leiting-bim 2.1.126 → 2.1.128

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.
@@ -1,4 +1,4 @@
1
- (function(D,te){typeof exports=="object"&&typeof module<"u"?te(exports):typeof define=="function"&&define.amd?define(["exports"],te):(D=typeof globalThis<"u"?globalThis:D||self,te(D.CesiumCore={}))})(this,(function(D){"use strict";var Oo=Object.defineProperty;var Ro=(D,te,V)=>te in D?Oo(D,te,{enumerable:!0,configurable:!0,writable:!0,value:V}):D[te]=V;var h=(D,te,V)=>Ro(D,typeof te!="symbol"?te+"":te,V);class te{constructor(t,e,i){h(this,"Cesium");h(this,"viewer");h(this,"labelPool");h(this,"threshold");h(this,"displayLimit");h(this,"maxLevel");h(this,"debugCurrentGrids");h(this,"levels");h(this,"points",[]);h(this,"gridLayers",new Map);h(this,"debugGrids",[]);h(this,"_updateFn");h(this,"clusterTheme");h(this,"pointTheme");h(this,"centralPointMode");h(this,"minGlobalPointCount");h(this,"groupByTheme");h(this,"tilingScheme");h(this,"terrainLevelOffset");h(this,"debugTileCoordLayer",null);h(this,"levelIndexByTileLevel",new Map);h(this,"_lastTileProvider",null);h(this,"_updateTimer",null);h(this,"_updateDelay",100);h(this,"_tilesRetryCount",0);h(this,"_tilesRetryMax",100);h(this,"_cameraDirty",!1);h(this,"_tileLoadListener",null);h(this,"_cameraChangedHandler",null);h(this,"defaultMinLevel",0);h(this,"defaultMaxLevel",28);h(this,"maxRefineLevels",2);this.Cesium=t,this.viewer=e,this.labelPool=i.labelPool,this.threshold=i.threshold??10,this.displayLimit=i.displayLimit??100,this.maxLevel=i.maxLevel??5,this.debugCurrentGrids=i.debugCurrentGrids??!1,this.clusterTheme=i.clusterTheme??"cluster-label",this.pointTheme=i.pointTheme??"point-label",this.centralPointMode=i.centralPointMode??"central",this.minGlobalPointCount=i.minGlobalPointCount??0,this.groupByTheme=i.groupByTheme??!1,this.terrainLevelOffset=i.terrainLevelOffset??2;const o=this.viewer.scene&&this.viewer.scene.globe,s=o&&o._surface,r=s&&s._tileProvider,n=(r==null?void 0:r.tilingScheme)||new this.Cesium.GeographicTilingScheme;this._lastTileProvider=r,this.tilingScheme=n,this.levels=this._createLevels(),this._buildLevels(),this._updateFn=this._update.bind(this),this.debugCurrentGrids&&this._ensureDebugImageryLayer(),o&&(this._tileLoadListener=l=>{l===0&&this._cameraDirty&&(this._cameraDirty=!1,this._scheduleUpdate())},o.tileLoadProgressEvent.addEventListener(this._tileLoadListener)),this._cameraChangedHandler=()=>{this._update()},this.viewer.camera.changed.addEventListener(this._cameraChangedHandler)}setGroupByTheme(t,e=!0,i=!0){if(this.groupByTheme===t){i&&this._update();return}this.groupByTheme=t,e&&this._buildLevels(),i&&this._update()}setMinGlobalPointCount(t,e=!0){this.minGlobalPointCount=t,e&&this._update()}setThreshold(t,e=!0){this.threshold=t,e&&this._update()}setDebugCurrentGrids(t,e=!0){this.debugCurrentGrids=t,t?this._ensureDebugImageryLayer():(this._clearDebugGrids(),this._removeDebugImageryLayer()),e&&this._update()}_syncTilingSchemeAndLevels(){const t=this.viewer.scene&&this.viewer.scene.globe,e=t&&t._surface,i=e&&e._tileProvider,o=(i==null?void 0:i.tilingScheme)||new this.Cesium.GeographicTilingScheme,s=i!==this._lastTileProvider,r=this.tilingScheme!==o;!s&&!r&&this.levels&&this.levels.length>0||(this._lastTileProvider=i,this.tilingScheme=o,this.levels=this._createLevels(),this._buildLevels(),this.debugCurrentGrids&&(this._removeDebugImageryLayer(),this._ensureDebugImageryLayer()))}_createLevels(){const t=[];this.levelIndexByTileLevel=new Map;const e=0,i=this.maxLevel;let o=0;for(let s=e;s<=i;s++,o++){const r=360/Math.pow(2,s);t.push({level:s,size:r,minViewWidth:r*4}),this.levelIndexByTileLevel.set(s,o)}return t}addPoints(t){this.points=t,this._buildLevels()}appendPoints(t,e=!0){for(const i of t)this._preparePointLevelRange(i),this.points.push(i);for(const i of t)this._addPointToGrid(i);e&&this._scheduleUpdate()}_scheduleUpdate(){this._updateTimer!==null&&clearTimeout(this._updateTimer),this._updateTimer=window.setTimeout(()=>{this._update(),this._cameraDirty=!0,this._updateTimer=null},this._updateDelay)}updatePoint(t){var s,r,n,l;const e=this.points.findIndex(c=>c.id===t.id);if(e===-1)return;const i=this.points[e];for(const c of this.levels){const d=c.level,u=this.gridLayers.get(d);if(!u)continue;const m=this.Cesium.Cartographic.fromDegrees(i.lon,i.lat),g=this.tilingScheme.positionToTileXY(m,d,new this.Cesium.Cartesian2);if(!g)continue;const p=`${g.x}_${g.y}`,y=u.get(p);if(y){const w=y.allPoints.findIndex(f=>f.id===t.id);if(w!==-1&&y.allPoints.splice(w,1),(n=(r=(s=i.data)==null?void 0:s.billboard)==null?void 0:r[0])!=null&&n.skipAggregation){const f=y.skipPoints.findIndex(v=>v.id===t.id);f!==-1&&y.skipPoints.splice(f,1)}else{const f=this.groupByTheme?(l=i.data)==null?void 0:l.theme:this.clusterTheme,v=y.groups.get(f);if(v){const C=v.findIndex(b=>b.id===t.id);C!==-1&&v.splice(C,1),v.length===0&&y.groups.delete(f)}}}}const o={...i,...t};this.points[e]=o,this._addPointToGrid(o),this._update()}removePointsById(t){const e=new Set(t);this.points=this.points.filter(i=>!e.has(i.id));for(const i of this.levels){const o=this.gridLayers.get(i.level);if(o)for(const[s,r]of o.entries()){r.allPoints=r.allPoints.filter(n=>!e.has(n.id)),r.skipPoints=r.skipPoints.filter(n=>!e.has(n.id));for(const[n,l]of r.groups.entries()){const c=l.filter(d=>!e.has(d.id));c.length===0?r.groups.delete(n):r.groups.set(n,c)}r.allPoints.length===0&&o.delete(s)}}this._update()}_buildLevels(){this.gridLayers.clear();for(const t of this.levels)this.gridLayers.set(t.level,new Map);for(const t of this.points)this._addPointToGrid(t)}_addPointToGrid(t){var e,i,o,s,r,n;for(const l of this.levels){const c=l.level,d=this.gridLayers.get(c);if(!d)continue;const u=this.Cesium.Cartographic.fromDegrees(t.lon,t.lat),m=this.tilingScheme.positionToTileXY(u,c,new this.Cesium.Cartesian2);if(!m)continue;const g=`${m.x}_${m.y}`;let p=d.get(g);if(p||(p={allPoints:[],groups:new Map,skipPoints:[]},d.set(g,p)),p.allPoints.push(t),(o=(i=(e=t.data)==null?void 0:e.billboard)==null?void 0:i[0])!=null&&o.skipAggregation)p.skipPoints.push(t);else{const y=this.groupByTheme?(n=(r=(s=t.data)==null?void 0:s.billboard)==null?void 0:r[0])==null?void 0:n.theme:this.clusterTheme;p.groups.has(y)||p.groups.set(y,[]),p.groups.get(y).push(t)}}}_preparePointLevelRange(t){const e=t.data||{};let i=e.minLevel,o=e.maxLevel;const s=e.levelRange;Array.isArray(s)?(s.length>0&&i==null&&(i=s[0]),s.length>1&&o==null&&(o=s[1])):s&&typeof s=="object"&&(i==null&&typeof s.min=="number"&&(i=s.min),o==null&&typeof s.max=="number"&&(o=s.max));const r=i==null?this.defaultMinLevel:Number(i)||this.defaultMinLevel,n=o==null?this.defaultMaxLevel:Number(o)||this.defaultMaxLevel;t.__minLevel=r,t.__maxLevel=n}_isVisibleAtLevel(t,e){if(e==null)return!0;(t.__minLevel===void 0||t.__maxLevel===void 0)&&this._preparePointLevelRange(t);const i=t.__minLevel??this.defaultMinLevel,o=t.__maxLevel??this.defaultMaxLevel;return e>=i&&e<=o}_update(){if(!this.labelPool)return;this._syncTilingSchemeAndLevels(),this.labelPool.reset(),this.debugCurrentGrids&&this._clearDebugGrids();const t=this.points.length<this.minGlobalPointCount?1/0:this.threshold;let e=0;const i=(o,s,r,n)=>{e=this._processCell(o,s,r,n,t,e)};try{const o=this._getSurfaceTiles();if(!o||o.length===0){this._handleNoSurfaceTiles(e);return}this._tilesRetryCount=0,this._processTiles(o,i)}catch{this.labelPool.cleanup();return}this.labelPool.cleanup()}_getSurfaceTiles(){const t=this.viewer.scene&&this.viewer.scene.globe,e=t&&t._surface;if(e)return e._tilesToRender||e._tilesToRenderByTextureCount}_handleNoSurfaceTiles(t){var e,i,o,s;for(const r of this.points){if(t>=this.displayLimit)break;((e=r.data)==null?void 0:e.show)!==!1&&(this.labelPool.add(r.data,{id:`point-${r.id}`,lon:r.lon,lat:r.lat,height:r.height,theme:((s=(o=(i=r.data)==null?void 0:i.billboard)==null?void 0:o[0])==null?void 0:s.theme)||this.pointTheme,style:r.style}),t++)}this.labelPool.cleanup(),this.points.length>0&&this._tilesRetryCount<this._tilesRetryMax&&(this._tilesRetryCount++,this._scheduleUpdate())}_resolveLevelIndex(t){let e=this.levelIndexByTileLevel.get(t);if(e!==void 0)return e;if(this.levels.length===0)return;const i=this.levels[0].level,o=this.levels[this.levels.length-1].level;if(t>o)return this.levels.length-1;if(t<i)return 0;let s=0,r=1/0;for(let n=0;n<this.levels.length;n++){const l=Math.abs(this.levels[n].level-t);l<r&&(r=l,s=n)}return s}_isTerrainEnabled(){const t=this.viewer.terrainProvider,e=this.viewer.scene,i=e&&e.globe,o=i&&i.terrainProvider,s=t||o;return s?!(s instanceof this.Cesium.EllipsoidTerrainProvider):!1}_getGridRefLevel(t){let e=t;if(this._isTerrainEnabled()&&(e+=this.terrainLevelOffset),this.levels.length>0){const i=this.levels[this.levels.length-1].level;e>i&&(e=i)}return e}_processTiles(t,e){const i=new Set,o=this.viewer.scene,s=o&&o.globe,r=s&&s.ellipsoid,n=r&&o.camera.computeViewRectangle(r),l=(c,d,u)=>{if(!n)return!0;const m=this.tilingScheme.tileXYToRectangle(c,d,u);return!(!m||m.east<=n.west||m.west>=n.east||m.north<=n.south||m.south>=n.north)};for(const c of t){const d=c.rectangle,u=c._level??c.level;if(!d||typeof u!="number")continue;const m=this._getGridRefLevel(u),g=this._resolveLevelIndex(m);if(g===void 0)continue;const p=this.levels[g].level,y=c._x??c.x,w=c._y??c.y;if(typeof y=="number"&&typeof w=="number"){const x=u-p;if(x>=0){const T=1<<x,A=Math.floor(y/T),$=Math.floor(w/T),R=`${p}_${A}_${$}`;if(i.has(R))continue;i.add(R),e(g,A,$,u)}else{const A=1<<Math.min(-x,this.maxRefineLevels),$=y*A,R=w*A;for(let _=0;_<A;_++)for(let O=0;O<A;O++){const k=$+_,G=R+O;if(!l(k,G,p))continue;const B=`${p}_${k}_${G}`;i.has(B)||(i.add(B),e(g,k,G,u))}}continue}const v=this.levels[g].size,C=this.Cesium.Math.toDegrees(d.west),b=this.Cesium.Math.toDegrees(d.east),M=this.Cesium.Math.toDegrees(d.south),P=this.Cesium.Math.toDegrees(d.north),L=Math.floor((C- -180)/v),E=Math.floor((b- -180)/v),I=Math.floor((M- -90)/v),S=Math.floor((P- -90)/v);for(let x=L;x<=E;x++)for(let T=I;T<=S;T++){if(!l(x,T,p))continue;const A=`${p}_${x}_${T}`;i.has(A)||(i.add(A),e(g,x,T,u))}}}_processCell(t,e,i,o,s,r){if(r>=this.displayLimit||t<0)return r;t>=this.levels.length&&(t=this.levels.length-1);const n=this._getCellContext(t,e,i,o);return n?(r=this._processCellSkipPoints(n,r),r>=this.displayLimit?(this._debugDrawCell(n),r):(r=this._processCellGroups(n,s,r),this._debugDrawCell(n),r)):r}_getCellContext(t,e,i,o){const r=this.levels[t].level,n=this.gridLayers.get(r);if(!n)return null;const l=`${e}_${i}`,c=n.get(l);if(!c)return null;const d=this.tilingScheme.tileXYToRectangle(e,i,r),u=this.Cesium.Math.toDegrees(d.west),m=this.Cesium.Math.toDegrees(d.south),g=this.Cesium.Math.toDegrees(d.east),p=this.Cesium.Math.toDegrees(d.north),y=(u+g)/2,w=(m+p)/2;return{levelIdx:t,tileLevel:r,lonIdx:e,latIdx:i,key:l,cell:c,rect:d,west:u,south:m,east:g,north:p,centerLon:y,centerLat:w,viewTileLevel:o}}_processCellSkipPoints(t,e){var r,n,l,c;const{cell:i,viewTileLevel:o}=t,s=o;for(const d of i.skipPoints)if(((r=d.data)==null?void 0:r.show)!==!1){if(e>=this.displayLimit)break;this._isVisibleAtLevel(d,s)&&(this.labelPool.add(d.data,{id:`point-${d.id}`,lon:d.lon,lat:d.lat,height:d.height,theme:((c=(l=(n=d.data)==null?void 0:n.billboard)==null?void 0:l[0])==null?void 0:c.theme)||this.pointTheme,style:d.style}),e++)}return e}_processCellGroups(t,e,i){var m,g,p,y,w,f,v,C,b,M,P,L,E;const{levelIdx:o,lonIdx:s,latIdx:r,cell:n,centerLon:l,centerLat:c,viewTileLevel:d}=t,u=d;for(const[I,S]of n.groups){const x=S.filter(_=>{var O;return((O=_.data)==null?void 0:O.show)!==!1});if(x.length===0)continue;let T=l,A=c,$=((m=x[0])==null?void 0:m.height)||0;if(this.centralPointMode=="firstPoint"&&(T=((g=x[0])==null?void 0:g.lon)||0,A=((p=x[0])==null?void 0:p.lat)||0,$=((y=x[0])==null?void 0:y.height)||0),o===this.levels.length-1||x.length<e)for(const _ of x){if(i>=this.displayLimit)break;this._isVisibleAtLevel(_,u)&&(this.labelPool.add(_.data,{id:`point-${_.id}`,lon:_.lon,lat:_.lat,height:_.height,theme:((v=(f=(w=_.data)==null?void 0:w.billboard)==null?void 0:f[0])==null?void 0:v.theme)||this.pointTheme,style:_.style}),i++)}else{if(i>=this.displayLimit)return i;const _=u==null?x:x.filter(B=>this._isVisibleAtLevel(B,u));if(!_.length)return i;const k=((P=(M=(b=(C=_[0])==null?void 0:C.data)==null?void 0:b.billboard)==null?void 0:M[0])==null?void 0:P.theme)||this.clusterTheme,G=this.groupByTheme?`cluster-${o}-${s}-${r}-${I}`:`cluster-${o}-${s}-${r}`;this.labelPool.add({id:G,billboard:((E=(L=_[0])==null?void 0:L.data)==null?void 0:E.billboard)||[],count:_.length,gridKey:`${s}_${r}`,points:_,aggregationGroup:I},{id:G,lon:T,lat:A,height:$,theme:k}),i++}}return i}_debugDrawCell(t){if(!this.debugCurrentGrids)return;const{levelIdx:e,west:i,south:o,east:s,north:r,lonIdx:n,latIdx:l}=t,c=this.levels[e].level;this._drawDebugGrid(i,o,s,r,`L:${c} X:${n} Y:${l}`)}refresh(){this._update()}_drawDebugGrid(t,e,i,o,s){const r=this.Cesium.Rectangle.fromDegrees(t,e,i,o),n=this.Cesium.Cartesian3.fromDegreesArray([t,e,i,e,i,o,t,o,t,e]),l=this.viewer.entities.add({rectangle:{coordinates:r,material:this.Cesium.Color.YELLOW.withAlpha(.2),outline:!0,outlineColor:this.Cesium.Color.RED,heightReference:this.Cesium.HeightReference.CLAMP_TO_GROUND,classificationType:this.Cesium.ClassificationType.TERRAIN},polyline:{positions:n,width:2,material:this.Cesium.Color.RED,clampToGround:!0},label:{text:s,font:"14px sans-serif",fillColor:this.Cesium.Color.BLACK,outlineColor:this.Cesium.Color.WHITE,outlineWidth:2,style:this.Cesium.LabelStyle.FILL_AND_OUTLINE,verticalOrigin:this.Cesium.VerticalOrigin.CENTER,horizontalOrigin:this.Cesium.HorizontalOrigin.CENTER}});this.debugGrids.push(l)}_clearDebugGrids(){for(const t of this.debugGrids)this.viewer.entities.remove(t);this.debugGrids=[]}_ensureDebugImageryLayer(){if(this.debugTileCoordLayer||!this.viewer||!this.viewer.imageryLayers)return;const t={tilingScheme:this.tilingScheme};this.debugTileCoordLayer=this.viewer.imageryLayers.addImageryProvider(new this.Cesium.TileCoordinatesImageryProvider(t))}_removeDebugImageryLayer(){if(!(!this.debugTileCoordLayer||!this.viewer||!this.viewer.imageryLayers)){try{this.viewer.imageryLayers.remove(this.debugTileCoordLayer,!1)}catch{}this.debugTileCoordLayer=null}}destroy(){this._cameraChangedHandler&&(this.viewer.camera.changed.removeEventListener(this._cameraChangedHandler),this._cameraChangedHandler=null);const t=this.viewer.scene,e=t&&t.globe;e&&this._tileLoadListener&&(e.tileLoadProgressEvent.removeEventListener(this._tileLoadListener),this._tileLoadListener=null),this._updateTimer!==null&&(clearTimeout(this._updateTimer),this._updateTimer=null),this.labelPool.reset(),this._clearDebugGrids(),this._removeDebugImageryLayer()}}var V=(a=>(a.Click="marker:click",a.DoubleClick="marker:dblclick",a.RightClick="marker:rightclick",a.MouseEnter="marker:mouseenter",a.MouseLeave="marker:mouseleave",a.MouseDown="marker:mousedown",a.MouseUp="marker:mouseup",a))(V||{});class tt{constructor(){h(this,"listenerMap",new Map)}addListener(t,e,i=!1){let o=this.listenerMap.get(t);return o||(o=new Map,this.listenerMap.set(t,o)),o.has(e.name)?i?(console.warn(`[MarkerEventBus] Overwriting listener "${e.name}" for event "${t}".`),o.set(e.name,e),!0):(console.warn(`[MarkerEventBus] Listener "${e.name}" for event "${t}" already exists. Use overwrite=true to replace it.`),!1):(o.set(e.name,e),!0)}removeListenerByKey(t){const e=this.listenerMap.has(t);return this.listenerMap.set(t,new Map),e}removeListenerByKeyAndName(t,e){const i=this.listenerMap.get(t);return i?i.delete(e):!1}runListener(t,e,i){const o=this.listenerMap.get(t);if(o)for(const[s,r]of o.entries()){try{r.fn(e,i)}catch(n){console.error(`Error in listener "${s}" for event "${t}":`,n)}r.once&&o.delete(s)}}}const it={[V.Click]:"click",[V.DoubleClick]:"dblclick",[V.RightClick]:"contextmenu",[V.MouseEnter]:"mouseenter",[V.MouseLeave]:"mouseleave",[V.MouseDown]:"mousedown",[V.MouseUp]:"mouseup"};class N{constructor(t,e,i="html-label-container",o,s=!0){h(this,"viewer");h(this,"Cesium");h(this,"container");h(this,"labels",new Map);h(this,"activeIds",new Set);h(this,"_updateFn");h(this,"themes",{});h(this,"eventBus");h(this,"openWheel",!0);this.Cesium=t,this.viewer=e,this.container=this._createContainer(i),this._updateFn=this._update.bind(this),this.viewer.scene.postRender.addEventListener(this._updateFn),this.eventBus=o||new tt,this.openWheel=s}_createContainer(t){let e=document.getElementById(t);return e||(e=document.createElement("div"),e.id=t,Object.assign(e.style,{position:"absolute",top:"0",left:"0",pointerEvents:"none",width:"100%",height:"100%",zIndex:"100",overflow:"hidden"}),document.body.appendChild(e)),e}registerTheme(t,e){this.themes[t]=e}add(t,e){const{id:i,lon:o,lat:s,height:r=0,theme:n,show:l=!0,notCreateElement:c=!1,style:d}=e,u=this.themes[n];if(!u){console.warn(`Theme "${n}" not registered`);return}let m=this.labels.get(i);if(m){m.theme=n,m.data=t,m.notCreateElement=c;try{m.unload=u.createElement(m.el,{id:i,theme:n,data:t},u),(!c||l)&&this.container.appendChild(m.el)}catch(g){console.error(`Error updating label element for id "${i}":`,g)}}else{const g=document.createElement("div");Object.assign(g.style,{position:"absolute",transform:"translate(0, 0)",pointerEvents:"auto",...e.style||{}});for(const[y,w]of Object.entries(it)){g.addEventListener(w,v=>{v.stopPropagation();const C=this.labels.get(i);this.eventBus.runListener(y,C,v)});let f=0;g.addEventListener("wheel",v=>{if(!this.openWheel)return;const C=v.currentTarget;f=Date.now();const b=f;C.style.pointerEvents="none",setTimeout(()=>{f===b&&(C.style.pointerEvents="auto")},2e3)})}let p=null;if(!c||l){try{p=u.createElement(g,{id:i,theme:n,data:t},u)||{}}catch(y){console.error(`Error updating label element for id "${i}":`,y)}this.container.appendChild(g)}m={id:i,el:g,theme:n,data:t,notCreateElement:c,unload:p},this.labels.set(i,m)}m.el.dataset.lon=String(o),m.el.dataset.lat=String(s),m.el.dataset.height=String(r),m.el.style.zIndex=(d==null?void 0:d.zIndex)||"1",m.el.style.display=l?"block":"none",l&&this.activeIds.add(i)}addBatch(t){for(const{data:e,options:i}of t)this.add(e,i)}removeByIds(t){for(const e of t){const i=this.labels.get(e);i&&(this.unloadByLabel(i),this.labels.delete(e),this.activeIds.delete(e))}}unloadByLabel(t){t.el.remove(),t!=null&&t.unload&&typeof t.unload=="function"&&(t==null||t.unload()),t.unload=null}removeAll(){for(const t of this.labels.values())this.unloadByLabel(t);this.labels.clear(),this.activeIds.clear()}update(t,e){const i=this.labels.get(t);if(!i){console.warn(`Label with id "${t}" not found for update.`);return}const o=this.themes[i.theme];if(!o){console.warn(`Theme "${i.theme}" not registered.`);return}try{o.createElement(i.el,{id:t,theme:i.theme,data:e},o)}catch(s){console.error(`Failed to update label "${t}":`,s)}}hideByIds(t){for(const e of t){const i=this.labels.get(e);i&&(i.notCreateElement&&this.unloadByLabel(i),i.el.style.display="none",this.activeIds.delete(e))}}hideAll(){for(const t of this.labels.values())t.notCreateElement&&this.unloadByLabel(t),t.el.style.display="none",this.activeIds.delete(t.id)}hideFilter(t){for(const e of this.labels.values())t(e.data)&&(e.notCreateElement&&this.unloadByLabel(e),e.el.style.display="none",this.activeIds.delete(e.id))}showByIds(t){for(const e of t){const i=this.labels.get(e);if(i){if((i.notCreateElement||!i.el.parentNode)&&this.container.appendChild(i.el),!i.unload)try{const o=this.themes[i.theme];if(!o){console.warn(`Theme "${i.theme}" not registered`);return}i.unload=o.createElement(i.el,{id:e,theme:i.theme,data:i.data},o)||{}}catch(o){console.error(`Error creating label element for theme "${i.theme}":`,o);return}i.el.style.display="block",this.activeIds.add(e)}}}has(t){return this.labels.has(t)}reset(){for(const t of this.activeIds.values()){let e=this.labels.get(t);e&&this.unloadByLabel(e)}this.activeIds.clear()}cleanup(){for(const[t,e]of this.labels.entries())this.activeIds.has(t)||(e.el.style.display="none")}async toWindowPositionByLonLat(t,e){const i=this.Cesium,o=this.viewer.scene,s=[i.Cartographic.fromDegrees(t,e)];let r;try{r=await o.clampToHeightMostDetailed(s)}catch{console.warn("clampToHeightMostDetailed failed, fallback to ellipsoid height.")}let n=0;r&&r[0]&&r[0].height!=null?n=r[0].height:n=0;const l=i.Cartesian3.fromDegrees(t,e,n);return this.toWindowCoordinates(l)}toWindowCoordinates(t){const e=this.viewer.scene,i=this.Cesium.SceneTransforms;if(typeof(i==null?void 0:i.wgs84ToWindowCoordinates)=="function")return i.wgs84ToWindowCoordinates(e,t);if(typeof(i==null?void 0:i.worldToWindowCoordinates)=="function")return i.worldToWindowCoordinates(e,t);console.warn("No compatible window coordinate transform function found.")}_isValidCoordinate(t,e){return!(Number.isNaN(t)||Number.isNaN(e)||t===0&&e===0||t<-180||t>180||e<-90||e>90)}async _update(){var t;for(const e of this.activeIds){const i=this.labels.get(e);if(!i)continue;const o=parseFloat(i.el.dataset.lon),s=parseFloat(i.el.dataset.lat),r=parseFloat(i.el.dataset.height||"0");if(!this._isValidCoordinate(o,s)){i.el.style.display="none";continue}const n=this.Cesium.Cartesian3.fromDegrees(o,s,r),l=this.toWindowCoordinates(n);if(this.Cesium.defined(l)){const d=((t=this.themes[i.theme].options)==null?void 0:t.offset)||{},u=d.x||0,m=d.y||0;i.el.style.left=`${l.x}px`,i.el.style.top=`${l.y}px`,i.el.style.transform=`translate(${u}px, ${m}px)`,i.el.style.display="block"}else i.el.style.display="none"}}destroy(){this.viewer.scene.postRender.removeEventListener(this._updateFn),this.labels.clear(),this.activeIds.clear()}}class xe{constructor(){h(this,"tooltipEl");h(this,"visible",!1);h(this,"offsetX",10);h(this,"offsetY",-20);h(this,"onMouseMove",null);this.tooltipEl=document.createElement("div"),this.tooltipEl.style.position="fixed",this.tooltipEl.style.pointerEvents="none",this.tooltipEl.style.zIndex="10000",this.tooltipEl.style.padding="4px 8px",this.tooltipEl.style.borderRadius="4px",this.tooltipEl.style.background="rgba(0, 0, 0, 0.7)",this.tooltipEl.style.color="#fff",this.tooltipEl.style.fontSize="13px",this.tooltipEl.style.transition="opacity 0.1s ease",this.tooltipEl.style.opacity="0",document.body.appendChild(this.tooltipEl),this.onMouseMove=t=>{this.visible&&(this.tooltipEl.style.left=`${t.clientX+this.offsetX}px`,this.tooltipEl.style.top=`${t.clientY+this.offsetY}px`)},window.addEventListener("mousemove",this.onMouseMove)}show(t){this.tooltipEl.innerText=t,this.tooltipEl.style.opacity="1",this.visible=!0}hide(){this.tooltipEl.style.opacity="0",this.visible=!1}destroy(){this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.tooltipEl.parentElement&&this.tooltipEl.parentElement.removeChild(this.tooltipEl)}}class Gt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"entity",null);h(this,"tooltip",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.tooltip=new xe,this.tooltip.show("左键添加点"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var m,g;const s=i.scene.pickPosition(o.position);if(!s)return;const r=e.Cartographic.fromCartesian(s),n=e.Math.toDegrees(r.longitude),l=e.Math.toDegrees(r.latitude),c=r.height,d=i.entities.add({position:s,point:{pixelSize:10,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.entity=d;const u={entity:d,position:s,lnglat:{lng:n,lat:l,height:c},clear:()=>{this.clear()}};(m=t.onComplete)==null||m.call(t,u),this.stopDrawing(),(g=this.tooltip)==null||g.hide(),this.tooltip=null},e.ScreenSpaceEventType.LEFT_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.stopDrawing()}}class Bt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.tempPoints=[],this.tooltip=new xe,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var n,l;const s=i.scene.pickPosition(o.position);if(!s)return;this.positions.push(s);const r=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(r),this.entity||(this.entity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>this.positions,!1),width:3,material:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY,depthFailMaterial:((l=(n=t.color)==null?void 0:n.withAlpha)==null?void 0:l.call(n,.5))||e.Color.YELLOW.withAlpha(.5)}}))},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var r,n;if(this.stopDrawing(),(r=this.tooltip)==null||r.hide(),this.tooltip=null,this.positions.length<2)return;this.positions.length=this.positions.length-1;const o=this.positions.map(l=>{const c=e.Cartographic.fromCartesian(l);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),s={entity:this.entity,positions:this.positions,lnglats:o,clear:()=>{this.clear()}};(n=t.onComplete)==null||n.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.stopDrawing()}}class jt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"startPoint",null);h(this,"endPoint",null);h(this,"entity",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var r;const s=i.scene.pickPosition(o.position);if(s)if(!this.startPoint)this.startPoint=s,this.entity=i.entities.add({rectangle:{coordinates:new e.CallbackProperty(()=>{if(!(!this.startPoint||!this.endPoint))try{const n=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c=Math.min(n.longitude,l.longitude),d=Math.max(n.longitude,l.longitude),u=Math.min(n.latitude,l.latitude),m=Math.max(n.latitude,l.latitude);return new e.Rectangle(c,u,d,m)}catch(n){console.warn("Rectangle calculation error:",n);return}},!1),material:t.color||e.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:e.Color.BLACK,disableDepthTestDistance:Number.POSITIVE_INFINITY}});else{this.stopDrawing();const n=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c={lng:e.Math.toDegrees(Math.min(n.longitude,l.longitude)),lat:e.Math.toDegrees(Math.min(n.latitude,l.latitude)),height:0},d={lng:e.Math.toDegrees(Math.max(n.longitude,l.longitude)),lat:e.Math.toDegrees(Math.max(n.latitude,l.latitude)),height:0},u={entity:this.entity,position:this.startPoint,lnglat:{lng:e.Math.toDegrees(n.longitude),lat:e.Math.toDegrees(n.latitude),height:n.height},positions:[this.startPoint,this.endPoint],lnglats:[c,d],clear:()=>{this.clear()}};(r=t.onComplete)==null||r.call(t,u)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(o=>{if(!this.startPoint)return;const s=i.scene.pickPosition(o.endPosition);s&&(this.endPoint=s)},e.ScreenSpaceEventType.MOUSE_MOVE)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.startPoint=null,this.endPoint=null,this.stopDrawing()}}class Yt{constructor(t,e){h(this,"viewer");h(this,"Cesium");h(this,"handler",null);h(this,"entity",null);h(this,"positions",[]);h(this,"_isDrawing",!1);h(this,"currentRadius",0);this.Cesium=t,this.viewer=e}startDrawing(t){this.clear(),this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.canvas),this._isDrawing=!0,this.handler.setInputAction(e=>{const i=this.viewer.scene.pickPosition(e.position);i&&(this.positions.push(i),this.positions.length===2&&(this.stopDrawing(),this.drawFinalCircle(t)))},this.Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(e=>{if(this.positions.length!==1)return;const i=this.positions[0],o=this.viewer.camera.getPickRay(e.endPosition),s=this.viewer.scene.globe.pick(o,this.viewer.scene);s&&this.drawPreviewCircle(i,s,t)},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE)}drawPreviewCircle(t,e,i){const o=this.Cesium.Cartesian3.distance(t,e);if(this.entity)Math.abs(this.currentRadius-o)>.5&&(this.currentRadius=o);else{this.currentRadius=o;const s=new this.Cesium.CallbackProperty(()=>this.currentRadius,!1);this.entity=this.viewer.entities.add({position:t,ellipse:{semiMajorAxis:s,semiMinorAxis:s,material:i.color||this.Cesium.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:i.color||this.Cesium.Color.YELLOW,heightReference:this.Cesium.HeightReference.NONE,disableDepthTestDistance:Number.POSITIVE_INFINITY}})}}drawFinalCircle(t){var u;const[e,i]=this.positions,o=this.Cesium.Cartesian3.distance(e,i),s=this.Cesium.Cartographic.fromCartesian(e),r={lng:this.Cesium.Math.toDegrees(s.longitude),lat:this.Cesium.Math.toDegrees(s.latitude),height:s.height},n=(t==null?void 0:t.step)||1,l=[],c=[];for(let m=0;m<360;m+=n){const g=this.Cesium.Math.toRadians(m),p=new this.Cesium.EllipsoidGeodesic;p.setEndPoints(s,new this.Cesium.Cartographic(s.longitude+1e-4*Math.cos(g),s.latitude+1e-4*Math.sin(g)));const y=p.interpolateUsingSurfaceDistance(o),w=this.Cesium.Ellipsoid.WGS84.cartographicToCartesian(y);l.push(w);const f=this.Cesium.Cartographic.fromCartesian(w);c.push({lng:this.Cesium.Math.toDegrees(f.longitude),lat:this.Cesium.Math.toDegrees(f.latitude),height:f.height})}c.push(c[0]);const d=this.positions.map(m=>{const g=this.Cesium.Cartographic.fromCartesian(m);return{lng:this.Cesium.Math.toDegrees(g.longitude),lat:this.Cesium.Math.toDegrees(g.latitude),height:g.height}});(u=t.onComplete)==null||u.call(t,{entity:this.entity,positions:this.positions,lnglats:d,circlePoints:l,circleLnglats:c,center:r,radius:o,clear:()=>{this.clear()}})}stopDrawing(){this.handler&&(this.handler.destroy(),this.handler=null),this._isDrawing=!1}clear(){this.stopDrawing(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.positions=[],this.currentRadius=0}}class Vt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.tempPoints=[],this.tooltip=new xe,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{const s=i.scene.pickPosition(o.position);if(!s)return;this.positions.push(s);const r=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY,heightReference:e.HeightReference.CLAMP_TO_GROUND}});this.tempPoints.push(r),this.entity||(this.entity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>({positions:this.positions}),!1),material:t.color||e.Color.YELLOW.withAlpha(.5)}}))},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var r,n;if(this.stopDrawing(),(r=this.tooltip)==null||r.hide(),this.tooltip=null,this.positions.length<3)return;this.positions.length=this.positions.length-1;const o=this.positions.map(l=>{const c=e.Cartographic.fromCartesian(l);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),s={entity:this.entity,positions:this.positions,lnglats:o,clear:()=>{this.clear()}};(n=t.onComplete)==null||n.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.stopDrawing()}}class Wt{constructor(t,e){h(this,"viewer");h(this,"Cesium");h(this,"activeDrawer",null);this.viewer=e,this.Cesium=t}draw(t,e){var i;switch(this.clear(),t){case"point":this.activeDrawer=new Gt(this.Cesium,this.viewer);break;case"line":this.activeDrawer=new Bt(this.Cesium,this.viewer);break;case"rectangle":this.activeDrawer=new jt(this.Cesium,this.viewer);break;case"circle":this.activeDrawer=new Yt(this.Cesium,this.viewer);break;case"polygon":this.activeDrawer=new Vt(this.Cesium,this.viewer);break;default:throw new Error(`Unsupported draw type: ${t}`)}(i=this.activeDrawer)==null||i.startDrawing(e)}clear(){this.activeDrawer&&(this.activeDrawer.stopDrawing(),this.activeDrawer.clear(),this.activeDrawer=null)}cancel(){this.clear()}}var st=typeof global=="object"&&global&&global.Object===Object&&global,Ut=typeof self=="object"&&self&&self.Object===Object&&self,se=st||Ut||Function("return this")(),me=se.Symbol,rt=Object.prototype,Kt=rt.hasOwnProperty,qt=rt.toString,be=me?me.toStringTag:void 0;function Xt(a){var t=Kt.call(a,be),e=a[be];try{a[be]=void 0;var i=!0}catch{}var o=qt.call(a);return i&&(t?a[be]=e:delete a[be]),o}var Jt=Object.prototype,Qt=Jt.toString;function Zt(a){return Qt.call(a)}var ei="[object Null]",ti="[object Undefined]",ot=me?me.toStringTag:void 0;function Pe(a){return a==null?a===void 0?ti:ei:ot&&ot in Object(a)?Xt(a):Zt(a)}function Le(a){return a!=null&&typeof a=="object"}var _e=Array.isArray;function De(a){var t=typeof a;return a!=null&&(t=="object"||t=="function")}var ii="[object AsyncFunction]",si="[object Function]",ri="[object GeneratorFunction]",oi="[object Proxy]";function nt(a){if(!De(a))return!1;var t=Pe(a);return t==si||t==ri||t==ii||t==oi}var Fe=se["__core-js_shared__"],at=(function(){var a=/[^.]+$/.exec(Fe&&Fe.keys&&Fe.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""})();function ni(a){return!!at&&at in a}var ai=Function.prototype,li=ai.toString;function ce(a){if(a!=null){try{return li.call(a)}catch{}try{return a+""}catch{}}return""}var hi=/[\\^$.*+?()[\]{}|]/g,ci=/^\[object .+?Constructor\]$/,di=Function.prototype,pi=Object.prototype,ui=di.toString,mi=pi.hasOwnProperty,gi=RegExp("^"+ui.call(mi).replace(hi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function fi(a){if(!De(a)||ni(a))return!1;var t=nt(a)?gi:ci;return t.test(ce(a))}function yi(a,t){return a==null?void 0:a[t]}function de(a,t){var e=yi(a,t);return fi(e)?e:void 0}var ke=de(se,"WeakMap"),lt=Object.create,wi=(function(){function a(){}return function(t){if(!De(t))return{};if(lt)return lt(t);a.prototype=t;var e=new a;return a.prototype=void 0,e}})(),ht=(function(){try{var a=de(Object,"defineProperty");return a({},"",{}),a}catch{}})();function vi(a,t){for(var e=-1,i=a==null?0:a.length;++e<i&&t(a[e],e,a)!==!1;);return a}var Ci=9007199254740991,bi=/^(?:0|[1-9]\d*)$/;function Pi(a,t){var e=typeof a;return t=t??Ci,!!t&&(e=="number"||e!="symbol"&&bi.test(a))&&a>-1&&a%1==0&&a<t}function Li(a,t,e){t=="__proto__"&&ht?ht(a,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):a[t]=e}function ct(a,t){return a===t||a!==a&&t!==t}var Ei=Object.prototype,Mi=Ei.hasOwnProperty;function Ii(a,t,e){var i=a[t];(!(Mi.call(a,t)&&ct(i,e))||e===void 0&&!(t in a))&&Li(a,t,e)}var Ti=9007199254740991;function dt(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=Ti}function xi(a){return a!=null&&dt(a.length)&&!nt(a)}var _i=Object.prototype;function pt(a){var t=a&&a.constructor,e=typeof t=="function"&&t.prototype||_i;return a===e}function Di(a,t){for(var e=-1,i=Array(a);++e<a;)i[e]=t(e);return i}var Si="[object Arguments]";function ut(a){return Le(a)&&Pe(a)==Si}var mt=Object.prototype,Ai=mt.hasOwnProperty,$i=mt.propertyIsEnumerable,Oi=ut((function(){return arguments})())?ut:function(a){return Le(a)&&Ai.call(a,"callee")&&!$i.call(a,"callee")};function Ri(){return!1}var gt=typeof D=="object"&&D&&!D.nodeType&&D,ft=gt&&typeof module=="object"&&module&&!module.nodeType&&module,Fi=ft&&ft.exports===gt,yt=Fi?se.Buffer:void 0,ki=yt?yt.isBuffer:void 0,wt=ki||Ri,Hi="[object Arguments]",zi="[object Array]",Ni="[object Boolean]",Gi="[object Date]",Bi="[object Error]",ji="[object Function]",Yi="[object Map]",Vi="[object Number]",Wi="[object Object]",Ui="[object RegExp]",Ki="[object Set]",qi="[object String]",Xi="[object WeakMap]",Ji="[object ArrayBuffer]",Qi="[object DataView]",Zi="[object Float32Array]",es="[object Float64Array]",ts="[object Int8Array]",is="[object Int16Array]",ss="[object Int32Array]",rs="[object Uint8Array]",os="[object Uint8ClampedArray]",ns="[object Uint16Array]",as="[object Uint32Array]",z={};z[Zi]=z[es]=z[ts]=z[is]=z[ss]=z[rs]=z[os]=z[ns]=z[as]=!0,z[Hi]=z[zi]=z[Ji]=z[Ni]=z[Qi]=z[Gi]=z[Bi]=z[ji]=z[Yi]=z[Vi]=z[Wi]=z[Ui]=z[Ki]=z[qi]=z[Xi]=!1;function ls(a){return Le(a)&&dt(a.length)&&!!z[Pe(a)]}function He(a){return function(t){return a(t)}}var vt=typeof D=="object"&&D&&!D.nodeType&&D,Ee=vt&&typeof module=="object"&&module&&!module.nodeType&&module,hs=Ee&&Ee.exports===vt,ze=hs&&st.process,ge=(function(){try{var a=Ee&&Ee.require&&Ee.require("util").types;return a||ze&&ze.binding&&ze.binding("util")}catch{}})(),Ct=ge&&ge.isTypedArray,cs=Ct?He(Ct):ls,ds=Object.prototype,ps=ds.hasOwnProperty;function us(a,t){var e=_e(a),i=!e&&Oi(a),o=!e&&!i&&wt(a),s=!e&&!i&&!o&&cs(a),r=e||i||o||s,n=r?Di(a.length,String):[],l=n.length;for(var c in a)ps.call(a,c)&&!(r&&(c=="length"||o&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Pi(c,l)))&&n.push(c);return n}function bt(a,t){return function(e){return a(t(e))}}var ms=bt(Object.keys,Object),gs=Object.prototype,fs=gs.hasOwnProperty;function ys(a){if(!pt(a))return ms(a);var t=[];for(var e in Object(a))fs.call(a,e)&&e!="constructor"&&t.push(e);return t}function ws(a){return xi(a)?us(a):ys(a)}var Me=de(Object,"create");function vs(){this.__data__=Me?Me(null):{},this.size=0}function Cs(a){var t=this.has(a)&&delete this.__data__[a];return this.size-=t?1:0,t}var bs="__lodash_hash_undefined__",Ps=Object.prototype,Ls=Ps.hasOwnProperty;function Es(a){var t=this.__data__;if(Me){var e=t[a];return e===bs?void 0:e}return Ls.call(t,a)?t[a]:void 0}var Ms=Object.prototype,Is=Ms.hasOwnProperty;function Ts(a){var t=this.__data__;return Me?t[a]!==void 0:Is.call(t,a)}var xs="__lodash_hash_undefined__";function _s(a,t){var e=this.__data__;return this.size+=this.has(a)?0:1,e[a]=Me&&t===void 0?xs:t,this}function pe(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}pe.prototype.clear=vs,pe.prototype.delete=Cs,pe.prototype.get=Es,pe.prototype.has=Ts,pe.prototype.set=_s;function Ds(){this.__data__=[],this.size=0}function Se(a,t){for(var e=a.length;e--;)if(ct(a[e][0],t))return e;return-1}var Ss=Array.prototype,As=Ss.splice;function $s(a){var t=this.__data__,e=Se(t,a);if(e<0)return!1;var i=t.length-1;return e==i?t.pop():As.call(t,e,1),--this.size,!0}function Os(a){var t=this.__data__,e=Se(t,a);return e<0?void 0:t[e][1]}function Rs(a){return Se(this.__data__,a)>-1}function Fs(a,t){var e=this.__data__,i=Se(e,a);return i<0?(++this.size,e.push([a,t])):e[i][1]=t,this}function oe(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}oe.prototype.clear=Ds,oe.prototype.delete=$s,oe.prototype.get=Os,oe.prototype.has=Rs,oe.prototype.set=Fs;var Ie=de(se,"Map");function ks(){this.size=0,this.__data__={hash:new pe,map:new(Ie||oe),string:new pe}}function Hs(a){var t=typeof a;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?a!=="__proto__":a===null}function Ae(a,t){var e=a.__data__;return Hs(t)?e[typeof t=="string"?"string":"hash"]:e.map}function zs(a){var t=Ae(this,a).delete(a);return this.size-=t?1:0,t}function Ns(a){return Ae(this,a).get(a)}function Gs(a){return Ae(this,a).has(a)}function Bs(a,t){var e=Ae(this,a),i=e.size;return e.set(a,t),this.size+=e.size==i?0:1,this}function fe(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}fe.prototype.clear=ks,fe.prototype.delete=zs,fe.prototype.get=Ns,fe.prototype.has=Gs,fe.prototype.set=Bs;function js(a,t){for(var e=-1,i=t.length,o=a.length;++e<i;)a[o+e]=t[e];return a}var Ys=bt(Object.getPrototypeOf,Object);function Vs(){this.__data__=new oe,this.size=0}function Ws(a){var t=this.__data__,e=t.delete(a);return this.size=t.size,e}function Us(a){return this.__data__.get(a)}function Ks(a){return this.__data__.has(a)}var qs=200;function Xs(a,t){var e=this.__data__;if(e instanceof oe){var i=e.__data__;if(!Ie||i.length<qs-1)return i.push([a,t]),this.size=++e.size,this;e=this.__data__=new fe(i)}return e.set(a,t),this.size=e.size,this}function ye(a){var t=this.__data__=new oe(a);this.size=t.size}ye.prototype.clear=Vs,ye.prototype.delete=Ws,ye.prototype.get=Us,ye.prototype.has=Ks,ye.prototype.set=Xs;var Pt=typeof D=="object"&&D&&!D.nodeType&&D,Lt=Pt&&typeof module=="object"&&module&&!module.nodeType&&module,Js=Lt&&Lt.exports===Pt,Et=Js?se.Buffer:void 0;Et&&Et.allocUnsafe;function Qs(a,t){return a.slice()}function Zs(a,t){for(var e=-1,i=a==null?0:a.length,o=0,s=[];++e<i;){var r=a[e];t(r,e,a)&&(s[o++]=r)}return s}function er(){return[]}var tr=Object.prototype,ir=tr.propertyIsEnumerable,Mt=Object.getOwnPropertySymbols,sr=Mt?function(a){return a==null?[]:(a=Object(a),Zs(Mt(a),function(t){return ir.call(a,t)}))}:er;function rr(a,t,e){var i=t(a);return _e(a)?i:js(i,e(a))}function or(a){return rr(a,ws,sr)}var Ne=de(se,"DataView"),Ge=de(se,"Promise"),Be=de(se,"Set"),It="[object Map]",nr="[object Object]",Tt="[object Promise]",xt="[object Set]",_t="[object WeakMap]",Dt="[object DataView]",ar=ce(Ne),lr=ce(Ie),hr=ce(Ge),cr=ce(Be),dr=ce(ke),ne=Pe;(Ne&&ne(new Ne(new ArrayBuffer(1)))!=Dt||Ie&&ne(new Ie)!=It||Ge&&ne(Ge.resolve())!=Tt||Be&&ne(new Be)!=xt||ke&&ne(new ke)!=_t)&&(ne=function(a){var t=Pe(a),e=t==nr?a.constructor:void 0,i=e?ce(e):"";if(i)switch(i){case ar:return Dt;case lr:return It;case hr:return Tt;case cr:return xt;case dr:return _t}return t});var pr=Object.prototype,ur=pr.hasOwnProperty;function mr(a){var t=a.length,e=new a.constructor(t);return t&&typeof a[0]=="string"&&ur.call(a,"index")&&(e.index=a.index,e.input=a.input),e}var St=se.Uint8Array;function je(a){var t=new a.constructor(a.byteLength);return new St(t).set(new St(a)),t}function gr(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.byteLength)}var fr=/\w*$/;function yr(a){var t=new a.constructor(a.source,fr.exec(a));return t.lastIndex=a.lastIndex,t}var At=me?me.prototype:void 0,$t=At?At.valueOf:void 0;function wr(a){return $t?Object($t.call(a)):{}}function vr(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.length)}var Cr="[object Boolean]",br="[object Date]",Pr="[object Map]",Lr="[object Number]",Er="[object RegExp]",Mr="[object Set]",Ir="[object String]",Tr="[object Symbol]",xr="[object ArrayBuffer]",_r="[object DataView]",Dr="[object Float32Array]",Sr="[object Float64Array]",Ar="[object Int8Array]",$r="[object Int16Array]",Or="[object Int32Array]",Rr="[object Uint8Array]",Fr="[object Uint8ClampedArray]",kr="[object Uint16Array]",Hr="[object Uint32Array]";function zr(a,t,e){var i=a.constructor;switch(t){case xr:return je(a);case Cr:case br:return new i(+a);case _r:return gr(a);case Dr:case Sr:case Ar:case $r:case Or:case Rr:case Fr:case kr:case Hr:return vr(a);case Pr:return new i;case Lr:case Ir:return new i(a);case Er:return yr(a);case Mr:return new i;case Tr:return wr(a)}}function Nr(a){return typeof a.constructor=="function"&&!pt(a)?wi(Ys(a)):{}}var Gr="[object Map]";function Br(a){return Le(a)&&ne(a)==Gr}var Ot=ge&&ge.isMap,jr=Ot?He(Ot):Br,Yr="[object Set]";function Vr(a){return Le(a)&&ne(a)==Yr}var Rt=ge&&ge.isSet,Wr=Rt?He(Rt):Vr,Ft="[object Arguments]",Ur="[object Array]",Kr="[object Boolean]",qr="[object Date]",Xr="[object Error]",kt="[object Function]",Jr="[object GeneratorFunction]",Qr="[object Map]",Zr="[object Number]",Ht="[object Object]",eo="[object RegExp]",to="[object Set]",io="[object String]",so="[object Symbol]",ro="[object WeakMap]",oo="[object ArrayBuffer]",no="[object DataView]",ao="[object Float32Array]",lo="[object Float64Array]",ho="[object Int8Array]",co="[object Int16Array]",po="[object Int32Array]",uo="[object Uint8Array]",mo="[object Uint8ClampedArray]",go="[object Uint16Array]",fo="[object Uint32Array]",H={};H[Ft]=H[Ur]=H[oo]=H[no]=H[Kr]=H[qr]=H[ao]=H[lo]=H[ho]=H[co]=H[po]=H[Qr]=H[Zr]=H[Ht]=H[eo]=H[to]=H[io]=H[so]=H[uo]=H[mo]=H[go]=H[fo]=!0,H[Xr]=H[kt]=H[ro]=!1;function $e(a,t,e,i,o,s){var r;if(r!==void 0)return r;if(!De(a))return a;var n=_e(a);if(n)r=mr(a);else{var l=ne(a),c=l==kt||l==Jr;if(wt(a))return Qs(a);if(l==Ht||l==Ft||c&&!o)r=c?{}:Nr(a);else{if(!H[l])return o?a:{};r=zr(a,l)}}s||(s=new ye);var d=s.get(a);if(d)return d;s.set(a,r),Wr(a)?a.forEach(function(g){r.add($e(g,t,e,g,a,s))}):jr(a)&&a.forEach(function(g,p){r.set(p,$e(g,t,e,p,a,s))});var u=or,m=n?void 0:u(a);return vi(m||a,function(g,p){m&&(p=g,g=a[p]),Ii(r,p,$e(g,t,e,p,a,s))}),r}var yo=1,wo=4;function Oe(a){return $e(a,yo|wo)}var zt=(a=>(a.Rotate="rotate",a.Move="move",a.Scale="scale",a.MoveHeight="moveHeight",a.Empty="",a))(zt||{}),Nt=(a=>(a.Scale="addScale",a.Rotate="rotate",a.Translation="translation",a.Remove="removeById",a.Add="add",a))(Nt||{});class vo{constructor(t){h(this,"primitives",new Map);h(this,"eventListener",new Map);h(this,"Cesium");h(this,"viewer");h(this,"handler");h(this,"rotationRing");h(this,"translationSquare");h(this,"heightArrow");h(this,"editMode","");h(this,"dragEndCallbackMap",new Map);this.Cesium=t.Cesium,this.viewer=t.viewer,this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)}init(t,e=!1){const i=this.viewer;this.primitives.forEach(o=>{i.scene.primitives.remove(o)}),t.forEach(o=>{this.primitives.has(o.id)||this.add(o,e)})}get(t){return this.primitives.get(t)}add(t,e=!0){var u,m,g;const i=this.viewer,o=this.Cesium,s=o.Math.toRadians(((u=t.headingPitchRoll)==null?void 0:u.heading)||0),r=o.Math.toRadians(((m=t.headingPitchRoll)==null?void 0:m.pitch)||0),n=o.Math.toRadians(((g=t.headingPitchRoll)==null?void 0:g.roll)||0),l=new o.HeadingPitchRoll(s,r,n),c=o.Transforms.headingPitchRollToFixedFrame(t.position,l,i.scene.globe.ellipsoid,o.Transforms.eastNorthUpToFixedFrame,new o.Matrix4);let d=i.scene.primitives.add(o.Model.fromGltf({id:t.id,...t.model,modelMatrix:c}));d.scale=t.scale||1,this.primitives.set(t.id,d),d.show=e,this.runEventListener("add",{info:t,gltf:d})}flyTo(t){const e=this.viewer,i=this.Cesium;let o=this.primitives.get(t);const s=o.boundingSphere,r=i.Matrix4.multiplyByPoint(o.modelMatrix,s.center,new i.Cartesian3),n=new i.BoundingSphere(r,s.radius);e.camera.flyToBoundingSphere(n,{duration:1.5,offset:new i.HeadingPitchRange(0,-.5,s.radius*2)})}removeById(t){var o;const e=this.viewer;let i=this.primitives.get(t);if(!i){console.error(`No model found with id: ${t}`);return}e.scene.primitives.remove(i),this.primitives.delete(t),(!((o=this.rotationRing)!=null&&o._instanceIds.includes(`rotationRing_${t}`))||!this.rotationRing)&&this.removeTool(),this.runEventListener("removeById",{id:t,gltf:i})}show(t){let e=this.primitives.get(t);e&&(e.show=!0)}hide(t){let e=this.primitives.get(t);e&&(e.show=!1)}addScale(t,e=.1){let i=this.primitives.get(t.id);i&&(i.scale=i.scale+e,this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t.id,scale:i.scale}))}setScale(t,e=.1){let i=this.primitives.get(t);i&&(i.scale=e,this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t,scale:i.scale}))}setEditMode(t){this.editMode=t}lockCamera(){const t=this.viewer.scene.screenSpaceCameraController;t.enableRotate=!1,t.enableTranslate=!1,t.enableZoom=!1}unlockCamera(){const t=this.viewer.scene.screenSpaceCameraController;t.enableRotate=!0,t.enableTranslate=!0,t.enableZoom=!0}toCartographic(t){const e=this.Cesium.Cartographic.fromCartesian(t);return{longitude:e.longitude,latitude:e.latitude}}calculateHeading(t,e){const i=e.longitude-t.longitude,o=e.latitude-t.latitude;return Math.atan2(o,i)}getModelHeadingPitchRoll(t){const e=this.Cesium,i=this.viewer,o=e.Transforms.eastNorthUpToFixedFrame(e.Matrix4.getTranslation(t,new e.Cartesian3),i.scene.globe.ellipsoid,new e.Matrix4),s=e.Matrix4.multiply(e.Matrix4.inverse(o,new e.Matrix4),t,new e.Matrix4),r=e.Matrix4.getRotation(s,new e.Matrix3),n=e.Quaternion.fromRotationMatrix(r);return e.HeadingPitchRoll.fromQuaternion(n)}addEventListener(t,e,i){let o={f:e,options:i};return this.eventListener.get(t)?(this.eventListener.get(t)||[]).push(o):this.eventListener.set(t,[o]),o}removeEventListener(t,e){let i=this.eventListener.get(t);if(!i)return console.error("key不存在");let o=i.findIndex(s=>s==e);o>=0?i.splice(o,1):console.error("instantiation不存在")}runEventListener(t,e){let i=this.eventListener.get(t);return i?(i.forEach(o=>{typeof o.f=="function"&&o.f(e)}),!0):!1}initEditBox(t){const e=this.Cesium,i=this.viewer,o=i.scene;let s=null,r=null,n=null,l=null,c=null;const d=()=>{s=null,r=null,n=null,c=null,l=null,this.setEditMode(""),this.unlockCamera()},u=(m,g)=>{if(s=this.primitives.get(m),s){r=e.Matrix4.clone(s.modelMatrix);const p=e.Matrix4.getTranslation(r,new e.Cartesian3);n=this.toCartographic(p),c=g.position;const y=o.globe.pick(i.camera.getPickRay(g.position),o);l=this.toCartographic(y),this.lockCamera()}};this.handler.setInputAction(m=>{var y,w,f,v,C,b,M,P,L,E;if(!t())return;const p=o.pick(m.position);if(p&&p.id&&((y=p.id)!=null&&y.includes("rotationRing"))){let I=p.id.split("rotationRing_")[1];this.setEditMode("rotate"),u(I,m)}else if(p&&p.id&&((w=p.id)!=null&&w.includes("translationSquare_"))){let I=p.id.split("translationSquare_")[1];this.setEditMode("move"),u(I,m)}else if(p&&p.id&&((f=p.id)!=null&&f.includes("heightArrow-line_"))){let I=p.id.split("heightArrow-line_")[1];this.setEditMode("moveHeight"),u(I,m)}else if(p&&p.id&&((v=p.id)!=null&&v.includes("heightArrow-arrow_"))){let I=p.id.split("heightArrow-arrow_")[1];this.setEditMode("moveHeight"),u(I,m)}else if(p&&p.id){if(s=this.primitives.get(p.id),!s)return;(!this.rotationRing||!((b=(C=this.rotationRing)==null?void 0:C._instanceIds)!=null&&b.includes(`rotationRing_${s.id}`)))&&this.createRotationRing(s),(!this.translationSquare||!((P=(M=this.translationSquare)==null?void 0:M._instanceIds)!=null&&P.includes(`translationSquare_${s.id}`)))&&this.createTranslationSquare(s),(!this.heightArrow||!((E=(L=this.heightArrow)==null?void 0:L._instanceIds)!=null&&E.includes(`heightArrow_${s.id}`)))&&this.createHeightArrow(s)}else d()},e.ScreenSpaceEventType.LEFT_DOWN),this.handler.setInputAction(m=>{if(t()&&this.editMode!=""&&s){const p=o.globe.pick(i.camera.getPickRay(m.endPosition),o),y=this.toCartographic(p);let w=0;if(this.editMode==="rotate"){let f=this.calculateHeading(n,y);w=this.calculateHeading(n,l)-f,this.rotateModel(s,r,w)}else this.editMode==="move"?this.moveModel(s,r,m):this.editMode==="moveHeight"&&this.moveModelHeight(s,r,m,c)}},e.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(()=>{if(!t())return;let g=this.dragEndCallbackMap.get(s==null?void 0:s.id);if(g&&(this.editMode==="move"||this.editMode==="moveHeight")){let p=g.get("translation");p&&(this.runEventListener("translation",p),g.delete("translation"))}else if(g&&this.editMode==="rotate"){let p=g.get("rotate");p&&(this.runEventListener("rotate",p),g.delete("rotate"))}d()},e.ScreenSpaceEventType.LEFT_UP),this.handler.setInputAction(()=>{this.removeTool()},e.ScreenSpaceEventType.RIGHT_UP)}createRotationRing(t){const e=this.Cesium,i=this.viewer;this.rotationRing&&i.scene.primitives.remove(this.rotationRing);const o=[];for(let n=0;n<=360;n+=3){const l=Math.sin(e.Math.toRadians(n)),c=Math.cos(e.Math.toRadians(n)),d=t.boundingSphere.radius*c,u=t.boundingSphere.radius*l;o.push(new e.Cartesian3(d,u,0))}const s=new e.PolylineGeometry({positions:o,width:Math.max(t.boundingSphere.radius*.05,1)}),r=new e.GeometryInstance({id:`rotationRing_${t.id}`,geometry:s,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.RED)}});this.rotationRing=new e.Primitive({geometryInstances:r,appearance:new e.PolylineColorAppearance({translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.RED.withAlpha(.3)}),translucent:!0}),modelMatrix:t.modelMatrix,cull:!1}),i.scene.primitives.add(this.rotationRing)}createTranslationSquare(t){const e=this.Cesium,i=this.viewer;this.translationSquare&&i.scene.primitives.remove(this.translationSquare);const s=Math.max(t.boundingSphere.radius*.2,1)/2,r=new e.BoxGeometry({maximum:new e.Cartesian3(s,s,s),minimum:new e.Cartesian3(-s,-s,-s)}),n=new e.GeometryInstance({id:`translationSquare_${t.id}`,geometry:r,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.BLUE)}});this.translationSquare=new e.Primitive({geometryInstances:n,appearance:new e.PolylineColorAppearance({translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.BLUE.withAlpha(.3)}),translucent:!0}),cull:!1,modelMatrix:t.modelMatrix}),i.scene.primitives.add(this.translationSquare)}createHeightArrow(t){const e=this.Cesium,i=this.viewer;this.heightArrow&&i.scene.primitives.remove(this.heightArrow);let o=e.Color.GREEN,s=Math.max(t.boundingSphere.radius*.025,1),r=2*s,n=t.boundingSphere.radius+50,l=n*.1;const c=Math.max(t.boundingSphere.radius*.2,1),d=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:n,topRadius:s,bottomRadius:s})),u=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:l,topRadius:0,bottomRadius:r}));let m=n+c,g=(n+c)/2;this.translate(d,[0,0,g]),this.translate(u,[0,0,m]),this.heightArrow=new e.Primitive({modelMatrix:t.modelMatrix,geometryInstances:[new e.GeometryInstance({id:`heightArrow-line_${t.id}`,geometry:d}),new e.GeometryInstance({id:`heightArrow-arrow_${t.id}`,geometry:u})],appearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:o}),translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:o.withAlpha(.3)}),translucent:!0}),cull:!1}),i.scene.primitives.add(this.heightArrow)}translate(t,e){let i=this.Cesium;const o=new i.Cartesian3;_e(e)?(o.x=e[0],o.y=e[1],o.z=e[2]):i.Cartesian3.clone(e,o);for(let s=0;s<t.attributes.position.values.length;s+=3)t.attributes.position.values[s]+=o.x,t.attributes.position.values[s+1]+=o.y,t.attributes.position.values[s+2]+=o.z}removeTool(){this.rotationRing&&this.viewer.scene.primitives.remove(this.rotationRing),this.translationSquare&&this.viewer.scene.primitives.remove(this.translationSquare),this.heightArrow&&this.viewer.scene.primitives.remove(this.heightArrow)}updatedTool(t){this.rotationRing&&(this.rotationRing.modelMatrix=t),this.translationSquare&&(this.translationSquare.modelMatrix=t),this.heightArrow&&(this.heightArrow.modelMatrix=t)}moveModel(t,e,i){const o=this.Cesium,s=this.viewer,r=s.scene,n=r.globe.pick(s.camera.getPickRay(i.endPosition),r);if(n){const l=o.Matrix4.getTranslation(e,new o.Cartesian3),c=o.Cartographic.fromCartesian(l),d=o.Cartographic.fromCartesian(n),u=new o.Cartographic(d.longitude,d.latitude,c.height),m=o.Cartographic.toCartesian(u),g=o.Matrix4.getRotation(e,new o.Matrix3),p=o.Matrix4.fromRotationTranslation(g,m);t.modelMatrix=p,this.updatedTool(p);let y=new o.Cartesian3(p[12],p[13],p[14]),w=this.dragEndCallbackMap.get(t.id);w||(w=new Map,this.dragEndCallbackMap.set(t.id,w)),w.set("translation",{id:t.id,position:y})}}moveModelHeight(t,e,i,o){const s=this.Cesium,r=this.viewer,n=r.scene,l=o.y-i.endPosition.y;if(n.globe.pick(r.camera.getPickRay(i.endPosition),n)){const d=s.Matrix4.getTranslation(e,new s.Cartesian3),u=s.Cartographic.fromCartesian(d),m=new s.Cartographic(u.longitude,u.latitude,u.height+l*.001*Math.max(r.camera.positionCartographic.height,1)),g=s.Cartographic.toCartesian(m),p=s.Matrix4.getRotation(e,new s.Matrix3),y=s.Matrix4.fromRotationTranslation(p,g);t.modelMatrix=y,this.updatedTool(y);let w=new s.Cartesian3(y[12],y[13],y[14]),f=this.dragEndCallbackMap.get(t.id);f||(f=new Map,this.dragEndCallbackMap.set(t.id,f)),f.set("translation",{id:t.id,position:w})}}rotateModel(t,e,i){const o=this.Cesium,s=this.viewer,r=this.getModelHeadingPitchRoll(e),n=r.heading+i,l=new o.HeadingPitchRoll(n,r.pitch,r.roll),c=o.Transforms.headingPitchRollToFixedFrame(o.Matrix4.getTranslation(t.modelMatrix,new o.Cartesian3),l,s.scene.globe.ellipsoid,o.Transforms.eastNorthUpToFixedFrame,new o.Matrix4);t.modelMatrix=c;let d=this.dragEndCallbackMap.get(t.id);d||(d=new Map,this.dragEndCallbackMap.set(t.id,d)),d.set("rotate",{id:t.id,headingPitchRoll:{heading:o.Math.toDegrees(n),pitch:o.Math.toDegrees(r.pitch),roll:o.Math.toDegrees(r.roll)}})}cleanup(){this.handler&&(this.handler.destroy(),this.handler=null)}}function Co(a,t){const e=t.materialType||"DynamicImgMaterial"+Date.now()+Math.floor(Math.random()*1e3);function i(s){this._definitionChanged=new a.Event,this._color=s.color,this._colorSubscription=void 0,this.color=s.color,this.duration=s.duration,this._time=Date.now()}Object.defineProperties(i.prototype,{isConstant:{get(){return!1}},definitionChanged:{get(){return this._definitionChanged}},color:a.createPropertyDescriptor("color")}),i.prototype.getType=function(){return e},i.prototype.getValue=function(s,r){return a.defined(r)||(r={}),r.color=a.Property.getValueOrClonedDefault(this._color,s,a.Color.WHITE,r.color),r.image=t.image,r},i.prototype.equals=function(s){return this===s||s instanceof i&&a.Property.equals(this._color,s._color)};const o=function(s){return`
1
+ (function(D,te){typeof exports=="object"&&typeof module<"u"?te(exports):typeof define=="function"&&define.amd?define(["exports"],te):(D=typeof globalThis<"u"?globalThis:D||self,te(D.CesiumCore={}))})(this,(function(D){"use strict";var Oo=Object.defineProperty;var Ro=(D,te,V)=>te in D?Oo(D,te,{enumerable:!0,configurable:!0,writable:!0,value:V}):D[te]=V;var h=(D,te,V)=>Ro(D,typeof te!="symbol"?te+"":te,V);class te{constructor(t,e,i){h(this,"Cesium");h(this,"viewer");h(this,"labelPool");h(this,"threshold");h(this,"displayLimit");h(this,"maxLevel");h(this,"debugCurrentGrids");h(this,"levels");h(this,"points",[]);h(this,"gridLayers",new Map);h(this,"debugGrids",[]);h(this,"_updateFn");h(this,"clusterTheme");h(this,"pointTheme");h(this,"centralPointMode");h(this,"minGlobalPointCount");h(this,"groupByTheme");h(this,"tilingScheme");h(this,"terrainLevelOffset");h(this,"debugTileCoordLayer",null);h(this,"levelIndexByTileLevel",new Map);h(this,"_lastTileProvider",null);h(this,"_updateTimer",null);h(this,"_updateDelay",100);h(this,"_tilesRetryCount",0);h(this,"_tilesRetryMax",100);h(this,"_cameraDirty",!1);h(this,"_tileLoadListener",null);h(this,"_cameraChangedHandler",null);h(this,"defaultMinLevel",0);h(this,"defaultMaxLevel",28);h(this,"maxRefineLevels",2);this.Cesium=t,this.viewer=e,this.labelPool=i.labelPool,this.threshold=i.threshold??10,this.displayLimit=i.displayLimit??100,this.maxLevel=i.maxLevel??5,this.debugCurrentGrids=i.debugCurrentGrids??!1,this.clusterTheme=i.clusterTheme??"cluster-label",this.pointTheme=i.pointTheme??"point-label",this.centralPointMode=i.centralPointMode??"central",this.minGlobalPointCount=i.minGlobalPointCount??0,this.groupByTheme=i.groupByTheme??!1,this.terrainLevelOffset=i.terrainLevelOffset??2;const o=this.viewer.scene&&this.viewer.scene.globe,s=o&&o._surface,r=s&&s._tileProvider,n=(r==null?void 0:r.tilingScheme)||new this.Cesium.GeographicTilingScheme;this._lastTileProvider=r,this.tilingScheme=n,this.levels=this._createLevels(),this._buildLevels(),this._updateFn=this._update.bind(this),this.debugCurrentGrids&&this._ensureDebugImageryLayer(),o&&(this._tileLoadListener=l=>{l===0&&this._cameraDirty&&(this._cameraDirty=!1,this._scheduleUpdate())},o.tileLoadProgressEvent.addEventListener(this._tileLoadListener)),this._cameraChangedHandler=()=>{this._update()},this.viewer.camera.changed.addEventListener(this._cameraChangedHandler)}setGroupByTheme(t,e=!0,i=!0){if(this.groupByTheme===t){i&&this._update();return}this.groupByTheme=t,e&&this._buildLevels(),i&&this._update()}setMinGlobalPointCount(t,e=!0){this.minGlobalPointCount=t,e&&this._update()}setThreshold(t,e=!0){this.threshold=t,e&&this._update()}setDebugCurrentGrids(t,e=!0){this.debugCurrentGrids=t,t?this._ensureDebugImageryLayer():(this._clearDebugGrids(),this._removeDebugImageryLayer()),e&&this._update()}_syncTilingSchemeAndLevels(){const t=this.viewer.scene&&this.viewer.scene.globe,e=t&&t._surface,i=e&&e._tileProvider,o=(i==null?void 0:i.tilingScheme)||new this.Cesium.GeographicTilingScheme,s=i!==this._lastTileProvider,r=this.tilingScheme!==o;!s&&!r&&this.levels&&this.levels.length>0||(this._lastTileProvider=i,this.tilingScheme=o,this.levels=this._createLevels(),this._buildLevels(),this.debugCurrentGrids&&(this._removeDebugImageryLayer(),this._ensureDebugImageryLayer()))}_createLevels(){const t=[];this.levelIndexByTileLevel=new Map;const e=0,i=this.maxLevel;let o=0;for(let s=e;s<=i;s++,o++){const r=360/Math.pow(2,s);t.push({level:s,size:r,minViewWidth:r*4}),this.levelIndexByTileLevel.set(s,o)}return t}addPoints(t){this.points=t,this._buildLevels()}appendPoints(t,e=!0){for(const i of t)this._preparePointLevelRange(i),this.points.push(i);for(const i of t)this._addPointToGrid(i);e&&this._scheduleUpdate()}_scheduleUpdate(){this._updateTimer!==null&&clearTimeout(this._updateTimer),this._updateTimer=window.setTimeout(()=>{this._update(),this._cameraDirty=!0,this._updateTimer=null},this._updateDelay)}updatePoint(t){var s,r,n,l;const e=this.points.findIndex(c=>c.id===t.id);if(e===-1)return;const i=this.points[e];for(const c of this.levels){const d=c.level,u=this.gridLayers.get(d);if(!u)continue;const m=this.Cesium.Cartographic.fromDegrees(i.lon,i.lat),g=this.tilingScheme.positionToTileXY(m,d,new this.Cesium.Cartesian2);if(!g)continue;const p=`${g.x}_${g.y}`,y=u.get(p);if(y){const w=y.allPoints.findIndex(f=>f.id===t.id);if(w!==-1&&y.allPoints.splice(w,1),(n=(r=(s=i.data)==null?void 0:s.billboard)==null?void 0:r[0])!=null&&n.skipAggregation){const f=y.skipPoints.findIndex(v=>v.id===t.id);f!==-1&&y.skipPoints.splice(f,1)}else{const f=this.groupByTheme?(l=i.data)==null?void 0:l.theme:this.clusterTheme,v=y.groups.get(f);if(v){const C=v.findIndex(b=>b.id===t.id);C!==-1&&v.splice(C,1),v.length===0&&y.groups.delete(f)}}}}const o={...i,...t};this.points[e]=o,this._addPointToGrid(o),this._update()}removePointsById(t){const e=new Set(t);this.points=this.points.filter(i=>!e.has(i.id));for(const i of this.levels){const o=this.gridLayers.get(i.level);if(o)for(const[s,r]of o.entries()){r.allPoints=r.allPoints.filter(n=>!e.has(n.id)),r.skipPoints=r.skipPoints.filter(n=>!e.has(n.id));for(const[n,l]of r.groups.entries()){const c=l.filter(d=>!e.has(d.id));c.length===0?r.groups.delete(n):r.groups.set(n,c)}r.allPoints.length===0&&o.delete(s)}}this._update()}_buildLevels(){this.gridLayers.clear();for(const t of this.levels)this.gridLayers.set(t.level,new Map);for(const t of this.points)this._addPointToGrid(t)}_addPointToGrid(t){var e,i,o,s,r,n;for(const l of this.levels){const c=l.level,d=this.gridLayers.get(c);if(!d)continue;const u=this.Cesium.Cartographic.fromDegrees(t.lon,t.lat),m=this.tilingScheme.positionToTileXY(u,c,new this.Cesium.Cartesian2);if(!m)continue;const g=`${m.x}_${m.y}`;let p=d.get(g);if(p||(p={allPoints:[],groups:new Map,skipPoints:[]},d.set(g,p)),p.allPoints.push(t),(o=(i=(e=t.data)==null?void 0:e.billboard)==null?void 0:i[0])!=null&&o.skipAggregation)p.skipPoints.push(t);else{const y=this.groupByTheme?(n=(r=(s=t.data)==null?void 0:s.billboard)==null?void 0:r[0])==null?void 0:n.theme:this.clusterTheme;p.groups.has(y)||p.groups.set(y,[]),p.groups.get(y).push(t)}}}_preparePointLevelRange(t){const e=t.data||{};let i=e.minLevel,o=e.maxLevel;const s=e.levelRange;Array.isArray(s)?(s.length>0&&i==null&&(i=s[0]),s.length>1&&o==null&&(o=s[1])):s&&typeof s=="object"&&(i==null&&typeof s.min=="number"&&(i=s.min),o==null&&typeof s.max=="number"&&(o=s.max));const r=i==null?this.defaultMinLevel:Number(i)||this.defaultMinLevel,n=o==null?this.defaultMaxLevel:Number(o)||this.defaultMaxLevel;t.__minLevel=r,t.__maxLevel=n}_isVisibleAtLevel(t,e){if(e==null)return!0;(t.__minLevel===void 0||t.__maxLevel===void 0)&&this._preparePointLevelRange(t);const i=t.__minLevel??this.defaultMinLevel,o=t.__maxLevel??this.defaultMaxLevel;return e>=i&&e<=o}_update(){if(!this.labelPool)return;this._syncTilingSchemeAndLevels(),this.labelPool.reset(),this.debugCurrentGrids&&this._clearDebugGrids();const t=this.points.length<this.minGlobalPointCount?1/0:this.threshold;let e=0;const i=(o,s,r,n)=>{e=this._processCell(o,s,r,n,t,e)};try{const o=this._getSurfaceTiles();if(!o||o.length===0){this._handleNoSurfaceTiles(e);return}this._tilesRetryCount=0,this._processTiles(o,i)}catch{this.labelPool.cleanup();return}this.labelPool.cleanup()}_getSurfaceTiles(){const t=this.viewer.scene&&this.viewer.scene.globe,e=t&&t._surface;if(e)return e._tilesToRender||e._tilesToRenderByTextureCount}_handleNoSurfaceTiles(t){var e,i,o,s;for(const r of this.points){if(t>=this.displayLimit)break;((e=r.data)==null?void 0:e.show)!==!1&&(this.labelPool.add(r.data,{id:`point-${r.id}`,lon:r.lon,lat:r.lat,height:r.height,theme:((s=(o=(i=r.data)==null?void 0:i.billboard)==null?void 0:o[0])==null?void 0:s.theme)||this.pointTheme,style:r.style}),t++)}this.labelPool.cleanup(),this.points.length>0&&this._tilesRetryCount<this._tilesRetryMax&&(this._tilesRetryCount++,this._scheduleUpdate())}_resolveLevelIndex(t){let e=this.levelIndexByTileLevel.get(t);if(e!==void 0)return e;if(this.levels.length===0)return;const i=this.levels[0].level,o=this.levels[this.levels.length-1].level;if(t>o)return this.levels.length-1;if(t<i)return 0;let s=0,r=1/0;for(let n=0;n<this.levels.length;n++){const l=Math.abs(this.levels[n].level-t);l<r&&(r=l,s=n)}return s}_isTerrainEnabled(){const t=this.viewer.terrainProvider,e=this.viewer.scene,i=e&&e.globe,o=i&&i.terrainProvider,s=t||o;return s?!(s instanceof this.Cesium.EllipsoidTerrainProvider):!1}_getGridRefLevel(t){let e=t;if(this._isTerrainEnabled()&&(e+=this.terrainLevelOffset),this.levels.length>0){const i=this.levels[this.levels.length-1].level;e>i&&(e=i)}return e}_processTiles(t,e){const i=new Set,o=this.viewer.scene,s=o&&o.globe,r=s&&s.ellipsoid,n=r&&o.camera.computeViewRectangle(r),l=(c,d,u)=>{if(!n)return!0;const m=this.tilingScheme.tileXYToRectangle(c,d,u);return!(!m||m.east<=n.west||m.west>=n.east||m.north<=n.south||m.south>=n.north)};for(const c of t){const d=c.rectangle,u=c._level??c.level;if(!d||typeof u!="number")continue;const m=this._getGridRefLevel(u),g=this._resolveLevelIndex(m);if(g===void 0)continue;const p=this.levels[g].level,y=c._x??c.x,w=c._y??c.y;if(typeof y=="number"&&typeof w=="number"){const x=u-p;if(x>=0){const T=1<<x,A=Math.floor(y/T),$=Math.floor(w/T),R=`${p}_${A}_${$}`;if(i.has(R))continue;i.add(R),e(g,A,$,u)}else{const A=1<<Math.min(-x,this.maxRefineLevels),$=y*A,R=w*A;for(let _=0;_<A;_++)for(let O=0;O<A;O++){const k=$+_,G=R+O;if(!l(k,G,p))continue;const B=`${p}_${k}_${G}`;i.has(B)||(i.add(B),e(g,k,G,u))}}continue}const v=this.levels[g].size,C=this.Cesium.Math.toDegrees(d.west),b=this.Cesium.Math.toDegrees(d.east),M=this.Cesium.Math.toDegrees(d.south),P=this.Cesium.Math.toDegrees(d.north),L=Math.floor((C- -180)/v),E=Math.floor((b- -180)/v),I=Math.floor((M- -90)/v),S=Math.floor((P- -90)/v);for(let x=L;x<=E;x++)for(let T=I;T<=S;T++){if(!l(x,T,p))continue;const A=`${p}_${x}_${T}`;i.has(A)||(i.add(A),e(g,x,T,u))}}}_processCell(t,e,i,o,s,r){if(r>=this.displayLimit||t<0)return r;t>=this.levels.length&&(t=this.levels.length-1);const n=this._getCellContext(t,e,i,o);return n?(r=this._processCellSkipPoints(n,r),r>=this.displayLimit?(this._debugDrawCell(n),r):(r=this._processCellGroups(n,s,r),this._debugDrawCell(n),r)):r}_getCellContext(t,e,i,o){const r=this.levels[t].level,n=this.gridLayers.get(r);if(!n)return null;const l=`${e}_${i}`,c=n.get(l);if(!c)return null;const d=this.tilingScheme.tileXYToRectangle(e,i,r),u=this.Cesium.Math.toDegrees(d.west),m=this.Cesium.Math.toDegrees(d.south),g=this.Cesium.Math.toDegrees(d.east),p=this.Cesium.Math.toDegrees(d.north),y=(u+g)/2,w=(m+p)/2;return{levelIdx:t,tileLevel:r,lonIdx:e,latIdx:i,key:l,cell:c,rect:d,west:u,south:m,east:g,north:p,centerLon:y,centerLat:w,viewTileLevel:o}}_processCellSkipPoints(t,e){var r,n,l,c;const{cell:i,viewTileLevel:o}=t,s=o;for(const d of i.skipPoints)if(((r=d.data)==null?void 0:r.show)!==!1){if(e>=this.displayLimit)break;this._isVisibleAtLevel(d,s)&&(this.labelPool.add(d.data,{id:`point-${d.id}`,lon:d.lon,lat:d.lat,height:d.height,theme:((c=(l=(n=d.data)==null?void 0:n.billboard)==null?void 0:l[0])==null?void 0:c.theme)||this.pointTheme,style:d.style}),e++)}return e}_processCellGroups(t,e,i){var m,g,p,y,w,f,v,C,b,M,P,L,E;const{levelIdx:o,lonIdx:s,latIdx:r,cell:n,centerLon:l,centerLat:c,viewTileLevel:d}=t,u=d;for(const[I,S]of n.groups){const x=S.filter(_=>{var O;return((O=_.data)==null?void 0:O.show)!==!1});if(x.length===0)continue;let T=l,A=c,$=((m=x[0])==null?void 0:m.height)||0;if(this.centralPointMode=="firstPoint"&&(T=((g=x[0])==null?void 0:g.lon)||0,A=((p=x[0])==null?void 0:p.lat)||0,$=((y=x[0])==null?void 0:y.height)||0),o===this.levels.length-1||x.length<e)for(const _ of x){if(i>=this.displayLimit)break;this._isVisibleAtLevel(_,u)&&(this.labelPool.add(_.data,{id:`point-${_.id}`,lon:_.lon,lat:_.lat,height:_.height,theme:((v=(f=(w=_.data)==null?void 0:w.billboard)==null?void 0:f[0])==null?void 0:v.theme)||this.pointTheme,style:_.style}),i++)}else{if(i>=this.displayLimit)return i;const _=u==null?x:x.filter(B=>this._isVisibleAtLevel(B,u));if(!_.length)return i;const k=((P=(M=(b=(C=_[0])==null?void 0:C.data)==null?void 0:b.billboard)==null?void 0:M[0])==null?void 0:P.theme)||this.clusterTheme,G=this.groupByTheme?`cluster-${o}-${s}-${r}-${I}`:`cluster-${o}-${s}-${r}`;this.labelPool.add({id:G,billboard:((E=(L=_[0])==null?void 0:L.data)==null?void 0:E.billboard)||[],count:_.length,gridKey:`${s}_${r}`,points:_,aggregationGroup:I},{id:G,lon:T,lat:A,height:$,theme:k}),i++}}return i}_debugDrawCell(t){if(!this.debugCurrentGrids)return;const{levelIdx:e,west:i,south:o,east:s,north:r,lonIdx:n,latIdx:l}=t,c=this.levels[e].level;this._drawDebugGrid(i,o,s,r,`L:${c} X:${n} Y:${l}`)}refresh(){this._update()}_drawDebugGrid(t,e,i,o,s){const r=this.Cesium.Rectangle.fromDegrees(t,e,i,o),n=this.Cesium.Cartesian3.fromDegreesArray([t,e,i,e,i,o,t,o,t,e]),l=this.viewer.entities.add({rectangle:{coordinates:r,material:this.Cesium.Color.YELLOW.withAlpha(.2),outline:!0,outlineColor:this.Cesium.Color.RED,heightReference:this.Cesium.HeightReference.CLAMP_TO_GROUND,classificationType:this.Cesium.ClassificationType.TERRAIN},polyline:{positions:n,width:2,material:this.Cesium.Color.RED,clampToGround:!0},label:{text:s,font:"14px sans-serif",fillColor:this.Cesium.Color.BLACK,outlineColor:this.Cesium.Color.WHITE,outlineWidth:2,style:this.Cesium.LabelStyle.FILL_AND_OUTLINE,verticalOrigin:this.Cesium.VerticalOrigin.CENTER,horizontalOrigin:this.Cesium.HorizontalOrigin.CENTER}});this.debugGrids.push(l)}_clearDebugGrids(){for(const t of this.debugGrids)this.viewer.entities.remove(t);this.debugGrids=[]}_ensureDebugImageryLayer(){if(this.debugTileCoordLayer||!this.viewer||!this.viewer.imageryLayers)return;const t={tilingScheme:this.tilingScheme};this.debugTileCoordLayer=this.viewer.imageryLayers.addImageryProvider(new this.Cesium.TileCoordinatesImageryProvider(t))}_removeDebugImageryLayer(){if(!(!this.debugTileCoordLayer||!this.viewer||!this.viewer.imageryLayers)){try{this.viewer.imageryLayers.remove(this.debugTileCoordLayer,!1)}catch{}this.debugTileCoordLayer=null}}destroy(){this._cameraChangedHandler&&(this.viewer.camera.changed.removeEventListener(this._cameraChangedHandler),this._cameraChangedHandler=null);const t=this.viewer.scene,e=t&&t.globe;e&&this._tileLoadListener&&(e.tileLoadProgressEvent.removeEventListener(this._tileLoadListener),this._tileLoadListener=null),this._updateTimer!==null&&(clearTimeout(this._updateTimer),this._updateTimer=null),this.labelPool.reset(),this._clearDebugGrids(),this._removeDebugImageryLayer()}}var V=(a=>(a.Click="marker:click",a.DoubleClick="marker:dblclick",a.RightClick="marker:rightclick",a.MouseEnter="marker:mouseenter",a.MouseLeave="marker:mouseleave",a.MouseDown="marker:mousedown",a.MouseUp="marker:mouseup",a))(V||{});class tt{constructor(){h(this,"listenerMap",new Map)}addListener(t,e,i=!1){let o=this.listenerMap.get(t);return o||(o=new Map,this.listenerMap.set(t,o)),o.has(e.name)?i?(console.warn(`[MarkerEventBus] Overwriting listener "${e.name}" for event "${t}".`),o.set(e.name,e),!0):(console.warn(`[MarkerEventBus] Listener "${e.name}" for event "${t}" already exists. Use overwrite=true to replace it.`),!1):(o.set(e.name,e),!0)}removeListenerByKey(t){const e=this.listenerMap.has(t);return this.listenerMap.set(t,new Map),e}removeListenerByKeyAndName(t,e){const i=this.listenerMap.get(t);return i?i.delete(e):!1}runListener(t,e,i){const o=this.listenerMap.get(t);if(o)for(const[s,r]of o.entries()){try{r.fn(e,i)}catch(n){console.error(`Error in listener "${s}" for event "${t}":`,n)}r.once&&o.delete(s)}}}const it={[V.Click]:"click",[V.DoubleClick]:"dblclick",[V.RightClick]:"contextmenu",[V.MouseEnter]:"mouseenter",[V.MouseLeave]:"mouseleave",[V.MouseDown]:"mousedown",[V.MouseUp]:"mouseup"};class N{constructor(t,e,i="html-label-container",o,s=!0){h(this,"viewer");h(this,"Cesium");h(this,"container");h(this,"labels",new Map);h(this,"activeIds",new Set);h(this,"_updateFn");h(this,"themes",{});h(this,"eventBus");h(this,"openWheel",!0);this.Cesium=t,this.viewer=e,this.container=this._createContainer(i),this._updateFn=this._update.bind(this),this.viewer.scene.postRender.addEventListener(this._updateFn),this.eventBus=o||new tt,this.openWheel=s}_createContainer(t){let e=document.getElementById(t);return e||(e=document.createElement("div"),e.id=t,Object.assign(e.style,{position:"absolute",top:"0",left:"0",pointerEvents:"none",width:"100%",height:"100%",zIndex:"100",overflow:"hidden"}),document.body.appendChild(e)),e}registerTheme(t,e){this.themes[t]=e}add(t,e){const{id:i,lon:o,lat:s,height:r=0,theme:n,show:l=!0,notCreateElement:c=!1,style:d}=e,u=this.themes[n];if(!u){console.warn(`Theme "${n}" not registered`);return}let m=this.labels.get(i);if(m){m.theme=n,m.data=t,m.notCreateElement=c;try{m.unload=u.createElement(m.el,{id:i,theme:n,data:t},u),(!c||l)&&this.container.appendChild(m.el)}catch(g){console.error(`Error updating label element for id "${i}":`,g)}}else{const g=document.createElement("div");Object.assign(g.style,{position:"absolute",transform:"translate(0, 0)",pointerEvents:"auto",...e.style||{}});for(const[y,w]of Object.entries(it)){g.addEventListener(w,v=>{v.stopPropagation();const C=this.labels.get(i);this.eventBus.runListener(y,C,v)});let f=0;g.addEventListener("wheel",v=>{if(!this.openWheel)return;const C=v.currentTarget;f=Date.now();const b=f;C.style.pointerEvents="none",setTimeout(()=>{f===b&&(C.style.pointerEvents="auto")},2e3)})}let p=null;if(!c||l){try{p=u.createElement(g,{id:i,theme:n,data:t},u)||{}}catch(y){console.error(`Error updating label element for id "${i}":`,y)}this.container.appendChild(g)}m={id:i,el:g,theme:n,data:t,notCreateElement:c,unload:p},this.labels.set(i,m)}m.el.dataset.lon=String(o),m.el.dataset.lat=String(s),m.el.dataset.height=String(r),m.el.style.zIndex=(d==null?void 0:d.zIndex)||"1",m.el.style.display=l?"block":"none",l&&this.activeIds.add(i)}addBatch(t){for(const{data:e,options:i}of t)this.add(e,i)}removeByIds(t){for(const e of t){const i=this.labels.get(e);i&&(this.unloadByLabel(i),this.labels.delete(e),this.activeIds.delete(e))}}unloadByLabel(t){t.el.remove(),t!=null&&t.unload&&typeof t.unload=="function"&&(t==null||t.unload()),t.unload=null}removeAll(){for(const t of this.labels.values())this.unloadByLabel(t);this.labels.clear(),this.activeIds.clear()}update(t,e){const i=this.labels.get(t);if(!i){console.warn(`Label with id "${t}" not found for update.`);return}const o=this.themes[i.theme];if(!o){console.warn(`Theme "${i.theme}" not registered.`);return}try{o.createElement(i.el,{id:t,theme:i.theme,data:e},o)}catch(s){console.error(`Failed to update label "${t}":`,s)}}hideByIds(t){for(const e of t){const i=this.labels.get(e);i&&(i.notCreateElement&&this.unloadByLabel(i),i.el.style.display="none",this.activeIds.delete(e))}}hideAll(){for(const t of this.labels.values())t.notCreateElement&&this.unloadByLabel(t),t.el.style.display="none",this.activeIds.delete(t.id)}hideFilter(t){for(const e of this.labels.values())t(e.data)&&(e.notCreateElement&&this.unloadByLabel(e),e.el.style.display="none",this.activeIds.delete(e.id))}showByIds(t){for(const e of t){const i=this.labels.get(e);if(i){if((i.notCreateElement||!i.el.parentNode)&&this.container.appendChild(i.el),!i.unload)try{const o=this.themes[i.theme];if(!o){console.warn(`Theme "${i.theme}" not registered`);return}i.unload=o.createElement(i.el,{id:e,theme:i.theme,data:i.data},o)||{}}catch(o){console.error(`Error creating label element for theme "${i.theme}":`,o);return}i.el.style.display="block",this.activeIds.add(e)}}}has(t){return this.labels.has(t)}reset(){for(const t of this.activeIds.values()){let e=this.labels.get(t);e&&this.unloadByLabel(e)}this.activeIds.clear()}cleanup(){for(const[t,e]of this.labels.entries())this.activeIds.has(t)||(e.el.style.display="none")}async toWindowPositionByLonLat(t,e){const i=this.Cesium,o=this.viewer.scene,s=[i.Cartographic.fromDegrees(t,e)];let r;try{r=await o.clampToHeightMostDetailed(s)}catch{console.warn("clampToHeightMostDetailed failed, fallback to ellipsoid height.")}let n=0;r&&r[0]&&r[0].height!=null?n=r[0].height:n=0;const l=i.Cartesian3.fromDegrees(t,e,n);return this.toWindowCoordinates(l)}toWindowCoordinates(t){const e=this.viewer.scene,i=this.Cesium.SceneTransforms;if(typeof(i==null?void 0:i.wgs84ToWindowCoordinates)=="function")return i.wgs84ToWindowCoordinates(e,t);if(typeof(i==null?void 0:i.worldToWindowCoordinates)=="function")return i.worldToWindowCoordinates(e,t);console.warn("No compatible window coordinate transform function found.")}_isValidCoordinate(t,e){return!(Number.isNaN(t)||Number.isNaN(e)||t===0&&e===0||t<-180||t>180||e<-90||e>90)}async _update(){var t;for(const e of this.activeIds){const i=this.labels.get(e);if(!i)continue;const o=parseFloat(i.el.dataset.lon),s=parseFloat(i.el.dataset.lat),r=parseFloat(i.el.dataset.height||"0");if(!this._isValidCoordinate(o,s)){i.el.style.display="none";continue}const n=this.Cesium.Cartesian3.fromDegrees(o,s,r),l=this.toWindowCoordinates(n);if(this.Cesium.defined(l)){const d=((t=this.themes[i.theme].options)==null?void 0:t.offset)||{},u=d.x||0,m=d.y||0;i.el.style.left=`${l.x}px`,i.el.style.top=`${l.y}px`,i.el.style.transform=`translate(${u}px, ${m}px)`,i.el.style.display="block"}else i.el.style.display="none"}}destroy(){this.viewer.scene.postRender.removeEventListener(this._updateFn),this.labels.clear(),this.activeIds.clear()}}class xe{constructor(){h(this,"tooltipEl");h(this,"visible",!1);h(this,"offsetX",10);h(this,"offsetY",-20);h(this,"onMouseMove",null);this.tooltipEl=document.createElement("div"),this.tooltipEl.style.position="fixed",this.tooltipEl.style.pointerEvents="none",this.tooltipEl.style.zIndex="10000",this.tooltipEl.style.padding="4px 8px",this.tooltipEl.style.borderRadius="4px",this.tooltipEl.style.background="rgba(0, 0, 0, 0.7)",this.tooltipEl.style.color="#fff",this.tooltipEl.style.fontSize="13px",this.tooltipEl.style.transition="opacity 0.1s ease",this.tooltipEl.style.opacity="0",document.body.appendChild(this.tooltipEl),this.onMouseMove=t=>{this.visible&&(this.tooltipEl.style.left=`${t.clientX+this.offsetX}px`,this.tooltipEl.style.top=`${t.clientY+this.offsetY}px`)},window.addEventListener("mousemove",this.onMouseMove)}show(t){this.tooltipEl.innerText=t,this.tooltipEl.style.opacity="1",this.visible=!0}hide(){this.tooltipEl.style.opacity="0",this.visible=!1}destroy(){this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.tooltipEl.parentElement&&this.tooltipEl.parentElement.removeChild(this.tooltipEl)}}class Gt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"entity",null);h(this,"tooltip",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.tooltip=new xe,this.tooltip.show("左键添加点"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var m,g;const s=i.scene.pickPosition(o.position);if(!s)return;const r=e.Cartographic.fromCartesian(s),n=e.Math.toDegrees(r.longitude),l=e.Math.toDegrees(r.latitude),c=r.height,d=i.entities.add({position:s,point:{pixelSize:10,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.entity=d;const u={entity:d,position:s,lnglat:{lng:n,lat:l,height:c},clear:()=>{this.clear()}};(m=t.onComplete)==null||m.call(t,u),this.stopDrawing(),(g=this.tooltip)==null||g.hide(),this.tooltip=null},e.ScreenSpaceEventType.LEFT_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.stopDrawing()}}class Bt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.tempPoints=[],this.entity=null,this.tooltip=new xe,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var n,l;const s=i.scene.pickPosition(o.position);if(!s)return;this.positions.push(s);const r=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(r),this.entity?this.entity.polyline.positions=this.positions.slice():this.entity=i.entities.add({polyline:{positions:this.positions.slice(),width:3,material:t.color||e.Color.YELLOW,depthFailMaterial:((l=(n=t.color)==null?void 0:n.withAlpha)==null?void 0:l.call(n,.5))||e.Color.YELLOW.withAlpha(.5)}})},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var r,n;if(this.stopDrawing(),(r=this.tooltip)==null||r.hide(),this.tooltip=null,this.positions.length<2)return;this.positions.length=this.positions.length-1,this.entity&&(this.entity.polyline.positions=this.positions.slice());const o=this.positions.map(l=>{const c=e.Cartographic.fromCartesian(l);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),s={entity:this.entity,positions:this.positions,lnglats:o,clear:()=>{this.clear()}};(n=t.onComplete)==null||n.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.stopDrawing()}}class jt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"startPoint",null);h(this,"endPoint",null);h(this,"entity",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var r;const s=i.scene.pickPosition(o.position);if(s)if(!this.startPoint)this.startPoint=s,this.entity=i.entities.add({rectangle:{coordinates:new e.CallbackProperty(()=>{if(!(!this.startPoint||!this.endPoint))try{const n=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c=Math.min(n.longitude,l.longitude),d=Math.max(n.longitude,l.longitude),u=Math.min(n.latitude,l.latitude),m=Math.max(n.latitude,l.latitude);return new e.Rectangle(c,u,d,m)}catch(n){console.warn("Rectangle calculation error:",n);return}},!1),material:t.color||e.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:e.Color.BLACK,disableDepthTestDistance:Number.POSITIVE_INFINITY}});else{this.stopDrawing();const n=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c={lng:e.Math.toDegrees(Math.min(n.longitude,l.longitude)),lat:e.Math.toDegrees(Math.min(n.latitude,l.latitude)),height:0},d={lng:e.Math.toDegrees(Math.max(n.longitude,l.longitude)),lat:e.Math.toDegrees(Math.max(n.latitude,l.latitude)),height:0},u={entity:this.entity,position:this.startPoint,lnglat:{lng:e.Math.toDegrees(n.longitude),lat:e.Math.toDegrees(n.latitude),height:n.height},positions:[this.startPoint,this.endPoint],lnglats:[c,d],clear:()=>{this.clear()}};(r=t.onComplete)==null||r.call(t,u)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(o=>{if(!this.startPoint)return;const s=i.scene.pickPosition(o.endPosition);s&&(this.endPoint=s)},e.ScreenSpaceEventType.MOUSE_MOVE)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.startPoint=null,this.endPoint=null,this.stopDrawing()}}class Yt{constructor(t,e){h(this,"viewer");h(this,"Cesium");h(this,"handler",null);h(this,"entity",null);h(this,"positions",[]);h(this,"_isDrawing",!1);h(this,"currentRadius",0);this.Cesium=t,this.viewer=e}startDrawing(t){this.clear(),this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.canvas),this._isDrawing=!0,this.handler.setInputAction(e=>{const i=this.viewer.scene.pickPosition(e.position);i&&(this.positions.push(i),this.positions.length===2&&(this.stopDrawing(),this.drawFinalCircle(t)))},this.Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(e=>{if(this.positions.length!==1)return;const i=this.positions[0],o=this.viewer.camera.getPickRay(e.endPosition),s=this.viewer.scene.globe.pick(o,this.viewer.scene);s&&this.drawPreviewCircle(i,s,t)},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE)}drawPreviewCircle(t,e,i){const o=this.Cesium.Cartesian3.distance(t,e);if(this.entity)Math.abs(this.currentRadius-o)>.5&&(this.currentRadius=o);else{this.currentRadius=o;const s=new this.Cesium.CallbackProperty(()=>this.currentRadius,!1);this.entity=this.viewer.entities.add({position:t,ellipse:{semiMajorAxis:s,semiMinorAxis:s,material:i.color||this.Cesium.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:i.color||this.Cesium.Color.YELLOW,heightReference:this.Cesium.HeightReference.NONE,disableDepthTestDistance:Number.POSITIVE_INFINITY}})}}drawFinalCircle(t){var u;const[e,i]=this.positions,o=this.Cesium.Cartesian3.distance(e,i),s=this.Cesium.Cartographic.fromCartesian(e),r={lng:this.Cesium.Math.toDegrees(s.longitude),lat:this.Cesium.Math.toDegrees(s.latitude),height:s.height},n=(t==null?void 0:t.step)||1,l=[],c=[];for(let m=0;m<360;m+=n){const g=this.Cesium.Math.toRadians(m),p=new this.Cesium.EllipsoidGeodesic;p.setEndPoints(s,new this.Cesium.Cartographic(s.longitude+1e-4*Math.cos(g),s.latitude+1e-4*Math.sin(g)));const y=p.interpolateUsingSurfaceDistance(o),w=this.Cesium.Ellipsoid.WGS84.cartographicToCartesian(y);l.push(w);const f=this.Cesium.Cartographic.fromCartesian(w);c.push({lng:this.Cesium.Math.toDegrees(f.longitude),lat:this.Cesium.Math.toDegrees(f.latitude),height:f.height})}c.push(c[0]);const d=this.positions.map(m=>{const g=this.Cesium.Cartographic.fromCartesian(m);return{lng:this.Cesium.Math.toDegrees(g.longitude),lat:this.Cesium.Math.toDegrees(g.latitude),height:g.height}});(u=t.onComplete)==null||u.call(t,{entity:this.entity,positions:this.positions,lnglats:d,circlePoints:l,circleLnglats:c,center:r,radius:o,clear:()=>{this.clear()}})}stopDrawing(){this.handler&&(this.handler.destroy(),this.handler=null),this._isDrawing=!1}clear(){this.stopDrawing(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.positions=[],this.currentRadius=0}}class Vt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.tempPoints=[],this.tooltip=new xe,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{const s=i.scene.pickPosition(o.position);if(!s)return;this.positions.push(s);const r=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY,heightReference:e.HeightReference.CLAMP_TO_GROUND}});this.tempPoints.push(r),this.entity||(this.entity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>({positions:this.positions}),!1),material:t.color||e.Color.YELLOW.withAlpha(.5)}}))},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var r,n;if(this.stopDrawing(),(r=this.tooltip)==null||r.hide(),this.tooltip=null,this.positions.length<3)return;this.positions.length=this.positions.length-1;const o=this.positions.map(l=>{const c=e.Cartographic.fromCartesian(l);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),s={entity:this.entity,positions:this.positions,lnglats:o,clear:()=>{this.clear()}};(n=t.onComplete)==null||n.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.stopDrawing()}}class Wt{constructor(t,e){h(this,"viewer");h(this,"Cesium");h(this,"activeDrawer",null);this.viewer=e,this.Cesium=t}draw(t,e){var i;switch(this.clear(),t){case"point":this.activeDrawer=new Gt(this.Cesium,this.viewer);break;case"line":this.activeDrawer=new Bt(this.Cesium,this.viewer);break;case"rectangle":this.activeDrawer=new jt(this.Cesium,this.viewer);break;case"circle":this.activeDrawer=new Yt(this.Cesium,this.viewer);break;case"polygon":this.activeDrawer=new Vt(this.Cesium,this.viewer);break;default:throw new Error(`Unsupported draw type: ${t}`)}(i=this.activeDrawer)==null||i.startDrawing(e)}clear(){this.activeDrawer&&(this.activeDrawer.stopDrawing(),this.activeDrawer.clear(),this.activeDrawer=null)}cancel(){this.clear()}}var st=typeof global=="object"&&global&&global.Object===Object&&global,Ut=typeof self=="object"&&self&&self.Object===Object&&self,se=st||Ut||Function("return this")(),me=se.Symbol,rt=Object.prototype,Kt=rt.hasOwnProperty,qt=rt.toString,be=me?me.toStringTag:void 0;function Xt(a){var t=Kt.call(a,be),e=a[be];try{a[be]=void 0;var i=!0}catch{}var o=qt.call(a);return i&&(t?a[be]=e:delete a[be]),o}var Jt=Object.prototype,Qt=Jt.toString;function Zt(a){return Qt.call(a)}var ei="[object Null]",ti="[object Undefined]",ot=me?me.toStringTag:void 0;function Pe(a){return a==null?a===void 0?ti:ei:ot&&ot in Object(a)?Xt(a):Zt(a)}function Le(a){return a!=null&&typeof a=="object"}var _e=Array.isArray;function De(a){var t=typeof a;return a!=null&&(t=="object"||t=="function")}var ii="[object AsyncFunction]",si="[object Function]",ri="[object GeneratorFunction]",oi="[object Proxy]";function nt(a){if(!De(a))return!1;var t=Pe(a);return t==si||t==ri||t==ii||t==oi}var Fe=se["__core-js_shared__"],at=(function(){var a=/[^.]+$/.exec(Fe&&Fe.keys&&Fe.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""})();function ni(a){return!!at&&at in a}var ai=Function.prototype,li=ai.toString;function ce(a){if(a!=null){try{return li.call(a)}catch{}try{return a+""}catch{}}return""}var hi=/[\\^$.*+?()[\]{}|]/g,ci=/^\[object .+?Constructor\]$/,di=Function.prototype,pi=Object.prototype,ui=di.toString,mi=pi.hasOwnProperty,gi=RegExp("^"+ui.call(mi).replace(hi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function fi(a){if(!De(a)||ni(a))return!1;var t=nt(a)?gi:ci;return t.test(ce(a))}function yi(a,t){return a==null?void 0:a[t]}function de(a,t){var e=yi(a,t);return fi(e)?e:void 0}var ke=de(se,"WeakMap"),lt=Object.create,wi=(function(){function a(){}return function(t){if(!De(t))return{};if(lt)return lt(t);a.prototype=t;var e=new a;return a.prototype=void 0,e}})(),ht=(function(){try{var a=de(Object,"defineProperty");return a({},"",{}),a}catch{}})();function vi(a,t){for(var e=-1,i=a==null?0:a.length;++e<i&&t(a[e],e,a)!==!1;);return a}var Ci=9007199254740991,bi=/^(?:0|[1-9]\d*)$/;function Pi(a,t){var e=typeof a;return t=t??Ci,!!t&&(e=="number"||e!="symbol"&&bi.test(a))&&a>-1&&a%1==0&&a<t}function Li(a,t,e){t=="__proto__"&&ht?ht(a,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):a[t]=e}function ct(a,t){return a===t||a!==a&&t!==t}var Ei=Object.prototype,Mi=Ei.hasOwnProperty;function Ii(a,t,e){var i=a[t];(!(Mi.call(a,t)&&ct(i,e))||e===void 0&&!(t in a))&&Li(a,t,e)}var Ti=9007199254740991;function dt(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=Ti}function xi(a){return a!=null&&dt(a.length)&&!nt(a)}var _i=Object.prototype;function pt(a){var t=a&&a.constructor,e=typeof t=="function"&&t.prototype||_i;return a===e}function Di(a,t){for(var e=-1,i=Array(a);++e<a;)i[e]=t(e);return i}var Si="[object Arguments]";function ut(a){return Le(a)&&Pe(a)==Si}var mt=Object.prototype,Ai=mt.hasOwnProperty,$i=mt.propertyIsEnumerable,Oi=ut((function(){return arguments})())?ut:function(a){return Le(a)&&Ai.call(a,"callee")&&!$i.call(a,"callee")};function Ri(){return!1}var gt=typeof D=="object"&&D&&!D.nodeType&&D,ft=gt&&typeof module=="object"&&module&&!module.nodeType&&module,Fi=ft&&ft.exports===gt,yt=Fi?se.Buffer:void 0,ki=yt?yt.isBuffer:void 0,wt=ki||Ri,Hi="[object Arguments]",zi="[object Array]",Ni="[object Boolean]",Gi="[object Date]",Bi="[object Error]",ji="[object Function]",Yi="[object Map]",Vi="[object Number]",Wi="[object Object]",Ui="[object RegExp]",Ki="[object Set]",qi="[object String]",Xi="[object WeakMap]",Ji="[object ArrayBuffer]",Qi="[object DataView]",Zi="[object Float32Array]",es="[object Float64Array]",ts="[object Int8Array]",is="[object Int16Array]",ss="[object Int32Array]",rs="[object Uint8Array]",os="[object Uint8ClampedArray]",ns="[object Uint16Array]",as="[object Uint32Array]",z={};z[Zi]=z[es]=z[ts]=z[is]=z[ss]=z[rs]=z[os]=z[ns]=z[as]=!0,z[Hi]=z[zi]=z[Ji]=z[Ni]=z[Qi]=z[Gi]=z[Bi]=z[ji]=z[Yi]=z[Vi]=z[Wi]=z[Ui]=z[Ki]=z[qi]=z[Xi]=!1;function ls(a){return Le(a)&&dt(a.length)&&!!z[Pe(a)]}function He(a){return function(t){return a(t)}}var vt=typeof D=="object"&&D&&!D.nodeType&&D,Ee=vt&&typeof module=="object"&&module&&!module.nodeType&&module,hs=Ee&&Ee.exports===vt,ze=hs&&st.process,ge=(function(){try{var a=Ee&&Ee.require&&Ee.require("util").types;return a||ze&&ze.binding&&ze.binding("util")}catch{}})(),Ct=ge&&ge.isTypedArray,cs=Ct?He(Ct):ls,ds=Object.prototype,ps=ds.hasOwnProperty;function us(a,t){var e=_e(a),i=!e&&Oi(a),o=!e&&!i&&wt(a),s=!e&&!i&&!o&&cs(a),r=e||i||o||s,n=r?Di(a.length,String):[],l=n.length;for(var c in a)ps.call(a,c)&&!(r&&(c=="length"||o&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Pi(c,l)))&&n.push(c);return n}function bt(a,t){return function(e){return a(t(e))}}var ms=bt(Object.keys,Object),gs=Object.prototype,fs=gs.hasOwnProperty;function ys(a){if(!pt(a))return ms(a);var t=[];for(var e in Object(a))fs.call(a,e)&&e!="constructor"&&t.push(e);return t}function ws(a){return xi(a)?us(a):ys(a)}var Me=de(Object,"create");function vs(){this.__data__=Me?Me(null):{},this.size=0}function Cs(a){var t=this.has(a)&&delete this.__data__[a];return this.size-=t?1:0,t}var bs="__lodash_hash_undefined__",Ps=Object.prototype,Ls=Ps.hasOwnProperty;function Es(a){var t=this.__data__;if(Me){var e=t[a];return e===bs?void 0:e}return Ls.call(t,a)?t[a]:void 0}var Ms=Object.prototype,Is=Ms.hasOwnProperty;function Ts(a){var t=this.__data__;return Me?t[a]!==void 0:Is.call(t,a)}var xs="__lodash_hash_undefined__";function _s(a,t){var e=this.__data__;return this.size+=this.has(a)?0:1,e[a]=Me&&t===void 0?xs:t,this}function pe(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}pe.prototype.clear=vs,pe.prototype.delete=Cs,pe.prototype.get=Es,pe.prototype.has=Ts,pe.prototype.set=_s;function Ds(){this.__data__=[],this.size=0}function Se(a,t){for(var e=a.length;e--;)if(ct(a[e][0],t))return e;return-1}var Ss=Array.prototype,As=Ss.splice;function $s(a){var t=this.__data__,e=Se(t,a);if(e<0)return!1;var i=t.length-1;return e==i?t.pop():As.call(t,e,1),--this.size,!0}function Os(a){var t=this.__data__,e=Se(t,a);return e<0?void 0:t[e][1]}function Rs(a){return Se(this.__data__,a)>-1}function Fs(a,t){var e=this.__data__,i=Se(e,a);return i<0?(++this.size,e.push([a,t])):e[i][1]=t,this}function oe(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}oe.prototype.clear=Ds,oe.prototype.delete=$s,oe.prototype.get=Os,oe.prototype.has=Rs,oe.prototype.set=Fs;var Ie=de(se,"Map");function ks(){this.size=0,this.__data__={hash:new pe,map:new(Ie||oe),string:new pe}}function Hs(a){var t=typeof a;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?a!=="__proto__":a===null}function Ae(a,t){var e=a.__data__;return Hs(t)?e[typeof t=="string"?"string":"hash"]:e.map}function zs(a){var t=Ae(this,a).delete(a);return this.size-=t?1:0,t}function Ns(a){return Ae(this,a).get(a)}function Gs(a){return Ae(this,a).has(a)}function Bs(a,t){var e=Ae(this,a),i=e.size;return e.set(a,t),this.size+=e.size==i?0:1,this}function fe(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}fe.prototype.clear=ks,fe.prototype.delete=zs,fe.prototype.get=Ns,fe.prototype.has=Gs,fe.prototype.set=Bs;function js(a,t){for(var e=-1,i=t.length,o=a.length;++e<i;)a[o+e]=t[e];return a}var Ys=bt(Object.getPrototypeOf,Object);function Vs(){this.__data__=new oe,this.size=0}function Ws(a){var t=this.__data__,e=t.delete(a);return this.size=t.size,e}function Us(a){return this.__data__.get(a)}function Ks(a){return this.__data__.has(a)}var qs=200;function Xs(a,t){var e=this.__data__;if(e instanceof oe){var i=e.__data__;if(!Ie||i.length<qs-1)return i.push([a,t]),this.size=++e.size,this;e=this.__data__=new fe(i)}return e.set(a,t),this.size=e.size,this}function ye(a){var t=this.__data__=new oe(a);this.size=t.size}ye.prototype.clear=Vs,ye.prototype.delete=Ws,ye.prototype.get=Us,ye.prototype.has=Ks,ye.prototype.set=Xs;var Pt=typeof D=="object"&&D&&!D.nodeType&&D,Lt=Pt&&typeof module=="object"&&module&&!module.nodeType&&module,Js=Lt&&Lt.exports===Pt,Et=Js?se.Buffer:void 0;Et&&Et.allocUnsafe;function Qs(a,t){return a.slice()}function Zs(a,t){for(var e=-1,i=a==null?0:a.length,o=0,s=[];++e<i;){var r=a[e];t(r,e,a)&&(s[o++]=r)}return s}function er(){return[]}var tr=Object.prototype,ir=tr.propertyIsEnumerable,Mt=Object.getOwnPropertySymbols,sr=Mt?function(a){return a==null?[]:(a=Object(a),Zs(Mt(a),function(t){return ir.call(a,t)}))}:er;function rr(a,t,e){var i=t(a);return _e(a)?i:js(i,e(a))}function or(a){return rr(a,ws,sr)}var Ne=de(se,"DataView"),Ge=de(se,"Promise"),Be=de(se,"Set"),It="[object Map]",nr="[object Object]",Tt="[object Promise]",xt="[object Set]",_t="[object WeakMap]",Dt="[object DataView]",ar=ce(Ne),lr=ce(Ie),hr=ce(Ge),cr=ce(Be),dr=ce(ke),ne=Pe;(Ne&&ne(new Ne(new ArrayBuffer(1)))!=Dt||Ie&&ne(new Ie)!=It||Ge&&ne(Ge.resolve())!=Tt||Be&&ne(new Be)!=xt||ke&&ne(new ke)!=_t)&&(ne=function(a){var t=Pe(a),e=t==nr?a.constructor:void 0,i=e?ce(e):"";if(i)switch(i){case ar:return Dt;case lr:return It;case hr:return Tt;case cr:return xt;case dr:return _t}return t});var pr=Object.prototype,ur=pr.hasOwnProperty;function mr(a){var t=a.length,e=new a.constructor(t);return t&&typeof a[0]=="string"&&ur.call(a,"index")&&(e.index=a.index,e.input=a.input),e}var St=se.Uint8Array;function je(a){var t=new a.constructor(a.byteLength);return new St(t).set(new St(a)),t}function gr(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.byteLength)}var fr=/\w*$/;function yr(a){var t=new a.constructor(a.source,fr.exec(a));return t.lastIndex=a.lastIndex,t}var At=me?me.prototype:void 0,$t=At?At.valueOf:void 0;function wr(a){return $t?Object($t.call(a)):{}}function vr(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.length)}var Cr="[object Boolean]",br="[object Date]",Pr="[object Map]",Lr="[object Number]",Er="[object RegExp]",Mr="[object Set]",Ir="[object String]",Tr="[object Symbol]",xr="[object ArrayBuffer]",_r="[object DataView]",Dr="[object Float32Array]",Sr="[object Float64Array]",Ar="[object Int8Array]",$r="[object Int16Array]",Or="[object Int32Array]",Rr="[object Uint8Array]",Fr="[object Uint8ClampedArray]",kr="[object Uint16Array]",Hr="[object Uint32Array]";function zr(a,t,e){var i=a.constructor;switch(t){case xr:return je(a);case Cr:case br:return new i(+a);case _r:return gr(a);case Dr:case Sr:case Ar:case $r:case Or:case Rr:case Fr:case kr:case Hr:return vr(a);case Pr:return new i;case Lr:case Ir:return new i(a);case Er:return yr(a);case Mr:return new i;case Tr:return wr(a)}}function Nr(a){return typeof a.constructor=="function"&&!pt(a)?wi(Ys(a)):{}}var Gr="[object Map]";function Br(a){return Le(a)&&ne(a)==Gr}var Ot=ge&&ge.isMap,jr=Ot?He(Ot):Br,Yr="[object Set]";function Vr(a){return Le(a)&&ne(a)==Yr}var Rt=ge&&ge.isSet,Wr=Rt?He(Rt):Vr,Ft="[object Arguments]",Ur="[object Array]",Kr="[object Boolean]",qr="[object Date]",Xr="[object Error]",kt="[object Function]",Jr="[object GeneratorFunction]",Qr="[object Map]",Zr="[object Number]",Ht="[object Object]",eo="[object RegExp]",to="[object Set]",io="[object String]",so="[object Symbol]",ro="[object WeakMap]",oo="[object ArrayBuffer]",no="[object DataView]",ao="[object Float32Array]",lo="[object Float64Array]",ho="[object Int8Array]",co="[object Int16Array]",po="[object Int32Array]",uo="[object Uint8Array]",mo="[object Uint8ClampedArray]",go="[object Uint16Array]",fo="[object Uint32Array]",H={};H[Ft]=H[Ur]=H[oo]=H[no]=H[Kr]=H[qr]=H[ao]=H[lo]=H[ho]=H[co]=H[po]=H[Qr]=H[Zr]=H[Ht]=H[eo]=H[to]=H[io]=H[so]=H[uo]=H[mo]=H[go]=H[fo]=!0,H[Xr]=H[kt]=H[ro]=!1;function $e(a,t,e,i,o,s){var r;if(r!==void 0)return r;if(!De(a))return a;var n=_e(a);if(n)r=mr(a);else{var l=ne(a),c=l==kt||l==Jr;if(wt(a))return Qs(a);if(l==Ht||l==Ft||c&&!o)r=c?{}:Nr(a);else{if(!H[l])return o?a:{};r=zr(a,l)}}s||(s=new ye);var d=s.get(a);if(d)return d;s.set(a,r),Wr(a)?a.forEach(function(g){r.add($e(g,t,e,g,a,s))}):jr(a)&&a.forEach(function(g,p){r.set(p,$e(g,t,e,p,a,s))});var u=or,m=n?void 0:u(a);return vi(m||a,function(g,p){m&&(p=g,g=a[p]),Ii(r,p,$e(g,t,e,p,a,s))}),r}var yo=1,wo=4;function Oe(a){return $e(a,yo|wo)}var zt=(a=>(a.Rotate="rotate",a.Move="move",a.Scale="scale",a.MoveHeight="moveHeight",a.Empty="",a))(zt||{}),Nt=(a=>(a.Scale="addScale",a.Rotate="rotate",a.Translation="translation",a.Remove="removeById",a.Add="add",a))(Nt||{});class vo{constructor(t){h(this,"primitives",new Map);h(this,"eventListener",new Map);h(this,"Cesium");h(this,"viewer");h(this,"handler");h(this,"rotationRing");h(this,"translationSquare");h(this,"heightArrow");h(this,"editMode","");h(this,"dragEndCallbackMap",new Map);this.Cesium=t.Cesium,this.viewer=t.viewer,this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)}init(t,e=!1){const i=this.viewer;this.primitives.forEach(o=>{i.scene.primitives.remove(o)}),t.forEach(o=>{this.primitives.has(o.id)||this.add(o,e)})}get(t){return this.primitives.get(t)}add(t,e=!0){var u,m,g;const i=this.viewer,o=this.Cesium,s=o.Math.toRadians(((u=t.headingPitchRoll)==null?void 0:u.heading)||0),r=o.Math.toRadians(((m=t.headingPitchRoll)==null?void 0:m.pitch)||0),n=o.Math.toRadians(((g=t.headingPitchRoll)==null?void 0:g.roll)||0),l=new o.HeadingPitchRoll(s,r,n),c=o.Transforms.headingPitchRollToFixedFrame(t.position,l,i.scene.globe.ellipsoid,o.Transforms.eastNorthUpToFixedFrame,new o.Matrix4);let d=i.scene.primitives.add(o.Model.fromGltf({id:t.id,...t.model,modelMatrix:c}));d.scale=t.scale||1,this.primitives.set(t.id,d),d.show=e,this.runEventListener("add",{info:t,gltf:d})}flyTo(t){const e=this.viewer,i=this.Cesium;let o=this.primitives.get(t);const s=o.boundingSphere,r=i.Matrix4.multiplyByPoint(o.modelMatrix,s.center,new i.Cartesian3),n=new i.BoundingSphere(r,s.radius);e.camera.flyToBoundingSphere(n,{duration:1.5,offset:new i.HeadingPitchRange(0,-.5,s.radius*2)})}removeById(t){var o;const e=this.viewer;let i=this.primitives.get(t);if(!i){console.error(`No model found with id: ${t}`);return}e.scene.primitives.remove(i),this.primitives.delete(t),(!((o=this.rotationRing)!=null&&o._instanceIds.includes(`rotationRing_${t}`))||!this.rotationRing)&&this.removeTool(),this.runEventListener("removeById",{id:t,gltf:i})}show(t){let e=this.primitives.get(t);e&&(e.show=!0)}hide(t){let e=this.primitives.get(t);e&&(e.show=!1)}addScale(t,e=.1){let i=this.primitives.get(t.id);i&&(i.scale=i.scale+e,this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t.id,scale:i.scale}))}setScale(t,e=.1){let i=this.primitives.get(t);i&&(i.scale=e,this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t,scale:i.scale}))}setEditMode(t){this.editMode=t}lockCamera(){const t=this.viewer.scene.screenSpaceCameraController;t.enableRotate=!1,t.enableTranslate=!1,t.enableZoom=!1}unlockCamera(){const t=this.viewer.scene.screenSpaceCameraController;t.enableRotate=!0,t.enableTranslate=!0,t.enableZoom=!0}toCartographic(t){const e=this.Cesium.Cartographic.fromCartesian(t);return{longitude:e.longitude,latitude:e.latitude}}calculateHeading(t,e){const i=e.longitude-t.longitude,o=e.latitude-t.latitude;return Math.atan2(o,i)}getModelHeadingPitchRoll(t){const e=this.Cesium,i=this.viewer,o=e.Transforms.eastNorthUpToFixedFrame(e.Matrix4.getTranslation(t,new e.Cartesian3),i.scene.globe.ellipsoid,new e.Matrix4),s=e.Matrix4.multiply(e.Matrix4.inverse(o,new e.Matrix4),t,new e.Matrix4),r=e.Matrix4.getRotation(s,new e.Matrix3),n=e.Quaternion.fromRotationMatrix(r);return e.HeadingPitchRoll.fromQuaternion(n)}addEventListener(t,e,i){let o={f:e,options:i};return this.eventListener.get(t)?(this.eventListener.get(t)||[]).push(o):this.eventListener.set(t,[o]),o}removeEventListener(t,e){let i=this.eventListener.get(t);if(!i)return console.error("key不存在");let o=i.findIndex(s=>s==e);o>=0?i.splice(o,1):console.error("instantiation不存在")}runEventListener(t,e){let i=this.eventListener.get(t);return i?(i.forEach(o=>{typeof o.f=="function"&&o.f(e)}),!0):!1}initEditBox(t){const e=this.Cesium,i=this.viewer,o=i.scene;let s=null,r=null,n=null,l=null,c=null;const d=()=>{s=null,r=null,n=null,c=null,l=null,this.setEditMode(""),this.unlockCamera()},u=(m,g)=>{if(s=this.primitives.get(m),s){r=e.Matrix4.clone(s.modelMatrix);const p=e.Matrix4.getTranslation(r,new e.Cartesian3);n=this.toCartographic(p),c=g.position;const y=o.globe.pick(i.camera.getPickRay(g.position),o);l=this.toCartographic(y),this.lockCamera()}};this.handler.setInputAction(m=>{var y,w,f,v,C,b,M,P,L,E;if(!t())return;const p=o.pick(m.position);if(p&&p.id&&((y=p.id)!=null&&y.includes("rotationRing"))){let I=p.id.split("rotationRing_")[1];this.setEditMode("rotate"),u(I,m)}else if(p&&p.id&&((w=p.id)!=null&&w.includes("translationSquare_"))){let I=p.id.split("translationSquare_")[1];this.setEditMode("move"),u(I,m)}else if(p&&p.id&&((f=p.id)!=null&&f.includes("heightArrow-line_"))){let I=p.id.split("heightArrow-line_")[1];this.setEditMode("moveHeight"),u(I,m)}else if(p&&p.id&&((v=p.id)!=null&&v.includes("heightArrow-arrow_"))){let I=p.id.split("heightArrow-arrow_")[1];this.setEditMode("moveHeight"),u(I,m)}else if(p&&p.id){if(s=this.primitives.get(p.id),!s)return;(!this.rotationRing||!((b=(C=this.rotationRing)==null?void 0:C._instanceIds)!=null&&b.includes(`rotationRing_${s.id}`)))&&this.createRotationRing(s),(!this.translationSquare||!((P=(M=this.translationSquare)==null?void 0:M._instanceIds)!=null&&P.includes(`translationSquare_${s.id}`)))&&this.createTranslationSquare(s),(!this.heightArrow||!((E=(L=this.heightArrow)==null?void 0:L._instanceIds)!=null&&E.includes(`heightArrow_${s.id}`)))&&this.createHeightArrow(s)}else d()},e.ScreenSpaceEventType.LEFT_DOWN),this.handler.setInputAction(m=>{if(t()&&this.editMode!=""&&s){const p=o.globe.pick(i.camera.getPickRay(m.endPosition),o),y=this.toCartographic(p);let w=0;if(this.editMode==="rotate"){let f=this.calculateHeading(n,y);w=this.calculateHeading(n,l)-f,this.rotateModel(s,r,w)}else this.editMode==="move"?this.moveModel(s,r,m):this.editMode==="moveHeight"&&this.moveModelHeight(s,r,m,c)}},e.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(()=>{if(!t())return;let g=this.dragEndCallbackMap.get(s==null?void 0:s.id);if(g&&(this.editMode==="move"||this.editMode==="moveHeight")){let p=g.get("translation");p&&(this.runEventListener("translation",p),g.delete("translation"))}else if(g&&this.editMode==="rotate"){let p=g.get("rotate");p&&(this.runEventListener("rotate",p),g.delete("rotate"))}d()},e.ScreenSpaceEventType.LEFT_UP),this.handler.setInputAction(()=>{this.removeTool()},e.ScreenSpaceEventType.RIGHT_UP)}createRotationRing(t){const e=this.Cesium,i=this.viewer;this.rotationRing&&i.scene.primitives.remove(this.rotationRing);const o=[];for(let n=0;n<=360;n+=3){const l=Math.sin(e.Math.toRadians(n)),c=Math.cos(e.Math.toRadians(n)),d=t.boundingSphere.radius*c,u=t.boundingSphere.radius*l;o.push(new e.Cartesian3(d,u,0))}const s=new e.PolylineGeometry({positions:o,width:Math.max(t.boundingSphere.radius*.05,1)}),r=new e.GeometryInstance({id:`rotationRing_${t.id}`,geometry:s,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.RED)}});this.rotationRing=new e.Primitive({geometryInstances:r,appearance:new e.PolylineColorAppearance({translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.RED.withAlpha(.3)}),translucent:!0}),modelMatrix:t.modelMatrix,cull:!1}),i.scene.primitives.add(this.rotationRing)}createTranslationSquare(t){const e=this.Cesium,i=this.viewer;this.translationSquare&&i.scene.primitives.remove(this.translationSquare);const s=Math.max(t.boundingSphere.radius*.2,1)/2,r=new e.BoxGeometry({maximum:new e.Cartesian3(s,s,s),minimum:new e.Cartesian3(-s,-s,-s)}),n=new e.GeometryInstance({id:`translationSquare_${t.id}`,geometry:r,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.BLUE)}});this.translationSquare=new e.Primitive({geometryInstances:n,appearance:new e.PolylineColorAppearance({translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.BLUE.withAlpha(.3)}),translucent:!0}),cull:!1,modelMatrix:t.modelMatrix}),i.scene.primitives.add(this.translationSquare)}createHeightArrow(t){const e=this.Cesium,i=this.viewer;this.heightArrow&&i.scene.primitives.remove(this.heightArrow);let o=e.Color.GREEN,s=Math.max(t.boundingSphere.radius*.025,1),r=2*s,n=t.boundingSphere.radius+50,l=n*.1;const c=Math.max(t.boundingSphere.radius*.2,1),d=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:n,topRadius:s,bottomRadius:s})),u=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:l,topRadius:0,bottomRadius:r}));let m=n+c,g=(n+c)/2;this.translate(d,[0,0,g]),this.translate(u,[0,0,m]),this.heightArrow=new e.Primitive({modelMatrix:t.modelMatrix,geometryInstances:[new e.GeometryInstance({id:`heightArrow-line_${t.id}`,geometry:d}),new e.GeometryInstance({id:`heightArrow-arrow_${t.id}`,geometry:u})],appearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:o}),translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:o.withAlpha(.3)}),translucent:!0}),cull:!1}),i.scene.primitives.add(this.heightArrow)}translate(t,e){let i=this.Cesium;const o=new i.Cartesian3;_e(e)?(o.x=e[0],o.y=e[1],o.z=e[2]):i.Cartesian3.clone(e,o);for(let s=0;s<t.attributes.position.values.length;s+=3)t.attributes.position.values[s]+=o.x,t.attributes.position.values[s+1]+=o.y,t.attributes.position.values[s+2]+=o.z}removeTool(){this.rotationRing&&this.viewer.scene.primitives.remove(this.rotationRing),this.translationSquare&&this.viewer.scene.primitives.remove(this.translationSquare),this.heightArrow&&this.viewer.scene.primitives.remove(this.heightArrow)}updatedTool(t){this.rotationRing&&(this.rotationRing.modelMatrix=t),this.translationSquare&&(this.translationSquare.modelMatrix=t),this.heightArrow&&(this.heightArrow.modelMatrix=t)}moveModel(t,e,i){const o=this.Cesium,s=this.viewer,r=s.scene,n=r.globe.pick(s.camera.getPickRay(i.endPosition),r);if(n){const l=o.Matrix4.getTranslation(e,new o.Cartesian3),c=o.Cartographic.fromCartesian(l),d=o.Cartographic.fromCartesian(n),u=new o.Cartographic(d.longitude,d.latitude,c.height),m=o.Cartographic.toCartesian(u),g=o.Matrix4.getRotation(e,new o.Matrix3),p=o.Matrix4.fromRotationTranslation(g,m);t.modelMatrix=p,this.updatedTool(p);let y=new o.Cartesian3(p[12],p[13],p[14]),w=this.dragEndCallbackMap.get(t.id);w||(w=new Map,this.dragEndCallbackMap.set(t.id,w)),w.set("translation",{id:t.id,position:y})}}moveModelHeight(t,e,i,o){const s=this.Cesium,r=this.viewer,n=r.scene,l=o.y-i.endPosition.y;if(n.globe.pick(r.camera.getPickRay(i.endPosition),n)){const d=s.Matrix4.getTranslation(e,new s.Cartesian3),u=s.Cartographic.fromCartesian(d),m=new s.Cartographic(u.longitude,u.latitude,u.height+l*.001*Math.max(r.camera.positionCartographic.height,1)),g=s.Cartographic.toCartesian(m),p=s.Matrix4.getRotation(e,new s.Matrix3),y=s.Matrix4.fromRotationTranslation(p,g);t.modelMatrix=y,this.updatedTool(y);let w=new s.Cartesian3(y[12],y[13],y[14]),f=this.dragEndCallbackMap.get(t.id);f||(f=new Map,this.dragEndCallbackMap.set(t.id,f)),f.set("translation",{id:t.id,position:w})}}rotateModel(t,e,i){const o=this.Cesium,s=this.viewer,r=this.getModelHeadingPitchRoll(e),n=r.heading+i,l=new o.HeadingPitchRoll(n,r.pitch,r.roll),c=o.Transforms.headingPitchRollToFixedFrame(o.Matrix4.getTranslation(t.modelMatrix,new o.Cartesian3),l,s.scene.globe.ellipsoid,o.Transforms.eastNorthUpToFixedFrame,new o.Matrix4);t.modelMatrix=c;let d=this.dragEndCallbackMap.get(t.id);d||(d=new Map,this.dragEndCallbackMap.set(t.id,d)),d.set("rotate",{id:t.id,headingPitchRoll:{heading:o.Math.toDegrees(n),pitch:o.Math.toDegrees(r.pitch),roll:o.Math.toDegrees(r.roll)}})}cleanup(){this.handler&&(this.handler.destroy(),this.handler=null)}}function Co(a,t){const e=t.materialType||"DynamicImgMaterial"+Date.now()+Math.floor(Math.random()*1e3);function i(s){this._definitionChanged=new a.Event,this._color=s.color,this._colorSubscription=void 0,this.color=s.color,this.duration=s.duration,this._time=Date.now()}Object.defineProperties(i.prototype,{isConstant:{get(){return!1}},definitionChanged:{get(){return this._definitionChanged}},color:a.createPropertyDescriptor("color")}),i.prototype.getType=function(){return e},i.prototype.getValue=function(s,r){return a.defined(r)||(r={}),r.color=a.Property.getValueOrClonedDefault(this._color,s,a.Color.WHITE,r.color),r.image=t.image,r},i.prototype.equals=function(s){return this===s||s instanceof i&&a.Property.equals(this._color,s._color)};const o=function(s){return`
2
2
  czm_material czm_getMaterial(czm_materialInput materialInput)
3
3
  {
4
4
  czm_material material = czm_getDefaultMaterial(materialInput);
@@ -16,15 +16,15 @@
16
16
  `;return s.freely=="vertical"?r+="vec4 colorImage = texture(image, vec2(fract(float("+s.count+")*st.t "+s.direction+` time), fract(st.s)));
