svg-path-simplify 0.0.7 → 0.0.8
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 +775 -169
- package/dist/svg-path-simplify.esm.min.js +1 -1
- package/dist/svg-path-simplify.js +4674 -4068
- package/dist/svg-path-simplify.min.js +1 -1
- package/dist/svg-path-simplify.node.js +775 -169
- package/dist/svg-path-simplify.node.min.js +1 -1
- package/index.html +11 -8
- package/package.json +5 -3
- package/src/dom-polyfill.js +29 -0
- package/src/dom-polyfill_back.js +22 -0
- package/src/index.js +7 -1
- package/src/pathData_simplify_cubic.js +1 -37
- package/src/pathData_simplify_cubic_extrapolate.js +43 -28
- package/src/pathSimplify-main.js +50 -9
- package/src/svgii/geometry.js +8 -155
- package/src/svgii/geometry_flatness.js +101 -0
- package/src/svgii/pathData_analyze.js +11 -596
- package/src/svgii/pathData_parse_els.js +239 -0
- package/src/svgii/pathData_remove_collinear.js +3 -1
- package/src/svgii/pathData_remove_orphaned.js +20 -0
- package/src/svgii/pathData_remove_zerolength.js +12 -2
- package/src/svgii/pathData_reorder.js +3 -1
- package/src/svgii/pathData_split.js +1 -0
- package/src/svgii/rounding.js +25 -19
- package/src/svgii/simplify_refineExtremes.js +173 -0
- package/src/svgii/svg_cleanup.js +4 -1
- package/testSVG.js +39 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e){"use strict";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,n=!0){let s,r,p,u,i,y={};try{if(s=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==s)return!1}catch{console.log("!catch",e,t,"p3:",l,a)}r=e.y-l.y,p=e.x-l.x,u=(a.x-l.x)*r-(a.y-l.y)*p,i=(t.x-e.x)*r-(t.y-e.y)*p,r=u/s,p=i/s,y={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};let h=!1;return r>0&&r<1&&p>0&&p<1&&(h=!0),!(n&&!h)&&y}function C(e,t){return v((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function A(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function w(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 L(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=w(s,r,t),n?(l=w(r,p,t),y=w(p,u,t),h=w(e,l,t),o=w(l,y,t),i=w(h,o,t),i.angle=M(h,o),a&&(i.cpts=[l,y,h,o])):(l=w(s,r,t),y=w(r,u,t),i=w(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):w(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*m),n}function P(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=.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 I(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,C,A,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 C=v*v-4*d*g,C<0?Math.abs(C)<1e-12&&(m=-v/(2*g),0<m&&m<1&&w.push(m)):(A=Math.sqrt(C),M=(-v+A)/(2*g),0<M&&M<1&&w.push(M),b=(-v-A)/(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 k(e,t=.025){let l=e[0],a=e[e.length-1],n=e.map(e=>e.x),s=e.map(e=>e.y),r=Math.min(...n),p=Math.max(...n),u=Math.min(...s),i=p-r,y=Math.max(...s)-u;if(e.length<3||0===i||0===y)return{area:0,flat:!0,thresh:1e-4,ratio:0};let h=A(l,a),o=A(l,e[0]),c=(o+(e.length>3?A(a,e[1]):o))/2;let x=.5*(i+y)*.5,f=0;for(let t=0,l=e.length;t<l;t++){f+=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}f=+Math.abs(f).toFixed(9);return{area:f,flat:0===f||f<c/1e3,thresh:x,ratio:f/c,squareDist:h,areaThresh:h/1e3}}function F(e,t,l){let a=!1,n=2===t.length,s=t[0],r=n?t[1]:s;if(e.x===s.x&&e.y===s.y&&l.x===r.x&&l.y===r.y)return!0;let p=s.x-e.x,u=s.y-e.y,i=l.x-r.x,y=l.y-r.y,h=Math.abs(p*y-u*i);if(!h)return!0;let o=l.x-e.x,c=l.y-e.y,x=Math.abs(o*u-c*p);return!x||(x/h<1.1&&(a=!0),a)}function z(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function E(e){let t=[];try{e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e)}catch{console.log("catch",e)}let l=e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e);return 1===l.length?[e]:(l.forEach((a,n)=>{t.push(e.slice(a,l[n+1]))}),t)}function Q(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=L([y,h],t),a=L([h,o],t),n=L([o,c],t),s=L([l,a],t),r=L([a,n],t),p=L([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=L([y,h],t),n=L([h,c],t),p=L([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=L([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 T(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=I("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=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,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 $(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=T(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 q(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 D(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=w(p,u,.5),a=P(l.x,l.y,e,e,0),n=P(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=q(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],[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 N(e,l=9){let a=0,n=[],r=E(e),u=r.length>1,i=[];if(u){let e=D(r);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){O(t,a)&&i.push(l)}}})}return r.forEach((e,l)=>{n=[];let r=0,u=0,y=1,h=[];e.forEach(function(l,a){let[u,i]=[l.type,l.values],y=i.length;if(i.length){let o=(a>0?e[a-1]:e[0]).values,c=o.length,x={x:o[c-2],y:o[c-1]},f={x:i[y-2],y:i[y-1]};if("C"===u||"Q"===u){let e={x:i[0],y:i[1]};h="C"===u?[x,e,{x:i[2],y:i[3]},f]:[x,e,f];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}(h));r+=t,n.push(x,f)}else if("A"===u){let e=function(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,C=(e-y)/2,A=(l-h)/2,w=(e+y)/2,L=(l+h)/2,P=d?b*C+M*A:C,S=d?b*A-M*C:A,I=P*P/(a*a)+S*S/(n*n);I>1&&(a*=v(I),n*=v(I),c.rx=a,c.ry=n);let k=a*n,F=a*S,z=n*P,E=F**2+z**2;if(!E)throw Error("start point can not be same as end point");let Q=v(t((k*k-E)/E));u==i&&(Q=-Q);let T=Q*F/n,$=-Q*z/a;x=d?b*T-M*$+w:w+T,f=d?M*T+b*$+L:L+$,c.cy=f,c.cx=x;let q=o(x,f,e,l),D=o(x,f,y,h);!i&&D>q&&(D-=2*Math.PI),i&&q>D&&(D=D<=0?D+2*Math.PI:D);let O=D-q;return c.startAngle=q,c.endAngle=D,c.deltaAngle=O,c}(x.x,x.y,l.values[0],l.values[1],l.values[2],l.values[3],l.values[4],f.x,f.y),{cx:a,cy:u,rx:i,ry:y,startAngle:h,endAngle:o,deltaAngle:c}=e,d=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))}(i,y,h,o));d-=Math.abs(j([x,{x:a,y:u},f])),n.push(x,f),r+=d}else n.push(x,f)}});let o=j(n);-1!==i.indexOf(l)&&(y=-1),u=o<0&&r<0?(Math.abs(r)-Math.abs(o))*y:(Math.abs(r)+Math.abs(o))*y,a+=u}),a}function j(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 B(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=l.type===a.type&&"m"!==a.type.toLowerCase()&&n||"M"===l.type&&"L"===a.type&&n?" ":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 Z(e,t,l=!1,a=1){let n=[e,t],s=function(e,t){let l=b(e.p0,e.cp1,t.cp2,t.p,!1),a=b(l,t.p,t.p0,t.cp1,!1),n=C(l,t.p),s=C(a,t.p),r=1-s/n,p=C(e.cp2,e.p),u=C(e.cp2,t.cp1);return r=Math.min(p)/u,r}(e,t),r=z(e.p0,e.p),p=z(t.p0,t.p),u=.05*Math.min(r,p)*a,i=function(e,t,l=0,a=0){let{p0:n,cp1:s}=e,{p:r,cp2:p}=t,u={x:(s.x-(1-l)*n.x)/l,y:(s.y-(1-l)*n.y)/l},i={x:(p.x-a*r.x)/(1-a),y:(p.y-a*r.y)/(1-a)},y={p0:n,cp1:u,cp2:i,p:r};return y}(e,t,s,s),y=L([i.p0,i.cp1,i.cp2,i.p],s),h=z(e.p,y),o=0,c=0,x=!1,f=h;if(h<u){let l=.5*(1+s);if(o=z(L([t.p0,t.cp1,t.cp2,t.p],.5),L([i.p0,i.cp1,i.cp2,i.p],l)),f+=o,o<u){let t=.5*s;c=z(L([e.p0,e.cp1,e.cp2,e.p],.5),L([i.p0,i.cp1,i.cp2,i.p],t)),o+c<u&&(x=!0),f+=c}}if(l&&!x){let l=function(e,t,l=0,a=1){const n=(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 s=[e,t],r=A(e.p0,e.p)>A(t.p0,t.p),p=JSON.parse(JSON.stringify(e)),u=JSON.parse(JSON.stringify(t)),i=b(p.p0,p.cp1,u.p,u.cp2,!1);if(!i)return s;if(r){let l={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: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=l}let y=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),h=(e,t)=>({x:e.x*t,y:e.y*t}),o=(e,t)=>e.x*t.x+e.y*t.y,c=t.p0,x=n(t.p0,t.cp1,t.cp2,t.p,0),f=o(y(e.p0,c),x)/o(x,x),g=L([t.p0,t.cp1,t.cp2,t.p],f),v=n(t.p0,t.cp1,t.cp2,t.p,f);f-=o(y(g,e.p0),v)/o(v,v);let d=L([t.p0,t.cp1,t.cp2,t.p],f),m=t.p,M=n(t.p0,t.cp1,t.cp2,t.p,f),C=n(t.p0,t.cp1,t.cp2,t.p,1),P=1-f,S=(I=d,k=h(M,P/3),{x:I.x+k.x,y:I.y+k.y});var I,k;let F=y(m,h(C,P/3)),E={p0:d,cp1:S,cp2:F,p:m};r&&(E={p0:m,cp1:F,cp2:S,p:d});let Q=.5*(1-f),T=L([E.p0,E.cp1,E.cp2,E.p],Q,!1,!0),$=T.cpts[2],q=b(T,$,E.p0,i,!1),D=b(T,$,E.p,i,!1),O=w(E.p0,q,1.333),j=w(E.p,D,1.333);if(b(p.p0,O,u.p,j,!0))return s;E.cp1=O,E.cp2=j;let Z=z(p.p0,E.p0)+z(u.p,E.p);if(E.p0=p.p0,E.p=u.p,E.extreme=u.extreme,E.corner=u.corner,E.dimA=u.dimA,E.directionChange=u.directionChange,E.values=[E.cp1.x,E.cp1.y,E.cp2.x,E.cp2.y,E.p.x,E.p.y],Z<l){let e=N([{type:"M",values:[p.p0.x,p.p0.y]},{type:"C",values:[p.cp1.x,p.cp1.y,p.cp2.x,p.cp2.y,p.p.x,p.p.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]}]),t=[{type:"M",values:[E.p0.x,E.p0.y]},{type:"C",values:[E.cp1.x,E.cp1.y,E.cp2.x,E.cp2.y,E.p.x,E.p.y]}],l=N(t),n=Math.abs(l/e-1);E.error=10*n*a,B(t),n<.01&&(s=[E])}return s}(e,t,u,a);1===l.length&&(x=!0,i=l[0],f=i.error)}return x&&(i.p0=e.p0,i.p=t.p,i.dimA=z(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=f/u,n=[i]),n}function R(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=q(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],d=!1;a.idx=l-1,a.lineto=!1,a.corner=!1,a.extreme=!1,a.directionChange=!1,a.closePath=!1,a.dimA=0;let m,b,C,w,L,P,I,F=.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 E=z(x,t);if(a.dimA=E,"L"===n&&(a.lineto=!0),"Z"===n&&(a.closePath=!0,c.x!==h&&c.y!==o&&(a.lineto=!0)),"Q"!==n&&"C"!==n||(m={x:i[0],y:i[1]},b="C"===n?{x:i[2],y:i[3]}:null,a.cp1=m,b&&(a.cp2=b)),i.length>2){"Q"!==n&&"C"!==n||v.push(m),"C"===n&&v.push(b),v.push(t),d=k(v).flat,a.flat=d,d&&(a.extreme=!1)}d||"L"===n||t.x!==s&&t.y!==p&&t.x!==r&&t.y!==u||(a.extreme=!0);let Q=e[l]?e[l]:null,T=Q?Q.values.slice(-2):null;P=Q?Q.type:null,!Q||"Q"!==Q.type&&"C"!==Q.type||(L=Q?{x:T[0],y:T[1]}:null,C={x:Q.values[0],y:Q.values[1]},w="C"===Q.type?{x:Q.values[2],y:Q.values[3]}:null),I=j(v);let $=g<0&&I>0||g>0&&I<0;if(g=I,$&&(a.directionChange=!0),("Q"===n||"C"===n)&&("Q"===n&&"Q"===P||"C"===n&&"C"===P)){let e=v.slice(1),l=k("C"===n?[t,C,w,L]:[t,C,L],((L?Math.abs(L.x-x.x):0)+(L?Math.abs(L.y-x.y):0))/2*.1).flat;if((!d||!l)&&(!!a.extreme||S(0,e,F)))a.extreme=!0;else{let e=b?[b,t]:[m,t],l=[t,C],n=M(...e,!0),s=M(...l,!0),r=180*Math.abs(n-s)/Math.PI,p=A(...e),u=A(...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 H(e,t=-1){let l=!("auto"!=t||!e[0].hasOwnProperty("decimals"));for(let a=0,n=e.length;a<n;a++){let n=e[a];(t>-1||l)&&(t=l?n.decimals:t,e[a].values=n.values.map(e=>e?+e.toFixed(t):e))}return e}function U(e={},t={},l={},a={}){let n=w(e,t,1.5),s=w(a,l,1.5),r=.01*z(e,a),p=z(n,s),u=null,i={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return p<r&&(u=b(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.p=a)),i}function J(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!0){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?X(e,t):e;let n={type:"M",values:e[0].values};e[0].decimals&&(n.decimals=e[0].decimals);let s,r=[n],p={x:e[0].values[0],y:e[0].values[1]},u=.01;for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:i,values:y}=a,h=y.slice(-2),o=e[l-1],c=o.type;s={x:h[0],y:h[1]};let x,f,g,v,d={x:y[0],y:y[1]},m=Math.abs(s.x-p.x),M=Math.abs(s.y-p.y),b=(m+M)/2*u;switch(i){case"L":n=0===M||M<b&&m>b?{type:"H",values:[y[0]]}:0===m||M>b&&m<b?{type:"V",values:[y[1]]}:a;break;case"Q":if("Q"!==c){p={x:h[0],y:h[1]},r.push(a);continue}let e={x:o.values[0],y:o.values[1]};v={x:2*p.x-e.x,y:2*p.y-e.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"T",values:[s.x,s.y]}:a;break;case"C":let t={x:y[2],y:y[3]};if("C"!==c){r.push(a),p={x:h[0],y:h[1]};continue}let l={x:o.values[2],y:o.values[3]};v={x:2*p.x-l.x,y:2*p.y-l.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"S",values:[t.x,t.y,s.x,s.y]}:a;break;default:n={type:i,values:y}}(a.decimals||0===a.decimals)&&(n.decimals=a.decimals),t>-1&&(n.values=n.values.map(e=>+e.toFixed(t))),p={x:h[0],y:h[1]},r.push(n)}return r}(e)),e=H(e,a),l&&(e=function(e,t=-1){return W(e,!0,t)}(e)),a>-1&&(e=H(e,a)),e}function V(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 W(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 X(e,t=-1){return W(e,!1,t)}function Y(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 C=b?b*n/s*f:0,A=b?b*-s/n*x:0,w=c*C-o*A+(e.x+i)/2,L=o*C+c*A+(e.y+y)/2,P=(x-C)/n,S=(f-A)/s,I=(-x-C)/n,k=(-f-A)/s;const F=(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 z=F(1,0,P,S),E=F(P,S,I,k);0===u&&E>0?E-=2*Math.PI:1===u&&E<0&&(E+=2*Math.PI);let Q=(+(Math.abs(E)/(a/4)).toFixed(0)||1)*l;E/=Q;let T=[];const $=1.5707963267948966,q=.551785;let D=E===$?q:E===-$?-q:4/3*Math.tan(E/4),O=E?Math.cos(E):1,N=E?Math.sin(E):0;const j=(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:[]};j(z,E,D,O,N).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-o*a+w,o*l+c*a+L)}),T.push(e),z+=E}return T}function G(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=b(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=j([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=N([{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(j([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 K(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 _(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=W(e,!1)),p&&l&&(e=function(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}let n=[],s={type:"M",values:(e=l&&a?X(e,t):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,C]=[v[d-2],v[d-1]];switch(x){case"H":s={type:"L",values:[f[0],C]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[v[0],v[1]],[b,C]=[v[d-2],v[d-1]],p=b+(b-a),u=C+(C-r),s={type:"Q",values:[p,u,m,M]};break;case"S":[a,r]=[v[0],v[1]],[b,C]=[v[d-2],v[d-1]],[h,o]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,C],p=2*b-h,u=2*C-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}(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?Y(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(V(r,a.values)):t.push(a)}return t}(e)),e}function ee(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=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 C=!1,A=!1,w=!1;for(;s<r;){let l=e.charCodeAt(s),r=l>47&&l<58;if(r||(C=101===l||69===l,A=45===l||43===l,w=46===l),r||A||w||C){if(h||45!==l&&46!==l)d();else{let e=46===l;m(e),d(),e&&o++}y+=e[s],h=C,s++}else if((l<48||l>5759)&&a(l))m(),s++;else{if(l>64){if(!te.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=le[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();if(t&&v.length){if(n="Invalid path data:\n"+v.join("\n"),"log"!==t)throw new Error(n);console.log(n)}u[0].type="M";let L=Array.from(g).join(""),P=/[lcqamts]/g.test(L),S=/[vhst]/gi.test(L),I=/[a]/gi.test(L),k=/[qt]/gi.test(L);return{pathData:u,hasRelatives:P,hasShorthands:S,hasQuadratics:k,hasArcs:I}}(e),{hasRelatives:p,hasShorthands:u,hasQuadratics:i,hasArcs:y}=r,h=r.pathData;return h=_(h,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s},{hasRelatives:p,hasShorthands:u,hasQuadratics:i,hasArcs:y}),h}const te=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),le=new Uint8Array(128);function ae(e,t=1,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-1],y=e[p],h=e[p+1]||e[u-1],o="z"===h.type.toLowerCase()?n:{x:h.values[h.values.length-2],y:h.values[h.values.length-1]},{type:c,values:x}=y,f=x.slice(-2);r="Z"!==c?{x:f[0],y:f[1]}:n;let g=j([s,r,o],!0);A(s,r),A(r,o);let v=g<A(s,o)/200*t,d=!1;if(l||"C"!==c||(v=!1),l&&("C"===c||"Q"===c)){d=F(s,"C"===c?[{x:x[0],y:x[1]},{x:x[2],y:x[3]}]:"Q"===c?[{x:x[0],y:x[1]}]:[],r),d&&p<u-1&&"C"!==i.type&&(c="L",y.type="L",y.values=f)}s=r,v&&p<u-1&&("L"===c||l&&d)||("M"===c?(n=r,s=n):"Z"===c&&(s=n),a.push(y))}return a}function ne(e){let t=[];return e.forEach((e,l)=>{let{type:a,values:n}=e;if("l"===a||"v"===a||"h"===a){("l"===a?"00"!==n.join(""):0!==n[0])&&t.push(e)}else t.push(e)}),t}function se(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],{type:r,values:p}=s,u=p.slice(-2);l={x:u[0],y:u[1]},"L"===r&&l.x===t.x&&l.y===t.y||(a.push(s),t=l)}return a}function re(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?ue(e,l):e}function pe(e,t=!0,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[n-2],i=u.type,y=u.values.slice(-2).map(e=>+e.toFixed(8)),h=y[0]===s.x&&y[1]===s.y,o="L"!==e[1].type&&(!h||"L"===i);if(o=!1,!r)return e;let c=0;{let t=[];for(let l=0,a=e.length;l<a;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(1)-+t.y.toFixed(1)||e.x-t.x),c=t[0].index;e=c?ue(e,c):e}return s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(7)},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 ue(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 ie(e,{arcToCubic:t=!1,quadraticToCubic:l=!1,toClockwise:a=!1,returnD:n=!1}={}){const s=(e,t)=>{let l=[],a=[];if("A"!==e){for(let e=0;e<t.length;e+=2)l.push([t[e],t[e+1]]);a=l.pop(),l.reverse()}else{let e=0==t[4]?1:0;l=[t[0],t[1],t[2],t[3],e],a=[t[5],t[6]]}return{controlPoints:l,endPoints:a}};let r=[],p="z"===e[e.length-1].type.toLowerCase();p&&(e=(e=>{let t="z"===e[e.length-1].type.toLowerCase(),l=e[0],[a,n]=[l.values[0],l.values[1]],s=t?e[e.length-2]:e[e.length-1],[r,p]=[s.values[s.values.length-2],s.values[s.values.length-1]];return!t||a==r&&n==p||(e.pop(),e.push({type:"L",values:[a,n]},{type:"Z",values:[]})),e})(e),e.pop());let u=e[e.length-1].values,i=u.length,y=p?e[0]:{type:"M",values:[u[i-2],u[i-1]]};r.push(y),e.reverse();for(let t=1;t<e.length;t++){let l=e[t],a=l.type,n=l.values,p=e[t-1],u=p.type,i=[];i=[s(u,p.values).controlPoints,s(a,n).endPoints].flat(),r.push({type:u,values:i.flat()})}return p&&r.push({type:"z",values:[]}),r}function ye(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 he(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,removeColinear:y=!0,flatBezierToLinetos:h=!0,revertToQuadratics:o=!0,keepExtremes:c=!0,keepCorners:x=!0,extrapolateDominant:f=!0,keepInflections:g=!1,addExtremes:v=!1,decimals:d=3,autoAccuracy:m=!0,minifyD:M=0,tolerance:b=1,reverse:C=!1,mergePaths:A=!1,removeHidden:w=!0,removeUnused:L=!0}={}){b=Math.max(.1,b);let P=function(e){let t="string";if(Array.isArray(e))return"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),S="",I=0,k=0,F=0,Q={},T="",q="svgMarkup"===P?1:0,D=[];if(I=new Blob([e]).size,q){S=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"]);let s=["metadata","script"];if(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)return n;let r=ye(n);return console.log(r),r}(e,{returnDom:!0,removeHidden:w,removeUnused:L}),S.querySelectorAll("path").forEach(e=>{D.push({d:e.getAttribute("d"),el:e})})}else"pathDataString"===P?T=e:"polyString"===P&&(T="M"+e),D.push({d:T,el:null});let O={toRelative:a,toShorthands:n,decimals:d},N=[];if(D.forEach(e=>{let{d:t,el:a}=e,n=ee(t,{quadraticToCubic:s,toAbsolute:l,arcToCubic:r}),w=JSON.parse(JSON.stringify(n)),L=n.length,P=E(w),S=[];for(let e=0,t=P.length;e<t;e++){let t=P[e];C&&(t=ie(t)),y&&(t=se(t)),v&&(t=$(t,0,1)),i&&(t=re(t)),y&&(t=ae(t,b,h));let l=R(t),{pathData:a,bb:n,dimA:s}=l;if(a=u?oe(a,{simplifyBezier:u,keepInflections:g,keepExtremes:c,keepCorners:x,extrapolateDominant:f,revertToQuadratics:o,tolerance:b,reverse:C}):a,p){let e=3;a.forEach((t,l)=>{let{type:n,values:s,p0:r,cp1:p=null,cp2:u=null,p:i=null}=t;if("C"===n){let t=G(r,p,u,i,e);t.isArc&&(a[l]=t.com)}}),a=K(a)}o&&a.forEach((e,t)=>{let{type:l,values:n,p0:s,cp1:r=null,cp2:p=null,p:u=null}=e;if("C"===l){let l=U(s,r,p,u);"Q"===l.type&&(l.extreme=e.extreme,l.corner=e.corner,l.dimA=e.dimA,a[t]=l)}}),i&&(a=pe(a)),S.push(a)}if(w=S.flat(),a&&A)N.push(...w);else{m&&(d=function(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=new Set;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?+z(l,a).toFixed(8):0;y&&n.add(y),"M"===p&&(t=a),l=a}let s=Array.from(n).sort(),r=Math.ceil(s.length/8);s=s.slice(0,r);let p=s.reduce((e,t)=>e+t,0)/r,u=p>50?0:Math.floor(50/p).toString().length;return Math.min(Math.max(0,u),8)}(w)),w=J(w,O),w=ne(w);let t=w.length,l=B(w,M);k=new Blob([l]).size,F=+(100/I*k).toFixed(2),e.d=l,e.report={original:L,new:t,saved:L-t,compression:F,decimals:d},a&&a.setAttribute("d",l)}}),q){if(N.length){let e=J(N,O);e=ne(e);let t=B(e,M);D[0].el.setAttribute("d",t);for(let e=1;e<D.length;e++){let t=D[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(S)}S=ye(S),k=new Blob([S]).size,F=+(100/I*k).toFixed(2),I=+(I/1024).toFixed(3),k=+(k/1024).toFixed(3),Q={svgSize:I,svgSizeOpt:k,compression:F}}else({d:T,report:Q}=D[0]);return t?{svg:S,d:T,report:Q,inputType:P,mode:q}:T||S}function oe(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1,reverse:r=!1}={}){let p=[e[0]];for(let r=2,u=e.length;u&&r<=u;r++){let i=e[r-1],y=r<u?e[r]:null,h=y?.type||null,o=i?.directionChange||null,c=y?.directionChange||null,{type:x,values:f,p0:g,p:v,cp1:d=null,cp2:m=null,extreme:M=!1,corner:b=!1,dimA:C=0}=i;if("C"===x&&"C"===h)if(l&&c||a&&b||!o&&t&&M)p.push(i);else{let h=Z(i,y,n,s),o=0;if(1===h.length){i=h[0];let y=1;o+=i.error;for(let p=r+1;o<s&&p<u;p++){let r=e[p];if("C"!==r.type||l&&r.directionChange||a&&i.corner||t&&i.extreme)break;let u=Z(i,r,n,s);1===u.length&&(o+=.5*u[0].error,y++),i=u[0]}p.push(i),r<u&&(r+=y)}else p.push(i)}else p.push(i)}return r&&(p=ie(p)),p}le[77]=2,le[109]=2,le[65]=7,le[97]=7,le[67]=6,le[99]=6,le[76]=2,le[108]=2,le[81]=4,le[113]=4,le[83]=4,le[115]=4,le[84]=2,le[116]=2,le[72]=1,le[104]=1,le[86]=1,le[118]=1,le[90]=0,le[122]=0;const{abs:ce,acos:xe,asin:fe,atan:ge,atan2:ve,ceil:de,cos:me,exp:Me,floor:be,log:Ce,hypot:Ae,max:we,min:Le,pow:Pe,random:Se,round:Ie,sin:ke,sqrt:Fe,tan:ze,PI:Ee}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=he),e.PI=Ee,e.abs=ce,e.acos=xe,e.asin=fe,e.atan=ge,e.atan2=ve,e.ceil=de,e.cos=me,e.exp=Me,e.floor=be,e.hypot=Ae,e.log=Ce,e.max=we,e.min=Le,e.pow=Pe,e.random=Se,e.round=Ie,e.sin=ke,e.sqrt=Fe,e.svgPathSimplify=he,e.tan=ze}(this["svg-path-simplify"]=this["svg-path-simplify"]||{});
|
|
1
|
+
!function(e){"use strict";const{abs:t,acos:l,asin:a,atan:n,atan2:s,ceil:r,cos:p,exp:i,floor:u,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=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 A(e,t){return v((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function C(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function w(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 L(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=w(s,r,t),n?(l=w(r,p,t),y=w(p,i,t),h=w(e,l,t),o=w(l,y,t),u=w(h,o,t),u.angle=M(h,o),a&&(u.cpts=[l,y,h,o])):(l=w(s,r,t),y=w(r,i,t),u=w(l,y,t),u.angle=M(l,y),a&&(u.cpts=[l,y]))):(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):w(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*m),n}function P(e,l,a,n,r,i,u,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: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(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=u?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=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-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,S=P*P/(a*a)+k*k/(n*n);S>1&&(a*=v(S),n*=v(S),c.rx=a,c.ry=n);let $=a*n,F=a*k,I=n*P,E=F**2+I**2;if(!E)throw Error("start point can not be same as end point");let z=v(t(($*$-E)/E));i==u&&(z=-z);let Q=z*F/n,T=-z*I/a;x=d?b*Q-M*T+w:w+Q,f=d?M*Q+b*T+L:L+T,c.cy=f,c.cx=x;let q=o(x,f,e,l),D=o(x,f,y,h);!u&&D>q&&(D-=2*Math.PI),u&&q>D&&(D=D<=0?D+2*Math.PI:D);let B=D-q;return c.startAngle=q,c.endAngle=D,c.deltaAngle=B,c}function k(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 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=.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?M(r,n,!0):null;if(i=Math.abs(y%p)<l||Math.abs(y%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 $(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 F(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=P(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],k=Math.min(...w),S=Math.max(...w),$=Math.min(...L),F=Math.max(...L),I=l(c-.001*x,h,o,u,y,d),E=l(c-.999*x,h,o,u,y,d);return(I.x>S||E.x>S)&&(a=l(M,h,o,u,y,d),v.push(a)),(I.x<k||E.x<k)&&(n=l(b,h,o,u,y,d),v.push(n)),(I.y<$||E.y<$)&&(r=l(C,h,o,u,y,d),v.push(r)),(I.y>F||E.y>F)&&(s=l(A,h,o,u,y,d),v.push(s)),v}function I(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function E(e){let t=[];try{e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e)}catch{console.log("catch",e)}let l=e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e);return 1===l.length?[e]:(l.forEach((a,n)=>{t.push(e.slice(a,l[n+1]))}),t)}function z(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=L([y,h],t),a=L([h,o],t),n=L([o,c],t),s=L([l,a],t),r=L([a,n],t),p=L([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=L([y,h],t),n=L([h,c],t),p=L([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=L([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 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,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=$("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=z(p,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=z(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=z(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 T(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=Q(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 q(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 D(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=A(p,i)/2,l=w(p,i,.5),a=k(l.x,l.y,e,e,0),n=k(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=q(t);return l}(e);t.push(l)}),t}function B(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 j(e,t=9){let l=0,a=[],n=E(e),s=n.length>1,r=[];if(s){let e=D(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){B(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=P(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(N([h,{x:l,y:s},o])),a.push(h,o),n+=c}else a.push(h,o)}});let u=N(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 N(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 Z(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=l.type===a.type&&"m"!==a.type.toLowerCase()&&n||"M"===l.type&&"L"===a.type&&n?" ":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 O(e,t,l=0,a=1,n=!1){const s=(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 r=[e,t],p=I(e.p0,e.p)>I(t.p0,t.p),i=JSON.parse(JSON.stringify(e)),u=JSON.parse(JSON.stringify(t)),y=b(i.p0,i.cp1,u.p,u.cp2,!1);if(!y)return r;if(p){let l={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: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=l}let h=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),o=(e,t)=>({x:e.x*t,y:e.y*t}),c=(e,t)=>e.x*t.x+e.y*t.y,x=t.p0,f=s(t.p0,t.cp1,t.cp2,t.p,0),g=c(h(e.p0,x),f)/c(f,f),v=L([t.p0,t.cp1,t.cp2,t.p],g),d=s(t.p0,t.cp1,t.cp2,t.p,g);g-=c(h(v,e.p0),d)/c(d,d);let m=L([t.p0,t.cp1,t.cp2,t.p],g),M=t.p,A=s(t.p0,t.cp1,t.cp2,t.p,g),C=s(t.p0,t.cp1,t.cp2,t.p,1),P=1-g,k=(S=m,$=o(A,P/3),{x:S.x+$.x,y:S.y+$.y});var S,$;let F=h(M,o(C,P/3)),E={p0:m,cp1:k,cp2:F,p:M};p&&(E={p0:M,cp1:F,cp2:k,p:m});let z=.5*(1-g),Q=L([E.p0,E.cp1,E.cp2,E.p],z,!1,!0),T=Q.cpts[2],q=b(Q,T,E.p0,y,!1),D=b(Q,T,E.p,y,!1),B=w(E.p0,q,1.333),N=w(E.p,D,1.333);if(b(i.p0,B,u.p,N,!0))return r;n&&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,Q,"purple"),E.cp1=B,E.cp2=N;let O=I(i.p0,E.p0)+I(u.p,E.p);if(E.p0=i.p0,E.p=u.p,E.extreme=u.extreme,E.corner=u.corner,E.dimA=u.dimA,E.directionChange=u.directionChange,E.type="C",E.values=[E.cp1.x,E.cp1.y,E.cp2.x,E.cp2.y,E.p.x,E.p.y],O<l){let t=p?1+g:Math.abs(g);if(I(L([E.p0,E.cp1,E.cp2,E.p],t),e.p)>l*a)return r;let s=j([{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:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]}]),y=[{type:"M",values:[E.p0.x,E.p0.y]},{type:"C",values:[E.cp1.x,E.cp1.y,E.cp2.x,E.cp2.y,E.p.x,E.p.y]}],h=j(y),o=Math.abs(h/s-1);if(E.error=5*o*a,n){let e=Z(y);!function(e,t="",l="green",a="1%",n=!0){let s=`<path d="${t}" fill="none" stroke="${l}" stroke-width="${a}" /> `;if(!n)return s;e.insertAdjacentHTML("beforeend",s)}(markers,e,"orange")}o<.05*a&&(r=[E])}return r}function H(e,t,l=!1,a=1){let n=[e,t],s=function(e,t){let l=A(e.cp2,e.p),a=A(e.cp2,t.cp1),n=Math.min(l)/a;return n}(e,t),r=I(e.p0,e.p),p=I(t.p0,t.p),i=.05*Math.min(r,p)*a,u=function(e,t,l=0,a=0){let{p0:n,cp1:s}=e,{p:r,cp2:p}=t,i={x:(s.x-(1-l)*n.x)/l,y:(s.y-(1-l)*n.y)/l},u={x:(p.x-a*r.x)/(1-a),y:(p.y-a*r.y)/(1-a)},y={p0:n,cp1:i,cp2:u,p:r};return y}(e,t,s,s),y=L([u.p0,u.cp1,u.cp2,u.p],s),h=I(e.p,y),o=0,c=0,x=!1,f=h;if(h<i){let l=.5*(1+s);if(o=I(L([t.p0,t.cp1,t.cp2,t.p],.5),L([u.p0,u.cp1,u.cp2,u.p],l)),f+=o,o<i){let t=.5*s;c=I(L([e.p0,e.cp1,e.cp2,e.p],.5),L([u.p0,u.cp1,u.cp2,u.p],t)),o+c<i&&(x=!0),f+=c}}if(l&&!x){let l=O(e,t,i,a);1===l.length&&(x=!0,u=l[0],f=u.error)}return x&&(u.p0=e.p0,u.p=t.p,u.dimA=I(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=f/i,n=[u]),n}function R(e,t,l){let a=!1,n=2===t.length,s=t[0],r=n?t[1]:s;if(e.x===s.x&&e.y===s.y&&l.x===r.x&&l.y===r.y)return!0;let p=s.x-e.x,i=s.y-e.y,u=l.x-r.x,y=l.y-r.y;if(!Math.abs(p*y-i*u))return!0;let h=l.x-e.x,o=l.y-e.y;return!Math.abs(h*i-o*p)||(a=N([e,...t,l],!0)<C(e,l)/200,a)}function U(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=q(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,b,A,w,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=I(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 $=e[l]?e[l]:null,F=$?$.values.slice(-2):null;w=$?$.type:null,!$||"Q"!==$.type&&"C"!==$.type||(A=$?{x:F[0],y:F[1]}:null,b={x:$.values[0],y:$.values[1]},"C"===$.type&&($.values[2],$.values[3])),L=N(v);let E=g<0&&L>0||g>0&&L<0;if(g=L,E&&(a.directionChange=!0),("Q"===n||"C"===n)&&("Q"===n&&"Q"===w||"C"===n&&"C"===w)){let e=v.slice(1);if(A&&Math.abs(A.x-x.x),A&&Math.abs(A.y-x.y),!!a.extreme||S(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=C(...e),i=C(...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 V(e,t=-1){let l=!("auto"!=t||!e[0].hasOwnProperty("decimals"));for(let a=0,n=e.length;a<n;a++){let n=e[a];(t>-1||l)&&(t=l?n.decimals:t,e[a].values=n.values.map(e=>e?+e.toFixed(t):e))}return e}function J(e={},t={},l={},a={}){let n=w(e,t,1.5),s=w(a,l,1.5),r=.01*I(e,a),p=I(n,s),i=null,u={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return p<r&&(i=b(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.p=a)),u}function W(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!0){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?G(e,t):e;let n={type:"M",values:e[0].values};e[0].decimals&&(n.decimals=e[0].decimals);let s,r=[n],p={x:e[0].values[0],y:e[0].values[1]},i=.01;for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:u,values:y}=a,h=y.slice(-2),o=e[l-1],c=o.type;s={x:h[0],y:h[1]};let x,f,g,v,d={x:y[0],y:y[1]},m=Math.abs(s.x-p.x),M=Math.abs(s.y-p.y),b=(m+M)/2*i;switch(u){case"L":n=0===M||M<b&&m>b?{type:"H",values:[y[0]]}:0===m||M>b&&m<b?{type:"V",values:[y[1]]}:a;break;case"Q":if("Q"!==c){p={x:h[0],y:h[1]},r.push(a);continue}let e={x:o.values[0],y:o.values[1]};v={x:2*p.x-e.x,y:2*p.y-e.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"T",values:[s.x,s.y]}:a;break;case"C":let t={x:y[2],y:y[3]};if("C"!==c){r.push(a),p={x:h[0],y:h[1]};continue}let l={x:o.values[2],y:o.values[3]};v={x:2*p.x-l.x,y:2*p.y-l.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"S",values:[t.x,t.y,s.x,s.y]}:a;break;default:n={type:u,values:y}}(a.decimals||0===a.decimals)&&(n.decimals=a.decimals),t>-1&&(n.values=n.values.map(e=>+e.toFixed(t))),p={x:h[0],y:h[1]},r.push(n)}return r}(e)),e=V(e,a),l&&(e=function(e,t=-1){return Y(e,!0,t)}(e)),a>-1&&(e=V(e,a)),e}function X(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 Y(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 G(e,t=-1){return Y(e,!1,t)}function K(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,S=(-x-A)/n,$=(-f-C)/s;const F=(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 I=F(1,0,P,k),E=F(P,k,S,$);0===i&&E>0?E-=2*Math.PI:1===i&&E<0&&(E+=2*Math.PI);let z=(+(Math.abs(E)/(a/4)).toFixed(0)||1)*l;E/=z;let Q=[];const T=1.5707963267948966,q=.551785;let D=E===T?q:E===-T?-q:4/3*Math.tan(E/4),B=E?Math.cos(E):1,j=E?Math.sin(E):0;const N=(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<z;e++){let e={type:"C",values:[]};N(I,E,D,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)}),Q.push(e),I+=E}return Q}function _(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),y=180*Math.abs(i-u)/Math.PI;if(Math.abs(y%180-90)<3){let i=b(e,t,a,l,!1);if(i){let u=A(e,i),y=A(a,i),h=+Math.max(u,y).toFixed(8),o=+Math.min(u,y).toFixed(8),c=o,x=h,f=N([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=j([{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(N([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 ee(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 te(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=Y(e,!1)),p&&l&&(e=function(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}let n=[],s={type:"M",values:(e=l&&a?G(e,t):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}(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?K(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(X(r,a.values)):t.push(a)}return t}(e)),e}function le(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=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(!ae.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=ne[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();if(t&&v.length){if(n="Invalid path data:\n"+v.join("\n"),"log"!==t)throw new Error(n);console.log(n)}i[0].type="M";let L=Array.from(g).join(""),P=/[lcqamts]/g.test(L),k=/[vhst]/gi.test(L),S=/[a]/gi.test(L),$=/[qt]/gi.test(L);return{pathData:i,hasRelatives:P,hasShorthands:k,hasQuadratics:$,hasArcs:S}}(e),{hasRelatives:p,hasShorthands:i,hasQuadratics:u,hasArcs:y}=r,h=r.pathData;return h=te(h,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s},{hasRelatives:p,hasShorthands:i,hasQuadratics:u,hasArcs:y}),h}const ae=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),ne=new Uint8Array(128);function se(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=le(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)),"circle"===m?(y=u,h=u):(y=y||u,h=h||u),d=[{type:"M",values:[o+y,c]},{type:"A",values:[y,h,0,1,1,o-y,c]},{type:"A",values:[y,h,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 t=e.getAttribute("points").replaceAll(","," ").split(" ").filter(Boolean);for(let e=0;e<t.length;e+=2)d.push({type:0===e?"M":"L",values:[+t[e],+t[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 re(e,t=1,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-1],y=e[p],h=e[p+1]||e[i-1],o="z"===h.type.toLowerCase()?n:{x:h.values[h.values.length-2],y:h.values[h.values.length-1]},{type:c,values:x}=y,f=x.slice(-2);r="Z"!==c?{x:f[0],y:f[1]}:n;let g=N([s,r,o],!0);C(s,r),C(r,o);let v=g<C(s,o)/200*t,d=!1;if(l||"C"!==c||(v=!1),l&&("C"===c||"Q"===c)){d=R(s,"C"===c?[{x:x[0],y:x[1]},{x:x[2],y:x[3]}]:"Q"===c?[{x:x[0],y:x[1]}]:[],r),d&&p<i-1&&"C"!==u.type&&(c="L",y.type="L",y.values=f)}s=r,v&&p<i-1&&("L"===c||l&&d)||("M"===c?(n=r,s=n):"Z"===c&&(s=n),a.push(y))}return a}function pe(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],{type:r,values:p}=s,i=p.length;if(l={x:p[i-2],y:p[i-1]},"L"!==r||l.x!==t.x||l.y!==t.y){if("l"===r||"v"===r||"h"===r){if("l"===r?"00"===p.join(""):0===p[0])continue}a.push(s),t=l}}return a}function ie(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?ye(e,l):e}function ue(e,t=!0,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[n-2],u=i.type,y=i.values.slice(-2).map(e=>+e.toFixed(8)),h=y[0]===s.x&&y[1]===s.y,o="L"!==e[1].type&&(!h||"L"===u);if(o=!1,!r)return e;let c=0;{let t=[];for(let l=0,a=e.length;l<a;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(1)-+t.y.toFixed(1)||e.x-t.x),c=t[0].index;e=c?ye(e,c):e}return s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(7)},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 ye(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 he(e,{arcToCubic:t=!1,quadraticToCubic:l=!1,toClockwise:a=!1,returnD:n=!1}={}){const s=(e,t)=>{let l=[],a=[];if("A"!==e){for(let e=0;e<t.length;e+=2)l.push([t[e],t[e+1]]);a=l.pop(),l.reverse()}else{let e=0==t[4]?1:0;l=[t[0],t[1],t[2],t[3],e],a=[t[5],t[6]]}return{controlPoints:l,endPoints:a}};let r=[],p="z"===e[e.length-1].type.toLowerCase();p&&(e=(e=>{let t="z"===e[e.length-1].type.toLowerCase(),l=e[0],[a,n]=[l.values[0],l.values[1]],s=t?e[e.length-2]:e[e.length-1],[r,p]=[s.values[s.values.length-2],s.values[s.values.length-1]];return!t||a==r&&n==p||(e.pop(),e.push({type:"L",values:[a,n]},{type:"Z",values:[]})),e})(e),e.pop());let i=e[e.length-1].values,u=i.length,y=p?e[0]:{type:"M",values:[i[u-2],i[u-1]]};r.push(y),e.reverse();for(let t=1;t<e.length;t++){let l=e[t],a=l.type,n=l.values,p=e[t-1],i=p.type,u=[];u=[s(i,p.values).controlPoints,s(a,n).endPoints].flat(),r.push({type:i,values:u.flat()})}return p&&r.push({type:"z",values:[]}),r}function oe(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];$(p).forEach(e=>{let t=L(p,e);s(t)})}else"A"===a&&F(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;if(o&&"C"===s&&"C"===o.type&&p&&!i){if(I(h,o.p)<t){let s,r=a.cp1.x-o.p0.x,p=a.cp1.y-o.p0.y,i=Math.abs(p)<Math.abs(r),u=o.p,y=1;if(o.extreme){i?(y=Math.abs(Math.abs(o.cp2.x-o.p.x)/Math.abs(a.cp2.x-a.p.x)),s=w(o.p,a.cp2,1+y),a.cp2.x=s.x):(y=Math.abs(Math.abs(o.cp2.y-o.p.y)/Math.abs(a.cp2.y-a.p.y)),s=w(o.p,a.cp2,1+y),a.cp2.y=s.y),e[n+1].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,u.x,u.y],e[n+1].cp1=a.cp1,e[n+1].cp2=a.cp2,e[n+1].p0=a.p0,e[n+1].p=u,e[n+1].extreme=!0,e[n]=null;continue}{let a=e[n+2]?e[n+2]:null;if(!a&&"C"!==a.type)continue;let s=O(o,a,t,l,!1);if(1===s.length){e[n+1]=null,s=s[0],e[n+2].values=[s.cp1.x,s.cp1.y,s.cp2.x,s.cp2.y,s.p.x,s.p.y],e[n+2].cp1=s.cp1,e[n+2].cp2=s.cp2,e[n+2].p0=s.p0,e[n+2].p=s.p,e[n+2].extreme=s.extreme,n++;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=I(s.p0,s.p)<t;if(r&&"C"===r.type&&h&&u&&y){Math.abs(y.cp1.x-p.x),Math.abs(y.cp1.y-p.y);let a=O(r,s,t,l,!1);console.log("comEx",a),1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function ce(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 xe(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,removeColinear:y=!0,flatBezierToLinetos:h=!0,revertToQuadratics:o=!0,refineExtremes:c=!0,keepExtremes:x=!0,keepCorners:f=!0,extrapolateDominant:g=!0,keepInflections:v=!1,addExtremes:d=!1,removeOrphanSubpaths:m=!1,decimals:M=3,autoAccuracy:b=!0,minifyD:A=0,tolerance:C=1,reverse:w=!1,mergePaths:L=!1,removeHidden:P=!0,removeUnused:k=!0,shapesToPaths:S=!0}={}){C=Math.max(.1,C);let $=function(e){let t="string";if(Array.isArray(e))return"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),F="",z=0,Q=0,q=0,D={},B="",j="svgMarkup"===$?1:0,N=[];if(z=new Blob([e]).size,j){if(F=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"]);let s=["metadata","script"];if(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)return n;let r=ce(n);return console.log(r),r}(e,{returnDom:!0,removeHidden:P,removeUnused:k}),S){F.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=se(e);e.replaceWith(t)})}F.querySelectorAll("path").forEach(e=>{N.push({d:e.getAttribute("d"),el:e})})}else"pathDataString"===$?B=e:"polyString"===$&&(B="M"+e),N.push({d:B,el:null});let O={toRelative:a,toShorthands:n,decimals:M},H=[];if(N.forEach(e=>{let{d:t,el:a}=e,n=le(t,{quadraticToCubic:s,toAbsolute:l,arcToCubic:r}),P=n.length,k=n;m&&(k=function(e){for(let t=0,l=e.length;t<l;t++){let l=e[t];if(!l)continue;let{type:a=null,values:n=[]}=l,s=e[t+1]?e[t+1]:null;"M"!==a&&"m"!==a||s&&(!s||"Z"!==s.type&&"z"!==s.type)||(e[t]=null,e[t+1]=null)}return e.filter(Boolean)}(k));let S=E(k),$=[];for(let e=0,t=S.length;e<t;e++){let t=S[e];w&&(t=he(t)),y&&(t=pe(t)),d&&(t=T(t,0,1)),u&&(t=ie(t)),y&&(t=re(t,C,h));let l=U(t),{pathData:a,bb:n,dimA:s}=l;if(a=i?fe(a,{simplifyBezier:i,keepInflections:v,keepExtremes:x,keepCorners:f,extrapolateDominant:g,revertToQuadratics:o,tolerance:C,reverse:w}):a,c){let e=(n.width+n.height)/2*.05;a=oe(a,{threshold:e,tolerance:C})}if(p){let e=3;a.forEach((t,l)=>{let{type:n,values:s,p0:r,cp1:p=null,cp2:i=null,p:u=null}=t;if("C"===n){let t=_(r,p,i,u,e);t.isArc&&(a[l]=t.com)}}),a=ee(a)}o&&a.forEach((e,t)=>{let{type:l,values:n,p0:s,cp1:r=null,cp2:p=null,p:i=null}=e;if("C"===l){let l=J(s,r,p,i);"Q"===l.type&&(l.extreme=e.extreme,l.corner=e.corner,l.dimA=e.dimA,a[t]=l)}}),u&&(a=ue(a)),$.push(a)}if(k=$.flat(),a&&L)H.push(...k);else{b&&(M=function(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=new Set;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?+I(l,a).toFixed(8):0;y&&n.add(y),"M"===p&&(t=a),l=a}let s=Array.from(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)}(k),O.decimals=M),k=W(k,O),k=pe(k);let t=k.length,l=Z(k,A);Q=new Blob([l]).size,q=+(100/z*Q).toFixed(2),e.d=l,e.report={original:P,new:t,saved:P-t,compression:q,decimals:M},a&&a.setAttribute("d",l)}}),j){if(H.length){let e=W(H,O);e=pe(e);let t=Z(e,A);N[0].el.setAttribute("d",t);for(let e=1;e<N.length;e++){let t=N[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(F)}F=ce(F),Q=new Blob([F]).size,q=+(100/z*Q).toFixed(2),z=+(z/1024).toFixed(3),Q=+(Q/1024).toFixed(3),D={svgSize:z,svgSizeOpt:Q,compression:q}}else({d:B,report:D}=N[0]);return t?{svg:F,d:B,report:D,inputType:$,mode:j}:B||F}function fe(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1,reverse:r=!1}={}){let p=[e[0]];for(let r=2,i=e.length;i&&r<=i;r++){let u=e[r-1],y=r<i?e[r]:null,h=y?.type||null,o=u?.directionChange||null,c=y?.directionChange||null,{type:x,values:f,p0:g,p:v,cp1:d=null,cp2:m=null,extreme:M=!1,corner:b=!1,dimA:A=0}=u;if("C"===x&&"C"===h)if(l&&c||a&&b||!o&&t&&M)p.push(u);else{let h=H(u,y,n,s),o=0;if(1===h.length){u=h[0];let y=1;o+=u.error;for(let p=r+1;o<s&&p<i;p++){let r=e[p];if("C"!==r.type||l&&r.directionChange||a&&u.corner||t&&u.extreme)break;let i=H(u,r,n,s);1===i.length&&(o+=.5*i[0].error,y++),u=i[0]}p.push(u),r<i&&(r+=y)}else p.push(u)}else p.push(u)}return r&&(p=he(p)),p}ne[77]=2,ne[109]=2,ne[65]=7,ne[97]=7,ne[67]=6,ne[99]=6,ne[76]=2,ne[108]=2,ne[81]=4,ne[113]=4,ne[83]=4,ne[115]=4,ne[84]=2,ne[116]=2,ne[72]=1,ne[104]=1,ne[86]=1,ne[118]=1,ne[90]=0,ne[122]=0;const{abs:ge,acos:ve,asin:de,atan:me,atan2:Me,ceil:be,cos:Ae,exp:Ce,floor:we,log:Le,hypot:Pe,max:ke,min:Se,pow:$e,random:Fe,round:Ie,sin:Ee,sqrt:ze,tan:Qe,PI:Te}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=xe),e.PI=Te,e.abs=ge,e.acos=ve,e.asin=de,e.atan=me,e.atan2=Me,e.ceil=be,e.cos=Ae,e.exp=Ce,e.floor=we,e.hypot=Pe,e.log=Le,e.max=ke,e.min=Se,e.pow=$e,e.random=Fe,e.round=Ie,e.sin=Ee,e.sqrt=ze,e.svgPathSimplify=xe,e.tan=Qe}(this["svg-path-simplify"]=this["svg-path-simplify"]||{});
|