export function normalize(a){const t=[];let e="",s=0,c=0,o=0,h=0,n=0,r=0;for(const{key:M,data:u}of a){switch(M){case"M":t.push({key:"M",data:[...u]}),[s,c]=u,[o,h]=u;break;case"C":t.push({key:"C",data:[...u]}),s=u[4],c=u[5],n=u[2],r=u[3];break;case"L":t.push({key:"L",data:[...u]}),[s,c]=u;break;case"H":s=u[0],t.push({key:"L",data:[s,c]});break;case"V":c=u[0],t.push({key:"L",data:[s,c]});break;case"S":{let a=0,o=0;"C"===e||"S"===e?(a=s+(s-n),o=c+(c-r)):(a=s,o=c),t.push({key:"C",data:[a,o,...u]}),n=u[0],r=u[1],s=u[2],c=u[3];break}case"T":{const[a,o]=u;let h=0,M=0;"Q"===e||"T"===e?(h=s+(s-n),M=c+(c-r)):(h=s,M=c);const i=s+2*(h-s)/3,k=c+2*(M-c)/3,b=a+2*(h-a)/3,d=o+2*(M-o)/3;t.push({key:"C",data:[i,k,b,d,a,o]}),n=h,r=M,s=a,c=o;break}case"Q":{const[a,e,o,h]=u,M=s+2*(a-s)/3,i=c+2*(e-c)/3,k=o+2*(a-o)/3,b=h+2*(e-h)/3;t.push({key:"C",data:[M,i,k,b,o,h]}),n=a,r=e,s=o,c=h;break}case"A":{const a=Math.abs(u[0]),e=Math.abs(u[1]),o=u[2],h=u[3],n=u[4],r=u[5],M=u[6];if(0===a||0===e)t.push({key:"C",data:[s,c,r,M,r,M]}),s=r,c=M;else if(s!==r||c!==M){arcToCubicCurves(s,c,r,M,a,e,o,h,n).forEach((function(a){t.push({key:"C",data:a})})),s=r,c=M}break}case"Z":t.push({key:"Z",data:[]}),s=o,c=h}e=M}return t}function rotate(a,t,e){return[a*Math.cos(e)-t*Math.sin(e),a*Math.sin(e)+t*Math.cos(e)]}function arcToCubicCurves(a,t,e,s,c,o,h,n,r,M){const u=function degToRad(a){return Math.PI*a/180}(h);let i=[],k=0,b=0,d=0,p=0;if(M)[k,b,d,p]=M;else{[a,t]=rotate(a,t,-u),[e,s]=rotate(e,s,-u);const h=(a-e)/2,M=(t-s)/2;let i=h*h/(c*c)+M*M/(o*o);i>1&&(i=Math.sqrt(i),c*=i,o*=i);const f=c*c,C=o*o,l=f*C-f*M*M-C*h*h,y=f*M*M+C*h*h,I=(n===r?-1:1)*Math.sqrt(Math.abs(l/y));d=I*c*M/o+(a+e)/2,p=I*-o*h/c+(t+s)/2,k=Math.asin(parseFloat(((t-p)/o).toFixed(9))),b=Math.asin(parseFloat(((s-p)/o).toFixed(9))),a<d&&(k=Math.PI-k),e<d&&(b=Math.PI-b),k<0&&(k=2*Math.PI+k),b<0&&(b=2*Math.PI+b),r&&k>b&&(k-=2*Math.PI),!r&&b>k&&(b-=2*Math.PI)}let f=b-k;if(Math.abs(f)>120*Math.PI/180){const a=b,t=e,n=s;b=r&&b>k?k+120*Math.PI/180*1:k+120*Math.PI/180*-1,i=arcToCubicCurves(e=d+c*Math.cos(b),s=p+o*Math.sin(b),t,n,c,o,h,0,r,[b,a,d,p])}f=b-k;const C=Math.cos(k),l=Math.sin(k),y=Math.cos(b),I=Math.sin(b),P=Math.tan(f/4),T=4/3*c*P,F=4/3*o*P,L=[a,t],v=[a+T*l,t-F*C],x=[e+T*I,s-F*y],g=[e,s];if(v[0]=2*L[0]-v[0],v[1]=2*L[1]-v[1],M)return[v,x,g].concat(i);{i=[v,x,g].concat(i);const a=[];for(let t=0;t<i.length;t+=3){const e=rotate(i[t][0],i[t][1],u),s=rotate(i[t+1][0],i[t+1][1],u),c=rotate(i[t+2][0],i[t+2][1],u);a.push([e[0],e[1],s[0],s[1],c[0],c[1]])}return a}}