@orbcharts/core 4.0.0-alpha.0 → 4.0.0-beta.1

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(T,oe){typeof exports=="object"&&typeof module<"u"?oe(exports):typeof define=="function"&&define.amd?define(["exports"],oe):(T=typeof globalThis<"u"?globalThis:T||self,oe(T["orbcharts-core"]={}))})(this,function(T){"use strict";var oe=function(t,e){return oe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])},oe(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");oe(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function jt(t,e,r,n){function o(s){return s instanceof r?s:new r(function(u){u(s)})}return new(r||(r=Promise))(function(s,u){function a(h){try{i(n.next(h))}catch(b){u(b)}}function l(h){try{i(n.throw(h))}catch(b){u(b)}}function i(h){h.done?s(h.value):o(h.value).then(a,l)}i((n=n.apply(t,e||[])).next())})}function Ve(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,o,s,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(h){return l([i,h])}}function l(i){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,i[0]&&(r=0)),r;)try{if(n=1,o&&(s=i[0]&2?o.return:i[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,i[1])).done)return s;switch(o=0,s&&(i=[i[0]&2,s.value]),i[0]){case 0:case 1:s=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,o=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!s||i[1]>s[0]&&i[1]<s[3])){r.label=i[1];break}if(i[0]===6&&r.label<s[1]){r.label=s[1],s=i;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(i);break}s[2]&&r.ops.pop(),r.trys.pop();continue}i=e.call(t,r)}catch(h){i=[6,h],o=0}finally{n=s=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ie(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 ue(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,s=[],u;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(a){u={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(u)throw u.error}}return s}function le(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,s;n<o;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}function ce(t){return this instanceof ce?(this.v=t,this):new ce(t)}function kt(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",u),o[Symbol.asyncIterator]=function(){return this},o;function u(m){return function(v){return Promise.resolve(v).then(m,b)}}function a(m,v){n[m]&&(o[m]=function(y){return new Promise(function(p,E){s.push([m,y,p,E])>1||l(m,y)})},v&&(o[m]=v(o[m])))}function l(m,v){try{i(n[m](v))}catch(y){w(s[0][3],y)}}function i(m){m.value instanceof ce?Promise.resolve(m.value.v).then(h,b):w(s[0][2],m)}function h(m){l("next",m)}function b(m){l("throw",m)}function w(m,v){m(v),s.shift(),s.length&&l(s[0][0],s[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 ie=="function"?ie(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(u){return new Promise(function(a,l){u=t[s](u),o(a,l,u.done,u.value)})}}function o(s,u,a,l){Promise.resolve(l).then(function(i){s({value:i,done:a})},u)}}typeof SuppressedError=="function"&&SuppressedError;function V(t){return typeof t=="function"}function xe(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 Se=xe(function(t){return function(r){t(this),this.message=r?r.length+` errors occurred during unsubscription:
1
+ (function(P,se){typeof exports=="object"&&typeof module<"u"?se(exports):typeof define=="function"&&define.amd?define(["exports"],se):(P=typeof globalThis<"u"?globalThis:P||self,se(P.orbchartsCore={}))})(this,function(P){"use strict";var se=function(t,e){return se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])},se(t,e)};function Y(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");se(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function jt(t,e,r,n){function o(s){return s instanceof r?s:new r(function(u){u(s)})}return new(r||(r=Promise))(function(s,u){function a(f){try{i(n.next(f))}catch(w){u(w)}}function l(f){try{i(n.throw(f))}catch(w){u(w)}}function i(f){f.done?s(f.value):o(f.value).then(a,l)}i((n=n.apply(t,e||[])).next())})}function Le(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,o,s,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 l([i,f])}}function l(i){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,i[0]&&(r=0)),r;)try{if(n=1,o&&(s=i[0]&2?o.return:i[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,i[1])).done)return s;switch(o=0,s&&(i=[i[0]&2,s.value]),i[0]){case 0:case 1:s=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,o=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!s||i[1]>s[0]&&i[1]<s[3])){r.label=i[1];break}if(i[0]===6&&r.label<s[1]){r.label=s[1],s=i;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(i);break}s[2]&&r.ops.pop(),r.trys.pop();continue}i=e.call(t,r)}catch(f){i=[6,f],o=0}finally{n=s=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ie(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 ue(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,s=[],u;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(a){u={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(u)throw u.error}}return s}function le(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,s;n<o;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}function ce(t){return this instanceof ce?(this.v=t,this):new ce(t)}function kt(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",u),o[Symbol.asyncIterator]=function(){return this},o;function u(y){return function(x){return Promise.resolve(x).then(y,w)}}function a(y,x){n[y]&&(o[y]=function(m){return new Promise(function(p,b){s.push([y,m,p,b])>1||l(y,m)})},x&&(o[y]=x(o[y])))}function l(y,x){try{i(n[y](x))}catch(m){S(s[0][3],m)}}function i(y){y.value instanceof ce?Promise.resolve(y.value.v).then(f,w):S(s[0][2],y)}function f(y){l("next",y)}function w(y){l("throw",y)}function S(y,x){y(x),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Lt(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 ie=="function"?ie(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(u){return new Promise(function(a,l){u=t[s](u),o(a,l,u.done,u.value)})}}function o(s,u,a,l){Promise.resolve(l).then(function(i){s({value:i,done:a})},u)}}typeof SuppressedError=="function"&&SuppressedError;function V(t){return typeof t=="function"}function xe(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 Se=xe(function(t){return function(r){t(this),this.message=r?r.length+` errors occurred during unsubscription:
2
2
  `+r.map(function(n,o){return o+1+") "+n.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=r}});function be(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,o,s;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var a=ie(u),l=a.next();!l.done;l=a.next()){var i=l.value;i.remove(this)}}catch(y){e={error:y}}finally{try{l&&!l.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}else u.remove(this);var h=this.initialTeardown;if(V(h))try{h()}catch(y){s=y instanceof Se?y.errors:[y]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var w=ie(b),m=w.next();!m.done;m=w.next()){var v=m.value;try{Ke(v)}catch(y){s=s??[],y instanceof Se?s=le(le([],ue(s)),ue(y.errors)):s.push(y)}}}catch(y){n={error:y}}finally{try{m&&!m.done&&(o=w.return)&&o.call(w)}finally{if(n)throw n.error}}}if(s)throw new Se(s)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)Ke(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)&&be(r,e)},t.prototype.remove=function(e){var r=this._finalizers;r&&be(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),Le=pe.EMPTY;function Re(t){return t instanceof pe||t&&"closed"in t&&V(t.remove)&&V(t.add)&&V(t.unsubscribe)}function Ke(t){V(t)?t():t.unsubscribe()}var Lt={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],ue(r)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function Fe(t){Rt.setTimeout(function(){throw t})}function _e(){}function we(t){t()}var Ce=function(t){W(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=Dt,n}return e.create=function(r,n,o){return new me(r,n,o)},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),Kt=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){Ee(n)}},t.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(n){Ee(n)}else Ee(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){Ee(r)}},t}(),me=function(t){W(e,t);function e(r,n,o){var s=t.call(this)||this,u;return V(r)||!r?u={next:r??void 0,error:n??void 0,complete:o??void 0}:u=r,s.destination=new Kt(u),s}return e}(Ce);function Ee(t){Fe(t)}function Ft(t){throw t}var Dt={closed:!0,next:_e,error:Ft,complete:_e},Oe=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function ve(t){return t}function Nt(t){return t.length===0?ve:t.length===1?t[0]:function(r){return t.reduce(function(n,o){return o(n)},r)}}var K=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 o=this,s=Ut(e)?e:new me(e,r,n);return we(function(){var u=o,a=u.operator,l=u.source;s.add(a?a.call(s,l):l?o._subscribe(s):o._trySubscribe(s))}),s},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=De(r),new r(function(o,s){var u=new me({next:function(a){try{e(a)}catch(l){s(l),u.unsubscribe()}},error:s,complete:o});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 Nt(e)(this)},t.prototype.toPromise=function(e){var r=this;return e=De(e),new e(function(n,o){var s;r.subscribe(function(u){return s=u},function(u){return o(u)},function(){return n(s)})})},t.create=function(e){return new t(e)},t}();function De(t){var e;return(e=t??Lt.Promise)!==null&&e!==void 0?e:Promise}function Gt(t){return t&&V(t.next)&&V(t.error)&&V(t.complete)}function Ut(t){return t&&t instanceof Ce||Gt(t)&&Re(t)}function zt(t){return V(t==null?void 0:t.lift)}function D(t){return function(e){if(zt(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 N(t,e,r,n,o){return new qt(t,e,r,n,o)}var qt=function(t){W(e,t);function e(r,n,o,s,u,a){var l=t.call(this,r)||this;return l.onFinalize=u,l.shouldUnsubscribe=a,l._next=n?function(i){try{n(i)}catch(h){r.error(h)}}:t.prototype._next,l._error=s?function(i){try{s(i)}catch(h){r.error(h)}finally{this.unsubscribe()}}:t.prototype._error,l._complete=o?function(){try{o()}catch(i){r.error(i)}finally{this.unsubscribe()}}:t.prototype._complete,l}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}(Ce),Wt=xe(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),se=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 Ne(this,this);return n.operator=r,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Wt},e.prototype.next=function(r){var n=this;we(function(){var o,s;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var u=ie(n.currentObservers),a=u.next();!a.done;a=u.next()){var l=a.value;l.next(r)}}catch(i){o={error:i}}finally{try{a&&!a.done&&(s=u.return)&&s.call(u)}finally{if(o)throw o.error}}}})},e.prototype.error=function(r){var n=this;we(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var o=n.observers;o.length;)o.shift().error(r)}})},e.prototype.complete=function(){var r=this;we(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,o=this,s=o.hasError,u=o.isStopped,a=o.observers;return s||u?Le:(this.currentObservers=null,a.push(r),new pe(function(){n.currentObservers=null,be(a,r)}))},e.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,s=n.thrownError,u=n.isStopped;o?r.error(s):u&&r.complete()},e.prototype.asObservable=function(){var r=new K;return r.source=this,r},e.create=function(r,n){return new Ne(r,n)},e}(K),Ne=function(t){W(e,t);function e(r,n){var o=t.call(this)||this;return o.destination=r,o.source=n,o}return e.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},e.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.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,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:Le},e}(se),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,o=r.thrownError,s=r._value;if(n)throw o;return this._throwIfClosed(),s},e.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},e}(se),$e={now:function(){return($e.delegate||Date).now()},delegate:void 0},Yt=function(t){W(e,t);function e(r,n,o){r===void 0&&(r=1/0),n===void 0&&(n=1/0),o===void 0&&(o=$e);var s=t.call(this)||this;return s._bufferSize=r,s._windowTime=n,s._timestampProvider=o,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=n===1/0,s._bufferSize=Math.max(1,r),s._windowTime=Math.max(1,n),s}return e.prototype.next=function(r){var n=this,o=n.isStopped,s=n._buffer,u=n._infiniteTimeWindow,a=n._timestampProvider,l=n._windowTime;o||(s.push(r),!u&&s.push(a.now()+l)),this._trimBuffer(),t.prototype.next.call(this,r)},e.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),o=this,s=o._infiniteTimeWindow,u=o._buffer,a=u.slice(),l=0;l<a.length&&!r.closed;l+=s?1:2)r.next(a[l]);return this._checkFinalizedStatuses(r),n},e.prototype._trimBuffer=function(){var r=this,n=r._bufferSize,o=r._timestampProvider,s=r._buffer,u=r._infiniteTimeWindow,a=(u?1:2)*n;if(n<1/0&&a<s.length&&s.splice(0,s.length-a),!u){for(var l=o.now(),i=0,h=1;h<s.length&&s[h]<=l;h+=2)i=h;i&&s.splice(0,i+1)}},e}(se),Zt=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),Ge={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],ue(r)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},Jt=function(t){W(e,t);function e(r,n){var o=t.call(this,r,n)||this;return o.scheduler=r,o.work=n,o.pending=!1,o}return e.prototype.schedule=function(r,n){var o;if(n===void 0&&(n=0),this.closed)return this;this.state=r;var s=this.id,u=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(u,s,n)),this.pending=!0,this.delay=n,this.id=(o=this.id)!==null&&o!==void 0?o:this.requestAsyncId(u,this.id,n),this},e.prototype.requestAsyncId=function(r,n,o){return o===void 0&&(o=0),Ge.setInterval(r.flush.bind(r,this),o)},e.prototype.recycleAsyncId=function(r,n,o){if(o===void 0&&(o=0),o!=null&&this.delay===o&&this.pending===!1)return n;n!=null&&Ge.clearInterval(n)},e.prototype.execute=function(r,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var o=this._execute(r,n);if(o)return o;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(r,n){var o=!1,s;try{this.work(r)}catch(u){o=!0,s=u||new Error("Scheduled action threw falsy error")}if(o)return this.unsubscribe(),s},e.prototype.unsubscribe=function(){if(!this.closed){var r=this,n=r.id,o=r.scheduler,s=o.actions;this.work=this.state=this.scheduler=null,this.pending=!1,be(s,this),n!=null&&(this.id=this.recycleAsyncId(o,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(Zt),Ue=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}(),Ht=function(t){W(e,t);function e(r,n){n===void 0&&(n=Ue.now);var o=t.call(this,r,n)||this;return o.actions=[],o._active=!1,o}return e.prototype.flush=function(r){var n=this.actions;if(this._active){n.push(r);return}var o;this._active=!0;do if(o=r.execute(r.state,r.delay))break;while(r=n.shift());if(this._active=!1,o){for(;r=n.shift();)r.unsubscribe();throw o}},e}(Ue),Qt=new Ht(Jt),fe=new K(function(t){return t.complete()});function Xt(t){return t&&V(t.schedule)}function ze(t){return t[t.length-1]}function er(t){return V(ze(t))?t.pop():void 0}function qe(t){return Xt(ze(t))?t.pop():void 0}var We=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function Ye(t){return V(t==null?void 0:t.then)}function Ze(t){return V(t[Oe])}function Je(t){return Symbol.asyncIterator&&V(t==null?void 0:t[Symbol.asyncIterator])}function He(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 tr(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Qe=tr();function Xe(t){return V(t==null?void 0:t[Qe])}function et(t){return kt(this,arguments,function(){var r,n,o,s;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,ce(r.read())];case 3:return n=u.sent(),o=n.value,s=n.done,s?[4,ce(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,ce(o)];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 tt(t){return V(t==null?void 0:t.getReader)}function X(t){if(t instanceof K)return t;if(t!=null){if(Ze(t))return rr(t);if(We(t))return nr(t);if(Ye(t))return or(t);if(Je(t))return rt(t);if(Xe(t))return sr(t);if(tt(t))return ar(t)}throw He(t)}function rr(t){return new K(function(e){var r=t[Oe]();if(V(r.subscribe))return r.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function nr(t){return new K(function(e){for(var r=0;r<t.length&&!e.closed;r++)e.next(t[r]);e.complete()})}function or(t){return new K(function(e){t.then(function(r){e.closed||(e.next(r),e.complete())},function(r){return e.error(r)}).then(null,Fe)})}function sr(t){return new K(function(e){var r,n;try{for(var o=ie(t),s=o.next();!s.done;s=o.next()){var u=s.value;if(e.next(u),e.closed)return}}catch(a){r={error:a}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()})}function rt(t){return new K(function(e){ir(t,e).catch(function(r){return e.error(r)})})}function ar(t){return rt(et(t))}function ir(t,e){var r,n,o,s;return jt(this,void 0,void 0,function(){var u,a;return Ve(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),r=Vt(t),l.label=1;case 1:return[4,r.next()];case 2:if(n=l.sent(),!!n.done)return[3,4];if(u=n.value,e.next(u),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),o={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function te(t,e,r,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var s=e.schedule(function(){r(),o?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(s),!o)return s}function nt(t,e){return e===void 0&&(e=0),D(function(r,n){r.subscribe(N(n,function(o){return te(n,t,function(){return n.next(o)},e)},function(){return te(n,t,function(){return n.complete()},e)},function(o){return te(n,t,function(){return n.error(o)},e)}))})}function ot(t,e){return e===void 0&&(e=0),D(function(r,n){n.add(t.schedule(function(){return r.subscribe(n)},e))})}function ur(t,e){return X(t).pipe(ot(e),nt(e))}function lr(t,e){return X(t).pipe(ot(e),nt(e))}function cr(t,e){return new K(function(r){var n=0;return e.schedule(function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())})})}function fr(t,e){return new K(function(r){var n;return te(r,e,function(){n=t[Qe](),te(r,e,function(){var o,s,u;try{o=n.next(),s=o.value,u=o.done}catch(a){r.error(a);return}u?r.complete():r.next(s)},0,!0)}),function(){return V(n==null?void 0:n.return)&&n.return()}})}function st(t,e){if(!t)throw new Error("Iterable cannot be null");return new K(function(r){te(r,e,function(){var n=t[Symbol.asyncIterator]();te(r,e,function(){n.next().then(function(o){o.done?r.complete():r.next(o.value)})},0,!0)})})}function hr(t,e){return st(et(t),e)}function yr(t,e){if(t!=null){if(Ze(t))return ur(t,e);if(We(t))return cr(t,e);if(Ye(t))return lr(t,e);if(Je(t))return st(t,e);if(Xe(t))return fr(t,e);if(tt(t))return hr(t,e)}throw He(t)}function Te(t,e){return e?yr(t,e):X(t)}function dr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=qe(t);return Te(t,r)}var at=xe(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function q(t,e){return D(function(r,n){var o=0;r.subscribe(N(n,function(s){n.next(t.call(e,s,o++))}))})}var pr=Array.isArray;function mr(t,e){return pr(e)?t.apply(void 0,le([],ue(e))):t(e)}function vr(t){return q(function(e){return mr(t,e)})}var gr=Array.isArray,br=Object.getPrototypeOf,wr=Object.prototype,Er=Object.keys;function Ar(t){if(t.length===1){var e=t[0];if(gr(e))return{args:e,keys:null};if(xr(e)){var r=Er(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"&&br(t)===wr}function Sr(t,e){return t.reduce(function(r,n,o){return r[n]=e[o],r},{})}function ee(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=qe(t),n=er(t),o=Ar(t),s=o.args,u=o.keys;if(s.length===0)return Te([],r);var a=new K(_r(s,r,u?function(l){return Sr(u,l)}:ve));return n?a.pipe(vr(n)):a}function _r(t,e,r){return r===void 0&&(r=ve),function(n){it(e,function(){for(var o=t.length,s=new Array(o),u=o,a=o,l=function(h){it(e,function(){var b=Te(t[h],e),w=!1;b.subscribe(N(n,function(m){s[h]=m,w||(w=!0,a--),a||n.next(r(s.slice()))},function(){--u||n.complete()}))},n)},i=0;i<o;i++)l(i)},n)}}function it(t,e,r){t?te(r,t,e):e()}function Cr(t){return new K(function(e){X(t()).subscribe(e)})}function Or(t,e,r){return Cr(function(){return t()?e:r})}function ge(t,e){return D(function(r,n){var o=0;r.subscribe(N(n,function(s){return t.call(e,s,o++)&&n.next(s)}))})}function he(t){return D(function(e,r){var n=null,o=!1,s;n=e.subscribe(N(r,void 0,void 0,function(u){s=X(t(u,he(t)(e))),n?(n.unsubscribe(),n=null,s.subscribe(r)):o=!0})),o&&(n.unsubscribe(),n=null,s.subscribe(r))})}function Y(t,e){return e===void 0&&(e=Qt),D(function(r,n){var o=null,s=null,u=null,a=function(){if(o){o.unsubscribe(),o=null;var i=s;s=null,n.next(i)}};function l(){var i=u+t,h=e.now();if(h<i){o=this.schedule(void 0,i-h),n.add(o);return}a()}r.subscribe(N(n,function(i){s=i,u=e.now(),o||(o=e.schedule(l,t),n.add(o))},function(){a(),n.complete()},void 0,function(){s=o=null}))})}function $r(t){return D(function(e,r){var n=!1;e.subscribe(N(r,function(o){n=!0,r.next(o)},function(){n||r.next(t),r.complete()}))})}function Tr(t){return t<=0?function(){return fe}:D(function(e,r){var n=0;e.subscribe(N(r,function(o){++n<=t&&(r.next(o),t<=n&&r.complete())}))})}function Ir(t,e){return e===void 0&&(e=ve),t=t??Br,D(function(r,n){var o,s=!0;r.subscribe(N(n,function(u){var a=e(u);(s||!t(o,a))&&(s=!1,o=a,n.next(u))}))})}function Br(t,e){return t===e}function Pr(t){return t===void 0&&(t=Mr),D(function(e,r){var n=!1;e.subscribe(N(r,function(o){n=!0,r.next(o)},function(){return n?r.complete():r.error(t())}))})}function Mr(){return new at}function jr(t,e){var r=arguments.length>=2;return function(n){return n.pipe(ve,Tr(1),r?$r(e):Pr(function(){return new at}))}}function ut(t){t===void 0&&(t={});var e=t.connector,r=e===void 0?function(){return new se}:e,n=t.resetOnError,o=n===void 0?!0:n,s=t.resetOnComplete,u=s===void 0?!0:s,a=t.resetOnRefCountZero,l=a===void 0?!0:a;return function(i){var h,b,w,m=0,v=!1,y=!1,p=function(){b==null||b.unsubscribe(),b=void 0},E=function(){p(),h=w=void 0,v=y=!1},d=function(){var _=h;E(),_==null||_.unsubscribe()};return D(function(_,O){m++,!y&&!v&&p();var x=w=w??r();O.add(function(){m--,m===0&&!y&&!v&&(b=Ie(d,l))}),x.subscribe(O),!h&&m>0&&(h=new me({next:function(A){return x.next(A)},error:function(A){y=!0,p(),b=Ie(E,o,A),x.error(A)},complete:function(){v=!0,p(),b=Ie(E,u),x.complete()}}),X(_).subscribe(h))})(i)}}function Ie(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 o=new me({next:function(){o.unsubscribe(),t()}});return X(e.apply(void 0,le([],ue(r)))).subscribe(o)}}function re(t,e,r){var n,o=!1;return n=t,ut({connector:function(){return new Yt(n,e,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:o})}function kr(t,e){return D(function(r,n){var o=null,s=0,u=!1,a=function(){return u&&!o&&n.complete()};r.subscribe(N(n,function(l){o==null||o.unsubscribe();var i=0,h=s++;X(t(l,h)).subscribe(o=N(n,function(b){return n.next(e?e(l,b,h,i++):b)},function(){o=null,a()}))},function(){u=!0,a()}))})}function Vr(t){return D(function(e,r){X(t).subscribe(N(r,function(){return r.complete()},_e)),!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 ct(t){const e=t.filter(n=>n!==null&&!isNaN(n));return e.length===0?null:e.reduce((n,o)=>n+o,0)/e.length}function ft(t){const e=t.filter(o=>o!==null&&!isNaN(o));if(e.length===0)return null;const r=[...e].sort((o,s)=>o-s),n=Math.floor(r.length/2);return r.length%2===0?(r[n-1]+r[n])/2:r[n]}function ht(t){const e=t.filter(r=>r!==null&&!isNaN(r));return e.length===0?null:Math.min(...e)}function yt(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 pt(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 ct(t);case"median":return ft(t);case"min":return ht(t);case"max":return yt(t);case"count":return dt(t);case"none":return pt(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,o=t%n.length;return n[o]}function F(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 Z(t){return Object.prototype.toString.call(t)==="[object Object]"}function vt(t){return Object.prototype.toString.call(t)==="[object Function]"}function Be(t){return!!(t&&t.nodeType)}function J(t,e){if(Z(e)===!1||Z(t)===!1)return Object.assign({},t);const r=(n,o)=>{const s=Object.assign({},n);for(let u of Object.keys(o)){if(!(u in n))continue;let a;Z(o[u])&&Z(n[u])?(a=r(n[u],o[u]),s[u]=a):s[u]=o[u]}return s};return r(t,e)}function Lr(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 gt(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 bt(t){const e=document.createElementNS("http://www.w3.org/2000/svg","g");return t&&e.classList.add(t),e}function Pe(t){const e=document.createElement("canvas");return t&&e.classList.add(t),e}function Kr(t){const e=document.createElement("div");return t&&e.classList.add(t),e}function wt(t){if(Be(t))for(;t.firstChild;)t.removeChild(t.firstChild)}function Me(t){return`[OrbCharts ${t}]:`}function U(t){return`${Me("error")} ${t.message}`}function de({from:t,systemMessage:e}){return`unexpected error from '${t}':
3
+ `):"",this.name="UnsubscriptionError",this.errors=r}});function be(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,o,s;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var a=ie(u),l=a.next();!l.done;l=a.next()){var i=l.value;i.remove(this)}}catch(m){e={error:m}}finally{try{l&&!l.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}else u.remove(this);var f=this.initialTeardown;if(V(f))try{f()}catch(m){s=m instanceof Se?m.errors:[m]}var w=this._finalizers;if(w){this._finalizers=null;try{for(var S=ie(w),y=S.next();!y.done;y=S.next()){var x=y.value;try{Ke(x)}catch(m){s=s??[],m instanceof Se?s=le(le([],ue(s)),ue(m.errors)):s.push(m)}}}catch(m){n={error:m}}finally{try{y&&!y.done&&(o=S.return)&&o.call(S)}finally{if(n)throw n.error}}}if(s)throw new Se(s)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)Ke(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)&&be(r,e)},t.prototype.remove=function(e){var r=this._finalizers;r&&be(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),Ve=pe.EMPTY;function Re(t){return t instanceof pe||t&&"closed"in t&&V(t.remove)&&V(t.add)&&V(t.unsubscribe)}function Ke(t){V(t)?t():t.unsubscribe()}var Vt={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],ue(r)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function Fe(t){Rt.setTimeout(function(){throw t})}function _e(){}function we(t){t()}var Ce=function(t){Y(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=Dt,n}return e.create=function(r,n,o){return new me(r,n,o)},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),Kt=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){Ee(n)}},t.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(n){Ee(n)}else Ee(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){Ee(r)}},t}(),me=function(t){Y(e,t);function e(r,n,o){var s=t.call(this)||this,u;return V(r)||!r?u={next:r??void 0,error:n??void 0,complete:o??void 0}:u=r,s.destination=new Kt(u),s}return e}(Ce);function Ee(t){Fe(t)}function Ft(t){throw t}var Dt={closed:!0,next:_e,error:Ft,complete:_e},Oe=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function ve(t){return t}function Nt(t){return t.length===0?ve:t.length===1?t[0]:function(r){return t.reduce(function(n,o){return o(n)},r)}}var K=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 o=this,s=Ut(e)?e:new me(e,r,n);return we(function(){var u=o,a=u.operator,l=u.source;s.add(a?a.call(s,l):l?o._subscribe(s):o._trySubscribe(s))}),s},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=De(r),new r(function(o,s){var u=new me({next:function(a){try{e(a)}catch(l){s(l),u.unsubscribe()}},error:s,complete:o});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 Nt(e)(this)},t.prototype.toPromise=function(e){var r=this;return e=De(e),new e(function(n,o){var s;r.subscribe(function(u){return s=u},function(u){return o(u)},function(){return n(s)})})},t.create=function(e){return new t(e)},t}();function De(t){var e;return(e=t??Vt.Promise)!==null&&e!==void 0?e:Promise}function Gt(t){return t&&V(t.next)&&V(t.error)&&V(t.complete)}function Ut(t){return t&&t instanceof Ce||Gt(t)&&Re(t)}function zt(t){return V(t==null?void 0:t.lift)}function N(t){return function(e){if(zt(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 G(t,e,r,n,o){return new qt(t,e,r,n,o)}var qt=function(t){Y(e,t);function e(r,n,o,s,u,a){var l=t.call(this,r)||this;return l.onFinalize=u,l.shouldUnsubscribe=a,l._next=n?function(i){try{n(i)}catch(f){r.error(f)}}:t.prototype._next,l._error=s?function(i){try{s(i)}catch(f){r.error(f)}finally{this.unsubscribe()}}:t.prototype._error,l._complete=o?function(){try{o()}catch(i){r.error(i)}finally{this.unsubscribe()}}:t.prototype._complete,l}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}(Ce),Wt=xe(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ae=function(t){Y(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 Ne(this,this);return n.operator=r,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Wt},e.prototype.next=function(r){var n=this;we(function(){var o,s;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var u=ie(n.currentObservers),a=u.next();!a.done;a=u.next()){var l=a.value;l.next(r)}}catch(i){o={error:i}}finally{try{a&&!a.done&&(s=u.return)&&s.call(u)}finally{if(o)throw o.error}}}})},e.prototype.error=function(r){var n=this;we(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var o=n.observers;o.length;)o.shift().error(r)}})},e.prototype.complete=function(){var r=this;we(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,o=this,s=o.hasError,u=o.isStopped,a=o.observers;return s||u?Ve:(this.currentObservers=null,a.push(r),new pe(function(){n.currentObservers=null,be(a,r)}))},e.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,s=n.thrownError,u=n.isStopped;o?r.error(s):u&&r.complete()},e.prototype.asObservable=function(){var r=new K;return r.source=this,r},e.create=function(r,n){return new Ne(r,n)},e}(K),Ne=function(t){Y(e,t);function e(r,n){var o=t.call(this)||this;return o.destination=r,o.source=n,o}return e.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},e.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.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,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:Ve},e}(ae),U=function(t){Y(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,o=r.thrownError,s=r._value;if(n)throw o;return this._throwIfClosed(),s},e.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},e}(ae),Te={now:function(){return(Te.delegate||Date).now()},delegate:void 0},Yt=function(t){Y(e,t);function e(r,n,o){r===void 0&&(r=1/0),n===void 0&&(n=1/0),o===void 0&&(o=Te);var s=t.call(this)||this;return s._bufferSize=r,s._windowTime=n,s._timestampProvider=o,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=n===1/0,s._bufferSize=Math.max(1,r),s._windowTime=Math.max(1,n),s}return e.prototype.next=function(r){var n=this,o=n.isStopped,s=n._buffer,u=n._infiniteTimeWindow,a=n._timestampProvider,l=n._windowTime;o||(s.push(r),!u&&s.push(a.now()+l)),this._trimBuffer(),t.prototype.next.call(this,r)},e.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),o=this,s=o._infiniteTimeWindow,u=o._buffer,a=u.slice(),l=0;l<a.length&&!r.closed;l+=s?1:2)r.next(a[l]);return this._checkFinalizedStatuses(r),n},e.prototype._trimBuffer=function(){var r=this,n=r._bufferSize,o=r._timestampProvider,s=r._buffer,u=r._infiniteTimeWindow,a=(u?1:2)*n;if(n<1/0&&a<s.length&&s.splice(0,s.length-a),!u){for(var l=o.now(),i=0,f=1;f<s.length&&s[f]<=l;f+=2)i=f;i&&s.splice(0,i+1)}},e}(ae),Zt=function(t){Y(e,t);function e(r,n){return t.call(this)||this}return e.prototype.schedule=function(r,n){return this},e}(pe),Ge={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],ue(r)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},Jt=function(t){Y(e,t);function e(r,n){var o=t.call(this,r,n)||this;return o.scheduler=r,o.work=n,o.pending=!1,o}return e.prototype.schedule=function(r,n){var o;if(n===void 0&&(n=0),this.closed)return this;this.state=r;var s=this.id,u=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(u,s,n)),this.pending=!0,this.delay=n,this.id=(o=this.id)!==null&&o!==void 0?o:this.requestAsyncId(u,this.id,n),this},e.prototype.requestAsyncId=function(r,n,o){return o===void 0&&(o=0),Ge.setInterval(r.flush.bind(r,this),o)},e.prototype.recycleAsyncId=function(r,n,o){if(o===void 0&&(o=0),o!=null&&this.delay===o&&this.pending===!1)return n;n!=null&&Ge.clearInterval(n)},e.prototype.execute=function(r,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var o=this._execute(r,n);if(o)return o;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(r,n){var o=!1,s;try{this.work(r)}catch(u){o=!0,s=u||new Error("Scheduled action threw falsy error")}if(o)return this.unsubscribe(),s},e.prototype.unsubscribe=function(){if(!this.closed){var r=this,n=r.id,o=r.scheduler,s=o.actions;this.work=this.state=this.scheduler=null,this.pending=!1,be(s,this),n!=null&&(this.id=this.recycleAsyncId(o,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(Zt),Ue=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=Te.now,t}(),Ht=function(t){Y(e,t);function e(r,n){n===void 0&&(n=Ue.now);var o=t.call(this,r,n)||this;return o.actions=[],o._active=!1,o}return e.prototype.flush=function(r){var n=this.actions;if(this._active){n.push(r);return}var o;this._active=!0;do if(o=r.execute(r.state,r.delay))break;while(r=n.shift());if(this._active=!1,o){for(;r=n.shift();)r.unsubscribe();throw o}},e}(Ue),Qt=new Ht(Jt),fe=new K(function(t){return t.complete()});function Xt(t){return t&&V(t.schedule)}function ze(t){return t[t.length-1]}function er(t){return V(ze(t))?t.pop():void 0}function qe(t){return Xt(ze(t))?t.pop():void 0}var We=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function Ye(t){return V(t==null?void 0:t.then)}function Ze(t){return V(t[Oe])}function Je(t){return Symbol.asyncIterator&&V(t==null?void 0:t[Symbol.asyncIterator])}function He(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 tr(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Qe=tr();function Xe(t){return V(t==null?void 0:t[Qe])}function et(t){return kt(this,arguments,function(){var r,n,o,s;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,ce(r.read())];case 3:return n=u.sent(),o=n.value,s=n.done,s?[4,ce(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,ce(o)];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 tt(t){return V(t==null?void 0:t.getReader)}function X(t){if(t instanceof K)return t;if(t!=null){if(Ze(t))return rr(t);if(We(t))return nr(t);if(Ye(t))return or(t);if(Je(t))return rt(t);if(Xe(t))return sr(t);if(tt(t))return ar(t)}throw He(t)}function rr(t){return new K(function(e){var r=t[Oe]();if(V(r.subscribe))return r.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function nr(t){return new K(function(e){for(var r=0;r<t.length&&!e.closed;r++)e.next(t[r]);e.complete()})}function or(t){return new K(function(e){t.then(function(r){e.closed||(e.next(r),e.complete())},function(r){return e.error(r)}).then(null,Fe)})}function sr(t){return new K(function(e){var r,n;try{for(var o=ie(t),s=o.next();!s.done;s=o.next()){var u=s.value;if(e.next(u),e.closed)return}}catch(a){r={error:a}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()})}function rt(t){return new K(function(e){ir(t,e).catch(function(r){return e.error(r)})})}function ar(t){return rt(et(t))}function ir(t,e){var r,n,o,s;return jt(this,void 0,void 0,function(){var u,a;return Le(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),r=Lt(t),l.label=1;case 1:return[4,r.next()];case 2:if(n=l.sent(),!!n.done)return[3,4];if(u=n.value,e.next(u),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),o={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function re(t,e,r,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var s=e.schedule(function(){r(),o?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(s),!o)return s}function nt(t,e){return e===void 0&&(e=0),N(function(r,n){r.subscribe(G(n,function(o){return re(n,t,function(){return n.next(o)},e)},function(){return re(n,t,function(){return n.complete()},e)},function(o){return re(n,t,function(){return n.error(o)},e)}))})}function ot(t,e){return e===void 0&&(e=0),N(function(r,n){n.add(t.schedule(function(){return r.subscribe(n)},e))})}function ur(t,e){return X(t).pipe(ot(e),nt(e))}function lr(t,e){return X(t).pipe(ot(e),nt(e))}function cr(t,e){return new K(function(r){var n=0;return e.schedule(function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())})})}function fr(t,e){return new K(function(r){var n;return re(r,e,function(){n=t[Qe](),re(r,e,function(){var o,s,u;try{o=n.next(),s=o.value,u=o.done}catch(a){r.error(a);return}u?r.complete():r.next(s)},0,!0)}),function(){return V(n==null?void 0:n.return)&&n.return()}})}function st(t,e){if(!t)throw new Error("Iterable cannot be null");return new K(function(r){re(r,e,function(){var n=t[Symbol.asyncIterator]();re(r,e,function(){n.next().then(function(o){o.done?r.complete():r.next(o.value)})},0,!0)})})}function hr(t,e){return st(et(t),e)}function yr(t,e){if(t!=null){if(Ze(t))return ur(t,e);if(We(t))return cr(t,e);if(Ye(t))return lr(t,e);if(Je(t))return st(t,e);if(Xe(t))return fr(t,e);if(tt(t))return hr(t,e)}throw He(t)}function $e(t,e){return e?yr(t,e):X(t)}function dr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=qe(t);return $e(t,r)}var at=xe(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function q(t,e){return N(function(r,n){var o=0;r.subscribe(G(n,function(s){n.next(t.call(e,s,o++))}))})}var pr=Array.isArray;function mr(t,e){return pr(e)?t.apply(void 0,le([],ue(e))):t(e)}function vr(t){return q(function(e){return mr(t,e)})}var gr=Array.isArray,br=Object.getPrototypeOf,wr=Object.prototype,Er=Object.keys;function Ar(t){if(t.length===1){var e=t[0];if(gr(e))return{args:e,keys:null};if(xr(e)){var r=Er(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"&&br(t)===wr}function Sr(t,e){return t.reduce(function(r,n,o){return r[n]=e[o],r},{})}function ee(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=qe(t),n=er(t),o=Ar(t),s=o.args,u=o.keys;if(s.length===0)return $e([],r);var a=new K(_r(s,r,u?function(l){return Sr(u,l)}:ve));return n?a.pipe(vr(n)):a}function _r(t,e,r){return r===void 0&&(r=ve),function(n){it(e,function(){for(var o=t.length,s=new Array(o),u=o,a=o,l=function(f){it(e,function(){var w=$e(t[f],e),S=!1;w.subscribe(G(n,function(y){s[f]=y,S||(S=!0,a--),a||n.next(r(s.slice()))},function(){--u||n.complete()}))},n)},i=0;i<o;i++)l(i)},n)}}function it(t,e,r){t?re(r,t,e):e()}function Cr(t){return new K(function(e){X(t()).subscribe(e)})}function Or(t,e,r){return Cr(function(){return t()?e:r})}function ge(t,e){return N(function(r,n){var o=0;r.subscribe(G(n,function(s){return t.call(e,s,o++)&&n.next(s)}))})}function he(t){return N(function(e,r){var n=null,o=!1,s;n=e.subscribe(G(r,void 0,void 0,function(u){s=X(t(u,he(t)(e))),n?(n.unsubscribe(),n=null,s.subscribe(r)):o=!0})),o&&(n.unsubscribe(),n=null,s.subscribe(r))})}function Z(t,e){return e===void 0&&(e=Qt),N(function(r,n){var o=null,s=null,u=null,a=function(){if(o){o.unsubscribe(),o=null;var i=s;s=null,n.next(i)}};function l(){var i=u+t,f=e.now();if(f<i){o=this.schedule(void 0,i-f),n.add(o);return}a()}r.subscribe(G(n,function(i){s=i,u=e.now(),o||(o=e.schedule(l,t),n.add(o))},function(){a(),n.complete()},void 0,function(){s=o=null}))})}function Tr(t){return N(function(e,r){var n=!1;e.subscribe(G(r,function(o){n=!0,r.next(o)},function(){n||r.next(t),r.complete()}))})}function $r(t){return t<=0?function(){return fe}:N(function(e,r){var n=0;e.subscribe(G(r,function(o){++n<=t&&(r.next(o),t<=n&&r.complete())}))})}function Ir(t,e){return e===void 0&&(e=ve),t=t??Br,N(function(r,n){var o,s=!0;r.subscribe(G(n,function(u){var a=e(u);(s||!t(o,a))&&(s=!1,o=a,n.next(u))}))})}function Br(t,e){return t===e}function Pr(t){return t===void 0&&(t=Mr),N(function(e,r){var n=!1;e.subscribe(G(r,function(o){n=!0,r.next(o)},function(){return n?r.complete():r.error(t())}))})}function Mr(){return new at}function jr(t,e){var r=arguments.length>=2;return function(n){return n.pipe(ve,$r(1),r?Tr(e):Pr(function(){return new at}))}}function ut(t){t===void 0&&(t={});var e=t.connector,r=e===void 0?function(){return new ae}:e,n=t.resetOnError,o=n===void 0?!0:n,s=t.resetOnComplete,u=s===void 0?!0:s,a=t.resetOnRefCountZero,l=a===void 0?!0:a;return function(i){var f,w,S,y=0,x=!1,m=!1,p=function(){w==null||w.unsubscribe(),w=void 0},b=function(){p(),f=S=void 0,x=m=!1},O=function(){var T=f;b(),T==null||T.unsubscribe()};return N(function(T,h){y++,!m&&!x&&p();var d=S=S??r();h.add(function(){y--,y===0&&!m&&!x&&(w=Ie(O,l))}),d.subscribe(h),!f&&y>0&&(f=new me({next:function(E){return d.next(E)},error:function(E){m=!0,p(),w=Ie(b,o,E),d.error(E)},complete:function(){x=!0,p(),w=Ie(b,u),d.complete()}}),X(T).subscribe(f))})(i)}}function Ie(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 o=new me({next:function(){o.unsubscribe(),t()}});return X(e.apply(void 0,le([],ue(r)))).subscribe(o)}}function ne(t,e,r){var n,o=!1;return n=t,ut({connector:function(){return new Yt(n,e,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:o})}function kr(t,e){return N(function(r,n){var o=null,s=0,u=!1,a=function(){return u&&!o&&n.complete()};r.subscribe(G(n,function(l){o==null||o.unsubscribe();var i=0,f=s++;X(t(l,f)).subscribe(o=G(n,function(w){return n.next(e?e(l,w,f,i++):w)},function(){o=null,a()}))},function(){u=!0,a()}))})}function Lr(t){return N(function(e,r){X(t).subscribe(G(r,function(){return r.complete()},_e)),!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 ct(t){const e=t.filter(n=>n!==null&&!isNaN(n));return e.length===0?null:e.reduce((n,o)=>n+o,0)/e.length}function ft(t){const e=t.filter(o=>o!==null&&!isNaN(o));if(e.length===0)return null;const r=[...e].sort((o,s)=>o-s),n=Math.floor(r.length/2);return r.length%2===0?(r[n-1]+r[n])/2:r[n]}function ht(t){const e=t.filter(r=>r!==null&&!isNaN(r));return e.length===0?null:Math.min(...e)}function yt(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 pt(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 ct(t);case"median":return ft(t);case"min":return ht(t);case"max":return yt(t);case"count":return dt(t);case"none":return pt(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,o=t%n.length;return n[o]}function F(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 J(t){return Object.prototype.toString.call(t)==="[object Object]"}function vt(t){return Object.prototype.toString.call(t)==="[object Function]"}function Be(t){return!!(t&&t.nodeType)}function W(t,e){if(J(e)===!1||J(t)===!1)return Object.assign({},t);const r=(n,o)=>{const s=Object.assign({},n);for(let u of Object.keys(o)){if(!(u in n))continue;let a;J(o[u])&&J(n[u])?(a=r(n[u],o[u]),s[u]=a):s[u]=o[u]}return s};return r(t,e)}function Vr(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 gt(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 bt(t){const e=document.createElementNS("http://www.w3.org/2000/svg","g");return t&&e.classList.add(t),e}function Pe(t){const e=document.createElement("canvas");return t&&e.classList.add(t),e}function Kr(t){const e=document.createElement("div");return t&&e.classList.add(t),e}function wt(t){if(Be(t))for(;t.firstChild;)t.removeChild(t.firstChild)}function Me(t){return`[OrbCharts ${t}]:`}function z(t){return`${Me("error")} ${t.message}`}function de({from:t,systemMessage:e}){return`unexpected error from '${t}':
4
4
  ${e}`}function H({columnName:t,expectToBe:e,from:r}){return`Invalid value: '${t}' must be '${e}'
5
5
 
6
6
  ----> find in '${r}'`}function Q({columnName:t,expectToBe:e,from:r}){return`${Me("warning")} Value is not correct: '${t}' suppose to be '${e}', it may cause unexpected errors.'
7
7
 
8
- ----> find in '${r}'`}function Et(t){return new K(e=>{const r=new ResizeObserver(n=>{const o=n[0];o&&o.contentRect&&e.next(o.contentRect)});return r.observe(t),function(){r.unobserve(t)}})}function At(t){return`orbcharts-${t}`}function xt(t,e){return`${At(t)}-${e}`}function Fr(t,e){const r={string:s=>typeof s=="string",number:s=>typeof s=="number",boolean:s=>typeof s=="boolean",object:s=>Z(s),"object[]":s=>Array.isArray(s)&&s.every(u=>Z(u)),"string[]":s=>Array.isArray(s)&&s.every(u=>typeof u=="string"),"number[]":s=>Array.isArray(s)&&s.every(u=>typeof u=="number"),Function:s=>vt(s),null:s=>s===null,undefined:s=>s===void 0},n={ColorType:s=>s==="none"||s==="data"||s==="primary"||s==="secondary"||s==="dataContrast"||s==="background"};return Object.keys(t).find(s=>{if(e[s]){const u=e[s],a=t[s];if(u.toBeTypes){if(u.toBeTypes.some(h=>r[h](a))===!1)return!0}else if(u.toBe){const{toBe:l,test:i}=u;if(i(a)===!1)return!0}else if(u.toBeOption){const l=u.toBeOption;if(n[l](a)===!1)return!0}}return!1})}function R(t,e){const r=Fr(t,e);if(r){const n=e[r],o=n.toBeTypes?n.toBeTypes.join(" | "):n.toBe?n.toBe:n.toBeOption?n.toBeOption:"";return{status:"error",columnName:r,expectToBe:o}}else return{status:"success",columnName:"",expectToBe:""}}const St={width:"auto",height:"auto",resizeDebounce:50},_t={dataset:{from:"dataset",sort:"original"},series:{from:"series",sort:"original"},category:{from:"category",sort:"original"},value:{from:"value",sort:"original",aggregate:"none"},multivariate:[{from:"x",name:"x"},{from:"y",name:"y"},{from:"z",name:"z"}],color:{from:"series"}},Ct={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"},Dr=(t,e,r)=>{const n=new Map,o=Array.isArray(t[0]);o?t.forEach((a,l)=>{a.forEach(i=>{const h=i[e.dataset.from]||`dataset-${l}`;n.has(h)||n.set(h,[]),n.get(h).push(i)})}):t.forEach(a=>{const l=a[e.dataset.from]||"default";n.has(l)||n.set(l,[]),n.get(l).push(a)});let s=Array.from(n.keys());if(Array.isArray(e.dataset.sort))s=e.dataset.sort.filter(a=>n.has(a)).concat(s.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];o?t.forEach((l,i)=>{l.forEach(h=>{const b=h[e.dataset.from]||`dataset-${i}`;a.includes(b)||a.push(b)})}):t.forEach(l=>{const i=l[e.dataset.from]||"default";a.includes(i)||a.push(i)}),s=a}else e.dataset.sort==="alphabetical"&&s.sort((a,l)=>a.localeCompare(l,void 0,{numeric:!0}));const u=[];return s.forEach((a,l)=>{const i=n.get(a),h=new Map;i.forEach(y=>{const p=y[e.series.from]||"default";h.has(p)||h.set(p,[]),h.get(p).push(y)});let b=Array.from(h.keys());if(Array.isArray(e.series.sort))b=e.series.sort.filter(y=>h.has(y)).concat(b.filter(y=>!e.series.sort.includes(y)));else if(e.series.sort==="original"){const y=[];i.forEach(p=>{const E=p[e.series.from]||"default";y.includes(E)||y.push(E)}),b=y}else e.series.sort==="alphabetical"&&b.sort((y,p)=>y.localeCompare(p,void 0,{numeric:!0}));const w=[];if(e.category.sort==="original")i.forEach(y=>{const p=y[e.category.from]||"default";w.includes(p)||w.push(p)});else if(e.category.sort==="alphabetical"){const y=new Set;i.forEach(p=>{y.add(p[e.category.from]||"default")}),w.push(...Array.from(y).sort((p,E)=>p.localeCompare(E,void 0,{numeric:!0})))}else if(Array.isArray(e.category.sort)){const y=[];i.forEach(E=>{const d=E[e.category.from]||"default";y.includes(d)||y.push(d)});const p=e.category.sort;w.push(...p.filter(E=>y.includes(E)),...y.filter(E=>!p.includes(E)))}const m=new Map;w.forEach((y,p)=>{m.set(y,p)});const v=[];b.forEach((y,p)=>{const E=h.get(y),d=new Map;E.forEach(x=>{const A=x[e.category.from]||"default";d.has(A)||d.set(A,[]),d.get(A).push(x)});const _=w.filter(x=>d.has(x)),O=[];e.category.sort==="original"&&e.value.aggregate==="none"?(E.forEach((x,A)=>{const P=x[e.category.from]||"default",I=m.get(P),c=x[e.value.from];O.push({id:x.id||`${a}-${y}-${P}-${A}`,index:I,modelType:"series",name:x.name||"",data:x.data,value:typeof c=="number"?c:null,color:F(e.color.from,{index:I,seriesIndex:p,categoryIndex:I,datasetIndex:l},r),series:y,seriesIndex:p,category:P,categoryIndex:I})}),e.value.sort==="asc"?O.sort((x,A)=>x.value===null&&A.value===null?0:x.value===null?1:A.value===null?-1:x.value-A.value):e.value.sort==="desc"&&O.sort((x,A)=>x.value===null&&A.value===null?0:x.value===null?1:A.value===null?-1:A.value-x.value)):_.forEach(x=>{const A=m.get(x),P=d.get(x);if(e.value.aggregate==="none"){let I=P.map((c,f)=>{const g=c[e.value.from];return{id:c.id||`${a}-${y}-${x}-${f}`,index:A,modelType:"series",name:c.name||"",data:c.data,value:typeof g=="number"?g:null,color:F(e.color.from,{index:A,seriesIndex:p,categoryIndex:A,datasetIndex:l},r),series:y,seriesIndex:p,category:x,categoryIndex:A}});e.value.sort==="asc"?I.sort((c,f)=>c.value===null&&f.value===null?0:c.value===null?1:f.value===null?-1:c.value-f.value):e.value.sort==="desc"&&I.sort((c,f)=>c.value===null&&f.value===null?0:c.value===null?1:f.value===null?-1:f.value-c.value),O.push(...I)}else{const I=P.map(S=>{if(e.value.aggregate==="count")return 1;const C=S[e.value.from];return typeof C=="number"?C:null}),c=ye(I,e.value.aggregate),f=P[0],g={id:f.id||`${a}-${y}-${x}-aggregated`,index:A,modelType:"series",name:f.name||x,data:f.data,value:c,color:F(e.color.from,{index:A,seriesIndex:p,categoryIndex:A,datasetIndex:l},r),series:y,seriesIndex:p,category:x,categoryIndex:A};O.push(g)}}),v.push(O)}),u.push(v)}),u},Nr=(t,e,r)=>{const n=new Map,o=Array.isArray(t[0]);o?t.forEach((a,l)=>{a.forEach(i=>{const h=i[e.dataset.from]||`dataset-${l}`;n.has(h)||n.set(h,[]),n.get(h).push(i)})}):t.forEach(a=>{const l=a[e.dataset.from]||"default";n.has(l)||n.set(l,[]),n.get(l).push(a)});let s=Array.from(n.keys());if(Array.isArray(e.dataset.sort))s=e.dataset.sort.filter(a=>n.has(a)).concat(s.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];o?t.forEach((l,i)=>{l.forEach(h=>{const b=h[e.dataset.from]||`dataset-${i}`;a.includes(b)||a.push(b)})}):t.forEach(l=>{const i=l[e.dataset.from]||"default";a.includes(i)||a.push(i)}),s=a}else e.dataset.sort==="alphabetical"&&s.sort((a,l)=>a.localeCompare(l,void 0,{numeric:!0}));const u=[];return s.forEach((a,l)=>{const i=n.get(a),h=new Map;i.forEach(p=>{const E=p[e.series.from]||"default";h.has(E)||h.set(E,[]),h.get(E).push(p)});let b=Array.from(h.keys());if(Array.isArray(e.series.sort))b=e.series.sort.filter(p=>h.has(p)).concat(b.filter(p=>!e.series.sort.includes(p)));else if(e.series.sort==="original"){const p=[];i.forEach(E=>{const d=E[e.series.from]||"default";p.includes(d)||p.push(d)}),b=p}else e.series.sort==="alphabetical"&&b.sort((p,E)=>p.localeCompare(E,void 0,{numeric:!0}));const w=[];i.forEach(p=>{const E=p[e.category.from]||"default";w.includes(E)||w.push(E)});const m=new Set(w);let v=Array.from(m);Array.isArray(e.category.sort)?v=e.category.sort.filter(p=>m.has(p)).concat(v.filter(p=>!e.category.sort.includes(p))):e.category.sort==="original"?v=w:e.category.sort==="alphabetical"&&v.sort((p,E)=>p.localeCompare(E,void 0,{numeric:!0}));const y=[];b.forEach((p,E)=>{const d=h.get(p),_=new Map;d.forEach(x=>{const A=x[e.category.from]||"default";_.has(A)||_.set(A,[]),_.get(A).push(x)});const O=[];v.forEach((x,A)=>{const P=_.get(x);if(!P)O.push({id:`${a}-${p}-${x}-null`,index:A,modelType:"grid",name:x,data:void 0,value:null,color:F(e.color.from,{index:A,seriesIndex:E,categoryIndex:A,datasetIndex:l},r),series:p,seriesIndex:E,category:x,categoryIndex:A});else if(e.value.aggregate==="none"){let I=P.map((c,f)=>{const g=c[e.value.from];return{id:c.id||`${a}-${p}-${x}-${f}`,index:A,modelType:"grid",name:c.name||"",data:c.data,value:typeof g=="number"?g:null,color:F(e.color.from,{index:A,seriesIndex:E,categoryIndex:A,datasetIndex:l},r),series:p,seriesIndex:E,category:x,categoryIndex:A}});e.value.sort==="asc"?I.sort((c,f)=>c.value===null&&f.value===null?0:c.value===null?1:f.value===null?-1:c.value-f.value):e.value.sort==="desc"&&I.sort((c,f)=>c.value===null&&f.value===null?0:c.value===null?1:f.value===null?-1:f.value-c.value),O.push(...I)}else{const I=P.map(S=>{if(e.value.aggregate==="count")return 1;const C=S[e.value.from];return typeof C=="number"?C:null}),c=ye(I,e.value.aggregate),f=P[0],g={id:f.id||`${a}-${p}-${x}-aggregated`,index:A,modelType:"grid",name:f.name||x,data:f.data,value:c,color:F(e.color.from,{index:A,seriesIndex:E,categoryIndex:A,datasetIndex:l},r),series:p,seriesIndex:E,category:x,categoryIndex:A};O.push(g)}}),y.push(O)}),u.push(y)}),u},Gr=(t,e,r)=>{const n=new Map,o=Array.isArray(t[0]);o?t.forEach((a,l)=>{a.forEach(i=>{const h=i[e.dataset.from]||`dataset-${l}`;n.has(h)||n.set(h,[]),n.get(h).push(i)})}):t.forEach(a=>{const l=a[e.dataset.from]||"default";n.has(l)||n.set(l,[]),n.get(l).push(a)});let s=Array.from(n.keys());if(Array.isArray(e.dataset.sort))s=e.dataset.sort.filter(a=>n.has(a)).concat(s.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];o?t.forEach((l,i)=>{l.forEach(h=>{const b=h[e.dataset.from]||`dataset-${i}`;a.includes(b)||a.push(b)})}):t.forEach(l=>{const i=l[e.dataset.from]||"default";a.includes(i)||a.push(i)}),s=a}else e.dataset.sort==="alphabetical"&&s.sort((a,l)=>a.localeCompare(l,void 0,{numeric:!0}));const u=[];return s.forEach((a,l)=>{const i=n.get(a),h=new Map;i.forEach(m=>{const v=m[e.series.from]||"default";h.has(v)||h.set(v,[]),h.get(v).push(m)});let b=Array.from(h.keys());if(Array.isArray(e.series.sort))b=e.series.sort.filter(m=>h.has(m)).concat(b.filter(m=>!e.series.sort.includes(m)));else if(e.series.sort==="original"){const m=[];i.forEach(v=>{const y=v[e.series.from]||"default";m.includes(y)||m.push(y)}),b=m}else e.series.sort==="alphabetical"&&b.sort((m,v)=>m.localeCompare(v,void 0,{numeric:!0}));const w=[];b.forEach((m,v)=>{const y=h.get(m),p=new Map;y.forEach(_=>{const O=_[e.category.from]||"default";p.has(O)||p.set(O,[]),p.get(O).push(_)});let E=Array.from(p.keys());if(Array.isArray(e.category.sort))E=e.category.sort.filter(_=>p.has(_)).concat(E.filter(_=>!e.category.sort.includes(_)));else if(e.category.sort==="original"){const _=[];y.forEach(O=>{const x=O[e.category.from]||"default";_.includes(x)||_.push(x)}),E=_}else e.category.sort==="alphabetical"&&E.sort((_,O)=>_.localeCompare(O,void 0,{numeric:!0}));const d=[];E.forEach((_,O)=>{p.get(_).forEach((A,P)=>{const I=e.multivariate.map((f,g)=>({index:g,name:f.name,value:(()=>{const S=A[f.from];return typeof S=="number"?S:null})()})),c={id:A.id||`${a}-${m}-${_}-${P}`,index:P,modelType:"multivariate",name:A.name||"",data:A.data,value:null,color:F(e.color.from,{index:P,seriesIndex:v,categoryIndex:O,datasetIndex:l},r),multivariate:I,series:m,seriesIndex:v,category:_,categoryIndex:O};d.push(c)})}),w.push(d)}),u.push(w)}),u},Ur=(t,e,r)=>{const n=Array.isArray(t[0]),o=[],s=[];n?t.forEach(i=>{i.forEach(h=>{h.source&&h.target?s.push(h):o.push(h)})}):t.forEach(i=>{i.source&&i.target?s.push(i):o.push(i)});const u=new Map;n?t.forEach((i,h)=>{i.forEach(b=>{if(!b.source||!b.target){const w=b[e.dataset.from]||`dataset-${h}`;u.has(w)||u.set(w,[]),u.get(w).push(b)}})}):o.forEach(i=>{const h=i[e.dataset.from]||"default";u.has(h)||u.set(h,[]),u.get(h).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((h,b)=>{h.forEach(w=>{if(!w.source||!w.target){const m=w[e.dataset.from]||`dataset-${b}`;i.includes(m)||i.push(m)}})}):o.forEach(h=>{const b=h[e.dataset.from]||"default";i.includes(b)||i.push(b)}),a=i}else e.dataset.sort==="alphabetical"&&a.sort((i,h)=>i.localeCompare(h,void 0,{numeric:!0}));const l=[];return a.forEach((i,h)=>{const b=u.get(i),w=[],m=new Map;b.forEach(c=>{const f=c[e.series.from]||"default";m.has(f)||m.set(f,[]),m.get(f).push(c)});let v=Array.from(m.keys());if(Array.isArray(e.series.sort))v=e.series.sort.filter(c=>m.has(c)).concat(v.filter(c=>!e.series.sort.includes(c)));else if(e.series.sort==="original"){const c=[];b.forEach(f=>{const g=f[e.series.from]||"default";c.includes(g)||c.push(g)}),v=c}else e.series.sort==="alphabetical"&&v.sort((c,f)=>c.localeCompare(f,void 0,{numeric:!0}));v.forEach((c,f)=>{const g=m.get(c),S=new Map;g.forEach($=>{const B=$[e.category.from]||"default";S.has(B)||S.set(B,[]),S.get(B).push($)});let C=Array.from(S.keys());if(Array.isArray(e.category.sort))C=e.category.sort.filter($=>S.has($)).concat(C.filter($=>!e.category.sort.includes($)));else if(e.category.sort==="original"){const $=[];g.forEach(B=>{const L=B[e.category.from]||"default";$.includes(L)||$.push(L)}),C=$}else e.category.sort==="alphabetical"&&C.sort(($,B)=>$.localeCompare(B,void 0,{numeric:!0}));C.forEach(($,B)=>{const L=S.get($);if(e.value.aggregate==="none"){let k=L.map((M,j)=>{const z=M[e.value.from];return{id:M.id||`${i}-${c}-${$}-${j}`,index:w.length+j,modelType:"graph",name:M.name||"",data:M.data,value:typeof z=="number"?z:null,color:F(e.color.from,{index:B,seriesIndex:f,categoryIndex:B,datasetIndex:h},r),series:c,seriesIndex:f,category:$,categoryIndex:B}});e.value.sort==="asc"?k.sort((M,j)=>M.value===null&&j.value===null?0:M.value===null?1:j.value===null?-1:M.value-j.value):e.value.sort==="desc"&&k.sort((M,j)=>M.value===null&&j.value===null?0:M.value===null?1:j.value===null?-1:j.value-M.value),w.push(...k)}else{const k=L.map(ae=>{if(e.value.aggregate==="count")return 1;const ne=ae[e.value.from];return typeof ne=="number"?ne:null}),M=ye(k,e.value.aggregate),j=L[0],z={id:j.id||`${i}-${c}-${$}-aggregated`,index:w.length,modelType:"graph",name:j.name||$,data:j.data,value:M,color:F(e.color.from,{index:B,seriesIndex:f,categoryIndex:B,datasetIndex:h},r),series:c,seriesIndex:f,category:$,categoryIndex:B};w.push(z)}})});const y=[],p=new Map;w.forEach(c=>{const f=o.find(g=>g.id===c.id||g.name===c.name);f!=null&&f.id&&p.set(f.id,c.index),f!=null&&f.name&&p.set(f.name,c.index)});const E=new Map,d=new Map;w.forEach(c=>{E.has(c.series)||E.set(c.series,c.seriesIndex),d.has(c.category)||d.set(c.category,c.categoryIndex)});let _=E.size,O=d.size;const x=c=>(E.has(c)||E.set(c,_++),E.get(c)),A=c=>(d.has(c)||d.set(c,O++),d.get(c)),P=s.filter(c=>(c[e.dataset.from]||"default")===i),I=new Map;P.forEach(c=>{const f=c.source,g=c.target,S=c[e.series.from]||"default",C=c[e.category.from]||"default",$=`${f}-${g}-${S}-${C}`;I.has($)||I.set($,[]),I.get($).push(c)}),Array.from(I.entries()).forEach(([c,f],g)=>{const S=f[0],C=S.source,$=S.target,B=p.get(C)??-1,L=p.get($)??-1;if(B>=0&&L>=0)if(e.value.aggregate==="none")f.forEach((k,M)=>{const j=k[e.value.from],z=k[e.series.from]||"default",ae=k[e.category.from]||"default",ne=x(z),Ae=A(ae),ke={id:k.id||`edge-${g}-${M}`,index:y.length,modelType:"graph",name:k.name||"",data:k.data,value:typeof j=="number"?j:null,color:F(e.color.from,{index:y.length,seriesIndex:ne,categoryIndex:Ae,datasetIndex:h},r),series:z,seriesIndex:ne,category:ae,categoryIndex:Ae,source:C,sourceIndex:B,target:$,targetIndex:L};y.push(ke)});else{const k=f.map(ke=>{if(e.value.aggregate==="count")return 1;const Mt=ke[e.value.from];return typeof Mt=="number"?Mt:null}),M=ye(k,e.value.aggregate),j=S[e.series.from]||"default",z=S[e.category.from]||"default",ae=x(j),ne=A(z),Ae={id:S.id||`edge-${g}-aggregated`,index:y.length,modelType:"graph",name:S.name||"",data:S.data,value:M,color:F(e.color.from,{index:y.length,seriesIndex:ae,categoryIndex:ne,datasetIndex:h},r),series:j,seriesIndex:ae,category:z,categoryIndex:ne,source:C,sourceIndex:B,target:$,targetIndex:L};y.push(Ae)}}),l.push({nodes:w,edges:y})}),l},zr=(t,e,r)=>{const n=new Map,o=Array.isArray(t[0]);o?t.forEach((a,l)=>{a.forEach(i=>{const h=i[e.dataset.from]||`dataset-${l}`;n.has(h)||n.set(h,[]),n.get(h).push(i)})}):t.forEach(a=>{const l=a[e.dataset.from]||"default";n.has(l)||n.set(l,[]),n.get(l).push(a)});let s=Array.from(n.keys());if(Array.isArray(e.dataset.sort))s=e.dataset.sort.filter(a=>n.has(a)).concat(s.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];o?t.forEach((l,i)=>{l.forEach(h=>{const b=h[e.dataset.from]||`dataset-${i}`;a.includes(b)||a.push(b)})}):t.forEach(l=>{const i=l[e.dataset.from]||"default";a.includes(i)||a.push(i)}),s=a}else e.dataset.sort==="alphabetical"&&s.sort((a,l)=>a.localeCompare(l,void 0,{numeric:!0}));const u=[];return s.forEach((a,l)=>{const i=n.get(a),h=new Map;i.forEach(c=>{const f=c[e.series.from]||"default";h.has(f)||h.set(f,[]),h.get(f).push(c)});let b=Array.from(h.keys());if(Array.isArray(e.series.sort))b=e.series.sort.filter(c=>h.has(c)).concat(b.filter(c=>!e.series.sort.includes(c)));else if(e.series.sort==="original"){const c=[];i.forEach(f=>{const g=f[e.series.from]||"default";c.includes(g)||c.push(g)}),b=c}else e.series.sort==="alphabetical"&&b.sort((c,f)=>c.localeCompare(f,void 0,{numeric:!0}));const w=new Map;i.forEach(c=>{const f=c[e.category.from]||"default";w.has(f)||w.set(f,[]),w.get(f).push(c)});let m=Array.from(w.keys());if(Array.isArray(e.category.sort))m=e.category.sort.filter(c=>w.has(c)).concat(m.filter(c=>!e.category.sort.includes(c)));else if(e.category.sort==="original"){const c=[];i.forEach(f=>{const g=f[e.category.from]||"default";c.includes(g)||c.push(g)}),m=c}else e.category.sort==="alphabetical"&&m.sort((c,f)=>c.localeCompare(f,void 0,{numeric:!0}));const v=new Map;i.forEach(c=>{const f=c.id||"unknown";v.has(f)||v.set(f,[]),v.get(f).push(c)});let y=0;const p=b[0]||"default",E=b.indexOf(p),d=new Map;Array.from(v.entries()).forEach(([c,f])=>{const g=f[0],S=g[e.series.from]||"default",C=b.indexOf(S),$=g[e.category.from]||"default",B=m.indexOf($);if(e.value.aggregate==="none"){const L=g[e.value.from],k={id:c,index:y++,modelType:"tree",name:g.name||c,data:g.data,value:typeof L=="number"?L:null,color:F(e.color.from,{index:y-1,seriesIndex:C,categoryIndex:B,datasetIndex:l},r),parent:g.parent||null,parentIndex:null,depth:0,seq:0,children:[],series:S,seriesIndex:C,category:$,categoryIndex:B};d.set(c,k)}else{const L=f.map(j=>{if(e.value.aggregate==="count")return 1;const z=j[e.value.from];return typeof z=="number"?z:null}),k=ye(L,e.value.aggregate),M={id:c,index:y++,modelType:"tree",name:g.name||c,data:g.data,value:k,color:F(e.color.from,{index:y-1,seriesIndex:C,categoryIndex:B,datasetIndex:l},r),parent:g.parent||null,parentIndex:null,depth:0,seq:0,children:[],series:S,seriesIndex:C,category:$,categoryIndex:B};d.set(c,M)}});const _=Array.from(d.values()),O=new Map;_.forEach(c=>{O.set(c.id,c.index)}),_.forEach(c=>{c.parent&&O.has(c.parent)&&(c.parentIndex=O.get(c.parent))});const x=[],A=new Map;_.forEach(c=>{c.parent===null?x.push(c):(A.has(c.parent)||A.set(c.parent,[]),A.get(c.parent).push(c))});function P(c,f){c.depth=f;const g=A.get(c.id)||[];return e.value.sort==="asc"?g.sort((S,C)=>S.value===null&&C.value===null?0:S.value===null?1:C.value===null?-1:S.value-C.value):e.value.sort==="desc"&&g.sort((S,C)=>S.value===null&&C.value===null?0:S.value===null?1:C.value===null?-1:C.value-S.value),g.forEach((S,C)=>{S.seq=C}),c.children=g.map(S=>P(S,f+1)),c}const I=x.map(c=>P(c,0));if(I.length===0)u.push({id:`empty-${a}`,index:y++,modelType:"tree",name:"Empty Tree",data:{},value:null,color:F(e.color.from,{index:y-1,seriesIndex:E<0?0:E,categoryIndex:0,datasetIndex:l},r),parent:null,parentIndex:null,depth:0,seq:0,children:[],series:p,seriesIndex:E<0?0:E,category:"default",categoryIndex:0});else if(I.length===1)u.push(I[0]);else{const c={id:`virtual-root-${a}`,index:y++,modelType:"tree",name:`Virtual Root (${a})`,data:{},value:null,color:F(e.color.from,{index:y-1,seriesIndex:E<0?0:E,categoryIndex:0,datasetIndex:l},r),parent:null,parentIndex:null,depth:0,seq:0,children:I.map((f,g)=>{const S=(C,$)=>(C.depth=$,$===1&&(C.seq=g),C.children=C.children.map(B=>S(B,$+1)),C);return S(f,1)}),series:p,seriesIndex:E<0?0:E,category:"default",categoryIndex:0};u.push(c)}}),u};function qr(t,e,r){const n=e.map(a=>r[a]).filter(a=>a&&a.parentNode===t);if(n.length===0)return;let o=!0,s=null;for(const a of n){if(s&&s.nextElementSibling!==a){o=!1;break}s=a}if(o)return;const u=document.createDocumentFragment();e.forEach(a=>{const l=r[a];l&&l.parentNode===t&&u.appendChild(l)}),t.appendChild(u)}function Ot(t,e,r,n,o){Object.keys(r).filter(i=>!e.includes(i)).forEach(i=>{const h=r[i];h&&h.parentNode===t&&t.removeChild(h),delete r[i]});const a=e.filter(i=>!r[i]);a.forEach(i=>{const h=n(i);r[i]=h,t.appendChild(h)}),e.filter(i=>r[i]&&!a.includes(i)).forEach(i=>{r[i]}),e.length>0&&qr(t,e,r)}function Wr(t){return R({element:t},{element:{toBe:"Dom",test:r=>Be(r)}})}function Yr(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 Tt(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(o=>typeof o=="string")}});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(o=>typeof o=="string")}});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(o=>typeof o=="string")}});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(o=>typeof o.from=="string"&&typeof o.label=="string")}});if(r.status==="error")return r}if(t.color){const r=R(t.color,{from:{toBe:'"index" | "series" | "category" | "dataset"',test:n=>["index","series","category","dataset"].includes(n)}});if(r.status==="error")return r}return e}function It(t){return R({data:t},{data:{toBe:"RawDataColumn[] | RawDataColumn[][]",test:r=>Array.isArray(r)&&r.every(n=>Array.isArray(n)||Z(n))}})}function je(t){return R({plugins:t},{plugins:{toBe:"PluginEntity[]",test:r=>Array.isArray(r)&&r.every(n=>Z(n)&&typeof n._name=="string"&&typeof n._injectContext=="function")}})}function Zr(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=>Z(n)&&typeof n._name=="string"&&typeof n._injectContext=="function")}});if(e.status==="error")return e;if(t.size){const r=Yr(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=Tt(t.encoding);if(r.status==="error")return r}if(t.data){const r=It(t.data);if(r.status==="error")return r}if(t.plugins){const r=je(t.plugins);if(r.status==="error")return r}return e}function Jr({svgElement$:t,canvasElement$:e,pluginsInstance$:r}){let n=[],o=[];const s=(l,i,h)=>{const b=r.getValue().reduce((v,y,p)=>(v[y._getId()]=p,v),{}),w=h.map(v=>({...v,pluginSeq:b[v.pluginId]}));return(l==="svg"?n:o).filter(v=>v.pluginId!==i).map(v=>({...v,pluginSeq:b[v.pluginId]})).concat(w).sort((v,y)=>v.layerIndex-y.layerIndex||v.pluginSeq-y.pluginSeq)},u={},a={};return(l,i,h)=>{const b=l==="svg"?t.getValue():e.getValue();if(!b)return{};const w=l==="svg"?u:a,m=s(l,i,h),v=m.map(p=>xt(p.pluginId,p.layerName));return l==="svg"?(Ot(b,v,w,p=>bt(p)),n=m):(Ot(b,v,w,p=>Pe(p)),o=m),Object.entries(w).reduce((p,[E,d])=>{const[_,O,x]=E.split("-");return O===i&&(p[x]=d),p},{})}}const Hr=(t,e)=>{try{const{status:v,columnName:y,expectToBe:p}=Zr(e);if(v==="error")throw new Error(H({columnName:y,expectToBe:p,from:"Chart.constructor"}));if(v==="warning")console.warn(Q({columnName:y,expectToBe:p,from:"Chart.constructor"}));else{const{status:E,columnName:d,expectToBe:_}=Wr(t);if(E==="error")throw new Error(H({columnName:d,expectToBe:_,from:"Chart.constructor"}));E==="warning"&&console.warn(Q({columnName:d,expectToBe:_,from:"Chart.constructor"}))}}catch(v){throw new Error(v)}const r=new se,n=new G((e==null?void 0:e.data)||[]),o=e&&e.encoding?J(_t,e.encoding):_t,s=new G(o),u=e&&e.theme?J(Ct,e.theme):Ct,a=new G(u),l=new G((e==null?void 0:e.plugins)||[]),i=e&&e.size?J(St,e.size):St,h=new G(i),b=new G(null),w=new G(null),m=(()=>{const v=h.pipe(kr(f=>Or(()=>f.width==="auto"||f.height==="auto",Et(t).pipe(q(g=>({width:f.width==="auto"?g.width:f.width,height:f.height==="auto"?g.height<=0?g.width:g.height:f.height})),Y(f.resizeDebounce),Ir((g,S)=>JSON.stringify(g)===JSON.stringify(S))),dr({width:f.width,height:f.height}))),Vr(r),re(1)),y=s.asObservable().pipe(re(1)),p=ee([n,s,a]).pipe(Y(0),q(([f,g,S])=>{try{return Dr(f,g,S)}catch(C){throw new Error(de({from:"Chart.seriesData$",systemMessage:C}))}}),he(f=>(console.error(U(f)),fe)),re(1)),E=ee([n,s,a]).pipe(Y(0),q(([f,g,S])=>{try{return Nr(f,g,S)}catch(C){throw new Error(de({from:"Chart.gridData$",systemMessage:C}))}}),he(f=>(console.error(U(f)),fe)),re(1)),d=ee([n,s,a]).pipe(Y(0),q(([f,g,S])=>{try{return Gr(f,g,S)}catch(C){throw new Error(de({from:"Chart.multivariateData$",systemMessage:C}))}}),he(f=>(console.error(U(f)),fe)),re(1)),_=ee([n,s,a]).pipe(Y(0),q(([f,g,S])=>{try{return Ur(f,g,S)}catch(C){throw new Error(de({from:"Chart.graphData$",systemMessage:C}))}}),he(f=>(console.error(U(f)),fe)),re(1)),O=ee([n,s,a]).pipe(Y(0),q(([f,g,S])=>{try{return zr(f,g,S)}catch(C){throw new Error(de({from:"Chart.treeData$",systemMessage:C}))}}),he(f=>(console.error(U(f)),fe)),re(1)),x=new G([]);l.subscribe(f=>{const g={},S=f.map($=>{var L;let B=$._getId();if(g[B]){const k=((L=g[B].split("[")[1])==null?void 0:L.split("]")[0])||"0",M=parseInt(k)+1;B=`${B.split("[")[0]}[${M}]`}return g[B]=$._getId(),B});f.forEach(($,B)=>$._setId(S[B]));const C=f.map($=>({id:$._getId(),name:$._name,elementType:$._elementType,shownLayers:$.getShownLayerNames()}));x.next(C)});const A=a.asObservable().pipe(re(1)),P=new se,I=P.asObservable().pipe(ut());return{root:t,svg:null,canvas:null,size$:v,encoding$:y,seriesData$:p,gridData$:E,multivariateData$:d,graphData$:_,treeData$:O,plugins$:x,theme$:A,event$:I,eventTrigger$:P,_updateLayerElements:Jr({svgElement$:b,canvasElement$:w,pluginsInstance$:l})}})();return l.subscribe(v=>{let y=!1,p=!1;v.forEach(E=>{E._elementType==="svg"?y=!0:E._elementType==="canvas"&&(p=!0)}),y&&!m.svg?(m.svg=gt("orbcharts-root-svg"),m.root.appendChild(m.svg),b.next(m.svg)):!y&&m.svg&&(m.svg.remove(),m.svg=null,b.next(null)),p&&!m.canvas?(m.canvas=Pe("orbcharts-root-canvas"),m.root.appendChild(m.canvas),w.next(m.canvas)):!p&&m.canvas&&(m.canvas.remove(),m.canvas=null,w.next(null)),v.forEach(E=>{E._injectContext(m)})}),ee({size:m.size$,svg:b}).pipe(Y(0),ge(({svg:v})=>!!v)).subscribe(({size:v,svg:y})=>{y&&(y.setAttribute("width",v.width.toString()),y.setAttribute("height",v.height.toString()))}),ee({size:m.size$,canvas:w}).pipe(Y(0),ge(({canvas:v})=>!!v)).subscribe(({size:v,canvas:y})=>{y&&(y.width=v.width,y.height=v.height)}),(()=>{function v(f){h.next(f)}function y(f){try{const{status:g,columnName:S,expectToBe:C}=It(f);if(g==="error")throw new Error(H({columnName:S,expectToBe:C,from:"Chart.setData"}));g==="warning"&&console.warn(Q({columnName:S,expectToBe:C,from:"Chart.setData"}))}catch(g){console.error(U(g))}n.next(f)}function p(f){try{const{status:S,columnName:C,expectToBe:$}=Tt(f);if(S==="error")throw new Error(H({columnName:C,expectToBe:$,from:"Chart.updateEncoding"}));S==="warning"&&console.warn(Q({columnName:C,expectToBe:$,from:"Chart.updateEncoding"}))}catch(S){console.error(U(S))}const g=J(s.getValue(),f);s.next(g)}function E(f){s.next(f)}function d(){return s.getValue()}function _(f){try{const{status:g,columnName:S,expectToBe:C}=je(f);if(g==="error")throw new Error(H({columnName:S,expectToBe:C,from:"Chart.setPlugins"}));g==="warning"&&console.warn(Q({columnName:S,expectToBe:C,from:"Chart.setPlugins"}))}catch(g){console.error(U(g))}l.next(f)}function O(f){try{const{status:g,columnName:S,expectToBe:C}=je([f]);if(g==="error")throw new Error(H({columnName:S,expectToBe:C,from:"Chart.addPlugin"}));g==="warning"&&console.warn(Q({columnName:S,expectToBe:C,from:"Chart.addPlugin"}))}catch(g){console.error(U(g))}l.next([...l.getValue(),f])}function x(f){l.next(l.getValue().filter(g=>g._getId()!==f))}function A(f){try{const{status:S,columnName:C,expectToBe:$}=$t(f);if(S==="error")throw new Error(H({columnName:C,expectToBe:$,from:"Chart.updateTheme"}));S==="warning"&&console.warn(Q({columnName:C,expectToBe:$,from:"Chart.updateTheme"}))}catch(S){console.error(U(S))}const g=J(a.getValue(),f);a.next(g)}function P(f){a.next(f)}function I(){return a.getValue()}function c(){r.next(void 0),wt(t)}return{resize:v,setData:y,updateEncoding:p,forceReplaceEncoding:E,getEncoding:d,setPlugins:_,addPlugin:O,removePlugin:x,updateTheme:A,forceReplaceTheme:P,getTheme:I,destroy:c,context:m}})()};class Qr{constructor(e,r){return Hr(e,r)}}const Bt=(t,e,r)=>{let n=e.name,o=()=>{};const s=new G(null),u=s.pipe(ge(d=>d!==null)),a={...e.layers.reduce((d,_)=>(d[_._name]=_,d),{})},l=()=>new Set(e.layers.map(d=>d._name)),i=d=>{if(d){const _=l();return Object.keys(d).filter(x=>_.has(x))}return[]},h=e.layers.reduce((d,_)=>(_._initShow&&d.push(_._name),d),[]),b=i(r),w=new G(new Set(b.length>0?b:h)),m=w.pipe(q(d=>Array.from(d).map(O=>{var x;return[O,((x=e.layers.find(A=>A._name===O))==null?void 0:x._layerIndex)??-1]}).filter(([,O])=>O!==-1).sort((O,x)=>O[1]-x[1]).map(([O])=>O))),v=new G(r??{}),y=new se,p=new K(d=>{v.subscribe(_=>{try{const{status:x,columnName:A,expectToBe:P}=e.validator(_);if(x==="error")throw new Error(H({columnName:A,expectToBe:P,from:`${e.name}.params$`}));x==="warning"&&console.warn(Q({columnName:A,expectToBe:P,from:`${e.name}.params$`}))}catch(x){console.error(U(x))}const O=J(e.defaultParams,_??{});d.next(O)}),y.subscribe(_=>{d.next(_)})}),E=u.pipe(q(d=>({context:d,pluginParams$:p})),jr());return ee({pluginSetupProps:E,ShownLayerNameSet:w,shownLayerNamesSeq:m}).pipe(Y(0)).subscribe(({pluginSetupProps:d,ShownLayerNameSet:_,shownLayerNamesSeq:O})=>{const x=d.context._updateLayerElements(t,n,O.map(A=>({pluginId:n,pluginName:e.name,layerName:A,layerIndex:a[A]._layerIndex})));e.setup&&(o=e.setup(d)),e.layers.forEach(A=>{var P,I;if(_.has(A._name)){const c=t==="svg"?{svgG:x[A._name],context:d.context,pluginParams$:p,initLayerParams:((P=v.getValue())==null?void 0:P[A._name])||{}}:{canvas:x[A._name],context:d.context,pluginParams$:p,initLayerParams:((I=v.getValue())==null?void 0:I[A._name])||{}};A._enable(c)}else A._disable()})}),{_name:e.name,_elementType:t,_getId:()=>n,_setId:d=>{n=d},_injectContext:d=>{s.next(Object.assign({},d))},show:d=>{d=Array.isArray(d)?d:[d],w.next(new Set([...Array.from(w.getValue()),...d]))},showOnly:d=>{d=Array.isArray(d)?d:[d],w.next(new Set([...d]))},showAll:()=>{w.next(l())},hide:d=>{d=Array.isArray(d)?d:[d],w.next(new Set([...Array.from(w.getValue()).filter(_=>!d.includes(_))]))},hideAll:()=>{w.next(new Set)},toggle:d=>{d=Array.isArray(d)?d:[d],Array.from(w.getValue()).forEach(_=>{d.includes(_)?d.splice(d.indexOf(_),1):d.push(_)}),w.next(new Set(d))},getShownLayerNames:()=>Array.from(w.getValue()),updateParams:d=>{v.next(d),Object.keys(d).forEach(_=>{const O=a[_];O&&O._updateParams(d[_])})},forceReplaceParams:d=>{y.next(d),Object.keys(d).forEach(_=>{const O=a[_];O&&O._forceReplaceParams(d[_])})},getParams:()=>e.layers.reduce((d,_)=>(d[_._name]=_._getParams(),d),{}),destroy:()=>{o(),s.complete(),w.complete(),e.layers.forEach(d=>{d._destroy()})}}},Xr=t=>class{constructor(r){return Bt("svg",t,r)}},Pt=(t,e)=>{const r=new G(Object.assign({},e.defaultParams));let n=()=>{};const o=new G(null),s=o.pipe(ge(u=>u!==null));return ee({layerParams:r,enabledProps:s}).pipe(Y(0)).subscribe(({layerParams:u,enabledProps:a})=>{n(),n=t==="svg"?e.setup({svgG:a.svgG,context:a.context,pluginParams$:a.pluginParams$,layerParams$:r.pipe(q(l=>J(l,a.initLayerParams??{})))}):e.setup({canvas:a.canvas,context:a.context,pluginParams$:a.pluginParams$,layerParams$:r.pipe(q(l=>J(l,a.initLayerParams??{})))})}),o.pipe(ge(u=>u===null)).subscribe(()=>{n()}),{_name:e.name,_defaultParams:e.defaultParams,_layerIndex:e.layerIndex,_initShow:e.initShow,_enable:u=>{o.next(u)},_disable:()=>{o.next(null)},_updateParams:u=>{try{const{status:l,columnName:i,expectToBe:h}=e.validator(u);if(l==="error")throw new Error(H({columnName:i,expectToBe:h,from:`${e.name}.params$`}));l==="warning"&&console.warn(Q({columnName:i,expectToBe:h,from:`${e.name}.params$`}))}catch(l){console.error(U(l))}const a=J(r.getValue(),u);r.next(a)},_forceReplaceParams:u=>{r.next(u)},_getParams:()=>r.getValue(),_destroy:()=>{o.next(null),o.complete(),r.complete()}}},en=t=>class{constructor(){return Pt("svg",t)}},tn=t=>class{constructor(r){return Bt("canvas",t,r)}},rn=t=>class{constructor(){return Pt("canvas",t)}};T.OrbCharts=Qr,T.aggregate=ye,T.count=dt,T.createCanvas=Pe,T.createCanvasElement=Rr,T.createDiv=Kr,T.createLayerClassName=xt,T.createMessagePrefix=Me,T.createOrbChartsErrorMessage=U,T.createPluginClassName=At,T.createSVG=gt,T.createSVGGroup=bt,T.createUnexpectedErrorMessage=de,T.createValidatorErrorMessage=H,T.createValidatorWarningMessage=Q,T.deepOverwrite=J,T.defineCanvasLayer=rn,T.defineCanvasPlugin=tn,T.defineSVGLayer=en,T.defineSVGPlugin=Xr,T.formatCommaNumber=Lr,T.getColorByFrom=F,T.getColorByIndex=mt,T.isDom=Be,T.isFunction=vt,T.isPlainObject=Z,T.max=yt,T.mean=ct,T.median=ft,T.min=ht,T.none=pt,T.removeElementChildren=wt,T.resizeObservable=Et,T.sum=lt,T.validateObject=R,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
8
+ ----> find in '${r}'`}function Et(t){return new K(e=>{const r=new ResizeObserver(n=>{const o=n[0];o&&o.contentRect&&e.next(o.contentRect)});return r.observe(t),function(){r.unobserve(t)}})}function At(t){return`orbcharts-${t}`}function xt(t,e){return`${At(t)}-${e}`}function Fr(t,e){const r={string:s=>typeof s=="string",number:s=>typeof s=="number",boolean:s=>typeof s=="boolean",object:s=>J(s),"object[]":s=>Array.isArray(s)&&s.every(u=>J(u)),"string[]":s=>Array.isArray(s)&&s.every(u=>typeof u=="string"),"number[]":s=>Array.isArray(s)&&s.every(u=>typeof u=="number"),Function:s=>vt(s),null:s=>s===null,undefined:s=>s===void 0},n={ColorType:s=>s==="none"||s==="data"||s==="primary"||s==="secondary"||s==="dataContrast"||s==="background"};return Object.keys(t).find(s=>{if(e[s]){const u=e[s],a=t[s];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:l,test:i}=u;if(i(a)===!1)return!0}else if(u.toBeOption){const l=u.toBeOption;if(n[l](a)===!1)return!0}}return!1})}function R(t,e){const r=Fr(t,e);if(r){const n=e[r],o=n.toBeTypes?n.toBeTypes.join(" | "):n.toBe?n.toBe:n.toBeOption?n.toBeOption:"";return{status:"error",columnName:r,expectToBe:o}}else return{status:"success",columnName:"",expectToBe:""}}const St={width:"auto",height:"auto",resizeDebounce:50},_t={dataset:{from:"dataset",sort:"original"},series:{from:"series",sort:"original"},category:{from:"category",sort:"original"},value:{from:"value",sort:"original",aggregate:"none"},multivariate:[{from:"x",name:"x"},{from:"y",name:"y"},{from:"z",name:"z"}],color:{from:"series"}},Ct={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"},Dr=(t,e,r)=>{const n=new Map,o=Array.isArray(t[0]);o?t.forEach((a,l)=>{a.forEach(i=>{const f=i[e.dataset.from]||`dataset-${l}`;n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const l=a[e.dataset.from]||"default";n.has(l)||n.set(l,[]),n.get(l).push(a)});let s=Array.from(n.keys());if(Array.isArray(e.dataset.sort))s=e.dataset.sort.filter(a=>n.has(a)).concat(s.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];o?t.forEach((l,i)=>{l.forEach(f=>{const w=f[e.dataset.from]||`dataset-${i}`;a.includes(w)||a.push(w)})}):t.forEach(l=>{const i=l[e.dataset.from]||"default";a.includes(i)||a.push(i)}),s=a}else e.dataset.sort==="alphabetical"&&s.sort((a,l)=>a.localeCompare(l,void 0,{numeric:!0}));const u=[];return s.forEach((a,l)=>{const i=n.get(a),f=new Map;i.forEach(m=>{const p=m[e.series.from]||"default";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=p[e.series.from]||"default";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 S=[];if(e.category.sort==="original")i.forEach(m=>{const p=m[e.category.from]||"default";S.includes(p)||S.push(p)});else if(e.category.sort==="alphabetical"){const m=new Set;i.forEach(p=>{m.add(p[e.category.from]||"default")}),S.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=b[e.category.from]||"default";m.includes(O)||m.push(O)});const p=e.category.sort;S.push(...p.filter(b=>m.includes(b)),...m.filter(b=>!p.includes(b)))}const y=new Map;S.forEach((m,p)=>{y.set(m,p)});const x=[];w.forEach((m,p)=>{const b=f.get(m),O=new Map;b.forEach(d=>{const E=d[e.category.from]||"default";O.has(E)||O.set(E,[]),O.get(E).push(d)});const T=S.filter(d=>O.has(d)),h=[];e.category.sort==="original"&&e.value.aggregate==="none"?(b.forEach((d,E)=>{const M=d[e.category.from]||"default",$=y.get(M),c=d[e.value.from];h.push({id:d.id||`${a}-${m}-${M}-${E}`,index:$,modelType:"series",name:d.name||"",data:d.data,value:typeof c=="number"?c:null,color:F(e.color.from,{index:$,seriesIndex:p,categoryIndex:$,datasetIndex:l},r),series:m,seriesIndex:p,category:M,categoryIndex:$})}),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)):T.forEach(d=>{const E=y.get(d),M=O.get(d);if(e.value.aggregate==="none"){let $=M.map((c,v)=>{const C=c[e.value.from];return{id:c.id||`${a}-${m}-${d}-${v}`,index:E,modelType:"series",name:c.name||"",data:c.data,value:typeof C=="number"?C:null,color:F(e.color.from,{index:E,seriesIndex:p,categoryIndex:E,datasetIndex:l},r),series:m,seriesIndex:p,category:d,categoryIndex:E}});e.value.sort==="asc"?$.sort((c,v)=>c.value===null&&v.value===null?0:c.value===null?1:v.value===null?-1:c.value-v.value):e.value.sort==="desc"&&$.sort((c,v)=>c.value===null&&v.value===null?0:c.value===null?1:v.value===null?-1:v.value-c.value),h.push(...$)}else{const $=M.map(I=>{if(e.value.aggregate==="count")return 1;const g=I[e.value.from];return typeof g=="number"?g:null}),c=ye($,e.value.aggregate),v=M[0],C={id:v.id||`${a}-${m}-${d}-aggregated`,index:E,modelType:"series",name:v.name||d,data:v.data,value:c,color:F(e.color.from,{index:E,seriesIndex:p,categoryIndex:E,datasetIndex:l},r),series:m,seriesIndex:p,category:d,categoryIndex:E};h.push(C)}}),x.push(h)}),u.push(x)}),u},Nr=(t,e,r)=>{const n=new Map,o=Array.isArray(t[0]);o?t.forEach((a,l)=>{a.forEach(i=>{const f=i[e.dataset.from]||`dataset-${l}`;n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const l=a[e.dataset.from]||"default";n.has(l)||n.set(l,[]),n.get(l).push(a)});let s=Array.from(n.keys());if(Array.isArray(e.dataset.sort))s=e.dataset.sort.filter(a=>n.has(a)).concat(s.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];o?t.forEach((l,i)=>{l.forEach(f=>{const w=f[e.dataset.from]||`dataset-${i}`;a.includes(w)||a.push(w)})}):t.forEach(l=>{const i=l[e.dataset.from]||"default";a.includes(i)||a.push(i)}),s=a}else e.dataset.sort==="alphabetical"&&s.sort((a,l)=>a.localeCompare(l,void 0,{numeric:!0}));const u=[];return s.forEach((a,l)=>{const i=n.get(a),f=new Map;i.forEach(p=>{const b=p[e.series.from]||"default";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=b[e.series.from]||"default";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 S=[];i.forEach(p=>{const b=p[e.category.from]||"default";S.includes(b)||S.push(b)});const y=new Set(S);let x=Array.from(y);Array.isArray(e.category.sort)?x=e.category.sort.filter(p=>y.has(p)).concat(x.filter(p=>!e.category.sort.includes(p))):e.category.sort==="original"?x=S:e.category.sort==="alphabetical"&&x.sort((p,b)=>p.localeCompare(b,void 0,{numeric:!0}));const m=[];w.forEach((p,b)=>{const O=f.get(p),T=new Map;O.forEach(d=>{const E=d[e.category.from]||"default";T.has(E)||T.set(E,[]),T.get(E).push(d)});const h=[];x.forEach((d,E)=>{const M=T.get(d);if(!M)h.push({id:`${a}-${p}-${d}-null`,index:E,modelType:"grid",name:d,data:void 0,value:null,color:F(e.color.from,{index:E,seriesIndex:b,categoryIndex:E,datasetIndex:l},r),series:p,seriesIndex:b,category:d,categoryIndex:E});else if(e.value.aggregate==="none"){let $=M.map((c,v)=>{const C=c[e.value.from];return{id:c.id||`${a}-${p}-${d}-${v}`,index:E,modelType:"grid",name:c.name||"",data:c.data,value:typeof C=="number"?C:null,color:F(e.color.from,{index:E,seriesIndex:b,categoryIndex:E,datasetIndex:l},r),series:p,seriesIndex:b,category:d,categoryIndex:E}});e.value.sort==="asc"?$.sort((c,v)=>c.value===null&&v.value===null?0:c.value===null?1:v.value===null?-1:c.value-v.value):e.value.sort==="desc"&&$.sort((c,v)=>c.value===null&&v.value===null?0:c.value===null?1:v.value===null?-1:v.value-c.value),h.push(...$)}else{const $=M.map(I=>{if(e.value.aggregate==="count")return 1;const g=I[e.value.from];return typeof g=="number"?g:null}),c=ye($,e.value.aggregate),v=M[0],C={id:v.id||`${a}-${p}-${d}-aggregated`,index:E,modelType:"grid",name:v.name||d,data:v.data,value:c,color:F(e.color.from,{index:E,seriesIndex:b,categoryIndex:E,datasetIndex:l},r),series:p,seriesIndex:b,category:d,categoryIndex:E};h.push(C)}}),m.push(h)}),u.push(m)}),u},Gr=(t,e,r)=>{const n=new Map,o=Array.isArray(t[0]);o?t.forEach((a,l)=>{a.forEach(i=>{const f=i[e.dataset.from]||`dataset-${l}`;n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const l=a[e.dataset.from]||"default";n.has(l)||n.set(l,[]),n.get(l).push(a)});let s=Array.from(n.keys());if(Array.isArray(e.dataset.sort))s=e.dataset.sort.filter(a=>n.has(a)).concat(s.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];o?t.forEach((l,i)=>{l.forEach(f=>{const w=f[e.dataset.from]||`dataset-${i}`;a.includes(w)||a.push(w)})}):t.forEach(l=>{const i=l[e.dataset.from]||"default";a.includes(i)||a.push(i)}),s=a}else e.dataset.sort==="alphabetical"&&s.sort((a,l)=>a.localeCompare(l,void 0,{numeric:!0}));const u=[];return s.forEach((a,l)=>{const i=n.get(a),f=new Map;i.forEach(y=>{const x=y[e.series.from]||"default";f.has(x)||f.set(x,[]),f.get(x).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(x=>{const m=x[e.series.from]||"default";y.includes(m)||y.push(m)}),w=y}else e.series.sort==="alphabetical"&&w.sort((y,x)=>y.localeCompare(x,void 0,{numeric:!0}));const S=[];w.forEach((y,x)=>{const m=f.get(y),p=new Map;m.forEach(T=>{const h=T[e.category.from]||"default";p.has(h)||p.set(h,[]),p.get(h).push(T)});let b=Array.from(p.keys());if(Array.isArray(e.category.sort))b=e.category.sort.filter(T=>p.has(T)).concat(b.filter(T=>!e.category.sort.includes(T)));else if(e.category.sort==="original"){const T=[];m.forEach(h=>{const d=h[e.category.from]||"default";T.includes(d)||T.push(d)}),b=T}else e.category.sort==="alphabetical"&&b.sort((T,h)=>T.localeCompare(h,void 0,{numeric:!0}));const O=[];b.forEach((T,h)=>{p.get(T).forEach((E,M)=>{const $=e.multivariate.map((v,C)=>({index:C,name:v.name,value:(()=>{const I=E[v.from];return typeof I=="number"?I:null})()})),c={id:E.id||`${a}-${y}-${T}-${M}`,index:M,modelType:"multivariate",name:E.name||"",data:E.data,value:null,color:F(e.color.from,{index:M,seriesIndex:x,categoryIndex:h,datasetIndex:l},r),multivariate:$,series:y,seriesIndex:x,category:T,categoryIndex:h};O.push(c)})}),S.push(O)}),u.push(S)}),u},Ur=(t,e,r)=>{const n=Array.isArray(t[0]),o=[],s=[];n?t.forEach(i=>{i.forEach(f=>{f.source&&f.target?s.push(f):o.push(f)})}):t.forEach(i=>{i.source&&i.target?s.push(i):o.push(i)});const u=new Map;n?t.forEach((i,f)=>{i.forEach(w=>{if(!w.source||!w.target){const S=w[e.dataset.from]||`dataset-${f}`;u.has(S)||u.set(S,[]),u.get(S).push(w)}})}):o.forEach(i=>{const f=i[e.dataset.from]||"default";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(S=>{if(!S.source||!S.target){const y=S[e.dataset.from]||`dataset-${w}`;i.includes(y)||i.push(y)}})}):o.forEach(f=>{const w=f[e.dataset.from]||"default";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 l=[];return a.forEach((i,f)=>{const w=u.get(i),S=[],y=new Map;w.forEach(c=>{const v=c[e.series.from]||"default";y.has(v)||y.set(v,[]),y.get(v).push(c)});let x=Array.from(y.keys());if(Array.isArray(e.series.sort))x=e.series.sort.filter(c=>y.has(c)).concat(x.filter(c=>!e.series.sort.includes(c)));else if(e.series.sort==="original"){const c=[];w.forEach(v=>{const C=v[e.series.from]||"default";c.includes(C)||c.push(C)}),x=c}else e.series.sort==="alphabetical"&&x.sort((c,v)=>c.localeCompare(v,void 0,{numeric:!0}));x.forEach((c,v)=>{const C=y.get(c),I=new Map;C.forEach(A=>{const _=A[e.category.from]||"default";I.has(_)||I.set(_,[]),I.get(_).push(A)});let g=Array.from(I.keys());if(Array.isArray(e.category.sort))g=e.category.sort.filter(A=>I.has(A)).concat(g.filter(A=>!e.category.sort.includes(A)));else if(e.category.sort==="original"){const A=[];C.forEach(_=>{const B=_[e.category.from]||"default";A.includes(B)||A.push(B)}),g=A}else e.category.sort==="alphabetical"&&g.sort((A,_)=>A.localeCompare(_,void 0,{numeric:!0}));g.forEach((A,_)=>{const B=I.get(A);if(e.value.aggregate==="none"){let j=B.map((k,L)=>{const D=k[e.value.from];return{id:k.id||`${i}-${c}-${A}-${L}`,index:S.length+L,modelType:"graph",name:k.name||"",data:k.data,value:typeof D=="number"?D:null,color:F(e.color.from,{index:_,seriesIndex:v,categoryIndex:_,datasetIndex:f},r),series:c,seriesIndex:v,category:A,categoryIndex:_}});e.value.sort==="asc"?j.sort((k,L)=>k.value===null&&L.value===null?0:k.value===null?1:L.value===null?-1:k.value-L.value):e.value.sort==="desc"&&j.sort((k,L)=>k.value===null&&L.value===null?0:k.value===null?1:L.value===null?-1:L.value-k.value),S.push(...j)}else{const j=B.map(te=>{if(e.value.aggregate==="count")return 1;const oe=te[e.value.from];return typeof oe=="number"?oe:null}),k=ye(j,e.value.aggregate),L=B[0],D={id:L.id||`${i}-${c}-${A}-aggregated`,index:S.length,modelType:"graph",name:L.name||A,data:L.data,value:k,color:F(e.color.from,{index:_,seriesIndex:v,categoryIndex:_,datasetIndex:f},r),series:c,seriesIndex:v,category:A,categoryIndex:_};S.push(D)}})});const m=[],p=new Map;S.forEach(c=>{const v=o.find(C=>C.id===c.id||C.name===c.name);v!=null&&v.id&&p.set(v.id,c.index),v!=null&&v.name&&p.set(v.name,c.index)});const b=new Map,O=new Map;S.forEach(c=>{b.has(c.series)||b.set(c.series,c.seriesIndex),O.has(c.category)||O.set(c.category,c.categoryIndex)});let T=b.size,h=O.size;const d=c=>(b.has(c)||b.set(c,T++),b.get(c)),E=c=>(O.has(c)||O.set(c,h++),O.get(c)),M=s.filter(c=>(c[e.dataset.from]||"default")===i),$=new Map;M.forEach(c=>{const v=c.source,C=c.target,I=c[e.series.from]||"default",g=c[e.category.from]||"default",A=`${v}-${C}-${I}-${g}`;$.has(A)||$.set(A,[]),$.get(A).push(c)}),Array.from($.entries()).forEach(([c,v],C)=>{const I=v[0],g=I.source,A=I.target,_=p.get(g)??-1,B=p.get(A)??-1;if(_>=0&&B>=0)if(e.value.aggregate==="none")v.forEach((j,k)=>{const L=j[e.value.from],D=j[e.series.from]||"default",te=j[e.category.from]||"default",oe=d(D),Ae=E(te),ke={id:j.id||`edge-${C}-${k}`,index:m.length,modelType:"graph",name:j.name||"",data:j.data,value:typeof L=="number"?L:null,color:F(e.color.from,{index:m.length,seriesIndex:oe,categoryIndex:Ae,datasetIndex:f},r),series:D,seriesIndex:oe,category:te,categoryIndex:Ae,source:g,sourceIndex:_,target:A,targetIndex:B};m.push(ke)});else{const j=v.map(ke=>{if(e.value.aggregate==="count")return 1;const Mt=ke[e.value.from];return typeof Mt=="number"?Mt:null}),k=ye(j,e.value.aggregate),L=I[e.series.from]||"default",D=I[e.category.from]||"default",te=d(L),oe=E(D),Ae={id:I.id||`edge-${C}-aggregated`,index:m.length,modelType:"graph",name:I.name||"",data:I.data,value:k,color:F(e.color.from,{index:m.length,seriesIndex:te,categoryIndex:oe,datasetIndex:f},r),series:L,seriesIndex:te,category:D,categoryIndex:oe,source:g,sourceIndex:_,target:A,targetIndex:B};m.push(Ae)}}),l.push({nodes:S,edges:m})}),l},zr=(t,e,r)=>{const n=new Map,o=Array.isArray(t[0]);o?t.forEach((a,l)=>{a.forEach(i=>{const f=i[e.dataset.from]||`dataset-${l}`;n.has(f)||n.set(f,[]),n.get(f).push(i)})}):t.forEach(a=>{const l=a[e.dataset.from]||"default";n.has(l)||n.set(l,[]),n.get(l).push(a)});let s=Array.from(n.keys());if(Array.isArray(e.dataset.sort))s=e.dataset.sort.filter(a=>n.has(a)).concat(s.filter(a=>!e.dataset.sort.includes(a)));else if(e.dataset.sort==="original"){const a=[];o?t.forEach((l,i)=>{l.forEach(f=>{const w=f[e.dataset.from]||`dataset-${i}`;a.includes(w)||a.push(w)})}):t.forEach(l=>{const i=l[e.dataset.from]||"default";a.includes(i)||a.push(i)}),s=a}else e.dataset.sort==="alphabetical"&&s.sort((a,l)=>a.localeCompare(l,void 0,{numeric:!0}));const u=[];return s.forEach((a,l)=>{const i=n.get(a),f=new Map;i.forEach(c=>{const v=c[e.series.from]||"default";f.has(v)||f.set(v,[]),f.get(v).push(c)});let w=Array.from(f.keys());if(Array.isArray(e.series.sort))w=e.series.sort.filter(c=>f.has(c)).concat(w.filter(c=>!e.series.sort.includes(c)));else if(e.series.sort==="original"){const c=[];i.forEach(v=>{const C=v[e.series.from]||"default";c.includes(C)||c.push(C)}),w=c}else e.series.sort==="alphabetical"&&w.sort((c,v)=>c.localeCompare(v,void 0,{numeric:!0}));const S=new Map;i.forEach(c=>{const v=c[e.category.from]||"default";S.has(v)||S.set(v,[]),S.get(v).push(c)});let y=Array.from(S.keys());if(Array.isArray(e.category.sort))y=e.category.sort.filter(c=>S.has(c)).concat(y.filter(c=>!e.category.sort.includes(c)));else if(e.category.sort==="original"){const c=[];i.forEach(v=>{const C=v[e.category.from]||"default";c.includes(C)||c.push(C)}),y=c}else e.category.sort==="alphabetical"&&y.sort((c,v)=>c.localeCompare(v,void 0,{numeric:!0}));const x=new Map;i.forEach(c=>{const v=c.id||"unknown";x.has(v)||x.set(v,[]),x.get(v).push(c)});let m=0;const p=w[0]||"default",b=w.indexOf(p),O=new Map;Array.from(x.entries()).forEach(([c,v])=>{const C=v[0],I=C[e.series.from]||"default",g=w.indexOf(I),A=C[e.category.from]||"default",_=y.indexOf(A);if(e.value.aggregate==="none"){const B=C[e.value.from],j={id:c,index:m++,modelType:"tree",name:C.name||c,data:C.data,value:typeof B=="number"?B:null,color:F(e.color.from,{index:m-1,seriesIndex:g,categoryIndex:_,datasetIndex:l},r),parent:C.parent||null,parentIndex:null,depth:0,seq:0,children:[],series:I,seriesIndex:g,category:A,categoryIndex:_};O.set(c,j)}else{const B=v.map(L=>{if(e.value.aggregate==="count")return 1;const D=L[e.value.from];return typeof D=="number"?D:null}),j=ye(B,e.value.aggregate),k={id:c,index:m++,modelType:"tree",name:C.name||c,data:C.data,value:j,color:F(e.color.from,{index:m-1,seriesIndex:g,categoryIndex:_,datasetIndex:l},r),parent:C.parent||null,parentIndex:null,depth:0,seq:0,children:[],series:I,seriesIndex:g,category:A,categoryIndex:_};O.set(c,k)}});const T=Array.from(O.values()),h=new Map;T.forEach(c=>{h.set(c.id,c.index)}),T.forEach(c=>{c.parent&&h.has(c.parent)&&(c.parentIndex=h.get(c.parent))});const d=[],E=new Map;T.forEach(c=>{c.parent===null?d.push(c):(E.has(c.parent)||E.set(c.parent,[]),E.get(c.parent).push(c))});function M(c,v){c.depth=v;const C=E.get(c.id)||[];return e.value.sort==="asc"?C.sort((I,g)=>I.value===null&&g.value===null?0:I.value===null?1:g.value===null?-1:I.value-g.value):e.value.sort==="desc"&&C.sort((I,g)=>I.value===null&&g.value===null?0:I.value===null?1:g.value===null?-1:g.value-I.value),C.forEach((I,g)=>{I.seq=g}),c.children=C.map(I=>M(I,v+1)),c}const $=d.map(c=>M(c,0));if($.length===0)u.push({id:`empty-${a}`,index:m++,modelType:"tree",name:"Empty Tree",data:{},value:null,color:F(e.color.from,{index:m-1,seriesIndex:b<0?0:b,categoryIndex:0,datasetIndex:l},r),parent:null,parentIndex:null,depth:0,seq:0,children:[],series:p,seriesIndex:b<0?0:b,category:"default",categoryIndex:0});else if($.length===1)u.push($[0]);else{const c={id:`virtual-root-${a}`,index:m++,modelType:"tree",name:`Virtual Root (${a})`,data:{},value:null,color:F(e.color.from,{index:m-1,seriesIndex:b<0?0:b,categoryIndex:0,datasetIndex:l},r),parent:null,parentIndex:null,depth:0,seq:0,children:$.map((v,C)=>{const I=(g,A)=>(g.depth=A,A===1&&(g.seq=C),g.children=g.children.map(_=>I(_,A+1)),g);return I(v,1)}),series:p,seriesIndex:b<0?0:b,category:"default",categoryIndex:0};u.push(c)}}),u};function qr(t,e,r){const n=e.map(a=>r[a]).filter(a=>a&&a.parentNode===t);if(n.length===0)return;let o=!0,s=null;for(const a of n){if(s&&s.nextElementSibling!==a){o=!1;break}s=a}if(o)return;const u=document.createDocumentFragment();e.forEach(a=>{const l=r[a];l&&l.parentNode===t&&u.appendChild(l)}),t.appendChild(u)}function Ot(t,e,r,n,o){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&&qr(t,e,r)}function Wr(t){return R({element:t},{element:{toBe:"Dom",test:r=>Be(r)}})}function Yr(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 Tt(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 $t(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(o=>typeof o=="string")}});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(o=>typeof o=="string")}});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(o=>typeof o=="string")}});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(o=>typeof o.from=="string"&&typeof o.label=="string")}});if(r.status==="error")return r}if(t.color){const r=R(t.color,{from:{toBe:'"index" | "series" | "category" | "dataset"',test:n=>["index","series","category","dataset"].includes(n)}});if(r.status==="error")return r}return e}function It(t){return R({data:t},{data:{toBe:"RawDataColumn[] | RawDataColumn[][]",test:r=>Array.isArray(r)&&r.every(n=>Array.isArray(n)||J(n))}})}function je(t){return R({plugins:t},{plugins:{toBe:"PluginEntity[]",test:r=>Array.isArray(r)&&r.every(n=>J(n)&&typeof n._name=="string"&&typeof n._injectContext=="function")}})}function Zr(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=>J(n)&&typeof n._name=="string"&&typeof n._injectContext=="function")}});if(e.status==="error")return e;if(t.size){const r=Yr(t.size);if(r.status==="error")return r}if(t.theme){const r=Tt(t.theme);if(r.status==="error")return r}if(t.encoding){const r=$t(t.encoding);if(r.status==="error")return r}if(t.data){const r=It(t.data);if(r.status==="error")return r}if(t.plugins){const r=je(t.plugins);if(r.status==="error")return r}return e}function Jr({svgElement$:t,canvasElement$:e,pluginsInstance$:r}){let n=[],o=[];const s=(l,i,f)=>{const w=r.getValue().reduce((x,m,p)=>(x[m._getId()]=p,x),{}),S=f.map(x=>({...x,pluginSeq:w[x.pluginId]}));return(l==="svg"?n:o).filter(x=>x.pluginId!==i).map(x=>({...x,pluginSeq:w[x.pluginId]})).concat(S).sort((x,m)=>x.layerIndex-m.layerIndex||x.pluginSeq-m.pluginSeq)},u={},a={};return(l,i,f)=>{const w=l==="svg"?t.getValue():e.getValue();if(!w)return{};const S=l==="svg"?u:a,y=s(l,i,f),x=y.map(p=>xt(p.pluginId,p.layerName));return l==="svg"?(Ot(w,x,S,p=>bt(p)),n=y):(Ot(w,x,S,p=>Pe(p)),o=y),Object.entries(S).reduce((p,[b,O])=>{const[T,h,d]=b.split("-");return h===i&&(p[d]=O),p},{})}}const Hr=(t,e)=>{try{const{status:b,columnName:O,expectToBe:T}=Zr(e);if(b==="error")throw new Error(H({columnName:O,expectToBe:T,from:"Chart.constructor"}));if(b==="warning")console.warn(Q({columnName:O,expectToBe:T,from:"Chart.constructor"}));else{const{status:h,columnName:d,expectToBe:E}=Wr(t);if(h==="error")throw new Error(H({columnName:d,expectToBe:E,from:"Chart.constructor"}));h==="warning"&&console.warn(Q({columnName:d,expectToBe:E,from:"Chart.constructor"}))}}catch(b){throw new Error(b)}const r=new ae,n=new U((e==null?void 0:e.data)||[]),o=e&&e.encoding?W(_t,e.encoding):_t,s=new U(o),u=e&&e.theme?W(Ct,e.theme):Ct,a=new U(u),l=new U((e==null?void 0:e.plugins)||[]),i=e&&e.size?W(St,e.size):St,f=new U(i),w=new U(null),S=new U(null),y=(()=>{const b=f.pipe(kr(g=>Or(()=>g.width==="auto"||g.height==="auto",Et(t).pipe(q(A=>({width:g.width==="auto"?A.width:g.width,height:g.height==="auto"?A.height<=0?A.width:A.height:g.height})),Z(g.resizeDebounce),Ir((A,_)=>JSON.stringify(A)===JSON.stringify(_))),dr({width:g.width,height:g.height}))),Lr(r),ne(1)),O=s.asObservable().pipe(ne(1)),T=ee([n,s,a]).pipe(Z(0),q(([g,A,_])=>{try{return Dr(g,A,_)}catch(B){throw new Error(de({from:"Chart.seriesData$",systemMessage:B}))}}),he(g=>(console.error(z(g)),fe)),ne(1)),h=ee([n,s,a]).pipe(Z(0),q(([g,A,_])=>{try{return Nr(g,A,_)}catch(B){throw new Error(de({from:"Chart.gridData$",systemMessage:B}))}}),he(g=>(console.error(z(g)),fe)),ne(1)),d=ee([n,s,a]).pipe(Z(0),q(([g,A,_])=>{try{return Gr(g,A,_)}catch(B){throw new Error(de({from:"Chart.multivariateData$",systemMessage:B}))}}),he(g=>(console.error(z(g)),fe)),ne(1)),E=ee([n,s,a]).pipe(Z(0),q(([g,A,_])=>{try{return Ur(g,A,_)}catch(B){throw new Error(de({from:"Chart.graphData$",systemMessage:B}))}}),he(g=>(console.error(z(g)),fe)),ne(1)),M=ee([n,s,a]).pipe(Z(0),q(([g,A,_])=>{try{return zr(g,A,_)}catch(B){throw new Error(de({from:"Chart.treeData$",systemMessage:B}))}}),he(g=>(console.error(z(g)),fe)),ne(1)),$=new U([]);l.subscribe(g=>{const A={},_=g.map(j=>{var L;let k=j._getId();if(A[k]){const D=((L=A[k].split("[")[1])==null?void 0:L.split("]")[0])||"0",te=parseInt(D)+1;k=`${k.split("[")[0]}[${te}]`}return A[k]=j._getId(),k});g.forEach((j,k)=>j._setId(_[k]));const B=g.map(j=>({id:j._getId(),name:j._name,elementType:j._elementType,shownLayers:j.getShownLayerNames()}));$.next(B)});const c=a.asObservable().pipe(ne(1)),v=new ae,C=v.asObservable().pipe(ut());return{root:t,svg:null,canvas:null,size$:b,encoding$:O,seriesData$:T,gridData$:h,multivariateData$:d,graphData$:E,treeData$:M,plugins$:$,theme$:c,event$:C,eventTrigger$:v,_updateLayerElements:Jr({svgElement$:w,canvasElement$:S,pluginsInstance$:l})}})();let x=null;const m=()=>(x||(x=document.createElement("div"),x.classList.add("orbcharts-container"),x.style.position="relative",t.appendChild(x)),x);let p=[];return l.subscribe(b=>{p.filter(d=>!b.includes(d)).forEach(d=>{y._updateLayerElements(d._elementType,d._getId(),[]),d.destroy()}),p=b;let T=!1,h=!1;b.forEach(d=>{d._elementType==="svg"?T=!0:d._elementType==="canvas"&&(h=!0)}),T&&!y.svg?(y.svg=gt("orbcharts-root-svg"),m().appendChild(y.svg),w.next(y.svg)):!T&&y.svg&&(y.svg.remove(),y.svg=null,w.next(null)),h&&!y.canvas?(y.canvas=Pe("orbcharts-root-canvas"),m().appendChild(y.canvas),S.next(y.canvas)):!h&&y.canvas&&(y.canvas.remove(),y.canvas=null,S.next(null)),b.forEach(d=>{d._injectContext(y)})}),ee({size:y.size$,svg:w}).pipe(Z(0),ge(({svg:b})=>!!b)).subscribe(({size:b,svg:O})=>{O&&(O.setAttribute("width",b.width.toString()),O.setAttribute("height",b.height.toString()))}),ee({size:y.size$,canvas:S}).pipe(Z(0),ge(({canvas:b})=>!!b)).subscribe(({size:b,canvas:O})=>{O&&(O.width=b.width,O.height=b.height)}),(()=>{function b(g){f.next(g)}function O(g){try{const{status:A,columnName:_,expectToBe:B}=It(g);if(A==="error")throw new Error(H({columnName:_,expectToBe:B,from:"Chart.setData"}));A==="warning"&&console.warn(Q({columnName:_,expectToBe:B,from:"Chart.setData"}))}catch(A){console.error(z(A))}n.next(g)}function T(g){try{const{status:_,columnName:B,expectToBe:j}=$t(g);if(_==="error")throw new Error(H({columnName:B,expectToBe:j,from:"Chart.updateEncoding"}));_==="warning"&&console.warn(Q({columnName:B,expectToBe:j,from:"Chart.updateEncoding"}))}catch(_){console.error(z(_))}const A=W(s.getValue(),g);s.next(A)}function h(g){s.next(g)}function d(){return s.getValue()}function E(g){try{const{status:A,columnName:_,expectToBe:B}=je(g);if(A==="error")throw new Error(H({columnName:_,expectToBe:B,from:"Chart.setPlugins"}));A==="warning"&&console.warn(Q({columnName:_,expectToBe:B,from:"Chart.setPlugins"}))}catch(A){console.error(z(A))}l.next(g)}function M(g){try{const{status:A,columnName:_,expectToBe:B}=je([g]);if(A==="error")throw new Error(H({columnName:_,expectToBe:B,from:"Chart.addPlugin"}));A==="warning"&&console.warn(Q({columnName:_,expectToBe:B,from:"Chart.addPlugin"}))}catch(A){console.error(z(A))}l.next([...l.getValue(),g])}function $(g){l.next(l.getValue().filter(A=>A._getId()!==g))}function c(g){try{const{status:_,columnName:B,expectToBe:j}=Tt(g);if(_==="error")throw new Error(H({columnName:B,expectToBe:j,from:"Chart.updateTheme"}));_==="warning"&&console.warn(Q({columnName:B,expectToBe:j,from:"Chart.updateTheme"}))}catch(_){console.error(z(_))}const A=W(a.getValue(),g);a.next(A)}function v(g){a.next(g)}function C(){return a.getValue()}function I(){r.next(void 0),wt(t),x=null}return{resize:b,setData:O,updateEncoding:T,forceReplaceEncoding:h,getEncoding:d,setPlugins:E,addPlugin:M,removePlugin:$,updateTheme:c,forceReplaceTheme:v,getTheme:C,destroy:I,context:y}})()};class Qr{constructor(e,r){return Hr(e,r)}}const Bt=(t,e,r)=>{let n=e.name,o=()=>{};const s=new U(null),u=s.pipe(ge(h=>h!==null)),a=e.layers.map(h=>new h),l={...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(M=>d.has(M))}return[]},w=a.reduce((h,d)=>(d._initShow&&h.push(d._name),h),[]),S=f(r),y=new U(new Set(S.length>0?S:w)),x=y.pipe(q(h=>Array.from(h).map(E=>{var M;return[E,((M=a.find($=>$._name===E))==null?void 0:M._layerIndex)??-1]}).filter(([,E])=>E!==-1).sort((E,M)=>E[1]-M[1]).map(([E])=>E)));let m=W(e.defaultParams??{},r??{});const p=new U(r??{}),b=new ae,O=new K(h=>{p.subscribe(d=>{try{const{status:E,columnName:M,expectToBe:$}=e.validator(d);if(E==="error")throw new Error(H({columnName:M,expectToBe:$,from:`${e.name}.params$`}));E==="warning"&&console.warn(Q({columnName:M,expectToBe:$,from:`${e.name}.params$`}))}catch(E){console.error(z(E))}h.next(m)}),b.subscribe(d=>{h.next(d)})}),T=u.pipe(q(h=>({context:h,pluginParams$:O})),jr());return ee({pluginSetupProps:T,ShownLayerNameSet:y,shownLayerNamesSeq:x}).pipe(Z(0)).subscribe(({pluginSetupProps:h,ShownLayerNameSet:d,shownLayerNamesSeq:E})=>{const M=h.context._updateLayerElements(t,n,E.map($=>({pluginId:n,pluginName:e.name,layerName:$,layerIndex:l[$]._layerIndex})));e.setup&&(o=e.setup(h)),a.forEach($=>{var c,v;if(d.has($._name)){const C=t==="svg"?{svgG:M[$._name],context:h.context,pluginParams$:O,initLayerParams:((c=p.getValue())==null?void 0:c[$._name])||{}}:{canvas:M[$._name],context:h.context,pluginParams$:O,initLayerParams:((v=p.getValue())==null?void 0:v[$._name])||{}};$._enable(C)}else $._disable()})}),{_name:e.name,_elementType:t,_getId:()=>n,_setId:h=>{n=h},_injectContext:h=>{s.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=W(m,h),p.next(h),Object.keys(h).forEach(d=>{const E=l[d];E&&E._updateParams(h[d])})},forceReplaceParams:h=>{m=h,b.next(h),Object.keys(h).forEach(d=>{const E=l[d];E&&E._forceReplaceParams(h[d])})},getParams:()=>{const h=Object.assign({},m);return a.forEach(d=>{h[d._name]=d._getParams()}),h},destroy:()=>{o(),s.complete(),y.complete(),a.forEach(h=>{h._destroy()})}}},Xr=t=>class{constructor(r){return Bt("svg",t,r)}},Pt=(t,e)=>{const r=new U(Object.assign({},e.defaultParams));let n=()=>{};const o=new U(null),s=o.pipe(ge(u=>u!==null));return ee({layerParams:r,enabledProps:s}).pipe(Z(0)).subscribe(({layerParams:u,enabledProps:a})=>{n(),n=t==="svg"?e.setup({svgG:a.svgG,context:a.context,pluginParams$:a.pluginParams$,layerParams$:r.pipe(q(l=>W(l,a.initLayerParams??{})))}):e.setup({canvas:a.canvas,context:a.context,pluginParams$:a.pluginParams$,layerParams$:r.pipe(q(l=>W(l,a.initLayerParams??{})))})}),o.pipe(ge(u=>u===null)).subscribe(()=>{n()}),{_name:e.name,_defaultParams:e.defaultParams,_layerIndex:e.layerIndex,_initShow:e.initShow,_enable:u=>{o.next(u)},_disable:()=>{o.next(null)},_updateParams:u=>{try{const{status:l,columnName:i,expectToBe:f}=e.validator(u);if(l==="error")throw new Error(H({columnName:i,expectToBe:f,from:`${e.name}.params$`}));l==="warning"&&console.warn(Q({columnName:i,expectToBe:f,from:`${e.name}.params$`}))}catch(l){console.error(z(l))}const a=W(r.getValue(),u);r.next(a)},_forceReplaceParams:u=>{r.next(u)},_getParams:()=>r.getValue(),_destroy:()=>{o.next(null),o.complete(),r.complete()}}},en=t=>class{constructor(){return Pt("svg",t)}},tn=t=>class{constructor(r){return Bt("canvas",t,r)}},rn=t=>class{constructor(){return Pt("canvas",t)}};P.OrbCharts=Qr,P.aggregate=ye,P.count=dt,P.createCanvas=Pe,P.createCanvasElement=Rr,P.createDiv=Kr,P.createLayerClassName=xt,P.createMessagePrefix=Me,P.createOrbChartsErrorMessage=z,P.createPluginClassName=At,P.createSVG=gt,P.createSVGGroup=bt,P.createUnexpectedErrorMessage=de,P.createValidatorErrorMessage=H,P.createValidatorWarningMessage=Q,P.deepOverwrite=W,P.defineCanvasLayer=rn,P.defineCanvasPlugin=tn,P.defineSVGLayer=en,P.defineSVGPlugin=Xr,P.formatCommaNumber=Vr,P.getColorByFrom=F,P.getColorByIndex=mt,P.isDom=Be,P.isFunction=vt,P.isPlainObject=J,P.max=yt,P.mean=ct,P.median=ft,P.min=ht,P.none=pt,P.removeElementChildren=wt,P.resizeObservable=Et,P.sum=lt,P.validateObject=R,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
@@ -16,7 +16,7 @@ export interface DefinePluginConfig<ExtendContext extends ExtendableContext, Plu
16
16
  name: string;
17
17
  defaultParams?: PluginParams;
18
18
  validator?: (params: DeepPartial<AllLayerParams | PluginParams>) => ValidatorResult;
19
- layers?: LayerEntity<ExtendContext, PluginParams, AllLayerParams[keyof AllLayerParams]>[];
19
+ layers?: (new () => LayerEntity<ExtendContext, PluginParams, AllLayerParams[keyof AllLayerParams]>)[];
20
20
  setup?: (props: PluginSetupProps<ExtendContext, PluginParams>) => () => void;
21
21
  }
22
22
  export interface PluginEntity<ElementType extends 'svg' | 'canvas', PluginParams extends Record<string, any>, AllLayerParams extends Record<string, any>> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbcharts/core",
3
- "version": "4.0.0-alpha.0",
3
+ "version": "4.0.0-beta.1",
4
4
  "description": "Core codes for OrbCharts",
5
5
  "author": "Blue Planet Inc.",
6
6
  "license": "Apache-2.0",
@@ -741,8 +741,41 @@ export const createChart: CreateChart = (element, options) => {
741
741
  return _context
742
742
  })()
743
743
 
744
+ // OrbCharts 自有的 container(root 的直接子元素,由 OrbCharts 建立及擁有):
745
+ // svg/canvas 為 position:absolute,需要一個 positioned ancestor 作為錨點,
746
+ // 但 root 是使用者傳入的元素、不應修改它的樣式——
747
+ // 因此在 root 底下建立 position:relative 的 container 來掛載 svg/canvas。
748
+ // (container 本身高度為 0、不影響 root 的尺寸量測;destroy 時隨 root 清空一併移除)
749
+ let orbContainer: HTMLDivElement | null = null
750
+ const getOrbContainer = (): HTMLDivElement => {
751
+ if (!orbContainer) {
752
+ orbContainer = document.createElement('div')
753
+ orbContainer.classList.add('orbcharts-container')
754
+ orbContainer.style.position = 'relative'
755
+ element.appendChild(orbContainer)
756
+ }
757
+ return orbContainer
758
+ }
759
+
744
760
  // inject context into plugins
761
+ let previousPlugins: PluginEntity<any, unknown, unknown>[] = []
745
762
  pluginsInstance$.subscribe(plugins => {
763
+ // -- 清理被移除的 plugin --
764
+ // setPlugins()/removePlugin() 換掉的舊 plugin,若沒有新 plugin 用相同
765
+ // pluginId 重新呼叫 _updateLayerElements(例如從 GridPlot 換成
766
+ // PartitionPlot 這種不同種類的切換),它的 layer 登記會一直留在
767
+ // svgLayerInfo/canvasLayerInfo 裡、DOM 元素永遠不會被移除(同種類切換
768
+ // 之所以看起來正常,只是因為新 plugin 用同一個 pluginId 重新登記,
769
+ // 把舊登記蓋掉的副作用,並不是真的有清理機制)。這裡明確對每個「上一輪
770
+ // 有、這一輪沒有」的 plugin 呼叫一次空的 _updateLayerElements 把它的
771
+ // 登記清掉,並呼叫 destroy() 釋放其內部資源。
772
+ const removedPlugins = previousPlugins.filter(prevPlugin => !plugins.includes(prevPlugin))
773
+ removedPlugins.forEach(removedPlugin => {
774
+ context._updateLayerElements(removedPlugin._elementType, removedPlugin._getId(), [])
775
+ removedPlugin.destroy()
776
+ })
777
+ previousPlugins = plugins
778
+
746
779
  // -- 建立頂層 svg 和 canvas --
747
780
  let hasSVGPlugin = false
748
781
  let hasCanvasPlugin = false
@@ -755,7 +788,7 @@ export const createChart: CreateChart = (element, options) => {
755
788
  })
756
789
  if (hasSVGPlugin && !context.svg) {
757
790
  context.svg = createSVG('orbcharts-root-svg')
758
- context.root.appendChild(context.svg)
791
+ getOrbContainer().appendChild(context.svg)
759
792
  svgElement$.next(context.svg)
760
793
  } else if (!hasSVGPlugin && context.svg) {
761
794
  context.svg.remove()
@@ -764,7 +797,7 @@ export const createChart: CreateChart = (element, options) => {
764
797
  }
765
798
  if (hasCanvasPlugin && !context.canvas) {
766
799
  context.canvas = createCanvas('orbcharts-root-canvas')
767
- context.root.appendChild(context.canvas)
800
+ getOrbContainer().appendChild(context.canvas)
768
801
  canvasElement$.next(context.canvas)
769
802
  } else if (!hasCanvasPlugin && context.canvas) {
770
803
  context.canvas.remove()
@@ -972,8 +1005,9 @@ export const createChart: CreateChart = (element, options) => {
972
1005
  // context.svgSelection.remove()
973
1006
  // context.canvasSelection.remove()
974
1007
  destroy$.next(undefined)
975
- // 清空 element 底下所有元素
1008
+ // 清空 element 底下所有元素(含 OrbCharts 自有的 container)
976
1009
  removeElementChildren(element)
1010
+ orbContainer = null
977
1011
  }
978
1012
 
979
1013
  return {
@@ -43,15 +43,21 @@ export const createPlugin = <
43
43
  // const layerSVGElementsRef: Record<string, SVGElement> = {}
44
44
  // const layerCanvasElementsRef: Record<string, HTMLCanvasElement> = {}
45
45
 
46
+ // 每個 plugin 實例建立「自己的」layer 實體。
47
+ // Layer 內部狀態(enableProps$、setup 訂閱等)一次只能服務一個 plugin 實例,
48
+ // 若跨實例共用(例如 module 層級的單例),同頁多個 plugin 會互搶 layer,
49
+ // 造成部分圖表的 layer 不繪製或被銷毀。
50
+ const layers = config.layers.map((Layer) => new Layer())
51
+
46
52
  // 全部的layers
47
53
  const allLayerInstances = {
48
54
  // 將陣列轉成字典
49
- ...config.layers.reduce((acc, layer) => {
55
+ ...layers.reduce((acc, layer) => {
50
56
  acc[layer._name as keyof AllLayerParams] = layer
51
57
  return acc
52
- }, {} as Record<keyof AllLayerParams, typeof config.layers[number]>)
58
+ }, {} as Record<keyof AllLayerParams, typeof layers[number]>)
53
59
  }
54
- const getAllLayerNamesSet = () => new Set(config.layers.map(l => l._name as keyof AllLayerParams))
60
+ const getAllLayerNamesSet = () => new Set(layers.map(l => l._name as keyof AllLayerParams))
55
61
  // const getParamsKeySet = (params: DeepPartial<PluginParams | AllLayerParams>): Set<keyof AllLayerParams> => {
56
62
  // // 取得有設定 params 的 layer name
57
63
  // if (params) {
@@ -72,7 +78,7 @@ export const createPlugin = <
72
78
  }
73
79
 
74
80
  // config 設定顯示的 layers
75
- const systemInitLayerNames = config.layers.reduce((prev, current) => {
81
+ const systemInitLayerNames = layers.reduce((prev, current) => {
76
82
  if (current._initShow) {
77
83
  prev.push(current._name as keyof AllLayerParams)
78
84
  }
@@ -107,7 +113,7 @@ export const createPlugin = <
107
113
  const shownLayerNamesSeq: string[] = Array.from(ShownLayerNameSet)
108
114
  .map(name => [
109
115
  name,
110
- config.layers.find(l => l._name === name)?._layerIndex ?? -1
116
+ layers.find(l => l._name === name)?._layerIndex ?? -1
111
117
  ])
112
118
  .filter(([, index]) => index !== -1)
113
119
  .sort((a, b) => (a[1] as number) - (b[1] as number))
@@ -138,6 +144,14 @@ export const createPlugin = <
138
144
  // })
139
145
  // )
140
146
 
147
+ // 目前生效的 plugin 本身 params(預設值 + 歷次 patch 累積合併)。
148
+ // deepOverwrite 會忽略 defaults 中不存在的 key,因此建構子參數內的
149
+ // layer keys(如 { Bar: {} })會被自然濾除,不會混入 plugin-level params。
150
+ let currentPluginParams: PluginParams = deepOverwrite(
151
+ (config.defaultParams ?? {}) as PluginParams,
152
+ (initPluginParams ?? {}) as DeepPartial<PluginParams>
153
+ )
154
+
141
155
  // update plugin params
142
156
  const patchPluginParams$ = new BehaviorSubject<DeepPartial<AllLayerParams | PluginParams> | undefined>(
143
157
  initPluginParams ?? {}
@@ -171,9 +185,8 @@ export const createPlugin = <
171
185
  console.error(createOrbChartsErrorMessage(e))
172
186
  }
173
187
 
174
- const newParams = deepOverwrite(config.defaultParams, patch as DeepPartial<PluginParams> ?? {})
175
- // console.log('newParams', newParams)
176
- subscriber.next(newParams)
188
+ // currentPluginParams 已於 updateParams 中累積合併(歷次 patch 不互相覆蓋)
189
+ subscriber.next(currentPluginParams)
177
190
  })
178
191
 
179
192
  // -- force replace --
@@ -279,7 +292,7 @@ export const createPlugin = <
279
292
  // }
280
293
 
281
294
  // init layers
282
- config.layers.forEach((layer) => {
295
+ layers.forEach((layer) => {
283
296
  if (ShownLayerNameSet.has(layer._name as keyof AllLayerParams)) {
284
297
  const layerEnableProps: LayerEnableProps<'svg' | 'canvas', ExtendContext, PluginParams, unknown> =
285
298
  elementType === 'svg' ?
@@ -397,7 +410,8 @@ export const createPlugin = <
397
410
  // params = { ...params, ...partial }
398
411
  // },
399
412
  updateParams: (patch: DeepPartial<PluginParams | AllLayerParams>) => {
400
- // plugin params
413
+ // plugin params(累積合併至目前值,使連續多次 updateParams 不互相覆蓋)
414
+ currentPluginParams = deepOverwrite(currentPluginParams, patch as DeepPartial<PluginParams>)
401
415
  patchPluginParams$.next(patch)
402
416
  // layer params
403
417
  Object.keys(patch).forEach((key) => {
@@ -411,6 +425,7 @@ export const createPlugin = <
411
425
  },
412
426
  forceReplaceParams: (full: PluginParams | AllLayerParams) => {
413
427
  // plugin params
428
+ currentPluginParams = full as PluginParams
414
429
  forceReplacePluginParams$.next(full)
415
430
  // layer params
416
431
  Object.keys(full).forEach((key) => {
@@ -422,10 +437,12 @@ export const createPlugin = <
422
437
  // InitLayerNameSet$.next(getParamsKeySet(full))
423
438
  },
424
439
  getParams: () => {
425
- return config.layers.reduce((acc, layer) => {
426
- acc[layer._name] = layer._getParams()
427
- return acc
428
- }, {} as Record<string, any>) as PluginParams | AllLayerParams
440
+ // plugin 本身的 params 在前、各 layer params 在後
441
+ const result: Record<string, any> = Object.assign({}, currentPluginParams)
442
+ layers.forEach((layer) => {
443
+ result[layer._name] = layer._getParams()
444
+ })
445
+ return result as PluginParams | AllLayerParams
429
446
  },
430
447
  // layer: <LayerName extends keyof PluginParams>(name: LayerName) => ({
431
448
  // // set: (partial: DeepPartial<PluginParams[LayerName]>) => {
@@ -458,7 +475,8 @@ export const createPlugin = <
458
475
  // IsShowLayerNameSet$.complete()
459
476
  ShownLayerNameSet$.complete()
460
477
 
461
- config.layers.forEach((layer) => {
478
+ // layers 為本實例專屬,destroy 不影響其他 plugin 實例
479
+ layers.forEach((layer) => {
462
480
  layer._destroy()
463
481
  })
464
482
  },
@@ -49,7 +49,10 @@ export interface DefinePluginConfig<ExtendContext extends ExtendableContext, Plu
49
49
  defaultParams?: PluginParams
50
50
  validator?: (params: DeepPartial<AllLayerParams | PluginParams>) => ValidatorResult
51
51
  // { valid: boolean; errors?: string[] }
52
- layers?: LayerEntity<ExtendContext, PluginParams, AllLayerParams[keyof AllLayerParams]>[]
52
+ // Layer 建構子陣列——由 createPlugin 在「每個 plugin 實例」建立時各自實例化。
53
+ // (Layer 內部狀態(enableProps$ 等)不可跨 plugin 實例共用,否則同頁多個
54
+ // plugin 實例會互搶 layer,造成部分圖表不繪製)
55
+ layers?: (new () => LayerEntity<ExtendContext, PluginParams, AllLayerParams[keyof AllLayerParams]>)[]
53
56
  // extendContext?: (context: Readonly<ChartContext>) => ExtendContext
54
57
  setup?: (props: PluginSetupProps<ExtendContext, PluginParams>) => () => void
55
58
  }
@@ -57,6 +57,16 @@ function getInvalidProperty<T> (data: T, rules: Partial<ValidatorRule<T>>) {
57
57
  if (rules[columnName as keyof T]) {
58
58
  const rule: ValidatorRuleToBeTypes | ValidatorRuleToBe | ValidatorRuleToBeOption = rules[columnName as keyof T]
59
59
  const value = data[columnName as keyof T]
60
+ // 明確傳入 undefined 視同「未提供該欄位」,不做驗證。
61
+ // 常見於呼叫端用 spread/條件式建構 options(例如
62
+ // `{ ...base, encoding: hasEncoding ? {...} : undefined }`),
63
+ // Object.keys() 仍會列出該屬性名稱,若不特別排除,這裡會誤判成
64
+ // "型別錯誤" 而不是 "沒有提供"(目前程式碼裡沒有任何規則真的需要
65
+ // 用 toBeTypes: ['undefined'] 去要求欄位必須是 undefined,所以一律
66
+ // 跳過是安全的)。
67
+ if (value === undefined) {
68
+ return false
69
+ }
60
70
  // 測試 "toBeTypes"
61
71
  if ((rule as ValidatorRuleToBeTypes).toBeTypes) {
62
72
  const toBeTypes = (rule as ValidatorRuleToBeTypes).toBeTypes