define(["./Transforms-d5c6ad6e","./Matrix2-ccd5b911","./RuntimeError-346a3079","./when-4bbc8319","./ComponentDatatype-93750d1a","./ArcType-98ec98bf","./arrayRemoveDuplicates-18786327","./EllipsoidGeodesic-19ea7553","./EllipsoidRhumbLine-aa9e6266","./EncodedCartesian3-08b8d980","./GeometryAttribute-c30799b8","./IntersectionTests-4d6f5c54","./Plane-18bb00f8","./WebMercatorProjection-b29097b4","./combine-83860057","./WebGLConstants-1c8239cc"],function(Oe,be,e,B,Pe,j,G,M,V,Ae,ke,Y,r,a,t,n){"use strict";function i(e){e=B.defaultValue(e,B.defaultValue.EMPTY_OBJECT),this._ellipsoid=B.defaultValue(e.ellipsoid,be.Ellipsoid.WGS84),this._rectangle=B.defaultValue(e.rectangle,be.Rectangle.MAX_VALUE),this._projection=new Oe.GeographicProjection(this._ellipsoid),this._numberOfLevelZeroTilesX=B.defaultValue(e.numberOfLevelZeroTilesX,2),this._numberOfLevelZeroTilesY=B.defaultValue(e.numberOfLevelZeroTilesY,1)}Object.defineProperties(i.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}}),i.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<Se?(F=Ne(a,P,ee,V,$e),q=Ne(a,A,G,Y,ea)):1===Me?(q=Ne(a,A,G,Y,ea),F.x=0,F.y=Pe.CesiumMath.sign(P.longitude-Math.abs(A.longitude)),F.z=0):(F=Ne(a,P,ee,V,$e),q.x=0,q.y=Pe.CesiumMath.sign(P.longitude-A.longitude),q.z=0));var ae=be.Cartesian3.distance($,j),te=Ae.EncodedCartesian3.fromCartesian(K,oa),ne=be.Cartesian3.subtract(B,K,aa),ie=be.Cartesian3.normalize(ne,ia),re=be.Cartesian3.subtract($,K,ta);re=be.Cartesian3.normalize(re,re);var se=be.Cartesian3.cross(ie,re,ia);se=be.Cartesian3.normalize(se,se);var oe=be.Cartesian3.cross(re,ee,ra);oe=be.Cartesian3.normalize(oe,oe);var le=be.Cartesian3.subtract(j,B,na);le=be.Cartesian3.normalize(le,le);var ue=be.Cartesian3.cross(G,le,sa);ue=be.Cartesian3.normalize(ue,ue);var ce=ae/I,Ce=Z/I,pe=0,de=0,he=0;for(s&&(pe=be.Cartesian3.distance(V,Y),X=Ae.EncodedCartesian3.fromCartesian(V,la),W=be.Cartesian3.subtract(Y,V,ua),Te=(U=be.Cartesian3.normalize(W,ca)).x,U.x=U.y,U.y=-Te,de=pe/b,he=J/b),x=0;x<8;x++){var ge=z+4*x,me=R+2*x,fe=ge+3,we=x<4?1:-1,ye=2===x||3===x||6===x||7===x?1:-1;be.Cartesian3.pack(te.high,v,ge),v[fe]=ne.x,be.Cartesian3.pack(te.low,M,ge),M[fe]=ne.y,be.Cartesian3.pack(oe,T,ge),T[fe]=ne.z,be.Cartesian3.pack(ue,E,ge),E[fe]=ce*we,be.Cartesian3.pack(se,_,ge);var ve=Ce*ye;0===ve&&ye<0&&(ve=9),_[fe]=ve,s&&(u[ge]=X.high.x,u[ge+1]=X.high.y,u[ge+2]=X.low.x,u[ge+3]=X.low.y,C[ge]=-F.y,C[ge+1]=F.x,C[ge+2]=q.y,C[ge+3]=-q.x,c[ge]=W.x,c[ge+1]=W.y,c[ge+2]=U.x,c[ge+3]=U.y,p[me]=de*we,0===(ve=he*ye)&&ye<0&&(ve=9),p[me+1]=ve)}var Me=Ze,ie=Je,re=We,ee=Ue,le=be.Rectangle.fromCartographicArray(qe,Xe),Te=Le.getMinimumMaximumHeights(le,d),le=Te.minimumTerrainHeight,Te=Te.maximumTerrainHeight;Q+=le,Q+=Te,Re(K,$,le,Te,Me,re),Re(B,j,le,Te,ie,ee);Te=be.Cartesian3.multiplyByScalar(se,Pe.CesiumMath.EPSILON5,Ca);be.Cartesian3.add(Me,Te,Me),be.Cartesian3.add(ie,Te,ie),be.Cartesian3.add(re,Te,re),be.Cartesian3.add(ee,Te,ee),De(Me,ie),De(re,ee),be.Cartesian3.pack(Me,y,D),be.Cartesian3.pack(ie,y,D+3),be.Cartesian3.pack(ee,y,D+6),be.Cartesian3.pack(re,y,D+9),Te=be.Cartesian3.multiplyByScalar(se,-2*Pe.CesiumMath.EPSILON5,Ca),be.Cartesian3.add(Me,Te,Me),be.Cartesian3.add(ie,Te,ie),be.Cartesian3.add(re,Te,re),be.Cartesian3.add(ee,Te,ee),De(Me,ie),De(re,ee),be.Cartesian3.pack(Me,y,D+12),be.Cartesian3.pack(ie,y,D+15),be.Cartesian3.pack(ee,y,D+18),be.Cartesian3.pack(re,y,D+21),N+=2,l+=3,R+=16,D+=24,z+=32,Z+=ae,J+=pe}var Ee=l=0;for(o=0;oPe.CesiumMath.PI_OVER_TWO&&(o=!0,s=be.Cartesian3.subtract(r,t,H),u=l.cartesianToCartographic(s,D)),u.height=0;u=e.project(u,i);return(i=be.Cartesian3.subtract(u,n,i)).z=0,i=be.Cartesian3.normalize(i,i),o&&be.Cartesian3.negate(i,i),i}var oe=new be.Cartesian3,le=new be.Cartesian3;function Re(e,a,t,n,i,r){var s=be.Cartesian3.subtract(a,e,oe);be.Cartesian3.normalize(s,s);t=be.Cartesian3.multiplyByScalar(s,t-q,le);be.Cartesian3.add(e,t,i);t=be.Cartesian3.multiplyByScalar(s,n-X,le);be.Cartesian3.add(a,t,r)}var ue=new be.Cartesian3;function De(e,a){var t=r.Plane.getPointDistance(Q,e),n=r.Plane.getPointDistance(Q,a),i=ue;Pe.CesiumMath.equalsEpsilon(t,0,Pe.CesiumMath.EPSILON2)?(i=xe(a,e,i),be.Cartesian3.multiplyByScalar(i,Pe.CesiumMath.EPSILON2,i),be.Cartesian3.add(e,i,e)):Pe.CesiumMath.equalsEpsilon(n,0,Pe.CesiumMath.EPSILON2)&&(i=xe(e,a,i),be.Cartesian3.multiplyByScalar(i,Pe.CesiumMath.EPSILON2,i),be.Cartesian3.add(a,i,a))}var ze=new be.Cartographic,He=new be.Cartographic,Be=new be.Cartesian3,je=new be.Cartesian3,Ge=new be.Cartesian3,Ve=new be.Cartesian3,Ye=new be.Cartesian3,Fe=new be.Cartesian3,qe=[ze,He],Xe=new be.Rectangle,We=new be.Cartesian3,Ue=new be.Cartesian3,Ze=new be.Cartesian3,Je=new be.Cartesian3,Qe=new be.Cartesian3,Ke=new be.Cartesian3,$e=new be.Cartesian3,ea=new be.Cartesian3,aa=new be.Cartesian3,ta=new be.Cartesian3,na=new be.Cartesian3,ia=new be.Cartesian3,ra=new be.Cartesian3,sa=new be.Cartesian3,oa=new Ae.EncodedCartesian3,la=new Ae.EncodedCartesian3,ua=new be.Cartesian3,ca=new be.Cartesian3,Ca=new be.Cartesian3,pa=[new Oe.BoundingSphere,new Oe.BoundingSphere],da=[0,2,1,0,3,2,0,7,3,0,4,7,0,5,4,0,1,5,5,7,4,5,6,7,5,2,6,5,1,2,3,6,2,3,7,6],ha=da.length;function ga(e){return new ke.GeometryAttribute({componentDatatype:Pe.ComponentDatatype.FLOAT,componentsPerAttribute:4,normalize:!1,values:e})}return w._projectNormal=Ne,function(e,a){return Le.initialize().then(function(){return B.defined(a)&&(e=w.unpack(e,a)),w.createGeometry(e)})}});