UNPKG

vizzu

Version:

Vizzu is a free, open-source Javascript/C++ library utilizing a generic dataviz engine that generates many types of charts and seamlessly animates between them. It can be used to create static charts but more importantly it is designed for building animat

1 lines 61.4 kB
class t extends Error{constructor(t,e){const s=new e.ExceptionInfo(t).get_type(),r=e._vizzu_errorMessage(t,s);super("error: "+e.UTF8ToString(r)),this.name="CError"}}class e{constructor(t,e){this.tt=t,this.et=e}st(t){const e=4*t.length+1,s=this.tt._malloc(e);return this.tt.stringToUTF8(t,s,e),s}rt(t){return this.tt.UTF8ToString(t)}nt(t){const e=this.it(t)();return()=>e}it(e){return(...s)=>{try{return e(...s)}catch(e){throw"number"==typeof e&&Number.isInteger(e)?new t(e,this.tt):e}}}cObjectParams(){return[this.tt,this.et]}}class s extends e{constructor(t,e){super(...e.cObjectParams()),this.getId=t}ot(t){const e=this.ht(t)();return()=>e}ht(t){return super.it(t).bind(this,this.getId())}}class r extends s{constructor(t,e){super(t,e),this.et.register(this.getId)}free(){this.et.unregister(this.getId),this.tt._object_free(this.getId())}}class n extends r{}class i extends s{setParam(t,e=""){const s=this.st(t),r=this.st(e);try{this.ht(this.tt._anim_control_setValue)(s,r)}finally{this.tt._free(r),this.tt._free(s)}}getParam(t){const e=this.st(t);try{const t=this.ht(this.tt._anim_control_getValue)(e);return this.rt(t)}finally{this.tt._free(e)}}storeAnim(){return new n(this.ot(this.tt._chart_anim_store),this)}}class a extends s{constructor(t,e,s){super(()=>e,t),this.stops=this.lt(s)}lt(t){const e=[],s=this.getId();for(let r=0;r<40*t;r+=40)e.push({offset:this.tt.getValue(s+r,"double"),color:"rgba("+255*this.tt.getValue(s+r+8,"double")+","+255*this.tt.getValue(s+r+16,"double")+","+255*this.tt.getValue(s+r+24,"double")+","+this.tt.getValue(s+r+32,"double")+")"});return e}}class o extends r{constructor(t,e){super(e,t)}getColorGradient(t,e){return new a(this,t,e)}getString(t){return this.tt.UTF8ToString(t)}}function h(t,e){if(null===t||"object"!=typeof t)return t;if(t instanceof Function)return t;if(Array.isArray(t)&&t instanceof Array)return t.map(t=>h(t,e));if(e&&t instanceof e)return t;const s={};for(const r in t)r in t&&(s[r]=h(t[r],e));return s}function l(t,e,s=""){if(t&&null!==t&&"object"==typeof t){const r=Array.isArray(t);r&&e(s+".begin",t.length),Object.keys(t).forEach(r=>{const n=s+(0===s.length?"":".")+r,i=t[r];!function(t){return"object"==typeof t&&null!==t}(i)?e(n,i):l(i,e,n)}),r&&e(s+".end",t.length)}}function c(t,e,s){const r=e.split(".");let n=t;r.forEach((t,e)=>{if(!function(t){return"object"==typeof t&&null!==t}(n))throw new Error("Expected an object, but got "+typeof n);e<r.length-1?(n[t]=n[t]||("number"==typeof r[e+1]?[]:{}),n=n[t]):n[t]=s})}class u extends s{constructor(t,e,s,r,n,i){super(t,e),this.ct=s,this.ut=r,this.dt=n,this.ft=i||((t,e)=>e)}set(t){l(t,this.setParam.bind(this))}get(){return function(t,e){const s=t(),r={};for(const t of s)c(r,t,e(t));return Object.freeze(r)}(this.listParams.bind(this),this.getParam.bind(this))}listParams(){const t=this.ht(this.ct)(),e=this.rt(t);return JSON.parse(e)}getParam(t){const e=this.st(t);try{const s=this.ht(this.ut)(e),r=this.rt(s);return this.ft(t,r)}finally{this.tt._free(e)}}setParam(t,e){const s=this.st(t),r=this.st(String(e).toString());try{this.ht(this.dt)(s,r)}finally{this.tt._free(r),this.tt._free(s)}}}class d extends r{}class m extends s{preventDefault(){this.ht(this.tt._event_preventDefault)()}}class f extends u{}class y extends u{}class p extends u{}class g extends r{constructor(t,e){super(e,t),this.config=this.yt(),this.style=this.gt(!1),this.computedStyle=this.gt(!0),this.animOptions=this.wt()}update(t){this.ht(this.tt._vizzu_update)(t)}render(t,e,s){this.vt=t,this.ht(this.tt._vizzu_render)(t.getId(),e,s)}animate(t){const e=this.tt.addFunction(s=>{t(s),this.tt.removeFunction(e)},"vi");this.ht(this.tt._chart_animate)(e)}storeSnapshot(){return new d(this.ot(this.tt._chart_store),this)}restoreSnapshot(t){this.ht(this.tt._chart_restore)(t.getId())}restoreAnim(t){this.ht(this.tt._chart_anim_restore)(t.getId())}setKeyframe(){this.ht(this.tt._chart_setKeyframe)()}addEventListener(t,e){const s=this.tt.addFunction((t,s)=>{const r=new m(()=>t,this);e(r,JSON.parse(this.rt(s)))},"vii"),r=this.st(t);try{this.ht(this.tt._addEventListener)(r,s)}finally{this.tt._free(r)}return s}removeEventListener(t,e){const s=this.st(t);try{this.ht(this.tt._removeEventListener)(s,e)}finally{this.tt._free(s)}this.tt.removeFunction(e)}pointerdown(t,e,s){this.vt&&this.ht(this.tt._vizzu_pointerDown)(this.vt.getId(),t,e,s)}pointermove(t,e,s){this.vt&&this.ht(this.tt._vizzu_pointerMove)(this.vt.getId(),t,e,s)}pointerup(t,e,s){this.vt&&this.ht(this.tt._vizzu_pointerUp)(this.vt.getId(),t,e,s)}pointerleave(t){this.vt&&this.ht(this.tt._vizzu_pointerLeave)(this.vt.getId(),t)}wheel(t){this.vt&&this.ht(this.tt._vizzu_wheel)(this.vt.getId(),t)}getString(t){return this.tt.UTF8ToString(t)}yt(){return new f(this.getId,this,this.tt._chart_getList,this.tt._chart_getValue,this.tt._chart_setValue,(t,e)=>t.startsWith("channels.")&&t.endsWith(".set")?JSON.parse(e):e)}gt(t){return new y(this.getId,this,this.tt._style_getList,(e,s)=>this.tt._style_getValue(e,s,t),this.tt._style_setValue)}wt(){return new p(this.getId,this,()=>0,()=>0,this.tt._anim_setValue)}}class w extends s{toCanvasCoords(t){const e=this.ht(this.tt._chart_relToCanvasCoords)(t.x,t.y);return this.bt(e)}toRelCoords(t){const e=this.ht(this.tt._chart_canvasToRelCoords)(t.x,t.y);return this.bt(e)}bt(t){return{x:this.tt.getValue(t,"double"),y:this.tt.getValue(t+8,"double")}}}class v extends s{constructor(t,e){super(()=>e,t)}getValue(t){const e=this.st(t);let s,r;try{s=this.ht(this.tt._record_getValue)(e),r=this.tt.getValue(s,"i1")?this.rt(this.tt.getValue(s+8,"i8*")):this.tt.getValue(s+8,"double")}finally{this.tt._free(e)}return r}}class b extends s{getMetaInfo(){const t=this.ht(this.tt._data_metaInfo)(),e=this.rt(t);return{series:JSON.parse(e)}}addDimension(t,e,s,r){const n=new Uint32Array(s.length);for(let t=0;t<s.length;t++)n[t]=this.st(s[t]);const i=4*s.length,a=this.tt._malloc(i);new Uint8Array(this.tt.HEAPU8.buffer,a,i).set(new Uint8Array(n.buffer));const o=4*e.length,h=this.tt._malloc(o);new Uint8Array(this.tt.HEAPU8.buffer,h,o).set(new Uint8Array(new Uint32Array(e).buffer));const l=this.st(t);try{this.ht(this.tt._data_addDimension)(l,a,s.length,h,e.length,r)}finally{this.tt._free(l);for(const t of n)this.tt._free(t);this.tt._free(h),this.tt._free(a)}}addMeasure(t,e,s){const r=new Float64Array(s),n=8*s.length,i=this.tt._malloc(n);new Uint8Array(this.tt.HEAPU8.buffer,i,n).set(new Uint8Array(r.buffer));const a=this.st(t),o=this.st(e);try{this.ht(this.tt._data_addMeasure)(a,o,i,s.length)}finally{this.tt._free(a),this.tt._free(o),this.tt._free(i)}}addRecord(t){const e=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const r=this.st(String(t[s]).toString());e[s]=r}const s=4*t.length,r=this.tt._malloc(s);new Uint8Array(this.tt.HEAPU8.buffer,r,s).set(new Uint8Array(e.buffer));try{this.ht(this.tt._data_addRecord)(r,t.length)}finally{for(const t of e)this.tt._free(t);this.tt._free(r)}}setFilter(t){const e=[0,0];if(null!==t){const s=e=>t(new v(this,e));e[0]=this.tt.addFunction(s,"ii");const r=t=>{t!==e[0]&&console.warn("Wrong pointer passed to destructor"),this.tt.removeFunction(e[0]),this.tt.removeFunction(e[1])};e[1]=this.tt.addFunction(r,"vi")}this.ht(this.tt._chart_setFilter)(...e)}}class _{setFont(t){this.canvas&&this.setFontStyle(this.canvas.getString(t))}text(t,e,s,r,n){this.canvas&&this.drawText(t,e,s,r,this.canvas.getString(n))}setBrushGradient(t,e,s,r,n,i){this.canvas&&this.setGradient(t,e,s,r,this.canvas.getColorGradient(i,n))}}class x{constructor(t){this._t=new FinalizationRegistry(e=>{t(e)})}register(t){this._t.register(t,t())}unregister(t){this._t.unregister(t)}}class A extends e{constructor(t){super(t,new x(t._object_free));const e=document.createElement("canvas").getContext("2d");if(!e)throw new Error("Failed to get 2D context");this.tt.measureCanvas=e,this.tt.canvases={},this.tt.charts={},this.setLogging(!1)}registerChart(t,e){this.tt.charts[t.getId()]=e}unregisterChart(t){delete this.tt.charts[t.getId()]}registerRenderer(t,e){this.tt.canvases[t.getId()]=e}unregisterRenderer(t){delete this.tt.canvases[t.getId()]}version(){return this.tt.UTF8ToString(this.tt._vizzu_version())}setLogging(t){this.it(this.tt._vizzu_setLogging)(t)}getData(t){return new b(t.getId,this)}getCoordSystem(t){return new w(t.getId,this)}getAnimControl(t){return new i(t.getId,this)}createChart(){return new g(this,this.nt(this.tt._vizzu_createChart))}createCanvas(){return new o(this,this.nt(this.tt._vizzu_createCanvas))}}var k,S=(k=import.meta.url,function(t={}){var e,s,r,n=t,i=new Promise((t,r)=>{e=t,s=r}),a=Object.assign({},n),o=(t,e)=>{throw e},h="";"undefined"!=typeof document&&document.currentScript&&(h=document.currentScript.src),k&&(h=k),h=h.startsWith("blob:")?"":h.substr(0,h.replace(/[?#].*/,"").lastIndexOf("/")+1),r=async t=>{var e=await fetch(t,{credentials:"same-origin"});if(e.ok)return e.arrayBuffer();throw new Error(e.status+" : "+e.url)};var l,c=console.log.bind(console),u=console.error.bind(console);Object.assign(n,a),a=null;var d,m,f,y,p,g,w,v,b,_=!1;function x(){var t=l.buffer;m=new Int8Array(t),y=new Int16Array(t),n.HEAPU8=f=new Uint8Array(t),p=new Uint16Array(t),g=new Int32Array(t),w=new Uint32Array(t),v=new Float32Array(t),b=new Float64Array(t)}var A=[],S=[],C=[],B=0,E=null;function j(t){u(t="Aborted("+t+")"),_=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw s(e),e}var P,T=t=>t.startsWith("data:application/octet-stream;base64,");function z(){if(n.locateFile){var t="cvizzu.wasm";return T(t)?t:(e=t,n.locateFile?n.locateFile(e,h):h+e)}var e;return new URL("cvizzu.wasm",import.meta.url).href}async function O(t,e){try{var s=await async function(t){try{var e=await r(t);return new Uint8Array(e)}catch{}return function(){throw"both async and sync fetching of the wasm failed"}()}(t);return await WebAssembly.instantiate(s,e)}catch(t){u(`failed to asynchronously prepare wasm: ${t}`),j(t)}}class D{name="ExitStatus";constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var F=t=>{for(;t.length>0;)t.shift()(n)};function W(t,e,s="i8"){switch(s.endsWith("*")&&(s="*"),s){case"i1":case"i8":m[t]=e;break;case"i16":y[t>>1]=e;break;case"i32":g[t>>2]=e;break;case"i64":j("to do setValue(i64) use WASM_BIGINT");case"float":v[t>>2]=e;break;case"double":b[t>>3]=e;break;case"*":w[t>>2]=e;break;default:j(`invalid type for setValue: ${s}`)}}class L{constructor(t){this.excPtr=t,this.ptr=t-24}set_type(t){w[this.ptr+4>>2]=t}get_type(){return w[this.ptr+4>>2]}set_destructor(t){w[this.ptr+8>>2]=t}get_destructor(){return w[this.ptr+8>>2]}set_caught(t){t=t?1:0,m[this.ptr+12]=t}get_caught(){return 0!=m[this.ptr+12]}set_rethrown(t){t=t?1:0,m[this.ptr+13]=t}get_rethrown(){return 0!=m[this.ptr+13]}init(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)}set_adjusted_ptr(t){w[this.ptr+16>>2]=t}get_adjusted_ptr(){return w[this.ptr+16>>2]}}var U,M,I=t=>{for(var e="",s=t;f[s];)e+=U[f[s++]];return e},N={},R={},$=t=>{throw new M(t)};function V(t,e,s={}){return function(t,e,s={}){var r=e.name;if(t||$(`type "${r}" must have a positive integer typeid pointer`),R.hasOwnProperty(t)){if(s.ignoreDuplicateRegistrations)return;$(`Cannot register type '${r}' twice`)}if(R[t]=e,N.hasOwnProperty(t)){var n=N[t];delete N[t],n.forEach(t=>t())}}(t,e,s)}var H=[],G=[],K=()=>G.length/2-5-H.length,q=t=>(t||$("Cannot use deleted val. handle = "+t),G[t]),J=t=>{switch(t){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const e=H.pop()||G.length;return G[e]=t,G[e+1]=1,e}}};function Q(t){return this.fromWireType(w[t>>2])}var Y,X,Z={name:"emscripten::val",fromWireType:t=>{var e=q(t);return(t=>{t>9&&0===--G[t+1]&&(G[t]=void 0,H.push(t))})(t),e},toWireType:(t,e)=>J(e),argPackAdvance:8,readValueFromPointer:Q,destructorFunction:null},tt=(t,e)=>{switch(e){case 4:return function(t){return this.fromWireType(v[t>>2])};case 8:return function(t){return this.fromWireType(b[t>>3])};default:throw new TypeError(`invalid float width (${e}): ${t}`)}},et=(t,e,s)=>{switch(e){case 1:return s?t=>m[t]:t=>f[t];case 2:return s?t=>y[t>>1]:t=>p[t>>1];case 4:return s?t=>g[t>>2]:t=>w[t>>2];default:throw new TypeError(`invalid integer width (${e}): ${t}`)}},st=(t,e,s)=>((t,e,s,r)=>{if(!(r>0))return 0;for(var n=s,i=s+r-1,a=0;a<t.length;++a){var o=t.charCodeAt(a);if(o>=55296&&o<=57343&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++a)),o<=127){if(s>=i)break;e[s++]=o}else if(o<=2047){if(s+1>=i)break;e[s++]=192|o>>6,e[s++]=128|63&o}else if(o<=65535){if(s+2>=i)break;e[s++]=224|o>>12,e[s++]=128|o>>6&63,e[s++]=128|63&o}else{if(s+3>=i)break;e[s++]=240|o>>18,e[s++]=128|o>>12&63,e[s++]=128|o>>6&63,e[s++]=128|63&o}}return e[s]=0,s-n})(t,f,e,s),rt="undefined"!=typeof TextDecoder?new TextDecoder:void 0,nt=(t,e=0,s=NaN)=>{for(var r=e+s,n=e;t[n]&&!(n>=r);)++n;if(n-e>16&&t.buffer&&rt)return rt.decode(t.subarray(e,n));for(var i="";e<n;){var a=t[e++];if(128&a){var o=63&t[e++];if(192!=(224&a)){var h=63&t[e++];if((a=224==(240&a)?(15&a)<<12|o<<6|h:(7&a)<<18|o<<12|h<<6|63&t[e++])<65536)i+=String.fromCharCode(a);else{var l=a-65536;i+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else i+=String.fromCharCode((31&a)<<6|o)}else i+=String.fromCharCode(a)}return i},it=(t,e)=>t?nt(f,t,e):"",at="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,ot=(t,e)=>{for(var s=t,r=s>>1,n=r+e/2;!(r>=n)&&p[r];)++r;if((s=r<<1)-t>32&&at)return at.decode(f.subarray(t,s));for(var i="",a=0;!(a>=e/2);++a){var o=y[t+2*a>>1];if(0==o)break;i+=String.fromCharCode(o)}return i},ht=(t,e,s)=>{if(s??=2147483647,s<2)return 0;for(var r=e,n=(s-=2)<2*t.length?s/2:t.length,i=0;i<n;++i){var a=t.charCodeAt(i);y[e>>1]=a,e+=2}return y[e>>1]=0,e-r},lt=t=>2*t.length,ct=(t,e)=>{for(var s=0,r="";!(s>=e/4);){var n=g[t+4*s>>2];if(0==n)break;if(++s,n>=65536){var i=n-65536;r+=String.fromCharCode(55296|i>>10,56320|1023&i)}else r+=String.fromCharCode(n)}return r},ut=(t,e,s)=>{if(s??=2147483647,s<4)return 0;for(var r=e,n=r+s-4,i=0;i<t.length;++i){var a=t.charCodeAt(i);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&t.charCodeAt(++i)),g[e>>2]=a,(e+=4)+4>n)break}return g[e>>2]=0,e-r},dt=t=>{for(var e=0,s=0;s<t.length;++s){var r=t.charCodeAt(s);r>=55296&&r<=57343&&++s,e+=4}return e},mt={},ft=t=>{if(!_)try{t()}catch(t){(t=>{if(t instanceof D||"unwind"==t)return d;o(0,t)})(t)}},yt=(t,e)=>Math.ceil(t/e)*e,pt=t=>{var e=(t-l.buffer.byteLength+65535)/65536|0;try{return l.grow(e),x(),1}catch(t){}},gt=[null,[],[]],wt=(t,e)=>{var s=gt[t];0===e||10===e?((1===t?c:u)(nt(s)),s.length=0):s.push(e)},vt=(t,e)=>{t<128?e.push(t):e.push(t%128|128,t>>7)},bt=(t,e)=>{if("function"==typeof WebAssembly.Function)return new WebAssembly.Function((t=>{for(var e={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"},s={parameters:[],results:"v"==t[0]?[]:[e[t[0]]]},r=1;r<t.length;++r)s.parameters.push(e[t[r]]);return s})(e),t);var s=[1];((t,e)=>{var s=t.slice(0,1),r=t.slice(1),n={i:127,p:127,j:126,f:125,d:124,e:111};e.push(96),vt(r.length,e);for(var i=0;i<r.length;++i)e.push(n[r[i]]);"v"==s?e.push(0):e.push(1,n[s])})(e,s);var r=[0,97,115,109,1,0,0,0,1];vt(s.length,r),r.push(...s),r.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var n=new WebAssembly.Module(new Uint8Array(r));return new WebAssembly.Instance(n,{e:{f:t}}).exports.f},_t=t=>Y.get(t),xt=t=>(X||(X=new WeakMap,((t,e)=>{if(X)for(var s=t;s<t+e;s++){var r=_t(s);r&&X.set(r,s)}})(0,Y.length)),X.get(t)||0),At=[],kt=(t,e)=>Y.set(t,e);(()=>{for(var t=new Array(256),e=0;e<256;++e)t[e]=String.fromCharCode(e);U=t})(),M=n.BindingError=class extends Error{constructor(t){super(t),this.name="BindingError"}},n.InternalError=class extends Error{constructor(t){super(t),this.name="InternalError"}},G.push(0,1,void 0,1,null,1,!0,1,!1,1),n.count_emval_handles=K;var St,Ct={a:(t,e,s)=>{throw new L(t).init(e,s),t},t:()=>j(""),k:(t,e,s,r,n)=>{},r:(t,e,s,r)=>{V(t,{name:e=I(e),fromWireType:function(t){return!!t},toWireType:function(t,e){return e?s:r},argPackAdvance:8,readValueFromPointer:function(t){return this.fromWireType(f[t])},destructorFunction:null})},p:t=>V(t,Z),e:(t,e,s)=>{V(t,{name:e=I(e),fromWireType:t=>t,toWireType:(t,e)=>e,argPackAdvance:8,readValueFromPointer:tt(e,s),destructorFunction:null})},c:(t,e,s,r,n)=>{e=I(e);var i=t=>t;if(0===r){var a=32-8*s;i=t=>t<<a>>>a}var o=e.includes("unsigned");V(t,{name:e,fromWireType:i,toWireType:o?function(t,e){return this.name,e>>>0}:function(t,e){return this.name,e},argPackAdvance:8,readValueFromPointer:et(e,s,0!==r),destructorFunction:null})},b:(t,e,s)=>{var r=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][e];function n(t){var e=w[t>>2],s=w[t+4>>2];return new r(m.buffer,s,e)}V(t,{name:s=I(s),fromWireType:n,argPackAdvance:8,readValueFromPointer:n},{ignoreDuplicateRegistrations:!0})},q:(t,e)=>{V(t,{name:e=I(e),fromWireType(t){for(var e,s=w[t>>2],r=t+4,n=r,i=0;i<=s;++i){var a=r+i;if(i==s||0==f[a]){var o=it(n,a-n);void 0===e?e=o:(e+=String.fromCharCode(0),e+=o),n=a+1}}return Pt(t),e},toWireType(t,e){var s;e instanceof ArrayBuffer&&(e=new Uint8Array(e));var r="string"==typeof e;r||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||$("Cannot pass non-string to std::string"),s=r?(t=>{for(var e=0,s=0;s<t.length;++s){var r=t.charCodeAt(s);r<=127?e++:r<=2047?e+=2:r>=55296&&r<=57343?(e+=4,++s):e+=3}return e})(e):e.length;var n=jt(4+s+1),i=n+4;if(w[n>>2]=s,r)st(e,i,s+1);else if(r)for(var a=0;a<s;++a){var o=e.charCodeAt(a);o>255&&(Pt(i),$("String has UTF-16 code units that do not fit in 8 bits")),f[i+a]=o}else for(a=0;a<s;++a)f[i+a]=e[a];return null!==t&&t.push(Pt,n),n},argPackAdvance:8,readValueFromPointer:Q,destructorFunction(t){Pt(t)}})},d:(t,e,s)=>{var r,n,i,a;s=I(s),2===e?(r=ot,n=ht,a=lt,i=t=>p[t>>1]):4===e&&(r=ct,n=ut,a=dt,i=t=>w[t>>2]),V(t,{name:s,fromWireType:t=>{for(var s,n=w[t>>2],a=t+4,o=0;o<=n;++o){var h=t+4+o*e;if(o==n||0==i(h)){var l=r(a,h-a);void 0===s?s=l:(s+=String.fromCharCode(0),s+=l),a=h+e}}return Pt(t),s},toWireType:(t,r)=>{"string"!=typeof r&&$(`Cannot pass non-string to C++ string type ${s}`);var i=a(r),o=jt(4+i+e);return w[o>>2]=i/e,n(r,o+4,i+e),null!==t&&t.push(Pt,o),o},argPackAdvance:8,readValueFromPointer:Q,destructorFunction(t){Pt(t)}})},s:(t,e)=>{V(t,{isVoid:!0,name:e=I(e),argPackAdvance:0,fromWireType:()=>{},toWireType:(t,e)=>{}})},m:()=>{},n:(t,e)=>{if(mt[t]&&(clearTimeout(mt[t].id),delete mt[t]),!e)return 0;var s=setTimeout(()=>{delete mt[t],ft(()=>Et(t,performance.now()))},e);return mt[t]={id:s,timeout_ms:e},0},K:function(t,e,s,r,i,a,o){n.canvases[t].addBezier(e,s,r,i,a,o)},L:function(t,e,s){n.canvases[t].addPoint(e,s)},R:function(t){n.canvases[t].beginDropShadow()},M:function(t){n.canvases[t].beginPolygon()},G:function(t,e,s,r){n.canvases[t].circle(e,s,r)},N:function(t){n.canvases[t].endDropShadow()},J:function(t){n.canvases[t].endPolygon()},B:function(t){n.canvases[t].frameBegin()},C:function(t){n.canvases[t].frameEnd()},F:function(t,e,s,r,i){n.canvases[t].line(e,s,r,i)},I:function(t,e,s,r,i){n.canvases[t].rectangle(e,s,r,i)},y:function(t){n.canvases[t].restore()},z:function(t){n.canvases[t].save()},i:function(t,e,s,r,i){n.canvases[t].setBrushColor(e,s,r,i)},D:function(t,e,s,r,i,a,o){n.canvases[t].setBrushGradient(e,s,r,i,a,o)},o:function(t,e,s,r){n.canvases[t].setClipCircle(e,s,r)},j:function(t){n.canvases[t].setClipPolygon()},w:function(t,e,s,r,i){n.canvases[t].setClipRect(e,s,r,i)},Q:function(t,e){n.canvases[t].setDropShadowBlur(e)},P:function(t,e,s,r,i){n.canvases[t].setDropShadowColor(e,s,r,i)},O:function(t,e,s){n.canvases[t].setDropShadowOffset(e,s)},f:function(t,e){n.canvases[t].setFont(e)},h:function(t,e,s,r,i){n.canvases[t].setLineColor(e,s,r,i)},g:function(t,e){n.canvases[t].setLineWidth(e)},E:function(t,e,s,r,i,a){n.canvases[t].text(e,s,r,i,a)},A:function(t,e,s,r,i,a,o){n.canvases[t].transform(e,s,r,i,a,o)},H:function(t){n.charts[t].doChange()},S:function(t,e){n.charts[t].openUrl(e)},u:t=>{var e=f.length,s=2147483648;if((t>>>=0)>s)return!1;for(var r=1;r<=4;r*=2){var n=e*(1+.2/r);n=Math.min(n,t+100663296);var i=Math.min(s,yt(Math.max(t,n),65536));if(pt(i))return!0}return!1},v:(t,e,s,r)=>{for(var n=0,i=0;i<s;i++){var a=w[e>>2],o=w[e+4>>2];e+=8;for(var h=0;h<o;h++)wt(t,f[a+h]);n+=o}return w[r>>2]=n,0},l:t=>{d=t,o(0,new D(t))},x:function(t,e,s,r){const i=n.measureCanvas;i.font=it(t);let a=i.measureText(it(e));const o=a.width;a=i.measureText("Op");const h=a.actualBoundingBoxAscent+a.actualBoundingBoxDescent;W(s,o,"double"),W(r,h,"double")}};!async function(){function t(t,e){var s;return St=t.exports,l=St.T,x(),Y=St.Ga,s=St.U,S.unshift(s),function(){if(0==--B&&E){var t=E;E=null,t()}}(),St}B++;var e={a:Ct};P??=z();try{var r=await async function(t,e,s){if("function"==typeof WebAssembly.instantiateStreaming&&!T(e)&&"function"==typeof fetch)try{var r=fetch(e,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(r,s)}catch(t){u(`wasm streaming compile failed: ${t}`),u("falling back to ArrayBuffer instantiation")}return O(e,s)}(0,P,e);return function(e){t(e.instance)}(r),r}catch(t){return void s(t)}}(),n._vizzu_errorMessage=(t,e)=>(n._vizzu_errorMessage=St.V)(t,e),n._vizzu_version=()=>(n._vizzu_version=St.W)(),n._vizzu_setLogging=t=>(n._vizzu_setLogging=St.X)(t),n._vizzu_createChart=()=>(n._vizzu_createChart=St.Y)(),n._vizzu_createCanvas=()=>(n._vizzu_createCanvas=St.Z)(),n._vizzu_pointerMove=(t,e,s,r,i)=>(n._vizzu_pointerMove=St._)(t,e,s,r,i),n._vizzu_pointerDown=(t,e,s,r,i)=>(n._vizzu_pointerDown=St.$)(t,e,s,r,i),n._vizzu_pointerUp=(t,e,s,r,i)=>(n._vizzu_pointerUp=St.aa)(t,e,s,r,i),n._vizzu_pointerLeave=(t,e,s)=>(n._vizzu_pointerLeave=St.ba)(t,e,s),n._vizzu_wheel=(t,e,s)=>(n._vizzu_wheel=St.ca)(t,e,s),n._vizzu_update=(t,e)=>(n._vizzu_update=St.da)(t,e),n._vizzu_render=(t,e,s,r)=>(n._vizzu_render=St.ea)(t,e,s,r),n._style_getList=()=>(n._style_getList=St.fa)(),n._style_setValue=(t,e,s)=>(n._style_setValue=St.ga)(t,e,s),n._style_getValue=(t,e,s)=>(n._style_getValue=St.ha)(t,e,s),n._chart_store=t=>(n._chart_store=St.ia)(t),n._chart_restore=(t,e)=>(n._chart_restore=St.ja)(t,e),n._chart_anim_store=t=>(n._chart_anim_store=St.ka)(t),n._chart_anim_restore=(t,e)=>(n._chart_anim_restore=St.la)(t,e),n._object_free=t=>(n._object_free=St.ma)(t),n._chart_getList=()=>(n._chart_getList=St.na)(),n._chart_getValue=(t,e)=>(n._chart_getValue=St.oa)(t,e),n._chart_setValue=(t,e,s)=>(n._chart_setValue=St.pa)(t,e,s),n._chart_setFilter=(t,e,s)=>(n._chart_setFilter=St.qa)(t,e,s),n._record_getValue=(t,e)=>(n._record_getValue=St.ra)(t,e),n._data_addDimension=(t,e,s,r,i,a,o)=>(n._data_addDimension=St.sa)(t,e,s,r,i,a,o),n._data_addMeasure=(t,e,s,r,i)=>(n._data_addMeasure=St.ta)(t,e,s,r,i),n._data_addRecord=(t,e,s)=>(n._data_addRecord=St.ua)(t,e,s),n._data_metaInfo=t=>(n._data_metaInfo=St.va)(t),n._addEventListener=(t,e,s)=>(n._addEventListener=St.wa)(t,e,s),n._removeEventListener=(t,e,s)=>(n._removeEventListener=St.xa)(t,e,s),n._event_preventDefault=t=>(n._event_preventDefault=St.ya)(t),n._chart_animate=(t,e)=>(n._chart_animate=St.za)(t,e),n._chart_relToCanvasCoords=(t,e,s)=>(n._chart_relToCanvasCoords=St.Aa)(t,e,s),n._chart_canvasToRelCoords=(t,e,s)=>(n._chart_canvasToRelCoords=St.Ba)(t,e,s),n._chart_setKeyframe=t=>(n._chart_setKeyframe=St.Ca)(t),n._anim_control_setValue=(t,e,s)=>(n._anim_control_setValue=St.Da)(t,e,s),n._anim_control_getValue=(t,e)=>(n._anim_control_getValue=St.Ea)(t,e),n._anim_setValue=(t,e,s)=>(n._anim_setValue=St.Fa)(t,e,s);var Bt,Et=(t,e)=>(Et=St.Ha)(t,e),jt=n._malloc=t=>(jt=n._malloc=St.Ia)(t),Pt=n._free=t=>(Pt=n._free=St.Ja)(t);function Tt(){B>0||(F(A),B>0||Bt||(Bt=!0,n.calledRun=!0,_||(F(S),e(n),F(C))))}return n.addFunction=(t,e)=>{var s=xt(t);if(s)return s;var r=(()=>{if(At.length)return At.pop();try{Y.grow(1)}catch(t){if(!(t instanceof RangeError))throw t;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}return Y.length-1})();try{kt(r,t)}catch(s){if(!(s instanceof TypeError))throw s;var n=bt(t,e);kt(r,n)}return X.set(t,r),r},n.removeFunction=t=>{X.delete(_t(t)),kt(t,null),At.push(t)},n.setValue=W,n.getValue=function(t,e="i8"){switch(e.endsWith("*")&&(e="*"),e){case"i1":case"i8":return m[t];case"i16":return y[t>>1];case"i32":return g[t>>2];case"i64":j("to do getValue(i64) use WASM_BIGINT");case"float":return v[t>>2];case"double":return b[t>>3];case"*":return w[t>>2];default:j(`invalid type for getValue: ${e}`)}},n.UTF8ToString=it,n.stringToUTF8=st,n.ExceptionInfo=L,E=function t(){Bt||Tt(),Bt||(E=t)},Tt(),i});const C=new class{constructor(){this.xt={},this.At=null}set options(t){this.xt={...this.xt,...t}}get options(){return this.xt}initialize(){return this.At||(this.At=this.kt()),this.At}async kt(){return new A(await S(this.St()))}St(){const t={};if(this.xt?.wasmUrl){const e=this.xt.wasmUrl;t.locateFile=t=>t.endsWith(".wasm")?e:t}return t}};class B extends Error{constructor(){super("Canvas is not initialized"),this.name="CanvasError"}}class E extends _{constructor(){super(...arguments),this.Ct=!1,this.Bt=1}get hooks(){return{render:(t,e)=>{"htmlCanvas"in t&&(this.Et=t.htmlCanvas,t.renderer=this),e()}}}get jt(){if(!this.Et)throw new B;return this.Et}get Pt(){if(!this.Et)throw new B;return this.Et.context}frameBegin(){this.Bt=1,this.Ct=!1,this.jt.frameBegin()}frameEnd(){this.jt.frameEnd()}setClipRect(t,e,s,r){const n=this.Pt;n.beginPath(),n.rect(t,e,s,r),n.clip()}setClipCircle(t,e,s){const r=this.Pt;r.beginPath(),r.arc(t,e,s,0,6.28318530718),r.clip()}setClipPolygon(){const t=this.Pt;t.closePath(),t.clip(),this.Ct=!1}setBrushColor(t,e,s,r){this.Pt.fillStyle="rgba("+255*t+","+255*e+","+255*s+","+r+")"}setLineColor(t,e,s,r){this.Pt.strokeStyle="rgba("+255*t+","+255*e+","+255*s+","+r+")"}setLineWidth(t){this.Pt.lineWidth=t,this.Bt=t}setFontStyle(t){this.Pt.font=t}beginDropShadow(){}setDropShadowBlur(t){this.Pt.shadowBlur=t}setDropShadowColor(t,e,s,r){this.Pt.shadowColor="rgba("+255*t+","+255*e+","+255*s+","+r+")"}setDropShadowOffset(t,e){const s=this.Pt;s.shadowOffsetX=t,s.shadowOffsetY=e}endDropShadow(){const t=this.Pt;t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor="rgba(0, 0, 0, 0)"}beginPolygon(){this.Pt.beginPath()}addPoint(t,e){const s=this.Pt;this.Ct?s.lineTo(t,e):s.moveTo(t,e),this.Ct=!0}addBezier(t,e,s,r,n,i){this.Pt.bezierCurveTo(t,e,s,r,n,i)}endPolygon(){const t=this.Pt;t.closePath(),t.fill(),0!==this.Bt&&t.stroke(),this.Ct=!1}rectangle(t,e,s,r){const n=this.Pt;n.beginPath(),n.rect(t,e,s,r),n.fill(),0!==this.Bt&&n.stroke()}circle(t,e,s){const r=this.Pt;r.beginPath(),r.arc(t,e,s,0,6.28318530718),r.fill(),0!==this.Bt&&r.stroke()}line(t,e,s,r){const n=this.Pt;n.beginPath(),n.moveTo(t,e),n.lineTo(s,r),0!==this.Bt&&n.stroke()}drawText(t,e,s,r,n){const i=this.Pt;i.textAlign="left",i.textBaseline="top",t+=s<0?-s:0,e+=r<0?-r:0,i.fillText(n,t,e)}setGradient(t,e,s,r,n){const i=this.Pt,a=i.createLinearGradient(t,e,s,r);n.stops.forEach(t=>a.addColorStop(t.offset,t.color)),i.fillStyle=a}transform(t,e,s,r,n,i){this.Pt.transform(t,e,s,r,n,i)}save(){this.Pt.save()}restore(){this.Pt.restore()}}class j{constructor(){this.meta={name:"clock"}}get api(){return{now:()=>this.Tt()}}get hooks(){return{update:(t,e)=>{null===t.timeInMSecs&&(t.timeInMSecs=this.Tt()),e()}}}Tt(){return performance.now()}}class P{constructor(t){this.meta={name:"coordSystem"},this.api={toCanvas:t=>this.zt.toCanvasCoords(t),toRelative:t=>this.zt.toRelCoords(t)},this.zt=t}}const T=t=>{try{return t.cssRules,!0}catch(t){return!1}},z=(t,e="")=>{const s=((t="")=>[...document.styleSheets].filter(T).reduce((e,s)=>e.concat([...s.cssRules].filter(t=>"CSSStyleRule"===t.constructor.name).reduce((e,s)=>[...e,...[...s.style].filter(e=>0===e.trim().indexOf("--"+t+"-")).map(t=>t.trim())],[])),[]))(e),r=getComputedStyle(t);return s.map(t=>[t,r.getPropertyValue(t).trim()]).filter(t=>""!==t[1])};class O{constructor(t={}){this.meta={name:"cssProperties",depends:["htmlCanvas"]},this.api={prefix:"vizzu"},t?.prefix&&(this.api.prefix=t.prefix)}get hooks(){return{prepareAnimation:(t,e)=>{const s=z(this.Ot.feature.htmlCanvas.element,this.api.prefix);Array.isArray(t.target)&&t.target.forEach(({target:t})=>{t instanceof d||(t.style=((t,e,s="",r=!1)=>(e=e||{},e=t.reduce((t,[e,n])=>(e&&((t,e,s,r)=>{e.reduce((t,n,i)=>(i===e.length-1?!r&&t[n]||(t[n]=s):t[n]||(t[n]={}),t[n]),t)})(t,e.replace("--"+(s?s+"-":""),"").split("-"),n,r),t),e),e))(s,t.style,this.api.prefix))}),e()}}}register(t){this.Ot=t}}var D;!function(t){t.click="click",t.pointermove="pointermove",t.pointerdown="pointerdown",t.pointerup="pointerup",t.pointerleave="pointerleave",t.wheel="wheel",t.update="update",t.drawBegin="draw-begin",t.drawComplete="draw-complete",t.backgroundDraw="background-draw",t.titleDraw="title-draw",t.subtitleDraw="subtitle-draw",t.captionDraw="caption-draw",t.logoDraw="logo-draw",t.legendBackgroundDraw="legend-background-draw",t.legendTitleDraw="legend-title-draw",t.legendLabelDraw="legend-label-draw",t.legendMarkerDraw="legend-marker-draw",t.legendBarDraw="legend-bar-draw",t.plotBackgroundDraw="plot-background-draw",t.plotAreaDraw="plot-area-draw",t.plotMarkerDraw="plot-marker-draw",t.plotMarkerLabelDraw="plot-marker-label-draw",t.plotMarkerGuideDraw="plot-marker-guide-draw",t.plotAxisDraw="plot-axis-draw",t.plotAxisTitleDraw="plot-axis-title-draw",t.plotAxisLabelDraw="plot-axis-label-draw",t.plotAxisTickDraw="plot-axis-tick-draw",t.plotAxisGuideDraw="plot-axis-guide-draw",t.plotAxisInterlacingDraw="plot-axis-interlacing-draw",t.animationBegin="animation-begin",t.animationComplete="animation-complete"}(D||(D={}));class F{constructor(t){this.Dt={},this.Ft=t}add(t,e){if("string"!=typeof t)throw new Error("first parameter should be string");this.Wt(t).push(e)}Wt(t){if(!(t in this.Dt)){let e=null;if(!this.Lt(t)){const s=(e,s)=>{this.Ut(t,s,e)};e=this.Ft.addEventListener(t,s)}this.Dt[t]=[e,[]]}return this.Dt[t][1]}remove(t,e){if("string"!=typeof t)throw new Error("first parameter should be string");const s=this.Dt[t];if(!s)throw new Error("unknown event handler");const[r,n]=s;n.find((t,s)=>t===e&&(n.splice(s,1),!0)),0===n.length&&(this.Lt(t)||r&&this.Ft.removeEventListener(t,r),delete this.Dt[t])}addMany(t){for(const[e,s]of Object.entries(t))this.add(e,s)}removeMany(t){for(const[e,s]of Object.entries(t))this.remove(e,s)}Ut(t,e,s){const r={canceled:!1};try{const n=this.Dt[t];if(n)for(const i of[...n[1]]){i(this.Lt(t)?this.Mt(e,r):s?this.It(s,e,r):e)}}catch(t){console.log(`exception in event handler: ${t}`)}return r.canceled}Lt(t){return t.startsWith("api-")}Mt(t,e){return t.preventDefault=()=>{e.canceled=!0},t}It(t,e,s){return e.preventDefault=()=>{t.preventDefault(),s.canceled=!0},e}}var W=Object.freeze({__proto__:null,get EventType(){return D},Events:F});class L{get api(){const t=this;return{get element(){return t.Nt},set element(e){t.Rt(e)},context:this.context,clientToCanvas:this.$t.bind(this),canvasToClient:this.Vt.bind(this)}}get hooks(){return{start:(t,e)=>{this.Ht=t.update,e()},render:(t,e)=>{t.htmlCanvas=this,t.size=this.Gt(),e()}}}get listeners(){return Object.fromEntries(Object.values(D).filter(t=>t.endsWith("-draw")||t.startsWith("draw-")).map(t=>[t,this.Kt.bind(this)]))}Kt(t){t.renderingContext=this.context}static extractOptions(t){const e="object"!=typeof t||t instanceof HTMLElement?{element:t}:t;if(null===e||!("element"in e))throw new Error("element not specified");let s=e.element;if("string"==typeof s&&(s=document.getElementById(s)),!(s instanceof HTMLElement))throw new Error(`Cannot find element ${e.element} to render Vizzu!`);return{element:s}}constructor(t){this.Ht=()=>{},this.qt="",this.Jt=1,this.Qt=1,this.Yt=1,this.meta={name:"htmlCanvas"},this.Xt=document.createElement("canvas");const e=this.Xt.getContext("2d");if(!e)throw Error("Cannot get rendering context of internal canvas");this.Zt=e,this.te=()=>{this.Ht(!0)},this.Rt(t.element),window.addEventListener("resize",this.te)}Rt(t){this.Nt=this.ee(t),this.qt="";const e=this.Nt.getContext("2d");if(!e)throw Error("Cannot get rendering context of canvas");this.Pt=e,this.Gt(),this.se=this.re(this.Nt)}unregister(){window.removeEventListener("resize",this.te),this.se.disconnect(),this.ne&&this.ne.removeChild(this.Nt)}get element(){return this.Nt}set element(t){this.Rt(t)}get context(){return this.Zt}Gt(){this.Jt=window.devicePixelRatio,this.Qt=+getComputedStyle(this.Nt).width.slice(0,-2),this.Yt=+getComputedStyle(this.Nt).height.slice(0,-2);const t=`${this.Jt}:${this.Qt}:${this.Yt}`;return t!==this.qt&&(this.Nt.width=this.Qt*this.Jt,this.Nt.height=this.Yt*this.Jt,this.Xt.width=this.Qt*this.Jt,this.Xt.height=this.Yt*this.Jt,this.Zt.setTransform(1,0,0,1,0,0),this.Zt.translate(.5,.5),this.Zt.scale(this.Jt,this.Jt)),this.qt=t,{x:this.Qt,y:this.Yt}}frameBegin(){this.Zt.clearRect(-1,-1,this.Qt+2,this.Yt+2)}frameEnd(){this.Pt.clearRect(-1,-1,this.Nt.width+1,this.Nt.height+1),this.Pt.drawImage(this.Xt,0,0)}ie(){return this.Nt.getBoundingClientRect()}ae(t){return{x:t.width/(this.Nt.width/this.Jt),y:t.height/(this.Nt.height/this.Jt)}}$t(t){const e=this.ie(),s=this.ae(e);return{x:(t.x-e.x)/s.x,y:(t.y-e.y)/s.y}}Vt(t){const e=this.ie(),s=this.ae(e);return{x:e.x+t.x*s.x,y:e.y+t.y*s.y}}ee(t){if(t instanceof HTMLCanvasElement)return t;{const e=document.createElement("canvas");return e.style.width="100%",e.style.height="100%",this.ne=t,this.ne.appendChild(e),e}}re(t){const e=new ResizeObserver(()=>{this.Ht(!0)});return e.observe(t),e}}class U{constructor(t){this.meta={name:"logging"},this.oe=t}enable(t){this.oe(t)}}const M=(t,e)=>{if(!t)throw new Error("Assert failed: "+e)},I=(t,e,s)=>{M(Array.isArray(e),"array is not a list");try{if(e.length!==t.dimensions[s].values.length)throw new Error("Assert failed")}catch(t){M(!1,"dimensions are not the same")}e.forEach(e=>{Array.isArray(e)&&I(t,e,s-1)})};class N{static isPivot(t){return void 0!==t&&("dimensions"in t&&void 0!==t.dimensions||"measures"in t&&void 0!==t.measures)}static convert(t){M("object"==typeof t&&null!==t&&!Array.isArray(t),"data is not an object"),M("dimensions"in t,"data.dimensions is requreid"),M("measures"in t,"data.measures is requreid");const e=(({dimensions:t,measures:e,...s})=>Object.assign(s,{series:[]}))(t);let s=1;M(Array.isArray(t.dimensions),"data.dimensions is not a list");for(let e=0;e<t.dimensions.length;e++){const r=t.dimensions[e];M("object"==typeof r&&null!==r&&!Array.isArray(r),"data.dimensions.item is not an object"),M("name"in r,"data.dimensions.item.name is requreid"),M(void 0===r.type||"dimension"===r.type,"data.dimensions.item.type is invalid"),M("values"in r,"data.dimensions.item.values is requreid"),M(Array.isArray(r.values),"data.dimensions.item.values is not a list"),M(0!==r.values.length,"data.dimensions.item.values length is zero"),s*=r.values.length}let r=1;for(let n=0;n<t.dimensions.length;n++){const i=t.dimensions[n];let a=[];const o=[];i.values.forEach(t=>{for(let e=1;e<=r;e++)o.push(t)}),r*=i.values.length;for(let t=1;t<=s/r;t++)a=a.concat(o);const h={name:i.name,type:"dimension",values:a};e.series.push(h)}M("object"==typeof t.measures&&null!==t.measures,"data.measures is not a list or an object"),Array.isArray(t.measures)||(t.measures=[t.measures]);for(let r=0;r<t.measures.length;r++){const n=t.measures[r];M("object"==typeof n&&null!==n&&!Array.isArray(n),"data.measures.item is not an object"),M("name"in n,"data.measures.item.name is requreid"),M("values"in n,"data.measures.item.values is requreid"),M(Array.isArray(n.values),"data.measures.item.values is not a list"),I(t,n.values,t.dimensions.length-1);const i={name:n.name,type:n.type,values:n.values.flat(1/0)};void 0===i.type&&delete i.type,M(i.values.length===s,"dimensions are not the same"),e.series.push(i)}return e}}class R{constructor(){this.meta={name:"pivotData"}}get hooks(){return{prepareAnimation:(t,e)=>{Array.isArray(t.target)&&t.target.forEach(({target:t})=>{if(!(t instanceof d)&&t.data&&t.data&&N.isPivot(t.data)){if(R.he(t.data))throw new Error("inconsistent data form: series/records and dimensions/measures are both set.");t.data=N.convert(t.data)}}),e()}}}static he(t){return"series"in t||"records"in t}}class $ extends Error{constructor(){super("animation canceled"),this.name="CancelError"}}class V extends Error{constructor(){super("vizzu is not initialized, use `initializing` promise"),this.name="NotInitializedError"}}class H{constructor(t){this.le=!1,this.meta={name:"pointerEvents",depends:["htmlCanvas"]},this.ce={pointermove:e=>{this.ue(e,t.pointermove.bind(t))},pointerup:e=>{this.ue(e,t.pointerup.bind(t))},pointerdown:e=>{this.ue(e,t.pointerdown.bind(t))},pointerleave:e=>{this.ue(e,t.pointerleave.bind(t))},wheel:e=>{this.ue(e,t.wheel.bind(t),"deltaY")}}}register(t){this.de=t,this.me=this.de?.feature.htmlCanvas}unregister(){this.le&&this.fe()}enable(t){this.le=t,t?this.ye():this.fe()}ye(){if(!this.de||!this.ce)throw new V;this.jt=this.de.feature.htmlCanvas.element;for(const[t,e]of Object.entries(this.ce))this.jt.addEventListener(t,e,{passive:!1})}fe(){if(this.ce&&this.jt)for(const[t,e]of Object.entries(this.ce))this.jt.removeEventListener(t,e);delete this.jt}ue(t,e,s="pointerId"){const r=[t[s]];void 0!==t.clientX&&r.push(...this.pe(t)),e(...r)}pe(t){const e={x:t.clientX,y:t.clientY};if(!this.me)throw new V;const s=this.me.clientToCanvas(e);return[s.x,s.y]}}const G={column:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},label:{set:[{name:"y"}]}}},groupedColumn:{channels:{x:{set:[{name:"groupedBy"},{name:"x"}]},y:{set:[{name:"y"}]},label:{set:[{name:"y"}]},color:{set:[{name:"x"}]}}},stackedColumn:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"stackedBy"}]},label:{set:[{name:"y"}]},color:{set:[{name:"stackedBy"}]}}},splittedColumn:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"splittedBy"}],split:!0},color:{set:[{name:"splittedBy"}]},label:{set:[{name:"y"}]}}},percentageColumn:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"stackedBy"}],align:"stretch"},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"y"}]}}},waterfall:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"x"}]},label:{set:[{name:"y"}]},color:{set:[{name:"y"}]}}},mekko:{channels:{x:{set:[{name:"x"},{name:"groupedBy"}]},y:{set:[{name:"y"},{name:"stackedBy"}]},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"x"}]}}},marimekko:{channels:{x:{set:[{name:"x"},{name:"groupedBy"}]},y:{set:[{name:"y"},{name:"stackedBy"}],align:"stretch"},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"x"}]}}},bar:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},label:{set:[{name:"x"}]}}},groupedBar:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"groupedBy"},{name:"y"}]},label:{set:[{name:"x"}]},color:{set:[{name:"y"}]}}},stackedBar:{channels:{x:{set:[{name:"x"},{name:"stackedBy"}]},y:{set:[{name:"y"}]},label:{set:[{name:"x"}]},color:{set:[{name:"stackedBy"}]}}},splittedBar:{channels:{x:{set:[{name:"x"},{name:"splittedBy"}],split:!0},y:{set:[{name:"y"}]},color:{set:[{name:"splittedBy"}]},label:{set:[{name:"x"}]}}},percentageBar:{channels:{x:{set:[{name:"x"},{name:"stackedBy"}],align:"stretch"},y:{set:[{name:"y"}]},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"x"}]}}},lollipop:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},label:{set:[{name:"y"}]}},geometry:"circle"},scatter:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},noop:{set:[{name:"dividedBy"}]}},geometry:"circle"},bubbleplot:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},color:{set:[{name:"color"}]},size:{set:[{name:"size"}]},label:{set:[{name:"dividedBy"}]},noop:{set:[{name:"dividedBy"}]}},geometry:"circle"},area:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]}},geometry:"area"},stackedArea:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"stackedBy"}]},color:{set:[{name:"stackedBy"}]}},geometry:"area"},percentageArea:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"stackedBy"}],align:"stretch"},color:{set:[{name:"stackedBy"}]}},geometry:"area"},splittedArea:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"splittedBy"}],split:!0},color:{set:[{name:"splittedBy"}]}},geometry:"area"},stream:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"stackedBy"}],align:"center"},color:{set:[{name:"stackedBy"}]}},geometry:"area"},verticalStream:{channels:{x:{set:[{name:"x"},{name:"stackedBy"}],align:"center"},y:{set:[{name:"y"}]},color:{set:[{name:"stackedBy"}]}},geometry:"area"},violin:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"splittedBy"}],align:"center",split:!0},color:{set:[{name:"splittedBy"}]}},geometry:"area"},verticalViolin:{channels:{x:{set:[{name:"x"},{name:"splittedBy"}],align:"center",split:!0},y:{set:[{name:"y"}]},color:{set:[{name:"splittedBy"}]}},geometry:"area"},line:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},color:{set:[{name:"dividedBy"}]}},geometry:"line"},verticalLine:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},color:{set:[{name:"dividedBy"}]}},geometry:"line"},pie:{channels:{x:{set:[{name:"angle"},{name:"by"}]},color:{set:[{name:"by"}]},label:{set:[{name:"angle"}]}},coordSystem:"polar"},polarColumn:{channels:{x:{set:[{name:"angle"}]},y:{set:[{name:"radius"}]},label:{set:[{name:"radius"}]}},coordSystem:"polar"},polarStackedColumn:{channels:{x:{set:[{name:"angle"}]},y:{set:[{name:"radius"},{name:"stackedBy"}]},color:{set:[{name:"stackedBy"}]}},coordSystem:"polar"},variableRadiusPie:{channels:{x:{set:[{name:"angle"},{name:"by"}]},y:{set:[{name:"radius"}]},color:{set:[{name:"by"}]},label:{set:[{name:"radius"}]}},coordSystem:"polar"},radialBar:{channels:{x:{set:[{name:"angle"}]},y:{set:[{name:"radius"}],range:{min:"-50%"}},label:{set:[{name:"angle"}]}},coordSystem:"polar"},radialStackedBar:{channels:{x:{set:[{name:"angle"},{name:"stackedBy"}]},y:{set:[{name:"radius"}],range:{min:"-50%"}},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"angle"}]}},coordSystem:"polar"},donut:{channels:{x:{set:[{name:"angle"},{name:"stackedBy"}]},y:{range:{min:"-200%",max:"100%"}},color:{set:[{name:"stackedBy"}]}},coordSystem:"polar"},nestedDonut:{channels:{x:{set:[{name:"angle"},{name:"stackedBy"}],align:"stretch"},y:{set:[{name:"radius"}],range:{min:"-50%"}},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"angle"}]}},coordSystem:"polar"},polarScatter:{channels:{x:{set:[{name:"angle"}]},y:{set:[{name:"radius"}]},noop:{set:[{name:"dividedBy"}]}},coordSystem:"polar",geometry:"circle"},polarLine:{channels:{x:{set:[{name:"angle"}]},y:{set:[{name:"radius"}]},color:{set:[{name:"dividedBy"}]}},coordSystem:"polar",geometry:"line"},treemap:{channels:{size:{set:[{name:"size"},{name:"color"}]},color:{set:[{name:"color"}]},label:{set:[{name:"color"}]}}},stackedTreemap:{channels:{size:{set:[{name:"size"},{name:"dividedBy"}]},color:{set:[{name:"color"}]},label:{set:[{name:"dividedBy"}]},lightness:{set:[{name:"size"}]}}},heatmap:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},lightness:{set:[{name:"lightness"}]}}},bubble:{channels:{size:{set:[{name:"size"}]},color:{set:[{name:"color"}]},label:{set:[{name:"color"}]}},geometry:"circle"},stackedBubble:{channels:{size:{set:[{name:"size"},{name:"stackedBy"}]},color:{set:[{name:"color"}]}},geometry:"circle"}};class K{constructor(){this.ge=G;for(const t in this.ge){const e=t;this[e]=t=>this.we(e,t)}}ve(){return{coordSystem:"cartesian",orientation:"auto",angle:0,geometry:"rectangle",channels:{x:{set:null,title:"auto",labelLevel:"auto",axis:"auto",labels:"auto",ticks:"auto",interlacing:"auto",guides:"auto",markerGuides:"auto",step:"auto",align:"none",split:!1},y:{set:null,title:"auto",labelLevel:"auto",axis:"auto",labels:"auto",ticks:"auto",interlacing:"auto",guides:"auto",markerGuides:"auto",step:"auto",align:"none",split:!1},color:{set:null,title:"auto",labelLevel:"auto"},lightness:{set:null,title:"auto",labelLevel:"auto"},size:{set:null,title:"auto",labelLevel:"auto"},noop:{set:null,title:"auto",labelLevel:"auto"},label:{set:null,title:"auto",labelLevel:"auto"}}}}be(t){const e=h(this.ge[t]),s={...this.ve().channels,...e.channels},r=Object.assign(this.ve(),e);return r.channels=s,r}_e(t){return null==t?null:Array.isArray(t)?t:[t]}xe(t,e){if(!e)return;const s=t.channels;for(const t in s){const r=s[t];if(this.Ae(r))if("string"==typeof r.set){const t=r.set;r.set=this._e(e[t])}else if(Array.isArray(r.set)){const t=[];for(let s=0;s<r.set.length;s++){const n=r.set[s].name,i=this._e(e[n]);null!==i&&t.push(i)}r.set=t.length>0?t.flat():null}}}Ae(t){return"object"==typeof t&&null!==t&&"set"in t}ke(t,e,s){const r=e[s];void 0!==r&&(t[s]=r)}Se(t,e,s){["legend","title","subtitle","caption"].forEach(s=>{const r=s;this.ke(t,e,r)}),["reverse","sort"].forEach(r=>{this.ke(t.channels?.[s],e,r)})}Ce(t){return new Set(["bar","groupedBar","stackedBar","splittedBar","percentageBar","verticalStream","verticalViolin","verticalLine","pie","radialBar","radialStackedBar","donut","nestedDonut"]).has(t)?"y":"x"}we(t,e){const s=this.be(t),r=this.Ce(t);return this.xe(s,e),this.Se(s,e,r),s}}var q,J;!function(t){t.start="start",t.update="update",t.render="render",t.prepareAnimation="prepareAnimation",t.registerAnimation="registerAnimation",t.runAnimation="runAnimation"}(q||(q={})),function(t){t.forced="forced",t.allowed="allowed",t.disabled="disabled"}(J||(J={}));class Q{constructor(t,e){if(this.Be=t,this.Ee=[],e){if(!Array.isArray(e))throw new Error("Plugins must be an array");e.forEach(t=>this.register(t,!0))}}init(t){this.je=t,this.Ee.forEach(t=>{t.enabled&&this.Pe(t)})}enable(t,e){const s=this.Te(t);this.ze(s,e)}getRegisteredName(t){const e=this.Ee.find(e=>e.instance===t);return e?.name}register(t,e=!0){this.Oe(t);const s=this.De(t);t.register&&this.Be&&t.register(this.Be);const r={name:s,instance:t,enabled:!e};return this.Ee.push(r),this.ze(r,e),s}destruct(){const t=this.Ee.map(t=>t.name);try{t.forEach(t=>this.unregister(t))}finally{this.Ee=[],this.Be=null}}unregister(t){const e=this.Ee.findIndex(e=>e.name===t);if(-1!==e){const t=this.Ee[e];this.Ee.splice(e,1),t?.instance.unregister&&this.Be&&t.instance.unregister(this.Be)}}api(t){return this.Te(t).instance.api||{}}hook(t,e){return{default:(s=()=>{})=>{this.Fe(e,t,s)}}}ze(t,e){t.enabled!==e&&(t.enabled=e,t.instance.enable&&t.instance.enable(e),t.enabled?this.Pe(t):this.We(t))}Pe(t){t.instance.listeners&&(t.registeredListeners=t.instance.listeners,this.je?.addMany(t.registeredListeners))}We(t){t.registeredListeners&&this.je?.removeMany(t.registeredListeners),delete t.registeredListeners}Oe(t){this.Le(t),this.Ue(t)}Le(t){const e=this.De(t);if(!("string"==typeof e&&e.length>0))throw new Error("Plugin must have a non empty name string")}De(t){return t.meta?.name??(t.constructor?.name?this.Me(t.constructor.name):void 0)}Me(t){return"string"==typeof t&&t[0]?t[0].toLowerCase()+t.slice(1):""}Ue(t){if(t.meta?.depends){if(Array.isArray(t.meta.depends)){for(const e of t.meta.depends)this.Te(e);return}throw new Error("Plugin depends must be an array")}}Te(t){const e=this.Ee.find(e=>e.name===t);if(e)return e;throw new Error(`Plugin ${t} is not registered`)}Fe(t,e,s){const r=[...this.Ie(e),s];this.Ne(r,t)}Ie(t){return this.Ee.filter(e=>e.enabled&&e.instance.hooks?.[t]).map(e=>e.instance.hooks[t]).sort((t,e)=>(e.priority||0)-(t.priority||0))}Ne(t,e){const s=r=>{if(r>=t.length)return;const n=t[r],i=()=>s(r+1);n?n(e,i):i()};s(0)}}var Y=Object.freeze({__proto__:null,get Hooks(){return q},PluginRegistry:Q,get RenderControlMode(){return J}});class X{constructor(){this.Ht=()=>{},this.Re=null,this.le=!0,this.meta={name:"rendering"}}get api(){return{update:(t=null)=>{this.Re=t,this.Ht(!0)}}}get hooks(){return{start:(t,e)=>{this.Ht=t.update,e()},update:(t,e)=>{null!==this.Re&&(t.timeInMSecs=this.Re,this.Re=null),e()},render:(t,e)=>{t.control===J.disabled&&this.le&&(t.control=J.allowed),e()}}}enable(t){this.le=t}}class Z{constructor(){this.Ht=()=>{},this.le=!1,this.meta={name:"scheduler"}}get hooks(){return{start:(t,e)=>{this.Ht=t.update,this.$e(),e()}}}enable(t){this.le=t,this.le?this.$e():this.Ve()}unregister(){this.Ve()}$e(){this.He||(this.Ht(!1),this.He=setInterval(()=>{this.le&&this.Ht(!1)},25))}Ve(){this.He&&clearInterval(this.He),delete this.He}}class tt{constructor(t){return new Proxy(this,{get:(e,s)=>t.getValue(s)})}}class et{constructor(t){this.Ge=t}set(t){if(t){if(t.series){if(!Array.isArray(t.series))throw new Error("data series field is not an array");for(const e of t.series)this.Ke(e)}if("records"in t){if(!Array.isArray(t.records))throw new Error("data records field is not an array");const e=this.Ge.getMetaInfo().series;for(const s of t.records)this.qe(s,e)}(t.filter||null===t.filter)&&this.Je(t.filter)}}qe(t,e){if(!Array.isArray(t)){if("object"!=typeof t||null===t)throw new Error("data record is not an array or object");t=this.Qe(t,e)}this.Ge.addRecord(t)}Qe(t,e){const s=[];return e.forEach(e=>{e.name in t?s.push(t[e.name]||this.Ye(e.type)):s.push(this.Ye(e.type))}),s}Ye(t){return"measure"===t?0:""}Ke(t){if(!t.name)throw new Error("missing series name");if(this.Xe(t))this.Ze(t),this.ts(t.name,t.values??[],t.categories,t.isContiguous??!1);else{const e=t?.values??[],s=t?.type??this.es(e);if(this.ss(t,s)){const{indexes:s,categories:r}=this.rs(e);this.ts(t.name,s,r,t.isContiguous??!1)}else{if(!this.ns(t,s)){throw new Error("invalid series type: "+t.type)}t.unit||(t.unit=""),this.hs(t.name,t.unit,e)}}}Xe(t){return!(!("categories"in t)||!Array.isArray(t.categories))}ss(t,e){return"dimension"===e||"isContiguous"in t&&"boolean"==typeof t.isContiguous}ns(t,e){return"measure"===e||"unit"in t&&"string"==typeof t.unit}Ze(t){if(t.values&&Array.isArray(t.values)){const e=t.categories.length;for(const s of t.values){if(null===s)continue;const t=Number(s);if(!Number.isInteger(t))throw new Error("invalid category value (not an int): "+t);if(t<0)throw new Error("invalid category value (negative): "+t);if(t>=e)throw new Error("invalid category value (out of range): "+t)}}if(new Set(t.categories).size!==t.categories.length)throw new Error("duplicate category values")}es(t){if(Array.isArray(t)&&t.length){if("number"==typeof t[0]||null===t[0])return"measure";if("string"==typeof t[0])return"dimension"}return null}ts(t,e,s,r){if("string"!=typeof t)throw new Error("first parameter should be string");if(!(e instanceof Array))throw new Error("second