@rentman/rm-core 6.1.2 → 6.2.0

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.
@@ -1,4 +1,4 @@
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=15)}([function(e,t,r){"use strict";var n,i,o=r(6),s=r.n(o),a=r(1),c=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.isExpensiveFormat=function(e){switch(e){case"date":case"datetime":case"duration":return!0;default:return!1}},e.prototype.mergeCopyFields=function(e,t,r,n){for(var i=0,o=n;i<o.length;i++){var s=o[i],a=s.path;void 0===r[a]||"id"!==a&&void 0!==t[a]&&!this.compareFields(s.apiColumn.type,t[a],e[a])||(t[a]=this.clone(s.apiColumn.type,r[a]))}return t},e.prototype.formatRequest=function(e,t,r){for(var n={},i=0,o=r;i<o.length;i++){var s=o[i],a=s.id,c=s.apiColumn,u=c.type;c.readOnly||(this.compareFields(u,e[a],t[a])||(n[a]=this.formatRequestValue(u,t[a])))}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,a=o.apiColumn;a.readOnly||(r[s]=this.formatRequestValue(a.type,e[s]))}return r},e.prototype.hasChanges=function(e,t,r,n){void 0===n&&(n=!1);for(var i=0,o=r;i<o.length;i++){var s=o[i],a=s.id,c=s.apiColumn;if("id"===c.type||"link"===c.type||"parenttype"===c.type||"parentid"===c.type||n||!c.readOnly){if(this.isExpensiveFormat(s.apiColumn.type)){var u=Object.getOwnPropertyDescriptor(t,a);if(void 0!==u&&void 0===u.value&&void 0!==u.get)continue}if(!this.compareFields(c.type,e[a],t[a]))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],a=s.id,c=s.apiColumn;c.readOnly||(this.compareFields(c.type,e[a],t[a])||n.push({oldValue:e[a],newValue:t[a],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;e.hasOwnProperty(s)&&(this.isExpensiveFormat(o.apiColumn.type)||void 0!==e[s])&&(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],a=s.path;r[a]=void 0!==e[a]?e[a]:this.clone(s.apiColumn.type,t[a])}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":case"order":return t===r;default:return Object(a.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?s.a.invalid():s()(e,s.a.ISO_8601)},e.prototype.formatResponseDuration=function(e){return s.a.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":case"order":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 s.a.invalid();case"duration":return s.a.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 s()(t);case"json":return Object(a.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 s.a.duration(e)},e.prototype.cloneDate=function(e){return e.clone()},e.prototype.identity=function(e){return e},e}(),u=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}(),l=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.itemType=t.itemType,this.createColumnMaps()}return e.prototype.fetchColumnObject=function(e){return this.columnMap[e]},e.prototype.fetchValue=function(e,t,r){if(void 0!==this.items[e][t]){var n=this.columnMap[e][r],i=this.columnIndexMap[e][r];return this.apiFormatter.formatResponseValue(n.type,this.items[e][t].data[i])}},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.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++){var s=this.columns[e][o];this.apiFormatter.isExpensiveFormat(s.type)?this.addLazyFormattingFunction(s.id,s.type,n[o],i):i[s.id]=this.apiFormatter.formatResponseValue(s.type,n[o])}if(r){var a=this.items[e][t].links;for(var c in i.__links={},a)i.__links[c]=this.fetchObjectArray(c,r,a[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.fetchColumnsObject=function(){return this.columnMap},e.prototype.addLazyFormattingFunction=function(e,t,r,n){var i=this;Object.defineProperty(n,e,{enumerable:!0,configurable:!0,set:function(t){delete n[e],n[e]=t},get:function(){return delete n[e],n[e]=i.apiFormatter.formatResponseValue(t,r)}})},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}(),h=function(){function e(e){this.transaction=e,this.compilation={create:{},delete:{},update:{},move:{}},this.processDelta()}return e.prototype.processDelta=function(){var e=this.transaction.getDelta();for(var t in e.deleted)for(var r=0,n=e.deleted[t];r<n.length;r++){var i=n[r];i.isLocal()||this.addDeleteEntry(i)}for(var o in e.created){var s=e.created[o];this.addCreateEntry(s)}for(var o in e.updated){s=e.updated[o];this.addUpdateEntry(s.entry)}for(var o in e.moved){s=e.moved[o];this.addMoveEntry(s.entry,s.to)}},e.prototype.getDefaultParent=function(){return{itemType:"Void",itemId:0}},e.prototype.addMoveEntry=function(e,t){Object(a.b)(this.compilation.move,[t.itemType,t.itemId],[{},[]]).push(e)},e.prototype.addDeleteEntry=function(e){Object(a.b)(this.compilation.delete,[e.itemType],[[]]).push(e)},e.prototype.addUpdateEntry=function(e){Object(a.b)(this.compilation.update,[e.itemType,e.itemId],[{},e])},e.prototype.addCreateEntry=function(e){var t=this.transaction.getParent(e.entry);null===t&&(t=this.getDefaultParent()),Object(a.b)(this.compilation.create,[t.itemType,t.itemId,e.entry.itemType,e.entry.itemId],[{},{},{},e])},e}(),d=r(3),p=r(2),m=function(e){function t(t,r){var n=e.call(this,r)||this;return n.itemIdConversionMap=t,n}return Object(d.b)(t,e),t.prototype.parseEmptyQuery=function(){},t.prototype.parseSubQuery=function(e,t,r){return void 0===r&&(r=!1),this.parse(t)},t.prototype.parseSubFieldQuery=function(e,t,r,n,i){},t.prototype.parseSearchQuery=function(e,t){},t.prototype.parseCustomQuery=function(e,t,r){void 0===r&&(r=!1)},t.prototype.parseSimpleQuery=function(e,t,r,n,i){for(var o in this.itemIdConversionMap)void 0!==this.itemIdConversionMap[o][t]&&(i.value=this.itemIdConversionMap[o][t])},t.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1),this.parse(t)},t.prototype.parseComplexQuery=function(e,t,r){return this.parseConditions(e)},t.prototype.parseConditions=function(e){var t=this;return e.forEach(function(e){return t.parse(e)})},t}(p.c),f=function(){function e(e,t,r,n,i,o,s,a,c,u,l,h,d){this.changesDeltaFactory=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.columnExpansionFactory=n,this.createRequestFactory=i,this.errorHandler=o,this.promiseService=s,this.requestColumnExpansionFactory=a,this.collectionEntryService=c,this.itemEntryService=u,this.transaction=l,this.breakUpByParent=h,this.onAfterCreateCallback=d,this.itemIdConversionMap={},this.serverCache=this.transaction.getServerCache()}return e.prototype.execute=function(){var e=this,t=this.changesCompilationFactory.construct(this.transaction),r=t.compilation;return this.executeCreateRequests(t).then(function(){return e.executeMoveRequests(r.move)},this.errorHandler.reject).then(function(){return e.executeUpdateRequests(r.update)},this.errorHandler.reject).then(function(){return e.executeDeleteRequests(r.delete)},this.errorHandler.reject).then(function(){return e.itemIdConversionMap},this.errorHandler.reject)},e.prototype.buildMoveRequest=function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r],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&&(r=this.itemIdConversionMap),void 0!==r&&void 0!==r[e])return r[e][t]},e.prototype.executeCreateRequests=function(e){for(var t=this,r=[],n=0,i=this.createRequestFactory.construct(e.compilation.create,this.transaction,this.breakUpByParent).run();n<i.length;n++){var o=i[n];r.push(this.executeCreateRequest(o).then(function(e){return void 0!==t.onAfterCreateCallback&&t.onAfterCreateCallback(t.itemIdConversionMap),e},this.errorHandler.reject))}return this.promiseService.all(r)},e.prototype.executeCreateRequest=function(e){var t=this;return this.apiRequestService.requestSkeleton(e.request).then(function(r){var n=t.changesDeltaFactory.construct(),i=r.map,o=r.fetchColumnsObject(),s=e.items;for(var a in s){var c=t.columnExpansionFactory.construct(a,e.request.columns[a],o);for(var u in s[a]){var l=s[a][u],h=t.getMapValue(a,parseInt(u,10),i);if(void 0!==h){var d=t.transaction.itemHandler.entries.get(a,u);d.itemId=h,t.serverCache.itemHandler.itemChanges[d.id]=t.serverCache.itemHandler.copyTransactionItemEntryChanges(t.transaction.itemHandler.itemChanges[d.id],d),t.serverCache.itemHandler.entries.add(d),t.transaction.itemHandler.entries.clearByItemId(a,Number(u)),void 0!==t.transaction.itemHandler.fieldChangeCallbacks[l.itemType]&&(t.transaction.itemHandler.fieldChangeCallbacks[l.itemType][h]=t.transaction.itemHandler.fieldChangeCallbacks[l.itemType][u],delete t.transaction.itemHandler.fieldChangeCallbacks[l.itemType][u]),t.serverCache.itemHandler.processApiResponse(n,r,l.itemType,Number(h),l.columns,c)}else console.warn("Create failed!",l)}}for(var a in i)for(var u in void 0===t.itemIdConversionMap[a]&&(t.itemIdConversionMap[a]={}),i[a])t.itemIdConversionMap[a][u]=i[a][u];var p=t.transaction.cachedQueryHandler,f=p.cachedQueries;for(var a in f)for(var y in f[a]){var v=f[a][y],g=p.getCachedQueryItems(a,v.query.string);delete p.cachedQueries[a][v.query.string],new m(t.itemIdConversionMap,v.query.object).parse(),v.query=t.collectionEntryService.createQuery(v.query.object);var C=t.transaction.cachedQueryHandler.setCachedQuery(a,v.query,g,v.requestColumns);C.deferred.resolve(C);var I=t.serverCache.cachedQueryHandler.setCachedQuery(a,v.query,g.slice(),v.requestColumns);I.deferred.resolve(I)}var b=t.transaction.collectionHandler,S=b.collectionResources;for(var a in S)for(var y in S[a]){var E=S[a][y];delete b.collectionResources[a][y];for(var R=0,F=E;R<F.length;R++){var q=F[R],T=q.entry,H=T.parent;if(null!==H){var w=t.getMapValue(H.itemType,H.itemId);void 0!==w&&(H.itemId=w)}new m(t.itemIdConversionMap,T.query.object).parse(),T.query=t.collectionEntryService.createQuery(T.query.object),T.query=t.collectionEntryService.createQueryFromOptions(q.options)}b.collectionResources[a][E[0].entry.query.string]=E}return t.serverCache.applyChangesDelta(n)},this.errorHandler.reject)},e.prototype.executeUpdateRequests=function(e){var t=[];for(var r in e)t.push(this.executeUpdateRequest(r,e[r]));return this.promiseService.all(t)},e.prototype.executeUpdateRequest=function(e,t){var r=this,n={},i=this.requestColumnExpansionFactory.construct();for(var o in n[e]={},t){var s=t[o],c=n[e][o]={},u=Object(a.h)(this.transaction.tabRequestParameters,[e,o]);c.values=this.transaction.itemHandler.formatRequest(s),void 0!==u&&(c.parameters=u),i.expand(s.columns)}var l=i.get();return this.apiRequestService.updateItems(e,n,l).then(function(e){return r.serverCache.processResponse(e,l,!0,!1)},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){var r=this;return this.apiRequestService.delete(e,t.map(function(e){return e.itemId})).then(function(e){for(var n=r.changesDeltaFactory.constructInternalDelta(),i=e.items,o=[],s=0,c=t;s<c.length;s++){var u=c[s];Object(a.j)(u.itemId,i)?o.push(u):console.warn("Delete failed!",u)}return n.setItemsDeleted(o),r.serverCache.applyChangesFromParent(n,!0)},this.errorHandler.reject)},e.prototype.executeMoveRequests=function(e){var t=this,r=[],n=function(n,i){var o=e[n][i],s=t.getMapValue(n,i);r.push(t.apiRequestService.moveItems(n,void 0!==s?s:i,t.buildMoveRequest(o)).then(function(){for(var e=t.changesDeltaFactory.constructInternalDelta(),r=0,a=o;r<a.length;r++){var c=a[r];e.setItemUpdated(c,t.itemEntryService.getLinkFieldsByParent({itemType:n,itemId:void 0!==s?s:i},c.itemType))}return t.serverCache.applyChangesFromParent(e,!0)},t.errorHandler.reject))};for(var i in e)for(var o in e[i])n(i,+o);return this.promiseService.all(r)},e}(),y=r(10),v=function(){function e(e,t){this.queryParserFactory=e,this.queryService=t}return e.prototype.createUnfoundLocalCollectionError=function(e){return{message:"A local collection of type "+e+" could not be found"}},e.prototype.cloneOptions=function(e,t){var r=new y.a(e);return r.parent=t,r},e.prototype.processOptions=function(e){return new y.a(e)},e.prototype.createQuery=function(e){var t=this.queryParserFactory.construct(e).parse();return{object:t[0],string:t[1]}},e.prototype.createQueryFromOptions=function(e){var t,r=e.parent;if(null===r)t=e.query;else{var n={linkedTo:r.itemType,query:{id:r.itemId}};t=null===e.query?n:this.queryService.addAndCondition(e.query,n)}return this.createQuery(t)},e.prototype.getIdArray=function(e,t){void 0===t&&(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 a=0;a<e.length;a++)e[a]=r[a];return n},e}(),g=r(16),C=r(5),I=function(){function e(){}return e.prototype.processOptions=function(e){return new C.b(e)},e.prototype.getIdArray=function(e){return e.map(function(e){return e.entry.itemId})},e}(),b=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,o=this.columnUtil.parseRequestColumn(t),s=this.getColumn(e,o.id);if(void 0!==s){if(void 0===n[e]&&(n[e]={}),n[e][o.id]=s,0!==o.children.length){var a=[];this.retrieveColumns(s.itemType,o.children,a,n),0!==a.length&&r.push(((i={})[o.id]=a,i))}}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.columnInfoFactory=e,this.itemType=t,this.responseColumns=n,this.expansionMap={},this.expansionMapSize=0,!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=this.expansionMap,r=e.id;return void 0!==t[r]?t[r]:(this.expansionMapSize++,t[r]=e.isSupersetOf(this.requestColumns)?null:e.expand(this.requestColumns,this.requestColumnsTrue,this.responseColumns))},e.prototype.aggregateRootColumns=function(){var e=this.expansionMap;if(1===this.expansionMapSize){var t=e[Object(a.g)(e)];return null!==t?t.difference.root:[]}var r={};for(var n in e){var i=e[n];null!==i&&this.expandRootColumnMap(i.difference.root,r)}return this.columnInfoFactory.constructFromRootMap(r)},e.prototype.expandRootColumnMap=function(e,t){for(var r=0,n=e;r<n.length;r++){var i=n[r],o=i.id;void 0===t[o]&&(t[o]={apiColumn:i.apiColumn,children:{}}),this.expandRootColumnMap(i.children,t[o].children)}},e}(),E=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,i=this;return void 0===r&&(r={filter:!1}),this.apiRequestService.columns(e,(n={},n[e]=t,n),r).then(function(r){return i.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}(),R=r(4),F=function(){function e(e,t){void 0===t&&(t=null),this.apiColumn=e,this.parent=t,this.itemType=null,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+R.b+r,this.tailPath=0===t.level?r:t.tailPath+R.b+r)}return e.prototype.setChildren=function(e,t){return this.itemType=e,this.children=t,this.isLeaf=!1,this},e}(),q={},T=0,H=function(){function e(e,t,r){this.columnUtil=e,this.columnSetFactory=t,this.itemType=r,this.id=++T,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=[]}return e.prototype.groupColumnInfo=function(e){var t=this.columnUtil,r=e.apiColumn,n=null!==e.parent;n?this.derived.push(e):(this.main.push(e),"link"===r.type&&(this.link=e),this[t.isItemColumn(r)?"item":"notItem"].push(e),e.isLeaf||this.root.push(e)),t.isFormattedColumn(r)&&this.formatted[n?"derived":"main"].push(e),t.isFilteredColumn(r)&&this.filtered.push(e),t.isSearchableColumn(r)&&this.searchable.push(e),t.isCustomColumn(r)&&this.custom.push(e),e.isLeaf&&this.leaf.push(e)},e.prototype.toJSON=function(){var e=function(e){return e.map(function(e){return e.id})};return{main:e(this.main),derived:e(this.derived)}},e.prototype.isSupersetOf=function(e){if(!0===e)return this.requestColumnsTrue;var t=this.columnUtil,r=this.request;if(!0===r)return!t.containsDerivedColumns(e);for(var n=0,i=e;n<i.length;n++){var o=i[n];if(!t.containsColumn(o,r))return!1}return!0},e.prototype.getMergedColumnSet=function(e,t,r){var n=this.columnSetFactory.construct(this.itemType,e.merged,t);return n.requestColumnsTrue=this.requestColumnsTrue||r,n},e.prototype.mergeRequestColumns=function(e){return this.columnUtil.mergeRequestColumns(this.request,e)},e.prototype.mergeResponseColumns=function(e){return this.columnUtil.mergeResponseColumns(this.response,e).merged},e.prototype.merge=function(e){return this.getMergedColumnSet(this.mergeRequestColumns(e.request),this.mergeResponseColumns(e.response),e.requestColumnsTrue)},e.prototype.expand=function(e,t,r){var n=this.mergeRequestColumns(e),i=this.mergeResponseColumns(r);return{merged:this.getMergedColumnSet(n,i,t),difference:this.columnSetFactory.construct(this.itemType,n.difference,i,!1,!1)}},e}(),w=function(){function e(e,t){this.columnUtil=e,this.requestColumns=t,this.cache={}}return e.prototype.run=function(e){var t=this.cache,r=e.id;return void 0!==t[r]?t[r]:t[r]=e.isSupersetOf(this.requestColumns)},e.prototype.runWithRequestColumns=function(e){if(!0===this.requestColumns)return!0===e;if(!0===e)return!0;for(var t=0,r=this.requestColumns;t<r.length;t++){var n=r[t];if(!this.columnUtil.containsColumn(n,e))return!1}return!0},e}(),k=r(8),M=function(){function e(e){this.linkTreeService=e}return e.prototype.getColumnsFromLink=function(e,t){var r=this.linkTreeService.get()[e][t],n=[];switch(r.type){case k.ApiLinkTreeType.DIRECT:n.push(r.field);break;case k.ApiLinkTreeType.ITEMTABLE:n.push("itemtype"),n.push("item")}return n},e.prototype.getColumnPath=function(e,t){for(var r="",n="",i=0,o=e;i<o.length;i++){n+=r+o[i].id,r=R.b}return null!==t&&(n+=R.g+t),n},e.prototype.getDateFormatOptions=function(e){var t=s()(),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(a.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"country":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":case"icon":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.containsColumn=function(e,t){var r=this.parseRequestColumn(e),n=this.findRequestColumn(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.containsDerivedColumns=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.parseRequestColumn(n).children.length>0)return!0}return!1},e.prototype.responseColumnsAvailable=function(e,t,r){for(var n=0,i=t;n<i.length;n++){var o,s=i[n],a=this.parseRequestColumn(s),c=a.children,u=r[e];if(void 0===u)return!1;if(void 0===(o=u[a.id]))return!1;if(c.length>0&&!this.responseColumnsAvailable(o.itemType,c,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,r=this.parseRequestColumn(e);if(0===r.children.length)return r.id;for(var n=[],i=0,o=r.children;i<o.length;i++){var s=o[i];n.push(this.copyRequestColumn(s))}return(t={})[r.id]=n,t},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],a=this.mergeRequestColumn(s,r);null!==a&&n.push(a)}return{merged:r,difference:n}},e.prototype.mergeRequestColumn=function(e,t){var r,n,i=this.parseRequestColumn(e),o=this.findRequestColumn(i.id,t);if(-1===o)return t.push(e),e;if(0===i.children.length)return null;"string"==typeof t[o]&&(t[o]=((r={})[i.id]=[],r));for(var s=[],a=0,c=i.children;a<c.length;a++){var u=c[a],l=this.mergeRequestColumn(u,t[o][i.id]);null!==l&&s.push(l)}return 0===s.length?null:((n={})[i.id]=s,n)},e.prototype.getRequestColumnId=function(e){if("string"==typeof e)return e;var t;for(t in e);return t},e.prototype.parseRequestColumn=function(e){if("string"==typeof e)return{id:e,children:[]};var t=Object(a.g)(e);return{id:t,children:e[t]}},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(a.p)(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.parseConfigColumn=function(e){return e.split(R.g)[0].split(R.b)},e.prototype.processConfigColumn=function(e,t){var r,n,i=e[0],o=1===e.length,s=this.findRequestColumn(i,t);o?-1===s&&t.push(i):(-1===s?s=t.push(((r={})[i]=[],r))-1:"string"==typeof t[s]&&(t[s]=((n={})[i]=[],n)),this.processConfigColumn(e.slice(1),t[s][i]))},e.prototype.findRequestColumn=function(e,t){for(var r=0;r<t.length;r++){var n=t[r];if(this.getRequestColumnId(n)===e)return r}return-1},e}(),x=function(){function e(e){this.keyService=e}return 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 a=0,c=s;a<c.length;a++){var u=c[a];n[o][u]=this.keyService.getLocalId(),this.expandLocalConversionMap(o,u,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.updateItemValues=function(e,t,r,n,i){void 0===i&&(i=null);for(var o=0,s=r;o<s.length;o++){var a=s[o],c=a.id,u=a.apiColumn,l=void 0;"link"===u.type&&void 0===e[c]?null!==i&&(l=i.itemId):l=this.getConversionValue(u.itemType,e[c],n),void 0!==l&&(t[c]=l)}},e}(),j=function(){function e(e,t,r,n,i,o){void 0===o&&(o=!1),this.apiFormatter=e,this.keyService=t,this.requestColumnExpansionFactory=r,this.compilation=n,this.transaction=i,this.breakupByParent=o,this.requests=[]}return e.prototype.finalizeRequest=function(e){var t=e.columns;return e.request.columns=t.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(){var e=this.compilation;if(this.breakupByParent)for(var t in e){var r=e[t];for(var n in r)if(!this.keyService.isLocalId(n)){var i=this.initializeRequest();this.extendRequest(r[n],this.setRequestParent(t,i)?+n:null,i),this.requests.push(this.finalizeRequest(i))}}else for(var t in e){r=e[t],i=this.initializeRequest();var o=this.setRequestParent(t,i),s=!1;for(var n in r)this.keyService.isLocalId(n)||(this.extendRequest(r[n],o?+n:null,i),s=!0);s&&this.requests.push(this.finalizeRequest(i))}return this.requests},e.prototype.initializeRequest=function(){return{request:{requestType:"create",items:{},columns:{}},columns:this.requestColumnExpansionFactory.construct(),items:{}}},e.prototype.extendRequest=function(e,t,r){var n=r.request,i=r.items;for(var o in e)for(var s in void 0===n.itemType&&(n.itemType=o),void 0===i[o]&&(i[o]={},n.items[o]={}),e[o]){var c=e[o][s],u=c.entry,l=Object(a.h)(this.compilation,[o,u.itemId]),h=n.items[o][u.itemId]={},d=Object(a.h)(this.transaction.tabRequestParameters,[o,u.itemId]);if(null!==t&&(n.parentId[u.itemId]=t),r.columns.expand(u.columns),i[o][s]=u,h.values=this.apiFormatter.formatRequestLocal(c.fields,u.columns.main),h.parameters=d,void 0!==l){var p=h.links={};for(var m in l)for(var f in p[m]=[],l[m])p[m].push(parseInt(f,10));this.extendRequest(l,null,r)}}},e}(),D=r(9),O=r(13),Q=r(15),L=function(e){function t(t,r,n,i,o,s,a,c,u,l){var h=e.call(this,o,u,n,c,l)||this;return h.columnSubsetCacheFactory=t,h.requestBufferManager=r,h.apiRequestService=i,h.errorHandler=s,h.itemHandler=a,h.transaction=l,h}return Object(d.b)(t,e),t.prototype.__fetchCachedQueryItem=function(e,t){var r=this,n=this.collectionEntryService.createQueryFromOptions(t);this.expandColumnsWithQueryColumns(e,t,n.object);var i,o=this.transaction.core.changesDeltaFactory.construct(),s=this.columnSubsetCacheFactory.construct(t.columns);return this.__fetchItemEntriesByQueryData(e,t,s,n).then(function(e){return i=e,r.transaction.applyChangesDelta(o)},this.errorHandler.reject).then(function(){return i},this.errorHandler.reject)},t.prototype.__fetchLinkedCachedQueryItems=function(e,t,r,n){var i=this,o={};Object(Q.isFunction)(t)&&(t=t());for(var s=this.transaction.core.changesDeltaFactory.construct(),a=0,c=t;a<c.length;a++){var u=c[a],l=this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:u}),h=this.collectionEntryService.createQueryFromOptions(l);this.expandColumnsWithQueryColumns(r,l,h.object);var d=this.columnSubsetCacheFactory.construct(l.columns);o[u]=this.__fetchItemEntriesByQueryData(r,l,d,h)}return this.promiseService.all(o).then(function(e){return i.transaction.applyChangesDelta(s).then(function(){return e},i.errorHandler.reject)},this.errorHandler.reject)},t.prototype.__addItemEntriesToCachedQueries=function(t,r,n){e.prototype.__addItemEntriesToCachedQueries.call(this,t,r,n,function(e){return e.isLocal()})},t.prototype.__expandCachedQuery=function(e,t){var r=this,n=this.columnUtil.mergeRequestColumns(e.requestColumns,t).difference;return!0!==n&&0===n.length?this.promiseService.when(e):this.requestBufferManager.fetchByQuery(e.itemType,[e.query.object,e.query.string],n).then(function(){return e.requestColumns=r.columnUtil.mergeRequestColumns(e.requestColumns,t).merged,e},this.errorHandler.reject)},t.prototype.__fetchItemEntriesByQueryData=function(e,t,r,n){var i,o,s=this;if(null!==t.limit){var a,c=((i={})[e]=t.columns,i);return this.apiRequestService.requestSkeleton({requestType:"query",itemType:e,columns:c,query:n.object,limit:t.limit}).then(function(e){return a=e,s.transaction.processResponse(a,c,!1,!1)},this.errorHandler.reject).then(function(){for(var r=[],i=0,o=a.links[e];i<o.length;i++){var c=o[i];r.push(s.itemHandler.entries.get(e,c))}var u=s.promiseService.defer(),l={itemType:e,query:n,items:r,requestColumns:t.columns,deferred:u,promise:u.promise};return u.resolve(l),l})}var u,l=null===(o=this.cachedQueries[e])||void 0===o?void 0:o[n.string];if(void 0===l)l=this.initCachedQuery(e,n,r.requestColumns),u=this.requestBufferManager.fetchByQuery(e,[n.object,n.string],r.requestColumns);else{if(r.runWithRequestColumns(l.requestColumns))return l.promise;u=this.requestBufferManager.fetchByQuery(e,[n.object,n.string],r.requestColumns)}return u.then(function(){return l.requestColumns=s.columnUtil.mergeRequestColumns(l.requestColumns,r.requestColumns).merged,l.deferred.resolve(l),l},function(e){return l.deferred.reject(e),s.errorHandler.reject(e)})},t}(r(29).a),_=function(e){function t(t,r,n,i,o,s,a,c,u,l,h,d){var p=e.call(this,a,c,u,s,o,h,l,d)||this;return p.requestBufferManager=t,p.queryParserFactory=r,p.queryService=n,p.columnSubsetCacheFactory=i,p.transaction=d,p.itemChanges={},p}return Object(d.b)(t,e),t.prototype.createItemEntry=function(t){var r=e.prototype.createItemEntry.call(this,t);return this.itemChanges[r.id]=t.fields,r},t.prototype.processItemEntryChanges=function(e,t,r,n,i){void 0===t&&(t=!1),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=!1);var o=e.entry,s=e.changes;void 0===this.itemChanges[o.id]&&(this.itemChanges[o.id]={}),null!==s.expandedColumns&&(o.columns=s.expandedColumns.merged);var a=this.apiFormatter.copyFields(this.itemChanges[o.id],{},o.columns.main);return this.apiFormatter.copyFields(s.fields,this.itemChanges[o.id],o.columns.main),void 0!==s.fields.id&&(o.itemId=s.fields.id),a},t.prototype.copyTransactionItemEntryChanges=function(e,t){return this.apiFormatter.copyFields(e.changes,{},t.columns.main)},t.prototype.fetchItemEntry=function(e,t,r){return r.columns=this.expandColumnsWithCachedQueryColumns(e,r.columns),this.fetchItemEntryData(e,t,this.columnSubsetCacheFactory.construct(r.columns))},t.prototype.fetchItemEntriesByQuery=function(e,t,r){var n=this;return r.columns=this.expandColumnsWithCachedQueryColumns(e,r.columns),this.requestBufferManager.fetchByQuery(e,this.queryParserFactory.construct(this.queryService.addParentCondition(t,r.parent)).parse(),r.columns).then(function(t){for(var r=[],i=0,o=t.links[e];i<o.length;i++){var s=o[i],a=n.entries.get(e,s);void 0!==a&&r.push(a)}return r},this.errorHandler.reject)},t.prototype.extendItemEntries=function(e,t,r){return this.requestBufferManager.fetchByIds(e,t.map(function(e){return e.itemId}),r).then(function(){return t},this.errorHandler.reject)},t.prototype.fetchItemEntries=function(e,t,r){r.columns=this.expandColumnsWithCachedQueryColumns(e,r.columns);for(var n=this.columnSubsetCacheFactory.construct(r.columns),i=[],o=0,s=t;o<s.length;o++){var a=s[o];i.push(this.fetchItemEntryData(e,a,n))}return this.promiseService.all(i)},t.prototype.fetchLinkedItemEntriesData=function(e,t,r,n,i){return null===n?this.requestBufferManager.fetchByIds(e,t,i):this.requestBufferManager.fetchByQuery(r,this.queryParserFactory.construct(this.queryService.addAndCondition(n,{linkedTo:e,query:{id:t}})).parse(),i)},t.prototype.processApiResponse=function(e,t,r,n,i,o){var s=this.entries.get(r,n),a=t.fetchObject(r,n);if(void 0===a)throw new Error("Fields not found in response for "+r+":"+n);void 0===s?e._setItemCreated(n,a,i):e.setItemUpdated(s,a,o.run(s.columns))},t.prototype.fetchItemEntryData=function(e,t,r){var n=this,i=this.entries.get(e,t);return void 0!==i&&r.run(i.columns)?this.promiseService.when(i):this.requestBufferManager.fetchById(e,t,r.requestColumns).then(function(){return n.entries.get(e,t)},this.errorHandler.reject)},t}(r(27).a),P=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.dependencies=t,n.parent=null,n.itemHandler=new _(t.requestBufferManager,t.queryParserFactory,t.queryService,t.columnSubsetCacheFactory,t.errorHandler,t.promiseService,t.columnUtil,t.apiFormatter,t.itemEntryFactory,t.itemCacheFactory,t.requestColumnExpansionFactory,n),n.cachedQueryHandler=new L(t.columnSubsetCacheFactory,t.requestBufferManager,t.requestColumnExpansionFactory,t.apiRequestService,t.collectionEntryService,t.errorHandler,n.itemHandler,t.promiseService,t.columnUtil,n),n}return Object(d.b)(t,e),t.prototype.getServerCache=function(){return this},t.prototype.createChild=function(e,t){var r=new re.a(this.dependencies,this.core,this,e,t);return this.children.push(r),r},t.prototype.expandCollectionResources=function(e,t,r){var n=this;if(0===r.length)return this.dependencies.promiseService.when(t);var i=[];for(var o in t)i.push(Number(o));return this.itemHandler.fetchLinkedItemEntriesData(t[0].entry.parent.itemType,i,e,null,r).then(function(o){for(var s,a=n.dependencies.columnExpansionFactory.construct(e,r,o.fetchColumnsObject()),c=0,u=i;c<u.length;c++){var l=u[c],h=t[l].entry,d=null===(s=n.cachedQueryHandler.cachedQueries[h.itemType])||void 0===s?void 0:s[h.query.string];void 0!==d&&(d.requestColumns=n.dependencies.columnUtil.mergeRequestColumns(d.requestColumns,r).merged),h.expandColumns(a)}return t})},t.prototype.processResponse=function(e,t,r,n,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=this.core.changesDeltaFactory.construct());var o=e.fetchColumnsObject();for(var s in o)this.dependencies.columnCache.setColumns(s,t[s],o);for(var s in e.items){var a=void 0;a=s===e.itemType?this.core.columnSetFactory.construct(s,t[s],o):this.core.columnSetFactory.constructFromResponse(s,o);var c=this.core.columnExpansionFactory.construct(s,!!a.requestColumnsTrue||a.request,o);for(var u in e.items[s])this.itemHandler.processApiResponse(i,e,s,Number(u),a,c)}return this.applyChangesDelta(i,r,n)},t.prototype.applyChangesFromParent=function(e,t,r){var n=this;for(var i in void 0===t&&(t=!1),void 0===r&&(r=!1),e.updated)this.itemHandler.processItemEntryChanges(e.updated[i],r);for(var o in e.deleted)for(var s=0,a=e.deleted[o];s<a.length;s++){var c=a[s];this.itemHandler.entries.clear(c),delete this.itemHandler.itemChanges[c.id]}return this.core.collectionMatcherFactory.constructCachedQueryProcessor(this,function(e){return n.cachedQueryHandler.getCachedQueryObjectsByItemType(e)}).processDelta(e).__removeFromAndAddToCachedQueries(r,e).then(function(){for(var i=0,o=n.children;i<o.length;i++){o[i].applyChangesFromParent(e,t,r)}})},t.prototype.getLinkFieldsByParent=function(e,t){var r=this.dependencies.linkTreeService.get()[e.itemType][t],n={};if(void 0===r)throw new Error("Non existing link between '"+e.itemType+"'->'"+t+"'");return r.type===k.ApiLinkTreeType.DIRECT?n[r.field]=e.itemId:(n.itemtype=e.itemType,n.item=e.itemId),n},t.prototype.getParent=function(e,t,r){return void 0===t&&(t=!0),this.getParentFromFields(e,this.itemHandler.itemChanges[e.id])},t.prototype.getItemChangesRecursively=function(e,t){void 0===t&&(t=!0);var r=this.itemHandler.itemChanges[e],n=this.getLocalItemEntry(e);if(void 0!==r&&void 0!==n)return t?this.dependencies.apiFormatter.copyFields(r,{},n.columns.main):r;if(void 0===n)throw new Error("No local entry found");throw new Error("No local fields found for ItemEntry with ItemType '"+n.itemType+"'")},t.prototype.getLocalItemEntryChangesTuple=function(e){var t=this.getLocalItemEntry(e);if(void 0===t)throw new Error("Tried to get a local ItemEntry with entryId '"+e+"' but couldn't find it");return{entry:t,changes:this.itemHandler.itemChanges[e]}},t.prototype.getCollectionChangesRecursively=function(e,t){var r;return null===(r=this.cachedQueryHandler.cachedQueries[e])||void 0===r?void 0:r[t.string]},t.prototype.invalidateCache=function(){this.itemHandler.entries.forEach(function(e){return e.queueReload()}),this.cachedQueryHandler.cachedQueries={}},t.prototype.applyChangesFromChild=function(e,t,r){return this.dependencies.changesProcessorFactory.construct(e,t,r).execute()},t.prototype.applyChangesDelta=function(t,r,n){var i=this;return void 0===r&&(r=!0),void 0===n&&(n=!1),t.isEmpty()?this.dependencies.promiseService.when({created:[],rollback:D.c}):this.fetchUpdatedDerivedValuesFromDelta(t).then(function(){var o=e.prototype._applyChangesDelta.call(i,t),s=o.result,a=o.internalChangesDelta,c=o.rollbackFunctions;for(var u in t.deleted)for(var l=function(e){i.itemHandler.entries.clear(e);var r=i.itemHandler.itemChanges[e.id];delete t.updated[e.id],delete i.itemHandler.itemChanges[e.id],a.setItemDeleted(e),c.push(function(t){t.setItemUpdated(e,r)})},h=0,d=t.deleted[u];h<d.length;h++){l(d[h])}return i.core.collectionMatcherFactory.constructCachedQueryProcessor(i,function(e){return i.cachedQueryHandler.getCachedQueryObjectsByItemType(e)}).processDelta(a).__removeFromAndAddToCachedQueries(n,a).then(function(){for(var e=0,t=i.children;e<t.length;e++){t[e].applyChangesFromParent(a,r,n)}return s})})},t.prototype.getLocalItemEntry=function(e){var t=this.itemHandler.entries.getByEntryId(e);if(void 0!==t)return t},t.prototype.getLocalItemEntryByItemId=function(e,t){var r=this.itemHandler.entries.get(e,t);if(void 0!==r)return r},t.prototype.getChangesFromItemChanges=function(e){return e},t}(O.a),A=function(){function e(e,t){this.queryMatcherFactory=e,this.transaction=t,this.entries={},this.entriesByEntryId={}}return e.prototype.getByEntryId=function(e){return this.entriesByEntryId[e]},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];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],a=this.transaction.getParent(s);null!==a&&(a.itemType===e&&a.itemId==t&&i.push(s))}return i},e.prototype.batchGetLocalByParent=function(e,t,r,n){for(var i=this.entries[r],o={},s=0,a=t;s<a.length;s++){o[a[s]]=[]}if(void 0===i)return o;for(var c in i){var u=i[c],l=this.transaction.getParent(u);null!==l&&(l.itemType===e&&void 0!==o[l.itemId]&&u.isLocal()&&(null===n||this.matchQuery(u,n))&&o[l.itemId].push(u))}return o},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]={}),this.entriesByEntryId[e.id]=e,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={},this.entriesByEntryId={},!0):this.clearByItemId(e.itemType,e.itemId)},e.prototype.clearByItemId=function(e,t){var r=this.entries[e];return void 0!==r&&(!!r.hasOwnProperty(t)&&(delete this.entriesByEntryId[r[t].id],delete r[t]))},e.prototype.matchQuery=function(e,t){var r=this.transaction.getLocalItemEntryChangesTuple(e.id);return!0===this.queryMatcherFactory.construct(e.itemType,this.transaction instanceof P?r.changes:r.changes.changes,this.transaction.getParent(e)).matchQuery(t)},e}(),B=function(){function e(e,t){this.authInterface=e,this.linkTreeService=t}return e.prototype.matchParent=function(e,t){return null===e&&null===t||!(null===e&&null!==t||null!==e&&null===t)&&(e.itemType===t.itemType&&e.itemId==t.itemId)},e.prototype.getLinkFieldsByParent=function(e,t){var r=this.linkTreeService.get()[e.itemType][t];if(void 0===r)throw new Error("Non existing link between '"+e.itemType+"'->'"+t+"'");var n={};return r.type===k.ApiLinkTreeType.DIRECT?n[r.field]=e.itemId:(n.itemtype=e.itemType,n.item=e.itemId),n},e.prototype.getParentByFields=function(e,t,r){var n=this.linkTreeService.get()[e][t.itemType];if(void 0===n)throw new Error("Non existing link between '"+e+"'->'"+t.itemType+"'");var i={};return n.type===k.ApiLinkTreeType.DIRECT?(i.itemType=e,i.itemId=r[n.field]):(i.itemType=r.itemtype,i.itemId=r.item),i},e.prototype.getDisplayName=function(e,t){switch(e.itemType){case"Contact":return"bedrijf"===t.type?t.bedrijf:this.getFullName(t.voornaam,t.tussenvoegsel,t.naam);case"Medewerker":case"Person":return this.getFullName(t.voornaam,t.tussenvoegsel,t.achternaam);default:return t[this.getTitleField(e.itemType)]}},e.prototype.processOptions=function(e){return new C.e(e)},e.prototype.createUnfoundRemoteItemError=function(){return{message:"The requested item could not be found / your current permissions are not sufficient"}},e.prototype.createUnfoundLocalItemError=function(e){return{message:"A local item of type "+e+" could not be found"}},e.prototype.createExistingLocalItemError=function(e){return{message:"A local item of type "+e+" not be created, the ID is already in use"}},e.prototype.getFullName=function(e,t,r){return void 0===e&&(e=""),void 0===t&&(t=""),void 0===r&&(r=""),e.trim().concat(" ",t).trim().concat(" ",r).trim()},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":case"Rol":return"naam";default:return"displayname"}},e.prototype.getLocalDefaultValues=function(){return{permissions:R.a,creator:this.authInterface.getUserId(),created:s()()}},e}(),U=function(){function e(){this.separator=":",this.idCounter=0}return e.prototype.getSingleKey=function(e,t){return e+this.separator+t},e.prototype.getCssKey=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.join("_")},e.prototype.parseStateKey=function(e){return(e=e.toString()).substring(0,R.e.length)===R.e?{type:k.StateKeyType.New,template:e.substring(R.e.length)}:e.substring(0,R.c.length)===R.c?{type:k.StateKeyType.Duplicate,itemId:+e.substring(R.c.length)}:null},e.prototype.getDuplicateStateKey=function(e){return R.c+e},e.prototype.getNewStateKey=function(e){return R.e+e},e.prototype.getLocalId=function(){return+(R.f+this.getRandomString())},e.prototype.getLocalDuplicateId=function(){return+(R.d+this.getRandomString())},e.prototype.getRandomString=function(){return(++this.idCounter).toString()},e.prototype.isLocalId=function(e){return void 0!==e&&(this.isNewId(e)||this.isDuplicateId(e))},e.prototype.isNewId=function(e){return e===R.e||(""+e).substring(0,R.f.length)===R.f},e.prototype.isDuplicateId=function(e){return e===R.c||(""+e).substring(0,R.d.length)===R.d},e}(),V=r(11),N=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.getLocks=function(){return this.lockItems},e.prototype.hasLock=function(e){var t=this.lockItems;for(var r in t)for(var n in t[r]){var i=t[r][n];if(!i.isForeign&&i.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,r=this.errorHandler;return this.fetchCachedLock(e).then(function(r){return void 0!==r?r:t.requestLock(e)},r.reject).then(function(e){return e.isForeign?r.reject(e.message):e.token},r.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=this.lockItems[e.itemType];return void 0!==t&&delete t[e.itemId]},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(a.b)(r,[e.itemType,e.itemId],[{},t])},e}(),W={},Y=function(){function e(e){this.transaction=e,this.parentMap={},this.destination={}}return e.prototype.process=function(){if(void 0===this.transaction.rootItem)throw new Error("A TransactionCache rootItem is required for ModuleChangesCompilation");return this.parentMap=this.createParentMap(),this.processItems(this.transaction.rootItem.itemType,[this.transaction.rootItem],{}),{itemType:this.transaction.rootItem.itemType,itemId:this.transaction.rootItem.itemId,items:this.destination}},e.prototype.createParentMap=function(){var e={};for(var t in this.transaction.itemHandler.itemChanges){var r=this.transaction.getLocalItemEntry(Number(t));if(void 0!==r){var n=r.itemType,i=this.transaction.getParent(r);if(null!==i){var o=i.itemType,s=i.itemId;void 0===e[o]&&(e[o]={}),void 0===e[o][s]&&(e[o][s]={}),void 0===e[o][s][n]&&(e[o][s][n]=[]),e[o][s][n].push(r)}}}return e},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.transaction.itemHandler.formatRequest(e),o={};for(var s in n)this.processItems(s,n[s],o);var c=Object(a.i)(i),u=Object(a.i)(o);return c&&u?{values:i,links:o}:c?{values:i}:u?{links:o}:W},e.prototype.getItemsByParent=function(e,t){var r=this.parentMap[e];return void 0===r?{}:void 0===r[t]?{}:r[t]},e}(),J="maybe",K=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 s.a.isMoment(t)?this.apiFormatter.compareMomentObjects(t,e):s.a.isDuration(t)?this.apiFormatter.compareDurations(t,e):t==e},e.prototype.matchQuery=function(e){if(void 0!==e.search)return J;if(void 0!==e.custom)return J;if(void 0!==e.linkedTo)return this.matchLinkedToQuery(e);if(void 0!==e.query)return J;if(void 0!==e.conditions)return this.matchComplexQuery(e);if(void 0!==e.key)return this.matchSimpleQuery(this.fields[e.key],e);if(!Object(a.i)(e))return!0;throw new Error("queryMatcher: Unsupported query! Parsed?")},e.prototype.matchLinkedToQuery=function(e){if(e.reverse)return J;var t,r=this.parent;return(t=null!==r&&(e.linkedTo===r.itemType&&this.matchSimpleQuery(r.itemId,e.query)))===J?J: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],a=this.matchQuery(s);if(a===r)return e.not?!r:r;a===J&&(t=J)}return t===J?J:e.not?!t:t},e.prototype.matchSimpleQuery=function(e,t){var r=t.key,n=t.value;if(!Object(a.i)(t))return!0;if(void 0===e)return console.warn("Required field",r,"not found for",this.itemType),J;switch("NOW"===n&&(n=s()()),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":var i=Object(a.j)(e,n);return t.not?!i:i;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=":"}(i||(i={}));var z=Object.keys(p.a).map(function(e){return p.a[e]}),G=((n={})[p.a.EQUALS]=p.a.NOT_EQUALS,n[p.a.NOT_EQUALS]=p.a.EQUALS,n[p.a.MORE_THAN]=p.a.LESS_OR_EQUAL_THAN,n[p.a.LESS_THAN]=p.a.EQUAL_OR_MORE_THAN,n[p.a.LESS_OR_EQUAL_THAN]=p.a.MORE_THAN,n[p.a.EQUAL_OR_MORE_THAN]=p.a.LESS_THAN,n[p.a.IN]=p.a.IN,n),X=function(e){function t(t){return e.call(this,t)||this}return Object(d.b)(t,e),t.prototype.parseEmptyQuery=function(){return[{},"{}"]},t.prototype.parseSubQuery=function(e,t,r){void 0===r&&(r=!1);var n=this.parse(t);return[{key:e,query:n[i.OBJ],not:r},"[sub"+i.SEP+e+i.SEP+n[i.STR]+i.SEP+r+"]"]},t.prototype.parseSubFieldQuery=function(e,t,r,n,o){void 0===e&&(e=""),void 0===t&&(t=""),void 0===r&&(r=""),void 0===o&&(o=!1);var s=this.parse(n);return[{key:e,itemType:t,field:r,query:s[i.OBJ],not:o},"[subField"+i.SEP+e+i.SEP+t+i.SEP+r+i.SEP+s[i.STR]+i.SEP+o+"]"]},t.prototype.parseSearchQuery=function(e,t){return void 0===t&&(t=!1),[{search:(e=this.formatValue(e))[i.OBJ],not:t},"[search"+i.SEP+e[i.STR]+i.SEP+t+"]"]},t.prototype.parseCustomQuery=function(e,t,r){if(void 0===r&&(r=!1),void 0===t)return[{custom:e,not:r},"["+e+i.SEP+r+"]"];var n=this.parseCustomParameters(t);return[{custom:e,parameters:n[i.OBJ],not:r},"["+e+i.SEP+n[i.STR]+i.SEP+r+"]"]},t.prototype.parseCustomParameters=function(e){for(var t=Object.keys(e).sort(),r={},n="",o=0;o<t.length;o++){var s=t[o],a=this.formatValue(e[s]);r[s]=a[i.OBJ],o>0&&(n+=i.SEP),n+=a[i.STR]}return[r,n]},t.prototype.parseSimpleQuery=function(e,t,r,n){if(void 0===n&&(n=!1),t=this.formatValue(t),void 0===r&&(r=Array.isArray(t[i.OBJ])?p.a.IN:p.a.EQUALS),-1===z.indexOf(r))throw new Error("Unknown comparator '"+r+"', it might be that the backend supports it but the frontend doesn't !");n&&(r=G[r]);var o=r===p.a.IN&&n,s=[{key:e,value:t[i.OBJ],comparator:r,not:o},"["+r+i.SEP+e+i.SEP+t[i.STR]+"]"];return o&&(s[1]=s[1].slice(0,-1),s[1]+=i.SEP+n+"]"),s},t.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1);var o=this.parse(t);return[{linkedTo:e,query:o[i.OBJ],reverse:r,not:n},"[linkedTo"+i.SEP+e+i.SEP+o[i.STR]+i.SEP+r+i.SEP+n+"]"]},t.prototype.parseComplexQuery=function(e,t,r){void 0===t&&(t=p.b.AND),void 0===r&&(r=!1),t=t.toUpperCase();var n=this.parseConditions(e);return[{conditions:n[i.OBJ],operator:t,not:r},"["+t+n[i.STR]+i.SEP+r+"]"]},t.prototype.parseConditions=function(e){for(var t=this,r=[],n=[],o="",s=0,a=e;s<a.length;s++){var c=a[s];r.push(this.parse(c))}for(var u=0,l=r=r.sort(function(e,r){return t.compareParsedQueries(e,r)});u<l.length;u++){var h=l[u];n.push(h[i.OBJ]),o+=h[i.STR]}return[n,o]},t.prototype.formatValue=function(e){var t=this.processValue(e);return[t,""+t]},t.prototype.processValue=function(e){return Array.isArray(e)?e.slice().sort():s.a.isMoment(e)?s()(e):s.a.isDuration(e)?s.a.duration(e):e},t.prototype.compareParsedQueries=function(e,t){return e[i.STR]===t[i.STR]?0:e[i.STR]>t[i.STR]?1:-1},t}(p.c),Z=function(e){function t(t,r){var n=e.call(this,r)||this;return n.callback=t,n}return Object(d.b)(t,e),t.prototype.parseEmptyQuery=function(){return!1},t.prototype.parseSubQuery=function(e,t,r){return void 0===r&&(r=!1),this.parse(t)},t.prototype.parseSubFieldQuery=function(e,t,r,n,i){return!1},t.prototype.parseSearchQuery=function(e,t){return!1},t.prototype.parseCustomQuery=function(e,t,r){return void 0===r&&(r=!1),!1},t.prototype.parseSimpleQuery=function(e,t,r,n){return!1},t.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1);var i=this.callback(e,t);return n?!i:i},t.prototype.parseComplexQuery=function(e,t,r){return this.parseConditions(e)},t.prototype.parseConditions=function(e){var t=this;return e.some(function(e){return t.parse(e)})},t}(p.c),$=function(){function e(e){this.keyService=e}return e.prototype.containsLinkedTo=function(e,t,r){return new Z(function(e,n){return e===t&&n.id==r},e).parse()},e.prototype.containsLocalLinkedTo=function(e){var t=this;return new Z(function(e,r){return r.hasOwnProperty("id")&&t.keyService.isLocalId(r.id)},e).parse()},e.prototype.addAndCondition=function(e,t){return void 0===e.conditions||e.operator===p.b.OR?{conditions:[e,t]}:{conditions:e.conditions.concat(t)}},e.prototype.addOrCondition=function(e,t){return e.operator===p.b.OR?{conditions:e.conditions.concat(t)}:{conditions:[e,t],operator:p.b.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:p.a.IN,key:"id",value:e,not:!0}},e}(),ee=function(){function e(e){this.columnUtil=e,this.columns={},this.columnSetIdMap={}}return e.prototype.expandWithRequestColumns=function(e,t){var r=this.columns;void 0===r[e]&&(r[e]=[]);var n=this.columnUtil.mergeRequestColumns(r[e],t);return r[e]=n.merged,n},e.prototype.expand=function(e){if(!this.columnSetIdMap[e.id]){var t=this.columns,r=e.itemType;void 0===t[r]&&(t[r]=[]),t[r]=this.columnUtil.mergeRequestColumns(t[r],e.request).merged,this.columnSetIdMap[e.id]=!0}},e.prototype.get=function(){return this.columns},e}(),te=function(){function e(e,t,r,n,i,o,s,a,c){this.requestBufferManager=e,this.changesDeltaFactory=t,this.apiFormatter=r,this.errorHandler=n,this.transactionCacheFactory=i,this.promiseService=o,this.requestColumnExpansionFactory=s,this.apiRequestService=a,this.queryMatcherFactory=c}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)}},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.createQueriesWithFittingItemsMap=function(e,t,r){var n={};for(var i in t){var o=t[i],s=null!==o.parent?o.parent:{},a=this.formatMessageValues(o.values,r);n[i]=this.getCachedQueriesByFittingItem(e,a,s)}return n},e.prototype.getCachedQueriesByFittingItem=function(e,t,r){var n=this.transactionCacheFactory.getServerCache().cachedQueryHandler.cachedQueries[e],i={fitting:[],notfitting:[],maybe:[]};if(!Object(a.i)(n))return i;var o=this.queryMatcherFactory.construct(e,t,r);for(var s in n){var c=n[s],u=o.matchQuery(c.query.object);!0===u?i.fitting.push(c):"maybe"===u?i.maybe.push(c):i.notfitting.push(c)}return i},e.prototype.getRequestColumns=function(e,t){var r=this.transactionCacheFactory.getServerCache(),n=this.requestColumnExpansionFactory.construct();for(var i in t){for(var o=t[i].fitting,s=r.itemHandler.entries.get(e,i),a=0,c=o;a<c.length;a++){var u=c[a];n.expandWithRequestColumns(u.itemType,u.requestColumns)}void 0!==s&&n.expand(s.columns)}return n.get()},e.prototype.processMessage=function(e){var t=this.transactionCacheFactory.getServerCache(),r=e.itemType,n=[],i=this.createQueriesWithFittingItemsMap(r,e.items[r],e.columns[r]),o=this.getRequestColumns(r,i);for(var s in i){var a=+s;void 0===t.itemHandler.entries.get(r,s)?0!==i[a].fitting.length&&n.push(a):n.push(a)}return 0===n.length?this.promiseService.when():this.apiRequestService.query(r,{key:"id",comparator:"IN",value:n},o).then(function(e){return t.processResponse(e,o,!1,!0)},this.errorHandler.reject)},e.prototype.processFunctionChangesResolve=function(e){var t=this,r=this.transactionCacheFactory.getServerCache(),n=e.items.FunctionChangesResolve,i=[];for(var o in n){var s=n[o].parent.itemId,a=r.itemHandler.entries.get("Functie",s);void 0!==a&&void 0!==a.columns.response.Functie.newchanges&&i.push(s)}return 0===i.length?this.promiseService.when():this.requestBufferManager.fetchByIds("Functie",i,["newchanges"]).then(function(e){for(var n=t.changesDeltaFactory.construct(),i=0,o=e.response.links.Functie;i<o.length;i++){var s=o[i],a=r.itemHandler.entries.get("Functie",s),c=r.itemHandler.itemChanges[a.id],u=e.response.fetchObject("Functie",s,!1);void 0!==u&&u.newchanges!==c.newchanges&&n.setItemUpdated(a,{newchanges:u.newchanges})}return r.applyChangesDelta(n,!1,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.isFunctionChangesResolveMessage=function(e){return"FunctionChangesResolve"===e.body.itemType},e.prototype.handleCreate=function(e){var t=e.body;return this.isFunctionChangesResolveMessage(e)?this.processFunctionChangesResolve(t):this.processMessage(t).catch(this.errorHandler.notifyError)},e.prototype.handleUpdate=function(e){return this.processMessage(e.body).catch(this.errorHandler.notifyError)},e.prototype.handleDelete=function(e){for(var t=this.changesDeltaFactory.constructInternalDelta(),r=this.transactionCacheFactory.getServerCache(),n=e.body,i=[],o=0,s=n.items;o<s.length;o++){var a=s[o],c=r.itemHandler.entries.get(n.itemType,a);void 0!==c&&i.push(c)}return t.setItemsDeleted(i),r.applyChangesFromParent(t,!1,!0),this.promiseService.when()},e.prototype.handleLinkMove=function(e){return this.processMessage(e.body).catch(this.errorHandler.notifyError)},e}(),re=r(12),ne=r(17),ie=r(18),oe=function(){function e(e,t,r,n){this.itemHandler=e,this.cachedQueryHandler=t,this.dependencies=r,this.transaction=n,this.collectionResources={}}return e.prototype.expandCollectionResource=function(e,t){var r=this,n=e.entry.columns.mergeRequestColumns(t).difference;return!0!==n&&0===n.length?this.dependencies.promiseService.when():this.dependencies.columnHandler.fetch(e.entry.itemType,n).then(function(t){var i=r.dependencies.changesDeltaFactory.constructInternalDelta();return r.itemHandler.expandLocalItemEntries(i,e.entry.itemType,e.items.map(function(e){return e.entry}),n,t).then(function(){return r.transaction.applyChangesFromParent(i)},r.dependencies.errorHandler.reject).then(function(){var i=r.dependencies.columnExpansionFactory.construct(e.entry.itemType,n,t);e.entry.expandColumns(i)},r.dependencies.errorHandler.reject)},this.dependencies.errorHandler.reject)},e.prototype.addResource=function(e){Object(a.b)(this.collectionResources,[e.entry.itemType,e.entry.query.string],[{},[]]).push(e)},e.prototype.clearResource=function(e){if(e.__clear(),void 0!==this.collectionResources[e.entry.itemType]){var t=this.collectionResources[e.entry.itemType][e.entry.query.string];if(void 0!==t){var r=t.indexOf(e);-1!==r&&t.splice(r,1),0===t.length&&(delete this.collectionResources[e.entry.itemType][e.entry.query.string],Object(a.i)(this.collectionResources[e.entry.itemType])||delete this.collectionResources[e.entry.itemType])}}},e.prototype.moveItems=function(e,t,r){if(e.itemType!==t.itemType)throw new Error("collectionResourceService: Cannot move items: itemType mismatch");for(var n=this.dependencies.changesDeltaFactory.construct(),i=0,o=r;i<o.length;i++){var s=o[i];n.setItemMoved(s,t.parent)}this.transaction.applyChangesDelta(n)},e.prototype.cloneCollectionEntry=function(e,t,r,n){void 0===r&&(r={});var i=this.transaction.getCollectionChangesRecursively(t.itemType,t.query);if(void 0===i)throw new Error("Tried to clone a CollectionEntry which didn't have cached ItemEntries yet");this.itemHandler.cloneItemEntries(e,i.items,r,n)},e}(),se=function(){function e(e){this.transaction=e,this.lastCallId={global:{},item:{}}}return e.prototype.setGlobalError=function(e,t,r,n){var i=this,o=this.getRandomId();this.lastCallId.global[e]=o,Object(a.u)(t)?(this.transaction.isValid=!1,t.then(function(t){o===i.lastCallId.global[e]&&(delete i.lastCallId.global[e],i.transaction._setGlobalError(e,t,r,n))},function(){i.transaction._setIsValid()})):this.transaction._setGlobalError(e,t,r,n)},e.prototype.setItemError=function(e,t,r,n,i,o,s){var c=this,u=this.getRandomId();this.lastCallId.item[e]=u,Object(a.u)(n)?(this.transaction.isValid=!1,n.then(function(n){u===c.lastCallId.item[e]&&(delete c.lastCallId.item[e],c.transaction._setItemError(e,t,r,n,i,o,s))},function(){c.transaction._setIsValid()})):this.transaction._setItemError(e,t,r,n,i,o,s)},e.prototype.getRandomId=function(){return Math.random().toString().split(".")[1]},e}(),ae=r(14),ce=r(19),ue=r(21),le=r(26),he=r(22),de=r(23),pe=r(20);r.d(t,"b",function(){return c}),r.d(t,"c",function(){return u}),r.d(t,"d",function(){return l}),r.d(t,"f",function(){return h}),r.d(t,"i",function(){return f}),r.d(t,"j",function(){return v}),r.d(t,"k",function(){return g.a}),r.d(t,"l",function(){return I}),r.d(t,"m",function(){return b}),r.d(t,"n",function(){return S}),r.d(t,"o",function(){return E}),r.d(t,"p",function(){return F}),r.d(t,"q",function(){return H}),r.d(t,"r",function(){return w}),r.d(t,"s",function(){return M}),r.d(t,"t",function(){return x}),r.d(t,"u",function(){return j}),r.d(t,"x",function(){return A}),r.d(t,"z",function(){return B}),r.d(t,"A",function(){return U}),r.d(t,"R",function(){return V.a}),r.d(t,"B",function(){return N}),r.d(t,"C",function(){return Y}),r.d(t,"D",function(){return K}),r.d(t,"e",function(){return i}),r.d(t,"E",function(){return X}),r.d(t,"F",function(){return $}),r.d(t,"I",function(){return ee}),r.d(t,"M",function(){return te}),r.d(t,"eb",function(){return a.k}),r.d(t,"ub",function(){return a.A}),r.d(t,"cb",function(){return a.i}),r.d(t,"ab",function(){return a.g}),r.d(t,"db",function(){return a.j}),r.d(t,"Z",function(){return a.f}),r.d(t,"W",function(){return a.c}),r.d(t,"tb",function(){return a.z}),r.d(t,"V",function(){return a.b}),r.d(t,"bb",function(){return a.h}),r.d(t,"Y",function(){return a.e}),r.d(t,"sb",function(){return a.y}),r.d(t,"nb",function(){return a.t}),r.d(t,"gb",function(){return a.m}),r.d(t,"qb",function(){return a.w}),r.d(t,"mb",function(){return a.s}),r.d(t,"ib",function(){return a.o}),r.d(t,"fb",function(){return a.l}),r.d(t,"lb",function(){return a.r}),r.d(t,"ob",function(){return a.u}),r.d(t,"pb",function(){return a.v}),r.d(t,"hb",function(){return a.n}),r.d(t,"kb",function(){return a.q}),r.d(t,"rb",function(){return a.x}),r.d(t,"jb",function(){return a.p}),r.d(t,"X",function(){return a.d}),r.d(t,"U",function(){return a.a}),r.d(t,"a",function(){return O.a}),r.d(t,"J",function(){return P}),r.d(t,"L",function(){return _}),r.d(t,"K",function(){return L}),r.d(t,"Q",function(){return re.b}),r.d(t,"N",function(){return re.a}),r.d(t,"S",function(){return ne.a}),r.d(t,"O",function(){return ie.a}),r.d(t,"P",function(){return oe}),r.d(t,"R",function(){return V.a}),r.d(t,"T",function(){return se}),r.d(t,"h",function(){return ae.a}),r.d(t,"g",function(){return ce.a}),r.d(t,"w",function(){return ue.a}),r.d(t,"H",function(){return le.a}),r.d(t,"G",function(){return he.a}),r.d(t,"y",function(){return de.a}),r.d(t,"v",function(){return pe.a})},function(e,t,r){"use strict";function n(e,t){for(var r in t)r in e&&void 0!==t[r]&&(e[r]=t[r])}function i(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 o(e){for(var t in e)return!0;return!1}function s(e){if("object"!=typeof e)return null;for(var t in e)return t;return null}function a(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,a=r;s<a.length;s++){var c=a[s];e.push(c)}return!0}function u(e){e.splice(0)}function l(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 h(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 d(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(y(o)||S(o))for(var s=Object.keys(o),a=0,c=s.length;a<c;a++){var u=s[a],l=o[u];r&&y(l)?I(l)?e[u]=new Date(l.valueOf()):R(l)?e[u]=new RegExp(l):l.nodeName?e[u]=l.cloneNode(!0):q(l)?e[u]=l.clone():(y(e[u])||(e[u]=b(l)?[]:{}),p(e[u],[l],!0)):e[u]=l}}return e}function m(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return p(e,t,!1)}function f(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return p(e,t,!0)}function y(e){return null!==e&&"object"==typeof e}function v(e){return null!==e&&"object"==typeof e&&!Object.getPrototypeOf(e)}function g(e){return"string"==typeof e}function C(e){return"number"==typeof e}function I(e){return"[object Date]"===toString.call(e)}r.d(t,"k",function(){return n}),r.d(t,"A",function(){return i}),r.d(t,"i",function(){return o}),r.d(t,"g",function(){return s}),r.d(t,"j",function(){return a}),r.d(t,"f",function(){return c}),r.d(t,"c",function(){return u}),r.d(t,"z",function(){return l}),r.d(t,"b",function(){return h}),r.d(t,"h",function(){return d}),r.d(t,"e",function(){return m}),r.d(t,"y",function(){return f}),r.d(t,"t",function(){return y}),r.d(t,"m",function(){return v}),r.d(t,"w",function(){return g}),r.d(t,"s",function(){return C}),r.d(t,"o",function(){return I}),r.d(t,"l",function(){return b}),r.d(t,"r",function(){return S}),r.d(t,"u",function(){return E}),r.d(t,"v",function(){return R}),r.d(t,"n",function(){return F}),r.d(t,"q",function(){return q}),r.d(t,"x",function(){return T}),r.d(t,"p",function(){return H}),r.d(t,"d",function(){return w}),r.d(t,"a",function(){return k});var b=Array.isArray;function S(e){return"function"==typeof e}function E(e){return e&&S(e.then)}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 T(e){return e&&e.window===e}function H(e){return void 0!==e}function w(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,a=typeof e;if(a===typeof t&&"object"===a){if(!b(e)){if(I(e))return!!I(t)&&(o=e.getTime(),s=t.getTime(),o===s||o!=o&&s!=s);if(R(e))return!!R(t)&&e.toString()===t.toString();if(T(e)||T(t)||b(t)||I(t)||R(t))return!1;for(n in i=Object.create(null),e)if(!S(e[n])){if(!w(e[n],t[n]))return!1;i[n]=!0}for(n in t)if(!(n in i)&&H(t[n])&&!S(t[n]))return!1;return!0}if(!b(t))return!1;if(r=e.length,e.length===t.length){for(n=0;n<r;n++)if(!w(e[n],t[n]))return!1;return!0}}return!1}function k(e,t,r){var n=[],i=[];if(r=function(e){return C(e)&&e>0}(r)?r:NaN,t){if(e===t)throw new Error("Can't copy! Source and destination are identical.");if(b(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 a(e,r);function s(e,t,r){if(--r<0)return"...";if(b(e))for(var n=0,i=e.length;n<i;n++)t.push(a(e[n],r));else if(v(e))for(var o in e)t[o]=a(e[o],r);else if(e&&"function"==typeof e.hasOwnProperty)for(var o in e)e.hasOwnProperty(o)&&(t[o]=a(e[o],r));else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=a(e[o],r));return t}function a(e,t){if(void 0===t&&(t=5),!y(e))return e;var r=n.indexOf(e);if(-1!==r)return i[r];if(T(e))throw new Error("Can't copy! Making copies of Window instances is not supported.");var o=!1,c=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(a(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===c&&(c=b(e)?[]:Object.create(Object.getPrototypeOf(e)),o=!0),n.push(e),i.push(c),o?s(e,c,t):c}}},function(e,t,r){"use strict";r.d(t,"b",function(){return n}),r.d(t,"a",function(){return i}),r.d(t,"c",function(){return s});var n,i,o=r(1);!function(e){e.OR="OR",e.AND="AND"}(n||(n={})),function(e){e.EQUALS="=",e.NOT_EQUALS="!=",e.LESS_THAN="<",e.MORE_THAN=">",e.LESS_OR_EQUAL_THAN="<=",e.EQUAL_OR_MORE_THAN=">=",e.IN="IN"}(i||(i={}));var s=function(){function e(e){this.query=e}return 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,e);if(void 0!==e.custom)return this.parseCustomQuery(e.custom,e.parameters,e.not,e);if(void 0!==e.search)return this.parseSearchQuery(e.search,e.not,e);if(void 0!==e.conditions)return this.parseComplexQuery(e.conditions,e.operator,e.not,e);if(void 0!==e.itemType)return this.parseSubFieldQuery(e.key,e.itemType,e.field,e.query,e.not,e);if(void 0!==e.key)return"object"==typeof e.query?this.parseSubQuery(e.key,e.query,e.not,e):this.parseSimpleQuery(e.key,e.value,e.comparator,e.not,e);var t=Object(o.g)(e);if(null===t)return this.parseEmptyQuery();var r=e[t];return null!==r&&"object"==typeof r&&r.constructor===Object?this.parseSubQuery(t,r,!1,e):this.parseSimpleQuery(t,r,e.comparator,e.not,e)},e}()},function(e,t,r){"use strict";r.d(t,"b",function(){return i}),r.d(t,"a",function(){return o});
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=15)}([function(e,t,r){"use strict";var n,i,o=r(6),s=r.n(o),a=r(1),c=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.isExpensiveFormat=function(e){switch(e){case"date":case"datetime":case"duration":return!0;default:return!1}},e.prototype.mergeCopyFields=function(e,t,r,n){for(var i=0,o=n;i<o.length;i++){var s=o[i],a=s.path;void 0===r[a]||"id"!==a&&void 0!==t[a]&&!this.compareFields(s.apiColumn.type,t[a],e[a])||(t[a]=this.clone(s.apiColumn.type,r[a]))}return t},e.prototype.formatRequest=function(e,t,r){for(var n={},i=0,o=r;i<o.length;i++){var s=o[i],a=s.id,c=s.apiColumn,u=c.type;c.readOnly||(this.compareFields(u,e[a],t[a])||(n[a]=this.formatRequestValue(u,t[a])))}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,a=o.apiColumn;a.readOnly||(r[s]=this.formatRequestValue(a.type,e[s]))}return r},e.prototype.hasChanges=function(e,t,r,n){void 0===n&&(n=!1);for(var i=0,o=r;i<o.length;i++){var s=o[i],a=s.id,c=s.apiColumn;if("id"===c.type||"link"===c.type||"parenttype"===c.type||"parentid"===c.type||n||!c.readOnly){if(this.isExpensiveFormat(s.apiColumn.type)){var u=Object.getOwnPropertyDescriptor(t,a);if(void 0!==u&&void 0===u.value&&void 0!==u.get)continue}if(!this.compareFields(c.type,e[a],t[a]))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],a=s.id,c=s.apiColumn;c.readOnly||(this.compareFields(c.type,e[a],t[a])||n.push({oldValue:e[a],newValue:t[a],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;e.hasOwnProperty(s)&&(this.isExpensiveFormat(o.apiColumn.type)||void 0!==e[s])&&(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],a=s.path;r[a]=void 0!==e[a]?e[a]:this.clone(s.apiColumn.type,t[a])}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":case"order":return t===r;default:return Object(a.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?s.a.invalid():s()(e,s.a.ISO_8601)},e.prototype.formatResponseDuration=function(e){return s.a.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":case"order":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 s.a.invalid();case"duration":return s.a.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 s()(t);case"json":return Object(a.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 s.a.duration(e)},e.prototype.cloneDate=function(e){return e.clone()},e.prototype.identity=function(e){return e},e}(),u=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}(),l=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.itemType=t.itemType,this.createColumnMaps()}return e.prototype.fetchColumnObject=function(e){return this.columnMap[e]},e.prototype.fetchValue=function(e,t,r){if(void 0!==this.items[e][t]){var n=this.columnMap[e][r],i=this.columnIndexMap[e][r];return this.apiFormatter.formatResponseValue(n.type,this.items[e][t].data[i])}},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.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++){var s=this.columns[e][o];this.apiFormatter.isExpensiveFormat(s.type)?this.addLazyFormattingFunction(s.id,s.type,n[o],i):i[s.id]=this.apiFormatter.formatResponseValue(s.type,n[o])}if(r){var a=this.items[e][t].links;for(var c in i.__links={},a)i.__links[c]=this.fetchObjectArray(c,r,a[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.fetchColumnsObject=function(){return this.columnMap},e.prototype.addLazyFormattingFunction=function(e,t,r,n){var i=this;Object.defineProperty(n,e,{enumerable:!0,configurable:!0,set:function(t){delete n[e],n[e]=t},get:function(){return delete n[e],n[e]=i.apiFormatter.formatResponseValue(t,r)}})},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}(),h=function(){function e(e){this.transaction=e,this.compilation={create:{},delete:{},update:{},move:{}},this.processDelta()}return e.prototype.processDelta=function(){var e=this.transaction.getDelta();for(var t in e.deleted)for(var r=0,n=e.deleted[t];r<n.length;r++){var i=n[r];i.isLocal()||this.addDeleteEntry(i)}for(var o in e.created){var s=e.created[o];this.addCreateEntry(s)}for(var o in e.updated){s=e.updated[o];this.addUpdateEntry(s.entry)}for(var o in e.moved){s=e.moved[o];this.addMoveEntry(s.entry,s.to)}},e.prototype.getDefaultParent=function(){return{itemType:"Void",itemId:0}},e.prototype.addMoveEntry=function(e,t){Object(a.b)(this.compilation.move,[t.itemType,t.itemId],[{},[]]).push(e)},e.prototype.addDeleteEntry=function(e){Object(a.b)(this.compilation.delete,[e.itemType],[[]]).push(e)},e.prototype.addUpdateEntry=function(e){Object(a.b)(this.compilation.update,[e.itemType,e.itemId],[{},e])},e.prototype.addCreateEntry=function(e){var t=this.transaction.getParent(e.entry);null===t&&(t=this.getDefaultParent()),Object(a.b)(this.compilation.create,[t.itemType,t.itemId,e.entry.itemType,e.entry.itemId],[{},{},{},e])},e}(),d=r(3),p=r(2),m=function(e){function t(t,r){var n=e.call(this,r)||this;return n.itemIdConversionMap=t,n}return Object(d.b)(t,e),t.prototype.parseEmptyQuery=function(){},t.prototype.parseSubQuery=function(e,t,r){return void 0===r&&(r=!1),this.parse(t)},t.prototype.parseSubFieldQuery=function(e,t,r,n,i){},t.prototype.parseSearchQuery=function(e,t){},t.prototype.parseCustomQuery=function(e,t,r){void 0===r&&(r=!1)},t.prototype.parseSimpleQuery=function(e,t,r,n,i){for(var o in this.itemIdConversionMap)void 0!==this.itemIdConversionMap[o][t]&&(i.value=this.itemIdConversionMap[o][t])},t.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1),this.parse(t)},t.prototype.parseComplexQuery=function(e,t,r){return this.parseConditions(e)},t.prototype.parseConditions=function(e){var t=this;return e.forEach(function(e){return t.parse(e)})},t}(p.c),f=function(){function e(e,t,r,n,i,o,s,a,c,u,l,h,d){this.changesDeltaFactory=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.columnExpansionFactory=n,this.createRequestFactory=i,this.errorHandler=o,this.promiseService=s,this.requestColumnExpansionFactory=a,this.collectionEntryService=c,this.itemEntryService=u,this.transaction=l,this.breakUpByParent=h,this.onAfterCreateCallback=d,this.itemIdConversionMap={},this.serverCache=this.transaction.getServerCache()}return e.prototype.execute=function(){var e=this,t=this.changesCompilationFactory.construct(this.transaction),r=t.compilation;return this.executeCreateRequests(t).then(function(){return e.executeMoveRequests(r.move)},this.errorHandler.reject).then(function(){return e.executeUpdateRequests(r.update)},this.errorHandler.reject).then(function(){return e.executeDeleteRequests(r.delete)},this.errorHandler.reject).then(function(){return e.itemIdConversionMap},this.errorHandler.reject)},e.prototype.buildMoveRequest=function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r],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&&(r=this.itemIdConversionMap),void 0!==r&&void 0!==r[e])return r[e][t]},e.prototype.executeCreateRequests=function(e){for(var t=this,r=[],n=0,i=this.createRequestFactory.construct(e.compilation.create,this.transaction,this.breakUpByParent).run();n<i.length;n++){var o=i[n];r.push(this.executeCreateRequest(o).then(function(e){return void 0!==t.onAfterCreateCallback&&t.onAfterCreateCallback(t.itemIdConversionMap),e},this.errorHandler.reject))}return this.promiseService.all(r)},e.prototype.executeCreateRequest=function(e){var t=this;return this.apiRequestService.requestSkeleton(e.request).then(function(r){var n=t.changesDeltaFactory.construct(),i=r.map,o=r.fetchColumnsObject(),s=e.items;for(var a in s){var c=t.columnExpansionFactory.construct(a,e.request.columns[a],o);for(var u in s[a]){var l=s[a][u],h=t.getMapValue(a,parseInt(u,10),i);if(void 0!==h){var d=t.transaction.itemHandler.entries.get(a,u);d.itemId=h,t.serverCache.itemHandler.itemChanges[d.id]=t.serverCache.itemHandler.copyTransactionItemEntryChanges(t.transaction.itemHandler.itemChanges[d.id],d),t.serverCache.itemHandler.entries.add(d),t.transaction.itemHandler.entries.clearByItemId(a,Number(u)),void 0!==t.transaction.itemHandler.fieldChangeCallbacks[l.itemType]&&(t.transaction.itemHandler.fieldChangeCallbacks[l.itemType][h]=t.transaction.itemHandler.fieldChangeCallbacks[l.itemType][u],delete t.transaction.itemHandler.fieldChangeCallbacks[l.itemType][u]),t.serverCache.itemHandler.processApiResponse(n,r,l.itemType,Number(h),l.columns,c)}else console.warn("Create failed!",l)}}for(var a in i)for(var u in void 0===t.itemIdConversionMap[a]&&(t.itemIdConversionMap[a]={}),i[a])t.itemIdConversionMap[a][u]=i[a][u];var p=t.transaction.cachedQueryHandler,f=p.cachedQueries;for(var a in f)for(var y in f[a]){var v=f[a][y],g=p.getCachedQueryItems(a,v.query.string);delete p.cachedQueries[a][v.query.string],new m(t.itemIdConversionMap,v.query.object).parse(),v.query=t.collectionEntryService.createQuery(v.query.object),t.transaction.cachedQueryHandler.setCachedQuery(a,v.query,g,v.requestColumns).resolve(),t.serverCache.cachedQueryHandler.setCachedQuery(a,v.query,g.slice(),v.requestColumns).resolve()}var C=t.transaction.collectionHandler,I=C.collectionResources;for(var a in I)for(var y in I[a]){var b=I[a][y];delete C.collectionResources[a][y];for(var S=0,E=b;S<E.length;S++){var F=E[S],R=F.entry,q=R.parent;if(null!==q){var T=t.getMapValue(q.itemType,q.itemId);void 0!==T&&(q.itemId=T)}new m(t.itemIdConversionMap,R.query.object).parse(),R.query=t.collectionEntryService.createQuery(R.query.object),R.query=t.collectionEntryService.createQueryFromOptions(F.options)}C.collectionResources[a][b[0].entry.query.string]=b}return t.serverCache.applyChangesDelta(n)},this.errorHandler.reject)},e.prototype.executeUpdateRequests=function(e){var t=[];for(var r in e)t.push(this.executeUpdateRequest(r,e[r]));return this.promiseService.all(t)},e.prototype.executeUpdateRequest=function(e,t){var r=this,n={},i=this.requestColumnExpansionFactory.construct();for(var o in n[e]={},t){var s=t[o],c=n[e][o]={},u=Object(a.h)(this.transaction.tabRequestParameters,[e,o]);c.values=this.transaction.itemHandler.formatRequest(s),void 0!==u&&(c.parameters=u),i.expand(s.columns)}var l=i.get();return this.apiRequestService.updateItems(e,n,l).then(function(e){return r.serverCache.processResponse(e,l,!0,!1)},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){var r=this;return this.apiRequestService.delete(e,t.map(function(e){return e.itemId})).then(function(e){for(var n=r.changesDeltaFactory.constructInternalDelta(),i=e.items,o=[],s=0,c=t;s<c.length;s++){var u=c[s];Object(a.j)(u.itemId,i)?o.push(u):console.warn("Delete failed!",u)}return n.setItemsDeleted(o),r.serverCache.applyChangesFromParent(n,!0)},this.errorHandler.reject)},e.prototype.executeMoveRequests=function(e){var t=this,r=[],n=function(n,i){var o=e[n][i],s=t.getMapValue(n,i);r.push(t.apiRequestService.moveItems(n,void 0!==s?s:i,t.buildMoveRequest(o)).then(function(){for(var e=t.changesDeltaFactory.constructInternalDelta(),r=0,a=o;r<a.length;r++){var c=a[r];e.setItemUpdated(c,t.itemEntryService.getLinkFieldsByParent({itemType:n,itemId:void 0!==s?s:i},c.itemType))}return t.serverCache.applyChangesFromParent(e,!0)},t.errorHandler.reject))};for(var i in e)for(var o in e[i])n(i,+o);return this.promiseService.all(r)},e}(),y=r(10),v=function(){function e(e,t){this.queryParserFactory=e,this.queryService=t}return e.prototype.createUnfoundLocalCollectionError=function(e){return{message:"A local collection of type "+e+" could not be found"}},e.prototype.cloneOptions=function(e,t){var r=new y.a(e);return r.parent=t,r},e.prototype.processOptions=function(e){return new y.a(e)},e.prototype.createQuery=function(e){var t=this.queryParserFactory.construct(e).parse();return{object:t[0],string:t[1]}},e.prototype.createQueryFromOptions=function(e){var t,r=e.parent;if(null===r)t=e.query;else{var n={linkedTo:r.itemType,query:{id:r.itemId}};t=null===e.query?n:this.queryService.addAndCondition(e.query,n)}return this.createQuery(t)},e.prototype.getIdArray=function(e,t){void 0===t&&(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 a=0;a<e.length;a++)e[a]=r[a];return n},e}(),g=r(16),C=r(5),I=function(){function e(){}return e.prototype.processOptions=function(e){return new C.b(e)},e.prototype.getIdArray=function(e){return e.map(function(e){return e.entry.itemId})},e}(),b=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,o=this.columnUtil.parseRequestColumn(t),s=this.getColumn(e,o.id);if(void 0!==s){if(void 0===n[e]&&(n[e]={}),n[e][o.id]=s,0!==o.children.length){var a=[];this.retrieveColumns(s.itemType,o.children,a,n),0!==a.length&&r.push(((i={})[o.id]=a,i))}}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.columnInfoFactory=e,this.itemType=t,this.responseColumns=n,this.expansionMap={},this.expansionMapSize=0,!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=this.expansionMap,r=e.id;return void 0!==t[r]?t[r]:(this.expansionMapSize++,t[r]=e.isSupersetOf(this.requestColumns)?null:e.expand(this.requestColumns,this.requestColumnsTrue,this.responseColumns))},e.prototype.aggregateRootColumns=function(){var e=this.expansionMap;if(1===this.expansionMapSize){var t=e[Object(a.g)(e)];return null!==t?t.difference.root:[]}var r={};for(var n in e){var i=e[n];null!==i&&this.expandRootColumnMap(i.difference.root,r)}return this.columnInfoFactory.constructFromRootMap(r)},e.prototype.expandRootColumnMap=function(e,t){for(var r=0,n=e;r<n.length;r++){var i=n[r],o=i.id;void 0===t[o]&&(t[o]={apiColumn:i.apiColumn,children:{}}),this.expandRootColumnMap(i.children,t[o].children)}},e}(),E=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,i=this;return void 0===r&&(r={filter:!1}),this.apiRequestService.columns(e,(n={},n[e]=t,n),r).then(function(r){return i.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=r(4),R=function(){function e(e,t){void 0===t&&(t=null),this.apiColumn=e,this.parent=t,this.itemType=null,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+F.b+r,this.tailPath=0===t.level?r:t.tailPath+F.b+r)}return e.prototype.setChildren=function(e,t){return this.itemType=e,this.children=t,this.isLeaf=!1,this},e}(),q={},T=0,H=function(){function e(e,t,r){this.columnUtil=e,this.columnSetFactory=t,this.itemType=r,this.id=++T,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=[]}return e.prototype.groupColumnInfo=function(e){var t=this.columnUtil,r=e.apiColumn,n=null!==e.parent;n?this.derived.push(e):(this.main.push(e),"link"===r.type&&(this.link=e),this[t.isItemColumn(r)?"item":"notItem"].push(e),e.isLeaf||this.root.push(e)),t.isFormattedColumn(r)&&this.formatted[n?"derived":"main"].push(e),t.isFilteredColumn(r)&&this.filtered.push(e),t.isSearchableColumn(r)&&this.searchable.push(e),t.isCustomColumn(r)&&this.custom.push(e),e.isLeaf&&this.leaf.push(e)},e.prototype.toJSON=function(){var e=function(e){return e.map(function(e){return e.id})};return{main:e(this.main),derived:e(this.derived)}},e.prototype.isSupersetOf=function(e){if(!0===e)return this.requestColumnsTrue;var t=this.columnUtil,r=this.request;if(!0===r)return!t.containsDerivedColumns(e);for(var n=0,i=e;n<i.length;n++){var o=i[n];if(!t.containsColumn(o,r))return!1}return!0},e.prototype.getMergedColumnSet=function(e,t,r){var n=this.columnSetFactory.construct(this.itemType,e.merged,t);return n.requestColumnsTrue=this.requestColumnsTrue||r,n},e.prototype.mergeRequestColumns=function(e){return this.columnUtil.mergeRequestColumns(this.request,e)},e.prototype.mergeResponseColumns=function(e){return this.columnUtil.mergeResponseColumns(this.response,e).merged},e.prototype.merge=function(e){return this.getMergedColumnSet(this.mergeRequestColumns(e.request),this.mergeResponseColumns(e.response),e.requestColumnsTrue)},e.prototype.expand=function(e,t,r){var n=this.mergeRequestColumns(e),i=this.mergeResponseColumns(r);return{merged:this.getMergedColumnSet(n,i,t),difference:this.columnSetFactory.construct(this.itemType,n.difference,i,!1,!1)}},e}(),M=function(){function e(e,t){this.columnUtil=e,this.requestColumns=t,this.cache={}}return e.prototype.run=function(e){var t=this.cache,r=e.id;return void 0!==t[r]?t[r]:t[r]=e.isSupersetOf(this.requestColumns)},e.prototype.runWithRequestColumns=function(e){if(!0===this.requestColumns)return!0===e;if(!0===e)return!0;for(var t=0,r=this.requestColumns;t<r.length;t++){var n=r[t];if(!this.columnUtil.containsColumn(n,e))return!1}return!0},e}(),w=r(8),k=function(){function e(e){this.linkTreeService=e}return e.prototype.getColumnsFromLink=function(e,t){var r=this.linkTreeService.get()[e][t],n=[];switch(r.type){case w.ApiLinkTreeType.DIRECT:n.push(r.field);break;case w.ApiLinkTreeType.ITEMTABLE:n.push("itemtype"),n.push("item")}return n},e.prototype.getColumnPath=function(e,t){for(var r="",n="",i=0,o=e;i<o.length;i++){n+=r+o[i].id,r=F.b}return null!==t&&(n+=F.g+t),n},e.prototype.getDateFormatOptions=function(e){var t=s()(),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(a.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"country":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":case"icon":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.containsColumn=function(e,t){var r=this.parseRequestColumn(e),n=this.findRequestColumn(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.containsDerivedColumns=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.parseRequestColumn(n).children.length>0)return!0}return!1},e.prototype.responseColumnsAvailable=function(e,t,r){for(var n=0,i=t;n<i.length;n++){var o,s=i[n],a=this.parseRequestColumn(s),c=a.children,u=r[e];if(void 0===u)return!1;if(void 0===(o=u[a.id]))return!1;if(c.length>0&&!this.responseColumnsAvailable(o.itemType,c,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,r=this.parseRequestColumn(e);if(0===r.children.length)return r.id;for(var n=[],i=0,o=r.children;i<o.length;i++){var s=o[i];n.push(this.copyRequestColumn(s))}return(t={})[r.id]=n,t},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],a=this.mergeRequestColumn(s,r);null!==a&&n.push(a)}return{merged:r,difference:n}},e.prototype.mergeRequestColumn=function(e,t){var r,n,i=this.parseRequestColumn(e),o=this.findRequestColumn(i.id,t);if(-1===o)return t.push(e),e;if(0===i.children.length)return null;"string"==typeof t[o]&&(t[o]=((r={})[i.id]=[],r));for(var s=[],a=0,c=i.children;a<c.length;a++){var u=c[a],l=this.mergeRequestColumn(u,t[o][i.id]);null!==l&&s.push(l)}return 0===s.length?null:((n={})[i.id]=s,n)},e.prototype.getRequestColumnId=function(e){if("string"==typeof e)return e;var t;for(t in e);return t},e.prototype.parseRequestColumn=function(e){if("string"==typeof e)return{id:e,children:[]};var t=Object(a.g)(e);return{id:t,children:e[t]}},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(a.p)(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.parseConfigColumn=function(e){return e.split(F.g)[0].split(F.b)},e.prototype.processConfigColumn=function(e,t){var r,n,i=e[0],o=1===e.length,s=this.findRequestColumn(i,t);o?-1===s&&t.push(i):(-1===s?s=t.push(((r={})[i]=[],r))-1:"string"==typeof t[s]&&(t[s]=((n={})[i]=[],n)),this.processConfigColumn(e.slice(1),t[s][i]))},e.prototype.findRequestColumn=function(e,t){for(var r=0;r<t.length;r++){var n=t[r];if(this.getRequestColumnId(n)===e)return r}return-1},e}(),D=function(){function e(e){this.keyService=e}return 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 a=0,c=s;a<c.length;a++){var u=c[a];n[o][u]=this.keyService.getLocalId(),this.expandLocalConversionMap(o,u,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.updateItemValues=function(e,t,r,n,i){void 0===i&&(i=null);for(var o=0,s=r;o<s.length;o++){var a=s[o],c=a.id,u=a.apiColumn,l=void 0;"link"===u.type&&void 0===e[c]?null!==i&&(l=i.itemId):l=this.getConversionValue(u.itemType,e[c],n),void 0!==l&&(t[c]=l)}},e}(),j=function(){function e(e,t,r,n,i,o){void 0===o&&(o=!1),this.apiFormatter=e,this.keyService=t,this.requestColumnExpansionFactory=r,this.compilation=n,this.transaction=i,this.breakupByParent=o,this.requests=[]}return e.prototype.finalizeRequest=function(e){var t=e.columns;return e.request.columns=t.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(){var e=this.compilation;if(this.breakupByParent)for(var t in e){var r=e[t];for(var n in r)if(!this.keyService.isLocalId(n)){var i=this.initializeRequest();this.extendRequest(r[n],this.setRequestParent(t,i)?+n:null,i),this.requests.push(this.finalizeRequest(i))}}else for(var t in e){r=e[t],i=this.initializeRequest();var o=this.setRequestParent(t,i),s=!1;for(var n in r)this.keyService.isLocalId(n)||(this.extendRequest(r[n],o?+n:null,i),s=!0);s&&this.requests.push(this.finalizeRequest(i))}return this.requests},e.prototype.initializeRequest=function(){return{request:{requestType:"create",items:{},columns:{}},columns:this.requestColumnExpansionFactory.construct(),items:{}}},e.prototype.extendRequest=function(e,t,r){var n=r.request,i=r.items;for(var o in e)for(var s in void 0===n.itemType&&(n.itemType=o),void 0===i[o]&&(i[o]={},n.items[o]={}),e[o]){var c=e[o][s],u=c.entry,l=Object(a.h)(this.compilation,[o,u.itemId]),h=n.items[o][u.itemId]={},d=Object(a.h)(this.transaction.tabRequestParameters,[o,u.itemId]);if(null!==t&&(n.parentId[u.itemId]=t),r.columns.expand(u.columns),i[o][s]=u,h.values=this.apiFormatter.formatRequestLocal(c.fields,u.columns.main),h.parameters=d,void 0!==l){var p=h.links={};for(var m in l)for(var f in p[m]=[],l[m])p[m].push(parseInt(f,10));this.extendRequest(l,null,r)}}},e}(),x=r(9),O=r(13),Q=r(15),L=function(e){function t(t,r,n,i,o,s,a,c,u,l){var h=e.call(this,o,u,n,c,l)||this;return h.columnSubsetCacheFactory=t,h.requestBufferManager=r,h.apiRequestService=i,h.errorHandler=s,h.itemHandler=a,h.transaction=l,h}return Object(d.b)(t,e),t.prototype.__fetchCachedQueryItem=function(e,t){var r=this,n=this.collectionEntryService.createQueryFromOptions(t);this.expandColumnsWithQueryColumns(e,t,n.object);var i,o=this.transaction.core.changesDeltaFactory.construct(),s=this.columnSubsetCacheFactory.construct(t.columns);return this.__fetchItemEntriesByQueryData(e,t,s,n).then(function(e){return i=e,r.transaction.applyChangesDelta(o)},this.errorHandler.reject).then(function(){return i},this.errorHandler.reject)},t.prototype.__fetchLinkedCachedQueryItems=function(e,t,r,n){var i=this,o={};Object(Q.isFunction)(t)&&(t=t());for(var s=this.transaction.core.changesDeltaFactory.construct(),a=0,c=t;a<c.length;a++){var u=c[a],l=this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:u}),h=this.collectionEntryService.createQueryFromOptions(l);this.expandColumnsWithQueryColumns(r,l,h.object);var d=this.columnSubsetCacheFactory.construct(l.columns);o[u]=this.__fetchItemEntriesByQueryData(r,l,d,h)}return this.promiseService.all(o).then(function(e){return i.transaction.applyChangesDelta(s).then(function(){return e},i.errorHandler.reject)},this.errorHandler.reject)},t.prototype.__addItemEntriesToCachedQueries=function(t,r,n){e.prototype.__addItemEntriesToCachedQueries.call(this,t,r,n,function(e){return e.isLocal()})},t.prototype.__expandCachedQuery=function(e,t){var r=this,n=this.columnUtil.mergeRequestColumns(e.requestColumns,t).difference;return!0!==n&&0===n.length?this.promiseService.when(e):this.requestBufferManager.fetchByQuery(e.itemType,[e.query.object,e.query.string],n).then(function(){return e.requestColumns=r.columnUtil.mergeRequestColumns(e.requestColumns,t).merged,e},this.errorHandler.reject)},t.prototype.__fetchItemEntriesByQueryData=function(e,t,r,n){var i,o,s=this;if(null!==t.limit){var a,c=((i={})[e]=t.columns,i);return this.apiRequestService.requestSkeleton({requestType:"query",itemType:e,columns:c,query:n.object,limit:t.limit}).then(function(e){return a=e,s.transaction.processResponse(a,c,!1,!1)},this.errorHandler.reject).then(function(){for(var r=[],i=0,o=a.links[e];i<o.length;i++){var c=o[i];r.push(s.itemHandler.entries.get(e,c))}var u=s.promiseService.defer(),l={itemType:e,query:n,items:r,requestColumns:t.columns,promise:u.promise,resolve:function(){u.resolve(l)},reject:function(e){u.reject(e)}};return l.resolve(),l})}var u,l=null===(o=this.cachedQueries[e])||void 0===o?void 0:o[n.string];if(void 0===l)l=this.initCachedQuery(e,n,r.requestColumns),u=this.requestBufferManager.fetchByQuery(e,[n.object,n.string],r.requestColumns);else{if(r.runWithRequestColumns(l.requestColumns))return l.promise;u=this.requestBufferManager.fetchByQuery(e,[n.object,n.string],r.requestColumns)}return u.then(function(){return l.requestColumns=s.columnUtil.mergeRequestColumns(l.requestColumns,r.requestColumns).merged,l.resolve(),l},function(e){return l.reject(e),s.errorHandler.reject(e)})},t}(r(29).a),_=function(e){function t(t,r,n,i,o,s,a,c,u,l,h,d){var p=e.call(this,a,c,u,s,o,h,l,d)||this;return p.requestBufferManager=t,p.queryParserFactory=r,p.queryService=n,p.columnSubsetCacheFactory=i,p.transaction=d,p.itemChanges={},p}return Object(d.b)(t,e),t.prototype.createItemEntry=function(t){var r=e.prototype.createItemEntry.call(this,t);return this.itemChanges[r.id]=t.fields,r},t.prototype.processItemEntryChanges=function(e,t,r,n,i){void 0===t&&(t=!1),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=!1);var o=e.entry,s=e.changes;void 0===this.itemChanges[o.id]&&(this.itemChanges[o.id]={}),null!==s.expandedColumns&&(o.columns=s.expandedColumns.merged);var a=this.apiFormatter.copyFields(this.itemChanges[o.id],{},o.columns.main);return this.apiFormatter.copyFields(s.fields,this.itemChanges[o.id],o.columns.main),void 0!==s.fields.id&&(o.itemId=s.fields.id),a},t.prototype.copyTransactionItemEntryChanges=function(e,t){return this.apiFormatter.copyFields(e.changes,{},t.columns.main)},t.prototype.fetchItemEntry=function(e,t,r){return r.columns=this.expandColumnsWithCachedQueryColumns(e,r.columns),this.fetchItemEntryData(e,t,this.columnSubsetCacheFactory.construct(r.columns))},t.prototype.fetchItemEntriesByQuery=function(e,t,r){var n=this;return r.columns=this.expandColumnsWithCachedQueryColumns(e,r.columns),this.requestBufferManager.fetchByQuery(e,this.queryParserFactory.construct(this.queryService.addParentCondition(t,r.parent)).parse(),r.columns).then(function(t){for(var r=[],i=0,o=t.links[e];i<o.length;i++){var s=o[i],a=n.entries.get(e,s);void 0!==a&&r.push(a)}return r},this.errorHandler.reject)},t.prototype.extendItemEntries=function(e,t,r){return this.requestBufferManager.fetchByIds(e,t.map(function(e){return e.itemId}),r).then(function(){return t},this.errorHandler.reject)},t.prototype.fetchItemEntries=function(e,t,r){r.columns=this.expandColumnsWithCachedQueryColumns(e,r.columns);for(var n=this.columnSubsetCacheFactory.construct(r.columns),i=[],o=0,s=t;o<s.length;o++){var a=s[o];i.push(this.fetchItemEntryData(e,a,n))}return this.promiseService.all(i)},t.prototype.fetchLinkedItemEntriesData=function(e,t,r,n,i){return null===n?this.requestBufferManager.fetchByIds(e,t,i):this.requestBufferManager.fetchByQuery(r,this.queryParserFactory.construct(this.queryService.addAndCondition(n,{linkedTo:e,query:{id:t}})).parse(),i)},t.prototype.processApiResponse=function(e,t,r,n,i,o){var s=this.entries.get(r,n),a=t.fetchObject(r,n);if(void 0===a)throw new Error("Fields not found in response for "+r+":"+n);void 0===s?e._setItemCreated(n,a,i):e.setItemUpdated(s,a,o.run(s.columns))},t.prototype.fetchItemEntryData=function(e,t,r){var n=this,i=this.entries.get(e,t);return void 0!==i&&r.run(i.columns)?this.promiseService.when(i):this.requestBufferManager.fetchById(e,t,r.requestColumns).then(function(){return n.entries.get(e,t)},this.errorHandler.reject)},t}(r(27).a),P=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.dependencies=t,n.parent=null,n.itemHandler=new _(t.requestBufferManager,t.queryParserFactory,t.queryService,t.columnSubsetCacheFactory,t.errorHandler,t.promiseService,t.columnUtil,t.apiFormatter,t.itemEntryFactory,t.itemCacheFactory,t.requestColumnExpansionFactory,n),n.cachedQueryHandler=new L(t.columnSubsetCacheFactory,t.requestBufferManager,t.requestColumnExpansionFactory,t.apiRequestService,t.collectionEntryService,t.errorHandler,n.itemHandler,t.promiseService,t.columnUtil,n),n}return Object(d.b)(t,e),t.prototype.getServerCache=function(){return this},t.prototype.createChild=function(e,t){var r=new re.a(this.dependencies,this.core,this,e,t);return this.children.push(r),r},t.prototype.expandCollectionResources=function(e,t,r){var n=this;if(0===r.length)return this.dependencies.promiseService.when(t);var i=[];for(var o in t)i.push(Number(o));return this.itemHandler.fetchLinkedItemEntriesData(t[0].entry.parent.itemType,i,e,null,r).then(function(o){for(var s,a=n.dependencies.columnExpansionFactory.construct(e,r,o.fetchColumnsObject()),c=0,u=i;c<u.length;c++){var l=u[c],h=t[l].entry,d=null===(s=n.cachedQueryHandler.cachedQueries[h.itemType])||void 0===s?void 0:s[h.query.string];void 0!==d&&(d.requestColumns=n.dependencies.columnUtil.mergeRequestColumns(d.requestColumns,r).merged),h.expandColumns(a)}return t})},t.prototype.processResponse=function(e,t,r,n,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=this.core.changesDeltaFactory.construct());var o=e.fetchColumnsObject();for(var s in o)this.dependencies.columnCache.setColumns(s,t[s],o);for(var s in e.items){var a=void 0;a=s===e.itemType?this.core.columnSetFactory.construct(s,t[s],o):this.core.columnSetFactory.constructFromResponse(s,o);var c=this.core.columnExpansionFactory.construct(s,!!a.requestColumnsTrue||a.request,o);for(var u in e.items[s])this.itemHandler.processApiResponse(i,e,s,Number(u),a,c)}return this.applyChangesDelta(i,r,n)},t.prototype.applyChangesFromParent=function(e,t,r){var n=this;void 0===t&&(t=!1),void 0===r&&(r=!1);var i=this.core.changesDeltaFactory.constructInternalDelta();for(var o in e.updated){var s=e.updated[o];null!==this.itemHandler.processItemEntryChanges(s,r)&&i.setItemUpdated(s.entry,s.changes.fields,s.changes.expandedColumns)}for(var a in e.deleted)for(var c=0,u=e.deleted[a];c<u.length;c++){var l=u[c];this.itemHandler.entries.clear(l),i.setItemDeleted(l),delete this.itemHandler.itemChanges[l.id]}return this.core.collectionMatcherFactory.constructCachedQueryProcessor(this,function(e){return n.cachedQueryHandler.getCachedQueryObjectsByItemType(e)}).processDelta(i).__removeFromAndAddToCachedQueries(r,i).then(function(){for(var i=0,o=n.children;i<o.length;i++){o[i].applyChangesFromParent(e,t,r)}})},t.prototype.getLinkFieldsByParent=function(e,t){var r=this.dependencies.linkTreeService.get()[e.itemType][t],n={};if(void 0===r)throw new Error("Non existing link between '"+e.itemType+"'->'"+t+"'");return r.type===w.ApiLinkTreeType.DIRECT?n[r.field]=e.itemId:(n.itemtype=e.itemType,n.item=e.itemId),n},t.prototype.getParent=function(e,t,r){return void 0===t&&(t=!0),this.getParentFromFields(e,this.itemHandler.itemChanges[e.id])},t.prototype.getItemChangesRecursively=function(e,t){void 0===t&&(t=!0);var r=this.itemHandler.itemChanges[e],n=this.getLocalItemEntry(e);if(void 0!==r&&void 0!==n)return t?this.dependencies.apiFormatter.copyFields(r,{},n.columns.main):r;if(void 0===n)throw new Error("No local entry found");throw new Error("No local fields found for ItemEntry with ItemType '"+n.itemType+"'")},t.prototype.getLocalItemEntryChangesTuple=function(e){var t=this.getLocalItemEntry(e);if(void 0===t)throw new Error("Tried to get a local ItemEntry with entryId '"+e+"' but couldn't find it");return{entry:t,changes:this.itemHandler.itemChanges[e]}},t.prototype.getCollectionChangesRecursively=function(e,t){var r;return null===(r=this.cachedQueryHandler.cachedQueries[e])||void 0===r?void 0:r[t.string]},t.prototype.invalidateCache=function(){this.itemHandler.entries.forEach(function(e){return e.queueReload()}),this.cachedQueryHandler.cachedQueries={}},t.prototype.applyChangesFromChild=function(e,t,r){return this.dependencies.changesProcessorFactory.construct(e,t,r).execute()},t.prototype.applyChangesDelta=function(t,r,n){var i=this;return void 0===r&&(r=!0),void 0===n&&(n=!1),t.isEmpty()?this.dependencies.promiseService.when({created:[],rollback:x.c}):this.fetchUpdatedDerivedValuesFromDelta(t).then(function(){var o=e.prototype._applyChangesDelta.call(i,t),s=o.result,a=o.matchingDelta,c=o.internalChangesDelta,u=o.rollbackFunctions;for(var l in t.deleted)for(var h=function(e){i.itemHandler.entries.clear(e);var r=i.itemHandler.itemChanges[e.id];delete t.updated[e.id],delete i.itemHandler.itemChanges[e.id],c.setItemDeleted(e),a.setItemDeleted(e),u.push(function(t){t.setItemUpdated(e,r)})},d=0,p=t.deleted[l];d<p.length;d++){h(p[d])}return i.core.collectionMatcherFactory.constructCachedQueryProcessor(i,function(e){return i.cachedQueryHandler.getCachedQueryObjectsByItemType(e)}).processDelta(a).__removeFromAndAddToCachedQueries(n,a).then(function(){for(var e=0,t=i.children;e<t.length;e++){t[e].applyChangesFromParent(c,r,n)}return s})})},t.prototype.getLocalItemEntry=function(e){var t=this.itemHandler.entries.getByEntryId(e);if(void 0!==t)return t},t.prototype.getLocalItemEntryByItemId=function(e,t){var r=this.itemHandler.entries.get(e,t);if(void 0!==r)return r},t.prototype.getChangesFromItemChanges=function(e){return e},t}(O.a),A=function(){function e(e,t){this.queryMatcherFactory=e,this.transaction=t,this.entries={},this.entriesByEntryId={}}return e.prototype.getByEntryId=function(e){return this.entriesByEntryId[e]},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];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],a=this.transaction.getParent(s);null!==a&&(a.itemType===e&&a.itemId==t&&i.push(s))}return i},e.prototype.batchGetLocalByParent=function(e,t,r,n){for(var i=this.entries[r],o={},s=0,a=t;s<a.length;s++){o[a[s]]=[]}if(void 0===i)return o;for(var c in i){var u=i[c],l=this.transaction.getParent(u);null!==l&&(l.itemType===e&&void 0!==o[l.itemId]&&u.isLocal()&&(null===n||this.matchQuery(u,n))&&o[l.itemId].push(u))}return o},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]={}),this.entriesByEntryId[e.id]=e,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={},this.entriesByEntryId={},!0):this.clearByItemId(e.itemType,e.itemId)},e.prototype.clearByItemId=function(e,t){var r=this.entries[e];return void 0!==r&&(!!r.hasOwnProperty(t)&&(delete this.entriesByEntryId[r[t].id],delete r[t]))},e.prototype.matchQuery=function(e,t){var r=this.transaction.getLocalItemEntryChangesTuple(e.id);return!0===this.queryMatcherFactory.construct(e.itemType,this.transaction instanceof P?r.changes:r.changes.changes,this.transaction.getParent(e)).matchQuery(t)},e}(),B=function(){function e(e,t){this.authInterface=e,this.linkTreeService=t}return e.prototype.matchParent=function(e,t){return null===e&&null===t||!(null===e&&null!==t||null!==e&&null===t)&&(e.itemType===t.itemType&&e.itemId==t.itemId)},e.prototype.getLinkFieldsByParent=function(e,t){var r=this.linkTreeService.get()[e.itemType][t];if(void 0===r)throw new Error("Non existing link between '"+e.itemType+"'->'"+t+"'");var n={};return r.type===w.ApiLinkTreeType.DIRECT?n[r.field]=e.itemId:(n.itemtype=e.itemType,n.item=e.itemId),n},e.prototype.getParentByFields=function(e,t,r){var n=this.linkTreeService.get()[e][t.itemType];if(void 0===n)throw new Error("Non existing link between '"+e+"'->'"+t.itemType+"'");var i={};return n.type===w.ApiLinkTreeType.DIRECT?(i.itemType=e,i.itemId=r[n.field]):(i.itemType=r.itemtype,i.itemId=r.item),i},e.prototype.getDisplayName=function(e,t){switch(e.itemType){case"Contact":return"bedrijf"===t.type?t.bedrijf:this.getFullName(t.voornaam,t.tussenvoegsel,t.naam);case"Medewerker":case"Person":return this.getFullName(t.voornaam,t.tussenvoegsel,t.achternaam);default:return t[this.getTitleField(e.itemType)]}},e.prototype.processOptions=function(e){return new C.e(e)},e.prototype.createUnfoundRemoteItemError=function(){return{message:"The requested item could not be found / your current permissions are not sufficient"}},e.prototype.createUnfoundLocalItemError=function(e){return{message:"A local item of type "+e+" could not be found"}},e.prototype.createExistingLocalItemError=function(e){return{message:"A local item of type "+e+" not be created, the ID is already in use"}},e.prototype.getFullName=function(e,t,r){return void 0===e&&(e=""),void 0===t&&(t=""),void 0===r&&(r=""),e.trim().concat(" ",t).trim().concat(" ",r).trim()},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":case"Rol":return"naam";default:return"displayname"}},e.prototype.getLocalDefaultValues=function(){return{permissions:F.a,creator:this.authInterface.getUserId(),created:s()()}},e}(),U=function(){function e(){this.separator=":",this.idCounter=0}return e.prototype.getSingleKey=function(e,t){return e+this.separator+t},e.prototype.getCssKey=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.join("_")},e.prototype.parseStateKey=function(e){return(e=e.toString()).substring(0,F.e.length)===F.e?{type:w.StateKeyType.New,template:e.substring(F.e.length)}:e.substring(0,F.c.length)===F.c?{type:w.StateKeyType.Duplicate,itemId:+e.substring(F.c.length)}:null},e.prototype.getDuplicateStateKey=function(e){return F.c+e},e.prototype.getNewStateKey=function(e){return F.e+e},e.prototype.getLocalId=function(){return+(F.f+this.getRandomString())},e.prototype.getLocalDuplicateId=function(){return+(F.d+this.getRandomString())},e.prototype.getRandomString=function(){return(++this.idCounter).toString()},e.prototype.isLocalId=function(e){return void 0!==e&&(this.isNewId(e)||this.isDuplicateId(e))},e.prototype.isNewId=function(e){return e===F.e||(""+e).substring(0,F.f.length)===F.f},e.prototype.isDuplicateId=function(e){return e===F.c||(""+e).substring(0,F.d.length)===F.d},e}(),V=r(11),N=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.getLocks=function(){return this.lockItems},e.prototype.hasLock=function(e){var t=this.lockItems;for(var r in t)for(var n in t[r]){var i=t[r][n];if(!i.isForeign&&i.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,r=this.errorHandler;return this.fetchCachedLock(e).then(function(r){return void 0!==r?r:t.requestLock(e)},r.reject).then(function(e){return e.isForeign?r.reject(e.message):e.token},r.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=this.lockItems[e.itemType];return void 0!==t&&delete t[e.itemId]},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(a.b)(r,[e.itemType,e.itemId],[{},t])},e}(),W={},Y=function(){function e(e){this.transaction=e,this.parentMap={},this.destination={}}return e.prototype.process=function(){if(void 0===this.transaction.rootItem)throw new Error("A TransactionCache rootItem is required for ModuleChangesCompilation");return this.parentMap=this.createParentMap(),this.processItems(this.transaction.rootItem.itemType,[this.transaction.rootItem],{}),{itemType:this.transaction.rootItem.itemType,itemId:this.transaction.rootItem.itemId,items:this.destination}},e.prototype.createParentMap=function(){var e={};for(var t in this.transaction.itemHandler.itemChanges){var r=this.transaction.getLocalItemEntry(Number(t));if(void 0!==r){var n=r.itemType,i=this.transaction.getParent(r);if(null!==i){var o=i.itemType,s=i.itemId;void 0===e[o]&&(e[o]={}),void 0===e[o][s]&&(e[o][s]={}),void 0===e[o][s][n]&&(e[o][s][n]=[]),e[o][s][n].push(r)}}}return e},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.transaction.itemHandler.formatRequest(e),o={};for(var s in n)this.processItems(s,n[s],o);var c=Object(a.i)(i),u=Object(a.i)(o);return c&&u?{values:i,links:o}:c?{values:i}:u?{links:o}:W},e.prototype.getItemsByParent=function(e,t){var r=this.parentMap[e];return void 0===r?{}:void 0===r[t]?{}:r[t]},e}(),J="maybe",K=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 s.a.isMoment(t)?this.apiFormatter.compareMomentObjects(t,e):s.a.isDuration(t)?this.apiFormatter.compareDurations(t,e):t==e},e.prototype.matchQuery=function(e){if(void 0!==e.search)return J;if(void 0!==e.custom)return J;if(void 0!==e.linkedTo)return this.matchLinkedToQuery(e);if(void 0!==e.query)return J;if(void 0!==e.conditions)return this.matchComplexQuery(e);if(void 0!==e.key)return this.matchSimpleQuery(this.fields[e.key],e);if(!Object(a.i)(e))return!0;throw new Error("queryMatcher: Unsupported query! Parsed?")},e.prototype.matchLinkedToQuery=function(e){if(e.reverse)return J;var t,r=this.parent;return(t=null!==r&&(e.linkedTo===r.itemType&&this.matchSimpleQuery(r.itemId,e.query)))===J?J: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],a=this.matchQuery(s);if(a===r)return e.not?!r:r;a===J&&(t=J)}return t===J?J:e.not?!t:t},e.prototype.matchSimpleQuery=function(e,t){var r=t.key,n=t.value;if(!Object(a.i)(t))return!0;if(void 0===e)return console.warn("Required field",r,"not found for",this.itemType),J;switch("NOW"===n&&(n=s()()),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":var i=Object(a.j)(e,n);return t.not?!i:i;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=":"}(i||(i={}));var z=Object.keys(p.a).map(function(e){return p.a[e]}),G=((n={})[p.a.EQUALS]=p.a.NOT_EQUALS,n[p.a.NOT_EQUALS]=p.a.EQUALS,n[p.a.MORE_THAN]=p.a.LESS_OR_EQUAL_THAN,n[p.a.LESS_THAN]=p.a.EQUAL_OR_MORE_THAN,n[p.a.LESS_OR_EQUAL_THAN]=p.a.MORE_THAN,n[p.a.EQUAL_OR_MORE_THAN]=p.a.LESS_THAN,n[p.a.IN]=p.a.IN,n),X=function(e){function t(t){return e.call(this,t)||this}return Object(d.b)(t,e),t.prototype.parseEmptyQuery=function(){return[{},"{}"]},t.prototype.parseSubQuery=function(e,t,r){void 0===r&&(r=!1);var n=this.parse(t);return[{key:e,query:n[i.OBJ],not:r},"[sub"+i.SEP+e+i.SEP+n[i.STR]+i.SEP+r+"]"]},t.prototype.parseSubFieldQuery=function(e,t,r,n,o){void 0===e&&(e=""),void 0===t&&(t=""),void 0===r&&(r=""),void 0===o&&(o=!1);var s=this.parse(n);return[{key:e,itemType:t,field:r,query:s[i.OBJ],not:o},"[subField"+i.SEP+e+i.SEP+t+i.SEP+r+i.SEP+s[i.STR]+i.SEP+o+"]"]},t.prototype.parseSearchQuery=function(e,t){return void 0===t&&(t=!1),[{search:(e=this.formatValue(e))[i.OBJ],not:t},"[search"+i.SEP+e[i.STR]+i.SEP+t+"]"]},t.prototype.parseCustomQuery=function(e,t,r){if(void 0===r&&(r=!1),void 0===t)return[{custom:e,not:r},"["+e+i.SEP+r+"]"];var n=this.parseCustomParameters(t);return[{custom:e,parameters:n[i.OBJ],not:r},"["+e+i.SEP+n[i.STR]+i.SEP+r+"]"]},t.prototype.parseCustomParameters=function(e){for(var t=Object.keys(e).sort(),r={},n="",o=0;o<t.length;o++){var s=t[o],a=this.formatValue(e[s]);r[s]=a[i.OBJ],o>0&&(n+=i.SEP),n+=a[i.STR]}return[r,n]},t.prototype.parseSimpleQuery=function(e,t,r,n){if(void 0===n&&(n=!1),t=this.formatValue(t),void 0===r&&(r=Array.isArray(t[i.OBJ])?p.a.IN:p.a.EQUALS),-1===z.indexOf(r))throw new Error("Unknown comparator '"+r+"', it might be that the backend supports it but the frontend doesn't !");n&&(r=G[r]);var o=r===p.a.IN&&n,s=[{key:e,value:t[i.OBJ],comparator:r,not:o},"["+r+i.SEP+e+i.SEP+t[i.STR]+"]"];return o&&(s[1]=s[1].slice(0,-1),s[1]+=i.SEP+n+"]"),s},t.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1);var o=this.parse(t);return[{linkedTo:e,query:o[i.OBJ],reverse:r,not:n},"[linkedTo"+i.SEP+e+i.SEP+o[i.STR]+i.SEP+r+i.SEP+n+"]"]},t.prototype.parseComplexQuery=function(e,t,r){void 0===t&&(t=p.b.AND),void 0===r&&(r=!1),t=t.toUpperCase();var n=this.parseConditions(e);return[{conditions:n[i.OBJ],operator:t,not:r},"["+t+n[i.STR]+i.SEP+r+"]"]},t.prototype.parseConditions=function(e){for(var t=this,r=[],n=[],o="",s=0,a=e;s<a.length;s++){var c=a[s];r.push(this.parse(c))}for(var u=0,l=r=r.sort(function(e,r){return t.compareParsedQueries(e,r)});u<l.length;u++){var h=l[u];n.push(h[i.OBJ]),o+=h[i.STR]}return[n,o]},t.prototype.formatValue=function(e){var t=this.processValue(e);return[t,""+t]},t.prototype.processValue=function(e){return Array.isArray(e)?e.slice().sort():s.a.isMoment(e)?s()(e):s.a.isDuration(e)?s.a.duration(e):e},t.prototype.compareParsedQueries=function(e,t){return e[i.STR]===t[i.STR]?0:e[i.STR]>t[i.STR]?1:-1},t}(p.c),Z=function(e){function t(t,r){var n=e.call(this,r)||this;return n.callback=t,n}return Object(d.b)(t,e),t.prototype.parseEmptyQuery=function(){return!1},t.prototype.parseSubQuery=function(e,t,r){return void 0===r&&(r=!1),this.parse(t)},t.prototype.parseSubFieldQuery=function(e,t,r,n,i){return!1},t.prototype.parseSearchQuery=function(e,t){return!1},t.prototype.parseCustomQuery=function(e,t,r){return void 0===r&&(r=!1),!1},t.prototype.parseSimpleQuery=function(e,t,r,n){return!1},t.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1);var i=this.callback(e,t);return n?!i:i},t.prototype.parseComplexQuery=function(e,t,r){return this.parseConditions(e)},t.prototype.parseConditions=function(e){var t=this;return e.some(function(e){return t.parse(e)})},t}(p.c),$=function(){function e(e){this.keyService=e}return e.prototype.containsLinkedTo=function(e,t,r){return new Z(function(e,n){return e===t&&n.id==r},e).parse()},e.prototype.containsLocalLinkedTo=function(e){var t=this;return new Z(function(e,r){return r.hasOwnProperty("id")&&t.keyService.isLocalId(r.id)},e).parse()},e.prototype.addAndCondition=function(e,t){return void 0===e.conditions||e.operator===p.b.OR?{conditions:[e,t]}:{conditions:e.conditions.concat(t)}},e.prototype.addOrCondition=function(e,t){return e.operator===p.b.OR?{conditions:e.conditions.concat(t)}:{conditions:[e,t],operator:p.b.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:p.a.IN,key:"id",value:e,not:!0}},e}(),ee=function(){function e(e){this.columnUtil=e,this.columns={},this.columnSetIdMap={}}return e.prototype.expandWithRequestColumns=function(e,t){var r=this.columns;void 0===r[e]&&(r[e]=[]);var n=this.columnUtil.mergeRequestColumns(r[e],t);return r[e]=n.merged,n},e.prototype.expand=function(e){if(!this.columnSetIdMap[e.id]){var t=this.columns,r=e.itemType;void 0===t[r]&&(t[r]=[]),t[r]=this.columnUtil.mergeRequestColumns(t[r],e.request).merged,this.columnSetIdMap[e.id]=!0}},e.prototype.get=function(){return this.columns},e}(),te=function(){function e(e,t,r,n,i,o,s,a,c){this.requestBufferManager=e,this.changesDeltaFactory=t,this.apiFormatter=r,this.errorHandler=n,this.transactionCacheFactory=i,this.promiseService=o,this.requestColumnExpansionFactory=s,this.apiRequestService=a,this.queryMatcherFactory=c}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)}},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.createQueriesWithFittingItemsMap=function(e,t,r){var n={};for(var i in t){var o=t[i],s=null!==o.parent?o.parent:{},a=this.formatMessageValues(o.values,r);n[i]=this.getCachedQueriesByFittingItem(e,a,s)}return n},e.prototype.getCachedQueriesByFittingItem=function(e,t,r){var n=this.transactionCacheFactory.getServerCache().cachedQueryHandler.cachedQueries[e],i={fitting:[],notfitting:[],maybe:[]};if(!Object(a.i)(n))return i;var o=this.queryMatcherFactory.construct(e,t,r);for(var s in n){var c=n[s],u=o.matchQuery(c.query.object);!0===u?i.fitting.push(c):"maybe"===u?i.maybe.push(c):i.notfitting.push(c)}return i},e.prototype.getRequestColumns=function(e,t){var r=this.transactionCacheFactory.getServerCache(),n=this.requestColumnExpansionFactory.construct();for(var i in t){for(var o=t[i].fitting,s=r.itemHandler.entries.get(e,i),a=0,c=o;a<c.length;a++){var u=c[a];n.expandWithRequestColumns(u.itemType,u.requestColumns)}void 0!==s&&n.expand(s.columns)}return n.get()},e.prototype.processMessage=function(e){var t=this.transactionCacheFactory.getServerCache(),r=e.itemType,n=[],i=this.createQueriesWithFittingItemsMap(r,e.items[r],e.columns[r]),o=this.getRequestColumns(r,i);for(var s in i){var a=+s;void 0===t.itemHandler.entries.get(r,s)?0!==i[a].fitting.length&&n.push(a):n.push(a)}return 0===n.length?this.promiseService.when():this.apiRequestService.query(r,{key:"id",comparator:"IN",value:n},o).then(function(e){return t.processResponse(e,o,!1,!0)},this.errorHandler.reject)},e.prototype.processFunctionChangesResolve=function(e){var t=this,r=this.transactionCacheFactory.getServerCache(),n=e.items.FunctionChangesResolve,i=[];for(var o in n){var s=n[o].parent.itemId,a=r.itemHandler.entries.get("Functie",s);void 0!==a&&void 0!==a.columns.response.Functie.newchanges&&i.push(s)}return 0===i.length?this.promiseService.when():this.requestBufferManager.fetchByIds("Functie",i,["newchanges"]).then(function(e){for(var n=t.changesDeltaFactory.construct(),i=0,o=e.response.links.Functie;i<o.length;i++){var s=o[i],a=r.itemHandler.entries.get("Functie",s),c=r.itemHandler.itemChanges[a.id],u=e.response.fetchObject("Functie",s,!1);void 0!==u&&u.newchanges!==c.newchanges&&n.setItemUpdated(a,{newchanges:u.newchanges})}return r.applyChangesDelta(n,!1,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.isFunctionChangesResolveMessage=function(e){return"FunctionChangesResolve"===e.body.itemType},e.prototype.handleCreate=function(e){var t=e.body;return this.isFunctionChangesResolveMessage(e)?this.processFunctionChangesResolve(t):this.processMessage(t).catch(this.errorHandler.notifyError)},e.prototype.handleUpdate=function(e){return this.processMessage(e.body).catch(this.errorHandler.notifyError)},e.prototype.handleDelete=function(e){for(var t=this.changesDeltaFactory.constructInternalDelta(),r=this.transactionCacheFactory.getServerCache(),n=e.body,i=[],o=0,s=n.items;o<s.length;o++){var a=s[o],c=r.itemHandler.entries.get(n.itemType,a);void 0!==c&&i.push(c)}return t.setItemsDeleted(i),r.applyChangesFromParent(t,!1,!0),this.promiseService.when()},e.prototype.handleLinkMove=function(e){return this.processMessage(e.body).catch(this.errorHandler.notifyError)},e}(),re=r(12),ne=r(17),ie=r(18),oe=function(){function e(e,t,r,n){this.itemHandler=e,this.cachedQueryHandler=t,this.dependencies=r,this.transaction=n,this.collectionResources={}}return e.prototype.expandCollectionResource=function(e,t){var r=this,n=e.entry.columns.mergeRequestColumns(t).difference;return!0!==n&&0===n.length?this.dependencies.promiseService.when():this.dependencies.columnHandler.fetch(e.entry.itemType,n).then(function(t){var i=r.dependencies.changesDeltaFactory.constructInternalDelta();return r.itemHandler.expandLocalItemEntries(i,e.entry.itemType,e.items.map(function(e){return e.entry}),n,t).then(function(){return r.transaction.applyChangesFromParent(i)},r.dependencies.errorHandler.reject).then(function(){var i=r.dependencies.columnExpansionFactory.construct(e.entry.itemType,n,t);e.entry.expandColumns(i)},r.dependencies.errorHandler.reject)},this.dependencies.errorHandler.reject)},e.prototype.addResource=function(e){Object(a.b)(this.collectionResources,[e.entry.itemType,e.entry.query.string],[{},[]]).push(e)},e.prototype.clearResource=function(e){if(e.__clear(),void 0!==this.collectionResources[e.entry.itemType]){var t=this.collectionResources[e.entry.itemType][e.entry.query.string];if(void 0!==t){var r=t.indexOf(e);-1!==r&&t.splice(r,1),0===t.length&&(delete this.collectionResources[e.entry.itemType][e.entry.query.string],Object(a.i)(this.collectionResources[e.entry.itemType])||delete this.collectionResources[e.entry.itemType])}}},e.prototype.moveItems=function(e,t,r){if(e.itemType!==t.itemType)throw new Error("collectionResourceService: Cannot move items: itemType mismatch");for(var n=this.dependencies.changesDeltaFactory.construct(),i=0,o=r;i<o.length;i++){var s=o[i];n.setItemMoved(s,t.parent)}this.transaction.applyChangesDelta(n)},e.prototype.cloneCollectionEntry=function(e,t,r,n){void 0===r&&(r={});var i=this.transaction.getCollectionChangesRecursively(t.itemType,t.query);if(void 0===i)throw new Error("Tried to clone a CollectionEntry which didn't have cached ItemEntries yet");this.itemHandler.cloneItemEntries(e,i.items,r,n)},e}(),se=function(){function e(e){this.transaction=e,this.lastCallIdMap={global:{},item:{}},this._lastCallId=0}return e.prototype.isPending=function(){return Object(a.i)(this.lastCallIdMap.global)||Object(a.i)(this.lastCallIdMap.item)},e.prototype.setGlobalError=function(e,t,r,n){var i=this,o=this._lastCallId++;if(this.lastCallIdMap.global[e]=o,!Object(a.u)(t))return delete this.lastCallIdMap.global[e],void this.transaction._setGlobalError(e,t,r,n);t.then(function(t){o===i.lastCallIdMap.global[e]&&(delete i.lastCallIdMap.global[e],i.transaction._setGlobalError(e,t,r,n))},function(){o===i.lastCallIdMap.global[e]&&(delete i.lastCallIdMap.global[e],i.transaction._setIsValid())})},e.prototype.setItemError=function(e,t,r,n,i,o,s){var c=this,u=this._lastCallId++,l=this.getHash(e,t,r);if(this.lastCallIdMap.item[l]=u,!Object(a.u)(n))return delete this.lastCallIdMap.item[l],void this.transaction._setItemError(e,t,r,n,i,o,s);n.then(function(n){c.lastCallIdMap.item[l]===u&&(delete c.lastCallIdMap.item[l],c.transaction._setItemError(e,t,r,n,i,o,s))},function(){c.lastCallIdMap.item[l]===u&&(delete c.lastCallIdMap.item[l],c.transaction._setIsValid())})},e.prototype.getHash=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.join("-")},e}(),ae=r(14),ce=r(19),ue=r(21),le=r(26),he=r(22),de=r(23),pe=r(20);r.d(t,"b",function(){return c}),r.d(t,"c",function(){return u}),r.d(t,"d",function(){return l}),r.d(t,"f",function(){return h}),r.d(t,"i",function(){return f}),r.d(t,"j",function(){return v}),r.d(t,"k",function(){return g.a}),r.d(t,"l",function(){return I}),r.d(t,"m",function(){return b}),r.d(t,"n",function(){return S}),r.d(t,"o",function(){return E}),r.d(t,"p",function(){return R}),r.d(t,"q",function(){return H}),r.d(t,"r",function(){return M}),r.d(t,"s",function(){return k}),r.d(t,"t",function(){return D}),r.d(t,"u",function(){return j}),r.d(t,"x",function(){return A}),r.d(t,"z",function(){return B}),r.d(t,"A",function(){return U}),r.d(t,"R",function(){return V.a}),r.d(t,"B",function(){return N}),r.d(t,"C",function(){return Y}),r.d(t,"D",function(){return K}),r.d(t,"e",function(){return i}),r.d(t,"E",function(){return X}),r.d(t,"F",function(){return $}),r.d(t,"I",function(){return ee}),r.d(t,"M",function(){return te}),r.d(t,"eb",function(){return a.k}),r.d(t,"ub",function(){return a.A}),r.d(t,"cb",function(){return a.i}),r.d(t,"ab",function(){return a.g}),r.d(t,"db",function(){return a.j}),r.d(t,"Z",function(){return a.f}),r.d(t,"W",function(){return a.c}),r.d(t,"tb",function(){return a.z}),r.d(t,"V",function(){return a.b}),r.d(t,"bb",function(){return a.h}),r.d(t,"Y",function(){return a.e}),r.d(t,"sb",function(){return a.y}),r.d(t,"nb",function(){return a.t}),r.d(t,"gb",function(){return a.m}),r.d(t,"qb",function(){return a.w}),r.d(t,"mb",function(){return a.s}),r.d(t,"ib",function(){return a.o}),r.d(t,"fb",function(){return a.l}),r.d(t,"lb",function(){return a.r}),r.d(t,"ob",function(){return a.u}),r.d(t,"pb",function(){return a.v}),r.d(t,"hb",function(){return a.n}),r.d(t,"kb",function(){return a.q}),r.d(t,"rb",function(){return a.x}),r.d(t,"jb",function(){return a.p}),r.d(t,"X",function(){return a.d}),r.d(t,"U",function(){return a.a}),r.d(t,"a",function(){return O.a}),r.d(t,"J",function(){return P}),r.d(t,"L",function(){return _}),r.d(t,"K",function(){return L}),r.d(t,"Q",function(){return re.b}),r.d(t,"N",function(){return re.a}),r.d(t,"S",function(){return ne.a}),r.d(t,"O",function(){return ie.a}),r.d(t,"P",function(){return oe}),r.d(t,"R",function(){return V.a}),r.d(t,"T",function(){return se}),r.d(t,"h",function(){return ae.a}),r.d(t,"g",function(){return ce.a}),r.d(t,"w",function(){return ue.a}),r.d(t,"H",function(){return le.a}),r.d(t,"G",function(){return he.a}),r.d(t,"y",function(){return de.a}),r.d(t,"v",function(){return pe.a})},function(e,t,r){"use strict";function n(e,t){for(var r in t)r in e&&void 0!==t[r]&&(e[r]=t[r])}function i(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 o(e){for(var t in e)return!0;return!1}function s(e){if("object"!=typeof e)return null;for(var t in e)return t;return null}function a(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,a=r;s<a.length;s++){var c=a[s];e.push(c)}return!0}function u(e){e.splice(0)}function l(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 h(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 d(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(y(o)||S(o))for(var s=Object.keys(o),a=0,c=s.length;a<c;a++){var u=s[a],l=o[u];r&&y(l)?I(l)?e[u]=new Date(l.valueOf()):F(l)?e[u]=new RegExp(l):l.nodeName?e[u]=l.cloneNode(!0):q(l)?e[u]=l.clone():(y(e[u])||(e[u]=b(l)?[]:{}),p(e[u],[l],!0)):e[u]=l}}return e}function m(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return p(e,t,!1)}function f(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return p(e,t,!0)}function y(e){return null!==e&&"object"==typeof e}function v(e){return null!==e&&"object"==typeof e&&!Object.getPrototypeOf(e)}function g(e){return"string"==typeof e}function C(e){return"number"==typeof e}function I(e){return"[object Date]"===toString.call(e)}r.d(t,"k",function(){return n}),r.d(t,"A",function(){return i}),r.d(t,"i",function(){return o}),r.d(t,"g",function(){return s}),r.d(t,"j",function(){return a}),r.d(t,"f",function(){return c}),r.d(t,"c",function(){return u}),r.d(t,"z",function(){return l}),r.d(t,"b",function(){return h}),r.d(t,"h",function(){return d}),r.d(t,"e",function(){return m}),r.d(t,"y",function(){return f}),r.d(t,"t",function(){return y}),r.d(t,"m",function(){return v}),r.d(t,"w",function(){return g}),r.d(t,"s",function(){return C}),r.d(t,"o",function(){return I}),r.d(t,"l",function(){return b}),r.d(t,"r",function(){return S}),r.d(t,"u",function(){return E}),r.d(t,"v",function(){return F}),r.d(t,"n",function(){return R}),r.d(t,"q",function(){return q}),r.d(t,"x",function(){return T}),r.d(t,"p",function(){return H}),r.d(t,"d",function(){return M}),r.d(t,"a",function(){return w});var b=Array.isArray;function S(e){return"function"==typeof e}function E(e){return e&&S(e.then)}function F(e){return"[object RegExp]"===toString.call(e)}function R(e){return"boolean"==typeof e}function q(e){return!(!e||!(e.nodeName||e.prop&&e.attr&&e.find))}function T(e){return e&&e.window===e}function H(e){return void 0!==e}function M(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,a=typeof e;if(a===typeof t&&"object"===a){if(!b(e)){if(I(e))return!!I(t)&&(o=e.getTime(),s=t.getTime(),o===s||o!=o&&s!=s);if(F(e))return!!F(t)&&e.toString()===t.toString();if(T(e)||T(t)||b(t)||I(t)||F(t))return!1;for(n in i=Object.create(null),e)if(!S(e[n])){if(!M(e[n],t[n]))return!1;i[n]=!0}for(n in t)if(!(n in i)&&H(t[n])&&!S(t[n]))return!1;return!0}if(!b(t))return!1;if(r=e.length,e.length===t.length){for(n=0;n<r;n++)if(!M(e[n],t[n]))return!1;return!0}}return!1}function w(e,t,r){var n=[],i=[];if(r=function(e){return C(e)&&e>0}(r)?r:NaN,t){if(e===t)throw new Error("Can't copy! Source and destination are identical.");if(b(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 a(e,r);function s(e,t,r){if(--r<0)return"...";if(b(e))for(var n=0,i=e.length;n<i;n++)t.push(a(e[n],r));else if(v(e))for(var o in e)t[o]=a(e[o],r);else if(e&&"function"==typeof e.hasOwnProperty)for(var o in e)e.hasOwnProperty(o)&&(t[o]=a(e[o],r));else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=a(e[o],r));return t}function a(e,t){if(void 0===t&&(t=5),!y(e))return e;var r=n.indexOf(e);if(-1!==r)return i[r];if(T(e))throw new Error("Can't copy! Making copies of Window instances is not supported.");var o=!1,c=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(a(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===c&&(c=b(e)?[]:Object.create(Object.getPrototypeOf(e)),o=!0),n.push(e),i.push(c),o?s(e,c,t):c}}},function(e,t,r){"use strict";r.d(t,"b",function(){return n}),r.d(t,"a",function(){return i}),r.d(t,"c",function(){return s});var n,i,o=r(1);!function(e){e.OR="OR",e.AND="AND"}(n||(n={})),function(e){e.EQUALS="=",e.NOT_EQUALS="!=",e.LESS_THAN="<",e.MORE_THAN=">",e.LESS_OR_EQUAL_THAN="<=",e.EQUAL_OR_MORE_THAN=">=",e.IN="IN"}(i||(i={}));var s=function(){function e(e){this.query=e}return 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,e);if(void 0!==e.custom)return this.parseCustomQuery(e.custom,e.parameters,e.not,e);if(void 0!==e.search)return this.parseSearchQuery(e.search,e.not,e);if(void 0!==e.conditions)return this.parseComplexQuery(e.conditions,e.operator,e.not,e);if(void 0!==e.itemType)return this.parseSubFieldQuery(e.key,e.itemType,e.field,e.query,e.not,e);if(void 0!==e.key)return"object"==typeof e.query?this.parseSubQuery(e.key,e.query,e.not,e):this.parseSimpleQuery(e.key,e.value,e.comparator,e.not,e);var t=Object(o.g)(e);if(null===t)return this.parseEmptyQuery();var r=e[t];return null!==r&&"object"==typeof r&&r.constructor===Object?this.parseSubQuery(t,r,!1,e):this.parseSimpleQuery(t,r,e.comparator,e.not,e)},e}()},function(e,t,r){"use strict";r.d(t,"b",function(){return i}),r.d(t,"a",function(){return o});
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation. All rights reserved.
4
4
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -13,4 +13,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
13
13
  See the Apache Version 2.0 License for specific language governing permissions
14
14
  and limitations under the License.
15
15
  ***************************************************************************** */
16
- var n=function(e,t){return(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])})(e,t)};function i(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)}},function(e,t,r){"use strict";r.d(t,"a",function(){return n}),r.d(t,"b",function(){return i}),r.d(t,"g",function(){return o}),r.d(t,"f",function(){return s}),r.d(t,"d",function(){return a}),r.d(t,"e",function(){return c}),r.d(t,"c",function(){return u});var n="7",i=">",o=":",s="-1",a="-2",c="new-",u="dup-"},function(e,t,r){"use strict";var n=r(0),i=function(){return function(e){this.columns=!0,this.parent=null,this.templateOptions={},Object(n.eb)(this,e)}}(),o=0,s=function(){function e(e,t,r,n){this.factory=e,this.itemType=t,this.itemId=r,this.columns=n,this.id=++o,this.reloadQueued=!1}return e.prototype.queueReload=function(){return this.reloadQueued=!0,this},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.toJSON=function(){return{id:this.id,columns:this.columns}},e}(),a=function(){function e(e,t,r,n){this.factory=e,this.entry=t,this._isNew=r,this.transaction=n,this.columns=t.columns.response[t.columns.itemType],this.initial=this.transaction.itemHandler.itemChanges[t.id].initial,this.fields=n.itemHandler.itemChanges[t.id].changes,this.onConstruct()}return e.prototype.onConstruct=function(){},e.prototype.setFields=function(e){var t=this,r=this.columns;for(var n in e){void 0===r[n]&&console.warn("setFields: no column found for",n)}var i=this.transaction.createChangesDelta();return i.setItemUpdated(this.entry,e),this.transaction.applyChangesDelta(i).then(function(){return t},this.factory.errorHandler.reject)},e.prototype.copyFields=function(e){void 0===e&&(e={});var t=this.entry;return this.factory.apiFormatter.copyFields(this.fields,e,t.columns.main),e},e.prototype.getParent=function(e){return this.transaction.getParent(this.entry,e,this.fields)},e.prototype.callOnChange=function(e){var t,r=this,n=null===(t=this.transaction.itemHandler.fieldChangeCallbacks[this.entry.itemType])||void 0===t?void 0:t[this.entry.itemId];if(void 0!==n)for(var i=0,o=n;i<o.length;i++){var s=o[i];try{s({itemEntry:this.entry,compareField:function(t){return r.factory.apiFormatter.compareFields(r.entry.columns.response[r.entry.itemType][t].type,r.fields[t],e[t])},fields:this.fields,isCalledAfterSocketUpdate:!1,previous:e})}catch(e){this.factory.exceptionHandler(e)}}},e.prototype.compareItemField=function(e,t){var r=this.columns[e];if(void 0===r)throw new Error("Missing column in ItemResource.compareItemField");return this.factory.apiFormatter.compareFields(r.type,this.fields[e],t[e])},e.prototype.hasChanges=function(){return this.transaction.itemHandler.detectEntryChanges(this.entry.id)},e.prototype.setTransactionParameters=function(e){Object(n.V)(this.transaction.tabRequestParameters,[this.entry.itemType,this.entry.itemId],[{},e])},e.prototype.isNew=function(){return this._isNew},e.prototype.isLocal=function(){return this.entry.isLocal()},e.prototype.toJSON=function(){var e=[];for(var t in this.columns)e.push(t);return{columns:e,fields:this.fields,entry:this.entry}},e.prototype.getDerivedValue=function(e){return this.transaction.itemHandler.getDerivedValue(this.entry,e)},e.prototype.getDerivedValues=function(e){return this.transaction.itemHandler.getDerivedValues(this.entry,e)},e}(),c=r(10),u=0,l=function(){function e(e,t,r,n,i,o,s){this.collectionEntryService=e,this.queryService=t,this.columnSetFactory=r,this.keyService=n,this.columnCache=i,this.itemType=o,this.options=s,this.id=u++,this.parent=null,this.reloadQueued=!1,this.parent=s.parent,this.query=this.collectionEntryService.createQueryFromOptions(s);var a=this.columnCache.retrieve(o,s.columns);(!0===a.missing||a.missing.length>0)&&console.warn("Missing columns in CollectionEntry",a.missing),this.columns=this.columnSetFactory.construct(o,s.columns,a.cached)}return e.prototype.isLocal=function(){var e=this.parent;return null===e?this.queryService.containsLocalLinkedTo(this.query.object):this.keyService.isLocalId(e.itemId)},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.options.columns=this.columns.request)},e}(),h=r(9),d=function(){function e(e,t,r,n,i){this.factory=e,this.options=t,this.transaction=r,this.itemIdMap={},this.fieldChangeDeregFns={},this.onChangeCallbacks=[],this.onAddCallbacks=[],this.onRemoveCallbacks=[],this.removedItemIds=[],this.entry=this.factory.collectionEntryFactory.construct(n,this.options),this.columns=this.entry.columns.response,this.items=[],this.itemIdMap={},this.registerListeners(),this.addItemResources(i,!0),this.onConstruct()}return e.prototype.onConstruct=function(){},e.prototype.setLimit=function(e){var t=null===this.options.limit?null:this.options.limit.limit;if("number"==typeof e){if(null===this.options.limit)throw new Error("Tried to set a limit only using a number, but the collection didn't have a limit object yet");this.options.limit.limit=e}else this.options.limit=e;null===t&&null===this.options.limit||(null===t||t>this.options.limit.limit?this.limitAfterAdd(!1):t<this.options.limit.limit&&this.limitAfterRemove())},e.prototype.onAdd=function(e){return this.__registerCallback(this.onAddCallbacks,e)},e.prototype.onChange=function(e){return this.__registerCallback(this.onChangeCallbacks,e)},e.prototype.onRemove=function(e){return this.__registerCallback(this.onRemoveCallbacks,e)},e.prototype.__clear=function(){this.onAddCallbacks.length=0,this.onChangeCallbacks.length=0,this.onRemoveCallbacks.length=0},e.prototype.moveItems=function(e,t){return this.transaction.collectionHandler.moveItems(this.entry,t.entry,e)},e.prototype.removeItems=function(e){for(var t=this.factory.changesDeltaFactory.construct(),r=[],n=0,i=this.items;n<i.length;n++){var o=i[n].entry;-1!==e.indexOf(o.itemId)&&r.push(o)}return t.setItemsDeleted(r),this.transaction.applyChangesDelta(t)},e.prototype.removeItem=function(e){return this.removeItems([e])},e.prototype.addItems=function(e){var t=this,r=this.transaction.createChangesDelta();if(null!==this.entry.parent)for(var n=this.factory.itemEntryService.getLinkFieldsByParent(this.entry.parent,this.entry.itemType),i=0,o=e;i<o.length;i++){var s=o[i];for(var a in n)s[a]=n[a]}return r.setItemsCreated(this.entry.itemType,e).then(function(){return t.transaction.applyChangesDelta(r)})},e.prototype.addItem=function(e){return this.addItems([e])},e.prototype.getIdArray=function(){return this.items.map(function(e){return e.entry.itemId})},e.prototype.getItemById=function(e){return this.itemIdMap[e]},e.prototype.addItemResources=function(e,t,r){var n=this;if(void 0===t&&(t=!1),void 0===r&&(r=!1),0===e.length)return[];e=e.filter(function(e){return void 0===n.itemIdMap[e.itemId]});for(var i=this.transaction.createItemResources(e),o=0,s=i;o<s.length;o++){var a=s[o],c=a.entry.itemId;if(void 0===this.itemIdMap[c]){this.items.push(a),this.itemIdMap[c]=a;var u=this.removedItemIds.indexOf(c);u>-1&&this.removedItemIds.splice(u),this.fieldChangeDeregFns[a.entry.id]=this.transaction.registerFieldChangeCallback(a.entry.itemType,a.entry.itemId,function(e){n.callOnChange(e.itemEntry,e.compareField,e.fields,r,e.previous)})}}return this.limitAfterAdd(r,i),i.length>0&&(!t||this.options.callOnAddWithInitialItems)&&this.callOnAdd(i,t,r),i},e.prototype.removeItemResources=function(e,t){var r=this,i=[];return 0===e.length?i:(Object(n.Z)(this.items,function(t){for(var n=0,o=e;n<o.length;n++){var s=o[n];if(t.entry===s)return i.push(t),delete r.itemIdMap[s.itemId],r.fieldChangeDeregFns[s.id](),delete r.fieldChangeDeregFns[s.id],r.removedItemIds.push(s.itemId),!1}return!0}),this.callOnRemove(i,t),this.limitAfterRemove(),i)},e.prototype.callOnAdd=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=!1);try{for(var n=0,i=this.onAddCallbacks;n<i.length;n++){(0,i[n])({itemResources:e,collectionResource:this,isInitialCall:t,isCalledAfterSocketUpdate:r})}}catch(e){this.factory.exceptionHandler(e)}},e.prototype.callOnChange=function(e,t,r,n,i){try{for(var o=0,s=this.onChangeCallbacks;o<s.length;o++){(0,s[o])({itemEntry:e,compareField:t,fields:r,isCalledAfterSocketUpdate:n,previous:i})}}catch(e){this.factory.exceptionHandler(e)}},e.prototype.callOnRemove=function(e,t){try{for(var r=0,n=this.onRemoveCallbacks;r<n.length;r++){(0,n[r])({itemResources:e,collectionResource:this,isCalledAfterSocketUpdate:t})}}catch(e){this.factory.exceptionHandler(e)}},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++){if(void 0===(a=i[n]).entry.columns.response[this.entry.itemType][e])throw new Error("Trying to group on a column not in one of the items in this collection! (column '"+e+"', item "+a.entry.itemType+":"+a.entry.itemId+")");void 0===r[c=a.fields[e]]&&(r[c]=[]),r[c].push(a)}if("function"==typeof e)for(var o=0,s=t;o<s.length;o++){var a,c;null!==(c=e(a=s[o]))&&(void 0===r[c]&&(r[c]=[]),r[c].push(a))}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.clearResource=function(){for(var e in this.fieldChangeDeregFns)this.fieldChangeDeregFns[e](),delete this.fieldChangeDeregFns[e];this.transaction.clearCollectionResource(this)},e.prototype.registerListeners=function(){var e=this;this.onChangeCallbacks.push(function(t){t.compareField("id")||(e.itemIdMap[t.fields.id]=e.getItemById(t.previous.id),delete e.itemIdMap[t.previous.id])}),this.options.onAdd!==h.c&&this.onAddCallbacks.push(function(t){e.options.onAdd(t.itemResources,t.collectionResource,t.isInitialCall,t.isCalledAfterSocketUpdate)}),this.options.onRemove!==h.c&&this.onRemoveCallbacks.push(function(t){e.options.onRemove(t.itemResources,t.collectionResource,t.isCalledAfterSocketUpdate)}),this.options.onChange!==h.c&&this.onChangeCallbacks.push(function(t){return e.options.onChange(t)})},e.prototype.__registerCallback=function(e,t){return e.push(t),function(){var r=e.indexOf(t);r>-1&&e.splice(r,1)}},e.prototype.limitAfterRemove=function(){var e=this;null===this.options.limit||this.options.limit.limit<=this.items.length||this.transaction.cachedQueryHandler.__fetchCachedQueryItem(this.entry.itemType,new c.a({query:this.factory.queryService.addAndCondition(this.entry.query.object,this.factory.queryService.createNotIn(this.removedItemIds)),columns:this.entry.options.columns,parent:this.entry.parent,limit:this.entry.options.limit})).then(function(t){e.addItemResources(t.items)})},e.prototype.limitAfterAdd=function(e,t){var r=this.entry.options.limit;if(!(null===r||this.items.length<=r.limit)){this.items.sort(function(e,t){var n=e.fields[r.field]-t.fields[r.field];return void 0===r.order||"desc"===r.order?-n:n});for(var n=this.items.splice(r.limit,this.items.length-r.limit),i=0,o=n;i<o.length;i++){var s=o[i];if(this.fieldChangeDeregFns[s.entry.id](),delete this.itemIdMap[s.entry.itemId],delete this.fieldChangeDeregFns[s.entry.id],this.removedItemIds.push(s.entry.itemId),void 0!==t){var a=t.indexOf(s);a>-1&&t.splice(a,1)}}this.callOnRemove(n,e)}},e}(),p=function(){function e(e,t,r,n,i){this.itemType=t,this.response=r;var o=r.fetchColumnsObject();this.responseColumns=e.columnUtil.mergeResponseColumns(o,i).merged,this.columns=e.columnSetFactory.constructFromResponse(t,o),this.columns=this.columns.expand(n[t],!1,i).merged}return e.prototype.getFields=function(){var e=this.itemType;return this.response.fetchObject(e,this.response.links[e][0])},e}();r.d(t,"e",function(){return i}),r.d(t,"d",function(){return s}),r.d(t,"f",function(){return a}),r.d(t,"b",function(){return c.a}),r.d(t,"a",function(){return l}),r.d(t,"c",function(){return d}),r.d(t,"g",function(){return p})},function(t,r){t.exports=e},function(e,t,r){"use strict";var n=r(0),i=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e){return new n.d(this.apiFormatter,e)},e}(),o=function(){function e(){}return e.prototype.construct=function(e){return new n.f(e)},e}(),s=r(5),a=r(10),c=function(){function e(e,t,r,n,i){this.collectionEntryService=e,this.columnSetFactory=t,this.keyService=r,this.queryService=n,this.columnCache=i}return e.prototype.construct=function(e,t){return new s.a(this.collectionEntryService,this.queryService,this.columnSetFactory,this.keyService,this.columnCache,e,new a.a(t))},e}(),u=r(3),l=r(28),h=r(12),d=function(e){function t(t,r,n,i,o,s){var a=e.call(this,n,i,o)||this;return a.apiRequestService=t,a.promiseService=r,a.getQueries=s,a.map={},a}return Object(u.b)(t,e),t.prototype.__removeFromAndAddToCachedQueries=function(e,t){var r=this;void 0===e&&(e=!1);var n=[],i=function(e){var i,s=o.map[e],a=o.groupItemEntries(s.matches);if(o.transaction.cachedQueryHandler.__removeItemEntriesFromCachedQueries(s.itemType,s.query,a.notFitting),o.transaction.cachedQueryHandler.__addItemEntriesToCachedQueries(s.itemType,s.query,a.fitting),a.maybe.length>0){if(o.transaction instanceof h.a)for(var c=0,u=a.maybe;c<u.length;c++){var l=u[c];o.transaction.itemHandler.detectEntryChanges(l.id)&&console.error("!! Trying to re-query 'maybe' matching results but one of the entries has changes, please report this to Martijn !!")}n.push(o.apiRequestService.query(s.itemType,s.query.object,(i={},i[s.itemType]=["id"],i)).then(function(e){void 0!==t&&t._setQueryResult(s.itemType,s.query.string,e.links[s.itemType]),r.transaction.cachedQueryHandler.__addItemEntriesToCachedQueries(s.itemType,s.query,a.maybe.filter(function(t){return e.links[s.itemType].indexOf(t.itemId)>-1}))}).then(function(){},function(){}))}},o=this;for(var s in this.map)i(s);return this.promiseService.all(n)},t.prototype._expand=function(e,t){for(var r=0,n=this.getQueries(e.itemType);r<n.length;r++){var i=n[r],o=i.itemType+"-"+i.query.string;void 0===this.map[o]&&(this.map[o]={itemType:e.itemType,query:i.query,matches:{},cachedQuery:i});var s=this.map[o].matches;void 0===s[e.itemId]&&(s[e.itemId]={item:e,isMatch:t(e.itemType,i.query)})}return this},t}(l.a),p=r(16),m=function(){function e(e,t,r,n){this.queryMatcherFactory=e,this.queryService=t,this.apiRequestService=r,this.promiseService=n}return e.prototype.constructCachedCollectionProcessor=function(e,t){return new p.a(this.apiRequestService,this.promiseService,this.queryService,this.queryMatcherFactory,e,t)},e.prototype.constructCachedQueryProcessor=function(e,t){return new d(this.apiRequestService,this.promiseService,this.queryService,this.queryMatcherFactory,e,t)},e}(),f=function(){function e(e,t,r,n,i,o,s,a,c){this.errorHandler=e,this.exceptionHandler=t,this.keyService=r,this.promiseService=n,this.changesDeltaFactory=i,this.itemEntryService=o,this.collectionEntryFactory=s,this.queryService=a,this.columnSetFactory=c}return e.prototype.construct=function(e,t,r,n){return new s.c(this,new s.b(t),r,e,n)},e}(),y=function(){function e(e){this.columnInfoFactory=e}return e.prototype.construct=function(e,t,r){return new n.n(this.columnInfoFactory,e,t,r)},e}(),v=function(){function e(){}return e.prototype.construct=function(e,t){return new n.p(e,t)},e.prototype.constructFromRootMap=function(e,t){void 0===t&&(t=null);var r=[];for(var n in e){var i=e[n],o=this.construct(i.apiColumn,t),s=this.constructFromRootMap(i.children,o);s.length>0&&o.setChildren(o.apiColumn.itemType,s),r.push(o)}return r},e}(),g=function(){function e(e,t,r){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r}return e.prototype.constructStub=function(e,t){var r=new n.q(this.columnUtil,this,e);return r.request=t,r.requestColumnsTrue=!0===t,r},e.prototype.resolveStub=function(e,t,r,n){return void 0===r&&(r=!0),void 0===n&&(n=!0),e.requestColumnsTrue?this.processResponseColumns(e,t,r):this.processRequestColumns(e,t,r,n)},e.prototype.construct=function(e,t,r,n,i){return this.resolveStub(this.constructStub(e,t),r,n,i)},e.prototype.constructFromResponse=function(e,t,r){void 0===r&&(r=!0);var i=new n.q(this.columnUtil,this,e);return i.requestColumnsTrue=!1,this.processResponseColumns(i,t,r)},e.prototype.processResponseColumns=function(e,t,r){var n=e.itemType,i={};return e.response=t,this.expandRootColumnMapFromResponseColumns(n,t,i,r,{}),this.processColumnInfo(e,this.columnInfoFactory.constructFromRootMap(i),n),e.request=this.constructRequestColumnsFromRootColumnMap(i),e},e.prototype.constructRequestColumnsFromRootColumnMap=function(e){var t,r=[];for(var i in e){var o=e[i];Object(n.cb)(o.children)?r.push(((t={})[i]=this.constructRequestColumnsFromRootColumnMap(o.children),t)):r.push(i)}return r},e.prototype.expandRootColumnMapFromResponseColumns=function(e,t,r,i,o){if(!0!==o[e])for(var s in o[e]=!0,t[e]){var a=t[e][s];if(void 0!==a&&(i&&this.columnHandler.setColumn(e,a),void 0===r[s]&&(r[s]={apiColumn:a,children:{}}),this.columnUtil.isItemColumn(a,!1))){var c=t[a.itemType];void 0!==c&&Object(n.cb)(c)&&this.expandRootColumnMapFromResponseColumns(a.itemType,t,r[s].children,i,o)}}},e.prototype.processRequestColumns=function(e,t,r,n){var i=e.itemType,o={};return this.expandRootColumnMap(e.request,i,t,o,r),n&&this.expandRootColumnMap(["id"],i,t,o,r),e.response={},this.processColumnInfo(e,this.columnInfoFactory.constructFromRootMap(o),i),e},e.prototype.processColumnInfo=function(e,t,r){var n=e.response;void 0===n[r]&&(n[r]={});for(var i=0,o=t;i<o.length;i++){var s=o[i];n[r][s.id]=s.apiColumn,e.groupColumnInfo(s),s.isLeaf||this.processColumnInfo(e,s.children,s.itemType)}},e.prototype.expandRootColumnMap=function(e,t,r,n,i){for(var o=0,s=e;o<s.length;o++){var a=s[o],c=this.columnUtil.parseRequestColumn(a),u=c.id,l=c.children,h=void 0;void 0!==r[t]&&(h=r[t][u]),void 0!==h?(i&&(h=this.columnHandler.setColumn(t,h)),void 0===n[u]&&(n[u]={apiColumn:h,children:{}}),0!==l.length&&this.expandRootColumnMap(l,h.itemType,r,n[u].children,i)):console.warn("No api column for request column",u,"for itemType",t)}},e}(),C=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(e){return new n.r(this.columnUtil,e)},e}(),I=function(){function e(e,t,r){this.apiFormatter=e,this.keyService=t,this.requestColumnExpansionFactory=r}return e.prototype.construct=function(e,t,r){return new n.u(this.apiFormatter,this.keyService,this.requestColumnExpansionFactory,e,t,r)},e}(),b=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e){return new n.x(this.queryMatcherFactory,e)},e}(),S=function(){function e(e,t,r,n,i,o){this.apiFormatter=e,this.columnSetFactory=t,this.exceptionHandler=r,this.itemEntryService=n,this.keyService=i,this.promiseService=o}return e.prototype.construct=function(e,t){return new s.d(this,t.itemType,e,t)},e}(),E=function(){function e(e,t,r,n,i){this.apiFormatter=e,this.errorHandler=t,this.promiseService=r,this.exceptionHandler=n,this.columnUtil=i}return e.prototype.construct=function(e,t,r){return void 0===r&&(r=!1),new s.f(this,e,r,t)},e}(),R=function(){function e(e,t){this.dependencies=e,this.core=t,this.serverCache=new n.J(this.dependencies,this.core)}return e.prototype.getById=function(e){var t=function(r){for(var n=0,i=r;n<i.length;n++){var o=i[n];if(o.id===e)return o;var s=t(o.children);if(void 0!==s)return s}};return t(this.serverCache.children)},e.prototype.construct=function(e,t){return this.serverCache.createChild(e,t)},e.prototype.getServerCache=function(){return this.serverCache},e}(),F=function(){function e(){}return e.prototype.construct=function(e){return new n.C(e)},e}(),q=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e,t,r){return new n.D(this.apiFormatter,e,t,r)},e}(),T=function(){function e(){}return e.prototype.construct=function(e){return new n.E(e)},e}(),H=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(){return new n.I(this.columnUtil)},e}(),w=function(){function e(e,t){this.columnSetFactory=e,this.columnUtil=t}return e.prototype.construct=function(e,t,r,n){return new s.g(this,e,t,r,n)},e}(),k=r(24),M=r(25);r.d(t,"a",function(){return i}),r.d(t,"b",function(){return o}),r.d(t,"e",function(){return c}),r.d(t,"f",function(){return m}),r.d(t,"g",function(){return f}),r.d(t,"h",function(){return y}),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 b}),r.d(t,"n",function(){return S}),r.d(t,"o",function(){return E}),r.d(t,"u",function(){return R}),r.d(t,"p",function(){return F}),r.d(t,"q",function(){return q}),r.d(t,"r",function(){return T}),r.d(t,"s",function(){return H}),r.d(t,"t",function(){return w}),r.d(t,"c",function(){return k.a}),r.d(t,"d",function(){return M.a})},function(e,t,r){"use strict";r.r(t);var n=r(30);r.d(t,"StateKeyType",function(){return n.b}),r.d(t,"ApiLinkTreeType",function(){return n.a});var i=r(31);for(var o in i)["StateKeyType","ApiLinkTreeType","default"].indexOf(o)<0&&function(e){r.d(t,e,function(){return i[e]})}(o)},function(e,t,r){"use strict";var n=r(0),i=r(23),o=r(26),s=r(1),a=function(){function e(e,t,r,n,i,o,s){this.columnUtil=e,this.promiseService=t,this.columnHandler=r,this.templateFactory=n,this.errorHandler=i,this.requestColumnExpansionFactory=o,this.apiRequestService=s,this.pendingTemplateBufferMap={},this.templates={}}return e.prototype.fetchTemplate=function(e,t,r,n,i){var o=this;void 0===r&&(r={}),void 0===n&&(n={}),void 0===i&&(i=null);var a=Object(s.i)(r),c=this.requestColumnExpansionFactory.construct();if(void 0!==n[e]&&c.expandWithRequestColumns(e,n[e]),c.expandWithRequestColumns(e,[{creator:["displayname"]},"created","permissions"]),null!==i&&c.expandWithRequestColumns(e,this.columnUtil.getColumnsFromLink("string"==typeof i?i:i.itemType,e)),n[e]=c.get()[e],!a){var u=this.templates[e];if(void 0!==u&&(null===e||this.columnUtil.responseColumnsAvailable(e,n[e],u.responseColumns)))return this.promiseService.when(u)}return this.promiseService.all({template:this.fetchTemplateById(e,t,r),additionalColumns:void 0===n[e]?{}:this.columnHandler.fetch(e,n[e])}).then(function(t){var r=t.template,i=o.templateFactory.construct(e,r,n,t.additionalColumns);return!a&&r.cacheable&&(o.templates[e]=i),i},this.errorHandler.reject)},e.prototype.fetchTemplateById=function(e,t,r){return void 0===t&&(t="no-id"),void 0===this.pendingTemplateBufferMap[e]||void 0===this.pendingTemplateBufferMap[e][t]?this.constructTemplateBuffer(e,t,r):this.pendingTemplateBufferMap[e][t]},e.prototype.constructTemplateBuffer=function(e,t,r){var n=this;return void 0===this.pendingTemplateBufferMap[e]&&(this.pendingTemplateBufferMap[e]={}),this.pendingTemplateBufferMap[e][t]=this.apiRequestService.template(e,r).then(function(r){return delete n.pendingTemplateBufferMap[e][t],r},function(){return delete n.pendingTemplateBufferMap[e][t],n.errorHandler.reject()})},e}(),c=r(7),u=r(24),l=r(25);r.d(t,"a",function(){return h}),r.d(t,"c",function(){return d}),r.d(t,"b",function(){return p});var h=function(){return function(e,t,r,s,h,p){this.version="6.1.2",this.noop=d;var m=new n.A,f=new n.b,y=new c.q(f),v=new c.r,g=new n.F(m),C=new n.l,I=new n.s(p),b=new c.s(I),S=new n.z(t,p),E=new c.a(f),R=new n.c(e,E),F=new c.f(y,g,R,h),q=new n.m(I),T=new n.o(R,r,h,q,I),H=new c.i,w=new c.h(H),k=new c.j(T,I,H),M=new c.k(I),x=new n.B(R,r,m,h),j=new c.t(k,I),D=new c.m(y),O=new c.o(f,r,h,s,I),Q=new a(I,h,T,j,r,b,R),L=new n.t(m),_=new i.a(k,L,r,m,h,Q),P=new u.a(r,S,_),A=new o.a(h,R,b,m,P),B=new c.n(f,k,s,S,m,h),U=new n.j(v,g),V=new c.e(U,k,m,g,q),N=new c.g(r,s,m,h,P,S,V,g,k),W=new c.l(f,m,b),Y=new c.b,J=new l.a(P,R,Y,w,W,r,h,b,U,S),K=new c.p,z=new c.u({apiFormatter:f,apiRequestService:R,authInterface:t,changesDeltaFactory:P,changesProcessorFactory:J,collectionEntryFactory:V,collectionEntryService:U,collectionMatcherFactory:F,collectionResourceFactory:N,columnCache:q,columnExpansionFactory:w,columnHandler:T,columnSetFactory:k,columnSubsetCacheFactory:M,columnUtil:I,conversionMapService:L,errorHandler:r,exceptionHandler:s,itemCacheFactory:D,itemCreateService:_,itemEntryFactory:B,itemEntryService:S,itemResourceFactory:O,keyService:m,linkTreeService:p,lockService:x,moduleChangesCompilationFactory:K,promiseService:h,queryMatcherFactory:y,queryParserFactory:v,queryService:g,requestBufferManager:A,requestColumnExpansionFactory:b,templateCache:Q},this);A.setServerCache(z.getServerCache());var G=new n.M(A,P,f,r,z,h,b,R,y);this.apiFormatter=f,this.apiRequestService=R,this.apiResponseProcessorFactory=E,this.changesCompilationFactory=Y,this.changesDeltaFactory=P,this.changesProcessorFactory=J,this.collectionEntryFactory=V,this.collectionEntryService=U,this.collectionMatcherFactory=F,this.collectionResourceFactory=N,this.collectionResourceService=C,this.columnCache=q,this.columnExpansionFactory=w,this.columnHandler=T,this.columnInfoFactory=H,this.columnSetFactory=k,this.columnSubsetCacheFactory=M,this.columnUtil=I,this.conversionMapService=L,this.createRequestFactory=W,this.itemCacheFactory=D,this.itemCreateService=_,this.itemEntryFactory=B,this.itemEntryService=S,this.itemResourceFactory=O,this.keyService=m,this.lockService=x,this.moduleChangesCompilationFactory=K,this.queryMatcherFactory=y,this.queryParserFactory=v,this.queryService=g,this.requestColumnExpansionFactory=b,this.socketMessageHandler=G,this.templateCache=Q,this.templateFactory=j,this.transactionCacheFactory=z}}();function d(){}function p(e){return e}},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(0),i=r(9),o=function(){return function(e){this.columns=[],this.query=null,this.queryColumns=[],this.parent=null,this.limit=null,this.onAdd=i.c,this.onRemove=i.c,this.onChange=i.c,this.custom=null,this.callOnAddWithInitialItems=!1,Object(n.eb)(this,e)}}()},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n=function(){function e(e,t,r){this.errorHandler=e,this.exceptionHandler=t,this.promiseService=r,this.callbacks={onBeforeSave:[],onSaveSuccess:[],onSetItemError:[],onClearItemError:[],onSetGlobalError:[],onClearGlobalError:[]}}return e.prototype.registerCallback=function(e,t,r,n,i){var o=this;return void 0===n&&(n="always"),void 0===i&&(i=100),this.getPriorityLevel(e,i)[t]={callback:r,condition:n},function(){delete o.getPriorityLevel(e,i)[t]}},e.prototype.executeCallbacks=function(e,t,r){for(var n=this.callbacks[e],i=r?"onClose":"skipOnClose",o=this.promiseService.when(),s=0,a=n;s<a.length;s++){var c=a[s];o=o.then(this.executeCallbacksPriorityLevel(c[1],i,t),this.errorHandler.reject)}return o},e.prototype.getPriorityLevel=function(e,t){for(var r,n=this.callbacks[e],i=0;i<n.length;i++){var o=n[i];if(!(o[0]<t))return o[0]===t?o[1]:(r={},n.splice(i,0,[t,r]),r)}return r={},n.push([t,r]),r},e.prototype.executeCallbacksPriorityLevel=function(e,t,r){var n=this;return function(){var i={};for(var o in e){var s=e[o];if(s.condition===t||"always"===s.condition)try{i[o]=r(s.callback)}catch(e){n.exceptionHandler(e)}}return n.promiseService.all(i)}},e}()},function(e,t,r){"use strict";r.d(t,"b",function(){return n}),r.d(t,"a",function(){return m});var n,i=r(3),o=r(0),s=r(9),a=r(5),c=r(10),u=r(8),l=r(1),h=r(13),d=r(18),p=r(11);!function(e){e.warning="warning",e.error="error"}(n||(n={}));var m=function(e){function t(t,r,n,i,s){var a=e.call(this,t,r)||this;return a.id=i,a.errors={item:{},global:{}},a.isValid=!0,a.tabRequestParameters={},a.isSaving=!1,a.hasChanges=!1,a.changesInterval=null,a.validator=void 0===s?void 0:s.construct(a),a.parent=n,a.itemHandler=new o.S(t,a,a.validator),a.cachedQueryHandler=new d.a(t,a.itemHandler,a),a.collectionHandler=new o.P(a.itemHandler,a.cachedQueryHandler,a.dependencies,a),a.eventHandler=new p.a(t.errorHandler,t.exceptionHandler,t.promiseService),a}return Object(i.b)(t,e),t.prototype.createChild=function(e,r){var n=new t(this.dependencies,this.core,this,e,r);return this.children.push(n),n},t.prototype.destroy=function(){this.parent.onChildDestroy(this)},t.prototype.expandCollectionResource=function(e,t){var r,n=this,i=null===(r=this.cachedQueryHandler.cachedQueries[e.entry.itemType])||void 0===r?void 0:r[e.entry.query.string];return void 0===i?this.collectionHandler.expandCollectionResource(e,t):this.cachedQueryHandler.__expandCachedQuery(i,t).then(function(){e.entry.columns=n.dependencies.columnSetFactory.construct(i.itemType,i.requestColumns,n.dependencies.columnCache.retrieve(i.itemType,i.requestColumns).cached)},this.dependencies.errorHandler.reject)},t.prototype.expandCollectionResources=function(e,t,r){var n=this;if(!Object(l.i)(t))return this.dependencies.promiseService.when(t);var i=[],o=[];for(var s in t)for(var a=0,c=t[s].items;a<c.length;a++){var u=c[a];u.entry.isLocal()?i.push(u.entry):o.push(u.entry)}return(0===o.length?this.dependencies.columnHandler.fetch(e,r):this.getServerCache().itemHandler.extendItemEntries(e,o,r)).then(function(){if(0===i.length)return n.dependencies.promiseService.when();var t=n.createChangesDelta();return n.itemHandler.expandLocalItemEntries(t,e,i,r,n.dependencies.columnCache.retrieve(e,r).cached).then(function(){return n.applyChangesDelta(t)},n.dependencies.errorHandler.reject)},this.dependencies.errorHandler.reject).then(function(){var i,o=n.dependencies.columnExpansionFactory.construct(e,r,n.dependencies.columnCache.retrieve(e,r).cached);for(var s in t){var a=t[s].entry,c=null===(i=n.cachedQueryHandler.cachedQueries[a.itemType])||void 0===i?void 0:i[a.query.string];void 0!==c&&(c.requestColumns=n.dependencies.columnUtil.mergeRequestColumns(c.requestColumns,r).merged),a.expandColumns(o)}return t},this.dependencies.errorHandler.reject)},t.prototype.registerFieldChangeCallback=function(e,t,r){return this.itemHandler.registerFieldChangeCallback(e,t,r)},t.prototype.createChangesDelta=function(){return this.dependencies.changesDeltaFactory.construct()},t.prototype.getFirstErrorString=function(){for(var e in this.errors.global){if((s=this.errors.global[e]).level===n.error)return s.string}for(var t in this.errors.item){var r=this.errors.item[t];for(var i in r){var o=r[i];for(var e in o){var s;if((s=o[e]).level===n.error)return s.string}}}},t.prototype._setGlobalError=function(e,t,r,n){t?(this.errors.global[e]={string:r(),level:n},this.eventHandler.executeCallbacks("onSetGlobalError",function(t){return t(e,n)},!1),this._setIsValid()):this.clearGlobalError(e)},t.prototype._setItemError=function(e,t,r,n,i,s,a){n?(Object(o.V)(this.errors.item,[e,t,r],[{},{},{fieldString:i(),string:s(),level:a}]),this.eventHandler.executeCallbacks("onSetItemError",function(n){return n(e,t,r)},!1),this._setIsValid()):this.clearItemError(e,t,r)},t.prototype._setIsValid=function(){for(var e in this.isValid=!0,this.errors.global){if(this.errors.global[e].level===n.error)return void(this.isValid=!1)}for(var t in this.errors.item){var r=this.errors.item[t];for(var i in r){var o=r[i];for(var e in o){if(o[e].level===n.error)return void(this.isValid=!1)}}}},t.prototype.applyChangesFromParent=function(e,t,r){var n=this;for(var i in void 0===t&&(t=!1),void 0===r&&(r=!1),e.updated){var o=e.updated[i];this.itemHandler.processItemEntryChanges(o,t,!0,r)}for(var s in e.deleted)for(var a=0,c=e.deleted[s];a<c.length;a++){var u=c[a];if(this.itemHandler.entries.clear(u),delete this.itemHandler.itemChanges[u.id],this.clearItemError(u.id),void 0!==this.itemHandler.deletedItems[u.itemType]){var l=this.itemHandler.deletedItems[u.itemType].indexOf(u);-1!==l&&this.itemHandler.deletedItems[u.itemType].splice(l,1)}}return this.core.collectionMatcherFactory.constructCachedQueryProcessor(this,function(e){return n.cachedQueryHandler.getCachedQueryObjectsByItemType(e)}).processDelta(e).__removeFromAndAddToCachedQueries(r,e).then(function(){return n.core.collectionMatcherFactory.constructCachedCollectionProcessor(n,function(e){return n.collectionHandler.collectionResources[e]}).processDelta(e).__removeFromAndAddToCollections(r,e)}).then(function(){for(var t=0,r=n.children;t<r.length;t++){r[t].applyChangesFromParent(e)}n.hasChanges=!1,n.detectChanges(),void 0!==n.validator&&(n.clearGlobalError(),n.validator.validateTransaction())})},t.prototype.applyChangesDelta=function(t){var r=this;return t.isEmpty()?this.dependencies.promiseService.when({created:[],rollback:s.c}):this.fetchUpdatedDerivedValuesFromDelta(t).then(function(){var n=e.prototype._applyChangesDelta.call(r,t),i=n.result,o=n.internalChangesDelta,s=n.rollbackFunctions;for(var a in t.deleted)for(var c=function(e){r.itemHandler.entries.clear(e);var n=r.itemHandler.itemChanges[e.id];delete t.updated[e.id],delete r.itemHandler.itemChanges[e.id],void 0===r.itemHandler.deletedItems[e.itemType]&&(r.itemHandler.deletedItems[e.itemType]=[]),r.itemHandler.deletedItems[e.itemType].push(e),o.setItemDeleted(e),r.clearItemError(e.id),s.push(function(t){t.setItemUpdated(e,n.changes)})},u=0,l=t.deleted[a];u<l.length;u++){c(l[u])}return r.core.collectionMatcherFactory.constructCachedQueryProcessor(r,function(e){return r.cachedQueryHandler.getCachedQueryObjectsByItemType(e)}).processDelta(o).__removeFromAndAddToCachedQueries(!1,o).then(function(){return r.core.collectionMatcherFactory.constructCachedCollectionProcessor(r,function(e){return r.collectionHandler.collectionResources[e]}).processDelta(o).__removeFromAndAddToCollections(!1,o)}).then(function(){for(var e=0,t=r.children;e<t.length;e++){t[e].applyChangesFromParent(o)}return r.hasChanges=!1,r.detectChanges(),void 0!==r.validator&&r.validator.validateTransaction(),i})})},t.prototype.getServerCache=function(){return this.parent.getServerCache()},t.prototype.getParent=function(e,t,r){var n;if(void 0===t&&(t=!1),void 0!==r)n=r;else{var i=this.itemHandler.itemChanges[e.id];void 0!==i&&(n=i[t?"initial":"changes"])}if(void 0!==n){var o=this.getParentFromFields(e,n);if(null!==o)return o}return this.parent.getParent(e,t)},t.prototype.getCollectionChangesRecursively=function(e,t){var r,n=null===(r=this.cachedQueryHandler.cachedQueries[e])||void 0===r?void 0:r[t.string];if(void 0===n){if(void 0===(n=this.parent.getCollectionChangesRecursively(e,t)))return;this.cachedQueryHandler.setCachedQuery(e,t,n.items.slice(),!0===n.requestColumns||n.requestColumns.slice())}return n},t.prototype.getItemChangesRecursively=function(e,t){void 0===t&&(t=!0);var r=this.itemHandler.itemChanges[e],n=this.getLocalItemEntry(e);return void 0!==r&&void 0!==n?t?this.dependencies.apiFormatter.copyFields(r.changes,{},n.columns.main):r.changes:this.parent.getItemChangesRecursively(e,t)},t.prototype.clearCollectionResource=function(e){return this.collectionHandler.clearResource(e)},t.prototype.isLockable=function(){return void 0!==this.rootItem&&this.rootItem.isLockable()},t.prototype.disableChangesWatcher=function(){null!==this.changesInterval&&(clearInterval(this.changesInterval),this.changesInterval=null)},t.prototype.enableChangesWatcher=function(){var e=this;null!==this.changesInterval&&(console.warn("Changes watcher already running!",this),this.disableChangesWatcher()),this.changesInterval=window.setInterval(function(){e.detectChanges()&&(e.disableChangesWatcher(),e.isLockable()&&e.dependencies.lockService.fetchLock(e.rootItem))},3e3)},t.prototype.save=function(e,t,r,n){var o,s=this;return void 0===e&&(e=!1),void 0===t&&(t={}),this.isSaving?this.dependencies.errorHandler.reject():(this.isSaving=!0,this.detectChanges(),this.disableChangesWatcher(),(this.isLockable()?this.dependencies.lockService.fetchLock(this.rootItem):this.dependencies.promiseService.when()).then(function(){return s.eventHandler.executeCallbacks("onBeforeSave",function(e){return e(s)},e)},this.dependencies.errorHandler.reject).then(function(){return s.tabRequestParameters=Object(i.a)(Object(i.a)({},s.tabRequestParameters),t),s.parent.applyChangesFromChild(s,r,n)}).then(function(t){return o=t,s.tabRequestParameters={},s.isLockable()&&s.dependencies.lockService.clearLock(s.rootItem),s.hasChanges=!1,s.eventHandler.executeCallbacks("onSaveSuccess",function(e){return e(s,o)},e)},this.dependencies.errorHandler.reject).then(function(){return e||s.enableChangesWatcher(),s.isSaving=!1,o},this.dependencies.errorHandler.reject).catch(function(e){return s.isSaving=!1,s.dependencies.errorHandler.reject(e)}))},t.prototype.detectChanges=function(){return!!this.hasChanges||(this.itemHandler.detectChanges()?this.hasChanges=!0:this.hasChanges=!1)},t.prototype.clearItem=function(e){this.clearItemEntry(e.entry)},t.prototype.clearItemEntry=function(e){return this.itemHandler.clearItemEntry(e)},t.prototype.onBeforeSave=function(e,t,r,n){return this.eventHandler.registerCallback("onBeforeSave",e,t,r,n)},t.prototype.onSaveSuccess=function(e,t,r,n){return this.eventHandler.registerCallback("onSaveSuccess",e,t,r,n)},t.prototype.getModuleChanges=function(){if(void 0===this.rootItem)throw new Error("No root item for transaction cache "+this);return this.dependencies.moduleChangesCompilationFactory.construct(this).process()},t.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])}},t.prototype.getAllLinkCollections=function(e,t,r){var n,i=this;return this.dependencies.apiRequestService.query(e,{},(n={},n[e]=["id"],n)).then(function(n){return i.getLinkCollections(e,n.links[e],t,r)},this.dependencies.errorHandler.reject)},t.prototype.getLinkCollectionsFromDef=function(e,t,r){var n=this;return this.cachedQueryHandler.__fetchLinkedCachedQueryItems(e,t,r.itemType,r.options).then(function(t){var i={};for(var o in t){var s=t[o],a=n.core.collectionEntryService.cloneOptions(r.options,{itemType:e,itemId:Number(o)});a.columns=s.requestColumns,i[o]=n.createCollectionResource(r.itemType,a,s.items)}return i},this.dependencies.errorHandler.reject)},t.prototype.getLinkCollections=function(e,t,r,n){var i=this,o=new c.a(n);return this.cachedQueryHandler.__fetchLinkedCachedQueryItems(e,t,r,o).then(function(t){var n={};for(var s in t){var a=t[s],c=i.core.collectionEntryService.cloneOptions(o,{itemType:e,itemId:Number(s)});c.columns=a.requestColumns,n[s]=i.createCollectionResource(r,c,a.items)}return n},this.dependencies.errorHandler.reject)},t.prototype.getCollectionFromDef=function(e){var t=this;return this.cachedQueryHandler.__fetchCachedQueryItem(e.itemType,e.options).then(function(r){return t.createCollectionResource(e.itemType,e.options,r.items)},this.dependencies.errorHandler.reject)},t.prototype.getCollection=function(e,t){var r=this;return this.cachedQueryHandler.__fetchCachedQueryItem(e,new c.a(t)).then(function(n){return r.createCollectionResource(e,t,n.items)},this.dependencies.errorHandler.reject)},t.prototype.getCollectionDef=function(e,t){return{itemType:e,options:new c.a(t)}},t.prototype.getLinkCollectionsDef=function(e,t,r){return{itemType:e,linkField:t,options:new c.a(r)}},t.prototype.getItemByState=function(e,t,r,n){void 0===r&&(r={});var i=this.dependencies.keyService.parseStateKey(t);if(null===i){var o=t;if(!this.dependencies.keyService.isLocalId(o)||void 0!==this.getLocalItemEntryByItemId(e,o))return this.getItemById(e,o,r,n)}else if(i.type===u.StateKeyType.Duplicate)return this.getDuplicateById(e,i.itemId,r,!1,n);return this.getNewResource(e,r,!1,n)},t.prototype.getDuplicateById=function(e,t,r,n,i){return void 0===r&&(r={}),void 0===r.templateOptions&&(r.templateOptions={}),void 0===r.templateOptions.item&&(r.templateOptions.item=t),this.getNewResourceWithId(e,this.dependencies.keyService.getLocalDuplicateId(),r,n,i)},t.prototype.getNewResourceWithId=function(e,t,r,n,i){var o=this;return void 0===n&&(n=!1),this.itemHandler.fetchNewItemEntry(e,t,new a.e(r)).then(function(r){for(var s,a={},c=0,u=r.created;c<u.length;c++){var l=u[c];l.itemType!==e||l.itemId!==t?(void 0===a[l.itemType]&&(a[l.itemType]=[]),a[l.itemType].push(l)):s=l}if(void 0===s)throw new Error("The ItemEntry with the requested ItemId was not in the template response");var h=o.createItemResource(s,i,!0);return n?{main:h,linked:o.processLinkedItems(a)}:h},this.dependencies.errorHandler.reject)},t.prototype.getNewResource=function(e,t,r,n){return void 0===t&&(t={}),this.getNewResourceWithId(e,this.dependencies.keyService.getLocalId(),t,r,n)},t.prototype.getItemsByQuery=function(e,t,r){var n=this;return void 0===r&&(r={}),this.cachedQueryHandler.__fetchCachedQueryItem(e,new c.a({query:t,parent:r.parent,columns:r.columns})).then(function(e){return n.createItemResources(e.items)},this.dependencies.errorHandler.reject)},t.prototype.getItemsById=function(e,t,r){var n=this;return void 0===r&&(r={}),this.itemHandler.fetchItemEntries(e,t,new a.e(r)).then(function(e){return n.createItemResources(e)},this.dependencies.errorHandler.reject)},t.prototype.getItemById=function(e,t,r,n){var i=this;return void 0===r&&(r={}),this.itemHandler.fetchItemEntry(e,t,new a.e(r)).then(function(e){return i.createItemResource(e,n)},this.dependencies.errorHandler.reject)},t.prototype.fetchTitle=function(e,t){return this.itemHandler.fetchTitle(e,t)},t.prototype.applyChangesFromChild=function(e,t,r){var n=this,i=this.dependencies.linkTreeService.get(),o=e.getDelta();for(var s in o.moved){var a=o.moved[s];o.setItemUpdated(a.entry,{},null,a.to),delete o.moved[s]}for(var s in o.updated){a=o.updated[s];void 0===this.itemHandler.itemChanges[s]?this.itemHandler.itemChanges[s]=this.itemHandler.copyTransactionItemEntryChanges(e.itemHandler.itemChanges[s],a.entry):this.itemHandler.processItemEntryChanges(a,!0)}for(var s in o.created){a=o.created[s];this.itemHandler.entries.add(a.entry),e.itemHandler.entries.clear(a.entry);var c=this.itemHandler.itemChanges[a.entry.id]=this.itemHandler.copyTransactionItemEntryChanges(e.itemHandler.itemChanges[s],a.entry),l=this.dependencies.itemEntryService.getDisplayName(a.entry,c.changes);if(void 0!==l&&(c.changes.displayname=l),void 0!==this.rootItem){var h=i[this.rootItem.itemType][a.entry.itemType];void 0!==h&&(h.type===u.ApiLinkTreeType.ITEMTABLE?(c.changes.itemtype=this.rootItem.itemType,c.changes.item=this.rootItem.itemId):h.type===u.ApiLinkTreeType.DIRECT&&(c.changes[h.field]=this.rootItem.itemId))}}for(var d in o.deleted){void 0===this.itemHandler.deletedItems[d]&&(this.itemHandler.deletedItems[d]=[]);for(var p=0,m=o.deleted[d];p<m.length;p++){var f=m[p];f.isLocal()||(this.itemHandler.entries.clear(f),this.itemHandler.deletedItems[d].push(f),this.clearItemError(f.id))}}return this.hasChanges=!0,this.expandItemsFromDelta(o).then(function(){return n.core.collectionMatcherFactory.constructCachedQueryProcessor(n,function(e){return n.cachedQueryHandler.getCachedQueryObjectsByItemType(e)}).processDelta(o).__removeFromAndAddToCachedQueries(!1,o)}).then(function(){return n.core.collectionMatcherFactory.constructCachedCollectionProcessor(n,function(e){return n.collectionHandler.collectionResources[e]}).processDelta(o).__removeFromAndAddToCollections(!1,o)}).then(function(){for(var t=0,r=n.children;t<r.length;t++){var i=r[t];i!==e&&i.applyChangesFromParent(o)}return void 0!==n.validator&&n.validator.validateTransaction(),o.itemIdConversionMap})},t.prototype.getLocalItemEntryChangesTuple=function(e){var t=this.getLocalItemEntry(e);if(void 0===t)throw new Error("Tried to get a local ItemEntry with entryId '"+e+"' but couldn't find it");return{entry:t,changes:this.itemHandler.itemChanges[e]}},t.prototype.getLocalItemEntry=function(e){var t=this.itemHandler.entries.getByEntryId(e);return void 0!==t?t:this.parent.getLocalItemEntry(e)},t.prototype.getLocalItemEntryByItemId=function(e,t){var r=this.itemHandler.entries.get(e,t);return void 0!==r?r:this.parent.getLocalItemEntryByItemId(e,t)},t.prototype.getDelta=function(){var e=this.dependencies.changesDeltaFactory.constructInternalDelta();for(var t in this.itemHandler.itemChanges){var r=this.getLocalItemEntryChangesTuple(Number(t));if(this.itemHandler.entries.contains(r.entry.itemType,r.entry.itemId)&&r.entry.isLocal())r.entry.itemId=r.changes.changes.id,e.setItemCreated(r.entry,r.changes.changes);else{var n=this.getParent(r.entry);if(null!==n){var i=this.getParent(r.entry,!0);this.dependencies.itemEntryService.matchParent(i,n)||e.setItemMoved(r.entry,n)}this.dependencies.apiFormatter.hasChanges(r.changes.initial,r.changes.changes,r.entry.columns.main)&&e.setItemUpdated(r.entry,r.changes.changes)}}for(var o in this.itemHandler.deletedItems)e.setItemsDeleted(this.itemHandler.deletedItems[o]);return e},t.prototype.createItemResource=function(e,t,r){return void 0===t&&(t=!1),t&&(this.rootItem=e),void 0===this.itemHandler.itemChanges[e.id]&&(this.itemHandler.itemChanges[e.id]={initial:this.getItemChangesRecursively(e.id),changes:this.getItemChangesRecursively(e.id)}),this.dependencies.itemResourceFactory.construct(e,this,r)},t.prototype.createItemResources=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];void 0===this.itemHandler.itemChanges[i.id]&&(this.itemHandler.itemChanges[i.id]={initial:this.getItemChangesRecursively(i.id,!0),changes:this.getItemChangesRecursively(i.id,!0)});var o=this.dependencies.itemResourceFactory.construct(i,this);t.push(o)}return t},t.prototype.processLinkedItems=function(e){var t={};for(var r in e)t[r]=this.createItemResources(e[r]);return t},t.prototype.createCollectionResource=function(e,t,r){var n=this.dependencies.collectionResourceFactory.construct(e,t,this,r);return this.collectionHandler.addResource(n),n},t.prototype.getChangesFromItemChanges=function(e){return e.changes},t.prototype.expandItemsFromDelta=function(e){var t={},r={},n=function(e){void 0===t[e.itemType]&&(t[e.itemType]=[]),t[e.itemType].push(e)};for(var i in e.created)n(e.created[i].entry);for(var i in e.updated)n(e.updated[i].entry);for(var o in t){var s=this.cachedQueryHandler.cachedQueries[o];if(void 0!==s){var a=this.dependencies.requestColumnExpansionFactory.construct();for(var c in s){var u=s[c];a.expandWithRequestColumns(u.itemType,u.requestColumns)}r[o]=a.get()[o]}}var l=[];for(var o in r)l.push(this.itemHandler.expandLocalItemEntries(e,o,t[o],r[o],this.dependencies.columnCache.retrieve(o,r[o]).cached));return this.dependencies.promiseService.all(l)},t.prototype.clearGlobalError=function(e){var t=this,r=function(e){t.eventHandler.executeCallbacks("onClearGlobalError",function(t){return t(e)},!1)};if(void 0===e){for(var n in this.errors.global)r(n);this.errors.global={}}else r(e),delete this.errors.global[e];this._setIsValid()},t.prototype.clearItemError=function(e,t,r){var n,i,o=this,s=function(e,t,r){var n,i;o.eventHandler.executeCallbacks("onClearItemError",function(n){return n(e,t,r)},!1),void 0!==(null===(i=null===(n=o.errors.item[e])||void 0===n?void 0:n[t])||void 0===i?void 0:i[r])&&delete o.errors.item[e][t][r]};if(void 0===e){for(var a in this.errors.item){var c=this.errors.item[a];for(var u in c){var h=c[u];for(var d in h)s(Number(a),u,d)}}return this.errors.item={},void this._setIsValid()}if(void 0===t){c=this.errors.item[e];for(var u in c){h=c[u];for(var d in h)s(Number(e),u,d)}return delete this.errors.item[e],void this._setIsValid()}if(void 0!==this.errors.item[e]){if(void 0===r){h=this.errors.item[e][t];for(var d in h)s(Number(e),t,d);return delete this.errors.item[e][t],Object(l.i)(this.errors.item[e])||this.clearItemError(e),void this._setIsValid()}s(e,t,r),void 0!==(null===(i=null===(n=this.errors.item[e])||void 0===n?void 0:n[t])||void 0===i?void 0:i[r])&&delete this.errors.item[e][t][r],Object(l.i)(this.errors.item[e][t])||this.clearItemError(e,t),this._setIsValid()}else this._setIsValid()},t}(h.a)},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=r(17),i=function(){function e(e,t){this.dependencies=e,this.core=t,this.children=[]}return e.prototype.onChildDestroy=function(e){var t=this.children.indexOf(e);-1!==t&&this.children.splice(t,1)},e.prototype.getTransactionChain=function(){var e=[],t=this;do{e.push(t),t=t.parent}while(null!==t);return e},e.prototype.getCurrentItemEntryCache=function(){return this.itemHandler.entries},e.prototype.getParentFromFields=function(e,t){if(void 0===t)return null;if(null!==e.columns.link)return{itemType:e.columns.link.apiColumn.itemType,itemId:t[e.columns.link.id]};var r=e.columns.response[e.itemType];return void 0!==r.itemtype&&void 0!==r.item?{itemType:t.itemtype,itemId:t.item}:null},e.prototype._applyChangesDelta=function(e){var t=this,r=this.dependencies.changesDeltaFactory.constructInternalDelta();for(var i in e._queryResults)for(var o in e._queryResults[i])r._setQueryResult(i,o,e._queryResults[i][o]);var s=[],a=[];e.created.forEach(function(e){var n=t.itemHandler.createItemEntry(e);s.push(n),r.setItemCreated(n,t.getChangesFromItemChanges(t.itemHandler.itemChanges[n.id])),a.push(function(e){return e.setItemDeleted(n)})});var c=function(t){var i=e.updated[t],o=u.itemHandler.processItemEntryChanges(i,!0,!1,!1,!0);if(r.setItemUpdated(i.entry,i.changes.fields,i.changes.expandedColumns),null!==o&&a.push(function(e){return e.setItemUpdated(i.entry,o)}),null!==i.changes.parent&&r.setItemMoved(i.entry,i.changes.parent),u.itemHandler instanceof n.a){var s=u.itemHandler.deletedItems[i.entry.itemType];if(void 0===s)return"continue";var c=s.indexOf(i.entry);c>-1&&s.splice(c,1)}},u=this;for(var l in e.updated)c(l);return{result:{created:s,rollback:function(){for(var e=t.dependencies.changesDeltaFactory.construct(),r=0,n=a;r<n.length;r++){(0,n[r])(e)}return t.applyChangesDelta(e)}},internalChangesDelta:r,rollbackFunctions:a}},e.prototype.fetchUpdatedDerivedValuesFromDelta=function(e){var t=[];for(var r in e.updated){for(var n=e.updated[r],i=[],o=0,s=n.entry.columns.root;o<s.length;o++){var a=s[o];n.changes.fields.hasOwnProperty(a.id)&&n.changes.fields[a.id]!==this.getChangesFromItemChanges(this.itemHandler.itemChanges[n.entry.id])[a.id]&&i.push(a)}0!==i.length&&t.push(this.itemHandler.resolveDerivedValues([n.entry],i,e))}return this.dependencies.promiseService.all(t)},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=r(1),i=function(){function e(e){this.itemEntryService=e,this.updated={},this.deleted={},this._queryResults={}}return e.prototype._setQueryResult=function(e,t,r){void 0===this._queryResults[e]&&(this._queryResults[e]={}),this._queryResults[e][t]=r},e.prototype.setItemUpdated=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null),void 0===this.updated[e.id]&&(this.updated[e.id]={entry:e,changes:{fields:{},expandedColumns:null,parent:n}});var i=this.updated[e.id];if(null!==n){var o=this.itemEntryService.getLinkFieldsByParent(n,e.itemType);for(var s in o)t[s]=o[s]}for(var a in t){var c=Object.getOwnPropertyDescriptor(t,a);void 0!==c?Object.defineProperty(i.changes.fields,a,c):i.changes.fields[a]=t[a]}return null!==r&&(i.changes.expandedColumns=r),this},e.prototype.setItemDeleted=function(e){return this.setItemsDeleted([e])},e.prototype.setItemsDeleted=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];void 0===this.deleted[n.itemType]&&(this.deleted[n.itemType]=[]),this.deleted[n.itemType].indexOf(n)>-1||this.deleted[n.itemType].push(n)}return this},e.prototype.isEmpty=function(){return!Object(n.i)(this.updated)&&!Object(n.i)(this.deleted)},e}()},function(e,t,r){"use strict";r.r(t);var n=r(9);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(4);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.g}),r.d(t,"NEW_PREFIX",function(){return i.f}),r.d(t,"DUPLICATE_PREFIX",function(){return i.d}),r.d(t,"NEW_KEYWORD",function(){return i.e}),r.d(t,"DUPLICATE_KEYWORD",function(){return i.c});var o=r(5);r.d(t,"ItemEntryOptions",function(){return o.e}),r.d(t,"ItemEntry",function(){return o.d}),r.d(t,"ItemResource",function(){return o.f}),r.d(t,"CollectionOptions",function(){return o.b}),r.d(t,"CollectionEntry",function(){return o.a}),r.d(t,"CollectionResource",function(){return o.c}),r.d(t,"Template",function(){return o.g});var s=r(32);for(var a in s)["RmCore","noop","identity","ALL_PERMISSIONS","COLUMN_SEPERATOR","RENDER_AS_SEPERATOR","NEW_PREFIX","DUPLICATE_PREFIX","NEW_KEYWORD","DUPLICATE_KEYWORD","ItemEntryOptions","ItemEntry","ItemResource","CollectionOptions","CollectionEntry","CollectionResource","Template","default"].indexOf(a)<0&&function(e){r.d(t,e,function(){return s[e]})}(a);var c=r(0);r.d(t,"ApiFormatter",function(){return c.b}),r.d(t,"ApiRequestService",function(){return c.c}),r.d(t,"ApiResponseProcessor",function(){return c.d}),r.d(t,"ChangesCompilation",function(){return c.f}),r.d(t,"ChangesProcessor",function(){return c.i}),r.d(t,"CollectionEntryService",function(){return c.j}),r.d(t,"CollectionMatcherCachedCollectionProcessor",function(){return c.k}),r.d(t,"CollectionResourceService",function(){return c.l}),r.d(t,"ColumnCache",function(){return c.m}),r.d(t,"ColumnExpansion",function(){return c.n}),r.d(t,"ColumnHandler",function(){return c.o}),r.d(t,"ColumnInfo",function(){return c.p}),r.d(t,"ColumnSet",function(){return c.q}),r.d(t,"ColumnSubsetCache",function(){return c.r}),r.d(t,"ColumnUtil",function(){return c.s}),r.d(t,"ConversionMapService",function(){return c.t}),r.d(t,"CreateRequest",function(){return c.u}),r.d(t,"ItemCache",function(){return c.x}),r.d(t,"ItemEntryService",function(){return c.z}),r.d(t,"KeyService",function(){return c.A}),r.d(t,"TransactionEventHandler",function(){return c.R}),r.d(t,"LockService",function(){return c.B}),r.d(t,"ModuleChangesCompilation",function(){return c.C}),r.d(t,"QueryMatcher",function(){return c.D}),r.d(t,"CONSTANTS",function(){return c.e}),r.d(t,"QueryParser",function(){return c.E}),r.d(t,"QueryService",function(){return c.F}),r.d(t,"RequestColumnExpansion",function(){return c.I}),r.d(t,"SocketMessageHandler",function(){return c.M}),r.d(t,"instantiateOptions",function(){return c.eb}),r.d(t,"shallowMerge",function(){return c.ub}),r.d(t,"hasProperties",function(){return c.cb}),r.d(t,"getFirstProperty",function(){return c.ab}),r.d(t,"inArray",function(){return c.db}),r.d(t,"filterArray",function(){return c.Z}),r.d(t,"emptyArray",function(){return c.W}),r.d(t,"pathExists",function(){return c.tb}),r.d(t,"createPath",function(){return c.V}),r.d(t,"getPath",function(){return c.bb}),r.d(t,"extend",function(){return c.Y}),r.d(t,"merge",function(){return c.sb}),r.d(t,"isObject",function(){return c.nb}),r.d(t,"isBlankObject",function(){return c.gb}),r.d(t,"isString",function(){return c.qb}),r.d(t,"isNumber",function(){return c.mb}),r.d(t,"isDate",function(){return c.ib}),r.d(t,"isArray",function(){return c.fb}),r.d(t,"isFunction",function(){return c.lb}),r.d(t,"isPromiseLike",function(){return c.ob}),r.d(t,"isRegExp",function(){return c.pb}),r.d(t,"isBoolean",function(){return c.hb}),r.d(t,"isElement",function(){return c.kb}),r.d(t,"isWindow",function(){return c.rb}),r.d(t,"isDefined",function(){return c.jb}),r.d(t,"equals",function(){return c.X}),r.d(t,"copy",function(){return c.U}),r.d(t,"AbstractCache",function(){return c.a}),r.d(t,"ServerCache",function(){return c.J}),r.d(t,"ServerItemHandler",function(){return c.L}),r.d(t,"ServerCachedQueryHandler",function(){return c.K}),r.d(t,"TransactionErrorLevel",function(){return c.Q}),r.d(t,"TransactionCache",function(){return c.N}),r.d(t,"TransactionItemHandler",function(){return c.S}),r.d(t,"TransactionCachedQueryHandler",function(){return c.O}),r.d(t,"TransactionCollectionHandler",function(){return c.P}),r.d(t,"TransactionValidator",function(){return c.T}),r.d(t,"ChangesDeltaBase",function(){return c.h}),r.d(t,"ChangesDelta",function(){return c.g}),r.d(t,"InternalChangesDelta",function(){return c.w}),r.d(t,"RequestBufferManager",function(){return c.H}),r.d(t,"RequestBuffer",function(){return c.G}),r.d(t,"ItemCreateService",function(){return c.y}),r.d(t,"CreatedChangesDelta",function(){return c.v});var u=r(7);r.d(t,"ApiResponseProcessorFactory",function(){return u.a}),r.d(t,"ChangesCompilationFactory",function(){return u.b}),r.d(t,"CollectionEntryFactory",function(){return u.e}),r.d(t,"CollectionMatcherFactory",function(){return u.f}),r.d(t,"CollectionResourceFactory",function(){return u.g}),r.d(t,"ColumnExpansionFactory",function(){return u.h}),r.d(t,"ColumnInfoFactory",function(){return u.i}),r.d(t,"ColumnSetFactory",function(){return u.j}),r.d(t,"ColumnSubsetCacheFactory",function(){return u.k}),r.d(t,"CreateRequestFactory",function(){return u.l}),r.d(t,"ItemCacheFactory",function(){return u.m}),r.d(t,"ItemEntryFactory",function(){return u.n}),r.d(t,"ItemResourceFactory",function(){return u.o}),r.d(t,"TransactionCacheFactory",function(){return u.u}),r.d(t,"ModuleChangesCompilationFactory",function(){return u.p}),r.d(t,"QueryMatcherFactory",function(){return u.q}),r.d(t,"QueryParserFactory",function(){return u.r}),r.d(t,"RequestColumnExpansionFactory",function(){return u.s}),r.d(t,"TemplateFactory",function(){return u.t}),r.d(t,"ChangesDeltaFactory",function(){return u.c}),r.d(t,"ChangesProcessorFactory",function(){return u.d});var l=r(8);for(var a in l)["RmCore","noop","identity","ALL_PERMISSIONS","COLUMN_SEPERATOR","RENDER_AS_SEPERATOR","NEW_PREFIX","DUPLICATE_PREFIX","NEW_KEYWORD","DUPLICATE_KEYWORD","ItemEntryOptions","ItemEntry","ItemResource","CollectionOptions","CollectionEntry","CollectionResource","Template","ApiFormatter","ApiRequestService","ApiResponseProcessor","ChangesCompilation","ChangesProcessor","CollectionEntryService","CollectionMatcherCachedCollectionProcessor","CollectionResourceService","ColumnCache","ColumnExpansion","ColumnHandler","ColumnInfo","ColumnSet","ColumnSubsetCache","ColumnUtil","ConversionMapService","CreateRequest","ItemCache","ItemEntryService","KeyService","TransactionEventHandler","LockService","ModuleChangesCompilation","QueryMatcher","CONSTANTS","QueryParser","QueryService","RequestColumnExpansion","SocketMessageHandler","instantiateOptions","shallowMerge","hasProperties","getFirstProperty","inArray","filterArray","emptyArray","pathExists","createPath","getPath","extend","merge","isObject","isBlankObject","isString","isNumber","isDate","isArray","isFunction","isPromiseLike","isRegExp","isBoolean","isElement","isWindow","isDefined","equals","copy","AbstractCache","ServerCache","ServerItemHandler","ServerCachedQueryHandler","TransactionErrorLevel","TransactionCache","TransactionItemHandler","TransactionCachedQueryHandler","TransactionCollectionHandler","TransactionValidator","ChangesDeltaBase","ChangesDelta","InternalChangesDelta","RequestBufferManager","RequestBuffer","ItemCreateService","CreatedChangesDelta","ApiResponseProcessorFactory","ChangesCompilationFactory","CollectionEntryFactory","CollectionMatcherFactory","CollectionResourceFactory","ColumnExpansionFactory","ColumnInfoFactory","ColumnSetFactory","ColumnSubsetCacheFactory","CreateRequestFactory","ItemCacheFactory","ItemEntryFactory","ItemResourceFactory","TransactionCacheFactory","ModuleChangesCompilationFactory","QueryMatcherFactory","QueryParserFactory","RequestColumnExpansionFactory","TemplateFactory","ChangesDeltaFactory","ChangesProcessorFactory","default"].indexOf(a)<0&&function(e){r.d(t,e,function(){return l[e]})}(a)},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(3),i=r(12),o=function(e){function t(t,r,n,i,o,s){var a=e.call(this,n,i,o)||this;return a.apiRequestService=t,a.promiseService=r,a.getCollections=s,a.map={},a}return Object(n.b)(t,e),t.prototype.__removeFromAndAddToCollections=function(e,t){void 0===e&&(e=!1);var r=[],n=function(n){var s,a=o.map[n],c=o.groupItemEntries(a.matches);if(a.collectionResources.forEach(function(t){return t.removeItemResources(c.notFitting,e)}),a.collectionResources.forEach(function(t){return t.addItemResources(c.fitting,!1,e)}),c.maybe.length>0){if(o.transaction instanceof i.a)for(var u=0,l=c.maybe;u<l.length;u++){var h=l[u];o.transaction.itemHandler.detectEntryChanges(h.id)&&console.error("!! Trying to re-query 'maybe' matching results but one of the entries has changes, please report this to Martijn !!")}r.push(o.apiRequestService.query(a.itemType,a.query.object,(s={},s[a.itemType]=["id"],s)).then(function(e){void 0!==t&&t._setQueryResult(a.itemType,a.query.string,e.links[a.itemType]),a.collectionResources.forEach(function(t){return t.addItemResources(c.maybe.filter(function(t){return e.links[a.itemType].indexOf(t.itemId)>-1}))})}).then(function(){},function(){}))}},o=this;for(var s in this.map)n(s);return this.promiseService.all(r)},t.prototype._expand=function(e,t){var r=this.getCollections(e.itemType);for(var n in r){var i=r[n];if(0!==i.length){var o=i[0],s=o.entry.query,a=o.entry.itemType+"-"+n;void 0===this.map[a]&&(this.map[a]={itemType:e.itemType,query:o.entry.query,collectionResources:r[n],matches:{}});var c=this.map[a].matches;void 0===c[e.itemId]&&(c[e.itemId]={item:e,isMatch:t(e.itemType,s)})}}return this},t}(r(28).a)},function(e,t,r){"use strict";r.d(t,"a",function(){return s});var n=r(3),i=r(5),o=r(0),s=function(e){function t(t,r,n){var i=e.call(this,t.columnUtil,t.apiFormatter,t.itemEntryFactory,t.promiseService,t.errorHandler,t.requestColumnExpansionFactory,t.itemCacheFactory,r)||this;return i.dependencies=t,i.transaction=r,i.validator=n,i.deletedItems={},i.itemChanges={},i.fieldChangeCallbacks={},i}return Object(n.b)(t,e),t.prototype.registerFieldChangeCallback=function(e,t,r){Object(o.V)(this.fieldChangeCallbacks,[e,t],[{},[]]);var n=this.fieldChangeCallbacks[e][t];return n.push(r),function(){var e=n.indexOf(r);-1!==e&&n.splice(e,1)}},t.prototype.copyTransactionItemEntryChanges=function(e,t){return{initial:this.apiFormatter.copyFields(e.initial,{},t.columns.main),changes:this.apiFormatter.copyFields(e.changes,{},t.columns.main)}},t.prototype.createItemEntry=function(t){var r=e.prototype.createItemEntry.call(this,t),n=this.dependencies.itemEntryService.getLocalDefaultValues();for(var i in n)t.fields[i]=n[i];var o=this.apiFormatter.copyFields(t.fields,{},t.columns.main);return this.itemChanges[r.id]={initial:t.fields,changes:o},this.itemChanges[r.id].initial.id=r.itemId,this.itemChanges[r.id].changes.id=r.itemId,void 0!==this.validator&&this.validator.validateItem(r,t.fields,t.fields),r},t.prototype.formatRequest=function(e){var t=e.columns.main;return e.isLocal()?this.apiFormatter.formatRequestLocal(this.itemChanges[e.id].changes,t):this.apiFormatter.formatRequest(this.itemChanges[e.id].initial,this.itemChanges[e.id].changes,t)},t.prototype.detectChanges=function(){for(var e in this.entries.entriesByEntryId)return!0;for(var t in this.deletedItems)if(this.deletedItems[t].length>0)return!0;for(var r in this.itemChanges){if(this.detectEntryChanges(Number(r)))return!0}return!1},t.prototype.detectEntryChanges=function(e){var t=this.transaction.getLocalItemEntry(e),r=this.itemChanges[e];return void 0!==r&&this.apiFormatter.hasChanges(r.initial,r.changes,t.columns.main)},t.prototype.processItemEntryChanges=function(e,t,r,n,i){var o,s=this;void 0===t&&(t=!1),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=!1);var a=e.entry,c=e.changes;if(void 0===this.itemChanges[a.id]){if(!i)return null;this.itemChanges[a.id]={initial:this.transaction.getItemChangesRecursively(a.id),changes:this.transaction.getItemChangesRecursively(a.id)}}null!==c.expandedColumns&&(a.columns=c.expandedColumns.merged);var u=this.itemChanges[a.id],l=this.apiFormatter.copyFields(u.changes,{},a.columns.main),h=this.apiFormatter.hasChanges(c.fields,u.changes,a.columns.main,!0);if(t?this.apiFormatter.copyFields(c.fields,u.changes,a.columns.main):this.apiFormatter.mergeCopyFields(u.initial,u.changes,c.fields,a.columns.main),r&&this.apiFormatter.copyFields(c.fields,u.initial,a.columns.main),void 0===c.fields.displayname){var d=this.dependencies.itemEntryService.getDisplayName(a,u.changes);void 0!==d&&(u.changes.displayname=d)}if(h){void 0!==this.validator&&this.validator.validateItem(a,u.changes,l);var p=null===(o=this.fieldChangeCallbacks[a.itemType])||void 0===o?void 0:o[a.itemId];if(void 0!==p)for(var m=0,f=p;m<f.length;m++){var y=f[m];try{y({itemEntry:a,compareField:function(e){return s.apiFormatter.compareFields(a.columns.response[a.itemType][e].type,u.changes[e],l[e])},fields:u.changes,isCalledAfterSocketUpdate:n,previous:l})}catch(e){this.dependencies.exceptionHandler(e)}}}return l},t.prototype.cloneItemEntries=function(e,t,r,n){void 0===r&&(r={}),this.dependencies.conversionMapService.batchExpandConversionMap(t,r);for(var i=0,o=t;i<o.length;i++){var s=o[i];this.cloneItemEntry(e,s,r,n)}return[]},t.prototype.cloneItemEntry=function(e,t,r,n){void 0===r&&(r={});var i=this.transaction.getItemChangesRecursively(t.id),o=this.dependencies.conversionMapService.expandConversionMap(t,r),s=this.apiFormatter.copyFields(i,{},t.columns.main);return this.dependencies.conversionMapService.updateItemValues(s,s,t.columns.item,r),void 0!==n&&n(t.itemType,s),e._setItemCreated(o,s,t.columns),o},t.prototype.fetchItemEntriesByQuery=function(e,t,r){return this.transaction.getServerCache().itemHandler.fetchItemEntriesByQuery(e,t,r)},t.prototype.fetchItemEntry=function(e,t,r){var n=this;if(!this.dependencies.keyService.isLocalId(t))return this.transaction.getServerCache().itemHandler.fetchItemEntry(e,t,r);if(void 0===this.entries.get(e,t))return this.transaction.parent instanceof o.J?this.errorHandler.reject(this.dependencies.itemEntryService.createUnfoundLocalItemError(e)):this.transaction.parent.itemHandler.fetchItemEntry(e,t,r);r.columns=this.expandColumnsWithCachedQueryColumns(e,r.columns);var i=this.dependencies.changesDeltaFactory.construct(),s=this.dependencies.columnSubsetCacheFactory.construct(r.columns);return this.fetchLocalItemEntryData(i,e,t,s,r).then(function(e){return n.transaction.applyChangesDelta(i).then(function(){return e},n.errorHandler.reject)},this.errorHandler.reject)},t.prototype.fetchNewItemEntry=function(e,t,r){var n,i,o=this;return void 0!==this.entries.get(e,t)?this.errorHandler.reject(this.dependencies.itemEntryService.createExistingLocalItemError(e)):this.dependencies.templateCache.fetchTemplate(e,t,r.templateOptions,(n={},n[e]=r.columns,n),r.parent).then(function(n){if(void 0!==o.entries.get(e,t))return o.errorHandler.reject(o.dependencies.itemEntryService.createExistingLocalItemError(e));var i=o.dependencies.changesDeltaFactory.construct();return o.dependencies.itemCreateService.processTemplate(i,e,t,r.parent,n),o.transaction.applyChangesDelta(i)},this.errorHandler.reject).then(function(e){var t=(i=e).created.reduce(function(e,t){return e.hasOwnProperty(t.itemType)||(e[t.itemType]=[]),e[t.itemType].push(t),e},{}),r=o.transaction.createChangesDelta(),n=[];for(var s in t)n.push(o.resolveDerivedValues(t[s],t[s][0].columns.root,r));return o.promiseService.all(n)}).then(function(){return i})},t.prototype.fetchItemEntries=function(e,t,r){for(var n=[],i=[],o=0,s=t;o<s.length;o++){var a=s[o];this.dependencies.keyService.isLocalId(a)?i.push(a):n.push(a)}return this.promiseService.all({remote:this.transaction.getServerCache().itemHandler.fetchItemEntries(e,n,r),local:this.fetchLocalItemEntries(e,i,r)}).then(function(e){return e.remote.concat(e.local)})},t.prototype.fetchTitle=function(e,t){var r=this,n=this.dependencies.itemEntryService.getTitleField(e);return this.fetchItemEntry(e,t,new i.e({columns:[n]})).then(function(e){return r.transaction.getItemChangesRecursively(e.id,!1)[n]},this.errorHandler.reject)},t.prototype.resolveLocalItemEntry=function(e,t,r,n){var i=this;if(r.run(t.columns))return this.promiseService.when(t);var o=this.getColumnDifference(t,n.columns);return this.dependencies.columnHandler.fetch(t.itemType,o).then(function(r){return i.expandLocalItemEntries(e,t.itemType,[t],o,r)},this.errorHandler.reject).then(function(){return t},this.errorHandler.reject)},t.prototype.expandLocalItemEntries=function(e,t,r,n,i){if(0===r.length)return this.promiseService.when(r);for(var o=this.dependencies.columnExpansionFactory.construct(t,n,i),s=0,a=r;s<a.length;s++){var c=a[s],u=o.run(c.columns);null!==u&&this.expandLocalItemEntry(e,c,u)}return this.resolveDerivedValues(r,o.aggregateRootColumns(),e)},t.prototype.fetchLocalItemEntryData=function(e,t,r,n,i){var o=this.entries.get(t,r);return void 0===o?this.errorHandler.reject(this.dependencies.itemEntryService.createUnfoundLocalItemError(t)):this.resolveLocalItemEntry(e,o,n,i)},t.prototype.fetchLocalItemEntries=function(e,t,r){var n=this;r.columns=this.expandColumnsWithCachedQueryColumns(e,r.columns);for(var i=this.dependencies.changesDeltaFactory.construct(),s=this.dependencies.columnSubsetCacheFactory.construct(r.columns),a=[],c=[],u=0,l=t;u<l.length;u++){var h=l[u];if(void 0!==this.entries.get(e,h))a.push(this.fetchLocalItemEntryData(i,e,h,s,r));else{if(this.transaction.parent instanceof o.J)return this.errorHandler.reject(this.dependencies.itemEntryService.createUnfoundLocalItemError(e));c.push(h)}}if(c.length>0){if(this.transaction.parent instanceof o.J)throw new Error("Tried looking for local entries on the serverCache");a.push(this.transaction.parent.itemHandler.fetchLocalItemEntries(e,c,r))}return this.promiseService.all(a).then(function(){return n.transaction.applyChangesDelta(i).then(function(){return t.map(function(t){return n.transaction.getLocalItemEntryByItemId(e,t)})},n.errorHandler.reject)},this.errorHandler.reject)},t.prototype.getColumnDifference=function(e,t){return this.columnUtil.mergeRequestColumns(e.columns.request,t).difference},t.prototype.expandLocalItemEntry=function(e,t,r){var n=r.difference.main;if(t.columns=r.merged,0!==n.length){var i=this.getLocalValues(t,n);Object(o.cb)(i)&&e.setItemUpdated(t,i,r)}},t.prototype.getLocalValues=function(e,t){for(var r=this.transaction.getParent(e),n=this.transaction.getChangesFromItemChanges(this.itemChanges[e.id]),i={},o=0,s=t;o<s.length;o++){var a=s[o],c=a.id;if(void 0===n[c]){var u=a.apiColumn.type;i[c]="link"===u&&null!==r?r.itemId:this.apiFormatter.getDefaultValue(u)}}return i},t}(r(27).a)},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(3),i=r(15),o=function(e){function t(t,r,n){var i=e.call(this,t.collectionEntryService,t.columnUtil,t.requestColumnExpansionFactory,t.promiseService,n)||this;return i.dependencies=t,i.itemHandler=r,i.transaction=n,i}return Object(n.b)(t,e),t.prototype.__fetchCachedQueryItem=function(e,t){var r=this.collectionEntryService.createQueryFromOptions(t);this.expandColumnsWithQueryColumns(e,t,r.object);var n=this.dependencies.columnSubsetCacheFactory.construct(t.columns);return this.__fetchItemEntriesByQueryData(e,t,n,r)},t.prototype.__expandCachedQuery=function(e,t){var r=this,n=this.columnUtil.mergeRequestColumns(e.requestColumns,t).difference;if(!0!==n&&0===n.length)return this.dependencies.promiseService.when(e);for(var i=e.itemType,o=[],s=[],a=[],c=0,u=e.items;c<u.length;c++){var l=u[c];l.isLocal()?s.push(l):a.push(l)}if(a.length>0&&o.push(this.transaction.getServerCache().cachedQueryHandler.__expandCachedQuery(e,t)),s.length>0){var h=this.dependencies.changesDeltaFactory.constructInternalDelta();o.push(this.dependencies.columnHandler.fetch(i,n).then(function(e){return r.itemHandler.expandLocalItemEntries(h,i,s,n,e)},this.dependencies.errorHandler.reject).then(function(){return r.transaction.applyChangesFromParent(h)},this.dependencies.errorHandler.reject))}return this.dependencies.promiseService.all(o).then(function(){return e.requestColumns=r.columnUtil.mergeRequestColumns(e.requestColumns,t).merged,e},this.dependencies.errorHandler.reject)},t.prototype.__addItemEntriesToCachedQueries=function(t,r,n){e.prototype.__addItemEntriesToCachedQueries.call(this,t,r,n,function(){return!1})},t.prototype.isLocal=function(e,t){var r=e.parent;return null===r?this.dependencies.queryService.containsLocalLinkedTo(t):this.dependencies.keyService.isLocalId(r.itemId)},t.prototype.__fetchItemEntriesByQueryData=function(e,t,r,n){var o,s,a=this,c=null===(o=this.cachedQueries[e])||void 0===o?void 0:o[n.string];return void 0!==c?r.runWithRequestColumns(c.requestColumns)?c.promise:this.__expandCachedQuery(c,r.requestColumns).then(function(){return c},this.dependencies.errorHandler.reject):(this.isLocal(t,n.object)&&this.transaction.parent instanceof i.ServerCache?this.transaction.dependencies.columnHandler.fetch(e,r.requestColumns).then(function(){s=a.setCachedQuery(e,n,[],r.requestColumns)},this.dependencies.errorHandler.reject):this.transaction.parent.cachedQueryHandler.__fetchItemEntriesByQueryData(e,t,r,n).then(function(e){s=null===t.limit?a.setCachedQuery(e.itemType,e.query,e.items.slice(),e.requestColumns):e},this.dependencies.errorHandler.reject)).then(function(){for(var e=a.dependencies.collectionMatcherFactory.constructCachedQueryProcessor(a.transaction,function(e){return e===s.itemType?[s]:[]}),t=0,r=s.items;t<r.length;t++){var n=r[t];a.transaction.itemHandler.detectEntryChanges(n.id)&&e.expand(n,a.transaction.getItemChangesRecursively(n.id,!1))}for(var i=0,o=a.transaction.itemHandler.entries.getByItemType(s.itemType);i<o.length;i++){n=o[i];e.expand(n,a.transaction.getItemChangesRecursively(n.id,!1))}return e.__removeFromAndAddToCachedQueries(!1)},this.dependencies.errorHandler.reject).then(function(){return s.deferred.resolve(s),s},function(e){return s.deferred.reject(e),a.dependencies.errorHandler.reject(e)})},t.prototype.__fetchLinkedCachedQueryItems=function(e,t,r,n){Object(i.isFunction)(t)&&(t=t());for(var o={},s=0,a=t;s<a.length;s++){var c=a[s],u=this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:c}),l=this.collectionEntryService.createQueryFromOptions(u);this.expandColumnsWithQueryColumns(r,u,l.object);var h=this.dependencies.columnSubsetCacheFactory.construct(u.columns);o[c]=this.__fetchItemEntriesByQueryData(r,n,h,l)}return this.dependencies.promiseService.all(o)},t}(r(29).a)},function(e,t,r){"use strict";r.d(t,"a",function(){return s});var n=r(3),i=r(14),o=r(20),s=function(e){function t(t,r,n){var i=e.call(this,n)||this;return i.errorHandler=t,i.itemCreateService=r,i.created=new o.a,i}return Object(n.b)(t,e),t.prototype.setItemCreated=function(e,t){var r=this;return this.itemCreateService.createItemsFromValues(this,e,[t]).then(function(){return r},this.errorHandler.reject)},t.prototype.setItemsCreated=function(e,t){var r=this;return this.itemCreateService.createItemsFromValues(this,e,t).then(function(){return r},this.errorHandler.reject)},t.prototype._setItemCreated=function(e,t,r,n){void 0===n&&(n=null);var i={};if(null!==n)for(var o in i=this.itemEntryService.getLinkFieldsByParent(n,r.itemType))t[o]=i[o];var s=this.itemEntryService.getLocalDefaultValues();for(var o in s)t.hasOwnProperty(o)||(t[o]=s[o]);return this.created.add(e,t,r),this},t.prototype.setItemMoved=function(e,t){return this.setItemUpdated(e,{},null,t)},t.prototype.isEmpty=function(){return e.prototype.isEmpty.call(this)&&this.created.isEmpty()},t}(i.a)},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=r(1),i=function(){function e(){this.tuples={}}return e.prototype.add=function(e,t,r){var n=r.itemType;void 0===this.tuples[n]&&(this.tuples[n]=[]),this.tuples[n].push({itemId:e,fields:t,columns:r})},e.prototype.isEmpty=function(){return!Object(n.i)(this.tuples)},e.prototype.forEach=function(e){for(var t in this.tuples)for(var r=this.tuples[t],n=0;n<r.length;n++)e(r[n],t,n)},e.prototype.contains=function(e){return void 0!==this.tuples[e]},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return s});var n=r(3),i=r(14),o=r(1),s=function(e){function t(t){var r=e.call(this,t)||this;return r.created={},r.moved={},r.itemIdConversionMap={},r}return Object(n.b)(t,e),t.prototype.setItemCreated=function(e,t){this.created[e.id]={entry:e,fields:t}},t.prototype.setItemMoved=function(e,t){this.moved[e.id]={entry:e,to:t}},t.prototype.isEmpty=function(){return e.prototype.isEmpty.call(this)&&!Object(o.i)(this.created)},t}(i.a)},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n=function(){function e(e,t,r,n,i,o){this.promiseLibrary=e,this.apiRequestService=t,this.requestColumnExpansionFactory=r,this.changesDeltaFactory=n,this.serverCache=i,this.itemType=o,this.deferred=this.promiseLibrary.defer(),this.requestColumnExpansion=this.requestColumnExpansionFactory.construct(),this.singleItemIds=[],this.queries={}}return e.prototype.containsId=function(e){return-1!==this.singleItemIds.indexOf(e)},e.prototype.containsQuery=function(e){return void 0!==this.queries[e]},e.prototype.addSingleItem=function(e,t){return this.requestColumnExpansion.expandWithRequestColumns(this.itemType,t),-1===this.singleItemIds.indexOf(e)&&this.singleItemIds.push(e),this.getPromise()},e.prototype.addQuery=function(e,t){return this.requestColumnExpansion.expandWithRequestColumns(this.itemType,t),void 0===this.queries[e[1]]&&(this.queries[e[1]]=e[0]),this.getPromise()},e.prototype.flush=function(){var e=this,t=[];for(var r in this.singleItemIds.length>0&&t.push({key:"id",comparator:"IN",value:this.singleItemIds}),this.queries)t.push(this.queries[r]);if(0===t.length)throw new Error("Tried to flush a RequestBuffer without singleItems or queries");var n,i=this.requestColumnExpansion.get();return this.apiRequestService.query(this.itemType,{conditions:t,operator:"OR"},i).then(function(t){n=t;var r=e.changesDeltaFactory.construct();if(0===e.singleItemIds.length&&!e.hasMultipleQueries()){var o=e.getFirstQueryString();void 0!==o&&r._setQueryResult(e.itemType,o,n.links[e.itemType])}return e.serverCache.processResponse(n,i,!1,!1,r)},function(t){return e.deferred.reject(t)}).then(function(){return e.deferred.resolve(n)},function(t){return e.deferred.reject(t)}),this.getPromise()},e.prototype.getPromise=function(){return this.deferred.promise},e.prototype.hasMultipleQueries=function(){var e=!0;for(var t in this.queries){if(!e)return!0;e=!1}return!1},e.prototype.getFirstQueryString=function(){for(var e in this.queries)return e},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n=function(){function e(e,t,r,n,i,o){this.columnSetFactory=e,this.conversionMapService=t,this.errorHandler=r,this.keyService=n,this.promiseService=i,this.templateCache=o}return e.prototype.createItemsFromValues=function(e,t,r,n){var i=this;if(void 0===n&&(n=null),0===r.length)return this.promiseService.when();for(var o=[],s=function(s){var c,u=s.hasOwnProperty("id")?s.id:a.keyService.getLocalId();o.push(a.templateCache.fetchTemplate(t,u,{},(c={},c[t]=Object.keys(r[0]),c),n).then(function(r){i.processTemplate(e,t,u,n,r,function(){return!0},function(e,r){if(e===t)for(var n in s)r[n]=s[n]})},a.errorHandler.reject))},a=this,c=0,u=r;c<u.length;c++){s(u[c])}return this.promiseService.all(o).then(function(){})},e.prototype.processTemplate=function(e,t,r,n,i,o,s){void 0===o&&(o=function(){return!0});var a=this.conversionMapService.createLocalConversionMap(t,r,!0,i.response),c=i.getFields();this.conversionMapService.updateItemValues(c,c,i.columns.item,a,n),void 0!==s&&s(t,c,a),e._setItemCreated(r,c,i.columns,n),this.processTemplateLinkItems(e,t,r,i,a,o,s)},e.prototype.processTemplateLinkItems=function(e,t,r,n,i,o,s){var a=this;void 0===o&&(o=function(){return!0});var c=n.response,u={},l=function(t,r,h){var d={itemType:t,itemId:r},p=c.items[t][h].links;for(var m in p)if(p.hasOwnProperty(m)){void 0===u[m]&&(u[m]=a.columnSetFactory.construct(m,!0,n.responseColumns));for(var f=0,y=p[m];f<y.length;f++){var v=y[f],g=c.fetchObject(m,v);if(o(m,g)){var C=i[m][v];a.conversionMapService.updateItemValues(g,g,u[m].item,i,d),void 0!==s&&s(m,g,i),e._setItemCreated(C,g,u[m],d),l(m,C,v)}}}};l(t,r,c.links[t][0])},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(19),i=r(21),o=function(){function e(e,t,r){this.errorHandler=e,this.itemEntryService=t,this.itemCreateService=r}return e.prototype.construct=function(){return new n.a(this.errorHandler,this.itemCreateService,this.itemEntryService)},e.prototype.constructInternalDelta=function(){return new i.a(this.itemEntryService)},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=r(0),i=function(){function e(e,t,r,n,i,o,s,a,c,u){this.changesDeltaFactory=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.columnExpansionFactory=n,this.createRequestFactory=i,this.errorHandler=o,this.promiseService=s,this.requestColumnExpansionFactory=a,this.collectionEntryService=c,this.itemEntryService=u}return e.prototype.construct=function(e,t,r){return new n.i(this.changesDeltaFactory,this.apiRequestService,this.changesCompilationFactory,this.columnExpansionFactory,this.createRequestFactory,this.errorHandler,this.promiseService,this.requestColumnExpansionFactory,this.collectionEntryService,this.itemEntryService,e,t,r)},e}()},function(e,t,r){"use strict";var n=r(3),i=function(e){function t(t){return e.call(this,t)||this}return Object(n.b)(t,e),t.prototype.parseEmptyQuery=function(){return!0},t.prototype.parseSubQuery=function(e,t,r){return void 0===r&&(r=!1),!1},t.prototype.parseSubFieldQuery=function(e,t,r,n,i){return!1},t.prototype.parseSearchQuery=function(e,t){return!1},t.prototype.parseCustomQuery=function(e,t,r){return void 0===r&&(r=!1),!1},t.prototype.parseSimpleQuery=function(e,t,r,n){return!0},t.prototype.parseLinkedToQuery=function(e,t,r,n){return void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1),!0},t.prototype.parseComplexQuery=function(e,t,r){return this.parseConditions(e)},t.prototype.parseConditions=function(e){var t=this;return e.every(function(e){return t.parse(e)})},t}(r(2).c),o=r(22);r.d(t,"a",function(){return s});var s=function(){function e(e,t,r,n,i){this.promiseLibrary=e,this.apiRequestService=t,this.requestColumnExpansionFactory=r,this.keyService=n,this.changesDeltaFactory=i,this.pendingBufferMap={},this.pendingTrueBufferMap={}}return e.prototype.setServerCache=function(e){this.serverCache=e},e.prototype.fetchByIds=function(e,t,r){for(var n=0,i=t;n<i.length;n++){var o=i[n];this.fetchById(e,o,r)}return this.pendingBufferMap[e].getPromise()},e.prototype.fetchById=function(e,t,r){if(this.keyService.isLocalId(t))throw new Error("Unexpected local ItemId in RequestBufferManager.fetchById, for local ItemIds you should use RequestBufferManager.fetchByLocalId");var n;return!0===r?void 0===(n=this.pendingTrueBufferMap[e])?n=this.constructBuffer(e,this.pendingTrueBufferMap):console.log("Existing 'columns: true' RequestBuffer "+e+" at "+performance.now()+" by id"):void 0===(n=this.pendingBufferMap[e])?n=this.constructBuffer(e):console.log("Existing RequestBuffer "+e+" at "+performance.now()+" by id"),n.addSingleItem(t,r),n.getPromise()},e.prototype.fetchByQuery=function(e,t,r){var n;return new i(t[0]).parse()?(void 0===(n=this.pendingBufferMap[e])?n=this.constructBuffer(e):console.log("Existing RequestBuffer "+e+" at "+performance.now()+" with query"),n.addQuery(t,r),n.getPromise()):((n=this._constructBuffer(e)).addQuery(t,r),n.flush(),n.getPromise())},e.prototype.constructBuffer=function(e,t){void 0===t&&(t=this.pendingBufferMap);var r=t[e]=this._constructBuffer(e);return window.setTimeout(function(){r.flush(),delete t[e]},150),r},e.prototype._constructBuffer=function(e){return new o.a(this.promiseLibrary,this.apiRequestService,this.requestColumnExpansionFactory,this.changesDeltaFactory,this.serverCache,e)},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(5),i=r(1),o=function(){function e(e,t,r,n,i,o,s,a){this.columnUtil=e,this.apiFormatter=t,this.itemEntryFactory=r,this.promiseService=n,this.errorHandler=i,this.requestColumnExpansionFactory=o,this.transaction=a,this.entries=s.construct(this.transaction)}return e.prototype.getDerivedValues=function(e,t){for(var r=e,n=this.transaction.getChangesFromItemChanges(this.itemChanges[e.id]),i=0,o=t;i<o.length;i++){var s=o[i],a=r.columns.response[r.itemType][s];if(void 0===a)throw new Error("Column '"+s+"' not found on entry in ItemResource.getDerivedValue");if(null===a.itemType)throw new Error("Column '"+s+"' doesn't have children in ItemResource.getDerivedValue");var c=n[s];if(null===c)return;if(void 0===(r=this.transaction.getLocalItemEntryByItemId(a.itemType,c)))throw new Error("Derived itemEntry "+a.itemType+":"+c+" couldn't be found");n=this.transaction.getItemChangesRecursively(r.id,!1)}return n},e.prototype.getDerivedValue=function(e,t){"string"==typeof t&&(t=this.columnUtil.parseConfigColumn(t));var r=this.getDerivedValues(e,t.slice(0,-1));if(void 0!==r)return r[t[t.length-1]]},e.prototype.clearItemEntry=function(e){this.entries.clear(e),delete this.itemChanges[e.id]},e.prototype.fetchDerivedValuesByColumn=function(e,t,r){var o=this,s=t.children;if(0===s.length)return this.promiseService.when();var a=s[0];if(1===s.length&&"id"===a.apiColumn.type)throw new Error("You should use fields[columnId] instead of derived['columnId>id'] to get the id of a derived item");for(var c={},u=0,l=e;u<l.length;u++){var h=l[u];null!==(p=this.getItemIdByColumn(h,t,r))&&(void 0===c[p]&&(c[p]=[]),c[p].push(h))}if(!Object(i.i)(c))return this.promiseService.when();var d=[];for(var p in c)d.push(+p);for(var m=[],f=0,y=s;f<y.length;f++){var v=y[f];m.push(v.id)}return this.fetchItemEntries(t.itemType,d,new n.e({columns:m})).then(function(){return o.resolveDerivedValues(e,s,r)},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.createItemEntry=function(e){var t=this.itemEntryFactory.construct(e.itemId,e.columns);return this.entries.add(t),t},e.prototype.getItemIdByColumn=function(e,t,r){if(0===t.level)return void 0!==r&&void 0!==r.updated[e.id]?r.updated[e.id].changes.fields[t.path]:this.transaction.getItemChangesRecursively(e.id)[t.path];var n=this.getItemIdByColumn(e,t.parent,r),i=this.transaction.getLocalItemEntryByItemId(t.parent.itemType,n);return void 0!==r&&void 0!==r.updated[i.id]?r.updated[i.id].changes.fields[t.id]:this.transaction.getItemChangesRecursively(i.id)[t.id]},e.prototype.expandColumnsWithCachedQueryColumns=function(e,t){var r=this.requestColumnExpansionFactory.construct();void 0!==t&&r.expandWithRequestColumns(e,t);for(var n=function(t){var n=t.cachedQueryHandler.cachedQueries[e];if(void 0!==n)for(var i in n){var o=n[i];r.expandWithRequestColumns(o.itemType,o.requestColumns)}},i=function(e){for(var t=0,r=e;t<r.length;t++){var o=r[t];n(o),i(o.children)}},o=0,s=this.transaction.getTransactionChain();o<s.length;o++){var a=s[o];n(a)}return i(this.transaction.children),r.get()[e]},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n=function(){function e(e,t,r){this.queryService=e,this.queryMatcherFactory=t,this.transaction=r}return e.prototype.expand=function(e,t){var r=this.queryMatcherFactory.construct(e.itemType,t,this.transaction.getParent(e));return this._expand(e,function(e,t){return r.matchQuery(t.object)})},e.prototype.processDelta=function(e){var t=this;for(var r in e.deleted)for(var n=0,i=e.deleted[r];n<i.length;n++){var o=i[n];this._expand(o,function(){return!1})}var s=function(t){var r=e.created[t],n=a.queryMatcherFactory.construct(r.entry.itemType,r.fields,a.transaction.getParent(r.entry));a._expand(r.entry,function(t,i){var o=e._queryResults[t];if(void 0!==o){var s=o[i.string];if(void 0!==s)return!r.entry.isLocal()&&-1!==s.indexOf(r.entry.itemId)}return n.matchQuery(i.object)})},a=this;for(var c in e.created)s(c);var u=function(r){var n=e.moved[r];l._expand(n.entry,function(e,r){return t.queryService.containsLinkedTo(r.object,n.to.itemType,n.to.itemId)})},l=this;for(var c in e.moved)u(c);var h=function(t){var r=e.updated[t],n={},i=d.transaction.getItemChangesRecursively(Number(t),!1),o=function(e,t){var r=Object.getOwnPropertyDescriptor(e,t);void 0!==r?Object.defineProperty(n,t,r):n[t]=e[t]};for(var s in i)o(i,s);for(var s in r.changes.fields)o(r.changes.fields,s);var a=d.queryMatcherFactory.construct(r.entry.itemType,n,d.transaction.getParent(r.entry));d._expand(r.entry,function(t,n){var i=e._queryResults[t];if(void 0!==i){var o=i[n.string];if(void 0!==o)return!r.entry.isLocal()&&-1!==o.indexOf(r.entry.itemId)}return a.matchQuery(n.object)})},d=this;for(var c in e.updated)h(c);return this},e.prototype.groupItemEntries=function(e){var t=[],r=[],n=[];for(var i in e){var o=e[i],s=o.item,a=o.isMatch;!0===a?t.push(s):!1===a?r.push(s):n.push(s)}return{fitting:t,notFitting:r,maybe:n}},e}()},function(e,t,r){"use strict";var n=r(3),i=function(e){function t(t,r,n){var i=e.call(this,n)||this;return i.columnUtil=t,i.itemType=r,i}return Object(n.b)(t,e),t.prototype.parseEmptyQuery=function(){return[]},t.prototype.parseSubQuery=function(e,t,r){var n;return void 0===r&&(r=!1),[(n={},n[e]=this.parse(t),n)]},t.prototype.parseSubFieldQuery=function(e,t,r,n,i){return[]},t.prototype.parseSearchQuery=function(e,t){return[]},t.prototype.parseCustomQuery=function(e,t,r){return void 0===r&&(r=!1),[]},t.prototype.parseSimpleQuery=function(e,t,r,n){return[e]},t.prototype.parseLinkedToQuery=function(e,t,r,n){return void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1),this.columnUtil.getColumnsFromLink(e,this.itemType)},t.prototype.parseComplexQuery=function(e,t,r){return this.parseConditions(e)},t.prototype.parseConditions=function(e){var t=this;return e.reduce(function(e,r){return e.concat(t.parse(r))},[])},t}(r(2).c),o=r(1);r.d(t,"a",function(){return s});var s=function(){function e(e,t,r,n,i){this.collectionEntryService=e,this.columnUtil=t,this.requestColumnExpansionFactory=r,this.promiseService=n,this.transaction=i,this.cachedQueries={}}return e.prototype.setCachedQuery=function(e,t,r,n){void 0===this.cachedQueries[e]&&(this.cachedQueries[e]={});var i=this.promiseService.defer();return this.cachedQueries[e][t.string]={itemType:e,query:t,items:r,deferred:i,promise:i.promise,requestColumns:n}},e.prototype.getCachedQueryItems=function(e,t){var r,n;return null===(n=null===(r=this.cachedQueries[e])||void 0===r?void 0:r[t])||void 0===n?void 0:n.items},e.prototype.getCachedQueryObjectsByItemType=function(e){var t=[];if(void 0===this.cachedQueries[e])return t;for(var r in this.cachedQueries[e])t.push(this.cachedQueries[e][r]);return t},e.prototype.initCachedQuery=function(e,t,r){return this.setCachedQuery(e,t,[],r)},e.prototype.__addItemEntriesToCachedQueries=function(e,t,r,n){if(0!==r.length){var i=this.getCachedQueryItems(e,t.string);if(void 0!==i)for(var o=[],s=0,a=r;s<a.length;s++){var c=a[s];-1!==i.indexOf(c)||n(c)||(i.push(c),o.push(c))}}},e.prototype.__removeItemEntriesFromCachedQueries=function(e,t,r){if(0===r.length)return[];var n=this.getCachedQueryItems(e,t.string);return void 0===n?[]:this.collectionEntryService.filterArray(n,function(e){return!Object(o.j)(e,r)})},e.prototype.expandColumnsWithQueryColumns=function(e,t,r){var n=new i(this.columnUtil,e,r);if(t.queryColumns=n.parse(),!0!==t.columns){var o=this.requestColumnExpansionFactory.construct();o.expandWithRequestColumns(e,t.columns),o.expandWithRequestColumns(e,t.queryColumns),null!==t.limit&&o.expandWithRequestColumns(e,[t.limit.field]),t.columns=o.get()[e]}},e}()},function(e,t,r){"use strict";var n,i;r.d(t,"b",function(){return n}),r.d(t,"a",function(){return i}),function(e){e.New="new",e.Duplicate="duplicate"}(n||(n={})),function(e){e.ITEMTABLE="itemtable",e.DIRECT="direct"}(i||(i={}))},function(e,t){},function(e,t,r){"use strict";r.r(t);var n=r(33);for(var i in n)"default"!==i&&function(e){r.d(t,e,function(){return n[e]})}(i);var o=r(34);for(var i in o)"default"!==i&&function(e){r.d(t,e,function(){return o[e]})}(i);var s=r(35);for(var i in s)"default"!==i&&function(e){r.d(t,e,function(){return s[e]})}(i);var a=r(36);for(var i in a)"default"!==i&&function(e){r.d(t,e,function(){return a[e]})}(i);var c=r(37);for(var i in c)"default"!==i&&function(e){r.d(t,e,function(){return c[e]})}(i);var u=r(38);for(var i in u)"default"!==i&&function(e){r.d(t,e,function(){return u[e]})}(i);var l=r(39);for(var i in l)"default"!==i&&function(e){r.d(t,e,function(){return l[e]})}(i);var h=r(40);for(var i in h)"default"!==i&&function(e){r.d(t,e,function(){return h[e]})}(i);var d=r(41);for(var i in d)"default"!==i&&function(e){r.d(t,e,function(){return d[e]})}(i);var p=r(42);for(var i in p)"default"!==i&&function(e){r.d(t,e,function(){return p[e]})}(i);var m=r(43);for(var i in m)"default"!==i&&function(e){r.d(t,e,function(){return m[e]})}(i)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){}])});
16
+ var n=function(e,t){return(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])})(e,t)};function i(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)}},function(e,t,r){"use strict";r.d(t,"a",function(){return n}),r.d(t,"b",function(){return i}),r.d(t,"g",function(){return o}),r.d(t,"f",function(){return s}),r.d(t,"d",function(){return a}),r.d(t,"e",function(){return c}),r.d(t,"c",function(){return u});var n="7",i=">",o=":",s="-1",a="-2",c="new-",u="dup-"},function(e,t,r){"use strict";var n=r(0),i=function(){return function(e){this.columns=!0,this.parent=null,this.templateOptions={},Object(n.eb)(this,e)}}(),o=0,s=function(){function e(e,t,r,n){this.factory=e,this.itemType=t,this.itemId=r,this.columns=n,this.id=++o,this.reloadQueued=!1}return e.prototype.queueReload=function(){return this.reloadQueued=!0,this},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.toJSON=function(){return{id:this.id,columns:this.columns}},e}(),a=function(){function e(e,t,r,n){this.factory=e,this.entry=t,this._isNew=r,this.transaction=n,this.columns=t.columns.response[t.columns.itemType],this.initial=this.transaction.itemHandler.itemChanges[t.id].initial,this.fields=n.itemHandler.itemChanges[t.id].changes,this.onConstruct()}return e.prototype.onConstruct=function(){},e.prototype.setFields=function(e){var t=this,r=this.columns;for(var n in e){void 0===r[n]&&console.warn("setFields: no column found for",n)}var i=this.transaction.createChangesDelta();return i.setItemUpdated(this.entry,e),this.transaction.applyChangesDelta(i).then(function(){return t},this.factory.errorHandler.reject)},e.prototype.copyFields=function(e){void 0===e&&(e={});var t=this.entry;return this.factory.apiFormatter.copyFields(this.fields,e,t.columns.main),e},e.prototype.getParent=function(e){return this.transaction.getParent(this.entry,e,this.fields)},e.prototype.callOnChange=function(e){var t,r=this,n=null===(t=this.transaction.itemHandler.fieldChangeCallbacks[this.entry.itemType])||void 0===t?void 0:t[this.entry.itemId];if(void 0!==n)for(var i=0,o=n;i<o.length;i++){var s=o[i];try{s({itemEntry:this.entry,compareField:function(t){return r.factory.apiFormatter.compareFields(r.entry.columns.response[r.entry.itemType][t].type,r.fields[t],e[t])},fields:this.fields,isCalledAfterSocketUpdate:!1,previous:e})}catch(e){this.factory.exceptionHandler(e)}}},e.prototype.compareItemField=function(e,t){var r=this.columns[e];if(void 0===r)throw new Error("Missing column in ItemResource.compareItemField");return this.factory.apiFormatter.compareFields(r.type,this.fields[e],t[e])},e.prototype.hasChanges=function(){return this.transaction.itemHandler.detectEntryChanges(this.entry.id)},e.prototype.setTransactionParameters=function(e){Object(n.V)(this.transaction.tabRequestParameters,[this.entry.itemType,this.entry.itemId],[{},e])},e.prototype.isNew=function(){return this._isNew},e.prototype.isLocal=function(){return this.entry.isLocal()},e.prototype.toJSON=function(){var e=[];for(var t in this.columns)e.push(t);return{columns:e,fields:this.fields,entry:this.entry}},e.prototype.getDerivedValue=function(e){return this.transaction.itemHandler.getDerivedValue(this.entry,e)},e.prototype.getDerivedValues=function(e){return this.transaction.itemHandler.getDerivedValues(this.entry,e)},e}(),c=r(10),u=0,l=function(){function e(e,t,r,n,i,o,s){this.collectionEntryService=e,this.queryService=t,this.columnSetFactory=r,this.keyService=n,this.columnCache=i,this.itemType=o,this.options=s,this.id=u++,this.parent=null,this.reloadQueued=!1,this.parent=s.parent,this.query=this.collectionEntryService.createQueryFromOptions(s);var a=this.columnCache.retrieve(o,s.columns);(!0===a.missing||a.missing.length>0)&&console.warn("Missing columns in CollectionEntry",a.missing),this.columns=this.columnSetFactory.construct(o,s.columns,a.cached)}return e.prototype.isLocal=function(){var e=this.parent;return null===e?this.queryService.containsLocalLinkedTo(this.query.object):this.keyService.isLocalId(e.itemId)},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.options.columns=this.columns.request)},e}(),h=r(9),d=function(){function e(e,t,r,n,i){this.factory=e,this.options=t,this.transaction=r,this.itemIdMap={},this.fieldChangeDeregFns={},this.onChangeCallbacks=[],this.onAddCallbacks=[],this.onRemoveCallbacks=[],this.removedItemIds=[],this.entry=this.factory.collectionEntryFactory.construct(n,this.options),this.columns=this.entry.columns.response,this.items=[],this.itemIdMap={},this.registerListeners(),this.addItemResources(i,!0),this.onConstruct()}return e.prototype.onConstruct=function(){},e.prototype.setLimit=function(e){var t=null===this.options.limit?null:this.options.limit.limit;if("number"==typeof e){if(null===this.options.limit)throw new Error("Tried to set a limit only using a number, but the collection didn't have a limit object yet");this.options.limit.limit=e}else this.options.limit=e;null===t&&null===this.options.limit||(null===t||t>this.options.limit.limit?this.limitAfterAdd(!1):t<this.options.limit.limit&&this.limitAfterRemove())},e.prototype.onAdd=function(e){return this.__registerCallback(this.onAddCallbacks,e)},e.prototype.onChange=function(e){return this.__registerCallback(this.onChangeCallbacks,e)},e.prototype.onRemove=function(e){return this.__registerCallback(this.onRemoveCallbacks,e)},e.prototype.__clear=function(){this.onAddCallbacks.length=0,this.onChangeCallbacks.length=0,this.onRemoveCallbacks.length=0},e.prototype.moveItems=function(e,t){return this.transaction.collectionHandler.moveItems(this.entry,t.entry,e)},e.prototype.removeItems=function(e){for(var t=this.factory.changesDeltaFactory.construct(),r=[],n=0,i=this.items;n<i.length;n++){var o=i[n].entry;-1!==e.indexOf(o.itemId)&&r.push(o)}return t.setItemsDeleted(r),this.transaction.applyChangesDelta(t)},e.prototype.removeItem=function(e){return this.removeItems([e])},e.prototype.addItems=function(e){var t=this,r=this.transaction.createChangesDelta();if(null!==this.entry.parent)for(var n=this.factory.itemEntryService.getLinkFieldsByParent(this.entry.parent,this.entry.itemType),i=0,o=e;i<o.length;i++){var s=o[i];for(var a in n)s[a]=n[a]}return r.setItemsCreated(this.entry.itemType,e).then(function(){return t.transaction.applyChangesDelta(r)})},e.prototype.addItem=function(e){return this.addItems([e])},e.prototype.getIdArray=function(){return this.items.map(function(e){return e.entry.itemId})},e.prototype.getItemById=function(e){return this.itemIdMap[e]},e.prototype.addItemResources=function(e,t,r){var n=this;if(void 0===t&&(t=!1),void 0===r&&(r=!1),0===e.length)return[];e=e.filter(function(e){return void 0===n.itemIdMap[e.itemId]});for(var i=this.transaction.createItemResources(e),o=0,s=i;o<s.length;o++){var a=s[o],c=a.entry.itemId;if(void 0===this.itemIdMap[c]){this.items.push(a),this.itemIdMap[c]=a;var u=this.removedItemIds.indexOf(c);u>-1&&this.removedItemIds.splice(u),this.fieldChangeDeregFns[a.entry.id]=this.transaction.registerFieldChangeCallback(a.entry.itemType,a.entry.itemId,function(e){n.callOnChange(e.itemEntry,e.compareField,e.fields,r,e.previous)})}}return this.limitAfterAdd(r,i),i.length>0&&(!t||this.options.callOnAddWithInitialItems)&&this.callOnAdd(i,t,r),i},e.prototype.removeItemResources=function(e,t){var r=this,i=[];return 0===e.length?i:(Object(n.Z)(this.items,function(t){for(var n=0,o=e;n<o.length;n++){var s=o[n];if(t.entry===s)return i.push(t),delete r.itemIdMap[s.itemId],r.fieldChangeDeregFns[s.id](),delete r.fieldChangeDeregFns[s.id],r.removedItemIds.push(s.itemId),!1}return!0}),this.callOnRemove(i,t),this.limitAfterRemove(),i)},e.prototype.callOnAdd=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=!1);try{for(var n=0,i=this.onAddCallbacks;n<i.length;n++){(0,i[n])({itemResources:e,collectionResource:this,isInitialCall:t,isCalledAfterSocketUpdate:r})}}catch(e){this.factory.exceptionHandler(e)}},e.prototype.callOnChange=function(e,t,r,n,i){try{for(var o=0,s=this.onChangeCallbacks;o<s.length;o++){(0,s[o])({itemEntry:e,compareField:t,fields:r,isCalledAfterSocketUpdate:n,previous:i})}}catch(e){this.factory.exceptionHandler(e)}},e.prototype.callOnRemove=function(e,t){try{for(var r=0,n=this.onRemoveCallbacks;r<n.length;r++){(0,n[r])({itemResources:e,collectionResource:this,isCalledAfterSocketUpdate:t})}}catch(e){this.factory.exceptionHandler(e)}},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++){if(void 0===(a=i[n]).entry.columns.response[this.entry.itemType][e])throw new Error("Trying to group on a column not in one of the items in this collection! (column '"+e+"', item "+a.entry.itemType+":"+a.entry.itemId+")");void 0===r[c=a.fields[e]]&&(r[c]=[]),r[c].push(a)}if("function"==typeof e)for(var o=0,s=t;o<s.length;o++){var a,c;null!==(c=e(a=s[o]))&&(void 0===r[c]&&(r[c]=[]),r[c].push(a))}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.clearResource=function(){for(var e in this.fieldChangeDeregFns)this.fieldChangeDeregFns[e](),delete this.fieldChangeDeregFns[e];this.transaction.clearCollectionResource(this)},e.prototype.registerListeners=function(){var e=this;this.onChangeCallbacks.push(function(t){t.compareField("id")||(e.itemIdMap[t.fields.id]=e.getItemById(t.previous.id),delete e.itemIdMap[t.previous.id])}),this.options.onAdd!==h.c&&this.onAddCallbacks.push(function(t){e.options.onAdd(t.itemResources,t.collectionResource,t.isInitialCall,t.isCalledAfterSocketUpdate)}),this.options.onRemove!==h.c&&this.onRemoveCallbacks.push(function(t){e.options.onRemove(t.itemResources,t.collectionResource,t.isCalledAfterSocketUpdate)}),this.options.onChange!==h.c&&this.onChangeCallbacks.push(function(t){return e.options.onChange(t)})},e.prototype.__registerCallback=function(e,t){return e.push(t),function(){var r=e.indexOf(t);r>-1&&e.splice(r,1)}},e.prototype.limitAfterRemove=function(){var e=this;null===this.options.limit||this.options.limit.limit<=this.items.length||this.transaction.cachedQueryHandler.__fetchCachedQueryItem(this.entry.itemType,new c.a({query:this.factory.queryService.addAndCondition(this.entry.query.object,this.factory.queryService.createNotIn(this.removedItemIds)),columns:this.entry.options.columns,parent:this.entry.parent,limit:this.entry.options.limit})).then(function(t){e.addItemResources(t.items)})},e.prototype.limitAfterAdd=function(e,t){var r=this.entry.options.limit;if(!(null===r||this.items.length<=r.limit)){this.items.sort(function(e,t){var n=e.fields[r.field]-t.fields[r.field];return void 0===r.order||"desc"===r.order?-n:n});for(var n=this.items.splice(r.limit,this.items.length-r.limit),i=0,o=n;i<o.length;i++){var s=o[i];if(this.fieldChangeDeregFns[s.entry.id](),delete this.itemIdMap[s.entry.itemId],delete this.fieldChangeDeregFns[s.entry.id],this.removedItemIds.push(s.entry.itemId),void 0!==t){var a=t.indexOf(s);a>-1&&t.splice(a,1)}}this.callOnRemove(n,e)}},e}(),p=function(){function e(e,t,r,n,i){this.itemType=t,this.response=r;var o=r.fetchColumnsObject();this.responseColumns=e.columnUtil.mergeResponseColumns(o,i).merged,this.columns=e.columnSetFactory.constructFromResponse(t,o),this.columns=this.columns.expand(n[t],!1,i).merged}return e.prototype.getFields=function(){var e=this.itemType;return this.response.fetchObject(e,this.response.links[e][0])},e}();r.d(t,"e",function(){return i}),r.d(t,"d",function(){return s}),r.d(t,"f",function(){return a}),r.d(t,"b",function(){return c.a}),r.d(t,"a",function(){return l}),r.d(t,"c",function(){return d}),r.d(t,"g",function(){return p})},function(t,r){t.exports=e},function(e,t,r){"use strict";var n=r(0),i=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e){return new n.d(this.apiFormatter,e)},e}(),o=function(){function e(){}return e.prototype.construct=function(e){return new n.f(e)},e}(),s=r(5),a=r(10),c=function(){function e(e,t,r,n,i){this.collectionEntryService=e,this.columnSetFactory=t,this.keyService=r,this.queryService=n,this.columnCache=i}return e.prototype.construct=function(e,t){return new s.a(this.collectionEntryService,this.queryService,this.columnSetFactory,this.keyService,this.columnCache,e,new a.a(t))},e}(),u=r(3),l=r(28),h=r(12),d=function(e){function t(t,r,n,i,o,s){var a=e.call(this,n,i,o)||this;return a.apiRequestService=t,a.promiseService=r,a.getQueries=s,a.map={},a}return Object(u.b)(t,e),t.prototype.__removeFromAndAddToCachedQueries=function(e,t){var r=this;void 0===e&&(e=!1);var n=[],i=function(e){var i,s=o.map[e],a=o.groupItemEntries(s.matches);if(o.transaction.cachedQueryHandler.__removeItemEntriesFromCachedQueries(s.itemType,s.query,a.notFitting),o.transaction.cachedQueryHandler.__addItemEntriesToCachedQueries(s.itemType,s.query,a.fitting),a.maybe.length>0){if(o.transaction instanceof h.a)for(var c=0,u=a.maybe;c<u.length;c++){var l=u[c];o.transaction.itemHandler.detectEntryChanges(l.id)&&console.error("!! Trying to re-query 'maybe' matching results but one of the entries has changes, please report this to Martijn !!")}n.push(o.apiRequestService.query(s.itemType,s.query.object,(i={},i[s.itemType]=["id"],i)).then(function(e){void 0!==t&&t._setQueryResult(s.itemType,s.query.string,e.links[s.itemType]),r.transaction.cachedQueryHandler.__addItemEntriesToCachedQueries(s.itemType,s.query,a.maybe.filter(function(t){return e.links[s.itemType].indexOf(t.itemId)>-1}))}).then(function(){},function(){}))}},o=this;for(var s in this.map)i(s);return this.promiseService.all(n)},t.prototype._expand=function(e,t){for(var r=0,n=this.getQueries(e.itemType);r<n.length;r++){var i=n[r],o=i.itemType+"-"+i.query.string;void 0===this.map[o]&&(this.map[o]={itemType:e.itemType,query:i.query,matches:{},cachedQuery:i});var s=this.map[o].matches;void 0===s[e.itemId]&&(s[e.itemId]={item:e,isMatch:t(e.itemType,i.query)})}return this},t}(l.a),p=r(16),m=function(){function e(e,t,r,n){this.queryMatcherFactory=e,this.queryService=t,this.apiRequestService=r,this.promiseService=n}return e.prototype.constructCachedCollectionProcessor=function(e,t){return new p.a(this.apiRequestService,this.promiseService,this.queryService,this.queryMatcherFactory,e,t)},e.prototype.constructCachedQueryProcessor=function(e,t){return new d(this.apiRequestService,this.promiseService,this.queryService,this.queryMatcherFactory,e,t)},e}(),f=function(){function e(e,t,r,n,i,o,s,a,c){this.errorHandler=e,this.exceptionHandler=t,this.keyService=r,this.promiseService=n,this.changesDeltaFactory=i,this.itemEntryService=o,this.collectionEntryFactory=s,this.queryService=a,this.columnSetFactory=c}return e.prototype.construct=function(e,t,r,n){return new s.c(this,new s.b(t),r,e,n)},e}(),y=function(){function e(e){this.columnInfoFactory=e}return e.prototype.construct=function(e,t,r){return new n.n(this.columnInfoFactory,e,t,r)},e}(),v=function(){function e(){}return e.prototype.construct=function(e,t){return new n.p(e,t)},e.prototype.constructFromRootMap=function(e,t){void 0===t&&(t=null);var r=[];for(var n in e){var i=e[n],o=this.construct(i.apiColumn,t),s=this.constructFromRootMap(i.children,o);s.length>0&&o.setChildren(o.apiColumn.itemType,s),r.push(o)}return r},e}(),g=function(){function e(e,t,r){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r}return e.prototype.constructStub=function(e,t){var r=new n.q(this.columnUtil,this,e);return r.request=t,r.requestColumnsTrue=!0===t,r},e.prototype.resolveStub=function(e,t,r,n){return void 0===r&&(r=!0),void 0===n&&(n=!0),e.requestColumnsTrue?this.processResponseColumns(e,t,r):this.processRequestColumns(e,t,r,n)},e.prototype.construct=function(e,t,r,n,i){return this.resolveStub(this.constructStub(e,t),r,n,i)},e.prototype.constructFromResponse=function(e,t,r){void 0===r&&(r=!0);var i=new n.q(this.columnUtil,this,e);return i.requestColumnsTrue=!1,this.processResponseColumns(i,t,r)},e.prototype.processResponseColumns=function(e,t,r){var n=e.itemType,i={};return e.response=t,this.expandRootColumnMapFromResponseColumns(n,t,i,r,{}),this.processColumnInfo(e,this.columnInfoFactory.constructFromRootMap(i),n),e.request=this.constructRequestColumnsFromRootColumnMap(i),e},e.prototype.constructRequestColumnsFromRootColumnMap=function(e){var t,r=[];for(var i in e){var o=e[i];Object(n.cb)(o.children)?r.push(((t={})[i]=this.constructRequestColumnsFromRootColumnMap(o.children),t)):r.push(i)}return r},e.prototype.expandRootColumnMapFromResponseColumns=function(e,t,r,i,o){if(!0!==o[e])for(var s in o[e]=!0,t[e]){var a=t[e][s];if(void 0!==a&&(i&&this.columnHandler.setColumn(e,a),void 0===r[s]&&(r[s]={apiColumn:a,children:{}}),this.columnUtil.isItemColumn(a,!1))){var c=t[a.itemType];void 0!==c&&Object(n.cb)(c)&&this.expandRootColumnMapFromResponseColumns(a.itemType,t,r[s].children,i,o)}}},e.prototype.processRequestColumns=function(e,t,r,n){var i=e.itemType,o={};return this.expandRootColumnMap(e.request,i,t,o,r),n&&this.expandRootColumnMap(["id"],i,t,o,r),e.response={},this.processColumnInfo(e,this.columnInfoFactory.constructFromRootMap(o),i),e},e.prototype.processColumnInfo=function(e,t,r){var n=e.response;void 0===n[r]&&(n[r]={});for(var i=0,o=t;i<o.length;i++){var s=o[i];n[r][s.id]=s.apiColumn,e.groupColumnInfo(s),s.isLeaf||this.processColumnInfo(e,s.children,s.itemType)}},e.prototype.expandRootColumnMap=function(e,t,r,n,i){for(var o=0,s=e;o<s.length;o++){var a=s[o],c=this.columnUtil.parseRequestColumn(a),u=c.id,l=c.children,h=void 0;void 0!==r[t]&&(h=r[t][u]),void 0!==h?(i&&(h=this.columnHandler.setColumn(t,h)),void 0===n[u]&&(n[u]={apiColumn:h,children:{}}),0!==l.length&&this.expandRootColumnMap(l,h.itemType,r,n[u].children,i)):console.warn("No api column for request column",u,"for itemType",t)}},e}(),C=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(e){return new n.r(this.columnUtil,e)},e}(),I=function(){function e(e,t,r){this.apiFormatter=e,this.keyService=t,this.requestColumnExpansionFactory=r}return e.prototype.construct=function(e,t,r){return new n.u(this.apiFormatter,this.keyService,this.requestColumnExpansionFactory,e,t,r)},e}(),b=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e){return new n.x(this.queryMatcherFactory,e)},e}(),S=function(){function e(e,t,r,n,i,o){this.apiFormatter=e,this.columnSetFactory=t,this.exceptionHandler=r,this.itemEntryService=n,this.keyService=i,this.promiseService=o}return e.prototype.construct=function(e,t){return new s.d(this,t.itemType,e,t)},e}(),E=function(){function e(e,t,r,n,i){this.apiFormatter=e,this.errorHandler=t,this.promiseService=r,this.exceptionHandler=n,this.columnUtil=i}return e.prototype.construct=function(e,t,r){return void 0===r&&(r=!1),new s.f(this,e,r,t)},e}(),F=function(){function e(e,t){this.dependencies=e,this.core=t,this.serverCache=new n.J(this.dependencies,this.core)}return e.prototype.getById=function(e){var t=function(r){for(var n=0,i=r;n<i.length;n++){var o=i[n];if(o.id===e)return o;var s=t(o.children);if(void 0!==s)return s}};return t(this.serverCache.children)},e.prototype.construct=function(e,t){return this.serverCache.createChild(e,t)},e.prototype.getServerCache=function(){return this.serverCache},e}(),R=function(){function e(){}return e.prototype.construct=function(e){return new n.C(e)},e}(),q=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e,t,r){return new n.D(this.apiFormatter,e,t,r)},e}(),T=function(){function e(){}return e.prototype.construct=function(e){return new n.E(e)},e}(),H=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(){return new n.I(this.columnUtil)},e}(),M=function(){function e(e,t){this.columnSetFactory=e,this.columnUtil=t}return e.prototype.construct=function(e,t,r,n){return new s.g(this,e,t,r,n)},e}(),w=r(24),k=r(25);r.d(t,"a",function(){return i}),r.d(t,"b",function(){return o}),r.d(t,"e",function(){return c}),r.d(t,"f",function(){return m}),r.d(t,"g",function(){return f}),r.d(t,"h",function(){return y}),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 b}),r.d(t,"n",function(){return S}),r.d(t,"o",function(){return E}),r.d(t,"u",function(){return F}),r.d(t,"p",function(){return R}),r.d(t,"q",function(){return q}),r.d(t,"r",function(){return T}),r.d(t,"s",function(){return H}),r.d(t,"t",function(){return M}),r.d(t,"c",function(){return w.a}),r.d(t,"d",function(){return k.a})},function(e,t,r){"use strict";r.r(t);var n=r(30);r.d(t,"StateKeyType",function(){return n.b}),r.d(t,"ApiLinkTreeType",function(){return n.a});var i=r(31);for(var o in i)["StateKeyType","ApiLinkTreeType","default"].indexOf(o)<0&&function(e){r.d(t,e,function(){return i[e]})}(o)},function(e,t,r){"use strict";var n=r(0),i=r(23),o=r(26),s=r(1),a=function(){function e(e,t,r,n,i,o,s){this.columnUtil=e,this.promiseService=t,this.columnHandler=r,this.templateFactory=n,this.errorHandler=i,this.requestColumnExpansionFactory=o,this.apiRequestService=s,this.pendingTemplateBufferMap={},this.templates={}}return e.prototype.fetchTemplate=function(e,t,r,n,i){var o=this;void 0===r&&(r={}),void 0===n&&(n={}),void 0===i&&(i=null);var a=Object(s.i)(r),c=this.requestColumnExpansionFactory.construct();if(void 0!==n[e]&&c.expandWithRequestColumns(e,n[e]),c.expandWithRequestColumns(e,[{creator:["displayname"]},"created","permissions"]),null!==i&&c.expandWithRequestColumns(e,this.columnUtil.getColumnsFromLink("string"==typeof i?i:i.itemType,e)),n[e]=c.get()[e],!a){var u=this.templates[e];if(void 0!==u&&(null===e||this.columnUtil.responseColumnsAvailable(e,n[e],u.responseColumns)))return this.promiseService.when(u)}return this.promiseService.all({template:this.fetchTemplateById(e,t,r),additionalColumns:void 0===n[e]?{}:this.columnHandler.fetch(e,n[e])}).then(function(t){var r=t.template,i=o.templateFactory.construct(e,r,n,t.additionalColumns);return!a&&r.cacheable&&(o.templates[e]=i),i},this.errorHandler.reject)},e.prototype.fetchTemplateById=function(e,t,r){return void 0===t&&(t="no-id"),void 0===this.pendingTemplateBufferMap[e]||void 0===this.pendingTemplateBufferMap[e][t]?this.constructTemplateBuffer(e,t,r):this.pendingTemplateBufferMap[e][t]},e.prototype.constructTemplateBuffer=function(e,t,r){var n=this;return void 0===this.pendingTemplateBufferMap[e]&&(this.pendingTemplateBufferMap[e]={}),this.pendingTemplateBufferMap[e][t]=this.apiRequestService.template(e,r).then(function(r){return delete n.pendingTemplateBufferMap[e][t],r},function(){return delete n.pendingTemplateBufferMap[e][t],n.errorHandler.reject()})},e}(),c=r(7),u=r(24),l=r(25);r.d(t,"a",function(){return h}),r.d(t,"c",function(){return d}),r.d(t,"b",function(){return p});var h=function(){return function(e,t,r,s,h,p){this.version="6.2.0",this.noop=d;var m=new n.A,f=new n.b,y=new c.q(f),v=new c.r,g=new n.F(m),C=new n.l,I=new n.s(p),b=new c.s(I),S=new n.z(t,p),E=new c.a(f),F=new n.c(e,E),R=new c.f(y,g,F,h),q=new n.m(I),T=new n.o(F,r,h,q,I),H=new c.i,M=new c.h(H),w=new c.j(T,I,H),k=new c.k(I),D=new n.B(F,r,m,h),j=new c.t(w,I),x=new c.m(y),O=new c.o(f,r,h,s,I),Q=new a(I,h,T,j,r,b,F),L=new n.t(m),_=new i.a(w,L,r,m,h,Q),P=new u.a(r,S,_),A=new o.a(h,F,b,m,P),B=new c.n(f,w,s,S,m,h),U=new n.j(v,g),V=new c.e(U,w,m,g,q),N=new c.g(r,s,m,h,P,S,V,g,w),W=new c.l(f,m,b),Y=new c.b,J=new l.a(P,F,Y,M,W,r,h,b,U,S),K=new c.p,z=new c.u({apiFormatter:f,apiRequestService:F,authInterface:t,changesDeltaFactory:P,changesProcessorFactory:J,collectionEntryFactory:V,collectionEntryService:U,collectionMatcherFactory:R,collectionResourceFactory:N,columnCache:q,columnExpansionFactory:M,columnHandler:T,columnSetFactory:w,columnSubsetCacheFactory:k,columnUtil:I,conversionMapService:L,errorHandler:r,exceptionHandler:s,itemCacheFactory:x,itemCreateService:_,itemEntryFactory:B,itemEntryService:S,itemResourceFactory:O,keyService:m,linkTreeService:p,lockService:D,moduleChangesCompilationFactory:K,promiseService:h,queryMatcherFactory:y,queryParserFactory:v,queryService:g,requestBufferManager:A,requestColumnExpansionFactory:b,templateCache:Q},this);A.setServerCache(z.getServerCache());var G=new n.M(A,P,f,r,z,h,b,F,y);this.apiFormatter=f,this.apiRequestService=F,this.apiResponseProcessorFactory=E,this.changesCompilationFactory=Y,this.changesDeltaFactory=P,this.changesProcessorFactory=J,this.collectionEntryFactory=V,this.collectionEntryService=U,this.collectionMatcherFactory=R,this.collectionResourceFactory=N,this.collectionResourceService=C,this.columnCache=q,this.columnExpansionFactory=M,this.columnHandler=T,this.columnInfoFactory=H,this.columnSetFactory=w,this.columnSubsetCacheFactory=k,this.columnUtil=I,this.conversionMapService=L,this.createRequestFactory=W,this.itemCacheFactory=x,this.itemCreateService=_,this.itemEntryFactory=B,this.itemEntryService=S,this.itemResourceFactory=O,this.keyService=m,this.lockService=D,this.moduleChangesCompilationFactory=K,this.queryMatcherFactory=y,this.queryParserFactory=v,this.queryService=g,this.requestColumnExpansionFactory=b,this.socketMessageHandler=G,this.templateCache=Q,this.templateFactory=j,this.transactionCacheFactory=z}}();function d(){}function p(e){return e}},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(0),i=r(9),o=function(){return function(e){this.columns=[],this.query=null,this.queryColumns=[],this.parent=null,this.limit=null,this.onAdd=i.c,this.onRemove=i.c,this.onChange=i.c,this.custom=null,this.callOnAddWithInitialItems=!1,Object(n.eb)(this,e)}}()},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n=function(){function e(e,t,r){this.errorHandler=e,this.exceptionHandler=t,this.promiseService=r,this.callbacks={onBeforeSave:[],onSaveSuccess:[],onSetItemError:[],onClearItemError:[],onSetGlobalError:[],onClearGlobalError:[]}}return e.prototype.registerCallback=function(e,t,r,n,i){var o=this;return void 0===n&&(n="always"),void 0===i&&(i=100),this.getPriorityLevel(e,i)[t]={callback:r,condition:n},function(){delete o.getPriorityLevel(e,i)[t]}},e.prototype.executeCallbacks=function(e,t,r){for(var n=this.callbacks[e],i=r?"onClose":"skipOnClose",o=this.promiseService.when(),s=0,a=n;s<a.length;s++){var c=a[s];o=o.then(this.executeCallbacksPriorityLevel(c[1],i,t),this.errorHandler.reject)}return o},e.prototype.getPriorityLevel=function(e,t){for(var r,n=this.callbacks[e],i=0;i<n.length;i++){var o=n[i];if(!(o[0]<t))return o[0]===t?o[1]:(r={},n.splice(i,0,[t,r]),r)}return r={},n.push([t,r]),r},e.prototype.executeCallbacksPriorityLevel=function(e,t,r){var n=this;return function(){var i={};for(var o in e){var s=e[o];if(s.condition===t||"always"===s.condition)try{i[o]=r(s.callback)}catch(e){n.exceptionHandler(e)}}return n.promiseService.all(i)}},e}()},function(e,t,r){"use strict";r.d(t,"b",function(){return n}),r.d(t,"a",function(){return m});var n,i=r(3),o=r(0),s=r(9),a=r(5),c=r(10),u=r(8),l=r(1),h=r(13),d=r(18),p=r(11);!function(e){e.warning="warning",e.error="error"}(n||(n={}));var m=function(e){function t(t,r,n,i,s){var a=e.call(this,t,r)||this;return a.id=i,a.errors={item:{},global:{}},a.tabRequestParameters={},a.isSaving=!1,a.hasChanges=!1,a.changesInterval=null,a._isValid=!0,a.validator=void 0===s?void 0:s.construct(a),a.parent=n,a.itemHandler=new o.S(t,a,a.validator),a.cachedQueryHandler=new d.a(t,a.itemHandler,a),a.collectionHandler=new o.P(a.itemHandler,a.cachedQueryHandler,a.dependencies,a),a.eventHandler=new p.a(t.errorHandler,t.exceptionHandler,t.promiseService),a}return Object(i.b)(t,e),Object.defineProperty(t.prototype,"isValid",{get:function(){return(void 0===this.validator||!this.validator.isPending())&&this._isValid},enumerable:!0,configurable:!0}),t.prototype.createChild=function(e,r){var n=new t(this.dependencies,this.core,this,e,r);return this.children.push(n),n},t.prototype.destroy=function(){this.parent.onChildDestroy(this)},t.prototype.expandCollectionResource=function(e,t){var r,n=this,i=null===(r=this.cachedQueryHandler.cachedQueries[e.entry.itemType])||void 0===r?void 0:r[e.entry.query.string];return void 0===i?this.collectionHandler.expandCollectionResource(e,t):this.cachedQueryHandler.__expandCachedQuery(i,t).then(function(){e.entry.columns=n.dependencies.columnSetFactory.construct(i.itemType,i.requestColumns,n.dependencies.columnCache.retrieve(i.itemType,i.requestColumns).cached)},this.dependencies.errorHandler.reject)},t.prototype.expandCollectionResources=function(e,t,r){var n=this;if(!Object(l.i)(t))return this.dependencies.promiseService.when(t);var i=[],o=[];for(var s in t)for(var a=0,c=t[s].items;a<c.length;a++){var u=c[a];u.entry.isLocal()?i.push(u.entry):o.push(u.entry)}return(0===o.length?this.dependencies.columnHandler.fetch(e,r):this.getServerCache().itemHandler.extendItemEntries(e,o,r)).then(function(){if(0===i.length)return n.dependencies.promiseService.when();var t=n.createChangesDelta();return n.itemHandler.expandLocalItemEntries(t,e,i,r,n.dependencies.columnCache.retrieve(e,r).cached).then(function(){return n.applyChangesDelta(t)},n.dependencies.errorHandler.reject)},this.dependencies.errorHandler.reject).then(function(){var i,o=n.dependencies.columnExpansionFactory.construct(e,r,n.dependencies.columnCache.retrieve(e,r).cached);for(var s in t){var a=t[s].entry,c=null===(i=n.cachedQueryHandler.cachedQueries[a.itemType])||void 0===i?void 0:i[a.query.string];void 0!==c&&(c.requestColumns=n.dependencies.columnUtil.mergeRequestColumns(c.requestColumns,r).merged),a.expandColumns(o)}return t},this.dependencies.errorHandler.reject)},t.prototype.registerFieldChangeCallback=function(e,t,r){return this.itemHandler.registerFieldChangeCallback(e,t,r)},t.prototype.createChangesDelta=function(){return this.dependencies.changesDeltaFactory.construct()},t.prototype.getFirstErrorString=function(){for(var e in this.errors.global){if((s=this.errors.global[e]).level===n.error)return s.string}for(var t in this.errors.item){var r=this.errors.item[t];for(var i in r){var o=r[i];for(var e in o){var s;if((s=o[e]).level===n.error)return s.string}}}},t.prototype._setGlobalError=function(e,t,r,n){t?(this.errors.global[e]={string:r(),level:n},this.eventHandler.executeCallbacks("onSetGlobalError",function(t){return t(e,n)},!1),this._setIsValid()):this.clearGlobalError(e)},t.prototype._setItemError=function(e,t,r,n,i,s,a){n?(Object(o.V)(this.errors.item,[e,t,r],[{},{},{fieldString:i(),string:s(),level:a}]),this.eventHandler.executeCallbacks("onSetItemError",function(n){return n(e,t,r)},!1),this._setIsValid()):this.clearItemError(e,t,r)},t.prototype._setIsValid=function(){for(var e in this._isValid=!0,this.errors.global){if(this.errors.global[e].level===n.error)return void(this._isValid=!1)}for(var t in this.errors.item){var r=this.errors.item[t];for(var i in r){var o=r[i];for(var e in o){if(o[e].level===n.error)return void(this._isValid=!1)}}}},t.prototype.applyChangesFromParent=function(e,t,r){var n=this;void 0===t&&(t=!1),void 0===r&&(r=!1);var i=this.core.changesDeltaFactory.constructInternalDelta();for(var o in e.updated){var s=e.updated[o];null!==this.itemHandler.processItemEntryChanges(s,t,!0,r)&&i.setItemUpdated(s.entry,s.changes.fields,s.changes.expandedColumns)}for(var a in e.deleted)for(var c=0,u=e.deleted[a];c<u.length;c++){var l=u[c];if(this.itemHandler.entries.clear(l),delete this.itemHandler.itemChanges[l.id],this.clearItemError(l.id),i.setItemDeleted(l),void 0!==this.itemHandler.deletedItems[l.itemType]){var h=this.itemHandler.deletedItems[l.itemType].indexOf(l);-1!==h&&this.itemHandler.deletedItems[l.itemType].splice(h,1)}}return this.core.collectionMatcherFactory.constructCachedQueryProcessor(this,function(e){return n.cachedQueryHandler.getCachedQueryObjectsByItemType(e)}).processDelta(i).__removeFromAndAddToCachedQueries(r,i).then(function(){return n.core.collectionMatcherFactory.constructCachedCollectionProcessor(n,function(e){return n.collectionHandler.collectionResources[e]}).processDelta(i).__removeFromAndAddToCollections(r,i)}).then(function(){for(var t=0,r=n.children;t<r.length;t++){r[t].applyChangesFromParent(e)}n.hasChanges=!1,n.detectChanges(),void 0!==n.validator&&(n.clearGlobalError(),n.validator.validateTransaction())})},t.prototype.applyChangesDelta=function(t){var r=this;return t.isEmpty()?this.dependencies.promiseService.when({created:[],rollback:s.c}):this.fetchUpdatedDerivedValuesFromDelta(t).then(function(){var n=e.prototype._applyChangesDelta.call(r,t),i=n.result,o=n.matchingDelta,s=n.internalChangesDelta,a=n.rollbackFunctions;for(var c in t.deleted)for(var u=function(e){r.itemHandler.entries.clear(e);var n=r.itemHandler.itemChanges[e.id];delete t.updated[e.id],delete r.itemHandler.itemChanges[e.id],void 0===r.itemHandler.deletedItems[e.itemType]&&(r.itemHandler.deletedItems[e.itemType]=[]),r.itemHandler.deletedItems[e.itemType].push(e),s.setItemDeleted(e),o.setItemDeleted(e),r.clearItemError(e.id),a.push(function(t){t.setItemUpdated(e,n.changes)})},l=0,h=t.deleted[c];l<h.length;l++){u(h[l])}return r.core.collectionMatcherFactory.constructCachedQueryProcessor(r,function(e){return r.cachedQueryHandler.getCachedQueryObjectsByItemType(e)}).processDelta(o).__removeFromAndAddToCachedQueries(!1,o).then(function(){return r.core.collectionMatcherFactory.constructCachedCollectionProcessor(r,function(e){return r.collectionHandler.collectionResources[e]}).processDelta(o).__removeFromAndAddToCollections(!1,o)}).then(function(){for(var e=0,t=r.children;e<t.length;e++){t[e].applyChangesFromParent(s)}return r.hasChanges=!1,r.detectChanges(),void 0!==r.validator&&r.validator.validateTransaction(),i})})},t.prototype.getServerCache=function(){return this.parent.getServerCache()},t.prototype.getParent=function(e,t,r){var n;if(void 0===t&&(t=!1),void 0!==r)n=r;else{var i=this.itemHandler.itemChanges[e.id];void 0!==i&&(n=i[t?"initial":"changes"])}if(void 0!==n){var o=this.getParentFromFields(e,n);if(null!==o)return o}return this.parent.getParent(e,t)},t.prototype.getCollectionChangesRecursively=function(e,t){var r,n=null===(r=this.cachedQueryHandler.cachedQueries[e])||void 0===r?void 0:r[t.string];if(void 0===n){if(void 0===(n=this.parent.getCollectionChangesRecursively(e,t)))return;this.cachedQueryHandler.setCachedQuery(e,t,n.items.slice(),!0===n.requestColumns||n.requestColumns.slice()).resolve()}return n},t.prototype.getItemChangesRecursively=function(e,t){void 0===t&&(t=!0);var r=this.itemHandler.itemChanges[e],n=this.getLocalItemEntry(e);return void 0!==r&&void 0!==n?t?this.dependencies.apiFormatter.copyFields(r.changes,{},n.columns.main):r.changes:this.parent.getItemChangesRecursively(e,t)},t.prototype.clearCollectionResource=function(e){return this.collectionHandler.clearResource(e)},t.prototype.isLockable=function(){return void 0!==this.rootItem&&this.rootItem.isLockable()},t.prototype.disableChangesWatcher=function(){null!==this.changesInterval&&(clearInterval(this.changesInterval),this.changesInterval=null)},t.prototype.enableChangesWatcher=function(){var e=this;null!==this.changesInterval&&(console.warn("Changes watcher already running!",this),this.disableChangesWatcher()),this.changesInterval=window.setInterval(function(){e.detectChanges()&&(e.disableChangesWatcher(),e.isLockable()&&e.dependencies.lockService.fetchLock(e.rootItem))},3e3)},t.prototype.save=function(e,t,r,n){var o,s=this;return void 0===e&&(e=!1),void 0===t&&(t={}),this.isSaving?this.dependencies.errorHandler.reject():(this.isSaving=!0,this.detectChanges(),this.disableChangesWatcher(),(this.isLockable()?this.dependencies.lockService.fetchLock(this.rootItem):this.dependencies.promiseService.when()).then(function(){return s.eventHandler.executeCallbacks("onBeforeSave",function(e){return e(s)},e)},this.dependencies.errorHandler.reject).then(function(){return s.tabRequestParameters=Object(i.a)(Object(i.a)({},s.tabRequestParameters),t),s.parent.applyChangesFromChild(s,r,n)}).then(function(t){return o=t,s.tabRequestParameters={},s.isLockable()&&s.dependencies.lockService.clearLock(s.rootItem),s.hasChanges=!1,s.eventHandler.executeCallbacks("onSaveSuccess",function(e){return e(s,o)},e)},this.dependencies.errorHandler.reject).then(function(){return e||s.enableChangesWatcher(),s.isSaving=!1,o},this.dependencies.errorHandler.reject).catch(function(e){return s.isSaving=!1,s.dependencies.errorHandler.reject(e)}))},t.prototype.detectChanges=function(){return!!this.hasChanges||(this.itemHandler.detectChanges()?this.hasChanges=!0:this.hasChanges=!1)},t.prototype.clearItem=function(e){this.clearItemEntry(e.entry)},t.prototype.clearItemEntry=function(e){return this.itemHandler.clearItemEntry(e)},t.prototype.onBeforeSave=function(e,t,r,n){return this.eventHandler.registerCallback("onBeforeSave",e,t,r,n)},t.prototype.onSaveSuccess=function(e,t,r,n){return this.eventHandler.registerCallback("onSaveSuccess",e,t,r,n)},t.prototype.getModuleChanges=function(){if(void 0===this.rootItem)throw new Error("No root item for transaction cache "+this);return this.dependencies.moduleChangesCompilationFactory.construct(this).process()},t.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])}},t.prototype.getAllLinkCollections=function(e,t,r){var n,i=this;return this.dependencies.apiRequestService.query(e,{},(n={},n[e]=["id"],n)).then(function(n){return i.getLinkCollections(e,n.links[e],t,r)},this.dependencies.errorHandler.reject)},t.prototype.getLinkCollectionsFromDef=function(e,t,r){var n=this;return this.cachedQueryHandler.__fetchLinkedCachedQueryItems(e,t,r.itemType,r.options).then(function(t){var i={};for(var o in t){var s=t[o],a=n.core.collectionEntryService.cloneOptions(r.options,{itemType:e,itemId:Number(o)});a.columns=s.requestColumns,i[o]=n.createCollectionResource(r.itemType,a,s.items)}return i},this.dependencies.errorHandler.reject)},t.prototype.getLinkCollections=function(e,t,r,n){var i=this,o=new c.a(n);return this.cachedQueryHandler.__fetchLinkedCachedQueryItems(e,t,r,o).then(function(t){var n={};for(var s in t){var a=t[s],c=i.core.collectionEntryService.cloneOptions(o,{itemType:e,itemId:Number(s)});c.columns=a.requestColumns,n[s]=i.createCollectionResource(r,c,a.items)}return n},this.dependencies.errorHandler.reject)},t.prototype.getCollectionFromDef=function(e){var t=this;return this.cachedQueryHandler.__fetchCachedQueryItem(e.itemType,e.options).then(function(r){return t.createCollectionResource(e.itemType,e.options,r.items)},this.dependencies.errorHandler.reject)},t.prototype.getCollection=function(e,t){var r=this;return this.cachedQueryHandler.__fetchCachedQueryItem(e,new c.a(t)).then(function(n){return r.createCollectionResource(e,t,n.items)},this.dependencies.errorHandler.reject)},t.prototype.getCollectionDef=function(e,t){return{itemType:e,options:new c.a(t)}},t.prototype.getLinkCollectionsDef=function(e,t,r){return{itemType:e,linkField:t,options:new c.a(r)}},t.prototype.getItemByState=function(e,t,r,n){void 0===r&&(r={});var i=this.dependencies.keyService.parseStateKey(t);if(null===i){var o=t;if(!this.dependencies.keyService.isLocalId(o)||void 0!==this.getLocalItemEntryByItemId(e,o))return this.getItemById(e,o,r,n)}else if(i.type===u.StateKeyType.Duplicate)return this.getDuplicateById(e,i.itemId,r,!1,n);return this.getNewResource(e,r,!1,n)},t.prototype.getDuplicateById=function(e,t,r,n,i){return void 0===r&&(r={}),void 0===r.templateOptions&&(r.templateOptions={}),void 0===r.templateOptions.item&&(r.templateOptions.item=t),this.getNewResourceWithId(e,this.dependencies.keyService.getLocalDuplicateId(),r,n,i)},t.prototype.getNewResourceWithId=function(e,t,r,n,i){var o=this;return void 0===n&&(n=!1),this.itemHandler.fetchNewItemEntry(e,t,new a.e(r)).then(function(r){for(var s,a={},c=0,u=r.created;c<u.length;c++){var l=u[c];l.itemType!==e||l.itemId!==t?(void 0===a[l.itemType]&&(a[l.itemType]=[]),a[l.itemType].push(l)):s=l}if(void 0===s)throw new Error("The ItemEntry with the requested ItemId was not in the template response");var h=o.createItemResource(s,i,!0);return n?{main:h,linked:o.processLinkedItems(a)}:h},this.dependencies.errorHandler.reject)},t.prototype.getNewResource=function(e,t,r,n){return void 0===t&&(t={}),this.getNewResourceWithId(e,this.dependencies.keyService.getLocalId(),t,r,n)},t.prototype.getItemsByQuery=function(e,t,r){var n=this;return void 0===r&&(r={}),this.cachedQueryHandler.__fetchCachedQueryItem(e,new c.a({query:t,parent:r.parent,columns:r.columns})).then(function(e){return n.createItemResources(e.items)},this.dependencies.errorHandler.reject)},t.prototype.getItemsById=function(e,t,r){var n=this;return void 0===r&&(r={}),this.itemHandler.fetchItemEntries(e,t,new a.e(r)).then(function(e){return n.createItemResources(e)},this.dependencies.errorHandler.reject)},t.prototype.getItemById=function(e,t,r,n){var i=this;return void 0===r&&(r={}),this.itemHandler.fetchItemEntry(e,t,new a.e(r)).then(function(e){return i.createItemResource(e,n)},this.dependencies.errorHandler.reject)},t.prototype.fetchTitle=function(e,t){return this.itemHandler.fetchTitle(e,t)},t.prototype.applyChangesFromChild=function(e,t,r){var n=this,i=this.dependencies.linkTreeService.get(),o=e.getDelta();for(var s in o.moved){var a=o.moved[s];o.setItemUpdated(a.entry,{},null,a.to),delete o.moved[s]}for(var s in o.updated){a=o.updated[s];void 0===this.itemHandler.itemChanges[s]?this.itemHandler.itemChanges[s]=this.itemHandler.copyTransactionItemEntryChanges(e.itemHandler.itemChanges[s],a.entry):this.itemHandler.processItemEntryChanges(a,!0)}for(var s in o.created){a=o.created[s];this.itemHandler.entries.add(a.entry),e.itemHandler.entries.clear(a.entry);var c=this.itemHandler.itemChanges[a.entry.id]=this.itemHandler.copyTransactionItemEntryChanges(e.itemHandler.itemChanges[s],a.entry),l=this.dependencies.itemEntryService.getDisplayName(a.entry,c.changes);if(void 0!==l&&(c.changes.displayname=l),void 0!==this.rootItem){var h=i[this.rootItem.itemType][a.entry.itemType];void 0!==h&&(h.type===u.ApiLinkTreeType.ITEMTABLE?(c.changes.itemtype=this.rootItem.itemType,c.changes.item=this.rootItem.itemId):h.type===u.ApiLinkTreeType.DIRECT&&(c.changes[h.field]=this.rootItem.itemId))}}for(var d in o.deleted){void 0===this.itemHandler.deletedItems[d]&&(this.itemHandler.deletedItems[d]=[]);for(var p=0,m=o.deleted[d];p<m.length;p++){var f=m[p];f.isLocal()||(this.itemHandler.entries.clear(f),this.itemHandler.deletedItems[d].push(f),this.clearItemError(f.id))}}return this.hasChanges=!0,this.expandItemsFromDelta(o).then(function(){return n.core.collectionMatcherFactory.constructCachedQueryProcessor(n,function(e){return n.cachedQueryHandler.getCachedQueryObjectsByItemType(e)}).processDelta(o).__removeFromAndAddToCachedQueries(!1,o)}).then(function(){return n.core.collectionMatcherFactory.constructCachedCollectionProcessor(n,function(e){return n.collectionHandler.collectionResources[e]}).processDelta(o).__removeFromAndAddToCollections(!1,o)}).then(function(){for(var t=0,r=n.children;t<r.length;t++){var i=r[t];i!==e&&i.applyChangesFromParent(o)}return void 0!==n.validator&&n.validator.validateTransaction(),o.itemIdConversionMap})},t.prototype.getLocalItemEntryChangesTuple=function(e){var t=this.getLocalItemEntry(e);if(void 0===t)throw new Error("Tried to get a local ItemEntry with entryId '"+e+"' but couldn't find it");return{entry:t,changes:this.itemHandler.itemChanges[e]}},t.prototype.getLocalItemEntry=function(e){var t=this.itemHandler.entries.getByEntryId(e);return void 0!==t?t:this.parent.getLocalItemEntry(e)},t.prototype.getLocalItemEntryByItemId=function(e,t){var r=this.itemHandler.entries.get(e,t);return void 0!==r?r:this.parent.getLocalItemEntryByItemId(e,t)},t.prototype.getDelta=function(){var e=this.dependencies.changesDeltaFactory.constructInternalDelta();for(var t in this.itemHandler.itemChanges){var r=this.getLocalItemEntryChangesTuple(Number(t));if(this.itemHandler.entries.contains(r.entry.itemType,r.entry.itemId)&&r.entry.isLocal())r.entry.itemId=r.changes.changes.id,e.setItemCreated(r.entry,r.changes.changes);else{var n=this.getParent(r.entry);if(null!==n){var i=this.getParent(r.entry,!0);this.dependencies.itemEntryService.matchParent(i,n)||e.setItemMoved(r.entry,n)}this.dependencies.apiFormatter.hasChanges(r.changes.initial,r.changes.changes,r.entry.columns.main)&&e.setItemUpdated(r.entry,r.changes.changes)}}for(var o in this.itemHandler.deletedItems)e.setItemsDeleted(this.itemHandler.deletedItems[o]);return e},t.prototype.createItemResource=function(e,t,r){return void 0===t&&(t=!1),t&&(this.rootItem=e),void 0===this.itemHandler.itemChanges[e.id]&&(this.itemHandler.itemChanges[e.id]={initial:this.getItemChangesRecursively(e.id),changes:this.getItemChangesRecursively(e.id)}),this.dependencies.itemResourceFactory.construct(e,this,r)},t.prototype.createItemResources=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];void 0===this.itemHandler.itemChanges[i.id]&&(this.itemHandler.itemChanges[i.id]={initial:this.getItemChangesRecursively(i.id,!0),changes:this.getItemChangesRecursively(i.id,!0)});var o=this.dependencies.itemResourceFactory.construct(i,this);t.push(o)}return t},t.prototype.processLinkedItems=function(e){var t={};for(var r in e)t[r]=this.createItemResources(e[r]);return t},t.prototype.createCollectionResource=function(e,t,r){var n=this.dependencies.collectionResourceFactory.construct(e,t,this,r);return this.collectionHandler.addResource(n),n},t.prototype.getChangesFromItemChanges=function(e){return e.changes},t.prototype.expandItemsFromDelta=function(e){var t={},r={},n=function(e){void 0===t[e.itemType]&&(t[e.itemType]=[]),t[e.itemType].push(e)};for(var i in e.created)n(e.created[i].entry);for(var i in e.updated)n(e.updated[i].entry);for(var o in t){var s=this.cachedQueryHandler.cachedQueries[o];if(void 0!==s){var a=this.dependencies.requestColumnExpansionFactory.construct();for(var c in s){var u=s[c];a.expandWithRequestColumns(u.itemType,u.requestColumns)}r[o]=a.get()[o]}}var l=[];for(var o in r)l.push(this.itemHandler.expandLocalItemEntries(e,o,t[o],r[o],this.dependencies.columnCache.retrieve(o,r[o]).cached));return this.dependencies.promiseService.all(l)},t.prototype.clearGlobalError=function(e){var t=this,r=function(e){t.eventHandler.executeCallbacks("onClearGlobalError",function(t){return t(e)},!1)};if(void 0===e){for(var n in this.errors.global)r(n);this.errors.global={}}else r(e),delete this.errors.global[e];this._setIsValid()},t.prototype.clearItemError=function(e,t,r){var n,i,o=this,s=function(e,t,r){var n,i;o.eventHandler.executeCallbacks("onClearItemError",function(n){return n(e,t,r)},!1),void 0!==(null===(i=null===(n=o.errors.item[e])||void 0===n?void 0:n[t])||void 0===i?void 0:i[r])&&delete o.errors.item[e][t][r]};if(void 0===e){for(var a in this.errors.item){var c=this.errors.item[a];for(var u in c){var h=c[u];for(var d in h)s(Number(a),u,d)}}return this.errors.item={},void this._setIsValid()}if(void 0===t){c=this.errors.item[e];for(var u in c){h=c[u];for(var d in h)s(Number(e),u,d)}return delete this.errors.item[e],void this._setIsValid()}if(void 0!==this.errors.item[e]){if(void 0===r){h=this.errors.item[e][t];for(var d in h)s(Number(e),t,d);return delete this.errors.item[e][t],Object(l.i)(this.errors.item[e])||this.clearItemError(e),void this._setIsValid()}s(e,t,r),void 0!==(null===(i=null===(n=this.errors.item[e])||void 0===n?void 0:n[t])||void 0===i?void 0:i[r])&&delete this.errors.item[e][t][r],Object(l.i)(this.errors.item[e][t])||this.clearItemError(e,t),this._setIsValid()}else this._setIsValid()},t}(h.a)},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=r(17),i=function(){function e(e,t){this.dependencies=e,this.core=t,this.children=[]}return e.prototype.onChildDestroy=function(e){var t=this.children.indexOf(e);-1!==t&&this.children.splice(t,1)},e.prototype.getTransactionChain=function(){var e=[],t=this;do{e.push(t),t=t.parent}while(null!==t);return e},e.prototype.getCurrentItemEntryCache=function(){return this.itemHandler.entries},e.prototype.getParentFromFields=function(e,t){if(void 0===t)return null;if(null!==e.columns.link)return{itemType:e.columns.link.apiColumn.itemType,itemId:t[e.columns.link.id]};var r=e.columns.response[e.itemType];return void 0!==r.itemtype&&void 0!==r.item?{itemType:t.itemtype,itemId:t.item}:null},e.prototype._applyChangesDelta=function(e){var t=this,r=this.dependencies.changesDeltaFactory.constructInternalDelta(),i=this.dependencies.changesDeltaFactory.constructInternalDelta();for(var o in e._queryResults)for(var s in e._queryResults[o])r._setQueryResult(o,s,e._queryResults[o][s]),i._setQueryResult(o,s,e._queryResults[o][s]);var a=[],c=[];e.created.forEach(function(n){var o=t.getLocalItemEntryByItemId(n.columns.itemType,n.itemId);if(void 0!==o)return e.setItemUpdated(o,n.fields,t.core.columnExpansionFactory.construct(n.columns.itemType,!!n.columns.requestColumnsTrue||n.columns.request,n.columns.response).run(o.columns)),void e.created.remove(o.itemType,o.itemId);var s=t.itemHandler.createItemEntry(n),u=t.getChangesFromItemChanges(t.itemHandler.itemChanges[s.id]);a.push(s),r.setItemCreated(s,u),i.setItemCreated(s,u),c.push(function(e){return e.setItemDeleted(s)})});var u=function(t){var o=e.updated[t],s=l.itemHandler.processItemEntryChanges(o,!0,!1,!1,!0);if(r.setItemUpdated(o.entry,o.changes.fields,o.changes.expandedColumns),null!==s&&(i.setItemUpdated(o.entry,o.changes.fields,o.changes.expandedColumns),c.push(function(e){return e.setItemUpdated(o.entry,s)})),null!==o.changes.parent&&(r.setItemMoved(o.entry,o.changes.parent),i.setItemMoved(o.entry,o.changes.parent)),l.itemHandler instanceof n.a){var a=l.itemHandler.deletedItems[o.entry.itemType];if(void 0===a)return"continue";var u=a.indexOf(o.entry);u>-1&&a.splice(u,1)}},l=this;for(var h in e.updated)u(h);return{result:{created:a,rollback:function(){for(var e=t.dependencies.changesDeltaFactory.construct(),r=0,n=c;r<n.length;r++){(0,n[r])(e)}return t.applyChangesDelta(e)}},matchingDelta:i,internalChangesDelta:r,rollbackFunctions:c}},e.prototype.fetchUpdatedDerivedValuesFromDelta=function(e){var t=[];for(var r in e.updated){for(var n=e.updated[r],i=[],o=0,s=n.entry.columns.root;o<s.length;o++){var a=s[o];n.changes.fields.hasOwnProperty(a.id)&&n.changes.fields[a.id]!==this.getChangesFromItemChanges(this.itemHandler.itemChanges[n.entry.id])[a.id]&&i.push(a)}0!==i.length&&t.push(this.itemHandler.resolveDerivedValues([n.entry],i,e))}return this.dependencies.promiseService.all(t)},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=r(1),i=function(){function e(e){this.itemEntryService=e,this.updated={},this.deleted={},this._queryResults={}}return e.prototype._setQueryResult=function(e,t,r){void 0===this._queryResults[e]&&(this._queryResults[e]={}),this._queryResults[e][t]=r},e.prototype.setItemUpdated=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null),void 0===this.updated[e.id]&&(this.updated[e.id]={entry:e,changes:{fields:{},expandedColumns:null,parent:n}});var i=this.updated[e.id];if(null!==n){var o=this.itemEntryService.getLinkFieldsByParent(n,e.itemType);for(var s in o)t[s]=o[s]}for(var a in t){var c=Object.getOwnPropertyDescriptor(t,a);void 0!==c?Object.defineProperty(i.changes.fields,a,c):i.changes.fields[a]=t[a]}return null!==r&&(i.changes.expandedColumns=r),this},e.prototype.setItemDeleted=function(e){return this.setItemsDeleted([e])},e.prototype.setItemsDeleted=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];void 0===this.deleted[n.itemType]&&(this.deleted[n.itemType]=[]),this.deleted[n.itemType].indexOf(n)>-1||this.deleted[n.itemType].push(n)}return this},e.prototype.isEmpty=function(){return!Object(n.i)(this.updated)&&!Object(n.i)(this.deleted)},e}()},function(e,t,r){"use strict";r.r(t);var n=r(9);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(4);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.g}),r.d(t,"NEW_PREFIX",function(){return i.f}),r.d(t,"DUPLICATE_PREFIX",function(){return i.d}),r.d(t,"NEW_KEYWORD",function(){return i.e}),r.d(t,"DUPLICATE_KEYWORD",function(){return i.c});var o=r(5);r.d(t,"ItemEntryOptions",function(){return o.e}),r.d(t,"ItemEntry",function(){return o.d}),r.d(t,"ItemResource",function(){return o.f}),r.d(t,"CollectionOptions",function(){return o.b}),r.d(t,"CollectionEntry",function(){return o.a}),r.d(t,"CollectionResource",function(){return o.c}),r.d(t,"Template",function(){return o.g});var s=r(32);for(var a in s)["RmCore","noop","identity","ALL_PERMISSIONS","COLUMN_SEPERATOR","RENDER_AS_SEPERATOR","NEW_PREFIX","DUPLICATE_PREFIX","NEW_KEYWORD","DUPLICATE_KEYWORD","ItemEntryOptions","ItemEntry","ItemResource","CollectionOptions","CollectionEntry","CollectionResource","Template","default"].indexOf(a)<0&&function(e){r.d(t,e,function(){return s[e]})}(a);var c=r(0);r.d(t,"ApiFormatter",function(){return c.b}),r.d(t,"ApiRequestService",function(){return c.c}),r.d(t,"ApiResponseProcessor",function(){return c.d}),r.d(t,"ChangesCompilation",function(){return c.f}),r.d(t,"ChangesProcessor",function(){return c.i}),r.d(t,"CollectionEntryService",function(){return c.j}),r.d(t,"CollectionMatcherCachedCollectionProcessor",function(){return c.k}),r.d(t,"CollectionResourceService",function(){return c.l}),r.d(t,"ColumnCache",function(){return c.m}),r.d(t,"ColumnExpansion",function(){return c.n}),r.d(t,"ColumnHandler",function(){return c.o}),r.d(t,"ColumnInfo",function(){return c.p}),r.d(t,"ColumnSet",function(){return c.q}),r.d(t,"ColumnSubsetCache",function(){return c.r}),r.d(t,"ColumnUtil",function(){return c.s}),r.d(t,"ConversionMapService",function(){return c.t}),r.d(t,"CreateRequest",function(){return c.u}),r.d(t,"ItemCache",function(){return c.x}),r.d(t,"ItemEntryService",function(){return c.z}),r.d(t,"KeyService",function(){return c.A}),r.d(t,"TransactionEventHandler",function(){return c.R}),r.d(t,"LockService",function(){return c.B}),r.d(t,"ModuleChangesCompilation",function(){return c.C}),r.d(t,"QueryMatcher",function(){return c.D}),r.d(t,"CONSTANTS",function(){return c.e}),r.d(t,"QueryParser",function(){return c.E}),r.d(t,"QueryService",function(){return c.F}),r.d(t,"RequestColumnExpansion",function(){return c.I}),r.d(t,"SocketMessageHandler",function(){return c.M}),r.d(t,"instantiateOptions",function(){return c.eb}),r.d(t,"shallowMerge",function(){return c.ub}),r.d(t,"hasProperties",function(){return c.cb}),r.d(t,"getFirstProperty",function(){return c.ab}),r.d(t,"inArray",function(){return c.db}),r.d(t,"filterArray",function(){return c.Z}),r.d(t,"emptyArray",function(){return c.W}),r.d(t,"pathExists",function(){return c.tb}),r.d(t,"createPath",function(){return c.V}),r.d(t,"getPath",function(){return c.bb}),r.d(t,"extend",function(){return c.Y}),r.d(t,"merge",function(){return c.sb}),r.d(t,"isObject",function(){return c.nb}),r.d(t,"isBlankObject",function(){return c.gb}),r.d(t,"isString",function(){return c.qb}),r.d(t,"isNumber",function(){return c.mb}),r.d(t,"isDate",function(){return c.ib}),r.d(t,"isArray",function(){return c.fb}),r.d(t,"isFunction",function(){return c.lb}),r.d(t,"isPromiseLike",function(){return c.ob}),r.d(t,"isRegExp",function(){return c.pb}),r.d(t,"isBoolean",function(){return c.hb}),r.d(t,"isElement",function(){return c.kb}),r.d(t,"isWindow",function(){return c.rb}),r.d(t,"isDefined",function(){return c.jb}),r.d(t,"equals",function(){return c.X}),r.d(t,"copy",function(){return c.U}),r.d(t,"AbstractCache",function(){return c.a}),r.d(t,"ServerCache",function(){return c.J}),r.d(t,"ServerItemHandler",function(){return c.L}),r.d(t,"ServerCachedQueryHandler",function(){return c.K}),r.d(t,"TransactionErrorLevel",function(){return c.Q}),r.d(t,"TransactionCache",function(){return c.N}),r.d(t,"TransactionItemHandler",function(){return c.S}),r.d(t,"TransactionCachedQueryHandler",function(){return c.O}),r.d(t,"TransactionCollectionHandler",function(){return c.P}),r.d(t,"TransactionValidator",function(){return c.T}),r.d(t,"ChangesDeltaBase",function(){return c.h}),r.d(t,"ChangesDelta",function(){return c.g}),r.d(t,"InternalChangesDelta",function(){return c.w}),r.d(t,"RequestBufferManager",function(){return c.H}),r.d(t,"RequestBuffer",function(){return c.G}),r.d(t,"ItemCreateService",function(){return c.y}),r.d(t,"CreatedChangesDelta",function(){return c.v});var u=r(7);r.d(t,"ApiResponseProcessorFactory",function(){return u.a}),r.d(t,"ChangesCompilationFactory",function(){return u.b}),r.d(t,"CollectionEntryFactory",function(){return u.e}),r.d(t,"CollectionMatcherFactory",function(){return u.f}),r.d(t,"CollectionResourceFactory",function(){return u.g}),r.d(t,"ColumnExpansionFactory",function(){return u.h}),r.d(t,"ColumnInfoFactory",function(){return u.i}),r.d(t,"ColumnSetFactory",function(){return u.j}),r.d(t,"ColumnSubsetCacheFactory",function(){return u.k}),r.d(t,"CreateRequestFactory",function(){return u.l}),r.d(t,"ItemCacheFactory",function(){return u.m}),r.d(t,"ItemEntryFactory",function(){return u.n}),r.d(t,"ItemResourceFactory",function(){return u.o}),r.d(t,"TransactionCacheFactory",function(){return u.u}),r.d(t,"ModuleChangesCompilationFactory",function(){return u.p}),r.d(t,"QueryMatcherFactory",function(){return u.q}),r.d(t,"QueryParserFactory",function(){return u.r}),r.d(t,"RequestColumnExpansionFactory",function(){return u.s}),r.d(t,"TemplateFactory",function(){return u.t}),r.d(t,"ChangesDeltaFactory",function(){return u.c}),r.d(t,"ChangesProcessorFactory",function(){return u.d});var l=r(8);for(var a in l)["RmCore","noop","identity","ALL_PERMISSIONS","COLUMN_SEPERATOR","RENDER_AS_SEPERATOR","NEW_PREFIX","DUPLICATE_PREFIX","NEW_KEYWORD","DUPLICATE_KEYWORD","ItemEntryOptions","ItemEntry","ItemResource","CollectionOptions","CollectionEntry","CollectionResource","Template","ApiFormatter","ApiRequestService","ApiResponseProcessor","ChangesCompilation","ChangesProcessor","CollectionEntryService","CollectionMatcherCachedCollectionProcessor","CollectionResourceService","ColumnCache","ColumnExpansion","ColumnHandler","ColumnInfo","ColumnSet","ColumnSubsetCache","ColumnUtil","ConversionMapService","CreateRequest","ItemCache","ItemEntryService","KeyService","TransactionEventHandler","LockService","ModuleChangesCompilation","QueryMatcher","CONSTANTS","QueryParser","QueryService","RequestColumnExpansion","SocketMessageHandler","instantiateOptions","shallowMerge","hasProperties","getFirstProperty","inArray","filterArray","emptyArray","pathExists","createPath","getPath","extend","merge","isObject","isBlankObject","isString","isNumber","isDate","isArray","isFunction","isPromiseLike","isRegExp","isBoolean","isElement","isWindow","isDefined","equals","copy","AbstractCache","ServerCache","ServerItemHandler","ServerCachedQueryHandler","TransactionErrorLevel","TransactionCache","TransactionItemHandler","TransactionCachedQueryHandler","TransactionCollectionHandler","TransactionValidator","ChangesDeltaBase","ChangesDelta","InternalChangesDelta","RequestBufferManager","RequestBuffer","ItemCreateService","CreatedChangesDelta","ApiResponseProcessorFactory","ChangesCompilationFactory","CollectionEntryFactory","CollectionMatcherFactory","CollectionResourceFactory","ColumnExpansionFactory","ColumnInfoFactory","ColumnSetFactory","ColumnSubsetCacheFactory","CreateRequestFactory","ItemCacheFactory","ItemEntryFactory","ItemResourceFactory","TransactionCacheFactory","ModuleChangesCompilationFactory","QueryMatcherFactory","QueryParserFactory","RequestColumnExpansionFactory","TemplateFactory","ChangesDeltaFactory","ChangesProcessorFactory","default"].indexOf(a)<0&&function(e){r.d(t,e,function(){return l[e]})}(a)},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(3),i=r(12),o=function(e){function t(t,r,n,i,o,s){var a=e.call(this,n,i,o)||this;return a.apiRequestService=t,a.promiseService=r,a.getCollections=s,a.map={},a}return Object(n.b)(t,e),t.prototype.__removeFromAndAddToCollections=function(e,t){void 0===e&&(e=!1);var r=[],n=function(n){var s,a=o.map[n],c=o.groupItemEntries(a.matches);if(a.collectionResources.forEach(function(t){return t.removeItemResources(c.notFitting,e)}),a.collectionResources.forEach(function(t){return t.addItemResources(c.fitting,!1,e)}),c.maybe.length>0){if(o.transaction instanceof i.a)for(var u=0,l=c.maybe;u<l.length;u++){var h=l[u];o.transaction.itemHandler.detectEntryChanges(h.id)&&console.error("!! Trying to re-query 'maybe' matching results but one of the entries has changes, please report this to Martijn !!")}r.push(o.apiRequestService.query(a.itemType,a.query.object,(s={},s[a.itemType]=["id"],s)).then(function(e){void 0!==t&&t._setQueryResult(a.itemType,a.query.string,e.links[a.itemType]),a.collectionResources.forEach(function(t){return t.addItemResources(c.maybe.filter(function(t){return e.links[a.itemType].indexOf(t.itemId)>-1}))})}).then(function(){},function(){}))}},o=this;for(var s in this.map)n(s);return this.promiseService.all(r)},t.prototype._expand=function(e,t){var r=this.getCollections(e.itemType);for(var n in r){var i=r[n];if(0!==i.length){var o=i[0],s=o.entry.query,a=o.entry.itemType+"-"+n;void 0===this.map[a]&&(this.map[a]={itemType:e.itemType,query:o.entry.query,collectionResources:r[n],matches:{}});var c=this.map[a].matches;void 0===c[e.itemId]&&(c[e.itemId]={item:e,isMatch:t(e.itemType,s)})}}return this},t}(r(28).a)},function(e,t,r){"use strict";r.d(t,"a",function(){return s});var n=r(3),i=r(5),o=r(0),s=function(e){function t(t,r,n){var i=e.call(this,t.columnUtil,t.apiFormatter,t.itemEntryFactory,t.promiseService,t.errorHandler,t.requestColumnExpansionFactory,t.itemCacheFactory,r)||this;return i.dependencies=t,i.transaction=r,i.validator=n,i.deletedItems={},i.itemChanges={},i.fieldChangeCallbacks={},i}return Object(n.b)(t,e),t.prototype.registerFieldChangeCallback=function(e,t,r){Object(o.V)(this.fieldChangeCallbacks,[e,t],[{},[]]);var n=this.fieldChangeCallbacks[e][t];return n.push(r),function(){var e=n.indexOf(r);-1!==e&&n.splice(e,1)}},t.prototype.copyTransactionItemEntryChanges=function(e,t){return{initial:this.apiFormatter.copyFields(e.initial,{},t.columns.main),changes:this.apiFormatter.copyFields(e.changes,{},t.columns.main)}},t.prototype.createItemEntry=function(t){var r=e.prototype.createItemEntry.call(this,t),n=this.dependencies.itemEntryService.getLocalDefaultValues();for(var i in n)t.fields[i]=n[i];var o=this.apiFormatter.copyFields(t.fields,{},t.columns.main);return this.itemChanges[r.id]={initial:t.fields,changes:o},this.itemChanges[r.id].initial.id=r.itemId,this.itemChanges[r.id].changes.id=r.itemId,void 0!==this.validator&&this.validator.validateItem(r,t.fields,t.fields),r},t.prototype.formatRequest=function(e){var t=e.columns.main;return e.isLocal()?this.apiFormatter.formatRequestLocal(this.itemChanges[e.id].changes,t):this.apiFormatter.formatRequest(this.itemChanges[e.id].initial,this.itemChanges[e.id].changes,t)},t.prototype.detectChanges=function(){for(var e in this.entries.entriesByEntryId)return!0;for(var t in this.deletedItems)if(this.deletedItems[t].length>0)return!0;for(var r in this.itemChanges){if(this.detectEntryChanges(Number(r)))return!0}return!1},t.prototype.detectEntryChanges=function(e){var t=this.transaction.getLocalItemEntry(e),r=this.itemChanges[e];return void 0!==r&&this.apiFormatter.hasChanges(r.initial,r.changes,t.columns.main)},t.prototype.processItemEntryChanges=function(e,t,r,n,i){var o,s=this;void 0===t&&(t=!1),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=!1);var a=e.entry,c=e.changes;if(void 0===this.itemChanges[a.id]){if(!i)return null;this.itemChanges[a.id]={initial:this.transaction.getItemChangesRecursively(a.id),changes:this.transaction.getItemChangesRecursively(a.id)}}null!==c.expandedColumns&&(a.columns=c.expandedColumns.merged);var u=this.itemChanges[a.id];if(!this.apiFormatter.hasChanges(c.fields,u.changes,a.columns.main,!0))return null;var l=this.apiFormatter.copyFields(u.changes,{},a.columns.main);if(t?this.apiFormatter.copyFields(c.fields,u.changes,a.columns.main):this.apiFormatter.mergeCopyFields(u.initial,u.changes,c.fields,a.columns.main),r&&this.apiFormatter.copyFields(c.fields,u.initial,a.columns.main),void 0===c.fields.displayname){var h=this.dependencies.itemEntryService.getDisplayName(a,u.changes);void 0!==h&&(u.changes.displayname=h)}void 0!==this.validator&&this.validator.validateItem(a,u.changes,l);var d=null===(o=this.fieldChangeCallbacks[a.itemType])||void 0===o?void 0:o[a.itemId];if(void 0!==d)for(var p=0,m=d;p<m.length;p++){var f=m[p];try{f({itemEntry:a,compareField:function(e){return s.apiFormatter.compareFields(a.columns.response[a.itemType][e].type,u.changes[e],l[e])},fields:u.changes,isCalledAfterSocketUpdate:n,previous:l})}catch(e){this.dependencies.exceptionHandler(e)}}return l},t.prototype.cloneItemEntries=function(e,t,r,n){void 0===r&&(r={}),this.dependencies.conversionMapService.batchExpandConversionMap(t,r);for(var i=0,o=t;i<o.length;i++){var s=o[i];this.cloneItemEntry(e,s,r,n)}return[]},t.prototype.cloneItemEntry=function(e,t,r,n){void 0===r&&(r={});var i=this.transaction.getItemChangesRecursively(t.id),o=this.dependencies.conversionMapService.expandConversionMap(t,r),s=this.apiFormatter.copyFields(i,{},t.columns.main);return this.dependencies.conversionMapService.updateItemValues(s,s,t.columns.item,r),void 0!==n&&n(t.itemType,s),e._setItemCreated(o,s,t.columns),o},t.prototype.fetchItemEntriesByQuery=function(e,t,r){return this.transaction.getServerCache().itemHandler.fetchItemEntriesByQuery(e,t,r)},t.prototype.fetchItemEntry=function(e,t,r){var n=this;if(!this.dependencies.keyService.isLocalId(t))return this.transaction.getServerCache().itemHandler.fetchItemEntry(e,t,r);if(void 0===this.entries.get(e,t))return this.transaction.parent instanceof o.J?this.errorHandler.reject(this.dependencies.itemEntryService.createUnfoundLocalItemError(e)):this.transaction.parent.itemHandler.fetchItemEntry(e,t,r);r.columns=this.expandColumnsWithCachedQueryColumns(e,r.columns);var i=this.dependencies.changesDeltaFactory.construct(),s=this.dependencies.columnSubsetCacheFactory.construct(r.columns);return this.fetchLocalItemEntryData(i,e,t,s,r).then(function(e){return n.transaction.applyChangesDelta(i).then(function(){return e},n.errorHandler.reject)},this.errorHandler.reject)},t.prototype.fetchNewItemEntry=function(e,t,r){var n,i,o=this;return void 0!==this.entries.get(e,t)?this.errorHandler.reject(this.dependencies.itemEntryService.createExistingLocalItemError(e)):this.dependencies.templateCache.fetchTemplate(e,t,r.templateOptions,(n={},n[e]=r.columns,n),r.parent).then(function(n){if(void 0!==o.entries.get(e,t))return o.errorHandler.reject(o.dependencies.itemEntryService.createExistingLocalItemError(e));var i=o.dependencies.changesDeltaFactory.construct();return o.dependencies.itemCreateService.processTemplate(i,e,t,r.parent,n),o.transaction.applyChangesDelta(i)},this.errorHandler.reject).then(function(e){var t=(i=e).created.reduce(function(e,t){return e.hasOwnProperty(t.itemType)||(e[t.itemType]=[]),e[t.itemType].push(t),e},{}),r=o.transaction.createChangesDelta(),n=[];for(var s in t)n.push(o.resolveDerivedValues(t[s],t[s][0].columns.root,r));return o.promiseService.all(n)}).then(function(){return i})},t.prototype.fetchItemEntries=function(e,t,r){for(var n=[],i=[],o=0,s=t;o<s.length;o++){var a=s[o];this.dependencies.keyService.isLocalId(a)?i.push(a):n.push(a)}return this.promiseService.all({remote:this.transaction.getServerCache().itemHandler.fetchItemEntries(e,n,r),local:this.fetchLocalItemEntries(e,i,r)}).then(function(e){return e.remote.concat(e.local)})},t.prototype.fetchTitle=function(e,t){var r=this,n=this.dependencies.itemEntryService.getTitleField(e);return this.fetchItemEntry(e,t,new i.e({columns:[n]})).then(function(e){return r.transaction.getItemChangesRecursively(e.id,!1)[n]},this.errorHandler.reject)},t.prototype.resolveLocalItemEntry=function(e,t,r,n){var i=this;if(r.run(t.columns))return this.promiseService.when(t);var o=this.getColumnDifference(t,n.columns);return this.dependencies.columnHandler.fetch(t.itemType,o).then(function(r){return i.expandLocalItemEntries(e,t.itemType,[t],o,r)},this.errorHandler.reject).then(function(){return t},this.errorHandler.reject)},t.prototype.expandLocalItemEntries=function(e,t,r,n,i){if(0===r.length)return this.promiseService.when(r);for(var o=this.dependencies.columnExpansionFactory.construct(t,n,i),s=0,a=r;s<a.length;s++){var c=a[s],u=o.run(c.columns);null!==u&&this.expandLocalItemEntry(e,c,u)}return this.resolveDerivedValues(r,o.aggregateRootColumns(),e)},t.prototype.fetchLocalItemEntryData=function(e,t,r,n,i){var o=this.entries.get(t,r);return void 0===o?this.errorHandler.reject(this.dependencies.itemEntryService.createUnfoundLocalItemError(t)):this.resolveLocalItemEntry(e,o,n,i)},t.prototype.fetchLocalItemEntries=function(e,t,r){var n=this;r.columns=this.expandColumnsWithCachedQueryColumns(e,r.columns);for(var i=this.dependencies.changesDeltaFactory.construct(),s=this.dependencies.columnSubsetCacheFactory.construct(r.columns),a=[],c=[],u=0,l=t;u<l.length;u++){var h=l[u];if(void 0!==this.entries.get(e,h))a.push(this.fetchLocalItemEntryData(i,e,h,s,r));else{if(this.transaction.parent instanceof o.J)return this.errorHandler.reject(this.dependencies.itemEntryService.createUnfoundLocalItemError(e));c.push(h)}}if(c.length>0){if(this.transaction.parent instanceof o.J)throw new Error("Tried looking for local entries on the serverCache");a.push(this.transaction.parent.itemHandler.fetchLocalItemEntries(e,c,r))}return this.promiseService.all(a).then(function(){return n.transaction.applyChangesDelta(i).then(function(){return t.map(function(t){return n.transaction.getLocalItemEntryByItemId(e,t)})},n.errorHandler.reject)},this.errorHandler.reject)},t.prototype.getColumnDifference=function(e,t){return this.columnUtil.mergeRequestColumns(e.columns.request,t).difference},t.prototype.expandLocalItemEntry=function(e,t,r){var n=r.difference.main;if(t.columns=r.merged,0!==n.length){var i=this.getLocalValues(t,n);Object(o.cb)(i)&&e.setItemUpdated(t,i,r)}},t.prototype.getLocalValues=function(e,t){for(var r=this.transaction.getParent(e),n=this.transaction.getChangesFromItemChanges(this.itemChanges[e.id]),i={},o=0,s=t;o<s.length;o++){var a=s[o],c=a.id;if(void 0===n[c]){var u=a.apiColumn.type;i[c]="link"===u&&null!==r?r.itemId:this.apiFormatter.getDefaultValue(u)}}return i},t}(r(27).a)},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(3),i=r(15),o=function(e){function t(t,r,n){var i=e.call(this,t.collectionEntryService,t.columnUtil,t.requestColumnExpansionFactory,t.promiseService,n)||this;return i.dependencies=t,i.itemHandler=r,i.transaction=n,i}return Object(n.b)(t,e),t.prototype.__fetchCachedQueryItem=function(e,t){var r=this.collectionEntryService.createQueryFromOptions(t);this.expandColumnsWithQueryColumns(e,t,r.object);var n=this.dependencies.columnSubsetCacheFactory.construct(t.columns);return this.__fetchItemEntriesByQueryData(e,t,n,r)},t.prototype.__expandCachedQuery=function(e,t){var r=this,n=this.columnUtil.mergeRequestColumns(e.requestColumns,t).difference;if(!0!==n&&0===n.length)return this.dependencies.promiseService.when(e);for(var i=e.itemType,o=[],s=[],a=[],c=0,u=e.items;c<u.length;c++){var l=u[c];l.isLocal()?s.push(l):a.push(l)}if(a.length>0&&o.push(this.transaction.getServerCache().cachedQueryHandler.__expandCachedQuery(e,t)),s.length>0){var h=this.dependencies.changesDeltaFactory.constructInternalDelta();o.push(this.dependencies.columnHandler.fetch(i,n).then(function(e){return r.itemHandler.expandLocalItemEntries(h,i,s,n,e)},this.dependencies.errorHandler.reject).then(function(){return r.transaction.applyChangesFromParent(h)},this.dependencies.errorHandler.reject))}return this.dependencies.promiseService.all(o).then(function(){return e.requestColumns=r.columnUtil.mergeRequestColumns(e.requestColumns,t).merged,e},this.dependencies.errorHandler.reject)},t.prototype.__addItemEntriesToCachedQueries=function(t,r,n){e.prototype.__addItemEntriesToCachedQueries.call(this,t,r,n,function(){return!1})},t.prototype.isLocal=function(e,t){var r=e.parent;return null===r?this.dependencies.queryService.containsLocalLinkedTo(t):this.dependencies.keyService.isLocalId(r.itemId)},t.prototype.__fetchItemEntriesByQueryData=function(e,t,r,n){var o,s,a=this,c=null===(o=this.cachedQueries[e])||void 0===o?void 0:o[n.string];return void 0!==c?r.runWithRequestColumns(c.requestColumns)?c.promise:this.__expandCachedQuery(c,r.requestColumns).then(function(){return c},this.dependencies.errorHandler.reject):(this.isLocal(t,n.object)&&this.transaction.parent instanceof i.ServerCache?this.transaction.dependencies.columnHandler.fetch(e,r.requestColumns).then(function(){s=a.setCachedQuery(e,n,[],r.requestColumns)},this.dependencies.errorHandler.reject):this.transaction.parent.cachedQueryHandler.__fetchItemEntriesByQueryData(e,t,r,n).then(function(e){s=null===t.limit?a.setCachedQuery(e.itemType,e.query,e.items.slice(),e.requestColumns):e},this.dependencies.errorHandler.reject)).then(function(){for(var e=a.dependencies.collectionMatcherFactory.constructCachedQueryProcessor(a.transaction,function(e){return e===s.itemType?[s]:[]}),t=0,r=s.items;t<r.length;t++){var n=r[t];a.transaction.itemHandler.detectEntryChanges(n.id)&&e.expand(n,a.transaction.getItemChangesRecursively(n.id,!1))}for(var i=0,o=a.transaction.itemHandler.entries.getByItemType(s.itemType);i<o.length;i++){n=o[i];e.expand(n,a.transaction.getItemChangesRecursively(n.id,!1))}return e.__removeFromAndAddToCachedQueries(!1)},this.dependencies.errorHandler.reject).then(function(){return s.resolve(),s},function(e){return s.reject(e),a.dependencies.errorHandler.reject(e)})},t.prototype.__fetchLinkedCachedQueryItems=function(e,t,r,n){Object(i.isFunction)(t)&&(t=t());for(var o={},s=0,a=t;s<a.length;s++){var c=a[s],u=this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:c}),l=this.collectionEntryService.createQueryFromOptions(u);this.expandColumnsWithQueryColumns(r,u,l.object);var h=this.dependencies.columnSubsetCacheFactory.construct(u.columns);o[c]=this.__fetchItemEntriesByQueryData(r,n,h,l)}return this.dependencies.promiseService.all(o)},t}(r(29).a)},function(e,t,r){"use strict";r.d(t,"a",function(){return s});var n=r(3),i=r(14),o=r(20),s=function(e){function t(t,r,n){var i=e.call(this,n)||this;return i.errorHandler=t,i.itemCreateService=r,i.created=new o.a,i}return Object(n.b)(t,e),t.prototype.setItemCreated=function(e,t){var r=this;return this.itemCreateService.createItemsFromValues(this,e,[t]).then(function(){return r},this.errorHandler.reject)},t.prototype.setItemsCreated=function(e,t){var r=this;return this.itemCreateService.createItemsFromValues(this,e,t).then(function(){return r},this.errorHandler.reject)},t.prototype._setItemCreated=function(e,t,r,n){void 0===n&&(n=null);var i={};if(null!==n)for(var o in i=this.itemEntryService.getLinkFieldsByParent(n,r.itemType))t[o]=i[o];var s=this.itemEntryService.getLocalDefaultValues();for(var o in s)t.hasOwnProperty(o)||(t[o]=s[o]);return this.created.add(e,t,r),this},t.prototype.setItemMoved=function(e,t){return this.setItemUpdated(e,{},null,t)},t.prototype.isEmpty=function(){return e.prototype.isEmpty.call(this)&&this.created.isEmpty()},t}(i.a)},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=r(1),i=function(){function e(){this.tuples={}}return e.prototype.remove=function(e,t){return void 0!==this.tuples[e]&&delete this.tuples[e][t]},e.prototype.add=function(e,t,r){var n=r.itemType;void 0===this.tuples[n]&&(this.tuples[n]=[]),this.tuples[n].push({itemId:e,fields:t,columns:r})},e.prototype.isEmpty=function(){return!Object(n.i)(this.tuples)},e.prototype.forEach=function(e){for(var t in this.tuples)for(var r=this.tuples[t],n=0;n<r.length;n++)e(r[n],t,n)},e.prototype.contains=function(e){return void 0!==this.tuples[e]},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return s});var n=r(3),i=r(14),o=r(1),s=function(e){function t(t){var r=e.call(this,t)||this;return r.created={},r.moved={},r.itemIdConversionMap={},r}return Object(n.b)(t,e),t.prototype.setItemCreated=function(e,t){this.created[e.id]={entry:e,fields:t}},t.prototype.setItemMoved=function(e,t){this.moved[e.id]={entry:e,to:t}},t.prototype.isEmpty=function(){return e.prototype.isEmpty.call(this)&&!Object(o.i)(this.created)},t}(i.a)},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n=function(){function e(e,t,r,n,i,o){this.promiseLibrary=e,this.apiRequestService=t,this.requestColumnExpansionFactory=r,this.changesDeltaFactory=n,this.serverCache=i,this.itemType=o,this.deferred=this.promiseLibrary.defer(),this.requestColumnExpansion=this.requestColumnExpansionFactory.construct(),this.singleItemIds=[],this.queries={}}return e.prototype.containsId=function(e){return-1!==this.singleItemIds.indexOf(e)},e.prototype.containsQuery=function(e){return void 0!==this.queries[e]},e.prototype.addSingleItem=function(e,t){return this.requestColumnExpansion.expandWithRequestColumns(this.itemType,t),-1===this.singleItemIds.indexOf(e)&&this.singleItemIds.push(e),this.getPromise()},e.prototype.addQuery=function(e,t){return this.requestColumnExpansion.expandWithRequestColumns(this.itemType,t),void 0===this.queries[e[1]]&&(this.queries[e[1]]=e[0]),this.getPromise()},e.prototype.flush=function(){var e=this,t=[];for(var r in this.singleItemIds.length>0&&t.push({key:"id",comparator:"IN",value:this.singleItemIds}),this.queries)t.push(this.queries[r]);if(0===t.length)throw new Error("Tried to flush a RequestBuffer without singleItems or queries");var n,i=this.requestColumnExpansion.get();return this.apiRequestService.query(this.itemType,{conditions:t,operator:"OR"},i).then(function(t){n=t;var r=e.changesDeltaFactory.construct();if(0===e.singleItemIds.length&&!e.hasMultipleQueries()){var o=e.getFirstQueryString();void 0!==o&&r._setQueryResult(e.itemType,o,n.links[e.itemType])}return e.serverCache.processResponse(n,i,!1,!1,r)},function(t){return e.deferred.reject(t)}).then(function(){return e.deferred.resolve(n)},function(t){return e.deferred.reject(t)}),this.getPromise()},e.prototype.getPromise=function(){return this.deferred.promise},e.prototype.hasMultipleQueries=function(){var e=!0;for(var t in this.queries){if(!e)return!0;e=!1}return!1},e.prototype.getFirstQueryString=function(){for(var e in this.queries)return e},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n=function(){function e(e,t,r,n,i,o){this.columnSetFactory=e,this.conversionMapService=t,this.errorHandler=r,this.keyService=n,this.promiseService=i,this.templateCache=o}return e.prototype.createItemsFromValues=function(e,t,r,n){var i=this;if(void 0===n&&(n=null),0===r.length)return this.promiseService.when();for(var o=[],s=function(s){var c,u=s.hasOwnProperty("id")?s.id:a.keyService.getLocalId();o.push(a.templateCache.fetchTemplate(t,u,{},(c={},c[t]=Object.keys(r[0]),c),n).then(function(r){i.processTemplate(e,t,u,n,r,function(){return!0},function(e,r){if(e===t)for(var n in s)r[n]=s[n]})},a.errorHandler.reject))},a=this,c=0,u=r;c<u.length;c++){s(u[c])}return this.promiseService.all(o).then(function(){})},e.prototype.processTemplate=function(e,t,r,n,i,o,s){void 0===o&&(o=function(){return!0});var a=this.conversionMapService.createLocalConversionMap(t,r,!0,i.response),c=i.getFields();this.conversionMapService.updateItemValues(c,c,i.columns.item,a,n),void 0!==s&&s(t,c,a),e._setItemCreated(r,c,i.columns,n),this.processTemplateLinkItems(e,t,r,i,a,o,s)},e.prototype.processTemplateLinkItems=function(e,t,r,n,i,o,s){var a=this;void 0===o&&(o=function(){return!0});var c=n.response,u={},l=function(t,r,h){var d={itemType:t,itemId:r},p=c.items[t][h].links;for(var m in p)if(p.hasOwnProperty(m)){void 0===u[m]&&(u[m]=a.columnSetFactory.construct(m,!0,n.responseColumns));for(var f=0,y=p[m];f<y.length;f++){var v=y[f],g=c.fetchObject(m,v);if(o(m,g)){var C=i[m][v];a.conversionMapService.updateItemValues(g,g,u[m].item,i,d),void 0!==s&&s(m,g,i),e._setItemCreated(C,g,u[m],d),l(m,C,v)}}}};l(t,r,c.links[t][0])},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(19),i=r(21),o=function(){function e(e,t,r){this.errorHandler=e,this.itemEntryService=t,this.itemCreateService=r}return e.prototype.construct=function(){return new n.a(this.errorHandler,this.itemCreateService,this.itemEntryService)},e.prototype.constructInternalDelta=function(){return new i.a(this.itemEntryService)},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=r(0),i=function(){function e(e,t,r,n,i,o,s,a,c,u){this.changesDeltaFactory=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.columnExpansionFactory=n,this.createRequestFactory=i,this.errorHandler=o,this.promiseService=s,this.requestColumnExpansionFactory=a,this.collectionEntryService=c,this.itemEntryService=u}return e.prototype.construct=function(e,t,r){return new n.i(this.changesDeltaFactory,this.apiRequestService,this.changesCompilationFactory,this.columnExpansionFactory,this.createRequestFactory,this.errorHandler,this.promiseService,this.requestColumnExpansionFactory,this.collectionEntryService,this.itemEntryService,e,t,r)},e}()},function(e,t,r){"use strict";var n=r(3),i=function(e){function t(t){return e.call(this,t)||this}return Object(n.b)(t,e),t.prototype.parseEmptyQuery=function(){return!0},t.prototype.parseSubQuery=function(e,t,r){return void 0===r&&(r=!1),!1},t.prototype.parseSubFieldQuery=function(e,t,r,n,i){return!1},t.prototype.parseSearchQuery=function(e,t){return!1},t.prototype.parseCustomQuery=function(e,t,r){return void 0===r&&(r=!1),!1},t.prototype.parseSimpleQuery=function(e,t,r,n){return!0},t.prototype.parseLinkedToQuery=function(e,t,r,n){return void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1),!0},t.prototype.parseComplexQuery=function(e,t,r){return this.parseConditions(e)},t.prototype.parseConditions=function(e){var t=this;return e.every(function(e){return t.parse(e)})},t}(r(2).c),o=r(22);r.d(t,"a",function(){return s});var s=function(){function e(e,t,r,n,i){this.promiseLibrary=e,this.apiRequestService=t,this.requestColumnExpansionFactory=r,this.keyService=n,this.changesDeltaFactory=i,this.pendingBufferMap={},this.pendingTrueBufferMap={}}return e.prototype.setServerCache=function(e){this.serverCache=e},e.prototype.fetchByIds=function(e,t,r){for(var n=0,i=t;n<i.length;n++){var o=i[n];this.fetchById(e,o,r)}return this.pendingBufferMap[e].getPromise()},e.prototype.fetchById=function(e,t,r){if(this.keyService.isLocalId(t))throw new Error("Unexpected local ItemId in RequestBufferManager.fetchById, for local ItemIds you should use RequestBufferManager.fetchByLocalId");var n;return!0===r?void 0===(n=this.pendingTrueBufferMap[e])?n=this.constructBuffer(e,this.pendingTrueBufferMap):console.log("Existing 'columns: true' RequestBuffer "+e+" at "+performance.now()+" by id"):void 0===(n=this.pendingBufferMap[e])?n=this.constructBuffer(e):console.log("Existing RequestBuffer "+e+" at "+performance.now()+" by id"),n.addSingleItem(t,r),n.getPromise()},e.prototype.fetchByQuery=function(e,t,r){var n;return new i(t[0]).parse()?(void 0===(n=this.pendingBufferMap[e])?n=this.constructBuffer(e):console.log("Existing RequestBuffer "+e+" at "+performance.now()+" with query"),n.addQuery(t,r),n.getPromise()):((n=this._constructBuffer(e)).addQuery(t,r),n.flush(),n.getPromise())},e.prototype.constructBuffer=function(e,t){void 0===t&&(t=this.pendingBufferMap);var r=t[e]=this._constructBuffer(e);return window.setTimeout(function(){r.flush(),delete t[e]},150),r},e.prototype._constructBuffer=function(e){return new o.a(this.promiseLibrary,this.apiRequestService,this.requestColumnExpansionFactory,this.changesDeltaFactory,this.serverCache,e)},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(5),i=r(1),o=function(){function e(e,t,r,n,i,o,s,a){this.columnUtil=e,this.apiFormatter=t,this.itemEntryFactory=r,this.promiseService=n,this.errorHandler=i,this.requestColumnExpansionFactory=o,this.transaction=a,this.entries=s.construct(this.transaction)}return e.prototype.getDerivedValues=function(e,t){for(var r=e,n=this.transaction.getChangesFromItemChanges(this.itemChanges[e.id]),i=0,o=t;i<o.length;i++){var s=o[i],a=r.columns.response[r.itemType][s];if(void 0===a)throw new Error("Column '"+s+"' not found on entry in ItemResource.getDerivedValue");if(null===a.itemType)throw new Error("Column '"+s+"' doesn't have children in ItemResource.getDerivedValue");var c=n[s];if(null===c)return;if(void 0===(r=this.transaction.getLocalItemEntryByItemId(a.itemType,c)))throw new Error("Derived itemEntry "+a.itemType+":"+c+" couldn't be found");n=this.transaction.getItemChangesRecursively(r.id,!1)}return n},e.prototype.getDerivedValue=function(e,t){"string"==typeof t&&(t=this.columnUtil.parseConfigColumn(t));var r=this.getDerivedValues(e,t.slice(0,-1));if(void 0!==r)return r[t[t.length-1]]},e.prototype.clearItemEntry=function(e){this.entries.clear(e),delete this.itemChanges[e.id]},e.prototype.fetchDerivedValuesByColumn=function(e,t,r){var o=this,s=t.children;if(0===s.length)return this.promiseService.when();var a=s[0];if(1===s.length&&"id"===a.apiColumn.type)throw new Error("You should use fields[columnId] instead of derived['columnId>id'] to get the id of a derived item");for(var c={},u=0,l=e;u<l.length;u++){var h=l[u];null!==(p=this.getItemIdByColumn(h,t,r))&&(void 0===c[p]&&(c[p]=[]),c[p].push(h))}if(!Object(i.i)(c))return this.promiseService.when();var d=[];for(var p in c)d.push(+p);for(var m=[],f=0,y=s;f<y.length;f++){var v=y[f];m.push(v.id)}return this.fetchItemEntries(t.itemType,d,new n.e({columns:m})).then(function(){return o.resolveDerivedValues(e,s,r)},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.createItemEntry=function(e){var t=this.itemEntryFactory.construct(e.itemId,e.columns);return this.entries.add(t),t},e.prototype.getItemIdByColumn=function(e,t,r){if(0===t.level)return void 0!==r&&void 0!==r.updated[e.id]?r.updated[e.id].changes.fields[t.path]:this.transaction.getItemChangesRecursively(e.id)[t.path];var n=this.getItemIdByColumn(e,t.parent,r),i=this.transaction.getLocalItemEntryByItemId(t.parent.itemType,n);return void 0!==r&&void 0!==r.updated[i.id]?r.updated[i.id].changes.fields[t.id]:this.transaction.getItemChangesRecursively(i.id)[t.id]},e.prototype.expandColumnsWithCachedQueryColumns=function(e,t){var r=this.requestColumnExpansionFactory.construct();void 0!==t&&r.expandWithRequestColumns(e,t);for(var n=function(t){var n=t.cachedQueryHandler.cachedQueries[e];if(void 0!==n)for(var i in n){var o=n[i];r.expandWithRequestColumns(o.itemType,o.requestColumns)}},i=function(e){for(var t=0,r=e;t<r.length;t++){var o=r[t];n(o),i(o.children)}},o=0,s=this.transaction.getTransactionChain();o<s.length;o++){var a=s[o];n(a)}return i(this.transaction.children),r.get()[e]},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n=function(){function e(e,t,r){this.queryService=e,this.queryMatcherFactory=t,this.transaction=r}return e.prototype.expand=function(e,t){var r=this.queryMatcherFactory.construct(e.itemType,t,this.transaction.getParent(e));return this._expand(e,function(e,t){return r.matchQuery(t.object)})},e.prototype.processDelta=function(e){var t=this;for(var r in e.deleted)for(var n=0,i=e.deleted[r];n<i.length;n++){var o=i[n];this._expand(o,function(){return!1})}var s=function(t){var r=e.created[t],n=a.queryMatcherFactory.construct(r.entry.itemType,r.fields,a.transaction.getParent(r.entry));a._expand(r.entry,function(t,i){var o=e._queryResults[t];if(void 0!==o){var s=o[i.string];if(void 0!==s)return!r.entry.isLocal()&&-1!==s.indexOf(r.entry.itemId)}return n.matchQuery(i.object)})},a=this;for(var c in e.created)s(c);var u=function(r){var n=e.moved[r];l._expand(n.entry,function(e,r){return t.queryService.containsLinkedTo(r.object,n.to.itemType,n.to.itemId)})},l=this;for(var c in e.moved)u(c);var h=function(t){var r=e.updated[t],n={},i=d.transaction.getItemChangesRecursively(Number(t),!1),o=function(e,t){var r=Object.getOwnPropertyDescriptor(e,t);void 0!==r?Object.defineProperty(n,t,r):n[t]=e[t]};for(var s in i)o(i,s);for(var s in r.changes.fields)o(r.changes.fields,s);var a=d.queryMatcherFactory.construct(r.entry.itemType,n,d.transaction.getParent(r.entry));d._expand(r.entry,function(t,n){var i=e._queryResults[t];if(void 0!==i){var o=i[n.string];if(void 0!==o)return!r.entry.isLocal()&&-1!==o.indexOf(r.entry.itemId)}return a.matchQuery(n.object)})},d=this;for(var c in e.updated)h(c);return this},e.prototype.groupItemEntries=function(e){var t=[],r=[],n=[];for(var i in e){var o=e[i],s=o.item,a=o.isMatch;!0===a?t.push(s):!1===a?r.push(s):n.push(s)}return{fitting:t,notFitting:r,maybe:n}},e}()},function(e,t,r){"use strict";var n=r(3),i=function(e){function t(t,r,n){var i=e.call(this,n)||this;return i.columnUtil=t,i.itemType=r,i}return Object(n.b)(t,e),t.prototype.parseEmptyQuery=function(){return[]},t.prototype.parseSubQuery=function(e,t,r){var n;return void 0===r&&(r=!1),[(n={},n[e]=this.parse(t),n)]},t.prototype.parseSubFieldQuery=function(e,t,r,n,i){return[]},t.prototype.parseSearchQuery=function(e,t){return[]},t.prototype.parseCustomQuery=function(e,t,r){return void 0===r&&(r=!1),[]},t.prototype.parseSimpleQuery=function(e,t,r,n){return[e]},t.prototype.parseLinkedToQuery=function(e,t,r,n){return void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1),this.columnUtil.getColumnsFromLink(e,this.itemType)},t.prototype.parseComplexQuery=function(e,t,r){return this.parseConditions(e)},t.prototype.parseConditions=function(e){var t=this;return e.reduce(function(e,r){return e.concat(t.parse(r))},[])},t}(r(2).c),o=r(1);r.d(t,"a",function(){return s});var s=function(){function e(e,t,r,n,i){this.collectionEntryService=e,this.columnUtil=t,this.requestColumnExpansionFactory=r,this.promiseService=n,this.transaction=i,this.cachedQueries={}}return e.prototype.setCachedQuery=function(e,t,r,n){void 0===this.cachedQueries[e]&&(this.cachedQueries[e]={});var i=this.promiseService.defer(),o=this.cachedQueries[e][t.string]={itemType:e,query:t,items:r,promise:i.promise,requestColumns:n,resolve:function(){i.resolve(o)},reject:function(e){i.reject(e)}};return o},e.prototype.getCachedQueryItems=function(e,t){var r,n;return null===(n=null===(r=this.cachedQueries[e])||void 0===r?void 0:r[t])||void 0===n?void 0:n.items},e.prototype.getCachedQueryObjectsByItemType=function(e){var t=[];if(void 0===this.cachedQueries[e])return t;for(var r in this.cachedQueries[e])t.push(this.cachedQueries[e][r]);return t},e.prototype.initCachedQuery=function(e,t,r){return this.setCachedQuery(e,t,[],r)},e.prototype.__addItemEntriesToCachedQueries=function(e,t,r,n){if(0!==r.length){var i=this.getCachedQueryItems(e,t.string);if(void 0!==i)for(var o=[],s=0,a=r;s<a.length;s++){var c=a[s];-1!==i.indexOf(c)||n(c)||(i.push(c),o.push(c))}}},e.prototype.__removeItemEntriesFromCachedQueries=function(e,t,r){if(0===r.length)return[];var n=this.getCachedQueryItems(e,t.string);return void 0===n?[]:this.collectionEntryService.filterArray(n,function(e){return!Object(o.j)(e,r)})},e.prototype.expandColumnsWithQueryColumns=function(e,t,r){var n=new i(this.columnUtil,e,r);if(t.queryColumns=n.parse(),!0!==t.columns){var o=this.requestColumnExpansionFactory.construct();o.expandWithRequestColumns(e,t.columns),o.expandWithRequestColumns(e,t.queryColumns),null!==t.limit&&o.expandWithRequestColumns(e,[t.limit.field]),t.columns=o.get()[e]}},e}()},function(e,t,r){"use strict";var n,i;r.d(t,"b",function(){return n}),r.d(t,"a",function(){return i}),function(e){e.New="new",e.Duplicate="duplicate"}(n||(n={})),function(e){e.ITEMTABLE="itemtable",e.DIRECT="direct"}(i||(i={}))},function(e,t){},function(e,t,r){"use strict";r.r(t);var n=r(33);for(var i in n)"default"!==i&&function(e){r.d(t,e,function(){return n[e]})}(i);var o=r(34);for(var i in o)"default"!==i&&function(e){r.d(t,e,function(){return o[e]})}(i);var s=r(35);for(var i in s)"default"!==i&&function(e){r.d(t,e,function(){return s[e]})}(i);var a=r(36);for(var i in a)"default"!==i&&function(e){r.d(t,e,function(){return a[e]})}(i);var c=r(37);for(var i in c)"default"!==i&&function(e){r.d(t,e,function(){return c[e]})}(i);var u=r(38);for(var i in u)"default"!==i&&function(e){r.d(t,e,function(){return u[e]})}(i);var l=r(39);for(var i in l)"default"!==i&&function(e){r.d(t,e,function(){return l[e]})}(i);var h=r(40);for(var i in h)"default"!==i&&function(e){r.d(t,e,function(){return h[e]})}(i);var d=r(41);for(var i in d)"default"!==i&&function(e){r.d(t,e,function(){return d[e]})}(i);var p=r(42);for(var i in p)"default"!==i&&function(e){r.d(t,e,function(){return p[e]})}(i);var m=r(43);for(var i in m)"default"!==i&&function(e){r.d(t,e,function(){return m[e]})}(i)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){}])});