/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","./maybe","./RandomLCG"],(function(n,t,e){"use strict";function r(n){if(!n)return;return n.length>0?n[0]:void 0}function o(n){if(!n)return;const t=n.length;return t>0?n[t-1]:void 0}function i(n){return n}function l(n,t=i){if(!n||0===n.length)return;let e=n[0],r=t(e);for(let o=1;o<n.length;++o){const i=n[o],l=Number(t(i));l>r&&(r=l,e=i)}return e}function f(n,t=i){return l(n,(n=>-t(n)))}function u(n,t){return t?n.filter(((n,e,r)=>r.findIndex(t.bind(null,n))===e)):n.filter(((n,t,e)=>e.indexOf(n)===t))}function s(n,e,r){if(t.isNone(n)&&t.isNone(e))return!0;if(t.isNone(n)||t.isNone(e)||n.length!==e.length)return!1;if(r){for(let t=0;t<n.length;t++)if(!r(n[t],e[t]))return!1}else for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function c(n,t){let e=n.length!==t.length;n.length=t.length;for(let r=0;r<t.length;++r)n[r]!==t[r]&&(n[r]=t[r],e=!0);return e}function a(n,t,e){let r,o;return e?(r=t.filter((t=>!n.some((n=>e(n,t))))),o=n.filter((n=>!t.some((t=>e(t,n)))))):(r=t.filter((t=>!n.includes(t))),o=n.filter((n=>!t.includes(n)))),{added:r,removed:o}}function h(n,t,e){return n&&t?e?n.filter((n=>t.findIndex((t=>e(n,t)))>-1)):n.filter((n=>t.includes(n))):[]}function d(n){return n&&"number"==typeof n.length}function g(n,t){const e=n.length;if(0===e)return[];const r=[];for(let o=0;o<e;o+=t)r.push(n.slice(o,o+t));return r}const m=!!Array.prototype.fill;function p(n,t){if(m)return new Array(n).fill(t);const e=new Array(n);for(let r=0;r<n;r++)e[r]=t;return e}function y(n,t){void 0===t&&(t=n,n=0);const e=new Array(t-n);for(let r=n;r<t;r++)e[r-n]=r;return e}function M(n,t,e){const r=n.length;let o=0,i=r-1;for(;o<i;){const e=o+Math.floor((i-o)/2);t>n[e]?o=e+1:i=e}const l=n[o];return e?t>=n[r-1]?-1:l===t?o:o-1:l===t?o:-1}function x(n,t,e){if(!n||0===n.length)return;const r=n.length-1,o=n[0];if(t<=e(o))return o;const i=n[r];if(t>=e(i))return i;let l=0,f=0,u=r;for(;l<u;){f=l+Math.floor((u-l)/2);const o=n[f],i=e(o);if(i===t)return o;if(t<i){if(f>0){const r=n[f-1],l=e(r);if(t>l)return t-l>=i-t?o:r}u=f}else{if(f<r){const r=n[f+1],l=e(r);if(t<l)return t-i>=l-t?r:o}l=f+1}}return n[f]}function v(n){return n.reduce(((n,t)=>n.concat(t||[])),[])}let b=function(){this.last=0};const w=new b;function A(n,t,e,r){r=r||w;const o=Math.max(0,r.last-10);for(let l=o;l<e;++l)if(n[l]===t)return r.last=l,l;const i=Math.min(o,e);for(let l=0;l<i;++l)if(n[l]===t)return r.last=l,l;return-1}function N(n,t,e,r){const o=null==e?n.length:e,i=A(n,t,o,r);if(-1!==i)return n[i]=n[o-1],null==e&&n.pop(),t}const O=new Set;function I(n,t,e=n.length,r=t.length,o,i){if(0===r||0===e)return e;O.clear();for(let f=0;f<r;++f)O.add(t[f]);o=o||w;const l=Math.max(0,o.last-10);for(let f=l;f<e;++f)if(O.has(n[f])&&(i&&i.push(n[f]),O.delete(n[f]),n[f]=n[e-1],--e,--f,0===O.size||0===e))return O.clear(),e;for(let f=0;f<l;++f)if(O.has(n[f])&&(i&&i.push(n[f]),O.delete(n[f]),n[f]=n[e-1],--e,--f,0===O.size||0===e))return O.clear(),e;return O.clear(),e}function S(n,t,e){const r=n.length;if(t>=r)return n.slice(0);const o=k(e),i=new Set,l=[];for(;l.length<t;){const t=Math.floor(o()*r);i.has(t)||(i.add(t),l.push(n[t]))}return l}function k(n){return n?(q.seed=n,()=>q.getFloat()):Math.random}function C(n,t){const e=k(t);for(let r=n.length-1;r>0;r--){const t=Math.floor(e()*(r+1)),o=n[r];n[r]=n[t],n[t]=o}return n}const q=new e;function z(n,t){const e=n.indexOf(t);return-1!==e?(n.splice(e,1),t):null}n.PositionHint=b,n.binaryFindClosest=x,n.binaryIndexOf=M,n.constant=p,n.difference=a,n.equals=s,n.first=r,n.flatten=v,n.indexOf=A,n.intersect=h,n.isArrayLike=d,n.last=o,n.max=l,n.min=f,n.pickRandom=S,n.range=y,n.remove=z,n.removeUnordered=N,n.removeUnorderedMany=I,n.shuffle=C,n.splitIntoChunks=g,n.unique=u,n.update=c,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
