svg-path-simplify 0.0.5 → 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/README.md +193 -11
- package/dist/svg-path-simplify.esm.js +890 -263
- package/dist/svg-path-simplify.esm.min.js +1 -1
- package/dist/svg-path-simplify.js +889 -263
- package/dist/svg-path-simplify.min.js +1 -1
- package/dist/svg-path-simplify.node.js +889 -263
- package/dist/svg-path-simplify.node.min.js +1 -1
- package/index.html +16 -8
- package/package.json +6 -3
- package/src/detect_input.js +2 -0
- package/src/dom-polyfill.js +29 -0
- package/src/dom-polyfill_back.js +22 -0
- package/src/index.js +11 -5
- package/src/pathData_simplify_cubic.js +1 -37
- package/src/pathData_simplify_cubic_extrapolate.js +45 -27
- package/src/pathSimplify-main.js +163 -68
- 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_convert.js +7 -3
- package/src/svgii/pathData_parse_els.js +239 -0
- package/src/svgii/pathData_remove_collinear.js +13 -3
- package/src/svgii/pathData_remove_orphaned.js +20 -0
- package/src/svgii/pathData_remove_zerolength.js +28 -2
- package/src/svgii/pathData_reorder.js +3 -1
- package/src/svgii/pathData_split.js +5 -0
- package/src/svgii/pathData_toPolygon.js +98 -47
- package/src/svgii/poly_analyze.js +20 -16
- package/src/svgii/rounding.js +25 -19
- package/src/svgii/simplify_refineExtremes.js +173 -0
- package/src/svgii/svg_cleanup.js +14 -2
- package/test.js +14 -0
- package/testSVG.js +39 -0
- /package/src/svgii/{simplify_polygon.js → polygon_unite.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const{abs:e,acos:t,asin:l,atan:a,atan2:n,ceil:s,cos:r,exp:i,floor:p,log:u,max:y,min:o,pow:h,random:c,round:x,sin:f,sqrt:g,tan:v,PI:d}=Math;function m(e,t,l=!1){let a=n(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function M(e,t,l,a,n=!0){let s,r,i,p,u,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,i=e.x-l.x,p=(a.x-l.x)*r-(a.y-l.y)*i,u=(t.x-e.x)*r-(t.y-e.y)*i,r=p/s,i=u/s,y={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};let o=!1;return r>0&&r<1&&i>0&&i<1&&(o=!0),!(n&&!o)&&y}function b(e,t){return g((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 A(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*d)),n}function w(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],i=n?e[2]:e[1],p=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,y,o,h,c=s.x===r.x&&s.y===r.y,x=p.x===i.x&&p.y===i.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=A(s,r,t),n?(l=A(r,i,t),y=A(i,p,t),o=A(e,l,t),h=A(l,y,t),u=A(o,h,t),u.angle=m(o,h),a&&(u.cpts=[l,y,o,h])):(l=A(s,r,t),y=A(r,p,t),u=A(l,y,t),u.angle=m(l,y),a&&(u.cpts=[l,y]))):(u.x=p.x,u.y=p.y,u.angle=m(i,p)):(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*i.x+t**3*p.x,y:e**3*s.y+3*e**2*t*r.y+3*e*t**2*i.y+t**3*p.y}:{x:e*e*s.x+2*e*t*r.x+t**2*p.x,y:e*e*s.y+2*e*t*r.y+t**2*p.y}}return u})(e,t,l):A(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*d),n}function L(e,t,l,n,s,i=0,p=!0,u=!1){if(s=u?s*d/180:s,i=u?i*d/180:i,i=l!==n&&i!==2*d?i:0,p&&l!==n){let e=a(v(s=i?s-i:s)*(l/n));s=r(s)<0?e+d:e}let y=e+l*r(s),o=t+n*f(s),h={x:y,y:o};return i&&(h.x=e+(y-e)*r(i)-(o-t)*f(i),h.y=t+(y-e)*f(i)+(o-t)*r(i)),h}function P(e,t=[],l=.05){let a=3===t.length,n=t[0]||null,s=a?t[1]:null,r=a?t[2]:t[1],i=.5*Math.PI,p=!1,u=!1,y=n?m(r,n,!0):null;if(p=Math.abs(y%i)<l||Math.abs(y%i-i)<l,a){let e=s?m(s,r,!0):0;u=Math.abs(e%i)<=l||Math.abs(e%i-i)<=l}return p||u}function S(e){return 4===e.length?function(e,t,l,a){let[n,s,r,i,p,u,y,o]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],h=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>=h&&t.y<=f&&l.y>=h&&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*p,g=-3*n+9*r-9*p+3*y,d=3*r-3*n):(v=6*s-12*i+6*u,g=-3*s+9*i-9*u+3*o,d=3*i-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),i=Math.min(e.x,l.x),p=Math.max(e.x,l.x),u=Math.max(e.y,l.y);if(t.y>=r&&t.y<=u&&t.x>=i&&t.x<=p)return[];let[y,o,h,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*h+x:o-2*c+f,n=0==e?-2*y+2*h:-2*o+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 I(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),i=Math.max(...n),p=Math.min(...s),u=i-r,y=Math.max(...s)-p;if(e.length<3||0===u||0===y)return{area:0,flat:!0,thresh:1e-4,ratio:0};let o=C(l,a),h=C(l,e[0]),c=(h+(e.length>3?C(a,e[1]):h))/2;let x=.5*(u+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:o,areaThresh:o/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 i=s.x-e.x,p=s.y-e.y,u=l.x-r.x,y=l.y-r.y,o=Math.abs(i*y-p*u);if(!o)return!0;let h=l.x-e.x,c=l.y-e.y,x=Math.abs(h*p-c*i);return!x||(x/o<1.1&&(a=!0),a)}function k(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function $(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,i,p=[],u=[],y=e[0],o=e[1],h=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=w([y,o],t),a=w([o,h],t),n=w([h,c],t),s=w([l,a],t),r=w([a,n],t),i=w([s,r],t),p.push({x:y.x,y:y.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:i.x,y:i.y}),u.push({x:i.x,y:i.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=w([y,o],t),n=w([o,c],t),i=w([a,n],t),p.push({x:y.x,y:y.y},{x:a.x,y:a.y},{x:i.x,y:i.y}),u.push({x:i.x,y:i.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=w([y,c],t),p.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})),[p,u]}function E(e,t,l=0,a=1){let n=[],s=6===t.length?"C":"Q",r={x:t[0],y:t[1]},i="C"===s?{x:t[2],y:t[3]}:r,p={x:t[4],y:t[5]},u=Math.max(p.x,e.x),y=Math.min(p.x,e.x),o=Math.max(p.y,e.y),h=Math.min(p.y,e.y),c=0;if(r.x<y||r.x>u||r.y<h||r.y>o||i.x<y||i.x>u||i.y<h||i.y>o){let u=S("C"===s?[e,r,i,p]:[e,r,p]).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,i,p=t.length,u={x:t[p-2],y:t[p-1]};2===t.length?i=[e,u]:4===t.length?(s={x:t[0],y:t[1]},i=[e,s,u]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},i=[e,s,r,u]);if(l.length)if(1===l.length){let e=z(i,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=z(i,e),a=t[0];n.push(a),i=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=z(i,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),i=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 i=1;r&&i<r;i++){let r=e[i],{type:p,values:u}=r,y=u.slice(-2);if(y[0],y[1],"C"!==p&&"Q"!==p)a.push(r);else if("C"===p||"Q"===p){let e=E(n,u,t,l).pathData;a.push(...e)}n={x:y[0],y:y[1]},"z"===p.toLowerCase()?n=s:"M"===p&&(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),i=Math.max(...a),p={x:n,left:n,right:s,y:r,top:r,bottom:i,width:s-n,height:i-r};if(t>-1)for(let e in p)p[e]=+p[e].toFixed(t);return p}function q(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,i={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},p=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=b(i,p)/2,l=A(i,p,.5),a=L(l.x,l.y,e,e,0),n=L(l.x,l.y,e,e,Math.PI);t.push(a,n,p);break}arcToBezier(i,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(p)}return t}(e),l=Q(t);return l}(e);t.push(l)}),t}function D(e,t){let[l,a,n,s,r,i]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[p,u,y,o,h,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=y*o&&n*s>y*o&&l<p&&r>h&&a<u&&i>c&&(x=!0),x}function B(t,l=9){let a=0,s=[],i=$(t),p=i.length>1,u=[];if(p){let e=q(i);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){D(t,a)&&u.push(l)}}})}return i.forEach((t,l)=>{s=[];let i=0,p=0,y=1,o=[];t.forEach(function(l,a){let[p,u]=[l.type,l.values],y=u.length;if(u.length){let h=(a>0?t[a-1]:t[0]).values,c=h.length,x={x:h[c-2],y:h[c-1]},v={x:u[y-2],y:u[y-1]};if("C"===p||"Q"===p){let e={x:u[0],y:u[1]};o="C"===p?[x,e,{x:u[2],y:u[3]},v]:[x,e,v];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}(o));i+=t,s.push(x,v)}else if("A"===p){let t=function(t,l,a,s,i,p,u,y,o){const h=(e,t,l,a)=>n(a-t,l-e);let c={cx:0,cy:0,rx:a=e(a),ry:s=e(s),startAngle:0,endAngle:0,deltaAngle:0,clockwise:u,xAxisRotation:i,largeArc:p,sweep:u};if(0==a||0==s)throw Error("rx and ry can not be 0");if(a===s){let e=Math.abs(y-t),a=Math.abs(o-l),n=e,s=Math.min(t,y),r=Math.min(l,o),i=.5*Math.PI;if(0===e&&a||0===a&&e)return n=0===e&&a?a/2:e/2,c.rx=n,c.ry=n,0===e&&a?(c.cx=t,c.cy=r+a/2,c.startAngle=l>o?i:-i,c.endAngle=l>o?-i:i,c.deltaAngle=u?Math.PI:-Math.PI):0===a&&e&&(c.cx=s+e/2,c.cy=l,c.startAngle=t>y?Math.PI:0,c.endAngle=t>y?-Math.PI:Math.PI,c.deltaAngle=u?Math.PI:-Math.PI),c}let x,v,m=a===s?0:i*d/180,M=m?f(m):0,b=m?r(m):1,C=(t-y)/2,A=(l-o)/2,w=(t+y)/2,L=(l+o)/2,P=m?b*C+M*A:C,S=m?b*A-M*C:A,I=P*P/(a*a)+S*S/(s*s);I>1&&(a*=g(I),s*=g(I),c.rx=a,c.ry=s);let F=a*s,k=a*S,$=s*P,z=k**2+$**2;if(!z)throw Error("start point can not be same as end point");let E=g(e((F*F-z)/z));p==u&&(E=-E);let T=E*k/s,Q=-E*$/a;x=m?b*T-M*Q+w:w+T,v=m?M*T+b*Q+L:L+Q,c.cy=v,c.cx=x;let q=h(x,v,t,l),D=h(x,v,y,o);!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}(x.x,x.y,l.values[0],l.values[1],l.values[2],l.values[3],l.values[4],v.x,v.y),{cx:a,cy:p,rx:u,ry:y,startAngle:o,endAngle:h,deltaAngle:c}=t,m=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))}(u,y,o,h));m-=Math.abs(O([x,{x:a,y:p},v])),s.push(x,v),i+=m}else s.push(x,v)}});let h=O(s);-1!==u.indexOf(l)&&(y=-1),p=h<0&&i<0?(Math.abs(i)-Math.abs(h))*y:(Math.abs(i)+Math.abs(h))*y,a+=p}),a}function O(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 j(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,s="",r=a?"\n":n?"":" ",i=n?"":" ";s=`${e[0].type}${i}${e[0].values.join(" ")}${r}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:p,values:u}=a;if(!n||"A"!==p&&"a"!==p||(u=[u[0],u[1],u[2],`${u[3]}${u[4]}${u[5]}`,u[6]]),p=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+=`${p}${i}${e}${r}`}else s+=`${p}${i}${u.join(" ")}${r}`}return n&&(s=s.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function N(e,t,l=!1,a=1){let n=[e,t],s=function(e,t){let l=M(e.p0,e.cp1,t.cp2,t.p,!1),a=M(l,t.p,t.p0,t.cp1,!1),n=b(l,t.p),s=b(a,t.p),r=1-s/n,i=b(e.cp2,e.p),p=b(e.cp2,t.cp1);return r=Math.min(i)/p,r}(e,t),r=k(e.p0,e.p),i=k(t.p0,t.p),p=.05*Math.min(r,i)*a,u=function(e,t,l=0,a=0){let{p0:n,cp1:s}=e,{p:r,cp2:i}=t,p={x:(s.x-(1-l)*n.x)/l,y:(s.y-(1-l)*n.y)/l},u={x:(i.x-a*r.x)/(1-a),y:(i.y-a*r.y)/(1-a)},y={p0:n,cp1:p,cp2:u,p:r};return y}(e,t,s,s),y=w([u.p0,u.cp1,u.cp2,u.p],s),o=k(e.p,y),h=0,c=0,x=!1,f=o;if(o<p){let l=.5*(1+s);if(h=k(w([t.p0,t.cp1,t.cp2,t.p],.5),w([u.p0,u.cp1,u.cp2,u.p],l)),f+=h,h<p){let t=.5*s;c=k(w([e.p0,e.cp1,e.cp2,e.p],.5),w([u.p0,u.cp1,u.cp2,u.p],t)),h+c<p&&(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=C(e.p0,e.p)>C(t.p0,t.p),i=JSON.parse(JSON.stringify(e)),p=JSON.parse(JSON.stringify(t)),u=M(i.p0,i.cp1,p.p,p.cp2,!1);if(!u)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}),o=(e,t)=>({x:e.x*t,y:e.y*t}),h=(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=h(y(e.p0,c),x)/h(x,x),g=w([t.p0,t.cp1,t.cp2,t.p],f),v=n(t.p0,t.cp1,t.cp2,t.p,f);f-=h(y(g,e.p0),v)/h(v,v);let d=w([t.p0,t.cp1,t.cp2,t.p],f),m=t.p,b=n(t.p0,t.cp1,t.cp2,t.p,f),L=n(t.p0,t.cp1,t.cp2,t.p,1),P=1-f,S=(I=d,F=o(b,P/3),{x:I.x+F.x,y:I.y+F.y});var I,F;let $=y(m,o(L,P/3)),z={p0:d,cp1:S,cp2:$,p:m};r&&(z={p0:m,cp1:$,cp2:S,p:d});let E=w([z.p0,z.cp1,z.cp2,z.p],.5,!1,!0),T=E.cpts[2],Q=M(E,T,z.p0,u,!1),q=M(E,T,z.p,u,!1),D=A(z.p0,Q,1.333),O=A(z.p,q,1.333);if(M(i.p0,D,p.p,O,!0))return s;z.cp1=D,z.cp2=O;let N=k(i.p0,z.p0)+k(p.p,z.p);if(z.p0=i.p0,z.p=p.p,z.extreme=p.extreme,z.corner=p.corner,z.dimA=p.dimA,z.directionChange=p.directionChange,z.values=[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y],N<l){let e=B([{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:[p.cp1.x,p.cp1.y,p.cp2.x,p.cp2.y,p.p.x,p.p.y]}]),t=[{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]}],l=B(t),n=Math.abs(l/e-1);z.error=10*n*a,j(t),n<.01&&(s=[z])}return s}(e,t,p,a);1===l.length&&(x=!0,u=l[0],f=u.error)}return x&&(u.p0=e.p0,u.p=t.p,u.dimA=k(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/p,n=[u]),n}function V(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:i,bottom:p,width:u,height:y}=n,o=e[0].values[0],h=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],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,A,w,L,S,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 z=k(x,t);if(a.dimA=z,"L"===n&&(a.lineto=!0),"Z"===n&&(a.closePath=!0,c.x!==o&&c.y!==h&&(a.lineto=!0)),"Q"!==n&&"C"!==n||(M={x:u[0],y:u[1]},b="C"===n?{x:u[2],y:u[3]}:null,a.cp1=M,b&&(a.cp2=b)),u.length>2){"Q"!==n&&"C"!==n||v.push(M),"C"===n&&v.push(b),v.push(t),d=I(v).flat,a.flat=d,d&&(a.extreme=!1)}d||"L"===n||t.x!==s&&t.y!==i&&t.x!==r&&t.y!==p||(a.extreme=!0);let E=e[l]?e[l]:null,T=E?E.values.slice(-2):null;S=E?E.type:null,!E||"Q"!==E.type&&"C"!==E.type||(L=E?{x:T[0],y:T[1]}:null,A={x:E.values[0],y:E.values[1]},w="C"===E.type?{x:E.values[2],y:E.values[3]}:null),F=O(v);let Q=g<0&&F>0||g>0&&F<0;if(g=F,Q&&(a.directionChange=!0),("Q"===n||"C"===n)&&("Q"===n&&"Q"===S||"C"===n&&"C"===S)){let e=v.slice(1),l=I("C"===n?[t,A,w,L]:[t,A,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||P(0,e,$)))a.extreme=!0;else{let e=b?[b,t]:[M,t],l=[t,A],n=m(...e,!0),s=m(...l,!0),r=180*Math.abs(n-s)/Math.PI,i=C(...e),p=C(...l);r>10&&i&&p&&(a.corner=!0)}}f.push(a),x=t}return l={pathData:f,bb:n,dimA:(u+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 Z(e={},t={},l={},a={}){let n=A(e,t,1.5),s=A(a,l,1.5),r=.01*k(e,a),i=k(n,s),p=null,u="C",y=[t.x,t.y,l.x,l.y,a.x,a.y];return i<r&&(p=M(e,t,a,l,!1),p&&(u="Q",y=[p.x,p.y,a.x,a.y])),{type:u,values:y}}function R(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?W(e,t):e;let n={type:"M",values:e[0].values};e[0].decimals&&(n.decimals=e[0].decimals);let s,r=[n],i={x:e[0].values[0],y:e[0].values[1]},p=.01;for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:u,values:y}=a,o=y.slice(-2),h=e[l-1],c=h.type;s={x:o[0],y:o[1]};let x,f,g,v,d={x:y[0],y:y[1]},m=Math.abs(s.x-i.x),M=Math.abs(s.y-i.y),b=(m+M)/2*p;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){i={x:o[0],y:o[1]},r.push(a);continue}let e={x:h.values[0],y:h.values[1]};v={x:2*i.x-e.x,y:2*i.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),i={x:o[0],y:o[1]};continue}let l={x:h.values[2],y:h.values[3]};v={x:2*i.x-l.x,y:2*i.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))),i={x:o[0],y:o[1]},r.push(n)}return r}(e)),e=H(e,a),l&&(e=function(e,t=-1){return J(e,!0,t)}(e)),a>-1&&(e=H(e,a)),e}function U(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 J(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,i=s;for(let a=1,p=e.length;a<p;a++){let p=e[a],{type:u,values:y}=p,o=t?u.toLowerCase():u.toUpperCase();if(u!==o)switch(u=o,p.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],i=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 h=y.length;switch(u){case"z":case"Z":n=r,s=i;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[h-2]+(t?n:0),i=y[h-1]+(t?s:0);default:n=y[h-2]+(t?n:0),s=y[h-1]+(t?s:0)}l>=0&&(p.values=p.values.map(e=>+e.toFixed(l)))}return e}function W(e,t=-1){return J(e,!1,t)}function X(e,t,l=1){const a=2*Math.PI;let[n,s,r,i,p,u,y]=t;if(0===n||0===s)return[];let o=r?r*a/360:0,h=o?Math.sin(o):0,c=o?Math.cos(o):1,x=c*(e.x-u)/2+h*(e.y-y)/2,f=-h*(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)*(i===p?-1:1));let C=b?b*n/s*f:0,A=b?b*-s/n*x:0,w=c*C-h*A+(e.x+u)/2,L=h*C+c*A+(e.y+y)/2,P=(x-C)/n,S=(f-A)/s,I=(-x-C)/n,F=(-f-A)/s;const k=(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 $=k(1,0,P,S),z=k(P,S,I,F);0===p&&z>0?z-=2*Math.PI:1===p&&z<0&&(z+=2*Math.PI);let E=(+(Math.abs(z)/(a/4)).toFixed(0)||1)*l;z/=E;let T=[];const Q=1.5707963267948966,q=.551785;let D=z===Q?q:z===-Q?-q:4/3*Math.tan(z/4),B=z?Math.cos(z):1,O=z?Math.sin(z):0;const j=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,i=Math.cos(e+t),p=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:i+p*l,y:p-i*l},{x:i,y:p}]};for(let e=0;e<E;e++){let e={type:"C",values:[]};j($,z,D,B,O).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-h*a+w,h*l+c*a+L)}),T.push(e),$+=z}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,i=!1,p=m(e,t,!0),u=m(a,l,!0),y=180*Math.abs(p-u)/Math.PI;if(Math.abs(y%180-90)<3){let p=M(e,t,a,l,!1);if(p){let u=b(e,p),y=b(a,p),o=+Math.max(u,y).toFixed(8),h=+Math.min(u,y).toFixed(8),c=h,x=o,f=O([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=o,x=c),g&&(c=o,x=h);let v=B([{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(O([e,a,p])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<n&&(i=!0,s=d)}}return{com:s,isArc:i,area:r}}function Y(e){let t,l=[[]],a=0,n=[[]],s={x:e[0].values[0],y:e[0].values[1]};for(let r=0,i=e.length;r<i;r++){let i=e[r],{type:p,values:u}=i;if("A"===p){let p=e[r-1].values.slice(-2);s={x:p[0],y:p[1]};let[y,o,h,c,x,f,g]=u,v=100/y*Math.abs(y-o)<5;t={x:u[5],y:u[6]},i.p0=s,i.p=t,i.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(i),n[a].push(r)),d&&"A"===d.type){let[e,i,p,u,h,c,x]=d.values,f=y!=e?100/y*Math.abs(y-e):0,g=o!=i?100/o*Math.abs(o-i):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 i=0,p=0;a.forEach(({values:e})=>{const[t,l]=e;i+=t,p+=l}),i/=r,p/=r;let u=100/i*Math.abs(i-p)<5;u&&(i=(i+p)/2,p=i);let y=e[s-1].values.slice(-2);if(y[0],y[1],4===r){let[t,l,n,y,o,h,c]=a[1].values,[,,,,,x,f]=a[3].values;u&&(i=1,p=1);let g={type:"A",values:[i,p,n,y,o,h,c]},v={type:"A",values:[i,p,n,y,o,x,f]};e.splice(s,r,g,v)}else if(3===r){let[t,l,n,u,y,o,h]=a[0].values,[c,x,,,,f,g]=a[2].values;u=1;let v={type:"A",values:[i,p,n,u,y,f,g]};e.splice(s,r,v)}else if(2===r){let[t,l,n,y,o,h,c]=a[0].values,[x,f,,,,g,v]=a[1].values;u&&(i=1,p=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:[i,p,n,y,o,g,v]};e.splice(s,r,t)}}}return e}function K(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2}={},{hasRelatives:r=!0,hasShorthands:i=!0,hasQuadratics:p=!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),p=/[qt]/gi.test(t),u=/[a]/gi.test(t),i=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(p&&a||u&&n)&&(l=!0,t=!0),r&&t&&(e=J(e,!1)),i&&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?W(e,t):e)[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,i,p,u,y,o,h,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]],i=b+(b-a),p=C+(C-r),s={type:"Q",values:[i,p,m,M]};break;case"S":[a,r]=[v[0],v[1]],[b,C]=[v[d-2],v[d-1]],[o,h]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,C],i=2*b-o,p=2*C-h,u=f[0],y=f[1],s={type:"C",values:[i,p,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,i={x:s[r-2],y:s[r-1]};"A"===n.type?X(i,n.values,t).forEach(e=>{l.push(e)}):l.push(n)}return l}(e,s)),p&&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(U(r,a.values)):t.push(a)}return t}(e)),e}function _(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,i="",p=[],u=-1,y="",o=!1,h=0,c=0,x=0,f=!1,g=new Set([]),v=[];const d=()=>{f&&("M"===i?i="L":"m"===i&&(i="l"),p.push({type:i,values:[]}),u++,c=0,f=!1)},m=(e=!1)=>{(e?h>0:""!==y)&&(t&&-1===u&&(n="Pathdata must start with M command",v.push(n),i="M",p.push({type:i,values:[]}),x=2,c=0,u++),"A"===i||"a"===i?(y=M(),p[u].values.push(...y)):(t&&y[1]&&"."!==y[1]&&"0"===y[0]&&(n=`${u}. command: Leading zeros not valid: ${y}`,v.push(n)),p[u].values.push(+y)),c++,y="",h=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=p[u].values.length;if(e&&e<x||e&&e>x||("z"===i||"Z"===i)&&e>0){n=`${u}. command of type "${i}": ${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(o||45!==l&&46!==l)d();else{let e=46===l;m(e),d(),e&&h++}y+=e[s],o=C,s++}else if((l<48||l>5759)&&a(l))m(),s++;else{if(l>64){if(!ee.has(l)){n=`${u}. command "${e[s]}" is not a valid type`,v.push(n),s++;continue}""!==y&&(p[u].values.push(+y),c++,y=""),t&&b(),i=e[s],x=te[l];let a="M"===i||"m"===i,r=u>0&&("z"===p[u].type||"Z"===p[u].type);g.add(i),r&&!a&&(p.push({type:"m",values:[0,0]}),u++),p.push({type:i,values:[]}),u++,h=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)}p[0].type="M";let L=Array.from(g).join(""),P=/[lcqamts]/g.test(L),S=/[vhst]/gi.test(L),I=/[a]/gi.test(L),F=/[qt]/gi.test(L);return{pathData:p,hasRelatives:P,hasShorthands:S,hasQuadratics:F,hasArcs:I}}(e),{hasRelatives:i,hasShorthands:p,hasQuadratics:u,hasArcs:y}=r,o=r.pathData;return o=K(o,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s},{hasRelatives:i,hasShorthands:p,hasQuadratics:u,hasArcs:y}),o}const ee=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),te=new Uint8Array(128);function le(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 i=1,p=e.length;i<p;i++){let u=e[i-1],y=e[i],o=e[i+1]||e[p-1],h="z"===o.type.toLowerCase()?n:{x:o.values[o.values.length-2],y:o.values[o.values.length-1]},{type:c,values:x}=y,f=x.slice(-2);r="Z"!==c?{x:f[0],y:f[1]}:n;let g=O([s,r,h],!0)<C(s,h)/100*t,v=!1;if(l||"C"!==c||(g=!1),l&&("C"===c||"Q"===c)){v=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),v&&i<p-1&&"C"!==u.type&&(c="L",y.type="L",y.values=f)}s=r,g&&i<p-1&&("L"===c||l&&v)||("M"===c?(n=r,s=n):"Z"===c&&(s=n),a.push(y))}return a}function ae(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:i}=s,p=i.slice(-2);l={x:p[0],y:p[1]},"L"===r&&l.x===t.x&&l.y===t.y||(a.push(s),t=l)}return a}function ne(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?re(e,l):e}function se(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(),i=e.filter(e=>"L"===e.type),p=e[n-2],u=p.type,y=p.values.slice(-2).map(e=>+e.toFixed(8)),o=y[0]===s.x&&y[1]===s.y,h="L"!==e[1].type&&(!o||"L"===u);if(h=!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,i=e[l+1]&&"L"===e[l+1].type,p=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:i,prevCom:p,nextCom:u};y.index=l,t.push(y)}}if(i.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?re(e,c):e}return s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(7)},n=e.length,p=e[n-2],u=p.type,y=p.values.slice(-2).map(e=>+e.toFixed(8)),o="L"===u&&y[0]===s.x&&y[1]===s.y,t&&o&&e.splice(n-2,1),a.push(...e),a}function re(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],i=r.values.length,[p,u]=[r.values[i-2],r.values[i-1]].map(e=>+e.toFixed(8));!l||n==p&&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,i=e.slice(l),p=e.slice(0,l);return p.shift(),s=p[p.length-1].values||[],r=[s[s.length-2],s[s.length-1]],n&&(i.pop(),p.push({type:"Z",values:[]})),e=[{type:"M",values:r},...i,...p]}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=[],i="z"===e[e.length-1].type.toLowerCase();i&&(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,i]=[s.values[s.values.length-2],s.values[s.values.length-1]];return!t||a==r&&n==i||(e.pop(),e.push({type:"L",values:[a,n]},{type:"Z",values:[]})),e})(e),e.pop());let p=e[e.length-1].values,u=p.length,y=i?e[0]:{type:"M",values:[p[u-2],p[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,i=e[t-1],p=i.type,u=[];u=[s(p,i.values).controlPoints,s(a,n).endPoints].flat(),r.push({type:p,values:u.flat()})}return i&&r.push({type:"z",values:[]}),r}function pe(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){let t=[...e.attributes].map(e=>e.name);t.forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t)return n;let r=function(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}(n);return console.log(r),r}function ue(e="",{toAbsolute:t=!0,toRelative:l=!0,toShorthands:a=!0,decimals:n=3,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:i=!1,arcAccuracy:p=4,keepExtremes:u=!0,keepCorners:y=!0,keepInflections:o=!0,extrapolateDominant:h=!1,addExtremes:c=!1,optimizeOrder:x=!0,removeColinear:f=!0,simplifyBezier:g=!0,autoAccuracy:v=!0,flatBezierToLinetos:d=!0,revertToQuadratics:m=!0,minifyD:M=0,tolerance:b=1,reverse:C=!1,removeHidden:A=!0,removeUnused:w=!0,getObject:L=!1}={}){b=Math.max(.1,b);let P=function(e){let t="string";if(e instanceof HTMLImageElement)return"img";if(e instanceof SVGElement)return"svg";if(e instanceof HTMLCanvasElement)return"canvas";if(e instanceof File)return"file";if(e instanceof ArrayBuffer)return"buffer";if(e instanceof Blob)return"blob";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,F=0,z=0,E={},Q="",q="svgMarkup"===P?1:0,D=[];if(I=new Blob([e]).size,q){S=pe(e,{returnDom:!0,removeHidden:A,removeUnused:w}),S.querySelectorAll("path").forEach(e=>{D.push({d:e.getAttribute("d"),el:e})})}else"pathDataString"===P?Q=e:"polyString"===P&&(Q="M"+e),D.push({d:Q,el:null});return D.forEach(e=>{let{d:p,el:A}=e,w=_(p,{quadraticToCubic:s,toAbsolute:t,arcToCubic:r}),L=JSON.parse(JSON.stringify(w)),P=w.length,S=$(L),E=[];for(let e=0,t=S.length;e<t;e++){let t=S[e];C&&(t=ie(t)),f&&(t=ae(t)),c&&(t=T(t,0,1)),x&&(t=ne(t)),f&&(t=le(t,b,d));let l=V(t),{pathData:a,bb:n,dimA:s}=l;if(a=g?ye(a,{simplifyBezier:g,keepInflections:o,keepExtremes:u,keepCorners:y,extrapolateDominant:h,revertToQuadratics:m,tolerance:b,reverse:C}):a,i){let e=3;a.forEach((t,l)=>{let{type:n,values:s,p0:r,cp1:i=null,cp2:p=null,p:u=null}=t;if("C"===n){let t=G(r,i,p,u,e);t.isArc&&(a[l]=t.com)}}),a=Y(a)}m&&a.forEach((e,t)=>{let{type:l,values:n,p0:s,cp1:r=null,cp2:i=null,p:p=null}=e;if("C"===l){let e=Z(s,r,i,p);"Q"===e.type&&(a[t]=e)}}),x&&(a=se(a)),E.push(a)}L=E.flat(),v&&(n=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:i,values:p}=r,u=p.length?p.slice(-2):[t.x,t.y];a={x:u[0],y:u[1]};let y=r.dimA?+r.dimA.toFixed(8):"M"!==i?+k(l,a).toFixed(8):0;y&&n.add(y),"M"===i&&(t=a),l=a}let s=Array.from(n).sort(),r=Math.ceil(s.length/8);s=s.slice(0,r);let i=s.reduce((e,t)=>e+t,0)/r,p=i>50?0:Math.floor(50/i).toString().length;return Math.min(Math.max(0,p),8)}(L)),L=R(L,{toRelative:l,toShorthands:a,decimals:n});let Q=[];L.forEach((e,t)=>{let{type:l,values:a}=e;if("l"===l||"v"===l||"h"===l){("l"===l?"00"!==a.join(""):0!==a[0])&&Q.push(e)}else Q.push(e)}),L=Q;let q=L.length,D=j(L,M);F=new Blob([D]).size,z=+(100/I*F).toFixed(2),e.d=D,e.report={original:P,new:q,saved:P-q,compression:z,decimals:n},A&&A.setAttribute("d",D)}),q?(S=(new XMLSerializer).serializeToString(S),F=new Blob([S]).size,z=+(100/I*F).toFixed(2),I=+(I/1024).toFixed(3),F=+(F/1024).toFixed(3),E={svgSize:I,svgSizeOpt:F,compression:z}):({d:Q,report:E}=D[0]),L?{svg:S,d:Q,report:E,inputType:P,mode:q}:Q||S}function ye(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1,reverse:r=!1}={}){let i=[e[0]];for(let r=2,p=e.length;p&&r<=p;r++){let u=e[r-1],y=r<p?e[r]:null,o=y?.type||null,h=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:C=0}=u;if("C"===x&&"C"===o)if(l&&c||a&&b||!h&&t&&M)i.push(u);else{let o=N(u,y,n,s),h=0;if(1===o.length){u=o[0];let y=1;h+=u.error;for(let i=r+1;h<s&&i<p;i++){let r=e[i];if("C"!==r.type||l&&r.directionChange||a&&u.corner||t&&u.extreme)break;let p=N(u,r,n,s);1===p.length&&y++,u=p[0]}i.push(u),r<p&&(r+=y)}else i.push(u)}else i.push(u)}return r&&(i=ie(i)),i}function oe(e=null,t=!1){if(!e)return{x:0,y:0,width:300,height:150};let l=window.getComputedStyle(e),a=e.hasAttribute("width")?e.width.baseVal.value:parseFloat(l.width)||300,n=e.hasAttribute("height")?e.height.baseVal.value:parseFloat(l.height)||150,s=e.getAttribute("viewBox")?e.viewBox.baseVal:{x:0,y:0,width:a,height:n},{x:r,y:i,width:p,height:u}=s;if(s={x:r,y:i,width:p,height:u},t)for(let e in s)s[e]=Math.ceil(s[e]);return s}te[77]=2,te[109]=2,te[65]=7,te[97]=7,te[67]=6,te[99]=6,te[76]=2,te[108]=2,te[81]=4,te[113]=4,te[83]=4,te[115]=4,te[84]=2,te[116]=2,te[72]=1,te[104]=1,te[86]=1,te[118]=1,te[90]=0,te[122]=0;const{abs:he,acos:ce,asin:xe,atan:fe,atan2:ge,ceil:ve,cos:de,exp:me,floor:Me,log:be,hypot:Ce,max:Ae,min:we,pow:Le,random:Pe,round:Se,sin:Ie,sqrt:Fe,tan:ke,PI:$e}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=ue,window.getViewBox=oe,window.renderPoint=function(e,t,l="red",a="1%",n="1",s="",r=!0,i="",p=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let u=`<circle class="${p}" opacity="${n}" id="${i}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return u;e.insertAdjacentHTML("beforeend",u)}),exports.PI=$e,exports.abs=he,exports.acos=ce,exports.asin=xe,exports.atan=fe,exports.atan2=ge,exports.ceil=ve,exports.cos=de,exports.exp=me,exports.floor=Me,exports.getViewBox=oe,exports.hypot=Ce,exports.log=be,exports.max=Ae,exports.min=we,exports.pow=Le,exports.random=Pe,exports.round=Se,exports.sin=Ie,exports.sqrt=Fe,exports.svgPathSimplify=ue,exports.tan=ke;
|
|
1
|
+
"use strict";const{abs:e,acos:t,asin:l,atan:a,atan2:s,ceil:n,cos:r,exp:p,floor:i,log:u,max:y,min:o,pow:h,random:c,round:x,sin:f,sqrt:g,tan:v,PI:d}=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 M(e=null,t=null,l=null,a=null,s=!0,n=!1){let r,p,i,u,y,o={};if(!(e&&t&&l&&a))return n&&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 n&&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,o={x:e.x+p*(t.x-e.x),y:e.y+p*(t.y-e.y)};let h=!1;return p>0&&p<1&&i>0&&i<1&&(h=!0),!(s&&!h)&&o}function b(e,t){return g((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 C(e,t,l,a=!1){let s={x:(t.x-e.x)*l+e.x,y:(t.y-e.y)*l+e.y};return a&&(s.angle=m(e,t),s.angle<0&&(s.angle+=2*d)),s}function w(e,t=.5,l=!1,a=!1){let s;return s=e.length>2?((e,t,l=!1)=>{let s=4===e.length,n=e[0],r=e[1],p=s?e[2]:e[1],i=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,y,o,h,c=n.x===r.x&&n.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=C(n,r,t),s?(l=C(r,p,t),y=C(p,i,t),o=C(e,l,t),h=C(l,y,t),u=C(o,h,t),u.angle=m(o,h),a&&(u.cpts=[l,y,o,h])):(l=C(n,r,t),y=C(r,i,t),u=C(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=n.x,u.y=n.y,u.angle=m(n,r))}else{let e=1-t;u=s?{x:e**3*n.x+3*e**2*t*r.x+3*e*t**2*p.x+t**3*i.x,y:e**3*n.y+3*e**2*t*r.y+3*e*t**2*p.y+t**3*i.y}:{x:e*e*n.x+2*e*t*r.x+t**2*i.x,y:e*e*n.y+2*e*t*r.y+t**2*i.y}}return u})(e,t,l):C(e[0],e[1],t,l),l&&s.angle<0&&(s.angle+=2*d),s}function L(t,l,a,n,p,i,u,y,o){const h=(e,t,l,a)=>s(a-t,l-e);let c={cx:0,cy:0,rx:a=e(a),ry:n=e(n),startAngle:0,endAngle:0,deltaAngle:0,clockwise:u,xAxisRotation:p,largeArc:i,sweep:u};if(0==a||0==n)throw Error("rx and ry can not be 0");if(a===n){let e=Math.abs(y-t),a=Math.abs(o-l),s=e,n=Math.min(t,y),r=Math.min(l,o),p=.5*Math.PI;if(0===e&&a||0===a&&e)return s=0===e&&a?a/2:e/2,c.rx=s,c.ry=s,0===e&&a?(c.cx=t,c.cy=r+a/2,c.startAngle=l>o?p:-p,c.endAngle=l>o?-p:p,c.deltaAngle=u?Math.PI:-Math.PI):0===a&&e&&(c.cx=n+e/2,c.cy=l,c.startAngle=t>y?Math.PI:0,c.endAngle=t>y?-Math.PI:Math.PI,c.deltaAngle=u?Math.PI:-Math.PI),c}let x,v,m=a===n?0:p*d/180,M=m?f(m):0,b=m?r(m):1,A=(t-y)/2,C=(l-o)/2,w=(t+y)/2,L=(l+o)/2,P=m?b*A+M*C:A,k=m?b*C-M*A:C,S=P*P/(a*a)+k*k/(n*n);S>1&&(a*=g(S),n*=g(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=g(e(($*$-E)/E));i==u&&(z=-z);let Q=z*F/n,T=-z*I/a;x=m?b*Q-M*T+w:w+Q,v=m?M*Q+b*T+L:L+T,c.cy=v,c.cx=x;let q=h(x,v,t,l),D=h(x,v,y,o);!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 P(e,t,l,s,n,p=0,i=!0,u=!1){if(n=u?n*d/180:n,p=u?p*d/180:p,p=l!==s&&p!==2*d?p:0,i&&l!==s){let e=a(v(n=p?n-p:n)*(l/s));n=r(n)<0?e+d:e}let y=e+l*r(n),o=t+s*f(n),h={x:y,y:o};return p&&(h.x=e+(y-e)*r(p)-(o-t)*f(p),h.y=t+(y-e)*f(p)+(o-t)*r(p)),h}function k(e,t=[],l=.05){let a=3===t.length,s=t[0]||null,n=a?t[1]:null,r=a?t[2]:t[1],p=.5*Math.PI,i=!1,u=!1,y=s?m(r,s,!0):null;if(i=Math.abs(y%p)<l||Math.abs(y%p-p)<l,a){let e=n?m(n,r,!0):0;u=Math.abs(e%p)<=l||Math.abs(e%p-p)<=l}return i||u}function S(e){return 4===e.length?function(e,t,l,a){let[s,n,r,p,i,u,y,o]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],h=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>=h&&t.y<=f&&l.y>=h&&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*s-12*r+6*i,g=-3*s+9*r-9*i+3*y,d=3*r-3*s):(v=6*n-12*p+6*u,g=-3*n+9*p-9*u+3*o,d=3*p-3*n),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,s,n,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,o,h,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*h+x:o-2*c+f,s=0==e?-2*y+2*h:-2*o+2*c,Math.abs(a)>1e-12&&(n=-s/(2*a),n>0&&n<1&&g.push(n));return g}(e[0],e[1],e[2])}function $(e,t){const l=(e,t,l,a,s,n)=>{var r=Math.cos(n),p=Math.sin(n),i=a*Math.cos(e),u=s*Math.sin(e);return{x:t+r*i-p*u,y:l+p*i+r*u}};let a,s,n,r,p,i=L(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:u,ry:y,cx:o,cy:h,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],P=[e.y,g.y],k=Math.min(...w),S=Math.max(...w),$=Math.min(...P),F=Math.max(...P),I=l(c-.001*x,o,h,u,y,d),E=l(c-.999*x,o,h,u,y,d);return(I.x>S||E.x>S)&&(a=l(M,o,h,u,y,d),v.push(a)),(I.x<k||E.x<k)&&(s=l(b,o,h,u,y,d),v.push(s)),(I.y<$||E.y<$)&&(r=l(C,o,h,u,y,d),v.push(r)),(I.y>F||E.y>F)&&(n=l(A,o,h,u,y,d),v.push(n)),v}function F(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function I(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,s)=>{t.push(e.slice(a,l[s+1]))}),t)}function E(e,t){let l,a,s,n,r,p,i=[],u=[],y=e[0],o=e[1],h=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=w([y,o],t),a=w([o,h],t),s=w([h,c],t),n=w([l,a],t),r=w([a,s],t),p=w([n,r],t),i.push({x:y.x,y:y.y},{x:l.x,y:l.y},{x:n.x,y:n.y},{x:p.x,y:p.y}),u.push({x:p.x,y:p.y},{x:r.x,y:r.y},{x:s.x,y:s.y},{x:c.x,y:c.y})):3===e.length?(a=w([y,o],t),s=w([o,c],t),p=w([a,s],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:s.x,y:s.y},{x:c.x,y:c.y})):2===e.length&&(a=w([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 z(e,t,l=0,a=1){let s=[],n=6===t.length?"C":"Q",r={x:t[0],y:t[1]},p="C"===n?{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),o=Math.max(i.y,e.y),h=Math.min(i.y,e.y),c=0;if(r.x<y||r.x>u||r.y<h||r.y>o||p.x<y||p.x>u||p.y<h||p.y>o){let u=S("C"===n?[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 s=[];if(!l.length)return!1;let n,r,p,i=t.length,u={x:t[i-2],y:t[i-1]};2===t.length?p=[e,u]:4===t.length?(n={x:t[0],y:t[1]},p=[e,n,u]):6===t.length&&(n={x:t[0],y:t[1]},r={x:t[2],y:t[3]},p=[e,n,r,u]);if(l.length)if(1===l.length){let e=E(p,l[0]),t=e[0],a=e[1];s.push(t,a)}else{let e=l[0],t=E(p,e),a=t[0];s.push(a),p=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=E(p,(l[t]-e)/(1-e));s.push(a[0]),t===l.length-1&&s.push(a[a.length-1]),p=a[1]}}if(a){let e,t,l=[];return s.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 s}(e,t,u);s.push(...l),c+=l.length}else s.push({type:n,values:t})}else s.push({type:n,values:t});return{pathData:s,count:c}}function Q(e,t=0,l=1){let a=[e[0]],s={x:e[0].values[0],y:e[0].values[1]},n={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=z(s,u,t,l).pathData;a.push(...e)}s={x:y[0],y:y[1]},"z"===i.toLowerCase()?s=n:"M"===i&&(n={x:y[0],y:y[1]})}return a}function T(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),s=Math.min(...l),n=Math.max(...l),r=Math.min(...a),p=Math.max(...a),i={x:s,left:s,right:n,y:r,top:r,bottom:p,width:n-s,height:p-r};if(t>-1)for(let e in i)i[e]=+i[e].toFixed(t);return i}function q(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],s=l>0?e[l-1]:e[l],{type:n,values:r}=a,p={x:s.values[s.values.length-2],y:s.values[s.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(n){case"A":if("function"!=typeof arcToBezier){let e=b(p,i)/2,l=C(p,i,.5),a=P(l.x,l.y,e,e,0),s=P(l.x,l.y,e,e,Math.PI);t.push(a,s,i);break}arcToBezier(p,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},s={x:l[2],y:l[3]},n={x:l[4],y:l[5]};t.push(a,s,n)});break;case"C":let e={x:r[2],y:r[3]};t.push(u,e);break;case"Q":t.push(u)}"z"!==n.toLowerCase()&&t.push(i)}return t}(e),l=T(t);return l}(e);t.push(l)}),t}function D(e,t){let[l,a,s,n,r,p]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[i,u,y,o,h,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return s*n!=y*o&&s*n>y*o&&l<i&&r>h&&a<u&&p>c&&(x=!0),x}function B(e,t=9){let l=0,a=[],s=I(e),n=s.length>1,r=[];if(n){let e=q(s);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){D(t,a)&&r.push(l)}}})}return s.forEach((e,t)=>{a=[];let s=0,n=0,p=1,i=[];e.forEach(function(t,l){let[n,r]=[t.type,t.values],p=r.length;if(r.length){let u=(l>0?e[l-1]:e[0]).values,y=u.length,o={x:u[y-2],y:u[y-1]},h={x:r[p-2],y:r[p-1]};if("C"===n||"Q"===n){let e={x:r[0],y:r[1]};i="C"===n?[o,e,{x:r[2],y:r[3]},h]:[o,e,h];let t=Math.abs(function(e,t=!1){let l,[a,s,n,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(s={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},n={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*s.y-n.y+3*r.y)+s.x*(2*a.y-n.y-r.y)+n.x*(a.y+s.y-2*r.y)+r.x*(-3*a.y+s.y+2*n.y))/20,t?Math.abs(l):l}(i));s+=t,a.push(o,h)}else if("A"===n){let e=L(o.x,o.y,t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],h.x,h.y),{cx:l,cy:n,rx:r,ry:p,startAngle:i,endAngle:u,deltaAngle:y}=e,c=Math.abs(function(e,t,l,a){const s=Math.PI*e*t;let n=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return s*(n/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),n=(a-l+2*Math.PI)%(2*Math.PI),s*(n/(2*Math.PI))}(r,p,i,u));c-=Math.abs(j([o,{x:l,y:n},h])),a.push(o,h),s+=c}else a.push(o,h)}});let u=j(a);-1!==r.indexOf(t)&&(p=-1),n=u<0&&s<0?(Math.abs(s)-Math.abs(u))*p:(Math.abs(s)+Math.abs(u))*p,l+=n}),l}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 N(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,s=!a&&!t,n="",r=a?"\n":s?"":" ",p=s?"":" ";n=`${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(!s||"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()&&s||"M"===l.type&&"L"===a.type&&s?" ":a.type,s){let e="",t=!1;for(let l=0,a=u.length;l<a;l++){let a=u[l],s=a.toString(),n=s.includes(".")&&Math.abs(a)<1;n&&t&&(s=s.replace(/^0\./,".")),!(l>0)||t&&n||(e+=" "),e+=s,t=n}n+=`${i}${p}${e}${r}`}else n+=`${i}${p}${u.join(" ")}${r}`}return s&&(n=n.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),n}function Z(e,t,l=0,a=1,s=!1){const n=(e,t,l,a,s)=>{let n=1-s;return{x:3*n*n*(t.x-e.x)+6*n*s*(l.x-t.x)+3*s*s*(a.x-l.x),y:3*n*n*(t.y-e.y)+6*n*s*(l.y-t.y)+3*s*s*(a.y-l.y)}};let r=[e,t],p=F(e.p0,e.p)>F(t.p0,t.p),i=JSON.parse(JSON.stringify(e)),u=JSON.parse(JSON.stringify(t)),y=M(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 o=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),h=(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=n(t.p0,t.cp1,t.cp2,t.p,0),g=c(o(e.p0,x),f)/c(f,f),v=w([t.p0,t.cp1,t.cp2,t.p],g),d=n(t.p0,t.cp1,t.cp2,t.p,g);g-=c(o(v,e.p0),d)/c(d,d);let m=w([t.p0,t.cp1,t.cp2,t.p],g),b=t.p,A=n(t.p0,t.cp1,t.cp2,t.p,g),L=n(t.p0,t.cp1,t.cp2,t.p,1),P=1-g,k=(S=m,$=h(A,P/3),{x:S.x+$.x,y:S.y+$.y});var S,$;let I=o(b,h(L,P/3)),E={p0:m,cp1:k,cp2:I,p:b};p&&(E={p0:b,cp1:I,cp2:k,p:m});let z=.5*(1-g),Q=w([E.p0,E.cp1,E.cp2,E.p],z,!1,!0),T=Q.cpts[2],q=M(Q,T,E.p0,y,!1),D=M(Q,T,E.p,y,!1),j=C(E.p0,q,1.333),Z=C(E.p,D,1.333);if(M(i.p0,j,u.p,Z,!0))return r;s&&function(e,t,l="red",a="1%",s="1",n="",r=!0,p="",i=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let u=`<circle class="${i}" opacity="${s}" id="${p}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${n}</title></circle>`;if(!r)return u;e.insertAdjacentHTML("beforeend",u)}(markers,Q,"purple"),E.cp1=j,E.cp2=Z;let O=F(i.p0,E.p0)+F(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(F(w([E.p0,E.cp1,E.cp2,E.p],t),e.p)>l*a)return r;let n=B([{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]}],o=B(y),h=Math.abs(o/n-1);if(E.error=5*h*a,s){let e=N(y);!function(e,t="",l="green",a="1%",s=!0){let n=`<path d="${t}" fill="none" stroke="${l}" stroke-width="${a}" /> `;if(!s)return n;e.insertAdjacentHTML("beforeend",n)}(markers,e,"orange")}h<.05*a&&(r=[E])}return r}function O(e,t,l=!1,a=1){let s=[e,t],n=function(e,t){let l=b(e.cp2,e.p),a=b(e.cp2,t.cp1),s=Math.min(l)/a;return s}(e,t),r=F(e.p0,e.p),p=F(t.p0,t.p),i=.05*Math.min(r,p)*a,u=function(e,t,l=0,a=0){let{p0:s,cp1:n}=e,{p:r,cp2:p}=t,i={x:(n.x-(1-l)*s.x)/l,y:(n.y-(1-l)*s.y)/l},u={x:(p.x-a*r.x)/(1-a),y:(p.y-a*r.y)/(1-a)},y={p0:s,cp1:i,cp2:u,p:r};return y}(e,t,n,n),y=w([u.p0,u.cp1,u.cp2,u.p],n),o=F(e.p,y),h=0,c=0,x=!1,f=o;if(o<i){let l=.5*(1+n);if(h=F(w([t.p0,t.cp1,t.cp2,t.p],.5),w([u.p0,u.cp1,u.cp2,u.p],l)),f+=h,h<i){let t=.5*n;c=F(w([e.p0,e.cp1,e.cp2,e.p],.5),w([u.p0,u.cp1,u.cp2,u.p],t)),h+c<i&&(x=!0),f+=c}}if(l&&!x){let l=Z(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=F(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,s=[u]),s}function H(e,t,l){let a=!1,s=2===t.length,n=t[0],r=s?t[1]:n;if(e.x===n.x&&e.y===n.y&&l.x===r.x&&l.y===r.y)return!0;let p=n.x-e.x,i=n.y-e.y,u=l.x-r.x,y=l.y-r.y;if(!Math.abs(p*y-i*u))return!0;let o=l.x-e.x,h=l.y-e.y;return!Math.abs(o*i-h*p)||(a=j([e,...t,l],!0)<A(e,l)/200,a)}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:s}=e;if(s.length){let e=s.length>1?{x:s[s.length-2],y:s[s.length-1]}:"V"===a?{x:l.x,y:s[0]}:{x:s[0],y:l.y};t.push(e),l=e}}),t}(e),s=T(a),{left:n,right:r,top:p,bottom:i,width:u,height:y}=s,o=e[0].values[0],h=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:s,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,C,w,L,P=.05;t=y.length?{x:y[0],y:y[1]}:c,"M"===s?(c=t,x=t):"z"===s.toLowerCase()&&(t=c),a.p0=x,a.p=t;let S=F(x,t);a.dimA=S,"L"===s&&(a.lineto=!0),"Z"===s&&(a.closePath=!0,c.x!==o&&c.y!==h&&(a.lineto=!0)),"Q"!==s&&"C"!==s||(d={x:u[0],y:u[1]},M="C"===s?{x:u[2],y:u[3]}:null,a.cp1=d,M&&(a.cp2=M)),u.length>2&&("Q"!==s&&"C"!==s||v.push(d),"C"===s&&v.push(M),v.push(t)),"L"===s||t.x!==n&&t.y!==p&&t.x!==r&&t.y!==i||(a.extreme=!0);let $=e[l]?e[l]:null,I=$?$.values.slice(-2):null;w=$?$.type:null,!$||"Q"!==$.type&&"C"!==$.type||(C=$?{x:I[0],y:I[1]}:null,b={x:$.values[0],y:$.values[1]},"C"===$.type&&($.values[2],$.values[3])),L=j(v);let E=g<0&&L>0||g>0&&L<0;if(g=L,E&&(a.directionChange=!0),("Q"===s||"C"===s)&&("Q"===s&&"Q"===w||"C"===s&&"C"===w)){let e=v.slice(1);if(C&&Math.abs(C.x-x.x),C&&Math.abs(C.y-x.y),!!a.extreme||k(0,e,P))a.extreme=!0;else{let e=M?[M,t]:[d,t],l=[t,b],s=m(...e,!0),n=m(...l,!0),r=180*Math.abs(s-n)/Math.PI,p=A(...e),i=A(...l);r>10&&p&&i&&(a.corner=!0)}}f.push(a),x=t}return l={pathData:f,bb:s,dimA:(u+y)/2},l}function U(e,t=-1){let l=!("auto"!=t||!e[0].hasOwnProperty("decimals"));for(let a=0,s=e.length;a<s;a++){let s=e[a];(t>-1||l)&&(t=l?s.decimals:t,e[a].values=s.values.map(e=>e?+e.toFixed(t):e))}return e}function V(e={},t={},l={},a={}){let s=C(e,t,1.5),n=C(a,l,1.5),r=.01*F(e,a),p=F(s,n),i=null,u={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return p<r&&(i=M(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 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?Y(e,t):e;let s={type:"M",values:e[0].values};e[0].decimals&&(s.decimals=e[0].decimals);let n,r=[s],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,o=y.slice(-2),h=e[l-1],c=h.type;n={x:o[0],y:o[1]};let x,f,g,v,d={x:y[0],y:y[1]},m=Math.abs(n.x-p.x),M=Math.abs(n.y-p.y),b=(m+M)/2*i;switch(u){case"L":s=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:o[0],y:o[1]},r.push(a);continue}let e={x:h.values[0],y:h.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,s=g<b?{type:"T",values:[n.x,n.y]}:a;break;case"C":let t={x:y[2],y:y[3]};if("C"!==c){r.push(a),p={x:o[0],y:o[1]};continue}let l={x:h.values[2],y:h.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,s=g<b?{type:"S",values:[t.x,t.y,n.x,n.y]}:a;break;default:s={type:u,values:y}}(a.decimals||0===a.decimals)&&(s.decimals=a.decimals),t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),p={x:o[0],y:o[1]},r.push(s)}return r}(e)),e=U(e,a),l&&(e=function(e,t=-1){return X(e,!0,t)}(e)),a>-1&&(e=U(e,a)),e}function W(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 X(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e[0].values,s=a[0],n=a[1],r=s,p=n;for(let a=1,i=e.length;a<i;a++){let i=e[a],{type:u,values:y}=i,o=t?u.toLowerCase():u.toUpperCase();if(u!==o)switch(u=o,i.type=u,u){case"a":case"A":y[5]=t?y[5]-s:y[5]+s,y[6]=t?y[6]-n:y[6]+n;break;case"v":case"V":y[0]=t?y[0]-n:y[0]+n;break;case"h":case"H":y[0]=t?y[0]-s:y[0]+s;break;case"m":case"M":t?(y[0]-=s,y[1]-=n):(y[0]+=s,y[1]+=n),r=t?y[0]+s:y[0],p=t?y[1]+n:y[1];break;default:if(y.length)for(let e=0;e<y.length;e++)y[e]=t?y[e]-(e%2?n:s):y[e]+(e%2?n:s)}let h=y.length;switch(u){case"z":case"Z":s=r,n=p;break;case"h":case"H":s=t?s+y[0]:y[0];break;case"v":case"V":n=t?n+y[0]:y[0];break;case"m":case"M":r=y[h-2]+(t?s:0),p=y[h-1]+(t?n:0);default:s=y[h-2]+(t?s:0),n=y[h-1]+(t?n:0)}l>=0&&(i.values=i.values.map(e=>+e.toFixed(l)))}return e}function Y(e,t=-1){return X(e,!1,t)}function G(e,t,l=1){const a=2*Math.PI;let[s,n,r,p,i,u,y]=t;if(0===s||0===n)return[];let o=r?r*a/360:0,h=o?Math.sin(o):0,c=o?Math.cos(o):1,x=c*(e.x-u)/2+h*(e.y-y)/2,f=-h*(e.x-u)/2+c*(e.y-y)/2;if(0===x&&0===f)return[];s=Math.abs(s),n=Math.abs(n);let g=x*x/(s*s)+f*f/(n*n);if(g>1){let e=Math.sqrt(g);s*=e,n*=e}let v=s*s,d=s===n?v:n*n,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*s/n*f:0,C=b?b*-n/s*x:0,w=c*A-h*C+(e.x+u)/2,L=h*A+c*C+(e.y+y)/2,P=(x-A)/s,k=(f-C)/n,S=(-x-A)/s,$=(-f-C)/n;const F=(e,t,l,a)=>{let s=+(e*l+t*a).toFixed(9);return 1===s||-1===s?1===s?0:Math.PI:(s=s>1?1:s<-1?-1:s,(e*a-t*l<0?-1:1)*Math.acos(s))};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,s)=>{let n=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):s,p=Math.cos(e+t),i=Math.sin(e+t);return[{x:n-r*l,y:r+n*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*s,a=t.y*n;e.values.push(c*l-h*a+w,h*l+c*a+L)}),Q.push(e),I+=E}return Q}function K(e,t,l,a,s=7.5){let n={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=M(e,t,a,l,!1);if(i){let u=b(e,i),y=b(a,i),o=+Math.max(u,y).toFixed(8),h=+Math.min(u,y).toFixed(8),c=h,x=o,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=o,x=c),g&&(c=o,x=h);let v=B([{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,i])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<s&&(p=!0,n=d)}}return{com:n,isArc:p,area:r}}function _(e){let t,l=[[]],a=0,s=[[]],n={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);n={x:i[0],y:i[1]};let[y,o,h,c,x,f,g]=u,v=100/y*Math.abs(y-o)<5;t={x:u[5],y:u[6]},p.p0=n,p.p=t,p.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(p),s[a].push(r)),d&&"A"===d.type){let[e,p,i,u,h,c,x]=d.values,f=y!=e?100/y*Math.abs(y-e):0,g=o!=p?100/o*Math.abs(o-p):0;t={x:d.values[5],y:d.values[6]},d.p0=n,d.p=t,f<5&&g<5?(l[a].push(d),s[a].push(r+1)):(l.push([]),s.push([]),a++)}else l.push([]),s.push([]),a++}}if(!s.length)return e;l=l.filter(e=>e.length),s=s.filter(e=>e.length);for(let t=l.length-1;t>=0;t--){const a=l[t],n=s[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[n-1].values.slice(-2);if(y[0],y[1],4===r){let[t,l,s,y,o,h,c]=a[1].values,[,,,,,x,f]=a[3].values;u&&(p=1,i=1);let g={type:"A",values:[p,i,s,y,o,h,c]},v={type:"A",values:[p,i,s,y,o,x,f]};e.splice(n,r,g,v)}else if(3===r){let[t,l,s,u,y,o,h]=a[0].values,[c,x,,,,f,g]=a[2].values;u=1;let v={type:"A",values:[p,i,s,u,y,f,g]};e.splice(n,r,v)}else if(2===r){let[t,l,s,y,o,h,c]=a[0].values,[x,f,,,,g,v]=a[1].values;u&&(p=1,i=1,s=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,s,y,o,g,v]};e.splice(n,r,t)}}}return e}function ee(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:s=!1,arcAccuracy:n=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&&s)&&(l=!0,t=!0),r&&t&&(e=X(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 s=[],n={type:"M",values:(e=l&&a?Y(e,t):e)[0].values};s.push(n);for(let l=1,a=e.length;l<a;l++){let a,r,p,i,u,y,o,h,c=e[l],{type:x,values:f}=c,g=f.length,v=n.values,d=v.length,[m,M]=[f[g-2],f[g-1]],[b,A]=[v[d-2],v[d-1]];switch(x){case"H":n={type:"L",values:[f[0],A]};break;case"V":n={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),n={type:"Q",values:[p,i,m,M]};break;case"S":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],[o,h]=d>2&&"A"!==n.type?[v[2],v[3]]:[b,A],p=2*b-o,i=2*A-h,u=f[0],y=f[1],n={type:"C",values:[p,i,u,y,m,M]};break;default:n={type:x,values:f}}t>-1&&(n.values=n.values.map(e=>+e.toFixed(t))),s.push(n)}return s}(e,-1,!1)),u&&s&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,s=e.length;a<s;a++){let s=e[a],n=e[a-1].values,r=n.length,p={x:n[r-2],y:n[r-1]};"A"===s.type?G(p,s.values,t).forEach(e=>{l.push(e)}):l.push(s)}return l}(e,n)),i&&a&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],s=e[l-1].values,n=s.length,r={x:s[n-2],y:s[n-1]};"Q"===a.type?t.push(W(r,a.values)):t.push(a)}return t}(e)),e}function te(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:s=!1,arcAccuracy:n=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 s,n=0,r=e.length,p="",i=[],u=-1,y="",o=!1,h=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?h>0:""!==y)&&(t&&-1===u&&(s="Pathdata must start with M command",v.push(s),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]&&(s=`${u}. command: Leading zeros not valid: ${y}`,v.push(s)),i[u].values.push(+y)),c++,y="",h=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){s=`${u}. command of type "${p}": ${x-e} values too few - ${x} expected`,v[v.length-1]!==s&&v.push(s)}}};let A=!1,C=!1,w=!1;for(;n<r;){let l=e.charCodeAt(n),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(o||45!==l&&46!==l)d();else{let e=46===l;m(e),d(),e&&h++}y+=e[n],o=A,n++}else if((l<48||l>5759)&&a(l))m(),n++;else{if(l>64){if(!le.has(l)){s=`${u}. command "${e[n]}" is not a valid type`,v.push(s),n++;continue}""!==y&&(i[u].values.push(+y),c++,y=""),t&&b(),p=e[n],x=ae[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++,h=0,c=0,f=!1,n++;continue}r||(s=`${u}. ${e[n]} is not a valid separarator or token`,v.push(s),y=""),n++}}m(),t&&b();if(t&&v.length){if(s="Invalid path data:\n"+v.join("\n"),"log"!==t)throw new Error(s);console.log(s)}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,o=r.pathData;return o=ee(o,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:s,arcAccuracy:n},{hasRelatives:p,hasShorthands:i,hasQuadratics:u,hasArcs:y}),o}const le=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),ae=new Uint8Array(128);function se(e){if("path"===e.nodeName.toLowerCase())return e;let t=function(e,t=!1){let l,a,s,n,r,p,i,u,y,o,h,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 s,n=parseFloat(e);if(!a)return n;switch(a){case"in":s=l;break;case"pt":s=1/72*96;break;case"cm":s=1/2.54*96;break;case"mm":s=1/2.54*96/10;break;case"em":case"rem":s=16;break;default:s=1}return+(n*s).toFixed(t)};let s=l.getAttribute("width");s=s?a(s):300;let n=l.getAttribute("height");n=s?a(n):150;let r=l.getAttribute("viewBox");r=r?r.replace(/,/g," ").split(" ").filter(Boolean).map(e=>+e):[];let p=r.length?r[2]:s,i=r.length?r[3]:n,u=p/100,y=i/100,o=Math.sqrt((Math.pow(u,2)+Math.pow(y,2))/2),h=["x","width","x1","x2","rx","cx","r"],c=["y","height","y1","y2","ry","cy"];e.getAttributeNames().forEach(t=>{let l=e.getAttribute(t),s=l;if(h.includes(t)||c.includes(t)){let n=h.includes(t)?u:y;n="r"===t&&p!=i?o:n;let r=l.match(/([a-z|%]+)/gi);r=r?r[0]:"",s=l.includes("%")?parseFloat(l)*n:a(l),e.setAttribute(t,+s)}})};M(e);const b=t=>(l={},t.forEach(t=>{l[t]=+e.getAttribute(t)}),l);switch(m){case"path":s=e.getAttribute("d"),d=te(s);break;case"rect":a=["x","y","width","height","rx","ry"],({x:n,y:r,width:p,height:i,rx:y,ry:o}=b(a)),y||o?(y>p/2&&(y=p/2),o>i/2&&(o=i/2),d=[{type:"M",values:[n+y,r]},{type:"L",values:[n+p-y,r]},{type:"A",values:[y,o,0,0,1,n+p,r+o]},{type:"L",values:[n+p,r+i-o]},{type:"A",values:[y,o,0,0,1,n+p-y,r+i]},{type:"L",values:[n+y,r+i]},{type:"A",values:[y,o,0,0,1,n,r+i-o]},{type:"L",values:[n,r+o]},{type:"A",values:[y,o,0,0,1,n+y,r]},{type:"Z",values:[]}]):d=[{type:"M",values:[n,r]},{type:"L",values:[n+p,r]},{type:"L",values:[n+p,r+i]},{type:"L",values:[n,r+i]},{type:"Z",values:[]}];break;case"circle":case"ellipse":a=["cx","cy","rx","ry","r"],({cx:h,cy:c,r:u,rx:y,ry:o}=b(a)),"circle"===m?(y=u,o=u):(y=y||u,o=o||u),d=[{type:"M",values:[h+y,c]},{type:"A",values:[y,o,0,1,1,h-y,c]},{type:"A",values:[y,o,0,1,1,h+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),s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",l);let n=["x","y","cx","cy","dx","dy","r","rx","ry","width","height","points"];return a.forEach(t=>{if(!n.includes(t)){let l=e.getAttribute(t);s.setAttribute(t,l)}}),s}function ne(e,t=1,l=!0){let a=[e[0]],s={x:e[0].values[0],y:e[0].values[1]},n=s,r=s;e[e.length-1].type.toLowerCase();for(let p=1,i=e.length;p<i;p++){let u=e[p-1],y=e[p],o=e[p+1]||e[i-1],h="z"===o.type.toLowerCase()?s:{x:o.values[o.values.length-2],y:o.values[o.values.length-1]},{type:c,values:x}=y,f=x.slice(-2);r="Z"!==c?{x:f[0],y:f[1]}:s;let g=j([n,r,h],!0);A(n,r),A(r,h);let v=g<A(n,h)/200*t,d=!1;if(l||"C"!==c||(v=!1),l&&("C"===c||"Q"===c)){d=H(n,"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)}n=r,v&&p<i-1&&("L"===c||l&&d)||("M"===c?(s=r,n=s):"Z"===c&&(n=s),a.push(y))}return a}function re(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let s=1,n=e.length;s<n;s++){let n=e[s],{type:r,values:p}=n,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(n),t=l}}return a}function pe(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:s,values:n}=t,r=n.length;if(r){let e={type:s,x:n[r-2],y:n[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 ie(e,t=!0,l=!0){let a=[],s=e.length,n={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},r="z"===e[s-1].type.toLowerCase(),p=e.filter(e=>"L"===e.type),i=e[s-2],u=i.type,y=i.values.slice(-2).map(e=>+e.toFixed(8)),o=y[0]===n.x&&y[1]===n.y,h="L"!==e[1].type&&(!o||"L"===u);if(h=!1,!r)return e;let c=0;{let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l],{type:s,values:n}=a;if(n.length){let a=n.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:s,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?ue(e,c):e}return n={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(7)},s=e.length,i=e[s-2],u=i.type,y=i.values.slice(-2).map(e=>+e.toFixed(8)),o="L"===u&&y[0]===n.x&&y[1]===n.y,t&&o&&e.splice(s-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 s=a?1:0;!function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[s,n]=[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||s==i&&n==u||(e.pop(),e.push({type:"L",values:[s,n]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-s;let n,r,p=e.slice(l),i=e.slice(0,l);return i.shift(),n=i[i.length-1].values||[],r=[n[n.length-2],n[n.length-1]],s&&(p.pop(),i.push({type:"Z",values:[]})),e=[{type:"M",values:r},...p,...i]}function ye(e,{arcToCubic:t=!1,quadraticToCubic:l=!1,toClockwise:a=!1,returnD:s=!1}={}){const n=(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,s]=[l.values[0],l.values[1]],n=t?e[e.length-2]:e[e.length-1],[r,p]=[n.values[n.values.length-2],n.values[n.values.length-1]];return!t||a==r&&s==p||(e.pop(),e.push({type:"L",values:[a,s]},{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,s=l.values,p=e[t-1],i=p.type,u=[];u=[n(i,p.values).controlPoints,n(a,s).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,s=-1/0;const n=e=>{e.x<t&&(t=e.x),e.x>l&&(l=e.x),e.y<a&&(a=e.y),e.y>s&&(s=e.y)};for(let t=0;t<e.length;t++){let l=e[t],{type:a,values:s}=l,r=s.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:s[r-2],y:s[r-1]};if(n(t),"C"===a||"Q"===a){let l={x:s[0],y:s[1]},r="C"===a?{x:s[2],y:s[3]}:l,p="C"===a?[e,l,r,t]:[e,l,t];S(p).forEach(e=>{let t=w(p,e);n(t)})}else"A"===a&&$(e,s).forEach(e=>{n(e)})}}return{x:t,y:a,width:l-t,height:s-a}}(e);t=(l.width+l.height)/2*.05}let a=e.length;for(let s=0;s<a;s++){let a=e[s],{type:n,values:r,extreme:p,corner:i=!1,dimA:u,p0:y,p:o}=a,h=e[s+1]?e[s+1]:null;if(h&&"C"===n&&"C"===h.type&&p&&!i){if(F(o,h.p)<t){let n,r=a.cp1.x-h.p0.x,p=a.cp1.y-h.p0.y,i=Math.abs(p)<Math.abs(r),u=h.p,y=1;if(h.extreme){i?(y=Math.abs(Math.abs(h.cp2.x-h.p.x)/Math.abs(a.cp2.x-a.p.x)),n=C(h.p,a.cp2,1+y),a.cp2.x=n.x):(y=Math.abs(Math.abs(h.cp2.y-h.p.y)/Math.abs(a.cp2.y-a.p.y)),n=C(h.p,a.cp2,1+y),a.cp2.y=n.y),e[s+1].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,u.x,u.y],e[s+1].cp1=a.cp1,e[s+1].cp2=a.cp2,e[s+1].p0=a.p0,e[s+1].p=u,e[s+1].extreme=!0,e[s]=null;continue}{let a=e[s+2]?e[s+2]:null;if(!a&&"C"!==a.type)continue;let n=Z(h,a,t,l,!1);if(1===n.length){e[s+1]=null,n=n[0],e[s+2].values=[n.cp1.x,n.cp1.y,n.cp2.x,n.cp2.y,n.p.x,n.p.y],e[s+2].cp1=n.cp1,e[s+2].cp2=n.cp2,e[s+2].p0=n.p0,e[s+2].p=n.p,e[s+2].extreme=n.extreme,s++;continue}}}}}a=(e=e.filter(Boolean)).length;let s="z"===e[a-1].type.toLowerCase()?a-2:a-1,n=e[s],r=e[s-1]||null,p={x:e[0].values[0],y:e[0].values[1]},i=n.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,o=F(n.p0,n.p)<t;if(r&&"C"===r.type&&o&&u&&y){Math.abs(y.cp1.x-p.x),Math.abs(y.cp1.y-p.y);let a=Z(r,n,t,l,!1);console.log("comEx",a),1===a.length&&(e[s-1]=a[0],e[s]=null,e=e.filter(Boolean))}return e}function he(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 ce(e="",{getObject:t=!1,toAbsolute:l=!0,toRelative:a=!0,toShorthands:s=!0,quadraticToCubic:n=!0,arcToCubic:r=!1,cubicToArc:p=!1,simplifyBezier:i=!0,optimizeOrder:u=!0,removeColinear:y=!0,flatBezierToLinetos:o=!0,revertToQuadratics:h=!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"),s=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(s)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),E="",z=0,T=0,q=0,D={},B="",j="svgMarkup"===$?1:0,Z=[];if(z=new Blob([e]).size,j){if(E=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 s=(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)})}(s,["viewBox","xmlns","width","height","id","class","fill","stroke","stroke-width"]);let n=["metadata","script"];if(s.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",s=!!a&&a.trim().includes("display:none"),r=e.getAttribute("display")&&"none"===e.getAttribute("display")||s;t.includes(":")||n.includes(t)||l&&r?e.remove():function(e){[...e.attributes].map(e=>e.name).forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t)return s;let r=he(s);return console.log(r),r}(e,{returnDom:!0,removeHidden:P,removeUnused:k}),S){E.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=se(e);e.replaceWith(t)})}E.querySelectorAll("path").forEach(e=>{Z.push({d:e.getAttribute("d"),el:e})})}else"pathDataString"===$?B=e:"polyString"===$&&(B="M"+e),Z.push({d:B,el:null});let O={toRelative:a,toShorthands:s,decimals:M},H=[];if(Z.forEach(e=>{let{d:t,el:a}=e,s=te(t,{quadraticToCubic:n,toAbsolute:l,arcToCubic:r}),P=s.length,k=s;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:s=[]}=l,n=e[t+1]?e[t+1]:null;"M"!==a&&"m"!==a||n&&(!n||"Z"!==n.type&&"z"!==n.type)||(e[t]=null,e[t+1]=null)}return e.filter(Boolean)}(k));let S=I(k),$=[];for(let e=0,t=S.length;e<t;e++){let t=S[e];w&&(t=ye(t)),y&&(t=re(t)),d&&(t=Q(t,0,1)),u&&(t=pe(t)),y&&(t=ne(t,C,o));let l=R(t),{pathData:a,bb:s,dimA:n}=l;if(a=i?xe(a,{simplifyBezier:i,keepInflections:v,keepExtremes:x,keepCorners:f,extrapolateDominant:g,revertToQuadratics:h,tolerance:C,reverse:w}):a,c){let e=(s.width+s.height)/2*.05;a=oe(a,{threshold:e,tolerance:C})}if(p){let e=3;a.forEach((t,l)=>{let{type:s,values:n,p0:r,cp1:p=null,cp2:i=null,p:u=null}=t;if("C"===s){let t=K(r,p,i,u,e);t.isArc&&(a[l]=t.com)}}),a=_(a)}h&&a.forEach((e,t)=>{let{type:l,values:s,p0:n,cp1:r=null,cp2:p=null,p:i=null}=e;if("C"===l){let l=V(n,r,p,i);"Q"===l.type&&(l.extreme=e.extreme,l.corner=e.corner,l.dimA=e.dimA,a[t]=l)}}),u&&(a=ie(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 s=new Set;for(let n=0,r=e.length;n<r;n++){let r=e[n],{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?+F(l,a).toFixed(8):0;y&&s.add(y),"M"===p&&(t=a),l=a}let n=Array.from(s).sort(),r=Math.ceil(n.length/10);n=n.slice(0,r);let p=n.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=J(k,O),k=re(k);let t=k.length,l=N(k,A);T=new Blob([l]).size,q=+(100/z*T).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=J(H,O);e=re(e);let t=N(e,A);Z[0].el.setAttribute("d",t);for(let e=1;e<Z.length;e++){let t=Z[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(E)}E=he(E),T=new Blob([E]).size,q=+(100/z*T).toFixed(2),z=+(z/1024).toFixed(3),T=+(T/1024).toFixed(3),D={svgSize:z,svgSizeOpt:T,compression:q}}else({d:B,report:D}=Z[0]);return t?{svg:E,d:B,report:D,inputType:$,mode:j}:B||E}function xe(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:s=!0,tolerance:n=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,o=y?.type||null,h=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"===o)if(l&&c||a&&b||!h&&t&&M)p.push(u);else{let o=O(u,y,s,n),h=0;if(1===o.length){u=o[0];let y=1;h+=u.error;for(let p=r+1;h<n&&p<i;p++){let r=e[p];if("C"!==r.type||l&&r.directionChange||a&&u.corner||t&&u.extreme)break;let i=O(u,r,s,n);1===i.length&&(h+=.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=ye(p)),p}ae[77]=2,ae[109]=2,ae[65]=7,ae[97]=7,ae[67]=6,ae[99]=6,ae[76]=2,ae[108]=2,ae[81]=4,ae[113]=4,ae[83]=4,ae[115]=4,ae[84]=2,ae[116]=2,ae[72]=1,ae[104]=1,ae[86]=1,ae[118]=1,ae[90]=0,ae[122]=0;const{abs:fe,acos:ge,asin:ve,atan:de,atan2:me,ceil:Me,cos:be,exp:Ae,floor:Ce,log:we,hypot:Le,max:Pe,min:ke,pow:Se,random:$e,round:Fe,sin:Ie,sqrt:Ee,tan:ze,PI:Qe}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=ce),exports.PI=Qe,exports.abs=fe,exports.acos=ge,exports.asin=ve,exports.atan=de,exports.atan2=me,exports.ceil=Me,exports.cos=be,exports.exp=Ae,exports.floor=Ce,exports.hypot=Le,exports.log=we,exports.max=Pe,exports.min=ke,exports.pow=Se,exports.random=$e,exports.round=Fe,exports.sin=Ie,exports.sqrt=Ee,exports.svgPathSimplify=ce,exports.tan=ze;
|
package/index.html
CHANGED
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
<body class="enhance-inputs-init --scrollbar --scroll-content pdd-0 mrg-0"
|
|
45
45
|
data-enhance-inputs='{"storageName":"svgPathSimplify", "getQuery":true, "cacheToStorage":true,"icons":"all"}'>
|
|
46
46
|
|
|
47
|
-
<div class="grd-main hgh-100vh grd grd-md-3 grd-ld-5 gap-
|
|
47
|
+
<div class="grd-main hgh-100vh grd grd-md-3 grd-ld-5 gap-0">
|
|
48
48
|
<div class="sidebar-wrap scrollbar scroll-content scroll-track">
|
|
49
49
|
|
|
50
50
|
<!--toolbars-->
|
|
51
51
|
<aside class="aside aside-1 hgh-100 aside scrollbar scroll-content-ld scroll-track pdd-1em pos-rlt">
|
|
52
52
|
|
|
53
53
|
<h1>Simplify pathdata</h1>
|
|
54
|
-
<p>Enter your SVG pathData
|
|
54
|
+
<p>Enter your SVG pathData or complete file markup.</p>
|
|
55
55
|
|
|
56
56
|
<p><input type="file" class="dsp-non --btn-neg" id="inputFile" name="svgFile" value="upload"
|
|
57
57
|
data-label="Upload file" accept=".svg"></p>
|
|
@@ -67,13 +67,19 @@
|
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
<label>Input SVG
|
|
70
|
-
<textarea name="dInput" id="inputSvg" data-tools="size upload copy"
|
|
70
|
+
<textarea name="dInput" id="inputSvg" data-tools="size upload copy">m71.72 20.83 0 0c-1.76 .59-3.69 .97-5.79 1.15s-4.68 .26-7.73 .26c5.45 2.46 8.16 6.35 8.16 11.67 0 4.62-1.58 8.39-4.73 11.32s-7.46 4.39-12.9 4.39c-2.11 0-4.07-.3-5.88-.88-.71 .47-1.26 1.1-1.67 1.89s-.61 1.59-.61 2.41c0 2.52 2.02 3.77 6.05 3.77h7.37c3.1 0 5.85 .56 8.25 1.67s4.26 2.64 5.57 4.56 1.98 4.13 1.98 6.59c0 4.5-1.84 7.97-5.53 10.39s-9.07 3.65-16.14 3.65c-4.98 0-8.91-.52-11.81-1.54s-4.95-2.56-6.18-4.61-1.85-4.68-1.85-7.89h5.54 1.75c0 1.87 .35 3.34 1.05 4.43 .7 1.08 1.96 1.9 3.77 2.46s4.39 .83 7.73 .83c4.85 0 8.32-.6 10.39-1.8s3.12-3 3.12-5.4c0-2.16-.82-3.8-2.46-4.91s-3.92-1.67-6.85-1.67h-7.28c-3.92 0-6.89-.83-8.91-2.5s-3.02-3.76-3.02-6.27c0-1.53 .44-2.99 1.31-4.39s2.14-2.66 3.78-3.77c-2.69-1.41-4.67-3.15-5.92-5.23s-1.89-4.6-1.89-7.58c0-3.11 .77-5.89 2.32-8.34s3.69-4.38 6.41-5.75 5.75-2.06 9.08-2.06c3.63 .06 6.67-.08 9.13-.4s4.48-.76 6.1-1.31 3.58-1.36 5.92-2.42l0.88 2.71 .88 2.7 .61 1.87zm-30.58 5.49c-1.67 1.9-2.51 4.4-2.51 7.5 0 3.16 .85 5.69 2.55 7.59s4.1 2.85 7.2 2.85 5.57-.92 7.24-2.76 2.5-4.43 2.5-7.76c0-6.85-3.31-10.27-9.92-10.27-3.04 0-5.4 .95-7.06 2.85z
|
|
71
|
+
</textarea>
|
|
71
72
|
</label>
|
|
72
73
|
|
|
73
74
|
<h3>SVG normalization</h3>
|
|
74
75
|
<p>
|
|
75
76
|
<label><input type="checkbox" name="arcToCubic">arcToCubic</label>
|
|
76
77
|
<label><input type="checkbox" name="quadraticToCubic" checked>quadraticToCubic</label>
|
|
78
|
+
<label><input type="checkbox" name="removeHidden" checked>removeHidden</label>
|
|
79
|
+
<label><input type="checkbox" name="mergePaths" >mergePaths</label>
|
|
80
|
+
<label><input type="checkbox" name="shapesToPaths" data-info="convert shapes like circles, rects to path elements">shapesToPaths</label>
|
|
81
|
+
|
|
82
|
+
|
|
77
83
|
</p>
|
|
78
84
|
|
|
79
85
|
|
|
@@ -107,7 +113,6 @@
|
|
|
107
113
|
<label><input type="checkbox" name="cubicToArc"
|
|
108
114
|
data-info="Reverts cubic to arcs if applicable">cubicToArc</label>
|
|
109
115
|
|
|
110
|
-
|
|
111
116
|
<!--
|
|
112
117
|
<label><input type="checkbox" name="reverse">try with reversed drawing direction</label>
|
|
113
118
|
|
|
@@ -116,7 +121,10 @@
|
|
|
116
121
|
-->
|
|
117
122
|
|
|
118
123
|
|
|
119
|
-
|
|
124
|
+
|
|
125
|
+
<label><input type="checkbox" name="removeOrphanSubpaths" data-info="remove orphaned M commands not connecting to lines or curve segments" checked>removeOrphanSubpaths</label>
|
|
126
|
+
<label><input type="checkbox" name="refineExtremes">refineExtremes</label>
|
|
127
|
+
<label><input type="checkbox" name="addExtremes">addExtremes</label>
|
|
120
128
|
|
|
121
129
|
|
|
122
130
|
|
|
@@ -155,7 +163,7 @@
|
|
|
155
163
|
<p>
|
|
156
164
|
<label>Output SVG
|
|
157
165
|
<textarea name="dOutput" id="outputSvg"
|
|
158
|
-
data-tools="size upload copy"
|
|
166
|
+
data-tools="size upload copy"></textarea>
|
|
159
167
|
</label>
|
|
160
168
|
</p>
|
|
161
169
|
|
|
@@ -167,9 +175,9 @@
|
|
|
167
175
|
<!--main-->
|
|
168
176
|
<main class="main --spn-ld-2 --spn-ld-3 scrollbar scroll-content pst-rlt">
|
|
169
177
|
|
|
170
|
-
<header class="pst-sticky --pdd-1em z-ind-1000">
|
|
178
|
+
<header class="pst-sticky --pdd-1em z-ind-1000 pdd-1em">
|
|
171
179
|
<label class="navToggle"><input type="checkbox" name="showNav" class="showNav"
|
|
172
|
-
data-icon="adjustments-vertical"
|
|
180
|
+
data-icon="adjustments-vertical" checked title="show settings"></label>
|
|
173
181
|
|
|
174
182
|
<a class="lnk-github" href="https://github.com/herrstrietzel/svg-path-simplify"
|
|
175
183
|
title="See github repository">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svg-path-simplify",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"main": "./dist/svg-path-simplify.node.js",
|
|
5
5
|
"module": "./dist/svg-path-simplify.esm.js",
|
|
6
6
|
"browser": "./dist/svg-path-simplify.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "rollup -c",
|
|
23
23
|
"watch": "rollup -c --watch",
|
|
24
|
-
"test": "node
|
|
24
|
+
"test": "node testSVG.js"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@rollup/plugin-terser": "^0.4.4",
|
|
@@ -31,12 +31,15 @@
|
|
|
31
31
|
"keywords": [
|
|
32
32
|
"bezier-simplification",
|
|
33
33
|
"svg-minification",
|
|
34
|
-
"simplification"
|
|
34
|
+
"simplification",
|
|
35
|
+
"svg"
|
|
35
36
|
],
|
|
36
37
|
"author": "herrstrietzel",
|
|
37
38
|
"license": "GPL-2.0",
|
|
38
39
|
"description": "Simplify Bézier paths while maintaining their shape",
|
|
39
40
|
"dependencies": {
|
|
41
|
+
"linkedom": "^0.18.12",
|
|
42
|
+
"svg-path-simplify": "^0.0.5",
|
|
40
43
|
"terser": "^5.43.1"
|
|
41
44
|
},
|
|
42
45
|
"bugs": {
|
package/src/detect_input.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export function detectInputType(input) {
|
|
2
2
|
let type = 'string';
|
|
3
|
+
/*
|
|
3
4
|
if (input instanceof HTMLImageElement) return "img";
|
|
4
5
|
if (input instanceof SVGElement) return "svg";
|
|
5
6
|
if (input instanceof HTMLCanvasElement) return "canvas";
|
|
6
7
|
if (input instanceof File) return "file";
|
|
7
8
|
if (input instanceof ArrayBuffer) return "buffer";
|
|
8
9
|
if (input instanceof Blob) return "blob";
|
|
10
|
+
*/
|
|
9
11
|
if (Array.isArray(input)) return "array";
|
|
10
12
|
|
|
11
13
|
if (typeof input === "string") {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// dom-polyfill.js
|
|
2
|
+
import { DOMParser } from 'linkedom';
|
|
3
|
+
|
|
4
|
+
// XMLSerializer polyfill
|
|
5
|
+
class XMLSerializerPoly {
|
|
6
|
+
serializeToString(document) {
|
|
7
|
+
// LinkedOM's toString() should work for XML documents
|
|
8
|
+
return document.toString();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Function to install polyfills globally
|
|
13
|
+
export function installDOMPolyfills() {
|
|
14
|
+
if (typeof globalThis.DOMParser === 'undefined') {
|
|
15
|
+
globalThis.DOMParser = DOMParser;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (typeof globalThis.XMLSerializer === 'undefined') {
|
|
19
|
+
globalThis.XMLSerializer = XMLSerializerPoly;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Export individual polyfills for manual use
|
|
24
|
+
export { DOMParser, XMLSerializerPoly as XMLSerializer };
|
|
25
|
+
|
|
26
|
+
// Auto-install if in Node.js environment and not in browser
|
|
27
|
+
if (typeof window === 'undefined' && typeof globalThis.DOMParser === 'undefined') {
|
|
28
|
+
installDOMPolyfills();
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// polyfill browsers XMLSerializer
|
|
2
|
+
export class XMLSerializerPoly {
|
|
3
|
+
serializeToString(document) {
|
|
4
|
+
return document.toString();
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class DOMParserPoly {
|
|
9
|
+
parseFromString(string) {
|
|
10
|
+
return parseHTML(string);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (typeof globalThis.XMLSerializer === 'undefined') {
|
|
15
|
+
globalThis.XMLSerializer = XMLSerializerPoly;
|
|
16
|
+
//console.log('!!!no XMLSerializer')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (typeof globalThis.DOMParser === 'undefined') {
|
|
20
|
+
globalThis.DOMParser = DOMParserPoly;
|
|
21
|
+
//console.log('!!!no DOMParser')
|
|
22
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
import {XMLSerializerPoly, DOMParserPoly} from './dom_polyfills';
|
|
3
|
+
export {XMLSerializerPoly as XMLSerializerPoly};
|
|
4
|
+
export {DOMParserPoly as DOMParserPoly};
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
// just for visual debugging
|
|
2
8
|
import { renderPoint } from './svgii/visualize';
|
|
3
9
|
|
|
4
10
|
import {svgPathSimplify} from './pathSimplify-main';
|
|
5
|
-
import {getViewBox} from './svg_getViewbox';
|
|
6
|
-
|
|
11
|
+
//import {getViewBox} from './svg_getViewbox';
|
|
7
12
|
|
|
8
13
|
export {svgPathSimplify as svgPathSimplify};
|
|
9
|
-
export {getViewBox as getViewBox};
|
|
14
|
+
//export {getViewBox as getViewBox};
|
|
10
15
|
|
|
11
16
|
export {
|
|
12
17
|
abs, acos, asin, atan, atan2, ceil, cos, exp, floor, hypot,
|
|
@@ -14,11 +19,12 @@ export {
|
|
|
14
19
|
} from './constants';
|
|
15
20
|
|
|
16
21
|
|
|
22
|
+
|
|
17
23
|
// IIFE
|
|
18
24
|
if (typeof window !== 'undefined') {
|
|
19
25
|
window.svgPathSimplify = svgPathSimplify;
|
|
20
|
-
window.getViewBox = getViewBox;
|
|
21
|
-
window.renderPoint = renderPoint;
|
|
26
|
+
//window.getViewBox = getViewBox;
|
|
27
|
+
//window.renderPoint = renderPoint;
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
|
|
@@ -160,16 +160,6 @@ export function combineCubicPairs(com1, com2, extrapolateDominant = false, toler
|
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
|
|
163
|
-
/*
|
|
164
|
-
if (extrapolateDominant && com2.extreme) {
|
|
165
|
-
renderPoint(markers, com2.p)
|
|
166
|
-
//renderPoint(markers, com1.p, 'cyan')
|
|
167
|
-
//extrapolateDominant = false;
|
|
168
|
-
}
|
|
169
|
-
*/
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
163
|
|
|
174
164
|
// try extrapolated dominant curve
|
|
175
165
|
//&& !com2.extreme
|
|
@@ -283,38 +273,12 @@ export function getBezierCommandArea(commands = [com1, com2], absolute = true) {
|
|
|
283
273
|
|
|
284
274
|
function findSplitT(com1, com2) {
|
|
285
275
|
|
|
286
|
-
//let selfIntersecting = false
|
|
287
|
-
|
|
288
|
-
// control tangent intersection
|
|
289
|
-
let pt1 = checkLineIntersection(com1.p0, com1.cp1, com2.cp2, com2.p, false)
|
|
290
|
-
|
|
291
|
-
// intersection 2nd cp1 tangent and global tangent intersection
|
|
292
|
-
let ptI = checkLineIntersection(pt1, com2.p, com2.p0, com2.cp1, false)
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
let len1 = getDistance(pt1, com2.p)
|
|
296
|
-
let len2 = getDistance(ptI, com2.p)
|
|
297
|
-
|
|
298
|
-
//let t = !t3 ? 1-len2/len1 : (t3+len2/len1)*0.5
|
|
299
|
-
let t = 1 - len2 / len1
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
// check self intersections
|
|
303
|
-
//let ptI2 = checkLineIntersection(com1.cp1, com2.cp2, com1.p0, com2.p, true)
|
|
304
|
-
//let hasInfliction = ptI2!==null
|
|
305
|
-
|
|
306
|
-
|
|
307
276
|
let len3 = getDistance(com1.cp2, com1.p)
|
|
308
277
|
let len4 = getDistance(com1.cp2, com2.cp1)
|
|
309
278
|
|
|
310
|
-
|
|
311
|
-
t = Math.min(len3) / len4
|
|
312
|
-
|
|
313
|
-
//console.log('???selfIntersecting:', t, hasInfliction, ptI2)
|
|
279
|
+
let t = Math.min(len3) / len4
|
|
314
280
|
|
|
315
281
|
return t
|
|
316
|
-
|
|
317
|
-
|
|
318
282
|
}
|
|
319
283
|
|
|
320
284
|
|