define(["exports","./RuntimeError-346a3079","./when-4bbc8319","./ComponentDatatype-93750d1a"],function(e,P,b,k){"use strict";function S(e,t,n){this.x=b.defaultValue(e,0),this.y=b.defaultValue(t,0),this.z=b.defaultValue(n,0)}S.fromSpherical=function(e,t){b.defined(t)||(t=new S);var n=e.clock,r=e.cone,a=b.defaultValue(e.magnitude,1),e=a*Math.sin(r);return t.x=e*Math.cos(n),t.y=e*Math.sin(n),t.z=a*Math.cos(r),t},S.fromElements=function(e,t,n,r){return b.defined(r)?(r.x=e,r.y=t,r.z=n,r):new S(e,t,n)},S.fromCartesian4=S.clone=function(e,t){if(b.defined(e))return b.defined(t)?(t.x=e.x,t.y=e.y,t.z=e.z,t):new S(e.x,e.y,e.z)},S.packedLength=3,S.pack=function(e,t,n){return n=b.defaultValue(n,0),t[n++]=e.x,t[n++]=e.y,t[n]=e.z,t},S.unpack=function(e,t,n){return t=b.defaultValue(t,0),(n=!b.defined(n)?new S:n).x=e[t++],n.y=e[t++],n.z=e[t],n},S.packArray=function(e,t){var n=e.length,r=3*n;if(b.defined(t)){if(!Array.isArray(t)&&t.length!==r)throw new P.DeveloperError("If result is a typed array, it must have exactly array.length * 3 elements");t.length!==r&&(t.length=r)}else t=new Array(r);for(var a=0;ak.CesiumMath.EPSILON12);return b.defined(a)?(a.x=i*M,a.y=u*w,a.z=o*g,a):new S(i*M,u*w,o*g)}function d(e,t,n){this.longitude=b.defaultValue(e,0),this.latitude=b.defaultValue(t,0),this.height=b.defaultValue(n,0)}d.fromRadians=function(e,t,n,r){return n=b.defaultValue(n,0),b.defined(r)?(r.longitude=e,r.latitude=t,r.height=n,r):new d(e,t,n)},d.fromDegrees=function(e,t,n,r){return e=k.CesiumMath.toRadians(e),t=k.CesiumMath.toRadians(t),d.fromRadians(e,t,n,r)};var c=new S,h=new S,m=new S,y=new S(1/6378137,1/6378137,1/6356752.314245179),p=new S(1/40680631590769,1/40680631590769,1/40408299984661.445),x=k.CesiumMath.EPSILON1;function M(e,t,n,r){t=b.defaultValue(t,0),n=b.defaultValue(n,0),r=b.defaultValue(r,0),e._radii=new S(t,n,r),e._radiiSquared=new S(t*t,n*n,r*r),e._radiiToTheFourth=new S(t*t*t*t,n*n*n*n,r*r*r*r),e._oneOverRadii=new S(0===t?0:1/t,0===n?0:1/n,0===r?0:1/r),e._oneOverRadiiSquared=new S(0===t?0:1/(t*t),0===n?0:1/(n*n),0===r?0:1/(r*r)),e._minimumRadius=Math.min(t,n,r),e._maximumRadius=Math.max(t,n,r),e._centerToleranceSquared=k.CesiumMath.EPSILON1,0!==e._radiiSquared.z&&(e._squaredXOverSquaredZ=e._radiiSquared.x/e._radiiSquared.z)}function w(e,t,n){this._radii=void 0,this._radiiSquared=void 0,this._radiiToTheFourth=void 0,this._oneOverRadii=void 0,this._oneOverRadiiSquared=void 0,this._minimumRadius=void 0,this._maximumRadius=void 0,this._centerToleranceSquared=void 0,this._squaredXOverSquaredZ=void 0,M(this,e,t,n)}d.fromCartesian=function(e,t,n){var r=b.defined(t)?t.oneOverRadii:y,a=b.defined(t)?t.oneOverRadiiSquared:p,r=l(e,r,a,b.defined(t)?t._centerToleranceSquared:x,h);if(b.defined(r)){t=S.multiplyComponents(r,a,c),t=S.normalize(t,t),a=S.subtract(e,r,m),r=Math.atan2(t.y,t.x),t=Math.asin(t.z),a=k.CesiumMath.sign(S.dot(a,e))*S.magnitude(a);return b.defined(n)?(n.longitude=r,n.latitude=t,n.height=a,n):new d(r,t,a)}},d.toCartesian=function(e,t,n){return S.fromRadians(e.longitude,e.latitude,e.height,t,n)},d.clone=function(e,t){if(b.defined(e))return b.defined(t)?(t.longitude=e.longitude,t.latitude=e.latitude,t.height=e.height,t):new d(e.longitude,e.latitude,e.height)},d.equals=function(e,t){return e===t||b.defined(e)&&b.defined(t)&&e.longitude===t.longitude&&e.latitude===t.latitude&&e.height===t.height},d.equalsEpsilon=function(e,t,n){return n=b.defaultValue(n,0),e===t||b.defined(e)&&b.defined(t)&&Math.abs(e.longitude-t.longitude)<=n&&Math.abs(e.latitude-t.latitude)<=n&&Math.abs(e.height-t.height)<=n},d.ZERO=Object.freeze(new d(0,0,0)),d.prototype.clone=function(e){return d.clone(this,e)},d.prototype.equals=function(e){return d.equals(this,e)},d.prototype.equalsEpsilon=function(e,t){return d.equalsEpsilon(this,e,t)},d.prototype.toString=function(){return"("+this.longitude+", "+this.latitude+", "+this.height+")"},Object.defineProperties(w.prototype,{radii:{get:function(){return this._radii}},radiiSquared:{get:function(){return this._radiiSquared}},radiiToTheFourth:{get:function(){return this._radiiToTheFourth}},oneOverRadii:{get:function(){return this._oneOverRadii}},oneOverRadiiSquared:{get:function(){return this._oneOverRadiiSquared}},minimumRadius:{get:function(){return this._minimumRadius}},maximumRadius:{get:function(){return this._maximumRadius}}}),w.clone=function(e,t){if(b.defined(e)){var n=e._radii;return b.defined(t)?(S.clone(n,t._radii),S.clone(e._radiiSquared,t._radiiSquared),S.clone(e._radiiToTheFourth,t._radiiToTheFourth),S.clone(e._oneOverRadii,t._oneOverRadii),S.clone(e._oneOverRadiiSquared,t._oneOverRadiiSquared),t._minimumRadius=e._minimumRadius,t._maximumRadius=e._maximumRadius,t._centerToleranceSquared=e._centerToleranceSquared,t):new w(n.x,n.y,n.z)}},w.fromCartesian3=function(e,t){return b.defined(t)||(t=new w),b.defined(e)&&M(t,e.x,e.y,e.z),t},w.WGS84=Object.freeze(new w(6378137,6378137,6356752.314245179)),w.UNIT_SPHERE=Object.freeze(new w(1,1,1)),w.MOON=Object.freeze(new w(k.CesiumMath.LUNAR_RADIUS,k.CesiumMath.LUNAR_RADIUS,k.CesiumMath.LUNAR_RADIUS)),w.prototype.clone=function(e){return w.clone(this,e)},w.packedLength=S.packedLength,w.pack=function(e,t,n){return n=b.defaultValue(n,0),S.pack(e._radii,t,n),t},w.unpack=function(e,t,n){t=b.defaultValue(t,0);t=S.unpack(e,t);return w.fromCartesian3(t,n)},w.prototype.geocentricSurfaceNormal=S.normalize,w.prototype.geodeticSurfaceNormalCartographic=function(e,t){var n=e.longitude,r=e.latitude,a=Math.cos(r),e=a*Math.cos(n),n=a*Math.sin(n),r=Math.sin(r);return(t=!b.defined(t)?new S:t).x=e,t.y=n,t.z=r,S.normalize(t,t)},w.prototype.geodeticSurfaceNormal=function(e,t){if(!S.equalsEpsilon(e,S.ZERO,k.CesiumMath.EPSILON14))return b.defined(t)||(t=new S),t=S.multiplyComponents(e,this._oneOverRadiiSquared,t),S.normalize(t,t)};var g=new S,z=new S;w.prototype.cartographicToCartesian=function(e,t){var n=g,r=z;this.geodeticSurfaceNormalCartographic(e,n),S.multiplyComponents(this._radiiSquared,n,r);var a=Math.sqrt(S.dot(n,r));return S.divideByScalar(r,a,r),S.multiplyByScalar(n,e.height,n),b.defined(t)||(t=new S),S.add(r,n,t)},w.prototype.cartographicArrayToCartesianArray=function(e,t){var n=e.length;b.defined(t)?t.length=n:t=new Array(n);for(var r=0;r=this._radii.z-t))return n};var R=[.14887433898163,.43339539412925,.67940956829902,.86506336668898,.97390652851717,0],V=[.29552422471475,.26926671930999,.21908636251598,.14945134915058,.066671344308684,0];function E(e,t,n){for(var r=.5*(t+e),a=.5*(t-e),i=0,u=0;u<5;u++){var o=a*R[u];i+=V[u]*(n(r+o)+n(r-o))}return i*=a}function B(e,t,n,r,a,i,u,o,s){this[0]=b.defaultValue(e,0),this[1]=b.defaultValue(r,0),this[2]=b.defaultValue(u,0),this[3]=b.defaultValue(t,0),this[4]=b.defaultValue(a,0),this[5]=b.defaultValue(o,0),this[6]=b.defaultValue(n,0),this[7]=b.defaultValue(i,0),this[8]=b.defaultValue(s,0)}w.prototype.surfaceArea=function(e){for(var t=e.west,a=e.east,n=e.south,r=e.north;ao;)!function(e,t){for(var n=k.CesiumMath.EPSILON15,r=0,a=1,i=0;i<3;++i){var u=Math.abs(e[B.getElementIndex(U[i],N[i])]);rn&&(s=(n=(n=(e[B.getElementIndex(l,l)]-e[B.getElementIndex(f,f)])/2/e[B.getElementIndex(l,f)])<0?-1/(-n+Math.sqrt(1+n*n)):1/(n+Math.sqrt(1+n*n)))*(o=1/Math.sqrt(1+n*n))),(t=B.clone(B.IDENTITY,t))[B.getElementIndex(f,f)]=t[B.getElementIndex(l,l)]=o,t[B.getElementIndex(l,f)]=s,t[B.getElementIndex(f,l)]=-s}(u,L),B.transpose(L,W),B.multiply(u,L,u),B.multiply(W,u,u),B.multiply(i,L,i),2<++r&&(++a,r=0);return t},B.abs=function(e,t){return t[0]=Math.abs(e[0]),t[1]=Math.abs(e[1]),t[2]=Math.abs(e[2]),t[3]=Math.abs(e[3]),t[4]=Math.abs(e[4]),t[5]=Math.abs(e[5]),t[6]=Math.abs(e[6]),t[7]=Math.abs(e[7]),t[8]=Math.abs(e[8]),t},B.determinant=function(e){var t=e[0],n=e[3],r=e[6],a=e[1],i=e[4],u=e[7],o=e[2],s=e[5],e=e[8];return t*(i*e-s*u)+a*(s*r-n*e)+o*(n*u-i*r)},B.inverse=function(e,t){var n=e[0],r=e[1],a=e[2],i=e[3],u=e[4],o=e[5],s=e[6],f=e[7],l=e[8],e=B.determinant(e);return t[0]=u*l-f*o,t[1]=f*a-r*l,t[2]=r*o-u*a,t[3]=s*o-i*l,t[4]=n*l-s*a,t[5]=i*a-n*o,t[6]=i*f-s*u,t[7]=s*r-n*f,t[8]=n*u-i*r,B.multiplyByScalar(t,1/e,t)};var j=new B;function X(e,t,n,r){this.x=b.defaultValue(e,0),this.y=b.defaultValue(t,0),this.z=b.defaultValue(n,0),this.w=b.defaultValue(r,0)}B.inverseTranspose=function(e,t){return B.inverse(B.transpose(e,j),t)},B.equals=function(e,t){return e===t||b.defined(e)&&b.defined(t)&&e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]},B.equalsEpsilon=function(e,t,n){return n=b.defaultValue(n,0),e===t||b.defined(e)&&b.defined(t)&&Math.abs(e[0]-t[0])<=n&&Math.abs(e[1]-t[1])<=n&&Math.abs(e[2]-t[2])<=n&&Math.abs(e[3]-t[3])<=n&&Math.abs(e[4]-t[4])<=n&&Math.abs(e[5]-t[5])<=n&&Math.abs(e[6]-t[6])<=n&&Math.abs(e[7]-t[7])<=n&&Math.abs(e[8]-t[8])<=n},B.IDENTITY=Object.freeze(new B(1,0,0,0,1,0,0,0,1)),B.ZERO=Object.freeze(new B(0,0,0,0,0,0,0,0,0)),B.COLUMN0ROW0=0,B.COLUMN0ROW1=1,B.COLUMN0ROW2=2,B.COLUMN1ROW0=3,B.COLUMN1ROW1=4,B.COLUMN1ROW2=5,B.COLUMN2ROW0=6,B.COLUMN2ROW1=7,B.COLUMN2ROW2=8,Object.defineProperties(B.prototype,{length:{get:function(){return B.packedLength}}}),B.prototype.clone=function(e){return B.clone(this,e)},B.prototype.equals=function(e){return B.equals(this,e)},B.equalsArray=function(e,t,n){return e[0]===t[n]&&e[1]===t[n+1]&&e[2]===t[n+2]&&e[3]===t[n+3]&&e[4]===t[n+4]&&e[5]===t[n+5]&&e[6]===t[n+6]&&e[7]===t[n+7]&&e[8]===t[n+8]},B.prototype.equalsEpsilon=function(e,t){return B.equalsEpsilon(this,e,t)},B.prototype.toString=function(){return"("+this[0]+", "+this[3]+", "+this[6]+")\n("+this[1]+", "+this[4]+", "+this[7]+")\n("+this[2]+", "+this[5]+", "+this[8]+")"},X.fromElements=function(e,t,n,r,a){return b.defined(a)?(a.x=e,a.y=t,a.z=n,a.w=r,a):new X(e,t,n,r)},X.fromColor=function(e,t){return b.defined(t)?(t.x=e.red,t.y=e.green,t.z=e.blue,t.w=e.alpha,t):new X(e.red,e.green,e.blue,e.alpha)},X.clone=function(e,t){if(b.defined(e))return b.defined(t)?(t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t):new X(e.x,e.y,e.z,e.w)},X.packedLength=4,X.pack=function(e,t,n){return n=b.defaultValue(n,0),t[n++]=e.x,t[n++]=e.y,t[n++]=e.z,t[n]=e.w,t},X.unpack=function(e,t,n){return t=b.defaultValue(t,0),(n=!b.defined(n)?new X:n).x=e[t++],n.y=e[t++],n.z=e[t++],n.w=e[t],n},X.packArray=function(e,t){var n=e.length,r=4*n;if(b.defined(t)){if(!Array.isArray(t)&&t.length!==r)throw new P.DeveloperError("If result is a typed array, it must have exactly array.length * 4 elements");t.length!==r&&(t.length=r)}else t=new Array(r);for(var a=0;ak.CesiumMath.PI&&(r-=k.CesiumMath.TWO_PI),n>k.CesiumMath.PI&&(n-=k.CesiumMath.TWO_PI)),b.defined(t)?(t.west=n,t.south=u,t.east=r,t.north=o,t):new fe(n,u,r,o)},fe.fromCartesianArray=function(e,t,n){t=b.defaultValue(t,w.WGS84);for(var r=Number.MAX_VALUE,a=-Number.MAX_VALUE,i=Number.MAX_VALUE,u=-Number.MAX_VALUE,o=Number.MAX_VALUE,s=-Number.MAX_VALUE,f=0,l=e.length;fk.CesiumMath.PI&&(a-=k.CesiumMath.TWO_PI),r>k.CesiumMath.PI&&(r-=k.CesiumMath.TWO_PI)),b.defined(n)?(n.west=r,n.south=o,n.east=a,n.north=s,n):new fe(r,o,a,s)},fe.clone=function(e,t){if(b.defined(e))return b.defined(t)?(t.west=e.west,t.south=e.south,t.east=e.east,t.north=e.north,t):new fe(e.west,e.south,e.east,e.north)},fe.equalsEpsilon=function(e,t,n){return n=b.defaultValue(n,0),e===t||b.defined(e)&&b.defined(t)&&Math.abs(e.west-t.west)<=n&&Math.abs(e.south-t.south)<=n&&Math.abs(e.east-t.east)<=n&&Math.abs(e.north-t.north)<=n},fe.prototype.clone=function(e){return fe.clone(this,e)},fe.prototype.equals=function(e){return fe.equals(this,e)},fe.equals=function(e,t){return e===t||b.defined(e)&&b.defined(t)&&e.west===t.west&&e.south===t.south&&e.east===t.east&&e.north===t.north},fe.prototype.equalsEpsilon=function(e,t){return fe.equalsEpsilon(this,e,t)},fe.validate=function(e){},fe.southwest=function(e,t){return b.defined(t)?(t.longitude=e.west,t.latitude=e.south,t.height=0,t):new d(e.west,e.south)},fe.northwest=function(e,t){return b.defined(t)?(t.longitude=e.west,t.latitude=e.north,t.height=0,t):new d(e.west,e.north)},fe.northeast=function(e,t){return b.defined(t)?(t.longitude=e.east,t.latitude=e.north,t.height=0,t):new d(e.east,e.north)},fe.southeast=function(e,t){return b.defined(t)?(t.longitude=e.east,t.latitude=e.south,t.height=0,t):new d(e.east,e.south)},fe.center=function(e,t){var n=e.east,r=e.west;n=e.south&&r<=e.north};var le=new d;function de(e,t){this.x=b.defaultValue(e,0),this.y=b.defaultValue(t,0)}fe.subsample=function(e,t,n,r){t=b.defaultValue(t,w.WGS84),n=b.defaultValue(n,0),b.defined(r)||(r=[]);var a=0,i=e.north,u=e.south,o=e.east,s=e.west,f=le;f.height=n,f.longitude=s,f.latitude=i,r[a]=t.cartographicToCartesian(f,r[a]),a++,f.longitude=o,r[a]=t.cartographicToCartesian(f,r[a]),a++,f.latitude=u,r[a]=t.cartographicToCartesian(f,r[a]),a++,f.longitude=s,r[a]=t.cartographicToCartesian(f,r[a]),a++,f.latitude=i<0?i:0