@rentman/rm-core 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/definitions/classes/ApiFormatter.d.ts +36 -0
  2. package/dist/definitions/classes/BatchStatus.d.ts +16 -0
  3. package/dist/definitions/classes/ChangesCompiler.d.ts +34 -0
  4. package/dist/definitions/classes/ChangesProcessor.d.ts +46 -0
  5. package/dist/definitions/classes/CollectionCache.d.ts +39 -0
  6. package/dist/definitions/classes/CollectionEntryService.d.ts +15 -0
  7. package/dist/definitions/classes/CollectionHandler.d.ts +79 -0
  8. package/dist/definitions/classes/CollectionResourceService.d.ts +5 -0
  9. package/dist/definitions/classes/ColumnCache.d.ts +18 -0
  10. package/dist/definitions/classes/ColumnExpansion.d.ts +16 -0
  11. package/dist/definitions/classes/ColumnHandler.d.ts +19 -0
  12. package/dist/definitions/classes/ColumnSet.d.ts +54 -0
  13. package/dist/definitions/classes/ColumnUtil.d.ts +80 -0
  14. package/dist/definitions/classes/CreateRequest.d.ts +28 -0
  15. package/dist/definitions/classes/ItemAdministrator.d.ts +114 -0
  16. package/dist/definitions/classes/ItemCache.d.ts +22 -0
  17. package/dist/definitions/classes/ItemEntryService.d.ts +50 -0
  18. package/dist/definitions/classes/ItemHandler.d.ts +70 -0
  19. package/dist/definitions/classes/ItemRequestService.d.ts +31 -0
  20. package/dist/definitions/classes/ItemResourceService.d.ts +8 -0
  21. package/dist/definitions/classes/KeyService.d.ts +28 -0
  22. package/dist/definitions/classes/LockService.d.ts +25 -0
  23. package/dist/definitions/classes/ModuleChangesCompiler.d.ts +18 -0
  24. package/dist/definitions/classes/PromiseService.d.ts +10 -0
  25. package/dist/definitions/classes/QueryMatcher.d.ts +14 -0
  26. package/dist/definitions/classes/QueryParser.d.ts +16 -0
  27. package/dist/definitions/classes/QueryService.d.ts +19 -0
  28. package/dist/definitions/classes/RequestColumnExpansion.d.ts +9 -0
  29. package/dist/definitions/classes/ResourceCache.d.ts +78 -0
  30. package/dist/definitions/classes/Util.d.ts +25 -0
  31. package/dist/definitions/constants.d.ts +10 -0
  32. package/dist/definitions/factories/BatchStatusFactory.d.ts +8 -0
  33. package/dist/definitions/factories/ChangesCompilerFactory.d.ts +9 -0
  34. package/dist/definitions/factories/ChangesProcessorFactory.d.ts +31 -0
  35. package/{src/factories/CollectionCacheFactory.ts → dist/definitions/factories/CollectionCacheFactory.d.ts} +3 -11
  36. package/dist/definitions/factories/CollectionEntryFactory.d.ts +19 -0
  37. package/dist/definitions/factories/CollectionResourceFactory.d.ts +18 -0
  38. package/dist/definitions/factories/ColumnExpansionFactory.d.ts +11 -0
  39. package/dist/definitions/factories/ColumnSetFactory.d.ts +9 -0
  40. package/dist/definitions/factories/CreateRequestFactory.d.ts +13 -0
  41. package/dist/definitions/factories/ItemCacheFactory.d.ts +9 -0
  42. package/dist/definitions/factories/ItemEntryFactory.d.ts +6 -0
  43. package/dist/definitions/factories/ItemResourceFactory.d.ts +12 -0
  44. package/{src/factories/ModuleChangesCompilerFactory.ts → dist/definitions/factories/ModuleChangesCompilerFactory.d.ts} +3 -14
  45. package/dist/definitions/factories/QueryMatcherFactory.d.ts +7 -0
  46. package/dist/definitions/factories/QueryParserFactory.d.ts +5 -0
  47. package/{src/factories/RequestColumnExpansionFactory.ts → dist/definitions/factories/RequestColumnExpansionFactory.d.ts} +3 -11
  48. package/dist/definitions/factories/ResourceCacheFactory.d.ts +33 -0
  49. package/dist/definitions/index.d.ts +121 -0
  50. package/dist/definitions/interfaces/ApiRequestServiceInterface.d.ts +10 -0
  51. package/dist/definitions/interfaces/AuthInterface.d.ts +4 -0
  52. package/{src/interfaces/ErrorHandlerInterface.ts → dist/definitions/interfaces/ErrorHandlerInterface.d.ts} +2 -2
  53. package/dist/definitions/interfaces/ResourceCacheInterface.d.ts +6 -0
  54. package/dist/definitions/models/CollectionEditResource.d.ts +23 -0
  55. package/dist/definitions/models/CollectionEntry.d.ts +61 -0
  56. package/dist/definitions/models/CollectionResource.d.ts +29 -0
  57. package/{src/models/CollectionViewResource.ts → dist/definitions/models/CollectionViewResource.d.ts} +6 -13
  58. package/dist/definitions/models/EditResource.d.ts +7 -0
  59. package/dist/definitions/models/ItemEntry.d.ts +18 -0
  60. package/dist/definitions/models/ItemResource.d.ts +14 -0
  61. package/dist/definitions/models/ViewResource.d.ts +7 -0
  62. package/dist/rm-core.js +29 -0
  63. package/dist/rm-core.js.map +1 -0
  64. package/package.json +5 -1
  65. package/.editorconfig +0 -23
  66. package/src/classes/ApiFormatter.ts +0 -338
  67. package/src/classes/BatchStatus.ts +0 -86
  68. package/src/classes/ChangesCompiler.ts +0 -161
  69. package/src/classes/ChangesProcessor.ts +0 -475
  70. package/src/classes/CollectionCache.ts +0 -234
  71. package/src/classes/CollectionEntryService.ts +0 -83
  72. package/src/classes/CollectionHandler.ts +0 -619
  73. package/src/classes/CollectionResourceService.ts +0 -38
  74. package/src/classes/ColumnCache.ts +0 -114
  75. package/src/classes/ColumnExpansion.ts +0 -74
  76. package/src/classes/ColumnHandler.ts +0 -90
  77. package/src/classes/ColumnSet.ts +0 -181
  78. package/src/classes/ColumnUtil.ts +0 -589
  79. package/src/classes/CreateRequest.ts +0 -158
  80. package/src/classes/ItemAdministrator.ts +0 -571
  81. package/src/classes/ItemCache.ts +0 -158
  82. package/src/classes/ItemEntryService.ts +0 -488
  83. package/src/classes/ItemHandler.ts +0 -592
  84. package/src/classes/ItemRequestService.ts +0 -229
  85. package/src/classes/ItemResourceService.ts +0 -36
  86. package/src/classes/KeyService.ts +0 -76
  87. package/src/classes/LockService.ts +0 -184
  88. package/src/classes/ModuleChangesCompiler.ts +0 -123
  89. package/src/classes/PromiseService.ts +0 -19
  90. package/src/classes/QueryMatcher.ts +0 -135
  91. package/src/classes/QueryParser.ts +0 -209
  92. package/src/classes/QueryService.ts +0 -35
  93. package/src/classes/RequestColumnExpansion.ts +0 -31
  94. package/src/classes/ResourceCache.ts +0 -289
  95. package/src/classes/Util.ts +0 -422
  96. package/src/constants.ts +0 -11
  97. package/src/factories/BatchStatusFactory.ts +0 -18
  98. package/src/factories/ChangesCompilerFactory.ts +0 -20
  99. package/src/factories/ChangesProcessorFactory.ts +0 -53
  100. package/src/factories/CollectionEntryFactory.ts +0 -35
  101. package/src/factories/CollectionResourceFactory.ts +0 -36
  102. package/src/factories/ColumnExpansionFactory.ts +0 -25
  103. package/src/factories/ColumnSetFactory.ts +0 -24
  104. package/src/factories/CreateRequestFactory.ts +0 -28
  105. package/src/factories/ItemCacheFactory.ts +0 -18
  106. package/src/factories/ItemEntryFactory.ts +0 -18
  107. package/src/factories/ItemResourceFactory.ts +0 -28
  108. package/src/factories/QueryMatcherFactory.ts +0 -20
  109. package/src/factories/QueryParserFactory.ts +0 -10
  110. package/src/factories/ResourceCacheFactory.ts +0 -55
  111. package/src/index.ts +0 -188
  112. package/src/interfaces/ApiRequestServiceInterface.ts +0 -17
  113. package/src/interfaces/AuthInterface.ts +0 -5
  114. package/src/interfaces/ResourceCacheInterface.ts +0 -9
  115. package/src/models/CollectionEditResource.ts +0 -139
  116. package/src/models/CollectionEntry.ts +0 -448
  117. package/src/models/CollectionResource.ts +0 -223
  118. package/src/models/EditResource.ts +0 -15
  119. package/src/models/ItemEntry.ts +0 -24
  120. package/src/models/ItemResource.ts +0 -35
  121. package/src/models/ViewResource.ts +0 -14
  122. package/tsconfig.json +0 -12
  123. package/tslint.json +0 -63
  124. package/webpack.common.js +0 -35
  125. package/webpack.dev.js +0 -10
  126. package/webpack.prod.js +0 -17
