svg-path-commander 1.0.5 → 2.0.0-alpha2
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 +26 -4
- package/dist/svg-path-commander.cjs +2 -0
- package/dist/svg-path-commander.cjs.map +1 -0
- package/dist/svg-path-commander.d.ts +454 -0
- package/dist/svg-path-commander.js +2 -3762
- package/dist/svg-path-commander.js.map +1 -0
- package/dist/svg-path-commander.mjs +1194 -0
- package/dist/svg-path-commander.mjs.map +1 -0
- package/package.json +39 -42
- package/src/convert/pathToAbsolute.ts +101 -0
- package/src/convert/{pathToCurve.js → pathToCurve.ts} +12 -14
- package/src/convert/pathToRelative.ts +92 -0
- package/src/convert/pathToString.ts +17 -0
- package/src/{svg-path-commander.js → index.ts} +143 -66
- package/src/interface.ts +129 -0
- package/src/math/distanceSquareRoot.ts +13 -0
- package/src/math/midPoint.ts +16 -0
- package/src/math/{polygonArea.js → polygonArea.ts} +6 -4
- package/src/math/{polygonLength.js → polygonLength.ts} +5 -3
- package/src/math/rotateVector.ts +16 -0
- package/src/options/options.ts +9 -0
- package/src/parser/error.ts +2 -0
- package/src/parser/finalizeSegment.ts +31 -0
- package/src/parser/{invalidPathValue.js → invalidPathValue.ts} +0 -0
- package/src/parser/{isArcCommand.js → isArcCommand.ts} +5 -4
- package/src/parser/isDigit.ts +12 -0
- package/src/parser/isDigitStart.ts +14 -0
- package/src/parser/isPathCommand.ts +28 -0
- package/src/parser/isSpace.ts +23 -0
- package/src/parser/paramsCount.ts +16 -0
- package/src/parser/paramsParser.ts +14 -0
- package/src/parser/{parsePathString.js → parsePathString.ts} +13 -7
- package/src/parser/pathParser.ts +29 -0
- package/src/parser/{scanFlag.js → scanFlag.ts} +8 -5
- package/src/parser/{scanParam.js → scanParam.ts} +12 -11
- package/src/parser/{scanSegment.js → scanSegment.ts} +9 -5
- package/src/parser/{skipSpaces.js → skipSpaces.ts} +5 -3
- package/src/process/{arcToCubic.js → arcToCubic.ts} +42 -28
- package/src/process/fixArc.ts +23 -0
- package/src/process/getSVGMatrix.ts +70 -0
- package/src/process/lineToCubic.ts +17 -0
- package/src/process/{normalizePath.js → normalizePath.ts} +10 -10
- package/src/process/normalizeSegment.ts +47 -0
- package/src/process/{optimizePath.js → optimizePath.ts} +18 -21
- package/src/process/{projection2d.js → projection2d.ts} +16 -15
- package/src/process/quadToCubic.ts +31 -0
- package/src/process/reverseCurve.ts +21 -0
- package/src/process/reversePath.ts +101 -0
- package/src/process/roundPath.ts +29 -0
- package/src/process/segmentToCubic.ts +46 -0
- package/src/process/shortenSegment.ts +79 -0
- package/src/process/splitCubic.ts +28 -0
- package/src/process/{splitPath.js → splitPath.ts} +9 -8
- package/src/process/{transformPath.js → transformPath.ts} +55 -48
- package/src/types.ts +193 -0
- package/src/util/getClosestPoint.ts +15 -0
- package/src/util/{getDrawDirection.js → getDrawDirection.ts} +7 -4
- package/src/util/getPathArea.ts +70 -0
- package/src/util/{getPathBBox.js → getPathBBox.ts} +16 -5
- package/src/util/getPointAtLength.ts +14 -0
- package/src/util/{getPropertiesAtLength.js → getPropertiesAtLength.ts} +28 -19
- package/src/util/{getPropertiesAtPoint.js → getPropertiesAtPoint.ts} +16 -12
- package/src/util/getSegmentAtLength.ts +15 -0
- package/src/util/getSegmentOfPoint.ts +18 -0
- package/src/util/{getTotalLength.js → getTotalLength.ts} +6 -4
- package/src/util/isAbsoluteArray.ts +18 -0
- package/src/util/{isCurveArray.js → isCurveArray.ts} +6 -4
- package/src/util/{isNormalizedArray.js → isNormalizedArray.ts} +4 -2
- package/src/util/isPathArray.ts +19 -0
- package/src/util/isPointInStroke.ts +15 -0
- package/src/util/isRelativeArray.ts +18 -0
- package/src/util/{isValidPath.js → isValidPath.ts} +5 -4
- package/src/util/{pathLengthFactory.js → pathLengthFactory.ts} +38 -31
- package/src/util/{segmentArcFactory.js → segmentArcFactory.ts} +71 -55
- package/src/util/segmentCubicFactory.ts +114 -0
- package/src/util/{segmentLineFactory.js → segmentLineFactory.ts} +10 -8
- package/src/util/{segmentQuadFactory.js → segmentQuadFactory.ts} +47 -32
- package/src/util/shapeToPath.ts +214 -0
- package/dist/svg-path-commander.es5.js +0 -3875
- package/dist/svg-path-commander.es5.min.js +0 -2
- package/dist/svg-path-commander.esm.js +0 -3754
- package/dist/svg-path-commander.esm.min.js +0 -2
- package/dist/svg-path-commander.min.js +0 -2
- package/src/convert/pathToAbsolute.js +0 -86
- package/src/convert/pathToRelative.js +0 -84
- package/src/convert/pathToString.js +0 -14
- package/src/index.js +0 -10
- package/src/math/distanceSquareRoot.js +0 -14
- package/src/math/epsilon.js +0 -8
- package/src/math/midPoint.js +0 -13
- package/src/math/rotateVector.js +0 -14
- package/src/options/options.js +0 -10
- package/src/parser/error.js +0 -2
- package/src/parser/finalizeSegment.js +0 -28
- package/src/parser/isDigit.js +0 -9
- package/src/parser/isDigitStart.js +0 -13
- package/src/parser/isPathCommand.js +0 -25
- package/src/parser/isSpace.js +0 -16
- package/src/parser/paramsCount.js +0 -9
- package/src/parser/paramsParser.js +0 -8
- package/src/parser/pathParser.js +0 -24
- package/src/process/clonePath.js +0 -9
- package/src/process/fixArc.js +0 -21
- package/src/process/fixPath.js +0 -31
- package/src/process/getSVGMatrix.js +0 -61
- package/src/process/lineToCubic.js +0 -30
- package/src/process/normalizeSegment.js +0 -45
- package/src/process/quadToCubic.js +0 -22
- package/src/process/reverseCurve.js +0 -18
- package/src/process/reversePath.js +0 -89
- package/src/process/roundPath.js +0 -26
- package/src/process/segmentToCubic.js +0 -46
- package/src/process/shortenSegment.js +0 -58
- package/src/process/splitCubic.js +0 -26
- package/src/util/getClosestPoint.js +0 -12
- package/src/util/getPathArea.js +0 -47
- package/src/util/getPointAtLength.js +0 -12
- package/src/util/getSegmentAtLength.js +0 -11
- package/src/util/getSegmentOfPoint.js +0 -12
- package/src/util/isAbsoluteArray.js +0 -14
- package/src/util/isPathArray.js +0 -14
- package/src/util/isPointInStroke.js +0 -13
- package/src/util/isRelativeArray.js +0 -14
- package/src/util/segmentCubicFactory.js +0 -97
- package/src/util/shapeToPath.js +0 -204
- package/src/util/util.js +0 -82
- package/src/version.js +0 -8
- package/types/index.d.ts +0 -120
- package/types/more/modules.ts +0 -82
- package/types/more/svg.d.ts +0 -211
- package/types/svg-path-commander.d.ts +0 -1089
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// SVGPathCommander v1.0.5 | thednp © 2022 | MIT-License
|
|
2
|
-
const t={origin:[0,0,0],round:4},e={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function n(t){let n=t.pathValue[t.segmentStart],r=n.toLowerCase();const{data:s}=t;for(;s.length>=e[r]&&("m"===r&&s.length>2?(t.segments.push([n,...s.splice(0,2)]),r="l",n="m"===n?"l":"L"):t.segments.push([n,...s.splice(0,e[r])]),e[r]););}const r="SVGPathCommander error";function s(t){const{index:e,pathValue:n}=t,s=n.charCodeAt(e);return 48===s?(t.param=0,void(t.index+=1)):49===s?(t.param=1,void(t.index+=1)):void(t.err=`${r}: invalid Arc flag "${n[e]}", expecting 0 or 1 at index ${e}`)}function i(t){return t>=48&&t<=57}function a(t){const{max:e,pathValue:n,index:s}=t;let a,o=s,m=!1,c=!1,u=!1,l=!1;if(o>=e)t.err=`${r}: Invalid path value at index ${o}, "pathValue" is missing param`;else if(a=n.charCodeAt(o),43!==a&&45!==a||(o+=1,a=n.charCodeAt(o)),i(a)||46===a){if(46!==a){if(m=48===a,o+=1,a=n.charCodeAt(o),m&&o<e&&a&&i(a))return void(t.err=`${r}: Invalid path value at index ${s}, "${n[s]}" illegal number`);for(;o<e&&i(n.charCodeAt(o));)o+=1,c=!0;a=n.charCodeAt(o)}if(46===a){for(l=!0,o+=1;i(n.charCodeAt(o));)o+=1,u=!0;a=n.charCodeAt(o)}if(101===a||69===a){if(l&&!c&&!u)return void(t.err=`${r}: Invalid path value at index ${o}, "${n[o]}" invalid float exponent`);if(o+=1,a=n.charCodeAt(o),43!==a&&45!==a||(o+=1),!(o<e&&i(n.charCodeAt(o))))return void(t.err=`${r}: Invalid path value at index ${o}, "${n[o]}" invalid integer exponent`);for(;o<e&&i(n.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(s,o)}else t.err=`${r}: Invalid path value at index ${o}, "${n[o]}" is not a number`}function o(t){const{pathValue:e,max:n}=t;for(;t.index<n&&(10===(r=e.charCodeAt(t.index))||13===r||8232===r||8233===r||32===r||9===r||11===r||12===r||160===r||r>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(r));)t.index+=1;var r}function m(t){return t>=48&&t<=57||43===t||45===t||46===t}function c(t){const{max:i,pathValue:c,index:u}=t,l=c.charCodeAt(u),h=e[c[u].toLowerCase()];if(t.segmentStart=u,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(l))if(t.index+=1,o(t),t.data=[],h){for(;;){for(let e=h;e>0;e-=1){if(97!=(32|l)||3!==e&&4!==e?a(t):s(t),t.err.length)return;t.data.push(t.param),o(t),t.index<i&&44===c.charCodeAt(t.index)&&(t.index+=1,o(t))}if(t.index>=t.max)break;if(!m(c.charCodeAt(t.index)))break}n(t)}else n(t);else t.err=`${r}: Invalid path value "${c[u]}" is not a path command`}function u(t){return t.map(t=>Array.isArray(t)?[...t]:t)}function l(t){this.segments=[],this.pathValue=t,this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}function h(t){return Array.isArray(t)&&t.every(t=>{const n=t[0].toLowerCase();return e[n]===t.length-1&&"achlmqstvz".includes(n)})}function f(t){if(h(t))return u(t);const e=new l(t);for(o(e);e.index<e.max&&!e.err.length;)c(e);return e.err?e.err:e.segments}function y(t){return h(t)&&t.every(([t])=>t===t.toUpperCase())}function x(t){if(y(t))return u(t);const e=f(t);let n=0,r=0,s=0,i=0;return e.map(t=>{const e=t.slice(1).map(Number),[a]=t,o=a.toUpperCase();if("M"===a)return[n,r]=e,s=n,i=r,["M",n,r];let m=[];if(a!==o)switch(o){case"A":m=[o,e[0],e[1],e[2],e[3],e[4],e[5]+n,e[6]+r];break;case"V":m=[o,e[0]+r];break;case"H":m=[o,e[0]+n];break;default:m=[o,...e.map((t,e)=>t+(e%2?r:n))]}else m=[o,...e];const c=m.length;switch(o){case"Z":n=s,r=i;break;case"H":[,n]=m;break;case"V":[,r]=m;break;default:n=m[c-2],r=m[c-1],"M"===o&&(s=n,i=r)}return m})}function g(t){return h(t)&&t.slice(1).every(([t])=>t===t.toLowerCase())}function p(t){if(g(t))return u(t);const e=f(t);let n=0,r=0,s=0,i=0;return e.map(t=>{const e=t.slice(1).map(Number),[a]=t,o=a.toLowerCase();if("M"===a)return[n,r]=e,s=n,i=r,["M",n,r];let m=[];if(a!==o)switch(o){case"a":m=[o,e[0],e[1],e[2],e[3],e[4],e[5]-n,e[6]-r];break;case"v":m=[o,e[0]-r];break;case"h":m=[o,e[0]-n];break;default:m=[o,...e.map((t,e)=>t-(e%2?r:n))]}else"m"===a&&(s=e[0]+n,i=e[1]+r),m=[o,...e];const c=m.length;switch(o){case"z":n=s,r=i;break;case"h":n+=m[1];break;case"v":r+=m[1];break;default:n+=m[c-2],r+=m[c-1]}return m})}function d(t,e,n){if(t[n].length>7){t[n].shift();const r=t[n];let s=n;for(;r.length;)e[n]="A",t.splice(s+=1,0,["C",...r.splice(0,6)]);t.splice(n,1)}}function M(t){return y(t)&&t.every(([t])=>"ACLMQZ".includes(t))}function b(t){return M(t)&&t.every(([t])=>"MC".includes(t))}function N(t,e){const[n]=t,{x1:r,y1:s,x2:i,y2:a}=e,o=t.slice(1).map(Number);let m=t;if("TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n)m=["L",t[1],s];else if("V"===n)m=["L",r,t[1]];else if("S"===n){const t=2*r-i,n=2*s-a;e.x1=t,e.y1=n,m=["C",t,n,...o]}else if("T"===n){const t=2*r-e.qx,n=2*s-e.qy;e.qx=t,e.qy=n,m=["Q",t,n,...o]}else if("Q"===n){const[t,n]=o;e.qx=t,e.qy=n}return m}const A={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function v(t){if(M(t))return u(t);const e=x(t),n={...A},r=[],s=e.length;let i="";for(let t=0;t<s;t+=1){[i]=e[t],r[t]=i,e[t]=N(e[t],n);const s=e[t],a=s.length;n.x1=+s[a-2],n.y1=+s[a-1],n.x2=+s[a-4]||n.x1,n.y2=+s[a-3]||n.y1}return e}function w(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function C(t,e,n,r,s,i,a,o,m,c){let u=t,l=e,h=n,f=r,y=o,x=m;const g=120*Math.PI/180,p=Math.PI/180*(+s||0);let d,M,b,N,A,v=[];if(c)[M,b,N,A]=c;else{d=w(u,l,-p),u=d.x,l=d.y,d=w(y,x,-p),y=d.x,x=d.y;const t=(u-y)/2,e=(l-x)/2;let n=t*t/(h*h)+e*e/(f*f);n>1&&(n=Math.sqrt(n),h*=n,f*=n);const r=h*h,s=f*f,o=(i===a?-1:1)*Math.sqrt(Math.abs((r*s-r*e*e-s*t*t)/(r*e*e+s*t*t)));N=o*h*e/f+(u+y)/2,A=o*-f*t/h+(l+x)/2,M=Math.asin(((l-A)/f*10**9>>0)/10**9),b=Math.asin(((x-A)/f*10**9>>0)/10**9),M=u<N?Math.PI-M:M,b=y<N?Math.PI-b:b,M<0&&(M=2*Math.PI+M),b<0&&(b=2*Math.PI+b),a&&M>b&&(M-=2*Math.PI),!a&&b>M&&(b-=2*Math.PI)}let S=b-M;if(Math.abs(S)>g){const t=b,e=y,n=x;b=M+g*(a&&b>M?1:-1),y=N+h*Math.cos(b),x=A+f*Math.sin(b),v=C(y,x,h,f,s,0,a,e,n,[b,t,N,A])}S=b-M;const k=Math.cos(M),P=Math.sin(M),T=Math.cos(b),$=Math.sin(b),q=Math.tan(S/4),I=4/3*h*q,V=4/3*f*q,L=[u,l],j=[u+I*P,l-V*k],O=[y+I*$,x-V*T],E=[y,x];if(j[0]=2*L[0]-j[0],j[1]=2*L[1]-j[1],c)return[...j,...O,...E,...v];v=[...j,...O,...E,...v];const z=[];for(let t=0,e=v.length;t<e;t+=1)z[t]=t%2?w(v[t-1],v[t],p).y:w(v[t],v[t+1],p).x;return z}function S(t,e,n,r,s,i){return[1/3*t+2/3*n,1/3*e+2/3*r,1/3*s+2/3*n,1/3*i+2/3*r,s,i]}function k(t,e,n){const[r,s]=t,[i,a]=e;return[r+(i-r)*n,s+(a-s)*n]}function P(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function T(t,e,n,r,s){const i=P([t,e],[n,r]);let a={x:0,y:0};if("number"==typeof s)if(s<=0)a={x:t,y:e};else if(s>=i)a={x:n,y:r};else{const[o,m]=k([t,e],[n,r],s/i);a={x:o,y:m}}return{length:i,point:a,min:{x:Math.min(t,n),y:Math.min(e,r)},max:{x:Math.max(t,n),y:Math.max(e,r)}}}function $(t,e,n,r){const s=.5,i=[t,e],a=[n,r],o=k(i,a,s),m=k(a,o,s),c=k(o,m,s),u=k(m,c,s),l=k(c,u,s),h=T(...[...i,...o,...c,...l,s]).point,f=T(...[...l,...u,...m,...a,0]).point;return[h.x,h.y,f.x,f.y,n,r]}function q(t,e){const[n]=t,r=t.slice(1).map(Number),[s,i]=r;let a;const{x1:o,y1:m,x:c,y:u}=e;switch("TQ".includes(n)||(e.qx=null,e.qy=null),n){case"M":return e.x=s,e.y=i,t;case"A":return a=[o,m,...r],["C",...C(...a)];case"Q":return e.qx=s,e.qy=i,a=[o,m,...r],["C",...S(...a)];case"L":return["C",...$(o,m,s,i)];case"Z":return["C",...$(o,m,c,u)]}return t}function I(t){if(b(t))return u(t);const e=v(t),n={...A},r=[];let s="",i=e.length;for(let t=0;t<i;t+=1){[s]=e[t],r[t]=s,e[t]=q(e[t],n),d(e,r,t),i=e.length;const a=e[t],o=a.length;n.x1=+a[o-2],n.y1=+a[o-1],n.x2=+a[o-4]||n.x1,n.y2=+a[o-3]||n.y1}return e}function V(e,n){let{round:r}=t;if("off"===n||"off"===r)return u(e);r=n>=0?n:r;const s="number"==typeof r&&r>=1?10**r:1;return e.map(t=>{const e=t.slice(1).map(Number).map(t=>r?Math.round(t*s)/s:Math.round(t));return[t[0],...e]})}function L(t,e){return V(t,e).map(t=>t[0]+t.slice(1).join(" ")).join("")}function j(t){const e=x(t),n="Z"===e.slice(-1)[0][0],r=v(e).map((t,n)=>{const[r,s]=t.slice(-2).map(Number);return{seg:e[n],n:t,c:e[n][0],x:r,y:s}}).map((t,e,r)=>{const s=t.seg,i=t.n,a=e&&r[e-1],o=r[e+1],m=t.c,c=r.length,u=e?r[e-1].x:r[c-1].x,l=e?r[e-1].y:r[c-1].y;let h=[];switch(m){case"M":h=n?["Z"]:[m,u,l];break;case"A":h=[m,...s.slice(1,-3),1===s[5]?0:1,u,l];break;case"C":h=o&&"S"===o.c?["S",s[1],s[2],u,l]:[m,s[3],s[4],s[1],s[2],u,l];break;case"S":h=!a||!"CS".includes(a.c)||o&&"S"===o.c?[m,i[1],i[2],u,l]:["C",i[3],i[4],i[1],i[2],u,l];break;case"Q":h=o&&"T"===o.c?["T",u,l]:[m,...s.slice(1,-2),u,l];break;case"T":h=!a||!"QT".includes(a.c)||o&&"T"===o.c?[m,u,l]:["Q",i[1],i[2],u,l];break;case"Z":h=["M",u,l];break;case"H":h=[m,u];break;case"V":h=[m,l];break;default:h=[m,...s.slice(1,-2),u,l]}return h});return n?r.reverse():[r[0],...r.slice(1).reverse()]}function O(t){const e=[];let n,r=-1;return t.forEach(t=>{"M"===t[0]?(n=[t],r+=1):n=[...n,t],e[r]=n}),e}function E(t,e,n,r){const[s]=t,i=t=>Math.round(1e4*t)/1e4,a=t.slice(1).map(t=>+t),o=e.slice(1).map(t=>+t),{x1:m,y1:c,x2:u,y2:l,x:h,y:f}=n;let y=t;const[x,g]=o.slice(-2);if("TQ".includes(s)||(n.qx=null,n.qy=null),["V","H","S","T","Z"].includes(s))y=[s,...a];else if("L"===s)i(h)===i(x)?y=["V",g]:i(f)===i(g)&&(y=["H",x]);else if("C"===s){const[t,e]=o;"CS".includes(r)&&(i(t)===i(2*m-u)&&i(e)===i(2*c-l)||i(m)===i(2*u-h)&&i(c)===i(2*l-f))&&(y=["S",...o.slice(-4)]),n.x1=t,n.y1=e}else if("Q"===s){const[t,e]=o;n.qx=t,n.qy=e,"QT".includes(r)&&(i(t)===i(2*m-u)&&i(e)===i(2*c-l)||i(m)===i(2*u-h)&&i(c)===i(2*l-f))&&(y=["T",...o.slice(-2)])}return y}function z(t,e){const n=x(t),r=v(n),s={...A},i=[],a=n.length;let o="",m="",c=0,u=0,l=0,h=0;for(let t=0;t<a;t+=1){[o]=n[t],i[t]=o,t&&(m=i[t-1]),n[t]=E(n[t],r[t],s,m);const e=n[t],a=e.length;switch(s.x1=+e[a-2],s.y1=+e[a-1],s.x2=+e[a-4]||s.x1,s.y2=+e[a-3]||s.y1,o){case"Z":c=l,u=h;break;case"H":[,c]=e;break;case"V":[,u]=e;break;default:[c,u]=e.slice(-2).map(Number),"M"===o&&(l=c,h=u)}s.x=c,s.y=u}const f=V(n,e),y=V(p(n),e);return f.map((t,e)=>e?t.join("").length<y[e].join("").length?t:y[e]:t)}function Z(t){const e=new K,n=Array.from(t);if(!n.every(t=>!Number.isNaN(t)))throw TypeError(`CSSMatrix: "${t}" must only have numbers.`);if(16===n.length){const[t,r,s,i,a,o,m,c,u,l,h,f,y,x,g,p]=n;e.m11=t,e.a=t,e.m21=a,e.c=a,e.m31=u,e.m41=y,e.e=y,e.m12=r,e.b=r,e.m22=o,e.d=o,e.m32=l,e.m42=x,e.f=x,e.m13=s,e.m23=m,e.m33=h,e.m43=g,e.m14=i,e.m24=c,e.m34=f,e.m44=p}else{if(6!==n.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");{const[t,r,s,i,a,o]=n;e.m11=t,e.a=t,e.m12=r,e.b=r,e.m21=s,e.c=s,e.m22=i,e.d=i,e.m41=a,e.e=a,e.m42=o,e.f=o}}return e}function Q(t){const e=Object.keys(new K);if("object"==typeof t&&e.every(e=>e in t))return Z([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]);throw TypeError(`CSSMatrix: "${JSON.stringify(t)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)}function F(t){if("string"!=typeof t)throw TypeError(`CSSMatrix: "${t}" is not a string.`);const e=String(t).replace(/\s/g,"");let n=new K;const r=`CSSMatrix: invalid transform string "${t}"`;return e.split(")").filter(t=>t).forEach(t=>{const[e,s]=t.split("(");if(!s)throw TypeError(r);const i=s.split(",").map(t=>t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)),[a,o,m,c]=i,u=[a,o,m],l=[a,o,m,c];if("perspective"===e&&a&&[o,m].every(t=>void 0===t))n.m34=-1/a;else if(e.includes("matrix")&&[6,16].includes(i.length)&&i.every(t=>!Number.isNaN(+t))){const t=i.map(t=>Math.abs(t)<1e-6?0:t);n=n.multiply(Z(t))}else if("translate3d"===e&&u.every(t=>!Number.isNaN(+t)))n=n.translate(a,o,m);else if("translate"===e&&a&&void 0===m)n=n.translate(a,o||0,0);else if("rotate3d"===e&&l.every(t=>!Number.isNaN(+t))&&c)n=n.rotateAxisAngle(a,o,m,c);else if("rotate"===e&&a&&[o,m].every(t=>void 0===t))n=n.rotate(0,0,a);else if("scale3d"===e&&u.every(t=>!Number.isNaN(+t))&&u.some(t=>1!==t))n=n.scale(a,o,m);else if("scale"!==e||Number.isNaN(a)||1===a||void 0!==m)if("skew"===e&&(a||!Number.isNaN(a)&&o)&&void 0===m)n=n.skew(a,o||0);else{if(!(/[XYZ]/.test(e)&&a&&[o,m].every(t=>void 0===t)&&["translate","rotate","scale","skew"].some(t=>e.includes(t))))throw TypeError(r);if(["skewX","skewY"].includes(e))n=n[e](a);else{const t=e.replace(/[XYZ]/,""),r=e.replace(t,""),s=["X","Y","Z"].indexOf(r),i="scale"===t?1:0,o=[0===s?a:i,1===s?a:i,2===s?a:i];n=n[t](...o)}}else{const t=Number.isNaN(+o)?a:o;n=n.scale(a,t,1)}}),n}function D(t,e){return e?[t.a,t.b,t.c,t.d,t.e,t.f]:[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]}function H(t,e,n){const r=new K;return r.m41=t,r.e=t,r.m42=e,r.f=e,r.m43=n,r}function X(t,e,n){const r=new K,s=Math.PI/180,i=t*s,a=e*s,o=n*s,m=Math.cos(i),c=-Math.sin(i),u=Math.cos(a),l=-Math.sin(a),h=Math.cos(o),f=-Math.sin(o),y=u*h,x=-u*f;r.m11=y,r.a=y,r.m12=x,r.b=x,r.m13=l;const g=c*l*h+m*f;r.m21=g,r.c=g;const p=m*h-c*l*f;return r.m22=p,r.d=p,r.m23=-c*u,r.m31=c*f-m*l*h,r.m32=c*h+m*l*f,r.m33=m*u,r}function Y(t,e,n,r){const s=new K,i=Math.sqrt(t*t+e*e+n*n);if(0===i)return s;const a=t/i,o=e/i,m=n/i,c=r*(Math.PI/360),u=Math.sin(c),l=Math.cos(c),h=u*u,f=a*a,y=o*o,x=m*m,g=1-2*(y+x)*h;s.m11=g,s.a=g;const p=2*(a*o*h+m*u*l);s.m12=p,s.b=p,s.m13=2*(a*m*h-o*u*l);const d=2*(o*a*h-m*u*l);s.m21=d,s.c=d;const M=1-2*(x+f)*h;return s.m22=M,s.d=M,s.m23=2*(o*m*h+a*u*l),s.m31=2*(m*a*h+o*u*l),s.m32=2*(m*o*h-a*u*l),s.m33=1-2*(f+y)*h,s}function B(t,e,n){const r=new K;return r.m11=t,r.a=t,r.m22=e,r.d=e,r.m33=n,r}function R(t,e){const n=new K;if(t){const e=t*Math.PI/180,r=Math.tan(e);n.m21=r,n.c=r}if(e){const t=e*Math.PI/180,r=Math.tan(t);n.m12=r,n.b=r}return n}function J(t){return R(t,0)}function G(t){return R(0,t)}function U(t,e){return Z([e.m11*t.m11+e.m12*t.m21+e.m13*t.m31+e.m14*t.m41,e.m11*t.m12+e.m12*t.m22+e.m13*t.m32+e.m14*t.m42,e.m11*t.m13+e.m12*t.m23+e.m13*t.m33+e.m14*t.m43,e.m11*t.m14+e.m12*t.m24+e.m13*t.m34+e.m14*t.m44,e.m21*t.m11+e.m22*t.m21+e.m23*t.m31+e.m24*t.m41,e.m21*t.m12+e.m22*t.m22+e.m23*t.m32+e.m24*t.m42,e.m21*t.m13+e.m22*t.m23+e.m23*t.m33+e.m24*t.m43,e.m21*t.m14+e.m22*t.m24+e.m23*t.m34+e.m24*t.m44,e.m31*t.m11+e.m32*t.m21+e.m33*t.m31+e.m34*t.m41,e.m31*t.m12+e.m32*t.m22+e.m33*t.m32+e.m34*t.m42,e.m31*t.m13+e.m32*t.m23+e.m33*t.m33+e.m34*t.m43,e.m31*t.m14+e.m32*t.m24+e.m33*t.m34+e.m34*t.m44,e.m41*t.m11+e.m42*t.m21+e.m43*t.m31+e.m44*t.m41,e.m41*t.m12+e.m42*t.m22+e.m43*t.m32+e.m44*t.m42,e.m41*t.m13+e.m42*t.m23+e.m43*t.m33+e.m44*t.m43,e.m41*t.m14+e.m42*t.m24+e.m43*t.m34+e.m44*t.m44])}class K{constructor(...t){const e=this;if(e.a=1,e.b=0,e.c=0,e.d=1,e.e=0,e.f=0,e.m11=1,e.m12=0,e.m13=0,e.m14=0,e.m21=0,e.m22=1,e.m23=0,e.m24=0,e.m31=0,e.m32=0,e.m33=1,e.m34=0,e.m41=0,e.m42=0,e.m43=0,e.m44=1,t.length){const n=[16,6].some(e=>e===t.length)?t:t[0];return e.setMatrixValue(n)}return e}get isIdentity(){const t=this;return 1===t.m11&&0===t.m12&&0===t.m13&&0===t.m14&&0===t.m21&&1===t.m22&&0===t.m23&&0===t.m24&&0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m41&&0===t.m42&&0===t.m43&&1===t.m44}get is2D(){const t=this;return 0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m43&&1===t.m44}setMatrixValue(t){return"string"==typeof t&&t.length&&"none"!==t?F(t):[Array,Float64Array,Float32Array].some(e=>t instanceof e)?Z(t):[K,DOMMatrix,Object].some(e=>t instanceof e)?Q(t):this}toFloat32Array(t){return Float32Array.from(D(this,t))}toFloat64Array(t){return Float64Array.from(D(this,t))}toString(){const{is2D:t}=this;return`${t?"matrix":"matrix3d"}(${this.toFloat64Array(t).join(", ")})`}toJSON(){const{is2D:t,isIdentity:e}=this;return{...this,is2D:t,isIdentity:e}}multiply(t){return U(this,t)}translate(t,e,n){let r=e,s=n;return void 0===r&&(r=0),void 0===s&&(s=0),U(this,H(t,r,s))}scale(t,e,n){let r=e,s=n;return void 0===r&&(r=t),void 0===s&&(s=1),U(this,B(t,r,s))}rotate(t,e,n){let r=t,s=e||0,i=n||0;return"number"==typeof t&&void 0===e&&void 0===n&&(i=r,r=0,s=0),U(this,X(r,s,i))}rotateAxisAngle(t,e,n,r){if([t,e,n,r].some(t=>Number.isNaN(+t)))throw new TypeError("CSSMatrix: expecting 4 values");return U(this,Y(t,e,n,r))}skewX(t){return U(this,J(t))}skewY(t){return U(this,G(t))}skew(t,e){return U(this,R(t,e))}transformPoint(t){const e=this,n=e.m11*t.x+e.m21*t.y+e.m31*t.z+e.m41*t.w,r=e.m12*t.x+e.m22*t.y+e.m32*t.z+e.m42*t.w,s=e.m13*t.x+e.m23*t.y+e.m33*t.z+e.m43*t.w,i=e.m14*t.x+e.m24*t.y+e.m34*t.z+e.m44*t.w;return t instanceof DOMPoint?new DOMPoint(n,r,s,i):{x:n,y:r,z:s,w:i}}}Object.assign(K,{Translate:H,Rotate:X,RotateAxisAngle:Y,Scale:B,SkewX:J,SkewY:G,Skew:R,Multiply:U,fromArray:Z,fromMatrix:Q,fromString:F,toArray:D});function W(t,e,n){const[r,s,i]=n,[a,o,m]=function(t,e){let n=H(...e);return[,,,n.m44]=e,n=t.multiply(n),[n.m41,n.m42,n.m43,n.m44]}(t,[...e,0,1]),c=o-s,u=m-i;return[(a-r)*(Math.abs(i)/Math.abs(u)||1)+r,c*(Math.abs(i)/Math.abs(u)||1)+s]}function _(e,n){let r,s,i,a,o,m,c=0,l=0;const h=x(e),f=n&&Object.keys(n);if(!n||!f.length)return u(h);const y=v(h);if(!n.origin){const{origin:e}=t;Object.assign(n,{origin:e})}const g=function(t){let e=new K;const{origin:n}=t,[r,s]=n,{translate:i}=t,{rotate:a}=t,{skew:o}=t,{scale:m}=t;return Array.isArray(i)&&i.every(t=>!Number.isNaN(+t))&&i.some(t=>0!==t)?e=e.translate(...i):"number"!=typeof i||Number.isNaN(i)||(e=e.translate(i)),(a||o||m)&&(e=e.translate(r,s),Array.isArray(a)&&a.every(t=>!Number.isNaN(+t))&&a.some(t=>0!==t)?e=e.rotate(...a):"number"!=typeof a||Number.isNaN(a)||(e=e.rotate(a)),Array.isArray(o)&&o.every(t=>!Number.isNaN(+t))&&o.some(t=>0!==t)?(e=o[0]?e.skewX(o[0]):e,e=o[1]?e.skewY(o[1]):e):"number"!=typeof o||Number.isNaN(o)||(e=e.skewX(o)),Array.isArray(m)&&m.every(t=>!Number.isNaN(+t))&&m.some(t=>1!==t)?e=e.scale(...m):"number"!=typeof m||Number.isNaN(m)||(e=e.scale(m)),e=e.translate(-r,-s)),e}(n),{origin:p}=n,M={...A};let b=[],N=0,w="",C=[];const S=[];if(!g.isIdentity){for(r=0,i=h.length;r<i;r+=1){b=h[r],h[r]&&([w]=b),S[r]=w,"A"===w&&(b=q(y[r],M),h[r]=q(y[r],M),d(h,S,r),y[r]=q(y[r],M),d(y,S,r),i=Math.max(h.length,y.length)),b=y[r],N=b.length,M.x1=+b[N-2],M.y1=+b[N-1],M.x2=+b[N-4]||M.x1,M.y2=+b[N-3]||M.y1;const t={s:h[r],c:h[r][0],x:M.x1,y:M.y1};C=[...C,t]}return C.map(t=>{switch(w=t.c,b=t.s,w){case"L":case"H":case"V":return[o,m]=W(g,[t.x,t.y],p),c!==o&&l!==m?b=["L",o,m]:l===m?b=["H",o]:c===o&&(b=["V",m]),c=o,l=m,b;default:for(s=1,a=b.length;s<a;s+=2)[c,l]=W(g,[+b[s],+b[s+1]],p),b[s]=c,b[s+1]=l;return b}})}return u(h)}function tt(t,e){const{x:n,y:r}=t,{x:s,y:i}=e,a=n*s+r*i,o=Math.sqrt((n**2+r**2)*(s**2+i**2));return(n*i-r*s<0?-1:1)*Math.acos(a/o)}function et(t,e,n,r,s,i,a,o,m,c){const{abs:u,sin:l,cos:h,sqrt:f,PI:y}=Math;let x=u(n),g=u(r);const p=(s%360+360)%360*(y/180);if(t===o&&e===m)return{x:t,y:e};if(0===x||0===g)return T(t,e,o,m,c).point;const d=(t-o)/2,M=(e-m)/2,b=h(p)*d+l(p)*M,N=-l(p)*d+h(p)*M,A=b**2/x**2+N**2/g**2;A>1&&(x*=f(A),g*=f(A));let v=(x**2*g**2-x**2*N**2-g**2*b**2)/(x**2*N**2+g**2*b**2);v=v<0?0:v;const w=(i!==a?1:-1)*f(v),C=w*(x*N/g),S=w*(-g*b/x),k=h(p)*C-l(p)*S+(t+o)/2,P=l(p)*C+h(p)*S+(e+m)/2,$={x:(b-C)/x,y:(N-S)/g},q=tt({x:1,y:0},$);let I=tt($,{x:(-b-C)/x,y:(-N-S)/g});!a&&I>0?I-=2*y:a&&I<0&&(I+=2*y),I%=2*y;const V=q+I*c,L=x*h(V),j=g*l(V);return{x:h(p)*L-l(p)*j+k,y:l(p)*L+h(p)*j+P}}function nt(t,e,n,r,s,i,a,o,m,c){const u="number"==typeof c;let l=t,h=e,f=0,y=[l,h,f],x=[l,h],g=0,p={x:0,y:0},d=[{x:l,y:h}];u&&c<=0&&(p={x:l,y:h});for(let M=0;M<=300;M+=1){if(g=M/300,({x:l,y:h}=et(t,e,n,r,s,i,a,o,m,g)),d=[...d,{x:l,y:h}],f+=P(x,[l,h]),x=[l,h],u&&f>c&&c>y[2]){const t=(f-c)/(f-y[2]);p={x:x[0]*(1-t)+y[0]*t,y:x[1]*(1-t)+y[1]*t}}y=[l,h,f]}return u&&c>=f&&(p={x:o,y:m}),{length:f,point:p,min:{x:Math.min(...d.map(t=>t.x)),y:Math.min(...d.map(t=>t.y))},max:{x:Math.max(...d.map(t=>t.x)),y:Math.max(...d.map(t=>t.y))}}}function rt(t,e,n,r,s,i,a,o,m){const c=1-m;return{x:c**3*t+3*c**2*m*n+3*c*m**2*s+m**3*a,y:c**3*e+3*c**2*m*r+3*c*m**2*i+m**3*o}}function st(t,e,n,r,s,i,a,o,m){const c="number"==typeof m;let u=t,l=e,h=0,f=[u,l,h],y=[u,l],x=0,g={x:0,y:0},p=[{x:u,y:l}];c&&m<=0&&(g={x:u,y:l});for(let d=0;d<=300;d+=1){if(x=d/300,({x:u,y:l}=rt(t,e,n,r,s,i,a,o,x)),p=[...p,{x:u,y:l}],h+=P(y,[u,l]),y=[u,l],c&&h>m&&m>f[2]){const t=(h-m)/(h-f[2]);g={x:y[0]*(1-t)+f[0]*t,y:y[1]*(1-t)+f[1]*t}}f=[u,l,h]}return c&&m>=h&&(g={x:a,y:o}),{length:h,point:g,min:{x:Math.min(...p.map(t=>t.x)),y:Math.min(...p.map(t=>t.y))},max:{x:Math.max(...p.map(t=>t.x)),y:Math.max(...p.map(t=>t.y))}}}function it(t,e,n,r,s,i,a){const o=1-a;return{x:o**2*t+2*o*a*n+a**2*s,y:o**2*e+2*o*a*r+a**2*i}}function at(t,e,n,r,s,i,a){const o="number"==typeof a;let m=t,c=e,u=0,l=[m,c,u],h=[m,c],f=0,y={x:0,y:0},x=[{x:m,y:c}];o&&a<=0&&(y={x:m,y:c});for(let g=0;g<=300;g+=1){if(f=g/300,({x:m,y:c}=it(t,e,n,r,s,i,f)),x=[...x,{x:m,y:c}],u+=P(h,[m,c]),h=[m,c],o&&u>a&&a>l[2]){const t=(u-a)/(u-l[2]);y={x:h[0]*(1-t)+l[0]*t,y:h[1]*(1-t)+l[1]*t}}l=[m,c,u]}return o&&a>=u&&(y={x:s,y:i}),{length:u,point:y,min:{x:Math.min(...x.map(t=>t.x)),y:Math.min(...x.map(t=>t.y))},max:{x:Math.max(...x.map(t=>t.x)),y:Math.max(...x.map(t=>t.y))}}}function ot(t,e){const n=v(t),r="number"==typeof e;let s,i,a,o=[],m=0,c=0,u=0,l=0,h=[],f=[],y=0,x={x:0,y:0},g=x,p=x,d=x,M=0;for(let t=0,b=n.length;t<b;t+=1)a=n[t],[i]=a,s="M"===i,o=s?o:[m,c,...a.slice(1)],s?([,u,l]=a,x={x:u,y:l},g=x,y=0,r&&e<.001&&(d=x)):"L"===i?({length:y,min:x,max:g,point:p}=T(...o,(e||0)-M)):"A"===i?({length:y,min:x,max:g,point:p}=nt(...o,(e||0)-M)):"C"===i?({length:y,min:x,max:g,point:p}=st(...o,(e||0)-M)):"Q"===i?({length:y,min:x,max:g,point:p}=at(...o,(e||0)-M)):"Z"===i&&(o=[m,c,u,l],({length:y,min:x,max:g,point:p}=T(...o,(e||0)-M))),r&&M<e&&M+y>=e&&(d=p),f=[...f,g],h=[...h,x],M+=y,[m,c]="Z"!==i?a.slice(-2):[u,l];return r&&e>=M&&(d={x:m,y:c}),{length:M,point:d,min:{x:Math.min(...h.map(t=>t.x)),y:Math.min(...h.map(t=>t.y))},max:{x:Math.max(...f.map(t=>t.x)),y:Math.max(...f.map(t=>t.y))}}}function mt(t){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};const{min:{x:e,y:n},max:{x:r,y:s}}=ot(t),i=r-e,a=s-n;return{width:i,height:a,x:e,y:n,x2:r,y2:s,cx:e+i/2,cy:n+a/2,cz:Math.max(i,a)+Math.min(i,a)/2}}function ct(t){return ot(t).length}function ut(t,e){return ot(t,e).point}Object.assign(K,{Version:"1.0.3"});class lt{constructor(e,n){const s=n||{},i=void 0===e;if(i||!e.length)throw TypeError(`${r}: "pathValue" is ${i?"undefined":"empty"}`);const a=f(e);if("string"==typeof a)throw TypeError(a);this.segments=a;const{width:o,height:m,cx:c,cy:u,cz:l}=this.getBBox(),{round:h,origin:y}=s;let x,g;if("auto"===h){const t=(""+Math.floor(Math.max(o,m))).length;x=t>=4?0:4-t}else Number.isInteger(h)||"off"===h?x=h:({round:x}=t);if(Array.isArray(y)&&y.length>=2){const[t,e,n]=y.map(Number);g=[Number.isNaN(t)?c:t,Number.isNaN(e)?u:e,Number.isNaN(n)?l:n]}else g=[c,u,l];return this.round=x,this.origin=g,this}getBBox(){return mt(this.segments)}getTotalLength(){return ct(this.segments)}getPointAtLength(t){return ut(this.segments,t)}toAbsolute(){const{segments:t}=this;return this.segments=x(t),this}toRelative(){const{segments:t}=this;return this.segments=p(t),this}toCurve(){const{segments:t}=this;return this.segments=I(t),this}reverse(t){this.toAbsolute();const{segments:e}=this,n=O(e),r=n.length>1?n:0,s=r&&u(r).map((e,n)=>t?n?j(e):f(e):j(e));let i=[];return i=r?s.flat(1):t?e:j(e),this.segments=u(i),this}normalize(){const{segments:t}=this;return this.segments=v(t),this}optimize(){const{segments:t}=this;return this.segments=z(t,this.round),this}transform(t){if(!t||"object"!=typeof t||"object"==typeof t&&!["translate","rotate","skew","scale"].some(e=>e in t))return this;const e={};Object.keys(t).forEach(n=>{e[n]=Array.isArray(t[n])?[...t[n]]:Number(t[n])});const{segments:n}=this,[r,s,i]=this.origin,{origin:a}=e;if(Array.isArray(a)&&a.length>=2){const[t,n,o]=a.map(Number);e.origin=[Number.isNaN(t)?r:t,Number.isNaN(n)?s:n,o||i]}else e.origin=[r,s,i];return this.segments=_(n,e),this}flipX(){return this.transform({rotate:[0,180,0]}),this}flipY(){return this.transform({rotate:[180,0,0]}),this}toString(){return L(this.segments,this.round)}}function ht(t){let e=0,n=0,r=0;return I(t).map(t=>{switch(t[0]){case"M":return[,e,n]=t,0;default:return r=function(t,e,n,r,s,i,a,o){return 3*((o-e)*(n+s)-(a-t)*(r+i)+r*(t-s)-n*(e-i)+o*(s+t/3)-a*(i+e/3))/20}(e,n,...t.slice(1)),[e,n]=t.slice(-2),r}}).reduce((t,e)=>t+e,0)}function ft(t,e){const n=f(t);if("string"==typeof n)throw TypeError(n);let r=[...n],s=ct(r),i=r.length-1,a=0,o=0,m=n[0];const[c,u]=m.slice(-2),l={x:c,y:u};if(i<=0||!e||!Number.isFinite(e))return{segment:m,index:0,length:o,point:l,lengthAtSegment:a};if(e>=s)return r=n.slice(0,-1),a=ct(r),o=s-a,{segment:n[i],index:i,length:o,lengthAtSegment:a};const h=[];for(;i>0;)m=r[i],r=r.slice(0,-1),a=ct(r),o=s-a,s=a,h.push({segment:m,index:i,length:o,lengthAtSegment:a}),i-=1;return h.find(({lengthAtSegment:t})=>t<=e)}function yt(t,e){const n=f(t),r=v(n),s=ct(n),i=t=>{const n=t.x-e.x,r=t.y-e.y;return n*n+r*r};let a,o,m,c,u=8,l=0,h=0,y=1/0;for(let t=0;t<=s;t+=u)a=ut(r,t),l=i(a),l<y&&(o=a,h=t,y=l);u/=2;let x=0,g=0,p=0,d=0;for(;u>.5;)x=h-u,m=ut(r,x),p=i(m),g=h+u,c=ut(r,g),d=i(c),x>=0&&p<y?(o=m,h=x,y=p):g<=s&&d<y?(o=c,h=g,y=d):u/=2;const M=ft(n,h);return{closest:o,distance:Math.sqrt(y),segment:M}}function xt(t){if("string"!=typeof t)return!1;const e=new l(t);for(o(e);e.index<e.max&&!e.err.length;)c(e);return!e.err.length&&"mM".includes(e.segments[0][0])}const gt={line:["x1","y1","x2","y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],rect:["width","height","x","y","rx","ry"],polygon:["points"],polyline:["points"],glyph:["d"]};const pt={CSSMatrix:K,parsePathString:f,isPathArray:h,isCurveArray:b,isAbsoluteArray:y,isRelativeArray:g,isNormalizedArray:M,isValidPath:xt,pathToAbsolute:x,pathToRelative:p,pathToCurve:I,pathToString:L,getDrawDirection:function(t){return ht(I(t))>=0},getPathArea:ht,getPathBBox:mt,pathLengthFactory:ot,getTotalLength:ct,getPointAtLength:ut,getClosestPoint:function(t,e){return yt(t,e).closest},getSegmentOfPoint:function(t,e){return yt(t,e).segment},getPropertiesAtPoint:yt,getPropertiesAtLength:ft,getSegmentAtLength:function(t,e){return ft(t,e).segment},isPointInStroke:function(t,e){const{distance:n}=yt(t,e);return Math.abs(n)<.001},clonePath:u,splitPath:O,fixPath:function(t){const e=f(t),n=v(e),{length:r}=e,s="Z"===n.slice(-1)[0][0],i=s?r-2:r-1,[a,o]=n[0].slice(1),[m,c]=n[i].slice(-2);return s&&a===m&&o===c?e.slice(0,-1):e},roundPath:V,optimizePath:z,reverseCurve:function(t){const e=t.slice(1).map((e,n,r)=>n?[...r[n-1].slice(-2),...e.slice(1)]:[...t[0].slice(1),...e.slice(1)]).map(t=>t.map((e,n)=>t[t.length-n-2*(1-n%2)])).reverse();return[["M",...e[0].slice(0,2)],...e.map(t=>["C",...t.slice(2)])]},reversePath:j,normalizePath:v,transformPath:_,shapeToPath:function(e,n){const s=Object.keys(gt),{tagName:i}=e;if(i&&!s.some(t=>i===t))throw TypeError(`${r}: "${i}" is not SVGElement`);const a=document.createElementNS("http://www.w3.org/2000/svg","path"),o=i||e.type,m={};m.type=o;const c=gt[o];let u;i?(c.forEach(t=>{m[t]=e.getAttribute(t)}),Object.values(e.attributes).forEach(({name:t,value:e})=>{c.includes(t)||a.setAttribute(t,e)})):(Object.assign(m,e),Object.keys(m).forEach(t=>{c.includes(t)||"type"===t||a.setAttribute(t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),m[t])}));const{round:l}=t;return"circle"===o?u=L(function(t){const{cx:e,cy:n,r:r}=t;return[["M",e-r,n],["a",r,r,0,1,0,2*r,0],["a",r,r,0,1,0,-2*r,0]]}(m),l):"ellipse"===o?u=L(function(t){const{cx:e,cy:n,rx:r,ry:s}=t;return[["M",e-r,n],["a",r,s,0,1,0,2*r,0],["a",r,s,0,1,0,-2*r,0]]}(m),l):["polyline","polygon"].includes(o)?u=L(function(t){const e=[],n=(t.points||"").trim().split(/[\s|,]/).map(Number);let r=0;for(;r<n.length;)e.push([r?"L":"M",n[r],n[r+1]]),r+=2;return"polygon"===t.type?[...e,["z"]]:e}(m),l):"rect"===o?u=L(function(t){const e=+t.x||0,n=+t.y||0,r=+t.width,s=+t.height;let i=+t.rx,a=+t.ry;return i||a?(i=i||a,a=a||i,2*i>r&&(i-=(2*i-r)/2),2*a>s&&(a-=(2*a-s)/2),[["M",e+i,n],["h",r-2*i],["s",i,0,i,a],["v",s-2*a],["s",0,a,-i,a],["h",2*i-r],["s",-i,0,-i,-a],["v",2*a-s],["s",0,-a,i,-a]]):[["M",e,n],["h",r],["v",s],["H",e],["Z"]]}(m),l):"line"===o?u=L(function(t){const{x1:e,y1:n,x2:r,y2:s}=t;return[["M",e,n],["L",r,s]]}(m),l):"glyph"===o&&(u=i?e.getAttribute("d"):e.d),!!xt(u)&&(a.setAttribute("d",u),n&&i&&(e.before(a,e),e.remove()),a)},options:t};Object.assign(lt,pt,{Version:"1.0.5"});export{lt as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// SVGPathCommander v1.0.5 | thednp © 2022 | MIT-License
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).SVGPathCommander=e()}(this,(function(){"use strict";const t={origin:[0,0,0],round:4},e={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function n(t){let n=t.pathValue[t.segmentStart],r=n.toLowerCase();const{data:s}=t;for(;s.length>=e[r]&&("m"===r&&s.length>2?(t.segments.push([n,...s.splice(0,2)]),r="l",n="m"===n?"l":"L"):t.segments.push([n,...s.splice(0,e[r])]),e[r]););}const r="SVGPathCommander error";function s(t){const{index:e,pathValue:n}=t,s=n.charCodeAt(e);return 48===s?(t.param=0,void(t.index+=1)):49===s?(t.param=1,void(t.index+=1)):void(t.err=`${r}: invalid Arc flag "${n[e]}", expecting 0 or 1 at index ${e}`)}function i(t){return t>=48&&t<=57}function a(t){const{max:e,pathValue:n,index:s}=t;let a,o=s,m=!1,c=!1,u=!1,l=!1;if(o>=e)t.err=`${r}: Invalid path value at index ${o}, "pathValue" is missing param`;else if(a=n.charCodeAt(o),43!==a&&45!==a||(o+=1,a=n.charCodeAt(o)),i(a)||46===a){if(46!==a){if(m=48===a,o+=1,a=n.charCodeAt(o),m&&o<e&&a&&i(a))return void(t.err=`${r}: Invalid path value at index ${s}, "${n[s]}" illegal number`);for(;o<e&&i(n.charCodeAt(o));)o+=1,c=!0;a=n.charCodeAt(o)}if(46===a){for(l=!0,o+=1;i(n.charCodeAt(o));)o+=1,u=!0;a=n.charCodeAt(o)}if(101===a||69===a){if(l&&!c&&!u)return void(t.err=`${r}: Invalid path value at index ${o}, "${n[o]}" invalid float exponent`);if(o+=1,a=n.charCodeAt(o),43!==a&&45!==a||(o+=1),!(o<e&&i(n.charCodeAt(o))))return void(t.err=`${r}: Invalid path value at index ${o}, "${n[o]}" invalid integer exponent`);for(;o<e&&i(n.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(s,o)}else t.err=`${r}: Invalid path value at index ${o}, "${n[o]}" is not a number`}function o(t){const{pathValue:e,max:n}=t;for(;t.index<n&&(10===(r=e.charCodeAt(t.index))||13===r||8232===r||8233===r||32===r||9===r||11===r||12===r||160===r||r>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(r));)t.index+=1;var r}function m(t){return t>=48&&t<=57||43===t||45===t||46===t}function c(t){const{max:i,pathValue:c,index:u}=t,l=c.charCodeAt(u),h=e[c[u].toLowerCase()];if(t.segmentStart=u,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(l))if(t.index+=1,o(t),t.data=[],h){for(;;){for(let e=h;e>0;e-=1){if(97!=(32|l)||3!==e&&4!==e?a(t):s(t),t.err.length)return;t.data.push(t.param),o(t),t.index<i&&44===c.charCodeAt(t.index)&&(t.index+=1,o(t))}if(t.index>=t.max)break;if(!m(c.charCodeAt(t.index)))break}n(t)}else n(t);else t.err=`${r}: Invalid path value "${c[u]}" is not a path command`}function u(t){return t.map(t=>Array.isArray(t)?[...t]:t)}function l(t){this.segments=[],this.pathValue=t,this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}function h(t){return Array.isArray(t)&&t.every(t=>{const n=t[0].toLowerCase();return e[n]===t.length-1&&"achlmqstvz".includes(n)})}function f(t){if(h(t))return u(t);const e=new l(t);for(o(e);e.index<e.max&&!e.err.length;)c(e);return e.err?e.err:e.segments}function y(t){return h(t)&&t.every(([t])=>t===t.toUpperCase())}function x(t){if(y(t))return u(t);const e=f(t);let n=0,r=0,s=0,i=0;return e.map(t=>{const e=t.slice(1).map(Number),[a]=t,o=a.toUpperCase();if("M"===a)return[n,r]=e,s=n,i=r,["M",n,r];let m=[];if(a!==o)switch(o){case"A":m=[o,e[0],e[1],e[2],e[3],e[4],e[5]+n,e[6]+r];break;case"V":m=[o,e[0]+r];break;case"H":m=[o,e[0]+n];break;default:m=[o,...e.map((t,e)=>t+(e%2?r:n))]}else m=[o,...e];const c=m.length;switch(o){case"Z":n=s,r=i;break;case"H":[,n]=m;break;case"V":[,r]=m;break;default:n=m[c-2],r=m[c-1],"M"===o&&(s=n,i=r)}return m})}function p(t){return h(t)&&t.slice(1).every(([t])=>t===t.toLowerCase())}function g(t){if(p(t))return u(t);const e=f(t);let n=0,r=0,s=0,i=0;return e.map(t=>{const e=t.slice(1).map(Number),[a]=t,o=a.toLowerCase();if("M"===a)return[n,r]=e,s=n,i=r,["M",n,r];let m=[];if(a!==o)switch(o){case"a":m=[o,e[0],e[1],e[2],e[3],e[4],e[5]-n,e[6]-r];break;case"v":m=[o,e[0]-r];break;case"h":m=[o,e[0]-n];break;default:m=[o,...e.map((t,e)=>t-(e%2?r:n))]}else"m"===a&&(s=e[0]+n,i=e[1]+r),m=[o,...e];const c=m.length;switch(o){case"z":n=s,r=i;break;case"h":n+=m[1];break;case"v":r+=m[1];break;default:n+=m[c-2],r+=m[c-1]}return m})}function d(t,e,n){if(t[n].length>7){t[n].shift();const r=t[n];let s=n;for(;r.length;)e[n]="A",t.splice(s+=1,0,["C",...r.splice(0,6)]);t.splice(n,1)}}function b(t){return y(t)&&t.every(([t])=>"ACLMQZ".includes(t))}function M(t){return b(t)&&t.every(([t])=>"MC".includes(t))}function N(t,e){const[n]=t,{x1:r,y1:s,x2:i,y2:a}=e,o=t.slice(1).map(Number);let m=t;if("TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n)m=["L",t[1],s];else if("V"===n)m=["L",r,t[1]];else if("S"===n){const t=2*r-i,n=2*s-a;e.x1=t,e.y1=n,m=["C",t,n,...o]}else if("T"===n){const t=2*r-e.qx,n=2*s-e.qy;e.qx=t,e.qy=n,m=["Q",t,n,...o]}else if("Q"===n){const[t,n]=o;e.qx=t,e.qy=n}return m}const A={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function v(t){if(b(t))return u(t);const e=x(t),n={...A},r=[],s=e.length;let i="";for(let t=0;t<s;t+=1){[i]=e[t],r[t]=i,e[t]=N(e[t],n);const s=e[t],a=s.length;n.x1=+s[a-2],n.y1=+s[a-1],n.x2=+s[a-4]||n.x1,n.y2=+s[a-3]||n.y1}return e}function w(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function C(t,e,n,r,s,i,a,o,m,c){let u=t,l=e,h=n,f=r,y=o,x=m;const p=120*Math.PI/180,g=Math.PI/180*(+s||0);let d,b,M,N,A,v=[];if(c)[b,M,N,A]=c;else{d=w(u,l,-g),u=d.x,l=d.y,d=w(y,x,-g),y=d.x,x=d.y;const t=(u-y)/2,e=(l-x)/2;let n=t*t/(h*h)+e*e/(f*f);n>1&&(n=Math.sqrt(n),h*=n,f*=n);const r=h*h,s=f*f,o=(i===a?-1:1)*Math.sqrt(Math.abs((r*s-r*e*e-s*t*t)/(r*e*e+s*t*t)));N=o*h*e/f+(u+y)/2,A=o*-f*t/h+(l+x)/2,b=Math.asin(((l-A)/f*10**9>>0)/10**9),M=Math.asin(((x-A)/f*10**9>>0)/10**9),b=u<N?Math.PI-b:b,M=y<N?Math.PI-M:M,b<0&&(b=2*Math.PI+b),M<0&&(M=2*Math.PI+M),a&&b>M&&(b-=2*Math.PI),!a&&M>b&&(M-=2*Math.PI)}let S=M-b;if(Math.abs(S)>p){const t=M,e=y,n=x;M=b+p*(a&&M>b?1:-1),y=N+h*Math.cos(M),x=A+f*Math.sin(M),v=C(y,x,h,f,s,0,a,e,n,[M,t,N,A])}S=M-b;const k=Math.cos(b),P=Math.sin(b),T=Math.cos(M),$=Math.sin(M),q=Math.tan(S/4),I=4/3*h*q,V=4/3*f*q,L=[u,l],j=[u+I*P,l-V*k],O=[y+I*$,x-V*T],E=[y,x];if(j[0]=2*L[0]-j[0],j[1]=2*L[1]-j[1],c)return[...j,...O,...E,...v];v=[...j,...O,...E,...v];const z=[];for(let t=0,e=v.length;t<e;t+=1)z[t]=t%2?w(v[t-1],v[t],g).y:w(v[t],v[t+1],g).x;return z}function S(t,e,n,r,s,i){return[1/3*t+2/3*n,1/3*e+2/3*r,1/3*s+2/3*n,1/3*i+2/3*r,s,i]}function k(t,e,n){const[r,s]=t,[i,a]=e;return[r+(i-r)*n,s+(a-s)*n]}function P(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function T(t,e,n,r,s){const i=P([t,e],[n,r]);let a={x:0,y:0};if("number"==typeof s)if(s<=0)a={x:t,y:e};else if(s>=i)a={x:n,y:r};else{const[o,m]=k([t,e],[n,r],s/i);a={x:o,y:m}}return{length:i,point:a,min:{x:Math.min(t,n),y:Math.min(e,r)},max:{x:Math.max(t,n),y:Math.max(e,r)}}}function $(t,e,n,r){const s=.5,i=[t,e],a=[n,r],o=k(i,a,s),m=k(a,o,s),c=k(o,m,s),u=k(m,c,s),l=k(c,u,s),h=T(...[...i,...o,...c,...l,s]).point,f=T(...[...l,...u,...m,...a,0]).point;return[h.x,h.y,f.x,f.y,n,r]}function q(t,e){const[n]=t,r=t.slice(1).map(Number),[s,i]=r;let a;const{x1:o,y1:m,x:c,y:u}=e;switch("TQ".includes(n)||(e.qx=null,e.qy=null),n){case"M":return e.x=s,e.y=i,t;case"A":return a=[o,m,...r],["C",...C(...a)];case"Q":return e.qx=s,e.qy=i,a=[o,m,...r],["C",...S(...a)];case"L":return["C",...$(o,m,s,i)];case"Z":return["C",...$(o,m,c,u)]}return t}function I(t){if(M(t))return u(t);const e=v(t),n={...A},r=[];let s="",i=e.length;for(let t=0;t<i;t+=1){[s]=e[t],r[t]=s,e[t]=q(e[t],n),d(e,r,t),i=e.length;const a=e[t],o=a.length;n.x1=+a[o-2],n.y1=+a[o-1],n.x2=+a[o-4]||n.x1,n.y2=+a[o-3]||n.y1}return e}function V(e,n){let{round:r}=t;if("off"===n||"off"===r)return u(e);r=n>=0?n:r;const s="number"==typeof r&&r>=1?10**r:1;return e.map(t=>{const e=t.slice(1).map(Number).map(t=>r?Math.round(t*s)/s:Math.round(t));return[t[0],...e]})}function L(t,e){return V(t,e).map(t=>t[0]+t.slice(1).join(" ")).join("")}function j(t){const e=x(t),n="Z"===e.slice(-1)[0][0],r=v(e).map((t,n)=>{const[r,s]=t.slice(-2).map(Number);return{seg:e[n],n:t,c:e[n][0],x:r,y:s}}).map((t,e,r)=>{const s=t.seg,i=t.n,a=e&&r[e-1],o=r[e+1],m=t.c,c=r.length,u=e?r[e-1].x:r[c-1].x,l=e?r[e-1].y:r[c-1].y;let h=[];switch(m){case"M":h=n?["Z"]:[m,u,l];break;case"A":h=[m,...s.slice(1,-3),1===s[5]?0:1,u,l];break;case"C":h=o&&"S"===o.c?["S",s[1],s[2],u,l]:[m,s[3],s[4],s[1],s[2],u,l];break;case"S":h=!a||!"CS".includes(a.c)||o&&"S"===o.c?[m,i[1],i[2],u,l]:["C",i[3],i[4],i[1],i[2],u,l];break;case"Q":h=o&&"T"===o.c?["T",u,l]:[m,...s.slice(1,-2),u,l];break;case"T":h=!a||!"QT".includes(a.c)||o&&"T"===o.c?[m,u,l]:["Q",i[1],i[2],u,l];break;case"Z":h=["M",u,l];break;case"H":h=[m,u];break;case"V":h=[m,l];break;default:h=[m,...s.slice(1,-2),u,l]}return h});return n?r.reverse():[r[0],...r.slice(1).reverse()]}function O(t){const e=[];let n,r=-1;return t.forEach(t=>{"M"===t[0]?(n=[t],r+=1):n=[...n,t],e[r]=n}),e}function E(t,e,n,r){const[s]=t,i=t=>Math.round(1e4*t)/1e4,a=t.slice(1).map(t=>+t),o=e.slice(1).map(t=>+t),{x1:m,y1:c,x2:u,y2:l,x:h,y:f}=n;let y=t;const[x,p]=o.slice(-2);if("TQ".includes(s)||(n.qx=null,n.qy=null),["V","H","S","T","Z"].includes(s))y=[s,...a];else if("L"===s)i(h)===i(x)?y=["V",p]:i(f)===i(p)&&(y=["H",x]);else if("C"===s){const[t,e]=o;"CS".includes(r)&&(i(t)===i(2*m-u)&&i(e)===i(2*c-l)||i(m)===i(2*u-h)&&i(c)===i(2*l-f))&&(y=["S",...o.slice(-4)]),n.x1=t,n.y1=e}else if("Q"===s){const[t,e]=o;n.qx=t,n.qy=e,"QT".includes(r)&&(i(t)===i(2*m-u)&&i(e)===i(2*c-l)||i(m)===i(2*u-h)&&i(c)===i(2*l-f))&&(y=["T",...o.slice(-2)])}return y}function z(t,e){const n=x(t),r=v(n),s={...A},i=[],a=n.length;let o="",m="",c=0,u=0,l=0,h=0;for(let t=0;t<a;t+=1){[o]=n[t],i[t]=o,t&&(m=i[t-1]),n[t]=E(n[t],r[t],s,m);const e=n[t],a=e.length;switch(s.x1=+e[a-2],s.y1=+e[a-1],s.x2=+e[a-4]||s.x1,s.y2=+e[a-3]||s.y1,o){case"Z":c=l,u=h;break;case"H":[,c]=e;break;case"V":[,u]=e;break;default:[c,u]=e.slice(-2).map(Number),"M"===o&&(l=c,h=u)}s.x=c,s.y=u}const f=V(n,e),y=V(g(n),e);return f.map((t,e)=>e?t.join("").length<y[e].join("").length?t:y[e]:t)}function Z(t){const e=new K,n=Array.from(t);if(!n.every(t=>!Number.isNaN(t)))throw TypeError(`CSSMatrix: "${t}" must only have numbers.`);if(16===n.length){const[t,r,s,i,a,o,m,c,u,l,h,f,y,x,p,g]=n;e.m11=t,e.a=t,e.m21=a,e.c=a,e.m31=u,e.m41=y,e.e=y,e.m12=r,e.b=r,e.m22=o,e.d=o,e.m32=l,e.m42=x,e.f=x,e.m13=s,e.m23=m,e.m33=h,e.m43=p,e.m14=i,e.m24=c,e.m34=f,e.m44=g}else{if(6!==n.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");{const[t,r,s,i,a,o]=n;e.m11=t,e.a=t,e.m12=r,e.b=r,e.m21=s,e.c=s,e.m22=i,e.d=i,e.m41=a,e.e=a,e.m42=o,e.f=o}}return e}function Q(t){const e=Object.keys(new K);if("object"==typeof t&&e.every(e=>e in t))return Z([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]);throw TypeError(`CSSMatrix: "${JSON.stringify(t)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)}function F(t){if("string"!=typeof t)throw TypeError(`CSSMatrix: "${t}" is not a string.`);const e=String(t).replace(/\s/g,"");let n=new K;const r=`CSSMatrix: invalid transform string "${t}"`;return e.split(")").filter(t=>t).forEach(t=>{const[e,s]=t.split("(");if(!s)throw TypeError(r);const i=s.split(",").map(t=>t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)),[a,o,m,c]=i,u=[a,o,m],l=[a,o,m,c];if("perspective"===e&&a&&[o,m].every(t=>void 0===t))n.m34=-1/a;else if(e.includes("matrix")&&[6,16].includes(i.length)&&i.every(t=>!Number.isNaN(+t))){const t=i.map(t=>Math.abs(t)<1e-6?0:t);n=n.multiply(Z(t))}else if("translate3d"===e&&u.every(t=>!Number.isNaN(+t)))n=n.translate(a,o,m);else if("translate"===e&&a&&void 0===m)n=n.translate(a,o||0,0);else if("rotate3d"===e&&l.every(t=>!Number.isNaN(+t))&&c)n=n.rotateAxisAngle(a,o,m,c);else if("rotate"===e&&a&&[o,m].every(t=>void 0===t))n=n.rotate(0,0,a);else if("scale3d"===e&&u.every(t=>!Number.isNaN(+t))&&u.some(t=>1!==t))n=n.scale(a,o,m);else if("scale"!==e||Number.isNaN(a)||1===a||void 0!==m)if("skew"===e&&(a||!Number.isNaN(a)&&o)&&void 0===m)n=n.skew(a,o||0);else{if(!(/[XYZ]/.test(e)&&a&&[o,m].every(t=>void 0===t)&&["translate","rotate","scale","skew"].some(t=>e.includes(t))))throw TypeError(r);if(["skewX","skewY"].includes(e))n=n[e](a);else{const t=e.replace(/[XYZ]/,""),r=e.replace(t,""),s=["X","Y","Z"].indexOf(r),i="scale"===t?1:0,o=[0===s?a:i,1===s?a:i,2===s?a:i];n=n[t](...o)}}else{const t=Number.isNaN(+o)?a:o;n=n.scale(a,t,1)}}),n}function D(t,e){return e?[t.a,t.b,t.c,t.d,t.e,t.f]:[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]}function H(t,e,n){const r=new K;return r.m41=t,r.e=t,r.m42=e,r.f=e,r.m43=n,r}function X(t,e,n){const r=new K,s=Math.PI/180,i=t*s,a=e*s,o=n*s,m=Math.cos(i),c=-Math.sin(i),u=Math.cos(a),l=-Math.sin(a),h=Math.cos(o),f=-Math.sin(o),y=u*h,x=-u*f;r.m11=y,r.a=y,r.m12=x,r.b=x,r.m13=l;const p=c*l*h+m*f;r.m21=p,r.c=p;const g=m*h-c*l*f;return r.m22=g,r.d=g,r.m23=-c*u,r.m31=c*f-m*l*h,r.m32=c*h+m*l*f,r.m33=m*u,r}function Y(t,e,n,r){const s=new K,i=Math.sqrt(t*t+e*e+n*n);if(0===i)return s;const a=t/i,o=e/i,m=n/i,c=r*(Math.PI/360),u=Math.sin(c),l=Math.cos(c),h=u*u,f=a*a,y=o*o,x=m*m,p=1-2*(y+x)*h;s.m11=p,s.a=p;const g=2*(a*o*h+m*u*l);s.m12=g,s.b=g,s.m13=2*(a*m*h-o*u*l);const d=2*(o*a*h-m*u*l);s.m21=d,s.c=d;const b=1-2*(x+f)*h;return s.m22=b,s.d=b,s.m23=2*(o*m*h+a*u*l),s.m31=2*(m*a*h+o*u*l),s.m32=2*(m*o*h-a*u*l),s.m33=1-2*(f+y)*h,s}function B(t,e,n){const r=new K;return r.m11=t,r.a=t,r.m22=e,r.d=e,r.m33=n,r}function R(t,e){const n=new K;if(t){const e=t*Math.PI/180,r=Math.tan(e);n.m21=r,n.c=r}if(e){const t=e*Math.PI/180,r=Math.tan(t);n.m12=r,n.b=r}return n}function G(t){return R(t,0)}function J(t){return R(0,t)}function U(t,e){return Z([e.m11*t.m11+e.m12*t.m21+e.m13*t.m31+e.m14*t.m41,e.m11*t.m12+e.m12*t.m22+e.m13*t.m32+e.m14*t.m42,e.m11*t.m13+e.m12*t.m23+e.m13*t.m33+e.m14*t.m43,e.m11*t.m14+e.m12*t.m24+e.m13*t.m34+e.m14*t.m44,e.m21*t.m11+e.m22*t.m21+e.m23*t.m31+e.m24*t.m41,e.m21*t.m12+e.m22*t.m22+e.m23*t.m32+e.m24*t.m42,e.m21*t.m13+e.m22*t.m23+e.m23*t.m33+e.m24*t.m43,e.m21*t.m14+e.m22*t.m24+e.m23*t.m34+e.m24*t.m44,e.m31*t.m11+e.m32*t.m21+e.m33*t.m31+e.m34*t.m41,e.m31*t.m12+e.m32*t.m22+e.m33*t.m32+e.m34*t.m42,e.m31*t.m13+e.m32*t.m23+e.m33*t.m33+e.m34*t.m43,e.m31*t.m14+e.m32*t.m24+e.m33*t.m34+e.m34*t.m44,e.m41*t.m11+e.m42*t.m21+e.m43*t.m31+e.m44*t.m41,e.m41*t.m12+e.m42*t.m22+e.m43*t.m32+e.m44*t.m42,e.m41*t.m13+e.m42*t.m23+e.m43*t.m33+e.m44*t.m43,e.m41*t.m14+e.m42*t.m24+e.m43*t.m34+e.m44*t.m44])}class K{constructor(...t){const e=this;if(e.a=1,e.b=0,e.c=0,e.d=1,e.e=0,e.f=0,e.m11=1,e.m12=0,e.m13=0,e.m14=0,e.m21=0,e.m22=1,e.m23=0,e.m24=0,e.m31=0,e.m32=0,e.m33=1,e.m34=0,e.m41=0,e.m42=0,e.m43=0,e.m44=1,t.length){const n=[16,6].some(e=>e===t.length)?t:t[0];return e.setMatrixValue(n)}return e}get isIdentity(){const t=this;return 1===t.m11&&0===t.m12&&0===t.m13&&0===t.m14&&0===t.m21&&1===t.m22&&0===t.m23&&0===t.m24&&0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m41&&0===t.m42&&0===t.m43&&1===t.m44}get is2D(){const t=this;return 0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m43&&1===t.m44}setMatrixValue(t){return"string"==typeof t&&t.length&&"none"!==t?F(t):[Array,Float64Array,Float32Array].some(e=>t instanceof e)?Z(t):[K,DOMMatrix,Object].some(e=>t instanceof e)?Q(t):this}toFloat32Array(t){return Float32Array.from(D(this,t))}toFloat64Array(t){return Float64Array.from(D(this,t))}toString(){const{is2D:t}=this;return`${t?"matrix":"matrix3d"}(${this.toFloat64Array(t).join(", ")})`}toJSON(){const{is2D:t,isIdentity:e}=this;return{...this,is2D:t,isIdentity:e}}multiply(t){return U(this,t)}translate(t,e,n){let r=e,s=n;return void 0===r&&(r=0),void 0===s&&(s=0),U(this,H(t,r,s))}scale(t,e,n){let r=e,s=n;return void 0===r&&(r=t),void 0===s&&(s=1),U(this,B(t,r,s))}rotate(t,e,n){let r=t,s=e||0,i=n||0;return"number"==typeof t&&void 0===e&&void 0===n&&(i=r,r=0,s=0),U(this,X(r,s,i))}rotateAxisAngle(t,e,n,r){if([t,e,n,r].some(t=>Number.isNaN(+t)))throw new TypeError("CSSMatrix: expecting 4 values");return U(this,Y(t,e,n,r))}skewX(t){return U(this,G(t))}skewY(t){return U(this,J(t))}skew(t,e){return U(this,R(t,e))}transformPoint(t){const e=this,n=e.m11*t.x+e.m21*t.y+e.m31*t.z+e.m41*t.w,r=e.m12*t.x+e.m22*t.y+e.m32*t.z+e.m42*t.w,s=e.m13*t.x+e.m23*t.y+e.m33*t.z+e.m43*t.w,i=e.m14*t.x+e.m24*t.y+e.m34*t.z+e.m44*t.w;return t instanceof DOMPoint?new DOMPoint(n,r,s,i):{x:n,y:r,z:s,w:i}}}Object.assign(K,{Translate:H,Rotate:X,RotateAxisAngle:Y,Scale:B,SkewX:G,SkewY:J,Skew:R,Multiply:U,fromArray:Z,fromMatrix:Q,fromString:F,toArray:D});function W(t,e,n){const[r,s,i]=n,[a,o,m]=function(t,e){let n=H(...e);return[,,,n.m44]=e,n=t.multiply(n),[n.m41,n.m42,n.m43,n.m44]}(t,[...e,0,1]),c=o-s,u=m-i;return[(a-r)*(Math.abs(i)/Math.abs(u)||1)+r,c*(Math.abs(i)/Math.abs(u)||1)+s]}function _(e,n){let r,s,i,a,o,m,c=0,l=0;const h=x(e),f=n&&Object.keys(n);if(!n||!f.length)return u(h);const y=v(h);if(!n.origin){const{origin:e}=t;Object.assign(n,{origin:e})}const p=function(t){let e=new K;const{origin:n}=t,[r,s]=n,{translate:i}=t,{rotate:a}=t,{skew:o}=t,{scale:m}=t;return Array.isArray(i)&&i.every(t=>!Number.isNaN(+t))&&i.some(t=>0!==t)?e=e.translate(...i):"number"!=typeof i||Number.isNaN(i)||(e=e.translate(i)),(a||o||m)&&(e=e.translate(r,s),Array.isArray(a)&&a.every(t=>!Number.isNaN(+t))&&a.some(t=>0!==t)?e=e.rotate(...a):"number"!=typeof a||Number.isNaN(a)||(e=e.rotate(a)),Array.isArray(o)&&o.every(t=>!Number.isNaN(+t))&&o.some(t=>0!==t)?(e=o[0]?e.skewX(o[0]):e,e=o[1]?e.skewY(o[1]):e):"number"!=typeof o||Number.isNaN(o)||(e=e.skewX(o)),Array.isArray(m)&&m.every(t=>!Number.isNaN(+t))&&m.some(t=>1!==t)?e=e.scale(...m):"number"!=typeof m||Number.isNaN(m)||(e=e.scale(m)),e=e.translate(-r,-s)),e}(n),{origin:g}=n,b={...A};let M=[],N=0,w="",C=[];const S=[];if(!p.isIdentity){for(r=0,i=h.length;r<i;r+=1){M=h[r],h[r]&&([w]=M),S[r]=w,"A"===w&&(M=q(y[r],b),h[r]=q(y[r],b),d(h,S,r),y[r]=q(y[r],b),d(y,S,r),i=Math.max(h.length,y.length)),M=y[r],N=M.length,b.x1=+M[N-2],b.y1=+M[N-1],b.x2=+M[N-4]||b.x1,b.y2=+M[N-3]||b.y1;const t={s:h[r],c:h[r][0],x:b.x1,y:b.y1};C=[...C,t]}return C.map(t=>{switch(w=t.c,M=t.s,w){case"L":case"H":case"V":return[o,m]=W(p,[t.x,t.y],g),c!==o&&l!==m?M=["L",o,m]:l===m?M=["H",o]:c===o&&(M=["V",m]),c=o,l=m,M;default:for(s=1,a=M.length;s<a;s+=2)[c,l]=W(p,[+M[s],+M[s+1]],g),M[s]=c,M[s+1]=l;return M}})}return u(h)}function tt(t,e){const{x:n,y:r}=t,{x:s,y:i}=e,a=n*s+r*i,o=Math.sqrt((n**2+r**2)*(s**2+i**2));return(n*i-r*s<0?-1:1)*Math.acos(a/o)}function et(t,e,n,r,s,i,a,o,m,c){const{abs:u,sin:l,cos:h,sqrt:f,PI:y}=Math;let x=u(n),p=u(r);const g=(s%360+360)%360*(y/180);if(t===o&&e===m)return{x:t,y:e};if(0===x||0===p)return T(t,e,o,m,c).point;const d=(t-o)/2,b=(e-m)/2,M=h(g)*d+l(g)*b,N=-l(g)*d+h(g)*b,A=M**2/x**2+N**2/p**2;A>1&&(x*=f(A),p*=f(A));let v=(x**2*p**2-x**2*N**2-p**2*M**2)/(x**2*N**2+p**2*M**2);v=v<0?0:v;const w=(i!==a?1:-1)*f(v),C=w*(x*N/p),S=w*(-p*M/x),k=h(g)*C-l(g)*S+(t+o)/2,P=l(g)*C+h(g)*S+(e+m)/2,$={x:(M-C)/x,y:(N-S)/p},q=tt({x:1,y:0},$);let I=tt($,{x:(-M-C)/x,y:(-N-S)/p});!a&&I>0?I-=2*y:a&&I<0&&(I+=2*y),I%=2*y;const V=q+I*c,L=x*h(V),j=p*l(V);return{x:h(g)*L-l(g)*j+k,y:l(g)*L+h(g)*j+P}}function nt(t,e,n,r,s,i,a,o,m,c){const u="number"==typeof c;let l=t,h=e,f=0,y=[l,h,f],x=[l,h],p=0,g={x:0,y:0},d=[{x:l,y:h}];u&&c<=0&&(g={x:l,y:h});for(let b=0;b<=300;b+=1){if(p=b/300,({x:l,y:h}=et(t,e,n,r,s,i,a,o,m,p)),d=[...d,{x:l,y:h}],f+=P(x,[l,h]),x=[l,h],u&&f>c&&c>y[2]){const t=(f-c)/(f-y[2]);g={x:x[0]*(1-t)+y[0]*t,y:x[1]*(1-t)+y[1]*t}}y=[l,h,f]}return u&&c>=f&&(g={x:o,y:m}),{length:f,point:g,min:{x:Math.min(...d.map(t=>t.x)),y:Math.min(...d.map(t=>t.y))},max:{x:Math.max(...d.map(t=>t.x)),y:Math.max(...d.map(t=>t.y))}}}function rt(t,e,n,r,s,i,a,o,m){const c=1-m;return{x:c**3*t+3*c**2*m*n+3*c*m**2*s+m**3*a,y:c**3*e+3*c**2*m*r+3*c*m**2*i+m**3*o}}function st(t,e,n,r,s,i,a,o,m){const c="number"==typeof m;let u=t,l=e,h=0,f=[u,l,h],y=[u,l],x=0,p={x:0,y:0},g=[{x:u,y:l}];c&&m<=0&&(p={x:u,y:l});for(let d=0;d<=300;d+=1){if(x=d/300,({x:u,y:l}=rt(t,e,n,r,s,i,a,o,x)),g=[...g,{x:u,y:l}],h+=P(y,[u,l]),y=[u,l],c&&h>m&&m>f[2]){const t=(h-m)/(h-f[2]);p={x:y[0]*(1-t)+f[0]*t,y:y[1]*(1-t)+f[1]*t}}f=[u,l,h]}return c&&m>=h&&(p={x:a,y:o}),{length:h,point:p,min:{x:Math.min(...g.map(t=>t.x)),y:Math.min(...g.map(t=>t.y))},max:{x:Math.max(...g.map(t=>t.x)),y:Math.max(...g.map(t=>t.y))}}}function it(t,e,n,r,s,i,a){const o=1-a;return{x:o**2*t+2*o*a*n+a**2*s,y:o**2*e+2*o*a*r+a**2*i}}function at(t,e,n,r,s,i,a){const o="number"==typeof a;let m=t,c=e,u=0,l=[m,c,u],h=[m,c],f=0,y={x:0,y:0},x=[{x:m,y:c}];o&&a<=0&&(y={x:m,y:c});for(let p=0;p<=300;p+=1){if(f=p/300,({x:m,y:c}=it(t,e,n,r,s,i,f)),x=[...x,{x:m,y:c}],u+=P(h,[m,c]),h=[m,c],o&&u>a&&a>l[2]){const t=(u-a)/(u-l[2]);y={x:h[0]*(1-t)+l[0]*t,y:h[1]*(1-t)+l[1]*t}}l=[m,c,u]}return o&&a>=u&&(y={x:s,y:i}),{length:u,point:y,min:{x:Math.min(...x.map(t=>t.x)),y:Math.min(...x.map(t=>t.y))},max:{x:Math.max(...x.map(t=>t.x)),y:Math.max(...x.map(t=>t.y))}}}function ot(t,e){const n=v(t),r="number"==typeof e;let s,i,a,o=[],m=0,c=0,u=0,l=0,h=[],f=[],y=0,x={x:0,y:0},p=x,g=x,d=x,b=0;for(let t=0,M=n.length;t<M;t+=1)a=n[t],[i]=a,s="M"===i,o=s?o:[m,c,...a.slice(1)],s?([,u,l]=a,x={x:u,y:l},p=x,y=0,r&&e<.001&&(d=x)):"L"===i?({length:y,min:x,max:p,point:g}=T(...o,(e||0)-b)):"A"===i?({length:y,min:x,max:p,point:g}=nt(...o,(e||0)-b)):"C"===i?({length:y,min:x,max:p,point:g}=st(...o,(e||0)-b)):"Q"===i?({length:y,min:x,max:p,point:g}=at(...o,(e||0)-b)):"Z"===i&&(o=[m,c,u,l],({length:y,min:x,max:p,point:g}=T(...o,(e||0)-b))),r&&b<e&&b+y>=e&&(d=g),f=[...f,p],h=[...h,x],b+=y,[m,c]="Z"!==i?a.slice(-2):[u,l];return r&&e>=b&&(d={x:m,y:c}),{length:b,point:d,min:{x:Math.min(...h.map(t=>t.x)),y:Math.min(...h.map(t=>t.y))},max:{x:Math.max(...f.map(t=>t.x)),y:Math.max(...f.map(t=>t.y))}}}function mt(t){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};const{min:{x:e,y:n},max:{x:r,y:s}}=ot(t),i=r-e,a=s-n;return{width:i,height:a,x:e,y:n,x2:r,y2:s,cx:e+i/2,cy:n+a/2,cz:Math.max(i,a)+Math.min(i,a)/2}}function ct(t){return ot(t).length}function ut(t,e){return ot(t,e).point}Object.assign(K,{Version:"1.0.3"});class lt{constructor(e,n){const s=n||{},i=void 0===e;if(i||!e.length)throw TypeError(`${r}: "pathValue" is ${i?"undefined":"empty"}`);const a=f(e);if("string"==typeof a)throw TypeError(a);this.segments=a;const{width:o,height:m,cx:c,cy:u,cz:l}=this.getBBox(),{round:h,origin:y}=s;let x,p;if("auto"===h){const t=(""+Math.floor(Math.max(o,m))).length;x=t>=4?0:4-t}else Number.isInteger(h)||"off"===h?x=h:({round:x}=t);if(Array.isArray(y)&&y.length>=2){const[t,e,n]=y.map(Number);p=[Number.isNaN(t)?c:t,Number.isNaN(e)?u:e,Number.isNaN(n)?l:n]}else p=[c,u,l];return this.round=x,this.origin=p,this}getBBox(){return mt(this.segments)}getTotalLength(){return ct(this.segments)}getPointAtLength(t){return ut(this.segments,t)}toAbsolute(){const{segments:t}=this;return this.segments=x(t),this}toRelative(){const{segments:t}=this;return this.segments=g(t),this}toCurve(){const{segments:t}=this;return this.segments=I(t),this}reverse(t){this.toAbsolute();const{segments:e}=this,n=O(e),r=n.length>1?n:0,s=r&&u(r).map((e,n)=>t?n?j(e):f(e):j(e));let i=[];return i=r?s.flat(1):t?e:j(e),this.segments=u(i),this}normalize(){const{segments:t}=this;return this.segments=v(t),this}optimize(){const{segments:t}=this;return this.segments=z(t,this.round),this}transform(t){if(!t||"object"!=typeof t||"object"==typeof t&&!["translate","rotate","skew","scale"].some(e=>e in t))return this;const e={};Object.keys(t).forEach(n=>{e[n]=Array.isArray(t[n])?[...t[n]]:Number(t[n])});const{segments:n}=this,[r,s,i]=this.origin,{origin:a}=e;if(Array.isArray(a)&&a.length>=2){const[t,n,o]=a.map(Number);e.origin=[Number.isNaN(t)?r:t,Number.isNaN(n)?s:n,o||i]}else e.origin=[r,s,i];return this.segments=_(n,e),this}flipX(){return this.transform({rotate:[0,180,0]}),this}flipY(){return this.transform({rotate:[180,0,0]}),this}toString(){return L(this.segments,this.round)}}function ht(t){let e=0,n=0,r=0;return I(t).map(t=>{switch(t[0]){case"M":return[,e,n]=t,0;default:return r=function(t,e,n,r,s,i,a,o){return 3*((o-e)*(n+s)-(a-t)*(r+i)+r*(t-s)-n*(e-i)+o*(s+t/3)-a*(i+e/3))/20}(e,n,...t.slice(1)),[e,n]=t.slice(-2),r}}).reduce((t,e)=>t+e,0)}function ft(t,e){const n=f(t);if("string"==typeof n)throw TypeError(n);let r=[...n],s=ct(r),i=r.length-1,a=0,o=0,m=n[0];const[c,u]=m.slice(-2),l={x:c,y:u};if(i<=0||!e||!Number.isFinite(e))return{segment:m,index:0,length:o,point:l,lengthAtSegment:a};if(e>=s)return r=n.slice(0,-1),a=ct(r),o=s-a,{segment:n[i],index:i,length:o,lengthAtSegment:a};const h=[];for(;i>0;)m=r[i],r=r.slice(0,-1),a=ct(r),o=s-a,s=a,h.push({segment:m,index:i,length:o,lengthAtSegment:a}),i-=1;return h.find(({lengthAtSegment:t})=>t<=e)}function yt(t,e){const n=f(t),r=v(n),s=ct(n),i=t=>{const n=t.x-e.x,r=t.y-e.y;return n*n+r*r};let a,o,m,c,u=8,l=0,h=0,y=1/0;for(let t=0;t<=s;t+=u)a=ut(r,t),l=i(a),l<y&&(o=a,h=t,y=l);u/=2;let x=0,p=0,g=0,d=0;for(;u>.5;)x=h-u,m=ut(r,x),g=i(m),p=h+u,c=ut(r,p),d=i(c),x>=0&&g<y?(o=m,h=x,y=g):p<=s&&d<y?(o=c,h=p,y=d):u/=2;const b=ft(n,h);return{closest:o,distance:Math.sqrt(y),segment:b}}function xt(t){if("string"!=typeof t)return!1;const e=new l(t);for(o(e);e.index<e.max&&!e.err.length;)c(e);return!e.err.length&&"mM".includes(e.segments[0][0])}const pt={line:["x1","y1","x2","y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],rect:["width","height","x","y","rx","ry"],polygon:["points"],polyline:["points"],glyph:["d"]};const gt={CSSMatrix:K,parsePathString:f,isPathArray:h,isCurveArray:M,isAbsoluteArray:y,isRelativeArray:p,isNormalizedArray:b,isValidPath:xt,pathToAbsolute:x,pathToRelative:g,pathToCurve:I,pathToString:L,getDrawDirection:function(t){return ht(I(t))>=0},getPathArea:ht,getPathBBox:mt,pathLengthFactory:ot,getTotalLength:ct,getPointAtLength:ut,getClosestPoint:function(t,e){return yt(t,e).closest},getSegmentOfPoint:function(t,e){return yt(t,e).segment},getPropertiesAtPoint:yt,getPropertiesAtLength:ft,getSegmentAtLength:function(t,e){return ft(t,e).segment},isPointInStroke:function(t,e){const{distance:n}=yt(t,e);return Math.abs(n)<.001},clonePath:u,splitPath:O,fixPath:function(t){const e=f(t),n=v(e),{length:r}=e,s="Z"===n.slice(-1)[0][0],i=s?r-2:r-1,[a,o]=n[0].slice(1),[m,c]=n[i].slice(-2);return s&&a===m&&o===c?e.slice(0,-1):e},roundPath:V,optimizePath:z,reverseCurve:function(t){const e=t.slice(1).map((e,n,r)=>n?[...r[n-1].slice(-2),...e.slice(1)]:[...t[0].slice(1),...e.slice(1)]).map(t=>t.map((e,n)=>t[t.length-n-2*(1-n%2)])).reverse();return[["M",...e[0].slice(0,2)],...e.map(t=>["C",...t.slice(2)])]},reversePath:j,normalizePath:v,transformPath:_,shapeToPath:function(e,n){const s=Object.keys(pt),{tagName:i}=e;if(i&&!s.some(t=>i===t))throw TypeError(`${r}: "${i}" is not SVGElement`);const a=document.createElementNS("http://www.w3.org/2000/svg","path"),o=i||e.type,m={};m.type=o;const c=pt[o];let u;i?(c.forEach(t=>{m[t]=e.getAttribute(t)}),Object.values(e.attributes).forEach(({name:t,value:e})=>{c.includes(t)||a.setAttribute(t,e)})):(Object.assign(m,e),Object.keys(m).forEach(t=>{c.includes(t)||"type"===t||a.setAttribute(t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),m[t])}));const{round:l}=t;return"circle"===o?u=L(function(t){const{cx:e,cy:n,r:r}=t;return[["M",e-r,n],["a",r,r,0,1,0,2*r,0],["a",r,r,0,1,0,-2*r,0]]}(m),l):"ellipse"===o?u=L(function(t){const{cx:e,cy:n,rx:r,ry:s}=t;return[["M",e-r,n],["a",r,s,0,1,0,2*r,0],["a",r,s,0,1,0,-2*r,0]]}(m),l):["polyline","polygon"].includes(o)?u=L(function(t){const e=[],n=(t.points||"").trim().split(/[\s|,]/).map(Number);let r=0;for(;r<n.length;)e.push([r?"L":"M",n[r],n[r+1]]),r+=2;return"polygon"===t.type?[...e,["z"]]:e}(m),l):"rect"===o?u=L(function(t){const e=+t.x||0,n=+t.y||0,r=+t.width,s=+t.height;let i=+t.rx,a=+t.ry;return i||a?(i=i||a,a=a||i,2*i>r&&(i-=(2*i-r)/2),2*a>s&&(a-=(2*a-s)/2),[["M",e+i,n],["h",r-2*i],["s",i,0,i,a],["v",s-2*a],["s",0,a,-i,a],["h",2*i-r],["s",-i,0,-i,-a],["v",2*a-s],["s",0,-a,i,-a]]):[["M",e,n],["h",r],["v",s],["H",e],["Z"]]}(m),l):"line"===o?u=L(function(t){const{x1:e,y1:n,x2:r,y2:s}=t;return[["M",e,n],["L",r,s]]}(m),l):"glyph"===o&&(u=i?e.getAttribute("d"):e.d),!!xt(u)&&(a.setAttribute("d",u),n&&i&&(e.before(a,e),e.remove()),a)},options:t};return Object.assign(lt,gt,{Version:"1.0.5"}),lt}));
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import parsePathString from '../parser/parsePathString';
|
|
2
|
-
import clonePath from '../process/clonePath';
|
|
3
|
-
import isAbsoluteArray from '../util/isAbsoluteArray';
|
|
4
|
-
/**
|
|
5
|
-
* Parses a path string value or object and returns an array
|
|
6
|
-
* of segments, all converted to absolute values.
|
|
7
|
-
*
|
|
8
|
-
* @param {string | SVGPath.pathArray} pathInput the path string | object
|
|
9
|
-
* @returns {SVGPath.absoluteArray} the resulted `pathArray` with absolute values
|
|
10
|
-
*/
|
|
11
|
-
export default function pathToAbsolute(pathInput) {
|
|
12
|
-
/* istanbul ignore else */
|
|
13
|
-
if (isAbsoluteArray(pathInput)) {
|
|
14
|
-
// `isAbsoluteArray` checks if it's `pathArray`
|
|
15
|
-
return clonePath(pathInput);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const path = parsePathString(pathInput);
|
|
19
|
-
let x = 0; let y = 0;
|
|
20
|
-
let mx = 0; let my = 0;
|
|
21
|
-
|
|
22
|
-
// the `absoluteSegment[]` is for sure an `absolutePath`
|
|
23
|
-
return path.map((segment) => {
|
|
24
|
-
const values = segment.slice(1).map(Number);
|
|
25
|
-
const [pathCommand] = segment;
|
|
26
|
-
/** @type {SVGPath.absoluteCommand} */
|
|
27
|
-
const absCommand = pathCommand.toUpperCase();
|
|
28
|
-
|
|
29
|
-
if (pathCommand === 'M') {
|
|
30
|
-
[x, y] = values;
|
|
31
|
-
mx = x;
|
|
32
|
-
my = y;
|
|
33
|
-
return ['M', x, y];
|
|
34
|
-
}
|
|
35
|
-
/** @type {SVGPath.absoluteSegment} */
|
|
36
|
-
let absoluteSegment = [];
|
|
37
|
-
|
|
38
|
-
if (pathCommand !== absCommand) {
|
|
39
|
-
switch (absCommand) {
|
|
40
|
-
case 'A':
|
|
41
|
-
absoluteSegment = [
|
|
42
|
-
absCommand, values[0], values[1], values[2],
|
|
43
|
-
values[3], values[4], values[5] + x, values[6] + y];
|
|
44
|
-
break;
|
|
45
|
-
case 'V':
|
|
46
|
-
absoluteSegment = [absCommand, values[0] + y];
|
|
47
|
-
break;
|
|
48
|
-
case 'H':
|
|
49
|
-
absoluteSegment = [absCommand, values[0] + x];
|
|
50
|
-
break;
|
|
51
|
-
default: {
|
|
52
|
-
// use brakets for `eslint: no-case-declaration`
|
|
53
|
-
// https://stackoverflow.com/a/50753272/803358
|
|
54
|
-
const absValues = values.map((n, j) => n + (j % 2 ? y : x));
|
|
55
|
-
// for n, l, c, s, q, t
|
|
56
|
-
absoluteSegment = [absCommand, ...absValues];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
absoluteSegment = [absCommand, ...values];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const segLength = absoluteSegment.length;
|
|
64
|
-
switch (absCommand) {
|
|
65
|
-
case 'Z':
|
|
66
|
-
x = mx;
|
|
67
|
-
y = my;
|
|
68
|
-
break;
|
|
69
|
-
case 'H':
|
|
70
|
-
[, x] = absoluteSegment;
|
|
71
|
-
break;
|
|
72
|
-
case 'V':
|
|
73
|
-
[, y] = absoluteSegment;
|
|
74
|
-
break;
|
|
75
|
-
default:
|
|
76
|
-
x = absoluteSegment[segLength - 2];
|
|
77
|
-
y = absoluteSegment[segLength - 1];
|
|
78
|
-
|
|
79
|
-
if (absCommand === 'M') {
|
|
80
|
-
mx = x;
|
|
81
|
-
my = y;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return absoluteSegment;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import parsePathString from '../parser/parsePathString';
|
|
2
|
-
import clonePath from '../process/clonePath';
|
|
3
|
-
import isRelativeArray from '../util/isRelativeArray';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Parses a path string value or object and returns an array
|
|
7
|
-
* of segments, all converted to relative values.
|
|
8
|
-
*
|
|
9
|
-
* @param {string | SVGPath.pathArray} pathInput the path string | object
|
|
10
|
-
* @returns {SVGPath.relativeArray} the resulted `pathArray` with relative values
|
|
11
|
-
*/
|
|
12
|
-
export default function pathToRelative(pathInput) {
|
|
13
|
-
/* istanbul ignore else */
|
|
14
|
-
if (isRelativeArray(pathInput)) {
|
|
15
|
-
return clonePath(pathInput);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const path = parsePathString(pathInput);
|
|
19
|
-
let x = 0; let y = 0;
|
|
20
|
-
let mx = 0; let my = 0;
|
|
21
|
-
|
|
22
|
-
return path.map((segment) => {
|
|
23
|
-
const values = segment.slice(1).map(Number);
|
|
24
|
-
const [pathCommand] = segment;
|
|
25
|
-
/** @type {SVGPath.relativeCommand} */
|
|
26
|
-
const relativeCommand = pathCommand.toLowerCase();
|
|
27
|
-
|
|
28
|
-
if (pathCommand === 'M') {
|
|
29
|
-
[x, y] = values;
|
|
30
|
-
mx = x;
|
|
31
|
-
my = y;
|
|
32
|
-
return ['M', x, y];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** @type {SVGPath.relativeSegment} */
|
|
36
|
-
let relativeSegment = [];
|
|
37
|
-
|
|
38
|
-
if (pathCommand !== relativeCommand) {
|
|
39
|
-
switch (relativeCommand) {
|
|
40
|
-
case 'a':
|
|
41
|
-
relativeSegment = [
|
|
42
|
-
relativeCommand, values[0], values[1], values[2],
|
|
43
|
-
values[3], values[4], values[5] - x, values[6] - y];
|
|
44
|
-
break;
|
|
45
|
-
case 'v':
|
|
46
|
-
relativeSegment = [relativeCommand, values[0] - y];
|
|
47
|
-
break;
|
|
48
|
-
case 'h':
|
|
49
|
-
relativeSegment = [relativeCommand, values[0] - x];
|
|
50
|
-
break;
|
|
51
|
-
default: {
|
|
52
|
-
// use brakets for `eslint: no-case-declaration`
|
|
53
|
-
// https://stackoverflow.com/a/50753272/803358
|
|
54
|
-
const relValues = values.map((n, j) => n - (j % 2 ? y : x));
|
|
55
|
-
relativeSegment = [relativeCommand, ...relValues];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
if (pathCommand === 'm') {
|
|
60
|
-
mx = values[0] + x;
|
|
61
|
-
my = values[1] + y;
|
|
62
|
-
}
|
|
63
|
-
relativeSegment = [relativeCommand, ...values];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const segLength = relativeSegment.length;
|
|
67
|
-
switch (relativeCommand) {
|
|
68
|
-
case 'z':
|
|
69
|
-
x = mx;
|
|
70
|
-
y = my;
|
|
71
|
-
break;
|
|
72
|
-
case 'h':
|
|
73
|
-
x += relativeSegment[1];
|
|
74
|
-
break;
|
|
75
|
-
case 'v':
|
|
76
|
-
y += relativeSegment[1];
|
|
77
|
-
break;
|
|
78
|
-
default:
|
|
79
|
-
x += relativeSegment[segLength - 2];
|
|
80
|
-
y += relativeSegment[segLength - 1];
|
|
81
|
-
}
|
|
82
|
-
return relativeSegment;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import roundPath from '../process/roundPath';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns a valid `d` attribute string value created
|
|
5
|
-
* by rounding values and concatenating the `pathArray` segments.
|
|
6
|
-
*
|
|
7
|
-
* @param {SVGPath.pathArray} path the `pathArray` object
|
|
8
|
-
* @param {number | 'off'} round amount of decimals to round values to
|
|
9
|
-
* @returns {string} the concatenated path string
|
|
10
|
-
*/
|
|
11
|
-
export default function pathToString(path, round) {
|
|
12
|
-
return roundPath(path, round)
|
|
13
|
-
.map((x) => x[0] + x.slice(1).join(' ')).join('');
|
|
14
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** @typedef {import('../types/index')} */
|
|
2
|
-
|
|
3
|
-
import SVGPathCommander from './svg-path-commander';
|
|
4
|
-
import Util from './util/util';
|
|
5
|
-
import Version from './version';
|
|
6
|
-
|
|
7
|
-
// Export to global
|
|
8
|
-
Object.assign(SVGPathCommander, Util, { Version });
|
|
9
|
-
|
|
10
|
-
export default SVGPathCommander;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the square root of the distance
|
|
3
|
-
* between two given points.
|
|
4
|
-
*
|
|
5
|
-
* @param {[number, number]} a the first point coordinates
|
|
6
|
-
* @param {[number, number]} b the second point coordinates
|
|
7
|
-
* @returns {number} the distance value
|
|
8
|
-
*/
|
|
9
|
-
export default function distanceSquareRoot(a, b) {
|
|
10
|
-
return Math.sqrt(
|
|
11
|
-
(a[0] - b[0]) * (a[0] - b[0])
|
|
12
|
-
+ (a[1] - b[1]) * (a[1] - b[1]),
|
|
13
|
-
);
|
|
14
|
-
}
|
package/src/math/epsilon.js
DELETED
package/src/math/midPoint.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the coordinates of a specified distance
|
|
3
|
-
* ratio between two points.
|
|
4
|
-
*
|
|
5
|
-
* @param {[number, number]} a the first point coordinates
|
|
6
|
-
* @param {[number, number]} b the second point coordinates
|
|
7
|
-
* @param {number} t the ratio
|
|
8
|
-
* @returns {[number, number]} the midpoint coordinates
|
|
9
|
-
*/
|
|
10
|
-
export default function midPoint(a, b, t) {
|
|
11
|
-
const [ax, ay] = a; const [bx, by] = b;
|
|
12
|
-
return [ax + (bx - ax) * t, ay + (by - ay) * t];
|
|
13
|
-
}
|
package/src/math/rotateVector.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns an {x,y} vector rotated by a given
|
|
3
|
-
* angle in radian.
|
|
4
|
-
*
|
|
5
|
-
* @param {number} x the initial vector x
|
|
6
|
-
* @param {number} y the initial vector y
|
|
7
|
-
* @param {number} rad the radian vector angle
|
|
8
|
-
* @returns {{x: number, y: number}} the rotated vector
|
|
9
|
-
*/
|
|
10
|
-
export default function rotateVector(x, y, rad) {
|
|
11
|
-
const X = x * Math.cos(rad) - y * Math.sin(rad);
|
|
12
|
-
const Y = x * Math.sin(rad) + y * Math.cos(rad);
|
|
13
|
-
return { x: X, y: Y };
|
|
14
|
-
}
|
package/src/options/options.js
DELETED
package/src/parser/error.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import paramsCount from './paramsCount';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Breaks the parsing of a pathString once a segment is finalized.
|
|
5
|
-
*
|
|
6
|
-
* @param {SVGPath.PathParser} path the `PathParser` instance
|
|
7
|
-
*/
|
|
8
|
-
export default function finalizeSegment(path) {
|
|
9
|
-
let pathCommand = path.pathValue[path.segmentStart];
|
|
10
|
-
let LK = pathCommand.toLowerCase();
|
|
11
|
-
const { data } = path;
|
|
12
|
-
|
|
13
|
-
while (data.length >= paramsCount[LK]) {
|
|
14
|
-
// overloaded `moveTo`
|
|
15
|
-
// https://github.com/rveciana/svg-path-properties/blob/master/src/parse.ts
|
|
16
|
-
if (LK === 'm' && data.length > 2) {
|
|
17
|
-
path.segments.push([pathCommand, ...data.splice(0, 2)]);
|
|
18
|
-
LK = 'l';
|
|
19
|
-
pathCommand = pathCommand === 'm' ? 'l' : 'L';
|
|
20
|
-
} else {
|
|
21
|
-
path.segments.push([pathCommand, ...data.splice(0, paramsCount[LK])]);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (!paramsCount[LK]) {
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
package/src/parser/isDigit.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the character is or belongs to a number.
|
|
3
|
-
* [0-9]|+|-|.
|
|
4
|
-
*
|
|
5
|
-
* @param {number} code the character to check
|
|
6
|
-
* @returns {boolean} check result
|
|
7
|
-
*/
|
|
8
|
-
export default function isDigitStart(code) {
|
|
9
|
-
return (code >= 48 && code <= 57) /* 0..9 */
|
|
10
|
-
|| code === 0x2B /* + */
|
|
11
|
-
|| code === 0x2D /* - */
|
|
12
|
-
|| code === 0x2E; /* . */
|
|
13
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the character is a path command.
|
|
3
|
-
*
|
|
4
|
-
* @param {any} code the character to check
|
|
5
|
-
* @returns {boolean} check result
|
|
6
|
-
*/
|
|
7
|
-
export default function isPathCommand(code) {
|
|
8
|
-
// eslint-disable-next-line no-bitwise -- Impossible to satisfy
|
|
9
|
-
switch (code | 0x20) {
|
|
10
|
-
case 0x6D/* m */:
|
|
11
|
-
case 0x7A/* z */:
|
|
12
|
-
case 0x6C/* l */:
|
|
13
|
-
case 0x68/* h */:
|
|
14
|
-
case 0x76/* v */:
|
|
15
|
-
case 0x63/* c */:
|
|
16
|
-
case 0x73/* s */:
|
|
17
|
-
case 0x71/* q */:
|
|
18
|
-
case 0x74/* t */:
|
|
19
|
-
case 0x61/* a */:
|
|
20
|
-
// case 0x72/* r */:
|
|
21
|
-
return true;
|
|
22
|
-
default:
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
package/src/parser/isSpace.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the character is a space.
|
|
3
|
-
*
|
|
4
|
-
* @param {number} ch the character to check
|
|
5
|
-
* @returns {boolean} check result
|
|
6
|
-
*/
|
|
7
|
-
export default function isSpace(ch) {
|
|
8
|
-
const specialSpaces = [
|
|
9
|
-
0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006,
|
|
10
|
-
0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
|
|
11
|
-
/* istanbul ignore next */
|
|
12
|
-
return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029) // Line terminators
|
|
13
|
-
// White spaces
|
|
14
|
-
|| (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0)
|
|
15
|
-
|| (ch >= 0x1680 && specialSpaces.includes(ch));
|
|
16
|
-
}
|
package/src/parser/pathParser.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `PathParser` is used by the `parsePathString` static method
|
|
3
|
-
* to generate a `pathArray`.
|
|
4
|
-
*
|
|
5
|
-
* @param {string} pathString
|
|
6
|
-
*/
|
|
7
|
-
export default function PathParser(pathString) {
|
|
8
|
-
/** @type {SVGPath.pathArray} */
|
|
9
|
-
this.segments = [];
|
|
10
|
-
/** @type {string} */
|
|
11
|
-
this.pathValue = pathString;
|
|
12
|
-
/** @type {number} */
|
|
13
|
-
this.max = pathString.length;
|
|
14
|
-
/** @type {number} */
|
|
15
|
-
this.index = 0;
|
|
16
|
-
/** @type {number} */
|
|
17
|
-
this.param = 0.0;
|
|
18
|
-
/** @type {number} */
|
|
19
|
-
this.segmentStart = 0;
|
|
20
|
-
/** @type {any} */
|
|
21
|
-
this.data = [];
|
|
22
|
-
/** @type {string} */
|
|
23
|
-
this.err = '';
|
|
24
|
-
}
|
package/src/process/clonePath.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a clone of an existing `pathArray`.
|
|
3
|
-
*
|
|
4
|
-
* @param {SVGPath.pathArray | SVGPath.pathSegment} path the source `pathArray`
|
|
5
|
-
* @returns {any} the cloned `pathArray`
|
|
6
|
-
*/
|
|
7
|
-
export default function clonePath(path) {
|
|
8
|
-
return path.map((x) => (Array.isArray(x) ? [...x] : x));
|
|
9
|
-
}
|
package/src/process/fixArc.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Splits an extended A (arc-to) segment into two cubic-bezier segments.
|
|
3
|
-
*
|
|
4
|
-
* @param {SVGPath.pathArray} path the `pathArray` this segment belongs to
|
|
5
|
-
* @param {string[]} allPathCommands all previous path commands
|
|
6
|
-
* @param {number} i the segment index
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export default function fixArc(path, allPathCommands, i) {
|
|
10
|
-
if (path[i].length > 7) {
|
|
11
|
-
path[i].shift();
|
|
12
|
-
const segment = path[i];
|
|
13
|
-
let ni = i; // ESLint
|
|
14
|
-
while (segment.length) {
|
|
15
|
-
// if created multiple C:s, their original seg is saved
|
|
16
|
-
allPathCommands[i] = 'A';
|
|
17
|
-
path.splice(ni += 1, 0, ['C', ...segment.splice(0, 6)]);
|
|
18
|
-
}
|
|
19
|
-
path.splice(i, 1);
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/process/fixPath.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import parsePathString from '../parser/parsePathString';
|
|
2
|
-
import normalizePath from './normalizePath';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Checks a `pathArray` for an unnecessary `Z` segment
|
|
6
|
-
* and returns a new `pathArray` without it.
|
|
7
|
-
*
|
|
8
|
-
* The `pathInput` must be a single path, without
|
|
9
|
-
* sub-paths. For multi-path `<path>` elements,
|
|
10
|
-
* use `splitPath` first and apply this utility on each
|
|
11
|
-
* sub-path separately.
|
|
12
|
-
*
|
|
13
|
-
* @param {SVGPath.pathArray | string} pathInput the `pathArray` source
|
|
14
|
-
* @return {SVGPath.pathArray} a fixed `pathArray`
|
|
15
|
-
*/
|
|
16
|
-
export default function fixPath(pathInput) {
|
|
17
|
-
const pathArray = parsePathString(pathInput);
|
|
18
|
-
const normalArray = normalizePath(pathArray);
|
|
19
|
-
const { length } = pathArray;
|
|
20
|
-
const isClosed = normalArray.slice(-1)[0][0] === 'Z';
|
|
21
|
-
const segBeforeZ = isClosed ? length - 2 : length - 1;
|
|
22
|
-
|
|
23
|
-
const [mx, my] = normalArray[0].slice(1);
|
|
24
|
-
const [x, y] = normalArray[segBeforeZ].slice(-2);
|
|
25
|
-
|
|
26
|
-
/* istanbul ignore else */
|
|
27
|
-
if (isClosed && mx === x && my === y) {
|
|
28
|
-
return pathArray.slice(0, -1);
|
|
29
|
-
}
|
|
30
|
-
return pathArray;
|
|
31
|
-
}
|