define(["./when-cbf8cd21","./Check-35e1a91d","./Math-e66fad2a","./Rectangle-53325d53","./WebGLConstants-95ceb4e9","./PixelFormat-d198afce","./Transforms-00c25a19","./RuntimeError-f4c64df1","./ComponentDatatype-7ee14e67","./GeometryAttribute-0b3418e6","./GeometryAttributes-90846c5f","./AttributeCompression-fd688b33","./GeometryPipeline-eeba9dc9","./EncodedCartesian3-35776b5f","./IndexDatatype-66caba23","./IntersectionTests-fdc68d04","./Plane-353c5ea0","./VertexFormat-cc24f342","./GeometryInstance-5e3224ad","./arrayRemoveDuplicates-b817241d","./BoundingRectangle-1ba4d0fb","./EllipsoidTangentPlane-c89e3523","./OrientedBoundingBox-a499af21","./CoplanarPolygonGeometryLibrary-b3eafff6","./ArcType-2b58731c","./EllipsoidRhumbLine-59f604d0","./PolygonPipeline-ae1ebf63","./PolygonGeometryLibrary-5e083c62"],function(s,e,V,R,t,a,I,n,M,H,B,r,w,o,O,i,l,p,A,F,c,y,m,G,u,d,z,L){"use strict";var S=new R.Cartesian3,E=new c.BoundingRectangle,N=new R.Cartesian2,Q=new R.Cartesian2,T=new R.Cartesian3,D=new R.Cartesian3,_=new R.Cartesian3,k=new R.Cartesian3,j=new R.Cartesian3,U=new R.Cartesian3,Y=new I.Quaternion,q=new I.Matrix3,J=new I.Matrix3,W=new R.Cartesian3;function g(e){var t=(e=s.defaultValue(e,s.defaultValue.EMPTY_OBJECT)).polygonHierarchy,a=s.defaultValue(e.vertexFormat,p.VertexFormat.DEFAULT);this._vertexFormat=p.VertexFormat.clone(a),this._polygonHierarchy=t,this._stRotation=s.defaultValue(e.stRotation,0),this._ellipsoid=R.Ellipsoid.clone(s.defaultValue(e.ellipsoid,R.Ellipsoid.WGS84)),this._workerName="createCoplanarPolygonGeometry",this.packedLength=L.PolygonGeometryLibrary.computeHierarchyPackedLength(t)+p.VertexFormat.packedLength+R.Ellipsoid.packedLength+2}g.fromPositions=function(e){return new g({polygonHierarchy:{positions:(e=s.defaultValue(e,s.defaultValue.EMPTY_OBJECT)).positions},vertexFormat:e.vertexFormat,stRotation:e.stRotation,ellipsoid:e.ellipsoid})},g.pack=function(e,t,a){return a=s.defaultValue(a,0),a=L.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,a),R.Ellipsoid.pack(e._ellipsoid,t,a),a+=R.Ellipsoid.packedLength,p.VertexFormat.pack(e._vertexFormat,t,a),a+=p.VertexFormat.packedLength,t[a++]=e._stRotation,t[a]=e.packedLength,t};var b=R.Ellipsoid.clone(R.Ellipsoid.UNIT_SPHERE),h=new p.VertexFormat,f={polygonHierarchy:{}};return g.unpack=function(e,t,a){t=s.defaultValue(t,0);var n=L.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=n.startingIndex,delete n.startingIndex;var r=R.Ellipsoid.unpack(e,t,b);t+=R.Ellipsoid.packedLength;var o=p.VertexFormat.unpack(e,t,h);t+=p.VertexFormat.packedLength;var i=e[t++],l=e[t];return s.defined(a)||(a=new g(f)),a._polygonHierarchy=n,a._ellipsoid=R.Ellipsoid.clone(r,a._ellipsoid),a._vertexFormat=p.VertexFormat.clone(o,a._vertexFormat),a._stRotation=i,a.packedLength=l,a},g.createGeometry=function(e){var t=e._vertexFormat,a=e._polygonHierarchy,n=e._stRotation,r=a.positions;if(!((r=F.arrayRemoveDuplicates(r,R.Cartesian3.equalsEpsilon,!0)).length<3)){var o=T,i=D,l=_,s=j,p=U;if(G.CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments(r,k,s,p)){var c,o=R.Cartesian3.cross(s,p,o);o=R.Cartesian3.normalize(o,o),R.Cartesian3.equalsEpsilon(k,R.Cartesian3.ZERO,V.CesiumMath.EPSILON6)||(c=e._ellipsoid.geodeticSurfaceNormal(k,W),R.Cartesian3.dot(o,c)<0&&(o=R.Cartesian3.negate(o,o),s=R.Cartesian3.negate(s,s)));var y=G.CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction(k,s,p),m=G.CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction(k,s,p);t.tangent&&(i=R.Cartesian3.clone(s,i)),t.bitangent&&(l=R.Cartesian3.clone(p,l));var u=L.PolygonGeometryLibrary.polygonsFromHierarchy(a,y,!1),d=u.hierarchy,g=u.polygons;if(0!==d.length){r=d[0].outerRing;for(var b=I.BoundingSphere.fromPoints(r),h=L.PolygonGeometryLibrary.computeBoundingRectangle(o,m,r,n,E),f=[],v=0;v