bbl-mapbox-react 0.0.19 → 0.0.20

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.
Files changed (3) hide show
  1. package/dist/index.cjs +19 -19
  2. package/dist/index.mjs +711 -710
  3. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1,54 +1,54 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);let l=require(`mapbox-gl`);l=s(l);let u=require(`@turf/turf`);u=s(u);let d=require(`react-dom/client`);d=s(d);let f=require(`react-dom`);f=s(f);let p=require(`react/jsx-runtime`);p=s(p);let m=require(`@arco-design/web-react`);m=s(m);const h={fillColor:`#ffffff`,fillOpacity:1,strokeColor:`rgba(0, 0, 0, 0.8)`,strokeWidth:1,strokeOpacity:1},g={fillColor:`#ffcc00`,fillOpacity:1,strokeColor:`#ff6600`,strokeWidth:2,strokeOpacity:1},_={fillColor:`#ffffff`,fillOpacity:1,strokeColor:`rgba(0, 0, 0, 0.8)`,strokeWidth:1,strokeOpacity:1},v={color:`#ffffff`,width:1,opacity:1,dashArray:[4,4]};function y(e,t,n=v){return{color:e?.color??t?.color??n.color,width:e?.width??t?.width??n.width,opacity:e?.opacity??t?.opacity??n.opacity,dashArray:e?.dashArray??t?.dashArray??n.dashArray}}const b={fillColor:`#ffffff`,fillOpacity:1,strokeColor:`rgba(0, 0, 0, 0.8)`,strokeWidth:1,strokeOpacity:1};function x(e,t,n=h){return{fillColor:e?.fillColor??t?.fillColor??n.fillColor,fillOpacity:e?.fillOpacity??t?.fillOpacity??n.fillOpacity,strokeColor:e?.strokeColor??t?.strokeColor??n.strokeColor,strokeWidth:e?.strokeWidth??t?.strokeWidth??n.strokeWidth,strokeOpacity:e?.strokeOpacity??t?.strokeOpacity??n.strokeOpacity}}function S(e,t){if(!t)return e;let n={...e};return(n.type===`circle`||n.type===`square`||n.type===`rectangle`||n.type===`polygon`)&&n.showArea===void 0&&(n.showArea=t.showArea),(n.type===`square`||n.type===`rectangle`||n.type===`polygon`||n.type===`polyline`)&&n.showLength===void 0&&(n.showLength=t.showLength),n.type===`circle`&&n.showRadius===void 0&&(n.showRadius=t.showRadius),n}const C={blue:{center:`#4285f4`,edge:`#4285f400`,mid:`#1a73e8`},green:{center:`#34a853`,edge:`#34a85300`,mid:`#0d652d`},red:{center:`#ea4335`,edge:`#ea433500`,mid:`#c5221f`},purple:{center:`#9c27b0`,edge:`#9c27b000`,mid:`#6a1b9a`},cyan:{center:`#00bcd4`,edge:`#00bcd400`,mid:`#00838f`},orange:{center:`#ff9800`,edge:`#ff980000`,mid:`#f57c00`}},w={rotationSpeed:1,initialRotation:0,colorScheme:`green`,opacity:70,gradientType:`conical`,showRings:!0,showCenter:!0,showScanLine:!0},T={trigger:`click`,position:`top`,offset:[0,-10],showCloseButton:!0,animation:`fade`,closeOnClickOutside:!0,closeOnEscape:!0,hoverDelay:300,maxWidth:320,zIndex:1e3},E=[{class:`motorway`,label:`高速公路`,color:`#E84E3C`},{class:`trunk`,label:`国道`,color:`#FF8C00`},{class:`primary`,label:`主干道`,color:`#FFD700`},{class:`secondary`,label:`次干道`,color:`#4CAF50`},{class:`tertiary`,label:`三级道路`,color:`#2196F3`},{class:`motorway_link`,label:`高速匝道`,color:`#FF6B6B`},{class:`trunk_link`,label:`国道匝道`,color:`#FFB84D`},{class:`primary_link`,label:`主干道匝道`,color:`#FFE066`},{class:`secondary_link`,label:`次干道匝道`,color:`#66BB6A`},{class:`tertiary_link`,label:`三级道路匝道`,color:`#42A5F5`},{class:`minor`,label:`小路`,color:`#81C784`},{class:`residential`,label:`居民区道路`,color:`#81C784`},{class:`unclassified`,label:`未分类道路`,color:`#9E9E9E`},{class:`service`,label:`服务道路`,color:`#64B5F6`},{class:`track`,label:`土路`,color:`#A1887F`},{class:`path`,label:`小径`,color:`#BCAAA4`}];function D(e,t,n){let r=u.point(e);return u.destination(r,t/1e3,n,{units:`kilometers`}).geometry.coordinates}function O(e,t){return u.distance(u.point(e),u.point(t),{units:`kilometers`})*1e3}function k(e,t){return u.bearing(u.point(e),u.point(t))}function ee(e){let t=u.polygon([e]);return u.area(t)}function A(e){return e>=1e6?`${(e/1e6).toFixed(2)} km²`:`${e.toFixed(0)} m²`}function j(e){return e>=1e3?`${(e/1e3).toFixed(2)} km`:`${e.toFixed(0)} m`}const M=512,te=512/2,ne=512/2-2;function N(e){return e*Math.PI/180}function P(e=1){return .3+Math.max(0,Math.min(1,e))*.7}var re=class{constructor(e,t,n,r,i,a){this.isDestroyed=!1,this.isSelected=!1,this.map=e,this.entity=t,this.entityId=t.id,this.globalNameConfig=r,this.globalSelectNameConfig=i,this.globalAreaConfig=a,this.sourceId=`${n}-source-${String(t.id)}`,this.layerId=`${n}-layer-${String(t.id)}`,this.labelSourceId=`${n}-label-source-${String(t.id)}`,this.labelLayerId=`${n}-label-layer-${String(t.id)}`,this.areaSourceId=`${n}-area-source-${String(t.id)}`,this.areaLayerId=`${n}-area-layer-${String(t.id)}`,this.canvas=document.createElement(`canvas`),this.canvas.width=512,this.canvas.height=512,this.ctx=this.canvas.getContext(`2d`)}init(e){this.draw(),this.map.addSource(this.sourceId,{type:`canvas`,canvas:this.canvas,coordinates:e,animate:!0}),this.map.addLayer({id:this.layerId,type:`raster`,source:this.sourceId,paint:{"raster-fade-duration":0,"raster-opacity":1}}),this.initLabelLayer(),this.initAreaLayer()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get areaStyle(){return x(`areaConfig`in this.entity?this.entity.areaConfig:void 0,this.globalAreaConfig,_)}getAreaLabelAnchor(){return{anchor:`center`,offset:[0,0]}}initLabelLayer(){let e=this.getEntityCenter(),{confidence:t}=this.entity,n=P(t);this.map.addSource(this.labelSourceId,{type:`geojson`,data:{type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{name:this.entity.name||``,selected:this.isSelected,opacity:n}}}),this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.labelSourceId,layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.5],"text-allow-overlap":!0},paint:{"text-opacity":[`get`,`opacity`],"text-color":[`case`,[`get`,`selected`],this.selectNameStyle.fillColor,this.nameStyle.fillColor],"text-halo-color":[`case`,[`get`,`selected`],this.selectNameStyle.strokeColor,this.nameStyle.strokeColor],"text-halo-width":[`case`,[`get`,`selected`],this.selectNameStyle.strokeWidth,this.nameStyle.strokeWidth]}})}initAreaLayer(){if(!(`showArea`in this.entity&&this.entity.showArea)||!this.getArea)return;let e=this.getEntityCenter(),{confidence:t}=this.entity,n=P(t),{anchor:r,offset:i}=this.getAreaLabelAnchor();this.map.addSource(this.areaSourceId,{type:`geojson`,data:{type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{area:A(this.getArea()),opacity:n}}}),this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.areaSourceId,layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":r,"text-offset":i,"text-allow-overlap":!0},paint:{"text-opacity":[`get`,`opacity`],"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth}})}updateLabel(){let e=this.map.getSource(this.labelSourceId);if(!e)return;let t=P(this.entity.confidence);e.setData({type:`Feature`,geometry:{type:`Point`,coordinates:this.getEntityCenter()},properties:{name:this.entity.name||``,selected:this.isSelected,opacity:t}})}updateAreaLabel(){if(`showArea`in this.entity&&this.entity.showArea&&this.getArea){let e=this.map.getSource(this.areaSourceId);if(e){let t=P(this.entity.confidence);e.setData({type:`Feature`,geometry:{type:`Point`,coordinates:this.getEntityCenter()},properties:{area:A(this.getArea()),opacity:t}})}else this.initAreaLayer()}else this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getSource(this.areaSourceId)&&this.map.removeSource(this.areaSourceId)}setSelected(e){this.isSelected!==e&&(this.isSelected=e,this.updateLabel())}colorWithAlpha(e,t){if(e.startsWith(`rgba`))return e;if(e.startsWith(`#`)){let n=e.slice(1),r=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),a=parseInt(n.slice(4,6),16);return`rgba(${r}, ${i}, ${a}, ${t})`}return e.startsWith(`rgb(`)?e.replace(`rgb(`,`rgba(`).replace(`)`,`, ${t})`):e}updateSourceCoordinates(e){this.map.getSource(this.sourceId)?.setCoordinates(e)}getEntityId(){return this.entityId}getCenter(){return this.getEntityCenter()}getBounds(){return this.getEntityBounds()}getLayerId(){return this.layerId}getLabelLayerId(){return this.labelLayerId}destroy(){this.isDestroyed=!0,this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getSource(this.areaSourceId)&&this.map.removeSource(this.areaSourceId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getSource(this.labelSourceId)&&this.map.removeSource(this.labelSourceId),this.map.getLayer(this.layerId)&&this.map.removeLayer(this.layerId),this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId)}},ie=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1775030039452'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='24839'%20data-spm-anchor-id='a313x.search_index.0.i1.78953a81FCkAe0'%20width='64'%20height='64'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cpath%20d='M512%20938.666667l-170.666667-170.666667h341.333334l-170.666667%20170.666667z%20m0-853.333334l170.666667%20170.666667H341.333333l170.666667-170.666667z%20m0%20512a85.333333%2085.333333%200%201%201%200-170.666666%2085.333333%2085.333333%200%200%201%200%20170.666666zM85.333333%20512l170.666667-170.666667v341.333334l-170.666667-170.666667z%20m853.333334%200l-170.666667%20170.666667V341.333333l170.666667%20170.666667z'%20fill='%23ffffff'%20p-id='24840'%3e%3c/path%3e%3c/svg%3e`;const ae=`__edit-move-icon__`;var F=!1;function I(e){if(e.hasImage(`__edit-move-icon__`)||F)return;F=!0;let t=new Image;t.onload=()=>{if(e.hasImage(`__edit-move-icon__`)){F=!1;return}let n=document.createElement(`canvas`);n.width=28,n.height=28;let r=n.getContext(`2d`);r.beginPath(),r.arc(28/2,28/2,28/2,0,Math.PI*2),r.fillStyle=`rgba(51,136,255,0.9)`,r.fill();let i=28*.6,a=(28-i)/2;r.drawImage(t,a,a,i,i);let o=r.getImageData(0,0,28,28);e.addImage(ae,{width:28,height:28,data:new Uint8Array(o.data.buffer)}),F=!1},t.onerror=()=>{F=!1},t.src=ie}function oe(e,t){let n=D(e,t,0),r=D(e,t,90),i=D(e,t,180),a=D(e,t,270)[0],o=r[0],s=i[1],c=n[1];return[[a,c],[o,c],[o,s],[a,s]]}var se=class extends re{constructor(e,t,n,r){super(e,t,`radar`,n,r),this.animationFrameId=null,this.isEditing=!1,this.editSourceId=``,this.editMoveLayerId=``,this.editSourceId=`radar-edit-source-${t.id}`,this.editMoveLayerId=`radar-edit-move-${t.id}`,this.currentRotation=t.initialRotation??w.initialRotation;let i=oe(t.center,t.radius);this.init(i),t.isAnimating&&this.startAnimation()}getEntityCenter(){return this.entity.center}getEntityBounds(){let e=oe(this.entity.center,this.entity.radius),t=e[3][0],n=e[3][1],r=e[1][0],i=e[1][1];return[[t,n],[r,i]]}draw(){let e=this.ctx,t=this.entity;e.clearRect(0,0,512,512),e.globalAlpha=P(t.confidence),this.drawSector(e,t),(t.showRings??w.showRings)&&this.drawRings(e),(t.showScanLine??w.showScanLine)&&this.drawScanLine(e,t),(t.showCenter??w.showCenter)&&this.drawCenterDot(e,t),e.globalAlpha=1}drawSector(e,t){let n=t.colorScheme??w.colorScheme,r=C[n],i=(t.opacity??w.opacity)/100,a=t.sectorAngle,o=N(this.currentRotation-a/2-90),s=N(this.currentRotation+a/2-90),c=e.createRadialGradient(256,256,0,256,256,254);c.addColorStop(0,this.colorWithAlpha(r.center,i)),c.addColorStop(.5,this.colorWithAlpha(r.mid,i*.6)),c.addColorStop(1,this.colorWithAlpha(r.edge,0)),e.beginPath(),e.moveTo(256,256),e.arc(256,256,254,o,s),e.closePath(),e.fillStyle=c,e.fill()}drawRings(e){e.strokeStyle=`rgba(255, 255, 255, 0.2)`,e.lineWidth=2,e.setLineDash([5,5]);for(let t=1;t<=3;t++){let n=254*t/3;e.beginPath(),e.arc(256,256,n,0,Math.PI*2),e.stroke()}e.setLineDash([])}drawScanLine(e,t){let n=t.colorScheme??w.colorScheme,r=C[n],i=N(this.currentRotation-90),a=256+Math.cos(i)*254,o=256+Math.sin(i)*254;e.beginPath(),e.moveTo(256,256),e.lineTo(a,o),e.strokeStyle=r.center,e.lineWidth=2,e.lineCap=`round`,e.globalAlpha=.8,e.stroke(),e.globalAlpha=1}drawCenterDot(e,t){let n=t.colorScheme??w.colorScheme,r=C[n];e.beginPath(),e.arc(256,256,5,0,Math.PI*2),e.fillStyle=r.center,e.fill(),e.strokeStyle=`white`,e.lineWidth=2,e.stroke()}startAnimation(){if(this.animationFrameId!==null||this.isDestroyed)return;let e=()=>{if(this.isDestroyed)return;let t=this.entity.rotationSpeed??w.rotationSpeed;this.currentRotation+=t,this.currentRotation>=360&&(this.currentRotation-=360),this.draw(),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e),this.map.getSource(this.sourceId)?.play()}stopAnimation(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.map.getSource(this.sourceId)?.pause()}update(e){let t=this.entity;if(this.entity=e,t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.radius!==e.radius){let t=oe(e.center,e.radius);this.updateSourceCoordinates(t)}(t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.name!==e.name||t.confidence!==e.confidence)&&this.updateLabel(),t.isAnimating!==e.isAnimating&&(e.isAnimating?this.startAnimation():this.stopAnimation()),e.isAnimating||this.draw()}isPointInEntity(e){let{center:t,radius:n}=this.entity,r=e[0]-t[0],i=e[1]-t[1],a=111320*Math.cos(t[1]*Math.PI/180);return Math.sqrt((r*a)**2+(i*110540)**2)<=n}destroy(){this.removeEditLayers(),this.stopAnimation(),super.destroy()}getEditHandleGeoJSON(e){return{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`Point`,coordinates:e??this.entity.center},properties:{handleType:`move`,index:0}}]}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e){let t=this.map.getSource(this.editSourceId);t&&t.setData(this.getEditHandleGeoJSON(e))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,e?this.createEditLayers():this.removeEditLayers())}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.entity.center,r=this.map.project(e),i=this.map.project(n),a=r.x-i.x,o=r.y-i.y;return a*a+o*o<=144?{type:`move`,index:0,position:n}:null}applyHandleMove(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r],a={...this.entity,center:i};this.entity=a;let o=oe(i,this.entity.radius);return this.updateSourceCoordinates(o),this.updateLabel(),this.refreshEditHandles(),a}updateEditPreview(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r],a=oe(i,this.entity.radius);this.updateSourceCoordinates(a);let o=this.entity;this.entity={...this.entity,center:i},this.updateLabel(),this.entity=o,this.refreshEditHandles(i)}cancelEditPreview(){let e=oe(this.entity.center,this.entity.radius);this.updateSourceCoordinates(e),this.updateLabel(),this.refreshEditHandles()}};function ce(e,t,n){let r=t/2,i=n/2,a=D(e,i,0),o=D(e,r,90),s=D(e,i,180),c=D(e,r,270)[0],l=o[0],u=s[1],d=a[1];return[[c,d],[l,d],[l,u],[c,u]]}var le=class extends re{constructor(e,t,n,r){super(e,t,`image`,n,r),this.loadedImage=null,this.imageLoaded=!1,this.currentSrc=``,this.imageAspectRatio=1,this.isEditing=!1,this.editSourceId=``,this.editMoveLayerId=``,this.editSourceId=`image-edit-source-${t.id}`,this.editMoveLayerId=`image-edit-move-${t.id}`,this.loadImage(t.src,!0)}getSize(){let{width:e}=this.entity,t=e/this.imageAspectRatio;return[e,t]}loadImage(e,t=!1){if(!e){console.warn(`Image src is empty`);return}this.currentSrc=e;let n=new Image;n.crossOrigin=`anonymous`,n.onload=()=>{if(e===this.currentSrc)if(this.loadedImage=n,this.imageLoaded=!0,this.imageAspectRatio=n.naturalWidth/n.naturalHeight,t){let[e,t]=this.getSize(),n=ce(this.entity.center,e,t);this.init(n)}else{let[e,t]=this.getSize(),n=ce(this.entity.center,e,t);this.updateSourceCoordinates(n),this.draw()}},n.onerror=()=>{console.error(`Failed to load image: ${e}`)},n.src=e}getEntityCenter(){return this.entity.center}getEntityBounds(){let[e,t]=this.getSize(),n=ce(this.entity.center,e,t),r=n[3][0],i=n[3][1],a=n[1][0],o=n[1][1];return[[r,i],[a,o]]}initLabelLayer(){let e=this.getEntityCenter(),{name:t,confidence:n}=this.entity,r=P(n);this.map.addSource(this.labelSourceId,{type:`geojson`,data:{type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{name:t||``,selected:this.isSelected,opacity:r}}}),this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.labelSourceId,layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-opacity":[`get`,`opacity`],"text-color":[`case`,[`get`,`selected`],`#ffcc00`,`#ffffff`],"text-halo-color":[`case`,[`get`,`selected`],`#ff6600`,`rgba(0, 0, 0, 0.8)`],"text-halo-width":[`case`,[`get`,`selected`],2,1]}})}draw(){let e=this.ctx;if(e.clearRect(0,0,512,512),!this.imageLoaded||!this.loadedImage)return;e.globalAlpha=P(this.entity.confidence),e.save(),e.translate(256,256);let t=this.entity.rotation??0;t!==0&&e.rotate(N(t)),e.drawImage(this.loadedImage,-508/2,-508/2,508,508),e.restore(),e.globalAlpha=1}update(e){let t=this.entity;if(this.entity=e,t.src!==e.src){this.imageLoaded=!1,this.loadedImage=null,this.loadImage(e.src);return}if(t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.width!==e.width){let[t,n]=this.getSize(),r=ce(e.center,t,n);this.updateSourceCoordinates(r)}(t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.name!==e.name||t.confidence!==e.confidence)&&this.updateLabel(),(t.rotation!==e.rotation||t.confidence!==e.confidence)&&this.draw()}isPointInEntity(e){let{center:t}=this.entity,[n,r]=this.getSize(),i=e[0]-t[0],a=e[1]-t[1],o=111320*Math.cos(t[1]*Math.PI/180),s=Math.abs(i*o),c=Math.abs(a*110540);return s<=n/2&&c<=r/2}getEditHandleGeoJSON(e){return{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`Point`,coordinates:e??this.entity.center},properties:{handleType:`move`,index:0}}]}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e){let t=this.map.getSource(this.editSourceId);t&&t.setData(this.getEditHandleGeoJSON(e))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,e?this.createEditLayers():this.removeEditLayers())}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.entity.center,r=this.map.project(e),i=this.map.project(n),a=r.x-i.x,o=r.y-i.y;return a*a+o*o<=144?{type:`move`,index:0,position:n}:null}applyHandleMove(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r],a={...this.entity,center:i};this.entity=a;let[o,s]=this.getSize(),c=ce(i,o,s);return this.updateSourceCoordinates(c),this.updateLabel(),this.refreshEditHandles(),a}updateEditPreview(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r],[a,o]=this.getSize(),s=ce(i,a,o);this.updateSourceCoordinates(s);let c=this.entity;this.entity={...this.entity,center:i},this.updateLabel(),this.entity=c,this.refreshEditHandles(i)}cancelEditPreview(){let[e,t]=this.getSize(),n=ce(this.entity.center,e,t);this.updateSourceCoordinates(n),this.updateLabel(),this.refreshEditHandles()}destroy(){this.removeEditLayers(),super.destroy()}},ue=class{constructor(e,t,n,r){this.marker=null,this.markerElement=null,this.imageElement=null,this.labelElement=null,this.placeholderElement=null,this.isSelected=!1,this.imageAspectRatio=1,this.imageLoaded=!1,this.destroyed=!1,this.isEditing=!1,this.moveIconElement=null,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.loadImageAndCreateMarker(t.src)}loadImageAndCreateMarker(e){if(!e){console.warn(`Marker src is empty`);return}let t=new Image;t.crossOrigin=`anonymous`,t.onload=()=>{this.destroyed||(this.imageAspectRatio=t.naturalWidth/t.naturalHeight,this.imageLoaded=!0,this.createMarker())},t.onerror=()=>{console.error(`Failed to load marker image: ${e}`)},t.src=e}createMarker(){let{center:e,src:t,width:n,rotation:r=0,anchor:i=`center`,name:a,confidence:o}=this.entity,s=n/this.imageAspectRatio;this.markerElement=document.createElement(`div`),this.markerElement.className=`mapbox-marker-container`,this.markerElement.setAttribute(`data-entity-id`,String(this.entity.id)),this.onBeforeImageCreate(),a&&(this.placeholderElement=document.createElement(`div`),this.placeholderElement.className=`mapbox-marker-placeholder`,this.placeholderElement.textContent=a,this.markerElement.appendChild(this.placeholderElement)),this.imageElement=document.createElement(`img`),this.imageElement.src=t,this.imageElement.style.width=`${n}px`,this.imageElement.style.height=`${s}px`,this.imageElement.style.transform=`rotate(${r}deg)`,this.imageElement.style.opacity=`${P(o)}`,this.imageElement.style.pointerEvents=`auto`,this.markerElement.appendChild(this.imageElement),a&&(this.labelElement=document.createElement(`div`),this.labelElement.className=`mapbox-marker-label`,this.labelElement.textContent=a,this.labelElement.setAttribute(`data-entity-id`,String(this.entity.id)),this.updateLabelStyle(),this.markerElement.appendChild(this.labelElement)),this.marker=new l.default.Marker({element:this.markerElement,anchor:i}).setLngLat(e).addTo(this.map),this.onMarkerCreated()}onBeforeImageCreate(){}onMarkerCreated(){}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}updateLabelStyle(){if(!this.labelElement)return;let{confidence:e}=this.entity,t=P(e),n=this.isSelected?this.selectNameStyle:this.nameStyle;this.labelElement.className=this.isSelected?`mapbox-marker-label mapbox-marker-label--selected`:`mapbox-marker-label`,this.labelElement.style.opacity=`${t}`,this.labelElement.style.color=n.fillColor;let r=n.strokeWidth,i=n.strokeColor;this.labelElement.style.webkitTextStroke=`${r*1.5}px ${i}`,this.labelElement.style.paintOrder=`stroke fill`,this.labelElement.style.textShadow=`none`}getEntityId(){return this.entity.id}getCenter(){return this.entity.center}getBounds(){let{center:e,width:t}=this.entity,n=t/this.imageAspectRatio,r=this.map.getZoom(),i=156543.03392*Math.cos(e[1]*Math.PI/180)/2**r,a=t*i,o=n*i,s=111320*Math.cos(e[1]*Math.PI/180),c=a/2/s,l=o/2/110540;return[[e[0]-c,e[1]-l],[e[0]+c,e[1]+l]]}getLayerId(){return`marker-${this.entity.id}`}getLabelLayerId(){return null}setSelected(e){this.isSelected!==e&&(this.isSelected=e,this.updateLabelStyle())}isPointInEntity(e){if(!this.marker||!this.imageLoaded)return!1;let{center:t,width:n}=this.entity,r=n/this.imageAspectRatio,i=this.map.getZoom(),a=156543.03392*Math.cos(t[1]*Math.PI/180)/2**i,o=n*a,s=r*a,c=e[0]-t[0],l=e[1]-t[1],u=111320*Math.cos(t[1]*Math.PI/180),d=Math.abs(c*u),f=Math.abs(l*110540);return d<=o/2&&f<=s/2}update(e){let t=this.entity;if(this.entity=e,t.src!==e.src){this.destroy(),this.imageLoaded=!1,this.loadImageAndCreateMarker(e.src);return}if(!this.marker||!this.imageElement)return;(t.center[0]!==e.center[0]||t.center[1]!==e.center[1])&&this.marker.setLngLat(e.center);let n=e.width/this.imageAspectRatio,r=e.rotation??0,i=P(e.confidence);(t.width!==e.width||t.rotation!==e.rotation||t.confidence!==e.confidence)&&(this.imageElement.style.width=`${e.width}px`,this.imageElement.style.height=`${n}px`,this.imageElement.style.transform=`rotate(${r}deg)`,this.imageElement.style.opacity=`${i}`),t.name!==e.name&&(e.name&&!this.labelElement?(this.labelElement=document.createElement(`div`),this.labelElement.className=`mapbox-marker-label`,this.labelElement.textContent=e.name,this.updateLabelStyle(),this.markerElement?.appendChild(this.labelElement),this.placeholderElement=document.createElement(`div`),this.placeholderElement.className=`mapbox-marker-placeholder`,this.placeholderElement.textContent=e.name,this.markerElement?.insertBefore(this.placeholderElement,this.markerElement.firstChild)):!e.name&&this.labelElement?(this.labelElement.remove(),this.labelElement=null,this.placeholderElement?.remove(),this.placeholderElement=null):this.labelElement&&(this.labelElement.textContent=e.name||``,this.placeholderElement&&(this.placeholderElement.textContent=e.name||``))),t.confidence!==e.confidence&&this.updateLabelStyle()}destroy(){this.removeMoveIcon(),this.destroyed=!0,this.marker&&=(this.marker.remove(),null),this.markerElement=null,this.imageElement=null,this.labelElement=null,this.placeholderElement=null}createMoveIcon(){if(this.moveIconElement||!this.markerElement)return;let e=document.createElement(`div`);e.className=`mapbox-marker-move-icon`,e.style.cssText=`width:28px;height:28px;border-radius:50%;background:rgba(51,136,255,0.9);display:flex;align-items:center;justify-content:center;cursor:move;position:absolute;left:50%;bottom:0;transform:translate(-50%,100%);pointer-events:none;`;let t=document.createElement(`img`);t.src=ie,t.style.cssText=`width:60%;height:60%;`,e.appendChild(t),this.markerElement.appendChild(e),this.moveIconElement=e}removeMoveIcon(){this.moveIconElement&&=(this.moveIconElement.remove(),null)}setEditing(e){this.isEditing!==e&&(this.isEditing=e,e?this.createMoveIcon():this.removeMoveIcon())}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.map.project(e);if(this.moveIconElement){let t=this.moveIconElement.getBoundingClientRect(),r=this.map.getContainer().getBoundingClientRect(),i=t.left+t.width/2-r.left,a=t.top+t.height/2-r.top,o=n.x-i,s=n.y-a;if(o*o+s*s<=256)return{type:`move`,index:0,position:e}}return null}applyHandleMove(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r],a={...this.entity,center:i};return this.entity=a,this.marker&&this.marker.setLngLat(i),a}updateEditPreview(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r];this.marker&&this.marker.setLngLat(i)}cancelEditPreview(){this.marker&&this.marker.setLngLat(this.entity.center)}},de=class extends ue{constructor(e,t,n,r){super(e,t,n,r),this.showTrajectory=0,this.showTrajectoryPoints=!1,this.trajInitialized=!1,this.statusElement=null,this.statusRoot=null,this.trajSourceId=`unit-traj-source-${t.id}`,this.trajLayerId=`unit-traj-layer-${t.id}`,this.trajPointsLayerId=`unit-traj-points-layer-${t.id}`,t.showTrajectory&&(this.showTrajectory=t.showTrajectory),this.showTrajectoryPoints=t.showTrajectoryPoints??!1}renderStatus(){return null}onBeforeImageCreate(){this.markerElement&&(this.statusElement=document.createElement(`div`),this.statusElement.className=`mapbox-unit-status`,this.markerElement.appendChild(this.statusElement),this.updateStatusContent())}updateStatusContent(){if(!this.statusElement)return;let e=this.renderStatus();e?(this.statusRoot||=(0,d.createRoot)(this.statusElement),this.statusRoot.render(e),this.statusElement.style.display=`block`):(this.statusRoot&&this.statusRoot.render(null),this.statusElement.style.display=`none`)}refreshStatus(){this.updateStatusContent()}getLayerId(){return`unit-${this.entity.id}`}onMarkerCreated(){this.entity.showTrajectory&&(this.showTrajectory=this.entity.showTrajectory,this.initTrajectoryLayer())}shouldShowTrajectory(){return this.showTrajectory===`all`||typeof this.showTrajectory==`number`&&this.showTrajectory>0}getTrajectoryCount(){let{predicted_traj:e}=this.entity;return!e||e.length===0?0:this.showTrajectory===`all`?e.length:typeof this.showTrajectory==`number`&&this.showTrajectory>0?Math.min(this.showTrajectory,e.length):0}initTrajectoryLayer(){if(this.trajInitialized)return;if(!this.map.isStyleLoaded()){requestAnimationFrame(()=>this.initTrajectoryLayer());return}let e=this.getTrajectoryGeoJSON();this.map.addSource(this.trajSourceId,{type:`geojson`,data:e});let t=this.shouldShowTrajectory()?`visible`:`none`,n=this.shouldShowTrajectory()&&this.showTrajectoryPoints?`visible`:`none`;this.map.addLayer({id:this.trajLayerId,type:`line`,source:this.trajSourceId,layout:{"line-join":`round`,"line-cap":`round`,visibility:t},paint:{"line-color":this.isSelected?`#ffcc00`:`#00ff88`,"line-width":3,"line-opacity":P(this.entity.confidence)*.8,"line-dasharray":[2,2]}}),this.map.addLayer({id:this.trajPointsLayerId,type:`circle`,source:this.trajSourceId,filter:[`==`,`$type`,`Point`],layout:{visibility:n},paint:{"circle-radius":4,"circle-color":this.isSelected?`#ffcc00`:`#00ff88`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":1,"circle-opacity":P(this.entity.confidence)}}),this.trajInitialized=!0}getTrajectoryGeoJSON(){let{predicted_traj:e,center:t}=this.entity,n=this.getTrajectoryCount();if(!e||e.length===0||n===0)return{type:`FeatureCollection`,features:[]};let r=e.slice(0,n),i=[t],a=[];return r.forEach((e,t)=>{let n=[e.lon,e.lat];i.push(n),a.push({type:`Feature`,geometry:{type:`Point`,coordinates:n},properties:{index:t,alt:e.alt}})}),{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:i},properties:{}},...a]}}setShowTrajectory(e){let t=e===`all`||typeof e==`number`&&e>0;if(t&&!this.trajInitialized){this.showTrajectory=e,this.initTrajectoryLayer();return}let n=this.shouldShowTrajectory();if(this.showTrajectory=e,this.trajInitialized){let e=t?`visible`:`none`,r=t&&this.showTrajectoryPoints?`visible`:`none`;this.map.getLayer(this.trajLayerId)&&this.map.setLayoutProperty(this.trajLayerId,`visibility`,e),this.map.getLayer(this.trajPointsLayerId)&&this.map.setLayoutProperty(this.trajPointsLayerId,`visibility`,r),t&&n&&this.updateTrajectoryData()}}getShowTrajectory(){return this.showTrajectory}setShowTrajectoryPoints(e){if(this.showTrajectoryPoints=e,this.trajInitialized&&this.map.getLayer(this.trajPointsLayerId)){let t=this.shouldShowTrajectory()&&e?`visible`:`none`;this.map.setLayoutProperty(this.trajPointsLayerId,`visibility`,t)}}getShowTrajectoryPoints(){return this.showTrajectoryPoints}setSelected(e){let t=this.isSelected;super.setSelected(e),t!==e&&this.trajInitialized&&this.updateTrajectoryStyle()}updateTrajectoryStyle(){let e=this.isSelected?`#ffcc00`:`#00ff88`,t=P(this.entity.confidence);this.map.getLayer(this.trajLayerId)&&(this.map.setPaintProperty(this.trajLayerId,`line-color`,e),this.map.setPaintProperty(this.trajLayerId,`line-opacity`,t*.8)),this.map.getLayer(this.trajPointsLayerId)&&(this.map.setPaintProperty(this.trajPointsLayerId,`circle-color`,e),this.map.setPaintProperty(this.trajPointsLayerId,`circle-opacity`,t))}updateTrajectoryData(){if(!this.trajInitialized)return;let e=this.map.getSource(this.trajSourceId);e&&e.setData(this.getTrajectoryGeoJSON())}update(e){let t=this.entity;super.update(e),t.showTrajectory!==e.showTrajectory&&this.setShowTrajectory(e.showTrajectory??0),t.showTrajectoryPoints!==e.showTrajectoryPoints&&this.setShowTrajectoryPoints(e.showTrajectoryPoints??!1),this.updateTrajectoryData(),t.confidence!==e.confidence&&this.updateTrajectoryStyle()}destroy(){this.statusRoot&&=(this.statusRoot.unmount(),null),this.statusElement=null,this.trajInitialized&&(this.map.getLayer(this.trajPointsLayerId)&&this.map.removeLayer(this.trajPointsLayerId),this.map.getLayer(this.trajLayerId)&&this.map.removeLayer(this.trajLayerId),this.map.getSource(this.trajSourceId)&&this.map.removeSource(this.trajSourceId)),super.destroy()}},fe=class e{static{this.DEFAULTS={strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,fillColor:`#3388ff`,fillOpacity:.2}}constructor(e,t,n,r,i,a){this.isSelected=!1,this.initialized=!1,this.isEditing=!1,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.globalAreaConfig=i,this.globalLengthConfig=a,this.sourceId=`polygon-source-${t.id}`,this.fillLayerId=`polygon-fill-${t.id}`,this.strokeLayerId=`polygon-stroke-${t.id}`,this.labelLayerId=`polygon-label-${t.id}`,this.areaLayerId=`polygon-area-${t.id}`,this.lengthLayerId=`polygon-length-${t.id}`,this.editSourceId=`polygon-edit-source-${t.id}`,this.editHandleLayerId=`polygon-edit-handles-${t.id}`,this.editMidpointLayerId=`polygon-edit-midpoints-${t.id}`,this.editMoveLayerId=`polygon-edit-move-${t.id}`,this.initLayers()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get areaStyle(){return x(this.entity.areaConfig,this.globalAreaConfig,_)}get lengthStyle(){return x(this.entity.lengthConfig,this.globalLengthConfig,b)}initLayers(){if(!this.initialized)try{let t=this.getGeoJSON();this.map.addSource(this.sourceId,{type:`geojson`,data:t});let n=this.entity.confidence??1,r=P(n);this.map.addLayer({id:this.fillLayerId,type:`fill`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],paint:{"fill-color":this.entity.fillColor??e.DEFAULTS.fillColor,"fill-opacity":(this.entity.fillOpacity??e.DEFAULTS.fillOpacity)*r}}),this.map.addLayer({id:this.strokeLayerId,type:`line`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],layout:{"line-join":`round`,"line-cap":`round`},paint:{"line-color":this.isSelected?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor,"line-width":this.entity.strokeWidth??e.DEFAULTS.strokeWidth,"line-opacity":(this.entity.strokeOpacity??e.DEFAULTS.strokeOpacity)*r}}),this.entity.name&&this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":r}}),this.entity.showArea&&this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":r}}),this.entity.showLength&&this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":r}}),this.initialized=!0}catch{this.map.once(`idle`,()=>this.initLayers())}}getGeoJSON(){let{coordinates:e}=this.entity;if(!e||e.length<3)return{type:`FeatureCollection`,features:[]};let t=[...e];(e[0][0]!==e[e.length-1][0]||e[0][1]!==e[e.length-1][1])&&t.push(e[0]);let n=[{type:`Feature`,geometry:{type:`Polygon`,coordinates:[t]},properties:{}}];if(this.entity.name){let t=this.getBottomPoint(e);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:t},properties:{pointType:`label`,name:this.entity.name}})}if(this.entity.showArea){let e=this.calculateGeometricCenter();n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{pointType:`area`,area:A(this.getArea())}})}if(this.entity.showLength)for(let t=0;t<e.length;t++){let r=e[t],i=e[(t+1)%e.length],a=[(r[0]+i[0])/2,(r[1]+i[1])/2],o=O(r,i);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:a},properties:{pointType:`length`,length:j(o)}})}return{type:`FeatureCollection`,features:n}}getBottomPoint(e){let t=e[0],n=e[0][1];for(let r of e)r[1]<n&&(n=r[1],t=r);return t}getArea(){let{coordinates:e}=this.entity;if(!e||e.length<3)return 0;let t=[...e];return(t[0][0]!==t[t.length-1][0]||t[0][1]!==t[t.length-1][1])&&t.push(t[0]),ee(t)}getEntityId(){return this.entity.id}getBounds(){let{coordinates:e}=this.entity;if(!e||e.length===0){let e=this.getCenter();return[e,e]}let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let a of e)t=Math.min(t,a[0]),n=Math.max(n,a[0]),r=Math.min(r,a[1]),i=Math.max(i,a[1]);return[[t,r],[n,i]]}getCenter(){return this.entity.center?this.entity.center:this.calculateGeometricCenter()}calculateGeometricCenter(){let{coordinates:e}=this.entity;if(!e||e.length===0)return[0,0];let t=0,n=0;for(let r of e)t+=r[0],n+=r[1];return[t/e.length,n/e.length]}getLayerId(){return this.fillLayerId}getLabelLayerId(){return this.entity.name?this.labelLayerId:null}setSelected(t){this.isSelected!==t&&(this.isSelected=t,this.initialized&&(this.map.getLayer(this.strokeLayerId)&&this.map.setPaintProperty(this.strokeLayerId,`line-color`,t?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor),this.map.getLayer(this.labelLayerId)&&(this.map.setPaintProperty(this.labelLayerId,`text-color`,t?this.selectNameStyle.fillColor:this.nameStyle.fillColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-color`,t?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-width`,t?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth))))}isPointInEntity(e){let{coordinates:t}=this.entity;return!t||t.length<3?!1:this.pointInPolygon(e,t)}pointInPolygon(e,t){let[n,r]=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let[o,s]=t[e],[c,l]=t[a];s>r!=l>r&&n<(c-o)*(r-s)/(l-s)+o&&(i=!i)}return i}update(t){let n=this.entity;if(this.entity=t,!this.initialized)return;let r=t.confidence??1,i=P(r);if(n.coordinates!==t.coordinates||n.name!==t.name||n.showArea!==t.showArea||n.showLength!==t.showLength){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),!n.name&&t.name&&!this.map.getLayer(this.labelLayerId)?this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":i}}):n.name&&!t.name&&this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),!n.showArea&&t.showArea&&!this.map.getLayer(this.areaLayerId)?this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":i}}):n.showArea&&!t.showArea&&this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),!n.showLength&&t.showLength&&!this.map.getLayer(this.lengthLayerId)?this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":i}}):n.showLength&&!t.showLength&&this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId)}(n.fillColor!==t.fillColor||n.fillOpacity!==t.fillOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.fillLayerId)&&(this.map.setPaintProperty(this.fillLayerId,`fill-color`,t.fillColor??e.DEFAULTS.fillColor),this.map.setPaintProperty(this.fillLayerId,`fill-opacity`,(t.fillOpacity??e.DEFAULTS.fillOpacity)*i)),(n.strokeColor!==t.strokeColor||n.strokeWidth!==t.strokeWidth||n.strokeOpacity!==t.strokeOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.strokeLayerId)&&(this.isSelected||this.map.setPaintProperty(this.strokeLayerId,`line-color`,t.strokeColor??e.DEFAULTS.strokeColor),this.map.setPaintProperty(this.strokeLayerId,`line-width`,t.strokeWidth??e.DEFAULTS.strokeWidth),this.map.setPaintProperty(this.strokeLayerId,`line-opacity`,(t.strokeOpacity??e.DEFAULTS.strokeOpacity)*i)),n.confidence!==t.confidence&&(this.map.getLayer(this.labelLayerId)&&this.map.setPaintProperty(this.labelLayerId,`text-opacity`,i),this.map.getLayer(this.areaLayerId)&&this.map.setPaintProperty(this.areaLayerId,`text-opacity`,i),this.map.getLayer(this.lengthLayerId)&&this.map.setPaintProperty(this.lengthLayerId,`text-opacity`,i))}getEditHandleGeoJSON(e){let t=e??this.entity.coordinates;if(!t||t.length<3)return{type:`FeatureCollection`,features:[]};let n=[];for(let e=0;e<t.length;e++)n.push({type:`Feature`,geometry:{type:`Point`,coordinates:t[e]},properties:{handleType:`vertex`,index:e}});for(let e=0;e<t.length;e++){let r=t[e],i=t[(e+1)%t.length];n.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(r[0]+i[0])/2,(r[1]+i[1])/2]},properties:{handleType:`midpoint`,index:e}})}let r=0,i=0;for(let e of t)r+=e[0],i+=e[1];return r/=t.length,i/=t.length,n.push({type:`Feature`,geometry:{type:`Point`,coordinates:[r,i]},properties:{handleType:`move`,index:0}}),{type:`FeatureCollection`,features:n}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editMidpointLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`midpoint`],paint:{"circle-radius":4,"circle-color":`#3388ff`,"circle-opacity":.5,"circle-stroke-color":`#3388ff`,"circle-stroke-width":1}}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`vertex`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getLayer(this.editMidpointLayerId)&&this.map.removeLayer(this.editMidpointLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e){let t=this.map.getSource(this.editSourceId);t&&t.setData(this.getEditHandleGeoJSON(e))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,this.initialized&&(e?this.createEditLayers():this.removeEditLayers()))}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.entity.coordinates;if(!n||n.length<3)return null;let r=this.map.project(e),i=0,a=0;for(let e of n)i+=e[0],a+=e[1];i/=n.length,a/=n.length;let o=this.map.project([i,a]),s=r.x-o.x,c=r.y-o.y;if(s*s+c*c<=144)return{type:`move`,index:0,position:[i,a]};for(let e=0;e<n.length;e++){let t=this.map.project(n[e]),i=r.x-t.x,a=r.y-t.y;if(i*i+a*a<=100)return{type:`vertex`,index:e,position:n[e]}}for(let e=0;e<n.length;e++){let t=n[e],i=n[(e+1)%n.length],a=[(t[0]+i[0])/2,(t[1]+i[1])/2],o=this.map.project(a),s=r.x-o.x,c=r.y-o.y;if(s*s+c*c<=100)return{type:`midpoint`,index:e,position:a}}return null}offsetCoordinates(e,t,n){let r=n[0]-t[0],i=n[1]-t[1];return e.map(e=>[e[0]+r,e[1]+i])}applyHandleMove(e,t){let n;e.type===`move`?n=this.offsetCoordinates(this.entity.coordinates,e.position,t):(n=[...this.entity.coordinates],n[e.index]=t);let r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}updateEditPreview(e,t){let n;e.type===`move`?n=this.offsetCoordinates(this.entity.coordinates,e.position,t):(n=[...this.entity.coordinates],n[e.index]=t);let r=this.entity;this.entity={...this.entity,coordinates:n};let i=this.map.getSource(this.sourceId);i&&i.setData(this.getGeoJSON()),this.entity=r,this.refreshEditHandles(n)}cancelEditPreview(){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),this.refreshEditHandles()}deleteVertex(e){let t=this.entity.coordinates;if(!t||t.length<=3)return null;let n=t.filter((t,n)=>n!==e),r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}addVertex(e,t){let n=[...this.entity.coordinates];n.splice(e+1,0,t);let r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}destroy(){this.initialized&&=(this.removeEditLayers(),this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId),this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.strokeLayerId)&&this.map.removeLayer(this.strokeLayerId),this.map.getLayer(this.fillLayerId)&&this.map.removeLayer(this.fillLayerId),this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId),!1)}},pe=class e{static{this.DEFAULTS={strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,lineCap:`round`,lineJoin:`round`}}constructor(e,t,n,r,i){this.isSelected=!1,this.initialized=!1,this.isEditing=!1,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.globalLengthConfig=i,this.sourceId=`polyline-source-${t.id}`,this.lineLayerId=`polyline-stroke-${t.id}`,this.labelLayerId=`polyline-label-${t.id}`,this.lengthLayerId=`polyline-length-${t.id}`,this.editSourceId=`polyline-edit-source-${t.id}`,this.editHandleLayerId=`polyline-edit-handles-${t.id}`,this.editMidpointLayerId=`polyline-edit-midpoints-${t.id}`,this.editMoveLayerId=`polyline-edit-move-${t.id}`,this.initLayers()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get lengthStyle(){return x(this.entity.lengthConfig,this.globalLengthConfig,b)}initLayers(){if(!this.initialized)try{let t=this.getGeoJSON();this.map.addSource(this.sourceId,{type:`geojson`,data:t});let n=this.entity.confidence??1,r=P(n);this.map.addLayer({id:this.lineLayerId,type:`line`,source:this.sourceId,filter:[`==`,`$type`,`LineString`],layout:{"line-join":this.entity.lineJoin??e.DEFAULTS.lineJoin,"line-cap":this.entity.lineCap??e.DEFAULTS.lineCap},paint:{"line-color":this.isSelected?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor,"line-width":this.entity.strokeWidth??e.DEFAULTS.strokeWidth,"line-opacity":(this.entity.strokeOpacity??e.DEFAULTS.strokeOpacity)*r,...this.entity.dashArray?{"line-dasharray":this.entity.dashArray}:{}}}),this.entity.name&&this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":r}}),this.entity.showLength&&this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":r}}),this.initialized=!0}catch{this.map.once(`idle`,()=>this.initLayers())}}getGeoJSON(){let{coordinates:e,name:t}=this.entity;if(!e||e.length<2)return{type:`FeatureCollection`,features:[]};let n=[{type:`Feature`,geometry:{type:`LineString`,coordinates:e},properties:{}}];if(t){let r=this.getMidPoint(e);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:r},properties:{pointType:`label`,name:t}})}if(this.entity.showLength)for(let t=0;t<e.length-1;t++){let r=e[t],i=e[t+1],a=[(r[0]+i[0])/2,(r[1]+i[1])/2],o=O(r,i);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:a},properties:{pointType:`length`,length:j(o)}})}return{type:`FeatureCollection`,features:n}}getMidPoint(e){if(e.length===1)return e[0];let t=Math.floor((e.length-1)/2),n=e[t],r=e[t+1];return[(n[0]+r[0])/2,(n[1]+r[1])/2]}getEntityId(){return this.entity.id}getBounds(){let{coordinates:e}=this.entity;if(!e||e.length===0){let e=this.getCenter();return[e,e]}let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let a of e)t=Math.min(t,a[0]),n=Math.max(n,a[0]),r=Math.min(r,a[1]),i=Math.max(i,a[1]);return[[t,r],[n,i]]}getCenter(){return this.entity.center?this.entity.center:this.calculateGeometricCenter()}calculateGeometricCenter(){let{coordinates:e}=this.entity;if(!e||e.length===0)return[0,0];let t=0,n=0;for(let r of e)t+=r[0],n+=r[1];return[t/e.length,n/e.length]}getLayerId(){return this.lineLayerId}getLabelLayerId(){return this.entity.name?this.labelLayerId:null}setSelected(t){this.isSelected!==t&&(this.isSelected=t,this.initialized&&(this.map.getLayer(this.lineLayerId)&&this.map.setPaintProperty(this.lineLayerId,`line-color`,t?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor),this.map.getLayer(this.labelLayerId)&&(this.map.setPaintProperty(this.labelLayerId,`text-color`,t?this.selectNameStyle.fillColor:this.nameStyle.fillColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-color`,t?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-width`,t?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth))))}isPointInEntity(e){let{coordinates:t}=this.entity;if(!t||t.length<2)return!1;let n=this.getClickThreshold();for(let r=0;r<t.length-1;r++)if(this.pointToSegmentDistance(e,t[r],t[r+1])<n)return!0;return!1}getClickThreshold(){return .001*2**(12-this.map.getZoom())}pointToSegmentDistance(e,t,n){let[r,i]=e,[a,o]=t,[s,c]=n,l=s-a,u=c-o,d=l*l+u*u;if(d===0)return Math.sqrt((r-a)*(r-a)+(i-o)*(i-o));let f=((r-a)*l+(i-o)*u)/d;f=Math.max(0,Math.min(1,f));let p=a+f*l,m=o+f*u;return Math.sqrt((r-p)*(r-p)+(i-m)*(i-m))}update(t){let n=this.entity;if(this.entity=t,!this.initialized)return;let r=t.confidence??1,i=P(r);if(n.coordinates!==t.coordinates||n.name!==t.name||n.showLength!==t.showLength){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),!n.name&&t.name&&!this.map.getLayer(this.labelLayerId)?this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":i}}):n.name&&!t.name&&this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),!n.showLength&&t.showLength&&!this.map.getLayer(this.lengthLayerId)?this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":i}}):n.showLength&&!t.showLength&&this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId)}(n.strokeColor!==t.strokeColor||n.strokeWidth!==t.strokeWidth||n.strokeOpacity!==t.strokeOpacity||n.confidence!==t.confidence||n.dashArray!==t.dashArray)&&this.map.getLayer(this.lineLayerId)&&(this.isSelected||this.map.setPaintProperty(this.lineLayerId,`line-color`,t.strokeColor??e.DEFAULTS.strokeColor),this.map.setPaintProperty(this.lineLayerId,`line-width`,t.strokeWidth??e.DEFAULTS.strokeWidth),this.map.setPaintProperty(this.lineLayerId,`line-opacity`,(t.strokeOpacity??e.DEFAULTS.strokeOpacity)*i),t.dashArray&&this.map.setPaintProperty(this.lineLayerId,`line-dasharray`,t.dashArray)),(n.lineCap!==t.lineCap||n.lineJoin!==t.lineJoin)&&this.map.getLayer(this.lineLayerId)&&(this.map.setLayoutProperty(this.lineLayerId,`line-cap`,t.lineCap??e.DEFAULTS.lineCap),this.map.setLayoutProperty(this.lineLayerId,`line-join`,t.lineJoin??e.DEFAULTS.lineJoin)),n.confidence!==t.confidence&&this.map.getLayer(this.labelLayerId)&&this.map.setPaintProperty(this.labelLayerId,`text-opacity`,i),n.confidence!==t.confidence&&this.map.getLayer(this.lengthLayerId)&&this.map.setPaintProperty(this.lengthLayerId,`text-opacity`,i)}getEditHandleGeoJSON(e){let t=e??this.entity.coordinates;if(!t||t.length<2)return{type:`FeatureCollection`,features:[]};let n=[];for(let e=0;e<t.length;e++)n.push({type:`Feature`,geometry:{type:`Point`,coordinates:t[e]},properties:{handleType:`vertex`,index:e}});for(let e=0;e<t.length-1;e++){let r=t[e],i=t[e+1];n.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(r[0]+i[0])/2,(r[1]+i[1])/2]},properties:{handleType:`midpoint`,index:e}})}let r=0,i=0;for(let e of t)r+=e[0],i+=e[1];return r/=t.length,i/=t.length,n.push({type:`Feature`,geometry:{type:`Point`,coordinates:[r,i]},properties:{handleType:`move`,index:0}}),{type:`FeatureCollection`,features:n}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editMidpointLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`midpoint`],paint:{"circle-radius":4,"circle-color":`#3388ff`,"circle-opacity":.5,"circle-stroke-color":`#3388ff`,"circle-stroke-width":1}}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`vertex`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getLayer(this.editMidpointLayerId)&&this.map.removeLayer(this.editMidpointLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e){let t=this.map.getSource(this.editSourceId);t&&t.setData(this.getEditHandleGeoJSON(e))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,this.initialized&&(e?this.createEditLayers():this.removeEditLayers()))}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.entity.coordinates;if(!n||n.length<2)return null;let r=this.map.project(e),i=0,a=0;for(let e of n)i+=e[0],a+=e[1];i/=n.length,a/=n.length;let o=this.map.project([i,a]),s=r.x-o.x,c=r.y-o.y;if(s*s+c*c<=144)return{type:`move`,index:0,position:[i,a]};for(let e=0;e<n.length;e++){let t=this.map.project(n[e]),i=r.x-t.x,a=r.y-t.y;if(i*i+a*a<=100)return{type:`vertex`,index:e,position:n[e]}}for(let e=0;e<n.length-1;e++){let t=n[e],i=n[e+1],a=[(t[0]+i[0])/2,(t[1]+i[1])/2],o=this.map.project(a),s=r.x-o.x,c=r.y-o.y;if(s*s+c*c<=100)return{type:`midpoint`,index:e,position:a}}return null}offsetCoordinates(e,t,n){let r=n[0]-t[0],i=n[1]-t[1];return e.map(e=>[e[0]+r,e[1]+i])}applyHandleMove(e,t){let n;e.type===`move`?n=this.offsetCoordinates(this.entity.coordinates,e.position,t):(n=[...this.entity.coordinates],n[e.index]=t);let r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}updateEditPreview(e,t){let n;e.type===`move`?n=this.offsetCoordinates(this.entity.coordinates,e.position,t):(n=[...this.entity.coordinates],n[e.index]=t);let r=this.entity;this.entity={...this.entity,coordinates:n};let i=this.map.getSource(this.sourceId);i&&i.setData(this.getGeoJSON()),this.entity=r,this.refreshEditHandles(n)}cancelEditPreview(){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),this.refreshEditHandles()}deleteVertex(e){let t=this.entity.coordinates;if(!t||t.length<=2)return null;let n=t.filter((t,n)=>n!==e),r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}addVertex(e,t){let n=[...this.entity.coordinates];n.splice(e+1,0,t);let r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}destroy(){this.initialized&&=(this.removeEditLayers(),this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.lineLayerId)&&this.map.removeLayer(this.lineLayerId),this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId),!1)}};function me(e,t,n=64){let[r,i]=e,a=[],o=t/6371e3,s=i*Math.PI/180;for(let e=0;e<=n;e++){let t=e/n*2*Math.PI,c=o*Math.cos(t),l=o*Math.sin(t)/Math.cos(s),u=i+c*180/Math.PI,d=r+l*180/Math.PI;a.push([d,u])}return a}var he=class e{static{this.GRADIENT_STEPS=10}static{this.DEFAULTS={strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,fillColor:`#3388ff`,fillOpacity:.2,fillType:`solid`,showCenterPoint:!0,centerPointRadius:4}}constructor(e,t,n,r,i,a){this.isSelected=!1,this.initialized=!1,this.gradientLayerIds=[],this.gradientSourceIds=[],this.isEditing=!1,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.globalAreaConfig=i,this.globalCircleConfig=a,this.sourceId=`circle-source-${t.id}`,this.fillLayerId=`circle-fill-${t.id}`,this.strokeLayerId=`circle-stroke-${t.id}`,this.centerPointLayerId=`circle-center-${t.id}`,this.labelLayerId=`circle-label-${t.id}`,this.areaLayerId=`circle-area-${t.id}`,this.radiusLineLayerId=`circle-radius-line-${t.id}`,this.radiusLabelLayerId=`circle-radius-label-${t.id}`,this.editSourceId=`circle-edit-source-${t.id}`,this.editHandleLayerId=`circle-edit-handles-${t.id}`,this.editMoveLayerId=`circle-edit-move-${t.id}`,this.initLayers()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get areaStyle(){return x(this.entity.areaConfig,this.globalAreaConfig,_)}get radiusTextStyle(){return x(this.entity.circleConfig,this.globalCircleConfig,h)}get radiusLineStyle(){return y(this.entity.circleConfig?.radiusLine,this.globalCircleConfig?.radiusLine,v)}initLayers(){if(!this.initialized)try{let t=this.getGeoJSON();this.map.addSource(this.sourceId,{type:`geojson`,data:t});let n=this.entity.confidence??1,r=P(n);if((this.entity.fillType??e.DEFAULTS.fillType)===`radial-gradient`?this.initGradientLayers(r):this.map.addLayer({id:this.fillLayerId,type:`fill`,source:this.sourceId,filter:[`==`,[`get`,`type`],`circle`],paint:{"fill-color":this.entity.fillColor??e.DEFAULTS.fillColor,"fill-opacity":(this.entity.fillOpacity??e.DEFAULTS.fillOpacity)*r}}),this.map.addLayer({id:this.strokeLayerId,type:`line`,source:this.sourceId,filter:[`==`,[`get`,`type`],`circle`],layout:{"line-join":`round`,"line-cap":`round`},paint:{"line-color":this.isSelected?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor,"line-width":this.entity.strokeWidth??e.DEFAULTS.strokeWidth,"line-opacity":(this.entity.strokeOpacity??e.DEFAULTS.strokeOpacity)*r}}),(this.entity.showCenterPoint??e.DEFAULTS.showCenterPoint)&&this.map.addLayer({id:this.centerPointLayerId,type:`circle`,source:this.sourceId,filter:[`==`,[`get`,`type`],`center`],paint:{"circle-radius":this.entity.centerPointRadius??e.DEFAULTS.centerPointRadius,"circle-color":this.entity.centerPointColor??this.entity.fillColor??e.DEFAULTS.fillColor,"circle-opacity":r,"circle-stroke-width":1,"circle-stroke-color":`#ffffff`,"circle-stroke-opacity":r*.8}}),this.entity.name&&this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`center`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":r}}),this.entity.showArea&&this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`center`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`bottom`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":r}}),this.entity.showRadius){let e=this.radiusLineStyle;this.map.addLayer({id:this.radiusLineLayerId,type:`line`,source:this.sourceId,filter:[`==`,[`get`,`type`],`radius-line`],layout:{"line-cap":`round`},paint:{"line-color":e.color,"line-width":e.width,"line-opacity":e.opacity*r,"line-dasharray":e.dashArray}}),this.map.addLayer({id:this.radiusLabelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`radius-label`],layout:{"text-field":[`get`,`radius`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.radiusTextStyle.fillColor,"text-halo-color":this.radiusTextStyle.strokeColor,"text-halo-width":this.radiusTextStyle.strokeWidth,"text-opacity":r}})}this.initialized=!0}catch{this.map.once(`idle`,()=>this.initLayers())}}initGradientLayers(t){let{center:n,radius:r}=this.entity,i=this.entity.fillColor??e.DEFAULTS.fillColor,a=this.entity.fillOpacity??e.DEFAULTS.fillOpacity,o=this.parseColor(i);for(let i=0;i<e.GRADIENT_STEPS;i++){let s=1-i/e.GRADIENT_STEPS,c=r*s,l=i/(e.GRADIENT_STEPS-1)*a*t,u=`${this.sourceId}-gradient-${i}`,d=`${this.fillLayerId}-gradient-${i}`,f=me(n,c);this.map.addSource(u,{type:`geojson`,data:{type:`Feature`,geometry:{type:`Polygon`,coordinates:[f]},properties:{}}}),this.map.addLayer({id:d,type:`fill`,source:u,paint:{"fill-color":`rgb(${o.r}, ${o.g}, ${o.b})`,"fill-opacity":l}}),this.gradientSourceIds.push(u),this.gradientLayerIds.push(d)}}parseColor(e){if(e.startsWith(`#`)){let t=e.slice(1);return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}:{r:51,g:136,b:255}}getGeoJSON(){let{center:e,radius:t}=this.entity,n=[{type:`Feature`,geometry:{type:`Polygon`,coordinates:[me(e,t)]},properties:{type:`circle`}},{type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{type:`center`,name:this.entity.name||``,area:this.entity.showArea?A(this.getArea()):``}}];if(this.entity.showRadius){let r=this.entity.radiusAngle??90,i=D(e,t,r),a=[(e[0]+i[0])/2,(e[1]+i[1])/2];n.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[e,i]},properties:{type:`radius-line`}},{type:`Feature`,geometry:{type:`Point`,coordinates:a},properties:{type:`radius-label`,radius:j(t)}})}return{type:`FeatureCollection`,features:n}}getArea(){return Math.PI*this.entity.radius*this.entity.radius}getEntityId(){return this.entity.id}getCenter(){return this.entity.center}getBounds(){let{center:e,radius:t}=this.entity,[n,r]=e,i=t/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r-o],[n+s,r+o]]}getLayerId(){return this.gradientLayerIds.length>0?this.gradientLayerIds[this.gradientLayerIds.length-1]:this.fillLayerId}getLabelLayerId(){return this.entity.name?this.labelLayerId:null}setSelected(t){this.isSelected!==t&&(this.isSelected=t,this.initialized&&(this.map.getLayer(this.strokeLayerId)&&this.map.setPaintProperty(this.strokeLayerId,`line-color`,t?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor),this.map.getLayer(this.labelLayerId)&&(this.map.setPaintProperty(this.labelLayerId,`text-color`,t?this.selectNameStyle.fillColor:this.nameStyle.fillColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-color`,t?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-width`,t?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth))))}isPointInEntity(e){let{center:t,radius:n}=this.entity;return this.calculateDistance(e,t)<=n}calculateDistance(e,t){let[n,r]=e,[i,a]=t,o=(a-r)*Math.PI/180,s=(i-n)*Math.PI/180,c=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}update(t){let n=this.entity;if(this.entity=t,!this.initialized)return;let r=t.confidence??1,i=P(r),a=t.fillType??e.DEFAULTS.fillType,o=n.fillType??e.DEFAULTS.fillType;if(a!==o){this.destroy(),this.initialized=!1,this.gradientLayerIds=[],this.gradientSourceIds=[],this.initLayers();return}if(n.center!==t.center||n.radius!==t.radius||n.name!==t.name||n.showArea!==t.showArea||n.showRadius!==t.showRadius||n.radiusAngle!==t.radiusAngle){let e=this.map.getSource(this.sourceId);if(e&&e.setData(this.getGeoJSON()),a===`radial-gradient`&&this.updateGradientLayers(i),!n.name&&t.name&&!this.map.getLayer(this.labelLayerId)?this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`center`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":i}}):n.name&&!t.name&&this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),!n.showArea&&t.showArea&&!this.map.getLayer(this.areaLayerId)?this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`center`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`bottom`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":i}}):n.showArea&&!t.showArea&&this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),!n.showRadius&&t.showRadius){let e=this.radiusLineStyle;this.map.getLayer(this.radiusLineLayerId)||this.map.addLayer({id:this.radiusLineLayerId,type:`line`,source:this.sourceId,filter:[`==`,[`get`,`type`],`radius-line`],layout:{"line-cap":`round`},paint:{"line-color":e.color,"line-width":e.width,"line-opacity":e.opacity*i,"line-dasharray":e.dashArray}}),this.map.getLayer(this.radiusLabelLayerId)||this.map.addLayer({id:this.radiusLabelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`radius-label`],layout:{"text-field":[`get`,`radius`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0,"text-rotate":[`get`,`textRotation`],"text-rotation-alignment":`map`},paint:{"text-color":this.radiusTextStyle.fillColor,"text-halo-color":this.radiusTextStyle.strokeColor,"text-halo-width":this.radiusTextStyle.strokeWidth,"text-opacity":i}})}else n.showRadius&&!t.showRadius&&(this.map.getLayer(this.radiusLabelLayerId)&&this.map.removeLayer(this.radiusLabelLayerId),this.map.getLayer(this.radiusLineLayerId)&&this.map.removeLayer(this.radiusLineLayerId))}if(a===`solid`?(n.fillColor!==t.fillColor||n.fillOpacity!==t.fillOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.fillLayerId)&&(this.map.setPaintProperty(this.fillLayerId,`fill-color`,t.fillColor??e.DEFAULTS.fillColor),this.map.setPaintProperty(this.fillLayerId,`fill-opacity`,(t.fillOpacity??e.DEFAULTS.fillOpacity)*i)):(n.fillColor!==t.fillColor||n.fillOpacity!==t.fillOpacity||n.confidence!==t.confidence)&&this.updateGradientLayerStyles(i),(n.strokeColor!==t.strokeColor||n.strokeWidth!==t.strokeWidth||n.strokeOpacity!==t.strokeOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.strokeLayerId)&&(this.isSelected||this.map.setPaintProperty(this.strokeLayerId,`line-color`,t.strokeColor??e.DEFAULTS.strokeColor),this.map.setPaintProperty(this.strokeLayerId,`line-width`,t.strokeWidth??e.DEFAULTS.strokeWidth),this.map.setPaintProperty(this.strokeLayerId,`line-opacity`,(t.strokeOpacity??e.DEFAULTS.strokeOpacity)*i)),(n.centerPointColor!==t.centerPointColor||n.centerPointRadius!==t.centerPointRadius||n.fillColor!==t.fillColor||n.confidence!==t.confidence)&&this.map.getLayer(this.centerPointLayerId)&&(this.map.setPaintProperty(this.centerPointLayerId,`circle-color`,t.centerPointColor??t.fillColor??e.DEFAULTS.fillColor),this.map.setPaintProperty(this.centerPointLayerId,`circle-radius`,t.centerPointRadius??e.DEFAULTS.centerPointRadius),this.map.setPaintProperty(this.centerPointLayerId,`circle-opacity`,i)),n.confidence!==t.confidence){if(this.map.getLayer(this.labelLayerId)&&this.map.setPaintProperty(this.labelLayerId,`text-opacity`,i),this.map.getLayer(this.areaLayerId)&&this.map.setPaintProperty(this.areaLayerId,`text-opacity`,i),this.map.getLayer(this.radiusLineLayerId)){let e=this.radiusLineStyle;this.map.setPaintProperty(this.radiusLineLayerId,`line-opacity`,e.opacity*i)}this.map.getLayer(this.radiusLabelLayerId)&&this.map.setPaintProperty(this.radiusLabelLayerId,`text-opacity`,i)}}updateGradientLayers(t){let{center:n,radius:r}=this.entity;for(let t=0;t<this.gradientSourceIds.length;t++){let i=1-t/e.GRADIENT_STEPS,a=r*i,o=me(n,a),s=this.map.getSource(this.gradientSourceIds[t]);s&&s.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[o]},properties:{}})}this.updateGradientLayerStyles(t)}updateGradientLayerStyles(t){let n=this.entity.fillColor??e.DEFAULTS.fillColor,r=this.entity.fillOpacity??e.DEFAULTS.fillOpacity,i=this.parseColor(n);for(let n=0;n<this.gradientLayerIds.length;n++){let a=n/(e.GRADIENT_STEPS-1)*r*t;this.map.getLayer(this.gradientLayerIds[n])&&(this.map.setPaintProperty(this.gradientLayerIds[n],`fill-color`,`rgb(${i.r}, ${i.g}, ${i.b})`),this.map.setPaintProperty(this.gradientLayerIds[n],`fill-opacity`,a))}}static{this.EDGE_BEARINGS=[0,90,180,270]}getEditHandlePositions(t,n){let r=t??this.entity.center,i=n??this.entity.radius,a=[];for(let t=0;t<e.EDGE_BEARINGS.length;t++)a.push({type:`edge`,index:t,position:D(r,i,e.EDGE_BEARINGS[t])});return a.push({type:`move`,index:0,position:r}),a}getEditHandleGeoJSON(e,t){return{type:`FeatureCollection`,features:this.getEditHandlePositions(e,t).map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e.position},properties:{handleType:e.type,index:e.index}}))}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`edge`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e,t){let n=this.map.getSource(this.editSourceId);n&&n.setData(this.getEditHandleGeoJSON(e,t))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,this.initialized&&(e?this.createEditLayers():this.removeEditLayers()))}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.map.project(e),r=this.getEditHandlePositions(),i=r.find(e=>e.type===`move`);if(i){let e=this.map.project(i.position),t=n.x-e.x,r=n.y-e.y;if(t*t+r*r<=144)return{type:`move`,index:i.index,position:i.position}}for(let e of r){if(e.type===`move`)continue;let t=this.map.project(e.position),r=n.x-t.x,i=n.y-t.y;if(r*r+i*i<=100)return{type:e.type,index:e.index,position:e.position}}return null}applyHandleMove(e,t){let n;if(e.type===`move`)n={...this.entity,center:t};else{let e=this.calculateDistance(this.entity.center,t);n={...this.entity,radius:e}}this.entity=n;let r=this.map.getSource(this.sourceId);return r&&r.setData(this.getGeoJSON()),this.refreshEditHandles(),n}updateEditPreview(e,t){let n,r;e.type===`move`?(n=t,r=this.entity.radius):(n=this.entity.center,r=this.calculateDistance(this.entity.center,t));let i=this.entity;this.entity={...this.entity,center:n,radius:r};let a=this.map.getSource(this.sourceId);a&&a.setData(this.getGeoJSON()),this.entity=i,this.refreshEditHandles(n,r)}cancelEditPreview(){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),this.refreshEditHandles()}destroy(){if(this.initialized){this.removeEditLayers(),this.map.getLayer(this.radiusLabelLayerId)&&this.map.removeLayer(this.radiusLabelLayerId),this.map.getLayer(this.radiusLineLayerId)&&this.map.removeLayer(this.radiusLineLayerId),this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.centerPointLayerId)&&this.map.removeLayer(this.centerPointLayerId),this.map.getLayer(this.strokeLayerId)&&this.map.removeLayer(this.strokeLayerId),this.map.getLayer(this.fillLayerId)&&this.map.removeLayer(this.fillLayerId);for(let e of this.gradientLayerIds)this.map.getLayer(e)&&this.map.removeLayer(e);for(let e of this.gradientSourceIds)this.map.getSource(e)&&this.map.removeSource(e);this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId),this.initialized=!1}}};const L={gradientAnimation:`flicker`,animationSpeed:1,fillColor:`#3388ff`,fillOpacity:.6,strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,showCenterPoint:!0,centerPointRadius:4};function ge(e,t){let n=D(e,t,0),r=D(e,t,90),i=D(e,t,180),a=D(e,t,270)[0],o=r[0],s=i[1],c=n[1];return[[a,c],[o,c],[o,s],[a,s]]}var _e=class e extends re{static{this.EDGE_BEARINGS=[0,90,180,270]}constructor(e,t,n,r,i,a){super(e,t,`canvas-circle`,n,r,i),this.animationFrameId=null,this.animationTime=0,this.pulsePhase=0,this.isEditing=!1,this.editSourceId=``,this.editHandleLayerId=``,this.editMoveLayerId=``,this.globalCircleConfig=a,this.radiusSourceId=`canvas-circle-radius-source-${String(t.id)}`,this.radiusLineLayerId=`canvas-circle-radius-line-${String(t.id)}`,this.radiusLabelLayerId=`canvas-circle-radius-label-${String(t.id)}`,this.editSourceId=`canvas-circle-edit-source-${String(t.id)}`,this.editHandleLayerId=`canvas-circle-edit-handles-${String(t.id)}`,this.editMoveLayerId=`canvas-circle-edit-move-${String(t.id)}`;let o=ge(t.center,t.radius);this.init(o),this.initRadiusLayer(),t.isAnimating&&this.startAnimation()}getArea(){return Math.PI*this.entity.radius*this.entity.radius}getAreaLabelAnchor(){return{anchor:`bottom`,offset:[0,-.8]}}get radiusTextStyle(){return x(this.entity.circleConfig,this.globalCircleConfig,h)}get radiusLineStyleResolved(){return y(this.entity.circleConfig?.radiusLine,this.globalCircleConfig?.radiusLine,v)}initRadiusLayer(){if(!this.entity.showRadius)return;let{center:e,radius:t}=this.entity,n=this.entity.radiusAngle??90,r=D(e,t,n),i=[(e[0]+r[0])/2,(e[1]+r[1])/2],a=P(this.entity.confidence),o=this.radiusLineStyleResolved;this.map.addSource(this.radiusSourceId,{type:`geojson`,data:{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:[e,r]},properties:{featureType:`line`}},{type:`Feature`,geometry:{type:`Point`,coordinates:i},properties:{featureType:`label`,radius:j(t)}}]}}),this.map.addLayer({id:this.radiusLineLayerId,type:`line`,source:this.radiusSourceId,filter:[`==`,[`get`,`featureType`],`line`],layout:{"line-cap":`round`},paint:{"line-color":o.color,"line-width":o.width,"line-opacity":o.opacity*a,"line-dasharray":o.dashArray}}),this.map.addLayer({id:this.radiusLabelLayerId,type:`symbol`,source:this.radiusSourceId,filter:[`==`,[`get`,`featureType`],`label`],layout:{"text-field":[`get`,`radius`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.radiusTextStyle.fillColor,"text-halo-color":this.radiusTextStyle.strokeColor,"text-halo-width":this.radiusTextStyle.strokeWidth,"text-opacity":a}})}updateRadiusLayer(){if(this.entity.showRadius){let e=this.map.getSource(this.radiusSourceId);if(e){let{center:t,radius:n}=this.entity,r=this.entity.radiusAngle??90,i=D(t,n,r),a=[(t[0]+i[0])/2,(t[1]+i[1])/2];e.setData({type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:[t,i]},properties:{featureType:`line`}},{type:`Feature`,geometry:{type:`Point`,coordinates:a},properties:{featureType:`label`,radius:j(n)}}]})}else this.initRadiusLayer()}else this.map.getLayer(this.radiusLabelLayerId)&&this.map.removeLayer(this.radiusLabelLayerId),this.map.getLayer(this.radiusLineLayerId)&&this.map.removeLayer(this.radiusLineLayerId),this.map.getSource(this.radiusSourceId)&&this.map.removeSource(this.radiusSourceId)}getEntityCenter(){return this.entity.center}getEntityBounds(){let e=ge(this.entity.center,this.entity.radius),t=e[3][0],n=e[3][1],r=e[1][0],i=e[1][1];return[[t,n],[r,i]]}draw(){let e=this.ctx,t=this.entity;switch(e.clearRect(0,0,512,512),e.globalAlpha=P(t.confidence),t.gradientAnimation??L.gradientAnimation){case`static`:this.drawStaticGradient(e);break;case`flicker`:this.drawFlickerGradient(e);break;case`breath`:this.drawBreathGradient(e);break;case`pulse`:this.drawPulseGradient(e);break;default:this.drawStaticGradient(e)}this.drawStroke(e),(t.showCenterPoint??L.showCenterPoint)&&this.drawCenterPoint(e),e.globalAlpha=1}drawStaticGradient(e){let t=this.entity.fillColor??L.fillColor,n=this.entity.fillOpacity??L.fillOpacity,r=e.createRadialGradient(256,256,0,256,256,254),i=this.parseColor(t);r.addColorStop(0,`rgba(${i.r}, ${i.g}, ${i.b}, ${n})`),r.addColorStop(.7,`rgba(${i.r}, ${i.g}, ${i.b}, ${n*.5})`),r.addColorStop(1,`rgba(${i.r}, ${i.g}, ${i.b}, 0)`),e.beginPath(),e.arc(256,256,254,0,Math.PI*2),e.fillStyle=r,e.fill()}drawFlickerGradient(e){let t=this.entity.fillColor??L.fillColor,n=this.entity.fillOpacity??L.fillOpacity,r=this.entity.animationSpeed??L.animationSpeed,i=.5+.5*Math.sin(this.animationTime*r*8),a=n*(.3+.7*i),o=e.createRadialGradient(256,256,0,256,256,254),s=this.parseColor(t);o.addColorStop(0,`rgba(${s.r}, ${s.g}, ${s.b}, ${a})`),o.addColorStop(.7,`rgba(${s.r}, ${s.g}, ${s.b}, ${a*.5})`),o.addColorStop(1,`rgba(${s.r}, ${s.g}, ${s.b}, 0)`),e.beginPath(),e.arc(256,256,254,0,Math.PI*2),e.fillStyle=o,e.fill()}drawBreathGradient(e){let t=this.entity.fillColor??L.fillColor,n=this.entity.fillOpacity??L.fillOpacity,r=this.entity.animationSpeed??L.animationSpeed,i=.5+.5*Math.sin(this.animationTime*r*2),a=n*(.2+.8*i),o=e.createRadialGradient(256,256,0,256,256,254),s=this.parseColor(t);o.addColorStop(0,`rgba(${s.r}, ${s.g}, ${s.b}, ${a})`),o.addColorStop(.7,`rgba(${s.r}, ${s.g}, ${s.b}, ${a*.5})`),o.addColorStop(1,`rgba(${s.r}, ${s.g}, ${s.b}, 0)`),e.beginPath(),e.arc(256,256,254,0,Math.PI*2),e.fillStyle=o,e.fill()}drawPulseGradient(e){let t=this.entity.fillColor??L.fillColor,n=this.entity.fillOpacity??L.fillOpacity,r=this.parseColor(t),i=e.createRadialGradient(256,256,0,256,256,254);i.addColorStop(0,`rgba(${r.r}, ${r.g}, ${r.b}, ${n*.3})`),i.addColorStop(1,`rgba(${r.r}, ${r.g}, ${r.b}, 0)`),e.beginPath(),e.arc(256,256,254,0,Math.PI*2),e.fillStyle=i,e.fill();for(let t=0;t<3;t++){let i=(this.pulsePhase+t/3)%1,a=254*i,o=n*(1-i)*.6;a>0&&o>0&&(e.beginPath(),e.arc(256,256,a,0,Math.PI*2),e.strokeStyle=`rgba(${r.r}, ${r.g}, ${r.b}, ${o})`,e.lineWidth=3,e.stroke())}}drawStroke(e){let t=this.entity.strokeColor??L.strokeColor,n=this.entity.strokeWidth??L.strokeWidth,r=this.entity.strokeOpacity??L.strokeOpacity;n>0&&r>0&&(e.beginPath(),e.arc(256,256,254-n/2,0,Math.PI*2),e.strokeStyle=this.colorWithAlpha(t,r),e.lineWidth=n,e.stroke())}drawCenterPoint(e){let t=this.entity.centerPointColor??this.entity.fillColor??L.fillColor,n=(this.entity.centerPointRadius??L.centerPointRadius)*2;e.beginPath(),e.arc(256,256,n,0,Math.PI*2),e.fillStyle=t,e.fill(),e.strokeStyle=`white`,e.lineWidth=2,e.stroke()}parseColor(e){if(e.startsWith(`#`)){let t=e.slice(1);return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}:{r:51,g:136,b:255}}startAnimation(){if(this.animationFrameId!==null||this.isDestroyed)return;let e=this.entity.animationSpeed??L.animationSpeed,t=performance.now(),n=r=>{if(this.isDestroyed)return;let i=(r-t)/1e3;t=r,this.animationTime+=i,this.pulsePhase+=i*e*.5,this.pulsePhase>=1&&--this.pulsePhase,this.draw(),this.animationFrameId=requestAnimationFrame(n)};this.animationFrameId=requestAnimationFrame(n),this.map.getSource(this.sourceId)?.play()}stopAnimation(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.map.getSource(this.sourceId)?.pause()}update(e){let t=this.entity;if(this.entity=e,t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.radius!==e.radius){let t=ge(e.center,e.radius);this.updateSourceCoordinates(t)}(t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.name!==e.name||t.radius!==e.radius||t.confidence!==e.confidence)&&this.updateLabel(),(t.showArea!==e.showArea||t.radius!==e.radius||t.confidence!==e.confidence)&&this.updateAreaLabel(),(t.showRadius!==e.showRadius||t.radius!==e.radius||t.radiusAngle!==e.radiusAngle||t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.confidence!==e.confidence)&&this.updateRadiusLayer(),t.isAnimating!==e.isAnimating&&(e.isAnimating?this.startAnimation():this.stopAnimation()),e.isAnimating||this.draw()}isPointInEntity(e){let{center:t,radius:n}=this.entity,r=e[0]-t[0],i=e[1]-t[1],a=111320*Math.cos(t[1]*Math.PI/180);return Math.sqrt((r*a)**2+(i*110540)**2)<=n}destroy(){this.removeEditLayers(),this.stopAnimation(),this.map.getLayer(this.radiusLabelLayerId)&&this.map.removeLayer(this.radiusLabelLayerId),this.map.getLayer(this.radiusLineLayerId)&&this.map.removeLayer(this.radiusLineLayerId),this.map.getSource(this.radiusSourceId)&&this.map.removeSource(this.radiusSourceId),super.destroy()}getEditHandlePositions(t,n){let r=t??this.entity.center,i=n??this.entity.radius,a=[];for(let t=0;t<e.EDGE_BEARINGS.length;t++)a.push({type:`edge`,index:t,position:D(r,i,e.EDGE_BEARINGS[t])});return a.push({type:`move`,index:0,position:r}),a}getEditHandleGeoJSON(e,t){return{type:`FeatureCollection`,features:this.getEditHandlePositions(e,t).map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e.position},properties:{handleType:e.type,index:e.index}}))}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`edge`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e,t){let n=this.map.getSource(this.editSourceId);n&&n.setData(this.getEditHandleGeoJSON(e,t))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,e?this.createEditLayers():this.removeEditLayers())}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.map.project(e),r=this.getEditHandlePositions(),i=r.find(e=>e.type===`move`);if(i){let e=this.map.project(i.position),t=n.x-e.x,r=n.y-e.y;if(t*t+r*r<=144)return{type:`move`,index:i.index,position:i.position}}for(let e of r){if(e.type===`move`)continue;let t=this.map.project(e.position),r=n.x-t.x,i=n.y-t.y;if(r*r+i*i<=100)return{type:e.type,index:e.index,position:e.position}}return null}applyHandleMove(e,t){let n;if(e.type===`move`){let r=t[0]-e.position[0],i=t[1]-e.position[1],a=[this.entity.center[0]+r,this.entity.center[1]+i];n={...this.entity,center:a}}else{let e=O(this.entity.center,t);n={...this.entity,radius:e}}this.entity=n;let r=ge(n.center,n.radius);return this.updateSourceCoordinates(r),this.updateLabel(),this.updateAreaLabel(),this.updateRadiusLayer(),this.refreshEditHandles(),n}updateEditPreview(e,t){let n,r;if(e.type===`move`){let i=t[0]-e.position[0],a=t[1]-e.position[1];n=[this.entity.center[0]+i,this.entity.center[1]+a],r=this.entity.radius}else n=this.entity.center,r=O(this.entity.center,t);let i=ge(n,r);this.updateSourceCoordinates(i);let a=this.entity;this.entity={...this.entity,center:n,radius:r},this.updateLabel(),this.entity=a,this.refreshEditHandles(n,r)}cancelEditPreview(){let e=ge(this.entity.center,this.entity.radius);this.updateSourceCoordinates(e),this.updateLabel(),this.refreshEditHandles()}};function ve(e,t){let[n,r]=e,i=t/2/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r+o],[n+s,r+o],[n+s,r-o],[n-s,r-o],[n-s,r+o]]}var ye=class e{static{this.DEFAULTS={strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,fillColor:`#3388ff`,fillOpacity:.2}}constructor(e,t,n,r,i,a){this.isSelected=!1,this.initialized=!1,this.isEditing=!1,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.globalAreaConfig=i,this.globalLengthConfig=a,this.sourceId=`square-source-${t.id}`,this.fillLayerId=`square-fill-${t.id}`,this.strokeLayerId=`square-stroke-${t.id}`,this.labelLayerId=`square-label-${t.id}`,this.areaLayerId=`square-area-${t.id}`,this.lengthLayerId=`square-length-${t.id}`,this.editSourceId=`square-edit-source-${t.id}`,this.editHandleLayerId=`square-edit-handles-${t.id}`,this.editMoveLayerId=`square-edit-move-${t.id}`,this.initLayers()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get areaStyle(){return x(this.entity.areaConfig,this.globalAreaConfig,_)}get lengthStyle(){return x(this.entity.lengthConfig,this.globalLengthConfig,b)}initLayers(){if(!this.initialized)try{let t=this.getGeoJSON();this.map.addSource(this.sourceId,{type:`geojson`,data:t});let n=this.entity.confidence??1,r=P(n);this.map.addLayer({id:this.fillLayerId,type:`fill`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],paint:{"fill-color":this.entity.fillColor??e.DEFAULTS.fillColor,"fill-opacity":(this.entity.fillOpacity??e.DEFAULTS.fillOpacity)*r}}),this.map.addLayer({id:this.strokeLayerId,type:`line`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],layout:{"line-join":`miter`,"line-cap":`square`},paint:{"line-color":this.isSelected?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor,"line-width":this.entity.strokeWidth??e.DEFAULTS.strokeWidth,"line-opacity":(this.entity.strokeOpacity??e.DEFAULTS.strokeOpacity)*r}}),this.entity.name&&this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":r}}),this.entity.showArea&&this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":r}}),this.entity.showLength&&this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[.8,0],"text-allow-overlap":!0,"text-rotate":[`get`,`textRotation`],"text-rotation-alignment":`map`},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":r}}),this.initialized=!0}catch{this.map.once(`idle`,()=>this.initLayers())}}getGeoJSON(){let{center:e,length:t}=this.entity,n=ve(e,t),r=[{type:`Feature`,geometry:{type:`Polygon`,coordinates:[n]},properties:{}}];if(this.entity.name){let e=this.getBottomCenterPoint(n);r.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{pointType:`label`,name:this.entity.name}})}if(this.entity.showArea&&r.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{pointType:`area`,area:A(this.getArea())}}),this.entity.showLength){let e=n[1],t=n[2],i=[(e[0]+t[0])/2,(e[1]+t[1])/2],a=O(e,t);r.push({type:`Feature`,geometry:{type:`Point`,coordinates:i},properties:{pointType:`length`,length:j(a),textRotation:0}})}return{type:`FeatureCollection`,features:r}}getBottomCenterPoint(e){let t=e[2],n=e[3];return[(t[0]+n[0])/2,(t[1]+n[1])/2]}getArea(){return this.entity.length*this.entity.length}getEntityId(){return this.entity.id}getCenter(){return this.entity.center}getBounds(){let{center:e,length:t}=this.entity,[n,r]=e,i=t/2/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r-o],[n+s,r+o]]}getLayerId(){return this.fillLayerId}getLabelLayerId(){return this.entity.name?this.labelLayerId:null}setSelected(t){this.isSelected!==t&&(this.isSelected=t,this.initialized&&(this.map.getLayer(this.strokeLayerId)&&this.map.setPaintProperty(this.strokeLayerId,`line-color`,t?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor),this.map.getLayer(this.labelLayerId)&&(this.map.setPaintProperty(this.labelLayerId,`text-color`,t?this.selectNameStyle.fillColor:this.nameStyle.fillColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-color`,t?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-width`,t?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth))))}isPointInEntity(e){let{center:t,length:n}=this.entity,r=ve(t,n);return this.pointInPolygon(e,r)}pointInPolygon(e,t){let[n,r]=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let[o,s]=t[e],[c,l]=t[a];s>r!=l>r&&n<(c-o)*(r-s)/(l-s)+o&&(i=!i)}return i}update(t){let n=this.entity;if(this.entity=t,!this.initialized)return;let r=t.confidence??1,i=P(r);if(n.center!==t.center||n.length!==t.length||n.name!==t.name||n.showArea!==t.showArea||n.showLength!==t.showLength){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),!n.name&&t.name&&!this.map.getLayer(this.labelLayerId)?this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":i}}):n.name&&!t.name&&this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),!n.showArea&&t.showArea&&!this.map.getLayer(this.areaLayerId)?this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":i}}):n.showArea&&!t.showArea&&this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),!n.showLength&&t.showLength&&!this.map.getLayer(this.lengthLayerId)?this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[.8,0],"text-allow-overlap":!0,"text-rotate":[`get`,`textRotation`],"text-rotation-alignment":`map`},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":i}}):n.showLength&&!t.showLength&&this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId)}(n.fillColor!==t.fillColor||n.fillOpacity!==t.fillOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.fillLayerId)&&(this.map.setPaintProperty(this.fillLayerId,`fill-color`,t.fillColor??e.DEFAULTS.fillColor),this.map.setPaintProperty(this.fillLayerId,`fill-opacity`,(t.fillOpacity??e.DEFAULTS.fillOpacity)*i)),(n.strokeColor!==t.strokeColor||n.strokeWidth!==t.strokeWidth||n.strokeOpacity!==t.strokeOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.strokeLayerId)&&(this.isSelected||this.map.setPaintProperty(this.strokeLayerId,`line-color`,t.strokeColor??e.DEFAULTS.strokeColor),this.map.setPaintProperty(this.strokeLayerId,`line-width`,t.strokeWidth??e.DEFAULTS.strokeWidth),this.map.setPaintProperty(this.strokeLayerId,`line-opacity`,(t.strokeOpacity??e.DEFAULTS.strokeOpacity)*i)),n.confidence!==t.confidence&&(this.map.getLayer(this.labelLayerId)&&this.map.setPaintProperty(this.labelLayerId,`text-opacity`,i),this.map.getLayer(this.areaLayerId)&&this.map.setPaintProperty(this.areaLayerId,`text-opacity`,i),this.map.getLayer(this.lengthLayerId)&&this.map.setPaintProperty(this.lengthLayerId,`text-opacity`,i))}getCorners(e,t){return ve(e??this.entity.center,t??this.entity.length).slice(0,4)}getEditHandleGeoJSON(e,t){let n=this.getCorners(e,t).map((e,t)=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{handleType:`vertex`,index:t}})),r=e??this.entity.center;return n.push({type:`Feature`,geometry:{type:`Point`,coordinates:r},properties:{handleType:`move`,index:0}}),{type:`FeatureCollection`,features:n}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`vertex`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e,t){let n=this.map.getSource(this.editSourceId);n&&n.setData(this.getEditHandleGeoJSON(e,t))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,this.initialized&&(e?this.createEditLayers():this.removeEditLayers()))}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.getCorners(),r=this.map.project(e),i=this.entity.center,a=this.map.project(i),o=r.x-a.x,s=r.y-a.y;if(o*o+s*s<=144)return{type:`move`,index:0,position:i};for(let e=0;e<n.length;e++){let t=this.map.project(n[e]),i=r.x-t.x,a=r.y-t.y;if(i*i+a*a<=100)return{type:`vertex`,index:e,position:n[e]}}return null}computeNewLength(e){return O(this.entity.center,e)*Math.SQRT2}applyHandleMove(e,t){let n;if(e.type===`move`){let r=t[0]-e.position[0],i=t[1]-e.position[1],a=[this.entity.center[0]+r,this.entity.center[1]+i];n={...this.entity,center:a}}else{let e=this.computeNewLength(t);n={...this.entity,length:e}}this.entity=n;let r=this.map.getSource(this.sourceId);return r&&r.setData(this.getGeoJSON()),this.refreshEditHandles(),n}updateEditPreview(e,t){let n,r;if(e.type===`move`){let i=t[0]-e.position[0],a=t[1]-e.position[1];n=[this.entity.center[0]+i,this.entity.center[1]+a],r=this.entity.length}else n=this.entity.center,r=this.computeNewLength(t);let i=this.entity;this.entity={...this.entity,center:n,length:r};let a=this.map.getSource(this.sourceId);a&&a.setData(this.getGeoJSON()),this.entity=i,this.refreshEditHandles(n,r)}cancelEditPreview(){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),this.refreshEditHandles()}destroy(){this.initialized&&=(this.removeEditLayers(),this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId),this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.strokeLayerId)&&this.map.removeLayer(this.strokeLayerId),this.map.getLayer(this.fillLayerId)&&this.map.removeLayer(this.fillLayerId),this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId),!1)}};function be(e){let[[t,n],[r,i]]=e,a=Math.min(t,r),o=Math.max(t,r),s=Math.min(n,i),c=Math.max(n,i);return[[a,c],[o,c],[o,s],[a,s],[a,c]]}var xe=class e{static{this.DEFAULTS={strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,fillColor:`#3388ff`,fillOpacity:.2}}constructor(e,t,n,r,i,a){this.isSelected=!1,this.initialized=!1,this.isEditing=!1,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.globalAreaConfig=i,this.globalLengthConfig=a,this.sourceId=`rectangle-source-${t.id}`,this.fillLayerId=`rectangle-fill-${t.id}`,this.strokeLayerId=`rectangle-stroke-${t.id}`,this.labelLayerId=`rectangle-label-${t.id}`,this.areaLayerId=`rectangle-area-${t.id}`,this.lengthLayerId=`rectangle-length-${t.id}`,this.editSourceId=`rectangle-edit-source-${t.id}`,this.editHandleLayerId=`rectangle-edit-handles-${t.id}`,this.editMoveLayerId=`rectangle-edit-move-${t.id}`,this.initLayers()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get areaStyle(){return x(this.entity.areaConfig,this.globalAreaConfig,_)}get lengthStyle(){return x(this.entity.lengthConfig,this.globalLengthConfig,b)}initLayers(){if(!this.initialized)try{let t=this.getGeoJSON();this.map.addSource(this.sourceId,{type:`geojson`,data:t});let n=this.entity.confidence??1,r=P(n);this.map.addLayer({id:this.fillLayerId,type:`fill`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],paint:{"fill-color":this.entity.fillColor??e.DEFAULTS.fillColor,"fill-opacity":(this.entity.fillOpacity??e.DEFAULTS.fillOpacity)*r}}),this.map.addLayer({id:this.strokeLayerId,type:`line`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],layout:{"line-join":`miter`,"line-cap":`square`},paint:{"line-color":this.isSelected?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor,"line-width":this.entity.strokeWidth??e.DEFAULTS.strokeWidth,"line-opacity":(this.entity.strokeOpacity??e.DEFAULTS.strokeOpacity)*r}}),this.entity.name&&this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":r}}),this.entity.showArea&&this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":r}}),this.entity.showLength&&this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":r}}),this.initialized=!0}catch{this.map.once(`idle`,()=>this.initLayers())}}getGeoJSON(){let{bounds:e}=this.entity,t=be(e),n=[{type:`Feature`,geometry:{type:`Polygon`,coordinates:[t]},properties:{}}];if(this.entity.name){let e=this.getBottomCenterPoint(t);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{pointType:`label`,name:this.entity.name}})}if(this.entity.showArea){let e=this.calculateRectangleCenter();n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{pointType:`area`,area:A(this.getArea())}})}if(this.entity.showLength)for(let[e,r,i]of[[0,1,0],[1,2,0]]){let a=t[e],o=t[r],s=[(a[0]+o[0])/2,(a[1]+o[1])/2],c=O(a,o);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:s},properties:{pointType:`length`,length:j(c),textRotation:i}})}return{type:`FeatureCollection`,features:n}}getBottomCenterPoint(e){let t=e[2],n=e[3];return[(t[0]+n[0])/2,(t[1]+n[1])/2]}getArea(){let e=be(this.entity.bounds);return ee(e)}getEntityId(){return this.entity.id}getBounds(){let[[e,t],[n,r]]=this.entity.bounds,i=Math.min(e,n),a=Math.max(e,n);return[[i,Math.min(t,r)],[a,Math.max(t,r)]]}getCenter(){return this.entity.center?this.entity.center:this.calculateRectangleCenter()}calculateRectangleCenter(){let[[e,t],[n,r]]=this.entity.bounds;return[(e+n)/2,(t+r)/2]}getLayerId(){return this.fillLayerId}getLabelLayerId(){return this.entity.name?this.labelLayerId:null}setSelected(t){this.isSelected!==t&&(this.isSelected=t,this.initialized&&(this.map.getLayer(this.strokeLayerId)&&this.map.setPaintProperty(this.strokeLayerId,`line-color`,t?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor),this.map.getLayer(this.labelLayerId)&&(this.map.setPaintProperty(this.labelLayerId,`text-color`,t?this.selectNameStyle.fillColor:this.nameStyle.fillColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-color`,t?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-width`,t?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth))))}isPointInEntity(e){let{bounds:t}=this.entity,n=be(t);return this.pointInPolygon(e,n)}pointInPolygon(e,t){let[n,r]=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let[o,s]=t[e],[c,l]=t[a];s>r!=l>r&&n<(c-o)*(r-s)/(l-s)+o&&(i=!i)}return i}update(t){let n=this.entity;if(this.entity=t,!this.initialized)return;let r=t.confidence??1,i=P(r);if(n.bounds!==t.bounds||n.name!==t.name||n.showArea!==t.showArea||n.showLength!==t.showLength){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),!n.name&&t.name&&!this.map.getLayer(this.labelLayerId)?this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":i}}):n.name&&!t.name&&this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),!n.showArea&&t.showArea&&!this.map.getLayer(this.areaLayerId)?this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":i}}):n.showArea&&!t.showArea&&this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),!n.showLength&&t.showLength&&!this.map.getLayer(this.lengthLayerId)?this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":i}}):n.showLength&&!t.showLength&&this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId)}(n.fillColor!==t.fillColor||n.fillOpacity!==t.fillOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.fillLayerId)&&(this.map.setPaintProperty(this.fillLayerId,`fill-color`,t.fillColor??e.DEFAULTS.fillColor),this.map.setPaintProperty(this.fillLayerId,`fill-opacity`,(t.fillOpacity??e.DEFAULTS.fillOpacity)*i)),(n.strokeColor!==t.strokeColor||n.strokeWidth!==t.strokeWidth||n.strokeOpacity!==t.strokeOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.strokeLayerId)&&(this.isSelected||this.map.setPaintProperty(this.strokeLayerId,`line-color`,t.strokeColor??e.DEFAULTS.strokeColor),this.map.setPaintProperty(this.strokeLayerId,`line-width`,t.strokeWidth??e.DEFAULTS.strokeWidth),this.map.setPaintProperty(this.strokeLayerId,`line-opacity`,(t.strokeOpacity??e.DEFAULTS.strokeOpacity)*i)),n.confidence!==t.confidence&&(this.map.getLayer(this.labelLayerId)&&this.map.setPaintProperty(this.labelLayerId,`text-opacity`,i),this.map.getLayer(this.areaLayerId)&&this.map.setPaintProperty(this.areaLayerId,`text-opacity`,i),this.map.getLayer(this.lengthLayerId)&&this.map.setPaintProperty(this.lengthLayerId,`text-opacity`,i))}getCorners(e){return be(e??this.entity.bounds).slice(0,4)}getEditHandleGeoJSON(e){let t=this.getCorners(e).map((e,t)=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{handleType:`vertex`,index:t}})),n=e??this.entity.bounds,r=(n[0][0]+n[1][0])/2,i=(n[0][1]+n[1][1])/2;return t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[r,i]},properties:{handleType:`move`,index:0}}),{type:`FeatureCollection`,features:t}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`vertex`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e){let t=this.map.getSource(this.editSourceId);t&&t.setData(this.getEditHandleGeoJSON(e))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,this.initialized&&(e?this.createEditLayers():this.removeEditLayers()))}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.getCorners(),r=this.map.project(e),i=this.calculateRectangleCenter(),a=this.map.project(i),o=r.x-a.x,s=r.y-a.y;if(o*o+s*s<=144)return{type:`move`,index:0,position:i};for(let e=0;e<n.length;e++){let t=this.map.project(n[e]),i=r.x-t.x,a=r.y-t.y;if(i*i+a*a<=100)return{type:`vertex`,index:e,position:n[e]}}return null}computeNewBounds(e,t){let n=this.getCorners(),r=(e+2)%4,i=n[r];return[[Math.min(t[0],i[0]),Math.min(t[1],i[1])],[Math.max(t[0],i[0]),Math.max(t[1],i[1])]]}offsetBounds(e,t,n){let r=n[0]-t[0],i=n[1]-t[1];return[[e[0][0]+r,e[0][1]+i],[e[1][0]+r,e[1][1]+i]]}applyHandleMove(e,t){let n;n=e.type===`move`?this.offsetBounds(this.entity.bounds,e.position,t):this.computeNewBounds(e.index,t);let r={...this.entity,bounds:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}updateEditPreview(e,t){let n;n=e.type===`move`?this.offsetBounds(this.entity.bounds,e.position,t):this.computeNewBounds(e.index,t);let r=this.entity;this.entity={...this.entity,bounds:n};let i=this.map.getSource(this.sourceId);i&&i.setData(this.getGeoJSON()),this.entity=r,this.refreshEditHandles(n)}cancelEditPreview(){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),this.refreshEditHandles()}destroy(){this.initialized&&=(this.removeEditLayers(),this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId),this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.strokeLayerId)&&this.map.removeLayer(this.strokeLayerId),this.map.getLayer(this.fillLayerId)&&this.map.removeLayer(this.fillLayerId),this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId),!1)}};const Se=({popupState:e,onClose:t,portalContainer:n,popupRef:r})=>{let i=(0,c.useRef)(null),[a,o]=(0,c.useState)(`entering`),[s,l]=(0,c.useState)(!1),u=(0,c.useRef)(e.position),d=(0,c.useRef)(!1),m=r||i;d.current||(u.current=e.position),(0,c.useEffect)(()=>{let e=setTimeout(()=>{l(!0)},60);return()=>clearTimeout(e)},[]),(0,c.useEffect)(()=>{if(a===`entering`&&s){let e=setTimeout(()=>o(`entered`),50);return()=>clearTimeout(e)}},[a,s]);let h=(0,c.useCallback)(()=>{e.config.animation===`none`?t():(d.current=!0,o(`exiting`),setTimeout(()=>t(),200))},[e.config.animation,t]);(0,c.useEffect)(()=>{if(!e.config.closeOnEscape)return;let t=e=>{e.key===`Escape`&&h()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e.config.closeOnEscape,h]),(0,c.useEffect)(()=>{if(!e.config.closeOnClickOutside)return;let t=e=>{m.current&&!m.current.contains(e.target)&&h()},n=setTimeout(()=>{document.addEventListener(`click`,t,!0)},0);return()=>{clearTimeout(n),document.removeEventListener(`click`,t,!0)}},[e.config.closeOnClickOutside,h,m]);let g=()=>{switch(e.actualPosition){case`top`:return`center bottom`;case`bottom`:return`center top`;case`left`:return`right center`;case`right`:return`left center`;case`center`:default:return`center center`}},_=u.current,v=(0,p.jsxs)(`div`,{ref:m,className:`entity-popup ${s?`entity-popup--${a} animation-${e.config.animation}`:``} ${e.config.className||``}`,style:{position:`fixed`,left:`${_.x}px`,top:`${_.y}px`,maxWidth:e.config.maxWidth,zIndex:e.config.zIndex,pointerEvents:`all`,opacity:s?void 0:0,transformOrigin:g(),...e.config.style},role:`dialog`,"aria-modal":`true`,children:[e.config.showCloseButton&&(0,p.jsx)(`button`,{className:`entity-popup__close`,onClick:h,"aria-label":`Close popup`,children:`×`}),(0,p.jsx)(`div`,{className:`entity-popup__content`,children:e.config.content})]});return(0,f.createPortal)(v,n)};var Ce=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20t='1768373933818'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20p-id='30344'%20width='200'%20height='200'%3e%3cpath%20d='M400.440142%201024h-0.073136a48.781895%2048.781895%200%200%201-45.490763-31.448598L3.383306%2066.061072a48.781895%2048.781895%200%200%201%2062.897196-62.897197l926.563466%20351.419801a48.928168%2048.928168%200%200%201%200.219409%2091.127799L597.761811%20597.688654l-151.904042%20395.082157a48.781895%2048.781895%200%200%201-45.490763%2031.229189zM133.053921%20132.907627l267.678766%20705.691916%20113.87318-296.201913a48.855032%2048.855032%200%200%201%2028.011193-27.938057l296.201913-113.87318-705.765052-267.678766z'%20p-id='30345'%20fill='%23ffffff'%20/%3e%3cscript%20xmlns=''%20/%3e%3c/svg%3e`;function we({map:e,precision:t=6,className:n=``,style:r}){let[i,a]=(0,c.useState)(null),o=(0,c.useCallback)(e=>{a({lng:Number(e.lngLat.lng.toFixed(t)),lat:Number(e.lngLat.lat.toFixed(t))})},[t]);return(0,c.useEffect)(()=>{if(e)return e.on(`mousemove`,o),()=>{e.off(`mousemove`,o)}},[e,o]),i?(0,p.jsxs)(`div`,{className:`mapbox-coordinate-display ${n}`,style:r,children:[(0,p.jsx)(`img`,{src:Ce,alt:`location`,className:`mapbox-coordinate-display__icon`}),(0,p.jsxs)(`div`,{className:`mapbox-coordinate-display__content`,children:[(0,p.jsxs)(`span`,{className:`mapbox-coordinate-display__item`,children:[`经度:`,i.lng]}),(0,p.jsxs)(`span`,{className:`mapbox-coordinate-display__item`,children:[`纬度:`,i.lat]})]})]}):null}var R=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20t='1768374054549'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20p-id='31504'%20width='200'%20height='200'%3e%3cpath%20d='M53.80096%20687.40096l282.79808%20282.79808%20633.6-633.6-282.79808-282.79808-90.39872%2090.39872-28.29824%2028.20096-42.7008%2042.7008-23.5008%2023.5008-63.20128%2063.19616-12.29824%2012.29824-373.20192%20373.30432z%20m282.79808%20212.10112l-212.10112-212.1984%2054.99904-54.99904%20106.10176%20106.10176%2028.29824-28.29824-106.10176-106.10176%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.69184-70.71232%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.70208-70.70208%2042.39872-42.39872%20106.10176%20106.10176%2028.29824-28.29824-106.09664-106.10688%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.70208-70.7072%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.70208-70.70208%2042.7008-42.7008%20106.10176%20106.10176%2028.29824-28.29824-105.99936-106.10176%2054.99904-54.99904%20212.10112%20212.10112L336.59904%20899.50208z'%20fill='%23ffffff'%20p-id='31505'%20/%3e%3cscript%20xmlns=''%20/%3e%3c/svg%3e`;function Te({map:e,maxWidth:t=100,unit:n=`metric`,className:r=``,style:i}){let[a,o]=(0,c.useState)({width:100,label:`100 m`}),s=(0,c.useCallback)(()=>{if(!e)return;let r=e.getZoom(),i=e.getCenter().lat,a=40075016.686/(256*2**r),s=i*Math.PI/180,c=a*Math.cos(s)*t,l,u;if(n===`imperial`){let e=3.2808*c;if(e>5280){let n=e/5280;l=z(n),u=`${l} mi`;let r=l/n;o({width:t*r,label:u})}else{l=z(e),u=`${l} ft`;let n=l/e;o({width:t*n,label:u})}}else if(n===`nautical`){let e=c/1852;l=z(e),u=`${l} nm`;let n=l/e;o({width:t*n,label:u})}else if(c>=1e3){l=z(c/1e3),u=`${l} km`;let e=l/(c/1e3);o({width:t*e,label:u})}else{l=z(c),u=`${l} m`;let e=l/c;o({width:t*e,label:u})}},[e,t,n]);return(0,c.useEffect)(()=>{if(e)return s(),e.on(`move`,s),e.on(`zoom`,s),()=>{e.off(`move`,s),e.off(`zoom`,s)}},[e,s]),(0,p.jsxs)(`div`,{className:`mapbox-scale-control ${r}`,style:i,children:[(0,p.jsxs)(`div`,{className:`mapbox-scale-control__bar-wrapper`,children:[(0,p.jsx)(`img`,{src:R,alt:`scale`,className:`mapbox-scale-control__icon`}),(0,p.jsxs)(`div`,{className:`mapbox-scale-control__bar`,style:{width:`${a.width}px`},children:[(0,p.jsx)(`div`,{className:`mapbox-scale-control__tick mapbox-scale-control__tick--left`}),(0,p.jsx)(`div`,{className:`mapbox-scale-control__tick mapbox-scale-control__tick--right`})]})]}),(0,p.jsx)(`span`,{className:`mapbox-scale-control__label`,children:a.label})]})}function z(e){let t=10**(`${Math.floor(e)}`.length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,t*n}var B=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1768989620222'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5780'%20width='128'%20height='128'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cpath%20d='M938.666667%20602.752a42.666667%2042.666667%200%200%201%2042.368%2037.674667l0.298666%204.992V853.333333a128%20128%200%200%201-120.490666%20127.786667L853.333333%20981.333333h-208.896a42.666667%2042.666667%200%200%201-4.949333-85.034666l4.949333-0.298667H853.333333a42.666667%2042.666667%200%200%200%2042.368-37.674667L896%20853.333333v-207.914666a42.666667%2042.666667%200%200%201%2042.666667-42.666667z%20m-853.333334%203.285333a42.666667%2042.666667%200%200%201%2042.368%2037.674667l0.298667%204.992V853.333333a42.666667%2042.666667%200%200%200%2037.674667%2042.368L170.666667%20896h211.882666a42.666667%2042.666667%200%200%201%204.992%2085.034667L382.549333%20981.333333H170.666667a128%20128%200%200%201-127.786667-120.490666L42.666667%20853.333333v-204.629333a42.666667%2042.666667%200%200%201%2042.666666-42.666667zM381.866667%2042.666667A42.666667%2042.666667%200%200%201%20386.944%20127.701333L381.866667%20128H170.666667a42.666667%2042.666667%200%200%200-42.368%2037.674667L128%20170.666667v216.448a42.666667%2042.666667%200%200%201-85.034667%204.992L42.666667%20387.114667V170.666667A128%20128%200%200%201%20163.157333%2042.88L170.666667%2042.666667h211.2zM853.333333%2042.666667a128%20128%200%200%201%20127.786667%20120.490666L981.333333%20170.666667v216.064a42.666667%2042.666667%200%200%201-85.034666%204.992L896%20386.730667V170.666667a42.666667%2042.666667%200%200%200-37.674667-42.368L853.333333%20128h-214.4a42.666667%2042.666667%200%200%201-4.949333-85.034667L638.933333%2042.666667H853.333333z'%20fill='%23ffffff'%20p-id='5781'%3e%3c/path%3e%3cpath%20d='M512%20512m-128%200a128%20128%200%201%200%20256%200%20128%20128%200%201%200-256%200Z'%20fill='%23ffffff'%20p-id='5782'%3e%3c/path%3e%3c/svg%3e`;function Ee({map:e,initialCenter:t,initialZoom:n,initialPitch:r=0,initialBearing:i=0,className:a=``,style:o,duration:s=1e3}){return(0,p.jsxs)(`button`,{className:`mapbox-control-btn mapbox-reset-view-control ${a}`,onClick:()=>{e&&e.flyTo({center:t,zoom:n,pitch:r,bearing:i,duration:s})},style:o,title:`回到初始位置`,children:[(0,p.jsx)(`img`,{src:B,alt:`home`,className:`mapbox-control-btn__icon`}),(0,p.jsx)(`span`,{children:`复位`})]})}var De=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769487141027'%20class='icon'%20viewBox='0%200%201517%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='2644'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='189.625'%20height='128'%3e%3cpath%20d='M1.68121071-242.12320149h1508.24640296v1508.24640298h-1508.24640296z'%20fill='%23ffffff'%20fill-opacity='0'%20p-id='2645'%3e%3c/path%3e%3cpath%20d='M437.30078846%20170.6624h682.66239999v682.6624H437.30078846z'%20fill='%23ffffff'%20fill-opacity='0'%20p-id='2646'%3e%3c/path%3e%3cpath%20d='M1151.68343834%2040.66710748H373.42829443A81.76345149%2081.76345149%200%200%200%20292.90207634%20121.49379654v784.42363608c0%2040.42218191%2036.92257893%2077.41545989%2080.5262181%2077.4154599h781.6133488a81.76345149%2081.76345149%200%200%200%2080.52621814-80.82668906V121.49379654C1232.08593315%2077.76643404%201195.25172802%2040.66710748%201151.6657636%2040.66710748z%20m-325.39237822%20616.14222197H618.29445458V451.37556451h53.66057906c6.71640976%200%2013.41514477-3.35820487%2020.11387975-6.73408452l97.28189301-100.99359314h134.18679716v208.72127078c-46.96184405%2013.50351858-87.22495312%2053.90802574-97.28189299%20104.4048223z%20m130.7932427-20.23760311c23.50743418%200%2043.65666346%2020.21992834%2043.65666349%2043.76271204a44.50505206%2044.50505206%200%200%201-43.62131391%2043.7803868%2044.50505206%2044.50505206%200%200%201-43.6036392-43.7803868c0-23.54278369%2020.096205-43.76271203%2043.6036392-43.76271204h-0.05302433zM564.63387554%20926.10201142H373.42829443a22.87114272%2022.87114272%200%200%201-16.79102442-6.71640975%2023.04789036%2023.04789036%200%200%201-6.71640975-16.82637394V714.02253578h214.73069002v212.07947564z%20m0-269.31035673H349.92086026V118.13559167c0-10.1453137%2010.05693988-20.2376031%2023.50743417-20.23760309h553.4321645v188.53669194h-147.54891766c-6.69873499%200-13.39747001%203.35820487-20.096205%206.71640977l-97.28189297%2097.653063H460.61789801a26.44144475%2026.44144475%200%200%200-19.08874355%207.79457028%2026.63586714%2026.63586714%200%200%200-7.72387123%2019.1594426c0%2016.80869917%2013.39747001%2026.90098858%2026.81261478%2026.90098857h104.03365227v212.13249995z%20m610.48629795%20245.71454877c0.17674763%206.29221547-2.24469484%2012.37233377-6.68106024%2016.84404869s-10.49880895%206.89315739-16.77334965%206.75175927h-533.42433329v-212.0971504H829.63159021c13.39747001%2057.24855586%2067.07572382%2097.65306301%20127.48806219%2097.653063a128.67227125%20128.67227125%200%200%200%2093.05762473-37.87701612%20129.60903367%20129.60903367%200%200%200%2037.73561801-93.39344522c0-64.00031515-46.96184405-117.8553166-103.98062799-128.00063029v-208.73894554h194.56378599v558.91134088h-3.35820489v-0.05302427z%20m0-616.07152294H980.57406228V97.89798858h171.10937607c13.39747001%200%2023.45440988%2010.07461465%2023.4544099%2023.59580796v164.94088398z'%20fill='%23ffffff'%20p-id='2647'%3e%3c/path%3e%3c/svg%3e`,V=`road-highlight-`,Oe=[{source:`composite`,sourceLayer:`road`},{source:`openmaptiles`,sourceLayer:`transportation`},{source:`maptiler_planet`,sourceLayer:`transportation`}];function ke(e){let t=e.getStyle();if(!t||!t.sources)return null;for(let e of Oe){let n=t.sources[e.source];if(n&&n.type===`vector`)return e}for(let[e,n]of Object.entries(t.sources))if(n.type===`vector`)return{source:e,sourceLayer:`transportation`};return null}function Ae({map:e,highlightWidth:t=3,defaultRoadTypes:n=[],defaultMinWidth:r=0,source:i,sourceLayer:a,classField:o=`class`,className:s=``,style:u}){let[d,f]=(0,c.useState)(!1),[h,g]=(0,c.useState)(n),[_,v]=(0,c.useState)(!1),y=(0,c.useRef)(!1),b=(0,c.useRef)(null),x=(0,c.useRef)(null),S=(0,c.useRef)(null),C=(0,c.useCallback)((e,n,r)=>{if(!e.isStyleLoaded()||!e.getSource(n))return!1;let i=!0;return E.forEach(a=>{let s=`${V}${a.class}`;if(!e.getLayer(s))try{e.addLayer({id:s,type:`line`,source:n,"source-layer":r,filter:[`==`,[`get`,o],a.class],paint:{"line-color":a.color,"line-width":t,"line-opacity":.8},layout:{visibility:`none`}}),console.log(`Added road highlight layer: ${s} (source: ${n}, source-layer: ${r})`)}catch(e){console.error(`Failed to add road highlight layer for ${a.class}:`,e),i=!1}}),i},[t,o]);(0,c.useEffect)(()=>{if(!e)return;let t=()=>{let t=i,n=a;if(!t||!n){let r=ke(e);r&&(console.log(`Auto-detected vector source:`,r),t||=r.source,n||=r.sourceLayer)}t&&n?C(e,t,n)&&(y.current=!0,v(!0)):console.warn(`No vector source found for road highlighting`)};e.isStyleLoaded()?t():e.once(`load`,t);let n=()=>{e.isStyleLoaded()&&t()},r=()=>{y.current||t()};return e.on(`styledata`,n),e.on(`sourcedata`,r),()=>{e.off(`styledata`,n),e.off(`sourcedata`,r)}},[e,i,a,C]),(0,c.useEffect)(()=>{!e||!_||E.forEach(t=>{let n=`${V}${t.class}`;if(e.getLayer(n))try{let r=h.includes(t.class);e.setLayoutProperty(n,`visibility`,r?`visible`:`none`)}catch(e){console.error(`Failed to update layer ${n}:`,e)}})},[e,_,h]),(0,c.useEffect)(()=>{if(!d)return;let e=e=>{b.current&&!b.current.contains(e.target)&&x.current&&!x.current.contains(e.target)&&f(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[d]),(0,c.useEffect)(()=>()=>{e&&e.getStyle()&&E.forEach(t=>{let n=`${V}${t.class}`;if(e.getLayer(n))try{e.removeLayer(n)}catch{}}),S.current&&=(S.current.remove(),null)},[e]);let w=(0,c.useCallback)(e=>E.find(t=>t.class===e)?.label||e,[]),T=(0,c.useCallback)(t=>{if(!e||h.length===0){S.current&&S.current.remove(),e?.getCanvas().style.cursor&&(e.getCanvas().style.cursor=``);return}let n=h.map(e=>`${V}${e}`),r=[[t.point.x-10,t.point.y-10],[t.point.x+10,t.point.y+10]],i=e.queryRenderedFeatures(r,{layers:n.filter(t=>e.getLayer(t))});if(i.length>0){let n=i[0].properties||{},r=t.lngLat,a=n.name||n.name_en||n.name_local||``,o=n.class||``,s=n.type||``,c=n.structure||``,u=n.oneway,d=n.layer,f=n.iso_3166_1||``,p=n.iso_3166_2||``,m=e=>!(e==null||e===``||typeof e==`string`&&e.toLowerCase()===`none`),h=[];m(o)&&h.push(`
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);let l=require(`mapbox-gl`);l=s(l);let u=require(`@turf/turf`);u=s(u);let d=require(`react-dom/client`);d=s(d);let f=require(`react-dom`);f=s(f);let p=require(`react/jsx-runtime`);p=s(p);let m=require(`@arco-design/web-react`);m=s(m);const h={fillColor:`#ffffff`,fillOpacity:1,strokeColor:`rgba(0, 0, 0, 0.8)`,strokeWidth:1,strokeOpacity:1},g={fillColor:`#ffcc00`,fillOpacity:1,strokeColor:`#ff6600`,strokeWidth:2,strokeOpacity:1},_={fillColor:`#ffffff`,fillOpacity:1,strokeColor:`rgba(0, 0, 0, 0.8)`,strokeWidth:1,strokeOpacity:1},v={color:`#ffffff`,width:1,opacity:1,dashArray:[4,4]};function y(e,t,n=v){return{color:e?.color??t?.color??n.color,width:e?.width??t?.width??n.width,opacity:e?.opacity??t?.opacity??n.opacity,dashArray:e?.dashArray??t?.dashArray??n.dashArray}}const b={fillColor:`#ffffff`,fillOpacity:1,strokeColor:`rgba(0, 0, 0, 0.8)`,strokeWidth:1,strokeOpacity:1};function x(e,t,n=h){return{fillColor:e?.fillColor??t?.fillColor??n.fillColor,fillOpacity:e?.fillOpacity??t?.fillOpacity??n.fillOpacity,strokeColor:e?.strokeColor??t?.strokeColor??n.strokeColor,strokeWidth:e?.strokeWidth??t?.strokeWidth??n.strokeWidth,strokeOpacity:e?.strokeOpacity??t?.strokeOpacity??n.strokeOpacity}}function S(e,t){if(!t)return e;let n={...e};return(n.type===`circle`||n.type===`square`||n.type===`rectangle`||n.type===`polygon`)&&n.showArea===void 0&&(n.showArea=t.showArea),(n.type===`square`||n.type===`rectangle`||n.type===`polygon`||n.type===`polyline`)&&n.showLength===void 0&&(n.showLength=t.showLength),n.type===`circle`&&n.showRadius===void 0&&(n.showRadius=t.showRadius),n}const C={blue:{center:`#4285f4`,edge:`#4285f400`,mid:`#1a73e8`},green:{center:`#34a853`,edge:`#34a85300`,mid:`#0d652d`},red:{center:`#ea4335`,edge:`#ea433500`,mid:`#c5221f`},purple:{center:`#9c27b0`,edge:`#9c27b000`,mid:`#6a1b9a`},cyan:{center:`#00bcd4`,edge:`#00bcd400`,mid:`#00838f`},orange:{center:`#ff9800`,edge:`#ff980000`,mid:`#f57c00`}},w={rotationSpeed:1,initialRotation:0,colorScheme:`green`,opacity:70,gradientType:`conical`,showRings:!0,showCenter:!0,showScanLine:!0},T={trigger:`click`,position:`top`,offset:[0,-10],showCloseButton:!0,animation:`fade`,closeOnClickOutside:!0,closeOnEscape:!0,hoverDelay:300,maxWidth:320,zIndex:1e3},E=[{class:`motorway`,label:`高速公路`,color:`#E84E3C`},{class:`trunk`,label:`国道`,color:`#FF8C00`},{class:`primary`,label:`主干道`,color:`#FFD700`},{class:`secondary`,label:`次干道`,color:`#4CAF50`},{class:`tertiary`,label:`三级道路`,color:`#2196F3`},{class:`motorway_link`,label:`高速匝道`,color:`#FF6B6B`},{class:`trunk_link`,label:`国道匝道`,color:`#FFB84D`},{class:`primary_link`,label:`主干道匝道`,color:`#FFE066`},{class:`secondary_link`,label:`次干道匝道`,color:`#66BB6A`},{class:`tertiary_link`,label:`三级道路匝道`,color:`#42A5F5`},{class:`minor`,label:`小路`,color:`#81C784`},{class:`residential`,label:`居民区道路`,color:`#81C784`},{class:`unclassified`,label:`未分类道路`,color:`#9E9E9E`},{class:`service`,label:`服务道路`,color:`#64B5F6`},{class:`track`,label:`土路`,color:`#A1887F`},{class:`path`,label:`小径`,color:`#BCAAA4`}];function D(e,t,n){let r=u.point(e);return u.destination(r,t/1e3,n,{units:`kilometers`}).geometry.coordinates}function O(e,t){return u.distance(u.point(e),u.point(t),{units:`kilometers`})*1e3}function k(e,t){return u.bearing(u.point(e),u.point(t))}function ee(e){let t=u.polygon([e]);return u.area(t)}function A(e){return e>=1e6?`${(e/1e6).toFixed(2)} km²`:`${e.toFixed(0)} m²`}function j(e){return e>=1e3?`${(e/1e3).toFixed(2)} km`:`${e.toFixed(0)} m`}const M=512,te=512/2,ne=512/2-2;function N(e){return e*Math.PI/180}function P(e=1){return .3+Math.max(0,Math.min(1,e))*.7}var re=class{constructor(e,t,n,r,i,a){this.isDestroyed=!1,this.isSelected=!1,this.map=e,this.entity=t,this.entityId=t.id,this.globalNameConfig=r,this.globalSelectNameConfig=i,this.globalAreaConfig=a,this.sourceId=`${n}-source-${String(t.id)}`,this.layerId=`${n}-layer-${String(t.id)}`,this.labelSourceId=`${n}-label-source-${String(t.id)}`,this.labelLayerId=`${n}-label-layer-${String(t.id)}`,this.areaSourceId=`${n}-area-source-${String(t.id)}`,this.areaLayerId=`${n}-area-layer-${String(t.id)}`,this.canvas=document.createElement(`canvas`),this.canvas.width=512,this.canvas.height=512,this.ctx=this.canvas.getContext(`2d`)}init(e){this.draw(),this.map.addSource(this.sourceId,{type:`canvas`,canvas:this.canvas,coordinates:e,animate:!0}),this.map.addLayer({id:this.layerId,type:`raster`,source:this.sourceId,paint:{"raster-fade-duration":0,"raster-opacity":1}}),this.initLabelLayer(),this.initAreaLayer()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get areaStyle(){return x(`areaConfig`in this.entity?this.entity.areaConfig:void 0,this.globalAreaConfig,_)}getAreaLabelAnchor(){return{anchor:`center`,offset:[0,0]}}initLabelLayer(){let e=this.getEntityCenter(),{confidence:t}=this.entity,n=P(t);this.map.addSource(this.labelSourceId,{type:`geojson`,data:{type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{name:this.entity.name||``,selected:this.isSelected,opacity:n}}}),this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.labelSourceId,layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.5],"text-allow-overlap":!0},paint:{"text-opacity":[`get`,`opacity`],"text-color":[`case`,[`get`,`selected`],this.selectNameStyle.fillColor,this.nameStyle.fillColor],"text-halo-color":[`case`,[`get`,`selected`],this.selectNameStyle.strokeColor,this.nameStyle.strokeColor],"text-halo-width":[`case`,[`get`,`selected`],this.selectNameStyle.strokeWidth,this.nameStyle.strokeWidth]}})}initAreaLayer(){if(!(`showArea`in this.entity&&this.entity.showArea)||!this.getArea)return;let e=this.getEntityCenter(),{confidence:t}=this.entity,n=P(t),{anchor:r,offset:i}=this.getAreaLabelAnchor();this.map.addSource(this.areaSourceId,{type:`geojson`,data:{type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{area:A(this.getArea()),opacity:n}}}),this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.areaSourceId,layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":r,"text-offset":i,"text-allow-overlap":!0},paint:{"text-opacity":[`get`,`opacity`],"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth}})}updateLabel(){let e=this.map.getSource(this.labelSourceId);if(!e)return;let t=P(this.entity.confidence);e.setData({type:`Feature`,geometry:{type:`Point`,coordinates:this.getEntityCenter()},properties:{name:this.entity.name||``,selected:this.isSelected,opacity:t}})}updateAreaLabel(){if(`showArea`in this.entity&&this.entity.showArea&&this.getArea){let e=this.map.getSource(this.areaSourceId);if(e){let t=P(this.entity.confidence);e.setData({type:`Feature`,geometry:{type:`Point`,coordinates:this.getEntityCenter()},properties:{area:A(this.getArea()),opacity:t}})}else this.initAreaLayer()}else this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getSource(this.areaSourceId)&&this.map.removeSource(this.areaSourceId)}setSelected(e){this.isSelected!==e&&(this.isSelected=e,this.updateLabel())}colorWithAlpha(e,t){if(e.startsWith(`rgba`))return e;if(e.startsWith(`#`)){let n=e.slice(1),r=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),a=parseInt(n.slice(4,6),16);return`rgba(${r}, ${i}, ${a}, ${t})`}return e.startsWith(`rgb(`)?e.replace(`rgb(`,`rgba(`).replace(`)`,`, ${t})`):e}updateSourceCoordinates(e){this.map.getSource(this.sourceId)?.setCoordinates(e)}getEntityId(){return this.entityId}getCenter(){return this.getEntityCenter()}getBounds(){return this.getEntityBounds()}getLayerId(){return this.layerId}getLabelLayerId(){return this.labelLayerId}destroy(){this.isDestroyed=!0,this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getSource(this.areaSourceId)&&this.map.removeSource(this.areaSourceId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getSource(this.labelSourceId)&&this.map.removeSource(this.labelSourceId),this.map.getLayer(this.layerId)&&this.map.removeLayer(this.layerId),this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId)}},ie=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1775030039452'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='24839'%20data-spm-anchor-id='a313x.search_index.0.i1.78953a81FCkAe0'%20width='64'%20height='64'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cpath%20d='M512%20938.666667l-170.666667-170.666667h341.333334l-170.666667%20170.666667z%20m0-853.333334l170.666667%20170.666667H341.333333l170.666667-170.666667z%20m0%20512a85.333333%2085.333333%200%201%201%200-170.666666%2085.333333%2085.333333%200%200%201%200%20170.666666zM85.333333%20512l170.666667-170.666667v341.333334l-170.666667-170.666667z%20m853.333334%200l-170.666667%20170.666667V341.333333l170.666667%20170.666667z'%20fill='%23ffffff'%20p-id='24840'%3e%3c/path%3e%3c/svg%3e`;const ae=`__edit-move-icon__`;var F=!1;function I(e){if(e.hasImage(`__edit-move-icon__`)||F)return;F=!0;let t=new Image;t.onload=()=>{if(e.hasImage(`__edit-move-icon__`)){F=!1;return}let n=document.createElement(`canvas`);n.width=28,n.height=28;let r=n.getContext(`2d`);r.beginPath(),r.arc(28/2,28/2,28/2,0,Math.PI*2),r.fillStyle=`rgba(51,136,255,0.9)`,r.fill();let i=28*.6,a=(28-i)/2;r.drawImage(t,a,a,i,i);let o=r.getImageData(0,0,28,28);e.addImage(ae,{width:28,height:28,data:new Uint8Array(o.data.buffer)}),F=!1},t.onerror=()=>{F=!1},t.src=ie}function oe(e,t){let n=D(e,t,0),r=D(e,t,90),i=D(e,t,180),a=D(e,t,270)[0],o=r[0],s=i[1],c=n[1];return[[a,c],[o,c],[o,s],[a,s]]}var se=class extends re{constructor(e,t,n,r){super(e,t,`radar`,n,r),this.animationFrameId=null,this.isEditing=!1,this.editSourceId=``,this.editMoveLayerId=``,this.editSourceId=`radar-edit-source-${t.id}`,this.editMoveLayerId=`radar-edit-move-${t.id}`,this.currentRotation=t.initialRotation??w.initialRotation;let i=oe(t.center,t.radius);this.init(i),t.isAnimating&&this.startAnimation()}getEntityCenter(){return this.entity.center}getEntityBounds(){let e=oe(this.entity.center,this.entity.radius),t=e[3][0],n=e[3][1],r=e[1][0],i=e[1][1];return[[t,n],[r,i]]}draw(){let e=this.ctx,t=this.entity;e.clearRect(0,0,512,512),e.globalAlpha=P(t.confidence),this.drawSector(e,t),(t.showRings??w.showRings)&&this.drawRings(e),(t.showScanLine??w.showScanLine)&&this.drawScanLine(e,t),(t.showCenter??w.showCenter)&&this.drawCenterDot(e,t),e.globalAlpha=1}drawSector(e,t){let n=t.colorScheme??w.colorScheme,r=C[n],i=(t.opacity??w.opacity)/100,a=t.sectorAngle,o=N(this.currentRotation-a/2-90),s=N(this.currentRotation+a/2-90),c=e.createRadialGradient(256,256,0,256,256,254);c.addColorStop(0,this.colorWithAlpha(r.center,i)),c.addColorStop(.5,this.colorWithAlpha(r.mid,i*.6)),c.addColorStop(1,this.colorWithAlpha(r.edge,0)),e.beginPath(),e.moveTo(256,256),e.arc(256,256,254,o,s),e.closePath(),e.fillStyle=c,e.fill()}drawRings(e){e.strokeStyle=`rgba(255, 255, 255, 0.2)`,e.lineWidth=2,e.setLineDash([5,5]);for(let t=1;t<=3;t++){let n=254*t/3;e.beginPath(),e.arc(256,256,n,0,Math.PI*2),e.stroke()}e.setLineDash([])}drawScanLine(e,t){let n=t.colorScheme??w.colorScheme,r=C[n],i=N(this.currentRotation-90),a=256+Math.cos(i)*254,o=256+Math.sin(i)*254;e.beginPath(),e.moveTo(256,256),e.lineTo(a,o),e.strokeStyle=r.center,e.lineWidth=2,e.lineCap=`round`,e.globalAlpha=.8,e.stroke(),e.globalAlpha=1}drawCenterDot(e,t){let n=t.colorScheme??w.colorScheme,r=C[n];e.beginPath(),e.arc(256,256,5,0,Math.PI*2),e.fillStyle=r.center,e.fill(),e.strokeStyle=`white`,e.lineWidth=2,e.stroke()}startAnimation(){if(this.animationFrameId!==null||this.isDestroyed)return;let e=()=>{if(this.isDestroyed)return;let t=this.entity.rotationSpeed??w.rotationSpeed;this.currentRotation+=t,this.currentRotation>=360&&(this.currentRotation-=360),this.draw(),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e),this.map.getSource(this.sourceId)?.play()}stopAnimation(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.map.getSource(this.sourceId)?.pause()}update(e){let t=this.entity;if(this.entity=e,t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.radius!==e.radius){let t=oe(e.center,e.radius);this.updateSourceCoordinates(t)}(t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.name!==e.name||t.confidence!==e.confidence)&&this.updateLabel(),t.isAnimating!==e.isAnimating&&(e.isAnimating?this.startAnimation():this.stopAnimation()),e.isAnimating||this.draw()}isPointInEntity(e){let{center:t,radius:n}=this.entity,r=e[0]-t[0],i=e[1]-t[1],a=111320*Math.cos(t[1]*Math.PI/180);return Math.sqrt((r*a)**2+(i*110540)**2)<=n}destroy(){this.removeEditLayers(),this.stopAnimation(),super.destroy()}getEditHandleGeoJSON(e){return{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`Point`,coordinates:e??this.entity.center},properties:{handleType:`move`,index:0}}]}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e){let t=this.map.getSource(this.editSourceId);t&&t.setData(this.getEditHandleGeoJSON(e))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,e?this.createEditLayers():this.removeEditLayers())}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.entity.center,r=this.map.project(e),i=this.map.project(n),a=r.x-i.x,o=r.y-i.y;return a*a+o*o<=144?{type:`move`,index:0,position:n}:null}applyHandleMove(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r],a={...this.entity,center:i};this.entity=a;let o=oe(i,this.entity.radius);return this.updateSourceCoordinates(o),this.updateLabel(),this.refreshEditHandles(),a}updateEditPreview(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r],a=oe(i,this.entity.radius);this.updateSourceCoordinates(a);let o=this.entity;this.entity={...this.entity,center:i},this.updateLabel(),this.entity=o,this.refreshEditHandles(i)}cancelEditPreview(){let e=oe(this.entity.center,this.entity.radius);this.updateSourceCoordinates(e),this.updateLabel(),this.refreshEditHandles()}};function ce(e,t,n){let r=t/2,i=n/2,a=D(e,i,0),o=D(e,r,90),s=D(e,i,180),c=D(e,r,270)[0],l=o[0],u=s[1],d=a[1];return[[c,d],[l,d],[l,u],[c,u]]}var le=class extends re{constructor(e,t,n,r){super(e,t,`image`,n,r),this.loadedImage=null,this.imageLoaded=!1,this.currentSrc=``,this.imageAspectRatio=1,this.isEditing=!1,this.editSourceId=``,this.editMoveLayerId=``,this.editSourceId=`image-edit-source-${t.id}`,this.editMoveLayerId=`image-edit-move-${t.id}`,this.loadImage(t.src,!0)}getSize(){let{width:e}=this.entity,t=e/this.imageAspectRatio;return[e,t]}loadImage(e,t=!1){if(!e){console.warn(`Image src is empty`);return}this.currentSrc=e;let n=new Image;n.crossOrigin=`anonymous`,n.onload=()=>{if(e===this.currentSrc)if(this.loadedImage=n,this.imageLoaded=!0,this.imageAspectRatio=n.naturalWidth/n.naturalHeight,t){let[e,t]=this.getSize(),n=ce(this.entity.center,e,t);this.init(n)}else{let[e,t]=this.getSize(),n=ce(this.entity.center,e,t);this.updateSourceCoordinates(n),this.draw()}},n.onerror=()=>{console.error(`Failed to load image: ${e}`)},n.src=e}getEntityCenter(){return this.entity.center}getEntityBounds(){let[e,t]=this.getSize(),n=ce(this.entity.center,e,t),r=n[3][0],i=n[3][1],a=n[1][0],o=n[1][1];return[[r,i],[a,o]]}initLabelLayer(){let e=this.getEntityCenter(),{name:t,confidence:n}=this.entity,r=P(n);this.map.addSource(this.labelSourceId,{type:`geojson`,data:{type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{name:t||``,selected:this.isSelected,opacity:r}}}),this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.labelSourceId,layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-opacity":[`get`,`opacity`],"text-color":[`case`,[`get`,`selected`],`#ffcc00`,`#ffffff`],"text-halo-color":[`case`,[`get`,`selected`],`#ff6600`,`rgba(0, 0, 0, 0.8)`],"text-halo-width":[`case`,[`get`,`selected`],2,1]}})}draw(){let e=this.ctx;if(e.clearRect(0,0,512,512),!this.imageLoaded||!this.loadedImage)return;e.globalAlpha=P(this.entity.confidence),e.save(),e.translate(256,256);let t=this.entity.rotation??0;t!==0&&e.rotate(N(t)),e.drawImage(this.loadedImage,-508/2,-508/2,508,508),e.restore(),e.globalAlpha=1}update(e){let t=this.entity;if(this.entity=e,t.src!==e.src){this.imageLoaded=!1,this.loadedImage=null,this.loadImage(e.src);return}if(t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.width!==e.width){let[t,n]=this.getSize(),r=ce(e.center,t,n);this.updateSourceCoordinates(r)}(t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.name!==e.name||t.confidence!==e.confidence)&&this.updateLabel(),(t.rotation!==e.rotation||t.confidence!==e.confidence)&&this.draw()}isPointInEntity(e){let{center:t}=this.entity,[n,r]=this.getSize(),i=e[0]-t[0],a=e[1]-t[1],o=111320*Math.cos(t[1]*Math.PI/180),s=Math.abs(i*o),c=Math.abs(a*110540);return s<=n/2&&c<=r/2}getEditHandleGeoJSON(e){return{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`Point`,coordinates:e??this.entity.center},properties:{handleType:`move`,index:0}}]}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e){let t=this.map.getSource(this.editSourceId);t&&t.setData(this.getEditHandleGeoJSON(e))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,e?this.createEditLayers():this.removeEditLayers())}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.entity.center,r=this.map.project(e),i=this.map.project(n),a=r.x-i.x,o=r.y-i.y;return a*a+o*o<=144?{type:`move`,index:0,position:n}:null}applyHandleMove(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r],a={...this.entity,center:i};this.entity=a;let[o,s]=this.getSize(),c=ce(i,o,s);return this.updateSourceCoordinates(c),this.updateLabel(),this.refreshEditHandles(),a}updateEditPreview(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r],[a,o]=this.getSize(),s=ce(i,a,o);this.updateSourceCoordinates(s);let c=this.entity;this.entity={...this.entity,center:i},this.updateLabel(),this.entity=c,this.refreshEditHandles(i)}cancelEditPreview(){let[e,t]=this.getSize(),n=ce(this.entity.center,e,t);this.updateSourceCoordinates(n),this.updateLabel(),this.refreshEditHandles()}destroy(){this.removeEditLayers(),super.destroy()}},ue=class{constructor(e,t,n,r){this.marker=null,this.markerElement=null,this.imageElement=null,this.labelElement=null,this.placeholderElement=null,this.isSelected=!1,this.imageAspectRatio=1,this.imageLoaded=!1,this.destroyed=!1,this.isEditing=!1,this.moveIconElement=null,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.loadImageAndCreateMarker(t.src)}loadImageAndCreateMarker(e){if(!e){console.warn(`Marker src is empty`);return}let t=new Image;t.crossOrigin=`anonymous`,t.onload=()=>{this.destroyed||(this.imageAspectRatio=t.naturalWidth/t.naturalHeight,this.imageLoaded=!0,this.createMarker())},t.onerror=()=>{console.error(`Failed to load marker image: ${e}`)},t.src=e}createMarker(){let{center:e,src:t,width:n,rotation:r=0,anchor:i=`center`,name:a,confidence:o}=this.entity,s=n/this.imageAspectRatio;this.markerElement=document.createElement(`div`),this.markerElement.className=`mapbox-marker-container`,this.markerElement.setAttribute(`data-entity-id`,String(this.entity.id)),this.onBeforeImageCreate(),a&&(this.placeholderElement=document.createElement(`div`),this.placeholderElement.className=`mapbox-marker-placeholder`,this.placeholderElement.textContent=a,this.markerElement.appendChild(this.placeholderElement)),this.imageElement=document.createElement(`img`),this.imageElement.src=t,this.imageElement.style.width=`${n}px`,this.imageElement.style.height=`${s}px`,this.imageElement.style.transform=`rotate(${r}deg)`,this.imageElement.style.opacity=`${P(o)}`,this.imageElement.style.pointerEvents=`auto`,this.markerElement.appendChild(this.imageElement),a&&(this.labelElement=document.createElement(`div`),this.labelElement.className=`mapbox-marker-label`,this.labelElement.textContent=a,this.labelElement.setAttribute(`data-entity-id`,String(this.entity.id)),this.updateLabelStyle(),this.markerElement.appendChild(this.labelElement)),this.marker=new l.default.Marker({element:this.markerElement,anchor:i}).setLngLat(e).addTo(this.map),this.onMarkerCreated()}onBeforeImageCreate(){}onMarkerCreated(){}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}updateLabelStyle(){if(!this.labelElement)return;let{confidence:e}=this.entity,t=P(e),n=this.isSelected?this.selectNameStyle:this.nameStyle;this.labelElement.className=this.isSelected?`mapbox-marker-label mapbox-marker-label--selected`:`mapbox-marker-label`,this.labelElement.style.opacity=`${t}`,this.labelElement.style.color=n.fillColor;let r=n.strokeWidth,i=n.strokeColor;this.labelElement.style.webkitTextStroke=`${r*1.5}px ${i}`,this.labelElement.style.paintOrder=`stroke fill`,this.labelElement.style.textShadow=`none`}getEntityId(){return this.entity.id}getCenter(){return this.entity.center}getBounds(){let{center:e,width:t}=this.entity,n=t/this.imageAspectRatio,r=this.map.getZoom(),i=156543.03392*Math.cos(e[1]*Math.PI/180)/2**r,a=t*i,o=n*i,s=111320*Math.cos(e[1]*Math.PI/180),c=a/2/s,l=o/2/110540;return[[e[0]-c,e[1]-l],[e[0]+c,e[1]+l]]}getLayerId(){return`marker-${this.entity.id}`}getLabelLayerId(){return null}setSelected(e){this.isSelected!==e&&(this.isSelected=e,this.updateLabelStyle())}isPointInEntity(e){if(!this.marker||!this.imageLoaded)return!1;let{center:t,width:n}=this.entity,r=n/this.imageAspectRatio,i=this.map.getZoom(),a=156543.03392*Math.cos(t[1]*Math.PI/180)/2**i,o=n*a,s=r*a,c=e[0]-t[0],l=e[1]-t[1],u=111320*Math.cos(t[1]*Math.PI/180),d=Math.abs(c*u),f=Math.abs(l*110540);return d<=o/2&&f<=s/2}update(e){let t=this.entity;if(this.entity=e,t.src!==e.src){this.destroy(),this.imageLoaded=!1,this.loadImageAndCreateMarker(e.src);return}if(!this.marker||!this.imageElement)return;(t.center[0]!==e.center[0]||t.center[1]!==e.center[1])&&this.marker.setLngLat(e.center);let n=e.width/this.imageAspectRatio,r=e.rotation??0,i=P(e.confidence);(t.width!==e.width||t.rotation!==e.rotation||t.confidence!==e.confidence)&&(this.imageElement.style.width=`${e.width}px`,this.imageElement.style.height=`${n}px`,this.imageElement.style.transform=`rotate(${r}deg)`,this.imageElement.style.opacity=`${i}`),t.name!==e.name&&(e.name&&!this.labelElement?(this.labelElement=document.createElement(`div`),this.labelElement.className=`mapbox-marker-label`,this.labelElement.textContent=e.name,this.updateLabelStyle(),this.markerElement?.appendChild(this.labelElement),this.placeholderElement=document.createElement(`div`),this.placeholderElement.className=`mapbox-marker-placeholder`,this.placeholderElement.textContent=e.name,this.markerElement?.insertBefore(this.placeholderElement,this.markerElement.firstChild)):!e.name&&this.labelElement?(this.labelElement.remove(),this.labelElement=null,this.placeholderElement?.remove(),this.placeholderElement=null):this.labelElement&&(this.labelElement.textContent=e.name||``,this.placeholderElement&&(this.placeholderElement.textContent=e.name||``))),t.confidence!==e.confidence&&this.updateLabelStyle()}destroy(){this.removeMoveIcon(),this.destroyed=!0,this.marker&&=(this.marker.remove(),null),this.markerElement=null,this.imageElement=null,this.labelElement=null,this.placeholderElement=null}createMoveIcon(){if(this.moveIconElement||!this.markerElement)return;let e=document.createElement(`div`);e.className=`mapbox-marker-move-icon`,e.style.cssText=`width:28px;height:28px;border-radius:50%;background:rgba(51,136,255,0.9);display:flex;align-items:center;justify-content:center;cursor:move;position:absolute;left:50%;bottom:0;transform:translate(-50%,100%);pointer-events:none;`;let t=document.createElement(`img`);t.src=ie,t.style.cssText=`width:60%;height:60%;`,e.appendChild(t),this.markerElement.appendChild(e),this.moveIconElement=e}removeMoveIcon(){this.moveIconElement&&=(this.moveIconElement.remove(),null)}setEditing(e){this.isEditing!==e&&(this.isEditing=e,e?this.createMoveIcon():this.removeMoveIcon())}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.map.project(e);if(this.moveIconElement){let t=this.moveIconElement.getBoundingClientRect(),r=this.map.getContainer().getBoundingClientRect(),i=t.left+t.width/2-r.left,a=t.top+t.height/2-r.top,o=n.x-i,s=n.y-a;if(o*o+s*s<=256)return{type:`move`,index:0,position:e}}return null}applyHandleMove(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r],a={...this.entity,center:i};return this.entity=a,this.marker&&this.marker.setLngLat(i),a}updateEditPreview(e,t){let n=t[0]-e.position[0],r=t[1]-e.position[1],i=[this.entity.center[0]+n,this.entity.center[1]+r];this.marker&&this.marker.setLngLat(i)}cancelEditPreview(){this.marker&&this.marker.setLngLat(this.entity.center)}},de=class extends ue{constructor(e,t,n,r){super(e,t,n,r),this.showTrajectory=0,this.showTrajectoryPoints=!1,this.trajInitialized=!1,this.statusElement=null,this.statusRoot=null,this.trajSourceId=`unit-traj-source-${t.id}`,this.trajLayerId=`unit-traj-layer-${t.id}`,this.trajPointsLayerId=`unit-traj-points-layer-${t.id}`,t.showTrajectory&&(this.showTrajectory=t.showTrajectory),this.showTrajectoryPoints=t.showTrajectoryPoints??!1}renderStatus(){return null}onBeforeImageCreate(){this.markerElement&&(this.statusElement=document.createElement(`div`),this.statusElement.className=`mapbox-unit-status`,this.markerElement.appendChild(this.statusElement),this.updateStatusContent())}updateStatusContent(){if(!this.statusElement)return;let e=this.renderStatus();e?(this.statusRoot||=(0,d.createRoot)(this.statusElement),this.statusRoot.render(e),this.statusElement.style.display=`block`):(this.statusRoot&&this.statusRoot.render(null),this.statusElement.style.display=`none`)}refreshStatus(){this.updateStatusContent()}getLayerId(){return`unit-${this.entity.id}`}onMarkerCreated(){this.entity.showTrajectory&&(this.showTrajectory=this.entity.showTrajectory,this.initTrajectoryLayer())}shouldShowTrajectory(){return this.showTrajectory===`all`||typeof this.showTrajectory==`number`&&this.showTrajectory>0}getTrajectoryCount(){let{predicted_traj:e}=this.entity;return!e||e.length===0?0:this.showTrajectory===`all`?e.length:typeof this.showTrajectory==`number`&&this.showTrajectory>0?Math.min(this.showTrajectory,e.length):0}initTrajectoryLayer(){if(this.trajInitialized)return;if(!this.map.isStyleLoaded()){requestAnimationFrame(()=>this.initTrajectoryLayer());return}let e=this.getTrajectoryGeoJSON();this.map.addSource(this.trajSourceId,{type:`geojson`,data:e});let t=this.shouldShowTrajectory()?`visible`:`none`,n=this.shouldShowTrajectory()&&this.showTrajectoryPoints?`visible`:`none`;this.map.addLayer({id:this.trajLayerId,type:`line`,source:this.trajSourceId,layout:{"line-join":`round`,"line-cap":`round`,visibility:t},paint:{"line-color":this.isSelected?`#ffcc00`:`#00ff88`,"line-width":3,"line-opacity":P(this.entity.confidence)*.8,"line-dasharray":[2,2]}}),this.map.addLayer({id:this.trajPointsLayerId,type:`circle`,source:this.trajSourceId,filter:[`==`,`$type`,`Point`],layout:{visibility:n},paint:{"circle-radius":4,"circle-color":this.isSelected?`#ffcc00`:`#00ff88`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":1,"circle-opacity":P(this.entity.confidence)}}),this.trajInitialized=!0}getTrajectoryGeoJSON(){let{predicted_traj:e,center:t}=this.entity,n=this.getTrajectoryCount();if(!e||e.length===0||n===0)return{type:`FeatureCollection`,features:[]};let r=e.slice(0,n),i=[t],a=[];return r.forEach((e,t)=>{let n=[e.lon,e.lat];i.push(n),a.push({type:`Feature`,geometry:{type:`Point`,coordinates:n},properties:{index:t,alt:e.alt}})}),{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:i},properties:{}},...a]}}setShowTrajectory(e){let t=e===`all`||typeof e==`number`&&e>0;if(t&&!this.trajInitialized){this.showTrajectory=e,this.initTrajectoryLayer();return}let n=this.shouldShowTrajectory();if(this.showTrajectory=e,this.trajInitialized){let e=t?`visible`:`none`,r=t&&this.showTrajectoryPoints?`visible`:`none`;this.map.getLayer(this.trajLayerId)&&this.map.setLayoutProperty(this.trajLayerId,`visibility`,e),this.map.getLayer(this.trajPointsLayerId)&&this.map.setLayoutProperty(this.trajPointsLayerId,`visibility`,r),t&&n&&this.updateTrajectoryData()}}getShowTrajectory(){return this.showTrajectory}setShowTrajectoryPoints(e){if(this.showTrajectoryPoints=e,this.trajInitialized&&this.map.getLayer(this.trajPointsLayerId)){let t=this.shouldShowTrajectory()&&e?`visible`:`none`;this.map.setLayoutProperty(this.trajPointsLayerId,`visibility`,t)}}getShowTrajectoryPoints(){return this.showTrajectoryPoints}setSelected(e){let t=this.isSelected;super.setSelected(e),t!==e&&this.trajInitialized&&this.updateTrajectoryStyle()}updateTrajectoryStyle(){let e=this.isSelected?`#ffcc00`:`#00ff88`,t=P(this.entity.confidence);this.map.getLayer(this.trajLayerId)&&(this.map.setPaintProperty(this.trajLayerId,`line-color`,e),this.map.setPaintProperty(this.trajLayerId,`line-opacity`,t*.8)),this.map.getLayer(this.trajPointsLayerId)&&(this.map.setPaintProperty(this.trajPointsLayerId,`circle-color`,e),this.map.setPaintProperty(this.trajPointsLayerId,`circle-opacity`,t))}updateTrajectoryData(){if(!this.trajInitialized)return;let e=this.map.getSource(this.trajSourceId);e&&e.setData(this.getTrajectoryGeoJSON())}update(e){let t=this.entity;super.update(e),t.showTrajectory!==e.showTrajectory&&this.setShowTrajectory(e.showTrajectory??0),t.showTrajectoryPoints!==e.showTrajectoryPoints&&this.setShowTrajectoryPoints(e.showTrajectoryPoints??!1),this.updateTrajectoryData(),t.confidence!==e.confidence&&this.updateTrajectoryStyle()}destroy(){this.statusRoot&&=(this.statusRoot.unmount(),null),this.statusElement=null,this.trajInitialized&&(this.map.getLayer(this.trajPointsLayerId)&&this.map.removeLayer(this.trajPointsLayerId),this.map.getLayer(this.trajLayerId)&&this.map.removeLayer(this.trajLayerId),this.map.getSource(this.trajSourceId)&&this.map.removeSource(this.trajSourceId)),super.destroy()}},fe=class e{static{this.DEFAULTS={strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,fillColor:`#3388ff`,fillOpacity:.2}}constructor(e,t,n,r,i,a){this.isSelected=!1,this.initialized=!1,this.isEditing=!1,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.globalAreaConfig=i,this.globalLengthConfig=a,this.sourceId=`polygon-source-${t.id}`,this.fillLayerId=`polygon-fill-${t.id}`,this.strokeLayerId=`polygon-stroke-${t.id}`,this.labelLayerId=`polygon-label-${t.id}`,this.areaLayerId=`polygon-area-${t.id}`,this.lengthLayerId=`polygon-length-${t.id}`,this.editSourceId=`polygon-edit-source-${t.id}`,this.editHandleLayerId=`polygon-edit-handles-${t.id}`,this.editMidpointLayerId=`polygon-edit-midpoints-${t.id}`,this.editMoveLayerId=`polygon-edit-move-${t.id}`,this.initLayers()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get areaStyle(){return x(this.entity.areaConfig,this.globalAreaConfig,_)}get lengthStyle(){return x(this.entity.lengthConfig,this.globalLengthConfig,b)}initLayers(){if(!this.initialized)try{let t=this.getGeoJSON();this.map.addSource(this.sourceId,{type:`geojson`,data:t});let n=this.entity.confidence??1,r=P(n);this.map.addLayer({id:this.fillLayerId,type:`fill`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],paint:{"fill-color":this.entity.fillColor??e.DEFAULTS.fillColor,"fill-opacity":(this.entity.fillOpacity??e.DEFAULTS.fillOpacity)*r}}),this.map.addLayer({id:this.strokeLayerId,type:`line`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],layout:{"line-join":`round`,"line-cap":`round`},paint:{"line-color":this.isSelected?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor,"line-width":this.entity.strokeWidth??e.DEFAULTS.strokeWidth,"line-opacity":(this.entity.strokeOpacity??e.DEFAULTS.strokeOpacity)*r}}),this.entity.name&&this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":r}}),this.entity.showArea&&this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":r}}),this.entity.showLength&&this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":r}}),this.initialized=!0}catch{this.map.once(`idle`,()=>this.initLayers())}}getGeoJSON(){let{coordinates:e}=this.entity;if(!e||e.length<3)return{type:`FeatureCollection`,features:[]};let t=[...e];(e[0][0]!==e[e.length-1][0]||e[0][1]!==e[e.length-1][1])&&t.push(e[0]);let n=[{type:`Feature`,geometry:{type:`Polygon`,coordinates:[t]},properties:{}}];if(this.entity.name){let t=this.getBottomPoint(e);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:t},properties:{pointType:`label`,name:this.entity.name}})}if(this.entity.showArea){let e=this.calculateGeometricCenter();n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{pointType:`area`,area:A(this.getArea())}})}if(this.entity.showLength)for(let t=0;t<e.length;t++){let r=e[t],i=e[(t+1)%e.length],a=[(r[0]+i[0])/2,(r[1]+i[1])/2],o=O(r,i);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:a},properties:{pointType:`length`,length:j(o)}})}return{type:`FeatureCollection`,features:n}}getBottomPoint(e){let t=e[0],n=e[0][1];for(let r of e)r[1]<n&&(n=r[1],t=r);return t}getArea(){let{coordinates:e}=this.entity;if(!e||e.length<3)return 0;let t=[...e];return(t[0][0]!==t[t.length-1][0]||t[0][1]!==t[t.length-1][1])&&t.push(t[0]),ee(t)}getEntityId(){return this.entity.id}getBounds(){let{coordinates:e}=this.entity;if(!e||e.length===0){let e=this.getCenter();return[e,e]}let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let a of e)t=Math.min(t,a[0]),n=Math.max(n,a[0]),r=Math.min(r,a[1]),i=Math.max(i,a[1]);return[[t,r],[n,i]]}getCenter(){return this.entity.center?this.entity.center:this.calculateGeometricCenter()}calculateGeometricCenter(){let{coordinates:e}=this.entity;if(!e||e.length===0)return[0,0];let t=0,n=0;for(let r of e)t+=r[0],n+=r[1];return[t/e.length,n/e.length]}getLayerId(){return this.fillLayerId}getLabelLayerId(){return this.entity.name?this.labelLayerId:null}setSelected(t){this.isSelected!==t&&(this.isSelected=t,this.initialized&&(this.map.getLayer(this.strokeLayerId)&&this.map.setPaintProperty(this.strokeLayerId,`line-color`,t?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor),this.map.getLayer(this.labelLayerId)&&(this.map.setPaintProperty(this.labelLayerId,`text-color`,t?this.selectNameStyle.fillColor:this.nameStyle.fillColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-color`,t?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-width`,t?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth))))}isPointInEntity(e){let{coordinates:t}=this.entity;return!t||t.length<3?!1:this.pointInPolygon(e,t)}pointInPolygon(e,t){let[n,r]=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let[o,s]=t[e],[c,l]=t[a];s>r!=l>r&&n<(c-o)*(r-s)/(l-s)+o&&(i=!i)}return i}update(t){let n=this.entity;if(this.entity=t,!this.initialized)return;let r=t.confidence??1,i=P(r);if(n.coordinates!==t.coordinates||n.name!==t.name||n.showArea!==t.showArea||n.showLength!==t.showLength){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),!n.name&&t.name&&!this.map.getLayer(this.labelLayerId)?this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":i}}):n.name&&!t.name&&this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),!n.showArea&&t.showArea&&!this.map.getLayer(this.areaLayerId)?this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":i}}):n.showArea&&!t.showArea&&this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),!n.showLength&&t.showLength&&!this.map.getLayer(this.lengthLayerId)?this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":i}}):n.showLength&&!t.showLength&&this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId)}(n.fillColor!==t.fillColor||n.fillOpacity!==t.fillOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.fillLayerId)&&(this.map.setPaintProperty(this.fillLayerId,`fill-color`,t.fillColor??e.DEFAULTS.fillColor),this.map.setPaintProperty(this.fillLayerId,`fill-opacity`,(t.fillOpacity??e.DEFAULTS.fillOpacity)*i)),(n.strokeColor!==t.strokeColor||n.strokeWidth!==t.strokeWidth||n.strokeOpacity!==t.strokeOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.strokeLayerId)&&(this.isSelected||this.map.setPaintProperty(this.strokeLayerId,`line-color`,t.strokeColor??e.DEFAULTS.strokeColor),this.map.setPaintProperty(this.strokeLayerId,`line-width`,t.strokeWidth??e.DEFAULTS.strokeWidth),this.map.setPaintProperty(this.strokeLayerId,`line-opacity`,(t.strokeOpacity??e.DEFAULTS.strokeOpacity)*i)),n.confidence!==t.confidence&&(this.map.getLayer(this.labelLayerId)&&this.map.setPaintProperty(this.labelLayerId,`text-opacity`,i),this.map.getLayer(this.areaLayerId)&&this.map.setPaintProperty(this.areaLayerId,`text-opacity`,i),this.map.getLayer(this.lengthLayerId)&&this.map.setPaintProperty(this.lengthLayerId,`text-opacity`,i))}getEditHandleGeoJSON(e){let t=e??this.entity.coordinates;if(!t||t.length<3)return{type:`FeatureCollection`,features:[]};let n=[];for(let e=0;e<t.length;e++)n.push({type:`Feature`,geometry:{type:`Point`,coordinates:t[e]},properties:{handleType:`vertex`,index:e}});for(let e=0;e<t.length;e++){let r=t[e],i=t[(e+1)%t.length];n.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(r[0]+i[0])/2,(r[1]+i[1])/2]},properties:{handleType:`midpoint`,index:e}})}let r=0,i=0;for(let e of t)r+=e[0],i+=e[1];return r/=t.length,i/=t.length,n.push({type:`Feature`,geometry:{type:`Point`,coordinates:[r,i]},properties:{handleType:`move`,index:0}}),{type:`FeatureCollection`,features:n}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editMidpointLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`midpoint`],paint:{"circle-radius":4,"circle-color":`#3388ff`,"circle-opacity":.5,"circle-stroke-color":`#3388ff`,"circle-stroke-width":1}}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`vertex`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getLayer(this.editMidpointLayerId)&&this.map.removeLayer(this.editMidpointLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e){let t=this.map.getSource(this.editSourceId);t&&t.setData(this.getEditHandleGeoJSON(e))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,this.initialized&&(e?this.createEditLayers():this.removeEditLayers()))}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.entity.coordinates;if(!n||n.length<3)return null;let r=this.map.project(e),i=0,a=0;for(let e of n)i+=e[0],a+=e[1];i/=n.length,a/=n.length;let o=this.map.project([i,a]),s=r.x-o.x,c=r.y-o.y;if(s*s+c*c<=144)return{type:`move`,index:0,position:[i,a]};for(let e=0;e<n.length;e++){let t=this.map.project(n[e]),i=r.x-t.x,a=r.y-t.y;if(i*i+a*a<=100)return{type:`vertex`,index:e,position:n[e]}}for(let e=0;e<n.length;e++){let t=n[e],i=n[(e+1)%n.length],a=[(t[0]+i[0])/2,(t[1]+i[1])/2],o=this.map.project(a),s=r.x-o.x,c=r.y-o.y;if(s*s+c*c<=100)return{type:`midpoint`,index:e,position:a}}return null}offsetCoordinates(e,t,n){let r=n[0]-t[0],i=n[1]-t[1];return e.map(e=>[e[0]+r,e[1]+i])}applyHandleMove(e,t){let n;e.type===`move`?n=this.offsetCoordinates(this.entity.coordinates,e.position,t):(n=[...this.entity.coordinates],n[e.index]=t);let r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}updateEditPreview(e,t){let n;e.type===`move`?n=this.offsetCoordinates(this.entity.coordinates,e.position,t):(n=[...this.entity.coordinates],n[e.index]=t);let r=this.entity;this.entity={...this.entity,coordinates:n};let i=this.map.getSource(this.sourceId);i&&i.setData(this.getGeoJSON()),this.entity=r,this.refreshEditHandles(n)}cancelEditPreview(){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),this.refreshEditHandles()}deleteVertex(e){let t=this.entity.coordinates;if(!t||t.length<=3)return null;let n=t.filter((t,n)=>n!==e),r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}addVertex(e,t){let n=[...this.entity.coordinates];n.splice(e+1,0,t);let r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}destroy(){this.initialized&&=(this.removeEditLayers(),this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId),this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.strokeLayerId)&&this.map.removeLayer(this.strokeLayerId),this.map.getLayer(this.fillLayerId)&&this.map.removeLayer(this.fillLayerId),this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId),!1)}},pe=class e{static{this.DEFAULTS={strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,lineCap:`round`,lineJoin:`round`}}constructor(e,t,n,r,i){this.isSelected=!1,this.initialized=!1,this.isEditing=!1,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.globalLengthConfig=i,this.sourceId=`polyline-source-${t.id}`,this.lineLayerId=`polyline-stroke-${t.id}`,this.labelLayerId=`polyline-label-${t.id}`,this.lengthLayerId=`polyline-length-${t.id}`,this.editSourceId=`polyline-edit-source-${t.id}`,this.editHandleLayerId=`polyline-edit-handles-${t.id}`,this.editMidpointLayerId=`polyline-edit-midpoints-${t.id}`,this.editMoveLayerId=`polyline-edit-move-${t.id}`,this.initLayers()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get lengthStyle(){return x(this.entity.lengthConfig,this.globalLengthConfig,b)}initLayers(){if(!this.initialized)try{let t=this.getGeoJSON();this.map.addSource(this.sourceId,{type:`geojson`,data:t});let n=this.entity.confidence??1,r=P(n);this.map.addLayer({id:this.lineLayerId,type:`line`,source:this.sourceId,filter:[`==`,`$type`,`LineString`],layout:{"line-join":this.entity.lineJoin??e.DEFAULTS.lineJoin,"line-cap":this.entity.lineCap??e.DEFAULTS.lineCap},paint:{"line-color":this.isSelected?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor,"line-width":this.entity.strokeWidth??e.DEFAULTS.strokeWidth,"line-opacity":(this.entity.strokeOpacity??e.DEFAULTS.strokeOpacity)*r,...this.entity.dashArray?{"line-dasharray":this.entity.dashArray}:{}}}),this.entity.name&&this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":r}}),this.entity.showLength&&this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":r}}),this.initialized=!0}catch{this.map.once(`idle`,()=>this.initLayers())}}getGeoJSON(){let{coordinates:e,name:t}=this.entity;if(!e||e.length<2)return{type:`FeatureCollection`,features:[]};let n=[{type:`Feature`,geometry:{type:`LineString`,coordinates:e},properties:{}}];if(t){let r=this.getMidPoint(e);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:r},properties:{pointType:`label`,name:t}})}if(this.entity.showLength)for(let t=0;t<e.length-1;t++){let r=e[t],i=e[t+1],a=[(r[0]+i[0])/2,(r[1]+i[1])/2],o=O(r,i);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:a},properties:{pointType:`length`,length:j(o)}})}return{type:`FeatureCollection`,features:n}}getMidPoint(e){if(e.length===1)return e[0];let t=Math.floor((e.length-1)/2),n=e[t],r=e[t+1];return[(n[0]+r[0])/2,(n[1]+r[1])/2]}getEntityId(){return this.entity.id}getBounds(){let{coordinates:e}=this.entity;if(!e||e.length===0){let e=this.getCenter();return[e,e]}let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let a of e)t=Math.min(t,a[0]),n=Math.max(n,a[0]),r=Math.min(r,a[1]),i=Math.max(i,a[1]);return[[t,r],[n,i]]}getCenter(){return this.entity.center?this.entity.center:this.calculateGeometricCenter()}calculateGeometricCenter(){let{coordinates:e}=this.entity;if(!e||e.length===0)return[0,0];let t=0,n=0;for(let r of e)t+=r[0],n+=r[1];return[t/e.length,n/e.length]}getLayerId(){return this.lineLayerId}getLabelLayerId(){return this.entity.name?this.labelLayerId:null}setSelected(t){this.isSelected!==t&&(this.isSelected=t,this.initialized&&(this.map.getLayer(this.lineLayerId)&&this.map.setPaintProperty(this.lineLayerId,`line-color`,t?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor),this.map.getLayer(this.labelLayerId)&&(this.map.setPaintProperty(this.labelLayerId,`text-color`,t?this.selectNameStyle.fillColor:this.nameStyle.fillColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-color`,t?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-width`,t?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth))))}isPointInEntity(e){let{coordinates:t}=this.entity;if(!t||t.length<2)return!1;let n=this.getClickThreshold();for(let r=0;r<t.length-1;r++)if(this.pointToSegmentDistance(e,t[r],t[r+1])<n)return!0;return!1}getClickThreshold(){return .001*2**(12-this.map.getZoom())}pointToSegmentDistance(e,t,n){let[r,i]=e,[a,o]=t,[s,c]=n,l=s-a,u=c-o,d=l*l+u*u;if(d===0)return Math.sqrt((r-a)*(r-a)+(i-o)*(i-o));let f=((r-a)*l+(i-o)*u)/d;f=Math.max(0,Math.min(1,f));let p=a+f*l,m=o+f*u;return Math.sqrt((r-p)*(r-p)+(i-m)*(i-m))}update(t){let n=this.entity;if(this.entity=t,!this.initialized)return;let r=t.confidence??1,i=P(r);if(n.coordinates!==t.coordinates||n.name!==t.name||n.showLength!==t.showLength){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),!n.name&&t.name&&!this.map.getLayer(this.labelLayerId)?this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":i}}):n.name&&!t.name&&this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),!n.showLength&&t.showLength&&!this.map.getLayer(this.lengthLayerId)?this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":i}}):n.showLength&&!t.showLength&&this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId)}(n.strokeColor!==t.strokeColor||n.strokeWidth!==t.strokeWidth||n.strokeOpacity!==t.strokeOpacity||n.confidence!==t.confidence||n.dashArray!==t.dashArray)&&this.map.getLayer(this.lineLayerId)&&(this.isSelected||this.map.setPaintProperty(this.lineLayerId,`line-color`,t.strokeColor??e.DEFAULTS.strokeColor),this.map.setPaintProperty(this.lineLayerId,`line-width`,t.strokeWidth??e.DEFAULTS.strokeWidth),this.map.setPaintProperty(this.lineLayerId,`line-opacity`,(t.strokeOpacity??e.DEFAULTS.strokeOpacity)*i),t.dashArray&&this.map.setPaintProperty(this.lineLayerId,`line-dasharray`,t.dashArray)),(n.lineCap!==t.lineCap||n.lineJoin!==t.lineJoin)&&this.map.getLayer(this.lineLayerId)&&(this.map.setLayoutProperty(this.lineLayerId,`line-cap`,t.lineCap??e.DEFAULTS.lineCap),this.map.setLayoutProperty(this.lineLayerId,`line-join`,t.lineJoin??e.DEFAULTS.lineJoin)),n.confidence!==t.confidence&&this.map.getLayer(this.labelLayerId)&&this.map.setPaintProperty(this.labelLayerId,`text-opacity`,i),n.confidence!==t.confidence&&this.map.getLayer(this.lengthLayerId)&&this.map.setPaintProperty(this.lengthLayerId,`text-opacity`,i)}getEditHandleGeoJSON(e){let t=e??this.entity.coordinates;if(!t||t.length<2)return{type:`FeatureCollection`,features:[]};let n=[];for(let e=0;e<t.length;e++)n.push({type:`Feature`,geometry:{type:`Point`,coordinates:t[e]},properties:{handleType:`vertex`,index:e}});for(let e=0;e<t.length-1;e++){let r=t[e],i=t[e+1];n.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(r[0]+i[0])/2,(r[1]+i[1])/2]},properties:{handleType:`midpoint`,index:e}})}let r=0,i=0;for(let e of t)r+=e[0],i+=e[1];return r/=t.length,i/=t.length,n.push({type:`Feature`,geometry:{type:`Point`,coordinates:[r,i]},properties:{handleType:`move`,index:0}}),{type:`FeatureCollection`,features:n}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editMidpointLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`midpoint`],paint:{"circle-radius":4,"circle-color":`#3388ff`,"circle-opacity":.5,"circle-stroke-color":`#3388ff`,"circle-stroke-width":1}}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`vertex`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getLayer(this.editMidpointLayerId)&&this.map.removeLayer(this.editMidpointLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e){let t=this.map.getSource(this.editSourceId);t&&t.setData(this.getEditHandleGeoJSON(e))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,this.initialized&&(e?this.createEditLayers():this.removeEditLayers()))}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.entity.coordinates;if(!n||n.length<2)return null;let r=this.map.project(e),i=0,a=0;for(let e of n)i+=e[0],a+=e[1];i/=n.length,a/=n.length;let o=this.map.project([i,a]),s=r.x-o.x,c=r.y-o.y;if(s*s+c*c<=144)return{type:`move`,index:0,position:[i,a]};for(let e=0;e<n.length;e++){let t=this.map.project(n[e]),i=r.x-t.x,a=r.y-t.y;if(i*i+a*a<=100)return{type:`vertex`,index:e,position:n[e]}}for(let e=0;e<n.length-1;e++){let t=n[e],i=n[e+1],a=[(t[0]+i[0])/2,(t[1]+i[1])/2],o=this.map.project(a),s=r.x-o.x,c=r.y-o.y;if(s*s+c*c<=100)return{type:`midpoint`,index:e,position:a}}return null}offsetCoordinates(e,t,n){let r=n[0]-t[0],i=n[1]-t[1];return e.map(e=>[e[0]+r,e[1]+i])}applyHandleMove(e,t){let n;e.type===`move`?n=this.offsetCoordinates(this.entity.coordinates,e.position,t):(n=[...this.entity.coordinates],n[e.index]=t);let r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}updateEditPreview(e,t){let n;e.type===`move`?n=this.offsetCoordinates(this.entity.coordinates,e.position,t):(n=[...this.entity.coordinates],n[e.index]=t);let r=this.entity;this.entity={...this.entity,coordinates:n};let i=this.map.getSource(this.sourceId);i&&i.setData(this.getGeoJSON()),this.entity=r,this.refreshEditHandles(n)}cancelEditPreview(){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),this.refreshEditHandles()}deleteVertex(e){let t=this.entity.coordinates;if(!t||t.length<=2)return null;let n=t.filter((t,n)=>n!==e),r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}addVertex(e,t){let n=[...this.entity.coordinates];n.splice(e+1,0,t);let r={...this.entity,coordinates:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}destroy(){this.initialized&&=(this.removeEditLayers(),this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.lineLayerId)&&this.map.removeLayer(this.lineLayerId),this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId),!1)}};function me(e,t,n=64){let[r,i]=e,a=[],o=t/6371e3,s=i*Math.PI/180;for(let e=0;e<=n;e++){let t=e/n*2*Math.PI,c=o*Math.cos(t),l=o*Math.sin(t)/Math.cos(s),u=i+c*180/Math.PI,d=r+l*180/Math.PI;a.push([d,u])}return a}var he=class e{static{this.GRADIENT_STEPS=10}static{this.DEFAULTS={strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,fillColor:`#3388ff`,fillOpacity:.2,fillType:`solid`,showCenterPoint:!0,centerPointRadius:4}}constructor(e,t,n,r,i,a){this.isSelected=!1,this.initialized=!1,this.gradientLayerIds=[],this.gradientSourceIds=[],this.isEditing=!1,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.globalAreaConfig=i,this.globalCircleConfig=a,this.sourceId=`circle-source-${t.id}`,this.fillLayerId=`circle-fill-${t.id}`,this.strokeLayerId=`circle-stroke-${t.id}`,this.centerPointLayerId=`circle-center-${t.id}`,this.labelLayerId=`circle-label-${t.id}`,this.areaLayerId=`circle-area-${t.id}`,this.radiusLineLayerId=`circle-radius-line-${t.id}`,this.radiusLabelLayerId=`circle-radius-label-${t.id}`,this.editSourceId=`circle-edit-source-${t.id}`,this.editHandleLayerId=`circle-edit-handles-${t.id}`,this.editMoveLayerId=`circle-edit-move-${t.id}`,this.initLayers()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get areaStyle(){return x(this.entity.areaConfig,this.globalAreaConfig,_)}get radiusTextStyle(){return x(this.entity.circleConfig,this.globalCircleConfig,h)}get radiusLineStyle(){return y(this.entity.circleConfig?.radiusLine,this.globalCircleConfig?.radiusLine,v)}initLayers(){if(!this.initialized)try{let t=this.getGeoJSON();this.map.addSource(this.sourceId,{type:`geojson`,data:t});let n=this.entity.confidence??1,r=P(n);if((this.entity.fillType??e.DEFAULTS.fillType)===`radial-gradient`?this.initGradientLayers(r):this.map.addLayer({id:this.fillLayerId,type:`fill`,source:this.sourceId,filter:[`==`,[`get`,`type`],`circle`],paint:{"fill-color":this.entity.fillColor??e.DEFAULTS.fillColor,"fill-opacity":(this.entity.fillOpacity??e.DEFAULTS.fillOpacity)*r}}),this.map.addLayer({id:this.strokeLayerId,type:`line`,source:this.sourceId,filter:[`==`,[`get`,`type`],`circle`],layout:{"line-join":`round`,"line-cap":`round`},paint:{"line-color":this.isSelected?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor,"line-width":this.entity.strokeWidth??e.DEFAULTS.strokeWidth,"line-opacity":(this.entity.strokeOpacity??e.DEFAULTS.strokeOpacity)*r}}),(this.entity.showCenterPoint??e.DEFAULTS.showCenterPoint)&&this.map.addLayer({id:this.centerPointLayerId,type:`circle`,source:this.sourceId,filter:[`==`,[`get`,`type`],`center`],paint:{"circle-radius":this.entity.centerPointRadius??e.DEFAULTS.centerPointRadius,"circle-color":this.entity.centerPointColor??this.entity.fillColor??e.DEFAULTS.fillColor,"circle-opacity":r,"circle-stroke-width":1,"circle-stroke-color":`#ffffff`,"circle-stroke-opacity":r*.8}}),this.entity.name&&this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`center`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":r}}),this.entity.showArea&&this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`center`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`bottom`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":r}}),this.entity.showRadius){let e=this.radiusLineStyle;this.map.addLayer({id:this.radiusLineLayerId,type:`line`,source:this.sourceId,filter:[`==`,[`get`,`type`],`radius-line`],layout:{"line-cap":`round`},paint:{"line-color":e.color,"line-width":e.width,"line-opacity":e.opacity*r,"line-dasharray":e.dashArray}}),this.map.addLayer({id:this.radiusLabelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`radius-label`],layout:{"text-field":[`get`,`radius`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.radiusTextStyle.fillColor,"text-halo-color":this.radiusTextStyle.strokeColor,"text-halo-width":this.radiusTextStyle.strokeWidth,"text-opacity":r}})}this.initialized=!0}catch{this.map.once(`idle`,()=>this.initLayers())}}initGradientLayers(t){let{center:n,radius:r}=this.entity,i=this.entity.fillColor??e.DEFAULTS.fillColor,a=this.entity.fillOpacity??e.DEFAULTS.fillOpacity,o=this.parseColor(i);for(let i=0;i<e.GRADIENT_STEPS;i++){let s=1-i/e.GRADIENT_STEPS,c=r*s,l=i/(e.GRADIENT_STEPS-1)*a*t,u=`${this.sourceId}-gradient-${i}`,d=`${this.fillLayerId}-gradient-${i}`,f=me(n,c);this.map.addSource(u,{type:`geojson`,data:{type:`Feature`,geometry:{type:`Polygon`,coordinates:[f]},properties:{}}}),this.map.addLayer({id:d,type:`fill`,source:u,paint:{"fill-color":`rgb(${o.r}, ${o.g}, ${o.b})`,"fill-opacity":l}}),this.gradientSourceIds.push(u),this.gradientLayerIds.push(d)}}parseColor(e){if(e.startsWith(`#`)){let t=e.slice(1);return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}:{r:51,g:136,b:255}}getGeoJSON(){let{center:e,radius:t}=this.entity,n=[{type:`Feature`,geometry:{type:`Polygon`,coordinates:[me(e,t)]},properties:{type:`circle`}},{type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{type:`center`,name:this.entity.name||``,area:this.entity.showArea?A(this.getArea()):``}}];if(this.entity.showRadius){let r=this.entity.radiusAngle??90,i=D(e,t,r),a=[(e[0]+i[0])/2,(e[1]+i[1])/2];n.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[e,i]},properties:{type:`radius-line`}},{type:`Feature`,geometry:{type:`Point`,coordinates:a},properties:{type:`radius-label`,radius:j(t)}})}return{type:`FeatureCollection`,features:n}}getArea(){return Math.PI*this.entity.radius*this.entity.radius}getEntityId(){return this.entity.id}getCenter(){return this.entity.center}getBounds(){let{center:e,radius:t}=this.entity,[n,r]=e,i=t/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r-o],[n+s,r+o]]}getLayerId(){return this.gradientLayerIds.length>0?this.gradientLayerIds[this.gradientLayerIds.length-1]:this.fillLayerId}getLabelLayerId(){return this.entity.name?this.labelLayerId:null}setSelected(t){this.isSelected!==t&&(this.isSelected=t,this.initialized&&(this.map.getLayer(this.strokeLayerId)&&this.map.setPaintProperty(this.strokeLayerId,`line-color`,t?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor),this.map.getLayer(this.labelLayerId)&&(this.map.setPaintProperty(this.labelLayerId,`text-color`,t?this.selectNameStyle.fillColor:this.nameStyle.fillColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-color`,t?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-width`,t?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth))))}isPointInEntity(e){let{center:t,radius:n}=this.entity;return this.calculateDistance(e,t)<=n}calculateDistance(e,t){let[n,r]=e,[i,a]=t,o=(a-r)*Math.PI/180,s=(i-n)*Math.PI/180,c=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}update(t){let n=this.entity;if(this.entity=t,!this.initialized)return;let r=t.confidence??1,i=P(r),a=t.fillType??e.DEFAULTS.fillType,o=n.fillType??e.DEFAULTS.fillType;if(a!==o){this.destroy(),this.initialized=!1,this.gradientLayerIds=[],this.gradientSourceIds=[],this.initLayers();return}if(n.center!==t.center||n.radius!==t.radius||n.name!==t.name||n.showArea!==t.showArea||n.showRadius!==t.showRadius||n.radiusAngle!==t.radiusAngle){let e=this.map.getSource(this.sourceId);if(e&&e.setData(this.getGeoJSON()),a===`radial-gradient`&&this.updateGradientLayers(i),!n.name&&t.name&&!this.map.getLayer(this.labelLayerId)?this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`center`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":i}}):n.name&&!t.name&&this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),!n.showArea&&t.showArea&&!this.map.getLayer(this.areaLayerId)?this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`center`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`bottom`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":i}}):n.showArea&&!t.showArea&&this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),!n.showRadius&&t.showRadius){let e=this.radiusLineStyle;this.map.getLayer(this.radiusLineLayerId)||this.map.addLayer({id:this.radiusLineLayerId,type:`line`,source:this.sourceId,filter:[`==`,[`get`,`type`],`radius-line`],layout:{"line-cap":`round`},paint:{"line-color":e.color,"line-width":e.width,"line-opacity":e.opacity*i,"line-dasharray":e.dashArray}}),this.map.getLayer(this.radiusLabelLayerId)||this.map.addLayer({id:this.radiusLabelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`type`],`radius-label`],layout:{"text-field":[`get`,`radius`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0,"text-rotate":[`get`,`textRotation`],"text-rotation-alignment":`map`},paint:{"text-color":this.radiusTextStyle.fillColor,"text-halo-color":this.radiusTextStyle.strokeColor,"text-halo-width":this.radiusTextStyle.strokeWidth,"text-opacity":i}})}else n.showRadius&&!t.showRadius&&(this.map.getLayer(this.radiusLabelLayerId)&&this.map.removeLayer(this.radiusLabelLayerId),this.map.getLayer(this.radiusLineLayerId)&&this.map.removeLayer(this.radiusLineLayerId))}if(a===`solid`?(n.fillColor!==t.fillColor||n.fillOpacity!==t.fillOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.fillLayerId)&&(this.map.setPaintProperty(this.fillLayerId,`fill-color`,t.fillColor??e.DEFAULTS.fillColor),this.map.setPaintProperty(this.fillLayerId,`fill-opacity`,(t.fillOpacity??e.DEFAULTS.fillOpacity)*i)):(n.fillColor!==t.fillColor||n.fillOpacity!==t.fillOpacity||n.confidence!==t.confidence)&&this.updateGradientLayerStyles(i),(n.strokeColor!==t.strokeColor||n.strokeWidth!==t.strokeWidth||n.strokeOpacity!==t.strokeOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.strokeLayerId)&&(this.isSelected||this.map.setPaintProperty(this.strokeLayerId,`line-color`,t.strokeColor??e.DEFAULTS.strokeColor),this.map.setPaintProperty(this.strokeLayerId,`line-width`,t.strokeWidth??e.DEFAULTS.strokeWidth),this.map.setPaintProperty(this.strokeLayerId,`line-opacity`,(t.strokeOpacity??e.DEFAULTS.strokeOpacity)*i)),(n.centerPointColor!==t.centerPointColor||n.centerPointRadius!==t.centerPointRadius||n.fillColor!==t.fillColor||n.confidence!==t.confidence)&&this.map.getLayer(this.centerPointLayerId)&&(this.map.setPaintProperty(this.centerPointLayerId,`circle-color`,t.centerPointColor??t.fillColor??e.DEFAULTS.fillColor),this.map.setPaintProperty(this.centerPointLayerId,`circle-radius`,t.centerPointRadius??e.DEFAULTS.centerPointRadius),this.map.setPaintProperty(this.centerPointLayerId,`circle-opacity`,i)),n.confidence!==t.confidence){if(this.map.getLayer(this.labelLayerId)&&this.map.setPaintProperty(this.labelLayerId,`text-opacity`,i),this.map.getLayer(this.areaLayerId)&&this.map.setPaintProperty(this.areaLayerId,`text-opacity`,i),this.map.getLayer(this.radiusLineLayerId)){let e=this.radiusLineStyle;this.map.setPaintProperty(this.radiusLineLayerId,`line-opacity`,e.opacity*i)}this.map.getLayer(this.radiusLabelLayerId)&&this.map.setPaintProperty(this.radiusLabelLayerId,`text-opacity`,i)}}updateGradientLayers(t){let{center:n,radius:r}=this.entity;for(let t=0;t<this.gradientSourceIds.length;t++){let i=1-t/e.GRADIENT_STEPS,a=r*i,o=me(n,a),s=this.map.getSource(this.gradientSourceIds[t]);s&&s.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[o]},properties:{}})}this.updateGradientLayerStyles(t)}updateGradientLayerStyles(t){let n=this.entity.fillColor??e.DEFAULTS.fillColor,r=this.entity.fillOpacity??e.DEFAULTS.fillOpacity,i=this.parseColor(n);for(let n=0;n<this.gradientLayerIds.length;n++){let a=n/(e.GRADIENT_STEPS-1)*r*t;this.map.getLayer(this.gradientLayerIds[n])&&(this.map.setPaintProperty(this.gradientLayerIds[n],`fill-color`,`rgb(${i.r}, ${i.g}, ${i.b})`),this.map.setPaintProperty(this.gradientLayerIds[n],`fill-opacity`,a))}}static{this.EDGE_BEARINGS=[0,90,180,270]}getEditHandlePositions(t,n){let r=t??this.entity.center,i=n??this.entity.radius,a=[];for(let t=0;t<e.EDGE_BEARINGS.length;t++)a.push({type:`edge`,index:t,position:D(r,i,e.EDGE_BEARINGS[t])});return a.push({type:`move`,index:0,position:r}),a}getEditHandleGeoJSON(e,t){return{type:`FeatureCollection`,features:this.getEditHandlePositions(e,t).map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e.position},properties:{handleType:e.type,index:e.index}}))}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`edge`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e,t){let n=this.map.getSource(this.editSourceId);n&&n.setData(this.getEditHandleGeoJSON(e,t))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,this.initialized&&(e?this.createEditLayers():this.removeEditLayers()))}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.map.project(e),r=this.getEditHandlePositions(),i=r.find(e=>e.type===`move`);if(i){let e=this.map.project(i.position),t=n.x-e.x,r=n.y-e.y;if(t*t+r*r<=144)return{type:`move`,index:i.index,position:i.position}}for(let e of r){if(e.type===`move`)continue;let t=this.map.project(e.position),r=n.x-t.x,i=n.y-t.y;if(r*r+i*i<=100)return{type:e.type,index:e.index,position:e.position}}return null}applyHandleMove(e,t){let n;if(e.type===`move`)n={...this.entity,center:t};else{let e=this.calculateDistance(this.entity.center,t);n={...this.entity,radius:e}}this.entity=n;let r=this.map.getSource(this.sourceId);return r&&r.setData(this.getGeoJSON()),this.refreshEditHandles(),n}updateEditPreview(e,t){let n,r;e.type===`move`?(n=t,r=this.entity.radius):(n=this.entity.center,r=this.calculateDistance(this.entity.center,t));let i=this.entity;this.entity={...this.entity,center:n,radius:r};let a=this.map.getSource(this.sourceId);a&&a.setData(this.getGeoJSON()),this.entity=i,this.refreshEditHandles(n,r)}cancelEditPreview(){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),this.refreshEditHandles()}destroy(){if(this.initialized){this.removeEditLayers(),this.map.getLayer(this.radiusLabelLayerId)&&this.map.removeLayer(this.radiusLabelLayerId),this.map.getLayer(this.radiusLineLayerId)&&this.map.removeLayer(this.radiusLineLayerId),this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.centerPointLayerId)&&this.map.removeLayer(this.centerPointLayerId),this.map.getLayer(this.strokeLayerId)&&this.map.removeLayer(this.strokeLayerId),this.map.getLayer(this.fillLayerId)&&this.map.removeLayer(this.fillLayerId);for(let e of this.gradientLayerIds)this.map.getLayer(e)&&this.map.removeLayer(e);for(let e of this.gradientSourceIds)this.map.getSource(e)&&this.map.removeSource(e);this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId),this.initialized=!1}}};const L={gradientAnimation:`flicker`,animationSpeed:1,fillColor:`#3388ff`,fillOpacity:.6,strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,showCenterPoint:!0,centerPointRadius:4};function ge(e,t){let n=D(e,t,0),r=D(e,t,90),i=D(e,t,180),a=D(e,t,270)[0],o=r[0],s=i[1],c=n[1];return[[a,c],[o,c],[o,s],[a,s]]}var _e=class e extends re{static{this.EDGE_BEARINGS=[0,90,180,270]}constructor(e,t,n,r,i,a){super(e,t,`canvas-circle`,n,r,i),this.animationFrameId=null,this.animationTime=0,this.pulsePhase=0,this.isEditing=!1,this.editSourceId=``,this.editHandleLayerId=``,this.editMoveLayerId=``,this.globalCircleConfig=a,this.radiusSourceId=`canvas-circle-radius-source-${String(t.id)}`,this.radiusLineLayerId=`canvas-circle-radius-line-${String(t.id)}`,this.radiusLabelLayerId=`canvas-circle-radius-label-${String(t.id)}`,this.editSourceId=`canvas-circle-edit-source-${String(t.id)}`,this.editHandleLayerId=`canvas-circle-edit-handles-${String(t.id)}`,this.editMoveLayerId=`canvas-circle-edit-move-${String(t.id)}`;let o=ge(t.center,t.radius);this.init(o),this.initRadiusLayer(),t.isAnimating&&this.startAnimation()}getArea(){return Math.PI*this.entity.radius*this.entity.radius}getAreaLabelAnchor(){return{anchor:`bottom`,offset:[0,-.8]}}get radiusTextStyle(){return x(this.entity.circleConfig,this.globalCircleConfig,h)}get radiusLineStyleResolved(){return y(this.entity.circleConfig?.radiusLine,this.globalCircleConfig?.radiusLine,v)}initRadiusLayer(){if(!this.entity.showRadius)return;let{center:e,radius:t}=this.entity,n=this.entity.radiusAngle??90,r=D(e,t,n),i=[(e[0]+r[0])/2,(e[1]+r[1])/2],a=P(this.entity.confidence),o=this.radiusLineStyleResolved;this.map.addSource(this.radiusSourceId,{type:`geojson`,data:{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:[e,r]},properties:{featureType:`line`}},{type:`Feature`,geometry:{type:`Point`,coordinates:i},properties:{featureType:`label`,radius:j(t)}}]}}),this.map.addLayer({id:this.radiusLineLayerId,type:`line`,source:this.radiusSourceId,filter:[`==`,[`get`,`featureType`],`line`],layout:{"line-cap":`round`},paint:{"line-color":o.color,"line-width":o.width,"line-opacity":o.opacity*a,"line-dasharray":o.dashArray}}),this.map.addLayer({id:this.radiusLabelLayerId,type:`symbol`,source:this.radiusSourceId,filter:[`==`,[`get`,`featureType`],`label`],layout:{"text-field":[`get`,`radius`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.radiusTextStyle.fillColor,"text-halo-color":this.radiusTextStyle.strokeColor,"text-halo-width":this.radiusTextStyle.strokeWidth,"text-opacity":a}})}updateRadiusLayer(){if(this.entity.showRadius){let e=this.map.getSource(this.radiusSourceId);if(e){let{center:t,radius:n}=this.entity,r=this.entity.radiusAngle??90,i=D(t,n,r),a=[(t[0]+i[0])/2,(t[1]+i[1])/2];e.setData({type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:[t,i]},properties:{featureType:`line`}},{type:`Feature`,geometry:{type:`Point`,coordinates:a},properties:{featureType:`label`,radius:j(n)}}]})}else this.initRadiusLayer()}else this.map.getLayer(this.radiusLabelLayerId)&&this.map.removeLayer(this.radiusLabelLayerId),this.map.getLayer(this.radiusLineLayerId)&&this.map.removeLayer(this.radiusLineLayerId),this.map.getSource(this.radiusSourceId)&&this.map.removeSource(this.radiusSourceId)}getEntityCenter(){return this.entity.center}getEntityBounds(){let e=ge(this.entity.center,this.entity.radius),t=e[3][0],n=e[3][1],r=e[1][0],i=e[1][1];return[[t,n],[r,i]]}draw(){let e=this.ctx,t=this.entity;switch(e.clearRect(0,0,512,512),e.globalAlpha=P(t.confidence),t.gradientAnimation??L.gradientAnimation){case`static`:this.drawStaticGradient(e);break;case`flicker`:this.drawFlickerGradient(e);break;case`breath`:this.drawBreathGradient(e);break;case`pulse`:this.drawPulseGradient(e);break;default:this.drawStaticGradient(e)}this.drawStroke(e),(t.showCenterPoint??L.showCenterPoint)&&this.drawCenterPoint(e),e.globalAlpha=1}drawStaticGradient(e){let t=this.entity.fillColor??L.fillColor,n=this.entity.fillOpacity??L.fillOpacity,r=e.createRadialGradient(256,256,0,256,256,254),i=this.parseColor(t);r.addColorStop(0,`rgba(${i.r}, ${i.g}, ${i.b}, ${n})`),r.addColorStop(.7,`rgba(${i.r}, ${i.g}, ${i.b}, ${n*.5})`),r.addColorStop(1,`rgba(${i.r}, ${i.g}, ${i.b}, 0)`),e.beginPath(),e.arc(256,256,254,0,Math.PI*2),e.fillStyle=r,e.fill()}drawFlickerGradient(e){let t=this.entity.fillColor??L.fillColor,n=this.entity.fillOpacity??L.fillOpacity,r=this.entity.animationSpeed??L.animationSpeed,i=.5+.5*Math.sin(this.animationTime*r*8),a=n*(.3+.7*i),o=e.createRadialGradient(256,256,0,256,256,254),s=this.parseColor(t);o.addColorStop(0,`rgba(${s.r}, ${s.g}, ${s.b}, ${a})`),o.addColorStop(.7,`rgba(${s.r}, ${s.g}, ${s.b}, ${a*.5})`),o.addColorStop(1,`rgba(${s.r}, ${s.g}, ${s.b}, 0)`),e.beginPath(),e.arc(256,256,254,0,Math.PI*2),e.fillStyle=o,e.fill()}drawBreathGradient(e){let t=this.entity.fillColor??L.fillColor,n=this.entity.fillOpacity??L.fillOpacity,r=this.entity.animationSpeed??L.animationSpeed,i=.5+.5*Math.sin(this.animationTime*r*2),a=n*(.2+.8*i),o=e.createRadialGradient(256,256,0,256,256,254),s=this.parseColor(t);o.addColorStop(0,`rgba(${s.r}, ${s.g}, ${s.b}, ${a})`),o.addColorStop(.7,`rgba(${s.r}, ${s.g}, ${s.b}, ${a*.5})`),o.addColorStop(1,`rgba(${s.r}, ${s.g}, ${s.b}, 0)`),e.beginPath(),e.arc(256,256,254,0,Math.PI*2),e.fillStyle=o,e.fill()}drawPulseGradient(e){let t=this.entity.fillColor??L.fillColor,n=this.entity.fillOpacity??L.fillOpacity,r=this.parseColor(t),i=e.createRadialGradient(256,256,0,256,256,254);i.addColorStop(0,`rgba(${r.r}, ${r.g}, ${r.b}, ${n*.3})`),i.addColorStop(1,`rgba(${r.r}, ${r.g}, ${r.b}, 0)`),e.beginPath(),e.arc(256,256,254,0,Math.PI*2),e.fillStyle=i,e.fill();for(let t=0;t<3;t++){let i=(this.pulsePhase+t/3)%1,a=254*i,o=n*(1-i)*.6;a>0&&o>0&&(e.beginPath(),e.arc(256,256,a,0,Math.PI*2),e.strokeStyle=`rgba(${r.r}, ${r.g}, ${r.b}, ${o})`,e.lineWidth=3,e.stroke())}}drawStroke(e){let t=this.entity.strokeColor??L.strokeColor,n=this.entity.strokeWidth??L.strokeWidth,r=this.entity.strokeOpacity??L.strokeOpacity;n>0&&r>0&&(e.beginPath(),e.arc(256,256,254-n/2,0,Math.PI*2),e.strokeStyle=this.colorWithAlpha(t,r),e.lineWidth=n,e.stroke())}drawCenterPoint(e){let t=this.entity.centerPointColor??this.entity.fillColor??L.fillColor,n=(this.entity.centerPointRadius??L.centerPointRadius)*2;e.beginPath(),e.arc(256,256,n,0,Math.PI*2),e.fillStyle=t,e.fill(),e.strokeStyle=`white`,e.lineWidth=2,e.stroke()}parseColor(e){if(e.startsWith(`#`)){let t=e.slice(1);return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}:{r:51,g:136,b:255}}startAnimation(){if(this.animationFrameId!==null||this.isDestroyed)return;let e=this.entity.animationSpeed??L.animationSpeed,t=performance.now(),n=r=>{if(this.isDestroyed)return;let i=(r-t)/1e3;t=r,this.animationTime+=i,this.pulsePhase+=i*e*.5,this.pulsePhase>=1&&--this.pulsePhase,this.draw(),this.animationFrameId=requestAnimationFrame(n)};this.animationFrameId=requestAnimationFrame(n),this.map.getSource(this.sourceId)?.play()}stopAnimation(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.map.getSource(this.sourceId)?.pause()}update(e){let t=this.entity;if(this.entity=e,t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.radius!==e.radius){let t=ge(e.center,e.radius);this.updateSourceCoordinates(t)}(t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.name!==e.name||t.radius!==e.radius||t.confidence!==e.confidence)&&this.updateLabel(),(t.showArea!==e.showArea||t.radius!==e.radius||t.confidence!==e.confidence)&&this.updateAreaLabel(),(t.showRadius!==e.showRadius||t.radius!==e.radius||t.radiusAngle!==e.radiusAngle||t.center[0]!==e.center[0]||t.center[1]!==e.center[1]||t.confidence!==e.confidence)&&this.updateRadiusLayer(),t.isAnimating!==e.isAnimating&&(e.isAnimating?this.startAnimation():this.stopAnimation()),e.isAnimating||this.draw()}isPointInEntity(e){let{center:t,radius:n}=this.entity,r=e[0]-t[0],i=e[1]-t[1],a=111320*Math.cos(t[1]*Math.PI/180);return Math.sqrt((r*a)**2+(i*110540)**2)<=n}destroy(){this.removeEditLayers(),this.stopAnimation(),this.map.getLayer(this.radiusLabelLayerId)&&this.map.removeLayer(this.radiusLabelLayerId),this.map.getLayer(this.radiusLineLayerId)&&this.map.removeLayer(this.radiusLineLayerId),this.map.getSource(this.radiusSourceId)&&this.map.removeSource(this.radiusSourceId),super.destroy()}getEditHandlePositions(t,n){let r=t??this.entity.center,i=n??this.entity.radius,a=[];for(let t=0;t<e.EDGE_BEARINGS.length;t++)a.push({type:`edge`,index:t,position:D(r,i,e.EDGE_BEARINGS[t])});return a.push({type:`move`,index:0,position:r}),a}getEditHandleGeoJSON(e,t){return{type:`FeatureCollection`,features:this.getEditHandlePositions(e,t).map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e.position},properties:{handleType:e.type,index:e.index}}))}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`edge`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e,t){let n=this.map.getSource(this.editSourceId);n&&n.setData(this.getEditHandleGeoJSON(e,t))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,e?this.createEditLayers():this.removeEditLayers())}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.map.project(e),r=this.getEditHandlePositions(),i=r.find(e=>e.type===`move`);if(i){let e=this.map.project(i.position),t=n.x-e.x,r=n.y-e.y;if(t*t+r*r<=144)return{type:`move`,index:i.index,position:i.position}}for(let e of r){if(e.type===`move`)continue;let t=this.map.project(e.position),r=n.x-t.x,i=n.y-t.y;if(r*r+i*i<=100)return{type:e.type,index:e.index,position:e.position}}return null}applyHandleMove(e,t){let n;if(e.type===`move`){let r=t[0]-e.position[0],i=t[1]-e.position[1],a=[this.entity.center[0]+r,this.entity.center[1]+i];n={...this.entity,center:a}}else{let e=O(this.entity.center,t);n={...this.entity,radius:e}}this.entity=n;let r=ge(n.center,n.radius);return this.updateSourceCoordinates(r),this.updateLabel(),this.updateAreaLabel(),this.updateRadiusLayer(),this.refreshEditHandles(),n}updateEditPreview(e,t){let n,r;if(e.type===`move`){let i=t[0]-e.position[0],a=t[1]-e.position[1];n=[this.entity.center[0]+i,this.entity.center[1]+a],r=this.entity.radius}else n=this.entity.center,r=O(this.entity.center,t);let i=ge(n,r);this.updateSourceCoordinates(i);let a=this.entity;this.entity={...this.entity,center:n,radius:r},this.updateLabel(),this.entity=a,this.refreshEditHandles(n,r)}cancelEditPreview(){let e=ge(this.entity.center,this.entity.radius);this.updateSourceCoordinates(e),this.updateLabel(),this.refreshEditHandles()}};function ve(e,t){let[n,r]=e,i=t/2/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r+o],[n+s,r+o],[n+s,r-o],[n-s,r-o],[n-s,r+o]]}var ye=class e{static{this.DEFAULTS={strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,fillColor:`#3388ff`,fillOpacity:.2}}constructor(e,t,n,r,i,a){this.isSelected=!1,this.initialized=!1,this.isEditing=!1,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.globalAreaConfig=i,this.globalLengthConfig=a,this.sourceId=`square-source-${t.id}`,this.fillLayerId=`square-fill-${t.id}`,this.strokeLayerId=`square-stroke-${t.id}`,this.labelLayerId=`square-label-${t.id}`,this.areaLayerId=`square-area-${t.id}`,this.lengthLayerId=`square-length-${t.id}`,this.editSourceId=`square-edit-source-${t.id}`,this.editHandleLayerId=`square-edit-handles-${t.id}`,this.editMoveLayerId=`square-edit-move-${t.id}`,this.initLayers()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get areaStyle(){return x(this.entity.areaConfig,this.globalAreaConfig,_)}get lengthStyle(){return x(this.entity.lengthConfig,this.globalLengthConfig,b)}initLayers(){if(!this.initialized)try{let t=this.getGeoJSON();this.map.addSource(this.sourceId,{type:`geojson`,data:t});let n=this.entity.confidence??1,r=P(n);this.map.addLayer({id:this.fillLayerId,type:`fill`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],paint:{"fill-color":this.entity.fillColor??e.DEFAULTS.fillColor,"fill-opacity":(this.entity.fillOpacity??e.DEFAULTS.fillOpacity)*r}}),this.map.addLayer({id:this.strokeLayerId,type:`line`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],layout:{"line-join":`miter`,"line-cap":`square`},paint:{"line-color":this.isSelected?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor,"line-width":this.entity.strokeWidth??e.DEFAULTS.strokeWidth,"line-opacity":(this.entity.strokeOpacity??e.DEFAULTS.strokeOpacity)*r}}),this.entity.name&&this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":r}}),this.entity.showArea&&this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":r}}),this.entity.showLength&&this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[.8,0],"text-allow-overlap":!0,"text-rotate":[`get`,`textRotation`],"text-rotation-alignment":`map`},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":r}}),this.initialized=!0}catch{this.map.once(`idle`,()=>this.initLayers())}}getGeoJSON(){let{center:e,length:t}=this.entity,n=ve(e,t),r=[{type:`Feature`,geometry:{type:`Polygon`,coordinates:[n]},properties:{}}];if(this.entity.name){let e=this.getBottomCenterPoint(n);r.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{pointType:`label`,name:this.entity.name}})}if(this.entity.showArea&&r.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{pointType:`area`,area:A(this.getArea())}}),this.entity.showLength){let e=n[1],t=n[2],i=[(e[0]+t[0])/2,(e[1]+t[1])/2],a=O(e,t);r.push({type:`Feature`,geometry:{type:`Point`,coordinates:i},properties:{pointType:`length`,length:j(a),textRotation:0}})}return{type:`FeatureCollection`,features:r}}getBottomCenterPoint(e){let t=e[2],n=e[3];return[(t[0]+n[0])/2,(t[1]+n[1])/2]}getArea(){return this.entity.length*this.entity.length}getEntityId(){return this.entity.id}getCenter(){return this.entity.center}getBounds(){let{center:e,length:t}=this.entity,[n,r]=e,i=t/2/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r-o],[n+s,r+o]]}getLayerId(){return this.fillLayerId}getLabelLayerId(){return this.entity.name?this.labelLayerId:null}setSelected(t){this.isSelected!==t&&(this.isSelected=t,this.initialized&&(this.map.getLayer(this.strokeLayerId)&&this.map.setPaintProperty(this.strokeLayerId,`line-color`,t?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor),this.map.getLayer(this.labelLayerId)&&(this.map.setPaintProperty(this.labelLayerId,`text-color`,t?this.selectNameStyle.fillColor:this.nameStyle.fillColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-color`,t?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-width`,t?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth))))}isPointInEntity(e){let{center:t,length:n}=this.entity,r=ve(t,n);return this.pointInPolygon(e,r)}pointInPolygon(e,t){let[n,r]=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let[o,s]=t[e],[c,l]=t[a];s>r!=l>r&&n<(c-o)*(r-s)/(l-s)+o&&(i=!i)}return i}update(t){let n=this.entity;if(this.entity=t,!this.initialized)return;let r=t.confidence??1,i=P(r);if(n.center!==t.center||n.length!==t.length||n.name!==t.name||n.showArea!==t.showArea||n.showLength!==t.showLength){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),!n.name&&t.name&&!this.map.getLayer(this.labelLayerId)?this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":i}}):n.name&&!t.name&&this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),!n.showArea&&t.showArea&&!this.map.getLayer(this.areaLayerId)?this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":i}}):n.showArea&&!t.showArea&&this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),!n.showLength&&t.showLength&&!this.map.getLayer(this.lengthLayerId)?this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[.8,0],"text-allow-overlap":!0,"text-rotate":[`get`,`textRotation`],"text-rotation-alignment":`map`},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":i}}):n.showLength&&!t.showLength&&this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId)}(n.fillColor!==t.fillColor||n.fillOpacity!==t.fillOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.fillLayerId)&&(this.map.setPaintProperty(this.fillLayerId,`fill-color`,t.fillColor??e.DEFAULTS.fillColor),this.map.setPaintProperty(this.fillLayerId,`fill-opacity`,(t.fillOpacity??e.DEFAULTS.fillOpacity)*i)),(n.strokeColor!==t.strokeColor||n.strokeWidth!==t.strokeWidth||n.strokeOpacity!==t.strokeOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.strokeLayerId)&&(this.isSelected||this.map.setPaintProperty(this.strokeLayerId,`line-color`,t.strokeColor??e.DEFAULTS.strokeColor),this.map.setPaintProperty(this.strokeLayerId,`line-width`,t.strokeWidth??e.DEFAULTS.strokeWidth),this.map.setPaintProperty(this.strokeLayerId,`line-opacity`,(t.strokeOpacity??e.DEFAULTS.strokeOpacity)*i)),n.confidence!==t.confidence&&(this.map.getLayer(this.labelLayerId)&&this.map.setPaintProperty(this.labelLayerId,`text-opacity`,i),this.map.getLayer(this.areaLayerId)&&this.map.setPaintProperty(this.areaLayerId,`text-opacity`,i),this.map.getLayer(this.lengthLayerId)&&this.map.setPaintProperty(this.lengthLayerId,`text-opacity`,i))}getCorners(e,t){return ve(e??this.entity.center,t??this.entity.length).slice(0,4)}getEditHandleGeoJSON(e,t){let n=this.getCorners(e,t).map((e,t)=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{handleType:`vertex`,index:t}})),r=e??this.entity.center;return n.push({type:`Feature`,geometry:{type:`Point`,coordinates:r},properties:{handleType:`move`,index:0}}),{type:`FeatureCollection`,features:n}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`vertex`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e,t){let n=this.map.getSource(this.editSourceId);n&&n.setData(this.getEditHandleGeoJSON(e,t))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,this.initialized&&(e?this.createEditLayers():this.removeEditLayers()))}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.getCorners(),r=this.map.project(e),i=this.entity.center,a=this.map.project(i),o=r.x-a.x,s=r.y-a.y;if(o*o+s*s<=144)return{type:`move`,index:0,position:i};for(let e=0;e<n.length;e++){let t=this.map.project(n[e]),i=r.x-t.x,a=r.y-t.y;if(i*i+a*a<=100)return{type:`vertex`,index:e,position:n[e]}}return null}computeNewLength(e){return O(this.entity.center,e)*Math.SQRT2}applyHandleMove(e,t){let n;if(e.type===`move`){let r=t[0]-e.position[0],i=t[1]-e.position[1],a=[this.entity.center[0]+r,this.entity.center[1]+i];n={...this.entity,center:a}}else{let e=this.computeNewLength(t);n={...this.entity,length:e}}this.entity=n;let r=this.map.getSource(this.sourceId);return r&&r.setData(this.getGeoJSON()),this.refreshEditHandles(),n}updateEditPreview(e,t){let n,r;if(e.type===`move`){let i=t[0]-e.position[0],a=t[1]-e.position[1];n=[this.entity.center[0]+i,this.entity.center[1]+a],r=this.entity.length}else n=this.entity.center,r=this.computeNewLength(t);let i=this.entity;this.entity={...this.entity,center:n,length:r};let a=this.map.getSource(this.sourceId);a&&a.setData(this.getGeoJSON()),this.entity=i,this.refreshEditHandles(n,r)}cancelEditPreview(){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),this.refreshEditHandles()}destroy(){this.initialized&&=(this.removeEditLayers(),this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId),this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.strokeLayerId)&&this.map.removeLayer(this.strokeLayerId),this.map.getLayer(this.fillLayerId)&&this.map.removeLayer(this.fillLayerId),this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId),!1)}};function be(e){let[[t,n],[r,i]]=e,a=Math.min(t,r),o=Math.max(t,r),s=Math.min(n,i),c=Math.max(n,i);return[[a,c],[o,c],[o,s],[a,s],[a,c]]}var xe=class e{static{this.DEFAULTS={strokeColor:`#3388ff`,strokeWidth:2,strokeOpacity:1,fillColor:`#3388ff`,fillOpacity:.2}}constructor(e,t,n,r,i,a){this.isSelected=!1,this.initialized=!1,this.isEditing=!1,this.map=e,this.entity=t,this.globalNameConfig=n,this.globalSelectNameConfig=r,this.globalAreaConfig=i,this.globalLengthConfig=a,this.sourceId=`rectangle-source-${t.id}`,this.fillLayerId=`rectangle-fill-${t.id}`,this.strokeLayerId=`rectangle-stroke-${t.id}`,this.labelLayerId=`rectangle-label-${t.id}`,this.areaLayerId=`rectangle-area-${t.id}`,this.lengthLayerId=`rectangle-length-${t.id}`,this.editSourceId=`rectangle-edit-source-${t.id}`,this.editHandleLayerId=`rectangle-edit-handles-${t.id}`,this.editMoveLayerId=`rectangle-edit-move-${t.id}`,this.initLayers()}get nameStyle(){return x(this.entity.nameConfig,this.globalNameConfig,h)}get selectNameStyle(){return x(this.entity.selectNameConfig,this.globalSelectNameConfig,g)}get areaStyle(){return x(this.entity.areaConfig,this.globalAreaConfig,_)}get lengthStyle(){return x(this.entity.lengthConfig,this.globalLengthConfig,b)}initLayers(){if(!this.initialized)try{let t=this.getGeoJSON();this.map.addSource(this.sourceId,{type:`geojson`,data:t});let n=this.entity.confidence??1,r=P(n);this.map.addLayer({id:this.fillLayerId,type:`fill`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],paint:{"fill-color":this.entity.fillColor??e.DEFAULTS.fillColor,"fill-opacity":(this.entity.fillOpacity??e.DEFAULTS.fillOpacity)*r}}),this.map.addLayer({id:this.strokeLayerId,type:`line`,source:this.sourceId,filter:[`==`,`$type`,`Polygon`],layout:{"line-join":`miter`,"line-cap":`square`},paint:{"line-color":this.isSelected?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor,"line-width":this.entity.strokeWidth??e.DEFAULTS.strokeWidth,"line-opacity":(this.entity.strokeOpacity??e.DEFAULTS.strokeOpacity)*r}}),this.entity.name&&this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":r}}),this.entity.showArea&&this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":r}}),this.entity.showLength&&this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":r}}),this.initialized=!0}catch{this.map.once(`idle`,()=>this.initLayers())}}getGeoJSON(){let{bounds:e}=this.entity,t=be(e),n=[{type:`Feature`,geometry:{type:`Polygon`,coordinates:[t]},properties:{}}];if(this.entity.name){let e=this.getBottomCenterPoint(t);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{pointType:`label`,name:this.entity.name}})}if(this.entity.showArea){let e=this.calculateRectangleCenter();n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{pointType:`area`,area:A(this.getArea())}})}if(this.entity.showLength)for(let[e,r,i]of[[0,1,0],[1,2,0]]){let a=t[e],o=t[r],s=[(a[0]+o[0])/2,(a[1]+o[1])/2],c=O(a,o);n.push({type:`Feature`,geometry:{type:`Point`,coordinates:s},properties:{pointType:`length`,length:j(c),textRotation:i}})}return{type:`FeatureCollection`,features:n}}getBottomCenterPoint(e){let t=e[2],n=e[3];return[(t[0]+n[0])/2,(t[1]+n[1])/2]}getArea(){let e=be(this.entity.bounds);return ee(e)}getEntityId(){return this.entity.id}getBounds(){let[[e,t],[n,r]]=this.entity.bounds,i=Math.min(e,n),a=Math.max(e,n);return[[i,Math.min(t,r)],[a,Math.max(t,r)]]}getCenter(){return this.entity.center?this.entity.center:this.calculateRectangleCenter()}calculateRectangleCenter(){let[[e,t],[n,r]]=this.entity.bounds;return[(e+n)/2,(t+r)/2]}getLayerId(){return this.fillLayerId}getLabelLayerId(){return this.entity.name?this.labelLayerId:null}setSelected(t){this.isSelected!==t&&(this.isSelected=t,this.initialized&&(this.map.getLayer(this.strokeLayerId)&&this.map.setPaintProperty(this.strokeLayerId,`line-color`,t?`#ffcc00`:this.entity.strokeColor??e.DEFAULTS.strokeColor),this.map.getLayer(this.labelLayerId)&&(this.map.setPaintProperty(this.labelLayerId,`text-color`,t?this.selectNameStyle.fillColor:this.nameStyle.fillColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-color`,t?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor),this.map.setPaintProperty(this.labelLayerId,`text-halo-width`,t?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth))))}isPointInEntity(e){let{bounds:t}=this.entity,n=be(t);return this.pointInPolygon(e,n)}pointInPolygon(e,t){let[n,r]=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let[o,s]=t[e],[c,l]=t[a];s>r!=l>r&&n<(c-o)*(r-s)/(l-s)+o&&(i=!i)}return i}update(t){let n=this.entity;if(this.entity=t,!this.initialized)return;let r=t.confidence??1,i=P(r);if(n.bounds!==t.bounds||n.name!==t.name||n.showArea!==t.showArea||n.showLength!==t.showLength){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),!n.name&&t.name&&!this.map.getLayer(this.labelLayerId)?this.map.addLayer({id:this.labelLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`label`],layout:{"text-field":[`get`,`name`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":14,"text-anchor":`top`,"text-offset":[0,.8],"text-allow-overlap":!0},paint:{"text-color":this.isSelected?this.selectNameStyle.fillColor:this.nameStyle.fillColor,"text-halo-color":this.isSelected?this.selectNameStyle.strokeColor:this.nameStyle.strokeColor,"text-halo-width":this.isSelected?this.selectNameStyle.strokeWidth:this.nameStyle.strokeWidth,"text-opacity":i}}):n.name&&!t.name&&this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),!n.showArea&&t.showArea&&!this.map.getLayer(this.areaLayerId)?this.map.addLayer({id:this.areaLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`area`],layout:{"text-field":[`get`,`area`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-allow-overlap":!0},paint:{"text-color":this.areaStyle.fillColor,"text-halo-color":this.areaStyle.strokeColor,"text-halo-width":this.areaStyle.strokeWidth,"text-opacity":i}}):n.showArea&&!t.showArea&&this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),!n.showLength&&t.showLength&&!this.map.getLayer(this.lengthLayerId)?this.map.addLayer({id:this.lengthLayerId,type:`symbol`,source:this.sourceId,filter:[`==`,[`get`,`pointType`],`length`],layout:{"text-field":[`get`,`length`],"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-size":12,"text-anchor":`center`,"text-offset":[0,-.8],"text-allow-overlap":!0},paint:{"text-color":this.lengthStyle.fillColor,"text-halo-color":this.lengthStyle.strokeColor,"text-halo-width":this.lengthStyle.strokeWidth,"text-opacity":i}}):n.showLength&&!t.showLength&&this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId)}(n.fillColor!==t.fillColor||n.fillOpacity!==t.fillOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.fillLayerId)&&(this.map.setPaintProperty(this.fillLayerId,`fill-color`,t.fillColor??e.DEFAULTS.fillColor),this.map.setPaintProperty(this.fillLayerId,`fill-opacity`,(t.fillOpacity??e.DEFAULTS.fillOpacity)*i)),(n.strokeColor!==t.strokeColor||n.strokeWidth!==t.strokeWidth||n.strokeOpacity!==t.strokeOpacity||n.confidence!==t.confidence)&&this.map.getLayer(this.strokeLayerId)&&(this.isSelected||this.map.setPaintProperty(this.strokeLayerId,`line-color`,t.strokeColor??e.DEFAULTS.strokeColor),this.map.setPaintProperty(this.strokeLayerId,`line-width`,t.strokeWidth??e.DEFAULTS.strokeWidth),this.map.setPaintProperty(this.strokeLayerId,`line-opacity`,(t.strokeOpacity??e.DEFAULTS.strokeOpacity)*i)),n.confidence!==t.confidence&&(this.map.getLayer(this.labelLayerId)&&this.map.setPaintProperty(this.labelLayerId,`text-opacity`,i),this.map.getLayer(this.areaLayerId)&&this.map.setPaintProperty(this.areaLayerId,`text-opacity`,i),this.map.getLayer(this.lengthLayerId)&&this.map.setPaintProperty(this.lengthLayerId,`text-opacity`,i))}getCorners(e){return be(e??this.entity.bounds).slice(0,4)}getEditHandleGeoJSON(e){let t=this.getCorners(e).map((e,t)=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{handleType:`vertex`,index:t}})),n=e??this.entity.bounds,r=(n[0][0]+n[1][0])/2,i=(n[0][1]+n[1][1])/2;return t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[r,i]},properties:{handleType:`move`,index:0}}),{type:`FeatureCollection`,features:t}}createEditLayers(){this.map.getSource(this.editSourceId)||(I(this.map),this.map.addSource(this.editSourceId,{type:`geojson`,data:this.getEditHandleGeoJSON()}),this.map.addLayer({id:this.editHandleLayerId,type:`circle`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`vertex`],paint:{"circle-radius":6,"circle-color":`#ffffff`,"circle-stroke-color":`#3388ff`,"circle-stroke-width":2}}),this.map.addLayer({id:this.editMoveLayerId,type:`symbol`,source:this.editSourceId,filter:[`==`,[`get`,`handleType`],`move`],layout:{"icon-image":ae,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}))}removeEditLayers(){this.map.getLayer(this.editMoveLayerId)&&this.map.removeLayer(this.editMoveLayerId),this.map.getLayer(this.editHandleLayerId)&&this.map.removeLayer(this.editHandleLayerId),this.map.getSource(this.editSourceId)&&this.map.removeSource(this.editSourceId)}refreshEditHandles(e){let t=this.map.getSource(this.editSourceId);t&&t.setData(this.getEditHandleGeoJSON(e))}setEditing(e){this.isEditing!==e&&(this.isEditing=e,this.initialized&&(e?this.createEditLayers():this.removeEditLayers()))}getEditHandleAt(e,t){if(!this.isEditing)return null;let n=this.getCorners(),r=this.map.project(e),i=this.calculateRectangleCenter(),a=this.map.project(i),o=r.x-a.x,s=r.y-a.y;if(o*o+s*s<=144)return{type:`move`,index:0,position:i};for(let e=0;e<n.length;e++){let t=this.map.project(n[e]),i=r.x-t.x,a=r.y-t.y;if(i*i+a*a<=100)return{type:`vertex`,index:e,position:n[e]}}return null}computeNewBounds(e,t){let n=this.getCorners(),r=(e+2)%4,i=n[r];return[[Math.min(t[0],i[0]),Math.min(t[1],i[1])],[Math.max(t[0],i[0]),Math.max(t[1],i[1])]]}offsetBounds(e,t,n){let r=n[0]-t[0],i=n[1]-t[1];return[[e[0][0]+r,e[0][1]+i],[e[1][0]+r,e[1][1]+i]]}applyHandleMove(e,t){let n;n=e.type===`move`?this.offsetBounds(this.entity.bounds,e.position,t):this.computeNewBounds(e.index,t);let r={...this.entity,bounds:n};this.entity=r;let i=this.map.getSource(this.sourceId);return i&&i.setData(this.getGeoJSON()),this.refreshEditHandles(),r}updateEditPreview(e,t){let n;n=e.type===`move`?this.offsetBounds(this.entity.bounds,e.position,t):this.computeNewBounds(e.index,t);let r=this.entity;this.entity={...this.entity,bounds:n};let i=this.map.getSource(this.sourceId);i&&i.setData(this.getGeoJSON()),this.entity=r,this.refreshEditHandles(n)}cancelEditPreview(){let e=this.map.getSource(this.sourceId);e&&e.setData(this.getGeoJSON()),this.refreshEditHandles()}destroy(){this.initialized&&=(this.removeEditLayers(),this.map.getLayer(this.lengthLayerId)&&this.map.removeLayer(this.lengthLayerId),this.map.getLayer(this.areaLayerId)&&this.map.removeLayer(this.areaLayerId),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.strokeLayerId)&&this.map.removeLayer(this.strokeLayerId),this.map.getLayer(this.fillLayerId)&&this.map.removeLayer(this.fillLayerId),this.map.getSource(this.sourceId)&&this.map.removeSource(this.sourceId),!1)}};const Se=({popupState:e,onClose:t,portalContainer:n,popupRef:r})=>{let i=(0,c.useRef)(null),[a,o]=(0,c.useState)(`entering`),[s,l]=(0,c.useState)(!1),u=(0,c.useRef)(e.position),d=(0,c.useRef)(!1),m=r||i;d.current||(u.current=e.position),(0,c.useEffect)(()=>{let e=setTimeout(()=>{l(!0)},60);return()=>clearTimeout(e)},[]),(0,c.useEffect)(()=>{if(a===`entering`&&s){let e=setTimeout(()=>o(`entered`),50);return()=>clearTimeout(e)}},[a,s]);let h=(0,c.useCallback)(()=>{e.config.animation===`none`?t():(d.current=!0,o(`exiting`),setTimeout(()=>t(),200))},[e.config.animation,t]);(0,c.useEffect)(()=>{if(!e.config.closeOnEscape)return;let t=e=>{e.key===`Escape`&&h()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e.config.closeOnEscape,h]),(0,c.useEffect)(()=>{if(!e.config.closeOnClickOutside)return;let t=e=>{m.current&&!m.current.contains(e.target)&&h()},n=setTimeout(()=>{document.addEventListener(`click`,t,!0)},0);return()=>{clearTimeout(n),document.removeEventListener(`click`,t,!0)}},[e.config.closeOnClickOutside,h,m]);let g=()=>{switch(e.actualPosition){case`top`:return`center bottom`;case`bottom`:return`center top`;case`left`:return`right center`;case`right`:return`left center`;case`center`:default:return`center center`}},_=u.current,v=(0,p.jsxs)(`div`,{ref:m,className:`entity-popup ${s?`entity-popup--${a} animation-${e.config.animation}`:``} ${e.config.className||``}`,style:{position:`fixed`,left:`${_.x}px`,top:`${_.y}px`,maxWidth:e.config.maxWidth,zIndex:e.config.zIndex,pointerEvents:`all`,opacity:s?void 0:0,transformOrigin:g(),...e.config.style},role:`dialog`,"aria-modal":`true`,children:[e.config.showCloseButton&&(0,p.jsx)(`button`,{className:`entity-popup__close`,onClick:h,"aria-label":`Close popup`,children:`×`}),(0,p.jsx)(`div`,{className:`entity-popup__content`,children:e.config.content})]});return(0,f.createPortal)(v,n)};var Ce=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20t='1768373933818'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20p-id='30344'%20width='200'%20height='200'%3e%3cpath%20d='M400.440142%201024h-0.073136a48.781895%2048.781895%200%200%201-45.490763-31.448598L3.383306%2066.061072a48.781895%2048.781895%200%200%201%2062.897196-62.897197l926.563466%20351.419801a48.928168%2048.928168%200%200%201%200.219409%2091.127799L597.761811%20597.688654l-151.904042%20395.082157a48.781895%2048.781895%200%200%201-45.490763%2031.229189zM133.053921%20132.907627l267.678766%20705.691916%20113.87318-296.201913a48.855032%2048.855032%200%200%201%2028.011193-27.938057l296.201913-113.87318-705.765052-267.678766z'%20p-id='30345'%20fill='%23ffffff'%20/%3e%3cscript%20xmlns=''%20/%3e%3c/svg%3e`;function we({map:e,precision:t=6,className:n=``,style:r}){let[i,a]=(0,c.useState)(null),o=(0,c.useCallback)(e=>{a({lng:Number(e.lngLat.lng.toFixed(t)),lat:Number(e.lngLat.lat.toFixed(t))})},[t]);return(0,c.useEffect)(()=>{if(e)return e.on(`mousemove`,o),()=>{e.off(`mousemove`,o)}},[e,o]),i?(0,p.jsxs)(`div`,{className:`mapbox-coordinate-display ${n}`,style:r,children:[(0,p.jsx)(`img`,{src:Ce,alt:`location`,className:`mapbox-coordinate-display__icon`}),(0,p.jsxs)(`div`,{className:`mapbox-coordinate-display__content`,children:[(0,p.jsxs)(`span`,{className:`mapbox-coordinate-display__item`,children:[`经度:`,i.lng]}),(0,p.jsxs)(`span`,{className:`mapbox-coordinate-display__item`,children:[`纬度:`,i.lat]})]})]}):null}var R=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20t='1768374054549'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20p-id='31504'%20width='200'%20height='200'%3e%3cpath%20d='M53.80096%20687.40096l282.79808%20282.79808%20633.6-633.6-282.79808-282.79808-90.39872%2090.39872-28.29824%2028.20096-42.7008%2042.7008-23.5008%2023.5008-63.20128%2063.19616-12.29824%2012.29824-373.20192%20373.30432z%20m282.79808%20212.10112l-212.10112-212.1984%2054.99904-54.99904%20106.10176%20106.10176%2028.29824-28.29824-106.10176-106.10176%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.69184-70.71232%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.70208-70.70208%2042.39872-42.39872%20106.10176%20106.10176%2028.29824-28.29824-106.09664-106.10688%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.70208-70.7072%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.70208-70.70208%2042.7008-42.7008%20106.10176%20106.10176%2028.29824-28.29824-105.99936-106.10176%2054.99904-54.99904%20212.10112%20212.10112L336.59904%20899.50208z'%20fill='%23ffffff'%20p-id='31505'%20/%3e%3cscript%20xmlns=''%20/%3e%3c/svg%3e`;function Te({map:e,maxWidth:t=100,unit:n=`metric`,className:r=``,style:i}){let[a,o]=(0,c.useState)({width:100,label:`100 m`}),s=(0,c.useCallback)(()=>{if(!e)return;let r=e.getZoom(),i=e.getCenter().lat,a=40075016.686/(256*2**r),s=i*Math.PI/180,c=a*Math.cos(s)*t,l,u;if(n===`imperial`){let e=3.2808*c;if(e>5280){let n=e/5280;l=z(n),u=`${l} mi`;let r=l/n;o({width:t*r,label:u})}else{l=z(e),u=`${l} ft`;let n=l/e;o({width:t*n,label:u})}}else if(n===`nautical`){let e=c/1852;l=z(e),u=`${l} nm`;let n=l/e;o({width:t*n,label:u})}else if(c>=1e3){l=z(c/1e3),u=`${l} km`;let e=l/(c/1e3);o({width:t*e,label:u})}else{l=z(c),u=`${l} m`;let e=l/c;o({width:t*e,label:u})}},[e,t,n]);return(0,c.useEffect)(()=>{if(e)return s(),e.on(`move`,s),e.on(`zoom`,s),()=>{e.off(`move`,s),e.off(`zoom`,s)}},[e,s]),(0,p.jsxs)(`div`,{className:`mapbox-scale-control ${r}`,style:i,children:[(0,p.jsxs)(`div`,{className:`mapbox-scale-control__bar-wrapper`,children:[(0,p.jsx)(`img`,{src:R,alt:`scale`,className:`mapbox-scale-control__icon`}),(0,p.jsxs)(`div`,{className:`mapbox-scale-control__bar`,style:{width:`${a.width}px`},children:[(0,p.jsx)(`div`,{className:`mapbox-scale-control__tick mapbox-scale-control__tick--left`}),(0,p.jsx)(`div`,{className:`mapbox-scale-control__tick mapbox-scale-control__tick--right`})]})]}),(0,p.jsx)(`span`,{className:`mapbox-scale-control__label`,children:a.label})]})}function z(e){let t=10**(`${Math.floor(e)}`.length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,t*n}var B=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1768989620222'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5780'%20width='128'%20height='128'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cpath%20d='M938.666667%20602.752a42.666667%2042.666667%200%200%201%2042.368%2037.674667l0.298666%204.992V853.333333a128%20128%200%200%201-120.490666%20127.786667L853.333333%20981.333333h-208.896a42.666667%2042.666667%200%200%201-4.949333-85.034666l4.949333-0.298667H853.333333a42.666667%2042.666667%200%200%200%2042.368-37.674667L896%20853.333333v-207.914666a42.666667%2042.666667%200%200%201%2042.666667-42.666667z%20m-853.333334%203.285333a42.666667%2042.666667%200%200%201%2042.368%2037.674667l0.298667%204.992V853.333333a42.666667%2042.666667%200%200%200%2037.674667%2042.368L170.666667%20896h211.882666a42.666667%2042.666667%200%200%201%204.992%2085.034667L382.549333%20981.333333H170.666667a128%20128%200%200%201-127.786667-120.490666L42.666667%20853.333333v-204.629333a42.666667%2042.666667%200%200%201%2042.666666-42.666667zM381.866667%2042.666667A42.666667%2042.666667%200%200%201%20386.944%20127.701333L381.866667%20128H170.666667a42.666667%2042.666667%200%200%200-42.368%2037.674667L128%20170.666667v216.448a42.666667%2042.666667%200%200%201-85.034667%204.992L42.666667%20387.114667V170.666667A128%20128%200%200%201%20163.157333%2042.88L170.666667%2042.666667h211.2zM853.333333%2042.666667a128%20128%200%200%201%20127.786667%20120.490666L981.333333%20170.666667v216.064a42.666667%2042.666667%200%200%201-85.034666%204.992L896%20386.730667V170.666667a42.666667%2042.666667%200%200%200-37.674667-42.368L853.333333%20128h-214.4a42.666667%2042.666667%200%200%201-4.949333-85.034667L638.933333%2042.666667H853.333333z'%20fill='%23ffffff'%20p-id='5781'%3e%3c/path%3e%3cpath%20d='M512%20512m-128%200a128%20128%200%201%200%20256%200%20128%20128%200%201%200-256%200Z'%20fill='%23ffffff'%20p-id='5782'%3e%3c/path%3e%3c/svg%3e`;function Ee({map:e,initialCenter:t,initialZoom:n,initialPitch:r=0,initialBearing:i=0,className:a=``,style:o,duration:s=1e3}){return(0,p.jsxs)(`button`,{className:`mapbox-control-btn mapbox-reset-view-control ${a}`,onClick:()=>{e&&e.flyTo({center:t,zoom:n,pitch:r,bearing:i,duration:s})},style:o,title:`回到初始位置`,children:[(0,p.jsx)(`img`,{src:B,alt:`home`,className:`mapbox-control-btn__icon`}),(0,p.jsx)(`span`,{children:`复位`})]})}var De=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769487141027'%20class='icon'%20viewBox='0%200%201517%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='2644'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='189.625'%20height='128'%3e%3cpath%20d='M1.68121071-242.12320149h1508.24640296v1508.24640298h-1508.24640296z'%20fill='%23ffffff'%20fill-opacity='0'%20p-id='2645'%3e%3c/path%3e%3cpath%20d='M437.30078846%20170.6624h682.66239999v682.6624H437.30078846z'%20fill='%23ffffff'%20fill-opacity='0'%20p-id='2646'%3e%3c/path%3e%3cpath%20d='M1151.68343834%2040.66710748H373.42829443A81.76345149%2081.76345149%200%200%200%20292.90207634%20121.49379654v784.42363608c0%2040.42218191%2036.92257893%2077.41545989%2080.5262181%2077.4154599h781.6133488a81.76345149%2081.76345149%200%200%200%2080.52621814-80.82668906V121.49379654C1232.08593315%2077.76643404%201195.25172802%2040.66710748%201151.6657636%2040.66710748z%20m-325.39237822%20616.14222197H618.29445458V451.37556451h53.66057906c6.71640976%200%2013.41514477-3.35820487%2020.11387975-6.73408452l97.28189301-100.99359314h134.18679716v208.72127078c-46.96184405%2013.50351858-87.22495312%2053.90802574-97.28189299%20104.4048223z%20m130.7932427-20.23760311c23.50743418%200%2043.65666346%2020.21992834%2043.65666349%2043.76271204a44.50505206%2044.50505206%200%200%201-43.62131391%2043.7803868%2044.50505206%2044.50505206%200%200%201-43.6036392-43.7803868c0-23.54278369%2020.096205-43.76271203%2043.6036392-43.76271204h-0.05302433zM564.63387554%20926.10201142H373.42829443a22.87114272%2022.87114272%200%200%201-16.79102442-6.71640975%2023.04789036%2023.04789036%200%200%201-6.71640975-16.82637394V714.02253578h214.73069002v212.07947564z%20m0-269.31035673H349.92086026V118.13559167c0-10.1453137%2010.05693988-20.2376031%2023.50743417-20.23760309h553.4321645v188.53669194h-147.54891766c-6.69873499%200-13.39747001%203.35820487-20.096205%206.71640977l-97.28189297%2097.653063H460.61789801a26.44144475%2026.44144475%200%200%200-19.08874355%207.79457028%2026.63586714%2026.63586714%200%200%200-7.72387123%2019.1594426c0%2016.80869917%2013.39747001%2026.90098858%2026.81261478%2026.90098857h104.03365227v212.13249995z%20m610.48629795%20245.71454877c0.17674763%206.29221547-2.24469484%2012.37233377-6.68106024%2016.84404869s-10.49880895%206.89315739-16.77334965%206.75175927h-533.42433329v-212.0971504H829.63159021c13.39747001%2057.24855586%2067.07572382%2097.65306301%20127.48806219%2097.653063a128.67227125%20128.67227125%200%200%200%2093.05762473-37.87701612%20129.60903367%20129.60903367%200%200%200%2037.73561801-93.39344522c0-64.00031515-46.96184405-117.8553166-103.98062799-128.00063029v-208.73894554h194.56378599v558.91134088h-3.35820489v-0.05302427z%20m0-616.07152294H980.57406228V97.89798858h171.10937607c13.39747001%200%2023.45440988%2010.07461465%2023.4544099%2023.59580796v164.94088398z'%20fill='%23ffffff'%20p-id='2647'%3e%3c/path%3e%3c/svg%3e`,V=`road-highlight-`,Oe=[{source:`composite`,sourceLayer:`road`},{source:`openmaptiles`,sourceLayer:`transportation`},{source:`maptiler_planet`,sourceLayer:`transportation`}];function ke(e){let t=e.getStyle();if(!t||!t.sources)return null;for(let e of Oe){let n=t.sources[e.source];if(n&&n.type===`vector`)return e}for(let[e,n]of Object.entries(t.sources))if(n.type===`vector`)return{source:e,sourceLayer:`transportation`};return null}function Ae({map:e,highlightWidth:t=3,defaultRoadTypes:n=[],defaultMinWidth:r=0,source:i,sourceLayer:a,classField:o=`class`,className:s=``,style:u}){let[d,f]=(0,c.useState)(!1),[h,g]=(0,c.useState)(n),[_,v]=(0,c.useState)(!1),y=(0,c.useRef)(!1),b=(0,c.useRef)(null),x=(0,c.useRef)(null),S=(0,c.useRef)(null),C=(0,c.useCallback)((e,n,r)=>{if(!e.isStyleLoaded()||!e.getSource(n))return!1;let i=!0;return E.forEach(a=>{let s=`${V}${a.class}`;if(!e.getLayer(s))try{e.addLayer({id:s,type:`line`,source:n,"source-layer":r,filter:[`==`,[`get`,o],a.class],paint:{"line-color":a.color,"line-width":t,"line-opacity":.8},layout:{visibility:`none`}}),console.log(`Added road highlight layer: ${s} (source: ${n}, source-layer: ${r})`)}catch(e){console.error(`Failed to add road highlight layer for ${a.class}:`,e),i=!1}}),i},[t,o]);(0,c.useEffect)(()=>{if(!e)return;let t=()=>{let t=i,n=a;if(!t||!n){let r=ke(e);r&&(console.log(`Auto-detected vector source:`,r),t||=r.source,n||=r.sourceLayer)}t&&n?C(e,t,n)&&(y.current=!0,v(!0)):console.warn(`No vector source found for road highlighting`)};e.isStyleLoaded()?t():e.once(`load`,t);let n=()=>{e.isStyleLoaded()&&t()},r=()=>{y.current||t()};return e.on(`styledata`,n),e.on(`sourcedata`,r),()=>{e.off(`styledata`,n),e.off(`sourcedata`,r)}},[e,i,a,C]),(0,c.useEffect)(()=>{!e||!_||E.forEach(t=>{let n=`${V}${t.class}`;if(e.getLayer(n))try{let r=h.includes(t.class);e.setLayoutProperty(n,`visibility`,r?`visible`:`none`)}catch(e){console.error(`Failed to update layer ${n}:`,e)}})},[e,_,h]),(0,c.useEffect)(()=>{if(!d)return;let e=e=>{b.current&&!b.current.contains(e.target)&&x.current&&!x.current.contains(e.target)&&f(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[d]),(0,c.useEffect)(()=>()=>{e&&e.getStyle()&&E.forEach(t=>{let n=`${V}${t.class}`;if(e.getLayer(n))try{e.removeLayer(n)}catch{}}),S.current&&=(S.current.remove(),null)},[e]);let w=(0,c.useCallback)(e=>E.find(t=>t.class===e)?.label||e,[]),T=(0,c.useCallback)(t=>{if(!e||h.length===0){S.current&&S.current.remove(),e?.getCanvas().style.cursor&&(e.getCanvas().style.cursor=``);return}let n=h.map(e=>`${V}${e}`),r=[[t.point.x-10,t.point.y-10],[t.point.x+10,t.point.y+10]],i=e.queryRenderedFeatures(r,{layers:n.filter(t=>e.getLayer(t))});if(i.length>0){let n=i[0].properties||{},r=t.lngLat,a=n.name||n.name_en||n.name_local||``,s=n[o]||``,c=n.type||``,u=n.structure||``,d=n.oneway,f=n.layer,p=n.iso_3166_1||``,m=n.iso_3166_2||``,h=e=>!(e==null||e===``||typeof e==`string`&&e.toLowerCase()===`none`),g=[];h(s)&&g.push(`
2
2
  <div class="road-highlight-popup__row">
3
3
  <span>道路类型:</span>
4
- <span class="road-highlight-popup__value">${w(o)}</span>
4
+ <span class="road-highlight-popup__value">${w(s)}</span>
5
5
  </div>
6
- `),h.push(`
6
+ `),g.push(`
7
7
  <div class="road-highlight-popup__row">
8
8
  <span>经度:</span>
9
9
  <span class="road-highlight-popup__value">${r.lng.toFixed(6)}</span>
10
10
  </div>
11
- `),h.push(`
11
+ `),g.push(`
12
12
  <div class="road-highlight-popup__row">
13
13
  <span>纬度:</span>
14
14
  <span class="road-highlight-popup__value">${r.lat.toFixed(6)}</span>
15
15
  </div>
16
- `),m(s)&&h.push(`
16
+ `),h(c)&&g.push(`
17
17
  <div class="road-highlight-popup__row">
18
18
  <span>类别:</span>
19
- <span class="road-highlight-popup__value">${s}</span>
19
+ <span class="road-highlight-popup__value">${c}</span>
20
20
  </div>
21
- `),m(c)&&h.push(`
21
+ `),h(u)&&g.push(`
22
22
  <div class="road-highlight-popup__row">
23
23
  <span>结构:</span>
24
- <span class="road-highlight-popup__value">${c}</span>
24
+ <span class="road-highlight-popup__value">${u}</span>
25
25
  </div>
26
- `),u!=null&&u!==``&&h.push(`
26
+ `),d!=null&&d!==``&&g.push(`
27
27
  <div class="road-highlight-popup__row">
28
28
  <span>单行道:</span>
29
- <span class="road-highlight-popup__value">${u?`是`:`否`}</span>
29
+ <span class="road-highlight-popup__value">${d?`是`:`否`}</span>
30
30
  </div>
31
- `),m(d)&&h.push(`
31
+ `),h(f)&&g.push(`
32
32
  <div class="road-highlight-popup__row">
33
33
  <span>层级:</span>
34
- <span class="road-highlight-popup__value">${d}</span>
34
+ <span class="road-highlight-popup__value">${f}</span>
35
35
  </div>
36
- `),m(f)&&h.push(`
36
+ `),h(p)&&g.push(`
37
37
  <div class="road-highlight-popup__row">
38
38
  <span>国家代码:</span>
39
- <span class="road-highlight-popup__value">${f}</span>
39
+ <span class="road-highlight-popup__value">${p}</span>
40
40
  </div>
41
- `),m(p)&&h.push(`
41
+ `),h(m)&&g.push(`
42
42
  <div class="road-highlight-popup__row">
43
43
  <span>地区代码:</span>
44
- <span class="road-highlight-popup__value">${p}</span>
44
+ <span class="road-highlight-popup__value">${m}</span>
45
45
  </div>
46
- `);let g=`
46
+ `);let _=`
47
47
  <div class="road-highlight-popup__content">
48
48
  ${a?`<div class="road-highlight-popup__title">${a}</div>`:``}
49
- <div class="road-highlight-popup__info">${h.join(``)}</div>
49
+ <div class="road-highlight-popup__info">${g.join(``)}</div>
50
50
  </div>
51
- `;S.current||=new l.default.Popup({closeButton:!1,closeOnClick:!1,offset:15,className:`road-highlight-popup`}),S.current.setLngLat(r).setHTML(g).addTo(e),e.getCanvas().style.cursor=`pointer`}else S.current&&S.current.remove(),e.getCanvas().style.cursor=``},[e,h,w]);(0,c.useEffect)(()=>{if(!(!e||!_))return e.on(`mousemove`,T),()=>{e.off(`mousemove`,T),S.current&&S.current.remove(),e.getCanvas().style.cursor=``}},[e,_,T]);let D=(e,t)=>{g(n=>t?[...n,e]:n.filter(t=>t!==e))},O=e=>{g(e?E.map(e=>e.class):[])},k=h.length>0;return(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control ${s}`,style:u,children:[(0,p.jsxs)(`button`,{ref:x,className:`mapbox-control-btn mapbox-road-highlight-control__btn ${k?`mapbox-road-highlight-control__btn--active`:``}`,onClick:()=>f(!d),title:`路网高亮${h.length>0?` (已选 ${h.length})`:``}`,children:[(0,p.jsx)(`img`,{src:De,alt:`road`,className:`mapbox-road-highlight-control__btn-icon`}),(0,p.jsxs)(`span`,{children:[`路网`,h.length>0?` (${h.length})`:``]})]}),d&&(0,p.jsxs)(`div`,{ref:b,className:`mapbox-road-highlight-control__panel`,children:[(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control__panel-header`,children:[(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__panel-title`,children:`道路类型`}),(0,p.jsx)(m.Checkbox,{checked:h.length===E.length,indeterminate:h.length>0&&h.length<E.length,onChange:O,style:{"--color-text-1":`#fff`,"--color-border-2":`rgba(255, 255, 255, 0.3)`},children:(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__type-label`,children:`全选`})})]}),(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__scroll`,children:(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__type-list`,children:E.map(e=>(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control__type-item`,onClick:()=>D(e.class,!h.includes(e.class)),children:[(0,p.jsx)(m.Checkbox,{checked:h.includes(e.class),onChange:t=>D(e.class,t),onClick:e=>e.stopPropagation(),style:{"--color-text-1":`#fff`,"--color-border-2":`rgba(255, 255, 255, 0.3)`,marginRight:0,flexShrink:0}}),(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__color-indicator`,style:{backgroundColor:e.color}}),(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__type-label`,children:e.label})]},e.class))})}),(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__tip`,children:`💡 选中道路类型后立即显示高亮`}),!_&&(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__warning`,children:`⚠️ 正在初始化图层...`})]})]})}var je=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1773733446763'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='1802'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M110.34624%20352.01024a30.72%2030.72%200%201%200%2061.44%200v-38.46144h680.42752v38.5024a30.72%2030.72%200%200%200%2061.44%200V213.72928a30.72%2030.72%200%200%200-61.44%200v38.33856H171.78624v-38.33856a30.72%2030.72%200%200%200-61.44%200v138.28096z%20m34.816%20127.22176a34.816%2034.816%200%200%200-34.816%2034.816v312.60672c0%2019.2512%2015.5648%2034.816%2034.816%2034.816h733.5936c19.2512%200%2034.816-15.5648%2034.816-34.816V514.048a34.816%2034.816%200%200%200-34.816-34.816H145.2032z%20m26.624%20320.79872V540.672h680.3456v259.35872H171.8272z'%20fill='white'%20p-id='1804'%3e%3c/path%3e%3c/svg%3e`,Me=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='192'%20y='192'%20width='640'%20height='640'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,Ne=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='160'%20y='240'%20width='704'%20height='544'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,Pe=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3ccircle%20cx='512'%20cy='512'%20r='384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,Fe=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolygon%20points='512,128%20864,384%20736,800%20288,800%20160,384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'/%3e%3c/svg%3e`,Ie=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolyline%20points='160,768%20384,256%20640,576%20864,192'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'%20stroke-linecap='round'/%3e%3c/svg%3e`,Le=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`,Re={square:`正方形`,rectangle:`矩形`,circle:`圆形`,polygon:`多边形`,polyline:`折线`},ze=[{mode:`square`,icon:Me,label:`正方形`},{mode:`rectangle`,icon:Ne,label:`矩形`},{mode:`circle`,icon:Pe,label:`圆形`},{mode:`polygon`,icon:Fe,label:`多边形`},{mode:`polyline`,icon:Ie,label:`折线`}];function H(e,t){let[n,r]=e,[i,a]=t,o=(a-r)*Math.PI/180,s=(i-n)*Math.PI/180,c=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function Be(e,t,n=64){let[r,i]=e,a=[],o=t/6371e3,s=i*Math.PI/180;for(let e=0;e<=n;e++){let t=e/n*2*Math.PI,c=o*Math.cos(t),l=o*Math.sin(t)/Math.cos(s);a.push([r+l*180/Math.PI,i+c*180/Math.PI])}return a}function Ve(e,t){let[n,r]=e,i=t/2/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r+o],[n+s,r+o],[n+s,r-o],[n-s,r-o],[n-s,r+o]]}function He(e){if(e.type===`circle`)return A(Math.PI*e.radius*e.radius);if(e.type===`square`)return A(e.length*e.length);if(e.type===`rectangle`){let[[t,n],[r,i]]=e.bounds,a=[Math.min(t,r),Math.max(n,i)],o=[Math.max(t,r),Math.max(n,i)],s=[Math.max(t,r),Math.min(n,i)],c=O(a,o),l=O(o,s);return A(c*l)}if(e.type===`polygon`){let t=[...e.coordinates,e.coordinates[0]];return A(ee(t))}}function Ue(e){if(e.type===`circle`)return j(e.radius);if(e.type===`square`)return j(e.length);if(e.type===`rectangle`){let[[t,n],[r,i]]=e.bounds,a=[Math.min(t,r),Math.max(n,i)],o=[Math.max(t,r),Math.max(n,i)],s=[Math.max(t,r),Math.min(n,i)],c=O(a,o),l=O(o,s);return j(2*(c+l))}if(e.type===`polygon`){let t=0,n=e.coordinates;for(let e=0;e<n.length;e++)t+=O(n[e],n[(e+1)%n.length]);return j(t)}if(e.type===`polyline`){let t=0;for(let n=0;n<e.coordinates.length-1;n++)t+=O(e.coordinates[n],e.coordinates[n+1]);return j(t)}}var U=`measure-`;function W(e,t){e.getSource(t)||e.addSource(t,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}})}function We(e,t){let n=e.getSource(t);n&&n.setData({type:`FeatureCollection`,features:[]})}function G(e){if(!e.getStyle().glyphs){let t=e.style,n=`/gis-fonts/{fontstack}/{range}.pbf`;t.glyphs=n,t.stylesheet&&(t.stylesheet.glyphs=n)}}function Ge(e){G(e);for(let t of[`rect`,`circle`,`square`,`polygon`]){let n=`${U}${t}-preview-source`,r=`${U}${t}-preview-fill`,i=`${U}${t}-preview-line`,a=`${U}${t}-preview-measure-source`,o=`${U}${t}-preview-measure-label`;W(e,n),e.getLayer(r)||e.addLayer({id:r,type:`fill`,source:n,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.getLayer(i)||e.addLayer({id:i,type:`line`,source:n,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),W(e,a),e.getLayer(o)||e.addLayer({id:o,type:`symbol`,source:a,filter:[`==`,`$type`,`Point`],layout:{"text-field":[`get`,`label`],"text-size":12,"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-allow-overlap":!0,"text-offset":[0,-.8]},paint:{"text-color":`#ffffff`,"text-halo-color":`rgba(0,0,0,0.8)`,"text-halo-width":1}})}let t=`${U}polyline-preview-source`,n=`${U}polyline-preview-line`,r=`${U}polyline-vertices-source`,i=`${U}polyline-vertices`,a=`${U}polyline-preview-measure-source`,o=`${U}polyline-preview-measure-label`;W(e,t),e.getLayer(n)||e.addLayer({id:n,type:`line`,source:t,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),W(e,r),e.getLayer(i)||e.addLayer({id:i,type:`circle`,source:r,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}}),W(e,a),e.getLayer(o)||e.addLayer({id:o,type:`symbol`,source:a,filter:[`==`,`$type`,`Point`],layout:{"text-field":[`get`,`label`],"text-size":12,"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-allow-overlap":!0,"text-offset":[0,-.8]},paint:{"text-color":`#ffffff`,"text-halo-color":`rgba(0,0,0,0.8)`,"text-halo-width":1}});let s=`${U}polygon-vertices-source`,c=`${U}polygon-vertices`;W(e,s),e.getLayer(c)||e.addLayer({id:c,type:`circle`,source:s,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}});let l=`${U}circle-radius-source`,u=`${U}circle-radius-line`;W(e,l),e.getLayer(u)||e.addLayer({id:u,type:`line`,source:l,paint:{"line-color":`#ffffff`,"line-width":1,"line-dasharray":[4,4]}})}function K(e){for(let t of[`rect-preview-source`,`rect-preview-measure-source`,`circle-preview-source`,`circle-preview-measure-source`,`circle-radius-source`,`square-preview-source`,`square-preview-measure-source`,`polygon-preview-source`,`polygon-preview-measure-source`,`polygon-vertices-source`,`polyline-preview-source`,`polyline-preview-measure-source`,`polyline-vertices-source`])We(e,`${U}${t}`)}function Ke({map:e,entityConfig:t,onEntityConfigChange:n,onDrawModeChange:r,className:i=``,style:a}){let[o,s]=(0,c.useState)(!1),[l,u]=(0,c.useState)(null),[d,f]=(0,c.useState)({showArea:!0,showLength:!0,showRadius:!0}),h=t!==void 0,g=h?{showArea:t.showArea??!0,showLength:t.showLength??!0,showRadius:t.showRadius??!0}:d,[_,v]=(0,c.useState)([]),y=(0,c.useRef)(new Map),b=(0,c.useRef)(0),x=(0,c.useRef)(null),C=(0,c.useRef)(null),w=(0,c.useRef)(null),T=(0,c.useRef)(null),E=(0,c.useRef)(null),k=(0,c.useRef)([]),M=(0,c.useRef)([]),te=(0,c.useRef)(g);te.current=g;let ne=(0,c.useRef)(l);ne.current=l;let N=(0,c.useCallback)(()=>`measure-${++b.current}`,[]);(0,c.useEffect)(()=>{r?.(l!==null)},[l,r]);let P=(0,c.useRef)(!1),re=(0,c.useCallback)(()=>{!e||!e.isStyleLoaded()||(Ge(e),P.current=!0)},[e]);(0,c.useEffect)(()=>{if(!e)return;let t=()=>{Ge(e),P.current=!0};e.isStyleLoaded()?t():e.once(`load`,t);let n=()=>{P.current=!1};return e.on(`style.load`,n),()=>{e.off(`style.load`,n)}},[e]),(0,c.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&C.current&&!C.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let ie=(0,c.useCallback)(t=>{if(!e)return;let n=S(t,te.current),r=null;if(n.type===`circle`?r=new he(e,n):n.type===`square`?r=new ye(e,n):n.type===`rectangle`?r=new xe(e,n):n.type===`polygon`?r=new fe(e,n):n.type===`polyline`&&(r=new pe(e,n)),r){y.current.set(n.id,r);let e={entity:n,shapeLabel:Re[n.type]||n.type,area:He(n),lengthOrRadius:Ue(n)};v(t=>[...t,e])}},[e]),ae=(0,c.useCallback)(e=>{let t=y.current.get(e);t&&(t.destroy(),y.current.delete(e)),v(t=>t.filter(t=>t.entity.id!==e))},[]),F=(0,c.useCallback)(()=>{y.current.forEach(e=>e.destroy()),y.current.clear(),v([])},[]),I=(0,c.useCallback)(t=>{if(!e)return;let n=y.current.get(t);if(!n)return;let r=n.getBounds();e.fitBounds(r,{padding:80,maxZoom:18,duration:1e3})},[e]),oe=(0,c.useCallback)((e,t)=>{let r={...te.current,[e]:t};h?n?.({...r}):f(r),v(t=>t.map(t=>{let n={...t.entity};n[e]=void 0;let i=S(n,r),a=y.current.get(t.entity.id);return a&&a.update(i),{...t,entity:i}}))},[h,n]),se=(0,c.useCallback)((t,n)=>{if(!e)return;let[r,i]=t,[a,o]=n,s=[[Math.min(r,a),Math.max(i,o)],[Math.max(r,a),Math.max(i,o)],[Math.max(r,a),Math.min(i,o)],[Math.min(r,a),Math.min(i,o)],[Math.min(r,a),Math.max(i,o)]],c=e.getSource(`${U}rect-preview-source`);c&&c.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[s]},properties:{}});let l=e.getSource(`${U}rect-preview-measure-source`);if(l){let e=te.current,t=[],n=s[0],r=s[1],i=s[2];if(e?.showArea){let e=O(n,r),a=O(r,i);t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:A(e*a)}})}e?.showLength&&(t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+r[0])/2,(n[1]+r[1])/2]},properties:{label:j(O(n,r))}}),t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(r[0]+i[0])/2,(r[1]+i[1])/2]},properties:{label:j(O(r,i))}})),l.setData({type:`FeatureCollection`,features:t})}},[e]),ce=(0,c.useCallback)((t,n)=>{if(!e)return;let r=H(t,n),i=Be(t,r),a=e.getSource(`${U}circle-preview-source`);a&&a.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[i]},properties:{}});let o=te.current,s=[],c=[];if(o?.showArea&&s.push({type:`Feature`,geometry:{type:`Point`,coordinates:t},properties:{label:A(Math.PI*r*r)}}),o?.showRadius){let e=D(t,r,90),n=[(t[0]+e[0])/2,(t[1]+e[1])/2];c.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[t,e]},properties:{}}),s.push({type:`Feature`,geometry:{type:`Point`,coordinates:n},properties:{label:j(r)}})}let l=e.getSource(`${U}circle-preview-measure-source`);l&&l.setData({type:`FeatureCollection`,features:s});let u=e.getSource(`${U}circle-radius-source`);u&&u.setData({type:`FeatureCollection`,features:c})},[e]),le=(0,c.useCallback)((t,n)=>{if(!e)return;let r=H(t,n)*2,i=Ve(t,r),a=e.getSource(`${U}square-preview-source`);a&&a.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[i]},properties:{}});let o=e.getSource(`${U}square-preview-measure-source`);if(o){let e=te.current,n=[];if(e?.showArea&&n.push({type:`Feature`,geometry:{type:`Point`,coordinates:t},properties:{label:A(r*r)}}),e?.showLength){let e=[(i[1][0]+i[2][0])/2,(i[1][1]+i[2][1])/2];n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:j(r)}})}o.setData({type:`FeatureCollection`,features:n})}},[e]),ue=(0,c.useCallback)((t,n)=>{if(!e)return;let r=[...t,n],i=e.getSource(`${U}polygon-preview-source`);i&&(r.length>=3?i.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[[...r,r[0]]]},properties:{}}):r.length===2?i.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:r},properties:{}}):i.setData({type:`FeatureCollection`,features:[]}));let a=e.getSource(`${U}polygon-vertices-source`);a&&a.setData({type:`FeatureCollection`,features:t.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=e.getSource(`${U}polygon-preview-measure-source`);if(o){let e=te.current,t=[];if(e?.showArea&&r.length>=3){let e=ee([...r,r[0]]),n=0,i=0;for(let e of r)n+=e[0],i+=e[1];n/=r.length,i/=r.length,t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[n,i]},properties:{label:A(e)}})}if(e?.showLength&&r.length>=2){for(let e=0;e<r.length-1;e++){let n=r[e],i=r[e+1];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:j(O(n,i))}})}if(r.length>=3){let e=r[r.length-1],n=r[0];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(e[0]+n[0])/2,(e[1]+n[1])/2]},properties:{label:j(O(e,n))}})}}o.setData({type:`FeatureCollection`,features:t})}},[e]),de=(0,c.useCallback)((t,n)=>{if(!e)return;let r=[...t,n],i=e.getSource(`${U}polyline-preview-source`);i&&(r.length>=2?i.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:r},properties:{}}):i.setData({type:`FeatureCollection`,features:[]}));let a=e.getSource(`${U}polyline-vertices-source`);a&&a.setData({type:`FeatureCollection`,features:t.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=e.getSource(`${U}polyline-preview-measure-source`);if(o){let e=te.current,t=[];if(e?.showLength&&r.length>=2)for(let e=0;e<r.length-1;e++){let n=r[e],i=r[e+1];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:j(O(n,i))}})}o.setData({type:`FeatureCollection`,features:t})}},[e]);(0,c.useEffect)(()=>{if(!e||!l)return;re(),e.getCanvas().style.cursor=`crosshair`;let t=t=>{let n=[t.lngLat.lng,t.lngLat.lat],r=ne.current;if(r===`rectangle`){let t=w.current;if(!t)w.current=n;else{let r={id:N(),type:`rectangle`,bounds:[t,n]};ie(r),w.current=null,K(e),u(null)}}else if(r===`circle`){let t=T.current;if(!t)T.current={center:n};else{let r=H(t.center,n),i={id:N(),type:`circle`,center:t.center,radius:r};ie(i),T.current=null,K(e),u(null)}}else if(r===`square`){let t=E.current;if(!t)E.current={center:n};else{let r=H(t.center,n)*2,i={id:N(),type:`square`,center:t.center,length:r};ie(i),E.current=null,K(e),u(null)}}else if(r===`polygon`){let t=k.current;if(t.length>=3&&H(t[0],n)<20){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],K(e),u(null);return}k.current=[...t,n]}else r===`polyline`&&(M.current=[...M.current,n])},n=e=>{let t=[e.lngLat.lng,e.lngLat.lat],n=ne.current;if(n===`rectangle`&&w.current)se(w.current,t);else if(n===`circle`&&T.current)ce(T.current.center,t);else if(n===`square`&&E.current)le(E.current.center,t);else if(n===`polygon`){let e=k.current;e.length>0&&ue(e,t)}else if(n===`polyline`){let e=M.current;e.length>0&&de(e,t)}},r=t=>{t.preventDefault();let n=ne.current;if(n===`polygon`){let t=k.current;if(t.length>=3){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],K(e),u(null)}else k.current=[],K(e)}else if(n===`polyline`){let t=M.current;if(t.length>=2){let n={id:N(),type:`polyline`,coordinates:[...t]};ie(n),M.current=[],K(e),u(null)}else M.current=[],K(e)}},i=t=>{t.key===`Escape`&&(w.current=null,T.current=null,E.current=null,k.current=[],M.current=[],K(e),u(null))},a=t=>{t.preventDefault();let n=ne.current;if(n===`polygon`){let t=k.current;if(t.length>=3){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],K(e),u(null)}}else if(n===`polyline`){let t=M.current;if(t.length>=2){let n={id:N(),type:`polyline`,coordinates:[...t]};ie(n),M.current=[],K(e),u(null)}}};return e.doubleClickZoom.disable(),e.on(`click`,t),e.on(`mousemove`,n),e.on(`contextmenu`,r),e.on(`dblclick`,a),document.addEventListener(`keydown`,i),()=>{e.off(`click`,t),e.off(`mousemove`,n),e.off(`contextmenu`,r),e.off(`dblclick`,a),document.removeEventListener(`keydown`,i),e.getCanvas().style.cursor=``,e.doubleClickZoom.enable(),K(e)}},[e,l,N,ie,re,se,ce,le,ue,de]),(0,c.useEffect)(()=>()=>{y.current.forEach(e=>e.destroy()),y.current.clear()},[]);let me=(0,c.useCallback)(t=>{u(e=>e===t?null:t),w.current=null,T.current=null,E.current=null,k.current=[],M.current=[],e&&K(e)},[e]);return e?(0,p.jsxs)(`div`,{className:`mapbox-measure-control ${i}`,style:a,children:[(0,p.jsxs)(`button`,{ref:C,className:`mapbox-control-btn mapbox-measure-control__btn ${o?`mapbox-measure-control__btn--active`:``}`,onClick:()=>s(!o),title:`测量`,children:[(0,p.jsx)(`img`,{src:je,alt:`measure`,className:`mapbox-measure-control__btn-icon`}),(0,p.jsx)(`span`,{children:`测量`}),_.length>0&&(0,p.jsxs)(`span`,{children:[`(`,_.length,`)`]})]}),o&&(0,p.jsxs)(`div`,{ref:x,className:`mapbox-measure-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-measure-control__section-title`,children:`显示设置`}),(0,p.jsxs)(`div`,{className:`mapbox-measure-control__settings`,children:[(0,p.jsx)(m.Checkbox,{checked:g.showArea,onChange:e=>oe(`showArea`,e),children:`面积`}),(0,p.jsx)(m.Checkbox,{checked:g.showLength,onChange:e=>oe(`showLength`,e),children:`长度`}),(0,p.jsx)(m.Checkbox,{checked:g.showRadius,onChange:e=>oe(`showRadius`,e),children:`半径`})]}),(0,p.jsx)(`div`,{className:`mapbox-measure-control__section-title`,children:`绘制工具`}),(0,p.jsxs)(`div`,{className:`mapbox-measure-control__tools`,children:[ze.map(e=>(0,p.jsx)(`button`,{className:`mapbox-measure-control__tool-btn ${l===e.mode?`mapbox-measure-control__tool-btn--active`:``}`,onClick:()=>me(e.mode),title:e.label,children:(0,p.jsx)(`img`,{src:e.icon,alt:e.label})},e.mode)),_.length>0&&(0,p.jsx)(`button`,{className:`mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger`,onClick:F,title:`清除全部`,children:(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`,alt:`clear`})})]}),_.length>0?(0,p.jsx)(`div`,{className:`mapbox-measure-control__list`,children:(0,p.jsxs)(`table`,{className:`mapbox-measure-control__table`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`类型`}),(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`面积`}),(0,p.jsx)(`th`,{children:`长度/半径`}),(0,p.jsx)(`th`,{})]})}),(0,p.jsx)(`tbody`,{children:_.map(e=>(0,p.jsxs)(`tr`,{className:`mapbox-measure-control__table-row`,onClick:()=>I(e.entity.id),children:[(0,p.jsx)(`td`,{children:e.shapeLabel}),(0,p.jsx)(`td`,{children:String(e.entity.id)}),(0,p.jsx)(`td`,{children:e.area??`-`}),(0,p.jsx)(`td`,{children:e.lengthOrRadius??`-`}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`button`,{className:`mapbox-measure-control__delete-btn`,onClick:t=>{t.stopPropagation(),ae(e.entity.id)},title:`删除`,children:(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`,alt:`delete`})})})]},String(e.entity.id)))})]})}):(0,p.jsx)(`div`,{className:`mapbox-measure-control__empty`,children:`选择工具后在地图上点击绘制`})]})]}):null}var q=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1773803353422'%20class='icon'%20viewBox='0%200%201028%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6757'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128.5'%20height='128'%3e%3cpath%20d='M835.073959%20357.94044V345.56192a345.170251%20345.170251%200%201%200-686.690426%2049.672777A345.090902%20345.090902%200%200%200%20523.706588%20974.009826a345.090902%20345.090902%200%201%200%20311.049973-616.069386zM490.141757%2048.001359a297.877959%20297.877959%200%200%201%20297.560561%20297.560561c0%207.934948%200%2016.345994-1.031543%2025.074437A297.639911%20297.639911%200%200%201%20490.141757%20643.122482h-15.869897a289.943011%20289.943011%200%200%201-104.106522-24.757039A297.481212%20297.481212%200%200%201%20490.141757%2048.001359zM345.170251%20976.39031a297.560561%20297.560561%200%200%201-185.281043-530.371944c0%201.031543%200.714145%202.142436%201.031544%203.253328s1.50764%204.522921%202.301135%206.824056c1.269592%203.888125%202.697882%207.934948%204.126173%2011.743724%200.952194%202.301135%201.825038%204.60227%202.697882%206.903405%201.58699%203.808775%203.253329%207.934948%204.919668%2011.505675%200.952194%202.142436%201.904388%204.284872%202.935931%206.347958%201.983737%204.284872%204.126173%208.490395%206.268609%2012.695918l2.380485%204.60227c3.01528%205.633813%206.268609%2011.108928%209.601287%2016.504692%200.793495%201.428291%201.745689%202.777232%202.618533%204.126173%202.539183%204.046824%205.157716%207.934948%207.934948%2011.981772l4.205523%205.792512c2.380484%203.253329%204.760969%206.506658%207.220803%209.680637l4.840318%206.030561c2.459834%203.01528%204.999017%205.951211%207.538201%208.887142l5.157717%205.792512c2.777232%203.01528%205.633813%205.951211%208.569744%208.887142l4.840318%204.999018c4.205523%204.046824%208.411045%207.934948%2012.775267%2011.823073l3.09463%202.618533c4.205523%203.650076%208.490395%207.220803%2012.854616%2010.63283l5.713163%204.205523c3.332678%202.459834%206.586007%204.919668%209.998035%207.220803l6.506657%204.364222q4.999017%203.332678%209.998035%206.427308c2.221786%201.348941%204.443571%202.697882%206.744706%203.967474%203.570727%202.142436%207.300152%204.126173%2010.950229%206.10991l6.18926%203.253329%202.301135%201.269592v12.378519c0%207.379502%200%2014.759004%200.793494%2021.979807%200%202.459834%200.396747%204.840318%200.634796%207.220803%200%204.840318%200.793495%209.759986%201.428291%2014.600305%200%202.777232%200.872844%205.554464%201.269592%208.411045%200.714145%204.364222%201.428291%208.728443%202.221785%2013.013315%200.555446%202.935931%201.190242%205.871862%201.825038%208.728443%200.952194%204.205523%201.904388%207.934948%203.015281%2012.457869s1.50764%205.871862%202.380484%208.728443%202.380484%207.934948%203.729426%2012.140471c0.952194%202.856581%201.825038%205.633813%202.856581%208.490395%201.428291%204.046824%203.01528%207.934948%204.60227%2012.061121%201.110893%202.618533%202.142436%205.316415%203.253329%207.934948%201.825038%204.284872%203.729426%208.411045%205.713163%2012.537219%201.110893%202.301135%202.142436%204.681619%203.332678%206.903405%202.618533%205.316415%205.475114%2010.474132%208.411045%2015.869896%200.555446%201.110893%201.110893%202.221786%201.745689%203.332679%203.570727%206.10991%207.379502%2012.061121%2011.346976%2018.012332%201.269592%201.904388%202.697882%203.808775%204.046824%205.713163%202.777232%203.967474%205.475114%207.934948%208.411045%2011.664374%201.745689%202.301135%203.570727%204.443571%205.395765%206.744706s5.316415%206.586007%207.934948%209.839336%204.046824%204.60227%206.10991%206.824056%205.633813%206.030561%208.490395%209.045841l6.744706%206.586007c2.935931%202.856581%205.871862%205.633813%208.966492%207.934948s4.681619%204.205523%207.062104%206.268609%206.427308%205.316415%209.759986%207.934948%204.760969%203.888125%207.300152%205.713163l2.380485%201.904388A295.894222%20295.894222%200%200%201%20345.170251%20976.39031z%20m335.965711-11.981772a296.608368%20296.608368%200%200%201-146.479145-38.563848c-5.792512-3.332678-11.426326-6.744706-16.90144-10.315433-1.825038-1.190242-3.491377-2.539183-5.237066-3.729426-3.650076-2.459834-7.300152-4.999017-10.79153-7.934948-2.063087-1.50764-3.967474-3.173979-5.871862-4.760969-3.173979-2.459834-6.268609-4.919668-9.283889-7.934949s-3.967474-3.650076-5.951211-5.475114-5.633813-5.078367-7.934949-7.934948-3.808775-4.046824-5.792512-6.10991-5.078367-5.157716-7.458851-7.934949l-5.554464-6.506657c-1.825038-2.142436-4.60227-5.475114-6.824056-7.934949s-3.412028-4.681619-5.157716-7.062104-4.205523-5.633813-6.10991-8.490394-3.253329-4.999017-4.840319-7.458852-3.729426-5.792512-5.475114-8.807792-2.935931-5.157716-4.364222-7.934949-3.332678-6.030561-4.919668-9.045841-2.539183-5.395765-3.808775-7.934948-2.935931-6.18926-4.284872-9.363239-2.301135-5.554464-3.412028-8.411045-2.459834-6.268609-3.570726-9.521938-1.983737-5.792512-2.856582-8.649094-2.063087-6.506658-3.01528-9.759986-1.58699-5.951211-2.301135-8.887142-1.666339-6.586007-2.380485-9.918686S388.812467%20722.471965%20388.812467%20719.536034s-1.190242-6.665357-1.666339-9.998035-0.793495-6.18926-1.110893-9.28389-0.793495-6.824056-1.031543-10.236083%200-6.268609-0.555447-9.363239v-6.665357h0.396748l2.142436%200.634796c4.364222%201.428291%208.807793%202.697882%2013.251363%203.967474l4.840319%201.269592%2011.505675%202.697883%204.52292%201.031543c5.237066%201.031543%2010.474132%201.983737%2015.869897%202.856581h1.348941c4.840318%200.793495%209.759986%201.348941%2014.600305%201.904388l4.919668%200.476097q5.951211%200.634796%2011.902422%200.952194H490.855902a344.456106%20344.456106%200%200%200%20183.138607-52.529358c5.395765-3.412028%2010.71218-7.062104%2015.869896-10.71218%201.745689-1.190242%203.332678-2.539183%205.078367-3.729426%203.412028-2.539183%206.903405-5.157716%2010.236084-7.934948l5.713162-4.760969c3.01528-2.459834%206.030561-4.999017%208.966492-7.934949l5.633813-5.237066c2.856581-2.618533%205.554464-5.237066%207.934949-7.934948l5.475114-5.633813c2.618533-2.697882%205.237066-5.475114%207.934948-8.331696l5.078367-5.713163%207.458851-9.045841%204.522921-5.633813%207.934948-10.315433%203.570727-4.999017c3.173979-4.60227%206.268609-9.363239%209.20454-14.203558l1.031543-1.586989c3.332678-5.475114%206.506658-11.029578%209.601288-16.663392%200.634796-1.190242%201.190242-2.380484%201.745688-3.570727%202.301135-4.443571%204.60227-8.887142%206.665357-13.410062%200.872844-1.825038%201.666339-3.729426%202.539183-5.554464%201.745689-3.967474%203.491377-7.934948%205.078367-11.902422%200.793495-2.063087%201.58699-4.205523%202.459834-6.347959%201.428291-3.808775%202.856581-7.934948%204.126173-11.505675%200.793495-2.221786%201.50764-4.522921%202.221786-6.744706%201.190242-3.808775%202.380484-7.934948%203.491377-11.585025%200.634796-2.301135%201.269592-4.60227%201.825038-6.903405%201.031543-3.967474%201.904388-7.934948%202.777232-11.902422%200.555446-2.301135%201.031543-4.522921%201.50764-6.824056%200-1.031543%200.476097-2.142436%200.634796-3.173979a297.560561%20297.560561%200%200%201-148.304183%20555.446381z'%20fill='%23ffffff'%20p-id='6758'%3e%3c/path%3e%3c/svg%3e`,J={brightness:1,saturation:0,contrast:0,hueRotate:0},qe=[{key:`brightness`,label:`亮度`,min:0,max:1,step:.01},{key:`saturation`,label:`饱和度`,min:-1,max:1,step:.01},{key:`contrast`,label:`对比度`,min:-1,max:1,step:.01},{key:`hueRotate`,label:`色相`,min:0,max:360,step:1}];function Je({map:e,value:t,onChange:n,rasterPaintLayerIds:r=[],className:i,style:a}){let[o,s]=(0,c.useState)(!1),[l,u]=(0,c.useState)({...J}),d=(0,c.useRef)(null),f=(0,c.useRef)(null),h=t!==void 0;(0,c.useEffect)(()=>{let e=e=>{d.current&&!d.current.contains(e.target)&&f.current&&!f.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let g=(0,c.useMemo)(()=>h?{brightness:t.brightness??J.brightness,saturation:t.saturation??J.saturation,contrast:t.contrast??J.contrast,hueRotate:t.hueRotate??J.hueRotate}:l,[h,t,l]),_=(0,c.useRef)(h);(0,c.useEffect)(()=>{h&&!_.current&&u({...g}),_.current=h},[h,g]);let v=(0,c.useCallback)(t=>{if(!(!e||r.length===0))for(let n of r)e.getLayer(n)&&(e.setPaintProperty(n,`raster-brightness-min`,0),e.setPaintProperty(n,`raster-brightness-max`,t.brightness),e.setPaintProperty(n,`raster-saturation`,t.saturation),e.setPaintProperty(n,`raster-contrast`,t.contrast),e.setPaintProperty(n,`raster-hue-rotate`,t.hueRotate))},[e,r]),y=(0,c.useCallback)((e,t)=>{if(h)n?.({...g,[e]:t});else{let n={...l,[e]:t};u(n),v(n)}},[h,n,g,l,v]),b=(0,c.useCallback)(()=>{h?n?.({...J}):(u({...J}),v({...J}))},[h,n,v]);(0,c.useEffect)(()=>{!h&&r.length>0&&v(l)},[r,h,v,l]);let x=(e,t)=>e===`hueRotate`?`${Math.round(t)}°`:t.toFixed(2);return(0,p.jsxs)(`div`,{className:`mapbox-raster-paint-control${i?` ${i}`:``}`,style:a,children:[(0,p.jsxs)(`button`,{ref:f,className:`mapbox-control-btn mapbox-raster-paint-control__btn${o?` mapbox-raster-paint-control__btn--active`:``}`,onClick:()=>s(!o),title:`栅格渲染调节`,children:[(0,p.jsx)(`img`,{className:`mapbox-control-btn__icon mapbox-raster-paint-control__btn-icon`,src:q,alt:`raster paint`}),(0,p.jsx)(`span`,{children:`渲染`})]}),o&&(0,p.jsxs)(`div`,{ref:d,className:`mapbox-raster-paint-control__panel`,children:[qe.map(({key:e,label:t,min:n,max:r,step:i})=>(0,p.jsxs)(`div`,{className:`mapbox-raster-paint-control__slider-row`,children:[(0,p.jsx)(`span`,{className:`mapbox-raster-paint-control__label`,children:t}),(0,p.jsx)(m.Slider,{className:`mapbox-raster-paint-control__slider`,min:n,max:r,step:i,value:g[e],onChange:t=>y(e,t),tooltipVisible:!1}),(0,p.jsx)(`span`,{className:`mapbox-raster-paint-control__value`,children:x(e,g[e])})]},e)),(0,p.jsx)(`button`,{className:`mapbox-raster-paint-control__reset`,onClick:b,children:`重置`})]})]})}var Y=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769397418113'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='10253'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M755.4048%20217.2928A348.3648%20348.3648%200%200%200%20512%20119.3472a348.3136%20348.3136%200%200%200-243.3536%2097.8944%20328.4992%20328.4992%200%200%200-100.864%20236.3392c0%2049.408%2011.7248%2095.744%2032%20137.728a378.0096%20378.0096%200%200%200%2091.136%20118.4256l203.5712%20179.456%2017.5104%2015.4624%2017.5104-15.4624%20203.4176-179.3536a378.6752%20378.6752%200%200%200%2091.2384-118.4768c20.2752-41.984%2032.0512-88.32%2032.0512-137.7792a328.448%20328.448%200%200%200-100.8128-236.288z%20m24.1152%20353.3824a329.216%20329.216%200%200%201-79.872%20103.0656l-188.0064%20164.6592-187.1872-164.7616a329.0624%20329.0624%200%200%201-79.7696-103.0144%20267.0592%20267.0592%200%200%201-27.136-117.0944c0-78.7968%2032.9728-150.1184%2086.272-201.728a298.3936%20298.3936%200%200%201%20208.2816-83.5584c81.3056%200%20154.9824%2031.9488%20208.2304%2083.6096a279.9104%20279.9104%200%200%201%2086.272%20201.728%20266.496%20266.496%200%200%201-27.0848%20117.0944z%20m-164.1472-212.1728l0.0512-0.0512a146.9952%20146.9952%200%200%200-104.2432-43.2128c-40.6528%200-77.568%2016.5376-104.2432%2043.2128l0.0512%200.0512a147.3536%20147.3536%200%200%200-0.0512%20208.6912%20147.0464%20147.0464%200%200%200%20208.4864%200%20147.5072%20147.5072%200%200%200-0.0512-208.6912z%20m-34.1504%20174.2336a97.536%2097.536%200%200%201-69.2736%2028.7232%2097.6384%2097.6384%200%200%201-69.3248-28.7232%2097.792%2097.792%200%200%201-0.1536-138.4448h0.1024a97.9456%2097.9456%200%200%201%20138.5984%200h0.1536c17.664%2017.6128%2028.5696%2042.1376%2028.5696%2069.2224a97.1776%2097.1776%200%200%201-28.672%2069.2224z'%20fill='%23ffffff'%20p-id='10254'%3e%3c/path%3e%3c/svg%3e`;const Ye=({markerTemplates:e,selectedTemplate:t,onTemplateSelect:n,drawMode:r,onDrawModeChange:i,showRectangleTool:a=!1,showCircleTool:o=!1,showPolygonTool:s=!1,showSquareTool:l=!1,showPolylineTool:u=!1})=>{let[d,f]=(0,c.useState)(!1),m=(0,c.useRef)(null);(0,c.useEffect)(()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&f(!1)};if(d)return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[d]);let h=e=>{t?.id===e.id?(n(null),i(null)):(n(e),i(`marker`)),f(!1)},g=()=>{r===`rectangle`?i(null):(n(null),i(`rectangle`))},_=()=>{r===`circle`?i(null):(n(null),i(`circle`))},v=()=>{r===`polygon`?i(null):(n(null),i(`polygon`))},y=()=>{r===`square`?i(null):(n(null),i(`square`))},b=()=>{r===`polyline`?i(null):(n(null),i(`polyline`))},x=()=>{(r===`rectangle`||r===`circle`||r===`polygon`||r===`square`||r===`polyline`)&&i(null),f(!d)},S=e=>e.size?{width:e.size,height:e.size}:{width:e.width||32,height:e.height||32},C=d||t,w=r===`rectangle`,T=r===`circle`,E=r===`polygon`,D=r===`square`,O=r===`polyline`;return(0,p.jsxs)(`div`,{ref:m,className:`mapbox-edit-control`,children:[(0,p.jsxs)(`div`,{className:`mapbox-edit-control__btn-group`,children:[(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${C?`mapbox-control-btn--active`:``}`,onClick:x,title:`Marker`,children:[t?(0,p.jsx)(`img`,{src:t.icon,alt:t.name,className:`mapbox-edit-control__btn-icon`}):(0,p.jsx)(`img`,{src:Y,alt:`marker`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:t?t.name:`Marker`})]}),l&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${D?`mapbox-control-btn--active`:``}`,onClick:y,title:`绘制正方形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='192'%20y='192'%20width='640'%20height='640'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`square`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`正方形`})]}),a&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${w?`mapbox-control-btn--active`:``}`,onClick:g,title:`绘制矩形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='160'%20y='240'%20width='704'%20height='544'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`rectangle`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`矩形`})]}),o&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${T?`mapbox-control-btn--active`:``}`,onClick:_,title:`绘制圆形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3ccircle%20cx='512'%20cy='512'%20r='384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`circle`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`圆形`})]}),s&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${E?`mapbox-control-btn--active`:``}`,onClick:v,title:`绘制多边形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolygon%20points='512,128%20864,384%20736,800%20288,800%20160,384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'/%3e%3c/svg%3e`,alt:`polygon`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`多边形`})]}),u&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${O?`mapbox-control-btn--active`:``}`,onClick:b,title:`绘制折线`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolyline%20points='160,768%20384,256%20640,576%20864,192'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'%20stroke-linecap='round'/%3e%3c/svg%3e`,alt:`polyline`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`折线`})]})]}),d&&(0,p.jsxs)(`div`,{className:`mapbox-edit-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-edit-control__panel-header`,children:`选择 Marker`}),(0,p.jsx)(`div`,{className:`mapbox-edit-control__template-list`,children:e.map(e=>{let n=S(e),r=t?.id===e.id;return(0,p.jsxs)(`div`,{className:`mapbox-edit-control__template-item ${r?`mapbox-edit-control__template-item--selected`:``}`,onClick:()=>h(e),title:e.name,children:[(0,p.jsx)(`img`,{src:e.icon,alt:e.name,className:`mapbox-edit-control__template-icon`,style:{width:Math.min(n.width,24),height:Math.min(n.height,24)}}),(0,p.jsx)(`span`,{className:`mapbox-edit-control__template-name`,children:e.name})]},e.id)})})]})]})},Xe=({menuState:e,onClose:t,portalContainer:n,menuRef:r})=>{let i=(0,c.useRef)(null);(0,c.useEffect)(()=>(r&&(r.current=i.current),()=>{r&&(r.current=null)}));let a=(0,c.useCallback)(e=>{i.current&&!i.current.contains(e.target)&&t()},[t]),o=(0,c.useCallback)(e=>{e.key===`Escape`&&t()},[t]);(0,c.useEffect)(()=>{let e=setTimeout(()=>{document.addEventListener(`click`,a,!0),document.addEventListener(`contextmenu`,a,!0)},0);return document.addEventListener(`keydown`,o),()=>{clearTimeout(e),document.removeEventListener(`click`,a,!0),document.removeEventListener(`contextmenu`,a,!0),document.removeEventListener(`keydown`,o)}},[a,o]);let s={...e.position};if(i.current){let e=i.current.getBoundingClientRect();s.x+e.width>window.innerWidth&&(s.x=window.innerWidth-e.width-10),s.y+e.height>window.innerHeight&&(s.y=window.innerHeight-e.height-10)}let l=(0,p.jsx)(`div`,{ref:i,className:`context-menu`,style:{position:`fixed`,left:`${s.x}px`,top:`${s.y}px`,pointerEvents:`all`},children:e.items.map(e=>(0,p.jsxs)(`div`,{className:`context-menu__item ${e.danger?`context-menu__item--danger`:``}`,onClick:()=>{e.onClick(),t()},children:[e.icon&&(0,p.jsx)(`span`,{className:`context-menu__item-icon`,children:e.icon}),(0,p.jsx)(`span`,{className:`context-menu__item-label`,children:e.label})]},e.key))});return(0,f.createPortal)(l,n)};var Ze=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1775031767174'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='30653'%20data-spm-anchor-id='a313x.search_index.0.i6.78953a81FCkAe0'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='64'%20height='64'%3e%3cpath%20d='M322.24%20479.210667l-42.453333-42.432%20198.826666-198.826667c53.397333-53.376%20139.306667-53.568%20191.914667-0.981333%2052.608%2052.608%2052.416%20138.517333-0.981333%20191.914666L455.722667%20642.709333l-42.432-42.453333%20213.824-213.802667a74.773333%2074.773333%200%200%200-0.341334-105.728%2074.773333%2074.773333%200%200%200-105.728-0.341333l-198.826666%20198.826667z'%20fill='%23ffffff'%20p-id='30654'%3e%3c/path%3e%3cpath%20d='M699.093333%20613.333333l42.453334%2042.432-169.429334%20169.408c-48.341333%2048.341333-129.28%2042.282667-181.248-9.664-51.968-51.968-58.026667-132.906667-9.664-181.248l234.346667-234.346666%2042.432%2042.410666L423.616%20676.693333c-22.250667%2022.250667-19.050667%2065.024%2011.008%2095.061334%2030.037333%2030.058667%2072.810667%2033.258667%2095.061333%2010.986666l169.429334-169.408zM187.989333%20571.029333c-38.933333-38.933333-38.805333-102.613333%200.853334-142.293333%2039.68-39.68%20103.381333-39.808%20142.293333-0.853333%2038.954667%2038.912%2038.826667%20102.613333-0.853333%20142.293333-39.68%2039.658667-103.381333%2039.786667-142.293334%200.853333z%20m43.733334-43.733333c15.744%2015.744%2040.874667%2015.68%2056.128%200.426667%2015.253333-15.232%2015.296-40.362667-0.426667-56.106667-15.765333-15.744-40.896-15.701333-56.149333-0.448-15.232%2015.232-15.296%2040.384%200.448%2056.106667z'%20fill='%23ffffff'%20p-id='30655'%3e%3c/path%3e%3cpath%20d='M846.144%20489.728l-31.466667%20198.784-56.96-101.461333-104.042666-38.506667z'%20fill='%23ffffff'%20p-id='30656'%3e%3c/path%3e%3c/svg%3e`,X=`route-planning-temp-line`,Qe=`route-planning-temp-line-layer`,Z=`route-planning-temp-point-layer`;const $e=(0,c.forwardRef)(({map:e,pointCount:t=2,showPointCountInput:n=!1,visualType:r=`marker`,onSelectFinished:i,showButton:a=!0},o)=>{let[s,u]=(0,c.useState)(`idle`),[d,f]=(0,c.useState)(0),[m,h]=(0,c.useState)(t),[g,_]=(0,c.useState)(!1),v=(0,c.useRef)(null),y=(0,c.useRef)(null),b=(0,c.useRef)([]),x=(0,c.useRef)([]),S=(0,c.useRef)(`idle`),C=(0,c.useRef)(null),w=(0,c.useRef)(``);(0,c.useEffect)(()=>{S.current=s},[s]),(0,c.useEffect)(()=>{h(t)},[t]),(0,c.useEffect)(()=>{if(!g)return;let e=e=>{y.current&&!y.current.contains(e.target)&&v.current&&!v.current.contains(e.target)&&_(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[g]);let T=(0,c.useCallback)(()=>{for(let e of x.current)e.remove();x.current=[],e&&(e.getLayer(Qe)&&e.removeLayer(Qe),e.getLayer(Z)&&e.removeLayer(Z),e.getSource(X)&&e.removeSource(X))},[e]),E=(0,c.useCallback)(()=>{if(!e)return;let t=b.current,n={type:`FeatureCollection`,features:[{type:`Feature`,properties:{},geometry:{type:`LineString`,coordinates:t.length>=2?t:[]}},...t.map((e,t)=>({type:`Feature`,properties:{index:t},geometry:{type:`Point`,coordinates:e}}))]},r=e.getSource(X);r?r.setData(n):(e.addSource(X,{type:`geojson`,data:n}),e.addLayer({id:Qe,type:`line`,source:X,filter:[`==`,`$type`,`LineString`],paint:{"line-color":`#4A90D9`,"line-width":3,"line-dasharray":[2,2]}}),e.addLayer({id:Z,type:`circle`,source:X,filter:[`==`,`$type`,`Point`],paint:{"circle-radius":6,"circle-color":`#4A90D9`,"circle-stroke-width":2,"circle-stroke-color":`#fff`}}))},[e]),D=(0,c.useCallback)(t=>{if(!e||!C.current)return;let{visualType:n}=C.current;if(n===`marker`){let n=document.createElement(`div`);n.className=`route-planning-temp-marker`,n.textContent=String(b.current.length);let r=new l.default.Marker({element:n}).setLngLat(t).addTo(e);x.current.push(r)}else E()},[e,E]),O=(0,c.useCallback)(()=>{T(),b.current=[],C.current=null,f(0),u(`idle`),e&&(e.getCanvas().style.cursor=w.current)},[T,e]),k=(0,c.useCallback)(async()=>{let e=C.current,t=[...b.current];if(!e||t.length<2){O();return}u(`planning`);try{await e.onSelectFinished(t)}catch(e){console.error(`Route planning onSelectFinished failed:`,e)}finally{O()}},[O]),ee=(0,c.useCallback)(e=>{if(S.current!==`selecting`||!C.current)return;let t=[e.lngLat.lng,e.lngLat.lat];b.current.push(t);let n=b.current.length;f(n),D(t),n>=C.current.pointCount&&k()},[D,k]),A=(0,c.useCallback)(e=>{S.current===`selecting`&&(e.preventDefault(),O())},[O]);(0,c.useEffect)(()=>{if(e&&s===`selecting`)return e.on(`click`,ee),e.on(`contextmenu`,A),()=>{e.off(`click`,ee),e.off(`contextmenu`,A)}},[e,s,ee,A]);let j=(0,c.useCallback)(n=>{if(!e)return;S.current!==`idle`&&O();let i=Math.max(2,n.pointCount??t),a=n.visualType??r;C.current={pointCount:i,visualType:a,onSelectFinished:n.onSelectFinished},b.current=[],f(0),h(i),_(!1),w.current=e.getCanvas().style.cursor,e.getCanvas().style.cursor=`crosshair`,u(`selecting`)},[e,t,r,O]);(0,c.useImperativeHandle)(o,()=>({startPlanning:j}),[j]);let M=()=>{s===`idle`?_(e=>!e):s===`selecting`&&O()},te=()=>{i&&j({pointCount:Math.max(2,m),visualType:r,onSelectFinished:i})},ne=e=>{let t=parseInt(e.target.value,10);!isNaN(t)&&t>=2?h(t):e.target.value===``&&h(2)},N=()=>{if(s===`planning`)return(0,p.jsx)(`span`,{children:`规划中...`});if(s===`selecting`){let e=C.current?.pointCount??m;return(0,p.jsxs)(`span`,{children:[d,`/`,e]})}return`路径规划`},P=s===`selecting`,re=s===`planning`;return!a&&s===`idle`?null:(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control${a?``:` mapbox-route-planning-control--floating`}`,children:[(0,p.jsxs)(`button`,{ref:v,className:`mapbox-control-btn mapbox-route-planning-control__btn${P?` mapbox-route-planning-control__btn--active`:``}${re?` mapbox-route-planning-control__btn--planning`:``}${g?` mapbox-route-planning-control__btn--active`:``}`,onClick:M,disabled:re,title:s===`idle`?`路径规划`:s===`selecting`?`取消选点`:`规划中...`,children:[(0,p.jsx)(`img`,{src:Ze,alt:`route`,className:`mapbox-route-planning-control__btn-icon`}),N()]}),g&&s===`idle`&&(0,p.jsxs)(`div`,{ref:y,className:`mapbox-route-planning-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-route-planning-control__panel-header`,children:(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-title`,children:`路径规划`})}),(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control__panel-body`,children:[(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control__panel-row`,children:[(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-label`,children:`选点数量`}),n?(0,p.jsx)(`input`,{type:`number`,className:`mapbox-route-planning-control__panel-input`,value:m,min:2,onChange:ne}):(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-value`,children:m})]}),(0,p.jsx)(`div`,{className:`mapbox-route-planning-control__panel-tip`,children:`左键点击地图选点,右键取消`}),(0,p.jsx)(`button`,{className:`mapbox-route-planning-control__panel-start`,onClick:te,disabled:!i,children:`开始规划`})]})]})]})});$e.displayName=`RoutePlanningControl`;function et(e,t,n){return{content:e.content??n??null,trigger:e.trigger??t?.trigger??T.trigger,position:e.position??t?.position??T.position,offset:e.offset??t?.offset??T.offset,showCloseButton:e.showCloseButton??t?.showCloseButton??T.showCloseButton,animation:e.animation??t?.animation??T.animation,className:e.className??``,style:e.style??{},closeOnClickOutside:e.closeOnClickOutside??t?.closeOnClickOutside??T.closeOnClickOutside,closeOnEscape:e.closeOnEscape??t?.closeOnEscape??T.closeOnEscape,hoverDelay:e.hoverDelay??t?.hoverDelay??T.hoverDelay,maxWidth:e.maxWidth??t?.maxWidth??T.maxWidth,zIndex:e.zIndex??t?.zIndex??T.zIndex}}function tt(e,t,n,r,i){let a,o;if(e.type===`polygon`)o=e.center??nt(e.coordinates);else if(e.type===`polyline`)o=e.center??rt(e.coordinates);else if(e.type===`rectangle`)if(e.center)o=e.center;else{let[[t,n],[r,i]]=e.bounds;o=[(t+r)/2,(n+i)/2]}else o=e.center;let s=n.project(o);a={x:s.x,y:s.y};let c=it(i,t);return at(a,t.position,t.offset,c)}function nt(e){if(!e||e.length===0)return[0,0];let t=[...e];(e[0][0]!==e[e.length-1][0]||e[0][1]!==e[e.length-1][1])&&t.push(e[0]);let n=(0,u.polygon)([t]);return(0,u.centroid)(n).geometry.coordinates}function rt(e){if(!e||e.length===0)return[0,0];let t=0,n=0;for(let r of e)t+=r[0],n+=r[1];return[t/e.length,n/e.length]}function it(e,t){if(e){let t=e.getBoundingClientRect();return{width:t.width||320,height:t.height||200}}return{width:typeof t.maxWidth==`number`?t.maxWidth:320,height:200}}function at(e,t,n,r){let i={width:window.innerWidth,height:window.innerHeight},a=(()=>{switch(t){case`top`:return[`top`,`bottom`,`right`,`left`,`center`];case`bottom`:return[`bottom`,`top`,`right`,`left`,`center`];case`left`:return[`left`,`right`,`top`,`bottom`,`center`];case`right`:return[`right`,`left`,`top`,`bottom`,`center`];case`center`:default:return[`center`,`top`,`bottom`,`left`,`right`]}})(),o={top:()=>({x:e.x-r.width/2+n[0],y:e.y-r.height-20+n[1]}),bottom:()=>({x:e.x-r.width/2+n[0],y:e.y+20+n[1]}),left:()=>({x:e.x-r.width-20+n[0],y:e.y-r.height/2+n[1]}),right:()=>({x:e.x+20+n[0],y:e.y-r.height/2+n[1]}),center:()=>({x:e.x-r.width/2+n[0],y:e.y-r.height/2+n[1]})},s=e=>e.x>=10&&e.y>=10&&e.x+r.width+10<=i.width&&e.y+r.height+10<=i.height;for(let e of a){let t=o[e]();if(s(t))return{position:t,actualPosition:e}}let c=o[t]();return{position:ot(c,r),actualPosition:t}}function ot(e,t){let n={width:window.innerWidth,height:window.innerHeight},r={...e};return r.x+t.width+10>n.width&&(r.x=n.width-t.width-10),r.x<10&&(r.x=10),r.y+t.height+10>n.height&&(r.y=n.height-t.height-10),r.y<10&&(r.y=10),r}const st=(0,c.forwardRef)((e,t)=>{let{center:n=[116.4074,39.9042],zoom:r=12,pitch:i=0,bearing:a=0,style:o=`mapbox://styles/mapbox/dark-v11`,maxBounds:s,mode:u=`display`,editConfig:d={},pickerConfig:f={},onPick:m,interactive:h={},layers:g=[],rasterPaint:_,entities:v=[],selectedIds:y=[],entityConfig:b,nameConfig:C,selectNameConfig:w,areaConfig:T,circleConfig:E,lengthConfig:k,showCoordinates:M=!0,showScale:te=!0,showResetView:ne=!0,showRoadHighlight:N=!1,showMeasure:P=!1,showRasterPaint:re=!1,showRoutePlanning:ie,onRasterPaintChange:ae,popupDefaults:F,renderPopup:I,onMapLoad:oe,onEntityClick:ce,onPopupOpen:me,onPopupClose:L,className:ge=``,containerStyle:ve}=e,be=(0,c.useRef)(null),Ce=(0,c.useRef)(null),R=(0,c.useRef)(null),z=(0,c.useRef)(new Map),B=(0,c.useRef)(new Map),De=(0,c.useRef)(new Set),[V,Oe]=(0,c.useState)(null),ke=(0,c.useRef)(null),je=(0,c.useRef)(null),Me=(0,c.useRef)(null),[Ne,Pe]=(0,c.useState)(null),Fe=(0,c.useRef)(null),Ie=(0,c.useRef)(null),[Re,ze]=(0,c.useState)(null),[H,Be]=(0,c.useState)(u),[Ve,He]=(0,c.useState)(null),Ue=(0,c.useRef)(null),[U,W]=(0,c.useState)(null),[We,G]=(0,c.useState)(null),[Ge,K]=(0,c.useState)(null),q=(0,c.useRef)(!1),J=(0,c.useRef)(null),qe=(0,c.useRef)(null),Y=(0,c.useRef)(null),Ze=(0,c.useRef)(null),X=(0,c.useRef)(null),Qe=(0,c.useRef)([]),Z=(0,c.useRef)(null),nt=(0,c.useRef)(null),rt=(0,c.useRef)(null),it=(0,c.useRef)([]),at=(0,c.useRef)(null),ot=(0,c.useRef)(!1),[st,ct]=(0,c.useState)([]),lt=(0,c.useRef)([]);lt.current=st;let Q=(0,c.useRef)(null);(0,c.useEffect)(()=>{Be(u)},[u]);let ut=(0,c.useCallback)(e=>{let t=z.current.get(e),n=B.current.get(e);if(t&&n){if(n.type===`radar`&&t instanceof se){let r={...n,isAnimating:!0};B.current.set(e,r),t.startAnimation()}else if(n.type===`circle`&&t instanceof _e){let r={...n,isAnimating:!0};B.current.set(e,r),t.startAnimation()}}},[]),dt=(0,c.useCallback)(e=>{let t=z.current.get(e),n=B.current.get(e);if(t&&n){if(n.type===`radar`&&t instanceof se){let r={...n,isAnimating:!1};B.current.set(e,r),t.stopAnimation()}else if(n.type===`circle`&&t instanceof _e){let r={...n,isAnimating:!1};B.current.set(e,r),t.stopAnimation()}}},[]),ft=(0,c.useCallback)(e=>{let t=B.current.get(e);t&&(t.type===`radar`||t.type===`circle`)&&(t.type,t.isAnimating?dt(e):ut(e))},[ut,dt]),pt=(0,c.useCallback)(e=>{if(e===void 0){let e=!1;for(let[,t]of z.current)if(t instanceof de){let n=t.getShowTrajectory();if(n===`all`||typeof n==`number`&&n>0){e=!0;break}}let t=e?0:`all`;for(let[,e]of z.current)e instanceof de&&e.setShowTrajectory(t)}else{let t=new Set(e.map(String));for(let[e,n]of z.current)n instanceof de&&n.setShowTrajectory(t.has(String(e))?`all`:0)}},[]),mt=(0,c.useCallback)((e,t,n)=>{let r=v.find(t=>String(t.id)===String(e));if(!r?.popup||!R.current)return;let i=r.popup.content??I?.(r);if(!i)return;let a=et(r.popup,F,i),{position:o,actualPosition:s}=tt(r,a,R.current,n);Oe({entityId:e,position:o,config:a,openedBy:t,actualPosition:s}),me?.(e)},[v,F,I,me]),ht=(0,c.useCallback)(e=>{V?.entityId===e&&(Oe(null),L?.(e))},[V,L]),gt=(0,c.useCallback)(()=>{Oe(e=>(e&&L?.(e.entityId),null))},[L]),_t=(0,c.useCallback)(e=>V?.entityId===e,[V]),vt=(0,c.useCallback)((e,t,n)=>{let r=R.current;r&&r.flyTo({center:e,zoom:t??r.getZoom(),...n})},[]),yt=(0,c.useCallback)((e,t,n)=>{let r=R.current;if(!r||e.length===0)return;let i=[];for(let t of e){let e=z.current.get(t);e&&i.push(e.getBounds())}if(i.length===0)return;let a=1/0,o=-1/0,s=1/0,c=-1/0;for(let[[e,t],[n,r]]of i)a=Math.min(a,e),o=Math.max(o,n),s=Math.min(s,t),c=Math.max(c,r);let l=(a+o)/2,u=(s+c)/2,d=a===o&&s===c;if(i.length===1||d){let e={center:[l,u],zoom:t??r.getZoom()};n?.duration!==void 0&&(e.duration=n.duration),n?.pitch!==void 0&&(e.pitch=n.pitch),n?.bearing!==void 0&&(e.bearing=n.bearing),n?.essential!==void 0&&(e.essential=n.essential),r.flyTo(e);return}let f=[[a,s],[o,c]],p={padding:n?.padding??50,duration:n?.duration??1e3,bearing:n?.bearing??r.getBearing(),pitch:n?.pitch??r.getPitch()};t!==void 0&&(p.maxZoom=t),n?.essential!==void 0&&(p.essential=n.essential),r.fitBounds(f,p)},[]),bt=(0,c.useCallback)(e=>{let t=R.current;if(!t||!t.getContainer())return;let{showMarker:n=!0,markerColor:r=`#3388ff`,name:i,nameConfig:a}=f;if(!n){Ue.current&&=(Ue.current.remove(),null);return}if(Ue.current){Ue.current.setLngLat(e);let t=Ue.current.getElement(),n=t.querySelector(`.marker-label`);if(i){let e=x(a,C);if(n)n.textContent=i,n.style.color=e.fillColor,n.style.opacity=String(e.fillOpacity),n.style.webkitTextStrokeColor=e.strokeColor,n.style.webkitTextStrokeWidth=`${e.strokeWidth}px`;else{let n=document.createElement(`div`);n.className=`marker-label`,n.textContent=i,n.style.color=e.fillColor,n.style.opacity=String(e.fillOpacity),n.style.webkitTextStrokeColor=e.strokeColor,n.style.webkitTextStrokeWidth=`${e.strokeWidth}px`,t.appendChild(n)}}else n&&n.remove()}else{let n=document.createElement(`div`);n.className=`mapbox-picker-marker`;let o=document.createElement(`div`);if(o.className=`marker-inner`,o.style.background=r,n.appendChild(o),i){let e=x(a,C),t=document.createElement(`div`);t.className=`marker-label`,t.textContent=i,t.style.color=e.fillColor,t.style.opacity=String(e.fillOpacity),t.style.webkitTextStrokeColor=e.strokeColor,t.style.webkitTextStrokeWidth=`${e.strokeWidth}px`,n.appendChild(t)}Ue.current=new l.default.Marker({element:n,anchor:`bottom`}).setLngLat(e).addTo(t)}},[f,C]),xt=(0,c.useCallback)(()=>{Ue.current&&=(Ue.current.remove(),null)},[]),St=(0,c.useCallback)(()=>`marker-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,[]),Ct=(0,c.useCallback)(e=>{let t=R.current;if(be.current)if(at.current&&=(at.current.remove(),null),e&&t){t.getCanvas().style.cursor=`none`;let n=document.createElement(`div`);n.className=`mapbox-custom-cursor`;let r=e.size||e.width||32;n.style.cssText=`
51
+ `;S.current||=new l.default.Popup({closeButton:!1,closeOnClick:!1,offset:15,className:`road-highlight-popup`}),S.current.setLngLat(r).setHTML(_).addTo(e),e.getCanvas().style.cursor=`pointer`}else S.current&&S.current.remove(),e.getCanvas().style.cursor=``},[e,h,w,o]);(0,c.useEffect)(()=>{if(!(!e||!_))return e.on(`mousemove`,T),()=>{e.off(`mousemove`,T),S.current&&S.current.remove(),e.getCanvas().style.cursor=``}},[e,_,T]);let D=(e,t)=>{g(n=>t?[...n,e]:n.filter(t=>t!==e))},O=e=>{g(e?E.map(e=>e.class):[])},k=h.length>0;return(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control ${s}`,style:u,children:[(0,p.jsxs)(`button`,{ref:x,className:`mapbox-control-btn mapbox-road-highlight-control__btn ${k?`mapbox-road-highlight-control__btn--active`:``}`,onClick:()=>f(!d),title:`路网高亮${h.length>0?` (已选 ${h.length})`:``}`,children:[(0,p.jsx)(`img`,{src:De,alt:`road`,className:`mapbox-road-highlight-control__btn-icon`}),(0,p.jsxs)(`span`,{children:[`路网`,h.length>0?` (${h.length})`:``]})]}),d&&(0,p.jsxs)(`div`,{ref:b,className:`mapbox-road-highlight-control__panel`,children:[(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control__panel-header`,children:[(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__panel-title`,children:`道路类型`}),(0,p.jsx)(m.Checkbox,{checked:h.length===E.length,indeterminate:h.length>0&&h.length<E.length,onChange:O,style:{"--color-text-1":`#fff`,"--color-border-2":`rgba(255, 255, 255, 0.3)`},children:(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__type-label`,children:`全选`})})]}),(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__scroll`,children:(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__type-list`,children:E.map(e=>(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control__type-item`,onClick:()=>D(e.class,!h.includes(e.class)),children:[(0,p.jsx)(m.Checkbox,{checked:h.includes(e.class),onChange:t=>D(e.class,t),onClick:e=>e.stopPropagation(),style:{"--color-text-1":`#fff`,"--color-border-2":`rgba(255, 255, 255, 0.3)`,marginRight:0,flexShrink:0}}),(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__color-indicator`,style:{backgroundColor:e.color}}),(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__type-label`,children:e.label})]},e.class))})}),(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__tip`,children:`💡 选中道路类型后立即显示高亮`}),!_&&(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__warning`,children:`⚠️ 正在初始化图层...`})]})]})}var je=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1773733446763'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='1802'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M110.34624%20352.01024a30.72%2030.72%200%201%200%2061.44%200v-38.46144h680.42752v38.5024a30.72%2030.72%200%200%200%2061.44%200V213.72928a30.72%2030.72%200%200%200-61.44%200v38.33856H171.78624v-38.33856a30.72%2030.72%200%200%200-61.44%200v138.28096z%20m34.816%20127.22176a34.816%2034.816%200%200%200-34.816%2034.816v312.60672c0%2019.2512%2015.5648%2034.816%2034.816%2034.816h733.5936c19.2512%200%2034.816-15.5648%2034.816-34.816V514.048a34.816%2034.816%200%200%200-34.816-34.816H145.2032z%20m26.624%20320.79872V540.672h680.3456v259.35872H171.8272z'%20fill='white'%20p-id='1804'%3e%3c/path%3e%3c/svg%3e`,Me=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='192'%20y='192'%20width='640'%20height='640'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,Ne=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='160'%20y='240'%20width='704'%20height='544'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,Pe=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3ccircle%20cx='512'%20cy='512'%20r='384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,Fe=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolygon%20points='512,128%20864,384%20736,800%20288,800%20160,384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'/%3e%3c/svg%3e`,Ie=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolyline%20points='160,768%20384,256%20640,576%20864,192'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'%20stroke-linecap='round'/%3e%3c/svg%3e`,Le=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`,Re={square:`正方形`,rectangle:`矩形`,circle:`圆形`,polygon:`多边形`,polyline:`折线`},ze=[{mode:`square`,icon:Me,label:`正方形`},{mode:`rectangle`,icon:Ne,label:`矩形`},{mode:`circle`,icon:Pe,label:`圆形`},{mode:`polygon`,icon:Fe,label:`多边形`},{mode:`polyline`,icon:Ie,label:`折线`}];function H(e,t){let[n,r]=e,[i,a]=t,o=(a-r)*Math.PI/180,s=(i-n)*Math.PI/180,c=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function Be(e,t,n=64){let[r,i]=e,a=[],o=t/6371e3,s=i*Math.PI/180;for(let e=0;e<=n;e++){let t=e/n*2*Math.PI,c=o*Math.cos(t),l=o*Math.sin(t)/Math.cos(s);a.push([r+l*180/Math.PI,i+c*180/Math.PI])}return a}function Ve(e,t){let[n,r]=e,i=t/2/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r+o],[n+s,r+o],[n+s,r-o],[n-s,r-o],[n-s,r+o]]}function He(e){if(e.type===`circle`)return A(Math.PI*e.radius*e.radius);if(e.type===`square`)return A(e.length*e.length);if(e.type===`rectangle`){let[[t,n],[r,i]]=e.bounds,a=[Math.min(t,r),Math.max(n,i)],o=[Math.max(t,r),Math.max(n,i)],s=[Math.max(t,r),Math.min(n,i)],c=O(a,o),l=O(o,s);return A(c*l)}if(e.type===`polygon`){let t=[...e.coordinates,e.coordinates[0]];return A(ee(t))}}function Ue(e){if(e.type===`circle`)return j(e.radius);if(e.type===`square`)return j(e.length);if(e.type===`rectangle`){let[[t,n],[r,i]]=e.bounds,a=[Math.min(t,r),Math.max(n,i)],o=[Math.max(t,r),Math.max(n,i)],s=[Math.max(t,r),Math.min(n,i)],c=O(a,o),l=O(o,s);return j(2*(c+l))}if(e.type===`polygon`){let t=0,n=e.coordinates;for(let e=0;e<n.length;e++)t+=O(n[e],n[(e+1)%n.length]);return j(t)}if(e.type===`polyline`){let t=0;for(let n=0;n<e.coordinates.length-1;n++)t+=O(e.coordinates[n],e.coordinates[n+1]);return j(t)}}var U=`measure-`;function W(e,t){e.getSource(t)||e.addSource(t,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}})}function We(e,t){let n=e.getSource(t);n&&n.setData({type:`FeatureCollection`,features:[]})}function G(e){if(!e.getStyle().glyphs){let t=e.style,n=`/gis-fonts/{fontstack}/{range}.pbf`;t.glyphs=n,t.stylesheet&&(t.stylesheet.glyphs=n)}}function Ge(e){G(e);for(let t of[`rect`,`circle`,`square`,`polygon`]){let n=`${U}${t}-preview-source`,r=`${U}${t}-preview-fill`,i=`${U}${t}-preview-line`,a=`${U}${t}-preview-measure-source`,o=`${U}${t}-preview-measure-label`;W(e,n),e.getLayer(r)||e.addLayer({id:r,type:`fill`,source:n,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.getLayer(i)||e.addLayer({id:i,type:`line`,source:n,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),W(e,a),e.getLayer(o)||e.addLayer({id:o,type:`symbol`,source:a,filter:[`==`,`$type`,`Point`],layout:{"text-field":[`get`,`label`],"text-size":12,"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-allow-overlap":!0,"text-offset":[0,-.8]},paint:{"text-color":`#ffffff`,"text-halo-color":`rgba(0,0,0,0.8)`,"text-halo-width":1}})}let t=`${U}polyline-preview-source`,n=`${U}polyline-preview-line`,r=`${U}polyline-vertices-source`,i=`${U}polyline-vertices`,a=`${U}polyline-preview-measure-source`,o=`${U}polyline-preview-measure-label`;W(e,t),e.getLayer(n)||e.addLayer({id:n,type:`line`,source:t,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),W(e,r),e.getLayer(i)||e.addLayer({id:i,type:`circle`,source:r,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}}),W(e,a),e.getLayer(o)||e.addLayer({id:o,type:`symbol`,source:a,filter:[`==`,`$type`,`Point`],layout:{"text-field":[`get`,`label`],"text-size":12,"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-allow-overlap":!0,"text-offset":[0,-.8]},paint:{"text-color":`#ffffff`,"text-halo-color":`rgba(0,0,0,0.8)`,"text-halo-width":1}});let s=`${U}polygon-vertices-source`,c=`${U}polygon-vertices`;W(e,s),e.getLayer(c)||e.addLayer({id:c,type:`circle`,source:s,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}});let l=`${U}circle-radius-source`,u=`${U}circle-radius-line`;W(e,l),e.getLayer(u)||e.addLayer({id:u,type:`line`,source:l,paint:{"line-color":`#ffffff`,"line-width":1,"line-dasharray":[4,4]}})}function K(e){for(let t of[`rect-preview-source`,`rect-preview-measure-source`,`circle-preview-source`,`circle-preview-measure-source`,`circle-radius-source`,`square-preview-source`,`square-preview-measure-source`,`polygon-preview-source`,`polygon-preview-measure-source`,`polygon-vertices-source`,`polyline-preview-source`,`polyline-preview-measure-source`,`polyline-vertices-source`])We(e,`${U}${t}`)}function Ke({map:e,entityConfig:t,onEntityConfigChange:n,onDrawModeChange:r,className:i=``,style:a}){let[o,s]=(0,c.useState)(!1),[l,u]=(0,c.useState)(null),[d,f]=(0,c.useState)({showArea:!0,showLength:!0,showRadius:!0}),h=t!==void 0,g=h?{showArea:t.showArea??!0,showLength:t.showLength??!0,showRadius:t.showRadius??!0}:d,[_,v]=(0,c.useState)([]),y=(0,c.useRef)(new Map),b=(0,c.useRef)(0),x=(0,c.useRef)(null),C=(0,c.useRef)(null),w=(0,c.useRef)(null),T=(0,c.useRef)(null),E=(0,c.useRef)(null),k=(0,c.useRef)([]),M=(0,c.useRef)([]),te=(0,c.useRef)(g);te.current=g;let ne=(0,c.useRef)(l);ne.current=l;let N=(0,c.useCallback)(()=>`measure-${++b.current}`,[]);(0,c.useEffect)(()=>{r?.(l!==null)},[l,r]);let P=(0,c.useRef)(!1),re=(0,c.useCallback)(()=>{!e||!e.isStyleLoaded()||(Ge(e),P.current=!0)},[e]);(0,c.useEffect)(()=>{if(!e)return;let t=()=>{Ge(e),P.current=!0};e.isStyleLoaded()?t():e.once(`load`,t);let n=()=>{P.current=!1};return e.on(`style.load`,n),()=>{e.off(`style.load`,n)}},[e]),(0,c.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&C.current&&!C.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let ie=(0,c.useCallback)(t=>{if(!e)return;let n=S(t,te.current),r=null;if(n.type===`circle`?r=new he(e,n):n.type===`square`?r=new ye(e,n):n.type===`rectangle`?r=new xe(e,n):n.type===`polygon`?r=new fe(e,n):n.type===`polyline`&&(r=new pe(e,n)),r){y.current.set(n.id,r);let e={entity:n,shapeLabel:Re[n.type]||n.type,area:He(n),lengthOrRadius:Ue(n)};v(t=>[...t,e])}},[e]),ae=(0,c.useCallback)(e=>{let t=y.current.get(e);t&&(t.destroy(),y.current.delete(e)),v(t=>t.filter(t=>t.entity.id!==e))},[]),F=(0,c.useCallback)(()=>{y.current.forEach(e=>e.destroy()),y.current.clear(),v([])},[]),I=(0,c.useCallback)(t=>{if(!e)return;let n=y.current.get(t);if(!n)return;let r=n.getBounds();e.fitBounds(r,{padding:80,maxZoom:18,duration:1e3})},[e]),oe=(0,c.useCallback)((e,t)=>{let r={...te.current,[e]:t};h?n?.({...r}):f(r),v(t=>t.map(t=>{let n={...t.entity};n[e]=void 0;let i=S(n,r),a=y.current.get(t.entity.id);return a&&a.update(i),{...t,entity:i}}))},[h,n]),se=(0,c.useCallback)((t,n)=>{if(!e)return;let[r,i]=t,[a,o]=n,s=[[Math.min(r,a),Math.max(i,o)],[Math.max(r,a),Math.max(i,o)],[Math.max(r,a),Math.min(i,o)],[Math.min(r,a),Math.min(i,o)],[Math.min(r,a),Math.max(i,o)]],c=e.getSource(`${U}rect-preview-source`);c&&c.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[s]},properties:{}});let l=e.getSource(`${U}rect-preview-measure-source`);if(l){let e=te.current,t=[],n=s[0],r=s[1],i=s[2];if(e?.showArea){let e=O(n,r),a=O(r,i);t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:A(e*a)}})}e?.showLength&&(t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+r[0])/2,(n[1]+r[1])/2]},properties:{label:j(O(n,r))}}),t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(r[0]+i[0])/2,(r[1]+i[1])/2]},properties:{label:j(O(r,i))}})),l.setData({type:`FeatureCollection`,features:t})}},[e]),ce=(0,c.useCallback)((t,n)=>{if(!e)return;let r=H(t,n),i=Be(t,r),a=e.getSource(`${U}circle-preview-source`);a&&a.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[i]},properties:{}});let o=te.current,s=[],c=[];if(o?.showArea&&s.push({type:`Feature`,geometry:{type:`Point`,coordinates:t},properties:{label:A(Math.PI*r*r)}}),o?.showRadius){let e=D(t,r,90),n=[(t[0]+e[0])/2,(t[1]+e[1])/2];c.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[t,e]},properties:{}}),s.push({type:`Feature`,geometry:{type:`Point`,coordinates:n},properties:{label:j(r)}})}let l=e.getSource(`${U}circle-preview-measure-source`);l&&l.setData({type:`FeatureCollection`,features:s});let u=e.getSource(`${U}circle-radius-source`);u&&u.setData({type:`FeatureCollection`,features:c})},[e]),le=(0,c.useCallback)((t,n)=>{if(!e)return;let r=H(t,n)*2,i=Ve(t,r),a=e.getSource(`${U}square-preview-source`);a&&a.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[i]},properties:{}});let o=e.getSource(`${U}square-preview-measure-source`);if(o){let e=te.current,n=[];if(e?.showArea&&n.push({type:`Feature`,geometry:{type:`Point`,coordinates:t},properties:{label:A(r*r)}}),e?.showLength){let e=[(i[1][0]+i[2][0])/2,(i[1][1]+i[2][1])/2];n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:j(r)}})}o.setData({type:`FeatureCollection`,features:n})}},[e]),ue=(0,c.useCallback)((t,n)=>{if(!e)return;let r=[...t,n],i=e.getSource(`${U}polygon-preview-source`);i&&(r.length>=3?i.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[[...r,r[0]]]},properties:{}}):r.length===2?i.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:r},properties:{}}):i.setData({type:`FeatureCollection`,features:[]}));let a=e.getSource(`${U}polygon-vertices-source`);a&&a.setData({type:`FeatureCollection`,features:t.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=e.getSource(`${U}polygon-preview-measure-source`);if(o){let e=te.current,t=[];if(e?.showArea&&r.length>=3){let e=ee([...r,r[0]]),n=0,i=0;for(let e of r)n+=e[0],i+=e[1];n/=r.length,i/=r.length,t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[n,i]},properties:{label:A(e)}})}if(e?.showLength&&r.length>=2){for(let e=0;e<r.length-1;e++){let n=r[e],i=r[e+1];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:j(O(n,i))}})}if(r.length>=3){let e=r[r.length-1],n=r[0];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(e[0]+n[0])/2,(e[1]+n[1])/2]},properties:{label:j(O(e,n))}})}}o.setData({type:`FeatureCollection`,features:t})}},[e]),de=(0,c.useCallback)((t,n)=>{if(!e)return;let r=[...t,n],i=e.getSource(`${U}polyline-preview-source`);i&&(r.length>=2?i.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:r},properties:{}}):i.setData({type:`FeatureCollection`,features:[]}));let a=e.getSource(`${U}polyline-vertices-source`);a&&a.setData({type:`FeatureCollection`,features:t.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=e.getSource(`${U}polyline-preview-measure-source`);if(o){let e=te.current,t=[];if(e?.showLength&&r.length>=2)for(let e=0;e<r.length-1;e++){let n=r[e],i=r[e+1];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:j(O(n,i))}})}o.setData({type:`FeatureCollection`,features:t})}},[e]);(0,c.useEffect)(()=>{if(!e||!l)return;re(),e.getCanvas().style.cursor=`crosshair`;let t=t=>{let n=[t.lngLat.lng,t.lngLat.lat],r=ne.current;if(r===`rectangle`){let t=w.current;if(!t)w.current=n;else{let r={id:N(),type:`rectangle`,bounds:[t,n]};ie(r),w.current=null,K(e),u(null)}}else if(r===`circle`){let t=T.current;if(!t)T.current={center:n};else{let r=H(t.center,n),i={id:N(),type:`circle`,center:t.center,radius:r};ie(i),T.current=null,K(e),u(null)}}else if(r===`square`){let t=E.current;if(!t)E.current={center:n};else{let r=H(t.center,n)*2,i={id:N(),type:`square`,center:t.center,length:r};ie(i),E.current=null,K(e),u(null)}}else if(r===`polygon`){let t=k.current;if(t.length>=3&&H(t[0],n)<20){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],K(e),u(null);return}k.current=[...t,n]}else r===`polyline`&&(M.current=[...M.current,n])},n=e=>{let t=[e.lngLat.lng,e.lngLat.lat],n=ne.current;if(n===`rectangle`&&w.current)se(w.current,t);else if(n===`circle`&&T.current)ce(T.current.center,t);else if(n===`square`&&E.current)le(E.current.center,t);else if(n===`polygon`){let e=k.current;e.length>0&&ue(e,t)}else if(n===`polyline`){let e=M.current;e.length>0&&de(e,t)}},r=t=>{t.preventDefault();let n=ne.current;if(n===`polygon`){let t=k.current;if(t.length>=3){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],K(e),u(null)}else k.current=[],K(e)}else if(n===`polyline`){let t=M.current;if(t.length>=2){let n={id:N(),type:`polyline`,coordinates:[...t]};ie(n),M.current=[],K(e),u(null)}else M.current=[],K(e)}},i=t=>{t.key===`Escape`&&(w.current=null,T.current=null,E.current=null,k.current=[],M.current=[],K(e),u(null))},a=t=>{t.preventDefault();let n=ne.current;if(n===`polygon`){let t=k.current;if(t.length>=3){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],K(e),u(null)}}else if(n===`polyline`){let t=M.current;if(t.length>=2){let n={id:N(),type:`polyline`,coordinates:[...t]};ie(n),M.current=[],K(e),u(null)}}};return e.doubleClickZoom.disable(),e.on(`click`,t),e.on(`mousemove`,n),e.on(`contextmenu`,r),e.on(`dblclick`,a),document.addEventListener(`keydown`,i),()=>{e.off(`click`,t),e.off(`mousemove`,n),e.off(`contextmenu`,r),e.off(`dblclick`,a),document.removeEventListener(`keydown`,i),e.getCanvas().style.cursor=``,e.doubleClickZoom.enable(),K(e)}},[e,l,N,ie,re,se,ce,le,ue,de]),(0,c.useEffect)(()=>()=>{y.current.forEach(e=>e.destroy()),y.current.clear()},[]);let me=(0,c.useCallback)(t=>{u(e=>e===t?null:t),w.current=null,T.current=null,E.current=null,k.current=[],M.current=[],e&&K(e)},[e]);return e?(0,p.jsxs)(`div`,{className:`mapbox-measure-control ${i}`,style:a,children:[(0,p.jsxs)(`button`,{ref:C,className:`mapbox-control-btn mapbox-measure-control__btn ${o?`mapbox-measure-control__btn--active`:``}`,onClick:()=>s(!o),title:`测量`,children:[(0,p.jsx)(`img`,{src:je,alt:`measure`,className:`mapbox-measure-control__btn-icon`}),(0,p.jsx)(`span`,{children:`测量`}),_.length>0&&(0,p.jsxs)(`span`,{children:[`(`,_.length,`)`]})]}),o&&(0,p.jsxs)(`div`,{ref:x,className:`mapbox-measure-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-measure-control__section-title`,children:`显示设置`}),(0,p.jsxs)(`div`,{className:`mapbox-measure-control__settings`,children:[(0,p.jsx)(m.Checkbox,{checked:g.showArea,onChange:e=>oe(`showArea`,e),children:`面积`}),(0,p.jsx)(m.Checkbox,{checked:g.showLength,onChange:e=>oe(`showLength`,e),children:`长度`}),(0,p.jsx)(m.Checkbox,{checked:g.showRadius,onChange:e=>oe(`showRadius`,e),children:`半径`})]}),(0,p.jsx)(`div`,{className:`mapbox-measure-control__section-title`,children:`绘制工具`}),(0,p.jsxs)(`div`,{className:`mapbox-measure-control__tools`,children:[ze.map(e=>(0,p.jsx)(`button`,{className:`mapbox-measure-control__tool-btn ${l===e.mode?`mapbox-measure-control__tool-btn--active`:``}`,onClick:()=>me(e.mode),title:e.label,children:(0,p.jsx)(`img`,{src:e.icon,alt:e.label})},e.mode)),_.length>0&&(0,p.jsx)(`button`,{className:`mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger`,onClick:F,title:`清除全部`,children:(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`,alt:`clear`})})]}),_.length>0?(0,p.jsx)(`div`,{className:`mapbox-measure-control__list`,children:(0,p.jsxs)(`table`,{className:`mapbox-measure-control__table`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`类型`}),(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`面积`}),(0,p.jsx)(`th`,{children:`长度/半径`}),(0,p.jsx)(`th`,{})]})}),(0,p.jsx)(`tbody`,{children:_.map(e=>(0,p.jsxs)(`tr`,{className:`mapbox-measure-control__table-row`,onClick:()=>I(e.entity.id),children:[(0,p.jsx)(`td`,{children:e.shapeLabel}),(0,p.jsx)(`td`,{children:String(e.entity.id)}),(0,p.jsx)(`td`,{children:e.area??`-`}),(0,p.jsx)(`td`,{children:e.lengthOrRadius??`-`}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`button`,{className:`mapbox-measure-control__delete-btn`,onClick:t=>{t.stopPropagation(),ae(e.entity.id)},title:`删除`,children:(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`,alt:`delete`})})})]},String(e.entity.id)))})]})}):(0,p.jsx)(`div`,{className:`mapbox-measure-control__empty`,children:`选择工具后在地图上点击绘制`})]})]}):null}var q=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1773803353422'%20class='icon'%20viewBox='0%200%201028%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6757'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128.5'%20height='128'%3e%3cpath%20d='M835.073959%20357.94044V345.56192a345.170251%20345.170251%200%201%200-686.690426%2049.672777A345.090902%20345.090902%200%200%200%20523.706588%20974.009826a345.090902%20345.090902%200%201%200%20311.049973-616.069386zM490.141757%2048.001359a297.877959%20297.877959%200%200%201%20297.560561%20297.560561c0%207.934948%200%2016.345994-1.031543%2025.074437A297.639911%20297.639911%200%200%201%20490.141757%20643.122482h-15.869897a289.943011%20289.943011%200%200%201-104.106522-24.757039A297.481212%20297.481212%200%200%201%20490.141757%2048.001359zM345.170251%20976.39031a297.560561%20297.560561%200%200%201-185.281043-530.371944c0%201.031543%200.714145%202.142436%201.031544%203.253328s1.50764%204.522921%202.301135%206.824056c1.269592%203.888125%202.697882%207.934948%204.126173%2011.743724%200.952194%202.301135%201.825038%204.60227%202.697882%206.903405%201.58699%203.808775%203.253329%207.934948%204.919668%2011.505675%200.952194%202.142436%201.904388%204.284872%202.935931%206.347958%201.983737%204.284872%204.126173%208.490395%206.268609%2012.695918l2.380485%204.60227c3.01528%205.633813%206.268609%2011.108928%209.601287%2016.504692%200.793495%201.428291%201.745689%202.777232%202.618533%204.126173%202.539183%204.046824%205.157716%207.934948%207.934948%2011.981772l4.205523%205.792512c2.380484%203.253329%204.760969%206.506658%207.220803%209.680637l4.840318%206.030561c2.459834%203.01528%204.999017%205.951211%207.538201%208.887142l5.157717%205.792512c2.777232%203.01528%205.633813%205.951211%208.569744%208.887142l4.840318%204.999018c4.205523%204.046824%208.411045%207.934948%2012.775267%2011.823073l3.09463%202.618533c4.205523%203.650076%208.490395%207.220803%2012.854616%2010.63283l5.713163%204.205523c3.332678%202.459834%206.586007%204.919668%209.998035%207.220803l6.506657%204.364222q4.999017%203.332678%209.998035%206.427308c2.221786%201.348941%204.443571%202.697882%206.744706%203.967474%203.570727%202.142436%207.300152%204.126173%2010.950229%206.10991l6.18926%203.253329%202.301135%201.269592v12.378519c0%207.379502%200%2014.759004%200.793494%2021.979807%200%202.459834%200.396747%204.840318%200.634796%207.220803%200%204.840318%200.793495%209.759986%201.428291%2014.600305%200%202.777232%200.872844%205.554464%201.269592%208.411045%200.714145%204.364222%201.428291%208.728443%202.221785%2013.013315%200.555446%202.935931%201.190242%205.871862%201.825038%208.728443%200.952194%204.205523%201.904388%207.934948%203.015281%2012.457869s1.50764%205.871862%202.380484%208.728443%202.380484%207.934948%203.729426%2012.140471c0.952194%202.856581%201.825038%205.633813%202.856581%208.490395%201.428291%204.046824%203.01528%207.934948%204.60227%2012.061121%201.110893%202.618533%202.142436%205.316415%203.253329%207.934948%201.825038%204.284872%203.729426%208.411045%205.713163%2012.537219%201.110893%202.301135%202.142436%204.681619%203.332678%206.903405%202.618533%205.316415%205.475114%2010.474132%208.411045%2015.869896%200.555446%201.110893%201.110893%202.221786%201.745689%203.332679%203.570727%206.10991%207.379502%2012.061121%2011.346976%2018.012332%201.269592%201.904388%202.697882%203.808775%204.046824%205.713163%202.777232%203.967474%205.475114%207.934948%208.411045%2011.664374%201.745689%202.301135%203.570727%204.443571%205.395765%206.744706s5.316415%206.586007%207.934948%209.839336%204.046824%204.60227%206.10991%206.824056%205.633813%206.030561%208.490395%209.045841l6.744706%206.586007c2.935931%202.856581%205.871862%205.633813%208.966492%207.934948s4.681619%204.205523%207.062104%206.268609%206.427308%205.316415%209.759986%207.934948%204.760969%203.888125%207.300152%205.713163l2.380485%201.904388A295.894222%20295.894222%200%200%201%20345.170251%20976.39031z%20m335.965711-11.981772a296.608368%20296.608368%200%200%201-146.479145-38.563848c-5.792512-3.332678-11.426326-6.744706-16.90144-10.315433-1.825038-1.190242-3.491377-2.539183-5.237066-3.729426-3.650076-2.459834-7.300152-4.999017-10.79153-7.934948-2.063087-1.50764-3.967474-3.173979-5.871862-4.760969-3.173979-2.459834-6.268609-4.919668-9.283889-7.934949s-3.967474-3.650076-5.951211-5.475114-5.633813-5.078367-7.934949-7.934948-3.808775-4.046824-5.792512-6.10991-5.078367-5.157716-7.458851-7.934949l-5.554464-6.506657c-1.825038-2.142436-4.60227-5.475114-6.824056-7.934949s-3.412028-4.681619-5.157716-7.062104-4.205523-5.633813-6.10991-8.490394-3.253329-4.999017-4.840319-7.458852-3.729426-5.792512-5.475114-8.807792-2.935931-5.157716-4.364222-7.934949-3.332678-6.030561-4.919668-9.045841-2.539183-5.395765-3.808775-7.934948-2.935931-6.18926-4.284872-9.363239-2.301135-5.554464-3.412028-8.411045-2.459834-6.268609-3.570726-9.521938-1.983737-5.792512-2.856582-8.649094-2.063087-6.506658-3.01528-9.759986-1.58699-5.951211-2.301135-8.887142-1.666339-6.586007-2.380485-9.918686S388.812467%20722.471965%20388.812467%20719.536034s-1.190242-6.665357-1.666339-9.998035-0.793495-6.18926-1.110893-9.28389-0.793495-6.824056-1.031543-10.236083%200-6.268609-0.555447-9.363239v-6.665357h0.396748l2.142436%200.634796c4.364222%201.428291%208.807793%202.697882%2013.251363%203.967474l4.840319%201.269592%2011.505675%202.697883%204.52292%201.031543c5.237066%201.031543%2010.474132%201.983737%2015.869897%202.856581h1.348941c4.840318%200.793495%209.759986%201.348941%2014.600305%201.904388l4.919668%200.476097q5.951211%200.634796%2011.902422%200.952194H490.855902a344.456106%20344.456106%200%200%200%20183.138607-52.529358c5.395765-3.412028%2010.71218-7.062104%2015.869896-10.71218%201.745689-1.190242%203.332678-2.539183%205.078367-3.729426%203.412028-2.539183%206.903405-5.157716%2010.236084-7.934948l5.713162-4.760969c3.01528-2.459834%206.030561-4.999017%208.966492-7.934949l5.633813-5.237066c2.856581-2.618533%205.554464-5.237066%207.934949-7.934948l5.475114-5.633813c2.618533-2.697882%205.237066-5.475114%207.934948-8.331696l5.078367-5.713163%207.458851-9.045841%204.522921-5.633813%207.934948-10.315433%203.570727-4.999017c3.173979-4.60227%206.268609-9.363239%209.20454-14.203558l1.031543-1.586989c3.332678-5.475114%206.506658-11.029578%209.601288-16.663392%200.634796-1.190242%201.190242-2.380484%201.745688-3.570727%202.301135-4.443571%204.60227-8.887142%206.665357-13.410062%200.872844-1.825038%201.666339-3.729426%202.539183-5.554464%201.745689-3.967474%203.491377-7.934948%205.078367-11.902422%200.793495-2.063087%201.58699-4.205523%202.459834-6.347959%201.428291-3.808775%202.856581-7.934948%204.126173-11.505675%200.793495-2.221786%201.50764-4.522921%202.221786-6.744706%201.190242-3.808775%202.380484-7.934948%203.491377-11.585025%200.634796-2.301135%201.269592-4.60227%201.825038-6.903405%201.031543-3.967474%201.904388-7.934948%202.777232-11.902422%200.555446-2.301135%201.031543-4.522921%201.50764-6.824056%200-1.031543%200.476097-2.142436%200.634796-3.173979a297.560561%20297.560561%200%200%201-148.304183%20555.446381z'%20fill='%23ffffff'%20p-id='6758'%3e%3c/path%3e%3c/svg%3e`,J={brightness:1,saturation:0,contrast:0,hueRotate:0},qe=[{key:`brightness`,label:`亮度`,min:0,max:1,step:.01},{key:`saturation`,label:`饱和度`,min:-1,max:1,step:.01},{key:`contrast`,label:`对比度`,min:-1,max:1,step:.01},{key:`hueRotate`,label:`色相`,min:0,max:360,step:1}];function Je({map:e,value:t,onChange:n,rasterPaintLayerIds:r=[],className:i,style:a}){let[o,s]=(0,c.useState)(!1),[l,u]=(0,c.useState)({...J}),d=(0,c.useRef)(null),f=(0,c.useRef)(null),h=t!==void 0;(0,c.useEffect)(()=>{let e=e=>{d.current&&!d.current.contains(e.target)&&f.current&&!f.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let g=(0,c.useMemo)(()=>h?{brightness:t.brightness??J.brightness,saturation:t.saturation??J.saturation,contrast:t.contrast??J.contrast,hueRotate:t.hueRotate??J.hueRotate}:l,[h,t,l]),_=(0,c.useRef)(h);(0,c.useEffect)(()=>{h&&!_.current&&u({...g}),_.current=h},[h,g]);let v=(0,c.useCallback)(t=>{if(!(!e||r.length===0))for(let n of r)e.getLayer(n)&&(e.setPaintProperty(n,`raster-brightness-min`,0),e.setPaintProperty(n,`raster-brightness-max`,t.brightness),e.setPaintProperty(n,`raster-saturation`,t.saturation),e.setPaintProperty(n,`raster-contrast`,t.contrast),e.setPaintProperty(n,`raster-hue-rotate`,t.hueRotate))},[e,r]),y=(0,c.useCallback)((e,t)=>{if(h)n?.({...g,[e]:t});else{let n={...l,[e]:t};u(n),v(n)}},[h,n,g,l,v]),b=(0,c.useCallback)(()=>{h?n?.({...J}):(u({...J}),v({...J}))},[h,n,v]);(0,c.useEffect)(()=>{!h&&r.length>0&&v(l)},[r,h,v,l]);let x=(e,t)=>e===`hueRotate`?`${Math.round(t)}°`:t.toFixed(2);return(0,p.jsxs)(`div`,{className:`mapbox-raster-paint-control${i?` ${i}`:``}`,style:a,children:[(0,p.jsxs)(`button`,{ref:f,className:`mapbox-control-btn mapbox-raster-paint-control__btn${o?` mapbox-raster-paint-control__btn--active`:``}`,onClick:()=>s(!o),title:`栅格渲染调节`,children:[(0,p.jsx)(`img`,{className:`mapbox-control-btn__icon mapbox-raster-paint-control__btn-icon`,src:q,alt:`raster paint`}),(0,p.jsx)(`span`,{children:`渲染`})]}),o&&(0,p.jsxs)(`div`,{ref:d,className:`mapbox-raster-paint-control__panel`,children:[qe.map(({key:e,label:t,min:n,max:r,step:i})=>(0,p.jsxs)(`div`,{className:`mapbox-raster-paint-control__slider-row`,children:[(0,p.jsx)(`span`,{className:`mapbox-raster-paint-control__label`,children:t}),(0,p.jsx)(m.Slider,{className:`mapbox-raster-paint-control__slider`,min:n,max:r,step:i,value:g[e],onChange:t=>y(e,t),tooltipVisible:!1}),(0,p.jsx)(`span`,{className:`mapbox-raster-paint-control__value`,children:x(e,g[e])})]},e)),(0,p.jsx)(`button`,{className:`mapbox-raster-paint-control__reset`,onClick:b,children:`重置`})]})]})}var Y=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769397418113'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='10253'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M755.4048%20217.2928A348.3648%20348.3648%200%200%200%20512%20119.3472a348.3136%20348.3136%200%200%200-243.3536%2097.8944%20328.4992%20328.4992%200%200%200-100.864%20236.3392c0%2049.408%2011.7248%2095.744%2032%20137.728a378.0096%20378.0096%200%200%200%2091.136%20118.4256l203.5712%20179.456%2017.5104%2015.4624%2017.5104-15.4624%20203.4176-179.3536a378.6752%20378.6752%200%200%200%2091.2384-118.4768c20.2752-41.984%2032.0512-88.32%2032.0512-137.7792a328.448%20328.448%200%200%200-100.8128-236.288z%20m24.1152%20353.3824a329.216%20329.216%200%200%201-79.872%20103.0656l-188.0064%20164.6592-187.1872-164.7616a329.0624%20329.0624%200%200%201-79.7696-103.0144%20267.0592%20267.0592%200%200%201-27.136-117.0944c0-78.7968%2032.9728-150.1184%2086.272-201.728a298.3936%20298.3936%200%200%201%20208.2816-83.5584c81.3056%200%20154.9824%2031.9488%20208.2304%2083.6096a279.9104%20279.9104%200%200%201%2086.272%20201.728%20266.496%20266.496%200%200%201-27.0848%20117.0944z%20m-164.1472-212.1728l0.0512-0.0512a146.9952%20146.9952%200%200%200-104.2432-43.2128c-40.6528%200-77.568%2016.5376-104.2432%2043.2128l0.0512%200.0512a147.3536%20147.3536%200%200%200-0.0512%20208.6912%20147.0464%20147.0464%200%200%200%20208.4864%200%20147.5072%20147.5072%200%200%200-0.0512-208.6912z%20m-34.1504%20174.2336a97.536%2097.536%200%200%201-69.2736%2028.7232%2097.6384%2097.6384%200%200%201-69.3248-28.7232%2097.792%2097.792%200%200%201-0.1536-138.4448h0.1024a97.9456%2097.9456%200%200%201%20138.5984%200h0.1536c17.664%2017.6128%2028.5696%2042.1376%2028.5696%2069.2224a97.1776%2097.1776%200%200%201-28.672%2069.2224z'%20fill='%23ffffff'%20p-id='10254'%3e%3c/path%3e%3c/svg%3e`;const Ye=({markerTemplates:e,selectedTemplate:t,onTemplateSelect:n,drawMode:r,onDrawModeChange:i,showRectangleTool:a=!1,showCircleTool:o=!1,showPolygonTool:s=!1,showSquareTool:l=!1,showPolylineTool:u=!1})=>{let[d,f]=(0,c.useState)(!1),m=(0,c.useRef)(null);(0,c.useEffect)(()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&f(!1)};if(d)return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[d]);let h=e=>{t?.id===e.id?(n(null),i(null)):(n(e),i(`marker`)),f(!1)},g=()=>{r===`rectangle`?i(null):(n(null),i(`rectangle`))},_=()=>{r===`circle`?i(null):(n(null),i(`circle`))},v=()=>{r===`polygon`?i(null):(n(null),i(`polygon`))},y=()=>{r===`square`?i(null):(n(null),i(`square`))},b=()=>{r===`polyline`?i(null):(n(null),i(`polyline`))},x=()=>{(r===`rectangle`||r===`circle`||r===`polygon`||r===`square`||r===`polyline`)&&i(null),f(!d)},S=e=>e.size?{width:e.size,height:e.size}:{width:e.width||32,height:e.height||32},C=d||t,w=r===`rectangle`,T=r===`circle`,E=r===`polygon`,D=r===`square`,O=r===`polyline`;return(0,p.jsxs)(`div`,{ref:m,className:`mapbox-edit-control`,children:[(0,p.jsxs)(`div`,{className:`mapbox-edit-control__btn-group`,children:[(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${C?`mapbox-control-btn--active`:``}`,onClick:x,title:`Marker`,children:[t?(0,p.jsx)(`img`,{src:t.icon,alt:t.name,className:`mapbox-edit-control__btn-icon`}):(0,p.jsx)(`img`,{src:Y,alt:`marker`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:t?t.name:`Marker`})]}),l&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${D?`mapbox-control-btn--active`:``}`,onClick:y,title:`绘制正方形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='192'%20y='192'%20width='640'%20height='640'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`square`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`正方形`})]}),a&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${w?`mapbox-control-btn--active`:``}`,onClick:g,title:`绘制矩形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='160'%20y='240'%20width='704'%20height='544'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`rectangle`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`矩形`})]}),o&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${T?`mapbox-control-btn--active`:``}`,onClick:_,title:`绘制圆形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3ccircle%20cx='512'%20cy='512'%20r='384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`circle`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`圆形`})]}),s&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${E?`mapbox-control-btn--active`:``}`,onClick:v,title:`绘制多边形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolygon%20points='512,128%20864,384%20736,800%20288,800%20160,384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'/%3e%3c/svg%3e`,alt:`polygon`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`多边形`})]}),u&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${O?`mapbox-control-btn--active`:``}`,onClick:b,title:`绘制折线`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolyline%20points='160,768%20384,256%20640,576%20864,192'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'%20stroke-linecap='round'/%3e%3c/svg%3e`,alt:`polyline`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`折线`})]})]}),d&&(0,p.jsxs)(`div`,{className:`mapbox-edit-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-edit-control__panel-header`,children:`选择 Marker`}),(0,p.jsx)(`div`,{className:`mapbox-edit-control__template-list`,children:e.map(e=>{let n=S(e),r=t?.id===e.id;return(0,p.jsxs)(`div`,{className:`mapbox-edit-control__template-item ${r?`mapbox-edit-control__template-item--selected`:``}`,onClick:()=>h(e),title:e.name,children:[(0,p.jsx)(`img`,{src:e.icon,alt:e.name,className:`mapbox-edit-control__template-icon`,style:{width:Math.min(n.width,24),height:Math.min(n.height,24)}}),(0,p.jsx)(`span`,{className:`mapbox-edit-control__template-name`,children:e.name})]},e.id)})})]})]})},Xe=({menuState:e,onClose:t,portalContainer:n,menuRef:r})=>{let i=(0,c.useRef)(null);(0,c.useEffect)(()=>(r&&(r.current=i.current),()=>{r&&(r.current=null)}));let a=(0,c.useCallback)(e=>{i.current&&!i.current.contains(e.target)&&t()},[t]),o=(0,c.useCallback)(e=>{e.key===`Escape`&&t()},[t]);(0,c.useEffect)(()=>{let e=setTimeout(()=>{document.addEventListener(`click`,a,!0),document.addEventListener(`contextmenu`,a,!0)},0);return document.addEventListener(`keydown`,o),()=>{clearTimeout(e),document.removeEventListener(`click`,a,!0),document.removeEventListener(`contextmenu`,a,!0),document.removeEventListener(`keydown`,o)}},[a,o]);let s={...e.position};if(i.current){let e=i.current.getBoundingClientRect();s.x+e.width>window.innerWidth&&(s.x=window.innerWidth-e.width-10),s.y+e.height>window.innerHeight&&(s.y=window.innerHeight-e.height-10)}let l=(0,p.jsx)(`div`,{ref:i,className:`context-menu`,style:{position:`fixed`,left:`${s.x}px`,top:`${s.y}px`,pointerEvents:`all`},children:e.items.map(e=>(0,p.jsxs)(`div`,{className:`context-menu__item ${e.danger?`context-menu__item--danger`:``}`,onClick:()=>{e.onClick(),t()},children:[e.icon&&(0,p.jsx)(`span`,{className:`context-menu__item-icon`,children:e.icon}),(0,p.jsx)(`span`,{className:`context-menu__item-label`,children:e.label})]},e.key))});return(0,f.createPortal)(l,n)};var Ze=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1775031767174'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='30653'%20data-spm-anchor-id='a313x.search_index.0.i6.78953a81FCkAe0'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='64'%20height='64'%3e%3cpath%20d='M322.24%20479.210667l-42.453333-42.432%20198.826666-198.826667c53.397333-53.376%20139.306667-53.568%20191.914667-0.981333%2052.608%2052.608%2052.416%20138.517333-0.981333%20191.914666L455.722667%20642.709333l-42.432-42.453333%20213.824-213.802667a74.773333%2074.773333%200%200%200-0.341334-105.728%2074.773333%2074.773333%200%200%200-105.728-0.341333l-198.826666%20198.826667z'%20fill='%23ffffff'%20p-id='30654'%3e%3c/path%3e%3cpath%20d='M699.093333%20613.333333l42.453334%2042.432-169.429334%20169.408c-48.341333%2048.341333-129.28%2042.282667-181.248-9.664-51.968-51.968-58.026667-132.906667-9.664-181.248l234.346667-234.346666%2042.432%2042.410666L423.616%20676.693333c-22.250667%2022.250667-19.050667%2065.024%2011.008%2095.061334%2030.037333%2030.058667%2072.810667%2033.258667%2095.061333%2010.986666l169.429334-169.408zM187.989333%20571.029333c-38.933333-38.933333-38.805333-102.613333%200.853334-142.293333%2039.68-39.68%20103.381333-39.808%20142.293333-0.853333%2038.954667%2038.912%2038.826667%20102.613333-0.853333%20142.293333-39.68%2039.658667-103.381333%2039.786667-142.293334%200.853333z%20m43.733334-43.733333c15.744%2015.744%2040.874667%2015.68%2056.128%200.426667%2015.253333-15.232%2015.296-40.362667-0.426667-56.106667-15.765333-15.744-40.896-15.701333-56.149333-0.448-15.232%2015.232-15.296%2040.384%200.448%2056.106667z'%20fill='%23ffffff'%20p-id='30655'%3e%3c/path%3e%3cpath%20d='M846.144%20489.728l-31.466667%20198.784-56.96-101.461333-104.042666-38.506667z'%20fill='%23ffffff'%20p-id='30656'%3e%3c/path%3e%3c/svg%3e`,X=`route-planning-temp-line`,Qe=`route-planning-temp-line-layer`,Z=`route-planning-temp-point-layer`;const $e=(0,c.forwardRef)(({map:e,pointCount:t=2,showPointCountInput:n=!1,visualType:r=`marker`,onSelectFinished:i,showButton:a=!0},o)=>{let[s,u]=(0,c.useState)(`idle`),[d,f]=(0,c.useState)(0),[m,h]=(0,c.useState)(t),[g,_]=(0,c.useState)(!1),v=(0,c.useRef)(null),y=(0,c.useRef)(null),b=(0,c.useRef)([]),x=(0,c.useRef)([]),S=(0,c.useRef)(`idle`),C=(0,c.useRef)(null),w=(0,c.useRef)(``);(0,c.useEffect)(()=>{S.current=s},[s]),(0,c.useEffect)(()=>{h(t)},[t]),(0,c.useEffect)(()=>{if(!g)return;let e=e=>{y.current&&!y.current.contains(e.target)&&v.current&&!v.current.contains(e.target)&&_(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[g]);let T=(0,c.useCallback)(()=>{for(let e of x.current)e.remove();x.current=[],e&&(e.getLayer(Qe)&&e.removeLayer(Qe),e.getLayer(Z)&&e.removeLayer(Z),e.getSource(X)&&e.removeSource(X))},[e]),E=(0,c.useCallback)(()=>{if(!e)return;let t=b.current,n={type:`FeatureCollection`,features:[{type:`Feature`,properties:{},geometry:{type:`LineString`,coordinates:t.length>=2?t:[]}},...t.map((e,t)=>({type:`Feature`,properties:{index:t},geometry:{type:`Point`,coordinates:e}}))]},r=e.getSource(X);r?r.setData(n):(e.addSource(X,{type:`geojson`,data:n}),e.addLayer({id:Qe,type:`line`,source:X,filter:[`==`,`$type`,`LineString`],paint:{"line-color":`#4A90D9`,"line-width":3,"line-dasharray":[2,2]}}),e.addLayer({id:Z,type:`circle`,source:X,filter:[`==`,`$type`,`Point`],paint:{"circle-radius":6,"circle-color":`#4A90D9`,"circle-stroke-width":2,"circle-stroke-color":`#fff`}}))},[e]),D=(0,c.useCallback)(t=>{if(!e||!C.current)return;let{visualType:n}=C.current;if(n===`marker`){let n=document.createElement(`div`);n.className=`route-planning-temp-marker`,n.textContent=String(b.current.length);let r=new l.default.Marker({element:n}).setLngLat(t).addTo(e);x.current.push(r)}else E()},[e,E]),O=(0,c.useCallback)(()=>{T(),b.current=[],C.current=null,f(0),u(`idle`),e&&(e.getCanvas().style.cursor=w.current)},[T,e]),k=(0,c.useCallback)(async()=>{let e=C.current,t=[...b.current];if(!e||t.length<2){O();return}u(`planning`);try{await e.onSelectFinished(t)}catch(e){console.error(`Route planning onSelectFinished failed:`,e)}finally{O()}},[O]),ee=(0,c.useCallback)(e=>{if(S.current!==`selecting`||!C.current)return;let t=[e.lngLat.lng,e.lngLat.lat];b.current.push(t);let n=b.current.length;f(n),D(t),n>=C.current.pointCount&&k()},[D,k]),A=(0,c.useCallback)(e=>{S.current===`selecting`&&(e.preventDefault(),O())},[O]);(0,c.useEffect)(()=>{if(e&&s===`selecting`)return e.on(`click`,ee),e.on(`contextmenu`,A),()=>{e.off(`click`,ee),e.off(`contextmenu`,A)}},[e,s,ee,A]);let j=(0,c.useCallback)(n=>{if(!e)return;S.current!==`idle`&&O();let i=Math.max(2,n.pointCount??t),a=n.visualType??r;C.current={pointCount:i,visualType:a,onSelectFinished:n.onSelectFinished},b.current=[],f(0),h(i),_(!1),w.current=e.getCanvas().style.cursor,e.getCanvas().style.cursor=`crosshair`,u(`selecting`)},[e,t,r,O]);(0,c.useImperativeHandle)(o,()=>({startPlanning:j}),[j]);let M=()=>{s===`idle`?_(e=>!e):s===`selecting`&&O()},te=()=>{i&&j({pointCount:Math.max(2,m),visualType:r,onSelectFinished:i})},ne=e=>{let t=parseInt(e.target.value,10);!isNaN(t)&&t>=2?h(t):e.target.value===``&&h(2)},N=()=>{if(s===`planning`)return(0,p.jsx)(`span`,{children:`规划中...`});if(s===`selecting`){let e=C.current?.pointCount??m;return(0,p.jsxs)(`span`,{children:[d,`/`,e]})}return`路径规划`},P=s===`selecting`,re=s===`planning`;return!a&&s===`idle`?null:(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control${a?``:` mapbox-route-planning-control--floating`}`,children:[(0,p.jsxs)(`button`,{ref:v,className:`mapbox-control-btn mapbox-route-planning-control__btn${P?` mapbox-route-planning-control__btn--active`:``}${re?` mapbox-route-planning-control__btn--planning`:``}${g?` mapbox-route-planning-control__btn--active`:``}`,onClick:M,disabled:re,title:s===`idle`?`路径规划`:s===`selecting`?`取消选点`:`规划中...`,children:[(0,p.jsx)(`img`,{src:Ze,alt:`route`,className:`mapbox-route-planning-control__btn-icon`}),N()]}),g&&s===`idle`&&(0,p.jsxs)(`div`,{ref:y,className:`mapbox-route-planning-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-route-planning-control__panel-header`,children:(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-title`,children:`路径规划`})}),(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control__panel-body`,children:[(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control__panel-row`,children:[(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-label`,children:`选点数量`}),n?(0,p.jsx)(`input`,{type:`number`,className:`mapbox-route-planning-control__panel-input`,value:m,min:2,onChange:ne}):(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-value`,children:m})]}),(0,p.jsx)(`div`,{className:`mapbox-route-planning-control__panel-tip`,children:`左键点击地图选点,右键取消`}),(0,p.jsx)(`button`,{className:`mapbox-route-planning-control__panel-start`,onClick:te,disabled:!i,children:`开始规划`})]})]})]})});$e.displayName=`RoutePlanningControl`;function et(e,t,n){return{content:e.content??n??null,trigger:e.trigger??t?.trigger??T.trigger,position:e.position??t?.position??T.position,offset:e.offset??t?.offset??T.offset,showCloseButton:e.showCloseButton??t?.showCloseButton??T.showCloseButton,animation:e.animation??t?.animation??T.animation,className:e.className??``,style:e.style??{},closeOnClickOutside:e.closeOnClickOutside??t?.closeOnClickOutside??T.closeOnClickOutside,closeOnEscape:e.closeOnEscape??t?.closeOnEscape??T.closeOnEscape,hoverDelay:e.hoverDelay??t?.hoverDelay??T.hoverDelay,maxWidth:e.maxWidth??t?.maxWidth??T.maxWidth,zIndex:e.zIndex??t?.zIndex??T.zIndex}}function tt(e,t,n,r,i){let a,o;if(e.type===`polygon`)o=e.center??nt(e.coordinates);else if(e.type===`polyline`)o=e.center??rt(e.coordinates);else if(e.type===`rectangle`)if(e.center)o=e.center;else{let[[t,n],[r,i]]=e.bounds;o=[(t+r)/2,(n+i)/2]}else o=e.center;let s=n.project(o);a={x:s.x,y:s.y};let c=it(i,t);return at(a,t.position,t.offset,c)}function nt(e){if(!e||e.length===0)return[0,0];let t=[...e];(e[0][0]!==e[e.length-1][0]||e[0][1]!==e[e.length-1][1])&&t.push(e[0]);let n=(0,u.polygon)([t]);return(0,u.centroid)(n).geometry.coordinates}function rt(e){if(!e||e.length===0)return[0,0];let t=0,n=0;for(let r of e)t+=r[0],n+=r[1];return[t/e.length,n/e.length]}function it(e,t){if(e){let t=e.getBoundingClientRect();return{width:t.width||320,height:t.height||200}}return{width:typeof t.maxWidth==`number`?t.maxWidth:320,height:200}}function at(e,t,n,r){let i={width:window.innerWidth,height:window.innerHeight},a=(()=>{switch(t){case`top`:return[`top`,`bottom`,`right`,`left`,`center`];case`bottom`:return[`bottom`,`top`,`right`,`left`,`center`];case`left`:return[`left`,`right`,`top`,`bottom`,`center`];case`right`:return[`right`,`left`,`top`,`bottom`,`center`];case`center`:default:return[`center`,`top`,`bottom`,`left`,`right`]}})(),o={top:()=>({x:e.x-r.width/2+n[0],y:e.y-r.height-20+n[1]}),bottom:()=>({x:e.x-r.width/2+n[0],y:e.y+20+n[1]}),left:()=>({x:e.x-r.width-20+n[0],y:e.y-r.height/2+n[1]}),right:()=>({x:e.x+20+n[0],y:e.y-r.height/2+n[1]}),center:()=>({x:e.x-r.width/2+n[0],y:e.y-r.height/2+n[1]})},s=e=>e.x>=10&&e.y>=10&&e.x+r.width+10<=i.width&&e.y+r.height+10<=i.height;for(let e of a){let t=o[e]();if(s(t))return{position:t,actualPosition:e}}let c=o[t]();return{position:ot(c,r),actualPosition:t}}function ot(e,t){let n={width:window.innerWidth,height:window.innerHeight},r={...e};return r.x+t.width+10>n.width&&(r.x=n.width-t.width-10),r.x<10&&(r.x=10),r.y+t.height+10>n.height&&(r.y=n.height-t.height-10),r.y<10&&(r.y=10),r}const st=(0,c.forwardRef)((e,t)=>{let{center:n=[116.4074,39.9042],zoom:r=12,pitch:i=0,bearing:a=0,style:o=`mapbox://styles/mapbox/dark-v11`,maxBounds:s,mode:u=`display`,editConfig:d={},pickerConfig:f={},onPick:m,interactive:h={},layers:g=[],rasterPaint:_,entities:v=[],selectedIds:y=[],entityConfig:b,nameConfig:C,selectNameConfig:w,areaConfig:T,circleConfig:E,lengthConfig:k,showCoordinates:M=!0,showScale:te=!0,showResetView:ne=!0,showRoadHighlight:N=!1,showMeasure:P=!1,showRasterPaint:re=!1,showRoutePlanning:ie,onRasterPaintChange:ae,popupDefaults:F,renderPopup:I,onMapLoad:oe,onEntityClick:ce,onPopupOpen:me,onPopupClose:L,className:ge=``,containerStyle:ve}=e,be=(0,c.useRef)(null),Ce=(0,c.useRef)(null),R=(0,c.useRef)(null),z=(0,c.useRef)(new Map),B=(0,c.useRef)(new Map),De=(0,c.useRef)(new Set),[V,Oe]=(0,c.useState)(null),ke=(0,c.useRef)(null),je=(0,c.useRef)(null),Me=(0,c.useRef)(null),[Ne,Pe]=(0,c.useState)(null),Fe=(0,c.useRef)(null),Ie=(0,c.useRef)(null),[Re,ze]=(0,c.useState)(null),[H,Be]=(0,c.useState)(u),[Ve,He]=(0,c.useState)(null),Ue=(0,c.useRef)(null),[U,W]=(0,c.useState)(null),[We,G]=(0,c.useState)(null),[Ge,K]=(0,c.useState)(null),q=(0,c.useRef)(!1),J=(0,c.useRef)(null),qe=(0,c.useRef)(null),Y=(0,c.useRef)(null),Ze=(0,c.useRef)(null),X=(0,c.useRef)(null),Qe=(0,c.useRef)([]),Z=(0,c.useRef)(null),nt=(0,c.useRef)(null),rt=(0,c.useRef)(null),it=(0,c.useRef)([]),at=(0,c.useRef)(null),ot=(0,c.useRef)(!1),[st,ct]=(0,c.useState)([]),lt=(0,c.useRef)([]);lt.current=st;let Q=(0,c.useRef)(null);(0,c.useEffect)(()=>{Be(u)},[u]);let ut=(0,c.useCallback)(e=>{let t=z.current.get(e),n=B.current.get(e);if(t&&n){if(n.type===`radar`&&t instanceof se){let r={...n,isAnimating:!0};B.current.set(e,r),t.startAnimation()}else if(n.type===`circle`&&t instanceof _e){let r={...n,isAnimating:!0};B.current.set(e,r),t.startAnimation()}}},[]),dt=(0,c.useCallback)(e=>{let t=z.current.get(e),n=B.current.get(e);if(t&&n){if(n.type===`radar`&&t instanceof se){let r={...n,isAnimating:!1};B.current.set(e,r),t.stopAnimation()}else if(n.type===`circle`&&t instanceof _e){let r={...n,isAnimating:!1};B.current.set(e,r),t.stopAnimation()}}},[]),ft=(0,c.useCallback)(e=>{let t=B.current.get(e);t&&(t.type===`radar`||t.type===`circle`)&&(t.type,t.isAnimating?dt(e):ut(e))},[ut,dt]),pt=(0,c.useCallback)(e=>{if(e===void 0){let e=!1;for(let[,t]of z.current)if(t instanceof de){let n=t.getShowTrajectory();if(n===`all`||typeof n==`number`&&n>0){e=!0;break}}let t=e?0:`all`;for(let[,e]of z.current)e instanceof de&&e.setShowTrajectory(t)}else{let t=new Set(e.map(String));for(let[e,n]of z.current)n instanceof de&&n.setShowTrajectory(t.has(String(e))?`all`:0)}},[]),mt=(0,c.useCallback)((e,t,n)=>{let r=v.find(t=>String(t.id)===String(e));if(!r?.popup||!R.current)return;let i=r.popup.content??I?.(r);if(!i)return;let a=et(r.popup,F,i),{position:o,actualPosition:s}=tt(r,a,R.current,n);Oe({entityId:e,position:o,config:a,openedBy:t,actualPosition:s}),me?.(e)},[v,F,I,me]),ht=(0,c.useCallback)(e=>{V?.entityId===e&&(Oe(null),L?.(e))},[V,L]),gt=(0,c.useCallback)(()=>{Oe(e=>(e&&L?.(e.entityId),null))},[L]),_t=(0,c.useCallback)(e=>V?.entityId===e,[V]),vt=(0,c.useCallback)((e,t,n)=>{let r=R.current;r&&r.flyTo({center:e,zoom:t??r.getZoom(),...n})},[]),yt=(0,c.useCallback)((e,t,n)=>{let r=R.current;if(!r||e.length===0)return;let i=[];for(let t of e){let e=z.current.get(t);e&&i.push(e.getBounds())}if(i.length===0)return;let a=1/0,o=-1/0,s=1/0,c=-1/0;for(let[[e,t],[n,r]]of i)a=Math.min(a,e),o=Math.max(o,n),s=Math.min(s,t),c=Math.max(c,r);let l=(a+o)/2,u=(s+c)/2,d=a===o&&s===c;if(i.length===1||d){let e={center:[l,u],zoom:t??r.getZoom()};n?.duration!==void 0&&(e.duration=n.duration),n?.pitch!==void 0&&(e.pitch=n.pitch),n?.bearing!==void 0&&(e.bearing=n.bearing),n?.essential!==void 0&&(e.essential=n.essential),r.flyTo(e);return}let f=[[a,s],[o,c]],p={padding:n?.padding??50,duration:n?.duration??1e3,bearing:n?.bearing??r.getBearing(),pitch:n?.pitch??r.getPitch()};t!==void 0&&(p.maxZoom=t),n?.essential!==void 0&&(p.essential=n.essential),r.fitBounds(f,p)},[]),bt=(0,c.useCallback)(e=>{let t=R.current;if(!t||!t.getContainer())return;let{showMarker:n=!0,markerColor:r=`#3388ff`,name:i,nameConfig:a}=f;if(!n){Ue.current&&=(Ue.current.remove(),null);return}if(Ue.current){Ue.current.setLngLat(e);let t=Ue.current.getElement(),n=t.querySelector(`.marker-label`);if(i){let e=x(a,C);if(n)n.textContent=i,n.style.color=e.fillColor,n.style.opacity=String(e.fillOpacity),n.style.webkitTextStrokeColor=e.strokeColor,n.style.webkitTextStrokeWidth=`${e.strokeWidth}px`;else{let n=document.createElement(`div`);n.className=`marker-label`,n.textContent=i,n.style.color=e.fillColor,n.style.opacity=String(e.fillOpacity),n.style.webkitTextStrokeColor=e.strokeColor,n.style.webkitTextStrokeWidth=`${e.strokeWidth}px`,t.appendChild(n)}}else n&&n.remove()}else{let n=document.createElement(`div`);n.className=`mapbox-picker-marker`;let o=document.createElement(`div`);if(o.className=`marker-inner`,o.style.background=r,n.appendChild(o),i){let e=x(a,C),t=document.createElement(`div`);t.className=`marker-label`,t.textContent=i,t.style.color=e.fillColor,t.style.opacity=String(e.fillOpacity),t.style.webkitTextStrokeColor=e.strokeColor,t.style.webkitTextStrokeWidth=`${e.strokeWidth}px`,n.appendChild(t)}Ue.current=new l.default.Marker({element:n,anchor:`bottom`}).setLngLat(e).addTo(t)}},[f,C]),xt=(0,c.useCallback)(()=>{Ue.current&&=(Ue.current.remove(),null)},[]),St=(0,c.useCallback)(()=>`marker-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,[]),Ct=(0,c.useCallback)(e=>{let t=R.current;if(be.current)if(at.current&&=(at.current.remove(),null),e&&t){t.getCanvas().style.cursor=`none`;let n=document.createElement(`div`);n.className=`mapbox-custom-cursor`;let r=e.size||e.width||32;n.style.cssText=`
52
52
  position: fixed;
53
53
  pointer-events: none;
54
54
  z-index: 9999;