UNPKG

d2-ui

Version:
2 lines 64.8 kB
var d2=function(){var e=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}(function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(typeof e[t]){case"function":break;case"object":e[t]=function(t){var n=t.slice(1),r=e[t[0]];return function(e,t,i){r.apply(this,[e,t,i].concat(n))}}(e[t]);break;default:e[t]=e[e[t]]}return e}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function o(e){var t=new v["default"];t.setBaseUrl("");var n={getBaseUrl:function(){return this.activities.dhis.href}};return t.get(""+e).then(function(e){return Object.assign({},e,n)})}function a(){var e=v["default"].getApi();return _.baseUrl&&T&&e.setBaseUrl(_.baseUrl),e.get("userSettings")}function u(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],n=["apiEndpoint,name,authorities,singular,plural,shareable,metadata,klass,identifiableObject,properties[href","writable,collection,collectionName,name,propertyType,persisted,required,min,max,ordered,unique,constants","owner,itemPropertyType]"].join(","),r=[],i=function(t){return e.get("schemas/"+t,{fields:n})};if(t.length>0){var o=t.map(i),a=Promise.all(o).then(function(e){return{schemas:e}});r.push(a)}else r.push(e.get("schemas",{fields:n}));return r.push(e.get("attributes",{fields:":all,optionSet[:all,options[:all]]",paging:!1})),r}function s(e){var t=v["default"].getApi(),n=d["default"].getLogger(),r=P["default"].create(_,e),o={models:void 0,model:h["default"],Api:v["default"],system:g["default"].getSystem(),i18n:w["default"].getI18n()};P["default"].processConfigForD2(r,o),T?T=!1:j=c.Deferred.create();var s=u(t,r.schemas),l=[t.get("me",{fields:":all,organisationUnits[id],userGroups[id],userCredentials[:all,!user,userRoles[id]"}),t.get("me/authorization"),a()],f=[t.get("system/info"),t.get("apps")];return Promise.all([].concat(i(s),l,f,[o.i18n.load()])).then(function(e){var t={schemas:(0,c.pick)("schemas")(e[0]),attributes:(0,c.pick)("attributes")(e[1]),currentUser:e[2],authorities:e[3],userSettings:e[4],systemInfo:e[5],apps:e[6]};return t.schemas.map(function(e){return e.apiEndpoint=(0,c.updateAPIUrlWithBaseUrlVersionNumber)(e.apiEndpoint,r.baseUrl),e}).forEach(function(e){var n=t.attributes.filter(function(t){var n=[e.singular,"Attribute"].join("");return t[n]===!0});Object.prototype.hasOwnProperty.call(o.models,e.singular)||o.models.add(h["default"].ModelDefinition.createFromSchema(e,n))}),o.currentUser=E["default"].create(t.currentUser,t.authorities,o.models,t.userSettings),o.system.setSystemInfo(t.systemInfo),o.system.setInstalledApps(t.apps),j.resolve(o),j.promise})["catch"](function(e){return n.error("Unable to get schemas from the api",JSON.stringify(e),e),j.reject("Unable to get schemas from the DHIS2 API"),j.promise})}function l(){return j.promise}Object.defineProperty(t,"__esModule",{value:!0}),t.getManifest=o,t.getUserSettings=a,t.init=s,t.getInstance=l;var c=n(1),f=n(2),d=r(f),p=n(4),h=r(p),y=n(7),v=r(y),m=n(9),g=r(m),b=n(30),w=r(b),O=n(31),P=r(O),k=n(33),E=r(k);n(12);var T=!0,j=c.Deferred.create(),_=P["default"].create(),A=_;t.config=A,t["default"]={init:s,config:A,getInstance:l,getUserSettings:a,getManifest:o}},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){throw new Error(e)}function i(e,t){return function(){for(var n=arguments.length,r=Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.apply(this,[t].concat(r))}}function o(e,t,n){var r={enumerable:!0,configurable:!1,writable:!1,value:n};Object.defineProperty(e,t,r)}function a(e,t){var n=void 0;for(n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function u(e){return function(t){if(t)return t[e]}}function s(e,t){if(!t||!e)return e;var n=/api\/(2[3-9])/,r=t.match(n),i=r&&r[1],o=e&&!n.test(e);if(i&&o){var a=r[1];return e.replace(/api/,"api/"+a)}return e}function l(e){return encodeURIComponent(e).replace(h,decodeURIComponent)}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.throwError=r,t.curry=i,t.addLockedProperty=o,t.copyOwnProperties=a,t.pick=u,t.updateAPIUrlWithBaseUrlVersionNumber=s,t.customEncodeURIComponent=l;var f=function(){function e(){var t=this;n(this,e),this.promise=new Promise(function(e,n){t.resolve=e,t.reject=n})}return c(e,null,[{key:"create",value:function(){return new e}}]),e}();t.Deferred=f;var d=",&$=/;:",p=d.split("").map(function(e){return encodeURIComponent(e)}),h=new RegExp("(?:"+p.join("|")+")","g")},function(e,t,n){(function(r){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(3),u=function(){function e(t){i(this,e),(0,a.checkType)(t,"object","console"),this.logger=t}return o(e,[{key:"canLog",value:function(e){return!!(e&&console&&(0,a.isType)(this.logger[e],"function"))}},{key:"debug",value:function(){if(this.canLog("debug")){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.logger.debug.apply(console,t),!0}return!1}},{key:"error",value:function(){if(this.canLog("error")){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.logger.error.apply(console,t),!0}return!1}},{key:"log",value:function(){if(this.canLog("log")){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.logger.log.apply(console,t),!0}return!1}},{key:"warn",value:function(){if(this.canLog("warn")){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.logger.warn.apply(console,t),!0}return!1}}],[{key:"getLogger",value:function(){var t=void 0;try{t=r.console}catch(n){t=window.console}return this.logger?this.logger:this.logger=new e(t)}}]),e}();t["default"]=u,e.exports=t["default"]}).call(t,function(){return this}())},function(e,t){"use strict";function n(e,t){if(void 0!==e)return!0;throw new Error([t||"Value","should be provided"].join(" "))}function r(e,t,r){if(n(e,r),n(t,"Type"),"function"==typeof t&&e instanceof t||"string"==typeof t&&typeof e===t)return!0;throw new Error(["Expected",r||e,"to have type",t].join(" "))}function i(e,t){function n(){}try{return r(e,t),!0}catch(i){n()}return!1}function o(e){return i(e,"string")}function a(e){return Array.isArray(e)}function u(e){return i(e,Object)}function s(e){return void 0!==e}function l(e){return"number"==typeof e&&isFinite(e)&&e>-9007199254740992&&e<9007199254740992&&Math.floor(e)===e}function c(e){return"number"==typeof e&&isFinite(e)&&e-parseFloat(e)+1>=0}function f(e,t){var n=a(t)&&t||[];return n.indexOf(e)>=0}function d(e){return e&&11===e.length}Object.defineProperty(t,"__esModule",{value:!0}),t.checkDefined=n,t.checkType=r,t.isType=i,t.isString=o,t.isArray=a,t.isObject=u,t.isDefined=s,t.isInteger=l,t.isNumeric=c,t.contains=f,t.isValidUid=d,Number.isInteger||(Number.isInteger=l),t["default"]={checkType:r,checkDefined:n,isArray:a,isDefined:s,isInteger:l,isNumeric:c,isString:o,isType:i,contains:f,isValidUid:d}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(5),o=r(i),a=n(14),u=r(a),s=n(15),l=r(s),c=n(16),f=r(c),d=n(6),p=r(d);t["default"]={ModelBase:o["default"],Model:u["default"],ModelDefinition:l["default"],ModelDefinitions:f["default"],ModelValidation:p["default"]},e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){return Boolean(e.modelDefinition&&e.modelDefinition.modelValidations&&e.modelDefinition.modelValidations[t]&&Object.prototype.hasOwnProperty.call(e.modelDefinition.modelValidations,t))}function a(e){return e&&"Created"===e.httpStatus&&e&&(0,c.isValidUid)(e.response.uid)&&(this.dataValues.id=e.response.uid,this.dataValues.href=[this.modelDefinition.apiEndpoint,this.dataValues.id].join("/")),this.dirty=!1,this.getDirtyChildren().forEach(function(e){e.resetDirtyState?e.resetDirtyState():e.dirty=!1}),this[p].clear(),e}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(6),l=r(s),c=n(3),f=n(13),d=l["default"].getModelValidation(),p=Symbol("List to keep track of dirty properties");t.DIRTY_PROPERTY_LIST=p;var h=function(){function e(){i(this,e)}return u(e,[{key:"create",value:function(){var e=this;return this.validate().then(function(t){return t.status?e.modelDefinition.saveNew(e).then(a.bind(e)):Promise.reject(t)})}},{key:"save",value:function(e){var t=this;return this.isDirty(e)?this.validate().then(function(e){return e.status?t.modelDefinition.save(t).then(a.bind(t)):Promise.reject(e)}):Promise.reject("No changes to be saved")}},{key:"validate",value:function(){var e=this;return new Promise(function(t,n){function r(e,t){return t&&e.indexOf(t)===-1&&e.push(t),e}function i(e){return d.validateAgainstSchema(e)}var o=[];i(e)["catch"](function(e){return Array.isArray(e)?e:Promise.reject(e)}).then(function(e){o=o.concat(e);var n={status:0===e.length,fields:o.map(function(e){return e.property}).reduce(r,[]),messages:o};t(n)})["catch"](function(e){return n(e)})})}},{key:"clone",value:function(){return this.modelDefinition.create((0,f.getJSONForProperties)(this,Object.keys(this.modelDefinition.modelValidations)))}},{key:"delete",value:function(){return this.modelDefinition["delete"](this)}},{key:"isDirty",value:function(){var e=arguments.length<=0||void 0===arguments[0]||arguments[0];return!!(this.dirty||e===!0&&this.hasDirtyChildren())}},{key:"getDirtyPropertyNames",value:function(){return Array.from(this[p].values())}},{key:"getCollectionChildren",value:function(){var e=this;return Object.keys(this).filter(function(t){return e[t]&&o(e,t)&&e.modelDefinition.modelValidations[t].owner}).map(function(t){return e[t]})}},{key:"getCollectionChildrenPropertyNames",value:function(){var e=this;return Object.keys(this).filter(function(t){return e.modelDefinition&&e.modelDefinition.modelValidations&&e.modelDefinition.modelValidations[t]&&"COLLECTION"===e.modelDefinition.modelValidations[t].type})}},{key:"getDirtyChildren",value:function(){return this.getCollectionChildren().filter(function(e){return e&&e.dirty===!0})}},{key:"hasDirtyChildren",value:function(){return this.getDirtyChildren().length>0}}]),e}();t["default"]=new h},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(3),u=n(2),s=r(u),l=n(7),c=r(l),f=n(13),d=function(){function e(t){i(this,e),(0,a.checkType)(t,"object","logger (Logger)"),this.logger=t}return o(e,[{key:"validate",value:function(){throw this.logger.warn("Client side model validation is deprecated"),new Error("Client side model validation is deprecated")}},{key:"validateAgainstSchema",value:function(e){function t(e){if(e.response&&e.response.errorReports)return e.response.errorReports;throw new Error("Response was not a WebMessage with the expected format")}if(!(e&&e.modelDefinition&&e.modelDefinition.name))return Promise.reject("model.modelDefinition.name can not be found");var n="schemas/"+e.modelDefinition.name;return c["default"].getApi().post(n,(0,f.getOwnedPropertyJSON)(e)).then(function(e){return"OK"===e.status?[]:Promise.reject(e)})["catch"](t)}}],[{key:"getModelValidation",value:function(){return this.modelValidation?this.modelValidation:this.modelValidation=new e(s["default"].getLogger(console))}}]),e}();t["default"]=d,e.exports=t["default"]},function(e,t,n){(function(r,i){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(){var e=arguments.length<=0||void 0===arguments[0]?"REPLACE":arguments[0],t=h["default"].getSystem();return t.version&&Number(t.version.minor)<=22?"mergeStrategy="+e:"mergeMode="+e}function s(e,t){if(new RegExp("^(:?https?:)?//").test(t))return t;var n=[];return e&&n.push(e),n.push(t),n.join("/").replace(new RegExp("(.(?:[^:]))//+","g"),"$1/").replace(new RegExp("/$"),"")}function l(){return l.api?l.api:l.api=new y}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),f=n(3),d=n(1),p=n(9),h=o(p);n(12);var y=function(){function e(t){if(a(this,e),"function"==typeof t)this.fetch=t.bind("undefined"!=typeof window?window:r);else{if("undefined"==typeof fetch)throw new Error("Failed to initialise D2 Api: No fetch implementation is available");this.fetch=fetch.bind("undefined"!=typeof window?window:r)}this.baseUrl="/api",this.defaultFetchOptions={mode:"cors",credentials:"include",cache:"default",headers:new Headers}}return c(e,[{key:"get",value:function(e,t,n){return this.request("GET",s(this.baseUrl,e),t,n)}},{key:"post",value:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],r=s(this.baseUrl,e),o=t;if(n.headers=new Headers(n.headers||{}),n.contentType){if(!i.env||"test"!==i.env.npm_lifecycle_event){var a=new Error;console.warn("Deprecation warning: Setting `contentType` for API POST requests is deprecated, and support may be removed in the next major release of D2. In stead you may set the `Content-Type` header explicitly. If no `Content-Type` header is specified, the browser will try to determine one for you.\nRequest:","POST",r,a.stack)}n.headers.set("Content-Type","text/plain"),delete n.contentType}else"FormData"!==t.constructor.name||n.headers.get("Content-Type")?o=JSON.stringify(t):(n.headers.set("Content-Type","multipart/form-data"),o=t);return this.request("POST",r,o,n)}},{key:"delete",value:function(e,t){return this.request("DELETE",s(this.baseUrl,e),void 0,t)}},{key:"update",value:function(e,t){var n=!(arguments.length<=2||void 0===arguments[2])&&arguments[2],r=n===!0?e+"?"+u():e;return this.request("PUT",s(this.baseUrl,r),JSON.stringify(t))}},{key:"request",value:function(e,t,n){function r(t,r){var o=Object.assign({},s.defaultFetchOptions,t),a=new Headers(t.headers||{});if(o.method=e,"GET"===o.method||!r&&0!==r&&r!==!1?a["delete"]("Content-Type"):r&&(a.get("Content-Type")||a.set("Content-Type","FormData"===n.constructor.name?"multipart/form-data":"application/json"),o.body=r),t.dataType){if(!i.env||"test"!==i.env.npm_lifecycle_event){var u=new Error;console.warn("Deprecation warning: Setting `dataType` for API requests is deprecated, and support may be removed in the next major release of D2. In stead you should set the `Accept` header directly.\nRequest:",o.method,l,u.stack)}"text"===t.dataType&&(a.set("Accept","text/plain"),delete o.dataType)}return o.headers=a,o}function o(e){try{return JSON.parse(e)}catch(t){return e}}var a=this,u=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];(0,f.checkType)(e,"string","Request type"),(0,f.checkType)(t,"string","Url");var s=this,l=t,c="";l.indexOf("?")!==-1&&(c=l.substr(l.indexOf("?")+1),l=l.substr(0,l.indexOf("?"))),n&&Array.isArray(n.filter)&&(c=""+c+(c.length?"&":"")+"filter="+n.filter.join("&filter="),delete n.filter),n&&"GET"===e&&Object.keys(n).forEach(function(e){c=""+c+(c.length>0?"&":"")+e+"="+n[e]}),c.length&&(l=l+"?"+(0,d.customEncodeURIComponent)(c));var p=r(u,"GET"===u.method?void 0:n);return new Promise(function(e,t){a.fetch(l,p).then(function(n){n.ok?n.text().then(function(t){return e(o(t))}):n.text().then(function(e){i.env&&"test"===i.env.npm_lifecycle_event||console.warn("API request failed with status "+n.status+" "+n.statusText+"\n","Request: "+p.method+" "+l),t(o(e))})})["catch"](function(e){i.env&&"test"===i.env.npm_lifecycle_event||console.error("Server connection error:",e),t("Server connection failed for API request: "+p.method+" "+l)})})}},{key:"setBaseUrl",value:function(e){return(0,f.checkType)(e,"string","Base url"),this.baseUrl=e,this}}]),e}();y.getApi=l,t["default"]=y,e.exports=t["default"]}).call(t,function(){return this}(),n(8))},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function i(e){if(c===setTimeout)return setTimeout(e,0);if((c===n||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch(t){try{return c.call(null,e,0)}catch(t){return c.call(this,e,0)}}}function o(e){if(f===clearTimeout)return clearTimeout(e);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function a(){y&&p&&(y=!1,p.length?h=p.concat(h):v=-1,h.length&&u())}function u(){if(!y){var e=i(a);y=!0;for(var t=h.length;t;){for(p=h,h=[];++v<t;)p&&p[v].run();v=-1,t=h.length}p=null,y=!1,o(e)}}function s(e,t){this.fun=e,this.array=t}function l(){}var c,f,d=e.exports={};!function(){try{c="function"==typeof setTimeout?setTimeout:n}catch(e){c=n}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(e){f=r}}();var p,h=[],y=!1,v=-1;d.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new s(e,t)),1!==h.length||y||i(u)},s.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=l,d.addListener=l,d.once=l,d.off=l,d.removeListener=l,d.removeAllListeners=l,d.emit=l,d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.umask=function(){return 0}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(7),u=r(a),s=n(10),l=r(s),c=n(11),f=r(c),d=function(){function e(t,n){i(this,e),this.settings=t,this.configuration=n,this.systemInfo=void 0,this.version=void 0,this.installedApps=void 0}return o(e,[{key:"setSystemInfo",value:function(t){this.version=e.parseVersionString(t.version),this.systemInfo=t}},{key:"setInstalledApps",value:function(e){this.installedApps=e}},{key:"loadInstalledApps",value:function(){var e=this,t=u["default"].getApi();return t.get("apps").then(function(t){return e.setInstalledApps(t),t})}},{key:"uploadApp",value:function(e,t){var n=u["default"].getApi(),r=new FormData,i=void 0;return r.append("file",e),void 0!==t&&(i=new XMLHttpRequest,i.upload.onprogress=function(e){e.lengthComputable&&t(e.loaded/e.total)}),n.post("apps",r,{contentType:!1,processData:!1,xhr:void 0!==i?function(){return i}:void 0})}},{key:"loadAppStore",value:function(){var t=this,n=arguments.length<=0||void 0===arguments[0]||arguments[0];return new Promise(function(r,i){var o=u["default"].getApi();o.get("appStore").then(function(i){var o=Object.assign({},i);o.apps=o.apps.map(function(r){var i=Object.assign({},r);return n&&(i.versions=i.versions.filter(function(n){return e.isVersionCompatible(t.version,n)})),i}).filter(function(e){return e.versions.length>0}),r(o)})["catch"](function(e){i(e)})})}},{key:"installAppVersion",value:function(e){var t=u["default"].getApi();return new Promise(function(n,r){t.post(["appStore",e].join("/"),"",{dataType:"text"}).then(function(){n()})["catch"](function(e){r(e)})})}},{key:"uninstallApp",value:function(e){var t=u["default"].getApi();return t["delete"](["apps",e].join("/"))["catch"](function(){})}},{key:"reloadApps",value:function(){var e=this,t=u["default"].getApi();return t.update("apps").then(function(){return e.loadInstalledApps()})}}],[{key:"parseVersionString",value:function(e){return{major:Number.parseInt(e,10),minor:Number.parseInt(e.substring(e.indexOf(".")+1),10),snapshot:e.indexOf("-SNAPSHOT")>=0}}},{key:"compareVersions",value:function(t,n){var r="string"==typeof t||t instanceof String?e.parseVersionString(t):t,i="string"==typeof n||n instanceof String?e.parseVersionString(n):n;return r.major!==i.major?r.major-i.major:r.minor!==i.minor?r.minor-i.minor:(r.snapshot?0:1)-(i.snapshot?0:1)}},{key:"isVersionCompatible",value:function(t,n){var r=!n.min_platform_version||e.compareVersions(t,n.min_platform_version)>=0,i=!n.max_platform_version||e.compareVersions(t,n.max_platform_version)<=0;return r&&i}},{key:"getSystem",value:function(){return e.getSystem.system||(e.getSystem.system=new e(new l["default"],new f["default"])),e.getSystem.system}}]),e}();t["default"]=d,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(3),u=n(7),s=r(u),l=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?s["default"].getApi():arguments[0];i(this,e),this.api=t}return o(e,[{key:"all",value:function(){return this.api.get("systemSettings")}},{key:"get",value:function(e){function t(e){try{return JSON.parse(e)}catch(t){return e}}var n=this;return new Promise(function(r,i){if(!(0,a.isString)(e))throw new TypeError('A "key" parameter should be specified when calling get() on systemSettings');var o={headers:{accept:"text/plain"}};n.api.get(["systemSettings",e].join("/"),void 0,o).then(function(e){var n=t(e);n&&r(t(e)),i(new Error("The requested systemSetting has no value or does not exist."))})})}},{key:"set",value:function(e,t){var n=["systemSettings",e].join("/");return null===t||0===(""+t).length?this.api["delete"](n):this.api.post(n,t)}}]),e}();t["default"]=l,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(7),u=r(a),s=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?u["default"].getApi():arguments[0];i(this,e),this.api=t,this._configuration=void 0,this._configPromise=null}return o(e,[{key:"all",value:function(e){var t=this;return null!==this._configPromise&&e!==!0||(this._configPromise=this.api.get("configuration").then(function(e){return t._configuration=e,t._configuration})),this._configPromise}},{key:"get",value:function(e,t){return this.all(t).then(function(t){return t.hasOwnProperty(e)?Promise.resolve(t[e]):Promise.reject("Unknown config option: "+e)})}},{key:"set",value:function(e,t){var n=this,r=void 0;return"systemId"===e?Promise.reject("The system ID can't be changed"):(r="feedbackRecipients"!==e&&"selfRegistrationOrgUnit"!==e&&"selfRegistrationRole"!==e||"null"!==t&&null!==t?"corsWhitelist"===e?this.api.post(["configuration",e].join("/"),t.trim().split("\n")):this.api.post(["configuration",e].join("/"),t,{dataType:"text",contentType:"text/plain"}):this.api["delete"](["configuration",e].join("/")),r.then(function(){return n._configuration=void 0,Promise.resolve()})["catch"](function(){return Promise.reject("No configuration found for "+e)}))}}]),e}();t["default"]=s,e.exports=t["default"]},function(e,t){!function(e){"use strict";function t(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function n(e){return"string"!=typeof e&&(e=String(e)),e}function r(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return y.iterable&&(t[Symbol.iterator]=function(){return t}),t}function i(e){this.map={},e instanceof i?e.forEach(function(e,t){this.append(t,e)},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function o(e){return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function a(e){return new Promise(function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}})}function u(e){var t=new FileReader;return t.readAsArrayBuffer(e),a(t)}function s(e){var t=new FileReader;return t.readAsText(e),a(t)}function l(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,"string"==typeof e)this._bodyText=e;else if(y.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(y.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(y.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(e){if(!y.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e))throw new Error("unsupported BodyInit type")}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):y.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},y.blob?(this.blob=function(){var e=o(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(u)},this.text=function(){var e=o(this);if(e)return e;if(this._bodyBlob)return s(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var e=o(this);return e?e:Promise.resolve(this._bodyText)},y.formData&&(this.formData=function(){return this.text().then(d)}),this.json=function(){return this.text().then(JSON.parse)},this}function c(e){var t=e.toUpperCase();return v.indexOf(t)>-1?t:e}function f(e,t){t=t||{};var n=t.body;if(f.prototype.isPrototypeOf(e)){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new i(e.headers)),this.method=e.method,this.mode=e.mode,n||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=e;if(this.credentials=t.credentials||this.credentials||"omit",!t.headers&&this.headers||(this.headers=new i(t.headers)),this.method=c(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function d(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}}),t}function p(e){var t=new i,n=(e.getAllResponseHeaders()||"").trim().split("\n");return n.forEach(function(e){var n=e.trim().split(":"),r=n.shift().trim(),i=n.join(":").trim();t.append(r,i)}),t}function h(e,t){t||(t={}),this.type="default",this.status=t.status,this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText,this.headers=t.headers instanceof i?t.headers:new i(t.headers),this.url=t.url||"",this._initBody(e)}if(!e.fetch){var y={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};i.prototype.append=function(e,r){e=t(e),r=n(r);var i=this.map[e];i||(i=[],this.map[e]=i),i.push(r)},i.prototype["delete"]=function(e){delete this.map[t(e)]},i.prototype.get=function(e){var n=this.map[t(e)];return n?n[0]:null},i.prototype.getAll=function(e){return this.map[t(e)]||[]},i.prototype.has=function(e){return this.map.hasOwnProperty(t(e))},i.prototype.set=function(e,r){this.map[t(e)]=[n(r)]},i.prototype.forEach=function(e,t){Object.getOwnPropertyNames(this.map).forEach(function(n){this.map[n].forEach(function(r){e.call(t,r,n,this)},this)},this)},i.prototype.keys=function(){var e=[];return this.forEach(function(t,n){e.push(n)}),r(e)},i.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),r(e)},i.prototype.entries=function(){var e=[];return this.forEach(function(t,n){e.push([n,t])}),r(e)},y.iterable&&(i.prototype[Symbol.iterator]=i.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];f.prototype.clone=function(){return new f(this)},l.call(f.prototype),l.call(h.prototype),h.prototype.clone=function(){return new h(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new i(this.headers),url:this.url})},h.error=function(){var e=new h(null,{status:0,statusText:""});return e.type="error",e};var m=[301,302,303,307,308];h.redirect=function(e,t){if(m.indexOf(t)===-1)throw new RangeError("Invalid status code");return new h(null,{status:t,headers:{location:e}})},e.Headers=i,e.Request=f,e.Response=h,e.fetch=function(e,t){return new Promise(function(n,r){function i(){return"responseURL"in a?a.responseURL:/^X-Request-URL:/m.test(a.getAllResponseHeaders())?a.getResponseHeader("X-Request-URL"):void 0}var o;o=f.prototype.isPrototypeOf(e)&&!t?e:new f(e,t);var a=new XMLHttpRequest;a.onload=function(){var e={status:a.status,statusText:a.statusText,headers:p(a),url:i()},t="response"in a?a.response:a.responseText;n(new h(t,e))},a.onerror=function(){r(new TypeError("Network request failed"))},a.ontimeout=function(){r(new TypeError("Network request failed"))},a.open(o.method,o.url,!0),"include"===o.credentials&&(a.withCredentials=!0),"responseType"in a&&y.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send("undefined"==typeof o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)},function(e,t){"use strict";function n(e){return function(t){return e.indexOf(t)===-1}}function r(e){return function(t){return!n(e)(t)}}function i(e,t){var i={},a=e.getCollectionChildrenPropertyNames().filter(function(e){return"attributeValues"!==e}),u=Object.keys(e.modelDefinition.modelValidations).filter(function(e){return t.indexOf(e)>=0}).filter(function(t){return void 0!==e.dataValues[t]&&null!==e.dataValues[t]; });return u.filter(n(a)).forEach(function(t){i[t]=e.dataValues[t]}),u.filter(r(a)).forEach(function(t){return"compulsoryDataElementOperands"===t||"greyedFields"===t||"aggregationLevels"===t?void(i[t]=Array.from(e.dataValues[t])):void(i[t]=Array.from(e.dataValues[t].values()).filter(function(e){return e.id}).map(function(t){return e.modelDefinition&&"legendSet"===e.modelDefinition.name?o.call(t.modelDefinition,t):{id:t.id}}))}),i}function o(e){var t=e.modelDefinition.getOwnedPropertyNames();return i(e,t)}Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONForProperties=i,t.getOwnedPropertyJSON=o},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(3),u=n(5),s=r(u),l=function(){function e(t){var n=this;i(this,e),(0,a.checkType)(t,"object","modelDefinition"),(0,a.checkType)(t.modelProperties,"object","modelProperties"),Object.defineProperty(this,"modelDefinition",{enumerable:!1,configurable:!1,writable:!1,value:t}),Object.defineProperty(this,"dirty",{enumerable:!1,configurable:!1,writable:!0,value:!1}),Object.defineProperty(this,"dataValues",{enumerable:!1,configurable:!0,writable:!0,value:{}});var r=function(e){return e&&!!Object.keys(e).length},o={},s=t.attributeProperties;r(s)&&(Object.defineProperty(this,"attributes",{enumerable:!1,value:o}),Object.keys(s).forEach(function(e){Object.defineProperty(o,e,{enumerable:!0,get:function(){if(Array.isArray(n.attributeValues))return n.attributeValues.filter(function(t){return t.attribute.name===e}).reduce(function(e,t){return t.value},void 0)},set:function(t){n.attributeValues||(n.attributeValues=[]);var r=n.attributeValues.filter(function(t){return t.attribute.name===e}).reduce(function(e,t){return t},void 0);if(r){if(r.value===t)return;r.value=t}else n.attributeValues.push({value:t,attribute:{id:s[e].id,name:s[e].name}});n.dirty=!0}})})),Object.defineProperties(this,t.modelProperties),this[u.DIRTY_PROPERTY_LIST]=new Set([])}return o(e,null,[{key:"create",value:function(t){return new e(t)}}]),e}();l.prototype=s["default"],t["default"]=l,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){var n=t.collection?t.collectionName:t.name,r={configurable:!1,enumerable:!0,get:function(){return this.dataValues[n]}};t.writable&&(r.set=function(e){(!(0,h.isObject)(e)&&e!==this.dataValues[n]||(0,h.isObject)(e))&&(this.dirty=!0,this[A.DIRTY_PROPERTY_LIST].add(n),this.dataValues[n]=e)}),n&&(e[n]=r)}function u(e){var t={},n=(0,y.curry)(a,t);return(e||[]).forEach(n),t}function s(e,t){function n(e){if(e.href)return e.href.split("/").pop()}var r=t.collection?t.collectionName:t.name,i={persisted:t.persisted,type:T["default"].typeLookup(t.propertyType),required:t.required,min:t.min,max:t.max,owner:t.owner,unique:t.unique,writable:t.writable,constants:t.constants,ordered:Boolean(t.ordered)};("REFERENCE"===i.type||"COLLECTION"===i.type&&"REFERENCE"===t.itemPropertyType)&&(i.referenceType=n(t)),r&&(e[r]=i)}function l(e){var t={},n=(0,y.curry)(s,t);return(e||[]).forEach(n),t}function c(e,t){return function(n){return e&&t&&e.modelDefinition&&e.modelDefinition.modelValidations&&e.modelDefinition.modelValidations[n]&&"COLLECTION"===e.modelDefinition.modelValidations[n].type&&t.hasOwnProperty(e.modelDefinition.modelValidations[n].referenceType)}}function f(e){return Boolean(e.id)}Object.defineProperty(t,"__esModule",{value:!0});var d=function(e,t,n){for(var r=!0;r;){var i=e,o=t,a=n;r=!1,null===i&&(i=Function.prototype);var u=Object.getOwnPropertyDescriptor(i,o);if(void 0!==u){if("value"in u)return u.value;var s=u.get;if(void 0===s)return;return s.call(a)}var l=Object.getPrototypeOf(i);if(null===l)return;e=l,t=o,n=a,r=!0,u=l=void 0}},p=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=n(3),y=n(1),v=n(16),m=r(v),g=n(14),b=r(g),w=n(17),O=r(w),P=n(19),k=r(P),E=n(20),T=r(E),j=n(21),_=r(j),A=n(5),C=n(23),D=n(13),S=function(){function e(t,n,r,i,a,u,s){o(this,e),(0,h.checkType)(t,"string"),(0,h.checkType)(n,"string","Plural"),(0,y.addLockedProperty)(this,"name",t),(0,y.addLockedProperty)(this,"plural",n),(0,y.addLockedProperty)(this,"isShareable",r&&r.shareable||!1),(0,y.addLockedProperty)(this,"isMetaData",r&&r.metadata||!1),(0,y.addLockedProperty)(this,"apiEndpoint",r&&r.apiEndpoint),(0,y.addLockedProperty)(this,"javaClass",r&&r.klass),(0,y.addLockedProperty)(this,"identifiableObject",r&&r.identifiableObject),(0,y.addLockedProperty)(this,"modelProperties",i),(0,y.addLockedProperty)(this,"modelValidations",a),(0,y.addLockedProperty)(this,"attributeProperties",u),(0,y.addLockedProperty)(this,"authorities",s),this.filters=_["default"].getFilters(this),this.getOwnedPropertyJSON=D.getOwnedPropertyJSON.bind(this)}return p(e,[{key:"filter",value:function(){return this.clone().filters}},{key:"create",value:function(e){var t=b["default"].create(this),n=t.modelDefinition.modelValidations,r=m["default"].getModelDefinitions(),i=Object.assign({},e);return e?Object.keys(t).forEach(function(o){var a=n[o].hasOwnProperty("referenceType")&&n[o].referenceType||r.hasOwnProperty(o)&&o;a&&r.hasOwnProperty(a)&&Array.isArray(e[o])&&("translations"===o||"greyedFields"===o?i[o]=e[o]:i[o]=k["default"].create(t,r[a],e[o].map(function(e){return r[a].create(e)}))),t.dataValues[o]=i[o]}):!function(){Object.keys(t).filter(c(t,r)).forEach(function(e){var n=t.modelDefinition.modelValidations[e].referenceType;t.dataValues[e]=k["default"].create(t,r[n],[])});var e=(0,C.getDefaultValuesForModelType)(t.modelDefinition.name),n=c(t,r);Object.keys(t).filter(function(e){return!n(e)}).forEach(function(n){t.dataValues[n]=e[n]})}(),t}},{key:"clone",value:function(){var e=Object.getPrototypeOf(this),t=this.filters.filters,n=Object.create(e);return n=(0,y.copyOwnProperties)(n,this),n.filters=_["default"].getFilters(n),n.filters.filters=t.map(function(e){return e}),n}},{key:"get",value:function(e){var t=this,n=arguments.length<=1||void 0===arguments[1]?{fields:":all,attributeValues[:all,attribute[id,name,displayName]]"}:arguments[1];return(0,h.checkDefined)(e,"Identifier"),Array.isArray(e)?this.list({filter:["id:in:["+e.join(",")+"]"]}):this.api.get([this.apiEndpoint,e].join("/"),n).then(function(e){return t.create(e)})["catch"](function(e){return e.message?Promise.reject(e.message):Promise.reject(e)})}},{key:"list",value:function(){var e=this,t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=Object.assign({fields:":all"},t),r=this.filters.getFilters();return(0,h.isDefined)(n.filter)||(delete n.filter,r.length&&(n.filter=r)),this.api.get(this.apiEndpoint,n).then(function(t){return O["default"].create(e,t[e.plural].map(function(t){return e.create(t)}),t.pager)})}},{key:"save",value:function(e){if(f(e)){var t=D.getOwnedPropertyJSON.bind(this)(e),n=(0,y.updateAPIUrlWithBaseUrlVersionNumber)(e.dataValues.href,this.api.baseUrl);return this.api.update(n,t,!0)}return this.saveNew(e)}},{key:"saveNew",value:function(e){var t=D.getOwnedPropertyJSON.bind(this)(e);return this.api.post(this.apiEndpoint,t)}},{key:"getOwnedPropertyNames",value:function(){var e=this;return Object.keys(this.modelValidations).filter(function(t){return e.modelValidations[t].owner})}},{key:"delete",value:function(e){return e.dataValues.href?this.api["delete"](e.dataValues.href):this.api["delete"]([e.modelDefinition.apiEndpoint,e.dataValues.id].join("/"))}}],[{key:"createFromSchema",value:function(t){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],r=void 0;return(0,h.checkType)(t,Object,"Schema"),r="function"==typeof e.specialClasses[t.singular]?e.specialClasses[t.singular]:e,Object.freeze(new r(t.singular,t.plural,t,Object.freeze(u(t.properties)),Object.freeze(l(t.properties)),n.reduce(function(e,t){return e[t.name]=t,e},{}),t.authorities))}}]),e}(),M=function(e){function t(){o(this,t),d(Object.getPrototypeOf(t.prototype),"constructor",this).apply(this,arguments)}return i(t,e),p(t,[{key:"get",value:function(e){var n=arguments.length<=1||void 0===arguments[1]?{fields:":all,userCredentials[:owner]"}:arguments[1];return d(Object.getPrototypeOf(t.prototype),"get",this).call(this,e,n)}}]),t}(S),x=function(e){function t(){o(this,t),d(Object.getPrototypeOf(t.prototype),"constructor",this).apply(this,arguments)}return i(t,e),p(t,[{key:"create",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=Boolean(Object.keys(e).length),r=Object.keys(e).filter(function(e){return"compulsoryDataElementOperands"!==e}).reduce(function(t,n){return t[n]=e[n],t},{}),i=d(Object.getPrototypeOf(t.prototype),"create",this).call(this,n?r:void 0);return i.dataValues.compulsoryDataElementOperands=e.compulsoryDataElementOperands,i}}]),t}(S);S.specialClasses={user:M,dataSet:x},t["default"]=S,e.exports=t["default"]},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(){return i.modelDefinitions?i.modelDefinitions:i.modelDefinitions=new u}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(3),u=function(){function e(){r(this,e)}return o(e,[{key:"add",value:function(e){try{(0,a.checkType)(e.name,"string")}catch(t){throw new Error("Name should be set on the passed ModelDefinition to add one")}if(this[e.name])throw new Error(["Model",e.name,"already exists"].join(" "));this[e.name]=e,(0,a.isType)(e.plural,"string")&&(this[e.plural]=e)}},{key:"mapThroughDefinitions",value:function(e){var t=[],n=void 0;(0,a.checkType)(e,"function","transformer");for(n in this)this.hasOwnProperty(n)&&this[n].plural!==n&&t.push(e(this[n]));return t}}]),e}();u.getModelDefinitions=i,t["default"]=u,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e){if(e&&e[Symbol.iterator]){var t=[].concat(i(e));t.forEach(function(e){e instanceof d["default"]||(0,c.throwError)("Values of a ModelCollection must be instances of Model")})}}function u(e){if(e&&e[Symbol.iterator]){var t=[].concat(i(e));t.forEach(function(e){(0,l.isValidUid)(e.id)||(0,c.throwError)("Can not add a Model without id to a ModelCollection")})}}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(3),c=n(1),f=n(14),d=r(f),p=n(15),h=r(p),y=n(18),v=r(y),m=function(){function e(t,n,r){var i=this;o(this,e),(0,l.checkType)(t,h["default"]),this.modelDefinition=t,this.pager=new v["default"](r,t),this.valuesContainerMap=new Map,this[Symbol.iterator]=this.valuesContainerMap[Symbol.iterator].bind(this.valuesContainerMap),a(n),u(n),(0,l.isArray)(n)&&n.forEach(function(e){return i.valuesContainerMap.set(e.id,e)})}return s(e,[{key:"add",value:function(e){return a([e]),u([e]),this.set(e.id,e),this}},{key:"toArray",value:function(){var e=[];return this.forEach(function(t){e.push(t)}),e}},{key:"clear",value:function(){return this.valuesContainerMap.clear.apply(this.valuesContainerMap)}},{key:"delete",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.valuesContainerMap["delete"].apply(this.valuesContainerMap,t)}},{key:"entries",value:function(){return this.valuesContainerMap.entries.apply(this.valuesContainerMap)}},{key:"forEach",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.valuesContainerMap.forEach.apply(this.valuesContainerMap,t)}},{key:"get",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.valuesContainerMap.get.apply(this.valuesContainerMap,t)}},{key:"has",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.valuesContainerMap.has.apply(this.valuesContainerMap,t)}},{key:"keys",value:function(){return this.valuesContainerMap.keys.apply(this.valuesContainerMap)}},{key:"set",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.valuesContainerMap.set.apply(this.valuesContainerMap,t)}},{key:"values",value:function(){return this.valuesContainerMap.values.apply(this.valuesContainerMap)}},{key:"size",get:function(){return this.valuesContainerMap.size}}],[{key:"create",value:function(t,n,r){return new e(t,n,r)}},{key:"throwIfContainsOtherThanModelObjects",value:function(e){return a(e)}},{key:"throwIfContainsModelWithoutUid",value:function(e){return u(e)}}]),e}();t["default"]=m,e.exports=t["default"]},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(3),a=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?{page:1,pageCount:1}:arguments[0],n=arguments.length<=1||void 0===arguments[1]?{list:function(){return Promise.reject("No handler available")}}:arguments[1];r(this,e),this.page=t.page,this.pageCount=t.pageCount,this.total=t.total,this.nextPage=t.nextPage,this.prevPage=t.prevPage,this.pagingHandler=n}return i(e,[{key:"hasNextPage",value:function(){return(0,o.isDefined)(this.nextPage)}},{key:"hasPreviousPage",value:function(){return(0,o.isDefined)(this.prevPage)}},{key:"getNextPage",value:function(){return this.hasNextPage()?this.goToPage(this.page+1):Promise.reject("There is no next page for this collection")}},{key:"getPreviousPage",value:function(){return this.hasPreviousPage()?this.goToPage(this.page-1):Promise.reject("There is no previous page for this collection")}},{key:"goToPage",value:function(e){if(e<1)throw new Error("PageNr can not be less than 1");if(e>this.pageCount)throw new Error("PageNr can not be larger than the total page count of "+this.pageCount);return this.pagingHandler.list({page:e})}}]),e}();t["default"]=a,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(e,t,n){for(var r=!0;r;){var i=e,o=t,a=n;r=!1,null===i&&(i=Function.prototype);var u=Object.getOwnPropertyDescriptor(i,o);if(void 0!==u){if("value"in u)return u.value;var s=u.get;if(void 0===s)return;return s.call(a)}var l=Object.getPrototypeOf(i);if(null===l)return;e=l,t=o,n=a,r=!0,u=l=void 0}},s=n(17),l=r(s),c=function(e){function t(e,n,r){i(this,t),u(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,n,r,void 0),this.dirty=!1,this.added=new Set,this.removed=new Set,this.parentModel=e}return o(t,e),a(t,[{key:"add",value:function(e){return this.valuesContainerMap.has(e.id)?this:(u(Object.getPrototypeOf(t.prototype),"add",this).call(this,e),this.removed.has(e.id)?this.removed["delete"](e.id):this.added.add(e.id),this.updateDirty(),this)}},{key:"remove",value:function(e){return l["default"].throwIfContainsOtherThanModelObjects([e]),l["default"].throwIfContainsModelWithoutUid([e]),this["delete"](e.id)&&(this.added.has(e.id)?this.added["delete"](e.id):this.removed.add(e.id)),this.updateDirty(),this}},{key:"updateDirty",value:function(){return this.dirty=this.added.size>0||this.removed.size>0,this.dirty}},{key:"resetDirtyState",value:function(){this.dirty=!1,this.added=new Set,this.removed=new Set}},{key:"save",value:function(){var e=this;if(!this.dirty)return Promise.reject("Nothing to save!");var t=this.modelDefinition.api,n=[];return this.added.size&&Array.from(this.added).forEach(function(r){n.push(t.post([e.parentModel.href,e.modelDefinition.plural,r].join("/")))}),this.removed.size&&Array.from(this.removed).forEach(function(r){n.push(t["delete"]([e.parentModel.href,