@orbcharts/core 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(M,ae){typeof exports=="object"&&typeof module<"u"?ae(exports):typeof define=="function"&&define.amd?define(["exports"],ae):(M=typeof globalThis<"u"?globalThis:M||self,ae(M.orbchartsCore={}))})(this,function(M){"use strict";var ae=function(t,e){return ae=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},ae(t,e)};function
|
|
1
|
+
(function(M,ae){typeof exports=="object"&&typeof module<"u"?ae(exports):typeof define=="function"&&define.amd?define(["exports"],ae):(M=typeof globalThis<"u"?globalThis:M||self,ae(M.orbchartsCore={}))})(this,function(M){"use strict";var ae=function(t,e){return ae=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},ae(t,e)};function W(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ae(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function kt(t,e,r,n){function s(o){return o instanceof r?o:new r(function(u){u(o)})}return new(r||(r=Promise))(function(o,u){function a(f){try{i(n.next(f))}catch(w){u(w)}}function c(f){try{i(n.throw(f))}catch(w){u(w)}}function i(f){f.done?o(f.value):s(f.value).then(a,c)}i((n=n.apply(t,e||[])).next())})}function Ve(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return u.next=a(0),u.throw=a(1),u.return=a(2),typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(i){return function(f){return c([i,f])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,i[0]&&(r=0)),r;)try{if(n=1,s&&(o=i[0]&2?s.return:i[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,i[1])).done)return o;switch(s=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,s=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=e.call(t,r)}catch(f){i=[6,f],s=0}finally{n=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ue(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ce(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,o=[],u;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(a){u={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(u)throw u.error}}return o}function le(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))}function fe(t){return this instanceof fe?(this.v=t,this):new fe(t)}function Lt(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",u),s[Symbol.asyncIterator]=function(){return this},s;function u(y){return function(S){return Promise.resolve(S).then(y,w)}}function a(y,S){n[y]&&(s[y]=function(m){return new Promise(function(p,b){o.push([y,m,p,b])>1||c(y,m)})},S&&(s[y]=S(s[y])))}function c(y,S){try{i(n[y](S))}catch(m){x(o[0][3],m)}}function i(y){y.value instanceof fe?Promise.resolve(y.value.v).then(f,w):x(o[0][2],y)}function f(y){c("next",y)}function w(y){c("throw",y)}function x(y,S){y(S),o.shift(),o.length&&c(o[0][0],o[0][1])}}function Vt(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof ue=="function"?ue(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(u){return new Promise(function(a,c){u=t[o](u),s(a,c,u.done,u.value)})}}function s(o,u,a,c){Promise.resolve(c).then(function(i){o({value:i,done:a})},u)}}typeof SuppressedError=="function"&&SuppressedError;function K(t){return typeof t=="function"}function Ke(t){var e=function(n){Error.call(n),n.stack=new Error().stack},r=t(e);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var _e=Ke(function(t){return function(r){t(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
2
2
|
`+r.map(function(n,s){return s+1+") "+n.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=r}});function we(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}var ve=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,r,n,s,o;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var a=ue(u),c=a.next();!c.done;c=a.next()){var i=c.value;i.remove(this)}}catch(m){e={error:m}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}else u.remove(this);var f=this.initialTeardown;if(K(f))try{f()}catch(m){o=m instanceof _e?m.errors:[m]}var w=this._finalizers;if(w){this._finalizers=null;try{for(var x=ue(w),y=x.next();!y.done;y=x.next()){var S=y.value;try{Fe(S)}catch(m){o=o??[],m instanceof _e?o=le(le([],ce(o)),ce(m.errors)):o.push(m)}}}catch(m){n={error:m}}finally{try{y&&!y.done&&(s=x.return)&&s.call(x)}finally{if(n)throw n.error}}}if(o)throw new _e(o)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)Fe(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(e)}},t.prototype._hasParent=function(e){var r=this._parentage;return r===e||Array.isArray(r)&&r.includes(e)},t.prototype._addParent=function(e){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(e),r):r?[r,e]:e},t.prototype._removeParent=function(e){var r=this._parentage;r===e?this._parentage=null:Array.isArray(r)&&we(r,e)},t.prototype.remove=function(e){var r=this._finalizers;r&&we(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),Ke=ve.EMPTY;function Re(t){return t instanceof ve||t&&"closed"in t&&K(t.remove)&&K(t.add)&&K(t.unsubscribe)}function Fe(t){K(t)?t():t.unsubscribe()}var Kt={Promise:void 0},Rt={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,le([t,e],ce(r)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function De(t){Rt.setTimeout(function(){throw t})}function Ce(){}function Ee(t){t()}var Te=function(t){Z(e,t);function e(r){var n=t.call(this)||this;return n.isStopped=!1,r?(n.destination=r,Re(r)&&r.add(n)):n.destination=Nt,n}return e.create=function(r,n,s){return new me(r,n,s)},e.prototype.next=function(r){this.isStopped||this._next(r)},e.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(r){this.destination.next(r)},e.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(ve),Ft=function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var r=this.partialObserver;if(r.next)try{r.next(e)}catch(n){Ae(n)}},t.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(n){Ae(n)}else Ae(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){Ae(r)}},t}(),me=function(t){Z(e,t);function e(r,n,s){var o=t.call(this)||this,u;return K(r)||!r?u={next:r??void 0,error:n??void 0,complete:s??void 0}:u=r,o.destination=new Ft(u),o}return e}(Te);function Ae(t){De(t)}function Dt(t){throw t}var Nt={closed:!0,next:Ce,error:Dt,complete:Ce},Oe=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function ge(t){return t}function Gt(t){return t.length===0?ge:t.length===1?t[0]:function(r){return t.reduce(function(n,s){return s(n)},r)}}var F=function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(e,r,n){var s=this,o=zt(e)?e:new me(e,r,n);return Ee(function(){var u=s,a=u.operator,c=u.source;o.add(a?a.call(o,c):c?s._subscribe(o):s._trySubscribe(o))}),o},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(r){e.error(r)}},t.prototype.forEach=function(e,r){var n=this;return r=Ne(r),new r(function(s,o){var u=new me({next:function(a){try{e(a)}catch(c){o(c),u.unsubscribe()}},error:o,complete:s});n.subscribe(u)})},t.prototype._subscribe=function(e){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(e)},t.prototype[Oe]=function(){return this},t.prototype.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Gt(e)(this)},t.prototype.toPromise=function(e){var r=this;return e=Ne(e),new e(function(n,s){var o;r.subscribe(function(u){return o=u},function(u){return s(u)},function(){return n(o)})})},t.create=function(e){return new t(e)},t}();function Ne(t){var e;return(e=t??Kt.Promise)!==null&&e!==void 0?e:Promise}function Ut(t){return t&&K(t.next)&&K(t.error)&&K(t.complete)}function zt(t){return t&&t instanceof Te||Ut(t)&&Re(t)}function qt(t){return K(t==null?void 0:t.lift)}function G(t){return function(e){if(qt(e))return e.lift(function(r){try{return t(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function U(t,e,r,n,s){return new Wt(t,e,r,n,s)}var Wt=function(t){Z(e,t);function e(r,n,s,o,u,a){var c=t.call(this,r)||this;return c.onFinalize=u,c.shouldUnsubscribe=a,c._next=n?function(i){try{n(i)}catch(f){r.error(f)}}:t.prototype._next,c._error=o?function(i){try{o(i)}catch(f){r.error(f)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=s?function(){try{s()}catch(i){r.error(i)}finally{this.unsubscribe()}}:t.prototype._complete,c}return e.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},e}(Te),Yt=xe(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ie=function(t){Z(e,t);function e(){var r=t.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return e.prototype.lift=function(r){var n=new Ge(this,this);return n.operator=r,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Yt},e.prototype.next=function(r){var n=this;Ee(function(){var s,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var u=ue(n.currentObservers),a=u.next();!a.done;a=u.next()){var c=a.value;c.next(r)}}catch(i){s={error:i}}finally{try{a&&!a.done&&(o=u.return)&&o.call(u)}finally{if(s)throw s.error}}}})},e.prototype.error=function(r){var n=this;Ee(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var s=n.observers;s.length;)s.shift().error(r)}})},e.prototype.complete=function(){var r=this;Ee(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(r){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,r)},e.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},e.prototype._innerSubscribe=function(r){var n=this,s=this,o=s.hasError,u=s.isStopped,a=s.observers;return o||u?Ke:(this.currentObservers=null,a.push(r),new ve(function(){n.currentObservers=null,we(a,r)}))},e.prototype._checkFinalizedStatuses=function(r){var n=this,s=n.hasError,o=n.thrownError,u=n.isStopped;s?r.error(o):u&&r.complete()},e.prototype.asObservable=function(){var r=new F;return r.source=this,r},e.create=function(r,n){return new Ge(r,n)},e}(F),Ge=function(t){Z(e,t);function e(r,n){var s=t.call(this)||this;return s.destination=r,s.source=n,s}return e.prototype.next=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.next)===null||s===void 0||s.call(n,r)},e.prototype.error=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.error)===null||s===void 0||s.call(n,r)},e.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},e.prototype._subscribe=function(r){var n,s;return(s=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&s!==void 0?s:Ke},e}(ie),z=function(t){Z(e,t);function e(r){var n=t.call(this)||this;return n._value=r,n}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(r){var n=t.prototype._subscribe.call(this,r);return!n.closed&&r.next(this._value),n},e.prototype.getValue=function(){var r=this,n=r.hasError,s=r.thrownError,o=r._value;if(n)throw s;return this._throwIfClosed(),o},e.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},e}(ie),$e={now:function(){return($e.delegate||Date).now()},delegate:void 0},Zt=function(t){Z(e,t);function e(r,n,s){r===void 0&&(r=1/0),n===void 0&&(n=1/0),s===void 0&&(s=$e);var o=t.call(this)||this;return o._bufferSize=r,o._windowTime=n,o._timestampProvider=s,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=n===1/0,o._bufferSize=Math.max(1,r),o._windowTime=Math.max(1,n),o}return e.prototype.next=function(r){var n=this,s=n.isStopped,o=n._buffer,u=n._infiniteTimeWindow,a=n._timestampProvider,c=n._windowTime;s||(o.push(r),!u&&o.push(a.now()+c)),this._trimBuffer(),t.prototype.next.call(this,r)},e.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),s=this,o=s._infiniteTimeWindow,u=s._buffer,a=u.slice(),c=0;c<a.length&&!r.closed;c+=o?1:2)r.next(a[c]);return this._checkFinalizedStatuses(r),n},e.prototype._trimBuffer=function(){var r=this,n=r._bufferSize,s=r._timestampProvider,o=r._buffer,u=r._infiniteTimeWindow,a=(u?1:2)*n;if(n<1/0&&a<o.length&&o.splice(0,o.length-a),!u){for(var c=s.now(),i=0,f=1;f<o.length&&o[f]<=c;f+=2)i=f;i&&o.splice(0,i+1)}},e}(ie),Jt=function(t){Z(e,t);function e(r,n){return t.call(this)||this}return e.prototype.schedule=function(r,n){return this},e}(ve),Ue={setInterval:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,le([t,e],ce(r)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},Ht=function(t){Z(e,t);function e(r,n){var s=t.call(this,r,n)||this;return s.scheduler=r,s.work=n,s.pending=!1,s}return e.prototype.schedule=function(r,n){var s;if(n===void 0&&(n=0),this.closed)return this;this.state=r;var o=this.id,u=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(u,o,n)),this.pending=!0,this.delay=n,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(u,this.id,n),this},e.prototype.requestAsyncId=function(r,n,s){return s===void 0&&(s=0),Ue.setInterval(r.flush.bind(r,this),s)},e.prototype.recycleAsyncId=function(r,n,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return n;n!=null&&Ue.clearInterval(n)},e.prototype.execute=function(r,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(r,n);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(r,n){var s=!1,o;try{this.work(r)}catch(u){s=!0,o=u||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),o},e.prototype.unsubscribe=function(){if(!this.closed){var r=this,n=r.id,s=r.scheduler,o=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,we(o,this),n!=null&&(this.id=this.recycleAsyncId(s,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(Jt),ze=function(){function t(e,r){r===void 0&&(r=t.now),this.schedulerActionCtor=e,this.now=r}return t.prototype.schedule=function(e,r,n){return r===void 0&&(r=0),new this.schedulerActionCtor(this,e).schedule(n,r)},t.now=$e.now,t}(),Qt=function(t){Z(e,t);function e(r,n){n===void 0&&(n=ze.now);var s=t.call(this,r,n)||this;return s.actions=[],s._active=!1,s}return e.prototype.flush=function(r){var n=this.actions;if(this._active){n.push(r);return}var s;this._active=!0;do if(s=r.execute(r.state,r.delay))break;while(r=n.shift());if(this._active=!1,s){for(;r=n.shift();)r.unsubscribe();throw s}},e}(ze),Xt=new Qt(Ht),he=new F(function(t){return t.complete()});function er(t){return t&&K(t.schedule)}function qe(t){return t[t.length-1]}function tr(t){return K(qe(t))?t.pop():void 0}function We(t){return er(qe(t))?t.pop():void 0}var Ye=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function Ze(t){return K(t==null?void 0:t.then)}function Je(t){return K(t[Oe])}function He(t){return Symbol.asyncIterator&&K(t==null?void 0:t[Symbol.asyncIterator])}function Qe(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function rr(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Xe=rr();function et(t){return K(t==null?void 0:t[Xe])}function tt(t){return Vt(this,arguments,function(){var r,n,s,o;return Le(this,function(u){switch(u.label){case 0:r=t.getReader(),u.label=1;case 1:u.trys.push([1,,9,10]),u.label=2;case 2:return[4,fe(r.read())];case 3:return n=u.sent(),s=n.value,o=n.done,o?[4,fe(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,fe(s)];case 6:return[4,u.sent()];case 7:return u.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function rt(t){return K(t==null?void 0:t.getReader)}function ee(t){if(t instanceof F)return t;if(t!=null){if(Je(t))return nr(t);if(Ye(t))return sr(t);if(Ze(t))return or(t);if(He(t))return nt(t);if(et(t))return ar(t);if(rt(t))return ir(t)}throw Qe(t)}function nr(t){return new F(function(e){var r=t[Oe]();if(K(r.subscribe))return r.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function sr(t){return new F(function(e){for(var r=0;r<t.length&&!e.closed;r++)e.next(t[r]);e.complete()})}function or(t){return new F(function(e){t.then(function(r){e.closed||(e.next(r),e.complete())},function(r){return e.error(r)}).then(null,De)})}function ar(t){return new F(function(e){var r,n;try{for(var s=ue(t),o=s.next();!o.done;o=s.next()){var u=o.value;if(e.next(u),e.closed)return}}catch(a){r={error:a}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}e.complete()})}function nt(t){return new F(function(e){ur(t,e).catch(function(r){return e.error(r)})})}function ir(t){return nt(tt(t))}function ur(t,e){var r,n,s,o;return kt(this,void 0,void 0,function(){var u,a;return Le(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=Lt(t),c.label=1;case 1:return[4,r.next()];case 2:if(n=c.sent(),!!n.done)return[3,4];if(u=n.value,e.next(u),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),s={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function ne(t,e,r,n,s){n===void 0&&(n=0),s===void 0&&(s=!1);var o=e.schedule(function(){r(),s?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(o),!s)return o}function st(t,e){return e===void 0&&(e=0),G(function(r,n){r.subscribe(U(n,function(s){return ne(n,t,function(){return n.next(s)},e)},function(){return ne(n,t,function(){return n.complete()},e)},function(s){return ne(n,t,function(){return n.error(s)},e)}))})}function ot(t,e){return e===void 0&&(e=0),G(function(r,n){n.add(t.schedule(function(){return r.subscribe(n)},e))})}function cr(t,e){return ee(t).pipe(ot(e),st(e))}function lr(t,e){return ee(t).pipe(ot(e),st(e))}function fr(t,e){return new F(function(r){var n=0;return e.schedule(function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())})})}function hr(t,e){return new F(function(r){var n;return ne(r,e,function(){n=t[Xe](),ne(r,e,function(){var s,o,u;try{s=n.next(),o=s.value,u=s.done}catch(a){r.error(a);return}u?r.complete():r.next(o)},0,!0)}),function(){return K(n==null?void 0:n.return)&&n.return()}})}function at(t,e){if(!t)throw new Error("Iterable cannot be null");return new F(function(r){ne(r,e,function(){var n=t[Symbol.asyncIterator]();ne(r,e,function(){n.next().then(function(s){s.done?r.complete():r.next(s.value)})},0,!0)})})}function yr(t,e){return at(tt(t),e)}function pr(t,e){if(t!=null){if(Je(t))return cr(t,e);if(Ye(t))return fr(t,e);if(Ze(t))return lr(t,e);if(He(t))return at(t,e);if(et(t))return hr(t,e);if(rt(t))return yr(t,e)}throw Qe(t)}function Ie(t,e){return e?pr(t,e):ee(t)}function dr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=We(t);return Ie(t,r)}var it=xe(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function W(t,e){return G(function(r,n){var s=0;r.subscribe(U(n,function(o){n.next(t.call(e,o,s++))}))})}var vr=Array.isArray;function mr(t,e){return vr(e)?t.apply(void 0,le([],ce(e))):t(e)}function gr(t){return W(function(e){return mr(t,e)})}var br=Array.isArray,wr=Object.getPrototypeOf,Er=Object.prototype,Ar=Object.keys;function Sr(t){if(t.length===1){var e=t[0];if(br(e))return{args:e,keys:null};if(xr(e)){var r=Ar(e);return{args:r.map(function(n){return e[n]}),keys:r}}}return{args:t,keys:null}}function xr(t){return t&&typeof t=="object"&&wr(t)===Er}function _r(t,e){return t.reduce(function(r,n,s){return r[n]=e[s],r},{})}function te(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=We(t),n=tr(t),s=Sr(t),o=s.args,u=s.keys;if(o.length===0)return Ie([],r);var a=new F(Cr(o,r,u?function(c){return _r(u,c)}:ge));return n?a.pipe(gr(n)):a}function Cr(t,e,r){return r===void 0&&(r=ge),function(n){ut(e,function(){for(var s=t.length,o=new Array(s),u=s,a=s,c=function(f){ut(e,function(){var w=Ie(t[f],e),x=!1;w.subscribe(U(n,function(y){o[f]=y,x||(x=!0,a--),a||n.next(r(o.slice()))},function(){--u||n.complete()}))},n)},i=0;i<s;i++)c(i)},n)}}function ut(t,e,r){t?ne(r,t,e):e()}function Tr(t){return new F(function(e){ee(t()).subscribe(e)})}function Or(t,e,r){return Tr(function(){return t()?e:r})}function be(t,e){return G(function(r,n){var s=0;r.subscribe(U(n,function(o){return t.call(e,o,s++)&&n.next(o)}))})}function ye(t){return G(function(e,r){var n=null,s=!1,o;n=e.subscribe(U(r,void 0,void 0,function(u){o=ee(t(u,ye(t)(e))),n?(n.unsubscribe(),n=null,o.subscribe(r)):s=!0})),s&&(n.unsubscribe(),n=null,o.subscribe(r))})}function J(t,e){return e===void 0&&(e=Xt),G(function(r,n){var s=null,o=null,u=null,a=function(){if(s){s.unsubscribe(),s=null;var i=o;o=null,n.next(i)}};function c(){var i=u+t,f=e.now();if(f<i){s=this.schedule(void 0,i-f),n.add(s);return}a()}r.subscribe(U(n,function(i){o=i,u=e.now(),s||(s=e.schedule(c,t),n.add(s))},function(){a(),n.complete()},void 0,function(){o=s=null}))})}function $r(t){return G(function(e,r){var n=!1;e.subscribe(U(r,function(s){n=!0,r.next(s)},function(){n||r.next(t),r.complete()}))})}function Ir(t){return t<=0?function(){return he}:G(function(e,r){var n=0;e.subscribe(U(r,function(s){++n<=t&&(r.next(s),t<=n&&r.complete())}))})}function Br(t,e){return e===void 0&&(e=ge),t=t??Pr,G(function(r,n){var s,o=!0;r.subscribe(U(n,function(u){var a=e(u);(o||!t(s,a))&&(o=!1,s=a,n.next(u))}))})}function Pr(t,e){return t===e}function Mr(t){return t===void 0&&(t=jr),G(function(e,r){var n=!1;e.subscribe(U(r,function(s){n=!0,r.next(s)},function(){return n?r.complete():r.error(t())}))})}function jr(){return new it}function kr(t,e){var r=arguments.length>=2;return function(n){return n.pipe(ge,Ir(1),r?$r(e):Mr(function(){return new it}))}}function ct(t){t===void 0&&(t={});var e=t.connector,r=e===void 0?function(){return new ie}:e,n=t.resetOnError,s=n===void 0?!0:n,o=t.resetOnComplete,u=o===void 0?!0:o,a=t.resetOnRefCountZero,c=a===void 0?!0:a;return function(i){var f,w,x,y=0,S=!1,m=!1,d=function(){w==null||w.unsubscribe(),w=void 0},b=function(){d(),f=x=void 0,S=m=!1},O=function(){var $=f;b(),$==null||$.unsubscribe()};return G(function($,h){y++,!m&&!S&&d();var p=x=x??r();h.add(function(){y--,y===0&&!m&&!S&&(w=Be(O,c))}),p.subscribe(h),!f&&y>0&&(f=new me({next:function(E){return p.next(E)},error:function(E){m=!0,d(),w=Be(b,s,E),p.error(E)},complete:function(){S=!0,d(),w=Be(b,u),p.complete()}}),ee($).subscribe(f))})(i)}}function Be(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(e===!0){t();return}if(e!==!1){var s=new me({next:function(){s.unsubscribe(),t()}});return ee(e.apply(void 0,le([],ce(r)))).subscribe(s)}}function se(t,e,r){var n,s=!1;return n=t,ct({connector:function(){return new Zt(n,e,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:s})}function Vr(t,e){return G(function(r,n){var s=null,o=0,u=!1,a=function(){return u&&!s&&n.complete()};r.subscribe(U(n,function(c){s==null||s.unsubscribe();var i=0,f=o++;ee(t(c,f)).subscribe(s=U(n,function(w){return n.next(e?e(c,w,f,i++):w)},function(){s=null,a()}))},function(){u=!0,a()}))})}function Lr(t){return G(function(e,r){ee(t).subscribe(U(r,function(){return r.complete()},Ce)),!r.closed&&e.subscribe(r)})}function lt(t){const e=t.filter(r=>r!==null&&!isNaN(r));return e.length===0?null:e.reduce((r,n)=>r+n,0)}function ft(t){const e=t.filter(n=>n!==null&&!isNaN(n));return e.length===0?null:e.reduce((n,s)=>n+s,0)/e.length}function ht(t){const e=t.filter(s=>s!==null&&!isNaN(s));if(e.length===0)return null;const r=[...e].sort((s,o)=>s-o),n=Math.floor(r.length/2);return r.length%2===0?(r[n-1]+r[n])/2:r[n]}function yt(t){const e=t.filter(r=>r!==null&&!isNaN(r));return e.length===0?null:Math.min(...e)}function pt(t){const e=t.filter(r=>r!==null&&!isNaN(r));return e.length===0?null:Math.max(...e)}function dt(t){return t.filter(e=>e!==null&&!isNaN(e)).length}function vt(t){const e=t.filter(r=>r!==null&&!isNaN(r));return e.length>0?e[0]:null}function pe(t,e){switch(e){case"sum":return lt(t);case"mean":return ft(t);case"median":return ht(t);case"min":return yt(t);case"max":return pt(t);case"count":return dt(t);case"none":return vt(t);default:throw new Error(`Unknown aggregate type: ${e}`)}}function mt(t,e){let r;e.colorScheme==="auto"?r="light":r=e.colorScheme;const n=e.colors[r].data,s=t%n.length;return n[s]}function D(t,e,r){let n;switch(t){case"index":n=e.index??0;break;case"series":n=e.seriesIndex??0;break;case"category":n=e.categoryIndex??0;break;case"dataset":n=e.datasetIndex??0;break;default:n=0}return mt(n,r)}function H(t){return Object.prototype.toString.call(t)==="[object Object]"}function gt(t){return Object.prototype.toString.call(t)==="[object Function]"}function Pe(t){return!!(t&&t.nodeType)}function Y(t,e){if(H(e)===!1||H(t)===!1)return Object.assign({},t);const r=(n,s)=>{const o=Object.assign({},n);for(let u of Object.keys(s)){if(!(u in n))continue;let a;H(s[u])&&H(n[u])?(a=r(n[u],s[u]),o[u]=a):o[u]=s[u]}return o};return r(t,e)}function Kr(t=0){try{let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}catch(e){console.error(e)}}function bt(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");return e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),e.setAttribute("xmls","http://www.w3.org/2000/svg"),e.setAttribute("version","1.1"),e.style.position="absolute",t&&e.classList.add(t),e}function Rr(t){const e=document.createElement("canvas");return e.style.position="absolute",t&&e.classList.add(t),e}function wt(t){const e=document.createElementNS("http://www.w3.org/2000/svg","g");return t&&e.classList.add(t),e}function Me(t){const e=document.createElement("canvas");return t&&e.classList.add(t),e}function Fr(t){const e=document.createElement("div");return t&&e.classList.add(t),e}function Et(t){if(Pe(t))for(;t.firstChild;)t.removeChild(t.firstChild)}function T(t,e,r=""){return e.ignore?"":t[e.from]||r}function je(t){return`[OrbCharts ${t}]:`}function q(t){return`${je("error")} ${t.message}`}function de({from:t,systemMessage:e}){return`unexpected error from '${t}':
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=r}});function we(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}var pe=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,r,n,s,o;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var a=ue(u),c=a.next();!c.done;c=a.next()){var i=c.value;i.remove(this)}}catch(m){e={error:m}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}else u.remove(this);var f=this.initialTeardown;if(K(f))try{f()}catch(m){o=m instanceof _e?m.errors:[m]}var w=this._finalizers;if(w){this._finalizers=null;try{for(var x=ue(w),y=x.next();!y.done;y=x.next()){var S=y.value;try{De(S)}catch(m){o=o??[],m instanceof _e?o=le(le([],ce(o)),ce(m.errors)):o.push(m)}}}catch(m){n={error:m}}finally{try{y&&!y.done&&(s=x.return)&&s.call(x)}finally{if(n)throw n.error}}}if(o)throw new _e(o)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)De(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(e)}},t.prototype._hasParent=function(e){var r=this._parentage;return r===e||Array.isArray(r)&&r.includes(e)},t.prototype._addParent=function(e){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(e),r):r?[r,e]:e},t.prototype._removeParent=function(e){var r=this._parentage;r===e?this._parentage=null:Array.isArray(r)&&we(r,e)},t.prototype.remove=function(e){var r=this._finalizers;r&&we(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),Re=pe.EMPTY;function Fe(t){return t instanceof pe||t&&"closed"in t&&K(t.remove)&&K(t.add)&&K(t.unsubscribe)}function De(t){K(t)?t():t.unsubscribe()}var Kt={Promise:void 0},Rt={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,le([t,e],ce(r)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function Ne(t){Rt.setTimeout(function(){throw t})}function Ce(){}function Ee(t){t()}var Te=function(t){W(e,t);function e(r){var n=t.call(this)||this;return n.isStopped=!1,r?(n.destination=r,Fe(r)&&r.add(n)):n.destination=Nt,n}return e.create=function(r,n,s){return new ve(r,n,s)},e.prototype.next=function(r){this.isStopped||this._next(r)},e.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(r){this.destination.next(r)},e.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(pe),Ft=function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var r=this.partialObserver;if(r.next)try{r.next(e)}catch(n){Ae(n)}},t.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(n){Ae(n)}else Ae(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){Ae(r)}},t}(),ve=function(t){W(e,t);function e(r,n,s){var o=t.call(this)||this,u;return K(r)||!r?u={next:r??void 0,error:n??void 0,complete:s??void 0}:u=r,o.destination=new Ft(u),o}return e}(Te);function Ae(t){Ne(t)}function Dt(t){throw t}var Nt={closed:!0,next:Ce,error:Dt,complete:Ce},Oe=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Se(t){return t}function Gt(t){return t.length===0?Se:t.length===1?t[0]:function(r){return t.reduce(function(n,s){return s(n)},r)}}var F=function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(e,r,n){var s=this,o=zt(e)?e:new ve(e,r,n);return Ee(function(){var u=s,a=u.operator,c=u.source;o.add(a?a.call(o,c):c?s._subscribe(o):s._trySubscribe(o))}),o},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(r){e.error(r)}},t.prototype.forEach=function(e,r){var n=this;return r=Ge(r),new r(function(s,o){var u=new ve({next:function(a){try{e(a)}catch(c){o(c),u.unsubscribe()}},error:o,complete:s});n.subscribe(u)})},t.prototype._subscribe=function(e){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(e)},t.prototype[Oe]=function(){return this},t.prototype.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Gt(e)(this)},t.prototype.toPromise=function(e){var r=this;return e=Ge(e),new e(function(n,s){var o;r.subscribe(function(u){return o=u},function(u){return s(u)},function(){return n(o)})})},t.create=function(e){return new t(e)},t}();function Ge(t){var e;return(e=t??Kt.Promise)!==null&&e!==void 0?e:Promise}function Ut(t){return t&&K(t.next)&&K(t.error)&&K(t.complete)}function zt(t){return t&&t instanceof Te||Ut(t)&&Fe(t)}function qt(t){return K(t==null?void 0:t.lift)}function Y(t){return function(e){if(qt(e))return e.lift(function(r){try{return t(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function Z(t,e,r,n,s){return new Wt(t,e,r,n,s)}var Wt=function(t){W(e,t);function e(r,n,s,o,u,a){var c=t.call(this,r)||this;return c.onFinalize=u,c.shouldUnsubscribe=a,c._next=n?function(i){try{n(i)}catch(f){r.error(f)}}:t.prototype._next,c._error=o?function(i){try{o(i)}catch(f){r.error(f)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=s?function(){try{s()}catch(i){r.error(i)}finally{this.unsubscribe()}}:t.prototype._complete,c}return e.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},e}(Te),Yt=Ke(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ie=function(t){W(e,t);function e(){var r=t.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return e.prototype.lift=function(r){var n=new Ue(this,this);return n.operator=r,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Yt},e.prototype.next=function(r){var n=this;Ee(function(){var s,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var u=ue(n.currentObservers),a=u.next();!a.done;a=u.next()){var c=a.value;c.next(r)}}catch(i){s={error:i}}finally{try{a&&!a.done&&(o=u.return)&&o.call(u)}finally{if(s)throw s.error}}}})},e.prototype.error=function(r){var n=this;Ee(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var s=n.observers;s.length;)s.shift().error(r)}})},e.prototype.complete=function(){var r=this;Ee(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(r){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,r)},e.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},e.prototype._innerSubscribe=function(r){var n=this,s=this,o=s.hasError,u=s.isStopped,a=s.observers;return o||u?Re:(this.currentObservers=null,a.push(r),new pe(function(){n.currentObservers=null,we(a,r)}))},e.prototype._checkFinalizedStatuses=function(r){var n=this,s=n.hasError,o=n.thrownError,u=n.isStopped;s?r.error(o):u&&r.complete()},e.prototype.asObservable=function(){var r=new F;return r.source=this,r},e.create=function(r,n){return new Ue(r,n)},e}(F),Ue=function(t){W(e,t);function e(r,n){var s=t.call(this)||this;return s.destination=r,s.source=n,s}return e.prototype.next=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.next)===null||s===void 0||s.call(n,r)},e.prototype.error=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.error)===null||s===void 0||s.call(n,r)},e.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},e.prototype._subscribe=function(r){var n,s;return(s=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&s!==void 0?s:Re},e}(ie),G=function(t){W(e,t);function e(r){var n=t.call(this)||this;return n._value=r,n}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(r){var n=t.prototype._subscribe.call(this,r);return!n.closed&&r.next(this._value),n},e.prototype.getValue=function(){var r=this,n=r.hasError,s=r.thrownError,o=r._value;if(n)throw s;return this._throwIfClosed(),o},e.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},e}(ie),$e={now:function(){return($e.delegate||Date).now()},delegate:void 0},Zt=function(t){W(e,t);function e(r,n,s){r===void 0&&(r=1/0),n===void 0&&(n=1/0),s===void 0&&(s=$e);var o=t.call(this)||this;return o._bufferSize=r,o._windowTime=n,o._timestampProvider=s,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=n===1/0,o._bufferSize=Math.max(1,r),o._windowTime=Math.max(1,n),o}return e.prototype.next=function(r){var n=this,s=n.isStopped,o=n._buffer,u=n._infiniteTimeWindow,a=n._timestampProvider,c=n._windowTime;s||(o.push(r),!u&&o.push(a.now()+c)),this._trimBuffer(),t.prototype.next.call(this,r)},e.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),s=this,o=s._infiniteTimeWindow,u=s._buffer,a=u.slice(),c=0;c<a.length&&!r.closed;c+=o?1:2)r.next(a[c]);return this._checkFinalizedStatuses(r),n},e.prototype._trimBuffer=function(){var r=this,n=r._bufferSize,s=r._timestampProvider,o=r._buffer,u=r._infiniteTimeWindow,a=(u?1:2)*n;if(n<1/0&&a<o.length&&o.splice(0,o.length-a),!u){for(var c=s.now(),i=0,f=1;f<o.length&&o[f]<=c;f+=2)i=f;i&&o.splice(0,i+1)}},e}(ie),Jt=function(t){W(e,t);function e(r,n){return t.call(this)||this}return e.prototype.schedule=function(r,n){return this},e}(pe),ze={setInterval:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,le([t,e],ce(r)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},Ht=function(t){W(e,t);function e(r,n){var s=t.call(this,r,n)||this;return s.scheduler=r,s.work=n,s.pending=!1,s}return e.prototype.schedule=function(r,n){var s;if(n===void 0&&(n=0),this.closed)return this;this.state=r;var o=this.id,u=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(u,o,n)),this.pending=!0,this.delay=n,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(u,this.id,n),this},e.prototype.requestAsyncId=function(r,n,s){return s===void 0&&(s=0),ze.setInterval(r.flush.bind(r,this),s)},e.prototype.recycleAsyncId=function(r,n,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return n;n!=null&&ze.clearInterval(n)},e.prototype.execute=function(r,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(r,n);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(r,n){var s=!1,o;try{this.work(r)}catch(u){s=!0,o=u||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),o},e.prototype.unsubscribe=function(){if(!this.closed){var r=this,n=r.id,s=r.scheduler,o=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,we(o,this),n!=null&&(this.id=this.recycleAsyncId(s,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(Jt),qe=function(){function t(e,r){r===void 0&&(r=t.now),this.schedulerActionCtor=e,this.now=r}return t.prototype.schedule=function(e,r,n){return r===void 0&&(r=0),new this.schedulerActionCtor(this,e).schedule(n,r)},t.now=$e.now,t}(),Qt=function(t){W(e,t);function e(r,n){n===void 0&&(n=qe.now);var s=t.call(this,r,n)||this;return s.actions=[],s._active=!1,s}return e.prototype.flush=function(r){var n=this.actions;if(this._active){n.push(r);return}var s;this._active=!0;do if(s=r.execute(r.state,r.delay))break;while(r=n.shift());if(this._active=!1,s){for(;r=n.shift();)r.unsubscribe();throw s}},e}(qe),Xt=new Qt(Ht),me=new F(function(t){return t.complete()});function er(t){return t&&K(t.schedule)}function We(t){return t[t.length-1]}function tr(t){return K(We(t))?t.pop():void 0}function Ye(t){return er(We(t))?t.pop():void 0}var Ze=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function Je(t){return K(t==null?void 0:t.then)}function He(t){return K(t[Oe])}function Qe(t){return Symbol.asyncIterator&&K(t==null?void 0:t[Symbol.asyncIterator])}function Xe(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function rr(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var et=rr();function tt(t){return K(t==null?void 0:t[et])}function rt(t){return Lt(this,arguments,function(){var r,n,s,o;return Ve(this,function(u){switch(u.label){case 0:r=t.getReader(),u.label=1;case 1:u.trys.push([1,,9,10]),u.label=2;case 2:return[4,fe(r.read())];case 3:return n=u.sent(),s=n.value,o=n.done,o?[4,fe(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,fe(s)];case 6:return[4,u.sent()];case 7:return u.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function nt(t){return K(t==null?void 0:t.getReader)}function ee(t){if(t instanceof F)return t;if(t!=null){if(He(t))return nr(t);if(Ze(t))return sr(t);if(Je(t))return or(t);if(Qe(t))return st(t);if(tt(t))return ar(t);if(nt(t))return ir(t)}throw Xe(t)}function nr(t){return new F(function(e){var r=t[Oe]();if(K(r.subscribe))return r.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function sr(t){return new F(function(e){for(var r=0;r<t.length&&!e.closed;r++)e.next(t[r]);e.complete()})}function or(t){return new F(function(e){t.then(function(r){e.closed||(e.next(r),e.complete())},function(r){return e.error(r)}).then(null,Ne)})}function ar(t){return new F(function(e){var r,n;try{for(var s=ue(t),o=s.next();!o.done;o=s.next()){var u=o.value;if(e.next(u),e.closed)return}}catch(a){r={error:a}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}e.complete()})}function st(t){return new F(function(e){ur(t,e).catch(function(r){return e.error(r)})})}function ir(t){return st(rt(t))}function ur(t,e){var r,n,s,o;return kt(this,void 0,void 0,function(){var u,a;return Ve(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=Vt(t),c.label=1;case 1:return[4,r.next()];case 2:if(n=c.sent(),!!n.done)return[3,4];if(u=n.value,e.next(u),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),s={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function ne(t,e,r,n,s){n===void 0&&(n=0),s===void 0&&(s=!1);var o=e.schedule(function(){r(),s?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(o),!s)return o}function ot(t,e){return e===void 0&&(e=0),Y(function(r,n){r.subscribe(Z(n,function(s){return ne(n,t,function(){return n.next(s)},e)},function(){return ne(n,t,function(){return n.complete()},e)},function(s){return ne(n,t,function(){return n.error(s)},e)}))})}function at(t,e){return e===void 0&&(e=0),Y(function(r,n){n.add(t.schedule(function(){return r.subscribe(n)},e))})}function cr(t,e){return ee(t).pipe(at(e),ot(e))}function lr(t,e){return ee(t).pipe(at(e),ot(e))}function fr(t,e){return new F(function(r){var n=0;return e.schedule(function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())})})}function hr(t,e){return new F(function(r){var n;return ne(r,e,function(){n=t[et](),ne(r,e,function(){var s,o,u;try{s=n.next(),o=s.value,u=s.done}catch(a){r.error(a);return}u?r.complete():r.next(o)},0,!0)}),function(){return K(n==null?void 0:n.return)&&n.return()}})}function it(t,e){if(!t)throw new Error("Iterable cannot be null");return new F(function(r){ne(r,e,function(){var n=t[Symbol.asyncIterator]();ne(r,e,function(){n.next().then(function(s){s.done?r.complete():r.next(s.value)})},0,!0)})})}function yr(t,e){return it(rt(t),e)}function dr(t,e){if(t!=null){if(He(t))return cr(t,e);if(Ze(t))return fr(t,e);if(Je(t))return lr(t,e);if(Qe(t))return it(t,e);if(tt(t))return hr(t,e);if(nt(t))return yr(t,e)}throw Xe(t)}function Ie(t,e){return e?dr(t,e):ee(t)}function pr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=Ye(t);return Ie(t,r)}function z(t,e){return Y(function(r,n){var s=0;r.subscribe(Z(n,function(o){n.next(t.call(e,o,s++))}))})}var vr=Array.isArray;function mr(t,e){return vr(e)?t.apply(void 0,le([],ce(e))):t(e)}function gr(t){return z(function(e){return mr(t,e)})}var br=Array.isArray,wr=Object.getPrototypeOf,Er=Object.prototype,Ar=Object.keys;function Sr(t){if(t.length===1){var e=t[0];if(br(e))return{args:e,keys:null};if(xr(e)){var r=Ar(e);return{args:r.map(function(n){return e[n]}),keys:r}}}return{args:t,keys:null}}function xr(t){return t&&typeof t=="object"&&wr(t)===Er}function _r(t,e){return t.reduce(function(r,n,s){return r[n]=e[s],r},{})}function te(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=Ye(t),n=tr(t),s=Sr(t),o=s.args,u=s.keys;if(o.length===0)return Ie([],r);var a=new F(Cr(o,r,u?function(c){return _r(u,c)}:Se));return n?a.pipe(gr(n)):a}function Cr(t,e,r){return r===void 0&&(r=Se),function(n){ut(e,function(){for(var s=t.length,o=new Array(s),u=s,a=s,c=function(f){ut(e,function(){var w=Ie(t[f],e),x=!1;w.subscribe(Z(n,function(y){o[f]=y,x||(x=!0,a--),a||n.next(r(o.slice()))},function(){--u||n.complete()}))},n)},i=0;i<s;i++)c(i)},n)}}function ut(t,e,r){t?ne(r,t,e):e()}function Tr(t){return new F(function(e){ee(t()).subscribe(e)})}function Or(t,e,r){return Tr(function(){return t()?e:r})}function ge(t,e){return Y(function(r,n){var s=0;r.subscribe(Z(n,function(o){return t.call(e,o,s++)&&n.next(o)}))})}function he(t){return Y(function(e,r){var n=null,s=!1,o;n=e.subscribe(Z(r,void 0,void 0,function(u){o=ee(t(u,he(t)(e))),n?(n.unsubscribe(),n=null,o.subscribe(r)):s=!0})),s&&(n.unsubscribe(),n=null,o.subscribe(r))})}function J(t,e){return e===void 0&&(e=Xt),Y(function(r,n){var s=null,o=null,u=null,a=function(){if(s){s.unsubscribe(),s=null;var i=o;o=null,n.next(i)}};function c(){var i=u+t,f=e.now();if(f<i){s=this.schedule(void 0,i-f),n.add(s);return}a()}r.subscribe(Z(n,function(i){o=i,u=e.now(),s||(s=e.schedule(c,t),n.add(s))},function(){a(),n.complete()},void 0,function(){o=s=null}))})}function $r(t,e){return e===void 0&&(e=Se),t=t??Ir,Y(function(r,n){var s,o=!0;r.subscribe(Z(n,function(u){var a=e(u);(o||!t(s,a))&&(o=!1,s=a,n.next(u))}))})}function Ir(t,e){return t===e}function ct(t){t===void 0&&(t={});var e=t.connector,r=e===void 0?function(){return new ie}:e,n=t.resetOnError,s=n===void 0?!0:n,o=t.resetOnComplete,u=o===void 0?!0:o,a=t.resetOnRefCountZero,c=a===void 0?!0:a;return function(i){var f,w,x,y=0,S=!1,m=!1,p=function(){w==null||w.unsubscribe(),w=void 0},b=function(){p(),f=x=void 0,S=m=!1},O=function(){var $=f;b(),$==null||$.unsubscribe()};return Y(function($,h){y++,!m&&!S&&p();var d=x=x??r();h.add(function(){y--,y===0&&!m&&!S&&(w=Be(O,c))}),d.subscribe(h),!f&&y>0&&(f=new ve({next:function(E){return d.next(E)},error:function(E){m=!0,p(),w=Be(b,s,E),d.error(E)},complete:function(){S=!0,p(),w=Be(b,u),d.complete()}}),ee($).subscribe(f))})(i)}}function Be(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(e===!0){t();return}if(e!==!1){var s=new ve({next:function(){s.unsubscribe(),t()}});return ee(e.apply(void 0,le([],ce(r)))).subscribe(s)}}function se(t,e,r){var n,s=!1;return n=t,ct({connector:function(){return new Zt(n,e,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:s})}function Br(t,e){return Y(function(r,n){var s=null,o=0,u=!1,a=function(){return u&&!s&&n.complete()};r.subscribe(Z(n,function(c){s==null||s.unsubscribe();var i=0,f=o++;ee(t(c,f)).subscribe(s=Z(n,function(w){return n.next(e?e(c,w,f,i++):w)},function(){s=null,a()}))},function(){u=!0,a()}))})}function be(t){return Y(function(e,r){ee(t).subscribe(Z(r,function(){return r.complete()},Ce)),!r.closed&&e.subscribe(r)})}function lt(t){const e=t.filter(r=>r!==null&&!isNaN(r));return e.length===0?null:e.reduce((r,n)=>r+n,0)}function ft(t){const e=t.filter(n=>n!==null&&!isNaN(n));return e.length===0?null:e.reduce((n,s)=>n+s,0)/e.length}function ht(t){const e=t.filter(s=>s!==null&&!isNaN(s));if(e.length===0)return null;const r=[...e].sort((s,o)=>s-o),n=Math.floor(r.length/2);return r.length%2===0?(r[n-1]+r[n])/2:r[n]}function yt(t){const e=t.filter(r=>r!==null&&!isNaN(r));return e.length===0?null:Math.min(...e)}function dt(t){const e=t.filter(r=>r!==null&&!isNaN(r));return e.length===0?null:Math.max(...e)}function pt(t){return t.filter(e=>e!==null&&!isNaN(e)).length}function vt(t){const e=t.filter(r=>r!==null&&!isNaN(r));return e.length>0?e[0]:null}function ye(t,e){switch(e){case"sum":return lt(t);case"mean":return ft(t);case"median":return ht(t);case"min":return yt(t);case"max":return dt(t);case"count":return pt(t);case"none":return vt(t);default:throw new Error(`Unknown aggregate type: ${e}`)}}function mt(t,e){let r;e.colorScheme==="auto"?r="light":r=e.colorScheme;const n=e.colors[r].data,s=t%n.length;return n[s]}function D(t,e,r){let n;switch(t){case"index":n=e.index??0;break;case"series":n=e.seriesIndex??0;break;case"category":n=e.categoryIndex??0;break;case"dataset":n=e.datasetIndex??0;break;default:n=0}return mt(n,r)}function H(t){return Object.prototype.toString.call(t)==="[object Object]"}function gt(t){return Object.prototype.toString.call(t)==="[object Function]"}function Pe(t){return!!(t&&t.nodeType)}function q(t,e){if(H(e)===!1||H(t)===!1)return Object.assign({},t);const r=(n,s)=>{const o=Object.assign({},n);for(let u of Object.keys(s)){if(!(u in n))continue;let a;H(s[u])&&H(n[u])?(a=r(n[u],s[u]),o[u]=a):o[u]=s[u]}return o};return r(t,e)}function Pr(t=0){try{let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}catch(e){console.error(e)}}function bt(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");return e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),e.setAttribute("xmls","http://www.w3.org/2000/svg"),e.setAttribute("version","1.1"),e.style.position="absolute",t&&e.classList.add(t),e}function Mr(t){const e=document.createElement("canvas");return e.style.position="absolute",t&&e.classList.add(t),e}function wt(t){const e=document.createElementNS("http://www.w3.org/2000/svg","g");return t&&e.classList.add(t),e}function Me(t){const e=document.createElement("canvas");return t&&e.classList.add(t),e}function jr(t){const e=document.createElement("div");return t&&e.classList.add(t),e}function Et(t){if(Pe(t))for(;t.firstChild;)t.removeChild(t.firstChild)}function T(t,e,r=""){return e.ignore?"":t[e.from]||r}function je(t){return`[OrbCharts ${t}]:`}function U(t){return`${je("error")} ${t.message}`}function de({from:t,systemMessage:e}){return`unexpected error from '${t}':
|
|
4
4
|
${e}`}function Q({columnName:t,expectToBe:e,from:r}){return`Invalid value: '${t}' must be '${e}'
|
|
5
5
|
|
|
6
6
|
----> find in '${r}'`}function X({columnName:t,expectToBe:e,from:r}){return`${je("warning")} Value is not correct: '${t}' suppose to be '${e}', it may cause unexpected errors.'
|
|
7
7
|
|
|
8
|
-
----> find in '${r}'`}function At(t){return new F(e=>{const r=new ResizeObserver(n=>{const s=n[0];s&&s.contentRect&&e.next(s.contentRect)});return r.observe(t),function(){r.unobserve(t)}})}function St(t){return`orbcharts-${t}`}function xt(t,e){return`${St(t)}-${e}`}function Dr(t,e){const r={string:o=>typeof o=="string",number:o=>typeof o=="number",boolean:o=>typeof o=="boolean",object:o=>H(o),"object[]":o=>Array.isArray(o)&&o.every(u=>H(u)),"string[]":o=>Array.isArray(o)&&o.every(u=>typeof u=="string"),"number[]":o=>Array.isArray(o)&&o.every(u=>typeof u=="number"),Function:o=>gt(o),null:o=>o===null,undefined:o=>o===void 0},n={ColorType:o=>o==="none"||o==="data"||o==="primary"||o==="secondary"||o==="dataContrast"||o==="background"};return Object.keys(t).find(o=>{if(e[o]){const u=e[o],a=t[o];if(a===void 0)return!1;if(u.toBeTypes){if(u.toBeTypes.some(f=>r[f](a))===!1)return!0}else if(u.toBe){const{toBe:c,test:i}=u;if(i(a)===!1)return!0}else if(u.toBeOption){const c=u.toBeOption;if(n[c](a)===!1)return!0}}return!1})}function R(t,e){const r=Dr(t,e);if(r){const n=e[r],s=n.toBeTypes?n.toBeTypes.join(" | "):n.toBe?n.toBe:n.toBeOption?n.toBeOption:"";return{status:"error",columnName:r,expectToBe:s}}else return{status:"success",columnName:"",expectToBe:""}}const _t={width:"auto",height:"auto",resizeDebounce:50},Ct={dataset:{from:"dataset",sort:"original",ignore:!1},series:{from:"series",sort:"original",ignore:!1},category:{from:"category",sort:"original",ignore:!1},value:{from:"value",sort:"original",aggregate:"none"},multivariate:[{from:"x",name:"x"},{from:"y",name:"y"},{from:"z",name:"z"}],color:{by:"series"}},Tt={colorScheme:"light",colors:{light:{data:["#4E79A7","#F28E2B","#E15759","#76B7B2","#59A14F","#EDC948","#B07AA1","#FF9DA7","#9C755F","#BAB0AC"],primary:"#000000",secondary:"#e0e0e0",dataContrast:["#ffffff","#000000"],background:"#FFFFFF"},dark:{data:["#7EA6E0","#FFB86B","#FF7A7A","#6ED0CC","#7ED97A","#FFE06E","#D4A5D8","#FFB3BA","#C89F7A","#D3D3D3"],primary:"#FFFFFF",secondary:"#e0e0e0",dataContrast:["#ffffff","#000000"],background:"#000000"}},fontSize:"0.875rem"},Nr=(t,e,r)=>{const n=new Map,s=Array.isArray(t[0]);s?t.forEach((a,c)=>{a.forEach(i=>{const f=T(i,e.dataset,`dataset-${c}`);n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const c=T(a,e.dataset,"");n.has(c)||n.set(c,[]),n.get(c).push(a)});let o=Array.from(n.keys());if(Array.isArray(e.dataset.sort))o=e.dataset.sort.filter(a=>n.has(a)).concat(o.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];s?t.forEach((c,i)=>{c.forEach(f=>{const w=T(f,e.dataset,`dataset-${i}`);a.includes(w)||a.push(w)})}):t.forEach(c=>{const i=T(c,e.dataset,"");a.includes(i)||a.push(i)}),o=a}else e.dataset.sort==="alphabetical"&&o.sort((a,c)=>a.localeCompare(c,void 0,{numeric:!0}));const u=[];return o.forEach((a,c)=>{const i=n.get(a),f=new Map;i.forEach(m=>{const d=T(m,e.series,"");f.has(d)||f.set(d,[]),f.get(d).push(m)});let w=Array.from(f.keys());if(Array.isArray(e.series.sort))w=e.series.sort.filter(m=>f.has(m)).concat(w.filter(m=>!e.series.sort.includes(m)));else if(e.series.sort==="original"){const m=[];i.forEach(d=>{const b=T(d,e.series,"");m.includes(b)||m.push(b)}),w=m}else e.series.sort==="alphabetical"&&w.sort((m,d)=>m.localeCompare(d,void 0,{numeric:!0}));const x=[];if(e.category.sort==="original")i.forEach(m=>{const d=T(m,e.category,"");x.includes(d)||x.push(d)});else if(e.category.sort==="alphabetical"){const m=new Set;i.forEach(d=>{m.add(T(d,e.category,""))}),x.push(...Array.from(m).sort((d,b)=>d.localeCompare(b,void 0,{numeric:!0})))}else if(Array.isArray(e.category.sort)){const m=[];i.forEach(b=>{const O=T(b,e.category,"");m.includes(O)||m.push(O)});const d=e.category.sort;x.push(...d.filter(b=>m.includes(b)),...m.filter(b=>!d.includes(b)))}const y=new Map;x.forEach((m,d)=>{y.set(m,d)});const S=[];w.forEach((m,d)=>{const b=f.get(m),O=new Map;b.forEach(p=>{const E=T(p,e.category,"");O.has(E)||O.set(E,[]),O.get(E).push(p)});const $=x.filter(p=>O.has(p)),h=[];e.category.sort==="original"&&e.value.aggregate==="none"?(b.forEach((p,E)=>{const j=T(p,e.category,""),I=y.get(j),l=p[e.value.from];h.push({id:p.id||`${a}-${m}-${j}-${E}`,index:I,modelType:"series",name:p.name||"",data:p.data,value:typeof l=="number"?l:null,color:D(e.color.by,{index:I,seriesIndex:d,categoryIndex:I,datasetIndex:c},r),series:m,seriesIndex:d,category:j,categoryIndex:I})}),e.value.sort==="asc"?h.sort((p,E)=>p.value===null&&E.value===null?0:p.value===null?1:E.value===null?-1:p.value-E.value):e.value.sort==="desc"&&h.sort((p,E)=>p.value===null&&E.value===null?0:p.value===null?1:E.value===null?-1:E.value-p.value)):$.forEach(p=>{const E=y.get(p),j=O.get(p);if(e.value.aggregate==="none"){let I=j.map((l,g)=>{const C=l[e.value.from];return{id:l.id||`${a}-${m}-${p}-${g}`,index:E,modelType:"series",name:l.name||"",data:l.data,value:typeof C=="number"?C:null,color:D(e.color.by,{index:E,seriesIndex:d,categoryIndex:E,datasetIndex:c},r),series:m,seriesIndex:d,category:p,categoryIndex:E}});e.value.sort==="asc"?I.sort((l,g)=>l.value===null&&g.value===null?0:l.value===null?1:g.value===null?-1:l.value-g.value):e.value.sort==="desc"&&I.sort((l,g)=>l.value===null&&g.value===null?0:l.value===null?1:g.value===null?-1:g.value-l.value),h.push(...I)}else{const I=j.map(B=>{if(e.value.aggregate==="count")return 1;const v=B[e.value.from];return typeof v=="number"?v:null}),l=pe(I,e.value.aggregate),g=j[0],C={id:g.id||`${a}-${m}-${p}-aggregated`,index:E,modelType:"series",name:g.name||p,data:g.data,value:l,color:D(e.color.by,{index:E,seriesIndex:d,categoryIndex:E,datasetIndex:c},r),series:m,seriesIndex:d,category:p,categoryIndex:E};h.push(C)}}),S.push(h)}),u.push(S)}),u},Gr=(t,e,r)=>{const n=new Map,s=Array.isArray(t[0]);s?t.forEach((a,c)=>{a.forEach(i=>{const f=T(i,e.dataset,`dataset-${c}`);n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const c=T(a,e.dataset,"");n.has(c)||n.set(c,[]),n.get(c).push(a)});let o=Array.from(n.keys());if(Array.isArray(e.dataset.sort))o=e.dataset.sort.filter(a=>n.has(a)).concat(o.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];s?t.forEach((c,i)=>{c.forEach(f=>{const w=T(f,e.dataset,`dataset-${i}`);a.includes(w)||a.push(w)})}):t.forEach(c=>{const i=T(c,e.dataset,"");a.includes(i)||a.push(i)}),o=a}else e.dataset.sort==="alphabetical"&&o.sort((a,c)=>a.localeCompare(c,void 0,{numeric:!0}));const u=[];return o.forEach((a,c)=>{const i=n.get(a),f=new Map;i.forEach(d=>{const b=T(d,e.series,"");f.has(b)||f.set(b,[]),f.get(b).push(d)});let w=Array.from(f.keys());if(Array.isArray(e.series.sort))w=e.series.sort.filter(d=>f.has(d)).concat(w.filter(d=>!e.series.sort.includes(d)));else if(e.series.sort==="original"){const d=[];i.forEach(b=>{const O=T(b,e.series,"");d.includes(O)||d.push(O)}),w=d}else e.series.sort==="alphabetical"&&w.sort((d,b)=>d.localeCompare(b,void 0,{numeric:!0}));const x=[];i.forEach(d=>{const b=T(d,e.category,"");x.includes(b)||x.push(b)});const y=new Set(x);let S=Array.from(y);Array.isArray(e.category.sort)?S=e.category.sort.filter(d=>y.has(d)).concat(S.filter(d=>!e.category.sort.includes(d))):e.category.sort==="original"?S=x:e.category.sort==="alphabetical"&&S.sort((d,b)=>d.localeCompare(b,void 0,{numeric:!0}));const m=[];w.forEach((d,b)=>{const O=f.get(d),$=new Map;O.forEach(p=>{const E=T(p,e.category,"");$.has(E)||$.set(E,[]),$.get(E).push(p)});const h=[];S.forEach((p,E)=>{const j=$.get(p);if(!j)h.push({id:`${a}-${d}-${p}-null`,index:E,modelType:"grid",name:p,data:void 0,value:null,color:D(e.color.by,{index:E,seriesIndex:b,categoryIndex:E,datasetIndex:c},r),series:d,seriesIndex:b,category:p,categoryIndex:E});else if(e.value.aggregate==="none"){let I=j.map((l,g)=>{const C=l[e.value.from];return{id:l.id||`${a}-${d}-${p}-${g}`,index:E,modelType:"grid",name:l.name||"",data:l.data,value:typeof C=="number"?C:null,color:D(e.color.by,{index:E,seriesIndex:b,categoryIndex:E,datasetIndex:c},r),series:d,seriesIndex:b,category:p,categoryIndex:E}});e.value.sort==="asc"?I.sort((l,g)=>l.value===null&&g.value===null?0:l.value===null?1:g.value===null?-1:l.value-g.value):e.value.sort==="desc"&&I.sort((l,g)=>l.value===null&&g.value===null?0:l.value===null?1:g.value===null?-1:g.value-l.value),h.push(...I)}else{const I=j.map(B=>{if(e.value.aggregate==="count")return 1;const v=B[e.value.from];return typeof v=="number"?v:null}),l=pe(I,e.value.aggregate),g=j[0],C={id:g.id||`${a}-${d}-${p}-aggregated`,index:E,modelType:"grid",name:g.name||p,data:g.data,value:l,color:D(e.color.by,{index:E,seriesIndex:b,categoryIndex:E,datasetIndex:c},r),series:d,seriesIndex:b,category:p,categoryIndex:E};h.push(C)}}),m.push(h)}),u.push(m)}),u},Ur=(t,e,r)=>{const n=new Map,s=Array.isArray(t[0]);s?t.forEach((a,c)=>{a.forEach(i=>{const f=T(i,e.dataset,`dataset-${c}`);n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const c=T(a,e.dataset,"");n.has(c)||n.set(c,[]),n.get(c).push(a)});let o=Array.from(n.keys());if(Array.isArray(e.dataset.sort))o=e.dataset.sort.filter(a=>n.has(a)).concat(o.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];s?t.forEach((c,i)=>{c.forEach(f=>{const w=T(f,e.dataset,`dataset-${i}`);a.includes(w)||a.push(w)})}):t.forEach(c=>{const i=T(c,e.dataset,"");a.includes(i)||a.push(i)}),o=a}else e.dataset.sort==="alphabetical"&&o.sort((a,c)=>a.localeCompare(c,void 0,{numeric:!0}));const u=[];return o.forEach((a,c)=>{const i=n.get(a),f=new Map;i.forEach(y=>{const S=T(y,e.series,"");f.has(S)||f.set(S,[]),f.get(S).push(y)});let w=Array.from(f.keys());if(Array.isArray(e.series.sort))w=e.series.sort.filter(y=>f.has(y)).concat(w.filter(y=>!e.series.sort.includes(y)));else if(e.series.sort==="original"){const y=[];i.forEach(S=>{const m=T(S,e.series,"");y.includes(m)||y.push(m)}),w=y}else e.series.sort==="alphabetical"&&w.sort((y,S)=>y.localeCompare(S,void 0,{numeric:!0}));const x=[];w.forEach((y,S)=>{const m=f.get(y),d=new Map;m.forEach($=>{const h=T($,e.category,"");d.has(h)||d.set(h,[]),d.get(h).push($)});let b=Array.from(d.keys());if(Array.isArray(e.category.sort))b=e.category.sort.filter($=>d.has($)).concat(b.filter($=>!e.category.sort.includes($)));else if(e.category.sort==="original"){const $=[];m.forEach(h=>{const p=T(h,e.category,"");$.includes(p)||$.push(p)}),b=$}else e.category.sort==="alphabetical"&&b.sort(($,h)=>$.localeCompare(h,void 0,{numeric:!0}));const O=[];b.forEach(($,h)=>{d.get($).forEach((E,j)=>{const I=e.multivariate.map((g,C)=>({index:C,name:g.name,value:(()=>{const B=E[g.from];return typeof B=="number"?B:null})()})),l={id:E.id||`${a}-${y}-${$}-${j}`,index:j,modelType:"multivariate",name:E.name||"",data:E.data,value:null,color:D(e.color.by,{index:j,seriesIndex:S,categoryIndex:h,datasetIndex:c},r),multivariate:I,series:y,seriesIndex:S,category:$,categoryIndex:h};O.push(l)})}),x.push(O)}),u.push(x)}),u},zr=(t,e,r)=>{const n=Array.isArray(t[0]),s=[],o=[];n?t.forEach(i=>{i.forEach(f=>{f.source&&f.target?o.push(f):s.push(f)})}):t.forEach(i=>{i.source&&i.target?o.push(i):s.push(i)});const u=new Map;n?t.forEach((i,f)=>{i.forEach(w=>{if(!w.source||!w.target){const x=T(w,e.dataset,`dataset-${f}`);u.has(x)||u.set(x,[]),u.get(x).push(w)}})}):s.forEach(i=>{const f=T(i,e.dataset,"");u.has(f)||u.set(f,[]),u.get(f).push(i)});let a=Array.from(u.keys());if(Array.isArray(e.dataset.sort))a=e.dataset.sort.filter(i=>u.has(i)).concat(a.filter(i=>!e.dataset.sort.includes(i)));else if(e.dataset.sort==="original"){const i=[];n?t.forEach((f,w)=>{f.forEach(x=>{if(!x.source||!x.target){const y=T(x,e.dataset,`dataset-${w}`);i.includes(y)||i.push(y)}})}):s.forEach(f=>{const w=T(f,e.dataset,"");i.includes(w)||i.push(w)}),a=i}else e.dataset.sort==="alphabetical"&&a.sort((i,f)=>i.localeCompare(f,void 0,{numeric:!0}));const c=[];return a.forEach((i,f)=>{const w=u.get(i),x=[],y=new Map;w.forEach(l=>{const g=T(l,e.series,"");y.has(g)||y.set(g,[]),y.get(g).push(l)});let S=Array.from(y.keys());if(Array.isArray(e.series.sort))S=e.series.sort.filter(l=>y.has(l)).concat(S.filter(l=>!e.series.sort.includes(l)));else if(e.series.sort==="original"){const l=[];w.forEach(g=>{const C=T(g,e.series,"");l.includes(C)||l.push(C)}),S=l}else e.series.sort==="alphabetical"&&S.sort((l,g)=>l.localeCompare(g,void 0,{numeric:!0}));S.forEach((l,g)=>{const C=y.get(l),B=new Map;C.forEach(A=>{const _=T(A,e.category,"");B.has(_)||B.set(_,[]),B.get(_).push(A)});let v=Array.from(B.keys());if(Array.isArray(e.category.sort))v=e.category.sort.filter(A=>B.has(A)).concat(v.filter(A=>!e.category.sort.includes(A)));else if(e.category.sort==="original"){const A=[];C.forEach(_=>{const P=T(_,e.category,"");A.includes(P)||A.push(P)}),v=A}else e.category.sort==="alphabetical"&&v.sort((A,_)=>A.localeCompare(_,void 0,{numeric:!0}));v.forEach((A,_)=>{const P=B.get(A);if(e.value.aggregate==="none"){let k=P.map((V,L)=>{const N=V[e.value.from];return{id:V.id||`${i}-${l}-${A}-${L}`,index:x.length+L,modelType:"graph",name:V.name||"",data:V.data,value:typeof N=="number"?N:null,color:D(e.color.by,{index:_,seriesIndex:g,categoryIndex:_,datasetIndex:f},r),series:l,seriesIndex:g,category:A,categoryIndex:_}});e.value.sort==="asc"?k.sort((V,L)=>V.value===null&&L.value===null?0:V.value===null?1:L.value===null?-1:V.value-L.value):e.value.sort==="desc"&&k.sort((V,L)=>V.value===null&&L.value===null?0:V.value===null?1:L.value===null?-1:L.value-V.value),x.push(...k)}else{const k=P.map(re=>{if(e.value.aggregate==="count")return 1;const oe=re[e.value.from];return typeof oe=="number"?oe:null}),V=pe(k,e.value.aggregate),L=P[0],N={id:L.id||`${i}-${l}-${A}-aggregated`,index:x.length,modelType:"graph",name:L.name||A,data:L.data,value:V,color:D(e.color.by,{index:_,seriesIndex:g,categoryIndex:_,datasetIndex:f},r),series:l,seriesIndex:g,category:A,categoryIndex:_};x.push(N)}})});const m=[],d=new Map;x.forEach(l=>{const g=s.find(C=>C.id===l.id||C.name===l.name);g!=null&&g.id&&d.set(g.id,l.index),g!=null&&g.name&&d.set(g.name,l.index)});const b=new Map,O=new Map;x.forEach(l=>{b.has(l.series)||b.set(l.series,l.seriesIndex),O.has(l.category)||O.set(l.category,l.categoryIndex)});let $=b.size,h=O.size;const p=l=>(b.has(l)||b.set(l,$++),b.get(l)),E=l=>(O.has(l)||O.set(l,h++),O.get(l)),j=o.filter(l=>T(l,e.dataset,"")===i),I=new Map;j.forEach(l=>{const g=l.source,C=l.target,B=T(l,e.series,""),v=T(l,e.category,""),A=`${g}-${C}-${B}-${v}`;I.has(A)||I.set(A,[]),I.get(A).push(l)}),Array.from(I.entries()).forEach(([l,g],C)=>{const B=g[0],v=B.source,A=B.target,_=d.get(v)??-1,P=d.get(A)??-1;if(_>=0&&P>=0)if(e.value.aggregate==="none")g.forEach((k,V)=>{const L=k[e.value.from],N=T(k,e.series,""),re=T(k,e.category,""),oe=p(N),Se=E(re),Ve={id:k.id||`edge-${C}-${V}`,index:m.length,modelType:"graph",name:k.name||"",data:k.data,value:typeof L=="number"?L:null,color:D(e.color.by,{index:m.length,seriesIndex:oe,categoryIndex:Se,datasetIndex:f},r),series:N,seriesIndex:oe,category:re,categoryIndex:Se,source:v,sourceIndex:_,target:A,targetIndex:P};m.push(Ve)});else{const k=g.map(Ve=>{if(e.value.aggregate==="count")return 1;const jt=Ve[e.value.from];return typeof jt=="number"?jt:null}),V=pe(k,e.value.aggregate),L=T(B,e.series,""),N=T(B,e.category,""),re=p(L),oe=E(N),Se={id:B.id||`edge-${C}-aggregated`,index:m.length,modelType:"graph",name:B.name||"",data:B.data,value:V,color:D(e.color.by,{index:m.length,seriesIndex:re,categoryIndex:oe,datasetIndex:f},r),series:L,seriesIndex:re,category:N,categoryIndex:oe,source:v,sourceIndex:_,target:A,targetIndex:P};m.push(Se)}}),c.push({nodes:x,edges:m})}),c},qr=(t,e,r)=>{const n=new Map,s=Array.isArray(t[0]);s?t.forEach((a,c)=>{a.forEach(i=>{const f=T(i,e.dataset,`dataset-${c}`);n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const c=T(a,e.dataset,"");n.has(c)||n.set(c,[]),n.get(c).push(a)});let o=Array.from(n.keys());if(Array.isArray(e.dataset.sort))o=e.dataset.sort.filter(a=>n.has(a)).concat(o.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];s?t.forEach((c,i)=>{c.forEach(f=>{const w=T(f,e.dataset,`dataset-${i}`);a.includes(w)||a.push(w)})}):t.forEach(c=>{const i=T(c,e.dataset,"");a.includes(i)||a.push(i)}),o=a}else e.dataset.sort==="alphabetical"&&o.sort((a,c)=>a.localeCompare(c,void 0,{numeric:!0}));const u=[];return o.forEach((a,c)=>{const i=n.get(a),f=new Map;i.forEach(l=>{const g=T(l,e.series,"");f.has(g)||f.set(g,[]),f.get(g).push(l)});let w=Array.from(f.keys());if(Array.isArray(e.series.sort))w=e.series.sort.filter(l=>f.has(l)).concat(w.filter(l=>!e.series.sort.includes(l)));else if(e.series.sort==="original"){const l=[];i.forEach(g=>{const C=T(g,e.series,"");l.includes(C)||l.push(C)}),w=l}else e.series.sort==="alphabetical"&&w.sort((l,g)=>l.localeCompare(g,void 0,{numeric:!0}));const x=new Map;i.forEach(l=>{const g=T(l,e.category,"");x.has(g)||x.set(g,[]),x.get(g).push(l)});let y=Array.from(x.keys());if(Array.isArray(e.category.sort))y=e.category.sort.filter(l=>x.has(l)).concat(y.filter(l=>!e.category.sort.includes(l)));else if(e.category.sort==="original"){const l=[];i.forEach(g=>{const C=T(g,e.category,"");l.includes(C)||l.push(C)}),y=l}else e.category.sort==="alphabetical"&&y.sort((l,g)=>l.localeCompare(g,void 0,{numeric:!0}));const S=new Map;i.forEach(l=>{const g=l.id||"unknown";S.has(g)||S.set(g,[]),S.get(g).push(l)});let m=0;const d=w[0]||"",b=w.indexOf(d),O=new Map;Array.from(S.entries()).forEach(([l,g])=>{const C=g[0],B=T(C,e.series,""),v=w.indexOf(B),A=T(C,e.category,""),_=y.indexOf(A);if(e.value.aggregate==="none"){const P=C[e.value.from],k={id:l,index:m++,modelType:"tree",name:C.name||l,data:C.data,value:typeof P=="number"?P:null,color:D(e.color.by,{index:m-1,seriesIndex:v,categoryIndex:_,datasetIndex:c},r),parent:C.parent||null,parentIndex:null,depth:0,seq:0,children:[],series:B,seriesIndex:v,category:A,categoryIndex:_};O.set(l,k)}else{const P=g.map(L=>{if(e.value.aggregate==="count")return 1;const N=L[e.value.from];return typeof N=="number"?N:null}),k=pe(P,e.value.aggregate),V={id:l,index:m++,modelType:"tree",name:C.name||l,data:C.data,value:k,color:D(e.color.by,{index:m-1,seriesIndex:v,categoryIndex:_,datasetIndex:c},r),parent:C.parent||null,parentIndex:null,depth:0,seq:0,children:[],series:B,seriesIndex:v,category:A,categoryIndex:_};O.set(l,V)}});const $=Array.from(O.values()),h=new Map;$.forEach(l=>{h.set(l.id,l.index)}),$.forEach(l=>{l.parent&&h.has(l.parent)&&(l.parentIndex=h.get(l.parent))});const p=[],E=new Map;$.forEach(l=>{l.parent===null?p.push(l):(E.has(l.parent)||E.set(l.parent,[]),E.get(l.parent).push(l))});function j(l,g){l.depth=g;const C=E.get(l.id)||[];return e.value.sort==="asc"?C.sort((B,v)=>B.value===null&&v.value===null?0:B.value===null?1:v.value===null?-1:B.value-v.value):e.value.sort==="desc"&&C.sort((B,v)=>B.value===null&&v.value===null?0:B.value===null?1:v.value===null?-1:v.value-B.value),C.forEach((B,v)=>{B.seq=v}),l.children=C.map(B=>j(B,g+1)),l}const I=p.map(l=>j(l,0));if(I.length===0)u.push({id:`empty-${a}`,index:m++,modelType:"tree",name:"Empty Tree",data:{},value:null,color:D(e.color.by,{index:m-1,seriesIndex:b<0?0:b,categoryIndex:0,datasetIndex:c},r),parent:null,parentIndex:null,depth:0,seq:0,children:[],series:d,seriesIndex:b<0?0:b,category:"",categoryIndex:0});else if(I.length===1)u.push(I[0]);else{const l={id:`virtual-root-${a}`,index:m++,modelType:"tree",name:`Virtual Root (${a})`,data:{},value:null,color:D(e.color.by,{index:m-1,seriesIndex:b<0?0:b,categoryIndex:0,datasetIndex:c},r),parent:null,parentIndex:null,depth:0,seq:0,children:I.map((g,C)=>{const B=(v,A)=>(v.depth=A,A===1&&(v.seq=C),v.children=v.children.map(_=>B(_,A+1)),v);return B(g,1)}),series:d,seriesIndex:b<0?0:b,category:"",categoryIndex:0};u.push(l)}}),u};function Wr(t,e,r){const n=e.map(a=>r[a]).filter(a=>a&&a.parentNode===t);if(n.length===0)return;let s=!0,o=null;for(const a of n){if(o&&o.nextElementSibling!==a){s=!1;break}o=a}if(s)return;const u=document.createDocumentFragment();e.forEach(a=>{const c=r[a];c&&c.parentNode===t&&u.appendChild(c)}),t.appendChild(u)}function Ot(t,e,r,n,s){Object.keys(r).filter(i=>!e.includes(i)).forEach(i=>{const f=r[i];f&&f.parentNode===t&&t.removeChild(f),delete r[i]});const a=e.filter(i=>!r[i]);a.forEach(i=>{const f=n(i);r[i]=f,t.appendChild(f)}),e.filter(i=>r[i]&&!a.includes(i)).forEach(i=>{r[i]}),e.length>0&&Wr(t,e,r)}function Yr(t){return R({element:t},{element:{toBe:"Dom",test:r=>Pe(r)}})}function Zr(t){return R(t,{width:{toBe:'"auto" | number',test:r=>r==="auto"||typeof r=="number"},height:{toBe:'"auto" | number',test:r=>r==="auto"||typeof r=="number"},resizeDebounce:{toBe:"number",test:r=>typeof r=="number"}})}function $t(t){const e=R(t,{colorScheme:{toBe:'"dark" | "light" | "auto"',test:r=>r==="dark"||r==="light"||r==="auto"},colors:{toBeTypes:["object"],test:r=>r.light&&r.dark},fontSize:{toBeTypes:["string"]}});if(t.colors){const r=R(t.colors,{light:{toBeTypes:["object"],test:n=>n.data&&n.primary&&n.secondary&&n.dataContrast&&n.background},dark:{toBeTypes:["object"],test:n=>n.data&&n.primary&&n.secondary&&n.dataContrast&&n.background}});if(r.status==="error")return r;if(t.colors.light){const n=R(t.colors.light,{data:{toBeTypes:["string[]"]},primary:{toBeTypes:["string"]},secondary:{toBeTypes:["string"]},dataContrast:{toBeTypes:["string[]"]},background:{toBeTypes:["string"]}});if(n.status==="error")return n}if(t.colors.dark){const n=R(t.colors.dark,{data:{toBeTypes:["string[]"]},primary:{toBeTypes:["string"]},secondary:{toBeTypes:["string"]},dataContrast:{toBeTypes:["string[]"]},background:{toBeTypes:["string"]}});if(n.status==="error")return n}}return e}function It(t){const e=R(t,{dataset:{toBeTypes:["object"]},series:{toBeTypes:["object"]},category:{toBeTypes:["object"]},value:{toBeTypes:["object"]},multivariate:{toBeTypes:["object"]},color:{toBeTypes:["object"]}});if(t.dataset){const r=R(t.dataset,{from:{toBeTypes:["string"]},sort:{toBe:'"original" | "alphabetical" | string[]',test:n=>n==="original"||n==="alphabetical"||Array.isArray(n)&&n.every(s=>typeof s=="string")},ignore:{toBeTypes:["boolean"]}});if(r.status==="error")return r}if(t.series){const r=R(t.series,{from:{toBeTypes:["string"]},sort:{toBe:'"original" | "alphabetical" | string[]',test:n=>n==="original"||n==="alphabetical"||Array.isArray(n)&&n.every(s=>typeof s=="string")},ignore:{toBeTypes:["boolean"]}});if(r.status==="error")return r}if(t.category){const r=R(t.category,{from:{toBeTypes:["string"]},sort:{toBe:'"original" | "alphabetical" | string[]',test:n=>n==="original"||n==="alphabetical"||Array.isArray(n)&&n.every(s=>typeof s=="string")},ignore:{toBeTypes:["boolean"]}});if(r.status==="error")return r}if(t.value){const r=R(t.value,{from:{toBeTypes:["string"]},sort:{toBe:'"original" | "asc" | "desc"',test:n=>n==="original"||n==="asc"||n==="desc"},aggregate:{toBe:'"sum" | "mean" | "median" | "min" | "max" | "count" | "none"',test:n=>["sum","mean","median","min","max","count","none"].includes(n)}});if(r.status==="error")return r}if(t.multivariate){const r=R({multivariate:t.multivariate},{multivariate:{toBe:"EncodingMultivariateItem[]",test:n=>Array.isArray(n)&&n.every(s=>typeof s.from=="string"&&typeof s.label=="string")}});if(r.status==="error")return r}if(t.color){const r=R(t.color,{by:{toBe:'"index" | "series" | "category" | "dataset"',test:n=>["index","series","category","dataset"].includes(n)}});if(r.status==="error")return r}return e}function Bt(t){return R({data:t},{data:{toBe:"RawDataColumn[] | RawDataColumn[][]",test:r=>Array.isArray(r)&&r.every(n=>Array.isArray(n)||H(n))}})}function ke(t){return R({plugins:t},{plugins:{toBe:"PluginEntity[]",test:r=>Array.isArray(r)&&r.every(n=>H(n)&&typeof n._name=="string"&&typeof n._injectContext=="function")}})}function Jr(t){if(!t)return{status:"success",columnName:"",expectToBe:""};const e=R(t,{size:{toBeTypes:["object"]},theme:{toBeTypes:["object"]},data:{toBe:"RawDataColumn[] | RawDataColumn[][]",test:r=>Array.isArray(r)},encoding:{toBeTypes:["object"]},plugins:{toBe:"PluginEntity[]",test:r=>Array.isArray(r)&&r.every(n=>H(n)&&typeof n._name=="string"&&typeof n._injectContext=="function")}});if(e.status==="error")return e;if(t.size){const r=Zr(t.size);if(r.status==="error")return r}if(t.theme){const r=$t(t.theme);if(r.status==="error")return r}if(t.encoding){const r=It(t.encoding);if(r.status==="error")return r}if(t.data){const r=Bt(t.data);if(r.status==="error")return r}if(t.plugins){const r=ke(t.plugins);if(r.status==="error")return r}return e}function Hr({svgElement$:t,canvasElement$:e,pluginsInstance$:r}){let n=[],s=[];const o=(c,i,f)=>{const w=r.getValue().reduce((S,m,d)=>(S[m._getId()]=d,S),{}),x=f.map(S=>({...S,pluginSeq:w[S.pluginId]}));return(c==="svg"?n:s).filter(S=>S.pluginId!==i).map(S=>({...S,pluginSeq:w[S.pluginId]})).concat(x).sort((S,m)=>S.layerIndex-m.layerIndex||S.pluginSeq-m.pluginSeq)},u={},a={};return(c,i,f)=>{const w=c==="svg"?t.getValue():e.getValue();if(!w)return{};const x=c==="svg"?u:a,y=o(c,i,f),S=y.map(d=>xt(d.pluginId,d.layerName));return c==="svg"?(Ot(w,S,x,d=>wt(d)),n=y):(Ot(w,S,x,d=>Me(d)),s=y),Object.entries(x).reduce((d,[b,O])=>{const[$,h,p]=b.split("-");return h===i&&(d[p]=O),d},{})}}const Qr=(t,e)=>{try{const{status:b,columnName:O,expectToBe:$}=Jr(e);if(b==="error")throw new Error(Q({columnName:O,expectToBe:$,from:"Chart.constructor"}));if(b==="warning")console.warn(X({columnName:O,expectToBe:$,from:"Chart.constructor"}));else{const{status:h,columnName:p,expectToBe:E}=Yr(t);if(h==="error")throw new Error(Q({columnName:p,expectToBe:E,from:"Chart.constructor"}));h==="warning"&&console.warn(X({columnName:p,expectToBe:E,from:"Chart.constructor"}))}}catch(b){throw new Error(b)}const r=new ie,n=new z((e==null?void 0:e.data)||[]),s=e&&e.encoding?Y(Ct,e.encoding):Ct,o=new z(s),u=e&&e.theme?Y(Tt,e.theme):Tt,a=new z(u),c=new z((e==null?void 0:e.plugins)||[]),i=e&&e.size?Y(_t,e.size):_t,f=new z(i),w=new z(null),x=new z(null),y=(()=>{const b=f.pipe(Vr(v=>Or(()=>v.width==="auto"||v.height==="auto",At(t).pipe(W(A=>({width:v.width==="auto"?A.width:v.width,height:v.height==="auto"?A.height<=0?A.width:A.height:v.height})),J(v.resizeDebounce),Br((A,_)=>JSON.stringify(A)===JSON.stringify(_))),dr({width:v.width,height:v.height}))),Lr(r),se(1)),O=o.asObservable().pipe(se(1)),$=te([n,o,a]).pipe(J(0),W(([v,A,_])=>{try{return Nr(v,A,_)}catch(P){throw new Error(de({from:"Chart.seriesData$",systemMessage:P}))}}),ye(v=>(console.error(q(v)),he)),se(1)),h=te([n,o,a]).pipe(J(0),W(([v,A,_])=>{try{return Gr(v,A,_)}catch(P){throw new Error(de({from:"Chart.gridData$",systemMessage:P}))}}),ye(v=>(console.error(q(v)),he)),se(1)),p=te([n,o,a]).pipe(J(0),W(([v,A,_])=>{try{return Ur(v,A,_)}catch(P){throw new Error(de({from:"Chart.multivariateData$",systemMessage:P}))}}),ye(v=>(console.error(q(v)),he)),se(1)),E=te([n,o,a]).pipe(J(0),W(([v,A,_])=>{try{return zr(v,A,_)}catch(P){throw new Error(de({from:"Chart.graphData$",systemMessage:P}))}}),ye(v=>(console.error(q(v)),he)),se(1)),j=te([n,o,a]).pipe(J(0),W(([v,A,_])=>{try{return qr(v,A,_)}catch(P){throw new Error(de({from:"Chart.treeData$",systemMessage:P}))}}),ye(v=>(console.error(q(v)),he)),se(1)),I=new z([]);c.subscribe(v=>{const A={},_=v.map(k=>{var L;let V=k._getId();if(A[V]){const N=((L=A[V].split("[")[1])==null?void 0:L.split("]")[0])||"0",re=parseInt(N)+1;V=`${V.split("[")[0]}[${re}]`}return A[V]=k._getId(),V});v.forEach((k,V)=>k._setId(_[V]));const P=v.map(k=>({id:k._getId(),name:k._name,elementType:k._elementType,shownLayers:k.getShownLayerNames()}));I.next(P)});const l=a.asObservable().pipe(se(1)),g=new ie,C=g.asObservable().pipe(ct());return{root:t,svg:null,canvas:null,size$:b,encoding$:O,seriesData$:$,gridData$:h,multivariateData$:p,graphData$:E,treeData$:j,plugins$:I,theme$:l,event$:C,eventTrigger$:g,_updateLayerElements:Hr({svgElement$:w,canvasElement$:x,pluginsInstance$:c})}})();let S=null;const m=()=>(S||(S=document.createElement("div"),S.classList.add("orbcharts-container"),S.style.position="relative",t.appendChild(S)),S);let d=[];return c.subscribe(b=>{d.filter(p=>!b.includes(p)).forEach(p=>{y._updateLayerElements(p._elementType,p._getId(),[]),p.destroy()}),d=b;let $=!1,h=!1;b.forEach(p=>{p._elementType==="svg"?$=!0:p._elementType==="canvas"&&(h=!0)}),$&&!y.svg?(y.svg=bt("orbcharts-root-svg"),m().appendChild(y.svg),w.next(y.svg)):!$&&y.svg&&(y.svg.remove(),y.svg=null,w.next(null)),h&&!y.canvas?(y.canvas=Me("orbcharts-root-canvas"),m().appendChild(y.canvas),x.next(y.canvas)):!h&&y.canvas&&(y.canvas.remove(),y.canvas=null,x.next(null)),b.forEach(p=>{p._injectContext(y)})}),te({size:y.size$,svg:w}).pipe(J(0),be(({svg:b})=>!!b)).subscribe(({size:b,svg:O})=>{O&&(O.setAttribute("width",b.width.toString()),O.setAttribute("height",b.height.toString()))}),te({size:y.size$,canvas:x}).pipe(J(0),be(({canvas:b})=>!!b)).subscribe(({size:b,canvas:O})=>{O&&(O.width=b.width,O.height=b.height)}),(()=>{function b(v){f.next(v)}function O(v){try{const{status:A,columnName:_,expectToBe:P}=Bt(v);if(A==="error")throw new Error(Q({columnName:_,expectToBe:P,from:"Chart.setData"}));A==="warning"&&console.warn(X({columnName:_,expectToBe:P,from:"Chart.setData"}))}catch(A){console.error(q(A))}n.next(v)}function $(v){try{const{status:_,columnName:P,expectToBe:k}=It(v);if(_==="error")throw new Error(Q({columnName:P,expectToBe:k,from:"Chart.updateEncoding"}));_==="warning"&&console.warn(X({columnName:P,expectToBe:k,from:"Chart.updateEncoding"}))}catch(_){console.error(q(_))}const A=Y(o.getValue(),v);o.next(A)}function h(v){o.next(v)}function p(){return o.getValue()}function E(v){try{const{status:A,columnName:_,expectToBe:P}=ke(v);if(A==="error")throw new Error(Q({columnName:_,expectToBe:P,from:"Chart.setPlugins"}));A==="warning"&&console.warn(X({columnName:_,expectToBe:P,from:"Chart.setPlugins"}))}catch(A){console.error(q(A))}c.next(v)}function j(v){try{const{status:A,columnName:_,expectToBe:P}=ke([v]);if(A==="error")throw new Error(Q({columnName:_,expectToBe:P,from:"Chart.addPlugin"}));A==="warning"&&console.warn(X({columnName:_,expectToBe:P,from:"Chart.addPlugin"}))}catch(A){console.error(q(A))}c.next([...c.getValue(),v])}function I(v){c.next(c.getValue().filter(A=>A._getId()!==v))}function l(v){try{const{status:_,columnName:P,expectToBe:k}=$t(v);if(_==="error")throw new Error(Q({columnName:P,expectToBe:k,from:"Chart.updateTheme"}));_==="warning"&&console.warn(X({columnName:P,expectToBe:k,from:"Chart.updateTheme"}))}catch(_){console.error(q(_))}const A=Y(a.getValue(),v);a.next(A)}function g(v){a.next(v)}function C(){return a.getValue()}function B(){r.next(void 0),c.getValue().forEach(v=>v.destroy()),Et(t),S=null}return{resize:b,setData:O,updateEncoding:$,forceReplaceEncoding:h,getEncoding:p,setPlugins:E,addPlugin:j,removePlugin:I,updateTheme:l,forceReplaceTheme:g,getTheme:C,destroy:B,context:y}})()};class Xr{constructor(e,r){return Qr(e,r)}}const Pt=(t,e,r)=>{let n=e.name,s=()=>{};const o=new z(null),u=o.pipe(be(h=>h!==null)),a=e.layers.map(h=>new h),c={...a.reduce((h,p)=>(h[p._name]=p,h),{})},i=()=>new Set(a.map(h=>h._name)),f=h=>{if(h){const p=i();return Object.keys(h).filter(j=>p.has(j))}return[]},w=a.reduce((h,p)=>(p._initShow&&h.push(p._name),h),[]),x=f(r),y=new z(new Set(x.length>0?x:w)),S=y.pipe(W(h=>Array.from(h).map(E=>{var j;return[E,((j=a.find(I=>I._name===E))==null?void 0:j._layerIndex)??-1]}).filter(([,E])=>E!==-1).sort((E,j)=>E[1]-j[1]).map(([E])=>E)));let m=Y(e.defaultParams??{},r??{});const d=new z(r??{}),b=new ie,O=new F(h=>{d.subscribe(p=>{try{const{status:E,columnName:j,expectToBe:I}=e.validator(p);if(E==="error")throw new Error(Q({columnName:j,expectToBe:I,from:`${e.name}.params$`}));E==="warning"&&console.warn(X({columnName:j,expectToBe:I,from:`${e.name}.params$`}))}catch(E){console.error(q(E))}h.next(m)}),b.subscribe(p=>{h.next(p)})}),$=u.pipe(W(h=>({context:h,pluginParams$:O})),kr());return te({pluginSetupProps:$,ShownLayerNameSet:y,shownLayerNamesSeq:S}).pipe(J(0)).subscribe(({pluginSetupProps:h,ShownLayerNameSet:p,shownLayerNamesSeq:E})=>{const j=h.context._updateLayerElements(t,n,E.map(I=>({pluginId:n,pluginName:e.name,layerName:I,layerIndex:c[I]._layerIndex})));e.setup&&(s=e.setup(h)),a.forEach(I=>{var l,g;if(p.has(I._name)){const C=t==="svg"?{svgG:j[I._name],context:h.context,pluginParams$:O,initLayerParams:((l=d.getValue())==null?void 0:l[I._name])||{}}:{canvas:j[I._name],context:h.context,pluginParams$:O,initLayerParams:((g=d.getValue())==null?void 0:g[I._name])||{}};I._enable(C)}else I._disable()})}),{_name:e.name,_elementType:t,_getId:()=>n,_setId:h=>{n=h},_injectContext:h=>{o.next(Object.assign({},h))},show:h=>{h=Array.isArray(h)?h:[h],y.next(new Set([...Array.from(y.getValue()),...h]))},showOnly:h=>{h=Array.isArray(h)?h:[h],y.next(new Set([...h]))},showAll:()=>{y.next(i())},hide:h=>{h=Array.isArray(h)?h:[h],y.next(new Set([...Array.from(y.getValue()).filter(p=>!h.includes(p))]))},hideAll:()=>{y.next(new Set)},toggle:h=>{h=Array.isArray(h)?h:[h],Array.from(y.getValue()).forEach(p=>{h.includes(p)?h.splice(h.indexOf(p),1):h.push(p)}),y.next(new Set(h))},getShownLayerNames:()=>Array.from(y.getValue()),updateParams:h=>{m=Y(m,h),d.next(h),Object.keys(h).forEach(p=>{const E=c[p];E&&E._updateParams(h[p])})},forceReplaceParams:h=>{m=h,b.next(h),Object.keys(h).forEach(p=>{const E=c[p];E&&E._forceReplaceParams(h[p])})},getParams:()=>{const h=Object.assign({},m);return a.forEach(p=>{h[p._name]=p._getParams()}),h},destroy:()=>{s(),o.complete(),y.complete(),a.forEach(h=>{h._destroy()})}}},en=t=>class{constructor(r){return Pt("svg",t,r)}},Mt=(t,e)=>{const r=new z(Object.assign({},e.defaultParams));let n=()=>{};const s=new z(null),o=s.pipe(be(u=>u!==null));return te({layerParams:r,enabledProps:o}).pipe(J(0)).subscribe(({layerParams:u,enabledProps:a})=>{n(),n=t==="svg"?e.setup({svgG:a.svgG,context:a.context,pluginParams$:a.pluginParams$,layerParams$:r.pipe(W(c=>Y(c,a.initLayerParams??{})))}):e.setup({canvas:a.canvas,context:a.context,pluginParams$:a.pluginParams$,layerParams$:r.pipe(W(c=>Y(c,a.initLayerParams??{})))})}),s.pipe(be(u=>u===null)).subscribe(()=>{n()}),{_name:e.name,_defaultParams:e.defaultParams,_layerIndex:e.layerIndex,_initShow:e.initShow,_enable:u=>{s.next(u)},_disable:()=>{s.next(null)},_updateParams:u=>{try{const{status:c,columnName:i,expectToBe:f}=e.validator(u);if(c==="error")throw new Error(Q({columnName:i,expectToBe:f,from:`${e.name}.params$`}));c==="warning"&&console.warn(X({columnName:i,expectToBe:f,from:`${e.name}.params$`}))}catch(c){console.error(q(c))}const a=Y(r.getValue(),u);r.next(a)},_forceReplaceParams:u=>{r.next(u)},_getParams:()=>r.getValue(),_destroy:()=>{s.next(null),s.complete(),r.complete()}}},tn=t=>class{constructor(){return Mt("svg",t)}},rn=t=>class{constructor(r){return Pt("canvas",t,r)}},nn=t=>class{constructor(){return Mt("canvas",t)}};M.OrbCharts=Xr,M.aggregate=pe,M.count=dt,M.createCanvas=Me,M.createCanvasElement=Rr,M.createDiv=Fr,M.createLayerClassName=xt,M.createMessagePrefix=je,M.createOrbChartsErrorMessage=q,M.createPluginClassName=St,M.createSVG=bt,M.createSVGGroup=wt,M.createUnexpectedErrorMessage=de,M.createValidatorErrorMessage=Q,M.createValidatorWarningMessage=X,M.deepOverwrite=Y,M.defineCanvasLayer=nn,M.defineCanvasPlugin=rn,M.defineSVGLayer=tn,M.defineSVGPlugin=en,M.formatCommaNumber=Kr,M.getColorByFrom=D,M.getColorByIndex=mt,M.isDom=Pe,M.isFunction=gt,M.isPlainObject=H,M.max=pt,M.mean=ft,M.median=ht,M.min=yt,M.none=vt,M.removeElementChildren=Et,M.resizeObservable=At,M.resolveGroupKey=T,M.sum=lt,M.validateObject=R,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
|
8
|
+
----> find in '${r}'`}function At(t){return new F(e=>{const r=new ResizeObserver(n=>{const s=n[0];s&&s.contentRect&&e.next(s.contentRect)});return r.observe(t),function(){r.unobserve(t)}})}function St(t){return`orbcharts-${t}`}function xt(t,e){return`${St(t)}-${e}`}function kr(t,e){const r={string:o=>typeof o=="string",number:o=>typeof o=="number",boolean:o=>typeof o=="boolean",object:o=>H(o),"object[]":o=>Array.isArray(o)&&o.every(u=>H(u)),"string[]":o=>Array.isArray(o)&&o.every(u=>typeof u=="string"),"number[]":o=>Array.isArray(o)&&o.every(u=>typeof u=="number"),Function:o=>gt(o),null:o=>o===null,undefined:o=>o===void 0},n={ColorType:o=>o==="none"||o==="data"||o==="primary"||o==="secondary"||o==="dataContrast"||o==="background"};return Object.keys(t).find(o=>{if(e[o]){const u=e[o],a=t[o];if(a===void 0)return!1;if(u.toBeTypes){if(u.toBeTypes.some(f=>r[f](a))===!1)return!0}else if(u.toBe){const{toBe:c,test:i}=u;if(i(a)===!1)return!0}else if(u.toBeOption){const c=u.toBeOption;if(n[c](a)===!1)return!0}}return!1})}function R(t,e){const r=kr(t,e);if(r){const n=e[r],s=n.toBeTypes?n.toBeTypes.join(" | "):n.toBe?n.toBe:n.toBeOption?n.toBeOption:"";return{status:"error",columnName:r,expectToBe:s}}else return{status:"success",columnName:"",expectToBe:""}}const _t={width:"auto",height:"auto",resizeDebounce:50},Ct={dataset:{from:"dataset",sort:"original",ignore:!1},series:{from:"series",sort:"original",ignore:!1},category:{from:"category",sort:"original",ignore:!1},value:{from:"value",sort:"original",aggregate:"none"},multivariate:[{from:"x",name:"x"},{from:"y",name:"y"},{from:"z",name:"z"}],color:{by:"series"}},Tt={colorScheme:"light",colors:{light:{data:["#4E79A7","#F28E2B","#E15759","#76B7B2","#59A14F","#EDC948","#B07AA1","#FF9DA7","#9C755F","#BAB0AC"],primary:"#000000",secondary:"#e0e0e0",dataContrast:["#ffffff","#000000"],background:"#FFFFFF"},dark:{data:["#7EA6E0","#FFB86B","#FF7A7A","#6ED0CC","#7ED97A","#FFE06E","#D4A5D8","#FFB3BA","#C89F7A","#D3D3D3"],primary:"#FFFFFF",secondary:"#e0e0e0",dataContrast:["#ffffff","#000000"],background:"#000000"}},fontSize:"0.875rem"},Lr=(t,e,r)=>{const n=new Map,s=Array.isArray(t[0]);s?t.forEach((a,c)=>{a.forEach(i=>{const f=T(i,e.dataset,`dataset-${c}`);n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const c=T(a,e.dataset,"");n.has(c)||n.set(c,[]),n.get(c).push(a)});let o=Array.from(n.keys());if(Array.isArray(e.dataset.sort))o=e.dataset.sort.filter(a=>n.has(a)).concat(o.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];s?t.forEach((c,i)=>{c.forEach(f=>{const w=T(f,e.dataset,`dataset-${i}`);a.includes(w)||a.push(w)})}):t.forEach(c=>{const i=T(c,e.dataset,"");a.includes(i)||a.push(i)}),o=a}else e.dataset.sort==="alphabetical"&&o.sort((a,c)=>a.localeCompare(c,void 0,{numeric:!0}));const u=[];return o.forEach((a,c)=>{const i=n.get(a),f=new Map;i.forEach(m=>{const p=T(m,e.series,"");f.has(p)||f.set(p,[]),f.get(p).push(m)});let w=Array.from(f.keys());if(Array.isArray(e.series.sort))w=e.series.sort.filter(m=>f.has(m)).concat(w.filter(m=>!e.series.sort.includes(m)));else if(e.series.sort==="original"){const m=[];i.forEach(p=>{const b=T(p,e.series,"");m.includes(b)||m.push(b)}),w=m}else e.series.sort==="alphabetical"&&w.sort((m,p)=>m.localeCompare(p,void 0,{numeric:!0}));const x=[];if(e.category.sort==="original")i.forEach(m=>{const p=T(m,e.category,"");x.includes(p)||x.push(p)});else if(e.category.sort==="alphabetical"){const m=new Set;i.forEach(p=>{m.add(T(p,e.category,""))}),x.push(...Array.from(m).sort((p,b)=>p.localeCompare(b,void 0,{numeric:!0})))}else if(Array.isArray(e.category.sort)){const m=[];i.forEach(b=>{const O=T(b,e.category,"");m.includes(O)||m.push(O)});const p=e.category.sort;x.push(...p.filter(b=>m.includes(b)),...m.filter(b=>!p.includes(b)))}const y=new Map;x.forEach((m,p)=>{y.set(m,p)});const S=[];w.forEach((m,p)=>{const b=f.get(m),O=new Map;b.forEach(d=>{const E=T(d,e.category,"");O.has(E)||O.set(E,[]),O.get(E).push(d)});const $=x.filter(d=>O.has(d)),h=[];e.category.sort==="original"&&e.value.aggregate==="none"?(b.forEach((d,E)=>{const j=T(d,e.category,""),I=y.get(j),l=d[e.value.from];h.push({id:d.id||`${a}-${m}-${j}-${E}`,index:I,modelType:"series",name:d.name||"",data:d.data,value:typeof l=="number"?l:null,color:D(e.color.by,{index:I,seriesIndex:p,categoryIndex:I,datasetIndex:c},r),series:m,seriesIndex:p,category:j,categoryIndex:I})}),e.value.sort==="asc"?h.sort((d,E)=>d.value===null&&E.value===null?0:d.value===null?1:E.value===null?-1:d.value-E.value):e.value.sort==="desc"&&h.sort((d,E)=>d.value===null&&E.value===null?0:d.value===null?1:E.value===null?-1:E.value-d.value)):$.forEach(d=>{const E=y.get(d),j=O.get(d);if(e.value.aggregate==="none"){let I=j.map((l,g)=>{const C=l[e.value.from];return{id:l.id||`${a}-${m}-${d}-${g}`,index:E,modelType:"series",name:l.name||"",data:l.data,value:typeof C=="number"?C:null,color:D(e.color.by,{index:E,seriesIndex:p,categoryIndex:E,datasetIndex:c},r),series:m,seriesIndex:p,category:d,categoryIndex:E}});e.value.sort==="asc"?I.sort((l,g)=>l.value===null&&g.value===null?0:l.value===null?1:g.value===null?-1:l.value-g.value):e.value.sort==="desc"&&I.sort((l,g)=>l.value===null&&g.value===null?0:l.value===null?1:g.value===null?-1:g.value-l.value),h.push(...I)}else{const I=j.map(B=>{if(e.value.aggregate==="count")return 1;const v=B[e.value.from];return typeof v=="number"?v:null}),l=ye(I,e.value.aggregate),g=j[0],C={id:g.id||`${a}-${m}-${d}-aggregated`,index:E,modelType:"series",name:g.name||d,data:g.data,value:l,color:D(e.color.by,{index:E,seriesIndex:p,categoryIndex:E,datasetIndex:c},r),series:m,seriesIndex:p,category:d,categoryIndex:E};h.push(C)}}),S.push(h)}),u.push(S)}),u},Vr=(t,e,r)=>{const n=new Map,s=Array.isArray(t[0]);s?t.forEach((a,c)=>{a.forEach(i=>{const f=T(i,e.dataset,`dataset-${c}`);n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const c=T(a,e.dataset,"");n.has(c)||n.set(c,[]),n.get(c).push(a)});let o=Array.from(n.keys());if(Array.isArray(e.dataset.sort))o=e.dataset.sort.filter(a=>n.has(a)).concat(o.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];s?t.forEach((c,i)=>{c.forEach(f=>{const w=T(f,e.dataset,`dataset-${i}`);a.includes(w)||a.push(w)})}):t.forEach(c=>{const i=T(c,e.dataset,"");a.includes(i)||a.push(i)}),o=a}else e.dataset.sort==="alphabetical"&&o.sort((a,c)=>a.localeCompare(c,void 0,{numeric:!0}));const u=[];return o.forEach((a,c)=>{const i=n.get(a),f=new Map;i.forEach(p=>{const b=T(p,e.series,"");f.has(b)||f.set(b,[]),f.get(b).push(p)});let w=Array.from(f.keys());if(Array.isArray(e.series.sort))w=e.series.sort.filter(p=>f.has(p)).concat(w.filter(p=>!e.series.sort.includes(p)));else if(e.series.sort==="original"){const p=[];i.forEach(b=>{const O=T(b,e.series,"");p.includes(O)||p.push(O)}),w=p}else e.series.sort==="alphabetical"&&w.sort((p,b)=>p.localeCompare(b,void 0,{numeric:!0}));const x=[];i.forEach(p=>{const b=T(p,e.category,"");x.includes(b)||x.push(b)});const y=new Set(x);let S=Array.from(y);Array.isArray(e.category.sort)?S=e.category.sort.filter(p=>y.has(p)).concat(S.filter(p=>!e.category.sort.includes(p))):e.category.sort==="original"?S=x:e.category.sort==="alphabetical"&&S.sort((p,b)=>p.localeCompare(b,void 0,{numeric:!0}));const m=[];w.forEach((p,b)=>{const O=f.get(p),$=new Map;O.forEach(d=>{const E=T(d,e.category,"");$.has(E)||$.set(E,[]),$.get(E).push(d)});const h=[];S.forEach((d,E)=>{const j=$.get(d);if(!j)h.push({id:`${a}-${p}-${d}-null`,index:E,modelType:"grid",name:d,data:void 0,value:null,color:D(e.color.by,{index:E,seriesIndex:b,categoryIndex:E,datasetIndex:c},r),series:p,seriesIndex:b,category:d,categoryIndex:E});else if(e.value.aggregate==="none"){let I=j.map((l,g)=>{const C=l[e.value.from];return{id:l.id||`${a}-${p}-${d}-${g}`,index:E,modelType:"grid",name:l.name||"",data:l.data,value:typeof C=="number"?C:null,color:D(e.color.by,{index:E,seriesIndex:b,categoryIndex:E,datasetIndex:c},r),series:p,seriesIndex:b,category:d,categoryIndex:E}});e.value.sort==="asc"?I.sort((l,g)=>l.value===null&&g.value===null?0:l.value===null?1:g.value===null?-1:l.value-g.value):e.value.sort==="desc"&&I.sort((l,g)=>l.value===null&&g.value===null?0:l.value===null?1:g.value===null?-1:g.value-l.value),h.push(...I)}else{const I=j.map(B=>{if(e.value.aggregate==="count")return 1;const v=B[e.value.from];return typeof v=="number"?v:null}),l=ye(I,e.value.aggregate),g=j[0],C={id:g.id||`${a}-${p}-${d}-aggregated`,index:E,modelType:"grid",name:g.name||d,data:g.data,value:l,color:D(e.color.by,{index:E,seriesIndex:b,categoryIndex:E,datasetIndex:c},r),series:p,seriesIndex:b,category:d,categoryIndex:E};h.push(C)}}),m.push(h)}),u.push(m)}),u},Kr=(t,e,r)=>{const n=new Map,s=Array.isArray(t[0]);s?t.forEach((a,c)=>{a.forEach(i=>{const f=T(i,e.dataset,`dataset-${c}`);n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const c=T(a,e.dataset,"");n.has(c)||n.set(c,[]),n.get(c).push(a)});let o=Array.from(n.keys());if(Array.isArray(e.dataset.sort))o=e.dataset.sort.filter(a=>n.has(a)).concat(o.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];s?t.forEach((c,i)=>{c.forEach(f=>{const w=T(f,e.dataset,`dataset-${i}`);a.includes(w)||a.push(w)})}):t.forEach(c=>{const i=T(c,e.dataset,"");a.includes(i)||a.push(i)}),o=a}else e.dataset.sort==="alphabetical"&&o.sort((a,c)=>a.localeCompare(c,void 0,{numeric:!0}));const u=[];return o.forEach((a,c)=>{const i=n.get(a),f=new Map;i.forEach(y=>{const S=T(y,e.series,"");f.has(S)||f.set(S,[]),f.get(S).push(y)});let w=Array.from(f.keys());if(Array.isArray(e.series.sort))w=e.series.sort.filter(y=>f.has(y)).concat(w.filter(y=>!e.series.sort.includes(y)));else if(e.series.sort==="original"){const y=[];i.forEach(S=>{const m=T(S,e.series,"");y.includes(m)||y.push(m)}),w=y}else e.series.sort==="alphabetical"&&w.sort((y,S)=>y.localeCompare(S,void 0,{numeric:!0}));const x=[];w.forEach((y,S)=>{const m=f.get(y),p=new Map;m.forEach($=>{const h=T($,e.category,"");p.has(h)||p.set(h,[]),p.get(h).push($)});let b=Array.from(p.keys());if(Array.isArray(e.category.sort))b=e.category.sort.filter($=>p.has($)).concat(b.filter($=>!e.category.sort.includes($)));else if(e.category.sort==="original"){const $=[];m.forEach(h=>{const d=T(h,e.category,"");$.includes(d)||$.push(d)}),b=$}else e.category.sort==="alphabetical"&&b.sort(($,h)=>$.localeCompare(h,void 0,{numeric:!0}));const O=[];b.forEach(($,h)=>{p.get($).forEach((E,j)=>{const I=e.multivariate.map((g,C)=>({index:C,name:g.name,value:(()=>{const B=E[g.from];return typeof B=="number"?B:null})()})),l={id:E.id||`${a}-${y}-${$}-${j}`,index:j,modelType:"multivariate",name:E.name||"",data:E.data,value:null,color:D(e.color.by,{index:j,seriesIndex:S,categoryIndex:h,datasetIndex:c},r),multivariate:I,series:y,seriesIndex:S,category:$,categoryIndex:h};O.push(l)})}),x.push(O)}),u.push(x)}),u},Rr=(t,e,r)=>{const n=Array.isArray(t[0]),s=[],o=[];n?t.forEach(i=>{i.forEach(f=>{f.source&&f.target?o.push(f):s.push(f)})}):t.forEach(i=>{i.source&&i.target?o.push(i):s.push(i)});const u=new Map;n?t.forEach((i,f)=>{i.forEach(w=>{if(!w.source||!w.target){const x=T(w,e.dataset,`dataset-${f}`);u.has(x)||u.set(x,[]),u.get(x).push(w)}})}):s.forEach(i=>{const f=T(i,e.dataset,"");u.has(f)||u.set(f,[]),u.get(f).push(i)});let a=Array.from(u.keys());if(Array.isArray(e.dataset.sort))a=e.dataset.sort.filter(i=>u.has(i)).concat(a.filter(i=>!e.dataset.sort.includes(i)));else if(e.dataset.sort==="original"){const i=[];n?t.forEach((f,w)=>{f.forEach(x=>{if(!x.source||!x.target){const y=T(x,e.dataset,`dataset-${w}`);i.includes(y)||i.push(y)}})}):s.forEach(f=>{const w=T(f,e.dataset,"");i.includes(w)||i.push(w)}),a=i}else e.dataset.sort==="alphabetical"&&a.sort((i,f)=>i.localeCompare(f,void 0,{numeric:!0}));const c=[];return a.forEach((i,f)=>{const w=u.get(i),x=[],y=new Map;w.forEach(l=>{const g=T(l,e.series,"");y.has(g)||y.set(g,[]),y.get(g).push(l)});let S=Array.from(y.keys());if(Array.isArray(e.series.sort))S=e.series.sort.filter(l=>y.has(l)).concat(S.filter(l=>!e.series.sort.includes(l)));else if(e.series.sort==="original"){const l=[];w.forEach(g=>{const C=T(g,e.series,"");l.includes(C)||l.push(C)}),S=l}else e.series.sort==="alphabetical"&&S.sort((l,g)=>l.localeCompare(g,void 0,{numeric:!0}));S.forEach((l,g)=>{const C=y.get(l),B=new Map;C.forEach(A=>{const _=T(A,e.category,"");B.has(_)||B.set(_,[]),B.get(_).push(A)});let v=Array.from(B.keys());if(Array.isArray(e.category.sort))v=e.category.sort.filter(A=>B.has(A)).concat(v.filter(A=>!e.category.sort.includes(A)));else if(e.category.sort==="original"){const A=[];C.forEach(_=>{const P=T(_,e.category,"");A.includes(P)||A.push(P)}),v=A}else e.category.sort==="alphabetical"&&v.sort((A,_)=>A.localeCompare(_,void 0,{numeric:!0}));v.forEach((A,_)=>{const P=B.get(A);if(e.value.aggregate==="none"){let k=P.map((L,V)=>{const N=L[e.value.from];return{id:L.id||`${i}-${l}-${A}-${V}`,index:x.length+V,modelType:"graph",name:L.name||"",data:L.data,value:typeof N=="number"?N:null,color:D(e.color.by,{index:_,seriesIndex:g,categoryIndex:_,datasetIndex:f},r),series:l,seriesIndex:g,category:A,categoryIndex:_}});e.value.sort==="asc"?k.sort((L,V)=>L.value===null&&V.value===null?0:L.value===null?1:V.value===null?-1:L.value-V.value):e.value.sort==="desc"&&k.sort((L,V)=>L.value===null&&V.value===null?0:L.value===null?1:V.value===null?-1:V.value-L.value),x.push(...k)}else{const k=P.map(re=>{if(e.value.aggregate==="count")return 1;const oe=re[e.value.from];return typeof oe=="number"?oe:null}),L=ye(k,e.value.aggregate),V=P[0],N={id:V.id||`${i}-${l}-${A}-aggregated`,index:x.length,modelType:"graph",name:V.name||A,data:V.data,value:L,color:D(e.color.by,{index:_,seriesIndex:g,categoryIndex:_,datasetIndex:f},r),series:l,seriesIndex:g,category:A,categoryIndex:_};x.push(N)}})});const m=[],p=new Map;x.forEach(l=>{const g=s.find(C=>C.id===l.id||C.name===l.name);g!=null&&g.id&&p.set(g.id,l.index),g!=null&&g.name&&p.set(g.name,l.index)});const b=new Map,O=new Map;x.forEach(l=>{b.has(l.series)||b.set(l.series,l.seriesIndex),O.has(l.category)||O.set(l.category,l.categoryIndex)});let $=b.size,h=O.size;const d=l=>(b.has(l)||b.set(l,$++),b.get(l)),E=l=>(O.has(l)||O.set(l,h++),O.get(l)),j=o.filter(l=>T(l,e.dataset,"")===i),I=new Map;j.forEach(l=>{const g=l.source,C=l.target,B=T(l,e.series,""),v=T(l,e.category,""),A=`${g}-${C}-${B}-${v}`;I.has(A)||I.set(A,[]),I.get(A).push(l)}),Array.from(I.entries()).forEach(([l,g],C)=>{const B=g[0],v=B.source,A=B.target,_=p.get(v)??-1,P=p.get(A)??-1;if(_>=0&&P>=0)if(e.value.aggregate==="none")g.forEach((k,L)=>{const V=k[e.value.from],N=T(k,e.series,""),re=T(k,e.category,""),oe=d(N),xe=E(re),Le={id:k.id||`edge-${C}-${L}`,index:m.length,modelType:"graph",name:k.name||"",data:k.data,value:typeof V=="number"?V:null,color:D(e.color.by,{index:m.length,seriesIndex:oe,categoryIndex:xe,datasetIndex:f},r),series:N,seriesIndex:oe,category:re,categoryIndex:xe,source:v,sourceIndex:_,target:A,targetIndex:P};m.push(Le)});else{const k=g.map(Le=>{if(e.value.aggregate==="count")return 1;const jt=Le[e.value.from];return typeof jt=="number"?jt:null}),L=ye(k,e.value.aggregate),V=T(B,e.series,""),N=T(B,e.category,""),re=d(V),oe=E(N),xe={id:B.id||`edge-${C}-aggregated`,index:m.length,modelType:"graph",name:B.name||"",data:B.data,value:L,color:D(e.color.by,{index:m.length,seriesIndex:re,categoryIndex:oe,datasetIndex:f},r),series:V,seriesIndex:re,category:N,categoryIndex:oe,source:v,sourceIndex:_,target:A,targetIndex:P};m.push(xe)}}),c.push({nodes:x,edges:m})}),c},Fr=(t,e,r)=>{const n=new Map,s=Array.isArray(t[0]);s?t.forEach((a,c)=>{a.forEach(i=>{const f=T(i,e.dataset,`dataset-${c}`);n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const c=T(a,e.dataset,"");n.has(c)||n.set(c,[]),n.get(c).push(a)});let o=Array.from(n.keys());if(Array.isArray(e.dataset.sort))o=e.dataset.sort.filter(a=>n.has(a)).concat(o.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];s?t.forEach((c,i)=>{c.forEach(f=>{const w=T(f,e.dataset,`dataset-${i}`);a.includes(w)||a.push(w)})}):t.forEach(c=>{const i=T(c,e.dataset,"");a.includes(i)||a.push(i)}),o=a}else e.dataset.sort==="alphabetical"&&o.sort((a,c)=>a.localeCompare(c,void 0,{numeric:!0}));const u=[];return o.forEach((a,c)=>{const i=n.get(a),f=new Map;i.forEach(l=>{const g=T(l,e.series,"");f.has(g)||f.set(g,[]),f.get(g).push(l)});let w=Array.from(f.keys());if(Array.isArray(e.series.sort))w=e.series.sort.filter(l=>f.has(l)).concat(w.filter(l=>!e.series.sort.includes(l)));else if(e.series.sort==="original"){const l=[];i.forEach(g=>{const C=T(g,e.series,"");l.includes(C)||l.push(C)}),w=l}else e.series.sort==="alphabetical"&&w.sort((l,g)=>l.localeCompare(g,void 0,{numeric:!0}));const x=new Map;i.forEach(l=>{const g=T(l,e.category,"");x.has(g)||x.set(g,[]),x.get(g).push(l)});let y=Array.from(x.keys());if(Array.isArray(e.category.sort))y=e.category.sort.filter(l=>x.has(l)).concat(y.filter(l=>!e.category.sort.includes(l)));else if(e.category.sort==="original"){const l=[];i.forEach(g=>{const C=T(g,e.category,"");l.includes(C)||l.push(C)}),y=l}else e.category.sort==="alphabetical"&&y.sort((l,g)=>l.localeCompare(g,void 0,{numeric:!0}));const S=new Map;i.forEach(l=>{const g=l.id||"unknown";S.has(g)||S.set(g,[]),S.get(g).push(l)});let m=0;const p=w[0]||"",b=w.indexOf(p),O=new Map;Array.from(S.entries()).forEach(([l,g])=>{const C=g[0],B=T(C,e.series,""),v=w.indexOf(B),A=T(C,e.category,""),_=y.indexOf(A);if(e.value.aggregate==="none"){const P=C[e.value.from],k={id:l,index:m++,modelType:"tree",name:C.name||l,data:C.data,value:typeof P=="number"?P:null,color:D(e.color.by,{index:m-1,seriesIndex:v,categoryIndex:_,datasetIndex:c},r),parent:C.parent||null,parentIndex:null,depth:0,seq:0,children:[],series:B,seriesIndex:v,category:A,categoryIndex:_};O.set(l,k)}else{const P=g.map(V=>{if(e.value.aggregate==="count")return 1;const N=V[e.value.from];return typeof N=="number"?N:null}),k=ye(P,e.value.aggregate),L={id:l,index:m++,modelType:"tree",name:C.name||l,data:C.data,value:k,color:D(e.color.by,{index:m-1,seriesIndex:v,categoryIndex:_,datasetIndex:c},r),parent:C.parent||null,parentIndex:null,depth:0,seq:0,children:[],series:B,seriesIndex:v,category:A,categoryIndex:_};O.set(l,L)}});const $=Array.from(O.values()),h=new Map;$.forEach(l=>{h.set(l.id,l.index)}),$.forEach(l=>{l.parent&&h.has(l.parent)&&(l.parentIndex=h.get(l.parent))});const d=[],E=new Map;$.forEach(l=>{l.parent===null?d.push(l):(E.has(l.parent)||E.set(l.parent,[]),E.get(l.parent).push(l))});function j(l,g){l.depth=g;const C=E.get(l.id)||[];return e.value.sort==="asc"?C.sort((B,v)=>B.value===null&&v.value===null?0:B.value===null?1:v.value===null?-1:B.value-v.value):e.value.sort==="desc"&&C.sort((B,v)=>B.value===null&&v.value===null?0:B.value===null?1:v.value===null?-1:v.value-B.value),C.forEach((B,v)=>{B.seq=v}),l.children=C.map(B=>j(B,g+1)),l}const I=d.map(l=>j(l,0));if(I.length===0)u.push({id:`empty-${a}`,index:m++,modelType:"tree",name:"Empty Tree",data:{},value:null,color:D(e.color.by,{index:m-1,seriesIndex:b<0?0:b,categoryIndex:0,datasetIndex:c},r),parent:null,parentIndex:null,depth:0,seq:0,children:[],series:p,seriesIndex:b<0?0:b,category:"",categoryIndex:0});else if(I.length===1)u.push(I[0]);else{const l={id:`virtual-root-${a}`,index:m++,modelType:"tree",name:`Virtual Root (${a})`,data:{},value:null,color:D(e.color.by,{index:m-1,seriesIndex:b<0?0:b,categoryIndex:0,datasetIndex:c},r),parent:null,parentIndex:null,depth:0,seq:0,children:I.map((g,C)=>{const B=(v,A)=>(v.depth=A,A===1&&(v.seq=C),v.children=v.children.map(_=>B(_,A+1)),v);return B(g,1)}),series:p,seriesIndex:b<0?0:b,category:"",categoryIndex:0};u.push(l)}}),u};function Dr(t,e,r){const n=e.map(a=>r[a]).filter(a=>a&&a.parentNode===t);if(n.length===0)return;let s=!0,o=null;for(const a of n){if(o&&o.nextElementSibling!==a){s=!1;break}o=a}if(s)return;const u=document.createDocumentFragment();e.forEach(a=>{const c=r[a];c&&c.parentNode===t&&u.appendChild(c)}),t.appendChild(u)}function Ot(t,e,r,n,s){Object.keys(r).filter(i=>!e.includes(i)).forEach(i=>{const f=r[i];f&&f.parentNode===t&&t.removeChild(f),delete r[i]});const a=e.filter(i=>!r[i]);a.forEach(i=>{const f=n(i);r[i]=f,t.appendChild(f)}),e.filter(i=>r[i]&&!a.includes(i)).forEach(i=>{r[i]}),e.length>0&&Dr(t,e,r)}function Nr(t){return R({element:t},{element:{toBe:"Dom",test:r=>Pe(r)}})}function Gr(t){return R(t,{width:{toBe:'"auto" | number',test:r=>r==="auto"||typeof r=="number"},height:{toBe:'"auto" | number',test:r=>r==="auto"||typeof r=="number"},resizeDebounce:{toBe:"number",test:r=>typeof r=="number"}})}function $t(t){const e=R(t,{colorScheme:{toBe:'"dark" | "light" | "auto"',test:r=>r==="dark"||r==="light"||r==="auto"},colors:{toBeTypes:["object"],test:r=>r.light&&r.dark},fontSize:{toBeTypes:["string"]}});if(t.colors){const r=R(t.colors,{light:{toBeTypes:["object"],test:n=>n.data&&n.primary&&n.secondary&&n.dataContrast&&n.background},dark:{toBeTypes:["object"],test:n=>n.data&&n.primary&&n.secondary&&n.dataContrast&&n.background}});if(r.status==="error")return r;if(t.colors.light){const n=R(t.colors.light,{data:{toBeTypes:["string[]"]},primary:{toBeTypes:["string"]},secondary:{toBeTypes:["string"]},dataContrast:{toBeTypes:["string[]"]},background:{toBeTypes:["string"]}});if(n.status==="error")return n}if(t.colors.dark){const n=R(t.colors.dark,{data:{toBeTypes:["string[]"]},primary:{toBeTypes:["string"]},secondary:{toBeTypes:["string"]},dataContrast:{toBeTypes:["string[]"]},background:{toBeTypes:["string"]}});if(n.status==="error")return n}}return e}function It(t){const e=R(t,{dataset:{toBeTypes:["object"]},series:{toBeTypes:["object"]},category:{toBeTypes:["object"]},value:{toBeTypes:["object"]},multivariate:{toBeTypes:["object"]},color:{toBeTypes:["object"]}});if(t.dataset){const r=R(t.dataset,{from:{toBeTypes:["string"]},sort:{toBe:'"original" | "alphabetical" | string[]',test:n=>n==="original"||n==="alphabetical"||Array.isArray(n)&&n.every(s=>typeof s=="string")},ignore:{toBeTypes:["boolean"]}});if(r.status==="error")return r}if(t.series){const r=R(t.series,{from:{toBeTypes:["string"]},sort:{toBe:'"original" | "alphabetical" | string[]',test:n=>n==="original"||n==="alphabetical"||Array.isArray(n)&&n.every(s=>typeof s=="string")},ignore:{toBeTypes:["boolean"]}});if(r.status==="error")return r}if(t.category){const r=R(t.category,{from:{toBeTypes:["string"]},sort:{toBe:'"original" | "alphabetical" | string[]',test:n=>n==="original"||n==="alphabetical"||Array.isArray(n)&&n.every(s=>typeof s=="string")},ignore:{toBeTypes:["boolean"]}});if(r.status==="error")return r}if(t.value){const r=R(t.value,{from:{toBeTypes:["string"]},sort:{toBe:'"original" | "asc" | "desc"',test:n=>n==="original"||n==="asc"||n==="desc"},aggregate:{toBe:'"sum" | "mean" | "median" | "min" | "max" | "count" | "none"',test:n=>["sum","mean","median","min","max","count","none"].includes(n)}});if(r.status==="error")return r}if(t.multivariate){const r=R({multivariate:t.multivariate},{multivariate:{toBe:"EncodingMultivariateItem[]",test:n=>Array.isArray(n)&&n.every(s=>typeof s.from=="string"&&typeof s.label=="string")}});if(r.status==="error")return r}if(t.color){const r=R(t.color,{by:{toBe:'"index" | "series" | "category" | "dataset"',test:n=>["index","series","category","dataset"].includes(n)}});if(r.status==="error")return r}return e}function Bt(t){return R({data:t},{data:{toBe:"RawDataColumn[] | RawDataColumn[][]",test:r=>Array.isArray(r)&&r.every(n=>Array.isArray(n)||H(n))}})}function ke(t){return R({plugins:t},{plugins:{toBe:"PluginEntity[]",test:r=>Array.isArray(r)&&r.every(n=>H(n)&&typeof n._name=="string"&&typeof n._injectContext=="function")}})}function Ur(t){if(!t)return{status:"success",columnName:"",expectToBe:""};const e=R(t,{size:{toBeTypes:["object"]},theme:{toBeTypes:["object"]},data:{toBe:"RawDataColumn[] | RawDataColumn[][]",test:r=>Array.isArray(r)},encoding:{toBeTypes:["object"]},plugins:{toBe:"PluginEntity[]",test:r=>Array.isArray(r)&&r.every(n=>H(n)&&typeof n._name=="string"&&typeof n._injectContext=="function")}});if(e.status==="error")return e;if(t.size){const r=Gr(t.size);if(r.status==="error")return r}if(t.theme){const r=$t(t.theme);if(r.status==="error")return r}if(t.encoding){const r=It(t.encoding);if(r.status==="error")return r}if(t.data){const r=Bt(t.data);if(r.status==="error")return r}if(t.plugins){const r=ke(t.plugins);if(r.status==="error")return r}return e}function zr({svgElement$:t,canvasElement$:e,pluginsInstance$:r}){let n=[],s=[];const o=(c,i,f)=>{const w=r.getValue().reduce((S,m,p)=>(S[m._getId()]=p,S),{}),x=f.map(S=>({...S,pluginSeq:w[S.pluginId]}));return(c==="svg"?n:s).filter(S=>S.pluginId!==i).map(S=>({...S,pluginSeq:w[S.pluginId]})).concat(x).sort((S,m)=>S.layerIndex-m.layerIndex||S.pluginSeq-m.pluginSeq)},u={},a={};return(c,i,f)=>{const w=c==="svg"?t.getValue():e.getValue();if(!w)return{};const x=c==="svg"?u:a,y=o(c,i,f),S=y.map(p=>xt(p.pluginId,p.layerName));return c==="svg"?(Ot(w,S,x,p=>wt(p)),n=y):(Ot(w,S,x,p=>Me(p)),s=y),Object.entries(x).reduce((p,[b,O])=>{const[$,h,d]=b.split("-");return h===i&&(p[d]=O),p},{})}}const qr=(t,e)=>{try{const{status:b,columnName:O,expectToBe:$}=Ur(e);if(b==="error")throw new Error(Q({columnName:O,expectToBe:$,from:"Chart.constructor"}));if(b==="warning")console.warn(X({columnName:O,expectToBe:$,from:"Chart.constructor"}));else{const{status:h,columnName:d,expectToBe:E}=Nr(t);if(h==="error")throw new Error(Q({columnName:d,expectToBe:E,from:"Chart.constructor"}));h==="warning"&&console.warn(X({columnName:d,expectToBe:E,from:"Chart.constructor"}))}}catch(b){throw new Error(b)}const r=new ie,n=new G((e==null?void 0:e.data)||[]),s=e&&e.encoding?q(Ct,e.encoding):Ct,o=new G(s),u=e&&e.theme?q(Tt,e.theme):Tt,a=new G(u),c=new G((e==null?void 0:e.plugins)||[]),i=e&&e.size?q(_t,e.size):_t,f=new G(i),w=new G(null),x=new G(null),y=(()=>{const b=f.pipe(Br(v=>Or(()=>v.width==="auto"||v.height==="auto",At(t).pipe(z(A=>({width:v.width==="auto"?A.width:v.width,height:v.height==="auto"?A.height<=0?A.width:A.height:v.height})),J(v.resizeDebounce),$r((A,_)=>JSON.stringify(A)===JSON.stringify(_))),pr({width:v.width,height:v.height}))),be(r),se(1)),O=o.asObservable().pipe(se(1)),$=te([n,o,a]).pipe(J(0),z(([v,A,_])=>{try{return Lr(v,A,_)}catch(P){throw new Error(de({from:"Chart.seriesData$",systemMessage:P}))}}),he(v=>(console.error(U(v)),me)),se(1)),h=te([n,o,a]).pipe(J(0),z(([v,A,_])=>{try{return Vr(v,A,_)}catch(P){throw new Error(de({from:"Chart.gridData$",systemMessage:P}))}}),he(v=>(console.error(U(v)),me)),se(1)),d=te([n,o,a]).pipe(J(0),z(([v,A,_])=>{try{return Kr(v,A,_)}catch(P){throw new Error(de({from:"Chart.multivariateData$",systemMessage:P}))}}),he(v=>(console.error(U(v)),me)),se(1)),E=te([n,o,a]).pipe(J(0),z(([v,A,_])=>{try{return Rr(v,A,_)}catch(P){throw new Error(de({from:"Chart.graphData$",systemMessage:P}))}}),he(v=>(console.error(U(v)),me)),se(1)),j=te([n,o,a]).pipe(J(0),z(([v,A,_])=>{try{return Fr(v,A,_)}catch(P){throw new Error(de({from:"Chart.treeData$",systemMessage:P}))}}),he(v=>(console.error(U(v)),me)),se(1)),I=new G([]);c.pipe(be(r)).subscribe(v=>{const A={},_=v.map(k=>{var V;let L=k._getId();if(A[L]){const N=((V=A[L].split("[")[1])==null?void 0:V.split("]")[0])||"0",re=parseInt(N)+1;L=`${L.split("[")[0]}[${re}]`}return A[L]=k._getId(),L});v.forEach((k,L)=>k._setId(_[L]));const P=v.map(k=>({id:k._getId(),name:k._name,elementType:k._elementType,shownLayers:k.getShownLayerNames()}));I.next(P)});const l=a.asObservable().pipe(se(1)),g=new ie,C=g.asObservable().pipe(ct());return{root:t,svg:null,canvas:null,size$:b,encoding$:O,seriesData$:$,gridData$:h,multivariateData$:d,graphData$:E,treeData$:j,plugins$:I,theme$:l,event$:C,eventTrigger$:g,_updateLayerElements:zr({svgElement$:w,canvasElement$:x,pluginsInstance$:c})}})();let S=null;const m=()=>(S||(S=document.createElement("div"),S.classList.add("orbcharts-container"),S.style.position="relative",t.appendChild(S)),S);let p=[];return c.pipe(be(r)).subscribe(b=>{p.filter(d=>!b.includes(d)).forEach(d=>{y._updateLayerElements(d._elementType,d._getId(),[]),d.destroy()}),p=b;let $=!1,h=!1;b.forEach(d=>{d._elementType==="svg"?$=!0:d._elementType==="canvas"&&(h=!0)}),$&&!y.svg?(y.svg=bt("orbcharts-root-svg"),m().appendChild(y.svg),w.next(y.svg)):!$&&y.svg&&(y.svg.remove(),y.svg=null,w.next(null)),h&&!y.canvas?(y.canvas=Me("orbcharts-root-canvas"),m().appendChild(y.canvas),x.next(y.canvas)):!h&&y.canvas&&(y.canvas.remove(),y.canvas=null,x.next(null)),b.forEach(d=>{d._injectContext(y)})}),te({size:y.size$,svg:w}).pipe(J(0),ge(({svg:b})=>!!b),be(r)).subscribe(({size:b,svg:O})=>{O&&(O.setAttribute("width",b.width.toString()),O.setAttribute("height",b.height.toString()))}),te({size:y.size$,canvas:x}).pipe(J(0),ge(({canvas:b})=>!!b),be(r)).subscribe(({size:b,canvas:O})=>{O&&(O.width=b.width,O.height=b.height)}),(()=>{function b(v){f.next(v)}function O(v){try{const{status:A,columnName:_,expectToBe:P}=Bt(v);if(A==="error")throw new Error(Q({columnName:_,expectToBe:P,from:"Chart.setData"}));A==="warning"&&console.warn(X({columnName:_,expectToBe:P,from:"Chart.setData"}))}catch(A){console.error(U(A))}n.next(v)}function $(v){try{const{status:_,columnName:P,expectToBe:k}=It(v);if(_==="error")throw new Error(Q({columnName:P,expectToBe:k,from:"Chart.updateEncoding"}));_==="warning"&&console.warn(X({columnName:P,expectToBe:k,from:"Chart.updateEncoding"}))}catch(_){console.error(U(_))}const A=q(o.getValue(),v);o.next(A)}function h(v){o.next(v)}function d(){return o.getValue()}function E(v){try{const{status:A,columnName:_,expectToBe:P}=ke(v);if(A==="error")throw new Error(Q({columnName:_,expectToBe:P,from:"Chart.setPlugins"}));A==="warning"&&console.warn(X({columnName:_,expectToBe:P,from:"Chart.setPlugins"}))}catch(A){console.error(U(A))}c.next(v)}function j(v){try{const{status:A,columnName:_,expectToBe:P}=ke([v]);if(A==="error")throw new Error(Q({columnName:_,expectToBe:P,from:"Chart.addPlugin"}));A==="warning"&&console.warn(X({columnName:_,expectToBe:P,from:"Chart.addPlugin"}))}catch(A){console.error(U(A))}c.next([...c.getValue(),v])}function I(v){c.next(c.getValue().filter(A=>A._getId()!==v))}function l(v){try{const{status:_,columnName:P,expectToBe:k}=$t(v);if(_==="error")throw new Error(Q({columnName:P,expectToBe:k,from:"Chart.updateTheme"}));_==="warning"&&console.warn(X({columnName:P,expectToBe:k,from:"Chart.updateTheme"}))}catch(_){console.error(U(_))}const A=q(a.getValue(),v);a.next(A)}function g(v){a.next(v)}function C(){return a.getValue()}function B(){r.next(void 0),c.getValue().forEach(v=>v.destroy()),Et(t),S=null}return{resize:b,setData:O,updateEncoding:$,forceReplaceEncoding:h,getEncoding:d,setPlugins:E,addPlugin:j,removePlugin:I,updateTheme:l,forceReplaceTheme:g,getTheme:C,destroy:B,context:y}})()};class Wr{constructor(e,r){return qr(e,r)}}const Pt=(t,e,r)=>{let n=e.name,s=()=>{};const o=new G(null),u=o.pipe(ge(h=>h!==null)),a=e.layers.map(h=>new h),c={...a.reduce((h,d)=>(h[d._name]=d,h),{})},i=()=>new Set(a.map(h=>h._name)),f=h=>{if(h){const d=i();return Object.keys(h).filter(j=>d.has(j))}return[]},w=a.reduce((h,d)=>(d._initShow&&h.push(d._name),h),[]),x=f(r),y=new G(new Set(x.length>0?x:w)),S=y.pipe(z(h=>Array.from(h).map(E=>{var j;return[E,((j=a.find(I=>I._name===E))==null?void 0:j._layerIndex)??-1]}).filter(([,E])=>E!==-1).sort((E,j)=>E[1]-j[1]).map(([E])=>E)));let m=q(e.defaultParams??{},r??{});const p=new G(r??{}),b=new ie,O=new F(h=>{p.subscribe(d=>{try{const{status:E,columnName:j,expectToBe:I}=e.validator(d);if(E==="error")throw new Error(Q({columnName:j,expectToBe:I,from:`${e.name}.params$`}));E==="warning"&&console.warn(X({columnName:j,expectToBe:I,from:`${e.name}.params$`}))}catch(E){console.error(U(E))}h.next(m)}),b.subscribe(d=>{h.next(d)})}),$=u.pipe(z(h=>({context:h,pluginParams$:O})));return te({pluginSetupProps:$,ShownLayerNameSet:y,shownLayerNamesSeq:S}).pipe(J(0)).subscribe(({pluginSetupProps:h,ShownLayerNameSet:d,shownLayerNamesSeq:E})=>{s();const j=h.context._updateLayerElements(t,n,E.map(I=>({pluginId:n,pluginName:e.name,layerName:I,layerIndex:c[I]._layerIndex})));e.setup&&(s=e.setup(h)),a.forEach(I=>{var l,g;if(d.has(I._name)){const C=t==="svg"?{svgG:j[I._name],context:h.context,pluginParams$:O,initLayerParams:((l=p.getValue())==null?void 0:l[I._name])||{}}:{canvas:j[I._name],context:h.context,pluginParams$:O,initLayerParams:((g=p.getValue())==null?void 0:g[I._name])||{}};I._enable(C)}else I._disable()})}),{_name:e.name,_elementType:t,_getId:()=>n,_setId:h=>{n=h},_injectContext:h=>{o.next(Object.assign({},h))},show:h=>{h=Array.isArray(h)?h:[h],y.next(new Set([...Array.from(y.getValue()),...h]))},showOnly:h=>{h=Array.isArray(h)?h:[h],y.next(new Set([...h]))},showAll:()=>{y.next(i())},hide:h=>{h=Array.isArray(h)?h:[h],y.next(new Set([...Array.from(y.getValue()).filter(d=>!h.includes(d))]))},hideAll:()=>{y.next(new Set)},toggle:h=>{h=Array.isArray(h)?h:[h],Array.from(y.getValue()).forEach(d=>{h.includes(d)?h.splice(h.indexOf(d),1):h.push(d)}),y.next(new Set(h))},getShownLayerNames:()=>Array.from(y.getValue()),updateParams:h=>{m=q(m,h),p.next(h),Object.keys(h).forEach(d=>{const E=c[d];E&&E._updateParams(h[d])})},forceReplaceParams:h=>{m=h,b.next(h),Object.keys(h).forEach(d=>{const E=c[d];E&&E._forceReplaceParams(h[d])})},getParams:()=>{const h=Object.assign({},m);return a.forEach(d=>{h[d._name]=d._getParams()}),h},destroy:()=>{s(),a.forEach(h=>{h._destroy()})}}},Yr=t=>class{constructor(r){return Pt("svg",t,r)}},Mt=(t,e)=>{const r=new G(Object.assign({},e.defaultParams));let n=()=>{};const s=new G(null),o=s.pipe(ge(u=>u!==null));return te({layerParams:r,enabledProps:o}).pipe(J(0)).subscribe(({layerParams:u,enabledProps:a})=>{n(),n=t==="svg"?e.setup({svgG:a.svgG,context:a.context,pluginParams$:a.pluginParams$,layerParams$:r.pipe(z(c=>q(c,a.initLayerParams??{})))}):e.setup({canvas:a.canvas,context:a.context,pluginParams$:a.pluginParams$,layerParams$:r.pipe(z(c=>q(c,a.initLayerParams??{})))})}),s.pipe(ge(u=>u===null)).subscribe(()=>{n()}),{_name:e.name,_defaultParams:e.defaultParams,_layerIndex:e.layerIndex,_initShow:e.initShow,_enable:u=>{s.next(u)},_disable:()=>{s.next(null)},_updateParams:u=>{try{const{status:c,columnName:i,expectToBe:f}=e.validator(u);if(c==="error")throw new Error(Q({columnName:i,expectToBe:f,from:`${e.name}.params$`}));c==="warning"&&console.warn(X({columnName:i,expectToBe:f,from:`${e.name}.params$`}))}catch(c){console.error(U(c))}const a=q(r.getValue(),u);r.next(a)},_forceReplaceParams:u=>{r.next(u)},_getParams:()=>r.getValue(),_destroy:()=>{s.next(null)}}},Zr=t=>class{constructor(){return Mt("svg",t)}},Jr=t=>class{constructor(r){return Pt("canvas",t,r)}},Hr=t=>class{constructor(){return Mt("canvas",t)}};M.OrbCharts=Wr,M.aggregate=ye,M.count=pt,M.createCanvas=Me,M.createCanvasElement=Mr,M.createDiv=jr,M.createLayerClassName=xt,M.createMessagePrefix=je,M.createOrbChartsErrorMessage=U,M.createPluginClassName=St,M.createSVG=bt,M.createSVGGroup=wt,M.createUnexpectedErrorMessage=de,M.createValidatorErrorMessage=Q,M.createValidatorWarningMessage=X,M.deepOverwrite=q,M.defineCanvasLayer=Hr,M.defineCanvasPlugin=Jr,M.defineSVGLayer=Zr,M.defineSVGPlugin=Yr,M.formatCommaNumber=Pr,M.getColorByFrom=D,M.getColorByIndex=mt,M.isDom=Pe,M.isFunction=gt,M.isPlainObject=H,M.max=dt,M.mean=ft,M.median=ht,M.min=yt,M.none=vt,M.removeElementChildren=Et,M.resizeObservable=At,M.resolveGroupKey=T,M.sum=lt,M.validateObject=R,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
package/src/chart/createChart.ts
CHANGED
|
@@ -678,7 +678,7 @@ export const createChart: CreateChart = (element, options) => {
|
|
|
678
678
|
shareReplay(1)
|
|
679
679
|
)
|
|
680
680
|
const plugins$ = new BehaviorSubject<PluginInfo[]>([])
|
|
681
|
-
pluginsInstance$.subscribe(plugins => {
|
|
681
|
+
pluginsInstance$.pipe(takeUntil(destroy$)).subscribe(plugins => {
|
|
682
682
|
const pluginIdRecord: Record<string, string> = {}
|
|
683
683
|
const pluginIds = plugins.map(plugin => {
|
|
684
684
|
let id = plugin._getId()
|
|
@@ -768,7 +768,7 @@ export const createChart: CreateChart = (element, options) => {
|
|
|
768
768
|
|
|
769
769
|
// inject context into plugins
|
|
770
770
|
let previousPlugins: PluginEntity<any, unknown, unknown>[] = []
|
|
771
|
-
pluginsInstance$.subscribe(plugins => {
|
|
771
|
+
pluginsInstance$.pipe(takeUntil(destroy$)).subscribe(plugins => {
|
|
772
772
|
// -- 清理被移除的 plugin --
|
|
773
773
|
// setPlugins()/removePlugin() 換掉的舊 plugin,若沒有新 plugin 用相同
|
|
774
774
|
// pluginId 重新呼叫 _updateLayerElements(例如從 GridPlot 換成
|
|
@@ -825,7 +825,8 @@ export const createChart: CreateChart = (element, options) => {
|
|
|
825
825
|
svg: svgElement$,
|
|
826
826
|
}).pipe(
|
|
827
827
|
debounceTime(0),
|
|
828
|
-
filter(({ svg }) => !!svg)
|
|
828
|
+
filter(({ svg }) => !!svg),
|
|
829
|
+
takeUntil(destroy$)
|
|
829
830
|
).subscribe(({ size, svg }) => {
|
|
830
831
|
if (svg) {
|
|
831
832
|
svg.setAttribute('width', size.width.toString())
|
|
@@ -838,7 +839,8 @@ export const createChart: CreateChart = (element, options) => {
|
|
|
838
839
|
canvas: canvasElement$
|
|
839
840
|
}).pipe(
|
|
840
841
|
debounceTime(0),
|
|
841
|
-
filter(({ canvas }) => !!canvas)
|
|
842
|
+
filter(({ canvas }) => !!canvas),
|
|
843
|
+
takeUntil(destroy$)
|
|
842
844
|
).subscribe(({ size, canvas }) => {
|
|
843
845
|
if (canvas) {
|
|
844
846
|
canvas.width = size.width
|
package/src/layer/createLayer.ts
CHANGED
|
@@ -47,7 +47,7 @@ export const createLayer = <
|
|
|
47
47
|
debounceTime(0)
|
|
48
48
|
).subscribe(({ layerParams, enabledProps }) => {
|
|
49
49
|
destroySetup()
|
|
50
|
-
destroySetup = elementType === 'svg' ?
|
|
50
|
+
destroySetup = elementType === 'svg' ?
|
|
51
51
|
config.setup({
|
|
52
52
|
svgG: (enabledProps as LayerEnableProps<'svg', ExtendContext, PluginParams, LayerParams>).svgG,
|
|
53
53
|
// canvas: enabledProps.canvas,
|
|
@@ -130,9 +130,11 @@ export const createLayer = <
|
|
|
130
130
|
// enableProps$.next(true)
|
|
131
131
|
// },
|
|
132
132
|
_destroy: () => {
|
|
133
|
+
// 不能 complete() enableProps$/layerParams$:同一個 layer 物件(隨 plugin
|
|
134
|
+
// 物件)可能在 chart 銷毀後被沿用、重新 _enable() 到新的 chart instance
|
|
135
|
+
// (見 createPlugin.ts destroy() 的說明)。complete() 之後 .next() 會被
|
|
136
|
+
// 靜默忽略,之後的 _enable() 永遠無法讓這個 layer 重新畫出內容。
|
|
133
137
|
enableProps$.next(null)
|
|
134
|
-
enableProps$.complete()
|
|
135
|
-
layerParams$.complete()
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
}
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
of,
|
|
9
9
|
shareReplay,
|
|
10
10
|
debounceTime,
|
|
11
|
-
first,
|
|
12
11
|
Observable,
|
|
13
12
|
Subject,
|
|
14
13
|
} from 'rxjs'
|
|
@@ -240,8 +239,14 @@ export const createPlugin = <
|
|
|
240
239
|
context, // 初始化時 context 有可能被 in place 擴展
|
|
241
240
|
pluginParams$
|
|
242
241
|
}
|
|
243
|
-
})
|
|
244
|
-
first()
|
|
242
|
+
})
|
|
243
|
+
// 不能用 first():同一個 plugin 物件可能被重新 _injectContext() 綁定到
|
|
244
|
+
// 「另一個」全新的 chart instance(例如呼叫端銷毀舊 chart 後、沿用同一組
|
|
245
|
+
// plugin 物件建立新 chart——React StrictMode 的掛載→清除→再掛載就是這種
|
|
246
|
+
// 情境)。first() 只接受第一次注入的 context、之後永久 complete,會讓後續
|
|
247
|
+
// 重新注入的 context 被靜靜地忽略,導致新 chart 的這個 plugin 永遠不會
|
|
248
|
+
// 觸發 _updateLayerElements/_enable,畫面呈現「plugin 已建立、layer 群組
|
|
249
|
+
// 存在,但沒有畫出任何圖形」(保留 pluginSetupProps$ 為 hot、可重複觸發)。
|
|
245
250
|
)
|
|
246
251
|
|
|
247
252
|
combineLatest({
|
|
@@ -251,7 +256,10 @@ export const createPlugin = <
|
|
|
251
256
|
}).pipe(
|
|
252
257
|
debounceTime(0)
|
|
253
258
|
).subscribe(({ pluginSetupProps, ShownLayerNameSet, shownLayerNamesSeq }) => {
|
|
254
|
-
|
|
259
|
+
// 重新綁定到新 context 前,先清掉上一次 setup 留下的狀態——否則同一個
|
|
260
|
+
// plugin 物件被重新注入時會疊加執行兩次 config.setup(),造成重複綁定/洩漏
|
|
261
|
+
destroySetup()
|
|
262
|
+
|
|
255
263
|
// 更新 layer elements
|
|
256
264
|
const layerElements = pluginSetupProps.context._updateLayerElements(
|
|
257
265
|
elementType,
|
|
@@ -470,11 +478,15 @@ export const createPlugin = <
|
|
|
470
478
|
// }),
|
|
471
479
|
destroy: () => {
|
|
472
480
|
destroySetup()
|
|
473
|
-
//
|
|
474
|
-
|
|
475
|
-
//
|
|
476
|
-
|
|
477
|
-
|
|
481
|
+
// 不能 complete() context$/ShownLayerNameSet$:這個 plugin 物件本身可能被
|
|
482
|
+
// 銷毀後的 chart 沿用、重新 _injectContext() 到「另一個」全新的 chart
|
|
483
|
+
// instance(React StrictMode 的掛載→清除→再掛載就是這種情境,見
|
|
484
|
+
// _injectContext 上方註解)。RxJS 的 Subject 一旦 complete(),之後任何
|
|
485
|
+
// .next() 都會被靜默忽略——把這裡 complete 掉會讓重新注入的 context 永遠
|
|
486
|
+
// 失效,畫面呈現「plugin 已建立、layer 群組存在,但沒有畫出任何圖形」甚至
|
|
487
|
+
// 連 layer 群組都不會建立。這兩個 Subject 的訂閱設計上就是要跟著 plugin
|
|
488
|
+
// 物件活一輩子、反應每次新的注入,不需要也不應該在 destroy 時終結它們。
|
|
489
|
+
|
|
478
490
|
// layers 為本實例專屬,destroy 不影響其他 plugin 實例
|
|
479
491
|
layers.forEach((layer) => {
|
|
480
492
|
layer._destroy()
|