@map-colonies/react-components 4.9.0 → 4.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2267,12 +2267,12 @@ const An = De(null), es = An.Provider, ce = () => {
2267
2267
  }, u = (T) => {
2268
2268
  let M = null;
2269
2269
  T.setInputAction((S) => {
2270
- if (v.scene.mode === Ce.SCENE3D) {
2271
- const I = C(S.endPosition);
2272
- I ? Z(M, "id") !== Z(I, "id") && (M && (M[s(M)].material = U, v.container.style.cursor = "default"), M = I, M[s(M)].material = W, v.container.style.cursor = "pointer") : M && (M[s(M)].material = U, M = null, v.container.style.cursor = "default");
2273
- } else {
2270
+ if (v.scene.mode === Ce.SCENE2D) {
2274
2271
  const I = v.scene.pick(S.endPosition);
2275
2272
  I && I.id && (I.id.polygon || I.id.polyline) ? Z(M, "id") !== Z(I.id, "id") && (M && (M[s(M)].material = N, v.container.style.cursor = "default"), M = I.id, M[s(M)].material = W, v.container.style.cursor = "pointer") : M && (M[s(M)].material = N, M = null, v.container.style.cursor = "default");
2273
+ } else {
2274
+ const I = C(S.endPosition);
2275
+ I ? Z(M, "id") !== Z(I, "id") && (M && (M[s(M)].material = U, v.container.style.cursor = "default"), M = I, M[s(M)].material = W, v.container.style.cursor = "pointer") : M && (M[s(M)].material = U, M = null, v.container.style.cursor = "default");
2276
2276
  }
2277
2277
  }, ft.MOUSE_MOVE);
2278
2278
  }, y = (T, M) => {
@@ -9,7 +9,7 @@
9
9
  ${I.join("")}
10
10
  </tbody>
11
11
  </table>
12
- `},a=_=>_?_.polyline?"polyline":"polygon":"",l=_=>{var F,N;const I=(N=(F=_==null?void 0:_.polygon)==null?void 0:F.hierarchy)==null?void 0:N.getValue(p.JulianDate.now());if(!I)return null;const P=I.positions;return p.BoundingSphere.fromPoints(P).center},C=_=>{const P=T.scene.drillPick(_).map(N=>N.id).filter(N=>N&&N.polygon&&N.entityCollection.owner.name===H);if(P.length===0)return null;const F=P.map(N=>{const J=l(N);if(!J)return{entity:N,distance:Number.MAX_VALUE};const se=p.SceneTransforms.wgs84ToWindowCoordinates(T.scene,J);if(!se)return{entity:N,distance:Number.MAX_VALUE};const ce=_.x-se.x,re=_.y-se.y,de=Math.sqrt(ce*ce+re*re);return{entity:N,distance:de}});return F.sort((N,J)=>J.distance-N.distance),F[0].entity},g=_=>{let I=null;_.setInputAction(P=>{if(T.scene.mode===p.SceneMode.SCENE3D){const N=C(P.endPosition);N?q.get(I,"id")!==q.get(N,"id")&&(I&&(I[a(I)].material=Y,T.container.style.cursor="default"),I=N,I[a(I)].material=j,T.container.style.cursor="pointer"):I&&(I[a(I)].material=Y,I=null,T.container.style.cursor="default")}else{const N=T.scene.pick(P.endPosition);N&&N.id&&(N.id.polygon||N.id.polyline)?q.get(I,"id")!==q.get(N.id,"id")&&(I&&(I[a(I)].material=V,T.container.style.cursor="default"),I=N.id,I[a(I)].material=j,T.container.style.cursor="pointer"):I&&(I[a(I)].material=V,I=null,T.container.style.cursor="default")}},p.ScreenSpaceEventType.MOUSE_MOVE)},S=(_,I)=>{const P=navigator.hardwareConcurrency||4;let F=Math.ceil(P*1.5);return I==="cpu"&&(F=Math.max(2,Math.ceil(P/2))),_>=m?Math.min(200,F*4):_>1e3?Math.min(100,F*2):_>300?Math.min(50,F):Math.min(10,F)},y=(_=-1,I=-1)=>{X(P=>({...P,...t,cache:z.current.size,items:_,total:I,currentZoomLevel:T.currentZoomLevel}))},L=()=>{W.entities&&W.entities.values.length>0&&(W.show=!1,Z.current=0),y(0,0)},E=async(_,I="GET",P)=>{const F={method:I};P!==void 0&&(F.body=P);const N=await fetch(_,F);if(N.status===200)return await N.json()},D=async(_,I)=>{const P=[];return _.length>0&&await et(_,F=>{if(F.properties){const N=F.properties[v??"id"];z.current.has(N)||(z.current.add(N),F.properties.fetch_id=I,P.push(F))}},{concurrency:S(_.length,"cpu")}),P},k=(_,I)=>Array.from(G.current.values()).filter(P=>JSON.stringify(P.parentBBox)!==JSON.stringify(_)).reduce((P,F)=>{const N=Ti(I,F.bbox);return N>P.distance?{id:F.id,key:F.bbox.join(","),distance:N}:P},{id:"",key:"",distance:-1/0}),A=async _=>{const I=[];await et(W.entities.values,P=>{if(P.properties&&P.properties.fetch_id.getValue()===_){const F=P.properties[v??"id"].getValue();z.current.delete(F),I.push(P)}},{concurrency:S(W.entities.values.length,"cpu")}),I.length>0&&await et(I,P=>{W.entities.remove(P)},{concurrency:S(I.length,"cpu")})},O=async(_,I)=>{for(;z.current.size>m;){const P=k(_,I);if(P.id==="")break;await A(P.id),P.key&&G.current.delete(P.key)}},x=async(_,I,P,F)=>{let N="",J="",se=[];if(_.numberReturned&&_.numberReturned!==0&&(_.bbox&&(J=_.bbox.join(","),G.current.has(J)||(N=yt.v4())),se=await D(_.features,N),_.bbox&&se.length>0&&!G.current.has(J)&&G.current.set(J,{id:N,parentBBox:I,bbox:_.bbox,timestamp:_.timeStamp,items:se.length})),y(_.numberReturned!==0?P+_.numberReturned:_.numberMatched,_.numberMatched),se.length===0){_.numberReturned&&_.numberReturned!==0?B(Z.current++*h):Z.current=0;return}await O(I,F);const ce={type:"FeatureCollection",features:se};await W.process(ce,{describe:te}),T.scene.requestRender();const re=T.dataSources.getByName(H)[0];re&&r(T,re,se.map(de=>de.id)),_.numberReturned&&_.numberReturned!==0?B(Z.current++*h):Z.current=0},B=c.useCallback(async(_=0)=>{if(!T||T.scene.mode===p.SceneMode.MORPHING)return;const I=Li(T);if(!I)return;if(!T.currentZoomLevel||T.currentZoomLevel<f){L();return}W.show=!0;const P=Ci(I),F=wi(I);try{let N=`${s}?service=WFS&version=2.0.0&request=GetFeature&typeNames=${i}&outputFormat=application/json&bbox=${P.join(",")},EPSG:4326&startIndex=${_}&count=${h}`;v&&(N+=`&sortBy=${v}%20ASC`);const J=await E(N);await x(J,P,_,F)}catch(N){console.error("Error fetching WFS data:",N),y(-1,-1)}},[]);return c.useEffect(()=>{const _=T.dataSources.getByName(H)[0];_&&r(T,_,[])},[T.scene.mode]),c.useEffect(()=>{T.layersManager&&T.layersManager.dataLayerList.length>0&&T.layersManager.findDataLayerById(t.id)!==void 0&&T.layersManager.addMetaToDataLayer($)},[$]),c.useEffect(()=>{var _;(_=T.layersManager)==null||_.addDataLayer({options:n,meta:{...$},visualizationHandler:r})},[T.layersManager]),c.useEffect(()=>{T.dataSources.add(W);const _=()=>{B()};T.scene.camera.moveEnd.addEventListener(_);const I=new p.ScreenSpaceEventHandler(T.scene.canvas);return g(I),()=>{var P;q.get(T,"_cesiumWidget")!==void 0&&(z.current.clear(),G.current.clear(),T.dataSources.remove(W,!0),(P=T.layersManager)==null||P.removeDataLayer(t.id),T.scene.camera.moveEnd.removeEventListener(_),I.removeInputAction(p.ScreenSpaceEventType.MOUSE_MOVE))}},[]),null},gn=e=>o.jsx(ve.Entity,{...e}),$i=e=>o.jsx(ve.EntityDescription,{...e}),pn=e=>o.jsx(ve.EntityDescription,{...e}),fn=e=>o.jsx(ve.PolygonGraphics,{...e}),mn=e=>o.jsx(ve.RectangleGraphics,{...e}),yn=e=>o.jsx(ve.CustomDataSource,{...e}),Ui=e=>o.jsx(ve.PolylineGraphics,{...e}),$o="";var we=function(){var e=w.Ellipsoid.WGS84,n,t=w.Material.fromType(w.Material.ColorType);function r(a,l=new w.Color(1,1,0,.5),C=new w.Color(1,1,1,1)){this._scene=a.scene,t.uniforms.color=l,n=C,this._tooltip={setVisible:()=>{},showAt:()=>{}},this._surfaces=[],this.initialiseHandlers(),this.enhancePrimitives()}r.prototype.initialiseHandlers=function(){var a=this._scene,l=this,C=new w.ScreenSpaceEventHandler(a.canvas);function g(y,L){if(l._handlersMuted!=!0){var E=a.pick(L);E&&E.primitive&&E.primitive[y]&&E.primitive[y](L)}}C.setInputAction(function(y){g("leftClick",y.position)},w.ScreenSpaceEventType.LEFT_CLICK),C.setInputAction(function(y){g("leftDoubleClick",y.position)},w.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);var S;C.setInputAction(function(y){if(l._handlersMuted!=!0){var L=a.pick(y.endPosition);S&&(!L||S!=L.primitive)&&(!(S.isDestroyed&&S.isDestroyed())&&S.mouseOut(y.endPosition),S=null),L&&L.primitive&&(L=L.primitive,L.mouseOut&&(S=L),L.mouseMove&&L.mouseMove(y.endPosition))}},w.ScreenSpaceEventType.MOUSE_MOVE),C.setInputAction(function(y){g("leftUp",y.position)},w.ScreenSpaceEventType.LEFT_UP),C.setInputAction(function(y){g("leftDown",y.position)},w.ScreenSpaceEventType.LEFT_DOWN)},r.prototype.setListener=function(a,l,C){a[l]=C},r.prototype.muteHandlers=function(a){this._handlersMuted=a},r.prototype.registerEditableShape=function(a){var l=this;W(a,"mouseMove",function(C){a.setHighlighted(!0),a._editMode||l._tooltip.showAt(C,"Click to edit this shape")}),W(a,"mouseOut",function(C){a.setHighlighted(!1),l._tooltip.setVisible(!1)}),W(a,"leftClick",function(C){a.setEditMode(!0)})},r.prototype.startDrawing=function(a){this.disableAllEditMode(),this.editCleanUp&&this.editCleanUp(),this.editCleanUp=a,this.muteHandlers(!0)},r.prototype.stopDrawing=function(){this.editCleanUp&&(this.editCleanUp(),this.editCleanUp=null),this.muteHandlers(!1)},r.prototype.disableAllHighlights=function(){this.setHighlighted(void 0)},r.prototype.setHighlighted=function(a){this._highlightedSurface&&!this._highlightedSurface.isDestroyed()&&this._highlightedSurface!=a&&this._highlightedSurface.setHighlighted(!1),this._highlightedSurface=a},r.prototype.disableAllEditMode=function(){this.setEdited(void 0)},r.prototype.setEdited=function(a){this._editedSurface&&!this._editedSurface.isDestroyed()&&this._editedSurface.setEditMode(!1),this._editedSurface=a};var s={ellipsoid:w.Ellipsoid.WGS84,textureRotationAngle:0,height:0,asynchronous:!0,show:!0,debugShowBoundingVolume:!1},i=H(s,{appearance:new w.EllipsoidSurfaceAppearance({aboveGround:!1}),material:t,granularity:Math.PI/180}),u=H(s,{}),h=H(s,{}),f=H(s,{}),m=H(i,{rotation:0}),v=H(s,{width:5,geodesic:!0,granularity:1e4,appearance:new w.PolylineMaterialAppearance({aboveGround:!1}),material:t}),M=function(){function a(){}return a.prototype.initialiseOptions=function(l){j(this,l),this._ellipsoid=void 0,this._granularity=void 0,this._height=void 0,this._textureRotationAngle=void 0,this._id=void 0,this._createPrimitive=!0,this._primitive=void 0,this._outlinePolygon=void 0},a.prototype.setAttribute=function(l,C){this[l]=C,this._createPrimitive=!0},a.prototype.getAttribute=function(l){return this[l]},a.prototype.update=function(l,C,g){if(!w.defined(this.ellipsoid))throw new w.DeveloperError("this.ellipsoid must be defined.");if(!w.defined(this.appearance))throw new w.DeveloperError("this.material must be defined.");if(this.granularity<0)throw new w.DeveloperError("this.granularity and scene2D/scene3D overrides must be greater than zero.");if(this.show&&!(!this._createPrimitive&&!w.defined(this._primitive))){if(this._createPrimitive||this._ellipsoid!==this.ellipsoid||this._granularity!==this.granularity||this._height!==this.height||this._textureRotationAngle!==this.textureRotationAngle||this._id!==this.id){var S=this.getGeometry();if(!S)return;this._createPrimitive=!1,this._ellipsoid=this.ellipsoid,this._granularity=this.granularity,this._height=this.height,this._textureRotationAngle=this.textureRotationAngle,this._id=this.id,this._primitive=this._primitive&&this._primitive.destroy(),this._primitive=new w.Primitive({geometryInstances:new w.GeometryInstance({geometry:S,id:this.id,pickPrimitive:this}),appearance:this.appearance,asynchronous:this.asynchronous}),this._outlinePolygon=this._outlinePolygon&&this._outlinePolygon.destroy(),this.strokeColor&&this.getOutlineGeometry&&(this._outlinePolygon=new w.Primitive({geometryInstances:new w.GeometryInstance({geometry:this.getOutlineGeometry(),attributes:{color:w.ColorGeometryInstanceAttribute.fromColor(this.strokeColor)}}),appearance:new w.PerInstanceColorAppearance({flat:!0,renderState:{depthTest:{enabled:!0},lineWidth:this.strokeWidth||4}})}))}var y=this._primitive;y.appearance.material=this.material,y.debugShowBoundingVolume=this.debugShowBoundingVolume,y.update(l,C,g),this._outlinePolygon&&this._outlinePolygon.update(l,C,g)}},a.prototype.isDestroyed=function(){return!1},a.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),w.destroyObject(this)},a.prototype.setStrokeStyle=function(l,C){(!this.strokeColor||!this.strokeColor.equals(l)||this.strokeWidth!=C)&&(this._createPrimitive=!0,this.strokeColor=l,this.strokeWidth=C)},a}();r.ExtentPrimitive=function(){function a(l){if(!w.defined(l.extent))throw new w.DeveloperError("Extent is required");l=H(l,i),this.initialiseOptions(l),this.setExtent(l.extent)}return a.prototype=new M,a.prototype.setExtent=function(l){this.setAttribute("extent",l)},a.prototype.getExtent=function(){return this.getAttribute("extent")},a.prototype.getGeometry=function(){if(w.defined(this.extent))return new w.RectangleGeometry({rectangle:this.extent,height:this.height,vertexFormat:w.EllipsoidSurfaceAppearance.VERTEX_FORMAT,stRotation:this.textureRotationAngle,ellipsoid:this.ellipsoid,granularity:this.granularity})},a.prototype.getOutlineGeometry=function(){return new w.RectangleOutlineGeometry({rectangle:this.extent})},a}(),r.PolygonPrimitive=function(){function a(l){l=H(l,i),this.initialiseOptions(l),this.isPolygon=!0}return a.prototype=new M,a.prototype.setPositions=function(l){this.setAttribute("positions",l)},a.prototype.getPositions=function(){return this.getAttribute("positions")},a.prototype.getGeometry=function(){if(!(!w.defined(this.positions)||this.positions.length<3))return w.PolygonGeometry.fromPositions({positions:this.positions,height:this.height,vertexFormat:w.EllipsoidSurfaceAppearance.VERTEX_FORMAT,stRotation:this.textureRotationAngle,ellipsoid:this.ellipsoid,granularity:this.granularity})},a.prototype.getOutlineGeometry=function(){return w.PolygonOutlineGeometry.fromPositions({positions:this.getPositions()})},a}(),r.CirclePrimitive=function(){function a(l){if(!(w.defined(l.center)&&w.defined(l.radius)))throw new w.DeveloperError("Center and radius are required");l=H(l,i),this.initialiseOptions(l),this.setRadius(l.radius)}return a.prototype=new M,a.prototype.setCenter=function(l){this.setAttribute("center",l)},a.prototype.setRadius=function(l){this.setAttribute("radius",Math.max(.1,l))},a.prototype.getCenter=function(){return this.getAttribute("center")},a.prototype.getRadius=function(){return this.getAttribute("radius")},a.prototype.getGeometry=function(){if(w.defined(this.center)&&w.defined(this.radius))return new w.CircleGeometry({center:this.center,radius:this.radius,height:this.height,vertexFormat:w.EllipsoidSurfaceAppearance.VERTEX_FORMAT,stRotation:this.textureRotationAngle,ellipsoid:this.ellipsoid,granularity:this.granularity})},a.prototype.getOutlineGeometry=function(){return new w.CircleOutlineGeometry({center:this.getCenter(),radius:this.getRadius()})},a}(),r.EllipsePrimitive=function(){function a(l){if(!(w.defined(l.center)&&w.defined(l.semiMajorAxis)&&w.defined(l.semiMinorAxis)))throw new w.DeveloperError("Center and semi major and semi minor axis are required");l=H(l,m),this.initialiseOptions(l)}return a.prototype=new M,a.prototype.setCenter=function(l){this.setAttribute("center",l)},a.prototype.setSemiMajorAxis=function(l){l<this.getSemiMinorAxis()||this.setAttribute("semiMajorAxis",l)},a.prototype.setSemiMinorAxis=function(l){l>this.getSemiMajorAxis()||this.setAttribute("semiMinorAxis",l)},a.prototype.setRotation=function(l){return this.setAttribute("rotation",l)},a.prototype.getCenter=function(){return this.getAttribute("center")},a.prototype.getSemiMajorAxis=function(){return this.getAttribute("semiMajorAxis")},a.prototype.getSemiMinorAxis=function(){return this.getAttribute("semiMinorAxis")},a.prototype.getRotation=function(){return this.getAttribute("rotation")},a.prototype.getGeometry=function(){if(w.defined(this.center)&&w.defined(this.semiMajorAxis)&&w.defined(this.semiMinorAxis))return new w.EllipseGeometry({ellipsoid:this.ellipsoid,center:this.center,semiMajorAxis:this.semiMajorAxis,semiMinorAxis:this.semiMinorAxis,rotation:this.rotation,height:this.height,vertexFormat:w.EllipsoidSurfaceAppearance.VERTEX_FORMAT,stRotation:this.textureRotationAngle,granularity:this.granularity})},a.prototype.getOutlineGeometry=function(){return new w.EllipseOutlineGeometry({center:this.getCenter(),semiMajorAxis:this.getSemiMajorAxis(),semiMinorAxis:this.getSemiMinorAxis(),rotation:this.getRotation()})},a}(),r.PolylinePrimitive=function(){function a(l){l=H(l,v),this.initialiseOptions(l)}return a.prototype=new M,a.prototype.setPositions=function(l){this.setAttribute("positions",l)},a.prototype.setWidth=function(l){this.setAttribute("width",l)},a.prototype.setGeodesic=function(l){this.setAttribute("geodesic",l)},a.prototype.getPositions=function(){return this.getAttribute("positions")},a.prototype.getWidth=function(){return this.getAttribute("width")},a.prototype.getGeodesic=function(l){return this.getAttribute("geodesic")},a.prototype.getGeometry=function(){if(!(!w.defined(this.positions)||this.positions.length<2))return new w.PolylineGeometry({positions:this.positions,height:this.height,width:this.width<1?1:this.width,vertexFormat:w.EllipsoidSurfaceAppearance.VERTEX_FORMAT,ellipsoid:this.ellipsoid})},a}();var b={iconUrl:"./assets/img/dragIcon.png",shiftX:0,shiftY:0},T={iconUrl:"./assets/img/dragIcon.png",shiftX:0,shiftY:0},G={iconUrl:"./assets/img/dragIconLight.png",shiftX:0,shiftY:0};r.prototype.createBillboardGroup=function(a,l,C){var g=new r.BillboardGroup(this,l);return g.addBillboards(a,C),g},r.BillboardGroup=function(a,l){this._drawHelper=a,this._scene=a._scene,this._options=H(l,b);var C=new w.BillboardCollection;this._scene.primitives.add(C),this._billboards=C,this._orderedBillboards=[]},r.BillboardGroup.prototype.createBillboard=function(a,l){var C=this._billboards.add({show:!0,position:a,pixelOffset:new w.Cartesian2(this._options.shiftX,this._options.shiftY),eyeOffset:new w.Cartesian3(0,0,0),horizontalOrigin:w.HorizontalOrigin.CENTER,verticalOrigin:w.VerticalOrigin.CENTER,scale:1,image:this._options.iconUrl,color:n});if(l){let y=function(E){S.enableRotate=E},L=function(){for(var E=0,D=g._orderedBillboards.length;E<D&&g._orderedBillboards[E]!=C;++E);return E};var g=this,S=this._scene.screenSpaceCameraController;if(l.dragHandlers){var g=this;W(C,"leftDown",function(D){function k(x){C.position=x;for(var B=0,_=g._orderedBillboards.length;B<_&&g._orderedBillboards[B]!=C;++B);l.dragHandlers.onDrag&&l.dragHandlers.onDrag(L(),x)}function A(x){O.destroy(),y(!0),l.dragHandlers.onDragEnd&&l.dragHandlers.onDragEnd(L(),x)}var O=new w.ScreenSpaceEventHandler(g._scene.canvas);O.setInputAction(function(x){var B=g._scene.camera.pickEllipsoid(x.endPosition,e);B?k(B):A(B)},w.ScreenSpaceEventType.MOUSE_MOVE),O.setInputAction(function(x){A(g._scene.camera.pickEllipsoid(x.position,e))},w.ScreenSpaceEventType.LEFT_UP),y(!1),l.dragHandlers.onDragStart&&l.dragHandlers.onDragStart(L(),g._scene.camera.pickEllipsoid(D,e))})}l.onDoubleClick&&W(C,"leftDoubleClick",function(E){l.onDoubleClick(L())}),l.onClick&&W(C,"leftClick",function(E){l.onClick(L())}),l.tooltip&&(W(C,"mouseMove",function(E){g._drawHelper._tooltip.showAt(E,l.tooltip())}),W(C,"mouseOut",function(E){g._drawHelper._tooltip.setVisible(!1)}))}return C},r.BillboardGroup.prototype.insertBillboard=function(a,l,C){this._orderedBillboards.splice(a,0,this.createBillboard(l,C))},r.BillboardGroup.prototype.addBillboard=function(a,l){this._orderedBillboards.push(this.createBillboard(a,l))},r.BillboardGroup.prototype.addBillboards=function(a,l){for(var C=0;C<a.length;C++)this.addBillboard(a[C],l)},r.BillboardGroup.prototype.updateBillboardsPositions=function(a){for(var l=0;l<a.length;l++)this.getBillboard(l).position=a[l]},r.BillboardGroup.prototype.countBillboards=function(){return this._orderedBillboards.length},r.BillboardGroup.prototype.getBillboard=function(a){return this._orderedBillboards[a]},r.BillboardGroup.prototype.removeBillboard=function(a){this._billboards.remove(this.getBillboard(a)),this._orderedBillboards.splice(a,1)},r.BillboardGroup.prototype.remove=function(){this._billboards=this._billboards&&this._billboards.removeAll()&&this._billboards.destroy()},r.BillboardGroup.prototype.setOnTop=function(){this._scene.primitives.raiseToTop(this._billboards)},r.prototype.startDrawingMarker=function(l){var l=H(l,b);this.startDrawing(function(){y.remove(),L.destroy(),S.setVisible(!1)});var C=this,g=this._scene;g.primitives;var S=this._tooltip,y=new r.BillboardGroup(this,l),L=new w.ScreenSpaceEventHandler(g.canvas);L.setInputAction(function(E){if(E.position!=null){var D=g.camera.pickEllipsoid(E.position,e);D&&(y.addBillboard(D),C.stopDrawing(),l.callback(D))}},w.ScreenSpaceEventType.LEFT_CLICK),L.setInputAction(function(E){var D=E.endPosition;if(D!=null){var k=g.camera.pickEllipsoid(D,e);k?S.showAt(D,"<p>Click to add your marker. Position is: </p>"+Y(e.cartesianToCartographic(k))):S.showAt(D,"<p>Click on the globe to add your marker.</p>")}},w.ScreenSpaceEventType.MOUSE_MOVE)},r.prototype.startDrawingPolygon=function(l){var l=H(l,i);this.startDrawingPolyshape(!0,l)},r.prototype.startDrawingPolyline=function(l){var l=H(l,v);this.startDrawingPolyshape(!1,l)},r.prototype.startDrawingPolyshape=function(a,l){this.startDrawing(function(){S.remove(E),k.remove(),A.destroy(),y.setVisible(!1),$(g)});var C=this,g=this._scene,S=g.primitives,y=this._tooltip,L=a?3:2,E;a?E=new we.PolygonPrimitive(l):E=new we.PolylinePrimitive(l),E.asynchronous=!1,S.add(E);var D=[],k=new r.BillboardGroup(this,b),A=new w.ScreenSpaceEventHandler(g.canvas);Z(g),A.setInputAction(function(O){if(O.position!=null){var x=g.camera.pickEllipsoid(O.position,e);x&&(D.length==0&&(D.push(x.clone()),k.addBillboard(D[0])),D.length>=L&&(E.positions=D,E._createPrimitive=!0),D.push(x),k.addBillboard(x))}},w.ScreenSpaceEventType.LEFT_CLICK),A.setInputAction(function(O){var x=O.endPosition;if(x!=null)if(D.length==0)y.showAt(x,"<p>Click to add first point</p>");else{var B=g.camera.pickEllipsoid(x,e);B&&(D.pop(),B.y+=1+Math.random(),D.push(B),D.length>=L&&(E.positions=D,E._createPrimitive=!0),k.getBillboard(D.length-1).position=B,y.showAt(x,"<p>Click to add new point ("+D.length+")</p>"+(D.length>L?"<p>Double click to finish drawing</p>":"")))}},w.ScreenSpaceEventType.MOUSE_MOVE),A.setInputAction(function(O){var x=O.position;if(x!=null){if(D.length<L+2)return;var B=g.camera.pickEllipsoid(x,e);B&&($(g),C.stopDrawing(),typeof l.callback=="function"&&(D.length-1,l.callback(D)))}},w.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)};function z(a){return e.cartographicArrayToCartesianArray([w.Rectangle.northwest(a),w.Rectangle.northeast(a),w.Rectangle.southeast(a),w.Rectangle.southwest(a)])}function Z(a){a&&(a.canvas.style.cursor="crosshair")}function $(a){a&&(a.canvas.style.cursor="")}r.prototype.startDrawingExtent=function(l){var l=H(l,i);this.startDrawing(function(){E!=null&&S.remove(E),D!=null&&D.remove(),k.destroy(),y.setVisible(!1),$(g)});var C=this,g=this._scene,S=this._scene.primitives,y=this._tooltip,L=null,E=null,D=null,k=new w.ScreenSpaceEventHandler(g.canvas);Z(g);function A(O){E==null&&(E=new we.ExtentPrimitive({extent:O,material:l.material}),E.asynchronous=!1,S.add(E)),E.setExtent(O);var x=z(O);D==null?(D=new r.BillboardGroup(C,b),D.addBillboards(x)):D.updateBillboardsPositions(x)}k.setInputAction(function(O){if(O.position!=null){var x=g.camera.pickEllipsoid(O.position,e);if(x)if(E==null){L=e.cartesianToCartographic(x);var B=X(L,L);A(B)}else C.stopDrawing(),typeof l.callback=="function"&&l.callback(X(L,e.cartesianToCartographic(x)))}},w.ScreenSpaceEventType.LEFT_DOWN),k.setInputAction(function(O){var x=O.endPosition;if(x!=null)if(E==null)y.showAt(x,"<p>Click to start drawing rectangle</p>");else{var B=g.camera.pickEllipsoid(x,e);if(B){var _=X(L,e.cartesianToCartographic(B));A(_),y.showAt(x,"<p>Drag to change rectangle extent</p><p>Click again to finish drawing</p>")}}},w.ScreenSpaceEventType.MOUSE_MOVE)},r.prototype.startDrawingCircle=function(l){var l=H(l,i);this.startDrawing(function(){L!=null&&S.remove(L),E.remove(),D.destroy(),y.setVisible(!1)});var C=this,g=this._scene,S=this._scene.primitives,y=this._tooltip,L=null,E=null,D=new w.ScreenSpaceEventHandler(g.canvas);D.setInputAction(function(k){if(k.position!=null){var A=g.camera.pickEllipsoid(k.position,e);A&&(L==null?(L=new r.CirclePrimitive({center:A,radius:0,asynchronous:!1,material:l.material}),S.add(L),E=new r.BillboardGroup(C,b),E.addBillboards([A])):(typeof l.callback=="function"&&l.callback(L.getCenter(),L.getRadius()),C.stopDrawing()))}},w.ScreenSpaceEventType.LEFT_DOWN),D.setInputAction(function(k){var A=k.endPosition;if(A!=null)if(L==null)y.showAt(A,"<p>Click to start drawing the circle</p>");else{var O=g.camera.pickEllipsoid(A,e);O&&(L.setRadius(w.Cartesian3.distance(L.getCenter(),O)),E.updateBillboardsPositions(O),y.showAt(A,"<p>Move mouse to change circle radius</p><p>Click again to finish drawing</p>"))}},w.ScreenSpaceEventType.MOUSE_MOVE)},r.prototype.enhancePrimitives=function(){var a=this;w.Billboard.prototype.setEditable=function(){if(this._editable)return;this._editable=!0;var g=this,S=this;function y(L){a._scene.screenSpaceCameraController.enableRotate=L}W(g,"leftDown",function(L){function E(A){g.position=A,S.executeListeners({name:"drag",positions:A})}function D(A){k.destroy(),y(!0),S.executeListeners({name:"dragEnd",positions:A})}var k=new w.ScreenSpaceEventHandler(a._scene.canvas);k.setInputAction(function(A){var O=a._scene.camera.pickEllipsoid(A.endPosition,e);O?E(O):D(O)},w.ScreenSpaceEventType.MOUSE_MOVE),k.setInputAction(function(A){D(a._scene.camera.pickEllipsoid(A.position,e))},w.ScreenSpaceEventType.LEFT_UP),y(!1)}),te(g)};function l(g){a._scene,!(this._highlighted&&this._highlighted==g)&&this._editMode!==!0&&(this._highlighted=g,g?(a.setHighlighted(this),this._strokeColor=this.strokeColor,this.setStrokeStyle(w.Color.fromCssColorString("white"),this.strokeWidth)):this._strokeColor?this.setStrokeStyle(this._strokeColor,this.strokeWidth):this.setStrokeStyle(void 0,void 0))}function C(g){if(this._editMode!=g)if(a.disableAllHighlights(),g){a.setEdited(this);var S=a._scene,y=this;if(this._markers==null){let B=function(P,F){var N=P-1<0?F.length-1:P-1;N<E.countBillboards()&&(E.getBillboard(N).position=I(N)),N=P,N<E.countBillboards()&&(E.getBillboard(N).position=I(N))},_=function(){y.executeListeners({name:"onEdited",positions:y.positions})},I=function(P){var F=y.positions;return e.cartographicToCartesian(new w.EllipsoidGeodesic(e.cartesianToCartographic(F[P]),e.cartesianToCartographic(F[P<F.length-1?P+1:0])).interpolateUsingFraction(.5))};var L=new r.BillboardGroup(a,T),E=new r.BillboardGroup(a,G),D={dragHandlers:{onDrag:function(P,F){y.positions[P]=F,B(P,y.positions),y._createPrimitive=!0},onDragEnd:function(P,F){y._createPrimitive=!0,_()}},onDoubleClick:function(P){y.positions.length<4||(y.positions.splice(P,1),y._createPrimitive=!0,L.removeBillboard(P),E.removeBillboard(P),B(P,y.positions),_())},tooltip:function(){if(y.positions.length>3)return"Double click to remove this point"}};L.addBillboards(y.positions,D),this._markers=L;for(var k=[],A=0,O=y.positions.length+(this.isPolygon?0:-1);A<O;A++)k.push(I(A));var x={dragHandlers:{onDragStart:function(P,F){this.index=P+1,y.positions.splice(this.index,0,F),y._createPrimitive=!0},onDrag:function(P,F){y.positions[this.index]=F,y._createPrimitive=!0},onDragEnd:function(P,F){L.insertBillboard(this.index,F,D),E.getBillboard(this.index-1).position=I(this.index-1),E.insertBillboard(this.index,I(this.index),x),y._createPrimitive=!0,_()}},tooltip:function(){return"Drag to create a new point"}};E.addBillboards(k,x),this._editMarkers=E,this._globeClickhandler=new w.ScreenSpaceEventHandler(S.canvas),this._globeClickhandler.setInputAction(function(P){var F=S.pick(P.position);F&&F.primitive||y.setEditMode(!1)},w.ScreenSpaceEventType.LEFT_CLICK),L.setOnTop(),E.setOnTop()}this._editMode=!0}else this._markers!=null&&(this._markers.remove(),this._editMarkers.remove(),this._markers=null,this._editMarkers=null,this._globeClickhandler.destroy()),this._editMode=!1}we.PolylinePrimitive.prototype.setEditable=function(){if(!this.setEditMode){var g=this;g.isPolygon=!1,g.asynchronous=!1,a.registerEditableShape(g),g.setEditMode=C;var S=this.width;g.setHighlighted=function(y){this._editMode!==!0&&(y?(a.setHighlighted(this),this.setWidth(S*2)):this.setWidth(S))},g.getExtent=function(){return w.Rectangle.fromCartographicArray(e.cartesianArrayToCartographicArray(this.positions))},te(g),g.setEditMode(!1)}},we.PolygonPrimitive.prototype.setEditable=function(){var g=this;g.asynchronous=!1,a._scene,a.registerEditableShape(g),g.setEditMode=C,g.setHighlighted=l,te(g),g.setEditMode(!1)},we.ExtentPrimitive.prototype.setEditable=function(){if(!this.setEditMode){var g=this,S=a._scene;a.registerEditableShape(g),g.asynchronous=!1,g.setEditMode=function(y){if(this._editMode!=y)if(a.disableAllHighlights(),y){if(a.setEdited(this),this._markers==null){let D=function(){g.executeListeners({name:"onEdited",extent:g.extent})};var L=new r.BillboardGroup(a,T),E={dragHandlers:{onDrag:function(k,A){var O=L.getBillboard((k+2)%4).position;g.setExtent(X(e.cartesianToCartographic(O),e.cartesianToCartographic(A))),L.updateBillboardsPositions(z(g.extent))},onDragEnd:function(k,A){D()}},tooltip:function(){return"Drag to change the corners of this extent"}};L.addBillboards(z(g.extent),E),this._markers=L,this._globeClickhandler=new w.ScreenSpaceEventHandler(S.canvas),this._globeClickhandler.setInputAction(function(k){var A=S.pick(k.position);A&&!A.isDestroyed()&&A.primitive||g.setEditMode(!1)},w.ScreenSpaceEventType.LEFT_CLICK),L.setOnTop()}this._editMode=!0}else this._markers!=null&&(this._markers.remove(),this._markers=null,this._globeClickhandler.destroy()),this._editMode=!1},g.setHighlighted=l,te(g),g.setEditMode(!1)}},r.EllipsePrimitive.prototype.setEditable=function(){if(!this.setEditMode){var g=this,S=a._scene;g.asynchronous=!1,a.registerEditableShape(g),g.setEditMode=function(y){if(this._editMode!=y)if(a.disableAllHighlights(),y){a.setEdited(this);var L=this;if(this._markers==null){let k=function(){return w.EllipseOutlineGeometry(e,g.getCenter(),g.getSemiMajorAxis(),g.getSemiMinorAxis(),g.getRotation()+Math.PI/2,Math.PI/2).splice(0,4)},A=function(){g.executeListeners({name:"onEdited",center:g.getCenter(),semiMajorAxis:g.getSemiMajorAxis(),semiMinorAxis:g.getSemiMinorAxis(),rotation:0})};var E=new r.BillboardGroup(a,T),D={dragHandlers:{onDrag:function(O,x){var B=w.Cartesian3.distance(g.getCenter(),x);O%2==0?g.setSemiMajorAxis(B):g.setSemiMinorAxis(B),E.updateBillboardsPositions(k())},onDragEnd:function(O,x){A()}},tooltip:function(){return"Drag to change the excentricity and radius"}};E.addBillboards(k(),D),this._markers=E,this._globeClickhandler=new w.ScreenSpaceEventHandler(S.canvas),this._globeClickhandler.setInputAction(function(O){var x=S.pick(O.position);x&&x.primitive||L.setEditMode(!1)},w.ScreenSpaceEventType.LEFT_CLICK),E.setOnTop()}this._editMode=!0}else this._markers!=null&&(this._markers.remove(),this._markers=null,this._globeClickhandler.destroy()),this._editMode=!1},g.setHighlighted=l,te(g),g.setEditMode(!1)}},r.CirclePrimitive.prototype.getCircleCartesianCoordinates=function(g){for(var S=w.CircleOutlineGeometry.createGeometry(new w.CircleOutlineGeometry({ellipsoid:e,center:this.getCenter(),radius:this.getRadius(),granularity:g})),y=0,L,E=[];y<S.attributes.position.values.length;y+=3)L=S.attributes.position.values,E.push(new w.Cartesian3(L[y],L[y+1],L[y+2]));return E},r.CirclePrimitive.prototype.setEditable=function(){if(!this.setEditMode){var g=this,S=a._scene;g.asynchronous=!1,a.registerEditableShape(g),g.setEditMode=function(y){if(this._editMode!=y)if(a.disableAllHighlights(),y){a.setEdited(this);var L=this;if(this._markers==null){let k=function(){return L.getCircleCartesianCoordinates(w.Math.PI_OVER_TWO)},A=function(){g.executeListeners({name:"onEdited",center:g.getCenter(),radius:g.getRadius()})};var E=new r.BillboardGroup(a,T),D={dragHandlers:{onDrag:function(O,x){g.setRadius(w.Cartesian3.distance(g.getCenter(),x)),E.updateBillboardsPositions(k())},onDragEnd:function(O,x){A()}},tooltip:function(){return"Drag to change the radius"}};E.addBillboards(k(),D),this._markers=E,this._globeClickhandler=new w.ScreenSpaceEventHandler(S.canvas),this._globeClickhandler.setInputAction(function(O){var x=S.pick(O.position);x&&x.primitive||L.setEditMode(!1)},w.ScreenSpaceEventType.LEFT_CLICK),E.setOnTop()}this._editMode=!0}else this._markers!=null&&(this._markers.remove(),this._markers=null,this._globeClickhandler.destroy()),this._editMode=!1},g.setHighlighted=l,te(g),g.setEditMode(!1)}}},r.DrawHelperWidget=function(){function a(l,C){if(!w.defined(C.container))throw new w.DeveloperError("Container is required");var g={markerIcon:"./assets/img/glyphicons_242_google_maps.png",polylineIcon:"./assets/img/glyphicons_097_vector_path_line.png",polygonIcon:"./assets/img/glyphicons_096_vector_path_polygon.png",circleIcon:"./assets/img/glyphicons_095_vector_path_circle.png",extentIcon:"./assets/img/glyphicons_094_vector_path_square.png",clearIcon:"./assets/img/glyphicons_067_cleaning.png",polylineDrawingOptions:v,polygonDrawingOptions:u,extentDrawingOptions:h,circleDrawingOptions:f};j(C,g);var S=this,y=document.createElement("DIV");y.className="toolbar",C.container.appendChild(y);function L(k,A,O,x){var B=document.createElement("DIV");B.className="button",B.title=O,y.appendChild(B),B.onclick=x;var _=document.createElement("SPAN");B.appendChild(_);var I=document.createElement("IMG");return I.src=A,_.appendChild(I),B}var E=l._scene;L("marker",C.markerIcon,"Click to start drawing a 2D marker",function(){l.startDrawingMarker({callback:function(k){S.executeListeners({name:"markerCreated",position:k})}})}),L("polyline",C.polylineIcon,"Click to start drawing a 2D polyline",function(){l.startDrawingPolyline({callback:function(k){S.executeListeners({name:"polylineCreated",positions:k})}})}),L("polygon",C.polygonIcon,"Click to start drawing a 2D polygon",function(){l.startDrawingPolygon({callback:function(k){S.executeListeners({name:"polygonCreated",positions:k})}})}),L("extent",C.extentIcon,"Click to start drawing an Extent",function(){l.startDrawingExtent({callback:function(k){S.executeListeners({name:"extentCreated",extent:k})}})}),L("circle",C.circleIcon,"Click to start drawing a Circle",function(){l.startDrawingCircle({callback:function(k,A){S.executeListeners({name:"circleCreated",center:k,radius:A})}})});var D=document.createElement("DIV");D.className="divider",y.appendChild(D),L("clear",C.clearIcon,"Remove all primitives",function(){E.primitives.removeAll()}),te(this)}return a}(),r.prototype.addToolbar=function(a,l){return l=H(l,{container:a}),new r.DrawHelperWidget(this,l)};function X(a,l){var C=new w.Rectangle;C.west=Math.min(a.longitude,l.longitude),C.east=Math.max(a.longitude,l.longitude),C.south=Math.min(a.latitude,l.latitude),C.north=Math.max(a.latitude,l.latitude);var g=w.Math.EPSILON7;return C.east-C.west<g&&(C.east+=g*2),C.north-C.south<g&&(C.north+=g*2),C}function Y(a,l){return a.longitude.toFixed(l||3)+", "+a.latitude.toFixed(l||3)}function V(a,l){if(a==null||typeof a!="object"||a.constructor!=Object&&a.constructor!=Array)return a;if(a.constructor==Date||a.constructor==RegExp||a.constructor==Function||a.constructor==String||a.constructor==Number||a.constructor==Boolean)return new a.constructor(a);l=l||new a.constructor;for(var C in a)l[C]=typeof l[C]>"u"?V(a[C],null):l[C];return l}function j(a,l){a=a||{};var C;for(C in l)a[C]===void 0&&(a[C]=V(l[C]))}function H(a,l){var C=V(a),g;for(g in l)C[g]===void 0&&(C[g]=V(l[g]));return C}function W(a,l,C){a[l]=C}function te(a){a._listeners={},a.addListener=function(l,C){return this._listeners[l]=this._listeners[l]||[],this._listeners[l].push(C),this._listeners[l].length},a.executeListeners=function(l,C){if(this._listeners[l.name]&&this._listeners[l.name].length>0)for(var g=0;g<this._listeners[l.name].length;g++)this._listeners[l.name][g](l);else C&&C(l)}}return r}();const qi=2,ji=(e,n)=>{switch(e){case he.BOX:{if(n.features.length!==qi)throw new Error(`${e} must have 2 points`);const t=q.find(n.features,s=>{var i;return((i=s.properties)==null?void 0:i.type)===Ne.BOTTOM_LEFT}),r=q.find(n.features,s=>{var i;return((i=s.properties)==null?void 0:i.type)===Ne.TOP_RIGHT});if(r&&t){if(t.geometry.coordinates[0]===r.geometry.coordinates[0]&&t.geometry.coordinates[1]===r.geometry.coordinates[1])throw new Error(`${e} must define BOTTOM_LEFT and TOP_RIGHT different points`);return p.Rectangle.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],r.geometry.coordinates[0],r.geometry.coordinates[1])}else throw new Error(`${e} geojson must define BOTTOM_LEFT and TOP_RIGHT points`)}default:throw new Error(`${e} type geoJSON still not supported`)}},vn=e=>{const n=e.map(t=>{const r=p.Cartographic.fromCartesian(t);return[p.Math.toDegrees(r.longitude),p.Math.toDegrees(r.latitude)]});return n.push(n[0]),{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[n]}}},En=e=>{const n=wt.lineString([[p.Math.toDegrees(e.west),p.Math.toDegrees(e.south)],[p.Math.toDegrees(e.east),p.Math.toDegrees(e.north)]]);return Re(vt(n))},Sn=e=>{const n=wt.lineString([[e.west,e.south],[e.east,e.north]]);return Re(vt(n)).geometry.coordinates[0].map(r=>p.Cartesian3.fromRadiansArray(r)[0])};class Ki extends p.Color{}const Yi=e=>{const{drawState:n,drawingMaterial:t,drawingVertexColor:r,material:s,hollow:i,outlineWidth:u}=e,h=le(),[f,m]=c.useState();c.useEffect(()=>{m(new we(h,t,r))},[]),c.useEffect(()=>{if(f){const M=f;if(n.drawing)switch(n.type){case he.POLYGON:h.scene.globe.depthTestAgainstTerrain=!1,M.startDrawingPolygon({callback:b=>{n.handler({primitive:b,type:he.POLYGON,geojson:vn(b)})}});break;case he.BOX:h.scene.globe.depthTestAgainstTerrain=!1,M.startDrawingExtent({callback:b=>{n.handler({primitive:b,type:he.BOX,geojson:En(b)})}});break;default:throw new Error(`[CESIUM DRAW]: ${n.type} unrecognized primitive to draw.`)}else M.stopDrawing(),h.scene.globe.depthTestAgainstTerrain=!0}},[n,f]);const v=M=>{try{let b=M.coordinates!==void 0?M.coordinates:ji(M.type,M.geojson);if(i!==!0)switch(M.type){case he.BOX:return o.jsx(mn,{coordinates:b,material:s??t});case he.POLYGON:return o.jsx(fn,{hierarchy:new p.PolygonHierarchy(b),material:s??t});default:return o.jsx(o.Fragment,{})}else{switch(M.type){case he.BOX:b=Sn(b);break;case he.POLYGON:b=[...b,b[0]];break;default:return o.jsx(o.Fragment,{})}return o.jsx(Ui,{clampToGround:!0,positions:b,width:u??1,material:s??t})}}catch(b){return console.error(b),o.jsx(o.Fragment,{})}};return o.jsx(yn,{...e,children:e.drawings.map((M,b)=>o.jsxs(gn,{name:M.name,children:[o.jsxs(pn,{children:[o.jsxs("h1",{children:["Drawed Entity ",M.name]}),o.jsx("p",{children:"This is description of drawed entity"})]}),v(M)]},M.id))})},Zi=e=>{const n=le();return c.useEffect(()=>{n.extend(p.viewerCesiumInspectorMixin)},[n]),o.jsx(o.Fragment,{})},Xi=-25,Tn=2,Ji=e=>{const n=le(),t=(i,u=",")=>i.slice(i.indexOf(`
12
+ `},a=_=>_?_.polyline?"polyline":"polygon":"",l=_=>{var F,N;const I=(N=(F=_==null?void 0:_.polygon)==null?void 0:F.hierarchy)==null?void 0:N.getValue(p.JulianDate.now());if(!I)return null;const P=I.positions;return p.BoundingSphere.fromPoints(P).center},C=_=>{const P=T.scene.drillPick(_).map(N=>N.id).filter(N=>N&&N.polygon&&N.entityCollection.owner.name===H);if(P.length===0)return null;const F=P.map(N=>{const J=l(N);if(!J)return{entity:N,distance:Number.MAX_VALUE};const se=p.SceneTransforms.wgs84ToWindowCoordinates(T.scene,J);if(!se)return{entity:N,distance:Number.MAX_VALUE};const ce=_.x-se.x,re=_.y-se.y,de=Math.sqrt(ce*ce+re*re);return{entity:N,distance:de}});return F.sort((N,J)=>J.distance-N.distance),F[0].entity},g=_=>{let I=null;_.setInputAction(P=>{if(T.scene.mode===p.SceneMode.SCENE2D){const N=T.scene.pick(P.endPosition);N&&N.id&&(N.id.polygon||N.id.polyline)?q.get(I,"id")!==q.get(N.id,"id")&&(I&&(I[a(I)].material=V,T.container.style.cursor="default"),I=N.id,I[a(I)].material=j,T.container.style.cursor="pointer"):I&&(I[a(I)].material=V,I=null,T.container.style.cursor="default")}else{const N=C(P.endPosition);N?q.get(I,"id")!==q.get(N,"id")&&(I&&(I[a(I)].material=Y,T.container.style.cursor="default"),I=N,I[a(I)].material=j,T.container.style.cursor="pointer"):I&&(I[a(I)].material=Y,I=null,T.container.style.cursor="default")}},p.ScreenSpaceEventType.MOUSE_MOVE)},S=(_,I)=>{const P=navigator.hardwareConcurrency||4;let F=Math.ceil(P*1.5);return I==="cpu"&&(F=Math.max(2,Math.ceil(P/2))),_>=m?Math.min(200,F*4):_>1e3?Math.min(100,F*2):_>300?Math.min(50,F):Math.min(10,F)},y=(_=-1,I=-1)=>{X(P=>({...P,...t,cache:z.current.size,items:_,total:I,currentZoomLevel:T.currentZoomLevel}))},L=()=>{W.entities&&W.entities.values.length>0&&(W.show=!1,Z.current=0),y(0,0)},E=async(_,I="GET",P)=>{const F={method:I};P!==void 0&&(F.body=P);const N=await fetch(_,F);if(N.status===200)return await N.json()},D=async(_,I)=>{const P=[];return _.length>0&&await et(_,F=>{if(F.properties){const N=F.properties[v??"id"];z.current.has(N)||(z.current.add(N),F.properties.fetch_id=I,P.push(F))}},{concurrency:S(_.length,"cpu")}),P},k=(_,I)=>Array.from(G.current.values()).filter(P=>JSON.stringify(P.parentBBox)!==JSON.stringify(_)).reduce((P,F)=>{const N=Ti(I,F.bbox);return N>P.distance?{id:F.id,key:F.bbox.join(","),distance:N}:P},{id:"",key:"",distance:-1/0}),A=async _=>{const I=[];await et(W.entities.values,P=>{if(P.properties&&P.properties.fetch_id.getValue()===_){const F=P.properties[v??"id"].getValue();z.current.delete(F),I.push(P)}},{concurrency:S(W.entities.values.length,"cpu")}),I.length>0&&await et(I,P=>{W.entities.remove(P)},{concurrency:S(I.length,"cpu")})},O=async(_,I)=>{for(;z.current.size>m;){const P=k(_,I);if(P.id==="")break;await A(P.id),P.key&&G.current.delete(P.key)}},x=async(_,I,P,F)=>{let N="",J="",se=[];if(_.numberReturned&&_.numberReturned!==0&&(_.bbox&&(J=_.bbox.join(","),G.current.has(J)||(N=yt.v4())),se=await D(_.features,N),_.bbox&&se.length>0&&!G.current.has(J)&&G.current.set(J,{id:N,parentBBox:I,bbox:_.bbox,timestamp:_.timeStamp,items:se.length})),y(_.numberReturned!==0?P+_.numberReturned:_.numberMatched,_.numberMatched),se.length===0){_.numberReturned&&_.numberReturned!==0?B(Z.current++*h):Z.current=0;return}await O(I,F);const ce={type:"FeatureCollection",features:se};await W.process(ce,{describe:te}),T.scene.requestRender();const re=T.dataSources.getByName(H)[0];re&&r(T,re,se.map(de=>de.id)),_.numberReturned&&_.numberReturned!==0?B(Z.current++*h):Z.current=0},B=c.useCallback(async(_=0)=>{if(!T||T.scene.mode===p.SceneMode.MORPHING)return;const I=Li(T);if(!I)return;if(!T.currentZoomLevel||T.currentZoomLevel<f){L();return}W.show=!0;const P=Ci(I),F=wi(I);try{let N=`${s}?service=WFS&version=2.0.0&request=GetFeature&typeNames=${i}&outputFormat=application/json&bbox=${P.join(",")},EPSG:4326&startIndex=${_}&count=${h}`;v&&(N+=`&sortBy=${v}%20ASC`);const J=await E(N);await x(J,P,_,F)}catch(N){console.error("Error fetching WFS data:",N),y(-1,-1)}},[]);return c.useEffect(()=>{const _=T.dataSources.getByName(H)[0];_&&r(T,_,[])},[T.scene.mode]),c.useEffect(()=>{T.layersManager&&T.layersManager.dataLayerList.length>0&&T.layersManager.findDataLayerById(t.id)!==void 0&&T.layersManager.addMetaToDataLayer($)},[$]),c.useEffect(()=>{var _;(_=T.layersManager)==null||_.addDataLayer({options:n,meta:{...$},visualizationHandler:r})},[T.layersManager]),c.useEffect(()=>{T.dataSources.add(W);const _=()=>{B()};T.scene.camera.moveEnd.addEventListener(_);const I=new p.ScreenSpaceEventHandler(T.scene.canvas);return g(I),()=>{var P;q.get(T,"_cesiumWidget")!==void 0&&(z.current.clear(),G.current.clear(),T.dataSources.remove(W,!0),(P=T.layersManager)==null||P.removeDataLayer(t.id),T.scene.camera.moveEnd.removeEventListener(_),I.removeInputAction(p.ScreenSpaceEventType.MOUSE_MOVE))}},[]),null},gn=e=>o.jsx(ve.Entity,{...e}),$i=e=>o.jsx(ve.EntityDescription,{...e}),pn=e=>o.jsx(ve.EntityDescription,{...e}),fn=e=>o.jsx(ve.PolygonGraphics,{...e}),mn=e=>o.jsx(ve.RectangleGraphics,{...e}),yn=e=>o.jsx(ve.CustomDataSource,{...e}),Ui=e=>o.jsx(ve.PolylineGraphics,{...e}),$o="";var we=function(){var e=w.Ellipsoid.WGS84,n,t=w.Material.fromType(w.Material.ColorType);function r(a,l=new w.Color(1,1,0,.5),C=new w.Color(1,1,1,1)){this._scene=a.scene,t.uniforms.color=l,n=C,this._tooltip={setVisible:()=>{},showAt:()=>{}},this._surfaces=[],this.initialiseHandlers(),this.enhancePrimitives()}r.prototype.initialiseHandlers=function(){var a=this._scene,l=this,C=new w.ScreenSpaceEventHandler(a.canvas);function g(y,L){if(l._handlersMuted!=!0){var E=a.pick(L);E&&E.primitive&&E.primitive[y]&&E.primitive[y](L)}}C.setInputAction(function(y){g("leftClick",y.position)},w.ScreenSpaceEventType.LEFT_CLICK),C.setInputAction(function(y){g("leftDoubleClick",y.position)},w.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);var S;C.setInputAction(function(y){if(l._handlersMuted!=!0){var L=a.pick(y.endPosition);S&&(!L||S!=L.primitive)&&(!(S.isDestroyed&&S.isDestroyed())&&S.mouseOut(y.endPosition),S=null),L&&L.primitive&&(L=L.primitive,L.mouseOut&&(S=L),L.mouseMove&&L.mouseMove(y.endPosition))}},w.ScreenSpaceEventType.MOUSE_MOVE),C.setInputAction(function(y){g("leftUp",y.position)},w.ScreenSpaceEventType.LEFT_UP),C.setInputAction(function(y){g("leftDown",y.position)},w.ScreenSpaceEventType.LEFT_DOWN)},r.prototype.setListener=function(a,l,C){a[l]=C},r.prototype.muteHandlers=function(a){this._handlersMuted=a},r.prototype.registerEditableShape=function(a){var l=this;W(a,"mouseMove",function(C){a.setHighlighted(!0),a._editMode||l._tooltip.showAt(C,"Click to edit this shape")}),W(a,"mouseOut",function(C){a.setHighlighted(!1),l._tooltip.setVisible(!1)}),W(a,"leftClick",function(C){a.setEditMode(!0)})},r.prototype.startDrawing=function(a){this.disableAllEditMode(),this.editCleanUp&&this.editCleanUp(),this.editCleanUp=a,this.muteHandlers(!0)},r.prototype.stopDrawing=function(){this.editCleanUp&&(this.editCleanUp(),this.editCleanUp=null),this.muteHandlers(!1)},r.prototype.disableAllHighlights=function(){this.setHighlighted(void 0)},r.prototype.setHighlighted=function(a){this._highlightedSurface&&!this._highlightedSurface.isDestroyed()&&this._highlightedSurface!=a&&this._highlightedSurface.setHighlighted(!1),this._highlightedSurface=a},r.prototype.disableAllEditMode=function(){this.setEdited(void 0)},r.prototype.setEdited=function(a){this._editedSurface&&!this._editedSurface.isDestroyed()&&this._editedSurface.setEditMode(!1),this._editedSurface=a};var s={ellipsoid:w.Ellipsoid.WGS84,textureRotationAngle:0,height:0,asynchronous:!0,show:!0,debugShowBoundingVolume:!1},i=H(s,{appearance:new w.EllipsoidSurfaceAppearance({aboveGround:!1}),material:t,granularity:Math.PI/180}),u=H(s,{}),h=H(s,{}),f=H(s,{}),m=H(i,{rotation:0}),v=H(s,{width:5,geodesic:!0,granularity:1e4,appearance:new w.PolylineMaterialAppearance({aboveGround:!1}),material:t}),M=function(){function a(){}return a.prototype.initialiseOptions=function(l){j(this,l),this._ellipsoid=void 0,this._granularity=void 0,this._height=void 0,this._textureRotationAngle=void 0,this._id=void 0,this._createPrimitive=!0,this._primitive=void 0,this._outlinePolygon=void 0},a.prototype.setAttribute=function(l,C){this[l]=C,this._createPrimitive=!0},a.prototype.getAttribute=function(l){return this[l]},a.prototype.update=function(l,C,g){if(!w.defined(this.ellipsoid))throw new w.DeveloperError("this.ellipsoid must be defined.");if(!w.defined(this.appearance))throw new w.DeveloperError("this.material must be defined.");if(this.granularity<0)throw new w.DeveloperError("this.granularity and scene2D/scene3D overrides must be greater than zero.");if(this.show&&!(!this._createPrimitive&&!w.defined(this._primitive))){if(this._createPrimitive||this._ellipsoid!==this.ellipsoid||this._granularity!==this.granularity||this._height!==this.height||this._textureRotationAngle!==this.textureRotationAngle||this._id!==this.id){var S=this.getGeometry();if(!S)return;this._createPrimitive=!1,this._ellipsoid=this.ellipsoid,this._granularity=this.granularity,this._height=this.height,this._textureRotationAngle=this.textureRotationAngle,this._id=this.id,this._primitive=this._primitive&&this._primitive.destroy(),this._primitive=new w.Primitive({geometryInstances:new w.GeometryInstance({geometry:S,id:this.id,pickPrimitive:this}),appearance:this.appearance,asynchronous:this.asynchronous}),this._outlinePolygon=this._outlinePolygon&&this._outlinePolygon.destroy(),this.strokeColor&&this.getOutlineGeometry&&(this._outlinePolygon=new w.Primitive({geometryInstances:new w.GeometryInstance({geometry:this.getOutlineGeometry(),attributes:{color:w.ColorGeometryInstanceAttribute.fromColor(this.strokeColor)}}),appearance:new w.PerInstanceColorAppearance({flat:!0,renderState:{depthTest:{enabled:!0},lineWidth:this.strokeWidth||4}})}))}var y=this._primitive;y.appearance.material=this.material,y.debugShowBoundingVolume=this.debugShowBoundingVolume,y.update(l,C,g),this._outlinePolygon&&this._outlinePolygon.update(l,C,g)}},a.prototype.isDestroyed=function(){return!1},a.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),w.destroyObject(this)},a.prototype.setStrokeStyle=function(l,C){(!this.strokeColor||!this.strokeColor.equals(l)||this.strokeWidth!=C)&&(this._createPrimitive=!0,this.strokeColor=l,this.strokeWidth=C)},a}();r.ExtentPrimitive=function(){function a(l){if(!w.defined(l.extent))throw new w.DeveloperError("Extent is required");l=H(l,i),this.initialiseOptions(l),this.setExtent(l.extent)}return a.prototype=new M,a.prototype.setExtent=function(l){this.setAttribute("extent",l)},a.prototype.getExtent=function(){return this.getAttribute("extent")},a.prototype.getGeometry=function(){if(w.defined(this.extent))return new w.RectangleGeometry({rectangle:this.extent,height:this.height,vertexFormat:w.EllipsoidSurfaceAppearance.VERTEX_FORMAT,stRotation:this.textureRotationAngle,ellipsoid:this.ellipsoid,granularity:this.granularity})},a.prototype.getOutlineGeometry=function(){return new w.RectangleOutlineGeometry({rectangle:this.extent})},a}(),r.PolygonPrimitive=function(){function a(l){l=H(l,i),this.initialiseOptions(l),this.isPolygon=!0}return a.prototype=new M,a.prototype.setPositions=function(l){this.setAttribute("positions",l)},a.prototype.getPositions=function(){return this.getAttribute("positions")},a.prototype.getGeometry=function(){if(!(!w.defined(this.positions)||this.positions.length<3))return w.PolygonGeometry.fromPositions({positions:this.positions,height:this.height,vertexFormat:w.EllipsoidSurfaceAppearance.VERTEX_FORMAT,stRotation:this.textureRotationAngle,ellipsoid:this.ellipsoid,granularity:this.granularity})},a.prototype.getOutlineGeometry=function(){return w.PolygonOutlineGeometry.fromPositions({positions:this.getPositions()})},a}(),r.CirclePrimitive=function(){function a(l){if(!(w.defined(l.center)&&w.defined(l.radius)))throw new w.DeveloperError("Center and radius are required");l=H(l,i),this.initialiseOptions(l),this.setRadius(l.radius)}return a.prototype=new M,a.prototype.setCenter=function(l){this.setAttribute("center",l)},a.prototype.setRadius=function(l){this.setAttribute("radius",Math.max(.1,l))},a.prototype.getCenter=function(){return this.getAttribute("center")},a.prototype.getRadius=function(){return this.getAttribute("radius")},a.prototype.getGeometry=function(){if(w.defined(this.center)&&w.defined(this.radius))return new w.CircleGeometry({center:this.center,radius:this.radius,height:this.height,vertexFormat:w.EllipsoidSurfaceAppearance.VERTEX_FORMAT,stRotation:this.textureRotationAngle,ellipsoid:this.ellipsoid,granularity:this.granularity})},a.prototype.getOutlineGeometry=function(){return new w.CircleOutlineGeometry({center:this.getCenter(),radius:this.getRadius()})},a}(),r.EllipsePrimitive=function(){function a(l){if(!(w.defined(l.center)&&w.defined(l.semiMajorAxis)&&w.defined(l.semiMinorAxis)))throw new w.DeveloperError("Center and semi major and semi minor axis are required");l=H(l,m),this.initialiseOptions(l)}return a.prototype=new M,a.prototype.setCenter=function(l){this.setAttribute("center",l)},a.prototype.setSemiMajorAxis=function(l){l<this.getSemiMinorAxis()||this.setAttribute("semiMajorAxis",l)},a.prototype.setSemiMinorAxis=function(l){l>this.getSemiMajorAxis()||this.setAttribute("semiMinorAxis",l)},a.prototype.setRotation=function(l){return this.setAttribute("rotation",l)},a.prototype.getCenter=function(){return this.getAttribute("center")},a.prototype.getSemiMajorAxis=function(){return this.getAttribute("semiMajorAxis")},a.prototype.getSemiMinorAxis=function(){return this.getAttribute("semiMinorAxis")},a.prototype.getRotation=function(){return this.getAttribute("rotation")},a.prototype.getGeometry=function(){if(w.defined(this.center)&&w.defined(this.semiMajorAxis)&&w.defined(this.semiMinorAxis))return new w.EllipseGeometry({ellipsoid:this.ellipsoid,center:this.center,semiMajorAxis:this.semiMajorAxis,semiMinorAxis:this.semiMinorAxis,rotation:this.rotation,height:this.height,vertexFormat:w.EllipsoidSurfaceAppearance.VERTEX_FORMAT,stRotation:this.textureRotationAngle,granularity:this.granularity})},a.prototype.getOutlineGeometry=function(){return new w.EllipseOutlineGeometry({center:this.getCenter(),semiMajorAxis:this.getSemiMajorAxis(),semiMinorAxis:this.getSemiMinorAxis(),rotation:this.getRotation()})},a}(),r.PolylinePrimitive=function(){function a(l){l=H(l,v),this.initialiseOptions(l)}return a.prototype=new M,a.prototype.setPositions=function(l){this.setAttribute("positions",l)},a.prototype.setWidth=function(l){this.setAttribute("width",l)},a.prototype.setGeodesic=function(l){this.setAttribute("geodesic",l)},a.prototype.getPositions=function(){return this.getAttribute("positions")},a.prototype.getWidth=function(){return this.getAttribute("width")},a.prototype.getGeodesic=function(l){return this.getAttribute("geodesic")},a.prototype.getGeometry=function(){if(!(!w.defined(this.positions)||this.positions.length<2))return new w.PolylineGeometry({positions:this.positions,height:this.height,width:this.width<1?1:this.width,vertexFormat:w.EllipsoidSurfaceAppearance.VERTEX_FORMAT,ellipsoid:this.ellipsoid})},a}();var b={iconUrl:"./assets/img/dragIcon.png",shiftX:0,shiftY:0},T={iconUrl:"./assets/img/dragIcon.png",shiftX:0,shiftY:0},G={iconUrl:"./assets/img/dragIconLight.png",shiftX:0,shiftY:0};r.prototype.createBillboardGroup=function(a,l,C){var g=new r.BillboardGroup(this,l);return g.addBillboards(a,C),g},r.BillboardGroup=function(a,l){this._drawHelper=a,this._scene=a._scene,this._options=H(l,b);var C=new w.BillboardCollection;this._scene.primitives.add(C),this._billboards=C,this._orderedBillboards=[]},r.BillboardGroup.prototype.createBillboard=function(a,l){var C=this._billboards.add({show:!0,position:a,pixelOffset:new w.Cartesian2(this._options.shiftX,this._options.shiftY),eyeOffset:new w.Cartesian3(0,0,0),horizontalOrigin:w.HorizontalOrigin.CENTER,verticalOrigin:w.VerticalOrigin.CENTER,scale:1,image:this._options.iconUrl,color:n});if(l){let y=function(E){S.enableRotate=E},L=function(){for(var E=0,D=g._orderedBillboards.length;E<D&&g._orderedBillboards[E]!=C;++E);return E};var g=this,S=this._scene.screenSpaceCameraController;if(l.dragHandlers){var g=this;W(C,"leftDown",function(D){function k(x){C.position=x;for(var B=0,_=g._orderedBillboards.length;B<_&&g._orderedBillboards[B]!=C;++B);l.dragHandlers.onDrag&&l.dragHandlers.onDrag(L(),x)}function A(x){O.destroy(),y(!0),l.dragHandlers.onDragEnd&&l.dragHandlers.onDragEnd(L(),x)}var O=new w.ScreenSpaceEventHandler(g._scene.canvas);O.setInputAction(function(x){var B=g._scene.camera.pickEllipsoid(x.endPosition,e);B?k(B):A(B)},w.ScreenSpaceEventType.MOUSE_MOVE),O.setInputAction(function(x){A(g._scene.camera.pickEllipsoid(x.position,e))},w.ScreenSpaceEventType.LEFT_UP),y(!1),l.dragHandlers.onDragStart&&l.dragHandlers.onDragStart(L(),g._scene.camera.pickEllipsoid(D,e))})}l.onDoubleClick&&W(C,"leftDoubleClick",function(E){l.onDoubleClick(L())}),l.onClick&&W(C,"leftClick",function(E){l.onClick(L())}),l.tooltip&&(W(C,"mouseMove",function(E){g._drawHelper._tooltip.showAt(E,l.tooltip())}),W(C,"mouseOut",function(E){g._drawHelper._tooltip.setVisible(!1)}))}return C},r.BillboardGroup.prototype.insertBillboard=function(a,l,C){this._orderedBillboards.splice(a,0,this.createBillboard(l,C))},r.BillboardGroup.prototype.addBillboard=function(a,l){this._orderedBillboards.push(this.createBillboard(a,l))},r.BillboardGroup.prototype.addBillboards=function(a,l){for(var C=0;C<a.length;C++)this.addBillboard(a[C],l)},r.BillboardGroup.prototype.updateBillboardsPositions=function(a){for(var l=0;l<a.length;l++)this.getBillboard(l).position=a[l]},r.BillboardGroup.prototype.countBillboards=function(){return this._orderedBillboards.length},r.BillboardGroup.prototype.getBillboard=function(a){return this._orderedBillboards[a]},r.BillboardGroup.prototype.removeBillboard=function(a){this._billboards.remove(this.getBillboard(a)),this._orderedBillboards.splice(a,1)},r.BillboardGroup.prototype.remove=function(){this._billboards=this._billboards&&this._billboards.removeAll()&&this._billboards.destroy()},r.BillboardGroup.prototype.setOnTop=function(){this._scene.primitives.raiseToTop(this._billboards)},r.prototype.startDrawingMarker=function(l){var l=H(l,b);this.startDrawing(function(){y.remove(),L.destroy(),S.setVisible(!1)});var C=this,g=this._scene;g.primitives;var S=this._tooltip,y=new r.BillboardGroup(this,l),L=new w.ScreenSpaceEventHandler(g.canvas);L.setInputAction(function(E){if(E.position!=null){var D=g.camera.pickEllipsoid(E.position,e);D&&(y.addBillboard(D),C.stopDrawing(),l.callback(D))}},w.ScreenSpaceEventType.LEFT_CLICK),L.setInputAction(function(E){var D=E.endPosition;if(D!=null){var k=g.camera.pickEllipsoid(D,e);k?S.showAt(D,"<p>Click to add your marker. Position is: </p>"+Y(e.cartesianToCartographic(k))):S.showAt(D,"<p>Click on the globe to add your marker.</p>")}},w.ScreenSpaceEventType.MOUSE_MOVE)},r.prototype.startDrawingPolygon=function(l){var l=H(l,i);this.startDrawingPolyshape(!0,l)},r.prototype.startDrawingPolyline=function(l){var l=H(l,v);this.startDrawingPolyshape(!1,l)},r.prototype.startDrawingPolyshape=function(a,l){this.startDrawing(function(){S.remove(E),k.remove(),A.destroy(),y.setVisible(!1),$(g)});var C=this,g=this._scene,S=g.primitives,y=this._tooltip,L=a?3:2,E;a?E=new we.PolygonPrimitive(l):E=new we.PolylinePrimitive(l),E.asynchronous=!1,S.add(E);var D=[],k=new r.BillboardGroup(this,b),A=new w.ScreenSpaceEventHandler(g.canvas);Z(g),A.setInputAction(function(O){if(O.position!=null){var x=g.camera.pickEllipsoid(O.position,e);x&&(D.length==0&&(D.push(x.clone()),k.addBillboard(D[0])),D.length>=L&&(E.positions=D,E._createPrimitive=!0),D.push(x),k.addBillboard(x))}},w.ScreenSpaceEventType.LEFT_CLICK),A.setInputAction(function(O){var x=O.endPosition;if(x!=null)if(D.length==0)y.showAt(x,"<p>Click to add first point</p>");else{var B=g.camera.pickEllipsoid(x,e);B&&(D.pop(),B.y+=1+Math.random(),D.push(B),D.length>=L&&(E.positions=D,E._createPrimitive=!0),k.getBillboard(D.length-1).position=B,y.showAt(x,"<p>Click to add new point ("+D.length+")</p>"+(D.length>L?"<p>Double click to finish drawing</p>":"")))}},w.ScreenSpaceEventType.MOUSE_MOVE),A.setInputAction(function(O){var x=O.position;if(x!=null){if(D.length<L+2)return;var B=g.camera.pickEllipsoid(x,e);B&&($(g),C.stopDrawing(),typeof l.callback=="function"&&(D.length-1,l.callback(D)))}},w.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)};function z(a){return e.cartographicArrayToCartesianArray([w.Rectangle.northwest(a),w.Rectangle.northeast(a),w.Rectangle.southeast(a),w.Rectangle.southwest(a)])}function Z(a){a&&(a.canvas.style.cursor="crosshair")}function $(a){a&&(a.canvas.style.cursor="")}r.prototype.startDrawingExtent=function(l){var l=H(l,i);this.startDrawing(function(){E!=null&&S.remove(E),D!=null&&D.remove(),k.destroy(),y.setVisible(!1),$(g)});var C=this,g=this._scene,S=this._scene.primitives,y=this._tooltip,L=null,E=null,D=null,k=new w.ScreenSpaceEventHandler(g.canvas);Z(g);function A(O){E==null&&(E=new we.ExtentPrimitive({extent:O,material:l.material}),E.asynchronous=!1,S.add(E)),E.setExtent(O);var x=z(O);D==null?(D=new r.BillboardGroup(C,b),D.addBillboards(x)):D.updateBillboardsPositions(x)}k.setInputAction(function(O){if(O.position!=null){var x=g.camera.pickEllipsoid(O.position,e);if(x)if(E==null){L=e.cartesianToCartographic(x);var B=X(L,L);A(B)}else C.stopDrawing(),typeof l.callback=="function"&&l.callback(X(L,e.cartesianToCartographic(x)))}},w.ScreenSpaceEventType.LEFT_DOWN),k.setInputAction(function(O){var x=O.endPosition;if(x!=null)if(E==null)y.showAt(x,"<p>Click to start drawing rectangle</p>");else{var B=g.camera.pickEllipsoid(x,e);if(B){var _=X(L,e.cartesianToCartographic(B));A(_),y.showAt(x,"<p>Drag to change rectangle extent</p><p>Click again to finish drawing</p>")}}},w.ScreenSpaceEventType.MOUSE_MOVE)},r.prototype.startDrawingCircle=function(l){var l=H(l,i);this.startDrawing(function(){L!=null&&S.remove(L),E.remove(),D.destroy(),y.setVisible(!1)});var C=this,g=this._scene,S=this._scene.primitives,y=this._tooltip,L=null,E=null,D=new w.ScreenSpaceEventHandler(g.canvas);D.setInputAction(function(k){if(k.position!=null){var A=g.camera.pickEllipsoid(k.position,e);A&&(L==null?(L=new r.CirclePrimitive({center:A,radius:0,asynchronous:!1,material:l.material}),S.add(L),E=new r.BillboardGroup(C,b),E.addBillboards([A])):(typeof l.callback=="function"&&l.callback(L.getCenter(),L.getRadius()),C.stopDrawing()))}},w.ScreenSpaceEventType.LEFT_DOWN),D.setInputAction(function(k){var A=k.endPosition;if(A!=null)if(L==null)y.showAt(A,"<p>Click to start drawing the circle</p>");else{var O=g.camera.pickEllipsoid(A,e);O&&(L.setRadius(w.Cartesian3.distance(L.getCenter(),O)),E.updateBillboardsPositions(O),y.showAt(A,"<p>Move mouse to change circle radius</p><p>Click again to finish drawing</p>"))}},w.ScreenSpaceEventType.MOUSE_MOVE)},r.prototype.enhancePrimitives=function(){var a=this;w.Billboard.prototype.setEditable=function(){if(this._editable)return;this._editable=!0;var g=this,S=this;function y(L){a._scene.screenSpaceCameraController.enableRotate=L}W(g,"leftDown",function(L){function E(A){g.position=A,S.executeListeners({name:"drag",positions:A})}function D(A){k.destroy(),y(!0),S.executeListeners({name:"dragEnd",positions:A})}var k=new w.ScreenSpaceEventHandler(a._scene.canvas);k.setInputAction(function(A){var O=a._scene.camera.pickEllipsoid(A.endPosition,e);O?E(O):D(O)},w.ScreenSpaceEventType.MOUSE_MOVE),k.setInputAction(function(A){D(a._scene.camera.pickEllipsoid(A.position,e))},w.ScreenSpaceEventType.LEFT_UP),y(!1)}),te(g)};function l(g){a._scene,!(this._highlighted&&this._highlighted==g)&&this._editMode!==!0&&(this._highlighted=g,g?(a.setHighlighted(this),this._strokeColor=this.strokeColor,this.setStrokeStyle(w.Color.fromCssColorString("white"),this.strokeWidth)):this._strokeColor?this.setStrokeStyle(this._strokeColor,this.strokeWidth):this.setStrokeStyle(void 0,void 0))}function C(g){if(this._editMode!=g)if(a.disableAllHighlights(),g){a.setEdited(this);var S=a._scene,y=this;if(this._markers==null){let B=function(P,F){var N=P-1<0?F.length-1:P-1;N<E.countBillboards()&&(E.getBillboard(N).position=I(N)),N=P,N<E.countBillboards()&&(E.getBillboard(N).position=I(N))},_=function(){y.executeListeners({name:"onEdited",positions:y.positions})},I=function(P){var F=y.positions;return e.cartographicToCartesian(new w.EllipsoidGeodesic(e.cartesianToCartographic(F[P]),e.cartesianToCartographic(F[P<F.length-1?P+1:0])).interpolateUsingFraction(.5))};var L=new r.BillboardGroup(a,T),E=new r.BillboardGroup(a,G),D={dragHandlers:{onDrag:function(P,F){y.positions[P]=F,B(P,y.positions),y._createPrimitive=!0},onDragEnd:function(P,F){y._createPrimitive=!0,_()}},onDoubleClick:function(P){y.positions.length<4||(y.positions.splice(P,1),y._createPrimitive=!0,L.removeBillboard(P),E.removeBillboard(P),B(P,y.positions),_())},tooltip:function(){if(y.positions.length>3)return"Double click to remove this point"}};L.addBillboards(y.positions,D),this._markers=L;for(var k=[],A=0,O=y.positions.length+(this.isPolygon?0:-1);A<O;A++)k.push(I(A));var x={dragHandlers:{onDragStart:function(P,F){this.index=P+1,y.positions.splice(this.index,0,F),y._createPrimitive=!0},onDrag:function(P,F){y.positions[this.index]=F,y._createPrimitive=!0},onDragEnd:function(P,F){L.insertBillboard(this.index,F,D),E.getBillboard(this.index-1).position=I(this.index-1),E.insertBillboard(this.index,I(this.index),x),y._createPrimitive=!0,_()}},tooltip:function(){return"Drag to create a new point"}};E.addBillboards(k,x),this._editMarkers=E,this._globeClickhandler=new w.ScreenSpaceEventHandler(S.canvas),this._globeClickhandler.setInputAction(function(P){var F=S.pick(P.position);F&&F.primitive||y.setEditMode(!1)},w.ScreenSpaceEventType.LEFT_CLICK),L.setOnTop(),E.setOnTop()}this._editMode=!0}else this._markers!=null&&(this._markers.remove(),this._editMarkers.remove(),this._markers=null,this._editMarkers=null,this._globeClickhandler.destroy()),this._editMode=!1}we.PolylinePrimitive.prototype.setEditable=function(){if(!this.setEditMode){var g=this;g.isPolygon=!1,g.asynchronous=!1,a.registerEditableShape(g),g.setEditMode=C;var S=this.width;g.setHighlighted=function(y){this._editMode!==!0&&(y?(a.setHighlighted(this),this.setWidth(S*2)):this.setWidth(S))},g.getExtent=function(){return w.Rectangle.fromCartographicArray(e.cartesianArrayToCartographicArray(this.positions))},te(g),g.setEditMode(!1)}},we.PolygonPrimitive.prototype.setEditable=function(){var g=this;g.asynchronous=!1,a._scene,a.registerEditableShape(g),g.setEditMode=C,g.setHighlighted=l,te(g),g.setEditMode(!1)},we.ExtentPrimitive.prototype.setEditable=function(){if(!this.setEditMode){var g=this,S=a._scene;a.registerEditableShape(g),g.asynchronous=!1,g.setEditMode=function(y){if(this._editMode!=y)if(a.disableAllHighlights(),y){if(a.setEdited(this),this._markers==null){let D=function(){g.executeListeners({name:"onEdited",extent:g.extent})};var L=new r.BillboardGroup(a,T),E={dragHandlers:{onDrag:function(k,A){var O=L.getBillboard((k+2)%4).position;g.setExtent(X(e.cartesianToCartographic(O),e.cartesianToCartographic(A))),L.updateBillboardsPositions(z(g.extent))},onDragEnd:function(k,A){D()}},tooltip:function(){return"Drag to change the corners of this extent"}};L.addBillboards(z(g.extent),E),this._markers=L,this._globeClickhandler=new w.ScreenSpaceEventHandler(S.canvas),this._globeClickhandler.setInputAction(function(k){var A=S.pick(k.position);A&&!A.isDestroyed()&&A.primitive||g.setEditMode(!1)},w.ScreenSpaceEventType.LEFT_CLICK),L.setOnTop()}this._editMode=!0}else this._markers!=null&&(this._markers.remove(),this._markers=null,this._globeClickhandler.destroy()),this._editMode=!1},g.setHighlighted=l,te(g),g.setEditMode(!1)}},r.EllipsePrimitive.prototype.setEditable=function(){if(!this.setEditMode){var g=this,S=a._scene;g.asynchronous=!1,a.registerEditableShape(g),g.setEditMode=function(y){if(this._editMode!=y)if(a.disableAllHighlights(),y){a.setEdited(this);var L=this;if(this._markers==null){let k=function(){return w.EllipseOutlineGeometry(e,g.getCenter(),g.getSemiMajorAxis(),g.getSemiMinorAxis(),g.getRotation()+Math.PI/2,Math.PI/2).splice(0,4)},A=function(){g.executeListeners({name:"onEdited",center:g.getCenter(),semiMajorAxis:g.getSemiMajorAxis(),semiMinorAxis:g.getSemiMinorAxis(),rotation:0})};var E=new r.BillboardGroup(a,T),D={dragHandlers:{onDrag:function(O,x){var B=w.Cartesian3.distance(g.getCenter(),x);O%2==0?g.setSemiMajorAxis(B):g.setSemiMinorAxis(B),E.updateBillboardsPositions(k())},onDragEnd:function(O,x){A()}},tooltip:function(){return"Drag to change the excentricity and radius"}};E.addBillboards(k(),D),this._markers=E,this._globeClickhandler=new w.ScreenSpaceEventHandler(S.canvas),this._globeClickhandler.setInputAction(function(O){var x=S.pick(O.position);x&&x.primitive||L.setEditMode(!1)},w.ScreenSpaceEventType.LEFT_CLICK),E.setOnTop()}this._editMode=!0}else this._markers!=null&&(this._markers.remove(),this._markers=null,this._globeClickhandler.destroy()),this._editMode=!1},g.setHighlighted=l,te(g),g.setEditMode(!1)}},r.CirclePrimitive.prototype.getCircleCartesianCoordinates=function(g){for(var S=w.CircleOutlineGeometry.createGeometry(new w.CircleOutlineGeometry({ellipsoid:e,center:this.getCenter(),radius:this.getRadius(),granularity:g})),y=0,L,E=[];y<S.attributes.position.values.length;y+=3)L=S.attributes.position.values,E.push(new w.Cartesian3(L[y],L[y+1],L[y+2]));return E},r.CirclePrimitive.prototype.setEditable=function(){if(!this.setEditMode){var g=this,S=a._scene;g.asynchronous=!1,a.registerEditableShape(g),g.setEditMode=function(y){if(this._editMode!=y)if(a.disableAllHighlights(),y){a.setEdited(this);var L=this;if(this._markers==null){let k=function(){return L.getCircleCartesianCoordinates(w.Math.PI_OVER_TWO)},A=function(){g.executeListeners({name:"onEdited",center:g.getCenter(),radius:g.getRadius()})};var E=new r.BillboardGroup(a,T),D={dragHandlers:{onDrag:function(O,x){g.setRadius(w.Cartesian3.distance(g.getCenter(),x)),E.updateBillboardsPositions(k())},onDragEnd:function(O,x){A()}},tooltip:function(){return"Drag to change the radius"}};E.addBillboards(k(),D),this._markers=E,this._globeClickhandler=new w.ScreenSpaceEventHandler(S.canvas),this._globeClickhandler.setInputAction(function(O){var x=S.pick(O.position);x&&x.primitive||L.setEditMode(!1)},w.ScreenSpaceEventType.LEFT_CLICK),E.setOnTop()}this._editMode=!0}else this._markers!=null&&(this._markers.remove(),this._markers=null,this._globeClickhandler.destroy()),this._editMode=!1},g.setHighlighted=l,te(g),g.setEditMode(!1)}}},r.DrawHelperWidget=function(){function a(l,C){if(!w.defined(C.container))throw new w.DeveloperError("Container is required");var g={markerIcon:"./assets/img/glyphicons_242_google_maps.png",polylineIcon:"./assets/img/glyphicons_097_vector_path_line.png",polygonIcon:"./assets/img/glyphicons_096_vector_path_polygon.png",circleIcon:"./assets/img/glyphicons_095_vector_path_circle.png",extentIcon:"./assets/img/glyphicons_094_vector_path_square.png",clearIcon:"./assets/img/glyphicons_067_cleaning.png",polylineDrawingOptions:v,polygonDrawingOptions:u,extentDrawingOptions:h,circleDrawingOptions:f};j(C,g);var S=this,y=document.createElement("DIV");y.className="toolbar",C.container.appendChild(y);function L(k,A,O,x){var B=document.createElement("DIV");B.className="button",B.title=O,y.appendChild(B),B.onclick=x;var _=document.createElement("SPAN");B.appendChild(_);var I=document.createElement("IMG");return I.src=A,_.appendChild(I),B}var E=l._scene;L("marker",C.markerIcon,"Click to start drawing a 2D marker",function(){l.startDrawingMarker({callback:function(k){S.executeListeners({name:"markerCreated",position:k})}})}),L("polyline",C.polylineIcon,"Click to start drawing a 2D polyline",function(){l.startDrawingPolyline({callback:function(k){S.executeListeners({name:"polylineCreated",positions:k})}})}),L("polygon",C.polygonIcon,"Click to start drawing a 2D polygon",function(){l.startDrawingPolygon({callback:function(k){S.executeListeners({name:"polygonCreated",positions:k})}})}),L("extent",C.extentIcon,"Click to start drawing an Extent",function(){l.startDrawingExtent({callback:function(k){S.executeListeners({name:"extentCreated",extent:k})}})}),L("circle",C.circleIcon,"Click to start drawing a Circle",function(){l.startDrawingCircle({callback:function(k,A){S.executeListeners({name:"circleCreated",center:k,radius:A})}})});var D=document.createElement("DIV");D.className="divider",y.appendChild(D),L("clear",C.clearIcon,"Remove all primitives",function(){E.primitives.removeAll()}),te(this)}return a}(),r.prototype.addToolbar=function(a,l){return l=H(l,{container:a}),new r.DrawHelperWidget(this,l)};function X(a,l){var C=new w.Rectangle;C.west=Math.min(a.longitude,l.longitude),C.east=Math.max(a.longitude,l.longitude),C.south=Math.min(a.latitude,l.latitude),C.north=Math.max(a.latitude,l.latitude);var g=w.Math.EPSILON7;return C.east-C.west<g&&(C.east+=g*2),C.north-C.south<g&&(C.north+=g*2),C}function Y(a,l){return a.longitude.toFixed(l||3)+", "+a.latitude.toFixed(l||3)}function V(a,l){if(a==null||typeof a!="object"||a.constructor!=Object&&a.constructor!=Array)return a;if(a.constructor==Date||a.constructor==RegExp||a.constructor==Function||a.constructor==String||a.constructor==Number||a.constructor==Boolean)return new a.constructor(a);l=l||new a.constructor;for(var C in a)l[C]=typeof l[C]>"u"?V(a[C],null):l[C];return l}function j(a,l){a=a||{};var C;for(C in l)a[C]===void 0&&(a[C]=V(l[C]))}function H(a,l){var C=V(a),g;for(g in l)C[g]===void 0&&(C[g]=V(l[g]));return C}function W(a,l,C){a[l]=C}function te(a){a._listeners={},a.addListener=function(l,C){return this._listeners[l]=this._listeners[l]||[],this._listeners[l].push(C),this._listeners[l].length},a.executeListeners=function(l,C){if(this._listeners[l.name]&&this._listeners[l.name].length>0)for(var g=0;g<this._listeners[l.name].length;g++)this._listeners[l.name][g](l);else C&&C(l)}}return r}();const qi=2,ji=(e,n)=>{switch(e){case he.BOX:{if(n.features.length!==qi)throw new Error(`${e} must have 2 points`);const t=q.find(n.features,s=>{var i;return((i=s.properties)==null?void 0:i.type)===Ne.BOTTOM_LEFT}),r=q.find(n.features,s=>{var i;return((i=s.properties)==null?void 0:i.type)===Ne.TOP_RIGHT});if(r&&t){if(t.geometry.coordinates[0]===r.geometry.coordinates[0]&&t.geometry.coordinates[1]===r.geometry.coordinates[1])throw new Error(`${e} must define BOTTOM_LEFT and TOP_RIGHT different points`);return p.Rectangle.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],r.geometry.coordinates[0],r.geometry.coordinates[1])}else throw new Error(`${e} geojson must define BOTTOM_LEFT and TOP_RIGHT points`)}default:throw new Error(`${e} type geoJSON still not supported`)}},vn=e=>{const n=e.map(t=>{const r=p.Cartographic.fromCartesian(t);return[p.Math.toDegrees(r.longitude),p.Math.toDegrees(r.latitude)]});return n.push(n[0]),{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[n]}}},En=e=>{const n=wt.lineString([[p.Math.toDegrees(e.west),p.Math.toDegrees(e.south)],[p.Math.toDegrees(e.east),p.Math.toDegrees(e.north)]]);return Re(vt(n))},Sn=e=>{const n=wt.lineString([[e.west,e.south],[e.east,e.north]]);return Re(vt(n)).geometry.coordinates[0].map(r=>p.Cartesian3.fromRadiansArray(r)[0])};class Ki extends p.Color{}const Yi=e=>{const{drawState:n,drawingMaterial:t,drawingVertexColor:r,material:s,hollow:i,outlineWidth:u}=e,h=le(),[f,m]=c.useState();c.useEffect(()=>{m(new we(h,t,r))},[]),c.useEffect(()=>{if(f){const M=f;if(n.drawing)switch(n.type){case he.POLYGON:h.scene.globe.depthTestAgainstTerrain=!1,M.startDrawingPolygon({callback:b=>{n.handler({primitive:b,type:he.POLYGON,geojson:vn(b)})}});break;case he.BOX:h.scene.globe.depthTestAgainstTerrain=!1,M.startDrawingExtent({callback:b=>{n.handler({primitive:b,type:he.BOX,geojson:En(b)})}});break;default:throw new Error(`[CESIUM DRAW]: ${n.type} unrecognized primitive to draw.`)}else M.stopDrawing(),h.scene.globe.depthTestAgainstTerrain=!0}},[n,f]);const v=M=>{try{let b=M.coordinates!==void 0?M.coordinates:ji(M.type,M.geojson);if(i!==!0)switch(M.type){case he.BOX:return o.jsx(mn,{coordinates:b,material:s??t});case he.POLYGON:return o.jsx(fn,{hierarchy:new p.PolygonHierarchy(b),material:s??t});default:return o.jsx(o.Fragment,{})}else{switch(M.type){case he.BOX:b=Sn(b);break;case he.POLYGON:b=[...b,b[0]];break;default:return o.jsx(o.Fragment,{})}return o.jsx(Ui,{clampToGround:!0,positions:b,width:u??1,material:s??t})}}catch(b){return console.error(b),o.jsx(o.Fragment,{})}};return o.jsx(yn,{...e,children:e.drawings.map((M,b)=>o.jsxs(gn,{name:M.name,children:[o.jsxs(pn,{children:[o.jsxs("h1",{children:["Drawed Entity ",M.name]}),o.jsx("p",{children:"This is description of drawed entity"})]}),v(M)]},M.id))})},Zi=e=>{const n=le();return c.useEffect(()=>{n.extend(p.viewerCesiumInspectorMixin)},[n]),o.jsx(o.Fragment,{})},Xi=-25,Tn=2,Ji=e=>{const n=le(),t=(i,u=",")=>i.slice(i.indexOf(`
13
13
  `)+1).split(`
14
14
  `).map(m=>{const v=m.split(u);return{cartographic:p.Cartographic.fromDegrees(parseFloat(v[0]),parseFloat(v[1])),cartesian:new p.Cartesian2(parseFloat(v[0]),parseFloat(v[1]))}}),r=i=>{var h;i.preventDefault(),i.persist();const u=new FileReader;u.onload=f=>{var b;const m=(b=f.target)==null?void 0:b.result,v=t(m),M=p.Ellipsoid.WGS84;console.log(`Loaded CSV content:
15
15
  `,m),p.sampleTerrainMostDetailed(n.terrainProvider,v.map(T=>T.cartographic)).then(T=>{console.log(T),T=T.slice(0,T.length-1),n.scene.globe.depthTestAgainstTerrain=!0,n.entities.suspendEvents(),n.entities.removeAll(),T.forEach((G,z)=>{n.entities.add({name:(z+Tn).toString(),position:M.cartographicToCartesian(G),billboard:{verticalOrigin:p.VerticalOrigin.BOTTOM,scale:.7,image:"assets/img/map-marker.gif"},label:{text:(z+Tn).toString(),font:"14pt monospace",fillColor:p.Color.BLACK,style:p.LabelStyle.FILL_AND_OUTLINE,outlineWidth:4,outlineColor:p.Color.BLACK,verticalOrigin:p.VerticalOrigin.BOTTOM,pixelOffset:new p.Cartesian2(0,Xi)},description:`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@map-colonies/react-components",
3
- "version": "4.9.0",
3
+ "version": "4.9.1",
4
4
  "main": "./dist/@map-colonies/react-components.umd.js",
5
5
  "module": "./dist/@map-colonies/react-components.es.js",
6
6
  "types": "./dist/index.d.ts",
@@ -76,5 +76,5 @@
76
76
  "files": [
77
77
  "dist"
78
78
  ],
79
- "gitHead": "5d5d56a22d622af1c4d125ea295f4e63e50c2871"
79
+ "gitHead": "2ae5b6ed367f680b7392b5f9825d425d6cfdc03e"
80
80
  }