@d3plus/dom 3.0.16 → 3.1.0
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.
- package/LICENSE +21 -0
- package/README.md +252 -77
- package/es/index.js +1 -1
- package/es/src/D3Selection.js +4 -0
- package/es/src/assign.js +6 -8
- package/es/src/attrize.js +3 -4
- package/es/src/backgroundColor.js +14 -0
- package/es/src/date.js +4 -6
- package/es/src/elem.js +11 -18
- package/es/src/fontExists.js +5 -6
- package/es/src/getSize.js +20 -15
- package/es/src/inViewport.js +5 -7
- package/es/src/isObject.js +6 -6
- package/es/src/parseSides.js +3 -4
- package/es/src/rtl.js +3 -5
- package/es/src/stylize.js +3 -4
- package/es/src/textWidth.js +32 -27
- package/package.json +18 -9
- package/types/index.d.ts +14 -0
- package/types/src/D3Selection.d.ts +28 -0
- package/types/src/assign.d.ts +11 -0
- package/types/src/attrize.d.ts +7 -0
- package/types/src/backgroundColor.d.ts +7 -0
- package/types/src/date.d.ts +5 -0
- package/types/src/elem.d.ts +18 -0
- package/types/src/fontExists.d.ts +6 -0
- package/types/src/getSize.d.ts +5 -0
- package/types/src/inViewport.d.ts +6 -0
- package/types/src/isObject.d.ts +5 -0
- package/types/src/parseSides.d.ts +11 -0
- package/types/src/prefix.d.ts +5 -0
- package/types/src/rtl.d.ts +4 -0
- package/types/src/stylize.d.ts +7 -0
- package/types/src/textWidth.d.ts +7 -0
- package/umd/d3plus-dom.full.js +2321 -219
- package/umd/d3plus-dom.full.js.map +1 -1
- package/umd/d3plus-dom.full.min.js +185 -133
- package/umd/d3plus-dom.js +107 -217
- package/umd/d3plus-dom.js.map +1 -1
- package/umd/d3plus-dom.min.js +75 -75
- package/es/src/prefix.js +0 -10
|
@@ -4,216 +4,268 @@
|
|
|
4
4
|
Copyright (c) 2026 D3plus - https://d3plus.org
|
|
5
5
|
@license MIT
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define("@d3plus/dom",["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).d3plus={})}(this,function(t){
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
@
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
Detects if a variable is a javascript Object.
|
|
10
|
+
@param item The value to test.
|
|
11
|
+
*/
|
|
12
|
+
function n(t){return!(!t||"object"!=typeof t||"undefined"!=typeof window&&(t===window||t===window.document||t instanceof Element)||Array.isArray(t))}
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
@
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
Determines if the object passed is the document or window.
|
|
15
|
+
@param obj @private
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
Applies each key/value in an object as an attr.
|
|
19
|
+
@param e The d3 selection to apply attributes to.
|
|
20
|
+
@param a An object of key/value attr pairs.
|
|
18
21
|
*/
|
|
22
|
+
function e(t,n={}){for(const e in n)({}).hasOwnProperty.call(n,e)&&t.attr(e,n[e])}
|
|
19
23
|
/**
|
|
20
|
-
|
|
21
|
-
@
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/function u(t,e={}){for(var n in e)!{}.hasOwnProperty.call(e,n)||t.attr(n,e[n])}
|
|
25
|
-
/**
|
|
26
|
-
@function date
|
|
27
|
-
@summary Parses numbers and strings to valid Javascript Date objects.
|
|
28
|
-
@description Returns a javascript Date object for a given a Number (representing either a 4-digit year or milliseconds since epoch), a String representing a Quarter (ie. "Q2 1987", mapping to the last day in that quarter), or a String that is in [valid dateString format](http://dygraphs.com/date-formats.html). Besides the 4-digit year parsing, this function is useful when needing to parse negative (BC) years, which the vanilla Date object cannot parse.
|
|
29
|
-
@param {Number|String} *date*
|
|
30
|
-
*/var j="http://www.w3.org/1999/xhtml",z={svg:"http://www.w3.org/2000/svg",xhtml:j,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function i(t){var e=t+="",n=e.indexOf(":");return 0<=n&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),z.hasOwnProperty(e)?{space:z[e],local:t}:t;// eslint-disable-line no-prototype-builtins
|
|
31
|
-
}function F(t){t=i(t);return(t.local?function(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}:function(n){return function(){var t=this.ownerDocument,e=this.namespaceURI;return e===j&&t.documentElement.namespaceURI===j?t.createElement(n):t.createElementNS(e,n)}})(t)}function R(){}function H(t){return null==t?R:function(){return this.querySelector(t)}}function L(){return[]}function X(t){return null==t?L:function(){return this.querySelectorAll(t)}}function Y(e){return function(){return null==(t=e.apply(this,arguments))?[]:Array.isArray(t)?t:Array.from(t);
|
|
24
|
+
Parses numbers and strings into valid JavaScript Date objects, supporting years, quarters, months, and ISO 8601 formats.
|
|
25
|
+
@param d The date value to parse (number, string, or Date).
|
|
26
|
+
*/var r="http://www.w3.org/1999/xhtml",i={svg:"http://www.w3.org/2000/svg",xhtml:r,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function o(t){var n=t+="",e=n.indexOf(":");return e>=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),i.hasOwnProperty(n)?{space:i[n],local:t}:t;// eslint-disable-line no-prototype-builtins
|
|
27
|
+
}function s(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===r&&n.documentElement.namespaceURI===r?n.createElement(t):n.createElementNS(e,t)}}function u(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function a(t){var n=o(t);return(n.local?u:s)(n)}function l(){}function c(t){return null==t?l:function(){return this.querySelector(t)}}function f(){return[]}function h(t){return null==t?f:function(){return this.querySelectorAll(t)}}function d(t){return function(){return null==(n=t.apply(this,arguments))?[]:Array.isArray(n)?n:Array.from(n);
|
|
32
28
|
// Given something array like (or null), returns something that is strictly an
|
|
33
29
|
// array. This is used to ensure that array-like objects passed to d3.selectAll
|
|
34
30
|
// or selection.selectAll are converted into proper arrays when creating a
|
|
35
31
|
// selection; we don’t ever want to create a selection backed by a live
|
|
36
32
|
// HTMLCollection or NodeList. However, note that selection.selectAll will use a
|
|
37
33
|
// static NodeList as a group, since it safely derived from querySelectorAll.
|
|
38
|
-
var
|
|
34
|
+
var n}}function p(t){return function(){return this.matches(t)}}function g(t){return function(n){return n.matches(t)}}var m=Array.prototype.find;function y(){return this.firstElementChild}var L=Array.prototype.filter;function w(){return Array.from(this.children)}function v(t){return new Array(t.length)}function A(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function x(t,n,e,r,i,o){
|
|
39
35
|
// Put any non-null nodes that fit into update.
|
|
40
36
|
// Put any null nodes into enter.
|
|
41
37
|
// Put any remaining data into enter.
|
|
42
|
-
for(var
|
|
38
|
+
for(var s,u=0,a=n.length,l=o.length;u<l;++u)(s=n[u])?(s.__data__=o[u],r[u]=s):e[u]=new A(t,o[u]);
|
|
43
39
|
// Put any non-null nodes that don’t fit into exit.
|
|
44
|
-
for(;u<
|
|
40
|
+
for(;u<a;++u)(s=n[u])&&(i[u]=s)}function _(t,n,e,r,i,o,s){var u,a,l,c=new Map,f=n.length,h=o.length,d=new Array(f);
|
|
45
41
|
// Compute the key for each node.
|
|
46
42
|
// If multiple nodes have the same key, the duplicates are added to exit.
|
|
47
|
-
for(
|
|
43
|
+
for(u=0;u<f;++u)(a=n[u])&&(d[u]=l=s.call(a,a.__data__,u,n)+"",c.has(l)?i[u]=a:c.set(l,a));
|
|
48
44
|
// Compute the key for each datum.
|
|
49
45
|
// If there a node associated with this key, join and add it to update.
|
|
50
46
|
// If there is not (or the key is a duplicate), add it to enter.
|
|
51
|
-
for(
|
|
47
|
+
for(u=0;u<h;++u)l=s.call(t,o[u],u,o)+"",(a=c.get(l))?(r[u]=a,a.__data__=o[u],c.delete(l)):e[u]=new A(t,o[u]);
|
|
52
48
|
// Add any remaining nodes that were not bound to data to exit.
|
|
53
|
-
for(
|
|
54
|
-
}function M(t,e){return t.style.getPropertyValue(e)||et(t).getComputedStyle(t,null).getPropertyValue(e)}function nt(t){return t.trim().split(/^|\s+/)}function rt(t){return t.classList||new it(t)}function it(t){this._node=t,this._names=nt(t.getAttribute("class")||"")}function ot(t,e){for(var n=rt(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function at(t,e){for(var n=rt(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function ut(){this.textContent=""}function st(){this.innerHTML=""}function lt(){this.nextSibling&&this.parentNode.appendChild(this)}function ct(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ht(){return null}function ft(){var t=this.parentNode;t&&t.removeChild(this)}function pt(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function dt(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function yt(o){return function(){var t=this.__on;if(t){for(var e,n=0,r=-1,i=t.length;n<i;++n)e=t[n],o.type&&e.type!==o.type||e.name!==o.name?t[++r]=e:this.removeEventListener(e.type,e.listener,e.options);++r?t.length=r:delete this.__on}}}function gt(a,u,s){return function(){function t(t){n.call(this,t,this.__data__)}var e,n,r=this.__on;n=u;if(r)for(var i=0,o=r.length;i<o;++i)if((e=r[i]).type===a.type&&e.name===a.name)return this.removeEventListener(e.type,e.listener,e.options),this.addEventListener(e.type,e.listener=t,e.options=s),void(e.value=u);this.addEventListener(a.type,t,s),e={type:a.type,name:a.name,value:u,listener:t,options:s},r?r.push(e):this.__on=[e]}}function mt(t,e,n){var r=et(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}d.prototype={constructor:d,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},it.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){t=this._names.indexOf(t);0<=t&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return 0<=this._names.indexOf(t)}};var wt=[null];function x(t,e){this._groups=t,this._parents=e}function e(){return new x([[document.documentElement]],wt)}function s(t){return"string"==typeof t?new x([[document.querySelector(t)]],[document.documentElement]):new x([[t]],wt)}x.prototype=e.prototype={constructor:x,select:function(t){"function"!=typeof t&&(t=H(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,a,u=e[i],s=u.length,l=r[i]=new Array(s),c=0;c<s;++c)(o=u[c])&&(a=t.call(o,o.__data__,c,u))&&("__data__"in o&&(a.__data__=o.__data__),l[c]=a);return new x(r,this._parents)},selectAll:function(t){t=("function"==typeof t?Y:X)(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o)for(var a,u=e[o],s=u.length,l=0;l<s;++l)(a=u[l])&&(r.push(t.call(a,a.__data__,l,u)),i.push(a));return new x(r,i)},selectChild:function(t){return this.select(null==t?G:(e="function"==typeof t?t:I(t),function(){return B.call(this.children,e)}));var e},selectChildren:function(t){return this.selectAll(null==t?Q:(e="function"==typeof t?t:I(t),function(){return U.call(this.children,e)}));var e},filter:function(t){"function"!=typeof t&&(t=V(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,a=e[i],u=a.length,s=r[i]=[],l=0;l<u;++l)(o=a[l])&&t.call(o,o.__data__,l,a)&&s.push(o);return new x(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,J);var n,r=e?Z:K,i=this._parents,o=this._groups;"function"!=typeof t&&(n=t,t=function(){return n});for(var a=o.length,u=new Array(a),s=new Array(a),l=new Array(a),c=0;c<a;++c){var h=i[c],f=o[c],p=f.length,d="object"==typeof(d=t.call(h,h&&h.__data__,c,i))&&"length"in d?d:Array.from(d),y=d.length,g=s[c]=new Array(y),m=u[c]=new Array(y);r(h,f,g,m,l[c]=new Array(p),d,e);
|
|
55
|
-
// Now connect the enter nodes to their following update node, such that
|
|
56
|
-
// appendChild can insert the materialized enter node before this node,
|
|
57
|
-
// rather than at the end of the parent node.
|
|
58
|
-
for(var w,v,_=0,b=0;_<y;++_)if(w=g[_]){for(b<=_&&(b=_+1);!(v=m[b])&&++b<y;);w._next=v||null}}return(u=new x(u,i))._enter=s,u._exit=l,u}
|
|
49
|
+
for(u=0;u<f;++u)(a=n[u])&&c.get(d[u])===a&&(i[u]=a)}function N(t){return t.__data__}
|
|
59
50
|
// Given some data, this returns an array-like view of it: an object that
|
|
60
51
|
// exposes a length property and allows numeric indexing. Note that unlike
|
|
61
52
|
// selectAll, this isn’t worried about “live” collections because the resulting
|
|
62
53
|
// array will only be used briefly while data is being bound. (It is possible to
|
|
63
54
|
// cause the data to change while iterating by using a key function, but please
|
|
64
55
|
// don’t; we’d rather avoid a gratuitous copy.)
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
function b(t){return"object"==typeof t&&"length"in t?t:Array.from(t);// Map, Set, iterable, string, or anything else
|
|
57
|
+
}function k(t,n){return t<n?-1:t>n?1:t>=n?0:NaN}function S(t){return function(){this.removeAttribute(t)}}function E(t){return function(){this.removeAttributeNS(t.space,t.local)}}function O(t,n){return function(){this.setAttribute(t,n)}}function M(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function B(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function C(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function W(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView;// node is a Document
|
|
58
|
+
}function $(t){return function(){this.style.removeProperty(t)}}function I(t,n,e){return function(){this.style.setProperty(t,n,e)}}function P(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function F(t,n){return t.style.getPropertyValue(n)||W(t).getComputedStyle(t,null).getPropertyValue(n)}function R(t){return function(){delete this[t]}}function T(t,n){return function(){this[t]=n}}function z(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function j(t){return t.trim().split(/^|\s+/)}function H(t){return t.classList||new q(t)}function q(t){this._node=t,this._names=j(t.getAttribute("class")||"")}function D(t,n){for(var e=H(t),r=-1,i=n.length;++r<i;)e.add(n[r])}function X(t,n){for(var e=H(t),r=-1,i=n.length;++r<i;)e.remove(n[r])}function Y(t){return function(){D(this,t)}}function G(t){return function(){X(this,t)}}function V(t,n){return function(){(n.apply(this,arguments)?D:X)(this,t)}}function Q(){this.textContent=""}function K(t){return function(){this.textContent=t}}function J(t){return function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}}function U(){this.innerHTML=""}function Z(t){return function(){this.innerHTML=t}}function tt(t){return function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}}function nt(){this.nextSibling&&this.parentNode.appendChild(this)}function et(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function rt(){return null}function it(){var t=this.parentNode;t&&t.removeChild(this)}function ot(){var t=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}function st(){var t=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}function ut(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;r<o;++r)e=n[r],t.type&&e.type!==t.type||e.name!==t.name?n[++i]=e:this.removeEventListener(e.type,e.listener,e.options);++i?n.length=i:delete this.__on}}}function at(t,n,e){return function(){var r,i=this.__on,o=function(t){return function(n){t.call(this,n,this.__data__)}}(n);if(i)for(var s=0,u=i.length;s<u;++s)if((r=i[s]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=e),void(r.value=n);this.addEventListener(t.type,o,e),r={type:t.type,name:t.name,value:n,listener:o,options:e},i?i.push(r):this.__on=[r]}}function lt(t,n,e){var r=W(t),i=r.CustomEvent;"function"==typeof i?i=new i(n,e):(i=r.document.createEvent("Event"),e?(i.initEvent(n,e.bubbles,e.cancelable),i.detail=e.detail):i.initEvent(n,!1,!1)),t.dispatchEvent(i)}function ct(t,n){return function(){return lt(this,t,n)}}function ft(t,n){return function(){return lt(this,t,n.apply(this,arguments))}}A.prototype={constructor:A,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},q.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ht=[null];function dt(t,n){this._groups=t,this._parents=n}function pt(){return new dt([[document.documentElement]],ht)}function gt(t){return"string"==typeof t?new dt([[document.querySelector(t)]],[document.documentElement]):new dt([[t]],ht)}dt.prototype=pt.prototype={constructor:dt,select:function(t){"function"!=typeof t&&(t=c(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,s,u=n[i],a=u.length,l=r[i]=new Array(a),f=0;f<a;++f)(o=u[f])&&(s=t.call(o,o.__data__,f,u))&&("__data__"in o&&(s.__data__=o.__data__),l[f]=s);return new dt(r,this._parents)},selectAll:function(t){t="function"==typeof t?d(t):h(t);for(var n=this._groups,e=n.length,r=[],i=[],o=0;o<e;++o)for(var s,u=n[o],a=u.length,l=0;l<a;++l)(s=u[l])&&(r.push(t.call(s,s.__data__,l,u)),i.push(s));return new dt(r,i)},selectChild:function(t){return this.select(null==t?y:function(t){return function(){return m.call(this.children,t)}}("function"==typeof t?t:g(t)))},selectChildren:function(t){return this.selectAll(null==t?w:function(t){return function(){return L.call(this.children,t)}}("function"==typeof t?t:g(t)))},filter:function(t){"function"!=typeof t&&(t=p(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,s=n[i],u=s.length,a=r[i]=[],l=0;l<u;++l)(o=s[l])&&t.call(o,o.__data__,l,s)&&a.push(o);return new dt(r,this._parents)},data:function(t,n){if(!arguments.length)return Array.from(this,N);var e,r=n?_:x,i=this._parents,o=this._groups;"function"!=typeof t&&(e=t,t=function(){return e});for(var s=o.length,u=new Array(s),a=new Array(s),l=new Array(s),c=0;c<s;++c){var f=i[c],h=o[c],d=h.length,p=b(t.call(f,f&&f.__data__,c,i)),g=p.length,m=a[c]=new Array(g),y=u[c]=new Array(g);r(f,h,m,y,l[c]=new Array(d),p,n);
|
|
59
|
+
// Now connect the enter nodes to their following update node, such that
|
|
60
|
+
// appendChild can insert the materialized enter node before this node,
|
|
61
|
+
// rather than at the end of the parent node.
|
|
62
|
+
for(var L,w,v=0,A=0;v<g;++v)if(L=m[v]){for(v>=A&&(A=v+1);!(w=y[A])&&++A<g;);L._next=w||null}}return(u=new dt(u,i))._enter=a,u._exit=l,u},enter:function(){return new dt(this._enter||this._groups.map(v),this._parents)},exit:function(){return new dt(this._exit||this._groups.map(v),this._parents)},join:function(t,n,e){var r=this.enter(),i=this,o=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=n&&(i=n(i))&&(i=i.selection()),null==e?o.remove():e(o),r&&i?r.merge(i).order():i},merge:function(t){for(var n=t.selection?t.selection():t,e=this._groups,r=n._groups,i=e.length,o=r.length,s=Math.min(i,o),u=new Array(i),a=0;a<s;++a)for(var l,c=e[a],f=r[a],h=c.length,d=u[a]=new Array(h),p=0;p<h;++p)(l=c[p]||f[p])&&(d[p]=l);for(;a<i;++a)u[a]=e[a];return new dt(u,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,n=-1,e=t.length;++n<e;)for(var r,i=t[n],o=i.length-1,s=i[o];--o>=0;)(r=i[o])&&(s&&4^r.compareDocumentPosition(s)&&s.parentNode.insertBefore(r,s),s=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=k);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o<r;++o){for(var s,u=e[o],a=u.length,l=i[o]=new Array(a),c=0;c<a;++c)(s=u[c])&&(l[c]=s);l.sort(n)}return new dt(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,n=0,e=t.length;n<e;++n)for(var r=t[n],i=0,o=r.length;i<o;++i){var s=r[i];if(s)return s}return null},size:function(){let t=0;for(const n of this)++t;// eslint-disable-line no-unused-vars
|
|
63
|
+
return t},empty:function(){return!this.node()},each:function(t){for(var n=this._groups,e=0,r=n.length;e<r;++e)for(var i,o=n[e],s=0,u=o.length;s<u;++s)(i=o[s])&&t.call(i,i.__data__,s,o);return this},attr:function(t,n){var e=o(t);if(arguments.length<2){var r=this.node();return e.local?r.getAttributeNS(e.space,e.local):r.getAttribute(e)}return this.each((null==n?e.local?E:S:"function"==typeof n?e.local?C:B:e.local?M:O)(e,n))},style:function(t,n,e){return arguments.length>1?this.each((null==n?$:"function"==typeof n?P:I)(t,n,null==e?"":e)):F(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?R:"function"==typeof n?z:T)(t,n)):this.node()[t]},classed:function(t,n){var e=j(t+"");if(arguments.length<2){for(var r=H(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each(("function"==typeof n?V:n?Y:G)(e,n))},text:function(t){return arguments.length?this.each(null==t?Q:("function"==typeof t?J:K)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?U:("function"==typeof t?tt:Z)(t)):this.node().innerHTML},raise:function(){return this.each(nt)},lower:function(){return this.each(et)},append:function(t){var n="function"==typeof t?t:a(t);return this.select(function(){return this.appendChild(n.apply(this,arguments))})},insert:function(t,n){var e="function"==typeof t?t:a(t),r=null==n?rt:"function"==typeof n?n:c(n);return this.select(function(){return this.insertBefore(e.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(it)},clone:function(t){return this.select(t?st:ot)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,n,e){var r,i,o=function(t){return t.trim().split(/^|\s+/).map(function(t){var n="",e=t.indexOf(".");return e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}(t+""),s=o.length;if(!(arguments.length<2)){for(u=n?at:ut,r=0;r<s;++r)this.each(u(o[r],n,e));return this}var u=this.node().__on;if(u)for(var a,l=0,c=u.length;l<c;++l)for(r=0,a=u[l];r<s;++r)if((i=o[r]).type===a.type&&i.name===a.name)return a.value},dispatch:function(t,n){return this.each(("function"==typeof n?ft:ct)(t,n))},[Symbol.iterator]:function*(){for(var t=this._groups,n=0,e=t.length;n<e;++n)for(var r,i=t[n],o=0,s=i.length;o<s;++o)(r=i[o])&&(yield r)}};var mt={value:()=>{}};function yt(){for(var t,n=0,e=arguments.length,r={};n<e;++n){if(!(t=arguments[n]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new Lt(r)}function Lt(t){this._=t}function wt(t,n){for(var e,r=0,i=t.length;r<i;++r)if((e=t[r]).name===n)return e.value}function vt(t,n,e){for(var r=0,i=t.length;r<i;++r)if(t[r].name===n){t[r]=mt,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=e&&t.push({name:n,value:e}),t}Lt.prototype=yt.prototype={constructor:Lt,on:function(t,n){var e,r,i=this._,o=(r=i,(t+"").trim().split(/^|\s+/).map(function(t){var n="",e=t.indexOf(".");if(e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})),s=-1,u=o.length;
|
|
67
64
|
// If no callback was specified, return the callback of the given type and name.
|
|
68
65
|
if(!(arguments.length<2)){
|
|
69
66
|
// If a type was specified, set the callback for the given type and name.
|
|
70
67
|
// Otherwise, if a null callback was specified, remove callbacks of the given name.
|
|
71
|
-
if(null!=
|
|
72
|
-
++
|
|
73
|
-
var t,
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++s<u;)if(e=(t=o[s]).type)i[e]=vt(i[e],t.name,n);else if(null==n)for(e in i)i[e]=vt(i[e],t.name,null);return this}for(;++s<u;)if((e=(t=o[s]).type)&&(e=wt(i[e],t.name)))return e},copy:function(){var t={},n=this._;for(var e in n)t[e]=n[e].slice();return new Lt(t)},call:function(t,n){if((e=arguments.length-2)>0)for(var e,r,i=new Array(e),o=0;o<e;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,e=(r=this._[t]).length;o<e;++o)r[o].value.apply(n,i)},apply:function(t,n,e){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(n,e)}};var At,xt,_t=0,Nt=0,bt=0,kt=0,St=0,Et=0,Ot="object"==typeof performance&&performance.now?performance:Date,Mt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Bt(){return St||(Mt(Ct),St=Ot.now()+Et)}function Ct(){St=0}function Wt(){this._call=this._time=this._next=null}function $t(t,n,e){var r=new Wt;return r.restart(t,n,e),r}function It(){St=(kt=Ot.now())+Et,_t=Nt=0;try{!function(){Bt(),// Get the current time, if not already set.
|
|
69
|
+
++_t;for(// Pretend we’ve set an alarm, if we haven’t already.
|
|
70
|
+
var t,n=At;n;)(t=St-n._time)>=0&&n._call.call(void 0,t),n=n._next;--_t}()}finally{_t=0,function(){var t,n,e=At,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:At=n);xt=t,Ft(r)}(),St=0}}function Pt(){var t=Ot.now(),n=t-kt;n>1e3&&(Et-=n,kt=t)}function Ft(t){_t||(// Soonest alarm already set, or will be.
|
|
71
|
+
Nt&&(Nt=clearTimeout(Nt)),// Strictly less than if we recomputed clockNow.
|
|
72
|
+
t-St>24?(t<1/0&&(Nt=setTimeout(It,t-Ot.now()-Et)),bt&&(bt=clearInterval(bt))):(bt||(kt=Ot.now(),bt=setInterval(Pt,1e3)),_t=1,Mt(It)))}function Rt(t,n,e){var r=new Wt;return n=null==n?0:+n,r.restart(e=>{r.stop(),t(e+n)},n,e),r}Wt.prototype=$t.prototype={constructor:Wt,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?Bt():+e)+(null==n?0:+n),this._next||xt===this||(xt?xt._next=this:At=this,xt=this),this._call=t,this._time=e,Ft()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ft())}};var Tt=yt("start","end","cancel","interrupt"),zt=[];function jt(t,n,e,r,i,o){var s=t.__transition;if(s){if(e in s)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;
|
|
73
|
+
// Initialize the self timer when the transition is created.
|
|
74
|
+
// Note the actual delay is not known until the first callback!
|
|
75
|
+
function o(t){e.state=1,e.timer.restart(s,e.delay,e.time),
|
|
76
|
+
// If the elapsed delay is less than our first sleep, start immediately.
|
|
77
|
+
e.delay<=t&&s(t-e.delay)}function s(o){var l,c,f,h;
|
|
76
78
|
// If the state is not SCHEDULED, then we previously errored on start.
|
|
77
|
-
if(
|
|
79
|
+
if(1!==e.state)return a();for(l in i)if((h=i[l]).name===e.name){
|
|
78
80
|
// While this element already has a starting transition during this frame,
|
|
79
81
|
// defer starting an interrupting transition until that transition has a
|
|
80
82
|
// chance to tick (and possibly end); see d3/d3-transition#54!
|
|
81
|
-
if(
|
|
83
|
+
if(3===h.state)return Rt(s);
|
|
82
84
|
// Interrupt the active transition, if any.
|
|
83
|
-
|
|
85
|
+
4===h.state?(h.state=6,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[l]):+l<n&&(h.state=6,h.timer.stop(),h.on.call("cancel",t,t.__data__,h.index,h.group),delete i[l])}
|
|
84
86
|
// Defer the first tick to end of the current frame; see d3/d3#1576.
|
|
85
87
|
// Note the transition may be canceled after start and before the first tick!
|
|
86
88
|
// Note this must be scheduled before the start event; see d3/d3-transition#16!
|
|
87
89
|
// Assuming this is successful, subsequent callbacks go straight to tick.
|
|
88
|
-
if(
|
|
90
|
+
if(Rt(function(){3===e.state&&(e.state=4,e.timer.restart(u,e.delay,e.time),u(o))}),
|
|
89
91
|
// Dispatch the start event.
|
|
90
92
|
// Note this must be done before the tween are initialized.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
e.state=2,e.on.call("start",t,t.__data__,e.index,e.group),2===e.state){for(// interrupted
|
|
94
|
+
e.state=3,
|
|
93
95
|
// Initialize the tween, deleting null tween.
|
|
94
|
-
|
|
96
|
+
r=new Array(f=e.tween.length),l=0,c=-1;l<f;++l)(h=e.tween[l].value.call(t,t.__data__,e.index,e.group))&&(r[++c]=h);r.length=c+1}}function u(n){for(var i=n<e.duration?e.ease.call(null,n/e.duration):(e.timer.restart(a),e.state=5,1),o=-1,s=r.length;++o<s;)r[o].call(t,i);
|
|
95
97
|
// Dispatch the end event.
|
|
96
|
-
|
|
97
|
-
delete
|
|
98
|
-
|
|
99
|
-
// Note the actual delay is not known until the first callback!
|
|
100
|
-
(c=a.__transition)[u]=s).timer=kt(function(t){s.state=qt,s.timer.restart(f,s.delay,s.time),
|
|
101
|
-
// If the elapsed delay is less than our first sleep, start immediately.
|
|
102
|
-
s.delay<=t&&f(t-s.delay)},0,s.time)}function Lt(t,e){t=v(t,e);if(t.state>Dt)throw new Error("too late; already scheduled");return t}function O(t,e){t=v(t,e);if(t.state>jt)throw new Error("too late; already running");return t}function v(t,e){t=t.__transition;if(t=t&&t[e])return t;throw new Error("transition not found")}function Xt(t,e,n){(t.prototype=e.prototype=n).constructor=t}function Yt(t,e){var n,r=Object.create(t.prototype);for(n in e)r[n]=e[n];return r}function _(){}var r="\\s*([+-]?\\d+)\\s*",b="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",A="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Vt=/^#([0-9a-f]{3,8})$/,It=new RegExp(`^rgb\\(${r},${r},${r}\\)$`),Bt=new RegExp(`^rgb\\(${A},${A},${A}\\)$`),Gt=new RegExp(`^rgba\\(${r},${r},${r},${b}\\)$`),Ut=new RegExp(`^rgba\\(${A},${A},${A},${b}\\)$`),Qt=new RegExp(`^hsl\\(${b},${A},${A}\\)$`),Wt=new RegExp(`^hsla\\(${b},${A},${A},${b}\\)$`),Kt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Zt(){return this.rgb().formatHex()}function Jt(){return this.rgb().formatRgb()}function E(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Vt.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?te(e):3===n?new N(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?ee(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?ee(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=It.exec(t))?new N(e[1],e[2],e[3],1):(e=Bt.exec(t))?new N(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=Gt.exec(t))?ee(e[1],e[2],e[3],e[4]):(e=Ut.exec(t))?ee(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Qt.exec(t))?ae(e[1],e[2]/100,e[3]/100,1):(e=Wt.exec(t))?ae(e[1],e[2]/100,e[3]/100,e[4]):Kt.hasOwnProperty(t)?te(Kt[t]):"transparent"===t?new N(NaN,NaN,NaN,0):null}function te(t){return new N(t>>16&255,t>>8&255,255&t,1)}function ee(t,e,n,r){return new N(t=r<=0?e=n=NaN:t,e,n,r)}function ne(t,e,n,r){return 1===arguments.length?(i=(i=t)instanceof _?i:E(i))?new N((i=i.rgb()).r,i.g,i.b,i.opacity):new N:new N(t,e,n,null==r?1:r);var i}function N(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function re(){return"#"+S(this.r)+S(this.g)+S(this.b)}function ie(){var t=oe(this.opacity);return(1===t?"rgb(":"rgba(")+k(this.r)+`, ${k(this.g)}, `+k(this.b)+(1===t?")":`, ${t})`)}function oe(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function k(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function S(t){return((t=k(t))<16?"0":"")+t.toString(16)}function ae(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||1<=n?t=e=NaN:e<=0&&(t=NaN),new $(t,e,n,r)}function ue(t){var e,n,r,i,o,a,u,s;return t instanceof $?new $(t.h,t.s,t.l,t.opacity):(t=t instanceof _?t:E(t))?t instanceof $?t:(e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=NaN,s=((o=Math.max(e,n,r))+i)/2,(u=o-i)?(a=e===o?(n-r)/u+6*(n<r):n===o?(r-e)/u+2:(e-n)/u+4,u/=s<.5?o+i:2-o-i,a*=60):u=0<s&&s<1?0:a,new $(a,u,s,t.opacity)):new $}function $(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function se(t){return(t=(t||0)%360)<0?t+360:t}function le(t){return Math.max(0,Math.min(1,t||0))}
|
|
103
|
-
/* From FvD 13.37, CSS Color Module Level 3 */function ce(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Xt(_,E,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Zt,formatHex:Zt,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return ue(this).formatHsl()},formatRgb:Jt,toString:Jt}),Xt(N,ne,Yt(_,{brighter(t){return t=null==t?1/.7:Math.pow(1/.7,t),new N(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?.7:Math.pow(.7,t),new N(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new N(k(this.r),k(this.g),k(this.b),oe(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:re,formatHex:re,formatHex8:function(){return"#"+S(this.r)+S(this.g)+S(this.b)+S(255*(isNaN(this.opacity)?1:this.opacity))},formatRgb:ie,toString:ie})),Xt($,function(t,e,n,r){return 1===arguments.length?ue(t):new $(t,e,n,null==r?1:r)},Yt(_,{brighter(t){return t=null==t?1/.7:Math.pow(1/.7,t),new $(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?.7:Math.pow(.7,t),new $(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,e=n+(n<.5?n:1-n)*e,n=2*n-e;return new N(ce(240<=t?t-240:120+t,n,e),ce(t,n,e),ce(t<120?240+t:t-120,n,e),this.opacity)},clamp(){return new $(se(this.h),le(this.s),le(this.l),oe(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){var t=oe(this.opacity);return(1===t?"hsl(":"hsla(")+se(this.h)+`, ${100*le(this.s)}%, ${100*le(this.l)}%`+(1===t?")":`, ${t})`)}}));var he=t=>()=>t;function fe(o){return 1==(o=+o)?pe:function(t,e){return e-t?(n=t,r=e,i=o,n=Math.pow(n,i),r=Math.pow(r,i)-n,i=1/i,function(t){return Math.pow(n+t*r,i)}):he(isNaN(t)?e:t);var n,r,i}}function pe(t,e){var n,r,i=e-t;return i?(n=t,r=i,function(t){return n+t*r}):he(isNaN(t)?e:t)}var de=function t(e){var a=fe(e);function n(e,t){var n=a((e=ne(e)).r,(t=ne(t)).r),r=a(e.g,t.g),i=a(e.b,t.b),o=pe(e.opacity,t.opacity);return function(t){return e.r=n(t),e.g=r(t),e.b=i(t),e.opacity=o(t),e+""}}return n.gamma=t,n}(1);function C(e,n){return e=+e,n=+n,function(t){return e*(1-t)+n*t}}var ye=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ge=new RegExp(ye.source,"g");var me,we=180/Math.PI,ve={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function _e(t,e,n,r,i,o){var a,u,s;return(a=Math.sqrt(t*t+e*e))&&(t/=a,e/=a),(s=t*n+e*r)&&(n-=t*s,r-=e*s),(u=Math.sqrt(n*n+r*r))&&(n/=u,r/=u,s/=u),t*r<e*n&&(t=-t,e=-e,s=-s,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*we,skewX:Math.atan(s)*we,scaleX:a,scaleY:u}}function be(f,p,d,y){function g(t){return t.length?t.pop()+" ":""}return function(t,e){var n,r,i,o,a,u,s,l,c=[],h=[];// number interpolators
|
|
104
|
-
// gc
|
|
105
|
-
return t=f(t),e=f(e),r=t.translateX,i=t.translateY,s=e.translateX,a=e.translateY,u=c,o=h,r!==s||i!==a?(n=u.push("translate(",null,p,null,d),o.push({i:n-4,x:C(r,s)},{i:n-2,x:C(i,a)})):(s||a)&&u.push("translate("+s+p+a+d),o=t.rotate,r=c,n=h,o!==(i=e.rotate)?(180<o-i?i+=360:180<i-o&&(o+=360),// shortest path
|
|
106
|
-
n.push({i:r.push(g(r)+"rotate(",null,y)-2,x:C(o,i)})):i&&r.push(g(r)+"rotate("+i+y),u=t.skewX,s=c,a=h,u!==(o=e.skewX)?a.push({i:s.push(g(s)+"skewX(",null,y)-2,x:C(u,o)}):o&&s.push(g(s)+"skewX("+o+y),r=t.scaleX,i=t.scaleY,a=e.scaleY,u=c,s=h,r!==(o=e.scaleX)||i!==a?(l=u.push(g(u)+"scale(",null,",",null,")"),s.push({i:l-4,x:C(r,o)},{i:l-2,x:C(i,a)})):1===o&&1===a||u.push(g(u)+"scale("+o+","+a+")"),t=e=null,function(t){for(var e,n=-1,r=h.length;++n<r;)c[(e=h[n]).i]=e.x(t);return c.join("")}}}var xe=be(
|
|
107
|
-
/* eslint-disable no-undef */function(t){return(t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"")).isIdentity?ve:_e(t.a,t.b,t.c,t.d,t.e,t.f)},"px, ","px)","deg)"),Ae=be(function(t){return null!=t&&((me=me||document.createElementNS("http://www.w3.org/2000/svg","g")).setAttribute("transform",t),t=me.transform.baseVal.consolidate())?_e((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):ve},", ",")",")");function Ee(t,e,n){var r=t._id;return t.each(function(){var t=O(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return v(t,r).value[e]}}function Ne(t,e){var n;return("number"==typeof e?C:e instanceof E?de:(n=E(e))?(e=n,de):function(t,r){var e,n,i,o,a,u=ye.lastIndex=ge.lastIndex=0,s=-1,l=[],c=[];// number interpolators
|
|
98
|
+
5===e.state&&(e.on.call("end",t,t.__data__,e.index,e.group),a())}function a(){for(var r in e.state=6,e.timer.stop(),delete i[n],i)return;// eslint-disable-line no-unused-vars
|
|
99
|
+
delete t.__transition}i[n]=e,e.timer=$t(o,0,e.time)}(t,e,{name:n,index:r,group:i,on:Tt,tween:zt,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:0})}function Ht(t,n){var e=Dt(t,n);if(e.state>0)throw new Error("too late; already scheduled");return e}function qt(t,n){var e=Dt(t,n);if(e.state>3)throw new Error("too late; already running");return e}function Dt(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function Xt(t,n,e){t.prototype=n.prototype=e,e.constructor=t}function Yt(t,n){var e=Object.create(t.prototype);for(var r in n)e[r]=n[r];return e}function Gt(){}var Vt=.7,Qt=1/Vt,Kt="\\s*([+-]?\\d+)\\s*",Jt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ut="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Zt=/^#([0-9a-f]{3,8})$/,tn=new RegExp(`^rgb\\(${Kt},${Kt},${Kt}\\)$`),nn=new RegExp(`^rgb\\(${Ut},${Ut},${Ut}\\)$`),en=new RegExp(`^rgba\\(${Kt},${Kt},${Kt},${Jt}\\)$`),rn=new RegExp(`^rgba\\(${Ut},${Ut},${Ut},${Jt}\\)$`),on=new RegExp(`^hsl\\(${Jt},${Ut},${Ut}\\)$`),sn=new RegExp(`^hsla\\(${Jt},${Ut},${Ut},${Jt}\\)$`),un={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function an(){return this.rgb().formatHex()}function ln(){return this.rgb().formatRgb()}function cn(t){var n,e;return t=(t+"").trim().toLowerCase(),(n=Zt.exec(t))?(e=n[1].length,n=parseInt(n[1],16),6===e?fn(n):3===e?new pn(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?hn(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?hn(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=tn.exec(t))?new pn(n[1],n[2],n[3],1):(n=nn.exec(t))?new pn(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=en.exec(t))?hn(n[1],n[2],n[3],n[4]):(n=rn.exec(t))?hn(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=on.exec(t))?vn(n[1],n[2]/100,n[3]/100,1):(n=sn.exec(t))?vn(n[1],n[2]/100,n[3]/100,n[4]):un.hasOwnProperty(t)?fn(un[t]):"transparent"===t?new pn(NaN,NaN,NaN,0):null}function fn(t){return new pn(t>>16&255,t>>8&255,255&t,1)}function hn(t,n,e,r){return r<=0&&(t=n=e=NaN),new pn(t,n,e,r)}function dn(t,n,e,r){return 1===arguments.length?((i=t)instanceof Gt||(i=cn(i)),i?new pn((i=i.rgb()).r,i.g,i.b,i.opacity):new pn):new pn(t,n,e,null==r?1:r);var i}function pn(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function gn(){return`#${wn(this.r)}${wn(this.g)}${wn(this.b)}`}function mn(){const t=yn(this.opacity);return`${1===t?"rgb(":"rgba("}${Ln(this.r)}, ${Ln(this.g)}, ${Ln(this.b)}${1===t?")":`, ${t})`}`}function yn(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ln(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function wn(t){return((t=Ln(t))<16?"0":"")+t.toString(16)}function vn(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new xn(t,n,e,r)}function An(t){if(t instanceof xn)return new xn(t.h,t.s,t.l,t.opacity);if(t instanceof Gt||(t=cn(t)),!t)return new xn;if(t instanceof xn)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),s=NaN,u=o-i,a=(o+i)/2;return u?(s=n===o?(e-r)/u+6*(e<r):e===o?(r-n)/u+2:(n-e)/u+4,u/=a<.5?o+i:2-o-i,s*=60):u=a>0&&a<1?0:s,new xn(s,u,a,t.opacity)}function xn(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function _n(t){return(t=(t||0)%360)<0?t+360:t}function Nn(t){return Math.max(0,Math.min(1,t||0))}
|
|
100
|
+
/* From FvD 13.37, CSS Color Module Level 3 */function bn(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}Xt(Gt,cn,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:an,formatHex:an,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return An(this).formatHsl()},formatRgb:ln,toString:ln}),Xt(pn,dn,Yt(Gt,{brighter(t){return t=null==t?Qt:Math.pow(Qt,t),new pn(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Vt:Math.pow(Vt,t),new pn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new pn(Ln(this.r),Ln(this.g),Ln(this.b),yn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:gn,formatHex:gn,formatHex8:function(){return`#${wn(this.r)}${wn(this.g)}${wn(this.b)}${wn(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:mn,toString:mn})),Xt(xn,function(t,n,e,r){return 1===arguments.length?An(t):new xn(t,n,e,null==r?1:r)},Yt(Gt,{brighter(t){return t=null==t?Qt:Math.pow(Qt,t),new xn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Vt:Math.pow(Vt,t),new xn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new pn(bn(t>=240?t-240:t+120,i,r),bn(t,i,r),bn(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new xn(_n(this.h),Nn(this.s),Nn(this.l),yn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=yn(this.opacity);return`${1===t?"hsl(":"hsla("}${_n(this.h)}, ${100*Nn(this.s)}%, ${100*Nn(this.l)}%${1===t?")":`, ${t})`}`}}));var kn=t=>()=>t;function Sn(t){return 1===(t=+t)?En:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):kn(isNaN(n)?e:n)}}function En(t,n){var e=n-t;return e?function(t,n){return function(e){return t+e*n}}(t,e):kn(isNaN(t)?n:t)}var On=function t(n){var e=Sn(n);function r(t,n){var r=e((t=dn(t)).r,(n=dn(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),s=En(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=o(n),t.opacity=s(n),t+""}}return r.gamma=t,r}(1);function Mn(t,n){return t=+t,n=+n,function(e){return t*(1-e)+n*e}}var Bn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Cn=new RegExp(Bn.source,"g");function Wn(t,n){var e,r,i,o=Bn.lastIndex=Cn.lastIndex=0,s=-1,u=[],a=[];// number interpolators
|
|
108
101
|
// Coerce inputs to strings.
|
|
109
102
|
// Interpolate pairs of numbers in a & b.
|
|
110
|
-
for(t+="",
|
|
103
|
+
for(t+="",n+="";(e=Bn.exec(t))&&(r=Cn.exec(n));)(i=r.index)>o&&(i=n.slice(o,i),u[s]?u[s]+=i:u[++s]=i),(e=e[0])===(r=r[0])?u[s]?u[s]+=r:u[++s]=r:(u[++s]=null,a.push({i:s,x:Mn(e,r)})),o=Cn.lastIndex;
|
|
111
104
|
// Add remains of b.
|
|
112
105
|
// Special optimization for only a single match.
|
|
113
106
|
// Otherwise, interpolate each of the numbers and rejoin the string.
|
|
114
|
-
return
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// If this node shared a dispatch with the previous node,
|
|
120
|
-
// just assign the updated shared dispatch and we’re done!
|
|
121
|
-
// Otherwise, copy-on-write.
|
|
122
|
-
e===h&&p===n||(f=(h=e).copy()).on(g,p=n),t.on=f})):this.styleTween(t,(r=t,i=$,s=(o=e)+"",function(){var t=M(this,r);return t===s?null:t===a?u:u=i(a=t,o)}),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,Oe(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?(n=Ee(this,"text",t),function(){var t=n(this);this.textContent=null==t?"":t}):(e=null==t?"":t+"",function(){this.textContent=e}));var e,n},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,Ce(t))},remove:function(){return this.on("end.remove",(n=this._id,function(){var t,e=this.parentNode;for(t in this.__transition)if(+t!==n)return;e&&e.removeChild(this)}));var n},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=v(this.node(),n).tween,o=0,a=i.length;o<a;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==e?function(i,o){var a,u;return function(){var t=O(this,i),e=t.tween;
|
|
107
|
+
return o<n.length&&(i=n.slice(o),u[s]?u[s]+=i:u[++s]=i),u.length<2?a[0]?function(t){return function(n){return t(n)+""}}(a[0].x):function(t){return function(){return t}}(n):(n=a.length,function(t){for(var e,r=0;r<n;++r)u[(e=a[r]).i]=e.x(t);return u.join("")})}var $n,In=180/Math.PI,Pn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Fn(t,n,e,r,i,o){var s,u,a;return(s=Math.sqrt(t*t+n*n))&&(t/=s,n/=s),(a=t*e+n*r)&&(e-=t*a,r-=n*a),(u=Math.sqrt(e*e+r*r))&&(e/=u,r/=u,a/=u),t*r<n*e&&(t=-t,n=-n,a=-a,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(n,t)*In,skewX:Math.atan(a)*In,scaleX:s,scaleY:u}}function Rn(t,n,e,r){function i(t){return t.length?t.pop()+" ":""}return function(o,s){var u=[],a=[];// number interpolators
|
|
108
|
+
// gc
|
|
109
|
+
return o=t(o),s=t(s),function(t,r,i,o,s,u){if(t!==i||r!==o){var a=s.push("translate(",null,n,null,e);u.push({i:a-4,x:Mn(t,i)},{i:a-2,x:Mn(r,o)})}else(i||o)&&s.push("translate("+i+n+o+e)}(o.translateX,o.translateY,s.translateX,s.translateY,u,a),function(t,n,e,o){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),// shortest path
|
|
110
|
+
o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:Mn(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,s.rotate,u,a),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:Mn(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,s.skewX,u,a),function(t,n,e,r,o,s){if(t!==e||n!==r){var u=o.push(i(o)+"scale(",null,",",null,")");s.push({i:u-4,x:Mn(t,e)},{i:u-2,x:Mn(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,s.scaleX,s.scaleY,u,a),o=s=null,function(t){for(var n,e=-1,r=a.length;++e<r;)u[(n=a[e]).i]=n.x(t);return u.join("")}}}var Tn=Rn(
|
|
111
|
+
/* eslint-disable no-undef */function(t){const n=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return n.isIdentity?Pn:Fn(n.a,n.b,n.c,n.d,n.e,n.f)},"px, ","px)","deg)"),zn=Rn(function(t){return null==t?Pn:($n||($n=document.createElementNS("http://www.w3.org/2000/svg","g")),$n.setAttribute("transform",t),(t=$n.transform.baseVal.consolidate())?Fn((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Pn)},", ",")",")");function jn(t,n){var e,r;return function(){var i=qt(this,t),o=i.tween;
|
|
123
112
|
// If this node shared tween with the previous node,
|
|
124
113
|
// just assign the updated shared tween and we’re done!
|
|
125
114
|
// Otherwise, copy-on-write.
|
|
126
|
-
if(e
|
|
115
|
+
if(o!==e)for(var s=0,u=(r=e=o).length;s<u;++s)if(r[s].name===n){(r=r.slice()).splice(s,1);break}i.tween=r}}function Hn(t,n,e){var r,i;if("function"!=typeof e)throw new Error;return function(){var o=qt(this,t),s=o.tween;
|
|
127
116
|
// If this node shared tween with the previous node,
|
|
128
117
|
// just assign the updated shared tween and we’re done!
|
|
129
118
|
// Otherwise, copy-on-write.
|
|
130
|
-
if(
|
|
119
|
+
if(s!==r){i=(r=s).slice();for(var u={name:n,value:e},a=0,l=i.length;a<l;++a)if(i[a].name===n){i[a]=u;break}a===l&&i.push(u)}o.tween=i}}function qn(t,n,e){var r=t._id;return t.each(function(){var t=qt(this,r);(t.value||(t.value={}))[n]=e.apply(this,arguments)}),function(t){return Dt(t,r).value[n]}}function Dn(t,n){var e;return("number"==typeof n?Mn:n instanceof cn?On:(e=cn(n))?(n=e,On):Wn)(t,n)}function Xn(t){return function(){this.removeAttribute(t)}}function Yn(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Gn(t,n,e){var r,i,o=e+"";return function(){var s=this.getAttribute(t);return s===o?null:s===r?i:i=n(r=s,e)}}function Vn(t,n,e){var r,i,o=e+"";return function(){var s=this.getAttributeNS(t.space,t.local);return s===o?null:s===r?i:i=n(r=s,e)}}function Qn(t,n,e){var r,i,o;return function(){var s,u,a=e(this);if(null!=a)return(s=this.getAttribute(t))===(u=a+"")?null:s===r&&u===i?o:(i=u,o=n(r=s,a));this.removeAttribute(t)}}function Kn(t,n,e){var r,i,o;return function(){var s,u,a=e(this);if(null!=a)return(s=this.getAttributeNS(t.space,t.local))===(u=a+"")?null:s===r&&u===i?o:(i=u,o=n(r=s,a));this.removeAttributeNS(t.space,t.local)}}function Jn(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttributeNS(t.space,t.local,n.call(this,e))}}(t,i)),e}return i._value=n,i}function Un(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttribute(t,n.call(this,e))}}(t,i)),e}return i._value=n,i}function Zn(t,n){return function(){Ht(this,t).delay=+n.apply(this,arguments)}}function te(t,n){return n=+n,function(){Ht(this,t).delay=n}}function ne(t,n){return function(){qt(this,t).duration=+n.apply(this,arguments)}}function ee(t,n){return n=+n,function(){qt(this,t).duration=n}}var re=pt.prototype.constructor;function ie(t){return function(){this.style.removeProperty(t)}}var oe=0;function se(t,n,e,r){this._groups=t,this._parents=n,this._name=e,this._id=r}function ue(t){return pt().transition(t)}function ae(){return++oe}var le=pt.prototype;se.prototype=ue.prototype={constructor:se,select:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=c(t));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var u,a,l=r[s],f=l.length,h=o[s]=new Array(f),d=0;d<f;++d)(u=l[d])&&(a=t.call(u,u.__data__,d,l))&&("__data__"in u&&(a.__data__=u.__data__),h[d]=a,jt(h[d],n,e,d,h,Dt(u,e)));return new se(o,this._parents,n,e)},selectAll:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=h(t));for(var r=this._groups,i=r.length,o=[],s=[],u=0;u<i;++u)for(var a,l=r[u],c=l.length,f=0;f<c;++f)if(a=l[f]){for(var d,p=t.call(a,a.__data__,f,l),g=Dt(a,e),m=0,y=p.length;m<y;++m)(d=p[m])&&jt(d,n,e,m,p,g);o.push(p),s.push(a)}return new se(o,s,n,e)},selectChild:le.selectChild,selectChildren:le.selectChildren,filter:function(t){"function"!=typeof t&&(t=p(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,s=n[i],u=s.length,a=r[i]=[],l=0;l<u;++l)(o=s[l])&&t.call(o,o.__data__,l,s)&&a.push(o);return new se(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var n=this._groups,e=t._groups,r=n.length,i=e.length,o=Math.min(r,i),s=new Array(r),u=0;u<o;++u)for(var a,l=n[u],c=e[u],f=l.length,h=s[u]=new Array(f),d=0;d<f;++d)(a=l[d]||c[d])&&(h[d]=a);for(;u<r;++u)s[u]=n[u];return new se(s,this._parents,this._name,this._id)},selection:function(){return new re(this._groups,this._parents)},transition:function(){for(var t=this._name,n=this._id,e=ae(),r=this._groups,i=r.length,o=0;o<i;++o)for(var s,u=r[o],a=u.length,l=0;l<a;++l)if(s=u[l]){var c=Dt(s,n);jt(s,t,e,l,u,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new se(r,this._parents,t,e)},call:le.call,nodes:le.nodes,node:le.node,size:le.size,empty:le.empty,each:le.each,on:function(t,n){var e=this._id;return arguments.length<2?Dt(this.node(),e).on.on(t):this.each(function(t,n,e){var r,i,o=function(t){return(t+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||"start"===t})}(n)?Ht:qt;return function(){var s=o(this,t),u=s.on;
|
|
120
|
+
// If this node shared a dispatch with the previous node,
|
|
121
|
+
// just assign the updated shared dispatch and we’re done!
|
|
122
|
+
// Otherwise, copy-on-write.
|
|
123
|
+
u!==r&&(i=(r=u).copy()).on(n,e),s.on=i}}(e,t,n))},attr:function(t,n){var e=o(t),r="transform"===e?zn:Dn;return this.attrTween(t,"function"==typeof n?(e.local?Kn:Qn)(e,r,qn(this,"attr."+t,n)):null==n?(e.local?Yn:Xn)(e):(e.local?Vn:Gn)(e,r,n))},attrTween:function(t,n){var e="attr."+t;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(null==n)return this.tween(e,null);if("function"!=typeof n)throw new Error;var r=o(t);return this.tween(e,(r.local?Jn:Un)(r,n))},style:function(t,n,e){var r="transform"==(t+="")?Tn:Dn;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=F(this,t),s=(this.style.removeProperty(t),F(this,t));return o===s?null:o===e&&s===r?i:i=n(e=o,r=s)}}(t,r)).on("end.style."+t,ie(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var s=F(this,t),u=e(this),a=u+"";return null==u&&(this.style.removeProperty(t),a=u=F(this,t)),s===a?null:s===r&&a===i?o:(i=a,o=n(r=s,u))}}(t,r,qn(this,"style."+t,n))).each(function(t,n){var e,r,i,o,s="style."+n,u="end."+s;return function(){var a=qt(this,t),l=a.on,c=null==a.value[s]?o||(o=ie(n)):void 0;
|
|
131
124
|
// If this node shared a dispatch with the previous node,
|
|
132
125
|
// just assign the updated shared dispatch and we’re done!
|
|
133
126
|
// Otherwise, copy-on-write.
|
|
134
|
-
e
|
|
127
|
+
l===e&&i===c||(r=(e=l).copy()).on(u,i=c),a.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var r,i,o=e+"";return function(){var s=F(this,t);return s===o?null:s===r?i:i=n(r=s,e)}}(t,r,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,function(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}(t,o,e)),r}return o._value=n,o}(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}(qn(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;return this.tween(n,function(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&function(t){return function(n){this.textContent=t.call(this,n)}}(r)),n}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=Dt(this.node(),e).tween,o=0,s=i.length;o<s;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==n?jn:Hn)(e,t,n))},delay:function(t){var n=this._id;return arguments.length?this.each(("function"==typeof t?Zn:te)(n,t)):Dt(this.node(),n).delay},duration:function(t){var n=this._id;return arguments.length?this.each(("function"==typeof t?ne:ee)(n,t)):Dt(this.node(),n).duration},ease:function(t){var n=this._id;return arguments.length?this.each(function(t,n){if("function"!=typeof n)throw new Error;return function(){qt(this,t).ease=n}}(n,t)):Dt(this.node(),n).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,n){return function(){var e=n.apply(this,arguments);if("function"!=typeof e)throw new Error;qt(this,t).ease=e}}(this._id,t))},end:function(){var t,n,e=this,r=e._id,i=e.size();return new Promise(function(o,s){var u={value:s},a={value:function(){0===--i&&o()}};e.each(function(){var e=qt(this,r),i=e.on;
|
|
128
|
+
// If this node shared a dispatch with the previous node,
|
|
129
|
+
// just assign the updated shared dispatch and we’re done!
|
|
130
|
+
// Otherwise, copy-on-write.
|
|
131
|
+
i!==t&&((n=(t=i).copy())._.cancel.push(u),n._.interrupt.push(u),n._.end.push(a)),e.on=n}),
|
|
135
132
|
// The selection was empty, resolve end immediately
|
|
136
|
-
0===
|
|
133
|
+
0===i&&o()})},[Symbol.iterator]:le[Symbol.iterator]};var ce={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function fe(t,n){for(var e;!(e=t.__transition)||!(e=e[n]);)if(!(t=t.parentNode))throw new Error(`transition ${n} not found`);return e}pt.prototype.interrupt=function(t){return this.each(function(){!function(t,n){var e,r,i,o=t.__transition,s=!0;if(o){for(i in n=null==n?null:n+"",o)(e=o[i]).name===n?(r=e.state>2&&e.state<5,e.state=6,e.timer.stop(),e.on.call(r?"interrupt":"cancel",t,t.__data__,e.index,e.group),delete o[i]):s=!1;s&&delete t.__transition}}(this,t)})},pt.prototype.transition=function(t){var n,e;t instanceof se?(n=t._id,t=t._name):(n=ae(),(e=ce).time=Bt(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var s,u=r[o],a=u.length,l=0;l<a;++l)(s=u[l])&&jt(s,t,n,l,u,e||fe(s,n));return new se(r,this._parents,t,n)};
|
|
134
|
+
// Simplified bidi metadata helper for the rich prepareWithSegments() path,
|
|
135
|
+
// forked from pdf.js via Sebastian's text-layout. It classifies characters
|
|
136
|
+
// into bidi types, computes embedding levels, and maps them onto prepared
|
|
137
|
+
// segments for custom rendering. The line-breaking engine does not consume
|
|
138
|
+
// these levels.
|
|
139
|
+
const he=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ON","CS","ON","CS","ON","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ON","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","ON","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],de=["AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","CS","AL","ON","ON","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","ON","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL"];function pe(t){return t<=255?he[t]:1424<=t&&t<=1524?"R":1536<=t&&t<=1791?de[255&t]:1792<=t&&t<=2220?"AL":"L"}function ge(t,n){const e=function(t){const n=t.length;if(0===n)return null;
|
|
140
|
+
// eslint-disable-next-line unicorn/no-new-array
|
|
141
|
+
const e=new Array(n);let r=0;for(let i=0;i<n;i++){const n=pe(t.charCodeAt(i));"R"!==n&&"AL"!==n&&"AN"!==n||r++,e[i]=n}if(0===r)return null;const i=n/r<.3?0:1,o=new Int8Array(n);for(let t=0;t<n;t++)o[t]=i;const s=1&i?"R":"L",u=s;
|
|
142
|
+
// W1-W7
|
|
143
|
+
let a=u;for(let t=0;t<n;t++)"NSM"===e[t]?e[t]=a:a=e[t];a=u;for(let t=0;t<n;t++){const n=e[t];"EN"===n?e[t]="AL"===a?"AN":"EN":"R"!==n&&"L"!==n&&"AL"!==n||(a=n)}for(let t=0;t<n;t++)"AL"===e[t]&&(e[t]="R");for(let t=1;t<n-1;t++)"ES"===e[t]&&"EN"===e[t-1]&&"EN"===e[t+1]&&(e[t]="EN"),"CS"!==e[t]||"EN"!==e[t-1]&&"AN"!==e[t-1]||e[t+1]!==e[t-1]||(e[t]=e[t-1]);for(let t=0;t<n;t++){if("EN"!==e[t])continue;let r;for(r=t-1;r>=0&&"ET"===e[r];r--)e[r]="EN";for(r=t+1;r<n&&"ET"===e[r];r++)e[r]="EN"}for(let t=0;t<n;t++){const n=e[t];"WS"!==n&&"ES"!==n&&"ET"!==n&&"CS"!==n||(e[t]="ON")}a=u;for(let t=0;t<n;t++){const n=e[t];"EN"===n?e[t]="L"===a?"L":"EN":"R"!==n&&"L"!==n||(a=n)}
|
|
144
|
+
// N1-N2
|
|
145
|
+
for(let t=0;t<n;t++){if("ON"!==e[t])continue;let r=t+1;for(;r<n&&"ON"===e[r];)r++;const i="L"!==(t>0?e[t-1]:u)?"R":"L";if(i===("L"!==(r<n?e[r]:u)?"R":"L"))for(let n=t;n<r;n++)e[n]=i;t=r-1}for(let t=0;t<n;t++)"ON"===e[t]&&(e[t]=s);
|
|
146
|
+
// I1-I2
|
|
147
|
+
for(let t=0;t<n;t++){const n=e[t];1&o[t]?"L"!==n&&"AN"!==n&&"EN"!==n||o[t]++:"R"===n?o[t]++:"AN"!==n&&"EN"!==n||(o[t]+=2)}return o}(t);if(null===e)return null;const r=new Int8Array(n.length);for(let t=0;t<n.length;t++)r[t]=e[n[t]];return r}const me=/[ \t\n\r\f]+/g,ye=/[\t\n\r\f]| {2,}|^ | $/;let Le=null;const we=/\p{Script=Arabic}/u,ve=/\p{M}/u,Ae=/\p{Nd}/u;function xe(t){return we.test(t)}function _e(t){for(const n of t){const t=n.codePointAt(0);if(t>=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=183984&&t<=191471||t>=196608&&t<=201551||t>=63744&&t<=64255||t>=194560&&t<=195103||t>=12288&&t<=12351||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=44032&&t<=55215||t>=65280&&t<=65519)return!0}return!1}const Ne=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),be=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),ke=new Set(["'","’"]),Se=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),Ee=new Set([":",".","،","؛"]),Oe=new Set(["၏"]),Me=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function Be(t){if($e(t))return!0;let n=!1;for(const e of t)if(Se.has(e))n=!0;else if(!n||!ve.test(e))return!1;return n}function Ce(t){for(const n of t)if(!Ne.has(n)&&!Se.has(n))return!1;return t.length>0}function We(t){if($e(t))return!0;for(const n of t)if(!be.has(n)&&!ke.has(n)&&!ve.test(n))return!1;return t.length>0}function $e(t){let n=!1;for(const e of t)if("\\"!==e&&!ve.test(e)){if(!(be.has(e)||Se.has(e)||ke.has(e)))return!1;n=!0}return n}function Ie(t){const n=Array.from(t);let e=n.length;for(;e>0;){const t=n[e-1];if(ve.test(t))e--;else{if(!be.has(t)&&!ke.has(t))break;e--}}return e<=0||e===n.length?null:{head:n.slice(0,e).join(""),tail:n.slice(e).join("")}}function Pe(t,n){if(0===t.length)return!1;for(const e of t)if(e!==n)return!1;return!0}function Fe(t){return!(!xe(t)||0===t.length)&&Ee.has(t[t.length-1])}function Re(t){return 0!==t.length&&Oe.has(t[t.length-1])}function Te(t){if(t.length<2||" "!==t[0])return null;const n=t.slice(1);return/^\p{M}+$/u.test(n)?{space:" ",marks:n}:null}function ze(t){for(let n=t.length-1;n>=0;n--){const e=t[n];if(Me.has(e))return!0;if(!Se.has(e))return!1}return!1}function je(t,n){if(n.preserveOrdinarySpaces||n.preserveHardBreaks){if(" "===t)return"preserved-space";if("\t"===t)return"tab";if(n.preserveHardBreaks&&"\n"===t)return"hard-break"}return" "===t?"space":" "===t||" "===t||""===t||"\ufeff"===t?"glue":""===t?"zero-width-break":""===t?"soft-hyphen":"text"}function He(t,n,e,r){const i=[];let o=null,s="",u=e,a=!1,l=0;for(const c of t){const t=je(c,r),f="text"===t&&n;null===o||t!==o||f!==a?(null!==o&&i.push({text:s,isWordLike:a,kind:o,start:u}),o=t,s=c,u=e+l,a=f,l+=c.length):(s+=c,l+=c.length)}return null!==o&&i.push({text:s,isWordLike:a,kind:o,start:u}),i}function qe(t){return"space"===t||"preserved-space"===t||"zero-width-break"===t||"hard-break"===t}const De=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function Xe(t,n){const e=t.texts[n];return!!e.startsWith("www.")||De.test(e)&&n+1<t.len&&"text"===t.kinds[n+1]&&"//"===t.texts[n+1]}function Ye(t){return t.includes("?")&&(t.includes("://")||t.startsWith("www."))}const Ge=new Set([":","-","/","×",",",".","+","–","—"]),Ve=/^[A-Za-z0-9_]+[,:;]*$/,Qe=/[,:;]+$/;function Ke(t){for(const n of t)if(Ae.test(n))return!0;return!1}function Je(t){if(0===t.length)return!1;for(const n of t)if(!Ae.test(n)&&!Ge.has(n))return!1;return!0}function Ue(t,n,e){const r=(null===Le&&(Le=new Intl.Segmenter(void 0,{granularity:"word"})),Le);let i=0;const o=[],s=[],u=[],a=[];for(const l of r.segment(t))for(const t of He(l.segment,l.isWordLike??!1,l.index,e)){const e="text"===t.kind;n.carryCJKAfterClosingQuote&&e&&i>0&&"text"===u[i-1]&&_e(t.text)&&_e(o[i-1])&&ze(o[i-1])||e&&i>0&&"text"===u[i-1]&&Ce(t.text)&&_e(o[i-1])||e&&i>0&&"text"===u[i-1]&&Re(o[i-1])?(o[i-1]+=t.text,s[i-1]=s[i-1]||t.isWordLike):e&&i>0&&"text"===u[i-1]&&t.isWordLike&&xe(t.text)&&Fe(o[i-1])?(o[i-1]+=t.text,s[i-1]=!0):e&&!t.isWordLike&&i>0&&"text"===u[i-1]&&1===t.text.length&&"-"!==t.text&&"—"!==t.text&&Pe(o[i-1],t.text)||e&&!t.isWordLike&&i>0&&"text"===u[i-1]&&(Be(t.text)||"-"===t.text&&s[i-1])?o[i-1]+=t.text:(o[i]=t.text,s[i]=t.isWordLike,u[i]=t.kind,a[i]=t.start,i++)}for(let t=1;t<i;t++)"text"===u[t]&&!s[t]&&$e(o[t])&&"text"===u[t-1]&&(o[t-1]+=o[t],s[t-1]=s[t-1]||s[t],o[t]="");for(let t=i-2;t>=0;t--)if("text"===u[t]&&!s[t]&&We(o[t])){let n=t+1;for(;n<i&&""===o[n];)n++;n<i&&"text"===u[n]&&(o[n]=o[t]+o[n],a[n]=a[t],o[t]="")}let l=0;for(let t=0;t<i;t++){const n=o[t];0!==n.length&&(l!==t&&(o[l]=n,s[l]=s[t],u[l]=u[t],a[l]=a[t]),l++)}o.length=l,s.length=l,u.length=l,a.length=l;const c=function(t){const n=[],e=[],r=[],i=[];let o=0;for(;o<t.len;){let s=t.texts[o],u=t.isWordLike[o],a=t.kinds[o],l=t.starts[o];if("glue"===a){let c=s;const f=l;for(o++;o<t.len&&"glue"===t.kinds[o];)c+=t.texts[o],o++;if(!(o<t.len&&"text"===t.kinds[o])){n.push(c),e.push(!1),r.push("glue"),i.push(f);continue}s=c+t.texts[o],u=t.isWordLike[o],a="text",l=f,o++}else o++;if("text"===a)for(;o<t.len&&"glue"===t.kinds[o];){let n="";for(;o<t.len&&"glue"===t.kinds[o];)n+=t.texts[o],o++;o<t.len&&"text"===t.kinds[o]?(s+=n+t.texts[o],u=u||t.isWordLike[o],o++):s+=n}n.push(s),e.push(u),r.push(a),i.push(l)}return{len:n.length,texts:n,isWordLike:e,kinds:r,starts:i}}({len:l,texts:o,isWordLike:s,kinds:u,starts:a}),f=function(t){const n=t.texts.slice(),e=t.isWordLike.slice(),r=t.kinds.slice(),i=t.starts.slice();for(let t=0;t<n.length-1;t++){if("text"!==r[t]||"text"!==r[t+1])continue;if(!_e(n[t])||!_e(n[t+1]))continue;const e=Ie(n[t]);null!==e&&(n[t]=e.head,n[t+1]=e.tail+n[t+1],i[t+1]=i[t]+e.head.length)}return{len:n.length,texts:n,isWordLike:e,kinds:r,starts:i}}(function(t){const n=[],e=[],r=[],i=[];for(let o=0;o<t.len;o++){const s=t.texts[o],u=t.kinds[o],a=t.isWordLike[o];if("text"===u&&a&&Ve.test(s)){let u=s,a=o+1;for(;Qe.test(u)&&a<t.len&&"text"===t.kinds[a]&&t.isWordLike[a]&&Ve.test(t.texts[a]);)u+=t.texts[a],a++;n.push(u),e.push(!0),r.push("text"),i.push(t.starts[o]),o=a-1;continue}n.push(s),e.push(a),r.push(u),i.push(t.starts[o])}return{len:n.length,texts:n,isWordLike:e,kinds:r,starts:i}}(function(t){const n=[],e=[],r=[],i=[];for(let o=0;o<t.len;o++){const s=t.texts[o];if("text"===t.kinds[o]&&s.includes("-")){const u=s.split("-");let a=u.length>1;for(let t=0;t<u.length;t++){const n=u[t];if(!a)break;0!==n.length&&Ke(n)&&Je(n)||(a=!1)}if(a){let s=0;for(let a=0;a<u.length;a++){const l=u[a],c=a<u.length-1?`${l}-`:l;n.push(c),e.push(!0),r.push("text"),i.push(t.starts[o]+s),s+=c.length}continue}}n.push(s),e.push(t.isWordLike[o]),r.push(t.kinds[o]),i.push(t.starts[o])}return{len:n.length,texts:n,isWordLike:e,kinds:r,starts:i}}(function(t){const n=[],e=[],r=[],i=[];for(let o=0;o<t.len;o++){const s=t.texts[o],u=t.kinds[o];if("text"===u&&Je(s)&&Ke(s)){let u=s,a=o+1;for(;a<t.len&&"text"===t.kinds[a]&&Je(t.texts[a]);)u+=t.texts[a],a++;n.push(u),e.push(!0),r.push("text"),i.push(t.starts[o]),o=a-1;continue}n.push(s),e.push(t.isWordLike[o]),r.push(u),i.push(t.starts[o])}return{len:n.length,texts:n,isWordLike:e,kinds:r,starts:i}}(function(t){const n=[],e=[],r=[],i=[];for(let o=0;o<t.len;o++){const s=t.texts[o];if(n.push(s),e.push(t.isWordLike[o]),r.push(t.kinds[o]),i.push(t.starts[o]),!Ye(s))continue;const u=o+1;if(u>=t.len||qe(t.kinds[u]))continue;let a="";const l=t.starts[u];let c=u;for(;c<t.len&&!qe(t.kinds[c]);)a+=t.texts[c],c++;a.length>0&&(n.push(a),e.push(!0),r.push("text"),i.push(l),o=c-1)}return{len:n.length,texts:n,isWordLike:e,kinds:r,starts:i}}(function(t){const n=t.texts.slice(),e=t.isWordLike.slice(),r=t.kinds.slice(),i=t.starts.slice();for(let i=0;i<t.len;i++){if("text"!==r[i]||!Xe(t,i))continue;let o=i+1;for(;o<t.len&&!qe(r[o]);){n[i]+=n[o],e[i]=!0;const t=n[o].includes("?");if(r[o]="text",n[o]="",o++,t)break}}let o=0;for(let t=0;t<n.length;t++){const s=n[t];0!==s.length&&(o!==t&&(n[o]=s,e[o]=e[t],r[o]=r[t],i[o]=i[t]),o++)}return n.length=o,e.length=o,r.length=o,i.length=o,{len:o,texts:n,isWordLike:e,kinds:r,starts:i}}(c))))));for(let t=0;t<f.len-1;t++){const n=Te(f.texts[t]);null!==n&&("space"!==f.kinds[t]&&"preserved-space"!==f.kinds[t]||"text"!==f.kinds[t+1]||!xe(f.texts[t+1])||(f.texts[t]=n.space,f.isWordLike[t]=!1,f.kinds[t]="preserved-space"===f.kinds[t]?"preserved-space":"space",f.texts[t+1]=n.marks+f.texts[t+1],f.starts[t+1]=f.starts[t]+n.space.length))}return f}function Ze(t,n){if(0===t.len)return[];if(!n.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:t.len,consumedEndSegmentIndex:t.len}];const e=[];let r=0;for(let n=0;n<t.len;n++)"hard-break"===t.kinds[n]&&(e.push({startSegmentIndex:r,endSegmentIndex:n,consumedEndSegmentIndex:n+1}),r=n+1);return r<t.len&&e.push({startSegmentIndex:r,endSegmentIndex:t.len,consumedEndSegmentIndex:t.len}),e}function tr(t,n,e="normal"){const r=function(t){const n=t??"normal";return"pre-wrap"===n?{mode:n,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:n,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}(e),i="pre-wrap"===r.mode?function(t){return/[\r\f]/.test(t)?t.replace(/\r\n/g,"\n").replace(/[\r\f]/g,"\n"):t.replace(/\r\n/g,"\n")}(t):function(t){if(!ye.test(t))return t;let n=t.replace(me," ");return 32===n.charCodeAt(0)&&(n=n.slice(1)),n.length>0&&32===n.charCodeAt(n.length-1)&&(n=n.slice(0,-1)),n}(t);if(0===i.length)return{normalized:i,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};const o=Ue(i,n,r);return{normalized:i,chunks:Ze(o,r),...o}}let nr=null;const er=new Map;let rr=null;const ir=/\p{Emoji_Presentation}/u,or=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;let sr=null;const ur=new Map;function ar(){if(null!==nr)return nr;if("undefined"!=typeof OffscreenCanvas)return nr=new OffscreenCanvas(1,1).getContext("2d"),nr;if("undefined"!=typeof document)return nr=document.createElement("canvas").getContext("2d"),nr;throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function lr(t,n){let e=n.get(t);if(void 0===e){e={width:ar().measureText(t).width,containsCJK:_e(t)},n.set(t,e)}return e}function cr(){if(null!==rr)return rr;if("undefined"==typeof navigator)return rr={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},rr;const t=navigator.userAgent,n="Apple Computer, Inc."===navigator.vendor&&t.includes("Safari/")&&!t.includes("Chrome/")&&!t.includes("Chromium/")&&!t.includes("CriOS/")&&!t.includes("FxiOS/")&&!t.includes("EdgiOS/"),e=t.includes("Chrome/")||t.includes("Chromium/")||t.includes("CriOS/")||t.includes("Edg/");return rr={lineFitEpsilon:n?1/64:.005,carryCJKAfterClosingQuote:e,preferPrefixWidthsForBreakableRuns:n,preferEarlySoftHyphenBreak:n},rr}function fr(){return null===sr&&(sr=new Intl.Segmenter(void 0,{granularity:"grapheme"})),sr}function hr(t){return ir.test(t)||t.includes("️")}function dr(t,n){return void 0===n.emojiCount&&(n.emojiCount=function(t){let n=0;const e=fr();for(const r of e.segment(t))hr(r.segment)&&n++;return n}(t)),n.emojiCount}function pr(t,n,e){return 0===e?n.width:n.width-dr(t,n)*e}function gr(t,n,e,r){if(void 0!==n.graphemeWidths)return n.graphemeWidths;const i=[],o=fr();for(const n of o.segment(t)){const t=lr(n.segment,e);i.push(pr(n.segment,t,r))}return n.graphemeWidths=i.length>1?i:null,n.graphemeWidths}function mr(t,n,e,r){if(void 0!==n.graphemePrefixWidths)return n.graphemePrefixWidths;const i=[],o=fr();let s="";for(const n of o.segment(t)){s+=n.segment;const t=lr(s,e);i.push(pr(s,t,r))}return n.graphemePrefixWidths=i.length>1?i:null,n.graphemePrefixWidths}function yr(t,n){ar().font=t;const e=function(t){let n=er.get(t);return n||(n=new Map,er.set(t,n)),n}(t),r=function(t){const n=t.match(/(\d+(?:\.\d+)?)\s*px/);return n?parseFloat(n[1]):16}(t),i=n?function(t,n){let e=ur.get(t);if(void 0!==e)return e;const r=ar();r.font=t;const i=r.measureText("😀").width;if(e=0,i>n+.5&&"undefined"!=typeof document&&null!==document.body){const n=document.createElement("span");n.style.font=t,n.style.display="inline-block",n.style.visibility="hidden",n.style.position="absolute",n.textContent="😀",document.body.appendChild(n);const r=n.getBoundingClientRect().width;document.body.removeChild(n),i-r>.5&&(e=i-r)}return ur.set(t,e),e}(t,r):0;return{cache:e,fontSize:r,emojiCorrection:i}}function Lr(t){return"space"===t||"preserved-space"===t||"tab"===t||"zero-width-break"===t||"soft-hyphen"===t}function wr(t,n){if(n<=0)return 0;const e=t%n;return Math.abs(e)<=1e-6?n:n-e}function vr(t,n,e,r){return r&&null!==n?n[e]-(e>0?n[e-1]:0):t[e]}function Ar(t,n,e){const{widths:r,kinds:i,breakableWidths:o,breakablePrefixWidths:s}=t;if(0===r.length)return 0;const u=cr(),a=u.lineFitEpsilon;let l=0,c=0,f=!1,h=0,d=0,p=0,g=0,m=-1,y=0;function L(t=p,n=g,r=c){l++,e?.({startSegmentIndex:h,startGraphemeIndex:d,endSegmentIndex:t,endGraphemeIndex:n,width:r}),c=0,f=!1,m=-1,y=0}function w(t,n){f=!0,h=t,d=0,p=t+1,g=0,c=n}function v(t,n,e){f=!0,h=t,d=n,p=t,g=n+1,c=e}function A(t,n){f?(c+=n,p=t+1,g=0):w(t,n)}function x(t,n){Lr(i[t])&&(m=t+1,y=c-n)}function _(t){!function(t,e){const r=o[t],i=s[t]??null;for(let o=e;o<r.length;o++){const e=vr(r,i,o,u.preferPrefixWidthsForBreakableRuns);f?c+e>n+a?(L(),v(t,o,e)):(c+=e,p=t,g=o+1):v(t,o,e)}f&&p===t&&g===r.length&&(p=t+1,g=0)}(t,0)}let N=0;for(;N<r.length;){const t=r[N],e=i[N];if(!f){t>n&&null!==o[N]?_(N):w(N,t),x(N,t),N++;continue}if(c+t>n+a){if(Lr(e)){A(N,t),L(N+1,0,c-t),N++;continue}if(m>=0){L(m,0,y);continue}if(t>n&&null!==o[N]){L(),_(N),N++;continue}L()}else A(N,t),x(N,t),N++}return f&&L(),l}
|
|
148
|
+
// Text measurement for browser environments using canvas measureText.
|
|
149
|
+
// Problem: DOM-based text measurement (getBoundingClientRect, offsetHeight)
|
|
150
|
+
// forces synchronous layout reflow. When components independently measure text,
|
|
151
|
+
// each measurement triggers a reflow of the entire document. This creates
|
|
152
|
+
// read/write interleaving that can cost 30ms+ per frame for 500 text blocks.
|
|
153
|
+
// Solution: two-phase measurement centered around canvas measureText.
|
|
154
|
+
// prepare(text, font) — segments text via Intl.Segmenter, measures each word
|
|
155
|
+
// via canvas, caches widths, and does one cached DOM calibration read per
|
|
156
|
+
// font when emoji correction is needed. Call once when text first appears.
|
|
157
|
+
// layout(prepared, maxWidth, lineHeight) — walks cached word widths with pure
|
|
158
|
+
// arithmetic to count lines and compute height. Call on every resize.
|
|
159
|
+
// ~0.0002ms per text.
|
|
160
|
+
// i18n: Intl.Segmenter handles CJK (per-character breaking), Thai, Arabic, etc.
|
|
161
|
+
// Bidi: simplified rich-path metadata for mixed LTR/RTL custom rendering.
|
|
162
|
+
// Punctuation merging: "better." measured as one unit (matches CSS behavior).
|
|
163
|
+
// Trailing whitespace: hangs past line edge without triggering breaks (CSS behavior).
|
|
164
|
+
// overflow-wrap: pre-measured grapheme widths enable character-level word breaking.
|
|
165
|
+
// Emoji correction: Chrome/Firefox canvas measures emoji wider than DOM at font
|
|
166
|
+
// sizes <24px on macOS (Apple Color Emoji). The inflation is constant per emoji
|
|
167
|
+
// grapheme at a given size, font-independent. Auto-detected by comparing canvas
|
|
168
|
+
// vs actual DOM emoji width (one cached DOM read per font). Safari canvas and
|
|
169
|
+
// DOM agree (both wider than fontSize), so correction = 0 there.
|
|
170
|
+
// Limitations:
|
|
171
|
+
// - system-ui font: canvas resolves to different optical variants than DOM on macOS.
|
|
172
|
+
// Use named fonts (Helvetica, Inter, etc.) for guaranteed accuracy.
|
|
173
|
+
// See RESEARCH.md "Discovery: system-ui font resolution mismatch".
|
|
174
|
+
// Based on Sebastian Markbage's text-layout research (github.com/chenglou/text-layout).
|
|
175
|
+
let xr=null,_r=new WeakMap;
|
|
176
|
+
// Rich-path only. Reuses grapheme splits while materializing multiple lines
|
|
177
|
+
// from the same prepared handle, without pushing that cache into the API.
|
|
178
|
+
function Nr(){return null===xr&&(xr=new Intl.Segmenter(void 0,{granularity:"grapheme"})),xr}
|
|
179
|
+
// --- Public API ---
|
|
180
|
+
function br(t,n,e){const r=Nr(),i=cr(),{cache:o,emojiCorrection:s}=yr(n,(u=t.normalized,or.test(u)));var u;const a=pr("-",lr("-",o),s),l=8*pr(" ",lr(" ",o),s);if(0===t.len)return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]};const c=[],f=[],h=[],d=[];let p=t.chunks.length<=1;const g=[],m=[],y=[],L=e?[]:null,w=Array.from({length:t.len}),v=Array.from({length:t.len});function A(t,n,e,r,i,o,s,u){"text"!==i&&"space"!==i&&"zero-width-break"!==i&&(p=!1),c.push(n),f.push(e),h.push(r),d.push(i),g?.push(o),m.push(s),y.push(u),null!==L&&L.push(t)}for(let n=0;n<t.len;n++){w[n]=c.length;const e=t.texts[n],u=t.isWordLike[n],l=t.kinds[n],f=t.starts[n];if("soft-hyphen"===l){A(e,0,a,a,l,f,null,null),v[n]=c.length;continue}if("hard-break"===l){A(e,0,0,0,l,f,null,null),v[n]=c.length;continue}if("tab"===l){A(e,0,0,0,l,f,null,null),v[n]=c.length;continue}const h=lr(e,o);if("text"===l&&h.containsCJK){let t="",u=0;for(const n of r.segment(e)){const e=n.segment;if(0===t.length){t=e,u=n.index;continue}if(be.has(t)||Ne.has(e)||Se.has(e)||i.carryCJKAfterClosingQuote&&_e(e)&&ze(t)){t+=e;continue}const r=pr(t,lr(t,o),s);A(t,r,r,r,"text",f+u,null,null),t=e,u=n.index}if(t.length>0){const n=pr(t,lr(t,o),s);A(t,n,n,n,"text",f+u,null,null)}v[n]=c.length;continue}const d=pr(e,h,s),p="space"===l||"preserved-space"===l||"zero-width-break"===l?0:d,g="space"===l||"zero-width-break"===l?0:d;if(u&&e.length>1){A(e,d,p,g,l,f,gr(e,h,o,s),i.preferPrefixWidthsForBreakableRuns?mr(e,h,o,s):null)}else A(e,d,p,g,l,f,null,null);v[n]=c.length}const x=function(t,n,e){const r=[];for(let i=0;i<t.length;i++){const o=t[i],s=o.startSegmentIndex<n.length?n[o.startSegmentIndex]:e[e.length-1]??0,u=o.endSegmentIndex<n.length?n[o.endSegmentIndex]:e[e.length-1]??0,a=o.consumedEndSegmentIndex<n.length?n[o.consumedEndSegmentIndex]:e[e.length-1]??0;r.push({startSegmentIndex:s,endSegmentIndex:u,consumedEndSegmentIndex:a})}return r}(t.chunks,w,v),_=null===g?null:ge(t.normalized,g);return null!==L?{widths:c,lineEndFitAdvances:f,lineEndPaintAdvances:h,kinds:d,simpleLineWalkFastPath:p,segLevels:_,breakableWidths:m,breakablePrefixWidths:y,discretionaryHyphenWidth:a,tabStopAdvance:l,chunks:x,segments:L}:{widths:c,lineEndFitAdvances:f,lineEndPaintAdvances:h,kinds:d,simpleLineWalkFastPath:p,segLevels:_,breakableWidths:m,breakablePrefixWidths:y,discretionaryHyphenWidth:a,tabStopAdvance:l,chunks:x}}
|
|
181
|
+
// Rich variant used by callers that need enough information to render the
|
|
182
|
+
// laid-out lines themselves.
|
|
183
|
+
function kr(t,n,e){return function(t,n,e,r){return br(tr(t,cr(),r?.whiteSpace),n,e)}(t,n,!0,e)}function Sr(t,n,e){let r=e.get(t);if(void 0!==r)return r;r=[];const i=Nr();for(const e of i.segment(n[t]))r.push(e.segment);return e.set(t,r),r}function Er(t,n,e,r,i,o,s){let u="";const a=function(t,n,e,r){return r>0&&"soft-hyphen"===t[r-1]&&!(n===r&&e>0)}(n,r,i,o);for(let s=r;s<o;s++)"soft-hyphen"!==n[s]&&"hard-break"!==n[s]&&(u+=s===r&&i>0?Sr(s,t,e).slice(i).join(""):t[s]);return s>0?(a&&(u+="-"),u+=Sr(o,t,e).slice(r===o?i:0,s).join("")):a&&(u+="-"),u}function Or(t,n,e){return function(t,n,e,r,i,o,s){return{text:Er(t.segments,t.kinds,n,r,i,o,s),width:e,start:{segmentIndex:r,graphemeIndex:i},end:{segmentIndex:o,graphemeIndex:s}}}(t,n,e.width,e.startSegmentIndex,e.startGraphemeIndex,e.endSegmentIndex,e.endGraphemeIndex)}
|
|
184
|
+
// Rich layout API for callers that want the actual line contents and widths.
|
|
185
|
+
// Caller still supplies lineHeight at layout time. Mirrors layout()'s break
|
|
186
|
+
// decisions, but keeps extra per-line bookkeeping so it should stay off the
|
|
187
|
+
// resize hot path.
|
|
188
|
+
function Mr(t,n,e){const r=[];if(0===t.widths.length)return{lineCount:0,height:0,lines:r};const i=function(t){let n=_r.get(t);return void 0!==n||(n=new Map,_r.set(t,n)),n}(t),o=function(t,n,e){if(t.simpleLineWalkFastPath)return Ar(t,n,e);const{widths:r,lineEndFitAdvances:i,lineEndPaintAdvances:o,kinds:s,breakableWidths:u,breakablePrefixWidths:a,discretionaryHyphenWidth:l,tabStopAdvance:c,chunks:f}=t;if(0===r.length||0===f.length)return 0;const h=cr(),d=h.lineFitEpsilon;let p=0,g=0,m=!1,y=0,L=0,w=0,v=0,A=-1,x=0,_=0,N=null;function b(){A=-1,x=0,_=0,N=null}function k(t=w,n=v,r=g){p++,e?.({startSegmentIndex:y,startGraphemeIndex:L,endSegmentIndex:t,endGraphemeIndex:n,width:r}),g=0,m=!1,b()}function S(t,n){m=!0,y=t,L=0,w=t+1,v=0,g=n}function E(t,n,e){m=!0,y=t,L=n,w=t,v=n+1,g=e}function O(t,n){m?(g+=n,w=t+1,v=0):S(t,n)}function M(t,n){if(!Lr(s[t]))return;const e="tab"===s[t]?0:i[t],r="tab"===s[t]?n:o[t];A=t+1,x=g-n+e,_=g-n+r,N=s[t]}function B(t){C(t,0)}function C(t,e){const r=u[t],i=a[t]??null;for(let o=e;o<r.length;o++){const e=vr(r,i,o,h.preferPrefixWidthsForBreakableRuns);m?g+e>n+d?(k(),E(t,o,e)):(g+=e,w=t,v=o+1):E(t,o,e)}m&&w===t&&v===r.length&&(w=t+1,v=0)}function W(t){if("soft-hyphen"!==N)return!1;const e=u[t];if(null===e)return!1;const r=h.preferPrefixWidthsForBreakableRuns?a[t]??e:e,i=r!==e,{fitCount:o,fittedWidth:s}=function(t,n,e,r,i,o){let s=0,u=n;for(;s<t.length;){const a=o?n+t[s]:u+t[s];if((s+1<t.length?a+i:a)>e+r)break;u=a,s++}return{fitCount:s,fittedWidth:u}}(r,g,n,d,l,i);return 0!==o&&(g=s,w=t,v=o,b(),o===e.length?(w=t+1,v=0,!0):(k(t,o,s+l),C(t,o),!0))}function $(t){p++,e?.({startSegmentIndex:t.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:t.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),b()}for(let t=0;t<f.length;t++){const e=f[t];if(e.startSegmentIndex===e.endSegmentIndex){$(e);continue}m=!1,g=0,y=e.startSegmentIndex,L=0,w=e.startSegmentIndex,v=0,b();let a=e.startSegmentIndex;for(;a<e.endSegmentIndex;){const t=s[a],e="tab"===t?wr(g,c):r[a];if("soft-hyphen"!==t)if(m){if(g+e>n+d){const r=g+("tab"===t?0:i[a]),s=g+("tab"===t?e:o[a]);if("soft-hyphen"===N&&h.preferEarlySoftHyphenBreak&&x<=n+d){k(A,0,_);continue}if("soft-hyphen"===N&&W(a)){a++;continue}if(Lr(t)&&r<=n+d){O(a,e),k(a+1,0,s),a++;continue}if(A>=0&&x<=n+d){k(A,0,_);continue}if(e>n&&null!==u[a]){k(),B(a),a++;continue}k();continue}O(a,e),M(a,e),a++}else e>n&&null!==u[a]?B(a):S(a,e),M(a,e),a++;else m&&(w=a+1,v=0,A=a+1,x=g+l,_=g+l,N=t),a++}if(m){const t=A===e.consumedEndSegmentIndex?_:g;k(e.consumedEndSegmentIndex,0,t)}}return p}(t,n,n=>{r.push(Or(t,i,n))});return{lineCount:o,height:o*e,lines:r}}
|
|
137
189
|
/**
|
|
138
190
|
* Strips HTML and "un-escapes" escape characters.
|
|
139
191
|
* @param {String} input
|
|
140
|
-
*/function
|
|
192
|
+
*/function Br(t){if(""===t.replace(/\s+/g,""))return t;const n=(new DOMParser).parseFromString(t.replace(/<[^>]+>/g,""),"text/html");return n.documentElement?n.documentElement.textContent:t}
|
|
141
193
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
@param {Object} [style] An object of CSS font styles to apply. Accepts any of the valid [CSS font property](http://www.w3schools.com/cssref/pr_font_font.asp) values.
|
|
146
|
-
*/function D(t,e){e=Object.assign({"font-size":10,"font-family":"sans-serif","font-style":"normal","font-weight":400,"font-variant":"normal"},e);let n=document.createElement("canvas").getContext("2d");var r=[];return r.push(e["font-style"]),r.push(e["font-variant"]),r.push(e["font-weight"]),r.push("string"==typeof e["font-size"]?e["font-size"]:e["font-size"]+"px"),r.push(e["font-family"]),n.font=r.join(" "),t instanceof Array?t.map(t=>n.measureText(Pe(t)).width):n.measureText(Pe(t)).width}
|
|
194
|
+
* Builds a CSS font shorthand string from a style object.
|
|
195
|
+
* @param {Object} styleObj
|
|
196
|
+
*/
|
|
147
197
|
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
198
|
+
* Measures the width of a single text string using pretext.
|
|
199
|
+
* @param {String} text
|
|
200
|
+
* @param {String} font CSS font shorthand
|
|
201
|
+
*/
|
|
202
|
+
function Cr(t,n){if(!t)return 0;const e=Mr(kr(t,n),1/0,20);return e.lines.length?e.lines[0].width:0}function Wr(t,n={}){const e=`${(r=n)["font-style"]||"normal"} ${r["font-variant"]||"normal"} ${r["font-weight"]||400} ${"string"==typeof r["font-size"]?r["font-size"]:`${r["font-size"]||10}px`} ${r["font-family"]||"sans-serif"}`;var r;return t instanceof Array?t.map(t=>Cr(Br(t),e)):Cr(Br(t),e)}const $r="abcdefghiABCDEFGHI_!@#$%^&*()_+1234567890",Ir={};let Pr,Fr,Rr,Tr;
|
|
203
|
+
/**
|
|
204
|
+
Given either a single font-family or a list of fonts, returns the name of the first font that can be rendered, or `false` if none are installed on the user's machine.
|
|
205
|
+
@param font Can be either a valid CSS font-family string (single or comma-separated names) or an Array of string names.
|
|
206
|
+
*/
|
|
152
207
|
/**
|
|
153
|
-
|
|
208
|
+
Given an HTMLElement and a "width" or "height" string, this function returns the current calculated size for the DOM element.
|
|
154
209
|
@private
|
|
155
|
-
*/
|
|
210
|
+
*/
|
|
211
|
+
function zr(t,n){if(t){if(void 0===t.tagName||["BODY","HTML"].indexOf(t.tagName)>=0){let e=window[`inner${n.charAt(0).toUpperCase()+n.slice(1)}`];const r=gt(t);return"width"===n?(e-=parseFloat(r.style("margin-left")),e-=parseFloat(r.style("margin-right")),e-=parseFloat(r.style("padding-left")),e-=parseFloat(r.style("padding-right"))):(e-=parseFloat(r.style("margin-top")),e-=parseFloat(r.style("margin-bottom")),e-=parseFloat(r.style("padding-top")),e-=parseFloat(r.style("padding-bottom"))),e}{let e=t.getBoundingClientRect()[n];return"number"==typeof e&&e>0?("height"===n?(e-=parseFloat(gt(t).style("padding-top")),e-=parseFloat(gt(t).style("padding-bottom")),e-=parseFloat(gt(t).style("border-top")),e-=parseFloat(gt(t).style("border-bottom"))):(e-=parseFloat(gt(t).style("padding-left")),e-=parseFloat(gt(t).style("padding-right")),e-=parseFloat(gt(t).style("border-left")),e-=parseFloat(gt(t).style("border-right"))),e):zr(t.parentNode,n)}}}
|
|
156
212
|
/**
|
|
157
|
-
|
|
158
|
-
@desc Finds the available width and height for a specified HTMLElement, traversing it's parents until it finds something with constrained dimensions. Falls back to the inner dimensions of the browser window if none is found.
|
|
159
|
-
@param {HTMLElement} elem The HTMLElement to find dimensions for.
|
|
213
|
+
Finds the available width and height for a specified HTMLElement, traversing it's parents until it finds something with constrained dimensions. Falls back to the inner dimensions of the browser window if none is found.
|
|
160
214
|
@private
|
|
161
215
|
*/t.assign=
|
|
162
216
|
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
@example <caption>this</caption>
|
|
217
|
+
A deeply recursive version of `Object.assign`.
|
|
218
|
+
|
|
219
|
+
@example <caption>this</caption>
|
|
167
220
|
assign({id: "foo", deep: {group: "A"}}, {id: "bar", deep: {value: 20}}));
|
|
168
221
|
@example <caption>returns this</caption>
|
|
169
222
|
{id: "bar", deep: {group: "A", value: 20}}
|
|
170
|
-
|
|
223
|
+
@param objects The source objects to merge into the target.
|
|
224
|
+
*/
|
|
225
|
+
function t(...e){const r=e[0];for(let i=1;i<e.length;i++){const o=e[i];n(o)&&Object.keys(o).forEach(e=>{const i=o[e];var s;n(i)&&(s=i,"undefined"==typeof window||s!==window&&s!==document)?Object.prototype.hasOwnProperty.call(r,e)&&n(r[e])?r[e]=t({},r[e],i):r[e]=t({},i):Array.isArray(i)?r[e]=i.slice():r[e]=i})}return r}
|
|
226
|
+
/**
|
|
227
|
+
Given a DOM element, returns its background color by walking up the
|
|
228
|
+
ancestor chain until a non-transparent background is found. Falls back
|
|
229
|
+
to "rgb(255, 255, 255)" (white) if every ancestor is transparent.
|
|
230
|
+
@param elem The DOM element to check.
|
|
231
|
+
*/,t.attrize=e,t.backgroundColor=function(t){let n=t;for(;n;){const t=getComputedStyle(n).backgroundColor;if(t&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t)return t;n=n.parentElement}return"rgb(255, 255, 255)"},t.date=function(t){
|
|
171
232
|
// returns if falsey or already Date object
|
|
172
|
-
if([!1,void 0,NaN].includes(t)||t.constructor===Date)return t;if(t.constructor===Number
|
|
233
|
+
if([!1,void 0,NaN].includes(t)||t.constructor===Date)return t;if(t.constructor===Number&&`${t}`.length>5&&t%1==0)return new Date(t);let n=`${t}`;
|
|
173
234
|
// tests for MM/DD/YYYY and MM-DD-YYYY format
|
|
174
|
-
|
|
175
|
-
// detects if only passing a year value
|
|
176
|
-
e.includes("/")||e.includes(" ")||e.includes("-")&&e.indexOf("-")?new RegExp(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?$/g).exec(e)?new Date(e):new Date(e.replace(/-/g,"/")):((i=new Date(+e,0,1)).setFullYear(t),i)));
|
|
235
|
+
const e=new RegExp(/^\d{1,2}[./-]\d{1,2}[./-](-*\d{1,4})$/g).exec(n);if(e){const t=e[1];0===t.indexOf("-")&&(n=n.replace(t,t.substring(1)));const r=new Date(n);return r.setFullYear(t),r}
|
|
177
236
|
// tests for full Date object string format
|
|
237
|
+
const r=new RegExp(/^[A-z]{1,3} [A-z]{1,3} \d{1,2} (-*\d{1,4}) \d{1,2}:\d{1,2}:\d{1,2} [A-z]{1,3}-*\d{1,4} \([A-z]{1,3}\)/g).exec(n);if(r){const t=r[1];0===t.indexOf("-")&&(n=n.replace(t,t.substring(1)));const e=new Date(n);return e.setFullYear(t),e}
|
|
238
|
+
// tests for quarterly formats (ie. "QX YYYY" and "YYYY QX")
|
|
239
|
+
const i=new RegExp(/^([qQ]{1}[1-4]{1}|[1-4]{1}[qQ]{1})[\s|-]{0,1}(-*\d{1,4})$/g).exec(n),o=new RegExp(/^(-*\d{1,4})[\s|-]{0,1}([qQ]{1}[1-4]{1}|[1-4]{1}[qQ]{1})$/g).exec(n);if(i||o){const t=+(i?i[1]:o[2]).toLowerCase().replace("q",""),n=+(i?i[2]:o[1]),e=new Date(n,3*t-3,1);return e.setFullYear(n),e}
|
|
240
|
+
// tests for monthly formats (ie. "MM-YYYY" and "YYYY-MM")
|
|
241
|
+
const s=new RegExp(/^([-*\d]{1,2})-(-*\d{1,4})$/g).exec(n),u=new RegExp(/^(-*\d{1,4})-([-*\d]{1,2})$/g).exec(n);if(s||u){const t=+(s?s[1]:u[2]),n=+(s?s[2]:u[1]),e=new Date(n,t-1,1);return e.setFullYear(n),e}
|
|
242
|
+
// detects if only passing a year value
|
|
243
|
+
if(!(n.includes("/")||n.includes(" ")||n.includes("-")&&n.indexOf("-"))){const e=new Date(+n,0,1);return e.setFullYear(t),e}return new RegExp(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?$/g).exec(n)?new Date(n):new Date(n.replace(/-/g,"/"));
|
|
244
|
+
// falls back to Date object, replacing hyphens with slashes
|
|
178
245
|
},t.elem=
|
|
179
246
|
/**
|
|
180
|
-
|
|
181
|
-
@
|
|
182
|
-
@param
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
@param {Object} [params.enter = {}] A collection of key/value pairs that map to attributes to be given on enter.
|
|
186
|
-
@param {Object} [params.exit = {}] A collection of key/value pairs that map to attributes to be given on exit.
|
|
187
|
-
@param {D3Selection} [params.parent = d3.select("body")] The parent element for this new element to be appended to.
|
|
188
|
-
@param {Number} [params.duration = 0] The duration for the d3 transition.
|
|
189
|
-
@param {Object} [params.update = {}] A collection of key/value pairs that map to attributes to be given on update.
|
|
190
|
-
*/function(t,e){
|
|
247
|
+
Manages the enter/update/exit pattern for a single DOM element, applying enter, update, and exit attributes with optional transitions.
|
|
248
|
+
@param selector A CSS selector string for the element tag and classes.
|
|
249
|
+
@param p Configuration object with enter, exit, update, and parent options.
|
|
250
|
+
*/
|
|
251
|
+
function(t,n){
|
|
191
252
|
// overrides default params
|
|
192
|
-
|
|
253
|
+
const r=Object.assign({},{condition:!0,enter:{},exit:{},duration:0,parent:gt("body"),update:{}},n),i=/\.([^#]+)/g.exec(t),o=/#([^.]+)/g.exec(t),s=ue().duration(r.duration),u=/^([^.^#]+)/g.exec(t)[1],a=r.parent.selectAll(t.includes(":")?t.split(":")[1]:t).data(r.condition?[null]:[]),l=a.enter().append(u).call(e,r.enter);o&&l.attr("id",o[1]),i&&l.attr("class",i[1]),r.duration?a.exit().transition(s).call(e,r.exit).remove():a.exit().call(e,r.exit).remove();const c=l.merge(a);return r.duration?c.transition(s).call(e,r.update):c.call(e,r.update),c},t.fontExists=t=>{Pr||(Pr=Wr($r,{"font-family":"DejaVuSans","font-size":32}),Fr=Wr($r,{"font-family":"-apple-system","font-size":32}),Rr=Wr($r,{"font-family":"monospace","font-size":32}),Tr=Wr($r,{"font-family":"sans-serif","font-size":32})),t instanceof Array||(t=t.split(",")),t=t.map(t=>t.trim());for(let n=0;n<t.length;n++){const e=t[n];if(Ir[e]||["-apple-system","monospace","sans-serif","DejaVuSans"].includes(e))return e;if(!1===Ir[e])continue;const r=Wr($r,{"font-family":e,"font-size":32});if(Ir[e]=r!==Rr,Ir[e]&&(Ir[e]=r!==Tr),Fr&&Ir[e]&&(Ir[e]=r!==Fr),Pr&&Ir[e]&&(Ir[e]=r!==Pr),Ir[e])return e}return!1},t.getSize=function(t){return[zr(t,"width"),zr(t,"height")]}
|
|
193
254
|
/**
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
|
|
207
|
-
@
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
@function rtl
|
|
211
|
-
@desc Returns `true` if the HTML or body element has either the "dir" HTML attribute or the "direction" CSS property set to "rtl".
|
|
212
|
-
*/,t.rtl=()=>"rtl"===s("html").attr("dir")||"rtl"===s("body").attr("dir")||"rtl"===s("html").style("direction")||"rtl"===s("body").style("direction"),t.stylize=
|
|
213
|
-
/**
|
|
214
|
-
@function stylize
|
|
215
|
-
@desc Applies each key/value in an object as a style.
|
|
216
|
-
@param {D3selection} elem The D3 element to apply the styles to.
|
|
217
|
-
@param {Object} styles An object of key/value style pairs.
|
|
218
|
-
*/function(t,e={}){for(var n in e)!{}.hasOwnProperty.call(e,n)||t.style(n,e[n])},t.textWidth=D});
|
|
255
|
+
Determines whether a given DOM element is visible within the current viewport, with an optional pixel buffer.
|
|
256
|
+
@param elem The DOM element to check.
|
|
257
|
+
@param buffer Extra pixel margin around the viewport boundary.
|
|
258
|
+
*/,t.inViewport=function(t,n=0){const e=window.scrollX,r=window.scrollY,i=t.getBoundingClientRect(),o=i.height,s=i.left+e,u=i.top+r,a=i.width;return r+window.innerHeight>u+n&&r+n<u+o&&e+window.innerWidth>s+n&&e+n<s+a}
|
|
259
|
+
/**
|
|
260
|
+
Converts a string of directional CSS shorthand values into an object with the values expanded.
|
|
261
|
+
@param sides The CSS shorthand string to expand.
|
|
262
|
+
*/,t.isObject=n,t.parseSides=function(t){let n;return n="number"==typeof t?[`${t}`]:t.split(/\s+/),1===n.length?n=[n[0],n[0],n[0],n[0]]:2===n.length?n=n.concat(n):3===n.length&&n.push(n[1]),["top","right","bottom","left"].reduce((t,e,r)=>{const i=parseFloat(n[r]);return t[e]=i||0,t},{})}
|
|
263
|
+
/**
|
|
264
|
+
Returns `true` if the HTML or body element has either the "dir" HTML attribute or the "direction" CSS property set to "rtl".
|
|
265
|
+
*/,t.rtl=function(){return"rtl"===document.documentElement.dir||"rtl"===document.body.dir||"rtl"===getComputedStyle(document.documentElement).direction||"rtl"===getComputedStyle(document.body).direction}
|
|
266
|
+
/**
|
|
267
|
+
Applies each key/value in an object as a style.
|
|
268
|
+
@param e The d3 selection to apply styles to.
|
|
269
|
+
@param s An object of key/value style pairs.
|
|
270
|
+
*/,t.stylize=function(t,n={}){for(const e in n)({}).hasOwnProperty.call(n,e)&&t.style(e,n[e])},t.textWidth=Wr});
|
|
219
271
|
//# sourceMappingURL=d3plus-dom.full.js.map
|