text: !function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e="undefined"!=typeof globalThis?globalThis:e||self).CesiumSensorVolumes=i()}(this,(function(){"use strict";
  /**
  	 * Cesium Sensor Volumes - https://github.com/Flowm/cesium-sensor-volumes
  	 *
  	 * Copyright 2016 Jonathan Lounsbury
  	 * Copyright 2011-2014 Analytical Graphics Inc. and Cesium Contributors
  	 *
  	 * Licensed under the Apache License, Version 2.0 (the "License");
  	 * you may not use this file except in compliance with the License.
  	 * You may obtain a copy of the License at
  	 *
  	 * http://www.apache.org/licenses/LICENSE-2.0
  	 *
  	 * Unless required by applicable law or agreed to in writing, software
  	 * distributed under the License is distributed on an "AS IS" BASIS,
  	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  	 * See the License for the specific language governing permissions and
  	 * limitations under the License.
  	 *
  	 * Portions licensed separately.
  	 * See https://github.com/Flowm/cesium-sensor-volumes/blob/master/LICENSE.md for full licensing details.
  	 *
  	 * Derived from Cesium Sensors - https://github.com/AnalyticalGraphicsInc/cesium-sensors
  	 */const e=Cesium.Cartesian3,i=Cesium.Color,t=Cesium.defined,o=Cesium.Spherical,r=Cesium.TimeInterval,n=Cesium.CzmlDataSource,s=Cesium.DataSourceDisplay,a=Cesium.defaultValue,l=Cesium.DeveloperError,h=Cesium.Event,c=Cesium.createMaterialPropertyDescriptor,u=Cesium.createPropertyDescriptor,d=Cesium.AssociativeArray,m=Cesium.destroyObject,f=Cesium.Math,_=Cesium.Matrix3,p=Cesium.Matrix4,C=Cesium.Quaternion,g=Cesium.MaterialProperty,v=Cesium.Property,w=Cesium.BoundingSphere,S=Cesium.combine,y=Cesium.ComponentDatatype,A=Cesium.PrimitiveType,M=Cesium.Buffer,x=Cesium.BufferUsage,I=Cesium.DrawCommand,b=Cesium.Pass,T=Cesium.RenderState,E=Cesium.ShaderProgram,k=Cesium.ShaderSource,P=Cesium.VertexArray,H=Cesium.BlendingState,V=Cesium.CullFace,W=Cesium.Material,O=Cesium.SceneMode,F=Cesium.clone,D=function(e){this._minimumClockAngle=void 0,this._minimumClockAngleSubscription=void 0,this._maximumClockAngle=void 0,this._maximumClockAngleSubscription=void 0,this._innerHalfAngle=void 0,this._innerHalfAngleSubscription=void 0,this._outerHalfAngle=void 0,this._outerHalfAngleSubscription=void 0,this._lateralSurfaceMaterial=void 0,this._lateralSurfaceMaterialSubscription=void 0,this._intersectionColor=void 0,this._intersectionColorSubscription=void 0,this._intersectionWidth=void 0,this._intersectionWidthSubscription=void 0,this._showIntersection=void 0,this._showIntersectionSubscription=void 0,this._radius=void 0,this._radiusSubscription=void 0,this._show=void 0,this._showSubscription=void 0,this._definitionChanged=new h,this.merge(a(e,a.EMPTY_OBJECT))};Object.defineProperties(D.prototype,{definitionChanged:{get:function(){return this._definitionChanged}},minimumClockAngle:u("minimumClockAngle"),maximumClockAngle:u("maximumClockAngle"),innerHalfAngle:u("innerHalfAngle"),outerHalfAngle:u("outerHalfAngle"),lateralSurfaceMaterial:c("lateralSurfaceMaterial"),intersectionColor:u("intersectionColor"),intersectionWidth:u("intersectionWidth"),showIntersection:u("showIntersection"),radius:u("radius"),show:u("show")}),D.prototype.clone=function(e){return t(e)||(e=new D),e.show=this.show,e.innerHalfAngle=this.innerHalfAngle,e.outerHalfAngle=this.outerHalfAngle,e.minimumClockAngle=this.minimumClockAngle,e.maximumClockAngle=this.maximumClockAngle,e.radius=this.radius,e.showIntersection=this.showIntersection,e.intersectionColor=this.intersectionColor,e.intersectionWidth=this.intersectionWidth,e.lateralSurfaceMaterial=this.lateralSurfaceMaterial,e},D.prototype.merge=function(e){if(!t(e))throw new l("source is required.");this.show=a(this.show,e.show),this.innerHalfAngle=a(this.innerHalfAngle,e.innerHalfAngle),this.outerHalfAngle=a(this.outerHalfAngle,e.outerHalfAngle),this.minimumClockAngle=a(this.minimumClockAngle,e.minimumClockAngle),this.maximumClockAngle=a(this.maximumClockAngle,e.maximumClockAngle),this.radius=a(this.radius,e.radius),this.showIntersection=a(this.showIntersection,e.showIntersection),this.intersectionColor=a(this.intersectionColor,e.intersectionColor),this.intersectionWidth=a(this.intersectionWidth,e.intersectionWidth),this.lateralSurfaceMaterial=a(this.lateralSurfaceMaterial,e.lateralSurfaceMaterial)};var z="uniform vec4 u_intersectionColor;uniform float u_intersectionWidth;bool inSensorShadow(vec3 coneVertexWC,vec3 pointWC){vec3 D=czm_ellipsoidInverseRadii;vec3 q=D*coneVertexWC;float qMagnitudeSquared=dot(q,q);float test=qMagnitudeSquared-1.0;vec3 temp=(D*pointWC)-q;float d=dot(temp,q);return (d<-test)&&((d/length(temp))<-sqrt(test));}vec4 getIntersectionColor(){return u_intersectionColor;}float getIntersectionWidth(){return u_intersectionWidth;}vec2 sensor2dTextureCoordinates(float sensorRadius,vec3 pointMC){float t=pointMC.z/sensorRadius;float s=1.0+(atan(pointMC.y,pointMC.x)/czm_twoPi);s=s-floor(s);return vec2(s,t);}",R="#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nuniform bool u_showIntersection;uniform bool u_showThroughEllipsoid;uniform float u_sensorRadius;uniform float u_normalDirection;varying vec3 v_positionWC;varying vec3 v_positionEC;varying vec3 v_normalEC;vec4 getColor(float sensorRadius,vec3 pointEC){czm_materialInput materialInput;vec3 pointMC=(czm_inverseModelView*vec4(pointEC,1.0)).xyz;materialInput.st=sensor2dTextureCoordinates(sensorRadius,pointMC);materialInput.str=pointMC/sensorRadius;vec3 positionToEyeEC=-v_positionEC;materialInput.positionToEyeEC=positionToEyeEC;vec3 normalEC=normalize(v_normalEC);materialInput.normalEC=u_normalDirection*normalEC;czm_material material=czm_getMaterial(materialInput);return mix(czm_phong(normalize(positionToEyeEC),material,czm_lightDirectionEC),vec4(material.diffuse,material.alpha),0.4);}bool isOnBoundary(float value,float epsilon){float width=getIntersectionWidth();float tolerance=width*epsilon;\n#ifdef GL_OES_standard_derivatives\nfloat delta=max(abs(dFdx(value)),abs(dFdy(value)));float pixels=width*delta;float temp=abs(value);return ((temp<tolerance)&&(temp<pixels))||(((delta<(10.0*tolerance))&&((temp-delta)<tolerance))&&(temp<pixels));\n#else\nreturn abs(value)<tolerance;\n#endif\n}vec4 shade(bool isOnBoundary){if(u_showIntersection&&isOnBoundary){return getIntersectionColor();}return getColor(u_sensorRadius,v_positionEC);}float ellipsoidSurfaceFunction(vec3 point){vec3 scaled=czm_ellipsoidInverseRadii*point;return dot(scaled,scaled)-1.0;}void main(){vec3 sensorVertexWC=(czm_model[3]).xyz;vec3 sensorVertexEC=(czm_modelView[3]).xyz;float ellipsoidValue=ellipsoidSurfaceFunction(v_positionWC);if(!u_showThroughEllipsoid){if(ellipsoidValue<0.0){discard;}if(inSensorShadow(sensorVertexWC,v_positionWC)){discard;}}if(distance(v_positionEC,sensorVertexEC)>u_sensorRadius){discard;}bool isOnEllipsoid=isOnBoundary(ellipsoidValue,czm_epsilon3);gl_FragColor=shade(isOnEllipsoid);}",N="attribute vec4 position;attribute vec3 normal;varying vec3 v_positionWC;varying vec3 v_positionEC;varying vec3 v_normalEC;void main(){gl_Position=czm_modelViewProjection*position;v_positionWC=(czm_model*position).xyz;v_positionEC=(czm_modelView*position).xyz;v_normalEC=czm_normal*normal;}";const q={position:0,normal:1},B=5906376272e3,L=function(e){e=a(e,a.EMPTY_OBJECT),this._pickId=void 0,this._pickPrimitive=a(e._pickPrimitive,this),this._frontFaceColorCommand=new I,this._backFaceColorCommand=new I,this._pickCommand=new I,this._boundingSphere=new w,this._boundingSphereWC=new w,this._frontFaceColorCommand.primitiveType=A.TRIANGLES,this._frontFaceColorCommand.boundingVolume=this._boundingSphereWC,this._frontFaceColorCommand.owner=this,this._backFaceColorCommand.primitiveType=this._frontFaceColorCommand.primitiveType,this._backFaceColorCommand.boundingVolume=this._frontFaceColorCommand.boundingVolume,this._backFaceColorCommand.owner=this,this._pickCommand.primitiveType=this._frontFaceColorCommand.primitiveType,this._pickCommand.boundingVolume=this._frontFaceColorCommand.boundingVolume,this._pickCommand.owner=this,this.show=a(e.show,!0),this.showIntersection=a(e.showIntersection,!0),this.showThroughEllipsoid=a(e.showThroughEllipsoid,!1),this._showThroughEllipsoid=this.showThroughEllipsoid,this.modelMatrix=p.clone(a(e.modelMatrix,p.IDENTITY)),this._modelMatrix=new p,this.radius=a(e.radius,Number.POSITIVE_INFINITY),this._directions=void 0,this._directionsDirty=!1,this.directions=t(e.directions)?e.directions:[],this.lateralSurfaceMaterial=t(e.lateralSurfaceMaterial)?e.lateralSurfaceMaterial:W.fromType(W.ColorType),this._lateralSurfaceMaterial=void 0,this._translucent=void 0,this.intersectionColor=i.clone(a(e.intersectionColor,i.WHITE)),this.intersectionWidth=a(e.intersectionWidth,5),this.id=e.id,this._id=void 0;var o=this;this._uniforms={u_showThroughEllipsoid:function(){return o.showThroughEllipsoid},u_showIntersection:function(){return o.showIntersection},u_sensorRadius:function(){return isFinite(o.radius)?o.radius:B},u_intersectionColor:function(){return o.intersectionColor},u_intersectionWidth:function(){return o.intersectionWidth},u_normalDirection:function(){return 1}},this._mode=O.SCENE3D};Object.defineProperties(L.prototype,{directions:{get:function(){return this._directions},set:function(e){this._directions=e,this._directionsDirty=!0}}});const U=new e,Y=new e,j=new e;const G=new e;function Q(i,t){for(var o=function(i){for(var t=i._directions,o=t.length,r=new Float32Array(3*o),n=isFinite(i.radius)?i.radius:B,s=[e.ZERO],a=o-2,l=o-1,h=0;h<o;a=l++,l=h++){var c=e.fromSpherical(t[a],U),u=e.fromSpherical(t[l],Y),d=e.fromSpherical(t[h],j),m=Math.max(e.angleBetween(c,u),e.angleBetween(u,d)),f=n/Math.cos(.5*m),_=e.multiplyByScalar(u,f,new e);r[3*l]=_.x,r[3*l+1]=_.y,r[3*l+2]=_.z,s.push(_)}return w.fromPoints(s,i._boundingSphere),r}(i),r=i._directions.length,n=new Float32Array(18*r),s=0,a=r-1,l=0;l<r;a=l++){var h=new e(o[3*a],o[3*a+1],o[3*a+2]),c=new e(o[3*l],o[3*l+1],o[3*l+2]),u=e.normalize(e.cross(c,h,G),G);n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=u.x,n[s++]=u.y,n[s++]=u.z,n[s++]=c.x,n[s++]=c.y,n[s++]=c.z,n[s++]=u.x,n[s++]=u.y,n[s++]=u.z,n[s++]=h.x,n[s++]=h.y,n[s++]=h.z,n[s++]=u.x,n[s++]=u.y,n[s++]=u.z}var d=M.createVertexBuffer({context:t,typedArray:new Float32Array(n),usage:x.STATIC_DRAW}),m=6*Float32Array.BYTES_PER_ELEMENT,f=[{index:q.position,vertexBuffer:d,componentsPerAttribute:3,componentDatatype:y.FLOAT,offsetInBytes:0,strideInBytes:m},{index:q.normal,vertexBuffer:d,componentsPerAttribute:3,componentDatatype:y.FLOAT,offsetInBytes:3*Float32Array.BYTES_PER_ELEMENT,strideInBytes:m}];return new P({context:t,attributes:f})}function J(e,i,o){var r=i[e.id];if(t(r)){var n=r.primitive;o.remove(n),n.isDestroyed()||n.destroy(),delete i[e.id]}}L.prototype.update=function(e){if(this._mode=e.mode,this.show&&this._mode===O.SCENE3D){var i=e.context,o=e.commandList;if(this.radius<0)throw new l("this.radius must be greater than or equal to zero.");if(!t(this.lateralSurfaceMaterial))throw new l("this.lateralSurfaceMaterial must be defined.");var r,n=this.lateralSurfaceMaterial.isTranslucent();if(this._showThroughEllipsoid!==this.showThroughEllipsoid||!t(this._frontFaceColorCommand.renderState)||this._translucent!==n)this._showThroughEllipsoid=this.showThroughEllipsoid,this._translucent=n,n?(r=T.fromCache({depthTest:{enabled:!this.showThroughEllipsoid},depthMask:!1,blending:H.ALPHA_BLEND,cull:{enabled:!0,face:V.BACK}}),this._frontFaceColorCommand.renderState=r,this._frontFaceColorCommand.pass=b.TRANSLUCENT,r=T.fromCache({depthTest:{enabled:!this.showThroughEllipsoid},depthMask:!1,blending:H.ALPHA_BLEND,cull:{enabled:!0,face:V.FRONT}}),this._backFaceColorCommand.renderState=r,this._backFaceColorCommand.pass=b.TRANSLUCENT,r=T.fromCache({depthTest:{enabled:!this.showThroughEllipsoid},depthMask:!1,blending:H.ALPHA_BLEND}),this._pickCommand.renderState=r):(r=T.fromCache({depthTest:{enabled:!0},depthMask:!0}),this._frontFaceColorCommand.renderState=r,this._frontFaceColorCommand.pass=b.OPAQUE,r=T.fromCache({depthTest:{enabled:!0},depthMask:!0}),this._pickCommand.renderState=r);var s=this._directionsDirty;if(s){this._directionsDirty=!1,this._va=this._va&&this._va.destroy();var a=this._directions;a&&a.length>=3&&(this._frontFaceColorCommand.vertexArray=Q(this,i),this._backFaceColorCommand.vertexArray=this._frontFaceColorCommand.vertexArray,this._pickCommand.vertexArray=this._frontFaceColorCommand.vertexArray)}if(t(this._frontFaceColorCommand.vertexArray)){var h=e.passes,c=!p.equals(this.modelMatrix,this._modelMatrix);c&&p.clone(this.modelMatrix,this._modelMatrix),(s||c)&&w.transform(this._boundingSphere,this.modelMatrix,this._boundingSphereWC),this._frontFaceColorCommand.modelMatrix=this.modelMatrix,this._backFaceColorCommand.modelMatrix=this._frontFaceColorCommand.modelMatrix,this._pickCommand.modelMatrix=this._frontFaceColorCommand.modelMatrix;var u=this._lateralSurfaceMaterial!==this.lateralSurfaceMaterial;if(this._lateralSurfaceMaterial=this.lateralSurfaceMaterial,this._lateralSurfaceMaterial.update(i),h.render){var d=this._frontFaceColorCommand,m=this._backFaceColorCommand;if(u||!t(d.shaderProgram)){var f=new k({sources:[z,this._lateralSurfaceMaterial.shaderSource,R]});d.shaderProgram=E.replaceCache({context:i,shaderProgram:d.shaderProgram,vertexShaderSource:N,fragmentShaderSource:f,attributeLocations:q}),d.uniformMap=S(this._uniforms,this._lateralSurfaceMaterial._uniforms),m.shaderProgram=d.shaderProgram,m.uniformMap=S(this._uniforms,this._lateralSurfaceMaterial._uniforms),m.uniformMap.u_normalDirection=function(){return-1}}n?o.push(this._backFaceColorCommand,this._frontFaceColorCommand):o.push(this._frontFaceColorCommand)}if(h.pick){var _=this._pickCommand;if(t(this._pickId)&&this._id===this.id||(this._id=this.id,this._pickId=this._pickId&&this._pickId.destroy(),this._pickId=i.createPickId({primitive:this._pickPrimitive,id:this.id})),u||!t(_.shaderProgram)){var C=new k({sources:[z,this._lateralSurfaceMaterial.shaderSource,R],pickColorQualifier:"uniform"});_.shaderProgram=E.replaceCache({context:i,shaderProgram:_.shaderProgram,vertexShaderSource:N,fragmentShaderSource:C,attributeLocations:q});var g=this,v={czm_pickColor:function(){return g._pickId.color}};_.uniformMap=S(S(this._uniforms,this._lateralSurfaceMaterial._uniforms),v)}_.pass=n?b.TRANSLUCENT:b.OPAQUE,o.push(_)}}}},L.prototype.isDestroyed=function(){return!1},L.prototype.destroy=function(){return this._frontFaceColorCommand.vertexArray=this._frontFaceColorCommand.vertexArray&&this._frontFaceColorCommand.vertexArray.destroy(),this._frontFaceColorCommand.shaderProgram=this._frontFaceColorCommand.shaderProgram&&this._frontFaceColorCommand.shaderProgram.destroy(),this._pickCommand.shaderProgram=this._pickCommand.shaderProgram&&this._pickCommand.shaderProgram.destroy(),this._pickId=this._pickId&&this._pickId.destroy(),m(this)};const K=i.WHITE,Z=Number.POSITIVE_INFINITY,X=new _,$=new e,ee=new C;function ie(e,i,r,n){var s=i[e];t(s)||(s=new o,i[e]=s),s.clock=r,s.cone=n,s.magnitude=1}function te(e,i,t,o,r){var n,s=e.directions,a=0,l=f.toRadians(2);if(0===i&&t===f.TWO_PI)for(n=0;n<f.TWO_PI;n+=l)ie(a++,s,n,r);else{for(n=i;n<t;n+=l)ie(a++,s,n,r);if(ie(a++,s,t,r),o){for(n=t;n>i;n-=l)ie(a++,s,n,o);ie(a++,s,i,o)}else ie(a++,s,t,0)}s.length=a,e.directions=s}const oe=function(e,i){if(!t(e))throw new l("scene is required.");if(!t(i))throw new l("entityCollection is required.");i.collectionChanged.addEventListener(oe.prototype._onCollectionChanged,this),this._scene=e,this._primitives=e.primitives,this._entityCollection=i,this._hash={},this._entitiesToVisualize=new d,this._onCollectionChanged(i,i.values,[],[])};oe.prototype.update=function(i){if(!t(i))throw new l("time is required.");for(var o=this._entitiesToVisualize.values,r=this._hash,n=this._primitives,s=0,a=o.length;s<a;s++){var h,c,u=o[s],d=u._conicSensor,m=r[u.id],w=u.isShowing&&u.isAvailable(i)&&v.getValueOrDefault(d._show,i,!0);if(w&&(h=v.getValueOrUndefined(u._position,i,$),c=v.getValueOrUndefined(u._orientation,i,ee),w=t(h)&&t(c)),w){var S=t(m)?m.primitive:void 0;t(S)||((S=new L).id=u,n.add(S),m={primitive:S,position:void 0,orientation:void 0,minimumClockAngle:void 0,maximumClockAngle:void 0,innerHalfAngle:void 0,outerHalfAngle:void 0},r[u.id]=m),e.equals(h,m.position)&&C.equals(c,m.orientation)||(p.fromRotationTranslation(_.fromQuaternion(c,X),h,S.modelMatrix),m.position=e.clone(h,m.position),m.orientation=C.clone(c,m.orientation)),S.show=!0;var y=v.getValueOrDefault(d._minimumClockAngle,i,0),A=v.getValueOrDefault(d._maximumClockAngle,i,f.TWO_PI),M=v.getValueOrDefault(d._innerHalfAngle,i,0),x=v.getValueOrDefault(d._outerHalfAngle,i,Math.PI);y===m.minimumClockAngle&&A===m.maximumClockAngle&&M===m.innerHalfAngle&&x===m.outerHalfAngle||(te(S,y,A,M,x),m.innerHalfAngle=M,m.maximumClockAngle=A,m.outerHalfAngle=x,m.minimumClockAngle=y),S.radius=v.getValueOrDefault(d._radius,i,Z),S.lateralSurfaceMaterial=g.getValue(i,d._lateralSurfaceMaterial,S.lateralSurfaceMaterial),S.intersectionColor=v.getValueOrClonedDefault(d._intersectionColor,i,K,S.intersectionColor),S.intersectionWidth=v.getValueOrDefault(d._intersectionWidth,i,1)}else t(m)&&(m.primitive.show=!1)}return!0},oe.prototype.isDestroyed=function(){return!1},oe.prototype.destroy=function(){for(var e=this._entitiesToVisualize.values,i=this._hash,t=this._primitives,o=e.length-1;o>-1;o--)J(e[o],i,t);return m(this)},oe.prototype._onCollectionChanged=function(e,i,o,r){var n,s,a=this._entitiesToVisualize,l=this._hash,h=this._primitives;for(n=i.length-1;n>-1;n--)s=i[n],t(s._conicSensor)&&t(s._position)&&t(s._orientation)&&a.set(s.id,s);for(n=r.length-1;n>-1;n--)s=r[n],t(s._conicSensor)&&t(s._position)&&t(s._orientation)?a.set(s.id,s):(J(s,l,h),a.remove(s.id));for(n=o.length-1;n>-1;n--)J(s=o[n],l,h),a.remove(s.id)};const re=function(e){this._directions=void 0,this._directionsSubscription=void 0,this._lateralSurfaceMaterial=void 0,this._lateralSurfaceMaterialSubscription=void 0,this._intersectionColor=void 0,this._intersectionColorSubscription=void 0,this._intersectionWidth=void 0,this._intersectionWidthSubscription=void 0,this._showIntersection=void 0,this._showIntersectionSubscription=void 0,this._radius=void 0,this._radiusSubscription=void 0,this._show=void 0,this._showSubscription=void 0,this._definitionChanged=new h,this.merge(a(e,a.EMPTY_OBJECT))};Object.defineProperties(re.prototype,{definitionChanged:{get:function(){return this._definitionChanged}},directions:u("directions"),lateralSurfaceMaterial:c("lateralSurfaceMaterial"),intersectionColor:u("intersectionColor"),intersectionWidth:u("intersectionWidth"),showIntersection:u("showIntersection"),radius:u("radius"),show:u("show")}),re.prototype.clone=function(e){return t(e)||(e=new re),e.directions=this.directions,e.radius=this.radius,e.show=this.show,e.showIntersection=this.showIntersection,e.intersectionColor=this.intersectionColor,e.intersectionWidth=this.intersectionWidth,e.lateralSurfaceMaterial=this.lateralSurfaceMaterial,e},re.prototype.merge=function(e){if(!t(e))throw new l("source is required.");this.directions=a(this.directions,e.directions),this.radius=a(this.radius,e.radius),this.show=a(this.show,e.show),this.showIntersection=a(this.showIntersection,e.showIntersection),this.intersectionColor=a(this.intersectionColor,e.intersectionColor),this.intersectionWidth=a(this.intersectionWidth,e.intersectionWidth),this.lateralSurfaceMaterial=a(this.lateralSurfaceMaterial,e.lateralSurfaceMaterial)};const ne=i.WHITE,se=Number.POSITIVE_INFINITY,ae=new _,le=new e,he=new C,ce=function(e,i){if(!t(e))throw new l("scene is required.");if(!t(i))throw new l("entityCollection is required.");i.collectionChanged.addEventListener(ce.prototype._onCollectionChanged,this),this._scene=e,this._primitives=e.primitives,this._entityCollection=i,this._hash={},this._entitiesToVisualize=new d,this._onCollectionChanged(i,i.values,[],[])};ce.prototype.update=function(i){if(!t(i))throw new l("time is required.");for(var o=this._entitiesToVisualize.values,r=this._hash,n=this._primitives,s=0,a=o.length;s<a;s++){var h,c,u,d=o[s],m=d._customPatternSensor,f=r[d.id],w=d.isShowing&&d.isAvailable(i)&&v.getValueOrDefault(m._show,i,!0);if(w&&(h=v.getValueOrUndefined(d._position,i,le),c=v.getValueOrUndefined(d._orientation,i,he),u=v.getValueOrUndefined(m._directions,i),w=t(h)&&t(c)&&t(u)),w){var S=t(f)?f.primitive:void 0;t(S)||((S=new L).id=d,n.add(S),f={primitive:S,position:void 0,orientation:void 0},r[d.id]=f),e.equals(h,f.position)&&C.equals(c,f.orientation)||(p.fromRotationTranslation(_.fromQuaternion(c,ae),h,S.modelMatrix),f.position=e.clone(h,f.position),f.orientation=C.clone(c,f.orientation)),S.show=!0,S.directions=u,S.radius=v.getValueOrDefault(m._radius,i,se),S.lateralSurfaceMaterial=g.getValue(i,m._lateralSurfaceMaterial,S.lateralSurfaceMaterial),S.intersectionColor=v.getValueOrClonedDefault(m._intersectionColor,i,ne,S.intersectionColor),S.intersectionWidth=v.getValueOrDefault(m._intersectionWidth,i,1)}else t(f)&&(f.primitive.show=!1)}return!0},ce.prototype.isDestroyed=function(){return!1},ce.prototype.destroy=function(){for(var e=this._entitiesToVisualize.values,i=this._hash,t=this._primitives,o=e.length-1;o>-1;o--)J(e[o],i,t);return m(this)},ce.prototype._onCollectionChanged=function(e,i,o,r){var n,s,a=this._entitiesToVisualize,l=this._hash,h=this._primitives;for(n=i.length-1;n>-1;n--)s=i[n],t(s._customPatternSensor)&&t(s._position)&&t(s._orientation)&&a.set(s.id,s);for(n=r.length-1;n>-1;n--)s=r[n],t(s._customPatternSensor)&&t(s._position)&&t(s._orientation)?a.set(s.id,s):(J(s,l,h),a.remove(s.id));for(n=o.length-1;n>-1;n--)J(s=o[n],l,h),a.remove(s.id)};const ue=function(){this._xHalfAngle=void 0,this._xHalfAngleSubscription=void 0,this._yHalfAngle=void 0,this._yHalfAngleSubscription=void 0,this._lateralSurfaceMaterial=void 0,this._lateralSurfaceMaterialSubscription=void 0,this._intersectionColor=void 0,this._intersectionColorSubscription=void 0,this._intersectionWidth=void 0,this._intersectionWidthSubscription=void 0,this._showIntersection=void 0,this._showIntersectionSubscription=void 0,this._radius=void 0,this._radiusSubscription=void 0,this._show=void 0,this._showSubscription=void 0,this._definitionChanged=new h};function de(e,i,r,n){var s=i[e];t(s)||(s=new o,i[e]=s),s.clock=r,s.cone=n,s.magnitude=1}function me(e){var i=e._customSensor.directions,t=Math.tan(Math.min(e._xHalfAngle,f.toRadians(89))),o=Math.tan(Math.min(e._yHalfAngle,f.toRadians(89))),r=Math.atan(t/o),n=Math.atan(Math.sqrt(t*t+o*o));de(0,i,r,n),de(1,i,f.toRadians(180)-r,n),de(2,i,f.toRadians(180)+r,n),de(3,i,-r,n),i.length=4,e._customSensor.directions=i}Object.defineProperties(ue.prototype,{definitionChanged:{get:function(){return this._definitionChanged}},xHalfAngle:u("xHalfAngle"),yHalfAngle:u("yHalfAngle"),lateralSurfaceMaterial:u("lateralSurfaceMaterial"),intersectionColor:u("intersectionColor"),intersectionWidth:u("intersectionWidth"),showIntersection:u("showIntersection"),radius:u("radius"),show:u("show")}),ue.prototype.clone=function(e){return t(e)||(e=new ue),e.xHalfAngle=this.xHalfAngle,e.yHalfAngle=this.yHalfAngle,e.radius=this.radius,e.show=this.show,e.showIntersection=this.showIntersection,e.intersectionColor=this.intersectionColor,e.intersectionWidth=this.intersectionWidth,e.lateralSurfaceMaterial=this.lateralSurfaceMaterial,e},ue.prototype.merge=function(e){if(!t(e))throw new l("source is required.");this.xHalfAngle=a(this.xHalfAngle,e.xHalfAngle),this.yHalfAngle=a(this.yHalfAngle,e.yHalfAngle),this.radius=a(this.radius,e.radius),this.show=a(this.show,e.show),this.showIntersection=a(this.showIntersection,e.showIntersection),this.intersectionColor=a(this.intersectionColor,e.intersectionColor),this.intersectionWidth=a(this.intersectionWidth,e.intersectionWidth),this.lateralSurfaceMaterial=a(this.lateralSurfaceMaterial,e.lateralSurfaceMaterial)};const fe=function(e){e=a(e,a.EMPTY_OBJECT);var i=F(e);i._pickPrimitive=a(e._pickPrimitive,this),i.directions=void 0,this._customSensor=new L(i),this._xHalfAngle=a(e.xHalfAngle,f.PI_OVER_TWO),this._yHalfAngle=a(e.yHalfAngle,f.PI_OVER_TWO),me(this)};Object.defineProperties(fe.prototype,{xHalfAngle:{get:function(){return this._xHalfAngle},set:function(e){if(e>f.PI_OVER_TWO)throw new l("xHalfAngle must be less than or equal to 90 degrees.");this._xHalfAngle!==e&&(this._xHalfAngle=e,me(this))}},yHalfAngle:{get:function(){return this._yHalfAngle},set:function(e){if(e>f.PI_OVER_TWO)throw new l("yHalfAngle must be less than or equal to 90 degrees.");this._yHalfAngle!==e&&(this._yHalfAngle=e,me(this))}},show:{get:function(){return this._customSensor.show},set:function(e){this._customSensor.show=e}},showIntersection:{get:function(){return this._customSensor.showIntersection},set:function(e){this._customSensor.showIntersection=e}},showThroughEllipsoid:{get:function(){return this._customSensor.showThroughEllipsoid},set:function(e){this._customSensor.showThroughEllipsoid=e}},modelMatrix:{get:function(){return this._customSensor.modelMatrix},set:function(e){this._customSensor.modelMatrix=e}},radius:{get:function(){return this._customSensor.radius},set:function(e){this._customSensor.radius=e}},lateralSurfaceMaterial:{get:function(){return this._customSensor.lateralSurfaceMaterial},set:function(e){this._customSensor.lateralSurfaceMaterial=e}},intersectionColor:{get:function(){return this._customSensor.intersectionColor},set:function(e){this._customSensor.intersectionColor=e}},intersectionWidth:{get:function(){return this._customSensor.intersectionWidth},set:function(e){this._customSensor.intersectionWidth=e}},id:{get:function(){return this._customSensor.id},set:function(e){this._customSensor.id=e}}}),fe.prototype.update=function(e){this._customSensor.update(e)},fe.prototype.isDestroyed=function(){return!1},fe.prototype.destroy=function(){return this._customSensor=this._customSensor&&this._customSensor.destroy(),m(this)};const _e=i.WHITE,pe=Number.POSITIVE_INFINITY,Ce=new _,ge=new e,ve=new C,we=function(e,i){if(!t(e))throw new l("scene is required.");if(!t(i))throw new l("entityCollection is required.");i.collectionChanged.addEventListener(we.prototype._onCollectionChanged,this),this._scene=e,this._primitives=e.primitives,this._entityCollection=i,this._hash={},this._entitiesToVisualize=new d,this._onCollectionChanged(i,i.values,[],[])};we.prototype.update=function(i){if(!t(i))throw new l("time is required.");for(var o=this._entitiesToVisualize.values,r=this._hash,n=this._primitives,s=0,a=o.length;s<a;s++){var h,c,u=o[s],d=u._rectangularSensor,m=r[u.id],w=u.isShowing&&u.isAvailable(i)&&v.getValueOrDefault(d._show,i,!0);if(w&&(h=v.getValueOrUndefined(u._position,i,ge),c=v.getValueOrUndefined(u._orientation,i,ve),w=t(h)&&t(c)),w){var S=t(m)?m.primitive:void 0;t(S)||((S=new fe).id=u,n.add(S),m={primitive:S,position:void 0,orientation:void 0},r[u.id]=m),e.equals(h,m.position)&&C.equals(c,m.orientation)||(p.fromRotationTranslation(_.fromQuaternion(c,Ce),h,S.modelMatrix),m.position=e.clone(h,m.position),m.orientation=C.clone(c,m.orientation)),S.show=!0,S.xHalfAngle=v.getValueOrDefault(d._xHalfAngle,i,f.PI_OVER_TWO),S.yHalfAngle=v.getValueOrDefault(d._yHalfAngle,i,f.PI_OVER_TWO),S.radius=v.getValueOrDefault(d._radius,i,pe),S.lateralSurfaceMaterial=g.getValue(i,d._lateralSurfaceMaterial,S.lateralSurfaceMaterial),S.intersectionColor=v.getValueOrClonedDefault(d._intersectionColor,i,_e,S.intersectionColor),S.intersectionWidth=v.getValueOrDefault(d._intersectionWidth,i,1)}else t(m)&&(m.primitive.show=!1)}return!0},we.prototype.isDestroyed=function(){return!1},we.prototype.destroy=function(){for(var e=this._entitiesToVisualize.values,i=this._hash,t=this._primitives,o=e.length-1;o>-1;o--)J(e[o],i,t);return m(this)},we.prototype._onCollectionChanged=function(e,i,o,r){var n,s,a=this._entitiesToVisualize,l=this._hash,h=this._primitives;for(n=i.length-1;n>-1;n--)s=i[n],t(s._rectangularSensor)&&t(s._position)&&t(s._orientation)&&a.set(s.id,s);for(n=r.length-1;n>-1;n--)s=r[n],t(s._rectangularSensor)&&t(s._position)&&t(s._orientation)?a.set(s.id,s):(J(s,l,h),a.remove(s.id));for(n=o.length-1;n>-1;n--)J(s=o[n],l,h),a.remove(s.id)};var Se=n.processPacketData,ye=n.processMaterialPacketData;function Ae(i,r,n,s,a){var l,h,c=[],u=r.unitSpherical,d=r.spherical,m=r.unitCartesian,f=r.cartesian;if(t(u)){for(l=0,h=u.length;l<h;l+=2)c.push(new o(u[l],u[l+1]));r.array=c}else if(t(d)){for(l=0,h=d.length;l<h;l+=3)c.push(new o(d[l],d[l+1],d[l+2]));r.array=c}else if(t(m)){for(l=0,h=m.length;l<h;l+=3){var _=o.fromCartesian3(new e(m[l],m[l+1],m[l+2]));o.normalize(_,_),c.push(_)}r.array=c}else if(t(f)){for(l=0,h=f.length;l<h;l+=3)c.push(o.fromCartesian3(new e(f[l],f[l+1],f[l+2])));r.array=c}Se(Array,i,"directions",r,n,s,a)}function Me(e,t,o,r,n){Se(Boolean,e,"show",t.show,o,r,n),Se(Number,e,"radius",t.radius,o,r,n),Se(Boolean,e,"showIntersection",t.showIntersection,o,r,n),Se(i,e,"intersectionColor",t.intersectionColor,o,r,n),Se(Number,e,"intersectionWidth",t.intersectionWidth,o,r,n),ye(e,"lateralSurfaceMaterial",t.lateralSurfaceMaterial,o,r,n)}var xe={iso8601:void 0};function Ie(e,i,o,n){var s=i.agi_conicSensor;if(t(s)){var a,l=s.interval;t(l)&&(xe.iso8601=l,a=r.fromIso8601(xe));var h=e.conicSensor;t(h)||(e.addProperty("conicSensor"),h=new D,e.conicSensor=h),Me(h,s,a,n,o),Se(Number,h,"innerHalfAngle",s.innerHalfAngle,a,n,o),Se(Number,h,"outerHalfAngle",s.outerHalfAngle,a,n,o),Se(Number,h,"minimumClockAngle",s.minimumClockAngle,a,n,o),Se(Number,h,"maximumClockAngle",s.maximumClockAngle,a,n,o)}}function be(e,i,o,n){var s=i.agi_customPatternSensor;if(t(s)){var a,l=s.interval;t(l)&&(xe.iso8601=l,a=r.fromIso8601(xe));var h=e.customPatternSensor;t(h)||(e.addProperty("customPatternSensor"),h=new re,e.customPatternSensor=h),Me(h,s,a,n,o);var c=s.directions;if(t(c))if(Array.isArray(c))for(var u=c.length,d=0;d<u;d++)Ae(h,c[d],a,n,o);else Ae(h,c,a,n,o)}}function Te(e,i,o,n){var s=i.agi_rectangularSensor;if(t(s)){var a,l=s.interval;t(l)&&(xe.iso8601=l,a=r.fromIso8601(xe));var h=e.rectangularSensor;t(h)||(e.addProperty("rectangularSensor"),h=new ue,e.rectangularSensor=h),Me(h,s,a,n,o),Se(Number,h,"xHalfAngle",s.xHalfAngle,a,n,o),Se(Number,h,"yHalfAngle",s.yHalfAngle,a,n,o)}}var Ee=!1;return function(){if(!Ee){n.updaters.push(Ie,be,Te);var e=s.defaultVisualizersCallback;s.defaultVisualizersCallback=function(i,t,o){var r=o.entities;return e(i,t,o).concat([new oe(i,r),new ce(i,r),new we(i,r)])},Ee=!0}}(),{ConicSensorGraphics:D,ConicSensorVisualizer:oe,CustomPatternSensorGraphics:re,CustomPatternSensorVisualizer:ce,CustomSensorVolume:L,RectangularPyramidSensorVolume:fe,RectangularSensorGraphics:ue,RectangularSensorVisualizer:we}}));
  