/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../core/mathUtils"],(function(t,e){"use strict";function n(t,n,f){var u;const c=t.byteLength/(4*n),s=new Uint32Array(t,0,c*n);let a=new Uint32Array(c);const d=null!=(u=null==f?void 0:f.minReduction)?u:0,h=(null==f?void 0:f.originalIndices)||null,g=h?h.length:0,w=(null==f?void 0:f.componentOffsets)||null;let y=0;if(w)for(let e=0;e<w.length-1;e++){const t=w[e+1]-w[e];t>y&&(y=t)}else y=c;const U=Math.floor(1.1*y)+1;(null==i||i.length<2*U)&&(i=new Uint32Array(e.nextHighestPowerOfTwo(2*U)));for(let e=0;e<2*U;e++)i[e]=0;let b=0;const v=!!w&&!!h,A=v?g:c,M=v?new Uint32Array(g):null,m=1.96;let p=0!==d?Math.ceil(4*m*m/(d*d)*d*(1-d)):A,O=1,q=w?w[1]:A;for(let e=0;e<A;e++){if(e===p){const t=1-b/e;if(t+m*Math.sqrt(t*(1-t)/e)<d)return null;p*=2}if(e===q){for(let t=0;t<2*U;t++)i[t]=0;if(h)for(let t=w[O-1];t<w[O];t++)M[t]=a[h[t]];q=w[++O]}const t=v?h[e]:e,r=t*n,f=o(s,r,n);let u=f%U,c=b;for(;0!==i[2*u+1];){if(i[2*u]===f){const t=i[2*u+1]-1;if(l(s,r,t*n,n)){c=a[t];break}}u++,u>=U&&(u-=U)}c===b&&(i[2*u]=f,i[2*u+1]=t+1,b++),a[t]=c}if(0!==d&&1-b/c<d)return null;if(v){for(let t=w[O-1];t<M.length;t++)M[t]=a[h[t]];a=M}const x=new Uint32Array(n*b);b=0;for(let e=0;e<A;e++)if(a[e]===b){r(s,(v?h[e]:e)*n,x,b*n,n),b++}if(h&&!v){const t=new Uint32Array(g);for(let e=0;e<t.length;e++)t[e]=a[h[e]];a=t}return{buffer:x.buffer,indices:a,uniqueCount:b}}function l(t,e,n,l){for(let r=0;r<l;r++)if(t[e+r]!==t[n+r])return!1;return!0}function r(t,e,n,l,r){for(let o=0;o<r;o++)n[l+o]=t[e+o]}function o(t,e,n){let l=0;for(let r=0;r<n;r++)l=t[e+r]+l|0,l=l+(l<<11)+(l>>>2)|0;return l>>>0}let i=null;t.deduplicate=n,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