17
17
  `:r+="vec4 colorImage = texture(image, vec2(fract(float("+s.count+")*st.s "+s.direction+` time), fract(st.t)));
18
18
  `,r+=`vec4 fragColor;
19
- fragColor.rgb = (colorImage.rgb) / 1.0;
19
+ fragColor.rgb = (color.rgb) / 1.0;
20
20
  fragColor = czm_gammaCorrect(fragColor);
21
- `,r+=` material.diffuse = colorImage.rgb;
22
- material.alpha = colorImage.a;
21
+ `,r+=` material.diffuse = color.rgb;
22
+ material.alpha = colorImage.a * color.a;
23
23
  material.emission = fragColor.rgb;
24
24
 
25
25
  return material;
26
26
  }
27
- `,r};return a.Material._materialCache.addMaterial(e,{fabric:{type:e,uniforms:{color:new a.Color(1,0,0,.5),image:t.image,time:0},source:o({count:t.count,freely:t.freely,direction:t.direction})},translucent:function(){return!0}}),new i(t)}function Po(a,t){const e=a.Color,i=Object.defineProperties,o=a.Event,s=a.createPropertyDescriptor,r=a.Property,n=(u,m)=>u===void 0?m:u,l={};let c=t.materialType||"PolylineFlow"+Date.now()+Math.floor(Math.random()*1e3);function d(u){u=n(u,l),this._definitionChanged=new o,this._color=void 0,this._colorSubscription=void 0,this.color=u.color||e.fromBytes(0,255,255,255),this._duration=void 0,this._durationSubscription=void 0,this.duration=n(u.duration,45)}return i(d.prototype,{isConstant:{get(){return!1}},definitionChanged:{get(){return this._definitionChanged}}}),d.prototype.getType=function(u){return c},d.prototype.getValue=function(u,m){return m||(m={}),m.color=r.getValueOrClonedDefault(this._color,u,a.Color.WHITE,m.color),m.duration=this._duration,m},d.prototype.equals=function(u){return this===u||u instanceof d&&r.equals(this._color,u._color)},i(d.prototype,{color:s("color"),duration:s("duration")}),a.PolylineFlowMaterialProperty=d,a.Material._materialCache.addMaterial(c,{fabric:{type:c,uniforms:{color:new e(1,1,1,1),duration:45},source:(function(){return`uniform vec4 color;
27
+ `,r};return a.Material._materialCache.addMaterial(e,{fabric:{type:e,uniforms:{color:t.color||new a.Color(1,1,1,1),image:t.image,time:0},source:o({count:t.count,freely:t.freely,direction:t.direction})},translucent:function(){return!0}}),new i(t)}function Po(a,t){const e=a.Color,i=Object.defineProperties,o=a.Event,s=a.createPropertyDescriptor,r=a.Property,n=(u,m)=>u===void 0?m:u,l={};let c=t.materialType||"PolylineFlow"+Date.now()+Math.floor(Math.random()*1e3);function d(u){u=n(u,l),this._definitionChanged=new o,this._color=void 0,this._colorSubscription=void 0,this.color=u.color||e.fromBytes(0,255,255,255),this._duration=void 0,this._durationSubscription=void 0,this.duration=n(u.duration,45)}return i(d.prototype,{isConstant:{get(){return!1}},definitionChanged:{get(){return this._definitionChanged}}}),d.prototype.getType=function(u){return c},d.prototype.getValue=function(u,m){return m||(m={}),m.color=r.getValueOrClonedDefault(this._color,u,a.Color.WHITE,m.color),m.duration=this._duration,m},d.prototype.equals=function(u){return this===u||u instanceof d&&r.equals(this._color,u._color)},i(d.prototype,{color:s("color"),duration:s("duration")}),a.PolylineFlowMaterialProperty=d,a.Material._materialCache.addMaterial(c,{fabric:{type:c,uniforms:{color:new e(1,1,1,1),duration:45},source:(function(){return`uniform vec4 color;
28
28
  uniform float duration;
29
29
  czm_material czm_getMaterial(czm_materialInput materialInput){
30
30
  czm_material material = czm_getDefaultMaterial(materialInput);