(function(r,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(r=typeof globalThis<"u"?globalThis:r||self,r.GrahamScan=i())})(this,function(){"use strict";var N=Object.defineProperty;var T=(r,i,y)=>i in r?N(r,i,{enumerable:!0,configurable:!0,writable:!0,value:y}):r[i]=y;var m=(r,i,y)=>(T(r,typeof i!="symbol"?i+"":i,y),y);const r=Number.parseFloat("0.000005");class i{constructor(){m(this,"vertices",[])}setVertices(e){this.vertices=e}static isValid(e){return e!=null&&isFinite(e)&&!isNaN(e)}getStartingHullPoint(){let e=-1;for(let c=0;c!(n.x===t.x&&n.y===t.y)&&i.isValid(n.x)&&i.isValid(n.y));d.sort((n,s)=>h*(s.x-t.x)*(n.y-t.y)-h*(n.x-t.x)*(s.y-t.y));const p=n=>{let s=x.length;for(;s>1&&h*i.ccw(x[s-2],x[s-1],n){let s;V?(s=1,V=!1):n?s=-1:s=0,f===-1&&s!==0?l.sort((o,u)=>s*((o.x-t.x)**2+(o.y-t.y)**2)-s*((u.x-t.x)**2+(u.y-t.y)**2)):f!==-1&&(l=[l.reduce((o,u)=>(o.x-t.x)**2+(o.y-t.y)**2>(u.x-t.x)**2+(u.y-t.y)**2?o:u)])};for(let n=0;np(a))}l=[s]}return b(!0),l==null||l.forEach(n=>p(n)),x}}return i});