UNPKG

d2

Version:

Javascript library for DHIS2

2 lines 134 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.d2=e():t.d2=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=146)}([function(t,e,n){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){if(void 0!==t)return!0;throw new Error([e||"Value","should be provided"].join(" "))}function i(t,e,n){if(o(t,n),o(e,"Type"),"function"==typeof e&&t instanceof e||"string"==typeof e&&r(t)===e)return!0;throw new Error(["Expected",n||t,"to have type",e].join(" "))}function a(t,e){try{return i(t,e),!0}catch(t){}return!1}function u(t){return a(t,"string")}function s(t){return Array.isArray(t)}function c(t){return a(t,Object)}function l(t){return null!=t}function f(t,e){return(s(e)&&e||[]).indexOf(t)>=0}n.d(e,"b",function(){return o}),n.d(e,"c",function(){return i}),n.d(e,"o",function(){return a}),n.d(e,"n",function(){return u}),n.d(e,"h",function(){return s}),n.d(e,"m",function(){return c}),n.d(e,"i",function(){return l}),n.d(e,"e",function(){return f}),n.d(e,"j",function(){return p}),n.d(e,"p",function(){return h}),n.d(e,"f",function(){return y}),n.d(e,"a",function(){return d}),n.d(e,"l",function(){return b}),n.d(e,"k",function(){return m}),n.d(e,"g",function(){return g}),n.d(e,"d",function(){return j}),Number.isInteger||(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&t>-9007199254740992&&t<9007199254740992&&Math.floor(t)===t});var p=function(t){return 0===t.length};function h(t){return t&&11===t.length}var y=function(t){return t&&Object.keys(t).length>0};function d(t,e){return l(t)&&l(e)&&e===t}var v=function(t){return function(e){return t.some(function(t){return function(t,e){return t===e}(e,t)})}},b=v([void 0,null,""]),m=function(t){return"function"==typeof t},g=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},w=["OR","AND"],O=v(w);function j(t){if(i(t,"string","rootJunction"),O(t))return!0;throw new Error("Expected ".concat(t," to be one of [").concat(w,"]"))}},function(t,e,n){"use strict";function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t){throw new Error(t)}function i(t,e){return function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.apply(this,[e].concat(r))}}function a(t,e,n){var r={enumerable:!0,configurable:!1,writable:!1,value:n};Object.defineProperty(t,e,r)}function u(t,e){return Object.keys(e).filter(function(t){return e.hasOwnProperty(t)}).forEach(function(n){t[n]=e[n]}),t}function s(t){var e=t.split(".");return function(t){return e.reduce(function(t,e){if(t)return t[e]},t)}}n.d(e,"i",function(){return o}),n.d(e,"d",function(){return i}),n.d(e,"b",function(){return a}),n.d(e,"c",function(){return u}),n.d(e,"g",function(){return s}),n.d(e,"h",function(){return c}),n.d(e,"a",function(){return l}),n.d(e,"j",function(){return f}),n.d(e,"e",function(){return y}),n.d(e,"f",function(){return d});var c=function(t,e){return function(n){var r=s(t)(n);return void 0!==r?r:e}},l=function(){function t(){var e=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})}var e,n,o;return e=t,o=[{key:"create",value:function(){return new t}}],(n=null)&&r(e.prototype,n),o&&r(e,o),t}();function f(t,e){if(!e||!t)return t;var n=/api\/([1-9][0-9])/,r=e.match(n),o=r&&r[1],i=t&&!n.test(t);if(o&&i){var a=r[1];return t.replace(/api/,"api/".concat(a))}return t}var p=",&$=/;:".split("").map(function(t){return encodeURIComponent(t)}),h=new RegExp("(?:".concat(p.join("|"),")"),"g");function y(t){return encodeURIComponent(t).replace(h,decodeURIComponent)}function d(t){return t}},function(t,e,n){"use strict";(function(t,r){n(30);var o=n(0),i=n(1),a=n(20);function u(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function c(t,e){if(new RegExp("^(:?https?:)?//").test(e))return e;var n=[];return t&&n.push(t),n.push(e),n.join("/").replace(new RegExp("(.(?:[^:]))//+","g"),"$1/").replace(new RegExp("/$"),"")}var l=function(){function e(n){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),"function"==typeof n)this.fetch=n.bind("undefined"!=typeof window?window:t);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:t)}this.baseUrl="/api",this.defaultFetchOptions={mode:"cors",credentials:"include",cache:"default"},this.defaultHeaders={"X-Requested-With":"XMLHttpRequest"},this.unauthorizedCallback=null}var n,l,f;return n=e,(l=[{key:"setDefaultHeaders",value:function(t){this.defaultHeaders=t}},{key:"setUnauthorizedCallback",value:function(t){if("function"!=typeof t)throw new Error("Callback must be a function.");this.unauthorizedCallback=t}},{key:"get",value:function(t,e,n){return this.request("GET",c(this.baseUrl,t),e,n)}},{key:"post",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=c(this.baseUrl,t),o=e;return n.headers=new Headers(n.headers||{}),void 0!==e&&("FormData"===e.constructor.name?(n.headers.delete("Content-Type"),o=e):n.headers.has("Content-Type")&&n.headers.get("Content-Type").toLocaleLowerCase().startsWith("text/")?o=String(e):(n.headers.set("Content-Type","application/json"),o=JSON.stringify(e))),this.request("POST",r,o,n)}},{key:"delete",value:function(t,e){return this.request("DELETE",c(this.baseUrl,t),void 0,e)}},{key:"update",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=e,i=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(e){u(t,e,n[e])})}return t}({},r,{headers:new Headers(r.headers||{})});void 0!==e&&(i.headers.has("Content-Type")||"string"!=typeof o?o=JSON.stringify(e):i.headers.set("Content-Type","text/plain"));var s=!0===n?"".concat(t,"?").concat(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"REPLACE",e=a.a.getSystem();return e.version&&Number(e.version.minor)<=22?"mergeStrategy=".concat(t):"mergeMode=".concat(t)}()):t;return this.request("PUT",c(this.baseUrl,s),o,i)}},{key:"patch",value:function(t,e){return this.request("PATCH",c(this.baseUrl,t),JSON.stringify(e))}},{key:"request",value:function(t,e,n){var a=this,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};Object(o.c)(t,"string","Request type"),Object(o.c)(e,"string","Url");var s=this,c=e,l="";if(-1!==c.indexOf("?")&&(l=c.substr(c.indexOf("?")+1),c=c.substr(0,c.indexOf("?"))),l){var f;try{f=decodeURIComponent(l)}catch(t){return Promise.reject(new Error("Query parameters in URL are invalid"))}if(l!==f)return Promise.reject(new Error("Cannot process URL-encoded URLs, pass an unencoded URL"));l=Object(i.e)(l)}if(n&&Array.isArray(n.filter)){var p=n.filter.map(function(t){return t.split(":").map(encodeURIComponent).join(":")});l="".concat(l).concat(l.length?"&":"","filter=").concat(p.join("&filter=")),delete n.filter}n&&"GET"===t&&Object.keys(n).forEach(function(t){l="".concat(l).concat(l.length>0?"&":"")+"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(n[t]))}),l.length&&(c="".concat(c,"?").concat(l));var h,y,d,v,b,m=(h=this.defaultHeaders,y=u,d=n,v=Object.assign({},s.defaultFetchOptions,y),b=new Headers(y.headers||{}),Object.keys(h).filter(function(t){return!b.get(t)}).forEach(function(t){return b.set(t,h[t])}),v.method=t,"GET"===v.method||!d&&0!==d&&!1!==d?b.delete("Content-Type"):d&&("FormData"===n.constructor.name?b.delete("Content-Type"):b.get("Content-Type")||b.set("Content-Type","application/json"),v.body=d),v.headers=b,v);function g(t){try{return JSON.parse(t)}catch(e){return t}}return new Promise(function(o,i){a.fetch(c,m).then(function(s){s.ok?s.text().then(function(t){return o(g(t))}):s.text().then(function(o){var l=g(o);if(401===s.status){var f={method:t,url:e,data:n,options:u};a.unauthorizedCallback&&a.unauthorizedCallback(f,l)}r.env&&"test"===r.env.npm_lifecycle_event||console.warn("API request failed with status ".concat(s.status," ").concat(s.statusText,"\n"),"Request: ".concat(m.method," ").concat(c)),i(l)})}).catch(function(t){r.env&&"test"===r.env.npm_lifecycle_event||console.error("Server connection error:",t),i("Server connection failed for API request: ".concat(m.method," ").concat(c))})})}},{key:"setBaseUrl",value:function(t){return Object(o.c)(t,"string","Base url"),this.baseUrl=t,this}}])&&s(n.prototype,l),f&&s(n,f),e}();l.getApi=function t(){return t.api?t.api:t.api=new l},e.a=l}).call(this,n(21),n(48))},function(t,e,n){var r=n(32),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();t.exports=i},function(t,e){var n=Array.isArray;t.exports=n},function(t,e,n){var r=n(68),o=n(71);t.exports=function(t,e){var n=o(t,e);return r(n)?n:void 0}},function(t,e,n){var r=n(3).Symbol;t.exports=r},function(t,e,n){var r=n(6),o=n(52),i=n(53),a="[object Null]",u="[object Undefined]",s=r?r.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?u:a:s&&s in Object(t)?o(t):i(t)}},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,e,n){var r=n(49),o=n(54),i=n(137),a=n(145),u=i(function(t,e){if(null==t)return[];var n=e.length;return n>1&&a(t,e[0],e[1])?e=[]:n>2&&a(e[0],e[1],e[2])&&(e=[e[0]]),o(t,r(e,1),[])});t.exports=u},function(t,e,n){var r=n(58),o=n(59),i=n(60),a=n(61),u=n(62);function s(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=o,s.prototype.get=i,s.prototype.has=a,s.prototype.set=u,t.exports=s},function(t,e,n){var r=n(23);t.exports=function(t,e){for(var n=t.length;n--;)if(r(t[n][0],e))return n;return-1}},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e,n){var r=n(5)(Object,"create");t.exports=r},function(t,e,n){var r=n(80);t.exports=function(t,e){var n=t.__data__;return r(e)?n["string"==typeof e?"string":"hash"]:n.map}},function(t,e,n){var r=n(35),o=n(28);t.exports=function(t){return null!=t&&o(t.length)&&!r(t)}},function(t,e,n){var r=n(7),o=n(8),i="[object Symbol]";t.exports=function(t){return"symbol"==typeof t||o(t)&&r(t)==i}},function(t,e,n){var r=n(16),o=1/0;t.exports=function(t){if("string"==typeof t||r(t))return t;var e=t+"";return"0"==e&&1/t==-o?"-0":e}},function(t,e){t.exports=function(t){return t}},function(t,e,n){"use strict";(function(t){var r=n(0);function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var i=function(){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Object(r.c)(t,"object","console"),this.logger=t}var n,i,a;return n=e,a=[{key:"getLogger",value:function(){var n;try{n=t.console}catch(t){n=window.console}return this.logger?this.logger:this.logger=new e(n)}}],(i=[{key:"canLog",value:function(t){return!!(t&&console&&Object(r.o)(this.logger[t],"function"))}},{key:"logMessage",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"log";if(this.canLog(t)&&this.logger[t]){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return(e=this.logger)[t].apply(e,r),!0}return!1}},{key:"debug",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.logMessage.apply(this,["debug"].concat(e))}},{key:"error",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.logMessage.apply(this,["error"].concat(e))}},{key:"log",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.logMessage.apply(this,["log"].concat(e))}},{key:"warn",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.logMessage.apply(this,["warn"].concat(e))}}])&&o(n.prototype,i),a&&o(n,a),e}();e.a=i}).call(this,n(21))},function(t,e,n){"use strict";var r=n(2),o=n(0);function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var a=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r.a.getApi();!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.api=e}var e,n,a;return e=t,(n=[{key:"all",value:function(){var t=this;return this.settings?Promise.resolve(this.settings):this.api.get("systemSettings").then(function(e){return t.settings=e,Promise.resolve(t.settings)})}},{key:"get",value:function(t){var e=this;if(this.settings&&this.settings[t])return Promise.resolve(this.settings[t]);return new Promise(function(n,r){if(!Object(o.n)(t))throw new TypeError('A "key" parameter should be specified when calling get() on systemSettings');e.api.get(["systemSettings",t].join("/"),void 0,{headers:{accept:"text/plain"}}).then(function(t){t&&n(function(t){try{return JSON.parse(t)}catch(e){return t}}(t)),r(new Error("The requested systemSetting has no value or does not exist."))})})}},{key:"set",value:function(t,e){var n=this,r=["systemSettings",t].join("/");return null===e||0==="".concat(e).length?this.api.delete(r).then(function(e){return n.settings&&n.settings[t]&&delete n.settings[t],e}):this.api.post(r,e,{headers:{"Content-Type":"text/plain"}}).then(function(r){return n.settings&&(n.settings[t]=e),r})}}])&&i(e.prototype,n),a&&i(e,a),t}();function u(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var s=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r.a.getApi();!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.api=e,this.configuration=void 0,this.configPromise=null}var e,n,o;return e=t,(n=[{key:"all",value:function(t){var e=this;return null!==this.configPromise&&!0!==t||(this.configPromise=this.api.get("configuration").then(function(t){return e.configuration=t,e.configuration})),this.configPromise}},{key:"get",value:function(t,e){return this.all(e).then(function(e){return e.hasOwnProperty(t)?Promise.resolve(e[t]):Promise.reject("Unknown config option: ".concat(t))})}},{key:"set",value:function(t,e){var n=this;return"systemId"===t?Promise.reject("The system ID can't be changed"):("feedbackRecipients"!==t&&"selfRegistrationOrgUnit"!==t&&"selfRegistrationRole"!==t||"null"!==e&&null!==e?"corsWhitelist"===t?this.api.post(["configuration",t].join("/"),e.trim().split("\n")):this.api.post(["configuration",t].join("/"),e,{dataType:"text",contentType:"text/plain"}):this.api.delete(["configuration",t].join("/"))).then(function(){return n.configuration=void 0,Promise.resolve()}).catch(function(){return Promise.reject("No configuration found for ".concat(t))})}}])&&u(e.prototype,n),o&&u(e,o),t}();function c(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var l=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.settings=e,this.configuration=n,this.systemInfo=void 0,this.version=void 0,this.installedApps=void 0}var e,n,o;return e=t,o=[{key:"parseVersionString",value:function(t){return{major:Number.parseInt(t,10),minor:Number.parseInt(t.substring(t.indexOf(".")+1),10),snapshot:t.indexOf("-SNAPSHOT")>=0}}},{key:"compareVersions",value:function(e,n){var r="string"==typeof e||e instanceof String?t.parseVersionString(e):e,o="string"==typeof n||n instanceof String?t.parseVersionString(n):n;return r.major!==o.major?r.major-o.major:r.minor!==o.minor?r.minor-o.minor:(r.snapshot?0:1)-(o.snapshot?0:1)}},{key:"isVersionCompatible",value:function(e,n){var r=n.minDhisVersion||n.min_platform_version||null,o=n.maxDhisVersion||n.max_platform_version||null,i=!r||t.compareVersions(e,r)>=0,a=!o||t.compareVersions(e,o)<=0;return i&&a}},{key:"getSystem",value:function(){return t.getSystem.system||(t.getSystem.system=new t(new a,new s)),t.getSystem.system}}],(n=[{key:"setSystemInfo",value:function(e){this.version=t.parseVersionString(e.version),this.systemInfo=e}},{key:"setInstalledApps",value:function(t){this.installedApps=t}},{key:"loadInstalledApps",value:function(){var t=this;return r.a.getApi().get("apps").then(function(e){return t.setInstalledApps(e),e})}},{key:"uploadApp",value:function(t,e){var n,o=r.a.getApi(),i=new FormData;return i.append("file",t),void 0!==e&&((n=new XMLHttpRequest).upload.onprogress=function(t){t.lengthComputable&&e(t.loaded/t.total)}),o.post("apps",i,{contentType:!1,processData:!1,xhr:void 0!==n?function(){return n}:void 0})}},{key:"loadAppStore",value:function(){var e=this,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return new Promise(function(o,i){r.a.getApi().get("appStore").then(function(r){return o(r.map(function(r){var o=Object.assign({},r);return n&&(o.versions=o.versions.filter(function(n){return t.isVersionCompatible(e.version,n)})),o}).filter(function(t){return t.versions.length>0}))}).catch(function(t){return i(t)})})}},{key:"installAppVersion",value:function(t){var e=r.a.getApi();return new Promise(function(n,r){e.post(["appStore",t].join("/"),"",{dataType:"text"}).then(function(){n()}).catch(function(t){r(t)})})}},{key:"uninstallApp",value:function(t){return r.a.getApi().delete(["apps",t].join("/")).catch(function(){})}},{key:"reloadApps",value:function(){var t=this;return r.a.getApi().update("apps").then(function(){return t.loadInstalledApps()})}}])&&c(e.prototype,n),o&&c(e,o),t}();e.a=l},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){var r=n(51),o=n(8),i=Object.prototype,a=i.hasOwnProperty,u=i.propertyIsEnumerable,s=r(function(){return arguments}())?r:function(t){return o(t)&&a.call(t,"callee")&&!u.call(t,"callee")};t.exports=s},function(t,e){t.exports=function(t,e){return t===e||t!=t&&e!=e}},function(t,e,n){var r=n(5)(n(3),"Map");t.exports=r},function(t,e,n){var r=n(72),o=n(79),i=n(81),a=n(82),u=n(83);function s(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=o,s.prototype.get=i,s.prototype.has=a,s.prototype.set=u,t.exports=s},function(t,e,n){var r=n(100),o=n(105),i=n(15);t.exports=function(t){return i(t)?r(t):o(t)}},function(t,e){var n=9007199254740991,r=/^(?:0|[1-9]\d*)$/;t.exports=function(t,e){var o=typeof t;return!!(e=null==e?n:e)&&("number"==o||"symbol"!=o&&r.test(t))&&t>-1&&t%1==0&&t<e}},function(t,e){var n=9007199254740991;t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=n}},function(t,e,n){var r=n(4),o=n(16),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;t.exports=function(t,e){if(r(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!o(t))||a.test(t)||!i.test(t)||null!=e&&t in Object(e)}},function(t,e,n){n(47),t.exports=self.fetch.bind(self)},function(t,e){t.exports=function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}},function(t,e,n){(function(e){var n="object"==typeof e&&e&&e.Object===Object&&e;t.exports=n}).call(this,n(21))},function(t,e){t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}},function(t,e,n){var r=n(10),o=n(63),i=n(64),a=n(65),u=n(66),s=n(67);function c(t){var e=this.__data__=new r(t);this.size=e.size}c.prototype.clear=o,c.prototype.delete=i,c.prototype.get=a,c.prototype.has=u,c.prototype.set=s,t.exports=c},function(t,e,n){var r=n(7),o=n(12),i="[object AsyncFunction]",a="[object Function]",u="[object GeneratorFunction]",s="[object Proxy]";t.exports=function(t){if(!o(t))return!1;var e=r(t);return e==a||e==u||e==i||e==s}},function(t,e){var n=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return n.call(t)}catch(t){}try{return t+""}catch(t){}}return""}},function(t,e,n){var r=n(84),o=n(8);t.exports=function t(e,n,i,a,u){return e===n||(null==e||null==n||!o(e)&&!o(n)?e!=e&&n!=n:r(e,n,i,a,t,u))}},function(t,e,n){var r=n(85),o=n(88),i=n(89),a=1,u=2;t.exports=function(t,e,n,s,c,l){var f=n&a,p=t.length,h=e.length;if(p!=h&&!(f&&h>p))return!1;var y=l.get(t);if(y&&l.get(e))return y==e;var d=-1,v=!0,b=n&u?new r:void 0;for(l.set(t,e),l.set(e,t);++d<p;){var m=t[d],g=e[d];if(s)var w=f?s(g,m,d,e,t,l):s(m,g,d,t,e,l);if(void 0!==w){if(w)continue;v=!1;break}if(b){if(!o(e,function(t,e){if(!i(b,e)&&(m===t||c(m,t,n,s,l)))return b.push(e)})){v=!1;break}}else if(m!==g&&!c(m,g,n,s,l)){v=!1;break}}return l.delete(t),l.delete(e),v}},function(t,e,n){(function(t){var r=n(3),o=n(102),i=e&&!e.nodeType&&e,a=i&&"object"==typeof t&&t&&!t.nodeType&&t,u=a&&a.exports===i?r.Buffer:void 0,s=(u?u.isBuffer:void 0)||o;t.exports=s}).call(this,n(40)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){var r=n(103),o=n(42),i=n(104),a=i&&i.isTypedArray,u=a?o(a):r;t.exports=u},function(t,e){t.exports=function(t){return function(e){return t(e)}}},function(t,e,n){var r=n(12);t.exports=function(t){return t==t&&!r(t)}},function(t,e){t.exports=function(t,e){return function(n){return null!=n&&n[t]===e&&(void 0!==e||t in Object(n))}}},function(t,e,n){var r=n(46),o=n(17);t.exports=function(t,e){for(var n=0,i=(e=r(e,t)).length;null!=t&&n<i;)t=t[o(e[n++])];return n&&n==i?t:void 0}},function(t,e,n){var r=n(4),o=n(29),i=n(117),a=n(120);t.exports=function(t,e){return r(t)?t:o(t,e)?[t]:i(a(t))}},function(t,e){!function(t){"use strict";if(!t.fetch){var e={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(e.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],r=function(t){return t&&DataView.prototype.isPrototypeOf(t)},o=ArrayBuffer.isView||function(t){return t&&n.indexOf(Object.prototype.toString.call(t))>-1};l.prototype.append=function(t,e){t=u(t),e=s(e);var n=this.map[t];this.map[t]=n?n+","+e:e},l.prototype.delete=function(t){delete this.map[u(t)]},l.prototype.get=function(t){return t=u(t),this.has(t)?this.map[t]:null},l.prototype.has=function(t){return this.map.hasOwnProperty(u(t))},l.prototype.set=function(t,e){this.map[u(t)]=s(e)},l.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},l.prototype.keys=function(){var t=[];return this.forEach(function(e,n){t.push(n)}),c(t)},l.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),c(t)},l.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),c(t)},e.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var i=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},d.call(v.prototype),d.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},m.error=function(){var t=new m(null,{status:0,statusText:""});return t.type="error",t};var a=[301,302,303,307,308];m.redirect=function(t,e){if(-1===a.indexOf(e))throw new RangeError("Invalid status code");return new m(null,{status:e,headers:{location:t}})},t.Headers=l,t.Request=v,t.Response=m,t.fetch=function(t,n){return new Promise(function(r,o){var i=new v(t,n),a=new XMLHttpRequest;a.onload=function(){var t,e,n={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new l,t.split(/\r?\n/).forEach(function(t){var n=t.split(":"),r=n.shift().trim();if(r){var o=n.join(":").trim();e.append(r,o)}}),e)};n.url="responseURL"in a?a.responseURL:n.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;r(new m(o,n))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.open(i.method,i.url,!0),"include"===i.credentials&&(a.withCredentials=!0),"responseType"in a&&e.blob&&(a.responseType="blob"),i.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),a.send(void 0===i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}function u(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function s(t){return"string"!=typeof t&&(t=String(t)),t}function c(t){var n={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e.iterable&&(n[Symbol.iterator]=function(){return n}),n}function l(t){this.map={},t instanceof l?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise(function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}})}function h(t){var e=new FileReader,n=p(e);return e.readAsArrayBuffer(t),n}function y(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(e.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(e.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(e.arrayBuffer&&e.blob&&r(t))this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!e.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!o(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=y(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.blob&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));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._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(h)}),this.text=function(){var t,e,n,r=f(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,n=p(e),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}function v(t,e){var n,r,o=(e=e||{}).body;if(t instanceof v){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new l(t.headers)),this.method=t.method,this.mode=t.mode,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new l(e.headers)),this.method=(n=e.method||this.method||"GET",r=n.toUpperCase(),i.indexOf(r)>-1?r:n),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function b(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(o))}}),e}function m(t,e){e||(e={}),this.type="default",this.status="status"in e?e.status:200,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new l(e.headers),this.url=e.url||"",this._initBody(t)}}("undefined"!=typeof self?self:this)},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(t){r=a}}();var s,c=[],l=!1,f=-1;function p(){l&&s&&(l=!1,s.length?c=s.concat(c):f=-1,c.length&&h())}function h(){if(!l){var t=u(p);l=!0;for(var e=c.length;e;){for(s=c,c=[];++f<e;)s&&s[f].run();f=-1,e=c.length}s=null,l=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function y(t,e){this.fun=t,this.array=e}function d(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new y(t,e)),1!==c.length||l||u(h)},y.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=d,o.addListener=d,o.once=d,o.off=d,o.removeListener=d,o.removeAllListeners=d,o.emit=d,o.prependListener=d,o.prependOnceListener=d,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,n){var r=n(31),o=n(50);t.exports=function t(e,n,i,a,u){var s=-1,c=e.length;for(i||(i=o),u||(u=[]);++s<c;){var l=e[s];n>0&&i(l)?n>1?t(l,n-1,i,a,u):r(u,l):a||(u[u.length]=l)}return u}},function(t,e,n){var r=n(6),o=n(22),i=n(4),a=r?r.isConcatSpreadable:void 0;t.exports=function(t){return i(t)||o(t)||!!(a&&t&&t[a])}},function(t,e,n){var r=n(7),o=n(8),i="[object Arguments]";t.exports=function(t){return o(t)&&r(t)==i}},function(t,e,n){var r=n(6),o=Object.prototype,i=o.hasOwnProperty,a=o.toString,u=r?r.toStringTag:void 0;t.exports=function(t){var e=i.call(t,u),n=t[u];try{t[u]=void 0;var r=!0}catch(t){}var o=a.call(t);return r&&(e?t[u]=n:delete t[u]),o}},function(t,e){var n=Object.prototype.toString;t.exports=function(t){return n.call(t)}},function(t,e,n){var r=n(33),o=n(55),i=n(128),a=n(134),u=n(42),s=n(135),c=n(18);t.exports=function(t,e,n){var l=-1;e=r(e.length?e:[c],u(o));var f=i(t,function(t,n,o){return{criteria:r(e,function(e){return e(t)}),index:++l,value:t}});return a(f,function(t,e){return s(t,e,n)})}},function(t,e,n){var r=n(56),o=n(115),i=n(18),a=n(4),u=n(125);t.exports=function(t){return"function"==typeof t?t:null==t?i:"object"==typeof t?a(t)?o(t[0],t[1]):r(t):u(t)}},function(t,e,n){var r=n(57),o=n(114),i=n(44);t.exports=function(t){var e=o(t);return 1==e.length&&e[0][2]?i(e[0][0],e[0][1]):function(n){return n===t||r(n,t,e)}}},function(t,e,n){var r=n(34),o=n(37),i=1,a=2;t.exports=function(t,e,n,u){var s=n.length,c=s,l=!u;if(null==t)return!c;for(t=Object(t);s--;){var f=n[s];if(l&&f[2]?f[1]!==t[f[0]]:!(f[0]in t))return!1}for(;++s<c;){var p=(f=n[s])[0],h=t[p],y=f[1];if(l&&f[2]){if(void 0===h&&!(p in t))return!1}else{var d=new r;if(u)var v=u(h,y,p,t,e,d);if(!(void 0===v?o(y,h,i|a,u,d):v))return!1}}return!0}},function(t,e){t.exports=function(){this.__data__=[],this.size=0}},function(t,e,n){var r=n(11),o=Array.prototype.splice;t.exports=function(t){var e=this.__data__,n=r(e,t);return!(n<0||(n==e.length-1?e.pop():o.call(e,n,1),--this.size,0))}},function(t,e,n){var r=n(11);t.exports=function(t){var e=this.__data__,n=r(e,t);return n<0?void 0:e[n][1]}},function(t,e,n){var r=n(11);t.exports=function(t){return r(this.__data__,t)>-1}},function(t,e,n){var r=n(11);t.exports=function(t,e){var n=this.__data__,o=r(n,t);return o<0?(++this.size,n.push([t,e])):n[o][1]=e,this}},function(t,e,n){var r=n(10);t.exports=function(){this.__data__=new r,this.size=0}},function(t,e){t.exports=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}},function(t,e){t.exports=function(t){return this.__data__.get(t)}},function(t,e){t.exports=function(t){return this.__data__.has(t)}},function(t,e,n){var r=n(10),o=n(24),i=n(25),a=200;t.exports=function(t,e){var n=this.__data__;if(n instanceof r){var u=n.__data__;if(!o||u.length<a-1)return u.push([t,e]),this.size=++n.size,this;n=this.__data__=new i(u)}return n.set(t,e),this.size=n.size,this}},function(t,e,n){var r=n(35),o=n(69),i=n(12),a=n(36),u=/^\[object .+?Constructor\]$/,s=Function.prototype,c=Object.prototype,l=s.toString,f=c.hasOwnProperty,p=RegExp("^"+l.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return!(!i(t)||o(t))&&(r(t)?p:u).test(a(t))}},function(t,e,n){var r,o=n(70),i=(r=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";t.exports=function(t){return!!i&&i in t}},function(t,e,n){var r=n(3)["__core-js_shared__"];t.exports=r},function(t,e){t.exports=function(t,e){return null==t?void 0:t[e]}},function(t,e,n){var r=n(73),o=n(10),i=n(24);t.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||o),string:new r}}},function(t,e,n){var r=n(74),o=n(75),i=n(76),a=n(77),u=n(78);function s(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=o,s.prototype.get=i,s.prototype.has=a,s.prototype.set=u,t.exports=s},function(t,e,n){var r=n(13);t.exports=function(){this.__data__=r?r(null):{},this.size=0}},function(t,e){t.exports=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}},function(t,e,n){var r=n(13),o="__lodash_hash_undefined__",i=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;if(r){var n=e[t];return n===o?void 0:n}return i.call(e,t)?e[t]:void 0}},function(t,e,n){var r=n(13),o=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;return r?void 0!==e[t]:o.call(e,t)}},function(t,e,n){var r=n(13),o="__lodash_hash_undefined__";t.exports=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=r&&void 0===e?o:e,this}},function(t,e,n){var r=n(14);t.exports=function(t){var e=r(this,t).delete(t);return this.size-=e?1:0,e}},function(t,e){t.exports=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}},function(t,e,n){var r=n(14);t.exports=function(t){return r(this,t).get(t)}},function(t,e,n){var r=n(14);t.exports=function(t){return r(this,t).has(t)}},function(t,e,n){var r=n(14);t.exports=function(t,e){var n=r(this,t),o=n.size;return n.set(t,e),this.size+=n.size==o?0:1,this}},function(t,e,n){var r=n(34),o=n(38),i=n(90),a=n(94),u=n(109),s=n(4),c=n(39),l=n(41),f=1,p="[object Arguments]",h="[object Array]",y="[object Object]",d=Object.prototype.hasOwnProperty;t.exports=function(t,e,n,v,b,m){var g=s(t),w=s(e),O=g?h:u(t),j=w?h:u(e),E=(O=O==p?y:O)==y,k=(j=j==p?y:j)==y,P=O==j;if(P&&c(t)){if(!c(e))return!1;g=!0,E=!1}if(P&&!E)return m||(m=new r),g||l(t)?o(t,e,n,v,b,m):i(t,e,O,n,v,b,m);if(!(n&f)){var S=E&&d.call(t,"__wrapped__"),_=k&&d.call(e,"__wrapped__");if(S||_){var A=S?t.value():t,T=_?e.value():e;return m||(m=new r),b(A,T,n,v,m)}}return!!P&&(m||(m=new r),a(t,e,n,v,b,m))}},function(t,e,n){var r=n(25),o=n(86),i=n(87);function a(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new r;++e<n;)this.add(t[e])}a.prototype.add=a.prototype.push=o,a.prototype.has=i,t.exports=a},function(t,e){var n="__lodash_hash_undefined__";t.exports=function(t){return this.__data__.set(t,n),this}},function(t,e){t.exports=function(t){return this.__data__.has(t)}},function(t,e){t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}},function(t,e){t.exports=function(t,e){return t.has(e)}},function(t,e,n){var r=n(6),o=n(91),i=n(23),a=n(38),u=n(92),s=n(93),c=1,l=2,f="[object Boolean]",p="[object Date]",h="[object Error]",y="[object Map]",d="[object Number]",v="[object RegExp]",b="[object Set]",m="[object String]",g="[object Symbol]",w="[object ArrayBuffer]",O="[object DataView]",j=r?r.prototype:void 0,E=j?j.valueOf:void 0;t.exports=function(t,e,n,r,j,k,P){switch(n){case O:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case w:return!(t.byteLength!=e.byteLength||!k(new o(t),new o(e)));case f:case p:case d:return i(+t,+e);case h:return t.name==e.name&&t.message==e.message;case v:case m:return t==e+"";case y:var S=u;case b:var _=r&c;if(S||(S=s),t.size!=e.size&&!_)return!1;var A=P.get(t);if(A)return A==e;r|=l,P.set(t,e);var T=a(S(t),S(e),r,j,k,P);return P.delete(t),T;case g:if(E)return E.call(t)==E.call(e)}return!1}},function(t,e,n){var r=n(3).Uint8Array;t.exports=r},function(t,e){t.exports=function(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}},function(t,e){t.exports=function(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}},function(t,e,n){var r=n(95),o=1,i=Object.prototype.hasOwnProperty;t.exports=function(t,e,n,a,u,s){var c=n&o,l=r(t),f=l.length;if(f!=r(e).length&&!c)return!1;for(var p=f;p--;){var h=l[p];if(!(c?h in e:i.call(e,h)))return!1}var y=s.get(t);if(y&&s.get(e))return y==e;var d=!0;s.set(t,e),s.set(e,t);for(var v=c;++p<f;){var b=t[h=l[p]],m=e[h];if(a)var g=c?a(m,b,h,e,t,s):a(b,m,h,t,e,s);if(!(void 0===g?b===m||u(b,m,n,a,s):g)){d=!1;break}v||(v="constructor"==h)}if(d&&!v){var w=t.constructor,O=e.constructor;w!=O&&"constructor"in t&&"constructor"in e&&!("function"==typeof w&&w instanceof w&&"function"==typeof O&&O instanceof O)&&(d=!1)}return s.delete(t),s.delete(e),d}},function(t,e,n){var r=n(96),o=n(97),i=n(26);t.exports=function(t){return r(t,i,o)}},function(t,e,n){var r=n(31),o=n(4);t.exports=function(t,e,n){var i=e(t);return o(t)?i:r(i,n(t))}},function(t,e,n){var r=n(98),o=n(99),i=Object.prototype.propertyIsEnumerable,a=Object.getOwnPropertySymbols,u=a?function(t){return null==t?[]:(t=Object(t),r(a(t),function(e){return i.call(t,e)}))}:o;t.exports=u},function(t,e){t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length,o=0,i=[];++n<r;){var a=t[n];e(a,n,t)&&(i[o++]=a)}return i}},function(t,e){t.exports=function(){return[]}},function(t,e,n){var r=n(101),o=n(22),i=n(4),a=n(39),u=n(27),s=n(41),c=Object.prototype.hasOwnProperty;t.exports=function(t,e){var n=i(t),l=!n&&o(t),f=!n&&!l&&a(t),p=!n&&!l&&!f&&s(t),h=n||l||f||p,y=h?r(t.length,String):[],d=y.length;for(var v in t)!e&&!c.call(t,v)||h&&("length"==v||f&&("offset"==v||"parent"==v)||p&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||u(v,d))||y.push(v);return y}},function(t,e){t.exports=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}},function(t,e){t.exports=function(){return!1}},function(t,e,n){var r=n(7),o=n(28),i=n(8),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,t.exports=function(t){return i(t)&&o(t.length)&&!!a[r(t)]}},function(t,e,n){(function(t){var r=n(32),o=e&&!e.nodeType&&e,i=o&&"object"==typeof t&&t&&!t.nodeType&&t,a=i&&i.exports===o&&r.process,u=function(){try{var t=i&&i.require&&i.require("util").types;return t||a&&a.binding&&a.binding("util")}catch(t){}}();t.exports=u}).call(this,n(40)(t))},function(t,e,n){var r=n(106),o=n(107),i=Object.prototype.hasOwnProperty;t.exports=function(t){if(!r(t))return o(t);var e=[];for(var n in Object(t))i.call(t,n)&&"constructor"!=n&&e.push(n);return e}},function(t,e){var n=Object.prototype;t.exports=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||n)}},function(t,e,n){var r=n(108)(Object.keys,Object);t.exports=r},function(t,e){t.exports=function(t,e){return function(n){return t(e(n))}}},function(t,e,n){var r=n(110),o=n(24),i=n(111),a=n(112),u=n(113),s=n(7),c=n(36),l=c(r),f=c(o),p=c(i),h=c(a),y=c(u),d=s;(r&&"[object DataView]"!=d(new r(new ArrayBuffer(1)))||o&&"[object Map]"!=d(new o)||i&&"[object Promise]"!=d(i.resolve())||a&&"[object Set]"!=d(new a)||u&&"[object WeakMap]"!=d(new u))&&(d=function(t){var e=s(t),n="[object Object]"==e?t.constructor:void 0,r=n?c(n):"";if(r)switch(r){case l:return"[object DataView]";case f:return"[object Map]";case p:return"[object Promise]";case h:return"[object Set]";case y:return"[object WeakMap]"}return e}),t.exports=d},function(t,e,n){var r=n(5)(n(3),"DataView");t.exports=r},function(t,e,n){var r=n(5)(n(3),"Promise");t.exports=r},function(t,e,n){var r=n(5)(n(3),"Set");t.exports=r},function(t,e,n){var r=n(5)(n(3),"WeakMap");t.exports=r},function(t,e,n){var r=n(43),o=n(26);t.exports=function(t){for(var e=o(t),n=e.length;n--;){var i=e[n],a=t[i];e[n]=[i,a,r(a)]}return e}},function(t,e,n){var r=n(37),o=n(116),i=n(122),a=n(29),u=n(43),s=n(44),c=n(17),l=1,f=2;t.exports=function(t,e){return a(t)&&u(e)?s(c(t),e):function(n){var a=o(n,t);return void 0===a&&a===e?i(n,t):r(e,a,l|f)}}},function(t,e,n){var r=n(45);t.exports=function(t,e,n){var o=null==t?void 0:r(t,e);return void 0===o?n:o}},function(t,e,n){var r=n(118),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,a=r(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(o,function(t,n,r,o){e.push(r?o.replace(i,"$1"):n||t)}),e});t.exports=a},function(t,e,n){var r=n(119),o=500;t.exports=function(t){var e=r(t,function(t){return n.size===o&&n.clear(),t}),n=e.cache;return e}},function(t,e,n){var r=n(25),o="Expected a function";function i(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError(o);var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var a=t.apply(this,r);return n.cache=i.set(o,a)||i,a};return n.cache=new(i.Cache||r),n}i.Cache=r,t.exports=i},function(t,e,n){var r=n(121);t.exports=function(t){return null==t?"":r(t)}},function(t,e,n){var r=n(6),o=n(33),i=n(4),a=n(16),u=1/0,s=r?r.prototype:void 0,c=s?s.toString:void 0;t.exports=function t(e){if("string"==typeof e)return e;if(i(e))return o(e,t)+"";if(a(e))return c?c.call(e):"";var n=e+"";return"0"==n&&1/e==-u?"-0":n}},function(t,e,n){var r=n(123),o=n(124);t.exports=function(t,e){return null!=t&&o(t,e,r)}},function(t,e){t.exports=function(t,e){return null!=t&&e in Object(t)}},function(t,e,n){var r=n(46),o=n(22),i=n(4),a=n(27),u=n(28),s=n(17);t.exports=function(t,e,n){for(var c=-1,l=(e=r(e,t)).length,f=!1;++c<l;){var p=s(e[c]);if(!(f=null!=t&&n(t,p)))break;t=t[p]}return f||++c!=l?f:!!(l=null==t?0:t.length)&&u(l)&&a(p,l)&&(i(t)||o(t))}},function(t,e,n){var r=n(126),o=n(127),i=n(29),a=n(17);t.exports=function(t){return i(t)?r(a(t)):o(t)}},function(t,e){t.exports=function(t){return function(e){return null==e?void 0:e[t]}}},function(t,e,n){var r=n(45);t.exports=function(t){return function(e){return r(e,t)}}},function(t,e,n){var r=n(129),o=n(15);t.exports=function(t,e){var n=-1,i=o(t)?Array(t.length):[];return r(t,function(t,r,o){i[++n]=e(t,r,o)}),i}},function(t,e,n){var r=n(130),o=n(133)(r);t.exports=o},function(t,e,n){var r=n(131),o=n(26);t.exports=function(t,e){return t&&r(t,e,o)}},function(t,e,n){var r=n(132)();t.exports=r},function(t,e){t.exports=function(t){return function(e,n,r){for(var o=-1,i=Object(e),a=r(e),u=a.length;u--;){var s=a[t?u:++o];if(!1===n(i[s],s,i))break}return e}}},function(t,e,n){var r=n(15);t.exports=function(t,e){return function(n,o){if(null==n)return n;if(!r(n))return t(n,o);for(var i=n.length,a=e?i:-1,u=Object(n);(e?a--:++a<i)&&!1!==o(u[a],a,u););return n}}},function(t,e){t.exports=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}},function(t,e,n){var r=n(136);t.exports=function(t,e,n){for(var o=-1,i=t.criteria,a=e.criteria,u=i.length,s=n.length;++o<u;){var c=r(i[o],a[o]);if(c)return o>=s?c:c*("desc"==n[o]?-1:1)}return t.index-e.index}},function(t,e,n){var r=n(16);t.exports=function(t,e){if(t!==e){var n=void 0!==t,o=null===t,i=t==t,a=r(t),u=void 0!==e,s=null===e,c=e==e,l=r(e);if(!s&&!l&&!a&&t>e||a&&u&&c&&!s&&!l||o&&u&&c||!n&&c||!i)return 1;if(!o&&!a&&!l&&t<e||l&&n&&i&&!o&&!a||s&&n&&i||!u&&i||!c)return-1}return 0}},function(t,e,n){var r=n(18),o=n(138),i=n(140);t.exports=function(t,e){return i(o(t,e,r),t+"")}},function(t,e,n){var r=n(139),o=Math.max;t.exports=function(t,e,n){return e=o(void 0===e?t.length-1:e,0),function(){for(var i=arguments,a=-1,u=o(i.length-e,0),s=Array(u);++a<u;)s[a]=i[e+a];a=-1;for(var c=Array(e+1);++a<e;)c[a]=i[a];return c[e]=n(s),r(t,this,c)}}},function(t,e){t.exports=function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}},function(t,e,n){var r=n(141),o=n(144)(r);t.exports=o},function(t,e,n){var r=n(142),o=n(143),i=n(18),a=o?function(t,e){return o(t,"toString",{configurable:!0,enumerable:!1,value:r(e),writable:!0})}:i;t.exports=a},function(t,e){t.exports=function(t){return function(){return t}}},function(t,e,n){var r=n(5),o=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=o},function(t,e){var n=800,r=16,o=Date.now;t.exports=function(t){var e=0,i=0;return function(){var a=o(),u=r-(a-i);if(i=a,u>0){if(++e>=n)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}},function(t,e,n){var r=n(23),o=n(15),i=n(27),a=n(12);t.exports=function(t,e,n){if(!a(n))return!1;var u=typeof e;return!!("number"==u?o(n)&&i(e,n.length):"string"==u&&e in n)&&r(n[e],t)}},function(t,e,n){"use strict";n.r(e);n(30);var r=n(1),o=n(19),i=n(0),a=n(2),u={aggregationLevels:["dataElement"],grantTypes:["oAuth2Client"],translations:[],deliveryChannels:["programNotificationTemplate","dataSetNotificationTemplate"],redirectUris:["oAuth2Client"],organisationUnitLevels:["validationRule"],favorites:[],columns:[],rows:[],filters:[],yearlySeries:[],interpretations:["chart"],userGroupAccesses:[],userAccesses:[]},s=function(t,e){var n=u[t];return!!n&&(Object(i.e)(e,n)||Object(i.j)(n))};function c(t){return function(e){return-1===t.indexOf(e)}}function l(t){return function(e){return t.indexOf(e)>=0}}function f(t,e){var n,o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a={},u=t.getCollectionChildrenPropertyNames().filter(function(t){return"attributeValues"!==t}),f=Object.keys(t.modelDefinition.modelValidations).filter(function(t){return e.indexOf(t)>=0}).filter(function(e){return void 0!==t.dataValues[e]&&null!==t.dataValues[e]});return f.filter(c(u)).filter(function(e){return!l(t.getReferenceProperties())(e)}).forEach(function(e){a[e]=t.dataValues[e]}),f.filter(c(u)).filter(l(t.getReferenceProperties())).forEach(function(e){a[e]={id:t.dataValues[e].id}}),f.filter((n=u,function(t){return!c(n)(t)})).forEach(function(e){if(s(e,t.modelDefinition.name))a[e]=Array.from(t.dataValues[e]);else{var n=Array.isArray(t.dataValues[e])?t.dataValues[e]:Array.from(t.dataValues[e].values());-1===t.getEmbeddedObjectCollectionPropertyNames().indexOf(e)?a[e]=n.filter(Object(r.g)("id")).map(function(t){return o&&Object(i.k)(t.clone)?t.clone():{id:t.id}}):a[e]=n}}),a}function p(t){var e=t.modelDefinition.getOwnedPropertyNames();return f(t,e)}function h(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function y(t){if(t.response&&t.response.errorReports)return t.response.errorReports;throw new Error("Response was not a WebMessage with the expected format")}var d=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object(i.c)(e,"object","logger (Logger)"),this.logger=e}var e,n,r;return e=t,r=[{key:"getModelValidation",value:function(){return this.modelValidation?this.modelValidation:this.modelValidation=new t(o.a.getLogger(console))}}],(n=[{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(t){if(!(t&&t.modelDefinition&&t.modelDefinition.name))return Promise.reject("model.modelDefinition.name can not be found");var e="schemas/".concat(t.modelDefinition.name);return a.a.getApi().post(e,p(t)).then(function(t){return"OK"===t.status?[]:Promise.reject(t)}).catch(y)}}])&&h(e.prototype,n),r&&h(e,r),t}(),v="abcdefghijklmnopqrstuvwxyz",b=v.concat(v.toUpperCase()),m="0123456789".concat(b),g=(m.length,/^[a-zA-Z]{1}[a-zA-Z0-9]{10}$/);function w(t){return null!=t&&g.test(t)}var O=function(t,e){return Boolean(Object(r.g)("modelDefinition.modelValidations.".concat(t))(e))};var j=Object(r.g)("httpStatus"),E=Object(r.g)("response.uid"),k=function(t){return Object(r.g)("modelDefinition.modelValidations.".concat(t))},P=Object(r.g)("type"),S=Object(r.g)("embeddedObject"),_=Object(r.g)("owner"),A=function(t,e){return P(k(t)(e))},T=function(t,e){return S(k(t)(e))};function x(t){var e=E(t);return"Created"===j(t)&&w(e)&&(this.dataValues.id=e,this.dataValues.href=[this.modelDefinition.apiEndpoint,this.dataValues.id].join("/")),this.resetDirtyState(),t}function C(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var D=d.getModelValidation(),R=Symbol("List to keep track of dirty properties"),N=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);Object.defineProperty(this,"modelDefinition",{writable:!0,value:{modelValidations:{}}})}var e,n,r;return e=t,(n=[{key:"create",value:function(){var t=this;return this.validate().then(function(e){return e.status?t.modelDefinition.saveNew(t).then(function(e){return x.call(t,e)}):Promise.reject(e)})}},{key:"save",value:function(t){var e=this;return this.isDirty(t)?this.validate().then(function(t){return t.status?e.modelDefinition.save(e).then(function(t){return x.call(e,t)}):Promise.reject(t)}):Promise.resolve({})}},{key:"validate",value:function(){var t=this;return new Promise(function(e,n){var r,o=[];function i(t,e){return e&&-1===t.indexOf(e)&&t.push(e),t}(r=t,D.validateAgainstSchema(r)).catch(function(t){return Array.isArray(t)?t:Promise.reject(t)}).then(function(t){o=o.concat(t);var n={status:0===t.length,fields:o.map(function(t){return t.property}).reduce(i,[]),messages:o};e(n)}).catch(function(t){return n(t)})})}},{key:"clone",value:function(){var t=this.modelDefinition.create(f(this,Object.keys(this.modelDefinition.modelValidations),!0));return this.isDirty()&&(t.dirty=this.isDirty(!0)),t}},{key:"delete",value:function(){return this.modelDefinition.delete(this)}},{key:"isDirty",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.dirty||!0===t&&this.hasDirtyChildren()}},{key:"resetDirtyState",value:function(){return this.dirty=!1,this.getDirtyChildren().forEach(function(t){t.resetDirtyState?t.resetDirtyState():t.dirty=!1}),this[R].clear(),this}},{key:"getDirtyPropertyNames",value:function(){return Array.from(this[R].values())}},{key:"getCollectionChildren",value:function(){var t=this;return Object.keys(this).filter(function(e){return t[e]&&(n=t,r=e,Boolean(O(r,n)&&Object(i.g)(n.modelDefinition.modelValidations,r)))&&function(t,e){return _(k(t)(e))}(e,t);var n,r}).map(function(e){return t[e]})}},{key:"getCollectionChildrenPropertyNames",value:function(){var t=this;return Object.keys(this).filter(function(e){return"COLLECTION"===A(e,t)})}},{key:"getReferenceProperties",value:function(){var t=this;return Object.keys(this).filter(function(e){return"REFERENCE"===A(e,t)&&!1===T(e,t)})}},{key:"getEmbeddedObjectCollectionPropertyNames",value:function(){var t=this;return this.getCollectionChildrenPropertyNames().filter(function(e){return T(e,t)})}},{key:"getDirtyChildren",value:function(){return this.getCollectionChildren().filter(function(t){return t&&!0===t.dirty})}},{key:"hasDirtyChildren",value:function(){return this.getDirtyChildren().length>0}},{key:"toJSON",value:function(){return f(this,Object.keys(this.modelDefinition.modelValidations))}}])&&C(e.prototype,n),r&&C(e,r),t}(),U=Object(r.g)("value"),I=Object(r.g)("attribute.name");var M=function(t,e,n,r){return Object.keys(t).reduce(function(o,a){return o[a]={enumerable:!0,get:function(){return e().filter(function(t){return I(t)===a}).reduce(function(t,e){return e.value},void 0)},set:function(o){var u=e().filter(function(t){return t.attribute.name===a}).reduce(function(t,e){return e},void 0);if(!Object(i.a)(U(u),o)){if(u){if(Object(i.l)(o)){var s=e().filter(function(t){return t!==u});n(s)}u.value=o}else n(e().concat({value:o,attribute:{id:t[a].id,name:t[a].name}}));r()}}},o},{})};function V(t){return(V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function L(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function F(t){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function B(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function q(t,e){return(q=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var H=Object(r.h)("attributeValues",[]),G=function(t){function e(t){var n,r,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),r=this,o=F(e).call(this),n=!o||"object"!==V(o)&&"function"!=typeof o?B(r):o,Object(i.c)(t,"object","modelDefinition"),Object(i.c)(t.modelProperties,"object","modelProperties"),Object.defineProperty(B(n),"modelDefinition",{value:t}),Object.defineProperty(B(n),"dirty",{writable:!0,value:!1}),Object.defineProperty(B(n),"dataValues",{configurable:!0,writable:!0,value:{}}),Object.defineProperties(B(n),t.modelProperties);var a={},u=t.attributeProperties;if(Object(i.f)(u)){Object.defineProperty(B(n),"attributes",{value:a});var s=M(u,function(){return H(B(n))},function(t){return n.attributeValues=t},function(){return n.dirty=!0});Object.defineProperties(a,s)}return n[R]=new Set([]),n}var n,r,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&q(t,e)}(e,N),n=e,o=[{key:"create",value:function(t){return new e(t)}}],(r=null)&&L(n.prototype,r),o&&L(n,o),e}();function z(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var $=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,n,r;return e=t,(n=[{key:"add",value:function(t){try{Object(i.c)(t.name,"string")}catch(t){throw new Error("Name should be set on the passed ModelDefinition to add one")}if(this[t.name])throw new Error(["Model",t.name,"already exists"].join(" "));this[t.name]=t,Object(i.o)(t.plural,"string")&&(this[t.plural]=t)}},{key:"mapThroughDefinitions",value:function(t){var e=this;return Object(i.c)(t,"function","transformer"),Object.keys(this).filter(function(t){return e.hasOwnProperty(t)&&!(e[t].plural===t)}).map(function(n){return t(e[n])})}}])&&z(e.prototype,n),r&&z(e,r),t}();$.getModelDefinitions=function t(){return t.modelDefinitions?t.modelDefinitions:t.modelDefinitions=new $};var J=$;function W(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var X=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{page:1,pageCount:1,query:{}},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{list:function(){return Promise.reject("No handler available")}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.page=e.page,this.pageCount=e.pageCount,this.total=e.total,this.nextPage=e.nextPage,this.prevPage=e.prevPage,this.query=e.query,this.pagingHandler=n}var e,n,r;return e=t,(n=[{key:"hasNextPage",value:function(){return Object(i.i)(this.nextPage)}},{key:"hasPreviousPage",value:function(){return Object(i.i)(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(t){if(t<1)throw new Error("PageNr can not be less than 1");if(t>this.pageCount)throw new Error("PageNr can not be larger than the total page count of ".concat(this.pageCount));return this.pagingHandler.list(Object.assign({},this.query,{page:t}))}}])&&W(e.prototype,n),r&&W(e,r),t}();function K(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Y(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function Q(t){t&&t[Symbol.iterator]&&Y(t).forEach(function(t){t instanceof G||Object(r.i)("Values of a ModelCollection must be instances of Model")})}function Z(t){t&&t[Symbol.iterator]&&Y(t).forEach(function(t){Object(i.p)(t.id)||Object(r.i)("Can not add a Model without id to a ModelCollection")})}var tt=function(){function t(e,n,r){var o=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object(i.c)(e,It),this.modelDefinition=e,this.pager=new X(r,e),this.valuesContainerMap=new Map,this[Symbol.iterator]=this.valuesContainerMap[Symbol.iterator].bind(this.valuesContainerMap),Q(n),Z(n),Object(i.h)(n)&&n.forEach(function(t){return o.valuesContainerMap.set(t.id,t)})}var e,n,r;return e=t,r=[{key:"create",value:function(e,n,r){return new t(e,n,r)}},{key:"throwIfContainsOtherThanModelObjects",value:function(t){return Q(t)}},{key:"throwIfContainsModelWithoutUid",value:function(t){return Z(t)}}],(n=[{key:"add",value:function(t){return Q([t]),Z([t]),this.set(t.id,t),this}},{key:"toArray",value:function(){var t=[];return this.forEach(function(e){t.push(e)}),t}},{key:"clear",value:function(){return this.valuesContainerMap.clear.call(this.valuesContainerMap)}},{key:"delete",value:function(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(t=this.valuesContainerMap.delete).call.apply(t,[this.valuesContainerMap].concat(n))}},{key:"entries",value:function(){return this.valuesContainerMap.entries.call(this.valuesContainerMap)}},{key:"forEach",value:function(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(t=this.valuesContainerMap.forEach).call.apply(t,[this.valuesContainerMap].concat(n))}},{key:"get",value:function(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(t=this.valuesContainerMap.get).call.apply(t,[this.valuesContainerMap].concat(n))}},{key:"has",value:function(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(t=this.valuesContainerMap.has).call.apply(t,[this.valuesContainerMap].concat(n))}},{key:"keys",value:function(){return this.valuesContainerMap.keys.call(this.valuesContainerMap)}},{key:"set",value:function(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(t=this.valuesContainerMap.set).call.apply(t,[this.valuesContainerMap].concat(n))}},{key:"values",value:function(){return this.valuesContainerMap.values.call(this.valuesContainerMap)}},{key:"size",get:function(){return this.valuesContainerMap.size}}])&&K(e.prototype,n),r&&K(e,r),t}();function et(t){return(et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function nt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function rt(t,e){return!e||"object"!==et(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function ot(t,e,n){return(ot="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=it(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function it(t){return(it=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function at(t,e){return(at=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var ut=function(t){function e(t,n,r,o,i){var a;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(a=rt(this,it(e).call(this,n,o,void 0))).propName=r,a.dirty=!1,a.added=new Set,a.removed=new Set,a.hasUnloadedData=!0===o||void 0===o,a.api=i,a.parentModel=t,a}var n,r,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&at(t,e)}(e,tt),n=e,o=[{key:"create",value:function(t,n,r,o){return new e(t,n,r,o,a.a.getApi())}}],(r=[{key:"add",value:function(t){return this.valuesContainerMap.has(t.id)?this:(ot(it(e.prototype),"add",this).call(this,t),this.removed.has(t.id)?this.removed.delete(t.id):this.added.add(t.id),this.updateDirty(),this)}},{key:"remove",value:function(t){return tt.throwIfContainsOtherThanModelObjects([t]),tt.throwIfContainsModelWithoutUid([t]),this.delete(t.id)&&(this.added.has(t.id)?this.added.delete(t.id):this.removed.add(t.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:"isDirty",value:function(){return!(arguments.length>0&&void 0!==arguments[0])||arguments[0]?this.dirty||this.toArray().filter(function(t){return t&&!0===t.isDirty()}).length>0:this.dirty}},{key:"save",value:function(){var t=this;if(!this.isDirty())return Promise.resolve({});var e=[this.parentModel.href,this.modelDefinition.plural].join("/"),n={additions:Array.from(this.added).map(function(t){return{id:t}}),deletions:Array.from(this.removed).map(function(t){return{id:t}})};return this.api.post(e,n).then(function(){return t.resetDirtyState(),Promise.resolve({})}).catch(function(t){return Promise.reject("Failed to alter collection:",t)})}},{key:"load",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.hasUnloadedData&&!n)return Promise.resolve(this);var r=[this.parentModel.modelDefinition.apiEndpoint,this.parentModel.id].join("/"),o=Object.assign({paging:!1},t,{fields:"".concat(this.propName,"[").concat(t&&t.fields||":all","]")});return this.api.get(r,o).then(function(t){return t[e.propName]}).then(function(t){return Array.isArray(t)&&(e.valuesContainerMap.clear(),t.forEach(function(t){return e.valuesContainerMap.set(t.id,e.modelDefinition.create(t))})),e.hasUnloadedData=!1,Promise.resolve(e)})}}])&&nt(n.prototype,r),o&&nt(n,o),e}(),st=function(){return["TEXT","NUMBER","INTEGER","BOOLEAN","EMAIL","PASSWORD","URL","PHONENUMBER","GEOLOCATION","COLOR","COMPLEX","COLLECTION","REFERENCE","DATE","COMPLEX","IDENTIFIER","CONSTANT"]},ct={getTypes:st,typeLookup:function(t){if(["TEXT","NUMBER","INTEGER","BOOLEAN","EMAIL","PASSWORD","URL","PHONENUMBER","GEOLOCATION","COLOR","COMPLEX","COLLECTION","REFERENCE","DATE","COMPLEX","IDENTIFIER","CONSTANT"].indexOf(t)>=0&&Object(i.n)(t))return t;var e=['Type from schema "',t,'" not found available type list.'].join("");return Object(r.i)(e)}};function lt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var ft={equals:"eq",like:"like",ilike:"ilike",notEqual:"ne",in:"in",token:"token",notIn:"!in",nToken:"!token"},pt=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.addFilterCallback=e,this.propertyName="name",this.comparator="like",this.filterValue=void 0}var e,n,r;return e=t,r=[{key:"getFilter",value:function(e){return new t(e)}}],(n=[{key:"on",value:function(t){return Object(i.b)(t,"Property name to filter on"),this.propertyName=t,this}},{key:"getQueryParamFormat",value:function(){return[this.propertyName,this.comparator,this.filterValue].join(":")}},{key:"operator",value:function(t,e){return Object(i.b)(t,"operator"),Object(i.b)(e,"filterValue"),this.comparator=t,this.filterValue=e,this.addFilterCallback(this)}}])&&lt(e.prototype,n),r&&lt(e,r),t}();Object.keys(ft).forEach(function(t){Object.defineProperty(pt.prototype,t,{value:function(e){return Object(i.b)(e,"filterValue"),this.comparator=ft[t],this.filterValue=[ft.in,ft.notIn].includes(this.comparator)?"[".concat(e.join(","),"]"):e,this.addFilterCallback(this)}})});var ht=pt;function yt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var dt=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.filters=n,this.modelDefinition=e,this.rootJunction=null}var e,n,o;return e=t,o=[{key:"getFilters",value:function(e){return new t(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[])}}],(n=[{key:"on",value:function(t){var e=this.add.bind(this);return ht.getFilter(e).on(t)}},{key:"add",value:function(t){if(!Object(i.o)(t,ht))throw new TypeError("filter should be an instance of Filter");return this.filters.push(t),this.modelDefinition}},{key:"list",value:function(){return this.modelDefinition.list()}},{key:"getQueryFilterValues",value:function(){return this.filters.map(function(t){return t.getQueryParamFormat()})}},{key:"getFilters",value:function(){return this.getQueryFilterValues()}},{key:"getFilterList",value:function(){return this.filters.map(r.f)}},{key:"logicMode",value:function(t){return Object(i.d)(t),this.rootJunction=t,this}}])&&yt(e.prototype,n),o&&yt(e,o),t}(),vt=new Map([["organisationUnitGroupSet",{dataDimension:!0}],["category",{dataDimension:!0}],["categoryOptionGroupSet",{dataDimension:!0}],["dataElement",{aggregationType:"SUM",valueType:"NUMBER"}],["dataElementGroupSet",{dataDimension:!0}],["dataSet",{expiryDays:0,openFuturePeriods:0,timelyDays:15,periodType:"Monthly"}],["externalMapLayer",{mapService:"WMS",imageFormat:"PNG",mapLayerPosition:"BASEMAP"}],["validationNotificationTemplate",{notificationRecipient:"ORGANISATION_UNIT_CONTACT",deliveryChannels:[],notifyUsersInHierarchyOnly:!1}],["validationRule",{importance:"MEDIUM",periodType:"Monthly",operator:"not_equal_to",leftSide:{missingValueStrategy:"NEVER_SKIP",description:"",expression:""},rightSide:{missingValueStrategy:"NEVER_SKIP",description:"",expression:""}}],["program",{version:0,completeEventsExpiryDays:0,expiryDays:0}],["programNotificationTemplate",{notificationTrigger:"COMPLETION",notificationRecipient:"USERS_AT_ORGANISATION_UNIT"}]]);var bt=["apiEndpoint","name","displayName","authorities","singular","plural","shareable","metadata","klass","identifiableObject","translatable"].concat("properties[".concat(["href","writable","collection","collectionName","name","propertyType","persisted","required","min","max","ordered","unique","constants","owner","itemPropertyType","translationKey","embeddedObject"].join(","),"]")).join(",");function mt(t){return(mt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function gt(t,e){return!e||"object"!==mt(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function wt(t,e,n){return(wt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Ot(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function Ot(t){return(Ot=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function jt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Et(t,e)}function Et(t,e){return(Et=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function kt(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function Pt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function St(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function _t(t,e,n){return e&&St(t.prototype,e),n&&St(t,n),t}function At(t,e){var n=e.collection?e.collectionName:e.name,r={configurable:!1,enumerable:!0,get:function(){return this.dataValues[n]}};e.constants&&(r.constants=e.constants),e.writable&&(r.set=function(t){(!Object(i.m)(t)&&t!==this.dataValues[n]||Object(i.m)(t))&&(this.dirty=!0,this[R].add(n),this.dataValues[n]=t)}),n&&(t[n]=r)}function Tt(t,e){var n=e.collection?e.collectionName:e.name,r={persisted:e.persisted,type:ct.typeLookup(e.propertyType),required:e.required,min:e.min,max:e.max,owner:e.owner,unique:e.unique,writable:e.writable,ordered:Boolean(e.ordered),embeddedObject:Boolean(e.embeddedObject)};("REFERENCE"===r.type||"COLLECTION"===r.type&&"REFERENCE"===e.itemPropertyType)&&(r.referenceType=function(t){if(t.href)return t.href.split("/").pop()}(e)),n&&(t[n]=r)}function xt(t,e){return function(n){return t&&e&&t.modelDefinition&&t.modelDefinition.modelValidations&&t.modelDefinition.modelValidations[n]&&"COLLECTION"===t.modelDefinition.modelValidations[n].type&&e.hasOwnProperty(t.modelDefinition.modelValidations[n].referenceType)}}var Ct=new WeakMap,Dt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,o=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,u=arguments.length>4?arguments[4]:void 0;Pt(this,t),Object(i.c)(e.singular,"string"),Object(i.c)(e.plural,"string","Plural"),Object(r.b)(this,"name",e.singular),Object(r.b)(this,"displayName",e.displayName),Object(r.b)(this,"plural",e.plural),Object(r.b)(this,"isShareable",e.shareable||!1),Object(r.b)(this,"isMetaData",e.metadata||!1),Object(r.b)(this,"apiEndpoint",e.apiEndpoint),Object(r.b)(this,"javaClass",e.klass),Object(r.b)(this,"identifiableObject",e&&e.identifiableObject),Object(r.b)(this,"modelProperties",n),Object(r.b)(this,"modelValidations",o),Object(r.b)(this,"attributeProperties",a),Object(r.b)(this,"authorities",u),Object(r.b)(this,"translatable",e.translatable||!1),this.filters=dt.getFilters(this),Ct.set(this,(e.properties||[]).filter(function(t){return t.translationKey}).map(function(t){return{name:t.name,translationKey:t.translationKey}})),this.getOwnedPropertyJSON=p.bind(this)}return _t(t,[{key:"filter",value:function(){return this.clone().filters}},{key:"create",value:function(t){var e,n=G.create(this),r=J.getModelDefinitions(),o=t?Object.assign({},t):(e=n.modelDefinition.name,vt.has(e)?vt.get(e):{});return Object.keys(n).filter(xt(n,r)).forEach(function(t){var e=n.modelDefinition.modelValidations[t].referenceType,i=[];Array.isArray(o[t])?i=o[t].map(function(t){return r[e].create(t)}):!0!==o[t]&&void 0!==o[t]||(i=o[t]),o[t]=ut.create(n,r[e],t,i),n.dataValues[t]=o[t]}),Object.keys(n).filter(function(t){return!xt(n,r)(t)}).forEach(function(t){n.dataValues[t]=o[t]}),n}},{key:"clone",value:function(){var t=Object.getPrototypeOf(this),e=this.filters.getFilterList(),n=Object(r.c)(Object.create(t),this);return n.filters=dt.getFilters(n,e),n}},{key:"get",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{fields:":all,attributeValues[:all,attribute[id,name,displayName]]"};return Object(i.b)(t,"Identifier"),Array.isArray(t)?this.list({filter:["id:in:[".concat(t.join(","),"]")]}):this.api.get([this.apiEndpoint,t].join("/"),n).then(function(t){return e.create(t)}).catch(function(t){return t.message?Promise.reject(t.message):Promise.reject(t)})}},{key:"list",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.apiEndpoint,r=kt(e,["apiEndpoint"]),o=this.filters.rootJunction?{rootJunction:this.filters.rootJunction}:{},a=Object.assign({fields:":all"},o,r),u=this.filters.getQueryFilterValues();return Object(i.i)(a.filter)||(delete a.filter,u.length&&(a.filter=u)),this.api.get(n||this.apiEndpoint,a).then(function(e){return tt.create(t,e[t.plural].map(function(e){return t.create(e)}),Object.assign(e.pager||{},{query:a}))})}},{key:"save",value:function(t){if(Boolean(t.id)){var e=p.bind(this)(t),n=t.dataValues.href?Object(r.j)(t.dataValues.href,this.api.baseUrl):[t.modelDefinition.apiEndpoint,t.dataValues.id].join("/");return this.api.update(n,e,!0)}return this.saveNew(t)}},{key:"saveNew",value:function(t){var e=p.bind(this)(t);return this.api.post(this.apiEndpoint,e)}},{key:"getOwnedPropertyNames",value:function(){var t=this;return Object.keys(this.modelValidations).filter(function(e){return t.modelValidations[e].owner})}},{key:"delete",value:function(t){return t.dataValues.href?this.api.delete(t.dataValues.href):this.api.delete([t.modelDefinition.apiEndpoint,t.dataValues.id].join("/"))}},{key:"isTranslatable",value:function(){return this.translatable}},{key:"getTranslatableProperties",value:function(){return Ct.get(this).map(Object(r.g)("name"))}},{key:"getTranslatablePropertiesWithKeys",value:function(){return Ct.get(this)}}],[{key:"createFromSchema",value:function(e){var n,o,a,u,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return Object(i.c)(e,Object,"Schema"),n="function"==typeof t.specialClasses[e.singular]?t.specialClasses[e.singular]:t,Object.freeze(new n(e,Object.freeze((o=e.properties,a={},u=Object(r.d)(At,a),(o||[]).forEach(u),a)),Object.freeze(function(t){var e={},n=Object(r.d)(Tt,e);return(t||[]).forEach(n),e}(e.properties)),s.reduce(function(t,e){return t[e.name]=e,t},{}),e.authorities))}}]),t}(),Rt=function(t){function e(){return Pt(this,e),gt(this,Ot(e).apply(this,arguments))}return jt(e,Dt),_t(e,[{key:"get",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{fields:":all,userCredentials[:owner]"};return wt(Ot(e.prototype),"get",this).call(this,t,n)}}]),e}(),Nt=function(t){function e(){return Pt(this,e),gt(this,Ot(e).apply(this,arguments))}return jt(e,Dt),_t(e,[{key:"create",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=Boolean(Object.keys(t).length),r=Object.keys(t).filter(function(t){return"compulsoryDataElementOperands"!==t}).reduce(function(e,n){return e[n]=t[n],e},{}),o=wt(Ot(e.prototype),"create",this).call(this,n?r:void 0);return o.dataValues.compulsoryDataElementOperands=t.compulsoryDataElementOperands,o}}]),e}(),Ut=function(t){function e(){return Pt(this,e),gt(this,Ot(e).apply(this,arguments))}return jt(e,Dt),_t(e,[{key:"list",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.root,r=kt(t,["root"]);return t.hasOwnProperty("root")&&n&&(r.apiEndpoint="".concat(this.apiEndpoint,"/").concat(n)),wt(Ot(e.prototype),"list",this).call(this,r)}}]),e}();Dt.specialClasses={user:Rt,dataSet:Nt,organisationUnit:Ut};var It=Dt,Mt={ModelBase:N,Model:G,ModelDefinition:It,ModelDefinitions:J,ModelValidation:d},Vt=n(20);function Lt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function Ft(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var Bt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.a.getApi();!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sources=e,this.api=n,this.strings=new Set,this.translations=void 0}var e,n,r;return e=t,r=[{key:"getI18n",value:function(){return new t}}],(n=[{key:"addSource",value:function(t){this.sources.push(t)}},{key:"addStrings",value:function(t){var e=this;"string"==typeof t&&t.trim().length>0?this.strings.add(t.trim()):Array.from(t).filter(function(t){return t&&"".concat(t).trim().length>0}).forEach(function(t){return e.strings.add(t)})}},{key:"load",value:function(){var t=this,e=this;e.translations={};var n=[];return this.sources.forEach(function(t){n.push(e.api.request("GET",t).then(function(t){return Promise.resolve(t.split("\n").reduce(function(t,e){var n=Lt(e.split("=").map(function(t){return t.trim()}),2),r=n[0],o=n[1];return void 0===r||void 0===o||t.hasOwnProperty(r)||(t[r]=o.replace(/\\u([0-9a-f]{4})/gi,function(t,e){return String.fromCharCode(parseInt(e,16))})),t},{}))},function(){return Promise.resolve({})}))}),Promise.all(n).then(function(n){return n.forEach(function(n){Object.keys(n).forEach(function(r){e.translations.hasOwnProperty(r)||(e.translations[r]=n[r]),t.strings.delete(r)})}),t.strings.size>0?e.api.post("i18n",Array.from(e.strings)).then(function(t){return Object.keys(t).filter(function(e){return e!==t[e]}).forEach(function(n){e.translations[n]=t[n],e.strings.delete(n)}),Promise.resolve(e.translations)}):Promise.resolve(e.translations)})}},{key:"getTranslation",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0===this.translations)throw new Error("Tried to translate before loading translations!");var n=this.translations.hasOwnProperty(t)?this.translations[t]:"** ".concat(t," **");return Object.keys(e).length?n.replace(/\$\$(.+?)\$\$/gi,function(t,n){return e[n]||""}):n}},{key:"isTranslated",value:function(t){if(void 0===this.translations)throw new Error("Tried to translate before loading translations!");return this.translations.hasOwnProperty(t)}},{key:"getUntranslatedStrings",value:function(){return this.translations?Array.from(this.strings):void 0}}])&&Ft(e.prototype,n),r&&Ft(e,r),t}(),qt=new Set(["categoryOptionCombo"]),Ht={baseUrl:"/api",i18n:{sources:new Set,strings:new Set}};function Gt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var zt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,n,r;return e=t,r=[{key:"create",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(!e.filter(function(t){return t}).every(function(t){return Object(i.o)(t,"object")}))throw new Error("Expected Config parameter to have type object");return Object.assign.apply(Object,[{},Ht].concat(e))}},{key:"processPreInitConfig",value:function(t,e){t.headers&&e.setDefaultHeaders(t.headers),t.baseUrl&&e.setBaseUrl(t.baseUrl)}},{key:"processConfigForD2",value:function(t,e){var n=e.Api.getApi();e.model.ModelDefinition.prototype.api=n,e.models=e.model.ModelDefinitions.getModelDefinitions(),Object(i.n)(t.baseUrl)?n.setBaseUrl(t.baseUrl):n.setBaseUrl("/api"),t.headers&&n.setDefaultHeaders(t.headers),t.unauthorizedCb&&n.setUnauthorizedCallback(t.unauthorizedCb),t.i18n&&t.i18n.sources&&Array.from(t.i18n.sources).forEach(function(t){return e.i18n.addSource(t)}),t.i18n&&t.i18n.strings&&e.i18n.addStrings(Array.from(t.i18n.strings))}}],(n=null)&&Gt(e.prototype,n),r&&Gt(e,r),t}();function $t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var Jt=Symbol("authorities"),Wt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this[Jt]=new Set(e)}var e,n,r;return e=t,r=[{key:"create",value:function(e){return new t(e)}}],(n=[{key:"has",value:function(t){return!!this[Jt].has("ALL")||this[Jt].has(t)}}])&&$t(e.prototype,n),r&&$t(e,r),t}();function Xt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var Kt=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.a.getApi();!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.api=n,e&&(this.settings=e)}var e,n,r;return e=t,(n=[{key:"all",value:function(){var t=this;return this.settings?Promise.resolve(this.settings):this.api.get("userSettings").then(function(e){return t.settings=e,Promise.resolve(t.settings)})}},{key:"get",value:function(t){var e=this;if(this.settings&&this.settings[t])return Promise.resolve(this.settings[t]);return new Promise(function(n,r){if(!Object(i.n)(t))throw new TypeError('A "key" parameter should be specified when calling get() on userSettings');e.api.get(["userSettings",t].join("/")).then(function(o){var i=function(t){try{return JSON.parse(t)}catch(e){return t}}(o);e[t]=i,i&&n(i),r(new Error("The requested userSetting has no value or does not exist."))})})}},{key:"set",value:function(t,e){delete this.settings;var n=["userSettings",t].join("/");return null===e||0==="".concat(e).length?this.api.delete(n):this.api.post(n,e,{headers:{"Content-Type":"text/plain"}})}}])&&Xt(e.prototype,n),r&&Xt(e,r),t}();function Yt(t){return(Yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Qt(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function Zt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var te=function(){function t(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a.a.getApi(),o=arguments.length>3?arguments[3]:void 0;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!Object(i.n)(e))throw new Error("BaseStoreNamespace must be called with a string to identify the Namespace");if(!Object(i.n)(o))throw new Error("BaseStoreNamespace must be called with an endPoint");if(this.constructor===t)throw new Error("Can't instantiate abstract class!");this.api=r,this.namespace=e,this.keys=n||[],this.endPoint=o}var e,n,r;return e=t,(n=[{key:"getKeys",value:function(){var t=this;return this.api.get([this.endPoint,this.namespace].join("/")).then(function(e){return e&&Object(i.h)(e)?(t.keys=e,e):Promise.reject(new Error("The requested namespace has no keys or does not exist."))})}},{key:"get",value:function(t){return this.api.get([this.endPoint,this.namespace,t].join("/"))}},{key:"set",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!r&&this.keys.includes(t))return this.update(t,e);var i=!0===o?"?encrypt=true":"";return this.api.post([this.endPoint,this.namespace,t+i].join("/"),e).then(function(e){return n.keys=[].concat(Qt(n.keys),[t]),e})}},{key:"delete",value:function(t){var e=this;return Object(i.n)(t)?this.api.delete([this.endPoint,this.namespace,t].join("/")).then(function(n){return e.keys=e.keys.filter(function(e){return e!==t}),n}):Promise.reject(new Error("Expected key to be string, but got ".concat(Yt(t))))}},{key:"update",value:function(t,e){return this.api.update([this.endPoint,this.namespace,t].join("/"),e,!1,{headers:{"Content-Type":"application/json"}})}}])&&Zt(e.prototype,n),r&&Zt(e,r),t}();function ee(t){return(ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ne(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var re=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a.a.getApi(),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"dataStore",r=arguments.length>2?arguments[2]:void 0;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.constructor===t)throw new Error("Can't instantiate abstract class!");if(!(r.prototype instanceof te))throw new Error("NamespaceClass must be subclass of ".concat(ee(te)));this.NamespaceClass=r,this.endPoint=n,this.api=e}var e,n,r;return e=t,(n=[{key:"get",value:function(t){var e=this;return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?this.api.get([this.endPoint,t].join("/")).then(function(n){return n&&Object(i.h)(n)?n.length<1?Promise.reject(new Error("The requested namespace has no keys or does not exist.")):new e.NamespaceClass(t,n):Promise.reject(new Error("The requested namespace has no keys or does not exist."))}):new Promise(function(n){n(new e.NamespaceClass(t))})}},{key:"getAll",value:function(){return this.api.get(this.endPoint).then(function(t){if(t&&Object(i.h)(t))return t;throw new Error("No namespaces exist.")})}},{key:"has",value:function(t){return this.api.get([this.endPoint,t].join("/")).then(function(t){return t&&Object(i.h)(t)?!(t.length<1)||Promise.reject(t):Promise.reject(new Error("Response is not an array!"))}).catch(function(t){if(404===t.httpStatusCode||Object(i.h)(t)&&t.length<1)return Promise.resolve(!1);throw t})}},{key:"delete",value:function(t){return this.api.delete([this.endPoint,t].join("/"))}},{key:"create",value:function(t){var e=this;return this.has(t).then(function(n){return n?Promise.reject(new Error("Namespace already exists.")):new e.NamespaceClass(t)})}}])&&ne(e.prototype,n),r&&ne(e,r),t}();function oe(t){return(oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ie(t,e){return!e||"object"!==oe(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function ae(t){return(ae=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function ue(t,e){return(ue=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var se=function(t){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a.a.getApi(),o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"userDataStore";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),ie(this,ae(e).call(this,t,n,r,o))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ue(t,e)}(e,te),e}();function ce(t){return(ce="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function le(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function fe(t,e){return!e||"object"!==ce(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function pe(t,e,n){return(pe="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=he(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function he(t){return(he=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function ye(t,e){return(ye=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var de=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a.a.getApi(),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"userDataStore";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),fe(this,he(e).call(this,t,n,se))}var n,r,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ye(t,e)}(e,re),n=e,o=[{key:"getUserDataStore",value:function(){return e.getUserDataStore.dataStore||(e.getUserDataStore.dataStore=new e(a.a.getApi(),"userDataStore")),e.getUserDataStore.dataStore}}],(r=[{key:"get",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return pe(he(e.prototype),"get",this).call(this,t,n)}},{key:"create",value:function(t){return pe(he(e.prototype),"create",this).call(this,t)}}])&&le(n.prototype,r),o&&le(n,o),e}();function ve(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var be=Symbol("models"),me=new Set(["userCredentials","userGroups","userRoles","organisationUnits","dataViewOrganisationUnits"]),ge=["CREATE","CREATE_PUBLIC","CREATE_PRIVATE"],we=["CREATE_PUBLIC"],Oe=["CREATE_PRIVATE"],je=["DELETE"],Ee=["UPDATE"],ke=Array.from(me).reduce(function(t,e){return t[e]=Symbol(e),t},{});var Pe=function(){function t(e,n,r,o){var i,a;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,(a=(i=e).userCredentials?Object.assign({},i.userCredentials,i):Object.assign({},i),Object.keys(a).reduce(function(t,e){return me.has(e)?a[e].map&&(t[ke[e]]=a[e].map(function(t){return t.id})):t[e]=a[e],t},{}))),this.authorities=n,this[be]=r,this.userSettings=o,this.dataStore=de.getUserDataStore()}var e,n,r;return e=t,r=[{key:"create",value:function(e,n,r,o){return new t(e,Wt.create(n),r,new Kt(o))}}],(n=[{key:"getUserGroupIds",value:function(){return this[ke.userGroups]}},{key:"getUserGroups",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this[ke.userGroups];return this[be].userGroup.list(Object.assign({paging:!1},t,{filter:["id:in:[".concat(e.join(","),"]")]}))}},{key:"getUserRoles",value:function(){var t=this[ke.userRoles];return this[be].userRole.list({filter:["id:in:[".concat(t.join(","),"]")],paging:!1})}},{key:"getOrganisationUnits",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this[ke.organisationUnits];return this[be].organisationUnit.list(Object.assign({fields:":all,displayName,path,children[id,displayName,path,children::isNotEmpty]",paging:!1},t,{filter:["id:in:[".concat(e.join(","),"]")]}))}},{key:"getDataViewOrganisationUnits",value:function(t){var e=this[ke.dataViewOrganisationUnits];return this[be].organisationUnit.list(Object.assign({fields:":all,displayName,path,children[id,displayName,path,children::isNotEmpty]",paging:!1},t,{filter:["id:in:[".concat(e.join(","),"]")]}))}},{key:"checkAuthorityForType",value:function(t,e){var n=this;return!(!e||!Array.isArray(e.authorities))&&e.authorities.filter(function(e){return t.some(function(t){return t===e.type})}).some(function(t){return t.authorities.some(function(t){return n.authorities.has(t)})})}},{key:"checkCreateAuthorityForType",value:function(t,e){return!function(t){return Boolean(t&&qt.has(t.name))}(e)&&this.checkAuthorityForType(t,e)}},{key:"canCreate",value:function(t){return this.checkCreateAuthorityForType(ge,t)}},{key:"canCreatePublic",value:function(t){return this.checkCreateAuthorityForType(we,t)}},{key:"canCreatePrivate",value:function(t){return this.checkCreateAuthorityForType(Oe,t)}},{key:"canDelete",value:function(t){return this.checkAuthorityForType(je,t)}},{key:"canUpdate",value:function(t){return!!this.checkAuthorityForType(Ee,t)||this.checkAuthorityForType(ge,t)}}])&&ve(e.prototype,n),r&&ve(e,r),t}();function Se(t){return(Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _e(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Ae(t,e){return!e||"object"!==Se(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function Te(t){return(Te=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function xe(t,e){return(xe=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var Ce=function(t){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a.a.getApi(),o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"dataStore";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Ae(this,Te(e).call(this,t,n,r,o))}var n,r,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&xe(t,e)}(e,te),n=e,(r=[{key:"getMetaData",value:function(t){return this.api.get([this.endPoint,this.namespace,t,"metaData"].join("/"))}}])&&_e(n.prototype,r),o&&_e(n,o),e}();function De(t){return(De="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Re(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Ne(t,e){return!e||"object"!==De(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function Ue(t,e,n){return(Ue="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Ie(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function Ie(t){return(Ie=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Me(t,e){return(Me=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var Ve=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a.a.getApi(),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"dataStore";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Ne(this,Ie(e).call(this,t,n,Ce))}var n,r,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Me(t,e)}(e,re),n=e,o=[{key:"getDataStore",value:function(){return e.getDataStore.dataStore||(e.getDataStore.dataStore=new e),e.getDataStore.dataStore}}],(r=[{key:"get",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Ue(Ie(e.prototype),"get",this).call(this,t,n)}},{key:"create",value:function(t){return Ue(Ie(e.prototype),"create",this).call(this,t)}}])&&Re(n.prototype,r),o&&Re(n,o),e}();function Le(t){return(Le="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Fe(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function Be(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function qe(t,e){return!e||"object"!==Le(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function He(t){return(He=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Ge(t,e){return(Ge=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var ze=function(t){return function(e){function n(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),qe(this,He(n).apply(this,arguments))}var r,o,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ge(t,e)}(n,t),r=n,(o=[{key:"addDataDimension",value:function(t){return this.addDimension("dx",t)}},{key:"addPeriodDimension",value:function(t){return this.addDimension("pe",t)}},{key:"addOrgUnitDimension",value:function(t){return this.addDimension("ou",t)}},{key:"addDimension",value:function(t,e){var n=0,r=this.dimensions.find(function(e,r){return e.dimension===t&&(n=r,e)}),o=[],i=[];return r&&(i=r.items||[]),"string"==typeof e?o=Fe(new Set([].concat(Fe(i),[e]))):Array.isArray(e)&&(o=Fe(new Set([].concat(Fe(i),Fe(e))))),r?this.dimensions.splice(n,1,{dimension:t,items:o}):this.dimensions.push({dimension:t,items:o}),new bn(this)}}])&&Be(r.prototype,o),i&&Be(r,i),n}()};function $e(t){return($e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Je(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function We(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Xe(t,e){return!e||"object"!==$e(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function Ke(t){return(Ke=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Ye(t,e){return(Ye=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var Qe=function(t){return function(e){function n(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),Xe(this,Ke(n).apply(this,arguments))}var r,o,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ye(t,e)}(n,t),r=n,(o=[{key:"addDataFilter",value:function(t){return this.addFilter("dx",t)}},{key:"addPeriodFilter",value:function(t){return this.addFilter("pe",t)}},{key:"addOrgUnitFilter",value:function(t){return this.addFilter("ou",t)}},{key:"addFilter",value:function(t,e){var n=0,r=this.filters.find(function(e,r){return e.dimension===t&&(n=r,e)}),o=[],i=[];return r&&(i=r.items||[]),"string"==typeof e?o=Je(new Set([].concat(Je(i),[e]))):Array.isArray(e)&&(o=Je(new Set([].concat(Je(i),Je(e))))),r?this.filters.splice(n,1,{dimension:t,items:o}):this.filters.push({dimension:t,items:o}),new bn(this)}}])&&We(r.prototype,o),i&&We(r,i),n}()};function Ze(t){return(Ze="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function tn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function en(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function nn(t,e){return!e||"object"!==Ze(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function rn(t){return(rn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function on(t,e){return(on=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var an=function(t){return function(e){function n(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),nn(this,rn(n).apply(this,arguments))}var r,o,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&on(t,e)}(n,t),r=n,(o=[{key:"withParameters",value:function(t){return t&&(this.parameters=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(e){tn(t,e,n[e])})}return t}({},this.parameters,t)),new bn(this)}},{key:"withPath",value:function(t){return t&&(this.path=t),new bn(this)}},{key:"withFormat",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"json";return this.format=t,new bn(this)}},{key:"withAggregationType",value:function(t){var e=t.toUpperCase();return new Set(["AVERAGE","AVERAGE_SUM_ORG_UNIT","COUNT","LAST","LAST_AVERAGE_ORG_UNIT","MIN","MAX","STDDEV","SUM","VARIANCE"]).has(e)?this.parameters.aggregationType=e:"DEFAULT"!==e&&(console.warn('d2.analytics.request.withAggregationType(): "'.concat(t,'" not listed as possible value')),this.parameters.aggregationType=t),new bn(this)}},{key:"withMeasureCriteria",value:function(t){return t&&(this.parameters.measureCriteria=t),new bn(this)}},{key:"withPreAggregationMeasureCriteria",value:function(t){return t&&(this.parameters.preAggregationMeasureCriteria=t),new bn(this)}},{key:"withSkipMeta",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.skipMeta=t,new bn(this)}},{key:"withSkipData",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.skipData=t,new bn(this)}},{key:"withHierarchyMeta",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.hierarchyMeta=t,new bn(this)}},{key:"withIgnoreLimit",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.ignoreLimit=t,new bn(this)}},{key:"withTableLayout",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.tableLayout=t,new bn(this)}},{key:"withHideEmptyRows",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.hideEmptyRows=t,new bn(this)}},{key:"withHideEmptyColumns",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.hideEmptyColumns=t,new bn(this)}},{key:"withShowHierarchy",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.showHierarchy=t,new bn(this)}},{key:"withIncludeNumDen",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.includeNumDen=t,new bn(this)}},{key:"withIncludeMetadataDetails",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.includeMetadataDetails=t,new bn(this)}},{key:"withDisplayProperty",value:function(t){var e=t.toUpperCase();return new Set(["NAME","SHORTNAME"]).has(e)?this.parameters.displayProperty=e:(console.warn('d2.analytics.request.withDisplayProperty(): "'.concat(t,'" not listed as possible value')),this.parameters.displayProperty=t),new bn(this)}},{key:"withOutputIdScheme",value:function(t){return t&&(this.parameters.outputIdScheme=t),new bn(this)}},{key:"withInputIdScheme",value:function(t){return t&&(this.parameters.inputIdScheme=t),new bn(this)}},{key:"withApprovalLevel",value:function(t){return t&&(this.parameters.approvalLevel=t),new bn(this)}},{key:"withRelativePeriodDate",value:function(t){return t&&(this.parameters.relativePeriodDate=t),new bn(this)}},{key:"withUserOrgUnit",value:function(t){return t&&(this.parameters.userOrgUnit=t),new bn(this)}},{key:"withColumns",value:function(t){return t&&(this.parameters.columns=t),new bn(this)}},{key:"withRows",value:function(t){return t&&(this.parameters.rows=t),new bn(this)}},{key:"withStartDate",value:function(t){return t&&(this.parameters.startDate=t),new bn(this)}},{key:"withEndDate",value:function(t){return t&&(this.parameters.endDate=t),new bn(this)}},{key:"withProgram",value:function(t){return t&&(this.program=t),new bn(this)}},{key:"withStage",value:function(t){return t&&(this.parameters.stage=t),new bn(this)}},{key:"withEventStatus",value:function(t){var e=t.toUpperCase();return new Set(["ACTIVE","COMPLETED","SCHEDULED","OVERDUE","SKIPPED"]).has(e)?this.parameters.eventStatus=e:(console.warn('d2.analytics.request.withEventStatus(): "'.concat(t,'" not listed as possible value')),this.parameters.eventStatus=t),new bn(this)}},{key:"withProgramStatus",value:function(t){var e=t.toUpperCase();return new Set(["ACTIVE","COMPLETED","CANCELLED"]).has(e)?this.parameters.programStatus=e:(console.warn('d2.analytics.request.withProgramStatus(): "'.concat(t,'" not listed as possible value')),this.parameters.programStatus=t),new bn(this)}},{key:"withOuMode",value:function(t){var e=t.toUpperCase();return new Set(["DESCENDANTS","CHILDREN","SELECTED"]).has(e)?this.parameters.ouMode=e:(console.warn('d2.analytics.request.withOuMode(): "'.concat(t,'" not listed as possible value')),this.parameters.ouMode=t),new bn(this)}},{key:"withAsc",value:function(t){return t&&(this.parameters.asc=t),new bn(this)}},{key:"withDesc",value:function(t){return t&&(this.parameters.desc=t),new bn(this)}},{key:"withCoordinatesOnly",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.coordinatesOnly=t,new bn(this)}},{key:"withPage",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.parameters.page=t,new bn(this)}},{key:"withPageSize",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50;return this.parameters.pageSize=t,new bn(this)}},{key:"withValue",value:function(t){return t&&(this.parameters.value=t),new bn(this)}},{key:"withSortOrder",value:function(t){var e=t.toUpperCase();return new Set(["ASC","DESC"]).has(e)?this.parameters.sortOrder=e:(console.warn('d2.analytics.request.withSortOrder(): "'.concat(t,'" not listed as possible value')),this.parameters.sortOrder=t),new bn(this)}},{key:"withLimit",value:function(t){if(t){var e=t>1e4?1e4:t;this.parameters.limit=e}return new bn(this)}},{key:"withOutputType",value:function(t){var e=t.toUpperCase();return new Set(["EVENT","ENROLLMENT","TRACKED_ENTITY_INSTANCE"]).has(e)?this.parameters.outputType=e:(console.warn('d2.analytics.request.withOutputType(): "'.concat(t,'" not listed as possible value')),this.parameters.outputType=t),new bn(this)}},{key:"withCollapseDataDimensions",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.collapseDataDimensions=t,new bn(this)}},{key:"withSkipRounding",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.skipRounding=t,new bn(this)}},{key:"withAggregateData",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.aggregateData=t,new bn(this)}},{key:"withClusterSize",value:function(t){return t&&(this.parameters.clusterSize=t),new bn(this)}},{key:"withCoordinateField",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"EVENT";return this.parameters.coordinateField=t,new bn(this)}},{key:"withBbox",value:function(t){return t&&(this.parameters.bbox=t),new bn(this)}},{key:"withIncludeClusterPoints",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.parameters.includeClusterPoints=t,new bn(this)}}])&&en(r.prototype,o),i&&en(r,i),n}()},un=n(9),sn=n.n(un);function cn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ln(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var fn=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.endPoint,r=void 0===n?"analytics":n,o=e.format,i=void 0===o?"json":o,a=e.path,u=e.program,s=e.dimensions,c=void 0===s?[]:s,l=e.filters,f=void 0===l?[]:l,p=e.parameters,h=void 0===p?{}:p;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.endPoint=r,this.format=i.toLowerCase(),this.path=a,this.program=u,this.dimensions=c,this.filters=f,this.parameters=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(e){cn(t,e,n[e])})}return t}({},h)}var e,n,r;return e=t,(n=[{key:"buildUrl",value:function(t){var e=this.dimensions;t&&t.sorted&&(e=sn()(e,"dimension"));var n=e.map(function(e){var n=e.dimension,r=e.items;return Array.isArray(r)&&r.length?(t&&t.sorted&&(r=sn()(r)),"".concat(n,":").concat(r.join(";"))):n}),r=[this.endPoint,this.path,this.program].filter(function(t){return!!t}).join("/");return"".concat(r,".").concat(this.format,"?dimension=").concat(n.join("&dimension="))}},{key:"buildQuery",value:function(t){var e=this.filters;t&&t.sorted&&(e=sn()(e,"dimension"));var n=e.map(function(e){var n=e.dimension,r=e.items;return Array.isArray(r)&&r.length?(t&&t.sorted&&(r=sn()(r)),"".concat(n,":").concat(r.join(";"))):n});return e.length&&(this.parameters.filter=n),this.parameters}}])&&ln(e.prototype,n),r&&ln(e,r),t}();function pn(t){return(pn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function hn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function yn(t,e){return!e||"object"!==pn(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function dn(t){return(dn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function vn(t,e){return(vn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var bn=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),yn(this,dn(e).apply(this,arguments))}var n,r,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&vn(t,e)}(e,ze(Qe(an(fn)))),n=e,(r=[{key:"fromModel",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this,r=t.columns||[],o=t.rows||[];r.concat(o).forEach(function(t){var e=t.dimension;t.filter&&(e+=":".concat(t.filter)),n=n.addDimension(e,t.items.map(function(t){return t.id}))});var i=t.filters||[],a=["dx","ou","pe"];return i.forEach(function(t){n=e&&a.includes(t.dimension)?n.addDimension(t.dimension,t.items.map(function(t){return t.id})):n.addFilter(t.dimension,t.items.map(function(t){return t.id}))}),n}}])&&hn(n.prototype,r),o&&hn(n,o),e}();function mn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var wn=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a.a.getApi();!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.api=e}var e,n,r;return e=t,(n=[{key:"get",value:function(t){var e=new bn(t).withSkipMeta(!1).withSkipData(!0).withIncludeMetadataDetails(!0),n=new bn(t).withSkipData(!1).withSkipMeta(!0);return Promise.all([this.fetch(n,{sorted:!0}),this.fetch(e)]).then(function(t){return Promise.resolve(function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(e){mn(t,e,n[e])})}return t}({},t[0],{metaData:t[1].metaData}))})}},{key:"fetch",value:function(t,e){return this.api.get(t.buildUrl(e),t.buildQuery(e)).then(function(t){return Promise.resolve(t)})}}])&&gn(e.prototype,n),r&&gn(e,r),t}();function On(t){return(On="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function jn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function En(t,e){return!e||"object"!==On(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function kn(t){return(kn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Pn(t,e){return(Pn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var Sn=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),En(this,kn(e).apply(this,arguments))}var n,r,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Pn(t,e)}(e,wn),n=e,(r=[{key:"getDataValueSet",value:function(t){return this.fetch(t.withPath("dataValueSet"))}},{key:"getRawData",value:function(t){return this.fetch(t.withPath("rawData"))}},{key:"getDebugSql",value:function(t){return this.fetch(t.withPath("debug/sql"))}}])&&jn(n.prototype,r),o&&jn(n,o),e}();function _n(t){return(_n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function An(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Tn(t,e){return!e||"object"!==_n(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function xn(t){return(xn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Cn(t,e){return(Cn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var Dn=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Tn(this,xn(e).apply(this,arguments))}var n,r,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Cn(t,e)}(e,wn),n=e,(r=[{key:"getAggregate",value:function(t){return this.fetch(t.withPath("events/aggregate"))}},{key:"getCount",value:function(t){return this.fetch(t.withPath("events/count"))}},{key:"getCluster",value:function(t){return this.fetch(t.withPath("events/cluster"))}},{key:"getQuery",value:function(t){return this.fetch(t.withPath("events/query"))}}])&&An(n.prototype,r),o&&An(n,o),e}();function Rn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var Nn=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{isPrefix:!1,isCollect:!1,index:void 0};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,e,n)}var e,n,r;return e=t,(n=[{key:"getIndex",value:function(){return this.index}},{key:"setIndex",value:function(t){var e=+t;!Number.isNaN(e)&&Number.isFinite(e)&&(this.index=parseInt(e,10))}}])&&Rn(e.prototype,n),r&&Rn(e,r),t}();function Un(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function In(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var Mn={0:"No",1:"Yes"},Vn=["psi","ps","eventdate","longitude","latitude","ouname","oucode","eventdate","eventdate"],Ln=["dy"].concat(Vn),Fn=function(t){switch(t){case"STRING":case"TEXT":return function(t){return"".concat(t)};case"INTEGER":case"NUMBER":return function(t){return!Number.isNaN(+t)&&Number.isFinite(+t)?parseFloat(+t):t};default:return function(t){return t}}},Bn=function(t,e){return!Ln.includes(t.name)&&Boolean(Array.isArray(e)&&0===e.length)},qn=function(t,e){return!Vn.includes(t.name)&&Boolean(Array.isArray(e)&&0===e.length)},Hn=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e&&(this.response=e,this.headers=this.extractHeaders(),this.rows=this.extractRows(),this.metaData=this.extractMetadata())}var e,n,r;return e=t,(n=[{key:"extractHeaders",value:function(){var t=this.response.metaData.dimensions;return(this.response.headers||[]).map(function(e,n){return new Nn(e,{isPrefix:Bn(e,t[e.name]),isCollect:qn(e,t[e.name]),index:n})})}},{key:"extractRows",value:function(){var t=this.headers.filter(function(t){return t.optionSet}),e=this.response.rows;if(t.length){e=e.slice();var n=this.optionCodeIdMap();t.forEach(function(t){e.forEach(function(r,o){var i=n[t.name][r[t.index]];i&&(e[o][t.index]=i)})})}return e}},{key:"extractMetadata",value:function(){var t=this,e=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(e){Un(t,e,n[e])})}return t}({},this.response.metaData),n=e.dimensions,r=e.items;if(this.headers.filter(function(t){return!Vn.includes(t.name)}).forEach(function(e){var o;e.isCollect?(o=t.getSortedUniqueRowIdStringsByHeader(e),n[e.name]=o):o=n[e.name],e.isPrefix&&(n[e.name]=o.map(function(t){return function(t,e){return"".concat(e||""," ").concat(t)}(t,e.name)}),n[e.name].forEach(function(t,n){var i=function(t,e){return"BOOLEAN"===e?Mn[t]:t}(o[n],e.valueType);r[t]={name:i}}))}),this.hasHeader("ouname")&&this.hasHeader("ou")){var o,i,a=this.getHeader("ouname").getIndex(),u=this.getHeader("ou").getIndex();this.rows.forEach(function(t){o=t[u],void 0===r[o]&&(i=t[a],r[o]={name:i})})}return e}},{key:"getHeader",value:function(t){return this.headers.find(function(e){return e.name===t})}},{key:"hasHeader",value:function(t){return void 0!==this.getHeader(t)}},{key:"getSortedUniqueRowIdStringsByHeader",value:function(t){var e=Fn(t.valueType),n=Fn("STRING");return Array.from(new Set(this.rows.map(function(n){return e(n[t.index])}))).filter(function(t){return""!==t}).sort().map(function(t){return n(t)})}},{key:"optionCodeIdMap",value:function(){var t=this.response.metaData,e=t.dimensions,n=t.items,r={};return this.headers.filter(function(t){return"string"==typeof t.optionSet}).forEach(function(t){var o=e[t.name];r[t.name]=o.map(function(t){return Un({},n[t].code,t)}).reduce(function(t,e){return Object.assign(t,e)},{})}),r}},{key:"sortOrganisationUnitsHierarchy",value:function(){var t=this,e=this.metaData.dimensions.ou;e.forEach(function(n,r){var o=t.metaData.ouHierarchy[n],i=[n],a=[];o.split("/").reverse().forEach(function(t){i.unshift(t)}),i.forEach(function(e){t.metaData.items[e]&&a.push(t.metaData.items[e].name)}),e[r]={id:n,fullName:a.join(" / ")}}),e.sort(function(t,e){var n=t.fullName,r=e.fullName;return n<r?-1:n>r?1:0}),this.metaData.dimensions.ou=e.map(function(t){return t.id})}}])&&In(e.prototype,n),r&&In(e,r),t}();function Gn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var zn=function(){function t(e,n,r,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.aggregate=e,this.events=n,this.request=r,this.response=o}var e,n,r;return e=t,r=[{key:"getAnalytics",value:function(){return t.getAnalytics.analytics||(t.getAnalytics.analytics=new t(new Sn,new Dn,bn,Hn)),t.getAnalytics.analytics}}],(n=null)&&Gn(e.prototype,n),r&&Gn(e,r),t}();function $n(t,e,n){return($n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&Jn(o,n.prototype),o}).apply(null,arguments)}function Jn(t,e){return(Jn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Wn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Xn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Kn=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.orgUnits=e,this.displayName=n}var e,n,r;return e=t,r=[{key:"isValidOrgUnit",value:function(e){return w(e)||t.isValidOrgUnitLevel(e)||t.isValidOrgUnitGroup(e)||t.isValidUserOrgUnit(e)}},{key:"isValidOrgUnitLevel",value:function(t){var e=t.match(/LEVEL-(.*)$/);return Array.isArray(e)&&(/^[0-9]+$/.test(e[1])||w(e[1]))}},{key:"isValidOrgUnitGroup",value:function(t){var e=t.match(/OU_GROUP-(.*)$/);return Array.isArray(e)&&w(e[1])}},{key:"isValidUserOrgUnit",value:function(e){return e===t.USER_ORGUNIT||e===t.USER_ORGUNIT_CHILDREN||e===t.USER_ORGUNIT_GRANDCHILDREN}},{key:"isValidDisplayName",value:function(e){return e===t.DISPLAY_PROPERTY_NAME||e===t.DISPLAY_PROPERTY_SHORTNAME}},{key:"getGeoFeatures",value:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return $n(t,n)}}],(n=[{key:"byOrgUnit",value:function(e){if(!e)return this;var n=[].concat(e);if(!n.every(t.isValidOrgUnit))throw new Error("Invalid organisation unit: ".concat(e));return new t(n,this.displayName)}},{key:"displayProperty",value:function(e){if(!e)return this;if(!t.isValidDisplayName(e))throw new Error("Invalid display property: ".concat(e));return new t(this.orgUnits,e)}},{key:"getAll",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=a.a.getApi(),n=t;return this.orgUnits.length&&(n.ou="ou:".concat(this.orgUnits.join(";"))),this.displayName&&(n.displayProperty=this.displayName),e.get("geoFeatures",n)}}])&&Wn(e.prototype,n),r&&Wn(e,r),t}();Xn(Kn,"DISPLAY_PROPERTY_NAME","NAME"),Xn(Kn,"DISPLAY_PROPERTY_SHORTNAME","SHORTNAME"),Xn(Kn,"USER_ORGUNIT","USER_ORGUNIT"),Xn(Kn,"USER_ORGUNIT_CHILDREN","USER_ORGUNIT_CHILDREN"),Xn(Kn,"USER_ORGUNIT_GRANDCHILDREN","USER_ORGUNIT_GRANDCHILDREN");var Yn=Kn;function Qn(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}n.d(e,"getManifest",function(){return nr}),n.d(e,"getUserSettings",function(){return rr}),n.d(e,"init",function(){return or}),n.d(e,"getInstance",function(){return ir}),n.d(e,"setInstance",function(){return ar}),n.d(e,"config",function(){return ur});var Zn=!0,tr=r.a.create(),er=zt.create();function nr(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.a).getApi();e.setBaseUrl("");var n={getBaseUrl:function(){return this.activities.dhis.href}};return e.get("".concat(t)).then(function(t){return Object.assign({},t,n)})}function rr(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:a.a).getApi();return Zn&&zt.processPreInitConfig(er,t),t.get("userSettings")}function or(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.a,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o.a.getLogger(),i=e.getApi(),u=zt.create(er,t),s={models:void 0,model:Mt,Api:e,system:Vt.a.getSystem(),i18n:Bt.getI18n(),dataStore:Ve.getDataStore(),analytics:zn.getAnalytics(),geoFeatures:Yn.getGeoFeatures()};zt.processConfigForD2(u,s),Zn?Zn=!1:tr=r.a.create();var c=function(t,e){var n=[];if(Array.isArray(e)){var r=e.map(function(e){return t.get("schemas/".concat(e),{fields:bt})}).concat([]),o=Promise.all(r).then(function(t){return{schemas:t}});n.push(o),e.length>0?n.push(t.get("attributes",{fields:":all,optionSet[:all,options[:all]]",paging:!1})):n.push({attributes:[]})}else n.push(t.get("schemas",{fields:bt})),n.push(t.get("attributes",{fields:":all,optionSet[:all,options[:all]]",paging:!1}));return n}(i,u.schemas),l=[i.get("me",{fields:":all,organisationUnits[id],userGroups[id],userCredentials[:all,!user,userRoles[id]"}),i.get("me/authorization"),rr(e)],f=[i.get("system/info"),i.get("apps")];return Promise.all([].concat(Qn(c),l,f,[s.i18n.load()])).then(function(t){var e={schemas:Object(r.g)("schemas")(t[0]),attributes:Object(r.g)("attributes")(t[1]),currentUser:t[2],authorities:t[3],userSettings:t[4],systemInfo:t[5],apps:t[6]};return e.schemas.filter(function(t){return t.metadata}).map(function(t){return t.apiEndpoint=Object(r.j)(t.apiEndpoint,u.baseUrl),t}).forEach(function(t){var n=e.attributes.filter(function(e){return!0===e[[t.singular,"Attribute"].join("")]});Object.prototype.hasOwnProperty.call(s.models,t.singular)||s.models.add(Mt.ModelDefinition.createFromSchema(t,n))}),s.currentUser=Pe.create(e.currentUser,e.authorities,s.models,e.userSettings),s.system.setSystemInfo(e.systemInfo),s.system.setInstalledApps(e.apps),tr.resolve(s),tr.promise}).catch(function(t){return n.error("Unable to get schemas from the api",JSON.stringify(t),t),tr.reject("Unable to get schemas from the DHIS2 API"),tr.promise})}function ir(){return tr.promise}function ar(t){tr.resolve(t)}var ur=er}])});
//# sourceMappingURL=d2-browser.min.js.map