@@ -0,0 +1,29 @@
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=4)}([function(t,r){t.exports=e},function(e,t,r){(function(t,r){
2
+ /*!
3
+ *
4
+ * Copyright 2009-2017 Kris Kowal under the terms of the MIT
5
+ * license found at https://github.com/kriskowal/q/blob/v1/LICENSE
6
+ *
7
+ * With parts by Tyler Close
8
+ * Copyright 2007-2009 Tyler Close under the terms of the MIT X license found
9
+ * at http://www.opensource.org/licenses/mit-license.html
10
+ * Forked at ref_send.js version: 2009-05-11
11
+ *
12
+ * With parts by Mark Miller
13
+ * Copyright (C) 2011 Google Inc.
14
+ *
15
+ * Licensed under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License.
17
+ * You may obtain a copy of the License at
18
+ *
19
+ * http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software
22
+ * distributed under the License is distributed on an "AS IS" BASIS,
23
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ * See the License for the specific language governing permissions and
25
+ * limitations under the License.
26
+ *
27
+ */
28
+ !function(t){"use strict";"function"==typeof bootstrap?bootstrap("promise",t):e.exports=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var n,i=R(),o=function(){},s=function(){var e={task:void 0,next:null},n=e,i=!1,o=void 0,c=!1,a=[];function u(){for(var t,r;e.next;)t=(e=e.next).task,e.task=void 0,(r=e.domain)&&(e.domain=void 0,r.enter()),l(t,r);for(;a.length;)l(t=a.pop());i=!1}function l(e,t){try{e()}catch(e){if(c)throw t&&t.exit(),setTimeout(u,0),t&&t.enter(),e;setTimeout(function(){throw e},0)}t&&t.exit()}if(s=function(e){n=n.next={task:e,domain:c&&t.domain,next:null},i||(i=!0,o())},"object"==typeof t&&"[object process]"===t.toString()&&t.nextTick)c=!0,o=function(){t.nextTick(u)};else if("function"==typeof r)o="undefined"!=typeof window?r.bind(window,u):function(){r(u)};else if("undefined"!=typeof MessageChannel){var h=new MessageChannel;h.port1.onmessage=function(){o=p,h.port1.onmessage=u,u()};var p=function(){h.port2.postMessage(0)};o=function(){setTimeout(u,0),p()}}else o=function(){setTimeout(u,0)};return s.runAfter=function(e){a.push(e),i||(i=!0,o())},s}(),c=Function.call;function a(e){return function(){return c.apply(e,arguments)}}var u,l=a(Array.prototype.slice),h=a(Array.prototype.reduce||function(e,t){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){t=this[r++];break}if(++r>=n)throw new TypeError}for(;r<n;r++)r in this&&(t=e(t,this[r],r));return t}),p=a(Array.prototype.indexOf||function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return t;return-1}),f=a(Array.prototype.map||function(e,t){var r=this,n=[];return h(r,function(i,o,s){n.push(e.call(t,o,s,r))},void 0),n}),d=Object.create||function(e){function t(){}return t.prototype=e,new t},m=Object.defineProperty||function(e,t,r){return e[t]=r.value,e},v=a(Object.prototype.hasOwnProperty),y=Object.keys||function(e){var t=[];for(var r in e)v(e,r)&&t.push(r);return t},g=a(Object.prototype.toString);u="undefined"!=typeof ReturnValue?ReturnValue:function(e){this.value=e};var S="From previous event:";function C(t,r){if(e&&r.stack&&"object"==typeof t&&null!==t&&t.stack){for(var n=[],i=r;i;i=i.source)i.stack&&(!t.__minimumStackCounter__||t.__minimumStackCounter__>i.stackCounter)&&(m(t,"__minimumStackCounter__",{value:i.stackCounter,configurable:!0}),n.unshift(i.stack));n.unshift(t.stack);var o=function(e){for(var t=e.split("\n"),r=[],n=0;n<t.length;++n){var i=t[n];!E(i)&&-1===(o=i).indexOf("(module.js:")&&-1===o.indexOf("(node.js:")&&i&&r.push(i)}var o;return r.join("\n")}(n.join("\n"+S+"\n"));m(t,"stack",{value:o,configurable:!0})}}function I(e){var t=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(e);if(t)return[t[1],Number(t[2])];var r=/at ([^ ]+):(\d+):(?:\d+)$/.exec(e);if(r)return[r[1],Number(r[2])];var n=/.*@(.+):(\d+)$/.exec(e);return n?[n[1],Number(n[2])]:void 0}function E(e){var t=I(e);if(!t)return!1;var r=t[0],o=t[1];return r===n&&o>=i&&o<=J}function R(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),r=I(t[0].indexOf("@")>0?t[1]:t[2]);if(!r)return;return n=r[0],r[1]}}function q(e){return e instanceof w?e:x(e)?(t=e,r=b(),q.nextTick(function(){try{t.then(r.resolve,r.reject,r.notify)}catch(e){r.reject(e)}}),r.promise):B(e);var t,r}q.resolve=q,q.nextTick=s,q.longStackSupport=!1;var T=1;function b(){var t,r=[],n=[],i=d(b.prototype),o=d(w.prototype);if(o.promiseDispatch=function(e,i,o){var s=l(arguments);r?(r.push(s),"when"===i&&o[1]&&n.push(o[1])):q.nextTick(function(){t.promiseDispatch.apply(t,s)})},o.valueOf=function(){if(r)return o;var e=j(t);return H(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},q.longStackSupport&&e)try{throw new Error}catch(e){o.stack=e.stack.substring(e.stack.indexOf("\n")+1),o.stackCounter=T++}function s(i){t=i,q.longStackSupport&&e&&(o.source=i),h(r,function(e,t){q.nextTick(function(){i.promiseDispatch.apply(i,t)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(e){t||s(q(e))},i.fulfill=function(e){t||s(B(e))},i.reject=function(e){t||s(V(e))},i.notify=function(e){t||h(n,function(t,r){q.nextTick(function(){r(e)})},void 0)},i}function F(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=b();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function k(e){return F(function(t,r){for(var n=0,i=e.length;n<i;n++)q(e[n]).then(t,r)})}function w(e,t,r){void 0===t&&(t=function(e){return V(new Error("Promise does not support operation: "+e))}),void 0===r&&(r=function(){return{state:"unknown"}});var n=d(w.prototype);if(n.promiseDispatch=function(r,i,o){var s;try{s=e[i]?e[i].apply(n,o):t.call(n,i,o)}catch(e){s=V(e)}r&&r(s)},n.inspect=r,r){var i=r();"rejected"===i.state&&(n.exception=i.reason),n.valueOf=function(){var e=r();return"pending"===e.state||"rejected"===e.state?n:e.value}}return n}function O(e,t,r,n){return q(e).then(t,r,n)}function j(e){if(H(e)){var t=e.inspect();if("fulfilled"===t.state)return t.value}return e}function H(e){return e instanceof w}function x(e){return(t=e)===Object(t)&&"function"==typeof e.then;var t}"object"==typeof t&&t&&t.env&&t.env.Q_DEBUG&&(q.longStackSupport=!0),q.defer=b,b.prototype.makeNodeResolver=function(){var e=this;return function(t,r){t?e.reject(t):arguments.length>2?e.resolve(l(arguments,1)):e.resolve(r)}},q.Promise=F,q.promise=F,F.race=k,F.all=W,F.reject=V,F.resolve=q,q.passByCopy=function(e){return e},w.prototype.passByCopy=function(){return this},q.join=function(e,t){return q(e).join(t)},w.prototype.join=function(e){return q([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Q can't join: not the same: "+e+" "+t)})},q.race=k,w.prototype.race=function(){return this.then(q.race)},q.makePromise=w,w.prototype.toString=function(){return"[object Promise]"},w.prototype.then=function(e,t,r){var n=this,i=b(),o=!1;return q.nextTick(function(){n.promiseDispatch(function(t){o||(o=!0,i.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return V(e)}}(t)))},"when",[function(e){o||(o=!0,i.resolve(function(e){if("function"==typeof t){C(e,n);try{return t(e)}catch(e){return V(e)}}return V(e)}(e)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(e){var t,n=!1;try{t=function(e){return"function"==typeof r?r(e):e}(e)}catch(e){if(n=!0,!q.onerror)throw e;q.onerror(e)}n||i.notify(t)}]),i.promise},q.tap=function(e,t){return q(e).tap(t)},w.prototype.tap=function(e){return e=q(e),this.then(function(t){return e.fcall(t).thenResolve(t)})},q.when=O,w.prototype.thenResolve=function(e){return this.then(function(){return e})},q.thenResolve=function(e,t){return q(e).thenResolve(t)},w.prototype.thenReject=function(e){return this.then(function(){throw e})},q.thenReject=function(e,t){return q(e).thenReject(t)},q.nearer=j,q.isPromise=H,q.isPromiseAlike=x,q.isPending=function(e){return H(e)&&"pending"===e.inspect().state},w.prototype.isPending=function(){return"pending"===this.inspect().state},q.isFulfilled=function(e){return!H(e)||"fulfilled"===e.inspect().state},w.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},q.isRejected=function(e){return H(e)&&"rejected"===e.inspect().state},w.prototype.isRejected=function(){return"rejected"===this.inspect().state};var M,D,P,A=[],L=[],_=[],U=!0;function N(){A.length=0,L.length=0,U||(U=!0)}function V(e){var r=w({when:function(r){return r&&function(e){if(U){var r=p(L,e);-1!==r&&("object"==typeof t&&"function"==typeof t.emit&&q.nextTick.runAfter(function(){var n=p(_,e);-1!==n&&(t.emit("rejectionHandled",A[r],e),_.splice(n,1))}),L.splice(r,1),A.splice(r,1))}}(this),r?r(e):this}},function(){return this},function(){return{state:"rejected",reason:e}});return function(e,r){U&&("object"==typeof t&&"function"==typeof t.emit&&q.nextTick.runAfter(function(){-1!==p(L,e)&&(t.emit("unhandledRejection",r,e),_.push(e))}),L.push(e),r&&void 0!==r.stack?A.push(r.stack):A.push("(no stack) "+r))}(r,e),r}function B(e){return w({when:function(){return e},get:function(t){return e[t]},set:function(t,r){e[t]=r},delete:function(t){delete e[t]},post:function(t,r){return null===t||void 0===t?e.apply(void 0,r):e[t].apply(e,r)},apply:function(t,r){return e.apply(t,r)},keys:function(){return y(e)}},void 0,function(){return{state:"fulfilled",value:e}})}function Q(e,t,r){return q(e).spread(t,r)}function Y(e,t,r){return q(e).dispatch(t,r)}function W(e){return O(e,function(e){var t=0,r=b();return h(e,function(n,i,o){var s;H(i)&&"fulfilled"===(s=i.inspect()).state?e[o]=s.value:(++t,O(i,function(n){e[o]=n,0==--t&&r.resolve(e)},r.reject,function(e){r.notify({index:o,value:e})}))},void 0),0===t&&r.resolve(e),r.promise})}function X(e){if(0===e.length)return q.resolve();var t=q.defer(),r=0;return h(e,function(n,i,o){var s=e[o];r++,O(s,function(e){t.resolve(e)},function(e){if(0==--r){var n=e||new Error(""+e);n.message="Q can't get fulfillment value from any promise, all promises were rejected. Last error message: "+n.message,t.reject(n)}},function(e){t.notify({index:o,value:e})})},void 0),t.promise}function K(e){return O(e,function(e){return e=f(e,q),O(W(f(e,function(e){return O(e,o,o)})),function(){return e})})}q.resetUnhandledRejections=N,q.getUnhandledReasons=function(){return A.slice()},q.stopUnhandledRejectionTracking=function(){N(),U=!1},N(),q.reject=V,q.fulfill=B,q.master=function(e){return w({isDef:function(){}},function(t,r){return Y(e,t,r)},function(){return q(e).inspect()})},q.spread=Q,w.prototype.spread=function(e,t){return this.all().then(function(t){return e.apply(void 0,t)},t)},q.async=function(e){return function(){function t(e,t){var o;if("undefined"==typeof StopIteration){try{o=r[e](t)}catch(e){return V(e)}return o.done?q(o.value):O(o.value,n,i)}try{o=r[e](t)}catch(e){return function(e){return"[object StopIteration]"===g(e)||e instanceof u}(e)?q(e.value):V(e)}return O(o,n,i)}var r=e.apply(this,arguments),n=t.bind(t,"next"),i=t.bind(t,"throw");return n()}},q.spawn=function(e){q.done(q.async(e)())},q.return=function(e){throw new u(e)},q.promised=function(e){return function(){return Q([this,W(arguments)],function(t,r){return e.apply(t,r)})}},q.dispatch=Y,w.prototype.dispatch=function(e,t){var r=this,n=b();return q.nextTick(function(){r.promiseDispatch(n.resolve,e,t)}),n.promise},q.get=function(e,t){return q(e).dispatch("get",[t])},w.prototype.get=function(e){return this.dispatch("get",[e])},q.set=function(e,t,r){return q(e).dispatch("set",[t,r])},w.prototype.set=function(e,t){return this.dispatch("set",[e,t])},q.del=q.delete=function(e,t){return q(e).dispatch("delete",[t])},w.prototype.del=w.prototype.delete=function(e){return this.dispatch("delete",[e])},q.mapply=q.post=function(e,t,r){return q(e).dispatch("post",[t,r])},w.prototype.mapply=w.prototype.post=function(e,t){return this.dispatch("post",[e,t])},q.send=q.mcall=q.invoke=function(e,t){return q(e).dispatch("post",[t,l(arguments,2)])},w.prototype.send=w.prototype.mcall=w.prototype.invoke=function(e){return this.dispatch("post",[e,l(arguments,1)])},q.fapply=function(e,t){return q(e).dispatch("apply",[void 0,t])},w.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},q.try=q.fcall=function(e){return q(e).dispatch("apply",[void 0,l(arguments,1)])},w.prototype.fcall=function(){return this.dispatch("apply",[void 0,l(arguments)])},q.fbind=function(e){var t=q(e),r=l(arguments,1);return function(){return t.dispatch("apply",[this,r.concat(l(arguments))])}},w.prototype.fbind=function(){var e=this,t=l(arguments);return function(){return e.dispatch("apply",[this,t.concat(l(arguments))])}},q.keys=function(e){return q(e).dispatch("keys",[])},w.prototype.keys=function(){return this.dispatch("keys",[])},q.all=W,w.prototype.all=function(){return W(this)},q.any=X,w.prototype.any=function(){return X(this)},q.allResolved=(M=K,D="allResolved",P="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(D+" is deprecated, use "+P+" instead.",new Error("").stack),M.apply(M,arguments)}),w.prototype.allResolved=function(){return K(this)},q.allSettled=function(e){return q(e).allSettled()},w.prototype.allSettled=function(){return this.then(function(e){return W(f(e,function(e){function t(){return e.inspect()}return(e=q(e)).then(t,t)}))})},q.fail=q.catch=function(e,t){return q(e).then(void 0,t)},w.prototype.fail=w.prototype.catch=function(e){return this.then(void 0,e)},q.progress=function(e,t){return q(e).then(void 0,void 0,t)},w.prototype.progress=function(e){return this.then(void 0,void 0,e)},q.fin=q.finally=function(e,t){return q(e).finally(t)},w.prototype.fin=w.prototype.finally=function(e){if(!e||"function"!=typeof e.apply)throw new Error("Q can't apply finally callback");return e=q(e),this.then(function(t){return e.fcall().then(function(){return t})},function(t){return e.fcall().then(function(){throw t})})},q.done=function(e,t,r,n){return q(e).done(t,r,n)},w.prototype.done=function(e,r,n){var i=function(e){q.nextTick(function(){if(C(e,o),!q.onerror)throw e;q.onerror(e)})},o=e||r||n?this.then(e,r,n):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},q.timeout=function(e,t,r){return q(e).timeout(t,r)},w.prototype.timeout=function(e,t){var r=b(),n=setTimeout(function(){t&&"string"!=typeof t||((t=new Error(t||"Timed out after "+e+" ms")).code="ETIMEDOUT"),r.reject(t)},e);return this.then(function(e){clearTimeout(n),r.resolve(e)},function(e){clearTimeout(n),r.reject(e)},r.notify),r.promise},q.delay=function(e,t){return void 0===t&&(t=e,e=void 0),q(e).delay(t)},w.prototype.delay=function(e){return this.then(function(t){var r=b();return setTimeout(function(){r.resolve(t)},e),r.promise})},q.nfapply=function(e,t){return q(e).nfapply(t)},w.prototype.nfapply=function(e){var t=b(),r=l(e);return r.push(t.makeNodeResolver()),this.fapply(r).fail(t.reject),t.promise},q.nfcall=function(e){var t=l(arguments,1);return q(e).nfapply(t)},w.prototype.nfcall=function(){var e=l(arguments),t=b();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},q.nfbind=q.denodeify=function(e){if(void 0===e)throw new Error("Q can't wrap an undefined function");var t=l(arguments,1);return function(){var r=t.concat(l(arguments)),n=b();return r.push(n.makeNodeResolver()),q(e).fapply(r).fail(n.reject),n.promise}},w.prototype.nfbind=w.prototype.denodeify=function(){var e=l(arguments);return e.unshift(this),q.denodeify.apply(void 0,e)},q.nbind=function(e,t){var r=l(arguments,2);return function(){var n=r.concat(l(arguments)),i=b();return n.push(i.makeNodeResolver()),q(function(){return e.apply(t,arguments)}).fapply(n).fail(i.reject),i.promise}},w.prototype.nbind=function(){var e=l(arguments,0);return e.unshift(this),q.nbind.apply(void 0,e)},q.nmapply=q.npost=function(e,t,r){return q(e).npost(t,r)},w.prototype.nmapply=w.prototype.npost=function(e,t){var r=l(t||[]),n=b();return r.push(n.makeNodeResolver()),this.dispatch("post",[e,r]).fail(n.reject),n.promise},q.nsend=q.nmcall=q.ninvoke=function(e,t){var r=l(arguments,2),n=b();return r.push(n.makeNodeResolver()),q(e).dispatch("post",[t,r]).fail(n.reject),n.promise},w.prototype.nsend=w.prototype.nmcall=w.prototype.ninvoke=function(e){var t=l(arguments,1),r=b();return t.push(r.makeNodeResolver()),this.dispatch("post",[e,t]).fail(r.reject),r.promise},q.nodeify=function(e,t){return q(e).nodeify(t)},w.prototype.nodeify=function(e){if(!e)return this;this.then(function(t){q.nextTick(function(){e(null,t)})},function(t){q.nextTick(function(){e(t)})})},q.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var J=R();return q})}).call(this,r(3),r(6).setImmediate)},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var a,u=[],l=!1,h=-1;function p(){l&&a&&(l=!1,a.length?u=a.concat(u):h=-1,u.length&&f())}function f(){if(!l){var e=c(p);l=!0;for(var t=u.length;t;){for(a=u,u=[];++h<t;)a&&a[h].run();h=-1,t=u.length}a=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new d(e,t)),1!==u.length||l||c(f)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,r){"use strict";r.r(t);var n=r(0);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 c(e,t){for(var r=0,n=t;r<n.length;r++)if(e==n[r])return!0;return!1}function a(e,t){if(void 0===e)return!1;for(var r=0,n=t;r<n.length;r++){var i=n[r];if(void 0===e[i])return!1;e=e[i]}return!0}function u(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 l(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 h(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return function e(t,r,n){for(var i=0,o=r.length;i<o;++i){var s=r[i];if(p(s)||m(s))for(var c=Object.keys(s),a=0,u=c.length;a<u;a++){var l=c[a],h=s[l];n&&p(h)?f(h)?t[l]=new Date(h.valueOf()):v(h)?t[l]=new RegExp(h):h.nodeName?t[l]=h.cloneNode(!0):(y=h)&&(y.nodeName||y.prop&&y.attr&&y.find)?t[l]=h.clone():(p(t[l])||(t[l]=d(h)?[]:{}),e(t[l],[h],!0)):t[l]=h}}var y;return t}(e,t,!1)}function p(e){return null!==e&&"object"==typeof e}function f(e){return"[object Date]"===toString.call(e)}var d=Array.isArray;function m(e){return"function"==typeof e}function v(e){return"[object RegExp]"===toString.call(e)}function y(e){return e&&e.window===e}function g(e){return void 0!==e}function S(e,t,r){void 0===r&&(r=5);var n=[],i=[];if("number"!=typeof r&&(r=5),t){if(e===t)throw new Error("Can't copy! Source and destination are identical.");if(d(t))t.length=0;else for(var o in t)delete t[o];return n.push(e),i.push(t),s(e,t,r)}return c(e,r);function s(e,t,r){if(--r<0)return"...";if(d(e))for(var n=0,i=e.length;n<i;n++)t.push(c(e[n],r));else if(null===(s=e)||"object"!=typeof s||Object.getPrototypeOf(s))if(e&&"function"==typeof e.hasOwnProperty)for(var o in e)e.hasOwnProperty(o)&&(t[o]=c(e[o],r));else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=c(e[o],r));else for(var o in e)t[o]=c(e[o],r);var s;return t}function c(e,t){if(void 0===t&&(t=5),!p(e))return e;var r=n.indexOf(e);if(-1!==r)return i[r];if(y(e))throw new Error("Can't copy! Making copies of Window instances is not supported.");var o=!1,a=function(e){switch(toString.call(e)){case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Float32Array]":case"[object Float64Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return new e.constructor(c(e.buffer),e.byteOffset,e.length);case"[object ArrayBuffer]":if(!e.slice){var t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}return e.slice(0);case"[object Boolean]":case"[object Number]":case"[object String]":case"[object Date]":return new e.constructor(e.valueOf());case"[object RegExp]":var r=new RegExp(e._source,e.toString().match(/[^/]*$/)[0]);return r.lastIndex=e.lastIndex,r;case"[object Blob]":return new e.constructor([e],{type:e.type})}if(m(e.cloneNode))return e.cloneNode(!0)}(e);return void 0===a&&(a=d(e)?[]:Object.create(Object.getPrototypeOf(e)),o=!0),n.push(e),i.push(a),o?s(e,a,t):a}}var C,I=function(){function e(){this.MOMENT_INVALID="Invalid date",this.SERVER_DATETIME_FORMAT="YYYY-MM-DD[T]HH:mm:ssZ",this.SERVER_TIME_FORMAT="HH:mm:ss",this.SERVER_DATE_FORMAT="YYYY-MM-DD"}return e.prototype.formatResponse=function(e,t){for(var r=0,n=t;r<n.length;r++){var i=n[r];e[i.path]=this.formatResponseValue(i.apiColumn.type,e[i.path])}},e.prototype.expandResponse=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n];e[o.path]=this.formatResponseValue(o.apiColumn.type,t[o.path])}},e.prototype.formatRequest=function(e,t,r){for(var n={},i=0,o=r;i<o.length;i++){var s=o[i],c=s.id,a=s.apiColumn;a.readOnly||this.compareFields(a.type,e[c],t[c])||(n[c]=this.formatRequestValue(s.apiColumn.type,t[c]))}return n},e.prototype.hasChanges=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n],s=o.id,c=o.apiColumn;if(!c.readOnly&&!this.compareFields(c.type,e[s],t[s]))return!0}return!1},e.prototype.getChanges=function(e,t,r){for(var n=[],i=0,o=r;i<o.length;i++){var s=o[i],c=s.id,a=s.apiColumn;a.readOnly||this.compareFields(a.type,e[c],t[c])||n.push({oldValue:e[c],newValue:t[c],column:s.apiColumn})}return n},e.prototype.copyFields=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n],s=o.path;t[s]=this.clone(o.apiColumn.type,e[s])}return t},e.prototype.shallowCopyFields=function(e,t,r,n){for(var i=0,o=n;i<o.length;i++){var s=o[i],c=s.path;r[c]=void 0!==e[c]?e[c]:this.clone(s.apiColumn.type,t[c])}return r},e.prototype.setDefaultValues=function(e,t){for(var r=0,n=t;r<n.length;r++){var i=n[r];e[i.id]=this.getDefaultValue(i.apiColumn.type)}return e},e.prototype.compareFields=function(e,t,r){if(void 0===t)return void 0===r;if(void 0===r)return!1;switch(e){case"date":case"time":case"datetime":return this.compareMomentObjects(t,r);case"duration":return this.compareDurations(t,r);case"id":case"item":case"link":case"child":case"sibling":return t==r;case"current":case"dimension":case"distance":case"double":case"filesize":case"number":case"power":case"quantity":case"volume":case"weight":case"coordinate":case"price":case"percentage":return this.compareFloats(t,r);case"int":case"bool":case"enum":case"email":case"phone":case"url":case"text":case"longtext":case"color":return t===r;default:return function e(t,r){if(t===r)return!0;if(null===t||null===r)return!1;if(t!=t&&r!=r)return!0;var n,i,o,s,c,a=typeof t;if(a===typeof r&&"object"===a){if(!d(t)){if(f(t))return!!f(r)&&((s=t.getTime())===(c=r.getTime())||s!=s&&c!=c);if(v(t))return!!v(r)&&t.toString()===r.toString();if(y(t)||y(r)||d(r)||f(r)||v(r))return!1;for(i in o=Object.create(null),t)if(!m(t[i])){if(!e(t[i],r[i]))return!1;o[i]=!0}for(i in r)if(!(i in o)&&g(r[i])&&!m(r[i]))return!1;return!0}if(!d(r))return!1;if(n=t.length,t.length===r.length){for(i=0;i<n;i++)if(!e(t[i],r[i]))return!1;return!0}}return!1}(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?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?n.invalid():n(e)},e.prototype.formatResponseDuration=function(e){return n.duration(null===e?0:e,"seconds")},e.prototype.formatResponseColor=function(e){return"#"===e.charAt(0)?e:"#"+e},e.prototype.formatRequestDateTime=function(e){return e.isValid()?e.format(this.SERVER_DATETIME_FORMAT):null},e.prototype.formatRequestDate=function(e){return e.isValid()?e.format(this.SERVER_DATE_FORMAT):null},e.prototype.formatRequestDuration=function(e){return e.asSeconds()},e.prototype.formatRequestColor=function(e){return"#"===e.charAt(0)?e.substring(1):e},e.prototype.getDefaultValue=function(e){switch(e){case"int":case"double":case"percentage":case"price":return 0;case"item":case"link":case"child":case"sibling":return null;case"bool":return!1;case"enum":return"0";case"date":case"datetime":case"time":return n.invalid();case"duration":return n.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 n(t);case"json":return S(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 n.duration(e)},e.prototype.cloneDate=function(e){return e.clone()},e.prototype.identity=function(e){return e},e}(),E=function(){function e(e,t){this.queryParserFactory=e,this.queryService=t}return e.prototype.processOptions=function(e){return i(e,{columns:[],query:null,queryItemType:null,queryParams:{},parent:null,deferRequest:!1,limit:null,entryKey:"",addLocalItems:!1})},e.prototype.createQuery=function(e){var t,r=e.parent;if(null===r)t=e.query;else{var n={linkedTo:r.itemType,query:{id:"&parentId"}};e.queryParams.parentId=r.itemId,t=null===e.query?n:this.queryService.addAndCondition(e.query,n)}var i=this.queryParserFactory.construct(t,e.queryParams).parse();return{object:i[0],string:i[1]}},e.prototype.getIdArray=function(e,t){void 0===t&&(t=[]);for(var r=0,n=e;r<n.length;r++){var i=n[r];t.push(i.itemId)}return t},e.prototype.filterArray=function(e,t){for(var r=[],n=[],i=0,o=e;i<o.length;i++){var s=o[i];t(s)?r.push(s):n.push(s)}if(0===n.length)return n;e.length=r.length;for(var c=0;c<e.length;c++)e[c]=r[c];return n},e}(),R={CACHED:"cached",PROMISED:"promised",EXPAND:"expand",PROMISED_EXPAND:"promised-expand",RESOLVE:"resolve",LOCAL:"local"},q=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p,f){this.errorHandler=e,this.itemRequestService=t,this.itemHandler=r,this.columnHandler=n,this.collectionEntryFactory=i,this.collectionCacheFactory=o,this.queryParserFactory=s,this.collectionEntryService=c,this.columnSetFactory=a,this.itemEntryService=u,this.keyService=l,this.promiseService=h,this.queryService=p,this.columnUtil=f,this.entries=this.collectionCacheFactory.construct()}return e.prototype.getPromises=function(e){var t=e[R.PROMISED],r=e[R.PROMISED_EXPAND],n=[];for(var i in t)n.push(t[i]);for(var i in r)n.push(r[i]);return n},e.prototype.getRequestIds=function(e){var t=[];for(var r in e[R.RESOLVE])t.push(r);for(var r in e[R.EXPAND])t.push(r);return t},e.prototype.removeFromAndAddToCollections=function(e,t){for(var r in e){var n=e[r],i=n.collection;i.removeItems(n.notfitting,null,!0),i.addItems(n.fitting,null,!0),n.maybe.length>0&&i.extend(Pe,null,!0,t)}},e.prototype.removeFromCollections=function(e,t,r){var n;for(var i in void 0===r&&(r=null),e){for(var o=e[i],s=o.fitting,c=o.maybe,a=o.collection,u=[],l=0,h=s;l<h.length;l++){var p=h[l];u.push(p.itemId)}for(var f=0,d=c;f<d.length;f++){var m=d[f];u.push(m)}null!==r&&a===r.entry?n=a.removeItems(u,r,t):a.removeItems(u,null,t)}return n},e.prototype.addItemsToCollections=function(e){return this.addToCollections(this.createCollectionMap(e),!1)},e.prototype.addToCollections=function(e,t,r){var n;for(var i in void 0===r&&(r=null),e){var o=e[i],s=o.collection;s.isDeferred()||(null!==r&&s===r.entry?n=s.addItems(o.fitting,r,t):s.addItems(o.fitting,null,t),t&&o.maybe.length>0&&s.extend(Pe,null,!0,t))}return n},e.prototype.batchExpand=function(e,t,r,n){var i=this;if(0===n.length)return this.promiseService.when(r);var o=[],s=[];for(var c in r)o.push(c),s=s.concat(r[c].entry.items);return this.itemRequestService.requestLinkItems(e,o,t,null,n).then(function(e){for(var c=i.itemRequestService.processExpansion(n,e,t,s),a=0,u=o;a<u.length;a++){var l=u[a];r[l].entry.updateColumns(c)}})},e.prototype.batchExtend=function(e,t,r,n,i,s){var c=this;if(void 0===s&&(s=!1),!o(i))return{};var a=[],u=[];for(var l in r.queryParams=n(r.queryParams),i){var h=i[l].entry;h.extendQuery(n),a.push(l),u=u.concat(h.getIdArray())}return this.itemRequestService.requestLinkItems(e,a,t,this.queryService.addAndCondition(this.collectionEntryService.createQuery(r).object,this.queryService.createNotIn(u)),r.columns).then(function(n){return c.itemRequestService.processLinkResponse(n,e,a,t,r)},this.errorHandler.reject).then(function(e){for(var t={},r=0,n=a;r<n.length;r++){var o=n[r],c=i[o],u=c.entry.addItems(e.items[o],c);t[o]=s?c.items:u}return t},this.errorHandler.reject)},e.prototype.batchFetch=function(e,t,r,n,i){var s=this,c=this.createStatusResource(e,t,r,n,i);return this.promiseService.all(this.getPromises(c)).then(function(){var t=s.getRequestIds(c);return t.length>0?s.itemRequestService.requestLinkItems(e,t,r,null===n.query?null:s.queryParserFactory.construct(n.query,n.queryParams).parse()[0],n.columns).then(function(i){return s.itemRequestService.processLinkResponse(i,e,t,r,n)},s.errorHandler.reject).then(function(e){return s.handleBatchResponse(c,e)},s.errorHandler.reject):o(c[R.LOCAL])?s.columnHandler.fetch(r,n.columns).then(function(e){return s.handleBatchResponse(c,{columns:s.columnSetFactory.construct(r,n.columns,e,!1)})},s.errorHandler.reject):c[R.CACHED]},this.errorHandler.reject)},e.prototype.clone=function(e,t,r){void 0===r&&(r={});var n=e.itemType,i=e.items,o=[];void 0===r[n]&&(r[n]={});for(var s=r[n],c=0,a=i;c<a.length;c++)s[a[c].itemId]=this.keyService.getLocalId();for(var u=0,l=i;u<l.length;u++){var h=l[u],p=this.itemHandler.cloneItem(s[h.itemId],h,r);null!==t.parent&&(p.parent=t.parent),o.push(p)}return this.create(n,t,e.columns,o)},e.prototype.create=function(e,t,r,n){return this.entries.add(this.collectionEntryFactory.construct(e,t)).resolve({columns:r,items:n})},e.prototype.createCollectionMap=function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r];this.expandCollectionMap(i,t)}return t},e.prototype.createStatusResource=function(e,t,r,n,i){var o={};for(var s in R)o[R[s]]={};for(var c=0,a=t;c<a.length;c++){var u,l=a[c],h=this.collectionEntryService.processOptions(n);h.parent={itemType:e,itemId:l},o[(u=this.getEntryStatus(r,h,i)).status][l]=u.entry}return o},e.prototype.expandCollectionMap=function(e,t,r){void 0===r&&(r=this.entries);var n=void 0!==e.parent?e.parent:{},i=r.getByFittingItem(n.itemType,n.itemId,e.itemType,this.itemEntryService.getFields(e));for(var o in i)for(var s=0,c=i[o];s<c.length;s++){var a=c[s],u=a.id;void 0===t[u]&&(t[u]={collection:a,fitting:[],notfitting:[],maybe:[]}),t[u][o].push("fitting"===o?e:e.itemId)}},e.prototype.fetch=function(e,t,r,n){var i=this.getEntryStatus(e,t,n),o=i.entry;switch(i.status){case R.CACHED:return this.promiseService.when(o);case R.PROMISED:return o.promise;case R.EXPAND:return o.expand(t.columns);case R.PROMISED_EXPAND:return o.promise.then(function(){return o.expand(t.columns)},this.errorHandler.reject);case R.RESOLVE:return this.resolveRemote(o,r);case R.LOCAL:return this.resolveLocal(o,r)}},e.prototype.getDeferredEntryStatus=function(e,t){var r=e.options,n=r.columns,i=!1;return e.reloadQueued?(e.reloadQueued=!1,r.columns=this.columnUtil.mergeRequestColumns(t.columns,n).merged,{entry:e,status:e.isLocal()?R.LOCAL:R.RESOLVE}):(!0===n?(console.warn("Columns: true for collections is deprecated!"),i=!0):i=this.columnUtil.isColumnSubset(t.columns,n,!1),{entry:e,status:i?R.PROMISED:R.PROMISED_EXPAND})},e.prototype.getEntryStatus=function(e,t,r){var n=this.collectionEntryService.createQuery(t),i=this.entries.getByQuery(e,n);return null===i?this.getNewEntryStatus(e,n,t,r):i.isDeferred()?this.getDeferredEntryStatus(i,t):{entry:i,status:this.columnUtil.isColumnSubset(t.columns,i.columns.request,i.columns.true)?R.CACHED:R.EXPAND}},e.prototype.getNewEntryStatus=function(e,t,r,n){var i,o;if(r.deferRequest){if(null===(i=n.getByQuery(e,t)))return{entry:n.add(this.collectionEntryFactory.construct(e,r)),status:R.PROMISED};(o=i.options).columns=this.columnUtil.mergeRequestColumns(o.columns,r.columns).merged}else i=this.collectionEntryFactory.construct(e,r);return this.entries.add(i),{entry:i,status:i.isLocal()?R.LOCAL:R.RESOLVE}},e.prototype.handleBatchResponse=function(e,t){var r={};for(var n in e.cached)r[n]=e.cached[n];for(var n in e.resolve)r[n]=e.resolve[n].resolve({items:t.items[n],columns:t.columns});for(var n in e.expand)(i=e.expand[n]).updateColumns(t.columnExpansion),r[n]=i;for(var n in e.local){var i=e.local[n];r[n]=i.resolve({items:this.itemHandler.entries.getByParent(i.parent.itemType,n,i.itemType),columns:t.columns})}return r},e.prototype.removeItemsFromAndAddItemsToCollections=function(e){return this.removeFromAndAddToCollections(this.createCollectionMap(e),!1)},e.prototype.removeItemsFromCollections=function(e){return this.removeFromCollections(this.createCollectionMap(e),!1)},e.prototype.resolveLocal=function(e,t){var r=this,n=e.itemType,i=e.options.columns;return this.columnHandler.fetch(n,i).then(function(o){return e.resolve({items:t.getByQuery(n,e.query),columns:r.columnSetFactory.construct(n,i,o,!1)})},this.errorHandler.reject)},e.prototype.resolveRemote=function(e,t){var r,n=this,i=e.itemType,o=e.options;return this.itemRequestService.requestItems(e).then(function(t){return r=n.columnSetFactory.construct(i,o.columns,t.fetchColumnsObject()),n.itemRequestService.processResponse(t,t.links[i],e.parent,r)},this.errorHandler.reject).then(function(n){return e.resolve({items:n.concat(o.addLocalItems?t.getLocalByQuery(i,e.query):[]),columns:r})},this.errorHandler.reject)},e}(),T=function(){function e(){}return e.prototype.processOptions=function(e){return i(e,{editItems:!1,editCollection:!1,modInstant:!1,enableSave:!0,onItemsCreated:De,onChange:De,onAdd:De,onRemove:De,onAddInitial:De,onRemoveInitial:De,onDeactiveateItem:De,onDeactivateCollection:De,resourceKey:null,clearOnTabChange:!0,clearOnSubTabChange:!0,custom:null})},e.prototype.getIdArray=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];t.push(i.entry.itemId)}return t},e}(),b=function(){function e(e){this.columnUtil=e,this.cache={},this.allColumns={}}return e.prototype.setColumn=function(e,t){void 0===this.cache[e]&&(this.cache[e]={});var r=this.cache[e],n=t.id;return void 0===r[n]&&(r[n]=t),r[n]},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),{missing:n,cached:r}},e.prototype.containsAll=function(e){return!0===this.allColumns[e]},e.prototype.getColumns=function(e){var t=void 0===this.cache[e]?[]:this.cache[e],r={};return r[e]=t,r},e.prototype.retrieveColumns=function(e,t,r,n){this.retrieveColumn(e,"id",r,n);for(var i=0,o=t;i<o.length;i++){var s=o[i];this.retrieveColumn(e,s,r,n)}},e.prototype.retrieveColumn=function(e,t,r,n){var i=this.columnUtil.parseRequestColumn(t),o=this.getColumn(e,i.id);if(void 0!==o){if(void 0===n[e]&&(n[e]={}),n[e][i.id]=o,0!==i.children.length){var s=[];if(this.retrieveColumns(o.itemType,i.children,s,n),0!==s.length){var c={};c[i.id]=s,r.push(c)}}}else r.push(t)},e.prototype.getColumn=function(e,t){if(void 0!==this.cache[e])return this.cache[e][t]},e}(),F=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={},n=0,i=e;n<i.length;n++){var o=i[n],s=t.push(this.fetch(o,["id"]));r[o]=s-1}return this.promiseService.all(t).then(function(e){for(var t={},n=0;n<e.length;n++){var i=r[n];t[i]=e[i][i].id.name}return t},this.errorHandler.reject)},e.prototype.request=function(e,t,r){var n,i=this;void 0===r&&(r={});var o=((n={})[e]=t,n);return this.apiRequestService.columns(e,o,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;void 0===r&&(r={});var 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}(),k=function(){function e(){}return e.prototype.getColumnPath=function(e,t){for(var r="",n="",i=0,o=e;i<o.length;i++)n+=r+o[i].id,r=">";return null!==t&&(n+=":"+t),n},e.prototype.getDateFormatOptions=function(e){var t=n(),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&&h(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.isFloatColumn=function(e){switch(e.type){case"double":case"volume":case"weight":case"distance":case"dimension":case"power":case"current":case"price":case"percentage":return!0;default:return!1}},e.prototype.isIntColumn=function(e){switch(e.type){case"int":case"number":case"quantity":return!0;default:return!1}},e.prototype.isNumberColumn=function(e){return this.isFloatColumn(e)||this.isIntColumn(e)},e.prototype.isCustomColumn=function(e){return"customfield"===e.fieldtype},e.prototype.isItemColumn=function(e,t){switch(void 0===t&&(t=!0),e.type){case"id":return t;case"item":case"child":case"sibling":case"link":return!0;default:return!1}},e.prototype.isDateColumn=function(e){switch(e.type){case"datetime":case"date":return!0;default:return!1}},e.prototype.isRenderedColumn=function(e){switch(e.type){case"datetime":case"date":case"duration":return!0;default:return!1}},e.prototype.isFilteredColumn=function(e){if("staffel"===e.id)return!0;if(void 0!==e.generator)return!0;switch(e.type){case"price":case"bool":case"enum":case"volume":case"weight":case"distance":case"dimension":case"quantity":case"email":case"url":case"datetime":case"date":case"time":case"duration":case"html":case"textreplace":case"longtext":case"percentage":return!0;default:return!1}},e.prototype.isFormattedColumn=function(e){switch(e.type){case"datetime":case"date":case"time":case"duration":case"color":case"json":case"number":case"filesize":return!0;default:return!1}},e.prototype.isSelectableColumn=function(e){switch(e.type){case"blob":case"coordinate":case"forceupdate":case"id":case"json":case"order":case"parentid":case"parenttype":case"password":case"token":return!1}return!0},e.prototype.hasLocationProperty=function(e,t){return 0!=(t&e.location)},e.prototype.isEditableColumn=function(e){if(e.readOnly)return!1;switch(e.type){case"date":case"datetime":case"duration":return!1}return!0},e.prototype.isSearchableColumn=function(e){switch(e.type){case"email":case"phone":case"text":case"longtext":case"html":return!0;default:return!1}},e.prototype.getDefaultWeight=function(e){switch(e.type){case"double":case"price":case"bool":case"int":case"percentage":case"color":case"number":case"power":case"current":return.5;case"url":case"enum":case"email":case"text":case"item":case"link":return 1.5;case"longtext":case"html":case"textreplace":return 2;case"date":case"datetime":case"time":case"duration":default:return 1}},e.prototype.getComparators=function(e){switch(e.type){case"dimension":case"weight":case"price":return["=",">","<"];case"date":case"datetime":case"time":case"duration":return[">","<"];default:return["=","!="]}},e.prototype.isColumnSubset=function(e,t,r){if(!0===e)return r;for(var n=0,i=e;n<i.length;n++){var o=i[n];if(!this.containsColumn(o,t))return!1}return!0},e.prototype.containsColumn=function(e,t){var r=this.parseRequestColumn(e),n=this.findColumn(r.id,t);if(-1===n)return!1;if(0===r.children.length)return!0;if("string"==typeof t[n])return!1;for(var i=0,o=r.children;i<o.length;i++){var s=o[i];if(!this.containsColumn(s,t[n][r.id]))return!1}return!0},e.prototype.responseColumnsAvailable=function(e,t,r){for(var n=0,i=t;n<i.length;n++){var o,s=i[n],c=this.parseRequestColumn(s),a=c.children,u=r[e];if(void 0===u)return!1;if(void 0===(o=u[c.id]))return!1;if(a.length>0&&!this.responseColumnsAvailable(o.itemType,a,r))return!1}return!0},e.prototype.mergeRequestColumns=function(e,t){if(!0===e)return{merged:!0,difference:[]};if(!0===t)return{merged:!0,difference:!0};for(var r=S(e),n=[],i=0,o=t;i<o.length;i++){var s=o[i],c=this.mergeRequestColumn(s,r);null!==c&&n.push(c)}return{merged:r,difference:n}},e.prototype.mergeRequestColumn=function(e,t){var r,n,i=this.parseRequestColumn(e),o=this.findColumn(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=[],c=0,a=i.children;c<a.length;c++){var u=a[c],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.parseRequestColumn=function(e){var t="string"==typeof e,r=t?e:s(e);return{id:r,children:t?[]:e[r]}},e.prototype.mergeResponseColumns=function(e,t){var r={},n={};for(var i in e)if(void 0!==t[i]){var o=this.mergeResponseColumnMap(e[i],t[i]);r[i]=o.merged,n[i]=o.difference}else r[i]=e[i];for(var i in t)void 0===e[i]&&(r[i]=t[i],n[i]=t[i]);return{merged:r,difference:n}},e.prototype.mergeResponseColumnMap=function(e,t){var r={},n={};for(var i in e)r[i]=e[i];for(var i in t)g(e[i])||(r[i]=t[i],n[i]=t[i]);return{merged:r,difference:n}},e.prototype.isLocalColumnId=function(e){return"__"===e.substring(0,2)},e.prototype.processConfigColumns=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];this.isLocalColumnId(i)||this.processConfigColumn(this.parseConfigColumn(i),t)}return t},e.prototype.processLocalConfigColumns=function(e,t,r,n){for(var i={},o=0,s=t;o<s.length;o++){var c=s[o];i[c.id]=c}for(var a=0,u=e;a<u.length;a++){var l=u[a],h=l.split(":"),p=h[0];this.isLocalColumnId(p)?void 0!==i[p]&&(n(l,i[p]),delete i[p]):r(l,p,h[1])}},e.prototype.consolidateColumns=function(e,t,r){var n=this,i=[],o=S(r);return this.processLocalConfigColumns(e,t,function(e,t){n.processConfigColumn(t.split(">"),o)},function(e,t){i.push(t),o=n.mergeRequestColumns(o,t.valueOptions.requestColumns).merged}),{request:o,local:i}},e.prototype.parseConfigColumn=function(e){return e.split(":")[0].split(">")},e.prototype.processConfigColumn=function(e,t){var r,n=e[0];if(1===e.length)-1===t.indexOf(n)&&t.push(n);else{var i=this.findColumnObject(n,t);-1===i&&(i=t.push(((r={})[n]=[],r))-1),this.processConfigColumn(e.slice(1),t[i][n])}},e.prototype.findColumnObject=function(e,t){for(var r=0;r<t.length;r++)if(s(t[r])===e)return r;return-1},e.prototype.findColumn=function(e,t){for(var r=0;r<t.length;r++){var n=t[r];if("string"!=typeof n){if(s(n)===e)return r}else if(n===e)return r}return-1},e}(),w=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p,f,d){this.apiRequestService=e,this.resourceCacheInterface=t,this.authInterface=r,this.errorHandler=n,this.itemHandler=i,this.collectionHandler=o,this.columnSetFactory=s,this.itemRequestService=c,this.resourceCacheFactory=a,this.moduleChangesCompilerFactory=u,this.collectionEntryService=l,this.collectionResourceService=h,this.itemEntryService=p,this.keyService=f,this.queryService=d}return e.prototype.getItemDefinition=function(e,t,r){var n=this.keyService.parseStateKey(t),i={itemType:e,options:r,itemId:t};if(null!==n){switch(n.type){case"new":i.itemId=this.keyService.getLocalId();break;case"duplicate":r.duplicate=n.itemId,void 0===r.templateOptions&&(r.templateOptions={}),void 0===r.templateOptions.item&&(r.templateOptions.item=n.itemId),i.itemId=this.keyService.getLocalDuplicateId()}return i}return i.itemId=t,i},e.prototype.createCollectionMap=function(e,t){for(var r=this.getResourceCache(),n=r.collections,i={},o=0,s=e;o<s.length;o++){var c=s[o];t&&r.addSingleItem(c,{},!1),this.collectionHandler.expandCollectionMap(c,i,n)}return i},e.prototype.getItemById=function(e,t,r){var n=this;return this.itemHandler.fetchItem(e,t,r).then(function(e){return n.addSingleItem(e,r,!1)},this.errorHandler.reject)},e.prototype.getItemsById=function(e,t,r){var n=this;return this.itemHandler.fetchItems(e,t,this.itemEntryService.processOptions(r)).then(function(e){return n.addSingleItems(e,r)},this.errorHandler.reject)},e.prototype.getItemsByQuery=function(e,t,r){var n=this,i=this.itemEntryService.processOptions(r),o={};return o[e]=i.columns,this.apiRequestService.query(e,this.queryService.addParentCondition(t,i.parent),o).then(function(t){return n.itemRequestService.processResponse(t,t.links[e],i.parent,n.columnSetFactory.construct(e,i.columns,t.fetchColumnsObject()))},this.errorHandler.reject).then(function(e){return n.addSingleItems(e,r)},this.errorHandler.reject)},e.prototype.getDuplicateById=function(e,t,r){void 0===r&&(r={}),r.edit=!0;var n=this.getItemDefinition(e,this.keyService.getDuplicateStateKey(t),r);return this.getItemByDef(n,!1)},e.prototype.getNewResource=function(e,t,r,n){var i=this;return void 0===t&&(t={}),t.edit=!0,void 0===n&&(n=!1),this.itemHandler.fetchItem(e,this.keyService.getLocalId(),this.itemEntryService.processOptions(t)).then(function(e){var o=i.addSingleItem(e.main,t,n),s=i.processLinkedItems(e.linked,t,!0);return r?{main:o,linked:s}:o},this.errorHandler.reject)},e.prototype.getCollectionDef=function(e,t){return{itemType:e,options:{entry:this.collectionEntryService.processOptions(t),resource:this.collectionResourceService.processOptions(t)}}},e.prototype.getLinkCollectionsDef=function(e,t,r,n,i){return{itemType:r,linkType:e,linkIdArray:t,linkField:n,options:{entry:this.collectionEntryService.processOptions(i),resource:this.collectionResourceService.processOptions(i)}}},e.prototype.getCollection=function(e,t,r){var n=this,i=this.getResourceCache(),o=this.collectionEntryService.processOptions(r);return o.query=t,this.collectionHandler.fetch(e,o,i.items,i.deferredCollections).then(function(e){return n.addCollection(e,r)},this.errorHandler.reject)},e.prototype._getCollection=function(e,t){var r=this,n=this.getResourceCache();return this.collectionHandler.fetch(e,this.collectionEntryService.processOptions(t),n.items,n.deferredCollections).then(function(e){return r.addCollection(e,t)},this.errorHandler.reject)},e.prototype.getCollectionFromDef=function(e){var t=this,r=this.getResourceCache();return this.collectionHandler.fetch(e.itemType,e.options.entry,r.items,r.deferredCollections).then(function(r){return t.addCollection(r,e.options.resource,!1)},this.errorHandler.reject)},e.prototype.getLinkCollection=function(e,t,r,n){var i=this,o=this.getResourceCache(),s=this.collectionEntryService.processOptions(n);return s.parent={itemType:e,itemId:t},this.collectionHandler.fetch(r,s,o.items,o.deferredCollections).then(function(e){return i.addCollection(e,n)},this.errorHandler.reject)},e.prototype.getLinkCollections=function(e,t,r,n){var i=this;return this.collectionHandler.batchFetch(e,t,r,this.collectionEntryService.processOptions(n),this.getResourceCache().deferredCollections).then(function(e){return i.addCollections(e,i.collectionEntryService.processOptions(n))},this.errorHandler.reject)},e.prototype.getLinkCollectionsFromDef=function(e){var t=this;return this.collectionHandler.batchFetch(e.linkType,e.linkIdArray,e.itemType,e.options.entry,this.getResourceCache().deferredCollections).then(function(r){return t.addCollections(r,e.options.resource)},this.errorHandler.reject)},e.prototype.getAllLinkCollections=function(e,t,r){var n=this;return this.apiRequestService.query(e,{},{}).then(function(i){return n.getLinkCollections(e,i.links[e],t,r)},this.errorHandler.reject)},e.prototype.getItemByDef=function(e,t){var r=this;return this.itemHandler.fetchItem(e.itemType,e.itemId,this.itemEntryService.processOptions(e.options)).then(function(n){var i;return void 0!==n.linked?(r.processLinkedItems(n.linked,e.options,!1),i=n.main):i=n,r.addSingleItem(i,e.options,t)},this.errorHandler.reject)},e.prototype.cloneItem=function(e,t,r){return this.addSingleItem(this.itemHandler.cloneItem(e,t.entry),r)},e.prototype.cloneCollection=function(e,t,r){return this.addCollection(this.collectionHandler.clone(e.entry,this.collectionEntryService.processOptions(t),r),t)},e.prototype.saveCurrentTab=function(e,t,r,n,i){return this.saveCurrentResourceCache(e,t,r,n,i)},e.prototype.saveCurrentResourceCache=function(e,t,r,n,i){var o=this;return void 0===r&&(r=!1),void 0===i&&(i=!1),this.getResourceCache().save(e,t,r,n).then(function(t){return e?t:o.resourceCacheInterface.updateTabParams(t,!i).then(function(){return t},o.errorHandler.reject)},this.errorHandler.reject)},e.prototype.getCurrentCollections=function(){return this.getResourceCache().collections},e.prototype.getCurrentItems=function(){return this.getResourceCache().items},e.prototype.getCurrentChanges=function(){var e=this.getResourceCache();if(void 0===e.rootItem)throw new Error("itemAdministrator: No root item!");return this.moduleChangesCompilerFactory.construct(e.rootItem,e.items,e.collections).process()},e.prototype.addSingleItem=function(e,t,r){return this.getResourceCache().addSingleItem(e,t,r)},e.prototype.addSingleItems=function(e,t){for(var r=this.getResourceCache(),n=[],i=0,o=e;i<o.length;i++){var s=o[i];n.push(r.addSingleItem(s,t,!1))}return n},e.prototype.addCollection=function(e,t,r){return void 0===r&&(r=!0),this.getResourceCache().addCollection(e,r?this.collectionEntryService.processOptions(t):t)},e.prototype.addCollections=function(e,t){var r=this.getResourceCache(),n={};for(var i in e)n[i]=r.addCollection(e[i],t);return n},e.prototype.processLinkedItems=function(e,t,r){for(var n=this.getResourceCache(),i=n.collections,o={},s=0,c=e;s<c.length;s++){var a=c[s],l=a.itemType,h=a.itemEntries,p={};o[l]=[];for(var f=0,d=h;f<d.length;f++){var m=d[f];o[l].push(n.addSingleItem(m,t,!1)),r&&this.collectionHandler.expandCollectionMap(m,p,i),"Projectnotitie"===l&&u(n.tabRequestParameters,[m.itemType,m.itemId],[{},{no_notification:!0}])}r&&this.collectionHandler.addToCollections(p,!1)}return o},e.prototype.getTabEntry=function(){return this.getResourceCache()},e.prototype.getResourceCache=function(){return this.resourceCacheInterface.getCacheManager(this.authInterface.getUserId())},e.prototype.resetTabEntry=function(){return this.resetResourceCache()},e.prototype.resetResourceCache=function(){var e=this.getResourceCache(),t=this.resourceCacheFactory.construct();e.clearResources(),this.resourceCacheInterface.setCacheManager(this.authInterface.getUserId(),t)},e.prototype.addToCollections=function(e,t){return this.collectionHandler.addToCollections(this.createCollectionMap(e,!0),!1,t)},e.prototype.removeFromCollections=function(e,t){return this.collectionHandler.removeFromCollections(this.createCollectionMap(e,!1),!1,t)},e.prototype.updateItemIdMap=function(e,t){if(void 0!==t)for(var r in t){var n=t[r];void 0!==e[r]&&(e[n]=e[r],delete e[r])}},e.prototype.createCollectionResource=function(e,t,r){return this.addCollection(e,t,r)},e.prototype.createItemResource=function(e,t,r){return this.addSingleItem(e,t,r)},e.prototype.createItemResources=function(e,t){return this.addSingleItems(e,t)},e.prototype.onBeforeSave=function(e,t){return this.getResourceCache().registerCallback("onBeforeSave",e,t)},e.prototype.onSaveSuccess=function(e,t){return this.getResourceCache().registerCallback("onSaveSuccess",e,t)},e.prototype.onSaveWithoutClosing=function(e,t){return this.getResourceCache().registerCallback("onSaveWithoutClosing",e,t)},e}(),O=function(){function e(e,t,r){this.apiFormatter=e,this.keyService=t,this.promiseService=r,this.undefinedItemError="Het opgevraagde item bestaat niet / Je hebt niet voldoende rechten om dit item te bekijken",this.ALL_PERMISSIONS=7}return e.prototype.resetDerived=function(e,t){for(var r=[],n=0,i=e.columns.root;n<i.length;n++){var o=i[n];-1!==t.indexOf(o.id)&&r.push(o)}!function t(r){for(var n=0,i=r;n<i.length;n++){var o=i[n];o.isLeaf||t(o.children),delete e.derived[o.path]}}(r)},e.prototype.defer=function(e,t){return e.deferred=this.promiseService.defer(),e.deferRequest=t,e},e.prototype.resolve=function(e){var t=e.deferred;return delete e.deferred,delete e.deferRequest,t.resolve(e),e},e.prototype.reject=function(e,t){return void 0===t&&(t=this.undefinedItemError),e.deferred.reject(t),delete e.deferred,delete e.deferRequest,e},e.prototype.clearResources=function(e){e.resources=[]},e.prototype.deactivateResources=function(e){for(var t=0,r=e.resources;t<r.length;t++)r[t].deactivate()},e.prototype.getFields=function(e){return void 0!==e.modified?e.modified:e.initial},e.prototype.expand=function(e,t,r,n){var i=n.difference;return e.columns=n.merged,this.apiFormatter.expandResponse(e.initial,t,i.main),this.apiFormatter.expandResponse(e.derived,r,i.derived),void 0===e.modified?e:(this.apiFormatter.expandResponse(e.modified,t,i.main),e)},e.prototype.processOptions=function(e){return i(e,{columns:!0,parent:null,templateOptions:{},templateColumns:{},deferRequest:!1})},e.prototype.getConversionValue=function(e,t,r){if(void 0!==r[e])return r[e][t]},e.prototype.updateFields=function(e,t,r){void 0===r&&(r=!0);var n=e.columns.main,i=e.columns.formatted.main,o=e.initial,s=e.modified;if(void 0!==s){for(var c=0,a=n;c<a.length;c++){var u=(p=a[c]).id;(r||this.apiFormatter.compareFields(p.apiColumn.type,o[u],s[u]))&&(s[u]=t[u])}this.apiFormatter.formatResponse(s,i)}for(var l=0,h=n;l<h.length;l++){var p;o[u=(p=h[l]).id]=t[u]}return this.apiFormatter.formatResponse(o,i),e},e.prototype.updateItemValue=function(e,t,r,n){var i,o=r.id,s=t[o];"link"===r.type&&void 0===s?void 0!==e.parent&&(i=e.parent.itemId):i=this.getConversionValue(r.itemType,s,n),void 0!==i&&(t[o]=i)},e.prototype.updateItemFields=function(e,t){for(var r=e.columns.item,n=e.initial,i=e.modified,o=0,s=r;o<s.length;o++){var c=s[o].apiColumn;this.updateItemValue(e,n,c,t),void 0!==i&&this.updateItemValue(e,i,c,t)}},e.prototype.process=function(e){var t=e.columns.formatted;return this.apiFormatter.formatResponse(e.initial,t.main),this.apiFormatter.formatResponse(e.derived,t.derived),e},e.prototype.formatRequest=function(e){return void 0===e.modified?{}:this.apiFormatter.formatRequest(this.keyService.isLocalId(e.itemId)?{}:e.initial,e.modified,e.columns.main)},e.prototype.setDisplayName=function(e){if(void 0!==e.modified){var t=this.getDisplayName(e);t&&(e.modified.displayname=t)}},e.prototype.getDisplayName=function(e){var t=void 0===e.modified?e.initial:e.modified;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);case"Reparatie":return e.derived["materiaal>naam"];default:return t[this.getTitleField(e.itemType)]}},e.prototype.getFullName=function(e,t,r){return e.trim().concat(" ",t).trim().concat(" ",r)},e.prototype.getTitleField=function(e){switch(e){case"Exemplaar":return"serienummer";case"Factuur":return"nummer";case"Files":return"friendlyname";case"Functie":case"Standaardfunctie":return"naamintern";case"Voorraadmutatie":return"omschrijving";case"Barcode":return"code";case"Betaalmiddel":case"Betalingsconditie":case"Briefpapier":case"TaxClass":case"TaxSchema":case"Condition":case"Factuurmoment":case"Functiegroep":case"Grootboek":case"Inhuur":case"Inhuurgroep":case"Inhuurmateriaal":case"Materiaal":case"MateriaalCat":case"Medewerkertarief":case"Notitie":case"Planningmateriaal":case"Project":case"Staffelgroep":case"Subproject":case"Taak":case"Tag":case"Template":case"Tijd":case"Titel":case"Type":case"Voertuig":return"naam";default:return"displayname"}},e.prototype.getChanges=function(e,t){return void 0!==e.modified||t?this.apiFormatter.getChanges(e.initial,t?{}:e.modified,e.columns.main):[]},e.prototype.isLocal=function(e){return this.keyService.isLocalId(e.itemId)},e.prototype.isLockable=function(e){if(this.isLocal(e))return!1;switch(e.itemType){case"Project":case"Materiaal":case"Contact":case"Medewerker":case"Voertuig":case"Template":return!0;default:return!1}},e.prototype.hasChanges=function(e){return void 0!==e.modified&&this.apiFormatter.hasChanges(e.initial,e.modified,e.columns.main)},e.prototype.resetModified=function(e){var t=e.columns.main;if(void 0!==e.modified)for(var r=0,n=t;r<n.length;r++){var i=n[r];e.modified[i.id]=this.apiFormatter.clone(i.apiColumn.type,e.initial[i.id])}},e.prototype.setInitial=function(e,t,r){var n;for(var i in t)e.initial[i]=t[i];if(void 0===e.modified)return r&&this.callOnChange(e,this.apiFormatter.copyFields(e.initial,{},e.columns.main)),e;for(var i in n=this.apiFormatter.copyFields(e.modified,{},e.columns.main),t)e.modified[i]=t[i];return r&&this.callOnChange(e,n),e},e.prototype.setModified=function(e,t){var r=e.columns,n=r.response[e.itemType];if(void 0===e.modified){var i=e.resources,o=e.initial,s=e.modified={};if(void 0===t)this.apiFormatter.copyFields(o,s,r.main);else for(var c in this.apiFormatter.shallowCopyFields(t,o,s,r.main),t)void 0===n[c]&&(s[c]=t[c]);for(var a=0,u=i;a<u.length;a++)u[a].fields=s;return e}if(void 0===t)return e;for(var c in t)e.modified[c]=t[c];return e},e.prototype.setDerived=function(e,t){for(var r in t)e.derived[r]=t[r];return e},e.prototype.processLocal=function(e,t,r,i,o){return e.initial={permissions:this.ALL_PERMISSIONS},this.updateFields(e,t),this.updateItemFields(e,o),this.setModified(e,r),e.modified.created=n(),e.derived=i,e},e.prototype.setParent=function(e,t,r){return e.parent={itemType:t,itemId:r},e},e.prototype.callOnChange=function(e,t){for(var r=0,n=e.resources.length;r<n;r++){var i=e.resources[r];null!==i&&i.options.onChange(i,t)}},e}(),j=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p,f){this.apiRequestService=e,this.authInterface=t,this.errorHandler=r,this.itemEntryFactory=n,this.columnHandler=i,this.itemCacheFactory=o,this.batchStatusFactory=s,this.columnExpansionFactory=c,this.columnSetFactory=a,this.itemEntryService=u,this.apiFormatter=l,this.keyService=h,this.promiseService=p,this.columnUtil=f,this.templates={},this.entries=this.itemCacheFactory.construct()}return e.prototype.getItemId=function(e){return e.itemId},e.prototype.getPromise=function(e){return e.deferred.promise},e.prototype.fetchItem=function(e,t,r){var n=this,i=this.getEntryStatus(e,t,r),o=i.entry,s=i.status;return s===R.LOCAL?this.fetchTemplate(e,r.templateOptions,r.templateColumns).then(function(e){return n.resolveLocal(o,r.parent,e)},function(e){return n.itemEntryService.reject(o,e),e}):this.resolveCached(o,s,r)},e.prototype.fetchItems=function(e,t,r){for(var n=this,i=this.batchStatusFactory.construct(function(e){return n.getItemId(e)},function(e){return n.getPromise(e)}),o={},s=0,c=t;s<c.length;s++){var a=c[s];i.add(this.getEntryStatus(e,a,r))}return o.entries=i.getPromises(),i.hasRequests()&&(o.requests=this.requestItem(e,i.getRequestIds(),r.columns)),i.hasEntries([R.LOCAL])&&(o.template=this.fetchTemplate(e,r.templateOptions,r.templateColumns)),this.promiseService.all(o).then(function(t){return n.batchResolve(e,i,r.columns,t)},this.errorHandler.reject)},e.prototype.resolveCached=function(e,t,r){var n=this,i=e.itemType,o=e.itemId,s=e.columns.request;switch(t){case R.CACHED:return this.promiseService.when(e);case R.PROMISED:return e.deferred.promise;case R.PROMISED_EXPAND:return e.deferred.promise.then(function(){return n.resolveCached(e,n.getCachedEntryStatus(e,r),r)},this.errorHandler.reject)}if(t===R.EXPAND){var c=this.columnUtil.mergeRequestColumns(s,r.columns).difference;this.requestItem(i,o,c).then(function(t){n.resolveExpansion(e,n.columnExpansionFactory.construct(i,c,t.fetchColumnsObject()),t)},function(t){n.itemEntryService.reject(e,t)})}else this.requestItem(i,o,s).then(function(t){n.resolveRemote(e,n.columnSetFactory.construct(i,s,t.fetchColumnsObject()),t)},function(t){n.itemEntryService.reject(e,t)});return e.deferred.promise},e.prototype.resolveLocal=function(e,t,r){var n=e.itemType,i=e.itemId,o=this.createConversionMap(n,i,!0,r.response);return e.columns=r.columns,null!==t&&this.itemEntryService.setParent(e,t.itemType,t.itemId),this.itemEntryService.processLocal(e,r.fields,{},{},o),this.setCreator(e),this.itemEntryService.resolve(e),{main:e,linked:this.createLocalEntries(n,i,r,o)}},e.prototype.resolveExpansion=function(e,t,r){var n=e.itemType,i=e.itemId,o=t(e.columns,!0);return null===o?e:(this.itemEntryService.expand(e,r.fetchObject(n,i),r.fetchDerivedObject(n,i,o.difference.root),o),this.itemEntryService.resolve(e))},e.prototype.resolveRemote=function(e,t,r){var n=e.itemType,i=e.itemId,o=r.fetchObject(n,i);return void 0===o?(this.itemEntryService.reject(e),this.entries.clear(e),null):this.resolveDeferredEntry(e,o,r.fetchDerivedObject(n,i,t.root),t)},e.prototype.fetchTemplate=function(e,t,r){var n=this;void 0===t&&(t={}),void 0===r&&(r={});var i=o(t),c=s(r);if(!i){var a=this.templates[e];if(void 0!==a&&(null===c||this.columnUtil.responseColumnsAvailable(c,r[c],a.responseColumns)))return this.promiseService.when(a)}return this.promiseService.all([this.apiRequestService.template(e,t),null===c?{}:this.columnHandler.fetch(c,r[c])]).then(function(t){var r=t[0],o=n.columnUtil.mergeResponseColumns(r.fetchColumnsObject(),t[1]).merged,s={fields:r.fetchObject(e,r.links[e][0]),columns:n.columnSetFactory.construct(e,!0,o),response:r,responseColumns:o};return!i&&r.cacheable&&(n.templates[e]=s),s},this.errorHandler.reject)},e.prototype.getEntryStatus=function(e,t,r){var n=this.entries.get(e,t);return void 0===n?this.keyService.isLocalId(t)?{entry:this.createDeferredEntry(e,t,!0,!1),status:R.LOCAL}:{entry:this.createDeferredEntry(e,t,r.columns,r.deferRequest),status:r.deferRequest?R.PROMISED:R.RESOLVE}:{entry:n,status:this.getCachedEntryStatus(n,r)}},e.prototype.getCachedEntryStatus=function(e,t){var r=e.columns,n=this.itemEntryService.isLocal(e)||this.columnUtil.isColumnSubset(t.columns,r.request,r.true);return void 0!==e.deferred?e.deferRequest?(r.request=this.columnUtil.mergeRequestColumns(r.request,t.columns).merged,R.RESOLVE):n?R.PROMISED:R.PROMISED_EXPAND:n?R.CACHED:(this.itemEntryService.defer(e,!1),R.EXPAND)},e.prototype.createDeferredEntry=function(e,t,r,n){var i=this.createEntryStub(e,t);return i.columns={itemType:e,request:r,true:!0===r},this.itemEntryService.defer(i,n)},e.prototype.createEntryStub=function(e,t){return this.entries.add(this.itemEntryFactory.construct(e,t))},e.prototype.createEntry=function(e,t,r,n){return this.itemEntryService.process(this.entries.add(this.itemEntryFactory.construct(n.itemType,e,n,t,r)))},e.prototype.resolveDeferredEntry=function(e,t,r,n){return e.columns=n,e.initial=t,e.derived=r,this.itemEntryService.process(e),this.itemEntryService.resolve(e)},e.prototype.batchResolve=function(e,t,r,n){var i=this,o=n.requests,s=[R.EXPAND,R.PROMISED_EXPAND],c=[R.RESOLVE],a=!0;if(t.hasEntries(s)){var u=this.columnExpansionFactory.construct(e,r,o.fetchColumnsObject());t.forEachEntry(s,function(e){i.resolveExpansion(e,u,o)})}if(t.hasEntries(c)){var l=this.columnSetFactory.construct(e,r,o.fetchColumnsObject());t.forEachEntry(c,function(e){null===i.resolveRemote(e,l,o)&&(a=!1)})}return t.forEachEntry([R.LOCAL],function(e){i.resolveLocal(e,null,n.template)}),a?t.getArray():this.errorHandler.reject({message:this.itemEntryService.undefinedItemError})},e.prototype.cloneItem=function(e,t,r){var n,i,o=t.columns,s=t.parent;void 0===r&&((n={})[t.itemType]=((i={})[t.itemId]=e,i),r=n);var c=this.createEntry(e,this.apiFormatter.copyFields(this.itemEntryService.getFields(t),{},o.main),this.apiFormatter.copyFields(t.derived,{},o.derived),o);return this.itemEntryService.updateItemFields(c,r),c.modified=this.apiFormatter.copyFields(c.initial,{},o.main),s?this.itemEntryService.setParent(c,s.itemType,s.itemId):c},e.prototype.createConversionMap=function(e,t,r,n){var i,o,s=n.links[e][0],c=((i={})[e]=((o={})[s]=t,o),i);return r&&this.extendConversionMap(c,n.items[e][s].links,n),c},e.prototype.createLocalEntries=function(e,t,r,n){var i=this,o=this,s=r.response,c={},a={},u=[];for(var l in s.items)l!==e&&(c[l]=this.columnSetFactory.construct(l,!0,r.responseColumns));var h=function(e,t,r){var l={itemType:e,itemId:t},p=s.items[e][r].links;for(var f in p){var d=p[f];void 0===a[f]&&u.push({itemType:f,itemEntries:a[f]=[]});for(var m=0,v=d;m<v.length;m++){var y=v[m],g=n[f][y],S=o.createEntryStub(f,g);S.columns=c[f],S.parent=l,i.itemEntryService.processLocal(S,s.fetchObject(f,y),{},{},n),i.setCreator(S),a[f].push(S),h(f,g,y)}}};return h(e,t,s.links[e][0]),u},e.prototype.createLocalEntry=function(e,t,r,n,i){void 0===i&&(i=null);var o=t.columns.itemType,s=this.createEntryStub(o,e);return s.columns=t.columns,null!==i&&(s.parent=i),this.itemEntryService.processLocal(s,t.fields,r,n,this.createConversionMap(o,e,!1,t.response)),this.setCreator(s),s},e.prototype.extendConversionMap=function(e,t,r){for(var n in t){var i=t[n];void 0===e[n]&&(e[n]={});for(var o=0,s=i;o<s.length;o++){var c=s[o];e[n][c]=this.keyService.getLocalId(),this.extendConversionMap(e,r.items[n][c].links,r)}}},e.prototype.fetchTitle=function(e,t,r){void 0===r&&(r=!0);var n=this.itemEntryService.getTitleField(e);return this.fetchItem(e,t,this.itemEntryService.processOptions({columns:[n],deferRequest:r})).then(function(e){return void 0!==e.main?e.main.initial[n]:void 0!==e.modified?e.modified[n]:e.initial[n]},this.errorHandler.reject)},e.prototype.requestItem=function(e,t,r){var n,i=((n={})[e]=r,n);return this.apiRequestService.query(e,{id:t},i)},e.prototype.updateItemId=function(e,t){var r=e.itemId;return e.itemId=t,this.entries.updateItemId(e,r)},e.prototype.setCreator=function(e){e.modified.creator=this.authInterface.getUserId(),e.derived["creator>displayname"]=this.authInterface.getUserDisplayname()},e}(),H=function(){function e(e,t,r,n,i,o,s,c,a){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.columnHandler=n,this.columnExpansionFactory=i,this.columnSetFactory=o,this.itemEntryService=s,this.queryService=c,this.promiseService=a}return e.prototype.requestItem=function(e,t,r){var n,i=((n={})[e]=r,n);return this.apiRequestService.query(e,{id:t},i)},e.prototype.requestItems=function(e,t,r){var n;void 0===t&&(t=e.query.object),void 0===r&&(r=e.options.columns);var i=e.options,o={requestType:"query",columns:((n={})[e.itemType]=r,n),query:t,itemType:"",allLinkIds:!1,limit:null};return null===i.queryItemType?o.itemType=e.itemType:(o.itemType=i.queryItemType,o.allLinkIds=!0),null!==i.limit&&(o.limit=i.limit),this.apiRequestService.requestSkeleton(o)},e.prototype.requestLinkItems=function(e,t,r,n,i){var o,s=((o={})[r]=i,o);return null===n?this.apiRequestService.query(e,{id:t},s):this.apiRequestService.query(r,this.queryService.addAndCondition(n,{linkedTo:e,query:{id:t}}),s)},e.prototype.processExpansion=function(e,t,r,n){for(var i=this.columnExpansionFactory.construct(r,e,t.fetchColumnsObject()),o=0,s=n;o<s.length;o++){var c=s[o];this.itemEntryService.isLocal(c)||this.handleCachedItem(c,t,i)}return i},e.prototype.processResponse=function(e,t,r,n,i){var o=this;void 0===i&&(i=this.columnExpansionFactory.construct(n.itemType,!!n.true||n.request,n.response));for(var s=n.itemType,c=n.root,a=[],u=[],l=0,h=t;l<h.length;l++){var p=h[l],f=this.itemHandler.entries.get(s,p);void 0===f?(f=this.itemHandler.createEntry(p,e.fetchObject(s,p),e.fetchDerivedObject(s,p,c),n),a.push(f)):void 0!==f.deferred?f.deferRequest?a.push(this.itemHandler.resolveDeferredEntry(f,e.fetchObject(s,p),e.fetchDerivedObject(s,p,c),n)):u.push(f.deferred.promise):a.push(this.handleCachedItem(f,e,i)),null!==r&&(f.parent=r)}return this.promiseService.all(u).then(function(t){for(var r=0,n=t;r<n.length;r++){var s=n[r];a.push(o.handleCachedItem(s,e,i))}return a},this.errorHandler.reject)},e.prototype.handleCachedItem=function(e,t,r){var n=r.run(e.columns,!0);return null===n?e:this.itemEntryService.expand(e,t.fetchObject(e.itemType,e.itemId),t.fetchDerivedObject(e.itemType,e.itemId,n.difference.root),n)},e.prototype.processLinkResponse=function(e,t,r,n,i){for(var o=e.fetchColumnsObject(),s=this.columnSetFactory.construct(n,i.columns,o),c=this.columnExpansionFactory.construct(n,i.columns,o),u=e.items[t],l={},h=0,p=r;h<p.length;h++){var f=p[h];l[f]=a(u,[f,"links",n])?this.processResponse(e,u[f].links[n],{itemType:t,itemId:f},s,c.run):[]}return this.promiseService.all(l).then(function(e){return{items:e,columns:s,columnExpansion:c.run}},this.errorHandler.reject)},e}(),x=function(){function e(e){this.itemEntryService=e}return e.prototype.processOptions=function(e){return i(e,{edit:!1,onChange:De,onDeactivate:De})},e.prototype.compareOptions=function(e,t){for(var r in e)if(e[r]!==t[r])return!1;return!0},e.prototype.isNew=function(e){return this.itemEntryService.isLocal(e.entry)&&void 0===e.transactions},e}(),M=function(){function e(){this.NEW_PREFIX="-1",this.DUPLICATE_PREFIX="-2",this.NEW_KEYWORD="new-",this.DUPLICATE_KEYWORD="dup-",this.seperator=":"}return e.prototype.getSingleKey=function(e,t){return e.concat(this.seperator,String(t))},e.prototype.getCollectionCacheKey=function(e,t,r){return e.concat(this.seperator,String(t),this.seperator,r)},e.prototype.getCssKey=function(){return Array.prototype.join.call(arguments,"_")},e.prototype.parseStateKey=function(e){return 0===(e=e.toString()).indexOf(this.NEW_KEYWORD)?{type:"new",template:e.substring(this.NEW_KEYWORD.length)}:0===e.indexOf(this.DUPLICATE_KEYWORD)?{type:"duplicate",itemId:e.substring(this.DUPLICATE_KEYWORD.length)}:null},e.prototype.getDuplicateStateKey=function(e){return this.DUPLICATE_KEYWORD.concat(String(e))},e.prototype.getNewStateKey=function(e){return this.NEW_KEYWORD.concat(e)},e.prototype.getLocalId=function(){return parseInt(this.NEW_PREFIX.concat(this.getRandomString()),10)},e.prototype.getLocalDuplicateId=function(){return parseInt(this.DUPLICATE_PREFIX.concat(this.getRandomString()),10)},e.prototype.getRandomString=function(){return Math.random().toString().split(".")[1].substr(0,8)},e.prototype.isLocalId=function(e){return void 0!==e&&this.isNewId(e)||this.isDuplicateId(e)},e.prototype.isNewId=function(e){return 0===e.toString().indexOf(this.NEW_PREFIX)||e===this.NEW_KEYWORD},e.prototype.isDuplicateId=function(e){return 0===e.toString().indexOf(this.DUPLICATE_PREFIX)||e===this.DUPLICATE_KEYWORD},e}(),D=function(){function e(e,t,r,n){this.apiRequestService=e,this.errorHandler=t,this.keyService=r,this.promiseService=n,this.lockItems={},this.promises={}}return e.prototype.getValue=function(e,t){var r=e.itemType;if(void 0!==t[r])return t[r][e.itemId]},e.prototype.setValue=function(e,t,r){return u(r,[e.itemType,e.itemId],[{},t])},e.prototype.getLocks=function(){return this.lockItems},e.prototype.hasLock=function(e){for(var t in this.lockItems)for(var r in this.lockItems[t]){var n=this.lockItems[t][r];if(!n.isForeign&&n.id==e)return!0}return!1},e.prototype.isLocked=function(e){var t=this.getValue(e,this.lockItems);return void 0!==t&&t.isForeign},e.prototype.getMessage=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t&&t.isForeign)return t.message},e.prototype.fetchCachedLock=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t)return this.promiseService.when(t);var r=this.getValue(e,this.promises);return void 0!==r?r:this.promiseService.when()},e.prototype.fetchLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){return void 0!==r?r:t.requestLock(e)},this.errorHandler.reject).then(function(e){return e.isForeign?t.errorHandler.reject(e.message):e.token},this.errorHandler.reject)},e.prototype.requestLock=function(e){var t=this,r=e.itemType,n=e.itemId,i=this.apiRequestService.create("Locktoken",this.keyService.getLocalId(),{itemtype:r,item:n}).then(function(i){return delete t.promises[r][n],t.setValue(e,i.fetchObject("Locktoken",i.links.Locktoken[0]),t.lockItems)},function(i){return delete t.promises[r][n],301===i.code?t.setValue(e,{isForeign:!0,message:i.message},t.lockItems):t.errorHandler.reject(i)});return this.setValue(e,i,this.promises)},e.prototype.deleteLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){if(void 0!==r){if(!r.isForeign)return t.apiRequestService.delete("Locktoken",r.id).then(function(){t.clearLock(e)},t.errorHandler.reject);t.clearLock(e)}},this.errorHandler.reject)},e.prototype.clearLock=function(e){var t=e.itemType;return void 0!==this.lockItems[t]&&delete this.lockItems[t][e.itemId]},e}(),P=r(1),A=function(){function e(){}return e.prototype.all=function(e){return Object(P.all)(e)},e.prototype.when=function(e){return Object(P.when)(e)},e.prototype.reject=function(e){return Object(P.reject)(e)},e.prototype.defer=function(){return Object(P.defer)()},e}(),L=function(){function e(){}return e.prototype.addAndCondition=function(e,t){return void 0===e.conditions||"or"===e.operator?{conditions:[e,t]}:{conditions:e.conditions.concat(t)}},e.prototype.addOrCondition=function(e,t){return"or"===e.operator?{conditions:e.conditions.concat(t)}:{conditions:[e,t],operator:"or"}},e.prototype.addParentCondition=function(e,t){var r;return null===t?e:(r={linkedTo:t.itemType,query:t.itemId},null===e?r:this.addAndCondition(e,r))},e.prototype.createNotIn=function(e){return{comparator:"NOT IN",key:"id",value:e}},e}(),_=function(){function e(e,t,r){for(var n in this.promiseService=e,this.getItemId=t,this.getPromise=r,this.entries={},R)this.entries[R[n]]=[]}return e.prototype.add=function(e){var t=e.status;void 0===this.entries[t]&&(this.entries[t]=[]),this.entries[t].push(e.entry)},e.prototype.hasEntries=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.entries[n].length>0)return!0}return!1},e.prototype.hasRequests=function(){return this.hasEntries([R.RESOLVE,R.EXPAND,R.PROMISED_EXPAND])},e.prototype.forEachEntry=function(e,t){for(var r=0,n=e;r<n.length;r++)for(var i=n[r],o=0,s=this.entries[i];o<s.length;o++)t(s[o])},e.prototype.getPromises=function(){var e=this,t=[];return this.forEachEntry([R.PROMISED,R.PROMISED_EXPAND],function(r){t.push(e.getPromise(r))}),this.promiseService.all(t)},e.prototype.getRequestIds=function(){var e=this,t=[];return this.forEachEntry([R.RESOLVE,R.EXPAND,R.PROMISED_EXPAND],function(r){t.push(e.getItemId(r))}),t},e.prototype.getArray=function(){var e=[];for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++){var i=n[r];e.push(i)}return e},e}(),U=function(){function e(e){this.promiseService=e}return e.prototype.construct=function(e,t){return new _(this.promiseService,e,t)},e}(),N=function(){function e(e,t,r,n){this.itemEntryService=e,this.singleItems=t,this.collections=r,this.collectionOptions=n,this.compilation={create:{},delete:{},update:{},move:{}},this.moveArray=[],this.deleteMap={},this.processSingleItems(),this.processCollections(),this.postProcess()}return e.prototype.getParent=function(e){return void 0!==e.parent?e.parent:{itemType:"Void",itemId:0}},e.prototype.addMoveEntry=function(e){this.moveArray.push(e)},e.prototype.addDeleteEntry=function(e,t,r){u(this.deleteMap,[e.itemType,e.itemId],[{},{parentId:t,item:e,parentType:r}])},e.prototype.addUpdateEntry=function(e){u(this.compilation.update,[e.itemType,e.itemId],[{},e])},e.prototype.addCreateEntry=function(e){var t=this.getParent(e);u(this.compilation.create,[t.itemType,t.itemId,e.itemType,e.itemId],[{},{},{},e])},e.prototype.postProcess=function(){for(var e=0,t=this.moveArray;e<t.length;e++){var r=(c=t[e]).itemId,n=this.deleteMap[c.itemType];if(void 0!==n&&void 0!==n[r]){var i=c.parent;(s=u(this.compilation.move,[i.itemType,i.itemId],[{},[]])).push(n[r]),delete n[r]}}for(var o in this.deleteMap)for(var r in this.deleteMap[o]){var s,c=this.deleteMap[o][r].item;void 0===(s=this.compilation.delete)[o]&&(s[o]=[]),s[o].push(c)}},e.prototype.processSingleItems=function(){for(var e=0,t=this.singleItems;e<t.length;e++){var r=t[e];this.itemEntryService.isLocal(r)?this.addCreateEntry(r):this.itemEntryService.hasChanges(r)&&this.addUpdateEntry(r)}},e.prototype.isEditableCollection=function(e){return void 0===this.collectionOptions||this.collectionOptions[e.id].edit},e.prototype.hasEditableItems=function(e){return void 0===this.collectionOptions||this.collectionOptions[e.id].editItems},e.prototype.processCollections=function(){for(var e=0,t=this.collections;e<t.length;e++){var r=t[e];if(!r.isDeferred()){var n=r.parent,i=null!==n?n.itemId:0;if(this.isEditableCollection(r)){var o=void 0,s=void 0;r.isLocal()?(o=r.items,s=[]):(o=r.getAddedItems(),s=r.getRemovedItems());for(var c=0,a=o;c<a.length;c++){var u=a[c];this.itemEntryService.isLocal(u)?this.addCreateEntry(u):this.addMoveEntry(u)}for(var l=0,h=s;l<h.length;l++){var p=h[l];this.addDeleteEntry(p,i,n.itemType)}}if(this.hasEditableItems(r))for(var f=0,d=r.getUpdatedItems();f<d.length;f++){var m=d[f];this.addUpdateEntry(m)}}}},e}(),V=function(){function e(e){this.itemEntryService=e}return e.prototype.construct=function(e,t,r){return new N(this.itemEntryService,e,t,r)},e}(),B=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p){this.apiRequestService=e,this.itemHandler=t,this.errorHandler=r,this.collectionHandler=n,this.columnHandler=i,this.changesCompilerFactory=o,this.createRequestFactory=s,this.columnExpansionFactory=c,this.requestColumnExpansionFactory=a,this.collectionEntryService=u,this.itemEntryService=l,this.apiFormatter=h,this.promiseService=p}return e.prototype.getItemTypeUpdatePriority=function(e){switch(e){case"Factuurregelbedrag":return 0;case"Factuurregel":case"Minfactuur":return 1;default:return 2}},e.prototype.buildMoveRequest=function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r].item,o=i.itemType;void 0===t[o]&&(t[o]=[]),t[o].push(i.itemId)}return t},e.prototype.getMapValue=function(e,t,r){if(void 0!==r&&void 0!==r[e])return r[e][t]},e.prototype.execute=function(e,t,r,n,i,o){return void 0===r&&(r=!1),this.executeRequests(this.changesCompilerFactory.construct(e,t,i),n,r,o)},e.prototype.executeCreateRequests=function(e,t,r,n,i){for(var o=[],s=0,c=this.createRequestFactory.construct(e,t,n).run();s<c.length;s++){var a=c[s];o.push(this.executeCreateRequest(a,r).then(u))}return this.promiseService.all(o).then(function(){return r},this.errorHandler.reject);function u(e){return m(i)&&i(r),e}},e.prototype.executeCreateRequest=function(e,t){var r=this;return this.apiRequestService.requestSkeleton(e.request).then(function(n){var i=n.map,o=n.fetchColumnsObject(),s=e.items;for(var c in s){var a=r.columnExpansionFactory.construct(c,e.request.columns[c],o).run;for(var u in s[c]){var l=s[c][u],h=r.getMapValue(c,u,i);if(void 0!==h){r.itemHandler.updateItemId(l,h);var p=n.fetchObject(c,h),f=a(l.columns,!0);r.itemEntryService.updateFields(l,p),null!==f&&r.itemEntryService.expand(l,p,n.fetchDerivedObject(c,h,f.difference.root),f)}else console.warn("Create failed!",l)}}for(var c in r.collectionHandler.addToCollections(e.collections,!0),i)for(var u in void 0===t[c]&&(t[c]={}),i[c])t[c][u]=i[c][u]},this.errorHandler.reject)},e.prototype.prioritizeUpdateRequests=function(e,t){var r=[[],[],[]],n=this.promiseService.when();for(var i in e)r[this.getItemTypeUpdatePriority(i)].push(i);for(var o=0,s=r;o<s.length;o++){var c=s[o];0!==c.length&&(n=n.then(this.executeUpdateRequests(c,e,t),this.errorHandler.reject))}return n},e.prototype.executeUpdateRequests=function(e,t,r){var n=this;return function(){for(var i=[],o=0,s=e;o<s.length;o++){var c=s[o];i.push(n.executeUpdateRequest(c,t[c],r))}return n.promiseService.all(i)}},e.prototype.executeUpdateRequest=function(e,t,r){var n=this,i={},o=this.requestColumnExpansionFactory.construct(),s={};for(var c in i[e]={},t){var a=t[c],u=i[e][c]={},h=l(r,[e,c]);u.values=this.itemEntryService.formatRequest(a),void 0!==h&&(u.parameters=h),o.expand(a.columns),this.collectionHandler.expandCollectionMap(a,s)}for(var p in s){var f=s[p];f.fitting.length>0&&o.expand(f.collection.columns)}return this.apiRequestService.updateItems(e,i,o.get()).then(function(r){var i=n.columnExpansionFactory.construct(e,o.get(),r.fetchColumnsObject());for(var c in t){var a=t[c],u=r.fetchObject(e,c);if(void 0!==u){var l=n.apiFormatter.copyFields(a.initial,{},a.columns.main);n.itemEntryService.setDerived(a,r.fetchDerivedObject(e,c,a.columns.root)),n.itemEntryService.updateFields(a,u),n.itemEntryService.callOnChange(a,l);var h=i.run(a.columns,!0);null!==h&&n.itemEntryService.expand(a,u,r.fetchDerivedObject(e,c,h.difference.root),h)}else console.warn("Update failed!",a)}n.collectionHandler.removeFromAndAddToCollections(s)},this.errorHandler.reject)},e.prototype.executeDeleteRequests=function(e){var t=[];for(var r in e)t.push(this.executeDeleteRequest(r,e[r]));return this.promiseService.all(t)},e.prototype.executeDeleteRequest=function(e,t){for(var r=this,n=[],i=0,o=t;i<o.length;i++){var s=o[i];n.push(s.itemId)}return this.apiRequestService.delete(e,n).then(function(e){for(var n=e.items,i={},o=0,s=t;o<s.length;o++){var a=s[o];c(a.itemId,n)||console.warn("Delete failed!",a),r.collectionHandler.expandCollectionMap(a,i)}r.collectionHandler.removeFromCollections(i,!0)},this.errorHandler.reject)},e.prototype.executeMoveRequests=function(e,t){var r=this,n=[];for(var i in e)for(var o in e[i])s(i,o);return this.promiseService.all(n);function s(i,o){var s=e[i][o],c=this.getMapValue(i,o,t);n.push(r.apiRequestService.moveItems(i,void 0!==c?c:o,this.buildMoveRequest(s)).then(function(e){r.processMoveResponse(e,s)},r.errorHandler.reject))}},e.prototype.processMoveResponse=function(e,t){for(var r=[],n={},i={},o=0,s=t;o<s.length;o++){var c=s[o],a=c.item;this.addCollectionMapEntry(n,c.parentId,a,a.itemId),this.addCollectionMapEntry(i,a.parent.itemId,a,a),r.push(a)}this.forEachCollection(n,"removeItems"),this.forEachCollection(i,"addItems")},e.prototype.addCollectionMapEntry=function(e,t,r,n){u(e,[r.parent.itemType,t,r.itemType],[{},{},[]]).push(n)},e.prototype.forEachCollection=function(e,t){for(var r in e)for(var n in e[r])for(var i in e[r][n])this.collectionHandler.entries.getByParent(r,n,i)[t](e[r][n][i],null,!0)},e.prototype.onItemsCreated=function(e,t,r){var n=this;if(o(e)){for(var i=0,s=r;i<s.length;i++){var c=s[i],a=c.parent,u=c.getUpdatedItemColumns(e);null!==a&&(void 0!==(p=this.getMapValue(a.itemType,a.itemId,e))&&(a.itemId=p),c.query=this.collectionEntryService.createQuery(c.options)),o(u)&&(void 0!==u.id&&c.onItemsCreated(e[c.itemType]),c.forEach(function(t){n.itemEntryService.updateItemFields(t,e)}))}for(var l=0,h=t;l<h.length;l++){var p,f=h[l],d=f.parent;this.itemEntryService.updateItemFields(f,e),void 0!==d&&void 0!==(p=this.getMapValue(d.itemType,d.itemId,e))&&(d.itemId=p)}}},e.prototype.executeRequests=function(e,t,r,n){var i=this,o=e.compilation,s=e.singleItems,c=e.collections,a={};return this.executeCreateRequests(o.create,t,a,r,n).then(function(){return i.onItemsCreated(a,s,c),i.executeMoveRequests(o.move,a)},function(e){return i.onItemsCreated(a,s,c),i.errorHandler.reject(e)}).then(function(){return i.executeDeleteRequests(o.delete)},this.errorHandler.reject).then(function(){return i.prioritizeUpdateRequests(o.update,t)},this.errorHandler.reject).then(function(){return a},this.errorHandler.reject)},e}(),Q=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.collectionHandler=n,this.columnHandler=i,this.changesCompilerFactory=o,this.createRequestFactory=s,this.columnExpansionFactory=c,this.requestColumnExpansionFactory=a,this.collectionEntryService=u,this.itemEntryService=l,this.apiFormatter=h,this.promiseService=p}return e.prototype.construct=function(){return new B(this.apiRequestService,this.itemHandler,this.errorHandler,this.collectionHandler,this.columnHandler,this.changesCompilerFactory,this.createRequestFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.collectionEntryService,this.itemEntryService,this.apiFormatter,this.promiseService)},e}();(C||(C={})).MAYBE="maybe";var Y,W,X=function(){function e(e){this.queryMatcherFactory=e,this.entries={}}return e.prototype.contains=function(e){for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++)if(e===n[r])return!0;return!1},e.prototype.some=function(e){for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++)if(e(n[r]))return!0;return!1},e.prototype.forEach=function(e){for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++)e(n[r])},e.prototype.toArray=function(){var e=[];for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++){var i=n[r];e.push(i)}return e},e.prototype.add=function(e){var t=e.itemType;return void 0===this.entries[t]&&(this.entries[t]=[]),this.entries[t].push(e),e},e.prototype.clear=function(e){if(void 0===e)return this.entries={},!0;var t=e.itemType;if(void 0===this.entries[t])return!1;var r=this.entries[t].indexOf(e);return-1!==r&&(this.entries[t].splice(r,1),!0)},e.prototype.getByItemType=function(e){return void 0===this.entries[e]?[]:this.entries[e].slice()},e.prototype.getByParent=function(e,t,r){if(void 0===this.entries[r])return null;for(var n=0,i=this.entries[r];n<i.length;n++){var o=i[n];if(o.matchParent(e,t))return o}return null},e.prototype.getResourceByParent=function(e,t,r){var n=this.getByParent(e,t,r);return null===n?null:n.getCurrentResource()},e.prototype.getCollectionsByParent=function(e,t){var r=[];for(var n in this.entries)for(var i=0,o=this.entries[n];i<o.length;i++){var s=o[i];s.matchParent(e,t)&&r.push(s)}return r},e.prototype.getByContainingItem=function(e,t){var r=[];if(void 0===this.entries[e])return r;for(var n=0,i=this.entries[e];n<i.length;n++){var o=i[n];void 0!==o.getItemById(t)&&r.push(o)}return r},e.prototype.getByFittingItem=function(e,t,r,n){var i=[],o=[],s=[],c={fitting:i,notfitting:s,maybe:o};if(void 0===this.entries[r])return c;for(var a=this.queryMatcherFactory.construct(e,t,n,r),u=0,l=this.entries[r];u<l.length;u++){var h=l[u],p=a.matchQuery(h.query.object);!0===p?i.push(h):p===C.MAYBE?o.push(h):s.push(h)}return c},e.prototype.getByQuery=function(e,t){if(void 0===this.entries[e])return null;for(var r=0,n=this.entries[e];r<n.length;r++){var i=n[r];if(i.query.string===t.string)return i}return null},e.prototype.getByKey=function(e,t){var r=[];if(void 0===this.entries[e])return r;for(var n=0,i=this.entries[e];n<i.length;n++){var o=i[n];o.options.entryKey===t&&r.push(o)}return r},e.prototype.getResourceByKey=function(e,t){var r=[];if(void 0===this.entries[e])return r;for(var n=0,i=this.entries[e];n<i.length;n++)for(var o=0,s=i[n].resources;o<s.length;o++){var c=s[o];null!==c&&c.options.resourceKey===t&&r.push(c)}return r},e}(),K=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(){return new X(this.queryMatcherFactory)},e}(),J=0,z=function(){function e(e,t,r,n,i,o,s,c,a){this.errorHandler=e,this.collectionEntryService=t,this.itemRequestService=r,this.itemEntryService=n,this.keyService=i,this.queryService=o,this.promiseService=s,this.itemType=c,this.options=a,this.id=J++,this.parent=null,this.initial=[],this.items=[],this.resources=[],this.deferred=this.promiseService.defer(),this.itemType=c,this.options=a,this.query=t.createQuery(a)}return e.prototype.isDeferred=function(){return void 0!==this.promise},e.prototype.resolve=function(e){var t=this.deferred;return this.columns=e.columns,this.initial=e.items,this.items=e.items.slice(),delete this.deferred,delete this.promise,t.resolve(this),this},e.prototype.isLocal=function(){var e=this.parent;return null!==e&&this.keyService.isLocalId(e.itemId)},e.prototype.matchParent=function(e,t){var r=this.parent;return null!==r&&r.itemType===e&&r.itemId==t},e.prototype.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++)e(r[t])},e.prototype.getItemById=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(n.itemId===e)return n}},e.prototype.getIdArray=function(e){return void 0===e&&(e={}),this.collectionEntryService.getIdArray(this.items,e)},e.prototype.addItems=function(e,t,r,n){if(void 0===r&&(r=!1),void 0===n&&(n=!0),0===e.length)return[];var i=this.resources,o=this.parent,s=this.columns.link;if(r){for(var c=this.initial,a=[],u=0,l=e;u<l.length;u++){var h=l[u];-1===c.indexOf(h)&&(c.push(h),a.push(h))}if(a.length>0)for(var p=0,f=i;p<f.length;p++)(I=f[p]).options.onAddInitial(a,this)}for(var d=this.items,m=[],v=0,y=e;v<y.length;v++)h=y[v],-1===d.indexOf(h)&&(null!==o&&(h.parent=o,null!==s&&void 0!==h.modified&&(h.modified[s.id]=o.itemId)),d.push(h),m.push(h));if(m.length>0){for(var g=void 0,S=0,C=i;S<C.length;S++){var I,E=(I=C[S]).addItemResources(m);I===t?(g=E,n&&I.callOnAdd(E)):I.callOnAdd(E)}return g}return null===t?null:[]},e.prototype.removeItems=function(e,t,r,n){return 0===e.length?[]:this.handleRemovedItems(function(t){return c(t.itemId,e)},t,r,n)},e.prototype.clear=function(e,t,r){return this.handleRemovedItems(function(){return!1},e,t,r)},e.prototype.handleRemovedItems=function(e,t,r,n){void 0===n&&(n=!0);var i,o=this.resources,s=this.collectionEntryService.filterArray(this.items,e),c=r?this.collectionEntryService.filterArray(this.initial,e):[];if(c.length>0)for(var a=0,u=o;a<u.length;a++)(m=u[a]).options.onRemoveInitial(c,this);if(0===s.length)return null===t?null:[];for(var l=0,h=s;l<h.length;l++){var p=h[l];this.itemEntryService.deactivateResources(p)}for(var f=0,d=o;f<d.length;f++){var m,v=(m=d[f]).removeItemResources(s);m===t?(i=v,n&&m.callOnRemove(v)):m.callOnRemove(v)}return i},e.prototype.expand=function(e){var t=this,r=this.itemType;return 0===e.length?this.promiseService.when(this):(this.promise=this.itemRequestService.requestItems(this,void 0,e).then(function(n){var i=n.items[r],o=t.itemRequestService.processExpansion(e,n,r,t.items);return t.handleRemovedItems.call(t,function(e){return void 0!==i[e.itemId]||t.itemEntryService.isLocal(e)},null,!0,!0),t.updateColumns(o),delete t.promise,t},this.errorHandler.reject),this.promise)},e.prototype.extendQuery=function(e){var t=this.options;return void 0===e?this.query:(t.queryParams=e(t.queryParams),this.query=this.collectionEntryService.createQuery(t))},e.prototype.extend=function(e,t,r,n){var i=this,o=this.extendQuery(e).object,s=this.queryService.addAndCondition(o,this.queryService.createNotIn(this.getIdArray())),c=this.itemRequestService.requestItems(this,null!==this.options.limit?o:s).then(function(e){return i.itemRequestService.processResponse(e,e.links[i.itemType],i.parent,i.columns)},this.errorHandler.reject).then(function(e){return delete i.promise,i.addItems(e,t,n,r)},this.errorHandler.reject);return this.promise=c.then(function(){return i},this.errorHandler.reject),c},e.prototype.queueReload=function(){this.reloadQueued=!0,this.deferred=this.promiseService.defer(),this.promise=this.deferred.promise},e.prototype.updateColumns=function(e){var t=e(this.columns,!1);this.options.columns=t.request,this.columns=t},e.prototype.getAddedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=[],n=0,i=this.items;n<i.length;n++){var o=i[n];-1===t.indexOf(o)&&r.push(e?o.itemId:o)}return r},e.prototype.getRemovedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=this.items,n=[],i=0,o=t;i<o.length;i++){var s=o[i];-1===r.indexOf(s)&&n.push(e?s.itemId:s)}return n},e.prototype.getUpdatedItems=function(){for(var e=[],t=0,r=this.items;t<r.length;t++){var n=r[t];!this.itemEntryService.isLocal(n)&&this.itemEntryService.hasChanges(n)&&e.push(n)}return e},e.prototype.hasAddedItems=function(){return this.items.length>this.initial.length},e.prototype.hasRemovedItems=function(){return this.initial.length>this.items.length},e.prototype.hasUpdatedItems=function(){for(var e=0,t=this.items;e<t.length;e++){var r=t[e];if(this.itemEntryService.hasChanges(r))return!0}return!1},e.prototype.getCurrentResource=function(){var e=this.resources;return e[e.length-1]},e.prototype.clearResources=function(e){void 0===e&&(e=!1);for(var t=this.items,r=this.resources,n=[],i=0,o=t;i<o.length;i++){var s=o[i];this.itemEntryService.clearResources(s)}for(var c=0,a=r;c<a.length;c++){var u=a[c];if(!u.options[e?"clearOnSubTabChange":"clearOnTabChange"]){n.push(u);for(var l=0,h=u.items;l<h.length;l++){var p=h[l];p.entry.resources.push(p)}}}this.resources=n},e.prototype.revertChanges=function(){for(var e=this.resources,t=this.getRemovedItems(),r=this.getAddedItems(!0),n=0,i=e;n<i.length;n++){var o=i[n];o.addItemResources(t),o.removeItemResources(r)}this.items=this.initial.slice()},e.prototype.onItemsCreated=function(e){for(var t=0,r=this.resources;t<r.length;t++){var n=r[t];n.rebuildMap(),n.options.onItemsCreated(e)}},e.prototype.getUpdatedItemColumns=function(e){for(var t={},r=0,n=this.columns.item;r<n.length;r++){var i=n[r];void 0!==e[i.apiColumn.itemType]&&(t[i.id]=i)}return t},e}(),$=function(){function e(e,t,r,n,i,o,s){this.errorHandler=e,this.collectionEntryService=t,this.itemRequestService=r,this.itemEntryService=n,this.keyService=i,this.queryService=o,this.promiseService=s}return e.prototype.construct=function(e,t){return new z(this.errorHandler,this.collectionEntryService,this.itemRequestService,this.itemEntryService,this.keyService,this.queryService,this.promiseService,e,t)},e}(),G=function(){function e(e,t,r){this.itemResourceFactory=e,this.entry=t,this.options=r,this.columns=t.columns.response,this.itemIdMap={},this.items=[],t.resources.push(this),this.addItemResources(t.items)}return e.prototype.getItemById=function(e){return this.itemIdMap[e]},e.prototype.rebuildMap=function(){for(var e={},t=0,r=this.items;t<r.length;t++){var n=r[t];e[n.entry.itemId]=n}this.itemIdMap=e},e.prototype.addItemResources=function(e){if(0===e.length)return[];for(var t=[],r=this.options,n=this.items,i=this.itemIdMap,o=this.itemResourceFactory.getConstructor({edit:r.editItems,onChange:r.onChange,onDeactivate:r.onDeactivateItem}),s=0,c=e;s<c.length;s++){var a=c[s],u=a.itemId,l=void 0;void 0===i[u]?(l=o(a),n.push(l),i[u]=l):l=i[u],t.push(l)}return t},e.prototype.removeItemResources=function(e){var t=this,r=[];return function(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;e.splice(0);for(var s=0,c=r;s<c.length;s++){var a=c[s];e.push(a)}}(this.items,function(n){for(var i=0,o=e;i<o.length;i++){var s=o[i];if(n.entry===s)return r.push(n),delete t.itemIdMap[s.itemId],!1}return!0}),r},e.prototype.callOnAdd=function(e){this.options.onAdd(e,this)},e.prototype.callOnRemove=function(e){this.options.onRemove(e,this)},e.prototype.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++)e(r[t])},e.prototype.filter=function(e){for(var t=[],r=0,n=this.items;r<n.length;r++){var i=n[r];e(i)&&t.push(i)}return t},e.prototype.first=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(e(n))return n}return null},e.prototype.some=function(e){return null!==this.first(e)},e.prototype.groupBy=function(e){var t=this.items,r={};if("string"==typeof e)for(var n=0,i=t;n<i.length;n++)void 0===r[a=(c=i[n]).fields[e]]&&(r[a]=[]),r[a].push(c);if("function"==typeof e)for(var o=0,s=t;o<s.length;o++){var c,a;null!==(a=e(c=s[o]))&&(void 0===r[a]&&(r[a]=[]),r[a].push(c))}return r},e.prototype.map=function(e){var t=this.items,r=t.length,n=new Array(r);if("string"==typeof e)for(var i=0;i<r;i++)n[i]=t[i].fields[e];if("function"==typeof e)for(i=0;i<r;i++)n[i]=e(t[i]);return n},e.prototype.reduce=function(e,t){for(var r=0,n=this.items;r<n.length;r++)t=e(n[r],t);return t},e.prototype.extend=function(e,t,r){var n=this;return void 0===r&&(r=!0),this.entry.extend(e,this,r).then(function(e){return t?n.items:e})},e.prototype.deactivate=function(){this.options.onDeactivateCollection(this)},e.prototype.clearResource=function(){var e=this.entry.resources,t=this.items,r=e.indexOf(this);-1!==r&&e.splice(r,1);for(var n=0,i=t;n<i.length;n++)i[n].clearResource()},e}(),Z=(Y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}Y(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),ee=function(e){function t(t,r,n,i,o,s,c,a){var u=e.call(this,n,c,a)||this;return u.errorHandler=t,u.itemHandler=r,u.changesProcessorFactory=i,u.keyService=o,u.promiseService=s,u}return Z(t,e),t.prototype.save=function(){if(!this.options.enableSave)throw new Error("collectionResourceService: Saving disabled");var e=this.entry,t=e.parent;return null!==t&&this.keyService.isLocalId(t.itemId)?this.promiseService.when():this.changesProcessorFactory.construct().execute([],[e])},t.prototype.moveItems=function(e,t,r){var n=this.entry,i=this.options;if(i.enableSave||i.modInstant)throw new Error("collectionResourceService: Cannot move items: saving enabled");if(n.itemType!==t.entry.itemType)throw new Error("collectionResourceService: Cannot move items: itemType mismatch");for(var o=n.removeItems(e,this,!1,r),s=[],c=0,a=o;c<a.length;c++){var u=a[c];s.push(u.entry)}return t.entry.addItems(s,t,!1,r),o},t.prototype.removeItems=function(e,t){var r=this;void 0===t&&(t=!0);var n=this.entry.removeItems(e,this,!1,!1);return this.options.modInstant?this.save().then(function(){return t&&r.callOnRemove(n),n}):(t&&this.callOnRemove(n),this.promiseService.when(n))},t.prototype.removeItem=function(e,t){return this.removeItems([e],t).then(function(e){return e[0]},this.errorHandler.reject)},t.prototype.addItems=function(e,t){var r=this;return void 0===t&&(t=!0),this.itemHandler.fetchTemplate(this.entry.itemType).then(function(n){for(var i,o=[],s=0,c=e;s<c.length;s++){var a=c[s];o.push(r.itemHandler.createLocalEntry(r.keyService.getLocalId(),n,a.fields,a.derived))}return i=r.entry.addItems(o,self,!1,!1),r.options.modInstant?r.save().then(function(e){return t&&r.callOnAdd(i),i},r.errorHandler.reject):(t&&r.callOnAdd(i),i)},this.errorHandler.reject)},t.prototype.addItem=function(e,t){return this.addItems([e],t).then(function(e){return e[0]},this.errorHandler.reject)},t.prototype.clear=function(e){return this.entry.clear(this,!1,e)},t}(G),te=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),re=function(e){function t(t,r,n,i,o,s,c,a){var u=e.call(this,n,c,a)||this;return u.errorHandler=t,u.itemHandler=r,u.changesProcessorFactory=i,u.keyService=o,u.promiseService=s,u}return te(t,e),t}(G),ne=function(){function e(e,t,r,n,i,o){this.errorHandler=e,this.itemHandler=t,this.itemResourceFactory=r,this.changesProcessorFactory=n,this.keyService=i,this.promiseService=o}return e.prototype.construct=function(e,t){return new(t.editCollection?ee:re)(this.errorHandler,this.itemHandler,this.itemResourceFactory,this.changesProcessorFactory,this.keyService,this.promiseService,e,t)},e}(),ie=function(){function e(e,t,r,n,i,o){if(this.columnHandler=e,this.columnSetFactory=t,this.columnUtil=r,this.itemType=n,this.requestColumns=i,this.responseColumns=o,this.expansionMap={},!0===i)for(var s in this.requestColumnsTrue=!0,this.requestColumns=[],o[n])this.requestColumns.push(s);else this.requestColumnsTrue=!1}return e.prototype.run=function(e,t){var r=e.id;return void 0!==this.expansionMap[r]?t?this.expansionMap[r]:this.expansionMap[r].merged:this.columnUtil.isColumnSubset(this.requestColumns,e.request,e.true)?t?null:e:(this.expansionMap[r]=this.expandColumnInfo(e),t?this.expansionMap[r]:this.expansionMap[r].merged)},e.prototype.expandColumnInfo=function(e){var t=this.columnUtil.mergeRequestColumns(e.request,this.requestColumns),r=this.columnUtil.mergeResponseColumns(e.response,this.responseColumns).merged,n=this.columnSetFactory.construct(this.itemType,t.merged,r),i=this.columnSetFactory.construct(this.itemType,t.difference,r,!1,!1);return n.true=this.requestColumnsTrue||e.true,{merged:n,difference:i}},e}(),oe=function(){function e(e,t,r){this.columnHandler=e,this.columnSetFactory=t,this.columnUtil=r}return e.prototype.construct=function(e,t,r){return new ie(this.columnHandler,this.columnSetFactory,this.columnUtil,e,t,r)},e}(),se=0,ce=function(){function e(e,t,r,n,i,o,s){void 0===o&&(o=!0),void 0===s&&(s=!0),this.columnHandler=e,this.columnUtil=t,this.itemType=r,this.requestColumns=n,this.responseColumns=i,this.enableCaching=o,this.includeIdColumn=s,this.id=++se,this.link=null,this.main=[],this.derived=[],this.root=[],this.leaf=[],this.formatted={main:[],derived:[]},this.filtered=[],this.custom=[],this.searchable=[],this.item=[],this.notItem=[],this.request=[],this.response={},this.true=!0===n,!0===n?this.processResponseColumns():this.processRequestColumns()}return e.prototype.processResponseColumns=function(){for(var e in this.request=[],this.response=this.enableCaching?this.columnHandler.setColumns(this.itemType,!0,this.responseColumns):this.responseColumns,this.responseColumns[this.itemType])this.main.push(this.getColumnInfo(this.responseColumns[this.itemType][e],[],null)),this.request.push(e)},e.prototype.processRequestColumns=function(){if(this.request=this.requestColumns,this.response={},0!==this.requestColumns.length){for(var e=0,t=this.requestColumns;e<t.length;e++){var r=t[e],n=this.getRequestColumnInfo(r,this.itemType,null);null!==n&&(this.main.push(n),n.isLeaf||this.root.push(n))}this.includeIdColumn&&void 0===this.response[this.itemType].id&&this.main.push(this.getRequestColumnInfo("id",this.itemType,null))}},e.prototype.getRequestColumnInfo=function(e,t,r){var n,i=this.columnUtil.parseRequestColumn(e),o=i.id;if(void 0!==this.responseColumns[t]&&(n=this.responseColumns[t][o]),void 0===n)return console.warn("No api column for request column",o,"for itemType",t),null;this.enableCaching&&(n=this.columnHandler.setColumn(t,n));var s=this.response;return void 0===s[t]&&(s[t]={}),void 0===s[t][o]&&(s[t][o]=n),this.getColumnInfo(n,i.children,r)},e.prototype.getColumnInfo=function(e,t,r){var n=null!==r,i=e.id,o={id:i,path:n?r.path.concat(">",i):i,apiColumn:e,level:n?r.level+1:0,isLeaf:0===t.length,itemType:"",children:[],parent:null,tailPath:null};if(n?(this.derived.push(o),o.parent=r,o.tailPath=r.level>0?r.tailPath.concat(">",i):i):this[this.columnUtil.isItemColumn(e)?"item":"notItem"].push(o),this.columnUtil.isFormattedColumn(e)&&this.formatted[n?"derived":"main"].push(o),this.columnUtil.isFilteredColumn(e)&&this.filtered.push(o),this.columnUtil.isSearchableColumn(e)&&this.searchable.push(o),this.columnUtil.isCustomColumn(e)&&this.custom.push(o),"link"===e.type&&(this.link=e),0===t.length)return this.leaf.push(o),o;void 0===e.itemType&&console.warn("itemType undefined in column",e),o.itemType=e.itemType,o.children=[];for(var s=0,c=t;s<c.length;s++){var a=c[s],u=this.getRequestColumnInfo(a,o.itemType,o);null!==u&&o.children.push(u)}return o},e}(),ae=function(){function e(e,t){this.columnHandler=e,this.columnUtil=t}return e.prototype.construct=function(e,t,r,n,i){return void 0===n&&(n=!0),void 0===i&&(i=!0),new ce(this.columnHandler,this.columnUtil,e,t,r,n,i)},e}(),ue=function(){function e(e,t,r,n,i,o,s){void 0===s&&(s=!1),this.collectionHandler=e,this.requestColumnExpansionFactory=t,this.itemEntryService=r,this.keyService=n,this.compilation=i,this.parameterMap=o,this.breakupByParent=s,this.requests=[]}return e.prototype.finalizeRequest=function(e){var t=e.collections,r=e.columns;for(var n in t){var i=t[n];i.fitting.length>0&&r.expand(i.collection.columns)}return e.request.columns=r.get(),e},e.prototype.setRequestParent=function(e,t){var r=t.request;return"Void"!==e&&(r.parentType=e,r.parentId={},!0)},e.prototype.run=function(){if(this.breakupByParent)for(var e in this.compilation){var t=this.compilation[e];for(var r in t)if(!this.keyService.isLocalId(r)){var n=this.initializeRequest();this.extendRequest(t[r],this.setRequestParent(e,n)?r:null,n),this.requests.push(this.finalizeRequest(n))}}else for(var e in this.compilation){t=this.compilation[e],n=this.initializeRequest();var i=this.setRequestParent(e,n),o=!1;for(var r in t)this.keyService.isLocalId(r)||(this.extendRequest(t[r],i?r:null,n),o=!0);o&&this.requests.push(this.finalizeRequest(n))}return this.requests},e.prototype.initializeRequest=function(){return{request:{requestType:"create",items:{}},columns:this.requestColumnExpansionFactory.construct(),items:{},collections:{}}},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],a=l(this.compilation,[o,s]),u=n.items[o][s]={},h=l(this.parameterMap,[o,s]),p=void 0;if(null!==t&&(n.parentId[s]=t),r.columns.expand(c.columns),this.collectionHandler.expandCollectionMap(c,r.collections),i[o][s]=c,u.values=this.itemEntryService.formatRequest(c),u.parameters=h,void 0!==a){for(var f in p=u.links={},a)for(var d in p[f]=[],a[f])p[f].push(d);this.extendRequest(a,null,r)}}},e}(),le=function(){function e(e,t,r,n){this.collectionHandler=e,this.requestColumnExpansionFactory=t,this.itemEntryService=r,this.keyService=n}return e.prototype.construct=function(e,t,r){return void 0===r&&(r=!1),new ue(this.collectionHandler,this.requestColumnExpansionFactory,this.itemEntryService,this.keyService,e,t,r)},e}(),he=function(){function e(e,t){this.queryMatcherFactory=e,this.itemEntryService=t,this.entries={}}return e.prototype.some=function(e){for(var t in this.entries)for(var r in this.entries[t])if(e(this.entries[t][r]))return!0;return!1},e.prototype.getByItemType=function(e){var t=[];if(void 0===this.entries[e])return t;for(var r in this.entries[e])t.push(this.entries[e][r]);return t},e.prototype.getByQuery=function(e,t){var r=[];if(void 0===this.entries[e])return r;for(var n in this.entries[e]){var i=this.entries[e][n];this.matchQuery(i,t)&&r.push(i)}return r},e.prototype.getLocalByQuery=function(e,t){var r=[];if(void 0===this.entries[e])return r;for(var n in this.entries[e]){var i=this.entries[e][n];this.itemEntryService.isLocal(i)&&this.matchQuery(i,t)&&r.push(i)}return r},e.prototype.forEach=function(e){for(var t in this.entries)for(var r in this.entries[t])e(this.entries[t][r])},e.prototype.toArray=function(){var e=[];for(var t in this.entries)for(var r in this.entries[t])e.push(this.entries[t][r]);return e},e.prototype.add=function(e){var t=e.itemType;return void 0===this.entries[t]&&(this.entries[t]={}),this.entries[t][e.itemId]=e},e.prototype.get=function(e,t){return void 0===this.entries[e]?void 0:this.entries[e][t]},e.prototype.getByParent=function(e,t,r){var n=[];if(void 0===this.entries[r])return n;for(var i in this.entries[r]){var o=this.entries[r][i],s=o.parent;void 0!==s&&e===s.itemType&&t==s.itemId&&n.push(o)}return n},e.prototype.contains=function(e,t){return void 0!==this.entries[e]&&void 0!==this.entries[e][t]},e.prototype.updateItemId=function(e,t){var r=this.entries[e.itemType];return delete r[t],r[e.itemId]=e},e.prototype.clear=function(e){return void 0===e?(this.entries={},!0):void 0!==this.entries[e.itemType]&&delete this.entries[e.itemType][e.itemId]},e.prototype.matchQuery=function(e,t){var r=void 0!==e.parent?e.parent:{};return!0===this.queryMatcherFactory.construct(r.itemType,r.itemId,this.itemEntryService.getFields(e)).matchQuery(t.object)},e}(),pe=function(){function e(e,t){this.queryMatcherFactory=e,this.itemEntryService=t}return e.prototype.construct=function(){return new he(this.queryMatcherFactory,this.itemEntryService)},e}(),fe=0,de=function(e,t,r,n,i,o){void 0===n&&(n={}),void 0===i&&(i={}),void 0===o&&(o=[]),this.itemType=e,this.itemId=t,this.columns=r,this.initial=n,this.derived=i,this.resources=o,this.parent=null,this.deferRequest=!1,this.entryId=++fe},me=function(){function e(){}return e.prototype.construct=function(e,t,r,n,i,o){return void 0===n&&(n={}),void 0===i&&(i={}),void 0===o&&(o=[]),new de(e,t,r,n,i,o)},e}(),ve=function(){function e(e,t,r){this.itemEntryService=e,this.entry=t,this.options=r,this.derived=t.derived,this.columns=t.columns.response[t.columns.itemType],t.resources.push(this)}return e.prototype.isLocal=function(){return this.itemEntryService.isLocal(this.entry)},e.prototype.clearResource=function(){var e=this.entry.resources,t=e.indexOf(this);-1!==t&&e.splice(t,1)},e.prototype.deactivate=function(){this.options.onDeactivate(this)},e}(),ye=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ge=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return t.setModified(r),i.fields=r.modified,i}return ye(t,e),t}(ve),Se=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ce=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.fields=void 0===r.modified?r.initial:r.modified,i}return Se(t,e),t}(ve),Ie=function(){function e(e,t){this.itemEntryService=e,this.itemResourceService=t}return e.prototype.getConstructor=function(e){var t=this,r=(e=this.itemResourceService.processOptions(e)).edit?ge:Ce;return function(n){return new r(t.itemEntryService,n,e)}},e.prototype.construct=function(e,t){return new(t.edit?ge:Ce)(this.itemEntryService,e,t)},e}(),Ee={},Re=function(){function e(e,t,r,n){this.itemEntryService=e,this.rootItemEntry=t,this.singleItemCache=r,this.collectionCache=n}return e.prototype.process=function(){this.parentMap=this.createParentMap(this.singleItemCache),this.processItems(this.rootItemEntry.itemType,[this.rootItemEntry],{})},e.prototype.createParentMap=function(e){var t={};return e.forEach(function(e){var r=e.itemType,n=e.parent;if(void 0!==n){var i=n.itemType,o=n.itemId;void 0===t[i]&&(t[i]={});var s=t[i];void 0===s[o]&&(s[o]={}),void 0===(s=s[o])[r]&&(s[r]=[]),s[r].push(e)}}),t},e.prototype.processItems=function(e,t,r){void 0===this.destination[e]&&(this.destination[e]={}),void 0===r[e]&&(r[e]=[]);for(var n=0,i=t;n<i.length;n++){var o=i[n],s=o.itemId;void 0===this.destination[e][s]&&(r[e].push(s),this.destination[e][s]=this.processItem(o))}},e.prototype.processItem=function(e){var t=e.itemType,r=e.itemId,n=this.getItemsByParent(t,r),i=this.collectionCache.getCollectionsByParent(t,r),s=this.itemEntryService.formatRequest(e),c={};for(var a in n)this.processItems(a,n[a],c);for(var u=0,l=i;u<l.length;u++){var h=l[u];null===h.options.query&&this.processItems(h.itemType,h.items,c)}var p=o(s),f=o(c);return p&&f?{values:s,links:c}:p?{values:s}:f?{links:c}:Ee},e.prototype.getItemsByParent=function(e,t){var r=this.parentMap[e];return void 0===r?{}:void 0===r[t]?{}:r[t]},e}(),qe=function(){function e(e){this.itemEntryService=e}return e.prototype.construct=function(e,t,r){return new Re(this.itemEntryService,e,t,r)},e}(),Te="maybe",be=function(){function e(e,t,r,n,i){this.apiFormatter=e,this.parentType=t,this.parentId=r,this.fields=n,this.itemType=i}return e.prototype.compareValues=function(e,t){return n.isMoment(t)?this.apiFormatter.compareMomentObjects(t,e):n.isDuration(t)?this.apiFormatter.compareDurations(t,e):t==e},e.prototype.matchQuery=function(e){if(void 0!==e.search)return Te;if(void 0!==e.custom)return Te;if(void 0!==e.linkedTo)return this.matchLinkedToQuery(e);if(void 0!==e.conditions)return this.matchComplexQuery(e);if(void 0!==e.key)return this.matchSimpleQuery(this.fields[e.key],e);if(!o(e))return!0;throw new Error("queryMatcher: Unsupported query! Parsed?")},e.prototype.matchLinkedToQuery=function(e){return e.reverse?Te:(t=e.linkedTo===this.parentType&&this.matchSimpleQuery(this.parentId,e.query))===Te?Te:e.not?!t:t;var t},e.prototype.matchComplexQuery=function(e){var t,r,n=e.conditions;switch(e.operator){case"AND":t=!0,r=!1;break;case"OR":t=!1,r=!0;break;default:throw new Error("queryMatcher: Unsupported operator")}for(var i=0,o=n;i<o.length;i++){var s=o[i],c=this.matchQuery(s);if(c===r)return r;c===Te&&(t=Te)}return t},e.prototype.matchSimpleQuery=function(e,t){var r=t.key,i=t.value;if(!o(t))return!0;if(void 0===e)return console.warn("Required field",r,"not found for",this.itemType),Te;switch("NOW"===i&&(i=n()),t.comparator){case"=":return this.compareValues(e,i);case"!=":return!this.compareValues(e,i);case"<":return e<i;case"<=":return e<=i;case">":return e>i;case">=":return e>=i;case"IN":return c(e,i);case"NOT IN":return!c(e,i);default:throw new Error("queryMatcher: Unsupported comparator: "+t.comparator+" in query "+t)}},e}(),Fe=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e,t,r,n){return new be(this.apiFormatter,e,t,r,n)},e}();!function(e){e[e.OBJ=0]="OBJ",e[e.STR=1]="STR",e.SEP=":"}(W||(W={}));var ke=function(){function e(e,t){this.query=e,this.parameters=t}return e.prototype.processValue=function(e){return Array.isArray(e)?e.slice().sort():n.isMoment(e)?n(e):n.isDuration(e)?n.duration(e):e},e.prototype.compareParsedQueries=function(e,t){return e[W.STR]===t[W.STR]?0:e[W.STR]>t[W.STR]?1:-1},e.prototype.parse=function(e){if(void 0===e&&(e=this.query),void 0!==e.linkedTo)return this.parseLinkedToQuery(e.linkedTo,e.query,e.reverse,e.not);if(void 0!==e.not)throw new Error('queryParser: "Not" not supported');if(void 0!==e.custom)return this.parseCustomQuery(e.custom,e.parameters);if(void 0!==e.search)return this.parseSearchQuery(e.search);if(void 0!==e.conditions)return this.parseComplexQuery(e.conditions,e.operator);if(void 0!==e.key)return this.parseSimpleQuery(e.key,e.value,e.comparator);if(!o(e))return[{},"{}"];var t=s(e);return this.parseSimpleQuery(t,e[t])},e.prototype.parseSearchQuery=function(e){return[{search:(e=this.formatValue(e))[W.OBJ]},"[search"+W.SEP+e[W.STR]+"]"]},e.prototype.parseCustomQuery=function(e,t){if(void 0===t)return[{custom:e},"["+e+"]"];var r=this.parseCustomParameters(t);return[{custom:e,parameters:r[W.OBJ]},"["+e+W.SEP+r[W.STR]+"]"]},e.prototype.parseCustomParameters=function(e){for(var t=Object.keys(e).sort(),r={},n="",i=0;i<t.length;i++){var o=t[i],s=this.formatValue(e[o]);r[o]=s[W.OBJ],i>0&&(n+=W.SEP),n+=s[W.STR]}return[r,n]},e.prototype.parseSimpleQuery=function(e,t,r){return t=this.formatValue(t),void 0===r&&(r=Array.isArray(t[W.OBJ])?"IN":"="),[{key:e,value:t[W.OBJ],comparator:r},"["+r+W.SEP+e+W.SEP+t[W.STR]+"]"]},e.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1);var i=this.parse(t);return[{linkedTo:e,query:i[W.OBJ],reverse:r,not:n},"[linkedTo"+W.SEP+e+W.SEP+i[W.STR]+W.SEP+r+W.SEP+n+"]"]},e.prototype.parseComplexQuery=function(e,t){t=void 0===t?"AND":t.toUpperCase();var r=this.parseConditions(e);return[{conditions:r[W.OBJ],operator:t},"["+t+r[W.STR]+"]"]},e.prototype.parseConditions=function(e){for(var t=[],r=[],n="",i=0,o=e;i<o.length;i++){var s=o[i];t.push(this.parse(s))}for(var c=0,a=t=t.sort(this.compareParsedQueries);c<a.length;c++){var u=a[c];r.push(u[W.OBJ]),n+=u[W.STR]}return[r,n]},e.prototype.formatValue=function(e){var t;if("string"==typeof e&&"&"===e.charAt(0)){var r=e.substring(1);if(void 0===(e=this.parameters[r]))throw new Error("queryParser: Undefined template parameter '"+r+"'");return[t=this.processValue(e),r+">"+e]}return[t=this.processValue(e),""+t]},e}(),we=function(){function e(){}return e.prototype.construct=function(e,t){return new ke(e,t)},e}(),Oe=function(){function e(e){this.columnUtil=e,this.columns={},this.columnInfoIdMap={}}return e.prototype.expand=function(e){if(!this.columnInfoIdMap[e.id]){var t=e.itemType;void 0===this.columns[t]&&(this.columns[t]=[]),this.columns[t]=this.columnUtil.mergeRequestColumns(this.columns[t],e.request).merged,this.columnInfoIdMap[e.id]=!0}},e.prototype.get=function(){return this.columns},e}(),je=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(){return new Oe(this.columnUtil)},e}(),He=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p,f){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.collectionHandler=n,this.columnHandler=i,this.lockService=o,this.itemResourceFactory=s,this.collectionCacheFactory=c,this.changesProcessorFactory=a,this.itemCacheFactory=u,this.collectionResourceFactory=l,this.itemEntryService=h,this.itemResourceService=p,this.promiseService=f,this.collectionOptions={},this.tabRequestParameters={},this.callbacks={onBeforeSave:{},onSaveSuccess:{},onSaveWithoutClosing:{}},this._hasChanges=!1,this.collections=this.collectionCacheFactory.construct(),this.deferredCollections=this.collectionCacheFactory.construct(),this.items=this.itemCacheFactory.construct()}return e.prototype.addSingleItem=function(e,t,r){return r&&(this.rootItem=e),this.items.contains(e.itemType,e.itemId)||this.items.add(e),(t=this.itemResourceService.processOptions(t)).onDeactivate=this.clearItem,this.itemResourceFactory.construct(e,t)},e.prototype.addCollection=function(e,t){this.collections.contains(e)||this.collections.add(e);var r=e.id;if(void 0===this.collectionOptions[r])this.collectionOptions[r]={edit:t.editCollection,editItems:t.editItems};else{var n=this.collectionOptions[r];n.edit=n.edit||t.editCollection,n.editItems=n.editItems||t.editItems}return t.onDeactivateItem=this.clearItem,t.onDeactivateCollection=this.clearCollection,this.collectionResourceFactory.construct(e,t)},e.prototype.clearCollection=function(e){var t=e.entry;this.collections.clear(t),t.clearResources()},e.prototype.clearItem=function(e){var t=e.entry;this.items.clear(t),this.itemEntryService.clearResources(t)},e.prototype.clearResources=function(e){void 0===e&&(e=!1),this.items.forEach(this.itemEntryService.clearResources),this.collections.forEach(function(t){t.clearResources(e)}),e||this.collections.clear()},e.prototype.updateSingleItems=function(e){for(var t in e)for(var r in e[t]){var n=this.items.get(t,r);void 0!==n&&this.items.updateItemId(n,r)}},e.prototype.revertChanges=function(){this.items.forEach(this.itemEntryService.resetModified),this.collections.forEach(this.resetCollection)},e.prototype.resetCollection=function(e){var t=this.collectionOptions[e.id];if(t.edit&&e.revertChanges(),t.editItems)for(var r=0,n=e.items;r<n.length;r++){var i=n[r];this.itemEntryService.resetModified(i)}},e.prototype.hasChanges=function(){return this._hasChanges||(this._hasChanges=this.detectChanges()),this._hasChanges},e.prototype.detectChanges=function(){var e=this;return!!this.items.some(this.itemEntryService.hasChanges)||this.collections.some(function(t){e.collectionHasChanges(t)})},e.prototype.collectionHasChanges=function(e){var t=this.collectionOptions[e.id];return!(!t.edit||!e.hasAddedItems()&&!e.hasRemovedItems())||t.editItems&&e.hasUpdatedItems()},e.prototype.isLockable=function(){return void 0!==this.rootItem&&this.itemEntryService.isLockable(this.rootItem)},e.prototype.save=function(e,t,r,n){var i=this;return void 0===e&&(e=!1),(this.isLockable()?this.lockService.fetchLock(this.rootItem):this.promiseService.when()).then(function(t){return i.executeCallbacks("onBeforeSave",e)},this.errorHandler.reject).then(function(){var e=h({},i.tabRequestParameters,t);return i.tabRequestParameters={},i.changesProcessorFactory.construct().execute(i.items.toArray(),i.collections.toArray(),r,e,i.collectionOptions,n)},this.errorHandler.reject).then(function(t){return i.isLockable()&&i.lockService.clearLock(i.rootItem),i._hasChanges=!1,e||i.updateSingleItems(t),i.executeCallbacks("onSaveSuccess",t).then(function(){return e||i.executeCallbacks("onSaveWithoutClosing",t),t},i.errorHandler.reject)},this.errorHandler.reject)},e.prototype.executeCallbacks=function(e,t){var r={};for(var n in this.callbacks[e])r[n]=this.callbacks[e][n](t);return this.promiseService.all(r)},e.prototype.enableChangesWatcher=function(){var e=this;null!==this.changesInterval&&(console.warn("Changes watcher already running!",this),this.disableChangesWatcher()),this.changesInterval=setInterval(function(){e.hasChanges()&&(e.disableChangesWatcher(),e.isLockable()&&e.lockService.fetchLock(e.rootItem))},3e3)},e.prototype.enableWatcher=function(){this.enableChangesWatcher()},e.prototype.disableChangesWatcher=function(){clearInterval(this.changesInterval),this.changesInterval=null},e.prototype.disableWatcher=function(){this.disableChangesWatcher()},e.prototype.registerCallback=function(e,t,r){var n=this;return this.callbacks[e][t]=r,function(){delete n.callbacks[e][t]}},e}(),xe=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p,f){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.collectionHandler=n,this.columnHandler=i,this.lockService=o,this.itemResourceFactory=s,this.collectionCacheFactory=c,this.changesProcessorFactory=a,this.itemCacheFactory=u,this.collectionResourceFactory=l,this.itemEntryService=h,this.itemResourceService=p,this.promiseService=f}return e.prototype.construct=function(){return new He(this.apiRequestService,this.errorHandler,this.itemHandler,this.collectionHandler,this.columnHandler,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.itemEntryService,this.itemResourceService,this.promiseService)},e}();r.d(t,"noop",function(){return De}),r.d(t,"identity",function(){return Pe}),r.d(t,"ViewResource",function(){return Ce}),r.d(t,"EditResource",function(){return ge}),r.d(t,"ENTRY_STATUS",function(){return R}),r.d(t,"COLUMN_SEPERATOR",function(){return">"}),r.d(t,"RENDER_AS_SEPERATOR",function(){return":"});var Me=function(e,t,r,n){this.promiseService=new A,this.apiFormatter=new I,this.keyService=new M,this.queryService=new L,this.columnUtil=new k,this.itemEntryService=new O(this.apiFormatter,this.keyService,this.promiseService),this.itemResourceService=new x(this.itemEntryService),this.lockService=new D(e,n,this.keyService,this.promiseService),this.queryMatcherFactory=new Fe(this.apiFormatter),this.itemCacheFactory=new pe(this.queryMatcherFactory,this.itemEntryService),this.batchStatusFactory=new U(this.promiseService),this.columnCache=new b(this.columnUtil),this.columnHandler=new F(e,n,this.promiseService,this.columnCache,this.columnUtil),this.columnSetFactory=new ae(this.columnHandler,this.columnUtil),this.columnExpansionFactory=new oe(this.columnHandler,this.columnSetFactory,this.columnUtil),this.itemEntryFactory=new me,this.itemHandler=new j(e,r,n,this.itemEntryFactory,this.columnHandler,this.itemCacheFactory,this.batchStatusFactory,this.columnExpansionFactory,this.columnSetFactory,this.itemEntryService,this.apiFormatter,this.keyService,this.promiseService,this.columnUtil),this.itemRequestService=new H(e,n,this.itemHandler,this.columnHandler,this.columnExpansionFactory,this.columnSetFactory,this.itemEntryService,this.queryService,this.promiseService),this.queryParserFactory=new we,this.collectionEntryService=new E(this.queryParserFactory,this.queryService),this.collectionResourceService=new T,this.collectionEntryFactory=new $(n,this.collectionEntryService,this.itemRequestService,this.itemEntryService,this.keyService,this.queryService,this.promiseService),this.collectionCacheFactory=new K(this.queryMatcherFactory),this.collectionHandler=new q(n,this.itemRequestService,this.itemHandler,this.columnHandler,this.collectionEntryFactory,this.collectionCacheFactory,this.queryParserFactory,this.collectionEntryService,this.columnSetFactory,this.itemEntryService,this.keyService,this.promiseService,this.queryService,this.columnUtil),this.requestColumnExpansionFactory=new je(this.columnUtil),this.createRequestFactory=new le(this.collectionHandler,this.requestColumnExpansionFactory,this.itemEntryService,this.keyService),this.changesCompilerFactory=new V(this.itemEntryService),this.changesProcessorFactory=new Q(e,n,this.itemHandler,this.collectionHandler,this.columnHandler,this.changesCompilerFactory,this.createRequestFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.collectionEntryService,this.itemEntryService,this.apiFormatter,this.promiseService),this.itemResourceFactory=new Ie(this.itemEntryService,this.itemResourceService),this.collectionResourceFactory=new ne(n,this.itemHandler,this.itemResourceFactory,this.changesProcessorFactory,this.keyService,this.promiseService),this.resourceCacheFactory=new xe(e,n,this.itemHandler,this.collectionHandler,this.columnHandler,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.itemEntryService,this.itemResourceService,this.promiseService),this.moduleChangesCompilerFactory=new qe(this.itemEntryService),this.itemAdministrator=new w(e,t,r,n,this.itemHandler,this.collectionHandler,this.columnSetFactory,this.itemRequestService,this.resourceCacheFactory,this.moduleChangesCompilerFactory,this.collectionEntryService,this.collectionResourceService,this.itemEntryService,this.keyService,this.queryService)};function De(){}function Pe(e){return e}t.default=Me},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i,o,s,c,a=1,u={},l=!1,h=e.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(e);p=p&&p.setTimeout?p:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick(function(){d(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?(s="setImmediate$"+Math.random()+"$",c=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&d(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",c,!1):e.attachEvent("onmessage",c),n=function(t){e.postMessage(s+t,"*")}):e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){d(e.data)},n=function(e){o.port2.postMessage(e)}):h&&"onreadystatechange"in h.createElement("script")?(i=h.documentElement,n=function(e){var t=h.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(d,0,e)},p.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];var i={callback:e,args:t};return u[a]=i,n(a),a++},p.clearImmediate=f}function f(e){delete u[e]}function d(e){if(l)setTimeout(d,0,e);else{var t=u[e];if(t){l=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(r,n)}}(t)}finally{f(e),l=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,r(2),r(3))},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(5),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(2))}])});
29
+ //# sourceMappingURL=rm-core.js.map