-
Notifications
You must be signed in to change notification settings - Fork 1
/
import.mjs
2 lines (2 loc) · 21.1 KB
/
import.mjs
1
2
// jsonstat-euro v2.1.1 Copyright 2023 Xavier Badosa https://jsonstat.com
var e="2.1.1";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e){var n=e.lang||"en",r=e.version||"1.0",i=e.dataset||null,l=e.filter||null,a=e.label||null,s={class:"query",lang:n,version:r,dataset:i};return l&&"object"===t(l)&&0!==Object.keys(l).length&&(Object.keys(l).forEach((function(e){var t=l[e];Array.isArray(t)||(l[e]=[t]),0===l[e].length&&delete l[e]})),s.filter=l),a&&"object"===t(a)&&0!==Object.keys(a).length&&(s.label=a),s}function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function i(e,t,i,l){var a,s=JSON.parse(JSON.stringify(e));if("string"==typeof l&&s.filter.hasOwnProperty("geo")&&-1!==s.filter.geo.indexOf(l)||(l=null),r(s,"filter")){switch(i){case"last":a=function(e){s.filter[e]=s.filter[e].slice(-1)};break;case"middle":a=function(e){var t=Math.round(s.filter[e].length/2);s.filter[e]=s.filter[e].slice(t-1,t)};break;default:a=function(e){s.filter[e]=s.filter[e].slice(0,1)}}Object.keys(s.filter).forEach(a),!0===t&&(delete s.filter.time,s.filter.lastTimePeriod=["1"]),l&&(s.filter.geo=[l])}return r(s,"label")&&r(s.label,"category")&&(Object.keys(s.label.category).forEach((function(e){s.label.category[e]=s.label.category[e].slice(0,1)})),!0===t&&delete s.label.category.time),n(s)}function l(e){var t=JSON.parse(JSON.stringify(e));return r(t,"filter")?(delete t.filter.time,t.filter.lastTimePeriod=["1"]):t.filter={lastTimePeriod:["1"]},n(t)}function a(e,t,i){void 0===i&&(i=Object.keys(t),t=n({dataset:null,filter:t}));var l=JSON.parse(JSON.stringify(e)),a=r(t,"filter"),s=r(t,"label")&&r(t.label,"category");return i.forEach((function(e){a&&r(t.filter,e)&&(r(l,"filter")||(l.filter={}),l.filter[e]=t.filter[e]),s&&r(t.label.category,e)&&(r(l,"label")?r(l.label,"category")||(l.label.category={}):l.label={},l.label.category[e]=t.label.category[e])})),n(l)}function s(e,t){var i=JSON.parse(JSON.stringify(e)),l=r(i,"filter"),a=r(i,"label"),s=a&&r(i.label,"category"),o=a&&r(i.label,"dimension");return t.forEach((function(e){l&&delete i.filter[e],a&&(s&&delete i.label.category[e],o&&delete i.label.dimension[e])})),n(i)}function o(e){return s(e,["time","lastTimePeriod","sinceTimePeriod"])}function u(e,t){var n,r,i,l,a=function(e,t,n){var r,i=[];if(n&&!c(n.name)&&(n=null),"string"==typeof e&&(e=[e]),Array.isArray(e)||f(e)){if(e.length===t)return n&&-1===e.findIndex((function(e){return null==e}))?n.from(e):e;if(1===e.length){for(r=0;r<t;r++)i.push(e[0]);return i}}for(r=0;r<t;r++){var l=void 0===e[r]?null:e[r];i.push(l)}return i};if(this.length=0,this.id=[],null!=e)switch(this.class=e.class||"bundle",this.class){case"bundle":var s=[],o=0;if(this.error=null,this.length=0,null===e||"object"!=typeof e)return void(this.class=null);if(e.hasOwnProperty("error"))return void(this.error=e.error);if("dataset"===e.class||"collection"===e.class||"dimension"===e.class)return new u(e);for(r in e)o++,s.push(r);this.__tree__=e,this.length=o,this.id=s;break;case"dataset":e.hasOwnProperty("__tree__")?this.__tree__=n=e.__tree__:this.__tree__=n=e,this.label=n.label||null,this.note=n.note||null,this.link=n.link||null,this.href=n.href||null,this.updated=n.updated||null,this.source=n.source||null,this.extension=n.extension||null;var h,d=0,y=n.size||n.dimension&&n.dimension.size;if(this.size=y,this.value=n.hasOwnProperty("value")&&null!==n.value&&0!==n.value.length?n.value:{},Array.isArray(this.value)||f(this.value))d=this.value.length;else{var v=1;for(h=y.length;h--;)v*=y[h];d=v}if(this.value=a(this.value,d,t),this.status=n.hasOwnProperty("status")?a(n.status,d):null,n.hasOwnProperty("dimension")){var p=n.dimension,g=n.role||!n.version&&p.role||null,b=n.id||p.id,m=y.length,_=function(e){g.hasOwnProperty(e)||(g[e]=null)};if(!Array.isArray(b)||!Array.isArray(y)||b.length!=m)return;if(this.length=m,this.id=b,g&&(_("time"),_("geo"),_("metric"),_("classification")),g&&null===g.classification){var O=[],x=["time","geo","metric"],w=function(e,t){for(var n=t.length;n--;)if(e===t[n])return!0;return!1};for(h=0;h<3;h++){var j=g[x[h]];null!==j&&(O=O.concat(j))}for(g.classification=[],h=0;h<m;h++)w(b[h],O)||g.classification.push(b[h]);0===g.classification.length&&(g.classification=null)}this.role=g,this.n=d;for(var A=0,k=this.length;A<k;A++)if(p[b[A]].category.hasOwnProperty("index")){if(Array.isArray(p[b[A]].category.index)){var E={},P=p[b[A]].category.index;for(i=P.length,l=0;l<i;l++)E[P[l]]=l;p[b[A]].category.index=E}}else{var D=0;for(r in p[b[A]].category.index={},p[b[A]].category.label)p[b[A]].category.index[r]=D++}}else this.length=0;break;case"dimension":if(!e.hasOwnProperty("__tree__"))return new u({version:"2.0",class:"dataset",dimension:{d:e},id:["d"],size:[function(e){var t=void 0===e.index?e.label:e.index;return Array.isArray(t)?t.length:Object.keys(t).length}(e.category)],value:[null]}).Dimension(0);var S=[],z=(n=e.__tree__).category;if(!n.hasOwnProperty("category"))return;if(!z.hasOwnProperty("label"))for(r in z.label={},z.index)z.label[r]=r;for(r in z.index)S[z.index[r]]=r;this.__tree__=n,this.label=n.label||null,this.note=n.note||null,this.link=n.link||null,this.href=n.href||null,this.id=S,this.length=S.length,this.role=e.role,this.hierarchy=z.hasOwnProperty("child"),this.extension=n.extension||null;break;case"category":var N=e.child;this.id=N,this.length=null===N?0:N.length,this.index=e.index,this.label=e.label,this.note=e.note||null,this.unit=e.unit,this.coordinates=e.coord;break;case"collection":if(this.length=0,this.label=e.label||null,this.note=e.note||null,this.link=e.link||null,this.href=e.href||null,this.updated=e.updated||null,this.source=e.source||null,this.extension=e.extension||null,null!==this.link&&e.link.item){var J=e.link.item;if(this.length=Array.isArray(J)?J.length:0,this.length)for(l=0;l<this.length;l++)this.id[l]=J[l].href}}}function f(e){return"[object ArrayBuffer]"===Object.prototype.toString.call(e.buffer)}function c(e){return-1!==["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].indexOf(e)}function h(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);return e.json()}function d(e,t,n){var r="object"==typeof t?t:null;return"function"!=typeof n&&(n=null),n||"function"!=typeof t||(n=t),"object"==typeof e?new u(e,n):"version"===e?"1.4.2":fetch?fetch(e,r).then(h).then((function(e){return new u(e,n)})):void 0}function y(e){if("string"==typeof e){if(/https?:\/\//i.test(e))return e;e={dataset:e}}if("object"===t(e)&&null!==e&&!Array.isArray(e)&&e.dataset){e=n(e);var r="".concat("https://ec.europa.eu/eurostat/api/dissemination/statistics/").concat(e.version,"/data/").concat(e.dataset,"?lang=").concat(e.lang),i=[],l=e.filter||null;return l&&0!==Object.keys(l).length&&(Object.keys(l).forEach((function(e){l[e].forEach((function(t){i.push("".concat(e,"=").concat(t))}))})),r+="&"+i.join("&")),r}return null}function v(e){e.role={geo:[],time:[],metric:[],classification:[]},e.id.forEach((function(t){switch(e.Dimension(t).role="time"===t||"geo"===t?t:"classification",t){case"geo":case"time":e.role[t].push(t);break;case"unit":case"s_adj":case"indic_co":case"na_item":case"indic":e.role.metric.push(t);break;default:e.role.classification.push(t)}})),e.role.geo.length||delete e.role.geo,e.role.time.length||delete e.role.time,e.role.metric.length||delete e.role.metric,e.role.classification.length||delete e.role.classification}function p(e){if(e)return d(y(e)).then((function(e){return"dataset"===e.class?(v(e),e):e}),(function(e){var t=e.message.slice(0,3),n=isNaN(t)?"418":t;return{class:"error",status:n,label:"418"!==n?e.message.slice(4):e.message}}))}function g(e,t){"string"==typeof e&&(e={dataset:e});var n=!1!==t?l(e):e;return p(n).then((function(e){if("error"===e.class)return e;if(e.error)return{class:"error",status:e.error.status,label:e.error.label};var t={},r={},i={};return e.id.forEach((function(n){var l=e.Dimension(n);r[n]=l.label,t[n]=l.id,i[n]=l.Category().map((function(e){return e.label}))})),{class:"query",dataset:n.dataset,filter:t,label:{dataset:e.label,dimension:r,category:i},lang:n.lang||"en",version:n.version||"1.0"}}))}function b(e,t,n,l){"string"==typeof e&&(e={dataset:e}),"boolean"!=typeof t&&(t=!1),"string"!=typeof n&&(n="first"),"string"!=typeof l&&(l=null);var o=r(e,"filter")?e.filter:null;if(o&&0!==Object.keys(o).length){var u=Object.keys(o);return g(a(e,o),!1).then((function(e){return"error"===e.class?e:g(s(i(e,t,n,l),u),!1).then((function(t){return"error"===t.class?t:a(e,t,u)}))}))}return g(e,!1).then((function(e){return e}))}function m(e,t){function n(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);return e.json()}if(e){if("string"==typeof e){if(/https?:\/\//i.test(e))return new Promise((function(e){e({class:"error",status:400,label:"A URL was passed to fetchEmptyDataset. Only dataset codes and queries are accepted. "})}));e={dataset:e}}return e.filter={time_period:["null"]},fetch(y(e)).then(n).then((function(r){var i=d(r),l=r.id.indexOf("time"),a={};return i.id.forEach((function(e){"time"!==e&&(a[e]=[i.Dimension(e).id[0]])})),r.value=[],e.filter=a,fetch(y(e)).then(n).then((function(e){if(r.size[l]=e.size[l],r.dimension.time.category=e.dimension.time.category,t){var n=d(r);return"dataset"===n.class?(v(n),n):n}return r}))}),(function(e){var t=e.message.slice(0,3),n=isNaN(t)?"418":t;return{class:"error",status:n,label:"418"!==n?e.message.slice(4):e.message}}))}}function _(e,t){return e.extension.status.label[t]}function O(e){var t=r(e,"lang")?e.lang:"en",n=r(e,"dataset")?e.dataset:null,i={lang:t.toUpperCase(),datasetId:n},l=Object.keys(e.filter),a=l.map((function(t){return e.filter[t].length})),s={};l.forEach((function(t){s[t]={label:e.label.dimension[t],category:{index:e.filter[t],label:{}}},e.filter[t].forEach((function(n,r){Object.defineProperty(s[t].category.label,n,{value:e.label.category[t][r]})}))}));var o=d({version:"2.0",class:"dataset",label:e.label.dataset,extension:i,id:l,size:a,dimension:s,value:[]});return v(o),o}u.prototype.Item=function(e){if(null===this||"collection"!==this.class||!this.length)return null;if("number"==typeof e)return e>this.length||e<0?null:this.link.item[e];var t,n=[];if("object"==typeof e){if(!e.class&&!e.follow)return null;e.class&&(t="dataset"===e.class&&"boolean"==typeof e.embedded?!0===e.embedded?function(e,t,r){var i=e.link.item[t];r.class===i.class&&i.id&&i.size&&i.dimension&&n.push(i)}:function(e,t,r){var i=e.link.item[t];r.class!==i.class||i.id&&i.size&&i.dimension||n.push(i)}:function(e,t,r){r.class===e.link.item[t].class&&n.push(e.link.item[t])})}else t=function(e,t){n.push(e.link.item[t])};for(var r=0;r<this.length;r++)t(this,r,e);return n},u.prototype.Dataset=function(e){if(null===this)return null;if("dataset"===this.class)return void 0!==e?this:[this];var t,n=[],r=0;if("collection"===this.class){var i=this.Item({class:"dataset",embedded:!0});if(void 0===e){for(t=i.length;r<t;r++)n.push(new u(i[r]));return n}if("number"==typeof e&&e>=0&&e<i.length)return new u(i[e]);if("string"==typeof e)for(t=i.length;r<t;r++)if(i[r].href===e)return new u(i[r]);return null}if("bundle"!==this.class)return null;if(void 0===e){for(t=this.id.length;r<t;r++)n.push(this.Dataset(this.id[r]));return n}if("number"==typeof e){var l=this.id[e];return void 0!==l?this.Dataset(l):null}var a=this.__tree__[e];return void 0===a?null:new u({class:"dataset",__tree__:a})},u.prototype.Dimension=function(e,t){t="boolean"!=typeof t||t;var n,r=[],i=this.id.length,l=function(e,t){if(null!==e)for(var n in e)for(var r=null!==e[n]?e[n].length:0;r--;)if(e[n][r]===t)return n;return null};if(null===this||"dataset"!==this.class)return null;if(void 0===e){for(n=0;n<i;n++)r.push(this.Dimension(this.id[n]));return r}if("number"==typeof e){var a=this.id[e];return void 0!==a?this.Dimension(a,t):null}var s=this.role;if("object"==typeof e){if(e.hasOwnProperty("role")){for(n=0;n<i;n++){var o=this.id[n];l(s,o)===e.role&&r.push(this.Dimension(o,t))}return void 0===r[0]?null:r}return null}var f=this.__tree__.dimension;if(void 0===f)return null;var c=f[e];return void 0===c?null:t?new u({class:"dimension",__tree__:c,role:l(s,e)}):function(e,t){var n=[];for(var r in e)n[e[r]]=t[r];return n}(c.category.index,c.category.label)},u.prototype.Category=function(e){if(null===this||"dimension"!==this.class)return null;if(void 0===e){for(var t=[],n=0,r=this.id.length;n<r;n++)t.push(this.Category(this.id[n]));return t}if("number"==typeof e){var i=this.id[e];return void 0!==i?this.Category(i):null}var l=this.__tree__.category;if(void 0===l)return null;var a=l.index[e];if(void 0===a)return null;var s=l.unit&&l.unit[e]||null,o=l.coordinates&&l.coordinates[e]||null,f=l.child&&l.child[e]||null,c=l.note&&l.note[e]||null;return new u({class:"category",index:a,label:l.label[e],note:c,child:f,unit:s,coord:o})},u.prototype.Dice=function(e,t,n){var r,i,l,a,s=function(e,t){return e.hasOwnProperty(t)&&!!e[t]};if(null===this||"dataset"!==this.class)return null;if("object"!=typeof e)return this;"object"!=typeof t?("boolean"==typeof t&&!0===t&&(r=!0),"boolean"==typeof n&&!0===n||(n=!1)):(r=s(t,"clone"),n=s(t,"drop"),i=s(t,"stringify"),l=s(t,"ovalue"),a=s(t,"ostatus"));var o,c=this.value,h=r?new u(JSON.parse(JSON.stringify(this))):this,d=h.status,y=[],v=[],p=function(e,t){var n,r,i,l=(n=e,r=t,i={},Array.isArray(n[r])?(n[r].forEach((function(e,t){null!==e&&(i[String(t)]=e)})),i):n[r]);delete e[t],e[t]=l};Array.isArray(e)&&(e=function(e){var t={};return e.forEach((function(e){t[e[0]]=e[1]})),t}(e)),null===e&&(e={});var g=Object.keys(e);return g.length>0&&(g.forEach((function(t){var n=e[t];Array.isArray(n)||(e[t]=[n]),0===e[t].length&&delete e[t]})),n&&(e=function(e){var t={};return Object.keys(e).forEach((function(n){t[n]=h.Dimension(n).id.filter((function(t){return-1===e[n].indexOf(t)}))})),t}(e)),h.toTable({type:"arrobj",content:"id",status:!0}).forEach((function(t,n){var r=[];g.forEach((function(n){var i=e[n],l=[];i.forEach((function(e){l.push(t[n]===e)})),r.push(-1!==l.indexOf(!0))})),-1===r.indexOf(!1)&&(y.push(t.value),v.push(t.status))})),g.forEach((function(t){var n=h.Dimension(t).id,r=0,i={};h.size[h.id.indexOf(t)]=e[t].length,n.forEach((function(n){-1!==e[t].indexOf(n)&&(i[n]=r,r++)})),h.__tree__.dimension[t].category.index=i})),h.n=y.length,h.value=h.__tree__.value=f(c)?function(e,t){return t.from(e)}(y,c.constructor):y,h.status=h.__tree__.status=null!==d?v:null),i?((o=h.__tree__).hasOwnProperty("id")||(o.version="2.0",o.hasOwnProperty("class")||(o.class="dataset"),o.id=o.dimension.id,o.size=o.dimension.size,delete o.dimension.id,delete o.dimension.size,o.dimension.hasOwnProperty("role")&&(o.role=o.dimension.role,delete o.dimension.role)),o.hasOwnProperty("status")&&-1!==["null","{}","[]"].indexOf(JSON.stringify(o.status))&&delete o.status,o.hasOwnProperty("role")&&(delete o.role.classification,["geo","time","metric"].forEach((function(e){null===o.role[e]&&delete o.role[e]}))),l&&p(o,"value"),a&&o.hasOwnProperty("status")&&p(o,"status"),JSON.stringify(o)):h},u.prototype.Slice=function(e){if(null===this||"dataset"!==this.class)return null;if(void 0===e)return this;if(!Array.isArray(e)){var t,n=[];for(t in e)n.push([t,e[t]]);e=n}return this.Dice(e.map((function(e){return[e[0],[e[1]]]})))},u.prototype.Data=function(e,t){var n,r,i=[],l=function(e){for(var t in e)if(e.hasOwnProperty(t))return t};if(null===this||"dataset"!==this.class)return null;if(void 0===e){for(r=this.value.length,n=0;n<r;n++)i.push(this.Data(n));return i}if("boolean"!=typeof t&&(t=!0),"number"==typeof e){var a=this.value[e];return void 0===a?null:t?{value:a,status:this.status?this.status[e]:null}:a}var s="object",o=this.__tree__,u=o.size||o.dimension&&o.dimension.size,f=u.length;if(Array.isArray(e)){if(!Array.isArray(e[0])){if(this.length!==e.length)return null;var c=1,h=0,d=[],y=[];for(n=0;n<f;n++)if(void 0!==e[n]){if("number"!=typeof e[n]||e[n]>=u[n])return null;h+=(c*=n>0?u[f-n]:1)*e[f-n-1]}else d.push(n),y.push(u[n]);if(d.length>1)return null;if(1===d.length){for(var v=0,p=y[0];v<p;v++){var g=[];for(n=0;n<f;n++)n!==d[0]?g.push(e[n]):g.push(v);i.push(this.Data(g,t))}return i}return t?{value:this.value[h],status:this.status?this.status[h]:null}:this.value[h]}s="array"}var b=function(e,t,n){var r,i=[],a={},s=e.dimension,o=e.id||s.id,u=e.size||s&&s.size;if("array"===n){for(r=t.length;r--;)a[t[r][0]]=t[r][1];t=a}for(var f=0,c=o.length;f<c;f++){var h=o[f],d=t[h];i.push("string"==typeof d?d:1===u[f]?l(s[h].category.index):null)}return i}(o,e,s),m=[],_=o.dimension,O=o.id||_.id;for(n=0,r=b.length;n<r;n++)m.push(_[O[n]].category.index[b[n]]);return this.Data(m,t)},u.prototype.toTable=function(e,t){if(null===this||"dataset"!==this.class)return null;1==arguments.length&&"function"==typeof e&&(t=e,e=null),"arrobj"!==(e=e||{field:"label",content:"label",vlabel:"Value",slabel:"Status",type:"array",status:!1,unit:!1,by:null,prefix:"",drop:[],meta:!1,comma:!1,bylabel:!1}).type&&"objarr"!==e.type||void 0!==e.field||(e.field="id");var n,r,i,l,a,s,o,u,f,h="id"===e.field,d=function(e){return(h?"value":e)||"Value"},y=function(e){return(h?"status":e)||"Status"},v=this.__tree__,p=!0===e.status;if("function"==typeof t){n=this.toTable(e);var g=[],b="array"!==e.type?0:1;for(a=(F="object"!==e.type?n.slice(b):n.rows.slice(0)).length,r=0;r<a;r++){var m=t.call(this,F[r],r);void 0!==m&&g.push(m)}return"object"===e.type?{cols:n.cols,rows:g}:("array"===e.type&&g.unshift(n[0]),g)}if("arrobj"===e.type||"objarr"===e.type){var _=[],O=v.role&&v.role.metric,x=function(){},w={},j=this,A=j.id,k=e.by&&-1!==A.indexOf(e.by)?e.by:null,E=!0===e.meta,P=void 0!==e.drop&&Array.isArray(e.drop)?e.drop:[],D=!0===e.comma,S=!0===e.bylabel,z=j.value.constructor,N=function(t){var n,r={},i=d(e.vlabel);return"objarr"===e.type&&(n=null===k&&c(z.name)?function(e){r[e]=e===i?z.from(t,(function(t){return t[e]})):t.map((function(t){return t[e]}))}:function(e){r[e]=t.map((function(t){return t[e]}))},Object.keys(t[0]).forEach(n),t=r),E?(r={},A.forEach((function(e){var t=j.Dimension(e);r[e]={label:t.label,role:t.role,categories:{id:t.id,label:j.Dimension(e,!1)}}})),{meta:{label:j.label,source:j.source,updated:j.updated,id:A,status:p,unit:e.unit,by:k,bylabel:S,drop:null!==k&&P.length>0?P:null,prefix:null!==k?L||"":null,comma:D,dimensions:r},data:t}):t};k&&(e.field="id");var J=(n=this.toTable({field:e.field,vlabel:e.vlabel,slabel:e.slabel,content:e.content,status:p})).shift();if(null===k&&e.unit&&O){if("id"!==e.content)for(var T=O.length;T--;){var C=this.Dimension(O[T]);w[O[T]]={};for(var I=C.length;I--;)w[O[T]][C.Category(I).label]=C.id[I]}x=function(t,n){if(-1!==O.indexOf(t)){var r=v.dimension[t].category;r.unit?U.unit=r.unit["id"!==e.content?w[t][n]:n]:U.unit=null}},e.unit=!0}else e.unit=!1;for(a=n.length,r=0;r<a;r++){var U={};for(i=n[r].length;i--;)U[J[i]]=n[r][i],x(J[i],n[r][i]);_.push(U)}if(D&&_.forEach((function(e){null!==e.value&&(e.value=(""+e.value).replace(".",","))})),null!==k){var q,B={},F=[],V={},L=void 0!==e.prefix?e.prefix:"";P.forEach((function(e,t){(!j.Dimension(e)||j.Dimension(e).length>1)&&(P[t]="")}));var M=A.filter((function(e){return e!==k&&-1===P.indexOf(e)})),R=j.Dimension(k),G=function(e,t){var n=[];return t.forEach((function(t){n.push(e[t])})),n.join("\t")},H=function(e,t){var n={};return t.forEach((function(t){n[t]=e[t]})),n};for(var K in"id"!==e.content?S?q=function(e,t,n){e[t][L+n[k]]=n.value}:(R.Category().forEach((function(e,t){V[e.label]=R.id[t]})),q=function(e,t,n){e[t][L+V[n[k]]]=n.value}):q=function(e,t,n){e[t][L+n[k]]=n.value},_.forEach((function(e){var t=G(e,M);void 0===B[t]&&(B[t]=H(e,M)),q(B,t,e,k)})),B)F.push(B[K]);return p=!1,N(F)}return N(_)}if("object"===e.type){var Q="number"==typeof this.value[0]||null===this.value[0]?"number":"string";s=function(e,t){var n=h&&e||t||e;le.push({id:e,label:n,type:"string"})},o=function(e,t,n){var r=d(e),i=y(t);n&&le.push({id:"status",label:i,type:"string"}),le.push({id:"value",label:r,type:Q})},u=function(e){be.push({v:e})},f=function(e){be.push({v:e}),ae.push({c:be})}}else s=function(e,t){var n=h&&e||t||e;le.push(n)},o=function(e,t,n){var r=d(e),i=y(t);n&&le.push(i),le.push(r),ie.push(le)},u=function(e){be.push(e)},f=function(e){be.push(e),ie.push(be)};var W=v.dimension,X=v.id||W.id,Y=v.size||W.size,Z=X.length;if(Z!=Y.length)return!1;var $=[],ee=1,te=(T=1,[]),ne=[],re=[],ie=[],le=[],ae=[];for(r=0;r<Z;r++){var se=X[r],oe=W[se].label;s(se,oe),ee*=Y[r],T*=Y[r];var ue=[];for(i=0;i<Y[r];i++)for(var fe in W[X[r]].category.index)if(W[X[r]].category.index[fe]===i){var ce="id"!==e.content&&W[X[r]].category.label?W[X[r]].category.label[fe]:fe;ue.push(ce)}$.push(ue),te.push(T)}for(o(e.vlabel,e.slabel,p),a=$.length,r=0;r<a;r++){for(var he=[],de=0,ye=$[r].length;de<ye;de++)for(var ve=0;ve<ee/te[r];ve++)he.push($[r][de]);ne.push(he)}for(a=ne.length,r=0;r<a;r++){var pe=[],ge=0;for(l=0;l<ee;l++)pe.push(ne[r][ge]),++ge===ne[r].length&&(ge=0);re.push(pe)}for(l=0;l<ee;l++){var be=[];a=ne.length;for(var me=0;me<a;me++)u(re[me][l]);p&&u(this.status?this.status[l]:null),f(this.value[l])}return"object"===e.type?{cols:le,rows:ae}:ie},u.prototype.node=function(){return this.__tree__},u.prototype.toString=function(){return this.class};export{a as addParamQuery,p as fetchDataset,m as fetchEmptyDataset,b as fetchFullQuery,g as fetchQuery,O as getEmptyDataset,_ as getStatusLabel,y as getURL,l as lastPeriodQuery,s as removeParamQuery,o as removeTimeQuery,v as setRole,i as simpleQuery,e as version};