/*
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/has","../../core/mathUtils","../../core/maybe","../Extent"],(function(n,t,e,i,r){"use strict";function a(n){return n}function u(n=z){return a([n[0],n[1],n[2],n[3]])}function o(n){return a([n[0],n[1],n[2],n[3]])}function c(n,t){return n!==t&&(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3]),n}function s(n,t,e,i,r=u()){return r[0]=n,r[1]=t,r[2]=e,r[3]=i,r}function f(n,t=u()){return t[0]=n.xmin,t[1]=n.ymin,t[2]=n.xmax,t[3]=n.ymax,t}function m(n,t){return new r({xmin:n[0],ymin:n[1],xmax:n[2],ymax:n[3],spatialReference:t})}function h(n,t){t[0]<n[0]&&(n[0]=t[0]),t[0]>n[2]&&(n[2]=t[0]),t[1]<n[1]&&(n[1]=t[1]),t[1]>n[3]&&(n[3]=t[1])}function x(n,t,e){if(i.isNone(t))c(e,n);else if("length"in t)A(t)?(e[0]=Math.min(n[0],t[0]),e[1]=Math.min(n[1],t[1]),e[2]=Math.max(n[2],t[2]),e[3]=Math.max(n[3],t[3])):2!==t.length&&3!==t.length||(e[0]=Math.min(n[0],t[0]),e[1]=Math.min(n[1],t[1]),e[2]=Math.max(n[2],t[0]),e[3]=Math.max(n[3],t[1]));else switch(t.type){case"extent":e[0]=Math.min(n[0],t.xmin),e[1]=Math.min(n[1],t.ymin),e[2]=Math.max(n[2],t.xmax),e[3]=Math.max(n[3],t.ymax);break;case"point":e[0]=Math.min(n[0],t.x),e[1]=Math.min(n[1],t.y),e[2]=Math.max(n[2],t.x),e[3]=Math.max(n[3],t.y)}}function M(n,t,e=n){const i=t.length;let r=n[0],a=n[1],u=n[2],o=n[3];for(let c=0;c<i;c++){const n=t[c];r=Math.min(r,n[0]),a=Math.min(a,n[1]),u=Math.max(u,n[0]),o=Math.max(o,n[1])}return e[0]=r,e[1]=a,e[2]=u,e[3]=o,e}function l(n){for(let t=0;t<4;t++)if(!isFinite(n[t]))return!1;return!0}function y(n){return i.isNone(n)||n[0]>=n[2]?0:n[2]-n[0]}function p(n){return n[1]>=n[3]?0:n[3]-n[1]}function d(n){return y(n)*p(n)}function g(n,t=[0,0]){return t[0]=(n[0]+n[2])/2,t[1]=(n[1]+n[3])/2,t}function I(n,t){return E(n,t[0],t[1])}function N(n,t){const e=t[3],i=.5*(n[0]+n[2]),r=Math.abs(t[0]-i),a=.5*(n[2]-n[0]);if(r>e+a)return!1;const u=.5*(n[1]+n[3]),o=.5*(n[3]-n[1]),c=Math.abs(t[1]-u);if(c>e+o)return!1;if(r<a||c<o)return!0;const s=r-a,f=c-o;return s*s+f*f<=e*e}function b(n,t,e){const i=n[0],r=n[1],a=n[2],u=n[3],{x:o,y:c}=t,{x:s,y:f}=e,m=(n,t)=>(f-c)*n+(o-s)*t+(s*c-o*f)<0,h=m(i,u),x=m(a,u),M=m(a,r),l=m(i,r);return!(h===x&&x===M&&M===l&&l===h||o<i&&s<i||o>a&&s>a||c>u&&f>u||c<r&&f<r)}function P(n,t){return E(n,t.x,t.y)}function E(n,t,e){return t>=n[0]&&e>=n[1]&&t<=n[2]&&e<=n[3]}function F(n,t,e,i){return t>=n[0]-i&&e>=n[1]-i&&t<=n[2]+i&&e<=n[3]+i}function T(n,t,e){return t[0]>=n[0]-e&&t[1]>=n[1]-e&&t[0]<=n[2]+e&&t[1]<=n[3]+e}function S(n,t){return Math.max(t[0],n[0])<=Math.min(t[2],n[2])&&Math.max(t[1],n[1])<=Math.min(t[3],n[3])}function O(n,t){return t[0]>=n[0]&&t[2]<=n[2]&&t[1]>=n[1]&&t[3]<=n[3]}function Y(n,t,r){if(i.isNone(t))return c(r,n);const a=t[0],u=t[1],o=t[2],s=t[3];return r[0]=e.clamp(n[0],a,o),r[1]=e.clamp(n[1],u,s),r[2]=e.clamp(n[2],a,o),r[3]=e.clamp(n[3],u,s),r}function _(n,t){const e=(n[0]+n[2])/2,i=(n[1]+n[3])/2,r=Math.max(Math.abs(t[0]-e)-y(n)/2,0),a=Math.max(Math.abs(t[1]-i)-p(n)/2,0);return Math.sqrt(r*r+a*a)}function w(n,t){t[0]=n[2]-n[0],t[1]=n[3]-n[1]}function V(n,t,e,i=n){return i[0]=n[0]+t,i[1]=n[1]+e,i[2]=n[2]+t,i[3]=n[3]+e,i}function W(n,t,e=n){return e[0]=n[0]-t,e[1]=n[1]-t,e[2]=n[2]+t,e[3]=n[3]+t,e}function j(n,t,e=n){return e[0]=t[0],e[1]=t[1],e!==n&&(e[2]=n[2],e[3]=n[3]),e}function q(n,t,e=n){return e[2]=t[0],e[3]=t[1],e!==n&&(e[0]=n[0],e[1]=n[1]),n}function v(n){return n?c(n,k):u(k)}function A(n){return null!=n&&4===n.length}function R(n){return!(0!==y(n)&&isFinite(n[0])||0!==p(n)&&isFinite(n[1]))}function U(n,t){return A(n)&&A(t)?n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]:n===t}const X=a([-1/0,-1/0,1/0,1/0]),k=a([1/0,1/0,-1/0,-1/0]),z=a([0,0,0,0]),G=a([0,0,1,1]);n.NEGATIVE_INFINITY=k,n.POSITIVE_INFINITY=X,n.UNIT=G,n.ZERO=z,n.allFinite=l,n.area=d,n.center=g,n.clone=o,n.contains=O,n.containsPoint=I,n.containsPointObject=P,n.containsPointWithMargin=T,n.containsXY=E,n.containsXYWithMargin=F,n.copy=c,n.create=u,n.distance=_,n.empty=v,n.equals=U,n.expand=x,n.expandPointInPlace=h,n.expandWithNestedArray=M,n.fromExtent=f,n.fromValues=s,n.height=p,n.intersection=Y,n.intersects=S,n.intersectsSegment=b,n.intersectsSphere=N,n.is=A,n.isPoint=R,n.offset=V,n.pad=W,n.setMax=q,n.setMin=j,n.size=w,n.toExtent=m,n.width=y,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
