@d3plus/dom 3.0.0-alpha.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.
@@ -0,0 +1,219 @@
1
+ /*
2
+ @d3plus/dom v3.0.0
3
+ JavaScript functions for manipulating and analyzing DOM elements.
4
+ Copyright (c) 2025 D3plus - https://d3plus.org
5
+ @license MIT
6
+ */
7
+ (t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){if("undefined"!=typeof window){try{if("undefined"==typeof SVGElement||Boolean(SVGElement.prototype.innerHTML))return}catch(t){return}function r(t){switch(t.nodeType){case 1:var n=t,e="";return e+="<"+n.tagName,n.hasAttributes()&&[].forEach.call(n.attributes,function(t){e+=" "+t.name+'="'+t.value+'"'}),e+=">",n.hasChildNodes()&&[].forEach.call(n.childNodes,function(t){e+=r(t)}),e+="</"+n.tagName+">";case 3:return t.textContent.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");case 8:return"\x3c!--"+t.nodeValue+"--\x3e"}}Object.defineProperty(SVGElement.prototype,"innerHTML",{get:function(){var n="";return[].forEach.call(this.childNodes,function(t){n+=r(t)}),n},set:function(t){for(;this.firstChild;)this.removeChild(this.firstChild);try{var n=new DOMParser,e=(n.async=!1,"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"+t+"</svg>"),r=n.parseFromString(e,"text/xml").documentElement;[].forEach.call(r.childNodes,function(t){this.appendChild(this.ownerDocument.importNode(t,!0))}.bind(this))}catch(t){throw new Error("Error parsing markup string")}}}),Object.defineProperty(SVGElement.prototype,"innerSVG",{get:function(){return this.innerHTML},set:function(t){this.innerHTML=t}})}}),((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
+ /**
9
+ @function isObject
10
+ @desc Detects if a variable is a javascript Object.
11
+ @param {*} item
12
+ */function a(t){return!(!t||"object"!=typeof t||"undefined"!=typeof window&&(t===window||t===window.document||t instanceof Element)||Array.isArray(t))}
13
+ /**
14
+ @function validObject
15
+ @desc Determines if the object passed is the document or window.
16
+ @param {Object} obj
17
+ @private
18
+ */
19
+ /**
20
+ @function attrize
21
+ @desc Applies each key/value in an object as an attr.
22
+ @param {D3selection} elem The D3 element to apply the styles to.
23
+ @param {Object} attrs An object of key/value attr pairs.
24
+ */function u(t,n={}){for(var e in n)!{}.hasOwnProperty.call(n,e)||t.attr(e,n[e])}
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 n=t+="",e=n.indexOf(":");return 0<=e&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),z.hasOwnProperty(n)?{space:z[n],local:t}:t;// eslint-disable-line no-prototype-builtins
31
+ }function H(t){t=i(t);return(t.local?function(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}:function(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===j&&t.documentElement.namespaceURI===j?t.createElement(e):t.createElementNS(n,e)}})(t)}function F(){}function R(t){return null==t?F:function(){return this.querySelector(t)}}function L(){return[]}function X(t){return null==t?L:function(){return this.querySelectorAll(t)}}function V(n){return function(){return null==(t=n.apply(this,arguments))?[]:Array.isArray(t)?t:Array.from(t);
32
+ // Given something array like (or null), returns something that is strictly an
33
+ // array. This is used to ensure that array-like objects passed to d3.selectAll
34
+ // or selection.selectAll are converted into proper arrays when creating a
35
+ // selection; we don’t ever want to create a selection backed by a live
36
+ // HTMLCollection or NodeList. However, note that selection.selectAll will use a
37
+ // static NodeList as a group, since it safely derived from querySelectorAll.
38
+ var t}}function Y(t){return function(){return this.matches(t)}}function I(n){return function(t){return t.matches(n)}}var B=Array.prototype.find;function G(){return this.firstElementChild}var U=Array.prototype.filter;function Q(){return Array.from(this.children)}function W(t){return new Array(t.length)}function d(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function K(t,n,e,r,i,o){
39
+ // Put any non-null nodes that fit into update.
40
+ // Put any null nodes into enter.
41
+ // Put any remaining data into enter.
42
+ for(var a,u=0,s=n.length,l=o.length;u<l;++u)(a=n[u])?(a.__data__=o[u],r[u]=a):e[u]=new d(t,o[u]);
43
+ // Put any non-null nodes that don’t fit into exit.
44
+ for(;u<s;++u)(a=n[u])&&(i[u]=a)}function J(t,n,e,r,i,o,a){
45
+ // Compute the key for each node.
46
+ // If multiple nodes have the same key, the duplicates are added to exit.
47
+ for(var u,s,l=new Map,c=n.length,h=o.length,f=new Array(c),p=0;p<c;++p)(u=n[p])&&(f[p]=s=a.call(u,u.__data__,p,n)+"",l.has(s)?i[p]=u:l.set(s,u));
48
+ // Compute the key for each datum.
49
+ // If there a node associated with this key, join and add it to update.
50
+ // If there is not (or the key is a duplicate), add it to enter.
51
+ for(p=0;p<h;++p)s=a.call(t,o[p],p,o)+"",(u=l.get(s))?((r[p]=u).__data__=o[p],l.delete(s)):e[p]=new d(t,o[p]);
52
+ // Add any remaining nodes that were not bound to data to exit.
53
+ for(p=0;p<c;++p)(u=n[p])&&l.get(f[p])===u&&(i[p]=u)}function Z(t){return t.__data__}function tt(t,n){return t<n?-1:n<t?1:n<=t?0:NaN}function nt(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView;// node is a Document
54
+ }function $(t,n){return t.style.getPropertyValue(n)||nt(t).getComputedStyle(t,null).getPropertyValue(n)}function et(t){return t.trim().split(/^|\s+/)}function rt(t){return t.classList||new it(t)}function it(t){this._node=t,this._names=et(t.getAttribute("class")||"")}function ot(t,n){for(var e=rt(t),r=-1,i=n.length;++r<i;)e.add(n[r])}function at(t,n){for(var e=rt(t),r=-1,i=n.length;++r<i;)e.remove(n[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),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}function dt(){var t=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}function yt(o){return function(){var t=this.__on;if(t){for(var n,e=0,r=-1,i=t.length;e<i;++e)n=t[e],o.type&&n.type!==o.type||n.name!==o.name?t[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?t.length=r:delete this.__on}}}function gt(a,u,s){return function(){function t(t){e.call(this,t,this.__data__)}var n,e,r=this.__on;e=u;if(r)for(var i=0,o=r.length;i<o;++i)if((n=r[i]).type===a.type&&n.name===a.name)return this.removeEventListener(n.type,n.listener,n.options),this.addEventListener(n.type,n.listener=t,n.options=s),void(n.value=u);this.addEventListener(a.type,t,s),n={type:a.type,name:a.name,value:u,listener:t,options:s},r?r.push(n):this.__on=[n]}}function mt(t,n,e){var r=nt(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)}d.prototype={constructor:d,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)}},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,n){this._groups=t,this._parents=n}function n(){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=n.prototype={constructor:x,select:function(t){"function"!=typeof t&&(t=R(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a,u=n[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?V:X)(t);for(var n=this._groups,e=n.length,r=[],i=[],o=0;o<e;++o)for(var a,u=n[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:(n="function"==typeof t?t:I(t),function(){return B.call(this.children,n)}));var n},selectChildren:function(t){return this.selectAll(null==t?Q:(n="function"==typeof t?t:I(t),function(){return U.call(this.children,n)}));var n},filter:function(t){"function"!=typeof t&&(t=Y(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a=n[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,n){if(!arguments.length)return Array.from(this,Z);var e,r=n?J:K,i=this._parents,o=this._groups;"function"!=typeof t&&(e=t,t=function(){return e});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,n);
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}
59
+ // Given some data, this returns an array-like view of it: an object that
60
+ // exposes a length property and allows numeric indexing. Note that unlike
61
+ // selectAll, this isn’t worried about “live” collections because the resulting
62
+ // array will only be used briefly while data is being bound. (It is possible to
63
+ // cause the data to change while iterating by using a key function, but please
64
+ // don’t; we’d rather avoid a gratuitous copy.)
65
+ ,enter:function(){return new x(this._enter||this._groups.map(W),this._parents)},exit:function(){return new x(this._exit||this._groups.map(W),this._parents)},join:function(t,n,e){var r=this.enter(),i=this,o=this.exit(),r="function"==typeof t?(r=t(r))&&r.selection():r.append(t+"");return null!=n&&(i=(i=n(i))&&i.selection()),null==e?o.remove():e(o),r&&i?r.merge(i).order():i},merge:function(t){for(var t=t.selection?t.selection():t,n=this._groups,e=t._groups,r=n.length,t=e.length,i=Math.min(r,t),o=new Array(r),a=0;a<i;++a)for(var u,s=n[a],l=e[a],c=s.length,h=o[a]=new Array(c),f=0;f<c;++f)(u=s[f]||l[f])&&(h[f]=u);for(;a<r;++a)o[a]=n[a];return new x(o,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,a=i[o];0<=--o;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e=e||tt;for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var a,u=n[o],s=u.length,l=i[o]=new Array(s),c=0;c<s;++c)(a=u[c])&&(l[c]=a);l.sort(t)}return new x(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 a=r[i];if(a)return a}return null},size:function(){let t=0;for(var n of this)++t;// eslint-disable-line no-unused-vars
66
+ 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],a=0,u=o.length;a<u;++a)(i=o[a])&&t.call(i,i.__data__,a,o);return this},attr:function(t,n){var e,t=i(t);return arguments.length<2?(e=this.node(),t.local?e.getAttributeNS(t.space,t.local):e.getAttribute(t)):this.each((null==n?t.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}}:"function"==typeof n?t.local?function(n,e){return function(){var t=e.apply(this,arguments);null==t?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,t)}}:function(n,e){return function(){var t=e.apply(this,arguments);null==t?this.removeAttribute(n):this.setAttribute(n,t)}}:t.local?function(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}:function(t,n){return function(){this.setAttribute(t,n)}})(t,n))},style:function(t,n,e){return 1<arguments.length?this.each((null==n?function(t){return function(){this.style.removeProperty(t)}}:"function"==typeof n?function(n,e,r){return function(){var t=e.apply(this,arguments);null==t?this.style.removeProperty(n):this.style.setProperty(n,t,r)}}:function(t,n,e){return function(){this.style.setProperty(t,n,e)}})(t,n,null==e?"":e)):$(this.node(),t)},property:function(t,n){return 1<arguments.length?this.each((null==n?function(t){return function(){delete this[t]}}:"function"==typeof n?function(n,e){return function(){var t=e.apply(this,arguments);null==t?delete this[n]:this[n]=t}}:function(t,n){return function(){this[t]=n}})(t,n)):this.node()[t]},classed:function(t,n){var e=et(t+"");if(arguments.length<2){for(var r=rt(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each(("function"==typeof n?function(t,n){return function(){(n.apply(this,arguments)?ot:at)(this,t)}}:n?function(t){return function(){ot(this,t)}}:function(t){return function(){at(this,t)}})(e,n))},text:function(t){return arguments.length?this.each(null==t?ut:("function"==typeof t?function(n){return function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}}:function(t){return function(){this.textContent=t}})(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?st:("function"==typeof t?function(n){return function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}}:function(t){return function(){this.innerHTML=t}})(t)):this.node().innerHTML},raise:function(){return this.each(lt)},lower:function(){return this.each(ct)},append:function(t){var n="function"==typeof t?t:H(t);return this.select(function(){return this.appendChild(n.apply(this,arguments))})},insert:function(t,n){var e="function"==typeof t?t:H(t),r=null==n?ht:"function"==typeof n?n:R(n);return this.select(function(){return this.insertBefore(e.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(ft)},clone:function(t){return this.select(t?dt:pt)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,n,e){var r,i,o=(t+"").trim().split(/^|\s+/).map(function(t){var n="",e=t.indexOf(".");return 0<=e&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}}),a=o.length;if(!(arguments.length<2)){for(u=n?gt:yt,r=0;r<a;++r)this.each(u(o[r],n,e));return this}var u=this.node().__on;if(u)for(var s,l=0,c=u.length;l<c;++l)for(r=0,s=u[l];r<a;++r)if((i=o[r]).type===s.type&&i.name===s.name)return s.value},dispatch:function(t,n){return this.each(("function"==typeof n?function(t,n){return function(){return mt(this,t,n.apply(this,arguments))}}:function(t,n){return function(){return mt(this,t,n)}})(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,a=i.length;o<a;++o)(r=i[o])&&(yield r)}};var vt={value:()=>{}};function _t(){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 o(r)}function o(t){this._=t}function bt(t,n,e){for(var r=0,i=t.length;r<i;++r)if(t[r].name===n){t[r]=vt,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=e&&t.push({name:n,value:e}),t}o.prototype=_t.prototype={constructor:o,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(0<=e&&(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}})),a=-1,u=o.length;
67
+ // If no callback was specified, return the callback of the given type and name.
68
+ if(!(arguments.length<2)){
69
+ // If a type was specified, set the callback for the given type and name.
70
+ // Otherwise, if a null callback was specified, remove callbacks of the given name.
71
+ if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++a<u;)if(e=(t=o[a]).type)i[e]=bt(i[e],t.name,n);else if(null==n)for(e in i)i[e]=bt(i[e],t.name,null);return this}for(;++a<u;)if(e=(e=(t=o[a]).type)&&((t,n)=>{for(var e,r=0,i=t.length;r<i;++r)if((e=t[r]).name===n)return e.value})(i[e],t.name))return e},copy:function(){var t,n={},e=this._;for(t in e)n[t]=e[t].slice();return new o(n)},call:function(t,n){if(0<(e=arguments.length-2))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 l,c,h=0,f=0,e=0,xt=1e3,p=0,y=0,g=0,m="object"==typeof performance&&performance.now?performance:Date,At="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Nt(){return y||(At(Et),y=m.now()+g)}function Et(){y=0}function w(){this._call=this._time=this._next=null}function kt(t,n,e){var r=new w;return r.restart(t,n,e),r}function St(){y=(p=m.now())+g,h=f=0;try{Nt(),// Get the current time, if not already set.
72
+ ++h;for(// Pretend we’ve set an alarm, if we haven’t already.
73
+ var t,n=l;n;)0<=(t=y-n._time)&&n._call.call(void 0,t),n=n._next;--h}finally{for(var e,r,i=l,o=1/(h=0);i;)i=i._call?(o>i._time&&(o=i._time),(e=i)._next):(r=i._next,i._next=null,e?e._next=r:l=r);c=e,$t(o),y=0}}function Mt(){var t=m.now(),n=t-p;xt<n&&(g-=n,p=t)}function $t(t){h||(// Soonest alarm already set, or will be.
74
+ f=f&&clearTimeout(f),// Strictly less than if we recomputed clockNow.
75
+ 24<t-y?(t<1/0&&(f=setTimeout(St,t-m.now()-g)),e=e&&clearInterval(e)):(e||(p=m.now(),e=setInterval(Mt,xt)),h=1,At(St)))}function Ot(n,e,t){var r=new w;return e=null==e?0:+e,r.restart(t=>{r.stop(),n(t+e)},e,t),r}w.prototype=kt.prototype={constructor:w,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?Nt():+e)+(null==n?0:+n),this._next||c===this||(c?c._next=this:l=this,c=this),this._call=t,this._time=e,$t()},stop:function(){this._call&&(this._call=null,this._time=1/0,$t())}};var Ct=_t("start","end","cancel","interrupt"),Tt=[],qt=0,Pt=1,Dt=2,jt=3,zt=4,Ht=5,Ft=6;function Rt(t,n,e,r,i,o){var a,u,s,l,c,h=t.__transition;if(h){if(e in h)return}else t.__transition={};function f(t){var n,e,r,i;
76
+ // If the state is not SCHEDULED, then we previously errored on start.
77
+ if(s.state!==Pt)return d();for(n in c)if((i=c[n]).name===s.name){
78
+ // While this element already has a starting transition during this frame,
79
+ // defer starting an interrupting transition until that transition has a
80
+ // chance to tick (and possibly end); see d3/d3-transition#54!
81
+ if(i.state===jt)return Ot(f);
82
+ // Interrupt the active transition, if any.
83
+ i.state===zt?(i.state=Ft,i.timer.stop(),i.on.call("interrupt",a,a.__data__,i.index,i.group),delete c[n]):+n<u&&(i.state=Ft,i.timer.stop(),i.on.call("cancel",a,a.__data__,i.index,i.group),delete c[n])}
84
+ // Defer the first tick to end of the current frame; see d3/d3#1576.
85
+ // Note the transition may be canceled after start and before the first tick!
86
+ // Note this must be scheduled before the start event; see d3/d3-transition#16!
87
+ // Assuming this is successful, subsequent callbacks go straight to tick.
88
+ if(Ot(function(){s.state===jt&&(s.state=zt,s.timer.restart(p,s.delay,s.time),p(t))}),
89
+ // Dispatch the start event.
90
+ // Note this must be done before the tween are initialized.
91
+ s.state=Dt,s.on.call("start",a,a.__data__,s.index,s.group),s.state===Dt){for(// interrupted
92
+ s.state=jt,
93
+ // Initialize the tween, deleting null tween.
94
+ l=new Array(r=s.tween.length),n=0,e=-1;n<r;++n)(i=s.tween[n].value.call(a,a.__data__,s.index,s.group))&&(l[++e]=i);l.length=e+1}}function p(t){for(var n=t<s.duration?s.ease.call(null,t/s.duration):(s.timer.restart(d),s.state=Ht,1),e=-1,r=l.length;++e<r;)l[e].call(a,n);
95
+ // Dispatch the end event.
96
+ s.state===Ht&&(s.on.call("end",a,a.__data__,s.index,s.group),d())}function d(){for(var t in s.state=Ft,s.timer.stop(),delete c[u],c)return;// eslint-disable-line no-unused-vars
97
+ delete a.__transition}a=t,u=e,s={name:n,index:r,group:i,on:Ct,tween:Tt,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:qt},(
98
+ // Initialize the self timer when the transition is created.
99
+ // Note the actual delay is not known until the first callback!
100
+ (c=a.__transition)[u]=s).timer=kt(function(t){s.state=Pt,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,n){t=v(t,n);if(t.state>qt)throw new Error("too late; already scheduled");return t}function O(t,n){t=v(t,n);if(t.state>jt)throw new Error("too late; already running");return t}function v(t,n){t=t.__transition;if(t=t&&t[n])return t;throw new Error("transition not found")}function Xt(t,n,e){(t.prototype=n.prototype=e).constructor=t}function Vt(t,n){var e,r=Object.create(t.prototype);for(e in n)r[e]=n[e];return r}function _(){}var r="\\s*([+-]?\\d+)\\s*",b="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",A="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Yt=/^#([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 Jt(){return this.rgb().formatHex()}function Zt(){return this.rgb().formatRgb()}function N(t){var n,e;return t=(t+"").trim().toLowerCase(),(n=Yt.exec(t))?(e=n[1].length,n=parseInt(n[1],16),6===e?tn(n):3===e?new E(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?nn(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?nn(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=It.exec(t))?new E(n[1],n[2],n[3],1):(n=Bt.exec(t))?new E(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=Gt.exec(t))?nn(n[1],n[2],n[3],n[4]):(n=Ut.exec(t))?nn(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=Qt.exec(t))?un(n[1],n[2]/100,n[3]/100,1):(n=Wt.exec(t))?un(n[1],n[2]/100,n[3]/100,n[4]):Kt.hasOwnProperty(t)?tn(Kt[t]):"transparent"===t?new E(NaN,NaN,NaN,0):null}function tn(t){return new E(t>>16&255,t>>8&255,255&t,1)}function nn(t,n,e,r){return new E(t=r<=0?n=e=NaN:t,n,e,r)}function en(t,n,e,r){return 1===arguments.length?(i=(i=t)instanceof _?i:N(i))?new E((i=i.rgb()).r,i.g,i.b,i.opacity):new E:new E(t,n,e,null==r?1:r);var i}function E(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function rn(){return"#"+S(this.r)+S(this.g)+S(this.b)}function on(){var t=an(this.opacity);return(1===t?"rgb(":"rgba(")+k(this.r)+`, ${k(this.g)}, `+k(this.b)+(1===t?")":`, ${t})`)}function an(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 un(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||1<=e?t=n=NaN:n<=0&&(t=NaN),new M(t,n,e,r)}function sn(t){var n,e,r,i,o,a,u,s;return t instanceof M?new M(t.h,t.s,t.l,t.opacity):(t=t instanceof _?t:N(t))?t instanceof M?t:(n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),a=NaN,s=((o=Math.max(n,e,r))+i)/2,(u=o-i)?(a=n===o?(e-r)/u+6*(e<r):e===o?(r-n)/u+2:(n-e)/u+4,u/=s<.5?o+i:2-o-i,a*=60):u=0<s&&s<1?0:a,new M(a,u,s,t.opacity)):new M}function M(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function ln(t){return(t=(t||0)%360)<0?t+360:t}function cn(t){return Math.max(0,Math.min(1,t||0))}
103
+ /* From FvD 13.37, CSS Color Module Level 3 */function hn(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(_,N,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Jt,formatHex:Jt,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return sn(this).formatHsl()},formatRgb:Zt,toString:Zt}),Xt(E,en,Vt(_,{brighter(t){return t=null==t?1/.7:Math.pow(1/.7,t),new E(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?.7:Math.pow(.7,t),new E(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new E(k(this.r),k(this.g),k(this.b),an(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:rn,formatHex:rn,formatHex8:function(){return"#"+S(this.r)+S(this.g)+S(this.b)+S(255*(isNaN(this.opacity)?1:this.opacity))},formatRgb:on,toString:on})),Xt(M,function(t,n,e,r){return 1===arguments.length?sn(t):new M(t,n,e,null==r?1:r)},Vt(_,{brighter(t){return t=null==t?1/.7:Math.pow(1/.7,t),new M(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?.7:Math.pow(.7,t),new M(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,n=e+(e<.5?e:1-e)*n,e=2*e-n;return new E(hn(240<=t?t-240:120+t,e,n),hn(t,e,n),hn(t<120?240+t:t-120,e,n),this.opacity)},clamp(){return new M(ln(this.h),cn(this.s),cn(this.l),an(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=an(this.opacity);return(1===t?"hsl(":"hsla(")+ln(this.h)+`, ${100*cn(this.s)}%, ${100*cn(this.l)}%`+(1===t?")":`, ${t})`)}}));var fn=t=>()=>t;function pn(o){return 1==(o=+o)?dn:function(t,n){return n-t?(e=t,r=n,i=o,e=Math.pow(e,i),r=Math.pow(r,i)-e,i=1/i,function(t){return Math.pow(e+t*r,i)}):fn(isNaN(t)?n:t);var e,r,i}}function dn(t,n){var e,r,i=n-t;return i?(e=t,r=i,function(t){return e+t*r}):fn(isNaN(t)?n:t)}var yn=function t(n){var a=pn(n);function e(n,t){var e=a((n=en(n)).r,(t=en(t)).r),r=a(n.g,t.g),i=a(n.b,t.b),o=dn(n.opacity,t.opacity);return function(t){return n.r=e(t),n.g=r(t),n.b=i(t),n.opacity=o(t),n+""}}return e.gamma=t,e}(1);function C(n,e){return n=+n,e=+e,function(t){return n*(1-t)+e*t}}var gn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,mn=new RegExp(gn.source,"g");var wn,vn=180/Math.PI,_n={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function bn(t,n,e,r,i,o){var a,u,s;return(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a),(s=t*e+n*r)&&(e-=t*s,r-=n*s),(u=Math.sqrt(e*e+r*r))&&(e/=u,r/=u,s/=u),t*r<n*e&&(t=-t,n=-n,s=-s,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(n,t)*vn,skewX:Math.atan(s)*vn,scaleX:a,scaleY:u}}function xn(f,p,d,y){function g(t){return t.length?t.pop()+" ":""}return function(t,n){var e,r,i,o,a,u,s,l,c=[],h=[];// number interpolators
104
+ // gc
105
+ return t=f(t),n=f(n),r=t.translateX,i=t.translateY,s=n.translateX,a=n.translateY,u=c,o=h,r!==s||i!==a?(e=u.push("translate(",null,p,null,d),o.push({i:e-4,x:C(r,s)},{i:e-2,x:C(i,a)})):(s||a)&&u.push("translate("+s+p+a+d),o=t.rotate,r=c,e=h,o!==(i=n.rotate)?(180<o-i?i+=360:180<i-o&&(o+=360),// shortest path
106
+ e.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=n.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=n.scaleY,u=c,s=h,r!==(o=n.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=n=null,function(t){for(var n,e=-1,r=h.length;++e<r;)c[(n=h[e]).i]=n.x(t);return c.join("")}}}var An=xn(
107
+ /* eslint-disable no-undef */function(t){return(t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"")).isIdentity?_n:bn(t.a,t.b,t.c,t.d,t.e,t.f)},"px, ","px)","deg)"),Nn=xn(function(t){return null!=t&&((wn=wn||document.createElementNS("http://www.w3.org/2000/svg","g")).setAttribute("transform",t),t=wn.transform.baseVal.consolidate())?bn((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):_n},", ",")",")");function En(t,n,e){var r=t._id;return t.each(function(){var t=O(this,r);(t.value||(t.value={}))[n]=e.apply(this,arguments)}),function(t){return v(t,r).value[n]}}function kn(t,n){var e;return("number"==typeof n?C:n instanceof N?yn:(e=N(n))?(n=e,yn):function(t,r){var n,e,i,o,a,u=gn.lastIndex=mn.lastIndex=0,s=-1,l=[],c=[];// number interpolators
108
+ // Coerce inputs to strings.
109
+ // Interpolate pairs of numbers in a & b.
110
+ for(t+="",r+="";(n=gn.exec(t))&&(e=mn.exec(r));)(i=e.index)>u&&(i=r.slice(u,i),l[s]?l[s]+=i:l[++s]=i),(n=n[0])===(e=e[0])?l[s]?l[s]+=e:l[++s]=e:(l[++s]=null,c.push({i:s,x:C(n,e)})),u=mn.lastIndex;
111
+ // Add remains of b.
112
+ // Special optimization for only a single match.
113
+ // Otherwise, interpolate each of the numbers and rejoin the string.
114
+ return u<r.length&&(i=r.slice(u),l[s]?l[s]+=i:l[++s]=i),l.length<2?c[0]?(a=c[0].x,function(t){return a(t)+""}):(o=r,function(){return o}):(r=c.length,function(t){for(var n,e=0;e<r;++e)l[(n=c[e]).i]=n.x(t);return l.join("")})})(t,n)}function Sn(r,i){var o,a;function t(){var n,e,t=i.apply(this,arguments);return o=t!==a?(a=t)&&(n=r,e=t,function(t){this.setAttributeNS(n.space,n.local,e.call(this,t))}):o}return t._value=i,t}function Mn(r,i){var o,a;function t(){var n,e,t=i.apply(this,arguments);return o=t!==a?(a=t)&&(n=r,e=t,function(t){this.setAttribute(n,e.call(this,t))}):o}return t._value=i,t}var $n=n.prototype.constructor;function On(t){return function(){this.style.removeProperty(t)}}function Cn(i,o,a){var u,s;function t(){var n,e,r,t=o.apply(this,arguments);return u=t!==s?(s=t)&&(n=i,e=t,r=a,function(t){this.style.setProperty(n,e.call(this,t),r)}):u}return t._value=o,t}function Tn(e){var r,i;function t(){var n,t=e.apply(this,arguments);return r=t!==i?(i=t)&&(n=t,function(t){this.textContent=n.call(this,t)}):r}return t._value=e,t}var qn=0;function T(t,n,e,r){this._groups=t,this._parents=n,this._name=e,this._id=r}function Pn(t){return n().transition(t)}r=n.prototype;T.prototype=Pn.prototype={constructor:T,select:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=R(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a<i;++a)for(var u,s,l=r[a],c=l.length,h=o[a]=new Array(c),f=0;f<c;++f)(u=l[f])&&(s=t.call(u,u.__data__,f,l))&&("__data__"in u&&(s.__data__=u.__data__),h[f]=s,Rt(h[f],n,e,f,h,v(u,e)));return new T(o,this._parents,n,e)},selectAll:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=X(t));for(var r=this._groups,i=r.length,o=[],a=[],u=0;u<i;++u)for(var s,l=r[u],c=l.length,h=0;h<c;++h)if(s=l[h]){for(var f,p=t.call(s,s.__data__,h,l),d=v(s,e),y=0,g=p.length;y<g;++y)(f=p[y])&&Rt(f,n,e,y,p,d);o.push(p),a.push(s)}return new T(o,a,n,e)},selectChild:r.selectChild,selectChildren:r.selectChildren,filter:function(t){"function"!=typeof t&&(t=Y(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a=n[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 T(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,t=e.length,i=Math.min(r,t),o=new Array(r),a=0;a<i;++a)for(var u,s=n[a],l=e[a],c=s.length,h=o[a]=new Array(c),f=0;f<c;++f)(u=s[f]||l[f])&&(h[f]=u);for(;a<r;++a)o[a]=n[a];return new T(o,this._parents,this._name,this._id)},selection:function(){return new $n(this._groups,this._parents)},transition:function(){for(var t=this._name,n=this._id,e=++qn,r=this._groups,i=r.length,o=0;o<i;++o)for(var a,u=r[o],s=u.length,l=0;l<s;++l)(a=u[l])&&Rt(a,t,e,l,u,{time:(a=v(a,n)).time+a.delay+a.duration,delay:0,duration:a.duration,ease:a.ease});return new T(r,this._parents,t,e)},call:r.call,nodes:r.nodes,node:r.node,size:r.size,empty:r.empty,each:r.each,on:function(t,n){var e,r,i,o,a,u,s=this._id;return arguments.length<2?v(this.node(),s).on.on(t):this.each((e=s,i=n,u=((r=t)+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return!(t=0<=n?t.slice(0,n):t)||"start"===t})?Lt:O,function(){var t=u(this,e),n=t.on;
115
+ // If this node shared a dispatch with the previous node,
116
+ // just assign the updated shared dispatch and we’re done!
117
+ // Otherwise, copy-on-write.
118
+ n!==o&&(a=(o=n).copy()).on(r,i),t.on=a}))},attr:function(t,n){var e=i(t),r="transform"===e?Nn:kn;return this.attrTween(t,"function"==typeof n?(e.local?function(r,i,o){var a,u,s;return function(){var t,n,e=o(this);if(null!=e)return(t=this.getAttributeNS(r.space,r.local))===(n=e+"")?null:t===a&&n===u?s:(u=n,s=i(a=t,e));this.removeAttributeNS(r.space,r.local)}}:function(r,i,o){var a,u,s;return function(){var t,n,e=o(this);if(null!=e)return(t=this.getAttribute(r))===(n=e+"")?null:t===a&&n===u?s:(u=n,s=i(a=t,e));this.removeAttribute(r)}})(e,r,En(this,"attr."+t,n)):null==n?(e.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}})(e):(e.local?function(n,e,r){var i,o,a=r+"";return function(){var t=this.getAttributeNS(n.space,n.local);return t===a?null:t===i?o:o=e(i=t,r)}}:function(n,e,r){var i,o,a=r+"";return function(){var t=this.getAttribute(n);return t===a?null:t===i?o:o=e(i=t,r)}})(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;return t=i(t),this.tween(e,(t.local?Sn:Mn)(t,n))},style:function(t,n,e){var r,i,o,a,u,s,l,c,h,f,p,d,y,g,m,w,v,_,b,x,A,N,E,k,S,M="transform"==(t+="")?An:kn;return null==n?this.styleTween(t,(A=t,N=M,function(){var t=$(this,A),n=(this.style.removeProperty(A),$(this,A));return t===n?null:t===E&&n===k?S:S=N(E=t,k=n)})).on("end.style."+t,On(t)):"function"==typeof n?this.styleTween(t,(w=M,v=En(this,"style."+(m=t),n),function(){var t=$(this,m),n=v(this),e=n+"";return null==n&&(this.style.removeProperty(m),e=n=$(this,m)),t===e?null:t===_&&e===b?x:(b=e,x=w(_=t,n))})).each((l=this._id,g="end."+(y="style."+(c=t)),function(){var t=O(this,l),n=t.on,e=null==t.value[y]?d=d||On(c):void 0;
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
+ n===h&&p===e||(f=(h=n).copy()).on(g,p=e),t.on=f})):this.styleTween(t,(r=t,i=M,s=(o=n)+"",function(){var t=$(this,r);return t===s?null:t===a?u:u=i(a=t,o)}),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,Cn(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?(e=En(this,"text",t),function(){var t=e(this);this.textContent=null==t?"":t}):(n=null==t?"":t+"",function(){this.textContent=n}));var n,e},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,Tn(t))},remove:function(){return this.on("end.remove",(e=this._id,function(){var t,n=this.parentNode;for(t in this.__transition)if(+t!==e)return;n&&n.removeChild(this)}));var e},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=v(this.node(),e).tween,o=0,a=i.length;o<a;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==n?function(i,o){var a,u;return function(){var t=O(this,i),n=t.tween;
123
+ // If this node shared tween with the previous node,
124
+ // just assign the updated shared tween and we’re done!
125
+ // Otherwise, copy-on-write.
126
+ if(n!==a)for(var e=0,r=(u=a=n).length;e<r;++e)if(u[e].name===o){(u=u.slice()).splice(e,1);break}t.tween=u}}:function(o,a,u){var s,l;if("function"!=typeof u)throw new Error;return function(){var t=O(this,o),n=t.tween;
127
+ // If this node shared tween with the previous node,
128
+ // just assign the updated shared tween and we’re done!
129
+ // Otherwise, copy-on-write.
130
+ if(n!==s){l=(s=n).slice();for(var e={name:a,value:u},r=0,i=l.length;r<i;++r)if(l[r].name===a){l[r]=e;break}r===i&&l.push(e)}t.tween=l}})(e,t,n))},delay:function(t){var n=this._id;return arguments.length?this.each(("function"==typeof t?function(t,n){return function(){Lt(this,t).delay=+n.apply(this,arguments)}}:function(t,n){return n=+n,function(){Lt(this,t).delay=n}})(n,t)):v(this.node(),n).delay},duration:function(t){var n=this._id;return arguments.length?this.each(("function"==typeof t?function(t,n){return function(){O(this,t).duration=+n.apply(this,arguments)}}:function(t,n){return n=+n,function(){O(this,t).duration=n}})(n,t)):v(this.node(),n).duration},ease:function(t){var n=this._id;return arguments.length?this.each(((t,n)=>{if("function"!=typeof n)throw new Error;return function(){O(this,t).ease=n}})(n,t)):v(this.node(),n).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each((n=this._id,e=t,function(){var t=e.apply(this,arguments);if("function"!=typeof t)throw new Error;O(this,n).ease=t}));var n,e},end:function(){var i,o,a=this,u=a._id,s=a.size();return new Promise(function(t,n){var e={value:n},r={value:function(){0==--s&&t()}};a.each(function(){var t=O(this,u),n=t.on;
131
+ // If this node shared a dispatch with the previous node,
132
+ // just assign the updated shared dispatch and we’re done!
133
+ // Otherwise, copy-on-write.
134
+ n!==i&&((o=(i=n).copy())._.cancel.push(e),o._.interrupt.push(e),o._.end.push(r)),t.on=o}),
135
+ // The selection was empty, resolve end immediately
136
+ 0===s&&t()})},[Symbol.iterator]:r[Symbol.iterator]};var Dn={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};
137
+ /**
138
+ * Strips HTML and "un-escapes" escape characters.
139
+ * @param {String} input
140
+ */function jn(t){var n;return""!==t.replace(/\s+/g,"")&&(n=(new DOMParser).parseFromString(t.replace(/<[^>]+>/g,""),"text/html")).documentElement?n.documentElement.textContent:t}
141
+ /**
142
+ @function textWidth
143
+ @desc Given a text string, returns the predicted pixel width of the string when placed into DOM.
144
+ @param {String|Array} text Can be either a single string or an array of strings to analyze.
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 q(t,n){n=Object.assign({"font-size":10,"font-family":"sans-serif","font-style":"normal","font-weight":400,"font-variant":"normal"},n);let e=document.createElement("canvas").getContext("2d");var r=[];return r.push(n["font-style"]),r.push(n["font-variant"]),r.push(n["font-weight"]),r.push("string"==typeof n["font-size"]?n["font-size"]:n["font-size"]+"px"),r.push(n["font-family"]),e.font=r.join(" "),t instanceof Array?t.map(t=>e.measureText(jn(t)).width):e.measureText(jn(t)).width}
147
+ /**
148
+ @function trim
149
+ @desc Cross-browser implementation of [trim](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim).
150
+ @param {String} str
151
+ */n.prototype.interrupt=function(u){return this.each(function(){var t,n,e,r=this,i=u,o=r.__transition,a=!0;if(o){for(e in i=null==i?null:i+"",o)(t=o[e]).name!==i?a=!1:(n=Dt<t.state&&t.state<Ht,t.state=Ft,t.timer.stop(),t.on.call(n?"interrupt":"cancel",r,r.__data__,t.index,t.group),delete o[e]);a&&delete r.__transition}})},n.prototype.transition=function(t){var n,e;t=t instanceof T?(n=t._id,t._name):(n=++qn,(e=Dn).time=Nt(),null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var a,u=r[o],s=u.length,l=0;l<s;++l)(a=u[l])&&Rt(a,t,n,l,u,e||((t,n)=>{for(var e;!(e=t.__transition)||!(e=e[n]);)if(!(t=t.parentNode))throw new Error(`transition ${n} not found`);return e})(a,n));return new T(r,this._parents,t,n)};let P="abcdefghiABCDEFGHI_!@#$%^&*()_+1234567890",D={},zn,Hn,Fn,Rn;
152
+ /**
153
+ @desc Given an HTMLElement and a "width" or "height" string, this function returns the current calculated size for the DOM element.
154
+ @private
155
+ */function Ln(n,e){if(n){if(void 0===n.tagName||0<=["BODY","HTML"].indexOf(n.tagName)){let t=window["inner"+(e.charAt(0).toUpperCase()+e.slice(1))];var r=s(n);return t="width"===e?(t=(t=(t-=parseFloat(r.style("margin-left"),10))-parseFloat(r.style("margin-right"),10))-parseFloat(r.style("padding-left"),10))-parseFloat(r.style("padding-right"),10):(t=(t=(t-=parseFloat(r.style("margin-top"),10))-parseFloat(r.style("margin-bottom"),10))-parseFloat(r.style("padding-top"),10))-parseFloat(r.style("padding-bottom"),10)}return"number"==typeof(r=parseFloat(s(n).style(e),10))&&0<r?r:Ln(n.parentNode,e)}}
156
+ /**
157
+ @function getSize
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.
160
+ @private
161
+ */t.assign=
162
+ /**
163
+ @function assign
164
+ @desc A deeply recursive version of `Object.assign`.
165
+ @param {...Object} objects
166
+ @example <caption>this</caption>
167
+ assign({id: "foo", deep: {group: "A"}}, {id: "bar", deep: {value: 20}}));
168
+ @example <caption>returns this</caption>
169
+ {id: "bar", deep: {group: "A", value: 20}}
170
+ */function i(...n){let o=n[0];for(let t=1;t<n.length;t++){let r=n[t];a(r)&&Object.keys(r).forEach(t=>{var n,e=r[t];a(e)&&(n=e,"undefined"==typeof window||n!==window&&n!==document)?Object.prototype.hasOwnProperty.call(o,t)&&a(o[t])?o[t]=i({},o[t],e):o[t]=i({},e):Array.isArray(e)?o[t]=e.slice():o[t]=e})}return o},t.attrize=u,t.date=function(t){
171
+ // returns if falsey or already Date object
172
+ if([!1,void 0,NaN].includes(t)||t.constructor===Date)return t;if(t.constructor===Number&&5<(""+t).length&&t%1==0)return new Date(t);let n=""+t;
173
+ // tests for MM/DD/YYYY and MM-DD-YYYY format
174
+ var e,r,i=new RegExp(/^\d{1,2}[./-]\d{1,2}[./-](-*\d{1,4})$/g).exec(n);return i?(0===(i=i[1]).indexOf("-")&&(n=n.replace(i,i.substring(1))),(e=new Date(n)).setFullYear(i),e):(i=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))?(0===(e=i[1]).indexOf("-")&&(n=n.replace(e,e.substring(1))),(i=new Date(n)).setFullYear(e),i):(e=new RegExp(/^([qQ]{1}[1-4]{1}|[1-4]{1}[qQ]{1})[\s|-]{0,1}(-*\d{1,4})$/g).exec(n),i=new RegExp(/^(-*\d{1,4})[\s|-]{0,1}([qQ]{1}[1-4]{1}|[1-4]{1}[qQ]{1})$/g).exec(n),e||i?(r=+(e?e[1]:i[2]).toLowerCase().replace("q",""),e=+(e?e[2]:i[1]),(i=new Date(e,3*r-3,1)).setFullYear(e),i):
175
+ // detects if only passing a year value
176
+ n.includes("/")||n.includes(" ")||n.includes("-")&&n.indexOf("-")?new Date(n):((r=new Date(+n,0,1)).setFullYear(t),r));
177
+ // tests for full Date object string format
178
+ },t.elem=
179
+ /**
180
+ @function elem
181
+ @desc Manages the enter/update/exit pattern for a single DOM element.
182
+ @param {String} selector A D3 selector, which must include the tagname and a class and/or ID.
183
+ @param {Object} params Additional parameters.
184
+ @param {Boolean} [params.condition = true] Whether or not the element should be rendered (or removed).
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,n){
191
+ // overrides default params
192
+ n=Object.assign({},{condition:!0,enter:{},exit:{},duration:0,parent:s("body"),update:{}},n);var e=/\.([^#]+)/g.exec(t),r=/#([^.]+)/g.exec(t),i=Pn().duration(n.duration),o=/^([^.^#]+)/g.exec(t)[1],o=(t=n.parent.selectAll(t.includes(":")?t.split(":")[1]:t).data(n.condition?[null]:[])).enter().append(o).call(u,n.enter),r=(r&&o.attr("id",r[1]),e&&o.attr("class",e[1]),(n.duration?t.exit().transition(i):t.exit()).call(u,n.exit).remove(),o.merge(t));return(n.duration?r.transition(i):r).call(u,n.update),r},t.fontExists=n=>{zn||(zn=q(P,{"font-family":"DejaVuSans","font-size":32}),Hn=q(P,{"font-family":"-apple-system","font-size":32}),Fn=q(P,{"font-family":"monospace","font-size":32}),Rn=q(P,{"font-family":"sans-serif","font-size":32})),n=(n=n instanceof Array?n:n.split(",")).map(t=>t.toString().replace(/^\s+|\s+$/g,""));for(let t=0;t<n.length;t++){var e=n[t];if(D[e]||["-apple-system","monospace","sans-serif","DejaVuSans"].includes(e))return e;if(!1!==D[e]){var r=q(P,{"font-family":e,"font-size":32});if(D[e]=r!==Fn,D[e]&&(D[e]=r!==Rn),Hn&&D[e]&&(D[e]=r!==Hn),zn&&D[e]&&(D[e]=r!==zn),D[e])return e}}return!1},t.getSize=function(t){return[Ln(t,"width"),Ln(t,"height")]}
193
+ /**
194
+ @module inViewport
195
+ @desc Returns a *Boolean* denoting whether or not a given DOM element is visible in the current window.
196
+ @param {DOMElement} elem The DOM element to analyze.
197
+ @param {Number} [buffer = 0] A pixel offset from the edge of the top and bottom of the screen. If a positive value, the element will be deemed visible when it is that many pixels away from entering the viewport. If negative, the element will have to enter the viewport by that many pixels before being deemed visible.
198
+ @private
199
+ */,t.inViewport=function(t,n=0){var e=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,r=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,i=(t=t.getBoundingClientRect()).height,o=t.left+e,a=t.top+r;return r+window.innerHeight>a+n&&r+n<a+i&&e+window.innerWidth>o+n&&e+n<o+t.width}
200
+ /**
201
+ @function parseSides
202
+ @desc Converts a string of directional CSS shorthand values into an object with the values expanded.
203
+ @param {String|Number} sides The CSS shorthand string to expand.
204
+ */,t.isObject=a,t.parseSides=function(t){let r;return 1===(r="number"==typeof t?[t]:t.split(/\s+/)).length?r=[r[0],r[0],r[0],r[0]]:2===r.length?r=r.concat(r):3===r.length&&r.push(r[1]),["top","right","bottom","left"].reduce((t,n,e)=>{e=parseFloat(r[e]);return t[n]=e||0,t},{})}
205
+ /**
206
+ @function prefix
207
+ @desc Returns the appropriate CSS vendor prefix, given the current browser.
208
+ */,t.prefix=function(){return"-webkit-transform"in document.body.style?"-webkit-":"-moz-transform"in document.body.style?"-moz-":"-ms-transform"in document.body.style?"-ms-":"-o-transform"in document.body.style?"-o-":""}
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,n={}){for(var e in n)!{}.hasOwnProperty.call(n,e)||t.style(e,n[e])},t.textWidth=q});
219
+ //# sourceMappingURL=d3plus-dom.full.js.map