/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{nativeArrayMaxSize as r,isTypedArray as n}from"../../core/typedArrayUtil.js";function t(r){return e(r,!0)}function e(t,e){if(Array.isArray(t)){if(t.length<r)return t}else if(t.length<r)return Array.from(t);let i=!0,a=!0;return t.some((r,n)=>(i=i&&0===r,a=a&&r===n,!i&&!a)),i?c(t.length):a?l(t.length):n(t)&&t.BYTES_PER_ELEMENT===Uint16Array.BYTES_PER_ELEMENT?t:f(t,!e)}function i(n,t){return n.length<r?Array.from(n):t<256?Uint8Array.from(n):t<65536?Uint16Array.from(n):Uint32Array.from(n)}function f(r,t){for(const e of r){if(e>=65536)return n(r)?r:new Uint32Array(r);e>=256&&(t=!1)}return t?new Uint8Array(r):new Uint16Array(r)}function a(n){return n<=r?new Array(n):n<=65536?new Uint16Array(n):new Uint32Array(n)}function u(n){return n<=r?new Array(n):new Uint32Array(n)}let y=h(131072);const o=[0],A=(()=>{const r=new Uint16Array(65536);for(let n=0;n<r.length;++n)r[n]=n;return r})();function l(n){return 1===n?o:n<r?Array.from(new Uint16Array(A.buffer,0,n)):n<A.length?new Uint16Array(A.buffer,0,n):(n>y.length&&(y=h(Math.max(2*y.length,n))),new Uint32Array(y.buffer,0,n))}function U(n){return 1===n?[0]:n<r?Array.from(new Uint16Array(A.buffer,0,n)):n<A.length?new Uint16Array(A.buffer,0,n).slice():(n>y.length&&(y=h(Math.max(2*y.length,n))),new Uint32Array(y.buffer,0,n).slice())}function h(r){const n=new Uint32Array(r);for(let t=0;t<n.length;t++)n[t]=t;return n}let w=new Uint8Array(65536);function c(n){if(1===n)return o;if(n<r)return new Array(n).fill(0);if(n>w.length){const r=Math.max(2*w.length,n);w=new Uint8Array(r)}return new Uint8Array(w.buffer,0,n)}function g(){y=h(131072),w=new Uint8Array(65536)}function m(r){return"byteLength"in r?r.byteLength:8*r.length}export{e as compactIndices,t as compactMeshIndices,l as getContinuousIndexArray,c as getZeroIndexArray,m as indexArrayByteSize,i as indexArrayFrom,U as newContinuousIndexArray,a as newIndexArray,u as newIntArray,g as pruneIndexArrays};
