/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/shape-points@3.0.4/dist/shape-points.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t=t||self).ShapePoints={})}(this,(function(t){"use strict";function r(t,r,n,e,o,u){const a=[];let i=n;const s=(e-n)/((u=u>1?u:5)-1);for(let n=0;n<u;n++)a.push(t+o*Math.cos(i),r+o*Math.sin(i)),i+=s;return a}function n(t,r,n,e,o,u,a,i,s){const f=[],c=1/(s=s||5);for(let s=0;s<=1;s+=c){const c=Math.pow(1-s,3),h=3*s*Math.pow(1-s,2),m=3*Math.pow(s,2)*(1-s),l=Math.pow(s,3);f.push(c*t+h*n+m*o+l*a,c*r+h*e+m*u+l*i)}return f}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var e=function(t,r){return t(r={exports:{}},r.exports),r.exports}((function(t,r){!function(t){function r(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}
/**
         *  @preserve  JavaScript implementation of
         *  Algorithm for Automatically Fitting Digitized Curves
         *  by Philip J. Schneider
         *  "Graphics Gems", Academic Press, 1990
         *
         *  The MIT License (MIT)
         *
         *  https://github.com/soswow/fit-curves
         */function n(t,r,n,e,o,i){var c,h,m,l=function(t,r,n){var e,o,i,c,h,m,l,p;o=0,i=Math.floor(t.length/2);var d=u(r,10);for(h=0,m=t.length;h<m;h++)l=t[h],p=a(0,n[h],d,10),c=s.subtract(f.q(r,p),l),(e=c[0]*c[0]+c[1]*c[1])>o&&(o=e,i=h);return[o,i]}(t,c=function(t,r,n,e){var o,u,a,i,c,h,m,l,p,d,b,M,I,g,y,v,A,L=t[0],P=t[t.length-1];for(o=[L,null,null,P],u=s.zeros_Xx2x2(r.length),I=0,g=r.length;I<g;I++)v=r[I],A=1-v,(a=u[I])[0]=s.mulItems(n,3*v*(A*A)),a[1]=s.mulItems(e,3*A*(v*v));for(i=[[0,0],[0,0]],c=[0,0],I=0,g=t.length;I<g;I++)v=r[I],a=u[I],i[0][0]+=s.dot(a[0],a[0]),i[0][1]+=s.dot(a[0],a[1]),i[1][0]+=s.dot(a[0],a[1]),i[1][1]+=s.dot(a[1],a[1]),y=s.subtract(t[I],f.q([L,L,P,P],v)),c[0]+=s.dot(a[0],y),c[1]+=s.dot(a[1],y);return h=i[0][0]*i[1][1]-i[1][0]*i[0][1],m=i[0][0]*c[1]-i[1][0]*c[0],l=c[0]*i[1][1]-c[1]*i[0][1],p=0===h?0:l/h,d=0===h?0:m/h,M=s.vectorLen(s.subtract(L,P)),p<(b=1e-6*M)||d<b?(o[1]=s.addArrays(L,s.mulItems(n,M/3)),o[2]=s.addArrays(P,s.mulItems(e,M/3))):(o[1]=s.addArrays(L,s.mulItems(n,p)),o[2]=s.addArrays(P,s.mulItems(e,d))),o}(t,n,e,o),r);return h=l[0],m=l[1],i&&i({bez:c,points:t,params:r,maxErr:h,maxPoint:m}),[c,h,m]}function e(t,r,n){return n.map((function(n,e){return o(t,r[e],n)}))}function o(t,r,n){var e=s.subtract(f.q(t,n),r),o=f.qprime(t,n),u=s.mulMatrix(e,o),a=s.sum(s.squareItems(o))+2*s.mulMatrix(e,f.qprimeprime(t,n));return 0===a?n:n-u/a}var u=function(t,r){for(var n,e=[0],o=t[0],u=0,a=1;a<=r;a++)n=f.q(t,a/r),u+=s.vectorLen(s.subtract(n,o)),e.push(u),o=n;return e=e.map((function(t){return t/u}))};function a(t,r,n,e){if(r<0)return 0;if(r>1)return 1;for(var o,u,a,i,s=1;s<=e;s++)if(r<=n[s]){a=(s-1)/e,u=s/e,i=(r-(o=n[s-1]))/(n[s]-o)*(u-a)+a;break}return i}function i(t,r){return s.normalize(s.subtract(t,r))}var s=function(){function t(){r(this,t)}return t.zeros_Xx2x2=function(t){for(var r=[];t--;)r.push([0,0]);return r},t.mulItems=function(t,r){return t.map((function(t){return t*r}))},t.mulMatrix=function(t,r){return t.reduce((function(t,n,e){return t+n*r[e]}),0)},t.subtract=function(t,r){return t.map((function(t,n){return t-r[n]}))},t.addArrays=function(t,r){return t.map((function(t,n){return t+r[n]}))},t.addItems=function(t,r){return t.map((function(t){return t+r}))},t.sum=function(t){return t.reduce((function(t,r){return t+r}))},t.dot=function(r,n){return t.mulMatrix(r,n)},t.vectorLen=function(t){return Math.hypot.apply(Math,t)},t.divItems=function(t,r){return t.map((function(t){return t/r}))},t.squareItems=function(t){return t.map((function(t){return t*t}))},t.normalize=function(t){return this.divItems(t,this.vectorLen(t))},t}(),f=function(){function t(){r(this,t)}return t.q=function(t,r){var n=1-r,e=s.mulItems(t[0],n*n*n),o=s.mulItems(t[1],3*n*n*r),u=s.mulItems(t[2],3*n*r*r),a=s.mulItems(t[3],r*r*r);return s.addArrays(s.addArrays(e,o),s.addArrays(u,a))},t.qprime=function(t,r){var n=1-r,e=s.mulItems(s.subtract(t[1],t[0]),3*n*n),o=s.mulItems(s.subtract(t[2],t[1]),6*n*r),u=s.mulItems(s.subtract(t[3],t[2]),3*r*r);return s.addArrays(s.addArrays(e,o),u)},t.qprimeprime=function(t,r){return s.addArrays(s.mulItems(s.addArrays(s.subtract(t[2],s.mulItems(t[1],2)),t[0]),6*(1-r)),s.mulItems(s.addArrays(s.subtract(t[3],s.mulItems(t[2],2)),t[1]),6*r))},t}();t.exports=function(t,r,o){if(!Array.isArray(t))throw new TypeError("First argument should be an array");if(t.forEach((function(r){if(!Array.isArray(r)||r.some((function(t){return"number"!=typeof t}))||r.length!==t[0].length)throw Error("Each point should be an array of numbers. Each point should have the same amount of numbers.")})),(t=t.filter((function(r,n){return 0===n||!r.every((function(r,e){return r===t[n-1][e]}))}))).length<2)return[];var u=t.length,a=i(t[1],t[0]),f=i(t[u-2],t[u-1]);return function t(r,o,u,a,i){var f,c,h,m,l,p,d,b,M,I,g,y,v;if(2===r.length)return y=s.vectorLen(s.subtract(r[0],r[1]))/3,[f=[r[0],s.addArrays(r[0],s.mulItems(o,y)),s.addArrays(r[1],s.mulItems(u,y)),r[1]]];c=function(t){var r,n,e,o=[];return t.forEach((function(t,u){r=u?n+s.vectorLen(s.subtract(t,e)):0,o.push(r),n=r,e=t})),o=o.map((function(t){return t/n}))}(r);var A=n(r,c,c,o,u,i);if(f=A[0],m=A[1],p=A[2],0===m||m<a)return[f];if(m<a*a)for(h=c,l=m,d=p,v=0;v<20;v++){h=e(f,r,h);var L=n(r,c,h,o,u,i);if(f=L[0],m=L[1],p=L[2],m<a)return[f];if(p===d){var P=m/l;if(P>.9999&&P<1.0001)break}l=m,d=p}if(g=[],(b=s.subtract(r[p-1],r[p+1])).every((function(t){return 0===t}))){var x=[-(b=s.subtract(r[p-1],r[p]))[1],b[0]];b[0]=x[0],b[1]=x[1]}return M=s.normalize(b),I=s.mulItems(M,-1),g=(g=g.concat(t(r.slice(0,p+1),o,M,a,i))).concat(t(r.slice(p),I,u,a,i))}(t,a,f,r,o)}}(t)}));t.arc=r,t.bezierCurveThrough=function(){let t=5,r=50;const o=[];if(Array.isArray(arguments[0])){const n=arguments[0];for(let t=0;t<n.length;t+=2)o.push([n[t],n[t+1]]);2===arguments.length&&(t=arguments[1].pointsInArc,r=arguments[1].curveError)}else{let n=arguments.length;arguments.length%2==1&&(n--,t=arguments[n].pointsInArc,r=arguments[n].curveError);for(let t=0;t<n;t+=2)o.push([arguments[t],arguments[t+1]])}if(2===o.length)return[o[0][0],o[0][1],o[1][0],o[1][1]];if(o.length<4)return[];const u=[],a=e(o,r);for(let r=0;r<a.length;r++){const e=a[r];u.push(...n(e[0][0],e[0][1],e[1][0],e[1][1],e[2][0],e[2][1],e[3][0],e[3][1],t))}return u},t.bezierCurveTo=n,t.circle=function(t,r,n,e){e=e||5;const o=[],u=2*Math.PI/(4*e);for(let e=0;e<2*Math.PI;e+=u)o.push(t+Math.cos(e)*n,r+Math.sin(e)*n);return o},t.ellipse=function(t,r,n,e,o){o=o||5;const u=[],a=2*Math.PI/(4*o);for(let o=0;o<2*Math.PI;o+=a)u.push(t-n*Math.sin(o),r-e*Math.cos(o));return u},t.line=function(t,r,n,e,o){o=o||0;const u=Math.atan2(e-r,n-t)-Math.PI/2,a=isNaN(o)?{start:o.start/2,end:o.end/2}:{start:o/2,end:o/2};return[t-Math.cos(u)*a.start,r-Math.sin(u)*a.start,n-Math.cos(u)*a.end,e-Math.sin(u)*a.end,n+Math.cos(u)*a.end,e+Math.sin(u)*a.end,t+Math.cos(u)*a.start,r+Math.sin(u)*a.start]},t.quadraticCurveTo=function(t,r,n,e,o,u,a){const i=[],s=1/(a=a||5);for(let a=0;a<=1;a+=s){const s=Math.pow(1-a,2),f=2*a*(1-a),c=Math.pow(a,2);i.push(s*t+f*n+c*o,s*r+f*e+c*u)}return i},t.rect=function(t,r,n,e){return[t-n/2,r-e/2,t+n/2,r-e/2,t+n/2,r+e/2,t-n/2,r+e/2]},t.roundedRect=function(t,n,e,o,u,a){if(a=a||5,isNaN(u)){u.topLeft=u.topLeft||0,u.topRight=u.topRight||0,u.bottomLeft=u.bottomLeft||0,u.bottomRight=u.bottomRight||0;const i=[t-e/2+u.topLeft,n-o/2,t+e/2-u.topRight,n-o/2];return u.topRight&&i.push(...r(t+e/2-u.topRight,n-o/2+u.topRight,3*Math.PI/2,2*Math.PI,u.topRight,a)),i.push(t+e/2,n-o/2+u.topRight,t+e/2,n+o/2-u.bottomRight),u.bottomRight&&i.push(...r(t+e/2-u.bottomRight,n+o/2-u.bottomRight,0,Math.PI/2,u.bottomRight,a)),i.push(t+e/2-u.bottomRight,n+o/2,t-e/2+u.bottomLeft,n+o/2),u.bottomLeft&&i.push(...r(t-e/2+u.bottomLeft,n+o/2-u.bottomLeft,Math.PI/2,Math.PI,u.bottomLeft,a)),i.push(t-e/2,n+o/2-u.bottomLeft,t-e/2,n-o/2+u.topLeft),u.topLeft&&i.push(...r(t-e/2+u.topLeft,n-o/2+u.topLeft,Math.PI,3*Math.PI/2,u.topLeft,a)),i}return[t-e/2+u,n-o/2,t+e/2-u,n-o/2,...r(t+e/2-u,n-o/2+u,3*Math.PI/2,2*Math.PI,u,a),t+e/2,n-o/2+u,t+e/2,n+o/2-u,...r(t+e/2-u,n+o/2-u,0,Math.PI/2,u,a),t+e/2-u,n+o/2,t-e/2+u,n+o/2,...r(t-e/2+u,n+o/2-u,Math.PI/2,Math.PI,u,a),t-e/2,n+o/2-u,t-e/2,n-o/2+u,...r(t-e/2+u,n-o/2+u,Math.PI,3*Math.PI/2,u,a)]},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=shape-points.js.map
