@rentman/rm-core 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rm-core.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("moment")):"function"==typeof define&&define.amd?define(["moment"],t):"object"==typeof exports?exports.RmCore=t(require("moment")):e.RmCore=t(e.moment)}(window,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(e,t,r){"use strict";var n;r.d(t,"e",function(){return n}),r.d(t,"a",function(){return i}),r.d(t,"b",function(){return o}),r.d(t,"h",function(){return s}),r.d(t,"g",function(){return c}),r.d(t,"d",function(){return u}),r.d(t,"f",function(){return a}),r.d(t,"c",function(){return l}),function(e){e.CACHED="cached",e.PROMISED="promised",e.EXPAND="expand",e.PROMISED_EXPAND="promised-expand",e.RESOLVE="resolve",e.RESOLVE_VALUES="resolve-values",e.LOCAL="local"}(n||(n={}));var i="7",o=">",s=":",c="-1",u="-2",a="new-",l="dup-"},function(e,t,r){"use strict";function n(e,t){if(void 0===e)return t;var r={};for(var n in t)r[n]=void 0===e[n]?t[n]:e[n];return r}function i(e){for(var t in e)return!0;return!1}function o(e){if("object"!=typeof e)return null;for(var t in e)return t;return null}function s(e,t){for(var r=0,n=t;r<n.length;r++){if(e==n[r])return!0}return!1}function c(e,t){for(var r=[],n=0,i=e;n<i.length;n++){var o=i[n];t(o)&&r.push(o)}if(r.length===e.length)return!1;u(e);for(var s=0,c=r;s<c.length;s++){var a=c[s];e.push(a)}return!0}function u(e){e.splice(0)}function a(e,t){if(void 0===e)return!1;for(var r=0,n=t;r<n.length;r++){var i=n[r];if(void 0===e[i])return!1;e=e[i]}return!0}function l(e,t,r){for(var n=0;n<t.length;n++){var i=t[n];void 0===e[i]&&(e[i]=r[n]),e=e[i]}return e}function h(e,t,r){if(void 0===r&&(r=!1),void 0!==e){for(var n=0,i=t;n<i.length;n++){if(void 0===(e=e[i[n]])&&!r)return}return e}}function p(e,t,r){for(var n=0,i=t.length;n<i;++n){var o=t[n];if(m(o)||S(o))for(var s=Object.keys(o),c=0,u=s.length;c<u;c++){var a=s[c],l=o[a];r&&m(l)?C(l)?e[a]=new Date(l.valueOf()):R(l)?e[a]=new RegExp(l):l.nodeName?e[a]=l.cloneNode(!0):q(l)?e[a]=l.clone():(m(e[a])||(e[a]=I(l)?[]:{}),p(e[a],[l],!0)):e[a]=l}}return e}function f(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return p(e,t,!1)}function d(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return p(e,t,!0)}function m(e){return null!==e&&"object"==typeof e}function y(e){return null!==e&&"object"==typeof e&&!Object.getPrototypeOf(e)}function v(e){return"string"==typeof e}function g(e){return"number"==typeof e}function C(e){return"[object Date]"===toString.call(e)}r.d(t,"y",function(){return n}),r.d(t,"i",function(){return i}),r.d(t,"g",function(){return o}),r.d(t,"j",function(){return s}),r.d(t,"f",function(){return c}),r.d(t,"c",function(){return u}),r.d(t,"x",function(){return a}),r.d(t,"b",function(){return l}),r.d(t,"h",function(){return h}),r.d(t,"e",function(){return f}),r.d(t,"w",function(){return d}),r.d(t,"s",function(){return m}),r.d(t,"l",function(){return y}),r.d(t,"u",function(){return v}),r.d(t,"r",function(){return g}),r.d(t,"n",function(){return C}),r.d(t,"k",function(){return I}),r.d(t,"q",function(){return S}),r.d(t,"t",function(){return R}),r.d(t,"m",function(){return F}),r.d(t,"p",function(){return q}),r.d(t,"v",function(){return E}),r.d(t,"o",function(){return b}),r.d(t,"d",function(){return O}),r.d(t,"a",function(){return j});var I=Array.isArray;function S(e){return"function"==typeof e}function R(e){return"[object RegExp]"===toString.call(e)}function F(e){return"boolean"==typeof e}function q(e){return!(!e||!(e.nodeName||e.prop&&e.attr&&e.find))}function E(e){return e&&e.window===e}function b(e){return void 0!==e}function O(e,t){if(e===t)return!0;if(null===e||null===t)return!1;if(e!=e&&t!=t)return!0;var r,n,i,o,s,c=typeof e;if(c===typeof t&&"object"===c){if(!I(e)){if(C(e))return!!C(t)&&(o=e.getTime(),s=t.getTime(),o===s||o!=o&&s!=s);if(R(e))return!!R(t)&&e.toString()===t.toString();if(E(e)||E(t)||I(t)||C(t)||R(t))return!1;for(n in i=Object.create(null),e)if(!S(e[n])){if(!O(e[n],t[n]))return!1;i[n]=!0}for(n in t)if(!(n in i)&&b(t[n])&&!S(t[n]))return!1;return!0}if(!I(t))return!1;if(r=e.length,e.length===t.length){for(n=0;n<r;n++)if(!O(e[n],t[n]))return!1;return!0}}return!1}function j(e,t,r){var n=[],i=[];if(r=function(e){return g(e)&&e>0}(r)?r:NaN,t){if(e===t)throw new Error("Can't copy! Source and destination are identical.");if(I(t))t.length=0;else for(var o in t)delete t[o];return n.push(e),i.push(t),s(e,t,r)}return c(e,r);function s(e,t,r){if(--r<0)return"...";if(I(e))for(var n=0,i=e.length;n<i;n++)t.push(c(e[n],r));else if(y(e))for(var o in e)t[o]=c(e[o],r);else if(e&&"function"==typeof e.hasOwnProperty)for(var o in e)e.hasOwnProperty(o)&&(t[o]=c(e[o],r));else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=c(e[o],r));return t}function c(e,t){if(void 0===t&&(t=5),!m(e))return e;var r=n.indexOf(e);if(-1!==r)return i[r];if(E(e))throw new Error("Can't copy! Making copies of Window instances is not supported.");var o=!1,u=function(e){switch(toString.call(e)){case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Float32Array]":case"[object Float64Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return new e.constructor(c(e.buffer),e.byteOffset,e.length);case"[object ArrayBuffer]":if(!e.slice){var t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}return e.slice(0);case"[object Boolean]":case"[object Number]":case"[object String]":case"[object Date]":return new e.constructor(e.valueOf());case"[object RegExp]":var r=new RegExp(e._source,e.toString().match(/[^/]*$/)[0]);return r.lastIndex=e.lastIndex,r;case"[object Blob]":return new e.constructor([e],{type:e.type})}if(S(e.cloneNode))return e.cloneNode(!0)}(e);return void 0===u&&(u=I(e)?[]:Object.create(Object.getPrototypeOf(e)),o=!0),n.push(e),i.push(u),o?s(e,u,t):u}}},function(e,t,r){"use strict";var n,i=r(4),o=r(1),s=function(){function e(){this.MOMENT_INVALID="Invalid date",this.SERVER_DATETIME_FORMAT="YYYY-MM-DD[T]HH:mm:ssZ",this.SERVER_TIME_FORMAT="HH:mm:ss",this.SERVER_DATE_FORMAT="YYYY-MM-DD"}return e.prototype.formatResponse=function(e,t){for(var r=0,n=t;r<n.length;r++){var i=n[r];e[i.path]=this.formatResponseValue(i.apiColumn.type,e[i.path])}return e},e.prototype.expandResponse=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n];e[o.path]=this.formatResponseValue(o.apiColumn.type,t[o.path])}return e},e.prototype.formatRequest=function(e,t,r){for(var n={},i=0,o=r;i<o.length;i++){var s=o[i],c=s.id,u=s.apiColumn,a=u.type;u.readOnly||(this.compareFields(a,e[c],t[c])||(n[c]=this.formatRequestValue(a,t[c])))}return n},e.prototype.formatRequestLocal=function(e,t){for(var r={},n=0,i=t;n<i.length;n++){var o=i[n],s=o.id,c=o.apiColumn;c.readOnly||(r[s]=this.formatRequestValue(c.type,e[s]))}return r},e.prototype.hasChanges=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n],s=o.id,c=o.apiColumn;if(!c.readOnly&&!this.compareFields(c.type,e[s],t[s]))return!0}return!1},e.prototype.getChanges=function(e,t,r){for(var n=[],i=0,o=r;i<o.length;i++){var s=o[i],c=s.id,u=s.apiColumn;u.readOnly||(this.compareFields(u.type,e[c],t[c])||n.push({oldValue:e[c],newValue:t[c],column:s.apiColumn}))}return n},e.prototype.copyFields=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n],s=o.path;t[s]=this.clone(o.apiColumn.type,e[s])}return t},e.prototype.shallowCopyFields=function(e,t,r,n){for(var i=0,o=n;i<o.length;i++){var s=o[i],c=s.path;r[c]=void 0!==e[c]?e[c]:this.clone(s.apiColumn.type,t[c])}return r},e.prototype.setDefaultValues=function(e,t){for(var r=0,n=t;r<n.length;r++){var i=n[r];e[i.id]=this.getDefaultValue(i.apiColumn.type)}return e},e.prototype.compareFields=function(e,t,r){if(void 0===t)return void 0===r;if(void 0===r)return!1;switch(e){case"date":case"time":case"datetime":return this.compareMomentObjects(t,r);case"duration":return this.compareDurations(t,r);case"id":case"item":case"link":case"child":case"sibling":return t==r;case"current":case"dimension":case"distance":case"double":case"filesize":case"number":case"power":case"quantity":case"volume":case"weight":case"coordinate":case"price":case"percentage":return this.compareFloats(t,r);case"int":case"bool":case"enum":case"email":case"phone":case"url":case"text":case"longtext":case"color":return t===r;default:return Object(o.d)(t,r)}},e.prototype.compareFloats=function(e,t){var r=Math.abs(e),n=Math.abs(t),i=Math.abs(e-t);return e===t||(0===e||0===t||i<Number.MIN_VALUE?i<1.19e-7*Number.MIN_VALUE:i/Math.min(r+n,Number.MAX_VALUE)<1.19e-7)},e.prototype.compareMomentObjects=function(e,t){return e.isValid()?!!t.isValid()&&e.isSame(t):!t.isValid()},e.prototype.compareDurations=function(e,t){return e.asMilliseconds()===t.asMilliseconds()},e.prototype.formatResponseValue=function(e,t){switch(e){case"datetime":case"date":return this.formatResponseDate(t);case"color":return this.formatResponseColor(t);case"duration":return this.formatResponseDuration(t);case"json":return"string"==typeof t&&""!==t?JSON.parse(t):t;case"number":return 0===t?null:t;case"filesize":return t/1e6;default:return t}},e.prototype.formatRequestValue=function(e,t){switch(e){case"datetime":return this.formatRequestDateTime(t);case"date":return this.formatRequestDate(t);case"color":return this.formatRequestColor(t);case"duration":return this.formatRequestDuration(t);case"number":return 0===t?null:t;default:return t}},e.prototype.formatResponseDate=function(e){return null===e?i.invalid():i(e)},e.prototype.formatResponseDuration=function(e){return i.duration(null===e?0:e,"seconds")},e.prototype.formatResponseColor=function(e){return"#"===e.charAt(0)?e:"#"+e},e.prototype.formatRequestDateTime=function(e){return e.isValid()?e.format(this.SERVER_DATETIME_FORMAT):null},e.prototype.formatRequestDate=function(e){return e.isValid()?e.format(this.SERVER_DATE_FORMAT):null},e.prototype.formatRequestDuration=function(e){return e.asSeconds()},e.prototype.formatRequestColor=function(e){return"#"===e.charAt(0)?e.substring(1):e},e.prototype.getDefaultValue=function(e){switch(e){case"int":case"double":case"percentage":case"price":return 0;case"item":case"link":case"child":case"sibling":return null;case"bool":return!1;case"enum":return"0";case"date":case"datetime":case"time":return i.invalid();case"duration":return i.duration();case"text":case"longtext":return"";case"color":return"#000000";default:return""}},e.prototype.isDefaultValue=function(e,t){return this.compareFields(e,t,this.getDefaultValue(e))},e.prototype.clone=function(e,t){switch(e){case"duration":return this.cloneDuration(t);case"date":case"datetime":return i(t);case"json":return Object(o.a)(t);default:return t}},e.prototype.getCloneFunction=function(e){switch(e){case"duration":return this.cloneDuration;case"date":case"datetime":return this.cloneDate;default:return this.identity}},e.prototype.cloneDuration=function(e){return i.duration(e)},e.prototype.cloneDate=function(e){return e.clone()},e.prototype.identity=function(e){return e},e}(),c=function(){function e(e,t){this.externalApiRequestService=e,this.apiResponseProcessorFactory=t}return e.prototype.template=function(e,t){return this.processResponse(this.externalApiRequestService.template(e,t))},e.prototype.create=function(e,t,r,n,i){return this.processResponse(this.externalApiRequestService.create(e,t,r,n,i))},e.prototype.delete=function(e,t){return this.processResponse(this.externalApiRequestService.delete(e,t))},e.prototype.updateItems=function(e,t,r){return this.processResponse(this.externalApiRequestService.updateItems(e,t,r))},e.prototype.requestSkeleton=function(e,t){return this.processResponse(this.externalApiRequestService.requestSkeleton(e,t))},e.prototype.moveItems=function(e,t,r){return this.processResponse(this.externalApiRequestService.moveItems(e,t,r))},e.prototype.columns=function(e,t,r){return this.processResponse(this.externalApiRequestService.columns(e,t,r))},e.prototype.query=function(e,t,r,n){return this.processResponse(this.externalApiRequestService.query(e,t,r,n))},e.prototype.processResponse=function(e){var t=this;return e.then(function(e){return t.apiResponseProcessorFactory.construct(e)})},e}(),u=function(){function e(e,t){this.apiFormatter=e,this.response=t,this.columnIndexMap={},this.columnMap={},this.columns=t.columns,this.items=t.items,this.links=t.links,this.cacheable=t.cacheable,this.map=t.map,this.createColumnMaps()}return e.prototype.createColumnMaps=function(){for(var e in this.columns){this.columnIndexMap[e]={},this.columnMap[e]={};for(var t=0;t<this.columns[e].length;t++){var r=this.columns[e][t];this.columnIndexMap[e][r.id]=t,this.columnMap[e][r.id]=r}}},e.prototype.fetchValue=function(e,t,r){if(void 0!==this.items[e][t])return this.items[e][t].data[this.columnIndexMap[e][r]]},e.prototype.fetchDerivedObject=function(e,t,r){for(var n={},i=0,o=r;i<o.length;i++){var s=o[i];this.fetchDerivedValues(this.fetchValue(e,t,s.id),s,n)}return n},e.prototype.fetchDerivedValues=function(e,t,r){for(var n=0,i=t.children;n<i.length;n++){var o=i[n],s=void 0;null===e?(s=null,r[o.path]=this.apiFormatter.getDefaultValue(o.apiColumn.type)):(s=this.fetchValue(t.itemType,e,o.id),r[o.path]=s),o.isLeaf||this.fetchDerivedValues(s,o,r)}},e.prototype.fetchObject=function(e,t,r){if((void 0===r&&(r=!1),void 0!==this.items[e])&&void 0!==this.items[e][t]){for(var n=this.items[e][t].data,i={},o=0;o<n.length;o++)i[this.columns[e][o].id]=n[o];if(r){var s=this.items[e][t].links;for(var c in i.__links={},s)i.__links[c]=this.fetchObjectArray(c,r,s[c])}return i}},e.prototype.fetchObjectArray=function(e,t,r){var n=[];if(null===r){for(var i in this.items[e])n.push(this.fetchObject(e,i,t));return n}void 0===r&&(r=this.links[e]);for(var o=0,s=r;o<s.length;o++){i=s[o];n.push(this.fetchObject(e,i,t))}return n},e.prototype.fetchObjectMap=function(e,t,r,n){var i=this.columnIndexMap[e][t],o={},s=[];for(var c in this.items[e]){var u=this.items[e][c].data[i];s.push(u),o[u]=this.fetchObject(e,c,r)}return n?{result:o,keys:s}:o},e.prototype.fetchFieldMap=function(e,t){var r=this.columnIndexMap[e][t],n={};for(var i in this.items[e])n[i]=this.items[e][i].data[r];return n},e.prototype.fetchColumnArray=function(e){for(var t=[],r=0,n=this.columns[e];r<n.length;r++){var i=n[r];t.push(i)}return t},e.prototype.fetchColumnObject=function(e){return this.columnMap[e]},e.prototype.fetchColumnsObject=function(){return this.columnMap},e.prototype.createResource=function(e,t){return{object:this.fetchObject(e,t),links:this.items[e][t].links}},e.prototype.hasItems=function(e){for(var t in this.items[e])return!0;return!1},e.prototype.getIdArray=function(e){var t=[];for(var r in this.items[e])t.push(r);return t},e}(),a=r(0),l=function(){function e(e,t,r){for(var n in this.promiseService=e,this.getItemId=t,this.getPromise=r,this.requestStatusArray=[a.e.RESOLVE,a.e.RESOLVE_VALUES,a.e.EXPAND,a.e.PROMISED_EXPAND],this.entries={},a.e)this.entries[a.e[n]]=[]}return e.prototype.add=function(e){var t=e.status;void 0===this.entries[t]&&(this.entries[t]=[]),this.entries[t].push(e.entry)},e.prototype.hasEntries=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.entries[n].length>0)return!0}return!1},e.prototype.hasRequests=function(){return this.hasEntries(this.requestStatusArray)},e.prototype.forEachEntry=function(e,t){for(var r=0,n=e;r<n.length;r++)for(var i=n[r],o=0,s=this.entries[i];o<s.length;o++){t(s[o])}},e.prototype.getPromises=function(){var e=this,t=[];return this.forEachEntry([a.e.PROMISED,a.e.PROMISED_EXPAND],function(r){t.push(e.getPromise(r))}),this.promiseService.all(t)},e.prototype.getRequestIds=function(){var e=this,t=[];return this.forEachEntry(this.requestStatusArray,function(r){t.push(e.getItemId(r))}),t},e.prototype.getArray=function(){var e=[];for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++){var i=n[r];e.push(i)}return e},e}(),h=function(){function e(e,t,r){this.collectionCacheFactory=e,this.singleItems=t,this.compilation={create:{},delete:{},update:{},move:{}},this.moveArray=[],this.deleteMap={},this.collections=this.collectionCacheFactory.construct(),this.processSingleItems(),this.processCollections(r),this.postProcess()}return e.prototype.getDefaultParent=function(){return{itemType:"Void",itemId:0}},e.prototype.addMoveEntry=function(e){this.moveArray.push(e)},e.prototype.addDeleteEntry=function(e,t,r){Object(o.b)(this.deleteMap,[e.itemType,e.itemId],[{},{parentId:t,item:e,parentType:r}])},e.prototype.addUpdateEntry=function(e){Object(o.b)(this.compilation.update,[e.itemType,e.itemId],[{},e])},e.prototype.addCreateEntry=function(e){var t=e.parent;null===t&&(t=this.getDefaultParent()),Object(o.b)(this.compilation.create,[t.itemType,t.itemId,e.itemType,e.itemId],[{},{},{},e])},e.prototype.postProcess=function(){for(var e=0,t=this.moveArray;e<t.length;e++){var r=(u=t[e]).itemId,n=this.deleteMap[u.itemType];if(void 0!==n&&void 0!==n[r]){var i=u.parent;(c=Object(o.b)(this.compilation.move,[i.itemType,i.itemId],[{},[]])).push(n[r]),delete n[r]}}for(var s in this.deleteMap)for(var r in this.deleteMap[s]){var c,u=this.deleteMap[s][r].item;void 0===(c=this.compilation.delete)[s]&&(c[s]=[]),c[s].push(u)}},e.prototype.processSingleItems=function(){for(var e=0,t=this.singleItems;e<t.length;e++){var r=t[e];r.isLocal()?this.addCreateEntry(r):r.hasChanges()&&this.addUpdateEntry(r)}},e.prototype.processCollections=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.collections.add(n),!n.isDeferred()){var i=n.parent;null===i&&(i=this.getDefaultParent());var o=void 0,s=void 0;n.isLocal()?(o=n.items,s=[]):n.hasEditResources?(o=n.getAddedItems(),s=n.getRemovedItems()):(o=[],s=[]);for(var c=0,u=o;c<u.length;c++){var a=u[c];a.isLocal()?this.addCreateEntry(a):this.addMoveEntry(a)}for(var l=0,h=s;l<h.length;l++){var p=h[l];this.addDeleteEntry(p,i.itemId,i.itemType)}if(n.hasItemEditResources)for(var f=0,d=n.getUpdatedItems();f<d.length;f++){var m=d[f];this.addUpdateEntry(m)}}}},e}(),p=function(){function e(e,t,r,n,i,o,s,c,u,a,l){this.apiRequestService=e,this.itemHandler=t,this.errorHandler=r,this.collectionHandler=n,this.changesCompilationFactory=i,this.createRequestFactory=o,this.columnExpansionFactory=s,this.requestColumnExpansionFactory=c,this.collectionEntryService=u,this.apiFormatter=a,this.promiseService=l}return e.prototype.getItemTypeUpdatePriority=function(e){switch(e){case"Factuurregelbedrag":return 0;case"Factuurregel":case"Minfactuur":return 1;default:return 2}},e.prototype.isDocumentItemType=function(e){switch(e){case"Bon":case"Offerte":case"Contract":case"Factuur":case"Materiaalbon":case"Contactbon":case"Inhuurbon":case"Medewerkerbon":case"Reparatiebon":case"Voertuigbon":case"Aanmaning":return!0}return!1},e.prototype.isDocumentUpdate=function(e){var t=e.update;for(var r in t)if(this.isDocumentItemType(r))return!0;return!1},e.prototype.buildMoveRequest=function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r].item,o=i.itemType;void 0===t[o]&&(t[o]=[]),t[o].push(i.itemId)}return t},e.prototype.getMapValue=function(e,t,r){if(void 0!==r&&void 0!==r[e])return r[e][t]},e.prototype.executeCreateRequests=function(e,t,r,n,i){for(var o=[],s=0,c=this.createRequestFactory.construct(e.compilation.create,e.collections,t,n).run();s<c.length;s++){var u=c[s];o.push(this.executeCreateRequest(u,r).then(a))}return this.promiseService.all(o).then(function(){return r},this.errorHandler.reject);function a(e){return void 0!==i&&i(r),e}},e.prototype.executeCreateRequest=function(e,t){var r=this;return this.apiRequestService.requestSkeleton(e.request).then(function(n){var i=n.map,o=n.fetchColumnsObject(),s=e.items;for(var c in s){var u=r.columnExpansionFactory.construct(c,e.request.columns[c],o);for(var a in s[c]){var l=s[c][a],h=r.getMapValue(c,a,i);if(void 0!==h){var p=n.fetchObject(c,h),f=u.run(l.columns);l.itemId=h,l.updateFields(p),null!==f&&l.expand(p,n.fetchDerivedObject(c,h,f.difference.root),f),r.itemHandler.entries.add(l)}else console.warn("Create failed!",l)}}for(var c in e.collections.addToCollections(),i)for(var a in void 0===t[c]&&(t[c]={}),i[c])t[c][a]=i[c][a]},this.errorHandler.reject)},e.prototype.prioritizeUpdateRequests=function(e,t){var r=[[],[],[]],n=this.promiseService.when();for(var i in e)r[this.getItemTypeUpdatePriority(i)].push(i);for(var o=0,s=r;o<s.length;o++){var c=s[o];0!==c.length&&(n=n.then(this.executeUpdateRequests(c,e,t),this.errorHandler.reject))}return n},e.prototype.executeUpdateRequests=function(e,t,r){var n=this;return function(){for(var i=[],o=0,s=e;o<s.length;o++){var c=s[o];i.push(n.executeUpdateRequest(c,t[c],r))}return n.promiseService.all(i)}},e.prototype.executeUpdateRequest=function(e,t,r){var n=this,i={},s=this.requestColumnExpansionFactory.construct(),c=this.collectionHandler.getCollectionMatcher();for(var u in i[e]={},t){var a=t[u],l=i[e][u]={},h=Object(o.h)(r,[e,u]);l.values=a.formatRequest(),void 0!==h&&(l.parameters=h),s.expand(a.columns),c.expand(a)}for(var p=0,f=c.getCollectionsWithFittingItems();p<f.length;p++){var d=f[p];s.expand(d.columns)}return this.apiRequestService.updateItems(e,i,s.get()).then(function(r){var i=n.columnExpansionFactory.construct(e,s.get(),r.fetchColumnsObject());for(var o in t){var u=t[o],a=r.fetchObject(e,o);if(void 0!==a){var l=n.apiFormatter.copyFields(u.initial,{},u.columns.main);u.updateFields(a,r.fetchDerivedObject(e,o,u.columns.root)).callOnChange(l);var h=i.run(u.columns);null!==h&&u.expand(a,r.fetchDerivedObject(e,o,h.difference.root),h)}else console.warn("Update failed!",u)}c.removeFromAndAddToCollections()},this.errorHandler.reject)},e.prototype.executeDeleteRequests=function(e){var t=[];for(var r in e)t.push(this.executeDeleteRequest(r,e[r]));return this.promiseService.all(t)},e.prototype.executeDeleteRequest=function(e,t){for(var r=this,n=[],i=0,s=t;i<s.length;i++){var c=s[i];n.push(c.itemId)}return this.apiRequestService.delete(e,n).then(function(e){for(var n=e.items,i=r.collectionHandler.getCollectionMatcher(),s=0,c=t;s<c.length;s++){var u=c[s];Object(o.j)(u.itemId,n)||console.warn("Delete failed!",u),i.expand(u)}i.removeFromCollections()},this.errorHandler.reject)},e.prototype.executeMoveRequests=function(e,t){var r=this,n=[];for(var i in e)for(var o in e[i])s(i,o);return this.promiseService.all(n);function s(i,o){var s=e[i][o],c=r.getMapValue(i,o,t);n.push(r.apiRequestService.moveItems(i,void 0!==c?c:o,r.buildMoveRequest(s)).then(function(){r.processMoveResponse(s)},r.errorHandler.reject))}},e.prototype.processMoveResponse=function(e){for(var t=[],r={},n={},i=0,o=e;i<o.length;i++){var s=o[i],c=s.item;this.addCollectionMapEntry(r,s.parentId,c,c.itemId),this.addCollectionMapEntry(n,c.parent.itemId,c,c),t.push(c)}this.forEachCollection(r,"removeItems"),this.forEachCollection(n,"addItems")},e.prototype.addCollectionMapEntry=function(e,t,r,n){Object(o.b)(e,[r.parent.itemType,t,r.itemType],[{},{},[]]).push(n)},e.prototype.forEachCollection=function(e,t){for(var r in e)for(var n in e[r])for(var i in e[r][n]){var o=this.collectionHandler.entries.getByParent(r,n,i);null!==o&&o[t](e[r][n][i],null,!0)}},e.prototype.onItemsCreated=function(e,t,r){if(Object(o.i)(e)){for(var n=0,i=r;n<i.length;n++){var s=i[n],c=s.parent,u=s.getUpdatedItemColumns(e);if(null!==c)void 0!==(d=this.getMapValue(c.itemType,c.itemId,e))&&(c.itemId=d,s.query=this.collectionEntryService.createQuery(s.options),this.collectionHandler.entries.add(s));if(Object(o.i)(u)){void 0!==u.id&&s.onItemsCreated(e[s.itemType]);for(var a=0,l=s.items;a<l.length;a++){(f=l[a]).updateItemFields(e)}}}for(var h=0,p=t;h<p.length;h++){var f,d,m=(f=p[h]).parent;if(f.updateItemFields(e),null!==m)void 0!==(d=this.getMapValue(m.itemType,m.itemId,e))&&(m.itemId=d)}}},e.prototype.execute=function(e,t,r,n,i){var o=this;void 0===r&&(r={});var s=this.errorHandler,c=this.changesCompilationFactory.construct(e,t),u=c.compilation,a={},l=this.executeCreateRequests(c,r,a,n,i).then(function(){return o.onItemsCreated(a,e,t),o.executeMoveRequests(u.move,a)},function(r){return o.onItemsCreated(a,e,t),s.reject(r)});return(l=this.isDocumentUpdate(u)?l.then(function(){return o.executeDeleteRequests(u.delete)},s.reject).then(function(){return o.prioritizeUpdateRequests(u.update,r)},s.reject):l.then(function(){return o.prioritizeUpdateRequests(u.update,r)},s.reject).then(function(){return o.executeDeleteRequests(u.delete)},s.reject)).then(function(){return a},s.reject)},e}();!function(e){e.MAYBE="maybe"}(n||(n={}));var f,d=function(){function e(e){this.queryMatcherFactory=e,this.entries={}}return e.prototype.contains=function(e){var t=this.entries[e.itemType];return void 0!==t&&void 0!==t[e.id]},e.prototype.some=function(e){var t=this.entries;for(var r in t)for(var n in t[r])if(e(t[r][n]))return!0;return!1},e.prototype.forEach=function(e){var t=this.entries;for(var r in t)for(var n in t[r])e(t[r][n])},e.prototype.toArray=function(){var e=this.entries,t=[];for(var r in e)for(var n in e[r])t.push(e[r][n]);return t},e.prototype.add=function(e){var t=this.entries,r=e.itemType;return void 0===t[r]&&(t[r]={}),t[r][e.id]=e},e.prototype.clear=function(e){return void 0===e?(this.entries={},!0):!!this.contains(e)&&delete this.entries[e.itemType][e.id]},e.prototype.getByItemType=function(e){var t=this.entries[e],r=[];if(void 0===t)return r;for(var n in t)r.push(t[n]);return r},e.prototype.matchParent=function(e,t,r){var n=e.parent;return null!==n&&(n.itemType===t&&n.itemId==r)},e.prototype.getByParent=function(e,t,r){var n=this.entries[r];if(void 0===n)return null;for(var i in n)if(this.matchParent(n[i],e,t))return n[i];return null},e.prototype.getResourceByParent=function(e,t,r){var n=this.getByParent(e,t,r);return null===n?null:n.getCurrentResource()},e.prototype.getCollectionsByParent=function(e,t){var r=this.entries,n=[];for(var i in r)for(var o in r[i]){var s=r[i][o];this.matchParent(s,e,t)&&n.push(s)}return n},e.prototype.getByContainingItem=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var i in r){var o=r[i];void 0!==o.getItemById(t)&&n.push(o)}return n},e.prototype.getByFittingItem=function(e,t,r){var i=this.entries[e],o={fitting:[],notfitting:[],maybe:[]};if(void 0===i)return o;var s=this.queryMatcherFactory.construct(e,t,r);for(var c in i){var u=i[c],a=s.matchQuery(u.query.object);!0===a?o.fitting.push(u):a===n.MAYBE?o.maybe.push(u):o.notfitting.push(u)}return o},e.prototype.getByQuery=function(e,t){var r=this.entries[e];if(void 0===r)return null;for(var n in r){var i=r[n];if(i.query.string===t.string)return i}return null},e.prototype.getByKey=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var i in r){var o=r[i];o.options.entryKey===t&&n.push(o)}return n},e.prototype.getResourceByKey=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var i in r)for(var o=0,s=r[i].resources;o<s.length;o++){var c=s[o];c.options.resourceKey===t&&n.push(c)}return n},e}(),m=function(){function e(e,t){this.queryParserFactory=e,this.queryService=t}return e.prototype.cloneOptions=function(e,t){var r=this.processOptions(e);return r.queryParams=this.cloneQueryParams(e.queryParams),r.parent=t,r},e.prototype.cloneQueryParams=function(e){var t={};for(var r in e){var n=e[r],o=void 0;o=Array.isArray(n)?n.slice():i.isMoment(n)?n.clone():n,t[r]=o}return t},e.prototype.processOptions=function(e){return Object(o.y)(e,{columns:[],query:null,queryItemType:null,queryParams:{},parent:null,deferRequest:!1,limit:null,entryKey:""})},e.prototype.createQuery=function(e){var t,r=e.parent;if(null===r)t=e.query;else{var n={linkedTo:r.itemType,query:{id:"&parentId"}};e.queryParams.parentId=r.itemId,t=null===e.query?n:this.queryService.addAndCondition(e.query,n)}var i=this.queryParserFactory.construct(t,e.queryParams).parse();return{object:i[0],string:i[1]}},e.prototype.getIdArray=function(e,t){void 0===t&&(t=[]);for(var r=0,n=e;r<n.length;r++){var i=n[r];t.push(i.itemId)}return t},e.prototype.filterArray=function(e,t){for(var r=[],n=[],i=0,o=e;i<o.length;i++){var s=o[i];(t(s)?r:n).push(s)}if(0===n.length)return n;e.length=r.length;for(var c=0;c<e.length;c++)e[c]=r[c];return n},e}(),y=r(6),v=function(){function e(e,t,r,n,i,o,s,c,u,a,l,h){this.errorHandler=e,this.itemRequestService=t,this.columnHandler=r,this.columnSetFactory=n,this.collectionEntryFactory=i,this.collectionCacheFactory=o,this.queryParserFactory=s,this.collectionEntryService=c,this.keyService=u,this.promiseService=a,this.queryService=l,this.collectionMatcherFactory=h,this.entries=this.collectionCacheFactory.construct()}return e.prototype.getPromises=function(e){var t=e[a.e.PROMISED],r=e[a.e.PROMISED_EXPAND],n=[];for(var i in t)n.push(t[i]);for(var i in r)n.push(r[i]);return n},e.prototype.getRequestIds=function(e){var t=e[a.e.RESOLVE],r=e[a.e.EXPAND],n=[];for(var i in t)n.push(t[i].parent.itemId);for(var i in r)n.push(r[i].parent.itemId);return n},e.prototype.removeFromAndAddToCollections=function(e,t){for(var r in e){var n=e[r],i=n.collection;i.removeItems(n.notfitting,null,!0),i.addItems(n.fitting,null,!0),n.maybe.length>0&&i.extend(y.identity,null,!0,t)}},e.prototype.getCollectionMatcher=function(){return this.collectionMatcherFactory.construct([this.entries],!0,!0)},e.prototype.removeFromCollections=function(e,t,r){var n;for(var i in void 0===r&&(r=null),e){for(var o=e[i],s=o.fitting,c=o.maybe,u=o.collection,a=[],l=0,h=s;l<h.length;l++){var p=h[l];a.push(p.itemId)}for(var f=0,d=c;f<d.length;f++){var m=d[f];a.push(m)}null!==r&&u===r.entry?n=u.removeItems(a,r,t):u.removeItems(a,null,t)}return n},e.prototype.addToCollections=function(e,t,r){var n;for(var i in void 0===r&&(r=null),e){var o=e[i],s=o.collection;s.isDeferred()||(null!==r&&s===r.entry?n=s.addItems(o.fitting,r,t):s.addItems(o.fitting,null,t),t&&o.maybe.length>0&&s.extend(y.identity,null,!0,t))}return n},e.prototype.batchExpand=function(e,t,r,n){var i=this;if(0===n.length)return this.promiseService.when(r);var o=[],s=[];for(var c in r){var u=r[c].entry;u.defer(),o.push(u.parent.itemId),s=s.concat(u.items)}return this.itemRequestService.requestLinkItems(e,o,t,null,n).then(function(e){for(var c=i.itemRequestService.processExpansion(n,e,t,s),u=0,a=o;u<a.length;u++){var l=a[u],h=r[l].entry;h.expandColumns(c),h._resolve()}return r})},e.prototype.batchExtend=function(e,t,r,n,i,s){var c=this;if(void 0===s&&(s=!1),!Object(o.i)(i))return this.promiseService.when({});var u=[],a=[];for(var l in r.queryParams=n(r.queryParams),i){var h=i[l].entry;h.extendQuery(n),u.push(h.parent.itemId),a=a.concat(h.getIdArray())}return this.itemRequestService.requestLinkItems(e,u,t,this.queryService.addAndCondition(this.collectionEntryService.createQuery(r).object,this.queryService.createNotIn(a)),r.columns).then(function(n){return c.itemRequestService.processLinkResponse(n,e,u,t,r)},this.errorHandler.reject).then(function(e){for(var t={},r=0,n=u;r<n.length;r++){var o=n[r],c=i[o],a=c.entry.addItems(e.items[o],c);t[o]=s?c.items:a}return t},this.errorHandler.reject)},e.prototype.batchFetch=function(e,t,r,n,i,s,c){var u=this,l=this.createStatusResource(e,t,r,n,s,c);return this.promiseService.all(this.getPromises(l)).then(function(){var t=u.getRequestIds(l);return t.length>0?u.itemRequestService.requestLinkItems(e,t,r,null===n.query?null:u.queryParserFactory.construct(n.query,n.queryParams).parse()[0],n.columns).then(function(i){return u.itemRequestService.processLinkResponse(i,e,t,r,n)},u.errorHandler.reject).then(function(e){return u.handleBatchResponse(l,e,i)},u.errorHandler.reject):Object(o.i)(l[a.e.LOCAL])?u.columnHandler.fetch(r,n.columns).then(function(e){return u.handleBatchResponse(l,{columns:u.columnSetFactory.construct(r,n.columns,e,!1)},i)},u.errorHandler.reject):l[a.e.CACHED]},this.errorHandler.reject)},e.prototype.createStatusResource=function(e,t,r,n,i,o){var s={};for(var c in a.e)s[a.e[c]]={};for(var u=0,l=t;u<l.length;u++){var h=l[u],p=this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:h}),f=this.getEntryStatus(r,p,i,o);s[f.status][h]=f.entry}return s},e.prototype.fetch=function(e,t,r,n,i){var o=this.errorHandler,s=this.getEntryStatus(e,t,n,i),c=s.entry;switch(s.status){case a.e.CACHED:return this.promiseService.when(c);case a.e.PROMISED:return c.promise;case a.e.EXPAND:return c.expand(t.columns).then(function(){return c._resolve()},o.reject);case a.e.PROMISED_EXPAND:return c.promise.then(function(){return c.defer().expand(t.columns)},o.reject).then(function(){return c._resolve()},o.reject);case a.e.LOCAL:return this.resolveLocal(c,r);default:return this.resolveRemote(c,r)}},e.prototype.getCachedEntryStatus=function(e,t){return e.columns.isSupersetOf(t.columns)?e.isDeferred()?a.e.PROMISED:e.reloadQueued?(e.reloadQueued=!1,e.isLocal()?a.e.CACHED:(e.defer(),a.e.RESOLVE)):a.e.CACHED:e.isDeferred()?a.e.PROMISED_EXPAND:(e.defer(),a.e.EXPAND)},e.prototype.getDeferredEntryStatus=function(e,t,r,n){var i;return t.deferRequest?null!==(i=n.getByQuery(e,r))?(i.expandRequestColumns(t.columns),{entry:i,isDeferred:!1}):(i=this.collectionEntryFactory.construct(e,t),{entry:n.add(i),isDeferred:!0}):{entry:i=this.collectionEntryFactory.construct(e,t),isDeferred:!1}},e.prototype.getEntryStatus=function(e,t,r,n){var i,o,s,c=this.collectionEntryService.createQuery(t);return this.isLocal(t)?null!==(i=r.getByQuery(e,c))?{entry:i,status:this.getCachedEntryStatus(i,t)}:(i=(o=this.getDeferredEntryStatus(e,t,c,n)).entry,o.isDeferred?{entry:i,status:a.e.PROMISED}:{entry:r.add(i),status:a.e.LOCAL}):null!==(i=this.entries.getByQuery(e,c))?{entry:r.add(i),status:this.getCachedEntryStatus(i,t)}:(i=(s=this.getDeferredEntryStatus(e,t,c,n)).entry,s.isDeferred?{entry:i,status:a.e.PROMISED}:(r.add(i),this.entries.add(i),{entry:i,status:a.e.RESOLVE}))},e.prototype.handleBatchResponse=function(e,t,r){var n={};for(var i in e.cached)n[i]=e.cached[i];for(var i in e.resolve){var o=e.resolve[i];n[i]=o.resolve({items:t.items[i].concat(r.getLocalByQuery(o.itemType,o.query)),columns:t.columns})}for(var i in e.expand){(o=e.expand[i]).expandColumns(t.columnExpansion),n[i]=o._resolve()}for(var i in e.local){o=e.local[i];n[i]=o.resolve({items:r.getByQuery(o.itemType,o.query),columns:t.columns})}return n},e.prototype.resolveLocal=function(e,t){var r=this,n=e.itemType,i=e.options.columns;return this.columnHandler.fetch(n,i).then(function(o){return e.resolve({items:t.getByQuery(n,e.query),columns:r.columnSetFactory.construct(n,i,o,!1)})},this.errorHandler.reject)},e.prototype.resolveRemote=function(e,t){var r,n=this,i=e.itemType;return this.itemRequestService.requestItems(e).then(function(t){return r=n.columnSetFactory.construct(i,e.options.columns,t.fetchColumnsObject()),n.itemRequestService.processResponse(t,t.links[i],e.parent,r)},this.errorHandler.reject).then(function(n){return e.resolve({items:n.concat(t.getLocalByQuery(i,e.query)),columns:r})},this.errorHandler.reject)},e.prototype.isLocal=function(e){var t=e.parent;return null!==t&&this.keyService.isLocalId(t.itemId)},e}(),g=function(){function e(e,t,r,n){this.queryMatcherFactory=e,this.collectionCaches=t,this.updateInitial=r,this.callOnActivate=n,this.map={}}return e.prototype.expand=function(e){for(var t=e.itemId,r=this.queryMatcherFactory.construct(e.itemType,e.getFields(),e.parent),n=0,i=this.collectionCaches;n<i.length;n++)for(var o=0,s=i[n].getByItemType(e.itemType);o<s.length;o++){var c=s[o],u=c.id,a=void 0;void 0===this.map[u]&&(this.map[u]={collection:c,matches:{}}),void 0===(a=this.map[u].matches)[t]&&(a[t]={item:e,isMatch:r.matchQuery(c.query.object)})}return this},e.prototype.getCollectionsWithFittingItems=function(){var e=[];for(var t in this.map){var r=this.map[t];this.hasFittingItems(r.matches)&&e.push(r.collection)}return e},e.prototype.addToCollections=function(e){void 0===e&&(e=null);var t=null;for(var r in this.map){var n=this.map[r],i=n.collection,o=this.groupItemEntries(n.matches),s=o.fitting;i.isDeferred()||(null!==e&&i===e.entry?t=i.addItems(s,e,this.updateInitial,!0,this.callOnActivate):i.addItems(s,null,this.updateInitial,!0,this.callOnActivate),this.updateInitial&&o.maybe.length>0&&i.extend(y.identity,null,!0,this.updateInitial))}return t},e.prototype.removeFromCollections=function(e){void 0===e&&(e=null);var t=null;for(var r in this.map){var n=this.map[r],i=n.collection,o=this.groupItemIds(n.matches).fitting;null===e||i!==e.entry?t=i.removeItems(o,e,this.updateInitial):i.removeItems(o,null,this.updateInitial)}return t},e.prototype.removeFromAndAddToCollections=function(){for(var e in this.map){var t=this.map[e],r=t.collection,n=this.groupItemEntries(t.matches);r.removeItems(n.notFitting,null,this.updateInitial),r.addItems(n.fitting,null,this.updateInitial),n.maybe.length>0&&r.extend(y.identity,null,!0,this.updateInitial)}},e.prototype.groupItemEntries=function(e){var t=[],r=[],n=[];for(var i in e){var o=e[i],s=o.item,c=o.isMatch;!0===c?t.push(s):!1===c?r.push(s.itemId):n.push(s)}return{fitting:t,notFitting:r,maybe:n}},e.prototype.groupItemIds=function(e){var t=[],r=[];for(var n in e){var i=e[n];(!1===i.isMatch?r:t).push(i.item.itemId)}return{fitting:t,notFitting:r}},e.prototype.hasFittingItems=function(e){for(var t in e)if(!0===e[t].isMatch)return!0;return!1},e}(),C=function(){function e(){}return e.prototype.processOptions=function(e){return Object(o.y)(e,{editItems:!1,editCollection:!1,modInstant:!1,enableSave:!0,onItemsCreated:y.noop,onChange:y.noop,onAdd:y.noop,onRemove:y.noop,onAddInitial:y.noop,onRemoveInitial:y.noop,resourceKey:null,clearOnTabChange:!0,clearOnSubTabChange:!0,custom:null})},e.prototype.getIdArray=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];t.push(i.entry.itemId)}return t},e}(),I=function(){function e(e){this.columnUtil=e,this.cache={},this.allColumns={}}return e.prototype.setColumn=function(e,t){var r=this.cache;void 0===r[e]&&(r[e]={});var n=r[e],i=t.id;return void 0===n[i]&&(n[i]=t),n[i]},e.prototype.setColumns=function(e,t,r){var n={};for(var i in r){var o=r[i];for(var s in n[i]={},o)n[i][s]=this.setColumn(i,o[s])}return!0===t&&(this.allColumns[e]=!0),n},e.prototype.retrieve=function(e,t){if(!0===t)return this.containsAll(e)?{cached:this.getColumns(e),missing:[]}:{cached:{},missing:!0};var r={},n=[];return this.retrieveColumns(e,t,n,r),{cached:r,missing:n}},e.prototype.containsAll=function(e){return!0===this.allColumns[e]},e.prototype.getColumns=function(e){var t,r=this.cache;return(t={})[e]=void 0===r[e]?[]:r[e],t},e.prototype.retrieveColumns=function(e,t,r,n){this.retrieveColumn(e,"id",r,n);for(var i=0,o=t;i<o.length;i++){var s=o[i];this.retrieveColumn(e,s,r,n)}},e.prototype.retrieveColumn=function(e,t,r,n){var i=this.columnUtil.parseRequestColumn(t),o=this.getColumn(e,i.id);if(void 0!==o){if(void 0===n[e]&&(n[e]={}),n[e][i.id]=o,0!==i.children.length){var s,c=[];if(this.retrieveColumns(o.itemType,i.children,c,n),0!==c.length)r.push(((s={})[i.id]=c,s))}}else r.push(t)},e.prototype.getColumn=function(e,t){var r=this.cache[e];if(void 0!==r)return r[t]},e}(),S=function(){function e(e,t,r,n){if(this.columnUtil=e,this.itemType=t,this.responseColumns=n,this.expansionMap={},!0===r)for(var i in this.requestColumnsTrue=!0,this.requestColumns=[],n[t])this.requestColumns.push(i);else this.requestColumnsTrue=!1,this.requestColumns=r}return e.prototype.run=function(e){var t=e.id;return void 0!==this.expansionMap[t]?this.expansionMap[t]:this.columnUtil.isColumnSubset(this.requestColumns,e.request,e.requestColumnsTrue)?null:(this.expansionMap[t]=e.expand(this.requestColumns,this.requestColumnsTrue,this.responseColumns),this.expansionMap[t])},e}(),R=function(){function e(e,t,r,n,i){this.apiRequestService=e,this.errorHandler=t,this.promiseService=r,this.cache=n,this.columnUtil=i}return e.prototype.setColumn=function(e,t){return this.cache.setColumn(e,t)},e.prototype.setColumns=function(e,t,r){return this.cache.setColumns(e,t,r)},e.prototype.fetchItemTypeTranslations=function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r];t[i]=this.fetch(i,["id"])}return this.promiseService.all(t).then(function(e){var t={};for(var r in e)t[r]=e[r][r].id.name;return t},this.errorHandler.reject)},e.prototype.request=function(e,t,r){var n=this;void 0===r&&(r={filter:!1});var i,o=((i={})[e]=t,i);return this.apiRequestService.columns(e,o,r).then(function(r){return n.cache.setColumns(e,t,r.fetchColumnsObject())},this.errorHandler.reject)},e.prototype.fetch=function(e,t,r){var n=this,i=this.cache.retrieve(e,t);return!0!==i.missing&&0===i.missing.length?this.promiseService.when(i.cached):this.request(e,i.missing,r).then(function(e){return n.columnUtil.mergeResponseColumns(e,i.cached).merged})},e.prototype.fetchAll=function(e){return this.cache.containsAll(e)?this.promiseService.when(this.cache.getColumns(e)):this.request(e,!0)},e}(),F=function(){return function(e,t){void 0===t&&(t=null),this.apiColumn=e,this.parent=t,this.itemType="",this.children=[],this.isLeaf=!0;var r=e.id;this.id=r,null===t?(this.level=0,this.path=r,this.tailPath=""):(this.level=t.level+1,this.path=t.path+a.b+r,this.tailPath=0===t.level?r:t.tailPath+a.b+r)}}(),q={},E=0,b=function(){function e(e,t,r,n,i,o){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r,this.columnSetFactory=n,this.itemType=i,this.request=o,this.id=++E,this.response=q,this.link=null,this.main=[],this.derived=[],this.root=[],this.leaf=[],this.formatted={main:[],derived:[]},this.filtered=[],this.custom=[],this.searchable=[],this.item=[],this.notItem=[],this.requestColumnsTrue=!0===this.request}return e.prototype.resolve=function(e,t,r){return void 0===t&&(t=!0),void 0===r&&(r=!0),this.enableCaching=t,this.requestColumnsTrue?this.processResponseColumns(e):this.processRequestColumns(e,r),this},e.prototype.expandRequestColumns=function(e){var t=this.columnUtil.mergeRequestColumns(this.request,e).merged;this.request=t,this.requestColumnsTrue=!0===t},e.prototype.isSupersetOf=function(e){return this.columnUtil.isColumnSubset(e,this.request,this.requestColumnsTrue)},e.prototype.processResponseColumns=function(e){var t=this.itemType;for(var r in this.request=[],this.response=this.enableCaching?this.columnHandler.setColumns(this.itemType,!0,e):e,e[t])this.main.push(this.getColumnInfo(r,t,[],null,e)),this.request.push(r)},e.prototype.processRequestColumns=function(e,t){var r=this.itemType,n=this.request;if(this.response={},0!==n.length){for(var i=0,o=n;i<o.length;i++){var s=o[i];null!==(c=this.getRequestColumnInfo(s,r,null,e))&&(this.main.push(c),c.isLeaf||this.root.push(c))}var c;if(t&&void 0===this.response[r].id)null!==(c=this.getRequestColumnInfo("id",r,null,e))&&this.main.push(c)}},e.prototype.getRequestColumnInfo=function(e,t,r,n){var i,o=this.columnUtil.parseRequestColumn(e),s=o.id;if(void 0!==n[t]&&(i=n[t][s]),void 0===i)return console.warn("No api column for request column",s,"for itemType",t),null;this.enableCaching&&(i=this.columnHandler.setColumn(t,i));var c=this.response;return void 0===c[t]&&(c[t]={}),void 0===c[t][s]&&(c[t][s]=i),this.getColumnInfo(s,t,o.children,r,n)},e.prototype.getColumnInfo=function(e,t,r,n,i){var o=this.columnUtil,s=i[t][e],c=this.columnInfoFactory.construct(s,n),u=null!==n;if(u?this.derived.push(c):this[o.isItemColumn(s)?"item":"notItem"].push(c),o.isFormattedColumn(s)&&this.formatted[u?"derived":"main"].push(c),o.isFilteredColumn(s)&&this.filtered.push(c),o.isSearchableColumn(s)&&this.searchable.push(c),o.isCustomColumn(s)&&this.custom.push(c),"link"===s.type&&(this.link=c),0===r.length)return this.leaf.push(c),c;c.itemType=s.itemType,c.children=[],c.isLeaf=!1;for(var a=0,l=r;a<l.length;a++){var h=l[a],p=this.getRequestColumnInfo(h,s.itemType,c,i);null!==p&&c.children.push(p)}return c},e.prototype.expand=function(e,t,r){var n=this.columnUtil.mergeRequestColumns(this.request,e),i=this.columnUtil.mergeResponseColumns(this.response,r).merged,o=this.columnSetFactory.construct(this.itemType,n.merged,i),s=this.columnSetFactory.construct(this.itemType,n.difference,i,!1,!1);return o.requestColumnsTrue=this.requestColumnsTrue||t,{merged:o,difference:s}},e}(),O=function(){function e(){}return e.prototype.getColumnPath=function(e,t){for(var r="",n="",i=0,o=e;i<o.length;i++){n+=r+o[i].id,r=a.b}return null!==t&&(n+=a.h+t),n},e.prototype.getDateFormatOptions=function(e){var t=i(),r={"J-M-Y":t.format("DD-MM-YYYY"),"J-M":t.format("DD-MM"),"j+F+Y":t.format("D MMM YYYY"),"D+j+F+Y":t.format("dddd D MMM YYYY"),F:t.format("MMM"),f:t.format("MMMM"),D:t.format("dddd"),d:t.format("ddd")};return"datetime"===e&&Object(o.e)(r,{"J-M-Y+H:i":t.format("DD-MM-YYYY HH:mm"),"J-M+H:i":t.format("DD-MM HH:mm"),"j+F+Y+H:i":t.format("DD MMMM Y HH:mm"),"D+j+F+Y+H:i":t.format("dddd DD MMM Y HH:mm"),"H:i":t.format("HH:mm")}),r},e.prototype.isStringColumn=function(e){switch(e.type){case"email":case"phone":case"url":case"text":case"longtext":case"textreplace":return!0;default:return!1}},e.prototype.isFloatColumn=function(e){switch(e.type){case"double":case"volume":case"weight":case"distance":case"dimension":case"power":case"current":case"price":case"percentage":return!0;default:return!1}},e.prototype.isIntColumn=function(e){switch(e.type){case"int":case"number":case"quantity":return!0;default:return!1}},e.prototype.isNumberColumn=function(e){return this.isFloatColumn(e)||this.isIntColumn(e)},e.prototype.isCustomColumn=function(e){return"customfield"===e.fieldtype},e.prototype.isItemColumn=function(e,t){switch(void 0===t&&(t=!0),e.type){case"id":return t;case"item":case"child":case"sibling":case"link":return!0;default:return!1}},e.prototype.isDateColumn=function(e){switch(e.type){case"datetime":case"date":return!0;default:return!1}},e.prototype.isRenderedColumn=function(e){switch(e.type){case"datetime":case"date":case"duration":return!0;default:return!1}},e.prototype.isFilteredColumn=function(e){if("staffel"===e.id)return!0;if(void 0!==e.generator)return!0;switch(e.type){case"price":case"bool":case"enum":case"volume":case"weight":case"distance":case"dimension":case"quantity":case"email":case"url":case"datetime":case"date":case"time":case"duration":case"html":case"textreplace":case"longtext":case"percentage":return!0;default:return!1}},e.prototype.isFormattedColumn=function(e){switch(e.type){case"datetime":case"date":case"time":case"duration":case"color":case"json":case"number":case"filesize":return!0;default:return!1}},e.prototype.isSelectableColumn=function(e){switch(e.type){case"blob":case"coordinate":case"forceupdate":case"id":case"json":case"order":case"parentid":case"parenttype":case"password":case"token":return!1}return!0},e.prototype.hasLocationProperty=function(e,t){return 0!=(t&e.location)},e.prototype.isEditableColumn=function(e){if(e.readOnly)return!1;switch(e.type){case"date":case"datetime":case"duration":return!1}return!0},e.prototype.isSearchableColumn=function(e){switch(e.type){case"email":case"phone":case"text":case"longtext":case"html":return!0;default:return!1}},e.prototype.getDefaultWeight=function(e){switch(e.type){case"double":case"price":case"bool":case"int":case"percentage":case"color":case"number":case"power":case"current":return.5;case"url":case"enum":case"email":case"text":case"item":case"link":return 1.5;case"longtext":case"html":case"textreplace":return 2;case"date":case"datetime":case"time":case"duration":default:return 1}},e.prototype.getComparators=function(e){switch(e.type){case"dimension":case"weight":case"price":return["=",">","<"];case"date":case"datetime":case"time":case"duration":return[">","<"];default:return["=","!="]}},e.prototype.isColumnSubset=function(e,t,r){if(!0===e)return r;for(var n=0,i=e;n<i.length;n++){var o=i[n];if(!this.containsColumn(o,t))return!1}return!0},e.prototype.containsColumn=function(e,t){var r=this.parseRequestColumn(e),n=this.findColumn(r.id,t);if(-1===n)return!1;if(0===r.children.length)return!0;if("string"==typeof t[n])return!1;for(var i=0,o=r.children;i<o.length;i++){var s=o[i];if(!this.containsColumn(s,t[n][r.id]))return!1}return!0},e.prototype.responseColumnsAvailable=function(e,t,r){for(var n=0,i=t;n<i.length;n++){var o,s=i[n],c=this.parseRequestColumn(s),u=c.children,a=r[e];if(void 0===a)return!1;if(void 0===(o=a[c.id]))return!1;if(u.length>0&&!this.responseColumnsAvailable(o.itemType,u,r))return!1}return!0},e.prototype.copyRequestColumns=function(e){if(!0===e)return!0;for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];t.push(this.copyRequestColumn(i))}return t},e.prototype.copyRequestColumn=function(e){var t=this.parseRequestColumn(e);if(0===t.children.length)return t.id;for(var r,n=[],i=0,o=t.children;i<o.length;i++){var s=o[i];n.push(this.copyRequestColumn(s))}return(r={})[t.id]=n,r},e.prototype.mergeRequestColumns=function(e,t){if(!0===e)return{merged:!0,difference:[]};if(!0===t)return{merged:!0,difference:!0};for(var r=this.copyRequestColumns(e),n=[],i=0,o=t;i<o.length;i++){var s=o[i],c=this.mergeRequestColumn(s,r);null!==c&&n.push(c)}return{merged:r,difference:n}},e.prototype.mergeRequestColumn=function(e,t){var r=this.parseRequestColumn(e),n=this.findColumn(r.id,t);if(-1===n)return t.push(e),e;if(0===r.children.length)return null;"string"==typeof t[n]&&(t[n]=((i={})[r.id]=[],i));for(var i,o,s=[],c=0,u=r.children;c<u.length;c++){var a=u[c],l=this.mergeRequestColumn(a,t[n][r.id]);null!==l&&s.push(l)}return 0===s.length?null:((o={})[r.id]=s,o)},e.prototype.parseRequestColumn=function(e){var t="string"==typeof e,r=t?e:Object(o.g)(e);return{id:r,children:t?[]:e[r]}},e.prototype.mergeResponseColumns=function(e,t){var r={},n={};for(var i in e)if(void 0!==t[i]){var o=this.mergeResponseColumnMap(e[i],t[i]);r[i]=o.merged,n[i]=o.difference}else r[i]=e[i];for(var i in t)void 0===e[i]&&(r[i]=t[i],n[i]=t[i]);return{merged:r,difference:n}},e.prototype.mergeResponseColumnMap=function(e,t){var r={},n={};for(var i in e)r[i]=e[i];for(var i in t)Object(o.o)(e[i])||(r[i]=t[i],n[i]=t[i]);return{merged:r,difference:n}},e.prototype.isLocalColumnId=function(e){return"__"===e.substring(0,2)},e.prototype.processConfigColumns=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];this.isLocalColumnId(i)||this.processConfigColumn(this.parseConfigColumn(i),t)}return t},e.prototype.processLocalConfigColumns=function(e,t,r,n){for(var i={},o=0,s=t;o<s.length;o++){var c=s[o];i[c.id]=c}for(var u=0,l=e;u<l.length;u++){var h=l[u],p=h.split(a.h),f=p[0];this.isLocalColumnId(f)?void 0!==i[f]&&(n(h,i[f]),delete i[f]):r(h,f,p[1])}},e.prototype.consolidateColumns=function(e,t,r){var n=this,i=[],o=this.copyRequestColumns(r);return this.processLocalConfigColumns(e,t,function(e,t){n.processConfigColumn(t.split(a.b),o)},function(e,t){i.push(t),o=n.mergeRequestColumns(o,t.valueOptions.requestColumns).merged}),{request:o,local:i}},e.prototype.parseConfigColumn=function(e){return e.split(a.h)[0].split(a.b)},e.prototype.processConfigColumn=function(e,t){var r=e[0];if(1===e.length)-1===t.indexOf(r)&&t.push(r);else{var n,i=this.findColumnObject(r,t);-1===i&&(i=t.push(((n={})[r]=[],n))-1),this.processConfigColumn(e.slice(1),t[i][r])}},e.prototype.findColumnObject=function(e,t){for(var r=0;r<t.length;r++)if(Object(o.g)(t[r])===e)return r;return-1},e.prototype.findColumn=function(e,t){for(var r=0;r<t.length;r++){var n=t[r];if("string"!=typeof n){if(Object(o.g)(n)===e)return r}else if(n===e)return r}return-1},e}(),j=function(){function e(e,t,r,n,i,o,s,c){void 0===c&&(c=!1),this.collectionHandler=e,this.collectionMatcherFactory=t,this.keyService=r,this.requestColumnExpansionFactory=n,this.compilation=i,this.localCollectionCache=o,this.parameterMap=s,this.breakupByParent=c,this.requests=[]}return e.prototype.finalizeRequest=function(e){for(var t=e.collections.getCollectionsWithFittingItems(),r=e.columns,n=0,i=t;n<i.length;n++){var o=i[n];r.expand(o.columns)}return e.request.columns=r.get(),e},e.prototype.setRequestParent=function(e,t){var r=t.request;return"Void"!==e&&(r.parentType=e,r.parentId={},!0)},e.prototype.run=function(){if(this.breakupByParent)for(var e in this.compilation){var t=this.compilation[e];for(var r in t)if(!this.keyService.isLocalId(r)){var n=this.initializeRequest();this.extendRequest(t[r],this.setRequestParent(e,n)?r:null,n),this.requests.push(this.finalizeRequest(n))}}else for(var e in this.compilation){t=this.compilation[e],n=this.initializeRequest();var i=this.setRequestParent(e,n),o=!1;for(var r in t)this.keyService.isLocalId(r)||(this.extendRequest(t[r],i?r:null,n),o=!0);o&&this.requests.push(this.finalizeRequest(n))}return this.requests},e.prototype.initializeRequest=function(){return{request:{requestType:"create",items:{},columns:{}},columns:this.requestColumnExpansionFactory.construct(),items:{},collections:this.collectionMatcherFactory.construct([this.localCollectionCache,this.collectionHandler.entries],!0,!1)}},e.prototype.extendRequest=function(e,t,r){var n=r.request,i=r.items;for(var s in e)for(var c in void 0===n.itemType&&(n.itemType=s),void 0===i[s]&&(i[s]={},n.items[s]={}),e[s]){var u=e[s][c],a=Object(o.h)(this.compilation,[s,c]),l=n.items[s][c]={},h=Object(o.h)(this.parameterMap,[s,c]),p=void 0;if(null!==t&&(n.parentId[c]=t),r.columns.expand(u.columns),r.collections.expand(u),i[s][c]=u,l.values=u.formatRequest(),l.parameters=h,void 0!==a){for(var f in p=l.links={},a)for(var d in p[f]=[],a[f])p[f].push(d);this.extendRequest(a,null,r)}}},e}(),M=r(5),T=function(){function e(e,t,r,n,i,o,s,c,u,a,l,h,p,f,d,m,y){this.apiRequestService=e,this.authInterface=t,this.collectionEntryService=r,this.collectionHandler=n,this.collectionMatcherFactory=i,this.collectionResourceService=o,this.columnSetFactory=s,this.errorHandler=c,this.itemEntryService=u,this.itemHandler=a,this.itemRequestService=l,this.keyService=h,this.localCacheFactory=p,this.localCacheManager=f,this.moduleChangesCompilationFactory=d,this.promiseInterface=m,this.queryService=y}return e.prototype.invalidateCache=function(){this.itemHandler.entries.forEach(function(e){return e.queueReload()}),this.collectionHandler.entries.forEach(function(e){return e.queueReload()})},e.prototype.getItemDefinition=function(e,t,r){var n,i=this.keyService.parseStateKey(t);if(null===i)return{itemType:e,itemId:t,options:r,isNew:!1};switch(i.type){case"new":n=this.keyService.getLocalId();break;case"duplicate":r.duplicate=i.itemId,void 0===r.templateOptions&&(r.templateOptions={}),void 0===r.templateOptions.item&&(r.templateOptions.item=i.itemId),n=this.keyService.getLocalDuplicateId()}return{itemType:e,itemId:n,options:r,isNew:!0}},e.prototype.getCollectionMatcher=function(e,t){for(var r=this.getLocalCache(),n=this.collectionMatcherFactory.construct([r.collections],!1,!0),i=0,o=e;i<o.length;i++){var s=o[i];t&&r.items.add(s),n.expand(s)}return n},e.prototype.fetchTitle=function(e,t,r){return this.itemHandler.fetchTitle(e,t,r,this.getLocalCache().items)},e.prototype.getItemById=function(e,t,r){var n=this.getLocalCache();return this.itemHandler.fetchItem(e,t,this.itemEntryService.processOptions(r),n.items).then(function(e){return n.createItemResource(void 0!==e.linked?e.main:e,r,!1)},this.errorHandler.reject)},e.prototype.getItemsById=function(e,t,r){var n=this.getLocalCache();return this.itemHandler.fetchItems(e,t,this.itemEntryService.processOptions(r),n.items).then(function(e){return n.createItemResources(e,r)},this.errorHandler.reject)},e.prototype.getItemsByQuery=function(e,t,r){var n=this,i=this.getLocalCache(),o=this.itemEntryService.processOptions(r),s={};return s[e]=o.columns,this.apiRequestService.query(e,this.queryService.addParentCondition(t,o.parent),s).then(function(t){return n.itemRequestService.processResponse(t,t.links[e],o.parent,n.columnSetFactory.construct(e,o.columns,t.fetchColumnsObject()))},this.errorHandler.reject).then(function(e){return i.createItemResources(e,r)},this.errorHandler.reject)},e.prototype.getDuplicateById=function(e,t,r){void 0===r&&(r={}),r.edit=!0;var n=this.getItemDefinition(e,this.keyService.getDuplicateStateKey(t),r);return this.getItemByDef(n,!1)},e.prototype.getNewResource=function(e,t,r,n){var i=this;void 0===t&&(t={}),void 0===r&&(r=!1);var o=this.getLocalCache();return t.edit=!0,this.itemHandler.fetchItem(e,this.keyService.getLocalId(),this.itemEntryService.processOptions(t),o.items).then(function(e){var s=o.createItemResource(e.main,t,n,!0),c=i.processLinkedItems(e.linked,t,!0);return r?{main:s,linked:c}:s},this.errorHandler.reject)},e.prototype.getCollectionDef=function(e,t){return{itemType:e,options:{entry:this.collectionEntryService.processOptions(t),resource:this.collectionResourceService.processOptions(t)}}},e.prototype.getLinkCollectionsDef=function(e,t,r,n,i){return{itemType:r,linkType:e,linkIdArray:t,linkField:n,options:{entry:this.collectionEntryService.processOptions(i),resource:this.collectionResourceService.processOptions(i)}}},e.prototype.getCollection=function(e,t){var r=this,n=this.getLocalCache();return this.collectionHandler.fetch(e,this.collectionEntryService.processOptions(t),n.items,n.collections,n.deferredCollections).then(function(e){return n.createCollectionResource(e,r.collectionResourceService.processOptions(t))},this.errorHandler.reject)},e.prototype.getCollectionFromDef=function(e){var t=this.getLocalCache();return this.collectionHandler.fetch(e.itemType,e.options.entry,t.items,t.collections,t.deferredCollections).then(function(r){return t.createCollectionResource(r,e.options.resource)},this.errorHandler.reject)},e.prototype.getLinkCollection=function(e,t,r,n){var i=this,o=this.getLocalCache(),s=this.collectionEntryService.processOptions(n);return s.parent={itemType:e,itemId:t},this.collectionHandler.fetch(r,s,o.items,o.collections,o.deferredCollections).then(function(e){return o.createCollectionResource(e,i.collectionResourceService.processOptions(n))},this.errorHandler.reject)},e.prototype.getLinkCollections=function(e,t,r,n){var i=this,o=this.getLocalCache();return this.collectionHandler.batchFetch(e,t,r,this.collectionEntryService.processOptions(n),o.items,o.collections,o.deferredCollections).then(function(e){return o.createCollectionResources(e,i.collectionResourceService.processOptions(n))},this.errorHandler.reject)},e.prototype.getLinkCollectionsFromDef=function(e){var t=this.getLocalCache();return this.collectionHandler.batchFetch(e.linkType,e.linkIdArray,e.itemType,e.options.entry,t.items,t.collections,t.deferredCollections).then(function(r){return t.createCollectionResources(r,e.options.resource)},this.errorHandler.reject)},e.prototype.getAllLinkCollections=function(e,t,r){var n=this;return this.apiRequestService.query(e,{},{}).then(function(i){return n.getLinkCollections(e,i.links[e],t,r)},this.errorHandler.reject)},e.prototype.getItemByDef=function(e,t){var r=this,n=this.getLocalCache();return this.itemHandler.fetchItem(e.itemType,e.itemId,this.itemEntryService.processOptions(e.options),n.items).then(function(i){var o;return i instanceof M.f?o=i:(r.processLinkedItems(i.linked,e.options,!1),o=i.main),n.createItemResource(o,e.options,t,e.isNew)},this.errorHandler.reject)},e.prototype.cloneItem=function(e,t){return this.addSingleItem(e.entry.clone(),t,!1)},e.prototype.cloneCollection=function(e,t,r){var n=t.parent;return void 0===n&&(n=null),this.addCollection(e.entry.clone(n,r),t)},e.prototype.saveCurrentLocalCache=function(e,t,r,n){return this.getLocalCache().save(e,t,r,n)},e.prototype.getCurrentCollections=function(){return this.getLocalCache().collections},e.prototype.getCurrentItems=function(){return this.getLocalCache().items},e.prototype.getModuleChanges=function(e){if(void 0===e&&(e=this.getLocalCache()),void 0===e.rootItem)throw new Error("itemAdministrator: No root item for local cache "+e.id);return this.moduleChangesCompilationFactory.construct(e.rootItem,e.items,e.collections).process()},e.prototype.addSingleItem=function(e,t,r,n){return void 0===n&&(n=this.getLocalCache()),n.createItemResource(n.items.add(e),t,r)},e.prototype.addSingleItems=function(e,t){for(var r=this.getLocalCache(),n=[],i=0,o=e;i<o.length;i++){var s=o[i];n.push(this.addSingleItem(s,t,!1,r))}return n},e.prototype.addCollection=function(e,t){var r=this.getLocalCache();return r.collections.add(e),r.createCollectionResource(e,this.collectionResourceService.processOptions(t))},e.prototype.processLinkedItems=function(e,t,r){for(var n=this.getLocalCache(),i={},s=0,c=e;s<c.length;s++){var u=c[s],a=u.itemType,l=u.itemEntries,h=void 0;r&&(h=this.collectionMatcherFactory.construct([n.collections],!1,!1)),i[a]=[];for(var p=0,f=l;p<f.length;p++){var d=f[p];i[a].push(n.createItemResource(d,t)),r&&h.expand(d),"Projectnotitie"===a&&Object(o.b)(n.tabRequestParameters,[d.itemType,d.itemId],[{},{no_notification:!0}])}r&&h.addToCollections()}return i},e.prototype.getLocalCache=function(){return this.localCacheManager.getCurrentLocalCache(this.authInterface.getUniqueUserId())},e.prototype.resetLocalCache=function(){var e=this.getLocalCache(),t=this.localCacheFactory.construct();e.clearResources(),this.localCacheManager.setCurrentLocalCache(this.authInterface.getUniqueUserId(),t)},e.prototype.addToCollections=function(e,t){return this.getCollectionMatcher(e,!0).addToCollections(t)},e.prototype.removeFromCollections=function(e,t){return this.getCollectionMatcher(e,!1).removeFromCollections(t)},e.prototype.saveLocal=function(e){var t=e.entry;return t.setDisplayName(),this.addToCollections([t]),this.promiseInterface.when(e)},e.prototype.updateItemIdMap=function(e,t){if(void 0!==t)for(var r in t){var n=t[r];void 0!==e[r]&&(e[n]=e[r],delete e[r])}},e.prototype.createCollectionResource=function(e,t,r){return void 0===r&&(r=!0),this.addCollection(e,r?this.collectionResourceService.processOptions(t):t)},e.prototype.createItemResource=function(e,t,r){return this.addSingleItem(e,t,r)},e.prototype.onBeforeSave=function(e,t,r){return this.getLocalCache().onBeforeSave(e,t,r)},e.prototype.onSaveSuccess=function(e,t,r){return this.getLocalCache().onSaveSuccess(e,t,r)},e}(),k=function(){function e(e){this.queryMatcherFactory=e,this.entries={}}return e.prototype.some=function(e){var t=this.entries;for(var r in t)for(var n in t[r])if(e(t[r][n]))return!0;return!1},e.prototype.getByItemType=function(e){var t=this.entries[e],r=[];if(void 0===t)return r;for(var n in t)r.push(t[n]);return r},e.prototype.getByQuery=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var i in r){var o=r[i];o.isDeferred()||this.matchQuery(o,t)&&n.push(o)}return n},e.prototype.getLocalByQuery=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var i in r){var o=r[i];o.isLocal()&&(this.matchQuery(o,t)&&n.push(o))}return n},e.prototype.getByParent=function(e,t,r){var n=this.entries[r],i=[];if(void 0===n)return i;for(var o in n){var s=n[o],c=s.parent;null!==c&&(e===c.itemType&&t==c.itemId&&i.push(s))}return i},e.prototype.forEach=function(e){var t=this.entries;for(var r in t)for(var n in t[r])e(t[r][n])},e.prototype.toArray=function(){var e=this.entries,t=[];for(var r in e)for(var n in e[r])t.push(e[r][n]);return t},e.prototype.add=function(e){var t=this.entries,r=e.itemType;return void 0===t[r]&&(t[r]={}),t[r][e.itemId]=e},e.prototype.get=function(e,t){return void 0===this.entries[e]?void 0:this.entries[e][t]},e.prototype.contains=function(e,t){return void 0!==this.entries[e]&&void 0!==this.entries[e][t]},e.prototype.updateItemId=function(e,t){var r=this.entries[e.itemType];return delete r[t],r[e.itemId]=e},e.prototype.clear=function(e){return void 0===e?(this.entries={},!0):void 0!==this.entries[e.itemType]&&delete this.entries[e.itemType][e.itemId]},e.prototype.matchQuery=function(e,t){return!0===this.queryMatcherFactory.construct(e.itemType,e.getFields(),e.parent).matchQuery(t.object)},e}(),w=function(){function e(e,t){this.authInterface=e,this.keyService=t,this.undefinedItemError="Het opgevraagde item bestaat niet / Je hebt niet voldoende rechten om dit item te bekijken",this.ALL_PERMISSIONS=7}return e.prototype.processOptions=function(e){return Object(o.y)(e,{columns:!0,parent:null,templateOptions:{},templateColumns:{},deferRequest:!1})},e.prototype.createLocalConversionMap=function(e,t,r,n){void 0===r&&(r=!1);var i=n.links[e][0],o={};return o[e]={},o[e][i]=t,r&&this.expandLocalConversionMap(e,i,n,o),o},e.prototype.expandLocalConversionMap=function(e,t,r,n){var i=r.items[e][t].links;for(var o in i){var s=i[o];void 0===n[o]&&(n[o]={});for(var c=0,u=s;c<u.length;c++){var a=u[c];n[o][a]=this.keyService.getLocalId(),this.expandLocalConversionMap(o,a,r,n)}}},e.prototype.expandConversionMap=function(e,t,r){var n,i=e.itemType,o=e.itemId;return void 0===t[i]&&(t[i]={}),void 0!==(n=t[i])[o]?n[o]:(void 0===r&&(r=this.keyService.getLocalId()),n[o]=r)},e.prototype.batchExpandConversionMap=function(e,t){for(var r=0,n=e;r<n.length;r++){var i=n[r];this.expandConversionMap(i,t)}return t},e.prototype.getConversionValue=function(e,t,r){if(void 0!==r[e])return r[e][t]},e.prototype.batchClone=function(e,t){void 0===t&&(t={});var r=[];this.batchExpandConversionMap(e,t);for(var n=0,i=e;n<i.length;n++){var o=i[n];r.push(o.clone(t))}return r},e.prototype.getFullName=function(e,t,r){return e.trim().concat(" ",t).trim().concat(" ",r)},e.prototype.getTitleField=function(e){switch(e){case"Exemplaar":return"serienummer";case"Factuur":return"nummer";case"Files":return"friendlyname";case"Functie":case"Standaardfunctie":return"naamintern";case"Voorraadmutatie":return"omschrijving";case"Barcode":return"code";case"Betaalmiddel":case"Betalingsconditie":case"Briefpapier":case"TaxClass":case"TaxSchema":case"Condition":case"Factuurmoment":case"Functiegroep":case"Grootboek":case"Inhuur":case"Inhuurgroep":case"Inhuurmateriaal":case"Materiaal":case"MateriaalCat":case"Medewerkertarief":case"Notitie":case"Planningmateriaal":case"Project":case"Staffelgroep":case"Subproject":case"Taak":case"Tag":case"Template":case"Tijd":case"Titel":case"Type":case"Voertuig":return"naam";default:return"displayname"}},e.prototype.getLocalDefaultValues=function(){var e=this.authInterface;return{permissions:a.a,creator:e.getUserId(),created:i()}},e}(),x=function(){function e(e,t,r,n,i,o,s,c,u,a,l,h,p,f){this.apiFormatter=e,this.apiRequestService=t,this.batchStatusFactory=r,this.columnExpansionFactory=n,this.columnHandler=i,this.columnSetFactory=o,this.columnUtil=s,this.errorHandler=c,this.itemCacheFactory=u,this.itemEntryFactory=a,this.itemEntryService=l,this.keyService=h,this.promiseService=p,this.templateFactory=f,this.templates={},this.entries=this.itemCacheFactory.construct()}return e.prototype.fetchItem=function(e,t,r,n){var i=this,o=this.getEntryStatus(e,t,r,n),s=o.entry,c=o.status;return c===a.e.LOCAL?this.fetchTemplate(e,r.templateOptions,r.templateColumns).then(function(e){return i.resolveLocal(s,r.parent,e,n)},function(e){return s.reject(e),i.errorHandler.reject(e)}):this.resolveCached(s,c,r)},e.prototype.fetchItems=function(e,t,r,n){for(var i=this,o=this.batchStatusFactory.construct(function(e){return e.itemId},function(e){return e.deferred.promise}),s={},c=0,u=t;c<u.length;c++){var l=u[c];o.add(this.getEntryStatus(e,l,r,n))}return s.entries=o.getPromises(),o.hasRequests()&&(s.requests=this.requestItems(e,o.getRequestIds(),r.columns)),o.hasEntries([a.e.LOCAL])&&(s.template=this.fetchTemplate(e,r.templateOptions,r.templateColumns)),this.promiseService.all(s).then(function(t){return i.batchResolve(e,o,r.columns,t,n)},this.errorHandler.reject)},e.prototype.resolveCached=function(e,t,r){var n=this;switch(t){case a.e.CACHED:return this.promiseService.when(e);case a.e.PROMISED:return e.deferred.promise;case a.e.PROMISED_EXPAND:return e.deferred.promise.then(function(){return n.resolveCached(e,n.getCachedEntryStatus(e,r),r)},this.errorHandler.reject);case a.e.EXPAND:var i=this.columnUtil.mergeRequestColumns(e.columns.request,r.columns).difference;return this.requestItem(e,i).then(function(t){n.resolveExpansion(e,n.columnExpansionFactory.construct(e.itemType,i,t.fetchColumnsObject()),t)},function(t){e.reject(t)}),e.deferred.promise;case a.e.RESOLVE_VALUES:return this.requestItem(e).then(function(t){n.resolveRemoteValues(e,t)},function(t){e.reject(t)}),e.deferred.promise;default:return this.requestItem(e).then(function(t){n.resolveRemote(e,e.columns.resolve(t.fetchColumnsObject()),t)},function(t){e.reject(t)}),e.deferred.promise}},e.prototype.resolveLocal=function(e,t,r,n){var i=e.itemType,o=e.itemId,s=this.itemEntryService.createLocalConversionMap(i,o,!0,r.response);return e.columns=r.columns,null!==t&&e.setParent(t.itemType,t.itemId),e.setLocalFields(r.fields,s).resolve(),{main:e,linked:this.createLocalEntries(i,o,r,s,n)}},e.prototype.resolveExpansion=function(e,t,r){var n=e.itemType,i=e.itemId,o=t.run(e.columns);return null===o?e:(e.expand(r.fetchObject(n,i),r.fetchDerivedObject(n,i,o.difference.root),o),e.resolve())},e.prototype.resolveRemote=function(e,t,r){var n=this.getResponseFields(e,t,r);return null===n?null:e.resolveDeferred(n.initial,n.derived,t)},e.prototype.resolveRemoteValues=function(e,t){var r=this.getResponseFields(e,e.columns,t);return null===r?null:e.updateFields(r.initial,r.derived,!1).resolve()},e.prototype.getResponseFields=function(e,t,r){var n=e.itemType,i=e.itemId,o=r.fetchObject(n,i);return void 0===o?(e.reject(),this.entries.clear(e),null):{initial:o,derived:r.fetchDerivedObject(n,i,t.root)}},e.prototype.fetchTemplate=function(e,t,r){var n=this;void 0===t&&(t={}),void 0===r&&(r={});var i=Object(o.i)(t),s=Object(o.g)(r);if(!i){var c=this.templates[e];if(void 0!==c&&(null===s||this.columnUtil.responseColumnsAvailable(s,r[s],c.responseColumns)))return this.promiseService.when(c)}return this.promiseService.all({template:this.apiRequestService.template(e,t),additionalColumns:null===s?{}:this.columnHandler.fetch(s,r[s])}).then(function(t){var r=t.template,o=n.templateFactory.construct(e,r,t.additionalColumns);return!i&&r.cacheable&&(n.templates[e]=o),o},this.errorHandler.reject)},e.prototype.getEntryStatus=function(e,t,r,n){var i;return this.keyService.isLocalId(t)?void 0!==(i=n.get(e,t))?{entry:i,status:this.getCachedEntryStatus(i,r)}:(i=this.itemEntryFactory.constructDeferred(e,t,!0,!1),{entry:n.add(i),status:a.e.LOCAL}):void 0!==(i=this.entries.get(e,t))?{entry:n.add(i),status:this.getCachedEntryStatus(i,r)}:(i=this.itemEntryFactory.constructDeferred(e,t,r.columns,r.deferRequest),n.add(i),this.entries.add(i),{entry:i,status:r.deferRequest?a.e.PROMISED:a.e.RESOLVE})},e.prototype.isColumnSuperset=function(e,t){return e.isLocal()||e.columns.isSupersetOf(t)},e.prototype.getCachedEntryStatus=function(e,t){var r=t.columns;return e.isDeferred()?e.deferRequest?(e.columns.expandRequestColumns(r),a.e.RESOLVE):this.isColumnSuperset(e,r)?a.e.PROMISED:a.e.PROMISED_EXPAND:this.isColumnSuperset(e,r)?e.reloadQueued?(e.reloadQueued=!1,e.isLocal()?a.e.CACHED:(e.defer(),a.e.RESOLVE_VALUES)):a.e.CACHED:(e.defer(),a.e.EXPAND)},e.prototype.batchResolve=function(e,t,r,n,i){var o=this,s=n.requests,c=[a.e.EXPAND,a.e.PROMISED_EXPAND],u=[a.e.RESOLVE],l=!0;if(t.hasEntries(c)){var h=this.columnExpansionFactory.construct(e,r,s.fetchColumnsObject());t.forEachEntry(c,function(e){return o.resolveExpansion(e,h,s)})}if(t.hasEntries(u)){var p=this.columnSetFactory.construct(e,r,s.fetchColumnsObject());t.forEachEntry(u,function(e){null===o.resolveRemote(e,p,s)&&(l=!1)})}return t.forEachEntry([a.e.RESOLVE_VALUES],function(e){null===o.resolveRemoteValues(e,s)&&(l=!1)}),t.forEachEntry([a.e.LOCAL],function(e){return o.resolveLocal(e,null,n.template,i)}),l?t.getArray():this.errorHandler.reject()},e.prototype.createLocalEntries=function(e,t,r,n,i,o){var s=this;void 0===o&&(o=[]);var c=r.response,u={},a={},l=[];for(var h in c.items)h!==e&&-1===o.indexOf(h)&&(u[h]=this.columnSetFactory.construct(h,!0,r.responseColumns));var p=function(e,t,r){var h={itemType:e,itemId:t},f=c.items[e][r].links;for(var d in f)if(-1===o.indexOf(d)&&f.hasOwnProperty(d)){var m=f[d];void 0===a[d]&&l.push({itemType:d,itemEntries:a[d]=[]});for(var y=0,v=m;y<v.length;y++){var g=v[y],C=n[d][g],I=s.itemEntryFactory.constructLocalLinked(d,C,c.fetchObject(d,g),h,u[d],n);i.add(I),a[d].push(I),p(d,C,g)}}};return p(e,t,c.links[e][0]),l},e.prototype.fetchTitle=function(e,t,r,n){void 0===r&&(r=!0);var i=this.itemEntryService.getTitleField(e);return this.fetchItem(e,t,this.itemEntryService.processOptions({columns:[i],deferRequest:r}),n).then(function(e){return void 0!==e.main?e.main.getFields()[i]:e.getFields()[i]},this.errorHandler.reject)},e.prototype.resolveDerivedValues=function(e,t,r){for(var n=[],i=0,o=t;i<o.length;i++){var s=o[i];n.push(this.fetchDerivedValuesByColumn(e,s,r))}return this.promiseService.all(n).then(function(){return e},this.errorHandler.reject)},e.prototype.getDefaultValuesByColumn=function(e,t){var r=t.children;if(0!==r.length)for(var n=0,i=r;n<i.length;n++)for(var o=i[n],s=0,c=e;s<c.length;s++){c[s].derived[o.path]=this.apiFormatter.getDefaultValue(o.apiColumn.type)}},e.prototype.getItemIdByColumn=function(e,t){return 0===t.level?"link"===t.apiColumn.type&&null!==e.parent?e.parent.itemId:e.modified[t.path]:e.derived[t.path]},e.prototype.fetchDerivedValuesByColumn=function(e,t,r){var n=this,i=t.children;if(0===i.length)return this.promiseService.when();var o=i[0];if(1===i.length&&"id"===o.apiColumn.type){for(var s=0,c=e;s<c.length;s++){(h=c[s]).derived[o.path]=this.getItemIdByColumn(h,t)}return this.promiseService.when()}for(var u={},a=0,l=e;a<l.length;a++){var h=l[a],p=this.getItemIdByColumn(h,t);void 0===u[p]&&(u[p]=[]),u[p].push(h)}void 0!==u.null&&this.getDefaultValuesByColumn(u.null,t);var f=[];for(var p in u)"null"!==p&&f.push(+p);if(0===f.length)return this.promiseService.when();for(var d=[],m=0,y=i;m<y.length;m++){var v=y[m];d.push(v.id)}return this.fetchItems(t.itemType,f,{columns:d},r).then(function(e){for(var t=0,o=e;t<o.length;t++)for(var s=o[t],c=s.getFields(),a=0,l=u[s.itemId];a<l.length;a++)for(var h=l[a],p=0,f=i;p<f.length;p++){var d=f[p];h.derived[d.path]=c[d.id]}return n.resolveDerivedValues(e,i,r)},this.errorHandler.reject)},e.prototype.requestItem=function(e,t){return void 0===t&&(t=e.columns.request),this.requestItems(e.itemType,[e.itemId],t)},e.prototype.requestItems=function(e,t,r){return this.apiRequestService.query(e,{id:t},((n={})[e]=r,n));var n},e}(),D=function(){function e(e,t,r,n,i,o,s,c){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.columnExpansionFactory=n,this.columnSetFactory=i,this.itemEntryFactory=o,this.queryService=s,this.promiseService=c}return e.prototype.requestItem=function(e,t,r){var n,i=((n={})[e]=r,n);return this.apiRequestService.query(e,{id:t},i)},e.prototype.requestItems=function(e,t,r){void 0===t&&(t=e.query.object),void 0===r&&(r=e.options.columns);var n,i=e.options,o={requestType:"query",itemType:null===i.queryItemType?e.itemType:i.queryItemType,columns:(n={},n[e.itemType]=r,n),query:t,limit:null};return null!==i.limit&&(o.limit=i.limit),this.apiRequestService.requestSkeleton(o)},e.prototype.requestLinkItems=function(e,t,r,n,i){var o,s=((o={})[r]=i,o);return null===n?this.apiRequestService.query(e,{id:t},s):this.apiRequestService.query(r,this.queryService.addAndCondition(n,{linkedTo:e,query:{id:t}}),s)},e.prototype.processExpansion=function(e,t,r,n){for(var i=this.columnExpansionFactory.construct(r,e,t.fetchColumnsObject()),o=0,s=n;o<s.length;o++){var c=s[o];c.isLocal()||this.handleCachedItem(c,t,i)}return i},e.prototype.processResponse=function(e,t,r,n,i){var o=this;void 0===i&&(i=this.columnExpansionFactory.construct(n.itemType,!!n.requestColumnsTrue||n.request,n.response));for(var s=this.itemHandler,c=n.itemType,u=n.root,a=[],l=[],h=0,p=t;h<p.length;h++){var f=p[h],d=s.entries.get(c,f);void 0===d?(d=this.itemEntryFactory.construct(f,e.fetchObject(c,f),e.fetchDerivedObject(c,f,u),n),s.entries.add(d),a.push(d)):d.isDeferred()?d.deferRequest?a.push(d.resolveDeferred(e.fetchObject(c,f),e.fetchDerivedObject(c,f,u),n)):l.push(d.deferred.promise):d.reloadQueued?(d.reloadQueued=!1,d.updateFields(e.fetchObject(c,f),e.fetchDerivedObject(c,f,u),!1),a.push(d)):a.push(this.handleCachedItem(d,e,i)),null!==r&&(d.parent=r)}return this.promiseService.all(l).then(function(t){for(var r=0,n=t;r<n.length;r++){var s=n[r];a.push(o.handleCachedItem(s,e,i))}return a},this.errorHandler.reject)},e.prototype.handleCachedItem=function(e,t,r){var n=r.run(e.columns);return null===n?e:e.expand(t.fetchObject(e.itemType,e.itemId),t.fetchDerivedObject(e.itemType,e.itemId,n.difference.root),n)},e.prototype.processLinkResponse=function(e,t,r,n,i){for(var s=e.fetchColumnsObject(),c=this.columnSetFactory.construct(n,i.columns,s),u=this.columnExpansionFactory.construct(n,i.columns,s),a=e.items[t],l={},h=0,p=r;h<p.length;h++){var f=p[h];l[f]=Object(o.x)(a,[f,"links",n])?this.processResponse(e,a[f].links[n],{itemType:t,itemId:f},c,u):[]}return this.promiseService.all(l).then(function(e){return{items:e,columns:c,columnExpansion:u}},this.errorHandler.reject)},e}(),L=function(){function e(){}return e.prototype.processOptions=function(e){return Object(o.y)(e,{edit:!1,onChange:y.noop,onDeactivate:y.noop})},e.prototype.compareOptions=function(e,t){for(var r in e)if(e[r]!==t[r])return!1;return!0},e}(),A=function(){function e(){this.separator=":"}return e.prototype.getSingleKey=function(e,t){return e.concat(this.separator,String(t))},e.prototype.getCollectionCacheKey=function(e,t,r){return e.concat(this.separator,String(t),this.separator,r)},e.prototype.getCssKey=function(){return Array.prototype.join.call(arguments,"_")},e.prototype.parseStateKey=function(e){return 0===(e=e.toString()).indexOf(a.f)?{type:"new",template:e.substring(a.f.length)}:0===e.indexOf(a.c)?{type:"duplicate",itemId:e.substring(a.c.length)}:null},e.prototype.getDuplicateStateKey=function(e){return a.c+e},e.prototype.getNewStateKey=function(e){return a.f+e},e.prototype.getLocalId=function(){return+(a.g+this.getRandomString())},e.prototype.getLocalDuplicateId=function(){return+(a.d+this.getRandomString())},e.prototype.getRandomString=function(){return(""+Math.random()).split(".")[1].substr(0,8)},e.prototype.isLocalId=function(e){return void 0!==e&&(this.isNewId(e)||this.isDuplicateId(e))},e.prototype.isNewId=function(e){return e===a.f||(""+e).substring(0,a.g.length)===a.g},e.prototype.isDuplicateId=function(e){return e===a.c||(""+e).substring(0,a.d.length)===a.d},e}(),H=function(){function e(e,t,r,n,i,o,s,c,u,a){void 0===a&&(a=""),this.errorHandler=e,this.lockService=t,this.itemResourceFactory=r,this.collectionCacheFactory=n,this.changesProcessorFactory=i,this.itemCacheFactory=o,this.collectionResourceFactory=s,this.itemResourceService=c,this.promiseService=u,this.id=a,this.tabRequestParameters={},this.callbacks={onBeforeSave:{always:{},onClose:{},skipOnClose:{}},onSaveSuccess:{always:{},onClose:{},skipOnClose:{}}},this.changesInterval=null,this.hasChanges=!1,this.items=this.itemCacheFactory.construct(),this.collections=this.collectionCacheFactory.construct(),this.deferredCollections=this.collectionCacheFactory.construct()}return e.prototype.createItemResource=function(e,t,r,n){var i=this;return void 0===r&&(r=!1),r&&(this.rootItem=e),(t=this.itemResourceService.processOptions(t)).onDeactivate=function(e){return i.onDeactivateItem(e)},this.itemResourceFactory.construct(e,t,n)},e.prototype.createItemResources=function(e,t){for(var r=[],n=0,i=e;n<i.length;n++){var o=i[n];r.push(this.createItemResource(o,t))}return r},e.prototype.createCollectionResource=function(e,t){return this.collectionResourceFactory.construct(e,t,this)},e.prototype.createCollectionResources=function(e,t){var r={};for(var n in e)r[n]=this.createCollectionResource(e[n],t);return r},e.prototype.clearItem=function(e){this.clearItemEntry(e.entry)},e.prototype.clearItemEntry=function(e){this.items.clear(e),e.clearResources()},e.prototype.clearCollection=function(e){var t=e.entry;this.collections.clear(t),t.clearResources()},e.prototype.clearResources=function(e){void 0===e&&(e=!1),this.items.forEach(function(e){return e.clearResources()}),this.collections.forEach(function(t){return t.clearResources(e)}),this.deferredCollections.clear()},e.prototype.updateSingleItems=function(e){for(var t in e)for(var r in e[t]){var n=this.items.get(t,r);void 0!==n&&this.items.updateItemId(n,r)}},e.prototype.revertChanges=function(){var e=this;return this.items.forEach(function(e){return e.resetModified()}),this.collections.forEach(function(t){return e.resetCollection(t)}),this.hasChanges=!1,this.isLockable()?this.lockService.deleteLock(this.rootItem):this.promiseService.when()},e.prototype.resetCollection=function(e){if(e.hasEditResources&&e.revertChanges(),e.hasItemEditResources)for(var t=0,r=e.items;t<r.length;t++){r[t].resetModified()}},e.prototype.detectChanges=function(){var e=this;return!!this.hasChanges||(this.items.some(function(e){return e.hasChanges()})?this.hasChanges=!0:this.hasChanges=this.collections.some(function(t){return e.collectionHasChanges(t)}))},e.prototype.collectionHasChanges=function(e){return!(!e.hasEditResources||!e.hasAddedItems()&&!e.hasRemovedItems())||e.hasItemEditResources&&e.hasUpdatedItems()},e.prototype.isLockable=function(){return void 0!==this.rootItem&&this.rootItem.isLockable()},e.prototype.save=function(e,t,r,n){var i=this;return void 0===e&&(e=!1),void 0===t&&(t={}),this.detectChanges(),this.disableChangesWatcher(),(this.isLockable()?this.lockService.fetchLock(this.rootItem):this.promiseService.when()).then(function(){return i.executeCallbackEvent(i.callbacks.onBeforeSave,function(e){return e(i)},e)},this.errorHandler.reject).then(function(){var e=Object(o.e)({},i.tabRequestParameters,t);return i.tabRequestParameters={},i.changesProcessorFactory.construct().execute(i.items.toArray(),i.collections.toArray(),e,r,n)},this.errorHandler.reject).then(function(t){return i.isLockable()&&i.lockService.clearLock(i.rootItem),i.hasChanges=!1,e||i.updateSingleItems(t),i.executeCallbackEvent(i.callbacks.onSaveSuccess,function(e){return e(i,t)},e).then(function(){return e||i.enableChangesWatcher(),t},i.errorHandler.reject)},this.errorHandler.reject)},e.prototype.onBeforeSave=function(e,t,r){void 0===r&&(r="always");var n=this.callbacks.onBeforeSave[r];return n[e]=t,function(){return delete n[e]}},e.prototype.onSaveSuccess=function(e,t,r){void 0===r&&(r="always");var n=this.callbacks.onSaveSuccess[r];return n[e]=t,function(){return delete n[e]}},e.prototype.executeCallbackEvent=function(e,t,r){var n=this;return this.executeCallbacks(e.always,t).then(function(){return n.executeCallbacks(e[r?"onClose":"skipOnClose"],t)},this.errorHandler.reject)},e.prototype.executeCallbacks=function(e,t){var r={};for(var n in e)r[n]=t(e[n]);return this.promiseService.all(r)},e.prototype.enableChangesWatcher=function(){var e=this;null!==this.changesInterval&&(console.warn("Changes watcher already running!",this),this.disableChangesWatcher()),this.changesInterval=setInterval(function(){e.detectChanges()&&(e.disableChangesWatcher(),e.isLockable()&&e.lockService.fetchLock(e.rootItem))},3e3)},e.prototype.disableChangesWatcher=function(){null!==this.changesInterval&&(clearInterval(this.changesInterval),this.changesInterval=null)},e.prototype.onDeactivateItem=function(e){this.clearItemEntry(e)},e.prototype.onActivateItem=function(e){this.items.add(e)},e}(),P=function(){function e(e,t,r,n){this.apiRequestService=e,this.errorHandler=t,this.keyService=r,this.promiseService=n,this.lockItems={},this.promises={}}return e.prototype.getValue=function(e,t){var r=e.itemType;if(void 0!==t[r])return t[r][e.itemId]},e.prototype.setValue=function(e,t,r){return Object(o.b)(r,[e.itemType,e.itemId],[{},t])},e.prototype.getLocks=function(){return this.lockItems},e.prototype.hasLock=function(e){for(var t in this.lockItems)for(var r in this.lockItems[t]){var n=this.lockItems[t][r];if(!n.isForeign&&n.id==e)return!0}return!1},e.prototype.isLocked=function(e){var t=this.getValue(e,this.lockItems);return void 0!==t&&t.isForeign},e.prototype.getMessage=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t&&t.isForeign)return t.message},e.prototype.fetchCachedLock=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t)return this.promiseService.when(t);var r=this.getValue(e,this.promises);return void 0!==r?r:this.promiseService.when()},e.prototype.fetchLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){return void 0!==r?r:t.requestLock(e)},this.errorHandler.reject).then(function(e){return e.isForeign?t.errorHandler.reject(e.message):e.token},this.errorHandler.reject)},e.prototype.requestLock=function(e){var t=this,r=e.itemType,n=e.itemId,i=this.apiRequestService.create("Locktoken",this.keyService.getLocalId(),{itemtype:r,item:n}).then(function(i){return delete t.promises[r][n],t.setValue(e,i.fetchObject("Locktoken",i.links.Locktoken[0]),t.lockItems)},function(i){return delete t.promises[r][n],301===i.code?t.setValue(e,{isForeign:!0,message:i.message},t.lockItems):t.errorHandler.reject(i)});return this.setValue(e,i,this.promises)},e.prototype.deleteLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){if(void 0!==r){if(!r.isForeign)return t.apiRequestService.delete("Locktoken",r.id).then(function(){t.clearLock(e)},t.errorHandler.reject);t.clearLock(e)}},this.errorHandler.reject)},e.prototype.clearLock=function(e){var t=e.itemType;return void 0!==this.lockItems[t]&&delete this.lockItems[t][e.itemId]},e}(),V={},_=function(){function e(e,t,r){this.rootItemEntry=e,this.singleItemCache=t,this.collectionCache=r,this.parentMap={},this.destination={}}return e.prototype.process=function(){return this.parentMap=this.createParentMap(this.singleItemCache),this.processItems(this.rootItemEntry.itemType,[this.rootItemEntry],{}),{itemType:this.rootItemEntry.itemType,itemId:this.rootItemEntry.itemId,items:this.destination}},e.prototype.createParentMap=function(e){var t={};return e.forEach(function(e){var r=e.itemType,n=e.parent;if(null!==n){var i=n.itemType,o=n.itemId;void 0===t[i]&&(t[i]={});var s=t[i];void 0===s[o]&&(s[o]={}),void 0===(s=s[o])[r]&&(s[r]=[]),s[r].push(e)}}),t},e.prototype.processItems=function(e,t,r){void 0===this.destination[e]&&(this.destination[e]={}),void 0===r[e]&&(r[e]=[]);for(var n=0,i=t;n<i.length;n++){var o=i[n],s=o.itemId;void 0===this.destination[e][s]&&(r[e].push(s),this.destination[e][s]=this.processItem(o))}},e.prototype.processItem=function(e){var t=e.itemType,r=e.itemId,n=this.getItemsByParent(t,r),i=this.collectionCache.getCollectionsByParent(t,r),s=e.formatRequest(),c={};for(var u in n)this.processItems(u,n[u],c);for(var a=0,l=i;a<l.length;a++){var h=l[a];null===h.options.query&&this.processItems(h.itemType,h.items,c)}var p=Object(o.i)(s),f=Object(o.i)(c);return p&&f?{values:s,links:c}:p?{values:s}:f?{links:c}:V},e.prototype.getItemsByParent=function(e,t){var r=this.parentMap[e];return void 0===r?{}:void 0===r[t]?{}:r[t]},e}(),U="maybe",B=function(){function e(e,t,r,n){void 0===n&&(n=null),this.apiFormatter=e,this.itemType=t,this.fields=r,this.parent=n}return e.prototype.compareValues=function(e,t){return i.isMoment(t)?this.apiFormatter.compareMomentObjects(t,e):i.isDuration(t)?this.apiFormatter.compareDurations(t,e):t==e},e.prototype.matchQuery=function(e){if(void 0!==e.search)return U;if(void 0!==e.custom)return U;if(void 0!==e.linkedTo)return this.matchLinkedToQuery(e);if(void 0!==e.conditions)return this.matchComplexQuery(e);if(void 0!==e.key)return this.matchSimpleQuery(this.fields[e.key],e);if(!Object(o.i)(e))return!0;throw new Error("queryMatcher: Unsupported query! Parsed?")},e.prototype.matchLinkedToQuery=function(e){if(e.reverse)return U;var t,r=this.parent;return(t=null!==r&&(e.linkedTo===r.itemType&&this.matchSimpleQuery(r.itemId,e.query)))===U?U:e.not?!t:t},e.prototype.matchComplexQuery=function(e){var t,r,n=e.conditions;switch(e.operator){case"AND":t=!0,r=!1;break;case"OR":t=!1,r=!0;break;default:throw new Error("queryMatcher: Unsupported operator")}for(var i=0,o=n;i<o.length;i++){var s=o[i],c=this.matchQuery(s);if(c===r)return r;c===U&&(t=U)}return t},e.prototype.matchSimpleQuery=function(e,t){var r=t.key,n=t.value;if(!Object(o.i)(t))return!0;if(void 0===e)return console.warn("Required field",r,"not found for",this.itemType),U;switch("NOW"===n&&(n=i()),t.comparator){case"=":return this.compareValues(e,n);case"!=":return!this.compareValues(e,n);case"<":return e<n;case"<=":return e<=n;case">":return e>n;case">=":return e>=n;case"IN":return Object(o.j)(e,n);case"NOT IN":return!Object(o.j)(e,n);default:throw new Error("queryMatcher: Unsupported comparator: "+t.comparator+" in query "+t)}},e}();!function(e){e[e.OBJ=0]="OBJ",e[e.STR=1]="STR",e.SEP=":"}(f||(f={}));var N=function(){function e(e,t){this.query=e,this.parameters=t}return e.prototype.processValue=function(e){return Array.isArray(e)?e.slice().sort():i.isMoment(e)?i(e):i.isDuration(e)?i.duration(e):e},e.prototype.compareParsedQueries=function(e,t){return e[f.STR]===t[f.STR]?0:e[f.STR]>t[f.STR]?1:-1},e.prototype.parse=function(e){if(void 0===e&&(e=this.query),void 0!==e.linkedTo)return this.parseLinkedToQuery(e.linkedTo,e.query,e.reverse,e.not);if(void 0!==e.not)throw new Error('queryParser: "Not" not supported');if(void 0!==e.custom)return this.parseCustomQuery(e.custom,e.parameters);if(void 0!==e.search)return this.parseSearchQuery(e.search);if(void 0!==e.conditions)return this.parseComplexQuery(e.conditions,e.operator);if(void 0!==e.key)return this.parseSimpleQuery(e.key,e.value,e.comparator);var t=Object(o.g)(e);return null===t?[{},"{}"]:this.parseSimpleQuery(t,e[t])},e.prototype.parseSearchQuery=function(e){return[{search:(e=this.formatValue(e))[f.OBJ]},"[search"+f.SEP+e[f.STR]+"]"]},e.prototype.parseCustomQuery=function(e,t){if(void 0===t)return[{custom:e},"["+e+"]"];var r=this.parseCustomParameters(t);return[{custom:e,parameters:r[f.OBJ]},"["+e+f.SEP+r[f.STR]+"]"]},e.prototype.parseCustomParameters=function(e){for(var t=Object.keys(e).sort(),r={},n="",i=0;i<t.length;i++){var o=t[i],s=this.formatValue(e[o]);r[o]=s[f.OBJ],i>0&&(n+=f.SEP),n+=s[f.STR]}return[r,n]},e.prototype.parseSimpleQuery=function(e,t,r){return t=this.formatValue(t),void 0===r&&(r=Array.isArray(t[f.OBJ])?"IN":"="),[{key:e,value:t[f.OBJ],comparator:r},"["+r+f.SEP+e+f.SEP+t[f.STR]+"]"]},e.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1);var i=this.parse(t);return[{linkedTo:e,query:i[f.OBJ],reverse:r,not:n},"[linkedTo"+f.SEP+e+f.SEP+i[f.STR]+f.SEP+r+f.SEP+n+"]"]},e.prototype.parseComplexQuery=function(e,t){t=void 0===t?"AND":t.toUpperCase();var r=this.parseConditions(e);return[{conditions:r[f.OBJ],operator:t},"["+t+r[f.STR]+"]"]},e.prototype.parseConditions=function(e){for(var t=this,r=[],n=[],i="",o=0,s=e;o<s.length;o++){var c=s[o];r.push(this.parse(c))}for(var u=0,a=r=r.sort(function(e,r){return t.compareParsedQueries(e,r)});u<a.length;u++){var l=a[u];n.push(l[f.OBJ]),i+=l[f.STR]}return[n,i]},e.prototype.formatValue=function(e){var t;if("string"==typeof e&&"&"===e.charAt(0)){var r=e.substring(1);if(void 0===(e=this.parameters[r]))throw new Error("queryParser: Undefined template parameter '"+r+"'");return[t=this.processValue(e),r+">"+e]}return[t=this.processValue(e),""+t]},e}(),Q=function(){function e(){}return e.prototype.addAndCondition=function(e,t){return void 0===e.conditions||"or"===e.operator?{conditions:[e,t]}:{conditions:e.conditions.concat(t)}},e.prototype.addOrCondition=function(e,t){return"or"===e.operator?{conditions:e.conditions.concat(t)}:{conditions:[e,t],operator:"or"}},e.prototype.addParentCondition=function(e,t){var r;return null===t?e:(r={linkedTo:t.itemType,query:t.itemId},null===e?r:this.addAndCondition(e,r))},e.prototype.createNotIn=function(e){return{comparator:"NOT IN",key:"id",value:e}},e}(),Y=function(){function e(e){this.columnUtil=e,this.columns={},this.columnInfoIdMap={}}return e.prototype.expand=function(e){if(!this.columnInfoIdMap[e.id]){var t=e.itemType;void 0===this.columns[t]&&(this.columns[t]=[]),this.columns[t]=this.columnUtil.mergeRequestColumns(this.columns[t],e.request).merged,this.columnInfoIdMap[e.id]=!0}},e.prototype.get=function(){return this.columns},e}(),W=function(){function e(e,t,r,n,i,o,s,c,u,a){this.promiseService=e,this.apiRequestService=t,this.itemHandler=r,this.itemEntryFactory=n,this.collectionHandler=i,this.columnSetFactory=o,this.columnExpansionFactory=s,this.requestColumnExpansionFactory=c,this.apiFormatter=u,this.errorHandler=a}return e.prototype.onMessageReceived=function(e){switch(e.body.eventType){case"update":return this.handleUpdate(e);case"create":return this.handleCreate(e);case"delete":return this.handleDelete(e);case"linkTo":return this.handleLinkMove()}},e.prototype.formatMessageValues=function(e,t){var r={};for(var n in t)r[n]=this.apiFormatter.formatResponseValue(t[n].type,e[n]);return r},e.prototype.createCollectionMap=function(e,t,r){var n={};for(var i in t){var o=t[i],s=null!==o.parent?o.parent:{};n[i]=this.collectionHandler.entries.getByFittingItem(e,this.formatMessageValues(o.values,r),s)}return n},e.prototype.groupByCollectionId=function(e,t){var r={};for(var n in t){var i=t[n];for(var o in i)for(var s=0,c=i[o];s<c.length;s++){var u=c[s],a=u.id;void 0===r[a]&&(r[a]={collection:u,fitting:[],notfitting:[],maybe:[]}),r[a][o].push("fitting"===o?this.itemHandler.entries.get(e,n):n)}}return r},e.prototype.getRequestColumns=function(e,t){var r=this.requestColumnExpansionFactory.construct();for(var n in t){for(var i=t[n].fitting,o=this.itemHandler.entries.get(e,n),s=0,c=i;s<c.length;s++){var u=c[s];r.expand(u.columns)}void 0!==o&&r.expand(o.columns)}return r.get()},e.prototype.deferEntry=function(e){var t=e.deferred;return void 0===t?e.defer():t.promise.then(this.deferEntry.bind(this),this.errorHandler.reject)},e.prototype.processMessage=function(e){var t=this,r=e.itemType,n=this.createCollectionMap(r,e.items[r],e.columns[r]),i=this.getRequestColumns(r,n),o=[],s=[];for(var c in n){var u=this.itemHandler.entries.get(r,c),a=+c;void 0===u?0!==n[a].fitting.length&&(this.itemHandler.entries.add(this.itemEntryFactory.constructDeferred(r,a,i[r],!1)),s.push(a)):(o.push(this.deferEntry(u)),s.push(a))}return 0===s.length?this.promiseService.when(this.groupByCollectionId(r,n)):this.promiseService.all(o).then(function(){return t.apiRequestService.query(r,{id:s},i)},this.errorHandler.reject).then(function(e){return t.handleResponse(r,s,i[r],e,n)},this.errorHandler.reject)},e.prototype.processFunctionChangesResolve=function(e){var t=this,r=e.items.FunctionChangesResolve,n=[],i=[];for(var o in r){var s=r[o].parent.itemId,c=this.itemHandler.entries.get("Functie",s);void 0!==c&&void 0!==c.columns.response.Functie.newchanges&&(n.push(this.deferEntry(c)),i.push(s))}if(0!==i.length)return this.promiseService.all(n).then(function(){return t.apiRequestService.query("Functie",{id:i},{Functie:["newchanges"]})},this.errorHandler.reject).then(function(e){for(var r=0,n=e.links.Functie;r<n.length;r++){var i=n[r],o=t.itemHandler.entries.get("Functie",i),s=t.apiFormatter.copyFields(o.getFields(),{},o.columns.main),c=e.fetchValue("Functie",i,"newchanges");if(c===s.newchanges)return;o.setInitial({newchanges:c},!0).callOnChange(s).resolve()}},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleResponse=function(e,t,r,n,i){for(var o=n.fetchColumnsObject(),s=this.columnSetFactory.construct(e,r,o),c=this.columnExpansionFactory.construct(e,r,o),u=0,a=t;u<a.length;u++){var l=a[u],h=this.itemHandler.entries.get(e,l),p=void 0===h.initial,f=n.fetchObject(e,l);if(void 0!==f){var d=n.fetchDerivedObject(e,l,s.root);if(p)h.resolveDeferred(f,d,s);else{var m=c.run(h.columns),y=this.apiFormatter.copyFields(h.getFields(),{},h.columns.main);null!==m&&h.expand(f,d,m),h.updateFields(f,d,!1).callOnChange(y).resolve()}}else h.reject(),p&&this.itemHandler.entries.clear(h),delete i[l]}return this.groupByCollectionId(e,i)},e.prototype.handleCreate=function(e){var t=this,r=e.body;return"FunctionChangesResolve"===r.itemType?this.processFunctionChangesResolve(r):this.processMessage(r).then(function(e){return t.collectionHandler.addToCollections(e,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleUpdate=function(e){var t=this;return this.processMessage(e.body).then(function(e){return t.collectionHandler.removeFromAndAddToCollections(e,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleDelete=function(e){for(var t=e.body,r={},n=0,i=t.items;n<i.length;n++)for(var o=i[n],s=0,c=this.collectionHandler.entries.getByContainingItem(t.itemType,o);s<c.length;s++){var u=c[s];void 0===r[a=u.id]&&(r[a]={collection:u,items:[]}),r[a].items.push(o)}for(var a in r){var l=r[a];l.collection.removeItems(l.items,null,!0)}return this.promiseService.when()},e.prototype.handleLinkMove=function(){},e}();r.d(t,"a",function(){return s}),r.d(t,"b",function(){return c}),r.d(t,"c",function(){return u}),r.d(t,"d",function(){return l}),r.d(t,"e",function(){return h}),r.d(t,"f",function(){return p}),r.d(t,"g",function(){return d}),r.d(t,"h",function(){return m}),r.d(t,"i",function(){return v}),r.d(t,"j",function(){return g}),r.d(t,"k",function(){return C}),r.d(t,"l",function(){return I}),r.d(t,"m",function(){return S}),r.d(t,"n",function(){return R}),r.d(t,"o",function(){return F}),r.d(t,"p",function(){return b}),r.d(t,"q",function(){return O}),r.d(t,"r",function(){return j}),r.d(t,"s",function(){return T}),r.d(t,"t",function(){return k}),r.d(t,"u",function(){return w}),r.d(t,"v",function(){return x}),r.d(t,"w",function(){return D}),r.d(t,"x",function(){return L}),r.d(t,"y",function(){return A}),r.d(t,"z",function(){return H}),r.d(t,"A",function(){return P}),r.d(t,"B",function(){return _}),r.d(t,"C",function(){return B}),r.d(t,"D",function(){return N}),r.d(t,"E",function(){return Q}),r.d(t,"F",function(){return Y}),r.d(t,"G",function(){return W}),r.d(t,"fb",function(){return o.y}),r.d(t,"P",function(){return o.i}),r.d(t,"N",function(){return o.g}),r.d(t,"Q",function(){return o.j}),r.d(t,"M",function(){return o.f}),r.d(t,"J",function(){return o.c}),r.d(t,"eb",function(){return o.x}),r.d(t,"I",function(){return o.b}),r.d(t,"O",function(){return o.h}),r.d(t,"L",function(){return o.e}),r.d(t,"db",function(){return o.w}),r.d(t,"Z",function(){return o.s}),r.d(t,"S",function(){return o.l}),r.d(t,"bb",function(){return o.u}),r.d(t,"Y",function(){return o.r}),r.d(t,"U",function(){return o.n}),r.d(t,"R",function(){return o.k}),r.d(t,"X",function(){return o.q}),r.d(t,"ab",function(){return o.t}),r.d(t,"T",function(){return o.m}),r.d(t,"W",function(){return o.p}),r.d(t,"cb",function(){return o.v}),r.d(t,"V",function(){return o.o}),r.d(t,"K",function(){return o.d}),r.d(t,"H",function(){return o.a})},function(e,t,r){"use strict";var n=r(2),i=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e){return new n.c(this.apiFormatter,e)},e}(),o=function(){function e(e){this.promiseService=e}return e.prototype.construct=function(e,t){return new n.d(this.promiseService,e,t)},e}(),s=function(){function e(e){this.collectionCacheFactory=e}return e.prototype.construct=function(e,t){return new n.e(this.collectionCacheFactory,e,t)},e}(),c=function(){function e(e,t,r,n,i,o,s,c,u,a,l){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.collectionHandler=n,this.changesCompilationFactory=i,this.createRequestFactory=o,this.columnExpansionFactory=s,this.requestColumnExpansionFactory=c,this.collectionEntryService=u,this.apiFormatter=a,this.promiseService=l}return e.prototype.construct=function(){return new n.f(this.apiRequestService,this.itemHandler,this.errorHandler,this.collectionHandler,this.changesCompilationFactory,this.createRequestFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.collectionEntryService,this.apiFormatter,this.promiseService)},e}(),u=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(){return new n.g(this.queryMatcherFactory)},e}(),a=r(5),l=function(){function e(e,t,r,n,i,o,s,c,u,a){this.collectionEntryService=e,this.columnSetFactory=t,this.errorHandler=r,this.itemEntryFactory=n,this.itemEntryService=i,this.itemHandler=o,this.itemRequestService=s,this.keyService=c,this.promiseService=u,this.queryService=a}return e.prototype.construct=function(e,t){return new a.b(this,e,this.collectionEntryService.processOptions(t))},e}(),h=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e,t,r){return new n.j(this.queryMatcherFactory,e,t,r)},e}(),p=function(){function e(e,t,r,n,i,o){this.errorHandler=e,this.itemResourceFactory=t,this.changesProcessorFactory=r,this.keyService=n,this.promiseService=i,this.collectionResourceService=o}return e.prototype.construct=function(e,t,r){return(t=this.collectionResourceService.processOptions(t)).editItems&&(e.hasItemEditResources=!0),t.editCollection?(e.hasEditResources=!0,new a.a(this,e,t,r)):new a.d(this.itemResourceFactory,e,t,r)},e}(),f=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(e,t,r){return new n.m(this.columnUtil,e,t,r)},e}(),d=function(){function e(){}return e.prototype.construct=function(e,t){return new n.o(e,t)},e}(),m=function(){function e(e,t,r){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r}return e.prototype.constructStub=function(e,t){return new n.p(this.columnHandler,this.columnUtil,this.columnInfoFactory,this,e,t)},e.prototype.construct=function(e,t,r,n,i){return this.constructStub(e,t).resolve(r,n,i)},e}(),y=function(){function e(e,t,r,n){this.collectionHandler=e,this.collectionMatcherFactory=t,this.keyService=r,this.requestColumnExpansionFactory=n}return e.prototype.construct=function(e,t,r,i){return new n.r(this.collectionHandler,this.collectionMatcherFactory,this.keyService,this.requestColumnExpansionFactory,e,t,r,i)},e}(),v=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(){return new n.t(this.queryMatcherFactory)},e}(),g=function(){function e(e,t,r,n,i,o){this.authInterface=e,this.apiFormatter=t,this.columnSetFactory=r,this.itemEntryService=n,this.keyService=i,this.promiseService=o}return e.prototype.constructStub=function(e,t,r){return new a.f(this,e,t,r)},e.prototype.constructLocalLinked=function(e,t,r,n,i,o){var s=this.constructStub(e,t,i);return s.parent=n,s.setLocalFields(r,o)},e.prototype.constructLocal=function(e,t,r,n,i,o,s){void 0===i&&(i=null),void 0===o&&(o=t.columns);var c=t.columns.itemType;void 0===s&&(s=this.itemEntryService.createLocalConversionMap(c,e,!0,t.response));var u=this.constructStub(c,e,o);return u.parent=i,u.setLocalFields(t.fields,s,t.columns).setModified(r).setDerived(n)},e.prototype.constructDeferred=function(e,t,r,n){var i=this.constructStub(e,t,this.columnSetFactory.constructStub(e,r));return i.defer(n),i},e.prototype.construct=function(e,t,r,n){return this.constructStub(n.itemType,e,n).setFields(t,r)},e}(),C=function(){function e(e,t,r,n,i,o){this.itemResourceService=e,this.apiFormatter=t,this.lockService=r,this.changesProcessor=n,this.errorHandler=i,this.promiseService=o}return e.prototype.getConstructor=function(e){var t=this;return e=this.itemResourceService.processOptions(e),function(r){return e.edit?new a.e(t,r,e):new a.i(r,e)}},e.prototype.construct=function(e,t,r){return(t=this.itemResourceService.processOptions(t)).edit?new a.e(this,e,t,r):new a.i(e,t,r)},e}(),I=function(){function e(e,t,r,n,i,o,s,c,u){this.errorHandler=e,this.lockService=t,this.itemResourceFactory=r,this.collectionCacheFactory=n,this.changesProcessorFactory=i,this.itemCacheFactory=o,this.collectionResourceFactory=s,this.itemResourceService=c,this.promiseService=u}return e.prototype.construct=function(e){return new n.z(this.errorHandler,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.itemResourceService,this.promiseService,e)},e}(),S=function(){function e(){}return e.prototype.construct=function(e,t,r){return new n.B(e,t,r)},e}(),R=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e,t,r){return new n.C(this.apiFormatter,e,t,r)},e}(),F=function(){function e(){}return e.prototype.construct=function(e,t){return new n.D(e,t)},e}(),q=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(){return new n.F(this.columnUtil)},e}(),E=function(){function e(e,t){this.columnSetFactory=e,this.columnUtil=t}return e.prototype.construct=function(e,t,r){return new a.h(this,e,t,r)},e}();r.d(t,"a",function(){return i}),r.d(t,"b",function(){return o}),r.d(t,"c",function(){return s}),r.d(t,"d",function(){return c}),r.d(t,"e",function(){return u}),r.d(t,"f",function(){return l}),r.d(t,"g",function(){return h}),r.d(t,"h",function(){return p}),r.d(t,"i",function(){return f}),r.d(t,"j",function(){return d}),r.d(t,"k",function(){return m}),r.d(t,"l",function(){return y}),r.d(t,"m",function(){return v}),r.d(t,"n",function(){return g}),r.d(t,"o",function(){return C}),r.d(t,"p",function(){return I}),r.d(t,"q",function(){return S}),r.d(t,"r",function(){return R}),r.d(t,"s",function(){return F}),r.d(t,"t",function(){return q}),r.d(t,"u",function(){return E})},function(t,r){t.exports=e},function(e,t,r){"use strict";var n,i=r(2),o=0,s=function(){function e(e,t,r){this.factory=e,this.itemType=t,this.options=r,this.id=o++,this.templateColumns=null,this.parent=null,this.initial=[],this.items=[],this.resources=[],this.reloadQueued=!1,this.hasEditResources=!1,this.hasItemEditResources=!1,this.parent=r.parent,this.query=e.collectionEntryService.createQuery(r),this.columns=e.columnSetFactory.constructStub(t,r.columns),this.defer()}return e.prototype.defer=function(){return this.isDeferred()?this:(this.deferred=this.factory.promiseService.defer(),this.promise=this.deferred.promise,this)},e.prototype.isDeferred=function(){return void 0!==this.promise},e.prototype._resolve=function(){var e=this.deferred;return delete this.deferred,delete this.promise,e.resolve(this),this},e.prototype.resolve=function(e){return this.columns=e.columns,this.initial=e.items,this.items=e.items.slice(),this._resolve()},e.prototype.isLocal=function(){var e=this.parent;return null!==e&&this.factory.keyService.isLocalId(e.itemId)},e.prototype.matchParent=function(e,t){var r=this.parent;return null!==r&&(r.itemType===e&&r.itemId==t)},e.prototype.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++){e(r[t])}},e.prototype.getItemById=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(n.itemId===e)return n}},e.prototype.getIdArray=function(e){return void 0===e&&(e=[]),this.factory.collectionEntryService.getIdArray(this.items,e)},e.prototype.createItems=function(e){var t,r=this,n=this.factory,i=this.columns;return n.itemHandler.fetchTemplate(this.itemType).then(function(o){t=o;var s=[];null===r.templateColumns&&(r.templateColumns=t.columns.expand(i.request,i.requestColumnsTrue,i.response).merged);for(var c=0,u=e;c<u.length;c++){var a=u[c];s.push(n.itemEntryFactory.constructLocal(n.keyService.getLocalId(),t,a,{},r.parent,r.templateColumns))}return s},n.errorHandler.reject)},e.prototype.resolveDerivedValues=function(e,t){return this.factory.itemHandler.resolveDerivedValues(e,this.columns.root,t)},e.prototype.addItems=function(e,t,r,n,i){if(void 0===r&&(r=!1),0===e.length)return[];var o=this.items,s=this.parent,c=this.columns.link,u=[],a=[];if(r)for(var l=this.initial,h=0,p=e;h<p.length;h++){var f=p[h];-1===l.indexOf(f)&&(l.push(f),u.push(f))}for(var d=0,m=e;d<m.length;d++){f=m[d];-1===o.indexOf(f)&&(null!==s&&(f.parent=s,null!==c&&void 0!==f.modified&&(f.modified[c.id]=s.itemId)),o.push(f),a.push(f))}return this.handleAddedItemCallbacks(u,a,t,n,i)},e.prototype.handleAddedItemCallbacks=function(e,t,r,n,i){void 0===r&&(r=null),void 0===n&&(n=!0),void 0===i&&(i=!0);var o=this.resources;if(e.length>0)for(var s=0,c=o;s<c.length;s++){(m=c[s]).options.onAddInitial(e,this)}if(0===t.length)return null===r?null:[];if(i&&o.length>0)for(var u=o[0].localCache,a=0,l=t;a<l.length;a++){var h=l[a];u.onActivateItem(h)}for(var p=null,f=0,d=o;f<d.length;f++){var m,y=(m=d[f]).addItemResources(t);m===r?(p=y,n&&m.callOnAdd(y)):m.callOnAdd(y)}return p},e.prototype.removeItems=function(e,t,r,n){return 0===e.length?[]:this.handleRemovedItems(function(t){return!Object(i.Q)(t.itemId,e)},t,r,n)},e.prototype.clear=function(e,t,r){return this.handleRemovedItems(function(){return!1},e,t,r)},e.prototype.handleRemovedItems=function(e,t,r,n){void 0===r&&(r=!1);var i,o=this.factory.collectionEntryService,s=o.filterArray(this.items,e);if(r)i=o.filterArray(this.initial,e);else{for(var c=[],u=0,a=s;u<a.length;u++){var l=a[u];l.isLocal()&&c.push(l)}i=c.length>0?o.filterArray(this.initial,function(e){return-1===c.indexOf(e)}):[]}return this.handleRemovedItemCallbacks(i,s,t,n)},e.prototype.handleRemovedItemCallbacks=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var i=this.resources;if(e.length>0)for(var o=0,s=i;o<s.length;o++){(p=s[o]).options.onRemoveInitial(e,this)}if(0===t.length)return null===r?null:[];for(var c=null,u=0,a=t;u<a.length;u++){a[u].deactivateResources()}for(var l=0,h=i;l<h.length;l++){var p,f=(p=h[l]).removeItemResources(t);p===r?(c=f,n&&p.callOnRemove(f)):p.callOnRemove(f)}return c},e.prototype.expand=function(e){var t=this,r=this.factory,n=this.itemType;return!0!==e&&0===e.length?r.promiseService.when(this):r.itemRequestService.requestItems(this,void 0,e).then(function(i){var o=i.items[n],s=r.itemRequestService.processExpansion(e,i,n,t.items);return t.handleRemovedItems(function(e){return void 0!==o[e.itemId]||e.isLocal()},null,!0,!0),t.expandColumns(s),t},r.errorHandler.reject)},e.prototype.extendQuery=function(e){var t=this.options;return void 0===e?this.query:(t.queryParams=e(t.queryParams),this.query=this.factory.collectionEntryService.createQuery(t))},e.prototype.extend=function(e,t,r,n){var i=this,o=this.factory,s=o.errorHandler,c=this.extendQuery(e).object,u=o.queryService.addAndCondition(c,o.queryService.createNotIn(this.getIdArray())),a=o.itemRequestService.requestItems(this,null!==this.options.limit?c:u).then(function(e){return o.itemRequestService.processResponse(e,e.links[i.itemType],i.parent,i.columns)},s.reject).then(function(e){return delete i.promise,i.addItems(e,t,n,r,!1)},s.reject);return this.promise=a.then(function(){return i},s.reject),a},e.prototype.queueReload=function(){this.reloadQueued=!0},e.prototype.expandColumns=function(e){var t=e.run(this.columns);null!==t&&(this.columns=t.merged,this.templateColumns=null,this.options.columns=this.columns.request)},e.prototype.expandRequestColumns=function(e){this.columns.expandRequestColumns(e),this.options.columns=this.columns.request},e.prototype.getAddedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=[],n=0,i=this.items;n<i.length;n++){var o=i[n];-1===t.indexOf(o)&&r.push(e?o.itemId:o)}return r},e.prototype.getRemovedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=this.items,n=[],i=0,o=t;i<o.length;i++){var s=o[i];-1===r.indexOf(s)&&n.push(e?s.itemId:s)}return n},e.prototype.getUpdatedItems=function(){for(var e=[],t=0,r=this.items;t<r.length;t++){var n=r[t];!n.isLocal()&&n.hasChanges()&&e.push(n)}return e},e.prototype.hasAddedItems=function(){return this.items.length>this.initial.length},e.prototype.hasRemovedItems=function(){return this.initial.length>this.items.length},e.prototype.hasUpdatedItems=function(){for(var e=0,t=this.items;e<t.length;e++){if(t[e].hasChanges())return!0}return!1},e.prototype.getCurrentResource=function(){var e=this.resources;return e[e.length-1]},e.prototype.clearResources=function(e){void 0===e&&(e=!1);for(var t=this.items,r=this.resources,n=[],i=0,o=t;i<o.length;i++){o[i].clearResources()}for(var s=0,c=r;s<c.length;s++){var u=c[s];if(!u.options[e?"clearOnSubTabChange":"clearOnTabChange"]){n.push(u);for(var a=0,l=u.items;a<l.length;a++){var h=l[a];h.entry.resources.push(h)}}}this.resources=n},e.prototype.revertChanges=function(){var e=this.getAddedItems(),t=this.getRemovedItems();this.items=this.initial.slice(),this.handleAddedItemCallbacks([],t),this.handleRemovedItemCallbacks([],e)},e.prototype.onItemsCreated=function(e){for(var t=0,r=this.resources;t<r.length;t++){var n=r[t];n.rebuildMap(),n.options.onItemsCreated(e)}},e.prototype.getUpdatedItemColumns=function(e){for(var t={},r=0,n=this.columns.item;r<n.length;r++){var i=n[r];void 0!==e[i.apiColumn.itemType]&&(t[i.id]=i)}return t},e.prototype.clone=function(e,t){for(var r=this.factory,n=r.itemEntryService.batchClone(this.items,t),i=0,o=n;i<o.length;i++){o[i].parent=e}return r.construct(this.itemType,r.collectionEntryService.cloneOptions(this.options,e)).resolve({columns:this.columns,items:n})},e}(),c=r(1),u=function(){function e(e,t,r,n){this.itemResourceFactory=e,this.entry=t,this.options=r,this.localCache=n,this.itemIdMap={},this.columns=t.columns.response,this.itemIdMap={},this.items=[],t.resources.push(this),this.addItemResources(t.items)}return e.prototype.getItemById=function(e){return this.itemIdMap[e]},e.prototype.rebuildMap=function(){for(var e={},t=0,r=this.items;t<r.length;t++){var n=r[t];e[n.entry.itemId]=n}this.itemIdMap=e},e.prototype.addItemResources=function(e){var t=this;if(0===e.length)return[];for(var r=[],n=this.options,i=this.items,o=this.itemIdMap,s=this.itemResourceFactory.getConstructor({edit:n.editItems,onChange:n.onChange,onDeactivate:function(e){return t.localCache.onDeactivateItem(e)}}),c=0,u=e;c<u.length;c++){var a=u[c],l=a.itemId,h=void 0;void 0===o[l]?(h=s(a),i.push(h),o[l]=h):h=o[l],r.push(h)}return r},e.prototype.removeItemResources=function(e){var t=this,r=[];return Object(c.f)(this.items,function(n){for(var i=0,o=e;i<o.length;i++){var s=o[i];if(n.entry===s)return r.push(n),delete t.itemIdMap[s.itemId],!1}return!0}),r},e.prototype.callOnAdd=function(e){this.options.onAdd(e,this)},e.prototype.callOnRemove=function(e){this.options.onRemove(e,this)},e.prototype.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++){e(r[t])}},e.prototype.filter=function(e){for(var t=[],r=0,n=this.items;r<n.length;r++){var i=n[r];e(i)&&t.push(i)}return t},e.prototype.first=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(e(n))return n}return null},e.prototype.some=function(e){return null!==this.first(e)},e.prototype.groupBy=function(e){var t=this.items,r={};if("string"==typeof e)for(var n=0,i=t;n<i.length;n++){void 0===r[u=(c=i[n]).fields[e]]&&(r[u]=[]),r[u].push(c)}if("function"==typeof e)for(var o=0,s=t;o<s.length;o++){var c,u;null!==(u=e(c=s[o]))&&(void 0===r[u]&&(r[u]=[]),r[u].push(c))}return r},e.prototype.map=function(e){var t=this.items,r=t.length,n=new Array(r);if("string"==typeof e)for(var i=0;i<r;i++)n[i]=t[i].fields[e];if("function"==typeof e)for(i=0;i<r;i++)n[i]=e(t[i]);return n},e.prototype.reduce=function(e,t){for(var r=0,n=this.items;r<n.length;r++){t=e(n[r],t)}return t},e.prototype.extend=function(e,t,r){var n=this;return void 0===t&&(t=!1),this.entry.extend(e,this,r,!0).then(function(e){return t?n.items:e})},e.prototype.deactivate=function(){this.localCache.clearCollection(this)},e.prototype.clearResource=function(){var e=this.entry.resources,t=this.items,r=e.indexOf(this);-1!==r&&e.splice(r,1);for(var n=0,i=t;n<i.length;n++){i[n].clearResource()}},e}(),a=(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),l=function(e){function t(t,r,n,i){return e.call(this,t,r,n,i)||this}return a(t,e),t}(u),h=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),p=function(e){function t(t,r,n,i){var o=e.call(this,t.itemResourceFactory,r,n,i)||this;return o.factory=t,o}return h(t,e),t.prototype.save=function(){if(!this.options.enableSave)throw new Error("collectionResourceService: Saving disabled");var e=this.factory,t=this.entry,r=t.parent;return null!==r&&e.keyService.isLocalId(r.itemId)?e.promiseService.when():e.changesProcessorFactory.construct().execute([],[t])},t.prototype.moveItems=function(e,t,r){var n=this.entry,i=this.options;if(i.enableSave||i.modInstant)throw new Error("collectionResourceService: Cannot move items: saving enabled");if(n.itemType!==t.entry.itemType)throw new Error("collectionResourceService: Cannot move items: itemType mismatch");for(var o=n.removeItems(e,this,!1,r),s=[],c=0,u=o;c<u.length;c++){var a=u[c];s.push(a.entry)}return t.entry.addItems(s,t,!1,r),o},t.prototype.removeItems=function(e,t){var r=this;void 0===t&&(t=!0);var n=this.entry.removeItems(e,this,!1,!1);return this.options.modInstant?this.save().then(function(){return t&&r.callOnRemove(n),n}):(t&&this.callOnRemove(n),this.factory.promiseService.when(n))},t.prototype.removeItem=function(e,t){return this.removeItems([e],t).then(function(e){return e[0]},this.factory.errorHandler.reject)},t.prototype.addItems=function(e,t,r){var n=this;void 0===t&&(t=!0);var i=this.factory,o=this.options.modInstant;return this.entry.createItems(e).then(function(e){return o?e:n.entry.resolveDerivedValues(e,n.localCache.items)}).then(function(e){var s=n.entry.addItems(e,n,!1,!1,r);return o?n.save().then(function(){return t&&n.callOnAdd(s),s},i.errorHandler.reject):(t&&n.callOnAdd(s),s)},i.errorHandler.reject)},t.prototype.addItem=function(e,t,r){return this.addItems([e],t,r).then(function(e){return e[0]},this.factory.errorHandler.reject)},t.prototype.clear=function(e){return this.entry.clear(this,!1,e)},t}(u),f=0,d=function(){function e(e,t,r,n){this.factory=e,this.itemType=t,this.itemId=r,this.columns=n,this.id=++f,this.reloadQueued=!1,this.deferRequest=!1,this.parent=null,this.resources=[]}return e.prototype.queueReload=function(){return this.reloadQueued=!0,this},e.prototype.defer=function(e){return void 0===e&&(e=!1),this.deferred=this.factory.promiseService.defer(),this.deferRequest=e,this},e.prototype.resolve=function(){var e=this.deferred;return delete this.deferred,delete this.deferRequest,e.resolve(this),this},e.prototype.resolveDeferred=function(e,t,r){return this.columns=r,this.setFields(e,t),this.resolve()},e.prototype.isDeferred=function(){return void 0!==this.deferred},e.prototype.reject=function(e){return this.deferred.reject(e),delete this.deferred,delete this.deferRequest,this},e.prototype.setFields=function(e,t){var r=this.factory.apiFormatter,n=this.columns.formatted;return this.initial=r.formatResponse(e,n.main),this.derived=r.formatResponse(t,n.derived),this},e.prototype.setLocalFields=function(e,t,r){void 0===r&&(r=this.columns);for(var n=this.factory,i=n.itemEntryService.getLocalDefaultValues(),o=0,s=r.main;o<s.length;o++){var c=s[o].id;i[c]=e[c]}return this.initial=n.apiFormatter.formatResponse(i,r.formatted.main),this.derived={"creator>displayname":n.authInterface.getUserDisplayname()},this.updateItemFields(t)},e.prototype.clone=function(e){void 0===e&&(e={});var t=this.factory,r=t.apiFormatter,n=t.itemEntryService,i=this.columns,o=this.parent,s=n.expandConversionMap(this,e),c=t.construct(s,r.copyFields(this.getFields(),{},i.main),r.copyFields(this.derived,{},i.derived),i);if(c.updateItemFields(e),c.modified=r.copyFields(c.initial,{},i.main),null===o)return c;var u=n.getConversionValue(this.itemType,o.itemId,e);return c.setParent(o.itemType,void 0===u?o.itemId:u),c},e.prototype.resetDerived=function(e){for(var t=this,r=[],n=0,i=this.columns.root;n<i.length;n++){var o=i[n];-1!==e.indexOf(o.id)&&r.push(o)}return function e(r){for(var n=0,i=r;n<i.length;n++){var o=i[n];o.isLeaf||e(o.children),delete t.derived[o.path]}}(r),this},e.prototype.clearResources=function(){return this.resources=[],this},e.prototype.deactivateResources=function(){for(var e=0,t=this.resources;e<t.length;e++){t[e].deactivate()}return this},e.prototype.getFields=function(){return void 0!==this.modified?this.modified:this.initial},e.prototype.expand=function(e,t,r){var n=this.factory.apiFormatter,i=r.difference;return this.columns=r.merged,n.expandResponse(this.initial,e,i.main),n.expandResponse(this.derived,t,i.derived),void 0===this.modified?this:(n.expandResponse(this.modified,e,i.main),this)},e.prototype.updateFields=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r=!0);var n=this.factory.apiFormatter,i=this.columns.main,o=this.initial,s=this.modified;if(void 0!==s)for(var c=0,u=i;c<u.length;c++){var a=(f=u[c]).id,l=f.apiColumn.type;(r||n.compareFields(l,o[a],s[a]))&&(s[a]=n.formatResponseValue(l,e[a]))}for(var h=0,p=i;h<p.length;h++){var f;o[a=(f=p[h]).id]=n.formatResponseValue(f.apiColumn.type,e[a])}return null!==t&&this.setDerived(t),this},e.prototype.updateItemValue=function(e,t,r){var n,i=t.id,o=e[i];return"link"===t.type&&void 0===o?null!==this.parent&&(n=this.parent.itemId):n=this.factory.itemEntryService.getConversionValue(t.itemType,o,r),void 0!==n&&(e[i]=n),this},e.prototype.updateItemFields=function(e,t){void 0===t&&(t=this.columns);for(var r=t.item,n=this.initial,i=this.modified,o=0,s=r;o<s.length;o++){var c=s[o].apiColumn;this.updateItemValue(n,c,e),void 0!==i&&this.updateItemValue(i,c,e)}return this},e.prototype.formatRequest=function(){var e=this.factory.apiFormatter,t=this.columns.main;return this.isLocal()?e.formatRequestLocal(this.getFields(),t):void 0===this.modified?{}:e.formatRequest(this.initial,this.modified,t)},e.prototype.setDisplayName=function(){if(void 0===this.modified)return this;var e=this.getDisplayName();return e&&(this.modified.displayname=e),this},e.prototype.getDisplayName=function(){var e=this.factory.itemEntryService,t=this.getFields();switch(this.itemType){case"Contact":return"bedrijf"===t.type?t.bedrijf:e.getFullName(t.voornaam,t.tussenvoegsel,t.naam);case"Medewerker":case"Person":return e.getFullName(t.voornaam,t.tussenvoegsel,t.achternaam);case"Reparatie":return this.derived["materiaal>naam"];default:return t[e.getTitleField(this.itemType)]}},e.prototype.getChanges=function(e){return void 0===e&&(e=!1),void 0!==this.modified||e?this.factory.apiFormatter.getChanges(this.initial,e?{}:this.modified,this.columns.main):[]},e.prototype.isLocal=function(){return this.factory.keyService.isLocalId(this.itemId)},e.prototype.isLockable=function(){if(this.isLocal())return!1;switch(this.itemType){case"Project":case"Materiaal":case"Contact":case"Medewerker":case"Voertuig":case"Template":return!0;default:return!1}},e.prototype.hasChanges=function(){return void 0!==this.modified&&this.factory.apiFormatter.hasChanges(this.initial,this.modified,this.columns.main)},e.prototype.resetModified=function(){var e=this.columns.main;if(void 0===this.modified)return this;for(var t=0,r=e;t<r.length;t++){var n=r[t];this.modified[n.id]=this.factory.apiFormatter.clone(n.apiColumn.type,this.initial[n.id])}return this},e.prototype.setInitial=function(e,t){void 0===t&&(t=!1);var r,n=this.factory.apiFormatter;for(var i in e)this.initial[i]=e[i];if(void 0===this.modified)return t&&this.callOnChange(n.copyFields(this.initial,{},this.columns.main)),this;for(var i in r=n.copyFields(this.modified,{},this.columns.main),e)this.modified[i]=e[i];return t&&this.callOnChange(r),this},e.prototype.setModified=function(e){var t=this.factory,r=t.apiFormatter,n=this.columns,i=n.response[this.itemType];if(void 0===this.modified){var o=this.resources,s=this.initial,c=this.modified=this.isLocal()?t.itemEntryService.getLocalDefaultValues():{};if(void 0===e)r.copyFields(s,c,n.main);else for(var u in r.shallowCopyFields(e,s,c,n.main),e)void 0===i[u]&&(c[u]=e[u]);for(var a=0,l=o;a<l.length;a++){l[a].fields=c}return this}if(void 0===e)return this;for(var u in e)this.modified[u]=e[u];return this},e.prototype.setDerived=function(e){for(var t in e)this.derived[t]=e[t];return this},e.prototype.setParent=function(e,t){return this.parent={itemType:e,itemId:t},this},e.prototype.callOnChange=function(e){for(var t=0,r=this.resources.length;t<r;t++){var n=this.resources[t];null!==n&&n.options.onChange(n,e)}return this},e}(),m=function(){function e(e,t,r){void 0===r&&(r=!1),this.entry=e,this.options=t,this._isNew=r,this.derived=e.derived,this.columns=e.columns.response[e.columns.itemType],e.resources.push(this)}return e.prototype.isNew=function(){return this._isNew},e.prototype.isLocal=function(){return this.entry.isLocal()},e.prototype.clearResource=function(){var e=this.entry.resources,t=e.indexOf(this);-1!==t&&e.splice(t,1)},e.prototype.deactivate=function(){this.options.onDeactivate(this.entry)},e}(),y=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),v=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.fields=void 0===t.modified?t.initial:t.modified,i}return y(t,e),t}(m),g=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),C=function(e){function t(t,r,n,i){var o=e.call(this,r,n,i)||this;return o.factory=t,o.localCopies=[],o.transactions=0,r.setModified(),o.fields=r.modified,o}return g(t,e),t.prototype.isNew=function(){return this._isNew&&0===this.transactions},t.prototype.start=function(){return void 0===this.localCopies&&(this.localCopies=[]),this.localCopies.push(this.copyFields()),this},t.prototype.rollback=function(){var e=this.entry;return this.factory.apiFormatter.copyFields(this.localCopies.pop(),e.modified,e.columns.main),this.isNew()&&0===this.localCopies.length&&this.deactivate(),this},t.prototype.commit=function(e){void 0===e&&(e=!0);var t=this.localCopies.pop();return e&&this.callOnChange(t),this.transactions++,this},t.prototype.getLocalCopy=function(){var e=this.localCopies;return void 0===e?null:0===e.length?null:e[e.length-1]},t.prototype.copyFields=function(e){void 0===e&&(e={});var t=this.entry;return this.factory.apiFormatter.copyFields(t.modified,e,t.columns.main)},t.prototype.setFields=function(e,t){void 0===t&&(t=!0);var r,n=this.columns,i=this.fields,o=!1;for(var s in t&&(r=this.copyFields()),e){var c=n[s];void 0!==c?this.factory.apiFormatter.compareFields(c.type,i[s],e[s])||(i[s]=e[s],o=!0):console.warn("setFields: no column found for",s)}return t&&o&&this.callOnChange(r),this},t.prototype.callOnChange=function(e){return this.entry.callOnChange(e),this},t.prototype.save=function(e){var t=this,r=this.factory,n=this.entry,o={};return void 0!==e&&Object(i.I)(o,[n.itemType,n.itemId],[{},e]),(n.isLockable()?r.lockService.fetchLock(n):r.promiseService.when()).then(function(){return r.changesProcessor.execute([n],[],o)},r.errorHandler.reject).then(function(){return t},r.errorHandler.reject)},t}(m),I=function(){return function(e,t,r,n){this.itemType=t,this.response=r,this.fields=r.fetchObject(t,r.links[t][0]),this.responseColumns=e.columnUtil.mergeResponseColumns(r.fetchColumnsObject(),n).merged,this.columns=e.columnSetFactory.construct(t,!0,this.responseColumns)}}();r.d(t,"b",function(){return s}),r.d(t,"c",function(){return u}),r.d(t,"d",function(){return l}),r.d(t,"a",function(){return p}),r.d(t,"f",function(){return d}),r.d(t,"g",function(){return m}),r.d(t,"i",function(){return v}),r.d(t,"e",function(){return C}),r.d(t,"h",function(){return I})},function(e,t,r){"use strict";r.r(t);var n=r(7);r.d(t,"RmCore",function(){return n.a}),r.d(t,"noop",function(){return n.c}),r.d(t,"identity",function(){return n.b});var i=r(0);r.d(t,"ENTRY_STATUS",function(){return i.e}),r.d(t,"ALL_PERMISSIONS",function(){return i.a}),r.d(t,"COLUMN_SEPERATOR",function(){return i.b}),r.d(t,"RENDER_AS_SEPERATOR",function(){return i.h}),r.d(t,"NEW_PREFIX",function(){return i.g}),r.d(t,"DUPLICATE_PREFIX",function(){return i.d}),r.d(t,"NEW_KEYWORD",function(){return i.f}),r.d(t,"DUPLICATE_KEYWORD",function(){return i.c});var o=r(5);r.d(t,"CollectionEntry",function(){return o.b}),r.d(t,"CollectionResource",function(){return o.c}),r.d(t,"CollectionViewResource",function(){return o.d}),r.d(t,"CollectionEditResource",function(){return o.a}),r.d(t,"ItemEntry",function(){return o.f}),r.d(t,"ItemResource",function(){return o.g}),r.d(t,"ViewResource",function(){return o.i}),r.d(t,"EditResource",function(){return o.e}),r.d(t,"Template",function(){return o.h});var s=r(2);r.d(t,"ApiFormatter",function(){return s.a}),r.d(t,"ApiRequestService",function(){return s.b}),r.d(t,"ApiResponseProcessor",function(){return s.c}),r.d(t,"BatchStatus",function(){return s.d}),r.d(t,"ChangesCompilation",function(){return s.e}),r.d(t,"ChangesProcessor",function(){return s.f}),r.d(t,"CollectionCache",function(){return s.g}),r.d(t,"CollectionEntryService",function(){return s.h}),r.d(t,"CollectionHandler",function(){return s.i}),r.d(t,"CollectionMatcher",function(){return s.j}),r.d(t,"CollectionResourceService",function(){return s.k}),r.d(t,"ColumnCache",function(){return s.l}),r.d(t,"ColumnExpansion",function(){return s.m}),r.d(t,"ColumnHandler",function(){return s.n}),r.d(t,"ColumnInfo",function(){return s.o}),r.d(t,"ColumnSet",function(){return s.p}),r.d(t,"ColumnUtil",function(){return s.q}),r.d(t,"CreateRequest",function(){return s.r}),r.d(t,"ItemAdministrator",function(){return s.s}),r.d(t,"ItemCache",function(){return s.t}),r.d(t,"ItemEntryService",function(){return s.u}),r.d(t,"ItemHandler",function(){return s.v}),r.d(t,"ItemRequestService",function(){return s.w}),r.d(t,"ItemResourceService",function(){return s.x}),r.d(t,"KeyService",function(){return s.y}),r.d(t,"LocalCache",function(){return s.z}),r.d(t,"LockService",function(){return s.A}),r.d(t,"ModuleChangesCompilation",function(){return s.B}),r.d(t,"QueryMatcher",function(){return s.C}),r.d(t,"QueryParser",function(){return s.D}),r.d(t,"QueryService",function(){return s.E}),r.d(t,"RequestColumnExpansion",function(){return s.F}),r.d(t,"SocketMessageHandler",function(){return s.G}),r.d(t,"shallowMerge",function(){return s.fb}),r.d(t,"hasProperties",function(){return s.P}),r.d(t,"getFirstProperty",function(){return s.N}),r.d(t,"inArray",function(){return s.Q}),r.d(t,"filterArray",function(){return s.M}),r.d(t,"emptyArray",function(){return s.J}),r.d(t,"pathExists",function(){return s.eb}),r.d(t,"createPath",function(){return s.I}),r.d(t,"getPath",function(){return s.O}),r.d(t,"extend",function(){return s.L}),r.d(t,"merge",function(){return s.db}),r.d(t,"isObject",function(){return s.Z}),r.d(t,"isBlankObject",function(){return s.S}),r.d(t,"isString",function(){return s.bb}),r.d(t,"isNumber",function(){return s.Y}),r.d(t,"isDate",function(){return s.U}),r.d(t,"isArray",function(){return s.R}),r.d(t,"isFunction",function(){return s.X}),r.d(t,"isRegExp",function(){return s.ab}),r.d(t,"isBoolean",function(){return s.T}),r.d(t,"isElement",function(){return s.W}),r.d(t,"isWindow",function(){return s.cb}),r.d(t,"isDefined",function(){return s.V}),r.d(t,"equals",function(){return s.K}),r.d(t,"copy",function(){return s.H});var c=r(3);r.d(t,"ApiResponseProcessorFactory",function(){return c.a}),r.d(t,"BatchStatusFactory",function(){return c.b}),r.d(t,"ChangesCompilationFactory",function(){return c.c}),r.d(t,"ChangesProcessorFactory",function(){return c.d}),r.d(t,"CollectionCacheFactory",function(){return c.e}),r.d(t,"CollectionEntryFactory",function(){return c.f}),r.d(t,"CollectionMatcherFactory",function(){return c.g}),r.d(t,"CollectionResourceFactory",function(){return c.h}),r.d(t,"ColumnExpansionFactory",function(){return c.i}),r.d(t,"ColumnInfoFactory",function(){return c.j}),r.d(t,"ColumnSetFactory",function(){return c.k}),r.d(t,"CreateRequestFactory",function(){return c.l}),r.d(t,"ItemCacheFactory",function(){return c.m}),r.d(t,"ItemEntryFactory",function(){return c.n}),r.d(t,"ItemResourceFactory",function(){return c.o}),r.d(t,"LocalCacheFactory",function(){return c.p}),r.d(t,"ModuleChangesCompilationFactory",function(){return c.q}),r.d(t,"QueryMatcherFactory",function(){return c.r}),r.d(t,"QueryParserFactory",function(){return c.s}),r.d(t,"RequestColumnExpansionFactory",function(){return c.t}),r.d(t,"TemplateFactory",function(){return c.u});var u=r(8);for(var a in u)["RmCore","noop","identity","ENTRY_STATUS","ALL_PERMISSIONS","COLUMN_SEPERATOR","RENDER_AS_SEPERATOR","NEW_PREFIX","DUPLICATE_PREFIX","NEW_KEYWORD","DUPLICATE_KEYWORD","CollectionEntry","CollectionResource","CollectionViewResource","CollectionEditResource","ItemEntry","ItemResource","ViewResource","EditResource","Template","ApiFormatter","ApiRequestService","ApiResponseProcessor","BatchStatus","ChangesCompilation","ChangesProcessor","CollectionCache","CollectionEntryService","CollectionHandler","CollectionMatcher","CollectionResourceService","ColumnCache","ColumnExpansion","ColumnHandler","ColumnInfo","ColumnSet","ColumnUtil","CreateRequest","ItemAdministrator","ItemCache","ItemEntryService","ItemHandler","ItemRequestService","ItemResourceService","KeyService","LocalCache","LockService","ModuleChangesCompilation","QueryMatcher","QueryParser","QueryService","RequestColumnExpansion","SocketMessageHandler","shallowMerge","hasProperties","getFirstProperty","inArray","filterArray","emptyArray","pathExists","createPath","getPath","extend","merge","isObject","isBlankObject","isString","isNumber","isDate","isArray","isFunction","isRegExp","isBoolean","isElement","isWindow","isDefined","equals","copy","ApiResponseProcessorFactory","BatchStatusFactory","ChangesCompilationFactory","ChangesProcessorFactory","CollectionCacheFactory","CollectionEntryFactory","CollectionMatcherFactory","CollectionResourceFactory","ColumnExpansionFactory","ColumnInfoFactory","ColumnSetFactory","CreateRequestFactory","ItemCacheFactory","ItemEntryFactory","ItemResourceFactory","LocalCacheFactory","ModuleChangesCompilationFactory","QueryMatcherFactory","QueryParserFactory","RequestColumnExpansionFactory","TemplateFactory","default"].indexOf(a)<0&&function(e){r.d(t,e,function(){return u[e]})}(a)},function(e,t,r){"use strict";r.d(t,"a",function(){return o}),r.d(t,"c",function(){return s}),r.d(t,"b",function(){return c});var n=r(2),i=r(3),o=function(){return function(e,t,r,o,c){this.noop=s,this.version="1.2.1",this.apiFormatter=new n.a,this.keyService=new n.y,this.queryService=new n.E,this.columnUtil=new n.q,this.apiResponseProcessorFactory=new i.a(this.apiFormatter),this.apiRequestService=new n.b(e,this.apiResponseProcessorFactory),this.itemEntryService=new n.u(r,this.keyService),this.itemResourceService=new n.x,this.lockService=new n.A(this.apiRequestService,o,this.keyService,c),this.queryMatcherFactory=new i.r(this.apiFormatter),this.itemCacheFactory=new i.m(this.queryMatcherFactory),this.batchStatusFactory=new i.b(c),this.columnCache=new n.l(this.columnUtil),this.columnHandler=new n.n(this.apiRequestService,o,c,this.columnCache,this.columnUtil),this.columnInfoFactory=new i.j,this.columnSetFactory=new i.k(this.columnHandler,this.columnUtil,this.columnInfoFactory),this.columnExpansionFactory=new i.i(this.columnUtil),this.templateFactory=new i.u(this.columnSetFactory,this.columnUtil),this.itemEntryFactory=new i.n(r,this.apiFormatter,this.columnSetFactory,this.itemEntryService,this.keyService,c),this.itemHandler=new n.v(this.apiFormatter,this.apiRequestService,this.batchStatusFactory,this.columnExpansionFactory,this.columnHandler,this.columnSetFactory,this.columnUtil,o,this.itemCacheFactory,this.itemEntryFactory,this.itemEntryService,this.keyService,c,this.templateFactory),this.itemRequestService=new n.w(this.apiRequestService,o,this.itemHandler,this.columnExpansionFactory,this.columnSetFactory,this.itemEntryFactory,this.queryService,c),this.queryParserFactory=new i.s,this.collectionEntryService=new n.h(this.queryParserFactory,this.queryService),this.collectionResourceService=new n.k,this.collectionEntryFactory=new i.f(this.collectionEntryService,this.columnSetFactory,o,this.itemEntryFactory,this.itemEntryService,this.itemHandler,this.itemRequestService,this.keyService,c,this.queryService),this.collectionCacheFactory=new i.e(this.queryMatcherFactory),this.collectionMatcherFactory=new i.g(this.queryMatcherFactory),this.collectionHandler=new n.i(o,this.itemRequestService,this.columnHandler,this.columnSetFactory,this.collectionEntryFactory,this.collectionCacheFactory,this.queryParserFactory,this.collectionEntryService,this.keyService,c,this.queryService,this.collectionMatcherFactory),this.requestColumnExpansionFactory=new i.t(this.columnUtil),this.createRequestFactory=new i.l(this.collectionHandler,this.collectionMatcherFactory,this.keyService,this.requestColumnExpansionFactory),this.changesCompilationFactory=new i.c(this.collectionCacheFactory),this.changesProcessorFactory=new i.d(this.apiRequestService,o,this.itemHandler,this.collectionHandler,this.changesCompilationFactory,this.createRequestFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.collectionEntryService,this.apiFormatter,c),this.itemResourceFactory=new i.o(this.itemResourceService,this.apiFormatter,this.lockService,this.changesProcessorFactory.construct(),o,c),this.collectionResourceFactory=new i.h(o,this.itemResourceFactory,this.changesProcessorFactory,this.keyService,c,this.collectionResourceService),this.localCacheFactory=new i.p(o,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.itemResourceService,c),this.moduleChangesCompilationFactory=new i.q,this.itemAdministrator=new n.s(this.apiRequestService,r,this.collectionEntryService,this.collectionHandler,this.collectionMatcherFactory,this.collectionResourceService,this.columnSetFactory,o,this.itemEntryService,this.itemHandler,this.itemRequestService,this.keyService,this.localCacheFactory,t,this.moduleChangesCompilationFactory,c,this.queryService),this.socketMessageHandler=new n.G(c,this.apiRequestService,this.itemHandler,this.itemEntryFactory,this.collectionHandler,this.columnSetFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.apiFormatter,o)}}();function s(){}function c(e){return e}},function(e,t,r){"use strict";r.r(t);var n=r(9);for(var i in n)"default"!==i&&function(e){r.d(t,e,function(){return n[e]})}(i)},function(e,t){}])});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("moment")):"function"==typeof define&&define.amd?define(["moment"],t):"object"==typeof exports?exports.RmCore=t(require("moment")):e.RmCore=t(e.moment)}(window,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(e,t,r){"use strict";var n;r.d(t,"e",function(){return n}),r.d(t,"a",function(){return i}),r.d(t,"b",function(){return o}),r.d(t,"h",function(){return s}),r.d(t,"g",function(){return c}),r.d(t,"d",function(){return u}),r.d(t,"f",function(){return a}),r.d(t,"c",function(){return l}),function(e){e.CACHED="cached",e.PROMISED="promised",e.EXPAND="expand",e.PROMISED_EXPAND="promised-expand",e.RESOLVE="resolve",e.RESOLVE_VALUES="resolve-values",e.LOCAL="local"}(n||(n={}));var i="7",o=">",s=":",c="-1",u="-2",a="new-",l="dup-"},function(e,t,r){"use strict";function n(e,t){if(void 0===e)return t;var r={};for(var n in t)r[n]=void 0===e[n]?t[n]:e[n];return r}function i(e){for(var t in e)return!0;return!1}function o(e){if("object"!=typeof e)return null;for(var t in e)return t;return null}function s(e,t){for(var r=0,n=t;r<n.length;r++){if(e==n[r])return!0}return!1}function c(e,t){for(var r=[],n=0,i=e;n<i.length;n++){var o=i[n];t(o)&&r.push(o)}if(r.length===e.length)return!1;u(e);for(var s=0,c=r;s<c.length;s++){var a=c[s];e.push(a)}return!0}function u(e){e.splice(0)}function a(e,t){if(void 0===e)return!1;for(var r=0,n=t;r<n.length;r++){var i=n[r];if(void 0===e[i])return!1;e=e[i]}return!0}function l(e,t,r){for(var n=0;n<t.length;n++){var i=t[n];void 0===e[i]&&(e[i]=r[n]),e=e[i]}return e}function h(e,t,r){if(void 0===r&&(r=!1),void 0!==e){for(var n=0,i=t;n<i.length;n++){if(void 0===(e=e[i[n]])&&!r)return}return e}}function p(e,t,r){for(var n=0,i=t.length;n<i;++n){var o=t[n];if(m(o)||S(o))for(var s=Object.keys(o),c=0,u=s.length;c<u;c++){var a=s[c],l=o[a];r&&m(l)?C(l)?e[a]=new Date(l.valueOf()):R(l)?e[a]=new RegExp(l):l.nodeName?e[a]=l.cloneNode(!0):q(l)?e[a]=l.clone():(m(e[a])||(e[a]=I(l)?[]:{}),p(e[a],[l],!0)):e[a]=l}}return e}function f(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return p(e,t,!1)}function d(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return p(e,t,!0)}function m(e){return null!==e&&"object"==typeof e}function y(e){return null!==e&&"object"==typeof e&&!Object.getPrototypeOf(e)}function v(e){return"string"==typeof e}function g(e){return"number"==typeof e}function C(e){return"[object Date]"===toString.call(e)}r.d(t,"y",function(){return n}),r.d(t,"i",function(){return i}),r.d(t,"g",function(){return o}),r.d(t,"j",function(){return s}),r.d(t,"f",function(){return c}),r.d(t,"c",function(){return u}),r.d(t,"x",function(){return a}),r.d(t,"b",function(){return l}),r.d(t,"h",function(){return h}),r.d(t,"e",function(){return f}),r.d(t,"w",function(){return d}),r.d(t,"s",function(){return m}),r.d(t,"l",function(){return y}),r.d(t,"u",function(){return v}),r.d(t,"r",function(){return g}),r.d(t,"n",function(){return C}),r.d(t,"k",function(){return I}),r.d(t,"q",function(){return S}),r.d(t,"t",function(){return R}),r.d(t,"m",function(){return F}),r.d(t,"p",function(){return q}),r.d(t,"v",function(){return E}),r.d(t,"o",function(){return b}),r.d(t,"d",function(){return O}),r.d(t,"a",function(){return j});var I=Array.isArray;function S(e){return"function"==typeof e}function R(e){return"[object RegExp]"===toString.call(e)}function F(e){return"boolean"==typeof e}function q(e){return!(!e||!(e.nodeName||e.prop&&e.attr&&e.find))}function E(e){return e&&e.window===e}function b(e){return void 0!==e}function O(e,t){if(e===t)return!0;if(null===e||null===t)return!1;if(e!=e&&t!=t)return!0;var r,n,i,o,s,c=typeof e;if(c===typeof t&&"object"===c){if(!I(e)){if(C(e))return!!C(t)&&(o=e.getTime(),s=t.getTime(),o===s||o!=o&&s!=s);if(R(e))return!!R(t)&&e.toString()===t.toString();if(E(e)||E(t)||I(t)||C(t)||R(t))return!1;for(n in i=Object.create(null),e)if(!S(e[n])){if(!O(e[n],t[n]))return!1;i[n]=!0}for(n in t)if(!(n in i)&&b(t[n])&&!S(t[n]))return!1;return!0}if(!I(t))return!1;if(r=e.length,e.length===t.length){for(n=0;n<r;n++)if(!O(e[n],t[n]))return!1;return!0}}return!1}function j(e,t,r){var n=[],i=[];if(r=function(e){return g(e)&&e>0}(r)?r:NaN,t){if(e===t)throw new Error("Can't copy! Source and destination are identical.");if(I(t))t.length=0;else for(var o in t)delete t[o];return n.push(e),i.push(t),s(e,t,r)}return c(e,r);function s(e,t,r){if(--r<0)return"...";if(I(e))for(var n=0,i=e.length;n<i;n++)t.push(c(e[n],r));else if(y(e))for(var o in e)t[o]=c(e[o],r);else if(e&&"function"==typeof e.hasOwnProperty)for(var o in e)e.hasOwnProperty(o)&&(t[o]=c(e[o],r));else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=c(e[o],r));return t}function c(e,t){if(void 0===t&&(t=5),!m(e))return e;var r=n.indexOf(e);if(-1!==r)return i[r];if(E(e))throw new Error("Can't copy! Making copies of Window instances is not supported.");var o=!1,u=function(e){switch(toString.call(e)){case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Float32Array]":case"[object Float64Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return new e.constructor(c(e.buffer),e.byteOffset,e.length);case"[object ArrayBuffer]":if(!e.slice){var t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}return e.slice(0);case"[object Boolean]":case"[object Number]":case"[object String]":case"[object Date]":return new e.constructor(e.valueOf());case"[object RegExp]":var r=new RegExp(e._source,e.toString().match(/[^/]*$/)[0]);return r.lastIndex=e.lastIndex,r;case"[object Blob]":return new e.constructor([e],{type:e.type})}if(S(e.cloneNode))return e.cloneNode(!0)}(e);return void 0===u&&(u=I(e)?[]:Object.create(Object.getPrototypeOf(e)),o=!0),n.push(e),i.push(u),o?s(e,u,t):u}}},function(e,t,r){"use strict";var n,i=r(4),o=r(1),s=function(){function e(){this.MOMENT_INVALID="Invalid date",this.SERVER_DATETIME_FORMAT="YYYY-MM-DD[T]HH:mm:ssZ",this.SERVER_TIME_FORMAT="HH:mm:ss",this.SERVER_DATE_FORMAT="YYYY-MM-DD"}return e.prototype.formatResponse=function(e,t){for(var r=0,n=t;r<n.length;r++){var i=n[r];e[i.path]=this.formatResponseValue(i.apiColumn.type,e[i.path])}return e},e.prototype.expandResponse=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n];e[o.path]=this.formatResponseValue(o.apiColumn.type,t[o.path])}return e},e.prototype.formatRequest=function(e,t,r){for(var n={},i=0,o=r;i<o.length;i++){var s=o[i],c=s.id,u=s.apiColumn,a=u.type;u.readOnly||(this.compareFields(a,e[c],t[c])||(n[c]=this.formatRequestValue(a,t[c])))}return n},e.prototype.formatRequestLocal=function(e,t){for(var r={},n=0,i=t;n<i.length;n++){var o=i[n],s=o.id,c=o.apiColumn;c.readOnly||(r[s]=this.formatRequestValue(c.type,e[s]))}return r},e.prototype.hasChanges=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n],s=o.id,c=o.apiColumn;if(!c.readOnly&&!this.compareFields(c.type,e[s],t[s]))return!0}return!1},e.prototype.getChanges=function(e,t,r){for(var n=[],i=0,o=r;i<o.length;i++){var s=o[i],c=s.id,u=s.apiColumn;u.readOnly||(this.compareFields(u.type,e[c],t[c])||n.push({oldValue:e[c],newValue:t[c],column:s.apiColumn}))}return n},e.prototype.copyFields=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n],s=o.path;t[s]=this.clone(o.apiColumn.type,e[s])}return t},e.prototype.shallowCopyFields=function(e,t,r,n){for(var i=0,o=n;i<o.length;i++){var s=o[i],c=s.path;r[c]=void 0!==e[c]?e[c]:this.clone(s.apiColumn.type,t[c])}return r},e.prototype.setDefaultValues=function(e,t){for(var r=0,n=t;r<n.length;r++){var i=n[r];e[i.id]=this.getDefaultValue(i.apiColumn.type)}return e},e.prototype.compareFields=function(e,t,r){if(void 0===t)return void 0===r;if(void 0===r)return!1;switch(e){case"date":case"time":case"datetime":return this.compareMomentObjects(t,r);case"duration":return this.compareDurations(t,r);case"id":case"item":case"link":case"child":case"sibling":return t==r;case"current":case"dimension":case"distance":case"double":case"filesize":case"number":case"power":case"quantity":case"volume":case"weight":case"coordinate":case"price":case"percentage":return this.compareFloats(t,r);case"int":case"bool":case"enum":case"email":case"phone":case"url":case"text":case"longtext":case"color":return t===r;default:return Object(o.d)(t,r)}},e.prototype.compareFloats=function(e,t){var r=Math.abs(e),n=Math.abs(t),i=Math.abs(e-t);return e===t||(0===e||0===t||i<Number.MIN_VALUE?i<1.19e-7*Number.MIN_VALUE:i/Math.min(r+n,Number.MAX_VALUE)<1.19e-7)},e.prototype.compareMomentObjects=function(e,t){return e.isValid()?!!t.isValid()&&e.isSame(t):!t.isValid()},e.prototype.compareDurations=function(e,t){return e.asMilliseconds()===t.asMilliseconds()},e.prototype.formatResponseValue=function(e,t){switch(e){case"datetime":case"date":return this.formatResponseDate(t);case"color":return this.formatResponseColor(t);case"duration":return this.formatResponseDuration(t);case"json":return"string"==typeof t&&""!==t?JSON.parse(t):t;case"number":return 0===t?null:t;case"filesize":return t/1e6;default:return t}},e.prototype.formatRequestValue=function(e,t){switch(e){case"datetime":return this.formatRequestDateTime(t);case"date":return this.formatRequestDate(t);case"color":return this.formatRequestColor(t);case"duration":return this.formatRequestDuration(t);case"number":return 0===t?null:t;default:return t}},e.prototype.formatResponseDate=function(e){return null===e?i.invalid():i(e)},e.prototype.formatResponseDuration=function(e){return i.duration(null===e?0:e,"seconds")},e.prototype.formatResponseColor=function(e){return"#"===e.charAt(0)?e:"#"+e},e.prototype.formatRequestDateTime=function(e){return e.isValid()?e.format(this.SERVER_DATETIME_FORMAT):null},e.prototype.formatRequestDate=function(e){return e.isValid()?e.format(this.SERVER_DATE_FORMAT):null},e.prototype.formatRequestDuration=function(e){return e.asSeconds()},e.prototype.formatRequestColor=function(e){return"#"===e.charAt(0)?e.substring(1):e},e.prototype.getDefaultValue=function(e){switch(e){case"int":case"double":case"percentage":case"price":return 0;case"item":case"link":case"child":case"sibling":return null;case"bool":return!1;case"enum":return"0";case"date":case"datetime":case"time":return i.invalid();case"duration":return i.duration();case"text":case"longtext":return"";case"color":return"#000000";default:return""}},e.prototype.isDefaultValue=function(e,t){return this.compareFields(e,t,this.getDefaultValue(e))},e.prototype.clone=function(e,t){switch(e){case"duration":return this.cloneDuration(t);case"date":case"datetime":return i(t);case"json":return Object(o.a)(t);default:return t}},e.prototype.getCloneFunction=function(e){switch(e){case"duration":return this.cloneDuration;case"date":case"datetime":return this.cloneDate;default:return this.identity}},e.prototype.cloneDuration=function(e){return i.duration(e)},e.prototype.cloneDate=function(e){return e.clone()},e.prototype.identity=function(e){return e},e}(),c=function(){function e(e,t){this.externalApiRequestService=e,this.apiResponseProcessorFactory=t}return e.prototype.template=function(e,t){return this.processResponse(this.externalApiRequestService.template(e,t))},e.prototype.create=function(e,t,r,n,i){return this.processResponse(this.externalApiRequestService.create(e,t,r,n,i))},e.prototype.delete=function(e,t){return this.processResponse(this.externalApiRequestService.delete(e,t))},e.prototype.updateItems=function(e,t,r){return this.processResponse(this.externalApiRequestService.updateItems(e,t,r))},e.prototype.requestSkeleton=function(e,t){return this.processResponse(this.externalApiRequestService.requestSkeleton(e,t))},e.prototype.moveItems=function(e,t,r){return this.processResponse(this.externalApiRequestService.moveItems(e,t,r))},e.prototype.columns=function(e,t,r){return this.processResponse(this.externalApiRequestService.columns(e,t,r))},e.prototype.query=function(e,t,r,n){return this.processResponse(this.externalApiRequestService.query(e,t,r,n))},e.prototype.processResponse=function(e){var t=this;return e.then(function(e){return t.apiResponseProcessorFactory.construct(e)})},e}(),u=function(){function e(e,t){this.apiFormatter=e,this.response=t,this.columnIndexMap={},this.columnMap={},this.columns=t.columns,this.items=t.items,this.links=t.links,this.cacheable=t.cacheable,this.map=t.map,this.createColumnMaps()}return e.prototype.createColumnMaps=function(){for(var e in this.columns){this.columnIndexMap[e]={},this.columnMap[e]={};for(var t=0;t<this.columns[e].length;t++){var r=this.columns[e][t];this.columnIndexMap[e][r.id]=t,this.columnMap[e][r.id]=r}}},e.prototype.fetchValue=function(e,t,r){if(void 0!==this.items[e][t])return this.items[e][t].data[this.columnIndexMap[e][r]]},e.prototype.fetchDerivedObject=function(e,t,r){for(var n={},i=0,o=r;i<o.length;i++){var s=o[i];this.fetchDerivedValues(this.fetchValue(e,t,s.id),s,n)}return n},e.prototype.fetchDerivedValues=function(e,t,r){for(var n=0,i=t.children;n<i.length;n++){var o=i[n],s=void 0;null===e?(s=null,r[o.path]=this.apiFormatter.getDefaultValue(o.apiColumn.type)):(s=this.fetchValue(t.itemType,e,o.id),r[o.path]=s),o.isLeaf||this.fetchDerivedValues(s,o,r)}},e.prototype.fetchObject=function(e,t,r){if((void 0===r&&(r=!1),void 0!==this.items[e])&&void 0!==this.items[e][t]){for(var n=this.items[e][t].data,i={},o=0;o<n.length;o++)i[this.columns[e][o].id]=n[o];if(r){var s=this.items[e][t].links;for(var c in i.__links={},s)i.__links[c]=this.fetchObjectArray(c,r,s[c])}return i}},e.prototype.fetchObjectArray=function(e,t,r){var n=[];if(null===r){for(var i in this.items[e])n.push(this.fetchObject(e,i,t));return n}void 0===r&&(r=this.links[e]);for(var o=0,s=r;o<s.length;o++){i=s[o];n.push(this.fetchObject(e,i,t))}return n},e.prototype.fetchObjectMap=function(e,t,r,n){var i=this.columnIndexMap[e][t],o={},s=[];for(var c in this.items[e]){var u=this.items[e][c].data[i];s.push(u),o[u]=this.fetchObject(e,c,r)}return n?{result:o,keys:s}:o},e.prototype.fetchFieldMap=function(e,t){var r=this.columnIndexMap[e][t],n={};for(var i in this.items[e])n[i]=this.items[e][i].data[r];return n},e.prototype.fetchColumnArray=function(e){for(var t=[],r=0,n=this.columns[e];r<n.length;r++){var i=n[r];t.push(i)}return t},e.prototype.fetchColumnObject=function(e){return this.columnMap[e]},e.prototype.fetchColumnsObject=function(){return this.columnMap},e.prototype.createResource=function(e,t){return{object:this.fetchObject(e,t),links:this.items[e][t].links}},e.prototype.hasItems=function(e){for(var t in this.items[e])return!0;return!1},e.prototype.getIdArray=function(e){var t=[];for(var r in this.items[e])t.push(r);return t},e}(),a=r(0),l=function(){function e(e,t,r){for(var n in this.promiseService=e,this.getItemId=t,this.getPromise=r,this.requestStatusArray=[a.e.RESOLVE,a.e.RESOLVE_VALUES,a.e.EXPAND,a.e.PROMISED_EXPAND],this.entries={},a.e)this.entries[a.e[n]]=[]}return e.prototype.add=function(e){var t=e.status;void 0===this.entries[t]&&(this.entries[t]=[]),this.entries[t].push(e.entry)},e.prototype.hasEntries=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.entries[n].length>0)return!0}return!1},e.prototype.hasRequests=function(){return this.hasEntries(this.requestStatusArray)},e.prototype.forEachEntry=function(e,t){for(var r=0,n=e;r<n.length;r++)for(var i=n[r],o=0,s=this.entries[i];o<s.length;o++){t(s[o])}},e.prototype.getPromises=function(){var e=this,t=[];return this.forEachEntry([a.e.PROMISED,a.e.PROMISED_EXPAND],function(r){t.push(e.getPromise(r))}),this.promiseService.all(t)},e.prototype.getRequestIds=function(){var e=this,t=[];return this.forEachEntry(this.requestStatusArray,function(r){t.push(e.getItemId(r))}),t},e.prototype.getArray=function(){var e=[];for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++){var i=n[r];e.push(i)}return e},e}(),h=function(){function e(e,t,r){this.collectionCacheFactory=e,this.singleItems=t,this.compilation={create:{},delete:{},update:{},move:{}},this.moveArray=[],this.deleteMap={},this.collections=this.collectionCacheFactory.construct(),this.processSingleItems(),this.processCollections(r),this.postProcess()}return e.prototype.getDefaultParent=function(){return{itemType:"Void",itemId:0}},e.prototype.addMoveEntry=function(e){this.moveArray.push(e)},e.prototype.addDeleteEntry=function(e,t,r){Object(o.b)(this.deleteMap,[e.itemType,e.itemId],[{},{parentId:t,item:e,parentType:r}])},e.prototype.addUpdateEntry=function(e){Object(o.b)(this.compilation.update,[e.itemType,e.itemId],[{},e])},e.prototype.addCreateEntry=function(e){var t=e.parent;null===t&&(t=this.getDefaultParent()),Object(o.b)(this.compilation.create,[t.itemType,t.itemId,e.itemType,e.itemId],[{},{},{},e])},e.prototype.postProcess=function(){for(var e=0,t=this.moveArray;e<t.length;e++){var r=(u=t[e]).itemId,n=this.deleteMap[u.itemType];if(void 0!==n&&void 0!==n[r]){var i=u.parent;(c=Object(o.b)(this.compilation.move,[i.itemType,i.itemId],[{},[]])).push(n[r]),delete n[r]}}for(var s in this.deleteMap)for(var r in this.deleteMap[s]){var c,u=this.deleteMap[s][r].item;void 0===(c=this.compilation.delete)[s]&&(c[s]=[]),c[s].push(u)}},e.prototype.processSingleItems=function(){for(var e=0,t=this.singleItems;e<t.length;e++){var r=t[e];r.isLocal()?this.addCreateEntry(r):r.hasChanges()&&this.addUpdateEntry(r)}},e.prototype.processCollections=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.collections.add(n),!n.isDeferred()){var i=n.parent;null===i&&(i=this.getDefaultParent());var o=void 0,s=void 0;n.isLocal()?(o=n.items,s=[]):n.hasEditResources?(o=n.getAddedItems(),s=n.getRemovedItems()):(o=[],s=[]);for(var c=0,u=o;c<u.length;c++){var a=u[c];a.isLocal()?this.addCreateEntry(a):this.addMoveEntry(a)}for(var l=0,h=s;l<h.length;l++){var p=h[l];this.addDeleteEntry(p,i.itemId,i.itemType)}if(n.hasItemEditResources)for(var f=0,d=n.getUpdatedItems();f<d.length;f++){var m=d[f];this.addUpdateEntry(m)}}}},e}(),p=function(){function e(e,t,r,n,i,o,s,c,u,a,l){this.apiRequestService=e,this.itemHandler=t,this.errorHandler=r,this.collectionHandler=n,this.changesCompilationFactory=i,this.createRequestFactory=o,this.columnExpansionFactory=s,this.requestColumnExpansionFactory=c,this.collectionEntryService=u,this.apiFormatter=a,this.promiseService=l}return e.prototype.getItemTypeUpdatePriority=function(e){switch(e){case"Factuurregelbedrag":return 0;case"Factuurregel":case"Minfactuur":return 1;default:return 2}},e.prototype.isDocumentItemType=function(e){switch(e){case"Bon":case"Offerte":case"Contract":case"Factuur":case"Materiaalbon":case"Contactbon":case"Inhuurbon":case"Medewerkerbon":case"Reparatiebon":case"Voertuigbon":case"Aanmaning":return!0}return!1},e.prototype.isDocumentUpdate=function(e){var t=e.update;for(var r in t)if(this.isDocumentItemType(r))return!0;return!1},e.prototype.buildMoveRequest=function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r].item,o=i.itemType;void 0===t[o]&&(t[o]=[]),t[o].push(i.itemId)}return t},e.prototype.getMapValue=function(e,t,r){if(void 0!==r&&void 0!==r[e])return r[e][t]},e.prototype.executeCreateRequests=function(e,t,r,n,i){for(var o=[],s=0,c=this.createRequestFactory.construct(e.compilation.create,e.collections,t,n).run();s<c.length;s++){var u=c[s];o.push(this.executeCreateRequest(u,r).then(a))}return this.promiseService.all(o).then(function(){return r},this.errorHandler.reject);function a(e){return void 0!==i&&i(r),e}},e.prototype.executeCreateRequest=function(e,t){var r=this;return this.apiRequestService.requestSkeleton(e.request).then(function(n){var i=n.map,o=n.fetchColumnsObject(),s=e.items;for(var c in s){var u=r.columnExpansionFactory.construct(c,e.request.columns[c],o);for(var a in s[c]){var l=s[c][a],h=r.getMapValue(c,a,i);if(void 0!==h){var p=n.fetchObject(c,h),f=u.run(l.columns);l.itemId=h,l.updateFields(p,n.fetchDerivedObject(c,h,l.columns.root)),null!==f&&l.expand(p,n.fetchDerivedObject(c,h,f.difference.root),f),r.itemHandler.entries.add(l)}else console.warn("Create failed!",l)}}for(var c in e.collections.addToCollections(),i)for(var a in void 0===t[c]&&(t[c]={}),i[c])t[c][a]=i[c][a]},this.errorHandler.reject)},e.prototype.prioritizeUpdateRequests=function(e,t){var r=[[],[],[]],n=this.promiseService.when();for(var i in e)r[this.getItemTypeUpdatePriority(i)].push(i);for(var o=0,s=r;o<s.length;o++){var c=s[o];0!==c.length&&(n=n.then(this.executeUpdateRequests(c,e,t),this.errorHandler.reject))}return n},e.prototype.executeUpdateRequests=function(e,t,r){var n=this;return function(){for(var i=[],o=0,s=e;o<s.length;o++){var c=s[o];i.push(n.executeUpdateRequest(c,t[c],r))}return n.promiseService.all(i)}},e.prototype.executeUpdateRequest=function(e,t,r){var n=this,i={},s=this.requestColumnExpansionFactory.construct(),c=this.collectionHandler.getCollectionMatcher();for(var u in i[e]={},t){var a=t[u],l=i[e][u]={},h=Object(o.h)(r,[e,u]);l.values=a.formatRequest(),void 0!==h&&(l.parameters=h),s.expand(a.columns),c.expand(a)}for(var p=0,f=c.getCollectionsWithFittingItems();p<f.length;p++){var d=f[p];s.expand(d.columns)}return this.apiRequestService.updateItems(e,i,s.get()).then(function(r){var i=n.columnExpansionFactory.construct(e,s.get(),r.fetchColumnsObject());for(var o in t){var u=t[o],a=r.fetchObject(e,o);if(void 0!==a){var l=n.apiFormatter.copyFields(u.initial,{},u.columns.main);u.updateFields(a,r.fetchDerivedObject(e,o,u.columns.root)).callOnChange(l);var h=i.run(u.columns);null!==h&&u.expand(a,r.fetchDerivedObject(e,o,h.difference.root),h)}else console.warn("Update failed!",u)}c.removeFromAndAddToCollections()},this.errorHandler.reject)},e.prototype.executeDeleteRequests=function(e){var t=[];for(var r in e)t.push(this.executeDeleteRequest(r,e[r]));return this.promiseService.all(t)},e.prototype.executeDeleteRequest=function(e,t){for(var r=this,n=[],i=0,s=t;i<s.length;i++){var c=s[i];n.push(c.itemId)}return this.apiRequestService.delete(e,n).then(function(e){for(var n=e.items,i=r.collectionHandler.getCollectionMatcher(),s=0,c=t;s<c.length;s++){var u=c[s];Object(o.j)(u.itemId,n)||console.warn("Delete failed!",u),i.expand(u)}i.removeFromCollections()},this.errorHandler.reject)},e.prototype.executeMoveRequests=function(e,t){var r=this,n=[];for(var i in e)for(var o in e[i])s(i,o);return this.promiseService.all(n);function s(i,o){var s=e[i][o],c=r.getMapValue(i,o,t);n.push(r.apiRequestService.moveItems(i,void 0!==c?c:o,r.buildMoveRequest(s)).then(function(){r.processMoveResponse(s)},r.errorHandler.reject))}},e.prototype.processMoveResponse=function(e){for(var t=[],r={},n={},i=0,o=e;i<o.length;i++){var s=o[i],c=s.item;this.addCollectionMapEntry(r,s.parentId,c,c.itemId),this.addCollectionMapEntry(n,c.parent.itemId,c,c),t.push(c)}this.forEachCollection(r,"removeItems"),this.forEachCollection(n,"addItems")},e.prototype.addCollectionMapEntry=function(e,t,r,n){Object(o.b)(e,[r.parent.itemType,t,r.itemType],[{},{},[]]).push(n)},e.prototype.forEachCollection=function(e,t){for(var r in e)for(var n in e[r])for(var i in e[r][n]){var o=this.collectionHandler.entries.getByParent(r,n,i);null!==o&&o[t](e[r][n][i],null,!0)}},e.prototype.onItemsCreated=function(e,t,r){if(Object(o.i)(e)){for(var n=0,i=r;n<i.length;n++){var s=i[n],c=s.parent,u=s.getUpdatedItemColumns(e);if(null!==c)void 0!==(d=this.getMapValue(c.itemType,c.itemId,e))&&(c.itemId=d,s.query=this.collectionEntryService.createQuery(s.options),this.collectionHandler.entries.add(s));if(Object(o.i)(u)){void 0!==u.id&&s.onItemsCreated(e[s.itemType]);for(var a=0,l=s.items;a<l.length;a++){(f=l[a]).updateItemFields(e)}}}for(var h=0,p=t;h<p.length;h++){var f,d,m=(f=p[h]).parent;if(f.updateItemFields(e),null!==m)void 0!==(d=this.getMapValue(m.itemType,m.itemId,e))&&(m.itemId=d)}}},e.prototype.execute=function(e,t,r,n,i){var o=this;void 0===r&&(r={});var s=this.errorHandler,c=this.changesCompilationFactory.construct(e,t),u=c.compilation,a={},l=this.executeCreateRequests(c,r,a,n,i).then(function(){return o.onItemsCreated(a,e,t),o.executeMoveRequests(u.move,a)},function(r){return o.onItemsCreated(a,e,t),s.reject(r)});return(l=this.isDocumentUpdate(u)?l.then(function(){return o.executeDeleteRequests(u.delete)},s.reject).then(function(){return o.prioritizeUpdateRequests(u.update,r)},s.reject):l.then(function(){return o.prioritizeUpdateRequests(u.update,r)},s.reject).then(function(){return o.executeDeleteRequests(u.delete)},s.reject)).then(function(){return a},s.reject)},e}();!function(e){e.MAYBE="maybe"}(n||(n={}));var f,d=function(){function e(e){this.queryMatcherFactory=e,this.entries={}}return e.prototype.contains=function(e){var t=this.entries[e.itemType];return void 0!==t&&void 0!==t[e.id]},e.prototype.some=function(e){var t=this.entries;for(var r in t)for(var n in t[r])if(e(t[r][n]))return!0;return!1},e.prototype.forEach=function(e){var t=this.entries;for(var r in t)for(var n in t[r])e(t[r][n])},e.prototype.toArray=function(){var e=this.entries,t=[];for(var r in e)for(var n in e[r])t.push(e[r][n]);return t},e.prototype.add=function(e){var t=this.entries,r=e.itemType;return void 0===t[r]&&(t[r]={}),t[r][e.id]=e},e.prototype.clear=function(e){return void 0===e?(this.entries={},!0):!!this.contains(e)&&delete this.entries[e.itemType][e.id]},e.prototype.getByItemType=function(e){var t=this.entries[e],r=[];if(void 0===t)return r;for(var n in t)r.push(t[n]);return r},e.prototype.matchParent=function(e,t,r){var n=e.parent;return null!==n&&(n.itemType===t&&n.itemId==r)},e.prototype.getByParent=function(e,t,r){var n=this.entries[r];if(void 0===n)return null;for(var i in n)if(this.matchParent(n[i],e,t))return n[i];return null},e.prototype.getResourceByParent=function(e,t,r){var n=this.getByParent(e,t,r);return null===n?null:n.getCurrentResource()},e.prototype.getCollectionsByParent=function(e,t){var r=this.entries,n=[];for(var i in r)for(var o in r[i]){var s=r[i][o];this.matchParent(s,e,t)&&n.push(s)}return n},e.prototype.getByContainingItem=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var i in r){var o=r[i];void 0!==o.getItemById(t)&&n.push(o)}return n},e.prototype.getByFittingItem=function(e,t,r){var i=this.entries[e],o={fitting:[],notfitting:[],maybe:[]};if(void 0===i)return o;var s=this.queryMatcherFactory.construct(e,t,r);for(var c in i){var u=i[c],a=s.matchQuery(u.query.object);!0===a?o.fitting.push(u):a===n.MAYBE?o.maybe.push(u):o.notfitting.push(u)}return o},e.prototype.getByQuery=function(e,t){var r=this.entries[e];if(void 0===r)return null;for(var n in r){var i=r[n];if(i.query.string===t.string)return i}return null},e.prototype.getByKey=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var i in r){var o=r[i];o.options.entryKey===t&&n.push(o)}return n},e.prototype.getResourceByKey=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var i in r)for(var o=0,s=r[i].resources;o<s.length;o++){var c=s[o];c.options.resourceKey===t&&n.push(c)}return n},e}(),m=function(){function e(e,t){this.queryParserFactory=e,this.queryService=t}return e.prototype.cloneOptions=function(e,t){var r=this.processOptions(e);return r.queryParams=this.cloneQueryParams(e.queryParams),r.parent=t,r},e.prototype.cloneQueryParams=function(e){var t={};for(var r in e){var n=e[r],o=void 0;o=Array.isArray(n)?n.slice():i.isMoment(n)?n.clone():n,t[r]=o}return t},e.prototype.processOptions=function(e){return Object(o.y)(e,{columns:[],query:null,queryItemType:null,queryParams:{},parent:null,deferRequest:!1,limit:null,entryKey:""})},e.prototype.createQuery=function(e){var t,r=e.parent;if(null===r)t=e.query;else{var n={linkedTo:r.itemType,query:{id:"&parentId"}};e.queryParams.parentId=r.itemId,t=null===e.query?n:this.queryService.addAndCondition(e.query,n)}var i=this.queryParserFactory.construct(t,e.queryParams).parse();return{object:i[0],string:i[1]}},e.prototype.getIdArray=function(e,t){void 0===t&&(t=[]);for(var r=0,n=e;r<n.length;r++){var i=n[r];t.push(i.itemId)}return t},e.prototype.filterArray=function(e,t){for(var r=[],n=[],i=0,o=e;i<o.length;i++){var s=o[i];(t(s)?r:n).push(s)}if(0===n.length)return n;e.length=r.length;for(var c=0;c<e.length;c++)e[c]=r[c];return n},e}(),y=r(6),v=function(){function e(e,t,r,n,i,o,s,c,u,a,l,h){this.errorHandler=e,this.itemRequestService=t,this.columnHandler=r,this.columnSetFactory=n,this.collectionEntryFactory=i,this.collectionCacheFactory=o,this.queryParserFactory=s,this.collectionEntryService=c,this.keyService=u,this.promiseService=a,this.queryService=l,this.collectionMatcherFactory=h,this.entries=this.collectionCacheFactory.construct()}return e.prototype.getPromises=function(e){var t=e[a.e.PROMISED],r=e[a.e.PROMISED_EXPAND],n=[];for(var i in t)n.push(t[i]);for(var i in r)n.push(r[i]);return n},e.prototype.getRequestIds=function(e){var t=e[a.e.RESOLVE],r=e[a.e.EXPAND],n=[];for(var i in t)n.push(t[i].parent.itemId);for(var i in r)n.push(r[i].parent.itemId);return n},e.prototype.removeFromAndAddToCollections=function(e,t){for(var r in e){var n=e[r],i=n.collection;i.removeItems(n.notfitting,null,!0),i.addItems(n.fitting,null,!0),n.maybe.length>0&&i.extend(y.identity,null,!0,t)}},e.prototype.getCollectionMatcher=function(){return this.collectionMatcherFactory.construct([this.entries],!0,!0)},e.prototype.removeFromCollections=function(e,t,r){var n;for(var i in void 0===r&&(r=null),e){for(var o=e[i],s=o.fitting,c=o.maybe,u=o.collection,a=[],l=0,h=s;l<h.length;l++){var p=h[l];a.push(p.itemId)}for(var f=0,d=c;f<d.length;f++){var m=d[f];a.push(m)}null!==r&&u===r.entry?n=u.removeItems(a,r,t):u.removeItems(a,null,t)}return n},e.prototype.addToCollections=function(e,t,r){var n;for(var i in void 0===r&&(r=null),e){var o=e[i],s=o.collection;s.isDeferred()||(null!==r&&s===r.entry?n=s.addItems(o.fitting,r,t):s.addItems(o.fitting,null,t),t&&o.maybe.length>0&&s.extend(y.identity,null,!0,t))}return n},e.prototype.batchExpand=function(e,t,r,n){var i=this;if(0===n.length)return this.promiseService.when(r);var o=[],s=[];for(var c in r){var u=r[c].entry;u.defer(),o.push(u.parent.itemId),s=s.concat(u.items)}return this.itemRequestService.requestLinkItems(e,o,t,null,n).then(function(e){for(var c=i.itemRequestService.processExpansion(n,e,t,s),u=0,a=o;u<a.length;u++){var l=a[u],h=r[l].entry;h.expandColumns(c),h._resolve()}return r})},e.prototype.batchExtend=function(e,t,r,n,i,s){var c=this;if(void 0===s&&(s=!1),!Object(o.i)(i))return this.promiseService.when({});var u=[],a=[];for(var l in r.queryParams=n(r.queryParams),i){var h=i[l].entry;h.extendQuery(n),u.push(h.parent.itemId),a=a.concat(h.getIdArray())}return this.itemRequestService.requestLinkItems(e,u,t,this.queryService.addAndCondition(this.collectionEntryService.createQuery(r).object,this.queryService.createNotIn(a)),r.columns).then(function(n){return c.itemRequestService.processLinkResponse(n,e,u,t,r)},this.errorHandler.reject).then(function(e){for(var t={},r=0,n=u;r<n.length;r++){var o=n[r],c=i[o],a=c.entry.addItems(e.items[o],c);t[o]=s?c.items:a}return t},this.errorHandler.reject)},e.prototype.batchFetch=function(e,t,r,n,i,s,c){var u=this,l=this.createStatusResource(e,t,r,n,s,c);return this.promiseService.all(this.getPromises(l)).then(function(){var t=u.getRequestIds(l);return t.length>0?u.itemRequestService.requestLinkItems(e,t,r,null===n.query?null:u.queryParserFactory.construct(n.query,n.queryParams).parse()[0],n.columns).then(function(i){return u.itemRequestService.processLinkResponse(i,e,t,r,n)},u.errorHandler.reject).then(function(e){return u.handleBatchResponse(l,e,i)},u.errorHandler.reject):Object(o.i)(l[a.e.LOCAL])?u.columnHandler.fetch(r,n.columns).then(function(e){return u.handleBatchResponse(l,{columns:u.columnSetFactory.construct(r,n.columns,e,!1)},i)},u.errorHandler.reject):l[a.e.CACHED]},this.errorHandler.reject)},e.prototype.createStatusResource=function(e,t,r,n,i,o){var s={};for(var c in a.e)s[a.e[c]]={};for(var u=0,l=t;u<l.length;u++){var h=l[u],p=this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:h}),f=this.getEntryStatus(r,p,i,o);s[f.status][h]=f.entry}return s},e.prototype.fetch=function(e,t,r,n,i){var o=this.errorHandler,s=this.getEntryStatus(e,t,n,i),c=s.entry;switch(s.status){case a.e.CACHED:return this.promiseService.when(c);case a.e.PROMISED:return c.promise;case a.e.EXPAND:return c.expand(t.columns).then(function(){return c._resolve()},o.reject);case a.e.PROMISED_EXPAND:return c.promise.then(function(){return c.defer().expand(t.columns)},o.reject).then(function(){return c._resolve()},o.reject);case a.e.LOCAL:return this.resolveLocal(c,r);default:return this.resolveRemote(c,r)}},e.prototype.getCachedEntryStatus=function(e,t){return e.columns.isSupersetOf(t.columns)?e.isDeferred()?a.e.PROMISED:e.reloadQueued?(e.reloadQueued=!1,e.isLocal()?a.e.CACHED:(e.defer(),a.e.RESOLVE)):a.e.CACHED:e.isDeferred()?a.e.PROMISED_EXPAND:(e.defer(),a.e.EXPAND)},e.prototype.getDeferredEntryStatus=function(e,t,r,n){var i;return t.deferRequest?null!==(i=n.getByQuery(e,r))?(i.expandRequestColumns(t.columns),{entry:i,isDeferred:!1}):(i=this.collectionEntryFactory.construct(e,t),{entry:n.add(i),isDeferred:!0}):{entry:i=this.collectionEntryFactory.construct(e,t),isDeferred:!1}},e.prototype.getEntryStatus=function(e,t,r,n){var i,o,s,c=this.collectionEntryService.createQuery(t);return this.isLocal(t)?null!==(i=r.getByQuery(e,c))?{entry:i,status:this.getCachedEntryStatus(i,t)}:(i=(o=this.getDeferredEntryStatus(e,t,c,n)).entry,o.isDeferred?{entry:i,status:a.e.PROMISED}:{entry:r.add(i),status:a.e.LOCAL}):null!==(i=this.entries.getByQuery(e,c))?{entry:r.add(i),status:this.getCachedEntryStatus(i,t)}:(i=(s=this.getDeferredEntryStatus(e,t,c,n)).entry,s.isDeferred?{entry:i,status:a.e.PROMISED}:(r.add(i),this.entries.add(i),{entry:i,status:a.e.RESOLVE}))},e.prototype.handleBatchResponse=function(e,t,r){var n={};for(var i in e.cached)n[i]=e.cached[i];for(var i in e.resolve){var o=e.resolve[i];n[i]=o.resolve({items:t.items[i].concat(r.getLocalByQuery(o.itemType,o.query)),columns:t.columns})}for(var i in e.expand){(o=e.expand[i]).expandColumns(t.columnExpansion),n[i]=o._resolve()}for(var i in e.local){o=e.local[i];n[i]=o.resolve({items:r.getByQuery(o.itemType,o.query),columns:t.columns})}return n},e.prototype.resolveLocal=function(e,t){var r=this,n=e.itemType,i=e.options.columns;return this.columnHandler.fetch(n,i).then(function(o){return e.resolve({items:t.getByQuery(n,e.query),columns:r.columnSetFactory.construct(n,i,o,!1)})},this.errorHandler.reject)},e.prototype.resolveRemote=function(e,t){var r,n=this,i=e.itemType;return this.itemRequestService.requestItems(e).then(function(t){return r=n.columnSetFactory.construct(i,e.options.columns,t.fetchColumnsObject()),n.itemRequestService.processResponse(t,t.links[i],e.parent,r)},this.errorHandler.reject).then(function(n){return e.resolve({items:n.concat(t.getLocalByQuery(i,e.query)),columns:r})},this.errorHandler.reject)},e.prototype.isLocal=function(e){var t=e.parent;return null!==t&&this.keyService.isLocalId(t.itemId)},e}(),g=function(){function e(e,t,r,n){this.queryMatcherFactory=e,this.collectionCaches=t,this.updateInitial=r,this.callOnActivate=n,this.map={}}return e.prototype.expand=function(e){for(var t=e.itemId,r=this.queryMatcherFactory.construct(e.itemType,e.getFields(),e.parent),n=0,i=this.collectionCaches;n<i.length;n++)for(var o=0,s=i[n].getByItemType(e.itemType);o<s.length;o++){var c=s[o],u=c.id,a=void 0;void 0===this.map[u]&&(this.map[u]={collection:c,matches:{}}),void 0===(a=this.map[u].matches)[t]&&(a[t]={item:e,isMatch:r.matchQuery(c.query.object)})}return this},e.prototype.getCollectionsWithFittingItems=function(){var e=[];for(var t in this.map){var r=this.map[t];this.hasFittingItems(r.matches)&&e.push(r.collection)}return e},e.prototype.addToCollections=function(e){void 0===e&&(e=null);var t=null;for(var r in this.map){var n=this.map[r],i=n.collection,o=this.groupItemEntries(n.matches),s=o.fitting;i.isDeferred()||(null!==e&&i===e.entry?t=i.addItems(s,e,this.updateInitial,!0,this.callOnActivate):i.addItems(s,null,this.updateInitial,!0,this.callOnActivate),this.updateInitial&&o.maybe.length>0&&i.extend(y.identity,null,!0,this.updateInitial))}return t},e.prototype.removeFromCollections=function(e){void 0===e&&(e=null);var t=null;for(var r in this.map){var n=this.map[r],i=n.collection,o=this.groupItemIds(n.matches).fitting;null===e||i!==e.entry?t=i.removeItems(o,e,this.updateInitial):i.removeItems(o,null,this.updateInitial)}return t},e.prototype.removeFromAndAddToCollections=function(){for(var e in this.map){var t=this.map[e],r=t.collection,n=this.groupItemEntries(t.matches);r.removeItems(n.notFitting,null,this.updateInitial),r.addItems(n.fitting,null,this.updateInitial),n.maybe.length>0&&r.extend(y.identity,null,!0,this.updateInitial)}},e.prototype.groupItemEntries=function(e){var t=[],r=[],n=[];for(var i in e){var o=e[i],s=o.item,c=o.isMatch;!0===c?t.push(s):!1===c?r.push(s.itemId):n.push(s)}return{fitting:t,notFitting:r,maybe:n}},e.prototype.groupItemIds=function(e){var t=[],r=[];for(var n in e){var i=e[n];(!1===i.isMatch?r:t).push(i.item.itemId)}return{fitting:t,notFitting:r}},e.prototype.hasFittingItems=function(e){for(var t in e)if(!0===e[t].isMatch)return!0;return!1},e}(),C=function(){function e(){}return e.prototype.processOptions=function(e){return Object(o.y)(e,{editItems:!1,editCollection:!1,modInstant:!1,enableSave:!0,onItemsCreated:y.noop,onChange:y.noop,onAdd:y.noop,onRemove:y.noop,onAddInitial:y.noop,onRemoveInitial:y.noop,resourceKey:null,clearOnTabChange:!0,clearOnSubTabChange:!0,custom:null})},e.prototype.getIdArray=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];t.push(i.entry.itemId)}return t},e}(),I=function(){function e(e){this.columnUtil=e,this.cache={},this.allColumns={}}return e.prototype.setColumn=function(e,t){var r=this.cache;void 0===r[e]&&(r[e]={});var n=r[e],i=t.id;return void 0===n[i]&&(n[i]=t),n[i]},e.prototype.setColumns=function(e,t,r){var n={};for(var i in r){var o=r[i];for(var s in n[i]={},o)n[i][s]=this.setColumn(i,o[s])}return!0===t&&(this.allColumns[e]=!0),n},e.prototype.retrieve=function(e,t){if(!0===t)return this.containsAll(e)?{cached:this.getColumns(e),missing:[]}:{cached:{},missing:!0};var r={},n=[];return this.retrieveColumns(e,t,n,r),{cached:r,missing:n}},e.prototype.containsAll=function(e){return!0===this.allColumns[e]},e.prototype.getColumns=function(e){var t,r=this.cache;return(t={})[e]=void 0===r[e]?[]:r[e],t},e.prototype.retrieveColumns=function(e,t,r,n){this.retrieveColumn(e,"id",r,n);for(var i=0,o=t;i<o.length;i++){var s=o[i];this.retrieveColumn(e,s,r,n)}},e.prototype.retrieveColumn=function(e,t,r,n){var i=this.columnUtil.parseRequestColumn(t),o=this.getColumn(e,i.id);if(void 0!==o){if(void 0===n[e]&&(n[e]={}),n[e][i.id]=o,0!==i.children.length){var s,c=[];if(this.retrieveColumns(o.itemType,i.children,c,n),0!==c.length)r.push(((s={})[i.id]=c,s))}}else r.push(t)},e.prototype.getColumn=function(e,t){var r=this.cache[e];if(void 0!==r)return r[t]},e}(),S=function(){function e(e,t,r,n){if(this.columnUtil=e,this.itemType=t,this.responseColumns=n,this.expansionMap={},!0===r)for(var i in this.requestColumnsTrue=!0,this.requestColumns=[],n[t])this.requestColumns.push(i);else this.requestColumnsTrue=!1,this.requestColumns=r}return e.prototype.run=function(e){var t=e.id;return void 0!==this.expansionMap[t]?this.expansionMap[t]:this.columnUtil.isColumnSubset(this.requestColumns,e.request,e.requestColumnsTrue)?null:(this.expansionMap[t]=e.expand(this.requestColumns,this.requestColumnsTrue,this.responseColumns),this.expansionMap[t])},e}(),R=function(){function e(e,t,r,n,i){this.apiRequestService=e,this.errorHandler=t,this.promiseService=r,this.cache=n,this.columnUtil=i}return e.prototype.setColumn=function(e,t){return this.cache.setColumn(e,t)},e.prototype.setColumns=function(e,t,r){return this.cache.setColumns(e,t,r)},e.prototype.fetchItemTypeTranslations=function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r];t[i]=this.fetch(i,["id"])}return this.promiseService.all(t).then(function(e){var t={};for(var r in e)t[r]=e[r][r].id.name;return t},this.errorHandler.reject)},e.prototype.request=function(e,t,r){var n=this;void 0===r&&(r={filter:!1});var i,o=((i={})[e]=t,i);return this.apiRequestService.columns(e,o,r).then(function(r){return n.cache.setColumns(e,t,r.fetchColumnsObject())},this.errorHandler.reject)},e.prototype.fetch=function(e,t,r){var n=this,i=this.cache.retrieve(e,t);return!0!==i.missing&&0===i.missing.length?this.promiseService.when(i.cached):this.request(e,i.missing,r).then(function(e){return n.columnUtil.mergeResponseColumns(e,i.cached).merged})},e.prototype.fetchAll=function(e){return this.cache.containsAll(e)?this.promiseService.when(this.cache.getColumns(e)):this.request(e,!0)},e}(),F=function(){return function(e,t){void 0===t&&(t=null),this.apiColumn=e,this.parent=t,this.itemType="",this.children=[],this.isLeaf=!0;var r=e.id;this.id=r,null===t?(this.level=0,this.path=r,this.tailPath=""):(this.level=t.level+1,this.path=t.path+a.b+r,this.tailPath=0===t.level?r:t.tailPath+a.b+r)}}(),q={},E=0,b=function(){function e(e,t,r,n,i,o){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r,this.columnSetFactory=n,this.itemType=i,this.request=o,this.id=++E,this.response=q,this.link=null,this.main=[],this.derived=[],this.root=[],this.leaf=[],this.formatted={main:[],derived:[]},this.filtered=[],this.custom=[],this.searchable=[],this.item=[],this.notItem=[],this.requestColumnsTrue=!0===this.request}return e.prototype.resolve=function(e,t,r){return void 0===t&&(t=!0),void 0===r&&(r=!0),this.enableCaching=t,this.requestColumnsTrue?this.processResponseColumns(e):this.processRequestColumns(e,r),this},e.prototype.expandRequestColumns=function(e){var t=this.columnUtil.mergeRequestColumns(this.request,e).merged;this.request=t,this.requestColumnsTrue=!0===t},e.prototype.isSupersetOf=function(e){return this.columnUtil.isColumnSubset(e,this.request,this.requestColumnsTrue)},e.prototype.processResponseColumns=function(e){var t=this.itemType;for(var r in this.request=[],this.response=this.enableCaching?this.columnHandler.setColumns(this.itemType,!0,e):e,e[t])this.main.push(this.getColumnInfo(r,t,[],null,e)),this.request.push(r)},e.prototype.processRequestColumns=function(e,t){var r=this.itemType,n=this.request;if(this.response={},0!==n.length){for(var i=0,o=n;i<o.length;i++){var s=o[i];null!==(c=this.getRequestColumnInfo(s,r,null,e))&&(this.main.push(c),c.isLeaf||this.root.push(c))}var c;if(t&&void 0===this.response[r].id)null!==(c=this.getRequestColumnInfo("id",r,null,e))&&this.main.push(c)}},e.prototype.getRequestColumnInfo=function(e,t,r,n){var i,o=this.columnUtil.parseRequestColumn(e),s=o.id;if(void 0!==n[t]&&(i=n[t][s]),void 0===i)return console.warn("No api column for request column",s,"for itemType",t),null;this.enableCaching&&(i=this.columnHandler.setColumn(t,i));var c=this.response;return void 0===c[t]&&(c[t]={}),void 0===c[t][s]&&(c[t][s]=i),this.getColumnInfo(s,t,o.children,r,n)},e.prototype.getColumnInfo=function(e,t,r,n,i){var o=this.columnUtil,s=i[t][e],c=this.columnInfoFactory.construct(s,n),u=null!==n;if(u?this.derived.push(c):this[o.isItemColumn(s)?"item":"notItem"].push(c),o.isFormattedColumn(s)&&this.formatted[u?"derived":"main"].push(c),o.isFilteredColumn(s)&&this.filtered.push(c),o.isSearchableColumn(s)&&this.searchable.push(c),o.isCustomColumn(s)&&this.custom.push(c),"link"===s.type&&(this.link=c),0===r.length)return this.leaf.push(c),c;c.itemType=s.itemType,c.children=[],c.isLeaf=!1;for(var a=0,l=r;a<l.length;a++){var h=l[a],p=this.getRequestColumnInfo(h,s.itemType,c,i);null!==p&&c.children.push(p)}return c},e.prototype.expand=function(e,t,r){var n=this.columnUtil.mergeRequestColumns(this.request,e),i=this.columnUtil.mergeResponseColumns(this.response,r).merged,o=this.columnSetFactory.construct(this.itemType,n.merged,i),s=this.columnSetFactory.construct(this.itemType,n.difference,i,!1,!1);return o.requestColumnsTrue=this.requestColumnsTrue||t,{merged:o,difference:s}},e}(),O=function(){function e(){}return e.prototype.getColumnPath=function(e,t){for(var r="",n="",i=0,o=e;i<o.length;i++){n+=r+o[i].id,r=a.b}return null!==t&&(n+=a.h+t),n},e.prototype.getDateFormatOptions=function(e){var t=i(),r={"J-M-Y":t.format("DD-MM-YYYY"),"J-M":t.format("DD-MM"),"j+F+Y":t.format("D MMM YYYY"),"D+j+F+Y":t.format("dddd D MMM YYYY"),F:t.format("MMM"),f:t.format("MMMM"),D:t.format("dddd"),d:t.format("ddd")};return"datetime"===e&&Object(o.e)(r,{"J-M-Y+H:i":t.format("DD-MM-YYYY HH:mm"),"J-M+H:i":t.format("DD-MM HH:mm"),"j+F+Y+H:i":t.format("DD MMMM Y HH:mm"),"D+j+F+Y+H:i":t.format("dddd DD MMM Y HH:mm"),"H:i":t.format("HH:mm")}),r},e.prototype.isStringColumn=function(e){switch(e.type){case"email":case"phone":case"url":case"text":case"longtext":case"textreplace":return!0;default:return!1}},e.prototype.isFloatColumn=function(e){switch(e.type){case"double":case"volume":case"weight":case"distance":case"dimension":case"power":case"current":case"price":case"percentage":return!0;default:return!1}},e.prototype.isIntColumn=function(e){switch(e.type){case"int":case"number":case"quantity":return!0;default:return!1}},e.prototype.isNumberColumn=function(e){return this.isFloatColumn(e)||this.isIntColumn(e)},e.prototype.isCustomColumn=function(e){return"customfield"===e.fieldtype},e.prototype.isItemColumn=function(e,t){switch(void 0===t&&(t=!0),e.type){case"id":return t;case"item":case"child":case"sibling":case"link":return!0;default:return!1}},e.prototype.isDateColumn=function(e){switch(e.type){case"datetime":case"date":return!0;default:return!1}},e.prototype.isRenderedColumn=function(e){switch(e.type){case"datetime":case"date":case"duration":return!0;default:return!1}},e.prototype.isFilteredColumn=function(e){if("staffel"===e.id)return!0;if(void 0!==e.generator)return!0;switch(e.type){case"price":case"bool":case"enum":case"volume":case"weight":case"distance":case"dimension":case"quantity":case"email":case"url":case"datetime":case"date":case"time":case"duration":case"html":case"textreplace":case"longtext":case"percentage":return!0;default:return!1}},e.prototype.isFormattedColumn=function(e){switch(e.type){case"datetime":case"date":case"time":case"duration":case"color":case"json":case"number":case"filesize":return!0;default:return!1}},e.prototype.isSelectableColumn=function(e){switch(e.type){case"blob":case"coordinate":case"forceupdate":case"id":case"json":case"order":case"parentid":case"parenttype":case"password":case"token":return!1}return!0},e.prototype.hasLocationProperty=function(e,t){return 0!=(t&e.location)},e.prototype.isEditableColumn=function(e){if(e.readOnly)return!1;switch(e.type){case"date":case"datetime":case"duration":return!1}return!0},e.prototype.isSearchableColumn=function(e){switch(e.type){case"email":case"phone":case"text":case"longtext":case"html":return!0;default:return!1}},e.prototype.getDefaultWeight=function(e){switch(e.type){case"double":case"price":case"bool":case"int":case"percentage":case"color":case"number":case"power":case"current":return.5;case"url":case"enum":case"email":case"text":case"item":case"link":return 1.5;case"longtext":case"html":case"textreplace":return 2;case"date":case"datetime":case"time":case"duration":default:return 1}},e.prototype.getComparators=function(e){switch(e.type){case"dimension":case"weight":case"price":return["=",">","<"];case"date":case"datetime":case"time":case"duration":return[">","<"];default:return["=","!="]}},e.prototype.isColumnSubset=function(e,t,r){if(!0===e)return r;for(var n=0,i=e;n<i.length;n++){var o=i[n];if(!this.containsColumn(o,t))return!1}return!0},e.prototype.containsColumn=function(e,t){var r=this.parseRequestColumn(e),n=this.findColumn(r.id,t);if(-1===n)return!1;if(0===r.children.length)return!0;if("string"==typeof t[n])return!1;for(var i=0,o=r.children;i<o.length;i++){var s=o[i];if(!this.containsColumn(s,t[n][r.id]))return!1}return!0},e.prototype.responseColumnsAvailable=function(e,t,r){for(var n=0,i=t;n<i.length;n++){var o,s=i[n],c=this.parseRequestColumn(s),u=c.children,a=r[e];if(void 0===a)return!1;if(void 0===(o=a[c.id]))return!1;if(u.length>0&&!this.responseColumnsAvailable(o.itemType,u,r))return!1}return!0},e.prototype.copyRequestColumns=function(e){if(!0===e)return!0;for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];t.push(this.copyRequestColumn(i))}return t},e.prototype.copyRequestColumn=function(e){var t=this.parseRequestColumn(e);if(0===t.children.length)return t.id;for(var r,n=[],i=0,o=t.children;i<o.length;i++){var s=o[i];n.push(this.copyRequestColumn(s))}return(r={})[t.id]=n,r},e.prototype.mergeRequestColumns=function(e,t){if(!0===e)return{merged:!0,difference:[]};if(!0===t)return{merged:!0,difference:!0};for(var r=this.copyRequestColumns(e),n=[],i=0,o=t;i<o.length;i++){var s=o[i],c=this.mergeRequestColumn(s,r);null!==c&&n.push(c)}return{merged:r,difference:n}},e.prototype.mergeRequestColumn=function(e,t){var r=this.parseRequestColumn(e),n=this.findColumn(r.id,t);if(-1===n)return t.push(e),e;if(0===r.children.length)return null;"string"==typeof t[n]&&(t[n]=((i={})[r.id]=[],i));for(var i,o,s=[],c=0,u=r.children;c<u.length;c++){var a=u[c],l=this.mergeRequestColumn(a,t[n][r.id]);null!==l&&s.push(l)}return 0===s.length?null:((o={})[r.id]=s,o)},e.prototype.parseRequestColumn=function(e){var t="string"==typeof e,r=t?e:Object(o.g)(e);return{id:r,children:t?[]:e[r]}},e.prototype.mergeResponseColumns=function(e,t){var r={},n={};for(var i in e)if(void 0!==t[i]){var o=this.mergeResponseColumnMap(e[i],t[i]);r[i]=o.merged,n[i]=o.difference}else r[i]=e[i];for(var i in t)void 0===e[i]&&(r[i]=t[i],n[i]=t[i]);return{merged:r,difference:n}},e.prototype.mergeResponseColumnMap=function(e,t){var r={},n={};for(var i in e)r[i]=e[i];for(var i in t)Object(o.o)(e[i])||(r[i]=t[i],n[i]=t[i]);return{merged:r,difference:n}},e.prototype.isLocalColumnId=function(e){return"__"===e.substring(0,2)},e.prototype.processConfigColumns=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];this.isLocalColumnId(i)||this.processConfigColumn(this.parseConfigColumn(i),t)}return t},e.prototype.processLocalConfigColumns=function(e,t,r,n){for(var i={},o=0,s=t;o<s.length;o++){var c=s[o];i[c.id]=c}for(var u=0,l=e;u<l.length;u++){var h=l[u],p=h.split(a.h),f=p[0];this.isLocalColumnId(f)?void 0!==i[f]&&(n(h,i[f]),delete i[f]):r(h,f,p[1])}},e.prototype.consolidateColumns=function(e,t,r){var n=this,i=[],o=this.copyRequestColumns(r);return this.processLocalConfigColumns(e,t,function(e,t){n.processConfigColumn(t.split(a.b),o)},function(e,t){i.push(t),o=n.mergeRequestColumns(o,t.valueOptions.requestColumns).merged}),{request:o,local:i}},e.prototype.parseConfigColumn=function(e){return e.split(a.h)[0].split(a.b)},e.prototype.processConfigColumn=function(e,t){var r=e[0];if(1===e.length)-1===t.indexOf(r)&&t.push(r);else{var n,i=this.findColumnObject(r,t);-1===i&&(i=t.push(((n={})[r]=[],n))-1),this.processConfigColumn(e.slice(1),t[i][r])}},e.prototype.findColumnObject=function(e,t){for(var r=0;r<t.length;r++)if(Object(o.g)(t[r])===e)return r;return-1},e.prototype.findColumn=function(e,t){for(var r=0;r<t.length;r++){var n=t[r];if("string"!=typeof n){if(Object(o.g)(n)===e)return r}else if(n===e)return r}return-1},e}(),j=function(){function e(e,t,r,n,i,o,s,c){void 0===c&&(c=!1),this.collectionHandler=e,this.collectionMatcherFactory=t,this.keyService=r,this.requestColumnExpansionFactory=n,this.compilation=i,this.localCollectionCache=o,this.parameterMap=s,this.breakupByParent=c,this.requests=[]}return e.prototype.finalizeRequest=function(e){for(var t=e.collections.getCollectionsWithFittingItems(),r=e.columns,n=0,i=t;n<i.length;n++){var o=i[n];r.expand(o.columns)}return e.request.columns=r.get(),e},e.prototype.setRequestParent=function(e,t){var r=t.request;return"Void"!==e&&(r.parentType=e,r.parentId={},!0)},e.prototype.run=function(){if(this.breakupByParent)for(var e in this.compilation){var t=this.compilation[e];for(var r in t)if(!this.keyService.isLocalId(r)){var n=this.initializeRequest();this.extendRequest(t[r],this.setRequestParent(e,n)?r:null,n),this.requests.push(this.finalizeRequest(n))}}else for(var e in this.compilation){t=this.compilation[e],n=this.initializeRequest();var i=this.setRequestParent(e,n),o=!1;for(var r in t)this.keyService.isLocalId(r)||(this.extendRequest(t[r],i?r:null,n),o=!0);o&&this.requests.push(this.finalizeRequest(n))}return this.requests},e.prototype.initializeRequest=function(){return{request:{requestType:"create",items:{},columns:{}},columns:this.requestColumnExpansionFactory.construct(),items:{},collections:this.collectionMatcherFactory.construct([this.localCollectionCache,this.collectionHandler.entries],!0,!1)}},e.prototype.extendRequest=function(e,t,r){var n=r.request,i=r.items;for(var s in e)for(var c in void 0===n.itemType&&(n.itemType=s),void 0===i[s]&&(i[s]={},n.items[s]={}),e[s]){var u=e[s][c],a=Object(o.h)(this.compilation,[s,c]),l=n.items[s][c]={},h=Object(o.h)(this.parameterMap,[s,c]),p=void 0;if(null!==t&&(n.parentId[c]=t),r.columns.expand(u.columns),r.collections.expand(u),i[s][c]=u,l.values=u.formatRequest(),l.parameters=h,void 0!==a){for(var f in p=l.links={},a)for(var d in p[f]=[],a[f])p[f].push(d);this.extendRequest(a,null,r)}}},e}(),M=r(5),T=function(){function e(e,t,r,n,i,o,s,c,u,a,l,h,p,f,d,m,y){this.apiRequestService=e,this.authInterface=t,this.collectionEntryService=r,this.collectionHandler=n,this.collectionMatcherFactory=i,this.collectionResourceService=o,this.columnSetFactory=s,this.errorHandler=c,this.itemEntryService=u,this.itemHandler=a,this.itemRequestService=l,this.keyService=h,this.localCacheFactory=p,this.localCacheManager=f,this.moduleChangesCompilationFactory=d,this.promiseInterface=m,this.queryService=y}return e.prototype.invalidateCache=function(){this.itemHandler.entries.forEach(function(e){return e.queueReload()}),this.collectionHandler.entries.forEach(function(e){return e.queueReload()})},e.prototype.getItemDefinition=function(e,t,r){var n,i=this.keyService.parseStateKey(t);if(null===i)return{itemType:e,itemId:t,options:r,isNew:!1};switch(i.type){case"new":n=this.keyService.getLocalId();break;case"duplicate":r.duplicate=i.itemId,void 0===r.templateOptions&&(r.templateOptions={}),void 0===r.templateOptions.item&&(r.templateOptions.item=i.itemId),n=this.keyService.getLocalDuplicateId()}return{itemType:e,itemId:n,options:r,isNew:!0}},e.prototype.getCollectionMatcher=function(e,t){for(var r=this.getLocalCache(),n=this.collectionMatcherFactory.construct([r.collections],!1,!0),i=0,o=e;i<o.length;i++){var s=o[i];t&&r.items.add(s),n.expand(s)}return n},e.prototype.fetchTitle=function(e,t,r){return this.itemHandler.fetchTitle(e,t,r,this.getLocalCache().items)},e.prototype.getItemById=function(e,t,r){var n=this.getLocalCache();return this.itemHandler.fetchItem(e,t,this.itemEntryService.processOptions(r),n.items).then(function(e){return n.createItemResource(void 0!==e.linked?e.main:e,r,!1)},this.errorHandler.reject)},e.prototype.getItemsById=function(e,t,r){var n=this.getLocalCache();return this.itemHandler.fetchItems(e,t,this.itemEntryService.processOptions(r),n.items).then(function(e){return n.createItemResources(e,r)},this.errorHandler.reject)},e.prototype.getItemsByQuery=function(e,t,r){var n=this,i=this.getLocalCache(),o=this.itemEntryService.processOptions(r),s={};return s[e]=o.columns,this.apiRequestService.query(e,this.queryService.addParentCondition(t,o.parent),s).then(function(t){return n.itemRequestService.processResponse(t,t.links[e],o.parent,n.columnSetFactory.construct(e,o.columns,t.fetchColumnsObject()))},this.errorHandler.reject).then(function(e){return i.createItemResources(e,r)},this.errorHandler.reject)},e.prototype.getDuplicateById=function(e,t,r){void 0===r&&(r={}),r.edit=!0;var n=this.getItemDefinition(e,this.keyService.getDuplicateStateKey(t),r);return this.getItemByDef(n,!1)},e.prototype.getNewResource=function(e,t,r,n){var i=this;void 0===t&&(t={}),void 0===r&&(r=!1);var o=this.getLocalCache();return t.edit=!0,this.itemHandler.fetchItem(e,this.keyService.getLocalId(),this.itemEntryService.processOptions(t),o.items).then(function(e){var s=o.createItemResource(e.main,t,n,!0),c=i.processLinkedItems(e.linked,t,!0);return r?{main:s,linked:c}:s},this.errorHandler.reject)},e.prototype.getCollectionDef=function(e,t){return{itemType:e,options:{entry:this.collectionEntryService.processOptions(t),resource:this.collectionResourceService.processOptions(t)}}},e.prototype.getLinkCollectionsDef=function(e,t,r,n,i){return{itemType:r,linkType:e,linkIdArray:t,linkField:n,options:{entry:this.collectionEntryService.processOptions(i),resource:this.collectionResourceService.processOptions(i)}}},e.prototype.getCollection=function(e,t){var r=this,n=this.getLocalCache();return this.collectionHandler.fetch(e,this.collectionEntryService.processOptions(t),n.items,n.collections,n.deferredCollections).then(function(e){return n.createCollectionResource(e,r.collectionResourceService.processOptions(t))},this.errorHandler.reject)},e.prototype.getCollectionFromDef=function(e){var t=this.getLocalCache();return this.collectionHandler.fetch(e.itemType,e.options.entry,t.items,t.collections,t.deferredCollections).then(function(r){return t.createCollectionResource(r,e.options.resource)},this.errorHandler.reject)},e.prototype.getLinkCollection=function(e,t,r,n){var i=this,o=this.getLocalCache(),s=this.collectionEntryService.processOptions(n);return s.parent={itemType:e,itemId:t},this.collectionHandler.fetch(r,s,o.items,o.collections,o.deferredCollections).then(function(e){return o.createCollectionResource(e,i.collectionResourceService.processOptions(n))},this.errorHandler.reject)},e.prototype.getLinkCollections=function(e,t,r,n){var i=this,o=this.getLocalCache();return this.collectionHandler.batchFetch(e,t,r,this.collectionEntryService.processOptions(n),o.items,o.collections,o.deferredCollections).then(function(e){return o.createCollectionResources(e,i.collectionResourceService.processOptions(n))},this.errorHandler.reject)},e.prototype.getLinkCollectionsFromDef=function(e){var t=this.getLocalCache();return this.collectionHandler.batchFetch(e.linkType,e.linkIdArray,e.itemType,e.options.entry,t.items,t.collections,t.deferredCollections).then(function(r){return t.createCollectionResources(r,e.options.resource)},this.errorHandler.reject)},e.prototype.getAllLinkCollections=function(e,t,r){var n=this;return this.apiRequestService.query(e,{},{}).then(function(i){return n.getLinkCollections(e,i.links[e],t,r)},this.errorHandler.reject)},e.prototype.getItemByDef=function(e,t){var r=this,n=this.getLocalCache();return this.itemHandler.fetchItem(e.itemType,e.itemId,this.itemEntryService.processOptions(e.options),n.items).then(function(i){var o;return i instanceof M.f?o=i:(r.processLinkedItems(i.linked,e.options,!1),o=i.main),n.createItemResource(o,e.options,t,e.isNew)},this.errorHandler.reject)},e.prototype.cloneItem=function(e,t){return this.addSingleItem(e.entry.clone(),t,!1)},e.prototype.cloneCollection=function(e,t,r){var n=t.parent;return void 0===n&&(n=null),this.addCollection(e.entry.clone(n,r),t)},e.prototype.saveCurrentLocalCache=function(e,t,r,n){return this.getLocalCache().save(e,t,r,n)},e.prototype.getCurrentCollections=function(){return this.getLocalCache().collections},e.prototype.getCurrentItems=function(){return this.getLocalCache().items},e.prototype.getModuleChanges=function(e){if(void 0===e&&(e=this.getLocalCache()),void 0===e.rootItem)throw new Error("itemAdministrator: No root item for local cache "+e.id);return this.moduleChangesCompilationFactory.construct(e.rootItem,e.items,e.collections).process()},e.prototype.addSingleItem=function(e,t,r,n){return void 0===n&&(n=this.getLocalCache()),n.createItemResource(n.items.add(e),t,r)},e.prototype.addSingleItems=function(e,t){for(var r=this.getLocalCache(),n=[],i=0,o=e;i<o.length;i++){var s=o[i];n.push(this.addSingleItem(s,t,!1,r))}return n},e.prototype.addCollection=function(e,t){var r=this.getLocalCache();return r.collections.add(e),r.createCollectionResource(e,this.collectionResourceService.processOptions(t))},e.prototype.processLinkedItems=function(e,t,r){for(var n=this.getLocalCache(),i={},s=0,c=e;s<c.length;s++){var u=c[s],a=u.itemType,l=u.itemEntries,h=void 0;r&&(h=this.collectionMatcherFactory.construct([n.collections],!1,!1)),i[a]=[];for(var p=0,f=l;p<f.length;p++){var d=f[p];i[a].push(n.createItemResource(d,t)),r&&h.expand(d),"Projectnotitie"===a&&Object(o.b)(n.tabRequestParameters,[d.itemType,d.itemId],[{},{no_notification:!0}])}r&&h.addToCollections()}return i},e.prototype.getLocalCache=function(){return this.localCacheManager.getCurrentLocalCache(this.authInterface.getUniqueUserId())},e.prototype.resetLocalCache=function(){var e=this.getLocalCache(),t=this.localCacheFactory.construct();e.clearResources(),this.localCacheManager.setCurrentLocalCache(this.authInterface.getUniqueUserId(),t)},e.prototype.addToCollections=function(e,t){return this.getCollectionMatcher(e,!0).addToCollections(t)},e.prototype.removeFromCollections=function(e,t){return this.getCollectionMatcher(e,!1).removeFromCollections(t)},e.prototype.saveLocal=function(e){var t=e.entry;return t.setDisplayName(),this.addToCollections([t]),this.promiseInterface.when(e)},e.prototype.updateItemIdMap=function(e,t){if(void 0!==t)for(var r in t){var n=t[r];void 0!==e[r]&&(e[n]=e[r],delete e[r])}},e.prototype.createCollectionResource=function(e,t,r){return void 0===r&&(r=!0),this.addCollection(e,r?this.collectionResourceService.processOptions(t):t)},e.prototype.createItemResource=function(e,t,r){return this.addSingleItem(e,t,r)},e.prototype.onBeforeSave=function(e,t,r){return this.getLocalCache().onBeforeSave(e,t,r)},e.prototype.onSaveSuccess=function(e,t,r){return this.getLocalCache().onSaveSuccess(e,t,r)},e}(),k=function(){function e(e){this.queryMatcherFactory=e,this.entries={}}return e.prototype.some=function(e){var t=this.entries;for(var r in t)for(var n in t[r])if(e(t[r][n]))return!0;return!1},e.prototype.getByItemType=function(e){var t=this.entries[e],r=[];if(void 0===t)return r;for(var n in t)r.push(t[n]);return r},e.prototype.getByQuery=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var i in r){var o=r[i];o.isDeferred()||this.matchQuery(o,t)&&n.push(o)}return n},e.prototype.getLocalByQuery=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var i in r){var o=r[i];o.isLocal()&&(this.matchQuery(o,t)&&n.push(o))}return n},e.prototype.getByParent=function(e,t,r){var n=this.entries[r],i=[];if(void 0===n)return i;for(var o in n){var s=n[o],c=s.parent;null!==c&&(e===c.itemType&&t==c.itemId&&i.push(s))}return i},e.prototype.forEach=function(e){var t=this.entries;for(var r in t)for(var n in t[r])e(t[r][n])},e.prototype.toArray=function(){var e=this.entries,t=[];for(var r in e)for(var n in e[r])t.push(e[r][n]);return t},e.prototype.add=function(e){var t=this.entries,r=e.itemType;return void 0===t[r]&&(t[r]={}),t[r][e.itemId]=e},e.prototype.get=function(e,t){return void 0===this.entries[e]?void 0:this.entries[e][t]},e.prototype.contains=function(e,t){return void 0!==this.entries[e]&&void 0!==this.entries[e][t]},e.prototype.updateItemId=function(e,t){var r=this.entries[e.itemType];return delete r[t],r[e.itemId]=e},e.prototype.clear=function(e){return void 0===e?(this.entries={},!0):void 0!==this.entries[e.itemType]&&delete this.entries[e.itemType][e.itemId]},e.prototype.matchQuery=function(e,t){return!0===this.queryMatcherFactory.construct(e.itemType,e.getFields(),e.parent).matchQuery(t.object)},e}(),w=function(){function e(e,t){this.authInterface=e,this.keyService=t,this.undefinedItemError="Het opgevraagde item bestaat niet / Je hebt niet voldoende rechten om dit item te bekijken",this.ALL_PERMISSIONS=7}return e.prototype.processOptions=function(e){return Object(o.y)(e,{columns:!0,parent:null,templateOptions:{},templateColumns:{},deferRequest:!1})},e.prototype.createLocalConversionMap=function(e,t,r,n){void 0===r&&(r=!1);var i=n.links[e][0],o={};return o[e]={},o[e][i]=t,r&&this.expandLocalConversionMap(e,i,n,o),o},e.prototype.expandLocalConversionMap=function(e,t,r,n){var i=r.items[e][t].links;for(var o in i){var s=i[o];void 0===n[o]&&(n[o]={});for(var c=0,u=s;c<u.length;c++){var a=u[c];n[o][a]=this.keyService.getLocalId(),this.expandLocalConversionMap(o,a,r,n)}}},e.prototype.expandConversionMap=function(e,t,r){var n,i=e.itemType,o=e.itemId;return void 0===t[i]&&(t[i]={}),void 0!==(n=t[i])[o]?n[o]:(void 0===r&&(r=this.keyService.getLocalId()),n[o]=r)},e.prototype.batchExpandConversionMap=function(e,t){for(var r=0,n=e;r<n.length;r++){var i=n[r];this.expandConversionMap(i,t)}return t},e.prototype.getConversionValue=function(e,t,r){if(void 0!==r[e])return r[e][t]},e.prototype.batchClone=function(e,t){void 0===t&&(t={});var r=[];this.batchExpandConversionMap(e,t);for(var n=0,i=e;n<i.length;n++){var o=i[n];r.push(o.clone(t))}return r},e.prototype.getFullName=function(e,t,r){return e.trim().concat(" ",t).trim().concat(" ",r)},e.prototype.getTitleField=function(e){switch(e){case"Exemplaar":return"serienummer";case"Factuur":return"nummer";case"Files":return"friendlyname";case"Functie":case"Standaardfunctie":return"naamintern";case"Voorraadmutatie":return"omschrijving";case"Barcode":return"code";case"Betaalmiddel":case"Betalingsconditie":case"Briefpapier":case"TaxClass":case"TaxSchema":case"Condition":case"Factuurmoment":case"Functiegroep":case"Grootboek":case"Inhuur":case"Inhuurgroep":case"Inhuurmateriaal":case"Materiaal":case"MateriaalCat":case"Medewerkertarief":case"Notitie":case"Planningmateriaal":case"Project":case"Staffelgroep":case"Subproject":case"Taak":case"Tag":case"Template":case"Tijd":case"Titel":case"Type":case"Voertuig":return"naam";default:return"displayname"}},e.prototype.getLocalDefaultValues=function(){var e=this.authInterface;return{permissions:a.a,creator:e.getUserId(),created:i()}},e}(),x=function(){function e(e,t,r,n,i,o,s,c,u,a,l,h,p,f){this.apiFormatter=e,this.apiRequestService=t,this.batchStatusFactory=r,this.columnExpansionFactory=n,this.columnHandler=i,this.columnSetFactory=o,this.columnUtil=s,this.errorHandler=c,this.itemCacheFactory=u,this.itemEntryFactory=a,this.itemEntryService=l,this.keyService=h,this.promiseService=p,this.templateFactory=f,this.templates={},this.entries=this.itemCacheFactory.construct()}return e.prototype.fetchItem=function(e,t,r,n){var i=this,o=this.getEntryStatus(e,t,r,n),s=o.entry,c=o.status;return c===a.e.LOCAL?this.fetchTemplate(e,r.templateOptions,r.templateColumns).then(function(e){return i.resolveLocal(s,r.parent,e,n)},function(e){return s.reject(e),i.errorHandler.reject(e)}):this.resolveCached(s,c,r)},e.prototype.fetchItems=function(e,t,r,n){for(var i=this,o=this.batchStatusFactory.construct(function(e){return e.itemId},function(e){return e.deferred.promise}),s={},c=0,u=t;c<u.length;c++){var l=u[c];o.add(this.getEntryStatus(e,l,r,n))}return s.entries=o.getPromises(),o.hasRequests()&&(s.requests=this.requestItems(e,o.getRequestIds(),r.columns)),o.hasEntries([a.e.LOCAL])&&(s.template=this.fetchTemplate(e,r.templateOptions,r.templateColumns)),this.promiseService.all(s).then(function(t){return i.batchResolve(e,o,r.columns,t,n)},this.errorHandler.reject)},e.prototype.resolveCached=function(e,t,r){var n=this;switch(t){case a.e.CACHED:return this.promiseService.when(e);case a.e.PROMISED:return e.deferred.promise;case a.e.PROMISED_EXPAND:return e.deferred.promise.then(function(){return n.resolveCached(e,n.getCachedEntryStatus(e,r),r)},this.errorHandler.reject);case a.e.EXPAND:var i=this.columnUtil.mergeRequestColumns(e.columns.request,r.columns).difference;return this.requestItem(e,i).then(function(t){n.resolveExpansion(e,n.columnExpansionFactory.construct(e.itemType,i,t.fetchColumnsObject()),t)},function(t){e.reject(t)}),e.deferred.promise;case a.e.RESOLVE_VALUES:return this.requestItem(e).then(function(t){n.resolveRemoteValues(e,t)},function(t){e.reject(t)}),e.deferred.promise;default:return this.requestItem(e).then(function(t){n.resolveRemote(e,e.columns.resolve(t.fetchColumnsObject()),t)},function(t){e.reject(t)}),e.deferred.promise}},e.prototype.resolveLocal=function(e,t,r,n){var i=e.itemType,o=e.itemId,s=this.itemEntryService.createLocalConversionMap(i,o,!0,r.response);return e.columns=r.columns,null!==t&&e.setParent(t.itemType,t.itemId),e.setLocalFields(r.fields,s).resolve(),{main:e,linked:this.createLocalEntries(i,o,r,s,n)}},e.prototype.resolveExpansion=function(e,t,r){var n=e.itemType,i=e.itemId,o=t.run(e.columns);return null===o?e:(e.expand(r.fetchObject(n,i),r.fetchDerivedObject(n,i,o.difference.root),o),e.resolve())},e.prototype.resolveRemote=function(e,t,r){var n=this.getResponseFields(e,t,r);return null===n?null:e.resolveDeferred(n.initial,n.derived,t)},e.prototype.resolveRemoteValues=function(e,t){var r=this.getResponseFields(e,e.columns,t);return null===r?null:e.updateFields(r.initial,r.derived,!1).resolve()},e.prototype.getResponseFields=function(e,t,r){var n=e.itemType,i=e.itemId,o=r.fetchObject(n,i);return void 0===o?(e.reject(),this.entries.clear(e),null):{initial:o,derived:r.fetchDerivedObject(n,i,t.root)}},e.prototype.fetchTemplate=function(e,t,r){var n=this;void 0===t&&(t={}),void 0===r&&(r={});var i=Object(o.i)(t),s=Object(o.g)(r);if(!i){var c=this.templates[e];if(void 0!==c&&(null===s||this.columnUtil.responseColumnsAvailable(s,r[s],c.responseColumns)))return this.promiseService.when(c)}return this.promiseService.all({template:this.apiRequestService.template(e,t),additionalColumns:null===s?{}:this.columnHandler.fetch(s,r[s])}).then(function(t){var r=t.template,o=n.templateFactory.construct(e,r,t.additionalColumns);return!i&&r.cacheable&&(n.templates[e]=o),o},this.errorHandler.reject)},e.prototype.getEntryStatus=function(e,t,r,n){var i;return this.keyService.isLocalId(t)?void 0!==(i=n.get(e,t))?{entry:i,status:this.getCachedEntryStatus(i,r)}:(i=this.itemEntryFactory.constructDeferred(e,t,!0,!1),{entry:n.add(i),status:a.e.LOCAL}):void 0!==(i=this.entries.get(e,t))?{entry:n.add(i),status:this.getCachedEntryStatus(i,r)}:(i=this.itemEntryFactory.constructDeferred(e,t,r.columns,r.deferRequest),n.add(i),this.entries.add(i),{entry:i,status:r.deferRequest?a.e.PROMISED:a.e.RESOLVE})},e.prototype.isColumnSuperset=function(e,t){return e.isLocal()||e.columns.isSupersetOf(t)},e.prototype.getCachedEntryStatus=function(e,t){var r=t.columns;return e.isDeferred()?e.deferRequest?(e.columns.expandRequestColumns(r),a.e.RESOLVE):this.isColumnSuperset(e,r)?a.e.PROMISED:a.e.PROMISED_EXPAND:this.isColumnSuperset(e,r)?e.reloadQueued?(e.reloadQueued=!1,e.isLocal()?a.e.CACHED:(e.defer(),a.e.RESOLVE_VALUES)):a.e.CACHED:(e.defer(),a.e.EXPAND)},e.prototype.batchResolve=function(e,t,r,n,i){var o=this,s=n.requests,c=[a.e.EXPAND,a.e.PROMISED_EXPAND],u=[a.e.RESOLVE],l=!0;if(t.hasEntries(c)){var h=this.columnExpansionFactory.construct(e,r,s.fetchColumnsObject());t.forEachEntry(c,function(e){return o.resolveExpansion(e,h,s)})}if(t.hasEntries(u)){var p=this.columnSetFactory.construct(e,r,s.fetchColumnsObject());t.forEachEntry(u,function(e){null===o.resolveRemote(e,p,s)&&(l=!1)})}return t.forEachEntry([a.e.RESOLVE_VALUES],function(e){null===o.resolveRemoteValues(e,s)&&(l=!1)}),t.forEachEntry([a.e.LOCAL],function(e){return o.resolveLocal(e,null,n.template,i)}),l?t.getArray():this.errorHandler.reject()},e.prototype.createLocalEntries=function(e,t,r,n,i,o){var s=this;void 0===o&&(o=[]);var c=r.response,u={},a={},l=[];for(var h in c.items)h!==e&&-1===o.indexOf(h)&&(u[h]=this.columnSetFactory.construct(h,!0,r.responseColumns));var p=function(e,t,r){var h={itemType:e,itemId:t},f=c.items[e][r].links;for(var d in f)if(-1===o.indexOf(d)&&f.hasOwnProperty(d)){var m=f[d];void 0===a[d]&&l.push({itemType:d,itemEntries:a[d]=[]});for(var y=0,v=m;y<v.length;y++){var g=v[y],C=n[d][g],I=s.itemEntryFactory.constructLocalLinked(d,C,c.fetchObject(d,g),h,u[d],n);i.add(I),a[d].push(I),p(d,C,g)}}};return p(e,t,c.links[e][0]),l},e.prototype.fetchTitle=function(e,t,r,n){void 0===r&&(r=!0);var i=this.itemEntryService.getTitleField(e);return this.fetchItem(e,t,this.itemEntryService.processOptions({columns:[i],deferRequest:r}),n).then(function(e){return void 0!==e.main?e.main.getFields()[i]:e.getFields()[i]},this.errorHandler.reject)},e.prototype.resolveDerivedValues=function(e,t,r){for(var n=[],i=0,o=t;i<o.length;i++){var s=o[i];n.push(this.fetchDerivedValuesByColumn(e,s,r))}return this.promiseService.all(n).then(function(){return e},this.errorHandler.reject)},e.prototype.getDefaultValuesByColumn=function(e,t){var r=t.children;if(0!==r.length)for(var n=0,i=r;n<i.length;n++)for(var o=i[n],s=0,c=e;s<c.length;s++){c[s].derived[o.path]=this.apiFormatter.getDefaultValue(o.apiColumn.type)}},e.prototype.getItemIdByColumn=function(e,t){return 0===t.level?"link"===t.apiColumn.type&&null!==e.parent?e.parent.itemId:e.modified[t.path]:e.derived[t.path]},e.prototype.fetchDerivedValuesByColumn=function(e,t,r){var n=this,i=t.children;if(0===i.length)return this.promiseService.when();var o=i[0];if(1===i.length&&"id"===o.apiColumn.type){for(var s=0,c=e;s<c.length;s++){(h=c[s]).derived[o.path]=this.getItemIdByColumn(h,t)}return this.promiseService.when()}for(var u={},a=0,l=e;a<l.length;a++){var h=l[a],p=this.getItemIdByColumn(h,t);void 0===u[p]&&(u[p]=[]),u[p].push(h)}void 0!==u.null&&this.getDefaultValuesByColumn(u.null,t);var f=[];for(var p in u)"null"!==p&&f.push(+p);if(0===f.length)return this.promiseService.when();for(var d=[],m=0,y=i;m<y.length;m++){var v=y[m];d.push(v.id)}return this.fetchItems(t.itemType,f,{columns:d},r).then(function(e){for(var t=0,o=e;t<o.length;t++)for(var s=o[t],c=s.getFields(),a=0,l=u[s.itemId];a<l.length;a++)for(var h=l[a],p=0,f=i;p<f.length;p++){var d=f[p];h.derived[d.path]=c[d.id]}return n.resolveDerivedValues(e,i,r)},this.errorHandler.reject)},e.prototype.requestItem=function(e,t){return void 0===t&&(t=e.columns.request),this.requestItems(e.itemType,[e.itemId],t)},e.prototype.requestItems=function(e,t,r){return this.apiRequestService.query(e,{id:t},((n={})[e]=r,n));var n},e}(),D=function(){function e(e,t,r,n,i,o,s,c){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.columnExpansionFactory=n,this.columnSetFactory=i,this.itemEntryFactory=o,this.queryService=s,this.promiseService=c}return e.prototype.requestItem=function(e,t,r){var n,i=((n={})[e]=r,n);return this.apiRequestService.query(e,{id:t},i)},e.prototype.requestItems=function(e,t,r){void 0===t&&(t=e.query.object),void 0===r&&(r=e.options.columns);var n,i=e.options,o={requestType:"query",itemType:null===i.queryItemType?e.itemType:i.queryItemType,columns:(n={},n[e.itemType]=r,n),query:t,limit:null};return null!==i.limit&&(o.limit=i.limit),this.apiRequestService.requestSkeleton(o)},e.prototype.requestLinkItems=function(e,t,r,n,i){var o,s=((o={})[r]=i,o);return null===n?this.apiRequestService.query(e,{id:t},s):this.apiRequestService.query(r,this.queryService.addAndCondition(n,{linkedTo:e,query:{id:t}}),s)},e.prototype.processExpansion=function(e,t,r,n){for(var i=this.columnExpansionFactory.construct(r,e,t.fetchColumnsObject()),o=0,s=n;o<s.length;o++){var c=s[o];c.isLocal()||this.handleCachedItem(c,t,i)}return i},e.prototype.processResponse=function(e,t,r,n,i){var o=this;void 0===i&&(i=this.columnExpansionFactory.construct(n.itemType,!!n.requestColumnsTrue||n.request,n.response));for(var s=this.itemHandler,c=n.itemType,u=n.root,a=[],l=[],h=0,p=t;h<p.length;h++){var f=p[h],d=s.entries.get(c,f);void 0===d?(d=this.itemEntryFactory.construct(f,e.fetchObject(c,f),e.fetchDerivedObject(c,f,u),n),s.entries.add(d),a.push(d)):d.isDeferred()?d.deferRequest?a.push(d.resolveDeferred(e.fetchObject(c,f),e.fetchDerivedObject(c,f,u),n)):l.push(d.deferred.promise):d.reloadQueued?(d.reloadQueued=!1,d.updateFields(e.fetchObject(c,f),e.fetchDerivedObject(c,f,u),!1),a.push(d)):a.push(this.handleCachedItem(d,e,i)),null!==r&&(d.parent=r)}return this.promiseService.all(l).then(function(t){for(var r=0,n=t;r<n.length;r++){var s=n[r];a.push(o.handleCachedItem(s,e,i))}return a},this.errorHandler.reject)},e.prototype.handleCachedItem=function(e,t,r){var n=r.run(e.columns);return null===n?e:e.expand(t.fetchObject(e.itemType,e.itemId),t.fetchDerivedObject(e.itemType,e.itemId,n.difference.root),n)},e.prototype.processLinkResponse=function(e,t,r,n,i){for(var s=e.fetchColumnsObject(),c=this.columnSetFactory.construct(n,i.columns,s),u=this.columnExpansionFactory.construct(n,i.columns,s),a=e.items[t],l={},h=0,p=r;h<p.length;h++){var f=p[h];l[f]=Object(o.x)(a,[f,"links",n])?this.processResponse(e,a[f].links[n],{itemType:t,itemId:f},c,u):[]}return this.promiseService.all(l).then(function(e){return{items:e,columns:c,columnExpansion:u}},this.errorHandler.reject)},e}(),L=function(){function e(){}return e.prototype.processOptions=function(e){return Object(o.y)(e,{edit:!1,onChange:y.noop,onDeactivate:y.noop})},e.prototype.compareOptions=function(e,t){for(var r in e)if(e[r]!==t[r])return!1;return!0},e}(),A=function(){function e(){this.separator=":"}return e.prototype.getSingleKey=function(e,t){return e.concat(this.separator,String(t))},e.prototype.getCollectionCacheKey=function(e,t,r){return e.concat(this.separator,String(t),this.separator,r)},e.prototype.getCssKey=function(){return Array.prototype.join.call(arguments,"_")},e.prototype.parseStateKey=function(e){return 0===(e=e.toString()).indexOf(a.f)?{type:"new",template:e.substring(a.f.length)}:0===e.indexOf(a.c)?{type:"duplicate",itemId:e.substring(a.c.length)}:null},e.prototype.getDuplicateStateKey=function(e){return a.c+e},e.prototype.getNewStateKey=function(e){return a.f+e},e.prototype.getLocalId=function(){return+(a.g+this.getRandomString())},e.prototype.getLocalDuplicateId=function(){return+(a.d+this.getRandomString())},e.prototype.getRandomString=function(){return(""+Math.random()).split(".")[1].substr(0,8)},e.prototype.isLocalId=function(e){return void 0!==e&&(this.isNewId(e)||this.isDuplicateId(e))},e.prototype.isNewId=function(e){return e===a.f||(""+e).substring(0,a.g.length)===a.g},e.prototype.isDuplicateId=function(e){return e===a.c||(""+e).substring(0,a.d.length)===a.d},e}(),H=function(){function e(e,t,r,n,i,o,s,c,u,a){void 0===a&&(a=""),this.errorHandler=e,this.lockService=t,this.itemResourceFactory=r,this.collectionCacheFactory=n,this.changesProcessorFactory=i,this.itemCacheFactory=o,this.collectionResourceFactory=s,this.itemResourceService=c,this.promiseService=u,this.id=a,this.tabRequestParameters={},this.callbacks={onBeforeSave:{always:{},onClose:{},skipOnClose:{}},onSaveSuccess:{always:{},onClose:{},skipOnClose:{}}},this.changesInterval=null,this.hasChanges=!1,this.items=this.itemCacheFactory.construct(),this.collections=this.collectionCacheFactory.construct(),this.deferredCollections=this.collectionCacheFactory.construct()}return e.prototype.createItemResource=function(e,t,r,n){var i=this;return void 0===r&&(r=!1),r&&(this.rootItem=e),(t=this.itemResourceService.processOptions(t)).onDeactivate=function(e){return i.onDeactivateItem(e)},this.itemResourceFactory.construct(e,t,n)},e.prototype.createItemResources=function(e,t){for(var r=[],n=0,i=e;n<i.length;n++){var o=i[n];r.push(this.createItemResource(o,t))}return r},e.prototype.createCollectionResource=function(e,t){return this.collectionResourceFactory.construct(e,t,this)},e.prototype.createCollectionResources=function(e,t){var r={};for(var n in e)r[n]=this.createCollectionResource(e[n],t);return r},e.prototype.clearItem=function(e){this.clearItemEntry(e.entry)},e.prototype.clearItemEntry=function(e){this.items.clear(e),e.clearResources()},e.prototype.clearCollection=function(e){var t=e.entry;this.collections.clear(t),t.clearResources()},e.prototype.clearResources=function(e){void 0===e&&(e=!1),this.items.forEach(function(e){return e.clearResources()}),this.collections.forEach(function(t){return t.clearResources(e)}),this.deferredCollections.clear()},e.prototype.updateSingleItems=function(e){for(var t in e)for(var r in e[t]){var n=this.items.get(t,r);void 0!==n&&this.items.updateItemId(n,r)}},e.prototype.revertChanges=function(){var e=this;return this.items.forEach(function(e){return e.resetModified()}),this.collections.forEach(function(t){return e.resetCollection(t)}),this.hasChanges=!1,this.isLockable()?this.lockService.deleteLock(this.rootItem):this.promiseService.when()},e.prototype.resetCollection=function(e){if(e.hasEditResources&&e.revertChanges(),e.hasItemEditResources)for(var t=0,r=e.items;t<r.length;t++){r[t].resetModified()}},e.prototype.detectChanges=function(){var e=this;return!!this.hasChanges||(this.items.some(function(e){return e.hasChanges()})?this.hasChanges=!0:this.hasChanges=this.collections.some(function(t){return e.collectionHasChanges(t)}))},e.prototype.collectionHasChanges=function(e){return!(!e.hasEditResources||!e.hasAddedItems()&&!e.hasRemovedItems())||e.hasItemEditResources&&e.hasUpdatedItems()},e.prototype.isLockable=function(){return void 0!==this.rootItem&&this.rootItem.isLockable()},e.prototype.save=function(e,t,r,n){var i=this;return void 0===e&&(e=!1),void 0===t&&(t={}),this.detectChanges(),this.disableChangesWatcher(),(this.isLockable()?this.lockService.fetchLock(this.rootItem):this.promiseService.when()).then(function(){return i.executeCallbackEvent(i.callbacks.onBeforeSave,function(e){return e(i)},e)},this.errorHandler.reject).then(function(){var e=Object(o.e)({},i.tabRequestParameters,t);return i.tabRequestParameters={},i.changesProcessorFactory.construct().execute(i.items.toArray(),i.collections.toArray(),e,r,n)},this.errorHandler.reject).then(function(t){return i.isLockable()&&i.lockService.clearLock(i.rootItem),i.hasChanges=!1,e||i.updateSingleItems(t),i.executeCallbackEvent(i.callbacks.onSaveSuccess,function(e){return e(i,t)},e).then(function(){return e||i.enableChangesWatcher(),t},i.errorHandler.reject)},this.errorHandler.reject)},e.prototype.onBeforeSave=function(e,t,r){void 0===r&&(r="always");var n=this.callbacks.onBeforeSave[r];return n[e]=t,function(){return delete n[e]}},e.prototype.onSaveSuccess=function(e,t,r){void 0===r&&(r="always");var n=this.callbacks.onSaveSuccess[r];return n[e]=t,function(){return delete n[e]}},e.prototype.executeCallbackEvent=function(e,t,r){var n=this;return this.executeCallbacks(e.always,t).then(function(){return n.executeCallbacks(e[r?"onClose":"skipOnClose"],t)},this.errorHandler.reject)},e.prototype.executeCallbacks=function(e,t){var r={};for(var n in e)r[n]=t(e[n]);return this.promiseService.all(r)},e.prototype.enableChangesWatcher=function(){var e=this;null!==this.changesInterval&&(console.warn("Changes watcher already running!",this),this.disableChangesWatcher()),this.changesInterval=setInterval(function(){e.detectChanges()&&(e.disableChangesWatcher(),e.isLockable()&&e.lockService.fetchLock(e.rootItem))},3e3)},e.prototype.disableChangesWatcher=function(){null!==this.changesInterval&&(clearInterval(this.changesInterval),this.changesInterval=null)},e.prototype.onDeactivateItem=function(e){this.clearItemEntry(e)},e.prototype.onActivateItem=function(e){this.items.add(e)},e}(),P=function(){function e(e,t,r,n){this.apiRequestService=e,this.errorHandler=t,this.keyService=r,this.promiseService=n,this.lockItems={},this.promises={}}return e.prototype.getValue=function(e,t){var r=e.itemType;if(void 0!==t[r])return t[r][e.itemId]},e.prototype.setValue=function(e,t,r){return Object(o.b)(r,[e.itemType,e.itemId],[{},t])},e.prototype.getLocks=function(){return this.lockItems},e.prototype.hasLock=function(e){for(var t in this.lockItems)for(var r in this.lockItems[t]){var n=this.lockItems[t][r];if(!n.isForeign&&n.id==e)return!0}return!1},e.prototype.isLocked=function(e){var t=this.getValue(e,this.lockItems);return void 0!==t&&t.isForeign},e.prototype.getMessage=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t&&t.isForeign)return t.message},e.prototype.fetchCachedLock=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t)return this.promiseService.when(t);var r=this.getValue(e,this.promises);return void 0!==r?r:this.promiseService.when()},e.prototype.fetchLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){return void 0!==r?r:t.requestLock(e)},this.errorHandler.reject).then(function(e){return e.isForeign?t.errorHandler.reject(e.message):e.token},this.errorHandler.reject)},e.prototype.requestLock=function(e){var t=this,r=e.itemType,n=e.itemId,i=this.apiRequestService.create("Locktoken",this.keyService.getLocalId(),{itemtype:r,item:n}).then(function(i){return delete t.promises[r][n],t.setValue(e,i.fetchObject("Locktoken",i.links.Locktoken[0]),t.lockItems)},function(i){return delete t.promises[r][n],301===i.code?t.setValue(e,{isForeign:!0,message:i.message},t.lockItems):t.errorHandler.reject(i)});return this.setValue(e,i,this.promises)},e.prototype.deleteLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){if(void 0!==r){if(!r.isForeign)return t.apiRequestService.delete("Locktoken",r.id).then(function(){t.clearLock(e)},t.errorHandler.reject);t.clearLock(e)}},this.errorHandler.reject)},e.prototype.clearLock=function(e){var t=e.itemType;return void 0!==this.lockItems[t]&&delete this.lockItems[t][e.itemId]},e}(),V={},_=function(){function e(e,t,r){this.rootItemEntry=e,this.singleItemCache=t,this.collectionCache=r,this.parentMap={},this.destination={}}return e.prototype.process=function(){return this.parentMap=this.createParentMap(this.singleItemCache),this.processItems(this.rootItemEntry.itemType,[this.rootItemEntry],{}),{itemType:this.rootItemEntry.itemType,itemId:this.rootItemEntry.itemId,items:this.destination}},e.prototype.createParentMap=function(e){var t={};return e.forEach(function(e){var r=e.itemType,n=e.parent;if(null!==n){var i=n.itemType,o=n.itemId;void 0===t[i]&&(t[i]={});var s=t[i];void 0===s[o]&&(s[o]={}),void 0===(s=s[o])[r]&&(s[r]=[]),s[r].push(e)}}),t},e.prototype.processItems=function(e,t,r){void 0===this.destination[e]&&(this.destination[e]={}),void 0===r[e]&&(r[e]=[]);for(var n=0,i=t;n<i.length;n++){var o=i[n],s=o.itemId;void 0===this.destination[e][s]&&(r[e].push(s),this.destination[e][s]=this.processItem(o))}},e.prototype.processItem=function(e){var t=e.itemType,r=e.itemId,n=this.getItemsByParent(t,r),i=this.collectionCache.getCollectionsByParent(t,r),s=e.formatRequest(),c={};for(var u in n)this.processItems(u,n[u],c);for(var a=0,l=i;a<l.length;a++){var h=l[a];null===h.options.query&&this.processItems(h.itemType,h.items,c)}var p=Object(o.i)(s),f=Object(o.i)(c);return p&&f?{values:s,links:c}:p?{values:s}:f?{links:c}:V},e.prototype.getItemsByParent=function(e,t){var r=this.parentMap[e];return void 0===r?{}:void 0===r[t]?{}:r[t]},e}(),U="maybe",B=function(){function e(e,t,r,n){void 0===n&&(n=null),this.apiFormatter=e,this.itemType=t,this.fields=r,this.parent=n}return e.prototype.compareValues=function(e,t){return i.isMoment(t)?this.apiFormatter.compareMomentObjects(t,e):i.isDuration(t)?this.apiFormatter.compareDurations(t,e):t==e},e.prototype.matchQuery=function(e){if(void 0!==e.search)return U;if(void 0!==e.custom)return U;if(void 0!==e.linkedTo)return this.matchLinkedToQuery(e);if(void 0!==e.conditions)return this.matchComplexQuery(e);if(void 0!==e.key)return this.matchSimpleQuery(this.fields[e.key],e);if(!Object(o.i)(e))return!0;throw new Error("queryMatcher: Unsupported query! Parsed?")},e.prototype.matchLinkedToQuery=function(e){if(e.reverse)return U;var t,r=this.parent;return(t=null!==r&&(e.linkedTo===r.itemType&&this.matchSimpleQuery(r.itemId,e.query)))===U?U:e.not?!t:t},e.prototype.matchComplexQuery=function(e){var t,r,n=e.conditions;switch(e.operator){case"AND":t=!0,r=!1;break;case"OR":t=!1,r=!0;break;default:throw new Error("queryMatcher: Unsupported operator")}for(var i=0,o=n;i<o.length;i++){var s=o[i],c=this.matchQuery(s);if(c===r)return r;c===U&&(t=U)}return t},e.prototype.matchSimpleQuery=function(e,t){var r=t.key,n=t.value;if(!Object(o.i)(t))return!0;if(void 0===e)return console.warn("Required field",r,"not found for",this.itemType),U;switch("NOW"===n&&(n=i()),t.comparator){case"=":return this.compareValues(e,n);case"!=":return!this.compareValues(e,n);case"<":return e<n;case"<=":return e<=n;case">":return e>n;case">=":return e>=n;case"IN":return Object(o.j)(e,n);case"NOT IN":return!Object(o.j)(e,n);default:throw new Error("queryMatcher: Unsupported comparator: "+t.comparator+" in query "+t)}},e}();!function(e){e[e.OBJ=0]="OBJ",e[e.STR=1]="STR",e.SEP=":"}(f||(f={}));var N=function(){function e(e,t){this.query=e,this.parameters=t}return e.prototype.processValue=function(e){return Array.isArray(e)?e.slice().sort():i.isMoment(e)?i(e):i.isDuration(e)?i.duration(e):e},e.prototype.compareParsedQueries=function(e,t){return e[f.STR]===t[f.STR]?0:e[f.STR]>t[f.STR]?1:-1},e.prototype.parse=function(e){if(void 0===e&&(e=this.query),void 0!==e.linkedTo)return this.parseLinkedToQuery(e.linkedTo,e.query,e.reverse,e.not);if(void 0!==e.not)throw new Error('queryParser: "Not" not supported');if(void 0!==e.custom)return this.parseCustomQuery(e.custom,e.parameters);if(void 0!==e.search)return this.parseSearchQuery(e.search);if(void 0!==e.conditions)return this.parseComplexQuery(e.conditions,e.operator);if(void 0!==e.key)return this.parseSimpleQuery(e.key,e.value,e.comparator);var t=Object(o.g)(e);return null===t?[{},"{}"]:this.parseSimpleQuery(t,e[t])},e.prototype.parseSearchQuery=function(e){return[{search:(e=this.formatValue(e))[f.OBJ]},"[search"+f.SEP+e[f.STR]+"]"]},e.prototype.parseCustomQuery=function(e,t){if(void 0===t)return[{custom:e},"["+e+"]"];var r=this.parseCustomParameters(t);return[{custom:e,parameters:r[f.OBJ]},"["+e+f.SEP+r[f.STR]+"]"]},e.prototype.parseCustomParameters=function(e){for(var t=Object.keys(e).sort(),r={},n="",i=0;i<t.length;i++){var o=t[i],s=this.formatValue(e[o]);r[o]=s[f.OBJ],i>0&&(n+=f.SEP),n+=s[f.STR]}return[r,n]},e.prototype.parseSimpleQuery=function(e,t,r){return t=this.formatValue(t),void 0===r&&(r=Array.isArray(t[f.OBJ])?"IN":"="),[{key:e,value:t[f.OBJ],comparator:r},"["+r+f.SEP+e+f.SEP+t[f.STR]+"]"]},e.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1);var i=this.parse(t);return[{linkedTo:e,query:i[f.OBJ],reverse:r,not:n},"[linkedTo"+f.SEP+e+f.SEP+i[f.STR]+f.SEP+r+f.SEP+n+"]"]},e.prototype.parseComplexQuery=function(e,t){t=void 0===t?"AND":t.toUpperCase();var r=this.parseConditions(e);return[{conditions:r[f.OBJ],operator:t},"["+t+r[f.STR]+"]"]},e.prototype.parseConditions=function(e){for(var t=this,r=[],n=[],i="",o=0,s=e;o<s.length;o++){var c=s[o];r.push(this.parse(c))}for(var u=0,a=r=r.sort(function(e,r){return t.compareParsedQueries(e,r)});u<a.length;u++){var l=a[u];n.push(l[f.OBJ]),i+=l[f.STR]}return[n,i]},e.prototype.formatValue=function(e){var t;if("string"==typeof e&&"&"===e.charAt(0)){var r=e.substring(1);if(void 0===(e=this.parameters[r]))throw new Error("queryParser: Undefined template parameter '"+r+"'");return[t=this.processValue(e),r+">"+e]}return[t=this.processValue(e),""+t]},e}(),Q=function(){function e(){}return e.prototype.addAndCondition=function(e,t){return void 0===e.conditions||"or"===e.operator?{conditions:[e,t]}:{conditions:e.conditions.concat(t)}},e.prototype.addOrCondition=function(e,t){return"or"===e.operator?{conditions:e.conditions.concat(t)}:{conditions:[e,t],operator:"or"}},e.prototype.addParentCondition=function(e,t){var r;return null===t?e:(r={linkedTo:t.itemType,query:t.itemId},null===e?r:this.addAndCondition(e,r))},e.prototype.createNotIn=function(e){return{comparator:"NOT IN",key:"id",value:e}},e}(),Y=function(){function e(e){this.columnUtil=e,this.columns={},this.columnInfoIdMap={}}return e.prototype.expand=function(e){if(!this.columnInfoIdMap[e.id]){var t=e.itemType;void 0===this.columns[t]&&(this.columns[t]=[]),this.columns[t]=this.columnUtil.mergeRequestColumns(this.columns[t],e.request).merged,this.columnInfoIdMap[e.id]=!0}},e.prototype.get=function(){return this.columns},e}(),W=function(){function e(e,t,r,n,i,o,s,c,u,a){this.promiseService=e,this.apiRequestService=t,this.itemHandler=r,this.itemEntryFactory=n,this.collectionHandler=i,this.columnSetFactory=o,this.columnExpansionFactory=s,this.requestColumnExpansionFactory=c,this.apiFormatter=u,this.errorHandler=a}return e.prototype.onMessageReceived=function(e){switch(e.body.eventType){case"update":return this.handleUpdate(e);case"create":return this.handleCreate(e);case"delete":return this.handleDelete(e);case"linkTo":return this.handleLinkMove()}},e.prototype.formatMessageValues=function(e,t){var r={};for(var n in t)r[n]=this.apiFormatter.formatResponseValue(t[n].type,e[n]);return r},e.prototype.createCollectionMap=function(e,t,r){var n={};for(var i in t){var o=t[i],s=null!==o.parent?o.parent:{};n[i]=this.collectionHandler.entries.getByFittingItem(e,this.formatMessageValues(o.values,r),s)}return n},e.prototype.groupByCollectionId=function(e,t){var r={};for(var n in t){var i=t[n];for(var o in i)for(var s=0,c=i[o];s<c.length;s++){var u=c[s],a=u.id;void 0===r[a]&&(r[a]={collection:u,fitting:[],notfitting:[],maybe:[]}),r[a][o].push("fitting"===o?this.itemHandler.entries.get(e,n):n)}}return r},e.prototype.getRequestColumns=function(e,t){var r=this.requestColumnExpansionFactory.construct();for(var n in t){for(var i=t[n].fitting,o=this.itemHandler.entries.get(e,n),s=0,c=i;s<c.length;s++){var u=c[s];r.expand(u.columns)}void 0!==o&&r.expand(o.columns)}return r.get()},e.prototype.deferEntry=function(e){var t=e.deferred;return void 0===t?e.defer():t.promise.then(this.deferEntry.bind(this),this.errorHandler.reject)},e.prototype.processMessage=function(e){var t=this,r=e.itemType,n=this.createCollectionMap(r,e.items[r],e.columns[r]),i=this.getRequestColumns(r,n),o=[],s=[];for(var c in n){var u=this.itemHandler.entries.get(r,c),a=+c;void 0===u?0!==n[a].fitting.length&&(this.itemHandler.entries.add(this.itemEntryFactory.constructDeferred(r,a,i[r],!1)),s.push(a)):(o.push(this.deferEntry(u)),s.push(a))}return 0===s.length?this.promiseService.when(this.groupByCollectionId(r,n)):this.promiseService.all(o).then(function(){return t.apiRequestService.query(r,{id:s},i)},this.errorHandler.reject).then(function(e){return t.handleResponse(r,s,i[r],e,n)},this.errorHandler.reject)},e.prototype.processFunctionChangesResolve=function(e){var t=this,r=e.items.FunctionChangesResolve,n=[],i=[];for(var o in r){var s=r[o].parent.itemId,c=this.itemHandler.entries.get("Functie",s);void 0!==c&&void 0!==c.columns.response.Functie.newchanges&&(n.push(this.deferEntry(c)),i.push(s))}if(0!==i.length)return this.promiseService.all(n).then(function(){return t.apiRequestService.query("Functie",{id:i},{Functie:["newchanges"]})},this.errorHandler.reject).then(function(e){for(var r=0,n=e.links.Functie;r<n.length;r++){var i=n[r],o=t.itemHandler.entries.get("Functie",i),s=t.apiFormatter.copyFields(o.getFields(),{},o.columns.main),c=e.fetchValue("Functie",i,"newchanges");if(c===s.newchanges)return;o.setInitial({newchanges:c},!0).callOnChange(s).resolve()}},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleResponse=function(e,t,r,n,i){for(var o=n.fetchColumnsObject(),s=this.columnSetFactory.construct(e,r,o),c=this.columnExpansionFactory.construct(e,r,o),u=0,a=t;u<a.length;u++){var l=a[u],h=this.itemHandler.entries.get(e,l),p=void 0===h.initial,f=n.fetchObject(e,l);if(void 0!==f){var d=n.fetchDerivedObject(e,l,s.root);if(p)h.resolveDeferred(f,d,s);else{var m=c.run(h.columns),y=this.apiFormatter.copyFields(h.getFields(),{},h.columns.main);null!==m&&h.expand(f,d,m),h.updateFields(f,d,!1).callOnChange(y).resolve()}}else h.reject(),p&&this.itemHandler.entries.clear(h),delete i[l]}return this.groupByCollectionId(e,i)},e.prototype.handleCreate=function(e){var t=this,r=e.body;return"FunctionChangesResolve"===r.itemType?this.processFunctionChangesResolve(r):this.processMessage(r).then(function(e){return t.collectionHandler.addToCollections(e,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleUpdate=function(e){var t=this;return this.processMessage(e.body).then(function(e){return t.collectionHandler.removeFromAndAddToCollections(e,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleDelete=function(e){for(var t=e.body,r={},n=0,i=t.items;n<i.length;n++)for(var o=i[n],s=0,c=this.collectionHandler.entries.getByContainingItem(t.itemType,o);s<c.length;s++){var u=c[s];void 0===r[a=u.id]&&(r[a]={collection:u,items:[]}),r[a].items.push(o)}for(var a in r){var l=r[a];l.collection.removeItems(l.items,null,!0)}return this.promiseService.when()},e.prototype.handleLinkMove=function(){},e}();r.d(t,"a",function(){return s}),r.d(t,"b",function(){return c}),r.d(t,"c",function(){return u}),r.d(t,"d",function(){return l}),r.d(t,"e",function(){return h}),r.d(t,"f",function(){return p}),r.d(t,"g",function(){return d}),r.d(t,"h",function(){return m}),r.d(t,"i",function(){return v}),r.d(t,"j",function(){return g}),r.d(t,"k",function(){return C}),r.d(t,"l",function(){return I}),r.d(t,"m",function(){return S}),r.d(t,"n",function(){return R}),r.d(t,"o",function(){return F}),r.d(t,"p",function(){return b}),r.d(t,"q",function(){return O}),r.d(t,"r",function(){return j}),r.d(t,"s",function(){return T}),r.d(t,"t",function(){return k}),r.d(t,"u",function(){return w}),r.d(t,"v",function(){return x}),r.d(t,"w",function(){return D}),r.d(t,"x",function(){return L}),r.d(t,"y",function(){return A}),r.d(t,"z",function(){return H}),r.d(t,"A",function(){return P}),r.d(t,"B",function(){return _}),r.d(t,"C",function(){return B}),r.d(t,"D",function(){return N}),r.d(t,"E",function(){return Q}),r.d(t,"F",function(){return Y}),r.d(t,"G",function(){return W}),r.d(t,"fb",function(){return o.y}),r.d(t,"P",function(){return o.i}),r.d(t,"N",function(){return o.g}),r.d(t,"Q",function(){return o.j}),r.d(t,"M",function(){return o.f}),r.d(t,"J",function(){return o.c}),r.d(t,"eb",function(){return o.x}),r.d(t,"I",function(){return o.b}),r.d(t,"O",function(){return o.h}),r.d(t,"L",function(){return o.e}),r.d(t,"db",function(){return o.w}),r.d(t,"Z",function(){return o.s}),r.d(t,"S",function(){return o.l}),r.d(t,"bb",function(){return o.u}),r.d(t,"Y",function(){return o.r}),r.d(t,"U",function(){return o.n}),r.d(t,"R",function(){return o.k}),r.d(t,"X",function(){return o.q}),r.d(t,"ab",function(){return o.t}),r.d(t,"T",function(){return o.m}),r.d(t,"W",function(){return o.p}),r.d(t,"cb",function(){return o.v}),r.d(t,"V",function(){return o.o}),r.d(t,"K",function(){return o.d}),r.d(t,"H",function(){return o.a})},function(e,t,r){"use strict";var n=r(2),i=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e){return new n.c(this.apiFormatter,e)},e}(),o=function(){function e(e){this.promiseService=e}return e.prototype.construct=function(e,t){return new n.d(this.promiseService,e,t)},e}(),s=function(){function e(e){this.collectionCacheFactory=e}return e.prototype.construct=function(e,t){return new n.e(this.collectionCacheFactory,e,t)},e}(),c=function(){function e(e,t,r,n,i,o,s,c,u,a,l){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.collectionHandler=n,this.changesCompilationFactory=i,this.createRequestFactory=o,this.columnExpansionFactory=s,this.requestColumnExpansionFactory=c,this.collectionEntryService=u,this.apiFormatter=a,this.promiseService=l}return e.prototype.construct=function(){return new n.f(this.apiRequestService,this.itemHandler,this.errorHandler,this.collectionHandler,this.changesCompilationFactory,this.createRequestFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.collectionEntryService,this.apiFormatter,this.promiseService)},e}(),u=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(){return new n.g(this.queryMatcherFactory)},e}(),a=r(5),l=function(){function e(e,t,r,n,i,o,s,c,u,a){this.collectionEntryService=e,this.columnSetFactory=t,this.errorHandler=r,this.itemEntryFactory=n,this.itemEntryService=i,this.itemHandler=o,this.itemRequestService=s,this.keyService=c,this.promiseService=u,this.queryService=a}return e.prototype.construct=function(e,t){return new a.b(this,e,this.collectionEntryService.processOptions(t))},e}(),h=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e,t,r){return new n.j(this.queryMatcherFactory,e,t,r)},e}(),p=function(){function e(e,t,r,n,i,o){this.errorHandler=e,this.itemResourceFactory=t,this.changesProcessorFactory=r,this.keyService=n,this.promiseService=i,this.collectionResourceService=o}return e.prototype.construct=function(e,t,r){return(t=this.collectionResourceService.processOptions(t)).editItems&&(e.hasItemEditResources=!0),t.editCollection?(e.hasEditResources=!0,new a.a(this,e,t,r)):new a.d(this.itemResourceFactory,e,t,r)},e}(),f=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(e,t,r){return new n.m(this.columnUtil,e,t,r)},e}(),d=function(){function e(){}return e.prototype.construct=function(e,t){return new n.o(e,t)},e}(),m=function(){function e(e,t,r){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r}return e.prototype.constructStub=function(e,t){return new n.p(this.columnHandler,this.columnUtil,this.columnInfoFactory,this,e,t)},e.prototype.construct=function(e,t,r,n,i){return this.constructStub(e,t).resolve(r,n,i)},e}(),y=function(){function e(e,t,r,n){this.collectionHandler=e,this.collectionMatcherFactory=t,this.keyService=r,this.requestColumnExpansionFactory=n}return e.prototype.construct=function(e,t,r,i){return new n.r(this.collectionHandler,this.collectionMatcherFactory,this.keyService,this.requestColumnExpansionFactory,e,t,r,i)},e}(),v=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(){return new n.t(this.queryMatcherFactory)},e}(),g=function(){function e(e,t,r,n,i,o){this.authInterface=e,this.apiFormatter=t,this.columnSetFactory=r,this.itemEntryService=n,this.keyService=i,this.promiseService=o}return e.prototype.constructStub=function(e,t,r){return new a.f(this,e,t,r)},e.prototype.constructLocalLinked=function(e,t,r,n,i,o){var s=this.constructStub(e,t,i);return s.parent=n,s.setLocalFields(r,o)},e.prototype.constructLocal=function(e,t,r,n,i,o,s){void 0===i&&(i=null),void 0===o&&(o=t.columns);var c=t.columns.itemType;void 0===s&&(s=this.itemEntryService.createLocalConversionMap(c,e,!0,t.response));var u=this.constructStub(c,e,o);return u.parent=i,u.setLocalFields(t.fields,s,t.columns).setModified(r).setDerived(n)},e.prototype.constructDeferred=function(e,t,r,n){var i=this.constructStub(e,t,this.columnSetFactory.constructStub(e,r));return i.defer(n),i},e.prototype.construct=function(e,t,r,n){return this.constructStub(n.itemType,e,n).setFields(t,r)},e}(),C=function(){function e(e,t,r,n,i,o){this.itemResourceService=e,this.apiFormatter=t,this.lockService=r,this.changesProcessor=n,this.errorHandler=i,this.promiseService=o}return e.prototype.getConstructor=function(e){var t=this;return e=this.itemResourceService.processOptions(e),function(r){return e.edit?new a.e(t,r,e):new a.i(r,e)}},e.prototype.construct=function(e,t,r){return(t=this.itemResourceService.processOptions(t)).edit?new a.e(this,e,t,r):new a.i(e,t,r)},e}(),I=function(){function e(e,t,r,n,i,o,s,c,u){this.errorHandler=e,this.lockService=t,this.itemResourceFactory=r,this.collectionCacheFactory=n,this.changesProcessorFactory=i,this.itemCacheFactory=o,this.collectionResourceFactory=s,this.itemResourceService=c,this.promiseService=u}return e.prototype.construct=function(e){return new n.z(this.errorHandler,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.itemResourceService,this.promiseService,e)},e}(),S=function(){function e(){}return e.prototype.construct=function(e,t,r){return new n.B(e,t,r)},e}(),R=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e,t,r){return new n.C(this.apiFormatter,e,t,r)},e}(),F=function(){function e(){}return e.prototype.construct=function(e,t){return new n.D(e,t)},e}(),q=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(){return new n.F(this.columnUtil)},e}(),E=function(){function e(e,t){this.columnSetFactory=e,this.columnUtil=t}return e.prototype.construct=function(e,t,r){return new a.h(this,e,t,r)},e}();r.d(t,"a",function(){return i}),r.d(t,"b",function(){return o}),r.d(t,"c",function(){return s}),r.d(t,"d",function(){return c}),r.d(t,"e",function(){return u}),r.d(t,"f",function(){return l}),r.d(t,"g",function(){return h}),r.d(t,"h",function(){return p}),r.d(t,"i",function(){return f}),r.d(t,"j",function(){return d}),r.d(t,"k",function(){return m}),r.d(t,"l",function(){return y}),r.d(t,"m",function(){return v}),r.d(t,"n",function(){return g}),r.d(t,"o",function(){return C}),r.d(t,"p",function(){return I}),r.d(t,"q",function(){return S}),r.d(t,"r",function(){return R}),r.d(t,"s",function(){return F}),r.d(t,"t",function(){return q}),r.d(t,"u",function(){return E})},function(t,r){t.exports=e},function(e,t,r){"use strict";var n,i=r(2),o=0,s=function(){function e(e,t,r){this.factory=e,this.itemType=t,this.options=r,this.id=o++,this.templateColumns=null,this.parent=null,this.initial=[],this.items=[],this.resources=[],this.reloadQueued=!1,this.hasEditResources=!1,this.hasItemEditResources=!1,this.parent=r.parent,this.query=e.collectionEntryService.createQuery(r),this.columns=e.columnSetFactory.constructStub(t,r.columns),this.defer()}return e.prototype.defer=function(){return this.isDeferred()?this:(this.deferred=this.factory.promiseService.defer(),this.promise=this.deferred.promise,this)},e.prototype.isDeferred=function(){return void 0!==this.promise},e.prototype._resolve=function(){var e=this.deferred;return delete this.deferred,delete this.promise,e.resolve(this),this},e.prototype.resolve=function(e){return this.columns=e.columns,this.initial=e.items,this.items=e.items.slice(),this._resolve()},e.prototype.isLocal=function(){var e=this.parent;return null!==e&&this.factory.keyService.isLocalId(e.itemId)},e.prototype.matchParent=function(e,t){var r=this.parent;return null!==r&&(r.itemType===e&&r.itemId==t)},e.prototype.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++){e(r[t])}},e.prototype.getItemById=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(n.itemId===e)return n}},e.prototype.getIdArray=function(e){return void 0===e&&(e=[]),this.factory.collectionEntryService.getIdArray(this.items,e)},e.prototype.createItems=function(e){var t,r=this,n=this.factory,i=this.columns;return n.itemHandler.fetchTemplate(this.itemType).then(function(o){t=o;var s=[];null===r.templateColumns&&(r.templateColumns=t.columns.expand(i.request,i.requestColumnsTrue,i.response).merged);for(var c=0,u=e;c<u.length;c++){var a=u[c];s.push(n.itemEntryFactory.constructLocal(n.keyService.getLocalId(),t,a,{},r.parent,r.templateColumns))}return s},n.errorHandler.reject)},e.prototype.resolveDerivedValues=function(e,t){return this.factory.itemHandler.resolveDerivedValues(e,this.columns.root,t)},e.prototype.addItems=function(e,t,r,n,i){if(void 0===r&&(r=!1),0===e.length)return[];var o=this.items,s=this.parent,c=this.columns.link,u=[],a=[];if(r)for(var l=this.initial,h=0,p=e;h<p.length;h++){var f=p[h];-1===l.indexOf(f)&&(l.push(f),u.push(f))}for(var d=0,m=e;d<m.length;d++){f=m[d];-1===o.indexOf(f)&&(null!==s&&(f.parent=s,null!==c&&void 0!==f.modified&&(f.modified[c.id]=s.itemId)),o.push(f),a.push(f))}return this.handleAddedItemCallbacks(u,a,t,n,i)},e.prototype.handleAddedItemCallbacks=function(e,t,r,n,i){void 0===r&&(r=null),void 0===n&&(n=!0),void 0===i&&(i=!0);var o=this.resources;if(e.length>0)for(var s=0,c=o;s<c.length;s++){(m=c[s]).options.onAddInitial(e,this)}if(0===t.length)return null===r?null:[];if(i&&o.length>0)for(var u=o[0].localCache,a=0,l=t;a<l.length;a++){var h=l[a];u.onActivateItem(h)}for(var p=null,f=0,d=o;f<d.length;f++){var m,y=(m=d[f]).addItemResources(t);m===r?(p=y,n&&m.callOnAdd(y)):m.callOnAdd(y)}return p},e.prototype.removeItems=function(e,t,r,n){return 0===e.length?[]:this.handleRemovedItems(function(t){return!Object(i.Q)(t.itemId,e)},t,r,n)},e.prototype.clear=function(e,t,r){return this.handleRemovedItems(function(){return!1},e,t,r)},e.prototype.handleRemovedItems=function(e,t,r,n){void 0===r&&(r=!1);var i,o=this.factory.collectionEntryService,s=o.filterArray(this.items,e);if(r)i=o.filterArray(this.initial,e);else{for(var c=[],u=0,a=s;u<a.length;u++){var l=a[u];l.isLocal()&&c.push(l)}i=c.length>0?o.filterArray(this.initial,function(e){return-1===c.indexOf(e)}):[]}return this.handleRemovedItemCallbacks(i,s,t,n)},e.prototype.handleRemovedItemCallbacks=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var i=this.resources;if(e.length>0)for(var o=0,s=i;o<s.length;o++){(p=s[o]).options.onRemoveInitial(e,this)}if(0===t.length)return null===r?null:[];for(var c=null,u=0,a=t;u<a.length;u++){a[u].deactivateResources()}for(var l=0,h=i;l<h.length;l++){var p,f=(p=h[l]).removeItemResources(t);p===r?(c=f,n&&p.callOnRemove(f)):p.callOnRemove(f)}return c},e.prototype.expand=function(e){var t=this,r=this.factory,n=this.itemType;return!0!==e&&0===e.length?r.promiseService.when(this):r.itemRequestService.requestItems(this,void 0,e).then(function(i){var o=i.items[n],s=r.itemRequestService.processExpansion(e,i,n,t.items);return t.handleRemovedItems(function(e){return void 0!==o[e.itemId]||e.isLocal()},null,!0,!0),t.expandColumns(s),t},r.errorHandler.reject)},e.prototype.extendQuery=function(e){var t=this.options;return void 0===e?this.query:(t.queryParams=e(t.queryParams),this.query=this.factory.collectionEntryService.createQuery(t))},e.prototype.extend=function(e,t,r,n){var i=this,o=this.factory,s=o.errorHandler,c=this.extendQuery(e).object,u=o.queryService.addAndCondition(c,o.queryService.createNotIn(this.getIdArray())),a=o.itemRequestService.requestItems(this,null!==this.options.limit?c:u).then(function(e){return o.itemRequestService.processResponse(e,e.links[i.itemType],i.parent,i.columns)},s.reject).then(function(e){return delete i.promise,i.addItems(e,t,n,r,!1)},s.reject);return this.promise=a.then(function(){return i},s.reject),a},e.prototype.queueReload=function(){this.reloadQueued=!0},e.prototype.expandColumns=function(e){var t=e.run(this.columns);null!==t&&(this.columns=t.merged,this.templateColumns=null,this.options.columns=this.columns.request)},e.prototype.expandRequestColumns=function(e){this.columns.expandRequestColumns(e),this.options.columns=this.columns.request},e.prototype.getAddedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=[],n=0,i=this.items;n<i.length;n++){var o=i[n];-1===t.indexOf(o)&&r.push(e?o.itemId:o)}return r},e.prototype.getRemovedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=this.items,n=[],i=0,o=t;i<o.length;i++){var s=o[i];-1===r.indexOf(s)&&n.push(e?s.itemId:s)}return n},e.prototype.getUpdatedItems=function(){for(var e=[],t=0,r=this.items;t<r.length;t++){var n=r[t];!n.isLocal()&&n.hasChanges()&&e.push(n)}return e},e.prototype.hasAddedItems=function(){return this.items.length>this.initial.length},e.prototype.hasRemovedItems=function(){return this.initial.length>this.items.length},e.prototype.hasUpdatedItems=function(){for(var e=0,t=this.items;e<t.length;e++){if(t[e].hasChanges())return!0}return!1},e.prototype.getCurrentResource=function(){var e=this.resources;return e[e.length-1]},e.prototype.clearResources=function(e){void 0===e&&(e=!1);for(var t=this.items,r=this.resources,n=[],i=0,o=t;i<o.length;i++){o[i].clearResources()}for(var s=0,c=r;s<c.length;s++){var u=c[s];if(!u.options[e?"clearOnSubTabChange":"clearOnTabChange"]){n.push(u);for(var a=0,l=u.items;a<l.length;a++){var h=l[a];h.entry.resources.push(h)}}}this.resources=n},e.prototype.revertChanges=function(){var e=this.getAddedItems(),t=this.getRemovedItems();this.items=this.initial.slice(),this.handleAddedItemCallbacks([],t),this.handleRemovedItemCallbacks([],e)},e.prototype.onItemsCreated=function(e){for(var t=0,r=this.resources;t<r.length;t++){var n=r[t];n.rebuildMap(),n.options.onItemsCreated(e)}},e.prototype.getUpdatedItemColumns=function(e){for(var t={},r=0,n=this.columns.item;r<n.length;r++){var i=n[r];void 0!==e[i.apiColumn.itemType]&&(t[i.id]=i)}return t},e.prototype.clone=function(e,t){for(var r=this.factory,n=r.itemEntryService.batchClone(this.items,t),i=0,o=n;i<o.length;i++){o[i].parent=e}return r.construct(this.itemType,r.collectionEntryService.cloneOptions(this.options,e)).resolve({columns:this.columns,items:n})},e}(),c=r(1),u=function(){function e(e,t,r,n){this.itemResourceFactory=e,this.entry=t,this.options=r,this.localCache=n,this.itemIdMap={},this.columns=t.columns.response,this.itemIdMap={},this.items=[],t.resources.push(this),this.addItemResources(t.items)}return e.prototype.getItemById=function(e){return this.itemIdMap[e]},e.prototype.rebuildMap=function(){for(var e={},t=0,r=this.items;t<r.length;t++){var n=r[t];e[n.entry.itemId]=n}this.itemIdMap=e},e.prototype.addItemResources=function(e){var t=this;if(0===e.length)return[];for(var r=[],n=this.options,i=this.items,o=this.itemIdMap,s=this.itemResourceFactory.getConstructor({edit:n.editItems,onChange:n.onChange,onDeactivate:function(e){return t.localCache.onDeactivateItem(e)}}),c=0,u=e;c<u.length;c++){var a=u[c],l=a.itemId,h=void 0;void 0===o[l]?(h=s(a),i.push(h),o[l]=h):h=o[l],r.push(h)}return r},e.prototype.removeItemResources=function(e){var t=this,r=[];return Object(c.f)(this.items,function(n){for(var i=0,o=e;i<o.length;i++){var s=o[i];if(n.entry===s)return r.push(n),delete t.itemIdMap[s.itemId],!1}return!0}),r},e.prototype.callOnAdd=function(e){this.options.onAdd(e,this)},e.prototype.callOnRemove=function(e){this.options.onRemove(e,this)},e.prototype.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++){e(r[t])}},e.prototype.filter=function(e){for(var t=[],r=0,n=this.items;r<n.length;r++){var i=n[r];e(i)&&t.push(i)}return t},e.prototype.first=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(e(n))return n}return null},e.prototype.some=function(e){return null!==this.first(e)},e.prototype.groupBy=function(e){var t=this.items,r={};if("string"==typeof e)for(var n=0,i=t;n<i.length;n++){void 0===r[u=(c=i[n]).fields[e]]&&(r[u]=[]),r[u].push(c)}if("function"==typeof e)for(var o=0,s=t;o<s.length;o++){var c,u;null!==(u=e(c=s[o]))&&(void 0===r[u]&&(r[u]=[]),r[u].push(c))}return r},e.prototype.map=function(e){var t=this.items,r=t.length,n=new Array(r);if("string"==typeof e)for(var i=0;i<r;i++)n[i]=t[i].fields[e];if("function"==typeof e)for(i=0;i<r;i++)n[i]=e(t[i]);return n},e.prototype.reduce=function(e,t){for(var r=0,n=this.items;r<n.length;r++){t=e(n[r],t)}return t},e.prototype.extend=function(e,t,r){var n=this;return void 0===t&&(t=!1),this.entry.extend(e,this,r,!0).then(function(e){return t?n.items:e})},e.prototype.deactivate=function(){this.localCache.clearCollection(this)},e.prototype.clearResource=function(){var e=this.entry.resources,t=this.items,r=e.indexOf(this);-1!==r&&e.splice(r,1);for(var n=0,i=t;n<i.length;n++){i[n].clearResource()}},e}(),a=(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),l=function(e){function t(t,r,n,i){return e.call(this,t,r,n,i)||this}return a(t,e),t}(u),h=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),p=function(e){function t(t,r,n,i){var o=e.call(this,t.itemResourceFactory,r,n,i)||this;return o.factory=t,o}return h(t,e),t.prototype.save=function(){if(!this.options.enableSave)throw new Error("collectionResourceService: Saving disabled");var e=this.factory,t=this.entry,r=t.parent;return null!==r&&e.keyService.isLocalId(r.itemId)?e.promiseService.when():e.changesProcessorFactory.construct().execute([],[t])},t.prototype.moveItems=function(e,t,r){var n=this.entry,i=this.options;if(i.enableSave||i.modInstant)throw new Error("collectionResourceService: Cannot move items: saving enabled");if(n.itemType!==t.entry.itemType)throw new Error("collectionResourceService: Cannot move items: itemType mismatch");for(var o=n.removeItems(e,this,!1,r),s=[],c=0,u=o;c<u.length;c++){var a=u[c];s.push(a.entry)}return t.entry.addItems(s,t,!1,r),o},t.prototype.removeItems=function(e,t){var r=this;void 0===t&&(t=!0);var n=this.entry.removeItems(e,this,!1,!1);return this.options.modInstant?this.save().then(function(){return t&&r.callOnRemove(n),n}):(t&&this.callOnRemove(n),this.factory.promiseService.when(n))},t.prototype.removeItem=function(e,t){return this.removeItems([e],t).then(function(e){return e[0]},this.factory.errorHandler.reject)},t.prototype.addItems=function(e,t,r){var n=this;void 0===t&&(t=!0);var i=this.factory,o=this.options.modInstant;return this.entry.createItems(e).then(function(e){return o?e:n.entry.resolveDerivedValues(e,n.localCache.items)}).then(function(e){var s=n.entry.addItems(e,n,!1,!1,r);return o?n.save().then(function(){return t&&n.callOnAdd(s),s},i.errorHandler.reject):(t&&n.callOnAdd(s),s)},i.errorHandler.reject)},t.prototype.addItem=function(e,t,r){return this.addItems([e],t,r).then(function(e){return e[0]},this.factory.errorHandler.reject)},t.prototype.clear=function(e){return this.entry.clear(this,!1,e)},t}(u),f=0,d=function(){function e(e,t,r,n){this.factory=e,this.itemType=t,this.itemId=r,this.columns=n,this.id=++f,this.reloadQueued=!1,this.deferRequest=!1,this.parent=null,this.resources=[]}return e.prototype.queueReload=function(){return this.reloadQueued=!0,this},e.prototype.defer=function(e){return void 0===e&&(e=!1),this.deferred=this.factory.promiseService.defer(),this.deferRequest=e,this},e.prototype.resolve=function(){var e=this.deferred;return delete this.deferred,delete this.deferRequest,e.resolve(this),this},e.prototype.resolveDeferred=function(e,t,r){return this.columns=r,this.setFields(e,t),this.resolve()},e.prototype.isDeferred=function(){return void 0!==this.deferred},e.prototype.reject=function(e){return this.deferred.reject(e),delete this.deferred,delete this.deferRequest,this},e.prototype.setFields=function(e,t){var r=this.factory.apiFormatter,n=this.columns.formatted;return this.initial=r.formatResponse(e,n.main),this.derived=r.formatResponse(t,n.derived),this},e.prototype.setLocalFields=function(e,t,r){void 0===r&&(r=this.columns);for(var n=this.factory,i=n.itemEntryService.getLocalDefaultValues(),o=0,s=r.main;o<s.length;o++){var c=s[o].id;i[c]=e[c]}return this.initial=n.apiFormatter.formatResponse(i,r.formatted.main),this.derived={"creator>displayname":n.authInterface.getUserDisplayname()},this.updateItemFields(t)},e.prototype.clone=function(e){void 0===e&&(e={});var t=this.factory,r=t.apiFormatter,n=t.itemEntryService,i=this.columns,o=this.parent,s=n.expandConversionMap(this,e),c=t.construct(s,r.copyFields(this.getFields(),{},i.main),r.copyFields(this.derived,{},i.derived),i);if(c.updateItemFields(e),c.modified=r.copyFields(c.initial,{},i.main),null===o)return c;var u=n.getConversionValue(this.itemType,o.itemId,e);return c.setParent(o.itemType,void 0===u?o.itemId:u),c},e.prototype.resetDerived=function(e){for(var t=this,r=[],n=0,i=this.columns.root;n<i.length;n++){var o=i[n];-1!==e.indexOf(o.id)&&r.push(o)}return function e(r){for(var n=0,i=r;n<i.length;n++){var o=i[n];o.isLeaf||e(o.children),delete t.derived[o.path]}}(r),this},e.prototype.clearResources=function(){return this.resources=[],this},e.prototype.deactivateResources=function(){for(var e=0,t=this.resources;e<t.length;e++){t[e].deactivate()}return this},e.prototype.getFields=function(){return void 0!==this.modified?this.modified:this.initial},e.prototype.expand=function(e,t,r){var n=this.factory.apiFormatter,i=r.difference;return this.columns=r.merged,n.expandResponse(this.initial,e,i.main),n.expandResponse(this.derived,t,i.derived),void 0===this.modified?this:(n.expandResponse(this.modified,e,i.main),this)},e.prototype.updateFields=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r=!0);var n=this.factory.apiFormatter,i=this.columns.main,o=this.initial,s=this.modified;if(void 0!==s)for(var c=0,u=i;c<u.length;c++){var a=(f=u[c]).id,l=f.apiColumn.type;(r||n.compareFields(l,o[a],s[a]))&&(s[a]=n.formatResponseValue(l,e[a]))}for(var h=0,p=i;h<p.length;h++){var f;o[a=(f=p[h]).id]=n.formatResponseValue(f.apiColumn.type,e[a])}return null!==t&&this.setDerived(t),this},e.prototype.updateItemValue=function(e,t,r){var n,i=t.id,o=e[i];return"link"===t.type&&void 0===o?null!==this.parent&&(n=this.parent.itemId):n=this.factory.itemEntryService.getConversionValue(t.itemType,o,r),void 0!==n&&(e[i]=n),this},e.prototype.updateItemFields=function(e,t){void 0===t&&(t=this.columns);for(var r=t.item,n=this.initial,i=this.modified,o=0,s=r;o<s.length;o++){var c=s[o].apiColumn;this.updateItemValue(n,c,e),void 0!==i&&this.updateItemValue(i,c,e)}return this},e.prototype.formatRequest=function(){var e=this.factory.apiFormatter,t=this.columns.main;return this.isLocal()?e.formatRequestLocal(this.getFields(),t):void 0===this.modified?{}:e.formatRequest(this.initial,this.modified,t)},e.prototype.setDisplayName=function(){if(void 0===this.modified)return this;var e=this.getDisplayName();return e&&(this.modified.displayname=e),this},e.prototype.getDisplayName=function(){var e=this.factory.itemEntryService,t=this.getFields();switch(this.itemType){case"Contact":return"bedrijf"===t.type?t.bedrijf:e.getFullName(t.voornaam,t.tussenvoegsel,t.naam);case"Medewerker":case"Person":return e.getFullName(t.voornaam,t.tussenvoegsel,t.achternaam);case"Reparatie":return this.derived["materiaal>naam"];default:return t[e.getTitleField(this.itemType)]}},e.prototype.getChanges=function(e){return void 0===e&&(e=!1),void 0!==this.modified||e?this.factory.apiFormatter.getChanges(this.initial,e?{}:this.modified,this.columns.main):[]},e.prototype.isLocal=function(){return this.factory.keyService.isLocalId(this.itemId)},e.prototype.isLockable=function(){if(this.isLocal())return!1;switch(this.itemType){case"Project":case"Materiaal":case"Contact":case"Medewerker":case"Voertuig":case"Template":return!0;default:return!1}},e.prototype.hasChanges=function(){return void 0!==this.modified&&this.factory.apiFormatter.hasChanges(this.initial,this.modified,this.columns.main)},e.prototype.resetModified=function(){var e=this.columns.main;if(void 0===this.modified)return this;for(var t=0,r=e;t<r.length;t++){var n=r[t];this.modified[n.id]=this.factory.apiFormatter.clone(n.apiColumn.type,this.initial[n.id])}return this},e.prototype.setInitial=function(e,t){void 0===t&&(t=!1);var r,n=this.factory.apiFormatter;for(var i in e)this.initial[i]=e[i];if(void 0===this.modified)return t&&this.callOnChange(n.copyFields(this.initial,{},this.columns.main)),this;for(var i in r=n.copyFields(this.modified,{},this.columns.main),e)this.modified[i]=e[i];return t&&this.callOnChange(r),this},e.prototype.setModified=function(e){var t=this.factory,r=t.apiFormatter,n=this.columns,i=n.response[this.itemType];if(void 0===this.modified){var o=this.resources,s=this.initial,c=this.modified=this.isLocal()?t.itemEntryService.getLocalDefaultValues():{};if(void 0===e)r.copyFields(s,c,n.main);else for(var u in r.shallowCopyFields(e,s,c,n.main),e)void 0===i[u]&&(c[u]=e[u]);for(var a=0,l=o;a<l.length;a++){l[a].fields=c}return this}if(void 0===e)return this;for(var u in e)this.modified[u]=e[u];return this},e.prototype.setDerived=function(e){for(var t in e)this.derived[t]=e[t];return this},e.prototype.setParent=function(e,t){return this.parent={itemType:e,itemId:t},this},e.prototype.callOnChange=function(e){for(var t=0,r=this.resources.length;t<r;t++){var n=this.resources[t];null!==n&&n.options.onChange(n,e)}return this},e}(),m=function(){function e(e,t,r){void 0===r&&(r=!1),this.entry=e,this.options=t,this._isNew=r,this.derived=e.derived,this.columns=e.columns.response[e.columns.itemType],e.resources.push(this)}return e.prototype.isNew=function(){return this._isNew},e.prototype.isLocal=function(){return this.entry.isLocal()},e.prototype.clearResource=function(){var e=this.entry.resources,t=e.indexOf(this);-1!==t&&e.splice(t,1)},e.prototype.deactivate=function(){this.options.onDeactivate(this.entry)},e}(),y=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),v=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.fields=void 0===t.modified?t.initial:t.modified,i}return y(t,e),t}(m),g=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),C=function(e){function t(t,r,n,i){var o=e.call(this,r,n,i)||this;return o.factory=t,o.localCopies=[],o.transactions=0,r.setModified(),o.fields=r.modified,o}return g(t,e),t.prototype.isNew=function(){return this._isNew&&0===this.transactions},t.prototype.start=function(){return void 0===this.localCopies&&(this.localCopies=[]),this.localCopies.push(this.copyFields()),this},t.prototype.rollback=function(){var e=this.entry;return this.factory.apiFormatter.copyFields(this.localCopies.pop(),e.modified,e.columns.main),this.isNew()&&0===this.localCopies.length&&this.deactivate(),this},t.prototype.commit=function(e){void 0===e&&(e=!0);var t=this.localCopies.pop();return e&&this.callOnChange(t),this.transactions++,this},t.prototype.getLocalCopy=function(){var e=this.localCopies;return void 0===e?null:0===e.length?null:e[e.length-1]},t.prototype.copyFields=function(e){void 0===e&&(e={});var t=this.entry;return this.factory.apiFormatter.copyFields(t.modified,e,t.columns.main)},t.prototype.setFields=function(e,t){void 0===t&&(t=!0);var r,n=this.columns,i=this.fields,o=!1;for(var s in t&&(r=this.copyFields()),e){var c=n[s];void 0!==c?this.factory.apiFormatter.compareFields(c.type,i[s],e[s])||(i[s]=e[s],o=!0):console.warn("setFields: no column found for",s)}return t&&o&&this.callOnChange(r),this},t.prototype.callOnChange=function(e){return this.entry.callOnChange(e),this},t.prototype.save=function(e){var t=this,r=this.factory,n=this.entry,o={};return void 0!==e&&Object(i.I)(o,[n.itemType,n.itemId],[{},e]),(n.isLockable()?r.lockService.fetchLock(n):r.promiseService.when()).then(function(){return r.changesProcessor.execute([n],[],o)},r.errorHandler.reject).then(function(){return t},r.errorHandler.reject)},t}(m),I=function(){return function(e,t,r,n){this.itemType=t,this.response=r,this.fields=r.fetchObject(t,r.links[t][0]),this.responseColumns=e.columnUtil.mergeResponseColumns(r.fetchColumnsObject(),n).merged,this.columns=e.columnSetFactory.construct(t,!0,this.responseColumns)}}();r.d(t,"b",function(){return s}),r.d(t,"c",function(){return u}),r.d(t,"d",function(){return l}),r.d(t,"a",function(){return p}),r.d(t,"f",function(){return d}),r.d(t,"g",function(){return m}),r.d(t,"i",function(){return v}),r.d(t,"e",function(){return C}),r.d(t,"h",function(){return I})},function(e,t,r){"use strict";r.r(t);var n=r(7);r.d(t,"RmCore",function(){return n.a}),r.d(t,"noop",function(){return n.c}),r.d(t,"identity",function(){return n.b});var i=r(0);r.d(t,"ENTRY_STATUS",function(){return i.e}),r.d(t,"ALL_PERMISSIONS",function(){return i.a}),r.d(t,"COLUMN_SEPERATOR",function(){return i.b}),r.d(t,"RENDER_AS_SEPERATOR",function(){return i.h}),r.d(t,"NEW_PREFIX",function(){return i.g}),r.d(t,"DUPLICATE_PREFIX",function(){return i.d}),r.d(t,"NEW_KEYWORD",function(){return i.f}),r.d(t,"DUPLICATE_KEYWORD",function(){return i.c});var o=r(5);r.d(t,"CollectionEntry",function(){return o.b}),r.d(t,"CollectionResource",function(){return o.c}),r.d(t,"CollectionViewResource",function(){return o.d}),r.d(t,"CollectionEditResource",function(){return o.a}),r.d(t,"ItemEntry",function(){return o.f}),r.d(t,"ItemResource",function(){return o.g}),r.d(t,"ViewResource",function(){return o.i}),r.d(t,"EditResource",function(){return o.e}),r.d(t,"Template",function(){return o.h});var s=r(2);r.d(t,"ApiFormatter",function(){return s.a}),r.d(t,"ApiRequestService",function(){return s.b}),r.d(t,"ApiResponseProcessor",function(){return s.c}),r.d(t,"BatchStatus",function(){return s.d}),r.d(t,"ChangesCompilation",function(){return s.e}),r.d(t,"ChangesProcessor",function(){return s.f}),r.d(t,"CollectionCache",function(){return s.g}),r.d(t,"CollectionEntryService",function(){return s.h}),r.d(t,"CollectionHandler",function(){return s.i}),r.d(t,"CollectionMatcher",function(){return s.j}),r.d(t,"CollectionResourceService",function(){return s.k}),r.d(t,"ColumnCache",function(){return s.l}),r.d(t,"ColumnExpansion",function(){return s.m}),r.d(t,"ColumnHandler",function(){return s.n}),r.d(t,"ColumnInfo",function(){return s.o}),r.d(t,"ColumnSet",function(){return s.p}),r.d(t,"ColumnUtil",function(){return s.q}),r.d(t,"CreateRequest",function(){return s.r}),r.d(t,"ItemAdministrator",function(){return s.s}),r.d(t,"ItemCache",function(){return s.t}),r.d(t,"ItemEntryService",function(){return s.u}),r.d(t,"ItemHandler",function(){return s.v}),r.d(t,"ItemRequestService",function(){return s.w}),r.d(t,"ItemResourceService",function(){return s.x}),r.d(t,"KeyService",function(){return s.y}),r.d(t,"LocalCache",function(){return s.z}),r.d(t,"LockService",function(){return s.A}),r.d(t,"ModuleChangesCompilation",function(){return s.B}),r.d(t,"QueryMatcher",function(){return s.C}),r.d(t,"QueryParser",function(){return s.D}),r.d(t,"QueryService",function(){return s.E}),r.d(t,"RequestColumnExpansion",function(){return s.F}),r.d(t,"SocketMessageHandler",function(){return s.G}),r.d(t,"shallowMerge",function(){return s.fb}),r.d(t,"hasProperties",function(){return s.P}),r.d(t,"getFirstProperty",function(){return s.N}),r.d(t,"inArray",function(){return s.Q}),r.d(t,"filterArray",function(){return s.M}),r.d(t,"emptyArray",function(){return s.J}),r.d(t,"pathExists",function(){return s.eb}),r.d(t,"createPath",function(){return s.I}),r.d(t,"getPath",function(){return s.O}),r.d(t,"extend",function(){return s.L}),r.d(t,"merge",function(){return s.db}),r.d(t,"isObject",function(){return s.Z}),r.d(t,"isBlankObject",function(){return s.S}),r.d(t,"isString",function(){return s.bb}),r.d(t,"isNumber",function(){return s.Y}),r.d(t,"isDate",function(){return s.U}),r.d(t,"isArray",function(){return s.R}),r.d(t,"isFunction",function(){return s.X}),r.d(t,"isRegExp",function(){return s.ab}),r.d(t,"isBoolean",function(){return s.T}),r.d(t,"isElement",function(){return s.W}),r.d(t,"isWindow",function(){return s.cb}),r.d(t,"isDefined",function(){return s.V}),r.d(t,"equals",function(){return s.K}),r.d(t,"copy",function(){return s.H});var c=r(3);r.d(t,"ApiResponseProcessorFactory",function(){return c.a}),r.d(t,"BatchStatusFactory",function(){return c.b}),r.d(t,"ChangesCompilationFactory",function(){return c.c}),r.d(t,"ChangesProcessorFactory",function(){return c.d}),r.d(t,"CollectionCacheFactory",function(){return c.e}),r.d(t,"CollectionEntryFactory",function(){return c.f}),r.d(t,"CollectionMatcherFactory",function(){return c.g}),r.d(t,"CollectionResourceFactory",function(){return c.h}),r.d(t,"ColumnExpansionFactory",function(){return c.i}),r.d(t,"ColumnInfoFactory",function(){return c.j}),r.d(t,"ColumnSetFactory",function(){return c.k}),r.d(t,"CreateRequestFactory",function(){return c.l}),r.d(t,"ItemCacheFactory",function(){return c.m}),r.d(t,"ItemEntryFactory",function(){return c.n}),r.d(t,"ItemResourceFactory",function(){return c.o}),r.d(t,"LocalCacheFactory",function(){return c.p}),r.d(t,"ModuleChangesCompilationFactory",function(){return c.q}),r.d(t,"QueryMatcherFactory",function(){return c.r}),r.d(t,"QueryParserFactory",function(){return c.s}),r.d(t,"RequestColumnExpansionFactory",function(){return c.t}),r.d(t,"TemplateFactory",function(){return c.u});var u=r(8);for(var a in u)["RmCore","noop","identity","ENTRY_STATUS","ALL_PERMISSIONS","COLUMN_SEPERATOR","RENDER_AS_SEPERATOR","NEW_PREFIX","DUPLICATE_PREFIX","NEW_KEYWORD","DUPLICATE_KEYWORD","CollectionEntry","CollectionResource","CollectionViewResource","CollectionEditResource","ItemEntry","ItemResource","ViewResource","EditResource","Template","ApiFormatter","ApiRequestService","ApiResponseProcessor","BatchStatus","ChangesCompilation","ChangesProcessor","CollectionCache","CollectionEntryService","CollectionHandler","CollectionMatcher","CollectionResourceService","ColumnCache","ColumnExpansion","ColumnHandler","ColumnInfo","ColumnSet","ColumnUtil","CreateRequest","ItemAdministrator","ItemCache","ItemEntryService","ItemHandler","ItemRequestService","ItemResourceService","KeyService","LocalCache","LockService","ModuleChangesCompilation","QueryMatcher","QueryParser","QueryService","RequestColumnExpansion","SocketMessageHandler","shallowMerge","hasProperties","getFirstProperty","inArray","filterArray","emptyArray","pathExists","createPath","getPath","extend","merge","isObject","isBlankObject","isString","isNumber","isDate","isArray","isFunction","isRegExp","isBoolean","isElement","isWindow","isDefined","equals","copy","ApiResponseProcessorFactory","BatchStatusFactory","ChangesCompilationFactory","ChangesProcessorFactory","CollectionCacheFactory","CollectionEntryFactory","CollectionMatcherFactory","CollectionResourceFactory","ColumnExpansionFactory","ColumnInfoFactory","ColumnSetFactory","CreateRequestFactory","ItemCacheFactory","ItemEntryFactory","ItemResourceFactory","LocalCacheFactory","ModuleChangesCompilationFactory","QueryMatcherFactory","QueryParserFactory","RequestColumnExpansionFactory","TemplateFactory","default"].indexOf(a)<0&&function(e){r.d(t,e,function(){return u[e]})}(a)},function(e,t,r){"use strict";r.d(t,"a",function(){return o}),r.d(t,"c",function(){return s}),r.d(t,"b",function(){return c});var n=r(2),i=r(3),o=function(){return function(e,t,r,o,c){this.noop=s,this.version="1.2.2",this.apiFormatter=new n.a,this.keyService=new n.y,this.queryService=new n.E,this.columnUtil=new n.q,this.apiResponseProcessorFactory=new i.a(this.apiFormatter),this.apiRequestService=new n.b(e,this.apiResponseProcessorFactory),this.itemEntryService=new n.u(r,this.keyService),this.itemResourceService=new n.x,this.lockService=new n.A(this.apiRequestService,o,this.keyService,c),this.queryMatcherFactory=new i.r(this.apiFormatter),this.itemCacheFactory=new i.m(this.queryMatcherFactory),this.batchStatusFactory=new i.b(c),this.columnCache=new n.l(this.columnUtil),this.columnHandler=new n.n(this.apiRequestService,o,c,this.columnCache,this.columnUtil),this.columnInfoFactory=new i.j,this.columnSetFactory=new i.k(this.columnHandler,this.columnUtil,this.columnInfoFactory),this.columnExpansionFactory=new i.i(this.columnUtil),this.templateFactory=new i.u(this.columnSetFactory,this.columnUtil),this.itemEntryFactory=new i.n(r,this.apiFormatter,this.columnSetFactory,this.itemEntryService,this.keyService,c),this.itemHandler=new n.v(this.apiFormatter,this.apiRequestService,this.batchStatusFactory,this.columnExpansionFactory,this.columnHandler,this.columnSetFactory,this.columnUtil,o,this.itemCacheFactory,this.itemEntryFactory,this.itemEntryService,this.keyService,c,this.templateFactory),this.itemRequestService=new n.w(this.apiRequestService,o,this.itemHandler,this.columnExpansionFactory,this.columnSetFactory,this.itemEntryFactory,this.queryService,c),this.queryParserFactory=new i.s,this.collectionEntryService=new n.h(this.queryParserFactory,this.queryService),this.collectionResourceService=new n.k,this.collectionEntryFactory=new i.f(this.collectionEntryService,this.columnSetFactory,o,this.itemEntryFactory,this.itemEntryService,this.itemHandler,this.itemRequestService,this.keyService,c,this.queryService),this.collectionCacheFactory=new i.e(this.queryMatcherFactory),this.collectionMatcherFactory=new i.g(this.queryMatcherFactory),this.collectionHandler=new n.i(o,this.itemRequestService,this.columnHandler,this.columnSetFactory,this.collectionEntryFactory,this.collectionCacheFactory,this.queryParserFactory,this.collectionEntryService,this.keyService,c,this.queryService,this.collectionMatcherFactory),this.requestColumnExpansionFactory=new i.t(this.columnUtil),this.createRequestFactory=new i.l(this.collectionHandler,this.collectionMatcherFactory,this.keyService,this.requestColumnExpansionFactory),this.changesCompilationFactory=new i.c(this.collectionCacheFactory),this.changesProcessorFactory=new i.d(this.apiRequestService,o,this.itemHandler,this.collectionHandler,this.changesCompilationFactory,this.createRequestFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.collectionEntryService,this.apiFormatter,c),this.itemResourceFactory=new i.o(this.itemResourceService,this.apiFormatter,this.lockService,this.changesProcessorFactory.construct(),o,c),this.collectionResourceFactory=new i.h(o,this.itemResourceFactory,this.changesProcessorFactory,this.keyService,c,this.collectionResourceService),this.localCacheFactory=new i.p(o,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.itemResourceService,c),this.moduleChangesCompilationFactory=new i.q,this.itemAdministrator=new n.s(this.apiRequestService,r,this.collectionEntryService,this.collectionHandler,this.collectionMatcherFactory,this.collectionResourceService,this.columnSetFactory,o,this.itemEntryService,this.itemHandler,this.itemRequestService,this.keyService,this.localCacheFactory,t,this.moduleChangesCompilationFactory,c,this.queryService),this.socketMessageHandler=new n.G(c,this.apiRequestService,this.itemHandler,this.itemEntryFactory,this.collectionHandler,this.columnSetFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.apiFormatter,o)}}();function s(){}function c(e){return e}},function(e,t,r){"use strict";r.r(t);var n=r(9);for(var i in n)"default"!==i&&function(e){r.d(t,e,function(){return n[e]})}(i)},function(e,t){}])});
|