leiting-bim 2.1.103 → 2.1.104

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.
@@ -26,7 +26,7 @@
26
26
  ${r}
27
27
  <!-- 关闭按钮 -->
28
28
  ${l}
29
- `;this.promptDiv=window.document.createElement("div"),this.promptDiv.className=`easy3d-prompt ${this.opt.className}`,this.promptDiv.id=p,this.promptDiv.innerHTML=f,window.document.getElementById(o).appendChild(this.promptDiv);const m=window.document.getElementById(`prompt-close-${this.opt.id}`);let E=this;m&&m.addEventListener("click",A=>{E.hide(),E.opt.close&&E.opt.close()}),this.promptDom=window.document.getElementById(p),this.position=this.transPosition(this.opt.position),n==2&&this.bindRender(),this.opt.show==!1&&this.hide(),this.containerW=this.viewer.container.offsetWidth,this.containerH=this.viewer.container.offsetHeight,this.containerLeft=this.viewer.container.offsetLeft,this.containerTop=this.viewer.container.offsetTop,this.contentW=Math.ceil(Number(this.promptDom.offsetWidth)),this.contentH=this.promptDom.offsetHeight,this.opt.success&&this.opt.success()}destroy(){this.promptDiv&&(window.document.getElementById(this.viewer.container.id).removeChild(this.promptDiv),this.promptDiv=null),this.rendHandler&&(this.rendHandler(),this.rendHandler=null)}bindRender(){let e=this;this.rendHandler=this.viewer.scene.postRender.addEventListener(function(){if(!e.isShow&&e.promptDom){e.promptDom.style.display="none";return}if(e.position)if(e.position instanceof Cesium.Cartesian3){let t=Cesium.SceneTransforms.wgs84ToWindowCoordinates(e.viewer.scene,e.position);if(!t)return;new Cesium.EllipsoidalOccluder(e.viewer.scene.globe.ellipsoid,e.viewer.scene.camera.position).isPointVisible(e.position)?e.promptDom&&(e.promptDom.style.display="block"):e.promptDom&&(e.promptDom.style.display="none"),e.setByPX({x:t.x,y:t.y})}else e.setByPX({x:e.position.x,y:e.position.y})},this)}update(e,t){e instanceof Cesium.Cartesian3&&(this.position=e.clone(),e=Cesium.SceneTransforms.wgs84ToWindowCoordinates(this.viewer.scene,e)),this.contentW=Math.ceil(Number(this.promptDom.offsetWidth)),this.contentH=this.promptDom.offsetHeight,e&&this.setByPX(e),t&&this.setContent(t)}isInView(){if(!this.position)return!1;let e=null;this.position instanceof Cesium.Cartesian2?e=this.position:e=Cesium.SceneTransforms.wgs84ToWindowCoordinates(this.viewer.scene,this.position);const n=new Cesium.EllipsoidalOccluder(this.viewer.scene.globe.ellipsoid,this.viewer.scene.camera.position).isPointVisible(this.position);let s=!1;return e?(e.x>this.containerLeft&&e.x<this.containerLeft+this.containerW&&e.y>this.containerTop&&e.y<this.containerTop+this.containerH&&(s=!0),n&&s):s}setVisible(e){this.isInView(this.position)&&e?(this.isShow=!0,this.promptDom&&(this.promptDom.style.display="block")):(this.isShow=!1,this.promptDom&&(this.promptDom.style.display="none"))}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}setContent(e){let t=window.document.getElementById(`prompt-content-${this.opt.id}`);t.innerHTML=e}setByPX(e){e&&this.promptDom&&(this.promptDom.offsetWidth,this.promptDom.offsetHeight,this.opt.type==1?(this.promptDom.style.left=Number(e.x)+Number(this.opt.offset.x||0)+"px",this.promptDom.style.top=Number(e.y)+Number(this.opt.offset.y||0)+"px"):(this.promptDom.style.left=Number(e.x)+Number(this.opt.offset.x||0)-Number(this.contentW)/2+"px",this.promptDom.style.top=Number(e.y)+Number(this.opt.offset.y||0)-Number(this.contentH)+"px"))}transPosition(e){let t;return Array.isArray(e)?t=Cesium.Cartesian3.fromDegrees(e[0],e[1],e[2]||0).clone():e instanceof Cesium.Cartesian3?t=e.clone():t=e,t}}const Rr=Object.freeze(Object.defineProperty({__proto__:null,default:at},Symbol.toStringTag,{value:"Module"}));let se={};se.cartesianToLnglat=function(i,e){if(!i)return[];var t=Cesium.Cartographic.fromCartesian(i),n=Cesium.Math.toDegrees(t.latitude),s=Cesium.Math.toDegrees(t.longitude),o=t.height;return[s,n,o]},se.getViewCenter=i=>{if(i){var e=i.camera.computeViewRectangle(),t=e.west/Math.PI*180,n=e.north/Math.PI*180,s=e.east/Math.PI*180,o=e.south/Math.PI*180;return[(s+t)/2,(n+o)/2]}},se.cartesiansToLnglats=function(i,e){if(!(!i||i.length<1)){if(e=e||window.viewer,!e){console.log("util.cartesiansToLnglats方法缺少viewer对象");return}for(var t=[],n=0;n<i.length;n++)t.push(se.cartesianToLnglat(i[n],e));return t}},se.lnglatsToCartesians=function(i){if(!(!i||i.length<1)){for(var e=[],t=0;t<i.length;t++){var n=Cesium.Cartesian3.fromDegrees(i[t][0],i[t][1],i[t][2]||0);e.push(n)}return e}},se.flyTo=function(i,e){if(!e){console.log("util.flyTo缺少viewer对象");return}i=i||{};let t=i.center;if(!t){console.log("缺少定位坐标!");return}if(t instanceof Cesium.Cartesian3&&e.camera.flyToBoundingSphere(new Cesium.BoundingSphere(t),{offset:new Cesium.HeadingPitchRange(Cesium.Math.toRadians(i.heading||0),Cesium.Math.toRadians(i.pitch||-60),i.range||1e4)}),t instanceof Array){var n=new Cesium.BoundingSphere(Cesium.Cartesian3.fromDegrees(t[0],t[1],t[2]));e.camera.flyToBoundingSphere(n,{offset:new Cesium.HeadingPitchRange(Cesium.Math.toRadians(i.heading||0),Cesium.Math.toRadians(i.pitch||-60),i.range||1e4)})}},se.getCameraView=function(i){if(i=i||window.viewer,!i){console.log("util.getCameraView缺少viewer对象");return}var e=i.camera,t=e.position,n=e.heading,s=e.pitch,o=e.roll,r=Cesium.Cartographic.fromCartesian(t),l={x:Cesium.Math.toDegrees(r.longitude),y:Cesium.Math.toDegrees(r.latitude),z:r.height,heading:Cesium.Math.toDegrees(n),pitch:Cesium.Math.toDegrees(s),roll:Cesium.Math.toDegrees(o)};return l},se.setCameraView=function(i,e){if(e=e||window.viewer,!e){console.log("util.setCameraView缺少viewer对象");return}if(i){var t=i.destination||Cesium.Cartesian3.fromDegrees(i.x,i.y,i.z);e.camera.flyTo({destination:t,orientation:{heading:Cesium.Math.toRadians(i.heading||0),pitch:Cesium.Math.toRadians(i.pitch||0),roll:Cesium.Math.toRadians(i.roll||0)},duration:i.duration===void 0?3:i.duration,complete:i.complete})}},se.computeAreaOfTriangle=function(i,e,t){if(!i||!e||!t)return console.log("传入坐标有误!"),0;var n=Cesium.Cartesian3.distance(i,e),s=Cesium.Cartesian3.distance(e,t),o=Cesium.Cartesian3.distance(t,i),r=(n+s+o)/2;return Math.sqrt(r*(r-n)*(r-s)*(r-o))};class Ke{constructor(e,t){this.viewer=e,this.style=t||{},this.objId=+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0)),this.handler=void 0,this.modifyHandler=void 0,this.type="",this.positions=[],this.state=null,this.prompt=null,this.controlPoints=[],this.modifyPoint=null,this.entity=null,this.pointStyle={},this.promptStyle=this.style.prompt||{show:!0},this.properties={},this.clientScale=1}getCatesian3FromPX(e){if(e=this.transpx(e),this.viewer.scene.mode===Cesium.SceneMode.SCENE2D){let o=this.viewer.camera.getPickRay(e),r=null;return o&&(r=this.viewer.scene.globe.pick(o,this.viewer.scene)),r||(r=this.viewer.camera.pickEllipsoid(e,this.viewer.scene.globe.ellipsoid)),r}let t=this.viewer.scene.drillPick(e);this.viewer.scene.render();let n,s=!1;for(let o=0;o<t.length;o++)if(t[o]&&t[o].primitive&&t[o].primitive instanceof Cesium.Cesium3DTileset){s=!0;break}if(s)n=this.viewer.scene.pickPosition(e);else{let o=this.viewer.camera.getPickRay(e);if(!o)return null;n=this.viewer.scene.globe.pick(o,this.viewer.scene)}return n}setClientScale(e){e=e||1,this.clientScale=e}transpx(e){return{x:e.x/(this.clientScale||1),y:e.y/(this.clientScale||1)}}getEntity(){return this.entity}getPositions(e){return e?se.cartesiansToLnglats(this.positions,this.viewer):this.positions}getLnglats(){return se.cartesiansToLnglats(this.positions,this.viewer)}setOwnProp(e){this.entity&&(this.entity.ownProp=e)}remove(){this.entity&&(this.state="no",this.viewer.entities.remove(this.entity),this.entity=null)}setVisible(e){this.entity&&(this.entity.show=e)}forbidDrawWorld(e){this.viewer.scene.screenSpaceCameraController.enableRotate=!e,this.viewer.scene.screenSpaceCameraController.enableTilt=!e,this.viewer.scene.screenSpaceCameraController.enableTranslate=!e,this.viewer.scene.screenSpaceCameraController.enableInputs=!e}destroy(){this.handler&&(this.handler.destroy(),this.handler=null),this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.positions=[],this.style=null;for(var e=0;e<this.controlPoints.length;e++){var t=this.controlPoints[e];this.viewer.entities.remove(t)}this.controlPoints=[],this.modifyPoint=null,this.prompt&&(this.prompt.destroy(),this.prompt=null),this.state="no",this.forbidDrawWorld(!1)}startEdit(e){if(this.state=="startEdit"||this.state=="editing"||!this.entity)return;this.state="startEdit",this.modifyHandler||(this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));let t=this;for(let n=0;n<t.controlPoints.length;n++){let s=t.controlPoints[n];s&&(s.show=!0)}this.entity.show=!0,this.modifyHandler.setInputAction(function(n){if(!t.entity)return;let s=t.viewer.scene.pick(n.position);Cesium.defined(s)&&s.id&&(s.id.objId||(t.modifyPoint=s.id),t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(n){if(t.positions.length<1||!t.modifyPoint)return;let s=t.getCatesian3FromPX(n.endPosition,t.viewer,[t.entity,t.modifyPoint]);s&&(t.modifyPoint.position.setValue(s),t.positions[t.modifyPoint.wz]=s,t.state="editing",e&&e())},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(n){t.modifyPoint&&(t.modifyPoint=null,t.forbidDrawWorld(!1),t.state="editing")},Cesium.ScreenSpaceEventType.LEFT_UP)}endEdit(e){for(let t=0;t<this.controlPoints.length;t++){let n=this.controlPoints[t];n&&(n.show=!1)}this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null,e&&e(this.entity)),this.forbidDrawWorld(!1),this.state="endEdit"}endCreate(){}done(){}createPoint(e){if(!e)return;this.pointStyle.color=this.pointStyle.color||Cesium.Color.CORNFLOWERBLUE,this.pointStyle.outlineColor=this.pointStyle.color||Cesium.Color.CORNFLOWERBLUE;let t=this.pointStyle.color instanceof Cesium.Color?this.pointStyle.color:Cesium.Color.fromCssColorString(this.pointStyle.color);t=t.withAlpha(this.pointStyle.colorAlpha||1);let n=this.pointStyle.outlineColor instanceof Cesium.Color?this.pointStyle.outlineColor:Cesium.Color.fromCssColorString(this.pointStyle.outlineColor);return n=n.withAlpha(this.pointStyle.outlineColorAlpha||1),this.viewer.entities.add({position:e,point:{pixelSize:this.pointStyle.property||10,color:t,outlineWidth:this.pointStyle.outlineWidth||0,outlineColor:n,disableDepthTestDistance:Number.POSITIVE_INFINITY},show:!1})}transfromLineMaterial(e){if(!e)return;let t={};if(e instanceof Cesium.Color){let n=e.color.getValue();t.colorAlpha=n.alpha,t.colorHex=new Cesium.Color(n.red,n.green,n.blue,1).toCssHexString()}return t}transfromGonMaterial(e){if(!e)return;let t={};if(e instanceof Cesium.Color){let n=e.color.getValue();t.colorAlpha=n.alpha,t.colorHex=new Cesium.Color(n.red,n.green,n.blue,1).toCssHexString()}return t}setAttr(e){this.properties.attr=e||{}}getAttr(){return this.properties.attr}zoomTo(){this.entity&&this.viewer.zoomTo(this.entity)}}const Ep="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABHNCSVQICAgIfAhkiAAAAptJREFUOE+FVD1oU1EYvecVCU5acHFqsggKSlUcdDGZuvhToeAgYuIuaUcHMZ0c2+JuAg4dKrS6iFPiooMUAyqCS5PFTVpBKJKa4/nez817yateeOTm3vOd75zv3u/C5QySx50b3HMO89oupyBdzTvOHawBR3t5sRhfJH+tiqiu9X4UDJH80Tc169ywGCeZcY7CDZaB6b00hyckd6WKbW2WFLQoYCtPga0JW40I3Y6wt4T1alOE382OBuaBk7l20gnIHQkoyEFA5/YrQClUGhKS/YZ+FmVpVhuejNzXemhfwU4BWAUKywlxRBoYfguYkWohosXBruY14JS3Sf6Ik1CJpqRkaAe0ovSyeGJrRPrNiJr6ziu+K8LPCqBqdraYtdRPMms/GmRPxNiTGiP3g/ykcrELnKuKcNtAPeBCKHkU/EUKgw5wWvsJ4VcLFPbMGOG2HdBN4GJJhO9UVMju5VaacHxOfjClsux0AJd8kkj5+7LdEOAKRNgWoYEqGVBWbVvqoTpRiSsTicUhQidC0ZBvjFAXdE4WJwe5qUM7ovtmmGtmbWKQr0UYiHDOCF9JmdXwulTkgddj8O2JrkrQ5EuJQRW4URThhv2pAwvT+YTNotaLQO0fJXlhTaFTXrBTXlfA0CypPndy6vPU6nMVeOAvdDox+Tx0IA4V8G4n7pRnVht7XbRYi1swCiOfyIF7DDzMeUia1v8ftd8H7lvipPVs47dZOqb+1I2v+ReEbMSWGxnLZBgTPyYFK8molyMlK9aXpk6krgHU1/JqGmPN5qaipJplYMm7ytiISA9kn7LvevpVzwZSRmWnlAb6WNWeqX6r66SXacm78ZbHlahuChhaj1uL6TH146dmSsIW8ChTggRx6N06zO7/1v8CLeIaJJK0e+4AAAAASUVORK5CYII=";class wp extends Ke{constructor(e,t){super(e,t),this.type="billboard",this.viewer=e;let n={verticalOrigin:Cesium.VerticalOrigin.BOTTOM,scale:1};this.style=Object.assign({},n,t||{}),this.entity=null,this.style.hasOwnProperty("image")||console.warn("CreateBillboard: 未在 style 中指定 image,后续将使用回退图或占位图。"),this.position=null,this._defaultFallback=Ep,this.prompt=null,this.modifyHandler=null,this._globalMouseUpHandler=null,this._isDragging=!1,this._editPickedEntity=null,this.controlPoints=[],this.modifyPoint=null,this._isScaling=!1,this._fileInput=null}_preloadImage(e,t=7e3){return new Promise((n,s)=>{if(!e)return s(new Error("empty url"));try{const o=new window.Image;o.crossOrigin="anonymous";let r=!1;const l=()=>{r||(r=!0,clearTimeout(d),n(o))},a=h=>{r||(r=!0,clearTimeout(d),s(new Error("image load error: "+e)))};o.onload=l,o.onerror=a;const d=setTimeout(()=>{r||(r=!0,o.onload=o.onerror=null,s(new Error("image load timeout: "+e)))},t);o.src=e}catch(o){s(o)}})}createBillboard(e){if(!e)return;const t=this.style.fallbackImage||this._defaultFallback,n=this.viewer.entities.add({position:e,billboard:{image:t,scale:this.style.scale||1,pixelOffset:this.style.pixelOffset,heightReference:this.style.heightReference==null?Cesium.HeightReference.CLAMP_TO_GROUND:Number(this.style.heightReference),verticalOrigin:Cesium.VerticalOrigin.BOTTOM,color:this.style.color?this.style.color instanceof Cesium.Color?this.style.color.withAlpha(this.style.colorAlpha||1):Cesium.Color.fromCssColorString(this.style.color).withAlpha(this.style.colorAlpha||1):Cesium.Color.WHITE}});n.objId=this.objId;const s=this.style.image;if(s)this._preloadImage(s,7e3).then(o=>{try{n.billboard.image=o,this.style.image=s}catch(r){console.warn("CreateBillboard: set billboard image element failed, fallback to url string",r);try{n.billboard.image=s}catch{}}try{this.viewer.scene.requestRender()}catch{}}).catch(o=>{console.error("CreateBillboard: image load failed:",o.message," URL:",s," 使用回退图:",t);try{this.viewer.scene.requestRender()}catch{}});else try{this.viewer.scene.requestRender()}catch{}return this.position=e.clone(),this.entity=n,n}updateBillboardImage(e){if(!this.entity||!this.entity.billboard)return;const t=this.style.fallbackImage||this._defaultFallback;if(!e){try{this.entity.billboard.image=t}catch{}this.style.image=t;try{this.viewer.scene.requestRender()}catch{}return}try{this.entity.billboard.image=t}catch{}this._preloadImage(e,7e3).then(n=>{try{this.entity.billboard.image=n}catch(s){console.warn("CreateBillboard: set billboard image element failed, fallback to url string",s);try{this.entity.billboard.image=e}catch{}}this.style.image=e;try{this.viewer.scene.requestRender()}catch{}}).catch(n=>{console.error("CreateBillboard: updateBillboardImage failed to load:",n.message," URL:",e);try{this.entity.billboard.image=t}catch{}this.style.image=t;try{this.viewer.scene.requestRender()}catch{}})}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate";let t=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(n){let s=t.getCatesian3FromPX(n.position,t.viewer);if(s){if(t.position=s.clone(),t.entity=t.createBillboard(t.position),t.handler){try{t.handler.destroy()}catch{}t.handler=null}if(t.prompt){try{t.prompt.destroy()}catch{}t.prompt=null}t.state="endCreate",e&&e(t.entity)}},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){t.prompt&&t.prompt.update&&t.prompt.update(n.endPosition,"单击新增"),t.state="creating"},Cesium.ScreenSpaceEventType.MOUSE_MOVE)}endCreate(){let e=this;if(e.handler){try{e.handler.destroy()}catch{}e.handler=null}if(e.prompt){try{e.prompt.destroy()}catch{}e.prompt=null}e.state="endCreate"}done(){this.state=="startCreate"?this.destroy():this.state=="creating"?this.destroy():(this.state=="startEdit"||this.state=="editing")&&this.endEdit()}createByPositions(e,t){if(!e)return;this.state="startCreate";let n=null;e instanceof Cesium.Cartesian3?n=e.clone():n=Cesium.Cartesian3.fromDegrees(Number(e[0]),Number(e[1]),Number(e[2]||0)),n&&(this.position=n.clone(),this.entity=this.createBillboard(this.position),t&&t(this.entity),this.state="endCreate")}setStyle(e){if(!e)return;let t=this.entity&&this.entity.billboard;if(t){if(e.image!=null&&this.updateBillboardImage(e.image),e.heightReference!=null){let n=1;e.heightReference==!0?n=1:n=Number(e.heightReference);try{t.heightReference=n}catch{}}if(e.scale!=null)try{t.scale=Number(e.scale)}catch{}if(e.color){let n=e.color instanceof Cesium.Color?e.color:Cesium.Color.fromCssColorString(e.color);n=n.withAlpha(e.colorAlpha||1);try{t.color=n}catch{}}}this.style=Object.assign(this.style,e)}getStyle(){let e={},t=this.entity&&this.entity.billboard;if(e.image=this.style.image,t&&t.heightReference)try{let n=t.heightReference.getValue();e.heightReference=Number(n)}catch{}if(t&&t.scale)try{e.scale=t.scale.getValue()}catch{}if(t&&t.color)try{let n=t.color.getValue();e.colorAlpha=n.alpha,e.color=new Cesium.Color(n.red,n.green,n.blue,1).toCssHexString()}catch{}return e}startEdit(e){if(this._cleanupEditState(),!this.entity)return;this.state="startEdit",this.controlPoints=[],this.showControlPoints(),this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);let t=this,n=null,s=!1;const o=()=>{if(s){if(s=!1,t.entity&&Cesium.defined(t.entity.position))try{t.position=t.entity.position.getValue(Cesium.JulianDate.now()).clone()}catch(r){console.warn("更新位置引用失败:",r)}n=null,t._isDragging=!1,t._editPickedEntity=null,t.modifyPoint=null;try{t.forbidDrawWorld(!1)}catch{}t.state="editing"}};window.addEventListener("mouseup",o,!0),this._globalMouseUpHandler=o,this.modifyHandler.setInputAction(function(r){const l=t.viewer.scene.pick(r.position);if(Cesium.defined(l)&&l.id){if(l.id===t.entity){n=l.id,s=!0,t._isDragging=!0,t._editPickedEntity=n,t.modifyPoint=null;try{t.forbidDrawWorld(!0)}catch{}}else if(t.controlPoints.includes(l.id)){t.modifyPoint=l.id,s=!0,t._isDragging=!0,n=t.entity;try{t.forbidDrawWorld(!0)}catch{}}}},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(r){if(!s)return;let l=t.getCatesian3FromPX(r.endPosition,t.viewer);if(l){if(Cesium.defined(n)){try{n.position.setValue(l)}catch{n.position=l}t.position=l.clone(),t.controlPoints&&t.controlPoints.length>0&&t.controlPoints.forEach(a=>{try{a.position.setValue(l)}catch(d){console.warn("更新控制点位置失败:",d);try{a.position=l.clone()}catch(h){console.error("重新设置控制点位置失败:",h)}}})}t.state="editing",e&&e()}},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(){if(s){if(s=!1,t.entity&&Cesium.defined(t.entity.position))try{t.position=t.entity.position.getValue(Cesium.JulianDate.now()).clone()}catch(r){console.warn("更新位置引用失败:",r)}t._isDragging=!1,t._editPickedEntity=null,t.modifyPoint=null;try{t.forbidDrawWorld(!1)}catch{}t.state="editing"}},Cesium.ScreenSpaceEventType.LEFT_UP),this.modifyHandler.setInputAction(function(){if(t._isScaling){t._isScaling=!1,t._isDragging=!1,t._scalingControlPoint=null,delete t._initialScale,delete t._initialMousePosition,t.viewer.canvas.style.cursor="",t._hideScaleHint();try{t.forbidDrawWorld(!1)}catch{}}if(s){s=!1,t._isDragging=!1,t._editPickedEntity=null,t.modifyPoint=null;try{t.forbidDrawWorld(!1)}catch{}}if(t.hideControlPoints(),t.modifyHandler){try{t.modifyHandler.destroy()}catch{}t.modifyHandler=null}t._globalMouseUpHandler&&(window.removeEventListener("mouseup",t._globalMouseUpHandler,!0),t._globalMouseUpHandler=null),t.state="endEdit"},Cesium.ScreenSpaceEventType.RIGHT_CLICK),this.modifyHandler.setInputAction(function(r){const l=t.viewer.scene.pick(r.position);Cesium.defined(l)&&l.id===t.entity&&t._handleDoubleClick()},Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}createControlPoint(e){return e?this.viewer.entities.add({position:e,point:{pixelSize:8,color:Cesium.Color.WHITE,outlineColor:Cesium.Color.BLACK,outlineWidth:2,disableDepthTestDistance:Number.MAX_VALUE}}):null}createYellowControlPoint(e){if(!e)return null;const t=this.viewer.entities.add({position:e,point:{pixelSize:10,color:Cesium.Color.YELLOW,outlineColor:Cesium.Color.BLACK,outlineWidth:2,disableDepthTestDistance:Number.MAX_VALUE}});return t.isYellowControl=!0,t}createScaleControlPoint(e,t){if(!e)return null;let n=Cesium.Color.GREEN;t==="bottomLeft"&&(n=Cesium.Color.BLUE);const s=this.viewer.entities.add({position:e,point:{pixelSize:10,color:n,outlineColor:Cesium.Color.BLACK,outlineWidth:2,disableDepthTestDistance:Number.MAX_VALUE}});return s.isScaleControl=!0,s.corner=t,s}_calculateSpecialPosition(e){return this._calculateCornerPosition(e,"bottomRight")}_calculateCornerPosition(e,t){if(!e)return null;const s=50*(this.style.scale||1),o=this.viewer.camera,r=new Cesium.Cartesian3,l=new Cesium.Cartesian3,a=new Cesium.Cartesian3;Cesium.Cartesian3.clone(o.direction,r),Cesium.Cartesian3.clone(o.right,l),Cesium.Cartesian3.clone(o.up,a),Cesium.Cartesian3.normalize(r,r),Cesium.Cartesian3.normalize(l,l),Cesium.Cartesian3.normalize(a,a);const d=new Cesium.Cartesian3;Cesium.Cartesian3.multiplyByScalar(l,s,d),Cesium.Cartesian3.multiplyByScalar(a,s,a),Cesium.Cartesian3.add(d,a,d);const h=new Cesium.Ray(e,r),p=this.viewer.scene.globe.pick(h,this.viewer.scene),u=Cesium.Cartesian3.distance(e,p||e)*.001;return Cesium.Cartesian3.multiplyByScalar(d,u,d),Cesium.Cartesian3.add(e,d,new Cesium.Cartesian3)}showControlPoints(){if(this.controlPoints=this.controlPoints||[],this._isDragging){this.position&&this.controlPoints.length>0&&this.controlPoints.forEach(e=>{try{e.position.setValue(this.position)}catch{try{e.position=this.position.clone()}catch(n){console.warn("更新拖拽中控制点位置失败:",n)}}});return}if(this.controlPoints.length>0&&([...this.controlPoints].forEach(t=>{try{this.viewer&&this.viewer.entities&&t&&this.viewer.entities.remove(t)}catch(n){console.warn("移除控制点失败:",n)}}),this.controlPoints.length=0),this.position&&this.viewer&&!this._isDragging){const e=this.createControlPoint(this.position);e&&(e.wz=0,this.controlPoints.push(e))}}hideControlPoints(){this.controlPoints&&Array.isArray(this.controlPoints)&&this.controlPoints.length>0?([...this.controlPoints].forEach(t=>{try{this.viewer&&this.viewer.entities&&t&&this.viewer.entities.remove(t)}catch(n){console.warn("移除控制点失败:",n)}}),this.controlPoints.length=0):(!this.controlPoints||!Array.isArray(this.controlPoints))&&(this.controlPoints=[]),this.topRightControlPoint=null,this.bottomLeftControlPoint=null,this.scaleControlPoint=null,this.modifyPoint=null}endEdit(e){if(this.hideControlPoints(),this.modifyHandler){try{this.modifyHandler.destroy()}catch{}this.modifyHandler=null}if(this._globalMouseUpHandler){try{window.removeEventListener("mouseup",this._globalMouseUpHandler,!0)}catch{}this._globalMouseUpHandler=null}try{this.forbidDrawWorld(!1)}catch{}this.viewer&&this.viewer.canvas&&(this.viewer.canvas.style.cursor=""),this._isDragging=!1,this._editPickedEntity=null,this.modifyPoint=null,this.state="endEdit",e&&e(this.entity)}_cleanupEditState(){if(this._globalMouseUpHandler){try{window.removeEventListener("mouseup",this._globalMouseUpHandler,!0)}catch{}this._globalMouseUpHandler=null}if(this.modifyHandler){try{this.modifyHandler.destroy()}catch{}this.modifyHandler=null}this.controlPoints=this.controlPoints||[],this.hideControlPoints(),this._isDragging=!1,this._editPickedEntity=null,this.modifyPoint=null;try{this.forbidDrawWorld(!1)}catch{}}_showScaleHint(e){this._scaleHintElement||(this._scaleHintElement=document.createElement("div"),this._scaleHintElement.style.position="absolute",this._scaleHintElement.style.background="rgba(0, 0, 0, 0.7)",this._scaleHintElement.style.color="white",this._scaleHintElement.style.padding="4px 8px",this._scaleHintElement.style.borderRadius="4px",this._scaleHintElement.style.fontSize="12px",this._scaleHintElement.style.pointerEvents="none",this._scaleHintElement.style.zIndex="10000",document.body.appendChild(this._scaleHintElement)),this._scaleHintElement.textContent=`缩放: ${e.toFixed(2)}x`,this._scaleHintElement.style.left=`${window.event.clientX+10}px`,this._scaleHintElement.style.top=`${window.event.clientY-30}px`,this._scaleHintElement.style.display="block"}_hideScaleHint(){this._scaleHintElement&&(this._scaleHintElement.style.display="none")}move(e){if(!this.entity)return;let t=null;e instanceof Cesium.Cartesian3?t=e:t=Cesium.Cartesian3.fromDegrees(Number(e[0]),Number(e[1]),Number(e[2]||0));try{this.entity.position.setValue(t.clone())}catch{this.entity.position=t.clone()}this.position=t.clone(),this.state="editing"}_createFileInput(){if(this._fileInput)return this._fileInput;const e=document.createElement("input");return e.type="file",e.accept="image/*",e.style.display="none",e.onchange=t=>{this._handleFileUpload(t)},document.body.appendChild(e),this._fileInput=e,e}_handleFileUpload(e){const t=e.target.files[0];if(!t)return;if(!t.type.match("image.*")){console.warn("请选择有效的图片文件");return}const n=new FileReader;n.onload=s=>{this.updateBillboardImage(s.target.result),this._fileInput&&(this._fileInput.value="")},n.onerror=s=>{console.error("文件读取失败:",s)},n.readAsDataURL(t)}_handleDoubleClick(){this._createFileInput().click()}editImage(e){return e?(this.updateBillboardImage(e),!0):(console.warn("CreateBillboard.editImage: 未提供有效的图片URL"),!1)}remove(){try{this.endEdit()}catch{}if(this.entity){this.state="no";try{this.viewer.entities.remove(this.entity)}catch{}this.entity=null}}getPositions(e){return e?se.cartesianToLnglat(this.position,this.viewer):this.position}getLnglats(){return this.getPositions(!0)}setPosition(e){let t=null;e instanceof Cesium.Cartesian3?t=e:t=Cesium.Cartesian3.fromDegrees(e[0],e[1],e[2]||0);try{this.entity.position.setValue(t.clone())}catch{this.entity.position=t.clone()}this.position=t.clone()}destroy(){try{this.endEdit()}catch{}if(this.handler){try{this.handler.destroy()}catch{}this.handler=null}if(this.entity){try{this.viewer.entities.remove(this.entity)}catch{}this.entity=null}if(this.prompt){try{this.prompt.destroy()}catch{}this.prompt=null}this.position=null,this.state="no",this._isDragging=!1,this._editPickedEntity=null}}class bp extends Ke{constructor(e,t){super(e,t),this.type="circle",this.viewer=e,this.style=t||{},this.center=null,this.radiusPoint=null,this.radiusPointEntity=null,this.entity=null,this.handler=null,this.modifyHandler=null,this.modifyPoint=null,this._dragStartCart=null,this._dragStartCartCarto=null,this.pointsCount=64}start(e){!this.prompt&&this.promptStyle?.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate",this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));const t=this;this.handler.setInputAction(function(n){const s=t.getCatesian3FromPX(n.position,t.viewer,[]);s&&(t.entity?(t.endCreate(),e&&e(t.entity)):(t.center=s.clone(),t.radiusPoint=s.clone(),t.entity=t._createPolyline(),t.radiusPointEntity=t.createPoint(t.radiusPoint),t.radiusPointEntity.typeAttr="radius",t.radiusPointEntity.show=!1))},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){if(!t.entity){t.prompt?.update(n.endPosition,"单击开始绘制");return}t.prompt?.update(n.endPosition,"单击结束");const s=t.getCatesian3FromPX(n.endPosition,t.viewer,[]);s&&(t.radiusPoint=s.clone(),t._updatePolyline(),t._updateAuxPoints(),t.state="creating")},Cesium.ScreenSpaceEventType.MOUSE_MOVE)}endCreate(){this.handler?.destroy(),this.handler=null,this.radiusPointEntity&&(this.radiusPointEntity.show=!1),this.prompt?.destroy(),this.prompt=null,this.state="endCreate"}startEdit(e){if(!this.entity)return;this.state="startEdit",this.modifyHandler||(this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));const t=this;this.radiusPointEntity&&(this.radiusPointEntity.show=!0),this.modifyHandler.setInputAction(function(n){const s=t.viewer.scene.pick(n.position);if(!s?.id)return;t.modifyPoint=s.id;const o=t.getCatesian3FromPX(n.position,t.viewer,[t.entity,t.modifyPoint]);o&&(t._dragStartCart=o,t._dragStartCartCarto=Cesium.Ellipsoid.WGS84.cartesianToCartographic(o),t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(n){if(!t.modifyPoint)return;const s=t.getCatesian3FromPX(n.endPosition,t.viewer,[t.entity,t.modifyPoint]);s&&(t.modifyPoint.typeAttr==="radius"&&(t.radiusPoint=s.clone()),t._updatePolyline(),t._updateAuxPoints(),e&&e(),t.state="editing")},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(){t.modifyPoint=null,t._dragStartCart=null,t._dragStartCartCarto=null,t.forbidDrawWorld(!1),t._updatePolyline(),e&&e(t.entity),t.state="editing"},Cesium.ScreenSpaceEventType.LEFT_UP)}endEdit(e){this.radiusPointEntity&&(this.radiusPointEntity.show=!1),this.modifyHandler?.destroy(),this.modifyHandler=null,this.forbidDrawWorld(!1),this.state="endEdit",e&&e(this.entity)}_createPolyline(){const e=this,t=this.viewer.entities.add({polyline:{positions:new Cesium.CallbackProperty(()=>e._buildCirclePositions(),!1),width:this.style.outlineWidth||this.style.width||5,material:this.style.color instanceof Cesium.Color?this.style.color:Cesium.Color.fromCssColorString(this.style.color||"#00FF00"),clampToGround:!1}});return t._plotInstance=this,t.objId=this.objId,t}_updatePolyline(){if(!this.entity)return;const e=this._buildCirclePositions();try{const t=this.entity.polyline.positions;if(t&&typeof t.getValue=="function")return;if(t&&typeof t.setValue=="function"){t.setValue(e);return}this.entity.polyline.positions=e}catch{this.entity.polyline.positions=e}}_buildCirclePositions(){if(!this.center||!this.radiusPoint)return[];const e=[],t=Cesium.Ellipsoid.WGS84,n=t.cartesianToCartographic(this.center),s=t.cartesianToCartographic(this.radiusPoint),o=Math.abs(s.longitude-n.longitude),r=Math.abs(s.latitude-n.latitude);for(let l=0;l<=this.pointsCount;l++){const a=l/this.pointsCount*Math.PI*2,d=n.longitude+o*Math.cos(a),h=n.latitude+r*Math.sin(a);e.push(Cesium.Cartesian3.fromRadians(d,h))}return e}_updateAuxPoints(){!this.radiusPoint||!this.radiusPointEntity||(this.radiusPointEntity.position=this.radiusPoint)}syncFromEntity(){if(!this.entity||!this.center||!this.radiusPoint)return;const e=this.center,t=this.entity._centerCoord;if(!t)return;const n=t.x-e.x,s=t.y-e.y,o=t.z-e.z;this.center=new Cesium.Cartesian3(this.center.x+n,this.center.y+s,this.center.z+o),this.radiusPoint=new Cesium.Cartesian3(this.radiusPoint.x+n,this.radiusPoint.y+s,this.radiusPoint.z+o);const r=this.entity.objId,l=this.entity._plotInstance;this.radiusPointEntity&&this.viewer.entities.remove(this.radiusPointEntity),this.radiusPointEntity=null,this.viewer.entities.remove(this.entity),this.entity=this._createPolyline(),this.entity._plotInstance=l,this.entity.objId=r,this.radiusPointEntity=this.createPoint(this.radiusPoint),this.radiusPointEntity.typeAttr="radius",this.radiusPointEntity.show=this.state==="editing"}updatePositions(e){if(!e||e.length<1)return!1;try{if(!this.center||!this.radiusPoint)return!1;let t;if(e[0]instanceof Cesium.Cartesian3)t=e[0];else return!1;this.center=Cesium.Cartesian3.add(this.center,t,new Cesium.Cartesian3),this.radiusPoint=Cesium.Cartesian3.add(this.radiusPoint,t,new Cesium.Cartesian3),this._updatePolyline(),this._updateAuxPoints();try{this.viewer.scene.requestRender()}catch{}return!0}catch(t){return console.warn("Failed to update circle positions:",t),!1}}getPositions(e){return e?se.cartesiansToLnglats([this.center,this.radiusPoint],this.viewer):[this.center,this.radiusPoint]}getStyle(){const e=this.entity.polyline,t=e.material.color.getValue();return{color:new Cesium.Color(t.red,t.green,t.blue,1).toCssHexString(),colorAlpha:t.alpha,outlineWidth:e.width.getValue()}}setStyle(e){if(!this.entity)return;const t={...this.style,...e};let n=t.color instanceof Cesium.Color?t.color:Cesium.Color.fromCssColorString(t.color||"#00FF00");t.colorAlpha!=null&&(n=n.withAlpha(t.colorAlpha)),this.entity.polyline.material=n,this.entity.polyline.width=t.outlineWidth||t.width||5,this.style=t}destroy(){try{this.handler?.destroy(),this.modifyHandler?.destroy(),this.entity&&this.viewer.entities.remove(this.entity),this.entity=null,this.radiusPointEntity&&this.viewer.entities.remove(this.radiusPointEntity),this.radiusPointEntity=null,this.prompt?.destroy(),this.prompt=null}catch{}}_manageRadiusPointEntity(){this.radiusPointEntity?this.radiusPoint&&(this.radiusPointEntity.position=this.radiusPoint):(this.radiusPointEntity=this.createPoint(this.radiusPoint),this.radiusPointEntity&&(this.radiusPointEntity.typeAttr="radius",this.radiusPointEntity.show=!1))}createByPositions(e,t){try{if(!e||e.length===0)return console.error("createByPositions: positions array is empty or undefined"),t&&t(null),this;const n=e[0]instanceof Cesium.Cartesian3?e:se.lnglatsToCartesians(e);if(!n||n.length===0)return console.error("createByPositions: failed to convert positions to Cartesian3"),t&&t(null),this;if(n.length>=2)this.center=Cesium.Cartesian3.clone(n[0]),this.radiusPoint=Cesium.Cartesian3.clone(n[1]);else if(n.length===1)this.center=Cesium.Cartesian3.clone(n[0]),this._createDefaultRadiusPoint();else return console.error("createByPositions: invalid positions array"),t&&t(null),this;this.entity?this._updatePolyline():this.entity=this._createPolyline(),this._manageRadiusPointEntity(),this._updateAuxPoints(),this.state="endCreate";try{this.viewer.scene.requestRender()}catch(s){console.error("requestRender error:",s)}return t&&t(this.entity),this}catch(n){return console.error("createByPositions error:",n),t&&t(null),this}}}class vp extends Ke{constructor(e,t){if(super(e,t),this.type="gltfModel",t=t||{},this.viewer=e,!t.uri){console.warn("请输入模型地址!");return}let n={heading:0,pitch:0,roll:0,minimumPixelSize:24,maximumScale:120};this.style=Object.assign(n,t||{}),this.modelUri=t.uri,this.entity=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate";let t=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(n){let s=t.getCatesian3FromPX(n.position,t.viewer);s&&(t.entity.position=s,t.position=s.clone()),t.endCreate(),e&&e(t.entity)},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){t.prompt.update(n.endPosition,"单击新增"),t.state="creating";let s=t.getCatesian3FromPX(n.endPosition,t.viewer,[t.entity]);s&&(t.entity?t.entity.position=s:t.entity=t.createGltfModel(s.clone()))},Cesium.ScreenSpaceEventType.MOUSE_MOVE)}createByPositions(e,t){e&&(this.state="startCreate",e instanceof Cesium.Cartesian3?this.position=e:this.position=Cesium.Cartesian3.fromDegrees(e[0],e[1],e[2]||0),this.entity=this.createGltfModel(this.position),t(this.entity),this.state="endCreate")}startEdit(e){if(this.state=="startEdit"||this.state=="editing")return;this.modifyHandler||(this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));let t=this,n;this.state="startEdit",this.modifyHandler.setInputAction(function(s){let o=t.viewer.scene.pick(s.position);Cesium.defined(o)&&o.id&&(n=o.id,t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(s){if(!n)return;let o=t.getCatesian3FromPX(s.endPosition,t.viewer,[t.entity]);o&&(t.entity&&(t.entity.position.setValue(o),t.position=o.clone()),t.state="editing",e&&e())},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(s){n&&(t.forbidDrawWorld(!1),t.modifyHandler&&(t.modifyHandler.destroy(),t.modifyHandler=null),t.state="editing")},Cesium.ScreenSpaceEventType.LEFT_UP)}endCreate(){let e=this;e.state="endCreate",e.handler&&(e.handler.destroy(),e.handler=null),e.prompt&&(e.prompt.destroy(),e.prompt=null)}done(){this.state=="startCreate"?this.destroy():this.state=="creating"?this.destroy():(this.state=="startEdit"||this.state=="editing")&&this.endEdit()}endEdit(e){this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null,e&&e(this.entity)),this.forbidDrawWorld(!1),this.state="endEdit"}createGltfModel(e){if(!e)return;let t=Cesium.Math.toRadians(this.style.heading),n=Cesium.Math.toRadians(this.style.pitch),s=Cesium.Math.toRadians(this.style.roll),o=new Cesium.HeadingPitchRoll(t,n,s),r=Cesium.Transforms.headingPitchRollQuaternion(e,o),l=this.viewer.entities.add({position:e,orientation:r,model:{uri:this.modelUri,minimumPixelSize:this.style.minimumPixelSize,maximumScale:this.style.maximumScale,scale:this.style.scale||1,heightReference:this.style.heightReference}});return l.objId=this.objId,l}getPositions(e){return e?se.cartesianToLnglat(this.position,this.viewer):this.position}getStyle(){let e={},t=this.entity.model;e.minimumPixelSize=t.minimumPixelSize.getValue();let n=this.entity.orientation.getValue(),s=this.entity.position.getValue(this.viewer.clock.currentTime),o=se.oreatationToHpr(s.clone(),n,!0)||{};e.heading=(o.heading||0)<360?o.heading+360:o.heading,e.pitch=o.pitch||0,e.roll=o.roll||0,e.scale=t.scale.getValue(),e.uri=t.uri.getValue();let r=this.entity.heightReference&&this.entity.heightReference.getValue();return r!=null&&(e.heightReference=Number(r)),e}setStyle(e){e&&(this.setOrientation(e.heading,e.pitch,e.roll),this.entity.model.scale.setValue(e.scale==null?1:e.scale),e.uri&&this.entity.model.uri.setValue(e.uri),e.heightReference!=null&&this.entity.model.heightReference.setValue(Number(e.heightReference)),this.style=Object.assign(this.style,e))}setOrientation(e,t,n){e=e||0,t=t||0,n=n||0,this.style.heading=e,this.style.pitch=t,this.style.roll=n;var s=Cesium.Math.toRadians(e||0),o=Cesium.Math.toRadians(t||0),r=Cesium.Math.toRadians(n||0),l=new Cesium.HeadingPitchRoll(s,o,r),a=this.entity.position._value,d=Cesium.Transforms.headingPitchRollQuaternion(a,l);this.entity&&(this.entity.orientation=d)}remove(){this.entity&&(this.state="no",this.viewer.entities.remove(this.entity),this.entity=null)}destroy(){this.handler&&(this.handler.destroy(),this.handler=null),this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.style=null,this.prompt&&(this.prompt.destroy(),this.prompt=null)}}String.prototype.codePointAt||(function(){var i=(function(){try{var t={},n=Object.defineProperty,s=n(t,t,t)&&n}catch{}return s})(),e=function(t){if(this==null)throw TypeError();var n=String(this),s=n.length,o=t?Number(t):0;if(o!=o&&(o=0),!(o<0||o>=s)){var r=n.charCodeAt(o),l;return r>=55296&&r<=56319&&s>o+1&&(l=n.charCodeAt(o+1),l>=56320&&l<=57343)?(r-55296)*1024+l-56320+65536:r}};i?i(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e})();function Qt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ss,Or;function Ip(){if(Or)return ss;Or=1;var i=0,e=-3;function t(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function n(g,P){this.source=g,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=P,this.destLen=0,this.ltree=new t,this.dtree=new t}var s=new t,o=new t,r=new Uint8Array(30),l=new Uint16Array(30),a=new Uint8Array(30),d=new Uint16Array(30),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),p=new t,f=new Uint8Array(320);function u(g,P,x,F){var _,H;for(_=0;_<x;++_)g[_]=0;for(_=0;_<30-x;++_)g[_+x]=_/x|0;for(H=F,_=0;_<30;++_)P[_]=H,H+=1<<g[_]}function m(g,P){var x;for(x=0;x<7;++x)g.table[x]=0;for(g.table[7]=24,g.table[8]=152,g.table[9]=112,x=0;x<24;++x)g.trans[x]=256+x;for(x=0;x<144;++x)g.trans[24+x]=x;for(x=0;x<8;++x)g.trans[168+x]=280+x;for(x=0;x<112;++x)g.trans[176+x]=144+x;for(x=0;x<5;++x)P.table[x]=0;for(P.table[5]=32,x=0;x<32;++x)P.trans[x]=x}var E=new Uint16Array(16);function A(g,P,x,F){var _,H;for(_=0;_<16;++_)g.table[_]=0;for(_=0;_<F;++_)g.table[P[x+_]]++;for(g.table[0]=0,H=0,_=0;_<16;++_)E[_]=H,H+=g.table[_];for(_=0;_<F;++_)P[x+_]&&(g.trans[E[P[x+_]]++]=_)}function y(g){g.bitcount--||(g.tag=g.source[g.sourceIndex++],g.bitcount=7);var P=g.tag&1;return g.tag>>>=1,P}function v(g,P,x){if(!P)return x;for(;g.bitcount<24;)g.tag|=g.source[g.sourceIndex++]<<g.bitcount,g.bitcount+=8;var F=g.tag&65535>>>16-P;return g.tag>>>=P,g.bitcount-=P,F+x}function S(g,P){for(;g.bitcount<24;)g.tag|=g.source[g.sourceIndex++]<<g.bitcount,g.bitcount+=8;var x=0,F=0,_=0,H=g.tag;do F=2*F+(H&1),H>>>=1,++_,x+=P.table[_],F-=P.table[_];while(F>=0);return g.tag=H,g.bitcount-=_,P.trans[x+F]}function M(g,P,x){var F,_,H,N,w,C;for(F=v(g,5,257),_=v(g,5,1),H=v(g,4,4),N=0;N<19;++N)f[N]=0;for(N=0;N<H;++N){var b=v(g,3,0);f[h[N]]=b}for(A(p,f,0,19),w=0;w<F+_;){var D=S(g,p);switch(D){case 16:var k=f[w-1];for(C=v(g,2,3);C;--C)f[w++]=k;break;case 17:for(C=v(g,3,3);C;--C)f[w++]=0;break;case 18:for(C=v(g,7,11);C;--C)f[w++]=0;break;default:f[w++]=D;break}}A(P,f,0,F),A(x,f,F,_)}function O(g,P,x){for(;;){var F=S(g,P);if(F===256)return i;if(F<256)g.dest[g.destLen++]=F;else{var _,H,N,w;for(F-=257,_=v(g,r[F],l[F]),H=S(g,x),N=g.destLen-v(g,a[H],d[H]),w=N;w<N+_;++w)g.dest[g.destLen++]=g.dest[w]}}}function I(g){for(var P,x,F;g.bitcount>8;)g.sourceIndex--,g.bitcount-=8;if(P=g.source[g.sourceIndex+1],P=256*P+g.source[g.sourceIndex],x=g.source[g.sourceIndex+3],x=256*x+g.source[g.sourceIndex+2],P!==(~x&65535))return e;for(g.sourceIndex+=4,F=P;F;--F)g.dest[g.destLen++]=g.source[g.sourceIndex++];return g.bitcount=0,i}function B(g,P){var x=new n(g,P),F,_,H;do{switch(F=y(x),_=v(x,2,0),_){case 0:H=I(x);break;case 1:H=O(x,s,o);break;case 2:M(x,x.ltree,x.dtree),H=O(x,x.ltree,x.dtree);break;default:H=e}if(H!==i)throw new Error("Data error")}while(!F);return x.destLen<x.dest.length?typeof x.dest.slice=="function"?x.dest.slice(0,x.destLen):x.dest.subarray(0,x.destLen):x.dest}return m(s,o),u(r,l,4,3),u(a,d,2,1),r[28]=0,l[28]=258,ss=B,ss}var Bp=Ip();const xp=Qt(Bp);function Gt(i,e,t,n,s){return Math.pow(1-s,3)*i+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*t+Math.pow(s,3)*n}function lt(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}lt.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},lt.prototype.addPoint=function(i,e){typeof i=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=i,this.x2=i),i<this.x1&&(this.x1=i),i>this.x2&&(this.x2=i)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))},lt.prototype.addX=function(i){this.addPoint(i,null)},lt.prototype.addY=function(i){this.addPoint(null,i)},lt.prototype.addBezier=function(i,e,t,n,s,o,r,l){const a=[i,e],d=[t,n],h=[s,o],p=[r,l];this.addPoint(i,e),this.addPoint(r,l);for(let f=0;f<=1;f++){const u=6*a[f]-12*d[f]+6*h[f],m=-3*a[f]+9*d[f]-9*h[f]+3*p[f],E=3*d[f]-3*a[f];if(m===0){if(u===0)continue;const S=-E/u;0<S&&S<1&&(f===0&&this.addX(Gt(a[f],d[f],h[f],p[f],S)),f===1&&this.addY(Gt(a[f],d[f],h[f],p[f],S)));continue}const A=Math.pow(u,2)-4*E*m;if(A<0)continue;const y=(-u+Math.sqrt(A))/(2*m);0<y&&y<1&&(f===0&&this.addX(Gt(a[f],d[f],h[f],p[f],y)),f===1&&this.addY(Gt(a[f],d[f],h[f],p[f],y)));const v=(-u-Math.sqrt(A))/(2*m);0<v&&v<1&&(f===0&&this.addX(Gt(a[f],d[f],h[f],p[f],v)),f===1&&this.addY(Gt(a[f],d[f],h[f],p[f],v)))}},lt.prototype.addQuad=function(i,e,t,n,s,o){const r=i+.6666666666666666*(t-i),l=e+2/3*(n-e),a=r+1/3*(s-i),d=l+1/3*(o-e);this.addBezier(i,e,r,l,a,d,s,o)};function be(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}be.prototype.moveTo=function(i,e){this.commands.push({type:"M",x:i,y:e})},be.prototype.lineTo=function(i,e){this.commands.push({type:"L",x:i,y:e})},be.prototype.curveTo=be.prototype.bezierCurveTo=function(i,e,t,n,s,o){this.commands.push({type:"C",x1:i,y1:e,x2:t,y2:n,x:s,y:o})},be.prototype.quadTo=be.prototype.quadraticCurveTo=function(i,e,t,n){this.commands.push({type:"Q",x1:i,y1:e,x:t,y:n})},be.prototype.close=be.prototype.closePath=function(){this.commands.push({type:"Z"})},be.prototype.extend=function(i){if(i.commands)i=i.commands;else if(i instanceof lt){const e=i;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,i)},be.prototype.getBoundingBox=function(){const i=new lt;let e=0,t=0,n=0,s=0;for(let o=0;o<this.commands.length;o++){const r=this.commands[o];switch(r.type){case"M":i.addPoint(r.x,r.y),e=n=r.x,t=s=r.y;break;case"L":i.addPoint(r.x,r.y),n=r.x,s=r.y;break;case"Q":i.addQuad(n,s,r.x1,r.y1,r.x,r.y),n=r.x,s=r.y;break;case"C":i.addBezier(n,s,r.x1,r.y1,r.x2,r.y2,r.x,r.y),n=r.x,s=r.y;break;case"Z":n=e,s=t;break;default:throw new Error("Unexpected path command "+r.type)}}return i.isEmpty()&&i.addPoint(0,0),i},be.prototype.draw=function(i){i.beginPath();for(let e=0;e<this.commands.length;e+=1){const t=this.commands[e];t.type==="M"?i.moveTo(t.x,t.y):t.type==="L"?i.lineTo(t.x,t.y):t.type==="C"?i.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):t.type==="Q"?i.quadraticCurveTo(t.x1,t.y1,t.x,t.y):t.type==="Z"&&i.closePath()}this.fill&&(i.fillStyle=this.fill,i.fill()),this.stroke&&(i.strokeStyle=this.stroke,i.lineWidth=this.strokeWidth,i.stroke())},be.prototype.toPathData=function(i){i=i!==void 0?i:2;function e(s){return Math.round(s)===s?""+Math.round(s):s.toFixed(i)}function t(){let s="";for(let o=0;o<arguments.length;o+=1){const r=arguments[o];r>=0&&o>0&&(s+=" "),s+=e(r)}return s}let n="";for(let s=0;s<this.commands.length;s+=1){const o=this.commands[s];o.type==="M"?n+="M"+t(o.x,o.y):o.type==="L"?n+="L"+t(o.x,o.y):o.type==="C"?n+="C"+t(o.x1,o.y1,o.x2,o.y2,o.x,o.y):o.type==="Q"?n+="Q"+t(o.x1,o.y1,o.x,o.y):o.type==="Z"&&(n+="Z")}return n},be.prototype.toSVG=function(i){let e='<path d="';return e+=this.toPathData(i),e+='"',this.fill&&this.fill!=="black"&&(this.fill===null?e+=' fill="none"':e+=' fill="'+this.fill+'"'),this.stroke&&(e+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),e+="/>",e},be.prototype.toDOMElement=function(i){const e=this.toPathData(i),t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",e),t};function Lr(i){throw new Error(i)}function Nr(i,e){i||Lr(e)}const te={fail:Lr,argument:Nr,assert:Nr},Ur=32768,_r=2147483648,Ht={},z={},Z={};function Ue(i){return function(){return i}}z.BYTE=function(i){return te.argument(i>=0&&i<=255,"Byte value should be between 0 and 255."),[i]},Z.BYTE=Ue(1),z.CHAR=function(i){return[i.charCodeAt(0)]},Z.CHAR=Ue(1),z.CHARARRAY=function(i){const e=[];for(let t=0;t<i.length;t+=1)e[t]=i.charCodeAt(t);return e},Z.CHARARRAY=function(i){return i.length},z.USHORT=function(i){return[i>>8&255,i&255]},Z.USHORT=Ue(2),z.SHORT=function(i){return i>=Ur&&(i=-(2*Ur-i)),[i>>8&255,i&255]},Z.SHORT=Ue(2),z.UINT24=function(i){return[i>>16&255,i>>8&255,i&255]},Z.UINT24=Ue(3),z.ULONG=function(i){return[i>>24&255,i>>16&255,i>>8&255,i&255]},Z.ULONG=Ue(4),z.LONG=function(i){return i>=_r&&(i=-(2*_r-i)),[i>>24&255,i>>16&255,i>>8&255,i&255]},Z.LONG=Ue(4),z.FIXED=z.ULONG,Z.FIXED=Z.ULONG,z.FWORD=z.SHORT,Z.FWORD=Z.SHORT,z.UFWORD=z.USHORT,Z.UFWORD=Z.USHORT,z.LONGDATETIME=function(i){return[0,0,0,0,i>>24&255,i>>16&255,i>>8&255,i&255]},Z.LONGDATETIME=Ue(8),z.TAG=function(i){return te.argument(i.length===4,"Tag should be exactly 4 ASCII characters."),[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]},Z.TAG=Ue(4),z.Card8=z.BYTE,Z.Card8=Z.BYTE,z.Card16=z.USHORT,Z.Card16=Z.USHORT,z.OffSize=z.BYTE,Z.OffSize=Z.BYTE,z.SID=z.USHORT,Z.SID=Z.USHORT,z.NUMBER=function(i){return i>=-107&&i<=107?[i+139]:i>=108&&i<=1131?(i=i-108,[(i>>8)+247,i&255]):i>=-1131&&i<=-108?(i=-i-108,[(i>>8)+251,i&255]):i>=-32768&&i<=32767?z.NUMBER16(i):z.NUMBER32(i)},Z.NUMBER=function(i){return z.NUMBER(i).length},z.NUMBER16=function(i){return[28,i>>8&255,i&255]},Z.NUMBER16=Ue(3),z.NUMBER32=function(i){return[29,i>>24&255,i>>16&255,i>>8&255,i&255]},Z.NUMBER32=Ue(5),z.REAL=function(i){let e=i.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const o=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(i*o)/o).toString()}let n="";for(let o=0,r=e.length;o<r;o+=1){const l=e[o];l==="e"?n+=e[++o]==="-"?"c":"b":l==="."?n+="a":l==="-"?n+="e":n+=l}n+=n.length&1?"f":"ff";const s=[30];for(let o=0,r=n.length;o<r;o+=2)s.push(parseInt(n.substr(o,2),16));return s},Z.REAL=function(i){return z.REAL(i).length},z.NAME=z.CHARARRAY,Z.NAME=Z.CHARARRAY,z.STRING=z.CHARARRAY,Z.STRING=Z.CHARARRAY,Ht.UTF8=function(i,e,t){const n=[],s=t;for(let o=0;o<s;o++,e+=1)n[o]=i.getUint8(e);return String.fromCharCode.apply(null,n)},Ht.UTF16=function(i,e,t){const n=[],s=t/2;for(let o=0;o<s;o++,e+=2)n[o]=i.getUint16(e);return String.fromCharCode.apply(null,n)},z.UTF16=function(i){const e=[];for(let t=0;t<i.length;t+=1){const n=i.charCodeAt(t);e[e.length]=n>>8&255,e[e.length]=n&255}return e},Z.UTF16=function(i){return i.length*2};const os={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Ht.MACSTRING=function(i,e,t,n){const s=os[n];if(s===void 0)return;let o="";for(let r=0;r<t;r++){const l=i.getUint8(e+r);l<=127?o+=String.fromCharCode(l):o+=s[l&127]}return o};const Hi=typeof WeakMap=="function"&&new WeakMap;let Yi;const Sp=function(i){if(!Yi){Yi={};for(let s in os)Yi[s]=new String(s)}const e=Yi[i];if(e===void 0)return;if(Hi){const s=Hi.get(e);if(s!==void 0)return s}const t=os[i];if(t===void 0)return;const n={};for(let s=0;s<t.length;s++)n[t.charCodeAt(s)]=s+128;return Hi&&Hi.set(e,n),n};z.MACSTRING=function(i,e){const t=Sp(e);if(t===void 0)return;const n=[];for(let s=0;s<i.length;s++){let o=i.charCodeAt(s);if(o>=128&&(o=t[o],o===void 0))return;n[s]=o}return n},Z.MACSTRING=function(i,e){const t=z.MACSTRING(i,e);return t!==void 0?t.length:0};function rs(i){return i>=-128&&i<=127}function Tp(i,e,t){let n=0;const s=i.length;for(;e<s&&n<64&&i[e]===0;)++e,++n;return t.push(128|n-1),e}function Mp(i,e,t){let n=0;const s=i.length;let o=e;for(;o<s&&n<64;){const r=i[o];if(!rs(r)||r===0&&o+1<s&&i[o+1]===0)break;++o,++n}t.push(n-1);for(let r=e;r<o;++r)t.push(i[r]+256&255);return o}function Dp(i,e,t){let n=0;const s=i.length;let o=e;for(;o<s&&n<64;){const r=i[o];if(r===0||rs(r)&&o+1<s&&rs(i[o+1]))break;++o,++n}t.push(64|n-1);for(let r=e;r<o;++r){const l=i[r];t.push(l+65536>>8&255,l+256&255)}return o}z.VARDELTAS=function(i){let e=0;const t=[];for(;e<i.length;){const n=i[e];n===0?e=Tp(i,e,t):n>=-128&&n<=127?e=Mp(i,e,t):e=Dp(i,e,t)}return t},z.INDEX=function(i){let e=1;const t=[e],n=[];for(let l=0;l<i.length;l+=1){const a=z.OBJECT(i[l]);Array.prototype.push.apply(n,a),e+=a.length,t.push(e)}if(n.length===0)return[0,0];const s=[],o=1+Math.floor(Math.log(e)/Math.log(2))/8|0,r=[void 0,z.BYTE,z.USHORT,z.UINT24,z.ULONG][o];for(let l=0;l<t.length;l+=1){const a=r(t[l]);Array.prototype.push.apply(s,a)}return Array.prototype.concat(z.Card16(i.length),z.OffSize(o),s,n)},Z.INDEX=function(i){return z.INDEX(i).length},z.DICT=function(i){let e=[];const t=Object.keys(i),n=t.length;for(let s=0;s<n;s+=1){const o=parseInt(t[s],0),r=i[o];e=e.concat(z.OPERAND(r.value,r.type)),e=e.concat(z.OPERATOR(o))}return e},Z.DICT=function(i){return z.DICT(i).length},z.OPERATOR=function(i){return i<1200?[i]:[12,i-1200]},z.OPERAND=function(i,e){let t=[];if(Array.isArray(e))for(let n=0;n<e.length;n+=1)te.argument(i.length===e.length,"Not enough arguments given for type"+e),t=t.concat(z.OPERAND(i[n],e[n]));else if(e==="SID")t=t.concat(z.NUMBER(i));else if(e==="offset")t=t.concat(z.NUMBER32(i));else if(e==="number")t=t.concat(z.NUMBER(i));else if(e==="real")t=t.concat(z.REAL(i));else throw new Error("Unknown operand type "+e);return t},z.OP=z.BYTE,Z.OP=Z.BYTE;const Vi=typeof WeakMap=="function"&&new WeakMap;z.CHARSTRING=function(i){if(Vi){const n=Vi.get(i);if(n!==void 0)return n}let e=[];const t=i.length;for(let n=0;n<t;n+=1){const s=i[n];e=e.concat(z[s.type](s.value))}return Vi&&Vi.set(i,e),e},Z.CHARSTRING=function(i){return z.CHARSTRING(i).length},z.OBJECT=function(i){const e=z[i.type];return te.argument(e!==void 0,"No encoding function for type "+i.type),e(i.value)},Z.OBJECT=function(i){const e=Z[i.type];return te.argument(e!==void 0,"No sizeOf function for type "+i.type),e(i.value)},z.TABLE=function(i){let e=[];const t=i.fields.length,n=[],s=[];for(let o=0;o<t;o+=1){const r=i.fields[o],l=z[r.type];te.argument(l!==void 0,"No encoding function for field type "+r.type+" ("+r.name+")");let a=i[r.name];a===void 0&&(a=r.value);const d=l(a);r.type==="TABLE"?(s.push(e.length),e=e.concat([0,0]),n.push(d)):e=e.concat(d)}for(let o=0;o<n.length;o+=1){const r=s[o],l=e.length;te.argument(l<65536,"Table "+i.tableName+" too big."),e[r]=l>>8,e[r+1]=l&255,e=e.concat(n[o])}return e},Z.TABLE=function(i){let e=0;const t=i.fields.length;for(let n=0;n<t;n+=1){const s=i.fields[n],o=Z[s.type];te.argument(o!==void 0,"No sizeOf function for field type "+s.type+" ("+s.name+")");let r=i[s.name];r===void 0&&(r=s.value),e+=o(r),s.type==="TABLE"&&(e+=2)}return e},z.RECORD=z.TABLE,Z.RECORD=Z.TABLE,z.LITERAL=function(i){return i},Z.LITERAL=function(i){return i.length};function Se(i,e,t){for(let n=0;n<e.length;n+=1){const s=e[n];this[s.name]=s.value}if(this.tableName=i,this.fields=e,t){const n=Object.keys(t);for(let s=0;s<n.length;s+=1){const o=n[s],r=t[o];this[o]!==void 0&&(this[o]=r)}}}Se.prototype.encode=function(){return z.TABLE(this)},Se.prototype.sizeOf=function(){return Z.TABLE(this)};function ai(i,e,t){t===void 0&&(t=e.length);const n=new Array(e.length+1);n[0]={name:i+"Count",type:"USHORT",value:t};for(let s=0;s<e.length;s++)n[s+1]={name:i+s,type:"USHORT",value:e[s]};return n}function as(i,e,t){const n=e.length,s=new Array(n+1);s[0]={name:i+"Count",type:"USHORT",value:n};for(let o=0;o<n;o++)s[o+1]={name:i+o,type:"TABLE",value:t(e[o],o)};return s}function zi(i,e,t){const n=e.length;let s=[];s[0]={name:i+"Count",type:"USHORT",value:n};for(let o=0;o<n;o++)s=s.concat(t(e[o],o));return s}function Wi(i){i.format===1?Se.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(ai("glyph",i.glyphs))):te.assert(!1,"Can't create coverage table format 2 yet.")}Wi.prototype=Object.create(Se.prototype),Wi.prototype.constructor=Wi;function ji(i){Se.call(this,"scriptListTable",zi("scriptRecord",i,function(e,t){const n=e.script;let s=n.defaultLangSys;return te.assert(!!s,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+t,type:"TAG",value:e.tag},{name:"script"+t,type:"TABLE",value:new Se("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Se("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(ai("featureIndex",s.featureIndexes)))}].concat(zi("langSys",n.langSysRecords,function(o,r){const l=o.langSys;return[{name:"langSysTag"+r,type:"TAG",value:o.tag},{name:"langSys"+r,type:"TABLE",value:new Se("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:l.reqFeatureIndex}].concat(ai("featureIndex",l.featureIndexes)))}]})))}]}))}ji.prototype=Object.create(Se.prototype),ji.prototype.constructor=ji;function Ki(i){Se.call(this,"featureListTable",zi("featureRecord",i,function(e,t){const n=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new Se("featureTable",[{name:"featureParams",type:"USHORT",value:n.featureParams}].concat(ai("lookupListIndex",n.lookupListIndexes)))}]}))}Ki.prototype=Object.create(Se.prototype),Ki.prototype.constructor=Ki;function $i(i,e){Se.call(this,"lookupListTable",as("lookup",i,function(t){let n=e[t.lookupType];return te.assert(!!n,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new Se("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(as("subtable",t.subtables,n)))}))}$i.prototype=Object.create(Se.prototype),$i.prototype.constructor=$i;const J={Table:Se,Record:Se,Coverage:Wi,ScriptList:ji,FeatureList:Ki,LookupList:$i,ushortList:ai,tableList:as,recordList:zi};function Qr(i,e){return i.getUint8(e)}function Xi(i,e){return i.getUint16(e,!1)}function kp(i,e){return i.getInt16(e,!1)}function ls(i,e){return i.getUint32(e,!1)}function Gr(i,e){const t=i.getInt16(e,!1),n=i.getUint16(e+2,!1);return t+n/65535}function Pp(i,e){let t="";for(let n=e;n<e+4;n+=1)t+=String.fromCharCode(i.getInt8(n));return t}function Fp(i,e,t){let n=0;for(let s=0;s<t;s+=1)n<<=8,n+=i.getUint8(e+s);return n}function Rp(i,e,t){const n=[];for(let s=e;s<t;s+=1)n.push(i.getUint8(s));return n}function Op(i){let e="";for(let t=0;t<i.length;t+=1)e+=String.fromCharCode(i[t]);return e}const Lp={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function G(i,e){this.data=i,this.offset=e,this.relativeOffset=0}G.prototype.parseByte=function(){const i=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},G.prototype.parseChar=function(){const i=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},G.prototype.parseCard8=G.prototype.parseByte,G.prototype.parseUShort=function(){const i=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},G.prototype.parseCard16=G.prototype.parseUShort,G.prototype.parseSID=G.prototype.parseUShort,G.prototype.parseOffset16=G.prototype.parseUShort,G.prototype.parseShort=function(){const i=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},G.prototype.parseF2Dot14=function(){const i=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,i},G.prototype.parseULong=function(){const i=ls(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},G.prototype.parseOffset32=G.prototype.parseULong,G.prototype.parseFixed=function(){const i=Gr(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},G.prototype.parseString=function(i){const e=this.data,t=this.offset+this.relativeOffset;let n="";this.relativeOffset+=i;for(let s=0;s<i;s++)n+=String.fromCharCode(e.getUint8(t+s));return n},G.prototype.parseTag=function(){return this.parseString(4)},G.prototype.parseLongDateTime=function(){let i=ls(this.data,this.offset+this.relativeOffset+4);return i-=2082844800,this.relativeOffset+=8,i},G.prototype.parseVersion=function(i){const e=Xi(this.data,this.offset+this.relativeOffset),t=Xi(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,i===void 0&&(i=4096),e+t/i/10},G.prototype.skip=function(i,e){e===void 0&&(e=1),this.relativeOffset+=Lp[i]*e},G.prototype.parseULongList=function(i){i===void 0&&(i=this.parseULong());const e=new Array(i),t=this.data;let n=this.offset+this.relativeOffset;for(let s=0;s<i;s++)e[s]=t.getUint32(n),n+=4;return this.relativeOffset+=i*4,e},G.prototype.parseOffset16List=G.prototype.parseUShortList=function(i){i===void 0&&(i=this.parseUShort());const e=new Array(i),t=this.data;let n=this.offset+this.relativeOffset;for(let s=0;s<i;s++)e[s]=t.getUint16(n),n+=2;return this.relativeOffset+=i*2,e},G.prototype.parseShortList=function(i){const e=new Array(i),t=this.data;let n=this.offset+this.relativeOffset;for(let s=0;s<i;s++)e[s]=t.getInt16(n),n+=2;return this.relativeOffset+=i*2,e},G.prototype.parseByteList=function(i){const e=new Array(i),t=this.data;let n=this.offset+this.relativeOffset;for(let s=0;s<i;s++)e[s]=t.getUint8(n++);return this.relativeOffset+=i,e},G.prototype.parseList=function(i,e){e||(e=i,i=this.parseUShort());const t=new Array(i);for(let n=0;n<i;n++)t[n]=e.call(this);return t},G.prototype.parseList32=function(i,e){e||(e=i,i=this.parseULong());const t=new Array(i);for(let n=0;n<i;n++)t[n]=e.call(this);return t},G.prototype.parseRecordList=function(i,e){e||(e=i,i=this.parseUShort());const t=new Array(i),n=Object.keys(e);for(let s=0;s<i;s++){const o={};for(let r=0;r<n.length;r++){const l=n[r],a=e[l];o[l]=a.call(this)}t[s]=o}return t},G.prototype.parseRecordList32=function(i,e){e||(e=i,i=this.parseULong());const t=new Array(i),n=Object.keys(e);for(let s=0;s<i;s++){const o={};for(let r=0;r<n.length;r++){const l=n[r],a=e[l];o[l]=a.call(this)}t[s]=o}return t},G.prototype.parseStruct=function(i){if(typeof i=="function")return i.call(this);{const e=Object.keys(i),t={};for(let n=0;n<e.length;n++){const s=e[n],o=i[s];t[s]=o.call(this)}return t}},G.prototype.parseValueRecord=function(i){if(i===void 0&&(i=this.parseUShort()),i===0)return;const e={};return i&1&&(e.xPlacement=this.parseShort()),i&2&&(e.yPlacement=this.parseShort()),i&4&&(e.xAdvance=this.parseShort()),i&8&&(e.yAdvance=this.parseShort()),i&16&&(e.xPlaDevice=void 0,this.parseShort()),i&32&&(e.yPlaDevice=void 0,this.parseShort()),i&64&&(e.xAdvDevice=void 0,this.parseShort()),i&128&&(e.yAdvDevice=void 0,this.parseShort()),e},G.prototype.parseValueRecordList=function(){const i=this.parseUShort(),e=this.parseUShort(),t=new Array(e);for(let n=0;n<e;n++)t[n]=this.parseValueRecord(i);return t},G.prototype.parsePointer=function(i){const e=this.parseOffset16();if(e>0)return new G(this.data,this.offset+e).parseStruct(i)},G.prototype.parsePointer32=function(i){const e=this.parseOffset32();if(e>0)return new G(this.data,this.offset+e).parseStruct(i)},G.prototype.parseListOfLists=function(i){const e=this.parseOffset16List(),t=e.length,n=this.relativeOffset,s=new Array(t);for(let o=0;o<t;o++){const r=e[o];if(r===0){s[o]=void 0;continue}if(this.relativeOffset=r,i){const l=this.parseOffset16List(),a=new Array(l.length);for(let d=0;d<l.length;d++)this.relativeOffset=r+l[d],a[d]=i.call(this);s[o]=a}else s[o]=this.parseUShortList()}return this.relativeOffset=n,s},G.prototype.parseCoverage=function(){const i=this.offset+this.relativeOffset,e=this.parseUShort(),t=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(t)};if(e===2){const n=new Array(t);for(let s=0;s<t;s++)n[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:n}}throw new Error("0x"+i.toString(16)+": Coverage format must be 1 or 2.")},G.prototype.parseClassDef=function(){const i=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()};if(e===2)return{format:2,ranges:this.parseRecordList({start:G.uShort,end:G.uShort,classId:G.uShort})};throw new Error("0x"+i.toString(16)+": ClassDef format must be 1 or 2.")},G.list=function(i,e){return function(){return this.parseList(i,e)}},G.list32=function(i,e){return function(){return this.parseList32(i,e)}},G.recordList=function(i,e){return function(){return this.parseRecordList(i,e)}},G.recordList32=function(i,e){return function(){return this.parseRecordList32(i,e)}},G.pointer=function(i){return function(){return this.parsePointer(i)}},G.pointer32=function(i){return function(){return this.parsePointer32(i)}},G.tag=G.prototype.parseTag,G.byte=G.prototype.parseByte,G.uShort=G.offset16=G.prototype.parseUShort,G.uShortList=G.prototype.parseUShortList,G.uLong=G.offset32=G.prototype.parseULong,G.uLongList=G.prototype.parseULongList,G.struct=G.prototype.parseStruct,G.coverage=G.prototype.parseCoverage,G.classDef=G.prototype.parseClassDef;const Hr={reserved:G.uShort,reqFeatureIndex:G.uShort,featureIndexes:G.uShortList};G.prototype.parseScriptList=function(){return this.parsePointer(G.recordList({tag:G.tag,script:G.pointer({defaultLangSys:G.pointer(Hr),langSysRecords:G.recordList({tag:G.tag,langSys:G.pointer(Hr)})})}))||[]},G.prototype.parseFeatureList=function(){return this.parsePointer(G.recordList({tag:G.tag,feature:G.pointer({featureParams:G.offset16,lookupListIndexes:G.uShortList})}))||[]},G.prototype.parseLookupList=function(i){return this.parsePointer(G.list(G.pointer(function(){const e=this.parseUShort();te.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");const t=this.parseUShort(),n=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(G.pointer(i[e])),markFilteringSet:n?this.parseUShort():void 0}})))||[]},G.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){const i=this.parseUShort(),e=this.parseUShort();return te.argument(i===1&&e<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:G.offset32,featureTableSubstitutionOffset:G.offset32})})||[]};const $={getByte:Qr,getCard8:Qr,getUShort:Xi,getCard16:Xi,getShort:kp,getULong:ls,getFixed:Gr,getTag:Pp,getOffset:Fp,getBytes:Rp,bytesToString:Op,Parser:G};function Np(i,e){e.parseUShort(),i.length=e.parseULong(),i.language=e.parseULong();let t;i.groupCount=t=e.parseULong(),i.glyphIndexMap={};for(let n=0;n<t;n+=1){const s=e.parseULong(),o=e.parseULong();let r=e.parseULong();for(let l=s;l<=o;l+=1)i.glyphIndexMap[l]=r,r++}}function Up(i,e,t,n,s){i.length=e.parseUShort(),i.language=e.parseUShort();let o;i.segCount=o=e.parseUShort()>>1,e.skip("uShort",3),i.glyphIndexMap={};const r=new $.Parser(t,n+s+14),l=new $.Parser(t,n+s+16+o*2),a=new $.Parser(t,n+s+16+o*4),d=new $.Parser(t,n+s+16+o*6);let h=n+s+16+o*8;for(let p=0;p<o-1;p+=1){let f;const u=r.parseUShort(),m=l.parseUShort(),E=a.parseShort(),A=d.parseUShort();for(let y=m;y<=u;y+=1)A!==0?(h=d.offset+d.relativeOffset-2,h+=A,h+=(y-m)*2,f=$.getUShort(t,h),f!==0&&(f=f+E&65535)):f=y+E&65535,i.glyphIndexMap[y]=f}}function _p(i,e){const t={};t.version=$.getUShort(i,e),te.argument(t.version===0,"cmap table version should be 0."),t.numTables=$.getUShort(i,e+2);let n=-1;for(let o=t.numTables-1;o>=0;o-=1){const r=$.getUShort(i,e+4+o*8),l=$.getUShort(i,e+4+o*8+2);if(r===3&&(l===0||l===1||l===10)||r===0&&(l===0||l===1||l===2||l===3||l===4)){n=$.getULong(i,e+4+o*8+4);break}}if(n===-1)throw new Error("No valid cmap sub-tables found.");const s=new $.Parser(i,e+n);if(t.format=s.parseUShort(),t.format===12)Np(t,s);else if(t.format===4)Up(t,s,i,e,n);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+t.format+").");return t}function Qp(i,e,t){i.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function Gp(i){i.segments.push({end:65535,start:65535,delta:1,offset:0})}function Hp(i){let e=!0,t;for(t=i.length-1;t>0;t-=1)if(i.get(t).unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}let n=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||(n=n.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),n=n.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);const s=new J.Table("cmap",n);for(s.segments=[],t=0;t<i.length;t+=1){const u=i.get(t);for(let m=0;m<u.unicodes.length;m+=1)Qp(s,u.unicodes[m],t);s.segments=s.segments.sort(function(m,E){return m.start-E.start})}Gp(s);const o=s.segments.length;let r=0,l=[],a=[],d=[],h=[],p=[],f=[];for(t=0;t<o;t+=1){const u=s.segments[t];u.end<=65535&&u.start<=65535?(l=l.concat({name:"end_"+t,type:"USHORT",value:u.end}),a=a.concat({name:"start_"+t,type:"USHORT",value:u.start}),d=d.concat({name:"idDelta_"+t,type:"SHORT",value:u.delta}),h=h.concat({name:"idRangeOffset_"+t,type:"USHORT",value:u.offset}),u.glyphId!==void 0&&(p=p.concat({name:"glyph_"+t,type:"USHORT",value:u.glyphId}))):r+=1,!e&&u.glyphIndex!==void 0&&(f=f.concat({name:"cmap12Start_"+t,type:"ULONG",value:u.start}),f=f.concat({name:"cmap12End_"+t,type:"ULONG",value:u.end}),f=f.concat({name:"cmap12Glyph_"+t,type:"ULONG",value:u.glyphIndex}))}if(s.segCountX2=(o-r)*2,s.searchRange=Math.pow(2,Math.floor(Math.log(o-r)/Math.log(2)))*2,s.entrySelector=Math.log(s.searchRange/2)/Math.log(2),s.rangeShift=s.segCountX2-s.searchRange,s.fields=s.fields.concat(l),s.fields.push({name:"reservedPad",type:"USHORT",value:0}),s.fields=s.fields.concat(a),s.fields=s.fields.concat(d),s.fields=s.fields.concat(h),s.fields=s.fields.concat(p),s.cmap4Length=14+l.length*2+2+a.length*2+d.length*2+h.length*2+p.length*2,!e){const u=16+f.length*4;s.cmap12Offset=20+s.cmap4Length,s.fields=s.fields.concat([{name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:u},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:f.length/3}]),s.fields=s.fields.concat(f)}return s}const Yr={parse:_p,make:Hp},qi=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],Yp=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],Vp=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],wt=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function Vr(i){this.font=i}Vr.prototype.charToGlyphIndex=function(i){const e=i.codePointAt(0),t=this.font.glyphs;if(t)for(let n=0;n<t.length;n+=1){const s=t.get(n);for(let o=0;o<s.unicodes.length;o+=1)if(s.unicodes[o]===e)return n}return null};function zr(i){this.cmap=i}zr.prototype.charToGlyphIndex=function(i){return this.cmap.glyphIndexMap[i.codePointAt(0)]||0};function Ji(i,e){this.encoding=i,this.charset=e}Ji.prototype.charToGlyphIndex=function(i){const e=i.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function cs(i){switch(i.version){case 1:this.names=wt.slice();break;case 2:this.names=new Array(i.numberOfGlyphs);for(let e=0;e<i.numberOfGlyphs;e++)i.glyphNameIndex[e]<wt.length?this.names[e]=wt[i.glyphNameIndex[e]]:this.names[e]=i.names[i.glyphNameIndex[e]-wt.length];break;case 2.5:this.names=new Array(i.numberOfGlyphs);for(let e=0;e<i.numberOfGlyphs;e++)this.names[e]=wt[e+i.glyphNameIndex[e]];break;case 3:this.names=[];break;default:this.names=[];break}}cs.prototype.nameToGlyphIndex=function(i){return this.names.indexOf(i)},cs.prototype.glyphIndexToName=function(i){return this.names[i]};function zp(i){let e;const t=i.tables.cmap.glyphIndexMap,n=Object.keys(t);for(let s=0;s<n.length;s+=1){const o=n[s],r=t[o];e=i.glyphs.get(r),e.addUnicode(parseInt(o))}for(let s=0;s<i.glyphs.length;s+=1)e=i.glyphs.get(s),i.cffEncoding?i.isCIDFont?e.name="gid"+s:e.name=i.cffEncoding.charset[s]:i.glyphNames.names&&(e.name=i.glyphNames.glyphIndexToName(s))}function Wp(i,e,t,n,s){i.beginPath(),i.moveTo(e,t),i.lineTo(n,s),i.stroke()}const bt={line:Wp};function jp(i,e){let t=e||new be;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(n){t=n}}}function Ne(i){this.bindConstructorValues(i)}Ne.prototype.bindConstructorValues=function(i){this.index=i.index||0,this.name=i.name||null,this.unicode=i.unicode||void 0,this.unicodes=i.unicodes||i.unicode!==void 0?[i.unicode]:[],i.xMin&&(this.xMin=i.xMin),i.yMin&&(this.yMin=i.yMin),i.xMax&&(this.xMax=i.xMax),i.yMax&&(this.yMax=i.yMax),i.advanceWidth&&(this.advanceWidth=i.advanceWidth),Object.defineProperty(this,"path",jp(this,i.path))},Ne.prototype.addUnicode=function(i){this.unicodes.length===0&&(this.unicode=i),this.unicodes.push(i)},Ne.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},Ne.prototype.getPath=function(i,e,t,n,s){i=i!==void 0?i:0,e=e!==void 0?e:0,t=t!==void 0?t:72;let o,r;n||(n={});let l=n.xScale,a=n.yScale;if(n.hinting&&s&&s.hinting&&(r=this.path&&s.hinting.exec(this,t)),r)o=s.hinting.getCommands(r),i=Math.round(i),e=Math.round(e),l=a=1;else{o=this.path.commands;const h=1/this.path.unitsPerEm*t;l===void 0&&(l=h),a===void 0&&(a=h)}const d=new be;for(let h=0;h<o.length;h+=1){const p=o[h];p.type==="M"?d.moveTo(i+p.x*l,e+-p.y*a):p.type==="L"?d.lineTo(i+p.x*l,e+-p.y*a):p.type==="Q"?d.quadraticCurveTo(i+p.x1*l,e+-p.y1*a,i+p.x*l,e+-p.y*a):p.type==="C"?d.curveTo(i+p.x1*l,e+-p.y1*a,i+p.x2*l,e+-p.y2*a,i+p.x*l,e+-p.y*a):p.type==="Z"&&d.closePath()}return d},Ne.prototype.getContours=function(){if(this.points===void 0)return[];const i=[];let e=[];for(let t=0;t<this.points.length;t+=1){const n=this.points[t];e.push(n),n.lastPointOfContour&&(i.push(e),e=[])}return te.argument(e.length===0,"There are still points left in the current contour."),i},Ne.prototype.getMetrics=function(){const i=this.path.commands,e=[],t=[];for(let s=0;s<i.length;s+=1){const o=i[s];o.type!=="Z"&&(e.push(o.x),t.push(o.y)),(o.type==="Q"||o.type==="C")&&(e.push(o.x1),t.push(o.y1)),o.type==="C"&&(e.push(o.x2),t.push(o.y2))}const n={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,t),leftSideBearing:this.leftSideBearing};return isFinite(n.xMin)||(n.xMin=0),isFinite(n.xMax)||(n.xMax=this.advanceWidth),isFinite(n.yMin)||(n.yMin=0),isFinite(n.yMax)||(n.yMax=0),n.rightSideBearing=this.advanceWidth-n.leftSideBearing-(n.xMax-n.xMin),n},Ne.prototype.draw=function(i,e,t,n,s){this.getPath(e,t,n,s).draw(i)},Ne.prototype.drawPoints=function(i,e,t,n){function s(d,h,p,f){const u=Math.PI*2;i.beginPath();for(let m=0;m<d.length;m+=1)i.moveTo(h+d[m].x*f,p+d[m].y*f),i.arc(h+d[m].x*f,p+d[m].y*f,2,0,u,!1);i.closePath(),i.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:24;const o=1/this.path.unitsPerEm*n,r=[],l=[],a=this.path;for(let d=0;d<a.commands.length;d+=1){const h=a.commands[d];h.x!==void 0&&r.push({x:h.x,y:-h.y}),h.x1!==void 0&&l.push({x:h.x1,y:-h.y1}),h.x2!==void 0&&l.push({x:h.x2,y:-h.y2})}i.fillStyle="blue",s(r,e,t,o),i.fillStyle="red",s(l,e,t,o)},Ne.prototype.drawMetrics=function(i,e,t,n){let s;e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:24,s=1/this.path.unitsPerEm*n,i.lineWidth=1,i.strokeStyle="black",bt.line(i,e,-1e4,e,1e4),bt.line(i,-1e4,t,1e4,t);const o=this.xMin||0;let r=this.yMin||0;const l=this.xMax||0;let a=this.yMax||0;const d=this.advanceWidth||0;i.strokeStyle="blue",bt.line(i,e+o*s,-1e4,e+o*s,1e4),bt.line(i,e+l*s,-1e4,e+l*s,1e4),bt.line(i,-1e4,t+-r*s,1e4,t+-r*s),bt.line(i,-1e4,t+-a*s,1e4,t+-a*s),i.strokeStyle="green",bt.line(i,e+d*s,-1e4,e+d*s,1e4)};function Zi(i,e,t){Object.defineProperty(i,e,{get:function(){return i.path,i[t]},set:function(n){i[t]=n},enumerable:!0,configurable:!0})}function ds(i,e){if(this.font=i,this.glyphs={},Array.isArray(e))for(let t=0;t<e.length;t++)this.glyphs[t]=e[t];this.length=e&&e.length||0}ds.prototype.get=function(i){return typeof this.glyphs[i]=="function"&&(this.glyphs[i]=this.glyphs[i]()),this.glyphs[i]},ds.prototype.push=function(i,e){this.glyphs[i]=e,this.length++};function Kp(i,e){return new Ne({index:e,font:i})}function $p(i,e,t,n,s,o){return function(){const r=new Ne({index:e,font:i});return r.path=function(){t(r,n,s);const l=o(i.glyphs,r);return l.unitsPerEm=i.unitsPerEm,l},Zi(r,"xMin","_xMin"),Zi(r,"xMax","_xMax"),Zi(r,"yMin","_yMin"),Zi(r,"yMax","_yMax"),r}}function Xp(i,e,t,n){return function(){const s=new Ne({index:e,font:i});return s.path=function(){const o=t(i,s,n);return o.unitsPerEm=i.unitsPerEm,o},s}}const Yt={GlyphSet:ds,glyphLoader:Kp,ttfGlyphLoader:$p,cffGlyphLoader:Xp};function Wr(i,e){if(i===e)return!0;if(Array.isArray(i)&&Array.isArray(e)){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t+=1)if(!Wr(i[t],e[t]))return!1;return!0}else return!1}function hs(i){let e;return i.length<1240?e=107:i.length<33900?e=1131:e=32768,e}function ct(i,e,t){const n=[],s=[],o=$.getCard16(i,e);let r,l;if(o!==0){const a=$.getByte(i,e+2);r=e+(o+1)*a+2;let d=e+3;for(let h=0;h<o+1;h+=1)n.push($.getOffset(i,d,a)),d+=a;l=r+n[o]}else l=e+2;for(let a=0;a<n.length-1;a+=1){let d=$.getBytes(i,r+n[a],r+n[a+1]);t&&(d=t(d)),s.push(d)}return{objects:s,startOffset:e,endOffset:l}}function qp(i){let e="";const n=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=i.parseByte(),o=s>>4,r=s&15;if(o===15||(e+=n[o],r===15))break;e+=n[r]}return parseFloat(e)}function Jp(i,e){let t,n,s,o;if(e===28)return t=i.parseByte(),n=i.parseByte(),t<<8|n;if(e===29)return t=i.parseByte(),n=i.parseByte(),s=i.parseByte(),o=i.parseByte(),t<<24|n<<16|s<<8|o;if(e===30)return qp(i);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=i.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=i.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function Zp(i){const e={};for(let t=0;t<i.length;t+=1){const n=i[t][0],s=i[t][1];let o;if(s.length===1?o=s[0]:o=s,e.hasOwnProperty(n)&&!isNaN(e[n]))throw new Error("Object "+e+" already has key "+n);e[n]=o}return e}function jr(i,e,t){e=e!==void 0?e:0;const n=new $.Parser(i,e),s=[];let o=[];for(t=t!==void 0?t:i.length;n.relativeOffset<t;){let r=n.parseByte();r<=21?(r===12&&(r=1200+n.parseByte()),s.push([r,o]),o=[]):o.push(Jp(n,r))}return Zp(s)}function li(i,e){return e<=390?e=qi[e]:e=i[e-391],e}function Kr(i,e,t){const n={};let s;for(let o=0;o<e.length;o+=1){const r=e[o];if(Array.isArray(r.type)){const l=[];l.length=r.type.length;for(let a=0;a<r.type.length;a++)s=i[r.op]!==void 0?i[r.op][a]:void 0,s===void 0&&(s=r.value!==void 0&&r.value[a]!==void 0?r.value[a]:null),r.type[a]==="SID"&&(s=li(t,s)),l[a]=s;n[r.name]=l}else s=i[r.op],s===void 0&&(s=r.value!==void 0?r.value:null),r.type==="SID"&&(s=li(t,s)),n[r.name]=s}return n}function eg(i,e){const t={};return t.formatMajor=$.getCard8(i,e),t.formatMinor=$.getCard8(i,e+1),t.size=$.getCard8(i,e+2),t.offsetSize=$.getCard8(i,e+3),t.startOffset=e,t.endOffset=e+4,t}const $r=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],Xr=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}];function tg(i,e){const t=jr(i,0,i.byteLength);return Kr(t,$r,e)}function qr(i,e,t,n){const s=jr(i,e,t);return Kr(s,Xr,n)}function Jr(i,e,t,n){const s=[];for(let o=0;o<t.length;o+=1){const r=new DataView(new Uint8Array(t[o]).buffer),l=tg(r,n);l._subrs=[],l._subrsBias=0;const a=l.private[0],d=l.private[1];if(a!==0&&d!==0){const h=qr(i,d+e,a,n);if(l._defaultWidthX=h.defaultWidthX,l._nominalWidthX=h.nominalWidthX,h.subrs!==0){const p=d+h.subrs,f=ct(i,p+e);l._subrs=f.objects,l._subrsBias=hs(l._subrs)}l._privateDict=h}s.push(l)}return s}function ig(i,e,t,n){let s,o;const r=new $.Parser(i,e);t-=1;const l=[".notdef"],a=r.parseCard8();if(a===0)for(let d=0;d<t;d+=1)s=r.parseSID(),l.push(li(n,s));else if(a===1)for(;l.length<=t;){s=r.parseSID(),o=r.parseCard8();for(let d=0;d<=o;d+=1)l.push(li(n,s)),s+=1}else if(a===2)for(;l.length<=t;){s=r.parseSID(),o=r.parseCard16();for(let d=0;d<=o;d+=1)l.push(li(n,s)),s+=1}else throw new Error("Unknown charset format "+a);return l}function ng(i,e,t){let n;const s={},o=new $.Parser(i,e),r=o.parseCard8();if(r===0){const l=o.parseCard8();for(let a=0;a<l;a+=1)n=o.parseCard8(),s[n]=a}else if(r===1){const l=o.parseCard8();n=1;for(let a=0;a<l;a+=1){const d=o.parseCard8(),h=o.parseCard8();for(let p=d;p<=d+h;p+=1)s[p]=n,n+=1}}else throw new Error("Unknown encoding format "+r);return new Ji(s,t)}function sg(i,e,t){let n,s,o,r;const l=new be,a=[];let d=0,h=!1,p=!1,f=0,u=0,m,E,A,y;if(i.isCIDFont){const I=i.tables.cff.topDict._fdSelect[e.index],B=i.tables.cff.topDict._fdArray[I];m=B._subrs,E=B._subrsBias,A=B._defaultWidthX,y=B._nominalWidthX}else m=i.tables.cff.topDict._subrs,E=i.tables.cff.topDict._subrsBias,A=i.tables.cff.topDict._defaultWidthX,y=i.tables.cff.topDict._nominalWidthX;let v=A;function S(I,B){p&&l.closePath(),l.moveTo(I,B),p=!0}function M(){let I;I=a.length%2!==0,I&&!h&&(v=a.shift()+y),d+=a.length>>1,a.length=0,h=!0}function O(I){let B,g,P,x,F,_,H,N,w,C,b,D,k=0;for(;k<I.length;){let Q=I[k];switch(k+=1,Q){case 1:M();break;case 3:M();break;case 4:a.length>1&&!h&&(v=a.shift()+y,h=!0),u+=a.pop(),S(f,u);break;case 5:for(;a.length>0;)f+=a.shift(),u+=a.shift(),l.lineTo(f,u);break;case 6:for(;a.length>0&&(f+=a.shift(),l.lineTo(f,u),a.length!==0);)u+=a.shift(),l.lineTo(f,u);break;case 7:for(;a.length>0&&(u+=a.shift(),l.lineTo(f,u),a.length!==0);)f+=a.shift(),l.lineTo(f,u);break;case 8:for(;a.length>0;)n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r+a.shift(),l.curveTo(n,s,o,r,f,u);break;case 10:F=a.pop()+E,_=m[F],_&&O(_);break;case 11:return;case 12:switch(Q=I[k],k+=1,Q){case 35:n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),H=o+a.shift(),N=r+a.shift(),w=H+a.shift(),C=N+a.shift(),b=w+a.shift(),D=C+a.shift(),f=b+a.shift(),u=D+a.shift(),a.shift(),l.curveTo(n,s,o,r,H,N),l.curveTo(w,C,b,D,f,u);break;case 34:n=f+a.shift(),s=u,o=n+a.shift(),r=s+a.shift(),H=o+a.shift(),N=r,w=H+a.shift(),C=r,b=w+a.shift(),D=u,f=b+a.shift(),l.curveTo(n,s,o,r,H,N),l.curveTo(w,C,b,D,f,u);break;case 36:n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),H=o+a.shift(),N=r,w=H+a.shift(),C=r,b=w+a.shift(),D=C+a.shift(),f=b+a.shift(),l.curveTo(n,s,o,r,H,N),l.curveTo(w,C,b,D,f,u);break;case 37:n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),H=o+a.shift(),N=r+a.shift(),w=H+a.shift(),C=N+a.shift(),b=w+a.shift(),D=C+a.shift(),Math.abs(b-f)>Math.abs(D-u)?f=b+a.shift():u=D+a.shift(),l.curveTo(n,s,o,r,H,N),l.curveTo(w,C,b,D,f,u);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Q),a.length=0}break;case 14:a.length>0&&!h&&(v=a.shift()+y,h=!0),p&&(l.closePath(),p=!1);break;case 18:M();break;case 19:case 20:M(),k+=d+7>>3;break;case 21:a.length>2&&!h&&(v=a.shift()+y,h=!0),u+=a.pop(),f+=a.pop(),S(f,u);break;case 22:a.length>1&&!h&&(v=a.shift()+y,h=!0),f+=a.pop(),S(f,u);break;case 23:M();break;case 24:for(;a.length>2;)n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r+a.shift(),l.curveTo(n,s,o,r,f,u);f+=a.shift(),u+=a.shift(),l.lineTo(f,u);break;case 25:for(;a.length>6;)f+=a.shift(),u+=a.shift(),l.lineTo(f,u);n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r+a.shift(),l.curveTo(n,s,o,r,f,u);break;case 26:for(a.length%2&&(f+=a.shift());a.length>0;)n=f,s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o,u=r+a.shift(),l.curveTo(n,s,o,r,f,u);break;case 27:for(a.length%2&&(u+=a.shift());a.length>0;)n=f+a.shift(),s=u,o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r,l.curveTo(n,s,o,r,f,u);break;case 28:B=I[k],g=I[k+1],a.push((B<<24|g<<16)>>16),k+=2;break;case 29:F=a.pop()+i.gsubrsBias,_=i.gsubrs[F],_&&O(_);break;case 30:for(;a.length>0&&(n=f,s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r+(a.length===1?a.shift():0),l.curveTo(n,s,o,r,f,u),a.length!==0);)n=f+a.shift(),s=u,o=n+a.shift(),r=s+a.shift(),u=r+a.shift(),f=o+(a.length===1?a.shift():0),l.curveTo(n,s,o,r,f,u);break;case 31:for(;a.length>0&&(n=f+a.shift(),s=u,o=n+a.shift(),r=s+a.shift(),u=r+a.shift(),f=o+(a.length===1?a.shift():0),l.curveTo(n,s,o,r,f,u),a.length!==0);)n=f,s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r+(a.length===1?a.shift():0),l.curveTo(n,s,o,r,f,u);break;default:Q<32?console.log("Glyph "+e.index+": unknown operator "+Q):Q<247?a.push(Q-139):Q<251?(B=I[k],k+=1,a.push((Q-247)*256+B+108)):Q<255?(B=I[k],k+=1,a.push(-(Q-251)*256-B-108)):(B=I[k],g=I[k+1],P=I[k+2],x=I[k+3],k+=4,a.push((B<<24|g<<16|P<<8|x)/65536))}}}return O(t),e.advanceWidth=v,l}function og(i,e,t,n){const s=[];let o;const r=new $.Parser(i,e),l=r.parseCard8();if(l===0)for(let a=0;a<t;a++){if(o=r.parseCard8(),o>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+n+")");s.push(o)}else if(l===3){const a=r.parseCard16();let d=r.parseCard16();if(d!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+d);let h;for(let p=0;p<a;p++){if(o=r.parseCard8(),h=r.parseCard16(),o>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+n+")");if(h>t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+h);for(;d<h;d++)s.push(o);d=h}if(h!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+h)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+l);return s}function rg(i,e,t){t.tables.cff={};const n=eg(i,e),s=ct(i,n.endOffset,$.bytesToString),o=ct(i,s.endOffset),r=ct(i,o.endOffset,$.bytesToString),l=ct(i,r.endOffset);t.gsubrs=l.objects,t.gsubrsBias=hs(t.gsubrs);const a=Jr(i,e,o.objects,r.objects);if(a.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+a.length);const d=a[0];if(t.tables.cff.topDict=d,d._privateDict&&(t.defaultWidthX=d._privateDict.defaultWidthX,t.nominalWidthX=d._privateDict.nominalWidthX),d.ros[0]!==void 0&&d.ros[1]!==void 0&&(t.isCIDFont=!0),t.isCIDFont){let m=d.fdArray,E=d.fdSelect;if(m===0||E===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");m+=e;const A=ct(i,m),y=Jr(i,e,A.objects,r.objects);d._fdArray=y,E+=e,d._fdSelect=og(i,E,t.numGlyphs,y.length)}const h=e+d.private[1],p=qr(i,h,d.private[0],r.objects);if(t.defaultWidthX=p.defaultWidthX,t.nominalWidthX=p.nominalWidthX,p.subrs!==0){const m=h+p.subrs,E=ct(i,m);t.subrs=E.objects,t.subrsBias=hs(t.subrs)}else t.subrs=[],t.subrsBias=0;const f=ct(i,e+d.charStrings);t.nGlyphs=f.objects.length;const u=ig(i,e+d.charset,t.nGlyphs,r.objects);d.encoding===0?t.cffEncoding=new Ji(Yp,u):d.encoding===1?t.cffEncoding=new Ji(Vp,u):t.cffEncoding=ng(i,e+d.encoding,u),t.encoding=t.encoding||t.cffEncoding,t.glyphs=new Yt.GlyphSet(t);for(let m=0;m<t.nGlyphs;m+=1){const E=f.objects[m];t.glyphs.push(m,Yt.cffGlyphLoader(t,m,sg,E))}}function Zr(i,e){let t,n=qi.indexOf(i);return n>=0&&(t=n),n=e.indexOf(i),n>=0?t=n+qi.length:(t=qi.length+e.length,e.push(i)),t}function ag(){return new J.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function lg(i){const e=new J.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t<i.length;t+=1)e.names.push({name:"name_"+t,type:"NAME",value:i[t]});return e}function ea(i,e,t){const n={};for(let s=0;s<i.length;s+=1){const o=i[s];let r=e[o.name];r!==void 0&&!Wr(r,o.value)&&(o.type==="SID"&&(r=Zr(r,t)),n[o.op]={name:o.name,type:o.type,value:r})}return n}function ta(i,e){const t=new J.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=ea($r,i,e),t}function ia(i){const e=new J.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:i}],e}function cg(i){const e=new J.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(let t=0;t<i.length;t+=1)e.strings.push({name:"string_"+t,type:"STRING",value:i[t]});return e}function dg(){return new J.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function hg(i,e){const t=new J.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let n=0;n<i.length;n+=1){const s=i[n],o=Zr(s,e);t.fields.push({name:"glyph_"+n,type:"SID",value:o})}return t}function ug(i){const e=[],t=i.path;e.push({name:"width",type:"NUMBER",value:i.advanceWidth});let n=0,s=0;for(let o=0;o<t.commands.length;o+=1){let r,l,a=t.commands[o];if(a.type==="Q"){const d=.3333333333333333,h=2/3;a={type:"C",x:a.x,y:a.y,x1:d*n+h*a.x1,y1:d*s+h*a.y1,x2:d*a.x+h*a.x1,y2:d*a.y+h*a.y1}}if(a.type==="M")r=Math.round(a.x-n),l=Math.round(a.y-s),e.push({name:"dx",type:"NUMBER",value:r}),e.push({name:"dy",type:"NUMBER",value:l}),e.push({name:"rmoveto",type:"OP",value:21}),n=Math.round(a.x),s=Math.round(a.y);else if(a.type==="L")r=Math.round(a.x-n),l=Math.round(a.y-s),e.push({name:"dx",type:"NUMBER",value:r}),e.push({name:"dy",type:"NUMBER",value:l}),e.push({name:"rlineto",type:"OP",value:5}),n=Math.round(a.x),s=Math.round(a.y);else if(a.type==="C"){const d=Math.round(a.x1-n),h=Math.round(a.y1-s),p=Math.round(a.x2-a.x1),f=Math.round(a.y2-a.y1);r=Math.round(a.x-a.x2),l=Math.round(a.y-a.y2),e.push({name:"dx1",type:"NUMBER",value:d}),e.push({name:"dy1",type:"NUMBER",value:h}),e.push({name:"dx2",type:"NUMBER",value:p}),e.push({name:"dy2",type:"NUMBER",value:f}),e.push({name:"dx",type:"NUMBER",value:r}),e.push({name:"dy",type:"NUMBER",value:l}),e.push({name:"rrcurveto",type:"OP",value:8}),n=Math.round(a.x),s=Math.round(a.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function fg(i){const e=new J.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let t=0;t<i.length;t+=1){const n=i.get(t),s=ug(n);e.charStrings.push({name:n.name,type:"CHARSTRING",value:s})}return e}function pg(i,e){const t=new J.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=ea(Xr,i,e),t}function gg(i,e){const t=new J.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),n=1/e.unitsPerEm,s={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[n,0,0,n,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},o={},r=[];let l;for(let p=1;p<i.length;p+=1)l=i.get(p),r.push(l.name);const a=[];t.header=ag(),t.nameIndex=lg([e.postScriptName]);let d=ta(s,a);t.topDictIndex=ia(d),t.globalSubrIndex=dg(),t.charsets=hg(r,a),t.charStringsIndex=fg(i),t.privateDict=pg(o,a),t.stringIndex=cg(a);const h=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return s.charset=h,s.encoding=0,s.charStrings=s.charset+t.charsets.sizeOf(),s.private[1]=s.charStrings+t.charStringsIndex.sizeOf(),d=ta(s,a),t.topDictIndex=ia(d),t}const na={parse:rg,make:gg};function mg(i,e){const t={},n=new $.Parser(i,e);return t.version=n.parseVersion(),t.fontRevision=Math.round(n.parseFixed()*1e3)/1e3,t.checkSumAdjustment=n.parseULong(),t.magicNumber=n.parseULong(),te.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=n.parseUShort(),t.unitsPerEm=n.parseUShort(),t.created=n.parseLongDateTime(),t.modified=n.parseLongDateTime(),t.xMin=n.parseShort(),t.yMin=n.parseShort(),t.xMax=n.parseShort(),t.yMax=n.parseShort(),t.macStyle=n.parseUShort(),t.lowestRecPPEM=n.parseUShort(),t.fontDirectionHint=n.parseShort(),t.indexToLocFormat=n.parseShort(),t.glyphDataFormat=n.parseShort(),t}function Ag(i){const e=Math.round(new Date().getTime()/1e3)+2082844800;let t=e;return i.createdTimestamp&&(t=i.createdTimestamp+2082844800),new J.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:t},{name:"modified",type:"LONGDATETIME",value:e},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:0},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],i)}const sa={parse:mg,make:Ag};function yg(i,e){const t={},n=new $.Parser(i,e);return t.version=n.parseVersion(),t.ascender=n.parseShort(),t.descender=n.parseShort(),t.lineGap=n.parseShort(),t.advanceWidthMax=n.parseUShort(),t.minLeftSideBearing=n.parseShort(),t.minRightSideBearing=n.parseShort(),t.xMaxExtent=n.parseShort(),t.caretSlopeRise=n.parseShort(),t.caretSlopeRun=n.parseShort(),t.caretOffset=n.parseShort(),n.relativeOffset+=8,t.metricDataFormat=n.parseShort(),t.numberOfHMetrics=n.parseUShort(),t}function Cg(i){return new J.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],i)}const oa={parse:yg,make:Cg};function Eg(i,e,t,n,s){let o,r;const l=new $.Parser(i,e);for(let a=0;a<n;a+=1){a<t&&(o=l.parseUShort(),r=l.parseShort());const d=s.get(a);d.advanceWidth=o,d.leftSideBearing=r}}function wg(i){const e=new J.Table("hmtx",[]);for(let t=0;t<i.length;t+=1){const n=i.get(t),s=n.advanceWidth||0,o=n.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+t,type:"USHORT",value:s}),e.fields.push({name:"leftSideBearing_"+t,type:"SHORT",value:o})}return e}const ra={parse:Eg,make:wg};function bg(i){const e=new J.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:i.length}]);let t="";const n=12+i.length*4;for(let s=0;s<i.length;++s){let o=t.indexOf(i[s]);o<0&&(o=t.length,t+=i[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:n+o}),e.fields.push({name:"length "+s,type:"USHORT",value:i[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function vg(i,e){const t=new $.Parser(i,e),n=t.parseULong();te.argument(n===1,"Unsupported ltag table version."),t.skip("uLong",1);const s=t.parseULong(),o=[];for(let r=0;r<s;r++){let l="";const a=e+t.parseUShort(),d=t.parseUShort();for(let h=a;h<a+d;++h)l+=String.fromCharCode(i.getInt8(h));o.push(l)}return o}const aa={make:bg,parse:vg};function Ig(i,e){const t={},n=new $.Parser(i,e);return t.version=n.parseVersion(),t.numGlyphs=n.parseUShort(),t.version===1&&(t.maxPoints=n.parseUShort(),t.maxContours=n.parseUShort(),t.maxCompositePoints=n.parseUShort(),t.maxCompositeContours=n.parseUShort(),t.maxZones=n.parseUShort(),t.maxTwilightPoints=n.parseUShort(),t.maxStorage=n.parseUShort(),t.maxFunctionDefs=n.parseUShort(),t.maxInstructionDefs=n.parseUShort(),t.maxStackElements=n.parseUShort(),t.maxSizeOfInstructions=n.parseUShort(),t.maxComponentElements=n.parseUShort(),t.maxComponentDepth=n.parseUShort()),t}function Bg(i){return new J.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:i}])}const la={parse:Ig,make:Bg},ca=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],da={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},xg={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},ha={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function Sg(i,e,t){switch(i){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return da[e];case 3:return ha[e]}}const us="utf-16",Tg={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},Mg={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function ua(i,e,t){switch(i){case 0:return us;case 1:return Mg[t]||Tg[e];case 3:if(e===1||e===10)return us;break}}function Dg(i,e,t){const n={},s=new $.Parser(i,e),o=s.parseUShort(),r=s.parseUShort(),l=s.offset+s.parseUShort();for(let a=0;a<r;a++){const d=s.parseUShort(),h=s.parseUShort(),p=s.parseUShort(),f=s.parseUShort(),u=ca[f]||f,m=s.parseUShort(),E=s.parseUShort(),A=Sg(d,p,t),y=ua(d,h,p);if(y!==void 0&&A!==void 0){let v;if(y===us?v=Ht.UTF16(i,l+E,m):v=Ht.MACSTRING(i,l+E,m,y),v){let S=n[u];S===void 0&&(S=n[u]={}),S[A]=v}}}return o===1&&s.parseUShort(),n}function fs(i){const e={};for(let t in i)e[i[t]]=parseInt(t);return e}function fa(i,e,t,n,s,o){return new J.Record("NameRecord",[{name:"platformID",type:"USHORT",value:i},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:t},{name:"nameID",type:"USHORT",value:n},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:o}])}function kg(i,e){const t=i.length,n=e.length-t+1;e:for(let s=0;s<n;s++)for(;s<n;s++){for(let o=0;o<t;o++)if(e[s+o]!==i[o])continue e;return s}return-1}function pa(i,e){let t=kg(i,e);if(t<0){t=e.length;let n=0;const s=i.length;for(;n<s;++n)e.push(i[n])}return t}function Pg(i,e){let t;const n=[],s={},o=fs(ca);for(let p in i){let f=o[p];if(f===void 0&&(f=p),t=parseInt(f),isNaN(t))throw new Error('Name table entry "'+p+'" does not exist, see nameTableNames for complete list.');s[t]=i[p],n.push(t)}const r=fs(da),l=fs(ha),a=[],d=[];for(let p=0;p<n.length;p++){t=n[p];const f=s[t];for(let u in f){const m=f[u];let E=1,A=r[u],y=xg[A];const v=ua(E,y,A);let S=z.MACSTRING(m,v);S===void 0&&(E=0,A=e.indexOf(u),A<0&&(A=e.length,e.push(u)),y=4,S=z.UTF16(m));const M=pa(S,d);a.push(fa(E,y,A,t,S.length,M));const O=l[u];if(O!==void 0){const I=z.UTF16(m),B=pa(I,d);a.push(fa(3,1,O,t,I.length,B))}}}a.sort(function(p,f){return p.platformID-f.platformID||p.encodingID-f.encodingID||p.languageID-f.languageID||p.nameID-f.nameID});const h=new J.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:a.length},{name:"stringOffset",type:"USHORT",value:6+a.length*12}]);for(let p=0;p<a.length;p++)h.fields.push({name:"record_"+p,type:"RECORD",value:a[p]});return h.fields.push({name:"strings",type:"LITERAL",value:d}),h}const ga={parse:Dg,make:Pg},ps=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function Fg(i){for(let e=0;e<ps.length;e+=1){const t=ps[e];if(i>=t.begin&&i<t.end)return e}return-1}function Rg(i,e){const t={},n=new $.Parser(i,e);t.version=n.parseUShort(),t.xAvgCharWidth=n.parseShort(),t.usWeightClass=n.parseUShort(),t.usWidthClass=n.parseUShort(),t.fsType=n.parseUShort(),t.ySubscriptXSize=n.parseShort(),t.ySubscriptYSize=n.parseShort(),t.ySubscriptXOffset=n.parseShort(),t.ySubscriptYOffset=n.parseShort(),t.ySuperscriptXSize=n.parseShort(),t.ySuperscriptYSize=n.parseShort(),t.ySuperscriptXOffset=n.parseShort(),t.ySuperscriptYOffset=n.parseShort(),t.yStrikeoutSize=n.parseShort(),t.yStrikeoutPosition=n.parseShort(),t.sFamilyClass=n.parseShort(),t.panose=[];for(let s=0;s<10;s++)t.panose[s]=n.parseByte();return t.ulUnicodeRange1=n.parseULong(),t.ulUnicodeRange2=n.parseULong(),t.ulUnicodeRange3=n.parseULong(),t.ulUnicodeRange4=n.parseULong(),t.achVendID=String.fromCharCode(n.parseByte(),n.parseByte(),n.parseByte(),n.parseByte()),t.fsSelection=n.parseUShort(),t.usFirstCharIndex=n.parseUShort(),t.usLastCharIndex=n.parseUShort(),t.sTypoAscender=n.parseShort(),t.sTypoDescender=n.parseShort(),t.sTypoLineGap=n.parseShort(),t.usWinAscent=n.parseUShort(),t.usWinDescent=n.parseUShort(),t.version>=1&&(t.ulCodePageRange1=n.parseULong(),t.ulCodePageRange2=n.parseULong()),t.version>=2&&(t.sxHeight=n.parseShort(),t.sCapHeight=n.parseShort(),t.usDefaultChar=n.parseUShort(),t.usBreakChar=n.parseUShort(),t.usMaxContent=n.parseUShort()),t}function Og(i){return new J.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],i)}const gs={parse:Rg,make:Og,unicodeRanges:ps,getUnicodeRange:Fg};function Lg(i,e){const t={},n=new $.Parser(i,e);switch(t.version=n.parseVersion(),t.italicAngle=n.parseFixed(),t.underlinePosition=n.parseShort(),t.underlineThickness=n.parseShort(),t.isFixedPitch=n.parseULong(),t.minMemType42=n.parseULong(),t.maxMemType42=n.parseULong(),t.minMemType1=n.parseULong(),t.maxMemType1=n.parseULong(),t.version){case 1:t.names=wt.slice();break;case 2:t.numberOfGlyphs=n.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s<t.numberOfGlyphs;s++)t.glyphNameIndex[s]=n.parseUShort();t.names=[];for(let s=0;s<t.numberOfGlyphs;s++)if(t.glyphNameIndex[s]>=wt.length){const o=n.parseChar();t.names.push(n.parseString(o))}break;case 2.5:t.numberOfGlyphs=n.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s<t.numberOfGlyphs;s++)t.offset[s]=n.parseChar();break}return t}function Ng(){return new J.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:0},{name:"underlinePosition",type:"FWORD",value:0},{name:"underlineThickness",type:"FWORD",value:0},{name:"isFixedPitch",type:"ULONG",value:0},{name:"minMemType42",type:"ULONG",value:0},{name:"maxMemType42",type:"ULONG",value:0},{name:"minMemType1",type:"ULONG",value:0},{name:"maxMemType1",type:"ULONG",value:0}])}const ma={parse:Lg,make:Ng},_e=new Array(9);_e[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(G.coverage),deltaGlyphId:this.parseUShort()};if(t===2)return{substFormat:2,coverage:this.parsePointer(G.coverage),substitute:this.parseOffset16List()};te.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")},_e[2]=function(){const e=this.parseUShort();return te.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(G.coverage),sequences:this.parseListOfLists()}},_e[3]=function(){const e=this.parseUShort();return te.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(G.coverage),alternateSets:this.parseListOfLists()}},_e[4]=function(){const e=this.parseUShort();return te.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(G.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};const Vt={sequenceIndex:G.uShort,lookupListIndex:G.uShort};_e[5]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:t,coverage:this.parsePointer(G.coverage),ruleSets:this.parseListOfLists(function(){const n=this.parseUShort(),s=this.parseUShort();return{input:this.parseUShortList(n-1),lookupRecords:this.parseRecordList(s,Vt)}})};if(t===2)return{substFormat:t,coverage:this.parsePointer(G.coverage),classDef:this.parsePointer(G.classDef),classSets:this.parseListOfLists(function(){const n=this.parseUShort(),s=this.parseUShort();return{classes:this.parseUShortList(n-1),lookupRecords:this.parseRecordList(s,Vt)}})};if(t===3){const n=this.parseUShort(),s=this.parseUShort();return{substFormat:t,coverages:this.parseList(n,G.pointer(G.coverage)),lookupRecords:this.parseRecordList(s,Vt)}}te.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},_e[6]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(G.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Vt)}})};if(t===2)return{substFormat:2,coverage:this.parsePointer(G.coverage),backtrackClassDef:this.parsePointer(G.classDef),inputClassDef:this.parsePointer(G.classDef),lookaheadClassDef:this.parsePointer(G.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Vt)}})};if(t===3)return{substFormat:3,backtrackCoverage:this.parseList(G.pointer(G.coverage)),inputCoverage:this.parseList(G.pointer(G.coverage)),lookaheadCoverage:this.parseList(G.pointer(G.coverage)),lookupRecords:this.parseRecordList(Vt)};te.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},_e[7]=function(){const e=this.parseUShort();te.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");const t=this.parseUShort(),n=new G(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:_e[t].call(n)}},_e[8]=function(){const e=this.parseUShort();return te.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(G.coverage),backtrackCoverage:this.parseList(G.pointer(G.coverage)),lookaheadCoverage:this.parseList(G.pointer(G.coverage)),substitutes:this.parseUShortList()}};function Ug(i,e){e=e||0;const t=new G(i,e),n=t.parseVersion(1);return te.argument(n===1||n===1.1,"Unsupported GSUB table version."),n===1?{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(_e)}:{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(_e),variations:t.parseFeatureVariationsList()}}const en=new Array(9);en[1]=function(e){return e.substFormat===1?new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new J.Coverage(e.coverage)}].concat(J.ushortList("substitute",e.substitute)))},en[3]=function(e){return te.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(e.coverage)}].concat(J.tableList("altSet",e.alternateSets,function(t){return new J.Table("alternateSetTable",J.ushortList("alternate",t))})))},en[4]=function(e){return te.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(e.coverage)}].concat(J.tableList("ligSet",e.ligatureSets,function(t){return new J.Table("ligatureSetTable",J.tableList("ligature",t,function(n){return new J.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:n.ligGlyph}].concat(J.ushortList("component",n.components,n.components.length+1)))}))})))};function _g(i){return new J.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new J.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new J.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new J.LookupList(i.lookups,en)}])}const Aa={parse:Ug,make:_g};function Qg(i,e){const t=new $.Parser(i,e),n=t.parseULong();te.argument(n===1,"Unsupported META table version."),t.parseULong(),t.parseULong();const s=t.parseULong(),o={};for(let r=0;r<s;r++){const l=t.parseTag(),a=t.parseULong(),d=t.parseULong(),h=Ht.UTF8(i,e+a,d);o[l]=h}return o}function Gg(i){const e=Object.keys(i).length;let t="";const n=16+e*12,s=new J.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:n},{name:"numTags",type:"ULONG",value:e}]);for(let o in i){const r=t.length;t+=i[o],s.fields.push({name:"tag "+o,type:"TAG",value:o}),s.fields.push({name:"offset "+o,type:"ULONG",value:n+r}),s.fields.push({name:"length "+o,type:"ULONG",value:i[o].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),s}const ya={parse:Qg,make:Gg};function Ca(i){return Math.log(i)/Math.log(2)|0}function ms(i){for(;i.length%4!==0;)i.push(0);let e=0;for(let t=0;t<i.length;t+=4)e+=(i[t]<<24)+(i[t+1]<<16)+(i[t+2]<<8)+i[t+3];return e%=Math.pow(2,32),e}function Ea(i,e,t,n){return new J.Record("Table Record",[{name:"tag",type:"TAG",value:i!==void 0?i:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:t!==void 0?t:0},{name:"length",type:"ULONG",value:n!==void 0?n:0}])}function wa(i){const e=new J.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);e.tables=i,e.numTables=i.length;const t=Math.pow(2,Ca(e.numTables));e.searchRange=16*t,e.entrySelector=Ca(t),e.rangeShift=e.numTables*16-e.searchRange;const n=[],s=[];let o=e.sizeOf()+Ea().sizeOf()*e.numTables;for(;o%4!==0;)o+=1,s.push({name:"padding",type:"BYTE",value:0});for(let r=0;r<i.length;r+=1){const l=i[r];te.argument(l.tableName.length===4,"Table name"+l.tableName+" is invalid.");const a=l.sizeOf(),d=Ea(l.tableName,ms(l.encode()),o,a);for(n.push({name:d.tag+" Table Record",type:"RECORD",value:d}),s.push({name:l.tableName+" table",type:"RECORD",value:l}),o+=a,te.argument(!isNaN(o),"Something went wrong calculating the offset.");o%4!==0;)o+=1,s.push({name:"padding",type:"BYTE",value:0})}return n.sort(function(r,l){return r.value.tag>l.value.tag?1:-1}),e.fields=e.fields.concat(n),e.fields=e.fields.concat(s),e}function ba(i,e,t){for(let n=0;n<e.length;n+=1){const s=i.charToGlyphIndex(e[n]);if(s>0)return i.glyphs.get(s).getMetrics()}return t}function Hg(i){let e=0;for(let t=0;t<i.length;t+=1)e+=i[t];return e/i.length}function Yg(i){const e=[],t=[],n=[],s=[],o=[],r=[],l=[];let a,d=0,h=0,p=0,f=0,u=0;for(let T=0;T<i.glyphs.length;T+=1){const U=i.glyphs.get(T),V=U.unicode|0;if(isNaN(U.advanceWidth))throw new Error("Glyph "+U.name+" ("+T+"): advanceWidth is not a number.");(a>V||a===void 0)&&V>0&&(a=V),d<V&&(d=V);const W=gs.getUnicodeRange(V);if(W<32)h|=1<<W;else if(W<64)p|=1<<W-32;else if(W<96)f|=1<<W-64;else if(W<123)u|=1<<W-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(U.name===".notdef")continue;const q=U.getMetrics();e.push(q.xMin),t.push(q.yMin),n.push(q.xMax),s.push(q.yMax),r.push(q.leftSideBearing),l.push(q.rightSideBearing),o.push(U.advanceWidth)}const m={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,n),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,o),advanceWidthAvg:Hg(o),minLeftSideBearing:Math.min.apply(null,r),maxLeftSideBearing:Math.max.apply(null,r),minRightSideBearing:Math.min.apply(null,l)};m.ascender=i.ascender,m.descender=i.descender;const E=sa.make({flags:3,unitsPerEm:i.unitsPerEm,xMin:m.xMin,yMin:m.yMin,xMax:m.xMax,yMax:m.yMax,lowestRecPPEM:3,createdTimestamp:i.createdTimestamp}),A=oa.make({ascender:m.ascender,descender:m.descender,advanceWidthMax:m.advanceWidthMax,minLeftSideBearing:m.minLeftSideBearing,minRightSideBearing:m.minRightSideBearing,xMaxExtent:m.maxLeftSideBearing+(m.xMax-m.xMin),numberOfHMetrics:i.glyphs.length}),y=la.make(i.glyphs.length),v=gs.make({xAvgCharWidth:Math.round(m.advanceWidthAvg),usWeightClass:i.tables.os2.usWeightClass,usWidthClass:i.tables.os2.usWidthClass,usFirstCharIndex:a,usLastCharIndex:d,ulUnicodeRange1:h,ulUnicodeRange2:p,ulUnicodeRange3:f,ulUnicodeRange4:u,fsSelection:i.tables.os2.fsSelection,sTypoAscender:m.ascender,sTypoDescender:m.descender,sTypoLineGap:0,usWinAscent:m.yMax,usWinDescent:Math.abs(m.yMin),ulCodePageRange1:1,sxHeight:ba(i,"xyvw",{yMax:Math.round(m.ascender/2)}).yMax,sCapHeight:ba(i,"HIKLEFJMNTZBDPRAGOQSUVWXY",m).yMax,usDefaultChar:i.hasChar(" ")?32:0,usBreakChar:i.hasChar(" ")?32:0}),S=ra.make(i.glyphs),M=Yr.make(i.glyphs),O=i.getEnglishName("fontFamily"),I=i.getEnglishName("fontSubfamily"),B=O+" "+I;let g=i.getEnglishName("postScriptName");g||(g=O.replace(/\s/g,"")+"-"+I);const P={};for(let T in i.names)P[T]=i.names[T];P.uniqueID||(P.uniqueID={en:i.getEnglishName("manufacturer")+":"+B}),P.postScriptName||(P.postScriptName={en:g}),P.preferredFamily||(P.preferredFamily=i.names.fontFamily),P.preferredSubfamily||(P.preferredSubfamily=i.names.fontSubfamily);const x=[],F=ga.make(P,x),_=x.length>0?aa.make(x):void 0,H=ma.make(),N=na.make(i.glyphs,{version:i.getEnglishName("version"),fullName:B,familyName:O,weightName:I,postScriptName:g,unitsPerEm:i.unitsPerEm,fontBBox:[0,m.yMin,m.ascender,m.advanceWidthMax]}),w=i.metas&&Object.keys(i.metas).length>0?ya.make(i.metas):void 0,C=[E,A,y,v,F,M,H,N,S];_&&C.push(_),i.tables.gsub&&C.push(Aa.make(i.tables.gsub)),w&&C.push(w);const b=wa(C),D=b.encode(),k=ms(D),Q=b.fields;let R=!1;for(let T=0;T<Q.length;T+=1)if(Q[T].name==="head table"){Q[T].value.checkSumAdjustment=2981146554-k,R=!0;break}if(!R)throw new Error("Could not find head table with checkSum to adjust.");return b}const Vg={make:wa,fontToTable:Yg,computeCheckSum:ms};function As(i,e){let t=0,n=i.length-1;for(;t<=n;){const s=t+n>>>1,o=i[s].tag;if(o===e)return s;o<e?t=s+1:n=s-1}return-t-1}function va(i,e){let t=0,n=i.length-1;for(;t<=n;){const s=t+n>>>1,o=i[s];if(o===e)return s;o<e?t=s+1:n=s-1}return-t-1}function Ia(i,e){let t,n=0,s=i.length-1;for(;n<=s;){const o=n+s>>>1;t=i[o];const r=t.start;if(r===e)return t;r<e?n=o+1:s=o-1}if(n>0)return t=i[n-1],e>t.end?0:t}function ci(i,e){this.font=i,this.tableName=e}ci.prototype={searchTag:As,binSearch:va,getTable:function(i){let e=this.font.tables[this.tableName];return!e&&i&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let i=this.getTable();return i?i.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let i=this.getTable();if(!i)return;let e=!1;for(let t=0;t<i.scripts.length;t++){const n=i.scripts[t].tag;if(n==="DFLT")return n;n==="latn"&&(e=!0)}if(e)return"latn"},getScriptTable:function(i,e){const t=this.getTable(e);if(t){i=i||"DFLT";const n=t.scripts,s=As(t.scripts,i);if(s>=0)return n[s].script;if(e){const o={tag:i,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return n.splice(-1-s,0,o),o.script}}},getLangSysTable:function(i,e,t){const n=this.getScriptTable(i,t);if(n){if(!e||e==="dflt"||e==="DFLT")return n.defaultLangSys;const s=As(n.langSysRecords,e);if(s>=0)return n.langSysRecords[s].langSys;if(t){const o={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return n.langSysRecords.splice(-1-s,0,o),o.langSys}}},getFeatureTable:function(i,e,t,n){const s=this.getLangSysTable(i,e,n);if(s){let o;const r=s.featureIndexes,l=this.font.tables[this.tableName].features;for(let a=0;a<r.length;a++)if(o=l[r[a]],o.tag===t)return o.feature;if(n){const a=l.length;return te.assert(a===0||t>=l[a-1].tag,"Features must be added in alphabetical order."),o={tag:t,feature:{params:0,lookupListIndexes:[]}},l.push(o),r.push(a),o.feature}}},getLookupTables:function(i,e,t,n,s){const o=this.getFeatureTable(i,e,t,s),r=[];if(o){let l;const a=o.lookupListIndexes,d=this.font.tables[this.tableName].lookups;for(let h=0;h<a.length;h++)l=d[a[h]],l.lookupType===n&&r.push(l);if(r.length===0&&s){l={lookupType:n,lookupFlag:0,subtables:[],markFilteringSet:void 0};const h=d.length;return d.push(l),a.push(h),[l]}}return r},getGlyphClass:function(i,e){switch(i.format){case 1:return i.startGlyph<=e&&e<i.startGlyph+i.classes.length?i.classes[e-i.startGlyph]:0;case 2:const t=Ia(i.ranges,e);return t?t.classId:0}},getCoverageIndex:function(i,e){switch(i.format){case 1:const t=va(i.glyphs,e);return t>=0?t:-1;case 2:const n=Ia(i.ranges,e);return n?n.index+e-n.start:-1}},expandCoverage:function(i){if(i.format===1)return i.glyphs;{const e=[],t=i.ranges;for(let n=0;n<t.length;n++){const s=t[n],o=s.start,r=s.end;for(let l=o;l<=r;l++)e.push(l)}return e}}};function di(i){ci.call(this,i,"gpos")}di.prototype=ci.prototype,di.prototype.init=function(){const i=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(i)},di.prototype.getKerningValue=function(i,e,t){for(let n=0;n<i.length;n++){const s=i[n].subtables;for(let o=0;o<s.length;o++){const r=s[o],l=this.getCoverageIndex(r.coverage,e);if(!(l<0))switch(r.posFormat){case 1:let a=r.pairSets[l];for(let f=0;f<a.length;f++){let u=a[f];if(u.secondGlyph===t)return u.value1&&u.value1.xAdvance||0}break;case 2:const d=this.getGlyphClass(r.classDef1,e),h=this.getGlyphClass(r.classDef2,t),p=r.classRecords[d][h];return p.value1&&p.value1.xAdvance||0}}}return 0},di.prototype.getKerningTables=function(i,e){if(this.font.tables.gpos)return this.getLookupTables(i,e,"kern",2)};function Qe(i){ci.call(this,i,"gsub")}function zg(i,e){const t=i.length;if(t!==e.length)return!1;for(let n=0;n<t;n++)if(i[n]!==e[n])return!1;return!0}function Ba(i,e,t){const n=i.subtables;for(let s=0;s<n.length;s++){const o=n[s];if(o.substFormat===e)return o}if(t)return n.push(t),t}Qe.prototype=ci.prototype,Qe.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Qe.prototype.getSingle=function(i,e,t){const n=[],s=this.getLookupTables(e,t,i,1);for(let o=0;o<s.length;o++){const r=s[o].subtables;for(let l=0;l<r.length;l++){const a=r[l],d=this.expandCoverage(a.coverage);let h;if(a.substFormat===1){const p=a.deltaGlyphId;for(h=0;h<d.length;h++){const f=d[h];n.push({sub:f,by:f+p})}}else{const p=a.substitute;for(h=0;h<d.length;h++)n.push({sub:d[h],by:p[h]})}}}return n},Qe.prototype.getAlternates=function(i,e,t){const n=[],s=this.getLookupTables(e,t,i,3);for(let o=0;o<s.length;o++){const r=s[o].subtables;for(let l=0;l<r.length;l++){const a=r[l],d=this.expandCoverage(a.coverage),h=a.alternateSets;for(let p=0;p<d.length;p++)n.push({sub:d[p],by:h[p]})}}return n},Qe.prototype.getLigatures=function(i,e,t){const n=[],s=this.getLookupTables(e,t,i,4);for(let o=0;o<s.length;o++){const r=s[o].subtables;for(let l=0;l<r.length;l++){const a=r[l],d=this.expandCoverage(a.coverage),h=a.ligatureSets;for(let p=0;p<d.length;p++){const f=d[p],u=h[p];for(let m=0;m<u.length;m++){const E=u[m];n.push({sub:[f].concat(E.components),by:E.ligGlyph})}}}}return n},Qe.prototype.addSingle=function(i,e,t,n){const s=this.getLookupTables(t,n,i,1,!0)[0],o=Ba(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});te.assert(o.coverage.format===1,"Ligature: unable to modify coverage table format "+o.coverage.format);const r=e.sub;let l=this.binSearch(o.coverage.glyphs,r);l<0&&(l=-1-l,o.coverage.glyphs.splice(l,0,r),o.substitute.splice(l,0,0)),o.substitute[l]=e.by},Qe.prototype.addAlternate=function(i,e,t,n){const s=this.getLookupTables(t,n,i,3,!0)[0],o=Ba(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});te.assert(o.coverage.format===1,"Ligature: unable to modify coverage table format "+o.coverage.format);const r=e.sub;let l=this.binSearch(o.coverage.glyphs,r);l<0&&(l=-1-l,o.coverage.glyphs.splice(l,0,r),o.alternateSets.splice(l,0,0)),o.alternateSets[l]=e.by},Qe.prototype.addLigature=function(i,e,t,n){const s=this.getLookupTables(t,n,i,4,!0)[0];let o=s.subtables[0];o||(o={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=o),te.assert(o.coverage.format===1,"Ligature: unable to modify coverage table format "+o.coverage.format);const r=e.sub[0],l=e.sub.slice(1),a={ligGlyph:e.by,components:l};let d=this.binSearch(o.coverage.glyphs,r);if(d>=0){const h=o.ligatureSets[d];for(let p=0;p<h.length;p++)if(zg(h[p].components,l))return;h.push(a)}else d=-1-d,o.coverage.glyphs.splice(d,0,r),o.ligatureSets.splice(d,0,[a])},Qe.prototype.getFeature=function(i,e,t){if(/ss\d\d/.test(i))return this.getSingle(i,e,t);switch(i){case"aalt":case"salt":return this.getSingle(i,e,t).concat(this.getAlternates(i,e,t));case"dlig":case"liga":case"rlig":return this.getLigatures(i,e,t)}},Qe.prototype.add=function(i,e,t,n){if(/ss\d\d/.test(i))return this.addSingle(i,e,t,n);switch(i){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(i,e,t,n):this.addAlternate(i,e,t,n);case"dlig":case"liga":case"rlig":return this.addLigature(i,e,t,n)}};function Wg(){return typeof window<"u"}function jg(i){const e=new ArrayBuffer(i.length),t=new Uint8Array(e);for(let n=0;n<i.length;++n)t[n]=i[n];return e}function Kg(i){const e=new Buffer(i.byteLength),t=new Uint8Array(i);for(let n=0;n<e.length;++n)e[n]=t[n];return e}function zt(i,e){if(!i)throw e}function xa(i,e,t,n,s){let o;return(e&n)>0?(o=i.parseByte(),(e&s)===0&&(o=-o),o=t+o):(e&s)>0?o=t:o=t+i.parseShort(),o}function $g(i,e,t){const n=new $.Parser(e,t);i.numberOfContours=n.parseShort(),i._xMin=n.parseShort(),i._yMin=n.parseShort(),i._xMax=n.parseShort(),i._yMax=n.parseShort();let s,o;if(i.numberOfContours>0){const r=i.endPointIndices=[];for(let a=0;a<i.numberOfContours;a+=1)r.push(n.parseUShort());i.instructionLength=n.parseUShort(),i.instructions=[];for(let a=0;a<i.instructionLength;a+=1)i.instructions.push(n.parseByte());const l=r[r.length-1]+1;s=[];for(let a=0;a<l;a+=1)if(o=n.parseByte(),s.push(o),(o&8)>0){const d=n.parseByte();for(let h=0;h<d;h+=1)s.push(o),a+=1}if(te.argument(s.length===l,"Bad flags."),r.length>0){const a=[];let d;if(l>0){for(let f=0;f<l;f+=1)o=s[f],d={},d.onCurve=!!(o&1),d.lastPointOfContour=r.indexOf(f)>=0,a.push(d);let h=0;for(let f=0;f<l;f+=1)o=s[f],d=a[f],d.x=xa(n,o,h,2,16),h=d.x;let p=0;for(let f=0;f<l;f+=1)o=s[f],d=a[f],d.y=xa(n,o,p,4,32),p=d.y}i.points=a}else i.points=[]}else if(i.numberOfContours===0)i.points=[];else{i.isComposite=!0,i.points=[],i.components=[];let r=!0;for(;r;){s=n.parseUShort();const l={glyphIndex:n.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(l.dx=n.parseShort(),l.dy=n.parseShort()):l.matchedPoints=[n.parseUShort(),n.parseUShort()]:(s&2)>0?(l.dx=n.parseChar(),l.dy=n.parseChar()):l.matchedPoints=[n.parseByte(),n.parseByte()],(s&8)>0?l.xScale=l.yScale=n.parseF2Dot14():(s&64)>0?(l.xScale=n.parseF2Dot14(),l.yScale=n.parseF2Dot14()):(s&128)>0&&(l.xScale=n.parseF2Dot14(),l.scale01=n.parseF2Dot14(),l.scale10=n.parseF2Dot14(),l.yScale=n.parseF2Dot14()),i.components.push(l),r=!!(s&32)}if(s&256){i.instructionLength=n.parseUShort(),i.instructions=[];for(let l=0;l<i.instructionLength;l+=1)i.instructions.push(n.parseByte())}}}function ys(i,e){const t=[];for(let n=0;n<i.length;n+=1){const s=i[n],o={x:e.xScale*s.x+e.scale01*s.y+e.dx,y:e.scale10*s.x+e.yScale*s.y+e.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};t.push(o)}return t}function Xg(i){const e=[];let t=[];for(let n=0;n<i.length;n+=1){const s=i[n];t.push(s),s.lastPointOfContour&&(e.push(t),t=[])}return te.argument(t.length===0,"There are still points left in the current contour."),e}function Sa(i){const e=new be;if(!i)return e;const t=Xg(i);for(let n=0;n<t.length;++n){const s=t[n];let o=null,r=s[s.length-1],l=s[0];if(r.onCurve)e.moveTo(r.x,r.y);else if(l.onCurve)e.moveTo(l.x,l.y);else{const a={x:(r.x+l.x)*.5,y:(r.y+l.y)*.5};e.moveTo(a.x,a.y)}for(let a=0;a<s.length;++a)if(o=r,r=l,l=s[(a+1)%s.length],r.onCurve)e.lineTo(r.x,r.y);else{let d=l;o.onCurve||((r.x+o.x)*.5,(r.y+o.y)*.5),l.onCurve||(d={x:(r.x+l.x)*.5,y:(r.y+l.y)*.5}),e.quadraticCurveTo(r.x,r.y,d.x,d.y)}e.closePath()}return e}function qg(i,e){if(e.isComposite)for(let t=0;t<e.components.length;t+=1){const n=e.components[t],s=i.get(n.glyphIndex);if(s.getPath(),s.points){let o;if(n.matchedPoints===void 0)o=ys(s.points,n);else{if(n.matchedPoints[0]>e.points.length-1||n.matchedPoints[1]>s.points.length-1)throw Error("Matched points out of range in "+e.name);const r=e.points[n.matchedPoints[0]];let l=s.points[n.matchedPoints[1]];const a={xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:0,dy:0};l=ys([l],a)[0],a.dx=r.x-l.x,a.dy=r.y-l.y,o=ys(s.points,a)}e.points=e.points.concat(o)}}return Sa(e.points)}function Jg(i,e,t,n){const s=new Yt.GlyphSet(n);for(let o=0;o<t.length-1;o+=1){const r=t[o],l=t[o+1];r!==l?s.push(o,Yt.ttfGlyphLoader(n,o,$g,i,e+r,qg)):s.push(o,Yt.glyphLoader(n,o))}return s}const Ta={getPath:Sa,parse:Jg};let Ma,vt,Da,Cs;function ka(i){this.font=i,this.getCommands=function(e){return Ta.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Zg(i){return i}function Pa(i){return Math.sign(i)*Math.round(Math.abs(i))}function em(i){return Math.sign(i)*Math.round(Math.abs(i*2))/2}function tm(i){return Math.sign(i)*(Math.round(Math.abs(i)+.5)-.5)}function im(i){return Math.sign(i)*Math.ceil(Math.abs(i))}function nm(i){return Math.sign(i)*Math.floor(Math.abs(i))}const Fa=function(i){const e=this.srPeriod;let t=this.srPhase;const n=this.srThreshold;let s=1;return i<0&&(i=-i,s=-1),i+=n-t,i=Math.trunc(i/e)*e,i+=t,i<0?t*s:i*s},$e={x:1,y:0,axis:"x",distance:function(i,e,t,n){return(t?i.xo:i.x)-(n?e.xo:e.x)},interpolate:function(i,e,t,n){let s,o,r,l,a,d,h;if(!n||n===this){if(s=i.xo-e.xo,o=i.xo-t.xo,a=e.x-e.xo,d=t.x-t.xo,r=Math.abs(s),l=Math.abs(o),h=r+l,h===0){i.x=i.xo+(a+d)/2;return}i.x=i.xo+(a*l+d*r)/h;return}if(s=n.distance(i,e,!0,!0),o=n.distance(i,t,!0,!0),a=n.distance(e,e,!1,!0),d=n.distance(t,t,!1,!0),r=Math.abs(s),l=Math.abs(o),h=r+l,h===0){$e.setRelative(i,i,(a+d)/2,n,!0);return}$e.setRelative(i,i,(a*l+d*r)/h,n,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(i,e,t,n,s){if(!n||n===this){i.x=(s?e.xo:e.x)+t;return}const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*n.x,a=r+t*n.y;i.x=l+(i.y-a)/n.normalSlope},slope:0,touch:function(i){i.xTouched=!0},touched:function(i){return i.xTouched},untouch:function(i){i.xTouched=!1}},Je={x:0,y:1,axis:"y",distance:function(i,e,t,n){return(t?i.yo:i.y)-(n?e.yo:e.y)},interpolate:function(i,e,t,n){let s,o,r,l,a,d,h;if(!n||n===this){if(s=i.yo-e.yo,o=i.yo-t.yo,a=e.y-e.yo,d=t.y-t.yo,r=Math.abs(s),l=Math.abs(o),h=r+l,h===0){i.y=i.yo+(a+d)/2;return}i.y=i.yo+(a*l+d*r)/h;return}if(s=n.distance(i,e,!0,!0),o=n.distance(i,t,!0,!0),a=n.distance(e,e,!1,!0),d=n.distance(t,t,!1,!0),r=Math.abs(s),l=Math.abs(o),h=r+l,h===0){Je.setRelative(i,i,(a+d)/2,n,!0);return}Je.setRelative(i,i,(a*l+d*r)/h,n,!0)},normalSlope:0,setRelative:function(i,e,t,n,s){if(!n||n===this){i.y=(s?e.yo:e.y)+t;return}const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*n.x,a=r+t*n.y;i.y=a+n.normalSlope*(i.x-l)},slope:Number.POSITIVE_INFINITY,touch:function(i){i.yTouched=!0},touched:function(i){return i.yTouched},untouch:function(i){i.yTouched=!1}};Object.freeze($e),Object.freeze(Je);function hi(i,e){this.x=i,this.y=e,this.axis=void 0,this.slope=e/i,this.normalSlope=-i/e,Object.freeze(this)}hi.prototype.distance=function(i,e,t,n){return this.x*$e.distance(i,e,t,n)+this.y*Je.distance(i,e,t,n)},hi.prototype.interpolate=function(i,e,t,n){let s,o,r,l,a,d,h;if(r=n.distance(i,e,!0,!0),l=n.distance(i,t,!0,!0),s=n.distance(e,e,!1,!0),o=n.distance(t,t,!1,!0),a=Math.abs(r),d=Math.abs(l),h=a+d,h===0){this.setRelative(i,i,(s+o)/2,n,!0);return}this.setRelative(i,i,(s*d+o*a)/h,n,!0)},hi.prototype.setRelative=function(i,e,t,n,s){n=n||this;const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*n.x,a=r+t*n.y,d=n.normalSlope,h=this.slope,p=i.x,f=i.y;i.x=(h*p-d*l+a-f)/(h-d),i.y=h*(i.x-p)+f},hi.prototype.touch=function(i){i.xTouched=!0,i.yTouched=!0};function ui(i,e){const t=Math.sqrt(i*i+e*e);return i/=t,e/=t,i===1&&e===0?$e:i===0&&e===1?Je:new hi(i,e)}function Ze(i,e,t,n){this.x=this.xo=Math.round(i*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=n,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Ze.prototype.nextTouched=function(i){let e=this.nextPointOnContour;for(;!i.touched(e)&&e!==this;)e=e.nextPointOnContour;return e},Ze.prototype.prevTouched=function(i){let e=this.prevPointOnContour;for(;!i.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};const fi=Object.freeze(new Ze(0,0)),sm={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function dt(i,e){switch(this.env=i,this.stack=[],this.prog=e,i){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=$e,this.round=Pa}}ka.prototype.exec=function(i,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let n=this._prepState;if(!n||n.ppem!==e){let s=this._fpgmState;if(!s){dt.prototype=sm,s=this._fpgmState=new dt("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,L.DEBUG&&(console.log("---EXEC FPGM---"),s.step=-1);try{vt(s)}catch(r){console.log("Hinting error in FPGM:"+r),this._errorState=3;return}}dt.prototype=s,n=this._prepState=new dt("prep",t.tables.prep),n.ppem=e;const o=t.tables.cvt;if(o){const r=n.cvt=new Array(o.length),l=e/t.unitsPerEm;for(let a=0;a<o.length;a++)r[a]=o[a]*l}else n.cvt=[];L.DEBUG&&(console.log("---EXEC PREP---"),n.step=-1);try{vt(n)}catch(r){this._errorState<2&&console.log("Hinting error in PREP:"+r),this._errorState=2}}if(!(this._errorState>1))try{return Da(i,n)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},Da=function(i,e){const t=e.ppem/e.font.unitsPerEm,n=t;let s=i.components,o,r,l;if(dt.prototype=e,!s)l=new dt("glyf",i.instructions),L.DEBUG&&(console.log("---EXEC GLYPH---"),l.step=-1),Cs(i,l,t,n),r=l.gZone;else{const a=e.font;r=[],o=[];for(let d=0;d<s.length;d++){const h=s[d],p=a.glyphs.get(h.glyphIndex);l=new dt("glyf",p.instructions),L.DEBUG&&(console.log("---EXEC COMP "+d+"---"),l.step=-1),Cs(p,l,t,n);const f=Math.round(h.dx*t),u=Math.round(h.dy*n),m=l.gZone,E=l.contours;for(let y=0;y<m.length;y++){const v=m[y];v.xTouched=v.yTouched=!1,v.xo=v.x=v.x+f,v.yo=v.y=v.y+u}const A=r.length;r.push.apply(r,m);for(let y=0;y<E.length;y++)o.push(E[y]+A)}i.instructions&&!l.inhibitGridFit&&(l=new dt("glyf",i.instructions),l.gZone=l.z0=l.z1=l.z2=r,l.contours=o,r.push(new Ze(0,0),new Ze(Math.round(i.advanceWidth*t),0)),L.DEBUG&&(console.log("---EXEC COMPOSITE---"),l.step=-1),vt(l),r.length-=2)}return r},Cs=function(i,e,t,n){const s=i.points||[],o=s.length,r=e.gZone=e.z0=e.z1=e.z2=[],l=e.contours=[];let a;for(let p=0;p<o;p++)a=s[p],r[p]=new Ze(a.x*t,a.y*n,a.lastPointOfContour,a.onCurve);let d,h;for(let p=0;p<o;p++)a=r[p],d||(d=a,l.push(p)),a.lastPointOfContour?(a.nextPointOnContour=d,d.prevPointOnContour=a,d=void 0):(h=r[p+1],a.nextPointOnContour=h,h.prevPointOnContour=a);if(!e.inhibitGridFit){if(L.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(let p=0;p<o;p++)console.log(p,r[p].x,r[p].y)}if(r.push(new Ze(0,0),new Ze(Math.round(i.advanceWidth*t),0)),vt(e),r.length-=2,L.DEBUG){console.log("FINISHED GLYPH",e.stack);for(let p=0;p<o;p++)console.log(p,r[p].x,r[p].y)}}},vt=function(i){let e=i.prog;if(!e)return;const t=e.length;let n;for(i.ip=0;i.ip<t;i.ip++){if(L.DEBUG&&i.step++,n=Ma[e[i.ip]],!n)throw new Error("unknown instruction: 0x"+Number(e[i.ip]).toString(16));n(i)}};function tn(i){const e=i.tZone=new Array(i.gZone.length);for(let t=0;t<e.length;t++)e[t]=new Ze(0,0)}function Ra(i,e){const t=i.prog;let n=i.ip,s=1,o;do if(o=t[++n],o===88)s++;else if(o===89)s--;else if(o===64)n+=t[n+1]+1;else if(o===65)n+=2*t[n+1]+1;else if(o>=176&&o<=183)n+=o-176+1;else if(o>=184&&o<=191)n+=(o-184+1)*2;else if(e&&s===1&&o===27)break;while(s>0);i.ip=n}function Oa(i,e){L.DEBUG&&console.log(e.step,"SVTCA["+i.axis+"]"),e.fv=e.pv=e.dpv=i}function La(i,e){L.DEBUG&&console.log(e.step,"SPVTCA["+i.axis+"]"),e.pv=e.dpv=i}function Na(i,e){L.DEBUG&&console.log(e.step,"SFVTCA["+i.axis+"]"),e.fv=i}function Ua(i,e){const t=e.stack,n=t.pop(),s=t.pop(),o=e.z2[n],r=e.z1[s];L.DEBUG&&console.log("SPVTL["+i+"]",n,s);let l,a;i?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.pv=e.dpv=ui(l,a)}function _a(i,e){const t=e.stack,n=t.pop(),s=t.pop(),o=e.z2[n],r=e.z1[s];L.DEBUG&&console.log("SFVTL["+i+"]",n,s);let l,a;i?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.fv=ui(l,a)}function om(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"SPVFS[]",t,n),i.pv=i.dpv=ui(n,t)}function rm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"SPVFS[]",t,n),i.fv=ui(n,t)}function am(i){const e=i.stack,t=i.pv;L.DEBUG&&console.log(i.step,"GPV[]"),e.push(t.x*16384),e.push(t.y*16384)}function lm(i){const e=i.stack,t=i.fv;L.DEBUG&&console.log(i.step,"GFV[]"),e.push(t.x*16384),e.push(t.y*16384)}function cm(i){i.fv=i.pv,L.DEBUG&&console.log(i.step,"SFVTPV[]")}function dm(i){const e=i.stack,t=e.pop(),n=e.pop(),s=e.pop(),o=e.pop(),r=e.pop(),l=i.z0,a=i.z1,d=l[t],h=l[n],p=a[s],f=a[o],u=i.z2[r];L.DEBUG&&console.log("ISECT[], ",t,n,s,o,r);const m=d.x,E=d.y,A=h.x,y=h.y,v=p.x,S=p.y,M=f.x,O=f.y,I=(m-A)*(S-O)-(E-y)*(v-M),B=m*y-E*A,g=v*O-S*M;u.x=(B*(v-M)-g*(m-A))/I,u.y=(B*(S-O)-g*(E-y))/I}function hm(i){i.rp0=i.stack.pop(),L.DEBUG&&console.log(i.step,"SRP0[]",i.rp0)}function um(i){i.rp1=i.stack.pop(),L.DEBUG&&console.log(i.step,"SRP1[]",i.rp1)}function fm(i){i.rp2=i.stack.pop(),L.DEBUG&&console.log(i.step,"SRP2[]",i.rp2)}function pm(i){const e=i.stack.pop();switch(L.DEBUG&&console.log(i.step,"SZP0[]",e),i.zp0=e,e){case 0:i.tZone||tn(i),i.z0=i.tZone;break;case 1:i.z0=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function gm(i){const e=i.stack.pop();switch(L.DEBUG&&console.log(i.step,"SZP1[]",e),i.zp1=e,e){case 0:i.tZone||tn(i),i.z1=i.tZone;break;case 1:i.z1=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function mm(i){const e=i.stack.pop();switch(L.DEBUG&&console.log(i.step,"SZP2[]",e),i.zp2=e,e){case 0:i.tZone||tn(i),i.z2=i.tZone;break;case 1:i.z2=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function Am(i){const e=i.stack.pop();switch(L.DEBUG&&console.log(i.step,"SZPS[]",e),i.zp0=i.zp1=i.zp2=e,e){case 0:i.tZone||tn(i),i.z0=i.z1=i.z2=i.tZone;break;case 1:i.z0=i.z1=i.z2=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function ym(i){i.loop=i.stack.pop(),L.DEBUG&&console.log(i.step,"SLOOP[]",i.loop)}function Cm(i){L.DEBUG&&console.log(i.step,"RTG[]"),i.round=Pa}function Em(i){L.DEBUG&&console.log(i.step,"RTHG[]"),i.round=tm}function wm(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"SMD[]",e),i.minDis=e/64}function bm(i){L.DEBUG&&console.log(i.step,"ELSE[]"),Ra(i,!1)}function vm(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"JMPR[]",e),i.ip+=e-1}function Im(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"SCVTCI[]",e),i.cvCutIn=e/64}function Bm(i){const e=i.stack;L.DEBUG&&console.log(i.step,"DUP[]"),e.push(e[e.length-1])}function Es(i){L.DEBUG&&console.log(i.step,"POP[]"),i.stack.pop()}function xm(i){L.DEBUG&&console.log(i.step,"CLEAR[]"),i.stack.length=0}function Sm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"SWAP[]"),e.push(t),e.push(n)}function Tm(i){const e=i.stack;L.DEBUG&&console.log(i.step,"DEPTH[]"),e.push(e.length)}function Mm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"LOOPCALL[]",t,n);const s=i.ip,o=i.prog;i.prog=i.funcs[t];for(let r=0;r<n;r++)vt(i),L.DEBUG&&console.log(++i.step,r+1<n?"next loopcall":"done loopcall",r);i.ip=s,i.prog=o}function Dm(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"CALL[]",e);const t=i.ip,n=i.prog;i.prog=i.funcs[e],vt(i),i.ip=t,i.prog=n,L.DEBUG&&console.log(++i.step,"returning from",e)}function km(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"CINDEX[]",t),e.push(e[e.length-t])}function Pm(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"MINDEX[]",t),e.push(e.splice(e.length-t,1)[0])}function Fm(i){if(i.env!=="fpgm")throw new Error("FDEF not allowed here");const e=i.stack,t=i.prog;let n=i.ip;const s=e.pop(),o=n;for(L.DEBUG&&console.log(i.step,"FDEF[]",s);t[++n]!==45;);i.ip=n,i.funcs[s]=t.slice(o+1,n)}function Qa(i,e){const t=e.stack.pop(),n=e.z0[t],s=e.fv,o=e.pv;L.DEBUG&&console.log(e.step,"MDAP["+i+"]",t);let r=o.distance(n,fi);i&&(r=e.round(r)),s.setRelative(n,fi,r,o),s.touch(n),e.rp0=e.rp1=t}function Ga(i,e){const t=e.z2,n=t.length-2;let s,o,r;L.DEBUG&&console.log(e.step,"IUP["+i.axis+"]");for(let l=0;l<n;l++)s=t[l],!i.touched(s)&&(o=s.prevTouched(i),o!==s&&(r=s.nextTouched(i),o===r&&i.setRelative(s,s,i.distance(o,o,!1,!0),i,!0),i.interpolate(s,o,r,i)))}function Ha(i,e){const t=e.stack,n=i?e.rp1:e.rp2,s=(i?e.z0:e.z1)[n],o=e.fv,r=e.pv;let l=e.loop;const a=e.z2;for(;l--;){const d=t.pop(),h=a[d],p=r.distance(s,s,!1,!0);o.setRelative(h,h,p,r),o.touch(h),L.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-l)+": ":"")+"SHP["+(i?"rp1":"rp2")+"]",d)}e.loop=1}function Ya(i,e){const t=e.stack,n=i?e.rp1:e.rp2,s=(i?e.z0:e.z1)[n],o=e.fv,r=e.pv,l=t.pop(),a=e.z2[e.contours[l]];let d=a;L.DEBUG&&console.log(e.step,"SHC["+i+"]",l);const h=r.distance(s,s,!1,!0);do d!==s&&o.setRelative(d,d,h,r),d=d.nextPointOnContour;while(d!==a)}function Va(i,e){const t=e.stack,n=i?e.rp1:e.rp2,s=(i?e.z0:e.z1)[n],o=e.fv,r=e.pv,l=t.pop();L.DEBUG&&console.log(e.step,"SHZ["+i+"]",l);let a;switch(l){case 0:a=e.tZone;break;case 1:a=e.gZone;break;default:throw new Error("Invalid zone")}let d;const h=r.distance(s,s,!1,!0),p=a.length-2;for(let f=0;f<p;f++)d=a[f],o.setRelative(d,d,h,r)}function Rm(i){const e=i.stack;let t=i.loop;const n=i.fv,s=e.pop()/64,o=i.z2;for(;t--;){const r=e.pop(),l=o[r];L.DEBUG&&console.log(i.step,(i.loop>1?"loop "+(i.loop-t)+": ":"")+"SHPIX[]",r,s),n.setRelative(l,l,s),n.touch(l)}i.loop=1}function Om(i){const e=i.stack,t=i.rp1,n=i.rp2;let s=i.loop;const o=i.z0[t],r=i.z1[n],l=i.fv,a=i.dpv,d=i.z2;for(;s--;){const h=e.pop(),p=d[h];L.DEBUG&&console.log(i.step,(i.loop>1?"loop "+(i.loop-s)+": ":"")+"IP[]",h,t,"<->",n),l.interpolate(p,o,r,a),l.touch(p)}i.loop=1}function za(i,e){const t=e.stack,n=t.pop()/64,s=t.pop(),o=e.z1[s],r=e.z0[e.rp0],l=e.fv,a=e.pv;l.setRelative(o,r,n,a),l.touch(o),L.DEBUG&&console.log(e.step,"MSIRP["+i+"]",n,s),e.rp1=e.rp0,e.rp2=s,i&&(e.rp0=s)}function Lm(i){const e=i.stack,t=i.rp0,n=i.z0[t];let s=i.loop;const o=i.fv,r=i.pv,l=i.z1;for(;s--;){const a=e.pop(),d=l[a];L.DEBUG&&console.log(i.step,(i.loop>1?"loop "+(i.loop-s)+": ":"")+"ALIGNRP[]",a),o.setRelative(d,n,0,r),o.touch(d)}i.loop=1}function Nm(i){L.DEBUG&&console.log(i.step,"RTDG[]"),i.round=em}function Wa(i,e){const t=e.stack,n=t.pop(),s=t.pop(),o=e.z0[s],r=e.fv,l=e.pv;let a=e.cvt[n];L.DEBUG&&console.log(e.step,"MIAP["+i+"]",n,"(",a,")",s);let d=l.distance(o,fi);i&&(Math.abs(d-a)<e.cvCutIn&&(d=a),d=e.round(d)),r.setRelative(o,fi,d,l),e.zp0===0&&(o.xo=o.x,o.yo=o.y),r.touch(o),e.rp0=e.rp1=s}function Um(i){const e=i.prog;let t=i.ip;const n=i.stack,s=e[++t];L.DEBUG&&console.log(i.step,"NPUSHB[]",s);for(let o=0;o<s;o++)n.push(e[++t]);i.ip=t}function _m(i){let e=i.ip;const t=i.prog,n=i.stack,s=t[++e];L.DEBUG&&console.log(i.step,"NPUSHW[]",s);for(let o=0;o<s;o++){let r=t[++e]<<8|t[++e];r&32768&&(r=-((r^65535)+1)),n.push(r)}i.ip=e}function Qm(i){const e=i.stack;let t=i.store;t||(t=i.store=[]);const n=e.pop(),s=e.pop();L.DEBUG&&console.log(i.step,"WS",n,s),t[s]=n}function Gm(i){const e=i.stack,t=i.store,n=e.pop();L.DEBUG&&console.log(i.step,"RS",n);const s=t&&t[n]||0;e.push(s)}function Hm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"WCVTP",t,n),i.cvt[n]=t/64}function Ym(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"RCVT",t),e.push(i.cvt[t]*64)}function ja(i,e){const t=e.stack,n=t.pop(),s=e.z2[n];L.DEBUG&&console.log(e.step,"GC["+i+"]",n),t.push(e.dpv.distance(s,fi,i,!1)*64)}function Ka(i,e){const t=e.stack,n=t.pop(),s=t.pop(),o=e.z1[n],r=e.z0[s],l=e.dpv.distance(r,o,i,i);L.DEBUG&&console.log(e.step,"MD["+i+"]",n,s,"->",l),e.stack.push(Math.round(l*64))}function Vm(i){L.DEBUG&&console.log(i.step,"MPPEM[]"),i.stack.push(i.ppem)}function zm(i){L.DEBUG&&console.log(i.step,"FLIPON[]"),i.autoFlip=!0}function Wm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"LT[]",t,n),e.push(n<t?1:0)}function jm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"LTEQ[]",t,n),e.push(n<=t?1:0)}function Km(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"GT[]",t,n),e.push(n>t?1:0)}function $m(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"GTEQ[]",t,n),e.push(n>=t?1:0)}function Xm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"EQ[]",t,n),e.push(t===n?1:0)}function qm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"NEQ[]",t,n),e.push(t!==n?1:0)}function Jm(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"ODD[]",t),e.push(Math.trunc(t)%2?1:0)}function Zm(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"EVEN[]",t),e.push(Math.trunc(t)%2?0:1)}function eA(i){let e=i.stack.pop();L.DEBUG&&console.log(i.step,"IF[]",e),e||(Ra(i,!0),L.DEBUG&&console.log(i.step,"EIF[]"))}function tA(i){L.DEBUG&&console.log(i.step,"EIF[]")}function iA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"AND[]",t,n),e.push(t&&n?1:0)}function nA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"OR[]",t,n),e.push(t||n?1:0)}function sA(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"NOT[]",t),e.push(t?0:1)}function ws(i,e){const t=e.stack,n=t.pop(),s=e.fv,o=e.pv,r=e.ppem,l=e.deltaBase+(i-1)*16,a=e.deltaShift,d=e.z0;L.DEBUG&&console.log(e.step,"DELTAP["+i+"]",n,t);for(let h=0;h<n;h++){const p=t.pop(),f=t.pop();if(l+((f&240)>>4)!==r)continue;let m=(f&15)-8;m>=0&&m++,L.DEBUG&&console.log(e.step,"DELTAPFIX",p,"by",m*a);const E=d[p];s.setRelative(E,E,m*a,o)}}function oA(i){const t=i.stack.pop();L.DEBUG&&console.log(i.step,"SDB[]",t),i.deltaBase=t}function rA(i){const t=i.stack.pop();L.DEBUG&&console.log(i.step,"SDS[]",t),i.deltaShift=Math.pow(.5,t)}function aA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"ADD[]",t,n),e.push(n+t)}function lA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"SUB[]",t,n),e.push(n-t)}function cA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"DIV[]",t,n),e.push(n*64/t)}function dA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"MUL[]",t,n),e.push(n*t/64)}function hA(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"ABS[]",t),e.push(Math.abs(t))}function uA(i){const e=i.stack;let t=e.pop();L.DEBUG&&console.log(i.step,"NEG[]",t),e.push(-t)}function fA(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"FLOOR[]",t),e.push(Math.floor(t/64)*64)}function pA(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"CEILING[]",t),e.push(Math.ceil(t/64)*64)}function nn(i,e){const t=e.stack,n=t.pop();L.DEBUG&&console.log(e.step,"ROUND[]"),t.push(e.round(n/64)*64)}function gA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"WCVTF[]",t,n),i.cvt[n]=t*i.ppem/i.font.unitsPerEm}function bs(i,e){const t=e.stack,n=t.pop(),s=e.ppem,o=e.deltaBase+(i-1)*16,r=e.deltaShift;L.DEBUG&&console.log(e.step,"DELTAC["+i+"]",n,t);for(let l=0;l<n;l++){const a=t.pop(),d=t.pop();if(o+((d&240)>>4)!==s)continue;let p=(d&15)-8;p>=0&&p++;const f=p*r;L.DEBUG&&console.log(e.step,"DELTACFIX",a,"by",f),e.cvt[a]+=f}}function mA(i){let e=i.stack.pop();L.DEBUG&&console.log(i.step,"SROUND[]",e),i.round=Fa;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(i.srPeriod=t,e&48){case 0:i.srPhase=0;break;case 16:i.srPhase=.25*t;break;case 32:i.srPhase=.5*t;break;case 48:i.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?i.srThreshold=0:i.srThreshold=(e/8-.5)*t}function AA(i){let e=i.stack.pop();L.DEBUG&&console.log(i.step,"S45ROUND[]",e),i.round=Fa;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(i.srPeriod=t,e&48){case 0:i.srPhase=0;break;case 16:i.srPhase=.25*t;break;case 32:i.srPhase=.5*t;break;case 48:i.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?i.srThreshold=0:i.srThreshold=(e/8-.5)*t}function yA(i){L.DEBUG&&console.log(i.step,"ROFF[]"),i.round=Zg}function CA(i){L.DEBUG&&console.log(i.step,"RUTG[]"),i.round=im}function EA(i){L.DEBUG&&console.log(i.step,"RDTG[]"),i.round=nm}function wA(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"SCANCTRL[]",e)}function $a(i,e){const t=e.stack,n=t.pop(),s=t.pop(),o=e.z2[n],r=e.z1[s];L.DEBUG&&console.log(e.step,"SDPVTL["+i+"]",n,s);let l,a;i?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.dpv=ui(l,a)}function bA(i){const e=i.stack,t=e.pop();let n=0;L.DEBUG&&console.log(i.step,"GETINFO[]",t),t&1&&(n=35),t&32&&(n|=4096),e.push(n)}function vA(i){const e=i.stack,t=e.pop(),n=e.pop(),s=e.pop();L.DEBUG&&console.log(i.step,"ROLL[]"),e.push(n),e.push(t),e.push(s)}function IA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"MAX[]",t,n),e.push(Math.max(n,t))}function BA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"MIN[]",t,n),e.push(Math.min(n,t))}function xA(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"SCANTYPE[]",e)}function SA(i){const e=i.stack.pop();let t=i.stack.pop();switch(L.DEBUG&&console.log(i.step,"INSTCTRL[]",e,t),e){case 1:i.inhibitGridFit=!!t;return;case 2:i.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function ht(i,e){const t=e.stack,n=e.prog;let s=e.ip;L.DEBUG&&console.log(e.step,"PUSHB["+i+"]");for(let o=0;o<i;o++)t.push(n[++s]);e.ip=s}function ut(i,e){let t=e.ip;const n=e.prog,s=e.stack;L.DEBUG&&console.log(e.ip,"PUSHW["+i+"]");for(let o=0;o<i;o++){let r=n[++t]<<8|n[++t];r&32768&&(r=-((r^65535)+1)),s.push(r)}e.ip=t}function K(i,e,t,n,s,o){const r=o.stack,l=i&&r.pop(),a=r.pop(),d=o.rp0,h=o.z0[d],p=o.z1[a],f=o.minDis,u=o.fv,m=o.dpv;let E,A,y,v;A=E=m.distance(p,h,!0,!0),y=A>=0?1:-1,A=Math.abs(A),i&&(v=o.cvt[l],n&&Math.abs(A-v)<o.cvCutIn&&(A=v)),t&&A<f&&(A=f),n&&(A=o.round(A)),u.setRelative(p,h,y*A,m),u.touch(p),L.DEBUG&&console.log(o.step,(i?"MIRP[":"MDRP[")+(e?"M":"m")+(t?">":"_")+(n?"R":"_")+(s===0?"Gr":s===1?"Bl":s===2?"Wh":"")+"]",i?l+"("+o.cvt[l]+","+v+")":"",a,"(d =",E,"->",y*A,")"),o.rp1=o.rp0,o.rp2=a,e&&(o.rp0=a)}Ma=[Oa.bind(void 0,Je),Oa.bind(void 0,$e),La.bind(void 0,Je),La.bind(void 0,$e),Na.bind(void 0,Je),Na.bind(void 0,$e),Ua.bind(void 0,0),Ua.bind(void 0,1),_a.bind(void 0,0),_a.bind(void 0,1),om,rm,am,lm,cm,dm,hm,um,fm,pm,gm,mm,Am,ym,Cm,Em,wm,bm,vm,Im,void 0,void 0,Bm,Es,xm,Sm,Tm,km,Pm,void 0,void 0,void 0,Mm,Dm,Fm,void 0,Qa.bind(void 0,0),Qa.bind(void 0,1),Ga.bind(void 0,Je),Ga.bind(void 0,$e),Ha.bind(void 0,0),Ha.bind(void 0,1),Ya.bind(void 0,0),Ya.bind(void 0,1),Va.bind(void 0,0),Va.bind(void 0,1),Rm,Om,za.bind(void 0,0),za.bind(void 0,1),Lm,Nm,Wa.bind(void 0,0),Wa.bind(void 0,1),Um,_m,Qm,Gm,Hm,Ym,ja.bind(void 0,0),ja.bind(void 0,1),void 0,Ka.bind(void 0,0),Ka.bind(void 0,1),Vm,void 0,zm,void 0,void 0,Wm,jm,Km,$m,Xm,qm,Jm,Zm,eA,tA,iA,nA,sA,ws.bind(void 0,1),oA,rA,aA,lA,cA,dA,hA,uA,fA,pA,nn.bind(void 0,0),nn.bind(void 0,1),nn.bind(void 0,2),nn.bind(void 0,3),void 0,void 0,void 0,void 0,gA,ws.bind(void 0,2),ws.bind(void 0,3),bs.bind(void 0,1),bs.bind(void 0,2),bs.bind(void 0,3),mA,AA,void 0,void 0,yA,void 0,CA,EA,Es,Es,void 0,void 0,void 0,void 0,void 0,wA,$a.bind(void 0,0),$a.bind(void 0,1),bA,void 0,vA,IA,BA,xA,SA,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ht.bind(void 0,1),ht.bind(void 0,2),ht.bind(void 0,3),ht.bind(void 0,4),ht.bind(void 0,5),ht.bind(void 0,6),ht.bind(void 0,7),ht.bind(void 0,8),ut.bind(void 0,1),ut.bind(void 0,2),ut.bind(void 0,3),ut.bind(void 0,4),ut.bind(void 0,5),ut.bind(void 0,6),ut.bind(void 0,7),ut.bind(void 0,8),K.bind(void 0,0,0,0,0,0),K.bind(void 0,0,0,0,0,1),K.bind(void 0,0,0,0,0,2),K.bind(void 0,0,0,0,0,3),K.bind(void 0,0,0,0,1,0),K.bind(void 0,0,0,0,1,1),K.bind(void 0,0,0,0,1,2),K.bind(void 0,0,0,0,1,3),K.bind(void 0,0,0,1,0,0),K.bind(void 0,0,0,1,0,1),K.bind(void 0,0,0,1,0,2),K.bind(void 0,0,0,1,0,3),K.bind(void 0,0,0,1,1,0),K.bind(void 0,0,0,1,1,1),K.bind(void 0,0,0,1,1,2),K.bind(void 0,0,0,1,1,3),K.bind(void 0,0,1,0,0,0),K.bind(void 0,0,1,0,0,1),K.bind(void 0,0,1,0,0,2),K.bind(void 0,0,1,0,0,3),K.bind(void 0,0,1,0,1,0),K.bind(void 0,0,1,0,1,1),K.bind(void 0,0,1,0,1,2),K.bind(void 0,0,1,0,1,3),K.bind(void 0,0,1,1,0,0),K.bind(void 0,0,1,1,0,1),K.bind(void 0,0,1,1,0,2),K.bind(void 0,0,1,1,0,3),K.bind(void 0,0,1,1,1,0),K.bind(void 0,0,1,1,1,1),K.bind(void 0,0,1,1,1,2),K.bind(void 0,0,1,1,1,3),K.bind(void 0,1,0,0,0,0),K.bind(void 0,1,0,0,0,1),K.bind(void 0,1,0,0,0,2),K.bind(void 0,1,0,0,0,3),K.bind(void 0,1,0,0,1,0),K.bind(void 0,1,0,0,1,1),K.bind(void 0,1,0,0,1,2),K.bind(void 0,1,0,0,1,3),K.bind(void 0,1,0,1,0,0),K.bind(void 0,1,0,1,0,1),K.bind(void 0,1,0,1,0,2),K.bind(void 0,1,0,1,0,3),K.bind(void 0,1,0,1,1,0),K.bind(void 0,1,0,1,1,1),K.bind(void 0,1,0,1,1,2),K.bind(void 0,1,0,1,1,3),K.bind(void 0,1,1,0,0,0),K.bind(void 0,1,1,0,0,1),K.bind(void 0,1,1,0,0,2),K.bind(void 0,1,1,0,0,3),K.bind(void 0,1,1,0,1,0),K.bind(void 0,1,1,0,1,1),K.bind(void 0,1,1,0,1,2),K.bind(void 0,1,1,0,1,3),K.bind(void 0,1,1,1,0,0),K.bind(void 0,1,1,1,0,1),K.bind(void 0,1,1,1,0,2),K.bind(void 0,1,1,1,0,3),K.bind(void 0,1,1,1,1,0),K.bind(void 0,1,1,1,1,1),K.bind(void 0,1,1,1,1,2),K.bind(void 0,1,1,1,1,3)];const TA=Array.from||(i=>i.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g)||[]);function re(i){i=i||{},i.empty||(zt(i.familyName,"When creating a new Font object, familyName is required."),zt(i.styleName,"When creating a new Font object, styleName is required."),zt(i.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),zt(i.ascender,"When creating a new Font object, ascender is required."),zt(i.descender,"When creating a new Font object, descender is required."),zt(i.descender<0,"Descender should be negative (e.g. -512)."),this.names={fontFamily:{en:i.familyName||" "},fontSubfamily:{en:i.styleName||" "},fullName:{en:i.fullName||i.familyName+" "+i.styleName},postScriptName:{en:i.postScriptName||(i.familyName+i.styleName).replace(/\s/g,"")},designer:{en:i.designer||" "},designerURL:{en:i.designerURL||" "},manufacturer:{en:i.manufacturer||" "},manufacturerURL:{en:i.manufacturerURL||" "},license:{en:i.license||" "},licenseURL:{en:i.licenseURL||" "},version:{en:i.version||"Version 0.1"},description:{en:i.description||" "},copyright:{en:i.copyright||" "},trademark:{en:i.trademark||" "}},this.unitsPerEm=i.unitsPerEm||1e3,this.ascender=i.ascender,this.descender=i.descender,this.createdTimestamp=i.createdTimestamp,this.tables={os2:{usWeightClass:i.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:i.widthClass||this.usWidthClasses.MEDIUM,fsSelection:i.fsSelection||this.fsSelectionValues.REGULAR}}),this.supported=!0,this.glyphs=new Yt.GlyphSet(this,i.glyphs||[]),this.encoding=new Vr(this),this.position=new di(this),this.substitution=new Qe(this),this.tables=this.tables||{},Object.defineProperty(this,"hinting",{get:function(){if(this._hinting)return this._hinting;if(this.outlinesFormat==="truetype")return this._hinting=new ka(this)}})}re.prototype.hasChar=function(i){return this.encoding.charToGlyphIndex(i)!==null},re.prototype.charToGlyphIndex=function(i){return this.encoding.charToGlyphIndex(i)},re.prototype.charToGlyph=function(i){const e=this.charToGlyphIndex(i);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},re.prototype.stringToGlyphs=function(i,e){e=e||this.defaultRenderOptions;const t=TA(i),n=[];for(let l=0;l<t.length;l+=1){const a=t[l];n.push(this.charToGlyphIndex(a))}let s=n.length;if(e.features){const l=e.script||this.substitution.getDefaultScriptName();let a=[];e.features.liga&&(a=a.concat(this.substitution.getFeature("liga",l,e.language))),e.features.rlig&&(a=a.concat(this.substitution.getFeature("rlig",l,e.language)));for(let d=0;d<s;d+=1)for(let h=0;h<a.length;h++){const p=a[h],f=p.sub,u=f.length;let m=0;for(;m<u&&f[m]===n[d+m];)m++;m===u&&(n.splice(d,u,p.by),s=s-u+1)}}const o=new Array(s),r=this.glyphs.get(0);for(let l=0;l<s;l+=1)o[l]=this.glyphs.get(n[l])||r;return o},re.prototype.nameToGlyphIndex=function(i){return this.glyphNames.nameToGlyphIndex(i)},re.prototype.nameToGlyph=function(i){const e=this.nameToGlyphIndex(i);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},re.prototype.glyphIndexToName=function(i){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(i):""},re.prototype.getKerningValue=function(i,e){i=i.index||i,e=e.index||e;const t=this.position.defaultKerningTables;return t?this.position.getKerningValue(t,i,e):this.kerningPairs[i+","+e]||0},re.prototype.defaultRenderOptions={kerning:!0,features:{liga:!0,rlig:!0}},re.prototype.forEachGlyph=function(i,e,t,n,s,o){e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:72,s=s||this.defaultRenderOptions;const r=1/this.unitsPerEm*n,l=this.stringToGlyphs(i,s);let a;if(s.kerning){const d=s.script||this.position.getDefaultScriptName();a=this.position.getKerningTables(d,s.language)}for(let d=0;d<l.length;d+=1){const h=l[d];if(o.call(this,h,e,t,n,s),h.advanceWidth&&(e+=h.advanceWidth*r),s.kerning&&d<l.length-1){const p=a?this.position.getKerningValue(a,h.index,l[d+1].index):this.getKerningValue(h,l[d+1]);e+=p*r}s.letterSpacing?e+=s.letterSpacing*n:s.tracking&&(e+=s.tracking/1e3*n)}return e},re.prototype.getPath=function(i,e,t,n,s){const o=new be;return this.forEachGlyph(i,e,t,n,s,function(r,l,a,d){const h=r.getPath(l,a,d,s,this);o.extend(h)}),o},re.prototype.getPaths=function(i,e,t,n,s){const o=[];return this.forEachGlyph(i,e,t,n,s,function(r,l,a,d){const h=r.getPath(l,a,d,s,this);o.push(h)}),o},re.prototype.getAdvanceWidth=function(i,e,t){return this.forEachGlyph(i,0,0,e,t,function(){})},re.prototype.draw=function(i,e,t,n,s,o){this.getPath(e,t,n,s,o).draw(i)},re.prototype.drawPoints=function(i,e,t,n,s,o){this.forEachGlyph(e,t,n,s,o,function(r,l,a,d){r.drawPoints(i,l,a,d)})},re.prototype.drawMetrics=function(i,e,t,n,s,o){this.forEachGlyph(e,t,n,s,o,function(r,l,a,d){r.drawMetrics(i,l,a,d)})},re.prototype.getEnglishName=function(i){const e=this.names[i];if(e)return e.en},re.prototype.validate=function(){const i=this;function e(n,s){}function t(n){const s=i.getEnglishName(n);s&&s.trim().length>0}t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),this.unitsPerEm>0},re.prototype.toTables=function(){return Vg.fontToTable(this)},re.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},re.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let s=0;s<e.length;s++)n[s]=e[s];return t},re.prototype.download=function(i){const e=this.getEnglishName("fontFamily"),t=this.getEnglishName("fontSubfamily");i=i||e.replace(/\s/g,"")+"-"+t+".otf";const n=this.toArrayBuffer();if(Wg())if(window.URL=window.URL||window.webkitURL,window.URL){const s=new DataView(n),o=new Blob([s],{type:"font/opentype"});let r=document.createElement("a");r.href=window.URL.createObjectURL(o),r.download=i;let l=document.createEvent("MouseEvents");l.initEvent("click",!0,!1),r.dispatchEvent(l)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{const s=require("fs"),o=Kg(n);s.writeFileSync(i,o)}},re.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},re.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},re.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function Xa(i,e){const t=JSON.stringify(i);let n=256;for(let s in e){let o=parseInt(s);if(!(!o||o<256)){if(JSON.stringify(e[s])===t)return o;n<=o&&(n=o+1)}}return e[n]=i,n}function MA(i,e,t){const n=Xa(e.name,t);return[{name:"tag_"+i,type:"TAG",value:e.tag},{name:"minValue_"+i,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+i,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+i,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+i,type:"USHORT",value:0},{name:"nameID_"+i,type:"USHORT",value:n}]}function DA(i,e,t){const n={},s=new $.Parser(i,e);return n.tag=s.parseTag(),n.minValue=s.parseFixed(),n.defaultValue=s.parseFixed(),n.maxValue=s.parseFixed(),s.skip("uShort",1),n.name=t[s.parseUShort()]||{},n}function kA(i,e,t,n){const s=Xa(e.name,n),o=[{name:"nameID_"+i,type:"USHORT",value:s},{name:"flags_"+i,type:"USHORT",value:0}];for(let r=0;r<t.length;++r){const l=t[r].tag;o.push({name:"axis_"+i+" "+l,type:"FIXED",value:e.coordinates[l]<<16})}return o}function PA(i,e,t,n){const s={},o=new $.Parser(i,e);s.name=n[o.parseUShort()]||{},o.skip("uShort",1),s.coordinates={};for(let r=0;r<t.length;++r)s.coordinates[t[r].tag]=o.parseFixed();return s}function FA(i,e){const t=new J.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:i.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:i.instances.length},{name:"instanceSize",type:"USHORT",value:4+i.axes.length*4}]);t.offsetToData=t.sizeOf();for(let n=0;n<i.axes.length;n++)t.fields=t.fields.concat(MA(n,i.axes[n],e));for(let n=0;n<i.instances.length;n++)t.fields=t.fields.concat(kA(n,i.instances[n],i.axes,e));return t}function RA(i,e,t){const n=new $.Parser(i,e),s=n.parseULong();te.argument(s===65536,"Unsupported fvar table version.");const o=n.parseOffset16();n.skip("uShort",1);const r=n.parseUShort(),l=n.parseUShort(),a=n.parseUShort(),d=n.parseUShort(),h=[];for(let u=0;u<r;u++)h.push(DA(i,e+o+u*l,t));const p=[],f=e+o+r*l;for(let u=0;u<a;u++)p.push(PA(i,f+u*d,h,t));return{axes:h,instances:p}}const OA={make:FA,parse:RA},Ge=new Array(10);Ge[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(G.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(G.coverage),values:this.parseValueRecordList()};te.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},Ge[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();te.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const n=this.parsePointer(G.coverage),s=this.parseUShort(),o=this.parseUShort();if(t===1)return{posFormat:t,coverage:n,valueFormat1:s,valueFormat2:o,pairSets:this.parseList(G.pointer(G.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(o)}})))};if(t===2){const r=this.parsePointer(G.classDef),l=this.parsePointer(G.classDef),a=this.parseUShort(),d=this.parseUShort();return{posFormat:t,coverage:n,valueFormat1:s,valueFormat2:o,classDef1:r,classDef2:l,class1Count:a,class2Count:d,classRecords:this.parseList(a,G.list(d,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(o)}}))}}},Ge[3]=function(){return{error:"GPOS Lookup 3 not supported"}},Ge[4]=function(){return{error:"GPOS Lookup 4 not supported"}},Ge[5]=function(){return{error:"GPOS Lookup 5 not supported"}},Ge[6]=function(){return{error:"GPOS Lookup 6 not supported"}},Ge[7]=function(){return{error:"GPOS Lookup 7 not supported"}},Ge[8]=function(){return{error:"GPOS Lookup 8 not supported"}},Ge[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function LA(i,e){e=e||0;const t=new G(i,e),n=t.parseVersion(1);return te.argument(n===1||n===1.1,"Unsupported GPOS table version "+n),n===1?{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Ge)}:{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Ge),variations:t.parseFeatureVariationsList()}}const NA=new Array(10);function UA(i){return new J.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new J.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new J.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new J.LookupList(i.lookups,NA)}])}const _A={parse:LA,make:UA};function QA(i){const e={};i.skip("uShort");const t=i.parseUShort();te.argument(t===0,"Unsupported kern sub-table version."),i.skip("uShort",2);const n=i.parseUShort();i.skip("uShort",3);for(let s=0;s<n;s+=1){const o=i.parseUShort(),r=i.parseUShort(),l=i.parseShort();e[o+","+r]=l}return e}function GA(i){const e={};i.skip("uShort"),i.parseULong()>1&&console.warn("Only the first kern subtable is supported."),i.skip("uLong");const s=i.parseUShort()&255;if(i.skip("uShort"),s===0){const o=i.parseUShort();i.skip("uShort",3);for(let r=0;r<o;r+=1){const l=i.parseUShort(),a=i.parseUShort(),d=i.parseShort();e[l+","+a]=d}}return e}function HA(i,e){const t=new $.Parser(i,e),n=t.parseUShort();if(n===0)return QA(t);if(n===1)return GA(t);throw new Error("Unsupported kern table version ("+n+").")}const YA={parse:HA};function VA(i,e,t,n){const s=new $.Parser(i,e),o=n?s.parseUShort:s.parseULong,r=[];for(let l=0;l<t+1;l+=1){let a=o.call(s);n&&(a*=2),r.push(a)}return r}const zA={parse:VA};function WA(i,e){require("fs").readFile(i,function(n,s){if(n)return e(n.message);e(null,jg(s))})}function jA(i,e){const t=new XMLHttpRequest;t.open("get",i,!0),t.responseType="arraybuffer",t.onload=function(){return t.response?e(null,t.response):e("Font could not be loaded: "+t.statusText)},t.onerror=function(){e("Font could not be loaded")},t.send()}function qa(i,e){const t=[];let n=12;for(let s=0;s<e;s+=1){const o=$.getTag(i,n),r=$.getULong(i,n+4),l=$.getULong(i,n+8),a=$.getULong(i,n+12);t.push({tag:o,checksum:r,offset:l,length:a,compression:!1}),n+=16}return t}function KA(i,e){const t=[];let n=44;for(let s=0;s<e;s+=1){const o=$.getTag(i,n),r=$.getULong(i,n+4),l=$.getULong(i,n+8),a=$.getULong(i,n+12);let d;l<a?d="WOFF":d=!1,t.push({tag:o,offset:r,compression:d,compressedLength:l,length:a}),n+=20}return t}function Ee(i,e){if(e.compression==="WOFF"){const t=new Uint8Array(i.buffer,e.offset+2,e.compressedLength-2),n=new Uint8Array(e.length);if(xp(t,n),n.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");return{data:new DataView(n.buffer,0),offset:0}}else return{data:i,offset:e.offset}}function $A(i){let e,t;const n=new re({empty:!0}),s=new DataView(i,0);let o,r=[];const l=$.getTag(s,0);if(l==="\0\0\0"||l==="true"||l==="typ1")n.outlinesFormat="truetype",o=$.getUShort(s,4),r=qa(s,o);else if(l==="OTTO")n.outlinesFormat="cff",o=$.getUShort(s,4),r=qa(s,o);else if(l==="wOFF"){const O=$.getTag(s,4);if(O==="\0\0\0")n.outlinesFormat="truetype";else if(O==="OTTO")n.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+l);o=$.getUShort(s,12),r=KA(s,o)}else throw new Error("Unsupported OpenType signature "+l);let a,d,h,p,f,u,m,E,A,y,v;for(let O=0;O<o;O+=1){const I=r[O];let B;switch(I.tag){case"cmap":B=Ee(s,I),n.tables.cmap=Yr.parse(B.data,B.offset),n.encoding=new zr(n.tables.cmap);break;case"cvt ":B=Ee(s,I),v=new $.Parser(B.data,B.offset),n.tables.cvt=v.parseShortList(I.length/2);break;case"fvar":d=I;break;case"fpgm":B=Ee(s,I),v=new $.Parser(B.data,B.offset),n.tables.fpgm=v.parseByteList(I.length);break;case"head":B=Ee(s,I),n.tables.head=sa.parse(B.data,B.offset),n.unitsPerEm=n.tables.head.unitsPerEm,e=n.tables.head.indexToLocFormat;break;case"hhea":B=Ee(s,I),n.tables.hhea=oa.parse(B.data,B.offset),n.ascender=n.tables.hhea.ascender,n.descender=n.tables.hhea.descender,n.numberOfHMetrics=n.tables.hhea.numberOfHMetrics;break;case"hmtx":u=I;break;case"ltag":B=Ee(s,I),t=aa.parse(B.data,B.offset);break;case"maxp":B=Ee(s,I),n.tables.maxp=la.parse(B.data,B.offset),n.numGlyphs=n.tables.maxp.numGlyphs;break;case"name":A=I;break;case"OS/2":B=Ee(s,I),n.tables.os2=gs.parse(B.data,B.offset);break;case"post":B=Ee(s,I),n.tables.post=ma.parse(B.data,B.offset),n.glyphNames=new cs(n.tables.post);break;case"prep":B=Ee(s,I),v=new $.Parser(B.data,B.offset),n.tables.prep=v.parseByteList(I.length);break;case"glyf":h=I;break;case"loca":E=I;break;case"CFF ":a=I;break;case"kern":m=I;break;case"GPOS":p=I;break;case"GSUB":f=I;break;case"meta":y=I;break}}const S=Ee(s,A);if(n.tables.name=ga.parse(S.data,S.offset,t),n.names=n.tables.name,h&&E){const O=e===0,I=Ee(s,E),B=zA.parse(I.data,I.offset,n.numGlyphs,O),g=Ee(s,h);n.glyphs=Ta.parse(g.data,g.offset,B,n)}else if(a){const O=Ee(s,a);na.parse(O.data,O.offset,n)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");const M=Ee(s,u);if(ra.parse(M.data,M.offset,n.numberOfHMetrics,n.numGlyphs,n.glyphs),zp(n),m){const O=Ee(s,m);n.kerningPairs=YA.parse(O.data,O.offset)}else n.kerningPairs={};if(p){const O=Ee(s,p);n.tables.gpos=_A.parse(O.data,O.offset),n.position.init()}if(f){const O=Ee(s,f);n.tables.gsub=Aa.parse(O.data,O.offset)}if(d){const O=Ee(s,d);n.tables.fvar=OA.parse(O.data,O.offset,n.names)}if(y){const O=Ee(s,y);n.tables.meta=ya.parse(O.data,O.offset),n.metas=n.tables.meta}return n}function XA(i,e){(typeof window>"u"?WA:jA)(i,function(s,o){if(s)return e(s);let r;try{r=$A(o)}catch(l){return e(l,null)}return e(null,r)})}const vs=1e-12;function pi(i){if(!Array.isArray(i)||i.length===0)return i||[];const e=i[0],t=i[i.length-1];if(!e||!t||e.length<2||t.length<2)return i;const n=e[0]??0,s=e[1]??0,o=t[0]??0,r=t[1]??0;return(Math.abs(n-o)>vs||Math.abs(s-r)>vs)&&i.push([n,s]),i}function It(i){let e=0;if(!i)return 0;for(let t=0;t<i.length-1;t++){const n=i[t],s=i[t+1];if(!n||!s)continue;const o=n[0]??0,r=n[1]??0,l=s[0]??0,a=s[1]??0;e+=o*a-l*r}return e/2}function sn(i,e=vs){const t=[];if(!i)return t;for(const n of i){if(!n||n.length<2)continue;const s=t[t.length-1],o=n[0]??0,r=n[1]??0;if(!s){t.push([o,r]);continue}const l=s[0]??0,a=s[1]??0;(Math.abs(o-l)>e||Math.abs(r-a)>e)&&t.push([o,r])}return t}function qA(i,e,t,n,s=16){const o=[],r=i?.[0]??0,l=i?.[1]??0,a=t?.[0]??0,d=t?.[1]??0,h=n?.[0]??0,p=n?.[1]??0,f=e?.[0]??0,u=e?.[1]??0;for(let m=0;m<=s;m++){const E=m/s,A=1-E,y=A*A*A*r+3*A*A*E*a+3*A*E*E*h+E*E*E*f,v=A*A*A*l+3*A*A*E*d+3*A*E*E*p+E*E*E*u;o.push([y,v])}return o}function Ja(i,e){if(!i||!e)return!1;const t=i[0]??0,n=i[1]??0;let s=!1;for(let o=0,r=e.length-1;o<e.length;r=o++){const l=e[o],a=e[r];if(!l||!a)continue;const d=l[0]??0,h=l[1]??0,p=a[0]??0,f=a[1]??0;h>n!=f>n&&t<(p-d)*(n-h)/(f-h+0)+d&&(s=!s)}return s}function Is(i){return i?(It(i)<0&&i.reverse(),pi(i),i):[]}function JA(i){return i?(It(i)>0&&i.reverse(),pi(i),i):[]}function Za(i,e=16){if(!i||!Array.isArray(i.commands))return[];const t=[];let n=[];for(const s of i.commands){let o=function(l){const a=l.x!==void 0?l.x:0,d=l.y!==void 0?-l.y:0;return[a,d]};const r=s.type;if(r==="M")n.length&&t.push(sn(n)),n=[o(s)];else if(r==="L")n.push(o(s));else if(r==="Q"){const a=n[n.length-1]||o(s),d=[],h=s.x??0,p=s.y??0,f=s.x1??0,u=s.y1??0,m=a[0]??0,E=a[1]??0;for(let A=1;A<=e;A++){const y=A/e,v=1-y,S=v*v*m+2*v*y*f+y*y*h,M=v*v*E+2*v*y*u+y*y*-p;d.push([S,M])}d.length?n.push(...d):n.push(o(s))}else if(r==="C"){const a=n[n.length-1]||o(s),d=[s.x1||0,-(s.y1||0)],h=[s.x2||0,-(s.y2||0)],p=[s.x||0,-(s.y||0)],f=qA(a,p,d,h,e);f.length>1?n.push(...f.slice(1)):n.push(p)}else r==="Z"||r==="z"?(n.length&&t.push(sn(n)),n=[]):s.x!==void 0&&s.y!==void 0&&n.push(o(s))}return n.length&&t.push(sn(n)),t.map(s=>pi(s)).filter(s=>s&&s.length>=4)}function Bs(i,e){if(!i)return null;const t=i.map(n=>pi(n.slice()));return{type:"Feature",geometry:{type:"Polygon",coordinates:t},properties:{...e.properties||{},rings:t.length,polygons:1}}}function ZA(i,e,t={}){t=Object.assign({sampleSegments:16,simplifyTolerance:0,epsArea:1e-24,debug:!1,scale:1,widthScale:.6,fillWinding:"auto"},t||{scale:1});const n=!!t.debug;if(!i||!i.geometry||!Array.isArray(i.geometry.coordinates))return{type:"FeatureCollection",features:[]};const s=i.geometry.coordinates,o=i.properties||{},r=o.text||o.label||"",l=o.rotation??0,a=t.sampleSegments||16,d=t.epsArea||1e-24,p=o.height/.9||1,f=(t.scale||1)*p,u=-l*Math.PI/180,m=Math.cos(u),E=Math.sin(u),A=o.attachmentPoint||"bottom-left",y=[];if(!e||typeof e.getPaths!="function")return{type:"FeatureCollection",features:y};const v=e.getPaths(r,0,0,t.fontSize||1)||[];let S=[];for(const _ of v){const H=Za(_,a);for(const N of H)if(N)for(const w of N)w&&S.push(w)}let M=1/0,O=1/0,I=-1/0,B=-1/0;for(const _ of S){if(!_)continue;const H=_[0]??0,N=_[1]??0;M=Math.min(M,H),O=Math.min(O,N),I=Math.max(I,H),B=Math.max(B,N)}const g=I-M,P=B-O;let x=0,F=0;switch(A){case"top-left":x=0,F=-P;break;case"top-center":x=-g/2,F=P;break;case"top-right":x=-g,F=P;break;case"center-left":x=0,F=P/2;break;case"center":x=-g/2,F=P/2;break;case"center-right":x=-g,F=P/2;break;case"bottom-left":x=0,F=0;break;case"bottom-center":x=-g/2,F=0;break;case"bottom-right":x=-g,F=0;break;default:x=0,F=0}for(const _ of v){const H=Za(_,a);if(!H||H.length===0)continue;const N=H.map(k=>{if(!k)return[];const Q=k.map(R=>{if(!R)return[0,0];let T=(R[0]??0)+x,U=(R[1]??0)+F;T=T*(t.widthScale||.6);const V=T*m-U*E,W=T*E+U*m;return[s[0]+V*f,s[1]+W*f]});return pi(sn(Q))}).filter(k=>k&&k.length>=4&&Math.abs(It(k))>d);if(N.length===0)continue;let w=1;if(t.fillWinding==="positive")w=1;else if(t.fillWinding==="negative")w=-1;else{let k=0,Q=-1;for(let U=0;U<N.length;U++){const V=N[U];if(!V)continue;const W=It(V);Math.abs(W)>Q&&(Q=Math.abs(W),k=U)}const R=N[k],T=R?It(R):0;w=T>=0?1:-1,n&&console.log("[simple] auto fillSign=",w,"largest signed area=",T)}const C=N.map((k,Q)=>({idx:Q,ring:k,signedArea:It(k),absArea:Math.abs(It(k))}));for(const k of C)k.isFilled=k.signedArea*w>0,n&&console.log("[simple] ring",k.idx,"signedArea=",k.signedArea.toExponential(),"isFilled=",k.isFilled);const b=C.filter(k=>k.isFilled).sort((k,Q)=>k.absArea-Q.absArea),D=C.filter(k=>!k.isFilled).sort((k,Q)=>Q.absArea-k.absArea);for(const k of b)k.holes=[];for(const k of D){const Q=(function(T){let U=0,V=0;if(!T||T.length===0)return[0,0];for(const W of T)W&&(U+=W[0]??0,V+=W[1]??0);return[U/T.length,V/T.length]})(k.ring);let R=null;for(const T of b)Ja(Q,T.ring)&&(R===null||T.absArea<R.absArea&&T.idx<k.idx||T.absArea>R.absArea&&T.idx<k.idx&&D.length==1)&&(R=T);if(R){if(R.absArea<k.absArea&&D.length>1)for(const T of b)Ja(Q,T.ring)&&T.absArea>k.absArea&&T.holes.push(k.ring);else R.holes.push(k.ring);k.assigned=!0}else k.assigned=!1,n&&console.log("[simple] hole not assigned idx=",k.idx)}for(const k of b){const Q=Is(k.ring.slice()),R=(k.holes||[]).map(T=>JA(T.slice()));y.push(Bs([Q,...R],i))}for(const k of D)k.assigned||y.push(Bs([Is(k.ring.slice())],i));if(b.length===0)for(const k of C)y.push(Bs([Is(k.ring.slice())],i))}return{type:"FeatureCollection",features:y}}class ey extends Ke{constructor(e,t){super(e,t),this.type="label",this._centerCoord=null,this._plotInstance=this,this.fontUrl="https://leiting.chenxisoft.com/resource/font/HanaMinA.ttf",this.labelText="点击编辑文本",this.fontSize=10,this.color="#ff0000",this.polygonEntities=[],t&&(this.fontSize=t.fontSize||this.fontSize,this.color=t.color||this.color,this.labelText=t.text||this.labelText)}start(e){this.startCreate(e)}startCreate(e){try{this.state="creating",this.forbidDrawWorld(!0);const t=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium,n=this;if(!t){console.error("无法获取Cesium对象");return}this.handler&&this.handler.destroy(),this.handler=new t.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.handler.setInputAction(function(s){if(!s||!s.position)return;let o=n.getCatesian3FromPX(s.position);o&&(n.positions=[o],n._centerCoord=o,n.createLabel(o,function(){n.endCreate(e)}))},t.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(s){if(!s||!s.position)return;n.getCatesian3FromPX(s.position)&&n.state},t.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(s){!s||!s.position||n.endCreate()},t.ScreenSpaceEventType.RIGHT_CLICK)}catch(t){console.error("启动创建标签功能时出错:",t),e&&e(null)}}createLabel(e,t){const n=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium,s=this;if(!e){console.error("创建标签时位置参数无效"),t&&t();return}if(!n){console.error("创建标签时无法获取Cesium对象"),t&&t();return}this.clearPolygonEntities(),XA(this.fontUrl,(o,r)=>{try{if(o){console.error("加载字体失败:",o),t&&t();return}const l=n.Cartographic.fromCartesian(e),a=n.Math.toDegrees(l.longitude),d=n.Math.toDegrees(l.latitude),h={type:"Feature",geometry:{type:"Point",coordinates:[a,d]},properties:{text:s.labelText||"",rotation:0}},p={sampleSegments:16,fontSize:s.fontSize,scale:10},f=ZA(h,r,p);if(!f||!f.features||!Array.isArray(f.features)){console.error("文本转换为多边形失败"),t&&t();return}s.drawGeoJsonLocal(f,[a,d],1,r),s.entity={_centerCoord:s._centerCoord,_plotInstance:s._plotInstance,position:e,label:{text:s.labelText},updatePosition:function(u){s.updatePositions([u])},getPosition:function(){return s._centerCoord},type:s.type,objId:s.objId,isDraggable:!0,setPosition:function(u){s._centerCoord=u,s.positions[0]=u,s.createLabel(u)}},s.addClickEditHandler(),t&&t()}catch(l){console.error("创建文本标签时发生错误:",l);try{s.clearPolygonEntities()}catch(a){console.error("清理标签多边形实体时出错:",a)}t&&t()}})}drawGeoJsonLocal(e,t,n=1,s){try{const o=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium;if(!e||!t||!Array.isArray(t)||t.length!==2){console.error("drawGeoJsonLocal: 参数无效");return}const r=t[0],l=t[1],a=o.Cartesian3.fromDegrees(r,l,0),d=o.Transforms.eastNorthUpToFixedFrame(a),h=n*1;this.clearPolygonEntities();let p=[];for(const S of e.features||[]){if(!S||!S.geometry||S.geometry.type!=="Polygon")continue;const M=S.geometry.coordinates||[];for(const O of M)O&&Array.isArray(O)&&(p=p.concat(O))}let f=1/0,u=1/0,m=-1/0,E=-1/0;for(const S of p)Array.isArray(S)&&S.length>=2&&(f=Math.min(f,S[0]),u=Math.min(u,S[1]),m=Math.max(m,S[0]),E=Math.max(E,S[1]));const A=(f+m)/2,y=(u+E)/2,v=S=>{const M=(S[0]-A)*h,O=(S[1]-y)*h,I=new o.Cartesian3(M,O,0);return o.Matrix4.multiplyByPoint(d,I,new o.Cartesian3)};for(const S of e.features||[]){if(!S||!S.geometry||S.geometry.type!=="Polygon")continue;const M=S.geometry.coordinates||[];if(M.length>0)try{const O=M[0]||[];if(O.length===0)continue;const I=O.map(v);let B;if(M.length>1){const P=M.slice(1).map(x=>!x||!Array.isArray(x)||x.length===0?null:new o.PolygonHierarchy(x.map(v))).filter(Boolean);B=new o.PolygonHierarchy(I,P)}else B=new o.PolygonHierarchy(I);const g=this.viewer.entities.add({polygon:{hierarchy:B,material:o.Color.fromCssColorString(this.color||"#000000"),outline:!1},_labelOwner:this.objId});this.polygonEntities.push(g)}catch(O){console.warn("创建多边形实体时出错:",O);continue}}}catch(o){console.error("drawGeoJsonLocal: 发生错误:",o)}}clearPolygonEntities(){for(let e of this.polygonEntities)this.viewer.entities.remove(e);this.polygonEntities=[]}addClickEditHandler(){const e=this,t=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium;if(!t){console.error("添加点击编辑事件时无法获取Cesium对象");return}this.editHandler&&(this.editHandler.destroy(),this.editHandler=null),this.editHandler=new t.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.editHandler.setInputAction(function(n){if(!n||!n.position)return;const s=e.viewer.scene.pick(n.position);t.defined(s)&&s.id&&s.id._labelOwner===e.objId&&(n.preventDefault(),e.editText())},t.ScreenSpaceEventType.LEFT_CLICK),this.editHandler.setInputAction(function(n){if(!n||!n.position)return;const s=e.viewer.scene.pick(n.position);t.defined(s)&&s.id&&s.id._labelOwner===e.objId&&(n.preventDefault(),e.openStyleEditor())},t.ScreenSpaceEventType.RIGHT_CLICK)}editText(){const e=this;(function(n,s){const o=document.createElement("div");o.style.position="fixed",o.style.top="0",o.style.left="0",o.style.width="100%",o.style.height="100%",o.style.backgroundColor="rgba(0, 0, 0, 0.5)",o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.zIndex="10000";const r=document.createElement("div");r.style.backgroundColor="white",r.style.padding="20px",r.style.borderRadius="5px",r.style.width="500px",r.style.maxWidth="90vw",r.style.boxShadow="0 4px 8px rgba(0, 0, 0, 0.2)";const l=document.createElement("h3");l.textContent="编辑文本",l.style.marginTop="0";const a=document.createElement("textarea");a.value=n,a.style.width="100%",a.style.height="150px",a.style.marginBottom="10px",a.style.fontSize="14px",a.style.padding="8px",a.style.boxSizing="border-box";const d=document.createElement("div");d.style.display="flex",d.style.justifyContent="flex-end",d.style.gap="10px";const h=document.createElement("button");h.textContent="取消",h.addEventListener("click",function(){document.body.removeChild(o),s(null)});const p=document.createElement("button");p.textContent="确认",p.addEventListener("click",function(){document.body.removeChild(o),s(a.value)}),d.appendChild(h),d.appendChild(p),r.appendChild(l),r.appendChild(a),r.appendChild(d),o.appendChild(r),document.body.appendChild(o),a.focus();const f=function(u){u.key==="Escape"&&(document.body.removeChild(o),document.removeEventListener("keydown",f),s(null))};document.addEventListener("keydown",f)})(this.labelText,function(n){n!==null&&(e.labelText=n||"点击编辑文本",e._centerCoord&&e.createLabel(e._centerCoord))})}endCreate(e){try{this.state="endCreate",this.handler&&(this.handler.destroy(),this.handler=null),this.forbidDrawWorld(!1),this.entity&&!this.entity.objId&&(this.entity.objId=this.objId),e&&e(this.entity)}catch(t){console.error("结束创建标签时出错:",t),e&&e(null)}}updatePositions(e){try{if(!e||!e.length){console.warn("更新标签位置时参数无效");return}if(!(window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium)){console.error("更新标签位置时无法获取Cesium对象");return}this.positions=e,this._centerCoord=e[0],this.entity&&(this.entity.position=e[0]),this.createLabel(e[0])}catch(t){console.error("更新标签位置时出错:",t)}}moveEntity(e){try{const t=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium;if(!t){console.error("移动实体时无法获取Cesium对象");return}if(!e||!this._centerCoord)return;const n=t.Cartesian3.add(this._centerCoord,e,new t.Cartesian3);this.updatePositions([n])}catch(t){console.error("移动实体时出错:",t)}}setStyle(e){e&&(e.color&&(this.color=e.color),e.fontSize&&(this.fontSize=e.fontSize),e.text!==void 0&&(this.labelText=e.text),this._centerCoord&&this.createLabel(this._centerCoord))}openStyleEditor(){const e=this;(function(n,s){const o=document.createElement("div");o.style.position="fixed",o.style.top="0",o.style.left="0",o.style.width="100%",o.style.height="100%",o.style.backgroundColor="rgba(0, 0, 0, 0.5)",o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.zIndex="10000";const r=document.createElement("div");r.style.backgroundColor="white",r.style.padding="20px",r.style.borderRadius="5px",r.style.width="400px",r.style.maxWidth="90vw",r.style.boxShadow="0 4px 8px rgba(0, 0, 0, 0.2)";const l=document.createElement("h3");l.textContent="编辑样式",l.style.marginTop="0";const a=document.createElement("div");a.style.marginBottom="15px";const d=document.createElement("label");d.textContent="文本颜色: ",d.style.display="block",d.style.marginBottom="5px";const h=document.createElement("input");h.type="color",h.value=n.color,h.style.width="50px",a.appendChild(d),a.appendChild(h);const p=document.createElement("div");p.style.marginBottom="15px";const f=document.createElement("label");f.textContent="字体大小: ",f.style.display="block",f.style.marginBottom="5px";const u=document.createElement("input");u.type="number",u.value=n.fontSize,u.min="8",u.max="200",u.step="1",u.style.width="100%",u.style.padding="5px",u.style.boxSizing="border-box",p.appendChild(f),p.appendChild(u);const m=document.createElement("div");m.style.display="flex",m.style.justifyContent="flex-end",m.style.gap="10px",m.style.marginTop="20px";const E=document.createElement("button");E.textContent="取消",E.addEventListener("click",function(){document.body.removeChild(o),s(null)});const A=document.createElement("button");A.textContent="确认",A.addEventListener("click",function(){document.body.removeChild(o),s({color:h.value,fontSize:parseInt(u.value)})}),m.appendChild(E),m.appendChild(A),r.appendChild(l),r.appendChild(a),r.appendChild(p),r.appendChild(m),o.appendChild(r),document.body.appendChild(o);const y=function(v){v.key==="Escape"&&(document.body.removeChild(o),document.removeEventListener("keydown",y),s(null))};document.addEventListener("keydown",y)})(this.getStyle(),function(n){n&&e.setStyle(n)})}getStyle(){return{color:this.color,fontSize:this.fontSize,text:this.labelText}}destroy(){try{try{this.clearPolygonEntities()}catch(e){console.warn("清理标签多边形实体时出错:",e)}if(this.handler){try{this.handler.destroy()}catch(e){console.warn("销毁事件处理器时出错:",e)}this.handler=null}if(this.editHandler){try{this.editHandler.destroy()}catch(e){console.warn("销毁编辑事件处理器时出错:",e)}this.editHandler=null}this._centerCoord=null,this._plotInstance=null,this.entity=null,this.positions=null,this.objId=null;try{super.destroy()}catch(e){console.warn("调用父类destroy方法时出错:",e)}}catch(e){console.error("销毁CreateLabel对象时发生错误:",e)}}syncFromEntity(){this.entity&&this.entity.position&&(this._centerCoord=this.entity.position,this._plotInstance=this)}getEntityPositions(){return this.positions}calculateCenter(){return this._centerCoord}}class ty extends Ke{constructor(e,t){super(e,t),this.type="point",this.viewer=e;let n={color:Cesium.Color.AQUA,pixelSize:10,outlineWidth:1};this.style=Object.assign(n,t||{}),this.position=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate";let t=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(n){let s=t.getCatesian3FromPX(n.position,t.viewer);s&&(t.entity=t.createPoint(s),t.position=s,t.handler&&(t.handler.destroy(),t.handler=null),t.prompt&&(t.prompt.destroy(),t.prompt=null),t.state="endCreate",e&&e(t.entity))},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){t.prompt.update(n.endPosition,"单击新增"),t.state="creating"},Cesium.ScreenSpaceEventType.MOUSE_MOVE)}endCreate(){let e=this;e.handler&&(e.handler.destroy(),e.handler=null),e.prompt&&(e.prompt.destroy(),e.prompt=null),e.state="endCreate"}done(){this.state=="startCreate"?this.destroy():this.state=="creating"?this.destroy():(this.state=="startEdit"||this.state=="editing")&&this.endEdit()}createByPositions(e,t){if(!e)return;this.state="startCreate";let n=e instanceof Cesium.Cartesian3?e:Cesium.Cartesian3.fromDegrees(e[0],e[1],e[2]);this.position=n,n&&(this.entity=this.createPoint(n),t&&t(this.entity),this.state="endCreate")}setStyle(e){if(e){if(e.color){let t=Cesium.Color.fromCssColorString(e.color||"#ffff00");t=t.withAlpha(e.colorAlpha),this.entity.point.color=t}if(this.entity.point.outlineWidth=Number(e.outlineWidth),e.outlineColor){let t=Cesium.Color.fromCssColorString(e.outlineColor||"#000000");t=t.withAlpha(e.outlineColorAlpha),this.entity.point.outlineColor=t}this.entity.point.heightReference=Number(e.heightReference),this.entity.point.pixelSize=Number(e.pixelSize),this.style=Object.assign(this.style,e)}}getStyle(){let e={},t=this.entity.point,n=t.color.getValue();e.colorAlpha=n.alpha,e.color=new Cesium.Color(n.red,n.green,n.blue,1).toCssHexString(),e.outlineWidth=t.outlineWidth._value;let s=t.outlineColor.getValue();return e.outlineColorAlpha=s.alpha,e.outlineColor=new Cesium.Color(s.red,s.green,s.blue,1).toCssHexString(),t.heightReference!=null&&(e.heightReference=t.heightReference.getValue()),e.pixelSize=Number(t.pixelSize),e}getPositions(e){return e?se.cartesianToLnglat(this.position):this.position}getLnglats(){return this.getPositions(!0)}startEdit(e){if(this.state=="startEdit"||this.state=="editing"||!this.entity)return;this.state="startEdit",this.modifyHandler||(this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));let t=this,n;this.modifyHandler.setInputAction(function(s){let o=t.viewer.scene.pick(s.position);Cesium.defined(o)&&o.id&&(n=o.id,t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(s){if(!n)return;let o=t.getCatesian3FromPX(s.endPosition,t.viewer);o&&(t.entity&&(t.entity.position.setValue(o),t.position=o,t.state="editing"),e&&e())},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(s){n&&(t.forbidDrawWorld(!1),t.modifyHandler&&(t.modifyHandler.destroy(),t.modifyHandler=null,t.state="editing"))},Cesium.ScreenSpaceEventType.LEFT_UP)}endEdit(e){this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null,e&&e(this.entity)),this.forbidDrawWorld(!1),this.state="endEdit"}createPoint(e){if(!e)return;let t=this.viewer.entities.add({position:e,point:{color:this.style.color instanceof Cesium.Color?this.style.color:this.style.color?Cesium.Color.fromCssColorString(this.style.color).withAlpha(this.style.colorAlpha||1):Cesium.Color.WHITE,outlineColor:this.style.outlineColor instanceof Cesium.Color?this.style.outlineColor:this.style.outlineColor?Cesium.Color.fromCssColorString(this.style.outlineColor).withAlpha(this.style.outlineColorAlpha||1):Cesium.Color.BLACK,outlineWidth:this.style.outlineWidth||4,pixelSize:this.style.pixelSize||20,disableDepthTestDistance:Number.MAX_VALUE}});return t.objId=this.objId,t}}class iy extends Ke{constructor(e,t){super(e,t),this.type="polygon",this.viewer=e,this.entity=null,this.polyline=null;let n={outlineColor:"#000000",outlineWidth:2};this.style=Object.assign(n,t||{}),this.outline=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate";let t=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(n){let s=t.getCatesian3FromPX(n.position,t.viewer,[]);if(!s||(t.movePush&&(t.positions.pop(),t.movePush=!1),t.positions.some(l=>Math.abs(l.x-s.x)<1e-6&&Math.abs(l.y-s.y)<1e-6&&Math.abs(l.z-s.z)<1e-6)))return;t.positions.push(s);let r=t.createPoint(s);r.wz=t.positions.length-1,t.controlPoints.push(r)},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){if(t.positions.length<1){t.prompt.update(n.endPosition,"单击开始绘制"),t.state="startCreate";return}t.prompt&&t.prompt.update(n.endPosition,"双击结束,右键取消上一步");let s=t.getCatesian3FromPX(n.endPosition,t.viewer,[]);t.positions.length>=1&&(t.state="creating",t.movePush?t.positions[t.positions.length-1]=s:(t.positions.push(s),t.movePush=!0),t.positions.length==2&&(Cesium.defined(t.polyline)||(t.polyline=t.createPolyline())),t.positions.length==3&&(Cesium.defined(t.entity)||(t.entity=t.createPolygon(t.style),!t.style.outline&&t.polyline&&(t.polyline.show=!1),t.entity.objId=t.objId)))},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(n){t.entity&&(t.positions.splice(t.positions.length-2,1),t.viewer.entities.remove(t.controlPoints.pop()),t.positions.length==2&&t.entity&&(t.viewer.entities.remove(t.entity),t.entity=null,t.polyline&&(t.polyline.show=!0)),t.positions.length==1&&(t.polyline&&(t.viewer.entities.remove(t.polyline),t.polyline=null),t.prompt&&t.prompt.update(n.endPosition,"单击开始绘制"),t.positions=[],t.movePush=!1))},Cesium.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(function(n){t.entity&&(t.endCreate(),e&&e(t.entity))},Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}endCreate(){let e=this;e.state="endCreate",e.handler&&(e.handler.destroy(),e.handler=null),e.movePush=!1,e.prompt&&(e.prompt.destroy(),e.prompt=null),e.viewer.trackedEntity=void 0,e.viewer.scene.camera.lookAtTransform(Cesium.Matrix4.IDENTITY)}done(){this.state=="startCreate"?this.destroy():this.state=="creating"?this.positions.length<=2&&this.movePush==!0?this.destroy():this.endCreate():(this.state=="startEdit"||this.state=="editing")&&this.endEdit()}createByPositions(e,t){if(!e)return;this.state="startCreate";let n=e[0]instanceof Cesium.Cartesian3?e:se.lnglatsToCartesians(e);if(n){this.entity=this.createPolygon(),this.polyline=this.createPolyline(),this.polyline.show=this.style.outline,this.positions=n;for(let s=0;s<n.length;s++){let o=n[s],r=Cesium.Cartographic.fromCartesian(n[s]),l=this.createPoint(o);l.point.heightReference=this.style.heightReference,l.ctgc=r,l.wz=this.controlPoints.length,this.controlPoints.push(l)}this.state="endCreate",this.entity.objId=this.objId,t&&t(this.entity)}}getStyle(){if(!this.entity)return;let e={},t=this.entity.polygon;if(t.material instanceof Cesium.ColorMaterialProperty){e.material="common";let s=t.material.color.getValue();e.colorAlpha=s.alpha,e.color=new Cesium.Color(s.red,s.green,s.blue,1).toCssHexString()}if(e.fill=t.fill?t.fill.getValue():!1,t.heightReference){let s=t.heightReference.getValue();e.heightReference=Number(s)}let n=this.polyline.polyline;if(n&&this.polyline.show){e.outlineWidth=n.width.getValue(),e.outline=!0;let s=n.material.color.getValue();e.outlineColorAlpha=s.alpha,e.outlineColor=new Cesium.Color(s.red,s.green,s.blue,1).toCssHexString()}else e.outline=!1;return e}setStyle(e){if(!e)return;this.polyline.show=e.outline;let t=this.polyline.polyline;t.width=e.outlineWidth,this.polyline.clampToGround=!!e.heightReference;let s=(e.outlineColor instanceof Cesium.Color?e.outlineColor:Cesium.Color.fromCssColorString(e.outlineColor)).withAlpha(e.outlineColorAlpha||1);t.material=s,e.heightReference!=null&&(this.entity.polygon.heightReference=Number(e.heightReference));let r=(e.color instanceof Cesium.Color?e.color:Cesium.Color.fromCssColorString(e.color)).withAlpha(e.colorAlpha||1);this.entity.polygon.material=r,e.fill!=null&&(this.entity.polygon.fill=e.fill),this.style=Object.assign(this.style,e)}createPolygon(){let e=this;this.style.color=this.style.color||Cesium.Color.WHITE,this.style.outlineColor=this.style.outlineColor||Cesium.Color.BLACK;let t={polygon:{hierarchy:new Cesium.CallbackProperty(function(){return new Cesium.PolygonHierarchy(e.positions)},!1),heightReference:Number(this.style.heightReference),show:!0,fill:this.style.fill==null?!0:this.style.fill,material:this.style.color instanceof Cesium.Color?this.style.color:Cesium.Color.fromCssColorString(this.style.color).withAlpha(this.style.colorAlpha||1)}};return this.style.heightReference||(t.polygon.height=0,t.polygon.perPositionHeight=!0),this.viewer.entities.add(t)}createPolyline(){let e=this;return this.viewer.entities.add({polyline:{positions:new Cesium.CallbackProperty(function(){return e.positions.concat(e.positions[0])},!1),clampToGround:!!this.style.heightReference,material:this.style.outlineColor instanceof Cesium.Color?this.style.outlineColor:Cesium.Color.fromCssColorString(this.style.outlineColor).withAlpha(this.style.outlineColorAlpha||1),width:this.style.outlineWidth||1}})}destroy(){this.handler&&(this.handler.destroy(),this.handler=null),this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.polyline&&(this.viewer.entities.remove(this.polyline),this.polyline=null),this.positions=[],this.style=null,this.modifyPoint&&(this.viewer.entities.remove(this.modifyPoint),this.modifyPoint=null);for(let e=0;e<this.controlPoints.length;e++){let t=this.controlPoints[e];this.viewer.entities.remove(t)}this.controlPoints=[],this.state="no",this.prompt&&this.prompt.destroy(),this.polyline&&(this.polyline=null,this.viewer.entities.remove(this.polyline)),this.forbidDrawWorld(!1)}}class ny extends Ke{constructor(e,t){super(e,t),this.type="rectangle",this.viewer=e,this.style=t||{},this.leftup=null,this.rightdown=null,this.leftdownPoint=null,this.rightupPoint=null,this.entity=null,this.handler=null,this.modifyHandler=null,this.modifyPoint=null,this._dragStartCart=null,this._dragStartCartCarto=null}start(e){!this.prompt&&this.promptStyle?.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate",this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));const t=this;this.handler.setInputAction(function(n){const s=t.getCatesian3FromPX(n.position,t.viewer,[]);if(s)if(t.entity)t.endCreate(),e&&e(t.entity);else{t.leftup=s.clone(),t.rightdown=s.clone(),t.entity=t._createPolyline();const o=t._calcCornerCartesian("leftdown"),r=t._calcCornerCartesian("rightup");t.leftdownPoint=t.createPoint(o),t.leftdownPoint.typeAttr="leftdown",t.leftdownPoint.show=!1,t.rightupPoint=t.createPoint(r),t.rightupPoint.typeAttr="rightup",t.rightupPoint.show=!1}},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){if(!t.entity){t.prompt?.update(n.endPosition,"单击开始绘制");return}t.prompt?.update(n.endPosition,"单击结束");const s=t.getCatesian3FromPX(n.endPosition,t.viewer,[]);s&&(t.rightdown=s.clone(),t._updatePolyline(),t._updateAuxPoints(),t.state="creating")},Cesium.ScreenSpaceEventType.MOUSE_MOVE)}endCreate(){this.handler?.destroy(),this.handler=null,this.leftdownPoint&&(this.leftdownPoint.show=!1),this.rightupPoint&&(this.rightupPoint.show=!1),this.prompt?.destroy(),this.prompt=null,this.state="endCreate"}startEdit(e){if(!this.entity)return;this.state="startEdit",this.modifyHandler||(this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));const t=this;this.leftdownPoint&&(this.leftdownPoint.show=!0),this.rightupPoint&&(this.rightupPoint.show=!0),this.modifyHandler.setInputAction(function(n){const s=t.viewer.scene.pick(n.position);if(!s?.id)return;t.modifyPoint=s.id;const o=t.getCatesian3FromPX(n.position,t.viewer,[t.entity,t.modifyPoint]);o&&(t._dragStartCart=o,t._dragStartCartCarto=Cesium.Ellipsoid.WGS84.cartesianToCartographic(o),t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(n){if(!t.modifyPoint)return;const s=t.getCatesian3FromPX(n.endPosition,t.viewer,[t.entity,t.modifyPoint]);s&&(t.modifyPoint.typeAttr==="leftdown"?t._dragCorner(s,"leftdown"):t.modifyPoint.typeAttr==="rightup"&&t._dragCorner(s,"rightup"),t._updatePolyline(),t._updateAuxPoints(),e&&e(),t.state="editing")},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(){t.modifyPoint=null,t._dragStartCart=null,t._dragStartCartCarto=null,t.forbidDrawWorld(!1),t._updatePolyline(),e&&e(t.entity),t.state="editing"},Cesium.ScreenSpaceEventType.LEFT_UP)}endEdit(e){this.leftdownPoint&&(this.leftdownPoint.show=!1),this.rightupPoint&&(this.rightupPoint.show=!1),this.modifyHandler?.destroy(),this.modifyHandler=null,this.forbidDrawWorld(!1),this.state="endEdit",e&&e(this.entity)}_createPolyline(){const e=this,t=this.viewer.entities.add({polyline:{positions:new Cesium.CallbackProperty(()=>e._buildRectPositions(),!1),width:this.style.outlineWidth||this.style.width||5,material:this.style.color instanceof Cesium.Color?this.style.color:Cesium.Color.fromCssColorString(this.style.color||"#00FF00"),clampToGround:!1}});return t._plotInstance=this,t.objId=this.objId,t}_updatePolyline(){if(!this.entity)return;const e=this._buildRectPositions();try{const t=this.entity.polyline.positions;if(t&&typeof t.getValue=="function")return;if(t&&typeof t.setValue=="function"){t.setValue(e);return}this.entity.polyline.positions=e}catch{this.entity.polyline.positions=e}}_buildRectPositions(){if(!this.leftup||!this.rightdown)return[];const e=this._calcCornerCartesian("leftdown"),t=this.leftup,n=this._calcCornerCartesian("rightup"),s=this.rightdown;return[e,s,n,t,e]}_calcCornerCartesian(e){const t=Cesium.Ellipsoid.WGS84,n=t.cartesianToCartographic(this.leftup),s=t.cartesianToCartographic(this.rightdown),o=Math.min(n.longitude,s.longitude),r=Math.max(n.longitude,s.longitude),l=Math.min(n.latitude,s.latitude),a=Math.max(n.latitude,s.latitude);if(e==="leftdown")return Cesium.Cartesian3.fromRadians(o,l);if(e==="rightup")return Cesium.Cartesian3.fromRadians(r,a)}_updateAuxPoints(){if(!this.leftup||!this.rightdown)return;const e=this._calcCornerCartesian("leftdown"),t=this._calcCornerCartesian("rightup");this.leftdownPoint&&(this.leftdownPoint.position=e),this.rightupPoint&&(this.rightupPoint.position=t)}_dragCorner(e,t){const n=Cesium.Ellipsoid.WGS84,s=n.cartesianToCartographic(this.leftup),o=n.cartesianToCartographic(this.rightdown);let r=Math.min(s.longitude,o.longitude),l=Math.max(s.longitude,o.longitude),a=Math.min(s.latitude,o.latitude),d=Math.max(s.latitude,o.latitude);const h=n.cartesianToCartographic(e);t==="leftdown"?(r=h.longitude,a=h.latitude):(l=h.longitude,d=h.latitude),this.leftup=Cesium.Cartesian3.fromRadians(r,d),this.rightdown=Cesium.Cartesian3.fromRadians(l,a)}syncFromEntity(){if(!this.entity||!this.leftup||!this.rightdown)return;const e=Cesium.Cartesian3.midpoint(this.leftup,this.rightdown,new Cesium.Cartesian3),t=this.entity._centerCoord;if(!t)return;const n=t.x-e.x,s=t.y-e.y,o=t.z-e.z;this.leftup=new Cesium.Cartesian3(this.leftup.x+n,this.leftup.y+s,this.leftup.z+o),this.rightdown=new Cesium.Cartesian3(this.rightdown.x+n,this.rightdown.y+s,this.rightdown.z+o);const r=this.entity.objId,l=this.entity._plotInstance;this.leftdownPoint&&this.viewer.entities.remove(this.leftdownPoint),this.rightupPoint&&this.viewer.entities.remove(this.rightupPoint),this.leftdownPoint=this.rightupPoint=null,this.viewer.entities.remove(this.entity),this.entity=this._createPolyline(),this.entity._plotInstance=l,this.entity.objId=r;const a=this._calcCornerCartesian("leftdown"),d=this._calcCornerCartesian("rightup");this.leftdownPoint=this.createPoint(a),this.leftdownPoint.typeAttr="leftdown",this.leftdownPoint.show=this.state==="editing",this.rightupPoint=this.createPoint(d),this.rightupPoint.typeAttr="rightup",this.rightupPoint.show=this.state==="editing"}updatePositions(e){if(!e||e.length<1)return!1;try{if(!this.leftup||!this.rightdown)return!1;let t;if(e[0]instanceof Cesium.Cartesian3)t=e[0];else return!1;this.leftup=Cesium.Cartesian3.add(this.leftup,t,new Cesium.Cartesian3),this.rightdown=Cesium.Cartesian3.add(this.rightdown,t,new Cesium.Cartesian3),this._updatePolyline(),this._updateAuxPoints();try{this.viewer.scene.requestRender()}catch{}return!0}catch(t){return console.warn("Failed to update rectangle positions:",t),!1}}getPositions(e){return e?se.cartesiansToLnglats([this.leftup,this.rightdown],this.viewer):[this.leftup,this.rightdown]}getStyle(){const e=this.entity.polyline,t=e.material.color.getValue();return{color:new Cesium.Color(t.red,t.green,t.blue,1).toCssHexString(),colorAlpha:t.alpha,outlineWidth:e.width.getValue()}}setStyle(e){if(!this.entity)return;const t={...this.style,...e};let n=t.color instanceof Cesium.Color?t.color:Cesium.Color.fromCssColorString(t.color||"#00FF00");t.colorAlpha!=null&&(n=n.withAlpha(t.colorAlpha)),this.entity.polyline.material=n,this.entity.polyline.width=t.outlineWidth||t.width||5,this.style=t}destroy(){try{this.handler?.destroy(),this.modifyHandler?.destroy(),this.entity&&this.viewer.entities.remove(this.entity),this.entity=null,this.leftdownPoint&&this.viewer.entities.remove(this.leftdownPoint),this.rightupPoint&&this.viewer.entities.remove(this.rightupPoint),this.leftdownPoint=this.rightupPoint=null,this.prompt?.destroy(),this.prompt=null}catch{}}createByPositions(e,t){if(!e||e.length<2)return!1;const n=e[0]instanceof Cesium.Cartesian3?e:se.lnglatsToCartesians(e);if(!n||n.length<2)return!1;if(n.length===2)this.leftup=Cesium.Cartesian3.clone(n[0]),this.rightdown=Cesium.Cartesian3.clone(n[1]);else if(n.length>=4){let s=1/0,o=1/0,r=-1/0,l=-1/0;n.forEach(a=>{const d=Cesium.Ellipsoid.WGS84.cartesianToCartographic(a);d&&(s=Math.min(s,d.longitude),o=Math.min(o,d.latitude),r=Math.max(r,d.longitude),l=Math.max(l,d.latitude))}),this.leftup=Cesium.Cartesian3.fromRadians(s,l),this.rightdown=Cesium.Cartesian3.fromRadians(r,o)}if(this.entity?this._updatePolyline():this.entity=this._createPolyline(),!this.leftdownPoint){const s=this._calcCornerCartesian("leftdown");this.leftdownPoint=this.createPoint(s),this.leftdownPoint.typeAttr="leftdown",this.leftdownPoint.show=!1}if(!this.rightupPoint){const s=this._calcCornerCartesian("rightup");this.rightupPoint=this.createPoint(s),this.rightupPoint.typeAttr="rightup",this.rightupPoint.show=!1}this._updateAuxPoints(),this.state="endCreate";try{this.viewer.scene.requestRender()}catch(s){console.error("requestRender error:",s)}return t&&t(this.entity),!0}}class sy extends Ke{constructor(e,t){super(e,t),t=t||{},this.movePush=!1,this.type="polyline",this.maxPointNum=t.maxPointNum||Number.MAX_VALUE}updatePositions(e){if(!e||e.length<1)return!1;let t=e[0]instanceof Cesium.Cartesian3?e:util.lnglatsToCartesians(e);return t?(this.positions=t,this.updateControlPoints(),!0):!1}updateControlPoints(){for(let e=0;e<this.controlPoints.length;e++)this.viewer.entities.remove(this.controlPoints[e]);this.controlPoints=[];for(let e=0;e<this.positions.length;e++){let t=this.positions[e],n=this.createPoint(t);this.style.clampToGround&&(n.point.heightReference=1),n.wz=this.controlPoints.length,this.controlPoints.push(n)}}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate";let t=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(n){let s=t.getCatesian3FromPX(n.position,t.viewer,[t.entity]);if(!s)return;t.movePush&&(t.positions.pop(),t.movePush=!1),t.positions.push(s);let o=t.createPoint(s);o.wz=t.positions.length-1,t.controlPoints.push(o),t.positions.length==t.maxPointNum&&(t.endCreate(),e&&e(t.entity))},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){if(t.state="creating",t.positions.length<1){t.prompt.update(n.endPosition,"单击开始绘制"),t.state="startCreate";return}t.prompt.update(n.endPosition,"右键取消上一步,双击结束");let s=t.getCatesian3FromPX(n.endPosition,t.viewer,[t.entity]);s&&(t.movePush?t.positions[t.positions.length-1]=s:(t.positions.push(s),t.movePush=!0),t.positions.length==2&&(Cesium.defined(t.entity)||(t.entity=t.createPolyline())))},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(n){t.entity&&(t.positions.splice(t.positions.length-2,1),t.viewer.entities.remove(t.controlPoints.pop()),t.positions.length==1&&(t.entity&&(t.viewer.entities.remove(t.entity),t.entity=null),t.prompt.update(n.endPosition,"单击开始绘制"),t.movePush=!1,t.positions=[]))},Cesium.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(function(n){t.entity&&(t.endCreate(),e&&e(t.entity))},Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}endCreate(){let e=this;e.state="endCreate",e.handler&&(e.handler.destroy(),e.handler=null),e.positions.pop(),e.viewer.entities.remove(e.controlPoints.pop()),e.prompt&&(e.prompt.destroy(),e.prompt=null),e.viewer.trackedEntity=void 0,e.viewer.scene.camera.lookAtTransform(Cesium.Matrix4.IDENTITY)}done(){this.state=="startCreate"?this.destroy():this.state=="creating"?this.positions.length<=2&&this.movePush==!0?this.destroy():this.endCreate():(this.state=="startEdit"||this.state=="editing")&&this.endEdit()}createByPositions(e,t){if(!e||e.length<1)return;this.state="startCreate";let n=e[0]instanceof Cesium.Cartesian3?e:util.lnglatsToCartesians(e);if(n){this.entity=this.createPolyline(this.style),this.positions=n,t&&t(this.entity);for(let s=0;s<n.length;s++){let o=n[s],r=this.createPoint(o);this.style.clampToGround&&(r.point.heightReference=1),r.wz=this.controlPoints.length,this.controlPoints.push(r)}this.state="endCreate"}}setStyle(e){if(!e)return;let t=this.getMaterial(e.material,e);this.entity.polyline.material=t,this.entity.polyline.clampToGround=!!e.clampToGround,e.width&&(this.entity.polyline.width=e.width||3),this.style=Object.assign(this.style,e)}getStyle(){if(!this.entity)return;let e={},t=this.entity.polyline;this.style.animateType!=null&&(e.animateType=this.style.animateType,e.image=this.style.image,e.duration=this.style.duration),t.material instanceof Cesium.ColorMaterialProperty?e.material="common":(e.material="flowline",t.material instanceof animate.FlowLineMaterial,e.duration=t.material._duration,e.image=t.material.url);let n=t.material.color.getValue();e.colorAlpha=n.alpha,e.color=new Cesium.Color(n.red,n.green,n.blue,1).toCssHexString(),e.width=t.width._value;let s=t.clampToGround?t.clampToGround.getValue():!1;return e.clampToGround=!!s,e}createPolyline(){let e=this,t=this.viewer.entities.add({polyline:{positions:new Cesium.CallbackProperty(function(){return e.positions},!1),show:!0,material:this.getMaterial(this.style.animateType,this.style),width:this.style.width||3,clampToGround:this.style.clampToGround}});return t.objId=this.objId,t}getMaterial(e,t){t=t||{};let n=null,s=t.color||Cesium.Color.WHITE;return s=s instanceof Cesium.Color?s:Cesium.Color.fromCssColorString(t.color),s=s.withAlpha(t.colorAlpha||1),e=="flowline"||e=="flyline"||(n=s),n}updatePositions(e){if(!e||e.length<1)return!1;let t=e[0]instanceof Cesium.Cartesian3?e:util.lnglatsToCartesians(e);return t?(this.positions=t,this.updateControlPoints(),!0):!1}updateControlPoints(){for(let e=0;e<this.controlPoints.length;e++)this.viewer.entities.remove(this.controlPoints[e]);this.controlPoints=[];for(let e=0;e<this.positions.length;e++){let t=this.positions[e],n=this.createPoint(t);this.style.clampToGround&&(n.point.heightReference=1),n.wz=this.controlPoints.length,this.controlPoints.push(n)}}getPositions(e){return e?util.cartesiansToLnglats(this.positions,this.viewer):this.positions}}class oy extends Ke{constructor(e,t={}){super(e,t),this.type="freehandLine",this.maxPositions=t.maxPositions||1e4,this.minDistance=t.minDistance||2,this.renderInterval=t.renderInterval||30,this.style=Object.assign({smoothness:2,angleThreshold:3,curveResolution:3},t||{}),this.positions=[],this._stagingBuffer=[],this._flushScheduled=!1,this._flushRAF=null,this._lastFlushTime=0,this.isDrawing=!1,this.handler=null,this.startPointEntity=null,this.entity=null,this.lastAddPosition=null}start(e){if(this.state==="creating"||this.state==="startCreate")return;if(this.state="startCreate",this.positions=[],this._stagingBuffer.length=0,this._lastFlushTime=0,this.isDrawing=!1,this.lastAddPosition=null,this._cancelFlush(),!this.prompt&&this.promptStyle&&this.promptStyle.show&&Promise.resolve().then(()=>Rr).then(({default:n})=>{this.prompt=new n(this.viewer,this.promptStyle)}),this.handler){try{this.handler.destroy()}catch{}this.handler=null}if(this.entity){try{this.viewer.entities.remove(this.entity)}catch{}this.entity=null}if(this.startPointEntity){try{this.viewer.entities.remove(this.startPointEntity)}catch{}this.startPointEntity=null}this.entity=this.createFreehandLine();const t=this;this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.handler.setInputAction(function(n){t.state="creating",t.isDrawing=!0,t.forbidDrawWorld(!0),t.positions=[],t._stagingBuffer.length=0,t.lastAddPosition=null;let s=t._fastPick(n.position);if(!s){t.isDrawing=!1;return}const o=Cesium.Cartesian3.clone(s);if(t._pushToStaging(o),t.lastAddPosition=o,t.startPointEntity){try{t.viewer.entities.remove(t.startPointEntity)}catch{}t.startPointEntity=null}t.startPointEntity=t.viewer.entities.add({position:o,point:{pixelSize:6,color:Cesium.Color.RED,outlineColor:Cesium.Color.WHITE,outlineWidth:1}}),t._scheduleFlush(!0)},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.handler.setInputAction(function(n){if(!t.isDrawing){t.prompt&&n&&n.endPosition&&t.prompt.update(n.endPosition,"单击开始绘制");return}if(t.prompt&&n&&n.endPosition&&t.prompt.update(n.endPosition,"松键结束"),!n||!n.endPosition||t.positions.length+t._stagingBuffer.length>=t.maxPositions)return;let s=t._fastPick(n.endPosition);if(!s||t.lastAddPosition&&Cesium.Cartesian3.distance(t.lastAddPosition,s)<=t.minDistance)return;const o=Cesium.Cartesian3.clone(s);t._pushToStaging(o),t.lastAddPosition=o,t._scheduleFlush()},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(n){if(t.isDrawing){if(t.prompt&&t.prompt.update(null,"单击结束绘制"),t.isDrawing=!1,t.forbidDrawWorld(!1),t.startPointEntity){try{t.viewer.entities.remove(t.startPointEntity)}catch{}t.startPointEntity=null}t._scheduleFlush(!0),t.endCreate(e)}},Cesium.ScreenSpaceEventType.LEFT_UP),this.handler.setInputAction(function(n){if(t.isDrawing){if(t.prompt&&t.prompt.update(null,"单击结束绘制"),t.isDrawing=!1,t.forbidDrawWorld(!1),t.startPointEntity){try{t.viewer.entities.remove(t.startPointEntity)}catch{}t.startPointEntity=null}t._scheduleFlush(!0),t.endCreate(e)}},Cesium.ScreenSpaceEventType.RIGHT_DOWN)}_pushToStaging(e){this._stagingBuffer.push(e)}_scheduleFlush(e=!1){if(this._flushRAF){e&&(this._forceImmediate=!0);return}this._forceImmediate=e||!1;const t=this,n=function(){t._flushRAF=null;const s=performance.now();(t._forceImmediate||s-t._lastFlushTime>=t.renderInterval)&&(t._flushToPositions(),t._lastFlushTime=s),t._forceImmediate=!1};this._flushRAF=requestAnimationFrame(n)}_cancelFlush(){if(this._flushRAF){try{cancelAnimationFrame(this._flushRAF)}catch{}this._flushRAF=null}this._forceImmediate=!1}_fastPick(e){if(this.viewer.scene.mode===Cesium.SceneMode.SCENE2D){const n=this.viewer.camera.getPickRay(e);let s=null;return n&&(s=this.viewer.scene.globe.pick(n,this.viewer.scene)),s||(s=this.viewer.camera.pickEllipsoid(e,this.viewer.scene.globe.ellipsoid)),s}let t=null;try{t=this.viewer.scene.pickPosition(e)}catch{}if(!t){const n=this.viewer.camera.getPickRay(e);n&&(t=this.viewer.scene.globe.pick(n,this.viewer.scene))}return t}_flushToPositions(){if(!this._stagingBuffer||this._stagingBuffer.length===0)return;const e=this._stagingBuffer;this._stagingBuffer=[];const t=Math.max(0,Math.min(2,Number(this.style.smoothness||1)));let n=e;if(t>0){const l=(h,p)=>{if(!h||h.length<2)return h;p=Math.max(1,p|0);const f=[h[0]],u=h.length;for(let m=0;m<u-1;m++){const E=m>0?h[m-1]:h[m],A=h[m],y=h[m+1],v=m+2<u?h[m+2]:h[m+1];for(let S=1;S<p;S++){const M=S/p,O=M*M,I=O*M,B=-.5*E.x+1.5*A.x-1.5*y.x+.5*v.x,g=-.5*E.y+1.5*A.y-1.5*y.y+.5*v.y,P=-.5*E.z+1.5*A.z-1.5*y.z+.5*v.z,x=E.x-2.5*A.x+2*y.x-.5*v.x,F=E.y-2.5*A.y+2*y.y-.5*v.y,_=E.z-2.5*A.z+2*y.z-.5*v.z,H=-.5*E.x+.5*y.x,N=-.5*E.y+.5*y.y,w=-.5*E.z+.5*y.z,C=A.x,b=A.y,D=A.z,k=B*I+x*O+H*M+C,Q=g*I+F*O+N*M+b,R=P*I+_*O+w*M+D;f.push(new Cesium.Cartesian3(k,Q,R))}f.push(y)}return f},a=Math.max(1,Number(this.style.curveResolution)||1);n.length<200&&a>1&&(n=l(n,a));const d=h=>{if(!h||h.length<2)return h;const p=[];p.push(h[0]);for(let f=0;f<h.length-1;f++){const u=h[f],m=h[f+1],E=new Cesium.Cartesian3(u.x*.75+m.x*.25,u.y*.75+m.y*.25,u.z*.75+m.z*.25),A=new Cesium.Cartesian3(u.x*.25+m.x*.75,u.y*.25+m.y*.75,u.z*.25+m.z*.75);p.push(E),p.push(A)}return p.push(h[h.length-1]),p};n=n.slice(),n.length<300&&(n=d(n),t===2&&n.length<300&&(n=d(n)))}const s=(Number(this.style.angleThreshold)||6)*(Math.PI/180),o=this.positions,r=(l,a,d,h)=>{if(!l||!a||!d)return!1;const p=a.x-l.x,f=a.y-l.y,u=a.z-l.z,m=d.x-a.x,E=d.y-a.y,A=d.z-a.z,y=Math.hypot(p,f,u),v=Math.hypot(m,E,A);if(y===0||v===0)return!1;const S=(p*m+f*E+u*A)/(y*v),M=Math.max(-1,Math.min(1,S)),O=Math.acos(M);return Math.abs(O)<=h};for(let l=0;l<n.length;l++){const a=n[l];if(o.length===0){o.push(Cesium.Cartesian3.clone(a));continue}const d=o[o.length-1];if(!(Cesium.Cartesian3.distance(d,a)<=this.minDistance*.5)){if(o.length>=2){const p=o[o.length-2],f=o[o.length-1],u=a;if(r(p,f,u,s)){o.pop(),o.push(Cesium.Cartesian3.clone(u));continue}}if(o.push(Cesium.Cartesian3.clone(a)),o.length>this.maxPositions){const p=o.length-this.maxPositions;p>0&&o.splice(0,p)}}}try{this.viewer.scene.requestRender()}catch{}}endCreate(e){if(this.state==="endCreate")return;if(this.state="endCreate",this.handler){try{this.handler.destroy()}catch{}this.handler=null}if(this.prompt){try{this.prompt.destroy()}catch{}this.prompt=null}if(this._flushToPositions(),this._cancelFlush(),!this.positions||this.positions.length<2){if(this.entity){try{this.viewer.entities.remove(this.entity)}catch{}this.entity=null}e&&e(null);return}const t=this.positions.map(n=>Cesium.Cartesian3.clone(n));this.positions=t;try{this.viewer.scene.requestRender()}catch{}e&&e(this.entity)}done(e){this.isDrawing&&(this.isDrawing=!1,this.forbidDrawWorld(!1),this.endCreate(e))}createFreehandLine(){const e=this,t=this.getMaterial(this.style.animateType,this.style),n=this.viewer.entities.add({polyline:{positions:new Cesium.CallbackProperty(function(){return e.positions||[]},!1),show:!0,material:t,width:this.style.width||3,clampToGround:!!this.style.clampToGround||!1}});return n.objId=this.objId||null,this.entity=n,n}getMaterial(e,t){t=t||{};try{let n=t.color||Cesium.Color.RED;typeof n=="string"&&(n=Cesium.Color.fromCssColorString(n));const s=t.colorAlpha!==void 0?t.colorAlpha:1;return n=n.withAlpha(s),n}catch{return Cesium.Color.RED}}updatePositions(e){if(!e||e.length<1)return!1;try{let t=[];if(e[0]instanceof Cesium.Cartesian3?t=e.map(n=>Cesium.Cartesian3.clone(n)):t=se&&se.lnglatsToCartesians?se.lnglatsToCartesians(e):e,!t||t.length===0)return!1;this.positions=t.map(n=>Cesium.Cartesian3.clone(n)),this._stagingBuffer.length=0;try{this.viewer.scene.requestRender()}catch{}return!0}catch{return!1}}setStyle(e){if(!e||(this.style=Object.assign(this.style||{},e),!this.entity||!this.entity.polyline))return;const t=this.getMaterial(this.style.animateType,this.style);try{this.entity.polyline.material=t}catch{}if(e.width!==void 0)try{this.entity.polyline.width=e.width}catch{}if(e.clampToGround!==void 0)try{this.entity.polyline.clampToGround=!!e.clampToGround}catch{}}createByPositions(e,t){if(!e||e.length<1)return!1;const n=e[0]instanceof Cesium.Cartesian3?e:se.lnglatsToCartesians(e);if(!n||n.length<1)return!1;this.positions=n.map(s=>Cesium.Cartesian3.clone(s)),this.entity||this.createFreehandLine(),this.state="endCreate";try{this.viewer.scene.requestRender()}catch{}return t&&t(this.entity),!0}destroy(){if(this._cancelFlush(),this.handler){try{this.handler.destroy()}catch{}this.handler=null}if(this.entity){try{this.viewer.entities.remove(this.entity)}catch{}this.entity=null}if(this.startPointEntity){try{this.viewer.entities.remove(this.startPointEntity)}catch{}this.startPointEntity=null}this.positions=[],this._stagingBuffer=[],this.isDrawing=!1;try{this.endCreate()}catch{}}}class ry extends Ke{constructor(e,t={}){if(!e)throw new Error("CreateArrow requires viewer");if(super(e,t),this.type="arrow",this.style=t||{},this.arrowAngle=t.arrowAngle||Math.PI/6,this.positions=[],this.lineEntity=null,this.arrowEntity=null,this.controlPoints=[],this.handler=null,this._finalized=!1,this._editRenderHandler=null,this.Cesium=this._getCesium(),!this.Cesium)throw new Error("Cesium not found")}_getCesium(){return typeof window<"u"&&window.Cesium?window.Cesium:typeof Cesium<"u"?Cesium:this.viewer&&this.viewer.constructor&&this.viewer.constructor.Cesium?this.viewer.constructor.Cesium:null}start(e){if(!this.viewer||!this.Cesium)return e&&e(null),this;if(this.state==="creating"||this.state==="startCreate")return this;this.state="startCreate",this._cleanup(!1),!this.prompt&&this.promptStyle&&this.promptStyle.show&&Promise.resolve().then(()=>Rr).then(({default:n})=>{this.prompt=new n(this.viewer,this.promptStyle)}).catch(()=>{});try{this.forbidDrawWorld(!0)}catch{}const t=this;return this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.handler.setInputAction(function(n){if(t.state==="startCreate"){t.state="creating",t._finalized=!1;let s=t.getCatesian3FromPX(n.position);if(!s)return;t.positions=[t.Cesium.Cartesian3.clone(s),t.Cesium.Cartesian3.clone(s)],t._createLineEntity(),t._createArrowEntity(),t._createControlPoints(),t.prompt&&n&&n.position&&t.prompt.update(n.position,"再次单击完成绘制")}else if(t.state==="creating"){if(t.state="endCreate",t._finalized=!0,t._finalizeEntities(),t.prompt){try{t.prompt.destroy()}catch{}t.prompt=null}if(t.handler){try{t.handler.destroy()}catch{}t.handler=null}try{t.forbidDrawWorld(!1)}catch{}e&&e(t.entity||t.lineEntity)}try{t.viewer.scene.requestRender()}catch{}},this.Cesium.ScreenSpaceEventType.LEFT_DOWN),this.handler.setInputAction(function(n){if(t.state==="startCreate"){t.prompt&&n&&n.endPosition&&t.prompt.update(n.endPosition,"单击开始绘制");return}if(t.state==="creating"){let s=t.getCatesian3FromPX(n.endPosition);if(!s)return;if(t.positions[1]=s,t.controlPoints[1])try{t.controlPoints[1].position.setValue(s)}catch{}try{t.viewer.scene.requestRender()}catch{}}},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(){if(t.state==="creating"){if(t.state="endCreate",t._finalized=!1,t.lineEntity){try{t.viewer.entities.remove(t.lineEntity)}catch{}t.lineEntity=null}if(t.arrowEntity){try{t.viewer.entities.remove(t.arrowEntity)}catch{}t.arrowEntity=null}t.controlPoints.length&&(t.controlPoints.forEach(n=>{try{t.viewer.entities.remove(n)}catch{}}),t.controlPoints=[])}if(t.prompt){try{t.prompt.destroy()}catch{}t.prompt=null}if(t.handler){try{t.handler.destroy()}catch{}t.handler=null}try{t.forbidDrawWorld(!1)}catch{}e&&e(null)},this.Cesium.ScreenSpaceEventType.RIGHT_DOWN),this}_computeArrowPositions(e,t){if(!e||!t)return[];const n=this.Cesium.Cartesian3.distance(e,t);if(n<=1e-6)return[];const s=this.style.arrowLengthFactor!==void 0?this.style.arrowLengthFactor:.15,o=this.style.arrowMinSize!==void 0?this.style.arrowMinSize:1.5,r=this.style.arrowMaxSize!==void 0?this.style.arrowMaxSize:Number.MAX_VALUE;let l=this.style.arrowFixedSize!==void 0?this.style.arrowFixedSize:n*s;l<o&&(l=o),l>r&&(l=r);const a=this.Cesium.Cartesian3.subtract(t,e,new this.Cesium.Cartesian3);this.Cesium.Cartesian3.normalize(a,a);const d=this.Cesium.Transforms.eastNorthUpToFixedFrame(t),h=this.Cesium.Matrix4.getColumn(d,2,new this.Cesium.Cartesian3),p=new this.Cesium.Cartesian3(a.x-h.x*this.Cesium.Cartesian3.dot(a,h),a.y-h.y*this.Cesium.Cartesian3.dot(a,h),a.z-h.z*this.Cesium.Cartesian3.dot(a,h));let f;this.Cesium.Cartesian3.magnitudeSquared(p)<1e-6?f=this.Cesium.Matrix4.getColumn(d,0,new this.Cesium.Cartesian3):(this.Cesium.Cartesian3.normalize(p,p),f=this.Cesium.Cartesian3.cross(h,p,new this.Cesium.Cartesian3),this.Cesium.Cartesian3.normalize(f,f));const u=this.Cesium.Cartesian3.multiplyByScalar(a,-l,new this.Cesium.Cartesian3),m=this.Cesium.Cartesian3.add(t,u,new this.Cesium.Cartesian3),E=this.style.arrowWidthScale!==void 0?this.style.arrowWidthScale:1,A=Math.sin(this.arrowAngle)*l*E,y=this.Cesium.Cartesian3.multiplyByScalar(f,A,new this.Cesium.Cartesian3),v=this.Cesium.Cartesian3.multiplyByScalar(f,-A,new this.Cesium.Cartesian3),S=this.Cesium.Cartesian3.add(m,y,new this.Cesium.Cartesian3),M=this.Cesium.Cartesian3.add(m,v,new this.Cesium.Cartesian3);return[t,S,M,t]}_createLineEntity(){if(this.lineEntity){try{this.viewer.entities.remove(this.lineEntity)}catch{}this.lineEntity=null}const e=this,t=this._getMaterial(),n=new this.Cesium.CallbackProperty(function(){return!e.positions||e.positions.length<2?[]:[e.positions[0],e.positions[1]]},!1);this.lineEntity=this.viewer.entities.add({polyline:{positions:n,material:t,width:this.style.width||3,clampToGround:!!this.style.clampToGround||!1},objId:this.objId}),this.entity=this.lineEntity}_createArrowEntity(){if(this.arrowEntity){try{this.viewer.entities.remove(this.arrowEntity)}catch{}this.arrowEntity=null}const e=this,t=this._getMaterial(),n=new this.Cesium.CallbackProperty(function(){if(!e.positions||e.positions.length<2)return[];const s=e.positions[0],o=e.positions[1];return e._computeArrowPositions(s,o)},!1);this.arrowEntity=this.viewer.entities.add({polyline:{positions:n,material:t,width:this.style.width||3,clampToGround:!!this.style.clampToGround||!1},objId:this.objId}),console.log("this.arrowEntity",this.arrowEntity)}_createControlPoints(){if(this.controlPoints&&this.controlPoints.length&&(this.controlPoints.forEach(e=>{try{this.viewer.entities.remove(e)}catch{}}),this.controlPoints=[]),!(!this.positions||this.positions.length<2))for(let e=0;e<2;e++)try{const t=this.createPoint(this.positions[e]);t.wz=e,this.controlPoints.push(t)}catch{}}_finalizeEntities(){if(this.lineEntity&&this.lineEntity.polyline)try{const e=this.Cesium.Cartesian3.clone(this.positions[0]),t=this.Cesium.Cartesian3.clone(this.positions[1]);this.lineEntity.polyline.positions=[e,t]}catch{}if(this.arrowEntity&&this.arrowEntity.polyline)try{const e=this.positions[0],t=this.positions[1];this.arrowEntity.polyline.positions=this._computeArrowPositions(e,t)}catch{}this.entity=this.lineEntity,this.entity&&(this.entity.arrowEntity=this.arrowEntity,this.entity.positions=[this.positions[0],this.positions[1]],this.positions=[this.positions[0],this.positions[1]]);try{this.viewer.scene.requestRender()}catch{}}startEdit(e){super.startEdit(e),(!this.controlPoints||this.controlPoints.length<2)&&this._createControlPoints();for(let t=0;t<this.controlPoints.length;t++)try{this.controlPoints[t].show=!0}catch{}if(this.lineEntity&&this.lineEntity.polyline)try{const t=this;this.lineEntity.polyline.positions=new this.Cesium.CallbackProperty(function(){return!t.positions||t.positions.length<2?[]:[t.positions[0],t.positions[1]]},!1)}catch{}if(this.arrowEntity&&this.arrowEntity.polyline)try{const t=this;this.arrowEntity.polyline.positions=new this.Cesium.CallbackProperty(function(){if(!t.positions||t.positions.length<2)return[];const n=t.positions[0],s=t.positions[1];return t._computeArrowPositions(n,s)},!1)}catch{}if(!this._editRenderHandler){this._editRenderHandler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);const t=this;this._editRenderHandler.setInputAction(function(n){if(t.modifyPoint)try{t.viewer.scene.requestRender()}catch{}},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE)}}endEdit(e){if(super.endEdit(e),this._editRenderHandler){try{this._editRenderHandler.destroy()}catch{}this._editRenderHandler=null}this._finalized=!0,this._finalizeEntities()}createByPositions(e,t){if(!e||e.length<2)return!1;let n=e[0],s=e[1];if(!(n instanceof this.Cesium.Cartesian3))if(Array.isArray(n)&&n.length>=2)n=this.Cesium.Cartesian3.fromDegrees(n[0],n[1]),s=this.Cesium.Cartesian3.fromDegrees(s[0],s[1]);else return!1;return this.positions=[this.Cesium.Cartesian3.clone(n),this.Cesium.Cartesian3.clone(s)],this._createLineEntity(),this._createArrowEntity(),this._createControlPoints(),this._finalized=!0,this._finalizeEntities(),this.state="endCreate",t&&t(this.entity||this.lineEntity),!0}updatePositions(e){if(!e||e.length<2)return!1;let t=e[0],n=e[1];if(!(t instanceof this.Cesium.Cartesian3))if(Array.isArray(t)&&t.length>=2)t=this.Cesium.Cartesian3.fromDegrees(t[0],t[1]),n=this.Cesium.Cartesian3.fromDegrees(n[0],n[1]);else return!1;return this.positions=[this.Cesium.Cartesian3.clone(t),this.Cesium.Cartesian3.clone(n)],this.lineEntity||this._createLineEntity(),this.arrowEntity||this._createArrowEntity(),this._createControlPoints(),this._finalized=!0,this._finalizeEntities(),!0}setStyle(e){if(!e)return;this.style=Object.assign(this.style||{},e),e.arrowAngle!==void 0&&(this.arrowAngle=e.arrowAngle);const t=this._getMaterial();if(this.lineEntity&&this.lineEntity.polyline){try{this.lineEntity.polyline.material=t}catch{}if(e.width!==void 0)try{this.lineEntity.polyline.width=e.width}catch{}}if(this.arrowEntity&&this.arrowEntity.polyline)try{this.arrowEntity.polyline.material=t}catch{}}endCreate(e){if(this.state!=="endCreate"){if(this.state="endCreate",this.prompt){try{this.prompt.destroy()}catch{}this.prompt=null}if(this._finalized=!0,this._finalizeEntities(),this.handler){try{this.handler.destroy()}catch{}this.handler=null}try{this.forbidDrawWorld(!1)}catch{}e&&e(this.entity||this.lineEntity)}}done(e){this.isDrawing&&(this.isDrawing=!1,this.endCreate(e))}getEntity(){return this.entity||this.lineEntity}destroy(){this._cleanup(!0),this.state=null}_cleanup(e=!0){if(this.handler){try{this.handler.destroy()}catch{}this.handler=null}if(this._editRenderHandler){try{this._editRenderHandler.destroy()}catch{}this._editRenderHandler=null}if(e){if(this.lineEntity){try{this.viewer.entities.remove(this.lineEntity)}catch{}this.lineEntity=null}if(this.arrowEntity){try{this.viewer.entities.remove(this.arrowEntity)}catch{}this.arrowEntity=null}this.controlPoints&&this.controlPoints.length&&(this.controlPoints.forEach(t=>{try{this.viewer.entities.remove(t)}catch{}}),this.controlPoints=[]),this.entity=null}if(this.prompt){try{this.prompt.destroy()}catch{}this.prompt=null}this.positions=[],this.isDrawing=!1,this._finalized=!1;try{this.forbidDrawWorld(!1)}catch{}}_getMaterial(){try{let e=this.style.color||this.Cesium.Color.RED;typeof e=="string"&&(e=this.Cesium.Color.fromCssColorString(e));const t=this.style.colorAlpha!==void 0?this.style.colorAlpha:1;return e.withAlpha(t)}catch{return this.Cesium.Color.RED}}}class ay{constructor(e,t){if(!e){console.warn("缺少必要参数!--viewer");return}if(t=t||{},this.viewer=e,this.Cesium=window.Cesium||window.cesium,this.entityObjArr=[],this.handler=null,!this.Cesium){console.error("Cesium实例未找到!");return}this.removeHandler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.startEditFun=null,this.endEditFun=null,this.removeFun=null,this.editingFun=void 0,this.deleteEntityObj=null,this.bindEdit(),this.bindRemove(),this.canEdit=t.canEdit==null?!0:t.canEdit,this.fireEdit=t.fireEdit==null?!0:t.fireEdit,this.nowDrawEntityObj=null,this.nowEditEntityObj=null}on(e,t){e=="startEdit"&&(this.startEditFun=t),e=="endEdit"&&(this.endEditFun=t),e=="remove"&&(this.removeFun=t),e=="endCreate"&&(this.endCreateFun=t),e=="editing"&&(this.editingFun=t)}openEdit(){this.canEdit=!0}closeEdit(){this.endEdit(),this.canEdit=!1}start(e){if(!e||!e.type)return;e.id=e.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0));let t=this;this.endEdit(),this.nowDrawEntityObj&&(this.nowDrawEntityObj.state=="startCreate"||this.nowDrawEntityObj.state=="creating")&&(this.nowDrawEntityObj.destroy(),this.nowDrawEntityObj=null);let n=this.createByType(e);if(n)return n.attr=e||{},n.start(function(s){t.nowDrawEntityObj=void 0,t.entityObjArr.push(n),e.success&&e.success(n,s),t.endCreateFun&&t.endCreateFun(n,s),e.show==!1&&n.setVisible(!1),t.canEdit&&t.fireEdit&&(n.startEdit(function(){t.editingFun&&t.editingFun(n,n.entity)}),t.nowEditEntityObj=n,t.startEditFun&&t.startEditFun(n,s))}),this.nowDrawEntityObj=n,n}end(){this.nowDrawEntityObj}startEditOne(e){if(!this.canEdit)return;this.nowEditEntityObj&&(this.nowEditEntityObj.endEdit(),this.endEditFun&&this.endEditFun(this.nowEditEntityObj,this.nowEditEntityObj.getEntity()),this.nowEditEntityObj=null);let t=this;e&&(e.startEdit(function(){t.editingFun&&t.editingFun(e,e.entity)}),this.startEditFun&&this.startEditFun(e,e.getEntity()),this.nowEditEntityObj=e)}updateOneStyle(e,t){e&&e.setStyle(t)}createByPositions(e){if(e=e||{},e||(e={}),!e.positions)return;e.id=e.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0));let t=this,n=this.createByType(e);if(n)return n.attr=e,n.createByPositions(e.positions,function(s){t.entityObjArr.push(n),n.setStyle(e.style),e.success&&e.success(n,s),t.endCreateFun&&t.endCreateFun(n,s),e.show==!1&&n.setVisible(!1),t.canEdit&&t.fireEdit&&(n.startEdit(function(){t.editingFun&&t.editingFun(n,n.entity)}),t.startEditFun&&t.startEditFun(n,s),t.nowEditEntityObj=n)}),n}createByGeojson(e){let{features:t}=e,n=[];for(let s=0;s<t.length;s++){let o=t[s];const{properties:r,geometry:l}=o;let a=r.plotType;const d=l.type,h=l.coordinates;let p=[],f="";switch(d){case"LineString":p=se.lnglatsToCartesians(h),f="polyline";break;case"Polygon":p=se.lnglatsToCartesians(h[0]),f="polygon";break;case"Point":p=se.lnglatsToCartesians([h])[0],f=a;break}this.fireEdit=!1;let u=this.createByPositions({type:f,styleType:a,positions:p,style:r.style});u&&n.push(u)}return n}toGeojson(){let e={type:"FeatureCollection",features:[]};if(this.entityObjArr.length==0)return null;for(let t=0;t<this.entityObjArr.length;t++){let n=this.entityObjArr[t],s=n.getPositions(!0),o=[];for(let d=0;d<s.length;d++)o.push([s[d][0],s[d][1]]);let r=n.getStyle(),l=this.transType(n.type),a={type:"Feature",properties:{plotType:n.type,style:r},geometry:{type:l,coordinates:[]}};switch(l){case"Polygon":a.geometry.coordinates=[o];break;case"Point":a.geometry.coordinates=o;break;case"LineString":a.geometry.coordinates=o;break}a.properties=Object.assign(a.properties,n.properties),e.features.push(a)}return e}transType(e){let t="";switch(e){case"polyline":t="LineString";break;case"polygon":t="Polygon";break;case"point":case"gltfModel":case"label":case"billboard":t="Point";break;default:t=e}return t}destroy(){this.nowEditEntityObj&&(this.nowEditEntityObj.destroy(),this.nowEditEntityObj=null),this.nowDrawEntityObj&&(this.nowDrawEntityObj.destroy(),this.nowDrawEntityObj=null);for(let e=0;e<this.entityObjArr.length;e++)this.entityObjArr[e].destroy();this.entityObjArr=[],this.nowEditEntityObj=null,this.handler&&(this.handler.destroy(),this.handler=null),this.removeHandler&&(this.removeHandler.destroy(),this.removeHandler=null)}removeOne(e){e&&e&&(e.state!="endCreate"||e.state!="endEdit"?e.destroy():this.removeByObjId(e.objId))}removeAll(){this.nowDrawEntityObj&&(this.nowDrawEntityObj.destroy(),this.nowDrawEntityObj=null),this.nowEditEntityObj&&(this.nowEditEntityObj.destroy(),this.nowEditEntityObj=null);for(let e=0;e<this.entityObjArr.length;e++)this.entityObjArr[e].destroy();this.entityObjArr=[],this.nowEditEntityObj=null}hasEntityObj(e){return e?this.getEntityObjByObjId(e.objId)!={}:!1}removeByObjId(e){let t=this.getEntityObjByObjId(e);this.entityObjArr.splice(t.index,1),this.removeFun&&this.removeFun(t.entityObj,t.entityObj.getEntity()),t.entityObj&&t.entityObj.destroy()}removeById(e){let t=this.getEntityObjById(e);this.entityObjArr.splice(t.index,1),this.removeFun&&this.removeFun(t.entityObj,t.entityObj.getEntity()),t.entityObj&&t.entityObj.destroy()}zoomToByObjId(e){let t=this.getEntityObjByObjId(e);t.entityObj&&t.entityObj.zoomTo()}getEntityObjByField(e,t){let n={};if(t)for(let s=0;s<this.entityObjArr.length;s++){let o=this.entityObjArr[s];if(o.attr[e]==t){n.entityObj=o,n.index=s;break}}else for(let s=0;s<this.entityObjArr.length;s++){let o=this.entityObjArr[s];if(o.attr.id==e){n.entityObj=o,n.index=s;break}}return n}setVisible(e,t){let n=this.getEntityObjByField("id",e);n.entityObj&&n.entityObj.setVisible(t)}getEntityObjByObjId(e){if(!e)return;let t={};for(let n=0;n<this.entityObjArr.length;n++){let s=this.entityObjArr[n];if(s.objId==e){t.entityObj=s,t.index=n;break}}return t}getEntityObjById(e){if(!e)return;let t={};for(let n=0;n<this.entityObjArr.length;n++){let s=this.entityObjArr[n];if(s.attr.id==e){t.entityObj=s,t.index=n;break}}return t}bindEdit(){let e=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(t){if(!e.canEdit||e.nowDrawEntityObj)return;const n=e.viewer.scene.drillPick(t.position)||[];let s=-1,o;for(let r=0;r<n.length&&s===-1;r++){const l=n[r].id;if(l){for(let a=0;a<e.entityObjArr.length;a++)if(l.objId==e.entityObjArr[a].objId&&e.entityObjArr[a].state!="startCreate"&&e.entityObjArr[a].state!="creating"){s=a,o=l;break}}}s!==-1?(e.nowEditEntityObj&&(e.nowEditEntityObj.endEdit(),e.endEditFun&&e.endEditFun(e.nowEditEntityObj,e.nowEditEntityObj.getEntity()),e.nowEditEntityObj=null),e.entityObjArr[s].startEdit(function(){e.editingFun&&e.editingFun(e.nowEditEntityObj,e.nowEditEntityObj.entity)}),e.startEditFun&&e.startEditFun(e.entityObjArr[s],o),e.nowEditEntityObj=e.entityObjArr[s]):e.nowEditEntityObj&&(e.nowEditEntityObj.endEdit(),e.endEditFun&&e.endEditFun(e.nowEditEntityObj,e.nowEditEntityObj.getEntity()),e.nowEditEntityObj=void 0)},Cesium.ScreenSpaceEventType.LEFT_CLICK)}bindRemove(){let e=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(t){if(!e.canEdit||e.nowDrawEntityObj)return;const n=e.viewer.scene.drillPick(t.position)||[];let s;for(let o=0;o<n.length;o++){const r=n[o].id;if(r){for(let l=0;l<e.entityObjArr.length;l++)if(r.objId==e.entityObjArr[l].objId){s=r.objId;break}if(s)break}}s&&e.createDelteDom(t.position,s)},Cesium.ScreenSpaceEventType.RIGHT_CLICK)}createDelteDom(e,t){if(!t)return;let n=window.document.createElement("span");n.style.background="rgba(0,0,0,0.5)",n.style.position="absolute",n.style.color="white",n.style.left=e.x+10+"px",n.style.top=e.y+10+"px",n.style.padding="4px",n.style.cursor="pointer",n.id="easy3d-plot-delete",n.setAttribute("objId",t),n.innerHTML="删除",window.document.getElementById(this.viewer.container.id).appendChild(n);const o=window.document.getElementById("easy3d-plot-delete");if(!o)return;let r=this;o.addEventListener("click",l=>{let a=n.getAttribute("objId");r.removeByObjId(a)}),document.addEventListener("click",function(){o.remove()})}endEdit(){this.nowEditEntityObj&&(this.nowEditEntityObj.endEdit(),this.endEditFun&&this.endEditFun(this.nowEditEntityObj,this.nowEditEntityObj.getEntity()),this.nowEditEntityObj=null);for(let e=0;e<this.entityObjArr.length;e++)this.entityObjArr[e].endEdit()}done(){this.nowEditEntityObj&&(this.nowEditEntityObj.done(),this.endEditFun&&this.endEditFun(this.nowEditEntityObj,this.nowEditEntityObj.getEntity()),this.nowEditEntityObj=void 0),this.nowDrawEntityObj&&(this.nowDrawEntityObj.done(),this.entityObjArr.push(this.nowDrawEntityObj),this.endCreateFun&&this.endCreateFun(this.nowDrawEntityObj,this.nowDrawEntityObj.getEntity()),this.nowDrawEntityObj=void 0)}getEntityObjArr(){return this.entityObjArr}createByType(e){let t,n="";return e=e||{},e.type=="polyline"&&(t=new sy(this.viewer,e.style),n="折线_"),e.type=="freehandLine"&&(t=new oy(this.viewer,e.style),n="手绘线_"),e.type=="polygon"&&(t=new iy(this.viewer,e.style),n="面_"),e.type=="billboard"&&(t=new wp(this.viewer,e.style),n="图标_"),(e.type=="circle"||e.type=="ellipse")&&(t=new bp(this.viewer,e.style),n="圆_"),e.type=="rectangle"&&(t=new ny(this.viewer,e.style),n="矩形_"),e.type=="gltfModel"&&(t=new vp(this.viewer,e.style),n="模型_"),e.type=="point"&&(t=new ty(this.viewer,e.style),n="点_"),e.type=="label"&&(t=new ey(this.viewer,e.style),n="文字_"),e.type=="arrow"&&(t=new ry(this.viewer,e.style)),t&&(t.name=n+new Date().getTime()),t}}class el{viewer;Cesium;drawTool;flatTool;tileset;tilesets;flatTools;selectedEntityObj;selectionOutline;centerHandle;_dragHandler;_listeners;currentColor;currentWidth;originalDoubleClickAction=null;constructor({viewer:e,cesium:t}){window.Cesium=t,this.viewer=e,this.Cesium=t,this.drawTool=null,this.flatTool=null,this.tileset=null,this.tilesets=null,this.flatTools=null,this.selectedEntityObj=null,this.selectionOutline=null,this.centerHandle=null,this._dragHandler=null,this._listeners=[],this.currentColor=this.Cesium.Color.fromCssColorString("#ff0000"),this.currentWidth=1,this.originalDoubleClickAction=this.viewer.screenSpaceEventHandler.getInputAction(this.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.viewer.screenSpaceEventHandler.removeInputAction(this.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.initDrawTool()}setCurrentColor(e){typeof e=="string"?this.currentColor=this.Cesium.Color.fromCssColorString(e):this.currentColor=e}setCurrentWidth(e){this.currentWidth=e}initDrawTool(){this.drawTool||(this.drawTool=new ay(this.viewer,{canEdit:!0,fireEdit:!0}),this.drawTool.on("startEdit",(e,t)=>{this.selectedEntityObj=e,this.showEntityOutline(e)}),this.drawTool.on("endEdit",(e,t)=>{this.selectedEntityObj=null,this.hideEntityOutline()}),this.drawTool.on("remove",(e,t)=>{this.selectedEntityObj===e&&(this.selectedEntityObj=null,this.hideEntityOutline())}))}showEntityOutline(e){this.hideEntityOutline(),!(!e||!e.getEntity())&&this.createCenterHandle(e)}hideEntityOutline(){if(this.selectionOutline){try{this.viewer.entities.remove(this.selectionOutline)}catch{}this.selectionOutline=null}if(this.centerHandle){try{this.viewer.entities.remove(this.centerHandle)}catch{}this.centerHandle=null}if(this._dragHandler){try{this._dragHandler.destroy()}catch{}this._dragHandler=null}}createCenterHandle(e){if(!e||!e.getEntity())return;if(this.centerHandle){try{this.viewer.entities.remove(this.centerHandle)}catch{}this.centerHandle=null}const t=e.getEntity();let n=null;if(t._plotInstance&&typeof t._plotInstance.syncFromEntity=="function")try{t._plotInstance.syncFromEntity();const s=t._plotInstance;s.leftup&&s.rightdown&&(n=this.Cesium.Cartesian3.midpoint(s.leftup,s.rightdown,new this.Cesium.Cartesian3))}catch(s){console.warn("plotInstance.syncFromEntity failed",s)}if(!n){if(e.positions&&e.positions.length)n=this.calculateCenter(e.positions);else if(t.position&&t.position.getValue)n=t.position.getValue();else if(t.polyline&&t.polyline.positions&&t.polyline.positions.getValue){const s=t.polyline.positions.getValue();n=this.calculateCenter(s)}else if(t.polygon&&t.polygon.hierarchy&&t.polygon.hierarchy.getValue){const s=t.polygon.hierarchy.getValue().positions;n=this.calculateCenter(s)}else if(t.rectangle&&t.rectangle.coordinates&&t.rectangle.coordinates.getValue)try{const s=t.rectangle.coordinates.getValue(),o=(s.west+s.east)/2,r=(s.south+s.north)/2;n=this.Cesium.Cartesian3.fromRadians(o,r,0)}catch{}}n&&(this.centerHandle=this.viewer.entities.add({position:n,point:{pixelSize:10,color:this.Cesium.Color.WHITE,outlineColor:this.Cesium.Color.BLUE,outlineWidth:2}}),this.addDragHandler(e,n))}calculateCenter(e){if(!e||e.length===0)return null;const t=e.map(r=>r);let n=0,s=0,o=0;for(let r=0;r<t.length;r++)n+=t[r].x,s+=t[r].y,o+=t[r].z;return new this.Cesium.Cartesian3(n/t.length,s/t.length,o/t.length)}getEntityPositions(e){const t=e.getEntity();if(e.positions&&Array.isArray(e.positions))return e.positions.slice();if(t.polyline&&t.polyline.positions&&t.polyline.positions.getValue){const n=t.polyline.positions.getValue();return Array.isArray(n)?n.slice():[]}if(t.polygon&&t.polygon.hierarchy&&t.polygon.hierarchy.getValue){const n=t.polygon.hierarchy.getValue();return n&&n.positions?n.positions.slice():[]}if(t.position&&t.position.getValue)return[t.position.getValue()];if(t.rectangle&&t.rectangle.coordinates&&t.rectangle.coordinates.getValue){const n=t.rectangle.coordinates.getValue();return[this.Cesium.Cartesian3.fromDegrees(n.west,n.south),this.Cesium.Cartesian3.fromDegrees(n.east,n.south),this.Cesium.Cartesian3.fromDegrees(n.east,n.north),this.Cesium.Cartesian3.fromDegrees(n.west,n.north)]}return[]}addDragHandler(e,t){if(console.log("移动线段"),this._dragHandler){try{this._dragHandler.destroy()}catch{}this._dragHandler=null}let n=!1,s,o=0;const r=16,l=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);this._dragHandler=l;const a=d=>{let h;try{h=this.viewer.scene.pickPosition(d)}catch{}if(!this.Cesium.defined(h)){const p=this.viewer.camera.getPickRay(d);p&&(h=this.viewer.scene.globe.pick(p,this.viewer.scene))}return this.Cesium.defined(h)||(h=this.viewer.scene.camera.pickEllipsoid(d,this.viewer.scene.globe.ellipsoid)),h};l.setInputAction(d=>{let h=!1;const p=this.viewer.scene.drillPick(d.position)||[];for(let f=0;f<p.length;f++){const u=p[f].id;if(u&&u===this.centerHandle){h=!0;break}}if(h){n=!0;const f=a(d.position);this.Cesium.defined(f)&&(s=f.clone()),o=performance.now(),this.viewer.scene.screenSpaceCameraController.enableRotate=!1,this.viewer.scene.screenSpaceCameraController.enableTranslate=!1,this.viewer.scene.screenSpaceCameraController.enableZoom=!1,this.viewer.scene.screenSpaceCameraController.enableTilt=!1,this.viewer.scene.screenSpaceCameraController.enableLook=!1}},this.Cesium.ScreenSpaceEventType.LEFT_DOWN),l.setInputAction(d=>{if(!n||!this.Cesium.defined(s))return;const h=performance.now();if(h-o<r)return;o=h;const p=a(d.endPosition);if(!this.Cesium.defined(p))return;const f=this.Cesium.Cartesian3.subtract(p,s,new this.Cesium.Cartesian3);if(this.centerHandle&&this.centerHandle.position&&this.centerHandle.position.setValue){const u=this.centerHandle.position.getValue(this.Cesium.JulianDate.now());if(u){const m=this.Cesium.Cartesian3.add(u,f,new this.Cesium.Cartesian3);this.centerHandle.position.setValue(m)}}this.moveEntity(e,f);try{this.viewer.scene.requestRender()}catch{}s=p.clone()},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE),l.setInputAction(()=>{if(n){n=!1,this.viewer.scene.screenSpaceCameraController.enableRotate=!0,this.viewer.scene.screenSpaceCameraController.enableTranslate=!0,this.viewer.scene.screenSpaceCameraController.enableZoom=!0,this.viewer.scene.screenSpaceCameraController.enableTilt=!0,this.viewer.scene.screenSpaceCameraController.enableLook=!0;const d=e.getEntity();if(d.state="done",d&&d.rectangle&&d.rectangle.coordinates)try{const h=d.rectangle.coordinates.getValue?d.rectangle.coordinates.getValue():d.rectangle.coordinates;h&&d.rectangle.coordinates.setValue(h)}catch(h){console.warn("Failed to refresh rectangle coordinates",h)}e&&this.selectedEntityObj!==e&&this.showEntityOutline(e)}},this.Cesium.ScreenSpaceEventType.LEFT_UP)}moveEntity(e,t){const n=e.getEntity();if(!n)return;const s=o=>this.Cesium.Cartesian3.add(o,t,new this.Cesium.Cartesian3);if(n.position){const o=n.position.getValue?n.position.getValue():n.position,r=s(o);n.position.setValue?n.position.setValue(r):n.position=r,n.state="moving",e.positions&&e.positions.length===1&&(e.positions[0]=r);return}if(n.polyline){if(n._plotInstance&&n._plotInstance.type==="rectangle"&&typeof n._plotInstance.updatePositions=="function")try{const l=new this.Cesium.Cartesian3(t.x,t.y,t.z);if(n._plotInstance.updatePositions([l]))return}catch(l){console.warn("Failed to update rectangle positions:",l)}if(n._plotInstance&&n._plotInstance.type==="circle"&&typeof n._plotInstance.updatePositions=="function")try{const l=new this.Cesium.Cartesian3(t.x,t.y,t.z);if(n._plotInstance.updatePositions([l]))return}catch(l){console.warn("Failed to update circle positions:",l)}const r=(e.positions&&Array.isArray(e.positions)?e.positions:n.polyline.positions.getValue?n.polyline.positions.getValue():[]).map(l=>s(l));if(e.updatePositions&&typeof e.updatePositions=="function")e.updatePositions(r);else if(e.positions&&Array.isArray(e.positions)&&(e.positions=r),n.polyline&&n.polyline.positions)try{n.polyline.positions instanceof this.Cesium.CallbackProperty||(n.polyline.positions=r)}catch{n.polyline.positions=r}}}startFreehandLine(e={}){this.initDrawTool();const t=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"freehandLine",style:Object.assign({color:this.currentColor,width:this.currentWidth,clampToGround:!t,smoothness:2,minDistance:.01,angleThreshold:.8,renderInterval:16,curveResolution:3},e)})}startArrow(e={}){this.initDrawTool();const t=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"arrow",style:Object.assign({color:this.currentColor,width:this.currentWidth,clampToGround:!t},e)})}startStraightLine(e={}){this.initDrawTool();const t=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"polyline",style:Object.assign({color:this.currentColor,width:this.currentWidth,clampToGround:!t},e)})}startEllipse(e={}){this.initDrawTool();const t=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"circle",style:Object.assign({color:this.currentColor.withAlpha(1),outlineColor:this.currentColor,outlineWidth:this.currentWidth,outline:!0,fill:!1,clampToGround:!t},e)})}startImage(e,t){this.initDrawTool();const n=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"billboard",style:Object.assign({image:e,width:t&&t.width?t.width:50,height:t&&t.height?t.height:50,clampToGround:!n},t)})}startRectangle(e={}){this.initDrawTool();const t=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"rectangle",style:Object.assign({color:this.currentColor.withAlpha(1),outlineColor:this.currentColor,outlineWidth:this.currentWidth,clampToGround:!t},e)})}clearAll(){this.drawTool&&this.drawTool.removeAll(),this.hideEntityOutline()}destroy(){this.clearAll(),this.originalDoubleClickAction&&(this.viewer.screenSpaceEventHandler.setInputAction(this.originalDoubleClickAction,this.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.originalDoubleClickAction=null)}getAllEntities(){return this.drawTool&&typeof this.drawTool.getEntityObjArr=="function"?this.drawTool.getEntityObjArr():[]}saveAnnotations(){try{const e=this.getAllEntities(),t={freehand:[],arrow:[],text:[],image:[],polyline:[],rectangle:[],ellipse:[],other:[]};e.forEach(o=>{if(o&&typeof o=="object"){const r=o.type||o.constructor&&o.constructor.name,l={type:r,style:{}};switch(!0){case["freehandLine","CreateFreehandLine","polyline","CreatePolyline","arrow","CreateArrow"].includes(r):l.id=o.objId||o.id||Date.now().toString(),o.style&&(l.style={color:o.style.color,width:o.style.width,opacity:o.style.opacity,...o.style}),o.positions&&Array.isArray(o.positions)&&(l.positions=o.positions.map(a=>a&&typeof a=="object"&&a.x!==void 0&&a.y!==void 0&&a.z!==void 0?{x:a.x,y:a.y,z:a.z}:a)),["freehandLine","CreateFreehandLine"].includes(r)&&(l.isEdit=o.isEdit!==void 0?o.isEdit:!0,l.isFreehand=!0);break;case["rectangle","CreateRectangle"].includes(r):try{l.id=o.objId||o.id||Date.now().toString();let a=[];if(o.positions&&Array.isArray(o.positions)&&o.positions.length)a=o.positions.map(d=>({x:d.x,y:d.y,z:d.z}));else{const d=o.getEntity?o.getEntity():o;if(d)try{if(d.polyline&&d.polyline.positions&&d.polyline.positions.getValue){const h=d.polyline.positions.getValue(this.viewer.clock.currentTime);Array.isArray(h)&&(a=h.map(p=>({x:p.x,y:p.y,z:p.z})))}else if(d.rectangle&&d.rectangle.coordinates&&d.rectangle.coordinates.getValue){const h=d.rectangle.coordinates.getValue(this.viewer.clock.currentTime);a=[{west:h.west,south:h.south,east:h.east,north:h.north}]}}catch{}}o.style&&(l.style=Object.assign({},o.style)),a&&a.length&&(l.positions=a)}catch{}break;case["ellipse","CreateEllipse","circle","CreateCircle"].includes(r):try{l.id=o.objId||o.id||Date.now().toString();let a=[];const d=o.getEntity?o.getEntity():o;if(d&&d._plotInstance&&d._plotInstance.type==="circle"&&d._plotInstance.center&&d._plotInstance.radiusPoint){const h=d._plotInstance;a=[{x:h.center.x,y:h.center.y,z:h.center.z},{x:h.radiusPoint.x,y:h.radiusPoint.y,z:h.radiusPoint.z}]}else if(o.positions&&Array.isArray(o.positions)&&o.positions.length)a=o.positions.map(h=>({x:h.x,y:h.y,z:h.z}));else if(d)try{if(d.polyline&&d.polyline.positions&&d.polyline.positions.getValue){const h=d.polyline.positions.getValue(this.viewer.clock.currentTime);Array.isArray(h)&&(a=h.map(p=>({x:p.x,y:p.y,z:p.z})))}else if(d.ellipse&&d.ellipse.center&&d.ellipse.center.getValue&&d.ellipse.semiMajorAxis&&d.ellipse.semiMajorAxis.getValue){const h=d.ellipse.center.getValue(this.viewer.clock.currentTime),p=d.ellipse.semiMajorAxis.getValue(this.viewer.clock.currentTime);if(h&&p){const f={x:h.x,y:h.y,z:h.z||0},u={x:f.x+p,y:f.y,z:f.z};a=[f,u]}}}catch{}o.style&&(l.style=Object.assign({},o.style)),a&&a.length&&(l.positions=a)}catch{}break;case["label","CreateLabel"].includes(r):if(o.style)l.style=Object.assign({},o.style);else try{const a=o.getEntity?o.getEntity():o;if(a&&a.label){const d={};try{const h=a.label.fillColor&&a.label.fillColor.getValue?a.label.fillColor.getValue(this.viewer.clock.currentTime):a.label.fillColor;h&&(d.color=h)}catch{}a.label.font&&(d.font=a.label.font),l.style=d}}catch{}if(o.text)l.text=o.text;else try{const a=o.getEntity?o.getEntity():o;if(a&&a.label&&a.label.text){const d=a.label.text.getValue?a.label.text.getValue(this.viewer.clock.currentTime):a.label.text;d&&(l.text=d)}}catch{}if(o.position)l.position=o.position;else try{const a=o.getEntity?o.getEntity():o;if(a&&a.position&&a.position.getValue){const d=a.position.getValue(this.viewer.clock.currentTime);d&&(l.position={x:d.x,y:d.y,z:d.z})}}catch{}break;case["billboard","CreateBillboard"].includes(r):if(o.style)l.style=Object.assign({},o.style);else try{const a=o.getEntity?o.getEntity():o;if(a&&a.billboard){const d={};try{const h=a.billboard.image&&a.billboard.image.getValue?a.billboard.image.getValue(this.viewer.clock.currentTime):a.billboard.image;if(h){if(typeof h=="string")d.image=h;else if(h&&h.src)try{const p=h;if(typeof document<"u"&&p instanceof HTMLImageElement){const f=document.createElement("canvas");f.width=p.naturalWidth||p.width||1,f.height=p.naturalHeight||p.height||1;const u=f.getContext("2d");u?(u.drawImage(p,0,0),d.image=f.toDataURL()):d.image=p.src}else d.image=h.src}catch{d.image=h.src}}}catch{}a.billboard.width&&(d.width=a.billboard.width),a.billboard.height&&(d.height=a.billboard.height),l.style=d}}catch{}if(o.position)l.position=o.position;else try{const a=o.getEntity?o.getEntity():o;if(a&&a.position&&a.position.getValue){const d=a.position.getValue(this.viewer.clock.currentTime);d&&(l.position={x:d.x,y:d.y,z:d.z})}}catch{}break;default:o.style&&(l.style=o.style),o.position&&(l.position=o.position);break}switch(!0){case["freehandLine","CreateFreehandLine"].includes(r):t.freehand.push(l);break;case["arrow","CreateArrow"].includes(r):t.arrow.push(l);break;case["label","CreateLabel"].includes(r):t.text.push(l);break;case["billboard","CreateBillboard"].includes(r):t.image.push(l);break;case["polyline","CreatePolyline"].includes(r):t.polyline.push(l);break;case["rectangle","CreateRectangle"].includes(r):t.rectangle.push(l);break;case["ellipse","CreateEllipse","circle","CreateCircle"].includes(r):t.ellipse.push(l);break;default:t.other.push(l)}}});const n={version:"1.0",exportTime:new Date().toISOString(),totalEntities:e.length,annotations:t},s=JSON.stringify(n);return console.log("标注数据已按类型分类保存,只包含重绘所需信息:",s),s}catch(e){return console.error("保存标注失败:",e),!1}}loadAnnotations(e){try{const t=typeof e=="string"?JSON.parse(e):e;if(!t.annotations)return console.error("标注数据格式错误,缺少annotations字段"),!1;const n=t.annotations;let s=0;const o=(r,l)=>{Array.isArray(r)&&r.forEach(a=>{if(a.style){if(a.style.color&&typeof a.style.color=="object"){const d=a.style.color;a.style.color=`rgba(${Math.round(d.red*255)}, ${Math.round(d.green*255)}, ${Math.round(d.blue*255)}, ${d.alpha||1})`}if(a.style.outlineColor&&typeof a.style.outlineColor=="object"){const d=a.style.outlineColor;a.style.outlineColor=`rgba(${Math.round(d.red*255)}, ${Math.round(d.green*255)}, ${Math.round(d.blue*255)}, ${d.alpha||1})`}}switch(l){case"freehand":case"polyline":case"arrow":if(a.positions&&a.positions.length>0){const d=a.positions.map(f=>f&&typeof f=="object"?new this.Cesium.Cartesian3(f.x,f.y,f.z):f),h={type:l==="freehand"?"freehandLine":l,style:a.style||{},positions:d,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))},p=this.drawTool.createByPositions(h);if(p&&p.getEntity()){s++,p.isEdit=!0;const f=p.getEntity();f&&!f._plotInstance&&(f._plotInstance=p),f&&!f.objId&&(f.objId=p.objId),console.log(`Loaded ${l} entity with objId: ${p.objId}`)}}break;case"rectangle":{try{if(a.positions&&a.positions.length){let d=[];if(a.positions[0]&&a.positions[0].x!==void 0)d=a.positions.map(h=>new this.Cesium.Cartesian3(h.x,h.y,h.z!==void 0?h.z:0));else if(a.positions[0]&&a.positions[0].west!==void 0){const h=a.positions[0];d=[this.Cesium.Cartesian3.fromRadians(h.west,h.south),this.Cesium.Cartesian3.fromRadians(h.east,h.south),this.Cesium.Cartesian3.fromRadians(h.east,h.north),this.Cesium.Cartesian3.fromRadians(h.west,h.north),this.Cesium.Cartesian3.fromRadians(h.west,h.south)]}if(d.length){const h=JSON.parse(JSON.stringify(a.style||{}));if(h.color&&typeof h.color=="string"&&!h.color.startsWith("rgba"))try{const u=JSON.parse(h.color);u.red!==void 0&&(h.color=`rgba(${Math.round(u.red*255)}, ${Math.round(u.green*255)}, ${Math.round(u.blue*255)}, ${u.alpha||1})`)}catch{}const p={type:"rectangle",positions:d,style:h,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let f=null;try{f=this.drawTool.createByPositions(p)}catch(u){console.warn("drawTool.createByPositions(rectangle) failed",u)}if(f){s++,f.isEdit=!0;const u=f.getEntity?f.getEntity():f.entity||f;u&&(u._plotInstance=f,u.objId=f.objId||a.id,u.pickable=!0,u.polyline&&(u.polyline.pickWidth=10),console.log(`Loaded rectangle entity with objId: ${u.objId}, color: ${h.color}`))}}}}catch(d){console.warn("load rectangle failed",d)}break}case"text":if(a.position){const d=a.text||"文字标注",h={type:"label",style:a.style||{},text:d,position:new this.Cesium.Cartesian3(a.position.x,a.position.y,a.position.z||0)};h.style.fontSize||(h.style.fontSize=14),h.style.fontFamily||(h.style.fontFamily="Arial");let p;try{!h.positions&&h.position&&(h.positions=h.position),p=this.drawTool.createByPositions(h),!p&&this.drawTool.startText&&(console.log("使用startText创建文字"),this.drawTool.startText(h.style),this.drawTool.currentEntity&&(this.drawTool.currentEntity.text=d,this.drawTool.currentEntity.position=h.position,p=this.drawTool.currentEntity))}catch(f){console.log("创建文字失败",f)}if(!p)try{const f=this.viewer.entities.add({position:h.position,label:Object.assign({text:d,font:h.style&&h.style.font||"14pt Source Han Sans CN",fillColor:h.style&&h.style.fillColor||this.Cesium.Color.WHITE,outlineColor:h.style&&h.style.outlineColor||this.Cesium.Color.BLACK,outlineWidth:h.style&&h.style.outlineWidth||2,verticalOrigin:h.style&&h.style.verticalOrigin||this.Cesium.VerticalOrigin.BOTTOM,pixelOffset:h.style&&h.style.pixelOffset||new this.Cesium.Cartesian2(0,-10)},h.style&&h.style.label?h.style.label:{})}),u={getEntity:()=>f,entity:f,style:h.style||{},type:"label",objId:a.id||`label_${Date.now()}_${Math.random().toFixed(3)}`,isEdit:!0,destroy:()=>this.viewer.entities.remove(f)};try{f.objId=u.objId}catch{}this.drawTool&&(this.drawTool.entityObjArr||(this.drawTool.entityObjArr=[]),this.drawTool.entityObjArr.push(u)),p=u}catch(f){console.warn("回退创建文字实体失败",f)}p&&(s++,p.isEdit=!0)}break;case"image":if(a.position){const d={type:"billboard",style:a.style||{},position:new this.Cesium.Cartesian3(a.position.x,a.position.y,a.position.z||0)};d.style.image||(console.log("使用默认图片占位符"),d.style.image="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgdmlld0JveD0iMCAwIDUwIDUwIj48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNlNTMyMzIiLz48L3N2Zz4="),d.style.width||(d.style.width=50),d.style.height||(d.style.height=50);let h;try{!d.positions&&d.position&&(d.positions=d.position),h=this.drawTool.createByPositions(d),!h&&this.drawTool.startImage&&(console.log("使用startImage创建图片"),this.drawTool.startImage(d.style.image,d.style),this.drawTool.currentEntity&&(this.drawTool.currentEntity.position=d.position,h=this.drawTool.currentEntity))}catch(p){console.log("创建图片失败",p)}if(!h)try{const p=d.style&&d.style.image?d.style.image:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgdmlld0JveD0iMCAwIDUwIDUwIj48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNlNTMyMzIiLz48L3N2Zz4=",f=this.viewer.entities.add({position:d.position,billboard:{image:p,width:d.style&&d.style.width?d.style.width:50,height:d.style&&d.style.height?d.style.height:50,verticalOrigin:d.style&&d.style.verticalOrigin||this.Cesium.VerticalOrigin.CENTER,scale:d.style&&d.style.scale||1}}),u={getEntity:()=>f,entity:f,style:d.style||{},type:"billboard",objId:a.id||`billboard_${Date.now()}_${Math.random().toFixed(3)}`,isEdit:!0,destroy:()=>this.viewer.entities.remove(f)};try{f.objId=u.objId}catch{}this.drawTool&&(this.drawTool.entityObjArr||(this.drawTool.entityObjArr=[]),this.drawTool.entityObjArr.push(u)),h=u}catch(p){console.warn("回退创建图片实体失败",p)}h&&(s++,h.isEdit=!0)}break;case"ellipse":case"circle":{try{const d=JSON.parse(JSON.stringify(a.style||{}));if(d.color&&typeof d.color=="string"&&!d.color.startsWith("rgba"))try{const f=JSON.parse(d.color);f.red!==void 0&&(d.color=`rgba(${Math.round(f.red*255)}, ${Math.round(f.green*255)}, ${Math.round(f.blue*255)}, ${f.alpha||1})`)}catch{}let h=[],p=!1;if(a.positions&&a.positions.length&&(a.positions[0]&&a.positions[0].x!==void 0&&(h=a.positions.map(f=>new this.Cesium.Cartesian3(f.x,f.y,f.z!==void 0?f.z:0))),h.length)){const f={type:l,positions:h,style:d,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let u=null;try{if(u=this.drawTool.createByPositions(f),u){s++,u.isEdit=!0;const m=u.getEntity?u.getEntity():u.entity||u;m&&(m._plotInstance=u,m.objId=u.objId||a.id,m.pickable=!0,m.polyline&&(m.polyline.pickWidth=10),console.log(`Loaded ${l} entity with objId: ${m.objId} using positions`)),p=!0}}catch(m){console.warn(`drawTool.createByPositions(${l}) failed`,m)}}if(!p&&a.center&&a.radius)try{const f=new this.Cesium.Cartesian3(a.center.x,a.center.y,a.center.z||0),u=this.Cesium.Cartesian3.add(f,new this.Cesium.Cartesian3(a.radius,0,0),new this.Cesium.Cartesian3),E={type:l,positions:[f,u],style:d,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let A=null;try{if(A=this.drawTool.createByPositions(E),A){s++,A.isEdit=!0;const y=A.getEntity?A.getEntity():A.entity||A;y&&(y._plotInstance=A,y.objId=A.objId||a.id,y.pickable=!0,y.polyline&&(y.polyline.pickWidth=10),console.log(`Loaded ${l} entity with objId: ${y.objId} using center and radius`))}}catch(y){console.warn(`drawTool.createByPositions(${l}) with center/radius failed`,y)}}catch(f){console.warn(`Fallback creation for ${l} failed`,f)}}catch(d){console.warn(`load ${l} failed`,d)}break}default:console.log(`尝试加载未知类型实体: ${l}`);break}})};return Object.keys(n).forEach(r=>{o(n[r],r)}),console.log(`成功加载 ${s} 个标注实体`),this.drawTool&&typeof this.drawTool.bindEdit=="function"&&this.drawTool.bindEdit(),!0}catch(t){return console.error("加载标注失败:",t),!1}}changeEntityColor(e){try{if(!this.selectedEntityObj)return!1;if(this.selectedEntityObj.setStyle&&typeof this.selectedEntityObj.setStyle=="function")try{return this.selectedEntityObj.setStyle({color:e}),console.log("通过实体对象的setStyle方法修改颜色成功"),!0}catch(s){console.warn("通过setStyle修改颜色失败,尝试直接修改实体:",s)}const t=this.selectedEntityObj.getEntity();if(!t)return!1;let n;try{n=this.Cesium.Color.fromCssColorString(e)}catch(s){console.warn("Invalid color format:",e,s),n=e}if(t.polyline)try{t.polyline.material=new this.Cesium.ColorMaterialProperty(n)}catch{t.polyline.material=n}else if(t.polygon)try{t.polygon.material=new this.Cesium.ColorMaterialProperty(n)}catch{t.polygon.material=n}else if(t.rectangle){const s=t.rectangle.outline,o=t.rectangle.outlineWidth;try{t.rectangle.material=new this.Cesium.ColorMaterialProperty(n)}catch{t.rectangle.material=n}t.rectangle.outlineColor=n,s!==void 0&&(t.rectangle.outline=s),o!==void 0&&(t.rectangle.outlineWidth=o)}else if(t.ellipse||t.circle){const s=t.ellipse||t.circle,o=s.outline,r=s.outlineColor,l=s.outlineWidth;s.material=n,o!==void 0&&(s.outline=o),r!==void 0&&(s.outlineColor=r),l!==void 0&&(s.outlineWidth=l)}return!0}catch(t){return console.error("changeEntityColor failed",t),!1}}changeColor(e){return this.changeEntityColor(e)}setLineWidth(e){if(!this.selectedEntityObj)return!1;const t=this.selectedEntityObj.getEntity();let n=2;if(typeof e=="number")n=e;else switch(e){case"thin":n=2;break;case"medium":n=4;break;case"thick":n=8;break}if(t.polyline)t.polyline.width=n;else if(t.polygon&&t.polygon.outline)t.polygon.outlineWidth=n;else if(t.rectangle&&t.rectangle.outline)t.rectangle.outlineWidth=n;else if((t.ellipse||t.circle)&&(t.ellipse?.outline||t.circle?.outline)){const s=t.ellipse||t.circle;s.outlineWidth=n}return!0}changeWidth(e){return this.setLineWidth(e)}deleteSelectedEntity(){if(!this.selectedEntityObj)return!1;if(typeof this.drawTool.removeOne=="function")this.drawTool.removeOne(this.selectedEntityObj);else if(typeof this.drawTool.remove=="function")this.drawTool.remove(this.selectedEntityObj);else return console.error("No remove method found on drawTool"),!1;return this.selectedEntityObj=null,this.hideEntityOutline(),!0}}class tl{viewer;cesium;handler=null;measureEntities=[];originalDoubleClickAction=null;onMeasure=()=>{};activePoints=[];floatingPoint=null;activeShape=null;type=null;unit="m";cursorPosition=null;isSnapping=!1;snapIndicator=null;constructor({viewer:e,cesium:t}){this.viewer=e,this.cesium=t;const n=this.cesium;this.originalDoubleClickAction=this.viewer.screenSpaceEventHandler.getInputAction(n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.viewer.screenSpaceEventHandler.removeInputAction(n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}setUnit(e){this.unit=e}setSnapping(e){this.isSnapping=e,!e&&this.snapIndicator&&(this.viewer.entities.remove(this.snapIndicator),this.snapIndicator=null)}start(e){const t=this.cesium;this.clearActive(),this.type=e,this.handler=new t.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.handler.setInputAction(n=>{const s=this.getPickPosition(n.position);s&&this.addPoint(s)},t.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{const s=this.getPickPosition(n.endPosition);s&&(this.cursorPosition=s,this.updateFloatingPoint(s))},t.ScreenSpaceEventType.MOUSE_MOVE),this.type==="area"&&this.handler.setInputAction(()=>{this.finish()},t.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}addPoint(e){const t=this.cesium;this.activePoints.push(e);const n=this.viewer.entities.add({position:e,point:{pixelSize:8,color:t.Color.YELLOW,outlineColor:t.Color.BLACK,outlineWidth:2,disableDepthTestDistance:Number.POSITIVE_INFINITY}});if(this.measureEntities.push(n),this.type==="distance"){if(this.activePoints.length===1)this.onMeasure(null),this.activeShape=this.viewer.entities.add({polyline:{positions:new t.CallbackProperty(()=>{if(this.activePoints.length===0)return[];const s=[...this.activePoints];return this.cursorPosition&&s.push(this.cursorPosition),s},!1),width:2,material:t.Color.YELLOW,depthFailMaterial:t.Color.YELLOW}}),this.measureEntities.push(this.activeShape);else if(this.activePoints.length===2){const s=this.activePoints[0],o=this.activePoints[1];this.activeShape&&(this.viewer.entities.remove(this.activeShape),this.activeShape=null);const r=this.viewer.entities.add({polyline:{positions:[s,o],width:2,material:t.Color.YELLOW,depthFailMaterial:t.Color.YELLOW}});this.measureEntities.push(r);const l=t.Cartesian3.distance(s,o),a=t.Cartesian3.midpoint(s,o,new t.Cartesian3);this.addLabel(a,this.formatDistance(l));const d=t.Transforms.eastNorthUpToFixedFrame(s),h=t.Matrix4.inverse(d,new t.Matrix4),p=t.Matrix4.multiplyByPoint(h,o,new t.Cartesian3),f=p.x,u=p.y,m=p.z,E=t.Matrix4.getColumn(d,0,new t.Cartesian3),A=t.Matrix4.getColumn(d,1,new t.Cartesian3),y=t.Cartesian3.multiplyByScalar(E,f,new t.Cartesian3),v=t.Cartesian3.add(s,y,new t.Cartesian3),S=t.Cartesian3.multiplyByScalar(A,u,new t.Cartesian3),M=t.Cartesian3.add(v,S,new t.Cartesian3);if(this.viewer.scene.mode!==t.SceneMode.SCENE2D){const O=this.viewer.entities.add({polyline:{positions:[s,v],width:2,material:new t.PolylineDashMaterialProperty({color:t.Color.RED}),depthFailMaterial:new t.PolylineDashMaterialProperty({color:new t.Color(1,0,0,.5)})}}),I=this.viewer.entities.add({polyline:{positions:[v,M],width:2,material:new t.PolylineDashMaterialProperty({color:t.Color.GREEN}),depthFailMaterial:new t.PolylineDashMaterialProperty({color:new t.Color(0,1,0,.5)})}}),B=this.viewer.entities.add({polyline:{positions:[M,o],width:2,material:new t.PolylineDashMaterialProperty({color:t.Color.BLUE}),depthFailMaterial:new t.PolylineDashMaterialProperty({color:new t.Color(0,0,1,.5)})}});this.measureEntities.push(O,I,B)}this.onMeasure({type:"distance",dx:f,dy:u,dz:m,dist:l}),this.activePoints=[]}}else if(this.type==="angle"){if(this.activePoints.length===1)this.onMeasure(null);else if(this.activePoints.length===2)this.activeShape=this.viewer.entities.add({polyline:{positions:new t.CallbackProperty(()=>{if(this.activePoints.length<2)return[];const s=[...this.activePoints];return this.cursorPosition&&s.push(this.cursorPosition),s},!1),width:2,material:t.Color.YELLOW,depthFailMaterial:t.Color.YELLOW}}),this.measureEntities.push(this.activeShape);else if(this.activePoints.length===3){const s=this.activePoints[0],o=this.activePoints[1],r=this.activePoints[2];if(this.activeShape){this.viewer.entities.remove(this.activeShape);const a=this.viewer.entities.add({polyline:{positions:[s,o,r],width:2,material:t.Color.YELLOW,depthFailMaterial:t.Color.YELLOW}});this.measureEntities.push(a)}const l=this.calculateAngle(s,o,r);this.addLabel(o,`${l.toFixed(1)}°`),this.onMeasure({type:"angle",angle:l}),this.finish()}}else this.type==="area"&&this.activePoints.length===1&&(this.onMeasure(null),this.activeShape=this.viewer.entities.add({polygon:{hierarchy:new t.CallbackProperty(()=>{if(this.activePoints.length===0)return new t.PolygonHierarchy([]);const s=[...this.activePoints];return this.cursorPosition&&s.push(this.cursorPosition),new t.PolygonHierarchy(s)},!1),material:t.Color.YELLOW.withAlpha(.3),perPositionHeight:!0,outline:!0,outlineColor:t.Color.YELLOW,outlineWidth:2},polyline:{positions:new t.CallbackProperty(()=>{const s=[...this.activePoints];return this.cursorPosition&&(s.push(this.cursorPosition),s.push(s[0])),s},!1),width:2,material:t.Color.YELLOW,depthFailMaterial:t.Color.YELLOW,clampToGround:!1}}),this.measureEntities.push(this.activeShape))}updateFloatingPoint(e){const t=this.cesium;this.floatingPoint||(this.floatingPoint=this.viewer.entities.add({position:new t.CallbackProperty(()=>this.cursorPosition,!1),point:{pixelSize:5,color:t.Color.RED,disableDepthTestDistance:Number.POSITIVE_INFINITY}}))}finish(){const e=this.cesium;if(this.type==="distance"&&this.activePoints.length>1){let t=0;for(let s=0;s<this.activePoints.length-1;s++)t+=e.Cartesian3.distance(this.activePoints[s],this.activePoints[s+1]);const n=this.activePoints[this.activePoints.length-1];this.addLabel(n,`Total: ${this.formatDistance(t)}`)}else if(this.type==="area"&&this.activePoints.length>=3){const t=this.calculateArea(this.activePoints),n=this.calculateCenter(this.activePoints);this.addLabel(n,`面积: ${this.formatArea(t)}`),this.onMeasure({type:"area",area:t})}this.clearActive()}clearAll(){this.clear(),this.onMeasure(null)}clear(){this.clearActive(),this.measureEntities.forEach(e=>this.viewer.entities.remove(e)),this.measureEntities=[]}stop(){this.clearActive(),this.onMeasure(null)}destroy(){if(this.clear(),this.originalDoubleClickAction){const e=this.cesium;this.viewer.screenSpaceEventHandler.setInputAction(this.originalDoubleClickAction,e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.originalDoubleClickAction=null}}clearActive(){const e=this.cesium;if(this.handler&&(this.handler.destroy(),this.handler=null),this.floatingPoint&&(this.viewer.entities.remove(this.floatingPoint),this.floatingPoint=null),this.snapIndicator&&(this.viewer.entities.remove(this.snapIndicator),this.snapIndicator=null),this.activeShape){if(this.type==="distance"){const t=[...this.activePoints];this.viewer.entities.remove(this.activeShape);const n=this.viewer.entities.add({polyline:{positions:t,width:2,material:e.Color.YELLOW,depthFailMaterial:e.Color.YELLOW}});this.measureEntities.push(n)}else if(this.type==="area"){const t=[...this.activePoints];this.viewer.entities.remove(this.activeShape);const n=this.viewer.entities.add({polygon:{hierarchy:new e.PolygonHierarchy(t),material:e.Color.YELLOW.withAlpha(.3),perPositionHeight:!0,outline:!0,outlineColor:e.Color.YELLOW,outlineWidth:2},polyline:{positions:[...t,t[0]],width:2,material:e.Color.YELLOW,depthFailMaterial:e.Color.YELLOW}});this.measureEntities.push(n)}this.activeShape=null}this.activePoints=[],this.type=null,this.cursorPosition=null}getPickPosition(e){const t=this.cesium;let n;try{n=this.viewer.scene.pickPosition(e)}catch{}if(!n||!t.defined(n)){const s=this.viewer.camera.getPickRay(e);s&&(n=this.viewer.scene.globe.pick(s,this.viewer.scene))}if((!n||!t.defined(n))&&(n=this.viewer.scene.camera.pickEllipsoid(e,this.viewer.scene.globe.ellipsoid)),!n||!t.defined(n))return null;if(this.isSnapping){const s=this.snapToVertex(e);if(s)n=s;else{const o=this.snapTo3DTileFeature(e);o&&(n=o)}}return this.isSnapping&&(this.snapIndicator||(this.snapIndicator=this.viewer.entities.add({position:new t.CallbackProperty(()=>this.cursorPosition,!1),point:{pixelSize:10,color:t.Color.GREEN.withAlpha(.5),outlineColor:t.Color.GREEN,outlineWidth:2,disableDepthTestDistance:Number.POSITIVE_INFINITY}}))),n}snapTo3DTileFeature(e){const t=this.cesium,n=10,s=[{x:0,y:0},{x:-n,y:0},{x:n,y:0},{x:0,y:-n},{x:0,y:n},{x:-n,y:-n},{x:n,y:-n},{x:-n,y:n},{x:n,y:n}];for(let o=0;o<s.length;o++){const r=s[o];if(!r)continue;const l=new t.Cartesian2(e.x+r.x,e.y+r.y);let a=null;try{a=this.viewer.scene.pick(l)}catch{}if(t.defined(a)&&(a instanceof t.Cesium3DTileFeature||a.primitive&&a.primitive instanceof t.PointPrimitive))try{const d=this.viewer.scene.pickPosition(l);if(d)return d}catch{}}return null}snapToVertex(e){const t=this.cesium,n=this.viewer.entities.values;let s=20,o=null;for(let r=0;r<n.length;r++){const l=n[r];if(!l.show)continue;let a=[];if(l.polyline&&l.polyline.positions){const d=l.polyline.positions.getValue(t.JulianDate.now());d&&(a=d)}else if(l.polygon&&l.polygon.hierarchy){const d=l.polygon.hierarchy.getValue(t.JulianDate.now());d&&d.positions&&(a=d.positions)}else if(l.position){const d=l.position.getValue(t.JulianDate.now());d&&(a=[d])}else if(l.rectangle&&l.rectangle.coordinates){const d=l.rectangle.coordinates.getValue(t.JulianDate.now());d&&(a=[t.Cartesian3.fromRadians(d.west,d.south),t.Cartesian3.fromRadians(d.east,d.south),t.Cartesian3.fromRadians(d.east,d.north),t.Cartesian3.fromRadians(d.west,d.north)])}for(let d=0;d<a.length;d++){const h=a[d];try{const p=this.viewer.scene.cartesianToCanvasCoordinates(h);if(p){const f=t.Cartesian2.distance(p,e);f<s&&(s=f,o=h)}}catch{}}}return o}addLabel(e,t){const n=this.cesium,s=this.viewer.entities.add({position:e,label:{text:t,font:"14px sans-serif",fillColor:n.Color.WHITE,style:n.LabelStyle.FILL_AND_OUTLINE,outlineWidth:2,verticalOrigin:n.VerticalOrigin.BOTTOM,pixelOffset:new n.Cartesian2(0,-10),disableDepthTestDistance:Number.POSITIVE_INFINITY,showBackground:!0,backgroundColor:new n.Color(0,0,0,.5)}});this.measureEntities.push(s)}formatDistance(e){return this.unit==="mm"?`${(e*1e3).toFixed(0)}mm`:this.unit==="cm"?`${(e*100).toFixed(1)}cm`:`${e.toFixed(2)}m`}calculateAngle(e,t,n){const s=this.cesium,o=s.Cartesian3.subtract(e,t,new s.Cartesian3),r=s.Cartesian3.subtract(n,t,new s.Cartesian3);s.Cartesian3.normalize(o,o),s.Cartesian3.normalize(r,r);const l=s.Cartesian3.dot(o,r),a=Math.max(-1,Math.min(1,l)),d=Math.acos(a);return s.Math.toDegrees(d)}calculateArea(e){const t=this.cesium;if(e.length<3)return 0;const n=e[0],s=new t.Cartesian3(0,0,0);for(let o=1;o<e.length-1;o++){const r=e[o],l=e[o+1],a=t.Cartesian3.subtract(r,n,new t.Cartesian3),d=t.Cartesian3.subtract(l,n,new t.Cartesian3),h=t.Cartesian3.cross(a,d,new t.Cartesian3);t.Cartesian3.add(s,h,s)}return t.Cartesian3.magnitude(s)*.5}calculateCenter(e){const t=this.cesium;if(!e||e.length===0)return null;let n=0,s=0,o=0;for(let r=0;r<e.length;r++)n+=e[r].x,s+=e[r].y,o+=e[r].z;return new t.Cartesian3(n/e.length,s/e.length,o/e.length)}formatArea(e){return e>1e6?`${(e/1e6).toFixed(2)} km²`:`${e.toFixed(2)} m²`}}class ly{cesium;viewer;events=new Gi;lastBaseMapRequestId=0;_removeCameraLockListener=null;currentMode="3d";defaultMapBound={minLon:-180,maxLon:180,minLat:-90,maxLat:90};constructor(e){this.cesium=e.cesium,this.viewer=e.viewer}get is2d(){return this.currentMode==="2d"}setGlobeEnvironmentVisible(e){if(this.is2d){this.viewer.scene.globe.show=e,this.viewer.scene.globe.showGroundAtmosphere=!1,this.viewer.scene.skyAtmosphere.show=!1,this.viewer.scene.sun.show=!1,this.viewer.scene.moon.show=!1,this.viewer.scene.skyBox.show=!1;return}const{scene:t}=this.viewer;t.globe&&(t.globe.show=e,t.globe.showGroundAtmosphere=e,e||(t.globe.depthTestAgainstTerrain=!1)),t.skyAtmosphere&&(t.skyAtmosphere.show=e),t.sun&&(t.sun.show=e),t.moon&&(t.moon.show=e),t.skyBox&&(t.skyBox.show=e)}setGlobeColor(e){const t=this.cesium.Color.fromCssColorString(e);t&&(this.viewer.scene.backgroundColor=t,this.viewer.scene.globe.baseColor=t)}setBackgroundColor(e){const t=this.viewer.container;t&&(t.style.background=e);try{const n=this.cesium.Color.fromCssColorString(e);n?(this.viewer.scene.backgroundColor=n,this.viewer.scene.globe.baseColor=n):(this.viewer.scene.backgroundColor=this.cesium.Color.TRANSPARENT,this.viewer.scene.globe.baseColor=this.cesium.Color.TRANSPARENT)}catch{this.viewer.scene.backgroundColor=this.cesium.Color.TRANSPARENT,this.viewer.scene.globe.baseColor=this.cesium.Color.TRANSPARENT}}async setTerrainEnable(e){if(!(this.is2d&&e))if(e)try{const t=this.cesium.ArcGISTiledElevationTerrainProvider.fromUrl("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"),n=new Promise((s,o)=>setTimeout(()=>o(new Error("ArcGIS Terrain request timed out")),5e3));this.viewer.terrainProvider=await Promise.race([t,n])}catch(t){console.warn("Failed to load ArcGIS terrain (or timed out), trying Cesium World Terrain...",t);try{this.cesium.Terrain&&this.cesium.Terrain.fromWorldTerrain?this.viewer.terrainProvider=await this.cesium.Terrain.fromWorldTerrain({requestWaterMask:!0,requestVertexNormals:!0}):this.viewer.terrainProvider=this.cesium.createWorldTerrain({requestWaterMask:!0,requestVertexNormals:!0})}catch(n){console.error("Failed to enable terrain (both ArcGIS and Ion failed):",n),this.viewer.terrainProvider=new this.cesium.EllipsoidTerrainProvider}}else this.viewer.terrainProvider=new this.cesium.EllipsoidTerrainProvider}setDepthTestEnable(e){if(!this.viewer.scene.globe.show){this.viewer.scene.globe.depthTestAgainstTerrain=!1;return}this.viewer.scene.globe.depthTestAgainstTerrain=e}setCadMode(e){this.currentMode!==e&&(this.currentMode=e,this.is2d?this._enable2DMode():this._enable3DMode())}_enable2DMode(){const e=this.cesium,t=this.viewer.scene;this.setGlobeEnvironmentVisible(!0);const n=t.screenSpaceCameraController;this.setBackgroundColor("#000000"),this.setGlobeColor("#000000"),this.viewer.imageryLayers.removeAll(),n.enableZoomInertia=!0,n.minimumZoomDistance=1,n.maximumZoomDistance=1e6,n.enableTilt=!1,n.enableLook=!1,n.enableCollisionDetection=!1,this.viewer.camera.setView({orientation:{heading:0,pitch:e.Math.toRadians(-90),roll:0}}),this._removeCameraLockListener&&(this._removeCameraLockListener(),this._removeCameraLockListener=null);const s=()=>{const o=this.viewer.camera,r=e.Math.EPSILON3,l=0,a=e.Math.toRadians(-90),d=0,h=Math.abs(o.heading-l);((h>Math.PI?Math.abs(h-2*Math.PI):h)>r||Math.abs(o.pitch-a)>r||Math.abs(o.roll-d)>r)&&o.setView({orientation:{heading:l,pitch:a,roll:d}})};this._removeCameraLockListener=this.viewer.scene.postRender.addEventListener(s),this.setCollisionDetection(!1),this.setHeightBasedZoom(!0)}_enable3DMode(){this._removeCameraLockListener&&(this._removeCameraLockListener(),this._removeCameraLockListener=null);const e=this.viewer.scene.screenSpaceCameraController;e.enableRotate=!0,e.enableTilt=!0,e.enableLook=!0,this.viewer.scene.morphTo3D(0),this.setMouseHabit(0),this.setCollisionDetection(!0),this.viewer.scene.screenSpaceCameraController.minimumZoomDistance=1,this.setHeightBasedZoom(!1)}async changeBaseMap(e,t){if(this.is2d){this.viewer.imageryLayers.removeAll();return}const n=Date.now();this.lastBaseMapRequestId=n;const s=this.viewer.imageryLayers,o=[];if(e==="tianditu"){const r=t?.token||"c25f14fb6bd4397cf8fe45144ff768d6",l=t?.layerType||"img_w",a=l.split("_"),d=a[0]||"img",h=a[1]||"w";let p="";d==="img"?p="cia":d==="vec"?p="cva":d==="ter"&&(p="cta");const f=p?`${p}_${h}`:"";o.push(new this.cesium.WebMapTileServiceImageryProvider({url:`https://{s}.tianditu.gov.cn/${l}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${d}&STYLE=default&TILEMATRIXSET=${h}&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=${r}`,layer:d,style:"default",format:"tiles",tileMatrixSetID:h,maximumLevel:18,subdomains:["t0","t1","t2","t3","t4","t5","t6","t7"]})),t.showAnnotation!==!1&&f&&o.push(new this.cesium.WebMapTileServiceImageryProvider({url:`https://{s}.tianditu.gov.cn/${f}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${p}&STYLE=default&TILEMATRIXSET=${h}&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=${r}`,layer:p,style:"default",format:"tiles",tileMatrixSetID:h,maximumLevel:18,subdomains:["t0","t1","t2","t3","t4","t5","t6","t7"]}))}else if(e==="arcgis"){console.log("Switching to ArcGIS...");const r=t?.url||"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer";try{if(this.cesium.ArcGisMapServerImageryProvider.fromUrl){const l=this.cesium.ArcGisMapServerImageryProvider.fromUrl(r,{enablePickFeatures:!1}),a=new Promise((h,p)=>setTimeout(()=>p(new Error("ArcGIS metadata request timed out")),3e3)),d=await Promise.race([l,a]);o.push(d)}else o.push(new this.cesium.ArcGisMapServerImageryProvider({url:r,enablePickFeatures:!1}))}catch(l){console.warn("ArcGIS provider failed (or timed out), fallback to XYZ template",l),o.push(new this.cesium.UrlTemplateImageryProvider({url:`${r}/tile/{z}/{y}/{x}`,maximumLevel:19,credit:"ArcGIS Layer"}))}}else if(e==="tianditu_img")return this.changeBaseMap("tianditu",{...t,layerType:"img_w"});if(this.lastBaseMapRequestId!==n){console.log("BaseMap switch cancelled due to new request.");return}s.removeAll(),o.forEach(r=>s.addImageryProvider(r))}async searchLocation(e,t){if(!e)return null;if(!t)throw new Error("缺少天地图 Token");const s=JSON.stringify({keyWord:e,level:12,mapBound:"-180,-90,180,90",queryType:1,start:0,count:10}),o=`https://api.tianditu.gov.cn/v2/search?postStr=${encodeURIComponent(s)}&type=query&tk=${encodeURIComponent(t)}`,r=await fetch(o);if(!r.ok)throw new Error(`HTTP ${r.status}`);return await r.json()}setShadowsEnable(e){this.is2d||(this.viewer.shadows=e,this.viewer.terrainShadows=e?this.cesium.ShadowMode.ENABLED:this.cesium.ShadowMode.DISABLED,this.viewer.shadowMap&&(this._shadowDarkness===void 0?this.viewer.shadowMap.darkness=e?.7:.3:this.viewer.shadowMap.darkness=this._shadowDarkness))}_shadowDarkness;setShadowDarkness(e){this.is2d||(this._shadowDarkness=e,this.viewer.shadowMap&&(this.viewer.shadowMap.darkness=e))}setTime(e){if(this.is2d)return;let t;if(e instanceof Date)t=e;else{const s=this.cesium.JulianDate.now();t=this.cesium.JulianDate.toDate(s),t.setHours(e),t.setMinutes(0),t.setSeconds(0)}const n=this.cesium.JulianDate.fromDate(t);this.viewer.clock.currentTime=n}setModelColorAdjustment(e){if(this.is2d)return;const t=this.viewer,n=this.cesium;if(!t||!t.scene)return;const s=e.brightness!==void 0?e.brightness:1,o=e.contrast!==void 0?e.contrast:1,r=e.saturation!==void 0?e.saturation:1,l=t.scene.primitives,a=l.length,d=!!n.CustomShader;for(let h=0;h<a;++h){const p=l.get(h);if(p instanceof n.Cesium3DTileset)if(d)if(p.customShader&&p.customShader.isModelAdjustment)e.brightness!==void 0&&p.customShader.setUniform("u_brightness",s),e.contrast!==void 0&&p.customShader.setUniform("u_contrast",o),e.saturation!==void 0&&p.customShader.setUniform("u_saturation",r);else{const f=new n.CustomShader({uniforms:{u_brightness:{type:n.UniformType.FLOAT,value:s},u_contrast:{type:n.UniformType.FLOAT,value:o},u_saturation:{type:n.UniformType.FLOAT,value:r}},fragmentShaderText:`
29
+ `;this.promptDiv=window.document.createElement("div"),this.promptDiv.className=`easy3d-prompt ${this.opt.className}`,this.promptDiv.id=p,this.promptDiv.innerHTML=f,window.document.getElementById(o).appendChild(this.promptDiv);const m=window.document.getElementById(`prompt-close-${this.opt.id}`);let E=this;m&&m.addEventListener("click",A=>{E.hide(),E.opt.close&&E.opt.close()}),this.promptDom=window.document.getElementById(p),this.position=this.transPosition(this.opt.position),n==2&&this.bindRender(),this.opt.show==!1&&this.hide(),this.containerW=this.viewer.container.offsetWidth,this.containerH=this.viewer.container.offsetHeight,this.containerLeft=this.viewer.container.offsetLeft,this.containerTop=this.viewer.container.offsetTop,this.contentW=Math.ceil(Number(this.promptDom.offsetWidth)),this.contentH=this.promptDom.offsetHeight,this.opt.success&&this.opt.success()}destroy(){this.promptDiv&&(window.document.getElementById(this.viewer.container.id).removeChild(this.promptDiv),this.promptDiv=null),this.rendHandler&&(this.rendHandler(),this.rendHandler=null)}bindRender(){let e=this;this.rendHandler=this.viewer.scene.postRender.addEventListener(function(){if(!e.isShow&&e.promptDom){e.promptDom.style.display="none";return}if(e.position)if(e.position instanceof Cesium.Cartesian3){let t=Cesium.SceneTransforms.wgs84ToWindowCoordinates(e.viewer.scene,e.position);if(!t)return;new Cesium.EllipsoidalOccluder(e.viewer.scene.globe.ellipsoid,e.viewer.scene.camera.position).isPointVisible(e.position)?e.promptDom&&(e.promptDom.style.display="block"):e.promptDom&&(e.promptDom.style.display="none"),e.setByPX({x:t.x,y:t.y})}else e.setByPX({x:e.position.x,y:e.position.y})},this)}update(e,t){e instanceof Cesium.Cartesian3&&(this.position=e.clone(),e=Cesium.SceneTransforms.wgs84ToWindowCoordinates(this.viewer.scene,e)),this.contentW=Math.ceil(Number(this.promptDom.offsetWidth)),this.contentH=this.promptDom.offsetHeight,e&&this.setByPX(e),t&&this.setContent(t)}isInView(){if(!this.position)return!1;let e=null;this.position instanceof Cesium.Cartesian2?e=this.position:e=Cesium.SceneTransforms.wgs84ToWindowCoordinates(this.viewer.scene,this.position);const n=new Cesium.EllipsoidalOccluder(this.viewer.scene.globe.ellipsoid,this.viewer.scene.camera.position).isPointVisible(this.position);let s=!1;return e?(e.x>this.containerLeft&&e.x<this.containerLeft+this.containerW&&e.y>this.containerTop&&e.y<this.containerTop+this.containerH&&(s=!0),n&&s):s}setVisible(e){this.isInView(this.position)&&e?(this.isShow=!0,this.promptDom&&(this.promptDom.style.display="block")):(this.isShow=!1,this.promptDom&&(this.promptDom.style.display="none"))}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}setContent(e){let t=window.document.getElementById(`prompt-content-${this.opt.id}`);t.innerHTML=e}setByPX(e){e&&this.promptDom&&(this.promptDom.offsetWidth,this.promptDom.offsetHeight,this.opt.type==1?(this.promptDom.style.left=Number(e.x)+Number(this.opt.offset.x||0)+"px",this.promptDom.style.top=Number(e.y)+Number(this.opt.offset.y||0)+"px"):(this.promptDom.style.left=Number(e.x)+Number(this.opt.offset.x||0)-Number(this.contentW)/2+"px",this.promptDom.style.top=Number(e.y)+Number(this.opt.offset.y||0)-Number(this.contentH)+"px"))}transPosition(e){let t;return Array.isArray(e)?t=Cesium.Cartesian3.fromDegrees(e[0],e[1],e[2]||0).clone():e instanceof Cesium.Cartesian3?t=e.clone():t=e,t}}const Rr=Object.freeze(Object.defineProperty({__proto__:null,default:at},Symbol.toStringTag,{value:"Module"}));let se={};se.cartesianToLnglat=function(i,e){if(!i)return[];var t=Cesium.Cartographic.fromCartesian(i),n=Cesium.Math.toDegrees(t.latitude),s=Cesium.Math.toDegrees(t.longitude),o=t.height;return[s,n,o]},se.getViewCenter=i=>{if(i){var e=i.camera.computeViewRectangle(),t=e.west/Math.PI*180,n=e.north/Math.PI*180,s=e.east/Math.PI*180,o=e.south/Math.PI*180;return[(s+t)/2,(n+o)/2]}},se.cartesiansToLnglats=function(i,e){if(!(!i||i.length<1)){if(e=e||window.viewer,!e){console.log("util.cartesiansToLnglats方法缺少viewer对象");return}for(var t=[],n=0;n<i.length;n++)t.push(se.cartesianToLnglat(i[n],e));return t}},se.lnglatsToCartesians=function(i){if(!(!i||i.length<1)){for(var e=[],t=0;t<i.length;t++){var n=Cesium.Cartesian3.fromDegrees(i[t][0],i[t][1],i[t][2]||0);e.push(n)}return e}},se.flyTo=function(i,e){if(!e){console.log("util.flyTo缺少viewer对象");return}i=i||{};let t=i.center;if(!t){console.log("缺少定位坐标!");return}if(t instanceof Cesium.Cartesian3&&e.camera.flyToBoundingSphere(new Cesium.BoundingSphere(t),{offset:new Cesium.HeadingPitchRange(Cesium.Math.toRadians(i.heading||0),Cesium.Math.toRadians(i.pitch||-60),i.range||1e4)}),t instanceof Array){var n=new Cesium.BoundingSphere(Cesium.Cartesian3.fromDegrees(t[0],t[1],t[2]));e.camera.flyToBoundingSphere(n,{offset:new Cesium.HeadingPitchRange(Cesium.Math.toRadians(i.heading||0),Cesium.Math.toRadians(i.pitch||-60),i.range||1e4)})}},se.getCameraView=function(i){if(i=i||window.viewer,!i){console.log("util.getCameraView缺少viewer对象");return}var e=i.camera,t=e.position,n=e.heading,s=e.pitch,o=e.roll,r=Cesium.Cartographic.fromCartesian(t),l={x:Cesium.Math.toDegrees(r.longitude),y:Cesium.Math.toDegrees(r.latitude),z:r.height,heading:Cesium.Math.toDegrees(n),pitch:Cesium.Math.toDegrees(s),roll:Cesium.Math.toDegrees(o)};return l},se.setCameraView=function(i,e){if(e=e||window.viewer,!e){console.log("util.setCameraView缺少viewer对象");return}if(i){var t=i.destination||Cesium.Cartesian3.fromDegrees(i.x,i.y,i.z);e.camera.flyTo({destination:t,orientation:{heading:Cesium.Math.toRadians(i.heading||0),pitch:Cesium.Math.toRadians(i.pitch||0),roll:Cesium.Math.toRadians(i.roll||0)},duration:i.duration===void 0?3:i.duration,complete:i.complete})}},se.computeAreaOfTriangle=function(i,e,t){if(!i||!e||!t)return console.log("传入坐标有误!"),0;var n=Cesium.Cartesian3.distance(i,e),s=Cesium.Cartesian3.distance(e,t),o=Cesium.Cartesian3.distance(t,i),r=(n+s+o)/2;return Math.sqrt(r*(r-n)*(r-s)*(r-o))};class Ke{constructor(e,t){this.viewer=e,this.style=t||{},this.objId=+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0)),this.handler=void 0,this.modifyHandler=void 0,this.type="",this.positions=[],this.state=null,this.prompt=null,this.controlPoints=[],this.modifyPoint=null,this.entity=null,this.pointStyle={},this.promptStyle=this.style.prompt||{show:!0},this.properties={},this.clientScale=1}getCatesian3FromPX(e){if(e=this.transpx(e),this.viewer.scene.mode===Cesium.SceneMode.SCENE2D){let o=this.viewer.camera.getPickRay(e),r=null;return o&&(r=this.viewer.scene.globe.pick(o,this.viewer.scene)),r||(r=this.viewer.camera.pickEllipsoid(e,this.viewer.scene.globe.ellipsoid)),r}let t=this.viewer.scene.drillPick(e);this.viewer.scene.render();let n,s=!1;for(let o=0;o<t.length;o++)if(t[o]&&t[o].primitive&&t[o].primitive instanceof Cesium.Cesium3DTileset){s=!0;break}if(s)n=this.viewer.scene.pickPosition(e);else{let o=this.viewer.camera.getPickRay(e);if(!o)return null;n=this.viewer.scene.globe.pick(o,this.viewer.scene)}return n}setClientScale(e){e=e||1,this.clientScale=e}transpx(e){return{x:e.x/(this.clientScale||1),y:e.y/(this.clientScale||1)}}getEntity(){return this.entity}getPositions(e){return e?se.cartesiansToLnglats(this.positions,this.viewer):this.positions}getLnglats(){return se.cartesiansToLnglats(this.positions,this.viewer)}setOwnProp(e){this.entity&&(this.entity.ownProp=e)}remove(){this.entity&&(this.state="no",this.viewer.entities.remove(this.entity),this.entity=null)}setVisible(e){this.entity&&(this.entity.show=e)}forbidDrawWorld(e){this.viewer.scene.screenSpaceCameraController.enableRotate=!e,this.viewer.scene.screenSpaceCameraController.enableTilt=!e,this.viewer.scene.screenSpaceCameraController.enableTranslate=!e,this.viewer.scene.screenSpaceCameraController.enableInputs=!e}destroy(){this.handler&&(this.handler.destroy(),this.handler=null),this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.positions=[],this.style=null;for(var e=0;e<this.controlPoints.length;e++){var t=this.controlPoints[e];this.viewer.entities.remove(t)}this.controlPoints=[],this.modifyPoint=null,this.prompt&&(this.prompt.destroy(),this.prompt=null),this.state="no",this.forbidDrawWorld(!1)}startEdit(e){if(this.state=="startEdit"||this.state=="editing"||!this.entity)return;this.state="startEdit",this.modifyHandler||(this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));let t=this;for(let n=0;n<t.controlPoints.length;n++){let s=t.controlPoints[n];s&&(s.show=!0)}this.entity.show=!0,this.modifyHandler.setInputAction(function(n){if(!t.entity)return;let s=t.viewer.scene.pick(n.position);Cesium.defined(s)&&s.id&&(s.id.objId||(t.modifyPoint=s.id),t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(n){if(t.positions.length<1||!t.modifyPoint)return;let s=t.getCatesian3FromPX(n.endPosition,t.viewer,[t.entity,t.modifyPoint]);s&&(t.modifyPoint.position.setValue(s),t.positions[t.modifyPoint.wz]=s,t.state="editing",e&&e())},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(n){t.modifyPoint&&(t.modifyPoint=null,t.forbidDrawWorld(!1),t.state="editing")},Cesium.ScreenSpaceEventType.LEFT_UP)}endEdit(e){for(let t=0;t<this.controlPoints.length;t++){let n=this.controlPoints[t];n&&(n.show=!1)}this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null,e&&e(this.entity)),this.forbidDrawWorld(!1),this.state="endEdit"}endCreate(){}done(){}createPoint(e){if(!e)return;this.pointStyle.color=this.pointStyle.color||Cesium.Color.CORNFLOWERBLUE,this.pointStyle.outlineColor=this.pointStyle.color||Cesium.Color.CORNFLOWERBLUE;let t=this.pointStyle.color instanceof Cesium.Color?this.pointStyle.color:Cesium.Color.fromCssColorString(this.pointStyle.color);t=t.withAlpha(this.pointStyle.colorAlpha||1);let n=this.pointStyle.outlineColor instanceof Cesium.Color?this.pointStyle.outlineColor:Cesium.Color.fromCssColorString(this.pointStyle.outlineColor);return n=n.withAlpha(this.pointStyle.outlineColorAlpha||1),this.viewer.entities.add({position:e,point:{pixelSize:this.pointStyle.property||10,color:t,outlineWidth:this.pointStyle.outlineWidth||0,outlineColor:n,disableDepthTestDistance:Number.POSITIVE_INFINITY},show:!1})}transfromLineMaterial(e){if(!e)return;let t={};if(e instanceof Cesium.Color){let n=e.color.getValue();t.colorAlpha=n.alpha,t.colorHex=new Cesium.Color(n.red,n.green,n.blue,1).toCssHexString()}return t}transfromGonMaterial(e){if(!e)return;let t={};if(e instanceof Cesium.Color){let n=e.color.getValue();t.colorAlpha=n.alpha,t.colorHex=new Cesium.Color(n.red,n.green,n.blue,1).toCssHexString()}return t}setAttr(e){this.properties.attr=e||{}}getAttr(){return this.properties.attr}zoomTo(){this.entity&&this.viewer.zoomTo(this.entity)}}const Ep="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABHNCSVQICAgIfAhkiAAAAptJREFUOE+FVD1oU1EYvecVCU5acHFqsggKSlUcdDGZuvhToeAgYuIuaUcHMZ0c2+JuAg4dKrS6iFPiooMUAyqCS5PFTVpBKJKa4/nez817yateeOTm3vOd75zv3u/C5QySx50b3HMO89oupyBdzTvOHawBR3t5sRhfJH+tiqiu9X4UDJH80Tc169ywGCeZcY7CDZaB6b00hyckd6WKbW2WFLQoYCtPga0JW40I3Y6wt4T1alOE382OBuaBk7l20gnIHQkoyEFA5/YrQClUGhKS/YZ+FmVpVhuejNzXemhfwU4BWAUKywlxRBoYfguYkWohosXBruY14JS3Sf6Ik1CJpqRkaAe0ovSyeGJrRPrNiJr6ziu+K8LPCqBqdraYtdRPMms/GmRPxNiTGiP3g/ykcrELnKuKcNtAPeBCKHkU/EUKgw5wWvsJ4VcLFPbMGOG2HdBN4GJJhO9UVMju5VaacHxOfjClsux0AJd8kkj5+7LdEOAKRNgWoYEqGVBWbVvqoTpRiSsTicUhQidC0ZBvjFAXdE4WJwe5qUM7ovtmmGtmbWKQr0UYiHDOCF9JmdXwulTkgddj8O2JrkrQ5EuJQRW4URThhv2pAwvT+YTNotaLQO0fJXlhTaFTXrBTXlfA0CypPndy6vPU6nMVeOAvdDox+Tx0IA4V8G4n7pRnVht7XbRYi1swCiOfyIF7DDzMeUia1v8ftd8H7lvipPVs47dZOqb+1I2v+ReEbMSWGxnLZBgTPyYFK8molyMlK9aXpk6krgHU1/JqGmPN5qaipJplYMm7ytiISA9kn7LvevpVzwZSRmWnlAb6WNWeqX6r66SXacm78ZbHlahuChhaj1uL6TH146dmSsIW8ChTggRx6N06zO7/1v8CLeIaJJK0e+4AAAAASUVORK5CYII=";class wp extends Ke{constructor(e,t){super(e,t),this.type="billboard",this.viewer=e;let n={verticalOrigin:Cesium.VerticalOrigin.BOTTOM,scale:1};this.style=Object.assign({},n,t||{}),this.entity=null,this.style.hasOwnProperty("image")||console.warn("CreateBillboard: 未在 style 中指定 image,后续将使用回退图或占位图。"),this.position=null,this._defaultFallback=Ep,this.prompt=null,this.modifyHandler=null,this._globalMouseUpHandler=null,this._isDragging=!1,this._editPickedEntity=null,this.controlPoints=[],this.modifyPoint=null,this._isScaling=!1,this._fileInput=null}_preloadImage(e,t=7e3){return new Promise((n,s)=>{if(!e)return s(new Error("empty url"));try{const o=new window.Image;o.crossOrigin="anonymous";let r=!1;const l=()=>{r||(r=!0,clearTimeout(d),n(o))},a=h=>{r||(r=!0,clearTimeout(d),s(new Error("image load error: "+e)))};o.onload=l,o.onerror=a;const d=setTimeout(()=>{r||(r=!0,o.onload=o.onerror=null,s(new Error("image load timeout: "+e)))},t);o.src=e}catch(o){s(o)}})}createBillboard(e){if(!e)return;const t=this.style.fallbackImage||this._defaultFallback,n=this.viewer.entities.add({position:e,billboard:{image:t,scale:this.style.scale||1,pixelOffset:this.style.pixelOffset,heightReference:this.style.heightReference==null?Cesium.HeightReference.CLAMP_TO_GROUND:Number(this.style.heightReference),verticalOrigin:Cesium.VerticalOrigin.BOTTOM,color:this.style.color?this.style.color instanceof Cesium.Color?this.style.color.withAlpha(this.style.colorAlpha||1):Cesium.Color.fromCssColorString(this.style.color).withAlpha(this.style.colorAlpha||1):Cesium.Color.WHITE}});n.objId=this.objId;const s=this.style.image;if(s)this._preloadImage(s,7e3).then(o=>{try{n.billboard.image=o,this.style.image=s}catch(r){console.warn("CreateBillboard: set billboard image element failed, fallback to url string",r);try{n.billboard.image=s}catch{}}try{this.viewer.scene.requestRender()}catch{}}).catch(o=>{console.error("CreateBillboard: image load failed:",o.message," URL:",s," 使用回退图:",t);try{this.viewer.scene.requestRender()}catch{}});else try{this.viewer.scene.requestRender()}catch{}return this.position=e.clone(),this.entity=n,n}updateBillboardImage(e){if(!this.entity||!this.entity.billboard)return;const t=this.style.fallbackImage||this._defaultFallback;if(!e){try{this.entity.billboard.image=t}catch{}this.style.image=t;try{this.viewer.scene.requestRender()}catch{}return}try{this.entity.billboard.image=t}catch{}this._preloadImage(e,7e3).then(n=>{try{this.entity.billboard.image=n}catch(s){console.warn("CreateBillboard: set billboard image element failed, fallback to url string",s);try{this.entity.billboard.image=e}catch{}}this.style.image=e;try{this.viewer.scene.requestRender()}catch{}}).catch(n=>{console.error("CreateBillboard: updateBillboardImage failed to load:",n.message," URL:",e);try{this.entity.billboard.image=t}catch{}this.style.image=t;try{this.viewer.scene.requestRender()}catch{}})}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate";let t=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(n){let s=t.getCatesian3FromPX(n.position,t.viewer);if(s){if(t.position=s.clone(),t.entity=t.createBillboard(t.position),t.handler){try{t.handler.destroy()}catch{}t.handler=null}if(t.prompt){try{t.prompt.destroy()}catch{}t.prompt=null}t.state="endCreate",e&&e(t.entity)}},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){t.prompt&&t.prompt.update&&t.prompt.update(n.endPosition,"单击新增"),t.state="creating"},Cesium.ScreenSpaceEventType.MOUSE_MOVE)}endCreate(){let e=this;if(e.handler){try{e.handler.destroy()}catch{}e.handler=null}if(e.prompt){try{e.prompt.destroy()}catch{}e.prompt=null}e.state="endCreate"}done(){this.state=="startCreate"?this.destroy():this.state=="creating"?this.destroy():(this.state=="startEdit"||this.state=="editing")&&this.endEdit()}createByPositions(e,t){if(!e)return;this.state="startCreate";let n=null;e instanceof Cesium.Cartesian3?n=e.clone():n=Cesium.Cartesian3.fromDegrees(Number(e[0]),Number(e[1]),Number(e[2]||0)),n&&(this.position=n.clone(),this.entity=this.createBillboard(this.position),t&&t(this.entity),this.state="endCreate")}setStyle(e){if(!e)return;let t=this.entity&&this.entity.billboard;if(t){if(e.image!=null&&this.updateBillboardImage(e.image),e.heightReference!=null){let n=1;e.heightReference==!0?n=1:n=Number(e.heightReference);try{t.heightReference=n}catch{}}if(e.scale!=null)try{t.scale=Number(e.scale)}catch{}if(e.color){let n=e.color instanceof Cesium.Color?e.color:Cesium.Color.fromCssColorString(e.color);n=n.withAlpha(e.colorAlpha||1);try{t.color=n}catch{}}}this.style=Object.assign(this.style,e)}getStyle(){let e={},t=this.entity&&this.entity.billboard;if(e.image=this.style.image,t&&t.heightReference)try{let n=t.heightReference.getValue();e.heightReference=Number(n)}catch{}if(t&&t.scale)try{e.scale=t.scale.getValue()}catch{}if(t&&t.color)try{let n=t.color.getValue();e.colorAlpha=n.alpha,e.color=new Cesium.Color(n.red,n.green,n.blue,1).toCssHexString()}catch{}return e}startEdit(e){if(this._cleanupEditState(),!this.entity)return;this.state="startEdit",this.controlPoints=[],this.showControlPoints(),this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);let t=this,n=null,s=!1;const o=()=>{if(s){if(s=!1,t.entity&&Cesium.defined(t.entity.position))try{t.position=t.entity.position.getValue(Cesium.JulianDate.now()).clone()}catch(r){console.warn("更新位置引用失败:",r)}n=null,t._isDragging=!1,t._editPickedEntity=null,t.modifyPoint=null;try{t.forbidDrawWorld(!1)}catch{}t.state="editing"}};window.addEventListener("mouseup",o,!0),this._globalMouseUpHandler=o,this.modifyHandler.setInputAction(function(r){const l=t.viewer.scene.pick(r.position);if(Cesium.defined(l)&&l.id){if(l.id===t.entity){n=l.id,s=!0,t._isDragging=!0,t._editPickedEntity=n,t.modifyPoint=null;try{t.forbidDrawWorld(!0)}catch{}}else if(t.controlPoints.includes(l.id)){t.modifyPoint=l.id,s=!0,t._isDragging=!0,n=t.entity;try{t.forbidDrawWorld(!0)}catch{}}}},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(r){if(!s)return;let l=t.getCatesian3FromPX(r.endPosition,t.viewer);if(l){if(Cesium.defined(n)){try{n.position.setValue(l)}catch{n.position=l}t.position=l.clone(),t.controlPoints&&t.controlPoints.length>0&&t.controlPoints.forEach(a=>{try{a.position.setValue(l)}catch(d){console.warn("更新控制点位置失败:",d);try{a.position=l.clone()}catch(h){console.error("重新设置控制点位置失败:",h)}}})}t.state="editing",e&&e()}},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(){if(s){if(s=!1,t.entity&&Cesium.defined(t.entity.position))try{t.position=t.entity.position.getValue(Cesium.JulianDate.now()).clone()}catch(r){console.warn("更新位置引用失败:",r)}t._isDragging=!1,t._editPickedEntity=null,t.modifyPoint=null;try{t.forbidDrawWorld(!1)}catch{}t.state="editing"}},Cesium.ScreenSpaceEventType.LEFT_UP),this.modifyHandler.setInputAction(function(){if(t._isScaling){t._isScaling=!1,t._isDragging=!1,t._scalingControlPoint=null,delete t._initialScale,delete t._initialMousePosition,t.viewer.canvas.style.cursor="",t._hideScaleHint();try{t.forbidDrawWorld(!1)}catch{}}if(s){s=!1,t._isDragging=!1,t._editPickedEntity=null,t.modifyPoint=null;try{t.forbidDrawWorld(!1)}catch{}}if(t.hideControlPoints(),t.modifyHandler){try{t.modifyHandler.destroy()}catch{}t.modifyHandler=null}t._globalMouseUpHandler&&(window.removeEventListener("mouseup",t._globalMouseUpHandler,!0),t._globalMouseUpHandler=null),t.state="endEdit"},Cesium.ScreenSpaceEventType.RIGHT_CLICK),this.modifyHandler.setInputAction(function(r){const l=t.viewer.scene.pick(r.position);Cesium.defined(l)&&l.id===t.entity&&t._handleDoubleClick()},Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}createControlPoint(e){return e?this.viewer.entities.add({position:e,point:{pixelSize:8,color:Cesium.Color.WHITE,outlineColor:Cesium.Color.BLACK,outlineWidth:2,disableDepthTestDistance:Number.MAX_VALUE}}):null}createYellowControlPoint(e){if(!e)return null;const t=this.viewer.entities.add({position:e,point:{pixelSize:10,color:Cesium.Color.YELLOW,outlineColor:Cesium.Color.BLACK,outlineWidth:2,disableDepthTestDistance:Number.MAX_VALUE}});return t.isYellowControl=!0,t}createScaleControlPoint(e,t){if(!e)return null;let n=Cesium.Color.GREEN;t==="bottomLeft"&&(n=Cesium.Color.BLUE);const s=this.viewer.entities.add({position:e,point:{pixelSize:10,color:n,outlineColor:Cesium.Color.BLACK,outlineWidth:2,disableDepthTestDistance:Number.MAX_VALUE}});return s.isScaleControl=!0,s.corner=t,s}_calculateSpecialPosition(e){return this._calculateCornerPosition(e,"bottomRight")}_calculateCornerPosition(e,t){if(!e)return null;const s=50*(this.style.scale||1),o=this.viewer.camera,r=new Cesium.Cartesian3,l=new Cesium.Cartesian3,a=new Cesium.Cartesian3;Cesium.Cartesian3.clone(o.direction,r),Cesium.Cartesian3.clone(o.right,l),Cesium.Cartesian3.clone(o.up,a),Cesium.Cartesian3.normalize(r,r),Cesium.Cartesian3.normalize(l,l),Cesium.Cartesian3.normalize(a,a);const d=new Cesium.Cartesian3;Cesium.Cartesian3.multiplyByScalar(l,s,d),Cesium.Cartesian3.multiplyByScalar(a,s,a),Cesium.Cartesian3.add(d,a,d);const h=new Cesium.Ray(e,r),p=this.viewer.scene.globe.pick(h,this.viewer.scene),u=Cesium.Cartesian3.distance(e,p||e)*.001;return Cesium.Cartesian3.multiplyByScalar(d,u,d),Cesium.Cartesian3.add(e,d,new Cesium.Cartesian3)}showControlPoints(){if(this.controlPoints=this.controlPoints||[],this._isDragging){this.position&&this.controlPoints.length>0&&this.controlPoints.forEach(e=>{try{e.position.setValue(this.position)}catch{try{e.position=this.position.clone()}catch(n){console.warn("更新拖拽中控制点位置失败:",n)}}});return}if(this.controlPoints.length>0&&([...this.controlPoints].forEach(t=>{try{this.viewer&&this.viewer.entities&&t&&this.viewer.entities.remove(t)}catch(n){console.warn("移除控制点失败:",n)}}),this.controlPoints.length=0),this.position&&this.viewer&&!this._isDragging){const e=this.createControlPoint(this.position);e&&(e.wz=0,this.controlPoints.push(e))}}hideControlPoints(){this.controlPoints&&Array.isArray(this.controlPoints)&&this.controlPoints.length>0?([...this.controlPoints].forEach(t=>{try{this.viewer&&this.viewer.entities&&t&&this.viewer.entities.remove(t)}catch(n){console.warn("移除控制点失败:",n)}}),this.controlPoints.length=0):(!this.controlPoints||!Array.isArray(this.controlPoints))&&(this.controlPoints=[]),this.topRightControlPoint=null,this.bottomLeftControlPoint=null,this.scaleControlPoint=null,this.modifyPoint=null}endEdit(e){if(this.hideControlPoints(),this.modifyHandler){try{this.modifyHandler.destroy()}catch{}this.modifyHandler=null}if(this._globalMouseUpHandler){try{window.removeEventListener("mouseup",this._globalMouseUpHandler,!0)}catch{}this._globalMouseUpHandler=null}try{this.forbidDrawWorld(!1)}catch{}this.viewer&&this.viewer.canvas&&(this.viewer.canvas.style.cursor=""),this._isDragging=!1,this._editPickedEntity=null,this.modifyPoint=null,this.state="endEdit",e&&e(this.entity)}_cleanupEditState(){if(this._globalMouseUpHandler){try{window.removeEventListener("mouseup",this._globalMouseUpHandler,!0)}catch{}this._globalMouseUpHandler=null}if(this.modifyHandler){try{this.modifyHandler.destroy()}catch{}this.modifyHandler=null}this.controlPoints=this.controlPoints||[],this.hideControlPoints(),this._isDragging=!1,this._editPickedEntity=null,this.modifyPoint=null;try{this.forbidDrawWorld(!1)}catch{}}_showScaleHint(e){this._scaleHintElement||(this._scaleHintElement=document.createElement("div"),this._scaleHintElement.style.position="absolute",this._scaleHintElement.style.background="rgba(0, 0, 0, 0.7)",this._scaleHintElement.style.color="white",this._scaleHintElement.style.padding="4px 8px",this._scaleHintElement.style.borderRadius="4px",this._scaleHintElement.style.fontSize="12px",this._scaleHintElement.style.pointerEvents="none",this._scaleHintElement.style.zIndex="10000",document.body.appendChild(this._scaleHintElement)),this._scaleHintElement.textContent=`缩放: ${e.toFixed(2)}x`,this._scaleHintElement.style.left=`${window.event.clientX+10}px`,this._scaleHintElement.style.top=`${window.event.clientY-30}px`,this._scaleHintElement.style.display="block"}_hideScaleHint(){this._scaleHintElement&&(this._scaleHintElement.style.display="none")}move(e){if(!this.entity)return;let t=null;e instanceof Cesium.Cartesian3?t=e:t=Cesium.Cartesian3.fromDegrees(Number(e[0]),Number(e[1]),Number(e[2]||0));try{this.entity.position.setValue(t.clone())}catch{this.entity.position=t.clone()}this.position=t.clone(),this.state="editing"}_createFileInput(){if(this._fileInput)return this._fileInput;const e=document.createElement("input");return e.type="file",e.accept="image/*",e.style.display="none",e.onchange=t=>{this._handleFileUpload(t)},document.body.appendChild(e),this._fileInput=e,e}_handleFileUpload(e){const t=e.target.files[0];if(!t)return;if(!t.type.match("image.*")){console.warn("请选择有效的图片文件");return}const n=new FileReader;n.onload=s=>{this.updateBillboardImage(s.target.result),this._fileInput&&(this._fileInput.value="")},n.onerror=s=>{console.error("文件读取失败:",s)},n.readAsDataURL(t)}_handleDoubleClick(){this._createFileInput().click()}editImage(e){return e?(this.updateBillboardImage(e),!0):(console.warn("CreateBillboard.editImage: 未提供有效的图片URL"),!1)}remove(){try{this.endEdit()}catch{}if(this.entity){this.state="no";try{this.viewer.entities.remove(this.entity)}catch{}this.entity=null}}getPositions(e){return e?se.cartesianToLnglat(this.position,this.viewer):this.position}getLnglats(){return this.getPositions(!0)}setPosition(e){let t=null;e instanceof Cesium.Cartesian3?t=e:t=Cesium.Cartesian3.fromDegrees(e[0],e[1],e[2]||0);try{this.entity.position.setValue(t.clone())}catch{this.entity.position=t.clone()}this.position=t.clone()}destroy(){try{this.endEdit()}catch{}if(this.handler){try{this.handler.destroy()}catch{}this.handler=null}if(this.entity){try{this.viewer.entities.remove(this.entity)}catch{}this.entity=null}if(this.prompt){try{this.prompt.destroy()}catch{}this.prompt=null}this.position=null,this.state="no",this._isDragging=!1,this._editPickedEntity=null}}class bp extends Ke{constructor(e,t){super(e,t),this.type="circle",this.viewer=e,this.style=t||{},this.center=null,this.radiusPoint=null,this.radiusPointEntity=null,this.entity=null,this.handler=null,this.modifyHandler=null,this.modifyPoint=null,this._dragStartCart=null,this._dragStartCartCarto=null,this.pointsCount=64}start(e){!this.prompt&&this.promptStyle?.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate",this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));const t=this;this.handler.setInputAction(function(n){const s=t.getCatesian3FromPX(n.position,t.viewer,[]);s&&(t.entity?(t.endCreate(),e&&e(t.entity)):(t.center=s.clone(),t.radiusPoint=s.clone(),t.entity=t._createPolyline(),t.radiusPointEntity=t.createPoint(t.radiusPoint),t.radiusPointEntity.typeAttr="radius",t.radiusPointEntity.show=!1))},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){if(!t.entity){t.prompt?.update(n.endPosition,"单击开始绘制");return}t.prompt?.update(n.endPosition,"单击结束");const s=t.getCatesian3FromPX(n.endPosition,t.viewer,[]);s&&(t.radiusPoint=s.clone(),t._updatePolyline(),t._updateAuxPoints(),t.state="creating")},Cesium.ScreenSpaceEventType.MOUSE_MOVE)}endCreate(){this.handler?.destroy(),this.handler=null,this.radiusPointEntity&&(this.radiusPointEntity.show=!1),this.prompt?.destroy(),this.prompt=null,this.state="endCreate"}startEdit(e){if(!this.entity)return;this.state="startEdit",this.modifyHandler||(this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));const t=this;this.radiusPointEntity&&(this.radiusPointEntity.show=!0),this.modifyHandler.setInputAction(function(n){const s=t.viewer.scene.pick(n.position);if(!s?.id)return;t.modifyPoint=s.id;const o=t.getCatesian3FromPX(n.position,t.viewer,[t.entity,t.modifyPoint]);o&&(t._dragStartCart=o,t._dragStartCartCarto=Cesium.Ellipsoid.WGS84.cartesianToCartographic(o),t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(n){if(!t.modifyPoint)return;const s=t.getCatesian3FromPX(n.endPosition,t.viewer,[t.entity,t.modifyPoint]);s&&(t.modifyPoint.typeAttr==="radius"&&(t.radiusPoint=s.clone()),t._updatePolyline(),t._updateAuxPoints(),e&&e(),t.state="editing")},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(){t.modifyPoint=null,t._dragStartCart=null,t._dragStartCartCarto=null,t.forbidDrawWorld(!1),t._updatePolyline(),e&&e(t.entity),t.state="editing"},Cesium.ScreenSpaceEventType.LEFT_UP)}endEdit(e){this.radiusPointEntity&&(this.radiusPointEntity.show=!1),this.modifyHandler?.destroy(),this.modifyHandler=null,this.forbidDrawWorld(!1),this.state="endEdit",e&&e(this.entity)}_createPolyline(){const e=this,t=this.viewer.entities.add({polyline:{positions:new Cesium.CallbackProperty(()=>e._buildCirclePositions(),!1),width:this.style.outlineWidth||this.style.width||5,material:this.style.color instanceof Cesium.Color?this.style.color:Cesium.Color.fromCssColorString(this.style.color||"#00FF00"),clampToGround:!1}});return t._plotInstance=this,t.objId=this.objId,t}_updatePolyline(){if(!this.entity)return;const e=this._buildCirclePositions();try{const t=this.entity.polyline.positions;if(t&&typeof t.getValue=="function")return;if(t&&typeof t.setValue=="function"){t.setValue(e);return}this.entity.polyline.positions=e}catch{this.entity.polyline.positions=e}}_buildCirclePositions(){if(!this.center||!this.radiusPoint)return[];const e=[],t=Cesium.Ellipsoid.WGS84,n=t.cartesianToCartographic(this.center),s=t.cartesianToCartographic(this.radiusPoint),o=Math.abs(s.longitude-n.longitude),r=Math.abs(s.latitude-n.latitude);for(let l=0;l<=this.pointsCount;l++){const a=l/this.pointsCount*Math.PI*2,d=n.longitude+o*Math.cos(a),h=n.latitude+r*Math.sin(a);e.push(Cesium.Cartesian3.fromRadians(d,h))}return e}_updateAuxPoints(){!this.radiusPoint||!this.radiusPointEntity||(this.radiusPointEntity.position=this.radiusPoint)}syncFromEntity(){if(!this.entity||!this.center||!this.radiusPoint)return;const e=this.center,t=this.entity._centerCoord;if(!t)return;const n=t.x-e.x,s=t.y-e.y,o=t.z-e.z;this.center=new Cesium.Cartesian3(this.center.x+n,this.center.y+s,this.center.z+o),this.radiusPoint=new Cesium.Cartesian3(this.radiusPoint.x+n,this.radiusPoint.y+s,this.radiusPoint.z+o);const r=this.entity.objId,l=this.entity._plotInstance;this.radiusPointEntity&&this.viewer.entities.remove(this.radiusPointEntity),this.radiusPointEntity=null,this.viewer.entities.remove(this.entity),this.entity=this._createPolyline(),this.entity._plotInstance=l,this.entity.objId=r,this.radiusPointEntity=this.createPoint(this.radiusPoint),this.radiusPointEntity.typeAttr="radius",this.radiusPointEntity.show=this.state==="editing"}updatePositions(e){if(!e||e.length<1)return!1;try{if(!this.center||!this.radiusPoint)return!1;let t;if(e[0]instanceof Cesium.Cartesian3)t=e[0];else return!1;this.center=Cesium.Cartesian3.add(this.center,t,new Cesium.Cartesian3),this.radiusPoint=Cesium.Cartesian3.add(this.radiusPoint,t,new Cesium.Cartesian3),this._updatePolyline(),this._updateAuxPoints();try{this.viewer.scene.requestRender()}catch{}return!0}catch(t){return console.warn("Failed to update circle positions:",t),!1}}getPositions(e){return e?se.cartesiansToLnglats([this.center,this.radiusPoint],this.viewer):[this.center,this.radiusPoint]}getStyle(){const e=this.entity.polyline,t=e.material.color.getValue();return{color:new Cesium.Color(t.red,t.green,t.blue,1).toCssHexString(),colorAlpha:t.alpha,outlineWidth:e.width.getValue()}}setStyle(e){if(!this.entity)return;const t={...this.style,...e};let n=t.color instanceof Cesium.Color?t.color:Cesium.Color.fromCssColorString(t.color||"#00FF00");t.colorAlpha!=null&&(n=n.withAlpha(t.colorAlpha)),this.entity.polyline.material=n,this.entity.polyline.width=t.outlineWidth||t.width||5,this.style=t}destroy(){try{this.handler?.destroy(),this.modifyHandler?.destroy(),this.entity&&this.viewer.entities.remove(this.entity),this.entity=null,this.radiusPointEntity&&this.viewer.entities.remove(this.radiusPointEntity),this.radiusPointEntity=null,this.prompt?.destroy(),this.prompt=null}catch{}}_manageRadiusPointEntity(){this.radiusPointEntity?this.radiusPoint&&(this.radiusPointEntity.position=this.radiusPoint):(this.radiusPointEntity=this.createPoint(this.radiusPoint),this.radiusPointEntity&&(this.radiusPointEntity.typeAttr="radius",this.radiusPointEntity.show=!1))}createByPositions(e,t){try{if(!e||e.length===0)return console.error("createByPositions: positions array is empty or undefined"),t&&t(null),this;const n=e[0]instanceof Cesium.Cartesian3?e:se.lnglatsToCartesians(e);if(!n||n.length===0)return console.error("createByPositions: failed to convert positions to Cartesian3"),t&&t(null),this;if(n.length>=2)this.center=Cesium.Cartesian3.clone(n[0]),this.radiusPoint=Cesium.Cartesian3.clone(n[1]);else if(n.length===1)this.center=Cesium.Cartesian3.clone(n[0]),this._createDefaultRadiusPoint();else return console.error("createByPositions: invalid positions array"),t&&t(null),this;this.entity?this._updatePolyline():this.entity=this._createPolyline(),this._manageRadiusPointEntity(),this._updateAuxPoints(),this.state="endCreate";try{this.viewer.scene.requestRender()}catch(s){console.error("requestRender error:",s)}return t&&t(this.entity),this}catch(n){return console.error("createByPositions error:",n),t&&t(null),this}}}class vp extends Ke{constructor(e,t){if(super(e,t),this.type="gltfModel",t=t||{},this.viewer=e,!t.uri){console.warn("请输入模型地址!");return}let n={heading:0,pitch:0,roll:0,minimumPixelSize:24,maximumScale:120};this.style=Object.assign(n,t||{}),this.modelUri=t.uri,this.entity=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate";let t=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(n){let s=t.getCatesian3FromPX(n.position,t.viewer);s&&(t.entity.position=s,t.position=s.clone()),t.endCreate(),e&&e(t.entity)},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){t.prompt.update(n.endPosition,"单击新增"),t.state="creating";let s=t.getCatesian3FromPX(n.endPosition,t.viewer,[t.entity]);s&&(t.entity?t.entity.position=s:t.entity=t.createGltfModel(s.clone()))},Cesium.ScreenSpaceEventType.MOUSE_MOVE)}createByPositions(e,t){e&&(this.state="startCreate",e instanceof Cesium.Cartesian3?this.position=e:this.position=Cesium.Cartesian3.fromDegrees(e[0],e[1],e[2]||0),this.entity=this.createGltfModel(this.position),t(this.entity),this.state="endCreate")}startEdit(e){if(this.state=="startEdit"||this.state=="editing")return;this.modifyHandler||(this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));let t=this,n;this.state="startEdit",this.modifyHandler.setInputAction(function(s){let o=t.viewer.scene.pick(s.position);Cesium.defined(o)&&o.id&&(n=o.id,t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(s){if(!n)return;let o=t.getCatesian3FromPX(s.endPosition,t.viewer,[t.entity]);o&&(t.entity&&(t.entity.position.setValue(o),t.position=o.clone()),t.state="editing",e&&e())},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(s){n&&(t.forbidDrawWorld(!1),t.modifyHandler&&(t.modifyHandler.destroy(),t.modifyHandler=null),t.state="editing")},Cesium.ScreenSpaceEventType.LEFT_UP)}endCreate(){let e=this;e.state="endCreate",e.handler&&(e.handler.destroy(),e.handler=null),e.prompt&&(e.prompt.destroy(),e.prompt=null)}done(){this.state=="startCreate"?this.destroy():this.state=="creating"?this.destroy():(this.state=="startEdit"||this.state=="editing")&&this.endEdit()}endEdit(e){this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null,e&&e(this.entity)),this.forbidDrawWorld(!1),this.state="endEdit"}createGltfModel(e){if(!e)return;let t=Cesium.Math.toRadians(this.style.heading),n=Cesium.Math.toRadians(this.style.pitch),s=Cesium.Math.toRadians(this.style.roll),o=new Cesium.HeadingPitchRoll(t,n,s),r=Cesium.Transforms.headingPitchRollQuaternion(e,o),l=this.viewer.entities.add({position:e,orientation:r,model:{uri:this.modelUri,minimumPixelSize:this.style.minimumPixelSize,maximumScale:this.style.maximumScale,scale:this.style.scale||1,heightReference:this.style.heightReference}});return l.objId=this.objId,l}getPositions(e){return e?se.cartesianToLnglat(this.position,this.viewer):this.position}getStyle(){let e={},t=this.entity.model;e.minimumPixelSize=t.minimumPixelSize.getValue();let n=this.entity.orientation.getValue(),s=this.entity.position.getValue(this.viewer.clock.currentTime),o=se.oreatationToHpr(s.clone(),n,!0)||{};e.heading=(o.heading||0)<360?o.heading+360:o.heading,e.pitch=o.pitch||0,e.roll=o.roll||0,e.scale=t.scale.getValue(),e.uri=t.uri.getValue();let r=this.entity.heightReference&&this.entity.heightReference.getValue();return r!=null&&(e.heightReference=Number(r)),e}setStyle(e){e&&(this.setOrientation(e.heading,e.pitch,e.roll),this.entity.model.scale.setValue(e.scale==null?1:e.scale),e.uri&&this.entity.model.uri.setValue(e.uri),e.heightReference!=null&&this.entity.model.heightReference.setValue(Number(e.heightReference)),this.style=Object.assign(this.style,e))}setOrientation(e,t,n){e=e||0,t=t||0,n=n||0,this.style.heading=e,this.style.pitch=t,this.style.roll=n;var s=Cesium.Math.toRadians(e||0),o=Cesium.Math.toRadians(t||0),r=Cesium.Math.toRadians(n||0),l=new Cesium.HeadingPitchRoll(s,o,r),a=this.entity.position._value,d=Cesium.Transforms.headingPitchRollQuaternion(a,l);this.entity&&(this.entity.orientation=d)}remove(){this.entity&&(this.state="no",this.viewer.entities.remove(this.entity),this.entity=null)}destroy(){this.handler&&(this.handler.destroy(),this.handler=null),this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.style=null,this.prompt&&(this.prompt.destroy(),this.prompt=null)}}String.prototype.codePointAt||(function(){var i=(function(){try{var t={},n=Object.defineProperty,s=n(t,t,t)&&n}catch{}return s})(),e=function(t){if(this==null)throw TypeError();var n=String(this),s=n.length,o=t?Number(t):0;if(o!=o&&(o=0),!(o<0||o>=s)){var r=n.charCodeAt(o),l;return r>=55296&&r<=56319&&s>o+1&&(l=n.charCodeAt(o+1),l>=56320&&l<=57343)?(r-55296)*1024+l-56320+65536:r}};i?i(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e})();function Qt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ss,Or;function Ip(){if(Or)return ss;Or=1;var i=0,e=-3;function t(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function n(g,P){this.source=g,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=P,this.destLen=0,this.ltree=new t,this.dtree=new t}var s=new t,o=new t,r=new Uint8Array(30),l=new Uint16Array(30),a=new Uint8Array(30),d=new Uint16Array(30),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),p=new t,f=new Uint8Array(320);function u(g,P,x,F){var _,H;for(_=0;_<x;++_)g[_]=0;for(_=0;_<30-x;++_)g[_+x]=_/x|0;for(H=F,_=0;_<30;++_)P[_]=H,H+=1<<g[_]}function m(g,P){var x;for(x=0;x<7;++x)g.table[x]=0;for(g.table[7]=24,g.table[8]=152,g.table[9]=112,x=0;x<24;++x)g.trans[x]=256+x;for(x=0;x<144;++x)g.trans[24+x]=x;for(x=0;x<8;++x)g.trans[168+x]=280+x;for(x=0;x<112;++x)g.trans[176+x]=144+x;for(x=0;x<5;++x)P.table[x]=0;for(P.table[5]=32,x=0;x<32;++x)P.trans[x]=x}var E=new Uint16Array(16);function A(g,P,x,F){var _,H;for(_=0;_<16;++_)g.table[_]=0;for(_=0;_<F;++_)g.table[P[x+_]]++;for(g.table[0]=0,H=0,_=0;_<16;++_)E[_]=H,H+=g.table[_];for(_=0;_<F;++_)P[x+_]&&(g.trans[E[P[x+_]]++]=_)}function y(g){g.bitcount--||(g.tag=g.source[g.sourceIndex++],g.bitcount=7);var P=g.tag&1;return g.tag>>>=1,P}function v(g,P,x){if(!P)return x;for(;g.bitcount<24;)g.tag|=g.source[g.sourceIndex++]<<g.bitcount,g.bitcount+=8;var F=g.tag&65535>>>16-P;return g.tag>>>=P,g.bitcount-=P,F+x}function S(g,P){for(;g.bitcount<24;)g.tag|=g.source[g.sourceIndex++]<<g.bitcount,g.bitcount+=8;var x=0,F=0,_=0,H=g.tag;do F=2*F+(H&1),H>>>=1,++_,x+=P.table[_],F-=P.table[_];while(F>=0);return g.tag=H,g.bitcount-=_,P.trans[x+F]}function M(g,P,x){var F,_,H,N,w,C;for(F=v(g,5,257),_=v(g,5,1),H=v(g,4,4),N=0;N<19;++N)f[N]=0;for(N=0;N<H;++N){var b=v(g,3,0);f[h[N]]=b}for(A(p,f,0,19),w=0;w<F+_;){var D=S(g,p);switch(D){case 16:var k=f[w-1];for(C=v(g,2,3);C;--C)f[w++]=k;break;case 17:for(C=v(g,3,3);C;--C)f[w++]=0;break;case 18:for(C=v(g,7,11);C;--C)f[w++]=0;break;default:f[w++]=D;break}}A(P,f,0,F),A(x,f,F,_)}function O(g,P,x){for(;;){var F=S(g,P);if(F===256)return i;if(F<256)g.dest[g.destLen++]=F;else{var _,H,N,w;for(F-=257,_=v(g,r[F],l[F]),H=S(g,x),N=g.destLen-v(g,a[H],d[H]),w=N;w<N+_;++w)g.dest[g.destLen++]=g.dest[w]}}}function I(g){for(var P,x,F;g.bitcount>8;)g.sourceIndex--,g.bitcount-=8;if(P=g.source[g.sourceIndex+1],P=256*P+g.source[g.sourceIndex],x=g.source[g.sourceIndex+3],x=256*x+g.source[g.sourceIndex+2],P!==(~x&65535))return e;for(g.sourceIndex+=4,F=P;F;--F)g.dest[g.destLen++]=g.source[g.sourceIndex++];return g.bitcount=0,i}function B(g,P){var x=new n(g,P),F,_,H;do{switch(F=y(x),_=v(x,2,0),_){case 0:H=I(x);break;case 1:H=O(x,s,o);break;case 2:M(x,x.ltree,x.dtree),H=O(x,x.ltree,x.dtree);break;default:H=e}if(H!==i)throw new Error("Data error")}while(!F);return x.destLen<x.dest.length?typeof x.dest.slice=="function"?x.dest.slice(0,x.destLen):x.dest.subarray(0,x.destLen):x.dest}return m(s,o),u(r,l,4,3),u(a,d,2,1),r[28]=0,l[28]=258,ss=B,ss}var Bp=Ip();const xp=Qt(Bp);function Gt(i,e,t,n,s){return Math.pow(1-s,3)*i+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*t+Math.pow(s,3)*n}function lt(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}lt.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},lt.prototype.addPoint=function(i,e){typeof i=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=i,this.x2=i),i<this.x1&&(this.x1=i),i>this.x2&&(this.x2=i)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))},lt.prototype.addX=function(i){this.addPoint(i,null)},lt.prototype.addY=function(i){this.addPoint(null,i)},lt.prototype.addBezier=function(i,e,t,n,s,o,r,l){const a=[i,e],d=[t,n],h=[s,o],p=[r,l];this.addPoint(i,e),this.addPoint(r,l);for(let f=0;f<=1;f++){const u=6*a[f]-12*d[f]+6*h[f],m=-3*a[f]+9*d[f]-9*h[f]+3*p[f],E=3*d[f]-3*a[f];if(m===0){if(u===0)continue;const S=-E/u;0<S&&S<1&&(f===0&&this.addX(Gt(a[f],d[f],h[f],p[f],S)),f===1&&this.addY(Gt(a[f],d[f],h[f],p[f],S)));continue}const A=Math.pow(u,2)-4*E*m;if(A<0)continue;const y=(-u+Math.sqrt(A))/(2*m);0<y&&y<1&&(f===0&&this.addX(Gt(a[f],d[f],h[f],p[f],y)),f===1&&this.addY(Gt(a[f],d[f],h[f],p[f],y)));const v=(-u-Math.sqrt(A))/(2*m);0<v&&v<1&&(f===0&&this.addX(Gt(a[f],d[f],h[f],p[f],v)),f===1&&this.addY(Gt(a[f],d[f],h[f],p[f],v)))}},lt.prototype.addQuad=function(i,e,t,n,s,o){const r=i+.6666666666666666*(t-i),l=e+2/3*(n-e),a=r+1/3*(s-i),d=l+1/3*(o-e);this.addBezier(i,e,r,l,a,d,s,o)};function be(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}be.prototype.moveTo=function(i,e){this.commands.push({type:"M",x:i,y:e})},be.prototype.lineTo=function(i,e){this.commands.push({type:"L",x:i,y:e})},be.prototype.curveTo=be.prototype.bezierCurveTo=function(i,e,t,n,s,o){this.commands.push({type:"C",x1:i,y1:e,x2:t,y2:n,x:s,y:o})},be.prototype.quadTo=be.prototype.quadraticCurveTo=function(i,e,t,n){this.commands.push({type:"Q",x1:i,y1:e,x:t,y:n})},be.prototype.close=be.prototype.closePath=function(){this.commands.push({type:"Z"})},be.prototype.extend=function(i){if(i.commands)i=i.commands;else if(i instanceof lt){const e=i;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,i)},be.prototype.getBoundingBox=function(){const i=new lt;let e=0,t=0,n=0,s=0;for(let o=0;o<this.commands.length;o++){const r=this.commands[o];switch(r.type){case"M":i.addPoint(r.x,r.y),e=n=r.x,t=s=r.y;break;case"L":i.addPoint(r.x,r.y),n=r.x,s=r.y;break;case"Q":i.addQuad(n,s,r.x1,r.y1,r.x,r.y),n=r.x,s=r.y;break;case"C":i.addBezier(n,s,r.x1,r.y1,r.x2,r.y2,r.x,r.y),n=r.x,s=r.y;break;case"Z":n=e,s=t;break;default:throw new Error("Unexpected path command "+r.type)}}return i.isEmpty()&&i.addPoint(0,0),i},be.prototype.draw=function(i){i.beginPath();for(let e=0;e<this.commands.length;e+=1){const t=this.commands[e];t.type==="M"?i.moveTo(t.x,t.y):t.type==="L"?i.lineTo(t.x,t.y):t.type==="C"?i.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):t.type==="Q"?i.quadraticCurveTo(t.x1,t.y1,t.x,t.y):t.type==="Z"&&i.closePath()}this.fill&&(i.fillStyle=this.fill,i.fill()),this.stroke&&(i.strokeStyle=this.stroke,i.lineWidth=this.strokeWidth,i.stroke())},be.prototype.toPathData=function(i){i=i!==void 0?i:2;function e(s){return Math.round(s)===s?""+Math.round(s):s.toFixed(i)}function t(){let s="";for(let o=0;o<arguments.length;o+=1){const r=arguments[o];r>=0&&o>0&&(s+=" "),s+=e(r)}return s}let n="";for(let s=0;s<this.commands.length;s+=1){const o=this.commands[s];o.type==="M"?n+="M"+t(o.x,o.y):o.type==="L"?n+="L"+t(o.x,o.y):o.type==="C"?n+="C"+t(o.x1,o.y1,o.x2,o.y2,o.x,o.y):o.type==="Q"?n+="Q"+t(o.x1,o.y1,o.x,o.y):o.type==="Z"&&(n+="Z")}return n},be.prototype.toSVG=function(i){let e='<path d="';return e+=this.toPathData(i),e+='"',this.fill&&this.fill!=="black"&&(this.fill===null?e+=' fill="none"':e+=' fill="'+this.fill+'"'),this.stroke&&(e+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),e+="/>",e},be.prototype.toDOMElement=function(i){const e=this.toPathData(i),t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",e),t};function Lr(i){throw new Error(i)}function Nr(i,e){i||Lr(e)}const te={fail:Lr,argument:Nr,assert:Nr},Ur=32768,_r=2147483648,Ht={},z={},Z={};function Ue(i){return function(){return i}}z.BYTE=function(i){return te.argument(i>=0&&i<=255,"Byte value should be between 0 and 255."),[i]},Z.BYTE=Ue(1),z.CHAR=function(i){return[i.charCodeAt(0)]},Z.CHAR=Ue(1),z.CHARARRAY=function(i){const e=[];for(let t=0;t<i.length;t+=1)e[t]=i.charCodeAt(t);return e},Z.CHARARRAY=function(i){return i.length},z.USHORT=function(i){return[i>>8&255,i&255]},Z.USHORT=Ue(2),z.SHORT=function(i){return i>=Ur&&(i=-(2*Ur-i)),[i>>8&255,i&255]},Z.SHORT=Ue(2),z.UINT24=function(i){return[i>>16&255,i>>8&255,i&255]},Z.UINT24=Ue(3),z.ULONG=function(i){return[i>>24&255,i>>16&255,i>>8&255,i&255]},Z.ULONG=Ue(4),z.LONG=function(i){return i>=_r&&(i=-(2*_r-i)),[i>>24&255,i>>16&255,i>>8&255,i&255]},Z.LONG=Ue(4),z.FIXED=z.ULONG,Z.FIXED=Z.ULONG,z.FWORD=z.SHORT,Z.FWORD=Z.SHORT,z.UFWORD=z.USHORT,Z.UFWORD=Z.USHORT,z.LONGDATETIME=function(i){return[0,0,0,0,i>>24&255,i>>16&255,i>>8&255,i&255]},Z.LONGDATETIME=Ue(8),z.TAG=function(i){return te.argument(i.length===4,"Tag should be exactly 4 ASCII characters."),[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]},Z.TAG=Ue(4),z.Card8=z.BYTE,Z.Card8=Z.BYTE,z.Card16=z.USHORT,Z.Card16=Z.USHORT,z.OffSize=z.BYTE,Z.OffSize=Z.BYTE,z.SID=z.USHORT,Z.SID=Z.USHORT,z.NUMBER=function(i){return i>=-107&&i<=107?[i+139]:i>=108&&i<=1131?(i=i-108,[(i>>8)+247,i&255]):i>=-1131&&i<=-108?(i=-i-108,[(i>>8)+251,i&255]):i>=-32768&&i<=32767?z.NUMBER16(i):z.NUMBER32(i)},Z.NUMBER=function(i){return z.NUMBER(i).length},z.NUMBER16=function(i){return[28,i>>8&255,i&255]},Z.NUMBER16=Ue(3),z.NUMBER32=function(i){return[29,i>>24&255,i>>16&255,i>>8&255,i&255]},Z.NUMBER32=Ue(5),z.REAL=function(i){let e=i.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const o=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(i*o)/o).toString()}let n="";for(let o=0,r=e.length;o<r;o+=1){const l=e[o];l==="e"?n+=e[++o]==="-"?"c":"b":l==="."?n+="a":l==="-"?n+="e":n+=l}n+=n.length&1?"f":"ff";const s=[30];for(let o=0,r=n.length;o<r;o+=2)s.push(parseInt(n.substr(o,2),16));return s},Z.REAL=function(i){return z.REAL(i).length},z.NAME=z.CHARARRAY,Z.NAME=Z.CHARARRAY,z.STRING=z.CHARARRAY,Z.STRING=Z.CHARARRAY,Ht.UTF8=function(i,e,t){const n=[],s=t;for(let o=0;o<s;o++,e+=1)n[o]=i.getUint8(e);return String.fromCharCode.apply(null,n)},Ht.UTF16=function(i,e,t){const n=[],s=t/2;for(let o=0;o<s;o++,e+=2)n[o]=i.getUint16(e);return String.fromCharCode.apply(null,n)},z.UTF16=function(i){const e=[];for(let t=0;t<i.length;t+=1){const n=i.charCodeAt(t);e[e.length]=n>>8&255,e[e.length]=n&255}return e},Z.UTF16=function(i){return i.length*2};const os={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Ht.MACSTRING=function(i,e,t,n){const s=os[n];if(s===void 0)return;let o="";for(let r=0;r<t;r++){const l=i.getUint8(e+r);l<=127?o+=String.fromCharCode(l):o+=s[l&127]}return o};const Hi=typeof WeakMap=="function"&&new WeakMap;let Yi;const Sp=function(i){if(!Yi){Yi={};for(let s in os)Yi[s]=new String(s)}const e=Yi[i];if(e===void 0)return;if(Hi){const s=Hi.get(e);if(s!==void 0)return s}const t=os[i];if(t===void 0)return;const n={};for(let s=0;s<t.length;s++)n[t.charCodeAt(s)]=s+128;return Hi&&Hi.set(e,n),n};z.MACSTRING=function(i,e){const t=Sp(e);if(t===void 0)return;const n=[];for(let s=0;s<i.length;s++){let o=i.charCodeAt(s);if(o>=128&&(o=t[o],o===void 0))return;n[s]=o}return n},Z.MACSTRING=function(i,e){const t=z.MACSTRING(i,e);return t!==void 0?t.length:0};function rs(i){return i>=-128&&i<=127}function Tp(i,e,t){let n=0;const s=i.length;for(;e<s&&n<64&&i[e]===0;)++e,++n;return t.push(128|n-1),e}function Mp(i,e,t){let n=0;const s=i.length;let o=e;for(;o<s&&n<64;){const r=i[o];if(!rs(r)||r===0&&o+1<s&&i[o+1]===0)break;++o,++n}t.push(n-1);for(let r=e;r<o;++r)t.push(i[r]+256&255);return o}function Dp(i,e,t){let n=0;const s=i.length;let o=e;for(;o<s&&n<64;){const r=i[o];if(r===0||rs(r)&&o+1<s&&rs(i[o+1]))break;++o,++n}t.push(64|n-1);for(let r=e;r<o;++r){const l=i[r];t.push(l+65536>>8&255,l+256&255)}return o}z.VARDELTAS=function(i){let e=0;const t=[];for(;e<i.length;){const n=i[e];n===0?e=Tp(i,e,t):n>=-128&&n<=127?e=Mp(i,e,t):e=Dp(i,e,t)}return t},z.INDEX=function(i){let e=1;const t=[e],n=[];for(let l=0;l<i.length;l+=1){const a=z.OBJECT(i[l]);Array.prototype.push.apply(n,a),e+=a.length,t.push(e)}if(n.length===0)return[0,0];const s=[],o=1+Math.floor(Math.log(e)/Math.log(2))/8|0,r=[void 0,z.BYTE,z.USHORT,z.UINT24,z.ULONG][o];for(let l=0;l<t.length;l+=1){const a=r(t[l]);Array.prototype.push.apply(s,a)}return Array.prototype.concat(z.Card16(i.length),z.OffSize(o),s,n)},Z.INDEX=function(i){return z.INDEX(i).length},z.DICT=function(i){let e=[];const t=Object.keys(i),n=t.length;for(let s=0;s<n;s+=1){const o=parseInt(t[s],0),r=i[o];e=e.concat(z.OPERAND(r.value,r.type)),e=e.concat(z.OPERATOR(o))}return e},Z.DICT=function(i){return z.DICT(i).length},z.OPERATOR=function(i){return i<1200?[i]:[12,i-1200]},z.OPERAND=function(i,e){let t=[];if(Array.isArray(e))for(let n=0;n<e.length;n+=1)te.argument(i.length===e.length,"Not enough arguments given for type"+e),t=t.concat(z.OPERAND(i[n],e[n]));else if(e==="SID")t=t.concat(z.NUMBER(i));else if(e==="offset")t=t.concat(z.NUMBER32(i));else if(e==="number")t=t.concat(z.NUMBER(i));else if(e==="real")t=t.concat(z.REAL(i));else throw new Error("Unknown operand type "+e);return t},z.OP=z.BYTE,Z.OP=Z.BYTE;const Vi=typeof WeakMap=="function"&&new WeakMap;z.CHARSTRING=function(i){if(Vi){const n=Vi.get(i);if(n!==void 0)return n}let e=[];const t=i.length;for(let n=0;n<t;n+=1){const s=i[n];e=e.concat(z[s.type](s.value))}return Vi&&Vi.set(i,e),e},Z.CHARSTRING=function(i){return z.CHARSTRING(i).length},z.OBJECT=function(i){const e=z[i.type];return te.argument(e!==void 0,"No encoding function for type "+i.type),e(i.value)},Z.OBJECT=function(i){const e=Z[i.type];return te.argument(e!==void 0,"No sizeOf function for type "+i.type),e(i.value)},z.TABLE=function(i){let e=[];const t=i.fields.length,n=[],s=[];for(let o=0;o<t;o+=1){const r=i.fields[o],l=z[r.type];te.argument(l!==void 0,"No encoding function for field type "+r.type+" ("+r.name+")");let a=i[r.name];a===void 0&&(a=r.value);const d=l(a);r.type==="TABLE"?(s.push(e.length),e=e.concat([0,0]),n.push(d)):e=e.concat(d)}for(let o=0;o<n.length;o+=1){const r=s[o],l=e.length;te.argument(l<65536,"Table "+i.tableName+" too big."),e[r]=l>>8,e[r+1]=l&255,e=e.concat(n[o])}return e},Z.TABLE=function(i){let e=0;const t=i.fields.length;for(let n=0;n<t;n+=1){const s=i.fields[n],o=Z[s.type];te.argument(o!==void 0,"No sizeOf function for field type "+s.type+" ("+s.name+")");let r=i[s.name];r===void 0&&(r=s.value),e+=o(r),s.type==="TABLE"&&(e+=2)}return e},z.RECORD=z.TABLE,Z.RECORD=Z.TABLE,z.LITERAL=function(i){return i},Z.LITERAL=function(i){return i.length};function Se(i,e,t){for(let n=0;n<e.length;n+=1){const s=e[n];this[s.name]=s.value}if(this.tableName=i,this.fields=e,t){const n=Object.keys(t);for(let s=0;s<n.length;s+=1){const o=n[s],r=t[o];this[o]!==void 0&&(this[o]=r)}}}Se.prototype.encode=function(){return z.TABLE(this)},Se.prototype.sizeOf=function(){return Z.TABLE(this)};function ai(i,e,t){t===void 0&&(t=e.length);const n=new Array(e.length+1);n[0]={name:i+"Count",type:"USHORT",value:t};for(let s=0;s<e.length;s++)n[s+1]={name:i+s,type:"USHORT",value:e[s]};return n}function as(i,e,t){const n=e.length,s=new Array(n+1);s[0]={name:i+"Count",type:"USHORT",value:n};for(let o=0;o<n;o++)s[o+1]={name:i+o,type:"TABLE",value:t(e[o],o)};return s}function zi(i,e,t){const n=e.length;let s=[];s[0]={name:i+"Count",type:"USHORT",value:n};for(let o=0;o<n;o++)s=s.concat(t(e[o],o));return s}function Wi(i){i.format===1?Se.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(ai("glyph",i.glyphs))):te.assert(!1,"Can't create coverage table format 2 yet.")}Wi.prototype=Object.create(Se.prototype),Wi.prototype.constructor=Wi;function ji(i){Se.call(this,"scriptListTable",zi("scriptRecord",i,function(e,t){const n=e.script;let s=n.defaultLangSys;return te.assert(!!s,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+t,type:"TAG",value:e.tag},{name:"script"+t,type:"TABLE",value:new Se("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Se("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(ai("featureIndex",s.featureIndexes)))}].concat(zi("langSys",n.langSysRecords,function(o,r){const l=o.langSys;return[{name:"langSysTag"+r,type:"TAG",value:o.tag},{name:"langSys"+r,type:"TABLE",value:new Se("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:l.reqFeatureIndex}].concat(ai("featureIndex",l.featureIndexes)))}]})))}]}))}ji.prototype=Object.create(Se.prototype),ji.prototype.constructor=ji;function Ki(i){Se.call(this,"featureListTable",zi("featureRecord",i,function(e,t){const n=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new Se("featureTable",[{name:"featureParams",type:"USHORT",value:n.featureParams}].concat(ai("lookupListIndex",n.lookupListIndexes)))}]}))}Ki.prototype=Object.create(Se.prototype),Ki.prototype.constructor=Ki;function $i(i,e){Se.call(this,"lookupListTable",as("lookup",i,function(t){let n=e[t.lookupType];return te.assert(!!n,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new Se("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(as("subtable",t.subtables,n)))}))}$i.prototype=Object.create(Se.prototype),$i.prototype.constructor=$i;const J={Table:Se,Record:Se,Coverage:Wi,ScriptList:ji,FeatureList:Ki,LookupList:$i,ushortList:ai,tableList:as,recordList:zi};function Qr(i,e){return i.getUint8(e)}function Xi(i,e){return i.getUint16(e,!1)}function kp(i,e){return i.getInt16(e,!1)}function ls(i,e){return i.getUint32(e,!1)}function Gr(i,e){const t=i.getInt16(e,!1),n=i.getUint16(e+2,!1);return t+n/65535}function Pp(i,e){let t="";for(let n=e;n<e+4;n+=1)t+=String.fromCharCode(i.getInt8(n));return t}function Fp(i,e,t){let n=0;for(let s=0;s<t;s+=1)n<<=8,n+=i.getUint8(e+s);return n}function Rp(i,e,t){const n=[];for(let s=e;s<t;s+=1)n.push(i.getUint8(s));return n}function Op(i){let e="";for(let t=0;t<i.length;t+=1)e+=String.fromCharCode(i[t]);return e}const Lp={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function G(i,e){this.data=i,this.offset=e,this.relativeOffset=0}G.prototype.parseByte=function(){const i=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},G.prototype.parseChar=function(){const i=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},G.prototype.parseCard8=G.prototype.parseByte,G.prototype.parseUShort=function(){const i=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},G.prototype.parseCard16=G.prototype.parseUShort,G.prototype.parseSID=G.prototype.parseUShort,G.prototype.parseOffset16=G.prototype.parseUShort,G.prototype.parseShort=function(){const i=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},G.prototype.parseF2Dot14=function(){const i=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,i},G.prototype.parseULong=function(){const i=ls(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},G.prototype.parseOffset32=G.prototype.parseULong,G.prototype.parseFixed=function(){const i=Gr(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},G.prototype.parseString=function(i){const e=this.data,t=this.offset+this.relativeOffset;let n="";this.relativeOffset+=i;for(let s=0;s<i;s++)n+=String.fromCharCode(e.getUint8(t+s));return n},G.prototype.parseTag=function(){return this.parseString(4)},G.prototype.parseLongDateTime=function(){let i=ls(this.data,this.offset+this.relativeOffset+4);return i-=2082844800,this.relativeOffset+=8,i},G.prototype.parseVersion=function(i){const e=Xi(this.data,this.offset+this.relativeOffset),t=Xi(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,i===void 0&&(i=4096),e+t/i/10},G.prototype.skip=function(i,e){e===void 0&&(e=1),this.relativeOffset+=Lp[i]*e},G.prototype.parseULongList=function(i){i===void 0&&(i=this.parseULong());const e=new Array(i),t=this.data;let n=this.offset+this.relativeOffset;for(let s=0;s<i;s++)e[s]=t.getUint32(n),n+=4;return this.relativeOffset+=i*4,e},G.prototype.parseOffset16List=G.prototype.parseUShortList=function(i){i===void 0&&(i=this.parseUShort());const e=new Array(i),t=this.data;let n=this.offset+this.relativeOffset;for(let s=0;s<i;s++)e[s]=t.getUint16(n),n+=2;return this.relativeOffset+=i*2,e},G.prototype.parseShortList=function(i){const e=new Array(i),t=this.data;let n=this.offset+this.relativeOffset;for(let s=0;s<i;s++)e[s]=t.getInt16(n),n+=2;return this.relativeOffset+=i*2,e},G.prototype.parseByteList=function(i){const e=new Array(i),t=this.data;let n=this.offset+this.relativeOffset;for(let s=0;s<i;s++)e[s]=t.getUint8(n++);return this.relativeOffset+=i,e},G.prototype.parseList=function(i,e){e||(e=i,i=this.parseUShort());const t=new Array(i);for(let n=0;n<i;n++)t[n]=e.call(this);return t},G.prototype.parseList32=function(i,e){e||(e=i,i=this.parseULong());const t=new Array(i);for(let n=0;n<i;n++)t[n]=e.call(this);return t},G.prototype.parseRecordList=function(i,e){e||(e=i,i=this.parseUShort());const t=new Array(i),n=Object.keys(e);for(let s=0;s<i;s++){const o={};for(let r=0;r<n.length;r++){const l=n[r],a=e[l];o[l]=a.call(this)}t[s]=o}return t},G.prototype.parseRecordList32=function(i,e){e||(e=i,i=this.parseULong());const t=new Array(i),n=Object.keys(e);for(let s=0;s<i;s++){const o={};for(let r=0;r<n.length;r++){const l=n[r],a=e[l];o[l]=a.call(this)}t[s]=o}return t},G.prototype.parseStruct=function(i){if(typeof i=="function")return i.call(this);{const e=Object.keys(i),t={};for(let n=0;n<e.length;n++){const s=e[n],o=i[s];t[s]=o.call(this)}return t}},G.prototype.parseValueRecord=function(i){if(i===void 0&&(i=this.parseUShort()),i===0)return;const e={};return i&1&&(e.xPlacement=this.parseShort()),i&2&&(e.yPlacement=this.parseShort()),i&4&&(e.xAdvance=this.parseShort()),i&8&&(e.yAdvance=this.parseShort()),i&16&&(e.xPlaDevice=void 0,this.parseShort()),i&32&&(e.yPlaDevice=void 0,this.parseShort()),i&64&&(e.xAdvDevice=void 0,this.parseShort()),i&128&&(e.yAdvDevice=void 0,this.parseShort()),e},G.prototype.parseValueRecordList=function(){const i=this.parseUShort(),e=this.parseUShort(),t=new Array(e);for(let n=0;n<e;n++)t[n]=this.parseValueRecord(i);return t},G.prototype.parsePointer=function(i){const e=this.parseOffset16();if(e>0)return new G(this.data,this.offset+e).parseStruct(i)},G.prototype.parsePointer32=function(i){const e=this.parseOffset32();if(e>0)return new G(this.data,this.offset+e).parseStruct(i)},G.prototype.parseListOfLists=function(i){const e=this.parseOffset16List(),t=e.length,n=this.relativeOffset,s=new Array(t);for(let o=0;o<t;o++){const r=e[o];if(r===0){s[o]=void 0;continue}if(this.relativeOffset=r,i){const l=this.parseOffset16List(),a=new Array(l.length);for(let d=0;d<l.length;d++)this.relativeOffset=r+l[d],a[d]=i.call(this);s[o]=a}else s[o]=this.parseUShortList()}return this.relativeOffset=n,s},G.prototype.parseCoverage=function(){const i=this.offset+this.relativeOffset,e=this.parseUShort(),t=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(t)};if(e===2){const n=new Array(t);for(let s=0;s<t;s++)n[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:n}}throw new Error("0x"+i.toString(16)+": Coverage format must be 1 or 2.")},G.prototype.parseClassDef=function(){const i=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()};if(e===2)return{format:2,ranges:this.parseRecordList({start:G.uShort,end:G.uShort,classId:G.uShort})};throw new Error("0x"+i.toString(16)+": ClassDef format must be 1 or 2.")},G.list=function(i,e){return function(){return this.parseList(i,e)}},G.list32=function(i,e){return function(){return this.parseList32(i,e)}},G.recordList=function(i,e){return function(){return this.parseRecordList(i,e)}},G.recordList32=function(i,e){return function(){return this.parseRecordList32(i,e)}},G.pointer=function(i){return function(){return this.parsePointer(i)}},G.pointer32=function(i){return function(){return this.parsePointer32(i)}},G.tag=G.prototype.parseTag,G.byte=G.prototype.parseByte,G.uShort=G.offset16=G.prototype.parseUShort,G.uShortList=G.prototype.parseUShortList,G.uLong=G.offset32=G.prototype.parseULong,G.uLongList=G.prototype.parseULongList,G.struct=G.prototype.parseStruct,G.coverage=G.prototype.parseCoverage,G.classDef=G.prototype.parseClassDef;const Hr={reserved:G.uShort,reqFeatureIndex:G.uShort,featureIndexes:G.uShortList};G.prototype.parseScriptList=function(){return this.parsePointer(G.recordList({tag:G.tag,script:G.pointer({defaultLangSys:G.pointer(Hr),langSysRecords:G.recordList({tag:G.tag,langSys:G.pointer(Hr)})})}))||[]},G.prototype.parseFeatureList=function(){return this.parsePointer(G.recordList({tag:G.tag,feature:G.pointer({featureParams:G.offset16,lookupListIndexes:G.uShortList})}))||[]},G.prototype.parseLookupList=function(i){return this.parsePointer(G.list(G.pointer(function(){const e=this.parseUShort();te.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");const t=this.parseUShort(),n=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(G.pointer(i[e])),markFilteringSet:n?this.parseUShort():void 0}})))||[]},G.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){const i=this.parseUShort(),e=this.parseUShort();return te.argument(i===1&&e<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:G.offset32,featureTableSubstitutionOffset:G.offset32})})||[]};const $={getByte:Qr,getCard8:Qr,getUShort:Xi,getCard16:Xi,getShort:kp,getULong:ls,getFixed:Gr,getTag:Pp,getOffset:Fp,getBytes:Rp,bytesToString:Op,Parser:G};function Np(i,e){e.parseUShort(),i.length=e.parseULong(),i.language=e.parseULong();let t;i.groupCount=t=e.parseULong(),i.glyphIndexMap={};for(let n=0;n<t;n+=1){const s=e.parseULong(),o=e.parseULong();let r=e.parseULong();for(let l=s;l<=o;l+=1)i.glyphIndexMap[l]=r,r++}}function Up(i,e,t,n,s){i.length=e.parseUShort(),i.language=e.parseUShort();let o;i.segCount=o=e.parseUShort()>>1,e.skip("uShort",3),i.glyphIndexMap={};const r=new $.Parser(t,n+s+14),l=new $.Parser(t,n+s+16+o*2),a=new $.Parser(t,n+s+16+o*4),d=new $.Parser(t,n+s+16+o*6);let h=n+s+16+o*8;for(let p=0;p<o-1;p+=1){let f;const u=r.parseUShort(),m=l.parseUShort(),E=a.parseShort(),A=d.parseUShort();for(let y=m;y<=u;y+=1)A!==0?(h=d.offset+d.relativeOffset-2,h+=A,h+=(y-m)*2,f=$.getUShort(t,h),f!==0&&(f=f+E&65535)):f=y+E&65535,i.glyphIndexMap[y]=f}}function _p(i,e){const t={};t.version=$.getUShort(i,e),te.argument(t.version===0,"cmap table version should be 0."),t.numTables=$.getUShort(i,e+2);let n=-1;for(let o=t.numTables-1;o>=0;o-=1){const r=$.getUShort(i,e+4+o*8),l=$.getUShort(i,e+4+o*8+2);if(r===3&&(l===0||l===1||l===10)||r===0&&(l===0||l===1||l===2||l===3||l===4)){n=$.getULong(i,e+4+o*8+4);break}}if(n===-1)throw new Error("No valid cmap sub-tables found.");const s=new $.Parser(i,e+n);if(t.format=s.parseUShort(),t.format===12)Np(t,s);else if(t.format===4)Up(t,s,i,e,n);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+t.format+").");return t}function Qp(i,e,t){i.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function Gp(i){i.segments.push({end:65535,start:65535,delta:1,offset:0})}function Hp(i){let e=!0,t;for(t=i.length-1;t>0;t-=1)if(i.get(t).unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}let n=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||(n=n.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),n=n.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);const s=new J.Table("cmap",n);for(s.segments=[],t=0;t<i.length;t+=1){const u=i.get(t);for(let m=0;m<u.unicodes.length;m+=1)Qp(s,u.unicodes[m],t);s.segments=s.segments.sort(function(m,E){return m.start-E.start})}Gp(s);const o=s.segments.length;let r=0,l=[],a=[],d=[],h=[],p=[],f=[];for(t=0;t<o;t+=1){const u=s.segments[t];u.end<=65535&&u.start<=65535?(l=l.concat({name:"end_"+t,type:"USHORT",value:u.end}),a=a.concat({name:"start_"+t,type:"USHORT",value:u.start}),d=d.concat({name:"idDelta_"+t,type:"SHORT",value:u.delta}),h=h.concat({name:"idRangeOffset_"+t,type:"USHORT",value:u.offset}),u.glyphId!==void 0&&(p=p.concat({name:"glyph_"+t,type:"USHORT",value:u.glyphId}))):r+=1,!e&&u.glyphIndex!==void 0&&(f=f.concat({name:"cmap12Start_"+t,type:"ULONG",value:u.start}),f=f.concat({name:"cmap12End_"+t,type:"ULONG",value:u.end}),f=f.concat({name:"cmap12Glyph_"+t,type:"ULONG",value:u.glyphIndex}))}if(s.segCountX2=(o-r)*2,s.searchRange=Math.pow(2,Math.floor(Math.log(o-r)/Math.log(2)))*2,s.entrySelector=Math.log(s.searchRange/2)/Math.log(2),s.rangeShift=s.segCountX2-s.searchRange,s.fields=s.fields.concat(l),s.fields.push({name:"reservedPad",type:"USHORT",value:0}),s.fields=s.fields.concat(a),s.fields=s.fields.concat(d),s.fields=s.fields.concat(h),s.fields=s.fields.concat(p),s.cmap4Length=14+l.length*2+2+a.length*2+d.length*2+h.length*2+p.length*2,!e){const u=16+f.length*4;s.cmap12Offset=20+s.cmap4Length,s.fields=s.fields.concat([{name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:u},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:f.length/3}]),s.fields=s.fields.concat(f)}return s}const Yr={parse:_p,make:Hp},qi=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],Yp=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],Vp=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],wt=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function Vr(i){this.font=i}Vr.prototype.charToGlyphIndex=function(i){const e=i.codePointAt(0),t=this.font.glyphs;if(t)for(let n=0;n<t.length;n+=1){const s=t.get(n);for(let o=0;o<s.unicodes.length;o+=1)if(s.unicodes[o]===e)return n}return null};function zr(i){this.cmap=i}zr.prototype.charToGlyphIndex=function(i){return this.cmap.glyphIndexMap[i.codePointAt(0)]||0};function Ji(i,e){this.encoding=i,this.charset=e}Ji.prototype.charToGlyphIndex=function(i){const e=i.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function cs(i){switch(i.version){case 1:this.names=wt.slice();break;case 2:this.names=new Array(i.numberOfGlyphs);for(let e=0;e<i.numberOfGlyphs;e++)i.glyphNameIndex[e]<wt.length?this.names[e]=wt[i.glyphNameIndex[e]]:this.names[e]=i.names[i.glyphNameIndex[e]-wt.length];break;case 2.5:this.names=new Array(i.numberOfGlyphs);for(let e=0;e<i.numberOfGlyphs;e++)this.names[e]=wt[e+i.glyphNameIndex[e]];break;case 3:this.names=[];break;default:this.names=[];break}}cs.prototype.nameToGlyphIndex=function(i){return this.names.indexOf(i)},cs.prototype.glyphIndexToName=function(i){return this.names[i]};function zp(i){let e;const t=i.tables.cmap.glyphIndexMap,n=Object.keys(t);for(let s=0;s<n.length;s+=1){const o=n[s],r=t[o];e=i.glyphs.get(r),e.addUnicode(parseInt(o))}for(let s=0;s<i.glyphs.length;s+=1)e=i.glyphs.get(s),i.cffEncoding?i.isCIDFont?e.name="gid"+s:e.name=i.cffEncoding.charset[s]:i.glyphNames.names&&(e.name=i.glyphNames.glyphIndexToName(s))}function Wp(i,e,t,n,s){i.beginPath(),i.moveTo(e,t),i.lineTo(n,s),i.stroke()}const bt={line:Wp};function jp(i,e){let t=e||new be;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(n){t=n}}}function Ne(i){this.bindConstructorValues(i)}Ne.prototype.bindConstructorValues=function(i){this.index=i.index||0,this.name=i.name||null,this.unicode=i.unicode||void 0,this.unicodes=i.unicodes||i.unicode!==void 0?[i.unicode]:[],i.xMin&&(this.xMin=i.xMin),i.yMin&&(this.yMin=i.yMin),i.xMax&&(this.xMax=i.xMax),i.yMax&&(this.yMax=i.yMax),i.advanceWidth&&(this.advanceWidth=i.advanceWidth),Object.defineProperty(this,"path",jp(this,i.path))},Ne.prototype.addUnicode=function(i){this.unicodes.length===0&&(this.unicode=i),this.unicodes.push(i)},Ne.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},Ne.prototype.getPath=function(i,e,t,n,s){i=i!==void 0?i:0,e=e!==void 0?e:0,t=t!==void 0?t:72;let o,r;n||(n={});let l=n.xScale,a=n.yScale;if(n.hinting&&s&&s.hinting&&(r=this.path&&s.hinting.exec(this,t)),r)o=s.hinting.getCommands(r),i=Math.round(i),e=Math.round(e),l=a=1;else{o=this.path.commands;const h=1/this.path.unitsPerEm*t;l===void 0&&(l=h),a===void 0&&(a=h)}const d=new be;for(let h=0;h<o.length;h+=1){const p=o[h];p.type==="M"?d.moveTo(i+p.x*l,e+-p.y*a):p.type==="L"?d.lineTo(i+p.x*l,e+-p.y*a):p.type==="Q"?d.quadraticCurveTo(i+p.x1*l,e+-p.y1*a,i+p.x*l,e+-p.y*a):p.type==="C"?d.curveTo(i+p.x1*l,e+-p.y1*a,i+p.x2*l,e+-p.y2*a,i+p.x*l,e+-p.y*a):p.type==="Z"&&d.closePath()}return d},Ne.prototype.getContours=function(){if(this.points===void 0)return[];const i=[];let e=[];for(let t=0;t<this.points.length;t+=1){const n=this.points[t];e.push(n),n.lastPointOfContour&&(i.push(e),e=[])}return te.argument(e.length===0,"There are still points left in the current contour."),i},Ne.prototype.getMetrics=function(){const i=this.path.commands,e=[],t=[];for(let s=0;s<i.length;s+=1){const o=i[s];o.type!=="Z"&&(e.push(o.x),t.push(o.y)),(o.type==="Q"||o.type==="C")&&(e.push(o.x1),t.push(o.y1)),o.type==="C"&&(e.push(o.x2),t.push(o.y2))}const n={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,t),leftSideBearing:this.leftSideBearing};return isFinite(n.xMin)||(n.xMin=0),isFinite(n.xMax)||(n.xMax=this.advanceWidth),isFinite(n.yMin)||(n.yMin=0),isFinite(n.yMax)||(n.yMax=0),n.rightSideBearing=this.advanceWidth-n.leftSideBearing-(n.xMax-n.xMin),n},Ne.prototype.draw=function(i,e,t,n,s){this.getPath(e,t,n,s).draw(i)},Ne.prototype.drawPoints=function(i,e,t,n){function s(d,h,p,f){const u=Math.PI*2;i.beginPath();for(let m=0;m<d.length;m+=1)i.moveTo(h+d[m].x*f,p+d[m].y*f),i.arc(h+d[m].x*f,p+d[m].y*f,2,0,u,!1);i.closePath(),i.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:24;const o=1/this.path.unitsPerEm*n,r=[],l=[],a=this.path;for(let d=0;d<a.commands.length;d+=1){const h=a.commands[d];h.x!==void 0&&r.push({x:h.x,y:-h.y}),h.x1!==void 0&&l.push({x:h.x1,y:-h.y1}),h.x2!==void 0&&l.push({x:h.x2,y:-h.y2})}i.fillStyle="blue",s(r,e,t,o),i.fillStyle="red",s(l,e,t,o)},Ne.prototype.drawMetrics=function(i,e,t,n){let s;e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:24,s=1/this.path.unitsPerEm*n,i.lineWidth=1,i.strokeStyle="black",bt.line(i,e,-1e4,e,1e4),bt.line(i,-1e4,t,1e4,t);const o=this.xMin||0;let r=this.yMin||0;const l=this.xMax||0;let a=this.yMax||0;const d=this.advanceWidth||0;i.strokeStyle="blue",bt.line(i,e+o*s,-1e4,e+o*s,1e4),bt.line(i,e+l*s,-1e4,e+l*s,1e4),bt.line(i,-1e4,t+-r*s,1e4,t+-r*s),bt.line(i,-1e4,t+-a*s,1e4,t+-a*s),i.strokeStyle="green",bt.line(i,e+d*s,-1e4,e+d*s,1e4)};function Zi(i,e,t){Object.defineProperty(i,e,{get:function(){return i.path,i[t]},set:function(n){i[t]=n},enumerable:!0,configurable:!0})}function ds(i,e){if(this.font=i,this.glyphs={},Array.isArray(e))for(let t=0;t<e.length;t++)this.glyphs[t]=e[t];this.length=e&&e.length||0}ds.prototype.get=function(i){return typeof this.glyphs[i]=="function"&&(this.glyphs[i]=this.glyphs[i]()),this.glyphs[i]},ds.prototype.push=function(i,e){this.glyphs[i]=e,this.length++};function Kp(i,e){return new Ne({index:e,font:i})}function $p(i,e,t,n,s,o){return function(){const r=new Ne({index:e,font:i});return r.path=function(){t(r,n,s);const l=o(i.glyphs,r);return l.unitsPerEm=i.unitsPerEm,l},Zi(r,"xMin","_xMin"),Zi(r,"xMax","_xMax"),Zi(r,"yMin","_yMin"),Zi(r,"yMax","_yMax"),r}}function Xp(i,e,t,n){return function(){const s=new Ne({index:e,font:i});return s.path=function(){const o=t(i,s,n);return o.unitsPerEm=i.unitsPerEm,o},s}}const Yt={GlyphSet:ds,glyphLoader:Kp,ttfGlyphLoader:$p,cffGlyphLoader:Xp};function Wr(i,e){if(i===e)return!0;if(Array.isArray(i)&&Array.isArray(e)){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t+=1)if(!Wr(i[t],e[t]))return!1;return!0}else return!1}function hs(i){let e;return i.length<1240?e=107:i.length<33900?e=1131:e=32768,e}function ct(i,e,t){const n=[],s=[],o=$.getCard16(i,e);let r,l;if(o!==0){const a=$.getByte(i,e+2);r=e+(o+1)*a+2;let d=e+3;for(let h=0;h<o+1;h+=1)n.push($.getOffset(i,d,a)),d+=a;l=r+n[o]}else l=e+2;for(let a=0;a<n.length-1;a+=1){let d=$.getBytes(i,r+n[a],r+n[a+1]);t&&(d=t(d)),s.push(d)}return{objects:s,startOffset:e,endOffset:l}}function qp(i){let e="";const n=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=i.parseByte(),o=s>>4,r=s&15;if(o===15||(e+=n[o],r===15))break;e+=n[r]}return parseFloat(e)}function Jp(i,e){let t,n,s,o;if(e===28)return t=i.parseByte(),n=i.parseByte(),t<<8|n;if(e===29)return t=i.parseByte(),n=i.parseByte(),s=i.parseByte(),o=i.parseByte(),t<<24|n<<16|s<<8|o;if(e===30)return qp(i);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=i.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=i.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function Zp(i){const e={};for(let t=0;t<i.length;t+=1){const n=i[t][0],s=i[t][1];let o;if(s.length===1?o=s[0]:o=s,e.hasOwnProperty(n)&&!isNaN(e[n]))throw new Error("Object "+e+" already has key "+n);e[n]=o}return e}function jr(i,e,t){e=e!==void 0?e:0;const n=new $.Parser(i,e),s=[];let o=[];for(t=t!==void 0?t:i.length;n.relativeOffset<t;){let r=n.parseByte();r<=21?(r===12&&(r=1200+n.parseByte()),s.push([r,o]),o=[]):o.push(Jp(n,r))}return Zp(s)}function li(i,e){return e<=390?e=qi[e]:e=i[e-391],e}function Kr(i,e,t){const n={};let s;for(let o=0;o<e.length;o+=1){const r=e[o];if(Array.isArray(r.type)){const l=[];l.length=r.type.length;for(let a=0;a<r.type.length;a++)s=i[r.op]!==void 0?i[r.op][a]:void 0,s===void 0&&(s=r.value!==void 0&&r.value[a]!==void 0?r.value[a]:null),r.type[a]==="SID"&&(s=li(t,s)),l[a]=s;n[r.name]=l}else s=i[r.op],s===void 0&&(s=r.value!==void 0?r.value:null),r.type==="SID"&&(s=li(t,s)),n[r.name]=s}return n}function eg(i,e){const t={};return t.formatMajor=$.getCard8(i,e),t.formatMinor=$.getCard8(i,e+1),t.size=$.getCard8(i,e+2),t.offsetSize=$.getCard8(i,e+3),t.startOffset=e,t.endOffset=e+4,t}const $r=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],Xr=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}];function tg(i,e){const t=jr(i,0,i.byteLength);return Kr(t,$r,e)}function qr(i,e,t,n){const s=jr(i,e,t);return Kr(s,Xr,n)}function Jr(i,e,t,n){const s=[];for(let o=0;o<t.length;o+=1){const r=new DataView(new Uint8Array(t[o]).buffer),l=tg(r,n);l._subrs=[],l._subrsBias=0;const a=l.private[0],d=l.private[1];if(a!==0&&d!==0){const h=qr(i,d+e,a,n);if(l._defaultWidthX=h.defaultWidthX,l._nominalWidthX=h.nominalWidthX,h.subrs!==0){const p=d+h.subrs,f=ct(i,p+e);l._subrs=f.objects,l._subrsBias=hs(l._subrs)}l._privateDict=h}s.push(l)}return s}function ig(i,e,t,n){let s,o;const r=new $.Parser(i,e);t-=1;const l=[".notdef"],a=r.parseCard8();if(a===0)for(let d=0;d<t;d+=1)s=r.parseSID(),l.push(li(n,s));else if(a===1)for(;l.length<=t;){s=r.parseSID(),o=r.parseCard8();for(let d=0;d<=o;d+=1)l.push(li(n,s)),s+=1}else if(a===2)for(;l.length<=t;){s=r.parseSID(),o=r.parseCard16();for(let d=0;d<=o;d+=1)l.push(li(n,s)),s+=1}else throw new Error("Unknown charset format "+a);return l}function ng(i,e,t){let n;const s={},o=new $.Parser(i,e),r=o.parseCard8();if(r===0){const l=o.parseCard8();for(let a=0;a<l;a+=1)n=o.parseCard8(),s[n]=a}else if(r===1){const l=o.parseCard8();n=1;for(let a=0;a<l;a+=1){const d=o.parseCard8(),h=o.parseCard8();for(let p=d;p<=d+h;p+=1)s[p]=n,n+=1}}else throw new Error("Unknown encoding format "+r);return new Ji(s,t)}function sg(i,e,t){let n,s,o,r;const l=new be,a=[];let d=0,h=!1,p=!1,f=0,u=0,m,E,A,y;if(i.isCIDFont){const I=i.tables.cff.topDict._fdSelect[e.index],B=i.tables.cff.topDict._fdArray[I];m=B._subrs,E=B._subrsBias,A=B._defaultWidthX,y=B._nominalWidthX}else m=i.tables.cff.topDict._subrs,E=i.tables.cff.topDict._subrsBias,A=i.tables.cff.topDict._defaultWidthX,y=i.tables.cff.topDict._nominalWidthX;let v=A;function S(I,B){p&&l.closePath(),l.moveTo(I,B),p=!0}function M(){let I;I=a.length%2!==0,I&&!h&&(v=a.shift()+y),d+=a.length>>1,a.length=0,h=!0}function O(I){let B,g,P,x,F,_,H,N,w,C,b,D,k=0;for(;k<I.length;){let Q=I[k];switch(k+=1,Q){case 1:M();break;case 3:M();break;case 4:a.length>1&&!h&&(v=a.shift()+y,h=!0),u+=a.pop(),S(f,u);break;case 5:for(;a.length>0;)f+=a.shift(),u+=a.shift(),l.lineTo(f,u);break;case 6:for(;a.length>0&&(f+=a.shift(),l.lineTo(f,u),a.length!==0);)u+=a.shift(),l.lineTo(f,u);break;case 7:for(;a.length>0&&(u+=a.shift(),l.lineTo(f,u),a.length!==0);)f+=a.shift(),l.lineTo(f,u);break;case 8:for(;a.length>0;)n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r+a.shift(),l.curveTo(n,s,o,r,f,u);break;case 10:F=a.pop()+E,_=m[F],_&&O(_);break;case 11:return;case 12:switch(Q=I[k],k+=1,Q){case 35:n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),H=o+a.shift(),N=r+a.shift(),w=H+a.shift(),C=N+a.shift(),b=w+a.shift(),D=C+a.shift(),f=b+a.shift(),u=D+a.shift(),a.shift(),l.curveTo(n,s,o,r,H,N),l.curveTo(w,C,b,D,f,u);break;case 34:n=f+a.shift(),s=u,o=n+a.shift(),r=s+a.shift(),H=o+a.shift(),N=r,w=H+a.shift(),C=r,b=w+a.shift(),D=u,f=b+a.shift(),l.curveTo(n,s,o,r,H,N),l.curveTo(w,C,b,D,f,u);break;case 36:n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),H=o+a.shift(),N=r,w=H+a.shift(),C=r,b=w+a.shift(),D=C+a.shift(),f=b+a.shift(),l.curveTo(n,s,o,r,H,N),l.curveTo(w,C,b,D,f,u);break;case 37:n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),H=o+a.shift(),N=r+a.shift(),w=H+a.shift(),C=N+a.shift(),b=w+a.shift(),D=C+a.shift(),Math.abs(b-f)>Math.abs(D-u)?f=b+a.shift():u=D+a.shift(),l.curveTo(n,s,o,r,H,N),l.curveTo(w,C,b,D,f,u);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Q),a.length=0}break;case 14:a.length>0&&!h&&(v=a.shift()+y,h=!0),p&&(l.closePath(),p=!1);break;case 18:M();break;case 19:case 20:M(),k+=d+7>>3;break;case 21:a.length>2&&!h&&(v=a.shift()+y,h=!0),u+=a.pop(),f+=a.pop(),S(f,u);break;case 22:a.length>1&&!h&&(v=a.shift()+y,h=!0),f+=a.pop(),S(f,u);break;case 23:M();break;case 24:for(;a.length>2;)n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r+a.shift(),l.curveTo(n,s,o,r,f,u);f+=a.shift(),u+=a.shift(),l.lineTo(f,u);break;case 25:for(;a.length>6;)f+=a.shift(),u+=a.shift(),l.lineTo(f,u);n=f+a.shift(),s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r+a.shift(),l.curveTo(n,s,o,r,f,u);break;case 26:for(a.length%2&&(f+=a.shift());a.length>0;)n=f,s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o,u=r+a.shift(),l.curveTo(n,s,o,r,f,u);break;case 27:for(a.length%2&&(u+=a.shift());a.length>0;)n=f+a.shift(),s=u,o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r,l.curveTo(n,s,o,r,f,u);break;case 28:B=I[k],g=I[k+1],a.push((B<<24|g<<16)>>16),k+=2;break;case 29:F=a.pop()+i.gsubrsBias,_=i.gsubrs[F],_&&O(_);break;case 30:for(;a.length>0&&(n=f,s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r+(a.length===1?a.shift():0),l.curveTo(n,s,o,r,f,u),a.length!==0);)n=f+a.shift(),s=u,o=n+a.shift(),r=s+a.shift(),u=r+a.shift(),f=o+(a.length===1?a.shift():0),l.curveTo(n,s,o,r,f,u);break;case 31:for(;a.length>0&&(n=f+a.shift(),s=u,o=n+a.shift(),r=s+a.shift(),u=r+a.shift(),f=o+(a.length===1?a.shift():0),l.curveTo(n,s,o,r,f,u),a.length!==0);)n=f,s=u+a.shift(),o=n+a.shift(),r=s+a.shift(),f=o+a.shift(),u=r+(a.length===1?a.shift():0),l.curveTo(n,s,o,r,f,u);break;default:Q<32?console.log("Glyph "+e.index+": unknown operator "+Q):Q<247?a.push(Q-139):Q<251?(B=I[k],k+=1,a.push((Q-247)*256+B+108)):Q<255?(B=I[k],k+=1,a.push(-(Q-251)*256-B-108)):(B=I[k],g=I[k+1],P=I[k+2],x=I[k+3],k+=4,a.push((B<<24|g<<16|P<<8|x)/65536))}}}return O(t),e.advanceWidth=v,l}function og(i,e,t,n){const s=[];let o;const r=new $.Parser(i,e),l=r.parseCard8();if(l===0)for(let a=0;a<t;a++){if(o=r.parseCard8(),o>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+n+")");s.push(o)}else if(l===3){const a=r.parseCard16();let d=r.parseCard16();if(d!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+d);let h;for(let p=0;p<a;p++){if(o=r.parseCard8(),h=r.parseCard16(),o>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+n+")");if(h>t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+h);for(;d<h;d++)s.push(o);d=h}if(h!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+h)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+l);return s}function rg(i,e,t){t.tables.cff={};const n=eg(i,e),s=ct(i,n.endOffset,$.bytesToString),o=ct(i,s.endOffset),r=ct(i,o.endOffset,$.bytesToString),l=ct(i,r.endOffset);t.gsubrs=l.objects,t.gsubrsBias=hs(t.gsubrs);const a=Jr(i,e,o.objects,r.objects);if(a.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+a.length);const d=a[0];if(t.tables.cff.topDict=d,d._privateDict&&(t.defaultWidthX=d._privateDict.defaultWidthX,t.nominalWidthX=d._privateDict.nominalWidthX),d.ros[0]!==void 0&&d.ros[1]!==void 0&&(t.isCIDFont=!0),t.isCIDFont){let m=d.fdArray,E=d.fdSelect;if(m===0||E===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");m+=e;const A=ct(i,m),y=Jr(i,e,A.objects,r.objects);d._fdArray=y,E+=e,d._fdSelect=og(i,E,t.numGlyphs,y.length)}const h=e+d.private[1],p=qr(i,h,d.private[0],r.objects);if(t.defaultWidthX=p.defaultWidthX,t.nominalWidthX=p.nominalWidthX,p.subrs!==0){const m=h+p.subrs,E=ct(i,m);t.subrs=E.objects,t.subrsBias=hs(t.subrs)}else t.subrs=[],t.subrsBias=0;const f=ct(i,e+d.charStrings);t.nGlyphs=f.objects.length;const u=ig(i,e+d.charset,t.nGlyphs,r.objects);d.encoding===0?t.cffEncoding=new Ji(Yp,u):d.encoding===1?t.cffEncoding=new Ji(Vp,u):t.cffEncoding=ng(i,e+d.encoding,u),t.encoding=t.encoding||t.cffEncoding,t.glyphs=new Yt.GlyphSet(t);for(let m=0;m<t.nGlyphs;m+=1){const E=f.objects[m];t.glyphs.push(m,Yt.cffGlyphLoader(t,m,sg,E))}}function Zr(i,e){let t,n=qi.indexOf(i);return n>=0&&(t=n),n=e.indexOf(i),n>=0?t=n+qi.length:(t=qi.length+e.length,e.push(i)),t}function ag(){return new J.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function lg(i){const e=new J.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t<i.length;t+=1)e.names.push({name:"name_"+t,type:"NAME",value:i[t]});return e}function ea(i,e,t){const n={};for(let s=0;s<i.length;s+=1){const o=i[s];let r=e[o.name];r!==void 0&&!Wr(r,o.value)&&(o.type==="SID"&&(r=Zr(r,t)),n[o.op]={name:o.name,type:o.type,value:r})}return n}function ta(i,e){const t=new J.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=ea($r,i,e),t}function ia(i){const e=new J.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:i}],e}function cg(i){const e=new J.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(let t=0;t<i.length;t+=1)e.strings.push({name:"string_"+t,type:"STRING",value:i[t]});return e}function dg(){return new J.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function hg(i,e){const t=new J.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let n=0;n<i.length;n+=1){const s=i[n],o=Zr(s,e);t.fields.push({name:"glyph_"+n,type:"SID",value:o})}return t}function ug(i){const e=[],t=i.path;e.push({name:"width",type:"NUMBER",value:i.advanceWidth});let n=0,s=0;for(let o=0;o<t.commands.length;o+=1){let r,l,a=t.commands[o];if(a.type==="Q"){const d=.3333333333333333,h=2/3;a={type:"C",x:a.x,y:a.y,x1:d*n+h*a.x1,y1:d*s+h*a.y1,x2:d*a.x+h*a.x1,y2:d*a.y+h*a.y1}}if(a.type==="M")r=Math.round(a.x-n),l=Math.round(a.y-s),e.push({name:"dx",type:"NUMBER",value:r}),e.push({name:"dy",type:"NUMBER",value:l}),e.push({name:"rmoveto",type:"OP",value:21}),n=Math.round(a.x),s=Math.round(a.y);else if(a.type==="L")r=Math.round(a.x-n),l=Math.round(a.y-s),e.push({name:"dx",type:"NUMBER",value:r}),e.push({name:"dy",type:"NUMBER",value:l}),e.push({name:"rlineto",type:"OP",value:5}),n=Math.round(a.x),s=Math.round(a.y);else if(a.type==="C"){const d=Math.round(a.x1-n),h=Math.round(a.y1-s),p=Math.round(a.x2-a.x1),f=Math.round(a.y2-a.y1);r=Math.round(a.x-a.x2),l=Math.round(a.y-a.y2),e.push({name:"dx1",type:"NUMBER",value:d}),e.push({name:"dy1",type:"NUMBER",value:h}),e.push({name:"dx2",type:"NUMBER",value:p}),e.push({name:"dy2",type:"NUMBER",value:f}),e.push({name:"dx",type:"NUMBER",value:r}),e.push({name:"dy",type:"NUMBER",value:l}),e.push({name:"rrcurveto",type:"OP",value:8}),n=Math.round(a.x),s=Math.round(a.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function fg(i){const e=new J.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let t=0;t<i.length;t+=1){const n=i.get(t),s=ug(n);e.charStrings.push({name:n.name,type:"CHARSTRING",value:s})}return e}function pg(i,e){const t=new J.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=ea(Xr,i,e),t}function gg(i,e){const t=new J.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),n=1/e.unitsPerEm,s={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[n,0,0,n,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},o={},r=[];let l;for(let p=1;p<i.length;p+=1)l=i.get(p),r.push(l.name);const a=[];t.header=ag(),t.nameIndex=lg([e.postScriptName]);let d=ta(s,a);t.topDictIndex=ia(d),t.globalSubrIndex=dg(),t.charsets=hg(r,a),t.charStringsIndex=fg(i),t.privateDict=pg(o,a),t.stringIndex=cg(a);const h=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return s.charset=h,s.encoding=0,s.charStrings=s.charset+t.charsets.sizeOf(),s.private[1]=s.charStrings+t.charStringsIndex.sizeOf(),d=ta(s,a),t.topDictIndex=ia(d),t}const na={parse:rg,make:gg};function mg(i,e){const t={},n=new $.Parser(i,e);return t.version=n.parseVersion(),t.fontRevision=Math.round(n.parseFixed()*1e3)/1e3,t.checkSumAdjustment=n.parseULong(),t.magicNumber=n.parseULong(),te.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=n.parseUShort(),t.unitsPerEm=n.parseUShort(),t.created=n.parseLongDateTime(),t.modified=n.parseLongDateTime(),t.xMin=n.parseShort(),t.yMin=n.parseShort(),t.xMax=n.parseShort(),t.yMax=n.parseShort(),t.macStyle=n.parseUShort(),t.lowestRecPPEM=n.parseUShort(),t.fontDirectionHint=n.parseShort(),t.indexToLocFormat=n.parseShort(),t.glyphDataFormat=n.parseShort(),t}function Ag(i){const e=Math.round(new Date().getTime()/1e3)+2082844800;let t=e;return i.createdTimestamp&&(t=i.createdTimestamp+2082844800),new J.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:t},{name:"modified",type:"LONGDATETIME",value:e},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:0},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],i)}const sa={parse:mg,make:Ag};function yg(i,e){const t={},n=new $.Parser(i,e);return t.version=n.parseVersion(),t.ascender=n.parseShort(),t.descender=n.parseShort(),t.lineGap=n.parseShort(),t.advanceWidthMax=n.parseUShort(),t.minLeftSideBearing=n.parseShort(),t.minRightSideBearing=n.parseShort(),t.xMaxExtent=n.parseShort(),t.caretSlopeRise=n.parseShort(),t.caretSlopeRun=n.parseShort(),t.caretOffset=n.parseShort(),n.relativeOffset+=8,t.metricDataFormat=n.parseShort(),t.numberOfHMetrics=n.parseUShort(),t}function Cg(i){return new J.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],i)}const oa={parse:yg,make:Cg};function Eg(i,e,t,n,s){let o,r;const l=new $.Parser(i,e);for(let a=0;a<n;a+=1){a<t&&(o=l.parseUShort(),r=l.parseShort());const d=s.get(a);d.advanceWidth=o,d.leftSideBearing=r}}function wg(i){const e=new J.Table("hmtx",[]);for(let t=0;t<i.length;t+=1){const n=i.get(t),s=n.advanceWidth||0,o=n.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+t,type:"USHORT",value:s}),e.fields.push({name:"leftSideBearing_"+t,type:"SHORT",value:o})}return e}const ra={parse:Eg,make:wg};function bg(i){const e=new J.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:i.length}]);let t="";const n=12+i.length*4;for(let s=0;s<i.length;++s){let o=t.indexOf(i[s]);o<0&&(o=t.length,t+=i[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:n+o}),e.fields.push({name:"length "+s,type:"USHORT",value:i[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function vg(i,e){const t=new $.Parser(i,e),n=t.parseULong();te.argument(n===1,"Unsupported ltag table version."),t.skip("uLong",1);const s=t.parseULong(),o=[];for(let r=0;r<s;r++){let l="";const a=e+t.parseUShort(),d=t.parseUShort();for(let h=a;h<a+d;++h)l+=String.fromCharCode(i.getInt8(h));o.push(l)}return o}const aa={make:bg,parse:vg};function Ig(i,e){const t={},n=new $.Parser(i,e);return t.version=n.parseVersion(),t.numGlyphs=n.parseUShort(),t.version===1&&(t.maxPoints=n.parseUShort(),t.maxContours=n.parseUShort(),t.maxCompositePoints=n.parseUShort(),t.maxCompositeContours=n.parseUShort(),t.maxZones=n.parseUShort(),t.maxTwilightPoints=n.parseUShort(),t.maxStorage=n.parseUShort(),t.maxFunctionDefs=n.parseUShort(),t.maxInstructionDefs=n.parseUShort(),t.maxStackElements=n.parseUShort(),t.maxSizeOfInstructions=n.parseUShort(),t.maxComponentElements=n.parseUShort(),t.maxComponentDepth=n.parseUShort()),t}function Bg(i){return new J.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:i}])}const la={parse:Ig,make:Bg},ca=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],da={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},xg={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},ha={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function Sg(i,e,t){switch(i){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return da[e];case 3:return ha[e]}}const us="utf-16",Tg={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},Mg={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function ua(i,e,t){switch(i){case 0:return us;case 1:return Mg[t]||Tg[e];case 3:if(e===1||e===10)return us;break}}function Dg(i,e,t){const n={},s=new $.Parser(i,e),o=s.parseUShort(),r=s.parseUShort(),l=s.offset+s.parseUShort();for(let a=0;a<r;a++){const d=s.parseUShort(),h=s.parseUShort(),p=s.parseUShort(),f=s.parseUShort(),u=ca[f]||f,m=s.parseUShort(),E=s.parseUShort(),A=Sg(d,p,t),y=ua(d,h,p);if(y!==void 0&&A!==void 0){let v;if(y===us?v=Ht.UTF16(i,l+E,m):v=Ht.MACSTRING(i,l+E,m,y),v){let S=n[u];S===void 0&&(S=n[u]={}),S[A]=v}}}return o===1&&s.parseUShort(),n}function fs(i){const e={};for(let t in i)e[i[t]]=parseInt(t);return e}function fa(i,e,t,n,s,o){return new J.Record("NameRecord",[{name:"platformID",type:"USHORT",value:i},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:t},{name:"nameID",type:"USHORT",value:n},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:o}])}function kg(i,e){const t=i.length,n=e.length-t+1;e:for(let s=0;s<n;s++)for(;s<n;s++){for(let o=0;o<t;o++)if(e[s+o]!==i[o])continue e;return s}return-1}function pa(i,e){let t=kg(i,e);if(t<0){t=e.length;let n=0;const s=i.length;for(;n<s;++n)e.push(i[n])}return t}function Pg(i,e){let t;const n=[],s={},o=fs(ca);for(let p in i){let f=o[p];if(f===void 0&&(f=p),t=parseInt(f),isNaN(t))throw new Error('Name table entry "'+p+'" does not exist, see nameTableNames for complete list.');s[t]=i[p],n.push(t)}const r=fs(da),l=fs(ha),a=[],d=[];for(let p=0;p<n.length;p++){t=n[p];const f=s[t];for(let u in f){const m=f[u];let E=1,A=r[u],y=xg[A];const v=ua(E,y,A);let S=z.MACSTRING(m,v);S===void 0&&(E=0,A=e.indexOf(u),A<0&&(A=e.length,e.push(u)),y=4,S=z.UTF16(m));const M=pa(S,d);a.push(fa(E,y,A,t,S.length,M));const O=l[u];if(O!==void 0){const I=z.UTF16(m),B=pa(I,d);a.push(fa(3,1,O,t,I.length,B))}}}a.sort(function(p,f){return p.platformID-f.platformID||p.encodingID-f.encodingID||p.languageID-f.languageID||p.nameID-f.nameID});const h=new J.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:a.length},{name:"stringOffset",type:"USHORT",value:6+a.length*12}]);for(let p=0;p<a.length;p++)h.fields.push({name:"record_"+p,type:"RECORD",value:a[p]});return h.fields.push({name:"strings",type:"LITERAL",value:d}),h}const ga={parse:Dg,make:Pg},ps=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function Fg(i){for(let e=0;e<ps.length;e+=1){const t=ps[e];if(i>=t.begin&&i<t.end)return e}return-1}function Rg(i,e){const t={},n=new $.Parser(i,e);t.version=n.parseUShort(),t.xAvgCharWidth=n.parseShort(),t.usWeightClass=n.parseUShort(),t.usWidthClass=n.parseUShort(),t.fsType=n.parseUShort(),t.ySubscriptXSize=n.parseShort(),t.ySubscriptYSize=n.parseShort(),t.ySubscriptXOffset=n.parseShort(),t.ySubscriptYOffset=n.parseShort(),t.ySuperscriptXSize=n.parseShort(),t.ySuperscriptYSize=n.parseShort(),t.ySuperscriptXOffset=n.parseShort(),t.ySuperscriptYOffset=n.parseShort(),t.yStrikeoutSize=n.parseShort(),t.yStrikeoutPosition=n.parseShort(),t.sFamilyClass=n.parseShort(),t.panose=[];for(let s=0;s<10;s++)t.panose[s]=n.parseByte();return t.ulUnicodeRange1=n.parseULong(),t.ulUnicodeRange2=n.parseULong(),t.ulUnicodeRange3=n.parseULong(),t.ulUnicodeRange4=n.parseULong(),t.achVendID=String.fromCharCode(n.parseByte(),n.parseByte(),n.parseByte(),n.parseByte()),t.fsSelection=n.parseUShort(),t.usFirstCharIndex=n.parseUShort(),t.usLastCharIndex=n.parseUShort(),t.sTypoAscender=n.parseShort(),t.sTypoDescender=n.parseShort(),t.sTypoLineGap=n.parseShort(),t.usWinAscent=n.parseUShort(),t.usWinDescent=n.parseUShort(),t.version>=1&&(t.ulCodePageRange1=n.parseULong(),t.ulCodePageRange2=n.parseULong()),t.version>=2&&(t.sxHeight=n.parseShort(),t.sCapHeight=n.parseShort(),t.usDefaultChar=n.parseUShort(),t.usBreakChar=n.parseUShort(),t.usMaxContent=n.parseUShort()),t}function Og(i){return new J.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],i)}const gs={parse:Rg,make:Og,unicodeRanges:ps,getUnicodeRange:Fg};function Lg(i,e){const t={},n=new $.Parser(i,e);switch(t.version=n.parseVersion(),t.italicAngle=n.parseFixed(),t.underlinePosition=n.parseShort(),t.underlineThickness=n.parseShort(),t.isFixedPitch=n.parseULong(),t.minMemType42=n.parseULong(),t.maxMemType42=n.parseULong(),t.minMemType1=n.parseULong(),t.maxMemType1=n.parseULong(),t.version){case 1:t.names=wt.slice();break;case 2:t.numberOfGlyphs=n.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s<t.numberOfGlyphs;s++)t.glyphNameIndex[s]=n.parseUShort();t.names=[];for(let s=0;s<t.numberOfGlyphs;s++)if(t.glyphNameIndex[s]>=wt.length){const o=n.parseChar();t.names.push(n.parseString(o))}break;case 2.5:t.numberOfGlyphs=n.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s<t.numberOfGlyphs;s++)t.offset[s]=n.parseChar();break}return t}function Ng(){return new J.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:0},{name:"underlinePosition",type:"FWORD",value:0},{name:"underlineThickness",type:"FWORD",value:0},{name:"isFixedPitch",type:"ULONG",value:0},{name:"minMemType42",type:"ULONG",value:0},{name:"maxMemType42",type:"ULONG",value:0},{name:"minMemType1",type:"ULONG",value:0},{name:"maxMemType1",type:"ULONG",value:0}])}const ma={parse:Lg,make:Ng},_e=new Array(9);_e[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(G.coverage),deltaGlyphId:this.parseUShort()};if(t===2)return{substFormat:2,coverage:this.parsePointer(G.coverage),substitute:this.parseOffset16List()};te.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")},_e[2]=function(){const e=this.parseUShort();return te.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(G.coverage),sequences:this.parseListOfLists()}},_e[3]=function(){const e=this.parseUShort();return te.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(G.coverage),alternateSets:this.parseListOfLists()}},_e[4]=function(){const e=this.parseUShort();return te.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(G.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};const Vt={sequenceIndex:G.uShort,lookupListIndex:G.uShort};_e[5]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:t,coverage:this.parsePointer(G.coverage),ruleSets:this.parseListOfLists(function(){const n=this.parseUShort(),s=this.parseUShort();return{input:this.parseUShortList(n-1),lookupRecords:this.parseRecordList(s,Vt)}})};if(t===2)return{substFormat:t,coverage:this.parsePointer(G.coverage),classDef:this.parsePointer(G.classDef),classSets:this.parseListOfLists(function(){const n=this.parseUShort(),s=this.parseUShort();return{classes:this.parseUShortList(n-1),lookupRecords:this.parseRecordList(s,Vt)}})};if(t===3){const n=this.parseUShort(),s=this.parseUShort();return{substFormat:t,coverages:this.parseList(n,G.pointer(G.coverage)),lookupRecords:this.parseRecordList(s,Vt)}}te.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},_e[6]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(G.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Vt)}})};if(t===2)return{substFormat:2,coverage:this.parsePointer(G.coverage),backtrackClassDef:this.parsePointer(G.classDef),inputClassDef:this.parsePointer(G.classDef),lookaheadClassDef:this.parsePointer(G.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Vt)}})};if(t===3)return{substFormat:3,backtrackCoverage:this.parseList(G.pointer(G.coverage)),inputCoverage:this.parseList(G.pointer(G.coverage)),lookaheadCoverage:this.parseList(G.pointer(G.coverage)),lookupRecords:this.parseRecordList(Vt)};te.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},_e[7]=function(){const e=this.parseUShort();te.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");const t=this.parseUShort(),n=new G(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:_e[t].call(n)}},_e[8]=function(){const e=this.parseUShort();return te.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(G.coverage),backtrackCoverage:this.parseList(G.pointer(G.coverage)),lookaheadCoverage:this.parseList(G.pointer(G.coverage)),substitutes:this.parseUShortList()}};function Ug(i,e){e=e||0;const t=new G(i,e),n=t.parseVersion(1);return te.argument(n===1||n===1.1,"Unsupported GSUB table version."),n===1?{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(_e)}:{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(_e),variations:t.parseFeatureVariationsList()}}const en=new Array(9);en[1]=function(e){return e.substFormat===1?new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new J.Coverage(e.coverage)}].concat(J.ushortList("substitute",e.substitute)))},en[3]=function(e){return te.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(e.coverage)}].concat(J.tableList("altSet",e.alternateSets,function(t){return new J.Table("alternateSetTable",J.ushortList("alternate",t))})))},en[4]=function(e){return te.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(e.coverage)}].concat(J.tableList("ligSet",e.ligatureSets,function(t){return new J.Table("ligatureSetTable",J.tableList("ligature",t,function(n){return new J.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:n.ligGlyph}].concat(J.ushortList("component",n.components,n.components.length+1)))}))})))};function _g(i){return new J.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new J.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new J.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new J.LookupList(i.lookups,en)}])}const Aa={parse:Ug,make:_g};function Qg(i,e){const t=new $.Parser(i,e),n=t.parseULong();te.argument(n===1,"Unsupported META table version."),t.parseULong(),t.parseULong();const s=t.parseULong(),o={};for(let r=0;r<s;r++){const l=t.parseTag(),a=t.parseULong(),d=t.parseULong(),h=Ht.UTF8(i,e+a,d);o[l]=h}return o}function Gg(i){const e=Object.keys(i).length;let t="";const n=16+e*12,s=new J.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:n},{name:"numTags",type:"ULONG",value:e}]);for(let o in i){const r=t.length;t+=i[o],s.fields.push({name:"tag "+o,type:"TAG",value:o}),s.fields.push({name:"offset "+o,type:"ULONG",value:n+r}),s.fields.push({name:"length "+o,type:"ULONG",value:i[o].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),s}const ya={parse:Qg,make:Gg};function Ca(i){return Math.log(i)/Math.log(2)|0}function ms(i){for(;i.length%4!==0;)i.push(0);let e=0;for(let t=0;t<i.length;t+=4)e+=(i[t]<<24)+(i[t+1]<<16)+(i[t+2]<<8)+i[t+3];return e%=Math.pow(2,32),e}function Ea(i,e,t,n){return new J.Record("Table Record",[{name:"tag",type:"TAG",value:i!==void 0?i:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:t!==void 0?t:0},{name:"length",type:"ULONG",value:n!==void 0?n:0}])}function wa(i){const e=new J.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);e.tables=i,e.numTables=i.length;const t=Math.pow(2,Ca(e.numTables));e.searchRange=16*t,e.entrySelector=Ca(t),e.rangeShift=e.numTables*16-e.searchRange;const n=[],s=[];let o=e.sizeOf()+Ea().sizeOf()*e.numTables;for(;o%4!==0;)o+=1,s.push({name:"padding",type:"BYTE",value:0});for(let r=0;r<i.length;r+=1){const l=i[r];te.argument(l.tableName.length===4,"Table name"+l.tableName+" is invalid.");const a=l.sizeOf(),d=Ea(l.tableName,ms(l.encode()),o,a);for(n.push({name:d.tag+" Table Record",type:"RECORD",value:d}),s.push({name:l.tableName+" table",type:"RECORD",value:l}),o+=a,te.argument(!isNaN(o),"Something went wrong calculating the offset.");o%4!==0;)o+=1,s.push({name:"padding",type:"BYTE",value:0})}return n.sort(function(r,l){return r.value.tag>l.value.tag?1:-1}),e.fields=e.fields.concat(n),e.fields=e.fields.concat(s),e}function ba(i,e,t){for(let n=0;n<e.length;n+=1){const s=i.charToGlyphIndex(e[n]);if(s>0)return i.glyphs.get(s).getMetrics()}return t}function Hg(i){let e=0;for(let t=0;t<i.length;t+=1)e+=i[t];return e/i.length}function Yg(i){const e=[],t=[],n=[],s=[],o=[],r=[],l=[];let a,d=0,h=0,p=0,f=0,u=0;for(let T=0;T<i.glyphs.length;T+=1){const U=i.glyphs.get(T),V=U.unicode|0;if(isNaN(U.advanceWidth))throw new Error("Glyph "+U.name+" ("+T+"): advanceWidth is not a number.");(a>V||a===void 0)&&V>0&&(a=V),d<V&&(d=V);const W=gs.getUnicodeRange(V);if(W<32)h|=1<<W;else if(W<64)p|=1<<W-32;else if(W<96)f|=1<<W-64;else if(W<123)u|=1<<W-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(U.name===".notdef")continue;const q=U.getMetrics();e.push(q.xMin),t.push(q.yMin),n.push(q.xMax),s.push(q.yMax),r.push(q.leftSideBearing),l.push(q.rightSideBearing),o.push(U.advanceWidth)}const m={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,n),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,o),advanceWidthAvg:Hg(o),minLeftSideBearing:Math.min.apply(null,r),maxLeftSideBearing:Math.max.apply(null,r),minRightSideBearing:Math.min.apply(null,l)};m.ascender=i.ascender,m.descender=i.descender;const E=sa.make({flags:3,unitsPerEm:i.unitsPerEm,xMin:m.xMin,yMin:m.yMin,xMax:m.xMax,yMax:m.yMax,lowestRecPPEM:3,createdTimestamp:i.createdTimestamp}),A=oa.make({ascender:m.ascender,descender:m.descender,advanceWidthMax:m.advanceWidthMax,minLeftSideBearing:m.minLeftSideBearing,minRightSideBearing:m.minRightSideBearing,xMaxExtent:m.maxLeftSideBearing+(m.xMax-m.xMin),numberOfHMetrics:i.glyphs.length}),y=la.make(i.glyphs.length),v=gs.make({xAvgCharWidth:Math.round(m.advanceWidthAvg),usWeightClass:i.tables.os2.usWeightClass,usWidthClass:i.tables.os2.usWidthClass,usFirstCharIndex:a,usLastCharIndex:d,ulUnicodeRange1:h,ulUnicodeRange2:p,ulUnicodeRange3:f,ulUnicodeRange4:u,fsSelection:i.tables.os2.fsSelection,sTypoAscender:m.ascender,sTypoDescender:m.descender,sTypoLineGap:0,usWinAscent:m.yMax,usWinDescent:Math.abs(m.yMin),ulCodePageRange1:1,sxHeight:ba(i,"xyvw",{yMax:Math.round(m.ascender/2)}).yMax,sCapHeight:ba(i,"HIKLEFJMNTZBDPRAGOQSUVWXY",m).yMax,usDefaultChar:i.hasChar(" ")?32:0,usBreakChar:i.hasChar(" ")?32:0}),S=ra.make(i.glyphs),M=Yr.make(i.glyphs),O=i.getEnglishName("fontFamily"),I=i.getEnglishName("fontSubfamily"),B=O+" "+I;let g=i.getEnglishName("postScriptName");g||(g=O.replace(/\s/g,"")+"-"+I);const P={};for(let T in i.names)P[T]=i.names[T];P.uniqueID||(P.uniqueID={en:i.getEnglishName("manufacturer")+":"+B}),P.postScriptName||(P.postScriptName={en:g}),P.preferredFamily||(P.preferredFamily=i.names.fontFamily),P.preferredSubfamily||(P.preferredSubfamily=i.names.fontSubfamily);const x=[],F=ga.make(P,x),_=x.length>0?aa.make(x):void 0,H=ma.make(),N=na.make(i.glyphs,{version:i.getEnglishName("version"),fullName:B,familyName:O,weightName:I,postScriptName:g,unitsPerEm:i.unitsPerEm,fontBBox:[0,m.yMin,m.ascender,m.advanceWidthMax]}),w=i.metas&&Object.keys(i.metas).length>0?ya.make(i.metas):void 0,C=[E,A,y,v,F,M,H,N,S];_&&C.push(_),i.tables.gsub&&C.push(Aa.make(i.tables.gsub)),w&&C.push(w);const b=wa(C),D=b.encode(),k=ms(D),Q=b.fields;let R=!1;for(let T=0;T<Q.length;T+=1)if(Q[T].name==="head table"){Q[T].value.checkSumAdjustment=2981146554-k,R=!0;break}if(!R)throw new Error("Could not find head table with checkSum to adjust.");return b}const Vg={make:wa,fontToTable:Yg,computeCheckSum:ms};function As(i,e){let t=0,n=i.length-1;for(;t<=n;){const s=t+n>>>1,o=i[s].tag;if(o===e)return s;o<e?t=s+1:n=s-1}return-t-1}function va(i,e){let t=0,n=i.length-1;for(;t<=n;){const s=t+n>>>1,o=i[s];if(o===e)return s;o<e?t=s+1:n=s-1}return-t-1}function Ia(i,e){let t,n=0,s=i.length-1;for(;n<=s;){const o=n+s>>>1;t=i[o];const r=t.start;if(r===e)return t;r<e?n=o+1:s=o-1}if(n>0)return t=i[n-1],e>t.end?0:t}function ci(i,e){this.font=i,this.tableName=e}ci.prototype={searchTag:As,binSearch:va,getTable:function(i){let e=this.font.tables[this.tableName];return!e&&i&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let i=this.getTable();return i?i.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let i=this.getTable();if(!i)return;let e=!1;for(let t=0;t<i.scripts.length;t++){const n=i.scripts[t].tag;if(n==="DFLT")return n;n==="latn"&&(e=!0)}if(e)return"latn"},getScriptTable:function(i,e){const t=this.getTable(e);if(t){i=i||"DFLT";const n=t.scripts,s=As(t.scripts,i);if(s>=0)return n[s].script;if(e){const o={tag:i,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return n.splice(-1-s,0,o),o.script}}},getLangSysTable:function(i,e,t){const n=this.getScriptTable(i,t);if(n){if(!e||e==="dflt"||e==="DFLT")return n.defaultLangSys;const s=As(n.langSysRecords,e);if(s>=0)return n.langSysRecords[s].langSys;if(t){const o={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return n.langSysRecords.splice(-1-s,0,o),o.langSys}}},getFeatureTable:function(i,e,t,n){const s=this.getLangSysTable(i,e,n);if(s){let o;const r=s.featureIndexes,l=this.font.tables[this.tableName].features;for(let a=0;a<r.length;a++)if(o=l[r[a]],o.tag===t)return o.feature;if(n){const a=l.length;return te.assert(a===0||t>=l[a-1].tag,"Features must be added in alphabetical order."),o={tag:t,feature:{params:0,lookupListIndexes:[]}},l.push(o),r.push(a),o.feature}}},getLookupTables:function(i,e,t,n,s){const o=this.getFeatureTable(i,e,t,s),r=[];if(o){let l;const a=o.lookupListIndexes,d=this.font.tables[this.tableName].lookups;for(let h=0;h<a.length;h++)l=d[a[h]],l.lookupType===n&&r.push(l);if(r.length===0&&s){l={lookupType:n,lookupFlag:0,subtables:[],markFilteringSet:void 0};const h=d.length;return d.push(l),a.push(h),[l]}}return r},getGlyphClass:function(i,e){switch(i.format){case 1:return i.startGlyph<=e&&e<i.startGlyph+i.classes.length?i.classes[e-i.startGlyph]:0;case 2:const t=Ia(i.ranges,e);return t?t.classId:0}},getCoverageIndex:function(i,e){switch(i.format){case 1:const t=va(i.glyphs,e);return t>=0?t:-1;case 2:const n=Ia(i.ranges,e);return n?n.index+e-n.start:-1}},expandCoverage:function(i){if(i.format===1)return i.glyphs;{const e=[],t=i.ranges;for(let n=0;n<t.length;n++){const s=t[n],o=s.start,r=s.end;for(let l=o;l<=r;l++)e.push(l)}return e}}};function di(i){ci.call(this,i,"gpos")}di.prototype=ci.prototype,di.prototype.init=function(){const i=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(i)},di.prototype.getKerningValue=function(i,e,t){for(let n=0;n<i.length;n++){const s=i[n].subtables;for(let o=0;o<s.length;o++){const r=s[o],l=this.getCoverageIndex(r.coverage,e);if(!(l<0))switch(r.posFormat){case 1:let a=r.pairSets[l];for(let f=0;f<a.length;f++){let u=a[f];if(u.secondGlyph===t)return u.value1&&u.value1.xAdvance||0}break;case 2:const d=this.getGlyphClass(r.classDef1,e),h=this.getGlyphClass(r.classDef2,t),p=r.classRecords[d][h];return p.value1&&p.value1.xAdvance||0}}}return 0},di.prototype.getKerningTables=function(i,e){if(this.font.tables.gpos)return this.getLookupTables(i,e,"kern",2)};function Qe(i){ci.call(this,i,"gsub")}function zg(i,e){const t=i.length;if(t!==e.length)return!1;for(let n=0;n<t;n++)if(i[n]!==e[n])return!1;return!0}function Ba(i,e,t){const n=i.subtables;for(let s=0;s<n.length;s++){const o=n[s];if(o.substFormat===e)return o}if(t)return n.push(t),t}Qe.prototype=ci.prototype,Qe.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Qe.prototype.getSingle=function(i,e,t){const n=[],s=this.getLookupTables(e,t,i,1);for(let o=0;o<s.length;o++){const r=s[o].subtables;for(let l=0;l<r.length;l++){const a=r[l],d=this.expandCoverage(a.coverage);let h;if(a.substFormat===1){const p=a.deltaGlyphId;for(h=0;h<d.length;h++){const f=d[h];n.push({sub:f,by:f+p})}}else{const p=a.substitute;for(h=0;h<d.length;h++)n.push({sub:d[h],by:p[h]})}}}return n},Qe.prototype.getAlternates=function(i,e,t){const n=[],s=this.getLookupTables(e,t,i,3);for(let o=0;o<s.length;o++){const r=s[o].subtables;for(let l=0;l<r.length;l++){const a=r[l],d=this.expandCoverage(a.coverage),h=a.alternateSets;for(let p=0;p<d.length;p++)n.push({sub:d[p],by:h[p]})}}return n},Qe.prototype.getLigatures=function(i,e,t){const n=[],s=this.getLookupTables(e,t,i,4);for(let o=0;o<s.length;o++){const r=s[o].subtables;for(let l=0;l<r.length;l++){const a=r[l],d=this.expandCoverage(a.coverage),h=a.ligatureSets;for(let p=0;p<d.length;p++){const f=d[p],u=h[p];for(let m=0;m<u.length;m++){const E=u[m];n.push({sub:[f].concat(E.components),by:E.ligGlyph})}}}}return n},Qe.prototype.addSingle=function(i,e,t,n){const s=this.getLookupTables(t,n,i,1,!0)[0],o=Ba(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});te.assert(o.coverage.format===1,"Ligature: unable to modify coverage table format "+o.coverage.format);const r=e.sub;let l=this.binSearch(o.coverage.glyphs,r);l<0&&(l=-1-l,o.coverage.glyphs.splice(l,0,r),o.substitute.splice(l,0,0)),o.substitute[l]=e.by},Qe.prototype.addAlternate=function(i,e,t,n){const s=this.getLookupTables(t,n,i,3,!0)[0],o=Ba(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});te.assert(o.coverage.format===1,"Ligature: unable to modify coverage table format "+o.coverage.format);const r=e.sub;let l=this.binSearch(o.coverage.glyphs,r);l<0&&(l=-1-l,o.coverage.glyphs.splice(l,0,r),o.alternateSets.splice(l,0,0)),o.alternateSets[l]=e.by},Qe.prototype.addLigature=function(i,e,t,n){const s=this.getLookupTables(t,n,i,4,!0)[0];let o=s.subtables[0];o||(o={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=o),te.assert(o.coverage.format===1,"Ligature: unable to modify coverage table format "+o.coverage.format);const r=e.sub[0],l=e.sub.slice(1),a={ligGlyph:e.by,components:l};let d=this.binSearch(o.coverage.glyphs,r);if(d>=0){const h=o.ligatureSets[d];for(let p=0;p<h.length;p++)if(zg(h[p].components,l))return;h.push(a)}else d=-1-d,o.coverage.glyphs.splice(d,0,r),o.ligatureSets.splice(d,0,[a])},Qe.prototype.getFeature=function(i,e,t){if(/ss\d\d/.test(i))return this.getSingle(i,e,t);switch(i){case"aalt":case"salt":return this.getSingle(i,e,t).concat(this.getAlternates(i,e,t));case"dlig":case"liga":case"rlig":return this.getLigatures(i,e,t)}},Qe.prototype.add=function(i,e,t,n){if(/ss\d\d/.test(i))return this.addSingle(i,e,t,n);switch(i){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(i,e,t,n):this.addAlternate(i,e,t,n);case"dlig":case"liga":case"rlig":return this.addLigature(i,e,t,n)}};function Wg(){return typeof window<"u"}function jg(i){const e=new ArrayBuffer(i.length),t=new Uint8Array(e);for(let n=0;n<i.length;++n)t[n]=i[n];return e}function Kg(i){const e=new Buffer(i.byteLength),t=new Uint8Array(i);for(let n=0;n<e.length;++n)e[n]=t[n];return e}function zt(i,e){if(!i)throw e}function xa(i,e,t,n,s){let o;return(e&n)>0?(o=i.parseByte(),(e&s)===0&&(o=-o),o=t+o):(e&s)>0?o=t:o=t+i.parseShort(),o}function $g(i,e,t){const n=new $.Parser(e,t);i.numberOfContours=n.parseShort(),i._xMin=n.parseShort(),i._yMin=n.parseShort(),i._xMax=n.parseShort(),i._yMax=n.parseShort();let s,o;if(i.numberOfContours>0){const r=i.endPointIndices=[];for(let a=0;a<i.numberOfContours;a+=1)r.push(n.parseUShort());i.instructionLength=n.parseUShort(),i.instructions=[];for(let a=0;a<i.instructionLength;a+=1)i.instructions.push(n.parseByte());const l=r[r.length-1]+1;s=[];for(let a=0;a<l;a+=1)if(o=n.parseByte(),s.push(o),(o&8)>0){const d=n.parseByte();for(let h=0;h<d;h+=1)s.push(o),a+=1}if(te.argument(s.length===l,"Bad flags."),r.length>0){const a=[];let d;if(l>0){for(let f=0;f<l;f+=1)o=s[f],d={},d.onCurve=!!(o&1),d.lastPointOfContour=r.indexOf(f)>=0,a.push(d);let h=0;for(let f=0;f<l;f+=1)o=s[f],d=a[f],d.x=xa(n,o,h,2,16),h=d.x;let p=0;for(let f=0;f<l;f+=1)o=s[f],d=a[f],d.y=xa(n,o,p,4,32),p=d.y}i.points=a}else i.points=[]}else if(i.numberOfContours===0)i.points=[];else{i.isComposite=!0,i.points=[],i.components=[];let r=!0;for(;r;){s=n.parseUShort();const l={glyphIndex:n.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(l.dx=n.parseShort(),l.dy=n.parseShort()):l.matchedPoints=[n.parseUShort(),n.parseUShort()]:(s&2)>0?(l.dx=n.parseChar(),l.dy=n.parseChar()):l.matchedPoints=[n.parseByte(),n.parseByte()],(s&8)>0?l.xScale=l.yScale=n.parseF2Dot14():(s&64)>0?(l.xScale=n.parseF2Dot14(),l.yScale=n.parseF2Dot14()):(s&128)>0&&(l.xScale=n.parseF2Dot14(),l.scale01=n.parseF2Dot14(),l.scale10=n.parseF2Dot14(),l.yScale=n.parseF2Dot14()),i.components.push(l),r=!!(s&32)}if(s&256){i.instructionLength=n.parseUShort(),i.instructions=[];for(let l=0;l<i.instructionLength;l+=1)i.instructions.push(n.parseByte())}}}function ys(i,e){const t=[];for(let n=0;n<i.length;n+=1){const s=i[n],o={x:e.xScale*s.x+e.scale01*s.y+e.dx,y:e.scale10*s.x+e.yScale*s.y+e.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};t.push(o)}return t}function Xg(i){const e=[];let t=[];for(let n=0;n<i.length;n+=1){const s=i[n];t.push(s),s.lastPointOfContour&&(e.push(t),t=[])}return te.argument(t.length===0,"There are still points left in the current contour."),e}function Sa(i){const e=new be;if(!i)return e;const t=Xg(i);for(let n=0;n<t.length;++n){const s=t[n];let o=null,r=s[s.length-1],l=s[0];if(r.onCurve)e.moveTo(r.x,r.y);else if(l.onCurve)e.moveTo(l.x,l.y);else{const a={x:(r.x+l.x)*.5,y:(r.y+l.y)*.5};e.moveTo(a.x,a.y)}for(let a=0;a<s.length;++a)if(o=r,r=l,l=s[(a+1)%s.length],r.onCurve)e.lineTo(r.x,r.y);else{let d=l;o.onCurve||((r.x+o.x)*.5,(r.y+o.y)*.5),l.onCurve||(d={x:(r.x+l.x)*.5,y:(r.y+l.y)*.5}),e.quadraticCurveTo(r.x,r.y,d.x,d.y)}e.closePath()}return e}function qg(i,e){if(e.isComposite)for(let t=0;t<e.components.length;t+=1){const n=e.components[t],s=i.get(n.glyphIndex);if(s.getPath(),s.points){let o;if(n.matchedPoints===void 0)o=ys(s.points,n);else{if(n.matchedPoints[0]>e.points.length-1||n.matchedPoints[1]>s.points.length-1)throw Error("Matched points out of range in "+e.name);const r=e.points[n.matchedPoints[0]];let l=s.points[n.matchedPoints[1]];const a={xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:0,dy:0};l=ys([l],a)[0],a.dx=r.x-l.x,a.dy=r.y-l.y,o=ys(s.points,a)}e.points=e.points.concat(o)}}return Sa(e.points)}function Jg(i,e,t,n){const s=new Yt.GlyphSet(n);for(let o=0;o<t.length-1;o+=1){const r=t[o],l=t[o+1];r!==l?s.push(o,Yt.ttfGlyphLoader(n,o,$g,i,e+r,qg)):s.push(o,Yt.glyphLoader(n,o))}return s}const Ta={getPath:Sa,parse:Jg};let Ma,vt,Da,Cs;function ka(i){this.font=i,this.getCommands=function(e){return Ta.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Zg(i){return i}function Pa(i){return Math.sign(i)*Math.round(Math.abs(i))}function em(i){return Math.sign(i)*Math.round(Math.abs(i*2))/2}function tm(i){return Math.sign(i)*(Math.round(Math.abs(i)+.5)-.5)}function im(i){return Math.sign(i)*Math.ceil(Math.abs(i))}function nm(i){return Math.sign(i)*Math.floor(Math.abs(i))}const Fa=function(i){const e=this.srPeriod;let t=this.srPhase;const n=this.srThreshold;let s=1;return i<0&&(i=-i,s=-1),i+=n-t,i=Math.trunc(i/e)*e,i+=t,i<0?t*s:i*s},$e={x:1,y:0,axis:"x",distance:function(i,e,t,n){return(t?i.xo:i.x)-(n?e.xo:e.x)},interpolate:function(i,e,t,n){let s,o,r,l,a,d,h;if(!n||n===this){if(s=i.xo-e.xo,o=i.xo-t.xo,a=e.x-e.xo,d=t.x-t.xo,r=Math.abs(s),l=Math.abs(o),h=r+l,h===0){i.x=i.xo+(a+d)/2;return}i.x=i.xo+(a*l+d*r)/h;return}if(s=n.distance(i,e,!0,!0),o=n.distance(i,t,!0,!0),a=n.distance(e,e,!1,!0),d=n.distance(t,t,!1,!0),r=Math.abs(s),l=Math.abs(o),h=r+l,h===0){$e.setRelative(i,i,(a+d)/2,n,!0);return}$e.setRelative(i,i,(a*l+d*r)/h,n,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(i,e,t,n,s){if(!n||n===this){i.x=(s?e.xo:e.x)+t;return}const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*n.x,a=r+t*n.y;i.x=l+(i.y-a)/n.normalSlope},slope:0,touch:function(i){i.xTouched=!0},touched:function(i){return i.xTouched},untouch:function(i){i.xTouched=!1}},Je={x:0,y:1,axis:"y",distance:function(i,e,t,n){return(t?i.yo:i.y)-(n?e.yo:e.y)},interpolate:function(i,e,t,n){let s,o,r,l,a,d,h;if(!n||n===this){if(s=i.yo-e.yo,o=i.yo-t.yo,a=e.y-e.yo,d=t.y-t.yo,r=Math.abs(s),l=Math.abs(o),h=r+l,h===0){i.y=i.yo+(a+d)/2;return}i.y=i.yo+(a*l+d*r)/h;return}if(s=n.distance(i,e,!0,!0),o=n.distance(i,t,!0,!0),a=n.distance(e,e,!1,!0),d=n.distance(t,t,!1,!0),r=Math.abs(s),l=Math.abs(o),h=r+l,h===0){Je.setRelative(i,i,(a+d)/2,n,!0);return}Je.setRelative(i,i,(a*l+d*r)/h,n,!0)},normalSlope:0,setRelative:function(i,e,t,n,s){if(!n||n===this){i.y=(s?e.yo:e.y)+t;return}const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*n.x,a=r+t*n.y;i.y=a+n.normalSlope*(i.x-l)},slope:Number.POSITIVE_INFINITY,touch:function(i){i.yTouched=!0},touched:function(i){return i.yTouched},untouch:function(i){i.yTouched=!1}};Object.freeze($e),Object.freeze(Je);function hi(i,e){this.x=i,this.y=e,this.axis=void 0,this.slope=e/i,this.normalSlope=-i/e,Object.freeze(this)}hi.prototype.distance=function(i,e,t,n){return this.x*$e.distance(i,e,t,n)+this.y*Je.distance(i,e,t,n)},hi.prototype.interpolate=function(i,e,t,n){let s,o,r,l,a,d,h;if(r=n.distance(i,e,!0,!0),l=n.distance(i,t,!0,!0),s=n.distance(e,e,!1,!0),o=n.distance(t,t,!1,!0),a=Math.abs(r),d=Math.abs(l),h=a+d,h===0){this.setRelative(i,i,(s+o)/2,n,!0);return}this.setRelative(i,i,(s*d+o*a)/h,n,!0)},hi.prototype.setRelative=function(i,e,t,n,s){n=n||this;const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*n.x,a=r+t*n.y,d=n.normalSlope,h=this.slope,p=i.x,f=i.y;i.x=(h*p-d*l+a-f)/(h-d),i.y=h*(i.x-p)+f},hi.prototype.touch=function(i){i.xTouched=!0,i.yTouched=!0};function ui(i,e){const t=Math.sqrt(i*i+e*e);return i/=t,e/=t,i===1&&e===0?$e:i===0&&e===1?Je:new hi(i,e)}function Ze(i,e,t,n){this.x=this.xo=Math.round(i*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=n,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Ze.prototype.nextTouched=function(i){let e=this.nextPointOnContour;for(;!i.touched(e)&&e!==this;)e=e.nextPointOnContour;return e},Ze.prototype.prevTouched=function(i){let e=this.prevPointOnContour;for(;!i.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};const fi=Object.freeze(new Ze(0,0)),sm={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function dt(i,e){switch(this.env=i,this.stack=[],this.prog=e,i){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=$e,this.round=Pa}}ka.prototype.exec=function(i,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let n=this._prepState;if(!n||n.ppem!==e){let s=this._fpgmState;if(!s){dt.prototype=sm,s=this._fpgmState=new dt("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,L.DEBUG&&(console.log("---EXEC FPGM---"),s.step=-1);try{vt(s)}catch(r){console.log("Hinting error in FPGM:"+r),this._errorState=3;return}}dt.prototype=s,n=this._prepState=new dt("prep",t.tables.prep),n.ppem=e;const o=t.tables.cvt;if(o){const r=n.cvt=new Array(o.length),l=e/t.unitsPerEm;for(let a=0;a<o.length;a++)r[a]=o[a]*l}else n.cvt=[];L.DEBUG&&(console.log("---EXEC PREP---"),n.step=-1);try{vt(n)}catch(r){this._errorState<2&&console.log("Hinting error in PREP:"+r),this._errorState=2}}if(!(this._errorState>1))try{return Da(i,n)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},Da=function(i,e){const t=e.ppem/e.font.unitsPerEm,n=t;let s=i.components,o,r,l;if(dt.prototype=e,!s)l=new dt("glyf",i.instructions),L.DEBUG&&(console.log("---EXEC GLYPH---"),l.step=-1),Cs(i,l,t,n),r=l.gZone;else{const a=e.font;r=[],o=[];for(let d=0;d<s.length;d++){const h=s[d],p=a.glyphs.get(h.glyphIndex);l=new dt("glyf",p.instructions),L.DEBUG&&(console.log("---EXEC COMP "+d+"---"),l.step=-1),Cs(p,l,t,n);const f=Math.round(h.dx*t),u=Math.round(h.dy*n),m=l.gZone,E=l.contours;for(let y=0;y<m.length;y++){const v=m[y];v.xTouched=v.yTouched=!1,v.xo=v.x=v.x+f,v.yo=v.y=v.y+u}const A=r.length;r.push.apply(r,m);for(let y=0;y<E.length;y++)o.push(E[y]+A)}i.instructions&&!l.inhibitGridFit&&(l=new dt("glyf",i.instructions),l.gZone=l.z0=l.z1=l.z2=r,l.contours=o,r.push(new Ze(0,0),new Ze(Math.round(i.advanceWidth*t),0)),L.DEBUG&&(console.log("---EXEC COMPOSITE---"),l.step=-1),vt(l),r.length-=2)}return r},Cs=function(i,e,t,n){const s=i.points||[],o=s.length,r=e.gZone=e.z0=e.z1=e.z2=[],l=e.contours=[];let a;for(let p=0;p<o;p++)a=s[p],r[p]=new Ze(a.x*t,a.y*n,a.lastPointOfContour,a.onCurve);let d,h;for(let p=0;p<o;p++)a=r[p],d||(d=a,l.push(p)),a.lastPointOfContour?(a.nextPointOnContour=d,d.prevPointOnContour=a,d=void 0):(h=r[p+1],a.nextPointOnContour=h,h.prevPointOnContour=a);if(!e.inhibitGridFit){if(L.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(let p=0;p<o;p++)console.log(p,r[p].x,r[p].y)}if(r.push(new Ze(0,0),new Ze(Math.round(i.advanceWidth*t),0)),vt(e),r.length-=2,L.DEBUG){console.log("FINISHED GLYPH",e.stack);for(let p=0;p<o;p++)console.log(p,r[p].x,r[p].y)}}},vt=function(i){let e=i.prog;if(!e)return;const t=e.length;let n;for(i.ip=0;i.ip<t;i.ip++){if(L.DEBUG&&i.step++,n=Ma[e[i.ip]],!n)throw new Error("unknown instruction: 0x"+Number(e[i.ip]).toString(16));n(i)}};function tn(i){const e=i.tZone=new Array(i.gZone.length);for(let t=0;t<e.length;t++)e[t]=new Ze(0,0)}function Ra(i,e){const t=i.prog;let n=i.ip,s=1,o;do if(o=t[++n],o===88)s++;else if(o===89)s--;else if(o===64)n+=t[n+1]+1;else if(o===65)n+=2*t[n+1]+1;else if(o>=176&&o<=183)n+=o-176+1;else if(o>=184&&o<=191)n+=(o-184+1)*2;else if(e&&s===1&&o===27)break;while(s>0);i.ip=n}function Oa(i,e){L.DEBUG&&console.log(e.step,"SVTCA["+i.axis+"]"),e.fv=e.pv=e.dpv=i}function La(i,e){L.DEBUG&&console.log(e.step,"SPVTCA["+i.axis+"]"),e.pv=e.dpv=i}function Na(i,e){L.DEBUG&&console.log(e.step,"SFVTCA["+i.axis+"]"),e.fv=i}function Ua(i,e){const t=e.stack,n=t.pop(),s=t.pop(),o=e.z2[n],r=e.z1[s];L.DEBUG&&console.log("SPVTL["+i+"]",n,s);let l,a;i?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.pv=e.dpv=ui(l,a)}function _a(i,e){const t=e.stack,n=t.pop(),s=t.pop(),o=e.z2[n],r=e.z1[s];L.DEBUG&&console.log("SFVTL["+i+"]",n,s);let l,a;i?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.fv=ui(l,a)}function om(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"SPVFS[]",t,n),i.pv=i.dpv=ui(n,t)}function rm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"SPVFS[]",t,n),i.fv=ui(n,t)}function am(i){const e=i.stack,t=i.pv;L.DEBUG&&console.log(i.step,"GPV[]"),e.push(t.x*16384),e.push(t.y*16384)}function lm(i){const e=i.stack,t=i.fv;L.DEBUG&&console.log(i.step,"GFV[]"),e.push(t.x*16384),e.push(t.y*16384)}function cm(i){i.fv=i.pv,L.DEBUG&&console.log(i.step,"SFVTPV[]")}function dm(i){const e=i.stack,t=e.pop(),n=e.pop(),s=e.pop(),o=e.pop(),r=e.pop(),l=i.z0,a=i.z1,d=l[t],h=l[n],p=a[s],f=a[o],u=i.z2[r];L.DEBUG&&console.log("ISECT[], ",t,n,s,o,r);const m=d.x,E=d.y,A=h.x,y=h.y,v=p.x,S=p.y,M=f.x,O=f.y,I=(m-A)*(S-O)-(E-y)*(v-M),B=m*y-E*A,g=v*O-S*M;u.x=(B*(v-M)-g*(m-A))/I,u.y=(B*(S-O)-g*(E-y))/I}function hm(i){i.rp0=i.stack.pop(),L.DEBUG&&console.log(i.step,"SRP0[]",i.rp0)}function um(i){i.rp1=i.stack.pop(),L.DEBUG&&console.log(i.step,"SRP1[]",i.rp1)}function fm(i){i.rp2=i.stack.pop(),L.DEBUG&&console.log(i.step,"SRP2[]",i.rp2)}function pm(i){const e=i.stack.pop();switch(L.DEBUG&&console.log(i.step,"SZP0[]",e),i.zp0=e,e){case 0:i.tZone||tn(i),i.z0=i.tZone;break;case 1:i.z0=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function gm(i){const e=i.stack.pop();switch(L.DEBUG&&console.log(i.step,"SZP1[]",e),i.zp1=e,e){case 0:i.tZone||tn(i),i.z1=i.tZone;break;case 1:i.z1=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function mm(i){const e=i.stack.pop();switch(L.DEBUG&&console.log(i.step,"SZP2[]",e),i.zp2=e,e){case 0:i.tZone||tn(i),i.z2=i.tZone;break;case 1:i.z2=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function Am(i){const e=i.stack.pop();switch(L.DEBUG&&console.log(i.step,"SZPS[]",e),i.zp0=i.zp1=i.zp2=e,e){case 0:i.tZone||tn(i),i.z0=i.z1=i.z2=i.tZone;break;case 1:i.z0=i.z1=i.z2=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function ym(i){i.loop=i.stack.pop(),L.DEBUG&&console.log(i.step,"SLOOP[]",i.loop)}function Cm(i){L.DEBUG&&console.log(i.step,"RTG[]"),i.round=Pa}function Em(i){L.DEBUG&&console.log(i.step,"RTHG[]"),i.round=tm}function wm(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"SMD[]",e),i.minDis=e/64}function bm(i){L.DEBUG&&console.log(i.step,"ELSE[]"),Ra(i,!1)}function vm(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"JMPR[]",e),i.ip+=e-1}function Im(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"SCVTCI[]",e),i.cvCutIn=e/64}function Bm(i){const e=i.stack;L.DEBUG&&console.log(i.step,"DUP[]"),e.push(e[e.length-1])}function Es(i){L.DEBUG&&console.log(i.step,"POP[]"),i.stack.pop()}function xm(i){L.DEBUG&&console.log(i.step,"CLEAR[]"),i.stack.length=0}function Sm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"SWAP[]"),e.push(t),e.push(n)}function Tm(i){const e=i.stack;L.DEBUG&&console.log(i.step,"DEPTH[]"),e.push(e.length)}function Mm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"LOOPCALL[]",t,n);const s=i.ip,o=i.prog;i.prog=i.funcs[t];for(let r=0;r<n;r++)vt(i),L.DEBUG&&console.log(++i.step,r+1<n?"next loopcall":"done loopcall",r);i.ip=s,i.prog=o}function Dm(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"CALL[]",e);const t=i.ip,n=i.prog;i.prog=i.funcs[e],vt(i),i.ip=t,i.prog=n,L.DEBUG&&console.log(++i.step,"returning from",e)}function km(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"CINDEX[]",t),e.push(e[e.length-t])}function Pm(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"MINDEX[]",t),e.push(e.splice(e.length-t,1)[0])}function Fm(i){if(i.env!=="fpgm")throw new Error("FDEF not allowed here");const e=i.stack,t=i.prog;let n=i.ip;const s=e.pop(),o=n;for(L.DEBUG&&console.log(i.step,"FDEF[]",s);t[++n]!==45;);i.ip=n,i.funcs[s]=t.slice(o+1,n)}function Qa(i,e){const t=e.stack.pop(),n=e.z0[t],s=e.fv,o=e.pv;L.DEBUG&&console.log(e.step,"MDAP["+i+"]",t);let r=o.distance(n,fi);i&&(r=e.round(r)),s.setRelative(n,fi,r,o),s.touch(n),e.rp0=e.rp1=t}function Ga(i,e){const t=e.z2,n=t.length-2;let s,o,r;L.DEBUG&&console.log(e.step,"IUP["+i.axis+"]");for(let l=0;l<n;l++)s=t[l],!i.touched(s)&&(o=s.prevTouched(i),o!==s&&(r=s.nextTouched(i),o===r&&i.setRelative(s,s,i.distance(o,o,!1,!0),i,!0),i.interpolate(s,o,r,i)))}function Ha(i,e){const t=e.stack,n=i?e.rp1:e.rp2,s=(i?e.z0:e.z1)[n],o=e.fv,r=e.pv;let l=e.loop;const a=e.z2;for(;l--;){const d=t.pop(),h=a[d],p=r.distance(s,s,!1,!0);o.setRelative(h,h,p,r),o.touch(h),L.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-l)+": ":"")+"SHP["+(i?"rp1":"rp2")+"]",d)}e.loop=1}function Ya(i,e){const t=e.stack,n=i?e.rp1:e.rp2,s=(i?e.z0:e.z1)[n],o=e.fv,r=e.pv,l=t.pop(),a=e.z2[e.contours[l]];let d=a;L.DEBUG&&console.log(e.step,"SHC["+i+"]",l);const h=r.distance(s,s,!1,!0);do d!==s&&o.setRelative(d,d,h,r),d=d.nextPointOnContour;while(d!==a)}function Va(i,e){const t=e.stack,n=i?e.rp1:e.rp2,s=(i?e.z0:e.z1)[n],o=e.fv,r=e.pv,l=t.pop();L.DEBUG&&console.log(e.step,"SHZ["+i+"]",l);let a;switch(l){case 0:a=e.tZone;break;case 1:a=e.gZone;break;default:throw new Error("Invalid zone")}let d;const h=r.distance(s,s,!1,!0),p=a.length-2;for(let f=0;f<p;f++)d=a[f],o.setRelative(d,d,h,r)}function Rm(i){const e=i.stack;let t=i.loop;const n=i.fv,s=e.pop()/64,o=i.z2;for(;t--;){const r=e.pop(),l=o[r];L.DEBUG&&console.log(i.step,(i.loop>1?"loop "+(i.loop-t)+": ":"")+"SHPIX[]",r,s),n.setRelative(l,l,s),n.touch(l)}i.loop=1}function Om(i){const e=i.stack,t=i.rp1,n=i.rp2;let s=i.loop;const o=i.z0[t],r=i.z1[n],l=i.fv,a=i.dpv,d=i.z2;for(;s--;){const h=e.pop(),p=d[h];L.DEBUG&&console.log(i.step,(i.loop>1?"loop "+(i.loop-s)+": ":"")+"IP[]",h,t,"<->",n),l.interpolate(p,o,r,a),l.touch(p)}i.loop=1}function za(i,e){const t=e.stack,n=t.pop()/64,s=t.pop(),o=e.z1[s],r=e.z0[e.rp0],l=e.fv,a=e.pv;l.setRelative(o,r,n,a),l.touch(o),L.DEBUG&&console.log(e.step,"MSIRP["+i+"]",n,s),e.rp1=e.rp0,e.rp2=s,i&&(e.rp0=s)}function Lm(i){const e=i.stack,t=i.rp0,n=i.z0[t];let s=i.loop;const o=i.fv,r=i.pv,l=i.z1;for(;s--;){const a=e.pop(),d=l[a];L.DEBUG&&console.log(i.step,(i.loop>1?"loop "+(i.loop-s)+": ":"")+"ALIGNRP[]",a),o.setRelative(d,n,0,r),o.touch(d)}i.loop=1}function Nm(i){L.DEBUG&&console.log(i.step,"RTDG[]"),i.round=em}function Wa(i,e){const t=e.stack,n=t.pop(),s=t.pop(),o=e.z0[s],r=e.fv,l=e.pv;let a=e.cvt[n];L.DEBUG&&console.log(e.step,"MIAP["+i+"]",n,"(",a,")",s);let d=l.distance(o,fi);i&&(Math.abs(d-a)<e.cvCutIn&&(d=a),d=e.round(d)),r.setRelative(o,fi,d,l),e.zp0===0&&(o.xo=o.x,o.yo=o.y),r.touch(o),e.rp0=e.rp1=s}function Um(i){const e=i.prog;let t=i.ip;const n=i.stack,s=e[++t];L.DEBUG&&console.log(i.step,"NPUSHB[]",s);for(let o=0;o<s;o++)n.push(e[++t]);i.ip=t}function _m(i){let e=i.ip;const t=i.prog,n=i.stack,s=t[++e];L.DEBUG&&console.log(i.step,"NPUSHW[]",s);for(let o=0;o<s;o++){let r=t[++e]<<8|t[++e];r&32768&&(r=-((r^65535)+1)),n.push(r)}i.ip=e}function Qm(i){const e=i.stack;let t=i.store;t||(t=i.store=[]);const n=e.pop(),s=e.pop();L.DEBUG&&console.log(i.step,"WS",n,s),t[s]=n}function Gm(i){const e=i.stack,t=i.store,n=e.pop();L.DEBUG&&console.log(i.step,"RS",n);const s=t&&t[n]||0;e.push(s)}function Hm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"WCVTP",t,n),i.cvt[n]=t/64}function Ym(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"RCVT",t),e.push(i.cvt[t]*64)}function ja(i,e){const t=e.stack,n=t.pop(),s=e.z2[n];L.DEBUG&&console.log(e.step,"GC["+i+"]",n),t.push(e.dpv.distance(s,fi,i,!1)*64)}function Ka(i,e){const t=e.stack,n=t.pop(),s=t.pop(),o=e.z1[n],r=e.z0[s],l=e.dpv.distance(r,o,i,i);L.DEBUG&&console.log(e.step,"MD["+i+"]",n,s,"->",l),e.stack.push(Math.round(l*64))}function Vm(i){L.DEBUG&&console.log(i.step,"MPPEM[]"),i.stack.push(i.ppem)}function zm(i){L.DEBUG&&console.log(i.step,"FLIPON[]"),i.autoFlip=!0}function Wm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"LT[]",t,n),e.push(n<t?1:0)}function jm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"LTEQ[]",t,n),e.push(n<=t?1:0)}function Km(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"GT[]",t,n),e.push(n>t?1:0)}function $m(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"GTEQ[]",t,n),e.push(n>=t?1:0)}function Xm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"EQ[]",t,n),e.push(t===n?1:0)}function qm(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"NEQ[]",t,n),e.push(t!==n?1:0)}function Jm(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"ODD[]",t),e.push(Math.trunc(t)%2?1:0)}function Zm(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"EVEN[]",t),e.push(Math.trunc(t)%2?0:1)}function eA(i){let e=i.stack.pop();L.DEBUG&&console.log(i.step,"IF[]",e),e||(Ra(i,!0),L.DEBUG&&console.log(i.step,"EIF[]"))}function tA(i){L.DEBUG&&console.log(i.step,"EIF[]")}function iA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"AND[]",t,n),e.push(t&&n?1:0)}function nA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"OR[]",t,n),e.push(t||n?1:0)}function sA(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"NOT[]",t),e.push(t?0:1)}function ws(i,e){const t=e.stack,n=t.pop(),s=e.fv,o=e.pv,r=e.ppem,l=e.deltaBase+(i-1)*16,a=e.deltaShift,d=e.z0;L.DEBUG&&console.log(e.step,"DELTAP["+i+"]",n,t);for(let h=0;h<n;h++){const p=t.pop(),f=t.pop();if(l+((f&240)>>4)!==r)continue;let m=(f&15)-8;m>=0&&m++,L.DEBUG&&console.log(e.step,"DELTAPFIX",p,"by",m*a);const E=d[p];s.setRelative(E,E,m*a,o)}}function oA(i){const t=i.stack.pop();L.DEBUG&&console.log(i.step,"SDB[]",t),i.deltaBase=t}function rA(i){const t=i.stack.pop();L.DEBUG&&console.log(i.step,"SDS[]",t),i.deltaShift=Math.pow(.5,t)}function aA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"ADD[]",t,n),e.push(n+t)}function lA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"SUB[]",t,n),e.push(n-t)}function cA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"DIV[]",t,n),e.push(n*64/t)}function dA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"MUL[]",t,n),e.push(n*t/64)}function hA(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"ABS[]",t),e.push(Math.abs(t))}function uA(i){const e=i.stack;let t=e.pop();L.DEBUG&&console.log(i.step,"NEG[]",t),e.push(-t)}function fA(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"FLOOR[]",t),e.push(Math.floor(t/64)*64)}function pA(i){const e=i.stack,t=e.pop();L.DEBUG&&console.log(i.step,"CEILING[]",t),e.push(Math.ceil(t/64)*64)}function nn(i,e){const t=e.stack,n=t.pop();L.DEBUG&&console.log(e.step,"ROUND[]"),t.push(e.round(n/64)*64)}function gA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"WCVTF[]",t,n),i.cvt[n]=t*i.ppem/i.font.unitsPerEm}function bs(i,e){const t=e.stack,n=t.pop(),s=e.ppem,o=e.deltaBase+(i-1)*16,r=e.deltaShift;L.DEBUG&&console.log(e.step,"DELTAC["+i+"]",n,t);for(let l=0;l<n;l++){const a=t.pop(),d=t.pop();if(o+((d&240)>>4)!==s)continue;let p=(d&15)-8;p>=0&&p++;const f=p*r;L.DEBUG&&console.log(e.step,"DELTACFIX",a,"by",f),e.cvt[a]+=f}}function mA(i){let e=i.stack.pop();L.DEBUG&&console.log(i.step,"SROUND[]",e),i.round=Fa;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(i.srPeriod=t,e&48){case 0:i.srPhase=0;break;case 16:i.srPhase=.25*t;break;case 32:i.srPhase=.5*t;break;case 48:i.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?i.srThreshold=0:i.srThreshold=(e/8-.5)*t}function AA(i){let e=i.stack.pop();L.DEBUG&&console.log(i.step,"S45ROUND[]",e),i.round=Fa;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(i.srPeriod=t,e&48){case 0:i.srPhase=0;break;case 16:i.srPhase=.25*t;break;case 32:i.srPhase=.5*t;break;case 48:i.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?i.srThreshold=0:i.srThreshold=(e/8-.5)*t}function yA(i){L.DEBUG&&console.log(i.step,"ROFF[]"),i.round=Zg}function CA(i){L.DEBUG&&console.log(i.step,"RUTG[]"),i.round=im}function EA(i){L.DEBUG&&console.log(i.step,"RDTG[]"),i.round=nm}function wA(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"SCANCTRL[]",e)}function $a(i,e){const t=e.stack,n=t.pop(),s=t.pop(),o=e.z2[n],r=e.z1[s];L.DEBUG&&console.log(e.step,"SDPVTL["+i+"]",n,s);let l,a;i?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.dpv=ui(l,a)}function bA(i){const e=i.stack,t=e.pop();let n=0;L.DEBUG&&console.log(i.step,"GETINFO[]",t),t&1&&(n=35),t&32&&(n|=4096),e.push(n)}function vA(i){const e=i.stack,t=e.pop(),n=e.pop(),s=e.pop();L.DEBUG&&console.log(i.step,"ROLL[]"),e.push(n),e.push(t),e.push(s)}function IA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"MAX[]",t,n),e.push(Math.max(n,t))}function BA(i){const e=i.stack,t=e.pop(),n=e.pop();L.DEBUG&&console.log(i.step,"MIN[]",t,n),e.push(Math.min(n,t))}function xA(i){const e=i.stack.pop();L.DEBUG&&console.log(i.step,"SCANTYPE[]",e)}function SA(i){const e=i.stack.pop();let t=i.stack.pop();switch(L.DEBUG&&console.log(i.step,"INSTCTRL[]",e,t),e){case 1:i.inhibitGridFit=!!t;return;case 2:i.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function ht(i,e){const t=e.stack,n=e.prog;let s=e.ip;L.DEBUG&&console.log(e.step,"PUSHB["+i+"]");for(let o=0;o<i;o++)t.push(n[++s]);e.ip=s}function ut(i,e){let t=e.ip;const n=e.prog,s=e.stack;L.DEBUG&&console.log(e.ip,"PUSHW["+i+"]");for(let o=0;o<i;o++){let r=n[++t]<<8|n[++t];r&32768&&(r=-((r^65535)+1)),s.push(r)}e.ip=t}function K(i,e,t,n,s,o){const r=o.stack,l=i&&r.pop(),a=r.pop(),d=o.rp0,h=o.z0[d],p=o.z1[a],f=o.minDis,u=o.fv,m=o.dpv;let E,A,y,v;A=E=m.distance(p,h,!0,!0),y=A>=0?1:-1,A=Math.abs(A),i&&(v=o.cvt[l],n&&Math.abs(A-v)<o.cvCutIn&&(A=v)),t&&A<f&&(A=f),n&&(A=o.round(A)),u.setRelative(p,h,y*A,m),u.touch(p),L.DEBUG&&console.log(o.step,(i?"MIRP[":"MDRP[")+(e?"M":"m")+(t?">":"_")+(n?"R":"_")+(s===0?"Gr":s===1?"Bl":s===2?"Wh":"")+"]",i?l+"("+o.cvt[l]+","+v+")":"",a,"(d =",E,"->",y*A,")"),o.rp1=o.rp0,o.rp2=a,e&&(o.rp0=a)}Ma=[Oa.bind(void 0,Je),Oa.bind(void 0,$e),La.bind(void 0,Je),La.bind(void 0,$e),Na.bind(void 0,Je),Na.bind(void 0,$e),Ua.bind(void 0,0),Ua.bind(void 0,1),_a.bind(void 0,0),_a.bind(void 0,1),om,rm,am,lm,cm,dm,hm,um,fm,pm,gm,mm,Am,ym,Cm,Em,wm,bm,vm,Im,void 0,void 0,Bm,Es,xm,Sm,Tm,km,Pm,void 0,void 0,void 0,Mm,Dm,Fm,void 0,Qa.bind(void 0,0),Qa.bind(void 0,1),Ga.bind(void 0,Je),Ga.bind(void 0,$e),Ha.bind(void 0,0),Ha.bind(void 0,1),Ya.bind(void 0,0),Ya.bind(void 0,1),Va.bind(void 0,0),Va.bind(void 0,1),Rm,Om,za.bind(void 0,0),za.bind(void 0,1),Lm,Nm,Wa.bind(void 0,0),Wa.bind(void 0,1),Um,_m,Qm,Gm,Hm,Ym,ja.bind(void 0,0),ja.bind(void 0,1),void 0,Ka.bind(void 0,0),Ka.bind(void 0,1),Vm,void 0,zm,void 0,void 0,Wm,jm,Km,$m,Xm,qm,Jm,Zm,eA,tA,iA,nA,sA,ws.bind(void 0,1),oA,rA,aA,lA,cA,dA,hA,uA,fA,pA,nn.bind(void 0,0),nn.bind(void 0,1),nn.bind(void 0,2),nn.bind(void 0,3),void 0,void 0,void 0,void 0,gA,ws.bind(void 0,2),ws.bind(void 0,3),bs.bind(void 0,1),bs.bind(void 0,2),bs.bind(void 0,3),mA,AA,void 0,void 0,yA,void 0,CA,EA,Es,Es,void 0,void 0,void 0,void 0,void 0,wA,$a.bind(void 0,0),$a.bind(void 0,1),bA,void 0,vA,IA,BA,xA,SA,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ht.bind(void 0,1),ht.bind(void 0,2),ht.bind(void 0,3),ht.bind(void 0,4),ht.bind(void 0,5),ht.bind(void 0,6),ht.bind(void 0,7),ht.bind(void 0,8),ut.bind(void 0,1),ut.bind(void 0,2),ut.bind(void 0,3),ut.bind(void 0,4),ut.bind(void 0,5),ut.bind(void 0,6),ut.bind(void 0,7),ut.bind(void 0,8),K.bind(void 0,0,0,0,0,0),K.bind(void 0,0,0,0,0,1),K.bind(void 0,0,0,0,0,2),K.bind(void 0,0,0,0,0,3),K.bind(void 0,0,0,0,1,0),K.bind(void 0,0,0,0,1,1),K.bind(void 0,0,0,0,1,2),K.bind(void 0,0,0,0,1,3),K.bind(void 0,0,0,1,0,0),K.bind(void 0,0,0,1,0,1),K.bind(void 0,0,0,1,0,2),K.bind(void 0,0,0,1,0,3),K.bind(void 0,0,0,1,1,0),K.bind(void 0,0,0,1,1,1),K.bind(void 0,0,0,1,1,2),K.bind(void 0,0,0,1,1,3),K.bind(void 0,0,1,0,0,0),K.bind(void 0,0,1,0,0,1),K.bind(void 0,0,1,0,0,2),K.bind(void 0,0,1,0,0,3),K.bind(void 0,0,1,0,1,0),K.bind(void 0,0,1,0,1,1),K.bind(void 0,0,1,0,1,2),K.bind(void 0,0,1,0,1,3),K.bind(void 0,0,1,1,0,0),K.bind(void 0,0,1,1,0,1),K.bind(void 0,0,1,1,0,2),K.bind(void 0,0,1,1,0,3),K.bind(void 0,0,1,1,1,0),K.bind(void 0,0,1,1,1,1),K.bind(void 0,0,1,1,1,2),K.bind(void 0,0,1,1,1,3),K.bind(void 0,1,0,0,0,0),K.bind(void 0,1,0,0,0,1),K.bind(void 0,1,0,0,0,2),K.bind(void 0,1,0,0,0,3),K.bind(void 0,1,0,0,1,0),K.bind(void 0,1,0,0,1,1),K.bind(void 0,1,0,0,1,2),K.bind(void 0,1,0,0,1,3),K.bind(void 0,1,0,1,0,0),K.bind(void 0,1,0,1,0,1),K.bind(void 0,1,0,1,0,2),K.bind(void 0,1,0,1,0,3),K.bind(void 0,1,0,1,1,0),K.bind(void 0,1,0,1,1,1),K.bind(void 0,1,0,1,1,2),K.bind(void 0,1,0,1,1,3),K.bind(void 0,1,1,0,0,0),K.bind(void 0,1,1,0,0,1),K.bind(void 0,1,1,0,0,2),K.bind(void 0,1,1,0,0,3),K.bind(void 0,1,1,0,1,0),K.bind(void 0,1,1,0,1,1),K.bind(void 0,1,1,0,1,2),K.bind(void 0,1,1,0,1,3),K.bind(void 0,1,1,1,0,0),K.bind(void 0,1,1,1,0,1),K.bind(void 0,1,1,1,0,2),K.bind(void 0,1,1,1,0,3),K.bind(void 0,1,1,1,1,0),K.bind(void 0,1,1,1,1,1),K.bind(void 0,1,1,1,1,2),K.bind(void 0,1,1,1,1,3)];const TA=Array.from||(i=>i.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g)||[]);function re(i){i=i||{},i.empty||(zt(i.familyName,"When creating a new Font object, familyName is required."),zt(i.styleName,"When creating a new Font object, styleName is required."),zt(i.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),zt(i.ascender,"When creating a new Font object, ascender is required."),zt(i.descender,"When creating a new Font object, descender is required."),zt(i.descender<0,"Descender should be negative (e.g. -512)."),this.names={fontFamily:{en:i.familyName||" "},fontSubfamily:{en:i.styleName||" "},fullName:{en:i.fullName||i.familyName+" "+i.styleName},postScriptName:{en:i.postScriptName||(i.familyName+i.styleName).replace(/\s/g,"")},designer:{en:i.designer||" "},designerURL:{en:i.designerURL||" "},manufacturer:{en:i.manufacturer||" "},manufacturerURL:{en:i.manufacturerURL||" "},license:{en:i.license||" "},licenseURL:{en:i.licenseURL||" "},version:{en:i.version||"Version 0.1"},description:{en:i.description||" "},copyright:{en:i.copyright||" "},trademark:{en:i.trademark||" "}},this.unitsPerEm=i.unitsPerEm||1e3,this.ascender=i.ascender,this.descender=i.descender,this.createdTimestamp=i.createdTimestamp,this.tables={os2:{usWeightClass:i.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:i.widthClass||this.usWidthClasses.MEDIUM,fsSelection:i.fsSelection||this.fsSelectionValues.REGULAR}}),this.supported=!0,this.glyphs=new Yt.GlyphSet(this,i.glyphs||[]),this.encoding=new Vr(this),this.position=new di(this),this.substitution=new Qe(this),this.tables=this.tables||{},Object.defineProperty(this,"hinting",{get:function(){if(this._hinting)return this._hinting;if(this.outlinesFormat==="truetype")return this._hinting=new ka(this)}})}re.prototype.hasChar=function(i){return this.encoding.charToGlyphIndex(i)!==null},re.prototype.charToGlyphIndex=function(i){return this.encoding.charToGlyphIndex(i)},re.prototype.charToGlyph=function(i){const e=this.charToGlyphIndex(i);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},re.prototype.stringToGlyphs=function(i,e){e=e||this.defaultRenderOptions;const t=TA(i),n=[];for(let l=0;l<t.length;l+=1){const a=t[l];n.push(this.charToGlyphIndex(a))}let s=n.length;if(e.features){const l=e.script||this.substitution.getDefaultScriptName();let a=[];e.features.liga&&(a=a.concat(this.substitution.getFeature("liga",l,e.language))),e.features.rlig&&(a=a.concat(this.substitution.getFeature("rlig",l,e.language)));for(let d=0;d<s;d+=1)for(let h=0;h<a.length;h++){const p=a[h],f=p.sub,u=f.length;let m=0;for(;m<u&&f[m]===n[d+m];)m++;m===u&&(n.splice(d,u,p.by),s=s-u+1)}}const o=new Array(s),r=this.glyphs.get(0);for(let l=0;l<s;l+=1)o[l]=this.glyphs.get(n[l])||r;return o},re.prototype.nameToGlyphIndex=function(i){return this.glyphNames.nameToGlyphIndex(i)},re.prototype.nameToGlyph=function(i){const e=this.nameToGlyphIndex(i);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},re.prototype.glyphIndexToName=function(i){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(i):""},re.prototype.getKerningValue=function(i,e){i=i.index||i,e=e.index||e;const t=this.position.defaultKerningTables;return t?this.position.getKerningValue(t,i,e):this.kerningPairs[i+","+e]||0},re.prototype.defaultRenderOptions={kerning:!0,features:{liga:!0,rlig:!0}},re.prototype.forEachGlyph=function(i,e,t,n,s,o){e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:72,s=s||this.defaultRenderOptions;const r=1/this.unitsPerEm*n,l=this.stringToGlyphs(i,s);let a;if(s.kerning){const d=s.script||this.position.getDefaultScriptName();a=this.position.getKerningTables(d,s.language)}for(let d=0;d<l.length;d+=1){const h=l[d];if(o.call(this,h,e,t,n,s),h.advanceWidth&&(e+=h.advanceWidth*r),s.kerning&&d<l.length-1){const p=a?this.position.getKerningValue(a,h.index,l[d+1].index):this.getKerningValue(h,l[d+1]);e+=p*r}s.letterSpacing?e+=s.letterSpacing*n:s.tracking&&(e+=s.tracking/1e3*n)}return e},re.prototype.getPath=function(i,e,t,n,s){const o=new be;return this.forEachGlyph(i,e,t,n,s,function(r,l,a,d){const h=r.getPath(l,a,d,s,this);o.extend(h)}),o},re.prototype.getPaths=function(i,e,t,n,s){const o=[];return this.forEachGlyph(i,e,t,n,s,function(r,l,a,d){const h=r.getPath(l,a,d,s,this);o.push(h)}),o},re.prototype.getAdvanceWidth=function(i,e,t){return this.forEachGlyph(i,0,0,e,t,function(){})},re.prototype.draw=function(i,e,t,n,s,o){this.getPath(e,t,n,s,o).draw(i)},re.prototype.drawPoints=function(i,e,t,n,s,o){this.forEachGlyph(e,t,n,s,o,function(r,l,a,d){r.drawPoints(i,l,a,d)})},re.prototype.drawMetrics=function(i,e,t,n,s,o){this.forEachGlyph(e,t,n,s,o,function(r,l,a,d){r.drawMetrics(i,l,a,d)})},re.prototype.getEnglishName=function(i){const e=this.names[i];if(e)return e.en},re.prototype.validate=function(){const i=this;function e(n,s){}function t(n){const s=i.getEnglishName(n);s&&s.trim().length>0}t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),this.unitsPerEm>0},re.prototype.toTables=function(){return Vg.fontToTable(this)},re.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},re.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let s=0;s<e.length;s++)n[s]=e[s];return t},re.prototype.download=function(i){const e=this.getEnglishName("fontFamily"),t=this.getEnglishName("fontSubfamily");i=i||e.replace(/\s/g,"")+"-"+t+".otf";const n=this.toArrayBuffer();if(Wg())if(window.URL=window.URL||window.webkitURL,window.URL){const s=new DataView(n),o=new Blob([s],{type:"font/opentype"});let r=document.createElement("a");r.href=window.URL.createObjectURL(o),r.download=i;let l=document.createEvent("MouseEvents");l.initEvent("click",!0,!1),r.dispatchEvent(l)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{const s=require("fs"),o=Kg(n);s.writeFileSync(i,o)}},re.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},re.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},re.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function Xa(i,e){const t=JSON.stringify(i);let n=256;for(let s in e){let o=parseInt(s);if(!(!o||o<256)){if(JSON.stringify(e[s])===t)return o;n<=o&&(n=o+1)}}return e[n]=i,n}function MA(i,e,t){const n=Xa(e.name,t);return[{name:"tag_"+i,type:"TAG",value:e.tag},{name:"minValue_"+i,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+i,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+i,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+i,type:"USHORT",value:0},{name:"nameID_"+i,type:"USHORT",value:n}]}function DA(i,e,t){const n={},s=new $.Parser(i,e);return n.tag=s.parseTag(),n.minValue=s.parseFixed(),n.defaultValue=s.parseFixed(),n.maxValue=s.parseFixed(),s.skip("uShort",1),n.name=t[s.parseUShort()]||{},n}function kA(i,e,t,n){const s=Xa(e.name,n),o=[{name:"nameID_"+i,type:"USHORT",value:s},{name:"flags_"+i,type:"USHORT",value:0}];for(let r=0;r<t.length;++r){const l=t[r].tag;o.push({name:"axis_"+i+" "+l,type:"FIXED",value:e.coordinates[l]<<16})}return o}function PA(i,e,t,n){const s={},o=new $.Parser(i,e);s.name=n[o.parseUShort()]||{},o.skip("uShort",1),s.coordinates={};for(let r=0;r<t.length;++r)s.coordinates[t[r].tag]=o.parseFixed();return s}function FA(i,e){const t=new J.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:i.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:i.instances.length},{name:"instanceSize",type:"USHORT",value:4+i.axes.length*4}]);t.offsetToData=t.sizeOf();for(let n=0;n<i.axes.length;n++)t.fields=t.fields.concat(MA(n,i.axes[n],e));for(let n=0;n<i.instances.length;n++)t.fields=t.fields.concat(kA(n,i.instances[n],i.axes,e));return t}function RA(i,e,t){const n=new $.Parser(i,e),s=n.parseULong();te.argument(s===65536,"Unsupported fvar table version.");const o=n.parseOffset16();n.skip("uShort",1);const r=n.parseUShort(),l=n.parseUShort(),a=n.parseUShort(),d=n.parseUShort(),h=[];for(let u=0;u<r;u++)h.push(DA(i,e+o+u*l,t));const p=[],f=e+o+r*l;for(let u=0;u<a;u++)p.push(PA(i,f+u*d,h,t));return{axes:h,instances:p}}const OA={make:FA,parse:RA},Ge=new Array(10);Ge[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(G.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(G.coverage),values:this.parseValueRecordList()};te.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},Ge[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();te.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const n=this.parsePointer(G.coverage),s=this.parseUShort(),o=this.parseUShort();if(t===1)return{posFormat:t,coverage:n,valueFormat1:s,valueFormat2:o,pairSets:this.parseList(G.pointer(G.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(o)}})))};if(t===2){const r=this.parsePointer(G.classDef),l=this.parsePointer(G.classDef),a=this.parseUShort(),d=this.parseUShort();return{posFormat:t,coverage:n,valueFormat1:s,valueFormat2:o,classDef1:r,classDef2:l,class1Count:a,class2Count:d,classRecords:this.parseList(a,G.list(d,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(o)}}))}}},Ge[3]=function(){return{error:"GPOS Lookup 3 not supported"}},Ge[4]=function(){return{error:"GPOS Lookup 4 not supported"}},Ge[5]=function(){return{error:"GPOS Lookup 5 not supported"}},Ge[6]=function(){return{error:"GPOS Lookup 6 not supported"}},Ge[7]=function(){return{error:"GPOS Lookup 7 not supported"}},Ge[8]=function(){return{error:"GPOS Lookup 8 not supported"}},Ge[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function LA(i,e){e=e||0;const t=new G(i,e),n=t.parseVersion(1);return te.argument(n===1||n===1.1,"Unsupported GPOS table version "+n),n===1?{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Ge)}:{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Ge),variations:t.parseFeatureVariationsList()}}const NA=new Array(10);function UA(i){return new J.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new J.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new J.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new J.LookupList(i.lookups,NA)}])}const _A={parse:LA,make:UA};function QA(i){const e={};i.skip("uShort");const t=i.parseUShort();te.argument(t===0,"Unsupported kern sub-table version."),i.skip("uShort",2);const n=i.parseUShort();i.skip("uShort",3);for(let s=0;s<n;s+=1){const o=i.parseUShort(),r=i.parseUShort(),l=i.parseShort();e[o+","+r]=l}return e}function GA(i){const e={};i.skip("uShort"),i.parseULong()>1&&console.warn("Only the first kern subtable is supported."),i.skip("uLong");const s=i.parseUShort()&255;if(i.skip("uShort"),s===0){const o=i.parseUShort();i.skip("uShort",3);for(let r=0;r<o;r+=1){const l=i.parseUShort(),a=i.parseUShort(),d=i.parseShort();e[l+","+a]=d}}return e}function HA(i,e){const t=new $.Parser(i,e),n=t.parseUShort();if(n===0)return QA(t);if(n===1)return GA(t);throw new Error("Unsupported kern table version ("+n+").")}const YA={parse:HA};function VA(i,e,t,n){const s=new $.Parser(i,e),o=n?s.parseUShort:s.parseULong,r=[];for(let l=0;l<t+1;l+=1){let a=o.call(s);n&&(a*=2),r.push(a)}return r}const zA={parse:VA};function WA(i,e){require("fs").readFile(i,function(n,s){if(n)return e(n.message);e(null,jg(s))})}function jA(i,e){const t=new XMLHttpRequest;t.open("get",i,!0),t.responseType="arraybuffer",t.onload=function(){return t.response?e(null,t.response):e("Font could not be loaded: "+t.statusText)},t.onerror=function(){e("Font could not be loaded")},t.send()}function qa(i,e){const t=[];let n=12;for(let s=0;s<e;s+=1){const o=$.getTag(i,n),r=$.getULong(i,n+4),l=$.getULong(i,n+8),a=$.getULong(i,n+12);t.push({tag:o,checksum:r,offset:l,length:a,compression:!1}),n+=16}return t}function KA(i,e){const t=[];let n=44;for(let s=0;s<e;s+=1){const o=$.getTag(i,n),r=$.getULong(i,n+4),l=$.getULong(i,n+8),a=$.getULong(i,n+12);let d;l<a?d="WOFF":d=!1,t.push({tag:o,offset:r,compression:d,compressedLength:l,length:a}),n+=20}return t}function Ee(i,e){if(e.compression==="WOFF"){const t=new Uint8Array(i.buffer,e.offset+2,e.compressedLength-2),n=new Uint8Array(e.length);if(xp(t,n),n.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");return{data:new DataView(n.buffer,0),offset:0}}else return{data:i,offset:e.offset}}function $A(i){let e,t;const n=new re({empty:!0}),s=new DataView(i,0);let o,r=[];const l=$.getTag(s,0);if(l==="\0\0\0"||l==="true"||l==="typ1")n.outlinesFormat="truetype",o=$.getUShort(s,4),r=qa(s,o);else if(l==="OTTO")n.outlinesFormat="cff",o=$.getUShort(s,4),r=qa(s,o);else if(l==="wOFF"){const O=$.getTag(s,4);if(O==="\0\0\0")n.outlinesFormat="truetype";else if(O==="OTTO")n.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+l);o=$.getUShort(s,12),r=KA(s,o)}else throw new Error("Unsupported OpenType signature "+l);let a,d,h,p,f,u,m,E,A,y,v;for(let O=0;O<o;O+=1){const I=r[O];let B;switch(I.tag){case"cmap":B=Ee(s,I),n.tables.cmap=Yr.parse(B.data,B.offset),n.encoding=new zr(n.tables.cmap);break;case"cvt ":B=Ee(s,I),v=new $.Parser(B.data,B.offset),n.tables.cvt=v.parseShortList(I.length/2);break;case"fvar":d=I;break;case"fpgm":B=Ee(s,I),v=new $.Parser(B.data,B.offset),n.tables.fpgm=v.parseByteList(I.length);break;case"head":B=Ee(s,I),n.tables.head=sa.parse(B.data,B.offset),n.unitsPerEm=n.tables.head.unitsPerEm,e=n.tables.head.indexToLocFormat;break;case"hhea":B=Ee(s,I),n.tables.hhea=oa.parse(B.data,B.offset),n.ascender=n.tables.hhea.ascender,n.descender=n.tables.hhea.descender,n.numberOfHMetrics=n.tables.hhea.numberOfHMetrics;break;case"hmtx":u=I;break;case"ltag":B=Ee(s,I),t=aa.parse(B.data,B.offset);break;case"maxp":B=Ee(s,I),n.tables.maxp=la.parse(B.data,B.offset),n.numGlyphs=n.tables.maxp.numGlyphs;break;case"name":A=I;break;case"OS/2":B=Ee(s,I),n.tables.os2=gs.parse(B.data,B.offset);break;case"post":B=Ee(s,I),n.tables.post=ma.parse(B.data,B.offset),n.glyphNames=new cs(n.tables.post);break;case"prep":B=Ee(s,I),v=new $.Parser(B.data,B.offset),n.tables.prep=v.parseByteList(I.length);break;case"glyf":h=I;break;case"loca":E=I;break;case"CFF ":a=I;break;case"kern":m=I;break;case"GPOS":p=I;break;case"GSUB":f=I;break;case"meta":y=I;break}}const S=Ee(s,A);if(n.tables.name=ga.parse(S.data,S.offset,t),n.names=n.tables.name,h&&E){const O=e===0,I=Ee(s,E),B=zA.parse(I.data,I.offset,n.numGlyphs,O),g=Ee(s,h);n.glyphs=Ta.parse(g.data,g.offset,B,n)}else if(a){const O=Ee(s,a);na.parse(O.data,O.offset,n)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");const M=Ee(s,u);if(ra.parse(M.data,M.offset,n.numberOfHMetrics,n.numGlyphs,n.glyphs),zp(n),m){const O=Ee(s,m);n.kerningPairs=YA.parse(O.data,O.offset)}else n.kerningPairs={};if(p){const O=Ee(s,p);n.tables.gpos=_A.parse(O.data,O.offset),n.position.init()}if(f){const O=Ee(s,f);n.tables.gsub=Aa.parse(O.data,O.offset)}if(d){const O=Ee(s,d);n.tables.fvar=OA.parse(O.data,O.offset,n.names)}if(y){const O=Ee(s,y);n.tables.meta=ya.parse(O.data,O.offset),n.metas=n.tables.meta}return n}function XA(i,e){(typeof window>"u"?WA:jA)(i,function(s,o){if(s)return e(s);let r;try{r=$A(o)}catch(l){return e(l,null)}return e(null,r)})}const vs=1e-12;function pi(i){if(!Array.isArray(i)||i.length===0)return i||[];const e=i[0],t=i[i.length-1];if(!e||!t||e.length<2||t.length<2)return i;const n=e[0]??0,s=e[1]??0,o=t[0]??0,r=t[1]??0;return(Math.abs(n-o)>vs||Math.abs(s-r)>vs)&&i.push([n,s]),i}function It(i){let e=0;if(!i)return 0;for(let t=0;t<i.length-1;t++){const n=i[t],s=i[t+1];if(!n||!s)continue;const o=n[0]??0,r=n[1]??0,l=s[0]??0,a=s[1]??0;e+=o*a-l*r}return e/2}function sn(i,e=vs){const t=[];if(!i)return t;for(const n of i){if(!n||n.length<2)continue;const s=t[t.length-1],o=n[0]??0,r=n[1]??0;if(!s){t.push([o,r]);continue}const l=s[0]??0,a=s[1]??0;(Math.abs(o-l)>e||Math.abs(r-a)>e)&&t.push([o,r])}return t}function qA(i,e,t,n,s=16){const o=[],r=i?.[0]??0,l=i?.[1]??0,a=t?.[0]??0,d=t?.[1]??0,h=n?.[0]??0,p=n?.[1]??0,f=e?.[0]??0,u=e?.[1]??0;for(let m=0;m<=s;m++){const E=m/s,A=1-E,y=A*A*A*r+3*A*A*E*a+3*A*E*E*h+E*E*E*f,v=A*A*A*l+3*A*A*E*d+3*A*E*E*p+E*E*E*u;o.push([y,v])}return o}function Ja(i,e){if(!i||!e)return!1;const t=i[0]??0,n=i[1]??0;let s=!1;for(let o=0,r=e.length-1;o<e.length;r=o++){const l=e[o],a=e[r];if(!l||!a)continue;const d=l[0]??0,h=l[1]??0,p=a[0]??0,f=a[1]??0;h>n!=f>n&&t<(p-d)*(n-h)/(f-h+0)+d&&(s=!s)}return s}function Is(i){return i?(It(i)<0&&i.reverse(),pi(i),i):[]}function JA(i){return i?(It(i)>0&&i.reverse(),pi(i),i):[]}function Za(i,e=16){if(!i||!Array.isArray(i.commands))return[];const t=[];let n=[];for(const s of i.commands){let o=function(l){const a=l.x!==void 0?l.x:0,d=l.y!==void 0?-l.y:0;return[a,d]};const r=s.type;if(r==="M")n.length&&t.push(sn(n)),n=[o(s)];else if(r==="L")n.push(o(s));else if(r==="Q"){const a=n[n.length-1]||o(s),d=[],h=s.x??0,p=s.y??0,f=s.x1??0,u=s.y1??0,m=a[0]??0,E=a[1]??0;for(let A=1;A<=e;A++){const y=A/e,v=1-y,S=v*v*m+2*v*y*f+y*y*h,M=v*v*E+2*v*y*u+y*y*-p;d.push([S,M])}d.length?n.push(...d):n.push(o(s))}else if(r==="C"){const a=n[n.length-1]||o(s),d=[s.x1||0,-(s.y1||0)],h=[s.x2||0,-(s.y2||0)],p=[s.x||0,-(s.y||0)],f=qA(a,p,d,h,e);f.length>1?n.push(...f.slice(1)):n.push(p)}else r==="Z"||r==="z"?(n.length&&t.push(sn(n)),n=[]):s.x!==void 0&&s.y!==void 0&&n.push(o(s))}return n.length&&t.push(sn(n)),t.map(s=>pi(s)).filter(s=>s&&s.length>=4)}function Bs(i,e){if(!i)return null;const t=i.map(n=>pi(n.slice()));return{type:"Feature",geometry:{type:"Polygon",coordinates:t},properties:{...e.properties||{},rings:t.length,polygons:1}}}function ZA(i,e,t={}){t=Object.assign({sampleSegments:16,simplifyTolerance:0,epsArea:1e-24,debug:!1,scale:1,widthScale:.6,fillWinding:"auto"},t||{scale:1});const n=!!t.debug;if(!i||!i.geometry||!Array.isArray(i.geometry.coordinates))return{type:"FeatureCollection",features:[]};const s=i.geometry.coordinates,o=i.properties||{},r=o.text||o.label||"",l=o.rotation??0,a=t.sampleSegments||16,d=t.epsArea||1e-24,p=o.height/.9||1,f=(t.scale||1)*p,u=-l*Math.PI/180,m=Math.cos(u),E=Math.sin(u),A=o.attachmentPoint||"bottom-left",y=[];if(!e||typeof e.getPaths!="function")return{type:"FeatureCollection",features:y};const v=e.getPaths(r,0,0,t.fontSize||1)||[];let S=[];for(const _ of v){const H=Za(_,a);for(const N of H)if(N)for(const w of N)w&&S.push(w)}let M=1/0,O=1/0,I=-1/0,B=-1/0;for(const _ of S){if(!_)continue;const H=_[0]??0,N=_[1]??0;M=Math.min(M,H),O=Math.min(O,N),I=Math.max(I,H),B=Math.max(B,N)}const g=I-M,P=B-O;let x=0,F=0;switch(A){case"top-left":x=0,F=-P;break;case"top-center":x=-g/2,F=P;break;case"top-right":x=-g,F=P;break;case"center-left":x=0,F=P/2;break;case"center":x=-g/2,F=P/2;break;case"center-right":x=-g,F=P/2;break;case"bottom-left":x=0,F=0;break;case"bottom-center":x=-g/2,F=0;break;case"bottom-right":x=-g,F=0;break;default:x=0,F=0}for(const _ of v){const H=Za(_,a);if(!H||H.length===0)continue;const N=H.map(k=>{if(!k)return[];const Q=k.map(R=>{if(!R)return[0,0];let T=(R[0]??0)+x,U=(R[1]??0)+F;T=T*(t.widthScale||.6);const V=T*m-U*E,W=T*E+U*m;return[s[0]+V*f,s[1]+W*f]});return pi(sn(Q))}).filter(k=>k&&k.length>=4&&Math.abs(It(k))>d);if(N.length===0)continue;let w=1;if(t.fillWinding==="positive")w=1;else if(t.fillWinding==="negative")w=-1;else{let k=0,Q=-1;for(let U=0;U<N.length;U++){const V=N[U];if(!V)continue;const W=It(V);Math.abs(W)>Q&&(Q=Math.abs(W),k=U)}const R=N[k],T=R?It(R):0;w=T>=0?1:-1,n&&console.log("[simple] auto fillSign=",w,"largest signed area=",T)}const C=N.map((k,Q)=>({idx:Q,ring:k,signedArea:It(k),absArea:Math.abs(It(k))}));for(const k of C)k.isFilled=k.signedArea*w>0,n&&console.log("[simple] ring",k.idx,"signedArea=",k.signedArea.toExponential(),"isFilled=",k.isFilled);const b=C.filter(k=>k.isFilled).sort((k,Q)=>k.absArea-Q.absArea),D=C.filter(k=>!k.isFilled).sort((k,Q)=>Q.absArea-k.absArea);for(const k of b)k.holes=[];for(const k of D){const Q=(function(T){let U=0,V=0;if(!T||T.length===0)return[0,0];for(const W of T)W&&(U+=W[0]??0,V+=W[1]??0);return[U/T.length,V/T.length]})(k.ring);let R=null;for(const T of b)Ja(Q,T.ring)&&(R===null||T.absArea<R.absArea&&T.idx<k.idx||T.absArea>R.absArea&&T.idx<k.idx&&D.length==1)&&(R=T);if(R){if(R.absArea<k.absArea&&D.length>1)for(const T of b)Ja(Q,T.ring)&&T.absArea>k.absArea&&T.holes.push(k.ring);else R.holes.push(k.ring);k.assigned=!0}else k.assigned=!1,n&&console.log("[simple] hole not assigned idx=",k.idx)}for(const k of b){const Q=Is(k.ring.slice()),R=(k.holes||[]).map(T=>JA(T.slice()));y.push(Bs([Q,...R],i))}for(const k of D)k.assigned||y.push(Bs([Is(k.ring.slice())],i));if(b.length===0)for(const k of C)y.push(Bs([Is(k.ring.slice())],i))}return{type:"FeatureCollection",features:y}}class ey extends Ke{constructor(e,t){super(e,t),this.type="label",this._centerCoord=null,this._plotInstance=this,this.fontUrl="https://leiting.chenxisoft.com/resource/font/HanaMinA.ttf",this.labelText="点击编辑文本",this.fontSize=10,this.color="#ff0000",this.polygonEntities=[],t&&(this.fontSize=t.fontSize||this.fontSize,this.color=t.color||this.color,this.labelText=t.text||this.labelText)}start(e){this.startCreate(e)}startCreate(e){try{this.state="creating",this.forbidDrawWorld(!0);const t=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium,n=this;if(!t){console.error("无法获取Cesium对象");return}this.handler&&this.handler.destroy(),this.handler=new t.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.handler.setInputAction(function(s){if(!s||!s.position)return;let o=n.getCatesian3FromPX(s.position);o&&(n.positions=[o],n._centerCoord=o,n.createLabel(o,function(){n.endCreate(e)}))},t.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(s){if(!s||!s.position)return;n.getCatesian3FromPX(s.position)&&n.state},t.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(s){!s||!s.position||n.endCreate()},t.ScreenSpaceEventType.RIGHT_CLICK)}catch(t){console.error("启动创建标签功能时出错:",t),e&&e(null)}}createLabel(e,t){const n=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium,s=this;if(!e){console.error("创建标签时位置参数无效"),t&&t();return}if(!n){console.error("创建标签时无法获取Cesium对象"),t&&t();return}this.clearPolygonEntities(),XA(this.fontUrl,(o,r)=>{try{if(o){console.error("加载字体失败:",o),t&&t();return}const l=n.Cartographic.fromCartesian(e),a=n.Math.toDegrees(l.longitude),d=n.Math.toDegrees(l.latitude),h={type:"Feature",geometry:{type:"Point",coordinates:[a,d]},properties:{text:s.labelText||"",rotation:0}},p={sampleSegments:16,fontSize:s.fontSize,scale:10},f=ZA(h,r,p);if(!f||!f.features||!Array.isArray(f.features)){console.error("文本转换为多边形失败"),t&&t();return}s.drawGeoJsonLocal(f,[a,d],1,r),s.entity={_centerCoord:s._centerCoord,_plotInstance:s._plotInstance,position:e,label:{text:s.labelText},updatePosition:function(u){s.updatePositions([u])},getPosition:function(){return s._centerCoord},type:s.type,objId:s.objId,isDraggable:!0,setPosition:function(u){s._centerCoord=u,s.positions[0]=u,s.createLabel(u)}},s.addClickEditHandler(),t&&t()}catch(l){console.error("创建文本标签时发生错误:",l);try{s.clearPolygonEntities()}catch(a){console.error("清理标签多边形实体时出错:",a)}t&&t()}})}drawGeoJsonLocal(e,t,n=1,s){try{const o=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium;if(!e||!t||!Array.isArray(t)||t.length!==2){console.error("drawGeoJsonLocal: 参数无效");return}const r=t[0],l=t[1],a=o.Cartesian3.fromDegrees(r,l,0),d=o.Transforms.eastNorthUpToFixedFrame(a),h=n*1;this.clearPolygonEntities();let p=[];for(const S of e.features||[]){if(!S||!S.geometry||S.geometry.type!=="Polygon")continue;const M=S.geometry.coordinates||[];for(const O of M)O&&Array.isArray(O)&&(p=p.concat(O))}let f=1/0,u=1/0,m=-1/0,E=-1/0;for(const S of p)Array.isArray(S)&&S.length>=2&&(f=Math.min(f,S[0]),u=Math.min(u,S[1]),m=Math.max(m,S[0]),E=Math.max(E,S[1]));const A=(f+m)/2,y=(u+E)/2,v=S=>{const M=(S[0]-A)*h,O=(S[1]-y)*h,I=new o.Cartesian3(M,O,0);return o.Matrix4.multiplyByPoint(d,I,new o.Cartesian3)};for(const S of e.features||[]){if(!S||!S.geometry||S.geometry.type!=="Polygon")continue;const M=S.geometry.coordinates||[];if(M.length>0)try{const O=M[0]||[];if(O.length===0)continue;const I=O.map(v);let B;if(M.length>1){const P=M.slice(1).map(x=>!x||!Array.isArray(x)||x.length===0?null:new o.PolygonHierarchy(x.map(v))).filter(Boolean);B=new o.PolygonHierarchy(I,P)}else B=new o.PolygonHierarchy(I);const g=this.viewer.entities.add({polygon:{hierarchy:B,material:o.Color.fromCssColorString(this.color||"#000000"),outline:!1},_labelOwner:this.objId});this.polygonEntities.push(g)}catch(O){console.warn("创建多边形实体时出错:",O);continue}}}catch(o){console.error("drawGeoJsonLocal: 发生错误:",o)}}clearPolygonEntities(){for(let e of this.polygonEntities)this.viewer.entities.remove(e);this.polygonEntities=[]}addClickEditHandler(){const e=this,t=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium;if(!t){console.error("添加点击编辑事件时无法获取Cesium对象");return}this.editHandler&&(this.editHandler.destroy(),this.editHandler=null),this.editHandler=new t.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.editHandler.setInputAction(function(n){if(!n||!n.position)return;const s=e.viewer.scene.pick(n.position);t.defined(s)&&s.id&&s.id._labelOwner===e.objId&&(n.preventDefault(),e.editText())},t.ScreenSpaceEventType.LEFT_CLICK),this.editHandler.setInputAction(function(n){if(!n||!n.position)return;const s=e.viewer.scene.pick(n.position);t.defined(s)&&s.id&&s.id._labelOwner===e.objId&&(n.preventDefault(),e.openStyleEditor())},t.ScreenSpaceEventType.RIGHT_CLICK)}editText(){const e=this;(function(n,s){const o=document.createElement("div");o.style.position="fixed",o.style.top="0",o.style.left="0",o.style.width="100%",o.style.height="100%",o.style.backgroundColor="rgba(0, 0, 0, 0.5)",o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.zIndex="10000";const r=document.createElement("div");r.style.backgroundColor="white",r.style.padding="20px",r.style.borderRadius="5px",r.style.width="500px",r.style.maxWidth="90vw",r.style.boxShadow="0 4px 8px rgba(0, 0, 0, 0.2)";const l=document.createElement("h3");l.textContent="编辑文本",l.style.marginTop="0";const a=document.createElement("textarea");a.value=n,a.style.width="100%",a.style.height="150px",a.style.marginBottom="10px",a.style.fontSize="14px",a.style.padding="8px",a.style.boxSizing="border-box";const d=document.createElement("div");d.style.display="flex",d.style.justifyContent="flex-end",d.style.gap="10px";const h=document.createElement("button");h.textContent="取消",h.addEventListener("click",function(){document.body.removeChild(o),s(null)});const p=document.createElement("button");p.textContent="确认",p.addEventListener("click",function(){document.body.removeChild(o),s(a.value)}),d.appendChild(h),d.appendChild(p),r.appendChild(l),r.appendChild(a),r.appendChild(d),o.appendChild(r),document.body.appendChild(o),a.focus();const f=function(u){u.key==="Escape"&&(document.body.removeChild(o),document.removeEventListener("keydown",f),s(null))};document.addEventListener("keydown",f)})(this.labelText,function(n){n!==null&&(e.labelText=n||"点击编辑文本",e._centerCoord&&e.createLabel(e._centerCoord))})}endCreate(e){try{this.state="endCreate",this.handler&&(this.handler.destroy(),this.handler=null),this.forbidDrawWorld(!1),this.entity&&!this.entity.objId&&(this.entity.objId=this.objId),e&&e(this.entity)}catch(t){console.error("结束创建标签时出错:",t),e&&e(null)}}updatePositions(e){try{if(!e||!e.length){console.warn("更新标签位置时参数无效");return}if(!(window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium)){console.error("更新标签位置时无法获取Cesium对象");return}this.positions=e,this._centerCoord=e[0],this.entity&&(this.entity.position=e[0]),this.createLabel(e[0])}catch(t){console.error("更新标签位置时出错:",t)}}moveEntity(e){try{const t=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium;if(!t){console.error("移动实体时无法获取Cesium对象");return}if(!e||!this._centerCoord)return;const n=t.Cartesian3.add(this._centerCoord,e,new t.Cartesian3);this.updatePositions([n])}catch(t){console.error("移动实体时出错:",t)}}setStyle(e){e&&(e.color&&(this.color=e.color),e.fontSize&&(this.fontSize=e.fontSize),e.text!==void 0&&(this.labelText=e.text),this._centerCoord&&this.createLabel(this._centerCoord))}openStyleEditor(){const e=this;(function(n,s){const o=document.createElement("div");o.style.position="fixed",o.style.top="0",o.style.left="0",o.style.width="100%",o.style.height="100%",o.style.backgroundColor="rgba(0, 0, 0, 0.5)",o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.zIndex="10000";const r=document.createElement("div");r.style.backgroundColor="white",r.style.padding="20px",r.style.borderRadius="5px",r.style.width="400px",r.style.maxWidth="90vw",r.style.boxShadow="0 4px 8px rgba(0, 0, 0, 0.2)";const l=document.createElement("h3");l.textContent="编辑样式",l.style.marginTop="0";const a=document.createElement("div");a.style.marginBottom="15px";const d=document.createElement("label");d.textContent="文本颜色: ",d.style.display="block",d.style.marginBottom="5px";const h=document.createElement("input");h.type="color",h.value=n.color,h.style.width="50px",a.appendChild(d),a.appendChild(h);const p=document.createElement("div");p.style.marginBottom="15px";const f=document.createElement("label");f.textContent="字体大小: ",f.style.display="block",f.style.marginBottom="5px";const u=document.createElement("input");u.type="number",u.value=n.fontSize,u.min="8",u.max="200",u.step="1",u.style.width="100%",u.style.padding="5px",u.style.boxSizing="border-box",p.appendChild(f),p.appendChild(u);const m=document.createElement("div");m.style.display="flex",m.style.justifyContent="flex-end",m.style.gap="10px",m.style.marginTop="20px";const E=document.createElement("button");E.textContent="取消",E.addEventListener("click",function(){document.body.removeChild(o),s(null)});const A=document.createElement("button");A.textContent="确认",A.addEventListener("click",function(){document.body.removeChild(o),s({color:h.value,fontSize:parseInt(u.value)})}),m.appendChild(E),m.appendChild(A),r.appendChild(l),r.appendChild(a),r.appendChild(p),r.appendChild(m),o.appendChild(r),document.body.appendChild(o);const y=function(v){v.key==="Escape"&&(document.body.removeChild(o),document.removeEventListener("keydown",y),s(null))};document.addEventListener("keydown",y)})(this.getStyle(),function(n){n&&e.setStyle(n)})}getStyle(){return{color:this.color,fontSize:this.fontSize,text:this.labelText}}destroy(){try{try{this.clearPolygonEntities()}catch(e){console.warn("清理标签多边形实体时出错:",e)}if(this.handler){try{this.handler.destroy()}catch(e){console.warn("销毁事件处理器时出错:",e)}this.handler=null}if(this.editHandler){try{this.editHandler.destroy()}catch(e){console.warn("销毁编辑事件处理器时出错:",e)}this.editHandler=null}this._centerCoord=null,this._plotInstance=null,this.entity=null,this.positions=null,this.objId=null;try{super.destroy()}catch(e){console.warn("调用父类destroy方法时出错:",e)}}catch(e){console.error("销毁CreateLabel对象时发生错误:",e)}}syncFromEntity(){this.entity&&this.entity.position&&(this._centerCoord=this.entity.position,this._plotInstance=this)}getEntityPositions(){return this.positions}calculateCenter(){return this._centerCoord}}class ty extends Ke{constructor(e,t){super(e,t),this.type="point",this.viewer=e;let n={color:Cesium.Color.AQUA,pixelSize:10,outlineWidth:1};this.style=Object.assign(n,t||{}),this.position=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate";let t=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(n){let s=t.getCatesian3FromPX(n.position,t.viewer);s&&(t.entity=t.createPoint(s),t.position=s,t.handler&&(t.handler.destroy(),t.handler=null),t.prompt&&(t.prompt.destroy(),t.prompt=null),t.state="endCreate",e&&e(t.entity))},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){t.prompt.update(n.endPosition,"单击新增"),t.state="creating"},Cesium.ScreenSpaceEventType.MOUSE_MOVE)}endCreate(){let e=this;e.handler&&(e.handler.destroy(),e.handler=null),e.prompt&&(e.prompt.destroy(),e.prompt=null),e.state="endCreate"}done(){this.state=="startCreate"?this.destroy():this.state=="creating"?this.destroy():(this.state=="startEdit"||this.state=="editing")&&this.endEdit()}createByPositions(e,t){if(!e)return;this.state="startCreate";let n=e instanceof Cesium.Cartesian3?e:Cesium.Cartesian3.fromDegrees(e[0],e[1],e[2]);this.position=n,n&&(this.entity=this.createPoint(n),t&&t(this.entity),this.state="endCreate")}setStyle(e){if(e){if(e.color){let t=Cesium.Color.fromCssColorString(e.color||"#ffff00");t=t.withAlpha(e.colorAlpha),this.entity.point.color=t}if(this.entity.point.outlineWidth=Number(e.outlineWidth),e.outlineColor){let t=Cesium.Color.fromCssColorString(e.outlineColor||"#000000");t=t.withAlpha(e.outlineColorAlpha),this.entity.point.outlineColor=t}this.entity.point.heightReference=Number(e.heightReference),this.entity.point.pixelSize=Number(e.pixelSize),this.style=Object.assign(this.style,e)}}getStyle(){let e={},t=this.entity.point,n=t.color.getValue();e.colorAlpha=n.alpha,e.color=new Cesium.Color(n.red,n.green,n.blue,1).toCssHexString(),e.outlineWidth=t.outlineWidth._value;let s=t.outlineColor.getValue();return e.outlineColorAlpha=s.alpha,e.outlineColor=new Cesium.Color(s.red,s.green,s.blue,1).toCssHexString(),t.heightReference!=null&&(e.heightReference=t.heightReference.getValue()),e.pixelSize=Number(t.pixelSize),e}getPositions(e){return e?se.cartesianToLnglat(this.position):this.position}getLnglats(){return this.getPositions(!0)}startEdit(e){if(this.state=="startEdit"||this.state=="editing"||!this.entity)return;this.state="startEdit",this.modifyHandler||(this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));let t=this,n;this.modifyHandler.setInputAction(function(s){let o=t.viewer.scene.pick(s.position);Cesium.defined(o)&&o.id&&(n=o.id,t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(s){if(!n)return;let o=t.getCatesian3FromPX(s.endPosition,t.viewer);o&&(t.entity&&(t.entity.position.setValue(o),t.position=o,t.state="editing"),e&&e())},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(s){n&&(t.forbidDrawWorld(!1),t.modifyHandler&&(t.modifyHandler.destroy(),t.modifyHandler=null,t.state="editing"))},Cesium.ScreenSpaceEventType.LEFT_UP)}endEdit(e){this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null,e&&e(this.entity)),this.forbidDrawWorld(!1),this.state="endEdit"}createPoint(e){if(!e)return;let t=this.viewer.entities.add({position:e,point:{color:this.style.color instanceof Cesium.Color?this.style.color:this.style.color?Cesium.Color.fromCssColorString(this.style.color).withAlpha(this.style.colorAlpha||1):Cesium.Color.WHITE,outlineColor:this.style.outlineColor instanceof Cesium.Color?this.style.outlineColor:this.style.outlineColor?Cesium.Color.fromCssColorString(this.style.outlineColor).withAlpha(this.style.outlineColorAlpha||1):Cesium.Color.BLACK,outlineWidth:this.style.outlineWidth||4,pixelSize:this.style.pixelSize||20,disableDepthTestDistance:Number.MAX_VALUE}});return t.objId=this.objId,t}}class iy extends Ke{constructor(e,t){super(e,t),this.type="polygon",this.viewer=e,this.entity=null,this.polyline=null;let n={outlineColor:"#000000",outlineWidth:2};this.style=Object.assign(n,t||{}),this.outline=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate";let t=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(n){let s=t.getCatesian3FromPX(n.position,t.viewer,[]);if(!s||(t.movePush&&(t.positions.pop(),t.movePush=!1),t.positions.some(l=>Math.abs(l.x-s.x)<1e-6&&Math.abs(l.y-s.y)<1e-6&&Math.abs(l.z-s.z)<1e-6)))return;t.positions.push(s);let r=t.createPoint(s);r.wz=t.positions.length-1,t.controlPoints.push(r)},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){if(t.positions.length<1){t.prompt.update(n.endPosition,"单击开始绘制"),t.state="startCreate";return}t.prompt&&t.prompt.update(n.endPosition,"双击结束,右键取消上一步");let s=t.getCatesian3FromPX(n.endPosition,t.viewer,[]);t.positions.length>=1&&(t.state="creating",t.movePush?t.positions[t.positions.length-1]=s:(t.positions.push(s),t.movePush=!0),t.positions.length==2&&(Cesium.defined(t.polyline)||(t.polyline=t.createPolyline())),t.positions.length==3&&(Cesium.defined(t.entity)||(t.entity=t.createPolygon(t.style),!t.style.outline&&t.polyline&&(t.polyline.show=!1),t.entity.objId=t.objId)))},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(n){t.entity&&(t.positions.splice(t.positions.length-2,1),t.viewer.entities.remove(t.controlPoints.pop()),t.positions.length==2&&t.entity&&(t.viewer.entities.remove(t.entity),t.entity=null,t.polyline&&(t.polyline.show=!0)),t.positions.length==1&&(t.polyline&&(t.viewer.entities.remove(t.polyline),t.polyline=null),t.prompt&&t.prompt.update(n.endPosition,"单击开始绘制"),t.positions=[],t.movePush=!1))},Cesium.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(function(n){t.entity&&(t.endCreate(),e&&e(t.entity))},Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}endCreate(){let e=this;e.state="endCreate",e.handler&&(e.handler.destroy(),e.handler=null),e.movePush=!1,e.prompt&&(e.prompt.destroy(),e.prompt=null),e.viewer.trackedEntity=void 0,e.viewer.scene.camera.lookAtTransform(Cesium.Matrix4.IDENTITY)}done(){this.state=="startCreate"?this.destroy():this.state=="creating"?this.positions.length<=2&&this.movePush==!0?this.destroy():this.endCreate():(this.state=="startEdit"||this.state=="editing")&&this.endEdit()}createByPositions(e,t){if(!e)return;this.state="startCreate";let n=e[0]instanceof Cesium.Cartesian3?e:se.lnglatsToCartesians(e);if(n){this.entity=this.createPolygon(),this.polyline=this.createPolyline(),this.polyline.show=this.style.outline,this.positions=n;for(let s=0;s<n.length;s++){let o=n[s],r=Cesium.Cartographic.fromCartesian(n[s]),l=this.createPoint(o);l.point.heightReference=this.style.heightReference,l.ctgc=r,l.wz=this.controlPoints.length,this.controlPoints.push(l)}this.state="endCreate",this.entity.objId=this.objId,t&&t(this.entity)}}getStyle(){if(!this.entity)return;let e={},t=this.entity.polygon;if(t.material instanceof Cesium.ColorMaterialProperty){e.material="common";let s=t.material.color.getValue();e.colorAlpha=s.alpha,e.color=new Cesium.Color(s.red,s.green,s.blue,1).toCssHexString()}if(e.fill=t.fill?t.fill.getValue():!1,t.heightReference){let s=t.heightReference.getValue();e.heightReference=Number(s)}let n=this.polyline.polyline;if(n&&this.polyline.show){e.outlineWidth=n.width.getValue(),e.outline=!0;let s=n.material.color.getValue();e.outlineColorAlpha=s.alpha,e.outlineColor=new Cesium.Color(s.red,s.green,s.blue,1).toCssHexString()}else e.outline=!1;return e}setStyle(e){if(!e)return;this.polyline.show=e.outline;let t=this.polyline.polyline;t.width=e.outlineWidth,this.polyline.clampToGround=!!e.heightReference;let s=(e.outlineColor instanceof Cesium.Color?e.outlineColor:Cesium.Color.fromCssColorString(e.outlineColor)).withAlpha(e.outlineColorAlpha||1);t.material=s,e.heightReference!=null&&(this.entity.polygon.heightReference=Number(e.heightReference));let r=(e.color instanceof Cesium.Color?e.color:Cesium.Color.fromCssColorString(e.color)).withAlpha(e.colorAlpha||1);this.entity.polygon.material=r,e.fill!=null&&(this.entity.polygon.fill=e.fill),this.style=Object.assign(this.style,e)}createPolygon(){let e=this;this.style.color=this.style.color||Cesium.Color.WHITE,this.style.outlineColor=this.style.outlineColor||Cesium.Color.BLACK;let t={polygon:{hierarchy:new Cesium.CallbackProperty(function(){return new Cesium.PolygonHierarchy(e.positions)},!1),heightReference:Number(this.style.heightReference),show:!0,fill:this.style.fill==null?!0:this.style.fill,material:this.style.color instanceof Cesium.Color?this.style.color:Cesium.Color.fromCssColorString(this.style.color).withAlpha(this.style.colorAlpha||1)}};return this.style.heightReference||(t.polygon.height=0,t.polygon.perPositionHeight=!0),this.viewer.entities.add(t)}createPolyline(){let e=this;return this.viewer.entities.add({polyline:{positions:new Cesium.CallbackProperty(function(){return e.positions.concat(e.positions[0])},!1),clampToGround:!!this.style.heightReference,material:this.style.outlineColor instanceof Cesium.Color?this.style.outlineColor:Cesium.Color.fromCssColorString(this.style.outlineColor).withAlpha(this.style.outlineColorAlpha||1),width:this.style.outlineWidth||1}})}destroy(){this.handler&&(this.handler.destroy(),this.handler=null),this.modifyHandler&&(this.modifyHandler.destroy(),this.modifyHandler=null),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.polyline&&(this.viewer.entities.remove(this.polyline),this.polyline=null),this.positions=[],this.style=null,this.modifyPoint&&(this.viewer.entities.remove(this.modifyPoint),this.modifyPoint=null);for(let e=0;e<this.controlPoints.length;e++){let t=this.controlPoints[e];this.viewer.entities.remove(t)}this.controlPoints=[],this.state="no",this.prompt&&this.prompt.destroy(),this.polyline&&(this.polyline=null,this.viewer.entities.remove(this.polyline)),this.forbidDrawWorld(!1)}}class ny extends Ke{constructor(e,t){super(e,t),this.type="rectangle",this.viewer=e,this.style=t||{},this.leftup=null,this.rightdown=null,this.leftdownPoint=null,this.rightupPoint=null,this.entity=null,this.handler=null,this.modifyHandler=null,this.modifyPoint=null,this._dragStartCart=null,this._dragStartCartCarto=null}start(e){!this.prompt&&this.promptStyle?.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate",this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));const t=this;this.handler.setInputAction(function(n){const s=t.getCatesian3FromPX(n.position,t.viewer,[]);if(s)if(t.entity)t.endCreate(),e&&e(t.entity);else{t.leftup=s.clone(),t.rightdown=s.clone(),t.entity=t._createPolyline();const o=t._calcCornerCartesian("leftdown"),r=t._calcCornerCartesian("rightup");t.leftdownPoint=t.createPoint(o),t.leftdownPoint.typeAttr="leftdown",t.leftdownPoint.show=!1,t.rightupPoint=t.createPoint(r),t.rightupPoint.typeAttr="rightup",t.rightupPoint.show=!1}},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){if(!t.entity){t.prompt?.update(n.endPosition,"单击开始绘制");return}t.prompt?.update(n.endPosition,"单击结束");const s=t.getCatesian3FromPX(n.endPosition,t.viewer,[]);s&&(t.rightdown=s.clone(),t._updatePolyline(),t._updateAuxPoints(),t.state="creating")},Cesium.ScreenSpaceEventType.MOUSE_MOVE)}endCreate(){this.handler?.destroy(),this.handler=null,this.leftdownPoint&&(this.leftdownPoint.show=!1),this.rightupPoint&&(this.rightupPoint.show=!1),this.prompt?.destroy(),this.prompt=null,this.state="endCreate"}startEdit(e){if(!this.entity)return;this.state="startEdit",this.modifyHandler||(this.modifyHandler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas));const t=this;this.leftdownPoint&&(this.leftdownPoint.show=!0),this.rightupPoint&&(this.rightupPoint.show=!0),this.modifyHandler.setInputAction(function(n){const s=t.viewer.scene.pick(n.position);if(!s?.id)return;t.modifyPoint=s.id;const o=t.getCatesian3FromPX(n.position,t.viewer,[t.entity,t.modifyPoint]);o&&(t._dragStartCart=o,t._dragStartCartCarto=Cesium.Ellipsoid.WGS84.cartesianToCartographic(o),t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(n){if(!t.modifyPoint)return;const s=t.getCatesian3FromPX(n.endPosition,t.viewer,[t.entity,t.modifyPoint]);s&&(t.modifyPoint.typeAttr==="leftdown"?t._dragCorner(s,"leftdown"):t.modifyPoint.typeAttr==="rightup"&&t._dragCorner(s,"rightup"),t._updatePolyline(),t._updateAuxPoints(),e&&e(),t.state="editing")},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.modifyHandler.setInputAction(function(){t.modifyPoint=null,t._dragStartCart=null,t._dragStartCartCarto=null,t.forbidDrawWorld(!1),t._updatePolyline(),e&&e(t.entity),t.state="editing"},Cesium.ScreenSpaceEventType.LEFT_UP)}endEdit(e){this.leftdownPoint&&(this.leftdownPoint.show=!1),this.rightupPoint&&(this.rightupPoint.show=!1),this.modifyHandler?.destroy(),this.modifyHandler=null,this.forbidDrawWorld(!1),this.state="endEdit",e&&e(this.entity)}_createPolyline(){const e=this,t=this.viewer.entities.add({polyline:{positions:new Cesium.CallbackProperty(()=>e._buildRectPositions(),!1),width:this.style.outlineWidth||this.style.width||5,material:this.style.color instanceof Cesium.Color?this.style.color:Cesium.Color.fromCssColorString(this.style.color||"#00FF00"),clampToGround:!1}});return t._plotInstance=this,t.objId=this.objId,t}_updatePolyline(){if(!this.entity)return;const e=this._buildRectPositions();try{const t=this.entity.polyline.positions;if(t&&typeof t.getValue=="function")return;if(t&&typeof t.setValue=="function"){t.setValue(e);return}this.entity.polyline.positions=e}catch{this.entity.polyline.positions=e}}_buildRectPositions(){if(!this.leftup||!this.rightdown)return[];const e=this._calcCornerCartesian("leftdown"),t=this.leftup,n=this._calcCornerCartesian("rightup"),s=this.rightdown;return[e,s,n,t,e]}_calcCornerCartesian(e){const t=Cesium.Ellipsoid.WGS84,n=t.cartesianToCartographic(this.leftup),s=t.cartesianToCartographic(this.rightdown),o=Math.min(n.longitude,s.longitude),r=Math.max(n.longitude,s.longitude),l=Math.min(n.latitude,s.latitude),a=Math.max(n.latitude,s.latitude);if(e==="leftdown")return Cesium.Cartesian3.fromRadians(o,l);if(e==="rightup")return Cesium.Cartesian3.fromRadians(r,a)}_updateAuxPoints(){if(!this.leftup||!this.rightdown)return;const e=this._calcCornerCartesian("leftdown"),t=this._calcCornerCartesian("rightup");this.leftdownPoint&&(this.leftdownPoint.position=e),this.rightupPoint&&(this.rightupPoint.position=t)}_dragCorner(e,t){const n=Cesium.Ellipsoid.WGS84,s=n.cartesianToCartographic(this.leftup),o=n.cartesianToCartographic(this.rightdown);let r=Math.min(s.longitude,o.longitude),l=Math.max(s.longitude,o.longitude),a=Math.min(s.latitude,o.latitude),d=Math.max(s.latitude,o.latitude);const h=n.cartesianToCartographic(e);t==="leftdown"?(r=h.longitude,a=h.latitude):(l=h.longitude,d=h.latitude),this.leftup=Cesium.Cartesian3.fromRadians(r,d),this.rightdown=Cesium.Cartesian3.fromRadians(l,a)}syncFromEntity(){if(!this.entity||!this.leftup||!this.rightdown)return;const e=Cesium.Cartesian3.midpoint(this.leftup,this.rightdown,new Cesium.Cartesian3),t=this.entity._centerCoord;if(!t)return;const n=t.x-e.x,s=t.y-e.y,o=t.z-e.z;this.leftup=new Cesium.Cartesian3(this.leftup.x+n,this.leftup.y+s,this.leftup.z+o),this.rightdown=new Cesium.Cartesian3(this.rightdown.x+n,this.rightdown.y+s,this.rightdown.z+o);const r=this.entity.objId,l=this.entity._plotInstance;this.leftdownPoint&&this.viewer.entities.remove(this.leftdownPoint),this.rightupPoint&&this.viewer.entities.remove(this.rightupPoint),this.leftdownPoint=this.rightupPoint=null,this.viewer.entities.remove(this.entity),this.entity=this._createPolyline(),this.entity._plotInstance=l,this.entity.objId=r;const a=this._calcCornerCartesian("leftdown"),d=this._calcCornerCartesian("rightup");this.leftdownPoint=this.createPoint(a),this.leftdownPoint.typeAttr="leftdown",this.leftdownPoint.show=this.state==="editing",this.rightupPoint=this.createPoint(d),this.rightupPoint.typeAttr="rightup",this.rightupPoint.show=this.state==="editing"}updatePositions(e){if(!e||e.length<1)return!1;try{if(!this.leftup||!this.rightdown)return!1;let t;if(e[0]instanceof Cesium.Cartesian3)t=e[0];else return!1;this.leftup=Cesium.Cartesian3.add(this.leftup,t,new Cesium.Cartesian3),this.rightdown=Cesium.Cartesian3.add(this.rightdown,t,new Cesium.Cartesian3),this._updatePolyline(),this._updateAuxPoints();try{this.viewer.scene.requestRender()}catch{}return!0}catch(t){return console.warn("Failed to update rectangle positions:",t),!1}}getPositions(e){return e?se.cartesiansToLnglats([this.leftup,this.rightdown],this.viewer):[this.leftup,this.rightdown]}getStyle(){const e=this.entity.polyline,t=e.material.color.getValue();return{color:new Cesium.Color(t.red,t.green,t.blue,1).toCssHexString(),colorAlpha:t.alpha,outlineWidth:e.width.getValue()}}setStyle(e){if(!this.entity)return;const t={...this.style,...e};let n=t.color instanceof Cesium.Color?t.color:Cesium.Color.fromCssColorString(t.color||"#00FF00");t.colorAlpha!=null&&(n=n.withAlpha(t.colorAlpha)),this.entity.polyline.material=n,this.entity.polyline.width=t.outlineWidth||t.width||5,this.style=t}destroy(){try{this.handler?.destroy(),this.modifyHandler?.destroy(),this.entity&&this.viewer.entities.remove(this.entity),this.entity=null,this.leftdownPoint&&this.viewer.entities.remove(this.leftdownPoint),this.rightupPoint&&this.viewer.entities.remove(this.rightupPoint),this.leftdownPoint=this.rightupPoint=null,this.prompt?.destroy(),this.prompt=null}catch{}}createByPositions(e,t){if(!e||e.length<2)return!1;const n=e[0]instanceof Cesium.Cartesian3?e:se.lnglatsToCartesians(e);if(!n||n.length<2)return!1;if(n.length===2)this.leftup=Cesium.Cartesian3.clone(n[0]),this.rightdown=Cesium.Cartesian3.clone(n[1]);else if(n.length>=4){let s=1/0,o=1/0,r=-1/0,l=-1/0;n.forEach(a=>{const d=Cesium.Ellipsoid.WGS84.cartesianToCartographic(a);d&&(s=Math.min(s,d.longitude),o=Math.min(o,d.latitude),r=Math.max(r,d.longitude),l=Math.max(l,d.latitude))}),this.leftup=Cesium.Cartesian3.fromRadians(s,l),this.rightdown=Cesium.Cartesian3.fromRadians(r,o)}if(this.entity?this._updatePolyline():this.entity=this._createPolyline(),!this.leftdownPoint){const s=this._calcCornerCartesian("leftdown");this.leftdownPoint=this.createPoint(s),this.leftdownPoint.typeAttr="leftdown",this.leftdownPoint.show=!1}if(!this.rightupPoint){const s=this._calcCornerCartesian("rightup");this.rightupPoint=this.createPoint(s),this.rightupPoint.typeAttr="rightup",this.rightupPoint.show=!1}this._updateAuxPoints(),this.state="endCreate";try{this.viewer.scene.requestRender()}catch(s){console.error("requestRender error:",s)}return t&&t(this.entity),!0}}class sy extends Ke{constructor(e,t){super(e,t),t=t||{},this.movePush=!1,this.type="polyline",this.maxPointNum=t.maxPointNum||Number.MAX_VALUE}updatePositions(e){if(!e||e.length<1)return!1;let t=e[0]instanceof Cesium.Cartesian3?e:util.lnglatsToCartesians(e);return t?(this.positions=t,this.updateControlPoints(),!0):!1}updateControlPoints(){for(let e=0;e<this.controlPoints.length;e++)this.viewer.entities.remove(this.controlPoints[e]);this.controlPoints=[];for(let e=0;e<this.positions.length;e++){let t=this.positions[e],n=this.createPoint(t);this.style.clampToGround&&(n.point.heightReference=1),n.wz=this.controlPoints.length,this.controlPoints.push(n)}}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new at(this.viewer,this.promptStyle)),this.state="startCreate";let t=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(n){let s=t.getCatesian3FromPX(n.position,t.viewer,[t.entity]);if(!s)return;t.movePush&&(t.positions.pop(),t.movePush=!1),t.positions.push(s);let o=t.createPoint(s);o.wz=t.positions.length-1,t.controlPoints.push(o),t.positions.length==t.maxPointNum&&(t.endCreate(),e&&e(t.entity))},Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(n){if(t.state="creating",t.positions.length<1){t.prompt.update(n.endPosition,"单击开始绘制"),t.state="startCreate";return}t.prompt.update(n.endPosition,"右键取消上一步,双击结束");let s=t.getCatesian3FromPX(n.endPosition,t.viewer,[t.entity]);s&&(t.movePush?t.positions[t.positions.length-1]=s:(t.positions.push(s),t.movePush=!0),t.positions.length==2&&(Cesium.defined(t.entity)||(t.entity=t.createPolyline())))},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(n){t.entity&&(t.positions.splice(t.positions.length-2,1),t.viewer.entities.remove(t.controlPoints.pop()),t.positions.length==1&&(t.entity&&(t.viewer.entities.remove(t.entity),t.entity=null),t.prompt.update(n.endPosition,"单击开始绘制"),t.movePush=!1,t.positions=[]))},Cesium.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(function(n){t.entity&&(t.endCreate(),e&&e(t.entity))},Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}endCreate(){let e=this;e.state="endCreate",e.handler&&(e.handler.destroy(),e.handler=null),e.positions.pop(),e.viewer.entities.remove(e.controlPoints.pop()),e.prompt&&(e.prompt.destroy(),e.prompt=null),e.viewer.trackedEntity=void 0,e.viewer.scene.camera.lookAtTransform(Cesium.Matrix4.IDENTITY)}done(){this.state=="startCreate"?this.destroy():this.state=="creating"?this.positions.length<=2&&this.movePush==!0?this.destroy():this.endCreate():(this.state=="startEdit"||this.state=="editing")&&this.endEdit()}createByPositions(e,t){if(!e||e.length<1)return;this.state="startCreate";let n=e[0]instanceof Cesium.Cartesian3?e:util.lnglatsToCartesians(e);if(n){this.entity=this.createPolyline(this.style),this.positions=n,t&&t(this.entity);for(let s=0;s<n.length;s++){let o=n[s],r=this.createPoint(o);this.style.clampToGround&&(r.point.heightReference=1),r.wz=this.controlPoints.length,this.controlPoints.push(r)}this.state="endCreate"}}setStyle(e){if(!e)return;let t=this.getMaterial(e.material,e);this.entity.polyline.material=t,this.entity.polyline.clampToGround=!!e.clampToGround,e.width&&(this.entity.polyline.width=e.width||3),this.style=Object.assign(this.style,e)}getStyle(){if(!this.entity)return;let e={},t=this.entity.polyline;this.style.animateType!=null&&(e.animateType=this.style.animateType,e.image=this.style.image,e.duration=this.style.duration),t.material instanceof Cesium.ColorMaterialProperty?e.material="common":(e.material="flowline",t.material instanceof animate.FlowLineMaterial,e.duration=t.material._duration,e.image=t.material.url);let n=t.material.color.getValue();e.colorAlpha=n.alpha,e.color=new Cesium.Color(n.red,n.green,n.blue,1).toCssHexString(),e.width=t.width._value;let s=t.clampToGround?t.clampToGround.getValue():!1;return e.clampToGround=!!s,e}createPolyline(){let e=this,t=this.viewer.entities.add({polyline:{positions:new Cesium.CallbackProperty(function(){return e.positions},!1),show:!0,material:this.getMaterial(this.style.animateType,this.style),width:this.style.width||3,clampToGround:this.style.clampToGround}});return t.objId=this.objId,t}getMaterial(e,t){t=t||{};let n=null,s=t.color||Cesium.Color.WHITE;return s=s instanceof Cesium.Color?s:Cesium.Color.fromCssColorString(t.color),s=s.withAlpha(t.colorAlpha||1),e=="flowline"||e=="flyline"||(n=s),n}updatePositions(e){if(!e||e.length<1)return!1;let t=e[0]instanceof Cesium.Cartesian3?e:util.lnglatsToCartesians(e);return t?(this.positions=t,this.updateControlPoints(),!0):!1}updateControlPoints(){for(let e=0;e<this.controlPoints.length;e++)this.viewer.entities.remove(this.controlPoints[e]);this.controlPoints=[];for(let e=0;e<this.positions.length;e++){let t=this.positions[e],n=this.createPoint(t);this.style.clampToGround&&(n.point.heightReference=1),n.wz=this.controlPoints.length,this.controlPoints.push(n)}}getPositions(e){return e?util.cartesiansToLnglats(this.positions,this.viewer):this.positions}}class oy extends Ke{constructor(e,t={}){super(e,t),this.type="freehandLine",this.maxPositions=t.maxPositions||1e4,this.minDistance=t.minDistance||2,this.renderInterval=t.renderInterval||30,this.style=Object.assign({smoothness:2,angleThreshold:3,curveResolution:3},t||{}),this.positions=[],this._stagingBuffer=[],this._flushScheduled=!1,this._flushRAF=null,this._lastFlushTime=0,this.isDrawing=!1,this.handler=null,this.startPointEntity=null,this.entity=null,this.lastAddPosition=null}start(e){if(this.state==="creating"||this.state==="startCreate")return;if(this.state="startCreate",this.positions=[],this._stagingBuffer.length=0,this._lastFlushTime=0,this.isDrawing=!1,this.lastAddPosition=null,this._cancelFlush(),!this.prompt&&this.promptStyle&&this.promptStyle.show&&Promise.resolve().then(()=>Rr).then(({default:n})=>{this.prompt=new n(this.viewer,this.promptStyle)}),this.handler){try{this.handler.destroy()}catch{}this.handler=null}if(this.entity){try{this.viewer.entities.remove(this.entity)}catch{}this.entity=null}if(this.startPointEntity){try{this.viewer.entities.remove(this.startPointEntity)}catch{}this.startPointEntity=null}this.entity=this.createFreehandLine();const t=this;this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.handler.setInputAction(function(n){t.state="creating",t.isDrawing=!0,t.forbidDrawWorld(!0),t.positions=[],t._stagingBuffer.length=0,t.lastAddPosition=null;let s=t._fastPick(n.position);if(!s){t.isDrawing=!1;return}const o=Cesium.Cartesian3.clone(s);if(t._pushToStaging(o),t.lastAddPosition=o,t.startPointEntity){try{t.viewer.entities.remove(t.startPointEntity)}catch{}t.startPointEntity=null}t.startPointEntity=t.viewer.entities.add({position:o,point:{pixelSize:6,color:Cesium.Color.RED,outlineColor:Cesium.Color.WHITE,outlineWidth:1}}),t._scheduleFlush(!0)},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.handler.setInputAction(function(n){if(!t.isDrawing){t.prompt&&n&&n.endPosition&&t.prompt.update(n.endPosition,"单击开始绘制");return}if(t.prompt&&n&&n.endPosition&&t.prompt.update(n.endPosition,"松键结束"),!n||!n.endPosition||t.positions.length+t._stagingBuffer.length>=t.maxPositions)return;let s=t._fastPick(n.endPosition);if(!s||t.lastAddPosition&&Cesium.Cartesian3.distance(t.lastAddPosition,s)<=t.minDistance)return;const o=Cesium.Cartesian3.clone(s);t._pushToStaging(o),t.lastAddPosition=o,t._scheduleFlush()},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(n){if(t.isDrawing){if(t.prompt&&t.prompt.update(null,"单击结束绘制"),t.isDrawing=!1,t.forbidDrawWorld(!1),t.startPointEntity){try{t.viewer.entities.remove(t.startPointEntity)}catch{}t.startPointEntity=null}t._scheduleFlush(!0),t.endCreate(e)}},Cesium.ScreenSpaceEventType.LEFT_UP),this.handler.setInputAction(function(n){if(t.isDrawing){if(t.prompt&&t.prompt.update(null,"单击结束绘制"),t.isDrawing=!1,t.forbidDrawWorld(!1),t.startPointEntity){try{t.viewer.entities.remove(t.startPointEntity)}catch{}t.startPointEntity=null}t._scheduleFlush(!0),t.endCreate(e)}},Cesium.ScreenSpaceEventType.RIGHT_DOWN)}_pushToStaging(e){this._stagingBuffer.push(e)}_scheduleFlush(e=!1){if(this._flushRAF){e&&(this._forceImmediate=!0);return}this._forceImmediate=e||!1;const t=this,n=function(){t._flushRAF=null;const s=performance.now();(t._forceImmediate||s-t._lastFlushTime>=t.renderInterval)&&(t._flushToPositions(),t._lastFlushTime=s),t._forceImmediate=!1};this._flushRAF=requestAnimationFrame(n)}_cancelFlush(){if(this._flushRAF){try{cancelAnimationFrame(this._flushRAF)}catch{}this._flushRAF=null}this._forceImmediate=!1}_fastPick(e){if(this.viewer.scene.mode===Cesium.SceneMode.SCENE2D){const n=this.viewer.camera.getPickRay(e);let s=null;return n&&(s=this.viewer.scene.globe.pick(n,this.viewer.scene)),s||(s=this.viewer.camera.pickEllipsoid(e,this.viewer.scene.globe.ellipsoid)),s}let t=null;try{t=this.viewer.scene.pickPosition(e)}catch{}if(!t){const n=this.viewer.camera.getPickRay(e);n&&(t=this.viewer.scene.globe.pick(n,this.viewer.scene))}return t}_flushToPositions(){if(!this._stagingBuffer||this._stagingBuffer.length===0)return;const e=this._stagingBuffer;this._stagingBuffer=[];const t=Math.max(0,Math.min(2,Number(this.style.smoothness||1)));let n=e;if(t>0){const l=(h,p)=>{if(!h||h.length<2)return h;p=Math.max(1,p|0);const f=[h[0]],u=h.length;for(let m=0;m<u-1;m++){const E=m>0?h[m-1]:h[m],A=h[m],y=h[m+1],v=m+2<u?h[m+2]:h[m+1];for(let S=1;S<p;S++){const M=S/p,O=M*M,I=O*M,B=-.5*E.x+1.5*A.x-1.5*y.x+.5*v.x,g=-.5*E.y+1.5*A.y-1.5*y.y+.5*v.y,P=-.5*E.z+1.5*A.z-1.5*y.z+.5*v.z,x=E.x-2.5*A.x+2*y.x-.5*v.x,F=E.y-2.5*A.y+2*y.y-.5*v.y,_=E.z-2.5*A.z+2*y.z-.5*v.z,H=-.5*E.x+.5*y.x,N=-.5*E.y+.5*y.y,w=-.5*E.z+.5*y.z,C=A.x,b=A.y,D=A.z,k=B*I+x*O+H*M+C,Q=g*I+F*O+N*M+b,R=P*I+_*O+w*M+D;f.push(new Cesium.Cartesian3(k,Q,R))}f.push(y)}return f},a=Math.max(1,Number(this.style.curveResolution)||1);n.length<200&&a>1&&(n=l(n,a));const d=h=>{if(!h||h.length<2)return h;const p=[];p.push(h[0]);for(let f=0;f<h.length-1;f++){const u=h[f],m=h[f+1],E=new Cesium.Cartesian3(u.x*.75+m.x*.25,u.y*.75+m.y*.25,u.z*.75+m.z*.25),A=new Cesium.Cartesian3(u.x*.25+m.x*.75,u.y*.25+m.y*.75,u.z*.25+m.z*.75);p.push(E),p.push(A)}return p.push(h[h.length-1]),p};n=n.slice(),n.length<300&&(n=d(n),t===2&&n.length<300&&(n=d(n)))}const s=(Number(this.style.angleThreshold)||6)*(Math.PI/180),o=this.positions,r=(l,a,d,h)=>{if(!l||!a||!d)return!1;const p=a.x-l.x,f=a.y-l.y,u=a.z-l.z,m=d.x-a.x,E=d.y-a.y,A=d.z-a.z,y=Math.hypot(p,f,u),v=Math.hypot(m,E,A);if(y===0||v===0)return!1;const S=(p*m+f*E+u*A)/(y*v),M=Math.max(-1,Math.min(1,S)),O=Math.acos(M);return Math.abs(O)<=h};for(let l=0;l<n.length;l++){const a=n[l];if(o.length===0){o.push(Cesium.Cartesian3.clone(a));continue}const d=o[o.length-1];if(!(Cesium.Cartesian3.distance(d,a)<=this.minDistance*.5)){if(o.length>=2){const p=o[o.length-2],f=o[o.length-1],u=a;if(r(p,f,u,s)){o.pop(),o.push(Cesium.Cartesian3.clone(u));continue}}if(o.push(Cesium.Cartesian3.clone(a)),o.length>this.maxPositions){const p=o.length-this.maxPositions;p>0&&o.splice(0,p)}}}try{this.viewer.scene.requestRender()}catch{}}endCreate(e){if(this.state==="endCreate")return;if(this.state="endCreate",this.handler){try{this.handler.destroy()}catch{}this.handler=null}if(this.prompt){try{this.prompt.destroy()}catch{}this.prompt=null}if(this._flushToPositions(),this._cancelFlush(),!this.positions||this.positions.length<2){if(this.entity){try{this.viewer.entities.remove(this.entity)}catch{}this.entity=null}e&&e(null);return}const t=this.positions.map(n=>Cesium.Cartesian3.clone(n));this.positions=t;try{this.viewer.scene.requestRender()}catch{}e&&e(this.entity)}done(e){this.isDrawing&&(this.isDrawing=!1,this.forbidDrawWorld(!1),this.endCreate(e))}createFreehandLine(){const e=this,t=this.getMaterial(this.style.animateType,this.style),n=this.viewer.entities.add({polyline:{positions:new Cesium.CallbackProperty(function(){return e.positions||[]},!1),show:!0,material:t,width:this.style.width||3,clampToGround:!!this.style.clampToGround||!1}});return n.objId=this.objId||null,this.entity=n,n}getMaterial(e,t){t=t||{};try{let n=t.color||Cesium.Color.RED;typeof n=="string"&&(n=Cesium.Color.fromCssColorString(n));const s=t.colorAlpha!==void 0?t.colorAlpha:1;return n=n.withAlpha(s),n}catch{return Cesium.Color.RED}}updatePositions(e){if(!e||e.length<1)return!1;try{let t=[];if(e[0]instanceof Cesium.Cartesian3?t=e.map(n=>Cesium.Cartesian3.clone(n)):t=se&&se.lnglatsToCartesians?se.lnglatsToCartesians(e):e,!t||t.length===0)return!1;this.positions=t.map(n=>Cesium.Cartesian3.clone(n)),this._stagingBuffer.length=0;try{this.viewer.scene.requestRender()}catch{}return!0}catch{return!1}}setStyle(e){if(!e||(this.style=Object.assign(this.style||{},e),!this.entity||!this.entity.polyline))return;const t=this.getMaterial(this.style.animateType,this.style);try{this.entity.polyline.material=t}catch{}if(e.width!==void 0)try{this.entity.polyline.width=e.width}catch{}if(e.clampToGround!==void 0)try{this.entity.polyline.clampToGround=!!e.clampToGround}catch{}}createByPositions(e,t){if(!e||e.length<1)return!1;const n=e[0]instanceof Cesium.Cartesian3?e:se.lnglatsToCartesians(e);if(!n||n.length<1)return!1;this.positions=n.map(s=>Cesium.Cartesian3.clone(s)),this.entity||this.createFreehandLine(),this.state="endCreate";try{this.viewer.scene.requestRender()}catch{}return t&&t(this.entity),!0}destroy(){if(this._cancelFlush(),this.handler){try{this.handler.destroy()}catch{}this.handler=null}if(this.entity){try{this.viewer.entities.remove(this.entity)}catch{}this.entity=null}if(this.startPointEntity){try{this.viewer.entities.remove(this.startPointEntity)}catch{}this.startPointEntity=null}this.positions=[],this._stagingBuffer=[],this.isDrawing=!1;try{this.endCreate()}catch{}}}class ry extends Ke{constructor(e,t={}){if(!e)throw new Error("CreateArrow requires viewer");if(super(e,t),this.type="arrow",this.style=t||{},this.arrowAngle=t.arrowAngle||Math.PI/6,this.positions=[],this.lineEntity=null,this.arrowEntity=null,this.controlPoints=[],this.handler=null,this._finalized=!1,this._editRenderHandler=null,this.Cesium=this._getCesium(),!this.Cesium)throw new Error("Cesium not found")}_getCesium(){return typeof window<"u"&&window.Cesium?window.Cesium:typeof Cesium<"u"?Cesium:this.viewer&&this.viewer.constructor&&this.viewer.constructor.Cesium?this.viewer.constructor.Cesium:null}start(e){if(!this.viewer||!this.Cesium)return e&&e(null),this;if(this.state==="creating"||this.state==="startCreate")return this;this.state="startCreate",this._cleanup(!1),!this.prompt&&this.promptStyle&&this.promptStyle.show&&Promise.resolve().then(()=>Rr).then(({default:n})=>{this.prompt=new n(this.viewer,this.promptStyle)}).catch(()=>{});try{this.forbidDrawWorld(!0)}catch{}const t=this;return this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.handler.setInputAction(function(n){if(t.state==="startCreate"){t.state="creating",t._finalized=!1;let s=t.getCatesian3FromPX(n.position);if(!s)return;t.positions=[t.Cesium.Cartesian3.clone(s),t.Cesium.Cartesian3.clone(s)],t._createLineEntity(),t._createArrowEntity(),t._createControlPoints(),t.prompt&&n&&n.position&&t.prompt.update(n.position,"再次单击完成绘制")}else if(t.state==="creating"){if(t.state="endCreate",t._finalized=!0,t._finalizeEntities(),t.prompt){try{t.prompt.destroy()}catch{}t.prompt=null}if(t.handler){try{t.handler.destroy()}catch{}t.handler=null}try{t.forbidDrawWorld(!1)}catch{}e&&e(t.entity||t.lineEntity)}try{t.viewer.scene.requestRender()}catch{}},this.Cesium.ScreenSpaceEventType.LEFT_DOWN),this.handler.setInputAction(function(n){if(t.state==="startCreate"){t.prompt&&n&&n.endPosition&&t.prompt.update(n.endPosition,"单击开始绘制");return}if(t.state==="creating"){let s=t.getCatesian3FromPX(n.endPosition);if(!s)return;if(t.positions[1]=s,t.controlPoints[1])try{t.controlPoints[1].position.setValue(s)}catch{}try{t.viewer.scene.requestRender()}catch{}}},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(){if(t.state==="creating"){if(t.state="endCreate",t._finalized=!1,t.lineEntity){try{t.viewer.entities.remove(t.lineEntity)}catch{}t.lineEntity=null}if(t.arrowEntity){try{t.viewer.entities.remove(t.arrowEntity)}catch{}t.arrowEntity=null}t.controlPoints.length&&(t.controlPoints.forEach(n=>{try{t.viewer.entities.remove(n)}catch{}}),t.controlPoints=[])}if(t.prompt){try{t.prompt.destroy()}catch{}t.prompt=null}if(t.handler){try{t.handler.destroy()}catch{}t.handler=null}try{t.forbidDrawWorld(!1)}catch{}e&&e(null)},this.Cesium.ScreenSpaceEventType.RIGHT_DOWN),this}_computeArrowPositions(e,t){if(!e||!t)return[];const n=this.Cesium.Cartesian3.distance(e,t);if(n<=1e-6)return[];const s=this.style.arrowLengthFactor!==void 0?this.style.arrowLengthFactor:.15,o=this.style.arrowMinSize!==void 0?this.style.arrowMinSize:1.5,r=this.style.arrowMaxSize!==void 0?this.style.arrowMaxSize:Number.MAX_VALUE;let l=this.style.arrowFixedSize!==void 0?this.style.arrowFixedSize:n*s;l<o&&(l=o),l>r&&(l=r);const a=this.Cesium.Cartesian3.subtract(t,e,new this.Cesium.Cartesian3);this.Cesium.Cartesian3.normalize(a,a);const d=this.Cesium.Transforms.eastNorthUpToFixedFrame(t),h=this.Cesium.Matrix4.getColumn(d,2,new this.Cesium.Cartesian3),p=new this.Cesium.Cartesian3(a.x-h.x*this.Cesium.Cartesian3.dot(a,h),a.y-h.y*this.Cesium.Cartesian3.dot(a,h),a.z-h.z*this.Cesium.Cartesian3.dot(a,h));let f;this.Cesium.Cartesian3.magnitudeSquared(p)<1e-6?f=this.Cesium.Matrix4.getColumn(d,0,new this.Cesium.Cartesian3):(this.Cesium.Cartesian3.normalize(p,p),f=this.Cesium.Cartesian3.cross(h,p,new this.Cesium.Cartesian3),this.Cesium.Cartesian3.normalize(f,f));const u=this.Cesium.Cartesian3.multiplyByScalar(a,-l,new this.Cesium.Cartesian3),m=this.Cesium.Cartesian3.add(t,u,new this.Cesium.Cartesian3),E=this.style.arrowWidthScale!==void 0?this.style.arrowWidthScale:1,A=Math.sin(this.arrowAngle)*l*E,y=this.Cesium.Cartesian3.multiplyByScalar(f,A,new this.Cesium.Cartesian3),v=this.Cesium.Cartesian3.multiplyByScalar(f,-A,new this.Cesium.Cartesian3),S=this.Cesium.Cartesian3.add(m,y,new this.Cesium.Cartesian3),M=this.Cesium.Cartesian3.add(m,v,new this.Cesium.Cartesian3);return[t,S,M,t]}_createLineEntity(){if(this.lineEntity){try{this.viewer.entities.remove(this.lineEntity)}catch{}this.lineEntity=null}const e=this,t=this._getMaterial(),n=new this.Cesium.CallbackProperty(function(){return!e.positions||e.positions.length<2?[]:[e.positions[0],e.positions[1]]},!1);this.lineEntity=this.viewer.entities.add({polyline:{positions:n,material:t,width:this.style.width||3,clampToGround:!!this.style.clampToGround||!1},objId:this.objId}),this.entity=this.lineEntity}_createArrowEntity(){if(this.arrowEntity){try{this.viewer.entities.remove(this.arrowEntity)}catch{}this.arrowEntity=null}const e=this,t=this._getMaterial(),n=new this.Cesium.CallbackProperty(function(){if(!e.positions||e.positions.length<2)return[];const s=e.positions[0],o=e.positions[1];return e._computeArrowPositions(s,o)},!1);this.arrowEntity=this.viewer.entities.add({polyline:{positions:n,material:t,width:this.style.width||3,clampToGround:!!this.style.clampToGround||!1},objId:this.objId}),console.log("this.arrowEntity",this.arrowEntity)}_createControlPoints(){if(this.controlPoints&&this.controlPoints.length&&(this.controlPoints.forEach(e=>{try{this.viewer.entities.remove(e)}catch{}}),this.controlPoints=[]),!(!this.positions||this.positions.length<2))for(let e=0;e<2;e++)try{const t=this.createPoint(this.positions[e]);t.wz=e,this.controlPoints.push(t)}catch{}}_finalizeEntities(){if(this.lineEntity&&this.lineEntity.polyline)try{const e=this.Cesium.Cartesian3.clone(this.positions[0]),t=this.Cesium.Cartesian3.clone(this.positions[1]);this.lineEntity.polyline.positions=[e,t]}catch{}if(this.arrowEntity&&this.arrowEntity.polyline)try{const e=this.positions[0],t=this.positions[1];this.arrowEntity.polyline.positions=this._computeArrowPositions(e,t)}catch{}this.entity=this.lineEntity,this.entity&&(this.entity.arrowEntity=this.arrowEntity,this.entity.positions=[this.positions[0],this.positions[1]],this.positions=[this.positions[0],this.positions[1]]);try{this.viewer.scene.requestRender()}catch{}}startEdit(e){super.startEdit(e),(!this.controlPoints||this.controlPoints.length<2)&&this._createControlPoints();for(let t=0;t<this.controlPoints.length;t++)try{this.controlPoints[t].show=!0}catch{}if(this.lineEntity&&this.lineEntity.polyline)try{const t=this;this.lineEntity.polyline.positions=new this.Cesium.CallbackProperty(function(){return!t.positions||t.positions.length<2?[]:[t.positions[0],t.positions[1]]},!1)}catch{}if(this.arrowEntity&&this.arrowEntity.polyline)try{const t=this;this.arrowEntity.polyline.positions=new this.Cesium.CallbackProperty(function(){if(!t.positions||t.positions.length<2)return[];const n=t.positions[0],s=t.positions[1];return t._computeArrowPositions(n,s)},!1)}catch{}if(!this._editRenderHandler){this._editRenderHandler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);const t=this;this._editRenderHandler.setInputAction(function(n){if(t.modifyPoint)try{t.viewer.scene.requestRender()}catch{}},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE)}}endEdit(e){if(super.endEdit(e),this._editRenderHandler){try{this._editRenderHandler.destroy()}catch{}this._editRenderHandler=null}this._finalized=!0,this._finalizeEntities()}createByPositions(e,t){if(!e||e.length<2)return!1;let n=e[0],s=e[1];if(!(n instanceof this.Cesium.Cartesian3))if(Array.isArray(n)&&n.length>=2)n=this.Cesium.Cartesian3.fromDegrees(n[0],n[1]),s=this.Cesium.Cartesian3.fromDegrees(s[0],s[1]);else return!1;return this.positions=[this.Cesium.Cartesian3.clone(n),this.Cesium.Cartesian3.clone(s)],this._createLineEntity(),this._createArrowEntity(),this._createControlPoints(),this._finalized=!0,this._finalizeEntities(),this.state="endCreate",t&&t(this.entity||this.lineEntity),!0}updatePositions(e){if(!e||e.length<2)return!1;let t=e[0],n=e[1];if(!(t instanceof this.Cesium.Cartesian3))if(Array.isArray(t)&&t.length>=2)t=this.Cesium.Cartesian3.fromDegrees(t[0],t[1]),n=this.Cesium.Cartesian3.fromDegrees(n[0],n[1]);else return!1;return this.positions=[this.Cesium.Cartesian3.clone(t),this.Cesium.Cartesian3.clone(n)],this.lineEntity||this._createLineEntity(),this.arrowEntity||this._createArrowEntity(),this._createControlPoints(),this._finalized=!0,this._finalizeEntities(),!0}setStyle(e){if(!e)return;this.style=Object.assign(this.style||{},e),e.arrowAngle!==void 0&&(this.arrowAngle=e.arrowAngle);const t=this._getMaterial();if(this.lineEntity&&this.lineEntity.polyline){try{this.lineEntity.polyline.material=t}catch{}if(e.width!==void 0)try{this.lineEntity.polyline.width=e.width}catch{}}if(this.arrowEntity&&this.arrowEntity.polyline)try{this.arrowEntity.polyline.material=t}catch{}}endCreate(e){if(this.state!=="endCreate"){if(this.state="endCreate",this.prompt){try{this.prompt.destroy()}catch{}this.prompt=null}if(this._finalized=!0,this._finalizeEntities(),this.handler){try{this.handler.destroy()}catch{}this.handler=null}try{this.forbidDrawWorld(!1)}catch{}e&&e(this.entity||this.lineEntity)}}done(e){this.isDrawing&&(this.isDrawing=!1,this.endCreate(e))}getEntity(){return this.entity||this.lineEntity}destroy(){this._cleanup(!0),this.state=null}_cleanup(e=!0){if(this.handler){try{this.handler.destroy()}catch{}this.handler=null}if(this._editRenderHandler){try{this._editRenderHandler.destroy()}catch{}this._editRenderHandler=null}if(e){if(this.lineEntity){try{this.viewer.entities.remove(this.lineEntity)}catch{}this.lineEntity=null}if(this.arrowEntity){try{this.viewer.entities.remove(this.arrowEntity)}catch{}this.arrowEntity=null}this.controlPoints&&this.controlPoints.length&&(this.controlPoints.forEach(t=>{try{this.viewer.entities.remove(t)}catch{}}),this.controlPoints=[]),this.entity=null}if(this.prompt){try{this.prompt.destroy()}catch{}this.prompt=null}this.positions=[],this.isDrawing=!1,this._finalized=!1;try{this.forbidDrawWorld(!1)}catch{}}_getMaterial(){try{let e=this.style.color||this.Cesium.Color.RED;typeof e=="string"&&(e=this.Cesium.Color.fromCssColorString(e));const t=this.style.colorAlpha!==void 0?this.style.colorAlpha:1;return e.withAlpha(t)}catch{return this.Cesium.Color.RED}}}class ay{constructor(e,t){if(!e){console.warn("缺少必要参数!--viewer");return}if(t=t||{},this.viewer=e,this.Cesium=window.Cesium||window.cesium,this.entityObjArr=[],this.handler=null,!this.Cesium){console.error("Cesium实例未找到!");return}this.removeHandler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.startEditFun=null,this.endEditFun=null,this.removeFun=null,this.editingFun=void 0,this.deleteEntityObj=null,this.bindEdit(),this.bindRemove(),this.canEdit=t.canEdit==null?!0:t.canEdit,this.fireEdit=t.fireEdit==null?!0:t.fireEdit,this.nowDrawEntityObj=null,this.nowEditEntityObj=null}on(e,t){e=="startEdit"&&(this.startEditFun=t),e=="endEdit"&&(this.endEditFun=t),e=="remove"&&(this.removeFun=t),e=="endCreate"&&(this.endCreateFun=t),e=="editing"&&(this.editingFun=t)}openEdit(){this.canEdit=!0}closeEdit(){this.endEdit(),this.canEdit=!1}start(e){if(!e||!e.type)return;e.id=e.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0));let t=this;this.endEdit(),this.nowDrawEntityObj&&(this.nowDrawEntityObj.state=="startCreate"||this.nowDrawEntityObj.state=="creating")&&(this.nowDrawEntityObj.destroy(),this.nowDrawEntityObj=null);let n=this.createByType(e);if(n)return n.attr=e||{},n.start(function(s){t.nowDrawEntityObj=void 0,t.entityObjArr.push(n),e.success&&e.success(n,s),t.endCreateFun&&t.endCreateFun(n,s),e.show==!1&&n.setVisible(!1),t.canEdit&&t.fireEdit&&(n.startEdit(function(){t.editingFun&&t.editingFun(n,n.entity)}),t.nowEditEntityObj=n,t.startEditFun&&t.startEditFun(n,s))}),this.nowDrawEntityObj=n,n}end(){this.nowDrawEntityObj}startEditOne(e){if(!this.canEdit)return;this.nowEditEntityObj&&(this.nowEditEntityObj.endEdit(),this.endEditFun&&this.endEditFun(this.nowEditEntityObj,this.nowEditEntityObj.getEntity()),this.nowEditEntityObj=null);let t=this;e&&(e.startEdit(function(){t.editingFun&&t.editingFun(e,e.entity)}),this.startEditFun&&this.startEditFun(e,e.getEntity()),this.nowEditEntityObj=e)}updateOneStyle(e,t){e&&e.setStyle(t)}createByPositions(e){if(e=e||{},e||(e={}),!e.positions)return;e.id=e.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0));let t=this,n=this.createByType(e);if(n)return n.attr=e,n.createByPositions(e.positions,function(s){t.entityObjArr.push(n),n.setStyle(e.style),e.success&&e.success(n,s),t.endCreateFun&&t.endCreateFun(n,s),e.show==!1&&n.setVisible(!1),t.canEdit&&t.fireEdit&&(n.startEdit(function(){t.editingFun&&t.editingFun(n,n.entity)}),t.startEditFun&&t.startEditFun(n,s),t.nowEditEntityObj=n)}),n}createByGeojson(e){let{features:t}=e,n=[];for(let s=0;s<t.length;s++){let o=t[s];const{properties:r,geometry:l}=o;let a=r.plotType;const d=l.type,h=l.coordinates;let p=[],f="";switch(d){case"LineString":p=se.lnglatsToCartesians(h),f="polyline";break;case"Polygon":p=se.lnglatsToCartesians(h[0]),f="polygon";break;case"Point":p=se.lnglatsToCartesians([h])[0],f=a;break}this.fireEdit=!1;let u=this.createByPositions({type:f,styleType:a,positions:p,style:r.style});u&&n.push(u)}return n}toGeojson(){let e={type:"FeatureCollection",features:[]};if(this.entityObjArr.length==0)return null;for(let t=0;t<this.entityObjArr.length;t++){let n=this.entityObjArr[t],s=n.getPositions(!0),o=[];for(let d=0;d<s.length;d++)o.push([s[d][0],s[d][1]]);let r=n.getStyle(),l=this.transType(n.type),a={type:"Feature",properties:{plotType:n.type,style:r},geometry:{type:l,coordinates:[]}};switch(l){case"Polygon":a.geometry.coordinates=[o];break;case"Point":a.geometry.coordinates=o;break;case"LineString":a.geometry.coordinates=o;break}a.properties=Object.assign(a.properties,n.properties),e.features.push(a)}return e}transType(e){let t="";switch(e){case"polyline":t="LineString";break;case"polygon":t="Polygon";break;case"point":case"gltfModel":case"label":case"billboard":t="Point";break;default:t=e}return t}destroy(){this.nowEditEntityObj&&(this.nowEditEntityObj.destroy(),this.nowEditEntityObj=null),this.nowDrawEntityObj&&(this.nowDrawEntityObj.destroy(),this.nowDrawEntityObj=null);for(let e=0;e<this.entityObjArr.length;e++)this.entityObjArr[e].destroy();this.entityObjArr=[],this.nowEditEntityObj=null,this.handler&&(this.handler.destroy(),this.handler=null),this.removeHandler&&(this.removeHandler.destroy(),this.removeHandler=null)}removeOne(e){e&&e&&(e.state!="endCreate"||e.state!="endEdit"?e.destroy():this.removeByObjId(e.objId))}removeAll(){this.nowDrawEntityObj&&(this.nowDrawEntityObj.destroy(),this.nowDrawEntityObj=null),this.nowEditEntityObj&&(this.nowEditEntityObj.destroy(),this.nowEditEntityObj=null);for(let e=0;e<this.entityObjArr.length;e++)this.entityObjArr[e].destroy();this.entityObjArr=[],this.nowEditEntityObj=null}hasEntityObj(e){return e?this.getEntityObjByObjId(e.objId)!={}:!1}removeByObjId(e){let t=this.getEntityObjByObjId(e);this.entityObjArr.splice(t.index,1),this.removeFun&&this.removeFun(t.entityObj,t.entityObj.getEntity()),t.entityObj&&t.entityObj.destroy()}removeById(e){let t=this.getEntityObjById(e);this.entityObjArr.splice(t.index,1),this.removeFun&&this.removeFun(t.entityObj,t.entityObj.getEntity()),t.entityObj&&t.entityObj.destroy()}zoomToByObjId(e){let t=this.getEntityObjByObjId(e);t.entityObj&&t.entityObj.zoomTo()}getEntityObjByField(e,t){let n={};if(t)for(let s=0;s<this.entityObjArr.length;s++){let o=this.entityObjArr[s];if(o.attr[e]==t){n.entityObj=o,n.index=s;break}}else for(let s=0;s<this.entityObjArr.length;s++){let o=this.entityObjArr[s];if(o.attr.id==e){n.entityObj=o,n.index=s;break}}return n}setVisible(e,t){let n=this.getEntityObjByField("id",e);n.entityObj&&n.entityObj.setVisible(t)}getEntityObjByObjId(e){if(!e)return;let t={};for(let n=0;n<this.entityObjArr.length;n++){let s=this.entityObjArr[n];if(s.objId==e){t.entityObj=s,t.index=n;break}}return t}getEntityObjById(e){if(!e)return;let t={};for(let n=0;n<this.entityObjArr.length;n++){let s=this.entityObjArr[n];if(s.attr.id==e){t.entityObj=s,t.index=n;break}}return t}bindEdit(){let e=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(t){if(!e.canEdit||e.nowDrawEntityObj)return;const n=e.viewer.scene.drillPick(t.position)||[];let s=-1,o;for(let r=0;r<n.length&&s===-1;r++){const l=n[r].id;if(l){for(let a=0;a<e.entityObjArr.length;a++)if(l.objId==e.entityObjArr[a].objId&&e.entityObjArr[a].state!="startCreate"&&e.entityObjArr[a].state!="creating"){s=a,o=l;break}}}s!==-1?(e.nowEditEntityObj&&(e.nowEditEntityObj.endEdit(),e.endEditFun&&e.endEditFun(e.nowEditEntityObj,e.nowEditEntityObj.getEntity()),e.nowEditEntityObj=null),e.entityObjArr[s].startEdit(function(){e.editingFun&&e.editingFun(e.nowEditEntityObj,e.nowEditEntityObj.entity)}),e.startEditFun&&e.startEditFun(e.entityObjArr[s],o),e.nowEditEntityObj=e.entityObjArr[s]):e.nowEditEntityObj&&(e.nowEditEntityObj.endEdit(),e.endEditFun&&e.endEditFun(e.nowEditEntityObj,e.nowEditEntityObj.getEntity()),e.nowEditEntityObj=void 0)},Cesium.ScreenSpaceEventType.LEFT_CLICK)}bindRemove(){let e=this;this.handler||(this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)),this.handler.setInputAction(function(t){if(!e.canEdit||e.nowDrawEntityObj)return;const n=e.viewer.scene.drillPick(t.position)||[];let s;for(let o=0;o<n.length;o++){const r=n[o].id;if(r){for(let l=0;l<e.entityObjArr.length;l++)if(r.objId==e.entityObjArr[l].objId){s=r.objId;break}if(s)break}}s&&e.createDelteDom(t.position,s)},Cesium.ScreenSpaceEventType.RIGHT_CLICK)}createDelteDom(e,t){if(!t)return;let n=window.document.createElement("span");n.style.background="rgba(0,0,0,0.5)",n.style.position="absolute",n.style.color="white",n.style.left=e.x+10+"px",n.style.top=e.y+10+"px",n.style.padding="4px",n.style.cursor="pointer",n.id="easy3d-plot-delete",n.setAttribute("objId",t),n.innerHTML="删除",window.document.getElementById(this.viewer.container.id).appendChild(n);const o=window.document.getElementById("easy3d-plot-delete");if(!o)return;let r=this;o.addEventListener("click",l=>{let a=n.getAttribute("objId");r.removeByObjId(a)}),document.addEventListener("click",function(){o.remove()})}endEdit(){this.nowEditEntityObj&&(this.nowEditEntityObj.endEdit(),this.endEditFun&&this.endEditFun(this.nowEditEntityObj,this.nowEditEntityObj.getEntity()),this.nowEditEntityObj=null);for(let e=0;e<this.entityObjArr.length;e++)this.entityObjArr[e].endEdit()}done(){this.nowEditEntityObj&&(this.nowEditEntityObj.done(),this.endEditFun&&this.endEditFun(this.nowEditEntityObj,this.nowEditEntityObj.getEntity()),this.nowEditEntityObj=void 0),this.nowDrawEntityObj&&(this.nowDrawEntityObj.done(),this.entityObjArr.push(this.nowDrawEntityObj),this.endCreateFun&&this.endCreateFun(this.nowDrawEntityObj,this.nowDrawEntityObj.getEntity()),this.nowDrawEntityObj=void 0)}getEntityObjArr(){return this.entityObjArr}createByType(e){let t,n="";return e=e||{},e.type=="polyline"&&(t=new sy(this.viewer,e.style),n="折线_"),e.type=="freehandLine"&&(t=new oy(this.viewer,e.style),n="手绘线_"),e.type=="polygon"&&(t=new iy(this.viewer,e.style),n="面_"),e.type=="billboard"&&(t=new wp(this.viewer,e.style),n="图标_"),(e.type=="circle"||e.type=="ellipse")&&(t=new bp(this.viewer,e.style),n="圆_"),e.type=="rectangle"&&(t=new ny(this.viewer,e.style),n="矩形_"),e.type=="gltfModel"&&(t=new vp(this.viewer,e.style),n="模型_"),e.type=="point"&&(t=new ty(this.viewer,e.style),n="点_"),e.type=="label"&&(t=new ey(this.viewer,e.style),n="文字_"),e.type=="arrow"&&(t=new ry(this.viewer,e.style)),t&&(t.name=n+new Date().getTime()),t}}class el{viewer;Cesium;drawTool;flatTool;tileset;tilesets;flatTools;selectedEntityObj;selectionOutline;centerHandle;_dragHandler;_listeners;currentColor;currentWidth;originalDoubleClickAction=null;constructor({viewer:e,cesium:t}){window.Cesium=t,this.viewer=e,this.Cesium=t,this.drawTool=null,this.flatTool=null,this.tileset=null,this.tilesets=null,this.flatTools=null,this.selectedEntityObj=null,this.selectionOutline=null,this.centerHandle=null,this._dragHandler=null,this._listeners=[],this.currentColor=this.Cesium.Color.fromCssColorString("#ff0000"),this.currentWidth=1,this.originalDoubleClickAction=this.viewer.screenSpaceEventHandler.getInputAction(this.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.viewer.screenSpaceEventHandler.removeInputAction(this.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.initDrawTool()}setCurrentColor(e){typeof e=="string"?this.currentColor=this.Cesium.Color.fromCssColorString(e):this.currentColor=e}setCurrentWidth(e){this.currentWidth=e}initDrawTool(){this.drawTool||(this.drawTool=new ay(this.viewer,{canEdit:!0,fireEdit:!0}),this.drawTool.on("startEdit",(e,t)=>{this.selectedEntityObj=e,this.showEntityOutline(e)}),this.drawTool.on("endEdit",(e,t)=>{this.selectedEntityObj=null,this.hideEntityOutline()}),this.drawTool.on("remove",(e,t)=>{this.selectedEntityObj===e&&(this.selectedEntityObj=null,this.hideEntityOutline())}))}showEntityOutline(e){this.hideEntityOutline(),!(!e||!e.getEntity())&&this.createCenterHandle(e)}hideEntityOutline(){if(this.selectionOutline){try{this.viewer.entities.remove(this.selectionOutline)}catch{}this.selectionOutline=null}if(this.centerHandle){try{this.viewer.entities.remove(this.centerHandle)}catch{}this.centerHandle=null}if(this._dragHandler){try{this._dragHandler.destroy()}catch{}this._dragHandler=null}}createCenterHandle(e){if(!e||!e.getEntity())return;if(this.centerHandle){try{this.viewer.entities.remove(this.centerHandle)}catch{}this.centerHandle=null}const t=e.getEntity();let n=null;if(t._plotInstance&&typeof t._plotInstance.syncFromEntity=="function")try{t._plotInstance.syncFromEntity();const s=t._plotInstance;s.leftup&&s.rightdown&&(n=this.Cesium.Cartesian3.midpoint(s.leftup,s.rightdown,new this.Cesium.Cartesian3))}catch(s){console.warn("plotInstance.syncFromEntity failed",s)}if(!n){if(e.positions&&e.positions.length)n=this.calculateCenter(e.positions);else if(t.position&&t.position.getValue)n=t.position.getValue();else if(t.polyline&&t.polyline.positions&&t.polyline.positions.getValue){const s=t.polyline.positions.getValue();n=this.calculateCenter(s)}else if(t.polygon&&t.polygon.hierarchy&&t.polygon.hierarchy.getValue){const s=t.polygon.hierarchy.getValue().positions;n=this.calculateCenter(s)}else if(t.rectangle&&t.rectangle.coordinates&&t.rectangle.coordinates.getValue)try{const s=t.rectangle.coordinates.getValue(),o=(s.west+s.east)/2,r=(s.south+s.north)/2;n=this.Cesium.Cartesian3.fromRadians(o,r,0)}catch{}}n&&(this.centerHandle=this.viewer.entities.add({position:n,point:{pixelSize:10,color:this.Cesium.Color.WHITE,outlineColor:this.Cesium.Color.BLUE,outlineWidth:2}}),this.addDragHandler(e,n))}calculateCenter(e){if(!e||e.length===0)return null;const t=e.map(r=>r);let n=0,s=0,o=0;for(let r=0;r<t.length;r++)n+=t[r].x,s+=t[r].y,o+=t[r].z;return new this.Cesium.Cartesian3(n/t.length,s/t.length,o/t.length)}getEntityPositions(e){const t=e.getEntity();if(e.positions&&Array.isArray(e.positions))return e.positions.slice();if(t.polyline&&t.polyline.positions&&t.polyline.positions.getValue){const n=t.polyline.positions.getValue();return Array.isArray(n)?n.slice():[]}if(t.polygon&&t.polygon.hierarchy&&t.polygon.hierarchy.getValue){const n=t.polygon.hierarchy.getValue();return n&&n.positions?n.positions.slice():[]}if(t.position&&t.position.getValue)return[t.position.getValue()];if(t.rectangle&&t.rectangle.coordinates&&t.rectangle.coordinates.getValue){const n=t.rectangle.coordinates.getValue();return[this.Cesium.Cartesian3.fromDegrees(n.west,n.south),this.Cesium.Cartesian3.fromDegrees(n.east,n.south),this.Cesium.Cartesian3.fromDegrees(n.east,n.north),this.Cesium.Cartesian3.fromDegrees(n.west,n.north)]}return[]}addDragHandler(e,t){if(console.log("移动线段"),this._dragHandler){try{this._dragHandler.destroy()}catch{}this._dragHandler=null}let n=!1,s,o=0;const r=16,l=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);this._dragHandler=l;const a=d=>{let h;try{h=this.viewer.scene.pickPosition(d)}catch{}if(!this.Cesium.defined(h)){const p=this.viewer.camera.getPickRay(d);p&&(h=this.viewer.scene.globe.pick(p,this.viewer.scene))}return this.Cesium.defined(h)||(h=this.viewer.scene.camera.pickEllipsoid(d,this.viewer.scene.globe.ellipsoid)),h};l.setInputAction(d=>{let h=!1;const p=this.viewer.scene.drillPick(d.position)||[];for(let f=0;f<p.length;f++){const u=p[f].id;if(u&&u===this.centerHandle){h=!0;break}}if(h){n=!0;const f=a(d.position);this.Cesium.defined(f)&&(s=f.clone()),o=performance.now(),this.viewer.scene.screenSpaceCameraController.enableRotate=!1,this.viewer.scene.screenSpaceCameraController.enableTranslate=!1,this.viewer.scene.screenSpaceCameraController.enableZoom=!1,this.viewer.scene.screenSpaceCameraController.enableTilt=!1,this.viewer.scene.screenSpaceCameraController.enableLook=!1}},this.Cesium.ScreenSpaceEventType.LEFT_DOWN),l.setInputAction(d=>{if(!n||!this.Cesium.defined(s))return;const h=performance.now();if(h-o<r)return;o=h;const p=a(d.endPosition);if(!this.Cesium.defined(p))return;const f=this.Cesium.Cartesian3.subtract(p,s,new this.Cesium.Cartesian3);if(this.centerHandle&&this.centerHandle.position&&this.centerHandle.position.setValue){const u=this.centerHandle.position.getValue(this.Cesium.JulianDate.now());if(u){const m=this.Cesium.Cartesian3.add(u,f,new this.Cesium.Cartesian3);this.centerHandle.position.setValue(m)}}this.moveEntity(e,f);try{this.viewer.scene.requestRender()}catch{}s=p.clone()},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE),l.setInputAction(()=>{if(n){n=!1,this.viewer.scene.screenSpaceCameraController.enableRotate=!0,this.viewer.scene.screenSpaceCameraController.enableTranslate=!0,this.viewer.scene.screenSpaceCameraController.enableZoom=!0,this.viewer.scene.screenSpaceCameraController.enableTilt=!0,this.viewer.scene.screenSpaceCameraController.enableLook=!0;const d=e.getEntity();if(d.state="done",d&&d.rectangle&&d.rectangle.coordinates)try{const h=d.rectangle.coordinates.getValue?d.rectangle.coordinates.getValue():d.rectangle.coordinates;h&&d.rectangle.coordinates.setValue(h)}catch(h){console.warn("Failed to refresh rectangle coordinates",h)}e&&this.selectedEntityObj!==e&&this.showEntityOutline(e)}},this.Cesium.ScreenSpaceEventType.LEFT_UP)}moveEntity(e,t){const n=e.getEntity();if(!n)return;const s=o=>this.Cesium.Cartesian3.add(o,t,new this.Cesium.Cartesian3);if(n.position){const o=n.position.getValue?n.position.getValue():n.position,r=s(o);n.position.setValue?n.position.setValue(r):n.position=r,n.state="moving",e.positions&&e.positions.length===1&&(e.positions[0]=r);return}if(n.polyline){if(n._plotInstance&&n._plotInstance.type==="rectangle"&&typeof n._plotInstance.updatePositions=="function")try{const l=new this.Cesium.Cartesian3(t.x,t.y,t.z);if(n._plotInstance.updatePositions([l]))return}catch(l){console.warn("Failed to update rectangle positions:",l)}if(n._plotInstance&&n._plotInstance.type==="circle"&&typeof n._plotInstance.updatePositions=="function")try{const l=new this.Cesium.Cartesian3(t.x,t.y,t.z);if(n._plotInstance.updatePositions([l]))return}catch(l){console.warn("Failed to update circle positions:",l)}const r=(e.positions&&Array.isArray(e.positions)?e.positions:n.polyline.positions.getValue?n.polyline.positions.getValue():[]).map(l=>s(l));if(e.updatePositions&&typeof e.updatePositions=="function")e.updatePositions(r);else if(e.positions&&Array.isArray(e.positions)&&(e.positions=r),n.polyline&&n.polyline.positions)try{n.polyline.positions instanceof this.Cesium.CallbackProperty||(n.polyline.positions=r)}catch{n.polyline.positions=r}}}startFreehandLine(e={}){this.initDrawTool();const t=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"freehandLine",style:Object.assign({color:this.currentColor,width:this.currentWidth,clampToGround:!t,smoothness:2,minDistance:.01,angleThreshold:.8,renderInterval:16,curveResolution:3},e)})}startArrow(e={}){this.initDrawTool();const t=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"arrow",style:Object.assign({color:this.currentColor,width:this.currentWidth,clampToGround:!t},e)})}startStraightLine(e={}){this.initDrawTool();const t=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"polyline",style:Object.assign({color:this.currentColor,width:this.currentWidth,clampToGround:!t},e)})}startEllipse(e={}){this.initDrawTool();const t=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"circle",style:Object.assign({color:this.currentColor.withAlpha(1),outlineColor:this.currentColor,outlineWidth:this.currentWidth,outline:!0,fill:!1,clampToGround:!t},e)})}startImage(e,t){this.initDrawTool();const n=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"billboard",style:Object.assign({image:e,width:t&&t.width?t.width:50,height:t&&t.height?t.height:50,clampToGround:!n},t)})}startRectangle(e={}){this.initDrawTool();const t=this.viewer.scene.mode===this.Cesium.SceneMode.SCENE2D;return this.drawTool.start({type:"rectangle",style:Object.assign({color:this.currentColor.withAlpha(1),outlineColor:this.currentColor,outlineWidth:this.currentWidth,clampToGround:!t},e)})}clearAll(){this.drawTool&&this.drawTool.removeAll(),this.hideEntityOutline()}destroy(){this.clearAll(),this.originalDoubleClickAction&&(this.viewer.screenSpaceEventHandler.setInputAction(this.originalDoubleClickAction,this.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.originalDoubleClickAction=null)}getAllEntities(){return this.drawTool&&typeof this.drawTool.getEntityObjArr=="function"?this.drawTool.getEntityObjArr():[]}saveAnnotations(){try{const e=this.getAllEntities(),t={freehand:[],arrow:[],text:[],image:[],polyline:[],rectangle:[],ellipse:[],other:[]};e.forEach(o=>{if(o&&typeof o=="object"){const r=o.type||o.constructor&&o.constructor.name,l={type:r,style:{}};switch(!0){case["freehandLine","CreateFreehandLine","polyline","CreatePolyline","arrow","CreateArrow"].includes(r):l.id=o.objId||o.id||Date.now().toString(),o.style&&(l.style={color:o.style.color,width:o.style.width,opacity:o.style.opacity,...o.style}),o.positions&&Array.isArray(o.positions)&&(l.positions=o.positions.map(a=>a&&typeof a=="object"&&a.x!==void 0&&a.y!==void 0&&a.z!==void 0?{x:a.x,y:a.y,z:a.z}:a)),["freehandLine","CreateFreehandLine"].includes(r)&&(l.isEdit=o.isEdit!==void 0?o.isEdit:!0,l.isFreehand=!0);break;case["rectangle","CreateRectangle"].includes(r):try{l.id=o.objId||o.id||Date.now().toString();let a=[];if(o.positions&&Array.isArray(o.positions)&&o.positions.length)a=o.positions.map(d=>({x:d.x,y:d.y,z:d.z}));else{const d=o.getEntity?o.getEntity():o;if(d)try{if(d.polyline&&d.polyline.positions&&d.polyline.positions.getValue){const h=d.polyline.positions.getValue(this.viewer.clock.currentTime);Array.isArray(h)&&(a=h.map(p=>({x:p.x,y:p.y,z:p.z})))}else if(d.rectangle&&d.rectangle.coordinates&&d.rectangle.coordinates.getValue){const h=d.rectangle.coordinates.getValue(this.viewer.clock.currentTime);a=[{west:h.west,south:h.south,east:h.east,north:h.north}]}}catch{}}o.style&&(l.style=Object.assign({},o.style)),a&&a.length&&(l.positions=a)}catch{}break;case["ellipse","CreateEllipse","circle","CreateCircle"].includes(r):try{l.id=o.objId||o.id||Date.now().toString();let a=[];const d=o.getEntity?o.getEntity():o;if(d&&d._plotInstance&&d._plotInstance.type==="circle"&&d._plotInstance.center&&d._plotInstance.radiusPoint){const h=d._plotInstance;a=[{x:h.center.x,y:h.center.y,z:h.center.z},{x:h.radiusPoint.x,y:h.radiusPoint.y,z:h.radiusPoint.z}]}else if(o.positions&&Array.isArray(o.positions)&&o.positions.length)a=o.positions.map(h=>({x:h.x,y:h.y,z:h.z}));else if(d)try{if(d.polyline&&d.polyline.positions&&d.polyline.positions.getValue){const h=d.polyline.positions.getValue(this.viewer.clock.currentTime);Array.isArray(h)&&(a=h.map(p=>({x:p.x,y:p.y,z:p.z})))}else if(d.ellipse&&d.ellipse.center&&d.ellipse.center.getValue&&d.ellipse.semiMajorAxis&&d.ellipse.semiMajorAxis.getValue){const h=d.ellipse.center.getValue(this.viewer.clock.currentTime),p=d.ellipse.semiMajorAxis.getValue(this.viewer.clock.currentTime);if(h&&p){const f={x:h.x,y:h.y,z:h.z||0},u={x:f.x+p,y:f.y,z:f.z};a=[f,u]}}}catch{}o.style&&(l.style=Object.assign({},o.style)),a&&a.length&&(l.positions=a)}catch{}break;case["label","CreateLabel"].includes(r):if(o.style)l.style=Object.assign({},o.style);else try{const a=o.getEntity?o.getEntity():o;if(a&&a.label){const d={};try{const h=a.label.fillColor&&a.label.fillColor.getValue?a.label.fillColor.getValue(this.viewer.clock.currentTime):a.label.fillColor;h&&(d.color=h)}catch{}a.label.font&&(d.font=a.label.font),l.style=d}}catch{}if(o.text)l.text=o.text;else try{const a=o.getEntity?o.getEntity():o;if(a&&a.label&&a.label.text){const d=a.label.text.getValue?a.label.text.getValue(this.viewer.clock.currentTime):a.label.text;d&&(l.text=d)}}catch{}if(o.position)l.position=o.position;else try{const a=o.getEntity?o.getEntity():o;if(a&&a.position&&a.position.getValue){const d=a.position.getValue(this.viewer.clock.currentTime);d&&(l.position={x:d.x,y:d.y,z:d.z})}}catch{}break;case["billboard","CreateBillboard"].includes(r):if(o.style)l.style=Object.assign({},o.style);else try{const a=o.getEntity?o.getEntity():o;if(a&&a.billboard){const d={};try{const h=a.billboard.image&&a.billboard.image.getValue?a.billboard.image.getValue(this.viewer.clock.currentTime):a.billboard.image;if(h){if(typeof h=="string")d.image=h;else if(h&&h.src)try{const p=h;if(typeof document<"u"&&p instanceof HTMLImageElement){const f=document.createElement("canvas");f.width=p.naturalWidth||p.width||1,f.height=p.naturalHeight||p.height||1;const u=f.getContext("2d");u?(u.drawImage(p,0,0),d.image=f.toDataURL()):d.image=p.src}else d.image=h.src}catch{d.image=h.src}}}catch{}a.billboard.width&&(d.width=a.billboard.width),a.billboard.height&&(d.height=a.billboard.height),l.style=d}}catch{}if(o.position)l.position=o.position;else try{const a=o.getEntity?o.getEntity():o;if(a&&a.position&&a.position.getValue){const d=a.position.getValue(this.viewer.clock.currentTime);d&&(l.position={x:d.x,y:d.y,z:d.z})}}catch{}break;default:o.style&&(l.style=o.style),o.position&&(l.position=o.position);break}switch(!0){case["freehandLine","CreateFreehandLine"].includes(r):t.freehand.push(l);break;case["arrow","CreateArrow"].includes(r):t.arrow.push(l);break;case["label","CreateLabel"].includes(r):t.text.push(l);break;case["billboard","CreateBillboard"].includes(r):t.image.push(l);break;case["polyline","CreatePolyline"].includes(r):t.polyline.push(l);break;case["rectangle","CreateRectangle"].includes(r):t.rectangle.push(l);break;case["ellipse","CreateEllipse","circle","CreateCircle"].includes(r):t.ellipse.push(l);break;default:t.other.push(l)}}});const n={version:"1.0",exportTime:new Date().toISOString(),totalEntities:e.length,annotations:t},s=JSON.stringify(n);return console.log("标注数据已按类型分类保存,只包含重绘所需信息:",s),s}catch(e){return console.error("保存标注失败:",e),!1}}loadAnnotations(e){try{const t=typeof e=="string"?JSON.parse(e):e;if(!t.annotations)return console.error("标注数据格式错误,缺少annotations字段"),!1;const n=t.annotations;let s=0;const o=(r,l)=>{Array.isArray(r)&&r.forEach(a=>{if(a.style){if(a.style.color&&typeof a.style.color=="object"){const d=a.style.color;a.style.color=`rgba(${Math.round(d.red*255)}, ${Math.round(d.green*255)}, ${Math.round(d.blue*255)}, ${d.alpha||1})`}if(a.style.outlineColor&&typeof a.style.outlineColor=="object"){const d=a.style.outlineColor;a.style.outlineColor=`rgba(${Math.round(d.red*255)}, ${Math.round(d.green*255)}, ${Math.round(d.blue*255)}, ${d.alpha||1})`}}switch(l){case"freehand":case"polyline":case"arrow":if(a.positions&&a.positions.length>0){const d=a.positions.map(f=>f&&typeof f=="object"?new this.Cesium.Cartesian3(f.x,f.y,f.z):f),h={type:l==="freehand"?"freehandLine":l,style:a.style||{},positions:d,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))},p=this.drawTool.createByPositions(h);if(p&&p.getEntity()){s++,p.isEdit=!0;const f=p.getEntity();f&&!f._plotInstance&&(f._plotInstance=p),f&&!f.objId&&(f.objId=p.objId),console.log(`Loaded ${l} entity with objId: ${p.objId}`)}}break;case"rectangle":{try{if(a.positions&&a.positions.length){let d=[];if(a.positions[0]&&a.positions[0].x!==void 0)d=a.positions.map(h=>new this.Cesium.Cartesian3(h.x,h.y,h.z!==void 0?h.z:0));else if(a.positions[0]&&a.positions[0].west!==void 0){const h=a.positions[0];d=[this.Cesium.Cartesian3.fromRadians(h.west,h.south),this.Cesium.Cartesian3.fromRadians(h.east,h.south),this.Cesium.Cartesian3.fromRadians(h.east,h.north),this.Cesium.Cartesian3.fromRadians(h.west,h.north),this.Cesium.Cartesian3.fromRadians(h.west,h.south)]}if(d.length){const h=JSON.parse(JSON.stringify(a.style||{}));if(h.color&&typeof h.color=="string"&&!h.color.startsWith("rgba"))try{const u=JSON.parse(h.color);u.red!==void 0&&(h.color=`rgba(${Math.round(u.red*255)}, ${Math.round(u.green*255)}, ${Math.round(u.blue*255)}, ${u.alpha||1})`)}catch{}const p={type:"rectangle",positions:d,style:h,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let f=null;try{f=this.drawTool.createByPositions(p)}catch(u){console.warn("drawTool.createByPositions(rectangle) failed",u)}if(f){s++,f.isEdit=!0;const u=f.getEntity?f.getEntity():f.entity||f;u&&(u._plotInstance=f,u.objId=f.objId||a.id,u.pickable=!0,u.polyline&&(u.polyline.pickWidth=10),console.log(`Loaded rectangle entity with objId: ${u.objId}, color: ${h.color}`))}}}}catch(d){console.warn("load rectangle failed",d)}break}case"text":if(a.position){const d=a.text||"文字标注",h={type:"label",style:a.style||{},text:d,position:new this.Cesium.Cartesian3(a.position.x,a.position.y,a.position.z||0)};h.style.fontSize||(h.style.fontSize=14),h.style.fontFamily||(h.style.fontFamily="Arial");let p;try{!h.positions&&h.position&&(h.positions=h.position),p=this.drawTool.createByPositions(h),!p&&this.drawTool.startText&&(console.log("使用startText创建文字"),this.drawTool.startText(h.style),this.drawTool.currentEntity&&(this.drawTool.currentEntity.text=d,this.drawTool.currentEntity.position=h.position,p=this.drawTool.currentEntity))}catch(f){console.log("创建文字失败",f)}if(!p)try{const f=this.viewer.entities.add({position:h.position,label:Object.assign({text:d,font:h.style&&h.style.font||"14pt Source Han Sans CN",fillColor:h.style&&h.style.fillColor||this.Cesium.Color.WHITE,outlineColor:h.style&&h.style.outlineColor||this.Cesium.Color.BLACK,outlineWidth:h.style&&h.style.outlineWidth||2,verticalOrigin:h.style&&h.style.verticalOrigin||this.Cesium.VerticalOrigin.BOTTOM,pixelOffset:h.style&&h.style.pixelOffset||new this.Cesium.Cartesian2(0,-10)},h.style&&h.style.label?h.style.label:{})}),u={getEntity:()=>f,entity:f,style:h.style||{},type:"label",objId:a.id||`label_${Date.now()}_${Math.random().toFixed(3)}`,isEdit:!0,destroy:()=>this.viewer.entities.remove(f)};try{f.objId=u.objId}catch{}this.drawTool&&(this.drawTool.entityObjArr||(this.drawTool.entityObjArr=[]),this.drawTool.entityObjArr.push(u)),p=u}catch(f){console.warn("回退创建文字实体失败",f)}p&&(s++,p.isEdit=!0)}break;case"image":if(a.position){const d={type:"billboard",style:a.style||{},position:new this.Cesium.Cartesian3(a.position.x,a.position.y,a.position.z||0)};d.style.image||(console.log("使用默认图片占位符"),d.style.image="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgdmlld0JveD0iMCAwIDUwIDUwIj48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNlNTMyMzIiLz48L3N2Zz4="),d.style.width||(d.style.width=50),d.style.height||(d.style.height=50);let h;try{!d.positions&&d.position&&(d.positions=d.position),h=this.drawTool.createByPositions(d),!h&&this.drawTool.startImage&&(console.log("使用startImage创建图片"),this.drawTool.startImage(d.style.image,d.style),this.drawTool.currentEntity&&(this.drawTool.currentEntity.position=d.position,h=this.drawTool.currentEntity))}catch(p){console.log("创建图片失败",p)}if(!h)try{const p=d.style&&d.style.image?d.style.image:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgdmlld0JveD0iMCAwIDUwIDUwIj48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNlNTMyMzIiLz48L3N2Zz4=",f=this.viewer.entities.add({position:d.position,billboard:{image:p,width:d.style&&d.style.width?d.style.width:50,height:d.style&&d.style.height?d.style.height:50,verticalOrigin:d.style&&d.style.verticalOrigin||this.Cesium.VerticalOrigin.CENTER,scale:d.style&&d.style.scale||1}}),u={getEntity:()=>f,entity:f,style:d.style||{},type:"billboard",objId:a.id||`billboard_${Date.now()}_${Math.random().toFixed(3)}`,isEdit:!0,destroy:()=>this.viewer.entities.remove(f)};try{f.objId=u.objId}catch{}this.drawTool&&(this.drawTool.entityObjArr||(this.drawTool.entityObjArr=[]),this.drawTool.entityObjArr.push(u)),h=u}catch(p){console.warn("回退创建图片实体失败",p)}h&&(s++,h.isEdit=!0)}break;case"ellipse":case"circle":{try{const d=JSON.parse(JSON.stringify(a.style||{}));if(d.color&&typeof d.color=="string"&&!d.color.startsWith("rgba"))try{const f=JSON.parse(d.color);f.red!==void 0&&(d.color=`rgba(${Math.round(f.red*255)}, ${Math.round(f.green*255)}, ${Math.round(f.blue*255)}, ${f.alpha||1})`)}catch{}let h=[],p=!1;if(a.positions&&a.positions.length&&(a.positions[0]&&a.positions[0].x!==void 0&&(h=a.positions.map(f=>new this.Cesium.Cartesian3(f.x,f.y,f.z!==void 0?f.z:0))),h.length)){const f={type:l,positions:h,style:d,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let u=null;try{if(u=this.drawTool.createByPositions(f),u){s++,u.isEdit=!0;const m=u.getEntity?u.getEntity():u.entity||u;m&&(m._plotInstance=u,m.objId=u.objId||a.id,m.pickable=!0,m.polyline&&(m.polyline.pickWidth=10),console.log(`Loaded ${l} entity with objId: ${m.objId} using positions`)),p=!0}}catch(m){console.warn(`drawTool.createByPositions(${l}) failed`,m)}}if(!p&&a.center&&a.radius)try{const f=new this.Cesium.Cartesian3(a.center.x,a.center.y,a.center.z||0),u=this.Cesium.Cartesian3.add(f,new this.Cesium.Cartesian3(a.radius,0,0),new this.Cesium.Cartesian3),E={type:l,positions:[f,u],style:d,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let A=null;try{if(A=this.drawTool.createByPositions(E),A){s++,A.isEdit=!0;const y=A.getEntity?A.getEntity():A.entity||A;y&&(y._plotInstance=A,y.objId=A.objId||a.id,y.pickable=!0,y.polyline&&(y.polyline.pickWidth=10),console.log(`Loaded ${l} entity with objId: ${y.objId} using center and radius`))}}catch(y){console.warn(`drawTool.createByPositions(${l}) with center/radius failed`,y)}}catch(f){console.warn(`Fallback creation for ${l} failed`,f)}}catch(d){console.warn(`load ${l} failed`,d)}break}default:console.log(`尝试加载未知类型实体: ${l}`);break}})};return Object.keys(n).forEach(r=>{o(n[r],r)}),console.log(`成功加载 ${s} 个标注实体`),this.drawTool&&typeof this.drawTool.bindEdit=="function"&&this.drawTool.bindEdit(),!0}catch(t){return console.error("加载标注失败:",t),!1}}changeEntityColor(e){try{if(!this.selectedEntityObj)return!1;if(this.selectedEntityObj.setStyle&&typeof this.selectedEntityObj.setStyle=="function")try{return this.selectedEntityObj.setStyle({color:e}),console.log("通过实体对象的setStyle方法修改颜色成功"),!0}catch(s){console.warn("通过setStyle修改颜色失败,尝试直接修改实体:",s)}const t=this.selectedEntityObj.getEntity();if(!t)return!1;let n;try{n=this.Cesium.Color.fromCssColorString(e)}catch(s){console.warn("Invalid color format:",e,s),n=e}if(t.polyline)try{t.polyline.material=new this.Cesium.ColorMaterialProperty(n)}catch{t.polyline.material=n}else if(t.polygon)try{t.polygon.material=new this.Cesium.ColorMaterialProperty(n)}catch{t.polygon.material=n}else if(t.rectangle){const s=t.rectangle.outline,o=t.rectangle.outlineWidth;try{t.rectangle.material=new this.Cesium.ColorMaterialProperty(n)}catch{t.rectangle.material=n}t.rectangle.outlineColor=n,s!==void 0&&(t.rectangle.outline=s),o!==void 0&&(t.rectangle.outlineWidth=o)}else if(t.ellipse||t.circle){const s=t.ellipse||t.circle,o=s.outline,r=s.outlineColor,l=s.outlineWidth;s.material=n,o!==void 0&&(s.outline=o),r!==void 0&&(s.outlineColor=r),l!==void 0&&(s.outlineWidth=l)}return!0}catch(t){return console.error("changeEntityColor failed",t),!1}}changeColor(e){return this.changeEntityColor(e)}setLineWidth(e){if(!this.selectedEntityObj)return!1;const t=this.selectedEntityObj.getEntity();let n=2;if(typeof e=="number")n=e;else switch(e){case"thin":n=2;break;case"medium":n=4;break;case"thick":n=8;break}if(t.polyline)t.polyline.width=n;else if(t.polygon&&t.polygon.outline)t.polygon.outlineWidth=n;else if(t.rectangle&&t.rectangle.outline)t.rectangle.outlineWidth=n;else if((t.ellipse||t.circle)&&(t.ellipse?.outline||t.circle?.outline)){const s=t.ellipse||t.circle;s.outlineWidth=n}return!0}changeWidth(e){return this.setLineWidth(e)}deleteSelectedEntity(){if(!this.selectedEntityObj)return!1;if(typeof this.drawTool.removeOne=="function")this.drawTool.removeOne(this.selectedEntityObj);else if(typeof this.drawTool.remove=="function")this.drawTool.remove(this.selectedEntityObj);else return console.error("No remove method found on drawTool"),!1;return this.selectedEntityObj=null,this.hideEntityOutline(),!0}}class tl{viewer;cesium;handler=null;measureEntities=[];originalDoubleClickAction=null;onMeasure=()=>{};activePoints=[];floatingPoint=null;activeShape=null;type=null;unit="m";cursorPosition=null;isSnapping=!1;snapIndicator=null;constructor({viewer:e,cesium:t}){this.viewer=e,this.cesium=t;const n=this.cesium;this.originalDoubleClickAction=this.viewer.screenSpaceEventHandler.getInputAction(n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.viewer.screenSpaceEventHandler.removeInputAction(n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}setUnit(e){this.unit=e}setSnapping(e){this.isSnapping=e,!e&&this.snapIndicator&&(this.viewer.entities.remove(this.snapIndicator),this.snapIndicator=null)}start(e){const t=this.cesium;this.clearActive(),this.type=e,this.handler=new t.ScreenSpaceEventHandler(this.viewer.scene.canvas),this.handler.setInputAction(n=>{const s=this.getPickPosition(n.position);s&&this.addPoint(s)},t.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{const s=this.getPickPosition(n.endPosition);s&&(this.cursorPosition=s,this.updateFloatingPoint(s))},t.ScreenSpaceEventType.MOUSE_MOVE),this.type==="area"&&this.handler.setInputAction(()=>{this.finish()},t.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}addPoint(e){const t=this.cesium;this.activePoints.push(e);const n=this.viewer.entities.add({position:e,point:{pixelSize:8,color:t.Color.YELLOW,outlineColor:t.Color.BLACK,outlineWidth:2,disableDepthTestDistance:Number.POSITIVE_INFINITY}});if(this.measureEntities.push(n),this.type==="distance"){if(this.activePoints.length===1)this.onMeasure(null),this.activeShape=this.viewer.entities.add({polyline:{positions:new t.CallbackProperty(()=>{if(this.activePoints.length===0)return[];const s=[...this.activePoints];return this.cursorPosition&&s.push(this.cursorPosition),s},!1),width:2,material:t.Color.YELLOW,depthFailMaterial:t.Color.YELLOW}}),this.measureEntities.push(this.activeShape);else if(this.activePoints.length===2){const s=this.activePoints[0],o=this.activePoints[1];this.activeShape&&(this.viewer.entities.remove(this.activeShape),this.activeShape=null);const r=this.viewer.entities.add({polyline:{positions:[s,o],width:2,material:t.Color.YELLOW,depthFailMaterial:t.Color.YELLOW}});this.measureEntities.push(r);const l=t.Cartesian3.distance(s,o),a=t.Cartesian3.midpoint(s,o,new t.Cartesian3);this.addLabel(a,this.formatDistance(l));const d=t.Transforms.eastNorthUpToFixedFrame(s),h=t.Matrix4.inverse(d,new t.Matrix4),p=t.Matrix4.multiplyByPoint(h,o,new t.Cartesian3),f=p.x,u=p.y,m=p.z,E=t.Matrix4.getColumn(d,0,new t.Cartesian3),A=t.Matrix4.getColumn(d,1,new t.Cartesian3),y=t.Cartesian3.multiplyByScalar(E,f,new t.Cartesian3),v=t.Cartesian3.add(s,y,new t.Cartesian3),S=t.Cartesian3.multiplyByScalar(A,u,new t.Cartesian3),M=t.Cartesian3.add(v,S,new t.Cartesian3);if(this.viewer.scene.mode!==t.SceneMode.SCENE2D){const O=this.viewer.entities.add({polyline:{positions:[s,v],width:2,material:new t.PolylineDashMaterialProperty({color:t.Color.RED}),depthFailMaterial:new t.PolylineDashMaterialProperty({color:new t.Color(1,0,0,.5)})}}),I=this.viewer.entities.add({polyline:{positions:[v,M],width:2,material:new t.PolylineDashMaterialProperty({color:t.Color.GREEN}),depthFailMaterial:new t.PolylineDashMaterialProperty({color:new t.Color(0,1,0,.5)})}}),B=this.viewer.entities.add({polyline:{positions:[M,o],width:2,material:new t.PolylineDashMaterialProperty({color:t.Color.BLUE}),depthFailMaterial:new t.PolylineDashMaterialProperty({color:new t.Color(0,0,1,.5)})}});this.measureEntities.push(O,I,B)}this.onMeasure({type:"distance",dx:f,dy:u,dz:m,dist:l}),this.activePoints=[]}}else if(this.type==="angle"){if(this.activePoints.length===1)this.onMeasure(null);else if(this.activePoints.length===2)this.activeShape=this.viewer.entities.add({polyline:{positions:new t.CallbackProperty(()=>{if(this.activePoints.length<2)return[];const s=[...this.activePoints];return this.cursorPosition&&s.push(this.cursorPosition),s},!1),width:2,material:t.Color.YELLOW,depthFailMaterial:t.Color.YELLOW}}),this.measureEntities.push(this.activeShape);else if(this.activePoints.length===3){const s=this.activePoints[0],o=this.activePoints[1],r=this.activePoints[2];if(this.activeShape){this.viewer.entities.remove(this.activeShape);const a=this.viewer.entities.add({polyline:{positions:[s,o,r],width:2,material:t.Color.YELLOW,depthFailMaterial:t.Color.YELLOW}});this.measureEntities.push(a)}const l=this.calculateAngle(s,o,r);this.addLabel(o,`${l.toFixed(1)}°`),this.onMeasure({type:"angle",angle:l}),this.finish()}}else this.type==="area"&&this.activePoints.length===1&&(this.onMeasure(null),this.activeShape=this.viewer.entities.add({polygon:{hierarchy:new t.CallbackProperty(()=>{if(this.activePoints.length===0)return new t.PolygonHierarchy([]);const s=[...this.activePoints];return this.cursorPosition&&s.push(this.cursorPosition),new t.PolygonHierarchy(s)},!1),material:t.Color.YELLOW.withAlpha(.3),perPositionHeight:!0,outline:!0,outlineColor:t.Color.YELLOW,outlineWidth:2},polyline:{positions:new t.CallbackProperty(()=>{const s=[...this.activePoints];return this.cursorPosition&&(s.push(this.cursorPosition),s.push(s[0])),s},!1),width:2,material:t.Color.YELLOW,depthFailMaterial:t.Color.YELLOW,clampToGround:!1}}),this.measureEntities.push(this.activeShape))}updateFloatingPoint(e){const t=this.cesium;this.floatingPoint||(this.floatingPoint=this.viewer.entities.add({position:new t.CallbackProperty(()=>this.cursorPosition,!1),point:{pixelSize:5,color:t.Color.RED,disableDepthTestDistance:Number.POSITIVE_INFINITY}}))}finish(){const e=this.cesium;if(this.type==="distance"&&this.activePoints.length>1){let t=0;for(let s=0;s<this.activePoints.length-1;s++)t+=e.Cartesian3.distance(this.activePoints[s],this.activePoints[s+1]);const n=this.activePoints[this.activePoints.length-1];this.addLabel(n,`Total: ${this.formatDistance(t)}`)}else if(this.type==="area"&&this.activePoints.length>=3){const t=this.calculateArea(this.activePoints),n=this.calculateCenter(this.activePoints);this.addLabel(n,`面积: ${this.formatArea(t)}`),this.onMeasure({type:"area",area:t})}this.clearActive()}clearAll(){this.clear(),this.onMeasure(null)}clear(){this.clearActive(),this.measureEntities.forEach(e=>this.viewer.entities.remove(e)),this.measureEntities=[]}stop(){this.clearActive(),this.onMeasure(null)}destroy(){if(this.clear(),this.originalDoubleClickAction){const e=this.cesium;this.viewer.screenSpaceEventHandler.setInputAction(this.originalDoubleClickAction,e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.originalDoubleClickAction=null}}clearActive(){const e=this.cesium;if(this.handler&&(this.handler.destroy(),this.handler=null),this.floatingPoint&&(this.viewer.entities.remove(this.floatingPoint),this.floatingPoint=null),this.snapIndicator&&(this.viewer.entities.remove(this.snapIndicator),this.snapIndicator=null),this.activeShape){if(this.type==="distance"){const t=[...this.activePoints];this.viewer.entities.remove(this.activeShape);const n=this.viewer.entities.add({polyline:{positions:t,width:2,material:e.Color.YELLOW,depthFailMaterial:e.Color.YELLOW}});this.measureEntities.push(n)}else if(this.type==="area"){const t=[...this.activePoints];this.viewer.entities.remove(this.activeShape);const n=this.viewer.entities.add({polygon:{hierarchy:new e.PolygonHierarchy(t),material:e.Color.YELLOW.withAlpha(.3),perPositionHeight:!0,outline:!0,outlineColor:e.Color.YELLOW,outlineWidth:2},polyline:{positions:[...t,t[0]],width:2,material:e.Color.YELLOW,depthFailMaterial:e.Color.YELLOW}});this.measureEntities.push(n)}this.activeShape=null}this.activePoints=[],this.type=null,this.cursorPosition=null}getPickPosition(e){const t=this.cesium;let n;try{n=this.viewer.scene.pickPosition(e)}catch{}if(!n||!t.defined(n)){const s=this.viewer.camera.getPickRay(e);s&&(n=this.viewer.scene.globe.pick(s,this.viewer.scene))}if((!n||!t.defined(n))&&(n=this.viewer.scene.camera.pickEllipsoid(e,this.viewer.scene.globe.ellipsoid)),!n||!t.defined(n))return null;if(this.isSnapping){const s=this.snapToVertex(e);if(s)n=s;else{const o=this.snapTo3DTileFeature(e);o&&(n=o)}}return this.isSnapping&&(this.snapIndicator||(this.snapIndicator=this.viewer.entities.add({position:new t.CallbackProperty(()=>this.cursorPosition,!1),point:{pixelSize:10,color:t.Color.GREEN.withAlpha(.5),outlineColor:t.Color.GREEN,outlineWidth:2,disableDepthTestDistance:Number.POSITIVE_INFINITY}}))),n}snapTo3DTileFeature(e){const t=this.cesium,n=10,s=[{x:0,y:0},{x:-n,y:0},{x:n,y:0},{x:0,y:-n},{x:0,y:n},{x:-n,y:-n},{x:n,y:-n},{x:-n,y:n},{x:n,y:n}];for(let o=0;o<s.length;o++){const r=s[o];if(!r)continue;const l=new t.Cartesian2(e.x+r.x,e.y+r.y);let a=null;try{a=this.viewer.scene.pick(l)}catch{}if(t.defined(a)&&(a instanceof t.Cesium3DTileFeature||a.primitive&&a.primitive instanceof t.PointPrimitive))try{const d=this.viewer.scene.pickPosition(l);if(d)return d}catch{}}return null}snapToVertex(e){const t=this.cesium,n=this.viewer.entities.values;let s=20,o=null;for(let r=0;r<n.length;r++){const l=n[r];if(!l.show)continue;let a=[];if(l.polyline&&l.polyline.positions){const d=l.polyline.positions.getValue(t.JulianDate.now());d&&(a=d)}else if(l.polygon&&l.polygon.hierarchy){const d=l.polygon.hierarchy.getValue(t.JulianDate.now());d&&d.positions&&(a=d.positions)}else if(l.position){const d=l.position.getValue(t.JulianDate.now());d&&(a=[d])}else if(l.rectangle&&l.rectangle.coordinates){const d=l.rectangle.coordinates.getValue(t.JulianDate.now());d&&(a=[t.Cartesian3.fromRadians(d.west,d.south),t.Cartesian3.fromRadians(d.east,d.south),t.Cartesian3.fromRadians(d.east,d.north),t.Cartesian3.fromRadians(d.west,d.north)])}for(let d=0;d<a.length;d++){const h=a[d];try{const p=this.viewer.scene.cartesianToCanvasCoordinates(h);if(p){const f=t.Cartesian2.distance(p,e);f<s&&(s=f,o=h)}}catch{}}}return o}addLabel(e,t){const n=this.cesium,s=this.viewer.entities.add({position:e,label:{text:t,font:"14px sans-serif",fillColor:n.Color.WHITE,style:n.LabelStyle.FILL_AND_OUTLINE,outlineWidth:2,verticalOrigin:n.VerticalOrigin.BOTTOM,pixelOffset:new n.Cartesian2(0,-10),disableDepthTestDistance:Number.POSITIVE_INFINITY,showBackground:!0,backgroundColor:new n.Color(0,0,0,.5)}});this.measureEntities.push(s)}formatDistance(e){return this.unit==="mm"?`${(e*1e3).toFixed(0)}mm`:this.unit==="cm"?`${(e*100).toFixed(1)}cm`:`${e.toFixed(2)}m`}calculateAngle(e,t,n){const s=this.cesium,o=s.Cartesian3.subtract(e,t,new s.Cartesian3),r=s.Cartesian3.subtract(n,t,new s.Cartesian3);s.Cartesian3.normalize(o,o),s.Cartesian3.normalize(r,r);const l=s.Cartesian3.dot(o,r),a=Math.max(-1,Math.min(1,l)),d=Math.acos(a);return s.Math.toDegrees(d)}calculateArea(e){const t=this.cesium;if(e.length<3)return 0;const n=e[0],s=new t.Cartesian3(0,0,0);for(let o=1;o<e.length-1;o++){const r=e[o],l=e[o+1],a=t.Cartesian3.subtract(r,n,new t.Cartesian3),d=t.Cartesian3.subtract(l,n,new t.Cartesian3),h=t.Cartesian3.cross(a,d,new t.Cartesian3);t.Cartesian3.add(s,h,s)}return t.Cartesian3.magnitude(s)*.5}calculateCenter(e){const t=this.cesium;if(!e||e.length===0)return null;let n=0,s=0,o=0;for(let r=0;r<e.length;r++)n+=e[r].x,s+=e[r].y,o+=e[r].z;return new t.Cartesian3(n/e.length,s/e.length,o/e.length)}formatArea(e){return e>1e6?`${(e/1e6).toFixed(2)} km²`:`${e.toFixed(2)} m²`}}class ly{cesium;viewer;events=new Gi;lastBaseMapRequestId=0;_removeCameraLockListener=null;currentMode="3d";defaultMapBound={minLon:-180,maxLon:180,minLat:-90,maxLat:90};constructor(e){this.cesium=e.cesium,this.viewer=e.viewer}get is2d(){return this.currentMode==="2d"}setGlobeEnvironmentVisible(e){if(this.is2d){this.viewer.scene.globe.show=e,this.viewer.scene.globe.showGroundAtmosphere=!1,this.viewer.scene.skyAtmosphere.show=!1,this.viewer.scene.sun.show=!1,this.viewer.scene.moon.show=!1,this.viewer.scene.skyBox.show=!1;return}const{scene:t}=this.viewer;t.globe&&(t.globe.show=e,t.globe.showGroundAtmosphere=e,e||(t.globe.depthTestAgainstTerrain=!1)),t.skyAtmosphere&&(t.skyAtmosphere.show=e),t.sun&&(t.sun.show=e),t.moon&&(t.moon.show=e),t.skyBox&&(t.skyBox.show=e)}setGlobeColor(e){const t=this.cesium.Color.fromCssColorString(e);t&&(this.viewer.scene.backgroundColor=t,this.viewer.scene.globe.baseColor=t)}setBackgroundColor(e){const t=this.viewer.container;t&&(t.style.background=e);try{const n=this.cesium.Color.fromCssColorString(e);n?(this.viewer.scene.backgroundColor=n,this.viewer.scene.globe.baseColor=n):(this.viewer.scene.backgroundColor=this.cesium.Color.TRANSPARENT,this.viewer.scene.globe.baseColor=this.cesium.Color.TRANSPARENT)}catch{this.viewer.scene.backgroundColor=this.cesium.Color.TRANSPARENT,this.viewer.scene.globe.baseColor=this.cesium.Color.TRANSPARENT}}async setTerrainEnable(e){if(!(this.is2d&&e))if(e)try{const t=this.cesium.ArcGISTiledElevationTerrainProvider.fromUrl("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"),n=new Promise((s,o)=>setTimeout(()=>o(new Error("ArcGIS Terrain request timed out")),5e3));this.viewer.terrainProvider=await Promise.race([t,n])}catch(t){console.warn("Failed to load ArcGIS terrain (or timed out), trying Cesium World Terrain...",t);try{this.cesium.Terrain&&this.cesium.Terrain.fromWorldTerrain?this.viewer.terrainProvider=await this.cesium.Terrain.fromWorldTerrain({requestWaterMask:!0,requestVertexNormals:!0}):this.viewer.terrainProvider=this.cesium.createWorldTerrain({requestWaterMask:!0,requestVertexNormals:!0})}catch(n){console.error("Failed to enable terrain (both ArcGIS and Ion failed):",n),this.viewer.terrainProvider=new this.cesium.EllipsoidTerrainProvider}}else this.viewer.terrainProvider=new this.cesium.EllipsoidTerrainProvider}setDepthTestEnable(e){if(!this.viewer.scene.globe.show){this.viewer.scene.globe.depthTestAgainstTerrain=!1;return}this.viewer.scene.globe.depthTestAgainstTerrain=e}setCadMode(e){this.currentMode!==e&&(this.currentMode=e,this.is2d?this._enable2DMode():this._enable3DMode())}_enable2DMode(){const e=this.cesium,t=this.viewer.scene;this.setGlobeEnvironmentVisible(!0);const n=t.screenSpaceCameraController;this.setBackgroundColor("#000000"),this.setGlobeColor("#000000"),this.viewer.imageryLayers.removeAll(),n.enableZoomInertia=!0,n.minimumZoomDistance=1,n.maximumZoomDistance=1e6,n.enableTilt=!1,n.enableLook=!1,n.enableCollisionDetection=!1,this.viewer.camera.setView({orientation:{heading:0,pitch:e.Math.toRadians(-90),roll:0}}),this._removeCameraLockListener&&(this._removeCameraLockListener(),this._removeCameraLockListener=null);const s=()=>{const o=this.viewer.camera,r=e.Math.EPSILON3,l=0,a=e.Math.toRadians(-90),d=0,h=Math.abs(o.heading-l);((h>Math.PI?Math.abs(h-2*Math.PI):h)>r||Math.abs(o.pitch-a)>r||Math.abs(o.roll-d)>r)&&o.setView({orientation:{heading:l,pitch:o.pitch,roll:d}})};this._removeCameraLockListener=this.viewer.scene.postRender.addEventListener(s),this.setCollisionDetection(!1),this.setHeightBasedZoom(!0)}_enable3DMode(){this._removeCameraLockListener&&(this._removeCameraLockListener(),this._removeCameraLockListener=null);const e=this.viewer.scene.screenSpaceCameraController;e.enableRotate=!0,e.enableTilt=!0,e.enableLook=!0,this.viewer.scene.morphTo3D(0),this.setMouseHabit(0),this.setCollisionDetection(!0),this.viewer.scene.screenSpaceCameraController.minimumZoomDistance=1,this.setHeightBasedZoom(!1)}async changeBaseMap(e,t){if(this.is2d){this.viewer.imageryLayers.removeAll();return}const n=Date.now();this.lastBaseMapRequestId=n;const s=this.viewer.imageryLayers,o=[];if(e==="tianditu"){const r=t?.token||"c25f14fb6bd4397cf8fe45144ff768d6",l=t?.layerType||"img_w",a=l.split("_"),d=a[0]||"img",h=a[1]||"w";let p="";d==="img"?p="cia":d==="vec"?p="cva":d==="ter"&&(p="cta");const f=p?`${p}_${h}`:"";o.push(new this.cesium.WebMapTileServiceImageryProvider({url:`https://{s}.tianditu.gov.cn/${l}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${d}&STYLE=default&TILEMATRIXSET=${h}&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=${r}`,layer:d,style:"default",format:"tiles",tileMatrixSetID:h,maximumLevel:18,subdomains:["t0","t1","t2","t3","t4","t5","t6","t7"]})),t.showAnnotation!==!1&&f&&o.push(new this.cesium.WebMapTileServiceImageryProvider({url:`https://{s}.tianditu.gov.cn/${f}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${p}&STYLE=default&TILEMATRIXSET=${h}&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=${r}`,layer:p,style:"default",format:"tiles",tileMatrixSetID:h,maximumLevel:18,subdomains:["t0","t1","t2","t3","t4","t5","t6","t7"]}))}else if(e==="arcgis"){console.log("Switching to ArcGIS...");const r=t?.url||"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer";try{if(this.cesium.ArcGisMapServerImageryProvider.fromUrl){const l=this.cesium.ArcGisMapServerImageryProvider.fromUrl(r,{enablePickFeatures:!1}),a=new Promise((h,p)=>setTimeout(()=>p(new Error("ArcGIS metadata request timed out")),3e3)),d=await Promise.race([l,a]);o.push(d)}else o.push(new this.cesium.ArcGisMapServerImageryProvider({url:r,enablePickFeatures:!1}))}catch(l){console.warn("ArcGIS provider failed (or timed out), fallback to XYZ template",l),o.push(new this.cesium.UrlTemplateImageryProvider({url:`${r}/tile/{z}/{y}/{x}`,maximumLevel:19,credit:"ArcGIS Layer"}))}}else if(e==="tianditu_img")return this.changeBaseMap("tianditu",{...t,layerType:"img_w"});if(this.lastBaseMapRequestId!==n){console.log("BaseMap switch cancelled due to new request.");return}s.removeAll(),o.forEach(r=>s.addImageryProvider(r))}async searchLocation(e,t){if(!e)return null;if(!t)throw new Error("缺少天地图 Token");const s=JSON.stringify({keyWord:e,level:12,mapBound:"-180,-90,180,90",queryType:1,start:0,count:10}),o=`https://api.tianditu.gov.cn/v2/search?postStr=${encodeURIComponent(s)}&type=query&tk=${encodeURIComponent(t)}`,r=await fetch(o);if(!r.ok)throw new Error(`HTTP ${r.status}`);return await r.json()}setShadowsEnable(e){this.is2d||(this.viewer.shadows=e,this.viewer.terrainShadows=e?this.cesium.ShadowMode.ENABLED:this.cesium.ShadowMode.DISABLED,this.viewer.shadowMap&&(this._shadowDarkness===void 0?this.viewer.shadowMap.darkness=e?.7:.3:this.viewer.shadowMap.darkness=this._shadowDarkness))}_shadowDarkness;setShadowDarkness(e){this.is2d||(this._shadowDarkness=e,this.viewer.shadowMap&&(this.viewer.shadowMap.darkness=e))}setTime(e){if(this.is2d)return;let t;if(e instanceof Date)t=e;else{const s=this.cesium.JulianDate.now();t=this.cesium.JulianDate.toDate(s),t.setHours(e),t.setMinutes(0),t.setSeconds(0)}const n=this.cesium.JulianDate.fromDate(t);this.viewer.clock.currentTime=n}setModelColorAdjustment(e){if(this.is2d)return;const t=this.viewer,n=this.cesium;if(!t||!t.scene)return;const s=e.brightness!==void 0?e.brightness:1,o=e.contrast!==void 0?e.contrast:1,r=e.saturation!==void 0?e.saturation:1,l=t.scene.primitives,a=l.length,d=!!n.CustomShader;for(let h=0;h<a;++h){const p=l.get(h);if(p instanceof n.Cesium3DTileset)if(d)if(p.customShader&&p.customShader.isModelAdjustment)e.brightness!==void 0&&p.customShader.setUniform("u_brightness",s),e.contrast!==void 0&&p.customShader.setUniform("u_contrast",o),e.saturation!==void 0&&p.customShader.setUniform("u_saturation",r);else{const f=new n.CustomShader({uniforms:{u_brightness:{type:n.UniformType.FLOAT,value:s},u_contrast:{type:n.UniformType.FLOAT,value:o},u_saturation:{type:n.UniformType.FLOAT,value:r}},fragmentShaderText:`
30
30
  void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {
31
31
  // 1. 亮度 (Brightness) - RGB 乘法
32
32
  material.diffuse *= u_brightness;
@@ -46,7 +46,7 @@
46
46
  // 通常不需要 clamp,除非开启 HDR 后期望超亮,但负值需要避免
47
47
  material.diffuse = max(material.diffuse, vec3(0.0));
48
48
  }
49
- `});f.isModelAdjustment=!0,p.customShader=f}else e.brightness!==void 0&&e.brightness!==1&&!p.style&&(p.style=new n.Cesium3DTileStyle({color:`color('white') * ${e.brightness}`}))}}setModelBrightness(e){this.setModelColorAdjustment({brightness:e})}_defaultSkyBox=null;_updateLightDirection=e=>{e.light instanceof this.cesium.DirectionalLight&&(e.light.direction=e.camera.directionWC)};setEnvironmentMapEnable(e){this.is2d||(e?(this.viewer.scene.light=new this.cesium.DirectionalLight({direction:this.viewer.scene.camera.directionWC}),this.viewer.scene.preRender.addEventListener(this._updateLightDirection)):(this._defaultSkyBox&&(this.viewer.scene.skyBox=this._defaultSkyBox),this.viewer.scene.preRender.removeEventListener(this._updateLightDirection),this.viewer.scene.light=new this.cesium.SunLight),this.viewer.scene.imageBasedLighting&&(this.viewer.scene.imageBasedLighting.imageBasedLightingFactor=e?new this.cesium.Cartesian2(2,2):new this.cesium.Cartesian2(1,1)))}setAmbientOcclusion(e){if(this.is2d)return;const t=this.viewer.scene;if(!t||!t.postProcessStages||!t.postProcessStages.ambientOcclusion)return;const n=t.postProcessStages.ambientOcclusion;n.enabled=e,e&&(n.uniforms.ambientOcclusionOnly=!1,n.uniforms.intensity=3,n.uniforms.bias=.1,n.uniforms.lengthCap=.03,n.uniforms.stepSize=1,n.uniforms.blurStepSize=.86)}setCollisionDetection(e){if(this.is2d){this.viewer.scene.screenSpaceCameraController.enableCollisionDetection=!1;return}const t=this.viewer.scene.screenSpaceCameraController;t.enableCollisionDetection=e,e||t.minimumZoomDistance<1&&(t.minimumZoomDistance=1)}_customZoomHandler=null;_zoomInertiaListener=null;setHeightBasedZoom(e){const t=this.viewer.scene.screenSpaceCameraController,n=this.cesium;if(this.viewer.camera.frustum.near=1e-5,this.viewer.camera.frustum.far=1e8,this._customZoomHandler&&(this._customZoomHandler.destroy(),this._customZoomHandler=null),this._zoomInertiaListener&&(this._zoomInertiaListener(),this._zoomInertiaListener=null),!e){t.zoomEventTypes.includes(n.CameraEventType.WHEEL)||t.zoomEventTypes.push(n.CameraEventType.WHEEL);return}t.zoomEventTypes=t.zoomEventTypes.filter(l=>l!==n.CameraEventType.WHEEL),this._customZoomHandler=new n.ScreenSpaceEventHandler(this.viewer.scene.canvas);let s=null;this._customZoomHandler.setInputAction(l=>{s=l.endPosition},n.ScreenSpaceEventType.MOUSE_MOVE);let o=0,r=null;this._zoomInertiaListener=this.viewer.scene.preUpdate.addEventListener(()=>{if(Math.abs(o)<.001||!r){o=0;return}const l=this.viewer.camera,a=o*.2;if(s){const h=l.getPickRay(s);if(h){let p=this.viewer.scene.pickPosition(s);if(!p){const f=n.IntersectionTests.rayEllipsoid(h,this.viewer.scene.globe.ellipsoid);f&&(p=n.Ray.getPoint(h,f.start))}if(p){const f=n.Cartesian3.distance(l.position,p);if(a>0&&a>f-.01){if(o=0,f>.01){const u=n.Cartesian3.multiplyByScalar(r,f-.01,new n.Cartesian3);l.position=n.Cartesian3.add(l.position,u,new n.Cartesian3)}return}}}}const d=n.Cartesian3.multiplyByScalar(r,a,new n.Cartesian3);l.position=n.Cartesian3.add(l.position,d,new n.Cartesian3),o-=a}),this._customZoomHandler.setInputAction(l=>{const a=this.viewer.camera,d=a.positionCartographic.height;let h=0;d<1?h=.01:d<4?h=.1:d<8||d<1e3?h=d*.1:h=d*.2;const p=Math.sign(l);if(!s)r=a.direction;else{const f=a.getPickRay(s);if(f){let u=this.viewer.scene.pickPosition(s);if(!u){const m=n.IntersectionTests.rayEllipsoid(f,this.viewer.scene.globe.ellipsoid);m&&(u=n.Ray.getPoint(f,m.start))}if(u){const m=n.Cartesian3.subtract(u,a.position,new n.Cartesian3);r=n.Cartesian3.normalize(m,new n.Cartesian3)}else r=a.direction}else r=a.direction}o+=p>0?h:-h},n.ScreenSpaceEventType.WHEEL)}setMouseHabit(e){if(this.is2d)return;const t=this.viewer.scene.screenSpaceCameraController;t.enableTranslate=!0,t.enableRotate=!0,t.enableZoom=!0,t.enableTilt=!0,t.enableLook=!1,t.lookEventTypes=[],e===1?(t.rotateEventTypes=[this.cesium.CameraEventType.RIGHT_DRAG],t.zoomEventTypes=[this.cesium.CameraEventType.MIDDLE_DRAG,this.cesium.CameraEventType.WHEEL,this.cesium.CameraEventType.PINCH],t.tiltEventTypes=[this.cesium.CameraEventType.PINCH,this.cesium.CameraEventType.LEFT_DRAG]):(t.rotateEventTypes=[this.cesium.CameraEventType.LEFT_DRAG],t.zoomEventTypes=[this.cesium.CameraEventType.RIGHT_DRAG,this.cesium.CameraEventType.WHEEL,this.cesium.CameraEventType.PINCH],t.tiltEventTypes=[this.cesium.CameraEventType.PINCH,this.cesium.CameraEventType.MIDDLE_DRAG])}}class cy{cesium;viewer;constructor(e){this.cesium=e.cesium,this.viewer=e.viewer}getCameraView(){const e=this.viewer.camera;return{position:{x:e.position.x,y:e.position.y,z:e.position.z},destination:{x:e.position.x,y:e.position.y,z:e.position.z},orientation:{heading:e.heading,pitch:e.pitch,roll:e.roll},duration:1}}flyToCameraView(e){const{position:t,orientation:n,duration:s}=e,o=new this.cesium.Cartesian3(t.x,t.y,t.z),r=new this.cesium.HeadingPitchRoll(n.heading,n.pitch,n.roll);!s||s<=0?this.viewer.camera.setView({destination:o,orientation:r}):this.viewer.camera.flyTo({destination:o,orientation:r,duration:s})}getCurrentCameraPositionAndTarget(){const e=this.getCameraView();return{position:e.position,target:{heading:e.orientation.heading,pitch:e.orientation.pitch,roll:e.orientation.roll},duration:e.duration}}setCameraView(e){const t=e.target||e.orientation||{},n=e.destination||e.position||{};this.flyToCameraView({position:{x:Number(n.x),y:Number(n.y),z:Number(n.z)},destination:{x:Number(n.x),y:Number(n.y),z:Number(n.z)},orientation:{heading:Number(t.heading||0),pitch:Number(t.pitch||0),roll:Number(t.roll||0)},duration:e.duration})}flyToLonLatHeight(e,t,n,s=1){const o=this.cesium.Cartesian3.fromDegrees(e,t,n),r={heading:this.cesium.Math.toRadians(0),pitch:this.cesium.Math.toRadians(-90),roll:0};!s||s<=0?this.viewer.camera.setView({destination:o,orientation:r}):this.viewer.camera.flyTo({destination:o,orientation:r,duration:s})}}function dy(i){const{container:e,appContext:t,methods:n,viewerOptions:s,options:o,callbacks:r}=i,l=new Gi,a=window.Cesium;if(!a)throw new Error("Cesium is not loaded");e.id=`cesium-container-${op()}`;const d={animation:!1,timeline:!1,infoBox:!1,homeButton:!1,fullscreenButton:!1,sceneModePicker:!1,navigationHelpButton:!1,geocoder:!1,baseLayerPicker:!1,selectionIndicator:!1,heightBasedZoom:!0,creditContainer:document.createElement("div"),contextOptions:{webgl:{alpha:!0}}},h=t?.config?.globalProperties?.$leitingBimOptions,p={...d,...h?.viewerOptions??{},...s??{}},f=new a.Viewer(e,p);f.camera.setView({destination:a.Cartesian3.fromDegrees(108,32,1e7),orientation:{heading:a.Math.toRadians(0),pitch:a.Math.toRadians(-90),roll:0}});let u=n;if(!u&&h&&(h.methods||(h.methods={}),u=h.methods),u){const m=new yp({cesium:a,viewer:f,options:o,callbacks:r}),E=new Dr({cesium:a,viewer:f}),A=new ly({cesium:a,viewer:f}),y=new Cp({cesium:a,viewer:f}),v=new cy({cesium:a,viewer:f});let S;const M=new tl({cesium:a,viewer:f});o&&(o.globe!==void 0&&A.setGlobeEnvironmentVisible(o.globe),o.terrain!==void 0&&A.setTerrainEnable(o.terrain),o.depthTest!==void 0&&A.setDepthTestEnable(o.depthTest),o.mapProvider&&o.mode!=="2d"&&A.changeBaseMap(o.mapProvider,{token:o.tiandituToken,layerType:o.tiandituLayerType,showAnnotation:o.tiandituShowLabel,url:o.arcgisUrl}),o.shadows!==void 0&&A.setShadowsEnable(o.shadows),o.environmentMap!==void 0&&A.setEnvironmentMapEnable(o.environmentMap),o.ambientOcclusion!==void 0&&A.setAmbientOcclusion(o.ambientOcclusion),o.time!==void 0&&A.setTime(o.time),o.brightness!==void 0&&A.setModelBrightness(o.brightness),o.backgroundColor!==void 0&&A.setBackgroundColor(o.backgroundColor),o.collision!==void 0&&A.setCollisionDetection(o.collision),o.mouseHabit!==void 0&&A.setMouseHabit(o.mouseHabit),o.heightBasedZoom!==void 0&&A.setHeightBasedZoom(o.heightBasedZoom)),o&&o.mode==="2d"&&(console.log("InitMap: Setting CAD Mode 2D"),A.setCadMode("2d"),S=new el({cesium:a,viewer:f})),E.events.on("tilesetLoaded",g=>{m.baseCompt.attachTileset(g,m.baseCompt.selectedColor),m.baseSection.attachTileset(g,g.leiting?.model?.modelId),u&&u.tilesLoad3dTiles&&u.tilesLoad3dTiles(g),o?.tilesLoad3dTiles&&o.tilesLoad3dTiles(g.leiting)}),E.events.on("loadingStatus",g=>{u&&u.onLoadingStatus&&u.onLoadingStatus(g)}),E.events.on("mountAll3Dtiles",({modelList:g})=>{o?.mountAll3Dtiles&&o.mountAll3Dtiles(g),u?.mountAll3Dtiles&&u.mountAll3Dtiles(g)}),E.events.on("updateModels",({modelList:g})=>{o?.updateModels&&o.updateModels(g),u?.updateModels&&u.updateModels(g)}),y.events.on("mountAllCad",g=>{o?.mountAllCad&&o.mountAllCad(g),u?.mountAllCad&&u.mountAllCad(g)}),m.baseCompt.loadNodeDetailsForModel=g=>E.loadNodeDetailsForModel(g),m.baseCompt.selectionChange(g=>{g.length!==0&&(o?.selectionChange&&o.selectionChange(g),u?.selectionChange&&u.selectionChange(g))}),u.onSearchComponent=g=>{o?.searchComponent&&o.searchComponent(g),u?.searchComponent&&u.searchComponent(g)};const O=u.saveRegion;u.saveRegion=g=>{o?.saveRegion&&o.saveRegion(g),O&&O!==o?.saveRegion&&O(g)};const I=u.saveCadCalibration;u.saveCadCalibration=g=>{o?.saveCadCalibration&&o.saveCadCalibration(g),I&&I!==o?.saveCadCalibration&&I(g)};const B=u.saveCadRegion;u.saveCadRegion=g=>{o?.saveCadRegion&&o.saveCadRegion(g),B&&B!==o?.saveCadRegion&&B(g)},u.getCesium=()=>a,u.getViewer=()=>f,u.getAnnotationInstance=()=>S,u.getMeasureInstance=()=>M,u.flyToCamera=g=>{v.setCameraView(g)},u.flyToLonLatHeight=(g,P,x,F=1)=>{v.flyToLonLatHeight(g,P,x,F)},u.flyTo=u.flyToCamera,u.getCameraState=()=>v.getCameraView(),u.getCameraInfo=u.getCameraState,u.restoreCameraState=g=>v.flyToCameraView(g),u.flyToCameraView=u.restoreCameraState,u.getCameraPositionTarget=()=>v.getCurrentCameraPositionAndTarget(),u.getCurrentCameraPositionAndTarget=u.getCameraPositionTarget,u.setCameraLookAt=g=>v.setCameraView(g),u.setCameraView=u.setCameraLookAt,u.setCanvasBackground=g=>A.setBackgroundColor(g),u.setBackgroundColor=u.setCanvasBackground,u.setAntiAliasing=g=>m.enableCesiumFXAA(g),u.enableCesiumFXAA=u.setAntiAliasing,u.setSceneVisibility=g=>m.setSceneOptions(g),u.setSceneOptions=u.setSceneVisibility,u.addDebugPoint=(g,P,x=0)=>{f.entities.add({position:a.Cartesian3.fromDegrees(g,P,x),point:{pixelSize:10,color:a.Color.RED}})},u.addPoint=u.addDebugPoint,u.toggleDebugLabels=()=>m.enableTestLabel(),u.enableTestLabel=u.toggleDebugLabels,u.captureScreenshot=()=>{const g=f.scene.canvas;return f.render(),g.toDataURL("image/png")},u.getImageBase64=u.captureScreenshot,u.captureDomScreenshot=(g,P)=>m.getSnapDomSImageBase64(g,P),u.getSnapDomSImageBase64=u.captureDomScreenshot,u.addModels=g=>E.addModels(g),u.add3DtilesModel=u.addModels,u.addObliquePhotography=g=>E.addOSGB(g),u.addOSGB=u.addObliquePhotography,u.adjustOSGBModelMatrix=g=>E.updateOSGBMatrix(g),u.updateOSGBMatrix=u.adjustOSGBModelMatrix,u.setModelVisibility=g=>E.showModels(g),u.showModels=u.setModelVisibility,u.showTileset=u.setModelVisibility,u.removeModels=g=>E.deleteModels(g),u.deleteModels=u.removeModels,u.clearAllModels=()=>{E.deleteAllModels(),l.emit("deleteAllModels")},u.deleteAllModelList=u.clearAllModels,u.deleteAllModels=u.clearAllModels,u.flyToModel=g=>E.flyToTileset(g),u.flyToTileset=u.flyToModel,u.flyToByModelId=u.flyToModel,u.setModelBrightness=g=>m.updateModelEffect(g),u.updateModelEffect=u.setModelBrightness,u.getAllTilesets=()=>E.getMapTileset(),u.getMapTileset=u.getAllTilesets,u.getCurrentModelId=()=>E.getBIMmodelId(),u.getBIMmodelId=u.getCurrentModelId,u.getLoadedModels=()=>E.getModelList(),u.getModelList=u.getLoadedModels,u.loadModelStructure=async g=>{const P=typeof g=="string"?g:g?.modelId;if(!P){console.warn("loadModelStructure: modelId is required");return}return await E.loadTreeForModel(P)},u.loadTreeForModel=u.loadModelStructure,u.loadModelDetails=async g=>{const P=typeof g=="string"?g:g?.modelId;if(!P){console.warn("loadModelDetails: modelId is required");return}return await E.loadNodeDetailsForModel(P)},u.loadNodeDetailsForModel=u.loadModelDetails,u.setMapTileset=g=>E.setMapTileset(g),u.setCurrentModelId=g=>E.setBIMmodelId(g),u.setBIMmodelId=u.setCurrentModelId,u.setModelList=g=>E.setModelList(g),u.highlightComponents=(g,P={})=>m.baseCompt.setSelectColorUserModelCpt(g,P),u.setSelectColorUserModelCpt=u.highlightComponents,m.baseCompt.setLoadNodeDetailsCallback(g=>E.loadNodeDetailsForModel(g)),u.highlightAllComponents=g=>m.baseCompt.setAllSelectColorUserModelCpt(g),u.setAllSelectColorUserModelCpt=u.highlightAllComponents,u.setSelectColorUserModelCptByClear=()=>m.baseCompt.clearAllHaveSelected(),u.clearSelectColorUserModelCpt=()=>m.baseCompt.clearAllHaveSelected(),u.selectComponents=(g,P)=>{m.baseCompt.clearAllHaveSelected(),m.baseCompt.setSelectColorUserModelCpt(g,P??{rank:0})},u.setSelecteds=u.selectComponents,u.setSelectionColor=(g,P,x,F)=>m.baseCompt.setSelectedColorRgba(g,P,x,F),u.setSelectedColor=u.setSelectionColor,u.clearSelection=()=>m.baseCompt.clearAllHaveSelected(),u.clearAllHaveSelected=u.clearSelection,u.getSelectedComponents=g=>m.baseCompt.getSelected(g),u.getSelected=u.getSelectedComponents,u.onSelectionChange=g=>{m.baseCompt.selectionChange(g)},u.selectionChange=u.onSelectionChange,u.flyToComponents=g=>m.baseCompt.flyToObjects(g),u.flyToObjects=u.flyToComponents,u.setConstructionData=async g=>{if(g&&Array.isArray(g)){const P=new Set;g.forEach(x=>{x.mergeCpts&&Array.isArray(x.mergeCpts)&&x.mergeCpts.forEach(F=>{F.modelId&&P.add(F.modelId)})}),P.size>0&&await Promise.all(Array.from(P).map(x=>u.loadNodeDetailsForModel(x)))}m.baseCompt.setAllConstructionProgressTracking(g)},u.setAllConstructionProgressTracking=u.setConstructionData,u.startConstructionSimulation=()=>m.baseCompt.enableConstructionProgressTracking(),u.enableAllConstructionProgressTracking=u.startConstructionSimulation,u.stopConstructionSimulation=()=>m.baseCompt.disableConstructionProgressTracking(),u.disableConstructionProgressTracking=u.stopConstructionSimulation,u.disableAllConstructionProgressTracking=u.stopConstructionSimulation,u.resetConstructionSimulation=()=>m.baseCompt.freshConstructionProgressTracking(),u.freshConstructionProgressTracking=u.resetConstructionSimulation,u.restartConstructionSimulation=()=>m.baseCompt.reStartAnimation(),u.reStartAnimation=u.restartConstructionSimulation,u.resumeFlyTo=()=>m.baseCompt.resumeFlyTo(),u.pauseConstructionSimulation=()=>m.baseCompt.pauseFlyTo(),u.pauseFlyTo=u.pauseConstructionSimulation,u.pauseAnimation=u.pauseConstructionSimulation,u.resumeConstructionSimulation=()=>m.baseCompt.resumeFlyTo(),u.resumeAnimation=u.resumeConstructionSimulation,u.setComponentsVisibility=async g=>await m.baseCompt.setComponentVisibility(g),u.setElementsListVisible=u.setComponentsVisibility,u.setAllComponentsVisibility=async g=>await m.baseCompt.setAllComponentsVisibility(g),u.setAllElementsVisible=u.setAllComponentsVisibility,u.getComponentsByVisibility=g=>m.baseCompt.getComponentsByVisibility(g),u.getShowCpts=g=>m.baseCompt.getComponentsByVisibility(g),u.getElementsVisible=u.getComponentsByVisibility,u.setComponentVisibility=u.setComponentsVisibility,u.enableSectioning=(g,P)=>m.baseSection.open(g,P),u.openSection=u.enableSectioning,u.disableSectioning=g=>m.baseSection.close(g),u.closeSection=u.disableSectioning,u.updateSectionBox=g=>m.baseSection.updateRange(g),u.updateSectionRange=u.updateSectionBox,u.getSectionBox=()=>m.baseSection.getRange(),u.getSectionRange=u.getSectionBox,u.fitSectionToModel=()=>m.baseSection.fitToModels(),u.fitToModels=u.fitSectionToModel,u.setSectionBoxVisibility=g=>m.baseSection.setBoxVisibility(g),u.startFirstPersonMode=()=>{m.baseCompt.disableSelection(),m.basePlayer.openPlayer()},u.openPlayer=u.startFirstPersonMode,u.stopFirstPersonMode=()=>{m.basePlayer.closePlayer(),m.baseCompt.enableSelection()},u.closePlayer=u.stopFirstPersonMode,u.setPlayerPosition=g=>m.basePlayer.setPersonPosition(g),u.setPersonPosition=u.setPlayerPosition,u.setWalkSpeed=g=>m.basePlayer.setSpeed({speed:g}),u.setPlayerSpeed=u.setWalkSpeed,u.setPlayerConfig=g=>m.basePlayer.setParams(g),u.setPlayerParams=u.setPlayerConfig,u.setPlayerAction=(g,P)=>m.basePlayer.setMoveState(g,P),u.setPlayerMoveState=u.setPlayerAction,u.bindPlayerControls=g=>m.basePlayer.bindUiKeys(g),u.bindPlayerUiKeys=u.bindPlayerControls,u.setGlobeVisibility=g=>A.setGlobeEnvironmentVisible(g),u.setGlobeEnvironmentVisible=u.setGlobeVisibility,u.setTerrainVisibility=g=>A.setTerrainEnable(g),u.setTerrainEnable=u.setTerrainVisibility,u.setDepthTest=g=>A.setDepthTestEnable(g),u.setDepthTestEnable=u.setDepthTest,u.setBaseMap=(g,P)=>A.changeBaseMap(g,P),u.changeBaseMap=u.setBaseMap,u.setWorldTime=g=>A.setTime(g),u.setTime=u.setWorldTime,u.setGisOptions=g=>{g.globe!==void 0&&A.setGlobeEnvironmentVisible(g.globe),g.elevation!==void 0&&A.setTerrainEnable(g.elevation),g.depthTestAgainstTerrain!==void 0&&A.setDepthTestEnable(g.depthTestAgainstTerrain),g.rendering!==void 0&&A.setAmbientOcclusion(g.rendering)},u.setShadowVisibility=g=>A.setShadowsEnable(g),u.setShadowsEnable=u.setShadowVisibility,u.setEnvironmentMapVisibility=g=>A.setEnvironmentMapEnable(g),u.setEnvironmentMapEnable=u.setEnvironmentMapVisibility,u.setAOVisibility=g=>A.setAmbientOcclusion(g),u.setAmbientOcclusion=u.setAOVisibility,u.setBackgroundColor=g=>A.setGlobeColor(g),u.setGlobeColor=u.setBackgroundColor,u.setModelBrightness=g=>A.setModelBrightness(g),u.adjustModelColor=g=>A.setModelColorAdjustment(g),u.setModelColorAdjustment=u.adjustModelColor,u.setShadowIntensity=g=>{A.setShadowDarkness?A.setShadowDarkness(g):console.warn("baseSetting.setShadowDarkness is not available. Please reload the page.")},u.setShadowDarkness=u.setShadowIntensity,u.switchSceneMode=async g=>{const P=g?"2d":"3d";await A.setCadMode(P),g&&!S&&(S=new el({cesium:a,viewer:f}),u.setGlobeVisibility(!0)),l.emit("setMode",P)},u.setSceneMode=u.switchSceneMode,u.set2d=g=>u.switchSceneMode(g),u.is2dMode=()=>A.is2d,u.setMouseControlMode=g=>A.setMouseHabit(g),u.setMouseHabit=u.setMouseControlMode,u.setCollisionEnabled=g=>A.setCollisionDetection(g),u.setCollisionDetection=u.setCollisionEnabled,u.searchAndLocate=(g,P)=>A.searchLocation(g,P),u.searchLocation=u.searchAndLocate,u.getConfigure=()=>(console.warn("getConfigure is not initialized. Please ensure LeitingSetting component is mounted."),{}),u.setConfigure=g=>{console.warn("setConfigure is not initialized. Please ensure LeitingSetting component is mounted.",g)},u.addCadModel=g=>{const P={...g};return P.files&&!P.fileNames&&(P.fileNames=P.files),P.fileNames||(P.fileNames=[]),y.addDxfModel(P)},u.addDxfModel=u.addCadModel,u.deleteCad=g=>y.deleteCad(g),u.deleteAllCad=()=>y.deleteAllCad(),u.showCadModel=g=>y.showJson(g),u.showGeoJson=g=>y.showJson(g),u.showDxfModel=u.showCadModel,u.showCadLayer=g=>y.showJsonByLayer(g),u.showDxfLayer=u.showCadLayer,u.flyToCadModel=(g={})=>y.flyToCadModel(g),u.getCadModels=g=>y.getDxfModels(g),u.getDxfModels=u.getCadModels,u.getCadLayers=g=>y.getMapLayers(g),u.getDxfLayers=u.getCadLayers,u.getCadModelId=()=>y.getModelId(),u.setCadOpen=g=>y.setDxfOpen(g),u.setDxfOpen=u.setCadOpen,u.getCadOpen=()=>y.getDxfOpen(),u.getDxfOpen=u.getCadOpen,u.adjustCadModel=g=>y.adjustingModelByCad(g),u.adjustingModelByCad=u.adjustCadModel,u.saveAnnotations=()=>{let g=null;return S&&(g=S.saveAnnotations()),o?.saveAnnotations&&o.saveAnnotations(g),g},u.loadAnnotations=g=>S?S.loadAnnotations(g):!1,u.flyToTopView=()=>{y.flyToCadModel()},u.menuEvents=l,u.addMenuItems=g=>{l.emit("insertMenu",g)},u.insertMenu=u.addMenuItems,u.filterMenuItems=g=>{l.emit("setMenuListFilter",g)},u.setMenuListFilter=u.filterMenuItems,u.setMenuVisibility=g=>{l.emit("showMenu",g)},u.showMenu=u.setMenuVisibility,u.setPanelVisibility=(g,P)=>{l.emit("setMenuActive",g,P)},u.setMenuActive=u.setPanelVisibility,u.addContextMenuItems=g=>{console.warn("addContextMenuItems is not initialized yet. Please wait for LeitingBIM component to mount.",g)},u.insertContextMenu=u.addContextMenuItems,u.removeContextMenuItems=g=>{console.warn("removeContextMenuItems is not initialized yet.",g)},u.deleteContextMenu=u.removeContextMenuItems,u.closeContextMenu=()=>{console.warn("closeContextMenu is not initialized yet.")},u.hideContextMenu=u.closeContextMenu,u.getModelTree=()=>{const g=[],P=E.getMapTileset();return Object.keys(P).forEach(x=>{const F=P[x];if(F&&F.leiting&&F.leiting.tree){const _=F.leiting.tree;Array.isArray(_)?g.push(..._):g.push(_)}}),g},u.getTree=u.getModelTree,u.getAllComponentDetails=()=>{const g=E.getMapTileset(),P={},x=[];try{Object.keys(g).forEach(F=>{const _=g[F];if(!_||!_.leiting)return;const H=_.leiting,N=H.node,w=H.model.formData,C=H.box;if(!N||!N.nodeExtras)return;const b=H.model.modelId;P[b]=N.nodeExtras;const D=N.nodeExtras.element;if(!D)return;const k=C?C.center:{x:0,y:0,z:0};Object.values(D).forEach(Q=>{if(Q.box3)try{const R=a.Quaternion.fromAxisAngle(a.Cartesian3.UNIT_Z,a.Math.toRadians(w.totalRotation||0)),T=a.Matrix4.fromRotationTranslation(a.Matrix3.fromQuaternion(R),new a.Cartesian3(0,0,0)),U=a.Cartesian3.fromDegrees(w.longitude,w.latitude,w.height),V=a.Transforms.eastNorthUpToFixedFrame(U);a.Matrix4.multiply(V,T,V);const W=new a.Cartesian3(k.x,k.y,0),q=new a.Cartesian3;a.Matrix4.multiplyByPoint(V,W,q);const ie=a.Cartographic.fromCartesian(q),ae=Q.box3?.Center?.x||0,ne=Q.box3?.Center?.y||0,Y=Q.box3?.Center?.z||0,j=new a.Cartesian3(-k.x+ae,-k.y+ne,0+Y),ee=a.Matrix4.fromTranslation(j),le=a.Matrix4.clone(ee);a.Matrix4.multiply(T,le,le);const oe=a.Cartesian3.fromDegrees(ie.longitude/Math.PI*180,ie.latitude/Math.PI*180,w.height),ce=a.Transforms.eastNorthUpToFixedFrame(oe);a.Matrix4.multiply(ce,le,ce);const ve=a.Cartographic.fromCartesian(new a.Cartesian3(ce[12],ce[13],ce[14]));Q.box3.cartographic={longitude:ve.longitude/Math.PI*180,latitude:ve.latitude/Math.PI*180,height:ve.height};const Te={id:Q.uniqueId,billboard:[{theme:"Tag9999",position:[Q.box3.cartographic.longitude,Q.box3.cartographic.latitude,Q.box3.cartographic.height],options:{text:Q.name}}]};x.push(Te)}catch(R){console.warn("Error calculating component position:",R)}})})}catch(F){console.error("getAllComponents error:",F)}return P},u.getAllComponents=u.getAllComponentDetails,u.getComponentInfoList=g=>{if(!Array.isArray(g))return[];const P=E.getMapTileset(),x=[],F={};g.forEach(_=>{!_.modelId||!_.elementId||(F[_.modelId]||(F[_.modelId]=[]),F[_.modelId]?.push(_.elementId))});try{Object.keys(F).forEach(_=>{const H=P[_];if(!H||!H.leiting)return;const N=H.leiting,w=N.node,C=N.model.formData,b=N.box;if(!w||!w.nodeExtras)return;const D=w.nodeExtras.element;if(!D)return;const k=b?b.center:{x:0,y:0,z:0};F[_]?.forEach(Q=>{const R=D[Q];if(R&&R.box3)try{const T=a.Quaternion.fromAxisAngle(a.Cartesian3.UNIT_Z,a.Math.toRadians(C.totalRotation||0)),U=a.Matrix4.fromRotationTranslation(a.Matrix3.fromQuaternion(T),new a.Cartesian3(0,0,0)),V=a.Cartesian3.fromDegrees(C.longitude,C.latitude,C.height),W=a.Transforms.eastNorthUpToFixedFrame(V);a.Matrix4.multiply(W,U,W);const q=new a.Cartesian3(k.x,k.y,0),ie=new a.Cartesian3;a.Matrix4.multiplyByPoint(W,q,ie);const ae=a.Cartographic.fromCartesian(ie),ne=R.box3?.Center?.x||0,Y=R.box3?.Center?.y||0,j=R.box3?.Center?.z||0,ee=new a.Cartesian3(-k.x+ne,-k.y+Y,0+j),le=a.Matrix4.fromTranslation(ee),oe=a.Matrix4.clone(le);a.Matrix4.multiply(U,oe,oe);const ce=a.Cartesian3.fromDegrees(ae.longitude/Math.PI*180,ae.latitude/Math.PI*180,C.height),ve=a.Transforms.eastNorthUpToFixedFrame(ce);a.Matrix4.multiply(ve,oe,ve);const Te=a.Cartographic.fromCartesian(new a.Cartesian3(ve[12],ve[13],ve[14]));R.box3.cartographic={longitude:Te.longitude/Math.PI*180,latitude:Te.latitude/Math.PI*180,height:Te.height},R.elementId=Q,R.modelId=_,x.push(R)}catch(T){console.warn("Error calculating component position:",T)}})})}catch(_){console.error("getCptInfos error:",_)}return x},u.getCptInfos=u.getComponentInfoList,u.baseCompt=m.baseCompt,window.Methods=u}return console.log("methods",u),{Cesium:a,viewer:f,methods:u,menuEvents:l}}const we=c.reactive({visible:!1,type:"info",title:"",description:"",closable:!1,showIcon:!0,duration:3});let ye=null,il=null,nl=!1,xs=null,on=null,Ss=null;function hy(){if(on||typeof document>"u")return;const i=`
49
+ `});f.isModelAdjustment=!0,p.customShader=f}else e.brightness!==void 0&&e.brightness!==1&&!p.style&&(p.style=new n.Cesium3DTileStyle({color:`color('white') * ${e.brightness}`}))}}setModelBrightness(e){this.setModelColorAdjustment({brightness:e})}_defaultSkyBox=null;_updateLightDirection=e=>{e.light instanceof this.cesium.DirectionalLight&&(e.light.direction=e.camera.directionWC)};setEnvironmentMapEnable(e){this.is2d||(e?(this.viewer.scene.light=new this.cesium.DirectionalLight({direction:this.viewer.scene.camera.directionWC}),this.viewer.scene.preRender.addEventListener(this._updateLightDirection)):(this._defaultSkyBox&&(this.viewer.scene.skyBox=this._defaultSkyBox),this.viewer.scene.preRender.removeEventListener(this._updateLightDirection),this.viewer.scene.light=new this.cesium.SunLight),this.viewer.scene.imageBasedLighting&&(this.viewer.scene.imageBasedLighting.imageBasedLightingFactor=e?new this.cesium.Cartesian2(2,2):new this.cesium.Cartesian2(1,1)))}setAmbientOcclusion(e){if(this.is2d)return;const t=this.viewer.scene;if(!t||!t.postProcessStages||!t.postProcessStages.ambientOcclusion)return;const n=t.postProcessStages.ambientOcclusion;n.enabled=e,e&&(n.uniforms.ambientOcclusionOnly=!1,n.uniforms.intensity=3,n.uniforms.bias=.1,n.uniforms.lengthCap=.03,n.uniforms.stepSize=1,n.uniforms.blurStepSize=.86)}setCollisionDetection(e){if(this.is2d){this.viewer.scene.screenSpaceCameraController.enableCollisionDetection=!1;return}const t=this.viewer.scene.screenSpaceCameraController;t.enableCollisionDetection=e,e||t.minimumZoomDistance<1&&(t.minimumZoomDistance=1)}_customZoomHandler=null;_zoomInertiaListener=null;setHeightBasedZoom(e){const t=this.viewer.scene.screenSpaceCameraController,n=this.cesium;if(this.viewer.camera.frustum.near=1e-5,this.viewer.camera.frustum.far=1e8,this._customZoomHandler&&(this._customZoomHandler.destroy(),this._customZoomHandler=null),this._zoomInertiaListener&&(this._zoomInertiaListener(),this._zoomInertiaListener=null),!e){t.zoomEventTypes.includes(n.CameraEventType.WHEEL)||t.zoomEventTypes.push(n.CameraEventType.WHEEL);return}t.zoomEventTypes=t.zoomEventTypes.filter(l=>l!==n.CameraEventType.WHEEL),this._customZoomHandler=new n.ScreenSpaceEventHandler(this.viewer.scene.canvas);let s=null;this._customZoomHandler.setInputAction(l=>{s=l.endPosition},n.ScreenSpaceEventType.MOUSE_MOVE);let o=0,r=null;this._zoomInertiaListener=this.viewer.scene.preUpdate.addEventListener(()=>{if(Math.abs(o)<.001||!r){o=0;return}const l=this.viewer.camera,a=o*.2;if(s){const h=l.getPickRay(s);if(h){let p=this.viewer.scene.pickPosition(s);if(!p){const f=n.IntersectionTests.rayEllipsoid(h,this.viewer.scene.globe.ellipsoid);f&&(p=n.Ray.getPoint(h,f.start))}if(p){const f=n.Cartesian3.distance(l.position,p);if(a>0&&a>f-.01){if(o=0,f>.01){const u=n.Cartesian3.multiplyByScalar(r,f-.01,new n.Cartesian3);l.position=n.Cartesian3.add(l.position,u,new n.Cartesian3)}return}}}}const d=n.Cartesian3.multiplyByScalar(r,a,new n.Cartesian3);l.position=n.Cartesian3.add(l.position,d,new n.Cartesian3),o-=a}),this._customZoomHandler.setInputAction(l=>{const a=this.viewer.camera,d=a.positionCartographic.height;let h=0;d<.1?h=.001:d<1?h=.02:d<4?h=.2:d<8||d<1e3?h=d*.1:h=d*.2;const p=Math.sign(l);if(!s)r=a.direction;else{const f=a.getPickRay(s);if(f){let u=this.viewer.scene.pickPosition(s);if(!u){const m=n.IntersectionTests.rayEllipsoid(f,this.viewer.scene.globe.ellipsoid);m&&(u=n.Ray.getPoint(f,m.start))}if(u){const m=n.Cartesian3.subtract(u,a.position,new n.Cartesian3);r=n.Cartesian3.normalize(m,new n.Cartesian3)}else r=a.direction}else r=a.direction}o+=p>0?h:-h},n.ScreenSpaceEventType.WHEEL)}setMouseHabit(e){if(this.is2d)return;const t=this.viewer.scene.screenSpaceCameraController;t.enableTranslate=!0,t.enableRotate=!0,t.enableZoom=!0,t.enableTilt=!0,t.enableLook=!1,t.lookEventTypes=[],e===1?(t.rotateEventTypes=[this.cesium.CameraEventType.RIGHT_DRAG],t.zoomEventTypes=[this.cesium.CameraEventType.MIDDLE_DRAG,this.cesium.CameraEventType.WHEEL,this.cesium.CameraEventType.PINCH],t.tiltEventTypes=[this.cesium.CameraEventType.PINCH,this.cesium.CameraEventType.LEFT_DRAG]):(t.rotateEventTypes=[this.cesium.CameraEventType.LEFT_DRAG],t.zoomEventTypes=[this.cesium.CameraEventType.RIGHT_DRAG,this.cesium.CameraEventType.WHEEL,this.cesium.CameraEventType.PINCH],t.tiltEventTypes=[this.cesium.CameraEventType.PINCH,this.cesium.CameraEventType.MIDDLE_DRAG])}}class cy{cesium;viewer;constructor(e){this.cesium=e.cesium,this.viewer=e.viewer}getCameraView(){const e=this.viewer.camera;return{position:{x:e.position.x,y:e.position.y,z:e.position.z},destination:{x:e.position.x,y:e.position.y,z:e.position.z},orientation:{heading:e.heading,pitch:e.pitch,roll:e.roll},duration:1}}flyToCameraView(e){const{position:t,orientation:n,duration:s}=e,o=new this.cesium.Cartesian3(t.x,t.y,t.z),r=new this.cesium.HeadingPitchRoll(n.heading,n.pitch,n.roll);!s||s<=0?this.viewer.camera.setView({destination:o,orientation:r}):this.viewer.camera.flyTo({destination:o,orientation:r,duration:s})}getCurrentCameraPositionAndTarget(){const e=this.getCameraView();return{position:e.position,target:{heading:e.orientation.heading,pitch:e.orientation.pitch,roll:e.orientation.roll},duration:e.duration}}setCameraView(e){const t=e.target||e.orientation||{},n=e.destination||e.position||{};this.flyToCameraView({position:{x:Number(n.x),y:Number(n.y),z:Number(n.z)},destination:{x:Number(n.x),y:Number(n.y),z:Number(n.z)},orientation:{heading:Number(t.heading||0),pitch:Number(t.pitch||0),roll:Number(t.roll||0)},duration:e.duration})}flyToLonLatHeight(e,t,n,s=1){const o=this.cesium.Cartesian3.fromDegrees(e,t,n),r={heading:this.cesium.Math.toRadians(0),pitch:this.cesium.Math.toRadians(-90),roll:0};!s||s<=0?this.viewer.camera.setView({destination:o,orientation:r}):this.viewer.camera.flyTo({destination:o,orientation:r,duration:s})}}function dy(i){const{container:e,appContext:t,methods:n,viewerOptions:s,options:o,callbacks:r}=i,l=new Gi,a=window.Cesium;if(!a)throw new Error("Cesium is not loaded");e.id=`cesium-container-${op()}`;const d={animation:!1,timeline:!1,infoBox:!1,homeButton:!1,fullscreenButton:!1,sceneModePicker:!1,navigationHelpButton:!1,geocoder:!1,baseLayerPicker:!1,selectionIndicator:!1,heightBasedZoom:!0,creditContainer:document.createElement("div"),contextOptions:{webgl:{alpha:!0}}},h=t?.config?.globalProperties?.$leitingBimOptions,p={...d,...h?.viewerOptions??{},...s??{}},f=new a.Viewer(e,p);f.camera.setView({destination:a.Cartesian3.fromDegrees(108,32,1e7),orientation:{heading:a.Math.toRadians(0),pitch:a.Math.toRadians(-90),roll:0}});let u=n;if(!u&&h&&(h.methods||(h.methods={}),u=h.methods),u){const m=new yp({cesium:a,viewer:f,options:o,callbacks:r}),E=new Dr({cesium:a,viewer:f}),A=new ly({cesium:a,viewer:f}),y=new Cp({cesium:a,viewer:f}),v=new cy({cesium:a,viewer:f});let S;const M=new tl({cesium:a,viewer:f});o&&(o.globe!==void 0&&A.setGlobeEnvironmentVisible(o.globe),o.terrain!==void 0&&A.setTerrainEnable(o.terrain),o.depthTest!==void 0&&A.setDepthTestEnable(o.depthTest),o.mapProvider&&o.mode!=="2d"&&A.changeBaseMap(o.mapProvider,{token:o.tiandituToken,layerType:o.tiandituLayerType,showAnnotation:o.tiandituShowLabel,url:o.arcgisUrl}),o.shadows!==void 0&&A.setShadowsEnable(o.shadows),o.environmentMap!==void 0&&A.setEnvironmentMapEnable(o.environmentMap),o.ambientOcclusion!==void 0&&A.setAmbientOcclusion(o.ambientOcclusion),o.time!==void 0&&A.setTime(o.time),o.brightness!==void 0&&A.setModelBrightness(o.brightness),o.backgroundColor!==void 0&&A.setBackgroundColor(o.backgroundColor),o.collision!==void 0&&A.setCollisionDetection(o.collision),o.mouseHabit!==void 0&&A.setMouseHabit(o.mouseHabit),o.heightBasedZoom!==void 0&&A.setHeightBasedZoom(o.heightBasedZoom)),o&&o.mode==="2d"&&(console.log("InitMap: Setting CAD Mode 2D"),A.setCadMode("2d"),S=new el({cesium:a,viewer:f})),E.events.on("tilesetLoaded",g=>{m.baseCompt.attachTileset(g,m.baseCompt.selectedColor),m.baseSection.attachTileset(g,g.leiting?.model?.modelId),u&&u.tilesLoad3dTiles&&u.tilesLoad3dTiles(g),o?.tilesLoad3dTiles&&o.tilesLoad3dTiles(g.leiting)}),E.events.on("loadingStatus",g=>{u&&u.onLoadingStatus&&u.onLoadingStatus(g)}),E.events.on("mountAll3Dtiles",({modelList:g})=>{o?.mountAll3Dtiles&&o.mountAll3Dtiles(g),u?.mountAll3Dtiles&&u.mountAll3Dtiles(g)}),E.events.on("updateModels",({modelList:g})=>{o?.updateModels&&o.updateModels(g),u?.updateModels&&u.updateModels(g)}),y.events.on("mountAllCad",g=>{o?.mountAllCad&&o.mountAllCad(g),u?.mountAllCad&&u.mountAllCad(g)}),m.baseCompt.loadNodeDetailsForModel=g=>E.loadNodeDetailsForModel(g),m.baseCompt.selectionChange(g=>{g.length!==0&&(o?.selectionChange&&o.selectionChange(g),u?.selectionChange&&u.selectionChange(g))}),u.onSearchComponent=g=>{o?.searchComponent&&o.searchComponent(g),u?.searchComponent&&u.searchComponent(g)};const O=u.saveRegion;u.saveRegion=g=>{o?.saveRegion&&o.saveRegion(g),O&&O!==o?.saveRegion&&O(g)};const I=u.saveCadCalibration;u.saveCadCalibration=g=>{o?.saveCadCalibration&&o.saveCadCalibration(g),I&&I!==o?.saveCadCalibration&&I(g)};const B=u.saveCadRegion;u.saveCadRegion=g=>{o?.saveCadRegion&&o.saveCadRegion(g),B&&B!==o?.saveCadRegion&&B(g)},u.getCesium=()=>a,u.getViewer=()=>f,u.getAnnotationInstance=()=>S,u.getMeasureInstance=()=>M,u.flyToCamera=g=>{v.setCameraView(g)},u.flyToLonLatHeight=(g,P,x,F=1)=>{v.flyToLonLatHeight(g,P,x,F)},u.flyTo=u.flyToCamera,u.getCameraState=()=>v.getCameraView(),u.getCameraInfo=u.getCameraState,u.restoreCameraState=g=>v.flyToCameraView(g),u.flyToCameraView=u.restoreCameraState,u.getCameraPositionTarget=()=>v.getCurrentCameraPositionAndTarget(),u.getCurrentCameraPositionAndTarget=u.getCameraPositionTarget,u.setCameraLookAt=g=>v.setCameraView(g),u.setCameraView=u.setCameraLookAt,u.setCanvasBackground=g=>A.setBackgroundColor(g),u.setBackgroundColor=u.setCanvasBackground,u.setAntiAliasing=g=>m.enableCesiumFXAA(g),u.enableCesiumFXAA=u.setAntiAliasing,u.setSceneVisibility=g=>m.setSceneOptions(g),u.setSceneOptions=u.setSceneVisibility,u.addDebugPoint=(g,P,x=0)=>{f.entities.add({position:a.Cartesian3.fromDegrees(g,P,x),point:{pixelSize:10,color:a.Color.RED}})},u.addPoint=u.addDebugPoint,u.toggleDebugLabels=()=>m.enableTestLabel(),u.enableTestLabel=u.toggleDebugLabels,u.captureScreenshot=()=>{const g=f.scene.canvas;return f.render(),g.toDataURL("image/png")},u.getImageBase64=u.captureScreenshot,u.captureDomScreenshot=(g,P)=>m.getSnapDomSImageBase64(g,P),u.getSnapDomSImageBase64=u.captureDomScreenshot,u.addModels=g=>E.addModels(g),u.add3DtilesModel=u.addModels,u.addObliquePhotography=g=>E.addOSGB(g),u.addOSGB=u.addObliquePhotography,u.adjustOSGBModelMatrix=g=>E.updateOSGBMatrix(g),u.updateOSGBMatrix=u.adjustOSGBModelMatrix,u.setModelVisibility=g=>E.showModels(g),u.showModels=u.setModelVisibility,u.showTileset=u.setModelVisibility,u.removeModels=g=>E.deleteModels(g),u.deleteModels=u.removeModels,u.clearAllModels=()=>{E.deleteAllModels(),l.emit("deleteAllModels")},u.deleteAllModelList=u.clearAllModels,u.deleteAllModels=u.clearAllModels,u.flyToModel=g=>E.flyToTileset(g),u.flyToTileset=u.flyToModel,u.flyToByModelId=u.flyToModel,u.setModelBrightness=g=>m.updateModelEffect(g),u.updateModelEffect=u.setModelBrightness,u.getAllTilesets=()=>E.getMapTileset(),u.getMapTileset=u.getAllTilesets,u.getCurrentModelId=()=>E.getBIMmodelId(),u.getBIMmodelId=u.getCurrentModelId,u.getLoadedModels=()=>E.getModelList(),u.getModelList=u.getLoadedModels,u.loadModelStructure=async g=>{const P=typeof g=="string"?g:g?.modelId;if(!P){console.warn("loadModelStructure: modelId is required");return}return await E.loadTreeForModel(P)},u.loadTreeForModel=u.loadModelStructure,u.loadModelDetails=async g=>{const P=typeof g=="string"?g:g?.modelId;if(!P){console.warn("loadModelDetails: modelId is required");return}return await E.loadNodeDetailsForModel(P)},u.loadNodeDetailsForModel=u.loadModelDetails,u.setMapTileset=g=>E.setMapTileset(g),u.setCurrentModelId=g=>E.setBIMmodelId(g),u.setBIMmodelId=u.setCurrentModelId,u.setModelList=g=>E.setModelList(g),u.highlightComponents=(g,P={})=>m.baseCompt.setSelectColorUserModelCpt(g,P),u.setSelectColorUserModelCpt=u.highlightComponents,m.baseCompt.setLoadNodeDetailsCallback(g=>E.loadNodeDetailsForModel(g)),u.highlightAllComponents=g=>m.baseCompt.setAllSelectColorUserModelCpt(g),u.setAllSelectColorUserModelCpt=u.highlightAllComponents,u.setSelectColorUserModelCptByClear=()=>m.baseCompt.clearAllHaveSelected(),u.clearSelectColorUserModelCpt=()=>m.baseCompt.clearAllHaveSelected(),u.selectComponents=(g,P)=>{m.baseCompt.clearAllHaveSelected(),m.baseCompt.setSelectColorUserModelCpt(g,P??{rank:0})},u.setSelecteds=u.selectComponents,u.setSelectionColor=(g,P,x,F)=>m.baseCompt.setSelectedColorRgba(g,P,x,F),u.setSelectedColor=u.setSelectionColor,u.clearSelection=()=>m.baseCompt.clearAllHaveSelected(),u.clearAllHaveSelected=u.clearSelection,u.getSelectedComponents=g=>m.baseCompt.getSelected(g),u.getSelected=u.getSelectedComponents,u.onSelectionChange=g=>{m.baseCompt.selectionChange(g)},u.selectionChange=u.onSelectionChange,u.flyToComponents=g=>m.baseCompt.flyToObjects(g),u.flyToObjects=u.flyToComponents,u.setConstructionData=async g=>{if(g&&Array.isArray(g)){const P=new Set;g.forEach(x=>{x.mergeCpts&&Array.isArray(x.mergeCpts)&&x.mergeCpts.forEach(F=>{F.modelId&&P.add(F.modelId)})}),P.size>0&&await Promise.all(Array.from(P).map(x=>u.loadNodeDetailsForModel(x)))}m.baseCompt.setAllConstructionProgressTracking(g)},u.setAllConstructionProgressTracking=u.setConstructionData,u.startConstructionSimulation=()=>m.baseCompt.enableConstructionProgressTracking(),u.enableAllConstructionProgressTracking=u.startConstructionSimulation,u.stopConstructionSimulation=()=>m.baseCompt.disableConstructionProgressTracking(),u.disableConstructionProgressTracking=u.stopConstructionSimulation,u.disableAllConstructionProgressTracking=u.stopConstructionSimulation,u.resetConstructionSimulation=()=>m.baseCompt.freshConstructionProgressTracking(),u.freshConstructionProgressTracking=u.resetConstructionSimulation,u.restartConstructionSimulation=()=>m.baseCompt.reStartAnimation(),u.reStartAnimation=u.restartConstructionSimulation,u.resumeFlyTo=()=>m.baseCompt.resumeFlyTo(),u.pauseConstructionSimulation=()=>m.baseCompt.pauseFlyTo(),u.pauseFlyTo=u.pauseConstructionSimulation,u.pauseAnimation=u.pauseConstructionSimulation,u.resumeConstructionSimulation=()=>m.baseCompt.resumeFlyTo(),u.resumeAnimation=u.resumeConstructionSimulation,u.setComponentsVisibility=async g=>await m.baseCompt.setComponentVisibility(g),u.setElementsListVisible=u.setComponentsVisibility,u.setAllComponentsVisibility=async g=>await m.baseCompt.setAllComponentsVisibility(g),u.setAllElementsVisible=u.setAllComponentsVisibility,u.getComponentsByVisibility=g=>m.baseCompt.getComponentsByVisibility(g),u.getShowCpts=g=>m.baseCompt.getComponentsByVisibility(g),u.getElementsVisible=u.getComponentsByVisibility,u.setComponentVisibility=u.setComponentsVisibility,u.enableSectioning=(g,P)=>m.baseSection.open(g,P),u.openSection=u.enableSectioning,u.disableSectioning=g=>m.baseSection.close(g),u.closeSection=u.disableSectioning,u.updateSectionBox=g=>m.baseSection.updateRange(g),u.updateSectionRange=u.updateSectionBox,u.getSectionBox=()=>m.baseSection.getRange(),u.getSectionRange=u.getSectionBox,u.fitSectionToModel=()=>m.baseSection.fitToModels(),u.fitToModels=u.fitSectionToModel,u.setSectionBoxVisibility=g=>m.baseSection.setBoxVisibility(g),u.startFirstPersonMode=()=>{m.baseCompt.disableSelection(),m.basePlayer.openPlayer()},u.openPlayer=u.startFirstPersonMode,u.stopFirstPersonMode=()=>{m.basePlayer.closePlayer(),m.baseCompt.enableSelection()},u.closePlayer=u.stopFirstPersonMode,u.setPlayerPosition=g=>m.basePlayer.setPersonPosition(g),u.setPersonPosition=u.setPlayerPosition,u.setWalkSpeed=g=>m.basePlayer.setSpeed({speed:g}),u.setPlayerSpeed=u.setWalkSpeed,u.setPlayerConfig=g=>m.basePlayer.setParams(g),u.setPlayerParams=u.setPlayerConfig,u.setPlayerAction=(g,P)=>m.basePlayer.setMoveState(g,P),u.setPlayerMoveState=u.setPlayerAction,u.bindPlayerControls=g=>m.basePlayer.bindUiKeys(g),u.bindPlayerUiKeys=u.bindPlayerControls,u.setGlobeVisibility=g=>A.setGlobeEnvironmentVisible(g),u.setGlobeEnvironmentVisible=u.setGlobeVisibility,u.setTerrainVisibility=g=>A.setTerrainEnable(g),u.setTerrainEnable=u.setTerrainVisibility,u.setDepthTest=g=>A.setDepthTestEnable(g),u.setDepthTestEnable=u.setDepthTest,u.setBaseMap=(g,P)=>A.changeBaseMap(g,P),u.changeBaseMap=u.setBaseMap,u.setWorldTime=g=>A.setTime(g),u.setTime=u.setWorldTime,u.setGisOptions=g=>{g.globe!==void 0&&A.setGlobeEnvironmentVisible(g.globe),g.elevation!==void 0&&A.setTerrainEnable(g.elevation),g.depthTestAgainstTerrain!==void 0&&A.setDepthTestEnable(g.depthTestAgainstTerrain),g.rendering!==void 0&&A.setAmbientOcclusion(g.rendering)},u.setShadowVisibility=g=>A.setShadowsEnable(g),u.setShadowsEnable=u.setShadowVisibility,u.setEnvironmentMapVisibility=g=>A.setEnvironmentMapEnable(g),u.setEnvironmentMapEnable=u.setEnvironmentMapVisibility,u.setAOVisibility=g=>A.setAmbientOcclusion(g),u.setAmbientOcclusion=u.setAOVisibility,u.setBackgroundColor=g=>A.setGlobeColor(g),u.setGlobeColor=u.setBackgroundColor,u.setModelBrightness=g=>A.setModelBrightness(g),u.adjustModelColor=g=>A.setModelColorAdjustment(g),u.setModelColorAdjustment=u.adjustModelColor,u.setShadowIntensity=g=>{A.setShadowDarkness?A.setShadowDarkness(g):console.warn("baseSetting.setShadowDarkness is not available. Please reload the page.")},u.setShadowDarkness=u.setShadowIntensity,u.switchSceneMode=async g=>{const P=g?"2d":"3d";await A.setCadMode(P),g&&!S&&(S=new el({cesium:a,viewer:f}),u.setGlobeVisibility(!0)),l.emit("setMode",P)},u.setSceneMode=u.switchSceneMode,u.set2d=g=>u.switchSceneMode(g),u.is2dMode=()=>A.is2d,u.setMouseControlMode=g=>A.setMouseHabit(g),u.setMouseHabit=u.setMouseControlMode,u.setCollisionEnabled=g=>A.setCollisionDetection(g),u.setCollisionDetection=u.setCollisionEnabled,u.searchAndLocate=(g,P)=>A.searchLocation(g,P),u.searchLocation=u.searchAndLocate,u.getConfigure=()=>(console.warn("getConfigure is not initialized. Please ensure LeitingSetting component is mounted."),{}),u.setConfigure=g=>{console.warn("setConfigure is not initialized. Please ensure LeitingSetting component is mounted.",g)},u.addCadModel=g=>{const P={...g};return P.files&&!P.fileNames&&(P.fileNames=P.files),P.fileNames||(P.fileNames=[]),y.addDxfModel(P)},u.addDxfModel=u.addCadModel,u.deleteCad=g=>y.deleteCad(g),u.deleteAllCad=()=>y.deleteAllCad(),u.showCadModel=g=>y.showJson(g),u.showGeoJson=g=>y.showJson(g),u.showDxfModel=u.showCadModel,u.showCadLayer=g=>y.showJsonByLayer(g),u.showDxfLayer=u.showCadLayer,u.flyToCadModel=(g={})=>y.flyToCadModel(g),u.getCadModels=g=>y.getDxfModels(g),u.getDxfModels=u.getCadModels,u.getCadLayers=g=>y.getMapLayers(g),u.getDxfLayers=u.getCadLayers,u.getCadModelId=()=>y.getModelId(),u.setCadOpen=g=>y.setDxfOpen(g),u.setDxfOpen=u.setCadOpen,u.getCadOpen=()=>y.getDxfOpen(),u.getDxfOpen=u.getCadOpen,u.adjustCadModel=g=>y.adjustingModelByCad(g),u.adjustingModelByCad=u.adjustCadModel,u.saveAnnotations=()=>{let g=null;return S&&(g=S.saveAnnotations()),o?.saveAnnotations&&o.saveAnnotations(g),g},u.loadAnnotations=g=>S?S.loadAnnotations(g):!1,u.flyToTopView=()=>{y.flyToCadModel()},u.menuEvents=l,u.addMenuItems=g=>{l.emit("insertMenu",g)},u.insertMenu=u.addMenuItems,u.filterMenuItems=g=>{l.emit("setMenuListFilter",g)},u.setMenuListFilter=u.filterMenuItems,u.setMenuVisibility=g=>{l.emit("showMenu",g)},u.showMenu=u.setMenuVisibility,u.setPanelVisibility=(g,P)=>{l.emit("setMenuActive",g,P)},u.setMenuActive=u.setPanelVisibility,u.addContextMenuItems=g=>{console.warn("addContextMenuItems is not initialized yet. Please wait for LeitingBIM component to mount.",g)},u.insertContextMenu=u.addContextMenuItems,u.removeContextMenuItems=g=>{console.warn("removeContextMenuItems is not initialized yet.",g)},u.deleteContextMenu=u.removeContextMenuItems,u.closeContextMenu=()=>{console.warn("closeContextMenu is not initialized yet.")},u.hideContextMenu=u.closeContextMenu,u.getModelTree=()=>{const g=[],P=E.getMapTileset();return Object.keys(P).forEach(x=>{const F=P[x];if(F&&F.leiting&&F.leiting.tree){const _=F.leiting.tree;Array.isArray(_)?g.push(..._):g.push(_)}}),g},u.getTree=u.getModelTree,u.getAllComponentDetails=()=>{const g=E.getMapTileset(),P={},x=[];try{Object.keys(g).forEach(F=>{const _=g[F];if(!_||!_.leiting)return;const H=_.leiting,N=H.node,w=H.model.formData,C=H.box;if(!N||!N.nodeExtras)return;const b=H.model.modelId;P[b]=N.nodeExtras;const D=N.nodeExtras.element;if(!D)return;const k=C?C.center:{x:0,y:0,z:0};Object.values(D).forEach(Q=>{if(Q.box3)try{const R=a.Quaternion.fromAxisAngle(a.Cartesian3.UNIT_Z,a.Math.toRadians(w.totalRotation||0)),T=a.Matrix4.fromRotationTranslation(a.Matrix3.fromQuaternion(R),new a.Cartesian3(0,0,0)),U=a.Cartesian3.fromDegrees(w.longitude,w.latitude,w.height),V=a.Transforms.eastNorthUpToFixedFrame(U);a.Matrix4.multiply(V,T,V);const W=new a.Cartesian3(k.x,k.y,0),q=new a.Cartesian3;a.Matrix4.multiplyByPoint(V,W,q);const ie=a.Cartographic.fromCartesian(q),ae=Q.box3?.Center?.x||0,ne=Q.box3?.Center?.y||0,Y=Q.box3?.Center?.z||0,j=new a.Cartesian3(-k.x+ae,-k.y+ne,0+Y),ee=a.Matrix4.fromTranslation(j),le=a.Matrix4.clone(ee);a.Matrix4.multiply(T,le,le);const oe=a.Cartesian3.fromDegrees(ie.longitude/Math.PI*180,ie.latitude/Math.PI*180,w.height),ce=a.Transforms.eastNorthUpToFixedFrame(oe);a.Matrix4.multiply(ce,le,ce);const ve=a.Cartographic.fromCartesian(new a.Cartesian3(ce[12],ce[13],ce[14]));Q.box3.cartographic={longitude:ve.longitude/Math.PI*180,latitude:ve.latitude/Math.PI*180,height:ve.height};const Te={id:Q.uniqueId,billboard:[{theme:"Tag9999",position:[Q.box3.cartographic.longitude,Q.box3.cartographic.latitude,Q.box3.cartographic.height],options:{text:Q.name}}]};x.push(Te)}catch(R){console.warn("Error calculating component position:",R)}})})}catch(F){console.error("getAllComponents error:",F)}return P},u.getAllComponents=u.getAllComponentDetails,u.getComponentInfoList=g=>{if(!Array.isArray(g))return[];const P=E.getMapTileset(),x=[],F={};g.forEach(_=>{!_.modelId||!_.elementId||(F[_.modelId]||(F[_.modelId]=[]),F[_.modelId]?.push(_.elementId))});try{Object.keys(F).forEach(_=>{const H=P[_];if(!H||!H.leiting)return;const N=H.leiting,w=N.node,C=N.model.formData,b=N.box;if(!w||!w.nodeExtras)return;const D=w.nodeExtras.element;if(!D)return;const k=b?b.center:{x:0,y:0,z:0};F[_]?.forEach(Q=>{const R=D[Q];if(R&&R.box3)try{const T=a.Quaternion.fromAxisAngle(a.Cartesian3.UNIT_Z,a.Math.toRadians(C.totalRotation||0)),U=a.Matrix4.fromRotationTranslation(a.Matrix3.fromQuaternion(T),new a.Cartesian3(0,0,0)),V=a.Cartesian3.fromDegrees(C.longitude,C.latitude,C.height),W=a.Transforms.eastNorthUpToFixedFrame(V);a.Matrix4.multiply(W,U,W);const q=new a.Cartesian3(k.x,k.y,0),ie=new a.Cartesian3;a.Matrix4.multiplyByPoint(W,q,ie);const ae=a.Cartographic.fromCartesian(ie),ne=R.box3?.Center?.x||0,Y=R.box3?.Center?.y||0,j=R.box3?.Center?.z||0,ee=new a.Cartesian3(-k.x+ne,-k.y+Y,0+j),le=a.Matrix4.fromTranslation(ee),oe=a.Matrix4.clone(le);a.Matrix4.multiply(U,oe,oe);const ce=a.Cartesian3.fromDegrees(ae.longitude/Math.PI*180,ae.latitude/Math.PI*180,C.height),ve=a.Transforms.eastNorthUpToFixedFrame(ce);a.Matrix4.multiply(ve,oe,ve);const Te=a.Cartographic.fromCartesian(new a.Cartesian3(ve[12],ve[13],ve[14]));R.box3.cartographic={longitude:Te.longitude/Math.PI*180,latitude:Te.latitude/Math.PI*180,height:Te.height},R.elementId=Q,R.modelId=_,x.push(R)}catch(T){console.warn("Error calculating component position:",T)}})})}catch(_){console.error("getCptInfos error:",_)}return x},u.getCptInfos=u.getComponentInfoList,u.baseCompt=m.baseCompt,window.Methods=u}return console.log("methods",u),{Cesium:a,viewer:f,methods:u,menuEvents:l}}const we=c.reactive({visible:!1,type:"info",title:"",description:"",closable:!1,showIcon:!0,duration:3});let ye=null,il=null,nl=!1,xs=null,on=null,Ss=null;function hy(){if(on||typeof document>"u")return;const i=`
50
50
  .tech-alert-wrapper {
51
51
  position: absolute;
52
52
  top: 20px;