svg-path-simplify 0.1.2 → 0.1.3
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/dist/svg-path-simplify.esm.js +136 -14
- package/dist/svg-path-simplify.esm.min.js +1 -1
- package/dist/svg-path-simplify.js +136 -14
- package/dist/svg-path-simplify.min.js +1 -1
- package/dist/svg-path-simplify.poly.cjs +0 -1
- package/index.html +10 -2
- package/package.json +3 -5
- package/src/index-poly.js +0 -1
- package/src/pathData_simplify_cubic.js +5 -19
- package/src/pathSimplify-main.js +46 -0
- package/src/svg_getViewbox.js +28 -15
- package/src/svgii/pathData_transform_scale.js +51 -0
- package/testSVG.js +1 -1
|
@@ -1939,7 +1939,7 @@ function combineCubicPairs(com1, com2, {
|
|
|
1939
1939
|
let distAv2 = getDistAv(com2.p0, com2.p);
|
|
1940
1940
|
let distMin = Math.max(0, Math.min(distAv1, distAv2));
|
|
1941
1941
|
|
|
1942
|
-
let distScale = 0.
|
|
1942
|
+
let distScale = 0.08;
|
|
1943
1943
|
let maxDist = distMin * distScale * tolerance;
|
|
1944
1944
|
|
|
1945
1945
|
// get hypothetical combined command
|
|
@@ -1973,8 +1973,6 @@ function combineCubicPairs(com1, com2, {
|
|
|
1973
1973
|
|
|
1974
1974
|
error += dist1;
|
|
1975
1975
|
|
|
1976
|
-
// quit - paths not congruent
|
|
1977
|
-
|
|
1978
1976
|
if (dist1 < maxDist) {
|
|
1979
1977
|
|
|
1980
1978
|
// 1st segment mid
|
|
@@ -1984,18 +1982,9 @@ function combineCubicPairs(com1, com2, {
|
|
|
1984
1982
|
let ptS_1 = pointAtT([comS.p0, comS.cp1, comS.cp2, comS.p], t2);
|
|
1985
1983
|
dist2 = getDistAv(pt_1, ptS_1);
|
|
1986
1984
|
|
|
1987
|
-
/*
|
|
1988
|
-
if(dist1>tolerance){
|
|
1989
|
-
renderPoint(markers, pt_1, 'blue')
|
|
1990
|
-
renderPoint(markers, ptS_1, 'orange', '0.5%')
|
|
1991
|
-
}
|
|
1992
|
-
*/
|
|
1993
|
-
|
|
1994
|
-
// quit - paths not congruent
|
|
1995
|
-
if (dist1 + dist2 < maxDist) success = true;
|
|
1996
|
-
|
|
1997
|
-
// collect error data
|
|
1998
1985
|
error += dist2;
|
|
1986
|
+
|
|
1987
|
+
if (error < maxDist) success = true;
|
|
1999
1988
|
|
|
2000
1989
|
}
|
|
2001
1990
|
|
|
@@ -5247,6 +5236,98 @@ function refineClosingCommand(pathData = [], {
|
|
|
5247
5236
|
|
|
5248
5237
|
}
|
|
5249
5238
|
|
|
5239
|
+
/**
|
|
5240
|
+
* scale path data proportionaly
|
|
5241
|
+
*/
|
|
5242
|
+
function scalePathData(pathData, scale = 1) {
|
|
5243
|
+
let pathDataScaled = [];
|
|
5244
|
+
|
|
5245
|
+
for (let i = 0, l = pathData.length; i < l; i++) {
|
|
5246
|
+
let com = pathData[i];
|
|
5247
|
+
let { type, values } = com;
|
|
5248
|
+
let comT = {
|
|
5249
|
+
type: type,
|
|
5250
|
+
values: []
|
|
5251
|
+
};
|
|
5252
|
+
|
|
5253
|
+
switch (type.toLowerCase()) {
|
|
5254
|
+
// lineto shorthands
|
|
5255
|
+
case "h":
|
|
5256
|
+
comT.values = [values[0] * scale];
|
|
5257
|
+
break;
|
|
5258
|
+
case "v":
|
|
5259
|
+
comT.values = [values[0] * scale];
|
|
5260
|
+
break;
|
|
5261
|
+
|
|
5262
|
+
// arcto
|
|
5263
|
+
case "a":
|
|
5264
|
+
comT.values = [
|
|
5265
|
+
values[0] * scale, // rx: scale
|
|
5266
|
+
values[1] * scale, // ry: scale
|
|
5267
|
+
values[2], // x-axis-rotation: keep it
|
|
5268
|
+
values[3], // largeArc: dito
|
|
5269
|
+
values[4], // sweep: dito
|
|
5270
|
+
values[5] * scale, // final x: scale
|
|
5271
|
+
values[6] * scale // final y: scale
|
|
5272
|
+
];
|
|
5273
|
+
break;
|
|
5274
|
+
|
|
5275
|
+
/**
|
|
5276
|
+
* Other point based commands: L, C, S, Q, T
|
|
5277
|
+
* scale all values
|
|
5278
|
+
*/
|
|
5279
|
+
default:
|
|
5280
|
+
if (values.length) {
|
|
5281
|
+
comT.values = values.map((val, i) => {
|
|
5282
|
+
return val * scale;
|
|
5283
|
+
});
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
pathDataScaled.push(comT);
|
|
5287
|
+
} return pathDataScaled;
|
|
5288
|
+
}
|
|
5289
|
+
|
|
5290
|
+
/**
|
|
5291
|
+
* get viewBox
|
|
5292
|
+
* either from explicit attribute or
|
|
5293
|
+
* width and height attributes
|
|
5294
|
+
*/
|
|
5295
|
+
|
|
5296
|
+
function getViewBox(svg = null, decimals = -1) {
|
|
5297
|
+
|
|
5298
|
+
const getUnit=(val)=>{
|
|
5299
|
+
return val && isNaN(val) ? val.match(/[^\d]+/g)[0] : '';
|
|
5300
|
+
};
|
|
5301
|
+
|
|
5302
|
+
// browser default
|
|
5303
|
+
if (!svg) return false
|
|
5304
|
+
|
|
5305
|
+
let hasWidth = svg.hasAttribute('width');
|
|
5306
|
+
let hasHeight = svg.hasAttribute('height');
|
|
5307
|
+
let hasViewBox = svg.hasAttribute('viewBox');
|
|
5308
|
+
|
|
5309
|
+
let widthAtt = hasWidth ? svg.getAttribute('width') : 0;
|
|
5310
|
+
let heightAtt = hasHeight ? svg.getAttribute('height') : 0;
|
|
5311
|
+
|
|
5312
|
+
let widthUnit = hasWidth ? getUnit(widthAtt) : false;
|
|
5313
|
+
let heightUnit = hasHeight ? getUnit(widthAtt) : false;
|
|
5314
|
+
|
|
5315
|
+
let w = widthAtt ? (!widthAtt.includes('%') ? parseFloat(widthAtt) : 0 ) : 300;
|
|
5316
|
+
let h = heightAtt ? (!heightAtt.includes('%') ? parseFloat(heightAtt) : 0 ) : 150;
|
|
5317
|
+
|
|
5318
|
+
let viewBoxVals = hasViewBox ? svg.getAttribute('viewBox').split(/,| /).filter(Boolean).map(Number) : [0, 0, w, h];
|
|
5319
|
+
|
|
5320
|
+
// round
|
|
5321
|
+
if (decimals>-1) {
|
|
5322
|
+
[w, h] = [w, h].map(val=>+val.toFixed(decimals));
|
|
5323
|
+
viewBoxVals = viewBoxVals.map(val=>+val.toFixed(decimals));
|
|
5324
|
+
}
|
|
5325
|
+
|
|
5326
|
+
let viewBox = { x:viewBoxVals[0] , y:viewBoxVals[1], width:viewBoxVals[2], height:viewBoxVals[3], w, h, hasViewBox, hasWidth, hasHeight, widthUnit, heightUnit };
|
|
5327
|
+
|
|
5328
|
+
return viewBox
|
|
5329
|
+
}
|
|
5330
|
+
|
|
5250
5331
|
function svgPathSimplify(input = '', {
|
|
5251
5332
|
|
|
5252
5333
|
// return svg markup or object
|
|
@@ -5284,6 +5365,9 @@ function svgPathSimplify(input = '', {
|
|
|
5284
5365
|
|
|
5285
5366
|
simplifyRound = false,
|
|
5286
5367
|
|
|
5368
|
+
scale=1,
|
|
5369
|
+
scaleTo=0,
|
|
5370
|
+
|
|
5287
5371
|
// svg path optimizations
|
|
5288
5372
|
decimals = 3,
|
|
5289
5373
|
autoAccuracy = true,
|
|
@@ -5387,6 +5471,25 @@ function svgPathSimplify(input = '', {
|
|
|
5387
5471
|
|
|
5388
5472
|
let pathData = parsePathDataNormalized(d, { quadraticToCubic, toAbsolute, arcToCubic });
|
|
5389
5473
|
|
|
5474
|
+
// scale pathdata and viewBox
|
|
5475
|
+
if(scale!==1 || scaleTo){
|
|
5476
|
+
|
|
5477
|
+
// get bbox for scaling
|
|
5478
|
+
if(scaleTo){
|
|
5479
|
+
|
|
5480
|
+
let pathDataExtr = pathData.map(com=>{return {type:com.type, values:com.values}});
|
|
5481
|
+
pathDataExtr = addExtremePoints(pathDataExtr);
|
|
5482
|
+
let poly = getPathDataVertices(pathDataExtr);
|
|
5483
|
+
let bb = getPolyBBox(poly);
|
|
5484
|
+
|
|
5485
|
+
let scaleW = scaleTo/bb.width;
|
|
5486
|
+
scale = scaleW;
|
|
5487
|
+
|
|
5488
|
+
}
|
|
5489
|
+
|
|
5490
|
+
pathData = scalePathData(pathData, scale);
|
|
5491
|
+
}
|
|
5492
|
+
|
|
5390
5493
|
// count commands for evaluation
|
|
5391
5494
|
let comCount = pathData.length;
|
|
5392
5495
|
|
|
@@ -5583,6 +5686,25 @@ function svgPathSimplify(input = '', {
|
|
|
5583
5686
|
removeEmptySVGEls(svg);
|
|
5584
5687
|
}
|
|
5585
5688
|
|
|
5689
|
+
// adjust viewBox and width for scale
|
|
5690
|
+
if(scale){
|
|
5691
|
+
|
|
5692
|
+
let vB = getViewBox(svg, decimals);
|
|
5693
|
+
let {x,y, width, height, w, h, hasViewBox, hasWidth, hasHeight, widthUnit, heightUnit} = vB;
|
|
5694
|
+
|
|
5695
|
+
if(hasViewBox){
|
|
5696
|
+
svg.setAttribute('viewBox', [x, y, width, height].map(val=>+(val*scale).toFixed(decimals)).join(' ') );
|
|
5697
|
+
}
|
|
5698
|
+
if(hasWidth){
|
|
5699
|
+
svg.setAttribute('width', +(w*scale).toFixed(decimals)+widthUnit );
|
|
5700
|
+
}
|
|
5701
|
+
|
|
5702
|
+
if(hasHeight){
|
|
5703
|
+
svg.setAttribute('height', +(h*scale).toFixed(decimals)+heightUnit );
|
|
5704
|
+
}
|
|
5705
|
+
|
|
5706
|
+
}
|
|
5707
|
+
|
|
5586
5708
|
svg = stringifySVG(svg);
|
|
5587
5709
|
|
|
5588
5710
|
svgSizeOpt = svg.length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t="",l="green",a="1%",n="1",s=!0){let r=`<path d="${t}" fill="none" stroke="${l}" stroke-width="${a}" stroke-opacity="${n}" /> `;if(!s)return r;e.insertAdjacentHTML("beforeend",r)}const{abs:t,acos:l,asin:a,atan:n,atan2:s,ceil:r,cos:p,exp:u,floor:i,log:y,max:h,min:o,pow:c,random:x,round:f,sin:g,sqrt:v,tan:d,PI:M}=Math;function m(e,t,l=!1){let a=s(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function b(e,t,l,a=!1){let n=Math.atan2(t.y-e.y,t.x-e.x),s=Math.atan2(l.y-e.y,l.x-e.x),r=s-n;r=(e=>{let t=e%(2*Math.PI);return t>Math.PI?t-=2*Math.PI:t<=-Math.PI&&(t+=2*Math.PI),t})(r),a&&(r=2*Math.PI-Math.abs(r));let p=180/Math.PI;return{startAngle:n,endAngle:s,deltaAngle:r,startAngleDeg:n*p,endAngleDeg:s*p,deltaAngleDeg:r*p}}function A(e=null,t=null,l=null,a=null,n=!0,s=!1){let r,p,u,i,y,h={};if(!(e&&t&&l&&a))return s&&console.warn("points missing"),!1;try{if(r=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==r)return!1}catch{return s&&console.warn("!catch",e,t,"p3:",l,"p4:",a),!1}p=e.y-l.y,u=e.x-l.x,i=(a.x-l.x)*p-(a.y-l.y)*u,y=(t.x-e.x)*p-(t.y-e.y)*u,p=i/r,u=y/r,h={x:e.x+p*(t.x-e.x),y:e.y+p*(t.y-e.y)};let o=!1;return p>0&&p<1&&u>0&&u<1&&(o=!0),!(n&&!o)&&h}function C(e,t){return v((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function w(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function L(e,t,l,a=!1){let n={x:(t.x-e.x)*l+e.x,y:(t.y-e.y)*l+e.y};return a&&(n.angle=m(e,t),n.angle<0&&(n.angle+=2*M)),n}function P(e,t=.5,l=!1,a=!1){let n;return n=e.length>2?((e,t,l=!1)=>{let n=4===e.length,s=e[0],r=e[1],p=n?e[2]:e[1],u=e[e.length-1],i={x:0,y:0};if(l||a){let e,l,y,h,o,c=s.x===r.x&&s.y===r.y,x=u.x===p.x&&u.y===p.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=L(s,r,t),n?(l=L(r,p,t),y=L(p,u,t),h=L(e,l,t),o=L(l,y,t),i=L(h,o,t),i.angle=m(h,o),a&&(i.cpts=[l,y,h,o])):(l=L(s,r,t),y=L(r,u,t),i=L(l,y,t),i.angle=m(l,y),a&&(i.cpts=[l,y]))):(i.x=u.x,i.y=u.y,i.angle=m(p,u)):(i.x=s.x,i.y=s.y,i.angle=m(s,r))}else{let e=1-t;i=n?{x:e**3*s.x+3*e**2*t*r.x+3*e*t**2*p.x+t**3*u.x,y:e**3*s.y+3*e**2*t*r.y+3*e*t**2*p.y+t**3*u.y}:{x:e*e*s.x+2*e*t*r.x+t**2*u.x,y:e*e*s.y+2*e*t*r.y+t**2*u.y}}return i})(e,t,l):L(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*M),n}function k(e,l,a,n,r,u,i,y,h){const o=(e,t,l,a)=>s(a-t,l-e);let c={cx:0,cy:0,rx:a=t(a),ry:n=t(n),startAngle:0,endAngle:0,deltaAngle:0,clockwise:i,xAxisRotation:r,largeArc:u,sweep:i};if(0==a||0==n)throw Error("rx and ry can not be 0");if(a===n){let t=Math.abs(y-e),a=Math.abs(h-l),n=t,s=Math.min(e,y),r=Math.min(l,h),p=.5*Math.PI;if(0===t&&a||0===a&&t)return n=0===t&&a?a/2:t/2,c.rx=n,c.ry=n,0===t&&a?(c.cx=e,c.cy=r+a/2,c.startAngle=l>h?p:-p,c.endAngle=l>h?-p:p,c.deltaAngle=i?Math.PI:-Math.PI):0===a&&t&&(c.cx=s+t/2,c.cy=l,c.startAngle=e>y?Math.PI:0,c.endAngle=e>y?-Math.PI:Math.PI,c.deltaAngle=i?Math.PI:-Math.PI),c}let x,f,d=a===n?0:r*M/180,m=d?g(d):0,b=d?p(d):1,A=(e-y)/2,C=(l-h)/2,w=(e+y)/2,L=(l+h)/2,P=d?b*A+m*C:A,k=d?b*C-m*A:C,I=P*P/(a*a)+k*k/(n*n);I>1&&(a*=v(I),n*=v(I),c.rx=a,c.ry=n);let $=a*n,S=a*k,F=n*P,z=S**2+F**2;if(!z)throw Error("start point can not be same as end point");let Q=v(t(($*$-z)/z));u==i&&(Q=-Q);let E=Q*S/n,T=-Q*F/a;x=d?b*E-m*T+w:w+E,f=d?m*E+b*T+L:L+T,c.cy=f,c.cx=x;let D=o(x,f,e,l),q=o(x,f,y,h);!i&&q>D&&(q-=2*Math.PI),i&&D>q&&(q=q<=0?q+2*Math.PI:q);let j=q-D;return c.startAngle=D,c.endAngle=q,c.deltaAngle=j,c}function I(e,t,l,a=0,n=!1){return a?(a=n?a/180*Math.PI:a,{x:t+(e.x-t)*Math.cos(a)-(e.y-l)*Math.sin(a),y:l+(e.x-t)*Math.sin(a)+(e.y-l)*Math.cos(a)}):e}function $(e,t,l,a,s,r=0,u=!0,i=!1){if(s=i?s*M/180:s,r=i?r*M/180:r,r=l!==a&&r!==2*M?r:0,u&&l!==a){let e=n(d(s=r?s-r:s)*(l/a));s=p(s)<0?e+M:e}let y=e+l*p(s),h=t+a*g(s),o={x:y,y:h};return r&&(o.x=e+(y-e)*p(r)-(h-t)*g(r),o.y=t+(y-e)*g(r)+(h-t)*p(r)),o}function S(e,t,l){if(t===l||e%M*.5==0)return e;let a=n(d(e)*(t/l));return a=p(e)<0?a+M:a,a}function F(e,t=[],l=.05){let a=3===t.length,n=t[0]||null,s=a?t[1]:null,r=a?t[2]:t[1],p=.5*Math.PI,u=!1,i=!1,y=n?m(r,n,!0):null;if(u=Math.abs(y%p)<l||Math.abs(y%p-p)<l,a){let e=s?m(s,r,!0):0;i=Math.abs(e%p)<=l||Math.abs(e%p-p)<=l}return u||i}function z(e){return 4===e.length?function(e,t,l,a){let[n,s,r,p,u,i,y,h]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],o=Math.min(e.y,a.y),c=Math.min(e.x,a.x),x=Math.max(e.x,a.x),f=Math.max(e.y,a.y);if(t.y>=o&&t.y<=f&&l.y>=o&&l.y<=f&&t.x>=c&&t.x<=x&&l.x>=c&&l.x<=x)return[];let g,v,d,M,m,b,A,C,w=[];for(let e=0;e<2;++e)if(0==e?(v=6*n-12*r+6*u,g=-3*n+9*r-9*u+3*y,d=3*r-3*n):(v=6*s-12*p+6*i,g=-3*s+9*p-9*i+3*h,d=3*p-3*s),Math.abs(g)<1e-12){if(Math.abs(v)<1e-12)continue;M=-d/v,0<M&&M<1&&w.push(M)}else A=v*v-4*d*g,A<0?Math.abs(A)<1e-12&&(M=-v/(2*g),0<M&&M<1&&w.push(M)):(C=Math.sqrt(A),m=(-v+C)/(2*g),0<m&&m<1&&w.push(m),b=(-v-C)/(2*g),0<b&&b<1&&w.push(b));let L=w.length;for(;L--;)M=w[L];return w}(e[0],e[1],e[2],e[3]):function(e,t,l){let a,n,s,r=Math.min(e.y,l.y),p=Math.min(e.x,l.x),u=Math.max(e.x,l.x),i=Math.max(e.y,l.y);if(t.y>=r&&t.y<=i&&t.x>=p&&t.x<=u)return[];let[y,h,o,c,x,f]=[e.x,e.y,t.x,t.y,l.x,l.y],g=[];for(let e=0;e<2;++e)a=0==e?y-2*o+x:h-2*c+f,n=0==e?-2*y+2*o:-2*h+2*c,Math.abs(a)>1e-12&&(s=-n/(2*a),s>0&&s<1&&g.push(s));return g}(e[0],e[1],e[2])}function Q(e,t){const l=(e,t,l,a,n,s)=>{var r=Math.cos(s),p=Math.sin(s),u=a*Math.cos(e),i=n*Math.sin(e);return{x:t+r*u-p*i,y:l+p*u+r*i}};let a,n,s,r,p,u=k(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:i,ry:y,cx:h,cy:o,endAngle:c,deltaAngle:x}=u,f=t[2],g={x:t[5],y:t[6]},v=[g],d=f*Math.PI/180,M=Math.tan(d);p=Math.atan2(-y*M,i);let m=p,b=p+Math.PI,A=Math.atan2(y,i*M),C=A+Math.PI,w=[e.x,g.x],L=[e.y,g.y],P=Math.min(...w),I=Math.max(...w),$=Math.min(...L),S=Math.max(...L),F=l(c-.001*x,h,o,i,y,d),z=l(c-.999*x,h,o,i,y,d);return(F.x>I||z.x>I)&&(a=l(m,h,o,i,y,d),v.push(a)),(F.x<P||z.x<P)&&(n=l(b,h,o,i,y,d),v.push(n)),(F.y<$||z.y<$)&&(r=l(C,h,o,i,y,d),v.push(r)),(F.y>S||z.y>S)&&(s=l(A,h,o,i,y,d),v.push(s)),v}function E(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function T(e){let t=[],l=[e[0]],a=e.length;for(let n=1;n<a;n++){let a=e[n];"M"!==a.type&&"m"!==a.type||(t.push(l),l=[]),l.push(a)}return l.length&&t.push(l),t}function D(e,t){let l,a,n,s,r,p,u=[],i=[],y=e[0],h=e[1],o=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=P([y,h],t),a=P([h,o],t),n=P([o,c],t),s=P([l,a],t),r=P([a,n],t),p=P([s,r],t),u.push({x:y.x,y:y.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:p.x,y:p.y}),i.push({x:p.x,y:p.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=P([y,h],t),n=P([h,c],t),p=P([a,n],t),u.push({x:y.x,y:y.y},{x:a.x,y:a.y},{x:p.x,y:p.y}),i.push({x:p.x,y:p.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=P([y,c],t),u.push({x:y.x,y:y.y},{x:a.x,y:a.y}),i.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[u,i]}function q(e,t,l=0,a=1){let n=[],s=6===t.length?"C":"Q",r={x:t[0],y:t[1]},p="C"===s?{x:t[2],y:t[3]}:r,u={x:t[4],y:t[5]},i=Math.max(u.x,e.x),y=Math.min(u.x,e.x),h=Math.max(u.y,e.y),o=Math.min(u.y,e.y),c=0;if(r.x<y||r.x>i||r.y<o||r.y>h||p.x<y||p.x>i||p.y<o||p.y>h){let i=z("C"===s?[e,r,p,u]:[e,r,u]).sort();if(i=i.filter(e=>e>l&&e<a),i.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let s,r,p,u=t.length,i={x:t[u-2],y:t[u-1]};2===t.length?p=[e,i]:4===t.length?(s={x:t[0],y:t[1]},p=[e,s,i]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},p=[e,s,r,i]);if(l.length)if(1===l.length){let e=D(p,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=D(p,e),a=t[0];n.push(a),p=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=D(p,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),p=a[1]}}if(a){let e,t,l=[];return n.forEach(a=>{e={type:"",values:[]},a.shift(),t=a.map(e=>Object.values(e)).flat(),e.values=t,3===a.length?e.type="C":2===a.length?e.type="Q":1===a.length&&(e.type="L"),l.push(e)}),l}return n}(e,t,i);n.push(...l),c+=l.length}else n.push({type:s,values:t})}else n.push({type:s,values:t});return{pathData:n,count:c}}function j(e,t=0,l=1){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s={x:e[0].values[0],y:e[0].values[1]},r=e.length;for(let p=1;r&&p<r;p++){let r=e[p],{type:u,values:i}=r,y=i.slice(-2);if(y[0],y[1],"C"!==u&&"Q"!==u)a.push(r);else if("C"===u||"Q"===u){let e=q(n,i,t,l).pathData;a.push(...e)}n={x:y[0],y:y[1]},"z"===u.toLowerCase()?n=s:"M"===u&&(s={x:y[0],y:y[1]})}return a}function Z(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),s=Math.max(...l),r=Math.min(...a),p=Math.max(...a),u={x:n,left:n,right:s,y:r,top:r,bottom:p,width:s-n,height:p-r};if(t>-1)for(let e in u)u[e]=+u[e].toFixed(t);return u}function B(e){let t=[];return e.forEach(e=>{let l=function(e){let t=function(e){let t=[];for(let l=0;l<e.length;l++){let a=e[l],n=l>0?e[l-1]:e[l],{type:s,values:r}=a,p={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},u=r.length?{x:r[r.length-2],y:r[r.length-1]}:"",i=r.length?{x:r[0],y:r[1]}:"";switch(s){case"A":if("function"!=typeof arcToBezier){let e=C(p,u)/2,l=L(p,u,.5),a=$(l.x,l.y,e,e,0),n=$(l.x,l.y,e,e,Math.PI);t.push(a,n,u);break}arcToBezier(p,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},s={x:l[4],y:l[5]};t.push(a,n,s)});break;case"C":let e={x:r[2],y:r[3]};t.push(i,e);break;case"Q":t.push(i)}"z"!==s.toLowerCase()&&t.push(u)}return t}(e),l=Z(t);return l}(e);t.push(l)}),t}function N(e,t){let[l,a,n,s,r,p]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[u,i,y,h,o,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=y*h&&n*s>y*h&&l<u&&r>o&&a<i&&p>c&&(x=!0),x}function O(e,t=9){let l=0,a=[],n=T(e),s=n.length>1,r=[];if(s){let e=B(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){N(t,a)&&r.push(l)}}})}return n.forEach((e,t)=>{a=[];let n=0,s=0,p=1,u=[];e.forEach(function(t,l){let[s,r]=[t.type,t.values],p=r.length;if(r.length){let i=(l>0?e[l-1]:e[0]).values,y=i.length,h={x:i[y-2],y:i[y-1]},o={x:r[p-2],y:r[p-1]};if("C"===s||"Q"===s){let e={x:r[0],y:r[1]};u="C"===s?[h,e,{x:r[2],y:r[3]},o]:[h,e,o];let t=Math.abs(function(e,t=!1){let l,[a,n,s,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(n={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},s={x:1*e[2].x/3+2*e[1].x/3,y:1*e[2].y/3+2*e[1].y/3});return l=3*(a.x*(-2*n.y-s.y+3*r.y)+n.x*(2*a.y-s.y-r.y)+s.x*(a.y+n.y-2*r.y)+r.x*(-3*a.y+n.y+2*s.y))/20,t?Math.abs(l):l}(u));n+=t,a.push(h,o)}else if("A"===s){let e=k(h.x,h.y,t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],o.x,o.y),{cx:l,cy:s,rx:r,ry:p,startAngle:u,endAngle:i,deltaAngle:y}=e,c=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let s=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(s/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),s=(a-l+2*Math.PI)%(2*Math.PI),n*(s/(2*Math.PI))}(r,p,u,i));c-=Math.abs(R([h,{x:l,y:s},o])),a.push(h,o),n+=c}else a.push(h,o)}});let i=R(a);-1!==r.indexOf(t)&&(p=-1),s=i<0&&n<0?(Math.abs(n)-Math.abs(i))*p:(Math.abs(n)+Math.abs(i))*p,l+=s}),l}function R(e,t=!1){let l=0;for(let t=0,a=e.length;a&&t<a;t++){l+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}return t&&(l=Math.abs(l)),l}function H(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,s="",r=a?"\n":n?"":" ",p=n?"":" ";s=`${e[0].type}${p}${e[0].values.join(" ")}${r}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:u,values:i}=a;if(!n||"A"!==u&&"a"!==u||(i=[i[0],i[1],i[2],`${i[3]}${i[4]}${i[5]}`,i[6]]),u=n&&l.type===a.type&&"m"!==a.type.toLowerCase()||n&&"M"===l.type&&"L"===a.type?" ":a.type,n){let e="",t=!1;for(let l=0,a=i.length;l<a;l++){let a=i[l],n=a.toString(),s=n.includes(".")&&Math.abs(a)<1;s&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&s||(e+=" "),e+=n,t=s}s+=`${u}${p}${e}${r}`}else s+=`${u}${p}${i.join(" ")}${r}`}return n&&(s=s.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function U(t,l,a=0,n=1,s=!1){const r=(e,t,l,a,n)=>{let s=1-n;return{x:3*s*s*(t.x-e.x)+6*s*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*s*s*(t.y-e.y)+6*s*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let p=[t,l],u=E(t.p0,t.p)>E(l.p0,l.p),i=JSON.parse(JSON.stringify(t)),y=JSON.parse(JSON.stringify(l)),h=A(i.p0,i.cp1,y.p,y.cp2,!1);if(!h)return p;if(u){let e={p0:{x:t.p.x,y:t.p.y},cp1:{x:t.cp2.x,y:t.cp2.y},cp2:{x:t.cp1.x,y:t.cp1.y},p:{x:t.p0.x,y:t.p0.y}};t={p0:{x:l.p.x,y:l.p.y},cp1:{x:l.cp2.x,y:l.cp2.y},cp2:{x:l.cp1.x,y:l.cp1.y},p:{x:l.p0.x,y:l.p0.y}},l=e}let o=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),c=(e,t)=>({x:e.x*t,y:e.y*t}),x=(e,t)=>e.x*t.x+e.y*t.y,f=l.p0,g=r(l.p0,l.cp1,l.cp2,l.p,0),v=x(o(t.p0,f),g)/x(g,g),d=P([l.p0,l.cp1,l.cp2,l.p],v),M=r(l.p0,l.cp1,l.cp2,l.p,v);v-=x(o(d,t.p0),M)/x(M,M);let m=P([l.p0,l.cp1,l.cp2,l.p],v),b=l.p,C=r(l.p0,l.cp1,l.cp2,l.p,v),w=r(l.p0,l.cp1,l.cp2,l.p,1),k=1-v,I=($=m,S=c(C,k/3),{x:$.x+S.x,y:$.y+S.y});var $,S;let F=o(b,c(w,k/3)),z={p0:m,cp1:I,cp2:F,p:b,t0:v};u&&(z={p0:b,cp1:F,cp2:I,p:m,t0:v});let Q=.5*(1-v),T=P([z.p0,z.cp1,z.cp2,z.p],Q,!1,!0),D=T.cpts[2],q=A(T,D,z.p0,h,!1),j=A(T,D,z.p,h,!1),Z=L(z.p0,q,1.333),B=L(z.p,j,1.333);if(A(i.p0,Z,y.p,B,!0))return p;s&&function(e,t,l="red",a="1%",n="1",s="",r=!0,p="",u=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let i=`<circle class="${u}" opacity="${n}" id="${p}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return i;e.insertAdjacentHTML("beforeend",i)}(markers,T,"purple"),z.cp1=Z,z.cp2=B;let N=E(i.p0,z.p0)+E(y.p,z.p);if(z.p0=i.p0,z.p=y.p,z.extreme=y.extreme,z.corner=y.corner,z.dimA=y.dimA,z.directionChange=y.directionChange,z.type="C",z.values=[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y],N<a){let l=u?1+v:Math.abs(v),r=1+Math.abs(v);if(l=u?1+v:Math.abs(v)/r,E(P([z.p0,z.cp1,z.cp2,z.p],l),t.p)>a*n)return p;let h=O([{type:"M",values:[i.p0.x,i.p0.y]},{type:"C",values:[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y]},{type:"C",values:[y.cp1.x,y.cp1.y,y.cp2.x,y.cp2.y,y.p.x,y.p.y]}]),o=[{type:"M",values:[z.p0.x,z.p0.y]},{type:"C",values:[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y]}],c=O(o),x=Math.abs(c/h-1);if(z.error=5*x*n,s){let t=H(o);e(markers,t,"orange")}x<.05*n&&(p=[z])}return p}function V(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1}={}){let r=[e[0]],p=e.length;for(let n=2;p&&n<=p;n++){let u=e[n-1],i=n<p?e[n]:null,y=i?.type||null,h=u?.directionChange||null,o=i?.directionChange||null,{type:c,values:x,p0:f,p:g,cp1:v=null,cp2:d=null,extreme:M=!1,corner:m=!1,dimA:b=0}=u;if("C"===c&&"C"===y)if(l&&o||a&&m||!h&&t&&M)r.push(u);else{let y=J(u,i,{tolerance:s}),h=0;if(1===y.length){u=y[0];let i=1;h+=u.error;for(let r=n+1;h<s&&r<p;r++){let n=e[r];if("C"!==n.type||l&&n.directionChange||a&&u.corner||t&&u.extreme)break;let p=J(u,n,{tolerance:s});1===p.length&&(h+=.5*p[0].error,i++),u=p[0]}r.push(u),n<p&&(n+=i)}else r.push(u)}else r.push(u)}return r}function J(e,t,{tolerance:l=1}={}){let a=[e,t],n=function(e,t){let l=C(e.cp2,e.p),a=C(e.cp2,t.cp1),n=Math.min(l)/a;return n}(e,t),s=E(e.p0,e.p),r=E(t.p0,t.p),p=.06*Math.max(0,Math.min(s,r))*l,u=function(e,t,l=0){let{p0:a,cp1:n}=e,{p:s,cp2:r}=t;return n={x:(n.x-(1-l)*a.x)/l,y:(n.y-(1-l)*a.y)/l},r={x:(r.x-l*s.x)/(1-l),y:(r.y-l*s.y)/(1-l)},{p0:a,cp1:n,cp2:r,p:s}}(e,t,n),i=P([u.p0,u.cp1,u.cp2,u.p],n),y=E(e.p,i),h=0,o=0,c=!1,x=y;if(y<p){let l=.5*(1+n);if(h=E(P([t.p0,t.cp1,t.cp2,t.p],.5),P([u.p0,u.cp1,u.cp2,u.p],l)),x+=h,h<p){let t=.5*n;o=E(P([e.p0,e.cp1,e.cp2,e.p],.5),P([u.p0,u.cp1,u.cp2,u.p],t)),h+o<p&&(c=!0),x+=o}}return c&&(u.p0=e.p0,u.p=t.p,u.dimA=E(u.p0,u.p),u.type="C",u.extreme=t.extreme,u.directionChange=t.directionChange,u.corner=t.corner,u.values=[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y],u.error=x/p,a=[u]),a}function W(e,{tolerance:t=1,debug:l=!1}={}){let a=!1,n={flat:!0,steepness:0},s=e[0],r=e[e.length-1],p=new Set([...e.map(e=>+e.x.toFixed(8))]),u=new Set([...e.map(e=>+e.y.toFixed(8))]);if(1===p.size||1===u.size)return!l||n;let i=w(s,r),y=i/1e3*t,h=R(e,!0);return h<y&&(a=!0),l&&(n.flat=a,n.steepness=h/i*10),l?n:a}function X(e=[]){let t,l=[],a=function(e){let t=[],l={x:e[0].values[0],y:e[0].values[1]};return e.forEach(e=>{let{type:a,values:n}=e;if(n.length){let e=n.length>1?{x:n[n.length-2],y:n[n.length-1]}:"V"===a?{x:l.x,y:n[0]}:{x:n[0],y:l.y};t.push(e),l=e}}),t}(e),n=Z(a),{left:s,right:r,top:p,bottom:u,width:i,height:y}=n,h=e[0].values[0],o=e[0].values[1],c={x:e[0].values[0],y:e[0].values[1]},x={x:e[0].values[0],y:e[0].values[1]};e[0].idx=0,e[0].p0=c,e[0].p=c,e[0].lineto=!1,e[0].corner=!1,e[0].extreme=!1,e[0].directionChange=!1,e[0].closePath=!1,e[0].dimA=0;let f=[e[0]],g=0,v=e.length;for(let l=2;v&&l<=v;l++){let a=e[l-1],{type:n,values:i}=a,y=i.slice(-2),v=[x];a.idx=l-1,a.lineto=!1,a.corner=!1,a.extreme=!1,a.directionChange=!1,a.closePath=!1,a.dimA=0;let d,M,b,A,C,L,P=.05;t=y.length?{x:y[0],y:y[1]}:c,"M"===n?(c=t,x=t):"z"===n.toLowerCase()&&(t=c),a.p0=x,a.p=t;let k=E(x,t);a.dimA=k,"L"===n&&(a.lineto=!0),"Z"===n&&(a.closePath=!0,c.x!==h&&c.y!==o&&(a.lineto=!0)),"Q"!==n&&"C"!==n||(d={x:i[0],y:i[1]},M="C"===n?{x:i[2],y:i[3]}:null,a.cp1=d,M&&(a.cp2=M)),i.length>2&&("Q"!==n&&"C"!==n||v.push(d),"C"===n&&v.push(M),v.push(t)),"L"===n||t.x!==s&&t.y!==p&&t.x!==r&&t.y!==u||(a.extreme=!0);let I=e[l]?e[l]:null,$=I?I.values.slice(-2):null;C=I?I.type:null,!I||"Q"!==I.type&&"C"!==I.type||(A=I?{x:$[0],y:$[1]}:null,b={x:I.values[0],y:I.values[1]},"C"===I.type&&(I.values[2],I.values[3])),L=R(v);let S=g<0&&L>0||g>0&&L<0;if(g=L,S&&(a.directionChange=!0),("Q"===n||"C"===n)&&("Q"===n&&"Q"===C||"C"===n&&"C"===C)){let e=v.slice(1);if(A&&Math.abs(A.x-x.x),A&&Math.abs(A.y-x.y),!!a.extreme||F(0,e,P))a.extreme=!0;else{let e=M?[M,t]:[d,t],l=[t,b],n=m(...e,!0),s=m(...l,!0),r=180*Math.abs(n-s)/Math.PI,p=w(...e),u=w(...l);r>10&&p&&u&&(a.corner=!0)}}f.push(a),x=t}return l={pathData:f,bb:n,dimA:(i+y)/2},l}function Y(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=[];for(let s=0,r=e.length;s<r;s++){let r=e[s],{type:p,values:u}=r,i=u.length?u.slice(-2):[t.x,t.y];a={x:i[0],y:i[1]};let y=r.dimA?+r.dimA.toFixed(8):"M"!==p?+E(l,a).toFixed(8):0;y&&n.push(y),"M"===p&&(t=a),l=a}let s=n.sort(),r=Math.ceil(s.length/10);s=s.slice(0,r);let p=s.reduce((e,t)=>e+t,0)/r,u=p>60?0:Math.floor(40/p).toString().length;return Math.min(Math.max(0,u),8)}function G(e,t=-1){let l=e.length;for(let a=0;a<l;a++){let l=e[a].values,n=l.length;if(n&&t>-1)for(let s=0;s<n;s++)e[a].values[s]=+l[s].toFixed(t)}return e}function K(e={},t={},l={},a={}){let n=L(e,t,1.5),s=L(a,l,1.5),r=.03*E(e,a),p=E(n,s),u=null,i={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return p&&r&&p<r&&(u=A(e,t,a,l,!1),u&&(i.type="Q",i.values=[u.x,u.y,a.x,a.y],i.p0=e,i.cp1=u,i.cp2=null,i.p=a)),i}function _(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!1){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?te(e):e;let n=e.length,s=new Array(n),r={type:"M",values:e[0].values};s[0]=r;let p,u={x:e[0].values[0],y:e[0].values[1]},i=.01;for(let l=1;l<n;l++){let a=e[l],{type:n,values:y}=a,h=y.length,o=[y[h-2],y[h-1]],c=e[l-1],x=c.type;p={x:o[0],y:o[1]};let f,g,v,d,M={x:y[0],y:y[1]},m=Math.abs(p.x-u.x),b=Math.abs(p.y-u.y),A=(m+b)/2*i;switch(n){case"L":r=0===b||b<A&&m>A?{type:"H",values:[y[0]]}:0===m||b>A&&m<A?{type:"V",values:[y[1]]}:a;break;case"Q":if("Q"!==x){u={x:o[0],y:o[1]},s[l]=a;continue}let e={x:c.values[0],y:c.values[1]};d={x:2*u.x-e.x,y:2*u.y-e.y},f=Math.abs(M.x-d.x),g=Math.abs(M.y-d.y),v=(f+g)/2,r=v<A?{type:"T",values:[p.x,p.y]}:a;break;case"C":let t={x:y[2],y:y[3]};if("C"!==x){s[l]=a,u={x:o[0],y:o[1]};continue}let i={x:c.values[2],y:c.values[3]};d={x:2*u.x-i.x,y:2*u.y-i.y},f=Math.abs(M.x-d.x),g=Math.abs(M.y-d.y),v=(f+g)/2,r=v<A?{type:"S",values:[t.x,t.y,p.x,p.y]}:a;break;default:r={type:n,values:y}}(a.decimals||0===a.decimals)&&(r.decimals=a.decimals),t>-1&&(r.values=r.values.map(e=>+e.toFixed(t))),u={x:o[0],y:o[1]},s[l]=r}return s}(e)),a>-1&&l&&(e=G(e,a)),l&&(e=function(e,t=-1){return te(e,!0,t)}(e)),a>-1&&(e=G(e,a)),e}function ee(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let l={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},a={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[l.x,l.y,a.x,a.y,t[2],t[3]]}}function te(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e[0].values,n=a[0],s=a[1],r=n,p=s;for(let a=1,u=e.length;a<u;a++){let u=e[a],{type:i,values:y}=u,h=t?i.toLowerCase():i.toUpperCase();if(i!==h)switch(i=h,u.type=i,i){case"a":case"A":y[5]=t?y[5]-n:y[5]+n,y[6]=t?y[6]-s:y[6]+s;break;case"v":case"V":y[0]=t?y[0]-s:y[0]+s;break;case"h":case"H":y[0]=t?y[0]-n:y[0]+n;break;case"m":case"M":t?(y[0]-=n,y[1]-=s):(y[0]+=n,y[1]+=s),r=t?y[0]+n:y[0],p=t?y[1]+s:y[1];break;default:if(y.length)for(let e=0;e<y.length;e++)y[e]=t?y[e]-(e%2?s:n):y[e]+(e%2?s:n)}let o=y.length;switch(i){case"z":case"Z":n=r,s=p;break;case"h":case"H":n=t?n+y[0]:y[0];break;case"v":case"V":s=t?s+y[0]:y[0];break;case"m":case"M":r=y[o-2]+(t?n:0),p=y[o-1]+(t?s:0);default:n=y[o-2]+(t?n:0),s=y[o-1]+(t?s:0)}l>=0&&(u.values=u.values.map(e=>+e.toFixed(l)))}return e}function le(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}e=l&&a?function(e,t=-1){return te(e,!1,t)}(e,t):e;let n=[],s={type:"M",values:e[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,p,u,i,y,h,o,c=e[l],{type:x,values:f}=c,g=f.length,v=s.values,d=v.length,[M,m]=[f[g-2],f[g-1]],[b,A]=[v[d-2],v[d-1]];switch(x){case"H":s={type:"L",values:[f[0],A]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],p=b+(b-a),u=A+(A-r),s={type:"Q",values:[p,u,M,m]};break;case"S":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],[h,o]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,A],p=2*b-h,u=2*A-o,i=f[0],y=f[1],s={type:"C",values:[p,u,i,y,M,m]};break;default:s={type:x,values:f}}t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),n.push(s)}return n}function ae({p0:e={x:0,y:0},p:t={x:0,y:0},centroid:l={x:0,y:0},rx:a=0,ry:n=0,xAxisRotation:s=0,radToDegree:r=!1,startAngle:p=null,endAngle:u=null,deltaAngle:i=null}={}){if(!a||!n)return[];let y=[];const h=1.5707963267948966;let o=r?s:s*Math.PI/180,c=Math.cos(o),x=Math.sin(o);null!==p&&null!==u&&null!==i||({startAngle:p,endAngle:u,deltaAngle:i}=b(l,e,t));let f=a!==n?S(p,a,n):p,g=a!==n?S(i,a,n):i,v=Math.max(1,Math.ceil(Math.abs(g)/h)),d=g/v;for(let e=0;e<v;e++){const e=Math.abs(d)===h?.551785*Math.sign(d):4/3*Math.tan(d/4);let t=Math.cos(f),s=Math.sin(f),r=Math.cos(f+d),p=Math.sin(f+d),u=[];[{x:t-s*e,y:s+t*e},{x:r+p*e,y:p-r*e},{x:r,y:p}].forEach(e=>{let t=e.x*a,s=e.y*n;u.push(c*t-x*s+l.x,x*t+c*s+l.y)}),y.push({type:"C",values:u,cp1:{x:u[0],y:u[1]},cp2:{x:u[2],y:u[3]},p:{x:u[4],y:u[5]}}),f+=d}return y}function ne(e,t,l=1){const a=2*Math.PI;let[n,s,r,p,u,i,y]=t;if(0===n||0===s)return[];let h=r?r*a/360:0,o=h?Math.sin(h):0,c=h?Math.cos(h):1,x=c*(e.x-i)/2+o*(e.y-y)/2,f=-o*(e.x-i)/2+c*(e.y-y)/2;if(0===x&&0===f)return[];n=Math.abs(n),s=Math.abs(s);let g=x*x/(n*n)+f*f/(s*s);if(g>1){let e=Math.sqrt(g);n*=e,s*=e}let v=n*n,d=n===s?v:s*s,M=x*x,m=f*f,b=v*d-v*m-d*M;b<=0?b=0:(b/=v*m+d*M,b=Math.sqrt(b)*(p===u?-1:1));let A=b?b*n/s*f:0,C=b?b*-s/n*x:0,w=c*A-o*C+(e.x+i)/2,L=o*A+c*C+(e.y+y)/2,P=(x-A)/n,k=(f-C)/s,I=(-x-A)/n,$=(-f-C)/s;const S=(e,t,l,a)=>{let n=+(e*l+t*a).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*a-t*l<0?-1:1)*Math.acos(n))};let F=S(1,0,P,k),z=S(P,k,I,$);0===u&&z>0?z-=2*Math.PI:1===u&&z<0&&(z+=2*Math.PI);let Q=(+(Math.abs(z)/(a/4)).toFixed(0)||1)*l;z/=Q;let E=[];const T=1.5707963267948966,D=.551785;let q=z===T?D:z===-T?-D:4/3*Math.tan(z/4),j=z?Math.cos(z):1,Z=z?Math.sin(z):0;const B=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,p=Math.cos(e+t),u=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:p+u*l,y:u-p*l},{x:p,y:u}]};for(let e=0;e<Q;e++){let e={type:"C",values:[]};B(F,z,q,j,Z).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-o*a+w,o*l+c*a+L)}),E.push(e),F+=z}return E}function se(e,t,l,a,n=7.5){let s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},r=0,p=!1,u=m(e,t,!0),i=m(a,l,!0),y=180*Math.abs(u-i)/Math.PI;if(Math.abs(y%180-90)<3){let u=A(e,t,a,l,!1);if(u){let i=C(e,u),y=C(a,u),h=+Math.max(i,y).toFixed(8),o=+Math.min(i,y).toFixed(8),c=o,x=h,f=R([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/c*Math.abs(c-x)<5&&(c=h,x=c),g&&(c=h,x=o);let v=O([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),d={type:"A",values:[c,x,0,0,f,a.x,a.y]};r=Math.PI*(c*x)/4,r-=Math.abs(R([e,a,u])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<n&&(p=!0,s=d)}}return{com:s,isArc:p,area:r}}function re(e){let t,l=[[]],a=0,n=[[]],s={x:e[0].values[0],y:e[0].values[1]};for(let r=0,p=e.length;r<p;r++){let p=e[r],{type:u,values:i}=p;if("A"===u){let u=e[r-1].values.slice(-2);s={x:u[0],y:u[1]};let[y,h,o,c,x,f,g]=i,v=100/y*Math.abs(y-h)<5;t={x:i[5],y:i[6]},p.p0=s,p.p=t,p.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(p),n[a].push(r)),d&&"A"===d.type){let[e,p,u,i,o,c,x]=d.values,f=y!=e?100/y*Math.abs(y-e):0,g=h!=p?100/h*Math.abs(h-p):0;t={x:d.values[5],y:d.values[6]},d.p0=s,d.p=t,f<5&&g<5?(l[a].push(d),n[a].push(r+1)):(l.push([]),n.push([]),a++)}else l.push([]),n.push([]),a++}}if(!n.length)return e;l=l.filter(e=>e.length),n=n.filter(e=>e.length);for(let t=l.length-1;t>=0;t--){const a=l[t],s=n[t][0],r=a.length;let p=0,u=0;a.forEach(({values:e})=>{const[t,l]=e;p+=t,u+=l}),p/=r,u/=r;let i=100/p*Math.abs(p-u)<5;i&&(p=(p+u)/2,u=p);let y=e[s-1].values.slice(-2);if(y[0],y[1],4===r){let[t,l,n,y,h,o,c]=a[1].values,[,,,,,x,f]=a[3].values;i&&(p=1,u=1);let g={type:"A",values:[p,u,n,y,h,o,c]},v={type:"A",values:[p,u,n,y,h,x,f]};e.splice(s,r,g,v)}else if(3===r){let[t,l,n,i,y,h,o]=a[0].values,[c,x,,,,f,g]=a[2].values;i=1;let v={type:"A",values:[p,u,n,i,y,f,g]};e.splice(s,r,v)}else if(2===r){let[t,l,n,y,h,o,c]=a[0].values,[x,f,,,,g,v]=a[1].values;i&&(p=1,u=1,n=0);let{p0:d,p:M}=a[0],[m,b]=[a[1].p0,a[1].p];if(d.x!==b.x||d.y!==b.y){let t={type:"A",values:[p,u,n,y,h,g,v]};e.splice(s,r,t)}}}return e}function pe(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2,hasRelatives:r=!0,hasShorthands:p=!0,hasQuadratics:u=!0,hasArcs:i=!0,testTypes:y=!1}={}){if(y){let t=Array.from(new Set(e.map(e=>e.type))).join("");r=/[lcqamts]/gi.test(t),u=/[qt]/gi.test(t),i=/[a]/gi.test(t),p=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(u&&a||i&&n)&&(l=!0,t=!0),r&&t&&(e=te(e,!1)),p&&l&&(e=le(e,-1,!1)),i&&n&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],s=e[a-1].values,r=s.length,p={x:s[r-2],y:s[r-1]};"A"===n.type?ne(p,n.values,t).forEach(e=>{l.push(e)}):l.push(n)}return l}(e,s)),u&&a&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,s=n.length,r={x:n[s-2],y:n[s-1]};"Q"===a.type?t.push(ee(r,a.values)):t.push(a)}return t}(e)),e}function ue(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=Array.isArray(e),p=r&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,u=r?e:function(e,t=!0){if(e=e.trim(),""===e)return{pathData:[],hasRelatives:!1,hasShorthands:!1,hasQuadratics:!1,hasArcs:!1};const l=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),a=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&l.has(e);let n,s=0,r=e.length,p="",u=[],i=-1,y="",h=!1,o=0,c=0,x=0,f=!1,g=new Set([]),v=[];const d=()=>{f&&("M"===p?p="L":"m"===p&&(p="l"),u.push({type:p,values:[]}),i++,c=0,f=!1)},M=(e=!1)=>{(e?o>0:""!==y)&&(t&&-1===i&&(n="Pathdata must start with M command",v.push(n),p="M",u.push({type:p,values:[]}),x=2,c=0,i++),"A"===p||"a"===p?(y=m(),u[i].values.push(...y)):(t&&y[1]&&"."!==y[1]&&"0"===y[0]&&(n=`${i}. command: Leading zeros not valid: ${y}`,v.push(n)),u[i].values.push(+y)),c++,y="",o=0,f=c>=x)},m=()=>{let e=y.length,t=!1;return 3===c&&2===e||4===c&&e>1?(y=[+y[0],+y[1]],t=!0,c++):3===c&&e>=3&&(y=[+y[0],+y[1],+y.substring(2)],t=!0,c+=2),t?y:[+y]},b=()=>{if(i>0){let e=u[i].values.length;if(e&&e<x||e&&e>x||("z"===p||"Z"===p)&&e>0){n=`${i}. command of type "${p}": ${x-e} values too few - ${x} expected`,v[v.length-1]!==n&&v.push(n)}}};let A=!1,C=!1,w=!1;for(;s<r;){let l=e.charCodeAt(s),r=l>47&&l<58;if(r||(A=101===l||69===l,C=45===l||43===l,w=46===l),r||C||w||A){if(h||45!==l&&46!==l)d();else{let e=46===l;M(e),d(),e&&o++}y+=e[s],h=A,s++}else if((l<48||l>5759)&&a(l))M(),s++;else{if(l>64){if(!ie.has(l)){n=`${i}. command "${e[s]}" is not a valid type`,v.push(n),s++;continue}""!==y&&(u[i].values.push(+y),c++,y=""),t&&b(),p=e[s],x=ye[l];let a="M"===p||"m"===p,r=i>0&&("z"===u[i].type||"Z"===u[i].type);g.add(p),r&&!a&&(u.push({type:"m",values:[0,0]}),i++),u.push({type:p,values:[]}),i++,o=0,c=0,f=!1,s++;continue}r||(n=`${i}. ${e[s]} is not a valid separarator or token`,v.push(n),y=""),s++}}M(),t&&b();t&&v.length&&(n="Invalid path data:\n"+v.join("\n"),"log"===t?console.log(n):console.warn(n));u[0].type="M";let L=Array.from(g).join(""),P=/[lcqamts]/g.test(L),k=/[vhst]/gi.test(L),I=/[a]/gi.test(L),$=/[qt]/gi.test(L);return{pathData:u,hasRelatives:P,hasShorthands:k,hasQuadratics:$,hasArcs:I}}(e),{hasRelatives:i=!0,hasShorthands:y=!0,hasQuadratics:h=!0,hasArcs:o=!0}=u,c=p?u:u.pathData;return c=pe(c,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s,hasRelatives:i,hasShorthands:y,hasQuadratics:h,hasArcs:o}),c}const ie=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),ye=new Uint8Array(128);function he(e){if("path"===e.nodeName.toLowerCase())return e;let t=function(e,t=!1){let l,a,n,s,r,p,u,i,y,h,o,c,x,f,g,v,d=[],M=e.nodeName;const m=(e,t=9)=>{const l="svg"!==e.nodeName?e.closest("svg"):e,a=e=>{if(null===e)return 0;let l=96,a=e.match(/([a-z]+)/gi);a=a?a[0]:"";let n,s=parseFloat(e);if(!a)return s;switch(a){case"in":n=l;break;case"pt":n=1/72*96;break;case"cm":n=1/2.54*96;break;case"mm":n=1/2.54*96/10;break;case"em":case"rem":n=16;break;default:n=1}return+(s*n).toFixed(t)};let n=l.getAttribute("width");n=n?a(n):300;let s=l.getAttribute("height");s=n?a(s):150;let r=l.getAttribute("viewBox");r=r?r.replace(/,/g," ").split(" ").filter(Boolean).map(e=>+e):[];let p=r.length?r[2]:n,u=r.length?r[3]:s,i=p/100,y=u/100,h=Math.sqrt((Math.pow(i,2)+Math.pow(y,2))/2),o=["x","width","x1","x2","rx","cx","r"],c=["y","height","y1","y2","ry","cy"];e.getAttributeNames().forEach(t=>{let l=e.getAttribute(t),n=l;if(o.includes(t)||c.includes(t)){let s=o.includes(t)?i:y;s="r"===t&&p!=u?h:s;let r=l.match(/([a-z|%]+)/gi);r=r?r[0]:"",n=l.includes("%")?parseFloat(l)*s:a(l),e.setAttribute(t,+n)}})};m(e);const b=t=>(l={},t.forEach(t=>{l[t]=+e.getAttribute(t)}),l);switch(M){case"path":n=e.getAttribute("d"),d=ue(n);break;case"rect":a=["x","y","width","height","rx","ry"],({x:s,y:r,width:p,height:u,rx:y,ry:h}=b(a)),y||h?(y>p/2&&(y=p/2),h>u/2&&(h=u/2),d=[{type:"M",values:[s+y,r]},{type:"L",values:[s+p-y,r]},{type:"A",values:[y,h,0,0,1,s+p,r+h]},{type:"L",values:[s+p,r+u-h]},{type:"A",values:[y,h,0,0,1,s+p-y,r+u]},{type:"L",values:[s+y,r+u]},{type:"A",values:[y,h,0,0,1,s,r+u-h]},{type:"L",values:[s,r+h]},{type:"A",values:[y,h,0,0,1,s+y,r]},{type:"Z",values:[]}]):d=[{type:"M",values:[s,r]},{type:"L",values:[s+p,r]},{type:"L",values:[s+p,r+u]},{type:"L",values:[s,r+u]},{type:"Z",values:[]}];break;case"circle":case"ellipse":a=["cx","cy","rx","ry","r"],({cx:o,cy:c,r:i,rx:y,ry:h}=b(a));let t="circle"===M;t?(y=i,h=i):(y=y||i,h=h||i);let l=t&&i>=1?1:y,m=t&&i>=1?1:y;d=[{type:"M",values:[o+y,c]},{type:"A",values:[l,m,0,1,1,o-y,c]},{type:"A",values:[l,m,0,1,1,o+y,c]}];break;case"line":a=["x1","y1","x2","y2"],({x1:x,y1:g,x2:f,y2:v}=b(a)),d=[{type:"M",values:[x,g]},{type:"L",values:[f,v]}];break;case"polygon":case"polyline":let A=e.getAttribute("points").replaceAll(","," ").split(" ").filter(Boolean);for(let e=0;e<A.length;e+=2)d.push({type:0===e?"M":"L",values:[+A[e],+A[e+1]]});"polygon"===M&&d.push({type:"Z",values:[]})}return t?function(e){return e.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ")}(d):d}(e),l=t.map(e=>`${e.type} ${e.values} `).join(" "),a=[...e.attributes].map(e=>e.name),n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",l);let s=["x","y","cx","cy","dx","dy","r","rx","ry","width","height","points"];return a.forEach(t=>{if(!s.includes(t)){let l=e.getAttribute(t);n.setAttribute(t,l)}}),n}function oe(e,{tolerance:t=1,flatBezierToLinetos:l=!0}={}){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s=n,r=n;e[e.length-1].type.toLowerCase();for(let p=1,u=e.length;p<u;p++){let i=e[p],y=e[p+1]||e[u-1],h="z"===y.type.toLowerCase()?n:{x:y.values[y.values.length-2],y:y.values[y.values.length-1]},{type:o,values:c}=i,x=c.slice(-2);r="Z"!==o?{x:x[0],y:x[1]}:n;let f=h?R([s,r,h],!0):1/0,g=w(s,h),v=f<(g?g/333*t:0),d=!1;if(l||"C"!==o||(v=!1),l&&("C"===o||"Q"===o)){d=W([s,..."C"===o?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===o?[{x:c[0],y:c[1]}]:[],r],{tolerance:t}),d&&p<u-1&&(o="L",i.type="L",i.values=x)}v&&p<u-1&&"A"!==y.type&&("L"===o||l&&d)||(s=r,"M"===o?(n=r,s=n):"Z"===o&&(s=n),a.push(i))}return a}function ce(e){let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l];if(!a)continue;let{type:n=null,values:s=[]}=a,r=e[l+1]?e[l+1]:null;"M"!==n&&"m"!==n||r&&(!r||"Z"!==r.type&&"z"!==r.type)?t.push(a):r&&l++}return t}function xe(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,s=e.length;n<s;n++){let s=e[n],r=e[n-1],p=e[n+1]||null,{type:u,values:i}=s,y="m"===r.type.toLowerCase()&&!p,h=i.length;if(l={x:i[h-2],y:i[h-1]},y||"L"!==u||l.x!==t.x||l.y!==t.y){if(!y&&("l"===u||"v"===u||"h"===u)){if("l"===u?"00"===i.join(""):0===i[0])continue}a.push(s),t=l}}return a}function fe(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let l=0,a=[];for(let l=0;l<t;l++){let t=e[l],{type:n,values:s}=t,r=s.length;if(r){let e={type:n,x:s[r-2],y:s[r-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(3)-+t.y.toFixed(3)),l=a[0].index,l?ve(e,l):e}function ge(e,{removeFinalLineto:t=!0,autoClose:l=!0}={}){let a=[],n=e.length,s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},r="z"===e[n-1].type.toLowerCase(),p=e.filter(e=>"L"===e.type),u=e[r?n-2:n-1],i=u.type,y=u.values.slice(-2).map(e=>+e.toFixed(8)),h=y[0]===s.x&&y[1]===s.y;!r&&l&&h&&(e.push({type:"Z",values:[]}),r=!0,n++);let o="L"!==e[1].type&&(!h||"L"===u.type);if(o=!1,!r)return e;let c=0;{let t=[];for(let l=0;l<n;l++){let a=e[l],{type:n,values:s}=a;if(s.length){let a=s.slice(-2),r=e[l-1]&&"L"===e[l-1].type,p=e[l+1]&&"L"===e[l+1].type,u=e[l-1]?e[l-1].type.toUpperCase():null,i=e[l+1]?e[l+1].type.toUpperCase():null,y={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:r,nextL:p,prevCom:u,nextCom:i};y.index=l,t.push(y)}}if(p.length){let e=t.filter(e=>"L"!==e.type&&"M"!==e.type&&e.prevCom&&"L"===e.prevCom||"M"===e.prevCom&&"L"===i).sort((e,t)=>e.y-t.y||e.x-t.x)[0];c=e?e.index-1:0}else t=t.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),c=t[0].index;e=c?ve(e,c):e}return s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,u=e[n-2],i=u.type,y=u.values.slice(-2).map(e=>+e.toFixed(8)),h="L"===i&&y[0]===s.x&&y[1]===s.y,t&&h&&e.splice(n-2,1),a.push(...e),a}function ve(e,t){let l=0,a="z"===e[e.length-1].type.toLowerCase();if(!a||t<1||e.length<3)return e;let n=a?1:0;!function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[n,s]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),r=l?e[t-2]:e[t-1],p=r.values.length,[u,i]=[r.values[p-2],r.values[p-1]].map(e=>+e.toFixed(8));!l||n==u&&s==i||(e.pop(),e.push({type:"L",values:[n,s]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let s,r,p=e.slice(l),u=e.slice(0,l);return u.shift(),s=u[u.length-1].values||[],r=[s[s.length-2],s[s.length-1]],n&&(p.pop(),u.push({type:"Z",values:[]})),e=[{type:"M",values:r},...p,...u]}function de(e,{threshold:t=null,tolerance:l=1}={}){if(!t){let l=function(e){let t=1/0,l=-1/0,a=1/0,n=-1/0;const s=e=>{e.x<t&&(t=e.x),e.x>l&&(l=e.x),e.y<a&&(a=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let l=e[t],{type:a,values:n}=l,r=n.length,p=(e[t-1]?e[t-1]:e[t]).values,u=p.length;if(r){let e={x:p[u-2],y:p[u-1]},t={x:n[r-2],y:n[r-1]};if(s(t),"C"===a||"Q"===a){let l={x:n[0],y:n[1]},r="C"===a?{x:n[2],y:n[3]}:l,p="C"===a?[e,l,r,t]:[e,l,t];z(p).forEach(e=>{let t=P(p,e);s(t)})}else"A"===a&&Q(e,n).forEach(e=>{s(e)})}}return{x:t,y:a,width:l-t,height:n-a}}(e);t=(l.width+l.height)/2*.05}let a=e.length;for(let n=0;n<a;n++){let a=e[n],{type:s,values:r,extreme:p,corner:u=!1,dimA:i,p0:y,p:h}=a,o=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(o?E(h,o.p):1/0)<t,f=(c?E(c.p,o.p):1/0)<t;if(o&&"C"===s&&"C"===o.type&&p&&c&&c.extreme&&(f||x)){let a=U(o,c,t,l,!1);if(1===a.length){e[n+1]=null,a=a[0],e[n+2].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,a.p.x,a.p.y],e[n+2].cp1=a.cp1,e[n+2].cp2=a.cp2,e[n+2].p0=a.p0,e[n+2].p=a.p,e[n+2].extreme=a.extreme,n++;continue}}if(o&&"C"===s&&"C"===o.type&&p&&x){let t,l=a.cp1.x-o.p0.x,s=a.cp1.y-o.p0.y,r=Math.abs(s)<Math.abs(l),p=o.p,u=1,i=R([a.p0,a.p,o.p]),y=R([a.p0,a.cp1,a.cp2,a.p]);if(i<0&&y>0||i>0&&y<0)continue;if(o.extreme){r?(u=Math.abs(Math.abs(o.cp2.x-o.p.x)/Math.abs(a.cp2.x-a.p.x)),u=Math.min(1,u),t=L(o.p,a.cp2,1+u),a.cp2.x=t.x):(u=Math.abs(Math.abs(o.cp2.y-o.p.y)/Math.abs(a.cp2.y-a.p.y)),u=Math.min(1,u),t=L(o.p,a.cp2,1+u),a.cp2.y=t.y),e[n+1].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,p.x,p.y],e[n+1].cp1=a.cp1,e[n+1].cp2=a.cp2,e[n+1].p0=a.p0,e[n+1].p=p,e[n+1].extreme=!0,e[n]=null;continue}}}a=(e=e.filter(Boolean)).length;let n="z"===e[a-1].type.toLowerCase()?a-2:a-1,s=e[n],r=e[n-1]||null,p={x:e[0].values[0],y:e[0].values[1]},u=s.values.slice(-2),i=+u[0].toFixed(8)===+p.x.toFixed(8)&&+u[1].toFixed(8)===+p.y.toFixed(8),y="C"===e[1].type&&e[1].extreme?e[1]:null,h=E(s.p0,s.p)<t;if(r&&"C"===r.type&&h&&i&&y){let a=U(r,s,t,l,!1);1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function Me(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}function me(e,{threshold:t=0,tolerance:l=1}={}){let a=e.length,n=[e[0]],s="z"===e[a-1].type.toLowerCase(),r=!!s&&(e[a-1].p.x===e[0].p0.x&&e[a-1].p.y===e[0].p0.y),p=s?2:1,u=e[a-p],i="L"===u.type,y="C"===u.type,h="L"===e[1].type,o="C"===e[1].type,c=s&&o&&(i||r);c&&(e[a-1].values=e[0].values,e[a-1].type="L",i=!0);for(let t=1;t<a;t++){let r=e[t],{type:u}=r,x=e[t+1]?e[t+1]:null;if("L"===u&&x&&"C"===x.type||"C"===u&&x&&"L"===x.type){let c="L"===u?r:null,f=null,g=[],v=0;if(1===t&&o&&i&&(g=[e[1]],c=e[a-1],f=x),!c){n.push(r);continue}s&&y&&h&&t===a-p-1&&(f=e[1],g=[e[a-p]]);for(let l=t+1;l<a;l++){let t=e[l]?e[l]:null,a=e[l-1];if("C"===a.type&&g.push(a),"L"===t.type&&"C"===a.type){f=t;break}v++}if(f){let e=E(c.p0,c.p),a=E(f.p0,f.p),s=g.length,p=E(g[0].p0,g[s-1].p),u=R([c.p0,c.p,f.p0,f.p],!1),i=R([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),y=u<0&&i>0||u>0&&i<0,h=.5*p*l,o=h<e&&h<a;if(g.length&&!y&&o){let e=Math.abs(i)<=.005*w(g[0].p0,g[0].p),l=e?null:A(c.p0,c.p,f.p0,f.p,!1);if(!e&&l){if(!(E(P([c.p,l,f.p0],.5),1===g.length?P([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p)>p)){let e={type:"Q",values:[l.x,l.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=l,e.p=f.p0,n.push(c,e),t+=v;continue}n.push(r)}}}}c&&t===a-1&&"L"===u||n.push(r)}return(c||s&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function be(e){if(e.length<3)return!1;let t=e[0],l=e[Math.floor(e.length/2)],a=e[e.length-1],n=t.x,s=t.y,r=l.x,p=l.y,u=a.x,i=a.y,y=n-r,h=s-p,o=n-u,c=s-i,x=(n*n-r*r+(s*s-p*p))/2,f=(n*n-u*u+(s*s-i*i))/2,g=y*c-h*o;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let v={x:(c*x-h*f)/g,y:(-o*x+y*f)/g},d=C(v,t),M=b(v,t,a),{deltaAngle:m,startAngle:A,endAngle:w}=M;return{centroid:v,r:d,startAngle:A,endAngle:w,deltaAngle:m}}function Ae(t,{threshold:l=0,tolerance:a=1,toCubic:n=!1,debug:s=!1}={}){let r=t.length,p=[t[0]],u=[];for(let l=1;l<r;l++){let a=t[l],{type:r}=a,i=t[l-1],y=t[l+1]?t[l+1]:null,h=t[l+2]?t[l+2]:null,o=t[l+3]?t[l+3]:null,c=null;"C"===a.type||"Q"===a.type?c=a:!y||"C"!==y.type&&"Q"!==y.type||(c=y);let x,f,g,v,d,M=c?"C"===c.type?[c.p0,c.cp1,c.cp2,c.p]:[c.p0,c.cp1,c.p]:[],m=0,b=0,A=!1,C=!1,w=[];if("L"===i.type&&"L"===r&&c&&"L"===h.type&&o&&("L"===o.type||"Z"===o.type)?(x=[a.p0,a.p],f=[h.p0,h.p],g=a.p0,v=h.p,m=R(M,!1),b=R([...x,...f],!1),A=m<0&&b>0||m>0&&b<0,A||(d=P(M,.5),w=[g,d,v],C=!0)):"C"!==r&&"Q"!==r||"L"!==i.type||"C"!==y.type&&"Q"!==y.type||"L"!==h.type||(C=!0,x=[i.p0,i.p],f=[h.p0,h.p],g=i.p,v=h.p0,d=c.p,w=[g,c.p,v]),C){let t=be(w);if(t){let r,{centroid:i,r:y,deltaAngle:h,startAngle:o,endAngle:c}=t,x=0,f=h>0?1:0,M=Math.abs(h)>Math.PI?1:0;if(E(I(g,i.x,i.y,.5*h),d)<.05*E(g,v)){if(r=ae({p0:g,p:v,centroid:i,rx:y,ry:y,xAxisRotation:x,sweep:f,largeArc:M,deltaAngle:h,startAngle:o,endAngle:c}),1===r.length){let e=K(g,r[0].cp1,r[0].cp2,v);"Q"===e.type&&(n=!0),a=e}if(r.length>1&&(n=!1),n||(a.type="A",a.values=[y,y,x,M,f,v.x,v.y]),a.p0=g,a.p=v,a.extreme=!1,a.corner=!1,s){u=n?[{type:"M",values:[g.x,g.y]},...r]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[y,y,x,M,f,v.x,v.y]}];let t=H(u);e(markers,t,"orange","0.5%","0.5")}p.push(a),l++;continue}}}p.push(a)}return p}function Ce(e=[],{threshold:t=0}={}){let l=e.length,a="z"===e[l-1].type.toLowerCase(),n=a?l-2:l-1,s=e[n],r=s.values.slice(-2),p={x:e[0].values[0],y:e[0].values[1]},u=E(p,{x:r[0],y:r[1]});if(u&&u<t){let l=e[n].values.length;e[n].values[l-2]=p.x,e[n].values[l-1]=p.y;let a=e[1];if("C"===a.type&&"C"===s.type){let l=Math.abs(a.values[0]-s.values[2]),r=Math.abs(a.values[1]-s.values[3]),u=Math.abs(e[1].values[0]-a.values[0]),i=Math.abs(e[1].values[1]-a.values[1]),y=Math.abs(e[1].values[0]-s.values[2]),h=Math.abs(e[1].values[1]-s.values[3]),o=i<t&&h<t&&l;l&&l<t&&(u<t&&y<t&&r)&&(e[1].values[0]=p.x,e[n].values[2]=p.x),r&&r<t&&o&&(e[1].values[1]=p.y,e[n].values[3]=p.y)}}return e}function we(e="",{getObject:t=!1,toAbsolute:l=!0,toRelative:a=!0,toShorthands:n=!0,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:p=!1,simplifyBezier:u=!0,optimizeOrder:i=!0,autoClose:y=!0,removeZeroLength:h=!0,refineClosing:o=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:v=!1,keepExtremes:d=!0,keepCorners:M=!0,extrapolateDominant:m=!0,keepInflections:b=!1,addExtremes:A=!1,removeOrphanSubpaths:C=!1,simplifyRound:w=!1,decimals:L=3,autoAccuracy:P=!0,minifyD:k=0,tolerance:I=1,reverse:$=!1,mergePaths:S=!1,removeHidden:F=!0,removeUnused:z=!0,shapesToPaths:Q=!0}={}){I=Math.max(.1,I);let E=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"array";if("string"==typeof e){let l=(e=e.trim()).includes("<svg")&&e.includes("</svg"),a=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(n)t="polyString";else{let l=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),a=e.startsWith("data:image");t=l||a?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),D="",q=0,Z=0,B=0,N={},O="",R="svgMarkup"===E?1:0,U=[];if(q=e.length,R){if(D=function(e,{returnDom:t=!1,removeHidden:l=!0,removeUnused:a=!0}={}){e=(e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()).replaceAll("xlink:href=","href=");let n=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)||e.removeAttribute(l)})}(n,["viewBox","xmlns","width","height","id","class","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"]);let s=["metadata","script"];return n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),r=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||s.includes(t)||l&&r?e.remove():function(e){[...e.attributes].map(e=>e.name).forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t?n:Me(n)}(e,{returnDom:!0,removeHidden:F,removeUnused:z}),Q){D.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=he(e);e.replaceWith(t)})}D.querySelectorAll("path").forEach(e=>{U.push({d:e.getAttribute("d"),el:e})})}else{if("pathDataString"===E)O=e;else if("polyString"===E)O="M"+e;else if("pathData"===E){O=e,q=O.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}U.push({d:O,el:null})}let J={toRelative:a,toShorthands:n,decimals:L},W=[];for(let e=0,t=U.length;t&&e<t;e++){let t=U[e],{d:a,el:n}=t,F=ue(a,{quadraticToCubic:s,toAbsolute:l,arcToCubic:r}),z=F.length;C&&(F=ce(F));let Q=T(F),E=Q.length,D=[];for(let e=0;e<E;e++){let t=Q[e];(c||h)&&(t=xe(t)),A&&(t=j(t,0,1)),i&&(t=fe(t)),c&&(t=oe(t,{tolerance:I,flatBezierToLinetos:!1}));let l=X(t),{pathData:a,bb:n,dimA:s}=l;if(o&&(a=Ce(a,{threshold:.001*s})),a=u?V(a,{simplifyBezier:u,keepInflections:b,keepExtremes:d,keepCorners:M,extrapolateDominant:m,revertToQuadratics:f,tolerance:I,reverse:$}):a,g){a=de(a,{threshold:(n.width+n.height)/2*.05,tolerance:I})}if(p){let e=1;for(let t=0,l=a.length;t<l;t++){let l=a[t],{type:n,values:s,p0:r,cp1:p=null,cp2:u=null,p:i=null}=l;if("C"===n){let l=se(r,p,u,i,e);l.isArc&&(a[t]=l.com)}}a=re(a)}if(c&&x&&(a=oe(a,{tolerance:I,flatBezierToLinetos:x})),v){a=me(a,{threshold:(n.width+n.height)/2*.1,tolerance:I})}if(w&&(a=Ae(a)),f)for(let e=0,t=a.length;e<t;e++){let t=a[e],{type:l,values:n,p0:s,cp1:r=null,cp2:p=null,p:u=null}=t;if("C"===l){let l=K(s,r,p,u);"Q"===l.type&&(l.extreme=t.extreme,l.corner=t.corner,l.dimA=t.dimA,a[e]=l)}}i&&(a=ge(a,{autoClose:y})),D.push({pathData:a,bb:n})}if(i&&(D=D.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x)),F=[],D.forEach(e=>{F.push(...e.pathData)}),P&&(L=Y(F),J.decimals=L),n&&S)W.push(...F);else{F=_(F,J),F=xe(F);let e=F.length,l=H(F,k);Z=l.length,B=+(100/q*Z).toFixed(2),t.d=l,t.report={original:z,new:e,saved:z-e,compression:B,decimals:L},n&&n.setAttribute("d",l)}}if(R){if(W.length){let e=_(W,J);e=xe(e);let t=H(e,k);U[0].el.setAttribute("d",t);for(let e=1;e<U.length;e++){let t=U[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(D)}D=Me(D),Z=D.length,B=+(100/q*Z).toFixed(2),q=+(q/1024).toFixed(3),Z=+(Z/1024).toFixed(3),N={svgSize:q,svgSizeOpt:Z,compression:B}}else({d:O,report:N}=U[0]);return t?{svg:D,d:O,report:N,inputType:E,mode:R}:O||D}ye[77]=2,ye[109]=2,ye[65]=7,ye[97]=7,ye[67]=6,ye[99]=6,ye[76]=2,ye[108]=2,ye[81]=4,ye[113]=4,ye[83]=4,ye[115]=4,ye[84]=2,ye[116]=2,ye[72]=1,ye[104]=1,ye[86]=1,ye[118]=1,ye[90]=0,ye[122]=0;const{abs:Le,acos:Pe,asin:ke,atan:Ie,atan2:$e,ceil:Se,cos:Fe,exp:ze,floor:Qe,log:Ee,hypot:Te,max:De,min:qe,pow:je,random:Ze,round:Be,sin:Ne,sqrt:Oe,tan:Re,PI:He}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=we);export{He as PI,Le as abs,Pe as acos,ke as asin,Ie as atan,$e as atan2,Se as ceil,Fe as cos,ze as exp,Qe as floor,Te as hypot,Ee as log,De as max,qe as min,je as pow,Ze as random,Be as round,Ne as sin,Oe as sqrt,we as svgPathSimplify,Re as tan};
|
|
1
|
+
function e(e,t="",l="green",a="1%",n="1",s=!0){let r=`<path d="${t}" fill="none" stroke="${l}" stroke-width="${a}" stroke-opacity="${n}" /> `;if(!s)return r;e.insertAdjacentHTML("beforeend",r)}const{abs:t,acos:l,asin:a,atan:n,atan2:s,ceil:r,cos:p,exp:i,floor:u,log:h,max:y,min:o,pow:c,random:x,round:f,sin:g,sqrt:v,tan:d,PI:M}=Math;function m(e,t,l=!1){let a=s(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function b(e,t,l,a=!1){let n=Math.atan2(t.y-e.y,t.x-e.x),s=Math.atan2(l.y-e.y,l.x-e.x),r=s-n;r=(e=>{let t=e%(2*Math.PI);return t>Math.PI?t-=2*Math.PI:t<=-Math.PI&&(t+=2*Math.PI),t})(r),a&&(r=2*Math.PI-Math.abs(r));let p=180/Math.PI;return{startAngle:n,endAngle:s,deltaAngle:r,startAngleDeg:n*p,endAngleDeg:s*p,deltaAngleDeg:r*p}}function A(e=null,t=null,l=null,a=null,n=!0,s=!1){let r,p,i,u,h,y={};if(!(e&&t&&l&&a))return s&&console.warn("points missing"),!1;try{if(r=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==r)return!1}catch{return s&&console.warn("!catch",e,t,"p3:",l,"p4:",a),!1}p=e.y-l.y,i=e.x-l.x,u=(a.x-l.x)*p-(a.y-l.y)*i,h=(t.x-e.x)*p-(t.y-e.y)*i,p=u/r,i=h/r,y={x:e.x+p*(t.x-e.x),y:e.y+p*(t.y-e.y)};let o=!1;return p>0&&p<1&&i>0&&i<1&&(o=!0),!(n&&!o)&&y}function C(e,t){return v((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function w(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function L(e,t,l,a=!1){let n={x:(t.x-e.x)*l+e.x,y:(t.y-e.y)*l+e.y};return a&&(n.angle=m(e,t),n.angle<0&&(n.angle+=2*M)),n}function k(e,t=.5,l=!1,a=!1){let n;return n=e.length>2?((e,t,l=!1)=>{let n=4===e.length,s=e[0],r=e[1],p=n?e[2]:e[1],i=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,h,y,o,c=s.x===r.x&&s.y===r.y,x=i.x===p.x&&i.y===p.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=L(s,r,t),n?(l=L(r,p,t),h=L(p,i,t),y=L(e,l,t),o=L(l,h,t),u=L(y,o,t),u.angle=m(y,o),a&&(u.cpts=[l,h,y,o])):(l=L(s,r,t),h=L(r,i,t),u=L(l,h,t),u.angle=m(l,h),a&&(u.cpts=[l,h]))):(u.x=i.x,u.y=i.y,u.angle=m(p,i)):(u.x=s.x,u.y=s.y,u.angle=m(s,r))}else{let e=1-t;u=n?{x:e**3*s.x+3*e**2*t*r.x+3*e*t**2*p.x+t**3*i.x,y:e**3*s.y+3*e**2*t*r.y+3*e*t**2*p.y+t**3*i.y}:{x:e*e*s.x+2*e*t*r.x+t**2*i.x,y:e*e*s.y+2*e*t*r.y+t**2*i.y}}return u})(e,t,l):L(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*M),n}function P(e){let t=[],l={x:e[0].values[0],y:e[0].values[1]};return e.forEach(e=>{let{type:a,values:n}=e;if(n.length){let e=n.length>1?{x:n[n.length-2],y:n[n.length-1]}:"V"===a?{x:l.x,y:n[0]}:{x:n[0],y:l.y};t.push(e),l=e}}),t}function F(e,l,a,n,r,i,u,h,y){const o=(e,t,l,a)=>s(a-t,l-e);let c={cx:0,cy:0,rx:a=t(a),ry:n=t(n),startAngle:0,endAngle:0,deltaAngle:0,clockwise:u,xAxisRotation:r,largeArc:i,sweep:u};if(0==a||0==n)throw Error("rx and ry can not be 0");if(a===n){let t=Math.abs(h-e),a=Math.abs(y-l),n=t,s=Math.min(e,h),r=Math.min(l,y),p=.5*Math.PI;if(0===t&&a||0===a&&t)return n=0===t&&a?a/2:t/2,c.rx=n,c.ry=n,0===t&&a?(c.cx=e,c.cy=r+a/2,c.startAngle=l>y?p:-p,c.endAngle=l>y?-p:p,c.deltaAngle=u?Math.PI:-Math.PI):0===a&&t&&(c.cx=s+t/2,c.cy=l,c.startAngle=e>h?Math.PI:0,c.endAngle=e>h?-Math.PI:Math.PI,c.deltaAngle=u?Math.PI:-Math.PI),c}let x,f,d=a===n?0:r*M/180,m=d?g(d):0,b=d?p(d):1,A=(e-h)/2,C=(l-y)/2,w=(e+h)/2,L=(l+y)/2,k=d?b*A+m*C:A,P=d?b*C-m*A:C,F=k*k/(a*a)+P*P/(n*n);F>1&&(a*=v(F),n*=v(F),c.rx=a,c.ry=n);let I=a*n,$=a*P,S=n*k,z=$**2+S**2;if(!z)throw Error("start point can not be same as end point");let Q=v(t((I*I-z)/z));i==u&&(Q=-Q);let E=Q*$/n,T=-Q*S/a;x=d?b*E-m*T+w:w+E,f=d?m*E+b*T+L:L+T,c.cy=f,c.cx=x;let D=o(x,f,e,l),q=o(x,f,h,y);!u&&q>D&&(q-=2*Math.PI),u&&D>q&&(q=q<=0?q+2*Math.PI:q);let B=q-D;return c.startAngle=D,c.endAngle=q,c.deltaAngle=B,c}function I(e,t,l,a=0,n=!1){return a?(a=n?a/180*Math.PI:a,{x:t+(e.x-t)*Math.cos(a)-(e.y-l)*Math.sin(a),y:l+(e.x-t)*Math.sin(a)+(e.y-l)*Math.cos(a)}):e}function $(e,t,l,a,s,r=0,i=!0,u=!1){if(s=u?s*M/180:s,r=u?r*M/180:r,r=l!==a&&r!==2*M?r:0,i&&l!==a){let e=n(d(s=r?s-r:s)*(l/a));s=p(s)<0?e+M:e}let h=e+l*p(s),y=t+a*g(s),o={x:h,y:y};return r&&(o.x=e+(h-e)*p(r)-(y-t)*g(r),o.y=t+(h-e)*g(r)+(y-t)*p(r)),o}function S(e,t,l){if(t===l||e%M*.5==0)return e;let a=n(d(e)*(t/l));return a=p(e)<0?a+M:a,a}function z(e,t=[],l=.05){let a=3===t.length,n=t[0]||null,s=a?t[1]:null,r=a?t[2]:t[1],p=.5*Math.PI,i=!1,u=!1,h=n?m(r,n,!0):null;if(i=Math.abs(h%p)<l||Math.abs(h%p-p)<l,a){let e=s?m(s,r,!0):0;u=Math.abs(e%p)<=l||Math.abs(e%p-p)<=l}return i||u}function Q(e){return 4===e.length?function(e,t,l,a){let[n,s,r,p,i,u,h,y]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],o=Math.min(e.y,a.y),c=Math.min(e.x,a.x),x=Math.max(e.x,a.x),f=Math.max(e.y,a.y);if(t.y>=o&&t.y<=f&&l.y>=o&&l.y<=f&&t.x>=c&&t.x<=x&&l.x>=c&&l.x<=x)return[];let g,v,d,M,m,b,A,C,w=[];for(let e=0;e<2;++e)if(0==e?(v=6*n-12*r+6*i,g=-3*n+9*r-9*i+3*h,d=3*r-3*n):(v=6*s-12*p+6*u,g=-3*s+9*p-9*u+3*y,d=3*p-3*s),Math.abs(g)<1e-12){if(Math.abs(v)<1e-12)continue;M=-d/v,0<M&&M<1&&w.push(M)}else A=v*v-4*d*g,A<0?Math.abs(A)<1e-12&&(M=-v/(2*g),0<M&&M<1&&w.push(M)):(C=Math.sqrt(A),m=(-v+C)/(2*g),0<m&&m<1&&w.push(m),b=(-v-C)/(2*g),0<b&&b<1&&w.push(b));let L=w.length;for(;L--;)M=w[L];return w}(e[0],e[1],e[2],e[3]):function(e,t,l){let a,n,s,r=Math.min(e.y,l.y),p=Math.min(e.x,l.x),i=Math.max(e.x,l.x),u=Math.max(e.y,l.y);if(t.y>=r&&t.y<=u&&t.x>=p&&t.x<=i)return[];let[h,y,o,c,x,f]=[e.x,e.y,t.x,t.y,l.x,l.y],g=[];for(let e=0;e<2;++e)a=0==e?h-2*o+x:y-2*c+f,n=0==e?-2*h+2*o:-2*y+2*c,Math.abs(a)>1e-12&&(s=-n/(2*a),s>0&&s<1&&g.push(s));return g}(e[0],e[1],e[2])}function E(e,t){const l=(e,t,l,a,n,s)=>{var r=Math.cos(s),p=Math.sin(s),i=a*Math.cos(e),u=n*Math.sin(e);return{x:t+r*i-p*u,y:l+p*i+r*u}};let a,n,s,r,p,i=F(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:u,ry:h,cx:y,cy:o,endAngle:c,deltaAngle:x}=i,f=t[2],g={x:t[5],y:t[6]},v=[g],d=f*Math.PI/180,M=Math.tan(d);p=Math.atan2(-h*M,u);let m=p,b=p+Math.PI,A=Math.atan2(h,u*M),C=A+Math.PI,w=[e.x,g.x],L=[e.y,g.y],k=Math.min(...w),P=Math.max(...w),I=Math.min(...L),$=Math.max(...L),S=l(c-.001*x,y,o,u,h,d),z=l(c-.999*x,y,o,u,h,d);return(S.x>P||z.x>P)&&(a=l(m,y,o,u,h,d),v.push(a)),(S.x<k||z.x<k)&&(n=l(b,y,o,u,h,d),v.push(n)),(S.y<I||z.y<I)&&(r=l(C,y,o,u,h,d),v.push(r)),(S.y>$||z.y>$)&&(s=l(A,y,o,u,h,d),v.push(s)),v}function T(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function D(e){let t=[],l=[e[0]],a=e.length;for(let n=1;n<a;n++){let a=e[n];"M"!==a.type&&"m"!==a.type||(t.push(l),l=[]),l.push(a)}return l.length&&t.push(l),t}function q(e,t){let l,a,n,s,r,p,i=[],u=[],h=e[0],y=e[1],o=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=k([h,y],t),a=k([y,o],t),n=k([o,c],t),s=k([l,a],t),r=k([a,n],t),p=k([s,r],t),i.push({x:h.x,y:h.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:p.x,y:p.y}),u.push({x:p.x,y:p.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=k([h,y],t),n=k([y,c],t),p=k([a,n],t),i.push({x:h.x,y:h.y},{x:a.x,y:a.y},{x:p.x,y:p.y}),u.push({x:p.x,y:p.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=k([h,c],t),i.push({x:h.x,y:h.y},{x:a.x,y:a.y}),u.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[i,u]}function B(e,t,l=0,a=1){let n=[],s=6===t.length?"C":"Q",r={x:t[0],y:t[1]},p="C"===s?{x:t[2],y:t[3]}:r,i={x:t[4],y:t[5]},u=Math.max(i.x,e.x),h=Math.min(i.x,e.x),y=Math.max(i.y,e.y),o=Math.min(i.y,e.y),c=0;if(r.x<h||r.x>u||r.y<o||r.y>y||p.x<h||p.x>u||p.y<o||p.y>y){let u=Q("C"===s?[e,r,p,i]:[e,r,i]).sort();if(u=u.filter(e=>e>l&&e<a),u.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let s,r,p,i=t.length,u={x:t[i-2],y:t[i-1]};2===t.length?p=[e,u]:4===t.length?(s={x:t[0],y:t[1]},p=[e,s,u]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},p=[e,s,r,u]);if(l.length)if(1===l.length){let e=q(p,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=q(p,e),a=t[0];n.push(a),p=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=q(p,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),p=a[1]}}if(a){let e,t,l=[];return n.forEach(a=>{e={type:"",values:[]},a.shift(),t=a.map(e=>Object.values(e)).flat(),e.values=t,3===a.length?e.type="C":2===a.length?e.type="Q":1===a.length&&(e.type="L"),l.push(e)}),l}return n}(e,t,u);n.push(...l),c+=l.length}else n.push({type:s,values:t})}else n.push({type:s,values:t});return{pathData:n,count:c}}function j(e,t=0,l=1){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s={x:e[0].values[0],y:e[0].values[1]},r=e.length;for(let p=1;r&&p<r;p++){let r=e[p],{type:i,values:u}=r,h=u.slice(-2);if(h[0],h[1],"C"!==i&&"Q"!==i)a.push(r);else if("C"===i||"Q"===i){let e=B(n,u,t,l).pathData;a.push(...e)}n={x:h[0],y:h[1]},"z"===i.toLowerCase()?n=s:"M"===i&&(s={x:h[0],y:h[1]})}return a}function Z(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),s=Math.max(...l),r=Math.min(...a),p=Math.max(...a),i={x:n,left:n,right:s,y:r,top:r,bottom:p,width:s-n,height:p-r};if(t>-1)for(let e in i)i[e]=+i[e].toFixed(t);return i}function N(e){let t=[];return e.forEach(e=>{let l=function(e){let t=function(e){let t=[];for(let l=0;l<e.length;l++){let a=e[l],n=l>0?e[l-1]:e[l],{type:s,values:r}=a,p={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},i=r.length?{x:r[r.length-2],y:r[r.length-1]}:"",u=r.length?{x:r[0],y:r[1]}:"";switch(s){case"A":if("function"!=typeof arcToBezier){let e=C(p,i)/2,l=L(p,i,.5),a=$(l.x,l.y,e,e,0),n=$(l.x,l.y,e,e,Math.PI);t.push(a,n,i);break}arcToBezier(p,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},s={x:l[4],y:l[5]};t.push(a,n,s)});break;case"C":let e={x:r[2],y:r[3]};t.push(u,e);break;case"Q":t.push(u)}"z"!==s.toLowerCase()&&t.push(i)}return t}(e),l=Z(t);return l}(e);t.push(l)}),t}function O(e,t){let[l,a,n,s,r,p]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[i,u,h,y,o,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=h*y&&n*s>h*y&&l<i&&r>o&&a<u&&p>c&&(x=!0),x}function R(e,t=9){let l=0,a=[],n=D(e),s=n.length>1,r=[];if(s){let e=N(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){O(t,a)&&r.push(l)}}})}return n.forEach((e,t)=>{a=[];let n=0,s=0,p=1,i=[];e.forEach(function(t,l){let[s,r]=[t.type,t.values],p=r.length;if(r.length){let u=(l>0?e[l-1]:e[0]).values,h=u.length,y={x:u[h-2],y:u[h-1]},o={x:r[p-2],y:r[p-1]};if("C"===s||"Q"===s){let e={x:r[0],y:r[1]};i="C"===s?[y,e,{x:r[2],y:r[3]},o]:[y,e,o];let t=Math.abs(function(e,t=!1){let l,[a,n,s,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(n={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},s={x:1*e[2].x/3+2*e[1].x/3,y:1*e[2].y/3+2*e[1].y/3});return l=3*(a.x*(-2*n.y-s.y+3*r.y)+n.x*(2*a.y-s.y-r.y)+s.x*(a.y+n.y-2*r.y)+r.x*(-3*a.y+n.y+2*s.y))/20,t?Math.abs(l):l}(i));n+=t,a.push(y,o)}else if("A"===s){let e=F(y.x,y.y,t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],o.x,o.y),{cx:l,cy:s,rx:r,ry:p,startAngle:i,endAngle:u,deltaAngle:h}=e,c=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let s=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(s/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),s=(a-l+2*Math.PI)%(2*Math.PI),n*(s/(2*Math.PI))}(r,p,i,u));c-=Math.abs(H([y,{x:l,y:s},o])),a.push(y,o),n+=c}else a.push(y,o)}});let u=H(a);-1!==r.indexOf(t)&&(p=-1),s=u<0&&n<0?(Math.abs(n)-Math.abs(u))*p:(Math.abs(n)+Math.abs(u))*p,l+=s}),l}function H(e,t=!1){let l=0;for(let t=0,a=e.length;a&&t<a;t++){l+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}return t&&(l=Math.abs(l)),l}function U(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,s="",r=a?"\n":n?"":" ",p=n?"":" ";s=`${e[0].type}${p}${e[0].values.join(" ")}${r}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:i,values:u}=a;if(!n||"A"!==i&&"a"!==i||(u=[u[0],u[1],u[2],`${u[3]}${u[4]}${u[5]}`,u[6]]),i=n&&l.type===a.type&&"m"!==a.type.toLowerCase()||n&&"M"===l.type&&"L"===a.type?" ":a.type,n){let e="",t=!1;for(let l=0,a=u.length;l<a;l++){let a=u[l],n=a.toString(),s=n.includes(".")&&Math.abs(a)<1;s&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&s||(e+=" "),e+=n,t=s}s+=`${i}${p}${e}${r}`}else s+=`${i}${p}${u.join(" ")}${r}`}return n&&(s=s.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function V(t,l,a=0,n=1,s=!1){const r=(e,t,l,a,n)=>{let s=1-n;return{x:3*s*s*(t.x-e.x)+6*s*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*s*s*(t.y-e.y)+6*s*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let p=[t,l],i=T(t.p0,t.p)>T(l.p0,l.p),u=JSON.parse(JSON.stringify(t)),h=JSON.parse(JSON.stringify(l)),y=A(u.p0,u.cp1,h.p,h.cp2,!1);if(!y)return p;if(i){let e={p0:{x:t.p.x,y:t.p.y},cp1:{x:t.cp2.x,y:t.cp2.y},cp2:{x:t.cp1.x,y:t.cp1.y},p:{x:t.p0.x,y:t.p0.y}};t={p0:{x:l.p.x,y:l.p.y},cp1:{x:l.cp2.x,y:l.cp2.y},cp2:{x:l.cp1.x,y:l.cp1.y},p:{x:l.p0.x,y:l.p0.y}},l=e}let o=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),c=(e,t)=>({x:e.x*t,y:e.y*t}),x=(e,t)=>e.x*t.x+e.y*t.y,f=l.p0,g=r(l.p0,l.cp1,l.cp2,l.p,0),v=x(o(t.p0,f),g)/x(g,g),d=k([l.p0,l.cp1,l.cp2,l.p],v),M=r(l.p0,l.cp1,l.cp2,l.p,v);v-=x(o(d,t.p0),M)/x(M,M);let m=k([l.p0,l.cp1,l.cp2,l.p],v),b=l.p,C=r(l.p0,l.cp1,l.cp2,l.p,v),w=r(l.p0,l.cp1,l.cp2,l.p,1),P=1-v,F=(I=m,$=c(C,P/3),{x:I.x+$.x,y:I.y+$.y});var I,$;let S=o(b,c(w,P/3)),z={p0:m,cp1:F,cp2:S,p:b,t0:v};i&&(z={p0:b,cp1:S,cp2:F,p:m,t0:v});let Q=.5*(1-v),E=k([z.p0,z.cp1,z.cp2,z.p],Q,!1,!0),D=E.cpts[2],q=A(E,D,z.p0,y,!1),B=A(E,D,z.p,y,!1),j=L(z.p0,q,1.333),Z=L(z.p,B,1.333);if(A(u.p0,j,h.p,Z,!0))return p;s&&function(e,t,l="red",a="1%",n="1",s="",r=!0,p="",i=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let u=`<circle class="${i}" opacity="${n}" id="${p}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return u;e.insertAdjacentHTML("beforeend",u)}(markers,E,"purple"),z.cp1=j,z.cp2=Z;let N=T(u.p0,z.p0)+T(h.p,z.p);if(z.p0=u.p0,z.p=h.p,z.extreme=h.extreme,z.corner=h.corner,z.dimA=h.dimA,z.directionChange=h.directionChange,z.type="C",z.values=[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y],N<a){let l=i?1+v:Math.abs(v),r=1+Math.abs(v);if(l=i?1+v:Math.abs(v)/r,T(k([z.p0,z.cp1,z.cp2,z.p],l),t.p)>a*n)return p;let y=R([{type:"M",values:[u.p0.x,u.p0.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]},{type:"C",values:[h.cp1.x,h.cp1.y,h.cp2.x,h.cp2.y,h.p.x,h.p.y]}]),o=[{type:"M",values:[z.p0.x,z.p0.y]},{type:"C",values:[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y]}],c=R(o),x=Math.abs(c/y-1);if(z.error=5*x*n,s){let t=U(o);e(markers,t,"orange")}x<.05*n&&(p=[z])}return p}function W(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1}={}){let r=[e[0]],p=e.length;for(let n=2;p&&n<=p;n++){let i=e[n-1],u=n<p?e[n]:null,h=u?.type||null,y=i?.directionChange||null,o=u?.directionChange||null,{type:c,values:x,p0:f,p:g,cp1:v=null,cp2:d=null,extreme:M=!1,corner:m=!1,dimA:b=0}=i;if("C"===c&&"C"===h)if(l&&o||a&&m||!y&&t&&M)r.push(i);else{let h=J(i,u,{tolerance:s}),y=0;if(1===h.length){i=h[0];let u=1;y+=i.error;for(let r=n+1;y<s&&r<p;r++){let n=e[r];if("C"!==n.type||l&&n.directionChange||a&&i.corner||t&&i.extreme)break;let p=J(i,n,{tolerance:s});1===p.length&&(y+=.5*p[0].error,u++),i=p[0]}r.push(i),n<p&&(n+=u)}else r.push(i)}else r.push(i)}return r}function J(e,t,{tolerance:l=1}={}){let a=[e,t],n=function(e,t){let l=C(e.cp2,e.p),a=C(e.cp2,t.cp1),n=Math.min(l)/a;return n}(e,t),s=T(e.p0,e.p),r=T(t.p0,t.p),p=.08*Math.max(0,Math.min(s,r))*l,i=function(e,t,l=0){let{p0:a,cp1:n}=e,{p:s,cp2:r}=t;return n={x:(n.x-(1-l)*a.x)/l,y:(n.y-(1-l)*a.y)/l},r={x:(r.x-l*s.x)/(1-l),y:(r.y-l*s.y)/(1-l)},{p0:a,cp1:n,cp2:r,p:s}}(e,t,n),u=k([i.p0,i.cp1,i.cp2,i.p],n),h=T(e.p,u),y=0,o=0,c=!1,x=h;if(h<p){let l=.5*(1+n);if(y=T(k([t.p0,t.cp1,t.cp2,t.p],.5),k([i.p0,i.cp1,i.cp2,i.p],l)),x+=y,y<p){let t=.5*n;o=T(k([e.p0,e.cp1,e.cp2,e.p],.5),k([i.p0,i.cp1,i.cp2,i.p],t)),x+=o,x<p&&(c=!0)}}return c&&(i.p0=e.p0,i.p=t.p,i.dimA=T(i.p0,i.p),i.type="C",i.extreme=t.extreme,i.directionChange=t.directionChange,i.corner=t.corner,i.values=[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y],i.error=x/p,a=[i]),a}function X(e,{tolerance:t=1,debug:l=!1}={}){let a=!1,n={flat:!0,steepness:0},s=e[0],r=e[e.length-1],p=new Set([...e.map(e=>+e.x.toFixed(8))]),i=new Set([...e.map(e=>+e.y.toFixed(8))]);if(1===p.size||1===i.size)return!l||n;let u=w(s,r),h=u/1e3*t,y=H(e,!0);return y<h&&(a=!0),l&&(n.flat=a,n.steepness=y/u*10),l?n:a}function Y(e=[]){let t,l=[],a=Z(P(e)),{left:n,right:s,top:r,bottom:p,width:i,height:u}=a,h=e[0].values[0],y=e[0].values[1],o={x:e[0].values[0],y:e[0].values[1]},c={x:e[0].values[0],y:e[0].values[1]};e[0].idx=0,e[0].p0=o,e[0].p=o,e[0].lineto=!1,e[0].corner=!1,e[0].extreme=!1,e[0].directionChange=!1,e[0].closePath=!1,e[0].dimA=0;let x=[e[0]],f=0,g=e.length;for(let l=2;g&&l<=g;l++){let a=e[l-1],{type:i,values:u}=a,g=u.slice(-2),v=[c];a.idx=l-1,a.lineto=!1,a.corner=!1,a.extreme=!1,a.directionChange=!1,a.closePath=!1,a.dimA=0;let d,M,b,A,C,L,k=.05;t=g.length?{x:g[0],y:g[1]}:o,"M"===i?(o=t,c=t):"z"===i.toLowerCase()&&(t=o),a.p0=c,a.p=t;let P=T(c,t);a.dimA=P,"L"===i&&(a.lineto=!0),"Z"===i&&(a.closePath=!0,o.x!==h&&o.y!==y&&(a.lineto=!0)),"Q"!==i&&"C"!==i||(d={x:u[0],y:u[1]},M="C"===i?{x:u[2],y:u[3]}:null,a.cp1=d,M&&(a.cp2=M)),u.length>2&&("Q"!==i&&"C"!==i||v.push(d),"C"===i&&v.push(M),v.push(t)),"L"===i||t.x!==n&&t.y!==r&&t.x!==s&&t.y!==p||(a.extreme=!0);let F=e[l]?e[l]:null,I=F?F.values.slice(-2):null;C=F?F.type:null,!F||"Q"!==F.type&&"C"!==F.type||(A=F?{x:I[0],y:I[1]}:null,b={x:F.values[0],y:F.values[1]},"C"===F.type&&(F.values[2],F.values[3])),L=H(v);let $=f<0&&L>0||f>0&&L<0;if(f=L,$&&(a.directionChange=!0),("Q"===i||"C"===i)&&("Q"===i&&"Q"===C||"C"===i&&"C"===C)){let e=v.slice(1);if(A&&Math.abs(A.x-c.x),A&&Math.abs(A.y-c.y),!!a.extreme||z(0,e,k))a.extreme=!0;else{let e=M?[M,t]:[d,t],l=[t,b],n=m(...e,!0),s=m(...l,!0),r=180*Math.abs(n-s)/Math.PI,p=w(...e),i=w(...l);r>10&&p&&i&&(a.corner=!0)}}x.push(a),c=t}return l={pathData:x,bb:a,dimA:(i+u)/2},l}function G(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=[];for(let s=0,r=e.length;s<r;s++){let r=e[s],{type:p,values:i}=r,u=i.length?i.slice(-2):[t.x,t.y];a={x:u[0],y:u[1]};let h=r.dimA?+r.dimA.toFixed(8):"M"!==p?+T(l,a).toFixed(8):0;h&&n.push(h),"M"===p&&(t=a),l=a}let s=n.sort(),r=Math.ceil(s.length/10);s=s.slice(0,r);let p=s.reduce((e,t)=>e+t,0)/r,i=p>60?0:Math.floor(40/p).toString().length;return Math.min(Math.max(0,i),8)}function K(e,t=-1){let l=e.length;for(let a=0;a<l;a++){let l=e[a].values,n=l.length;if(n&&t>-1)for(let s=0;s<n;s++)e[a].values[s]=+l[s].toFixed(t)}return e}function _(e={},t={},l={},a={}){let n=L(e,t,1.5),s=L(a,l,1.5),r=.03*T(e,a),p=T(n,s),i=null,u={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return p&&r&&p<r&&(i=A(e,t,a,l,!1),i&&(u.type="Q",u.values=[i.x,i.y,a.x,a.y],u.p0=e,u.cp1=i,u.cp2=null,u.p=a)),u}function ee(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!1){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?le(e):e;let n=e.length,s=new Array(n),r={type:"M",values:e[0].values};s[0]=r;let p,i={x:e[0].values[0],y:e[0].values[1]},u=.01;for(let l=1;l<n;l++){let a=e[l],{type:n,values:h}=a,y=h.length,o=[h[y-2],h[y-1]],c=e[l-1],x=c.type;p={x:o[0],y:o[1]};let f,g,v,d,M={x:h[0],y:h[1]},m=Math.abs(p.x-i.x),b=Math.abs(p.y-i.y),A=(m+b)/2*u;switch(n){case"L":r=0===b||b<A&&m>A?{type:"H",values:[h[0]]}:0===m||b>A&&m<A?{type:"V",values:[h[1]]}:a;break;case"Q":if("Q"!==x){i={x:o[0],y:o[1]},s[l]=a;continue}let e={x:c.values[0],y:c.values[1]};d={x:2*i.x-e.x,y:2*i.y-e.y},f=Math.abs(M.x-d.x),g=Math.abs(M.y-d.y),v=(f+g)/2,r=v<A?{type:"T",values:[p.x,p.y]}:a;break;case"C":let t={x:h[2],y:h[3]};if("C"!==x){s[l]=a,i={x:o[0],y:o[1]};continue}let u={x:c.values[2],y:c.values[3]};d={x:2*i.x-u.x,y:2*i.y-u.y},f=Math.abs(M.x-d.x),g=Math.abs(M.y-d.y),v=(f+g)/2,r=v<A?{type:"S",values:[t.x,t.y,p.x,p.y]}:a;break;default:r={type:n,values:h}}(a.decimals||0===a.decimals)&&(r.decimals=a.decimals),t>-1&&(r.values=r.values.map(e=>+e.toFixed(t))),i={x:o[0],y:o[1]},s[l]=r}return s}(e)),a>-1&&l&&(e=K(e,a)),l&&(e=function(e,t=-1){return le(e,!0,t)}(e)),a>-1&&(e=K(e,a)),e}function te(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let l={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},a={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[l.x,l.y,a.x,a.y,t[2],t[3]]}}function le(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e[0].values,n=a[0],s=a[1],r=n,p=s;for(let a=1,i=e.length;a<i;a++){let i=e[a],{type:u,values:h}=i,y=t?u.toLowerCase():u.toUpperCase();if(u!==y)switch(u=y,i.type=u,u){case"a":case"A":h[5]=t?h[5]-n:h[5]+n,h[6]=t?h[6]-s:h[6]+s;break;case"v":case"V":h[0]=t?h[0]-s:h[0]+s;break;case"h":case"H":h[0]=t?h[0]-n:h[0]+n;break;case"m":case"M":t?(h[0]-=n,h[1]-=s):(h[0]+=n,h[1]+=s),r=t?h[0]+n:h[0],p=t?h[1]+s:h[1];break;default:if(h.length)for(let e=0;e<h.length;e++)h[e]=t?h[e]-(e%2?s:n):h[e]+(e%2?s:n)}let o=h.length;switch(u){case"z":case"Z":n=r,s=p;break;case"h":case"H":n=t?n+h[0]:h[0];break;case"v":case"V":s=t?s+h[0]:h[0];break;case"m":case"M":r=h[o-2]+(t?n:0),p=h[o-1]+(t?s:0);default:n=h[o-2]+(t?n:0),s=h[o-1]+(t?s:0)}l>=0&&(i.values=i.values.map(e=>+e.toFixed(l)))}return e}function ae(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}e=l&&a?function(e,t=-1){return le(e,!1,t)}(e,t):e;let n=[],s={type:"M",values:e[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,p,i,u,h,y,o,c=e[l],{type:x,values:f}=c,g=f.length,v=s.values,d=v.length,[M,m]=[f[g-2],f[g-1]],[b,A]=[v[d-2],v[d-1]];switch(x){case"H":s={type:"L",values:[f[0],A]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],p=b+(b-a),i=A+(A-r),s={type:"Q",values:[p,i,M,m]};break;case"S":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],[y,o]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,A],p=2*b-y,i=2*A-o,u=f[0],h=f[1],s={type:"C",values:[p,i,u,h,M,m]};break;default:s={type:x,values:f}}t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),n.push(s)}return n}function ne({p0:e={x:0,y:0},p:t={x:0,y:0},centroid:l={x:0,y:0},rx:a=0,ry:n=0,xAxisRotation:s=0,radToDegree:r=!1,startAngle:p=null,endAngle:i=null,deltaAngle:u=null}={}){if(!a||!n)return[];let h=[];const y=1.5707963267948966;let o=r?s:s*Math.PI/180,c=Math.cos(o),x=Math.sin(o);null!==p&&null!==i&&null!==u||({startAngle:p,endAngle:i,deltaAngle:u}=b(l,e,t));let f=a!==n?S(p,a,n):p,g=a!==n?S(u,a,n):u,v=Math.max(1,Math.ceil(Math.abs(g)/y)),d=g/v;for(let e=0;e<v;e++){const e=Math.abs(d)===y?.551785*Math.sign(d):4/3*Math.tan(d/4);let t=Math.cos(f),s=Math.sin(f),r=Math.cos(f+d),p=Math.sin(f+d),i=[];[{x:t-s*e,y:s+t*e},{x:r+p*e,y:p-r*e},{x:r,y:p}].forEach(e=>{let t=e.x*a,s=e.y*n;i.push(c*t-x*s+l.x,x*t+c*s+l.y)}),h.push({type:"C",values:i,cp1:{x:i[0],y:i[1]},cp2:{x:i[2],y:i[3]},p:{x:i[4],y:i[5]}}),f+=d}return h}function se(e,t,l=1){const a=2*Math.PI;let[n,s,r,p,i,u,h]=t;if(0===n||0===s)return[];let y=r?r*a/360:0,o=y?Math.sin(y):0,c=y?Math.cos(y):1,x=c*(e.x-u)/2+o*(e.y-h)/2,f=-o*(e.x-u)/2+c*(e.y-h)/2;if(0===x&&0===f)return[];n=Math.abs(n),s=Math.abs(s);let g=x*x/(n*n)+f*f/(s*s);if(g>1){let e=Math.sqrt(g);n*=e,s*=e}let v=n*n,d=n===s?v:s*s,M=x*x,m=f*f,b=v*d-v*m-d*M;b<=0?b=0:(b/=v*m+d*M,b=Math.sqrt(b)*(p===i?-1:1));let A=b?b*n/s*f:0,C=b?b*-s/n*x:0,w=c*A-o*C+(e.x+u)/2,L=o*A+c*C+(e.y+h)/2,k=(x-A)/n,P=(f-C)/s,F=(-x-A)/n,I=(-f-C)/s;const $=(e,t,l,a)=>{let n=+(e*l+t*a).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*a-t*l<0?-1:1)*Math.acos(n))};let S=$(1,0,k,P),z=$(k,P,F,I);0===i&&z>0?z-=2*Math.PI:1===i&&z<0&&(z+=2*Math.PI);let Q=(+(Math.abs(z)/(a/4)).toFixed(0)||1)*l;z/=Q;let E=[];const T=1.5707963267948966,D=.551785;let q=z===T?D:z===-T?-D:4/3*Math.tan(z/4),B=z?Math.cos(z):1,j=z?Math.sin(z):0;const Z=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,p=Math.cos(e+t),i=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:p+i*l,y:i-p*l},{x:p,y:i}]};for(let e=0;e<Q;e++){let e={type:"C",values:[]};Z(S,z,q,B,j).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-o*a+w,o*l+c*a+L)}),E.push(e),S+=z}return E}function re(e,t,l,a,n=7.5){let s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},r=0,p=!1,i=m(e,t,!0),u=m(a,l,!0),h=180*Math.abs(i-u)/Math.PI;if(Math.abs(h%180-90)<3){let i=A(e,t,a,l,!1);if(i){let u=C(e,i),h=C(a,i),y=+Math.max(u,h).toFixed(8),o=+Math.min(u,h).toFixed(8),c=o,x=y,f=H([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/c*Math.abs(c-x)<5&&(c=y,x=c),g&&(c=y,x=o);let v=R([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),d={type:"A",values:[c,x,0,0,f,a.x,a.y]};r=Math.PI*(c*x)/4,r-=Math.abs(H([e,a,i])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<n&&(p=!0,s=d)}}return{com:s,isArc:p,area:r}}function pe(e){let t,l=[[]],a=0,n=[[]],s={x:e[0].values[0],y:e[0].values[1]};for(let r=0,p=e.length;r<p;r++){let p=e[r],{type:i,values:u}=p;if("A"===i){let i=e[r-1].values.slice(-2);s={x:i[0],y:i[1]};let[h,y,o,c,x,f,g]=u,v=100/h*Math.abs(h-y)<5;t={x:u[5],y:u[6]},p.p0=s,p.p=t,p.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(p),n[a].push(r)),d&&"A"===d.type){let[e,p,i,u,o,c,x]=d.values,f=h!=e?100/h*Math.abs(h-e):0,g=y!=p?100/y*Math.abs(y-p):0;t={x:d.values[5],y:d.values[6]},d.p0=s,d.p=t,f<5&&g<5?(l[a].push(d),n[a].push(r+1)):(l.push([]),n.push([]),a++)}else l.push([]),n.push([]),a++}}if(!n.length)return e;l=l.filter(e=>e.length),n=n.filter(e=>e.length);for(let t=l.length-1;t>=0;t--){const a=l[t],s=n[t][0],r=a.length;let p=0,i=0;a.forEach(({values:e})=>{const[t,l]=e;p+=t,i+=l}),p/=r,i/=r;let u=100/p*Math.abs(p-i)<5;u&&(p=(p+i)/2,i=p);let h=e[s-1].values.slice(-2);if(h[0],h[1],4===r){let[t,l,n,h,y,o,c]=a[1].values,[,,,,,x,f]=a[3].values;u&&(p=1,i=1);let g={type:"A",values:[p,i,n,h,y,o,c]},v={type:"A",values:[p,i,n,h,y,x,f]};e.splice(s,r,g,v)}else if(3===r){let[t,l,n,u,h,y,o]=a[0].values,[c,x,,,,f,g]=a[2].values;u=1;let v={type:"A",values:[p,i,n,u,h,f,g]};e.splice(s,r,v)}else if(2===r){let[t,l,n,h,y,o,c]=a[0].values,[x,f,,,,g,v]=a[1].values;u&&(p=1,i=1,n=0);let{p0:d,p:M}=a[0],[m,b]=[a[1].p0,a[1].p];if(d.x!==b.x||d.y!==b.y){let t={type:"A",values:[p,i,n,h,y,g,v]};e.splice(s,r,t)}}}return e}function ie(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2,hasRelatives:r=!0,hasShorthands:p=!0,hasQuadratics:i=!0,hasArcs:u=!0,testTypes:h=!1}={}){if(h){let t=Array.from(new Set(e.map(e=>e.type))).join("");r=/[lcqamts]/gi.test(t),i=/[qt]/gi.test(t),u=/[a]/gi.test(t),p=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(i&&a||u&&n)&&(l=!0,t=!0),r&&t&&(e=le(e,!1)),p&&l&&(e=ae(e,-1,!1)),u&&n&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],s=e[a-1].values,r=s.length,p={x:s[r-2],y:s[r-1]};"A"===n.type?se(p,n.values,t).forEach(e=>{l.push(e)}):l.push(n)}return l}(e,s)),i&&a&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,s=n.length,r={x:n[s-2],y:n[s-1]};"Q"===a.type?t.push(te(r,a.values)):t.push(a)}return t}(e)),e}function ue(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=Array.isArray(e),p=r&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,i=r?e:function(e,t=!0){if(e=e.trim(),""===e)return{pathData:[],hasRelatives:!1,hasShorthands:!1,hasQuadratics:!1,hasArcs:!1};const l=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),a=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&l.has(e);let n,s=0,r=e.length,p="",i=[],u=-1,h="",y=!1,o=0,c=0,x=0,f=!1,g=new Set([]),v=[];const d=()=>{f&&("M"===p?p="L":"m"===p&&(p="l"),i.push({type:p,values:[]}),u++,c=0,f=!1)},M=(e=!1)=>{(e?o>0:""!==h)&&(t&&-1===u&&(n="Pathdata must start with M command",v.push(n),p="M",i.push({type:p,values:[]}),x=2,c=0,u++),"A"===p||"a"===p?(h=m(),i[u].values.push(...h)):(t&&h[1]&&"."!==h[1]&&"0"===h[0]&&(n=`${u}. command: Leading zeros not valid: ${h}`,v.push(n)),i[u].values.push(+h)),c++,h="",o=0,f=c>=x)},m=()=>{let e=h.length,t=!1;return 3===c&&2===e||4===c&&e>1?(h=[+h[0],+h[1]],t=!0,c++):3===c&&e>=3&&(h=[+h[0],+h[1],+h.substring(2)],t=!0,c+=2),t?h:[+h]},b=()=>{if(u>0){let e=i[u].values.length;if(e&&e<x||e&&e>x||("z"===p||"Z"===p)&&e>0){n=`${u}. command of type "${p}": ${x-e} values too few - ${x} expected`,v[v.length-1]!==n&&v.push(n)}}};let A=!1,C=!1,w=!1;for(;s<r;){let l=e.charCodeAt(s),r=l>47&&l<58;if(r||(A=101===l||69===l,C=45===l||43===l,w=46===l),r||C||w||A){if(y||45!==l&&46!==l)d();else{let e=46===l;M(e),d(),e&&o++}h+=e[s],y=A,s++}else if((l<48||l>5759)&&a(l))M(),s++;else{if(l>64){if(!he.has(l)){n=`${u}. command "${e[s]}" is not a valid type`,v.push(n),s++;continue}""!==h&&(i[u].values.push(+h),c++,h=""),t&&b(),p=e[s],x=ye[l];let a="M"===p||"m"===p,r=u>0&&("z"===i[u].type||"Z"===i[u].type);g.add(p),r&&!a&&(i.push({type:"m",values:[0,0]}),u++),i.push({type:p,values:[]}),u++,o=0,c=0,f=!1,s++;continue}r||(n=`${u}. ${e[s]} is not a valid separarator or token`,v.push(n),h=""),s++}}M(),t&&b();t&&v.length&&(n="Invalid path data:\n"+v.join("\n"),"log"===t?console.log(n):console.warn(n));i[0].type="M";let L=Array.from(g).join(""),k=/[lcqamts]/g.test(L),P=/[vhst]/gi.test(L),F=/[a]/gi.test(L),I=/[qt]/gi.test(L);return{pathData:i,hasRelatives:k,hasShorthands:P,hasQuadratics:I,hasArcs:F}}(e),{hasRelatives:u=!0,hasShorthands:h=!0,hasQuadratics:y=!0,hasArcs:o=!0}=i,c=p?i:i.pathData;return c=ie(c,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s,hasRelatives:u,hasShorthands:h,hasQuadratics:y,hasArcs:o}),c}const he=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),ye=new Uint8Array(128);function oe(e){if("path"===e.nodeName.toLowerCase())return e;let t=function(e,t=!1){let l,a,n,s,r,p,i,u,h,y,o,c,x,f,g,v,d=[],M=e.nodeName;const m=(e,t=9)=>{const l="svg"!==e.nodeName?e.closest("svg"):e,a=e=>{if(null===e)return 0;let l=96,a=e.match(/([a-z]+)/gi);a=a?a[0]:"";let n,s=parseFloat(e);if(!a)return s;switch(a){case"in":n=l;break;case"pt":n=1/72*96;break;case"cm":n=1/2.54*96;break;case"mm":n=1/2.54*96/10;break;case"em":case"rem":n=16;break;default:n=1}return+(s*n).toFixed(t)};let n=l.getAttribute("width");n=n?a(n):300;let s=l.getAttribute("height");s=n?a(s):150;let r=l.getAttribute("viewBox");r=r?r.replace(/,/g," ").split(" ").filter(Boolean).map(e=>+e):[];let p=r.length?r[2]:n,i=r.length?r[3]:s,u=p/100,h=i/100,y=Math.sqrt((Math.pow(u,2)+Math.pow(h,2))/2),o=["x","width","x1","x2","rx","cx","r"],c=["y","height","y1","y2","ry","cy"];e.getAttributeNames().forEach(t=>{let l=e.getAttribute(t),n=l;if(o.includes(t)||c.includes(t)){let s=o.includes(t)?u:h;s="r"===t&&p!=i?y:s;let r=l.match(/([a-z|%]+)/gi);r=r?r[0]:"",n=l.includes("%")?parseFloat(l)*s:a(l),e.setAttribute(t,+n)}})};m(e);const b=t=>(l={},t.forEach(t=>{l[t]=+e.getAttribute(t)}),l);switch(M){case"path":n=e.getAttribute("d"),d=ue(n);break;case"rect":a=["x","y","width","height","rx","ry"],({x:s,y:r,width:p,height:i,rx:h,ry:y}=b(a)),h||y?(h>p/2&&(h=p/2),y>i/2&&(y=i/2),d=[{type:"M",values:[s+h,r]},{type:"L",values:[s+p-h,r]},{type:"A",values:[h,y,0,0,1,s+p,r+y]},{type:"L",values:[s+p,r+i-y]},{type:"A",values:[h,y,0,0,1,s+p-h,r+i]},{type:"L",values:[s+h,r+i]},{type:"A",values:[h,y,0,0,1,s,r+i-y]},{type:"L",values:[s,r+y]},{type:"A",values:[h,y,0,0,1,s+h,r]},{type:"Z",values:[]}]):d=[{type:"M",values:[s,r]},{type:"L",values:[s+p,r]},{type:"L",values:[s+p,r+i]},{type:"L",values:[s,r+i]},{type:"Z",values:[]}];break;case"circle":case"ellipse":a=["cx","cy","rx","ry","r"],({cx:o,cy:c,r:u,rx:h,ry:y}=b(a));let t="circle"===M;t?(h=u,y=u):(h=h||u,y=y||u);let l=t&&u>=1?1:h,m=t&&u>=1?1:h;d=[{type:"M",values:[o+h,c]},{type:"A",values:[l,m,0,1,1,o-h,c]},{type:"A",values:[l,m,0,1,1,o+h,c]}];break;case"line":a=["x1","y1","x2","y2"],({x1:x,y1:g,x2:f,y2:v}=b(a)),d=[{type:"M",values:[x,g]},{type:"L",values:[f,v]}];break;case"polygon":case"polyline":let A=e.getAttribute("points").replaceAll(","," ").split(" ").filter(Boolean);for(let e=0;e<A.length;e+=2)d.push({type:0===e?"M":"L",values:[+A[e],+A[e+1]]});"polygon"===M&&d.push({type:"Z",values:[]})}return t?function(e){return e.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ")}(d):d}(e),l=t.map(e=>`${e.type} ${e.values} `).join(" "),a=[...e.attributes].map(e=>e.name),n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",l);let s=["x","y","cx","cy","dx","dy","r","rx","ry","width","height","points"];return a.forEach(t=>{if(!s.includes(t)){let l=e.getAttribute(t);n.setAttribute(t,l)}}),n}function ce(e,{tolerance:t=1,flatBezierToLinetos:l=!0}={}){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s=n,r=n;e[e.length-1].type.toLowerCase();for(let p=1,i=e.length;p<i;p++){let u=e[p],h=e[p+1]||e[i-1],y="z"===h.type.toLowerCase()?n:{x:h.values[h.values.length-2],y:h.values[h.values.length-1]},{type:o,values:c}=u,x=c.slice(-2);r="Z"!==o?{x:x[0],y:x[1]}:n;let f=y?H([s,r,y],!0):1/0,g=w(s,y),v=f<(g?g/333*t:0),d=!1;if(l||"C"!==o||(v=!1),l&&("C"===o||"Q"===o)){d=X([s,..."C"===o?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===o?[{x:c[0],y:c[1]}]:[],r],{tolerance:t}),d&&p<i-1&&(o="L",u.type="L",u.values=x)}v&&p<i-1&&"A"!==h.type&&("L"===o||l&&d)||(s=r,"M"===o?(n=r,s=n):"Z"===o&&(s=n),a.push(u))}return a}function xe(e){let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l];if(!a)continue;let{type:n=null,values:s=[]}=a,r=e[l+1]?e[l+1]:null;"M"!==n&&"m"!==n||r&&(!r||"Z"!==r.type&&"z"!==r.type)?t.push(a):r&&l++}return t}function fe(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,s=e.length;n<s;n++){let s=e[n],r=e[n-1],p=e[n+1]||null,{type:i,values:u}=s,h="m"===r.type.toLowerCase()&&!p,y=u.length;if(l={x:u[y-2],y:u[y-1]},h||"L"!==i||l.x!==t.x||l.y!==t.y){if(!h&&("l"===i||"v"===i||"h"===i)){if("l"===i?"00"===u.join(""):0===u[0])continue}a.push(s),t=l}}return a}function ge(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let l=0,a=[];for(let l=0;l<t;l++){let t=e[l],{type:n,values:s}=t,r=s.length;if(r){let e={type:n,x:s[r-2],y:s[r-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(3)-+t.y.toFixed(3)),l=a[0].index,l?de(e,l):e}function ve(e,{removeFinalLineto:t=!0,autoClose:l=!0}={}){let a=[],n=e.length,s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},r="z"===e[n-1].type.toLowerCase(),p=e.filter(e=>"L"===e.type),i=e[r?n-2:n-1],u=i.type,h=i.values.slice(-2).map(e=>+e.toFixed(8)),y=h[0]===s.x&&h[1]===s.y;!r&&l&&y&&(e.push({type:"Z",values:[]}),r=!0,n++);let o="L"!==e[1].type&&(!y||"L"===i.type);if(o=!1,!r)return e;let c=0;{let t=[];for(let l=0;l<n;l++){let a=e[l],{type:n,values:s}=a;if(s.length){let a=s.slice(-2),r=e[l-1]&&"L"===e[l-1].type,p=e[l+1]&&"L"===e[l+1].type,i=e[l-1]?e[l-1].type.toUpperCase():null,u=e[l+1]?e[l+1].type.toUpperCase():null,h={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:r,nextL:p,prevCom:i,nextCom:u};h.index=l,t.push(h)}}if(p.length){let e=t.filter(e=>"L"!==e.type&&"M"!==e.type&&e.prevCom&&"L"===e.prevCom||"M"===e.prevCom&&"L"===u).sort((e,t)=>e.y-t.y||e.x-t.x)[0];c=e?e.index-1:0}else t=t.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),c=t[0].index;e=c?de(e,c):e}return s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,i=e[n-2],u=i.type,h=i.values.slice(-2).map(e=>+e.toFixed(8)),y="L"===u&&h[0]===s.x&&h[1]===s.y,t&&y&&e.splice(n-2,1),a.push(...e),a}function de(e,t){let l=0,a="z"===e[e.length-1].type.toLowerCase();if(!a||t<1||e.length<3)return e;let n=a?1:0;!function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[n,s]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),r=l?e[t-2]:e[t-1],p=r.values.length,[i,u]=[r.values[p-2],r.values[p-1]].map(e=>+e.toFixed(8));!l||n==i&&s==u||(e.pop(),e.push({type:"L",values:[n,s]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let s,r,p=e.slice(l),i=e.slice(0,l);return i.shift(),s=i[i.length-1].values||[],r=[s[s.length-2],s[s.length-1]],n&&(p.pop(),i.push({type:"Z",values:[]})),e=[{type:"M",values:r},...p,...i]}function Me(e,{threshold:t=null,tolerance:l=1}={}){if(!t){let l=function(e){let t=1/0,l=-1/0,a=1/0,n=-1/0;const s=e=>{e.x<t&&(t=e.x),e.x>l&&(l=e.x),e.y<a&&(a=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let l=e[t],{type:a,values:n}=l,r=n.length,p=(e[t-1]?e[t-1]:e[t]).values,i=p.length;if(r){let e={x:p[i-2],y:p[i-1]},t={x:n[r-2],y:n[r-1]};if(s(t),"C"===a||"Q"===a){let l={x:n[0],y:n[1]},r="C"===a?{x:n[2],y:n[3]}:l,p="C"===a?[e,l,r,t]:[e,l,t];Q(p).forEach(e=>{let t=k(p,e);s(t)})}else"A"===a&&E(e,n).forEach(e=>{s(e)})}}return{x:t,y:a,width:l-t,height:n-a}}(e);t=(l.width+l.height)/2*.05}let a=e.length;for(let n=0;n<a;n++){let a=e[n],{type:s,values:r,extreme:p,corner:i=!1,dimA:u,p0:h,p:y}=a,o=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(o?T(y,o.p):1/0)<t,f=(c?T(c.p,o.p):1/0)<t;if(o&&"C"===s&&"C"===o.type&&p&&c&&c.extreme&&(f||x)){let a=V(o,c,t,l,!1);if(1===a.length){e[n+1]=null,a=a[0],e[n+2].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,a.p.x,a.p.y],e[n+2].cp1=a.cp1,e[n+2].cp2=a.cp2,e[n+2].p0=a.p0,e[n+2].p=a.p,e[n+2].extreme=a.extreme,n++;continue}}if(o&&"C"===s&&"C"===o.type&&p&&x){let t,l=a.cp1.x-o.p0.x,s=a.cp1.y-o.p0.y,r=Math.abs(s)<Math.abs(l),p=o.p,i=1,u=H([a.p0,a.p,o.p]),h=H([a.p0,a.cp1,a.cp2,a.p]);if(u<0&&h>0||u>0&&h<0)continue;if(o.extreme){r?(i=Math.abs(Math.abs(o.cp2.x-o.p.x)/Math.abs(a.cp2.x-a.p.x)),i=Math.min(1,i),t=L(o.p,a.cp2,1+i),a.cp2.x=t.x):(i=Math.abs(Math.abs(o.cp2.y-o.p.y)/Math.abs(a.cp2.y-a.p.y)),i=Math.min(1,i),t=L(o.p,a.cp2,1+i),a.cp2.y=t.y),e[n+1].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,p.x,p.y],e[n+1].cp1=a.cp1,e[n+1].cp2=a.cp2,e[n+1].p0=a.p0,e[n+1].p=p,e[n+1].extreme=!0,e[n]=null;continue}}}a=(e=e.filter(Boolean)).length;let n="z"===e[a-1].type.toLowerCase()?a-2:a-1,s=e[n],r=e[n-1]||null,p={x:e[0].values[0],y:e[0].values[1]},i=s.values.slice(-2),u=+i[0].toFixed(8)===+p.x.toFixed(8)&&+i[1].toFixed(8)===+p.y.toFixed(8),h="C"===e[1].type&&e[1].extreme?e[1]:null,y=T(s.p0,s.p)<t;if(r&&"C"===r.type&&y&&u&&h){let a=V(r,s,t,l,!1);1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function me(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}function be(e,{threshold:t=0,tolerance:l=1}={}){let a=e.length,n=[e[0]],s="z"===e[a-1].type.toLowerCase(),r=!!s&&(e[a-1].p.x===e[0].p0.x&&e[a-1].p.y===e[0].p0.y),p=s?2:1,i=e[a-p],u="L"===i.type,h="C"===i.type,y="L"===e[1].type,o="C"===e[1].type,c=s&&o&&(u||r);c&&(e[a-1].values=e[0].values,e[a-1].type="L",u=!0);for(let t=1;t<a;t++){let r=e[t],{type:i}=r,x=e[t+1]?e[t+1]:null;if("L"===i&&x&&"C"===x.type||"C"===i&&x&&"L"===x.type){let c="L"===i?r:null,f=null,g=[],v=0;if(1===t&&o&&u&&(g=[e[1]],c=e[a-1],f=x),!c){n.push(r);continue}s&&h&&y&&t===a-p-1&&(f=e[1],g=[e[a-p]]);for(let l=t+1;l<a;l++){let t=e[l]?e[l]:null,a=e[l-1];if("C"===a.type&&g.push(a),"L"===t.type&&"C"===a.type){f=t;break}v++}if(f){let e=T(c.p0,c.p),a=T(f.p0,f.p),s=g.length,p=T(g[0].p0,g[s-1].p),i=H([c.p0,c.p,f.p0,f.p],!1),u=H([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),h=i<0&&u>0||i>0&&u<0,y=.5*p*l,o=y<e&&y<a;if(g.length&&!h&&o){let e=Math.abs(u)<=.005*w(g[0].p0,g[0].p),l=e?null:A(c.p0,c.p,f.p0,f.p,!1);if(!e&&l){if(!(T(k([c.p,l,f.p0],.5),1===g.length?k([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p)>p)){let e={type:"Q",values:[l.x,l.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=l,e.p=f.p0,n.push(c,e),t+=v;continue}n.push(r)}}}}c&&t===a-1&&"L"===i||n.push(r)}return(c||s&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function Ae(e){if(e.length<3)return!1;let t=e[0],l=e[Math.floor(e.length/2)],a=e[e.length-1],n=t.x,s=t.y,r=l.x,p=l.y,i=a.x,u=a.y,h=n-r,y=s-p,o=n-i,c=s-u,x=(n*n-r*r+(s*s-p*p))/2,f=(n*n-i*i+(s*s-u*u))/2,g=h*c-y*o;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let v={x:(c*x-y*f)/g,y:(-o*x+h*f)/g},d=C(v,t),M=b(v,t,a),{deltaAngle:m,startAngle:A,endAngle:w}=M;return{centroid:v,r:d,startAngle:A,endAngle:w,deltaAngle:m}}function Ce(t,{threshold:l=0,tolerance:a=1,toCubic:n=!1,debug:s=!1}={}){let r=t.length,p=[t[0]],i=[];for(let l=1;l<r;l++){let a=t[l],{type:r}=a,u=t[l-1],h=t[l+1]?t[l+1]:null,y=t[l+2]?t[l+2]:null,o=t[l+3]?t[l+3]:null,c=null;"C"===a.type||"Q"===a.type?c=a:!h||"C"!==h.type&&"Q"!==h.type||(c=h);let x,f,g,v,d,M=c?"C"===c.type?[c.p0,c.cp1,c.cp2,c.p]:[c.p0,c.cp1,c.p]:[],m=0,b=0,A=!1,C=!1,w=[];if("L"===u.type&&"L"===r&&c&&"L"===y.type&&o&&("L"===o.type||"Z"===o.type)?(x=[a.p0,a.p],f=[y.p0,y.p],g=a.p0,v=y.p,m=H(M,!1),b=H([...x,...f],!1),A=m<0&&b>0||m>0&&b<0,A||(d=k(M,.5),w=[g,d,v],C=!0)):"C"!==r&&"Q"!==r||"L"!==u.type||"C"!==h.type&&"Q"!==h.type||"L"!==y.type||(C=!0,x=[u.p0,u.p],f=[y.p0,y.p],g=u.p,v=y.p0,d=c.p,w=[g,c.p,v]),C){let t=Ae(w);if(t){let r,{centroid:u,r:h,deltaAngle:y,startAngle:o,endAngle:c}=t,x=0,f=y>0?1:0,M=Math.abs(y)>Math.PI?1:0;if(T(I(g,u.x,u.y,.5*y),d)<.05*T(g,v)){if(r=ne({p0:g,p:v,centroid:u,rx:h,ry:h,xAxisRotation:x,sweep:f,largeArc:M,deltaAngle:y,startAngle:o,endAngle:c}),1===r.length){let e=_(g,r[0].cp1,r[0].cp2,v);"Q"===e.type&&(n=!0),a=e}if(r.length>1&&(n=!1),n||(a.type="A",a.values=[h,h,x,M,f,v.x,v.y]),a.p0=g,a.p=v,a.extreme=!1,a.corner=!1,s){i=n?[{type:"M",values:[g.x,g.y]},...r]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[h,h,x,M,f,v.x,v.y]}];let t=U(i);e(markers,t,"orange","0.5%","0.5")}p.push(a),l++;continue}}}p.push(a)}return p}function we(e=[],{threshold:t=0}={}){let l=e.length,a="z"===e[l-1].type.toLowerCase(),n=a?l-2:l-1,s=e[n],r=s.values.slice(-2),p={x:e[0].values[0],y:e[0].values[1]},i=T(p,{x:r[0],y:r[1]});if(i&&i<t){let l=e[n].values.length;e[n].values[l-2]=p.x,e[n].values[l-1]=p.y;let a=e[1];if("C"===a.type&&"C"===s.type){let l=Math.abs(a.values[0]-s.values[2]),r=Math.abs(a.values[1]-s.values[3]),i=Math.abs(e[1].values[0]-a.values[0]),u=Math.abs(e[1].values[1]-a.values[1]),h=Math.abs(e[1].values[0]-s.values[2]),y=Math.abs(e[1].values[1]-s.values[3]),o=u<t&&y<t&&l;l&&l<t&&(i<t&&h<t&&r)&&(e[1].values[0]=p.x,e[n].values[2]=p.x),r&&r<t&&o&&(e[1].values[1]=p.y,e[n].values[3]=p.y)}}return e}function Le(e,t=1){let l=[];for(let a=0,n=e.length;a<n;a++){let n=e[a],{type:s,values:r}=n,p={type:s,values:[]};switch(s.toLowerCase()){case"h":case"v":p.values=[r[0]*t];break;case"a":p.values=[r[0]*t,r[1]*t,r[2],r[3],r[4],r[5]*t,r[6]*t];break;default:r.length&&(p.values=r.map((e,l)=>e*t))}l.push(p)}return l}function ke(e="",{getObject:t=!1,toAbsolute:l=!0,toRelative:a=!0,toShorthands:n=!0,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:p=!1,simplifyBezier:i=!0,optimizeOrder:u=!0,autoClose:h=!0,removeZeroLength:y=!0,refineClosing:o=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:v=!1,keepExtremes:d=!0,keepCorners:M=!0,extrapolateDominant:m=!0,keepInflections:b=!1,addExtremes:A=!1,removeOrphanSubpaths:C=!1,simplifyRound:w=!1,scale:L=1,scaleTo:k=0,decimals:F=3,autoAccuracy:I=!0,minifyD:$=0,tolerance:S=1,reverse:z=!1,mergePaths:Q=!1,removeHidden:E=!0,removeUnused:T=!0,shapesToPaths:q=!0}={}){S=Math.max(.1,S);let B=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"array";if("string"==typeof e){let l=(e=e.trim()).includes("<svg")&&e.includes("</svg"),a=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(n)t="polyString";else{let l=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),a=e.startsWith("data:image");t=l||a?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),N="",O=0,R=0,H=0,V={},J="",X="svgMarkup"===B?1:0,K=[];if(O=e.length,X){if(N=function(e,{returnDom:t=!1,removeHidden:l=!0,removeUnused:a=!0}={}){e=(e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()).replaceAll("xlink:href=","href=");let n=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)||e.removeAttribute(l)})}(n,["viewBox","xmlns","width","height","id","class","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"]);let s=["metadata","script"];return n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),r=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||s.includes(t)||l&&r?e.remove():function(e){[...e.attributes].map(e=>e.name).forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t?n:me(n)}(e,{returnDom:!0,removeHidden:E,removeUnused:T}),q){N.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=oe(e);e.replaceWith(t)})}N.querySelectorAll("path").forEach(e=>{K.push({d:e.getAttribute("d"),el:e})})}else{if("pathDataString"===B)J=e;else if("polyString"===B)J="M"+e;else if("pathData"===B){J=e,O=J.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}K.push({d:J,el:null})}let te={toRelative:a,toShorthands:n,decimals:F},le=[];for(let e=0,t=K.length;t&&e<t;e++){let t=K[e],{d:a,el:n}=t,E=ue(a,{quadraticToCubic:s,toAbsolute:l,arcToCubic:r});if(1!==L||k){if(k){let e=E.map(e=>({type:e.type,values:e.values}));e=j(e);let t=k/Z(P(e)).width;L=t}E=Le(E,L)}let T=E.length;C&&(E=xe(E));let q=D(E),B=q.length,N=[];for(let e=0;e<B;e++){let t=q[e];(c||y)&&(t=fe(t)),A&&(t=j(t,0,1)),u&&(t=ge(t)),c&&(t=ce(t,{tolerance:S,flatBezierToLinetos:!1}));let l=Y(t),{pathData:a,bb:n,dimA:s}=l;if(o&&(a=we(a,{threshold:.001*s})),a=i?W(a,{simplifyBezier:i,keepInflections:b,keepExtremes:d,keepCorners:M,extrapolateDominant:m,revertToQuadratics:f,tolerance:S,reverse:z}):a,g){a=Me(a,{threshold:(n.width+n.height)/2*.05,tolerance:S})}if(p){let e=1;for(let t=0,l=a.length;t<l;t++){let l=a[t],{type:n,values:s,p0:r,cp1:p=null,cp2:i=null,p:u=null}=l;if("C"===n){let l=re(r,p,i,u,e);l.isArc&&(a[t]=l.com)}}a=pe(a)}if(c&&x&&(a=ce(a,{tolerance:S,flatBezierToLinetos:x})),v){a=be(a,{threshold:(n.width+n.height)/2*.1,tolerance:S})}if(w&&(a=Ce(a)),f)for(let e=0,t=a.length;e<t;e++){let t=a[e],{type:l,values:n,p0:s,cp1:r=null,cp2:p=null,p:i=null}=t;if("C"===l){let l=_(s,r,p,i);"Q"===l.type&&(l.extreme=t.extreme,l.corner=t.corner,l.dimA=t.dimA,a[e]=l)}}u&&(a=ve(a,{autoClose:h})),N.push({pathData:a,bb:n})}if(u&&(N=N.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x)),E=[],N.forEach(e=>{E.push(...e.pathData)}),I&&(F=G(E),te.decimals=F),n&&Q)le.push(...E);else{E=ee(E,te),E=fe(E);let e=E.length,l=U(E,$);R=l.length,H=+(100/O*R).toFixed(2),t.d=l,t.report={original:T,new:e,saved:T-e,compression:H,decimals:F},n&&n.setAttribute("d",l)}}if(X){if(le.length){let e=ee(le,te);e=fe(e);let t=U(e,$);K[0].el.setAttribute("d",t);for(let e=1;e<K.length;e++){let t=K[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(N)}if(L){let e=function(e=null,t=-1){const l=e=>e&&isNaN(e)?e.match(/[^\d]+/g)[0]:"";if(!e)return!1;let a=e.hasAttribute("width"),n=e.hasAttribute("height"),s=e.hasAttribute("viewBox"),r=a?e.getAttribute("width"):0,p=n?e.getAttribute("height"):0,i=!!a&&l(r),u=!!n&&l(r),h=r?r.includes("%")?0:parseFloat(r):300,y=p?p.includes("%")?0:parseFloat(p):150,o=s?e.getAttribute("viewBox").split(/,| /).filter(Boolean).map(Number):[0,0,h,y];return t>-1&&([h,y]=[h,y].map(e=>+e.toFixed(t)),o=o.map(e=>+e.toFixed(t))),{x:o[0],y:o[1],width:o[2],height:o[3],w:h,h:y,hasViewBox:s,hasWidth:a,hasHeight:n,widthUnit:i,heightUnit:u}}(N,F),{x:t,y:l,width:a,height:n,w:s,h:r,hasViewBox:p,hasWidth:i,hasHeight:u,widthUnit:h,heightUnit:y}=e;p&&N.setAttribute("viewBox",[t,l,a,n].map(e=>+(e*L).toFixed(F)).join(" ")),i&&N.setAttribute("width",+(s*L).toFixed(F)+h),u&&N.setAttribute("height",+(r*L).toFixed(F)+y)}N=me(N),R=N.length,H=+(100/O*R).toFixed(2),O=+(O/1024).toFixed(3),R=+(R/1024).toFixed(3),V={svgSize:O,svgSizeOpt:R,compression:H}}else({d:J,report:V}=K[0]);return t?{svg:N,d:J,report:V,inputType:B,mode:X}:J||N}ye[77]=2,ye[109]=2,ye[65]=7,ye[97]=7,ye[67]=6,ye[99]=6,ye[76]=2,ye[108]=2,ye[81]=4,ye[113]=4,ye[83]=4,ye[115]=4,ye[84]=2,ye[116]=2,ye[72]=1,ye[104]=1,ye[86]=1,ye[118]=1,ye[90]=0,ye[122]=0;const{abs:Pe,acos:Fe,asin:Ie,atan:$e,atan2:Se,ceil:ze,cos:Qe,exp:Ee,floor:Te,log:De,hypot:qe,max:Be,min:je,pow:Ze,random:Ne,round:Oe,sin:Re,sqrt:He,tan:Ue,PI:Ve}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=ke);export{Ve as PI,Pe as abs,Fe as acos,Ie as asin,$e as atan,Se as atan2,ze as ceil,Qe as cos,Ee as exp,Te as floor,qe as hypot,De as log,Be as max,je as min,Ze as pow,Ne as random,Oe as round,Re as sin,He as sqrt,ke as svgPathSimplify,Ue as tan};
|
|
@@ -1942,7 +1942,7 @@
|
|
|
1942
1942
|
let distAv2 = getDistAv(com2.p0, com2.p);
|
|
1943
1943
|
let distMin = Math.max(0, Math.min(distAv1, distAv2));
|
|
1944
1944
|
|
|
1945
|
-
let distScale = 0.
|
|
1945
|
+
let distScale = 0.08;
|
|
1946
1946
|
let maxDist = distMin * distScale * tolerance;
|
|
1947
1947
|
|
|
1948
1948
|
// get hypothetical combined command
|
|
@@ -1976,8 +1976,6 @@
|
|
|
1976
1976
|
|
|
1977
1977
|
error += dist1;
|
|
1978
1978
|
|
|
1979
|
-
// quit - paths not congruent
|
|
1980
|
-
|
|
1981
1979
|
if (dist1 < maxDist) {
|
|
1982
1980
|
|
|
1983
1981
|
// 1st segment mid
|
|
@@ -1987,18 +1985,9 @@
|
|
|
1987
1985
|
let ptS_1 = pointAtT([comS.p0, comS.cp1, comS.cp2, comS.p], t2);
|
|
1988
1986
|
dist2 = getDistAv(pt_1, ptS_1);
|
|
1989
1987
|
|
|
1990
|
-
/*
|
|
1991
|
-
if(dist1>tolerance){
|
|
1992
|
-
renderPoint(markers, pt_1, 'blue')
|
|
1993
|
-
renderPoint(markers, ptS_1, 'orange', '0.5%')
|
|
1994
|
-
}
|
|
1995
|
-
*/
|
|
1996
|
-
|
|
1997
|
-
// quit - paths not congruent
|
|
1998
|
-
if (dist1 + dist2 < maxDist) success = true;
|
|
1999
|
-
|
|
2000
|
-
// collect error data
|
|
2001
1988
|
error += dist2;
|
|
1989
|
+
|
|
1990
|
+
if (error < maxDist) success = true;
|
|
2002
1991
|
|
|
2003
1992
|
}
|
|
2004
1993
|
|
|
@@ -5250,6 +5239,98 @@
|
|
|
5250
5239
|
|
|
5251
5240
|
}
|
|
5252
5241
|
|
|
5242
|
+
/**
|
|
5243
|
+
* scale path data proportionaly
|
|
5244
|
+
*/
|
|
5245
|
+
function scalePathData(pathData, scale = 1) {
|
|
5246
|
+
let pathDataScaled = [];
|
|
5247
|
+
|
|
5248
|
+
for (let i = 0, l = pathData.length; i < l; i++) {
|
|
5249
|
+
let com = pathData[i];
|
|
5250
|
+
let { type, values } = com;
|
|
5251
|
+
let comT = {
|
|
5252
|
+
type: type,
|
|
5253
|
+
values: []
|
|
5254
|
+
};
|
|
5255
|
+
|
|
5256
|
+
switch (type.toLowerCase()) {
|
|
5257
|
+
// lineto shorthands
|
|
5258
|
+
case "h":
|
|
5259
|
+
comT.values = [values[0] * scale];
|
|
5260
|
+
break;
|
|
5261
|
+
case "v":
|
|
5262
|
+
comT.values = [values[0] * scale];
|
|
5263
|
+
break;
|
|
5264
|
+
|
|
5265
|
+
// arcto
|
|
5266
|
+
case "a":
|
|
5267
|
+
comT.values = [
|
|
5268
|
+
values[0] * scale, // rx: scale
|
|
5269
|
+
values[1] * scale, // ry: scale
|
|
5270
|
+
values[2], // x-axis-rotation: keep it
|
|
5271
|
+
values[3], // largeArc: dito
|
|
5272
|
+
values[4], // sweep: dito
|
|
5273
|
+
values[5] * scale, // final x: scale
|
|
5274
|
+
values[6] * scale // final y: scale
|
|
5275
|
+
];
|
|
5276
|
+
break;
|
|
5277
|
+
|
|
5278
|
+
/**
|
|
5279
|
+
* Other point based commands: L, C, S, Q, T
|
|
5280
|
+
* scale all values
|
|
5281
|
+
*/
|
|
5282
|
+
default:
|
|
5283
|
+
if (values.length) {
|
|
5284
|
+
comT.values = values.map((val, i) => {
|
|
5285
|
+
return val * scale;
|
|
5286
|
+
});
|
|
5287
|
+
}
|
|
5288
|
+
}
|
|
5289
|
+
pathDataScaled.push(comT);
|
|
5290
|
+
} return pathDataScaled;
|
|
5291
|
+
}
|
|
5292
|
+
|
|
5293
|
+
/**
|
|
5294
|
+
* get viewBox
|
|
5295
|
+
* either from explicit attribute or
|
|
5296
|
+
* width and height attributes
|
|
5297
|
+
*/
|
|
5298
|
+
|
|
5299
|
+
function getViewBox(svg = null, decimals = -1) {
|
|
5300
|
+
|
|
5301
|
+
const getUnit=(val)=>{
|
|
5302
|
+
return val && isNaN(val) ? val.match(/[^\d]+/g)[0] : '';
|
|
5303
|
+
};
|
|
5304
|
+
|
|
5305
|
+
// browser default
|
|
5306
|
+
if (!svg) return false
|
|
5307
|
+
|
|
5308
|
+
let hasWidth = svg.hasAttribute('width');
|
|
5309
|
+
let hasHeight = svg.hasAttribute('height');
|
|
5310
|
+
let hasViewBox = svg.hasAttribute('viewBox');
|
|
5311
|
+
|
|
5312
|
+
let widthAtt = hasWidth ? svg.getAttribute('width') : 0;
|
|
5313
|
+
let heightAtt = hasHeight ? svg.getAttribute('height') : 0;
|
|
5314
|
+
|
|
5315
|
+
let widthUnit = hasWidth ? getUnit(widthAtt) : false;
|
|
5316
|
+
let heightUnit = hasHeight ? getUnit(widthAtt) : false;
|
|
5317
|
+
|
|
5318
|
+
let w = widthAtt ? (!widthAtt.includes('%') ? parseFloat(widthAtt) : 0 ) : 300;
|
|
5319
|
+
let h = heightAtt ? (!heightAtt.includes('%') ? parseFloat(heightAtt) : 0 ) : 150;
|
|
5320
|
+
|
|
5321
|
+
let viewBoxVals = hasViewBox ? svg.getAttribute('viewBox').split(/,| /).filter(Boolean).map(Number) : [0, 0, w, h];
|
|
5322
|
+
|
|
5323
|
+
// round
|
|
5324
|
+
if (decimals>-1) {
|
|
5325
|
+
[w, h] = [w, h].map(val=>+val.toFixed(decimals));
|
|
5326
|
+
viewBoxVals = viewBoxVals.map(val=>+val.toFixed(decimals));
|
|
5327
|
+
}
|
|
5328
|
+
|
|
5329
|
+
let viewBox = { x:viewBoxVals[0] , y:viewBoxVals[1], width:viewBoxVals[2], height:viewBoxVals[3], w, h, hasViewBox, hasWidth, hasHeight, widthUnit, heightUnit };
|
|
5330
|
+
|
|
5331
|
+
return viewBox
|
|
5332
|
+
}
|
|
5333
|
+
|
|
5253
5334
|
function svgPathSimplify(input = '', {
|
|
5254
5335
|
|
|
5255
5336
|
// return svg markup or object
|
|
@@ -5287,6 +5368,9 @@
|
|
|
5287
5368
|
|
|
5288
5369
|
simplifyRound = false,
|
|
5289
5370
|
|
|
5371
|
+
scale=1,
|
|
5372
|
+
scaleTo=0,
|
|
5373
|
+
|
|
5290
5374
|
// svg path optimizations
|
|
5291
5375
|
decimals = 3,
|
|
5292
5376
|
autoAccuracy = true,
|
|
@@ -5390,6 +5474,25 @@
|
|
|
5390
5474
|
|
|
5391
5475
|
let pathData = parsePathDataNormalized(d, { quadraticToCubic, toAbsolute, arcToCubic });
|
|
5392
5476
|
|
|
5477
|
+
// scale pathdata and viewBox
|
|
5478
|
+
if(scale!==1 || scaleTo){
|
|
5479
|
+
|
|
5480
|
+
// get bbox for scaling
|
|
5481
|
+
if(scaleTo){
|
|
5482
|
+
|
|
5483
|
+
let pathDataExtr = pathData.map(com=>{return {type:com.type, values:com.values}});
|
|
5484
|
+
pathDataExtr = addExtremePoints(pathDataExtr);
|
|
5485
|
+
let poly = getPathDataVertices(pathDataExtr);
|
|
5486
|
+
let bb = getPolyBBox(poly);
|
|
5487
|
+
|
|
5488
|
+
let scaleW = scaleTo/bb.width;
|
|
5489
|
+
scale = scaleW;
|
|
5490
|
+
|
|
5491
|
+
}
|
|
5492
|
+
|
|
5493
|
+
pathData = scalePathData(pathData, scale);
|
|
5494
|
+
}
|
|
5495
|
+
|
|
5393
5496
|
// count commands for evaluation
|
|
5394
5497
|
let comCount = pathData.length;
|
|
5395
5498
|
|
|
@@ -5586,6 +5689,25 @@
|
|
|
5586
5689
|
removeEmptySVGEls(svg);
|
|
5587
5690
|
}
|
|
5588
5691
|
|
|
5692
|
+
// adjust viewBox and width for scale
|
|
5693
|
+
if(scale){
|
|
5694
|
+
|
|
5695
|
+
let vB = getViewBox(svg, decimals);
|
|
5696
|
+
let {x,y, width, height, w, h, hasViewBox, hasWidth, hasHeight, widthUnit, heightUnit} = vB;
|
|
5697
|
+
|
|
5698
|
+
if(hasViewBox){
|
|
5699
|
+
svg.setAttribute('viewBox', [x, y, width, height].map(val=>+(val*scale).toFixed(decimals)).join(' ') );
|
|
5700
|
+
}
|
|
5701
|
+
if(hasWidth){
|
|
5702
|
+
svg.setAttribute('width', +(w*scale).toFixed(decimals)+widthUnit );
|
|
5703
|
+
}
|
|
5704
|
+
|
|
5705
|
+
if(hasHeight){
|
|
5706
|
+
svg.setAttribute('height', +(h*scale).toFixed(decimals)+heightUnit );
|
|
5707
|
+
}
|
|
5708
|
+
|
|
5709
|
+
}
|
|
5710
|
+
|
|
5589
5711
|
svg = stringifySVG(svg);
|
|
5590
5712
|
|
|
5591
5713
|
svgSizeOpt = svg.length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e){"use strict";function t(e,t="",l="green",a="1%",n="1",s=!0){let r=`<path d="${t}" fill="none" stroke="${l}" stroke-width="${a}" stroke-opacity="${n}" /> `;if(!s)return r;e.insertAdjacentHTML("beforeend",r)}const{abs:l,acos:a,asin:n,atan:s,atan2:r,ceil:p,cos:i,exp:u,floor:y,log:h,max:o,min:c,pow:x,random:f,round:g,sin:v,sqrt:d,tan:M,PI:m}=Math;function b(e,t,l=!1){let a=r(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function A(e,t,l,a=!1){let n=Math.atan2(t.y-e.y,t.x-e.x),s=Math.atan2(l.y-e.y,l.x-e.x),r=s-n;r=(e=>{let t=e%(2*Math.PI);return t>Math.PI?t-=2*Math.PI:t<=-Math.PI&&(t+=2*Math.PI),t})(r),a&&(r=2*Math.PI-Math.abs(r));let p=180/Math.PI;return{startAngle:n,endAngle:s,deltaAngle:r,startAngleDeg:n*p,endAngleDeg:s*p,deltaAngleDeg:r*p}}function C(e=null,t=null,l=null,a=null,n=!0,s=!1){let r,p,i,u,y,h={};if(!(e&&t&&l&&a))return s&&console.warn("points missing"),!1;try{if(r=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==r)return!1}catch{return s&&console.warn("!catch",e,t,"p3:",l,"p4:",a),!1}p=e.y-l.y,i=e.x-l.x,u=(a.x-l.x)*p-(a.y-l.y)*i,y=(t.x-e.x)*p-(t.y-e.y)*i,p=u/r,i=y/r,h={x:e.x+p*(t.x-e.x),y:e.y+p*(t.y-e.y)};let o=!1;return p>0&&p<1&&i>0&&i<1&&(o=!0),!(n&&!o)&&h}function w(e,t){return d((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function L(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function P(e,t,l,a=!1){let n={x:(t.x-e.x)*l+e.x,y:(t.y-e.y)*l+e.y};return a&&(n.angle=b(e,t),n.angle<0&&(n.angle+=2*m)),n}function k(e,t=.5,l=!1,a=!1){let n;return n=e.length>2?((e,t,l=!1)=>{let n=4===e.length,s=e[0],r=e[1],p=n?e[2]:e[1],i=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,y,h,o,c=s.x===r.x&&s.y===r.y,x=i.x===p.x&&i.y===p.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=P(s,r,t),n?(l=P(r,p,t),y=P(p,i,t),h=P(e,l,t),o=P(l,y,t),u=P(h,o,t),u.angle=b(h,o),a&&(u.cpts=[l,y,h,o])):(l=P(s,r,t),y=P(r,i,t),u=P(l,y,t),u.angle=b(l,y),a&&(u.cpts=[l,y]))):(u.x=i.x,u.y=i.y,u.angle=b(p,i)):(u.x=s.x,u.y=s.y,u.angle=b(s,r))}else{let e=1-t;u=n?{x:e**3*s.x+3*e**2*t*r.x+3*e*t**2*p.x+t**3*i.x,y:e**3*s.y+3*e**2*t*r.y+3*e*t**2*p.y+t**3*i.y}:{x:e*e*s.x+2*e*t*r.x+t**2*i.x,y:e*e*s.y+2*e*t*r.y+t**2*i.y}}return u})(e,t,l):P(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*m),n}function I(e,t,a,n,s,p,u,y,h){const o=(e,t,l,a)=>r(a-t,l-e);let c={cx:0,cy:0,rx:a=l(a),ry:n=l(n),startAngle:0,endAngle:0,deltaAngle:0,clockwise:u,xAxisRotation:s,largeArc:p,sweep:u};if(0==a||0==n)throw Error("rx and ry can not be 0");if(a===n){let l=Math.abs(y-e),a=Math.abs(h-t),n=l,s=Math.min(e,y),r=Math.min(t,h),p=.5*Math.PI;if(0===l&&a||0===a&&l)return n=0===l&&a?a/2:l/2,c.rx=n,c.ry=n,0===l&&a?(c.cx=e,c.cy=r+a/2,c.startAngle=t>h?p:-p,c.endAngle=t>h?-p:p,c.deltaAngle=u?Math.PI:-Math.PI):0===a&&l&&(c.cx=s+l/2,c.cy=t,c.startAngle=e>y?Math.PI:0,c.endAngle=e>y?-Math.PI:Math.PI,c.deltaAngle=u?Math.PI:-Math.PI),c}let x,f,g=a===n?0:s*m/180,M=g?v(g):0,b=g?i(g):1,A=(e-y)/2,C=(t-h)/2,w=(e+y)/2,L=(t+h)/2,P=g?b*A+M*C:A,k=g?b*C-M*A:C,I=P*P/(a*a)+k*k/(n*n);I>1&&(a*=d(I),n*=d(I),c.rx=a,c.ry=n);let S=a*n,$=a*k,F=n*P,z=$**2+F**2;if(!z)throw Error("start point can not be same as end point");let Q=d(l((S*S-z)/z));p==u&&(Q=-Q);let E=Q*$/n,T=-Q*F/a;x=g?b*E-M*T+w:w+E,f=g?M*E+b*T+L:L+T,c.cy=f,c.cx=x;let D=o(x,f,e,t),q=o(x,f,y,h);!u&&q>D&&(q-=2*Math.PI),u&&D>q&&(q=q<=0?q+2*Math.PI:q);let j=q-D;return c.startAngle=D,c.endAngle=q,c.deltaAngle=j,c}function S(e,t,l,a=0,n=!1){return a?(a=n?a/180*Math.PI:a,{x:t+(e.x-t)*Math.cos(a)-(e.y-l)*Math.sin(a),y:l+(e.x-t)*Math.sin(a)+(e.y-l)*Math.cos(a)}):e}function $(e,t,l,a,n,r=0,p=!0,u=!1){if(n=u?n*m/180:n,r=u?r*m/180:r,r=l!==a&&r!==2*m?r:0,p&&l!==a){let e=s(M(n=r?n-r:n)*(l/a));n=i(n)<0?e+m:e}let y=e+l*i(n),h=t+a*v(n),o={x:y,y:h};return r&&(o.x=e+(y-e)*i(r)-(h-t)*v(r),o.y=t+(y-e)*v(r)+(h-t)*i(r)),o}function F(e,t,l){if(t===l||e%m*.5==0)return e;let a=s(M(e)*(t/l));return a=i(e)<0?a+m:a,a}function z(e,t=[],l=.05){let a=3===t.length,n=t[0]||null,s=a?t[1]:null,r=a?t[2]:t[1],p=.5*Math.PI,i=!1,u=!1,y=n?b(r,n,!0):null;if(i=Math.abs(y%p)<l||Math.abs(y%p-p)<l,a){let e=s?b(s,r,!0):0;u=Math.abs(e%p)<=l||Math.abs(e%p-p)<=l}return i||u}function Q(e){return 4===e.length?function(e,t,l,a){let[n,s,r,p,i,u,y,h]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],o=Math.min(e.y,a.y),c=Math.min(e.x,a.x),x=Math.max(e.x,a.x),f=Math.max(e.y,a.y);if(t.y>=o&&t.y<=f&&l.y>=o&&l.y<=f&&t.x>=c&&t.x<=x&&l.x>=c&&l.x<=x)return[];let g,v,d,M,m,b,A,C,w=[];for(let e=0;e<2;++e)if(0==e?(v=6*n-12*r+6*i,g=-3*n+9*r-9*i+3*y,d=3*r-3*n):(v=6*s-12*p+6*u,g=-3*s+9*p-9*u+3*h,d=3*p-3*s),Math.abs(g)<1e-12){if(Math.abs(v)<1e-12)continue;M=-d/v,0<M&&M<1&&w.push(M)}else A=v*v-4*d*g,A<0?Math.abs(A)<1e-12&&(M=-v/(2*g),0<M&&M<1&&w.push(M)):(C=Math.sqrt(A),m=(-v+C)/(2*g),0<m&&m<1&&w.push(m),b=(-v-C)/(2*g),0<b&&b<1&&w.push(b));let L=w.length;for(;L--;)M=w[L];return w}(e[0],e[1],e[2],e[3]):function(e,t,l){let a,n,s,r=Math.min(e.y,l.y),p=Math.min(e.x,l.x),i=Math.max(e.x,l.x),u=Math.max(e.y,l.y);if(t.y>=r&&t.y<=u&&t.x>=p&&t.x<=i)return[];let[y,h,o,c,x,f]=[e.x,e.y,t.x,t.y,l.x,l.y],g=[];for(let e=0;e<2;++e)a=0==e?y-2*o+x:h-2*c+f,n=0==e?-2*y+2*o:-2*h+2*c,Math.abs(a)>1e-12&&(s=-n/(2*a),s>0&&s<1&&g.push(s));return g}(e[0],e[1],e[2])}function E(e,t){const l=(e,t,l,a,n,s)=>{var r=Math.cos(s),p=Math.sin(s),i=a*Math.cos(e),u=n*Math.sin(e);return{x:t+r*i-p*u,y:l+p*i+r*u}};let a,n,s,r,p,i=I(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:u,ry:y,cx:h,cy:o,endAngle:c,deltaAngle:x}=i,f=t[2],g={x:t[5],y:t[6]},v=[g],d=f*Math.PI/180,M=Math.tan(d);p=Math.atan2(-y*M,u);let m=p,b=p+Math.PI,A=Math.atan2(y,u*M),C=A+Math.PI,w=[e.x,g.x],L=[e.y,g.y],P=Math.min(...w),k=Math.max(...w),S=Math.min(...L),$=Math.max(...L),F=l(c-.001*x,h,o,u,y,d),z=l(c-.999*x,h,o,u,y,d);return(F.x>k||z.x>k)&&(a=l(m,h,o,u,y,d),v.push(a)),(F.x<P||z.x<P)&&(n=l(b,h,o,u,y,d),v.push(n)),(F.y<S||z.y<S)&&(r=l(C,h,o,u,y,d),v.push(r)),(F.y>$||z.y>$)&&(s=l(A,h,o,u,y,d),v.push(s)),v}function T(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function D(e){let t=[],l=[e[0]],a=e.length;for(let n=1;n<a;n++){let a=e[n];"M"!==a.type&&"m"!==a.type||(t.push(l),l=[]),l.push(a)}return l.length&&t.push(l),t}function q(e,t){let l,a,n,s,r,p,i=[],u=[],y=e[0],h=e[1],o=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=k([y,h],t),a=k([h,o],t),n=k([o,c],t),s=k([l,a],t),r=k([a,n],t),p=k([s,r],t),i.push({x:y.x,y:y.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:p.x,y:p.y}),u.push({x:p.x,y:p.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=k([y,h],t),n=k([h,c],t),p=k([a,n],t),i.push({x:y.x,y:y.y},{x:a.x,y:a.y},{x:p.x,y:p.y}),u.push({x:p.x,y:p.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=k([y,c],t),i.push({x:y.x,y:y.y},{x:a.x,y:a.y}),u.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[i,u]}function j(e,t,l=0,a=1){let n=[],s=6===t.length?"C":"Q",r={x:t[0],y:t[1]},p="C"===s?{x:t[2],y:t[3]}:r,i={x:t[4],y:t[5]},u=Math.max(i.x,e.x),y=Math.min(i.x,e.x),h=Math.max(i.y,e.y),o=Math.min(i.y,e.y),c=0;if(r.x<y||r.x>u||r.y<o||r.y>h||p.x<y||p.x>u||p.y<o||p.y>h){let u=Q("C"===s?[e,r,p,i]:[e,r,i]).sort();if(u=u.filter(e=>e>l&&e<a),u.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let s,r,p,i=t.length,u={x:t[i-2],y:t[i-1]};2===t.length?p=[e,u]:4===t.length?(s={x:t[0],y:t[1]},p=[e,s,u]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},p=[e,s,r,u]);if(l.length)if(1===l.length){let e=q(p,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=q(p,e),a=t[0];n.push(a),p=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=q(p,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),p=a[1]}}if(a){let e,t,l=[];return n.forEach(a=>{e={type:"",values:[]},a.shift(),t=a.map(e=>Object.values(e)).flat(),e.values=t,3===a.length?e.type="C":2===a.length?e.type="Q":1===a.length&&(e.type="L"),l.push(e)}),l}return n}(e,t,u);n.push(...l),c+=l.length}else n.push({type:s,values:t})}else n.push({type:s,values:t});return{pathData:n,count:c}}function Z(e,t=0,l=1){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s={x:e[0].values[0],y:e[0].values[1]},r=e.length;for(let p=1;r&&p<r;p++){let r=e[p],{type:i,values:u}=r,y=u.slice(-2);if(y[0],y[1],"C"!==i&&"Q"!==i)a.push(r);else if("C"===i||"Q"===i){let e=j(n,u,t,l).pathData;a.push(...e)}n={x:y[0],y:y[1]},"z"===i.toLowerCase()?n=s:"M"===i&&(s={x:y[0],y:y[1]})}return a}function B(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),s=Math.max(...l),r=Math.min(...a),p=Math.max(...a),i={x:n,left:n,right:s,y:r,top:r,bottom:p,width:s-n,height:p-r};if(t>-1)for(let e in i)i[e]=+i[e].toFixed(t);return i}function N(e){let t=[];return e.forEach(e=>{let l=function(e){let t=function(e){let t=[];for(let l=0;l<e.length;l++){let a=e[l],n=l>0?e[l-1]:e[l],{type:s,values:r}=a,p={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},i=r.length?{x:r[r.length-2],y:r[r.length-1]}:"",u=r.length?{x:r[0],y:r[1]}:"";switch(s){case"A":if("function"!=typeof arcToBezier){let e=w(p,i)/2,l=P(p,i,.5),a=$(l.x,l.y,e,e,0),n=$(l.x,l.y,e,e,Math.PI);t.push(a,n,i);break}arcToBezier(p,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},s={x:l[4],y:l[5]};t.push(a,n,s)});break;case"C":let e={x:r[2],y:r[3]};t.push(u,e);break;case"Q":t.push(u)}"z"!==s.toLowerCase()&&t.push(i)}return t}(e),l=B(t);return l}(e);t.push(l)}),t}function O(e,t){let[l,a,n,s,r,p]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[i,u,y,h,o,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=y*h&&n*s>y*h&&l<i&&r>o&&a<u&&p>c&&(x=!0),x}function R(e,t=9){let l=0,a=[],n=D(e),s=n.length>1,r=[];if(s){let e=N(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){O(t,a)&&r.push(l)}}})}return n.forEach((e,t)=>{a=[];let n=0,s=0,p=1,i=[];e.forEach(function(t,l){let[s,r]=[t.type,t.values],p=r.length;if(r.length){let u=(l>0?e[l-1]:e[0]).values,y=u.length,h={x:u[y-2],y:u[y-1]},o={x:r[p-2],y:r[p-1]};if("C"===s||"Q"===s){let e={x:r[0],y:r[1]};i="C"===s?[h,e,{x:r[2],y:r[3]},o]:[h,e,o];let t=Math.abs(function(e,t=!1){let l,[a,n,s,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(n={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},s={x:1*e[2].x/3+2*e[1].x/3,y:1*e[2].y/3+2*e[1].y/3});return l=3*(a.x*(-2*n.y-s.y+3*r.y)+n.x*(2*a.y-s.y-r.y)+s.x*(a.y+n.y-2*r.y)+r.x*(-3*a.y+n.y+2*s.y))/20,t?Math.abs(l):l}(i));n+=t,a.push(h,o)}else if("A"===s){let e=I(h.x,h.y,t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],o.x,o.y),{cx:l,cy:s,rx:r,ry:p,startAngle:i,endAngle:u,deltaAngle:y}=e,c=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let s=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(s/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),s=(a-l+2*Math.PI)%(2*Math.PI),n*(s/(2*Math.PI))}(r,p,i,u));c-=Math.abs(H([h,{x:l,y:s},o])),a.push(h,o),n+=c}else a.push(h,o)}});let u=H(a);-1!==r.indexOf(t)&&(p=-1),s=u<0&&n<0?(Math.abs(n)-Math.abs(u))*p:(Math.abs(n)+Math.abs(u))*p,l+=s}),l}function H(e,t=!1){let l=0;for(let t=0,a=e.length;a&&t<a;t++){l+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}return t&&(l=Math.abs(l)),l}function U(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,s="",r=a?"\n":n?"":" ",p=n?"":" ";s=`${e[0].type}${p}${e[0].values.join(" ")}${r}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:i,values:u}=a;if(!n||"A"!==i&&"a"!==i||(u=[u[0],u[1],u[2],`${u[3]}${u[4]}${u[5]}`,u[6]]),i=n&&l.type===a.type&&"m"!==a.type.toLowerCase()||n&&"M"===l.type&&"L"===a.type?" ":a.type,n){let e="",t=!1;for(let l=0,a=u.length;l<a;l++){let a=u[l],n=a.toString(),s=n.includes(".")&&Math.abs(a)<1;s&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&s||(e+=" "),e+=n,t=s}s+=`${i}${p}${e}${r}`}else s+=`${i}${p}${u.join(" ")}${r}`}return n&&(s=s.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function V(e,l,a=0,n=1,s=!1){const r=(e,t,l,a,n)=>{let s=1-n;return{x:3*s*s*(t.x-e.x)+6*s*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*s*s*(t.y-e.y)+6*s*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let p=[e,l],i=T(e.p0,e.p)>T(l.p0,l.p),u=JSON.parse(JSON.stringify(e)),y=JSON.parse(JSON.stringify(l)),h=C(u.p0,u.cp1,y.p,y.cp2,!1);if(!h)return p;if(i){let t={p0:{x:e.p.x,y:e.p.y},cp1:{x:e.cp2.x,y:e.cp2.y},cp2:{x:e.cp1.x,y:e.cp1.y},p:{x:e.p0.x,y:e.p0.y}};e={p0:{x:l.p.x,y:l.p.y},cp1:{x:l.cp2.x,y:l.cp2.y},cp2:{x:l.cp1.x,y:l.cp1.y},p:{x:l.p0.x,y:l.p0.y}},l=t}let o=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),c=(e,t)=>({x:e.x*t,y:e.y*t}),x=(e,t)=>e.x*t.x+e.y*t.y,f=l.p0,g=r(l.p0,l.cp1,l.cp2,l.p,0),v=x(o(e.p0,f),g)/x(g,g),d=k([l.p0,l.cp1,l.cp2,l.p],v),M=r(l.p0,l.cp1,l.cp2,l.p,v);v-=x(o(d,e.p0),M)/x(M,M);let m=k([l.p0,l.cp1,l.cp2,l.p],v),b=l.p,A=r(l.p0,l.cp1,l.cp2,l.p,v),w=r(l.p0,l.cp1,l.cp2,l.p,1),L=1-v,I=(S=m,$=c(A,L/3),{x:S.x+$.x,y:S.y+$.y});var S,$;let F=o(b,c(w,L/3)),z={p0:m,cp1:I,cp2:F,p:b,t0:v};i&&(z={p0:b,cp1:F,cp2:I,p:m,t0:v});let Q=.5*(1-v),E=k([z.p0,z.cp1,z.cp2,z.p],Q,!1,!0),D=E.cpts[2],q=C(E,D,z.p0,h,!1),j=C(E,D,z.p,h,!1),Z=P(z.p0,q,1.333),B=P(z.p,j,1.333);if(C(u.p0,Z,y.p,B,!0))return p;s&&function(e,t,l="red",a="1%",n="1",s="",r=!0,p="",i=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let u=`<circle class="${i}" opacity="${n}" id="${p}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return u;e.insertAdjacentHTML("beforeend",u)}(markers,E,"purple"),z.cp1=Z,z.cp2=B;let N=T(u.p0,z.p0)+T(y.p,z.p);if(z.p0=u.p0,z.p=y.p,z.extreme=y.extreme,z.corner=y.corner,z.dimA=y.dimA,z.directionChange=y.directionChange,z.type="C",z.values=[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y],N<a){let l=i?1+v:Math.abs(v),r=1+Math.abs(v);if(l=i?1+v:Math.abs(v)/r,T(k([z.p0,z.cp1,z.cp2,z.p],l),e.p)>a*n)return p;let h=R([{type:"M",values:[u.p0.x,u.p0.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]},{type:"C",values:[y.cp1.x,y.cp1.y,y.cp2.x,y.cp2.y,y.p.x,y.p.y]}]),o=[{type:"M",values:[z.p0.x,z.p0.y]},{type:"C",values:[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y]}],c=R(o),x=Math.abs(c/h-1);if(z.error=5*x*n,s){let e=U(o);t(markers,e,"orange")}x<.05*n&&(p=[z])}return p}function J(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1}={}){let r=[e[0]],p=e.length;for(let n=2;p&&n<=p;n++){let i=e[n-1],u=n<p?e[n]:null,y=u?.type||null,h=i?.directionChange||null,o=u?.directionChange||null,{type:c,values:x,p0:f,p:g,cp1:v=null,cp2:d=null,extreme:M=!1,corner:m=!1,dimA:b=0}=i;if("C"===c&&"C"===y)if(l&&o||a&&m||!h&&t&&M)r.push(i);else{let y=W(i,u,{tolerance:s}),h=0;if(1===y.length){i=y[0];let u=1;h+=i.error;for(let r=n+1;h<s&&r<p;r++){let n=e[r];if("C"!==n.type||l&&n.directionChange||a&&i.corner||t&&i.extreme)break;let p=W(i,n,{tolerance:s});1===p.length&&(h+=.5*p[0].error,u++),i=p[0]}r.push(i),n<p&&(n+=u)}else r.push(i)}else r.push(i)}return r}function W(e,t,{tolerance:l=1}={}){let a=[e,t],n=function(e,t){let l=w(e.cp2,e.p),a=w(e.cp2,t.cp1),n=Math.min(l)/a;return n}(e,t),s=T(e.p0,e.p),r=T(t.p0,t.p),p=.06*Math.max(0,Math.min(s,r))*l,i=function(e,t,l=0){let{p0:a,cp1:n}=e,{p:s,cp2:r}=t;return n={x:(n.x-(1-l)*a.x)/l,y:(n.y-(1-l)*a.y)/l},r={x:(r.x-l*s.x)/(1-l),y:(r.y-l*s.y)/(1-l)},{p0:a,cp1:n,cp2:r,p:s}}(e,t,n),u=k([i.p0,i.cp1,i.cp2,i.p],n),y=T(e.p,u),h=0,o=0,c=!1,x=y;if(y<p){let l=.5*(1+n);if(h=T(k([t.p0,t.cp1,t.cp2,t.p],.5),k([i.p0,i.cp1,i.cp2,i.p],l)),x+=h,h<p){let t=.5*n;o=T(k([e.p0,e.cp1,e.cp2,e.p],.5),k([i.p0,i.cp1,i.cp2,i.p],t)),h+o<p&&(c=!0),x+=o}}return c&&(i.p0=e.p0,i.p=t.p,i.dimA=T(i.p0,i.p),i.type="C",i.extreme=t.extreme,i.directionChange=t.directionChange,i.corner=t.corner,i.values=[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y],i.error=x/p,a=[i]),a}function X(e,{tolerance:t=1,debug:l=!1}={}){let a=!1,n={flat:!0,steepness:0},s=e[0],r=e[e.length-1],p=new Set([...e.map(e=>+e.x.toFixed(8))]),i=new Set([...e.map(e=>+e.y.toFixed(8))]);if(1===p.size||1===i.size)return!l||n;let u=L(s,r),y=u/1e3*t,h=H(e,!0);return h<y&&(a=!0),l&&(n.flat=a,n.steepness=h/u*10),l?n:a}function Y(e=[]){let t,l=[],a=function(e){let t=[],l={x:e[0].values[0],y:e[0].values[1]};return e.forEach(e=>{let{type:a,values:n}=e;if(n.length){let e=n.length>1?{x:n[n.length-2],y:n[n.length-1]}:"V"===a?{x:l.x,y:n[0]}:{x:n[0],y:l.y};t.push(e),l=e}}),t}(e),n=B(a),{left:s,right:r,top:p,bottom:i,width:u,height:y}=n,h=e[0].values[0],o=e[0].values[1],c={x:e[0].values[0],y:e[0].values[1]},x={x:e[0].values[0],y:e[0].values[1]};e[0].idx=0,e[0].p0=c,e[0].p=c,e[0].lineto=!1,e[0].corner=!1,e[0].extreme=!1,e[0].directionChange=!1,e[0].closePath=!1,e[0].dimA=0;let f=[e[0]],g=0,v=e.length;for(let l=2;v&&l<=v;l++){let a=e[l-1],{type:n,values:u}=a,y=u.slice(-2),v=[x];a.idx=l-1,a.lineto=!1,a.corner=!1,a.extreme=!1,a.directionChange=!1,a.closePath=!1,a.dimA=0;let d,M,m,A,C,w,P=.05;t=y.length?{x:y[0],y:y[1]}:c,"M"===n?(c=t,x=t):"z"===n.toLowerCase()&&(t=c),a.p0=x,a.p=t;let k=T(x,t);a.dimA=k,"L"===n&&(a.lineto=!0),"Z"===n&&(a.closePath=!0,c.x!==h&&c.y!==o&&(a.lineto=!0)),"Q"!==n&&"C"!==n||(d={x:u[0],y:u[1]},M="C"===n?{x:u[2],y:u[3]}:null,a.cp1=d,M&&(a.cp2=M)),u.length>2&&("Q"!==n&&"C"!==n||v.push(d),"C"===n&&v.push(M),v.push(t)),"L"===n||t.x!==s&&t.y!==p&&t.x!==r&&t.y!==i||(a.extreme=!0);let I=e[l]?e[l]:null,S=I?I.values.slice(-2):null;C=I?I.type:null,!I||"Q"!==I.type&&"C"!==I.type||(A=I?{x:S[0],y:S[1]}:null,m={x:I.values[0],y:I.values[1]},"C"===I.type&&(I.values[2],I.values[3])),w=H(v);let $=g<0&&w>0||g>0&&w<0;if(g=w,$&&(a.directionChange=!0),("Q"===n||"C"===n)&&("Q"===n&&"Q"===C||"C"===n&&"C"===C)){let e=v.slice(1);if(A&&Math.abs(A.x-x.x),A&&Math.abs(A.y-x.y),!!a.extreme||z(0,e,P))a.extreme=!0;else{let e=M?[M,t]:[d,t],l=[t,m],n=b(...e,!0),s=b(...l,!0),r=180*Math.abs(n-s)/Math.PI,p=L(...e),i=L(...l);r>10&&p&&i&&(a.corner=!0)}}f.push(a),x=t}return l={pathData:f,bb:n,dimA:(u+y)/2},l}function G(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=[];for(let s=0,r=e.length;s<r;s++){let r=e[s],{type:p,values:i}=r,u=i.length?i.slice(-2):[t.x,t.y];a={x:u[0],y:u[1]};let y=r.dimA?+r.dimA.toFixed(8):"M"!==p?+T(l,a).toFixed(8):0;y&&n.push(y),"M"===p&&(t=a),l=a}let s=n.sort(),r=Math.ceil(s.length/10);s=s.slice(0,r);let p=s.reduce((e,t)=>e+t,0)/r,i=p>60?0:Math.floor(40/p).toString().length;return Math.min(Math.max(0,i),8)}function K(e,t=-1){let l=e.length;for(let a=0;a<l;a++){let l=e[a].values,n=l.length;if(n&&t>-1)for(let s=0;s<n;s++)e[a].values[s]=+l[s].toFixed(t)}return e}function _(e={},t={},l={},a={}){let n=P(e,t,1.5),s=P(a,l,1.5),r=.03*T(e,a),p=T(n,s),i=null,u={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return p&&r&&p<r&&(i=C(e,t,a,l,!1),i&&(u.type="Q",u.values=[i.x,i.y,a.x,a.y],u.p0=e,u.cp1=i,u.cp2=null,u.p=a)),u}function ee(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!1){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?le(e):e;let n=e.length,s=new Array(n),r={type:"M",values:e[0].values};s[0]=r;let p,i={x:e[0].values[0],y:e[0].values[1]},u=.01;for(let l=1;l<n;l++){let a=e[l],{type:n,values:y}=a,h=y.length,o=[y[h-2],y[h-1]],c=e[l-1],x=c.type;p={x:o[0],y:o[1]};let f,g,v,d,M={x:y[0],y:y[1]},m=Math.abs(p.x-i.x),b=Math.abs(p.y-i.y),A=(m+b)/2*u;switch(n){case"L":r=0===b||b<A&&m>A?{type:"H",values:[y[0]]}:0===m||b>A&&m<A?{type:"V",values:[y[1]]}:a;break;case"Q":if("Q"!==x){i={x:o[0],y:o[1]},s[l]=a;continue}let e={x:c.values[0],y:c.values[1]};d={x:2*i.x-e.x,y:2*i.y-e.y},f=Math.abs(M.x-d.x),g=Math.abs(M.y-d.y),v=(f+g)/2,r=v<A?{type:"T",values:[p.x,p.y]}:a;break;case"C":let t={x:y[2],y:y[3]};if("C"!==x){s[l]=a,i={x:o[0],y:o[1]};continue}let u={x:c.values[2],y:c.values[3]};d={x:2*i.x-u.x,y:2*i.y-u.y},f=Math.abs(M.x-d.x),g=Math.abs(M.y-d.y),v=(f+g)/2,r=v<A?{type:"S",values:[t.x,t.y,p.x,p.y]}:a;break;default:r={type:n,values:y}}(a.decimals||0===a.decimals)&&(r.decimals=a.decimals),t>-1&&(r.values=r.values.map(e=>+e.toFixed(t))),i={x:o[0],y:o[1]},s[l]=r}return s}(e)),a>-1&&l&&(e=K(e,a)),l&&(e=function(e,t=-1){return le(e,!0,t)}(e)),a>-1&&(e=K(e,a)),e}function te(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let l={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},a={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[l.x,l.y,a.x,a.y,t[2],t[3]]}}function le(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e[0].values,n=a[0],s=a[1],r=n,p=s;for(let a=1,i=e.length;a<i;a++){let i=e[a],{type:u,values:y}=i,h=t?u.toLowerCase():u.toUpperCase();if(u!==h)switch(u=h,i.type=u,u){case"a":case"A":y[5]=t?y[5]-n:y[5]+n,y[6]=t?y[6]-s:y[6]+s;break;case"v":case"V":y[0]=t?y[0]-s:y[0]+s;break;case"h":case"H":y[0]=t?y[0]-n:y[0]+n;break;case"m":case"M":t?(y[0]-=n,y[1]-=s):(y[0]+=n,y[1]+=s),r=t?y[0]+n:y[0],p=t?y[1]+s:y[1];break;default:if(y.length)for(let e=0;e<y.length;e++)y[e]=t?y[e]-(e%2?s:n):y[e]+(e%2?s:n)}let o=y.length;switch(u){case"z":case"Z":n=r,s=p;break;case"h":case"H":n=t?n+y[0]:y[0];break;case"v":case"V":s=t?s+y[0]:y[0];break;case"m":case"M":r=y[o-2]+(t?n:0),p=y[o-1]+(t?s:0);default:n=y[o-2]+(t?n:0),s=y[o-1]+(t?s:0)}l>=0&&(i.values=i.values.map(e=>+e.toFixed(l)))}return e}function ae(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}e=l&&a?function(e,t=-1){return le(e,!1,t)}(e,t):e;let n=[],s={type:"M",values:e[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,p,i,u,y,h,o,c=e[l],{type:x,values:f}=c,g=f.length,v=s.values,d=v.length,[M,m]=[f[g-2],f[g-1]],[b,A]=[v[d-2],v[d-1]];switch(x){case"H":s={type:"L",values:[f[0],A]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],p=b+(b-a),i=A+(A-r),s={type:"Q",values:[p,i,M,m]};break;case"S":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],[h,o]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,A],p=2*b-h,i=2*A-o,u=f[0],y=f[1],s={type:"C",values:[p,i,u,y,M,m]};break;default:s={type:x,values:f}}t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),n.push(s)}return n}function ne({p0:e={x:0,y:0},p:t={x:0,y:0},centroid:l={x:0,y:0},rx:a=0,ry:n=0,xAxisRotation:s=0,radToDegree:r=!1,startAngle:p=null,endAngle:i=null,deltaAngle:u=null}={}){if(!a||!n)return[];let y=[];const h=1.5707963267948966;let o=r?s:s*Math.PI/180,c=Math.cos(o),x=Math.sin(o);null!==p&&null!==i&&null!==u||({startAngle:p,endAngle:i,deltaAngle:u}=A(l,e,t));let f=a!==n?F(p,a,n):p,g=a!==n?F(u,a,n):u,v=Math.max(1,Math.ceil(Math.abs(g)/h)),d=g/v;for(let e=0;e<v;e++){const e=Math.abs(d)===h?.551785*Math.sign(d):4/3*Math.tan(d/4);let t=Math.cos(f),s=Math.sin(f),r=Math.cos(f+d),p=Math.sin(f+d),i=[];[{x:t-s*e,y:s+t*e},{x:r+p*e,y:p-r*e},{x:r,y:p}].forEach(e=>{let t=e.x*a,s=e.y*n;i.push(c*t-x*s+l.x,x*t+c*s+l.y)}),y.push({type:"C",values:i,cp1:{x:i[0],y:i[1]},cp2:{x:i[2],y:i[3]},p:{x:i[4],y:i[5]}}),f+=d}return y}function se(e,t,l=1){const a=2*Math.PI;let[n,s,r,p,i,u,y]=t;if(0===n||0===s)return[];let h=r?r*a/360:0,o=h?Math.sin(h):0,c=h?Math.cos(h):1,x=c*(e.x-u)/2+o*(e.y-y)/2,f=-o*(e.x-u)/2+c*(e.y-y)/2;if(0===x&&0===f)return[];n=Math.abs(n),s=Math.abs(s);let g=x*x/(n*n)+f*f/(s*s);if(g>1){let e=Math.sqrt(g);n*=e,s*=e}let v=n*n,d=n===s?v:s*s,M=x*x,m=f*f,b=v*d-v*m-d*M;b<=0?b=0:(b/=v*m+d*M,b=Math.sqrt(b)*(p===i?-1:1));let A=b?b*n/s*f:0,C=b?b*-s/n*x:0,w=c*A-o*C+(e.x+u)/2,L=o*A+c*C+(e.y+y)/2,P=(x-A)/n,k=(f-C)/s,I=(-x-A)/n,S=(-f-C)/s;const $=(e,t,l,a)=>{let n=+(e*l+t*a).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*a-t*l<0?-1:1)*Math.acos(n))};let F=$(1,0,P,k),z=$(P,k,I,S);0===i&&z>0?z-=2*Math.PI:1===i&&z<0&&(z+=2*Math.PI);let Q=(+(Math.abs(z)/(a/4)).toFixed(0)||1)*l;z/=Q;let E=[];const T=1.5707963267948966,D=.551785;let q=z===T?D:z===-T?-D:4/3*Math.tan(z/4),j=z?Math.cos(z):1,Z=z?Math.sin(z):0;const B=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,p=Math.cos(e+t),i=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:p+i*l,y:i-p*l},{x:p,y:i}]};for(let e=0;e<Q;e++){let e={type:"C",values:[]};B(F,z,q,j,Z).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-o*a+w,o*l+c*a+L)}),E.push(e),F+=z}return E}function re(e,t,l,a,n=7.5){let s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},r=0,p=!1,i=b(e,t,!0),u=b(a,l,!0),y=180*Math.abs(i-u)/Math.PI;if(Math.abs(y%180-90)<3){let i=C(e,t,a,l,!1);if(i){let u=w(e,i),y=w(a,i),h=+Math.max(u,y).toFixed(8),o=+Math.min(u,y).toFixed(8),c=o,x=h,f=H([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/c*Math.abs(c-x)<5&&(c=h,x=c),g&&(c=h,x=o);let v=R([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),d={type:"A",values:[c,x,0,0,f,a.x,a.y]};r=Math.PI*(c*x)/4,r-=Math.abs(H([e,a,i])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<n&&(p=!0,s=d)}}return{com:s,isArc:p,area:r}}function pe(e){let t,l=[[]],a=0,n=[[]],s={x:e[0].values[0],y:e[0].values[1]};for(let r=0,p=e.length;r<p;r++){let p=e[r],{type:i,values:u}=p;if("A"===i){let i=e[r-1].values.slice(-2);s={x:i[0],y:i[1]};let[y,h,o,c,x,f,g]=u,v=100/y*Math.abs(y-h)<5;t={x:u[5],y:u[6]},p.p0=s,p.p=t,p.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(p),n[a].push(r)),d&&"A"===d.type){let[e,p,i,u,o,c,x]=d.values,f=y!=e?100/y*Math.abs(y-e):0,g=h!=p?100/h*Math.abs(h-p):0;t={x:d.values[5],y:d.values[6]},d.p0=s,d.p=t,f<5&&g<5?(l[a].push(d),n[a].push(r+1)):(l.push([]),n.push([]),a++)}else l.push([]),n.push([]),a++}}if(!n.length)return e;l=l.filter(e=>e.length),n=n.filter(e=>e.length);for(let t=l.length-1;t>=0;t--){const a=l[t],s=n[t][0],r=a.length;let p=0,i=0;a.forEach(({values:e})=>{const[t,l]=e;p+=t,i+=l}),p/=r,i/=r;let u=100/p*Math.abs(p-i)<5;u&&(p=(p+i)/2,i=p);let y=e[s-1].values.slice(-2);if(y[0],y[1],4===r){let[t,l,n,y,h,o,c]=a[1].values,[,,,,,x,f]=a[3].values;u&&(p=1,i=1);let g={type:"A",values:[p,i,n,y,h,o,c]},v={type:"A",values:[p,i,n,y,h,x,f]};e.splice(s,r,g,v)}else if(3===r){let[t,l,n,u,y,h,o]=a[0].values,[c,x,,,,f,g]=a[2].values;u=1;let v={type:"A",values:[p,i,n,u,y,f,g]};e.splice(s,r,v)}else if(2===r){let[t,l,n,y,h,o,c]=a[0].values,[x,f,,,,g,v]=a[1].values;u&&(p=1,i=1,n=0);let{p0:d,p:M}=a[0],[m,b]=[a[1].p0,a[1].p];if(d.x!==b.x||d.y!==b.y){let t={type:"A",values:[p,i,n,y,h,g,v]};e.splice(s,r,t)}}}return e}function ie(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2,hasRelatives:r=!0,hasShorthands:p=!0,hasQuadratics:i=!0,hasArcs:u=!0,testTypes:y=!1}={}){if(y){let t=Array.from(new Set(e.map(e=>e.type))).join("");r=/[lcqamts]/gi.test(t),i=/[qt]/gi.test(t),u=/[a]/gi.test(t),p=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(i&&a||u&&n)&&(l=!0,t=!0),r&&t&&(e=le(e,!1)),p&&l&&(e=ae(e,-1,!1)),u&&n&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],s=e[a-1].values,r=s.length,p={x:s[r-2],y:s[r-1]};"A"===n.type?se(p,n.values,t).forEach(e=>{l.push(e)}):l.push(n)}return l}(e,s)),i&&a&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,s=n.length,r={x:n[s-2],y:n[s-1]};"Q"===a.type?t.push(te(r,a.values)):t.push(a)}return t}(e)),e}function ue(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=Array.isArray(e),p=r&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,i=r?e:function(e,t=!0){if(e=e.trim(),""===e)return{pathData:[],hasRelatives:!1,hasShorthands:!1,hasQuadratics:!1,hasArcs:!1};const l=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),a=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&l.has(e);let n,s=0,r=e.length,p="",i=[],u=-1,y="",h=!1,o=0,c=0,x=0,f=!1,g=new Set([]),v=[];const d=()=>{f&&("M"===p?p="L":"m"===p&&(p="l"),i.push({type:p,values:[]}),u++,c=0,f=!1)},M=(e=!1)=>{(e?o>0:""!==y)&&(t&&-1===u&&(n="Pathdata must start with M command",v.push(n),p="M",i.push({type:p,values:[]}),x=2,c=0,u++),"A"===p||"a"===p?(y=m(),i[u].values.push(...y)):(t&&y[1]&&"."!==y[1]&&"0"===y[0]&&(n=`${u}. command: Leading zeros not valid: ${y}`,v.push(n)),i[u].values.push(+y)),c++,y="",o=0,f=c>=x)},m=()=>{let e=y.length,t=!1;return 3===c&&2===e||4===c&&e>1?(y=[+y[0],+y[1]],t=!0,c++):3===c&&e>=3&&(y=[+y[0],+y[1],+y.substring(2)],t=!0,c+=2),t?y:[+y]},b=()=>{if(u>0){let e=i[u].values.length;if(e&&e<x||e&&e>x||("z"===p||"Z"===p)&&e>0){n=`${u}. command of type "${p}": ${x-e} values too few - ${x} expected`,v[v.length-1]!==n&&v.push(n)}}};let A=!1,C=!1,w=!1;for(;s<r;){let l=e.charCodeAt(s),r=l>47&&l<58;if(r||(A=101===l||69===l,C=45===l||43===l,w=46===l),r||C||w||A){if(h||45!==l&&46!==l)d();else{let e=46===l;M(e),d(),e&&o++}y+=e[s],h=A,s++}else if((l<48||l>5759)&&a(l))M(),s++;else{if(l>64){if(!ye.has(l)){n=`${u}. command "${e[s]}" is not a valid type`,v.push(n),s++;continue}""!==y&&(i[u].values.push(+y),c++,y=""),t&&b(),p=e[s],x=he[l];let a="M"===p||"m"===p,r=u>0&&("z"===i[u].type||"Z"===i[u].type);g.add(p),r&&!a&&(i.push({type:"m",values:[0,0]}),u++),i.push({type:p,values:[]}),u++,o=0,c=0,f=!1,s++;continue}r||(n=`${u}. ${e[s]} is not a valid separarator or token`,v.push(n),y=""),s++}}M(),t&&b();t&&v.length&&(n="Invalid path data:\n"+v.join("\n"),"log"===t?console.log(n):console.warn(n));i[0].type="M";let L=Array.from(g).join(""),P=/[lcqamts]/g.test(L),k=/[vhst]/gi.test(L),I=/[a]/gi.test(L),S=/[qt]/gi.test(L);return{pathData:i,hasRelatives:P,hasShorthands:k,hasQuadratics:S,hasArcs:I}}(e),{hasRelatives:u=!0,hasShorthands:y=!0,hasQuadratics:h=!0,hasArcs:o=!0}=i,c=p?i:i.pathData;return c=ie(c,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s,hasRelatives:u,hasShorthands:y,hasQuadratics:h,hasArcs:o}),c}const ye=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),he=new Uint8Array(128);function oe(e){if("path"===e.nodeName.toLowerCase())return e;let t=function(e,t=!1){let l,a,n,s,r,p,i,u,y,h,o,c,x,f,g,v,d=[],M=e.nodeName;const m=(e,t=9)=>{const l="svg"!==e.nodeName?e.closest("svg"):e,a=e=>{if(null===e)return 0;let l=96,a=e.match(/([a-z]+)/gi);a=a?a[0]:"";let n,s=parseFloat(e);if(!a)return s;switch(a){case"in":n=l;break;case"pt":n=1/72*96;break;case"cm":n=1/2.54*96;break;case"mm":n=1/2.54*96/10;break;case"em":case"rem":n=16;break;default:n=1}return+(s*n).toFixed(t)};let n=l.getAttribute("width");n=n?a(n):300;let s=l.getAttribute("height");s=n?a(s):150;let r=l.getAttribute("viewBox");r=r?r.replace(/,/g," ").split(" ").filter(Boolean).map(e=>+e):[];let p=r.length?r[2]:n,i=r.length?r[3]:s,u=p/100,y=i/100,h=Math.sqrt((Math.pow(u,2)+Math.pow(y,2))/2),o=["x","width","x1","x2","rx","cx","r"],c=["y","height","y1","y2","ry","cy"];e.getAttributeNames().forEach(t=>{let l=e.getAttribute(t),n=l;if(o.includes(t)||c.includes(t)){let s=o.includes(t)?u:y;s="r"===t&&p!=i?h:s;let r=l.match(/([a-z|%]+)/gi);r=r?r[0]:"",n=l.includes("%")?parseFloat(l)*s:a(l),e.setAttribute(t,+n)}})};m(e);const b=t=>(l={},t.forEach(t=>{l[t]=+e.getAttribute(t)}),l);switch(M){case"path":n=e.getAttribute("d"),d=ue(n);break;case"rect":a=["x","y","width","height","rx","ry"],({x:s,y:r,width:p,height:i,rx:y,ry:h}=b(a)),y||h?(y>p/2&&(y=p/2),h>i/2&&(h=i/2),d=[{type:"M",values:[s+y,r]},{type:"L",values:[s+p-y,r]},{type:"A",values:[y,h,0,0,1,s+p,r+h]},{type:"L",values:[s+p,r+i-h]},{type:"A",values:[y,h,0,0,1,s+p-y,r+i]},{type:"L",values:[s+y,r+i]},{type:"A",values:[y,h,0,0,1,s,r+i-h]},{type:"L",values:[s,r+h]},{type:"A",values:[y,h,0,0,1,s+y,r]},{type:"Z",values:[]}]):d=[{type:"M",values:[s,r]},{type:"L",values:[s+p,r]},{type:"L",values:[s+p,r+i]},{type:"L",values:[s,r+i]},{type:"Z",values:[]}];break;case"circle":case"ellipse":a=["cx","cy","rx","ry","r"],({cx:o,cy:c,r:u,rx:y,ry:h}=b(a));let t="circle"===M;t?(y=u,h=u):(y=y||u,h=h||u);let l=t&&u>=1?1:y,m=t&&u>=1?1:y;d=[{type:"M",values:[o+y,c]},{type:"A",values:[l,m,0,1,1,o-y,c]},{type:"A",values:[l,m,0,1,1,o+y,c]}];break;case"line":a=["x1","y1","x2","y2"],({x1:x,y1:g,x2:f,y2:v}=b(a)),d=[{type:"M",values:[x,g]},{type:"L",values:[f,v]}];break;case"polygon":case"polyline":let A=e.getAttribute("points").replaceAll(","," ").split(" ").filter(Boolean);for(let e=0;e<A.length;e+=2)d.push({type:0===e?"M":"L",values:[+A[e],+A[e+1]]});"polygon"===M&&d.push({type:"Z",values:[]})}return t?function(e){return e.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ")}(d):d}(e),l=t.map(e=>`${e.type} ${e.values} `).join(" "),a=[...e.attributes].map(e=>e.name),n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",l);let s=["x","y","cx","cy","dx","dy","r","rx","ry","width","height","points"];return a.forEach(t=>{if(!s.includes(t)){let l=e.getAttribute(t);n.setAttribute(t,l)}}),n}function ce(e,{tolerance:t=1,flatBezierToLinetos:l=!0}={}){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s=n,r=n;e[e.length-1].type.toLowerCase();for(let p=1,i=e.length;p<i;p++){let u=e[p],y=e[p+1]||e[i-1],h="z"===y.type.toLowerCase()?n:{x:y.values[y.values.length-2],y:y.values[y.values.length-1]},{type:o,values:c}=u,x=c.slice(-2);r="Z"!==o?{x:x[0],y:x[1]}:n;let f=h?H([s,r,h],!0):1/0,g=L(s,h),v=f<(g?g/333*t:0),d=!1;if(l||"C"!==o||(v=!1),l&&("C"===o||"Q"===o)){d=X([s,..."C"===o?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===o?[{x:c[0],y:c[1]}]:[],r],{tolerance:t}),d&&p<i-1&&(o="L",u.type="L",u.values=x)}v&&p<i-1&&"A"!==y.type&&("L"===o||l&&d)||(s=r,"M"===o?(n=r,s=n):"Z"===o&&(s=n),a.push(u))}return a}function xe(e){let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l];if(!a)continue;let{type:n=null,values:s=[]}=a,r=e[l+1]?e[l+1]:null;"M"!==n&&"m"!==n||r&&(!r||"Z"!==r.type&&"z"!==r.type)?t.push(a):r&&l++}return t}function fe(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,s=e.length;n<s;n++){let s=e[n],r=e[n-1],p=e[n+1]||null,{type:i,values:u}=s,y="m"===r.type.toLowerCase()&&!p,h=u.length;if(l={x:u[h-2],y:u[h-1]},y||"L"!==i||l.x!==t.x||l.y!==t.y){if(!y&&("l"===i||"v"===i||"h"===i)){if("l"===i?"00"===u.join(""):0===u[0])continue}a.push(s),t=l}}return a}function ge(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let l=0,a=[];for(let l=0;l<t;l++){let t=e[l],{type:n,values:s}=t,r=s.length;if(r){let e={type:n,x:s[r-2],y:s[r-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(3)-+t.y.toFixed(3)),l=a[0].index,l?de(e,l):e}function ve(e,{removeFinalLineto:t=!0,autoClose:l=!0}={}){let a=[],n=e.length,s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},r="z"===e[n-1].type.toLowerCase(),p=e.filter(e=>"L"===e.type),i=e[r?n-2:n-1],u=i.type,y=i.values.slice(-2).map(e=>+e.toFixed(8)),h=y[0]===s.x&&y[1]===s.y;!r&&l&&h&&(e.push({type:"Z",values:[]}),r=!0,n++);let o="L"!==e[1].type&&(!h||"L"===i.type);if(o=!1,!r)return e;let c=0;{let t=[];for(let l=0;l<n;l++){let a=e[l],{type:n,values:s}=a;if(s.length){let a=s.slice(-2),r=e[l-1]&&"L"===e[l-1].type,p=e[l+1]&&"L"===e[l+1].type,i=e[l-1]?e[l-1].type.toUpperCase():null,u=e[l+1]?e[l+1].type.toUpperCase():null,y={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:r,nextL:p,prevCom:i,nextCom:u};y.index=l,t.push(y)}}if(p.length){let e=t.filter(e=>"L"!==e.type&&"M"!==e.type&&e.prevCom&&"L"===e.prevCom||"M"===e.prevCom&&"L"===u).sort((e,t)=>e.y-t.y||e.x-t.x)[0];c=e?e.index-1:0}else t=t.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),c=t[0].index;e=c?de(e,c):e}return s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,i=e[n-2],u=i.type,y=i.values.slice(-2).map(e=>+e.toFixed(8)),h="L"===u&&y[0]===s.x&&y[1]===s.y,t&&h&&e.splice(n-2,1),a.push(...e),a}function de(e,t){let l=0,a="z"===e[e.length-1].type.toLowerCase();if(!a||t<1||e.length<3)return e;let n=a?1:0;!function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[n,s]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),r=l?e[t-2]:e[t-1],p=r.values.length,[i,u]=[r.values[p-2],r.values[p-1]].map(e=>+e.toFixed(8));!l||n==i&&s==u||(e.pop(),e.push({type:"L",values:[n,s]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let s,r,p=e.slice(l),i=e.slice(0,l);return i.shift(),s=i[i.length-1].values||[],r=[s[s.length-2],s[s.length-1]],n&&(p.pop(),i.push({type:"Z",values:[]})),e=[{type:"M",values:r},...p,...i]}function Me(e,{threshold:t=null,tolerance:l=1}={}){if(!t){let l=function(e){let t=1/0,l=-1/0,a=1/0,n=-1/0;const s=e=>{e.x<t&&(t=e.x),e.x>l&&(l=e.x),e.y<a&&(a=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let l=e[t],{type:a,values:n}=l,r=n.length,p=(e[t-1]?e[t-1]:e[t]).values,i=p.length;if(r){let e={x:p[i-2],y:p[i-1]},t={x:n[r-2],y:n[r-1]};if(s(t),"C"===a||"Q"===a){let l={x:n[0],y:n[1]},r="C"===a?{x:n[2],y:n[3]}:l,p="C"===a?[e,l,r,t]:[e,l,t];Q(p).forEach(e=>{let t=k(p,e);s(t)})}else"A"===a&&E(e,n).forEach(e=>{s(e)})}}return{x:t,y:a,width:l-t,height:n-a}}(e);t=(l.width+l.height)/2*.05}let a=e.length;for(let n=0;n<a;n++){let a=e[n],{type:s,values:r,extreme:p,corner:i=!1,dimA:u,p0:y,p:h}=a,o=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(o?T(h,o.p):1/0)<t,f=(c?T(c.p,o.p):1/0)<t;if(o&&"C"===s&&"C"===o.type&&p&&c&&c.extreme&&(f||x)){let a=V(o,c,t,l,!1);if(1===a.length){e[n+1]=null,a=a[0],e[n+2].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,a.p.x,a.p.y],e[n+2].cp1=a.cp1,e[n+2].cp2=a.cp2,e[n+2].p0=a.p0,e[n+2].p=a.p,e[n+2].extreme=a.extreme,n++;continue}}if(o&&"C"===s&&"C"===o.type&&p&&x){let t,l=a.cp1.x-o.p0.x,s=a.cp1.y-o.p0.y,r=Math.abs(s)<Math.abs(l),p=o.p,i=1,u=H([a.p0,a.p,o.p]),y=H([a.p0,a.cp1,a.cp2,a.p]);if(u<0&&y>0||u>0&&y<0)continue;if(o.extreme){r?(i=Math.abs(Math.abs(o.cp2.x-o.p.x)/Math.abs(a.cp2.x-a.p.x)),i=Math.min(1,i),t=P(o.p,a.cp2,1+i),a.cp2.x=t.x):(i=Math.abs(Math.abs(o.cp2.y-o.p.y)/Math.abs(a.cp2.y-a.p.y)),i=Math.min(1,i),t=P(o.p,a.cp2,1+i),a.cp2.y=t.y),e[n+1].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,p.x,p.y],e[n+1].cp1=a.cp1,e[n+1].cp2=a.cp2,e[n+1].p0=a.p0,e[n+1].p=p,e[n+1].extreme=!0,e[n]=null;continue}}}a=(e=e.filter(Boolean)).length;let n="z"===e[a-1].type.toLowerCase()?a-2:a-1,s=e[n],r=e[n-1]||null,p={x:e[0].values[0],y:e[0].values[1]},i=s.values.slice(-2),u=+i[0].toFixed(8)===+p.x.toFixed(8)&&+i[1].toFixed(8)===+p.y.toFixed(8),y="C"===e[1].type&&e[1].extreme?e[1]:null,h=T(s.p0,s.p)<t;if(r&&"C"===r.type&&h&&u&&y){let a=V(r,s,t,l,!1);1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function me(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}function be(e,{threshold:t=0,tolerance:l=1}={}){let a=e.length,n=[e[0]],s="z"===e[a-1].type.toLowerCase(),r=!!s&&(e[a-1].p.x===e[0].p0.x&&e[a-1].p.y===e[0].p0.y),p=s?2:1,i=e[a-p],u="L"===i.type,y="C"===i.type,h="L"===e[1].type,o="C"===e[1].type,c=s&&o&&(u||r);c&&(e[a-1].values=e[0].values,e[a-1].type="L",u=!0);for(let t=1;t<a;t++){let r=e[t],{type:i}=r,x=e[t+1]?e[t+1]:null;if("L"===i&&x&&"C"===x.type||"C"===i&&x&&"L"===x.type){let c="L"===i?r:null,f=null,g=[],v=0;if(1===t&&o&&u&&(g=[e[1]],c=e[a-1],f=x),!c){n.push(r);continue}s&&y&&h&&t===a-p-1&&(f=e[1],g=[e[a-p]]);for(let l=t+1;l<a;l++){let t=e[l]?e[l]:null,a=e[l-1];if("C"===a.type&&g.push(a),"L"===t.type&&"C"===a.type){f=t;break}v++}if(f){let e=T(c.p0,c.p),a=T(f.p0,f.p),s=g.length,p=T(g[0].p0,g[s-1].p),i=H([c.p0,c.p,f.p0,f.p],!1),u=H([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),y=i<0&&u>0||i>0&&u<0,h=.5*p*l,o=h<e&&h<a;if(g.length&&!y&&o){let e=Math.abs(u)<=.005*L(g[0].p0,g[0].p),l=e?null:C(c.p0,c.p,f.p0,f.p,!1);if(!e&&l){if(!(T(k([c.p,l,f.p0],.5),1===g.length?k([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p)>p)){let e={type:"Q",values:[l.x,l.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=l,e.p=f.p0,n.push(c,e),t+=v;continue}n.push(r)}}}}c&&t===a-1&&"L"===i||n.push(r)}return(c||s&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function Ae(e){if(e.length<3)return!1;let t=e[0],l=e[Math.floor(e.length/2)],a=e[e.length-1],n=t.x,s=t.y,r=l.x,p=l.y,i=a.x,u=a.y,y=n-r,h=s-p,o=n-i,c=s-u,x=(n*n-r*r+(s*s-p*p))/2,f=(n*n-i*i+(s*s-u*u))/2,g=y*c-h*o;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let v={x:(c*x-h*f)/g,y:(-o*x+y*f)/g},d=w(v,t),M=A(v,t,a),{deltaAngle:m,startAngle:b,endAngle:C}=M;return{centroid:v,r:d,startAngle:b,endAngle:C,deltaAngle:m}}function Ce(e,{threshold:l=0,tolerance:a=1,toCubic:n=!1,debug:s=!1}={}){let r=e.length,p=[e[0]],i=[];for(let l=1;l<r;l++){let a=e[l],{type:r}=a,u=e[l-1],y=e[l+1]?e[l+1]:null,h=e[l+2]?e[l+2]:null,o=e[l+3]?e[l+3]:null,c=null;"C"===a.type||"Q"===a.type?c=a:!y||"C"!==y.type&&"Q"!==y.type||(c=y);let x,f,g,v,d,M=c?"C"===c.type?[c.p0,c.cp1,c.cp2,c.p]:[c.p0,c.cp1,c.p]:[],m=0,b=0,A=!1,C=!1,w=[];if("L"===u.type&&"L"===r&&c&&"L"===h.type&&o&&("L"===o.type||"Z"===o.type)?(x=[a.p0,a.p],f=[h.p0,h.p],g=a.p0,v=h.p,m=H(M,!1),b=H([...x,...f],!1),A=m<0&&b>0||m>0&&b<0,A||(d=k(M,.5),w=[g,d,v],C=!0)):"C"!==r&&"Q"!==r||"L"!==u.type||"C"!==y.type&&"Q"!==y.type||"L"!==h.type||(C=!0,x=[u.p0,u.p],f=[h.p0,h.p],g=u.p,v=h.p0,d=c.p,w=[g,c.p,v]),C){let e=Ae(w);if(e){let r,{centroid:u,r:y,deltaAngle:h,startAngle:o,endAngle:c}=e,x=0,f=h>0?1:0,M=Math.abs(h)>Math.PI?1:0;if(T(S(g,u.x,u.y,.5*h),d)<.05*T(g,v)){if(r=ne({p0:g,p:v,centroid:u,rx:y,ry:y,xAxisRotation:x,sweep:f,largeArc:M,deltaAngle:h,startAngle:o,endAngle:c}),1===r.length){let e=_(g,r[0].cp1,r[0].cp2,v);"Q"===e.type&&(n=!0),a=e}if(r.length>1&&(n=!1),n||(a.type="A",a.values=[y,y,x,M,f,v.x,v.y]),a.p0=g,a.p=v,a.extreme=!1,a.corner=!1,s){i=n?[{type:"M",values:[g.x,g.y]},...r]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[y,y,x,M,f,v.x,v.y]}];let e=U(i);t(markers,e,"orange","0.5%","0.5")}p.push(a),l++;continue}}}p.push(a)}return p}function we(e=[],{threshold:t=0}={}){let l=e.length,a="z"===e[l-1].type.toLowerCase(),n=a?l-2:l-1,s=e[n],r=s.values.slice(-2),p={x:e[0].values[0],y:e[0].values[1]},i=T(p,{x:r[0],y:r[1]});if(i&&i<t){let l=e[n].values.length;e[n].values[l-2]=p.x,e[n].values[l-1]=p.y;let a=e[1];if("C"===a.type&&"C"===s.type){let l=Math.abs(a.values[0]-s.values[2]),r=Math.abs(a.values[1]-s.values[3]),i=Math.abs(e[1].values[0]-a.values[0]),u=Math.abs(e[1].values[1]-a.values[1]),y=Math.abs(e[1].values[0]-s.values[2]),h=Math.abs(e[1].values[1]-s.values[3]),o=u<t&&h<t&&l;l&&l<t&&(i<t&&y<t&&r)&&(e[1].values[0]=p.x,e[n].values[2]=p.x),r&&r<t&&o&&(e[1].values[1]=p.y,e[n].values[3]=p.y)}}return e}function Le(e="",{getObject:t=!1,toAbsolute:l=!0,toRelative:a=!0,toShorthands:n=!0,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:p=!1,simplifyBezier:i=!0,optimizeOrder:u=!0,autoClose:y=!0,removeZeroLength:h=!0,refineClosing:o=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:v=!1,keepExtremes:d=!0,keepCorners:M=!0,extrapolateDominant:m=!0,keepInflections:b=!1,addExtremes:A=!1,removeOrphanSubpaths:C=!1,simplifyRound:w=!1,decimals:L=3,autoAccuracy:P=!0,minifyD:k=0,tolerance:I=1,reverse:S=!1,mergePaths:$=!1,removeHidden:F=!0,removeUnused:z=!0,shapesToPaths:Q=!0}={}){I=Math.max(.1,I);let E=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"array";if("string"==typeof e){let l=(e=e.trim()).includes("<svg")&&e.includes("</svg"),a=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(n)t="polyString";else{let l=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),a=e.startsWith("data:image");t=l||a?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),T="",q=0,j=0,B=0,N={},O="",R="svgMarkup"===E?1:0,H=[];if(q=e.length,R){if(T=function(e,{returnDom:t=!1,removeHidden:l=!0,removeUnused:a=!0}={}){e=(e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()).replaceAll("xlink:href=","href=");let n=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)||e.removeAttribute(l)})}(n,["viewBox","xmlns","width","height","id","class","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"]);let s=["metadata","script"];return n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),r=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||s.includes(t)||l&&r?e.remove():function(e){[...e.attributes].map(e=>e.name).forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t?n:me(n)}(e,{returnDom:!0,removeHidden:F,removeUnused:z}),Q){T.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=oe(e);e.replaceWith(t)})}T.querySelectorAll("path").forEach(e=>{H.push({d:e.getAttribute("d"),el:e})})}else{if("pathDataString"===E)O=e;else if("polyString"===E)O="M"+e;else if("pathData"===E){O=e,q=O.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}H.push({d:O,el:null})}let V={toRelative:a,toShorthands:n,decimals:L},W=[];for(let e=0,t=H.length;t&&e<t;e++){let t=H[e],{d:a,el:n}=t,F=ue(a,{quadraticToCubic:s,toAbsolute:l,arcToCubic:r}),z=F.length;C&&(F=xe(F));let Q=D(F),E=Q.length,T=[];for(let e=0;e<E;e++){let t=Q[e];(c||h)&&(t=fe(t)),A&&(t=Z(t,0,1)),u&&(t=ge(t)),c&&(t=ce(t,{tolerance:I,flatBezierToLinetos:!1}));let l=Y(t),{pathData:a,bb:n,dimA:s}=l;if(o&&(a=we(a,{threshold:.001*s})),a=i?J(a,{simplifyBezier:i,keepInflections:b,keepExtremes:d,keepCorners:M,extrapolateDominant:m,revertToQuadratics:f,tolerance:I,reverse:S}):a,g){a=Me(a,{threshold:(n.width+n.height)/2*.05,tolerance:I})}if(p){let e=1;for(let t=0,l=a.length;t<l;t++){let l=a[t],{type:n,values:s,p0:r,cp1:p=null,cp2:i=null,p:u=null}=l;if("C"===n){let l=re(r,p,i,u,e);l.isArc&&(a[t]=l.com)}}a=pe(a)}if(c&&x&&(a=ce(a,{tolerance:I,flatBezierToLinetos:x})),v){a=be(a,{threshold:(n.width+n.height)/2*.1,tolerance:I})}if(w&&(a=Ce(a)),f)for(let e=0,t=a.length;e<t;e++){let t=a[e],{type:l,values:n,p0:s,cp1:r=null,cp2:p=null,p:i=null}=t;if("C"===l){let l=_(s,r,p,i);"Q"===l.type&&(l.extreme=t.extreme,l.corner=t.corner,l.dimA=t.dimA,a[e]=l)}}u&&(a=ve(a,{autoClose:y})),T.push({pathData:a,bb:n})}if(u&&(T=T.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x)),F=[],T.forEach(e=>{F.push(...e.pathData)}),P&&(L=G(F),V.decimals=L),n&&$)W.push(...F);else{F=ee(F,V),F=fe(F);let e=F.length,l=U(F,k);j=l.length,B=+(100/q*j).toFixed(2),t.d=l,t.report={original:z,new:e,saved:z-e,compression:B,decimals:L},n&&n.setAttribute("d",l)}}if(R){if(W.length){let e=ee(W,V);e=fe(e);let t=U(e,k);H[0].el.setAttribute("d",t);for(let e=1;e<H.length;e++){let t=H[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(T)}T=me(T),j=T.length,B=+(100/q*j).toFixed(2),q=+(q/1024).toFixed(3),j=+(j/1024).toFixed(3),N={svgSize:q,svgSizeOpt:j,compression:B}}else({d:O,report:N}=H[0]);return t?{svg:T,d:O,report:N,inputType:E,mode:R}:O||T}he[77]=2,he[109]=2,he[65]=7,he[97]=7,he[67]=6,he[99]=6,he[76]=2,he[108]=2,he[81]=4,he[113]=4,he[83]=4,he[115]=4,he[84]=2,he[116]=2,he[72]=1,he[104]=1,he[86]=1,he[118]=1,he[90]=0,he[122]=0;const{abs:Pe,acos:ke,asin:Ie,atan:Se,atan2:$e,ceil:Fe,cos:ze,exp:Qe,floor:Ee,log:Te,hypot:De,max:qe,min:je,pow:Ze,random:Be,round:Ne,sin:Oe,sqrt:Re,tan:He,PI:Ue}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=Le),e.PI=Ue,e.abs=Pe,e.acos=ke,e.asin=Ie,e.atan=Se,e.atan2=$e,e.ceil=Fe,e.cos=ze,e.exp=Qe,e.floor=Ee,e.hypot=De,e.log=Te,e.max=qe,e.min=je,e.pow=Ze,e.random=Be,e.round=Ne,e.sin=Oe,e.sqrt=Re,e.svgPathSimplify=Le,e.tan=He}(this["svg-path-simplify"]=this["svg-path-simplify"]||{});
|
|
1
|
+
!function(e){"use strict";function t(e,t="",l="green",a="1%",n="1",s=!0){let r=`<path d="${t}" fill="none" stroke="${l}" stroke-width="${a}" stroke-opacity="${n}" /> `;if(!s)return r;e.insertAdjacentHTML("beforeend",r)}const{abs:l,acos:a,asin:n,atan:s,atan2:r,ceil:p,cos:i,exp:u,floor:h,log:y,max:o,min:c,pow:x,random:f,round:g,sin:v,sqrt:d,tan:m,PI:M}=Math;function b(e,t,l=!1){let a=r(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function A(e,t,l,a=!1){let n=Math.atan2(t.y-e.y,t.x-e.x),s=Math.atan2(l.y-e.y,l.x-e.x),r=s-n;r=(e=>{let t=e%(2*Math.PI);return t>Math.PI?t-=2*Math.PI:t<=-Math.PI&&(t+=2*Math.PI),t})(r),a&&(r=2*Math.PI-Math.abs(r));let p=180/Math.PI;return{startAngle:n,endAngle:s,deltaAngle:r,startAngleDeg:n*p,endAngleDeg:s*p,deltaAngleDeg:r*p}}function C(e=null,t=null,l=null,a=null,n=!0,s=!1){let r,p,i,u,h,y={};if(!(e&&t&&l&&a))return s&&console.warn("points missing"),!1;try{if(r=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==r)return!1}catch{return s&&console.warn("!catch",e,t,"p3:",l,"p4:",a),!1}p=e.y-l.y,i=e.x-l.x,u=(a.x-l.x)*p-(a.y-l.y)*i,h=(t.x-e.x)*p-(t.y-e.y)*i,p=u/r,i=h/r,y={x:e.x+p*(t.x-e.x),y:e.y+p*(t.y-e.y)};let o=!1;return p>0&&p<1&&i>0&&i<1&&(o=!0),!(n&&!o)&&y}function w(e,t){return d((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function L(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function P(e,t,l,a=!1){let n={x:(t.x-e.x)*l+e.x,y:(t.y-e.y)*l+e.y};return a&&(n.angle=b(e,t),n.angle<0&&(n.angle+=2*M)),n}function k(e,t=.5,l=!1,a=!1){let n;return n=e.length>2?((e,t,l=!1)=>{let n=4===e.length,s=e[0],r=e[1],p=n?e[2]:e[1],i=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,h,y,o,c=s.x===r.x&&s.y===r.y,x=i.x===p.x&&i.y===p.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=P(s,r,t),n?(l=P(r,p,t),h=P(p,i,t),y=P(e,l,t),o=P(l,h,t),u=P(y,o,t),u.angle=b(y,o),a&&(u.cpts=[l,h,y,o])):(l=P(s,r,t),h=P(r,i,t),u=P(l,h,t),u.angle=b(l,h),a&&(u.cpts=[l,h]))):(u.x=i.x,u.y=i.y,u.angle=b(p,i)):(u.x=s.x,u.y=s.y,u.angle=b(s,r))}else{let e=1-t;u=n?{x:e**3*s.x+3*e**2*t*r.x+3*e*t**2*p.x+t**3*i.x,y:e**3*s.y+3*e**2*t*r.y+3*e*t**2*p.y+t**3*i.y}:{x:e*e*s.x+2*e*t*r.x+t**2*i.x,y:e*e*s.y+2*e*t*r.y+t**2*i.y}}return u})(e,t,l):P(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*M),n}function F(e){let t=[],l={x:e[0].values[0],y:e[0].values[1]};return e.forEach(e=>{let{type:a,values:n}=e;if(n.length){let e=n.length>1?{x:n[n.length-2],y:n[n.length-1]}:"V"===a?{x:l.x,y:n[0]}:{x:n[0],y:l.y};t.push(e),l=e}}),t}function I(e,t,a,n,s,p,u,h,y){const o=(e,t,l,a)=>r(a-t,l-e);let c={cx:0,cy:0,rx:a=l(a),ry:n=l(n),startAngle:0,endAngle:0,deltaAngle:0,clockwise:u,xAxisRotation:s,largeArc:p,sweep:u};if(0==a||0==n)throw Error("rx and ry can not be 0");if(a===n){let l=Math.abs(h-e),a=Math.abs(y-t),n=l,s=Math.min(e,h),r=Math.min(t,y),p=.5*Math.PI;if(0===l&&a||0===a&&l)return n=0===l&&a?a/2:l/2,c.rx=n,c.ry=n,0===l&&a?(c.cx=e,c.cy=r+a/2,c.startAngle=t>y?p:-p,c.endAngle=t>y?-p:p,c.deltaAngle=u?Math.PI:-Math.PI):0===a&&l&&(c.cx=s+l/2,c.cy=t,c.startAngle=e>h?Math.PI:0,c.endAngle=e>h?-Math.PI:Math.PI,c.deltaAngle=u?Math.PI:-Math.PI),c}let x,f,g=a===n?0:s*M/180,m=g?v(g):0,b=g?i(g):1,A=(e-h)/2,C=(t-y)/2,w=(e+h)/2,L=(t+y)/2,P=g?b*A+m*C:A,k=g?b*C-m*A:C,F=P*P/(a*a)+k*k/(n*n);F>1&&(a*=d(F),n*=d(F),c.rx=a,c.ry=n);let I=a*n,S=a*k,$=n*P,z=S**2+$**2;if(!z)throw Error("start point can not be same as end point");let Q=d(l((I*I-z)/z));p==u&&(Q=-Q);let E=Q*S/n,T=-Q*$/a;x=g?b*E-m*T+w:w+E,f=g?m*E+b*T+L:L+T,c.cy=f,c.cx=x;let D=o(x,f,e,t),q=o(x,f,h,y);!u&&q>D&&(q-=2*Math.PI),u&&D>q&&(q=q<=0?q+2*Math.PI:q);let B=q-D;return c.startAngle=D,c.endAngle=q,c.deltaAngle=B,c}function S(e,t,l,a=0,n=!1){return a?(a=n?a/180*Math.PI:a,{x:t+(e.x-t)*Math.cos(a)-(e.y-l)*Math.sin(a),y:l+(e.x-t)*Math.sin(a)+(e.y-l)*Math.cos(a)}):e}function $(e,t,l,a,n,r=0,p=!0,u=!1){if(n=u?n*M/180:n,r=u?r*M/180:r,r=l!==a&&r!==2*M?r:0,p&&l!==a){let e=s(m(n=r?n-r:n)*(l/a));n=i(n)<0?e+M:e}let h=e+l*i(n),y=t+a*v(n),o={x:h,y:y};return r&&(o.x=e+(h-e)*i(r)-(y-t)*v(r),o.y=t+(h-e)*v(r)+(y-t)*i(r)),o}function z(e,t,l){if(t===l||e%M*.5==0)return e;let a=s(m(e)*(t/l));return a=i(e)<0?a+M:a,a}function Q(e,t=[],l=.05){let a=3===t.length,n=t[0]||null,s=a?t[1]:null,r=a?t[2]:t[1],p=.5*Math.PI,i=!1,u=!1,h=n?b(r,n,!0):null;if(i=Math.abs(h%p)<l||Math.abs(h%p-p)<l,a){let e=s?b(s,r,!0):0;u=Math.abs(e%p)<=l||Math.abs(e%p-p)<=l}return i||u}function E(e){return 4===e.length?function(e,t,l,a){let[n,s,r,p,i,u,h,y]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],o=Math.min(e.y,a.y),c=Math.min(e.x,a.x),x=Math.max(e.x,a.x),f=Math.max(e.y,a.y);if(t.y>=o&&t.y<=f&&l.y>=o&&l.y<=f&&t.x>=c&&t.x<=x&&l.x>=c&&l.x<=x)return[];let g,v,d,m,M,b,A,C,w=[];for(let e=0;e<2;++e)if(0==e?(v=6*n-12*r+6*i,g=-3*n+9*r-9*i+3*h,d=3*r-3*n):(v=6*s-12*p+6*u,g=-3*s+9*p-9*u+3*y,d=3*p-3*s),Math.abs(g)<1e-12){if(Math.abs(v)<1e-12)continue;m=-d/v,0<m&&m<1&&w.push(m)}else A=v*v-4*d*g,A<0?Math.abs(A)<1e-12&&(m=-v/(2*g),0<m&&m<1&&w.push(m)):(C=Math.sqrt(A),M=(-v+C)/(2*g),0<M&&M<1&&w.push(M),b=(-v-C)/(2*g),0<b&&b<1&&w.push(b));let L=w.length;for(;L--;)m=w[L];return w}(e[0],e[1],e[2],e[3]):function(e,t,l){let a,n,s,r=Math.min(e.y,l.y),p=Math.min(e.x,l.x),i=Math.max(e.x,l.x),u=Math.max(e.y,l.y);if(t.y>=r&&t.y<=u&&t.x>=p&&t.x<=i)return[];let[h,y,o,c,x,f]=[e.x,e.y,t.x,t.y,l.x,l.y],g=[];for(let e=0;e<2;++e)a=0==e?h-2*o+x:y-2*c+f,n=0==e?-2*h+2*o:-2*y+2*c,Math.abs(a)>1e-12&&(s=-n/(2*a),s>0&&s<1&&g.push(s));return g}(e[0],e[1],e[2])}function T(e,t){const l=(e,t,l,a,n,s)=>{var r=Math.cos(s),p=Math.sin(s),i=a*Math.cos(e),u=n*Math.sin(e);return{x:t+r*i-p*u,y:l+p*i+r*u}};let a,n,s,r,p,i=I(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:u,ry:h,cx:y,cy:o,endAngle:c,deltaAngle:x}=i,f=t[2],g={x:t[5],y:t[6]},v=[g],d=f*Math.PI/180,m=Math.tan(d);p=Math.atan2(-h*m,u);let M=p,b=p+Math.PI,A=Math.atan2(h,u*m),C=A+Math.PI,w=[e.x,g.x],L=[e.y,g.y],P=Math.min(...w),k=Math.max(...w),F=Math.min(...L),S=Math.max(...L),$=l(c-.001*x,y,o,u,h,d),z=l(c-.999*x,y,o,u,h,d);return($.x>k||z.x>k)&&(a=l(M,y,o,u,h,d),v.push(a)),($.x<P||z.x<P)&&(n=l(b,y,o,u,h,d),v.push(n)),($.y<F||z.y<F)&&(r=l(C,y,o,u,h,d),v.push(r)),($.y>S||z.y>S)&&(s=l(A,y,o,u,h,d),v.push(s)),v}function D(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function q(e){let t=[],l=[e[0]],a=e.length;for(let n=1;n<a;n++){let a=e[n];"M"!==a.type&&"m"!==a.type||(t.push(l),l=[]),l.push(a)}return l.length&&t.push(l),t}function B(e,t){let l,a,n,s,r,p,i=[],u=[],h=e[0],y=e[1],o=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=k([h,y],t),a=k([y,o],t),n=k([o,c],t),s=k([l,a],t),r=k([a,n],t),p=k([s,r],t),i.push({x:h.x,y:h.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:p.x,y:p.y}),u.push({x:p.x,y:p.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=k([h,y],t),n=k([y,c],t),p=k([a,n],t),i.push({x:h.x,y:h.y},{x:a.x,y:a.y},{x:p.x,y:p.y}),u.push({x:p.x,y:p.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=k([h,c],t),i.push({x:h.x,y:h.y},{x:a.x,y:a.y}),u.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[i,u]}function j(e,t,l=0,a=1){let n=[],s=6===t.length?"C":"Q",r={x:t[0],y:t[1]},p="C"===s?{x:t[2],y:t[3]}:r,i={x:t[4],y:t[5]},u=Math.max(i.x,e.x),h=Math.min(i.x,e.x),y=Math.max(i.y,e.y),o=Math.min(i.y,e.y),c=0;if(r.x<h||r.x>u||r.y<o||r.y>y||p.x<h||p.x>u||p.y<o||p.y>y){let u=E("C"===s?[e,r,p,i]:[e,r,i]).sort();if(u=u.filter(e=>e>l&&e<a),u.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let s,r,p,i=t.length,u={x:t[i-2],y:t[i-1]};2===t.length?p=[e,u]:4===t.length?(s={x:t[0],y:t[1]},p=[e,s,u]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},p=[e,s,r,u]);if(l.length)if(1===l.length){let e=B(p,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=B(p,e),a=t[0];n.push(a),p=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=B(p,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),p=a[1]}}if(a){let e,t,l=[];return n.forEach(a=>{e={type:"",values:[]},a.shift(),t=a.map(e=>Object.values(e)).flat(),e.values=t,3===a.length?e.type="C":2===a.length?e.type="Q":1===a.length&&(e.type="L"),l.push(e)}),l}return n}(e,t,u);n.push(...l),c+=l.length}else n.push({type:s,values:t})}else n.push({type:s,values:t});return{pathData:n,count:c}}function Z(e,t=0,l=1){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s={x:e[0].values[0],y:e[0].values[1]},r=e.length;for(let p=1;r&&p<r;p++){let r=e[p],{type:i,values:u}=r,h=u.slice(-2);if(h[0],h[1],"C"!==i&&"Q"!==i)a.push(r);else if("C"===i||"Q"===i){let e=j(n,u,t,l).pathData;a.push(...e)}n={x:h[0],y:h[1]},"z"===i.toLowerCase()?n=s:"M"===i&&(s={x:h[0],y:h[1]})}return a}function N(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),s=Math.max(...l),r=Math.min(...a),p=Math.max(...a),i={x:n,left:n,right:s,y:r,top:r,bottom:p,width:s-n,height:p-r};if(t>-1)for(let e in i)i[e]=+i[e].toFixed(t);return i}function O(e){let t=[];return e.forEach(e=>{let l=function(e){let t=function(e){let t=[];for(let l=0;l<e.length;l++){let a=e[l],n=l>0?e[l-1]:e[l],{type:s,values:r}=a,p={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},i=r.length?{x:r[r.length-2],y:r[r.length-1]}:"",u=r.length?{x:r[0],y:r[1]}:"";switch(s){case"A":if("function"!=typeof arcToBezier){let e=w(p,i)/2,l=P(p,i,.5),a=$(l.x,l.y,e,e,0),n=$(l.x,l.y,e,e,Math.PI);t.push(a,n,i);break}arcToBezier(p,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},s={x:l[4],y:l[5]};t.push(a,n,s)});break;case"C":let e={x:r[2],y:r[3]};t.push(u,e);break;case"Q":t.push(u)}"z"!==s.toLowerCase()&&t.push(i)}return t}(e),l=N(t);return l}(e);t.push(l)}),t}function R(e,t){let[l,a,n,s,r,p]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[i,u,h,y,o,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=h*y&&n*s>h*y&&l<i&&r>o&&a<u&&p>c&&(x=!0),x}function H(e,t=9){let l=0,a=[],n=q(e),s=n.length>1,r=[];if(s){let e=O(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){R(t,a)&&r.push(l)}}})}return n.forEach((e,t)=>{a=[];let n=0,s=0,p=1,i=[];e.forEach(function(t,l){let[s,r]=[t.type,t.values],p=r.length;if(r.length){let u=(l>0?e[l-1]:e[0]).values,h=u.length,y={x:u[h-2],y:u[h-1]},o={x:r[p-2],y:r[p-1]};if("C"===s||"Q"===s){let e={x:r[0],y:r[1]};i="C"===s?[y,e,{x:r[2],y:r[3]},o]:[y,e,o];let t=Math.abs(function(e,t=!1){let l,[a,n,s,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(n={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},s={x:1*e[2].x/3+2*e[1].x/3,y:1*e[2].y/3+2*e[1].y/3});return l=3*(a.x*(-2*n.y-s.y+3*r.y)+n.x*(2*a.y-s.y-r.y)+s.x*(a.y+n.y-2*r.y)+r.x*(-3*a.y+n.y+2*s.y))/20,t?Math.abs(l):l}(i));n+=t,a.push(y,o)}else if("A"===s){let e=I(y.x,y.y,t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],o.x,o.y),{cx:l,cy:s,rx:r,ry:p,startAngle:i,endAngle:u,deltaAngle:h}=e,c=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let s=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(s/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),s=(a-l+2*Math.PI)%(2*Math.PI),n*(s/(2*Math.PI))}(r,p,i,u));c-=Math.abs(U([y,{x:l,y:s},o])),a.push(y,o),n+=c}else a.push(y,o)}});let u=U(a);-1!==r.indexOf(t)&&(p=-1),s=u<0&&n<0?(Math.abs(n)-Math.abs(u))*p:(Math.abs(n)+Math.abs(u))*p,l+=s}),l}function U(e,t=!1){let l=0;for(let t=0,a=e.length;a&&t<a;t++){l+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}return t&&(l=Math.abs(l)),l}function V(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,s="",r=a?"\n":n?"":" ",p=n?"":" ";s=`${e[0].type}${p}${e[0].values.join(" ")}${r}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:i,values:u}=a;if(!n||"A"!==i&&"a"!==i||(u=[u[0],u[1],u[2],`${u[3]}${u[4]}${u[5]}`,u[6]]),i=n&&l.type===a.type&&"m"!==a.type.toLowerCase()||n&&"M"===l.type&&"L"===a.type?" ":a.type,n){let e="",t=!1;for(let l=0,a=u.length;l<a;l++){let a=u[l],n=a.toString(),s=n.includes(".")&&Math.abs(a)<1;s&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&s||(e+=" "),e+=n,t=s}s+=`${i}${p}${e}${r}`}else s+=`${i}${p}${u.join(" ")}${r}`}return n&&(s=s.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function W(e,l,a=0,n=1,s=!1){const r=(e,t,l,a,n)=>{let s=1-n;return{x:3*s*s*(t.x-e.x)+6*s*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*s*s*(t.y-e.y)+6*s*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let p=[e,l],i=D(e.p0,e.p)>D(l.p0,l.p),u=JSON.parse(JSON.stringify(e)),h=JSON.parse(JSON.stringify(l)),y=C(u.p0,u.cp1,h.p,h.cp2,!1);if(!y)return p;if(i){let t={p0:{x:e.p.x,y:e.p.y},cp1:{x:e.cp2.x,y:e.cp2.y},cp2:{x:e.cp1.x,y:e.cp1.y},p:{x:e.p0.x,y:e.p0.y}};e={p0:{x:l.p.x,y:l.p.y},cp1:{x:l.cp2.x,y:l.cp2.y},cp2:{x:l.cp1.x,y:l.cp1.y},p:{x:l.p0.x,y:l.p0.y}},l=t}let o=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),c=(e,t)=>({x:e.x*t,y:e.y*t}),x=(e,t)=>e.x*t.x+e.y*t.y,f=l.p0,g=r(l.p0,l.cp1,l.cp2,l.p,0),v=x(o(e.p0,f),g)/x(g,g),d=k([l.p0,l.cp1,l.cp2,l.p],v),m=r(l.p0,l.cp1,l.cp2,l.p,v);v-=x(o(d,e.p0),m)/x(m,m);let M=k([l.p0,l.cp1,l.cp2,l.p],v),b=l.p,A=r(l.p0,l.cp1,l.cp2,l.p,v),w=r(l.p0,l.cp1,l.cp2,l.p,1),L=1-v,F=(I=M,S=c(A,L/3),{x:I.x+S.x,y:I.y+S.y});var I,S;let $=o(b,c(w,L/3)),z={p0:M,cp1:F,cp2:$,p:b,t0:v};i&&(z={p0:b,cp1:$,cp2:F,p:M,t0:v});let Q=.5*(1-v),E=k([z.p0,z.cp1,z.cp2,z.p],Q,!1,!0),T=E.cpts[2],q=C(E,T,z.p0,y,!1),B=C(E,T,z.p,y,!1),j=P(z.p0,q,1.333),Z=P(z.p,B,1.333);if(C(u.p0,j,h.p,Z,!0))return p;s&&function(e,t,l="red",a="1%",n="1",s="",r=!0,p="",i=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let u=`<circle class="${i}" opacity="${n}" id="${p}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return u;e.insertAdjacentHTML("beforeend",u)}(markers,E,"purple"),z.cp1=j,z.cp2=Z;let N=D(u.p0,z.p0)+D(h.p,z.p);if(z.p0=u.p0,z.p=h.p,z.extreme=h.extreme,z.corner=h.corner,z.dimA=h.dimA,z.directionChange=h.directionChange,z.type="C",z.values=[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y],N<a){let l=i?1+v:Math.abs(v),r=1+Math.abs(v);if(l=i?1+v:Math.abs(v)/r,D(k([z.p0,z.cp1,z.cp2,z.p],l),e.p)>a*n)return p;let y=H([{type:"M",values:[u.p0.x,u.p0.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]},{type:"C",values:[h.cp1.x,h.cp1.y,h.cp2.x,h.cp2.y,h.p.x,h.p.y]}]),o=[{type:"M",values:[z.p0.x,z.p0.y]},{type:"C",values:[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y]}],c=H(o),x=Math.abs(c/y-1);if(z.error=5*x*n,s){let e=V(o);t(markers,e,"orange")}x<.05*n&&(p=[z])}return p}function J(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1}={}){let r=[e[0]],p=e.length;for(let n=2;p&&n<=p;n++){let i=e[n-1],u=n<p?e[n]:null,h=u?.type||null,y=i?.directionChange||null,o=u?.directionChange||null,{type:c,values:x,p0:f,p:g,cp1:v=null,cp2:d=null,extreme:m=!1,corner:M=!1,dimA:b=0}=i;if("C"===c&&"C"===h)if(l&&o||a&&M||!y&&t&&m)r.push(i);else{let h=X(i,u,{tolerance:s}),y=0;if(1===h.length){i=h[0];let u=1;y+=i.error;for(let r=n+1;y<s&&r<p;r++){let n=e[r];if("C"!==n.type||l&&n.directionChange||a&&i.corner||t&&i.extreme)break;let p=X(i,n,{tolerance:s});1===p.length&&(y+=.5*p[0].error,u++),i=p[0]}r.push(i),n<p&&(n+=u)}else r.push(i)}else r.push(i)}return r}function X(e,t,{tolerance:l=1}={}){let a=[e,t],n=function(e,t){let l=w(e.cp2,e.p),a=w(e.cp2,t.cp1),n=Math.min(l)/a;return n}(e,t),s=D(e.p0,e.p),r=D(t.p0,t.p),p=.08*Math.max(0,Math.min(s,r))*l,i=function(e,t,l=0){let{p0:a,cp1:n}=e,{p:s,cp2:r}=t;return n={x:(n.x-(1-l)*a.x)/l,y:(n.y-(1-l)*a.y)/l},r={x:(r.x-l*s.x)/(1-l),y:(r.y-l*s.y)/(1-l)},{p0:a,cp1:n,cp2:r,p:s}}(e,t,n),u=k([i.p0,i.cp1,i.cp2,i.p],n),h=D(e.p,u),y=0,o=0,c=!1,x=h;if(h<p){let l=.5*(1+n);if(y=D(k([t.p0,t.cp1,t.cp2,t.p],.5),k([i.p0,i.cp1,i.cp2,i.p],l)),x+=y,y<p){let t=.5*n;o=D(k([e.p0,e.cp1,e.cp2,e.p],.5),k([i.p0,i.cp1,i.cp2,i.p],t)),x+=o,x<p&&(c=!0)}}return c&&(i.p0=e.p0,i.p=t.p,i.dimA=D(i.p0,i.p),i.type="C",i.extreme=t.extreme,i.directionChange=t.directionChange,i.corner=t.corner,i.values=[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y],i.error=x/p,a=[i]),a}function Y(e,{tolerance:t=1,debug:l=!1}={}){let a=!1,n={flat:!0,steepness:0},s=e[0],r=e[e.length-1],p=new Set([...e.map(e=>+e.x.toFixed(8))]),i=new Set([...e.map(e=>+e.y.toFixed(8))]);if(1===p.size||1===i.size)return!l||n;let u=L(s,r),h=u/1e3*t,y=U(e,!0);return y<h&&(a=!0),l&&(n.flat=a,n.steepness=y/u*10),l?n:a}function G(e=[]){let t,l=[],a=N(F(e)),{left:n,right:s,top:r,bottom:p,width:i,height:u}=a,h=e[0].values[0],y=e[0].values[1],o={x:e[0].values[0],y:e[0].values[1]},c={x:e[0].values[0],y:e[0].values[1]};e[0].idx=0,e[0].p0=o,e[0].p=o,e[0].lineto=!1,e[0].corner=!1,e[0].extreme=!1,e[0].directionChange=!1,e[0].closePath=!1,e[0].dimA=0;let x=[e[0]],f=0,g=e.length;for(let l=2;g&&l<=g;l++){let a=e[l-1],{type:i,values:u}=a,g=u.slice(-2),v=[c];a.idx=l-1,a.lineto=!1,a.corner=!1,a.extreme=!1,a.directionChange=!1,a.closePath=!1,a.dimA=0;let d,m,M,A,C,w,P=.05;t=g.length?{x:g[0],y:g[1]}:o,"M"===i?(o=t,c=t):"z"===i.toLowerCase()&&(t=o),a.p0=c,a.p=t;let k=D(c,t);a.dimA=k,"L"===i&&(a.lineto=!0),"Z"===i&&(a.closePath=!0,o.x!==h&&o.y!==y&&(a.lineto=!0)),"Q"!==i&&"C"!==i||(d={x:u[0],y:u[1]},m="C"===i?{x:u[2],y:u[3]}:null,a.cp1=d,m&&(a.cp2=m)),u.length>2&&("Q"!==i&&"C"!==i||v.push(d),"C"===i&&v.push(m),v.push(t)),"L"===i||t.x!==n&&t.y!==r&&t.x!==s&&t.y!==p||(a.extreme=!0);let F=e[l]?e[l]:null,I=F?F.values.slice(-2):null;C=F?F.type:null,!F||"Q"!==F.type&&"C"!==F.type||(A=F?{x:I[0],y:I[1]}:null,M={x:F.values[0],y:F.values[1]},"C"===F.type&&(F.values[2],F.values[3])),w=U(v);let S=f<0&&w>0||f>0&&w<0;if(f=w,S&&(a.directionChange=!0),("Q"===i||"C"===i)&&("Q"===i&&"Q"===C||"C"===i&&"C"===C)){let e=v.slice(1);if(A&&Math.abs(A.x-c.x),A&&Math.abs(A.y-c.y),!!a.extreme||Q(0,e,P))a.extreme=!0;else{let e=m?[m,t]:[d,t],l=[t,M],n=b(...e,!0),s=b(...l,!0),r=180*Math.abs(n-s)/Math.PI,p=L(...e),i=L(...l);r>10&&p&&i&&(a.corner=!0)}}x.push(a),c=t}return l={pathData:x,bb:a,dimA:(i+u)/2},l}function K(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=[];for(let s=0,r=e.length;s<r;s++){let r=e[s],{type:p,values:i}=r,u=i.length?i.slice(-2):[t.x,t.y];a={x:u[0],y:u[1]};let h=r.dimA?+r.dimA.toFixed(8):"M"!==p?+D(l,a).toFixed(8):0;h&&n.push(h),"M"===p&&(t=a),l=a}let s=n.sort(),r=Math.ceil(s.length/10);s=s.slice(0,r);let p=s.reduce((e,t)=>e+t,0)/r,i=p>60?0:Math.floor(40/p).toString().length;return Math.min(Math.max(0,i),8)}function _(e,t=-1){let l=e.length;for(let a=0;a<l;a++){let l=e[a].values,n=l.length;if(n&&t>-1)for(let s=0;s<n;s++)e[a].values[s]=+l[s].toFixed(t)}return e}function ee(e={},t={},l={},a={}){let n=P(e,t,1.5),s=P(a,l,1.5),r=.03*D(e,a),p=D(n,s),i=null,u={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return p&&r&&p<r&&(i=C(e,t,a,l,!1),i&&(u.type="Q",u.values=[i.x,i.y,a.x,a.y],u.p0=e,u.cp1=i,u.cp2=null,u.p=a)),u}function te(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!1){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?ae(e):e;let n=e.length,s=new Array(n),r={type:"M",values:e[0].values};s[0]=r;let p,i={x:e[0].values[0],y:e[0].values[1]},u=.01;for(let l=1;l<n;l++){let a=e[l],{type:n,values:h}=a,y=h.length,o=[h[y-2],h[y-1]],c=e[l-1],x=c.type;p={x:o[0],y:o[1]};let f,g,v,d,m={x:h[0],y:h[1]},M=Math.abs(p.x-i.x),b=Math.abs(p.y-i.y),A=(M+b)/2*u;switch(n){case"L":r=0===b||b<A&&M>A?{type:"H",values:[h[0]]}:0===M||b>A&&M<A?{type:"V",values:[h[1]]}:a;break;case"Q":if("Q"!==x){i={x:o[0],y:o[1]},s[l]=a;continue}let e={x:c.values[0],y:c.values[1]};d={x:2*i.x-e.x,y:2*i.y-e.y},f=Math.abs(m.x-d.x),g=Math.abs(m.y-d.y),v=(f+g)/2,r=v<A?{type:"T",values:[p.x,p.y]}:a;break;case"C":let t={x:h[2],y:h[3]};if("C"!==x){s[l]=a,i={x:o[0],y:o[1]};continue}let u={x:c.values[2],y:c.values[3]};d={x:2*i.x-u.x,y:2*i.y-u.y},f=Math.abs(m.x-d.x),g=Math.abs(m.y-d.y),v=(f+g)/2,r=v<A?{type:"S",values:[t.x,t.y,p.x,p.y]}:a;break;default:r={type:n,values:h}}(a.decimals||0===a.decimals)&&(r.decimals=a.decimals),t>-1&&(r.values=r.values.map(e=>+e.toFixed(t))),i={x:o[0],y:o[1]},s[l]=r}return s}(e)),a>-1&&l&&(e=_(e,a)),l&&(e=function(e,t=-1){return ae(e,!0,t)}(e)),a>-1&&(e=_(e,a)),e}function le(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let l={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},a={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[l.x,l.y,a.x,a.y,t[2],t[3]]}}function ae(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e[0].values,n=a[0],s=a[1],r=n,p=s;for(let a=1,i=e.length;a<i;a++){let i=e[a],{type:u,values:h}=i,y=t?u.toLowerCase():u.toUpperCase();if(u!==y)switch(u=y,i.type=u,u){case"a":case"A":h[5]=t?h[5]-n:h[5]+n,h[6]=t?h[6]-s:h[6]+s;break;case"v":case"V":h[0]=t?h[0]-s:h[0]+s;break;case"h":case"H":h[0]=t?h[0]-n:h[0]+n;break;case"m":case"M":t?(h[0]-=n,h[1]-=s):(h[0]+=n,h[1]+=s),r=t?h[0]+n:h[0],p=t?h[1]+s:h[1];break;default:if(h.length)for(let e=0;e<h.length;e++)h[e]=t?h[e]-(e%2?s:n):h[e]+(e%2?s:n)}let o=h.length;switch(u){case"z":case"Z":n=r,s=p;break;case"h":case"H":n=t?n+h[0]:h[0];break;case"v":case"V":s=t?s+h[0]:h[0];break;case"m":case"M":r=h[o-2]+(t?n:0),p=h[o-1]+(t?s:0);default:n=h[o-2]+(t?n:0),s=h[o-1]+(t?s:0)}l>=0&&(i.values=i.values.map(e=>+e.toFixed(l)))}return e}function ne(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}e=l&&a?function(e,t=-1){return ae(e,!1,t)}(e,t):e;let n=[],s={type:"M",values:e[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,p,i,u,h,y,o,c=e[l],{type:x,values:f}=c,g=f.length,v=s.values,d=v.length,[m,M]=[f[g-2],f[g-1]],[b,A]=[v[d-2],v[d-1]];switch(x){case"H":s={type:"L",values:[f[0],A]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],p=b+(b-a),i=A+(A-r),s={type:"Q",values:[p,i,m,M]};break;case"S":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],[y,o]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,A],p=2*b-y,i=2*A-o,u=f[0],h=f[1],s={type:"C",values:[p,i,u,h,m,M]};break;default:s={type:x,values:f}}t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),n.push(s)}return n}function se({p0:e={x:0,y:0},p:t={x:0,y:0},centroid:l={x:0,y:0},rx:a=0,ry:n=0,xAxisRotation:s=0,radToDegree:r=!1,startAngle:p=null,endAngle:i=null,deltaAngle:u=null}={}){if(!a||!n)return[];let h=[];const y=1.5707963267948966;let o=r?s:s*Math.PI/180,c=Math.cos(o),x=Math.sin(o);null!==p&&null!==i&&null!==u||({startAngle:p,endAngle:i,deltaAngle:u}=A(l,e,t));let f=a!==n?z(p,a,n):p,g=a!==n?z(u,a,n):u,v=Math.max(1,Math.ceil(Math.abs(g)/y)),d=g/v;for(let e=0;e<v;e++){const e=Math.abs(d)===y?.551785*Math.sign(d):4/3*Math.tan(d/4);let t=Math.cos(f),s=Math.sin(f),r=Math.cos(f+d),p=Math.sin(f+d),i=[];[{x:t-s*e,y:s+t*e},{x:r+p*e,y:p-r*e},{x:r,y:p}].forEach(e=>{let t=e.x*a,s=e.y*n;i.push(c*t-x*s+l.x,x*t+c*s+l.y)}),h.push({type:"C",values:i,cp1:{x:i[0],y:i[1]},cp2:{x:i[2],y:i[3]},p:{x:i[4],y:i[5]}}),f+=d}return h}function re(e,t,l=1){const a=2*Math.PI;let[n,s,r,p,i,u,h]=t;if(0===n||0===s)return[];let y=r?r*a/360:0,o=y?Math.sin(y):0,c=y?Math.cos(y):1,x=c*(e.x-u)/2+o*(e.y-h)/2,f=-o*(e.x-u)/2+c*(e.y-h)/2;if(0===x&&0===f)return[];n=Math.abs(n),s=Math.abs(s);let g=x*x/(n*n)+f*f/(s*s);if(g>1){let e=Math.sqrt(g);n*=e,s*=e}let v=n*n,d=n===s?v:s*s,m=x*x,M=f*f,b=v*d-v*M-d*m;b<=0?b=0:(b/=v*M+d*m,b=Math.sqrt(b)*(p===i?-1:1));let A=b?b*n/s*f:0,C=b?b*-s/n*x:0,w=c*A-o*C+(e.x+u)/2,L=o*A+c*C+(e.y+h)/2,P=(x-A)/n,k=(f-C)/s,F=(-x-A)/n,I=(-f-C)/s;const S=(e,t,l,a)=>{let n=+(e*l+t*a).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*a-t*l<0?-1:1)*Math.acos(n))};let $=S(1,0,P,k),z=S(P,k,F,I);0===i&&z>0?z-=2*Math.PI:1===i&&z<0&&(z+=2*Math.PI);let Q=(+(Math.abs(z)/(a/4)).toFixed(0)||1)*l;z/=Q;let E=[];const T=1.5707963267948966,D=.551785;let q=z===T?D:z===-T?-D:4/3*Math.tan(z/4),B=z?Math.cos(z):1,j=z?Math.sin(z):0;const Z=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,p=Math.cos(e+t),i=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:p+i*l,y:i-p*l},{x:p,y:i}]};for(let e=0;e<Q;e++){let e={type:"C",values:[]};Z($,z,q,B,j).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-o*a+w,o*l+c*a+L)}),E.push(e),$+=z}return E}function pe(e,t,l,a,n=7.5){let s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},r=0,p=!1,i=b(e,t,!0),u=b(a,l,!0),h=180*Math.abs(i-u)/Math.PI;if(Math.abs(h%180-90)<3){let i=C(e,t,a,l,!1);if(i){let u=w(e,i),h=w(a,i),y=+Math.max(u,h).toFixed(8),o=+Math.min(u,h).toFixed(8),c=o,x=y,f=U([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/c*Math.abs(c-x)<5&&(c=y,x=c),g&&(c=y,x=o);let v=H([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),d={type:"A",values:[c,x,0,0,f,a.x,a.y]};r=Math.PI*(c*x)/4,r-=Math.abs(U([e,a,i])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<n&&(p=!0,s=d)}}return{com:s,isArc:p,area:r}}function ie(e){let t,l=[[]],a=0,n=[[]],s={x:e[0].values[0],y:e[0].values[1]};for(let r=0,p=e.length;r<p;r++){let p=e[r],{type:i,values:u}=p;if("A"===i){let i=e[r-1].values.slice(-2);s={x:i[0],y:i[1]};let[h,y,o,c,x,f,g]=u,v=100/h*Math.abs(h-y)<5;t={x:u[5],y:u[6]},p.p0=s,p.p=t,p.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(p),n[a].push(r)),d&&"A"===d.type){let[e,p,i,u,o,c,x]=d.values,f=h!=e?100/h*Math.abs(h-e):0,g=y!=p?100/y*Math.abs(y-p):0;t={x:d.values[5],y:d.values[6]},d.p0=s,d.p=t,f<5&&g<5?(l[a].push(d),n[a].push(r+1)):(l.push([]),n.push([]),a++)}else l.push([]),n.push([]),a++}}if(!n.length)return e;l=l.filter(e=>e.length),n=n.filter(e=>e.length);for(let t=l.length-1;t>=0;t--){const a=l[t],s=n[t][0],r=a.length;let p=0,i=0;a.forEach(({values:e})=>{const[t,l]=e;p+=t,i+=l}),p/=r,i/=r;let u=100/p*Math.abs(p-i)<5;u&&(p=(p+i)/2,i=p);let h=e[s-1].values.slice(-2);if(h[0],h[1],4===r){let[t,l,n,h,y,o,c]=a[1].values,[,,,,,x,f]=a[3].values;u&&(p=1,i=1);let g={type:"A",values:[p,i,n,h,y,o,c]},v={type:"A",values:[p,i,n,h,y,x,f]};e.splice(s,r,g,v)}else if(3===r){let[t,l,n,u,h,y,o]=a[0].values,[c,x,,,,f,g]=a[2].values;u=1;let v={type:"A",values:[p,i,n,u,h,f,g]};e.splice(s,r,v)}else if(2===r){let[t,l,n,h,y,o,c]=a[0].values,[x,f,,,,g,v]=a[1].values;u&&(p=1,i=1,n=0);let{p0:d,p:m}=a[0],[M,b]=[a[1].p0,a[1].p];if(d.x!==b.x||d.y!==b.y){let t={type:"A",values:[p,i,n,h,y,g,v]};e.splice(s,r,t)}}}return e}function ue(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2,hasRelatives:r=!0,hasShorthands:p=!0,hasQuadratics:i=!0,hasArcs:u=!0,testTypes:h=!1}={}){if(h){let t=Array.from(new Set(e.map(e=>e.type))).join("");r=/[lcqamts]/gi.test(t),i=/[qt]/gi.test(t),u=/[a]/gi.test(t),p=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(i&&a||u&&n)&&(l=!0,t=!0),r&&t&&(e=ae(e,!1)),p&&l&&(e=ne(e,-1,!1)),u&&n&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],s=e[a-1].values,r=s.length,p={x:s[r-2],y:s[r-1]};"A"===n.type?re(p,n.values,t).forEach(e=>{l.push(e)}):l.push(n)}return l}(e,s)),i&&a&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,s=n.length,r={x:n[s-2],y:n[s-1]};"Q"===a.type?t.push(le(r,a.values)):t.push(a)}return t}(e)),e}function he(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=Array.isArray(e),p=r&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,i=r?e:function(e,t=!0){if(e=e.trim(),""===e)return{pathData:[],hasRelatives:!1,hasShorthands:!1,hasQuadratics:!1,hasArcs:!1};const l=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),a=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&l.has(e);let n,s=0,r=e.length,p="",i=[],u=-1,h="",y=!1,o=0,c=0,x=0,f=!1,g=new Set([]),v=[];const d=()=>{f&&("M"===p?p="L":"m"===p&&(p="l"),i.push({type:p,values:[]}),u++,c=0,f=!1)},m=(e=!1)=>{(e?o>0:""!==h)&&(t&&-1===u&&(n="Pathdata must start with M command",v.push(n),p="M",i.push({type:p,values:[]}),x=2,c=0,u++),"A"===p||"a"===p?(h=M(),i[u].values.push(...h)):(t&&h[1]&&"."!==h[1]&&"0"===h[0]&&(n=`${u}. command: Leading zeros not valid: ${h}`,v.push(n)),i[u].values.push(+h)),c++,h="",o=0,f=c>=x)},M=()=>{let e=h.length,t=!1;return 3===c&&2===e||4===c&&e>1?(h=[+h[0],+h[1]],t=!0,c++):3===c&&e>=3&&(h=[+h[0],+h[1],+h.substring(2)],t=!0,c+=2),t?h:[+h]},b=()=>{if(u>0){let e=i[u].values.length;if(e&&e<x||e&&e>x||("z"===p||"Z"===p)&&e>0){n=`${u}. command of type "${p}": ${x-e} values too few - ${x} expected`,v[v.length-1]!==n&&v.push(n)}}};let A=!1,C=!1,w=!1;for(;s<r;){let l=e.charCodeAt(s),r=l>47&&l<58;if(r||(A=101===l||69===l,C=45===l||43===l,w=46===l),r||C||w||A){if(y||45!==l&&46!==l)d();else{let e=46===l;m(e),d(),e&&o++}h+=e[s],y=A,s++}else if((l<48||l>5759)&&a(l))m(),s++;else{if(l>64){if(!ye.has(l)){n=`${u}. command "${e[s]}" is not a valid type`,v.push(n),s++;continue}""!==h&&(i[u].values.push(+h),c++,h=""),t&&b(),p=e[s],x=oe[l];let a="M"===p||"m"===p,r=u>0&&("z"===i[u].type||"Z"===i[u].type);g.add(p),r&&!a&&(i.push({type:"m",values:[0,0]}),u++),i.push({type:p,values:[]}),u++,o=0,c=0,f=!1,s++;continue}r||(n=`${u}. ${e[s]} is not a valid separarator or token`,v.push(n),h=""),s++}}m(),t&&b();t&&v.length&&(n="Invalid path data:\n"+v.join("\n"),"log"===t?console.log(n):console.warn(n));i[0].type="M";let L=Array.from(g).join(""),P=/[lcqamts]/g.test(L),k=/[vhst]/gi.test(L),F=/[a]/gi.test(L),I=/[qt]/gi.test(L);return{pathData:i,hasRelatives:P,hasShorthands:k,hasQuadratics:I,hasArcs:F}}(e),{hasRelatives:u=!0,hasShorthands:h=!0,hasQuadratics:y=!0,hasArcs:o=!0}=i,c=p?i:i.pathData;return c=ue(c,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s,hasRelatives:u,hasShorthands:h,hasQuadratics:y,hasArcs:o}),c}const ye=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),oe=new Uint8Array(128);function ce(e){if("path"===e.nodeName.toLowerCase())return e;let t=function(e,t=!1){let l,a,n,s,r,p,i,u,h,y,o,c,x,f,g,v,d=[],m=e.nodeName;const M=(e,t=9)=>{const l="svg"!==e.nodeName?e.closest("svg"):e,a=e=>{if(null===e)return 0;let l=96,a=e.match(/([a-z]+)/gi);a=a?a[0]:"";let n,s=parseFloat(e);if(!a)return s;switch(a){case"in":n=l;break;case"pt":n=1/72*96;break;case"cm":n=1/2.54*96;break;case"mm":n=1/2.54*96/10;break;case"em":case"rem":n=16;break;default:n=1}return+(s*n).toFixed(t)};let n=l.getAttribute("width");n=n?a(n):300;let s=l.getAttribute("height");s=n?a(s):150;let r=l.getAttribute("viewBox");r=r?r.replace(/,/g," ").split(" ").filter(Boolean).map(e=>+e):[];let p=r.length?r[2]:n,i=r.length?r[3]:s,u=p/100,h=i/100,y=Math.sqrt((Math.pow(u,2)+Math.pow(h,2))/2),o=["x","width","x1","x2","rx","cx","r"],c=["y","height","y1","y2","ry","cy"];e.getAttributeNames().forEach(t=>{let l=e.getAttribute(t),n=l;if(o.includes(t)||c.includes(t)){let s=o.includes(t)?u:h;s="r"===t&&p!=i?y:s;let r=l.match(/([a-z|%]+)/gi);r=r?r[0]:"",n=l.includes("%")?parseFloat(l)*s:a(l),e.setAttribute(t,+n)}})};M(e);const b=t=>(l={},t.forEach(t=>{l[t]=+e.getAttribute(t)}),l);switch(m){case"path":n=e.getAttribute("d"),d=he(n);break;case"rect":a=["x","y","width","height","rx","ry"],({x:s,y:r,width:p,height:i,rx:h,ry:y}=b(a)),h||y?(h>p/2&&(h=p/2),y>i/2&&(y=i/2),d=[{type:"M",values:[s+h,r]},{type:"L",values:[s+p-h,r]},{type:"A",values:[h,y,0,0,1,s+p,r+y]},{type:"L",values:[s+p,r+i-y]},{type:"A",values:[h,y,0,0,1,s+p-h,r+i]},{type:"L",values:[s+h,r+i]},{type:"A",values:[h,y,0,0,1,s,r+i-y]},{type:"L",values:[s,r+y]},{type:"A",values:[h,y,0,0,1,s+h,r]},{type:"Z",values:[]}]):d=[{type:"M",values:[s,r]},{type:"L",values:[s+p,r]},{type:"L",values:[s+p,r+i]},{type:"L",values:[s,r+i]},{type:"Z",values:[]}];break;case"circle":case"ellipse":a=["cx","cy","rx","ry","r"],({cx:o,cy:c,r:u,rx:h,ry:y}=b(a));let t="circle"===m;t?(h=u,y=u):(h=h||u,y=y||u);let l=t&&u>=1?1:h,M=t&&u>=1?1:h;d=[{type:"M",values:[o+h,c]},{type:"A",values:[l,M,0,1,1,o-h,c]},{type:"A",values:[l,M,0,1,1,o+h,c]}];break;case"line":a=["x1","y1","x2","y2"],({x1:x,y1:g,x2:f,y2:v}=b(a)),d=[{type:"M",values:[x,g]},{type:"L",values:[f,v]}];break;case"polygon":case"polyline":let A=e.getAttribute("points").replaceAll(","," ").split(" ").filter(Boolean);for(let e=0;e<A.length;e+=2)d.push({type:0===e?"M":"L",values:[+A[e],+A[e+1]]});"polygon"===m&&d.push({type:"Z",values:[]})}return t?function(e){return e.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ")}(d):d}(e),l=t.map(e=>`${e.type} ${e.values} `).join(" "),a=[...e.attributes].map(e=>e.name),n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",l);let s=["x","y","cx","cy","dx","dy","r","rx","ry","width","height","points"];return a.forEach(t=>{if(!s.includes(t)){let l=e.getAttribute(t);n.setAttribute(t,l)}}),n}function xe(e,{tolerance:t=1,flatBezierToLinetos:l=!0}={}){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s=n,r=n;e[e.length-1].type.toLowerCase();for(let p=1,i=e.length;p<i;p++){let u=e[p],h=e[p+1]||e[i-1],y="z"===h.type.toLowerCase()?n:{x:h.values[h.values.length-2],y:h.values[h.values.length-1]},{type:o,values:c}=u,x=c.slice(-2);r="Z"!==o?{x:x[0],y:x[1]}:n;let f=y?U([s,r,y],!0):1/0,g=L(s,y),v=f<(g?g/333*t:0),d=!1;if(l||"C"!==o||(v=!1),l&&("C"===o||"Q"===o)){d=Y([s,..."C"===o?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===o?[{x:c[0],y:c[1]}]:[],r],{tolerance:t}),d&&p<i-1&&(o="L",u.type="L",u.values=x)}v&&p<i-1&&"A"!==h.type&&("L"===o||l&&d)||(s=r,"M"===o?(n=r,s=n):"Z"===o&&(s=n),a.push(u))}return a}function fe(e){let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l];if(!a)continue;let{type:n=null,values:s=[]}=a,r=e[l+1]?e[l+1]:null;"M"!==n&&"m"!==n||r&&(!r||"Z"!==r.type&&"z"!==r.type)?t.push(a):r&&l++}return t}function ge(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,s=e.length;n<s;n++){let s=e[n],r=e[n-1],p=e[n+1]||null,{type:i,values:u}=s,h="m"===r.type.toLowerCase()&&!p,y=u.length;if(l={x:u[y-2],y:u[y-1]},h||"L"!==i||l.x!==t.x||l.y!==t.y){if(!h&&("l"===i||"v"===i||"h"===i)){if("l"===i?"00"===u.join(""):0===u[0])continue}a.push(s),t=l}}return a}function ve(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let l=0,a=[];for(let l=0;l<t;l++){let t=e[l],{type:n,values:s}=t,r=s.length;if(r){let e={type:n,x:s[r-2],y:s[r-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(3)-+t.y.toFixed(3)),l=a[0].index,l?me(e,l):e}function de(e,{removeFinalLineto:t=!0,autoClose:l=!0}={}){let a=[],n=e.length,s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},r="z"===e[n-1].type.toLowerCase(),p=e.filter(e=>"L"===e.type),i=e[r?n-2:n-1],u=i.type,h=i.values.slice(-2).map(e=>+e.toFixed(8)),y=h[0]===s.x&&h[1]===s.y;!r&&l&&y&&(e.push({type:"Z",values:[]}),r=!0,n++);let o="L"!==e[1].type&&(!y||"L"===i.type);if(o=!1,!r)return e;let c=0;{let t=[];for(let l=0;l<n;l++){let a=e[l],{type:n,values:s}=a;if(s.length){let a=s.slice(-2),r=e[l-1]&&"L"===e[l-1].type,p=e[l+1]&&"L"===e[l+1].type,i=e[l-1]?e[l-1].type.toUpperCase():null,u=e[l+1]?e[l+1].type.toUpperCase():null,h={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:r,nextL:p,prevCom:i,nextCom:u};h.index=l,t.push(h)}}if(p.length){let e=t.filter(e=>"L"!==e.type&&"M"!==e.type&&e.prevCom&&"L"===e.prevCom||"M"===e.prevCom&&"L"===u).sort((e,t)=>e.y-t.y||e.x-t.x)[0];c=e?e.index-1:0}else t=t.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),c=t[0].index;e=c?me(e,c):e}return s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,i=e[n-2],u=i.type,h=i.values.slice(-2).map(e=>+e.toFixed(8)),y="L"===u&&h[0]===s.x&&h[1]===s.y,t&&y&&e.splice(n-2,1),a.push(...e),a}function me(e,t){let l=0,a="z"===e[e.length-1].type.toLowerCase();if(!a||t<1||e.length<3)return e;let n=a?1:0;!function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[n,s]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),r=l?e[t-2]:e[t-1],p=r.values.length,[i,u]=[r.values[p-2],r.values[p-1]].map(e=>+e.toFixed(8));!l||n==i&&s==u||(e.pop(),e.push({type:"L",values:[n,s]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let s,r,p=e.slice(l),i=e.slice(0,l);return i.shift(),s=i[i.length-1].values||[],r=[s[s.length-2],s[s.length-1]],n&&(p.pop(),i.push({type:"Z",values:[]})),e=[{type:"M",values:r},...p,...i]}function Me(e,{threshold:t=null,tolerance:l=1}={}){if(!t){let l=function(e){let t=1/0,l=-1/0,a=1/0,n=-1/0;const s=e=>{e.x<t&&(t=e.x),e.x>l&&(l=e.x),e.y<a&&(a=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let l=e[t],{type:a,values:n}=l,r=n.length,p=(e[t-1]?e[t-1]:e[t]).values,i=p.length;if(r){let e={x:p[i-2],y:p[i-1]},t={x:n[r-2],y:n[r-1]};if(s(t),"C"===a||"Q"===a){let l={x:n[0],y:n[1]},r="C"===a?{x:n[2],y:n[3]}:l,p="C"===a?[e,l,r,t]:[e,l,t];E(p).forEach(e=>{let t=k(p,e);s(t)})}else"A"===a&&T(e,n).forEach(e=>{s(e)})}}return{x:t,y:a,width:l-t,height:n-a}}(e);t=(l.width+l.height)/2*.05}let a=e.length;for(let n=0;n<a;n++){let a=e[n],{type:s,values:r,extreme:p,corner:i=!1,dimA:u,p0:h,p:y}=a,o=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(o?D(y,o.p):1/0)<t,f=(c?D(c.p,o.p):1/0)<t;if(o&&"C"===s&&"C"===o.type&&p&&c&&c.extreme&&(f||x)){let a=W(o,c,t,l,!1);if(1===a.length){e[n+1]=null,a=a[0],e[n+2].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,a.p.x,a.p.y],e[n+2].cp1=a.cp1,e[n+2].cp2=a.cp2,e[n+2].p0=a.p0,e[n+2].p=a.p,e[n+2].extreme=a.extreme,n++;continue}}if(o&&"C"===s&&"C"===o.type&&p&&x){let t,l=a.cp1.x-o.p0.x,s=a.cp1.y-o.p0.y,r=Math.abs(s)<Math.abs(l),p=o.p,i=1,u=U([a.p0,a.p,o.p]),h=U([a.p0,a.cp1,a.cp2,a.p]);if(u<0&&h>0||u>0&&h<0)continue;if(o.extreme){r?(i=Math.abs(Math.abs(o.cp2.x-o.p.x)/Math.abs(a.cp2.x-a.p.x)),i=Math.min(1,i),t=P(o.p,a.cp2,1+i),a.cp2.x=t.x):(i=Math.abs(Math.abs(o.cp2.y-o.p.y)/Math.abs(a.cp2.y-a.p.y)),i=Math.min(1,i),t=P(o.p,a.cp2,1+i),a.cp2.y=t.y),e[n+1].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,p.x,p.y],e[n+1].cp1=a.cp1,e[n+1].cp2=a.cp2,e[n+1].p0=a.p0,e[n+1].p=p,e[n+1].extreme=!0,e[n]=null;continue}}}a=(e=e.filter(Boolean)).length;let n="z"===e[a-1].type.toLowerCase()?a-2:a-1,s=e[n],r=e[n-1]||null,p={x:e[0].values[0],y:e[0].values[1]},i=s.values.slice(-2),u=+i[0].toFixed(8)===+p.x.toFixed(8)&&+i[1].toFixed(8)===+p.y.toFixed(8),h="C"===e[1].type&&e[1].extreme?e[1]:null,y=D(s.p0,s.p)<t;if(r&&"C"===r.type&&y&&u&&h){let a=W(r,s,t,l,!1);1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function be(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}function Ae(e,{threshold:t=0,tolerance:l=1}={}){let a=e.length,n=[e[0]],s="z"===e[a-1].type.toLowerCase(),r=!!s&&(e[a-1].p.x===e[0].p0.x&&e[a-1].p.y===e[0].p0.y),p=s?2:1,i=e[a-p],u="L"===i.type,h="C"===i.type,y="L"===e[1].type,o="C"===e[1].type,c=s&&o&&(u||r);c&&(e[a-1].values=e[0].values,e[a-1].type="L",u=!0);for(let t=1;t<a;t++){let r=e[t],{type:i}=r,x=e[t+1]?e[t+1]:null;if("L"===i&&x&&"C"===x.type||"C"===i&&x&&"L"===x.type){let c="L"===i?r:null,f=null,g=[],v=0;if(1===t&&o&&u&&(g=[e[1]],c=e[a-1],f=x),!c){n.push(r);continue}s&&h&&y&&t===a-p-1&&(f=e[1],g=[e[a-p]]);for(let l=t+1;l<a;l++){let t=e[l]?e[l]:null,a=e[l-1];if("C"===a.type&&g.push(a),"L"===t.type&&"C"===a.type){f=t;break}v++}if(f){let e=D(c.p0,c.p),a=D(f.p0,f.p),s=g.length,p=D(g[0].p0,g[s-1].p),i=U([c.p0,c.p,f.p0,f.p],!1),u=U([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),h=i<0&&u>0||i>0&&u<0,y=.5*p*l,o=y<e&&y<a;if(g.length&&!h&&o){let e=Math.abs(u)<=.005*L(g[0].p0,g[0].p),l=e?null:C(c.p0,c.p,f.p0,f.p,!1);if(!e&&l){if(!(D(k([c.p,l,f.p0],.5),1===g.length?k([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p)>p)){let e={type:"Q",values:[l.x,l.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=l,e.p=f.p0,n.push(c,e),t+=v;continue}n.push(r)}}}}c&&t===a-1&&"L"===i||n.push(r)}return(c||s&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function Ce(e){if(e.length<3)return!1;let t=e[0],l=e[Math.floor(e.length/2)],a=e[e.length-1],n=t.x,s=t.y,r=l.x,p=l.y,i=a.x,u=a.y,h=n-r,y=s-p,o=n-i,c=s-u,x=(n*n-r*r+(s*s-p*p))/2,f=(n*n-i*i+(s*s-u*u))/2,g=h*c-y*o;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let v={x:(c*x-y*f)/g,y:(-o*x+h*f)/g},d=w(v,t),m=A(v,t,a),{deltaAngle:M,startAngle:b,endAngle:C}=m;return{centroid:v,r:d,startAngle:b,endAngle:C,deltaAngle:M}}function we(e,{threshold:l=0,tolerance:a=1,toCubic:n=!1,debug:s=!1}={}){let r=e.length,p=[e[0]],i=[];for(let l=1;l<r;l++){let a=e[l],{type:r}=a,u=e[l-1],h=e[l+1]?e[l+1]:null,y=e[l+2]?e[l+2]:null,o=e[l+3]?e[l+3]:null,c=null;"C"===a.type||"Q"===a.type?c=a:!h||"C"!==h.type&&"Q"!==h.type||(c=h);let x,f,g,v,d,m=c?"C"===c.type?[c.p0,c.cp1,c.cp2,c.p]:[c.p0,c.cp1,c.p]:[],M=0,b=0,A=!1,C=!1,w=[];if("L"===u.type&&"L"===r&&c&&"L"===y.type&&o&&("L"===o.type||"Z"===o.type)?(x=[a.p0,a.p],f=[y.p0,y.p],g=a.p0,v=y.p,M=U(m,!1),b=U([...x,...f],!1),A=M<0&&b>0||M>0&&b<0,A||(d=k(m,.5),w=[g,d,v],C=!0)):"C"!==r&&"Q"!==r||"L"!==u.type||"C"!==h.type&&"Q"!==h.type||"L"!==y.type||(C=!0,x=[u.p0,u.p],f=[y.p0,y.p],g=u.p,v=y.p0,d=c.p,w=[g,c.p,v]),C){let e=Ce(w);if(e){let r,{centroid:u,r:h,deltaAngle:y,startAngle:o,endAngle:c}=e,x=0,f=y>0?1:0,m=Math.abs(y)>Math.PI?1:0;if(D(S(g,u.x,u.y,.5*y),d)<.05*D(g,v)){if(r=se({p0:g,p:v,centroid:u,rx:h,ry:h,xAxisRotation:x,sweep:f,largeArc:m,deltaAngle:y,startAngle:o,endAngle:c}),1===r.length){let e=ee(g,r[0].cp1,r[0].cp2,v);"Q"===e.type&&(n=!0),a=e}if(r.length>1&&(n=!1),n||(a.type="A",a.values=[h,h,x,m,f,v.x,v.y]),a.p0=g,a.p=v,a.extreme=!1,a.corner=!1,s){i=n?[{type:"M",values:[g.x,g.y]},...r]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[h,h,x,m,f,v.x,v.y]}];let e=V(i);t(markers,e,"orange","0.5%","0.5")}p.push(a),l++;continue}}}p.push(a)}return p}function Le(e=[],{threshold:t=0}={}){let l=e.length,a="z"===e[l-1].type.toLowerCase(),n=a?l-2:l-1,s=e[n],r=s.values.slice(-2),p={x:e[0].values[0],y:e[0].values[1]},i=D(p,{x:r[0],y:r[1]});if(i&&i<t){let l=e[n].values.length;e[n].values[l-2]=p.x,e[n].values[l-1]=p.y;let a=e[1];if("C"===a.type&&"C"===s.type){let l=Math.abs(a.values[0]-s.values[2]),r=Math.abs(a.values[1]-s.values[3]),i=Math.abs(e[1].values[0]-a.values[0]),u=Math.abs(e[1].values[1]-a.values[1]),h=Math.abs(e[1].values[0]-s.values[2]),y=Math.abs(e[1].values[1]-s.values[3]),o=u<t&&y<t&&l;l&&l<t&&(i<t&&h<t&&r)&&(e[1].values[0]=p.x,e[n].values[2]=p.x),r&&r<t&&o&&(e[1].values[1]=p.y,e[n].values[3]=p.y)}}return e}function Pe(e,t=1){let l=[];for(let a=0,n=e.length;a<n;a++){let n=e[a],{type:s,values:r}=n,p={type:s,values:[]};switch(s.toLowerCase()){case"h":case"v":p.values=[r[0]*t];break;case"a":p.values=[r[0]*t,r[1]*t,r[2],r[3],r[4],r[5]*t,r[6]*t];break;default:r.length&&(p.values=r.map((e,l)=>e*t))}l.push(p)}return l}function ke(e="",{getObject:t=!1,toAbsolute:l=!0,toRelative:a=!0,toShorthands:n=!0,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:p=!1,simplifyBezier:i=!0,optimizeOrder:u=!0,autoClose:h=!0,removeZeroLength:y=!0,refineClosing:o=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:v=!1,keepExtremes:d=!0,keepCorners:m=!0,extrapolateDominant:M=!0,keepInflections:b=!1,addExtremes:A=!1,removeOrphanSubpaths:C=!1,simplifyRound:w=!1,scale:L=1,scaleTo:P=0,decimals:k=3,autoAccuracy:I=!0,minifyD:S=0,tolerance:$=1,reverse:z=!1,mergePaths:Q=!1,removeHidden:E=!0,removeUnused:T=!0,shapesToPaths:D=!0}={}){$=Math.max(.1,$);let B=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"array";if("string"==typeof e){let l=(e=e.trim()).includes("<svg")&&e.includes("</svg"),a=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(n)t="polyString";else{let l=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),a=e.startsWith("data:image");t=l||a?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),j="",O=0,R=0,H=0,U={},W="",X="svgMarkup"===B?1:0,Y=[];if(O=e.length,X){if(j=function(e,{returnDom:t=!1,removeHidden:l=!0,removeUnused:a=!0}={}){e=(e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()).replaceAll("xlink:href=","href=");let n=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)||e.removeAttribute(l)})}(n,["viewBox","xmlns","width","height","id","class","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"]);let s=["metadata","script"];return n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),r=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||s.includes(t)||l&&r?e.remove():function(e){[...e.attributes].map(e=>e.name).forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t?n:be(n)}(e,{returnDom:!0,removeHidden:E,removeUnused:T}),D){j.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=ce(e);e.replaceWith(t)})}j.querySelectorAll("path").forEach(e=>{Y.push({d:e.getAttribute("d"),el:e})})}else{if("pathDataString"===B)W=e;else if("polyString"===B)W="M"+e;else if("pathData"===B){W=e,O=W.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}Y.push({d:W,el:null})}let _={toRelative:a,toShorthands:n,decimals:k},le=[];for(let e=0,t=Y.length;t&&e<t;e++){let t=Y[e],{d:a,el:n}=t,E=he(a,{quadraticToCubic:s,toAbsolute:l,arcToCubic:r});if(1!==L||P){if(P){let e=E.map(e=>({type:e.type,values:e.values}));e=Z(e);let t=P/N(F(e)).width;L=t}E=Pe(E,L)}let T=E.length;C&&(E=fe(E));let D=q(E),B=D.length,j=[];for(let e=0;e<B;e++){let t=D[e];(c||y)&&(t=ge(t)),A&&(t=Z(t,0,1)),u&&(t=ve(t)),c&&(t=xe(t,{tolerance:$,flatBezierToLinetos:!1}));let l=G(t),{pathData:a,bb:n,dimA:s}=l;if(o&&(a=Le(a,{threshold:.001*s})),a=i?J(a,{simplifyBezier:i,keepInflections:b,keepExtremes:d,keepCorners:m,extrapolateDominant:M,revertToQuadratics:f,tolerance:$,reverse:z}):a,g){a=Me(a,{threshold:(n.width+n.height)/2*.05,tolerance:$})}if(p){let e=1;for(let t=0,l=a.length;t<l;t++){let l=a[t],{type:n,values:s,p0:r,cp1:p=null,cp2:i=null,p:u=null}=l;if("C"===n){let l=pe(r,p,i,u,e);l.isArc&&(a[t]=l.com)}}a=ie(a)}if(c&&x&&(a=xe(a,{tolerance:$,flatBezierToLinetos:x})),v){a=Ae(a,{threshold:(n.width+n.height)/2*.1,tolerance:$})}if(w&&(a=we(a)),f)for(let e=0,t=a.length;e<t;e++){let t=a[e],{type:l,values:n,p0:s,cp1:r=null,cp2:p=null,p:i=null}=t;if("C"===l){let l=ee(s,r,p,i);"Q"===l.type&&(l.extreme=t.extreme,l.corner=t.corner,l.dimA=t.dimA,a[e]=l)}}u&&(a=de(a,{autoClose:h})),j.push({pathData:a,bb:n})}if(u&&(j=j.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x)),E=[],j.forEach(e=>{E.push(...e.pathData)}),I&&(k=K(E),_.decimals=k),n&&Q)le.push(...E);else{E=te(E,_),E=ge(E);let e=E.length,l=V(E,S);R=l.length,H=+(100/O*R).toFixed(2),t.d=l,t.report={original:T,new:e,saved:T-e,compression:H,decimals:k},n&&n.setAttribute("d",l)}}if(X){if(le.length){let e=te(le,_);e=ge(e);let t=V(e,S);Y[0].el.setAttribute("d",t);for(let e=1;e<Y.length;e++){let t=Y[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(j)}if(L){let e=function(e=null,t=-1){const l=e=>e&&isNaN(e)?e.match(/[^\d]+/g)[0]:"";if(!e)return!1;let a=e.hasAttribute("width"),n=e.hasAttribute("height"),s=e.hasAttribute("viewBox"),r=a?e.getAttribute("width"):0,p=n?e.getAttribute("height"):0,i=!!a&&l(r),u=!!n&&l(r),h=r?r.includes("%")?0:parseFloat(r):300,y=p?p.includes("%")?0:parseFloat(p):150,o=s?e.getAttribute("viewBox").split(/,| /).filter(Boolean).map(Number):[0,0,h,y];return t>-1&&([h,y]=[h,y].map(e=>+e.toFixed(t)),o=o.map(e=>+e.toFixed(t))),{x:o[0],y:o[1],width:o[2],height:o[3],w:h,h:y,hasViewBox:s,hasWidth:a,hasHeight:n,widthUnit:i,heightUnit:u}}(j,k),{x:t,y:l,width:a,height:n,w:s,h:r,hasViewBox:p,hasWidth:i,hasHeight:u,widthUnit:h,heightUnit:y}=e;p&&j.setAttribute("viewBox",[t,l,a,n].map(e=>+(e*L).toFixed(k)).join(" ")),i&&j.setAttribute("width",+(s*L).toFixed(k)+h),u&&j.setAttribute("height",+(r*L).toFixed(k)+y)}j=be(j),R=j.length,H=+(100/O*R).toFixed(2),O=+(O/1024).toFixed(3),R=+(R/1024).toFixed(3),U={svgSize:O,svgSizeOpt:R,compression:H}}else({d:W,report:U}=Y[0]);return t?{svg:j,d:W,report:U,inputType:B,mode:X}:W||j}oe[77]=2,oe[109]=2,oe[65]=7,oe[97]=7,oe[67]=6,oe[99]=6,oe[76]=2,oe[108]=2,oe[81]=4,oe[113]=4,oe[83]=4,oe[115]=4,oe[84]=2,oe[116]=2,oe[72]=1,oe[104]=1,oe[86]=1,oe[118]=1,oe[90]=0,oe[122]=0;const{abs:Fe,acos:Ie,asin:Se,atan:$e,atan2:ze,ceil:Qe,cos:Ee,exp:Te,floor:De,log:qe,hypot:Be,max:je,min:Ze,pow:Ne,random:Oe,round:Re,sin:He,sqrt:Ue,tan:Ve,PI:We}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=ke),e.PI=We,e.abs=Fe,e.acos=Ie,e.asin=Se,e.atan=$e,e.atan2=ze,e.ceil=Qe,e.cos=Ee,e.exp=Te,e.floor=De,e.hypot=Be,e.log=qe,e.max=je,e.min=Ze,e.pow=Ne,e.random=Oe,e.round=Re,e.sin=He,e.sqrt=Ue,e.svgPathSimplify=ke,e.tan=Ve}(this["svg-path-simplify"]=this["svg-path-simplify"]||{});
|
package/index.html
CHANGED
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
</textarea>
|
|
84
84
|
</label>
|
|
85
85
|
|
|
86
|
-
<h3>SVG normalization</h3>
|
|
86
|
+
<h3>SVG input normalization</h3>
|
|
87
87
|
<p>
|
|
88
88
|
<label><input type="checkbox" name="arcToCubic">arcToCubic</label>
|
|
89
89
|
<label><input type="checkbox" name="quadraticToCubic" checked>quadraticToCubic</label>
|
|
@@ -94,6 +94,14 @@
|
|
|
94
94
|
</p>
|
|
95
95
|
|
|
96
96
|
|
|
97
|
+
<h3>SVG/path scaling</h3>
|
|
98
|
+
<p>
|
|
99
|
+
<label>Scale <input type="number" value="1" min="0.00001" max="10000" name="scale" step="0.1"></label>
|
|
100
|
+
</p>
|
|
101
|
+
<p>
|
|
102
|
+
<label>Scale to <input type="number" value="0" name="scaleTo"></label>
|
|
103
|
+
</p>
|
|
104
|
+
|
|
97
105
|
|
|
98
106
|
</aside>
|
|
99
107
|
|
|
@@ -254,7 +262,7 @@
|
|
|
254
262
|
<div class="wrp-zoom"
|
|
255
263
|
data-zoom='{"minScale":0.1,"maxScale":10,"zoom":1,"zoomStep":1.001, "toolbar":true}'>
|
|
256
264
|
|
|
257
|
-
<svg id="svg" viewBox="0 0 100 100">
|
|
265
|
+
<svg id="svg" class="svgO" viewBox="0 0 100 100">
|
|
258
266
|
|
|
259
267
|
<path id="path1" class="path pathO" d="M54,40.938C68.946,36.071,72.99,30.492,72.992,27
|
|
260
268
|
c0.004-5.928-11.632-5.845-1.367,13.938" />
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svg-path-simplify",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
|
|
5
5
|
"type": "module",
|
|
6
6
|
|
|
7
|
-
"main": "./dist/svg-path-simplify.
|
|
7
|
+
"main": "./dist/svg-path-simplify.js",
|
|
8
8
|
"module": "./dist/svg-path-simplify.esm.js",
|
|
9
|
+
"browser": "./dist/svg-path-simplify.min.js",
|
|
9
10
|
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|
|
@@ -22,9 +23,6 @@
|
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
|
|
25
|
-
"browser": {
|
|
26
|
-
"./dist/svg-path-simplify.node.cjs": "./dist/svg-path-simplify.esm.js"
|
|
27
|
-
},
|
|
28
26
|
|
|
29
27
|
"repository": {
|
|
30
28
|
"type": "git",
|
package/src/index-poly.js
CHANGED
|
@@ -123,7 +123,7 @@ export function combineCubicPairs(com1, com2, {
|
|
|
123
123
|
let distMin = Math.max(0, Math.min(distAv1, distAv2))
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
let distScale = 0.
|
|
126
|
+
let distScale = 0.08
|
|
127
127
|
let maxDist = distMin * distScale * tolerance
|
|
128
128
|
|
|
129
129
|
// get hypothetical combined command
|
|
@@ -142,7 +142,6 @@ export function combineCubicPairs(com1, com2, {
|
|
|
142
142
|
let error = dist0;
|
|
143
143
|
|
|
144
144
|
|
|
145
|
-
|
|
146
145
|
if (close) {
|
|
147
146
|
|
|
148
147
|
/**
|
|
@@ -160,11 +159,6 @@ export function combineCubicPairs(com1, com2, {
|
|
|
160
159
|
|
|
161
160
|
error += dist1;
|
|
162
161
|
|
|
163
|
-
|
|
164
|
-
// quit - paths not congruent
|
|
165
|
-
//if (dist2 > tolerance) return commands;
|
|
166
|
-
|
|
167
|
-
|
|
168
162
|
if (dist1 < maxDist) {
|
|
169
163
|
|
|
170
164
|
//renderPoint(markers, pt_2, 'magenta')
|
|
@@ -172,25 +166,17 @@ export function combineCubicPairs(com1, com2, {
|
|
|
172
166
|
|
|
173
167
|
// 1st segment mid
|
|
174
168
|
let pt_1 = pointAtT([com1.p0, com1.cp1, com1.cp2, com1.p], 0.5)
|
|
169
|
+
//let pt_1_2 = pointAtT([com1.p0, com1.cp1, com1.cp2, com1.p], 1)
|
|
170
|
+
|
|
175
171
|
|
|
176
172
|
let t2 = t * 0.5;
|
|
177
173
|
let ptS_1 = pointAtT([comS.p0, comS.cp1, comS.cp2, comS.p], t2)
|
|
178
174
|
dist2 = getDistAv(pt_1, ptS_1)
|
|
179
175
|
|
|
180
|
-
/*
|
|
181
|
-
if(dist1>tolerance){
|
|
182
|
-
renderPoint(markers, pt_1, 'blue')
|
|
183
|
-
renderPoint(markers, ptS_1, 'orange', '0.5%')
|
|
184
|
-
}
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
// quit - paths not congruent
|
|
188
|
-
if (dist1 + dist2 < maxDist) success = true;
|
|
189
176
|
|
|
190
|
-
// collect error data
|
|
191
177
|
error += dist2;
|
|
192
|
-
|
|
193
|
-
|
|
178
|
+
|
|
179
|
+
if (error < maxDist) success = true;
|
|
194
180
|
|
|
195
181
|
}
|
|
196
182
|
|
package/src/pathSimplify-main.js
CHANGED
|
@@ -23,6 +23,8 @@ import { renderPoint } from './svgii/visualize';
|
|
|
23
23
|
import { refineRoundedCorners } from './svgii/pathData_simplify_refineCorners';
|
|
24
24
|
import { refineRoundSegments } from './svgii/pathData_refine_round';
|
|
25
25
|
import { refineClosingCommand } from './svgii/pathData_remove_short';
|
|
26
|
+
import { scalePathData } from './svgii/pathData_transform_scale';
|
|
27
|
+
import { getViewBox } from './svg_getViewbox';
|
|
26
28
|
|
|
27
29
|
//import { installDOMPolyfills } from './dom-polyfill';
|
|
28
30
|
|
|
@@ -65,6 +67,10 @@ export function svgPathSimplify(input = '', {
|
|
|
65
67
|
|
|
66
68
|
simplifyRound = false,
|
|
67
69
|
|
|
70
|
+
//svg scaling
|
|
71
|
+
scale=1,
|
|
72
|
+
scaleTo=0,
|
|
73
|
+
|
|
68
74
|
|
|
69
75
|
// svg path optimizations
|
|
70
76
|
decimals = 3,
|
|
@@ -175,6 +181,27 @@ export function svgPathSimplify(input = '', {
|
|
|
175
181
|
|
|
176
182
|
let pathData = parsePathDataNormalized(d, { quadraticToCubic, toAbsolute, arcToCubic });
|
|
177
183
|
|
|
184
|
+
// scale pathdata and viewBox
|
|
185
|
+
if(scale!==1 || scaleTo){
|
|
186
|
+
|
|
187
|
+
// get bbox for scaling
|
|
188
|
+
if(scaleTo){
|
|
189
|
+
|
|
190
|
+
let pathDataExtr = pathData.map(com=>{return {type:com.type, values:com.values}})
|
|
191
|
+
pathDataExtr = addExtremePoints(pathDataExtr);
|
|
192
|
+
let poly = getPathDataVertices(pathDataExtr)
|
|
193
|
+
let bb = getPolyBBox(poly);
|
|
194
|
+
|
|
195
|
+
let scaleW = scaleTo/bb.width
|
|
196
|
+
scale = scaleW;
|
|
197
|
+
//console.log('scaleW', scaleW);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
pathData = scalePathData(pathData, scale)
|
|
203
|
+
}
|
|
204
|
+
|
|
178
205
|
// count commands for evaluation
|
|
179
206
|
let comCount = pathData.length
|
|
180
207
|
|
|
@@ -405,6 +432,25 @@ export function svgPathSimplify(input = '', {
|
|
|
405
432
|
removeEmptySVGEls(svg);
|
|
406
433
|
}
|
|
407
434
|
|
|
435
|
+
// adjust viewBox and width for scale
|
|
436
|
+
if(scale){
|
|
437
|
+
|
|
438
|
+
let vB = getViewBox(svg, decimals)
|
|
439
|
+
let {x,y, width, height, w, h, hasViewBox, hasWidth, hasHeight, widthUnit, heightUnit} = vB;
|
|
440
|
+
|
|
441
|
+
if(hasViewBox){
|
|
442
|
+
svg.setAttribute('viewBox', [x, y, width, height].map(val=>+(val*scale).toFixed(decimals)).join(' ') )
|
|
443
|
+
}
|
|
444
|
+
if(hasWidth){
|
|
445
|
+
svg.setAttribute('width', +(w*scale).toFixed(decimals)+widthUnit )
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if(hasHeight){
|
|
449
|
+
svg.setAttribute('height', +(h*scale).toFixed(decimals)+heightUnit )
|
|
450
|
+
}
|
|
451
|
+
//console.log(vB);
|
|
452
|
+
|
|
453
|
+
}
|
|
408
454
|
|
|
409
455
|
|
|
410
456
|
svg = stringifySVG(svg);
|
package/src/svg_getViewbox.js
CHANGED
|
@@ -4,29 +4,42 @@
|
|
|
4
4
|
* width and height attributes
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export function getViewBox(svg = null,
|
|
7
|
+
export function getViewBox(svg = null, decimals = -1) {
|
|
8
|
+
|
|
9
|
+
const getUnit=(val)=>{
|
|
10
|
+
return val && isNaN(val) ? val.match(/[^\d]+/g)[0] : '';
|
|
11
|
+
}
|
|
8
12
|
|
|
9
13
|
// browser default
|
|
10
|
-
if (!svg) return
|
|
14
|
+
if (!svg) return false
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
let hasWidth = svg.hasAttribute('width')
|
|
18
|
+
let hasHeight = svg.hasAttribute('height')
|
|
19
|
+
let hasViewBox = svg.hasAttribute('viewBox')
|
|
20
|
+
|
|
11
21
|
|
|
12
|
-
let
|
|
22
|
+
let widthAtt = hasWidth ? svg.getAttribute('width') : 0;
|
|
23
|
+
let heightAtt = hasHeight ? svg.getAttribute('height') : 0;
|
|
13
24
|
|
|
14
|
-
// the baseVal API method also converts physical units to pixels/user-units
|
|
15
|
-
let w = svg.hasAttribute('width') ? svg.width.baseVal.value : parseFloat(style.width) || 300;
|
|
16
|
-
let h = svg.hasAttribute('height') ? svg.height.baseVal.value : parseFloat(style.height) || 150;
|
|
17
25
|
|
|
18
|
-
let viewBox = svg.getAttribute('viewBox') ? svg.viewBox.baseVal : { x: 0, y: 0, width: w, height: h };
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
let
|
|
22
|
-
viewBox = { x, y, width, height };
|
|
27
|
+
let widthUnit = hasWidth ? getUnit(widthAtt) : false;
|
|
28
|
+
let heightUnit = hasHeight ? getUnit(widthAtt) : false
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
let w = widthAtt ? (!widthAtt.includes('%') ? parseFloat(widthAtt) : 0 ) : 300
|
|
31
|
+
let h = heightAtt ? (!heightAtt.includes('%') ? parseFloat(heightAtt) : 0 ) : 150
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
let viewBoxVals = hasViewBox ? svg.getAttribute('viewBox').split(/,| /).filter(Boolean).map(Number) : [0, 0, w, h];
|
|
35
|
+
|
|
36
|
+
// round
|
|
37
|
+
if (decimals>-1) {
|
|
38
|
+
[w, h] = [w, h].map(val=>+val.toFixed(decimals))
|
|
39
|
+
viewBoxVals = viewBoxVals.map(val=>+val.toFixed(decimals))
|
|
29
40
|
}
|
|
30
41
|
|
|
42
|
+
let viewBox = { x:viewBoxVals[0] , y:viewBoxVals[1], width:viewBoxVals[2], height:viewBoxVals[3], w, h, hasViewBox, hasWidth, hasHeight, widthUnit, heightUnit };
|
|
43
|
+
|
|
31
44
|
return viewBox
|
|
32
45
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scale path data proportionaly
|
|
3
|
+
*/
|
|
4
|
+
export function scalePathData(pathData, scale = 1) {
|
|
5
|
+
let pathDataScaled = [];
|
|
6
|
+
|
|
7
|
+
for (let i = 0, l = pathData.length; i < l; i++) {
|
|
8
|
+
let com = pathData[i];
|
|
9
|
+
let { type, values } = com;
|
|
10
|
+
let comT = {
|
|
11
|
+
type: type,
|
|
12
|
+
values: []
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
switch (type.toLowerCase()) {
|
|
16
|
+
// lineto shorthands
|
|
17
|
+
case "h":
|
|
18
|
+
comT.values = [values[0] * scale];
|
|
19
|
+
break;
|
|
20
|
+
case "v":
|
|
21
|
+
comT.values = [values[0] * scale];
|
|
22
|
+
break;
|
|
23
|
+
|
|
24
|
+
// arcto
|
|
25
|
+
case "a":
|
|
26
|
+
comT.values = [
|
|
27
|
+
values[0] * scale, // rx: scale
|
|
28
|
+
values[1] * scale, // ry: scale
|
|
29
|
+
values[2], // x-axis-rotation: keep it
|
|
30
|
+
values[3], // largeArc: dito
|
|
31
|
+
values[4], // sweep: dito
|
|
32
|
+
values[5] * scale, // final x: scale
|
|
33
|
+
values[6] * scale // final y: scale
|
|
34
|
+
];
|
|
35
|
+
break;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Other point based commands: L, C, S, Q, T
|
|
39
|
+
* scale all values
|
|
40
|
+
*/
|
|
41
|
+
default:
|
|
42
|
+
if (values.length) {
|
|
43
|
+
comT.values = values.map((val, i) => {
|
|
44
|
+
return val * scale;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
pathDataScaled.push(comT);
|
|
49
|
+
};
|
|
50
|
+
return pathDataScaled;
|
|
51
|
+
}
|