@logicflow/layout 1.2.0-alpha.15 → 2.0.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/stats.html ADDED
@@ -0,0 +1,4842 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <meta http-equiv="X-UA-Compatible" content="ie=edge" />
8
+ <title>Rollup Visualizer</title>
9
+ <style>
10
+ :root {
11
+ --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
12
+ "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
13
+ --background-color: #2b2d42;
14
+ --text-color: #edf2f4;
15
+ }
16
+
17
+ html {
18
+ box-sizing: border-box;
19
+ }
20
+
21
+ *,
22
+ *:before,
23
+ *:after {
24
+ box-sizing: inherit;
25
+ }
26
+
27
+ html {
28
+ background-color: var(--background-color);
29
+ color: var(--text-color);
30
+ font-family: var(--font-family);
31
+ }
32
+
33
+ body {
34
+ padding: 0;
35
+ margin: 0;
36
+ }
37
+
38
+ html,
39
+ body {
40
+ height: 100%;
41
+ width: 100%;
42
+ overflow: hidden;
43
+ }
44
+
45
+ body {
46
+ display: flex;
47
+ flex-direction: column;
48
+ }
49
+
50
+ svg {
51
+ vertical-align: middle;
52
+ width: 100%;
53
+ height: 100%;
54
+ max-height: 100vh;
55
+ }
56
+
57
+ main {
58
+ flex-grow: 1;
59
+ height: 100vh;
60
+ padding: 20px;
61
+ }
62
+
63
+ .tooltip {
64
+ position: absolute;
65
+ z-index: 1070;
66
+ border: 2px solid;
67
+ border-radius: 5px;
68
+ padding: 5px;
69
+ white-space: nowrap;
70
+ font-size: 0.875rem;
71
+ background-color: var(--background-color);
72
+ color: var(--text-color);
73
+ }
74
+
75
+ .tooltip-hidden {
76
+ visibility: hidden;
77
+ opacity: 0;
78
+ }
79
+
80
+ .sidebar {
81
+ position: fixed;
82
+ top: 0;
83
+ left: 0;
84
+ right: 0;
85
+ display: flex;
86
+ flex-direction: row;
87
+ font-size: 0.7rem;
88
+ align-items: center;
89
+ margin: 0 50px;
90
+ height: 20px;
91
+ }
92
+
93
+ .size-selectors {
94
+ display: flex;
95
+ flex-direction: row;
96
+ align-items: center;
97
+ }
98
+
99
+ .size-selector {
100
+ display: flex;
101
+ flex-direction: row;
102
+ align-items: center;
103
+ justify-content: center;
104
+ margin-right: 1rem;
105
+ }
106
+ .size-selector input {
107
+ margin: 0 0.3rem 0 0;
108
+ }
109
+
110
+ .filters {
111
+ flex: 1;
112
+ display: flex;
113
+ flex-direction: row;
114
+ align-items: center;
115
+ }
116
+
117
+ .module-filters {
118
+ display: flex;
119
+ flex-grow: 1;
120
+ }
121
+
122
+ .module-filter {
123
+ display: flex;
124
+ flex-direction: row;
125
+ align-items: center;
126
+ justify-content: center;
127
+ flex: 1;
128
+ }
129
+ .module-filter input {
130
+ flex: 1;
131
+ height: 1rem;
132
+ padding: 0.01rem;
133
+ font-size: 0.7rem;
134
+ margin-left: 0.3rem;
135
+ }
136
+ .module-filter + .module-filter {
137
+ margin-left: 0.5rem;
138
+ }
139
+
140
+ .node {
141
+ cursor: pointer;
142
+ }
143
+ </style>
144
+ </head>
145
+ <body>
146
+ <main></main>
147
+ <script>
148
+ /*<!--*/
149
+ var drawChart = (function (exports) {
150
+ 'use strict';
151
+
152
+ var n,l$1,u$2,i$1,o$1,r$1,f$2,e$1,c$1={},s$1=[],a$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,h$1=Array.isArray;function v$1(n,l){for(var u in l)n[u]=l[u];return n}function p$1(n){var l=n.parentNode;l&&l.removeChild(n);}function y$1(l,u,t){var i,o,r,f={};for(r in u)"key"==r?i=u[r]:"ref"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):t),"function"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return d$1(l,f,i,o,null)}function d$1(n,t,i,o,r){var f={type:n,props:t,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++u$2:r,__i:-1,__u:0};return null==r&&null!=l$1.vnode&&l$1.vnode(f),f}function g$1(n){return n.children}function b$1(n,l){this.props=n,this.context=l;}function m$1(n,l){if(null==l)return n.__?m$1(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?m$1(n):null}function k$1(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return k$1(n)}}function w$1(n){(!n.__d&&(n.__d=!0)&&i$1.push(n)&&!x.__r++||o$1!==l$1.debounceRendering)&&((o$1=l$1.debounceRendering)||r$1)(x);}function x(){var n,u,t,o,r,e,c,s,a;for(i$1.sort(f$2);n=i$1.shift();)n.__d&&(u=i$1.length,o=void 0,e=(r=(t=n).__v).__e,s=[],a=[],(c=t.__P)&&((o=v$1({},r)).__v=r.__v+1,l$1.vnode&&l$1.vnode(o),L(c,o,r,t.__n,void 0!==c.ownerSVGElement,32&r.__u?[e]:null,s,null==e?m$1(r):e,!!(32&r.__u),a),o.__.__k[o.__i]=o,M(s,o,a),o.__e!=e&&k$1(o)),i$1.length>u&&i$1.sort(f$2));x.__r=0;}function C(n,l,u,t,i,o,r,f,e,a,h){var v,p,y,d,_,g=t&&t.__k||s$1,b=l.length;for(u.__d=e,P(u,l,g),e=u.__d,v=0;v<b;v++)null!=(y=u.__k[v])&&"boolean"!=typeof y&&"function"!=typeof y&&(p=-1===y.__i?c$1:g[y.__i]||c$1,y.__i=v,L(n,y,p,i,o,r,f,e,a,h),d=y.__e,y.ref&&p.ref!=y.ref&&(p.ref&&z$1(p.ref,null,y),h.push(y.ref,y.__c||d,y)),null==_&&null!=d&&(_=d),65536&y.__u||p.__k===y.__k?e=S(y,e,n):"function"==typeof y.type&&void 0!==y.__d?e=y.__d:d&&(e=d.nextSibling),y.__d=void 0,y.__u&=-196609);u.__d=e,u.__e=_;}function P(n,l,u){var t,i,o,r,f,e=l.length,c=u.length,s=c,a=0;for(n.__k=[],t=0;t<e;t++)null!=(i=n.__k[t]=null==(i=l[t])||"boolean"==typeof i||"function"==typeof i?null:"string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?d$1(null,i,null,null,i):h$1(i)?d$1(g$1,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?d$1(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=n,i.__b=n.__b+1,f=H(i,u,r=t+a,s),i.__i=f,o=null,-1!==f&&(s--,(o=u[f])&&(o.__u|=131072)),null==o||null===o.__v?(-1==f&&a--,"function"!=typeof i.type&&(i.__u|=65536)):f!==r&&(f===r+1?a++:f>r?s>e-r?a+=f-r:a--:a=f<r&&f==r-1?f-r:0,f!==t+a&&(i.__u|=65536))):(o=u[t])&&null==o.key&&o.__e&&(o.__e==n.__d&&(n.__d=m$1(o)),N(o,o,!1),u[t]=null,s--);if(s)for(t=0;t<c;t++)null!=(o=u[t])&&0==(131072&o.__u)&&(o.__e==n.__d&&(n.__d=m$1(o)),N(o,o));}function S(n,l,u){var t,i;if("function"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=S(t[i],l,u));return l}return n.__e!=l&&(u.insertBefore(n.__e,l||null),l=n.__e),l&&l.nextSibling}function H(n,l,u,t){var i=n.key,o=n.type,r=u-1,f=u+1,e=l[u];if(null===e||e&&i==e.key&&o===e.type)return u;if(t>(null!=e&&0==(131072&e.__u)?1:0))for(;r>=0||f<l.length;){if(r>=0){if((e=l[r])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return r;r--;}if(f<l.length){if((e=l[f])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return f;f++;}}return -1}function I(n,l,u){"-"===l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||a$1.test(l)?u:u+"px";}function T$1(n,l,u,t,i){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof t&&(n.style.cssText=t=""),t)for(l in t)u&&l in u||I(n.style,l,"");if(u)for(l in u)t&&u[l]===t[l]||I(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/(PointerCapture)$|Capture$/,"$1")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?t?u.u=t.u:(u.u=Date.now(),n.addEventListener(l,o?D:A,o)):n.removeEventListener(l,o?D:A,o);else {if(i)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==l&&"height"!==l&&"href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&"rowSpan"!==l&&"colSpan"!==l&&"role"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||!1===u&&"-"!==l[4]?n.removeAttribute(l):n.setAttribute(l,u));}}function A(n){var u=this.l[n.type+!1];if(n.t){if(n.t<=u.u)return}else n.t=Date.now();return u(l$1.event?l$1.event(n):n)}function D(n){return this.l[n.type+!0](l$1.event?l$1.event(n):n)}function L(n,u,t,i,o,r,f,e,c,s){var a,p,y,d,_,m,k,w,x,P,S,$,H,I,T,A=u.type;if(void 0!==u.constructor)return null;128&t.__u&&(c=!!(32&t.__u),r=[e=u.__e=t.__e]),(a=l$1.__b)&&a(u);n:if("function"==typeof A)try{if(w=u.props,x=(a=A.contextType)&&i[a.__c],P=a?x?x.props.value:a.__:i,t.__c?k=(p=u.__c=t.__c).__=p.__E:("prototype"in A&&A.prototype.render?u.__c=p=new A(w,P):(u.__c=p=new b$1(w,P),p.constructor=A,p.render=O),x&&x.sub(p),p.props=w,p.state||(p.state={}),p.context=P,p.__n=i,y=p.__d=!0,p.__h=[],p._sb=[]),null==p.__s&&(p.__s=p.state),null!=A.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=v$1({},p.__s)),v$1(p.__s,A.getDerivedStateFromProps(w,p.__s))),d=p.props,_=p.state,p.__v=u,y)null==A.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else {if(null==A.getDerivedStateFromProps&&w!==d&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(w,P),!p.__e&&(null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(w,p.__s,P)||u.__v===t.__v)){for(u.__v!==t.__v&&(p.props=w,p.state=p.__s,p.__d=!1),u.__e=t.__e,u.__k=t.__k,u.__k.forEach(function(n){n&&(n.__=u);}),S=0;S<p._sb.length;S++)p.__h.push(p._sb[S]);p._sb=[],p.__h.length&&f.push(p);break n}null!=p.componentWillUpdate&&p.componentWillUpdate(w,p.__s,P),null!=p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(d,_,m);});}if(p.context=P,p.props=w,p.__P=n,p.__e=!1,$=l$1.__r,H=0,"prototype"in A&&A.prototype.render){for(p.state=p.__s,p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),I=0;I<p._sb.length;I++)p.__h.push(p._sb[I]);p._sb=[];}else do{p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),p.state=p.__s;}while(p.__d&&++H<25);p.state=p.__s,null!=p.getChildContext&&(i=v$1(v$1({},i),p.getChildContext())),y||null==p.getSnapshotBeforeUpdate||(m=p.getSnapshotBeforeUpdate(d,_)),C(n,h$1(T=null!=a&&a.type===g$1&&null==a.key?a.props.children:a)?T:[T],u,t,i,o,r,f,e,c,s),p.base=u.__e,u.__u&=-161,p.__h.length&&f.push(p),k&&(p.__E=p.__=null);}catch(n){u.__v=null,c||null!=r?(u.__e=e,u.__u|=c?160:32,r[r.indexOf(e)]=null):(u.__e=t.__e,u.__k=t.__k),l$1.__e(n,u,t);}else null==r&&u.__v===t.__v?(u.__k=t.__k,u.__e=t.__e):u.__e=j$1(t.__e,u,t,i,o,r,f,c,s);(a=l$1.diffed)&&a(u);}function M(n,u,t){u.__d=void 0;for(var i=0;i<t.length;i++)z$1(t[i],t[++i],t[++i]);l$1.__c&&l$1.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u);});}catch(n){l$1.__e(n,u.__v);}});}function j$1(l,u,t,i,o,r,f,e,s){var a,v,y,d,_,g,b,k=t.props,w=u.props,x=u.type;if("svg"===x&&(o=!0),null!=r)for(a=0;a<r.length;a++)if((_=r[a])&&"setAttribute"in _==!!x&&(x?_.localName===x:3===_.nodeType)){l=_,r[a]=null;break}if(null==l){if(null===x)return document.createTextNode(w);l=o?document.createElementNS("http://www.w3.org/2000/svg",x):document.createElement(x,w.is&&w),r=null,e=!1;}if(null===x)k===w||e&&l.data===w||(l.data=w);else {if(r=r&&n.call(l.childNodes),k=t.props||c$1,!e&&null!=r)for(k={},a=0;a<l.attributes.length;a++)k[(_=l.attributes[a]).name]=_.value;for(a in k)_=k[a],"children"==a||("dangerouslySetInnerHTML"==a?y=_:"key"===a||a in w||T$1(l,a,null,_,o));for(a in w)_=w[a],"children"==a?d=_:"dangerouslySetInnerHTML"==a?v=_:"value"==a?g=_:"checked"==a?b=_:"key"===a||e&&"function"!=typeof _||k[a]===_||T$1(l,a,_,k[a],o);if(v)e||y&&(v.__html===y.__html||v.__html===l.innerHTML)||(l.innerHTML=v.__html),u.__k=[];else if(y&&(l.innerHTML=""),C(l,h$1(d)?d:[d],u,t,i,o&&"foreignObject"!==x,r,f,r?r[0]:t.__k&&m$1(t,0),e,s),null!=r)for(a=r.length;a--;)null!=r[a]&&p$1(r[a]);e||(a="value",void 0!==g&&(g!==l[a]||"progress"===x&&!g||"option"===x&&g!==k[a])&&T$1(l,a,g,k[a],!1),a="checked",void 0!==b&&b!==l[a]&&T$1(l,a,b,k[a],!1));}return l}function z$1(n,u,t){try{"function"==typeof n?n(u):n.current=u;}catch(n){l$1.__e(n,t);}}function N(n,u,t){var i,o;if(l$1.unmount&&l$1.unmount(n),(i=n.ref)&&(i.current&&i.current!==n.__e||z$1(i,null,u)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount();}catch(n){l$1.__e(n,u);}i.base=i.__P=null,n.__c=void 0;}if(i=n.__k)for(o=0;o<i.length;o++)i[o]&&N(i[o],u,t||"function"!=typeof n.type);t||null==n.__e||p$1(n.__e),n.__=n.__e=n.__d=void 0;}function O(n,l,u){return this.constructor(n,u)}function q$1(u,t,i){var o,r,f,e;l$1.__&&l$1.__(u,t),r=(o="function"==typeof i)?null:i&&i.__k||t.__k,f=[],e=[],L(t,u=(!o&&i||t).__k=y$1(g$1,null,[u]),r||c$1,c$1,void 0!==t.ownerSVGElement,!o&&i?[i]:r?null:t.firstChild?n.call(t.childNodes):null,f,!o&&i?i:r?r.__e:t.firstChild,o,e),M(f,u,e);}function F$1(n,l){var u={__c:l="__cC"+e$1++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,t;return this.getChildContext||(u=[],(t={})[l]=this,this.getChildContext=function(){return t},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(function(n){n.__e=!0,w$1(n);});},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n);};}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=s$1.slice,l$1={__e:function(n,l,u,t){for(var i,o,r;l=l.__;)if((i=l.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(n)),r=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),r=i.__d),r)return i.__E=i}catch(l){n=l;}throw n}},u$2=0,b$1.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=v$1({},this.state),"function"==typeof n&&(n=n(v$1({},u),this.props)),n&&v$1(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),w$1(this));},b$1.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),w$1(this));},b$1.prototype.render=g$1,i$1=[],r$1="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f$2=function(n,l){return n.__v.__b-l.__v.__b},x.__r=0,e$1=0;
153
+
154
+ var f$1=0;function u$1(e,t,n,o,i,u){var a,c,p={};for(c in t)"ref"==c?a=t[c]:p[c]=t[c];var l={type:e,props:p,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--f$1,__i:-1,__u:0,__source:i,__self:u};if("function"==typeof e&&(a=e.defaultProps))for(c in a)void 0===p[c]&&(p[c]=a[c]);return l$1.vnode&&l$1.vnode(l),l}
155
+
156
+ function count$1(node) {
157
+ var sum = 0,
158
+ children = node.children,
159
+ i = children && children.length;
160
+ if (!i) sum = 1;
161
+ else while (--i >= 0) sum += children[i].value;
162
+ node.value = sum;
163
+ }
164
+
165
+ function node_count() {
166
+ return this.eachAfter(count$1);
167
+ }
168
+
169
+ function node_each(callback, that) {
170
+ let index = -1;
171
+ for (const node of this) {
172
+ callback.call(that, node, ++index, this);
173
+ }
174
+ return this;
175
+ }
176
+
177
+ function node_eachBefore(callback, that) {
178
+ var node = this, nodes = [node], children, i, index = -1;
179
+ while (node = nodes.pop()) {
180
+ callback.call(that, node, ++index, this);
181
+ if (children = node.children) {
182
+ for (i = children.length - 1; i >= 0; --i) {
183
+ nodes.push(children[i]);
184
+ }
185
+ }
186
+ }
187
+ return this;
188
+ }
189
+
190
+ function node_eachAfter(callback, that) {
191
+ var node = this, nodes = [node], next = [], children, i, n, index = -1;
192
+ while (node = nodes.pop()) {
193
+ next.push(node);
194
+ if (children = node.children) {
195
+ for (i = 0, n = children.length; i < n; ++i) {
196
+ nodes.push(children[i]);
197
+ }
198
+ }
199
+ }
200
+ while (node = next.pop()) {
201
+ callback.call(that, node, ++index, this);
202
+ }
203
+ return this;
204
+ }
205
+
206
+ function node_find(callback, that) {
207
+ let index = -1;
208
+ for (const node of this) {
209
+ if (callback.call(that, node, ++index, this)) {
210
+ return node;
211
+ }
212
+ }
213
+ }
214
+
215
+ function node_sum(value) {
216
+ return this.eachAfter(function(node) {
217
+ var sum = +value(node.data) || 0,
218
+ children = node.children,
219
+ i = children && children.length;
220
+ while (--i >= 0) sum += children[i].value;
221
+ node.value = sum;
222
+ });
223
+ }
224
+
225
+ function node_sort(compare) {
226
+ return this.eachBefore(function(node) {
227
+ if (node.children) {
228
+ node.children.sort(compare);
229
+ }
230
+ });
231
+ }
232
+
233
+ function node_path(end) {
234
+ var start = this,
235
+ ancestor = leastCommonAncestor(start, end),
236
+ nodes = [start];
237
+ while (start !== ancestor) {
238
+ start = start.parent;
239
+ nodes.push(start);
240
+ }
241
+ var k = nodes.length;
242
+ while (end !== ancestor) {
243
+ nodes.splice(k, 0, end);
244
+ end = end.parent;
245
+ }
246
+ return nodes;
247
+ }
248
+
249
+ function leastCommonAncestor(a, b) {
250
+ if (a === b) return a;
251
+ var aNodes = a.ancestors(),
252
+ bNodes = b.ancestors(),
253
+ c = null;
254
+ a = aNodes.pop();
255
+ b = bNodes.pop();
256
+ while (a === b) {
257
+ c = a;
258
+ a = aNodes.pop();
259
+ b = bNodes.pop();
260
+ }
261
+ return c;
262
+ }
263
+
264
+ function node_ancestors() {
265
+ var node = this, nodes = [node];
266
+ while (node = node.parent) {
267
+ nodes.push(node);
268
+ }
269
+ return nodes;
270
+ }
271
+
272
+ function node_descendants() {
273
+ return Array.from(this);
274
+ }
275
+
276
+ function node_leaves() {
277
+ var leaves = [];
278
+ this.eachBefore(function(node) {
279
+ if (!node.children) {
280
+ leaves.push(node);
281
+ }
282
+ });
283
+ return leaves;
284
+ }
285
+
286
+ function node_links() {
287
+ var root = this, links = [];
288
+ root.each(function(node) {
289
+ if (node !== root) { // Don’t include the root’s parent, if any.
290
+ links.push({source: node.parent, target: node});
291
+ }
292
+ });
293
+ return links;
294
+ }
295
+
296
+ function* node_iterator() {
297
+ var node = this, current, next = [node], children, i, n;
298
+ do {
299
+ current = next.reverse(), next = [];
300
+ while (node = current.pop()) {
301
+ yield node;
302
+ if (children = node.children) {
303
+ for (i = 0, n = children.length; i < n; ++i) {
304
+ next.push(children[i]);
305
+ }
306
+ }
307
+ }
308
+ } while (next.length);
309
+ }
310
+
311
+ function hierarchy(data, children) {
312
+ if (data instanceof Map) {
313
+ data = [undefined, data];
314
+ if (children === undefined) children = mapChildren;
315
+ } else if (children === undefined) {
316
+ children = objectChildren;
317
+ }
318
+
319
+ var root = new Node$1(data),
320
+ node,
321
+ nodes = [root],
322
+ child,
323
+ childs,
324
+ i,
325
+ n;
326
+
327
+ while (node = nodes.pop()) {
328
+ if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) {
329
+ node.children = childs;
330
+ for (i = n - 1; i >= 0; --i) {
331
+ nodes.push(child = childs[i] = new Node$1(childs[i]));
332
+ child.parent = node;
333
+ child.depth = node.depth + 1;
334
+ }
335
+ }
336
+ }
337
+
338
+ return root.eachBefore(computeHeight);
339
+ }
340
+
341
+ function node_copy() {
342
+ return hierarchy(this).eachBefore(copyData);
343
+ }
344
+
345
+ function objectChildren(d) {
346
+ return d.children;
347
+ }
348
+
349
+ function mapChildren(d) {
350
+ return Array.isArray(d) ? d[1] : null;
351
+ }
352
+
353
+ function copyData(node) {
354
+ if (node.data.value !== undefined) node.value = node.data.value;
355
+ node.data = node.data.data;
356
+ }
357
+
358
+ function computeHeight(node) {
359
+ var height = 0;
360
+ do node.height = height;
361
+ while ((node = node.parent) && (node.height < ++height));
362
+ }
363
+
364
+ function Node$1(data) {
365
+ this.data = data;
366
+ this.depth =
367
+ this.height = 0;
368
+ this.parent = null;
369
+ }
370
+
371
+ Node$1.prototype = hierarchy.prototype = {
372
+ constructor: Node$1,
373
+ count: node_count,
374
+ each: node_each,
375
+ eachAfter: node_eachAfter,
376
+ eachBefore: node_eachBefore,
377
+ find: node_find,
378
+ sum: node_sum,
379
+ sort: node_sort,
380
+ path: node_path,
381
+ ancestors: node_ancestors,
382
+ descendants: node_descendants,
383
+ leaves: node_leaves,
384
+ links: node_links,
385
+ copy: node_copy,
386
+ [Symbol.iterator]: node_iterator
387
+ };
388
+
389
+ function required(f) {
390
+ if (typeof f !== "function") throw new Error;
391
+ return f;
392
+ }
393
+
394
+ function constantZero() {
395
+ return 0;
396
+ }
397
+
398
+ function constant$1(x) {
399
+ return function() {
400
+ return x;
401
+ };
402
+ }
403
+
404
+ function roundNode(node) {
405
+ node.x0 = Math.round(node.x0);
406
+ node.y0 = Math.round(node.y0);
407
+ node.x1 = Math.round(node.x1);
408
+ node.y1 = Math.round(node.y1);
409
+ }
410
+
411
+ function treemapDice(parent, x0, y0, x1, y1) {
412
+ var nodes = parent.children,
413
+ node,
414
+ i = -1,
415
+ n = nodes.length,
416
+ k = parent.value && (x1 - x0) / parent.value;
417
+
418
+ while (++i < n) {
419
+ node = nodes[i], node.y0 = y0, node.y1 = y1;
420
+ node.x0 = x0, node.x1 = x0 += node.value * k;
421
+ }
422
+ }
423
+
424
+ function treemapSlice(parent, x0, y0, x1, y1) {
425
+ var nodes = parent.children,
426
+ node,
427
+ i = -1,
428
+ n = nodes.length,
429
+ k = parent.value && (y1 - y0) / parent.value;
430
+
431
+ while (++i < n) {
432
+ node = nodes[i], node.x0 = x0, node.x1 = x1;
433
+ node.y0 = y0, node.y1 = y0 += node.value * k;
434
+ }
435
+ }
436
+
437
+ var phi = (1 + Math.sqrt(5)) / 2;
438
+
439
+ function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
440
+ var rows = [],
441
+ nodes = parent.children,
442
+ row,
443
+ nodeValue,
444
+ i0 = 0,
445
+ i1 = 0,
446
+ n = nodes.length,
447
+ dx, dy,
448
+ value = parent.value,
449
+ sumValue,
450
+ minValue,
451
+ maxValue,
452
+ newRatio,
453
+ minRatio,
454
+ alpha,
455
+ beta;
456
+
457
+ while (i0 < n) {
458
+ dx = x1 - x0, dy = y1 - y0;
459
+
460
+ // Find the next non-empty node.
461
+ do sumValue = nodes[i1++].value; while (!sumValue && i1 < n);
462
+ minValue = maxValue = sumValue;
463
+ alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
464
+ beta = sumValue * sumValue * alpha;
465
+ minRatio = Math.max(maxValue / beta, beta / minValue);
466
+
467
+ // Keep adding nodes while the aspect ratio maintains or improves.
468
+ for (; i1 < n; ++i1) {
469
+ sumValue += nodeValue = nodes[i1].value;
470
+ if (nodeValue < minValue) minValue = nodeValue;
471
+ if (nodeValue > maxValue) maxValue = nodeValue;
472
+ beta = sumValue * sumValue * alpha;
473
+ newRatio = Math.max(maxValue / beta, beta / minValue);
474
+ if (newRatio > minRatio) { sumValue -= nodeValue; break; }
475
+ minRatio = newRatio;
476
+ }
477
+
478
+ // Position and record the row orientation.
479
+ rows.push(row = {value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1)});
480
+ if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
481
+ else treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
482
+ value -= sumValue, i0 = i1;
483
+ }
484
+
485
+ return rows;
486
+ }
487
+
488
+ var squarify = (function custom(ratio) {
489
+
490
+ function squarify(parent, x0, y0, x1, y1) {
491
+ squarifyRatio(ratio, parent, x0, y0, x1, y1);
492
+ }
493
+
494
+ squarify.ratio = function(x) {
495
+ return custom((x = +x) > 1 ? x : 1);
496
+ };
497
+
498
+ return squarify;
499
+ })(phi);
500
+
501
+ function treemap() {
502
+ var tile = squarify,
503
+ round = false,
504
+ dx = 1,
505
+ dy = 1,
506
+ paddingStack = [0],
507
+ paddingInner = constantZero,
508
+ paddingTop = constantZero,
509
+ paddingRight = constantZero,
510
+ paddingBottom = constantZero,
511
+ paddingLeft = constantZero;
512
+
513
+ function treemap(root) {
514
+ root.x0 =
515
+ root.y0 = 0;
516
+ root.x1 = dx;
517
+ root.y1 = dy;
518
+ root.eachBefore(positionNode);
519
+ paddingStack = [0];
520
+ if (round) root.eachBefore(roundNode);
521
+ return root;
522
+ }
523
+
524
+ function positionNode(node) {
525
+ var p = paddingStack[node.depth],
526
+ x0 = node.x0 + p,
527
+ y0 = node.y0 + p,
528
+ x1 = node.x1 - p,
529
+ y1 = node.y1 - p;
530
+ if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
531
+ if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
532
+ node.x0 = x0;
533
+ node.y0 = y0;
534
+ node.x1 = x1;
535
+ node.y1 = y1;
536
+ if (node.children) {
537
+ p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
538
+ x0 += paddingLeft(node) - p;
539
+ y0 += paddingTop(node) - p;
540
+ x1 -= paddingRight(node) - p;
541
+ y1 -= paddingBottom(node) - p;
542
+ if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
543
+ if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
544
+ tile(node, x0, y0, x1, y1);
545
+ }
546
+ }
547
+
548
+ treemap.round = function(x) {
549
+ return arguments.length ? (round = !!x, treemap) : round;
550
+ };
551
+
552
+ treemap.size = function(x) {
553
+ return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy];
554
+ };
555
+
556
+ treemap.tile = function(x) {
557
+ return arguments.length ? (tile = required(x), treemap) : tile;
558
+ };
559
+
560
+ treemap.padding = function(x) {
561
+ return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner();
562
+ };
563
+
564
+ treemap.paddingInner = function(x) {
565
+ return arguments.length ? (paddingInner = typeof x === "function" ? x : constant$1(+x), treemap) : paddingInner;
566
+ };
567
+
568
+ treemap.paddingOuter = function(x) {
569
+ return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop();
570
+ };
571
+
572
+ treemap.paddingTop = function(x) {
573
+ return arguments.length ? (paddingTop = typeof x === "function" ? x : constant$1(+x), treemap) : paddingTop;
574
+ };
575
+
576
+ treemap.paddingRight = function(x) {
577
+ return arguments.length ? (paddingRight = typeof x === "function" ? x : constant$1(+x), treemap) : paddingRight;
578
+ };
579
+
580
+ treemap.paddingBottom = function(x) {
581
+ return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant$1(+x), treemap) : paddingBottom;
582
+ };
583
+
584
+ treemap.paddingLeft = function(x) {
585
+ return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant$1(+x), treemap) : paddingLeft;
586
+ };
587
+
588
+ return treemap;
589
+ }
590
+
591
+ var treemapResquarify = (function custom(ratio) {
592
+
593
+ function resquarify(parent, x0, y0, x1, y1) {
594
+ if ((rows = parent._squarify) && (rows.ratio === ratio)) {
595
+ var rows,
596
+ row,
597
+ nodes,
598
+ i,
599
+ j = -1,
600
+ n,
601
+ m = rows.length,
602
+ value = parent.value;
603
+
604
+ while (++j < m) {
605
+ row = rows[j], nodes = row.children;
606
+ for (i = row.value = 0, n = nodes.length; i < n; ++i) row.value += nodes[i].value;
607
+ if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += (y1 - y0) * row.value / value : y1);
608
+ else treemapSlice(row, x0, y0, value ? x0 += (x1 - x0) * row.value / value : x1, y1);
609
+ value -= row.value;
610
+ }
611
+ } else {
612
+ parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1);
613
+ rows.ratio = ratio;
614
+ }
615
+ }
616
+
617
+ resquarify.ratio = function(x) {
618
+ return custom((x = +x) > 1 ? x : 1);
619
+ };
620
+
621
+ return resquarify;
622
+ })(phi);
623
+
624
+ const isModuleTree = (mod) => "children" in mod;
625
+
626
+ let count = 0;
627
+ class Id {
628
+ constructor(id) {
629
+ this._id = id;
630
+ const url = new URL(window.location.href);
631
+ url.hash = id;
632
+ this._href = url.toString();
633
+ }
634
+ get id() {
635
+ return this._id;
636
+ }
637
+ get href() {
638
+ return this._href;
639
+ }
640
+ toString() {
641
+ return `url(${this.href})`;
642
+ }
643
+ }
644
+ function generateUniqueId(name) {
645
+ count += 1;
646
+ const id = ["O", name, count].filter(Boolean).join("-");
647
+ return new Id(id);
648
+ }
649
+
650
+ const LABELS = {
651
+ renderedLength: "Rendered",
652
+ gzipLength: "Gzip",
653
+ brotliLength: "Brotli",
654
+ };
655
+ const getAvailableSizeOptions = (options) => {
656
+ const availableSizeProperties = ["renderedLength"];
657
+ if (options.gzip) {
658
+ availableSizeProperties.push("gzipLength");
659
+ }
660
+ if (options.brotli) {
661
+ availableSizeProperties.push("brotliLength");
662
+ }
663
+ return availableSizeProperties;
664
+ };
665
+
666
+ var t,r,u,i,o=0,f=[],c=[],e=l$1.__b,a=l$1.__r,v=l$1.diffed,l=l$1.__c,m=l$1.unmount;function d(t,u){l$1.__h&&l$1.__h(r,t,o||u),o=0;var i=r.__H||(r.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:c}),i.__[t]}function h(n){return o=1,s(B,n)}function s(n,u,i){var o=d(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):B(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}));}],o.__c=r,!r.u)){var f=function(n,t,r){if(!o.__c.__H)return !0;var u=o.__c.__H.__.filter(function(n){return n.__c});if(u.every(function(n){return !n.__N}))return !c||c.call(this,n,t,r);var i=!1;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0);}}),!(!i&&o.__c.props===n)&&(!c||c.call(this,n,t,r))};r.u=!0;var c=r.shouldComponentUpdate,e=r.componentWillUpdate;r.componentWillUpdate=function(n,t,r){if(this.__e){var u=c;c=void 0,f(n,t,r),c=u;}e&&e.call(this,n,t,r);},r.shouldComponentUpdate=f;}return o.__N||o.__}function p(u,i){var o=d(t++,3);!l$1.__s&&z(o.__H,i)&&(o.__=u,o.i=i,r.__H.__h.push(o));}function y(u,i){var o=d(t++,4);!l$1.__s&&z(o.__H,i)&&(o.__=u,o.i=i,r.__h.push(o));}function _(n){return o=5,F(function(){return {current:n}},[])}function F(n,r){var u=d(t++,7);return z(u.__H,r)?(u.__V=n(),u.i=r,u.__h=n,u.__V):u.__}function T(n,t){return o=8,F(function(){return n},t)}function q(n){var u=r.context[n.__c],i=d(t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function b(){for(var t;t=f.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(k),t.__H.__h.forEach(w),t.__H.__h=[];}catch(r){t.__H.__h=[],l$1.__e(r,t.__v);}}l$1.__b=function(n){r=null,e&&e(n);},l$1.__r=function(n){a&&a(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=c,n.__N=n.i=void 0;})):(i.__h.forEach(k),i.__h.forEach(w),i.__h=[],t=0)),u=r;},l$1.diffed=function(t){v&&v(t);var o=t.__c;o&&o.__H&&(o.__H.__h.length&&(1!==f.push(o)&&i===l$1.requestAnimationFrame||((i=l$1.requestAnimationFrame)||j)(b)),o.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==c&&(n.__=n.__V),n.i=void 0,n.__V=c;})),u=r=null;},l$1.__c=function(t,r){r.some(function(t){try{t.__h.forEach(k),t.__h=t.__h.filter(function(n){return !n.__||w(n)});}catch(u){r.some(function(n){n.__h&&(n.__h=[]);}),r=[],l$1.__e(u,t.__v);}}),l&&l(t,r);},l$1.unmount=function(t){m&&m(t);var r,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{k(n);}catch(n){r=n;}}),u.__H=void 0,r&&l$1.__e(r,u.__v));};var g="function"==typeof requestAnimationFrame;function j(n){var t,r=function(){clearTimeout(u),g&&cancelAnimationFrame(t),setTimeout(n);},u=setTimeout(r,100);g&&(t=requestAnimationFrame(r));}function k(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t;}function w(n){var t=r;n.__c=n.__(),r=t;}function z(n,t){return !n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function B(n,t){return "function"==typeof t?t(n):t}
667
+
668
+ const PLACEHOLDER = "*/**/file.js";
669
+ const SideBar = ({ availableSizeProperties, sizeProperty, setSizeProperty, onExcludeChange, onIncludeChange, }) => {
670
+ const [includeValue, setIncludeValue] = h("");
671
+ const [excludeValue, setExcludeValue] = h("");
672
+ const handleSizePropertyChange = (sizeProp) => () => {
673
+ if (sizeProp !== sizeProperty) {
674
+ setSizeProperty(sizeProp);
675
+ }
676
+ };
677
+ const handleIncludeChange = (event) => {
678
+ const value = event.currentTarget.value;
679
+ setIncludeValue(value);
680
+ onIncludeChange(value);
681
+ };
682
+ const handleExcludeChange = (event) => {
683
+ const value = event.currentTarget.value;
684
+ setExcludeValue(value);
685
+ onExcludeChange(value);
686
+ };
687
+ return (u$1("aside", { className: "sidebar", children: [u$1("div", { className: "size-selectors", children: availableSizeProperties.length > 1 &&
688
+ availableSizeProperties.map((sizeProp) => {
689
+ const id = `selector-${sizeProp}`;
690
+ return (u$1("div", { className: "size-selector", children: [u$1("input", { type: "radio", id: id, checked: sizeProp === sizeProperty, onChange: handleSizePropertyChange(sizeProp) }), u$1("label", { htmlFor: id, children: LABELS[sizeProp] })] }, sizeProp));
691
+ }) }), u$1("div", { className: "module-filters", children: [u$1("div", { className: "module-filter", children: [u$1("label", { htmlFor: "module-filter-exclude", children: "Exclude" }), u$1("input", { type: "text", id: "module-filter-exclude", value: excludeValue, onInput: handleExcludeChange, placeholder: PLACEHOLDER })] }), u$1("div", { className: "module-filter", children: [u$1("label", { htmlFor: "module-filter-include", children: "Include" }), u$1("input", { type: "text", id: "module-filter-include", value: includeValue, onInput: handleIncludeChange, placeholder: PLACEHOLDER })] })] })] }));
692
+ };
693
+
694
+ function getDefaultExportFromCjs (x) {
695
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
696
+ }
697
+
698
+ var utils$3 = {};
699
+
700
+ const WIN_SLASH = '\\\\/';
701
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
702
+
703
+ /**
704
+ * Posix glob regex
705
+ */
706
+
707
+ const DOT_LITERAL = '\\.';
708
+ const PLUS_LITERAL = '\\+';
709
+ const QMARK_LITERAL = '\\?';
710
+ const SLASH_LITERAL = '\\/';
711
+ const ONE_CHAR = '(?=.)';
712
+ const QMARK = '[^/]';
713
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
714
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
715
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
716
+ const NO_DOT = `(?!${DOT_LITERAL})`;
717
+ const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
718
+ const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
719
+ const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
720
+ const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
721
+ const STAR = `${QMARK}*?`;
722
+ const SEP = '/';
723
+
724
+ const POSIX_CHARS = {
725
+ DOT_LITERAL,
726
+ PLUS_LITERAL,
727
+ QMARK_LITERAL,
728
+ SLASH_LITERAL,
729
+ ONE_CHAR,
730
+ QMARK,
731
+ END_ANCHOR,
732
+ DOTS_SLASH,
733
+ NO_DOT,
734
+ NO_DOTS,
735
+ NO_DOT_SLASH,
736
+ NO_DOTS_SLASH,
737
+ QMARK_NO_DOT,
738
+ STAR,
739
+ START_ANCHOR,
740
+ SEP
741
+ };
742
+
743
+ /**
744
+ * Windows glob regex
745
+ */
746
+
747
+ const WINDOWS_CHARS = {
748
+ ...POSIX_CHARS,
749
+
750
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
751
+ QMARK: WIN_NO_SLASH,
752
+ STAR: `${WIN_NO_SLASH}*?`,
753
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
754
+ NO_DOT: `(?!${DOT_LITERAL})`,
755
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
756
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
757
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
758
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
759
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
760
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
761
+ SEP: '\\'
762
+ };
763
+
764
+ /**
765
+ * POSIX Bracket Regex
766
+ */
767
+
768
+ const POSIX_REGEX_SOURCE$1 = {
769
+ alnum: 'a-zA-Z0-9',
770
+ alpha: 'a-zA-Z',
771
+ ascii: '\\x00-\\x7F',
772
+ blank: ' \\t',
773
+ cntrl: '\\x00-\\x1F\\x7F',
774
+ digit: '0-9',
775
+ graph: '\\x21-\\x7E',
776
+ lower: 'a-z',
777
+ print: '\\x20-\\x7E ',
778
+ punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
779
+ space: ' \\t\\r\\n\\v\\f',
780
+ upper: 'A-Z',
781
+ word: 'A-Za-z0-9_',
782
+ xdigit: 'A-Fa-f0-9'
783
+ };
784
+
785
+ var constants$3 = {
786
+ MAX_LENGTH: 1024 * 64,
787
+ POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
788
+
789
+ // regular expressions
790
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
791
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
792
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
793
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
794
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
795
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
796
+
797
+ // Replace globs with equivalent patterns to reduce parsing time.
798
+ REPLACEMENTS: {
799
+ '***': '*',
800
+ '**/**': '**',
801
+ '**/**/**': '**'
802
+ },
803
+
804
+ // Digits
805
+ CHAR_0: 48, /* 0 */
806
+ CHAR_9: 57, /* 9 */
807
+
808
+ // Alphabet chars.
809
+ CHAR_UPPERCASE_A: 65, /* A */
810
+ CHAR_LOWERCASE_A: 97, /* a */
811
+ CHAR_UPPERCASE_Z: 90, /* Z */
812
+ CHAR_LOWERCASE_Z: 122, /* z */
813
+
814
+ CHAR_LEFT_PARENTHESES: 40, /* ( */
815
+ CHAR_RIGHT_PARENTHESES: 41, /* ) */
816
+
817
+ CHAR_ASTERISK: 42, /* * */
818
+
819
+ // Non-alphabetic chars.
820
+ CHAR_AMPERSAND: 38, /* & */
821
+ CHAR_AT: 64, /* @ */
822
+ CHAR_BACKWARD_SLASH: 92, /* \ */
823
+ CHAR_CARRIAGE_RETURN: 13, /* \r */
824
+ CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
825
+ CHAR_COLON: 58, /* : */
826
+ CHAR_COMMA: 44, /* , */
827
+ CHAR_DOT: 46, /* . */
828
+ CHAR_DOUBLE_QUOTE: 34, /* " */
829
+ CHAR_EQUAL: 61, /* = */
830
+ CHAR_EXCLAMATION_MARK: 33, /* ! */
831
+ CHAR_FORM_FEED: 12, /* \f */
832
+ CHAR_FORWARD_SLASH: 47, /* / */
833
+ CHAR_GRAVE_ACCENT: 96, /* ` */
834
+ CHAR_HASH: 35, /* # */
835
+ CHAR_HYPHEN_MINUS: 45, /* - */
836
+ CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
837
+ CHAR_LEFT_CURLY_BRACE: 123, /* { */
838
+ CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
839
+ CHAR_LINE_FEED: 10, /* \n */
840
+ CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
841
+ CHAR_PERCENT: 37, /* % */
842
+ CHAR_PLUS: 43, /* + */
843
+ CHAR_QUESTION_MARK: 63, /* ? */
844
+ CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
845
+ CHAR_RIGHT_CURLY_BRACE: 125, /* } */
846
+ CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
847
+ CHAR_SEMICOLON: 59, /* ; */
848
+ CHAR_SINGLE_QUOTE: 39, /* ' */
849
+ CHAR_SPACE: 32, /* */
850
+ CHAR_TAB: 9, /* \t */
851
+ CHAR_UNDERSCORE: 95, /* _ */
852
+ CHAR_VERTICAL_LINE: 124, /* | */
853
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
854
+
855
+ /**
856
+ * Create EXTGLOB_CHARS
857
+ */
858
+
859
+ extglobChars(chars) {
860
+ return {
861
+ '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
862
+ '?': { type: 'qmark', open: '(?:', close: ')?' },
863
+ '+': { type: 'plus', open: '(?:', close: ')+' },
864
+ '*': { type: 'star', open: '(?:', close: ')*' },
865
+ '@': { type: 'at', open: '(?:', close: ')' }
866
+ };
867
+ },
868
+
869
+ /**
870
+ * Create GLOB_CHARS
871
+ */
872
+
873
+ globChars(win32) {
874
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
875
+ }
876
+ };
877
+
878
+ (function (exports) {
879
+
880
+ const {
881
+ REGEX_BACKSLASH,
882
+ REGEX_REMOVE_BACKSLASH,
883
+ REGEX_SPECIAL_CHARS,
884
+ REGEX_SPECIAL_CHARS_GLOBAL
885
+ } = constants$3;
886
+
887
+ exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
888
+ exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
889
+ exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
890
+ exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
891
+ exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
892
+
893
+ exports.removeBackslashes = str => {
894
+ return str.replace(REGEX_REMOVE_BACKSLASH, match => {
895
+ return match === '\\' ? '' : match;
896
+ });
897
+ };
898
+
899
+ exports.supportsLookbehinds = () => {
900
+ const segs = process.version.slice(1).split('.').map(Number);
901
+ if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
902
+ return true;
903
+ }
904
+ return false;
905
+ };
906
+
907
+ exports.escapeLast = (input, char, lastIdx) => {
908
+ const idx = input.lastIndexOf(char, lastIdx);
909
+ if (idx === -1) return input;
910
+ if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
911
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
912
+ };
913
+
914
+ exports.removePrefix = (input, state = {}) => {
915
+ let output = input;
916
+ if (output.startsWith('./')) {
917
+ output = output.slice(2);
918
+ state.prefix = './';
919
+ }
920
+ return output;
921
+ };
922
+
923
+ exports.wrapOutput = (input, state = {}, options = {}) => {
924
+ const prepend = options.contains ? '' : '^';
925
+ const append = options.contains ? '' : '$';
926
+
927
+ let output = `${prepend}(?:${input})${append}`;
928
+ if (state.negated === true) {
929
+ output = `(?:^(?!${output}).*$)`;
930
+ }
931
+ return output;
932
+ };
933
+
934
+ exports.basename = (path, { windows } = {}) => {
935
+ if (windows) {
936
+ return path.replace(/[\\/]$/, '').replace(/.*[\\/]/, '');
937
+ } else {
938
+ return path.replace(/\/$/, '').replace(/.*\//, '');
939
+ }
940
+ };
941
+ } (utils$3));
942
+
943
+ const utils$2 = utils$3;
944
+ const {
945
+ CHAR_ASTERISK, /* * */
946
+ CHAR_AT, /* @ */
947
+ CHAR_BACKWARD_SLASH, /* \ */
948
+ CHAR_COMMA, /* , */
949
+ CHAR_DOT, /* . */
950
+ CHAR_EXCLAMATION_MARK, /* ! */
951
+ CHAR_FORWARD_SLASH, /* / */
952
+ CHAR_LEFT_CURLY_BRACE, /* { */
953
+ CHAR_LEFT_PARENTHESES, /* ( */
954
+ CHAR_LEFT_SQUARE_BRACKET, /* [ */
955
+ CHAR_PLUS, /* + */
956
+ CHAR_QUESTION_MARK, /* ? */
957
+ CHAR_RIGHT_CURLY_BRACE, /* } */
958
+ CHAR_RIGHT_PARENTHESES, /* ) */
959
+ CHAR_RIGHT_SQUARE_BRACKET /* ] */
960
+ } = constants$3;
961
+
962
+ const isPathSeparator = code => {
963
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
964
+ };
965
+
966
+ const depth = token => {
967
+ if (token.isPrefix !== true) {
968
+ token.depth = token.isGlobstar ? Infinity : 1;
969
+ }
970
+ };
971
+
972
+ /**
973
+ * Quickly scans a glob pattern and returns an object with a handful of
974
+ * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
975
+ * `glob` (the actual pattern), and `negated` (true if the path starts with `!`).
976
+ *
977
+ * ```js
978
+ * const pm = require('picomatch');
979
+ * console.log(pm.scan('foo/bar/*.js'));
980
+ * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
981
+ * ```
982
+ * @param {String} `str`
983
+ * @param {Object} `options`
984
+ * @return {Object} Returns an object with tokens and regex source string.
985
+ * @api public
986
+ */
987
+
988
+ const scan$1 = (input, options) => {
989
+ const opts = options || {};
990
+
991
+ const length = input.length - 1;
992
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
993
+ const slashes = [];
994
+ const tokens = [];
995
+ const parts = [];
996
+
997
+ let str = input;
998
+ let index = -1;
999
+ let start = 0;
1000
+ let lastIndex = 0;
1001
+ let isBrace = false;
1002
+ let isBracket = false;
1003
+ let isGlob = false;
1004
+ let isExtglob = false;
1005
+ let isGlobstar = false;
1006
+ let braceEscaped = false;
1007
+ let backslashes = false;
1008
+ let negated = false;
1009
+ let finished = false;
1010
+ let braces = 0;
1011
+ let prev;
1012
+ let code;
1013
+ let token = { value: '', depth: 0, isGlob: false };
1014
+
1015
+ const eos = () => index >= length;
1016
+ const peek = () => str.charCodeAt(index + 1);
1017
+ const advance = () => {
1018
+ prev = code;
1019
+ return str.charCodeAt(++index);
1020
+ };
1021
+
1022
+ while (index < length) {
1023
+ code = advance();
1024
+ let next;
1025
+
1026
+ if (code === CHAR_BACKWARD_SLASH) {
1027
+ backslashes = token.backslashes = true;
1028
+ code = advance();
1029
+
1030
+ if (code === CHAR_LEFT_CURLY_BRACE) {
1031
+ braceEscaped = true;
1032
+ }
1033
+ continue;
1034
+ }
1035
+
1036
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
1037
+ braces++;
1038
+
1039
+ while (eos() !== true && (code = advance())) {
1040
+ if (code === CHAR_BACKWARD_SLASH) {
1041
+ backslashes = token.backslashes = true;
1042
+ advance();
1043
+ continue;
1044
+ }
1045
+
1046
+ if (code === CHAR_LEFT_CURLY_BRACE) {
1047
+ braces++;
1048
+ continue;
1049
+ }
1050
+
1051
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
1052
+ isBrace = token.isBrace = true;
1053
+ isGlob = token.isGlob = true;
1054
+ finished = true;
1055
+
1056
+ if (scanToEnd === true) {
1057
+ continue;
1058
+ }
1059
+
1060
+ break;
1061
+ }
1062
+
1063
+ if (braceEscaped !== true && code === CHAR_COMMA) {
1064
+ isBrace = token.isBrace = true;
1065
+ isGlob = token.isGlob = true;
1066
+ finished = true;
1067
+
1068
+ if (scanToEnd === true) {
1069
+ continue;
1070
+ }
1071
+
1072
+ break;
1073
+ }
1074
+
1075
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
1076
+ braces--;
1077
+
1078
+ if (braces === 0) {
1079
+ braceEscaped = false;
1080
+ isBrace = token.isBrace = true;
1081
+ finished = true;
1082
+ break;
1083
+ }
1084
+ }
1085
+ }
1086
+
1087
+ if (scanToEnd === true) {
1088
+ continue;
1089
+ }
1090
+
1091
+ break;
1092
+ }
1093
+
1094
+ if (code === CHAR_FORWARD_SLASH) {
1095
+ slashes.push(index);
1096
+ tokens.push(token);
1097
+ token = { value: '', depth: 0, isGlob: false };
1098
+
1099
+ if (finished === true) continue;
1100
+ if (prev === CHAR_DOT && index === (start + 1)) {
1101
+ start += 2;
1102
+ continue;
1103
+ }
1104
+
1105
+ lastIndex = index + 1;
1106
+ continue;
1107
+ }
1108
+
1109
+ if (opts.noext !== true) {
1110
+ const isExtglobChar = code === CHAR_PLUS
1111
+ || code === CHAR_AT
1112
+ || code === CHAR_ASTERISK
1113
+ || code === CHAR_QUESTION_MARK
1114
+ || code === CHAR_EXCLAMATION_MARK;
1115
+
1116
+ if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
1117
+ isGlob = token.isGlob = true;
1118
+ isExtglob = token.isExtglob = true;
1119
+ finished = true;
1120
+
1121
+ if (scanToEnd === true) {
1122
+ while (eos() !== true && (code = advance())) {
1123
+ if (code === CHAR_BACKWARD_SLASH) {
1124
+ backslashes = token.backslashes = true;
1125
+ code = advance();
1126
+ continue;
1127
+ }
1128
+
1129
+ if (code === CHAR_RIGHT_PARENTHESES) {
1130
+ isGlob = token.isGlob = true;
1131
+ finished = true;
1132
+ break;
1133
+ }
1134
+ }
1135
+ continue;
1136
+ }
1137
+ break;
1138
+ }
1139
+ }
1140
+
1141
+ if (code === CHAR_ASTERISK) {
1142
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
1143
+ isGlob = token.isGlob = true;
1144
+ finished = true;
1145
+
1146
+ if (scanToEnd === true) {
1147
+ continue;
1148
+ }
1149
+ break;
1150
+ }
1151
+
1152
+ if (code === CHAR_QUESTION_MARK) {
1153
+ isGlob = token.isGlob = true;
1154
+ finished = true;
1155
+
1156
+ if (scanToEnd === true) {
1157
+ continue;
1158
+ }
1159
+ break;
1160
+ }
1161
+
1162
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
1163
+ while (eos() !== true && (next = advance())) {
1164
+ if (next === CHAR_BACKWARD_SLASH) {
1165
+ backslashes = token.backslashes = true;
1166
+ advance();
1167
+ continue;
1168
+ }
1169
+
1170
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
1171
+ isBracket = token.isBracket = true;
1172
+ isGlob = token.isGlob = true;
1173
+ finished = true;
1174
+
1175
+ if (scanToEnd === true) {
1176
+ continue;
1177
+ }
1178
+ break;
1179
+ }
1180
+ }
1181
+ }
1182
+
1183
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
1184
+ negated = token.negated = true;
1185
+ start++;
1186
+ continue;
1187
+ }
1188
+
1189
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
1190
+ isGlob = token.isGlob = true;
1191
+
1192
+ if (scanToEnd === true) {
1193
+ while (eos() !== true && (code = advance())) {
1194
+ if (code === CHAR_LEFT_PARENTHESES) {
1195
+ backslashes = token.backslashes = true;
1196
+ code = advance();
1197
+ continue;
1198
+ }
1199
+
1200
+ if (code === CHAR_RIGHT_PARENTHESES) {
1201
+ finished = true;
1202
+ break;
1203
+ }
1204
+ }
1205
+ continue;
1206
+ }
1207
+ break;
1208
+ }
1209
+
1210
+ if (isGlob === true) {
1211
+ finished = true;
1212
+
1213
+ if (scanToEnd === true) {
1214
+ continue;
1215
+ }
1216
+
1217
+ break;
1218
+ }
1219
+ }
1220
+
1221
+ if (opts.noext === true) {
1222
+ isExtglob = false;
1223
+ isGlob = false;
1224
+ }
1225
+
1226
+ let base = str;
1227
+ let prefix = '';
1228
+ let glob = '';
1229
+
1230
+ if (start > 0) {
1231
+ prefix = str.slice(0, start);
1232
+ str = str.slice(start);
1233
+ lastIndex -= start;
1234
+ }
1235
+
1236
+ if (base && isGlob === true && lastIndex > 0) {
1237
+ base = str.slice(0, lastIndex);
1238
+ glob = str.slice(lastIndex);
1239
+ } else if (isGlob === true) {
1240
+ base = '';
1241
+ glob = str;
1242
+ } else {
1243
+ base = str;
1244
+ }
1245
+
1246
+ if (base && base !== '' && base !== '/' && base !== str) {
1247
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
1248
+ base = base.slice(0, -1);
1249
+ }
1250
+ }
1251
+
1252
+ if (opts.unescape === true) {
1253
+ if (glob) glob = utils$2.removeBackslashes(glob);
1254
+
1255
+ if (base && backslashes === true) {
1256
+ base = utils$2.removeBackslashes(base);
1257
+ }
1258
+ }
1259
+
1260
+ const state = {
1261
+ prefix,
1262
+ input,
1263
+ start,
1264
+ base,
1265
+ glob,
1266
+ isBrace,
1267
+ isBracket,
1268
+ isGlob,
1269
+ isExtglob,
1270
+ isGlobstar,
1271
+ negated
1272
+ };
1273
+
1274
+ if (opts.tokens === true) {
1275
+ state.maxDepth = 0;
1276
+ if (!isPathSeparator(code)) {
1277
+ tokens.push(token);
1278
+ }
1279
+ state.tokens = tokens;
1280
+ }
1281
+
1282
+ if (opts.parts === true || opts.tokens === true) {
1283
+ let prevIndex;
1284
+
1285
+ for (let idx = 0; idx < slashes.length; idx++) {
1286
+ const n = prevIndex ? prevIndex + 1 : start;
1287
+ const i = slashes[idx];
1288
+ const value = input.slice(n, i);
1289
+ if (opts.tokens) {
1290
+ if (idx === 0 && start !== 0) {
1291
+ tokens[idx].isPrefix = true;
1292
+ tokens[idx].value = prefix;
1293
+ } else {
1294
+ tokens[idx].value = value;
1295
+ }
1296
+ depth(tokens[idx]);
1297
+ state.maxDepth += tokens[idx].depth;
1298
+ }
1299
+ if (idx !== 0 || value !== '') {
1300
+ parts.push(value);
1301
+ }
1302
+ prevIndex = i;
1303
+ }
1304
+
1305
+ if (prevIndex && prevIndex + 1 < input.length) {
1306
+ const value = input.slice(prevIndex + 1);
1307
+ parts.push(value);
1308
+
1309
+ if (opts.tokens) {
1310
+ tokens[tokens.length - 1].value = value;
1311
+ depth(tokens[tokens.length - 1]);
1312
+ state.maxDepth += tokens[tokens.length - 1].depth;
1313
+ }
1314
+ }
1315
+
1316
+ state.slashes = slashes;
1317
+ state.parts = parts;
1318
+ }
1319
+
1320
+ return state;
1321
+ };
1322
+
1323
+ var scan_1 = scan$1;
1324
+
1325
+ const constants$2 = constants$3;
1326
+ const utils$1 = utils$3;
1327
+
1328
+ /**
1329
+ * Constants
1330
+ */
1331
+
1332
+ const {
1333
+ MAX_LENGTH,
1334
+ POSIX_REGEX_SOURCE,
1335
+ REGEX_NON_SPECIAL_CHARS,
1336
+ REGEX_SPECIAL_CHARS_BACKREF,
1337
+ REPLACEMENTS
1338
+ } = constants$2;
1339
+
1340
+ /**
1341
+ * Helpers
1342
+ */
1343
+
1344
+ const expandRange = (args, options) => {
1345
+ if (typeof options.expandRange === 'function') {
1346
+ return options.expandRange(...args, options);
1347
+ }
1348
+
1349
+ args.sort();
1350
+ const value = `[${args.join('-')}]`;
1351
+
1352
+ try {
1353
+ /* eslint-disable-next-line no-new */
1354
+ new RegExp(value);
1355
+ } catch (ex) {
1356
+ return args.map(v => utils$1.escapeRegex(v)).join('..');
1357
+ }
1358
+
1359
+ return value;
1360
+ };
1361
+
1362
+ /**
1363
+ * Create the message for a syntax error
1364
+ */
1365
+
1366
+ const syntaxError = (type, char) => {
1367
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
1368
+ };
1369
+
1370
+ /**
1371
+ * Parse the given input string.
1372
+ * @param {String} input
1373
+ * @param {Object} options
1374
+ * @return {Object}
1375
+ */
1376
+
1377
+ const parse$2 = (input, options) => {
1378
+ if (typeof input !== 'string') {
1379
+ throw new TypeError('Expected a string');
1380
+ }
1381
+
1382
+ input = REPLACEMENTS[input] || input;
1383
+
1384
+ const opts = { ...options };
1385
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1386
+
1387
+ let len = input.length;
1388
+ if (len > max) {
1389
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1390
+ }
1391
+
1392
+ const bos = { type: 'bos', value: '', output: opts.prepend || '' };
1393
+ const tokens = [bos];
1394
+
1395
+ const capture = opts.capture ? '' : '?:';
1396
+
1397
+ // create constants based on platform, for windows or posix
1398
+ const PLATFORM_CHARS = constants$2.globChars(opts.windows);
1399
+ const EXTGLOB_CHARS = constants$2.extglobChars(PLATFORM_CHARS);
1400
+
1401
+ const {
1402
+ DOT_LITERAL,
1403
+ PLUS_LITERAL,
1404
+ SLASH_LITERAL,
1405
+ ONE_CHAR,
1406
+ DOTS_SLASH,
1407
+ NO_DOT,
1408
+ NO_DOT_SLASH,
1409
+ NO_DOTS_SLASH,
1410
+ QMARK,
1411
+ QMARK_NO_DOT,
1412
+ STAR,
1413
+ START_ANCHOR
1414
+ } = PLATFORM_CHARS;
1415
+
1416
+ const globstar = (opts) => {
1417
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1418
+ };
1419
+
1420
+ const nodot = opts.dot ? '' : NO_DOT;
1421
+ const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
1422
+ let star = opts.bash === true ? globstar(opts) : STAR;
1423
+
1424
+ if (opts.capture) {
1425
+ star = `(${star})`;
1426
+ }
1427
+
1428
+ // minimatch options support
1429
+ if (typeof opts.noext === 'boolean') {
1430
+ opts.noextglob = opts.noext;
1431
+ }
1432
+
1433
+ const state = {
1434
+ input,
1435
+ index: -1,
1436
+ start: 0,
1437
+ dot: opts.dot === true,
1438
+ consumed: '',
1439
+ output: '',
1440
+ prefix: '',
1441
+ backtrack: false,
1442
+ negated: false,
1443
+ brackets: 0,
1444
+ braces: 0,
1445
+ parens: 0,
1446
+ quotes: 0,
1447
+ globstar: false,
1448
+ tokens
1449
+ };
1450
+
1451
+ input = utils$1.removePrefix(input, state);
1452
+ len = input.length;
1453
+
1454
+ const extglobs = [];
1455
+ const braces = [];
1456
+ const stack = [];
1457
+ let prev = bos;
1458
+ let value;
1459
+
1460
+ /**
1461
+ * Tokenizing helpers
1462
+ */
1463
+
1464
+ const eos = () => state.index === len - 1;
1465
+ const peek = state.peek = (n = 1) => input[state.index + n];
1466
+ const advance = state.advance = () => input[++state.index];
1467
+ const remaining = () => input.slice(state.index + 1);
1468
+ const consume = (value = '', num = 0) => {
1469
+ state.consumed += value;
1470
+ state.index += num;
1471
+ };
1472
+ const append = token => {
1473
+ state.output += token.output != null ? token.output : token.value;
1474
+ consume(token.value);
1475
+ };
1476
+
1477
+ const negate = () => {
1478
+ let count = 1;
1479
+
1480
+ while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
1481
+ advance();
1482
+ state.start++;
1483
+ count++;
1484
+ }
1485
+
1486
+ if (count % 2 === 0) {
1487
+ return false;
1488
+ }
1489
+
1490
+ state.negated = true;
1491
+ state.start++;
1492
+ return true;
1493
+ };
1494
+
1495
+ const increment = type => {
1496
+ state[type]++;
1497
+ stack.push(type);
1498
+ };
1499
+
1500
+ const decrement = type => {
1501
+ state[type]--;
1502
+ stack.pop();
1503
+ };
1504
+
1505
+ /**
1506
+ * Push tokens onto the tokens array. This helper speeds up
1507
+ * tokenizing by 1) helping us avoid backtracking as much as possible,
1508
+ * and 2) helping us avoid creating extra tokens when consecutive
1509
+ * characters are plain text. This improves performance and simplifies
1510
+ * lookbehinds.
1511
+ */
1512
+
1513
+ const push = tok => {
1514
+ if (prev.type === 'globstar') {
1515
+ const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
1516
+ const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
1517
+
1518
+ if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
1519
+ state.output = state.output.slice(0, -prev.output.length);
1520
+ prev.type = 'star';
1521
+ prev.value = '*';
1522
+ prev.output = star;
1523
+ state.output += prev.output;
1524
+ }
1525
+ }
1526
+
1527
+ if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) {
1528
+ extglobs[extglobs.length - 1].inner += tok.value;
1529
+ }
1530
+
1531
+ if (tok.value || tok.output) append(tok);
1532
+ if (prev && prev.type === 'text' && tok.type === 'text') {
1533
+ prev.value += tok.value;
1534
+ prev.output = (prev.output || '') + tok.value;
1535
+ return;
1536
+ }
1537
+
1538
+ tok.prev = prev;
1539
+ tokens.push(tok);
1540
+ prev = tok;
1541
+ };
1542
+
1543
+ const extglobOpen = (type, value) => {
1544
+ const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
1545
+
1546
+ token.prev = prev;
1547
+ token.parens = state.parens;
1548
+ token.output = state.output;
1549
+ const output = (opts.capture ? '(' : '') + token.open;
1550
+
1551
+ increment('parens');
1552
+ push({ type, value, output: state.output ? '' : ONE_CHAR });
1553
+ push({ type: 'paren', extglob: true, value: advance(), output });
1554
+ extglobs.push(token);
1555
+ };
1556
+
1557
+ const extglobClose = token => {
1558
+ let output = token.close + (opts.capture ? ')' : '');
1559
+
1560
+ if (token.type === 'negate') {
1561
+ let extglobStar = star;
1562
+
1563
+ if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
1564
+ extglobStar = globstar(opts);
1565
+ }
1566
+
1567
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
1568
+ output = token.close = `)$))${extglobStar}`;
1569
+ }
1570
+
1571
+ if (token.prev.type === 'bos' && eos()) {
1572
+ state.negatedExtglob = true;
1573
+ }
1574
+ }
1575
+
1576
+ push({ type: 'paren', extglob: true, value, output });
1577
+ decrement('parens');
1578
+ };
1579
+
1580
+ /**
1581
+ * Fast paths
1582
+ */
1583
+
1584
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
1585
+ let backslashes = false;
1586
+
1587
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
1588
+ if (first === '\\') {
1589
+ backslashes = true;
1590
+ return m;
1591
+ }
1592
+
1593
+ if (first === '?') {
1594
+ if (esc) {
1595
+ return esc + first + (rest ? QMARK.repeat(rest.length) : '');
1596
+ }
1597
+ if (index === 0) {
1598
+ return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
1599
+ }
1600
+ return QMARK.repeat(chars.length);
1601
+ }
1602
+
1603
+ if (first === '.') {
1604
+ return DOT_LITERAL.repeat(chars.length);
1605
+ }
1606
+
1607
+ if (first === '*') {
1608
+ if (esc) {
1609
+ return esc + first + (rest ? star : '');
1610
+ }
1611
+ return star;
1612
+ }
1613
+ return esc ? m : `\\${m}`;
1614
+ });
1615
+
1616
+ if (backslashes === true) {
1617
+ if (opts.unescape === true) {
1618
+ output = output.replace(/\\/g, '');
1619
+ } else {
1620
+ output = output.replace(/\\+/g, m => {
1621
+ return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
1622
+ });
1623
+ }
1624
+ }
1625
+
1626
+ if (output === input && opts.contains === true) {
1627
+ state.output = input;
1628
+ return state;
1629
+ }
1630
+
1631
+ state.output = utils$1.wrapOutput(output, state, options);
1632
+ return state;
1633
+ }
1634
+
1635
+ /**
1636
+ * Tokenize input until we reach end-of-string
1637
+ */
1638
+
1639
+ while (!eos()) {
1640
+ value = advance();
1641
+
1642
+ if (value === '\u0000') {
1643
+ continue;
1644
+ }
1645
+
1646
+ /**
1647
+ * Escaped characters
1648
+ */
1649
+
1650
+ if (value === '\\') {
1651
+ const next = peek();
1652
+
1653
+ if (next === '/' && opts.bash !== true) {
1654
+ continue;
1655
+ }
1656
+
1657
+ if (next === '.' || next === ';') {
1658
+ continue;
1659
+ }
1660
+
1661
+ if (!next) {
1662
+ value += '\\';
1663
+ push({ type: 'text', value });
1664
+ continue;
1665
+ }
1666
+
1667
+ // collapse slashes to reduce potential for exploits
1668
+ const match = /^\\+/.exec(remaining());
1669
+ let slashes = 0;
1670
+
1671
+ if (match && match[0].length > 2) {
1672
+ slashes = match[0].length;
1673
+ state.index += slashes;
1674
+ if (slashes % 2 !== 0) {
1675
+ value += '\\';
1676
+ }
1677
+ }
1678
+
1679
+ if (opts.unescape === true) {
1680
+ value = advance() || '';
1681
+ } else {
1682
+ value += advance() || '';
1683
+ }
1684
+
1685
+ if (state.brackets === 0) {
1686
+ push({ type: 'text', value });
1687
+ continue;
1688
+ }
1689
+ }
1690
+
1691
+ /**
1692
+ * If we're inside a regex character class, continue
1693
+ * until we reach the closing bracket.
1694
+ */
1695
+
1696
+ if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
1697
+ if (opts.posix !== false && value === ':') {
1698
+ const inner = prev.value.slice(1);
1699
+ if (inner.includes('[')) {
1700
+ prev.posix = true;
1701
+
1702
+ if (inner.includes(':')) {
1703
+ const idx = prev.value.lastIndexOf('[');
1704
+ const pre = prev.value.slice(0, idx);
1705
+ const rest = prev.value.slice(idx + 2);
1706
+ const posix = POSIX_REGEX_SOURCE[rest];
1707
+ if (posix) {
1708
+ prev.value = pre + posix;
1709
+ state.backtrack = true;
1710
+ advance();
1711
+
1712
+ if (!bos.output && tokens.indexOf(prev) === 1) {
1713
+ bos.output = ONE_CHAR;
1714
+ }
1715
+ continue;
1716
+ }
1717
+ }
1718
+ }
1719
+ }
1720
+
1721
+ if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
1722
+ value = `\\${value}`;
1723
+ }
1724
+
1725
+ if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
1726
+ value = `\\${value}`;
1727
+ }
1728
+
1729
+ if (opts.posix === true && value === '!' && prev.value === '[') {
1730
+ value = '^';
1731
+ }
1732
+
1733
+ prev.value += value;
1734
+ append({ value });
1735
+ continue;
1736
+ }
1737
+
1738
+ /**
1739
+ * If we're inside a quoted string, continue
1740
+ * until we reach the closing double quote.
1741
+ */
1742
+
1743
+ if (state.quotes === 1 && value !== '"') {
1744
+ value = utils$1.escapeRegex(value);
1745
+ prev.value += value;
1746
+ append({ value });
1747
+ continue;
1748
+ }
1749
+
1750
+ /**
1751
+ * Double quotes
1752
+ */
1753
+
1754
+ if (value === '"') {
1755
+ state.quotes = state.quotes === 1 ? 0 : 1;
1756
+ if (opts.keepQuotes === true) {
1757
+ push({ type: 'text', value });
1758
+ }
1759
+ continue;
1760
+ }
1761
+
1762
+ /**
1763
+ * Parentheses
1764
+ */
1765
+
1766
+ if (value === '(') {
1767
+ increment('parens');
1768
+ push({ type: 'paren', value });
1769
+ continue;
1770
+ }
1771
+
1772
+ if (value === ')') {
1773
+ if (state.parens === 0 && opts.strictBrackets === true) {
1774
+ throw new SyntaxError(syntaxError('opening', '('));
1775
+ }
1776
+
1777
+ const extglob = extglobs[extglobs.length - 1];
1778
+ if (extglob && state.parens === extglob.parens + 1) {
1779
+ extglobClose(extglobs.pop());
1780
+ continue;
1781
+ }
1782
+
1783
+ push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
1784
+ decrement('parens');
1785
+ continue;
1786
+ }
1787
+
1788
+ /**
1789
+ * Square brackets
1790
+ */
1791
+
1792
+ if (value === '[') {
1793
+ if (opts.nobracket === true || !remaining().includes(']')) {
1794
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
1795
+ throw new SyntaxError(syntaxError('closing', ']'));
1796
+ }
1797
+
1798
+ value = `\\${value}`;
1799
+ } else {
1800
+ increment('brackets');
1801
+ }
1802
+
1803
+ push({ type: 'bracket', value });
1804
+ continue;
1805
+ }
1806
+
1807
+ if (value === ']') {
1808
+ if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
1809
+ push({ type: 'text', value, output: `\\${value}` });
1810
+ continue;
1811
+ }
1812
+
1813
+ if (state.brackets === 0) {
1814
+ if (opts.strictBrackets === true) {
1815
+ throw new SyntaxError(syntaxError('opening', '['));
1816
+ }
1817
+
1818
+ push({ type: 'text', value, output: `\\${value}` });
1819
+ continue;
1820
+ }
1821
+
1822
+ decrement('brackets');
1823
+
1824
+ const prevValue = prev.value.slice(1);
1825
+ if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
1826
+ value = `/${value}`;
1827
+ }
1828
+
1829
+ prev.value += value;
1830
+ append({ value });
1831
+
1832
+ // when literal brackets are explicitly disabled
1833
+ // assume we should match with a regex character class
1834
+ if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
1835
+ continue;
1836
+ }
1837
+
1838
+ const escaped = utils$1.escapeRegex(prev.value);
1839
+ state.output = state.output.slice(0, -prev.value.length);
1840
+
1841
+ // when literal brackets are explicitly enabled
1842
+ // assume we should escape the brackets to match literal characters
1843
+ if (opts.literalBrackets === true) {
1844
+ state.output += escaped;
1845
+ prev.value = escaped;
1846
+ continue;
1847
+ }
1848
+
1849
+ // when the user specifies nothing, try to match both
1850
+ prev.value = `(${capture}${escaped}|${prev.value})`;
1851
+ state.output += prev.value;
1852
+ continue;
1853
+ }
1854
+
1855
+ /**
1856
+ * Braces
1857
+ */
1858
+
1859
+ if (value === '{' && opts.nobrace !== true) {
1860
+ increment('braces');
1861
+
1862
+ const open = {
1863
+ type: 'brace',
1864
+ value,
1865
+ output: '(',
1866
+ outputIndex: state.output.length,
1867
+ tokensIndex: state.tokens.length
1868
+ };
1869
+
1870
+ braces.push(open);
1871
+ push(open);
1872
+ continue;
1873
+ }
1874
+
1875
+ if (value === '}') {
1876
+ const brace = braces[braces.length - 1];
1877
+
1878
+ if (opts.nobrace === true || !brace) {
1879
+ push({ type: 'text', value, output: value });
1880
+ continue;
1881
+ }
1882
+
1883
+ let output = ')';
1884
+
1885
+ if (brace.dots === true) {
1886
+ const arr = tokens.slice();
1887
+ const range = [];
1888
+
1889
+ for (let i = arr.length - 1; i >= 0; i--) {
1890
+ tokens.pop();
1891
+ if (arr[i].type === 'brace') {
1892
+ break;
1893
+ }
1894
+ if (arr[i].type !== 'dots') {
1895
+ range.unshift(arr[i].value);
1896
+ }
1897
+ }
1898
+
1899
+ output = expandRange(range, opts);
1900
+ state.backtrack = true;
1901
+ }
1902
+
1903
+ if (brace.comma !== true && brace.dots !== true) {
1904
+ const out = state.output.slice(0, brace.outputIndex);
1905
+ const toks = state.tokens.slice(brace.tokensIndex);
1906
+ brace.value = brace.output = '\\{';
1907
+ value = output = '\\}';
1908
+ state.output = out;
1909
+ for (const t of toks) {
1910
+ state.output += (t.output || t.value);
1911
+ }
1912
+ }
1913
+
1914
+ push({ type: 'brace', value, output });
1915
+ decrement('braces');
1916
+ braces.pop();
1917
+ continue;
1918
+ }
1919
+
1920
+ /**
1921
+ * Pipes
1922
+ */
1923
+
1924
+ if (value === '|') {
1925
+ if (extglobs.length > 0) {
1926
+ extglobs[extglobs.length - 1].conditions++;
1927
+ }
1928
+ push({ type: 'text', value });
1929
+ continue;
1930
+ }
1931
+
1932
+ /**
1933
+ * Commas
1934
+ */
1935
+
1936
+ if (value === ',') {
1937
+ let output = value;
1938
+
1939
+ const brace = braces[braces.length - 1];
1940
+ if (brace && stack[stack.length - 1] === 'braces') {
1941
+ brace.comma = true;
1942
+ output = '|';
1943
+ }
1944
+
1945
+ push({ type: 'comma', value, output });
1946
+ continue;
1947
+ }
1948
+
1949
+ /**
1950
+ * Slashes
1951
+ */
1952
+
1953
+ if (value === '/') {
1954
+ // if the beginning of the glob is "./", advance the start
1955
+ // to the current index, and don't add the "./" characters
1956
+ // to the state. This greatly simplifies lookbehinds when
1957
+ // checking for BOS characters like "!" and "." (not "./")
1958
+ if (prev.type === 'dot' && state.index === state.start + 1) {
1959
+ state.start = state.index + 1;
1960
+ state.consumed = '';
1961
+ state.output = '';
1962
+ tokens.pop();
1963
+ prev = bos; // reset "prev" to the first token
1964
+ continue;
1965
+ }
1966
+
1967
+ push({ type: 'slash', value, output: SLASH_LITERAL });
1968
+ continue;
1969
+ }
1970
+
1971
+ /**
1972
+ * Dots
1973
+ */
1974
+
1975
+ if (value === '.') {
1976
+ if (state.braces > 0 && prev.type === 'dot') {
1977
+ if (prev.value === '.') prev.output = DOT_LITERAL;
1978
+ const brace = braces[braces.length - 1];
1979
+ prev.type = 'dots';
1980
+ prev.output += value;
1981
+ prev.value += value;
1982
+ brace.dots = true;
1983
+ continue;
1984
+ }
1985
+
1986
+ if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
1987
+ push({ type: 'text', value, output: DOT_LITERAL });
1988
+ continue;
1989
+ }
1990
+
1991
+ push({ type: 'dot', value, output: DOT_LITERAL });
1992
+ continue;
1993
+ }
1994
+
1995
+ /**
1996
+ * Question marks
1997
+ */
1998
+
1999
+ if (value === '?') {
2000
+ const isGroup = prev && prev.value === '(';
2001
+ if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2002
+ extglobOpen('qmark', value);
2003
+ continue;
2004
+ }
2005
+
2006
+ if (prev && prev.type === 'paren') {
2007
+ const next = peek();
2008
+ let output = value;
2009
+
2010
+ if (next === '<' && !utils$1.supportsLookbehinds()) {
2011
+ throw new Error('Node.js v10 or higher is required for regex lookbehinds');
2012
+ }
2013
+
2014
+ if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
2015
+ output = `\\${value}`;
2016
+ }
2017
+
2018
+ push({ type: 'text', value, output });
2019
+ continue;
2020
+ }
2021
+
2022
+ if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
2023
+ push({ type: 'qmark', value, output: QMARK_NO_DOT });
2024
+ continue;
2025
+ }
2026
+
2027
+ push({ type: 'qmark', value, output: QMARK });
2028
+ continue;
2029
+ }
2030
+
2031
+ /**
2032
+ * Exclamation
2033
+ */
2034
+
2035
+ if (value === '!') {
2036
+ if (opts.noextglob !== true && peek() === '(') {
2037
+ if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
2038
+ extglobOpen('negate', value);
2039
+ continue;
2040
+ }
2041
+ }
2042
+
2043
+ if (opts.nonegate !== true && state.index === 0) {
2044
+ negate();
2045
+ continue;
2046
+ }
2047
+ }
2048
+
2049
+ /**
2050
+ * Plus
2051
+ */
2052
+
2053
+ if (value === '+') {
2054
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2055
+ extglobOpen('plus', value);
2056
+ continue;
2057
+ }
2058
+
2059
+ if ((prev && prev.value === '(') || opts.regex === false) {
2060
+ push({ type: 'plus', value, output: PLUS_LITERAL });
2061
+ continue;
2062
+ }
2063
+
2064
+ if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
2065
+ push({ type: 'plus', value });
2066
+ continue;
2067
+ }
2068
+
2069
+ push({ type: 'plus', value: PLUS_LITERAL });
2070
+ continue;
2071
+ }
2072
+
2073
+ /**
2074
+ * Plain text
2075
+ */
2076
+
2077
+ if (value === '@') {
2078
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2079
+ push({ type: 'at', extglob: true, value, output: '' });
2080
+ continue;
2081
+ }
2082
+
2083
+ push({ type: 'text', value });
2084
+ continue;
2085
+ }
2086
+
2087
+ /**
2088
+ * Plain text
2089
+ */
2090
+
2091
+ if (value !== '*') {
2092
+ if (value === '$' || value === '^') {
2093
+ value = `\\${value}`;
2094
+ }
2095
+
2096
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
2097
+ if (match) {
2098
+ value += match[0];
2099
+ state.index += match[0].length;
2100
+ }
2101
+
2102
+ push({ type: 'text', value });
2103
+ continue;
2104
+ }
2105
+
2106
+ /**
2107
+ * Stars
2108
+ */
2109
+
2110
+ if (prev && (prev.type === 'globstar' || prev.star === true)) {
2111
+ prev.type = 'star';
2112
+ prev.star = true;
2113
+ prev.value += value;
2114
+ prev.output = star;
2115
+ state.backtrack = true;
2116
+ state.globstar = true;
2117
+ consume(value);
2118
+ continue;
2119
+ }
2120
+
2121
+ let rest = remaining();
2122
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
2123
+ extglobOpen('star', value);
2124
+ continue;
2125
+ }
2126
+
2127
+ if (prev.type === 'star') {
2128
+ if (opts.noglobstar === true) {
2129
+ consume(value);
2130
+ continue;
2131
+ }
2132
+
2133
+ const prior = prev.prev;
2134
+ const before = prior.prev;
2135
+ const isStart = prior.type === 'slash' || prior.type === 'bos';
2136
+ const afterStar = before && (before.type === 'star' || before.type === 'globstar');
2137
+
2138
+ if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
2139
+ push({ type: 'star', value, output: '' });
2140
+ continue;
2141
+ }
2142
+
2143
+ const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
2144
+ const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
2145
+ if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
2146
+ push({ type: 'star', value, output: '' });
2147
+ continue;
2148
+ }
2149
+
2150
+ // strip consecutive `/**/`
2151
+ while (rest.slice(0, 3) === '/**') {
2152
+ const after = input[state.index + 4];
2153
+ if (after && after !== '/') {
2154
+ break;
2155
+ }
2156
+ rest = rest.slice(3);
2157
+ consume('/**', 3);
2158
+ }
2159
+
2160
+ if (prior.type === 'bos' && eos()) {
2161
+ prev.type = 'globstar';
2162
+ prev.value += value;
2163
+ prev.output = globstar(opts);
2164
+ state.output = prev.output;
2165
+ state.globstar = true;
2166
+ consume(value);
2167
+ continue;
2168
+ }
2169
+
2170
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
2171
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
2172
+ prior.output = `(?:${prior.output}`;
2173
+
2174
+ prev.type = 'globstar';
2175
+ prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
2176
+ prev.value += value;
2177
+ state.globstar = true;
2178
+ state.output += prior.output + prev.output;
2179
+ consume(value);
2180
+ continue;
2181
+ }
2182
+
2183
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
2184
+ const end = rest[1] !== void 0 ? '|$' : '';
2185
+
2186
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
2187
+ prior.output = `(?:${prior.output}`;
2188
+
2189
+ prev.type = 'globstar';
2190
+ prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
2191
+ prev.value += value;
2192
+
2193
+ state.output += prior.output + prev.output;
2194
+ state.globstar = true;
2195
+
2196
+ consume(value + advance());
2197
+
2198
+ push({ type: 'slash', value: '/', output: '' });
2199
+ continue;
2200
+ }
2201
+
2202
+ if (prior.type === 'bos' && rest[0] === '/') {
2203
+ prev.type = 'globstar';
2204
+ prev.value += value;
2205
+ prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
2206
+ state.output = prev.output;
2207
+ state.globstar = true;
2208
+ consume(value + advance());
2209
+ push({ type: 'slash', value: '/', output: '' });
2210
+ continue;
2211
+ }
2212
+
2213
+ // remove single star from output
2214
+ state.output = state.output.slice(0, -prev.output.length);
2215
+
2216
+ // reset previous token to globstar
2217
+ prev.type = 'globstar';
2218
+ prev.output = globstar(opts);
2219
+ prev.value += value;
2220
+
2221
+ // reset output with globstar
2222
+ state.output += prev.output;
2223
+ state.globstar = true;
2224
+ consume(value);
2225
+ continue;
2226
+ }
2227
+
2228
+ const token = { type: 'star', value, output: star };
2229
+
2230
+ if (opts.bash === true) {
2231
+ token.output = '.*?';
2232
+ if (prev.type === 'bos' || prev.type === 'slash') {
2233
+ token.output = nodot + token.output;
2234
+ }
2235
+ push(token);
2236
+ continue;
2237
+ }
2238
+
2239
+ if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
2240
+ token.output = value;
2241
+ push(token);
2242
+ continue;
2243
+ }
2244
+
2245
+ if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
2246
+ if (prev.type === 'dot') {
2247
+ state.output += NO_DOT_SLASH;
2248
+ prev.output += NO_DOT_SLASH;
2249
+
2250
+ } else if (opts.dot === true) {
2251
+ state.output += NO_DOTS_SLASH;
2252
+ prev.output += NO_DOTS_SLASH;
2253
+
2254
+ } else {
2255
+ state.output += nodot;
2256
+ prev.output += nodot;
2257
+ }
2258
+
2259
+ if (peek() !== '*') {
2260
+ state.output += ONE_CHAR;
2261
+ prev.output += ONE_CHAR;
2262
+ }
2263
+ }
2264
+
2265
+ push(token);
2266
+ }
2267
+
2268
+ while (state.brackets > 0) {
2269
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
2270
+ state.output = utils$1.escapeLast(state.output, '[');
2271
+ decrement('brackets');
2272
+ }
2273
+
2274
+ while (state.parens > 0) {
2275
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
2276
+ state.output = utils$1.escapeLast(state.output, '(');
2277
+ decrement('parens');
2278
+ }
2279
+
2280
+ while (state.braces > 0) {
2281
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
2282
+ state.output = utils$1.escapeLast(state.output, '{');
2283
+ decrement('braces');
2284
+ }
2285
+
2286
+ if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
2287
+ push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
2288
+ }
2289
+
2290
+ // rebuild the output if we had to backtrack at any point
2291
+ if (state.backtrack === true) {
2292
+ state.output = '';
2293
+
2294
+ for (const token of state.tokens) {
2295
+ state.output += token.output != null ? token.output : token.value;
2296
+
2297
+ if (token.suffix) {
2298
+ state.output += token.suffix;
2299
+ }
2300
+ }
2301
+ }
2302
+
2303
+ return state;
2304
+ };
2305
+
2306
+ /**
2307
+ * Fast paths for creating regular expressions for common glob patterns.
2308
+ * This can significantly speed up processing and has very little downside
2309
+ * impact when none of the fast paths match.
2310
+ */
2311
+
2312
+ parse$2.fastpaths = (input, options) => {
2313
+ const opts = { ...options };
2314
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
2315
+ const len = input.length;
2316
+ if (len > max) {
2317
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
2318
+ }
2319
+
2320
+ input = REPLACEMENTS[input] || input;
2321
+
2322
+ // create constants based on platform, for windows or posix
2323
+ const {
2324
+ DOT_LITERAL,
2325
+ SLASH_LITERAL,
2326
+ ONE_CHAR,
2327
+ DOTS_SLASH,
2328
+ NO_DOT,
2329
+ NO_DOTS,
2330
+ NO_DOTS_SLASH,
2331
+ STAR,
2332
+ START_ANCHOR
2333
+ } = constants$2.globChars(opts.windows);
2334
+
2335
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
2336
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
2337
+ const capture = opts.capture ? '' : '?:';
2338
+ const state = { negated: false, prefix: '' };
2339
+ let star = opts.bash === true ? '.*?' : STAR;
2340
+
2341
+ if (opts.capture) {
2342
+ star = `(${star})`;
2343
+ }
2344
+
2345
+ const globstar = (opts) => {
2346
+ if (opts.noglobstar === true) return star;
2347
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
2348
+ };
2349
+
2350
+ const create = str => {
2351
+ switch (str) {
2352
+ case '*':
2353
+ return `${nodot}${ONE_CHAR}${star}`;
2354
+
2355
+ case '.*':
2356
+ return `${DOT_LITERAL}${ONE_CHAR}${star}`;
2357
+
2358
+ case '*.*':
2359
+ return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
2360
+
2361
+ case '*/*':
2362
+ return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
2363
+
2364
+ case '**':
2365
+ return nodot + globstar(opts);
2366
+
2367
+ case '**/*':
2368
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
2369
+
2370
+ case '**/*.*':
2371
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
2372
+
2373
+ case '**/.*':
2374
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
2375
+
2376
+ default: {
2377
+ const match = /^(.*?)\.(\w+)$/.exec(str);
2378
+ if (!match) return;
2379
+
2380
+ const source = create(match[1]);
2381
+ if (!source) return;
2382
+
2383
+ return source + DOT_LITERAL + match[2];
2384
+ }
2385
+ }
2386
+ };
2387
+
2388
+ const output = utils$1.removePrefix(input, state);
2389
+ let source = create(output);
2390
+
2391
+ if (source && opts.strictSlashes !== true) {
2392
+ source += `${SLASH_LITERAL}?`;
2393
+ }
2394
+
2395
+ return source;
2396
+ };
2397
+
2398
+ var parse_1 = parse$2;
2399
+
2400
+ const scan = scan_1;
2401
+ const parse$1 = parse_1;
2402
+ const utils = utils$3;
2403
+ const constants$1 = constants$3;
2404
+ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
2405
+
2406
+ /**
2407
+ * Creates a matcher function from one or more glob patterns. The
2408
+ * returned function takes a string to match as its first argument,
2409
+ * and returns true if the string is a match. The returned matcher
2410
+ * function also takes a boolean as the second argument that, when true,
2411
+ * returns an object with additional information.
2412
+ *
2413
+ * ```js
2414
+ * const picomatch = require('picomatch');
2415
+ * // picomatch(glob[, options]);
2416
+ *
2417
+ * const isMatch = picomatch('*.!(*a)');
2418
+ * console.log(isMatch('a.a')); //=> false
2419
+ * console.log(isMatch('a.b')); //=> true
2420
+ * ```
2421
+ * @name picomatch
2422
+ * @param {String|Array} `globs` One or more glob patterns.
2423
+ * @param {Object=} `options`
2424
+ * @return {Function=} Returns a matcher function.
2425
+ * @api public
2426
+ */
2427
+
2428
+ const picomatch = (glob, options, returnState = false) => {
2429
+ if (Array.isArray(glob)) {
2430
+ const fns = glob.map(input => picomatch(input, options, returnState));
2431
+ const arrayMatcher = str => {
2432
+ for (const isMatch of fns) {
2433
+ const state = isMatch(str);
2434
+ if (state) return state;
2435
+ }
2436
+ return false;
2437
+ };
2438
+ return arrayMatcher;
2439
+ }
2440
+
2441
+ const isState = isObject(glob) && glob.tokens && glob.input;
2442
+
2443
+ if (glob === '' || (typeof glob !== 'string' && !isState)) {
2444
+ throw new TypeError('Expected pattern to be a non-empty string');
2445
+ }
2446
+
2447
+ const opts = options || {};
2448
+ const posix = opts.windows;
2449
+ const regex = isState
2450
+ ? picomatch.compileRe(glob, options)
2451
+ : picomatch.makeRe(glob, options, false, true);
2452
+
2453
+ const state = regex.state;
2454
+ delete regex.state;
2455
+
2456
+ let isIgnored = () => false;
2457
+ if (opts.ignore) {
2458
+ const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
2459
+ isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
2460
+ }
2461
+
2462
+ const matcher = (input, returnObject = false) => {
2463
+ const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
2464
+ const result = { glob, state, regex, posix, input, output, match, isMatch };
2465
+
2466
+ if (typeof opts.onResult === 'function') {
2467
+ opts.onResult(result);
2468
+ }
2469
+
2470
+ if (isMatch === false) {
2471
+ result.isMatch = false;
2472
+ return returnObject ? result : false;
2473
+ }
2474
+
2475
+ if (isIgnored(input)) {
2476
+ if (typeof opts.onIgnore === 'function') {
2477
+ opts.onIgnore(result);
2478
+ }
2479
+ result.isMatch = false;
2480
+ return returnObject ? result : false;
2481
+ }
2482
+
2483
+ if (typeof opts.onMatch === 'function') {
2484
+ opts.onMatch(result);
2485
+ }
2486
+ return returnObject ? result : true;
2487
+ };
2488
+
2489
+ if (returnState) {
2490
+ matcher.state = state;
2491
+ }
2492
+
2493
+ return matcher;
2494
+ };
2495
+
2496
+ /**
2497
+ * Test `input` with the given `regex`. This is used by the main
2498
+ * `picomatch()` function to test the input string.
2499
+ *
2500
+ * ```js
2501
+ * const picomatch = require('picomatch');
2502
+ * // picomatch.test(input, regex[, options]);
2503
+ *
2504
+ * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
2505
+ * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
2506
+ * ```
2507
+ * @param {String} `input` String to test.
2508
+ * @param {RegExp} `regex`
2509
+ * @return {Object} Returns an object with matching info.
2510
+ * @api public
2511
+ */
2512
+
2513
+ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
2514
+ if (typeof input !== 'string') {
2515
+ throw new TypeError('Expected input to be a string');
2516
+ }
2517
+
2518
+ if (input === '') {
2519
+ return { isMatch: false, output: '' };
2520
+ }
2521
+
2522
+ const opts = options || {};
2523
+ const format = opts.format || (posix ? utils.toPosixSlashes : null);
2524
+ let match = input === glob;
2525
+ let output = (match && format) ? format(input) : input;
2526
+
2527
+ if (match === false) {
2528
+ output = format ? format(input) : input;
2529
+ match = output === glob;
2530
+ }
2531
+
2532
+ if (match === false || opts.capture === true) {
2533
+ if (opts.matchBase === true || opts.basename === true) {
2534
+ match = picomatch.matchBase(input, regex, options, posix);
2535
+ } else {
2536
+ match = regex.exec(output);
2537
+ }
2538
+ }
2539
+
2540
+ return { isMatch: Boolean(match), match, output };
2541
+ };
2542
+
2543
+ /**
2544
+ * Match the basename of a filepath.
2545
+ *
2546
+ * ```js
2547
+ * const picomatch = require('picomatch');
2548
+ * // picomatch.matchBase(input, glob[, options]);
2549
+ * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
2550
+ * ```
2551
+ * @param {String} `input` String to test.
2552
+ * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
2553
+ * @return {Boolean}
2554
+ * @api public
2555
+ */
2556
+
2557
+ picomatch.matchBase = (input, glob, options) => {
2558
+ const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
2559
+ return regex.test(utils.basename(input));
2560
+ };
2561
+
2562
+ /**
2563
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
2564
+ *
2565
+ * ```js
2566
+ * const picomatch = require('picomatch');
2567
+ * // picomatch.isMatch(string, patterns[, options]);
2568
+ *
2569
+ * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
2570
+ * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
2571
+ * ```
2572
+ * @param {String|Array} str The string to test.
2573
+ * @param {String|Array} patterns One or more glob patterns to use for matching.
2574
+ * @param {Object} [options] See available [options](#options).
2575
+ * @return {Boolean} Returns true if any patterns match `str`
2576
+ * @api public
2577
+ */
2578
+
2579
+ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
2580
+
2581
+ /**
2582
+ * Parse a glob pattern to create the source string for a regular
2583
+ * expression.
2584
+ *
2585
+ * ```js
2586
+ * const picomatch = require('picomatch');
2587
+ * const result = picomatch.parse(pattern[, options]);
2588
+ * ```
2589
+ * @param {String} `pattern`
2590
+ * @param {Object} `options`
2591
+ * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
2592
+ * @api public
2593
+ */
2594
+
2595
+ picomatch.parse = (pattern, options) => {
2596
+ if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
2597
+ return parse$1(pattern, { ...options, fastpaths: false });
2598
+ };
2599
+
2600
+ /**
2601
+ * Scan a glob pattern to separate the pattern into segments.
2602
+ *
2603
+ * ```js
2604
+ * const picomatch = require('picomatch');
2605
+ * // picomatch.scan(input[, options]);
2606
+ *
2607
+ * const result = picomatch.scan('!./foo/*.js');
2608
+ * console.log(result);
2609
+ * { prefix: '!./',
2610
+ * input: '!./foo/*.js',
2611
+ * start: 3,
2612
+ * base: 'foo',
2613
+ * glob: '*.js',
2614
+ * isBrace: false,
2615
+ * isBracket: false,
2616
+ * isGlob: true,
2617
+ * isExtglob: false,
2618
+ * isGlobstar: false,
2619
+ * negated: true }
2620
+ * ```
2621
+ * @param {String} `input` Glob pattern to scan.
2622
+ * @param {Object} `options`
2623
+ * @return {Object} Returns an object with
2624
+ * @api public
2625
+ */
2626
+
2627
+ picomatch.scan = (input, options) => scan(input, options);
2628
+
2629
+ /**
2630
+ * Create a regular expression from a parsed glob pattern.
2631
+ *
2632
+ * ```js
2633
+ * const picomatch = require('picomatch');
2634
+ * const state = picomatch.parse('*.js');
2635
+ * // picomatch.compileRe(state[, options]);
2636
+ *
2637
+ * console.log(picomatch.compileRe(state));
2638
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
2639
+ * ```
2640
+ * @param {String} `state` The object returned from the `.parse` method.
2641
+ * @param {Object} `options`
2642
+ * @return {RegExp} Returns a regex created from the given pattern.
2643
+ * @api public
2644
+ */
2645
+
2646
+ picomatch.compileRe = (parsed, options, returnOutput = false, returnState = false) => {
2647
+ if (returnOutput === true) {
2648
+ return parsed.output;
2649
+ }
2650
+
2651
+ const opts = options || {};
2652
+ const prepend = opts.contains ? '' : '^';
2653
+ const append = opts.contains ? '' : '$';
2654
+
2655
+ let source = `${prepend}(?:${parsed.output})${append}`;
2656
+ if (parsed && parsed.negated === true) {
2657
+ source = `^(?!${source}).*$`;
2658
+ }
2659
+
2660
+ const regex = picomatch.toRegex(source, options);
2661
+ if (returnState === true) {
2662
+ regex.state = parsed;
2663
+ }
2664
+
2665
+ return regex;
2666
+ };
2667
+
2668
+ picomatch.makeRe = (input, options, returnOutput = false, returnState = false) => {
2669
+ if (!input || typeof input !== 'string') {
2670
+ throw new TypeError('Expected a non-empty string');
2671
+ }
2672
+
2673
+ const opts = options || {};
2674
+ let parsed = { negated: false, fastpaths: true };
2675
+ let prefix = '';
2676
+ let output;
2677
+
2678
+ if (input.startsWith('./')) {
2679
+ input = input.slice(2);
2680
+ prefix = parsed.prefix = './';
2681
+ }
2682
+
2683
+ if (opts.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
2684
+ output = parse$1.fastpaths(input, options);
2685
+ }
2686
+
2687
+ if (output === undefined) {
2688
+ parsed = parse$1(input, options);
2689
+ parsed.prefix = prefix + (parsed.prefix || '');
2690
+ } else {
2691
+ parsed.output = output;
2692
+ }
2693
+
2694
+ return picomatch.compileRe(parsed, options, returnOutput, returnState);
2695
+ };
2696
+
2697
+ /**
2698
+ * Create a regular expression from the given regex source string.
2699
+ *
2700
+ * ```js
2701
+ * const picomatch = require('picomatch');
2702
+ * // picomatch.toRegex(source[, options]);
2703
+ *
2704
+ * const { output } = picomatch.parse('*.js');
2705
+ * console.log(picomatch.toRegex(output));
2706
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
2707
+ * ```
2708
+ * @param {String} `source` Regular expression source string.
2709
+ * @param {Object} `options`
2710
+ * @return {RegExp}
2711
+ * @api public
2712
+ */
2713
+
2714
+ picomatch.toRegex = (source, options) => {
2715
+ try {
2716
+ const opts = options || {};
2717
+ return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
2718
+ } catch (err) {
2719
+ if (options && options.debug === true) throw err;
2720
+ return /$^/;
2721
+ }
2722
+ };
2723
+
2724
+ /**
2725
+ * Picomatch constants.
2726
+ * @return {Object}
2727
+ */
2728
+
2729
+ picomatch.constants = constants$1;
2730
+
2731
+ /**
2732
+ * Expose "picomatch"
2733
+ */
2734
+
2735
+ var picomatch_1 = picomatch;
2736
+
2737
+ var picomatchBrowser = picomatch_1;
2738
+
2739
+ var pm = /*@__PURE__*/getDefaultExportFromCjs(picomatchBrowser);
2740
+
2741
+ function isArray(arg) {
2742
+ return Array.isArray(arg);
2743
+ }
2744
+ function ensureArray(thing) {
2745
+ if (isArray(thing))
2746
+ return thing;
2747
+ if (thing == null)
2748
+ return [];
2749
+ return [thing];
2750
+ }
2751
+ const globToTest = (glob) => {
2752
+ const pattern = glob;
2753
+ const fn = pm(pattern, { dot: true });
2754
+ return {
2755
+ test: (what) => {
2756
+ const result = fn(what);
2757
+ return result;
2758
+ },
2759
+ };
2760
+ };
2761
+ const testTrue = {
2762
+ test: () => true,
2763
+ };
2764
+ const getMatcher = (filter) => {
2765
+ const bundleTest = "bundle" in filter && filter.bundle != null ? globToTest(filter.bundle) : testTrue;
2766
+ const fileTest = "file" in filter && filter.file != null ? globToTest(filter.file) : testTrue;
2767
+ return { bundleTest, fileTest };
2768
+ };
2769
+ const createFilter = (include, exclude) => {
2770
+ const includeMatchers = ensureArray(include).map(getMatcher);
2771
+ const excludeMatchers = ensureArray(exclude).map(getMatcher);
2772
+ return (bundleId, id) => {
2773
+ for (let i = 0; i < excludeMatchers.length; ++i) {
2774
+ const { bundleTest, fileTest } = excludeMatchers[i];
2775
+ if (bundleTest.test(bundleId) && fileTest.test(id))
2776
+ return false;
2777
+ }
2778
+ for (let i = 0; i < includeMatchers.length; ++i) {
2779
+ const { bundleTest, fileTest } = includeMatchers[i];
2780
+ if (bundleTest.test(bundleId) && fileTest.test(id))
2781
+ return true;
2782
+ }
2783
+ return !includeMatchers.length;
2784
+ };
2785
+ };
2786
+
2787
+ const throttleFilter = (callback, limit) => {
2788
+ let waiting = false;
2789
+ return (val) => {
2790
+ if (!waiting) {
2791
+ callback(val);
2792
+ waiting = true;
2793
+ setTimeout(() => {
2794
+ waiting = false;
2795
+ }, limit);
2796
+ }
2797
+ };
2798
+ };
2799
+ const prepareFilter = (filt) => {
2800
+ if (filt === "")
2801
+ return [];
2802
+ return (filt
2803
+ .split(",")
2804
+ // remove spaces before and after
2805
+ .map((entry) => entry.trim())
2806
+ // unquote "
2807
+ .map((entry) => entry.startsWith('"') && entry.endsWith('"') ? entry.substring(1, entry.length - 1) : entry)
2808
+ // unquote '
2809
+ .map((entry) => entry.startsWith("'") && entry.endsWith("'") ? entry.substring(1, entry.length - 1) : entry)
2810
+ // remove empty strings
2811
+ .filter((entry) => entry)
2812
+ // parse bundle:file
2813
+ .map((entry) => entry.split(":"))
2814
+ // normalize entry just in case
2815
+ .flatMap((entry) => {
2816
+ if (entry.length === 0)
2817
+ return [];
2818
+ let bundle = null;
2819
+ let file = null;
2820
+ if (entry.length === 1 && entry[0]) {
2821
+ file = entry[0];
2822
+ return [{ file, bundle }];
2823
+ }
2824
+ bundle = entry[0] || null;
2825
+ file = entry.slice(1).join(":") || null;
2826
+ return [{ bundle, file }];
2827
+ }));
2828
+ };
2829
+ const useFilter = () => {
2830
+ const [includeFilter, setIncludeFilter] = h("");
2831
+ const [excludeFilter, setExcludeFilter] = h("");
2832
+ const setIncludeFilterTrottled = F(() => throttleFilter(setIncludeFilter, 200), []);
2833
+ const setExcludeFilterTrottled = F(() => throttleFilter(setExcludeFilter, 200), []);
2834
+ const isIncluded = F(() => createFilter(prepareFilter(includeFilter), prepareFilter(excludeFilter)), [includeFilter, excludeFilter]);
2835
+ const getModuleFilterMultiplier = T((bundleId, data) => {
2836
+ return isIncluded(bundleId, data.id) ? 1 : 0;
2837
+ }, [isIncluded]);
2838
+ return {
2839
+ getModuleFilterMultiplier,
2840
+ includeFilter,
2841
+ excludeFilter,
2842
+ setExcludeFilter: setExcludeFilterTrottled,
2843
+ setIncludeFilter: setIncludeFilterTrottled,
2844
+ };
2845
+ };
2846
+
2847
+ function ascending(a, b) {
2848
+ return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
2849
+ }
2850
+
2851
+ function descending(a, b) {
2852
+ return a == null || b == null ? NaN
2853
+ : b < a ? -1
2854
+ : b > a ? 1
2855
+ : b >= a ? 0
2856
+ : NaN;
2857
+ }
2858
+
2859
+ function bisector(f) {
2860
+ let compare1, compare2, delta;
2861
+
2862
+ // If an accessor is specified, promote it to a comparator. In this case we
2863
+ // can test whether the search value is (self-) comparable. We can’t do this
2864
+ // for a comparator (except for specific, known comparators) because we can’t
2865
+ // tell if the comparator is symmetric, and an asymmetric comparator can’t be
2866
+ // used to test whether a single value is comparable.
2867
+ if (f.length !== 2) {
2868
+ compare1 = ascending;
2869
+ compare2 = (d, x) => ascending(f(d), x);
2870
+ delta = (d, x) => f(d) - x;
2871
+ } else {
2872
+ compare1 = f === ascending || f === descending ? f : zero$1;
2873
+ compare2 = f;
2874
+ delta = f;
2875
+ }
2876
+
2877
+ function left(a, x, lo = 0, hi = a.length) {
2878
+ if (lo < hi) {
2879
+ if (compare1(x, x) !== 0) return hi;
2880
+ do {
2881
+ const mid = (lo + hi) >>> 1;
2882
+ if (compare2(a[mid], x) < 0) lo = mid + 1;
2883
+ else hi = mid;
2884
+ } while (lo < hi);
2885
+ }
2886
+ return lo;
2887
+ }
2888
+
2889
+ function right(a, x, lo = 0, hi = a.length) {
2890
+ if (lo < hi) {
2891
+ if (compare1(x, x) !== 0) return hi;
2892
+ do {
2893
+ const mid = (lo + hi) >>> 1;
2894
+ if (compare2(a[mid], x) <= 0) lo = mid + 1;
2895
+ else hi = mid;
2896
+ } while (lo < hi);
2897
+ }
2898
+ return lo;
2899
+ }
2900
+
2901
+ function center(a, x, lo = 0, hi = a.length) {
2902
+ const i = left(a, x, lo, hi - 1);
2903
+ return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
2904
+ }
2905
+
2906
+ return {left, center, right};
2907
+ }
2908
+
2909
+ function zero$1() {
2910
+ return 0;
2911
+ }
2912
+
2913
+ function number$1(x) {
2914
+ return x === null ? NaN : +x;
2915
+ }
2916
+
2917
+ const ascendingBisect = bisector(ascending);
2918
+ const bisectRight = ascendingBisect.right;
2919
+ bisector(number$1).center;
2920
+ var bisect = bisectRight;
2921
+
2922
+ class InternMap extends Map {
2923
+ constructor(entries, key = keyof) {
2924
+ super();
2925
+ Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}});
2926
+ if (entries != null) for (const [key, value] of entries) this.set(key, value);
2927
+ }
2928
+ get(key) {
2929
+ return super.get(intern_get(this, key));
2930
+ }
2931
+ has(key) {
2932
+ return super.has(intern_get(this, key));
2933
+ }
2934
+ set(key, value) {
2935
+ return super.set(intern_set(this, key), value);
2936
+ }
2937
+ delete(key) {
2938
+ return super.delete(intern_delete(this, key));
2939
+ }
2940
+ }
2941
+
2942
+ function intern_get({_intern, _key}, value) {
2943
+ const key = _key(value);
2944
+ return _intern.has(key) ? _intern.get(key) : value;
2945
+ }
2946
+
2947
+ function intern_set({_intern, _key}, value) {
2948
+ const key = _key(value);
2949
+ if (_intern.has(key)) return _intern.get(key);
2950
+ _intern.set(key, value);
2951
+ return value;
2952
+ }
2953
+
2954
+ function intern_delete({_intern, _key}, value) {
2955
+ const key = _key(value);
2956
+ if (_intern.has(key)) {
2957
+ value = _intern.get(key);
2958
+ _intern.delete(key);
2959
+ }
2960
+ return value;
2961
+ }
2962
+
2963
+ function keyof(value) {
2964
+ return value !== null && typeof value === "object" ? value.valueOf() : value;
2965
+ }
2966
+
2967
+ function identity$2(x) {
2968
+ return x;
2969
+ }
2970
+
2971
+ function group(values, ...keys) {
2972
+ return nest(values, identity$2, identity$2, keys);
2973
+ }
2974
+
2975
+ function nest(values, map, reduce, keys) {
2976
+ return (function regroup(values, i) {
2977
+ if (i >= keys.length) return reduce(values);
2978
+ const groups = new InternMap();
2979
+ const keyof = keys[i++];
2980
+ let index = -1;
2981
+ for (const value of values) {
2982
+ const key = keyof(value, ++index, values);
2983
+ const group = groups.get(key);
2984
+ if (group) group.push(value);
2985
+ else groups.set(key, [value]);
2986
+ }
2987
+ for (const [key, values] of groups) {
2988
+ groups.set(key, regroup(values, i));
2989
+ }
2990
+ return map(groups);
2991
+ })(values, 0);
2992
+ }
2993
+
2994
+ const e10 = Math.sqrt(50),
2995
+ e5 = Math.sqrt(10),
2996
+ e2 = Math.sqrt(2);
2997
+
2998
+ function tickSpec(start, stop, count) {
2999
+ const step = (stop - start) / Math.max(0, count),
3000
+ power = Math.floor(Math.log10(step)),
3001
+ error = step / Math.pow(10, power),
3002
+ factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1;
3003
+ let i1, i2, inc;
3004
+ if (power < 0) {
3005
+ inc = Math.pow(10, -power) / factor;
3006
+ i1 = Math.round(start * inc);
3007
+ i2 = Math.round(stop * inc);
3008
+ if (i1 / inc < start) ++i1;
3009
+ if (i2 / inc > stop) --i2;
3010
+ inc = -inc;
3011
+ } else {
3012
+ inc = Math.pow(10, power) * factor;
3013
+ i1 = Math.round(start / inc);
3014
+ i2 = Math.round(stop / inc);
3015
+ if (i1 * inc < start) ++i1;
3016
+ if (i2 * inc > stop) --i2;
3017
+ }
3018
+ if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start, stop, count * 2);
3019
+ return [i1, i2, inc];
3020
+ }
3021
+
3022
+ function ticks(start, stop, count) {
3023
+ stop = +stop, start = +start, count = +count;
3024
+ if (!(count > 0)) return [];
3025
+ if (start === stop) return [start];
3026
+ const reverse = stop < start, [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count);
3027
+ if (!(i2 >= i1)) return [];
3028
+ const n = i2 - i1 + 1, ticks = new Array(n);
3029
+ if (reverse) {
3030
+ if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) / -inc;
3031
+ else for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) * inc;
3032
+ } else {
3033
+ if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) / -inc;
3034
+ else for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) * inc;
3035
+ }
3036
+ return ticks;
3037
+ }
3038
+
3039
+ function tickIncrement(start, stop, count) {
3040
+ stop = +stop, start = +start, count = +count;
3041
+ return tickSpec(start, stop, count)[2];
3042
+ }
3043
+
3044
+ function tickStep(start, stop, count) {
3045
+ stop = +stop, start = +start, count = +count;
3046
+ const reverse = stop < start, inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count);
3047
+ return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc);
3048
+ }
3049
+
3050
+ const TOP_PADDING = 20;
3051
+ const PADDING = 2;
3052
+
3053
+ const Node = ({ node, onMouseOver, onClick, selected }) => {
3054
+ const { getModuleColor } = q(StaticContext);
3055
+ const { backgroundColor, fontColor } = getModuleColor(node);
3056
+ const { x0, x1, y1, y0, data, children = null } = node;
3057
+ const textRef = _(null);
3058
+ const textRectRef = _();
3059
+ const width = x1 - x0;
3060
+ const height = y1 - y0;
3061
+ const textProps = {
3062
+ "font-size": "0.7em",
3063
+ "dominant-baseline": "middle",
3064
+ "text-anchor": "middle",
3065
+ x: width / 2,
3066
+ };
3067
+ if (children != null) {
3068
+ textProps.y = (TOP_PADDING + PADDING) / 2;
3069
+ }
3070
+ else {
3071
+ textProps.y = height / 2;
3072
+ }
3073
+ y(() => {
3074
+ if (width == 0 || height == 0 || !textRef.current) {
3075
+ return;
3076
+ }
3077
+ if (textRectRef.current == null) {
3078
+ textRectRef.current = textRef.current.getBoundingClientRect();
3079
+ }
3080
+ let scale = 1;
3081
+ if (children != null) {
3082
+ scale = Math.min((width * 0.9) / textRectRef.current.width, Math.min(height, TOP_PADDING + PADDING) / textRectRef.current.height);
3083
+ scale = Math.min(1, scale);
3084
+ textRef.current.setAttribute("y", String(Math.min(TOP_PADDING + PADDING, height) / 2 / scale));
3085
+ textRef.current.setAttribute("x", String(width / 2 / scale));
3086
+ }
3087
+ else {
3088
+ scale = Math.min((width * 0.9) / textRectRef.current.width, (height * 0.9) / textRectRef.current.height);
3089
+ scale = Math.min(1, scale);
3090
+ textRef.current.setAttribute("y", String(height / 2 / scale));
3091
+ textRef.current.setAttribute("x", String(width / 2 / scale));
3092
+ }
3093
+ textRef.current.setAttribute("transform", `scale(${scale.toFixed(2)})`);
3094
+ }, [children, height, width]);
3095
+ if (width == 0 || height == 0) {
3096
+ return null;
3097
+ }
3098
+ return (u$1("g", { className: "node", transform: `translate(${x0},${y0})`, onClick: (event) => {
3099
+ event.stopPropagation();
3100
+ onClick(node);
3101
+ }, onMouseOver: (event) => {
3102
+ event.stopPropagation();
3103
+ onMouseOver(node);
3104
+ }, children: [u$1("rect", { fill: backgroundColor, rx: 2, ry: 2, width: x1 - x0, height: y1 - y0, stroke: selected ? "#fff" : undefined, "stroke-width": selected ? 2 : undefined }), u$1("text", Object.assign({ ref: textRef, fill: fontColor, onClick: (event) => {
3105
+ var _a;
3106
+ if (((_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.toString()) !== "") {
3107
+ event.stopPropagation();
3108
+ }
3109
+ } }, textProps, { children: data.name }))] }));
3110
+ };
3111
+
3112
+ const TreeMap = ({ root, onNodeHover, selectedNode, onNodeClick, }) => {
3113
+ const { width, height, getModuleIds } = q(StaticContext);
3114
+ console.time("layering");
3115
+ // this will make groups by height
3116
+ const nestedData = F(() => {
3117
+ const nestedDataMap = group(root.descendants(), (d) => d.height);
3118
+ const nestedData = Array.from(nestedDataMap, ([key, values]) => ({
3119
+ key,
3120
+ values,
3121
+ }));
3122
+ nestedData.sort((a, b) => b.key - a.key);
3123
+ return nestedData;
3124
+ }, [root]);
3125
+ console.timeEnd("layering");
3126
+ return (u$1("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: `0 0 ${width} ${height}`, children: nestedData.map(({ key, values }) => {
3127
+ return (u$1("g", { className: "layer", children: values.map((node) => {
3128
+ return (u$1(Node, { node: node, onMouseOver: onNodeHover, selected: selectedNode === node, onClick: onNodeClick }, getModuleIds(node.data).nodeUid.id));
3129
+ }) }, key));
3130
+ }) }));
3131
+ };
3132
+
3133
+ var bytes$1 = {exports: {}};
3134
+
3135
+ /*!
3136
+ * bytes
3137
+ * Copyright(c) 2012-2014 TJ Holowaychuk
3138
+ * Copyright(c) 2015 Jed Watson
3139
+ * MIT Licensed
3140
+ */
3141
+
3142
+ /**
3143
+ * Module exports.
3144
+ * @public
3145
+ */
3146
+
3147
+ bytes$1.exports = bytes;
3148
+ var format_1 = bytes$1.exports.format = format$1;
3149
+ bytes$1.exports.parse = parse;
3150
+
3151
+ /**
3152
+ * Module variables.
3153
+ * @private
3154
+ */
3155
+
3156
+ var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
3157
+
3158
+ var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
3159
+
3160
+ var map$1 = {
3161
+ b: 1,
3162
+ kb: 1 << 10,
3163
+ mb: 1 << 20,
3164
+ gb: 1 << 30,
3165
+ tb: Math.pow(1024, 4),
3166
+ pb: Math.pow(1024, 5),
3167
+ };
3168
+
3169
+ var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
3170
+
3171
+ /**
3172
+ * Convert the given value in bytes into a string or parse to string to an integer in bytes.
3173
+ *
3174
+ * @param {string|number} value
3175
+ * @param {{
3176
+ * case: [string],
3177
+ * decimalPlaces: [number]
3178
+ * fixedDecimals: [boolean]
3179
+ * thousandsSeparator: [string]
3180
+ * unitSeparator: [string]
3181
+ * }} [options] bytes options.
3182
+ *
3183
+ * @returns {string|number|null}
3184
+ */
3185
+
3186
+ function bytes(value, options) {
3187
+ if (typeof value === 'string') {
3188
+ return parse(value);
3189
+ }
3190
+
3191
+ if (typeof value === 'number') {
3192
+ return format$1(value, options);
3193
+ }
3194
+
3195
+ return null;
3196
+ }
3197
+
3198
+ /**
3199
+ * Format the given value in bytes into a string.
3200
+ *
3201
+ * If the value is negative, it is kept as such. If it is a float,
3202
+ * it is rounded.
3203
+ *
3204
+ * @param {number} value
3205
+ * @param {object} [options]
3206
+ * @param {number} [options.decimalPlaces=2]
3207
+ * @param {number} [options.fixedDecimals=false]
3208
+ * @param {string} [options.thousandsSeparator=]
3209
+ * @param {string} [options.unit=]
3210
+ * @param {string} [options.unitSeparator=]
3211
+ *
3212
+ * @returns {string|null}
3213
+ * @public
3214
+ */
3215
+
3216
+ function format$1(value, options) {
3217
+ if (!Number.isFinite(value)) {
3218
+ return null;
3219
+ }
3220
+
3221
+ var mag = Math.abs(value);
3222
+ var thousandsSeparator = (options && options.thousandsSeparator) || '';
3223
+ var unitSeparator = (options && options.unitSeparator) || '';
3224
+ var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2;
3225
+ var fixedDecimals = Boolean(options && options.fixedDecimals);
3226
+ var unit = (options && options.unit) || '';
3227
+
3228
+ if (!unit || !map$1[unit.toLowerCase()]) {
3229
+ if (mag >= map$1.pb) {
3230
+ unit = 'PB';
3231
+ } else if (mag >= map$1.tb) {
3232
+ unit = 'TB';
3233
+ } else if (mag >= map$1.gb) {
3234
+ unit = 'GB';
3235
+ } else if (mag >= map$1.mb) {
3236
+ unit = 'MB';
3237
+ } else if (mag >= map$1.kb) {
3238
+ unit = 'KB';
3239
+ } else {
3240
+ unit = 'B';
3241
+ }
3242
+ }
3243
+
3244
+ var val = value / map$1[unit.toLowerCase()];
3245
+ var str = val.toFixed(decimalPlaces);
3246
+
3247
+ if (!fixedDecimals) {
3248
+ str = str.replace(formatDecimalsRegExp, '$1');
3249
+ }
3250
+
3251
+ if (thousandsSeparator) {
3252
+ str = str.split('.').map(function (s, i) {
3253
+ return i === 0
3254
+ ? s.replace(formatThousandsRegExp, thousandsSeparator)
3255
+ : s
3256
+ }).join('.');
3257
+ }
3258
+
3259
+ return str + unitSeparator + unit;
3260
+ }
3261
+
3262
+ /**
3263
+ * Parse the string value into an integer in bytes.
3264
+ *
3265
+ * If no unit is given, it is assumed the value is in bytes.
3266
+ *
3267
+ * @param {number|string} val
3268
+ *
3269
+ * @returns {number|null}
3270
+ * @public
3271
+ */
3272
+
3273
+ function parse(val) {
3274
+ if (typeof val === 'number' && !isNaN(val)) {
3275
+ return val;
3276
+ }
3277
+
3278
+ if (typeof val !== 'string') {
3279
+ return null;
3280
+ }
3281
+
3282
+ // Test if the string passed is valid
3283
+ var results = parseRegExp.exec(val);
3284
+ var floatValue;
3285
+ var unit = 'b';
3286
+
3287
+ if (!results) {
3288
+ // Nothing could be extracted from the given string
3289
+ floatValue = parseInt(val, 10);
3290
+ unit = 'b';
3291
+ } else {
3292
+ // Retrieve the value and the unit
3293
+ floatValue = parseFloat(results[1]);
3294
+ unit = results[4].toLowerCase();
3295
+ }
3296
+
3297
+ if (isNaN(floatValue)) {
3298
+ return null;
3299
+ }
3300
+
3301
+ return Math.floor(map$1[unit] * floatValue);
3302
+ }
3303
+
3304
+ const Tooltip_marginX = 10;
3305
+ const Tooltip_marginY = 30;
3306
+ const SOURCEMAP_RENDERED = (u$1("span", { children: [" ", u$1("b", { children: LABELS.renderedLength }), " is a number of characters in the file after individual and ", u$1("br", {}), " ", "whole bundle transformations according to sourcemap."] }));
3307
+ const RENDRED = (u$1("span", { children: [u$1("b", { children: LABELS.renderedLength }), " is a byte size of individual file after transformations and treeshake."] }));
3308
+ const COMPRESSED = (u$1("span", { children: [u$1("b", { children: LABELS.gzipLength }), " and ", u$1("b", { children: LABELS.brotliLength }), " is a byte size of individual file after individual transformations,", u$1("br", {}), " treeshake and compression."] }));
3309
+ const Tooltip = ({ node, visible, root, sizeProperty, }) => {
3310
+ const { availableSizeProperties, getModuleSize, data } = q(StaticContext);
3311
+ const ref = _(null);
3312
+ const [style, setStyle] = h({});
3313
+ const content = F(() => {
3314
+ if (!node)
3315
+ return null;
3316
+ const mainSize = getModuleSize(node.data, sizeProperty);
3317
+ const percentageNum = (100 * mainSize) / getModuleSize(root.data, sizeProperty);
3318
+ const percentage = percentageNum.toFixed(2);
3319
+ const percentageString = percentage + "%";
3320
+ const path = node
3321
+ .ancestors()
3322
+ .reverse()
3323
+ .map((d) => d.data.name)
3324
+ .join("/");
3325
+ let dataNode = null;
3326
+ if (!isModuleTree(node.data)) {
3327
+ const mainUid = data.nodeParts[node.data.uid].metaUid;
3328
+ dataNode = data.nodeMetas[mainUid];
3329
+ }
3330
+ return (u$1(g$1, { children: [u$1("div", { children: path }), availableSizeProperties.map((sizeProp) => {
3331
+ if (sizeProp === sizeProperty) {
3332
+ return (u$1("div", { children: [u$1("b", { children: [LABELS[sizeProp], ": ", format_1(mainSize)] }), " ", "(", percentageString, ")"] }, sizeProp));
3333
+ }
3334
+ else {
3335
+ return (u$1("div", { children: [LABELS[sizeProp], ": ", format_1(getModuleSize(node.data, sizeProp))] }, sizeProp));
3336
+ }
3337
+ }), u$1("br", {}), dataNode && dataNode.importedBy.length > 0 && (u$1("div", { children: [u$1("div", { children: [u$1("b", { children: "Imported By" }), ":"] }), dataNode.importedBy.map(({ uid }) => {
3338
+ const id = data.nodeMetas[uid].id;
3339
+ return u$1("div", { children: id }, id);
3340
+ })] })), u$1("br", {}), u$1("small", { children: data.options.sourcemap ? SOURCEMAP_RENDERED : RENDRED }), (data.options.gzip || data.options.brotli) && (u$1(g$1, { children: [u$1("br", {}), u$1("small", { children: COMPRESSED })] }))] }));
3341
+ }, [availableSizeProperties, data, getModuleSize, node, root.data, sizeProperty]);
3342
+ const updatePosition = (mouseCoords) => {
3343
+ if (!ref.current)
3344
+ return;
3345
+ const pos = {
3346
+ left: mouseCoords.x + Tooltip_marginX,
3347
+ top: mouseCoords.y + Tooltip_marginY,
3348
+ };
3349
+ const boundingRect = ref.current.getBoundingClientRect();
3350
+ if (pos.left + boundingRect.width > window.innerWidth) {
3351
+ // Shifting horizontally
3352
+ pos.left = window.innerWidth - boundingRect.width;
3353
+ }
3354
+ if (pos.top + boundingRect.height > window.innerHeight) {
3355
+ // Flipping vertically
3356
+ pos.top = mouseCoords.y - Tooltip_marginY - boundingRect.height;
3357
+ }
3358
+ setStyle(pos);
3359
+ };
3360
+ p(() => {
3361
+ const handleMouseMove = (event) => {
3362
+ updatePosition({
3363
+ x: event.pageX,
3364
+ y: event.pageY,
3365
+ });
3366
+ };
3367
+ document.addEventListener("mousemove", handleMouseMove, true);
3368
+ return () => {
3369
+ document.removeEventListener("mousemove", handleMouseMove, true);
3370
+ };
3371
+ }, []);
3372
+ return (u$1("div", { className: `tooltip ${visible ? "" : "tooltip-hidden"}`, ref: ref, style: style, children: content }));
3373
+ };
3374
+
3375
+ const Chart = ({ root, sizeProperty, selectedNode, setSelectedNode, }) => {
3376
+ const [showTooltip, setShowTooltip] = h(false);
3377
+ const [tooltipNode, setTooltipNode] = h(undefined);
3378
+ p(() => {
3379
+ const handleMouseOut = () => {
3380
+ setShowTooltip(false);
3381
+ };
3382
+ document.addEventListener("mouseover", handleMouseOut);
3383
+ return () => {
3384
+ document.removeEventListener("mouseover", handleMouseOut);
3385
+ };
3386
+ }, []);
3387
+ return (u$1(g$1, { children: [u$1(TreeMap, { root: root, onNodeHover: (node) => {
3388
+ setTooltipNode(node);
3389
+ setShowTooltip(true);
3390
+ }, selectedNode: selectedNode, onNodeClick: (node) => {
3391
+ setSelectedNode(selectedNode === node ? undefined : node);
3392
+ } }), u$1(Tooltip, { visible: showTooltip, node: tooltipNode, root: root, sizeProperty: sizeProperty })] }));
3393
+ };
3394
+
3395
+ const Main = () => {
3396
+ const { availableSizeProperties, rawHierarchy, getModuleSize, layout, data } = q(StaticContext);
3397
+ const [sizeProperty, setSizeProperty] = h(availableSizeProperties[0]);
3398
+ const [selectedNode, setSelectedNode] = h(undefined);
3399
+ const { getModuleFilterMultiplier, setExcludeFilter, setIncludeFilter } = useFilter();
3400
+ console.time("getNodeSizeMultiplier");
3401
+ const getNodeSizeMultiplier = F(() => {
3402
+ const selectedMultiplier = 1; // selectedSize < rootSize * increaseFactor ? (rootSize * increaseFactor) / selectedSize : rootSize / selectedSize;
3403
+ const nonSelectedMultiplier = 0; // 1 / selectedMultiplier
3404
+ if (selectedNode === undefined) {
3405
+ return () => 1;
3406
+ }
3407
+ else if (isModuleTree(selectedNode.data)) {
3408
+ const leaves = new Set(selectedNode.leaves().map((d) => d.data));
3409
+ return (node) => {
3410
+ if (leaves.has(node)) {
3411
+ return selectedMultiplier;
3412
+ }
3413
+ return nonSelectedMultiplier;
3414
+ };
3415
+ }
3416
+ else {
3417
+ return (node) => {
3418
+ if (node === selectedNode.data) {
3419
+ return selectedMultiplier;
3420
+ }
3421
+ return nonSelectedMultiplier;
3422
+ };
3423
+ }
3424
+ }, [getModuleSize, rawHierarchy.data, selectedNode, sizeProperty]);
3425
+ console.timeEnd("getNodeSizeMultiplier");
3426
+ console.time("root hierarchy compute");
3427
+ // root here always be the same as rawHierarchy even after layouting
3428
+ const root = F(() => {
3429
+ const rootWithSizesAndSorted = rawHierarchy
3430
+ .sum((node) => {
3431
+ var _a;
3432
+ if (isModuleTree(node))
3433
+ return 0;
3434
+ const meta = data.nodeMetas[data.nodeParts[node.uid].metaUid];
3435
+ const bundleId = (_a = Object.entries(meta.moduleParts).find(([bundleId, uid]) => uid == node.uid)) === null || _a === void 0 ? void 0 : _a[0];
3436
+ const ownSize = getModuleSize(node, sizeProperty);
3437
+ const zoomMultiplier = getNodeSizeMultiplier(node);
3438
+ const filterMultiplier = getModuleFilterMultiplier(bundleId, meta);
3439
+ return ownSize * zoomMultiplier * filterMultiplier;
3440
+ })
3441
+ .sort((a, b) => getModuleSize(a.data, sizeProperty) - getModuleSize(b.data, sizeProperty));
3442
+ return layout(rootWithSizesAndSorted);
3443
+ }, [
3444
+ data,
3445
+ getModuleFilterMultiplier,
3446
+ getModuleSize,
3447
+ getNodeSizeMultiplier,
3448
+ layout,
3449
+ rawHierarchy,
3450
+ sizeProperty,
3451
+ ]);
3452
+ console.timeEnd("root hierarchy compute");
3453
+ return (u$1(g$1, { children: [u$1(SideBar, { sizeProperty: sizeProperty, availableSizeProperties: availableSizeProperties, setSizeProperty: setSizeProperty, onExcludeChange: setExcludeFilter, onIncludeChange: setIncludeFilter }), u$1(Chart, { root: root, sizeProperty: sizeProperty, selectedNode: selectedNode, setSelectedNode: setSelectedNode })] }));
3454
+ };
3455
+
3456
+ function initRange(domain, range) {
3457
+ switch (arguments.length) {
3458
+ case 0: break;
3459
+ case 1: this.range(domain); break;
3460
+ default: this.range(range).domain(domain); break;
3461
+ }
3462
+ return this;
3463
+ }
3464
+
3465
+ function initInterpolator(domain, interpolator) {
3466
+ switch (arguments.length) {
3467
+ case 0: break;
3468
+ case 1: {
3469
+ if (typeof domain === "function") this.interpolator(domain);
3470
+ else this.range(domain);
3471
+ break;
3472
+ }
3473
+ default: {
3474
+ this.domain(domain);
3475
+ if (typeof interpolator === "function") this.interpolator(interpolator);
3476
+ else this.range(interpolator);
3477
+ break;
3478
+ }
3479
+ }
3480
+ return this;
3481
+ }
3482
+
3483
+ function define(constructor, factory, prototype) {
3484
+ constructor.prototype = factory.prototype = prototype;
3485
+ prototype.constructor = constructor;
3486
+ }
3487
+
3488
+ function extend(parent, definition) {
3489
+ var prototype = Object.create(parent.prototype);
3490
+ for (var key in definition) prototype[key] = definition[key];
3491
+ return prototype;
3492
+ }
3493
+
3494
+ function Color() {}
3495
+
3496
+ var darker = 0.7;
3497
+ var brighter = 1 / darker;
3498
+
3499
+ var reI = "\\s*([+-]?\\d+)\\s*",
3500
+ reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",
3501
+ reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
3502
+ reHex = /^#([0-9a-f]{3,8})$/,
3503
+ reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`),
3504
+ reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`),
3505
+ reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`),
3506
+ reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`),
3507
+ reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`),
3508
+ reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`);
3509
+
3510
+ var named = {
3511
+ aliceblue: 0xf0f8ff,
3512
+ antiquewhite: 0xfaebd7,
3513
+ aqua: 0x00ffff,
3514
+ aquamarine: 0x7fffd4,
3515
+ azure: 0xf0ffff,
3516
+ beige: 0xf5f5dc,
3517
+ bisque: 0xffe4c4,
3518
+ black: 0x000000,
3519
+ blanchedalmond: 0xffebcd,
3520
+ blue: 0x0000ff,
3521
+ blueviolet: 0x8a2be2,
3522
+ brown: 0xa52a2a,
3523
+ burlywood: 0xdeb887,
3524
+ cadetblue: 0x5f9ea0,
3525
+ chartreuse: 0x7fff00,
3526
+ chocolate: 0xd2691e,
3527
+ coral: 0xff7f50,
3528
+ cornflowerblue: 0x6495ed,
3529
+ cornsilk: 0xfff8dc,
3530
+ crimson: 0xdc143c,
3531
+ cyan: 0x00ffff,
3532
+ darkblue: 0x00008b,
3533
+ darkcyan: 0x008b8b,
3534
+ darkgoldenrod: 0xb8860b,
3535
+ darkgray: 0xa9a9a9,
3536
+ darkgreen: 0x006400,
3537
+ darkgrey: 0xa9a9a9,
3538
+ darkkhaki: 0xbdb76b,
3539
+ darkmagenta: 0x8b008b,
3540
+ darkolivegreen: 0x556b2f,
3541
+ darkorange: 0xff8c00,
3542
+ darkorchid: 0x9932cc,
3543
+ darkred: 0x8b0000,
3544
+ darksalmon: 0xe9967a,
3545
+ darkseagreen: 0x8fbc8f,
3546
+ darkslateblue: 0x483d8b,
3547
+ darkslategray: 0x2f4f4f,
3548
+ darkslategrey: 0x2f4f4f,
3549
+ darkturquoise: 0x00ced1,
3550
+ darkviolet: 0x9400d3,
3551
+ deeppink: 0xff1493,
3552
+ deepskyblue: 0x00bfff,
3553
+ dimgray: 0x696969,
3554
+ dimgrey: 0x696969,
3555
+ dodgerblue: 0x1e90ff,
3556
+ firebrick: 0xb22222,
3557
+ floralwhite: 0xfffaf0,
3558
+ forestgreen: 0x228b22,
3559
+ fuchsia: 0xff00ff,
3560
+ gainsboro: 0xdcdcdc,
3561
+ ghostwhite: 0xf8f8ff,
3562
+ gold: 0xffd700,
3563
+ goldenrod: 0xdaa520,
3564
+ gray: 0x808080,
3565
+ green: 0x008000,
3566
+ greenyellow: 0xadff2f,
3567
+ grey: 0x808080,
3568
+ honeydew: 0xf0fff0,
3569
+ hotpink: 0xff69b4,
3570
+ indianred: 0xcd5c5c,
3571
+ indigo: 0x4b0082,
3572
+ ivory: 0xfffff0,
3573
+ khaki: 0xf0e68c,
3574
+ lavender: 0xe6e6fa,
3575
+ lavenderblush: 0xfff0f5,
3576
+ lawngreen: 0x7cfc00,
3577
+ lemonchiffon: 0xfffacd,
3578
+ lightblue: 0xadd8e6,
3579
+ lightcoral: 0xf08080,
3580
+ lightcyan: 0xe0ffff,
3581
+ lightgoldenrodyellow: 0xfafad2,
3582
+ lightgray: 0xd3d3d3,
3583
+ lightgreen: 0x90ee90,
3584
+ lightgrey: 0xd3d3d3,
3585
+ lightpink: 0xffb6c1,
3586
+ lightsalmon: 0xffa07a,
3587
+ lightseagreen: 0x20b2aa,
3588
+ lightskyblue: 0x87cefa,
3589
+ lightslategray: 0x778899,
3590
+ lightslategrey: 0x778899,
3591
+ lightsteelblue: 0xb0c4de,
3592
+ lightyellow: 0xffffe0,
3593
+ lime: 0x00ff00,
3594
+ limegreen: 0x32cd32,
3595
+ linen: 0xfaf0e6,
3596
+ magenta: 0xff00ff,
3597
+ maroon: 0x800000,
3598
+ mediumaquamarine: 0x66cdaa,
3599
+ mediumblue: 0x0000cd,
3600
+ mediumorchid: 0xba55d3,
3601
+ mediumpurple: 0x9370db,
3602
+ mediumseagreen: 0x3cb371,
3603
+ mediumslateblue: 0x7b68ee,
3604
+ mediumspringgreen: 0x00fa9a,
3605
+ mediumturquoise: 0x48d1cc,
3606
+ mediumvioletred: 0xc71585,
3607
+ midnightblue: 0x191970,
3608
+ mintcream: 0xf5fffa,
3609
+ mistyrose: 0xffe4e1,
3610
+ moccasin: 0xffe4b5,
3611
+ navajowhite: 0xffdead,
3612
+ navy: 0x000080,
3613
+ oldlace: 0xfdf5e6,
3614
+ olive: 0x808000,
3615
+ olivedrab: 0x6b8e23,
3616
+ orange: 0xffa500,
3617
+ orangered: 0xff4500,
3618
+ orchid: 0xda70d6,
3619
+ palegoldenrod: 0xeee8aa,
3620
+ palegreen: 0x98fb98,
3621
+ paleturquoise: 0xafeeee,
3622
+ palevioletred: 0xdb7093,
3623
+ papayawhip: 0xffefd5,
3624
+ peachpuff: 0xffdab9,
3625
+ peru: 0xcd853f,
3626
+ pink: 0xffc0cb,
3627
+ plum: 0xdda0dd,
3628
+ powderblue: 0xb0e0e6,
3629
+ purple: 0x800080,
3630
+ rebeccapurple: 0x663399,
3631
+ red: 0xff0000,
3632
+ rosybrown: 0xbc8f8f,
3633
+ royalblue: 0x4169e1,
3634
+ saddlebrown: 0x8b4513,
3635
+ salmon: 0xfa8072,
3636
+ sandybrown: 0xf4a460,
3637
+ seagreen: 0x2e8b57,
3638
+ seashell: 0xfff5ee,
3639
+ sienna: 0xa0522d,
3640
+ silver: 0xc0c0c0,
3641
+ skyblue: 0x87ceeb,
3642
+ slateblue: 0x6a5acd,
3643
+ slategray: 0x708090,
3644
+ slategrey: 0x708090,
3645
+ snow: 0xfffafa,
3646
+ springgreen: 0x00ff7f,
3647
+ steelblue: 0x4682b4,
3648
+ tan: 0xd2b48c,
3649
+ teal: 0x008080,
3650
+ thistle: 0xd8bfd8,
3651
+ tomato: 0xff6347,
3652
+ turquoise: 0x40e0d0,
3653
+ violet: 0xee82ee,
3654
+ wheat: 0xf5deb3,
3655
+ white: 0xffffff,
3656
+ whitesmoke: 0xf5f5f5,
3657
+ yellow: 0xffff00,
3658
+ yellowgreen: 0x9acd32
3659
+ };
3660
+
3661
+ define(Color, color, {
3662
+ copy(channels) {
3663
+ return Object.assign(new this.constructor, this, channels);
3664
+ },
3665
+ displayable() {
3666
+ return this.rgb().displayable();
3667
+ },
3668
+ hex: color_formatHex, // Deprecated! Use color.formatHex.
3669
+ formatHex: color_formatHex,
3670
+ formatHex8: color_formatHex8,
3671
+ formatHsl: color_formatHsl,
3672
+ formatRgb: color_formatRgb,
3673
+ toString: color_formatRgb
3674
+ });
3675
+
3676
+ function color_formatHex() {
3677
+ return this.rgb().formatHex();
3678
+ }
3679
+
3680
+ function color_formatHex8() {
3681
+ return this.rgb().formatHex8();
3682
+ }
3683
+
3684
+ function color_formatHsl() {
3685
+ return hslConvert(this).formatHsl();
3686
+ }
3687
+
3688
+ function color_formatRgb() {
3689
+ return this.rgb().formatRgb();
3690
+ }
3691
+
3692
+ function color(format) {
3693
+ var m, l;
3694
+ format = (format + "").trim().toLowerCase();
3695
+ return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000
3696
+ : l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00
3697
+ : l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
3698
+ : l === 4 ? rgba((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000
3699
+ : null) // invalid hex
3700
+ : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
3701
+ : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
3702
+ : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
3703
+ : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
3704
+ : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
3705
+ : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
3706
+ : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins
3707
+ : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
3708
+ : null;
3709
+ }
3710
+
3711
+ function rgbn(n) {
3712
+ return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
3713
+ }
3714
+
3715
+ function rgba(r, g, b, a) {
3716
+ if (a <= 0) r = g = b = NaN;
3717
+ return new Rgb(r, g, b, a);
3718
+ }
3719
+
3720
+ function rgbConvert(o) {
3721
+ if (!(o instanceof Color)) o = color(o);
3722
+ if (!o) return new Rgb;
3723
+ o = o.rgb();
3724
+ return new Rgb(o.r, o.g, o.b, o.opacity);
3725
+ }
3726
+
3727
+ function rgb$1(r, g, b, opacity) {
3728
+ return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
3729
+ }
3730
+
3731
+ function Rgb(r, g, b, opacity) {
3732
+ this.r = +r;
3733
+ this.g = +g;
3734
+ this.b = +b;
3735
+ this.opacity = +opacity;
3736
+ }
3737
+
3738
+ define(Rgb, rgb$1, extend(Color, {
3739
+ brighter(k) {
3740
+ k = k == null ? brighter : Math.pow(brighter, k);
3741
+ return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
3742
+ },
3743
+ darker(k) {
3744
+ k = k == null ? darker : Math.pow(darker, k);
3745
+ return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
3746
+ },
3747
+ rgb() {
3748
+ return this;
3749
+ },
3750
+ clamp() {
3751
+ return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
3752
+ },
3753
+ displayable() {
3754
+ return (-0.5 <= this.r && this.r < 255.5)
3755
+ && (-0.5 <= this.g && this.g < 255.5)
3756
+ && (-0.5 <= this.b && this.b < 255.5)
3757
+ && (0 <= this.opacity && this.opacity <= 1);
3758
+ },
3759
+ hex: rgb_formatHex, // Deprecated! Use color.formatHex.
3760
+ formatHex: rgb_formatHex,
3761
+ formatHex8: rgb_formatHex8,
3762
+ formatRgb: rgb_formatRgb,
3763
+ toString: rgb_formatRgb
3764
+ }));
3765
+
3766
+ function rgb_formatHex() {
3767
+ return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`;
3768
+ }
3769
+
3770
+ function rgb_formatHex8() {
3771
+ return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
3772
+ }
3773
+
3774
+ function rgb_formatRgb() {
3775
+ const a = clampa(this.opacity);
3776
+ return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`;
3777
+ }
3778
+
3779
+ function clampa(opacity) {
3780
+ return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
3781
+ }
3782
+
3783
+ function clampi(value) {
3784
+ return Math.max(0, Math.min(255, Math.round(value) || 0));
3785
+ }
3786
+
3787
+ function hex(value) {
3788
+ value = clampi(value);
3789
+ return (value < 16 ? "0" : "") + value.toString(16);
3790
+ }
3791
+
3792
+ function hsla(h, s, l, a) {
3793
+ if (a <= 0) h = s = l = NaN;
3794
+ else if (l <= 0 || l >= 1) h = s = NaN;
3795
+ else if (s <= 0) h = NaN;
3796
+ return new Hsl(h, s, l, a);
3797
+ }
3798
+
3799
+ function hslConvert(o) {
3800
+ if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
3801
+ if (!(o instanceof Color)) o = color(o);
3802
+ if (!o) return new Hsl;
3803
+ if (o instanceof Hsl) return o;
3804
+ o = o.rgb();
3805
+ var r = o.r / 255,
3806
+ g = o.g / 255,
3807
+ b = o.b / 255,
3808
+ min = Math.min(r, g, b),
3809
+ max = Math.max(r, g, b),
3810
+ h = NaN,
3811
+ s = max - min,
3812
+ l = (max + min) / 2;
3813
+ if (s) {
3814
+ if (r === max) h = (g - b) / s + (g < b) * 6;
3815
+ else if (g === max) h = (b - r) / s + 2;
3816
+ else h = (r - g) / s + 4;
3817
+ s /= l < 0.5 ? max + min : 2 - max - min;
3818
+ h *= 60;
3819
+ } else {
3820
+ s = l > 0 && l < 1 ? 0 : h;
3821
+ }
3822
+ return new Hsl(h, s, l, o.opacity);
3823
+ }
3824
+
3825
+ function hsl(h, s, l, opacity) {
3826
+ return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
3827
+ }
3828
+
3829
+ function Hsl(h, s, l, opacity) {
3830
+ this.h = +h;
3831
+ this.s = +s;
3832
+ this.l = +l;
3833
+ this.opacity = +opacity;
3834
+ }
3835
+
3836
+ define(Hsl, hsl, extend(Color, {
3837
+ brighter(k) {
3838
+ k = k == null ? brighter : Math.pow(brighter, k);
3839
+ return new Hsl(this.h, this.s, this.l * k, this.opacity);
3840
+ },
3841
+ darker(k) {
3842
+ k = k == null ? darker : Math.pow(darker, k);
3843
+ return new Hsl(this.h, this.s, this.l * k, this.opacity);
3844
+ },
3845
+ rgb() {
3846
+ var h = this.h % 360 + (this.h < 0) * 360,
3847
+ s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
3848
+ l = this.l,
3849
+ m2 = l + (l < 0.5 ? l : 1 - l) * s,
3850
+ m1 = 2 * l - m2;
3851
+ return new Rgb(
3852
+ hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
3853
+ hsl2rgb(h, m1, m2),
3854
+ hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
3855
+ this.opacity
3856
+ );
3857
+ },
3858
+ clamp() {
3859
+ return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
3860
+ },
3861
+ displayable() {
3862
+ return (0 <= this.s && this.s <= 1 || isNaN(this.s))
3863
+ && (0 <= this.l && this.l <= 1)
3864
+ && (0 <= this.opacity && this.opacity <= 1);
3865
+ },
3866
+ formatHsl() {
3867
+ const a = clampa(this.opacity);
3868
+ return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`;
3869
+ }
3870
+ }));
3871
+
3872
+ function clamph(value) {
3873
+ value = (value || 0) % 360;
3874
+ return value < 0 ? value + 360 : value;
3875
+ }
3876
+
3877
+ function clampt(value) {
3878
+ return Math.max(0, Math.min(1, value || 0));
3879
+ }
3880
+
3881
+ /* From FvD 13.37, CSS Color Module Level 3 */
3882
+ function hsl2rgb(h, m1, m2) {
3883
+ return (h < 60 ? m1 + (m2 - m1) * h / 60
3884
+ : h < 180 ? m2
3885
+ : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
3886
+ : m1) * 255;
3887
+ }
3888
+
3889
+ var constant = x => () => x;
3890
+
3891
+ function linear$1(a, d) {
3892
+ return function(t) {
3893
+ return a + t * d;
3894
+ };
3895
+ }
3896
+
3897
+ function exponential(a, b, y) {
3898
+ return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
3899
+ return Math.pow(a + t * b, y);
3900
+ };
3901
+ }
3902
+
3903
+ function gamma(y) {
3904
+ return (y = +y) === 1 ? nogamma : function(a, b) {
3905
+ return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a);
3906
+ };
3907
+ }
3908
+
3909
+ function nogamma(a, b) {
3910
+ var d = b - a;
3911
+ return d ? linear$1(a, d) : constant(isNaN(a) ? b : a);
3912
+ }
3913
+
3914
+ var rgb = (function rgbGamma(y) {
3915
+ var color = gamma(y);
3916
+
3917
+ function rgb(start, end) {
3918
+ var r = color((start = rgb$1(start)).r, (end = rgb$1(end)).r),
3919
+ g = color(start.g, end.g),
3920
+ b = color(start.b, end.b),
3921
+ opacity = nogamma(start.opacity, end.opacity);
3922
+ return function(t) {
3923
+ start.r = r(t);
3924
+ start.g = g(t);
3925
+ start.b = b(t);
3926
+ start.opacity = opacity(t);
3927
+ return start + "";
3928
+ };
3929
+ }
3930
+
3931
+ rgb.gamma = rgbGamma;
3932
+
3933
+ return rgb;
3934
+ })(1);
3935
+
3936
+ function numberArray(a, b) {
3937
+ if (!b) b = [];
3938
+ var n = a ? Math.min(b.length, a.length) : 0,
3939
+ c = b.slice(),
3940
+ i;
3941
+ return function(t) {
3942
+ for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
3943
+ return c;
3944
+ };
3945
+ }
3946
+
3947
+ function isNumberArray(x) {
3948
+ return ArrayBuffer.isView(x) && !(x instanceof DataView);
3949
+ }
3950
+
3951
+ function genericArray(a, b) {
3952
+ var nb = b ? b.length : 0,
3953
+ na = a ? Math.min(nb, a.length) : 0,
3954
+ x = new Array(na),
3955
+ c = new Array(nb),
3956
+ i;
3957
+
3958
+ for (i = 0; i < na; ++i) x[i] = interpolate(a[i], b[i]);
3959
+ for (; i < nb; ++i) c[i] = b[i];
3960
+
3961
+ return function(t) {
3962
+ for (i = 0; i < na; ++i) c[i] = x[i](t);
3963
+ return c;
3964
+ };
3965
+ }
3966
+
3967
+ function date(a, b) {
3968
+ var d = new Date;
3969
+ return a = +a, b = +b, function(t) {
3970
+ return d.setTime(a * (1 - t) + b * t), d;
3971
+ };
3972
+ }
3973
+
3974
+ function interpolateNumber(a, b) {
3975
+ return a = +a, b = +b, function(t) {
3976
+ return a * (1 - t) + b * t;
3977
+ };
3978
+ }
3979
+
3980
+ function object(a, b) {
3981
+ var i = {},
3982
+ c = {},
3983
+ k;
3984
+
3985
+ if (a === null || typeof a !== "object") a = {};
3986
+ if (b === null || typeof b !== "object") b = {};
3987
+
3988
+ for (k in b) {
3989
+ if (k in a) {
3990
+ i[k] = interpolate(a[k], b[k]);
3991
+ } else {
3992
+ c[k] = b[k];
3993
+ }
3994
+ }
3995
+
3996
+ return function(t) {
3997
+ for (k in i) c[k] = i[k](t);
3998
+ return c;
3999
+ };
4000
+ }
4001
+
4002
+ var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
4003
+ reB = new RegExp(reA.source, "g");
4004
+
4005
+ function zero(b) {
4006
+ return function() {
4007
+ return b;
4008
+ };
4009
+ }
4010
+
4011
+ function one(b) {
4012
+ return function(t) {
4013
+ return b(t) + "";
4014
+ };
4015
+ }
4016
+
4017
+ function string(a, b) {
4018
+ var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b
4019
+ am, // current match in a
4020
+ bm, // current match in b
4021
+ bs, // string preceding current number in b, if any
4022
+ i = -1, // index in s
4023
+ s = [], // string constants and placeholders
4024
+ q = []; // number interpolators
4025
+
4026
+ // Coerce inputs to strings.
4027
+ a = a + "", b = b + "";
4028
+
4029
+ // Interpolate pairs of numbers in a & b.
4030
+ while ((am = reA.exec(a))
4031
+ && (bm = reB.exec(b))) {
4032
+ if ((bs = bm.index) > bi) { // a string precedes the next number in b
4033
+ bs = b.slice(bi, bs);
4034
+ if (s[i]) s[i] += bs; // coalesce with previous string
4035
+ else s[++i] = bs;
4036
+ }
4037
+ if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match
4038
+ if (s[i]) s[i] += bm; // coalesce with previous string
4039
+ else s[++i] = bm;
4040
+ } else { // interpolate non-matching numbers
4041
+ s[++i] = null;
4042
+ q.push({i: i, x: interpolateNumber(am, bm)});
4043
+ }
4044
+ bi = reB.lastIndex;
4045
+ }
4046
+
4047
+ // Add remains of b.
4048
+ if (bi < b.length) {
4049
+ bs = b.slice(bi);
4050
+ if (s[i]) s[i] += bs; // coalesce with previous string
4051
+ else s[++i] = bs;
4052
+ }
4053
+
4054
+ // Special optimization for only a single match.
4055
+ // Otherwise, interpolate each of the numbers and rejoin the string.
4056
+ return s.length < 2 ? (q[0]
4057
+ ? one(q[0].x)
4058
+ : zero(b))
4059
+ : (b = q.length, function(t) {
4060
+ for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
4061
+ return s.join("");
4062
+ });
4063
+ }
4064
+
4065
+ function interpolate(a, b) {
4066
+ var t = typeof b, c;
4067
+ return b == null || t === "boolean" ? constant(b)
4068
+ : (t === "number" ? interpolateNumber
4069
+ : t === "string" ? ((c = color(b)) ? (b = c, rgb) : string)
4070
+ : b instanceof color ? rgb
4071
+ : b instanceof Date ? date
4072
+ : isNumberArray(b) ? numberArray
4073
+ : Array.isArray(b) ? genericArray
4074
+ : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
4075
+ : interpolateNumber)(a, b);
4076
+ }
4077
+
4078
+ function interpolateRound(a, b) {
4079
+ return a = +a, b = +b, function(t) {
4080
+ return Math.round(a * (1 - t) + b * t);
4081
+ };
4082
+ }
4083
+
4084
+ function constants(x) {
4085
+ return function() {
4086
+ return x;
4087
+ };
4088
+ }
4089
+
4090
+ function number(x) {
4091
+ return +x;
4092
+ }
4093
+
4094
+ var unit = [0, 1];
4095
+
4096
+ function identity$1(x) {
4097
+ return x;
4098
+ }
4099
+
4100
+ function normalize(a, b) {
4101
+ return (b -= (a = +a))
4102
+ ? function(x) { return (x - a) / b; }
4103
+ : constants(isNaN(b) ? NaN : 0.5);
4104
+ }
4105
+
4106
+ function clamper(a, b) {
4107
+ var t;
4108
+ if (a > b) t = a, a = b, b = t;
4109
+ return function(x) { return Math.max(a, Math.min(b, x)); };
4110
+ }
4111
+
4112
+ // normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
4113
+ // interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
4114
+ function bimap(domain, range, interpolate) {
4115
+ var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
4116
+ if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
4117
+ else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
4118
+ return function(x) { return r0(d0(x)); };
4119
+ }
4120
+
4121
+ function polymap(domain, range, interpolate) {
4122
+ var j = Math.min(domain.length, range.length) - 1,
4123
+ d = new Array(j),
4124
+ r = new Array(j),
4125
+ i = -1;
4126
+
4127
+ // Reverse descending domains.
4128
+ if (domain[j] < domain[0]) {
4129
+ domain = domain.slice().reverse();
4130
+ range = range.slice().reverse();
4131
+ }
4132
+
4133
+ while (++i < j) {
4134
+ d[i] = normalize(domain[i], domain[i + 1]);
4135
+ r[i] = interpolate(range[i], range[i + 1]);
4136
+ }
4137
+
4138
+ return function(x) {
4139
+ var i = bisect(domain, x, 1, j) - 1;
4140
+ return r[i](d[i](x));
4141
+ };
4142
+ }
4143
+
4144
+ function copy$1(source, target) {
4145
+ return target
4146
+ .domain(source.domain())
4147
+ .range(source.range())
4148
+ .interpolate(source.interpolate())
4149
+ .clamp(source.clamp())
4150
+ .unknown(source.unknown());
4151
+ }
4152
+
4153
+ function transformer$1() {
4154
+ var domain = unit,
4155
+ range = unit,
4156
+ interpolate$1 = interpolate,
4157
+ transform,
4158
+ untransform,
4159
+ unknown,
4160
+ clamp = identity$1,
4161
+ piecewise,
4162
+ output,
4163
+ input;
4164
+
4165
+ function rescale() {
4166
+ var n = Math.min(domain.length, range.length);
4167
+ if (clamp !== identity$1) clamp = clamper(domain[0], domain[n - 1]);
4168
+ piecewise = n > 2 ? polymap : bimap;
4169
+ output = input = null;
4170
+ return scale;
4171
+ }
4172
+
4173
+ function scale(x) {
4174
+ return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate$1)))(transform(clamp(x)));
4175
+ }
4176
+
4177
+ scale.invert = function(y) {
4178
+ return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y)));
4179
+ };
4180
+
4181
+ scale.domain = function(_) {
4182
+ return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice();
4183
+ };
4184
+
4185
+ scale.range = function(_) {
4186
+ return arguments.length ? (range = Array.from(_), rescale()) : range.slice();
4187
+ };
4188
+
4189
+ scale.rangeRound = function(_) {
4190
+ return range = Array.from(_), interpolate$1 = interpolateRound, rescale();
4191
+ };
4192
+
4193
+ scale.clamp = function(_) {
4194
+ return arguments.length ? (clamp = _ ? true : identity$1, rescale()) : clamp !== identity$1;
4195
+ };
4196
+
4197
+ scale.interpolate = function(_) {
4198
+ return arguments.length ? (interpolate$1 = _, rescale()) : interpolate$1;
4199
+ };
4200
+
4201
+ scale.unknown = function(_) {
4202
+ return arguments.length ? (unknown = _, scale) : unknown;
4203
+ };
4204
+
4205
+ return function(t, u) {
4206
+ transform = t, untransform = u;
4207
+ return rescale();
4208
+ };
4209
+ }
4210
+
4211
+ function continuous() {
4212
+ return transformer$1()(identity$1, identity$1);
4213
+ }
4214
+
4215
+ function formatDecimal(x) {
4216
+ return Math.abs(x = Math.round(x)) >= 1e21
4217
+ ? x.toLocaleString("en").replace(/,/g, "")
4218
+ : x.toString(10);
4219
+ }
4220
+
4221
+ // Computes the decimal coefficient and exponent of the specified number x with
4222
+ // significant digits p, where x is positive and p is in [1, 21] or undefined.
4223
+ // For example, formatDecimalParts(1.23) returns ["123", 0].
4224
+ function formatDecimalParts(x, p) {
4225
+ if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity
4226
+ var i, coefficient = x.slice(0, i);
4227
+
4228
+ // The string returned by toExponential either has the form \d\.\d+e[-+]\d+
4229
+ // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3).
4230
+ return [
4231
+ coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
4232
+ +x.slice(i + 1)
4233
+ ];
4234
+ }
4235
+
4236
+ function exponent(x) {
4237
+ return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN;
4238
+ }
4239
+
4240
+ function formatGroup(grouping, thousands) {
4241
+ return function(value, width) {
4242
+ var i = value.length,
4243
+ t = [],
4244
+ j = 0,
4245
+ g = grouping[0],
4246
+ length = 0;
4247
+
4248
+ while (i > 0 && g > 0) {
4249
+ if (length + g + 1 > width) g = Math.max(1, width - length);
4250
+ t.push(value.substring(i -= g, i + g));
4251
+ if ((length += g + 1) > width) break;
4252
+ g = grouping[j = (j + 1) % grouping.length];
4253
+ }
4254
+
4255
+ return t.reverse().join(thousands);
4256
+ };
4257
+ }
4258
+
4259
+ function formatNumerals(numerals) {
4260
+ return function(value) {
4261
+ return value.replace(/[0-9]/g, function(i) {
4262
+ return numerals[+i];
4263
+ });
4264
+ };
4265
+ }
4266
+
4267
+ // [[fill]align][sign][symbol][0][width][,][.precision][~][type]
4268
+ var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
4269
+
4270
+ function formatSpecifier(specifier) {
4271
+ if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
4272
+ var match;
4273
+ return new FormatSpecifier({
4274
+ fill: match[1],
4275
+ align: match[2],
4276
+ sign: match[3],
4277
+ symbol: match[4],
4278
+ zero: match[5],
4279
+ width: match[6],
4280
+ comma: match[7],
4281
+ precision: match[8] && match[8].slice(1),
4282
+ trim: match[9],
4283
+ type: match[10]
4284
+ });
4285
+ }
4286
+
4287
+ formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
4288
+
4289
+ function FormatSpecifier(specifier) {
4290
+ this.fill = specifier.fill === undefined ? " " : specifier.fill + "";
4291
+ this.align = specifier.align === undefined ? ">" : specifier.align + "";
4292
+ this.sign = specifier.sign === undefined ? "-" : specifier.sign + "";
4293
+ this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + "";
4294
+ this.zero = !!specifier.zero;
4295
+ this.width = specifier.width === undefined ? undefined : +specifier.width;
4296
+ this.comma = !!specifier.comma;
4297
+ this.precision = specifier.precision === undefined ? undefined : +specifier.precision;
4298
+ this.trim = !!specifier.trim;
4299
+ this.type = specifier.type === undefined ? "" : specifier.type + "";
4300
+ }
4301
+
4302
+ FormatSpecifier.prototype.toString = function() {
4303
+ return this.fill
4304
+ + this.align
4305
+ + this.sign
4306
+ + this.symbol
4307
+ + (this.zero ? "0" : "")
4308
+ + (this.width === undefined ? "" : Math.max(1, this.width | 0))
4309
+ + (this.comma ? "," : "")
4310
+ + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0))
4311
+ + (this.trim ? "~" : "")
4312
+ + this.type;
4313
+ };
4314
+
4315
+ // Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k.
4316
+ function formatTrim(s) {
4317
+ out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
4318
+ switch (s[i]) {
4319
+ case ".": i0 = i1 = i; break;
4320
+ case "0": if (i0 === 0) i0 = i; i1 = i; break;
4321
+ default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break;
4322
+ }
4323
+ }
4324
+ return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
4325
+ }
4326
+
4327
+ var prefixExponent;
4328
+
4329
+ function formatPrefixAuto(x, p) {
4330
+ var d = formatDecimalParts(x, p);
4331
+ if (!d) return x + "";
4332
+ var coefficient = d[0],
4333
+ exponent = d[1],
4334
+ i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1,
4335
+ n = coefficient.length;
4336
+ return i === n ? coefficient
4337
+ : i > n ? coefficient + new Array(i - n + 1).join("0")
4338
+ : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i)
4339
+ : "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y!
4340
+ }
4341
+
4342
+ function formatRounded(x, p) {
4343
+ var d = formatDecimalParts(x, p);
4344
+ if (!d) return x + "";
4345
+ var coefficient = d[0],
4346
+ exponent = d[1];
4347
+ return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient
4348
+ : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1)
4349
+ : coefficient + new Array(exponent - coefficient.length + 2).join("0");
4350
+ }
4351
+
4352
+ var formatTypes = {
4353
+ "%": (x, p) => (x * 100).toFixed(p),
4354
+ "b": (x) => Math.round(x).toString(2),
4355
+ "c": (x) => x + "",
4356
+ "d": formatDecimal,
4357
+ "e": (x, p) => x.toExponential(p),
4358
+ "f": (x, p) => x.toFixed(p),
4359
+ "g": (x, p) => x.toPrecision(p),
4360
+ "o": (x) => Math.round(x).toString(8),
4361
+ "p": (x, p) => formatRounded(x * 100, p),
4362
+ "r": formatRounded,
4363
+ "s": formatPrefixAuto,
4364
+ "X": (x) => Math.round(x).toString(16).toUpperCase(),
4365
+ "x": (x) => Math.round(x).toString(16)
4366
+ };
4367
+
4368
+ function identity(x) {
4369
+ return x;
4370
+ }
4371
+
4372
+ var map = Array.prototype.map,
4373
+ prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];
4374
+
4375
+ function formatLocale(locale) {
4376
+ var group = locale.grouping === undefined || locale.thousands === undefined ? identity : formatGroup(map.call(locale.grouping, Number), locale.thousands + ""),
4377
+ currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "",
4378
+ currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "",
4379
+ decimal = locale.decimal === undefined ? "." : locale.decimal + "",
4380
+ numerals = locale.numerals === undefined ? identity : formatNumerals(map.call(locale.numerals, String)),
4381
+ percent = locale.percent === undefined ? "%" : locale.percent + "",
4382
+ minus = locale.minus === undefined ? "−" : locale.minus + "",
4383
+ nan = locale.nan === undefined ? "NaN" : locale.nan + "";
4384
+
4385
+ function newFormat(specifier) {
4386
+ specifier = formatSpecifier(specifier);
4387
+
4388
+ var fill = specifier.fill,
4389
+ align = specifier.align,
4390
+ sign = specifier.sign,
4391
+ symbol = specifier.symbol,
4392
+ zero = specifier.zero,
4393
+ width = specifier.width,
4394
+ comma = specifier.comma,
4395
+ precision = specifier.precision,
4396
+ trim = specifier.trim,
4397
+ type = specifier.type;
4398
+
4399
+ // The "n" type is an alias for ",g".
4400
+ if (type === "n") comma = true, type = "g";
4401
+
4402
+ // The "" type, and any invalid type, is an alias for ".12~g".
4403
+ else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g";
4404
+
4405
+ // If zero fill is specified, padding goes after sign and before digits.
4406
+ if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "=";
4407
+
4408
+ // Compute the prefix and suffix.
4409
+ // For SI-prefix, the suffix is lazily computed.
4410
+ var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
4411
+ suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "";
4412
+
4413
+ // What format function should we use?
4414
+ // Is this an integer type?
4415
+ // Can this type generate exponential notation?
4416
+ var formatType = formatTypes[type],
4417
+ maybeSuffix = /[defgprs%]/.test(type);
4418
+
4419
+ // Set the default precision if not specified,
4420
+ // or clamp the specified precision to the supported range.
4421
+ // For significant precision, it must be in [1, 21].
4422
+ // For fixed precision, it must be in [0, 20].
4423
+ precision = precision === undefined ? 6
4424
+ : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision))
4425
+ : Math.max(0, Math.min(20, precision));
4426
+
4427
+ function format(value) {
4428
+ var valuePrefix = prefix,
4429
+ valueSuffix = suffix,
4430
+ i, n, c;
4431
+
4432
+ if (type === "c") {
4433
+ valueSuffix = formatType(value) + valueSuffix;
4434
+ value = "";
4435
+ } else {
4436
+ value = +value;
4437
+
4438
+ // Determine the sign. -0 is not less than 0, but 1 / -0 is!
4439
+ var valueNegative = value < 0 || 1 / value < 0;
4440
+
4441
+ // Perform the initial formatting.
4442
+ value = isNaN(value) ? nan : formatType(Math.abs(value), precision);
4443
+
4444
+ // Trim insignificant zeros.
4445
+ if (trim) value = formatTrim(value);
4446
+
4447
+ // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign.
4448
+ if (valueNegative && +value === 0 && sign !== "+") valueNegative = false;
4449
+
4450
+ // Compute the prefix and suffix.
4451
+ valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
4452
+ valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
4453
+
4454
+ // Break the formatted value into the integer “value” part that can be
4455
+ // grouped, and fractional or exponential “suffix” part that is not.
4456
+ if (maybeSuffix) {
4457
+ i = -1, n = value.length;
4458
+ while (++i < n) {
4459
+ if (c = value.charCodeAt(i), 48 > c || c > 57) {
4460
+ valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
4461
+ value = value.slice(0, i);
4462
+ break;
4463
+ }
4464
+ }
4465
+ }
4466
+ }
4467
+
4468
+ // If the fill character is not "0", grouping is applied before padding.
4469
+ if (comma && !zero) value = group(value, Infinity);
4470
+
4471
+ // Compute the padding.
4472
+ var length = valuePrefix.length + value.length + valueSuffix.length,
4473
+ padding = length < width ? new Array(width - length + 1).join(fill) : "";
4474
+
4475
+ // If the fill character is "0", grouping is applied after padding.
4476
+ if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
4477
+
4478
+ // Reconstruct the final output based on the desired alignment.
4479
+ switch (align) {
4480
+ case "<": value = valuePrefix + value + valueSuffix + padding; break;
4481
+ case "=": value = valuePrefix + padding + value + valueSuffix; break;
4482
+ case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break;
4483
+ default: value = padding + valuePrefix + value + valueSuffix; break;
4484
+ }
4485
+
4486
+ return numerals(value);
4487
+ }
4488
+
4489
+ format.toString = function() {
4490
+ return specifier + "";
4491
+ };
4492
+
4493
+ return format;
4494
+ }
4495
+
4496
+ function formatPrefix(specifier, value) {
4497
+ var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)),
4498
+ e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3,
4499
+ k = Math.pow(10, -e),
4500
+ prefix = prefixes[8 + e / 3];
4501
+ return function(value) {
4502
+ return f(k * value) + prefix;
4503
+ };
4504
+ }
4505
+
4506
+ return {
4507
+ format: newFormat,
4508
+ formatPrefix: formatPrefix
4509
+ };
4510
+ }
4511
+
4512
+ var locale;
4513
+ var format;
4514
+ var formatPrefix;
4515
+
4516
+ defaultLocale({
4517
+ thousands: ",",
4518
+ grouping: [3],
4519
+ currency: ["$", ""]
4520
+ });
4521
+
4522
+ function defaultLocale(definition) {
4523
+ locale = formatLocale(definition);
4524
+ format = locale.format;
4525
+ formatPrefix = locale.formatPrefix;
4526
+ return locale;
4527
+ }
4528
+
4529
+ function precisionFixed(step) {
4530
+ return Math.max(0, -exponent(Math.abs(step)));
4531
+ }
4532
+
4533
+ function precisionPrefix(step, value) {
4534
+ return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step)));
4535
+ }
4536
+
4537
+ function precisionRound(step, max) {
4538
+ step = Math.abs(step), max = Math.abs(max) - step;
4539
+ return Math.max(0, exponent(max) - exponent(step)) + 1;
4540
+ }
4541
+
4542
+ function tickFormat(start, stop, count, specifier) {
4543
+ var step = tickStep(start, stop, count),
4544
+ precision;
4545
+ specifier = formatSpecifier(specifier == null ? ",f" : specifier);
4546
+ switch (specifier.type) {
4547
+ case "s": {
4548
+ var value = Math.max(Math.abs(start), Math.abs(stop));
4549
+ if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision;
4550
+ return formatPrefix(specifier, value);
4551
+ }
4552
+ case "":
4553
+ case "e":
4554
+ case "g":
4555
+ case "p":
4556
+ case "r": {
4557
+ if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
4558
+ break;
4559
+ }
4560
+ case "f":
4561
+ case "%": {
4562
+ if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
4563
+ break;
4564
+ }
4565
+ }
4566
+ return format(specifier);
4567
+ }
4568
+
4569
+ function linearish(scale) {
4570
+ var domain = scale.domain;
4571
+
4572
+ scale.ticks = function(count) {
4573
+ var d = domain();
4574
+ return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
4575
+ };
4576
+
4577
+ scale.tickFormat = function(count, specifier) {
4578
+ var d = domain();
4579
+ return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
4580
+ };
4581
+
4582
+ scale.nice = function(count) {
4583
+ if (count == null) count = 10;
4584
+
4585
+ var d = domain();
4586
+ var i0 = 0;
4587
+ var i1 = d.length - 1;
4588
+ var start = d[i0];
4589
+ var stop = d[i1];
4590
+ var prestep;
4591
+ var step;
4592
+ var maxIter = 10;
4593
+
4594
+ if (stop < start) {
4595
+ step = start, start = stop, stop = step;
4596
+ step = i0, i0 = i1, i1 = step;
4597
+ }
4598
+
4599
+ while (maxIter-- > 0) {
4600
+ step = tickIncrement(start, stop, count);
4601
+ if (step === prestep) {
4602
+ d[i0] = start;
4603
+ d[i1] = stop;
4604
+ return domain(d);
4605
+ } else if (step > 0) {
4606
+ start = Math.floor(start / step) * step;
4607
+ stop = Math.ceil(stop / step) * step;
4608
+ } else if (step < 0) {
4609
+ start = Math.ceil(start * step) / step;
4610
+ stop = Math.floor(stop * step) / step;
4611
+ } else {
4612
+ break;
4613
+ }
4614
+ prestep = step;
4615
+ }
4616
+
4617
+ return scale;
4618
+ };
4619
+
4620
+ return scale;
4621
+ }
4622
+
4623
+ function linear() {
4624
+ var scale = continuous();
4625
+
4626
+ scale.copy = function() {
4627
+ return copy$1(scale, linear());
4628
+ };
4629
+
4630
+ initRange.apply(scale, arguments);
4631
+
4632
+ return linearish(scale);
4633
+ }
4634
+
4635
+ function transformer() {
4636
+ var x0 = 0,
4637
+ x1 = 1,
4638
+ t0,
4639
+ t1,
4640
+ k10,
4641
+ transform,
4642
+ interpolator = identity$1,
4643
+ clamp = false,
4644
+ unknown;
4645
+
4646
+ function scale(x) {
4647
+ return x == null || isNaN(x = +x) ? unknown : interpolator(k10 === 0 ? 0.5 : (x = (transform(x) - t0) * k10, clamp ? Math.max(0, Math.min(1, x)) : x));
4648
+ }
4649
+
4650
+ scale.domain = function(_) {
4651
+ return arguments.length ? ([x0, x1] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0), scale) : [x0, x1];
4652
+ };
4653
+
4654
+ scale.clamp = function(_) {
4655
+ return arguments.length ? (clamp = !!_, scale) : clamp;
4656
+ };
4657
+
4658
+ scale.interpolator = function(_) {
4659
+ return arguments.length ? (interpolator = _, scale) : interpolator;
4660
+ };
4661
+
4662
+ function range(interpolate) {
4663
+ return function(_) {
4664
+ var r0, r1;
4665
+ return arguments.length ? ([r0, r1] = _, interpolator = interpolate(r0, r1), scale) : [interpolator(0), interpolator(1)];
4666
+ };
4667
+ }
4668
+
4669
+ scale.range = range(interpolate);
4670
+
4671
+ scale.rangeRound = range(interpolateRound);
4672
+
4673
+ scale.unknown = function(_) {
4674
+ return arguments.length ? (unknown = _, scale) : unknown;
4675
+ };
4676
+
4677
+ return function(t) {
4678
+ transform = t, t0 = t(x0), t1 = t(x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0);
4679
+ return scale;
4680
+ };
4681
+ }
4682
+
4683
+ function copy(source, target) {
4684
+ return target
4685
+ .domain(source.domain())
4686
+ .interpolator(source.interpolator())
4687
+ .clamp(source.clamp())
4688
+ .unknown(source.unknown());
4689
+ }
4690
+
4691
+ function sequential() {
4692
+ var scale = linearish(transformer()(identity$1));
4693
+
4694
+ scale.copy = function() {
4695
+ return copy(scale, sequential());
4696
+ };
4697
+
4698
+ return initInterpolator.apply(scale, arguments);
4699
+ }
4700
+
4701
+ const COLOR_BASE = "#cecece";
4702
+
4703
+ // https://www.w3.org/TR/WCAG20/#relativeluminancedef
4704
+ const rc = 0.2126;
4705
+ const gc = 0.7152;
4706
+ const bc = 0.0722;
4707
+ // low-gamma adjust coefficient
4708
+ const lowc = 1 / 12.92;
4709
+ function adjustGamma(p) {
4710
+ return Math.pow((p + 0.055) / 1.055, 2.4);
4711
+ }
4712
+ function relativeLuminance(o) {
4713
+ const rsrgb = o.r / 255;
4714
+ const gsrgb = o.g / 255;
4715
+ const bsrgb = o.b / 255;
4716
+ const r = rsrgb <= 0.03928 ? rsrgb * lowc : adjustGamma(rsrgb);
4717
+ const g = gsrgb <= 0.03928 ? gsrgb * lowc : adjustGamma(gsrgb);
4718
+ const b = bsrgb <= 0.03928 ? bsrgb * lowc : adjustGamma(bsrgb);
4719
+ return r * rc + g * gc + b * bc;
4720
+ }
4721
+ const createRainbowColor = (root) => {
4722
+ const colorParentMap = new Map();
4723
+ colorParentMap.set(root, COLOR_BASE);
4724
+ if (root.children != null) {
4725
+ const colorScale = sequential([0, root.children.length], (n) => hsl(360 * n, 0.3, 0.85));
4726
+ root.children.forEach((c, id) => {
4727
+ colorParentMap.set(c, colorScale(id).toString());
4728
+ });
4729
+ }
4730
+ const colorMap = new Map();
4731
+ const lightScale = linear().domain([0, root.height]).range([0.9, 0.3]);
4732
+ const getBackgroundColor = (node) => {
4733
+ const parents = node.ancestors();
4734
+ const colorStr = parents.length === 1
4735
+ ? colorParentMap.get(parents[0])
4736
+ : colorParentMap.get(parents[parents.length - 2]);
4737
+ const hslColor = hsl(colorStr);
4738
+ hslColor.l = lightScale(node.depth);
4739
+ return hslColor;
4740
+ };
4741
+ return (node) => {
4742
+ if (!colorMap.has(node)) {
4743
+ const backgroundColor = getBackgroundColor(node);
4744
+ const l = relativeLuminance(backgroundColor.rgb());
4745
+ const fontColor = l > 0.19 ? "#000" : "#fff";
4746
+ colorMap.set(node, {
4747
+ backgroundColor: backgroundColor.toString(),
4748
+ fontColor,
4749
+ });
4750
+ }
4751
+ return colorMap.get(node);
4752
+ };
4753
+ };
4754
+
4755
+ const StaticContext = F$1({});
4756
+ const drawChart = (parentNode, data, width, height) => {
4757
+ const availableSizeProperties = getAvailableSizeOptions(data.options);
4758
+ console.time("layout create");
4759
+ const layout = treemap()
4760
+ .size([width, height])
4761
+ .paddingOuter(PADDING)
4762
+ .paddingTop(TOP_PADDING)
4763
+ .paddingInner(PADDING)
4764
+ .round(true)
4765
+ .tile(treemapResquarify);
4766
+ console.timeEnd("layout create");
4767
+ console.time("rawHierarchy create");
4768
+ const rawHierarchy = hierarchy(data.tree);
4769
+ console.timeEnd("rawHierarchy create");
4770
+ const nodeSizesCache = new Map();
4771
+ const nodeIdsCache = new Map();
4772
+ const getModuleSize = (node, sizeKey) => { var _a, _b; return (_b = (_a = nodeSizesCache.get(node)) === null || _a === void 0 ? void 0 : _a[sizeKey]) !== null && _b !== void 0 ? _b : 0; };
4773
+ console.time("rawHierarchy eachAfter cache");
4774
+ rawHierarchy.eachAfter((node) => {
4775
+ var _a;
4776
+ const nodeData = node.data;
4777
+ nodeIdsCache.set(nodeData, {
4778
+ nodeUid: generateUniqueId("node"),
4779
+ clipUid: generateUniqueId("clip"),
4780
+ });
4781
+ const sizes = { renderedLength: 0, gzipLength: 0, brotliLength: 0 };
4782
+ if (isModuleTree(nodeData)) {
4783
+ for (const sizeKey of availableSizeProperties) {
4784
+ sizes[sizeKey] = nodeData.children.reduce((acc, child) => getModuleSize(child, sizeKey) + acc, 0);
4785
+ }
4786
+ }
4787
+ else {
4788
+ for (const sizeKey of availableSizeProperties) {
4789
+ sizes[sizeKey] = (_a = data.nodeParts[nodeData.uid][sizeKey]) !== null && _a !== void 0 ? _a : 0;
4790
+ }
4791
+ }
4792
+ nodeSizesCache.set(nodeData, sizes);
4793
+ });
4794
+ console.timeEnd("rawHierarchy eachAfter cache");
4795
+ const getModuleIds = (node) => nodeIdsCache.get(node);
4796
+ console.time("color");
4797
+ const getModuleColor = createRainbowColor(rawHierarchy);
4798
+ console.timeEnd("color");
4799
+ q$1(u$1(StaticContext.Provider, { value: {
4800
+ data,
4801
+ availableSizeProperties,
4802
+ width,
4803
+ height,
4804
+ getModuleSize,
4805
+ getModuleIds,
4806
+ getModuleColor,
4807
+ rawHierarchy,
4808
+ layout,
4809
+ }, children: u$1(Main, {}) }), parentNode);
4810
+ };
4811
+
4812
+ exports.StaticContext = StaticContext;
4813
+ exports.default = drawChart;
4814
+
4815
+ Object.defineProperty(exports, '__esModule', { value: true });
4816
+
4817
+ return exports;
4818
+
4819
+ })({});
4820
+
4821
+ /*-->*/
4822
+ </script>
4823
+ <script>
4824
+ /*<!--*/
4825
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.min.js","children":[{"name":"src/index.ts","uid":"569a8d4c-1"}]}],"isRoot":true},"nodeParts":{"569a8d4c-1":{"renderedLength":150,"gzipLength":0,"brotliLength":0,"metaUid":"569a8d4c-0"}},"nodeMetas":{"569a8d4c-0":{"id":"/src/index.ts","moduleParts":{"index.min.js":"569a8d4c-1"},"imported":[],"importedBy":[],"isEntry":true}},"env":{"rollup":"4.22.4"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
4826
+
4827
+ const run = () => {
4828
+ const width = window.innerWidth;
4829
+ const height = window.innerHeight;
4830
+
4831
+ const chartNode = document.querySelector("main");
4832
+ drawChart.default(chartNode, data, width, height);
4833
+ };
4834
+
4835
+ window.addEventListener('resize', run);
4836
+
4837
+ document.addEventListener('DOMContentLoaded', run);
4838
+ /*-->*/
4839
+ </script>
4840
+ </body>
4841
+ </html>
4842
+