leiting-bim 2.2.63 → 2.2.65
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.
- package/OpenSourceModelConvert/output/test/Errorlog/2026-10-21.log +250 -0
- package/leiting-bim.es.js +1 -1
- package/package.json +1 -1
- package/plugins/cesium-core/dist/cesium-core.mjs +21 -5
- package/plugins/cesium-core/dist/cesium-core.umd.js +1 -1
- package/plugins/cesium-core/dist/components/HtmlOverlayLabelPool.d.ts +16 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-manage/index.d.ts +1 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/index.d.ts +2 -2
- package/plugins/cesium-vue/dist/components/marker-manage.js +8 -7
- package/plugins/cesium-vue/dist/{index-qGfk85JD.js → index-DlOVVw3V.js} +516 -411
- package/plugins/cesium-vue/dist/index.js +20 -19
package/package.json
CHANGED
|
@@ -597,6 +597,19 @@ class z {
|
|
|
597
597
|
c(this, "openWheel", !0);
|
|
598
598
|
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._cameraChangedFn = this._scheduleOcclusionCheck.bind(this), this.viewer.camera.changed.addEventListener(this._cameraChangedFn), this.eventBus = n || new Bt(), this.openWheel = s, this.runOcclusionCheckNow();
|
|
599
599
|
}
|
|
600
|
+
getAnchorTransform(t = "top-left") {
|
|
601
|
+
return {
|
|
602
|
+
"top-left": "",
|
|
603
|
+
"top-center": "translate(-50%, 0)",
|
|
604
|
+
"top-right": "translate(-100%, 0)",
|
|
605
|
+
"center-left": "translate(0, -50%)",
|
|
606
|
+
center: "translate(-50%, -50%)",
|
|
607
|
+
"center-right": "translate(-100%, -50%)",
|
|
608
|
+
"bottom-left": "translate(0, -100%)",
|
|
609
|
+
"bottom-center": "translate(-50%, -100%)",
|
|
610
|
+
"bottom-right": "translate(-100%, -100%)"
|
|
611
|
+
}[t] || "";
|
|
612
|
+
}
|
|
600
613
|
/**
|
|
601
614
|
* 创建标签容器
|
|
602
615
|
*/
|
|
@@ -681,7 +694,7 @@ class z {
|
|
|
681
694
|
}
|
|
682
695
|
p = { id: i, el: g, theme: r, data: t, notCreateElement: l, unload: m }, this.labels.set(i, p);
|
|
683
696
|
}
|
|
684
|
-
p.el.dataset.lon = String(n), p.el.dataset.lat = String(s), p.el.dataset.height = String(o), p.el.style.zIndex = (d == null ? void 0 : d.zIndex) || "1", p.el.style.display = a ? "block" : "none", a && this.activeIds.add(i), a ? this._scheduleOcclusionCheck() : this.occludedIds.delete(i);
|
|
697
|
+
p.el.dataset.lon = String(n), p.el.dataset.lat = String(s), p.el.dataset.height = String(o), p.offset = e.offset, p.anchor = e.anchor || "top-left", p.el.style.zIndex = (d == null ? void 0 : d.zIndex) || "1", p.el.style.display = a ? "block" : "none", a && this.activeIds.add(i), a ? this._scheduleOcclusionCheck() : (this.activeIds.delete(i), this.occludedIds.delete(i));
|
|
685
698
|
}
|
|
686
699
|
/**
|
|
687
700
|
* 批量添加标签
|
|
@@ -725,7 +738,7 @@ class z {
|
|
|
725
738
|
return;
|
|
726
739
|
}
|
|
727
740
|
try {
|
|
728
|
-
n.createElement(i.el, { id: t, theme: i.theme, data: e }, n);
|
|
741
|
+
i.data = e, n.createElement(i.el, { id: t, theme: i.theme, data: e }, n);
|
|
729
742
|
} catch (s) {
|
|
730
743
|
console.error(`Failed to update label "${t}":`, s);
|
|
731
744
|
}
|
|
@@ -855,8 +868,10 @@ class z {
|
|
|
855
868
|
}
|
|
856
869
|
const r = this.Cesium.Cartesian3.fromDegrees(n, s, o), a = this.toWindowCoordinates(r);
|
|
857
870
|
if (this.Cesium.defined(a)) {
|
|
858
|
-
const
|
|
859
|
-
i.el.style.left = `${a.x}px`, i.el.style.top = `${a.y}px
|
|
871
|
+
const l = this.themes[i.theme], d = i.offset || ((t = l.options) == null ? void 0 : t.offset) || {}, u = d.x || 0, p = d.y || 0, g = this.occludedIds.has(e);
|
|
872
|
+
i.el.style.left = `${a.x}px`, i.el.style.top = `${a.y}px`;
|
|
873
|
+
const m = this.getAnchorTransform(i.anchor);
|
|
874
|
+
i.el.style.transform = `${m}${m ? " " : ""}translate(${u}px, ${p}px)`, i.el.style.display = g ? "none" : "block";
|
|
860
875
|
} else
|
|
861
876
|
i.el.style.display = "none";
|
|
862
877
|
}
|
|
@@ -1073,7 +1088,8 @@ class jt {
|
|
|
1073
1088
|
(t = this.handler) == null || t.destroy(), this.handler = null;
|
|
1074
1089
|
}
|
|
1075
1090
|
clear() {
|
|
1076
|
-
|
|
1091
|
+
var t;
|
|
1092
|
+
(t = this.tooltip) == null || t.hide(), this.tooltip = null, this.entity && (this.viewer.entities.remove(this.entity), this.entity = null), this.stopDrawing();
|
|
1077
1093
|
}
|
|
1078
1094
|
}
|
|
1079
1095
|
class Wt {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(_,te){typeof exports=="object"&&typeof module<"u"?te(exports):typeof define=="function"&&define.amd?define(["exports"],te):(_=typeof globalThis<"u"?globalThis:_||self,te(_.CesiumCore={}))})(this,(function(_){"use strict";var Fo=Object.defineProperty;var zo=(_,te,V)=>te in _?Fo(_,te,{enumerable:!0,configurable:!0,writable:!0,value:V}):_[te]=V;var c=(_,te,V)=>zo(_,typeof te!="symbol"?te+"":te,V);class te{constructor(t,e,i){c(this,"Cesium");c(this,"viewer");c(this,"labelPool");c(this,"threshold");c(this,"displayLimit");c(this,"maxLevel");c(this,"debugCurrentGrids");c(this,"levels");c(this,"points",[]);c(this,"gridLayers",new Map);c(this,"debugGrids",[]);c(this,"_updateFn");c(this,"clusterTheme");c(this,"pointTheme");c(this,"centralPointMode");c(this,"minGlobalPointCount");c(this,"groupByTheme");c(this,"tilingScheme");c(this,"terrainLevelOffset");c(this,"debugTileCoordLayer",null);c(this,"levelIndexByTileLevel",new Map);c(this,"_lastTileProvider",null);c(this,"_updateTimer",null);c(this,"_updateDelay",100);c(this,"_tilesRetryCount",0);c(this,"_tilesRetryMax",100);c(this,"_cameraDirty",!1);c(this,"_tileLoadListener",null);c(this,"_cameraChangedHandler",null);c(this,"defaultMinLevel",0);c(this,"defaultMaxLevel",28);c(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 n=this.viewer.scene&&this.viewer.scene.globe,s=n&&n._surface,o=s&&s._tileProvider,r=(o==null?void 0:o.tilingScheme)||new this.Cesium.GeographicTilingScheme;this._lastTileProvider=o,this.tilingScheme=r,this.levels=this._createLevels(),this._buildLevels(),this._updateFn=this._update.bind(this),this.debugCurrentGrids&&this._ensureDebugImageryLayer(),n&&(this._tileLoadListener=a=>{a===0&&this._cameraDirty&&(this._cameraDirty=!1,this._scheduleUpdate())},n.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,n=(i==null?void 0:i.tilingScheme)||new this.Cesium.GeographicTilingScheme,s=i!==this._lastTileProvider,o=this.tilingScheme!==n;!s&&!o&&this.levels&&this.levels.length>0||(this._lastTileProvider=i,this.tilingScheme=n,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 n=0;for(let s=e;s<=i;s++,n++){const o=360/Math.pow(2,s);t.push({level:s,size:o,minViewWidth:o*4}),this.levelIndexByTileLevel.set(s,n)}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()}_getCurrentBillboard(t){var e;return(t==null?void 0:t.__currentBillboard)||((e=t==null?void 0:t.billboard)==null?void 0:e[0])}_getBillboardTheme(t){var e;return(e=this._getCurrentBillboard(t))==null?void 0:e.theme}_shouldSkipAggregation(t){var e;return(e=this._getCurrentBillboard(t))==null?void 0:e.skipAggregation}_scheduleUpdate(){this._updateTimer!==null&&clearTimeout(this._updateTimer),this._updateTimer=window.setTimeout(()=>{this._update(),this._cameraDirty=!0,this._updateTimer=null},this._updateDelay)}updatePoint(t){const e=this.points.findIndex(s=>s.id===t.id);if(e===-1)return;const i=this.points[e];for(const s of this.levels){const o=s.level,r=this.gridLayers.get(o);if(!r)continue;const a=this.Cesium.Cartographic.fromDegrees(i.lon,i.lat),l=this.tilingScheme.positionToTileXY(a,o,new this.Cesium.Cartesian2);if(!l)continue;const d=`${l.x}_${l.y}`,u=r.get(d);if(u){const p=u.allPoints.findIndex(g=>g.id===t.id);if(p!==-1&&u.allPoints.splice(p,1),this._shouldSkipAggregation(i.data)){const g=u.skipPoints.findIndex(m=>m.id===t.id);g!==-1&&u.skipPoints.splice(g,1)}else{const g=this.groupByTheme?this._getBillboardTheme(i.data):this.clusterTheme,m=u.groups.get(g);if(m){const f=m.findIndex(y=>y.id===t.id);f!==-1&&m.splice(f,1),m.length===0&&u.groups.delete(g)}}}}const n={...i,...t};this.points[e]=n,this._addPointToGrid(n),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 n=this.gridLayers.get(i.level);if(n)for(const[s,o]of n.entries()){o.allPoints=o.allPoints.filter(r=>!e.has(r.id)),o.skipPoints=o.skipPoints.filter(r=>!e.has(r.id));for(const[r,a]of o.groups.entries()){const l=a.filter(d=>!e.has(d.id));l.length===0?o.groups.delete(r):o.groups.set(r,l)}o.allPoints.length===0&&n.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){for(const e of this.levels){const i=e.level,n=this.gridLayers.get(i);if(!n)continue;const s=this.Cesium.Cartographic.fromDegrees(t.lon,t.lat),o=this.tilingScheme.positionToTileXY(s,i,new this.Cesium.Cartesian2);if(!o)continue;const r=`${o.x}_${o.y}`;let a=n.get(r);if(a||(a={allPoints:[],groups:new Map,skipPoints:[]},n.set(r,a)),a.allPoints.push(t),this._shouldSkipAggregation(t.data))a.skipPoints.push(t);else{const l=this.groupByTheme?this._getBillboardTheme(t.data):this.clusterTheme;a.groups.has(l)||a.groups.set(l,[]),a.groups.get(l).push(t)}}}_preparePointLevelRange(t){const e=t.data||{};let i=e.minLevel,n=e.maxLevel;const s=e.levelRange;Array.isArray(s)?(s.length>0&&i==null&&(i=s[0]),s.length>1&&n==null&&(n=s[1])):s&&typeof s=="object"&&(i==null&&typeof s.min=="number"&&(i=s.min),n==null&&typeof s.max=="number"&&(n=s.max));const o=i==null?this.defaultMinLevel:Number(i)||this.defaultMinLevel,r=n==null?this.defaultMaxLevel:Number(n)||this.defaultMaxLevel;t.__minLevel=o,t.__maxLevel=r}_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,n=t.__maxLevel??this.defaultMaxLevel;return e>=i&&e<=n}_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=(n,s,o,r)=>{e=this._processCell(n,s,o,r,t,e)};try{const n=this._getSurfaceTiles();if(!n||n.length===0){this._handleNoSurfaceTiles(e);return}this._tilesRetryCount=0,this._processTiles(n,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;for(const i of this.points){if(t>=this.displayLimit)break;((e=i.data)==null?void 0:e.show)!==!1&&(this.labelPool.add(i.data,{id:`point-${i.id}`,lon:i.lon,lat:i.lat,height:i.height,theme:this._getBillboardTheme(i.data)||this.pointTheme,style:i.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,n=this.levels[this.levels.length-1].level;if(t>n)return this.levels.length-1;if(t<i)return 0;let s=0,o=1/0;for(let r=0;r<this.levels.length;r++){const a=Math.abs(this.levels[r].level-t);a<o&&(o=a,s=r)}return s}_isTerrainEnabled(){const t=this.viewer.terrainProvider,e=this.viewer.scene,i=e&&e.globe,n=i&&i.terrainProvider,s=t||n;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,n=!this._isTerrainEnabled(),s=this.viewer.scene,o=s&&s.globe,r=o&&o.ellipsoid,a=r&&s.camera.computeViewRectangle(r),l=(d,u,p)=>{if(!n||!a)return!0;const g=this.tilingScheme.tileXYToRectangle(d,u,p);return!(!g||g.east<=a.west||g.west>=a.east||g.north<=a.south||g.south>=a.north)};for(const d of t){const u=d.rectangle,p=d._level??d.level;if(!u||typeof p!="number")continue;const g=this._getGridRefLevel(p),m=this._resolveLevelIndex(g);if(m===void 0)continue;const f=this.levels[m].level,y=d._x??d.x,v=d._y??d.y;if(typeof y=="number"&&typeof v=="number"){const T=p-f;if(T>=0){const A=1<<T,D=Math.floor(y/A),$=Math.floor(v/A),k=`${f}_${D}_${$}`;if(i.has(k))continue;i.add(k),e(m,D,$,p)}else{const D=1<<Math.min(-T,this.maxRefineLevels),$=y*D,k=v*D;for(let R=0;R<D;R++)for(let H=0;H<D;H++){const B=$+R,Y=k+H;if(!l(B,Y,f))continue;const G=`${f}_${B}_${Y}`;i.has(G)||(i.add(G),e(m,B,Y,p))}}continue}const P=this.levels[m].size,b=this.Cesium.Math.toDegrees(u.west),C=this.Cesium.Math.toDegrees(u.east),E=this.Cesium.Math.toDegrees(u.south),L=this.Cesium.Math.toDegrees(u.north),M=Math.floor((b- -180)/P),I=Math.floor((C- -180)/P),x=Math.floor((E- -90)/P),S=Math.floor((L- -90)/P);for(let T=M;T<=I;T++)for(let A=x;A<=S;A++){if(!l(T,A,f))continue;const D=`${f}_${T}_${A}`;i.has(D)||(i.add(D),e(m,T,A,p))}}}_processCell(t,e,i,n,s,o){if(o>=this.displayLimit||t<0)return o;t>=this.levels.length&&(t=this.levels.length-1);const r=this._getCellContext(t,e,i,n);return r?(o=this._processCellSkipPoints(r,o),o>=this.displayLimit?(this._debugDrawCell(r),o):(o=this._processCellGroups(r,s,o),this._debugDrawCell(r),o)):o}_getCellContext(t,e,i,n){const o=this.levels[t].level,r=this.gridLayers.get(o);if(!r)return null;const a=`${e}_${i}`,l=r.get(a);if(!l)return null;const d=this.tilingScheme.tileXYToRectangle(e,i,o),u=this.Cesium.Math.toDegrees(d.west),p=this.Cesium.Math.toDegrees(d.south),g=this.Cesium.Math.toDegrees(d.east),m=this.Cesium.Math.toDegrees(d.north),f=(u+g)/2,y=(p+m)/2;return{levelIdx:t,tileLevel:o,lonIdx:e,latIdx:i,key:a,cell:l,rect:d,west:u,south:p,east:g,north:m,centerLon:f,centerLat:y,viewTileLevel:n}}_processCellSkipPoints(t,e){var o;const{cell:i,viewTileLevel:n}=t,s=n;for(const r of i.skipPoints)if(((o=r.data)==null?void 0:o.show)!==!1){if(e>=this.displayLimit)break;this._isVisibleAtLevel(r,s)&&(this.labelPool.add(r.data,{id:`point-${r.id}`,lon:r.lon,lat:r.lat,height:r.height,theme:this._getBillboardTheme(r.data)||this.pointTheme,style:r.style}),e++)}return e}_processCellGroups(t,e,i){var p,g,m,f,y,v,w;const{levelIdx:n,lonIdx:s,latIdx:o,cell:r,centerLon:a,centerLat:l,viewTileLevel:d}=t,u=d;for(const[P,b]of r.groups){const C=b.filter(x=>{var S;return((S=x.data)==null?void 0:S.show)!==!1});if(C.length===0)continue;let E=a,L=l,M=((p=C[0])==null?void 0:p.height)||0;if(this.centralPointMode=="firstPoint"&&(E=((g=C[0])==null?void 0:g.lon)||0,L=((m=C[0])==null?void 0:m.lat)||0,M=((f=C[0])==null?void 0:f.height)||0),n===this.levels.length-1||C.length<e)for(const x of C){if(i>=this.displayLimit)break;this._isVisibleAtLevel(x,u)&&(this.labelPool.add(x.data,{id:`point-${x.id}`,lon:x.lon,lat:x.lat,height:x.height,theme:this._getBillboardTheme(x.data)||this.pointTheme,style:x.style}),i++)}else{if(i>=this.displayLimit)return i;const x=u==null?C:C.filter(D=>this._isVisibleAtLevel(D,u));if(!x.length)return i;const T=this._getBillboardTheme((y=x[0])==null?void 0:y.data)||this.clusterTheme,A=this.groupByTheme?`cluster-${n}-${s}-${o}-${P}`:`cluster-${n}-${s}-${o}`;this.labelPool.add({id:A,billboard:((w=(v=x[0])==null?void 0:v.data)==null?void 0:w.billboard)||[],count:x.length,gridKey:`${s}_${o}`,points:x,aggregationGroup:P},{id:A,lon:E,lat:L,height:M,theme:T}),i++}}return i}_debugDrawCell(t){if(!this.debugCurrentGrids)return;const{levelIdx:e,west:i,south:n,east:s,north:o,lonIdx:r,latIdx:a}=t,l=this.levels[e].level;this._drawDebugGrid(i,n,s,o,`L:${l} X:${r} Y:${a}`)}refresh(){this._update()}_drawDebugGrid(t,e,i,n,s){const o=this.Cesium.Rectangle.fromDegrees(t,e,i,n),r=this.Cesium.Cartesian3.fromDegreesArray([t,e,i,e,i,n,t,n,t,e]),a=this.viewer.entities.add({rectangle:{coordinates:o,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:r,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(a)}_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=(h=>(h.Click="marker:click",h.DoubleClick="marker:dblclick",h.RightClick="marker:rightclick",h.MouseEnter="marker:mouseenter",h.MouseLeave="marker:mouseleave",h.MouseDown="marker:mousedown",h.MouseUp="marker:mouseup",h))(V||{});class nt{constructor(){c(this,"listenerMap",new Map)}addListener(t,e,i=!1){let n=this.listenerMap.get(t);return n||(n=new Map,this.listenerMap.set(t,n)),n.has(e.name)?i?(console.warn(`[MarkerEventBus] Overwriting listener "${e.name}" for event "${t}".`),n.set(e.name,e),!0):(console.warn(`[MarkerEventBus] Listener "${e.name}" for event "${t}" already exists. Use overwrite=true to replace it.`),!1):(n.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 n=this.listenerMap.get(t);if(n)for(const[s,o]of n.entries()){try{o.fn(e,i)}catch(r){console.error(`Error in listener "${s}" for event "${t}":`,r)}o.once&&n.delete(s)}}}const ot={[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",n,s=!0){c(this,"viewer");c(this,"Cesium");c(this,"container");c(this,"labels",new Map);c(this,"activeIds",new Set);c(this,"occludedIds",new Set);c(this,"_updateFn");c(this,"_cameraChangedFn");c(this,"themes",{});c(this,"occlusionCheckLogs",[]);c(this,"occlusionLogEnabled",!1);c(this,"occlusionLogMax",1e4);c(this,"occlusionOptions",{enabled:!1,throttleMs:120,distanceEpsilon:1});c(this,"_occlusionTimer",null);c(this,"_lastOcclusionAt",0);c(this,"_occlusionChecking",!1);c(this,"_occlusionPending",!1);c(this,"eventBus");c(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._cameraChangedFn=this._scheduleOcclusionCheck.bind(this),this.viewer.camera.changed.addEventListener(this._cameraChangedFn),this.eventBus=n||new nt,this.openWheel=s,this.runOcclusionCheckNow()}_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:n,lat:s,height:o=0,theme:r,show:a=!0,notCreateElement:l=!1,style:d}=e,u=this.themes[r];if(!u){console.warn(`Theme "${r}" not registered`);return}let p=this.labels.get(i);if(p){p.theme=r,p.data=t,p.notCreateElement=l;try{p.unload=u.createElement(p.el,{id:i,theme:r,data:t},u),(!l||a)&&this.container.appendChild(p.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[f,y]of Object.entries(ot)){g.addEventListener(y,w=>{w.stopPropagation();const P=this.labels.get(i);this.eventBus.runListener(f,P,w)});let v=0;g.addEventListener("wheel",w=>{if(!this.openWheel)return;const P=w.currentTarget;v=Date.now();const b=v;P.style.pointerEvents="none",setTimeout(()=>{v===b&&(P.style.pointerEvents="auto")},2e3)})}let m=null;if(!l||a){try{m=u.createElement(g,{id:i,theme:r,data:t},u)||{}}catch(f){console.error(`Error updating label element for id "${i}":`,f)}this.container.appendChild(g)}p={id:i,el:g,theme:r,data:t,notCreateElement:l,unload:m},this.labels.set(i,p)}p.el.dataset.lon=String(n),p.el.dataset.lat=String(s),p.el.dataset.height=String(o),p.el.style.zIndex=(d==null?void 0:d.zIndex)||"1",p.el.style.display=a?"block":"none",a&&this.activeIds.add(i),a?this._scheduleOcclusionCheck():this.occludedIds.delete(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),this.occludedIds.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(),this.occludedIds.clear()}update(t,e){const i=this.labels.get(t);if(!i){console.warn(`Label with id "${t}" not found for update.`);return}const n=this.themes[i.theme];if(!n){console.warn(`Theme "${i.theme}" not registered.`);return}try{n.createElement(i.el,{id:t,theme:i.theme,data:e},n)}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),this.occludedIds.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),this.occludedIds.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),this.occludedIds.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 n=this.themes[i.theme];if(!n){console.warn(`Theme "${i.theme}" not registered`);return}i.unload=n.createElement(i.el,{id:e,theme:i.theme,data:i.data},n)||{}}catch(n){console.error(`Error creating label element for theme "${i.theme}":`,n);return}i.el.style.display="block",this.activeIds.add(e),this.occludedIds.delete(e)}}this._scheduleOcclusionCheck()}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",this.occludedIds.delete(t))}async toWindowPositionByLonLat(t,e){const i=this.Cesium,n=this.viewer.scene,s=[i.Cartographic.fromDegrees(t,e)];let o;try{o=await n.clampToHeightMostDetailed(s)}catch{console.warn("clampToHeightMostDetailed failed, fallback to ellipsoid height.")}let r=0;o&&o[0]&&o[0].height!=null?r=o[0].height:r=0;const a=i.Cartesian3.fromDegrees(t,e,r);return this.toWindowCoordinates(a)}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 n=parseFloat(i.el.dataset.lon),s=parseFloat(i.el.dataset.lat),o=parseFloat(i.el.dataset.height||"0");if(!this._isValidCoordinate(n,s)){i.el.style.display="none";continue}const r=this.Cesium.Cartesian3.fromDegrees(n,s,o),a=this.toWindowCoordinates(r);if(this.Cesium.defined(a)){const d=((t=this.themes[i.theme].options)==null?void 0:t.offset)||{},u=d.x||0,p=d.y||0,g=this.occludedIds.has(e);i.el.style.left=`${a.x}px`,i.el.style.top=`${a.y}px`,i.el.style.transform=`translate(${u}px, ${p}px)`,i.el.style.display=g?"none":"block"}else i.el.style.display="none"}}_scheduleOcclusionCheck(){if(!this.occlusionOptions.enabled)return;const t=Date.now(),e=Math.max(0,Number(this.occlusionOptions.throttleMs)||0),i=t-this._lastOcclusionAt,n=Math.max(0,e-i);if(n===0){this.runOcclusionCheckNow();return}this._occlusionTimer===null&&(this._occlusionTimer=window.setTimeout(()=>{this._occlusionTimer=null,this.runOcclusionCheckNow()},n))}_pushOcclusionLog(t){this.occlusionLogEnabled&&(this.occlusionCheckLogs.push(t),this.occlusionCheckLogs.length>this.occlusionLogMax&&this.occlusionCheckLogs.splice(0,this.occlusionCheckLogs.length-this.occlusionLogMax))}_computeLabelOccluded(t,e,i,n,s,o){var d,u;const r=(d=this.viewer)==null?void 0:d.scene,a=(u=this.viewer)==null?void 0:u.camera,l=this.Cesium;if(!r||!a||!l)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"runtime-missing"}),!0;if(!r.pickPositionSupported||!i)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-unsupported"}),!0;try{const p=r.pickPosition(i);if(!p||!a.positionWC)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-empty"}),!0;const g=Number(this.occlusionOptions.distanceEpsilon)||0,m=l.Cartesian3.distance(a.positionWC,e),f=l.Cartesian3.distance(a.positionWC,p),y=f+g<m;return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:y,reason:"distance-compare",epsilon:g,labelDistance:m,pickedDistance:f}),y}catch{return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-error"}),!0}}runOcclusionCheckNow(){if(!this.occlusionOptions.enabled){this.occludedIds.clear();return}if(this._occlusionChecking){this._occlusionPending=!0;return}this._occlusionChecking=!0;try{for(const t of this.activeIds){const e=this.labels.get(t);if(!e){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,occluded:!1,reason:"label-missing"});continue}const i=parseFloat(e.el.dataset.lon),n=parseFloat(e.el.dataset.lat),s=parseFloat(e.el.dataset.height||"0");if(!this._isValidCoordinate(i,n)){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:i,lat:n,height:s,occluded:!1,reason:"invalid-coordinate"});continue}const o=this.Cesium.Cartesian3.fromDegrees(i,n,s),r=this.toWindowCoordinates(o);if(!this.Cesium.defined(r)){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:i,lat:n,height:s,occluded:!1,reason:"screen-position-undefined"});continue}this._computeLabelOccluded(t,o,r,i,n,s)?this.occludedIds.add(t):this.occludedIds.delete(t)}}finally{this._lastOcclusionAt=Date.now(),this._occlusionChecking=!1,this._occlusionPending&&(this._occlusionPending=!1,this._scheduleOcclusionCheck())}}setOcclusionEnabled(t){this.occlusionOptions.enabled=!!t,this.occlusionOptions.enabled?this.runOcclusionCheckNow():(this.occludedIds.clear(),this._occlusionTimer!==null&&(clearTimeout(this._occlusionTimer),this._occlusionTimer=null))}getOcclusionOptions(){return{enabled:this.occlusionOptions.enabled,throttleMs:this.occlusionOptions.throttleMs,distanceEpsilon:this.occlusionOptions.distanceEpsilon}}setOcclusionOptions(t){t.throttleMs!=null&&(this.occlusionOptions.throttleMs=Math.max(0,Number(t.throttleMs)||0)),t.distanceEpsilon!=null&&(this.occlusionOptions.distanceEpsilon=Math.max(0,Number(t.distanceEpsilon)||0)),this.occlusionOptions.enabled&&this._scheduleOcclusionCheck()}setOcclusionLogEnabled(t,e=!1){this.occlusionLogEnabled=!!t,e&&(this.occlusionCheckLogs=[])}destroy(){this.viewer.scene.postRender.removeEventListener(this._updateFn),this.viewer.camera.changed.removeEventListener(this._cameraChangedFn),this._occlusionTimer!==null&&(clearTimeout(this._occlusionTimer),this._occlusionTimer=null),this.labels.clear(),this.activeIds.clear(),this.occludedIds.clear()}}class ce{constructor(){c(this,"tooltipEl");c(this,"visible",!1);c(this,"offsetX",10);c(this,"offsetY",-20);c(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 jt{constructor(t,e){c(this,"Cesium");c(this,"viewer");c(this,"handler",null);c(this,"entity",null);c(this,"tooltip",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.tooltip=new ce,this.tooltip.show("左键添加点"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var p,g;const s=i.scene.pickPosition(n.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(o.longitude),a=e.Math.toDegrees(o.latitude),l=o.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:r,lat:a,height:l},clear:()=>{this.clear()}};(p=t.onComplete)==null||p.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 Vt{constructor(t,e){c(this,"Cesium");c(this,"viewer");c(this,"handler",null);c(this,"positions",[]);c(this,"entity",null);c(this,"tooltip",null);c(this,"tempPoints",[]);c(this,"options",null);c(this,"keydownHandler",null);this.Cesium=t,this.viewer=e}getPickPosition(t){var s,o,r,a;const{viewer:e}=this,i=e==null?void 0:e.scene;if(!i||!t)return null;let n=null;try{i.pickPositionSupported&&(n=i.pickPosition(t))}catch(l){console.warn("[LineDrawer] pickPosition failed:",l)}if(!n){const l=(o=(s=e.camera)==null?void 0:s.getPickRay)==null?void 0:o.call(s,t);l&&(n=((a=(r=i.globe)==null?void 0:r.pick)==null?void 0:a.call(r,l,i))||null)}return n}syncEntity(){if(this.entity){if(this.positions.length===0){this.viewer.entities.remove(this.entity),this.entity=null;return}this.entity.polyline.positions=this.positions.slice()}}undoLastPoint(){if(this.positions.length===0)return;this.positions.pop();const t=this.tempPoints.pop();t&&this.viewer.entities.remove(t),this.syncEntity()}finishDrawing(t=!1){var s,o,r;const{Cesium:e}=this;if(t&&this.positions.length>0){this.positions.length=this.positions.length-1;const a=this.tempPoints.pop();a&&this.viewer.entities.remove(a)}if(this.syncEntity(),this.stopDrawing(),(s=this.tooltip)==null||s.hide(),this.tooltip=null,this.positions.length<2)return;const i=this.positions.map(a=>{const l=e.Cartographic.fromCartesian(a);return{lng:e.Math.toDegrees(l.longitude),lat:e.Math.toDegrees(l.latitude),height:l.height}}),n={entity:this.entity,positions:this.positions,lnglats:i,clear:()=>{this.clear()}};(r=(o=this.options)==null?void 0:o.onComplete)==null||r.call(o,n)}bindKeyboardEvents(){this.unbindKeyboardEvents(),this.keydownHandler=t=>{t.key==="Escape"&&(t.preventDefault(),this.finishDrawing(!1))},document.addEventListener("keydown",this.keydownHandler)}unbindKeyboardEvents(){this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}startDrawing(t){const{Cesium:e,viewer:i}=this;this.options=t,this.positions=[],this.tempPoints=[],this.entity=null,this.tooltip=new ce,this.tooltip.show("单击左键添加点,右键撤销,双击左键或 Esc 结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.bindKeyboardEvents(),this.handler.setInputAction(n=>{var r,a;const s=this.getPickPosition(n.position);if(!s)return;this.positions.push(s);const o=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(o),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:((a=(r=t.color)==null?void 0:r.withAlpha)==null?void 0:a.call(r,.5))||e.Color.YELLOW.withAlpha(.5)}})},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{this.undoLastPoint()},e.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(()=>{this.finishDrawing(!0)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;this.unbindKeyboardEvents(),(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.options=null,this.stopDrawing()}}class Wt{constructor(t,e){c(this,"Cesium");c(this,"viewer");c(this,"handler",null);c(this,"startPoint",null);c(this,"endPoint",null);c(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(n=>{var o;const s=i.scene.pickPosition(n.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 r=e.Cartographic.fromCartesian(this.startPoint),a=e.Cartographic.fromCartesian(this.endPoint),l=Math.min(r.longitude,a.longitude),d=Math.max(r.longitude,a.longitude),u=Math.min(r.latitude,a.latitude),p=Math.max(r.latitude,a.latitude);return new e.Rectangle(l,u,d,p)}catch(r){console.warn("Rectangle calculation error:",r);return}},!1),material:t.color||e.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:e.Color.BLACK,disableDepthTestDistance:Number.POSITIVE_INFINITY}});else{this.stopDrawing();const r=e.Cartographic.fromCartesian(this.startPoint),a=e.Cartographic.fromCartesian(this.endPoint),l={lng:e.Math.toDegrees(Math.min(r.longitude,a.longitude)),lat:e.Math.toDegrees(Math.min(r.latitude,a.latitude)),height:0},d={lng:e.Math.toDegrees(Math.max(r.longitude,a.longitude)),lat:e.Math.toDegrees(Math.max(r.latitude,a.latitude)),height:0},u={entity:this.entity,position:this.startPoint,lnglat:{lng:e.Math.toDegrees(r.longitude),lat:e.Math.toDegrees(r.latitude),height:r.height},positions:[this.startPoint,this.endPoint],lnglats:[l,d],clear:()=>{this.clear()}};(o=t.onComplete)==null||o.call(t,u)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{if(!this.startPoint)return;const s=i.scene.pickPosition(n.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 Ut{constructor(t,e){c(this,"viewer");c(this,"Cesium");c(this,"handler",null);c(this,"entity",null);c(this,"positions",[]);c(this,"_isDrawing",!1);c(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],n=this.viewer.camera.getPickRay(e.endPosition),s=this.viewer.scene.globe.pick(n,this.viewer.scene);s&&this.drawPreviewCircle(i,s,t)},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE)}drawPreviewCircle(t,e,i){const n=this.Cesium.Cartesian3.distance(t,e);if(this.entity)Math.abs(this.currentRadius-n)>.5&&(this.currentRadius=n);else{this.currentRadius=n;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,n=this.Cesium.Cartesian3.distance(e,i),s=this.Cesium.Cartographic.fromCartesian(e),o={lng:this.Cesium.Math.toDegrees(s.longitude),lat:this.Cesium.Math.toDegrees(s.latitude),height:s.height},r=(t==null?void 0:t.step)||1,a=[],l=[];for(let p=0;p<360;p+=r){const g=this.Cesium.Math.toRadians(p),m=new this.Cesium.EllipsoidGeodesic;m.setEndPoints(s,new this.Cesium.Cartographic(s.longitude+1e-4*Math.cos(g),s.latitude+1e-4*Math.sin(g)));const f=m.interpolateUsingSurfaceDistance(n),y=this.Cesium.Ellipsoid.WGS84.cartographicToCartesian(f);a.push(y);const v=this.Cesium.Cartographic.fromCartesian(y);l.push({lng:this.Cesium.Math.toDegrees(v.longitude),lat:this.Cesium.Math.toDegrees(v.latitude),height:v.height})}l.push(l[0]);const d=this.positions.map(p=>{const g=this.Cesium.Cartographic.fromCartesian(p);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:a,circleLnglats:l,center:o,radius:n,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 Kt{constructor(t,e){c(this,"Cesium");c(this,"viewer");c(this,"handler",null);c(this,"positions",[]);c(this,"lnglats",[]);c(this,"entity",null);c(this,"tooltip",null);c(this,"tempPoints",[]);c(this,"options",null);c(this,"keydownHandler",null);this.Cesium=t,this.viewer=e}isHelperPick(t){var e;return((e=t==null?void 0:t.id)==null?void 0:e._drawHelper)===!0}withHiddenHelpers(t){const e=[this.entity,...this.tempPoints].filter(Boolean),i=e.map(n=>n.show);e.forEach(n=>{n.show=!1});try{return t()}finally{e.forEach((n,s)=>{n.show=i[s]})}}getPickPosition(t){var r,a,l,d;const{viewer:e}=this,i=e==null?void 0:e.scene;if(!i||!t)return null;let n=null;const s=i.pick(t),o=this.isHelperPick(s);try{i.pickPositionSupported&&(n=o?this.withHiddenHelpers(()=>i.pickPosition(t)):i.pickPosition(t))}catch(u){console.warn("[PolygonDrawer] pickPosition failed:",u)}if(!n){const u=(a=(r=e.camera)==null?void 0:r.getPickRay)==null?void 0:a.call(r,t);u&&(n=((d=(l=i.globe)==null?void 0:l.pick)==null?void 0:d.call(l,u,i))||null)}return n}syncEntity(){this.entity&&this.positions.length===0&&(this.viewer.entities.remove(this.entity),this.entity=null)}undoLastPoint(){if(this.positions.length===0)return;this.positions.pop(),this.lnglats.pop();const t=this.tempPoints.pop();t&&this.viewer.entities.remove(t),this.syncEntity()}finishDrawing(t=!1){var i,n,s;if(t&&this.positions.length>0){this.positions.length=this.positions.length-1,this.lnglats.length=this.lnglats.length-1;const o=this.tempPoints.pop();o&&this.viewer.entities.remove(o)}if(this.syncEntity(),this.stopDrawing(),(i=this.tooltip)==null||i.hide(),this.tooltip=null,this.positions.length<3)return;const e={entity:this.entity,positions:this.positions,lnglats:this.lnglats.slice(),clear:()=>{this.clear()}};(s=(n=this.options)==null?void 0:n.onComplete)==null||s.call(n,e)}bindKeyboardEvents(){this.unbindKeyboardEvents(),this.keydownHandler=t=>{t.key==="Escape"&&(t.preventDefault(),this.finishDrawing(!1))},document.addEventListener("keydown",this.keydownHandler)}unbindKeyboardEvents(){this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}startDrawing(t){const{Cesium:e,viewer:i}=this;this.options=t,this.positions=[],this.lnglats=[],this.tempPoints=[],this.entity=null,this.tooltip=new ce,this.tooltip.show("单击左键添加点,右键撤销,双击左键或 Esc 结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.bindKeyboardEvents(),this.handler.setInputAction(n=>{const s=this.getPickPosition(n.position);if(!s)return;this.positions.push(s);const o=e.Cartographic.fromCartesian(s);this.lnglats.push({lng:e.Math.toDegrees(o.longitude),lat:e.Math.toDegrees(o.latitude),height:Number.isFinite(o.height)?o.height:0});const r=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});r._drawHelper=!0,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)}}),this.entity._drawHelper=!0)},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{this.undoLastPoint()},e.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(()=>{this.finishDrawing(!0)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;this.unbindKeyboardEvents(),(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.lnglats=[],this.options=null,this.stopDrawing()}}class Xt{constructor(t,e){c(this,"viewer");c(this,"Cesium");c(this,"activeDrawer",null);this.viewer=e,this.Cesium=t}draw(t,e){var i;switch(this.clear(),t){case"point":this.activeDrawer=new jt(this.Cesium,this.viewer);break;case"line":this.activeDrawer=new Vt(this.Cesium,this.viewer);break;case"rectangle":this.activeDrawer=new Wt(this.Cesium,this.viewer);break;case"circle":this.activeDrawer=new Ut(this.Cesium,this.viewer);break;case"polygon":this.activeDrawer=new Kt(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 rt=typeof global=="object"&&global&&global.Object===Object&&global,qt=typeof self=="object"&&self&&self.Object===Object&&self,se=rt||qt||Function("return this")(),ge=se.Symbol,at=Object.prototype,Zt=at.hasOwnProperty,Jt=at.toString,Pe=ge?ge.toStringTag:void 0;function Qt(h){var t=Zt.call(h,Pe),e=h[Pe];try{h[Pe]=void 0;var i=!0}catch{}var n=Jt.call(h);return i&&(t?h[Pe]=e:delete h[Pe]),n}var ei=Object.prototype,ti=ei.toString;function ii(h){return ti.call(h)}var si="[object Null]",ni="[object Undefined]",lt=ge?ge.toStringTag:void 0;function Le(h){return h==null?h===void 0?ni:si:lt&< in Object(h)?Qt(h):ii(h)}function Ee(h){return h!=null&&typeof h=="object"}var Me=Array.isArray;function ke(h){var t=typeof h;return h!=null&&(t=="object"||t=="function")}var oi="[object AsyncFunction]",ri="[object Function]",ai="[object GeneratorFunction]",li="[object Proxy]";function ht(h){if(!ke(h))return!1;var t=Le(h);return t==ri||t==ai||t==oi||t==li}var Be=se["__core-js_shared__"],ct=(function(){var h=/[^.]+$/.exec(Be&&Be.keys&&Be.keys.IE_PROTO||"");return h?"Symbol(src)_1."+h:""})();function hi(h){return!!ct&&ct in h}var ci=Function.prototype,di=ci.toString;function de(h){if(h!=null){try{return di.call(h)}catch{}try{return h+""}catch{}}return""}var ui=/[\\^$.*+?()[\]{}|]/g,pi=/^\[object .+?Constructor\]$/,mi=Function.prototype,gi=Object.prototype,fi=mi.toString,yi=gi.hasOwnProperty,wi=RegExp("^"+fi.call(yi).replace(ui,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function vi(h){if(!ke(h)||hi(h))return!1;var t=ht(h)?wi:pi;return t.test(de(h))}function Ci(h,t){return h==null?void 0:h[t]}function ue(h,t){var e=Ci(h,t);return vi(e)?e:void 0}var Ye=ue(se,"WeakMap"),dt=Object.create,bi=(function(){function h(){}return function(t){if(!ke(t))return{};if(dt)return dt(t);h.prototype=t;var e=new h;return h.prototype=void 0,e}})(),ut=(function(){try{var h=ue(Object,"defineProperty");return h({},"",{}),h}catch{}})();function Pi(h,t){for(var e=-1,i=h==null?0:h.length;++e<i&&t(h[e],e,h)!==!1;);return h}var Li=9007199254740991,Ei=/^(?:0|[1-9]\d*)$/;function Mi(h,t){var e=typeof h;return t=t??Li,!!t&&(e=="number"||e!="symbol"&&Ei.test(h))&&h>-1&&h%1==0&&h<t}function Ii(h,t,e){t=="__proto__"&&ut?ut(h,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):h[t]=e}function pt(h,t){return h===t||h!==h&&t!==t}var xi=Object.prototype,Ti=xi.hasOwnProperty;function _i(h,t,e){var i=h[t];(!(Ti.call(h,t)&&pt(i,e))||e===void 0&&!(t in h))&&Ii(h,t,e)}var Di=9007199254740991;function mt(h){return typeof h=="number"&&h>-1&&h%1==0&&h<=Di}function Si(h){return h!=null&&mt(h.length)&&!ht(h)}var Ai=Object.prototype;function gt(h){var t=h&&h.constructor,e=typeof t=="function"&&t.prototype||Ai;return h===e}function ki(h,t){for(var e=-1,i=Array(h);++e<h;)i[e]=t(e);return i}var $i="[object Arguments]";function ft(h){return Ee(h)&&Le(h)==$i}var yt=Object.prototype,Ri=yt.hasOwnProperty,Oi=yt.propertyIsEnumerable,Hi=ft((function(){return arguments})())?ft:function(h){return Ee(h)&&Ri.call(h,"callee")&&!Oi.call(h,"callee")};function Fi(){return!1}var wt=typeof _=="object"&&_&&!_.nodeType&&_,vt=wt&&typeof module=="object"&&module&&!module.nodeType&&module,zi=vt&&vt.exports===wt,Ct=zi?se.Buffer:void 0,Ni=Ct?Ct.isBuffer:void 0,bt=Ni||Fi,Gi="[object Arguments]",Bi="[object Array]",Yi="[object Boolean]",ji="[object Date]",Vi="[object Error]",Wi="[object Function]",Ui="[object Map]",Ki="[object Number]",Xi="[object Object]",qi="[object RegExp]",Zi="[object Set]",Ji="[object String]",Qi="[object WeakMap]",es="[object ArrayBuffer]",ts="[object DataView]",is="[object Float32Array]",ss="[object Float64Array]",ns="[object Int8Array]",os="[object Int16Array]",rs="[object Int32Array]",as="[object Uint8Array]",ls="[object Uint8ClampedArray]",hs="[object Uint16Array]",cs="[object Uint32Array]",z={};z[is]=z[ss]=z[ns]=z[os]=z[rs]=z[as]=z[ls]=z[hs]=z[cs]=!0,z[Gi]=z[Bi]=z[es]=z[Yi]=z[ts]=z[ji]=z[Vi]=z[Wi]=z[Ui]=z[Ki]=z[Xi]=z[qi]=z[Zi]=z[Ji]=z[Qi]=!1;function ds(h){return Ee(h)&&mt(h.length)&&!!z[Le(h)]}function je(h){return function(t){return h(t)}}var Pt=typeof _=="object"&&_&&!_.nodeType&&_,Ie=Pt&&typeof module=="object"&&module&&!module.nodeType&&module,us=Ie&&Ie.exports===Pt,Ve=us&&rt.process,fe=(function(){try{var h=Ie&&Ie.require&&Ie.require("util").types;return h||Ve&&Ve.binding&&Ve.binding("util")}catch{}})(),Lt=fe&&fe.isTypedArray,ps=Lt?je(Lt):ds,ms=Object.prototype,gs=ms.hasOwnProperty;function fs(h,t){var e=Me(h),i=!e&&Hi(h),n=!e&&!i&&bt(h),s=!e&&!i&&!n&&ps(h),o=e||i||n||s,r=o?ki(h.length,String):[],a=r.length;for(var l in h)gs.call(h,l)&&!(o&&(l=="length"||n&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Mi(l,a)))&&r.push(l);return r}function Et(h,t){return function(e){return h(t(e))}}var ys=Et(Object.keys,Object),ws=Object.prototype,vs=ws.hasOwnProperty;function Cs(h){if(!gt(h))return ys(h);var t=[];for(var e in Object(h))vs.call(h,e)&&e!="constructor"&&t.push(e);return t}function bs(h){return Si(h)?fs(h):Cs(h)}var xe=ue(Object,"create");function Ps(){this.__data__=xe?xe(null):{},this.size=0}function Ls(h){var t=this.has(h)&&delete this.__data__[h];return this.size-=t?1:0,t}var Es="__lodash_hash_undefined__",Ms=Object.prototype,Is=Ms.hasOwnProperty;function xs(h){var t=this.__data__;if(xe){var e=t[h];return e===Es?void 0:e}return Is.call(t,h)?t[h]:void 0}var Ts=Object.prototype,_s=Ts.hasOwnProperty;function Ds(h){var t=this.__data__;return xe?t[h]!==void 0:_s.call(t,h)}var Ss="__lodash_hash_undefined__";function As(h,t){var e=this.__data__;return this.size+=this.has(h)?0:1,e[h]=xe&&t===void 0?Ss:t,this}function pe(h){var t=-1,e=h==null?0:h.length;for(this.clear();++t<e;){var i=h[t];this.set(i[0],i[1])}}pe.prototype.clear=Ps,pe.prototype.delete=Ls,pe.prototype.get=xs,pe.prototype.has=Ds,pe.prototype.set=As;function ks(){this.__data__=[],this.size=0}function $e(h,t){for(var e=h.length;e--;)if(pt(h[e][0],t))return e;return-1}var $s=Array.prototype,Rs=$s.splice;function Os(h){var t=this.__data__,e=$e(t,h);if(e<0)return!1;var i=t.length-1;return e==i?t.pop():Rs.call(t,e,1),--this.size,!0}function Hs(h){var t=this.__data__,e=$e(t,h);return e<0?void 0:t[e][1]}function Fs(h){return $e(this.__data__,h)>-1}function zs(h,t){var e=this.__data__,i=$e(e,h);return i<0?(++this.size,e.push([h,t])):e[i][1]=t,this}function oe(h){var t=-1,e=h==null?0:h.length;for(this.clear();++t<e;){var i=h[t];this.set(i[0],i[1])}}oe.prototype.clear=ks,oe.prototype.delete=Os,oe.prototype.get=Hs,oe.prototype.has=Fs,oe.prototype.set=zs;var Te=ue(se,"Map");function Ns(){this.size=0,this.__data__={hash:new pe,map:new(Te||oe),string:new pe}}function Gs(h){var t=typeof h;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?h!=="__proto__":h===null}function Re(h,t){var e=h.__data__;return Gs(t)?e[typeof t=="string"?"string":"hash"]:e.map}function Bs(h){var t=Re(this,h).delete(h);return this.size-=t?1:0,t}function Ys(h){return Re(this,h).get(h)}function js(h){return Re(this,h).has(h)}function Vs(h,t){var e=Re(this,h),i=e.size;return e.set(h,t),this.size+=e.size==i?0:1,this}function ye(h){var t=-1,e=h==null?0:h.length;for(this.clear();++t<e;){var i=h[t];this.set(i[0],i[1])}}ye.prototype.clear=Ns,ye.prototype.delete=Bs,ye.prototype.get=Ys,ye.prototype.has=js,ye.prototype.set=Vs;function Ws(h,t){for(var e=-1,i=t.length,n=h.length;++e<i;)h[n+e]=t[e];return h}var Us=Et(Object.getPrototypeOf,Object);function Ks(){this.__data__=new oe,this.size=0}function Xs(h){var t=this.__data__,e=t.delete(h);return this.size=t.size,e}function qs(h){return this.__data__.get(h)}function Zs(h){return this.__data__.has(h)}var Js=200;function Qs(h,t){var e=this.__data__;if(e instanceof oe){var i=e.__data__;if(!Te||i.length<Js-1)return i.push([h,t]),this.size=++e.size,this;e=this.__data__=new ye(i)}return e.set(h,t),this.size=e.size,this}function we(h){var t=this.__data__=new oe(h);this.size=t.size}we.prototype.clear=Ks,we.prototype.delete=Xs,we.prototype.get=qs,we.prototype.has=Zs,we.prototype.set=Qs;var Mt=typeof _=="object"&&_&&!_.nodeType&&_,It=Mt&&typeof module=="object"&&module&&!module.nodeType&&module,en=It&&It.exports===Mt,xt=en?se.Buffer:void 0;xt&&xt.allocUnsafe;function tn(h,t){return h.slice()}function sn(h,t){for(var e=-1,i=h==null?0:h.length,n=0,s=[];++e<i;){var o=h[e];t(o,e,h)&&(s[n++]=o)}return s}function nn(){return[]}var on=Object.prototype,rn=on.propertyIsEnumerable,Tt=Object.getOwnPropertySymbols,an=Tt?function(h){return h==null?[]:(h=Object(h),sn(Tt(h),function(t){return rn.call(h,t)}))}:nn;function ln(h,t,e){var i=t(h);return Me(h)?i:Ws(i,e(h))}function hn(h){return ln(h,bs,an)}var We=ue(se,"DataView"),Ue=ue(se,"Promise"),Ke=ue(se,"Set"),_t="[object Map]",cn="[object Object]",Dt="[object Promise]",St="[object Set]",At="[object WeakMap]",kt="[object DataView]",dn=de(We),un=de(Te),pn=de(Ue),mn=de(Ke),gn=de(Ye),re=Le;(We&&re(new We(new ArrayBuffer(1)))!=kt||Te&&re(new Te)!=_t||Ue&&re(Ue.resolve())!=Dt||Ke&&re(new Ke)!=St||Ye&&re(new Ye)!=At)&&(re=function(h){var t=Le(h),e=t==cn?h.constructor:void 0,i=e?de(e):"";if(i)switch(i){case dn:return kt;case un:return _t;case pn:return Dt;case mn:return St;case gn:return At}return t});var fn=Object.prototype,yn=fn.hasOwnProperty;function wn(h){var t=h.length,e=new h.constructor(t);return t&&typeof h[0]=="string"&&yn.call(h,"index")&&(e.index=h.index,e.input=h.input),e}var $t=se.Uint8Array;function Xe(h){var t=new h.constructor(h.byteLength);return new $t(t).set(new $t(h)),t}function vn(h,t){var e=Xe(h.buffer);return new h.constructor(e,h.byteOffset,h.byteLength)}var Cn=/\w*$/;function bn(h){var t=new h.constructor(h.source,Cn.exec(h));return t.lastIndex=h.lastIndex,t}var Rt=ge?ge.prototype:void 0,Ot=Rt?Rt.valueOf:void 0;function Pn(h){return Ot?Object(Ot.call(h)):{}}function Ln(h,t){var e=Xe(h.buffer);return new h.constructor(e,h.byteOffset,h.length)}var En="[object Boolean]",Mn="[object Date]",In="[object Map]",xn="[object Number]",Tn="[object RegExp]",_n="[object Set]",Dn="[object String]",Sn="[object Symbol]",An="[object ArrayBuffer]",kn="[object DataView]",$n="[object Float32Array]",Rn="[object Float64Array]",On="[object Int8Array]",Hn="[object Int16Array]",Fn="[object Int32Array]",zn="[object Uint8Array]",Nn="[object Uint8ClampedArray]",Gn="[object Uint16Array]",Bn="[object Uint32Array]";function Yn(h,t,e){var i=h.constructor;switch(t){case An:return Xe(h);case En:case Mn:return new i(+h);case kn:return vn(h);case $n:case Rn:case On:case Hn:case Fn:case zn:case Nn:case Gn:case Bn:return Ln(h);case In:return new i;case xn:case Dn:return new i(h);case Tn:return bn(h);case _n:return new i;case Sn:return Pn(h)}}function jn(h){return typeof h.constructor=="function"&&!gt(h)?bi(Us(h)):{}}var Vn="[object Map]";function Wn(h){return Ee(h)&&re(h)==Vn}var Ht=fe&&fe.isMap,Un=Ht?je(Ht):Wn,Kn="[object Set]";function Xn(h){return Ee(h)&&re(h)==Kn}var Ft=fe&&fe.isSet,qn=Ft?je(Ft):Xn,zt="[object Arguments]",Zn="[object Array]",Jn="[object Boolean]",Qn="[object Date]",eo="[object Error]",Nt="[object Function]",to="[object GeneratorFunction]",io="[object Map]",so="[object Number]",Gt="[object Object]",no="[object RegExp]",oo="[object Set]",ro="[object String]",ao="[object Symbol]",lo="[object WeakMap]",ho="[object ArrayBuffer]",co="[object DataView]",uo="[object Float32Array]",po="[object Float64Array]",mo="[object Int8Array]",go="[object Int16Array]",fo="[object Int32Array]",yo="[object Uint8Array]",wo="[object Uint8ClampedArray]",vo="[object Uint16Array]",Co="[object Uint32Array]",F={};F[zt]=F[Zn]=F[ho]=F[co]=F[Jn]=F[Qn]=F[uo]=F[po]=F[mo]=F[go]=F[fo]=F[io]=F[so]=F[Gt]=F[no]=F[oo]=F[ro]=F[ao]=F[yo]=F[wo]=F[vo]=F[Co]=!0,F[eo]=F[Nt]=F[lo]=!1;function Oe(h,t,e,i,n,s){var o;if(o!==void 0)return o;if(!ke(h))return h;var r=Me(h);if(r)o=wn(h);else{var a=re(h),l=a==Nt||a==to;if(bt(h))return tn(h);if(a==Gt||a==zt||l&&!n)o=l?{}:jn(h);else{if(!F[a])return n?h:{};o=Yn(h,a)}}s||(s=new we);var d=s.get(h);if(d)return d;s.set(h,o),qn(h)?h.forEach(function(g){o.add(Oe(g,t,e,g,h,s))}):Un(h)&&h.forEach(function(g,m){o.set(m,Oe(g,t,e,m,h,s))});var u=hn,p=r?void 0:u(h);return Pi(p||h,function(g,m){p&&(m=g,g=h[m]),_i(o,m,Oe(g,t,e,m,h,s))}),o}var bo=1,Po=4;function He(h){return Oe(h,bo|Po)}var Bt=(h=>(h.Rotate="rotate",h.Move="move",h.Scale="scale",h.MoveHeight="moveHeight",h.Empty="",h))(Bt||{}),Yt=(h=>(h.Scale="addScale",h.Rotate="rotate",h.Translation="translation",h.Remove="removeById",h.Add="add",h))(Yt||{});class Lo{constructor(t){c(this,"primitives",new Map);c(this,"eventListener",new Map);c(this,"Cesium");c(this,"viewer");c(this,"handler");c(this,"rotationRing");c(this,"moveAxis");c(this,"translationSquare");c(this,"heightArrow");c(this,"scaleHandle");c(this,"scaleCenterProxy");c(this,"editMode","");c(this,"dragEndCallbackMap",new Map);c(this,"activeModelId","");c(this,"activeModelVisualState",new Map);c(this,"overlayContainer",null);c(this,"modeToolbarEl",null);c(this,"feedbackLabelEl",null);c(this,"overlayUpdateFn",null);c(this,"feedbackAnchor",null);c(this,"tooltipManager",null);c(this,"tooltipHideTimer",null);c(this,"scaleCenterHintVisible",!1);this.Cesium=t.Cesium,this.viewer=t.viewer,this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.initOverlay(),typeof document<"u"&&(this.tooltipManager=new ce)}isSceneGadgetDebugEnabled(){var t;if(typeof window>"u")return!1;try{return window.__SCENE_GADGET_DEBUG__===!0||((t=window.localStorage)==null?void 0:t.getItem("sceneGadgetDebug"))==="1"}catch{return!1}}debugLog(t,e){this.isSceneGadgetDebugEnabled()&&console.log("[SceneGadget][GLTFManage]",t,e||{})}getPickDebugId(t){var i,n,s;if(!t)return null;const e=(t==null?void 0:t.id)||((i=t==null?void 0:t.primitive)==null?void 0:i.id)||null;return typeof e=="string"?e:e&&typeof(e==null?void 0:e.id)=="string"?e.id:e&&typeof(e==null?void 0:e.name)=="string"?e.name:(s=(n=t==null?void 0:t.primitive)==null?void 0:n.constructor)!=null&&s.name?`[primitive:${t.primitive.constructor.name}]`:String(e)}debugPickStack(t,e){var n;if(!this.isSceneGadgetDebugEnabled())return;const i=(n=this.viewer)==null?void 0:n.scene;if(!(!(i!=null&&i.drillPick)||!t))try{const s=i.drillPick(t,12)||[];this.debugLog("pick-stack",{mode:e,activeModelId:this.activeModelId,stack:s.map((o,r)=>({index:r,id:this.getPickDebugId(o)}))})}catch(s){this.debugLog("pick-stack:error",{mode:e,message:s instanceof Error?s.message:String(s)})}}showModeHint(t,e=2200){!this.tooltipManager||!t||(this.scaleCenterHintVisible=!0,this.tooltipManager.show(t),this.tooltipHideTimer&&clearTimeout(this.tooltipHideTimer),this.tooltipHideTimer=setTimeout(()=>{this.hideModeHint()},e))}showHoverModeHint(t){!this.tooltipManager||!t||(this.tooltipHideTimer&&(clearTimeout(this.tooltipHideTimer),this.tooltipHideTimer=null),this.tooltipManager.show(t),this.scaleCenterHintVisible=!0)}hideModeHint(){var t;this.tooltipHideTimer&&(clearTimeout(this.tooltipHideTimer),this.tooltipHideTimer=null),(t=this.tooltipManager)==null||t.hide(),this.scaleCenterHintVisible=!1}init(t,e=!1){const i=this.viewer;this.primitives.forEach(n=>{i.scene.primitives.remove(n)}),t.forEach(n=>{this.primitives.has(n.id)||this.add(n,e)})}get(t){return this.primitives.get(t)}async add(t,e=!0){var g,m,f,y,v;const i=this.viewer,n=this.Cesium,s=n.Math.toRadians(((g=t.headingPitchRoll)==null?void 0:g.heading)||0),o=n.Math.toRadians(((m=t.headingPitchRoll)==null?void 0:m.pitch)||0),r=n.Math.toRadians(((f=t.headingPitchRoll)==null?void 0:f.roll)||0),a=new n.HeadingPitchRoll(s,o,r);let l=t.position;if(Me(l)?l=n.Cartesian3.fromDegrees(l[0],l[1],l[2]||0):l&&typeof l=="object"&&typeof l.lng<"u"&&typeof l.lat<"u"&&(l=n.Cartesian3.fromDegrees(l.lng,l.lat,l.height||0)),!l)throw new Error("GLTFManage.add 缺少有效 position");const d=this.composeModelMatrix(l,a,t.scale),u={id:t.id,...t.model,modelMatrix:d};let p;if(typeof((y=n==null?void 0:n.Model)==null?void 0:y.fromGltf)=="function")p=i.scene.primitives.add(n.Model.fromGltf(u));else if(typeof((v=n==null?void 0:n.Model)==null?void 0:v.fromGltfAsync)=="function"){const w=await n.Model.fromGltfAsync(u);p=i.scene.primitives.add(w)}else throw new Error("Cesium.Model.fromGltf / fromGltfAsync 均不可用");p.scale=1,p.__sceneGadgetScale=this.getPrimitiveScale({modelMatrix:d}),this.initializePrimitiveRuntimeState(p),this.primitives.set(t.id,p),p.show=e,this.runEventListener("add",{info:t,gltf:p})}flyTo(t){const e=this.viewer;let i=this.primitives.get(t);const n=this.Cesium,s=this.getPrimitiveWorldBoundingSphere(i);s&&e.camera.flyToBoundingSphere(s,{duration:1.5,offset:new n.HeadingPitchRange(0,-.5,Math.max(s.radius*2.8,60))})}removeById(t){const e=this.viewer;let i=this.primitives.get(t);if(!i){console.error(`No model found with id: ${t}`);return}this.activeModelId===t&&this.deactivateEdit(),e.scene.primitives.remove(i),this.primitives.delete(t),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);if(i){const n=this.getPrimitiveScale(i),s={x:n.x+e,y:n.y+e,z:n.z+e};this.applyScaleToPrimitive(i,s),this.activeModelId===t.id?this.refreshActiveToolGeometry():this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t.id,scale:s})}}setScale(t,e=.1){let i=this.primitives.get(t);if(i){const n={x:e,y:e,z:e};this.applyScaleToPrimitive(i,n),this.activeModelId===t?this.refreshActiveToolGeometry():this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t,scale:n})}}setEditMode(t){this.editMode=t,this.updateToolbarState()}normalizeScaleVector(t){const e=this.Cesium;if(typeof t=="number"){const i=Number(t||1);return new e.Cartesian3(i,i,i)}return new e.Cartesian3(Number((t==null?void 0:t.x)??1),Number((t==null?void 0:t.y)??1),Number((t==null?void 0:t.z)??1))}getPrimitiveScale(t){const e=this.Cesium;if(!t)return{x:1,y:1,z:1};if(t.__sceneGadgetScale)return{x:Number(t.__sceneGadgetScale.x??1),y:Number(t.__sceneGadgetScale.y??1),z:Number(t.__sceneGadgetScale.z??1)};const i=e.Matrix4.getScale(t.modelMatrix,new e.Cartesian3);return{x:Number(i.x||1),y:Number(i.y||1),z:Number(i.z||1)}}initializePrimitiveRuntimeState(t){var i,n;if(!t)return;const e=()=>{const s=this.getPrimitiveRuntimeRadius(t);s>0&&(t.__sceneGadgetRuntimeRadiusReady=!0,this.cachePrimitiveUnitRadius(t,s))};if(e(),!t.__sceneGadgetRuntimeRadiusReady&&typeof((i=t==null?void 0:t.readyPromise)==null?void 0:i.then)=="function"){t.readyPromise.then(()=>{e()}).catch(()=>{});return}!t.__sceneGadgetRuntimeRadiusReady&&typeof((n=t==null?void 0:t.readyEvent)==null?void 0:n.addEventListener)=="function"&&t.readyEvent.addEventListener(()=>{e()})}getPrimitiveRuntimeRadius(t){var e;if(!t)return 0;try{const i=Number(((e=t==null?void 0:t.boundingSphere)==null?void 0:e.radius)||0);if(Number.isFinite(i)&&i>0)return i}catch{return 0}return 0}cachePrimitiveUnitRadius(t,e){if(!t)return 0;const i=Number(t.__sceneGadgetUnitRadius||0);if(Number.isFinite(i)&&i>0)return i;const n=Number(e||this.getPrimitiveRuntimeRadius(t)||0);if(!Number.isFinite(n)||n<=0)return 0;const s=this.getPrimitiveScale(t),o=Math.max(Math.abs(Number(s.x||1)),Math.abs(Number(s.y||1)),Math.abs(Number(s.z||1)),1),r=n/o;return t.__sceneGadgetUnitRadius=r,r}getPrimitiveFallbackRadius(t){if(!t)return 1;const e=this.getPrimitiveScale(t);return Math.max(Math.abs(Number(e.x||1)),Math.abs(Number(e.y||1)),Math.abs(Number(e.z||1)),1)}getPrimitiveEffectiveRadius(t){const e=this.cachePrimitiveUnitRadius(t);if(e>0){const i=this.getPrimitiveScale(t),n=Math.max(Math.abs(Number(i.x||1)),Math.abs(Number(i.y||1)),Math.abs(Number(i.z||1)),1);return Math.max(e*n,e,1)}return Math.max(this.getPrimitiveRuntimeRadius(t),this.getPrimitiveFallbackRadius(t),1)}getPrimitiveWorldBoundingSphere(t){const e=this.Cesium;if(!(t!=null&&t.modelMatrix))return null;const i=e.Matrix4.getTranslation(t.modelMatrix,new e.Cartesian3),n=this.getPrimitiveEffectiveRadius(t);return!Number.isFinite(n)||n<=0?null:new e.BoundingSphere(i,n)}extractModelBaseMatrix(t){const e=this.Cesium,i=e.Matrix4.getScale(t,new e.Cartesian3),n=new e.Cartesian3(Math.abs(i.x)<1e-6?1:1/i.x,Math.abs(i.y)<1e-6?1:1/i.y,Math.abs(i.z)<1e-6?1:1/i.z);return e.Matrix4.multiply(t,e.Matrix4.fromScale(n),new e.Matrix4)}composeModelMatrix(t,e,i){const n=this.Cesium,s=n.Transforms.headingPitchRollToFixedFrame(t,e,this.viewer.scene.globe.ellipsoid,n.Transforms.eastNorthUpToFixedFrame,new n.Matrix4);return n.Matrix4.multiply(s,n.Matrix4.fromScale(this.normalizeScaleVector(i)),new n.Matrix4)}applyScaleToPrimitive(t,e,i){const n=this.Cesium,s=this.getPrimitiveScale(t),o=this.getPrimitiveRuntimeRadius(t),r=this.getPrimitiveEffectiveRadius(t),a=this.cachePrimitiveUnitRadius(t,o),l=this.normalizeScaleVector(e),d=i||this.extractModelBaseMatrix(t.modelMatrix);t.__sceneGadgetScale={x:l.x,y:l.y,z:l.z},t.scale=1,t.modelMatrix=n.Matrix4.multiply(d,n.Matrix4.fromScale(l),new n.Matrix4);const u=this.getPrimitiveScale(t),p=this.getPrimitiveRuntimeRadius(t),g=this.getPrimitiveEffectiveRadius(t);return this.debugLog("applyScaleToPrimitive",{id:t==null?void 0:t.id,inputScale:e,unitRadius:a,beforeScale:s,afterScale:u,beforeRadius:o,afterRadius:p,beforeEffectiveRadius:r,afterEffectiveRadius:g}),t.modelMatrix}getGizmoModelMatrix(t){return this.extractModelBaseMatrix(t.modelMatrix)}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,n=e.latitude-t.latitude;return Math.atan2(n,i)}getModelHeadingPitchRoll(t){const e=this.Cesium,i=this.viewer,n=this.extractModelBaseMatrix(t),s=e.Transforms.eastNorthUpToFixedFrame(e.Matrix4.getTranslation(n,new e.Cartesian3),i.scene.globe.ellipsoid,new e.Matrix4),o=e.Matrix4.multiply(e.Matrix4.inverse(s,new e.Matrix4),n,new e.Matrix4),r=e.Matrix4.getRotation(o,new e.Matrix3),a=e.Quaternion.fromRotationMatrix(r);return e.HeadingPitchRoll.fromQuaternion(a)}addEventListener(t,e,i){let n={f:e,options:i};return this.eventListener.get(t)?(this.eventListener.get(t)||[]).push(n):this.eventListener.set(t,[n]),n}removeEventListener(t,e){let i=this.eventListener.get(t);if(!i)return console.error("key不存在");let n=i.findIndex(s=>s==e);n>=0?i.splice(n,1):console.error("instantiation不存在")}runEventListener(t,e){let i=this.eventListener.get(t);return i?(i.forEach(n=>{typeof n.f=="function"&&n.f(e)}),!0):!1}initEditBox(t){const e=this.Cesium,i=this.viewer,n=i.scene;let s=null,o=null,r=null,a=null,l="",d="",u=null,p=null,g=null,m=null;const f=()=>{s=null,o=null,r=null,a=null,l="",d="",u=null,p=null,g=null,m=null,this.hideFeedback(),this.unlockCamera()},y=P=>{const b=C=>(P.split(C)[1]||"").split("_");if(P.includes("moveAxis_")){const C=b("moveAxis_");return{modelId:C[0],mode:"move",axis:String(C[1]||"").toUpperCase()}}if(P.includes("translationPlane_")){const C=b("translationPlane_");return{modelId:C[0],mode:"move",axis:String(C[1]||"").toUpperCase()}}if(P.includes("rotationArc_")){const C=b("rotationArc_");return{modelId:C[0],mode:"rotate",axis:String(C[1]||"").toUpperCase()}}if(P.includes("rotationSector_")){const C=b("rotationSector_");return{modelId:C[0],mode:"rotate",axis:String(C[1]||"").toUpperCase()}}if(P.includes("scaleHandle_")){const C=b("scaleHandle_");return{modelId:C[0],mode:"scale",axis:String(C[1]||"").toUpperCase()}}if(P.includes("scaleAxis_")){const C=b("scaleAxis_");return{modelId:C[0],mode:"scale",axis:String(C[1]||"").toUpperCase()}}return P.includes("scaleCenter_")?{modelId:b("scaleCenter_")[0],mode:"scale",axis:"CENTER"}:P.includes("scaleCenterHit_")?{modelId:b("scaleCenterHit_")[0],mode:"scale",axis:"CENTER"}:null},v=P=>{if(this.editMode!=="scale"||!this.activeModelId||!P||!(n!=null&&n.drillPick))return!1;try{return(n.drillPick(P,12)||[]).some(C=>{const E=this.getPickDebugId(C);if(typeof E!="string")return!1;const L=y(E);return(L==null?void 0:L.mode)==="scale"&&(L==null?void 0:L.axis)==="CENTER"&&(L==null?void 0:L.modelId)===this.activeModelId})}catch{return!1}},w=(P,b,C,E)=>{if(s=this.primitives.get(P),s){l=C,d=E,o=e.Matrix4.clone(s.modelMatrix),a=this.normalizeScaleVector(this.getPrimitiveScale(s));const L=e.Matrix4.getTranslation(o,new e.Cartesian3);g=e.Cartesian3.clone(L),r=e.Cartesian2.clone(b.position||b.endPosition,new e.Cartesian2);const M=e.Transforms.eastNorthUpToFixedFrame(g);let I=new e.Cartesian3;C==="move"?E==="XY"?e.Matrix4.getColumn(M,2,I):E==="YZ"?e.Matrix4.getColumn(M,0,I):E==="ZX"?e.Matrix4.getColumn(M,1,I):I=e.Cartesian3.clone(i.scene.camera.direction):C==="rotate"?(E==="X"&&e.Matrix4.getColumn(M,0,I),E==="Y"&&e.Matrix4.getColumn(M,1,I),E==="Z"&&e.Matrix4.getColumn(M,2,I)):I=e.Cartesian3.clone(i.scene.camera.direction),e.Cartesian3.normalize(I,I),u=e.Plane.fromPointNormal(g,I);const x=i.camera.getPickRay(b.position||b.endPosition);p=x&&u?e.IntersectionTests.rayPlane(x,u):null,p&&(m=e.Cartesian3.subtract(p,g,new e.Cartesian3),e.Cartesian3.magnitudeSquared(m)>0&&e.Cartesian3.normalize(m,m)),this.lockCamera()}};this.handler.setInputAction(P=>{var M,I;if(!t())return;(this.editMode==="scale"||this.editMode==="move")&&this.debugPickStack(P.position,this.editMode);const C=n.pick(P.position),E=(C==null?void 0:C.id)||((M=C==null?void 0:C.primitive)==null?void 0:M.id);if(typeof E!="string"){this.editMode==="scale"&&this.debugLog("scale:leftDown:miss",{activeModelId:this.activeModelId,pickedPrimitiveId:(I=C==null?void 0:C.primitive)==null?void 0:I.id,pickedId:C==null?void 0:C.id});return}let L=y(E);this.editMode==="scale"&&this.debugLog("scale:leftDown:hit",{activeModelId:this.activeModelId,hitId:E,hitInfo:L}),L!=null&&L.modelId&&(this.setEditMode(L.mode),w(L.modelId,P,L.mode,L.axis),L.mode==="scale"&&L.axis==="CENTER"&&this.debugLog("scale:center:drag-start",{modelId:L.modelId,startMousePosition:P.position}))},e.ScreenSpaceEventType.LEFT_DOWN),this.handler.setInputAction(P=>{if(t()&&(l===""?v(P.endPosition)?this.showHoverModeHint("向上拖放大,向下拖缩小"):this.scaleCenterHintVisible&&this.hideModeHint():this.scaleCenterHintVisible&&this.hideModeHint(),l!=""&&s&&u&&g&&p)){const C=i.camera.getPickRay(P.endPosition),E=C?e.IntersectionTests.rayPlane(C,u):null;if(!E)return;l==="rotate"?this.rotateModel(s,o,d,g,m,E):l==="move"?this.moveModel(s,o,d,g,p,E):l==="scale"&&this.moveModelScale(s,o,d,g,r,p,a,P.endPosition,E)}},e.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(()=>{if(!t())return;let b=this.dragEndCallbackMap.get(s==null?void 0:s.id);if(b&&(l==="move"||l==="moveHeight")){let C=b.get("translation");C&&(this.runEventListener("translation",C),b.delete("translation"))}else if(b&&l==="rotate"){let C=b.get("rotate");C&&(this.runEventListener("rotate",C),b.delete("rotate"))}else if(b&&l==="scale"){let C=b.get("addScale");C&&(this.runEventListener("addScale",C),b.delete("addScale"))}f()},e.ScreenSpaceEventType.LEFT_UP),this.handler.setInputAction(()=>{f()},e.ScreenSpaceEventType.RIGHT_UP)}activateEditById(t,e){var s,o;const i=this.primitives.get(t);if(!i)return;const n=this.getPrimitiveRuntimeRadius(i);if(!Number.isFinite(n)||n<=0){typeof((s=i==null?void 0:i.readyPromise)==null?void 0:s.then)=="function"?i.readyPromise.then(()=>this.activateEditById(t,e)).catch(()=>{}):typeof((o=i==null?void 0:i.readyEvent)==null?void 0:o.addEventListener)=="function"&&i.readyEvent.addEventListener(()=>this.activateEditById(t,e));return}this.activeModelId&&this.activeModelId!==t&&this.deactivateEdit(!1),this.activeModelId=t,this.highlightModel(i,!0),this.showModeToolbar(t),this.switchEditMode(e||this.editMode||"move")}deactivateEdit(t=!0){this.removeTool(),this.clearActiveModelVisual(),this.hideModeToolbar(),this.hideFeedback(),this.hideModeHint(),this.activeModelId="",t&&this.setEditMode(""),this.unlockCamera()}switchEditMode(t){if(!t)return;const e=t==="moveHeight"?"move":t;this.setEditMode(e),this.refreshActiveToolGeometry(),this.updateOverlayPosition(),e!=="scale"&&this.hideModeHint()}refreshActiveToolGeometry(){const t=this.activeModelId?this.primitives.get(this.activeModelId):null;this.removeTool(),t&&(this.editMode==="move"?(this.createMoveAxis(t),this.createTranslationSquare(t)):this.editMode==="rotate"?this.createRotationRing(t):this.editMode==="scale"&&this.createScaleHandle(t))}highlightModel(t,e){if(!t)return;if(e){this.activeModelVisualState.has(t.id)||this.activeModelVisualState.set(t.id,{silhouetteColor:t.silhouetteColor,silhouetteSize:t.silhouetteSize}),t.silhouetteSize=0;return}const i=this.activeModelVisualState.get(t.id);i?(t.silhouetteColor=i.silhouetteColor,t.silhouetteSize=i.silhouetteSize,this.activeModelVisualState.delete(t.id)):t.silhouetteSize=0}clearActiveModelVisual(){if(!this.activeModelId)return;const t=this.primitives.get(this.activeModelId);if(t){this.highlightModel(t,!1);return}this.activeModelVisualState.delete(this.activeModelId)}initOverlay(){var r;if(typeof document>"u")return;const t=document.createElement("div");t.className="scene-gadget-gizmo-overlay",Object.assign(t.style,{position:"absolute",inset:"0",pointerEvents:"none",zIndex:"120"});const e=((r=this.viewer)==null?void 0:r.container)||document.body,i=window.getComputedStyle(e);e!==document.body&&i.position==="static"&&(e.style.position="relative");const n=document.createElement("div");Object.assign(n.style,{position:"absolute",display:"none",gap:"10px",flexDirection:"column",alignItems:"stretch",padding:"10px 8px",borderRadius:"14px",background:"rgba(7, 12, 20, 0.92)",border:"1px solid rgba(255,255,255,0.08)",boxShadow:"0 12px 28px rgba(0,0,0,0.28)",pointerEvents:"auto",transform:"translate(0, -50%)",backdropFilter:"blur(10px)"});const s=document.createElement("div");Object.assign(s.style,{position:"absolute",display:"none",padding:"4px 8px",borderRadius:"999px",background:"rgba(7, 13, 20, 0.92)",color:"#fff",fontSize:"12px",fontWeight:"600",lineHeight:"18px",pointerEvents:"none",transform:"translate(-50%, calc(-100% - 8px))",boxShadow:"0 8px 18px rgba(0,0,0,0.24)",whiteSpace:"nowrap"}),[{mode:"move",label:"移",title:"移动",color:"#53d7ff"},{mode:"rotate",label:"旋",title:"旋转",color:"#ff8a61"},{mode:"scale",label:"缩",title:"缩放",color:"#ffd76a"}].forEach(a=>{const l=document.createElement("button");l.type="button",l.dataset.mode=a.mode,l.title=a.title,l.innerText=a.label,Object.assign(l.style,{width:"42px",height:"42px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.08)",background:"rgba(255,255,255,0.05)",color:a.color,fontSize:"13px",fontWeight:"700",cursor:"pointer",pointerEvents:"auto"}),l.addEventListener("click",d=>{d.stopPropagation(),this.switchEditMode(a.mode)}),n.appendChild(l)}),t.appendChild(n),t.appendChild(s),e.appendChild(t),this.overlayContainer=t,this.modeToolbarEl=n,this.feedbackLabelEl=s,this.overlayUpdateFn=this.updateOverlayPosition.bind(this),this.viewer.scene.postRender.addEventListener(this.overlayUpdateFn)}showModeToolbar(t){this.modeToolbarEl&&(this.modeToolbarEl.style.display="flex",this.updateToolbarState(),this.updateOverlayPosition())}hideModeToolbar(){this.modeToolbarEl&&(this.modeToolbarEl.style.display="none")}updateToolbarState(){if(!this.modeToolbarEl)return;Array.from(this.modeToolbarEl.querySelectorAll("button")).forEach(e=>{const i=e.dataset.mode===this.editMode;Object.assign(e.style,i?{background:"rgba(255,255,255,0.14)",borderColor:"rgba(255,255,255,0.22)",boxShadow:"inset 0 0 0 1px rgba(255,255,255,0.05)"}:{background:"rgba(255,255,255,0.05)",borderColor:"rgba(255,255,255,0.08)",boxShadow:"none"})})}updateOverlayPosition(){var t,e;try{if(!this.activeModelId)return;const i=this.primitives.get(this.activeModelId);if(!i)return;const n=this.Cesium,s=this.getGizmoScreenBounds(i);if(!s){this.hideModeToolbar(),this.hideFeedback();return}const o=s.center,r=(e=(t=this.viewer)==null?void 0:t.scene)==null?void 0:e.canvas,a=Number((r==null?void 0:r.clientWidth)||(r==null?void 0:r.width)||0),l=Number((r==null?void 0:r.clientHeight)||(r==null?void 0:r.height)||0);if(this.modeToolbarEl&&this.modeToolbarEl.style.display!=="none"){const d=Number(this.modeToolbarEl.offsetWidth||58),u=Number(this.modeToolbarEl.offsetHeight||176),p=18;let g=s.maxX+p;g+d>a-12&&(g=s.minX-d-p),g=n.Math.clamp(g,12,Math.max(12,a-d-12));const m=(s.minY+s.maxY)/2,f=n.Math.clamp(m-u/2,12,Math.max(12,l-u-12));this.modeToolbarEl.style.left=`${g}px`,this.modeToolbarEl.style.top=`${f+u/2}px`}if(this.feedbackLabelEl&&this.feedbackLabelEl.style.display!=="none"){const d=this.feedbackAnchor||o,u=this.toWindowCoordinates(d);u&&(this.feedbackLabelEl.style.left=`${u.x}px`,this.feedbackLabelEl.style.top=`${u.y}px`)}}catch{this.hideModeToolbar(),this.hideFeedback()}}showFeedback(t,e){this.feedbackLabelEl&&(this.feedbackAnchor=e||null,this.feedbackLabelEl.innerText=t,this.feedbackLabelEl.style.display="block",this.updateOverlayPosition())}hideFeedback(){this.feedbackAnchor=null,this.feedbackLabelEl&&(this.feedbackLabelEl.style.display="none")}toWindowCoordinates(t){var s;const e=this.Cesium,i=(s=this.viewer)==null?void 0:s.scene,n=e==null?void 0:e.SceneTransforms;if(!(!i||!n||!t)){if(typeof n.wgs84ToWindowCoordinates=="function")return n.wgs84ToWindowCoordinates(i,t);if(typeof n.worldToWindowCoordinates=="function")return n.worldToWindowCoordinates(i,t)}}createUnitBoxGeometry(){const t=this.Cesium;return t.BoxGeometry.createGeometry(new t.BoxGeometry({maximum:new t.Cartesian3(.5,.5,.5),minimum:new t.Cartesian3(-.5,-.5,-.5)}))}getGizmoAppearance(){const t=this.Cesium;return new t.PerInstanceColorAppearance({translucent:!0,flat:!0,renderState:{depthTest:{enabled:!1},depthMask:!1,cull:{enabled:!1},blending:t.BlendingState.ALPHA_BLEND}})}getGizmoMetrics(t){const e=Math.max(this.getPrimitiveEffectiveRadius(t),8),i=Math.max(e*.08,2.2),n=Math.max(e*1.25,20),s=Math.max(e*.28,6),o=Math.max(e*.065,1.8),r=Math.max(e*.028,1.1),a=Math.max(i*2.2,e*.18),l=Math.max(e*.62,a+6),d=Math.max(e*.018,.8),u=Math.max(e*1.02,18),p=Math.max(e*.024,1.15),g=Math.max(e*1.06,18),m=Math.max(e*.075,2.4);return{centerRadius:i,axisLength:n,arrowLength:s,arrowRadius:o,axisThickness:r,planeStart:a,planeEnd:l,planeThickness:d,rotationRadius:u,rotationThickness:p,scaleOffset:g,scaleHandleRadius:m}}createSegmentInstance(t,e,i,n,s){const o=this.Cesium,r=o.Cartesian3.subtract(i,e,new o.Cartesian3),a=o.Cartesian3.magnitude(r);if(!Number.isFinite(a)||a<=0)return null;const l=o.Cartesian3.normalize(r,new o.Cartesian3),d=o.Cartesian3.midpoint(e,i,new o.Cartesian3),u=o.Cartesian3.UNIT_X,p=o.Cartesian3.cross(u,l,new o.Cartesian3),g=o.Cartesian3.magnitude(p),m=o.Math.clamp(o.Cartesian3.dot(u,l),-1,1);let f=o.Quaternion.clone(o.Quaternion.IDENTITY);return g>1e-6?(o.Cartesian3.normalize(p,p),f=o.Quaternion.fromAxisAngle(p,Math.acos(m))):m<0&&(f=o.Quaternion.fromAxisAngle(o.Cartesian3.UNIT_Z,Math.PI)),new o.GeometryInstance({id:t,geometry:this.createUnitBoxGeometry(),modelMatrix:o.Matrix4.fromTranslationQuaternionRotationScale(d,f,new o.Cartesian3(a,n,n)),attributes:{color:o.ColorGeometryInstanceAttribute.fromColor(s)}})}createCenterInstance(t,e,i){const n=this.Cesium;return new n.GeometryInstance({id:t,geometry:new n.EllipsoidGeometry({radii:new n.Cartesian3(e,e,e),vertexFormat:n.PerInstanceColorAppearance.VERTEX_FORMAT}),attributes:{color:n.ColorGeometryInstanceAttribute.fromColor(i)}})}createCenterBoxInstance(t,e,i){const n=this.Cesium;return new n.GeometryInstance({id:t,geometry:n.BoxGeometry.createGeometry(new n.BoxGeometry({maximum:new n.Cartesian3(e,e,e),minimum:new n.Cartesian3(-e,-e,-e)})),attributes:{color:n.ColorGeometryInstanceAttribute.fromColor(i)}})}getAxisVector(t,e){const i=this.Cesium;return e==="X"?i.Matrix4.getColumn(t,0,new i.Cartesian3):e==="Y"?i.Matrix4.getColumn(t,1,new i.Cartesian3):i.Matrix4.getColumn(t,2,new i.Cartesian3)}getRotationPlanePoint(t,e,i){const n=this.Cesium;return t==="xy"?new n.Cartesian3(e*Math.cos(i),e*Math.sin(i),0):t==="yz"?new n.Cartesian3(0,e*Math.cos(i),e*Math.sin(i)):new n.Cartesian3(e*Math.cos(i),0,e*Math.sin(i))}getGizmoLocalBounds(t){const e=this.Cesium,i=this.getGizmoMetrics(t);if(this.editMode==="rotate"){const n=[0,45,90].map(s=>e.Math.toRadians(s));return["xy","yz","xz"].flatMap(s=>n.map(o=>this.getRotationPlanePoint(s,i.rotationRadius,o)))}return this.editMode==="scale"?[new e.Cartesian3(i.scaleOffset,0,0),new e.Cartesian3(0,i.scaleOffset,0),new e.Cartesian3(0,0,i.scaleOffset),new e.Cartesian3(0,0,0)]:[new e.Cartesian3(i.axisLength+i.arrowLength,0,0),new e.Cartesian3(0,i.axisLength+i.arrowLength,0),new e.Cartesian3(0,0,i.axisLength+i.arrowLength),new e.Cartesian3(i.planeEnd,i.planeEnd,0),new e.Cartesian3(0,i.planeEnd,i.planeEnd),new e.Cartesian3(i.planeEnd,0,i.planeEnd)]}getGizmoScreenBounds(t){const e=this.Cesium,i=this.getGizmoModelMatrix(t),n=e.Matrix4.getTranslation(i,new e.Cartesian3),s=this.toWindowCoordinates(n);if(!s)return null;const o=this.getGizmoLocalBounds(t).map(r=>this.toWindowCoordinates(e.Matrix4.multiplyByPoint(i,r,new e.Cartesian3))).filter(Boolean);return o.length?o.reduce((r,a)=>({minX:Math.min(r.minX,a.x),maxX:Math.max(r.maxX,a.x),minY:Math.min(r.minY,a.y),maxY:Math.max(r.maxY,a.y),center:n}),{minX:Number.POSITIVE_INFINITY,maxX:Number.NEGATIVE_INFINITY,minY:Number.POSITIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,center:n}):{minX:s.x,maxX:s.x,minY:s.y,maxY:s.y,center:n}}writeDragEndPayload(t,e,i){let n=this.dragEndCallbackMap.get(t);n||(n=new Map,this.dragEndCallbackMap.set(t,n)),n.set(e,i)}applyTransformAroundCenter(t,e,i){const n=this.Cesium,s=n.Matrix4.fromTranslation(n.Cartesian3.negate(e,new n.Cartesian3)),o=n.Matrix4.fromTranslation(e),r=n.Matrix4.multiply(o,n.Matrix4.multiply(i,s,new n.Matrix4),new n.Matrix4);return n.Matrix4.multiply(r,t,new n.Matrix4)}createMoveAxis(t){const e=this.Cesium,i=this.viewer;this.moveAxis&&i.scene.primitives.remove(this.moveAxis);const n=this.getGizmoMetrics(t),s=[{axis:"X",start:new e.Cartesian3(n.centerRadius,0,0),end:new e.Cartesian3(n.axisLength,0,0),color:e.Color.RED.withAlpha(.98)},{axis:"Y",start:new e.Cartesian3(0,n.centerRadius,0),end:new e.Cartesian3(0,n.axisLength,0),color:e.Color.LIME.withAlpha(.98)},{axis:"Z",start:new e.Cartesian3(0,0,n.centerRadius),end:new e.Cartesian3(0,0,n.axisLength),color:e.Color.DODGERBLUE.withAlpha(.98)}].flatMap(o=>{const r=[],a=this.createSegmentInstance(`moveAxis_${t.id}_${o.axis}_line`,o.start,o.end,n.axisThickness,o.color);a&&r.push(a);const l=e.BoxGeometry.createGeometry(new e.BoxGeometry({maximum:new e.Cartesian3(n.scaleHandleRadius,n.scaleHandleRadius,n.scaleHandleRadius),minimum:new e.Cartesian3(-n.scaleHandleRadius,-n.scaleHandleRadius,-n.scaleHandleRadius)})),d=o.axis==="X"?[n.axisLength,0,0]:o.axis==="Y"?[0,n.axisLength,0]:[0,0,n.axisLength];return this.translate(l,d),r.push(new e.GeometryInstance({id:`moveAxis_${t.id}_${o.axis}_handle`,geometry:l,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(o.color)}})),r});s.push(this.createCenterInstance(`moveCenter_${t.id}`,n.centerRadius,e.Color.WHITE)),this.moveAxis=new e.Primitive({geometryInstances:s,appearance:this.getGizmoAppearance(),modelMatrix:this.getGizmoModelMatrix(t),cull:!1,asynchronous:!1}),i.scene.primitives.add(this.moveAxis)}createRotationRing(t){const e=this.Cesium,i=this.viewer;this.rotationRing&&i.scene.primitives.remove(this.rotationRing);const n=this.getGizmoMetrics(t),s=10,o=4,r=Math.max(n.rotationRadius-n.rotationThickness*5,1),l=(n.rotationRadius+n.rotationThickness*5-r)/o,d=[{axis:"X",plane:"yz",color:e.Color.RED.withAlpha(.92)},{axis:"Y",plane:"xz",color:e.Color.LIME.withAlpha(.9)},{axis:"Z",plane:"xy",color:e.Color.YELLOW.withAlpha(.92)}].flatMap(u=>{const p=[];for(let g=0;g<90;g+=s){const m=e.Math.toRadians(g),f=e.Math.toRadians(g+s),y=this.getRotationPlanePoint(u.plane,n.rotationRadius,m),v=this.getRotationPlanePoint(u.plane,n.rotationRadius,f),w=this.createSegmentInstance(`rotationArc_${t.id}_${u.axis}_${g}`,y,v,n.rotationThickness,u.color);w&&p.push(w);for(let P=0;P<o;P+=1){const b=r+l*(P+.5),C=this.getRotationPlanePoint(u.plane,b,m),E=this.getRotationPlanePoint(u.plane,b,f),L=this.createSegmentInstance(`rotationSector_${t.id}_${u.axis}_${P}_${g}`,C,E,Math.max(l*.92,n.rotationThickness*1.4),u.color.withAlpha(.04));L&&p.push(L)}}return p});this.rotationRing=new e.Primitive({geometryInstances:d,appearance:this.getGizmoAppearance(),modelMatrix:this.getGizmoModelMatrix(t),cull:!1,asynchronous:!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 n=this.getGizmoMetrics(t),o=[{axis:"XY",color:e.Color.DODGERBLUE.withAlpha(.28),minimum:new e.Cartesian3(n.planeStart,n.planeStart,-n.planeThickness),maximum:new e.Cartesian3(n.planeEnd,n.planeEnd,n.planeThickness)},{axis:"YZ",color:e.Color.RED.withAlpha(.24),minimum:new e.Cartesian3(-n.planeThickness,n.planeStart,n.planeStart),maximum:new e.Cartesian3(n.planeThickness,n.planeEnd,n.planeEnd)},{axis:"ZX",color:e.Color.LIME.withAlpha(.24),minimum:new e.Cartesian3(n.planeStart,-n.planeThickness,n.planeStart),maximum:new e.Cartesian3(n.planeEnd,n.planeThickness,n.planeEnd)}].map(r=>new e.GeometryInstance({id:`translationPlane_${t.id}_${r.axis}`,geometry:new e.BoxGeometry({minimum:r.minimum,maximum:r.maximum}),attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(r.color)}}));this.translationSquare=new e.Primitive({geometryInstances:o,appearance:this.getGizmoAppearance(),cull:!1,modelMatrix:this.getGizmoModelMatrix(t),asynchronous:!1}),i.scene.primitives.add(this.translationSquare)}createHeightArrow(t){const e=this.Cesium,i=this.viewer,n=Math.max(this.getPrimitiveEffectiveRadius(t),8);this.heightArrow&&i.scene.primitives.remove(this.heightArrow);let s=e.Color.GREEN,o=Math.max(n*.03,1.5),r=2*o,a=Math.max(n*1.6,36),l=a*.1;const d=Math.max(n*.2,2),u=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:a,topRadius:o,bottomRadius:o})),p=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:l,topRadius:0,bottomRadius:r}));let g=a+d,m=(a+d)/2;this.translate(u,[0,0,m]),this.translate(p,[0,0,g]),this.heightArrow=new e.Primitive({modelMatrix:t.modelMatrix,geometryInstances:[new e.GeometryInstance({id:`heightArrow-line_${t.id}`,geometry:u,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(s.withAlpha(.9))}}),new e.GeometryInstance({id:`heightArrow-arrow_${t.id}`,geometry:p,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(s.withAlpha(.9))}})],appearance:new e.PerInstanceColorAppearance({translucent:!0,closed:!0}),cull:!1,asynchronous:!1}),i.scene.primitives.add(this.heightArrow)}createScaleHandle(t){const e=this.Cesium,i=this.viewer;this.scaleHandle&&i.scene.primitives.remove(this.scaleHandle),this.scaleCenterProxy&&i.scene.primitives.remove(this.scaleCenterProxy);const n=this.getGizmoMetrics(t),s=[{axis:"X",color:e.Color.RED.withAlpha(.96),end:new e.Cartesian3(n.scaleOffset,0,0)},{axis:"Y",color:e.Color.LIME.withAlpha(.96),end:new e.Cartesian3(0,n.scaleOffset,0)},{axis:"Z",color:e.Color.DODGERBLUE.withAlpha(.96),end:new e.Cartesian3(0,0,n.scaleOffset)}].flatMap(o=>{const r=[],a=this.createSegmentInstance(`scaleAxis_${t.id}_${o.axis}`,new e.Cartesian3(0,0,0),o.end,n.axisThickness,o.color);a&&r.push(a);const l=e.BoxGeometry.createGeometry(new e.BoxGeometry({maximum:new e.Cartesian3(n.scaleHandleRadius,n.scaleHandleRadius,n.scaleHandleRadius),minimum:new e.Cartesian3(-n.scaleHandleRadius,-n.scaleHandleRadius,-n.scaleHandleRadius)}));return this.translate(l,o.end),r.push(new e.GeometryInstance({id:`scaleHandle_${t.id}_${o.axis}`,geometry:l,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(o.color)}})),r});s.push(this.createCenterInstance(`scaleCenter_${t.id}`,n.centerRadius*1.35,e.Color.WHITE)),this.scaleHandle=new e.Primitive({geometryInstances:s,appearance:this.getGizmoAppearance(),cull:!1,asynchronous:!1,modelMatrix:this.getGizmoModelMatrix(t)}),i.scene.primitives.add(this.scaleHandle),this.scaleCenterProxy=new e.Primitive({geometryInstances:[this.createCenterBoxInstance(`scaleCenterHit_${t.id}`,n.centerRadius*3.1,e.Color.WHITE.withAlpha(.02))],appearance:this.getGizmoAppearance(),cull:!1,asynchronous:!1,modelMatrix:this.getGizmoModelMatrix(t)}),i.scene.primitives.add(this.scaleCenterProxy)}translate(t,e){let i=this.Cesium;const n=new i.Cartesian3;Me(e)?(n.x=e[0],n.y=e[1],n.z=e[2]):i.Cartesian3.clone(e,n);for(let s=0;s<t.attributes.position.values.length;s+=3)t.attributes.position.values[s]+=n.x,t.attributes.position.values[s+1]+=n.y,t.attributes.position.values[s+2]+=n.z}removeTool(){this.rotationRing&&(this.viewer.scene.primitives.remove(this.rotationRing),this.rotationRing=null),this.moveAxis&&(this.viewer.scene.primitives.remove(this.moveAxis),this.moveAxis=null),this.translationSquare&&(this.viewer.scene.primitives.remove(this.translationSquare),this.translationSquare=null),this.heightArrow&&(this.viewer.scene.primitives.remove(this.heightArrow),this.heightArrow=null),this.scaleHandle&&(this.viewer.scene.primitives.remove(this.scaleHandle),this.scaleHandle=null),this.scaleCenterProxy&&(this.viewer.scene.primitives.remove(this.scaleCenterProxy),this.scaleCenterProxy=null)}updatedTool(t){const e=this.extractModelBaseMatrix(t);this.rotationRing&&(this.rotationRing.modelMatrix=e),this.moveAxis&&(this.moveAxis.modelMatrix=e),this.translationSquare&&(this.translationSquare.modelMatrix=e),this.heightArrow&&(this.heightArrow.modelMatrix=e),this.scaleHandle&&(this.scaleHandle.modelMatrix=e),this.scaleCenterProxy&&(this.scaleCenterProxy.modelMatrix=e)}moveModel(t,e,i,n,s,o){const r=this.Cesium,a=r.Cartesian3.subtract(o,s,new r.Cartesian3),l=r.Transforms.eastNorthUpToFixedFrame(n);let d=a;if(!["XY","YZ","ZX"].includes(i)){const f=this.getAxisVector(l,i),y=r.Cartesian3.dot(a,f);d=r.Cartesian3.multiplyByScalar(f,y,new r.Cartesian3)}const u=r.Matrix4.multiply(r.Matrix4.fromTranslation(d),e,new r.Matrix4);t.modelMatrix=u,this.updatedTool(u);const p=r.Matrix4.getTranslation(u,new r.Cartesian3),g=r.Cartesian3.magnitude(d),m=["XY","YZ","ZX"].includes(i)?i:`${i}轴`;this.showFeedback(`${m} ${g.toFixed(2)} m`,p),this.writeDragEndPayload(t.id,"translation",{id:t.id,position:p})}moveModelHeight(t,e,i,n,s,o){const r=this.Cesium,a=this.projectVerticalPoint(i.endPosition,n,s);if(a&&o){const l=r.Cartographic.fromCartesian(a),d=new r.Cartographic(o.longitude,o.latitude,(l==null?void 0:l.height)||o.height||0),u=r.Cartographic.toCartesian(d),p=r.Matrix4.getRotation(e,new r.Matrix3),g=r.Matrix4.fromRotationTranslation(p,u);t.modelMatrix=g,this.updatedTool(g),this.showFeedback(`${(((l==null?void 0:l.height)||0)-(o.height||0)).toFixed(2)} m`,u);let m=new r.Cartesian3(g[12],g[13],g[14]),f=this.dragEndCallbackMap.get(t.id);f||(f=new Map,this.dragEndCallbackMap.set(t.id,f)),f.set("translation",{id:t.id,position:m})}}projectVerticalPoint(t,e,i){const n=this.Cesium,s=this.viewer;if(!t||!e||!i)return null;const o=s.camera.getPickRay(t);if(!o)return null;const r=o.origin,a=n.Cartesian3.normalize(o.direction,new n.Cartesian3),l=e,d=i,u=n.Cartesian3.subtract(r,l,new n.Cartesian3),p=n.Cartesian3.dot(a,a),g=-n.Cartesian3.dot(a,d),m=n.Cartesian3.dot(d,d),f=-n.Cartesian3.dot(a,u),y=n.Cartesian3.dot(d,u),v=p*m-g*g;if(Math.abs(v)<1e-6)return null;const w=(p*y-g*f)/v;return n.Cartesian3.add(l,n.Cartesian3.multiplyByScalar(d,w,new n.Cartesian3),new n.Cartesian3)}rotateModel(t,e,i,n,s,o){const r=this.Cesium;if(!s||!o||!n)return;const a=r.Cartesian3.subtract(o,n,new r.Cartesian3);if(r.Cartesian3.magnitudeSquared(a)<=1e-6)return;r.Cartesian3.normalize(a,a);const l=r.Transforms.eastNorthUpToFixedFrame(n),d=this.getAxisVector(l,i),u=r.Math.clamp(r.Cartesian3.dot(s,a),-1,1),p=Math.acos(u);if(!Number.isFinite(p)||p<=1e-6)return;const g=r.Cartesian3.cross(s,a,new r.Cartesian3),m=r.Cartesian3.dot(g,d)>=0?1:-1,f=p*m,y=r.Quaternion.fromAxisAngle(d,f),v=r.Matrix4.fromRotationTranslation(r.Matrix3.fromQuaternion(y)),w=this.applyTransformAroundCenter(e,n,v);t.modelMatrix=w,this.updatedTool(w);const P=r.Matrix4.getTranslation(w,new r.Cartesian3);this.showFeedback(`${i}轴 ${r.Math.toDegrees(f).toFixed(1)}°`,P);const b=this.getModelHeadingPitchRoll(this.extractModelBaseMatrix(w));this.writeDragEndPayload(t.id,"rotate",{id:t.id,headingPitchRoll:{heading:Number(r.Math.toDegrees(b.heading).toFixed(3)),pitch:Number(r.Math.toDegrees(b.pitch).toFixed(3)),roll:Number(r.Math.toDegrees(b.roll).toFixed(3))}})}moveModelScale(t,e,i,n,s,o,r,a,l){const d=this.Cesium;if(!r)return;const u=this.getGizmoMetrics(t),p=d.Transforms.eastNorthUpToFixedFrame(n),g=Math.max(u.scaleOffset*.7,8);let m=0;if(i==="CENTER"){if(!s||!a)return;const b=Number(s.y||0)-Number(a.y||0);m=Math.pow(2,b/180)-1}else{if(!o||!l)return;const b=d.Cartesian3.subtract(l,o,new d.Cartesian3),C=this.getAxisVector(p,i);m=d.Cartesian3.dot(b,C)/g}const f=Math.max(.05,1+m),y={x:r.x,y:r.y,z:r.z};if(i==="CENTER")y.x=Math.max(.05,r.x*f),y.y=Math.max(.05,r.y*f),y.z=Math.max(.05,r.z*f);else{const b=Math.max(.05,Number((r[i.toLowerCase()]*f).toFixed(4)));y[i.toLowerCase()]=b}const v=this.extractModelBaseMatrix(e);this.applyScaleToPrimitive(t,y,v),this.activeModelId===t.id?this.refreshActiveToolGeometry():this.updatedTool(t.modelMatrix);const w=d.Matrix4.getTranslation(t.modelMatrix,new d.Cartesian3),P=i==="CENTER"?`${Math.max(y.x,y.y,y.z).toFixed(2)}x`:`${i}轴 ${y[i.toLowerCase()].toFixed(2)}x`;this.debugLog("moveModelScale",{id:t==null?void 0:t.id,axis:i,startScale:{x:Number((r==null?void 0:r.x)||1),y:Number((r==null?void 0:r.y)||1),z:Number((r==null?void 0:r.z)||1)},nextScale:y,deltaFactor:m,factor:f,runtimeRadius:this.getPrimitiveRuntimeRadius(t)}),this.showFeedback(P,w),this.writeDragEndPayload(t.id,"addScale",{id:t.id,scale:y})}cleanup(){var t,e;this.deactivateEdit(),this.hideModeHint(),(t=this.tooltipManager)==null||t.destroy(),this.tooltipManager=null,this.overlayUpdateFn&&(this.viewer.scene.postRender.removeEventListener(this.overlayUpdateFn),this.overlayUpdateFn=null),(e=this.overlayContainer)==null||e.remove(),this.overlayContainer=null,this.modeToolbarEl=null,this.feedbackLabelEl=null,this.handler&&(this.handler.destroy(),this.handler=null)}}function Eo(h,t){const e=t.materialType||"DynamicImgMaterial"+Date.now()+Math.floor(Math.random()*1e3);function i(s){this._definitionChanged=new h.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:h.createPropertyDescriptor("color")}),i.prototype.getType=function(){return e},i.prototype.getValue=function(s,o){return h.defined(o)||(o={}),o.color=h.Property.getValueOrClonedDefault(this._color,s,h.Color.WHITE,o.color),o.image=t.image,o},i.prototype.equals=function(s){return this===s||s instanceof i&&h.Property.equals(this._color,s._color)};const n=function(s){return`
|
|
1
|
+
(function(_,te){typeof exports=="object"&&typeof module<"u"?te(exports):typeof define=="function"&&define.amd?define(["exports"],te):(_=typeof globalThis<"u"?globalThis:_||self,te(_.CesiumCore={}))})(this,(function(_){"use strict";var Fo=Object.defineProperty;var zo=(_,te,V)=>te in _?Fo(_,te,{enumerable:!0,configurable:!0,writable:!0,value:V}):_[te]=V;var c=(_,te,V)=>zo(_,typeof te!="symbol"?te+"":te,V);class te{constructor(t,e,i){c(this,"Cesium");c(this,"viewer");c(this,"labelPool");c(this,"threshold");c(this,"displayLimit");c(this,"maxLevel");c(this,"debugCurrentGrids");c(this,"levels");c(this,"points",[]);c(this,"gridLayers",new Map);c(this,"debugGrids",[]);c(this,"_updateFn");c(this,"clusterTheme");c(this,"pointTheme");c(this,"centralPointMode");c(this,"minGlobalPointCount");c(this,"groupByTheme");c(this,"tilingScheme");c(this,"terrainLevelOffset");c(this,"debugTileCoordLayer",null);c(this,"levelIndexByTileLevel",new Map);c(this,"_lastTileProvider",null);c(this,"_updateTimer",null);c(this,"_updateDelay",100);c(this,"_tilesRetryCount",0);c(this,"_tilesRetryMax",100);c(this,"_cameraDirty",!1);c(this,"_tileLoadListener",null);c(this,"_cameraChangedHandler",null);c(this,"defaultMinLevel",0);c(this,"defaultMaxLevel",28);c(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 n=this.viewer.scene&&this.viewer.scene.globe,s=n&&n._surface,o=s&&s._tileProvider,r=(o==null?void 0:o.tilingScheme)||new this.Cesium.GeographicTilingScheme;this._lastTileProvider=o,this.tilingScheme=r,this.levels=this._createLevels(),this._buildLevels(),this._updateFn=this._update.bind(this),this.debugCurrentGrids&&this._ensureDebugImageryLayer(),n&&(this._tileLoadListener=a=>{a===0&&this._cameraDirty&&(this._cameraDirty=!1,this._scheduleUpdate())},n.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,n=(i==null?void 0:i.tilingScheme)||new this.Cesium.GeographicTilingScheme,s=i!==this._lastTileProvider,o=this.tilingScheme!==n;!s&&!o&&this.levels&&this.levels.length>0||(this._lastTileProvider=i,this.tilingScheme=n,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 n=0;for(let s=e;s<=i;s++,n++){const o=360/Math.pow(2,s);t.push({level:s,size:o,minViewWidth:o*4}),this.levelIndexByTileLevel.set(s,n)}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()}_getCurrentBillboard(t){var e;return(t==null?void 0:t.__currentBillboard)||((e=t==null?void 0:t.billboard)==null?void 0:e[0])}_getBillboardTheme(t){var e;return(e=this._getCurrentBillboard(t))==null?void 0:e.theme}_shouldSkipAggregation(t){var e;return(e=this._getCurrentBillboard(t))==null?void 0:e.skipAggregation}_scheduleUpdate(){this._updateTimer!==null&&clearTimeout(this._updateTimer),this._updateTimer=window.setTimeout(()=>{this._update(),this._cameraDirty=!0,this._updateTimer=null},this._updateDelay)}updatePoint(t){const e=this.points.findIndex(s=>s.id===t.id);if(e===-1)return;const i=this.points[e];for(const s of this.levels){const o=s.level,r=this.gridLayers.get(o);if(!r)continue;const a=this.Cesium.Cartographic.fromDegrees(i.lon,i.lat),l=this.tilingScheme.positionToTileXY(a,o,new this.Cesium.Cartesian2);if(!l)continue;const d=`${l.x}_${l.y}`,u=r.get(d);if(u){const p=u.allPoints.findIndex(g=>g.id===t.id);if(p!==-1&&u.allPoints.splice(p,1),this._shouldSkipAggregation(i.data)){const g=u.skipPoints.findIndex(m=>m.id===t.id);g!==-1&&u.skipPoints.splice(g,1)}else{const g=this.groupByTheme?this._getBillboardTheme(i.data):this.clusterTheme,m=u.groups.get(g);if(m){const f=m.findIndex(y=>y.id===t.id);f!==-1&&m.splice(f,1),m.length===0&&u.groups.delete(g)}}}}const n={...i,...t};this.points[e]=n,this._addPointToGrid(n),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 n=this.gridLayers.get(i.level);if(n)for(const[s,o]of n.entries()){o.allPoints=o.allPoints.filter(r=>!e.has(r.id)),o.skipPoints=o.skipPoints.filter(r=>!e.has(r.id));for(const[r,a]of o.groups.entries()){const l=a.filter(d=>!e.has(d.id));l.length===0?o.groups.delete(r):o.groups.set(r,l)}o.allPoints.length===0&&n.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){for(const e of this.levels){const i=e.level,n=this.gridLayers.get(i);if(!n)continue;const s=this.Cesium.Cartographic.fromDegrees(t.lon,t.lat),o=this.tilingScheme.positionToTileXY(s,i,new this.Cesium.Cartesian2);if(!o)continue;const r=`${o.x}_${o.y}`;let a=n.get(r);if(a||(a={allPoints:[],groups:new Map,skipPoints:[]},n.set(r,a)),a.allPoints.push(t),this._shouldSkipAggregation(t.data))a.skipPoints.push(t);else{const l=this.groupByTheme?this._getBillboardTheme(t.data):this.clusterTheme;a.groups.has(l)||a.groups.set(l,[]),a.groups.get(l).push(t)}}}_preparePointLevelRange(t){const e=t.data||{};let i=e.minLevel,n=e.maxLevel;const s=e.levelRange;Array.isArray(s)?(s.length>0&&i==null&&(i=s[0]),s.length>1&&n==null&&(n=s[1])):s&&typeof s=="object"&&(i==null&&typeof s.min=="number"&&(i=s.min),n==null&&typeof s.max=="number"&&(n=s.max));const o=i==null?this.defaultMinLevel:Number(i)||this.defaultMinLevel,r=n==null?this.defaultMaxLevel:Number(n)||this.defaultMaxLevel;t.__minLevel=o,t.__maxLevel=r}_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,n=t.__maxLevel??this.defaultMaxLevel;return e>=i&&e<=n}_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=(n,s,o,r)=>{e=this._processCell(n,s,o,r,t,e)};try{const n=this._getSurfaceTiles();if(!n||n.length===0){this._handleNoSurfaceTiles(e);return}this._tilesRetryCount=0,this._processTiles(n,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;for(const i of this.points){if(t>=this.displayLimit)break;((e=i.data)==null?void 0:e.show)!==!1&&(this.labelPool.add(i.data,{id:`point-${i.id}`,lon:i.lon,lat:i.lat,height:i.height,theme:this._getBillboardTheme(i.data)||this.pointTheme,style:i.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,n=this.levels[this.levels.length-1].level;if(t>n)return this.levels.length-1;if(t<i)return 0;let s=0,o=1/0;for(let r=0;r<this.levels.length;r++){const a=Math.abs(this.levels[r].level-t);a<o&&(o=a,s=r)}return s}_isTerrainEnabled(){const t=this.viewer.terrainProvider,e=this.viewer.scene,i=e&&e.globe,n=i&&i.terrainProvider,s=t||n;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,n=!this._isTerrainEnabled(),s=this.viewer.scene,o=s&&s.globe,r=o&&o.ellipsoid,a=r&&s.camera.computeViewRectangle(r),l=(d,u,p)=>{if(!n||!a)return!0;const g=this.tilingScheme.tileXYToRectangle(d,u,p);return!(!g||g.east<=a.west||g.west>=a.east||g.north<=a.south||g.south>=a.north)};for(const d of t){const u=d.rectangle,p=d._level??d.level;if(!u||typeof p!="number")continue;const g=this._getGridRefLevel(p),m=this._resolveLevelIndex(g);if(m===void 0)continue;const f=this.levels[m].level,y=d._x??d.x,v=d._y??d.y;if(typeof y=="number"&&typeof v=="number"){const T=p-f;if(T>=0){const A=1<<T,D=Math.floor(y/A),$=Math.floor(v/A),k=`${f}_${D}_${$}`;if(i.has(k))continue;i.add(k),e(m,D,$,p)}else{const D=1<<Math.min(-T,this.maxRefineLevels),$=y*D,k=v*D;for(let R=0;R<D;R++)for(let H=0;H<D;H++){const B=$+R,Y=k+H;if(!l(B,Y,f))continue;const G=`${f}_${B}_${Y}`;i.has(G)||(i.add(G),e(m,B,Y,p))}}continue}const P=this.levels[m].size,b=this.Cesium.Math.toDegrees(u.west),C=this.Cesium.Math.toDegrees(u.east),E=this.Cesium.Math.toDegrees(u.south),L=this.Cesium.Math.toDegrees(u.north),M=Math.floor((b- -180)/P),I=Math.floor((C- -180)/P),x=Math.floor((E- -90)/P),S=Math.floor((L- -90)/P);for(let T=M;T<=I;T++)for(let A=x;A<=S;A++){if(!l(T,A,f))continue;const D=`${f}_${T}_${A}`;i.has(D)||(i.add(D),e(m,T,A,p))}}}_processCell(t,e,i,n,s,o){if(o>=this.displayLimit||t<0)return o;t>=this.levels.length&&(t=this.levels.length-1);const r=this._getCellContext(t,e,i,n);return r?(o=this._processCellSkipPoints(r,o),o>=this.displayLimit?(this._debugDrawCell(r),o):(o=this._processCellGroups(r,s,o),this._debugDrawCell(r),o)):o}_getCellContext(t,e,i,n){const o=this.levels[t].level,r=this.gridLayers.get(o);if(!r)return null;const a=`${e}_${i}`,l=r.get(a);if(!l)return null;const d=this.tilingScheme.tileXYToRectangle(e,i,o),u=this.Cesium.Math.toDegrees(d.west),p=this.Cesium.Math.toDegrees(d.south),g=this.Cesium.Math.toDegrees(d.east),m=this.Cesium.Math.toDegrees(d.north),f=(u+g)/2,y=(p+m)/2;return{levelIdx:t,tileLevel:o,lonIdx:e,latIdx:i,key:a,cell:l,rect:d,west:u,south:p,east:g,north:m,centerLon:f,centerLat:y,viewTileLevel:n}}_processCellSkipPoints(t,e){var o;const{cell:i,viewTileLevel:n}=t,s=n;for(const r of i.skipPoints)if(((o=r.data)==null?void 0:o.show)!==!1){if(e>=this.displayLimit)break;this._isVisibleAtLevel(r,s)&&(this.labelPool.add(r.data,{id:`point-${r.id}`,lon:r.lon,lat:r.lat,height:r.height,theme:this._getBillboardTheme(r.data)||this.pointTheme,style:r.style}),e++)}return e}_processCellGroups(t,e,i){var p,g,m,f,y,v,w;const{levelIdx:n,lonIdx:s,latIdx:o,cell:r,centerLon:a,centerLat:l,viewTileLevel:d}=t,u=d;for(const[P,b]of r.groups){const C=b.filter(x=>{var S;return((S=x.data)==null?void 0:S.show)!==!1});if(C.length===0)continue;let E=a,L=l,M=((p=C[0])==null?void 0:p.height)||0;if(this.centralPointMode=="firstPoint"&&(E=((g=C[0])==null?void 0:g.lon)||0,L=((m=C[0])==null?void 0:m.lat)||0,M=((f=C[0])==null?void 0:f.height)||0),n===this.levels.length-1||C.length<e)for(const x of C){if(i>=this.displayLimit)break;this._isVisibleAtLevel(x,u)&&(this.labelPool.add(x.data,{id:`point-${x.id}`,lon:x.lon,lat:x.lat,height:x.height,theme:this._getBillboardTheme(x.data)||this.pointTheme,style:x.style}),i++)}else{if(i>=this.displayLimit)return i;const x=u==null?C:C.filter(D=>this._isVisibleAtLevel(D,u));if(!x.length)return i;const T=this._getBillboardTheme((y=x[0])==null?void 0:y.data)||this.clusterTheme,A=this.groupByTheme?`cluster-${n}-${s}-${o}-${P}`:`cluster-${n}-${s}-${o}`;this.labelPool.add({id:A,billboard:((w=(v=x[0])==null?void 0:v.data)==null?void 0:w.billboard)||[],count:x.length,gridKey:`${s}_${o}`,points:x,aggregationGroup:P},{id:A,lon:E,lat:L,height:M,theme:T}),i++}}return i}_debugDrawCell(t){if(!this.debugCurrentGrids)return;const{levelIdx:e,west:i,south:n,east:s,north:o,lonIdx:r,latIdx:a}=t,l=this.levels[e].level;this._drawDebugGrid(i,n,s,o,`L:${l} X:${r} Y:${a}`)}refresh(){this._update()}_drawDebugGrid(t,e,i,n,s){const o=this.Cesium.Rectangle.fromDegrees(t,e,i,n),r=this.Cesium.Cartesian3.fromDegreesArray([t,e,i,e,i,n,t,n,t,e]),a=this.viewer.entities.add({rectangle:{coordinates:o,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:r,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(a)}_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=(h=>(h.Click="marker:click",h.DoubleClick="marker:dblclick",h.RightClick="marker:rightclick",h.MouseEnter="marker:mouseenter",h.MouseLeave="marker:mouseleave",h.MouseDown="marker:mousedown",h.MouseUp="marker:mouseup",h))(V||{});class nt{constructor(){c(this,"listenerMap",new Map)}addListener(t,e,i=!1){let n=this.listenerMap.get(t);return n||(n=new Map,this.listenerMap.set(t,n)),n.has(e.name)?i?(console.warn(`[MarkerEventBus] Overwriting listener "${e.name}" for event "${t}".`),n.set(e.name,e),!0):(console.warn(`[MarkerEventBus] Listener "${e.name}" for event "${t}" already exists. Use overwrite=true to replace it.`),!1):(n.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 n=this.listenerMap.get(t);if(n)for(const[s,o]of n.entries()){try{o.fn(e,i)}catch(r){console.error(`Error in listener "${s}" for event "${t}":`,r)}o.once&&n.delete(s)}}}const ot={[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",n,s=!0){c(this,"viewer");c(this,"Cesium");c(this,"container");c(this,"labels",new Map);c(this,"activeIds",new Set);c(this,"occludedIds",new Set);c(this,"_updateFn");c(this,"_cameraChangedFn");c(this,"themes",{});c(this,"occlusionCheckLogs",[]);c(this,"occlusionLogEnabled",!1);c(this,"occlusionLogMax",1e4);c(this,"occlusionOptions",{enabled:!1,throttleMs:120,distanceEpsilon:1});c(this,"_occlusionTimer",null);c(this,"_lastOcclusionAt",0);c(this,"_occlusionChecking",!1);c(this,"_occlusionPending",!1);c(this,"eventBus");c(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._cameraChangedFn=this._scheduleOcclusionCheck.bind(this),this.viewer.camera.changed.addEventListener(this._cameraChangedFn),this.eventBus=n||new nt,this.openWheel=s,this.runOcclusionCheckNow()}getAnchorTransform(t="top-left"){return{"top-left":"","top-center":"translate(-50%, 0)","top-right":"translate(-100%, 0)","center-left":"translate(0, -50%)",center:"translate(-50%, -50%)","center-right":"translate(-100%, -50%)","bottom-left":"translate(0, -100%)","bottom-center":"translate(-50%, -100%)","bottom-right":"translate(-100%, -100%)"}[t]||""}_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:n,lat:s,height:o=0,theme:r,show:a=!0,notCreateElement:l=!1,style:d}=e,u=this.themes[r];if(!u){console.warn(`Theme "${r}" not registered`);return}let p=this.labels.get(i);if(p){p.theme=r,p.data=t,p.notCreateElement=l;try{p.unload=u.createElement(p.el,{id:i,theme:r,data:t},u),(!l||a)&&this.container.appendChild(p.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[f,y]of Object.entries(ot)){g.addEventListener(y,w=>{w.stopPropagation();const P=this.labels.get(i);this.eventBus.runListener(f,P,w)});let v=0;g.addEventListener("wheel",w=>{if(!this.openWheel)return;const P=w.currentTarget;v=Date.now();const b=v;P.style.pointerEvents="none",setTimeout(()=>{v===b&&(P.style.pointerEvents="auto")},2e3)})}let m=null;if(!l||a){try{m=u.createElement(g,{id:i,theme:r,data:t},u)||{}}catch(f){console.error(`Error updating label element for id "${i}":`,f)}this.container.appendChild(g)}p={id:i,el:g,theme:r,data:t,notCreateElement:l,unload:m},this.labels.set(i,p)}p.el.dataset.lon=String(n),p.el.dataset.lat=String(s),p.el.dataset.height=String(o),p.offset=e.offset,p.anchor=e.anchor||"top-left",p.el.style.zIndex=(d==null?void 0:d.zIndex)||"1",p.el.style.display=a?"block":"none",a&&this.activeIds.add(i),a?this._scheduleOcclusionCheck():(this.activeIds.delete(i),this.occludedIds.delete(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),this.occludedIds.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(),this.occludedIds.clear()}update(t,e){const i=this.labels.get(t);if(!i){console.warn(`Label with id "${t}" not found for update.`);return}const n=this.themes[i.theme];if(!n){console.warn(`Theme "${i.theme}" not registered.`);return}try{i.data=e,n.createElement(i.el,{id:t,theme:i.theme,data:e},n)}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),this.occludedIds.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),this.occludedIds.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),this.occludedIds.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 n=this.themes[i.theme];if(!n){console.warn(`Theme "${i.theme}" not registered`);return}i.unload=n.createElement(i.el,{id:e,theme:i.theme,data:i.data},n)||{}}catch(n){console.error(`Error creating label element for theme "${i.theme}":`,n);return}i.el.style.display="block",this.activeIds.add(e),this.occludedIds.delete(e)}}this._scheduleOcclusionCheck()}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",this.occludedIds.delete(t))}async toWindowPositionByLonLat(t,e){const i=this.Cesium,n=this.viewer.scene,s=[i.Cartographic.fromDegrees(t,e)];let o;try{o=await n.clampToHeightMostDetailed(s)}catch{console.warn("clampToHeightMostDetailed failed, fallback to ellipsoid height.")}let r=0;o&&o[0]&&o[0].height!=null?r=o[0].height:r=0;const a=i.Cartesian3.fromDegrees(t,e,r);return this.toWindowCoordinates(a)}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 n=parseFloat(i.el.dataset.lon),s=parseFloat(i.el.dataset.lat),o=parseFloat(i.el.dataset.height||"0");if(!this._isValidCoordinate(n,s)){i.el.style.display="none";continue}const r=this.Cesium.Cartesian3.fromDegrees(n,s,o),a=this.toWindowCoordinates(r);if(this.Cesium.defined(a)){const l=this.themes[i.theme],d=i.offset||((t=l.options)==null?void 0:t.offset)||{},u=d.x||0,p=d.y||0,g=this.occludedIds.has(e);i.el.style.left=`${a.x}px`,i.el.style.top=`${a.y}px`;const m=this.getAnchorTransform(i.anchor);i.el.style.transform=`${m}${m?" ":""}translate(${u}px, ${p}px)`,i.el.style.display=g?"none":"block"}else i.el.style.display="none"}}_scheduleOcclusionCheck(){if(!this.occlusionOptions.enabled)return;const t=Date.now(),e=Math.max(0,Number(this.occlusionOptions.throttleMs)||0),i=t-this._lastOcclusionAt,n=Math.max(0,e-i);if(n===0){this.runOcclusionCheckNow();return}this._occlusionTimer===null&&(this._occlusionTimer=window.setTimeout(()=>{this._occlusionTimer=null,this.runOcclusionCheckNow()},n))}_pushOcclusionLog(t){this.occlusionLogEnabled&&(this.occlusionCheckLogs.push(t),this.occlusionCheckLogs.length>this.occlusionLogMax&&this.occlusionCheckLogs.splice(0,this.occlusionCheckLogs.length-this.occlusionLogMax))}_computeLabelOccluded(t,e,i,n,s,o){var d,u;const r=(d=this.viewer)==null?void 0:d.scene,a=(u=this.viewer)==null?void 0:u.camera,l=this.Cesium;if(!r||!a||!l)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"runtime-missing"}),!0;if(!r.pickPositionSupported||!i)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-unsupported"}),!0;try{const p=r.pickPosition(i);if(!p||!a.positionWC)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-empty"}),!0;const g=Number(this.occlusionOptions.distanceEpsilon)||0,m=l.Cartesian3.distance(a.positionWC,e),f=l.Cartesian3.distance(a.positionWC,p),y=f+g<m;return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:y,reason:"distance-compare",epsilon:g,labelDistance:m,pickedDistance:f}),y}catch{return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-error"}),!0}}runOcclusionCheckNow(){if(!this.occlusionOptions.enabled){this.occludedIds.clear();return}if(this._occlusionChecking){this._occlusionPending=!0;return}this._occlusionChecking=!0;try{for(const t of this.activeIds){const e=this.labels.get(t);if(!e){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,occluded:!1,reason:"label-missing"});continue}const i=parseFloat(e.el.dataset.lon),n=parseFloat(e.el.dataset.lat),s=parseFloat(e.el.dataset.height||"0");if(!this._isValidCoordinate(i,n)){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:i,lat:n,height:s,occluded:!1,reason:"invalid-coordinate"});continue}const o=this.Cesium.Cartesian3.fromDegrees(i,n,s),r=this.toWindowCoordinates(o);if(!this.Cesium.defined(r)){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:i,lat:n,height:s,occluded:!1,reason:"screen-position-undefined"});continue}this._computeLabelOccluded(t,o,r,i,n,s)?this.occludedIds.add(t):this.occludedIds.delete(t)}}finally{this._lastOcclusionAt=Date.now(),this._occlusionChecking=!1,this._occlusionPending&&(this._occlusionPending=!1,this._scheduleOcclusionCheck())}}setOcclusionEnabled(t){this.occlusionOptions.enabled=!!t,this.occlusionOptions.enabled?this.runOcclusionCheckNow():(this.occludedIds.clear(),this._occlusionTimer!==null&&(clearTimeout(this._occlusionTimer),this._occlusionTimer=null))}getOcclusionOptions(){return{enabled:this.occlusionOptions.enabled,throttleMs:this.occlusionOptions.throttleMs,distanceEpsilon:this.occlusionOptions.distanceEpsilon}}setOcclusionOptions(t){t.throttleMs!=null&&(this.occlusionOptions.throttleMs=Math.max(0,Number(t.throttleMs)||0)),t.distanceEpsilon!=null&&(this.occlusionOptions.distanceEpsilon=Math.max(0,Number(t.distanceEpsilon)||0)),this.occlusionOptions.enabled&&this._scheduleOcclusionCheck()}setOcclusionLogEnabled(t,e=!1){this.occlusionLogEnabled=!!t,e&&(this.occlusionCheckLogs=[])}destroy(){this.viewer.scene.postRender.removeEventListener(this._updateFn),this.viewer.camera.changed.removeEventListener(this._cameraChangedFn),this._occlusionTimer!==null&&(clearTimeout(this._occlusionTimer),this._occlusionTimer=null),this.labels.clear(),this.activeIds.clear(),this.occludedIds.clear()}}class ce{constructor(){c(this,"tooltipEl");c(this,"visible",!1);c(this,"offsetX",10);c(this,"offsetY",-20);c(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 jt{constructor(t,e){c(this,"Cesium");c(this,"viewer");c(this,"handler",null);c(this,"entity",null);c(this,"tooltip",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.tooltip=new ce,this.tooltip.show("左键添加点"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var p,g;const s=i.scene.pickPosition(n.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(o.longitude),a=e.Math.toDegrees(o.latitude),l=o.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:r,lat:a,height:l},clear:()=>{this.clear()}};(p=t.onComplete)==null||p.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(){var t;(t=this.tooltip)==null||t.hide(),this.tooltip=null,this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.stopDrawing()}}class Vt{constructor(t,e){c(this,"Cesium");c(this,"viewer");c(this,"handler",null);c(this,"positions",[]);c(this,"entity",null);c(this,"tooltip",null);c(this,"tempPoints",[]);c(this,"options",null);c(this,"keydownHandler",null);this.Cesium=t,this.viewer=e}getPickPosition(t){var s,o,r,a;const{viewer:e}=this,i=e==null?void 0:e.scene;if(!i||!t)return null;let n=null;try{i.pickPositionSupported&&(n=i.pickPosition(t))}catch(l){console.warn("[LineDrawer] pickPosition failed:",l)}if(!n){const l=(o=(s=e.camera)==null?void 0:s.getPickRay)==null?void 0:o.call(s,t);l&&(n=((a=(r=i.globe)==null?void 0:r.pick)==null?void 0:a.call(r,l,i))||null)}return n}syncEntity(){if(this.entity){if(this.positions.length===0){this.viewer.entities.remove(this.entity),this.entity=null;return}this.entity.polyline.positions=this.positions.slice()}}undoLastPoint(){if(this.positions.length===0)return;this.positions.pop();const t=this.tempPoints.pop();t&&this.viewer.entities.remove(t),this.syncEntity()}finishDrawing(t=!1){var s,o,r;const{Cesium:e}=this;if(t&&this.positions.length>0){this.positions.length=this.positions.length-1;const a=this.tempPoints.pop();a&&this.viewer.entities.remove(a)}if(this.syncEntity(),this.stopDrawing(),(s=this.tooltip)==null||s.hide(),this.tooltip=null,this.positions.length<2)return;const i=this.positions.map(a=>{const l=e.Cartographic.fromCartesian(a);return{lng:e.Math.toDegrees(l.longitude),lat:e.Math.toDegrees(l.latitude),height:l.height}}),n={entity:this.entity,positions:this.positions,lnglats:i,clear:()=>{this.clear()}};(r=(o=this.options)==null?void 0:o.onComplete)==null||r.call(o,n)}bindKeyboardEvents(){this.unbindKeyboardEvents(),this.keydownHandler=t=>{t.key==="Escape"&&(t.preventDefault(),this.finishDrawing(!1))},document.addEventListener("keydown",this.keydownHandler)}unbindKeyboardEvents(){this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}startDrawing(t){const{Cesium:e,viewer:i}=this;this.options=t,this.positions=[],this.tempPoints=[],this.entity=null,this.tooltip=new ce,this.tooltip.show("单击左键添加点,右键撤销,双击左键或 Esc 结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.bindKeyboardEvents(),this.handler.setInputAction(n=>{var r,a;const s=this.getPickPosition(n.position);if(!s)return;this.positions.push(s);const o=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(o),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:((a=(r=t.color)==null?void 0:r.withAlpha)==null?void 0:a.call(r,.5))||e.Color.YELLOW.withAlpha(.5)}})},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{this.undoLastPoint()},e.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(()=>{this.finishDrawing(!0)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;this.unbindKeyboardEvents(),(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.options=null,this.stopDrawing()}}class Wt{constructor(t,e){c(this,"Cesium");c(this,"viewer");c(this,"handler",null);c(this,"startPoint",null);c(this,"endPoint",null);c(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(n=>{var o;const s=i.scene.pickPosition(n.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 r=e.Cartographic.fromCartesian(this.startPoint),a=e.Cartographic.fromCartesian(this.endPoint),l=Math.min(r.longitude,a.longitude),d=Math.max(r.longitude,a.longitude),u=Math.min(r.latitude,a.latitude),p=Math.max(r.latitude,a.latitude);return new e.Rectangle(l,u,d,p)}catch(r){console.warn("Rectangle calculation error:",r);return}},!1),material:t.color||e.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:e.Color.BLACK,disableDepthTestDistance:Number.POSITIVE_INFINITY}});else{this.stopDrawing();const r=e.Cartographic.fromCartesian(this.startPoint),a=e.Cartographic.fromCartesian(this.endPoint),l={lng:e.Math.toDegrees(Math.min(r.longitude,a.longitude)),lat:e.Math.toDegrees(Math.min(r.latitude,a.latitude)),height:0},d={lng:e.Math.toDegrees(Math.max(r.longitude,a.longitude)),lat:e.Math.toDegrees(Math.max(r.latitude,a.latitude)),height:0},u={entity:this.entity,position:this.startPoint,lnglat:{lng:e.Math.toDegrees(r.longitude),lat:e.Math.toDegrees(r.latitude),height:r.height},positions:[this.startPoint,this.endPoint],lnglats:[l,d],clear:()=>{this.clear()}};(o=t.onComplete)==null||o.call(t,u)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{if(!this.startPoint)return;const s=i.scene.pickPosition(n.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 Ut{constructor(t,e){c(this,"viewer");c(this,"Cesium");c(this,"handler",null);c(this,"entity",null);c(this,"positions",[]);c(this,"_isDrawing",!1);c(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],n=this.viewer.camera.getPickRay(e.endPosition),s=this.viewer.scene.globe.pick(n,this.viewer.scene);s&&this.drawPreviewCircle(i,s,t)},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE)}drawPreviewCircle(t,e,i){const n=this.Cesium.Cartesian3.distance(t,e);if(this.entity)Math.abs(this.currentRadius-n)>.5&&(this.currentRadius=n);else{this.currentRadius=n;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,n=this.Cesium.Cartesian3.distance(e,i),s=this.Cesium.Cartographic.fromCartesian(e),o={lng:this.Cesium.Math.toDegrees(s.longitude),lat:this.Cesium.Math.toDegrees(s.latitude),height:s.height},r=(t==null?void 0:t.step)||1,a=[],l=[];for(let p=0;p<360;p+=r){const g=this.Cesium.Math.toRadians(p),m=new this.Cesium.EllipsoidGeodesic;m.setEndPoints(s,new this.Cesium.Cartographic(s.longitude+1e-4*Math.cos(g),s.latitude+1e-4*Math.sin(g)));const f=m.interpolateUsingSurfaceDistance(n),y=this.Cesium.Ellipsoid.WGS84.cartographicToCartesian(f);a.push(y);const v=this.Cesium.Cartographic.fromCartesian(y);l.push({lng:this.Cesium.Math.toDegrees(v.longitude),lat:this.Cesium.Math.toDegrees(v.latitude),height:v.height})}l.push(l[0]);const d=this.positions.map(p=>{const g=this.Cesium.Cartographic.fromCartesian(p);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:a,circleLnglats:l,center:o,radius:n,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 Kt{constructor(t,e){c(this,"Cesium");c(this,"viewer");c(this,"handler",null);c(this,"positions",[]);c(this,"lnglats",[]);c(this,"entity",null);c(this,"tooltip",null);c(this,"tempPoints",[]);c(this,"options",null);c(this,"keydownHandler",null);this.Cesium=t,this.viewer=e}isHelperPick(t){var e;return((e=t==null?void 0:t.id)==null?void 0:e._drawHelper)===!0}withHiddenHelpers(t){const e=[this.entity,...this.tempPoints].filter(Boolean),i=e.map(n=>n.show);e.forEach(n=>{n.show=!1});try{return t()}finally{e.forEach((n,s)=>{n.show=i[s]})}}getPickPosition(t){var r,a,l,d;const{viewer:e}=this,i=e==null?void 0:e.scene;if(!i||!t)return null;let n=null;const s=i.pick(t),o=this.isHelperPick(s);try{i.pickPositionSupported&&(n=o?this.withHiddenHelpers(()=>i.pickPosition(t)):i.pickPosition(t))}catch(u){console.warn("[PolygonDrawer] pickPosition failed:",u)}if(!n){const u=(a=(r=e.camera)==null?void 0:r.getPickRay)==null?void 0:a.call(r,t);u&&(n=((d=(l=i.globe)==null?void 0:l.pick)==null?void 0:d.call(l,u,i))||null)}return n}syncEntity(){this.entity&&this.positions.length===0&&(this.viewer.entities.remove(this.entity),this.entity=null)}undoLastPoint(){if(this.positions.length===0)return;this.positions.pop(),this.lnglats.pop();const t=this.tempPoints.pop();t&&this.viewer.entities.remove(t),this.syncEntity()}finishDrawing(t=!1){var i,n,s;if(t&&this.positions.length>0){this.positions.length=this.positions.length-1,this.lnglats.length=this.lnglats.length-1;const o=this.tempPoints.pop();o&&this.viewer.entities.remove(o)}if(this.syncEntity(),this.stopDrawing(),(i=this.tooltip)==null||i.hide(),this.tooltip=null,this.positions.length<3)return;const e={entity:this.entity,positions:this.positions,lnglats:this.lnglats.slice(),clear:()=>{this.clear()}};(s=(n=this.options)==null?void 0:n.onComplete)==null||s.call(n,e)}bindKeyboardEvents(){this.unbindKeyboardEvents(),this.keydownHandler=t=>{t.key==="Escape"&&(t.preventDefault(),this.finishDrawing(!1))},document.addEventListener("keydown",this.keydownHandler)}unbindKeyboardEvents(){this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}startDrawing(t){const{Cesium:e,viewer:i}=this;this.options=t,this.positions=[],this.lnglats=[],this.tempPoints=[],this.entity=null,this.tooltip=new ce,this.tooltip.show("单击左键添加点,右键撤销,双击左键或 Esc 结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.bindKeyboardEvents(),this.handler.setInputAction(n=>{const s=this.getPickPosition(n.position);if(!s)return;this.positions.push(s);const o=e.Cartographic.fromCartesian(s);this.lnglats.push({lng:e.Math.toDegrees(o.longitude),lat:e.Math.toDegrees(o.latitude),height:Number.isFinite(o.height)?o.height:0});const r=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});r._drawHelper=!0,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)}}),this.entity._drawHelper=!0)},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{this.undoLastPoint()},e.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(()=>{this.finishDrawing(!0)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;this.unbindKeyboardEvents(),(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.lnglats=[],this.options=null,this.stopDrawing()}}class Xt{constructor(t,e){c(this,"viewer");c(this,"Cesium");c(this,"activeDrawer",null);this.viewer=e,this.Cesium=t}draw(t,e){var i;switch(this.clear(),t){case"point":this.activeDrawer=new jt(this.Cesium,this.viewer);break;case"line":this.activeDrawer=new Vt(this.Cesium,this.viewer);break;case"rectangle":this.activeDrawer=new Wt(this.Cesium,this.viewer);break;case"circle":this.activeDrawer=new Ut(this.Cesium,this.viewer);break;case"polygon":this.activeDrawer=new Kt(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 rt=typeof global=="object"&&global&&global.Object===Object&&global,qt=typeof self=="object"&&self&&self.Object===Object&&self,se=rt||qt||Function("return this")(),ge=se.Symbol,at=Object.prototype,Zt=at.hasOwnProperty,Jt=at.toString,Pe=ge?ge.toStringTag:void 0;function Qt(h){var t=Zt.call(h,Pe),e=h[Pe];try{h[Pe]=void 0;var i=!0}catch{}var n=Jt.call(h);return i&&(t?h[Pe]=e:delete h[Pe]),n}var ei=Object.prototype,ti=ei.toString;function ii(h){return ti.call(h)}var si="[object Null]",ni="[object Undefined]",lt=ge?ge.toStringTag:void 0;function Le(h){return h==null?h===void 0?ni:si:lt&< in Object(h)?Qt(h):ii(h)}function Ee(h){return h!=null&&typeof h=="object"}var Me=Array.isArray;function ke(h){var t=typeof h;return h!=null&&(t=="object"||t=="function")}var oi="[object AsyncFunction]",ri="[object Function]",ai="[object GeneratorFunction]",li="[object Proxy]";function ht(h){if(!ke(h))return!1;var t=Le(h);return t==ri||t==ai||t==oi||t==li}var Be=se["__core-js_shared__"],ct=(function(){var h=/[^.]+$/.exec(Be&&Be.keys&&Be.keys.IE_PROTO||"");return h?"Symbol(src)_1."+h:""})();function hi(h){return!!ct&&ct in h}var ci=Function.prototype,di=ci.toString;function de(h){if(h!=null){try{return di.call(h)}catch{}try{return h+""}catch{}}return""}var ui=/[\\^$.*+?()[\]{}|]/g,pi=/^\[object .+?Constructor\]$/,mi=Function.prototype,gi=Object.prototype,fi=mi.toString,yi=gi.hasOwnProperty,wi=RegExp("^"+fi.call(yi).replace(ui,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function vi(h){if(!ke(h)||hi(h))return!1;var t=ht(h)?wi:pi;return t.test(de(h))}function Ci(h,t){return h==null?void 0:h[t]}function ue(h,t){var e=Ci(h,t);return vi(e)?e:void 0}var Ye=ue(se,"WeakMap"),dt=Object.create,bi=(function(){function h(){}return function(t){if(!ke(t))return{};if(dt)return dt(t);h.prototype=t;var e=new h;return h.prototype=void 0,e}})(),ut=(function(){try{var h=ue(Object,"defineProperty");return h({},"",{}),h}catch{}})();function Pi(h,t){for(var e=-1,i=h==null?0:h.length;++e<i&&t(h[e],e,h)!==!1;);return h}var Li=9007199254740991,Ei=/^(?:0|[1-9]\d*)$/;function Mi(h,t){var e=typeof h;return t=t??Li,!!t&&(e=="number"||e!="symbol"&&Ei.test(h))&&h>-1&&h%1==0&&h<t}function Ii(h,t,e){t=="__proto__"&&ut?ut(h,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):h[t]=e}function pt(h,t){return h===t||h!==h&&t!==t}var xi=Object.prototype,Ti=xi.hasOwnProperty;function _i(h,t,e){var i=h[t];(!(Ti.call(h,t)&&pt(i,e))||e===void 0&&!(t in h))&&Ii(h,t,e)}var Di=9007199254740991;function mt(h){return typeof h=="number"&&h>-1&&h%1==0&&h<=Di}function Si(h){return h!=null&&mt(h.length)&&!ht(h)}var Ai=Object.prototype;function gt(h){var t=h&&h.constructor,e=typeof t=="function"&&t.prototype||Ai;return h===e}function ki(h,t){for(var e=-1,i=Array(h);++e<h;)i[e]=t(e);return i}var $i="[object Arguments]";function ft(h){return Ee(h)&&Le(h)==$i}var yt=Object.prototype,Ri=yt.hasOwnProperty,Oi=yt.propertyIsEnumerable,Hi=ft((function(){return arguments})())?ft:function(h){return Ee(h)&&Ri.call(h,"callee")&&!Oi.call(h,"callee")};function Fi(){return!1}var wt=typeof _=="object"&&_&&!_.nodeType&&_,vt=wt&&typeof module=="object"&&module&&!module.nodeType&&module,zi=vt&&vt.exports===wt,Ct=zi?se.Buffer:void 0,Ni=Ct?Ct.isBuffer:void 0,bt=Ni||Fi,Gi="[object Arguments]",Bi="[object Array]",Yi="[object Boolean]",ji="[object Date]",Vi="[object Error]",Wi="[object Function]",Ui="[object Map]",Ki="[object Number]",Xi="[object Object]",qi="[object RegExp]",Zi="[object Set]",Ji="[object String]",Qi="[object WeakMap]",es="[object ArrayBuffer]",ts="[object DataView]",is="[object Float32Array]",ss="[object Float64Array]",ns="[object Int8Array]",os="[object Int16Array]",rs="[object Int32Array]",as="[object Uint8Array]",ls="[object Uint8ClampedArray]",hs="[object Uint16Array]",cs="[object Uint32Array]",z={};z[is]=z[ss]=z[ns]=z[os]=z[rs]=z[as]=z[ls]=z[hs]=z[cs]=!0,z[Gi]=z[Bi]=z[es]=z[Yi]=z[ts]=z[ji]=z[Vi]=z[Wi]=z[Ui]=z[Ki]=z[Xi]=z[qi]=z[Zi]=z[Ji]=z[Qi]=!1;function ds(h){return Ee(h)&&mt(h.length)&&!!z[Le(h)]}function je(h){return function(t){return h(t)}}var Pt=typeof _=="object"&&_&&!_.nodeType&&_,Ie=Pt&&typeof module=="object"&&module&&!module.nodeType&&module,us=Ie&&Ie.exports===Pt,Ve=us&&rt.process,fe=(function(){try{var h=Ie&&Ie.require&&Ie.require("util").types;return h||Ve&&Ve.binding&&Ve.binding("util")}catch{}})(),Lt=fe&&fe.isTypedArray,ps=Lt?je(Lt):ds,ms=Object.prototype,gs=ms.hasOwnProperty;function fs(h,t){var e=Me(h),i=!e&&Hi(h),n=!e&&!i&&bt(h),s=!e&&!i&&!n&&ps(h),o=e||i||n||s,r=o?ki(h.length,String):[],a=r.length;for(var l in h)gs.call(h,l)&&!(o&&(l=="length"||n&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Mi(l,a)))&&r.push(l);return r}function Et(h,t){return function(e){return h(t(e))}}var ys=Et(Object.keys,Object),ws=Object.prototype,vs=ws.hasOwnProperty;function Cs(h){if(!gt(h))return ys(h);var t=[];for(var e in Object(h))vs.call(h,e)&&e!="constructor"&&t.push(e);return t}function bs(h){return Si(h)?fs(h):Cs(h)}var xe=ue(Object,"create");function Ps(){this.__data__=xe?xe(null):{},this.size=0}function Ls(h){var t=this.has(h)&&delete this.__data__[h];return this.size-=t?1:0,t}var Es="__lodash_hash_undefined__",Ms=Object.prototype,Is=Ms.hasOwnProperty;function xs(h){var t=this.__data__;if(xe){var e=t[h];return e===Es?void 0:e}return Is.call(t,h)?t[h]:void 0}var Ts=Object.prototype,_s=Ts.hasOwnProperty;function Ds(h){var t=this.__data__;return xe?t[h]!==void 0:_s.call(t,h)}var Ss="__lodash_hash_undefined__";function As(h,t){var e=this.__data__;return this.size+=this.has(h)?0:1,e[h]=xe&&t===void 0?Ss:t,this}function pe(h){var t=-1,e=h==null?0:h.length;for(this.clear();++t<e;){var i=h[t];this.set(i[0],i[1])}}pe.prototype.clear=Ps,pe.prototype.delete=Ls,pe.prototype.get=xs,pe.prototype.has=Ds,pe.prototype.set=As;function ks(){this.__data__=[],this.size=0}function $e(h,t){for(var e=h.length;e--;)if(pt(h[e][0],t))return e;return-1}var $s=Array.prototype,Rs=$s.splice;function Os(h){var t=this.__data__,e=$e(t,h);if(e<0)return!1;var i=t.length-1;return e==i?t.pop():Rs.call(t,e,1),--this.size,!0}function Hs(h){var t=this.__data__,e=$e(t,h);return e<0?void 0:t[e][1]}function Fs(h){return $e(this.__data__,h)>-1}function zs(h,t){var e=this.__data__,i=$e(e,h);return i<0?(++this.size,e.push([h,t])):e[i][1]=t,this}function oe(h){var t=-1,e=h==null?0:h.length;for(this.clear();++t<e;){var i=h[t];this.set(i[0],i[1])}}oe.prototype.clear=ks,oe.prototype.delete=Os,oe.prototype.get=Hs,oe.prototype.has=Fs,oe.prototype.set=zs;var Te=ue(se,"Map");function Ns(){this.size=0,this.__data__={hash:new pe,map:new(Te||oe),string:new pe}}function Gs(h){var t=typeof h;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?h!=="__proto__":h===null}function Re(h,t){var e=h.__data__;return Gs(t)?e[typeof t=="string"?"string":"hash"]:e.map}function Bs(h){var t=Re(this,h).delete(h);return this.size-=t?1:0,t}function Ys(h){return Re(this,h).get(h)}function js(h){return Re(this,h).has(h)}function Vs(h,t){var e=Re(this,h),i=e.size;return e.set(h,t),this.size+=e.size==i?0:1,this}function ye(h){var t=-1,e=h==null?0:h.length;for(this.clear();++t<e;){var i=h[t];this.set(i[0],i[1])}}ye.prototype.clear=Ns,ye.prototype.delete=Bs,ye.prototype.get=Ys,ye.prototype.has=js,ye.prototype.set=Vs;function Ws(h,t){for(var e=-1,i=t.length,n=h.length;++e<i;)h[n+e]=t[e];return h}var Us=Et(Object.getPrototypeOf,Object);function Ks(){this.__data__=new oe,this.size=0}function Xs(h){var t=this.__data__,e=t.delete(h);return this.size=t.size,e}function qs(h){return this.__data__.get(h)}function Zs(h){return this.__data__.has(h)}var Js=200;function Qs(h,t){var e=this.__data__;if(e instanceof oe){var i=e.__data__;if(!Te||i.length<Js-1)return i.push([h,t]),this.size=++e.size,this;e=this.__data__=new ye(i)}return e.set(h,t),this.size=e.size,this}function we(h){var t=this.__data__=new oe(h);this.size=t.size}we.prototype.clear=Ks,we.prototype.delete=Xs,we.prototype.get=qs,we.prototype.has=Zs,we.prototype.set=Qs;var Mt=typeof _=="object"&&_&&!_.nodeType&&_,It=Mt&&typeof module=="object"&&module&&!module.nodeType&&module,en=It&&It.exports===Mt,xt=en?se.Buffer:void 0;xt&&xt.allocUnsafe;function tn(h,t){return h.slice()}function sn(h,t){for(var e=-1,i=h==null?0:h.length,n=0,s=[];++e<i;){var o=h[e];t(o,e,h)&&(s[n++]=o)}return s}function nn(){return[]}var on=Object.prototype,rn=on.propertyIsEnumerable,Tt=Object.getOwnPropertySymbols,an=Tt?function(h){return h==null?[]:(h=Object(h),sn(Tt(h),function(t){return rn.call(h,t)}))}:nn;function ln(h,t,e){var i=t(h);return Me(h)?i:Ws(i,e(h))}function hn(h){return ln(h,bs,an)}var We=ue(se,"DataView"),Ue=ue(se,"Promise"),Ke=ue(se,"Set"),_t="[object Map]",cn="[object Object]",Dt="[object Promise]",St="[object Set]",At="[object WeakMap]",kt="[object DataView]",dn=de(We),un=de(Te),pn=de(Ue),mn=de(Ke),gn=de(Ye),re=Le;(We&&re(new We(new ArrayBuffer(1)))!=kt||Te&&re(new Te)!=_t||Ue&&re(Ue.resolve())!=Dt||Ke&&re(new Ke)!=St||Ye&&re(new Ye)!=At)&&(re=function(h){var t=Le(h),e=t==cn?h.constructor:void 0,i=e?de(e):"";if(i)switch(i){case dn:return kt;case un:return _t;case pn:return Dt;case mn:return St;case gn:return At}return t});var fn=Object.prototype,yn=fn.hasOwnProperty;function wn(h){var t=h.length,e=new h.constructor(t);return t&&typeof h[0]=="string"&&yn.call(h,"index")&&(e.index=h.index,e.input=h.input),e}var $t=se.Uint8Array;function Xe(h){var t=new h.constructor(h.byteLength);return new $t(t).set(new $t(h)),t}function vn(h,t){var e=Xe(h.buffer);return new h.constructor(e,h.byteOffset,h.byteLength)}var Cn=/\w*$/;function bn(h){var t=new h.constructor(h.source,Cn.exec(h));return t.lastIndex=h.lastIndex,t}var Rt=ge?ge.prototype:void 0,Ot=Rt?Rt.valueOf:void 0;function Pn(h){return Ot?Object(Ot.call(h)):{}}function Ln(h,t){var e=Xe(h.buffer);return new h.constructor(e,h.byteOffset,h.length)}var En="[object Boolean]",Mn="[object Date]",In="[object Map]",xn="[object Number]",Tn="[object RegExp]",_n="[object Set]",Dn="[object String]",Sn="[object Symbol]",An="[object ArrayBuffer]",kn="[object DataView]",$n="[object Float32Array]",Rn="[object Float64Array]",On="[object Int8Array]",Hn="[object Int16Array]",Fn="[object Int32Array]",zn="[object Uint8Array]",Nn="[object Uint8ClampedArray]",Gn="[object Uint16Array]",Bn="[object Uint32Array]";function Yn(h,t,e){var i=h.constructor;switch(t){case An:return Xe(h);case En:case Mn:return new i(+h);case kn:return vn(h);case $n:case Rn:case On:case Hn:case Fn:case zn:case Nn:case Gn:case Bn:return Ln(h);case In:return new i;case xn:case Dn:return new i(h);case Tn:return bn(h);case _n:return new i;case Sn:return Pn(h)}}function jn(h){return typeof h.constructor=="function"&&!gt(h)?bi(Us(h)):{}}var Vn="[object Map]";function Wn(h){return Ee(h)&&re(h)==Vn}var Ht=fe&&fe.isMap,Un=Ht?je(Ht):Wn,Kn="[object Set]";function Xn(h){return Ee(h)&&re(h)==Kn}var Ft=fe&&fe.isSet,qn=Ft?je(Ft):Xn,zt="[object Arguments]",Zn="[object Array]",Jn="[object Boolean]",Qn="[object Date]",eo="[object Error]",Nt="[object Function]",to="[object GeneratorFunction]",io="[object Map]",so="[object Number]",Gt="[object Object]",no="[object RegExp]",oo="[object Set]",ro="[object String]",ao="[object Symbol]",lo="[object WeakMap]",ho="[object ArrayBuffer]",co="[object DataView]",uo="[object Float32Array]",po="[object Float64Array]",mo="[object Int8Array]",go="[object Int16Array]",fo="[object Int32Array]",yo="[object Uint8Array]",wo="[object Uint8ClampedArray]",vo="[object Uint16Array]",Co="[object Uint32Array]",F={};F[zt]=F[Zn]=F[ho]=F[co]=F[Jn]=F[Qn]=F[uo]=F[po]=F[mo]=F[go]=F[fo]=F[io]=F[so]=F[Gt]=F[no]=F[oo]=F[ro]=F[ao]=F[yo]=F[wo]=F[vo]=F[Co]=!0,F[eo]=F[Nt]=F[lo]=!1;function Oe(h,t,e,i,n,s){var o;if(o!==void 0)return o;if(!ke(h))return h;var r=Me(h);if(r)o=wn(h);else{var a=re(h),l=a==Nt||a==to;if(bt(h))return tn(h);if(a==Gt||a==zt||l&&!n)o=l?{}:jn(h);else{if(!F[a])return n?h:{};o=Yn(h,a)}}s||(s=new we);var d=s.get(h);if(d)return d;s.set(h,o),qn(h)?h.forEach(function(g){o.add(Oe(g,t,e,g,h,s))}):Un(h)&&h.forEach(function(g,m){o.set(m,Oe(g,t,e,m,h,s))});var u=hn,p=r?void 0:u(h);return Pi(p||h,function(g,m){p&&(m=g,g=h[m]),_i(o,m,Oe(g,t,e,m,h,s))}),o}var bo=1,Po=4;function He(h){return Oe(h,bo|Po)}var Bt=(h=>(h.Rotate="rotate",h.Move="move",h.Scale="scale",h.MoveHeight="moveHeight",h.Empty="",h))(Bt||{}),Yt=(h=>(h.Scale="addScale",h.Rotate="rotate",h.Translation="translation",h.Remove="removeById",h.Add="add",h))(Yt||{});class Lo{constructor(t){c(this,"primitives",new Map);c(this,"eventListener",new Map);c(this,"Cesium");c(this,"viewer");c(this,"handler");c(this,"rotationRing");c(this,"moveAxis");c(this,"translationSquare");c(this,"heightArrow");c(this,"scaleHandle");c(this,"scaleCenterProxy");c(this,"editMode","");c(this,"dragEndCallbackMap",new Map);c(this,"activeModelId","");c(this,"activeModelVisualState",new Map);c(this,"overlayContainer",null);c(this,"modeToolbarEl",null);c(this,"feedbackLabelEl",null);c(this,"overlayUpdateFn",null);c(this,"feedbackAnchor",null);c(this,"tooltipManager",null);c(this,"tooltipHideTimer",null);c(this,"scaleCenterHintVisible",!1);this.Cesium=t.Cesium,this.viewer=t.viewer,this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.initOverlay(),typeof document<"u"&&(this.tooltipManager=new ce)}isSceneGadgetDebugEnabled(){var t;if(typeof window>"u")return!1;try{return window.__SCENE_GADGET_DEBUG__===!0||((t=window.localStorage)==null?void 0:t.getItem("sceneGadgetDebug"))==="1"}catch{return!1}}debugLog(t,e){this.isSceneGadgetDebugEnabled()&&console.log("[SceneGadget][GLTFManage]",t,e||{})}getPickDebugId(t){var i,n,s;if(!t)return null;const e=(t==null?void 0:t.id)||((i=t==null?void 0:t.primitive)==null?void 0:i.id)||null;return typeof e=="string"?e:e&&typeof(e==null?void 0:e.id)=="string"?e.id:e&&typeof(e==null?void 0:e.name)=="string"?e.name:(s=(n=t==null?void 0:t.primitive)==null?void 0:n.constructor)!=null&&s.name?`[primitive:${t.primitive.constructor.name}]`:String(e)}debugPickStack(t,e){var n;if(!this.isSceneGadgetDebugEnabled())return;const i=(n=this.viewer)==null?void 0:n.scene;if(!(!(i!=null&&i.drillPick)||!t))try{const s=i.drillPick(t,12)||[];this.debugLog("pick-stack",{mode:e,activeModelId:this.activeModelId,stack:s.map((o,r)=>({index:r,id:this.getPickDebugId(o)}))})}catch(s){this.debugLog("pick-stack:error",{mode:e,message:s instanceof Error?s.message:String(s)})}}showModeHint(t,e=2200){!this.tooltipManager||!t||(this.scaleCenterHintVisible=!0,this.tooltipManager.show(t),this.tooltipHideTimer&&clearTimeout(this.tooltipHideTimer),this.tooltipHideTimer=setTimeout(()=>{this.hideModeHint()},e))}showHoverModeHint(t){!this.tooltipManager||!t||(this.tooltipHideTimer&&(clearTimeout(this.tooltipHideTimer),this.tooltipHideTimer=null),this.tooltipManager.show(t),this.scaleCenterHintVisible=!0)}hideModeHint(){var t;this.tooltipHideTimer&&(clearTimeout(this.tooltipHideTimer),this.tooltipHideTimer=null),(t=this.tooltipManager)==null||t.hide(),this.scaleCenterHintVisible=!1}init(t,e=!1){const i=this.viewer;this.primitives.forEach(n=>{i.scene.primitives.remove(n)}),t.forEach(n=>{this.primitives.has(n.id)||this.add(n,e)})}get(t){return this.primitives.get(t)}async add(t,e=!0){var g,m,f,y,v;const i=this.viewer,n=this.Cesium,s=n.Math.toRadians(((g=t.headingPitchRoll)==null?void 0:g.heading)||0),o=n.Math.toRadians(((m=t.headingPitchRoll)==null?void 0:m.pitch)||0),r=n.Math.toRadians(((f=t.headingPitchRoll)==null?void 0:f.roll)||0),a=new n.HeadingPitchRoll(s,o,r);let l=t.position;if(Me(l)?l=n.Cartesian3.fromDegrees(l[0],l[1],l[2]||0):l&&typeof l=="object"&&typeof l.lng<"u"&&typeof l.lat<"u"&&(l=n.Cartesian3.fromDegrees(l.lng,l.lat,l.height||0)),!l)throw new Error("GLTFManage.add 缺少有效 position");const d=this.composeModelMatrix(l,a,t.scale),u={id:t.id,...t.model,modelMatrix:d};let p;if(typeof((y=n==null?void 0:n.Model)==null?void 0:y.fromGltf)=="function")p=i.scene.primitives.add(n.Model.fromGltf(u));else if(typeof((v=n==null?void 0:n.Model)==null?void 0:v.fromGltfAsync)=="function"){const w=await n.Model.fromGltfAsync(u);p=i.scene.primitives.add(w)}else throw new Error("Cesium.Model.fromGltf / fromGltfAsync 均不可用");p.scale=1,p.__sceneGadgetScale=this.getPrimitiveScale({modelMatrix:d}),this.initializePrimitiveRuntimeState(p),this.primitives.set(t.id,p),p.show=e,this.runEventListener("add",{info:t,gltf:p})}flyTo(t){const e=this.viewer;let i=this.primitives.get(t);const n=this.Cesium,s=this.getPrimitiveWorldBoundingSphere(i);s&&e.camera.flyToBoundingSphere(s,{duration:1.5,offset:new n.HeadingPitchRange(0,-.5,Math.max(s.radius*2.8,60))})}removeById(t){const e=this.viewer;let i=this.primitives.get(t);if(!i){console.error(`No model found with id: ${t}`);return}this.activeModelId===t&&this.deactivateEdit(),e.scene.primitives.remove(i),this.primitives.delete(t),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);if(i){const n=this.getPrimitiveScale(i),s={x:n.x+e,y:n.y+e,z:n.z+e};this.applyScaleToPrimitive(i,s),this.activeModelId===t.id?this.refreshActiveToolGeometry():this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t.id,scale:s})}}setScale(t,e=.1){let i=this.primitives.get(t);if(i){const n={x:e,y:e,z:e};this.applyScaleToPrimitive(i,n),this.activeModelId===t?this.refreshActiveToolGeometry():this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t,scale:n})}}setEditMode(t){this.editMode=t,this.updateToolbarState()}normalizeScaleVector(t){const e=this.Cesium;if(typeof t=="number"){const i=Number(t||1);return new e.Cartesian3(i,i,i)}return new e.Cartesian3(Number((t==null?void 0:t.x)??1),Number((t==null?void 0:t.y)??1),Number((t==null?void 0:t.z)??1))}getPrimitiveScale(t){const e=this.Cesium;if(!t)return{x:1,y:1,z:1};if(t.__sceneGadgetScale)return{x:Number(t.__sceneGadgetScale.x??1),y:Number(t.__sceneGadgetScale.y??1),z:Number(t.__sceneGadgetScale.z??1)};const i=e.Matrix4.getScale(t.modelMatrix,new e.Cartesian3);return{x:Number(i.x||1),y:Number(i.y||1),z:Number(i.z||1)}}initializePrimitiveRuntimeState(t){var i,n;if(!t)return;const e=()=>{const s=this.getPrimitiveRuntimeRadius(t);s>0&&(t.__sceneGadgetRuntimeRadiusReady=!0,this.cachePrimitiveUnitRadius(t,s))};if(e(),!t.__sceneGadgetRuntimeRadiusReady&&typeof((i=t==null?void 0:t.readyPromise)==null?void 0:i.then)=="function"){t.readyPromise.then(()=>{e()}).catch(()=>{});return}!t.__sceneGadgetRuntimeRadiusReady&&typeof((n=t==null?void 0:t.readyEvent)==null?void 0:n.addEventListener)=="function"&&t.readyEvent.addEventListener(()=>{e()})}getPrimitiveRuntimeRadius(t){var e;if(!t)return 0;try{const i=Number(((e=t==null?void 0:t.boundingSphere)==null?void 0:e.radius)||0);if(Number.isFinite(i)&&i>0)return i}catch{return 0}return 0}cachePrimitiveUnitRadius(t,e){if(!t)return 0;const i=Number(t.__sceneGadgetUnitRadius||0);if(Number.isFinite(i)&&i>0)return i;const n=Number(e||this.getPrimitiveRuntimeRadius(t)||0);if(!Number.isFinite(n)||n<=0)return 0;const s=this.getPrimitiveScale(t),o=Math.max(Math.abs(Number(s.x||1)),Math.abs(Number(s.y||1)),Math.abs(Number(s.z||1)),1),r=n/o;return t.__sceneGadgetUnitRadius=r,r}getPrimitiveFallbackRadius(t){if(!t)return 1;const e=this.getPrimitiveScale(t);return Math.max(Math.abs(Number(e.x||1)),Math.abs(Number(e.y||1)),Math.abs(Number(e.z||1)),1)}getPrimitiveEffectiveRadius(t){const e=this.cachePrimitiveUnitRadius(t);if(e>0){const i=this.getPrimitiveScale(t),n=Math.max(Math.abs(Number(i.x||1)),Math.abs(Number(i.y||1)),Math.abs(Number(i.z||1)),1);return Math.max(e*n,e,1)}return Math.max(this.getPrimitiveRuntimeRadius(t),this.getPrimitiveFallbackRadius(t),1)}getPrimitiveWorldBoundingSphere(t){const e=this.Cesium;if(!(t!=null&&t.modelMatrix))return null;const i=e.Matrix4.getTranslation(t.modelMatrix,new e.Cartesian3),n=this.getPrimitiveEffectiveRadius(t);return!Number.isFinite(n)||n<=0?null:new e.BoundingSphere(i,n)}extractModelBaseMatrix(t){const e=this.Cesium,i=e.Matrix4.getScale(t,new e.Cartesian3),n=new e.Cartesian3(Math.abs(i.x)<1e-6?1:1/i.x,Math.abs(i.y)<1e-6?1:1/i.y,Math.abs(i.z)<1e-6?1:1/i.z);return e.Matrix4.multiply(t,e.Matrix4.fromScale(n),new e.Matrix4)}composeModelMatrix(t,e,i){const n=this.Cesium,s=n.Transforms.headingPitchRollToFixedFrame(t,e,this.viewer.scene.globe.ellipsoid,n.Transforms.eastNorthUpToFixedFrame,new n.Matrix4);return n.Matrix4.multiply(s,n.Matrix4.fromScale(this.normalizeScaleVector(i)),new n.Matrix4)}applyScaleToPrimitive(t,e,i){const n=this.Cesium,s=this.getPrimitiveScale(t),o=this.getPrimitiveRuntimeRadius(t),r=this.getPrimitiveEffectiveRadius(t),a=this.cachePrimitiveUnitRadius(t,o),l=this.normalizeScaleVector(e),d=i||this.extractModelBaseMatrix(t.modelMatrix);t.__sceneGadgetScale={x:l.x,y:l.y,z:l.z},t.scale=1,t.modelMatrix=n.Matrix4.multiply(d,n.Matrix4.fromScale(l),new n.Matrix4);const u=this.getPrimitiveScale(t),p=this.getPrimitiveRuntimeRadius(t),g=this.getPrimitiveEffectiveRadius(t);return this.debugLog("applyScaleToPrimitive",{id:t==null?void 0:t.id,inputScale:e,unitRadius:a,beforeScale:s,afterScale:u,beforeRadius:o,afterRadius:p,beforeEffectiveRadius:r,afterEffectiveRadius:g}),t.modelMatrix}getGizmoModelMatrix(t){return this.extractModelBaseMatrix(t.modelMatrix)}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,n=e.latitude-t.latitude;return Math.atan2(n,i)}getModelHeadingPitchRoll(t){const e=this.Cesium,i=this.viewer,n=this.extractModelBaseMatrix(t),s=e.Transforms.eastNorthUpToFixedFrame(e.Matrix4.getTranslation(n,new e.Cartesian3),i.scene.globe.ellipsoid,new e.Matrix4),o=e.Matrix4.multiply(e.Matrix4.inverse(s,new e.Matrix4),n,new e.Matrix4),r=e.Matrix4.getRotation(o,new e.Matrix3),a=e.Quaternion.fromRotationMatrix(r);return e.HeadingPitchRoll.fromQuaternion(a)}addEventListener(t,e,i){let n={f:e,options:i};return this.eventListener.get(t)?(this.eventListener.get(t)||[]).push(n):this.eventListener.set(t,[n]),n}removeEventListener(t,e){let i=this.eventListener.get(t);if(!i)return console.error("key不存在");let n=i.findIndex(s=>s==e);n>=0?i.splice(n,1):console.error("instantiation不存在")}runEventListener(t,e){let i=this.eventListener.get(t);return i?(i.forEach(n=>{typeof n.f=="function"&&n.f(e)}),!0):!1}initEditBox(t){const e=this.Cesium,i=this.viewer,n=i.scene;let s=null,o=null,r=null,a=null,l="",d="",u=null,p=null,g=null,m=null;const f=()=>{s=null,o=null,r=null,a=null,l="",d="",u=null,p=null,g=null,m=null,this.hideFeedback(),this.unlockCamera()},y=P=>{const b=C=>(P.split(C)[1]||"").split("_");if(P.includes("moveAxis_")){const C=b("moveAxis_");return{modelId:C[0],mode:"move",axis:String(C[1]||"").toUpperCase()}}if(P.includes("translationPlane_")){const C=b("translationPlane_");return{modelId:C[0],mode:"move",axis:String(C[1]||"").toUpperCase()}}if(P.includes("rotationArc_")){const C=b("rotationArc_");return{modelId:C[0],mode:"rotate",axis:String(C[1]||"").toUpperCase()}}if(P.includes("rotationSector_")){const C=b("rotationSector_");return{modelId:C[0],mode:"rotate",axis:String(C[1]||"").toUpperCase()}}if(P.includes("scaleHandle_")){const C=b("scaleHandle_");return{modelId:C[0],mode:"scale",axis:String(C[1]||"").toUpperCase()}}if(P.includes("scaleAxis_")){const C=b("scaleAxis_");return{modelId:C[0],mode:"scale",axis:String(C[1]||"").toUpperCase()}}return P.includes("scaleCenter_")?{modelId:b("scaleCenter_")[0],mode:"scale",axis:"CENTER"}:P.includes("scaleCenterHit_")?{modelId:b("scaleCenterHit_")[0],mode:"scale",axis:"CENTER"}:null},v=P=>{if(this.editMode!=="scale"||!this.activeModelId||!P||!(n!=null&&n.drillPick))return!1;try{return(n.drillPick(P,12)||[]).some(C=>{const E=this.getPickDebugId(C);if(typeof E!="string")return!1;const L=y(E);return(L==null?void 0:L.mode)==="scale"&&(L==null?void 0:L.axis)==="CENTER"&&(L==null?void 0:L.modelId)===this.activeModelId})}catch{return!1}},w=(P,b,C,E)=>{if(s=this.primitives.get(P),s){l=C,d=E,o=e.Matrix4.clone(s.modelMatrix),a=this.normalizeScaleVector(this.getPrimitiveScale(s));const L=e.Matrix4.getTranslation(o,new e.Cartesian3);g=e.Cartesian3.clone(L),r=e.Cartesian2.clone(b.position||b.endPosition,new e.Cartesian2);const M=e.Transforms.eastNorthUpToFixedFrame(g);let I=new e.Cartesian3;C==="move"?E==="XY"?e.Matrix4.getColumn(M,2,I):E==="YZ"?e.Matrix4.getColumn(M,0,I):E==="ZX"?e.Matrix4.getColumn(M,1,I):I=e.Cartesian3.clone(i.scene.camera.direction):C==="rotate"?(E==="X"&&e.Matrix4.getColumn(M,0,I),E==="Y"&&e.Matrix4.getColumn(M,1,I),E==="Z"&&e.Matrix4.getColumn(M,2,I)):I=e.Cartesian3.clone(i.scene.camera.direction),e.Cartesian3.normalize(I,I),u=e.Plane.fromPointNormal(g,I);const x=i.camera.getPickRay(b.position||b.endPosition);p=x&&u?e.IntersectionTests.rayPlane(x,u):null,p&&(m=e.Cartesian3.subtract(p,g,new e.Cartesian3),e.Cartesian3.magnitudeSquared(m)>0&&e.Cartesian3.normalize(m,m)),this.lockCamera()}};this.handler.setInputAction(P=>{var M,I;if(!t())return;(this.editMode==="scale"||this.editMode==="move")&&this.debugPickStack(P.position,this.editMode);const C=n.pick(P.position),E=(C==null?void 0:C.id)||((M=C==null?void 0:C.primitive)==null?void 0:M.id);if(typeof E!="string"){this.editMode==="scale"&&this.debugLog("scale:leftDown:miss",{activeModelId:this.activeModelId,pickedPrimitiveId:(I=C==null?void 0:C.primitive)==null?void 0:I.id,pickedId:C==null?void 0:C.id});return}let L=y(E);this.editMode==="scale"&&this.debugLog("scale:leftDown:hit",{activeModelId:this.activeModelId,hitId:E,hitInfo:L}),L!=null&&L.modelId&&(this.setEditMode(L.mode),w(L.modelId,P,L.mode,L.axis),L.mode==="scale"&&L.axis==="CENTER"&&this.debugLog("scale:center:drag-start",{modelId:L.modelId,startMousePosition:P.position}))},e.ScreenSpaceEventType.LEFT_DOWN),this.handler.setInputAction(P=>{if(t()&&(l===""?v(P.endPosition)?this.showHoverModeHint("向上拖放大,向下拖缩小"):this.scaleCenterHintVisible&&this.hideModeHint():this.scaleCenterHintVisible&&this.hideModeHint(),l!=""&&s&&u&&g&&p)){const C=i.camera.getPickRay(P.endPosition),E=C?e.IntersectionTests.rayPlane(C,u):null;if(!E)return;l==="rotate"?this.rotateModel(s,o,d,g,m,E):l==="move"?this.moveModel(s,o,d,g,p,E):l==="scale"&&this.moveModelScale(s,o,d,g,r,p,a,P.endPosition,E)}},e.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(()=>{if(!t())return;let b=this.dragEndCallbackMap.get(s==null?void 0:s.id);if(b&&(l==="move"||l==="moveHeight")){let C=b.get("translation");C&&(this.runEventListener("translation",C),b.delete("translation"))}else if(b&&l==="rotate"){let C=b.get("rotate");C&&(this.runEventListener("rotate",C),b.delete("rotate"))}else if(b&&l==="scale"){let C=b.get("addScale");C&&(this.runEventListener("addScale",C),b.delete("addScale"))}f()},e.ScreenSpaceEventType.LEFT_UP),this.handler.setInputAction(()=>{f()},e.ScreenSpaceEventType.RIGHT_UP)}activateEditById(t,e){var s,o;const i=this.primitives.get(t);if(!i)return;const n=this.getPrimitiveRuntimeRadius(i);if(!Number.isFinite(n)||n<=0){typeof((s=i==null?void 0:i.readyPromise)==null?void 0:s.then)=="function"?i.readyPromise.then(()=>this.activateEditById(t,e)).catch(()=>{}):typeof((o=i==null?void 0:i.readyEvent)==null?void 0:o.addEventListener)=="function"&&i.readyEvent.addEventListener(()=>this.activateEditById(t,e));return}this.activeModelId&&this.activeModelId!==t&&this.deactivateEdit(!1),this.activeModelId=t,this.highlightModel(i,!0),this.showModeToolbar(t),this.switchEditMode(e||this.editMode||"move")}deactivateEdit(t=!0){this.removeTool(),this.clearActiveModelVisual(),this.hideModeToolbar(),this.hideFeedback(),this.hideModeHint(),this.activeModelId="",t&&this.setEditMode(""),this.unlockCamera()}switchEditMode(t){if(!t)return;const e=t==="moveHeight"?"move":t;this.setEditMode(e),this.refreshActiveToolGeometry(),this.updateOverlayPosition(),e!=="scale"&&this.hideModeHint()}refreshActiveToolGeometry(){const t=this.activeModelId?this.primitives.get(this.activeModelId):null;this.removeTool(),t&&(this.editMode==="move"?(this.createMoveAxis(t),this.createTranslationSquare(t)):this.editMode==="rotate"?this.createRotationRing(t):this.editMode==="scale"&&this.createScaleHandle(t))}highlightModel(t,e){if(!t)return;if(e){this.activeModelVisualState.has(t.id)||this.activeModelVisualState.set(t.id,{silhouetteColor:t.silhouetteColor,silhouetteSize:t.silhouetteSize}),t.silhouetteSize=0;return}const i=this.activeModelVisualState.get(t.id);i?(t.silhouetteColor=i.silhouetteColor,t.silhouetteSize=i.silhouetteSize,this.activeModelVisualState.delete(t.id)):t.silhouetteSize=0}clearActiveModelVisual(){if(!this.activeModelId)return;const t=this.primitives.get(this.activeModelId);if(t){this.highlightModel(t,!1);return}this.activeModelVisualState.delete(this.activeModelId)}initOverlay(){var r;if(typeof document>"u")return;const t=document.createElement("div");t.className="scene-gadget-gizmo-overlay",Object.assign(t.style,{position:"absolute",inset:"0",pointerEvents:"none",zIndex:"120"});const e=((r=this.viewer)==null?void 0:r.container)||document.body,i=window.getComputedStyle(e);e!==document.body&&i.position==="static"&&(e.style.position="relative");const n=document.createElement("div");Object.assign(n.style,{position:"absolute",display:"none",gap:"10px",flexDirection:"column",alignItems:"stretch",padding:"10px 8px",borderRadius:"14px",background:"rgba(7, 12, 20, 0.92)",border:"1px solid rgba(255,255,255,0.08)",boxShadow:"0 12px 28px rgba(0,0,0,0.28)",pointerEvents:"auto",transform:"translate(0, -50%)",backdropFilter:"blur(10px)"});const s=document.createElement("div");Object.assign(s.style,{position:"absolute",display:"none",padding:"4px 8px",borderRadius:"999px",background:"rgba(7, 13, 20, 0.92)",color:"#fff",fontSize:"12px",fontWeight:"600",lineHeight:"18px",pointerEvents:"none",transform:"translate(-50%, calc(-100% - 8px))",boxShadow:"0 8px 18px rgba(0,0,0,0.24)",whiteSpace:"nowrap"}),[{mode:"move",label:"移",title:"移动",color:"#53d7ff"},{mode:"rotate",label:"旋",title:"旋转",color:"#ff8a61"},{mode:"scale",label:"缩",title:"缩放",color:"#ffd76a"}].forEach(a=>{const l=document.createElement("button");l.type="button",l.dataset.mode=a.mode,l.title=a.title,l.innerText=a.label,Object.assign(l.style,{width:"42px",height:"42px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.08)",background:"rgba(255,255,255,0.05)",color:a.color,fontSize:"13px",fontWeight:"700",cursor:"pointer",pointerEvents:"auto"}),l.addEventListener("click",d=>{d.stopPropagation(),this.switchEditMode(a.mode)}),n.appendChild(l)}),t.appendChild(n),t.appendChild(s),e.appendChild(t),this.overlayContainer=t,this.modeToolbarEl=n,this.feedbackLabelEl=s,this.overlayUpdateFn=this.updateOverlayPosition.bind(this),this.viewer.scene.postRender.addEventListener(this.overlayUpdateFn)}showModeToolbar(t){this.modeToolbarEl&&(this.modeToolbarEl.style.display="flex",this.updateToolbarState(),this.updateOverlayPosition())}hideModeToolbar(){this.modeToolbarEl&&(this.modeToolbarEl.style.display="none")}updateToolbarState(){if(!this.modeToolbarEl)return;Array.from(this.modeToolbarEl.querySelectorAll("button")).forEach(e=>{const i=e.dataset.mode===this.editMode;Object.assign(e.style,i?{background:"rgba(255,255,255,0.14)",borderColor:"rgba(255,255,255,0.22)",boxShadow:"inset 0 0 0 1px rgba(255,255,255,0.05)"}:{background:"rgba(255,255,255,0.05)",borderColor:"rgba(255,255,255,0.08)",boxShadow:"none"})})}updateOverlayPosition(){var t,e;try{if(!this.activeModelId)return;const i=this.primitives.get(this.activeModelId);if(!i)return;const n=this.Cesium,s=this.getGizmoScreenBounds(i);if(!s){this.hideModeToolbar(),this.hideFeedback();return}const o=s.center,r=(e=(t=this.viewer)==null?void 0:t.scene)==null?void 0:e.canvas,a=Number((r==null?void 0:r.clientWidth)||(r==null?void 0:r.width)||0),l=Number((r==null?void 0:r.clientHeight)||(r==null?void 0:r.height)||0);if(this.modeToolbarEl&&this.modeToolbarEl.style.display!=="none"){const d=Number(this.modeToolbarEl.offsetWidth||58),u=Number(this.modeToolbarEl.offsetHeight||176),p=18;let g=s.maxX+p;g+d>a-12&&(g=s.minX-d-p),g=n.Math.clamp(g,12,Math.max(12,a-d-12));const m=(s.minY+s.maxY)/2,f=n.Math.clamp(m-u/2,12,Math.max(12,l-u-12));this.modeToolbarEl.style.left=`${g}px`,this.modeToolbarEl.style.top=`${f+u/2}px`}if(this.feedbackLabelEl&&this.feedbackLabelEl.style.display!=="none"){const d=this.feedbackAnchor||o,u=this.toWindowCoordinates(d);u&&(this.feedbackLabelEl.style.left=`${u.x}px`,this.feedbackLabelEl.style.top=`${u.y}px`)}}catch{this.hideModeToolbar(),this.hideFeedback()}}showFeedback(t,e){this.feedbackLabelEl&&(this.feedbackAnchor=e||null,this.feedbackLabelEl.innerText=t,this.feedbackLabelEl.style.display="block",this.updateOverlayPosition())}hideFeedback(){this.feedbackAnchor=null,this.feedbackLabelEl&&(this.feedbackLabelEl.style.display="none")}toWindowCoordinates(t){var s;const e=this.Cesium,i=(s=this.viewer)==null?void 0:s.scene,n=e==null?void 0:e.SceneTransforms;if(!(!i||!n||!t)){if(typeof n.wgs84ToWindowCoordinates=="function")return n.wgs84ToWindowCoordinates(i,t);if(typeof n.worldToWindowCoordinates=="function")return n.worldToWindowCoordinates(i,t)}}createUnitBoxGeometry(){const t=this.Cesium;return t.BoxGeometry.createGeometry(new t.BoxGeometry({maximum:new t.Cartesian3(.5,.5,.5),minimum:new t.Cartesian3(-.5,-.5,-.5)}))}getGizmoAppearance(){const t=this.Cesium;return new t.PerInstanceColorAppearance({translucent:!0,flat:!0,renderState:{depthTest:{enabled:!1},depthMask:!1,cull:{enabled:!1},blending:t.BlendingState.ALPHA_BLEND}})}getGizmoMetrics(t){const e=Math.max(this.getPrimitiveEffectiveRadius(t),8),i=Math.max(e*.08,2.2),n=Math.max(e*1.25,20),s=Math.max(e*.28,6),o=Math.max(e*.065,1.8),r=Math.max(e*.028,1.1),a=Math.max(i*2.2,e*.18),l=Math.max(e*.62,a+6),d=Math.max(e*.018,.8),u=Math.max(e*1.02,18),p=Math.max(e*.024,1.15),g=Math.max(e*1.06,18),m=Math.max(e*.075,2.4);return{centerRadius:i,axisLength:n,arrowLength:s,arrowRadius:o,axisThickness:r,planeStart:a,planeEnd:l,planeThickness:d,rotationRadius:u,rotationThickness:p,scaleOffset:g,scaleHandleRadius:m}}createSegmentInstance(t,e,i,n,s){const o=this.Cesium,r=o.Cartesian3.subtract(i,e,new o.Cartesian3),a=o.Cartesian3.magnitude(r);if(!Number.isFinite(a)||a<=0)return null;const l=o.Cartesian3.normalize(r,new o.Cartesian3),d=o.Cartesian3.midpoint(e,i,new o.Cartesian3),u=o.Cartesian3.UNIT_X,p=o.Cartesian3.cross(u,l,new o.Cartesian3),g=o.Cartesian3.magnitude(p),m=o.Math.clamp(o.Cartesian3.dot(u,l),-1,1);let f=o.Quaternion.clone(o.Quaternion.IDENTITY);return g>1e-6?(o.Cartesian3.normalize(p,p),f=o.Quaternion.fromAxisAngle(p,Math.acos(m))):m<0&&(f=o.Quaternion.fromAxisAngle(o.Cartesian3.UNIT_Z,Math.PI)),new o.GeometryInstance({id:t,geometry:this.createUnitBoxGeometry(),modelMatrix:o.Matrix4.fromTranslationQuaternionRotationScale(d,f,new o.Cartesian3(a,n,n)),attributes:{color:o.ColorGeometryInstanceAttribute.fromColor(s)}})}createCenterInstance(t,e,i){const n=this.Cesium;return new n.GeometryInstance({id:t,geometry:new n.EllipsoidGeometry({radii:new n.Cartesian3(e,e,e),vertexFormat:n.PerInstanceColorAppearance.VERTEX_FORMAT}),attributes:{color:n.ColorGeometryInstanceAttribute.fromColor(i)}})}createCenterBoxInstance(t,e,i){const n=this.Cesium;return new n.GeometryInstance({id:t,geometry:n.BoxGeometry.createGeometry(new n.BoxGeometry({maximum:new n.Cartesian3(e,e,e),minimum:new n.Cartesian3(-e,-e,-e)})),attributes:{color:n.ColorGeometryInstanceAttribute.fromColor(i)}})}getAxisVector(t,e){const i=this.Cesium;return e==="X"?i.Matrix4.getColumn(t,0,new i.Cartesian3):e==="Y"?i.Matrix4.getColumn(t,1,new i.Cartesian3):i.Matrix4.getColumn(t,2,new i.Cartesian3)}getRotationPlanePoint(t,e,i){const n=this.Cesium;return t==="xy"?new n.Cartesian3(e*Math.cos(i),e*Math.sin(i),0):t==="yz"?new n.Cartesian3(0,e*Math.cos(i),e*Math.sin(i)):new n.Cartesian3(e*Math.cos(i),0,e*Math.sin(i))}getGizmoLocalBounds(t){const e=this.Cesium,i=this.getGizmoMetrics(t);if(this.editMode==="rotate"){const n=[0,45,90].map(s=>e.Math.toRadians(s));return["xy","yz","xz"].flatMap(s=>n.map(o=>this.getRotationPlanePoint(s,i.rotationRadius,o)))}return this.editMode==="scale"?[new e.Cartesian3(i.scaleOffset,0,0),new e.Cartesian3(0,i.scaleOffset,0),new e.Cartesian3(0,0,i.scaleOffset),new e.Cartesian3(0,0,0)]:[new e.Cartesian3(i.axisLength+i.arrowLength,0,0),new e.Cartesian3(0,i.axisLength+i.arrowLength,0),new e.Cartesian3(0,0,i.axisLength+i.arrowLength),new e.Cartesian3(i.planeEnd,i.planeEnd,0),new e.Cartesian3(0,i.planeEnd,i.planeEnd),new e.Cartesian3(i.planeEnd,0,i.planeEnd)]}getGizmoScreenBounds(t){const e=this.Cesium,i=this.getGizmoModelMatrix(t),n=e.Matrix4.getTranslation(i,new e.Cartesian3),s=this.toWindowCoordinates(n);if(!s)return null;const o=this.getGizmoLocalBounds(t).map(r=>this.toWindowCoordinates(e.Matrix4.multiplyByPoint(i,r,new e.Cartesian3))).filter(Boolean);return o.length?o.reduce((r,a)=>({minX:Math.min(r.minX,a.x),maxX:Math.max(r.maxX,a.x),minY:Math.min(r.minY,a.y),maxY:Math.max(r.maxY,a.y),center:n}),{minX:Number.POSITIVE_INFINITY,maxX:Number.NEGATIVE_INFINITY,minY:Number.POSITIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,center:n}):{minX:s.x,maxX:s.x,minY:s.y,maxY:s.y,center:n}}writeDragEndPayload(t,e,i){let n=this.dragEndCallbackMap.get(t);n||(n=new Map,this.dragEndCallbackMap.set(t,n)),n.set(e,i)}applyTransformAroundCenter(t,e,i){const n=this.Cesium,s=n.Matrix4.fromTranslation(n.Cartesian3.negate(e,new n.Cartesian3)),o=n.Matrix4.fromTranslation(e),r=n.Matrix4.multiply(o,n.Matrix4.multiply(i,s,new n.Matrix4),new n.Matrix4);return n.Matrix4.multiply(r,t,new n.Matrix4)}createMoveAxis(t){const e=this.Cesium,i=this.viewer;this.moveAxis&&i.scene.primitives.remove(this.moveAxis);const n=this.getGizmoMetrics(t),s=[{axis:"X",start:new e.Cartesian3(n.centerRadius,0,0),end:new e.Cartesian3(n.axisLength,0,0),color:e.Color.RED.withAlpha(.98)},{axis:"Y",start:new e.Cartesian3(0,n.centerRadius,0),end:new e.Cartesian3(0,n.axisLength,0),color:e.Color.LIME.withAlpha(.98)},{axis:"Z",start:new e.Cartesian3(0,0,n.centerRadius),end:new e.Cartesian3(0,0,n.axisLength),color:e.Color.DODGERBLUE.withAlpha(.98)}].flatMap(o=>{const r=[],a=this.createSegmentInstance(`moveAxis_${t.id}_${o.axis}_line`,o.start,o.end,n.axisThickness,o.color);a&&r.push(a);const l=e.BoxGeometry.createGeometry(new e.BoxGeometry({maximum:new e.Cartesian3(n.scaleHandleRadius,n.scaleHandleRadius,n.scaleHandleRadius),minimum:new e.Cartesian3(-n.scaleHandleRadius,-n.scaleHandleRadius,-n.scaleHandleRadius)})),d=o.axis==="X"?[n.axisLength,0,0]:o.axis==="Y"?[0,n.axisLength,0]:[0,0,n.axisLength];return this.translate(l,d),r.push(new e.GeometryInstance({id:`moveAxis_${t.id}_${o.axis}_handle`,geometry:l,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(o.color)}})),r});s.push(this.createCenterInstance(`moveCenter_${t.id}`,n.centerRadius,e.Color.WHITE)),this.moveAxis=new e.Primitive({geometryInstances:s,appearance:this.getGizmoAppearance(),modelMatrix:this.getGizmoModelMatrix(t),cull:!1,asynchronous:!1}),i.scene.primitives.add(this.moveAxis)}createRotationRing(t){const e=this.Cesium,i=this.viewer;this.rotationRing&&i.scene.primitives.remove(this.rotationRing);const n=this.getGizmoMetrics(t),s=10,o=4,r=Math.max(n.rotationRadius-n.rotationThickness*5,1),l=(n.rotationRadius+n.rotationThickness*5-r)/o,d=[{axis:"X",plane:"yz",color:e.Color.RED.withAlpha(.92)},{axis:"Y",plane:"xz",color:e.Color.LIME.withAlpha(.9)},{axis:"Z",plane:"xy",color:e.Color.YELLOW.withAlpha(.92)}].flatMap(u=>{const p=[];for(let g=0;g<90;g+=s){const m=e.Math.toRadians(g),f=e.Math.toRadians(g+s),y=this.getRotationPlanePoint(u.plane,n.rotationRadius,m),v=this.getRotationPlanePoint(u.plane,n.rotationRadius,f),w=this.createSegmentInstance(`rotationArc_${t.id}_${u.axis}_${g}`,y,v,n.rotationThickness,u.color);w&&p.push(w);for(let P=0;P<o;P+=1){const b=r+l*(P+.5),C=this.getRotationPlanePoint(u.plane,b,m),E=this.getRotationPlanePoint(u.plane,b,f),L=this.createSegmentInstance(`rotationSector_${t.id}_${u.axis}_${P}_${g}`,C,E,Math.max(l*.92,n.rotationThickness*1.4),u.color.withAlpha(.04));L&&p.push(L)}}return p});this.rotationRing=new e.Primitive({geometryInstances:d,appearance:this.getGizmoAppearance(),modelMatrix:this.getGizmoModelMatrix(t),cull:!1,asynchronous:!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 n=this.getGizmoMetrics(t),o=[{axis:"XY",color:e.Color.DODGERBLUE.withAlpha(.28),minimum:new e.Cartesian3(n.planeStart,n.planeStart,-n.planeThickness),maximum:new e.Cartesian3(n.planeEnd,n.planeEnd,n.planeThickness)},{axis:"YZ",color:e.Color.RED.withAlpha(.24),minimum:new e.Cartesian3(-n.planeThickness,n.planeStart,n.planeStart),maximum:new e.Cartesian3(n.planeThickness,n.planeEnd,n.planeEnd)},{axis:"ZX",color:e.Color.LIME.withAlpha(.24),minimum:new e.Cartesian3(n.planeStart,-n.planeThickness,n.planeStart),maximum:new e.Cartesian3(n.planeEnd,n.planeThickness,n.planeEnd)}].map(r=>new e.GeometryInstance({id:`translationPlane_${t.id}_${r.axis}`,geometry:new e.BoxGeometry({minimum:r.minimum,maximum:r.maximum}),attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(r.color)}}));this.translationSquare=new e.Primitive({geometryInstances:o,appearance:this.getGizmoAppearance(),cull:!1,modelMatrix:this.getGizmoModelMatrix(t),asynchronous:!1}),i.scene.primitives.add(this.translationSquare)}createHeightArrow(t){const e=this.Cesium,i=this.viewer,n=Math.max(this.getPrimitiveEffectiveRadius(t),8);this.heightArrow&&i.scene.primitives.remove(this.heightArrow);let s=e.Color.GREEN,o=Math.max(n*.03,1.5),r=2*o,a=Math.max(n*1.6,36),l=a*.1;const d=Math.max(n*.2,2),u=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:a,topRadius:o,bottomRadius:o})),p=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:l,topRadius:0,bottomRadius:r}));let g=a+d,m=(a+d)/2;this.translate(u,[0,0,m]),this.translate(p,[0,0,g]),this.heightArrow=new e.Primitive({modelMatrix:t.modelMatrix,geometryInstances:[new e.GeometryInstance({id:`heightArrow-line_${t.id}`,geometry:u,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(s.withAlpha(.9))}}),new e.GeometryInstance({id:`heightArrow-arrow_${t.id}`,geometry:p,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(s.withAlpha(.9))}})],appearance:new e.PerInstanceColorAppearance({translucent:!0,closed:!0}),cull:!1,asynchronous:!1}),i.scene.primitives.add(this.heightArrow)}createScaleHandle(t){const e=this.Cesium,i=this.viewer;this.scaleHandle&&i.scene.primitives.remove(this.scaleHandle),this.scaleCenterProxy&&i.scene.primitives.remove(this.scaleCenterProxy);const n=this.getGizmoMetrics(t),s=[{axis:"X",color:e.Color.RED.withAlpha(.96),end:new e.Cartesian3(n.scaleOffset,0,0)},{axis:"Y",color:e.Color.LIME.withAlpha(.96),end:new e.Cartesian3(0,n.scaleOffset,0)},{axis:"Z",color:e.Color.DODGERBLUE.withAlpha(.96),end:new e.Cartesian3(0,0,n.scaleOffset)}].flatMap(o=>{const r=[],a=this.createSegmentInstance(`scaleAxis_${t.id}_${o.axis}`,new e.Cartesian3(0,0,0),o.end,n.axisThickness,o.color);a&&r.push(a);const l=e.BoxGeometry.createGeometry(new e.BoxGeometry({maximum:new e.Cartesian3(n.scaleHandleRadius,n.scaleHandleRadius,n.scaleHandleRadius),minimum:new e.Cartesian3(-n.scaleHandleRadius,-n.scaleHandleRadius,-n.scaleHandleRadius)}));return this.translate(l,o.end),r.push(new e.GeometryInstance({id:`scaleHandle_${t.id}_${o.axis}`,geometry:l,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(o.color)}})),r});s.push(this.createCenterInstance(`scaleCenter_${t.id}`,n.centerRadius*1.35,e.Color.WHITE)),this.scaleHandle=new e.Primitive({geometryInstances:s,appearance:this.getGizmoAppearance(),cull:!1,asynchronous:!1,modelMatrix:this.getGizmoModelMatrix(t)}),i.scene.primitives.add(this.scaleHandle),this.scaleCenterProxy=new e.Primitive({geometryInstances:[this.createCenterBoxInstance(`scaleCenterHit_${t.id}`,n.centerRadius*3.1,e.Color.WHITE.withAlpha(.02))],appearance:this.getGizmoAppearance(),cull:!1,asynchronous:!1,modelMatrix:this.getGizmoModelMatrix(t)}),i.scene.primitives.add(this.scaleCenterProxy)}translate(t,e){let i=this.Cesium;const n=new i.Cartesian3;Me(e)?(n.x=e[0],n.y=e[1],n.z=e[2]):i.Cartesian3.clone(e,n);for(let s=0;s<t.attributes.position.values.length;s+=3)t.attributes.position.values[s]+=n.x,t.attributes.position.values[s+1]+=n.y,t.attributes.position.values[s+2]+=n.z}removeTool(){this.rotationRing&&(this.viewer.scene.primitives.remove(this.rotationRing),this.rotationRing=null),this.moveAxis&&(this.viewer.scene.primitives.remove(this.moveAxis),this.moveAxis=null),this.translationSquare&&(this.viewer.scene.primitives.remove(this.translationSquare),this.translationSquare=null),this.heightArrow&&(this.viewer.scene.primitives.remove(this.heightArrow),this.heightArrow=null),this.scaleHandle&&(this.viewer.scene.primitives.remove(this.scaleHandle),this.scaleHandle=null),this.scaleCenterProxy&&(this.viewer.scene.primitives.remove(this.scaleCenterProxy),this.scaleCenterProxy=null)}updatedTool(t){const e=this.extractModelBaseMatrix(t);this.rotationRing&&(this.rotationRing.modelMatrix=e),this.moveAxis&&(this.moveAxis.modelMatrix=e),this.translationSquare&&(this.translationSquare.modelMatrix=e),this.heightArrow&&(this.heightArrow.modelMatrix=e),this.scaleHandle&&(this.scaleHandle.modelMatrix=e),this.scaleCenterProxy&&(this.scaleCenterProxy.modelMatrix=e)}moveModel(t,e,i,n,s,o){const r=this.Cesium,a=r.Cartesian3.subtract(o,s,new r.Cartesian3),l=r.Transforms.eastNorthUpToFixedFrame(n);let d=a;if(!["XY","YZ","ZX"].includes(i)){const f=this.getAxisVector(l,i),y=r.Cartesian3.dot(a,f);d=r.Cartesian3.multiplyByScalar(f,y,new r.Cartesian3)}const u=r.Matrix4.multiply(r.Matrix4.fromTranslation(d),e,new r.Matrix4);t.modelMatrix=u,this.updatedTool(u);const p=r.Matrix4.getTranslation(u,new r.Cartesian3),g=r.Cartesian3.magnitude(d),m=["XY","YZ","ZX"].includes(i)?i:`${i}轴`;this.showFeedback(`${m} ${g.toFixed(2)} m`,p),this.writeDragEndPayload(t.id,"translation",{id:t.id,position:p})}moveModelHeight(t,e,i,n,s,o){const r=this.Cesium,a=this.projectVerticalPoint(i.endPosition,n,s);if(a&&o){const l=r.Cartographic.fromCartesian(a),d=new r.Cartographic(o.longitude,o.latitude,(l==null?void 0:l.height)||o.height||0),u=r.Cartographic.toCartesian(d),p=r.Matrix4.getRotation(e,new r.Matrix3),g=r.Matrix4.fromRotationTranslation(p,u);t.modelMatrix=g,this.updatedTool(g),this.showFeedback(`${(((l==null?void 0:l.height)||0)-(o.height||0)).toFixed(2)} m`,u);let m=new r.Cartesian3(g[12],g[13],g[14]),f=this.dragEndCallbackMap.get(t.id);f||(f=new Map,this.dragEndCallbackMap.set(t.id,f)),f.set("translation",{id:t.id,position:m})}}projectVerticalPoint(t,e,i){const n=this.Cesium,s=this.viewer;if(!t||!e||!i)return null;const o=s.camera.getPickRay(t);if(!o)return null;const r=o.origin,a=n.Cartesian3.normalize(o.direction,new n.Cartesian3),l=e,d=i,u=n.Cartesian3.subtract(r,l,new n.Cartesian3),p=n.Cartesian3.dot(a,a),g=-n.Cartesian3.dot(a,d),m=n.Cartesian3.dot(d,d),f=-n.Cartesian3.dot(a,u),y=n.Cartesian3.dot(d,u),v=p*m-g*g;if(Math.abs(v)<1e-6)return null;const w=(p*y-g*f)/v;return n.Cartesian3.add(l,n.Cartesian3.multiplyByScalar(d,w,new n.Cartesian3),new n.Cartesian3)}rotateModel(t,e,i,n,s,o){const r=this.Cesium;if(!s||!o||!n)return;const a=r.Cartesian3.subtract(o,n,new r.Cartesian3);if(r.Cartesian3.magnitudeSquared(a)<=1e-6)return;r.Cartesian3.normalize(a,a);const l=r.Transforms.eastNorthUpToFixedFrame(n),d=this.getAxisVector(l,i),u=r.Math.clamp(r.Cartesian3.dot(s,a),-1,1),p=Math.acos(u);if(!Number.isFinite(p)||p<=1e-6)return;const g=r.Cartesian3.cross(s,a,new r.Cartesian3),m=r.Cartesian3.dot(g,d)>=0?1:-1,f=p*m,y=r.Quaternion.fromAxisAngle(d,f),v=r.Matrix4.fromRotationTranslation(r.Matrix3.fromQuaternion(y)),w=this.applyTransformAroundCenter(e,n,v);t.modelMatrix=w,this.updatedTool(w);const P=r.Matrix4.getTranslation(w,new r.Cartesian3);this.showFeedback(`${i}轴 ${r.Math.toDegrees(f).toFixed(1)}°`,P);const b=this.getModelHeadingPitchRoll(this.extractModelBaseMatrix(w));this.writeDragEndPayload(t.id,"rotate",{id:t.id,headingPitchRoll:{heading:Number(r.Math.toDegrees(b.heading).toFixed(3)),pitch:Number(r.Math.toDegrees(b.pitch).toFixed(3)),roll:Number(r.Math.toDegrees(b.roll).toFixed(3))}})}moveModelScale(t,e,i,n,s,o,r,a,l){const d=this.Cesium;if(!r)return;const u=this.getGizmoMetrics(t),p=d.Transforms.eastNorthUpToFixedFrame(n),g=Math.max(u.scaleOffset*.7,8);let m=0;if(i==="CENTER"){if(!s||!a)return;const b=Number(s.y||0)-Number(a.y||0);m=Math.pow(2,b/180)-1}else{if(!o||!l)return;const b=d.Cartesian3.subtract(l,o,new d.Cartesian3),C=this.getAxisVector(p,i);m=d.Cartesian3.dot(b,C)/g}const f=Math.max(.05,1+m),y={x:r.x,y:r.y,z:r.z};if(i==="CENTER")y.x=Math.max(.05,r.x*f),y.y=Math.max(.05,r.y*f),y.z=Math.max(.05,r.z*f);else{const b=Math.max(.05,Number((r[i.toLowerCase()]*f).toFixed(4)));y[i.toLowerCase()]=b}const v=this.extractModelBaseMatrix(e);this.applyScaleToPrimitive(t,y,v),this.activeModelId===t.id?this.refreshActiveToolGeometry():this.updatedTool(t.modelMatrix);const w=d.Matrix4.getTranslation(t.modelMatrix,new d.Cartesian3),P=i==="CENTER"?`${Math.max(y.x,y.y,y.z).toFixed(2)}x`:`${i}轴 ${y[i.toLowerCase()].toFixed(2)}x`;this.debugLog("moveModelScale",{id:t==null?void 0:t.id,axis:i,startScale:{x:Number((r==null?void 0:r.x)||1),y:Number((r==null?void 0:r.y)||1),z:Number((r==null?void 0:r.z)||1)},nextScale:y,deltaFactor:m,factor:f,runtimeRadius:this.getPrimitiveRuntimeRadius(t)}),this.showFeedback(P,w),this.writeDragEndPayload(t.id,"addScale",{id:t.id,scale:y})}cleanup(){var t,e;this.deactivateEdit(),this.hideModeHint(),(t=this.tooltipManager)==null||t.destroy(),this.tooltipManager=null,this.overlayUpdateFn&&(this.viewer.scene.postRender.removeEventListener(this.overlayUpdateFn),this.overlayUpdateFn=null),(e=this.overlayContainer)==null||e.remove(),this.overlayContainer=null,this.modeToolbarEl=null,this.feedbackLabelEl=null,this.handler&&(this.handler.destroy(),this.handler=null)}}function Eo(h,t){const e=t.materialType||"DynamicImgMaterial"+Date.now()+Math.floor(Math.random()*1e3);function i(s){this._definitionChanged=new h.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:h.createPropertyDescriptor("color")}),i.prototype.getType=function(){return e},i.prototype.getValue=function(s,o){return h.defined(o)||(o={}),o.color=h.Property.getValueOrClonedDefault(this._color,s,h.Color.WHITE,o.color),o.image=t.image,o},i.prototype.equals=function(s){return this===s||s instanceof i&&h.Property.equals(this._color,s._color)};const n=function(s){return`
|
|
2
2
|
czm_material czm_getMaterial(czm_materialInput materialInput)
|
|
3
3
|
{
|
|
4
4
|
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
@@ -9,7 +9,15 @@ interface LabelInstance {
|
|
|
9
9
|
data?: any;
|
|
10
10
|
notCreateElement?: boolean;
|
|
11
11
|
unload?: any;
|
|
12
|
+
/** 单个容器可以覆盖主题的默认偏移;用于不依赖主题尺寸的业务浮层。 */
|
|
13
|
+
offset?: {
|
|
14
|
+
x?: number;
|
|
15
|
+
y?: number;
|
|
16
|
+
};
|
|
17
|
+
/** 内容相对地图坐标点的 CSS 锚点。 */
|
|
18
|
+
anchor?: LabelAnchor;
|
|
12
19
|
}
|
|
20
|
+
export type LabelAnchor = 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
13
21
|
/**
|
|
14
22
|
* 主题配置项
|
|
15
23
|
*/
|
|
@@ -46,6 +54,13 @@ interface LabelOptions {
|
|
|
46
54
|
style?: {
|
|
47
55
|
[key: string]: string;
|
|
48
56
|
};
|
|
57
|
+
/** 覆盖主题偏移。未传时沿用主题 options.offset。 */
|
|
58
|
+
offset?: {
|
|
59
|
+
x?: number;
|
|
60
|
+
y?: number;
|
|
61
|
+
};
|
|
62
|
+
/** 默认 top-left,保持既有标记定位行为。 */
|
|
63
|
+
anchor?: LabelAnchor;
|
|
49
64
|
}
|
|
50
65
|
export { LabelOptions, LabelInstance, ThemeOptions };
|
|
51
66
|
/**
|
|
@@ -93,6 +108,7 @@ export declare class HtmlOverlayLabelPool {
|
|
|
93
108
|
private _occlusionPending;
|
|
94
109
|
eventBus: MarkerEventBus;
|
|
95
110
|
openWheel: boolean;
|
|
111
|
+
private getAnchorTransform;
|
|
96
112
|
/**
|
|
97
113
|
* 构造函数
|
|
98
114
|
* @param Cesium Cesium 命名空间
|
|
@@ -2,6 +2,7 @@ export * from './src/type/markerManage';
|
|
|
2
2
|
export * from './src/type/markerPreview';
|
|
3
3
|
export * from './src/core/MarkerManagerCore';
|
|
4
4
|
export * from './src/core/MarkerManage';
|
|
5
|
+
export * from './src/core/MarkerOverlayManager';
|
|
5
6
|
declare const CxMarkerManage: any;
|
|
6
7
|
declare const CxMarkerPreview: any;
|
|
7
8
|
export { CxMarkerManage, CxMarkerPreview };
|
|
@@ -4,7 +4,7 @@ import { default as CxMarkerHtml } from './components/marker-html';
|
|
|
4
4
|
import { default as CxMarkerSvg } from './components/marker-svg';
|
|
5
5
|
import { default as CxMarkerText } from './components/marker-text';
|
|
6
6
|
import { default as CxMarkerBubble, CxMarkerBubbleLine } from './components/marker-bubble';
|
|
7
|
-
import { default as CxMarkerManage, CxMarkerPreview, MarkerManagerCore } from './components/marker-manage';
|
|
7
|
+
import { default as CxMarkerManage, CxMarkerPreview, MarkerManagerCore, MarkerOverlayManager } from './components/marker-manage';
|
|
8
8
|
import { default as CxBasicVideo } from './components/basic-video';
|
|
9
9
|
import { default as CxCardContent } from './components/card-content';
|
|
10
10
|
import { default as CxCarouselImg } from './components/carousel-img';
|
|
@@ -26,7 +26,7 @@ declare const _default: {
|
|
|
26
26
|
install(app: App): void;
|
|
27
27
|
};
|
|
28
28
|
export default _default;
|
|
29
|
-
export { useMarKerManage, MarkerManageOptions, MarkerManagerCore };
|
|
29
|
+
export { useMarKerManage, MarkerManageOptions, MarkerManagerCore, MarkerOverlayManager };
|
|
30
30
|
export { CxMarkerDefault, CxMarkerSvg, CxMarkerText, CxMarkerBubble, CxMarkerBubbleLine, CxMarkerManage, CxMarkerPreview, CxBasicVideo, CxCardContent, CxCarouselImg, CxEchartsPro, CxCardPage, CxCardCarousel, CxBasicAudio, CxMarkerHtml, CxMeasurement, CxPositionPicker, };
|
|
31
31
|
declare module 'vue' {
|
|
32
32
|
interface GlobalComponents {
|