leiting-bim 2.1.70 → 2.1.72

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.

Potentially problematic release.


This version of leiting-bim might be problematic. Click here for more details.

Files changed (58) hide show
  1. package/leiting-bim.es.js +1 -1
  2. package/leiting-bim.umd.js +1 -1
  3. package/package.json +1 -1
  4. package/plugins/cesium-core/dist/cesium-core.mjs +20 -20
  5. package/plugins/cesium-core/dist/cesium-core.mjs.map +1 -1
  6. package/plugins/cesium-core/dist/cesium-core.umd.js +2 -2
  7. package/plugins/cesium-core/dist/cesium-core.umd.js.map +1 -1
  8. package/plugins/cesium-core/package.json +1 -1
  9. package/plugins/cesium-vue/dist/cesium-vue/src/components/basic-audio/index.d.ts +13 -0
  10. package/plugins/cesium-vue/dist/cesium-vue/src/components/basic-video/index.d.ts +98 -0
  11. package/plugins/cesium-vue/dist/cesium-vue/src/components/card-carousel/index.d.ts +147 -0
  12. package/plugins/cesium-vue/dist/cesium-vue/src/components/card-content/index.d.ts +16 -0
  13. package/plugins/cesium-vue/dist/cesium-vue/src/components/card-page/index.d.ts +64 -0
  14. package/plugins/cesium-vue/dist/cesium-vue/src/components/carousel-img/index.d.ts +34 -0
  15. package/plugins/cesium-vue/dist/cesium-vue/src/components/echarts-pro/index.d.ts +63 -0
  16. package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-bubble/index.d.ts +73 -0
  17. package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-default/index.d.ts +43 -0
  18. package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-html/index.d.ts +43 -0
  19. package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-manage/index.d.ts +159 -0
  20. package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-text/index.d.ts +25 -0
  21. package/plugins/cesium-vue/dist/cesium-vue/src/components/measurement/index.d.ts +73 -0
  22. package/plugins/cesium-vue/dist/cesium-vue/src/components/position-picker/index.d.ts +58 -0
  23. package/plugins/cesium-vue/dist/cesium-vue/src/index.d.ts +46 -0
  24. package/plugins/cesium-vue/dist/components/basic-audio.d.ts +3 -3
  25. package/plugins/cesium-vue/dist/components/basic-audio.js.map +1 -1
  26. package/plugins/cesium-vue/dist/components/basic-video.d.ts +3 -3
  27. package/plugins/cesium-vue/dist/components/basic-video.js.map +1 -1
  28. package/plugins/cesium-vue/dist/components/card-carousel.d.ts +3 -3
  29. package/plugins/cesium-vue/dist/components/card-carousel.js.map +1 -1
  30. package/plugins/cesium-vue/dist/components/card-content.d.ts +3 -3
  31. package/plugins/cesium-vue/dist/components/card-content.js.map +1 -1
  32. package/plugins/cesium-vue/dist/components/card-page.d.ts +3 -3
  33. package/plugins/cesium-vue/dist/components/card-page.js.map +1 -1
  34. package/plugins/cesium-vue/dist/components/carousel-img.d.ts +3 -3
  35. package/plugins/cesium-vue/dist/components/carousel-img.js.map +1 -1
  36. package/plugins/cesium-vue/dist/components/echarts-pro.d.ts +3 -3
  37. package/plugins/cesium-vue/dist/components/marker-bubble.d.ts +3 -3
  38. package/plugins/cesium-vue/dist/components/marker-bubble.js.map +1 -1
  39. package/plugins/cesium-vue/dist/components/marker-default.d.ts +3 -3
  40. package/plugins/cesium-vue/dist/components/marker-default.js.map +1 -1
  41. package/plugins/cesium-vue/dist/components/marker-html.d.ts +3 -3
  42. package/plugins/cesium-vue/dist/components/marker-html.js.map +1 -1
  43. package/plugins/cesium-vue/dist/components/marker-manage.d.ts +3 -3
  44. package/plugins/cesium-vue/dist/components/marker-manage.js +211 -194
  45. package/plugins/cesium-vue/dist/components/marker-manage.js.map +1 -1
  46. package/plugins/cesium-vue/dist/components/marker-text.d.ts +3 -3
  47. package/plugins/cesium-vue/dist/components/marker-text.js.map +1 -1
  48. package/plugins/cesium-vue/dist/components/measurement.d.ts +3 -3
  49. package/plugins/cesium-vue/dist/components/measurement.js.map +1 -1
  50. package/plugins/cesium-vue/dist/components/position-picker.d.ts +3 -3
  51. package/plugins/cesium-vue/dist/components/position-picker.js.map +1 -1
  52. package/plugins/cesium-vue/dist/index-CUs_hd1V.js.map +1 -1
  53. package/plugins/cesium-vue/dist/index-Kdqw0FJN.js.map +1 -1
  54. package/plugins/cesium-vue/dist/index.d.ts +6 -46
  55. package/plugins/cesium-vue/dist/index.js.map +1 -1
  56. package/plugins/cesium-vue/package.json +4 -4
  57. package/plugins/theme-chalk/package.json +1 -1
  58. package/plugins/utils/package.json +1 -1
@@ -95,7 +95,7 @@
95
95
  ${r}
96
96
  <!-- 关闭按钮 -->
97
97
  ${l}
98
- `;this.promptDiv=window.document.createElement("div"),this.promptDiv.className=`easy3d-prompt ${this.opt.className}`,this.promptDiv.id=f,this.promptDiv.innerHTML=p,window.document.getElementById(o).appendChild(this.promptDiv);const A=window.document.getElementById(`prompt-close-${this.opt.id}`);let C=this;A&&A.addEventListener("click",m=>{C.hide(),C.opt.close&&C.opt.close()}),this.promptDom=window.document.getElementById(f),this.position=this.transPosition(this.opt.position),i==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 i=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),i&&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 Oa=Object.freeze(Object.defineProperty({__proto__:null,default:yt},Symbol.toStringTag,{value:"Module"}));let ce={};ce.cartesianToLnglat=function(n,e){if(!n)return[];var t=Cesium.Cartographic.fromCartesian(n),i=Cesium.Math.toDegrees(t.latitude),s=Cesium.Math.toDegrees(t.longitude),o=t.height;return[s,i,o]},ce.getViewCenter=n=>{if(n){var e=n.camera.computeViewRectangle(),t=e.west/Math.PI*180,i=e.north/Math.PI*180,s=e.east/Math.PI*180,o=e.south/Math.PI*180;return[(s+t)/2,(i+o)/2]}},ce.cartesiansToLnglats=function(n,e){if(!(!n||n.length<1)){if(e=e||window.viewer,!e){console.log("util.cartesiansToLnglats方法缺少viewer对象");return}for(var t=[],i=0;i<n.length;i++)t.push(ce.cartesianToLnglat(n[i],e));return t}},ce.lnglatsToCartesians=function(n){if(!(!n||n.length<1)){for(var e=[],t=0;t<n.length;t++){var i=Cesium.Cartesian3.fromDegrees(n[t][0],n[t][1],n[t][2]||0);e.push(i)}return e}},ce.flyTo=function(n,e){if(!e){console.log("util.flyTo缺少viewer对象");return}n=n||{};let t=n.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(n.heading||0),Cesium.Math.toRadians(n.pitch||-60),n.range||1e4)}),t instanceof Array){var i=new Cesium.BoundingSphere(Cesium.Cartesian3.fromDegrees(t[0],t[1],t[2]));e.camera.flyToBoundingSphere(i,{offset:new Cesium.HeadingPitchRange(Cesium.Math.toRadians(n.heading||0),Cesium.Math.toRadians(n.pitch||-60),n.range||1e4)})}},ce.getCameraView=function(n){if(n=n||window.viewer,!n){console.log("util.getCameraView缺少viewer对象");return}var e=n.camera,t=e.position,i=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(i),pitch:Cesium.Math.toDegrees(s),roll:Cesium.Math.toDegrees(o)};return l},ce.setCameraView=function(n,e){if(e=e||window.viewer,!e){console.log("util.setCameraView缺少viewer对象");return}if(n){var t=n.destination||Cesium.Cartesian3.fromDegrees(n.x,n.y,n.z);e.camera.flyTo({destination:t,orientation:{heading:Cesium.Math.toRadians(n.heading||0),pitch:Cesium.Math.toRadians(n.pitch||0),roll:Cesium.Math.toRadians(n.roll||0)},duration:n.duration===void 0?3:n.duration,complete:n.complete})}},ce.computeAreaOfTriangle=function(n,e,t){if(!n||!e||!t)return console.log("传入坐标有误!"),0;var i=Cesium.Cartesian3.distance(n,e),s=Cesium.Cartesian3.distance(e,t),o=Cesium.Cartesian3.distance(t,n),r=(i+s+o)/2;return Math.sqrt(r*(r-i)*(r-s)*(r-o))};class tt{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 i,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)i=this.viewer.scene.pickPosition(e);else{let o=this.viewer.camera.getPickRay(e);if(!o)return null;i=this.viewer.scene.globe.pick(o,this.viewer.scene)}return i}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?ce.cartesiansToLnglats(this.positions,this.viewer):this.positions}getLnglats(){return ce.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 i=0;i<t.controlPoints.length;i++){let s=t.controlPoints[i];s&&(s.show=!0)}this.entity.show=!0,this.modifyHandler.setInputAction(function(i){if(!t.entity)return;let s=t.viewer.scene.pick(i.position);Cesium.defined(s)&&s.id&&(s.id.objId||(t.modifyPoint=s.id),t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(i){if(t.positions.length<1||!t.modifyPoint)return;let s=t.getCatesian3FromPX(i.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(i){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 i=this.controlPoints[t];i&&(i.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 i=this.pointStyle.outlineColor instanceof Cesium.Color?this.pointStyle.outlineColor:Cesium.Color.fromCssColorString(this.pointStyle.outlineColor);return i=i.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:i,disableDepthTestDistance:Number.POSITIVE_INFINITY},show:!1})}transfromLineMaterial(e){if(!e)return;let t={};if(e instanceof Cesium.Color){let i=e.color.getValue();t.colorAlpha=i.alpha,t.colorHex=new Cesium.Color(i.red,i.green,i.blue,1).toCssHexString()}return t}transfromGonMaterial(e){if(!e)return;let t={};if(e instanceof Cesium.Color){let i=e.color.getValue();t.colorAlpha=i.alpha,t.colorHex=new Cesium.Color(i.red,i.green,i.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 jg="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 $g extends tt{constructor(e,t){super(e,t),this.type="billboard",this.viewer=e;let i={verticalOrigin:Cesium.VerticalOrigin.BOTTOM,scale:1};this.style=Object.assign({},i,t||{}),this.entity=null,this.style.hasOwnProperty("image")||console.warn("CreateBillboard: 未在 style 中指定 image,后续将使用回退图或占位图。"),this.position=null,this._defaultFallback=jg,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((i,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(c),i(o))},a=u=>{r||(r=!0,clearTimeout(c),s(new Error("image load error: "+e)))};o.onload=l,o.onerror=a;const c=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,i=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}});i.objId=this.objId;const s=this.style.image;if(s)this._preloadImage(s,7e3).then(o=>{try{i.billboard.image=o,this.style.image=s}catch(r){console.warn("CreateBillboard: set billboard image element failed, fallback to url string",r);try{i.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=i,i}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(i=>{try{this.entity.billboard.image=i}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(i=>{console.error("CreateBillboard: updateBillboardImage failed to load:",i.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 yt(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(i){let s=t.getCatesian3FromPX(i.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(i){t.prompt&&t.prompt.update&&t.prompt.update(i.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 i=null;e instanceof Cesium.Cartesian3?i=e.clone():i=Cesium.Cartesian3.fromDegrees(Number(e[0]),Number(e[1]),Number(e[2]||0)),i&&(this.position=i.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 i=1;e.heightReference==!0?i=1:i=Number(e.heightReference);try{t.heightReference=i}catch{}}if(e.scale!=null)try{t.scale=Number(e.scale)}catch{}if(e.color){let i=e.color instanceof Cesium.Color?e.color:Cesium.Color.fromCssColorString(e.color);i=i.withAlpha(e.colorAlpha||1);try{t.color=i}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 i=t.heightReference.getValue();e.heightReference=Number(i)}catch{}if(t&&t.scale)try{e.scale=t.scale.getValue()}catch{}if(t&&t.color)try{let i=t.color.getValue();e.colorAlpha=i.alpha,e.color=new Cesium.Color(i.red,i.green,i.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,i=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)}i=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){i=l.id,s=!0,t._isDragging=!0,t._editPickedEntity=i,t.modifyPoint=null;try{t.forbidDrawWorld(!0)}catch{}}else if(t.controlPoints.includes(l.id)){t.modifyPoint=l.id,s=!0,t._isDragging=!0,i=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(i)){try{i.position.setValue(l)}catch{i.position=l}t.position=l.clone(),t.controlPoints&&t.controlPoints.length>0&&t.controlPoints.forEach(a=>{try{a.position.setValue(l)}catch(c){console.warn("更新控制点位置失败:",c);try{a.position=l.clone()}catch(u){console.error("重新设置控制点位置失败:",u)}}})}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 i=Cesium.Color.GREEN;t==="bottomLeft"&&(i=Cesium.Color.BLUE);const s=this.viewer.entities.add({position:e,point:{pixelSize:10,color:i,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 c=new Cesium.Cartesian3;Cesium.Cartesian3.multiplyByScalar(l,s,c),Cesium.Cartesian3.multiplyByScalar(a,s,a),Cesium.Cartesian3.add(c,a,c);const u=new Cesium.Ray(e,r),f=this.viewer.scene.globe.pick(u,this.viewer.scene),h=Cesium.Cartesian3.distance(e,f||e)*.001;return Cesium.Cartesian3.multiplyByScalar(c,h,c),Cesium.Cartesian3.add(e,c,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(i){console.warn("更新拖拽中控制点位置失败:",i)}}});return}if(this.controlPoints.length>0&&([...this.controlPoints].forEach(t=>{try{this.viewer&&this.viewer.entities&&t&&this.viewer.entities.remove(t)}catch(i){console.warn("移除控制点失败:",i)}}),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(i){console.warn("移除控制点失败:",i)}}),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 i=new FileReader;i.onload=s=>{this.updateBillboardImage(s.target.result),this._fileInput&&(this._fileInput.value="")},i.onerror=s=>{console.error("文件读取失败:",s)},i.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?ce.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 Kg extends tt{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 yt(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(i){const s=t.getCatesian3FromPX(i.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(i){if(!t.entity){t.prompt?.update(i.endPosition,"单击开始绘制");return}t.prompt?.update(i.endPosition,"单击结束");const s=t.getCatesian3FromPX(i.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(i){const s=t.viewer.scene.pick(i.position);if(!s?.id)return;t.modifyPoint=s.id;const o=t.getCatesian3FromPX(i.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(i){if(!t.modifyPoint)return;const s=t.getCatesian3FromPX(i.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,i=t.cartesianToCartographic(this.center),s=t.cartesianToCartographic(this.radiusPoint),o=Math.abs(s.longitude-i.longitude),r=Math.abs(s.latitude-i.latitude);for(let l=0;l<=this.pointsCount;l++){const a=l/this.pointsCount*Math.PI*2,c=i.longitude+o*Math.cos(a),u=i.latitude+r*Math.sin(a);e.push(Cesium.Cartesian3.fromRadians(c,u))}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 i=t.x-e.x,s=t.y-e.y,o=t.z-e.z;this.center=new Cesium.Cartesian3(this.center.x+i,this.center.y+s,this.center.z+o),this.radiusPoint=new Cesium.Cartesian3(this.radiusPoint.x+i,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?ce.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 i=t.color instanceof Cesium.Color?t.color:Cesium.Color.fromCssColorString(t.color||"#00FF00");t.colorAlpha!=null&&(i=i.withAlpha(t.colorAlpha)),this.entity.polyline.material=i,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 i=e[0]instanceof Cesium.Cartesian3?e:ce.lnglatsToCartesians(e);if(!i||i.length===0)return console.error("createByPositions: failed to convert positions to Cartesian3"),t&&t(null),this;if(i.length>=2)this.center=Cesium.Cartesian3.clone(i[0]),this.radiusPoint=Cesium.Cartesian3.clone(i[1]);else if(i.length===1)this.center=Cesium.Cartesian3.clone(i[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(i){return console.error("createByPositions error:",i),t&&t(null),this}}}class qg extends tt{constructor(e,t){if(super(e,t),this.type="gltfModel",t=t||{},this.viewer=e,!t.uri){console.warn("请输入模型地址!");return}let i={heading:0,pitch:0,roll:0,minimumPixelSize:24,maximumScale:120};this.style=Object.assign(i,t||{}),this.modelUri=t.uri,this.entity=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new yt(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(i){let s=t.getCatesian3FromPX(i.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(i){t.prompt.update(i.endPosition,"单击新增"),t.state="creating";let s=t.getCatesian3FromPX(i.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,i;this.state="startEdit",this.modifyHandler.setInputAction(function(s){let o=t.viewer.scene.pick(s.position);Cesium.defined(o)&&o.id&&(i=o.id,t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(s){if(!i)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){i&&(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),i=Cesium.Math.toRadians(this.style.pitch),s=Cesium.Math.toRadians(this.style.roll),o=new Cesium.HeadingPitchRoll(t,i,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?ce.cartesianToLnglat(this.position,this.viewer):this.position}getStyle(){let e={},t=this.entity.model;e.minimumPixelSize=t.minimumPixelSize.getValue();let i=this.entity.orientation.getValue(),s=this.entity.position.getValue(this.viewer.clock.currentTime),o=ce.oreatationToHpr(s.clone(),i,!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,i){e=e||0,t=t||0,i=i||0,this.style.heading=e,this.style.pitch=t,this.style.roll=i;var s=Cesium.Math.toRadians(e||0),o=Cesium.Math.toRadians(t||0),r=Cesium.Math.toRadians(i||0),l=new Cesium.HeadingPitchRoll(s,o,r),a=this.entity.position._value,c=Cesium.Transforms.headingPitchRollQuaternion(a,l);this.entity&&(this.entity.orientation=c)}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 n=(function(){try{var t={},i=Object.defineProperty,s=i(t,t,t)&&i}catch{}return s})(),e=function(t){if(this==null)throw TypeError();var i=String(this),s=i.length,o=t?Number(t):0;if(o!=o&&(o=0),!(o<0||o>=s)){var r=i.charCodeAt(o),l;return r>=55296&&r<=56319&&s>o+1&&(l=i.charCodeAt(o+1),l>=56320&&l<=57343)?(r-55296)*1024+l-56320+65536:r}};n?n(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e})();function nn(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Hs,La;function Xg(){if(La)return Hs;La=1;var n=0,e=-3;function t(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function i(g,R){this.source=g,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=R,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),c=new Uint16Array(30),u=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),f=new t,p=new Uint8Array(320);function h(g,R,M,F){var L,G;for(L=0;L<M;++L)g[L]=0;for(L=0;L<30-M;++L)g[L+M]=L/M|0;for(G=F,L=0;L<30;++L)R[L]=G,G+=1<<g[L]}function A(g,R){var M;for(M=0;M<7;++M)g.table[M]=0;for(g.table[7]=24,g.table[8]=152,g.table[9]=112,M=0;M<24;++M)g.trans[M]=256+M;for(M=0;M<144;++M)g.trans[24+M]=M;for(M=0;M<8;++M)g.trans[168+M]=280+M;for(M=0;M<112;++M)g.trans[176+M]=144+M;for(M=0;M<5;++M)R.table[M]=0;for(R.table[5]=32,M=0;M<32;++M)R.trans[M]=M}var C=new Uint16Array(16);function m(g,R,M,F){var L,G;for(L=0;L<16;++L)g.table[L]=0;for(L=0;L<F;++L)g.table[R[M+L]]++;for(g.table[0]=0,G=0,L=0;L<16;++L)C[L]=G,G+=g.table[L];for(L=0;L<F;++L)R[M+L]&&(g.trans[C[R[M+L]]++]=L)}function y(g){g.bitcount--||(g.tag=g.source[g.sourceIndex++],g.bitcount=7);var R=g.tag&1;return g.tag>>>=1,R}function E(g,R,M){if(!R)return M;for(;g.bitcount<24;)g.tag|=g.source[g.sourceIndex++]<<g.bitcount,g.bitcount+=8;var F=g.tag&65535>>>16-R;return g.tag>>>=R,g.bitcount-=R,F+M}function I(g,R){for(;g.bitcount<24;)g.tag|=g.source[g.sourceIndex++]<<g.bitcount,g.bitcount+=8;var M=0,F=0,L=0,G=g.tag;do F=2*F+(G&1),G>>>=1,++L,M+=R.table[L],F-=R.table[L];while(F>=0);return g.tag=G,g.bitcount-=L,R.trans[M+F]}function S(g,R,M){var F,L,G,N,v,w;for(F=E(g,5,257),L=E(g,5,1),G=E(g,4,4),N=0;N<19;++N)p[N]=0;for(N=0;N<G;++N){var b=E(g,3,0);p[u[N]]=b}for(m(f,p,0,19),v=0;v<F+L;){var T=I(g,f);switch(T){case 16:var P=p[v-1];for(w=E(g,2,3);w;--w)p[v++]=P;break;case 17:for(w=E(g,3,3);w;--w)p[v++]=0;break;case 18:for(w=E(g,7,11);w;--w)p[v++]=0;break;default:p[v++]=T;break}}m(R,p,0,F),m(M,p,F,L)}function k(g,R,M){for(;;){var F=I(g,R);if(F===256)return n;if(F<256)g.dest[g.destLen++]=F;else{var L,G,N,v;for(F-=257,L=E(g,r[F],l[F]),G=I(g,M),N=g.destLen-E(g,a[G],c[G]),v=N;v<N+L;++v)g.dest[g.destLen++]=g.dest[v]}}}function B(g){for(var R,M,F;g.bitcount>8;)g.sourceIndex--,g.bitcount-=8;if(R=g.source[g.sourceIndex+1],R=256*R+g.source[g.sourceIndex],M=g.source[g.sourceIndex+3],M=256*M+g.source[g.sourceIndex+2],R!==(~M&65535))return e;for(g.sourceIndex+=4,F=R;F;--F)g.dest[g.destLen++]=g.source[g.sourceIndex++];return g.bitcount=0,n}function x(g,R){var M=new i(g,R),F,L,G;do{switch(F=y(M),L=E(M,2,0),L){case 0:G=B(M);break;case 1:G=k(M,s,o);break;case 2:S(M,M.ltree,M.dtree),G=k(M,M.ltree,M.dtree);break;default:G=e}if(G!==n)throw new Error("Data error")}while(!F);return M.destLen<M.dest.length?typeof M.dest.slice=="function"?M.dest.slice(0,M.destLen):M.dest.subarray(0,M.destLen):M.dest}return A(s,o),h(r,l,4,3),h(a,c,2,1),r[28]=0,l[28]=258,Hs=x,Hs}var Jg=Xg();const Zg=nn(Jg);function sn(n,e,t,i,s){return Math.pow(1-s,3)*n+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*t+Math.pow(s,3)*i}function Ct(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}Ct.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},Ct.prototype.addPoint=function(n,e){typeof n=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=n,this.x2=n),n<this.x1&&(this.x1=n),n>this.x2&&(this.x2=n)),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))},Ct.prototype.addX=function(n){this.addPoint(n,null)},Ct.prototype.addY=function(n){this.addPoint(null,n)},Ct.prototype.addBezier=function(n,e,t,i,s,o,r,l){const a=[n,e],c=[t,i],u=[s,o],f=[r,l];this.addPoint(n,e),this.addPoint(r,l);for(let p=0;p<=1;p++){const h=6*a[p]-12*c[p]+6*u[p],A=-3*a[p]+9*c[p]-9*u[p]+3*f[p],C=3*c[p]-3*a[p];if(A===0){if(h===0)continue;const I=-C/h;0<I&&I<1&&(p===0&&this.addX(sn(a[p],c[p],u[p],f[p],I)),p===1&&this.addY(sn(a[p],c[p],u[p],f[p],I)));continue}const m=Math.pow(h,2)-4*C*A;if(m<0)continue;const y=(-h+Math.sqrt(m))/(2*A);0<y&&y<1&&(p===0&&this.addX(sn(a[p],c[p],u[p],f[p],y)),p===1&&this.addY(sn(a[p],c[p],u[p],f[p],y)));const E=(-h-Math.sqrt(m))/(2*A);0<E&&E<1&&(p===0&&this.addX(sn(a[p],c[p],u[p],f[p],E)),p===1&&this.addY(sn(a[p],c[p],u[p],f[p],E)))}},Ct.prototype.addQuad=function(n,e,t,i,s,o){const r=n+.6666666666666666*(t-n),l=e+2/3*(i-e),a=r+1/3*(s-n),c=l+1/3*(o-e);this.addBezier(n,e,r,l,a,c,s,o)};function Ie(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}Ie.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})},Ie.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})},Ie.prototype.curveTo=Ie.prototype.bezierCurveTo=function(n,e,t,i,s,o){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:o})},Ie.prototype.quadTo=Ie.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})},Ie.prototype.close=Ie.prototype.closePath=function(){this.commands.push({type:"Z"})},Ie.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Ct){const e=n;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,n)},Ie.prototype.getBoundingBox=function(){const n=new Ct;let e=0,t=0,i=0,s=0;for(let o=0;o<this.commands.length;o++){const r=this.commands[o];switch(r.type){case"M":n.addPoint(r.x,r.y),e=i=r.x,t=s=r.y;break;case"L":n.addPoint(r.x,r.y),i=r.x,s=r.y;break;case"Q":n.addQuad(i,s,r.x1,r.y1,r.x,r.y),i=r.x,s=r.y;break;case"C":n.addBezier(i,s,r.x1,r.y1,r.x2,r.y2,r.x,r.y),i=r.x,s=r.y;break;case"Z":i=e,s=t;break;default:throw new Error("Unexpected path command "+r.type)}}return n.isEmpty()&&n.addPoint(0,0),n},Ie.prototype.draw=function(n){n.beginPath();for(let e=0;e<this.commands.length;e+=1){const t=this.commands[e];t.type==="M"?n.moveTo(t.x,t.y):t.type==="L"?n.lineTo(t.x,t.y):t.type==="C"?n.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):t.type==="Q"?n.quadraticCurveTo(t.x1,t.y1,t.x,t.y):t.type==="Z"&&n.closePath()}this.fill&&(n.fillStyle=this.fill,n.fill()),this.stroke&&(n.strokeStyle=this.stroke,n.lineWidth=this.strokeWidth,n.stroke())},Ie.prototype.toPathData=function(n){n=n!==void 0?n:2;function e(s){return Math.round(s)===s?""+Math.round(s):s.toFixed(n)}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 i="";for(let s=0;s<this.commands.length;s+=1){const o=this.commands[s];o.type==="M"?i+="M"+t(o.x,o.y):o.type==="L"?i+="L"+t(o.x,o.y):o.type==="C"?i+="C"+t(o.x1,o.y1,o.x2,o.y2,o.x,o.y):o.type==="Q"?i+="Q"+t(o.x1,o.y1,o.x,o.y):o.type==="Z"&&(i+="Z")}return i},Ie.prototype.toSVG=function(n){let e='<path d="';return e+=this.toPathData(n),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},Ie.prototype.toDOMElement=function(n){const e=this.toPathData(n),t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",e),t};function Na(n){throw new Error(n)}function Ua(n,e){n||Na(e)}const ie={fail:Na,argument:Ua,assert:Ua},_a=32768,Qa=2147483648,on={},j={},te={};function Ge(n){return function(){return n}}j.BYTE=function(n){return ie.argument(n>=0&&n<=255,"Byte value should be between 0 and 255."),[n]},te.BYTE=Ge(1),j.CHAR=function(n){return[n.charCodeAt(0)]},te.CHAR=Ge(1),j.CHARARRAY=function(n){const e=[];for(let t=0;t<n.length;t+=1)e[t]=n.charCodeAt(t);return e},te.CHARARRAY=function(n){return n.length},j.USHORT=function(n){return[n>>8&255,n&255]},te.USHORT=Ge(2),j.SHORT=function(n){return n>=_a&&(n=-(2*_a-n)),[n>>8&255,n&255]},te.SHORT=Ge(2),j.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]},te.UINT24=Ge(3),j.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]},te.ULONG=Ge(4),j.LONG=function(n){return n>=Qa&&(n=-(2*Qa-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]},te.LONG=Ge(4),j.FIXED=j.ULONG,te.FIXED=te.ULONG,j.FWORD=j.SHORT,te.FWORD=te.SHORT,j.UFWORD=j.USHORT,te.UFWORD=te.USHORT,j.LONGDATETIME=function(n){return[0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255]},te.LONGDATETIME=Ge(8),j.TAG=function(n){return ie.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]},te.TAG=Ge(4),j.Card8=j.BYTE,te.Card8=te.BYTE,j.Card16=j.USHORT,te.Card16=te.USHORT,j.OffSize=j.BYTE,te.OffSize=te.BYTE,j.SID=j.USHORT,te.SID=te.USHORT,j.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?j.NUMBER16(n):j.NUMBER32(n)},te.NUMBER=function(n){return j.NUMBER(n).length},j.NUMBER16=function(n){return[28,n>>8&255,n&255]},te.NUMBER16=Ge(3),j.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]},te.NUMBER32=Ge(5),j.REAL=function(n){let e=n.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(n*o)/o).toString()}let i="";for(let o=0,r=e.length;o<r;o+=1){const l=e[o];l==="e"?i+=e[++o]==="-"?"c":"b":l==="."?i+="a":l==="-"?i+="e":i+=l}i+=i.length&1?"f":"ff";const s=[30];for(let o=0,r=i.length;o<r;o+=2)s.push(parseInt(i.substr(o,2),16));return s},te.REAL=function(n){return j.REAL(n).length},j.NAME=j.CHARARRAY,te.NAME=te.CHARARRAY,j.STRING=j.CHARARRAY,te.STRING=te.CHARARRAY,on.UTF8=function(n,e,t){const i=[],s=t;for(let o=0;o<s;o++,e+=1)i[o]=n.getUint8(e);return String.fromCharCode.apply(null,i)},on.UTF16=function(n,e,t){const i=[],s=t/2;for(let o=0;o<s;o++,e+=2)i[o]=n.getUint16(e);return String.fromCharCode.apply(null,i)},j.UTF16=function(n){const e=[];for(let t=0;t<n.length;t+=1){const i=n.charCodeAt(t);e[e.length]=i>>8&255,e[e.length]=i&255}return e},te.UTF16=function(n){return n.length*2};const Gs={"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":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};on.MACSTRING=function(n,e,t,i){const s=Gs[i];if(s===void 0)return;let o="";for(let r=0;r<t;r++){const l=n.getUint8(e+r);l<=127?o+=String.fromCharCode(l):o+=s[l&127]}return o};const mi=typeof WeakMap=="function"&&new WeakMap;let Ai;const em=function(n){if(!Ai){Ai={};for(let s in Gs)Ai[s]=new String(s)}const e=Ai[n];if(e===void 0)return;if(mi){const s=mi.get(e);if(s!==void 0)return s}const t=Gs[n];if(t===void 0)return;const i={};for(let s=0;s<t.length;s++)i[t.charCodeAt(s)]=s+128;return mi&&mi.set(e,i),i};j.MACSTRING=function(n,e){const t=em(e);if(t===void 0)return;const i=[];for(let s=0;s<n.length;s++){let o=n.charCodeAt(s);if(o>=128&&(o=t[o],o===void 0))return;i[s]=o}return i},te.MACSTRING=function(n,e){const t=j.MACSTRING(n,e);return t!==void 0?t.length:0};function Ys(n){return n>=-128&&n<=127}function tm(n,e,t){let i=0;const s=n.length;for(;e<s&&i<64&&n[e]===0;)++e,++i;return t.push(128|i-1),e}function nm(n,e,t){let i=0;const s=n.length;let o=e;for(;o<s&&i<64;){const r=n[o];if(!Ys(r)||r===0&&o+1<s&&n[o+1]===0)break;++o,++i}t.push(i-1);for(let r=e;r<o;++r)t.push(n[r]+256&255);return o}function im(n,e,t){let i=0;const s=n.length;let o=e;for(;o<s&&i<64;){const r=n[o];if(r===0||Ys(r)&&o+1<s&&Ys(n[o+1]))break;++o,++i}t.push(64|i-1);for(let r=e;r<o;++r){const l=n[r];t.push(l+65536>>8&255,l+256&255)}return o}j.VARDELTAS=function(n){let e=0;const t=[];for(;e<n.length;){const i=n[e];i===0?e=tm(n,e,t):i>=-128&&i<=127?e=nm(n,e,t):e=im(n,e,t)}return t},j.INDEX=function(n){let e=1;const t=[e],i=[];for(let l=0;l<n.length;l+=1){const a=j.OBJECT(n[l]);Array.prototype.push.apply(i,a),e+=a.length,t.push(e)}if(i.length===0)return[0,0];const s=[],o=1+Math.floor(Math.log(e)/Math.log(2))/8|0,r=[void 0,j.BYTE,j.USHORT,j.UINT24,j.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(j.Card16(n.length),j.OffSize(o),s,i)},te.INDEX=function(n){return j.INDEX(n).length},j.DICT=function(n){let e=[];const t=Object.keys(n),i=t.length;for(let s=0;s<i;s+=1){const o=parseInt(t[s],0),r=n[o];e=e.concat(j.OPERAND(r.value,r.type)),e=e.concat(j.OPERATOR(o))}return e},te.DICT=function(n){return j.DICT(n).length},j.OPERATOR=function(n){return n<1200?[n]:[12,n-1200]},j.OPERAND=function(n,e){let t=[];if(Array.isArray(e))for(let i=0;i<e.length;i+=1)ie.argument(n.length===e.length,"Not enough arguments given for type"+e),t=t.concat(j.OPERAND(n[i],e[i]));else if(e==="SID")t=t.concat(j.NUMBER(n));else if(e==="offset")t=t.concat(j.NUMBER32(n));else if(e==="number")t=t.concat(j.NUMBER(n));else if(e==="real")t=t.concat(j.REAL(n));else throw new Error("Unknown operand type "+e);return t},j.OP=j.BYTE,te.OP=te.BYTE;const yi=typeof WeakMap=="function"&&new WeakMap;j.CHARSTRING=function(n){if(yi){const i=yi.get(n);if(i!==void 0)return i}let e=[];const t=n.length;for(let i=0;i<t;i+=1){const s=n[i];e=e.concat(j[s.type](s.value))}return yi&&yi.set(n,e),e},te.CHARSTRING=function(n){return j.CHARSTRING(n).length},j.OBJECT=function(n){const e=j[n.type];return ie.argument(e!==void 0,"No encoding function for type "+n.type),e(n.value)},te.OBJECT=function(n){const e=te[n.type];return ie.argument(e!==void 0,"No sizeOf function for type "+n.type),e(n.value)},j.TABLE=function(n){let e=[];const t=n.fields.length,i=[],s=[];for(let o=0;o<t;o+=1){const r=n.fields[o],l=j[r.type];ie.argument(l!==void 0,"No encoding function for field type "+r.type+" ("+r.name+")");let a=n[r.name];a===void 0&&(a=r.value);const c=l(a);r.type==="TABLE"?(s.push(e.length),e=e.concat([0,0]),i.push(c)):e=e.concat(c)}for(let o=0;o<i.length;o+=1){const r=s[o],l=e.length;ie.argument(l<65536,"Table "+n.tableName+" too big."),e[r]=l>>8,e[r+1]=l&255,e=e.concat(i[o])}return e},te.TABLE=function(n){let e=0;const t=n.fields.length;for(let i=0;i<t;i+=1){const s=n.fields[i],o=te[s.type];ie.argument(o!==void 0,"No sizeOf function for field type "+s.type+" ("+s.name+")");let r=n[s.name];r===void 0&&(r=s.value),e+=o(r),s.type==="TABLE"&&(e+=2)}return e},j.RECORD=j.TABLE,te.RECORD=te.TABLE,j.LITERAL=function(n){return n},te.LITERAL=function(n){return n.length};function ke(n,e,t){for(let i=0;i<e.length;i+=1){const s=e[i];this[s.name]=s.value}if(this.tableName=n,this.fields=e,t){const i=Object.keys(t);for(let s=0;s<i.length;s+=1){const o=i[s],r=t[o];this[o]!==void 0&&(this[o]=r)}}}ke.prototype.encode=function(){return j.TABLE(this)},ke.prototype.sizeOf=function(){return te.TABLE(this)};function Mn(n,e,t){t===void 0&&(t=e.length);const i=new Array(e.length+1);i[0]={name:n+"Count",type:"USHORT",value:t};for(let s=0;s<e.length;s++)i[s+1]={name:n+s,type:"USHORT",value:e[s]};return i}function Vs(n,e,t){const i=e.length,s=new Array(i+1);s[0]={name:n+"Count",type:"USHORT",value:i};for(let o=0;o<i;o++)s[o+1]={name:n+o,type:"TABLE",value:t(e[o],o)};return s}function Ci(n,e,t){const i=e.length;let s=[];s[0]={name:n+"Count",type:"USHORT",value:i};for(let o=0;o<i;o++)s=s.concat(t(e[o],o));return s}function Ei(n){n.format===1?ke.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Mn("glyph",n.glyphs))):ie.assert(!1,"Can't create coverage table format 2 yet.")}Ei.prototype=Object.create(ke.prototype),Ei.prototype.constructor=Ei;function wi(n){ke.call(this,"scriptListTable",Ci("scriptRecord",n,function(e,t){const i=e.script;let s=i.defaultLangSys;return ie.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 ke("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new ke("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(Mn("featureIndex",s.featureIndexes)))}].concat(Ci("langSys",i.langSysRecords,function(o,r){const l=o.langSys;return[{name:"langSysTag"+r,type:"TAG",value:o.tag},{name:"langSys"+r,type:"TABLE",value:new ke("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:l.reqFeatureIndex}].concat(Mn("featureIndex",l.featureIndexes)))}]})))}]}))}wi.prototype=Object.create(ke.prototype),wi.prototype.constructor=wi;function bi(n){ke.call(this,"featureListTable",Ci("featureRecord",n,function(e,t){const i=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new ke("featureTable",[{name:"featureParams",type:"USHORT",value:i.featureParams}].concat(Mn("lookupListIndex",i.lookupListIndexes)))}]}))}bi.prototype=Object.create(ke.prototype),bi.prototype.constructor=bi;function vi(n,e){ke.call(this,"lookupListTable",Vs("lookup",n,function(t){let i=e[t.lookupType];return ie.assert(!!i,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new ke("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(Vs("subtable",t.subtables,i)))}))}vi.prototype=Object.create(ke.prototype),vi.prototype.constructor=vi;const Z={Table:ke,Record:ke,Coverage:Ei,ScriptList:wi,FeatureList:bi,LookupList:vi,ushortList:Mn,tableList:Vs,recordList:Ci};function Ha(n,e){return n.getUint8(e)}function Ii(n,e){return n.getUint16(e,!1)}function sm(n,e){return n.getInt16(e,!1)}function Ws(n,e){return n.getUint32(e,!1)}function Ga(n,e){const t=n.getInt16(e,!1),i=n.getUint16(e+2,!1);return t+i/65535}function om(n,e){let t="";for(let i=e;i<e+4;i+=1)t+=String.fromCharCode(n.getInt8(i));return t}function rm(n,e,t){let i=0;for(let s=0;s<t;s+=1)i<<=8,i+=n.getUint8(e+s);return i}function am(n,e,t){const i=[];for(let s=e;s<t;s+=1)i.push(n.getUint8(s));return i}function lm(n){let e="";for(let t=0;t<n.length;t+=1)e+=String.fromCharCode(n[t]);return e}const cm={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function H(n,e){this.data=n,this.offset=e,this.relativeOffset=0}H.prototype.parseByte=function(){const n=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n},H.prototype.parseChar=function(){const n=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n},H.prototype.parseCard8=H.prototype.parseByte,H.prototype.parseUShort=function(){const n=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n},H.prototype.parseCard16=H.prototype.parseUShort,H.prototype.parseSID=H.prototype.parseUShort,H.prototype.parseOffset16=H.prototype.parseUShort,H.prototype.parseShort=function(){const n=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n},H.prototype.parseF2Dot14=function(){const n=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,n},H.prototype.parseULong=function(){const n=Ws(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n},H.prototype.parseOffset32=H.prototype.parseULong,H.prototype.parseFixed=function(){const n=Ga(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n},H.prototype.parseString=function(n){const e=this.data,t=this.offset+this.relativeOffset;let i="";this.relativeOffset+=n;for(let s=0;s<n;s++)i+=String.fromCharCode(e.getUint8(t+s));return i},H.prototype.parseTag=function(){return this.parseString(4)},H.prototype.parseLongDateTime=function(){let n=Ws(this.data,this.offset+this.relativeOffset+4);return n-=2082844800,this.relativeOffset+=8,n},H.prototype.parseVersion=function(n){const e=Ii(this.data,this.offset+this.relativeOffset),t=Ii(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,n===void 0&&(n=4096),e+t/n/10},H.prototype.skip=function(n,e){e===void 0&&(e=1),this.relativeOffset+=cm[n]*e},H.prototype.parseULongList=function(n){n===void 0&&(n=this.parseULong());const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getUint32(i),i+=4;return this.relativeOffset+=n*4,e},H.prototype.parseOffset16List=H.prototype.parseUShortList=function(n){n===void 0&&(n=this.parseUShort());const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getUint16(i),i+=2;return this.relativeOffset+=n*2,e},H.prototype.parseShortList=function(n){const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getInt16(i),i+=2;return this.relativeOffset+=n*2,e},H.prototype.parseByteList=function(n){const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getUint8(i++);return this.relativeOffset+=n,e},H.prototype.parseList=function(n,e){e||(e=n,n=this.parseUShort());const t=new Array(n);for(let i=0;i<n;i++)t[i]=e.call(this);return t},H.prototype.parseList32=function(n,e){e||(e=n,n=this.parseULong());const t=new Array(n);for(let i=0;i<n;i++)t[i]=e.call(this);return t},H.prototype.parseRecordList=function(n,e){e||(e=n,n=this.parseUShort());const t=new Array(n),i=Object.keys(e);for(let s=0;s<n;s++){const o={};for(let r=0;r<i.length;r++){const l=i[r],a=e[l];o[l]=a.call(this)}t[s]=o}return t},H.prototype.parseRecordList32=function(n,e){e||(e=n,n=this.parseULong());const t=new Array(n),i=Object.keys(e);for(let s=0;s<n;s++){const o={};for(let r=0;r<i.length;r++){const l=i[r],a=e[l];o[l]=a.call(this)}t[s]=o}return t},H.prototype.parseStruct=function(n){if(typeof n=="function")return n.call(this);{const e=Object.keys(n),t={};for(let i=0;i<e.length;i++){const s=e[i],o=n[s];t[s]=o.call(this)}return t}},H.prototype.parseValueRecord=function(n){if(n===void 0&&(n=this.parseUShort()),n===0)return;const e={};return n&1&&(e.xPlacement=this.parseShort()),n&2&&(e.yPlacement=this.parseShort()),n&4&&(e.xAdvance=this.parseShort()),n&8&&(e.yAdvance=this.parseShort()),n&16&&(e.xPlaDevice=void 0,this.parseShort()),n&32&&(e.yPlaDevice=void 0,this.parseShort()),n&64&&(e.xAdvDevice=void 0,this.parseShort()),n&128&&(e.yAdvDevice=void 0,this.parseShort()),e},H.prototype.parseValueRecordList=function(){const n=this.parseUShort(),e=this.parseUShort(),t=new Array(e);for(let i=0;i<e;i++)t[i]=this.parseValueRecord(n);return t},H.prototype.parsePointer=function(n){const e=this.parseOffset16();if(e>0)return new H(this.data,this.offset+e).parseStruct(n)},H.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new H(this.data,this.offset+e).parseStruct(n)},H.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=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,n){const l=this.parseOffset16List(),a=new Array(l.length);for(let c=0;c<l.length;c++)this.relativeOffset=r+l[c],a[c]=n.call(this);s[o]=a}else s[o]=this.parseUShortList()}return this.relativeOffset=i,s},H.prototype.parseCoverage=function(){const n=this.offset+this.relativeOffset,e=this.parseUShort(),t=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(t)};if(e===2){const i=new Array(t);for(let s=0;s<t;s++)i[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:i}}throw new Error("0x"+n.toString(16)+": Coverage format must be 1 or 2.")},H.prototype.parseClassDef=function(){const n=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:H.uShort,end:H.uShort,classId:H.uShort})};throw new Error("0x"+n.toString(16)+": ClassDef format must be 1 or 2.")},H.list=function(n,e){return function(){return this.parseList(n,e)}},H.list32=function(n,e){return function(){return this.parseList32(n,e)}},H.recordList=function(n,e){return function(){return this.parseRecordList(n,e)}},H.recordList32=function(n,e){return function(){return this.parseRecordList32(n,e)}},H.pointer=function(n){return function(){return this.parsePointer(n)}},H.pointer32=function(n){return function(){return this.parsePointer32(n)}},H.tag=H.prototype.parseTag,H.byte=H.prototype.parseByte,H.uShort=H.offset16=H.prototype.parseUShort,H.uShortList=H.prototype.parseUShortList,H.uLong=H.offset32=H.prototype.parseULong,H.uLongList=H.prototype.parseULongList,H.struct=H.prototype.parseStruct,H.coverage=H.prototype.parseCoverage,H.classDef=H.prototype.parseClassDef;const Ya={reserved:H.uShort,reqFeatureIndex:H.uShort,featureIndexes:H.uShortList};H.prototype.parseScriptList=function(){return this.parsePointer(H.recordList({tag:H.tag,script:H.pointer({defaultLangSys:H.pointer(Ya),langSysRecords:H.recordList({tag:H.tag,langSys:H.pointer(Ya)})})}))||[]},H.prototype.parseFeatureList=function(){return this.parsePointer(H.recordList({tag:H.tag,feature:H.pointer({featureParams:H.offset16,lookupListIndexes:H.uShortList})}))||[]},H.prototype.parseLookupList=function(n){return this.parsePointer(H.list(H.pointer(function(){const e=this.parseUShort();ie.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");const t=this.parseUShort(),i=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(H.pointer(n[e])),markFilteringSet:i?this.parseUShort():void 0}})))||[]},H.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){const n=this.parseUShort(),e=this.parseUShort();return ie.argument(n===1&&e<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:H.offset32,featureTableSubstitutionOffset:H.offset32})})||[]};const q={getByte:Ha,getCard8:Ha,getUShort:Ii,getCard16:Ii,getShort:sm,getULong:Ws,getFixed:Ga,getTag:om,getOffset:rm,getBytes:am,bytesToString:lm,Parser:H};function dm(n,e){e.parseUShort(),n.length=e.parseULong(),n.language=e.parseULong();let t;n.groupCount=t=e.parseULong(),n.glyphIndexMap={};for(let i=0;i<t;i+=1){const s=e.parseULong(),o=e.parseULong();let r=e.parseULong();for(let l=s;l<=o;l+=1)n.glyphIndexMap[l]=r,r++}}function um(n,e,t,i,s){n.length=e.parseUShort(),n.language=e.parseUShort();let o;n.segCount=o=e.parseUShort()>>1,e.skip("uShort",3),n.glyphIndexMap={};const r=new q.Parser(t,i+s+14),l=new q.Parser(t,i+s+16+o*2),a=new q.Parser(t,i+s+16+o*4),c=new q.Parser(t,i+s+16+o*6);let u=i+s+16+o*8;for(let f=0;f<o-1;f+=1){let p;const h=r.parseUShort(),A=l.parseUShort(),C=a.parseShort(),m=c.parseUShort();for(let y=A;y<=h;y+=1)m!==0?(u=c.offset+c.relativeOffset-2,u+=m,u+=(y-A)*2,p=q.getUShort(t,u),p!==0&&(p=p+C&65535)):p=y+C&65535,n.glyphIndexMap[y]=p}}function hm(n,e){const t={};t.version=q.getUShort(n,e),ie.argument(t.version===0,"cmap table version should be 0."),t.numTables=q.getUShort(n,e+2);let i=-1;for(let o=t.numTables-1;o>=0;o-=1){const r=q.getUShort(n,e+4+o*8),l=q.getUShort(n,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)){i=q.getULong(n,e+4+o*8+4);break}}if(i===-1)throw new Error("No valid cmap sub-tables found.");const s=new q.Parser(n,e+i);if(t.format=s.parseUShort(),t.format===12)dm(t,s);else if(t.format===4)um(t,s,n,e,i);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+t.format+").");return t}function fm(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function pm(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function gm(n){let e=!0,t;for(t=n.length-1;t>0;t-=1)if(n.get(t).unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}let i=[{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||(i=i.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),i=i.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 Z.Table("cmap",i);for(s.segments=[],t=0;t<n.length;t+=1){const h=n.get(t);for(let A=0;A<h.unicodes.length;A+=1)fm(s,h.unicodes[A],t);s.segments=s.segments.sort(function(A,C){return A.start-C.start})}pm(s);const o=s.segments.length;let r=0,l=[],a=[],c=[],u=[],f=[],p=[];for(t=0;t<o;t+=1){const h=s.segments[t];h.end<=65535&&h.start<=65535?(l=l.concat({name:"end_"+t,type:"USHORT",value:h.end}),a=a.concat({name:"start_"+t,type:"USHORT",value:h.start}),c=c.concat({name:"idDelta_"+t,type:"SHORT",value:h.delta}),u=u.concat({name:"idRangeOffset_"+t,type:"USHORT",value:h.offset}),h.glyphId!==void 0&&(f=f.concat({name:"glyph_"+t,type:"USHORT",value:h.glyphId}))):r+=1,!e&&h.glyphIndex!==void 0&&(p=p.concat({name:"cmap12Start_"+t,type:"ULONG",value:h.start}),p=p.concat({name:"cmap12End_"+t,type:"ULONG",value:h.end}),p=p.concat({name:"cmap12Glyph_"+t,type:"ULONG",value:h.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(c),s.fields=s.fields.concat(u),s.fields=s.fields.concat(f),s.cmap4Length=14+l.length*2+2+a.length*2+c.length*2+u.length*2+f.length*2,!e){const h=16+p.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:h},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:p.length/3}]),s.fields=s.fields.concat(p)}return s}const Va={parse:hm,make:gm},xi=[".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"],mm=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Am=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Ft=[".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 Wa(n){this.font=n}Wa.prototype.charToGlyphIndex=function(n){const e=n.codePointAt(0),t=this.font.glyphs;if(t)for(let i=0;i<t.length;i+=1){const s=t.get(i);for(let o=0;o<s.unicodes.length;o+=1)if(s.unicodes[o]===e)return i}return null};function za(n){this.cmap=n}za.prototype.charToGlyphIndex=function(n){return this.cmap.glyphIndexMap[n.codePointAt(0)]||0};function Bi(n,e){this.encoding=n,this.charset=e}Bi.prototype.charToGlyphIndex=function(n){const e=n.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function zs(n){switch(n.version){case 1:this.names=Ft.slice();break;case 2:this.names=new Array(n.numberOfGlyphs);for(let e=0;e<n.numberOfGlyphs;e++)n.glyphNameIndex[e]<Ft.length?this.names[e]=Ft[n.glyphNameIndex[e]]:this.names[e]=n.names[n.glyphNameIndex[e]-Ft.length];break;case 2.5:this.names=new Array(n.numberOfGlyphs);for(let e=0;e<n.numberOfGlyphs;e++)this.names[e]=Ft[e+n.glyphNameIndex[e]];break;case 3:this.names=[];break;default:this.names=[];break}}zs.prototype.nameToGlyphIndex=function(n){return this.names.indexOf(n)},zs.prototype.glyphIndexToName=function(n){return this.names[n]};function ym(n){let e;const t=n.tables.cmap.glyphIndexMap,i=Object.keys(t);for(let s=0;s<i.length;s+=1){const o=i[s],r=t[o];e=n.glyphs.get(r),e.addUnicode(parseInt(o))}for(let s=0;s<n.glyphs.length;s+=1)e=n.glyphs.get(s),n.cffEncoding?n.isCIDFont?e.name="gid"+s:e.name=n.cffEncoding.charset[s]:n.glyphNames.names&&(e.name=n.glyphNames.glyphIndexToName(s))}function Cm(n,e,t,i,s){n.beginPath(),n.moveTo(e,t),n.lineTo(i,s),n.stroke()}const Rt={line:Cm};function Em(n,e){let t=e||new Ie;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function Qe(n){this.bindConstructorValues(n)}Qe.prototype.bindConstructorValues=function(n){this.index=n.index||0,this.name=n.name||null,this.unicode=n.unicode||void 0,this.unicodes=n.unicodes||n.unicode!==void 0?[n.unicode]:[],n.xMin&&(this.xMin=n.xMin),n.yMin&&(this.yMin=n.yMin),n.xMax&&(this.xMax=n.xMax),n.yMax&&(this.yMax=n.yMax),n.advanceWidth&&(this.advanceWidth=n.advanceWidth),Object.defineProperty(this,"path",Em(this,n.path))},Qe.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)},Qe.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},Qe.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72;let o,r;i||(i={});let l=i.xScale,a=i.yScale;if(i.hinting&&s&&s.hinting&&(r=this.path&&s.hinting.exec(this,t)),r)o=s.hinting.getCommands(r),n=Math.round(n),e=Math.round(e),l=a=1;else{o=this.path.commands;const u=1/this.path.unitsPerEm*t;l===void 0&&(l=u),a===void 0&&(a=u)}const c=new Ie;for(let u=0;u<o.length;u+=1){const f=o[u];f.type==="M"?c.moveTo(n+f.x*l,e+-f.y*a):f.type==="L"?c.lineTo(n+f.x*l,e+-f.y*a):f.type==="Q"?c.quadraticCurveTo(n+f.x1*l,e+-f.y1*a,n+f.x*l,e+-f.y*a):f.type==="C"?c.curveTo(n+f.x1*l,e+-f.y1*a,n+f.x2*l,e+-f.y2*a,n+f.x*l,e+-f.y*a):f.type==="Z"&&c.closePath()}return c},Qe.prototype.getContours=function(){if(this.points===void 0)return[];const n=[];let e=[];for(let t=0;t<this.points.length;t+=1){const i=this.points[t];e.push(i),i.lastPointOfContour&&(n.push(e),e=[])}return ie.argument(e.length===0,"There are still points left in the current contour."),n},Qe.prototype.getMetrics=function(){const n=this.path.commands,e=[],t=[];for(let s=0;s<n.length;s+=1){const o=n[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 i={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(i.xMin)||(i.xMin=0),isFinite(i.xMax)||(i.xMax=this.advanceWidth),isFinite(i.yMin)||(i.yMin=0),isFinite(i.yMax)||(i.yMax=0),i.rightSideBearing=this.advanceWidth-i.leftSideBearing-(i.xMax-i.xMin),i},Qe.prototype.draw=function(n,e,t,i,s){this.getPath(e,t,i,s).draw(n)},Qe.prototype.drawPoints=function(n,e,t,i){function s(c,u,f,p){const h=Math.PI*2;n.beginPath();for(let A=0;A<c.length;A+=1)n.moveTo(u+c[A].x*p,f+c[A].y*p),n.arc(u+c[A].x*p,f+c[A].y*p,2,0,h,!1);n.closePath(),n.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,i=i!==void 0?i:24;const o=1/this.path.unitsPerEm*i,r=[],l=[],a=this.path;for(let c=0;c<a.commands.length;c+=1){const u=a.commands[c];u.x!==void 0&&r.push({x:u.x,y:-u.y}),u.x1!==void 0&&l.push({x:u.x1,y:-u.y1}),u.x2!==void 0&&l.push({x:u.x2,y:-u.y2})}n.fillStyle="blue",s(r,e,t,o),n.fillStyle="red",s(l,e,t,o)},Qe.prototype.drawMetrics=function(n,e,t,i){let s;e=e!==void 0?e:0,t=t!==void 0?t:0,i=i!==void 0?i:24,s=1/this.path.unitsPerEm*i,n.lineWidth=1,n.strokeStyle="black",Rt.line(n,e,-1e4,e,1e4),Rt.line(n,-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 c=this.advanceWidth||0;n.strokeStyle="blue",Rt.line(n,e+o*s,-1e4,e+o*s,1e4),Rt.line(n,e+l*s,-1e4,e+l*s,1e4),Rt.line(n,-1e4,t+-r*s,1e4,t+-r*s),Rt.line(n,-1e4,t+-a*s,1e4,t+-a*s),n.strokeStyle="green",Rt.line(n,e+c*s,-1e4,e+c*s,1e4)};function Si(n,e,t){Object.defineProperty(n,e,{get:function(){return n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function js(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t<e.length;t++)this.glyphs[t]=e[t];this.length=e&&e.length||0}js.prototype.get=function(n){return typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]()),this.glyphs[n]},js.prototype.push=function(n,e){this.glyphs[n]=e,this.length++};function wm(n,e){return new Qe({index:e,font:n})}function bm(n,e,t,i,s,o){return function(){const r=new Qe({index:e,font:n});return r.path=function(){t(r,i,s);const l=o(n.glyphs,r);return l.unitsPerEm=n.unitsPerEm,l},Si(r,"xMin","_xMin"),Si(r,"xMax","_xMax"),Si(r,"yMin","_yMin"),Si(r,"yMax","_yMax"),r}}function vm(n,e,t,i){return function(){const s=new Qe({index:e,font:n});return s.path=function(){const o=t(n,s,i);return o.unitsPerEm=n.unitsPerEm,o},s}}const rn={GlyphSet:js,glyphLoader:wm,ttfGlyphLoader:bm,cffGlyphLoader:vm};function ja(n,e){if(n===e)return!0;if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t+=1)if(!ja(n[t],e[t]))return!1;return!0}else return!1}function $s(n){let e;return n.length<1240?e=107:n.length<33900?e=1131:e=32768,e}function Et(n,e,t){const i=[],s=[],o=q.getCard16(n,e);let r,l;if(o!==0){const a=q.getByte(n,e+2);r=e+(o+1)*a+2;let c=e+3;for(let u=0;u<o+1;u+=1)i.push(q.getOffset(n,c,a)),c+=a;l=r+i[o]}else l=e+2;for(let a=0;a<i.length-1;a+=1){let c=q.getBytes(n,r+i[a],r+i[a+1]);t&&(c=t(c)),s.push(c)}return{objects:s,startOffset:e,endOffset:l}}function Im(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),o=s>>4,r=s&15;if(o===15||(e+=i[o],r===15))break;e+=i[r]}return parseFloat(e)}function xm(n,e){let t,i,s,o;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),o=n.parseByte(),t<<24|i<<16|s<<8|o;if(e===30)return Im(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function Bm(n){const e={};for(let t=0;t<n.length;t+=1){const i=n[t][0],s=n[t][1];let o;if(s.length===1?o=s[0]:o=s,e.hasOwnProperty(i)&&!isNaN(e[i]))throw new Error("Object "+e+" already has key "+i);e[i]=o}return e}function $a(n,e,t){e=e!==void 0?e:0;const i=new q.Parser(n,e),s=[];let o=[];for(t=t!==void 0?t:n.length;i.relativeOffset<t;){let r=i.parseByte();r<=21?(r===12&&(r=1200+i.parseByte()),s.push([r,o]),o=[]):o.push(xm(i,r))}return Bm(s)}function Tn(n,e){return e<=390?e=xi[e]:e=n[e-391],e}function Ka(n,e,t){const i={};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=n[r.op]!==void 0?n[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=Tn(t,s)),l[a]=s;i[r.name]=l}else s=n[r.op],s===void 0&&(s=r.value!==void 0?r.value:null),r.type==="SID"&&(s=Tn(t,s)),i[r.name]=s}return i}function Sm(n,e){const t={};return t.formatMajor=q.getCard8(n,e),t.formatMinor=q.getCard8(n,e+1),t.size=q.getCard8(n,e+2),t.offsetSize=q.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4,t}const qa=[{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"}],Xa=[{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 Mm(n,e){const t=$a(n,0,n.byteLength);return Ka(t,qa,e)}function Ja(n,e,t,i){const s=$a(n,e,t);return Ka(s,Xa,i)}function Za(n,e,t,i){const s=[];for(let o=0;o<t.length;o+=1){const r=new DataView(new Uint8Array(t[o]).buffer),l=Mm(r,i);l._subrs=[],l._subrsBias=0;const a=l.private[0],c=l.private[1];if(a!==0&&c!==0){const u=Ja(n,c+e,a,i);if(l._defaultWidthX=u.defaultWidthX,l._nominalWidthX=u.nominalWidthX,u.subrs!==0){const f=c+u.subrs,p=Et(n,f+e);l._subrs=p.objects,l._subrsBias=$s(l._subrs)}l._privateDict=u}s.push(l)}return s}function Tm(n,e,t,i){let s,o;const r=new q.Parser(n,e);t-=1;const l=[".notdef"],a=r.parseCard8();if(a===0)for(let c=0;c<t;c+=1)s=r.parseSID(),l.push(Tn(i,s));else if(a===1)for(;l.length<=t;){s=r.parseSID(),o=r.parseCard8();for(let c=0;c<=o;c+=1)l.push(Tn(i,s)),s+=1}else if(a===2)for(;l.length<=t;){s=r.parseSID(),o=r.parseCard16();for(let c=0;c<=o;c+=1)l.push(Tn(i,s)),s+=1}else throw new Error("Unknown charset format "+a);return l}function Dm(n,e,t){let i;const s={},o=new q.Parser(n,e),r=o.parseCard8();if(r===0){const l=o.parseCard8();for(let a=0;a<l;a+=1)i=o.parseCard8(),s[i]=a}else if(r===1){const l=o.parseCard8();i=1;for(let a=0;a<l;a+=1){const c=o.parseCard8(),u=o.parseCard8();for(let f=c;f<=c+u;f+=1)s[f]=i,i+=1}}else throw new Error("Unknown encoding format "+r);return new Bi(s,t)}function km(n,e,t){let i,s,o,r;const l=new Ie,a=[];let c=0,u=!1,f=!1,p=0,h=0,A,C,m,y;if(n.isCIDFont){const B=n.tables.cff.topDict._fdSelect[e.index],x=n.tables.cff.topDict._fdArray[B];A=x._subrs,C=x._subrsBias,m=x._defaultWidthX,y=x._nominalWidthX}else A=n.tables.cff.topDict._subrs,C=n.tables.cff.topDict._subrsBias,m=n.tables.cff.topDict._defaultWidthX,y=n.tables.cff.topDict._nominalWidthX;let E=m;function I(B,x){f&&l.closePath(),l.moveTo(B,x),f=!0}function S(){let B;B=a.length%2!==0,B&&!u&&(E=a.shift()+y),c+=a.length>>1,a.length=0,u=!0}function k(B){let x,g,R,M,F,L,G,N,v,w,b,T,P=0;for(;P<B.length;){let _=B[P];switch(P+=1,_){case 1:S();break;case 3:S();break;case 4:a.length>1&&!u&&(E=a.shift()+y,u=!0),h+=a.pop(),I(p,h);break;case 5:for(;a.length>0;)p+=a.shift(),h+=a.shift(),l.lineTo(p,h);break;case 6:for(;a.length>0&&(p+=a.shift(),l.lineTo(p,h),a.length!==0);)h+=a.shift(),l.lineTo(p,h);break;case 7:for(;a.length>0&&(h+=a.shift(),l.lineTo(p,h),a.length!==0);)p+=a.shift(),l.lineTo(p,h);break;case 8:for(;a.length>0;)i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r+a.shift(),l.curveTo(i,s,o,r,p,h);break;case 10:F=a.pop()+C,L=A[F],L&&k(L);break;case 11:return;case 12:switch(_=B[P],P+=1,_){case 35:i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),G=o+a.shift(),N=r+a.shift(),v=G+a.shift(),w=N+a.shift(),b=v+a.shift(),T=w+a.shift(),p=b+a.shift(),h=T+a.shift(),a.shift(),l.curveTo(i,s,o,r,G,N),l.curveTo(v,w,b,T,p,h);break;case 34:i=p+a.shift(),s=h,o=i+a.shift(),r=s+a.shift(),G=o+a.shift(),N=r,v=G+a.shift(),w=r,b=v+a.shift(),T=h,p=b+a.shift(),l.curveTo(i,s,o,r,G,N),l.curveTo(v,w,b,T,p,h);break;case 36:i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),G=o+a.shift(),N=r,v=G+a.shift(),w=r,b=v+a.shift(),T=w+a.shift(),p=b+a.shift(),l.curveTo(i,s,o,r,G,N),l.curveTo(v,w,b,T,p,h);break;case 37:i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),G=o+a.shift(),N=r+a.shift(),v=G+a.shift(),w=N+a.shift(),b=v+a.shift(),T=w+a.shift(),Math.abs(b-p)>Math.abs(T-h)?p=b+a.shift():h=T+a.shift(),l.curveTo(i,s,o,r,G,N),l.curveTo(v,w,b,T,p,h);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+_),a.length=0}break;case 14:a.length>0&&!u&&(E=a.shift()+y,u=!0),f&&(l.closePath(),f=!1);break;case 18:S();break;case 19:case 20:S(),P+=c+7>>3;break;case 21:a.length>2&&!u&&(E=a.shift()+y,u=!0),h+=a.pop(),p+=a.pop(),I(p,h);break;case 22:a.length>1&&!u&&(E=a.shift()+y,u=!0),p+=a.pop(),I(p,h);break;case 23:S();break;case 24:for(;a.length>2;)i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r+a.shift(),l.curveTo(i,s,o,r,p,h);p+=a.shift(),h+=a.shift(),l.lineTo(p,h);break;case 25:for(;a.length>6;)p+=a.shift(),h+=a.shift(),l.lineTo(p,h);i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r+a.shift(),l.curveTo(i,s,o,r,p,h);break;case 26:for(a.length%2&&(p+=a.shift());a.length>0;)i=p,s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o,h=r+a.shift(),l.curveTo(i,s,o,r,p,h);break;case 27:for(a.length%2&&(h+=a.shift());a.length>0;)i=p+a.shift(),s=h,o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r,l.curveTo(i,s,o,r,p,h);break;case 28:x=B[P],g=B[P+1],a.push((x<<24|g<<16)>>16),P+=2;break;case 29:F=a.pop()+n.gsubrsBias,L=n.gsubrs[F],L&&k(L);break;case 30:for(;a.length>0&&(i=p,s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r+(a.length===1?a.shift():0),l.curveTo(i,s,o,r,p,h),a.length!==0);)i=p+a.shift(),s=h,o=i+a.shift(),r=s+a.shift(),h=r+a.shift(),p=o+(a.length===1?a.shift():0),l.curveTo(i,s,o,r,p,h);break;case 31:for(;a.length>0&&(i=p+a.shift(),s=h,o=i+a.shift(),r=s+a.shift(),h=r+a.shift(),p=o+(a.length===1?a.shift():0),l.curveTo(i,s,o,r,p,h),a.length!==0);)i=p,s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r+(a.length===1?a.shift():0),l.curveTo(i,s,o,r,p,h);break;default:_<32?console.log("Glyph "+e.index+": unknown operator "+_):_<247?a.push(_-139):_<251?(x=B[P],P+=1,a.push((_-247)*256+x+108)):_<255?(x=B[P],P+=1,a.push(-(_-251)*256-x-108)):(x=B[P],g=B[P+1],R=B[P+2],M=B[P+3],P+=4,a.push((x<<24|g<<16|R<<8|M)/65536))}}}return k(t),e.advanceWidth=E,l}function Pm(n,e,t,i){const s=[];let o;const r=new q.Parser(n,e),l=r.parseCard8();if(l===0)for(let a=0;a<t;a++){if(o=r.parseCard8(),o>=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+i+")");s.push(o)}else if(l===3){const a=r.parseCard16();let c=r.parseCard16();if(c!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+c);let u;for(let f=0;f<a;f++){if(o=r.parseCard8(),u=r.parseCard16(),o>=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+i+")");if(u>t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+u);for(;c<u;c++)s.push(o);c=u}if(u!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+u)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+l);return s}function Fm(n,e,t){t.tables.cff={};const i=Sm(n,e),s=Et(n,i.endOffset,q.bytesToString),o=Et(n,s.endOffset),r=Et(n,o.endOffset,q.bytesToString),l=Et(n,r.endOffset);t.gsubrs=l.objects,t.gsubrsBias=$s(t.gsubrs);const a=Za(n,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 c=a[0];if(t.tables.cff.topDict=c,c._privateDict&&(t.defaultWidthX=c._privateDict.defaultWidthX,t.nominalWidthX=c._privateDict.nominalWidthX),c.ros[0]!==void 0&&c.ros[1]!==void 0&&(t.isCIDFont=!0),t.isCIDFont){let A=c.fdArray,C=c.fdSelect;if(A===0||C===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");A+=e;const m=Et(n,A),y=Za(n,e,m.objects,r.objects);c._fdArray=y,C+=e,c._fdSelect=Pm(n,C,t.numGlyphs,y.length)}const u=e+c.private[1],f=Ja(n,u,c.private[0],r.objects);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const A=u+f.subrs,C=Et(n,A);t.subrs=C.objects,t.subrsBias=$s(t.subrs)}else t.subrs=[],t.subrsBias=0;const p=Et(n,e+c.charStrings);t.nGlyphs=p.objects.length;const h=Tm(n,e+c.charset,t.nGlyphs,r.objects);c.encoding===0?t.cffEncoding=new Bi(mm,h):c.encoding===1?t.cffEncoding=new Bi(Am,h):t.cffEncoding=Dm(n,e+c.encoding,h),t.encoding=t.encoding||t.cffEncoding,t.glyphs=new rn.GlyphSet(t);for(let A=0;A<t.nGlyphs;A+=1){const C=p.objects[A];t.glyphs.push(A,rn.cffGlyphLoader(t,A,km,C))}}function el(n,e){let t,i=xi.indexOf(n);return i>=0&&(t=i),i=e.indexOf(n),i>=0?t=i+xi.length:(t=xi.length+e.length,e.push(n)),t}function Rm(){return new Z.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 Om(n){const e=new Z.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t<n.length;t+=1)e.names.push({name:"name_"+t,type:"NAME",value:n[t]});return e}function tl(n,e,t){const i={};for(let s=0;s<n.length;s+=1){const o=n[s];let r=e[o.name];r!==void 0&&!ja(r,o.value)&&(o.type==="SID"&&(r=el(r,t)),i[o.op]={name:o.name,type:o.type,value:r})}return i}function nl(n,e){const t=new Z.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=tl(qa,n,e),t}function il(n){const e=new Z.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:n}],e}function Lm(n){const e=new Z.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(let t=0;t<n.length;t+=1)e.strings.push({name:"string_"+t,type:"STRING",value:n[t]});return e}function Nm(){return new Z.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Um(n,e){const t=new Z.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let i=0;i<n.length;i+=1){const s=n[i],o=el(s,e);t.fields.push({name:"glyph_"+i,type:"SID",value:o})}return t}function _m(n){const e=[],t=n.path;e.push({name:"width",type:"NUMBER",value:n.advanceWidth});let i=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 c=.3333333333333333,u=2/3;a={type:"C",x:a.x,y:a.y,x1:c*i+u*a.x1,y1:c*s+u*a.y1,x2:c*a.x+u*a.x1,y2:c*a.y+u*a.y1}}if(a.type==="M")r=Math.round(a.x-i),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}),i=Math.round(a.x),s=Math.round(a.y);else if(a.type==="L")r=Math.round(a.x-i),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}),i=Math.round(a.x),s=Math.round(a.y);else if(a.type==="C"){const c=Math.round(a.x1-i),u=Math.round(a.y1-s),f=Math.round(a.x2-a.x1),p=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:c}),e.push({name:"dy1",type:"NUMBER",value:u}),e.push({name:"dx2",type:"NUMBER",value:f}),e.push({name:"dy2",type:"NUMBER",value:p}),e.push({name:"dx",type:"NUMBER",value:r}),e.push({name:"dy",type:"NUMBER",value:l}),e.push({name:"rrcurveto",type:"OP",value:8}),i=Math.round(a.x),s=Math.round(a.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function Qm(n){const e=new Z.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let t=0;t<n.length;t+=1){const i=n.get(t),s=_m(i);e.charStrings.push({name:i.name,type:"CHARSTRING",value:s})}return e}function Hm(n,e){const t=new Z.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=tl(Xa,n,e),t}function Gm(n,e){const t=new Z.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"}]),i=1/e.unitsPerEm,s={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[i,0,0,i,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},o={},r=[];let l;for(let f=1;f<n.length;f+=1)l=n.get(f),r.push(l.name);const a=[];t.header=Rm(),t.nameIndex=Om([e.postScriptName]);let c=nl(s,a);t.topDictIndex=il(c),t.globalSubrIndex=Nm(),t.charsets=Um(r,a),t.charStringsIndex=Qm(n),t.privateDict=Hm(o,a),t.stringIndex=Lm(a);const u=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return s.charset=u,s.encoding=0,s.charStrings=s.charset+t.charsets.sizeOf(),s.private[1]=s.charStrings+t.charStringsIndex.sizeOf(),c=nl(s,a),t.topDictIndex=il(c),t}const sl={parse:Fm,make:Gm};function Ym(n,e){const t={},i=new q.Parser(n,e);return t.version=i.parseVersion(),t.fontRevision=Math.round(i.parseFixed()*1e3)/1e3,t.checkSumAdjustment=i.parseULong(),t.magicNumber=i.parseULong(),ie.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=i.parseUShort(),t.unitsPerEm=i.parseUShort(),t.created=i.parseLongDateTime(),t.modified=i.parseLongDateTime(),t.xMin=i.parseShort(),t.yMin=i.parseShort(),t.xMax=i.parseShort(),t.yMax=i.parseShort(),t.macStyle=i.parseUShort(),t.lowestRecPPEM=i.parseUShort(),t.fontDirectionHint=i.parseShort(),t.indexToLocFormat=i.parseShort(),t.glyphDataFormat=i.parseShort(),t}function Vm(n){const e=Math.round(new Date().getTime()/1e3)+2082844800;let t=e;return n.createdTimestamp&&(t=n.createdTimestamp+2082844800),new Z.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}],n)}const ol={parse:Ym,make:Vm};function Wm(n,e){const t={},i=new q.Parser(n,e);return t.version=i.parseVersion(),t.ascender=i.parseShort(),t.descender=i.parseShort(),t.lineGap=i.parseShort(),t.advanceWidthMax=i.parseUShort(),t.minLeftSideBearing=i.parseShort(),t.minRightSideBearing=i.parseShort(),t.xMaxExtent=i.parseShort(),t.caretSlopeRise=i.parseShort(),t.caretSlopeRun=i.parseShort(),t.caretOffset=i.parseShort(),i.relativeOffset+=8,t.metricDataFormat=i.parseShort(),t.numberOfHMetrics=i.parseUShort(),t}function zm(n){return new Z.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}],n)}const rl={parse:Wm,make:zm};function jm(n,e,t,i,s){let o,r;const l=new q.Parser(n,e);for(let a=0;a<i;a+=1){a<t&&(o=l.parseUShort(),r=l.parseShort());const c=s.get(a);c.advanceWidth=o,c.leftSideBearing=r}}function $m(n){const e=new Z.Table("hmtx",[]);for(let t=0;t<n.length;t+=1){const i=n.get(t),s=i.advanceWidth||0,o=i.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 al={parse:jm,make:$m};function Km(n){const e=new Z.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:n.length}]);let t="";const i=12+n.length*4;for(let s=0;s<n.length;++s){let o=t.indexOf(n[s]);o<0&&(o=t.length,t+=n[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:i+o}),e.fields.push({name:"length "+s,type:"USHORT",value:n[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function qm(n,e){const t=new q.Parser(n,e),i=t.parseULong();ie.argument(i===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(),c=t.parseUShort();for(let u=a;u<a+c;++u)l+=String.fromCharCode(n.getInt8(u));o.push(l)}return o}const ll={make:Km,parse:qm};function Xm(n,e){const t={},i=new q.Parser(n,e);return t.version=i.parseVersion(),t.numGlyphs=i.parseUShort(),t.version===1&&(t.maxPoints=i.parseUShort(),t.maxContours=i.parseUShort(),t.maxCompositePoints=i.parseUShort(),t.maxCompositeContours=i.parseUShort(),t.maxZones=i.parseUShort(),t.maxTwilightPoints=i.parseUShort(),t.maxStorage=i.parseUShort(),t.maxFunctionDefs=i.parseUShort(),t.maxInstructionDefs=i.parseUShort(),t.maxStackElements=i.parseUShort(),t.maxSizeOfInstructions=i.parseUShort(),t.maxComponentElements=i.parseUShort(),t.maxComponentDepth=i.parseUShort()),t}function Jm(n){return new Z.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:n}])}const cl={parse:Xm,make:Jm},dl=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],ul={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"},Zm={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},hl={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 eA(n,e,t){switch(n){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return ul[e];case 3:return hl[e]}}const Ks="utf-16",tA={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"},nA={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 fl(n,e,t){switch(n){case 0:return Ks;case 1:return nA[t]||tA[e];case 3:if(e===1||e===10)return Ks;break}}function iA(n,e,t){const i={},s=new q.Parser(n,e),o=s.parseUShort(),r=s.parseUShort(),l=s.offset+s.parseUShort();for(let a=0;a<r;a++){const c=s.parseUShort(),u=s.parseUShort(),f=s.parseUShort(),p=s.parseUShort(),h=dl[p]||p,A=s.parseUShort(),C=s.parseUShort(),m=eA(c,f,t),y=fl(c,u,f);if(y!==void 0&&m!==void 0){let E;if(y===Ks?E=on.UTF16(n,l+C,A):E=on.MACSTRING(n,l+C,A,y),E){let I=i[h];I===void 0&&(I=i[h]={}),I[m]=E}}}return o===1&&s.parseUShort(),i}function qs(n){const e={};for(let t in n)e[n[t]]=parseInt(t);return e}function pl(n,e,t,i,s,o){return new Z.Record("NameRecord",[{name:"platformID",type:"USHORT",value:n},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:t},{name:"nameID",type:"USHORT",value:i},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:o}])}function sA(n,e){const t=n.length,i=e.length-t+1;e:for(let s=0;s<i;s++)for(;s<i;s++){for(let o=0;o<t;o++)if(e[s+o]!==n[o])continue e;return s}return-1}function gl(n,e){let t=sA(n,e);if(t<0){t=e.length;let i=0;const s=n.length;for(;i<s;++i)e.push(n[i])}return t}function oA(n,e){let t;const i=[],s={},o=qs(dl);for(let f in n){let p=o[f];if(p===void 0&&(p=f),t=parseInt(p),isNaN(t))throw new Error('Name table entry "'+f+'" does not exist, see nameTableNames for complete list.');s[t]=n[f],i.push(t)}const r=qs(ul),l=qs(hl),a=[],c=[];for(let f=0;f<i.length;f++){t=i[f];const p=s[t];for(let h in p){const A=p[h];let C=1,m=r[h],y=Zm[m];const E=fl(C,y,m);let I=j.MACSTRING(A,E);I===void 0&&(C=0,m=e.indexOf(h),m<0&&(m=e.length,e.push(h)),y=4,I=j.UTF16(A));const S=gl(I,c);a.push(pl(C,y,m,t,I.length,S));const k=l[h];if(k!==void 0){const B=j.UTF16(A),x=gl(B,c);a.push(pl(3,1,k,t,B.length,x))}}}a.sort(function(f,p){return f.platformID-p.platformID||f.encodingID-p.encodingID||f.languageID-p.languageID||f.nameID-p.nameID});const u=new Z.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 f=0;f<a.length;f++)u.fields.push({name:"record_"+f,type:"RECORD",value:a[f]});return u.fields.push({name:"strings",type:"LITERAL",value:c}),u}const ml={parse:iA,make:oA},Xs=[{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 rA(n){for(let e=0;e<Xs.length;e+=1){const t=Xs[e];if(n>=t.begin&&n<t.end)return e}return-1}function aA(n,e){const t={},i=new q.Parser(n,e);t.version=i.parseUShort(),t.xAvgCharWidth=i.parseShort(),t.usWeightClass=i.parseUShort(),t.usWidthClass=i.parseUShort(),t.fsType=i.parseUShort(),t.ySubscriptXSize=i.parseShort(),t.ySubscriptYSize=i.parseShort(),t.ySubscriptXOffset=i.parseShort(),t.ySubscriptYOffset=i.parseShort(),t.ySuperscriptXSize=i.parseShort(),t.ySuperscriptYSize=i.parseShort(),t.ySuperscriptXOffset=i.parseShort(),t.ySuperscriptYOffset=i.parseShort(),t.yStrikeoutSize=i.parseShort(),t.yStrikeoutPosition=i.parseShort(),t.sFamilyClass=i.parseShort(),t.panose=[];for(let s=0;s<10;s++)t.panose[s]=i.parseByte();return t.ulUnicodeRange1=i.parseULong(),t.ulUnicodeRange2=i.parseULong(),t.ulUnicodeRange3=i.parseULong(),t.ulUnicodeRange4=i.parseULong(),t.achVendID=String.fromCharCode(i.parseByte(),i.parseByte(),i.parseByte(),i.parseByte()),t.fsSelection=i.parseUShort(),t.usFirstCharIndex=i.parseUShort(),t.usLastCharIndex=i.parseUShort(),t.sTypoAscender=i.parseShort(),t.sTypoDescender=i.parseShort(),t.sTypoLineGap=i.parseShort(),t.usWinAscent=i.parseUShort(),t.usWinDescent=i.parseUShort(),t.version>=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function lA(n){return new Z.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}],n)}const Js={parse:aA,make:lA,unicodeRanges:Xs,getUnicodeRange:rA};function cA(n,e){const t={},i=new q.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=Ft.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s<t.numberOfGlyphs;s++)t.glyphNameIndex[s]=i.parseUShort();t.names=[];for(let s=0;s<t.numberOfGlyphs;s++)if(t.glyphNameIndex[s]>=Ft.length){const o=i.parseChar();t.names.push(i.parseString(o))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s<t.numberOfGlyphs;s++)t.offset[s]=i.parseChar();break}return t}function dA(){return new Z.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 Al={parse:cA,make:dA},Ye=new Array(9);Ye[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(H.coverage),deltaGlyphId:this.parseUShort()};if(t===2)return{substFormat:2,coverage:this.parsePointer(H.coverage),substitute:this.parseOffset16List()};ie.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")},Ye[2]=function(){const e=this.parseUShort();return ie.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(H.coverage),sequences:this.parseListOfLists()}},Ye[3]=function(){const e=this.parseUShort();return ie.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(H.coverage),alternateSets:this.parseListOfLists()}},Ye[4]=function(){const e=this.parseUShort();return ie.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(H.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};const an={sequenceIndex:H.uShort,lookupListIndex:H.uShort};Ye[5]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:t,coverage:this.parsePointer(H.coverage),ruleSets:this.parseListOfLists(function(){const i=this.parseUShort(),s=this.parseUShort();return{input:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(s,an)}})};if(t===2)return{substFormat:t,coverage:this.parsePointer(H.coverage),classDef:this.parsePointer(H.classDef),classSets:this.parseListOfLists(function(){const i=this.parseUShort(),s=this.parseUShort();return{classes:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(s,an)}})};if(t===3){const i=this.parseUShort(),s=this.parseUShort();return{substFormat:t,coverages:this.parseList(i,H.pointer(H.coverage)),lookupRecords:this.parseRecordList(s,an)}}ie.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},Ye[6]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(H.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(an)}})};if(t===2)return{substFormat:2,coverage:this.parsePointer(H.coverage),backtrackClassDef:this.parsePointer(H.classDef),inputClassDef:this.parsePointer(H.classDef),lookaheadClassDef:this.parsePointer(H.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(an)}})};if(t===3)return{substFormat:3,backtrackCoverage:this.parseList(H.pointer(H.coverage)),inputCoverage:this.parseList(H.pointer(H.coverage)),lookaheadCoverage:this.parseList(H.pointer(H.coverage)),lookupRecords:this.parseRecordList(an)};ie.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},Ye[7]=function(){const e=this.parseUShort();ie.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");const t=this.parseUShort(),i=new H(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:Ye[t].call(i)}},Ye[8]=function(){const e=this.parseUShort();return ie.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(H.coverage),backtrackCoverage:this.parseList(H.pointer(H.coverage)),lookaheadCoverage:this.parseList(H.pointer(H.coverage)),substitutes:this.parseUShortList()}};function uA(n,e){e=e||0;const t=new H(n,e),i=t.parseVersion(1);return ie.argument(i===1||i===1.1,"Unsupported GSUB table version."),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Ye)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Ye),variations:t.parseFeatureVariationsList()}}const Mi=new Array(9);Mi[1]=function(e){return e.substFormat===1?new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)}].concat(Z.ushortList("substitute",e.substitute)))},Mi[3]=function(e){return ie.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)}].concat(Z.tableList("altSet",e.alternateSets,function(t){return new Z.Table("alternateSetTable",Z.ushortList("alternate",t))})))},Mi[4]=function(e){return ie.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)}].concat(Z.tableList("ligSet",e.ligatureSets,function(t){return new Z.Table("ligatureSetTable",Z.tableList("ligature",t,function(i){return new Z.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:i.ligGlyph}].concat(Z.ushortList("component",i.components,i.components.length+1)))}))})))};function hA(n){return new Z.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new Z.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new Z.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new Z.LookupList(n.lookups,Mi)}])}const yl={parse:uA,make:hA};function fA(n,e){const t=new q.Parser(n,e),i=t.parseULong();ie.argument(i===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(),c=t.parseULong(),u=on.UTF8(n,e+a,c);o[l]=u}return o}function pA(n){const e=Object.keys(n).length;let t="";const i=16+e*12,s=new Z.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:i},{name:"numTags",type:"ULONG",value:e}]);for(let o in n){const r=t.length;t+=n[o],s.fields.push({name:"tag "+o,type:"TAG",value:o}),s.fields.push({name:"offset "+o,type:"ULONG",value:i+r}),s.fields.push({name:"length "+o,type:"ULONG",value:n[o].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),s}const Cl={parse:fA,make:pA};function El(n){return Math.log(n)/Math.log(2)|0}function Zs(n){for(;n.length%4!==0;)n.push(0);let e=0;for(let t=0;t<n.length;t+=4)e+=(n[t]<<24)+(n[t+1]<<16)+(n[t+2]<<8)+n[t+3];return e%=Math.pow(2,32),e}function wl(n,e,t,i){return new Z.Record("Table Record",[{name:"tag",type:"TAG",value:n!==void 0?n:""},{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:i!==void 0?i:0}])}function bl(n){const e=new Z.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=n,e.numTables=n.length;const t=Math.pow(2,El(e.numTables));e.searchRange=16*t,e.entrySelector=El(t),e.rangeShift=e.numTables*16-e.searchRange;const i=[],s=[];let o=e.sizeOf()+wl().sizeOf()*e.numTables;for(;o%4!==0;)o+=1,s.push({name:"padding",type:"BYTE",value:0});for(let r=0;r<n.length;r+=1){const l=n[r];ie.argument(l.tableName.length===4,"Table name"+l.tableName+" is invalid.");const a=l.sizeOf(),c=wl(l.tableName,Zs(l.encode()),o,a);for(i.push({name:c.tag+" Table Record",type:"RECORD",value:c}),s.push({name:l.tableName+" table",type:"RECORD",value:l}),o+=a,ie.argument(!isNaN(o),"Something went wrong calculating the offset.");o%4!==0;)o+=1,s.push({name:"padding",type:"BYTE",value:0})}return i.sort(function(r,l){return r.value.tag>l.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function vl(n,e,t){for(let i=0;i<e.length;i+=1){const s=n.charToGlyphIndex(e[i]);if(s>0)return n.glyphs.get(s).getMetrics()}return t}function gA(n){let e=0;for(let t=0;t<n.length;t+=1)e+=n[t];return e/n.length}function mA(n){const e=[],t=[],i=[],s=[],o=[],r=[],l=[];let a,c=0,u=0,f=0,p=0,h=0;for(let D=0;D<n.glyphs.length;D+=1){const U=n.glyphs.get(D),V=U.unicode|0;if(isNaN(U.advanceWidth))throw new Error("Glyph "+U.name+" ("+D+"): advanceWidth is not a number.");(a>V||a===void 0)&&V>0&&(a=V),c<V&&(c=V);const $=Js.getUnicodeRange(V);if($<32)u|=1<<$;else if($<64)f|=1<<$-32;else if($<96)p|=1<<$-64;else if($<123)h|=1<<$-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(U.name===".notdef")continue;const X=U.getMetrics();e.push(X.xMin),t.push(X.yMin),i.push(X.xMax),s.push(X.yMax),r.push(X.leftSideBearing),l.push(X.rightSideBearing),o.push(U.advanceWidth)}const A={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,o),advanceWidthAvg:gA(o),minLeftSideBearing:Math.min.apply(null,r),maxLeftSideBearing:Math.max.apply(null,r),minRightSideBearing:Math.min.apply(null,l)};A.ascender=n.ascender,A.descender=n.descender;const C=ol.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:A.xMin,yMin:A.yMin,xMax:A.xMax,yMax:A.yMax,lowestRecPPEM:3,createdTimestamp:n.createdTimestamp}),m=rl.make({ascender:A.ascender,descender:A.descender,advanceWidthMax:A.advanceWidthMax,minLeftSideBearing:A.minLeftSideBearing,minRightSideBearing:A.minRightSideBearing,xMaxExtent:A.maxLeftSideBearing+(A.xMax-A.xMin),numberOfHMetrics:n.glyphs.length}),y=cl.make(n.glyphs.length),E=Js.make({xAvgCharWidth:Math.round(A.advanceWidthAvg),usWeightClass:n.tables.os2.usWeightClass,usWidthClass:n.tables.os2.usWidthClass,usFirstCharIndex:a,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:f,ulUnicodeRange3:p,ulUnicodeRange4:h,fsSelection:n.tables.os2.fsSelection,sTypoAscender:A.ascender,sTypoDescender:A.descender,sTypoLineGap:0,usWinAscent:A.yMax,usWinDescent:Math.abs(A.yMin),ulCodePageRange1:1,sxHeight:vl(n,"xyvw",{yMax:Math.round(A.ascender/2)}).yMax,sCapHeight:vl(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",A).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0}),I=al.make(n.glyphs),S=Va.make(n.glyphs),k=n.getEnglishName("fontFamily"),B=n.getEnglishName("fontSubfamily"),x=k+" "+B;let g=n.getEnglishName("postScriptName");g||(g=k.replace(/\s/g,"")+"-"+B);const R={};for(let D in n.names)R[D]=n.names[D];R.uniqueID||(R.uniqueID={en:n.getEnglishName("manufacturer")+":"+x}),R.postScriptName||(R.postScriptName={en:g}),R.preferredFamily||(R.preferredFamily=n.names.fontFamily),R.preferredSubfamily||(R.preferredSubfamily=n.names.fontSubfamily);const M=[],F=ml.make(R,M),L=M.length>0?ll.make(M):void 0,G=Al.make(),N=sl.make(n.glyphs,{version:n.getEnglishName("version"),fullName:x,familyName:k,weightName:B,postScriptName:g,unitsPerEm:n.unitsPerEm,fontBBox:[0,A.yMin,A.ascender,A.advanceWidthMax]}),v=n.metas&&Object.keys(n.metas).length>0?Cl.make(n.metas):void 0,w=[C,m,y,E,F,S,G,N,I];L&&w.push(L),n.tables.gsub&&w.push(yl.make(n.tables.gsub)),v&&w.push(v);const b=bl(w),T=b.encode(),P=Zs(T),_=b.fields;let O=!1;for(let D=0;D<_.length;D+=1)if(_[D].name==="head table"){_[D].value.checkSumAdjustment=2981146554-P,O=!0;break}if(!O)throw new Error("Could not find head table with checkSum to adjust.");return b}const AA={make:bl,fontToTable:mA,computeCheckSum:Zs};function eo(n,e){let t=0,i=n.length-1;for(;t<=i;){const s=t+i>>>1,o=n[s].tag;if(o===e)return s;o<e?t=s+1:i=s-1}return-t-1}function Il(n,e){let t=0,i=n.length-1;for(;t<=i;){const s=t+i>>>1,o=n[s];if(o===e)return s;o<e?t=s+1:i=s-1}return-t-1}function xl(n,e){let t,i=0,s=n.length-1;for(;i<=s;){const o=i+s>>>1;t=n[o];const r=t.start;if(r===e)return t;r<e?i=o+1:s=o-1}if(i>0)return t=n[i-1],e>t.end?0:t}function Dn(n,e){this.font=n,this.tableName=e}Dn.prototype={searchTag:eo,binSearch:Il,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t<n.scripts.length;t++){const i=n.scripts[t].tag;if(i==="DFLT")return i;i==="latn"&&(e=!0)}if(e)return"latn"},getScriptTable:function(n,e){const t=this.getTable(e);if(t){n=n||"DFLT";const i=t.scripts,s=eo(t.scripts,n);if(s>=0)return i[s].script;if(e){const o={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,o),o.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=eo(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const o={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,o),o.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);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(i){const a=l.length;return ie.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(n,e,t,i,s){const o=this.getFeatureTable(n,e,t,s),r=[];if(o){let l;const a=o.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u<a.length;u++)l=c[a[u]],l.lookupType===i&&r.push(l);if(r.length===0&&s){l={lookupType:i,lookupFlag:0,subtables:[],markFilteringSet:void 0};const u=c.length;return c.push(l),a.push(u),[l]}}return r},getGlyphClass:function(n,e){switch(n.format){case 1:return n.startGlyph<=e&&e<n.startGlyph+n.classes.length?n.classes[e-n.startGlyph]:0;case 2:const t=xl(n.ranges,e);return t?t.classId:0}},getCoverageIndex:function(n,e){switch(n.format){case 1:const t=Il(n.glyphs,e);return t>=0?t:-1;case 2:const i=xl(n.ranges,e);return i?i.index+e-i.start:-1}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;i<t.length;i++){const s=t[i],o=s.start,r=s.end;for(let l=o;l<=r;l++)e.push(l)}return e}}};function kn(n){Dn.call(this,n,"gpos")}kn.prototype=Dn.prototype,kn.prototype.init=function(){const n=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(n)},kn.prototype.getKerningValue=function(n,e,t){for(let i=0;i<n.length;i++){const s=n[i].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 p=0;p<a.length;p++){let h=a[p];if(h.secondGlyph===t)return h.value1&&h.value1.xAdvance||0}break;case 2:const c=this.getGlyphClass(r.classDef1,e),u=this.getGlyphClass(r.classDef2,t),f=r.classRecords[c][u];return f.value1&&f.value1.xAdvance||0}}}return 0},kn.prototype.getKerningTables=function(n,e){if(this.font.tables.gpos)return this.getLookupTables(n,e,"kern",2)};function Ve(n){Dn.call(this,n,"gsub")}function yA(n,e){const t=n.length;if(t!==e.length)return!1;for(let i=0;i<t;i++)if(n[i]!==e[i])return!1;return!0}function Bl(n,e,t){const i=n.subtables;for(let s=0;s<i.length;s++){const o=i[s];if(o.substFormat===e)return o}if(t)return i.push(t),t}Ve.prototype=Dn.prototype,Ve.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Ve.prototype.getSingle=function(n,e,t){const i=[],s=this.getLookupTables(e,t,n,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],c=this.expandCoverage(a.coverage);let u;if(a.substFormat===1){const f=a.deltaGlyphId;for(u=0;u<c.length;u++){const p=c[u];i.push({sub:p,by:p+f})}}else{const f=a.substitute;for(u=0;u<c.length;u++)i.push({sub:c[u],by:f[u]})}}}return i},Ve.prototype.getAlternates=function(n,e,t){const i=[],s=this.getLookupTables(e,t,n,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],c=this.expandCoverage(a.coverage),u=a.alternateSets;for(let f=0;f<c.length;f++)i.push({sub:c[f],by:u[f]})}}return i},Ve.prototype.getLigatures=function(n,e,t){const i=[],s=this.getLookupTables(e,t,n,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],c=this.expandCoverage(a.coverage),u=a.ligatureSets;for(let f=0;f<c.length;f++){const p=c[f],h=u[f];for(let A=0;A<h.length;A++){const C=h[A];i.push({sub:[p].concat(C.components),by:C.ligGlyph})}}}}return i},Ve.prototype.addSingle=function(n,e,t,i){const s=this.getLookupTables(t,i,n,1,!0)[0],o=Bl(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});ie.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},Ve.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],o=Bl(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ie.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},Ve.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let o=s.subtables[0];o||(o={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=o),ie.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 c=this.binSearch(o.coverage.glyphs,r);if(c>=0){const u=o.ligatureSets[c];for(let f=0;f<u.length;f++)if(yA(u[f].components,l))return;u.push(a)}else c=-1-c,o.coverage.glyphs.splice(c,0,r),o.ligatureSets.splice(c,0,[a])},Ve.prototype.getFeature=function(n,e,t){if(/ss\d\d/.test(n))return this.getSingle(n,e,t);switch(n){case"aalt":case"salt":return this.getSingle(n,e,t).concat(this.getAlternates(n,e,t));case"dlig":case"liga":case"rlig":return this.getLigatures(n,e,t)}},Ve.prototype.add=function(n,e,t,i){if(/ss\d\d/.test(n))return this.addSingle(n,e,t,i);switch(n){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(n,e,t,i):this.addAlternate(n,e,t,i);case"dlig":case"liga":case"rlig":return this.addLigature(n,e,t,i)}};function CA(){return typeof window<"u"}function EA(n){const e=new ArrayBuffer(n.length),t=new Uint8Array(e);for(let i=0;i<n.length;++i)t[i]=n[i];return e}function wA(n){const e=new Buffer(n.byteLength),t=new Uint8Array(n);for(let i=0;i<e.length;++i)e[i]=t[i];return e}function ln(n,e){if(!n)throw e}function Sl(n,e,t,i,s){let o;return(e&i)>0?(o=n.parseByte(),(e&s)===0&&(o=-o),o=t+o):(e&s)>0?o=t:o=t+n.parseShort(),o}function bA(n,e,t){const i=new q.Parser(e,t);n.numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,o;if(n.numberOfContours>0){const r=n.endPointIndices=[];for(let a=0;a<n.numberOfContours;a+=1)r.push(i.parseUShort());n.instructionLength=i.parseUShort(),n.instructions=[];for(let a=0;a<n.instructionLength;a+=1)n.instructions.push(i.parseByte());const l=r[r.length-1]+1;s=[];for(let a=0;a<l;a+=1)if(o=i.parseByte(),s.push(o),(o&8)>0){const c=i.parseByte();for(let u=0;u<c;u+=1)s.push(o),a+=1}if(ie.argument(s.length===l,"Bad flags."),r.length>0){const a=[];let c;if(l>0){for(let p=0;p<l;p+=1)o=s[p],c={},c.onCurve=!!(o&1),c.lastPointOfContour=r.indexOf(p)>=0,a.push(c);let u=0;for(let p=0;p<l;p+=1)o=s[p],c=a[p],c.x=Sl(i,o,u,2,16),u=c.x;let f=0;for(let p=0;p<l;p+=1)o=s[p],c=a[p],c.y=Sl(i,o,f,4,32),f=c.y}n.points=a}else n.points=[]}else if(n.numberOfContours===0)n.points=[];else{n.isComposite=!0,n.points=[],n.components=[];let r=!0;for(;r;){s=i.parseUShort();const l={glyphIndex:i.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(l.dx=i.parseShort(),l.dy=i.parseShort()):l.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(l.dx=i.parseChar(),l.dy=i.parseChar()):l.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?l.xScale=l.yScale=i.parseF2Dot14():(s&64)>0?(l.xScale=i.parseF2Dot14(),l.yScale=i.parseF2Dot14()):(s&128)>0&&(l.xScale=i.parseF2Dot14(),l.scale01=i.parseF2Dot14(),l.scale10=i.parseF2Dot14(),l.yScale=i.parseF2Dot14()),n.components.push(l),r=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let l=0;l<n.instructionLength;l+=1)n.instructions.push(i.parseByte())}}}function to(n,e){const t=[];for(let i=0;i<n.length;i+=1){const s=n[i],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 vA(n){const e=[];let t=[];for(let i=0;i<n.length;i+=1){const s=n[i];t.push(s),s.lastPointOfContour&&(e.push(t),t=[])}return ie.argument(t.length===0,"There are still points left in the current contour."),e}function Ml(n){const e=new Ie;if(!n)return e;const t=vA(n);for(let i=0;i<t.length;++i){const s=t[i];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 c=l;o.onCurve||((r.x+o.x)*.5,(r.y+o.y)*.5),l.onCurve||(c={x:(r.x+l.x)*.5,y:(r.y+l.y)*.5}),e.quadraticCurveTo(r.x,r.y,c.x,c.y)}e.closePath()}return e}function IA(n,e){if(e.isComposite)for(let t=0;t<e.components.length;t+=1){const i=e.components[t],s=n.get(i.glyphIndex);if(s.getPath(),s.points){let o;if(i.matchedPoints===void 0)o=to(s.points,i);else{if(i.matchedPoints[0]>e.points.length-1||i.matchedPoints[1]>s.points.length-1)throw Error("Matched points out of range in "+e.name);const r=e.points[i.matchedPoints[0]];let l=s.points[i.matchedPoints[1]];const a={xScale:i.xScale,scale01:i.scale01,scale10:i.scale10,yScale:i.yScale,dx:0,dy:0};l=to([l],a)[0],a.dx=r.x-l.x,a.dy=r.y-l.y,o=to(s.points,a)}e.points=e.points.concat(o)}}return Ml(e.points)}function xA(n,e,t,i){const s=new rn.GlyphSet(i);for(let o=0;o<t.length-1;o+=1){const r=t[o],l=t[o+1];r!==l?s.push(o,rn.ttfGlyphLoader(i,o,bA,n,e+r,IA)):s.push(o,rn.glyphLoader(i,o))}return s}const Tl={getPath:Ml,parse:xA};let Dl,Ot,kl,no;function Pl(n){this.font=n,this.getCommands=function(e){return Tl.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function BA(n){return n}function Fl(n){return Math.sign(n)*Math.round(Math.abs(n))}function SA(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function MA(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function TA(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function DA(n){return Math.sign(n)*Math.floor(Math.abs(n))}const Rl=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},nt={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,o,r,l,a,c,u;if(!i||i===this){if(s=n.xo-e.xo,o=n.xo-t.xo,a=e.x-e.xo,c=t.x-t.xo,r=Math.abs(s),l=Math.abs(o),u=r+l,u===0){n.x=n.xo+(a+c)/2;return}n.x=n.xo+(a*l+c*r)/u;return}if(s=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),a=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),r=Math.abs(s),l=Math.abs(o),u=r+l,u===0){nt.setRelative(n,n,(a+c)/2,i,!0);return}nt.setRelative(n,n,(a*l+c*r)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*i.x,a=r+t*i.y;n.x=l+(n.y-a)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},lt={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,o,r,l,a,c,u;if(!i||i===this){if(s=n.yo-e.yo,o=n.yo-t.yo,a=e.y-e.yo,c=t.y-t.yo,r=Math.abs(s),l=Math.abs(o),u=r+l,u===0){n.y=n.yo+(a+c)/2;return}n.y=n.yo+(a*l+c*r)/u;return}if(s=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),a=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),r=Math.abs(s),l=Math.abs(o),u=r+l,u===0){lt.setRelative(n,n,(a+c)/2,i,!0);return}lt.setRelative(n,n,(a*l+c*r)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*i.x,a=r+t*i.y;n.y=a+i.normalSlope*(n.x-l)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze(nt),Object.freeze(lt);function Pn(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Pn.prototype.distance=function(n,e,t,i){return this.x*nt.distance(n,e,t,i)+this.y*lt.distance(n,e,t,i)},Pn.prototype.interpolate=function(n,e,t,i){let s,o,r,l,a,c,u;if(r=i.distance(n,e,!0,!0),l=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),o=i.distance(t,t,!1,!0),a=Math.abs(r),c=Math.abs(l),u=a+c,u===0){this.setRelative(n,n,(s+o)/2,i,!0);return}this.setRelative(n,n,(s*c+o*a)/u,i,!0)},Pn.prototype.setRelative=function(n,e,t,i,s){i=i||this;const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*i.x,a=r+t*i.y,c=i.normalSlope,u=this.slope,f=n.x,p=n.y;n.x=(u*f-c*l+a-p)/(u-c),n.y=u*(n.x-f)+p},Pn.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function Fn(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?nt:n===0&&e===1?lt:new Pn(n,e)}function ct(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}ct.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e},ct.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};const Rn=Object.freeze(new ct(0,0)),kA={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function wt(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=nt,this.round=Fl}}Pl.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){wt.prototype=kA,s=this._fpgmState=new wt("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,Q.DEBUG&&(console.log("---EXEC FPGM---"),s.step=-1);try{Ot(s)}catch(r){console.log("Hinting error in FPGM:"+r),this._errorState=3;return}}wt.prototype=s,i=this._prepState=new wt("prep",t.tables.prep),i.ppem=e;const o=t.tables.cvt;if(o){const r=i.cvt=new Array(o.length),l=e/t.unitsPerEm;for(let a=0;a<o.length;a++)r[a]=o[a]*l}else i.cvt=[];Q.DEBUG&&(console.log("---EXEC PREP---"),i.step=-1);try{Ot(i)}catch(r){this._errorState<2&&console.log("Hinting error in PREP:"+r),this._errorState=2}}if(!(this._errorState>1))try{return kl(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},kl=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,o,r,l;if(wt.prototype=e,!s)l=new wt("glyf",n.instructions),Q.DEBUG&&(console.log("---EXEC GLYPH---"),l.step=-1),no(n,l,t,i),r=l.gZone;else{const a=e.font;r=[],o=[];for(let c=0;c<s.length;c++){const u=s[c],f=a.glyphs.get(u.glyphIndex);l=new wt("glyf",f.instructions),Q.DEBUG&&(console.log("---EXEC COMP "+c+"---"),l.step=-1),no(f,l,t,i);const p=Math.round(u.dx*t),h=Math.round(u.dy*i),A=l.gZone,C=l.contours;for(let y=0;y<A.length;y++){const E=A[y];E.xTouched=E.yTouched=!1,E.xo=E.x=E.x+p,E.yo=E.y=E.y+h}const m=r.length;r.push.apply(r,A);for(let y=0;y<C.length;y++)o.push(C[y]+m)}n.instructions&&!l.inhibitGridFit&&(l=new wt("glyf",n.instructions),l.gZone=l.z0=l.z1=l.z2=r,l.contours=o,r.push(new ct(0,0),new ct(Math.round(n.advanceWidth*t),0)),Q.DEBUG&&(console.log("---EXEC COMPOSITE---"),l.step=-1),Ot(l),r.length-=2)}return r},no=function(n,e,t,i){const s=n.points||[],o=s.length,r=e.gZone=e.z0=e.z1=e.z2=[],l=e.contours=[];let a;for(let f=0;f<o;f++)a=s[f],r[f]=new ct(a.x*t,a.y*i,a.lastPointOfContour,a.onCurve);let c,u;for(let f=0;f<o;f++)a=r[f],c||(c=a,l.push(f)),a.lastPointOfContour?(a.nextPointOnContour=c,c.prevPointOnContour=a,c=void 0):(u=r[f+1],a.nextPointOnContour=u,u.prevPointOnContour=a);if(!e.inhibitGridFit){if(Q.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(let f=0;f<o;f++)console.log(f,r[f].x,r[f].y)}if(r.push(new ct(0,0),new ct(Math.round(n.advanceWidth*t),0)),Ot(e),r.length-=2,Q.DEBUG){console.log("FINISHED GLYPH",e.stack);for(let f=0;f<o;f++)console.log(f,r[f].x,r[f].y)}}},Ot=function(n){let e=n.prog;if(!e)return;const t=e.length;let i;for(n.ip=0;n.ip<t;n.ip++){if(Q.DEBUG&&n.step++,i=Dl[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function Ti(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t<e.length;t++)e[t]=new ct(0,0)}function Ol(n,e){const t=n.prog;let i=n.ip,s=1,o;do if(o=t[++i],o===88)s++;else if(o===89)s--;else if(o===64)i+=t[i+1]+1;else if(o===65)i+=2*t[i+1]+1;else if(o>=176&&o<=183)i+=o-176+1;else if(o>=184&&o<=191)i+=(o-184+1)*2;else if(e&&s===1&&o===27)break;while(s>0);n.ip=i}function Ll(n,e){Q.DEBUG&&console.log(e.step,"SVTCA["+n.axis+"]"),e.fv=e.pv=e.dpv=n}function Nl(n,e){Q.DEBUG&&console.log(e.step,"SPVTCA["+n.axis+"]"),e.pv=e.dpv=n}function Ul(n,e){Q.DEBUG&&console.log(e.step,"SFVTCA["+n.axis+"]"),e.fv=n}function _l(n,e){const t=e.stack,i=t.pop(),s=t.pop(),o=e.z2[i],r=e.z1[s];Q.DEBUG&&console.log("SPVTL["+n+"]",i,s);let l,a;n?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.pv=e.dpv=Fn(l,a)}function Ql(n,e){const t=e.stack,i=t.pop(),s=t.pop(),o=e.z2[i],r=e.z1[s];Q.DEBUG&&console.log("SFVTL["+n+"]",i,s);let l,a;n?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.fv=Fn(l,a)}function PA(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"SPVFS[]",t,i),n.pv=n.dpv=Fn(i,t)}function FA(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"SPVFS[]",t,i),n.fv=Fn(i,t)}function RA(n){const e=n.stack,t=n.pv;Q.DEBUG&&console.log(n.step,"GPV[]"),e.push(t.x*16384),e.push(t.y*16384)}function OA(n){const e=n.stack,t=n.fv;Q.DEBUG&&console.log(n.step,"GFV[]"),e.push(t.x*16384),e.push(t.y*16384)}function LA(n){n.fv=n.pv,Q.DEBUG&&console.log(n.step,"SFVTPV[]")}function NA(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),o=e.pop(),r=e.pop(),l=n.z0,a=n.z1,c=l[t],u=l[i],f=a[s],p=a[o],h=n.z2[r];Q.DEBUG&&console.log("ISECT[], ",t,i,s,o,r);const A=c.x,C=c.y,m=u.x,y=u.y,E=f.x,I=f.y,S=p.x,k=p.y,B=(A-m)*(I-k)-(C-y)*(E-S),x=A*y-C*m,g=E*k-I*S;h.x=(x*(E-S)-g*(A-m))/B,h.y=(x*(I-k)-g*(C-y))/B}function UA(n){n.rp0=n.stack.pop(),Q.DEBUG&&console.log(n.step,"SRP0[]",n.rp0)}function _A(n){n.rp1=n.stack.pop(),Q.DEBUG&&console.log(n.step,"SRP1[]",n.rp1)}function QA(n){n.rp2=n.stack.pop(),Q.DEBUG&&console.log(n.step,"SRP2[]",n.rp2)}function HA(n){const e=n.stack.pop();switch(Q.DEBUG&&console.log(n.step,"SZP0[]",e),n.zp0=e,e){case 0:n.tZone||Ti(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function GA(n){const e=n.stack.pop();switch(Q.DEBUG&&console.log(n.step,"SZP1[]",e),n.zp1=e,e){case 0:n.tZone||Ti(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function YA(n){const e=n.stack.pop();switch(Q.DEBUG&&console.log(n.step,"SZP2[]",e),n.zp2=e,e){case 0:n.tZone||Ti(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function VA(n){const e=n.stack.pop();switch(Q.DEBUG&&console.log(n.step,"SZPS[]",e),n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Ti(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function WA(n){n.loop=n.stack.pop(),Q.DEBUG&&console.log(n.step,"SLOOP[]",n.loop)}function zA(n){Q.DEBUG&&console.log(n.step,"RTG[]"),n.round=Fl}function jA(n){Q.DEBUG&&console.log(n.step,"RTHG[]"),n.round=MA}function $A(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"SMD[]",e),n.minDis=e/64}function KA(n){Q.DEBUG&&console.log(n.step,"ELSE[]"),Ol(n,!1)}function qA(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"JMPR[]",e),n.ip+=e-1}function XA(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"SCVTCI[]",e),n.cvCutIn=e/64}function JA(n){const e=n.stack;Q.DEBUG&&console.log(n.step,"DUP[]"),e.push(e[e.length-1])}function io(n){Q.DEBUG&&console.log(n.step,"POP[]"),n.stack.pop()}function ZA(n){Q.DEBUG&&console.log(n.step,"CLEAR[]"),n.stack.length=0}function ey(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"SWAP[]"),e.push(t),e.push(i)}function ty(n){const e=n.stack;Q.DEBUG&&console.log(n.step,"DEPTH[]"),e.push(e.length)}function ny(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"LOOPCALL[]",t,i);const s=n.ip,o=n.prog;n.prog=n.funcs[t];for(let r=0;r<i;r++)Ot(n),Q.DEBUG&&console.log(++n.step,r+1<i?"next loopcall":"done loopcall",r);n.ip=s,n.prog=o}function iy(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"CALL[]",e);const t=n.ip,i=n.prog;n.prog=n.funcs[e],Ot(n),n.ip=t,n.prog=i,Q.DEBUG&&console.log(++n.step,"returning from",e)}function sy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"CINDEX[]",t),e.push(e[e.length-t])}function oy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"MINDEX[]",t),e.push(e.splice(e.length-t,1)[0])}function ry(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),o=i;for(Q.DEBUG&&console.log(n.step,"FDEF[]",s);t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(o+1,i)}function Hl(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,o=e.pv;Q.DEBUG&&console.log(e.step,"MDAP["+n+"]",t);let r=o.distance(i,Rn);n&&(r=e.round(r)),s.setRelative(i,Rn,r,o),s.touch(i),e.rp0=e.rp1=t}function Gl(n,e){const t=e.z2,i=t.length-2;let s,o,r;Q.DEBUG&&console.log(e.step,"IUP["+n.axis+"]");for(let l=0;l<i;l++)s=t[l],!n.touched(s)&&(o=s.prevTouched(n),o!==s&&(r=s.nextTouched(n),o===r&&n.setRelative(s,s,n.distance(o,o,!1,!0),n,!0),n.interpolate(s,o,r,n)))}function Yl(n,e){const t=e.stack,i=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[i],o=e.fv,r=e.pv;let l=e.loop;const a=e.z2;for(;l--;){const c=t.pop(),u=a[c],f=r.distance(s,s,!1,!0);o.setRelative(u,u,f,r),o.touch(u),Q.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-l)+": ":"")+"SHP["+(n?"rp1":"rp2")+"]",c)}e.loop=1}function Vl(n,e){const t=e.stack,i=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[i],o=e.fv,r=e.pv,l=t.pop(),a=e.z2[e.contours[l]];let c=a;Q.DEBUG&&console.log(e.step,"SHC["+n+"]",l);const u=r.distance(s,s,!1,!0);do c!==s&&o.setRelative(c,c,u,r),c=c.nextPointOnContour;while(c!==a)}function Wl(n,e){const t=e.stack,i=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[i],o=e.fv,r=e.pv,l=t.pop();Q.DEBUG&&console.log(e.step,"SHZ["+n+"]",l);let a;switch(l){case 0:a=e.tZone;break;case 1:a=e.gZone;break;default:throw new Error("Invalid zone")}let c;const u=r.distance(s,s,!1,!0),f=a.length-2;for(let p=0;p<f;p++)c=a[p],o.setRelative(c,c,u,r)}function ay(n){const e=n.stack;let t=n.loop;const i=n.fv,s=e.pop()/64,o=n.z2;for(;t--;){const r=e.pop(),l=o[r];Q.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-t)+": ":"")+"SHPIX[]",r,s),i.setRelative(l,l,s),i.touch(l)}n.loop=1}function ly(n){const e=n.stack,t=n.rp1,i=n.rp2;let s=n.loop;const o=n.z0[t],r=n.z1[i],l=n.fv,a=n.dpv,c=n.z2;for(;s--;){const u=e.pop(),f=c[u];Q.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-s)+": ":"")+"IP[]",u,t,"<->",i),l.interpolate(f,o,r,a),l.touch(f)}n.loop=1}function zl(n,e){const t=e.stack,i=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,i,a),l.touch(o),Q.DEBUG&&console.log(e.step,"MSIRP["+n+"]",i,s),e.rp1=e.rp0,e.rp2=s,n&&(e.rp0=s)}function cy(n){const e=n.stack,t=n.rp0,i=n.z0[t];let s=n.loop;const o=n.fv,r=n.pv,l=n.z1;for(;s--;){const a=e.pop(),c=l[a];Q.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-s)+": ":"")+"ALIGNRP[]",a),o.setRelative(c,i,0,r),o.touch(c)}n.loop=1}function dy(n){Q.DEBUG&&console.log(n.step,"RTDG[]"),n.round=SA}function jl(n,e){const t=e.stack,i=t.pop(),s=t.pop(),o=e.z0[s],r=e.fv,l=e.pv;let a=e.cvt[i];Q.DEBUG&&console.log(e.step,"MIAP["+n+"]",i,"(",a,")",s);let c=l.distance(o,Rn);n&&(Math.abs(c-a)<e.cvCutIn&&(c=a),c=e.round(c)),r.setRelative(o,Rn,c,l),e.zp0===0&&(o.xo=o.x,o.yo=o.y),r.touch(o),e.rp0=e.rp1=s}function uy(n){const e=n.prog;let t=n.ip;const i=n.stack,s=e[++t];Q.DEBUG&&console.log(n.step,"NPUSHB[]",s);for(let o=0;o<s;o++)i.push(e[++t]);n.ip=t}function hy(n){let e=n.ip;const t=n.prog,i=n.stack,s=t[++e];Q.DEBUG&&console.log(n.step,"NPUSHW[]",s);for(let o=0;o<s;o++){let r=t[++e]<<8|t[++e];r&32768&&(r=-((r^65535)+1)),i.push(r)}n.ip=e}function fy(n){const e=n.stack;let t=n.store;t||(t=n.store=[]);const i=e.pop(),s=e.pop();Q.DEBUG&&console.log(n.step,"WS",i,s),t[s]=i}function py(n){const e=n.stack,t=n.store,i=e.pop();Q.DEBUG&&console.log(n.step,"RS",i);const s=t&&t[i]||0;e.push(s)}function gy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"WCVTP",t,i),n.cvt[i]=t/64}function my(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"RCVT",t),e.push(n.cvt[t]*64)}function $l(n,e){const t=e.stack,i=t.pop(),s=e.z2[i];Q.DEBUG&&console.log(e.step,"GC["+n+"]",i),t.push(e.dpv.distance(s,Rn,n,!1)*64)}function Kl(n,e){const t=e.stack,i=t.pop(),s=t.pop(),o=e.z1[i],r=e.z0[s],l=e.dpv.distance(r,o,n,n);Q.DEBUG&&console.log(e.step,"MD["+n+"]",i,s,"->",l),e.stack.push(Math.round(l*64))}function Ay(n){Q.DEBUG&&console.log(n.step,"MPPEM[]"),n.stack.push(n.ppem)}function yy(n){Q.DEBUG&&console.log(n.step,"FLIPON[]"),n.autoFlip=!0}function Cy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"LT[]",t,i),e.push(i<t?1:0)}function Ey(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"LTEQ[]",t,i),e.push(i<=t?1:0)}function wy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"GT[]",t,i),e.push(i>t?1:0)}function by(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"GTEQ[]",t,i),e.push(i>=t?1:0)}function vy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"EQ[]",t,i),e.push(t===i?1:0)}function Iy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"NEQ[]",t,i),e.push(t!==i?1:0)}function xy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"ODD[]",t),e.push(Math.trunc(t)%2?1:0)}function By(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"EVEN[]",t),e.push(Math.trunc(t)%2?0:1)}function Sy(n){let e=n.stack.pop();Q.DEBUG&&console.log(n.step,"IF[]",e),e||(Ol(n,!0),Q.DEBUG&&console.log(n.step,"EIF[]"))}function My(n){Q.DEBUG&&console.log(n.step,"EIF[]")}function Ty(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"AND[]",t,i),e.push(t&&i?1:0)}function Dy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"OR[]",t,i),e.push(t||i?1:0)}function ky(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"NOT[]",t),e.push(t?0:1)}function so(n,e){const t=e.stack,i=t.pop(),s=e.fv,o=e.pv,r=e.ppem,l=e.deltaBase+(n-1)*16,a=e.deltaShift,c=e.z0;Q.DEBUG&&console.log(e.step,"DELTAP["+n+"]",i,t);for(let u=0;u<i;u++){const f=t.pop(),p=t.pop();if(l+((p&240)>>4)!==r)continue;let A=(p&15)-8;A>=0&&A++,Q.DEBUG&&console.log(e.step,"DELTAPFIX",f,"by",A*a);const C=c[f];s.setRelative(C,C,A*a,o)}}function Py(n){const t=n.stack.pop();Q.DEBUG&&console.log(n.step,"SDB[]",t),n.deltaBase=t}function Fy(n){const t=n.stack.pop();Q.DEBUG&&console.log(n.step,"SDS[]",t),n.deltaShift=Math.pow(.5,t)}function Ry(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"ADD[]",t,i),e.push(i+t)}function Oy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"SUB[]",t,i),e.push(i-t)}function Ly(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"DIV[]",t,i),e.push(i*64/t)}function Ny(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"MUL[]",t,i),e.push(i*t/64)}function Uy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"ABS[]",t),e.push(Math.abs(t))}function _y(n){const e=n.stack;let t=e.pop();Q.DEBUG&&console.log(n.step,"NEG[]",t),e.push(-t)}function Qy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"FLOOR[]",t),e.push(Math.floor(t/64)*64)}function Hy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"CEILING[]",t),e.push(Math.ceil(t/64)*64)}function Di(n,e){const t=e.stack,i=t.pop();Q.DEBUG&&console.log(e.step,"ROUND[]"),t.push(e.round(i/64)*64)}function Gy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"WCVTF[]",t,i),n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function oo(n,e){const t=e.stack,i=t.pop(),s=e.ppem,o=e.deltaBase+(n-1)*16,r=e.deltaShift;Q.DEBUG&&console.log(e.step,"DELTAC["+n+"]",i,t);for(let l=0;l<i;l++){const a=t.pop(),c=t.pop();if(o+((c&240)>>4)!==s)continue;let f=(c&15)-8;f>=0&&f++;const p=f*r;Q.DEBUG&&console.log(e.step,"DELTACFIX",a,"by",p),e.cvt[a]+=p}}function Yy(n){let e=n.stack.pop();Q.DEBUG&&console.log(n.step,"SROUND[]",e),n.round=Rl;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(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function Vy(n){let e=n.stack.pop();Q.DEBUG&&console.log(n.step,"S45ROUND[]",e),n.round=Rl;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(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function Wy(n){Q.DEBUG&&console.log(n.step,"ROFF[]"),n.round=BA}function zy(n){Q.DEBUG&&console.log(n.step,"RUTG[]"),n.round=TA}function jy(n){Q.DEBUG&&console.log(n.step,"RDTG[]"),n.round=DA}function $y(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"SCANCTRL[]",e)}function ql(n,e){const t=e.stack,i=t.pop(),s=t.pop(),o=e.z2[i],r=e.z1[s];Q.DEBUG&&console.log(e.step,"SDPVTL["+n+"]",i,s);let l,a;n?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.dpv=Fn(l,a)}function Ky(n){const e=n.stack,t=e.pop();let i=0;Q.DEBUG&&console.log(n.step,"GETINFO[]",t),t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function qy(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();Q.DEBUG&&console.log(n.step,"ROLL[]"),e.push(i),e.push(t),e.push(s)}function Xy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"MAX[]",t,i),e.push(Math.max(i,t))}function Jy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"MIN[]",t,i),e.push(Math.min(i,t))}function Zy(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"SCANTYPE[]",e)}function e0(n){const e=n.stack.pop();let t=n.stack.pop();switch(Q.DEBUG&&console.log(n.step,"INSTCTRL[]",e,t),e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function bt(n,e){const t=e.stack,i=e.prog;let s=e.ip;Q.DEBUG&&console.log(e.step,"PUSHB["+n+"]");for(let o=0;o<n;o++)t.push(i[++s]);e.ip=s}function vt(n,e){let t=e.ip;const i=e.prog,s=e.stack;Q.DEBUG&&console.log(e.ip,"PUSHW["+n+"]");for(let o=0;o<n;o++){let r=i[++t]<<8|i[++t];r&32768&&(r=-((r^65535)+1)),s.push(r)}e.ip=t}function K(n,e,t,i,s,o){const r=o.stack,l=n&&r.pop(),a=r.pop(),c=o.rp0,u=o.z0[c],f=o.z1[a],p=o.minDis,h=o.fv,A=o.dpv;let C,m,y,E;m=C=A.distance(f,u,!0,!0),y=m>=0?1:-1,m=Math.abs(m),n&&(E=o.cvt[l],i&&Math.abs(m-E)<o.cvCutIn&&(m=E)),t&&m<p&&(m=p),i&&(m=o.round(m)),h.setRelative(f,u,y*m,A),h.touch(f),Q.DEBUG&&console.log(o.step,(n?"MIRP[":"MDRP[")+(e?"M":"m")+(t?">":"_")+(i?"R":"_")+(s===0?"Gr":s===1?"Bl":s===2?"Wh":"")+"]",n?l+"("+o.cvt[l]+","+E+")":"",a,"(d =",C,"->",y*m,")"),o.rp1=o.rp0,o.rp2=a,e&&(o.rp0=a)}Dl=[Ll.bind(void 0,lt),Ll.bind(void 0,nt),Nl.bind(void 0,lt),Nl.bind(void 0,nt),Ul.bind(void 0,lt),Ul.bind(void 0,nt),_l.bind(void 0,0),_l.bind(void 0,1),Ql.bind(void 0,0),Ql.bind(void 0,1),PA,FA,RA,OA,LA,NA,UA,_A,QA,HA,GA,YA,VA,WA,zA,jA,$A,KA,qA,XA,void 0,void 0,JA,io,ZA,ey,ty,sy,oy,void 0,void 0,void 0,ny,iy,ry,void 0,Hl.bind(void 0,0),Hl.bind(void 0,1),Gl.bind(void 0,lt),Gl.bind(void 0,nt),Yl.bind(void 0,0),Yl.bind(void 0,1),Vl.bind(void 0,0),Vl.bind(void 0,1),Wl.bind(void 0,0),Wl.bind(void 0,1),ay,ly,zl.bind(void 0,0),zl.bind(void 0,1),cy,dy,jl.bind(void 0,0),jl.bind(void 0,1),uy,hy,fy,py,gy,my,$l.bind(void 0,0),$l.bind(void 0,1),void 0,Kl.bind(void 0,0),Kl.bind(void 0,1),Ay,void 0,yy,void 0,void 0,Cy,Ey,wy,by,vy,Iy,xy,By,Sy,My,Ty,Dy,ky,so.bind(void 0,1),Py,Fy,Ry,Oy,Ly,Ny,Uy,_y,Qy,Hy,Di.bind(void 0,0),Di.bind(void 0,1),Di.bind(void 0,2),Di.bind(void 0,3),void 0,void 0,void 0,void 0,Gy,so.bind(void 0,2),so.bind(void 0,3),oo.bind(void 0,1),oo.bind(void 0,2),oo.bind(void 0,3),Yy,Vy,void 0,void 0,Wy,void 0,zy,jy,io,io,void 0,void 0,void 0,void 0,void 0,$y,ql.bind(void 0,0),ql.bind(void 0,1),Ky,void 0,qy,Xy,Jy,Zy,e0,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,bt.bind(void 0,1),bt.bind(void 0,2),bt.bind(void 0,3),bt.bind(void 0,4),bt.bind(void 0,5),bt.bind(void 0,6),bt.bind(void 0,7),bt.bind(void 0,8),vt.bind(void 0,1),vt.bind(void 0,2),vt.bind(void 0,3),vt.bind(void 0,4),vt.bind(void 0,5),vt.bind(void 0,6),vt.bind(void 0,7),vt.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 t0=Array.from||(n=>n.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g)||[]);function ue(n){n=n||{},n.empty||(ln(n.familyName,"When creating a new Font object, familyName is required."),ln(n.styleName,"When creating a new Font object, styleName is required."),ln(n.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),ln(n.ascender,"When creating a new Font object, ascender is required."),ln(n.descender,"When creating a new Font object, descender is required."),ln(n.descender<0,"Descender should be negative (e.g. -512)."),this.names={fontFamily:{en:n.familyName||" "},fontSubfamily:{en:n.styleName||" "},fullName:{en:n.fullName||n.familyName+" "+n.styleName},postScriptName:{en:n.postScriptName||(n.familyName+n.styleName).replace(/\s/g,"")},designer:{en:n.designer||" "},designerURL:{en:n.designerURL||" "},manufacturer:{en:n.manufacturer||" "},manufacturerURL:{en:n.manufacturerURL||" "},license:{en:n.license||" "},licenseURL:{en:n.licenseURL||" "},version:{en:n.version||"Version 0.1"},description:{en:n.description||" "},copyright:{en:n.copyright||" "},trademark:{en:n.trademark||" "}},this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.tables={os2:{usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,fsSelection:n.fsSelection||this.fsSelectionValues.REGULAR}}),this.supported=!0,this.glyphs=new rn.GlyphSet(this,n.glyphs||[]),this.encoding=new Wa(this),this.position=new kn(this),this.substitution=new Ve(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 Pl(this)}})}ue.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)!==null},ue.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)},ue.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},ue.prototype.stringToGlyphs=function(n,e){e=e||this.defaultRenderOptions;const t=t0(n),i=[];for(let l=0;l<t.length;l+=1){const a=t[l];i.push(this.charToGlyphIndex(a))}let s=i.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 c=0;c<s;c+=1)for(let u=0;u<a.length;u++){const f=a[u],p=f.sub,h=p.length;let A=0;for(;A<h&&p[A]===i[c+A];)A++;A===h&&(i.splice(c,h,f.by),s=s-h+1)}}const o=new Array(s),r=this.glyphs.get(0);for(let l=0;l<s;l+=1)o[l]=this.glyphs.get(i[l])||r;return o},ue.prototype.nameToGlyphIndex=function(n){return this.glyphNames.nameToGlyphIndex(n)},ue.prototype.nameToGlyph=function(n){const e=this.nameToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},ue.prototype.glyphIndexToName=function(n){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(n):""},ue.prototype.getKerningValue=function(n,e){n=n.index||n,e=e.index||e;const t=this.position.defaultKerningTables;return t?this.position.getKerningValue(t,n,e):this.kerningPairs[n+","+e]||0},ue.prototype.defaultRenderOptions={kerning:!0,features:{liga:!0,rlig:!0}},ue.prototype.forEachGlyph=function(n,e,t,i,s,o){e=e!==void 0?e:0,t=t!==void 0?t:0,i=i!==void 0?i:72,s=s||this.defaultRenderOptions;const r=1/this.unitsPerEm*i,l=this.stringToGlyphs(n,s);let a;if(s.kerning){const c=s.script||this.position.getDefaultScriptName();a=this.position.getKerningTables(c,s.language)}for(let c=0;c<l.length;c+=1){const u=l[c];if(o.call(this,u,e,t,i,s),u.advanceWidth&&(e+=u.advanceWidth*r),s.kerning&&c<l.length-1){const f=a?this.position.getKerningValue(a,u.index,l[c+1].index):this.getKerningValue(u,l[c+1]);e+=f*r}s.letterSpacing?e+=s.letterSpacing*i:s.tracking&&(e+=s.tracking/1e3*i)}return e},ue.prototype.getPath=function(n,e,t,i,s){const o=new Ie;return this.forEachGlyph(n,e,t,i,s,function(r,l,a,c){const u=r.getPath(l,a,c,s,this);o.extend(u)}),o},ue.prototype.getPaths=function(n,e,t,i,s){const o=[];return this.forEachGlyph(n,e,t,i,s,function(r,l,a,c){const u=r.getPath(l,a,c,s,this);o.push(u)}),o},ue.prototype.getAdvanceWidth=function(n,e,t){return this.forEachGlyph(n,0,0,e,t,function(){})},ue.prototype.draw=function(n,e,t,i,s,o){this.getPath(e,t,i,s,o).draw(n)},ue.prototype.drawPoints=function(n,e,t,i,s,o){this.forEachGlyph(e,t,i,s,o,function(r,l,a,c){r.drawPoints(n,l,a,c)})},ue.prototype.drawMetrics=function(n,e,t,i,s,o){this.forEachGlyph(e,t,i,s,o,function(r,l,a,c){r.drawMetrics(n,l,a,c)})},ue.prototype.getEnglishName=function(n){const e=this.names[n];if(e)return e.en},ue.prototype.validate=function(){const n=this;function e(i,s){}function t(i){const s=n.getEnglishName(i);s&&s.trim().length>0}t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),this.unitsPerEm>0},ue.prototype.toTables=function(){return AA.fontToTable(this)},ue.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},ue.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s<e.length;s++)i[s]=e[s];return t},ue.prototype.download=function(n){const e=this.getEnglishName("fontFamily"),t=this.getEnglishName("fontSubfamily");n=n||e.replace(/\s/g,"")+"-"+t+".otf";const i=this.toArrayBuffer();if(CA())if(window.URL=window.URL||window.webkitURL,window.URL){const s=new DataView(i),o=new Blob([s],{type:"font/opentype"});let r=document.createElement("a");r.href=window.URL.createObjectURL(o),r.download=n;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=wA(i);s.writeFileSync(n,o)}},ue.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},ue.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},ue.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function Xl(n,e){const t=JSON.stringify(n);let i=256;for(let s in e){let o=parseInt(s);if(!(!o||o<256)){if(JSON.stringify(e[s])===t)return o;i<=o&&(i=o+1)}}return e[i]=n,i}function n0(n,e,t){const i=Xl(e.name,t);return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:i}]}function i0(n,e,t){const i={},s=new q.Parser(n,e);return i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1),i.name=t[s.parseUShort()]||{},i}function s0(n,e,t,i){const s=Xl(e.name,i),o=[{name:"nameID_"+n,type:"USHORT",value:s},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r<t.length;++r){const l=t[r].tag;o.push({name:"axis_"+n+" "+l,type:"FIXED",value:e.coordinates[l]<<16})}return o}function o0(n,e,t,i){const s={},o=new q.Parser(n,e);s.name=i[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 r0(n,e){const t=new Z.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:n.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:n.instances.length},{name:"instanceSize",type:"USHORT",value:4+n.axes.length*4}]);t.offsetToData=t.sizeOf();for(let i=0;i<n.axes.length;i++)t.fields=t.fields.concat(n0(i,n.axes[i],e));for(let i=0;i<n.instances.length;i++)t.fields=t.fields.concat(s0(i,n.instances[i],n.axes,e));return t}function a0(n,e,t){const i=new q.Parser(n,e),s=i.parseULong();ie.argument(s===65536,"Unsupported fvar table version.");const o=i.parseOffset16();i.skip("uShort",1);const r=i.parseUShort(),l=i.parseUShort(),a=i.parseUShort(),c=i.parseUShort(),u=[];for(let h=0;h<r;h++)u.push(i0(n,e+o+h*l,t));const f=[],p=e+o+r*l;for(let h=0;h<a;h++)f.push(o0(n,p+h*c,u,t));return{axes:u,instances:f}}const l0={make:r0,parse:a0},We=new Array(10);We[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(H.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(H.coverage),values:this.parseValueRecordList()};ie.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},We[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();ie.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(H.coverage),s=this.parseUShort(),o=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:o,pairSets:this.parseList(H.pointer(H.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(o)}})))};if(t===2){const r=this.parsePointer(H.classDef),l=this.parsePointer(H.classDef),a=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:o,classDef1:r,classDef2:l,class1Count:a,class2Count:c,classRecords:this.parseList(a,H.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(o)}}))}}},We[3]=function(){return{error:"GPOS Lookup 3 not supported"}},We[4]=function(){return{error:"GPOS Lookup 4 not supported"}},We[5]=function(){return{error:"GPOS Lookup 5 not supported"}},We[6]=function(){return{error:"GPOS Lookup 6 not supported"}},We[7]=function(){return{error:"GPOS Lookup 7 not supported"}},We[8]=function(){return{error:"GPOS Lookup 8 not supported"}},We[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function c0(n,e){e=e||0;const t=new H(n,e),i=t.parseVersion(1);return ie.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(We)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(We),variations:t.parseFeatureVariationsList()}}const d0=new Array(10);function u0(n){return new Z.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new Z.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new Z.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new Z.LookupList(n.lookups,d0)}])}const h0={parse:c0,make:u0};function f0(n){const e={};n.skip("uShort");const t=n.parseUShort();ie.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s<i;s+=1){const o=n.parseUShort(),r=n.parseUShort(),l=n.parseShort();e[o+","+r]=l}return e}function p0(n){const e={};n.skip("uShort"),n.parseULong()>1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const o=n.parseUShort();n.skip("uShort",3);for(let r=0;r<o;r+=1){const l=n.parseUShort(),a=n.parseUShort(),c=n.parseShort();e[l+","+a]=c}}return e}function g0(n,e){const t=new q.Parser(n,e),i=t.parseUShort();if(i===0)return f0(t);if(i===1)return p0(t);throw new Error("Unsupported kern table version ("+i+").")}const m0={parse:g0};function A0(n,e,t,i){const s=new q.Parser(n,e),o=i?s.parseUShort:s.parseULong,r=[];for(let l=0;l<t+1;l+=1){let a=o.call(s);i&&(a*=2),r.push(a)}return r}const y0={parse:A0};function C0(n,e){require("fs").readFile(n,function(i,s){if(i)return e(i.message);e(null,EA(s))})}function E0(n,e){const t=new XMLHttpRequest;t.open("get",n,!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 Jl(n,e){const t=[];let i=12;for(let s=0;s<e;s+=1){const o=q.getTag(n,i),r=q.getULong(n,i+4),l=q.getULong(n,i+8),a=q.getULong(n,i+12);t.push({tag:o,checksum:r,offset:l,length:a,compression:!1}),i+=16}return t}function w0(n,e){const t=[];let i=44;for(let s=0;s<e;s+=1){const o=q.getTag(n,i),r=q.getULong(n,i+4),l=q.getULong(n,i+8),a=q.getULong(n,i+12);let c;l<a?c="WOFF":c=!1,t.push({tag:o,offset:r,compression:c,compressedLength:l,length:a}),i+=20}return t}function ve(n,e){if(e.compression==="WOFF"){const t=new Uint8Array(n.buffer,e.offset+2,e.compressedLength-2),i=new Uint8Array(e.length);if(Zg(t,i),i.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");return{data:new DataView(i.buffer,0),offset:0}}else return{data:n,offset:e.offset}}function b0(n){let e,t;const i=new ue({empty:!0}),s=new DataView(n,0);let o,r=[];const l=q.getTag(s,0);if(l==="\0\0\0"||l==="true"||l==="typ1")i.outlinesFormat="truetype",o=q.getUShort(s,4),r=Jl(s,o);else if(l==="OTTO")i.outlinesFormat="cff",o=q.getUShort(s,4),r=Jl(s,o);else if(l==="wOFF"){const k=q.getTag(s,4);if(k==="\0\0\0")i.outlinesFormat="truetype";else if(k==="OTTO")i.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+l);o=q.getUShort(s,12),r=w0(s,o)}else throw new Error("Unsupported OpenType signature "+l);let a,c,u,f,p,h,A,C,m,y,E;for(let k=0;k<o;k+=1){const B=r[k];let x;switch(B.tag){case"cmap":x=ve(s,B),i.tables.cmap=Va.parse(x.data,x.offset),i.encoding=new za(i.tables.cmap);break;case"cvt ":x=ve(s,B),E=new q.Parser(x.data,x.offset),i.tables.cvt=E.parseShortList(B.length/2);break;case"fvar":c=B;break;case"fpgm":x=ve(s,B),E=new q.Parser(x.data,x.offset),i.tables.fpgm=E.parseByteList(B.length);break;case"head":x=ve(s,B),i.tables.head=ol.parse(x.data,x.offset),i.unitsPerEm=i.tables.head.unitsPerEm,e=i.tables.head.indexToLocFormat;break;case"hhea":x=ve(s,B),i.tables.hhea=rl.parse(x.data,x.offset),i.ascender=i.tables.hhea.ascender,i.descender=i.tables.hhea.descender,i.numberOfHMetrics=i.tables.hhea.numberOfHMetrics;break;case"hmtx":h=B;break;case"ltag":x=ve(s,B),t=ll.parse(x.data,x.offset);break;case"maxp":x=ve(s,B),i.tables.maxp=cl.parse(x.data,x.offset),i.numGlyphs=i.tables.maxp.numGlyphs;break;case"name":m=B;break;case"OS/2":x=ve(s,B),i.tables.os2=Js.parse(x.data,x.offset);break;case"post":x=ve(s,B),i.tables.post=Al.parse(x.data,x.offset),i.glyphNames=new zs(i.tables.post);break;case"prep":x=ve(s,B),E=new q.Parser(x.data,x.offset),i.tables.prep=E.parseByteList(B.length);break;case"glyf":u=B;break;case"loca":C=B;break;case"CFF ":a=B;break;case"kern":A=B;break;case"GPOS":f=B;break;case"GSUB":p=B;break;case"meta":y=B;break}}const I=ve(s,m);if(i.tables.name=ml.parse(I.data,I.offset,t),i.names=i.tables.name,u&&C){const k=e===0,B=ve(s,C),x=y0.parse(B.data,B.offset,i.numGlyphs,k),g=ve(s,u);i.glyphs=Tl.parse(g.data,g.offset,x,i)}else if(a){const k=ve(s,a);sl.parse(k.data,k.offset,i)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");const S=ve(s,h);if(al.parse(S.data,S.offset,i.numberOfHMetrics,i.numGlyphs,i.glyphs),ym(i),A){const k=ve(s,A);i.kerningPairs=m0.parse(k.data,k.offset)}else i.kerningPairs={};if(f){const k=ve(s,f);i.tables.gpos=h0.parse(k.data,k.offset),i.position.init()}if(p){const k=ve(s,p);i.tables.gsub=yl.parse(k.data,k.offset)}if(c){const k=ve(s,c);i.tables.fvar=l0.parse(k.data,k.offset,i.names)}if(y){const k=ve(s,y);i.tables.meta=Cl.parse(k.data,k.offset),i.metas=i.tables.meta}return i}function v0(n,e){(typeof window>"u"?C0:E0)(n,function(s,o){if(s)return e(s);let r;try{r=b0(o)}catch(l){return e(l,null)}return e(null,r)})}const ro=1e-12;function On(n){if(!Array.isArray(n)||n.length===0)return n||[];const e=n[0],t=n[n.length-1];if(!e||!t||e.length<2||t.length<2)return n;const i=e[0]??0,s=e[1]??0,o=t[0]??0,r=t[1]??0;return(Math.abs(i-o)>ro||Math.abs(s-r)>ro)&&n.push([i,s]),n}function Lt(n){let e=0;if(!n)return 0;for(let t=0;t<n.length-1;t++){const i=n[t],s=n[t+1];if(!i||!s)continue;const o=i[0]??0,r=i[1]??0,l=s[0]??0,a=s[1]??0;e+=o*a-l*r}return e/2}function ki(n,e=ro){const t=[];if(!n)return t;for(const i of n){if(!i||i.length<2)continue;const s=t[t.length-1],o=i[0]??0,r=i[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 I0(n,e,t,i,s=16){const o=[],r=n?.[0]??0,l=n?.[1]??0,a=t?.[0]??0,c=t?.[1]??0,u=i?.[0]??0,f=i?.[1]??0,p=e?.[0]??0,h=e?.[1]??0;for(let A=0;A<=s;A++){const C=A/s,m=1-C,y=m*m*m*r+3*m*m*C*a+3*m*C*C*u+C*C*C*p,E=m*m*m*l+3*m*m*C*c+3*m*C*C*f+C*C*C*h;o.push([y,E])}return o}function Zl(n,e){if(!n||!e)return!1;const t=n[0]??0,i=n[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 c=l[0]??0,u=l[1]??0,f=a[0]??0,p=a[1]??0;u>i!=p>i&&t<(f-c)*(i-u)/(p-u+0)+c&&(s=!s)}return s}function ao(n){return n?(Lt(n)<0&&n.reverse(),On(n),n):[]}function x0(n){return n?(Lt(n)>0&&n.reverse(),On(n),n):[]}function ec(n,e=16){if(!n||!Array.isArray(n.commands))return[];const t=[];let i=[];for(const s of n.commands){let o=function(l){const a=l.x!==void 0?l.x:0,c=l.y!==void 0?-l.y:0;return[a,c]};const r=s.type;if(r==="M")i.length&&t.push(ki(i)),i=[o(s)];else if(r==="L")i.push(o(s));else if(r==="Q"){const a=i[i.length-1]||o(s),c=[],u=s.x??0,f=s.y??0,p=s.x1??0,h=s.y1??0,A=a[0]??0,C=a[1]??0;for(let m=1;m<=e;m++){const y=m/e,E=1-y,I=E*E*A+2*E*y*p+y*y*u,S=E*E*C+2*E*y*h+y*y*-f;c.push([I,S])}c.length?i.push(...c):i.push(o(s))}else if(r==="C"){const a=i[i.length-1]||o(s),c=[s.x1||0,-(s.y1||0)],u=[s.x2||0,-(s.y2||0)],f=[s.x||0,-(s.y||0)],p=I0(a,f,c,u,e);p.length>1?i.push(...p.slice(1)):i.push(f)}else r==="Z"||r==="z"?(i.length&&t.push(ki(i)),i=[]):s.x!==void 0&&s.y!==void 0&&i.push(o(s))}return i.length&&t.push(ki(i)),t.map(s=>On(s)).filter(s=>s&&s.length>=4)}function lo(n,e){if(!n)return null;const t=n.map(i=>On(i.slice()));return{type:"Feature",geometry:{type:"Polygon",coordinates:t},properties:{...e.properties||{},rings:t.length,polygons:1}}}function B0(n,e,t={}){t=Object.assign({sampleSegments:16,simplifyTolerance:0,epsArea:1e-24,debug:!1,scale:1,widthScale:.6,fillWinding:"auto"},t||{scale:1});const i=!!t.debug;if(!n||!n.geometry||!Array.isArray(n.geometry.coordinates))return{type:"FeatureCollection",features:[]};const s=n.geometry.coordinates,o=n.properties||{},r=o.text||o.label||"",l=o.rotation??0,a=t.sampleSegments||16,c=t.epsArea||1e-24,f=o.height/.9||1,p=(t.scale||1)*f,h=-l*Math.PI/180,A=Math.cos(h),C=Math.sin(h),m=o.attachmentPoint||"bottom-left",y=[];if(!e||typeof e.getPaths!="function")return{type:"FeatureCollection",features:y};const E=e.getPaths(r,0,0,t.fontSize||1)||[];let I=[];for(const L of E){const G=ec(L,a);for(const N of G)if(N)for(const v of N)v&&I.push(v)}let S=1/0,k=1/0,B=-1/0,x=-1/0;for(const L of I){if(!L)continue;const G=L[0]??0,N=L[1]??0;S=Math.min(S,G),k=Math.min(k,N),B=Math.max(B,G),x=Math.max(x,N)}const g=B-S,R=x-k;let M=0,F=0;switch(m){case"top-left":M=0,F=-R;break;case"top-center":M=-g/2,F=R;break;case"top-right":M=-g,F=R;break;case"center-left":M=0,F=R/2;break;case"center":M=-g/2,F=R/2;break;case"center-right":M=-g,F=R/2;break;case"bottom-left":M=0,F=0;break;case"bottom-center":M=-g/2,F=0;break;case"bottom-right":M=-g,F=0;break;default:M=0,F=0}for(const L of E){const G=ec(L,a);if(!G||G.length===0)continue;const N=G.map(P=>{if(!P)return[];const _=P.map(O=>{if(!O)return[0,0];let D=(O[0]??0)+M,U=(O[1]??0)+F;D=D*(t.widthScale||.6);const V=D*A-U*C,$=D*C+U*A;return[s[0]+V*p,s[1]+$*p]});return On(ki(_))}).filter(P=>P&&P.length>=4&&Math.abs(Lt(P))>c);if(N.length===0)continue;let v=1;if(t.fillWinding==="positive")v=1;else if(t.fillWinding==="negative")v=-1;else{let P=0,_=-1;for(let U=0;U<N.length;U++){const V=N[U];if(!V)continue;const $=Lt(V);Math.abs($)>_&&(_=Math.abs($),P=U)}const O=N[P],D=O?Lt(O):0;v=D>=0?1:-1,i&&console.log("[simple] auto fillSign=",v,"largest signed area=",D)}const w=N.map((P,_)=>({idx:_,ring:P,signedArea:Lt(P),absArea:Math.abs(Lt(P))}));for(const P of w)P.isFilled=P.signedArea*v>0,i&&console.log("[simple] ring",P.idx,"signedArea=",P.signedArea.toExponential(),"isFilled=",P.isFilled);const b=w.filter(P=>P.isFilled).sort((P,_)=>P.absArea-_.absArea),T=w.filter(P=>!P.isFilled).sort((P,_)=>_.absArea-P.absArea);for(const P of b)P.holes=[];for(const P of T){const _=(function(D){let U=0,V=0;if(!D||D.length===0)return[0,0];for(const $ of D)$&&(U+=$[0]??0,V+=$[1]??0);return[U/D.length,V/D.length]})(P.ring);let O=null;for(const D of b)Zl(_,D.ring)&&(O===null||D.absArea<O.absArea&&D.idx<P.idx||D.absArea>O.absArea&&D.idx<P.idx&&T.length==1)&&(O=D);if(O){if(O.absArea<P.absArea&&T.length>1)for(const D of b)Zl(_,D.ring)&&D.absArea>P.absArea&&D.holes.push(P.ring);else O.holes.push(P.ring);P.assigned=!0}else P.assigned=!1,i&&console.log("[simple] hole not assigned idx=",P.idx)}for(const P of b){const _=ao(P.ring.slice()),O=(P.holes||[]).map(D=>x0(D.slice()));y.push(lo([_,...O],n))}for(const P of T)P.assigned||y.push(lo([ao(P.ring.slice())],n));if(b.length===0)for(const P of w)y.push(lo([ao(P.ring.slice())],n))}return{type:"FeatureCollection",features:y}}class S0 extends tt{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,i=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=i.getCatesian3FromPX(s.position);o&&(i.positions=[o],i._centerCoord=o,i.createLabel(o,function(){i.endCreate(e)}))},t.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(s){if(!s||!s.position)return;i.getCatesian3FromPX(s.position)&&i.state},t.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(s){!s||!s.position||i.endCreate()},t.ScreenSpaceEventType.RIGHT_CLICK)}catch(t){console.error("启动创建标签功能时出错:",t),e&&e(null)}}createLabel(e,t){const i=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium,s=this;if(!e){console.error("创建标签时位置参数无效"),t&&t();return}if(!i){console.error("创建标签时无法获取Cesium对象"),t&&t();return}this.clearPolygonEntities(),v0(this.fontUrl,(o,r)=>{try{if(o){console.error("加载字体失败:",o),t&&t();return}const l=i.Cartographic.fromCartesian(e),a=i.Math.toDegrees(l.longitude),c=i.Math.toDegrees(l.latitude),u={type:"Feature",geometry:{type:"Point",coordinates:[a,c]},properties:{text:s.labelText||"",rotation:0}},f={sampleSegments:16,fontSize:s.fontSize,scale:10},p=B0(u,r,f);if(!p||!p.features||!Array.isArray(p.features)){console.error("文本转换为多边形失败"),t&&t();return}s.drawGeoJsonLocal(p,[a,c],1,r),s.entity={_centerCoord:s._centerCoord,_plotInstance:s._plotInstance,position:e,label:{text:s.labelText},updatePosition:function(h){s.updatePositions([h])},getPosition:function(){return s._centerCoord},type:s.type,objId:s.objId,isDraggable:!0,setPosition:function(h){s._centerCoord=h,s.positions[0]=h,s.createLabel(h)}},s.addClickEditHandler(),t&&t()}catch(l){console.error("创建文本标签时发生错误:",l);try{s.clearPolygonEntities()}catch(a){console.error("清理标签多边形实体时出错:",a)}t&&t()}})}drawGeoJsonLocal(e,t,i=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),c=o.Transforms.eastNorthUpToFixedFrame(a),u=i*1;this.clearPolygonEntities();let f=[];for(const I of e.features||[]){if(!I||!I.geometry||I.geometry.type!=="Polygon")continue;const S=I.geometry.coordinates||[];for(const k of S)k&&Array.isArray(k)&&(f=f.concat(k))}let p=1/0,h=1/0,A=-1/0,C=-1/0;for(const I of f)Array.isArray(I)&&I.length>=2&&(p=Math.min(p,I[0]),h=Math.min(h,I[1]),A=Math.max(A,I[0]),C=Math.max(C,I[1]));const m=(p+A)/2,y=(h+C)/2,E=I=>{const S=(I[0]-m)*u,k=(I[1]-y)*u,B=new o.Cartesian3(S,k,0);return o.Matrix4.multiplyByPoint(c,B,new o.Cartesian3)};for(const I of e.features||[]){if(!I||!I.geometry||I.geometry.type!=="Polygon")continue;const S=I.geometry.coordinates||[];if(S.length>0)try{const k=S[0]||[];if(k.length===0)continue;const B=k.map(E);let x;if(S.length>1){const R=S.slice(1).map(M=>!M||!Array.isArray(M)||M.length===0?null:new o.PolygonHierarchy(M.map(E))).filter(Boolean);x=new o.PolygonHierarchy(B,R)}else x=new o.PolygonHierarchy(B);const g=this.viewer.entities.add({polygon:{hierarchy:x,material:o.Color.fromCssColorString(this.color||"#000000"),outline:!1},_labelOwner:this.objId});this.polygonEntities.push(g)}catch(k){console.warn("创建多边形实体时出错:",k);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(i){if(!i||!i.position)return;const s=e.viewer.scene.pick(i.position);t.defined(s)&&s.id&&s.id._labelOwner===e.objId&&(i.preventDefault(),e.editText())},t.ScreenSpaceEventType.LEFT_CLICK),this.editHandler.setInputAction(function(i){if(!i||!i.position)return;const s=e.viewer.scene.pick(i.position);t.defined(s)&&s.id&&s.id._labelOwner===e.objId&&(i.preventDefault(),e.openStyleEditor())},t.ScreenSpaceEventType.RIGHT_CLICK)}editText(){const e=this;(function(i,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=i,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 c=document.createElement("div");c.style.display="flex",c.style.justifyContent="flex-end",c.style.gap="10px";const u=document.createElement("button");u.textContent="取消",u.addEventListener("click",function(){document.body.removeChild(o),s(null)});const f=document.createElement("button");f.textContent="确认",f.addEventListener("click",function(){document.body.removeChild(o),s(a.value)}),c.appendChild(u),c.appendChild(f),r.appendChild(l),r.appendChild(a),r.appendChild(c),o.appendChild(r),document.body.appendChild(o),a.focus();const p=function(h){h.key==="Escape"&&(document.body.removeChild(o),document.removeEventListener("keydown",p),s(null))};document.addEventListener("keydown",p)})(this.labelText,function(i){i!==null&&(e.labelText=i||"点击编辑文本",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 i=t.Cartesian3.add(this._centerCoord,e,new t.Cartesian3);this.updatePositions([i])}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(i,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 c=document.createElement("label");c.textContent="文本颜色: ",c.style.display="block",c.style.marginBottom="5px";const u=document.createElement("input");u.type="color",u.value=i.color,u.style.width="50px",a.appendChild(c),a.appendChild(u);const f=document.createElement("div");f.style.marginBottom="15px";const p=document.createElement("label");p.textContent="字体大小: ",p.style.display="block",p.style.marginBottom="5px";const h=document.createElement("input");h.type="number",h.value=i.fontSize,h.min="8",h.max="200",h.step="1",h.style.width="100%",h.style.padding="5px",h.style.boxSizing="border-box",f.appendChild(p),f.appendChild(h);const A=document.createElement("div");A.style.display="flex",A.style.justifyContent="flex-end",A.style.gap="10px",A.style.marginTop="20px";const C=document.createElement("button");C.textContent="取消",C.addEventListener("click",function(){document.body.removeChild(o),s(null)});const m=document.createElement("button");m.textContent="确认",m.addEventListener("click",function(){document.body.removeChild(o),s({color:u.value,fontSize:parseInt(h.value)})}),A.appendChild(C),A.appendChild(m),r.appendChild(l),r.appendChild(a),r.appendChild(f),r.appendChild(A),o.appendChild(r),document.body.appendChild(o);const y=function(E){E.key==="Escape"&&(document.body.removeChild(o),document.removeEventListener("keydown",y),s(null))};document.addEventListener("keydown",y)})(this.getStyle(),function(i){i&&e.setStyle(i)})}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 M0 extends tt{constructor(e,t){super(e,t),this.type="point",this.viewer=e;let i={color:Cesium.Color.AQUA,pixelSize:10,outlineWidth:1};this.style=Object.assign(i,t||{}),this.position=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new yt(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(i){let s=t.getCatesian3FromPX(i.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(i){t.prompt.update(i.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 i=e instanceof Cesium.Cartesian3?e:Cesium.Cartesian3.fromDegrees(e[0],e[1],e[2]);this.position=i,i&&(this.entity=this.createPoint(i),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,i=t.color.getValue();e.colorAlpha=i.alpha,e.color=new Cesium.Color(i.red,i.green,i.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?ce.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,i;this.modifyHandler.setInputAction(function(s){let o=t.viewer.scene.pick(s.position);Cesium.defined(o)&&o.id&&(i=o.id,t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(s){if(!i)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){i&&(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 T0 extends tt{constructor(e,t){super(e,t),this.type="polygon",this.viewer=e,this.entity=null,this.polyline=null;let i={outlineColor:"#000000",outlineWidth:2};this.style=Object.assign(i,t||{}),this.outline=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new yt(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(i){let s=t.getCatesian3FromPX(i.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(i){if(t.positions.length<1){t.prompt.update(i.endPosition,"单击开始绘制"),t.state="startCreate";return}t.prompt&&t.prompt.update(i.endPosition,"双击结束,右键取消上一步");let s=t.getCatesian3FromPX(i.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(i){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(i.endPosition,"单击开始绘制"),t.positions=[],t.movePush=!1))},Cesium.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(function(i){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 i=e[0]instanceof Cesium.Cartesian3?e:ce.lnglatsToCartesians(e);if(i){this.entity=this.createPolygon(),this.polyline=this.createPolyline(),this.polyline.show=this.style.outline,this.positions=i;for(let s=0;s<i.length;s++){let o=i[s],r=Cesium.Cartographic.fromCartesian(i[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 i=this.polyline.polyline;if(i&&this.polyline.show){e.outlineWidth=i.width.getValue(),e.outline=!0;let s=i.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 D0 extends tt{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 yt(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(i){const s=t.getCatesian3FromPX(i.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(i){if(!t.entity){t.prompt?.update(i.endPosition,"单击开始绘制");return}t.prompt?.update(i.endPosition,"单击结束");const s=t.getCatesian3FromPX(i.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(i){const s=t.viewer.scene.pick(i.position);if(!s?.id)return;t.modifyPoint=s.id;const o=t.getCatesian3FromPX(i.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(i){if(!t.modifyPoint)return;const s=t.getCatesian3FromPX(i.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,i=this._calcCornerCartesian("rightup"),s=this.rightdown;return[e,s,i,t,e]}_calcCornerCartesian(e){const t=Cesium.Ellipsoid.WGS84,i=t.cartesianToCartographic(this.leftup),s=t.cartesianToCartographic(this.rightdown),o=Math.min(i.longitude,s.longitude),r=Math.max(i.longitude,s.longitude),l=Math.min(i.latitude,s.latitude),a=Math.max(i.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 i=Cesium.Ellipsoid.WGS84,s=i.cartesianToCartographic(this.leftup),o=i.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),c=Math.max(s.latitude,o.latitude);const u=i.cartesianToCartographic(e);t==="leftdown"?(r=u.longitude,a=u.latitude):(l=u.longitude,c=u.latitude),this.leftup=Cesium.Cartesian3.fromRadians(r,c),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 i=t.x-e.x,s=t.y-e.y,o=t.z-e.z;this.leftup=new Cesium.Cartesian3(this.leftup.x+i,this.leftup.y+s,this.leftup.z+o),this.rightdown=new Cesium.Cartesian3(this.rightdown.x+i,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"),c=this._calcCornerCartesian("rightup");this.leftdownPoint=this.createPoint(a),this.leftdownPoint.typeAttr="leftdown",this.leftdownPoint.show=this.state==="editing",this.rightupPoint=this.createPoint(c),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?ce.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 i=t.color instanceof Cesium.Color?t.color:Cesium.Color.fromCssColorString(t.color||"#00FF00");t.colorAlpha!=null&&(i=i.withAlpha(t.colorAlpha)),this.entity.polyline.material=i,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 i=e[0]instanceof Cesium.Cartesian3?e:ce.lnglatsToCartesians(e);if(!i||i.length<2)return!1;if(i.length===2)this.leftup=Cesium.Cartesian3.clone(i[0]),this.rightdown=Cesium.Cartesian3.clone(i[1]);else if(i.length>=4){let s=1/0,o=1/0,r=-1/0,l=-1/0;i.forEach(a=>{const c=Cesium.Ellipsoid.WGS84.cartesianToCartographic(a);c&&(s=Math.min(s,c.longitude),o=Math.min(o,c.latitude),r=Math.max(r,c.longitude),l=Math.max(l,c.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 k0 extends tt{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],i=this.createPoint(t);this.style.clampToGround&&(i.point.heightReference=1),i.wz=this.controlPoints.length,this.controlPoints.push(i)}}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new yt(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(i){let s=t.getCatesian3FromPX(i.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(i){if(t.state="creating",t.positions.length<1){t.prompt.update(i.endPosition,"单击开始绘制"),t.state="startCreate";return}t.prompt.update(i.endPosition,"右键取消上一步,双击结束");let s=t.getCatesian3FromPX(i.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(i){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(i.endPosition,"单击开始绘制"),t.movePush=!1,t.positions=[]))},Cesium.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(function(i){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 i=e[0]instanceof Cesium.Cartesian3?e:util.lnglatsToCartesians(e);if(i){this.entity=this.createPolyline(this.style),this.positions=i,t&&t(this.entity);for(let s=0;s<i.length;s++){let o=i[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 i=t.material.color.getValue();e.colorAlpha=i.alpha,e.color=new Cesium.Color(i.red,i.green,i.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 i=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"||(i=s),i}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],i=this.createPoint(t);this.style.clampToGround&&(i.point.heightReference=1),i.wz=this.controlPoints.length,this.controlPoints.push(i)}}getPositions(e){return e?util.cartesiansToLnglats(this.positions,this.viewer):this.positions}}class P0 extends tt{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(()=>Oa).then(({default:i})=>{this.prompt=new i(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(i){t.state="creating",t.isDrawing=!0,t.forbidDrawWorld(!0),t.positions=[],t._stagingBuffer.length=0,t.lastAddPosition=null;let s=t._fastPick(i.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(i){if(!t.isDrawing){t.prompt&&i&&i.endPosition&&t.prompt.update(i.endPosition,"单击开始绘制");return}if(t.prompt&&i&&i.endPosition&&t.prompt.update(i.endPosition,"松键结束"),!i||!i.endPosition||t.positions.length+t._stagingBuffer.length>=t.maxPositions)return;let s=t._fastPick(i.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(i){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(i){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,i=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(i)}_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 i=this.viewer.camera.getPickRay(e);let s=null;return i&&(s=this.viewer.scene.globe.pick(i,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 i=this.viewer.camera.getPickRay(e);i&&(t=this.viewer.scene.globe.pick(i,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 i=e;if(t>0){const l=(u,f)=>{if(!u||u.length<2)return u;f=Math.max(1,f|0);const p=[u[0]],h=u.length;for(let A=0;A<h-1;A++){const C=A>0?u[A-1]:u[A],m=u[A],y=u[A+1],E=A+2<h?u[A+2]:u[A+1];for(let I=1;I<f;I++){const S=I/f,k=S*S,B=k*S,x=-.5*C.x+1.5*m.x-1.5*y.x+.5*E.x,g=-.5*C.y+1.5*m.y-1.5*y.y+.5*E.y,R=-.5*C.z+1.5*m.z-1.5*y.z+.5*E.z,M=C.x-2.5*m.x+2*y.x-.5*E.x,F=C.y-2.5*m.y+2*y.y-.5*E.y,L=C.z-2.5*m.z+2*y.z-.5*E.z,G=-.5*C.x+.5*y.x,N=-.5*C.y+.5*y.y,v=-.5*C.z+.5*y.z,w=m.x,b=m.y,T=m.z,P=x*B+M*k+G*S+w,_=g*B+F*k+N*S+b,O=R*B+L*k+v*S+T;p.push(new Cesium.Cartesian3(P,_,O))}p.push(y)}return p},a=Math.max(1,Number(this.style.curveResolution)||1);i.length<200&&a>1&&(i=l(i,a));const c=u=>{if(!u||u.length<2)return u;const f=[];f.push(u[0]);for(let p=0;p<u.length-1;p++){const h=u[p],A=u[p+1],C=new Cesium.Cartesian3(h.x*.75+A.x*.25,h.y*.75+A.y*.25,h.z*.75+A.z*.25),m=new Cesium.Cartesian3(h.x*.25+A.x*.75,h.y*.25+A.y*.75,h.z*.25+A.z*.75);f.push(C),f.push(m)}return f.push(u[u.length-1]),f};i=i.slice(),i.length<300&&(i=c(i),t===2&&i.length<300&&(i=c(i)))}const s=(Number(this.style.angleThreshold)||6)*(Math.PI/180),o=this.positions,r=(l,a,c,u)=>{if(!l||!a||!c)return!1;const f=a.x-l.x,p=a.y-l.y,h=a.z-l.z,A=c.x-a.x,C=c.y-a.y,m=c.z-a.z,y=Math.hypot(f,p,h),E=Math.hypot(A,C,m);if(y===0||E===0)return!1;const I=(f*A+p*C+h*m)/(y*E),S=Math.max(-1,Math.min(1,I)),k=Math.acos(S);return Math.abs(k)<=u};for(let l=0;l<i.length;l++){const a=i[l];if(o.length===0){o.push(Cesium.Cartesian3.clone(a));continue}const c=o[o.length-1];if(!(Cesium.Cartesian3.distance(c,a)<=this.minDistance*.5)){if(o.length>=2){const f=o[o.length-2],p=o[o.length-1],h=a;if(r(f,p,h,s)){o.pop(),o.push(Cesium.Cartesian3.clone(h));continue}}if(o.push(Cesium.Cartesian3.clone(a)),o.length>this.maxPositions){const f=o.length-this.maxPositions;f>0&&o.splice(0,f)}}}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(i=>Cesium.Cartesian3.clone(i));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),i=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 i.objId=this.objId||null,this.entity=i,i}getMaterial(e,t){t=t||{};try{let i=t.color||Cesium.Color.RED;typeof i=="string"&&(i=Cesium.Color.fromCssColorString(i));const s=t.colorAlpha!==void 0?t.colorAlpha:1;return i=i.withAlpha(s),i}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(i=>Cesium.Cartesian3.clone(i)):t=ce&&ce.lnglatsToCartesians?ce.lnglatsToCartesians(e):e,!t||t.length===0)return!1;this.positions=t.map(i=>Cesium.Cartesian3.clone(i)),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 i=e[0]instanceof Cesium.Cartesian3?e:ce.lnglatsToCartesians(e);if(!i||i.length<1)return!1;this.positions=i.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 F0 extends tt{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(()=>Oa).then(({default:i})=>{this.prompt=new i(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(i){if(t.state==="startCreate"){t.state="creating",t._finalized=!1;let s=t.getCatesian3FromPX(i.position);if(!s)return;t.positions=[t.Cesium.Cartesian3.clone(s),t.Cesium.Cartesian3.clone(s)],t._createLineEntity(),t._createArrowEntity(),t._createControlPoints(),t.prompt&&i&&i.position&&t.prompt.update(i.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(i){if(t.state==="startCreate"){t.prompt&&i&&i.endPosition&&t.prompt.update(i.endPosition,"单击开始绘制");return}if(t.state==="creating"){let s=t.getCatesian3FromPX(i.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(i=>{try{t.viewer.entities.remove(i)}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 i=this.Cesium.Cartesian3.distance(e,t);if(i<=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:i*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 c=this.Cesium.Transforms.eastNorthUpToFixedFrame(t),u=this.Cesium.Matrix4.getColumn(c,2,new this.Cesium.Cartesian3),f=new this.Cesium.Cartesian3(a.x-u.x*this.Cesium.Cartesian3.dot(a,u),a.y-u.y*this.Cesium.Cartesian3.dot(a,u),a.z-u.z*this.Cesium.Cartesian3.dot(a,u));let p;this.Cesium.Cartesian3.magnitudeSquared(f)<1e-6?p=this.Cesium.Matrix4.getColumn(c,0,new this.Cesium.Cartesian3):(this.Cesium.Cartesian3.normalize(f,f),p=this.Cesium.Cartesian3.cross(u,f,new this.Cesium.Cartesian3),this.Cesium.Cartesian3.normalize(p,p));const h=this.Cesium.Cartesian3.multiplyByScalar(a,-l,new this.Cesium.Cartesian3),A=this.Cesium.Cartesian3.add(t,h,new this.Cesium.Cartesian3),C=this.style.arrowWidthScale!==void 0?this.style.arrowWidthScale:1,m=Math.sin(this.arrowAngle)*l*C,y=this.Cesium.Cartesian3.multiplyByScalar(p,m,new this.Cesium.Cartesian3),E=this.Cesium.Cartesian3.multiplyByScalar(p,-m,new this.Cesium.Cartesian3),I=this.Cesium.Cartesian3.add(A,y,new this.Cesium.Cartesian3),S=this.Cesium.Cartesian3.add(A,E,new this.Cesium.Cartesian3);return[t,I,S,t]}_createLineEntity(){if(this.lineEntity){try{this.viewer.entities.remove(this.lineEntity)}catch{}this.lineEntity=null}const e=this,t=this._getMaterial(),i=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:i,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(),i=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:i,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 i=t.positions[0],s=t.positions[1];return t._computeArrowPositions(i,s)},!1)}catch{}if(!this._editRenderHandler){this._editRenderHandler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);const t=this;this._editRenderHandler.setInputAction(function(i){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 i=e[0],s=e[1];if(!(i instanceof this.Cesium.Cartesian3))if(Array.isArray(i)&&i.length>=2)i=this.Cesium.Cartesian3.fromDegrees(i[0],i[1]),s=this.Cesium.Cartesian3.fromDegrees(s[0],s[1]);else return!1;return this.positions=[this.Cesium.Cartesian3.clone(i),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],i=e[1];if(!(t instanceof this.Cesium.Cartesian3))if(Array.isArray(t)&&t.length>=2)t=this.Cesium.Cartesian3.fromDegrees(t[0],t[1]),i=this.Cesium.Cartesian3.fromDegrees(i[0],i[1]);else return!1;return this.positions=[this.Cesium.Cartesian3.clone(t),this.Cesium.Cartesian3.clone(i)],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 R0{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 i=this.createByType(e);if(i)return i.attr=e||{},i.start(function(s){t.nowDrawEntityObj=void 0,t.entityObjArr.push(i),e.success&&e.success(i,s),t.endCreateFun&&t.endCreateFun(i,s),e.show==!1&&i.setVisible(!1),t.canEdit&&t.fireEdit&&(i.startEdit(function(){t.editingFun&&t.editingFun(i,i.entity)}),t.nowEditEntityObj=i,t.startEditFun&&t.startEditFun(i,s))}),this.nowDrawEntityObj=i,i}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,i=this.createByType(e);if(i)return i.attr=e,i.createByPositions(e.positions,function(s){t.entityObjArr.push(i),i.setStyle(e.style),e.success&&e.success(i,s),t.endCreateFun&&t.endCreateFun(i,s),e.show==!1&&i.setVisible(!1),t.canEdit&&t.fireEdit&&(i.startEdit(function(){t.editingFun&&t.editingFun(i,i.entity)}),t.startEditFun&&t.startEditFun(i,s),t.nowEditEntityObj=i)}),i}createByGeojson(e){let{features:t}=e,i=[];for(let s=0;s<t.length;s++){let o=t[s];const{properties:r,geometry:l}=o;let a=r.plotType;const c=l.type,u=l.coordinates;let f=[],p="";switch(c){case"LineString":f=ce.lnglatsToCartesians(u),p="polyline";break;case"Polygon":f=ce.lnglatsToCartesians(u[0]),p="polygon";break;case"Point":f=ce.lnglatsToCartesians([u])[0],p=a;break}this.fireEdit=!1;let h=this.createByPositions({type:p,styleType:a,positions:f,style:r.style});h&&i.push(h)}return i}toGeojson(){let e={type:"FeatureCollection",features:[]};if(this.entityObjArr.length==0)return null;for(let t=0;t<this.entityObjArr.length;t++){let i=this.entityObjArr[t],s=i.getPositions(!0),o=[];for(let c=0;c<s.length;c++)o.push([s[c][0],s[c][1]]);let r=i.getStyle(),l=this.transType(i.type),a={type:"Feature",properties:{plotType:i.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,i.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 i={};if(t)for(let s=0;s<this.entityObjArr.length;s++){let o=this.entityObjArr[s];if(o.attr[e]==t){i.entityObj=o,i.index=s;break}}else for(let s=0;s<this.entityObjArr.length;s++){let o=this.entityObjArr[s];if(o.attr.id==e){i.entityObj=o,i.index=s;break}}return i}setVisible(e,t){let i=this.getEntityObjByField("id",e);i.entityObj&&i.entityObj.setVisible(t)}getEntityObjByObjId(e){if(!e)return;let t={};for(let i=0;i<this.entityObjArr.length;i++){let s=this.entityObjArr[i];if(s.objId==e){t.entityObj=s,t.index=i;break}}return t}getEntityObjById(e){if(!e)return;let t={};for(let i=0;i<this.entityObjArr.length;i++){let s=this.entityObjArr[i];if(s.attr.id==e){t.entityObj=s,t.index=i;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 i=e.viewer.scene.drillPick(t.position)||[];let s=-1,o;for(let r=0;r<i.length&&s===-1;r++){const l=i[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 i=e.viewer.scene.drillPick(t.position)||[];let s;for(let o=0;o<i.length;o++){const r=i[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 i=window.document.createElement("span");i.style.background="rgba(0,0,0,0.5)",i.style.position="absolute",i.style.color="white",i.style.left=e.x+10+"px",i.style.top=e.y+10+"px",i.style.padding="4px",i.style.cursor="pointer",i.id="easy3d-plot-delete",i.setAttribute("objId",t),i.innerHTML="删除",window.document.getElementById(this.viewer.container.id).appendChild(i);const o=window.document.getElementById("easy3d-plot-delete");if(!o)return;let r=this;o.addEventListener("click",l=>{let a=i.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,i="";return e=e||{},e.type=="polyline"&&(t=new k0(this.viewer,e.style),i="折线_"),e.type=="freehandLine"&&(t=new P0(this.viewer,e.style),i="手绘线_"),e.type=="polygon"&&(t=new T0(this.viewer,e.style),i="面_"),e.type=="billboard"&&(t=new $g(this.viewer,e.style),i="图标_"),(e.type=="circle"||e.type=="ellipse")&&(t=new Kg(this.viewer,e.style),i="圆_"),e.type=="rectangle"&&(t=new D0(this.viewer,e.style),i="矩形_"),e.type=="gltfModel"&&(t=new qg(this.viewer,e.style),i="模型_"),e.type=="point"&&(t=new M0(this.viewer,e.style),i="点_"),e.type=="label"&&(t=new S0(this.viewer,e.style),i="文字_"),e.type=="arrow"&&(t=new F0(this.viewer,e.style)),t&&(t.name=i+new Date().getTime()),t}}class tc{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 R0(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 i=null;if(t._plotInstance&&typeof t._plotInstance.syncFromEntity=="function")try{t._plotInstance.syncFromEntity();const s=t._plotInstance;s.leftup&&s.rightdown&&(i=this.Cesium.Cartesian3.midpoint(s.leftup,s.rightdown,new this.Cesium.Cartesian3))}catch(s){console.warn("plotInstance.syncFromEntity failed",s)}if(!i){if(e.positions&&e.positions.length)i=this.calculateCenter(e.positions);else if(t.position&&t.position.getValue)i=t.position.getValue();else if(t.polyline&&t.polyline.positions&&t.polyline.positions.getValue){const s=t.polyline.positions.getValue();i=this.calculateCenter(s)}else if(t.polygon&&t.polygon.hierarchy&&t.polygon.hierarchy.getValue){const s=t.polygon.hierarchy.getValue().positions;i=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;i=this.Cesium.Cartesian3.fromRadians(o,r,0)}catch{}}i&&(this.centerHandle=this.viewer.entities.add({position:i,point:{pixelSize:10,color:this.Cesium.Color.WHITE,outlineColor:this.Cesium.Color.BLUE,outlineWidth:2}}),this.addDragHandler(e,i))}calculateCenter(e){if(!e||e.length===0)return null;const t=e.map(r=>r);let i=0,s=0,o=0;for(let r=0;r<t.length;r++)i+=t[r].x,s+=t[r].y,o+=t[r].z;return new this.Cesium.Cartesian3(i/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 i=t.polyline.positions.getValue();return Array.isArray(i)?i.slice():[]}if(t.polygon&&t.polygon.hierarchy&&t.polygon.hierarchy.getValue){const i=t.polygon.hierarchy.getValue();return i&&i.positions?i.positions.slice():[]}if(t.position&&t.position.getValue)return[t.position.getValue()];if(t.rectangle&&t.rectangle.coordinates&&t.rectangle.coordinates.getValue){const i=t.rectangle.coordinates.getValue();return[this.Cesium.Cartesian3.fromDegrees(i.west,i.south),this.Cesium.Cartesian3.fromDegrees(i.east,i.south),this.Cesium.Cartesian3.fromDegrees(i.east,i.north),this.Cesium.Cartesian3.fromDegrees(i.west,i.north)]}return[]}addDragHandler(e,t){if(console.log("移动线段"),this._dragHandler){try{this._dragHandler.destroy()}catch{}this._dragHandler=null}let i=!1,s,o=0;const r=16,l=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);this._dragHandler=l;const a=c=>{let u;try{u=this.viewer.scene.pickPosition(c)}catch{}if(!this.Cesium.defined(u)){const f=this.viewer.camera.getPickRay(c);f&&(u=this.viewer.scene.globe.pick(f,this.viewer.scene))}return this.Cesium.defined(u)||(u=this.viewer.scene.camera.pickEllipsoid(c,this.viewer.scene.globe.ellipsoid)),u};l.setInputAction(c=>{let u=!1;const f=this.viewer.scene.drillPick(c.position)||[];for(let p=0;p<f.length;p++){const h=f[p].id;if(h&&h===this.centerHandle){u=!0;break}}if(u){i=!0;const p=a(c.position);this.Cesium.defined(p)&&(s=p.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(c=>{if(!i||!this.Cesium.defined(s))return;const u=performance.now();if(u-o<r)return;o=u;const f=a(c.endPosition);if(!this.Cesium.defined(f))return;const p=this.Cesium.Cartesian3.subtract(f,s,new this.Cesium.Cartesian3);if(this.centerHandle&&this.centerHandle.position&&this.centerHandle.position.setValue){const h=this.centerHandle.position.getValue(this.Cesium.JulianDate.now());if(h){const A=this.Cesium.Cartesian3.add(h,p,new this.Cesium.Cartesian3);this.centerHandle.position.setValue(A)}}this.moveEntity(e,p);try{this.viewer.scene.requestRender()}catch{}s=f.clone()},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE),l.setInputAction(()=>{if(i){i=!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 c=e.getEntity();if(c.state="done",c&&c.rectangle&&c.rectangle.coordinates)try{const u=c.rectangle.coordinates.getValue?c.rectangle.coordinates.getValue():c.rectangle.coordinates;u&&c.rectangle.coordinates.setValue(u)}catch(u){console.warn("Failed to refresh rectangle coordinates",u)}e&&this.selectedEntityObj!==e&&this.showEntityOutline(e)}},this.Cesium.ScreenSpaceEventType.LEFT_UP)}moveEntity(e,t){const i=e.getEntity();if(!i)return;const s=o=>this.Cesium.Cartesian3.add(o,t,new this.Cesium.Cartesian3);if(i.position){const o=i.position.getValue?i.position.getValue():i.position,r=s(o);i.position.setValue?i.position.setValue(r):i.position=r,i.state="moving",e.positions&&e.positions.length===1&&(e.positions[0]=r);return}if(i.polyline){if(i._plotInstance&&i._plotInstance.type==="rectangle"&&typeof i._plotInstance.updatePositions=="function")try{const l=new this.Cesium.Cartesian3(t.x,t.y,t.z);if(i._plotInstance.updatePositions([l]))return}catch(l){console.warn("Failed to update rectangle positions:",l)}if(i._plotInstance&&i._plotInstance.type==="circle"&&typeof i._plotInstance.updatePositions=="function")try{const l=new this.Cesium.Cartesian3(t.x,t.y,t.z);if(i._plotInstance.updatePositions([l]))return}catch(l){console.warn("Failed to update circle positions:",l)}const r=(e.positions&&Array.isArray(e.positions)?e.positions:i.polyline.positions.getValue?i.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),i.polyline&&i.polyline.positions)try{i.polyline.positions instanceof this.Cesium.CallbackProperty||(i.polyline.positions=r)}catch{i.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 i=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:!i},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(c=>({x:c.x,y:c.y,z:c.z}));else{const c=o.getEntity?o.getEntity():o;if(c)try{if(c.polyline&&c.polyline.positions&&c.polyline.positions.getValue){const u=c.polyline.positions.getValue(this.viewer.clock.currentTime);Array.isArray(u)&&(a=u.map(f=>({x:f.x,y:f.y,z:f.z})))}else if(c.rectangle&&c.rectangle.coordinates&&c.rectangle.coordinates.getValue){const u=c.rectangle.coordinates.getValue(this.viewer.clock.currentTime);a=[{west:u.west,south:u.south,east:u.east,north:u.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 c=o.getEntity?o.getEntity():o;if(c&&c._plotInstance&&c._plotInstance.type==="circle"&&c._plotInstance.center&&c._plotInstance.radiusPoint){const u=c._plotInstance;a=[{x:u.center.x,y:u.center.y,z:u.center.z},{x:u.radiusPoint.x,y:u.radiusPoint.y,z:u.radiusPoint.z}]}else if(o.positions&&Array.isArray(o.positions)&&o.positions.length)a=o.positions.map(u=>({x:u.x,y:u.y,z:u.z}));else if(c)try{if(c.polyline&&c.polyline.positions&&c.polyline.positions.getValue){const u=c.polyline.positions.getValue(this.viewer.clock.currentTime);Array.isArray(u)&&(a=u.map(f=>({x:f.x,y:f.y,z:f.z})))}else if(c.ellipse&&c.ellipse.center&&c.ellipse.center.getValue&&c.ellipse.semiMajorAxis&&c.ellipse.semiMajorAxis.getValue){const u=c.ellipse.center.getValue(this.viewer.clock.currentTime),f=c.ellipse.semiMajorAxis.getValue(this.viewer.clock.currentTime);if(u&&f){const p={x:u.x,y:u.y,z:u.z||0},h={x:p.x+f,y:p.y,z:p.z};a=[p,h]}}}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 c={};try{const u=a.label.fillColor&&a.label.fillColor.getValue?a.label.fillColor.getValue(this.viewer.clock.currentTime):a.label.fillColor;u&&(c.color=u)}catch{}a.label.font&&(c.font=a.label.font),l.style=c}}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 c=a.label.text.getValue?a.label.text.getValue(this.viewer.clock.currentTime):a.label.text;c&&(l.text=c)}}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 c=a.position.getValue(this.viewer.clock.currentTime);c&&(l.position={x:c.x,y:c.y,z:c.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 c={};try{const u=a.billboard.image&&a.billboard.image.getValue?a.billboard.image.getValue(this.viewer.clock.currentTime):a.billboard.image;if(u){if(typeof u=="string")c.image=u;else if(u&&u.src)try{const f=u;if(typeof document<"u"&&f instanceof HTMLImageElement){const p=document.createElement("canvas");p.width=f.naturalWidth||f.width||1,p.height=f.naturalHeight||f.height||1;const h=p.getContext("2d");h?(h.drawImage(f,0,0),c.image=p.toDataURL()):c.image=f.src}else c.image=u.src}catch{c.image=u.src}}}catch{}a.billboard.width&&(c.width=a.billboard.width),a.billboard.height&&(c.height=a.billboard.height),l.style=c}}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 c=a.position.getValue(this.viewer.clock.currentTime);c&&(l.position={x:c.x,y:c.y,z:c.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 i={version:"1.0",exportTime:new Date().toISOString(),totalEntities:e.length,annotations:t},s=JSON.stringify(i);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 i=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 c=a.style.color;a.style.color=`rgba(${Math.round(c.red*255)}, ${Math.round(c.green*255)}, ${Math.round(c.blue*255)}, ${c.alpha||1})`}if(a.style.outlineColor&&typeof a.style.outlineColor=="object"){const c=a.style.outlineColor;a.style.outlineColor=`rgba(${Math.round(c.red*255)}, ${Math.round(c.green*255)}, ${Math.round(c.blue*255)}, ${c.alpha||1})`}}switch(l){case"freehand":case"polyline":case"arrow":if(a.positions&&a.positions.length>0){const c=a.positions.map(p=>p&&typeof p=="object"?new this.Cesium.Cartesian3(p.x,p.y,p.z):p),u={type:l==="freehand"?"freehandLine":l,style:a.style||{},positions:c,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))},f=this.drawTool.createByPositions(u);if(f&&f.getEntity()){s++,f.isEdit=!0;const p=f.getEntity();p&&!p._plotInstance&&(p._plotInstance=f),p&&!p.objId&&(p.objId=f.objId),console.log(`Loaded ${l} entity with objId: ${f.objId}`)}}break;case"rectangle":{try{if(a.positions&&a.positions.length){let c=[];if(a.positions[0]&&a.positions[0].x!==void 0)c=a.positions.map(u=>new this.Cesium.Cartesian3(u.x,u.y,u.z!==void 0?u.z:0));else if(a.positions[0]&&a.positions[0].west!==void 0){const u=a.positions[0];c=[this.Cesium.Cartesian3.fromRadians(u.west,u.south),this.Cesium.Cartesian3.fromRadians(u.east,u.south),this.Cesium.Cartesian3.fromRadians(u.east,u.north),this.Cesium.Cartesian3.fromRadians(u.west,u.north),this.Cesium.Cartesian3.fromRadians(u.west,u.south)]}if(c.length){const u=JSON.parse(JSON.stringify(a.style||{}));if(u.color&&typeof u.color=="string"&&!u.color.startsWith("rgba"))try{const h=JSON.parse(u.color);h.red!==void 0&&(u.color=`rgba(${Math.round(h.red*255)}, ${Math.round(h.green*255)}, ${Math.round(h.blue*255)}, ${h.alpha||1})`)}catch{}const f={type:"rectangle",positions:c,style:u,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let p=null;try{p=this.drawTool.createByPositions(f)}catch(h){console.warn("drawTool.createByPositions(rectangle) failed",h)}if(p){s++,p.isEdit=!0;const h=p.getEntity?p.getEntity():p.entity||p;h&&(h._plotInstance=p,h.objId=p.objId||a.id,h.pickable=!0,h.polyline&&(h.polyline.pickWidth=10),console.log(`Loaded rectangle entity with objId: ${h.objId}, color: ${u.color}`))}}}}catch(c){console.warn("load rectangle failed",c)}break}case"text":if(a.position){const c=a.text||"文字标注",u={type:"label",style:a.style||{},text:c,position:new this.Cesium.Cartesian3(a.position.x,a.position.y,a.position.z||0)};u.style.fontSize||(u.style.fontSize=14),u.style.fontFamily||(u.style.fontFamily="Arial");let f;try{!u.positions&&u.position&&(u.positions=u.position),f=this.drawTool.createByPositions(u),!f&&this.drawTool.startText&&(console.log("使用startText创建文字"),this.drawTool.startText(u.style),this.drawTool.currentEntity&&(this.drawTool.currentEntity.text=c,this.drawTool.currentEntity.position=u.position,f=this.drawTool.currentEntity))}catch(p){console.log("创建文字失败",p)}if(!f)try{const p=this.viewer.entities.add({position:u.position,label:Object.assign({text:c,font:u.style&&u.style.font||"14pt Source Han Sans CN",fillColor:u.style&&u.style.fillColor||this.Cesium.Color.WHITE,outlineColor:u.style&&u.style.outlineColor||this.Cesium.Color.BLACK,outlineWidth:u.style&&u.style.outlineWidth||2,verticalOrigin:u.style&&u.style.verticalOrigin||this.Cesium.VerticalOrigin.BOTTOM,pixelOffset:u.style&&u.style.pixelOffset||new this.Cesium.Cartesian2(0,-10)},u.style&&u.style.label?u.style.label:{})}),h={getEntity:()=>p,entity:p,style:u.style||{},type:"label",objId:a.id||`label_${Date.now()}_${Math.random().toFixed(3)}`,isEdit:!0,destroy:()=>this.viewer.entities.remove(p)};try{p.objId=h.objId}catch{}this.drawTool&&(this.drawTool.entityObjArr||(this.drawTool.entityObjArr=[]),this.drawTool.entityObjArr.push(h)),f=h}catch(p){console.warn("回退创建文字实体失败",p)}f&&(s++,f.isEdit=!0)}break;case"image":if(a.position){const c={type:"billboard",style:a.style||{},position:new this.Cesium.Cartesian3(a.position.x,a.position.y,a.position.z||0)};c.style.image||(console.log("使用默认图片占位符"),c.style.image="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgdmlld0JveD0iMCAwIDUwIDUwIj48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNlNTMyMzIiLz48L3N2Zz4="),c.style.width||(c.style.width=50),c.style.height||(c.style.height=50);let u;try{!c.positions&&c.position&&(c.positions=c.position),u=this.drawTool.createByPositions(c),!u&&this.drawTool.startImage&&(console.log("使用startImage创建图片"),this.drawTool.startImage(c.style.image,c.style),this.drawTool.currentEntity&&(this.drawTool.currentEntity.position=c.position,u=this.drawTool.currentEntity))}catch(f){console.log("创建图片失败",f)}if(!u)try{const f=c.style&&c.style.image?c.style.image:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgdmlld0JveD0iMCAwIDUwIDUwIj48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNlNTMyMzIiLz48L3N2Zz4=",p=this.viewer.entities.add({position:c.position,billboard:{image:f,width:c.style&&c.style.width?c.style.width:50,height:c.style&&c.style.height?c.style.height:50,verticalOrigin:c.style&&c.style.verticalOrigin||this.Cesium.VerticalOrigin.CENTER,scale:c.style&&c.style.scale||1}}),h={getEntity:()=>p,entity:p,style:c.style||{},type:"billboard",objId:a.id||`billboard_${Date.now()}_${Math.random().toFixed(3)}`,isEdit:!0,destroy:()=>this.viewer.entities.remove(p)};try{p.objId=h.objId}catch{}this.drawTool&&(this.drawTool.entityObjArr||(this.drawTool.entityObjArr=[]),this.drawTool.entityObjArr.push(h)),u=h}catch(f){console.warn("回退创建图片实体失败",f)}u&&(s++,u.isEdit=!0)}break;case"ellipse":case"circle":{try{const c=JSON.parse(JSON.stringify(a.style||{}));if(c.color&&typeof c.color=="string"&&!c.color.startsWith("rgba"))try{const p=JSON.parse(c.color);p.red!==void 0&&(c.color=`rgba(${Math.round(p.red*255)}, ${Math.round(p.green*255)}, ${Math.round(p.blue*255)}, ${p.alpha||1})`)}catch{}let u=[],f=!1;if(a.positions&&a.positions.length&&(a.positions[0]&&a.positions[0].x!==void 0&&(u=a.positions.map(p=>new this.Cesium.Cartesian3(p.x,p.y,p.z!==void 0?p.z:0))),u.length)){const p={type:l,positions:u,style:c,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let h=null;try{if(h=this.drawTool.createByPositions(p),h){s++,h.isEdit=!0;const A=h.getEntity?h.getEntity():h.entity||h;A&&(A._plotInstance=h,A.objId=h.objId||a.id,A.pickable=!0,A.polyline&&(A.polyline.pickWidth=10),console.log(`Loaded ${l} entity with objId: ${A.objId} using positions`)),f=!0}}catch(A){console.warn(`drawTool.createByPositions(${l}) failed`,A)}}if(!f&&a.center&&a.radius)try{const p=new this.Cesium.Cartesian3(a.center.x,a.center.y,a.center.z||0),h=this.Cesium.Cartesian3.add(p,new this.Cesium.Cartesian3(a.radius,0,0),new this.Cesium.Cartesian3),C={type:l,positions:[p,h],style:c,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let m=null;try{if(m=this.drawTool.createByPositions(C),m){s++,m.isEdit=!0;const y=m.getEntity?m.getEntity():m.entity||m;y&&(y._plotInstance=m,y.objId=m.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(p){console.warn(`Fallback creation for ${l} failed`,p)}}catch(c){console.warn(`load ${l} failed`,c)}break}default:console.log(`尝试加载未知类型实体: ${l}`);break}})};return Object.keys(i).forEach(r=>{o(i[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 i;try{i=this.Cesium.Color.fromCssColorString(e)}catch(s){console.warn("Invalid color format:",e,s),i=e}if(t.polyline)try{t.polyline.material=new this.Cesium.ColorMaterialProperty(i)}catch{t.polyline.material=i}else if(t.polygon)try{t.polygon.material=new this.Cesium.ColorMaterialProperty(i)}catch{t.polygon.material=i}else if(t.rectangle){const s=t.rectangle.outline,o=t.rectangle.outlineWidth;try{t.rectangle.material=new this.Cesium.ColorMaterialProperty(i)}catch{t.rectangle.material=i}t.rectangle.outlineColor=i,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=i,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 i=2;if(typeof e=="number")i=e;else switch(e){case"thin":i=2;break;case"medium":i=4;break;case"thick":i=8;break}if(t.polyline)t.polyline.width=i;else if(t.polygon&&t.polygon.outline)t.polygon.outlineWidth=i;else if(t.rectangle&&t.rectangle.outline)t.rectangle.outlineWidth=i;else if((t.ellipse||t.circle)&&(t.ellipse?.outline||t.circle?.outline)){const s=t.ellipse||t.circle;s.outlineWidth=i}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 nc{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 i=this.cesium;this.originalDoubleClickAction=this.viewer.screenSpaceEventHandler.getInputAction(i.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.viewer.screenSpaceEventHandler.removeInputAction(i.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(i=>{const s=this.getPickPosition(i.position);s&&this.addPoint(s)},t.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(i=>{const s=this.getPickPosition(i.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 i=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(i),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 c=t.Transforms.eastNorthUpToFixedFrame(s),u=t.Matrix4.inverse(c,new t.Matrix4),f=t.Matrix4.multiplyByPoint(u,o,new t.Cartesian3),p=f.x,h=f.y,A=f.z,C=t.Matrix4.getColumn(c,0,new t.Cartesian3),m=t.Matrix4.getColumn(c,1,new t.Cartesian3),y=t.Cartesian3.multiplyByScalar(C,p,new t.Cartesian3),E=t.Cartesian3.add(s,y,new t.Cartesian3),I=t.Cartesian3.multiplyByScalar(m,h,new t.Cartesian3),S=t.Cartesian3.add(E,I,new t.Cartesian3);if(this.viewer.scene.mode!==t.SceneMode.SCENE2D){const k=this.viewer.entities.add({polyline:{positions:[s,E],width:2,material:new t.PolylineDashMaterialProperty({color:t.Color.RED}),depthFailMaterial:new t.PolylineDashMaterialProperty({color:new t.Color(1,0,0,.5)})}}),B=this.viewer.entities.add({polyline:{positions:[E,S],width:2,material:new t.PolylineDashMaterialProperty({color:t.Color.GREEN}),depthFailMaterial:new t.PolylineDashMaterialProperty({color:new t.Color(0,1,0,.5)})}}),x=this.viewer.entities.add({polyline:{positions:[S,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(k,B,x)}this.onMeasure({type:"distance",dx:p,dy:h,dz:A,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 i=this.activePoints[this.activePoints.length-1];this.addLabel(i,`Total: ${this.formatDistance(t)}`)}else if(this.type==="area"&&this.activePoints.length>=3){const t=this.calculateArea(this.activePoints),i=this.calculateCenter(this.activePoints);this.addLabel(i,`面积: ${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 i=this.viewer.entities.add({polyline:{positions:t,width:2,material:e.Color.YELLOW,depthFailMaterial:e.Color.YELLOW}});this.measureEntities.push(i)}else if(this.type==="area"){const t=[...this.activePoints];this.viewer.entities.remove(this.activeShape);const i=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(i)}this.activeShape=null}this.activePoints=[],this.type=null,this.cursorPosition=null}getPickPosition(e){const t=this.cesium;let i;try{i=this.viewer.scene.pickPosition(e)}catch{}if(!i||!t.defined(i)){const s=this.viewer.camera.getPickRay(e);s&&(i=this.viewer.scene.globe.pick(s,this.viewer.scene))}if((!i||!t.defined(i))&&(i=this.viewer.scene.camera.pickEllipsoid(e,this.viewer.scene.globe.ellipsoid)),!i||!t.defined(i))return null;if(this.isSnapping){const s=this.snapToVertex(e);if(s)i=s;else{const o=this.snapTo3DTileFeature(e);o&&(i=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}}))),i}snapTo3DTileFeature(e){const t=this.cesium,i=10,s=[{x:0,y:0},{x:-i,y:0},{x:i,y:0},{x:0,y:-i},{x:0,y:i},{x:-i,y:-i},{x:i,y:-i},{x:-i,y:i},{x:i,y:i}];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 c=this.viewer.scene.pickPosition(l);if(c)return c}catch{}}return null}snapToVertex(e){const t=this.cesium,i=this.viewer.entities.values;let s=20,o=null;for(let r=0;r<i.length;r++){const l=i[r];if(!l.show)continue;let a=[];if(l.polyline&&l.polyline.positions){const c=l.polyline.positions.getValue(t.JulianDate.now());c&&(a=c)}else if(l.polygon&&l.polygon.hierarchy){const c=l.polygon.hierarchy.getValue(t.JulianDate.now());c&&c.positions&&(a=c.positions)}else if(l.position){const c=l.position.getValue(t.JulianDate.now());c&&(a=[c])}else if(l.rectangle&&l.rectangle.coordinates){const c=l.rectangle.coordinates.getValue(t.JulianDate.now());c&&(a=[t.Cartesian3.fromRadians(c.west,c.south),t.Cartesian3.fromRadians(c.east,c.south),t.Cartesian3.fromRadians(c.east,c.north),t.Cartesian3.fromRadians(c.west,c.north)])}for(let c=0;c<a.length;c++){const u=a[c];try{const f=this.viewer.scene.cartesianToCanvasCoordinates(u);if(f){const p=t.Cartesian2.distance(f,e);p<s&&(s=p,o=u)}}catch{}}}return o}addLabel(e,t){const i=this.cesium,s=this.viewer.entities.add({position:e,label:{text:t,font:"14px sans-serif",fillColor:i.Color.WHITE,style:i.LabelStyle.FILL_AND_OUTLINE,outlineWidth:2,verticalOrigin:i.VerticalOrigin.BOTTOM,pixelOffset:new i.Cartesian2(0,-10),disableDepthTestDistance:Number.POSITIVE_INFINITY,showBackground:!0,backgroundColor:new i.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,i){const s=this.cesium,o=s.Cartesian3.subtract(e,t,new s.Cartesian3),r=s.Cartesian3.subtract(i,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)),c=Math.acos(a);return s.Math.toDegrees(c)}calculateArea(e){const t=this.cesium;if(e.length<3)return 0;const i=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,i,new t.Cartesian3),c=t.Cartesian3.subtract(l,i,new t.Cartesian3),u=t.Cartesian3.cross(a,c,new t.Cartesian3);t.Cartesian3.add(s,u,s)}return t.Cartesian3.magnitude(s)*.5}calculateCenter(e){const t=this.cesium;if(!e||e.length===0)return null;let i=0,s=0,o=0;for(let r=0;r<e.length;r++)i+=e[r].x,s+=e[r].y,o+=e[r].z;return new t.Cartesian3(i/e.length,s/e.length,o/e.length)}formatArea(e){return e>1e6?`${(e/1e6).toFixed(2)} km²`:`${e.toFixed(2)} m²`}}class O0{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 i=this.cesium.Color.fromCssColorString(e);i?(this.viewer.scene.backgroundColor=i,this.viewer.scene.globe.baseColor=i):(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"),i=new Promise((s,o)=>setTimeout(()=>o(new Error("ArcGIS Terrain request timed out")),5e3));this.viewer.terrainProvider=await Promise.race([t,i])}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(i){console.error("Failed to enable terrain (both ArcGIS and Ion failed):",i),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,i=t.screenSpaceCameraController;t.postProcessStages.fxaa.enabled=!1,this.setBackgroundColor("#000000"),this.setGlobeColor("#000000"),this.viewer.imageryLayers.removeAll(),this.setGlobeEnvironmentVisible(!0),t.globe.depthTestAgainstTerrain=!1,this.viewer.terrainProvider=new e.EllipsoidTerrainProvider,i.zoomFactor=8,i.enableZoomInertia=!1,i.minimumZoomDistance=.001,i.maximumZoomDistance=1e6,i.enableTilt=!1,i.enableLook=!1,i.enableCollisionDetection=!0,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),c=0,u=Math.abs(o.heading-l);((u>Math.PI?Math.abs(u-2*Math.PI):u)>r||Math.abs(o.pitch-a)>r||Math.abs(o.roll-c)>r)&&o.setView({orientation:{heading:l,pitch:a,roll:c}})};this._removeCameraLockListener=this.viewer.scene.postRender.addEventListener(s)}_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}async changeBaseMap(e,t){if(this.is2d){this.viewer.imageryLayers.removeAll();return}const i=Date.now();this.lastBaseMapRequestId=i;const s=this.viewer.imageryLayers,o=[];if(e==="tianditu"){const r=t?.token||"c25f14fb6bd4397cf8fe45144ff768d6",l=t?.layerType||"img_w",a=l.split("_"),c=a[0]||"img",u=a[1]||"w";let f="";c==="img"?f="cia":c==="vec"?f="cva":c==="ter"&&(f="cta");const p=f?`${f}_${u}`:"";o.push(new this.cesium.WebMapTileServiceImageryProvider({url:`https://{s}.tianditu.gov.cn/${l}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${c}&STYLE=default&TILEMATRIXSET=${u}&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=${r}`,layer:c,style:"default",format:"tiles",tileMatrixSetID:u,maximumLevel:18,subdomains:["t0","t1","t2","t3","t4","t5","t6","t7"]})),t.showAnnotation!==!1&&p&&o.push(new this.cesium.WebMapTileServiceImageryProvider({url:`https://{s}.tianditu.gov.cn/${p}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${f}&STYLE=default&TILEMATRIXSET=${u}&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=${r}`,layer:f,style:"default",format:"tiles",tileMatrixSetID:u,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((u,f)=>setTimeout(()=>f(new Error("ArcGIS metadata request timed out")),3e3)),c=await Promise.race([l,a]);o.push(c)}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!==i){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 i=this.cesium.JulianDate.fromDate(t);this.viewer.clock.currentTime=i}setModelColorAdjustment(e){if(this.is2d)return;const t=this.viewer,i=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,c=!!i.CustomShader;for(let u=0;u<a;++u){const f=l.get(u);if(f instanceof i.Cesium3DTileset)if(c)if(f.customShader&&f.customShader.isModelAdjustment)e.brightness!==void 0&&f.customShader.setUniform("u_brightness",s),e.contrast!==void 0&&f.customShader.setUniform("u_contrast",o),e.saturation!==void 0&&f.customShader.setUniform("u_saturation",r);else{const p=new i.CustomShader({uniforms:{u_brightness:{type:i.UniformType.FLOAT,value:s},u_contrast:{type:i.UniformType.FLOAT,value:o},u_saturation:{type:i.UniformType.FLOAT,value:r}},fragmentShaderText:`
98
+ `;this.promptDiv=window.document.createElement("div"),this.promptDiv.className=`easy3d-prompt ${this.opt.className}`,this.promptDiv.id=f,this.promptDiv.innerHTML=p,window.document.getElementById(o).appendChild(this.promptDiv);const A=window.document.getElementById(`prompt-close-${this.opt.id}`);let C=this;A&&A.addEventListener("click",m=>{C.hide(),C.opt.close&&C.opt.close()}),this.promptDom=window.document.getElementById(f),this.position=this.transPosition(this.opt.position),i==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 i=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),i&&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 Oa=Object.freeze(Object.defineProperty({__proto__:null,default:yt},Symbol.toStringTag,{value:"Module"}));let ce={};ce.cartesianToLnglat=function(n,e){if(!n)return[];var t=Cesium.Cartographic.fromCartesian(n),i=Cesium.Math.toDegrees(t.latitude),s=Cesium.Math.toDegrees(t.longitude),o=t.height;return[s,i,o]},ce.getViewCenter=n=>{if(n){var e=n.camera.computeViewRectangle(),t=e.west/Math.PI*180,i=e.north/Math.PI*180,s=e.east/Math.PI*180,o=e.south/Math.PI*180;return[(s+t)/2,(i+o)/2]}},ce.cartesiansToLnglats=function(n,e){if(!(!n||n.length<1)){if(e=e||window.viewer,!e){console.log("util.cartesiansToLnglats方法缺少viewer对象");return}for(var t=[],i=0;i<n.length;i++)t.push(ce.cartesianToLnglat(n[i],e));return t}},ce.lnglatsToCartesians=function(n){if(!(!n||n.length<1)){for(var e=[],t=0;t<n.length;t++){var i=Cesium.Cartesian3.fromDegrees(n[t][0],n[t][1],n[t][2]||0);e.push(i)}return e}},ce.flyTo=function(n,e){if(!e){console.log("util.flyTo缺少viewer对象");return}n=n||{};let t=n.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(n.heading||0),Cesium.Math.toRadians(n.pitch||-60),n.range||1e4)}),t instanceof Array){var i=new Cesium.BoundingSphere(Cesium.Cartesian3.fromDegrees(t[0],t[1],t[2]));e.camera.flyToBoundingSphere(i,{offset:new Cesium.HeadingPitchRange(Cesium.Math.toRadians(n.heading||0),Cesium.Math.toRadians(n.pitch||-60),n.range||1e4)})}},ce.getCameraView=function(n){if(n=n||window.viewer,!n){console.log("util.getCameraView缺少viewer对象");return}var e=n.camera,t=e.position,i=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(i),pitch:Cesium.Math.toDegrees(s),roll:Cesium.Math.toDegrees(o)};return l},ce.setCameraView=function(n,e){if(e=e||window.viewer,!e){console.log("util.setCameraView缺少viewer对象");return}if(n){var t=n.destination||Cesium.Cartesian3.fromDegrees(n.x,n.y,n.z);e.camera.flyTo({destination:t,orientation:{heading:Cesium.Math.toRadians(n.heading||0),pitch:Cesium.Math.toRadians(n.pitch||0),roll:Cesium.Math.toRadians(n.roll||0)},duration:n.duration===void 0?3:n.duration,complete:n.complete})}},ce.computeAreaOfTriangle=function(n,e,t){if(!n||!e||!t)return console.log("传入坐标有误!"),0;var i=Cesium.Cartesian3.distance(n,e),s=Cesium.Cartesian3.distance(e,t),o=Cesium.Cartesian3.distance(t,n),r=(i+s+o)/2;return Math.sqrt(r*(r-i)*(r-s)*(r-o))};class tt{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 i,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)i=this.viewer.scene.pickPosition(e);else{let o=this.viewer.camera.getPickRay(e);if(!o)return null;i=this.viewer.scene.globe.pick(o,this.viewer.scene)}return i}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?ce.cartesiansToLnglats(this.positions,this.viewer):this.positions}getLnglats(){return ce.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 i=0;i<t.controlPoints.length;i++){let s=t.controlPoints[i];s&&(s.show=!0)}this.entity.show=!0,this.modifyHandler.setInputAction(function(i){if(!t.entity)return;let s=t.viewer.scene.pick(i.position);Cesium.defined(s)&&s.id&&(s.id.objId||(t.modifyPoint=s.id),t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(i){if(t.positions.length<1||!t.modifyPoint)return;let s=t.getCatesian3FromPX(i.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(i){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 i=this.controlPoints[t];i&&(i.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 i=this.pointStyle.outlineColor instanceof Cesium.Color?this.pointStyle.outlineColor:Cesium.Color.fromCssColorString(this.pointStyle.outlineColor);return i=i.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:i,disableDepthTestDistance:Number.POSITIVE_INFINITY},show:!1})}transfromLineMaterial(e){if(!e)return;let t={};if(e instanceof Cesium.Color){let i=e.color.getValue();t.colorAlpha=i.alpha,t.colorHex=new Cesium.Color(i.red,i.green,i.blue,1).toCssHexString()}return t}transfromGonMaterial(e){if(!e)return;let t={};if(e instanceof Cesium.Color){let i=e.color.getValue();t.colorAlpha=i.alpha,t.colorHex=new Cesium.Color(i.red,i.green,i.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 jg="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 $g extends tt{constructor(e,t){super(e,t),this.type="billboard",this.viewer=e;let i={verticalOrigin:Cesium.VerticalOrigin.BOTTOM,scale:1};this.style=Object.assign({},i,t||{}),this.entity=null,this.style.hasOwnProperty("image")||console.warn("CreateBillboard: 未在 style 中指定 image,后续将使用回退图或占位图。"),this.position=null,this._defaultFallback=jg,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((i,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(c),i(o))},a=u=>{r||(r=!0,clearTimeout(c),s(new Error("image load error: "+e)))};o.onload=l,o.onerror=a;const c=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,i=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}});i.objId=this.objId;const s=this.style.image;if(s)this._preloadImage(s,7e3).then(o=>{try{i.billboard.image=o,this.style.image=s}catch(r){console.warn("CreateBillboard: set billboard image element failed, fallback to url string",r);try{i.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=i,i}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(i=>{try{this.entity.billboard.image=i}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(i=>{console.error("CreateBillboard: updateBillboardImage failed to load:",i.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 yt(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(i){let s=t.getCatesian3FromPX(i.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(i){t.prompt&&t.prompt.update&&t.prompt.update(i.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 i=null;e instanceof Cesium.Cartesian3?i=e.clone():i=Cesium.Cartesian3.fromDegrees(Number(e[0]),Number(e[1]),Number(e[2]||0)),i&&(this.position=i.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 i=1;e.heightReference==!0?i=1:i=Number(e.heightReference);try{t.heightReference=i}catch{}}if(e.scale!=null)try{t.scale=Number(e.scale)}catch{}if(e.color){let i=e.color instanceof Cesium.Color?e.color:Cesium.Color.fromCssColorString(e.color);i=i.withAlpha(e.colorAlpha||1);try{t.color=i}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 i=t.heightReference.getValue();e.heightReference=Number(i)}catch{}if(t&&t.scale)try{e.scale=t.scale.getValue()}catch{}if(t&&t.color)try{let i=t.color.getValue();e.colorAlpha=i.alpha,e.color=new Cesium.Color(i.red,i.green,i.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,i=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)}i=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){i=l.id,s=!0,t._isDragging=!0,t._editPickedEntity=i,t.modifyPoint=null;try{t.forbidDrawWorld(!0)}catch{}}else if(t.controlPoints.includes(l.id)){t.modifyPoint=l.id,s=!0,t._isDragging=!0,i=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(i)){try{i.position.setValue(l)}catch{i.position=l}t.position=l.clone(),t.controlPoints&&t.controlPoints.length>0&&t.controlPoints.forEach(a=>{try{a.position.setValue(l)}catch(c){console.warn("更新控制点位置失败:",c);try{a.position=l.clone()}catch(u){console.error("重新设置控制点位置失败:",u)}}})}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 i=Cesium.Color.GREEN;t==="bottomLeft"&&(i=Cesium.Color.BLUE);const s=this.viewer.entities.add({position:e,point:{pixelSize:10,color:i,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 c=new Cesium.Cartesian3;Cesium.Cartesian3.multiplyByScalar(l,s,c),Cesium.Cartesian3.multiplyByScalar(a,s,a),Cesium.Cartesian3.add(c,a,c);const u=new Cesium.Ray(e,r),f=this.viewer.scene.globe.pick(u,this.viewer.scene),h=Cesium.Cartesian3.distance(e,f||e)*.001;return Cesium.Cartesian3.multiplyByScalar(c,h,c),Cesium.Cartesian3.add(e,c,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(i){console.warn("更新拖拽中控制点位置失败:",i)}}});return}if(this.controlPoints.length>0&&([...this.controlPoints].forEach(t=>{try{this.viewer&&this.viewer.entities&&t&&this.viewer.entities.remove(t)}catch(i){console.warn("移除控制点失败:",i)}}),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(i){console.warn("移除控制点失败:",i)}}),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 i=new FileReader;i.onload=s=>{this.updateBillboardImage(s.target.result),this._fileInput&&(this._fileInput.value="")},i.onerror=s=>{console.error("文件读取失败:",s)},i.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?ce.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 Kg extends tt{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 yt(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(i){const s=t.getCatesian3FromPX(i.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(i){if(!t.entity){t.prompt?.update(i.endPosition,"单击开始绘制");return}t.prompt?.update(i.endPosition,"单击结束");const s=t.getCatesian3FromPX(i.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(i){const s=t.viewer.scene.pick(i.position);if(!s?.id)return;t.modifyPoint=s.id;const o=t.getCatesian3FromPX(i.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(i){if(!t.modifyPoint)return;const s=t.getCatesian3FromPX(i.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,i=t.cartesianToCartographic(this.center),s=t.cartesianToCartographic(this.radiusPoint),o=Math.abs(s.longitude-i.longitude),r=Math.abs(s.latitude-i.latitude);for(let l=0;l<=this.pointsCount;l++){const a=l/this.pointsCount*Math.PI*2,c=i.longitude+o*Math.cos(a),u=i.latitude+r*Math.sin(a);e.push(Cesium.Cartesian3.fromRadians(c,u))}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 i=t.x-e.x,s=t.y-e.y,o=t.z-e.z;this.center=new Cesium.Cartesian3(this.center.x+i,this.center.y+s,this.center.z+o),this.radiusPoint=new Cesium.Cartesian3(this.radiusPoint.x+i,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?ce.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 i=t.color instanceof Cesium.Color?t.color:Cesium.Color.fromCssColorString(t.color||"#00FF00");t.colorAlpha!=null&&(i=i.withAlpha(t.colorAlpha)),this.entity.polyline.material=i,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 i=e[0]instanceof Cesium.Cartesian3?e:ce.lnglatsToCartesians(e);if(!i||i.length===0)return console.error("createByPositions: failed to convert positions to Cartesian3"),t&&t(null),this;if(i.length>=2)this.center=Cesium.Cartesian3.clone(i[0]),this.radiusPoint=Cesium.Cartesian3.clone(i[1]);else if(i.length===1)this.center=Cesium.Cartesian3.clone(i[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(i){return console.error("createByPositions error:",i),t&&t(null),this}}}class qg extends tt{constructor(e,t){if(super(e,t),this.type="gltfModel",t=t||{},this.viewer=e,!t.uri){console.warn("请输入模型地址!");return}let i={heading:0,pitch:0,roll:0,minimumPixelSize:24,maximumScale:120};this.style=Object.assign(i,t||{}),this.modelUri=t.uri,this.entity=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new yt(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(i){let s=t.getCatesian3FromPX(i.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(i){t.prompt.update(i.endPosition,"单击新增"),t.state="creating";let s=t.getCatesian3FromPX(i.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,i;this.state="startEdit",this.modifyHandler.setInputAction(function(s){let o=t.viewer.scene.pick(s.position);Cesium.defined(o)&&o.id&&(i=o.id,t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(s){if(!i)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){i&&(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),i=Cesium.Math.toRadians(this.style.pitch),s=Cesium.Math.toRadians(this.style.roll),o=new Cesium.HeadingPitchRoll(t,i,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?ce.cartesianToLnglat(this.position,this.viewer):this.position}getStyle(){let e={},t=this.entity.model;e.minimumPixelSize=t.minimumPixelSize.getValue();let i=this.entity.orientation.getValue(),s=this.entity.position.getValue(this.viewer.clock.currentTime),o=ce.oreatationToHpr(s.clone(),i,!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,i){e=e||0,t=t||0,i=i||0,this.style.heading=e,this.style.pitch=t,this.style.roll=i;var s=Cesium.Math.toRadians(e||0),o=Cesium.Math.toRadians(t||0),r=Cesium.Math.toRadians(i||0),l=new Cesium.HeadingPitchRoll(s,o,r),a=this.entity.position._value,c=Cesium.Transforms.headingPitchRollQuaternion(a,l);this.entity&&(this.entity.orientation=c)}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 n=(function(){try{var t={},i=Object.defineProperty,s=i(t,t,t)&&i}catch{}return s})(),e=function(t){if(this==null)throw TypeError();var i=String(this),s=i.length,o=t?Number(t):0;if(o!=o&&(o=0),!(o<0||o>=s)){var r=i.charCodeAt(o),l;return r>=55296&&r<=56319&&s>o+1&&(l=i.charCodeAt(o+1),l>=56320&&l<=57343)?(r-55296)*1024+l-56320+65536:r}};n?n(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e})();function nn(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Hs,La;function Xg(){if(La)return Hs;La=1;var n=0,e=-3;function t(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function i(g,R){this.source=g,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=R,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),c=new Uint16Array(30),u=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),f=new t,p=new Uint8Array(320);function h(g,R,M,F){var L,G;for(L=0;L<M;++L)g[L]=0;for(L=0;L<30-M;++L)g[L+M]=L/M|0;for(G=F,L=0;L<30;++L)R[L]=G,G+=1<<g[L]}function A(g,R){var M;for(M=0;M<7;++M)g.table[M]=0;for(g.table[7]=24,g.table[8]=152,g.table[9]=112,M=0;M<24;++M)g.trans[M]=256+M;for(M=0;M<144;++M)g.trans[24+M]=M;for(M=0;M<8;++M)g.trans[168+M]=280+M;for(M=0;M<112;++M)g.trans[176+M]=144+M;for(M=0;M<5;++M)R.table[M]=0;for(R.table[5]=32,M=0;M<32;++M)R.trans[M]=M}var C=new Uint16Array(16);function m(g,R,M,F){var L,G;for(L=0;L<16;++L)g.table[L]=0;for(L=0;L<F;++L)g.table[R[M+L]]++;for(g.table[0]=0,G=0,L=0;L<16;++L)C[L]=G,G+=g.table[L];for(L=0;L<F;++L)R[M+L]&&(g.trans[C[R[M+L]]++]=L)}function y(g){g.bitcount--||(g.tag=g.source[g.sourceIndex++],g.bitcount=7);var R=g.tag&1;return g.tag>>>=1,R}function E(g,R,M){if(!R)return M;for(;g.bitcount<24;)g.tag|=g.source[g.sourceIndex++]<<g.bitcount,g.bitcount+=8;var F=g.tag&65535>>>16-R;return g.tag>>>=R,g.bitcount-=R,F+M}function I(g,R){for(;g.bitcount<24;)g.tag|=g.source[g.sourceIndex++]<<g.bitcount,g.bitcount+=8;var M=0,F=0,L=0,G=g.tag;do F=2*F+(G&1),G>>>=1,++L,M+=R.table[L],F-=R.table[L];while(F>=0);return g.tag=G,g.bitcount-=L,R.trans[M+F]}function S(g,R,M){var F,L,G,N,v,w;for(F=E(g,5,257),L=E(g,5,1),G=E(g,4,4),N=0;N<19;++N)p[N]=0;for(N=0;N<G;++N){var b=E(g,3,0);p[u[N]]=b}for(m(f,p,0,19),v=0;v<F+L;){var T=I(g,f);switch(T){case 16:var P=p[v-1];for(w=E(g,2,3);w;--w)p[v++]=P;break;case 17:for(w=E(g,3,3);w;--w)p[v++]=0;break;case 18:for(w=E(g,7,11);w;--w)p[v++]=0;break;default:p[v++]=T;break}}m(R,p,0,F),m(M,p,F,L)}function k(g,R,M){for(;;){var F=I(g,R);if(F===256)return n;if(F<256)g.dest[g.destLen++]=F;else{var L,G,N,v;for(F-=257,L=E(g,r[F],l[F]),G=I(g,M),N=g.destLen-E(g,a[G],c[G]),v=N;v<N+L;++v)g.dest[g.destLen++]=g.dest[v]}}}function B(g){for(var R,M,F;g.bitcount>8;)g.sourceIndex--,g.bitcount-=8;if(R=g.source[g.sourceIndex+1],R=256*R+g.source[g.sourceIndex],M=g.source[g.sourceIndex+3],M=256*M+g.source[g.sourceIndex+2],R!==(~M&65535))return e;for(g.sourceIndex+=4,F=R;F;--F)g.dest[g.destLen++]=g.source[g.sourceIndex++];return g.bitcount=0,n}function x(g,R){var M=new i(g,R),F,L,G;do{switch(F=y(M),L=E(M,2,0),L){case 0:G=B(M);break;case 1:G=k(M,s,o);break;case 2:S(M,M.ltree,M.dtree),G=k(M,M.ltree,M.dtree);break;default:G=e}if(G!==n)throw new Error("Data error")}while(!F);return M.destLen<M.dest.length?typeof M.dest.slice=="function"?M.dest.slice(0,M.destLen):M.dest.subarray(0,M.destLen):M.dest}return A(s,o),h(r,l,4,3),h(a,c,2,1),r[28]=0,l[28]=258,Hs=x,Hs}var Jg=Xg();const Zg=nn(Jg);function sn(n,e,t,i,s){return Math.pow(1-s,3)*n+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*t+Math.pow(s,3)*i}function Ct(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}Ct.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},Ct.prototype.addPoint=function(n,e){typeof n=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=n,this.x2=n),n<this.x1&&(this.x1=n),n>this.x2&&(this.x2=n)),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))},Ct.prototype.addX=function(n){this.addPoint(n,null)},Ct.prototype.addY=function(n){this.addPoint(null,n)},Ct.prototype.addBezier=function(n,e,t,i,s,o,r,l){const a=[n,e],c=[t,i],u=[s,o],f=[r,l];this.addPoint(n,e),this.addPoint(r,l);for(let p=0;p<=1;p++){const h=6*a[p]-12*c[p]+6*u[p],A=-3*a[p]+9*c[p]-9*u[p]+3*f[p],C=3*c[p]-3*a[p];if(A===0){if(h===0)continue;const I=-C/h;0<I&&I<1&&(p===0&&this.addX(sn(a[p],c[p],u[p],f[p],I)),p===1&&this.addY(sn(a[p],c[p],u[p],f[p],I)));continue}const m=Math.pow(h,2)-4*C*A;if(m<0)continue;const y=(-h+Math.sqrt(m))/(2*A);0<y&&y<1&&(p===0&&this.addX(sn(a[p],c[p],u[p],f[p],y)),p===1&&this.addY(sn(a[p],c[p],u[p],f[p],y)));const E=(-h-Math.sqrt(m))/(2*A);0<E&&E<1&&(p===0&&this.addX(sn(a[p],c[p],u[p],f[p],E)),p===1&&this.addY(sn(a[p],c[p],u[p],f[p],E)))}},Ct.prototype.addQuad=function(n,e,t,i,s,o){const r=n+.6666666666666666*(t-n),l=e+2/3*(i-e),a=r+1/3*(s-n),c=l+1/3*(o-e);this.addBezier(n,e,r,l,a,c,s,o)};function Ie(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}Ie.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})},Ie.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})},Ie.prototype.curveTo=Ie.prototype.bezierCurveTo=function(n,e,t,i,s,o){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:o})},Ie.prototype.quadTo=Ie.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})},Ie.prototype.close=Ie.prototype.closePath=function(){this.commands.push({type:"Z"})},Ie.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Ct){const e=n;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,n)},Ie.prototype.getBoundingBox=function(){const n=new Ct;let e=0,t=0,i=0,s=0;for(let o=0;o<this.commands.length;o++){const r=this.commands[o];switch(r.type){case"M":n.addPoint(r.x,r.y),e=i=r.x,t=s=r.y;break;case"L":n.addPoint(r.x,r.y),i=r.x,s=r.y;break;case"Q":n.addQuad(i,s,r.x1,r.y1,r.x,r.y),i=r.x,s=r.y;break;case"C":n.addBezier(i,s,r.x1,r.y1,r.x2,r.y2,r.x,r.y),i=r.x,s=r.y;break;case"Z":i=e,s=t;break;default:throw new Error("Unexpected path command "+r.type)}}return n.isEmpty()&&n.addPoint(0,0),n},Ie.prototype.draw=function(n){n.beginPath();for(let e=0;e<this.commands.length;e+=1){const t=this.commands[e];t.type==="M"?n.moveTo(t.x,t.y):t.type==="L"?n.lineTo(t.x,t.y):t.type==="C"?n.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):t.type==="Q"?n.quadraticCurveTo(t.x1,t.y1,t.x,t.y):t.type==="Z"&&n.closePath()}this.fill&&(n.fillStyle=this.fill,n.fill()),this.stroke&&(n.strokeStyle=this.stroke,n.lineWidth=this.strokeWidth,n.stroke())},Ie.prototype.toPathData=function(n){n=n!==void 0?n:2;function e(s){return Math.round(s)===s?""+Math.round(s):s.toFixed(n)}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 i="";for(let s=0;s<this.commands.length;s+=1){const o=this.commands[s];o.type==="M"?i+="M"+t(o.x,o.y):o.type==="L"?i+="L"+t(o.x,o.y):o.type==="C"?i+="C"+t(o.x1,o.y1,o.x2,o.y2,o.x,o.y):o.type==="Q"?i+="Q"+t(o.x1,o.y1,o.x,o.y):o.type==="Z"&&(i+="Z")}return i},Ie.prototype.toSVG=function(n){let e='<path d="';return e+=this.toPathData(n),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},Ie.prototype.toDOMElement=function(n){const e=this.toPathData(n),t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",e),t};function Na(n){throw new Error(n)}function Ua(n,e){n||Na(e)}const ie={fail:Na,argument:Ua,assert:Ua},_a=32768,Qa=2147483648,on={},j={},te={};function Ge(n){return function(){return n}}j.BYTE=function(n){return ie.argument(n>=0&&n<=255,"Byte value should be between 0 and 255."),[n]},te.BYTE=Ge(1),j.CHAR=function(n){return[n.charCodeAt(0)]},te.CHAR=Ge(1),j.CHARARRAY=function(n){const e=[];for(let t=0;t<n.length;t+=1)e[t]=n.charCodeAt(t);return e},te.CHARARRAY=function(n){return n.length},j.USHORT=function(n){return[n>>8&255,n&255]},te.USHORT=Ge(2),j.SHORT=function(n){return n>=_a&&(n=-(2*_a-n)),[n>>8&255,n&255]},te.SHORT=Ge(2),j.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]},te.UINT24=Ge(3),j.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]},te.ULONG=Ge(4),j.LONG=function(n){return n>=Qa&&(n=-(2*Qa-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]},te.LONG=Ge(4),j.FIXED=j.ULONG,te.FIXED=te.ULONG,j.FWORD=j.SHORT,te.FWORD=te.SHORT,j.UFWORD=j.USHORT,te.UFWORD=te.USHORT,j.LONGDATETIME=function(n){return[0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255]},te.LONGDATETIME=Ge(8),j.TAG=function(n){return ie.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]},te.TAG=Ge(4),j.Card8=j.BYTE,te.Card8=te.BYTE,j.Card16=j.USHORT,te.Card16=te.USHORT,j.OffSize=j.BYTE,te.OffSize=te.BYTE,j.SID=j.USHORT,te.SID=te.USHORT,j.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?j.NUMBER16(n):j.NUMBER32(n)},te.NUMBER=function(n){return j.NUMBER(n).length},j.NUMBER16=function(n){return[28,n>>8&255,n&255]},te.NUMBER16=Ge(3),j.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]},te.NUMBER32=Ge(5),j.REAL=function(n){let e=n.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(n*o)/o).toString()}let i="";for(let o=0,r=e.length;o<r;o+=1){const l=e[o];l==="e"?i+=e[++o]==="-"?"c":"b":l==="."?i+="a":l==="-"?i+="e":i+=l}i+=i.length&1?"f":"ff";const s=[30];for(let o=0,r=i.length;o<r;o+=2)s.push(parseInt(i.substr(o,2),16));return s},te.REAL=function(n){return j.REAL(n).length},j.NAME=j.CHARARRAY,te.NAME=te.CHARARRAY,j.STRING=j.CHARARRAY,te.STRING=te.CHARARRAY,on.UTF8=function(n,e,t){const i=[],s=t;for(let o=0;o<s;o++,e+=1)i[o]=n.getUint8(e);return String.fromCharCode.apply(null,i)},on.UTF16=function(n,e,t){const i=[],s=t/2;for(let o=0;o<s;o++,e+=2)i[o]=n.getUint16(e);return String.fromCharCode.apply(null,i)},j.UTF16=function(n){const e=[];for(let t=0;t<n.length;t+=1){const i=n.charCodeAt(t);e[e.length]=i>>8&255,e[e.length]=i&255}return e},te.UTF16=function(n){return n.length*2};const Gs={"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":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};on.MACSTRING=function(n,e,t,i){const s=Gs[i];if(s===void 0)return;let o="";for(let r=0;r<t;r++){const l=n.getUint8(e+r);l<=127?o+=String.fromCharCode(l):o+=s[l&127]}return o};const mi=typeof WeakMap=="function"&&new WeakMap;let Ai;const em=function(n){if(!Ai){Ai={};for(let s in Gs)Ai[s]=new String(s)}const e=Ai[n];if(e===void 0)return;if(mi){const s=mi.get(e);if(s!==void 0)return s}const t=Gs[n];if(t===void 0)return;const i={};for(let s=0;s<t.length;s++)i[t.charCodeAt(s)]=s+128;return mi&&mi.set(e,i),i};j.MACSTRING=function(n,e){const t=em(e);if(t===void 0)return;const i=[];for(let s=0;s<n.length;s++){let o=n.charCodeAt(s);if(o>=128&&(o=t[o],o===void 0))return;i[s]=o}return i},te.MACSTRING=function(n,e){const t=j.MACSTRING(n,e);return t!==void 0?t.length:0};function Ys(n){return n>=-128&&n<=127}function tm(n,e,t){let i=0;const s=n.length;for(;e<s&&i<64&&n[e]===0;)++e,++i;return t.push(128|i-1),e}function nm(n,e,t){let i=0;const s=n.length;let o=e;for(;o<s&&i<64;){const r=n[o];if(!Ys(r)||r===0&&o+1<s&&n[o+1]===0)break;++o,++i}t.push(i-1);for(let r=e;r<o;++r)t.push(n[r]+256&255);return o}function im(n,e,t){let i=0;const s=n.length;let o=e;for(;o<s&&i<64;){const r=n[o];if(r===0||Ys(r)&&o+1<s&&Ys(n[o+1]))break;++o,++i}t.push(64|i-1);for(let r=e;r<o;++r){const l=n[r];t.push(l+65536>>8&255,l+256&255)}return o}j.VARDELTAS=function(n){let e=0;const t=[];for(;e<n.length;){const i=n[e];i===0?e=tm(n,e,t):i>=-128&&i<=127?e=nm(n,e,t):e=im(n,e,t)}return t},j.INDEX=function(n){let e=1;const t=[e],i=[];for(let l=0;l<n.length;l+=1){const a=j.OBJECT(n[l]);Array.prototype.push.apply(i,a),e+=a.length,t.push(e)}if(i.length===0)return[0,0];const s=[],o=1+Math.floor(Math.log(e)/Math.log(2))/8|0,r=[void 0,j.BYTE,j.USHORT,j.UINT24,j.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(j.Card16(n.length),j.OffSize(o),s,i)},te.INDEX=function(n){return j.INDEX(n).length},j.DICT=function(n){let e=[];const t=Object.keys(n),i=t.length;for(let s=0;s<i;s+=1){const o=parseInt(t[s],0),r=n[o];e=e.concat(j.OPERAND(r.value,r.type)),e=e.concat(j.OPERATOR(o))}return e},te.DICT=function(n){return j.DICT(n).length},j.OPERATOR=function(n){return n<1200?[n]:[12,n-1200]},j.OPERAND=function(n,e){let t=[];if(Array.isArray(e))for(let i=0;i<e.length;i+=1)ie.argument(n.length===e.length,"Not enough arguments given for type"+e),t=t.concat(j.OPERAND(n[i],e[i]));else if(e==="SID")t=t.concat(j.NUMBER(n));else if(e==="offset")t=t.concat(j.NUMBER32(n));else if(e==="number")t=t.concat(j.NUMBER(n));else if(e==="real")t=t.concat(j.REAL(n));else throw new Error("Unknown operand type "+e);return t},j.OP=j.BYTE,te.OP=te.BYTE;const yi=typeof WeakMap=="function"&&new WeakMap;j.CHARSTRING=function(n){if(yi){const i=yi.get(n);if(i!==void 0)return i}let e=[];const t=n.length;for(let i=0;i<t;i+=1){const s=n[i];e=e.concat(j[s.type](s.value))}return yi&&yi.set(n,e),e},te.CHARSTRING=function(n){return j.CHARSTRING(n).length},j.OBJECT=function(n){const e=j[n.type];return ie.argument(e!==void 0,"No encoding function for type "+n.type),e(n.value)},te.OBJECT=function(n){const e=te[n.type];return ie.argument(e!==void 0,"No sizeOf function for type "+n.type),e(n.value)},j.TABLE=function(n){let e=[];const t=n.fields.length,i=[],s=[];for(let o=0;o<t;o+=1){const r=n.fields[o],l=j[r.type];ie.argument(l!==void 0,"No encoding function for field type "+r.type+" ("+r.name+")");let a=n[r.name];a===void 0&&(a=r.value);const c=l(a);r.type==="TABLE"?(s.push(e.length),e=e.concat([0,0]),i.push(c)):e=e.concat(c)}for(let o=0;o<i.length;o+=1){const r=s[o],l=e.length;ie.argument(l<65536,"Table "+n.tableName+" too big."),e[r]=l>>8,e[r+1]=l&255,e=e.concat(i[o])}return e},te.TABLE=function(n){let e=0;const t=n.fields.length;for(let i=0;i<t;i+=1){const s=n.fields[i],o=te[s.type];ie.argument(o!==void 0,"No sizeOf function for field type "+s.type+" ("+s.name+")");let r=n[s.name];r===void 0&&(r=s.value),e+=o(r),s.type==="TABLE"&&(e+=2)}return e},j.RECORD=j.TABLE,te.RECORD=te.TABLE,j.LITERAL=function(n){return n},te.LITERAL=function(n){return n.length};function ke(n,e,t){for(let i=0;i<e.length;i+=1){const s=e[i];this[s.name]=s.value}if(this.tableName=n,this.fields=e,t){const i=Object.keys(t);for(let s=0;s<i.length;s+=1){const o=i[s],r=t[o];this[o]!==void 0&&(this[o]=r)}}}ke.prototype.encode=function(){return j.TABLE(this)},ke.prototype.sizeOf=function(){return te.TABLE(this)};function Mn(n,e,t){t===void 0&&(t=e.length);const i=new Array(e.length+1);i[0]={name:n+"Count",type:"USHORT",value:t};for(let s=0;s<e.length;s++)i[s+1]={name:n+s,type:"USHORT",value:e[s]};return i}function Vs(n,e,t){const i=e.length,s=new Array(i+1);s[0]={name:n+"Count",type:"USHORT",value:i};for(let o=0;o<i;o++)s[o+1]={name:n+o,type:"TABLE",value:t(e[o],o)};return s}function Ci(n,e,t){const i=e.length;let s=[];s[0]={name:n+"Count",type:"USHORT",value:i};for(let o=0;o<i;o++)s=s.concat(t(e[o],o));return s}function Ei(n){n.format===1?ke.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Mn("glyph",n.glyphs))):ie.assert(!1,"Can't create coverage table format 2 yet.")}Ei.prototype=Object.create(ke.prototype),Ei.prototype.constructor=Ei;function wi(n){ke.call(this,"scriptListTable",Ci("scriptRecord",n,function(e,t){const i=e.script;let s=i.defaultLangSys;return ie.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 ke("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new ke("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(Mn("featureIndex",s.featureIndexes)))}].concat(Ci("langSys",i.langSysRecords,function(o,r){const l=o.langSys;return[{name:"langSysTag"+r,type:"TAG",value:o.tag},{name:"langSys"+r,type:"TABLE",value:new ke("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:l.reqFeatureIndex}].concat(Mn("featureIndex",l.featureIndexes)))}]})))}]}))}wi.prototype=Object.create(ke.prototype),wi.prototype.constructor=wi;function bi(n){ke.call(this,"featureListTable",Ci("featureRecord",n,function(e,t){const i=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new ke("featureTable",[{name:"featureParams",type:"USHORT",value:i.featureParams}].concat(Mn("lookupListIndex",i.lookupListIndexes)))}]}))}bi.prototype=Object.create(ke.prototype),bi.prototype.constructor=bi;function vi(n,e){ke.call(this,"lookupListTable",Vs("lookup",n,function(t){let i=e[t.lookupType];return ie.assert(!!i,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new ke("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(Vs("subtable",t.subtables,i)))}))}vi.prototype=Object.create(ke.prototype),vi.prototype.constructor=vi;const Z={Table:ke,Record:ke,Coverage:Ei,ScriptList:wi,FeatureList:bi,LookupList:vi,ushortList:Mn,tableList:Vs,recordList:Ci};function Ha(n,e){return n.getUint8(e)}function Ii(n,e){return n.getUint16(e,!1)}function sm(n,e){return n.getInt16(e,!1)}function Ws(n,e){return n.getUint32(e,!1)}function Ga(n,e){const t=n.getInt16(e,!1),i=n.getUint16(e+2,!1);return t+i/65535}function om(n,e){let t="";for(let i=e;i<e+4;i+=1)t+=String.fromCharCode(n.getInt8(i));return t}function rm(n,e,t){let i=0;for(let s=0;s<t;s+=1)i<<=8,i+=n.getUint8(e+s);return i}function am(n,e,t){const i=[];for(let s=e;s<t;s+=1)i.push(n.getUint8(s));return i}function lm(n){let e="";for(let t=0;t<n.length;t+=1)e+=String.fromCharCode(n[t]);return e}const cm={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function H(n,e){this.data=n,this.offset=e,this.relativeOffset=0}H.prototype.parseByte=function(){const n=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n},H.prototype.parseChar=function(){const n=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n},H.prototype.parseCard8=H.prototype.parseByte,H.prototype.parseUShort=function(){const n=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n},H.prototype.parseCard16=H.prototype.parseUShort,H.prototype.parseSID=H.prototype.parseUShort,H.prototype.parseOffset16=H.prototype.parseUShort,H.prototype.parseShort=function(){const n=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n},H.prototype.parseF2Dot14=function(){const n=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,n},H.prototype.parseULong=function(){const n=Ws(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n},H.prototype.parseOffset32=H.prototype.parseULong,H.prototype.parseFixed=function(){const n=Ga(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n},H.prototype.parseString=function(n){const e=this.data,t=this.offset+this.relativeOffset;let i="";this.relativeOffset+=n;for(let s=0;s<n;s++)i+=String.fromCharCode(e.getUint8(t+s));return i},H.prototype.parseTag=function(){return this.parseString(4)},H.prototype.parseLongDateTime=function(){let n=Ws(this.data,this.offset+this.relativeOffset+4);return n-=2082844800,this.relativeOffset+=8,n},H.prototype.parseVersion=function(n){const e=Ii(this.data,this.offset+this.relativeOffset),t=Ii(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,n===void 0&&(n=4096),e+t/n/10},H.prototype.skip=function(n,e){e===void 0&&(e=1),this.relativeOffset+=cm[n]*e},H.prototype.parseULongList=function(n){n===void 0&&(n=this.parseULong());const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getUint32(i),i+=4;return this.relativeOffset+=n*4,e},H.prototype.parseOffset16List=H.prototype.parseUShortList=function(n){n===void 0&&(n=this.parseUShort());const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getUint16(i),i+=2;return this.relativeOffset+=n*2,e},H.prototype.parseShortList=function(n){const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getInt16(i),i+=2;return this.relativeOffset+=n*2,e},H.prototype.parseByteList=function(n){const e=new Array(n),t=this.data;let i=this.offset+this.relativeOffset;for(let s=0;s<n;s++)e[s]=t.getUint8(i++);return this.relativeOffset+=n,e},H.prototype.parseList=function(n,e){e||(e=n,n=this.parseUShort());const t=new Array(n);for(let i=0;i<n;i++)t[i]=e.call(this);return t},H.prototype.parseList32=function(n,e){e||(e=n,n=this.parseULong());const t=new Array(n);for(let i=0;i<n;i++)t[i]=e.call(this);return t},H.prototype.parseRecordList=function(n,e){e||(e=n,n=this.parseUShort());const t=new Array(n),i=Object.keys(e);for(let s=0;s<n;s++){const o={};for(let r=0;r<i.length;r++){const l=i[r],a=e[l];o[l]=a.call(this)}t[s]=o}return t},H.prototype.parseRecordList32=function(n,e){e||(e=n,n=this.parseULong());const t=new Array(n),i=Object.keys(e);for(let s=0;s<n;s++){const o={};for(let r=0;r<i.length;r++){const l=i[r],a=e[l];o[l]=a.call(this)}t[s]=o}return t},H.prototype.parseStruct=function(n){if(typeof n=="function")return n.call(this);{const e=Object.keys(n),t={};for(let i=0;i<e.length;i++){const s=e[i],o=n[s];t[s]=o.call(this)}return t}},H.prototype.parseValueRecord=function(n){if(n===void 0&&(n=this.parseUShort()),n===0)return;const e={};return n&1&&(e.xPlacement=this.parseShort()),n&2&&(e.yPlacement=this.parseShort()),n&4&&(e.xAdvance=this.parseShort()),n&8&&(e.yAdvance=this.parseShort()),n&16&&(e.xPlaDevice=void 0,this.parseShort()),n&32&&(e.yPlaDevice=void 0,this.parseShort()),n&64&&(e.xAdvDevice=void 0,this.parseShort()),n&128&&(e.yAdvDevice=void 0,this.parseShort()),e},H.prototype.parseValueRecordList=function(){const n=this.parseUShort(),e=this.parseUShort(),t=new Array(e);for(let i=0;i<e;i++)t[i]=this.parseValueRecord(n);return t},H.prototype.parsePointer=function(n){const e=this.parseOffset16();if(e>0)return new H(this.data,this.offset+e).parseStruct(n)},H.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new H(this.data,this.offset+e).parseStruct(n)},H.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=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,n){const l=this.parseOffset16List(),a=new Array(l.length);for(let c=0;c<l.length;c++)this.relativeOffset=r+l[c],a[c]=n.call(this);s[o]=a}else s[o]=this.parseUShortList()}return this.relativeOffset=i,s},H.prototype.parseCoverage=function(){const n=this.offset+this.relativeOffset,e=this.parseUShort(),t=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(t)};if(e===2){const i=new Array(t);for(let s=0;s<t;s++)i[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:i}}throw new Error("0x"+n.toString(16)+": Coverage format must be 1 or 2.")},H.prototype.parseClassDef=function(){const n=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:H.uShort,end:H.uShort,classId:H.uShort})};throw new Error("0x"+n.toString(16)+": ClassDef format must be 1 or 2.")},H.list=function(n,e){return function(){return this.parseList(n,e)}},H.list32=function(n,e){return function(){return this.parseList32(n,e)}},H.recordList=function(n,e){return function(){return this.parseRecordList(n,e)}},H.recordList32=function(n,e){return function(){return this.parseRecordList32(n,e)}},H.pointer=function(n){return function(){return this.parsePointer(n)}},H.pointer32=function(n){return function(){return this.parsePointer32(n)}},H.tag=H.prototype.parseTag,H.byte=H.prototype.parseByte,H.uShort=H.offset16=H.prototype.parseUShort,H.uShortList=H.prototype.parseUShortList,H.uLong=H.offset32=H.prototype.parseULong,H.uLongList=H.prototype.parseULongList,H.struct=H.prototype.parseStruct,H.coverage=H.prototype.parseCoverage,H.classDef=H.prototype.parseClassDef;const Ya={reserved:H.uShort,reqFeatureIndex:H.uShort,featureIndexes:H.uShortList};H.prototype.parseScriptList=function(){return this.parsePointer(H.recordList({tag:H.tag,script:H.pointer({defaultLangSys:H.pointer(Ya),langSysRecords:H.recordList({tag:H.tag,langSys:H.pointer(Ya)})})}))||[]},H.prototype.parseFeatureList=function(){return this.parsePointer(H.recordList({tag:H.tag,feature:H.pointer({featureParams:H.offset16,lookupListIndexes:H.uShortList})}))||[]},H.prototype.parseLookupList=function(n){return this.parsePointer(H.list(H.pointer(function(){const e=this.parseUShort();ie.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");const t=this.parseUShort(),i=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(H.pointer(n[e])),markFilteringSet:i?this.parseUShort():void 0}})))||[]},H.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){const n=this.parseUShort(),e=this.parseUShort();return ie.argument(n===1&&e<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:H.offset32,featureTableSubstitutionOffset:H.offset32})})||[]};const q={getByte:Ha,getCard8:Ha,getUShort:Ii,getCard16:Ii,getShort:sm,getULong:Ws,getFixed:Ga,getTag:om,getOffset:rm,getBytes:am,bytesToString:lm,Parser:H};function dm(n,e){e.parseUShort(),n.length=e.parseULong(),n.language=e.parseULong();let t;n.groupCount=t=e.parseULong(),n.glyphIndexMap={};for(let i=0;i<t;i+=1){const s=e.parseULong(),o=e.parseULong();let r=e.parseULong();for(let l=s;l<=o;l+=1)n.glyphIndexMap[l]=r,r++}}function um(n,e,t,i,s){n.length=e.parseUShort(),n.language=e.parseUShort();let o;n.segCount=o=e.parseUShort()>>1,e.skip("uShort",3),n.glyphIndexMap={};const r=new q.Parser(t,i+s+14),l=new q.Parser(t,i+s+16+o*2),a=new q.Parser(t,i+s+16+o*4),c=new q.Parser(t,i+s+16+o*6);let u=i+s+16+o*8;for(let f=0;f<o-1;f+=1){let p;const h=r.parseUShort(),A=l.parseUShort(),C=a.parseShort(),m=c.parseUShort();for(let y=A;y<=h;y+=1)m!==0?(u=c.offset+c.relativeOffset-2,u+=m,u+=(y-A)*2,p=q.getUShort(t,u),p!==0&&(p=p+C&65535)):p=y+C&65535,n.glyphIndexMap[y]=p}}function hm(n,e){const t={};t.version=q.getUShort(n,e),ie.argument(t.version===0,"cmap table version should be 0."),t.numTables=q.getUShort(n,e+2);let i=-1;for(let o=t.numTables-1;o>=0;o-=1){const r=q.getUShort(n,e+4+o*8),l=q.getUShort(n,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)){i=q.getULong(n,e+4+o*8+4);break}}if(i===-1)throw new Error("No valid cmap sub-tables found.");const s=new q.Parser(n,e+i);if(t.format=s.parseUShort(),t.format===12)dm(t,s);else if(t.format===4)um(t,s,n,e,i);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+t.format+").");return t}function fm(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function pm(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function gm(n){let e=!0,t;for(t=n.length-1;t>0;t-=1)if(n.get(t).unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}let i=[{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||(i=i.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),i=i.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 Z.Table("cmap",i);for(s.segments=[],t=0;t<n.length;t+=1){const h=n.get(t);for(let A=0;A<h.unicodes.length;A+=1)fm(s,h.unicodes[A],t);s.segments=s.segments.sort(function(A,C){return A.start-C.start})}pm(s);const o=s.segments.length;let r=0,l=[],a=[],c=[],u=[],f=[],p=[];for(t=0;t<o;t+=1){const h=s.segments[t];h.end<=65535&&h.start<=65535?(l=l.concat({name:"end_"+t,type:"USHORT",value:h.end}),a=a.concat({name:"start_"+t,type:"USHORT",value:h.start}),c=c.concat({name:"idDelta_"+t,type:"SHORT",value:h.delta}),u=u.concat({name:"idRangeOffset_"+t,type:"USHORT",value:h.offset}),h.glyphId!==void 0&&(f=f.concat({name:"glyph_"+t,type:"USHORT",value:h.glyphId}))):r+=1,!e&&h.glyphIndex!==void 0&&(p=p.concat({name:"cmap12Start_"+t,type:"ULONG",value:h.start}),p=p.concat({name:"cmap12End_"+t,type:"ULONG",value:h.end}),p=p.concat({name:"cmap12Glyph_"+t,type:"ULONG",value:h.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(c),s.fields=s.fields.concat(u),s.fields=s.fields.concat(f),s.cmap4Length=14+l.length*2+2+a.length*2+c.length*2+u.length*2+f.length*2,!e){const h=16+p.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:h},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:p.length/3}]),s.fields=s.fields.concat(p)}return s}const Va={parse:hm,make:gm},xi=[".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"],mm=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Am=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Ft=[".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 Wa(n){this.font=n}Wa.prototype.charToGlyphIndex=function(n){const e=n.codePointAt(0),t=this.font.glyphs;if(t)for(let i=0;i<t.length;i+=1){const s=t.get(i);for(let o=0;o<s.unicodes.length;o+=1)if(s.unicodes[o]===e)return i}return null};function za(n){this.cmap=n}za.prototype.charToGlyphIndex=function(n){return this.cmap.glyphIndexMap[n.codePointAt(0)]||0};function Bi(n,e){this.encoding=n,this.charset=e}Bi.prototype.charToGlyphIndex=function(n){const e=n.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function zs(n){switch(n.version){case 1:this.names=Ft.slice();break;case 2:this.names=new Array(n.numberOfGlyphs);for(let e=0;e<n.numberOfGlyphs;e++)n.glyphNameIndex[e]<Ft.length?this.names[e]=Ft[n.glyphNameIndex[e]]:this.names[e]=n.names[n.glyphNameIndex[e]-Ft.length];break;case 2.5:this.names=new Array(n.numberOfGlyphs);for(let e=0;e<n.numberOfGlyphs;e++)this.names[e]=Ft[e+n.glyphNameIndex[e]];break;case 3:this.names=[];break;default:this.names=[];break}}zs.prototype.nameToGlyphIndex=function(n){return this.names.indexOf(n)},zs.prototype.glyphIndexToName=function(n){return this.names[n]};function ym(n){let e;const t=n.tables.cmap.glyphIndexMap,i=Object.keys(t);for(let s=0;s<i.length;s+=1){const o=i[s],r=t[o];e=n.glyphs.get(r),e.addUnicode(parseInt(o))}for(let s=0;s<n.glyphs.length;s+=1)e=n.glyphs.get(s),n.cffEncoding?n.isCIDFont?e.name="gid"+s:e.name=n.cffEncoding.charset[s]:n.glyphNames.names&&(e.name=n.glyphNames.glyphIndexToName(s))}function Cm(n,e,t,i,s){n.beginPath(),n.moveTo(e,t),n.lineTo(i,s),n.stroke()}const Rt={line:Cm};function Em(n,e){let t=e||new Ie;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function Qe(n){this.bindConstructorValues(n)}Qe.prototype.bindConstructorValues=function(n){this.index=n.index||0,this.name=n.name||null,this.unicode=n.unicode||void 0,this.unicodes=n.unicodes||n.unicode!==void 0?[n.unicode]:[],n.xMin&&(this.xMin=n.xMin),n.yMin&&(this.yMin=n.yMin),n.xMax&&(this.xMax=n.xMax),n.yMax&&(this.yMax=n.yMax),n.advanceWidth&&(this.advanceWidth=n.advanceWidth),Object.defineProperty(this,"path",Em(this,n.path))},Qe.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)},Qe.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},Qe.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72;let o,r;i||(i={});let l=i.xScale,a=i.yScale;if(i.hinting&&s&&s.hinting&&(r=this.path&&s.hinting.exec(this,t)),r)o=s.hinting.getCommands(r),n=Math.round(n),e=Math.round(e),l=a=1;else{o=this.path.commands;const u=1/this.path.unitsPerEm*t;l===void 0&&(l=u),a===void 0&&(a=u)}const c=new Ie;for(let u=0;u<o.length;u+=1){const f=o[u];f.type==="M"?c.moveTo(n+f.x*l,e+-f.y*a):f.type==="L"?c.lineTo(n+f.x*l,e+-f.y*a):f.type==="Q"?c.quadraticCurveTo(n+f.x1*l,e+-f.y1*a,n+f.x*l,e+-f.y*a):f.type==="C"?c.curveTo(n+f.x1*l,e+-f.y1*a,n+f.x2*l,e+-f.y2*a,n+f.x*l,e+-f.y*a):f.type==="Z"&&c.closePath()}return c},Qe.prototype.getContours=function(){if(this.points===void 0)return[];const n=[];let e=[];for(let t=0;t<this.points.length;t+=1){const i=this.points[t];e.push(i),i.lastPointOfContour&&(n.push(e),e=[])}return ie.argument(e.length===0,"There are still points left in the current contour."),n},Qe.prototype.getMetrics=function(){const n=this.path.commands,e=[],t=[];for(let s=0;s<n.length;s+=1){const o=n[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 i={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(i.xMin)||(i.xMin=0),isFinite(i.xMax)||(i.xMax=this.advanceWidth),isFinite(i.yMin)||(i.yMin=0),isFinite(i.yMax)||(i.yMax=0),i.rightSideBearing=this.advanceWidth-i.leftSideBearing-(i.xMax-i.xMin),i},Qe.prototype.draw=function(n,e,t,i,s){this.getPath(e,t,i,s).draw(n)},Qe.prototype.drawPoints=function(n,e,t,i){function s(c,u,f,p){const h=Math.PI*2;n.beginPath();for(let A=0;A<c.length;A+=1)n.moveTo(u+c[A].x*p,f+c[A].y*p),n.arc(u+c[A].x*p,f+c[A].y*p,2,0,h,!1);n.closePath(),n.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,i=i!==void 0?i:24;const o=1/this.path.unitsPerEm*i,r=[],l=[],a=this.path;for(let c=0;c<a.commands.length;c+=1){const u=a.commands[c];u.x!==void 0&&r.push({x:u.x,y:-u.y}),u.x1!==void 0&&l.push({x:u.x1,y:-u.y1}),u.x2!==void 0&&l.push({x:u.x2,y:-u.y2})}n.fillStyle="blue",s(r,e,t,o),n.fillStyle="red",s(l,e,t,o)},Qe.prototype.drawMetrics=function(n,e,t,i){let s;e=e!==void 0?e:0,t=t!==void 0?t:0,i=i!==void 0?i:24,s=1/this.path.unitsPerEm*i,n.lineWidth=1,n.strokeStyle="black",Rt.line(n,e,-1e4,e,1e4),Rt.line(n,-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 c=this.advanceWidth||0;n.strokeStyle="blue",Rt.line(n,e+o*s,-1e4,e+o*s,1e4),Rt.line(n,e+l*s,-1e4,e+l*s,1e4),Rt.line(n,-1e4,t+-r*s,1e4,t+-r*s),Rt.line(n,-1e4,t+-a*s,1e4,t+-a*s),n.strokeStyle="green",Rt.line(n,e+c*s,-1e4,e+c*s,1e4)};function Si(n,e,t){Object.defineProperty(n,e,{get:function(){return n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function js(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t<e.length;t++)this.glyphs[t]=e[t];this.length=e&&e.length||0}js.prototype.get=function(n){return typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]()),this.glyphs[n]},js.prototype.push=function(n,e){this.glyphs[n]=e,this.length++};function wm(n,e){return new Qe({index:e,font:n})}function bm(n,e,t,i,s,o){return function(){const r=new Qe({index:e,font:n});return r.path=function(){t(r,i,s);const l=o(n.glyphs,r);return l.unitsPerEm=n.unitsPerEm,l},Si(r,"xMin","_xMin"),Si(r,"xMax","_xMax"),Si(r,"yMin","_yMin"),Si(r,"yMax","_yMax"),r}}function vm(n,e,t,i){return function(){const s=new Qe({index:e,font:n});return s.path=function(){const o=t(n,s,i);return o.unitsPerEm=n.unitsPerEm,o},s}}const rn={GlyphSet:js,glyphLoader:wm,ttfGlyphLoader:bm,cffGlyphLoader:vm};function ja(n,e){if(n===e)return!0;if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t+=1)if(!ja(n[t],e[t]))return!1;return!0}else return!1}function $s(n){let e;return n.length<1240?e=107:n.length<33900?e=1131:e=32768,e}function Et(n,e,t){const i=[],s=[],o=q.getCard16(n,e);let r,l;if(o!==0){const a=q.getByte(n,e+2);r=e+(o+1)*a+2;let c=e+3;for(let u=0;u<o+1;u+=1)i.push(q.getOffset(n,c,a)),c+=a;l=r+i[o]}else l=e+2;for(let a=0;a<i.length-1;a+=1){let c=q.getBytes(n,r+i[a],r+i[a+1]);t&&(c=t(c)),s.push(c)}return{objects:s,startOffset:e,endOffset:l}}function Im(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),o=s>>4,r=s&15;if(o===15||(e+=i[o],r===15))break;e+=i[r]}return parseFloat(e)}function xm(n,e){let t,i,s,o;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),o=n.parseByte(),t<<24|i<<16|s<<8|o;if(e===30)return Im(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function Bm(n){const e={};for(let t=0;t<n.length;t+=1){const i=n[t][0],s=n[t][1];let o;if(s.length===1?o=s[0]:o=s,e.hasOwnProperty(i)&&!isNaN(e[i]))throw new Error("Object "+e+" already has key "+i);e[i]=o}return e}function $a(n,e,t){e=e!==void 0?e:0;const i=new q.Parser(n,e),s=[];let o=[];for(t=t!==void 0?t:n.length;i.relativeOffset<t;){let r=i.parseByte();r<=21?(r===12&&(r=1200+i.parseByte()),s.push([r,o]),o=[]):o.push(xm(i,r))}return Bm(s)}function Tn(n,e){return e<=390?e=xi[e]:e=n[e-391],e}function Ka(n,e,t){const i={};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=n[r.op]!==void 0?n[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=Tn(t,s)),l[a]=s;i[r.name]=l}else s=n[r.op],s===void 0&&(s=r.value!==void 0?r.value:null),r.type==="SID"&&(s=Tn(t,s)),i[r.name]=s}return i}function Sm(n,e){const t={};return t.formatMajor=q.getCard8(n,e),t.formatMinor=q.getCard8(n,e+1),t.size=q.getCard8(n,e+2),t.offsetSize=q.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4,t}const qa=[{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"}],Xa=[{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 Mm(n,e){const t=$a(n,0,n.byteLength);return Ka(t,qa,e)}function Ja(n,e,t,i){const s=$a(n,e,t);return Ka(s,Xa,i)}function Za(n,e,t,i){const s=[];for(let o=0;o<t.length;o+=1){const r=new DataView(new Uint8Array(t[o]).buffer),l=Mm(r,i);l._subrs=[],l._subrsBias=0;const a=l.private[0],c=l.private[1];if(a!==0&&c!==0){const u=Ja(n,c+e,a,i);if(l._defaultWidthX=u.defaultWidthX,l._nominalWidthX=u.nominalWidthX,u.subrs!==0){const f=c+u.subrs,p=Et(n,f+e);l._subrs=p.objects,l._subrsBias=$s(l._subrs)}l._privateDict=u}s.push(l)}return s}function Tm(n,e,t,i){let s,o;const r=new q.Parser(n,e);t-=1;const l=[".notdef"],a=r.parseCard8();if(a===0)for(let c=0;c<t;c+=1)s=r.parseSID(),l.push(Tn(i,s));else if(a===1)for(;l.length<=t;){s=r.parseSID(),o=r.parseCard8();for(let c=0;c<=o;c+=1)l.push(Tn(i,s)),s+=1}else if(a===2)for(;l.length<=t;){s=r.parseSID(),o=r.parseCard16();for(let c=0;c<=o;c+=1)l.push(Tn(i,s)),s+=1}else throw new Error("Unknown charset format "+a);return l}function Dm(n,e,t){let i;const s={},o=new q.Parser(n,e),r=o.parseCard8();if(r===0){const l=o.parseCard8();for(let a=0;a<l;a+=1)i=o.parseCard8(),s[i]=a}else if(r===1){const l=o.parseCard8();i=1;for(let a=0;a<l;a+=1){const c=o.parseCard8(),u=o.parseCard8();for(let f=c;f<=c+u;f+=1)s[f]=i,i+=1}}else throw new Error("Unknown encoding format "+r);return new Bi(s,t)}function km(n,e,t){let i,s,o,r;const l=new Ie,a=[];let c=0,u=!1,f=!1,p=0,h=0,A,C,m,y;if(n.isCIDFont){const B=n.tables.cff.topDict._fdSelect[e.index],x=n.tables.cff.topDict._fdArray[B];A=x._subrs,C=x._subrsBias,m=x._defaultWidthX,y=x._nominalWidthX}else A=n.tables.cff.topDict._subrs,C=n.tables.cff.topDict._subrsBias,m=n.tables.cff.topDict._defaultWidthX,y=n.tables.cff.topDict._nominalWidthX;let E=m;function I(B,x){f&&l.closePath(),l.moveTo(B,x),f=!0}function S(){let B;B=a.length%2!==0,B&&!u&&(E=a.shift()+y),c+=a.length>>1,a.length=0,u=!0}function k(B){let x,g,R,M,F,L,G,N,v,w,b,T,P=0;for(;P<B.length;){let _=B[P];switch(P+=1,_){case 1:S();break;case 3:S();break;case 4:a.length>1&&!u&&(E=a.shift()+y,u=!0),h+=a.pop(),I(p,h);break;case 5:for(;a.length>0;)p+=a.shift(),h+=a.shift(),l.lineTo(p,h);break;case 6:for(;a.length>0&&(p+=a.shift(),l.lineTo(p,h),a.length!==0);)h+=a.shift(),l.lineTo(p,h);break;case 7:for(;a.length>0&&(h+=a.shift(),l.lineTo(p,h),a.length!==0);)p+=a.shift(),l.lineTo(p,h);break;case 8:for(;a.length>0;)i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r+a.shift(),l.curveTo(i,s,o,r,p,h);break;case 10:F=a.pop()+C,L=A[F],L&&k(L);break;case 11:return;case 12:switch(_=B[P],P+=1,_){case 35:i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),G=o+a.shift(),N=r+a.shift(),v=G+a.shift(),w=N+a.shift(),b=v+a.shift(),T=w+a.shift(),p=b+a.shift(),h=T+a.shift(),a.shift(),l.curveTo(i,s,o,r,G,N),l.curveTo(v,w,b,T,p,h);break;case 34:i=p+a.shift(),s=h,o=i+a.shift(),r=s+a.shift(),G=o+a.shift(),N=r,v=G+a.shift(),w=r,b=v+a.shift(),T=h,p=b+a.shift(),l.curveTo(i,s,o,r,G,N),l.curveTo(v,w,b,T,p,h);break;case 36:i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),G=o+a.shift(),N=r,v=G+a.shift(),w=r,b=v+a.shift(),T=w+a.shift(),p=b+a.shift(),l.curveTo(i,s,o,r,G,N),l.curveTo(v,w,b,T,p,h);break;case 37:i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),G=o+a.shift(),N=r+a.shift(),v=G+a.shift(),w=N+a.shift(),b=v+a.shift(),T=w+a.shift(),Math.abs(b-p)>Math.abs(T-h)?p=b+a.shift():h=T+a.shift(),l.curveTo(i,s,o,r,G,N),l.curveTo(v,w,b,T,p,h);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+_),a.length=0}break;case 14:a.length>0&&!u&&(E=a.shift()+y,u=!0),f&&(l.closePath(),f=!1);break;case 18:S();break;case 19:case 20:S(),P+=c+7>>3;break;case 21:a.length>2&&!u&&(E=a.shift()+y,u=!0),h+=a.pop(),p+=a.pop(),I(p,h);break;case 22:a.length>1&&!u&&(E=a.shift()+y,u=!0),p+=a.pop(),I(p,h);break;case 23:S();break;case 24:for(;a.length>2;)i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r+a.shift(),l.curveTo(i,s,o,r,p,h);p+=a.shift(),h+=a.shift(),l.lineTo(p,h);break;case 25:for(;a.length>6;)p+=a.shift(),h+=a.shift(),l.lineTo(p,h);i=p+a.shift(),s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r+a.shift(),l.curveTo(i,s,o,r,p,h);break;case 26:for(a.length%2&&(p+=a.shift());a.length>0;)i=p,s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o,h=r+a.shift(),l.curveTo(i,s,o,r,p,h);break;case 27:for(a.length%2&&(h+=a.shift());a.length>0;)i=p+a.shift(),s=h,o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r,l.curveTo(i,s,o,r,p,h);break;case 28:x=B[P],g=B[P+1],a.push((x<<24|g<<16)>>16),P+=2;break;case 29:F=a.pop()+n.gsubrsBias,L=n.gsubrs[F],L&&k(L);break;case 30:for(;a.length>0&&(i=p,s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r+(a.length===1?a.shift():0),l.curveTo(i,s,o,r,p,h),a.length!==0);)i=p+a.shift(),s=h,o=i+a.shift(),r=s+a.shift(),h=r+a.shift(),p=o+(a.length===1?a.shift():0),l.curveTo(i,s,o,r,p,h);break;case 31:for(;a.length>0&&(i=p+a.shift(),s=h,o=i+a.shift(),r=s+a.shift(),h=r+a.shift(),p=o+(a.length===1?a.shift():0),l.curveTo(i,s,o,r,p,h),a.length!==0);)i=p,s=h+a.shift(),o=i+a.shift(),r=s+a.shift(),p=o+a.shift(),h=r+(a.length===1?a.shift():0),l.curveTo(i,s,o,r,p,h);break;default:_<32?console.log("Glyph "+e.index+": unknown operator "+_):_<247?a.push(_-139):_<251?(x=B[P],P+=1,a.push((_-247)*256+x+108)):_<255?(x=B[P],P+=1,a.push(-(_-251)*256-x-108)):(x=B[P],g=B[P+1],R=B[P+2],M=B[P+3],P+=4,a.push((x<<24|g<<16|R<<8|M)/65536))}}}return k(t),e.advanceWidth=E,l}function Pm(n,e,t,i){const s=[];let o;const r=new q.Parser(n,e),l=r.parseCard8();if(l===0)for(let a=0;a<t;a++){if(o=r.parseCard8(),o>=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+i+")");s.push(o)}else if(l===3){const a=r.parseCard16();let c=r.parseCard16();if(c!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+c);let u;for(let f=0;f<a;f++){if(o=r.parseCard8(),u=r.parseCard16(),o>=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+i+")");if(u>t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+u);for(;c<u;c++)s.push(o);c=u}if(u!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+u)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+l);return s}function Fm(n,e,t){t.tables.cff={};const i=Sm(n,e),s=Et(n,i.endOffset,q.bytesToString),o=Et(n,s.endOffset),r=Et(n,o.endOffset,q.bytesToString),l=Et(n,r.endOffset);t.gsubrs=l.objects,t.gsubrsBias=$s(t.gsubrs);const a=Za(n,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 c=a[0];if(t.tables.cff.topDict=c,c._privateDict&&(t.defaultWidthX=c._privateDict.defaultWidthX,t.nominalWidthX=c._privateDict.nominalWidthX),c.ros[0]!==void 0&&c.ros[1]!==void 0&&(t.isCIDFont=!0),t.isCIDFont){let A=c.fdArray,C=c.fdSelect;if(A===0||C===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");A+=e;const m=Et(n,A),y=Za(n,e,m.objects,r.objects);c._fdArray=y,C+=e,c._fdSelect=Pm(n,C,t.numGlyphs,y.length)}const u=e+c.private[1],f=Ja(n,u,c.private[0],r.objects);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const A=u+f.subrs,C=Et(n,A);t.subrs=C.objects,t.subrsBias=$s(t.subrs)}else t.subrs=[],t.subrsBias=0;const p=Et(n,e+c.charStrings);t.nGlyphs=p.objects.length;const h=Tm(n,e+c.charset,t.nGlyphs,r.objects);c.encoding===0?t.cffEncoding=new Bi(mm,h):c.encoding===1?t.cffEncoding=new Bi(Am,h):t.cffEncoding=Dm(n,e+c.encoding,h),t.encoding=t.encoding||t.cffEncoding,t.glyphs=new rn.GlyphSet(t);for(let A=0;A<t.nGlyphs;A+=1){const C=p.objects[A];t.glyphs.push(A,rn.cffGlyphLoader(t,A,km,C))}}function el(n,e){let t,i=xi.indexOf(n);return i>=0&&(t=i),i=e.indexOf(n),i>=0?t=i+xi.length:(t=xi.length+e.length,e.push(n)),t}function Rm(){return new Z.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 Om(n){const e=new Z.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t<n.length;t+=1)e.names.push({name:"name_"+t,type:"NAME",value:n[t]});return e}function tl(n,e,t){const i={};for(let s=0;s<n.length;s+=1){const o=n[s];let r=e[o.name];r!==void 0&&!ja(r,o.value)&&(o.type==="SID"&&(r=el(r,t)),i[o.op]={name:o.name,type:o.type,value:r})}return i}function nl(n,e){const t=new Z.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=tl(qa,n,e),t}function il(n){const e=new Z.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:n}],e}function Lm(n){const e=new Z.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(let t=0;t<n.length;t+=1)e.strings.push({name:"string_"+t,type:"STRING",value:n[t]});return e}function Nm(){return new Z.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Um(n,e){const t=new Z.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let i=0;i<n.length;i+=1){const s=n[i],o=el(s,e);t.fields.push({name:"glyph_"+i,type:"SID",value:o})}return t}function _m(n){const e=[],t=n.path;e.push({name:"width",type:"NUMBER",value:n.advanceWidth});let i=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 c=.3333333333333333,u=2/3;a={type:"C",x:a.x,y:a.y,x1:c*i+u*a.x1,y1:c*s+u*a.y1,x2:c*a.x+u*a.x1,y2:c*a.y+u*a.y1}}if(a.type==="M")r=Math.round(a.x-i),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}),i=Math.round(a.x),s=Math.round(a.y);else if(a.type==="L")r=Math.round(a.x-i),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}),i=Math.round(a.x),s=Math.round(a.y);else if(a.type==="C"){const c=Math.round(a.x1-i),u=Math.round(a.y1-s),f=Math.round(a.x2-a.x1),p=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:c}),e.push({name:"dy1",type:"NUMBER",value:u}),e.push({name:"dx2",type:"NUMBER",value:f}),e.push({name:"dy2",type:"NUMBER",value:p}),e.push({name:"dx",type:"NUMBER",value:r}),e.push({name:"dy",type:"NUMBER",value:l}),e.push({name:"rrcurveto",type:"OP",value:8}),i=Math.round(a.x),s=Math.round(a.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function Qm(n){const e=new Z.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let t=0;t<n.length;t+=1){const i=n.get(t),s=_m(i);e.charStrings.push({name:i.name,type:"CHARSTRING",value:s})}return e}function Hm(n,e){const t=new Z.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=tl(Xa,n,e),t}function Gm(n,e){const t=new Z.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"}]),i=1/e.unitsPerEm,s={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[i,0,0,i,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},o={},r=[];let l;for(let f=1;f<n.length;f+=1)l=n.get(f),r.push(l.name);const a=[];t.header=Rm(),t.nameIndex=Om([e.postScriptName]);let c=nl(s,a);t.topDictIndex=il(c),t.globalSubrIndex=Nm(),t.charsets=Um(r,a),t.charStringsIndex=Qm(n),t.privateDict=Hm(o,a),t.stringIndex=Lm(a);const u=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return s.charset=u,s.encoding=0,s.charStrings=s.charset+t.charsets.sizeOf(),s.private[1]=s.charStrings+t.charStringsIndex.sizeOf(),c=nl(s,a),t.topDictIndex=il(c),t}const sl={parse:Fm,make:Gm};function Ym(n,e){const t={},i=new q.Parser(n,e);return t.version=i.parseVersion(),t.fontRevision=Math.round(i.parseFixed()*1e3)/1e3,t.checkSumAdjustment=i.parseULong(),t.magicNumber=i.parseULong(),ie.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=i.parseUShort(),t.unitsPerEm=i.parseUShort(),t.created=i.parseLongDateTime(),t.modified=i.parseLongDateTime(),t.xMin=i.parseShort(),t.yMin=i.parseShort(),t.xMax=i.parseShort(),t.yMax=i.parseShort(),t.macStyle=i.parseUShort(),t.lowestRecPPEM=i.parseUShort(),t.fontDirectionHint=i.parseShort(),t.indexToLocFormat=i.parseShort(),t.glyphDataFormat=i.parseShort(),t}function Vm(n){const e=Math.round(new Date().getTime()/1e3)+2082844800;let t=e;return n.createdTimestamp&&(t=n.createdTimestamp+2082844800),new Z.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}],n)}const ol={parse:Ym,make:Vm};function Wm(n,e){const t={},i=new q.Parser(n,e);return t.version=i.parseVersion(),t.ascender=i.parseShort(),t.descender=i.parseShort(),t.lineGap=i.parseShort(),t.advanceWidthMax=i.parseUShort(),t.minLeftSideBearing=i.parseShort(),t.minRightSideBearing=i.parseShort(),t.xMaxExtent=i.parseShort(),t.caretSlopeRise=i.parseShort(),t.caretSlopeRun=i.parseShort(),t.caretOffset=i.parseShort(),i.relativeOffset+=8,t.metricDataFormat=i.parseShort(),t.numberOfHMetrics=i.parseUShort(),t}function zm(n){return new Z.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}],n)}const rl={parse:Wm,make:zm};function jm(n,e,t,i,s){let o,r;const l=new q.Parser(n,e);for(let a=0;a<i;a+=1){a<t&&(o=l.parseUShort(),r=l.parseShort());const c=s.get(a);c.advanceWidth=o,c.leftSideBearing=r}}function $m(n){const e=new Z.Table("hmtx",[]);for(let t=0;t<n.length;t+=1){const i=n.get(t),s=i.advanceWidth||0,o=i.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 al={parse:jm,make:$m};function Km(n){const e=new Z.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:n.length}]);let t="";const i=12+n.length*4;for(let s=0;s<n.length;++s){let o=t.indexOf(n[s]);o<0&&(o=t.length,t+=n[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:i+o}),e.fields.push({name:"length "+s,type:"USHORT",value:n[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function qm(n,e){const t=new q.Parser(n,e),i=t.parseULong();ie.argument(i===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(),c=t.parseUShort();for(let u=a;u<a+c;++u)l+=String.fromCharCode(n.getInt8(u));o.push(l)}return o}const ll={make:Km,parse:qm};function Xm(n,e){const t={},i=new q.Parser(n,e);return t.version=i.parseVersion(),t.numGlyphs=i.parseUShort(),t.version===1&&(t.maxPoints=i.parseUShort(),t.maxContours=i.parseUShort(),t.maxCompositePoints=i.parseUShort(),t.maxCompositeContours=i.parseUShort(),t.maxZones=i.parseUShort(),t.maxTwilightPoints=i.parseUShort(),t.maxStorage=i.parseUShort(),t.maxFunctionDefs=i.parseUShort(),t.maxInstructionDefs=i.parseUShort(),t.maxStackElements=i.parseUShort(),t.maxSizeOfInstructions=i.parseUShort(),t.maxComponentElements=i.parseUShort(),t.maxComponentDepth=i.parseUShort()),t}function Jm(n){return new Z.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:n}])}const cl={parse:Xm,make:Jm},dl=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],ul={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"},Zm={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},hl={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 eA(n,e,t){switch(n){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return ul[e];case 3:return hl[e]}}const Ks="utf-16",tA={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"},nA={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 fl(n,e,t){switch(n){case 0:return Ks;case 1:return nA[t]||tA[e];case 3:if(e===1||e===10)return Ks;break}}function iA(n,e,t){const i={},s=new q.Parser(n,e),o=s.parseUShort(),r=s.parseUShort(),l=s.offset+s.parseUShort();for(let a=0;a<r;a++){const c=s.parseUShort(),u=s.parseUShort(),f=s.parseUShort(),p=s.parseUShort(),h=dl[p]||p,A=s.parseUShort(),C=s.parseUShort(),m=eA(c,f,t),y=fl(c,u,f);if(y!==void 0&&m!==void 0){let E;if(y===Ks?E=on.UTF16(n,l+C,A):E=on.MACSTRING(n,l+C,A,y),E){let I=i[h];I===void 0&&(I=i[h]={}),I[m]=E}}}return o===1&&s.parseUShort(),i}function qs(n){const e={};for(let t in n)e[n[t]]=parseInt(t);return e}function pl(n,e,t,i,s,o){return new Z.Record("NameRecord",[{name:"platformID",type:"USHORT",value:n},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:t},{name:"nameID",type:"USHORT",value:i},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:o}])}function sA(n,e){const t=n.length,i=e.length-t+1;e:for(let s=0;s<i;s++)for(;s<i;s++){for(let o=0;o<t;o++)if(e[s+o]!==n[o])continue e;return s}return-1}function gl(n,e){let t=sA(n,e);if(t<0){t=e.length;let i=0;const s=n.length;for(;i<s;++i)e.push(n[i])}return t}function oA(n,e){let t;const i=[],s={},o=qs(dl);for(let f in n){let p=o[f];if(p===void 0&&(p=f),t=parseInt(p),isNaN(t))throw new Error('Name table entry "'+f+'" does not exist, see nameTableNames for complete list.');s[t]=n[f],i.push(t)}const r=qs(ul),l=qs(hl),a=[],c=[];for(let f=0;f<i.length;f++){t=i[f];const p=s[t];for(let h in p){const A=p[h];let C=1,m=r[h],y=Zm[m];const E=fl(C,y,m);let I=j.MACSTRING(A,E);I===void 0&&(C=0,m=e.indexOf(h),m<0&&(m=e.length,e.push(h)),y=4,I=j.UTF16(A));const S=gl(I,c);a.push(pl(C,y,m,t,I.length,S));const k=l[h];if(k!==void 0){const B=j.UTF16(A),x=gl(B,c);a.push(pl(3,1,k,t,B.length,x))}}}a.sort(function(f,p){return f.platformID-p.platformID||f.encodingID-p.encodingID||f.languageID-p.languageID||f.nameID-p.nameID});const u=new Z.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 f=0;f<a.length;f++)u.fields.push({name:"record_"+f,type:"RECORD",value:a[f]});return u.fields.push({name:"strings",type:"LITERAL",value:c}),u}const ml={parse:iA,make:oA},Xs=[{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 rA(n){for(let e=0;e<Xs.length;e+=1){const t=Xs[e];if(n>=t.begin&&n<t.end)return e}return-1}function aA(n,e){const t={},i=new q.Parser(n,e);t.version=i.parseUShort(),t.xAvgCharWidth=i.parseShort(),t.usWeightClass=i.parseUShort(),t.usWidthClass=i.parseUShort(),t.fsType=i.parseUShort(),t.ySubscriptXSize=i.parseShort(),t.ySubscriptYSize=i.parseShort(),t.ySubscriptXOffset=i.parseShort(),t.ySubscriptYOffset=i.parseShort(),t.ySuperscriptXSize=i.parseShort(),t.ySuperscriptYSize=i.parseShort(),t.ySuperscriptXOffset=i.parseShort(),t.ySuperscriptYOffset=i.parseShort(),t.yStrikeoutSize=i.parseShort(),t.yStrikeoutPosition=i.parseShort(),t.sFamilyClass=i.parseShort(),t.panose=[];for(let s=0;s<10;s++)t.panose[s]=i.parseByte();return t.ulUnicodeRange1=i.parseULong(),t.ulUnicodeRange2=i.parseULong(),t.ulUnicodeRange3=i.parseULong(),t.ulUnicodeRange4=i.parseULong(),t.achVendID=String.fromCharCode(i.parseByte(),i.parseByte(),i.parseByte(),i.parseByte()),t.fsSelection=i.parseUShort(),t.usFirstCharIndex=i.parseUShort(),t.usLastCharIndex=i.parseUShort(),t.sTypoAscender=i.parseShort(),t.sTypoDescender=i.parseShort(),t.sTypoLineGap=i.parseShort(),t.usWinAscent=i.parseUShort(),t.usWinDescent=i.parseUShort(),t.version>=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function lA(n){return new Z.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}],n)}const Js={parse:aA,make:lA,unicodeRanges:Xs,getUnicodeRange:rA};function cA(n,e){const t={},i=new q.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=Ft.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s<t.numberOfGlyphs;s++)t.glyphNameIndex[s]=i.parseUShort();t.names=[];for(let s=0;s<t.numberOfGlyphs;s++)if(t.glyphNameIndex[s]>=Ft.length){const o=i.parseChar();t.names.push(i.parseString(o))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s<t.numberOfGlyphs;s++)t.offset[s]=i.parseChar();break}return t}function dA(){return new Z.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 Al={parse:cA,make:dA},Ye=new Array(9);Ye[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(H.coverage),deltaGlyphId:this.parseUShort()};if(t===2)return{substFormat:2,coverage:this.parsePointer(H.coverage),substitute:this.parseOffset16List()};ie.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")},Ye[2]=function(){const e=this.parseUShort();return ie.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(H.coverage),sequences:this.parseListOfLists()}},Ye[3]=function(){const e=this.parseUShort();return ie.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(H.coverage),alternateSets:this.parseListOfLists()}},Ye[4]=function(){const e=this.parseUShort();return ie.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(H.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};const an={sequenceIndex:H.uShort,lookupListIndex:H.uShort};Ye[5]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:t,coverage:this.parsePointer(H.coverage),ruleSets:this.parseListOfLists(function(){const i=this.parseUShort(),s=this.parseUShort();return{input:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(s,an)}})};if(t===2)return{substFormat:t,coverage:this.parsePointer(H.coverage),classDef:this.parsePointer(H.classDef),classSets:this.parseListOfLists(function(){const i=this.parseUShort(),s=this.parseUShort();return{classes:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(s,an)}})};if(t===3){const i=this.parseUShort(),s=this.parseUShort();return{substFormat:t,coverages:this.parseList(i,H.pointer(H.coverage)),lookupRecords:this.parseRecordList(s,an)}}ie.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},Ye[6]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(H.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(an)}})};if(t===2)return{substFormat:2,coverage:this.parsePointer(H.coverage),backtrackClassDef:this.parsePointer(H.classDef),inputClassDef:this.parsePointer(H.classDef),lookaheadClassDef:this.parsePointer(H.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(an)}})};if(t===3)return{substFormat:3,backtrackCoverage:this.parseList(H.pointer(H.coverage)),inputCoverage:this.parseList(H.pointer(H.coverage)),lookaheadCoverage:this.parseList(H.pointer(H.coverage)),lookupRecords:this.parseRecordList(an)};ie.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},Ye[7]=function(){const e=this.parseUShort();ie.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");const t=this.parseUShort(),i=new H(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:Ye[t].call(i)}},Ye[8]=function(){const e=this.parseUShort();return ie.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(H.coverage),backtrackCoverage:this.parseList(H.pointer(H.coverage)),lookaheadCoverage:this.parseList(H.pointer(H.coverage)),substitutes:this.parseUShortList()}};function uA(n,e){e=e||0;const t=new H(n,e),i=t.parseVersion(1);return ie.argument(i===1||i===1.1,"Unsupported GSUB table version."),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Ye)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Ye),variations:t.parseFeatureVariationsList()}}const Mi=new Array(9);Mi[1]=function(e){return e.substFormat===1?new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)}].concat(Z.ushortList("substitute",e.substitute)))},Mi[3]=function(e){return ie.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)}].concat(Z.tableList("altSet",e.alternateSets,function(t){return new Z.Table("alternateSetTable",Z.ushortList("alternate",t))})))},Mi[4]=function(e){return ie.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)}].concat(Z.tableList("ligSet",e.ligatureSets,function(t){return new Z.Table("ligatureSetTable",Z.tableList("ligature",t,function(i){return new Z.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:i.ligGlyph}].concat(Z.ushortList("component",i.components,i.components.length+1)))}))})))};function hA(n){return new Z.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new Z.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new Z.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new Z.LookupList(n.lookups,Mi)}])}const yl={parse:uA,make:hA};function fA(n,e){const t=new q.Parser(n,e),i=t.parseULong();ie.argument(i===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(),c=t.parseULong(),u=on.UTF8(n,e+a,c);o[l]=u}return o}function pA(n){const e=Object.keys(n).length;let t="";const i=16+e*12,s=new Z.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:i},{name:"numTags",type:"ULONG",value:e}]);for(let o in n){const r=t.length;t+=n[o],s.fields.push({name:"tag "+o,type:"TAG",value:o}),s.fields.push({name:"offset "+o,type:"ULONG",value:i+r}),s.fields.push({name:"length "+o,type:"ULONG",value:n[o].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),s}const Cl={parse:fA,make:pA};function El(n){return Math.log(n)/Math.log(2)|0}function Zs(n){for(;n.length%4!==0;)n.push(0);let e=0;for(let t=0;t<n.length;t+=4)e+=(n[t]<<24)+(n[t+1]<<16)+(n[t+2]<<8)+n[t+3];return e%=Math.pow(2,32),e}function wl(n,e,t,i){return new Z.Record("Table Record",[{name:"tag",type:"TAG",value:n!==void 0?n:""},{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:i!==void 0?i:0}])}function bl(n){const e=new Z.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=n,e.numTables=n.length;const t=Math.pow(2,El(e.numTables));e.searchRange=16*t,e.entrySelector=El(t),e.rangeShift=e.numTables*16-e.searchRange;const i=[],s=[];let o=e.sizeOf()+wl().sizeOf()*e.numTables;for(;o%4!==0;)o+=1,s.push({name:"padding",type:"BYTE",value:0});for(let r=0;r<n.length;r+=1){const l=n[r];ie.argument(l.tableName.length===4,"Table name"+l.tableName+" is invalid.");const a=l.sizeOf(),c=wl(l.tableName,Zs(l.encode()),o,a);for(i.push({name:c.tag+" Table Record",type:"RECORD",value:c}),s.push({name:l.tableName+" table",type:"RECORD",value:l}),o+=a,ie.argument(!isNaN(o),"Something went wrong calculating the offset.");o%4!==0;)o+=1,s.push({name:"padding",type:"BYTE",value:0})}return i.sort(function(r,l){return r.value.tag>l.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function vl(n,e,t){for(let i=0;i<e.length;i+=1){const s=n.charToGlyphIndex(e[i]);if(s>0)return n.glyphs.get(s).getMetrics()}return t}function gA(n){let e=0;for(let t=0;t<n.length;t+=1)e+=n[t];return e/n.length}function mA(n){const e=[],t=[],i=[],s=[],o=[],r=[],l=[];let a,c=0,u=0,f=0,p=0,h=0;for(let D=0;D<n.glyphs.length;D+=1){const U=n.glyphs.get(D),V=U.unicode|0;if(isNaN(U.advanceWidth))throw new Error("Glyph "+U.name+" ("+D+"): advanceWidth is not a number.");(a>V||a===void 0)&&V>0&&(a=V),c<V&&(c=V);const $=Js.getUnicodeRange(V);if($<32)u|=1<<$;else if($<64)f|=1<<$-32;else if($<96)p|=1<<$-64;else if($<123)h|=1<<$-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(U.name===".notdef")continue;const X=U.getMetrics();e.push(X.xMin),t.push(X.yMin),i.push(X.xMax),s.push(X.yMax),r.push(X.leftSideBearing),l.push(X.rightSideBearing),o.push(U.advanceWidth)}const A={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,o),advanceWidthAvg:gA(o),minLeftSideBearing:Math.min.apply(null,r),maxLeftSideBearing:Math.max.apply(null,r),minRightSideBearing:Math.min.apply(null,l)};A.ascender=n.ascender,A.descender=n.descender;const C=ol.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:A.xMin,yMin:A.yMin,xMax:A.xMax,yMax:A.yMax,lowestRecPPEM:3,createdTimestamp:n.createdTimestamp}),m=rl.make({ascender:A.ascender,descender:A.descender,advanceWidthMax:A.advanceWidthMax,minLeftSideBearing:A.minLeftSideBearing,minRightSideBearing:A.minRightSideBearing,xMaxExtent:A.maxLeftSideBearing+(A.xMax-A.xMin),numberOfHMetrics:n.glyphs.length}),y=cl.make(n.glyphs.length),E=Js.make({xAvgCharWidth:Math.round(A.advanceWidthAvg),usWeightClass:n.tables.os2.usWeightClass,usWidthClass:n.tables.os2.usWidthClass,usFirstCharIndex:a,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:f,ulUnicodeRange3:p,ulUnicodeRange4:h,fsSelection:n.tables.os2.fsSelection,sTypoAscender:A.ascender,sTypoDescender:A.descender,sTypoLineGap:0,usWinAscent:A.yMax,usWinDescent:Math.abs(A.yMin),ulCodePageRange1:1,sxHeight:vl(n,"xyvw",{yMax:Math.round(A.ascender/2)}).yMax,sCapHeight:vl(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",A).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0}),I=al.make(n.glyphs),S=Va.make(n.glyphs),k=n.getEnglishName("fontFamily"),B=n.getEnglishName("fontSubfamily"),x=k+" "+B;let g=n.getEnglishName("postScriptName");g||(g=k.replace(/\s/g,"")+"-"+B);const R={};for(let D in n.names)R[D]=n.names[D];R.uniqueID||(R.uniqueID={en:n.getEnglishName("manufacturer")+":"+x}),R.postScriptName||(R.postScriptName={en:g}),R.preferredFamily||(R.preferredFamily=n.names.fontFamily),R.preferredSubfamily||(R.preferredSubfamily=n.names.fontSubfamily);const M=[],F=ml.make(R,M),L=M.length>0?ll.make(M):void 0,G=Al.make(),N=sl.make(n.glyphs,{version:n.getEnglishName("version"),fullName:x,familyName:k,weightName:B,postScriptName:g,unitsPerEm:n.unitsPerEm,fontBBox:[0,A.yMin,A.ascender,A.advanceWidthMax]}),v=n.metas&&Object.keys(n.metas).length>0?Cl.make(n.metas):void 0,w=[C,m,y,E,F,S,G,N,I];L&&w.push(L),n.tables.gsub&&w.push(yl.make(n.tables.gsub)),v&&w.push(v);const b=bl(w),T=b.encode(),P=Zs(T),_=b.fields;let O=!1;for(let D=0;D<_.length;D+=1)if(_[D].name==="head table"){_[D].value.checkSumAdjustment=2981146554-P,O=!0;break}if(!O)throw new Error("Could not find head table with checkSum to adjust.");return b}const AA={make:bl,fontToTable:mA,computeCheckSum:Zs};function eo(n,e){let t=0,i=n.length-1;for(;t<=i;){const s=t+i>>>1,o=n[s].tag;if(o===e)return s;o<e?t=s+1:i=s-1}return-t-1}function Il(n,e){let t=0,i=n.length-1;for(;t<=i;){const s=t+i>>>1,o=n[s];if(o===e)return s;o<e?t=s+1:i=s-1}return-t-1}function xl(n,e){let t,i=0,s=n.length-1;for(;i<=s;){const o=i+s>>>1;t=n[o];const r=t.start;if(r===e)return t;r<e?i=o+1:s=o-1}if(i>0)return t=n[i-1],e>t.end?0:t}function Dn(n,e){this.font=n,this.tableName=e}Dn.prototype={searchTag:eo,binSearch:Il,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t<n.scripts.length;t++){const i=n.scripts[t].tag;if(i==="DFLT")return i;i==="latn"&&(e=!0)}if(e)return"latn"},getScriptTable:function(n,e){const t=this.getTable(e);if(t){n=n||"DFLT";const i=t.scripts,s=eo(t.scripts,n);if(s>=0)return i[s].script;if(e){const o={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,o),o.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=eo(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const o={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,o),o.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);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(i){const a=l.length;return ie.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(n,e,t,i,s){const o=this.getFeatureTable(n,e,t,s),r=[];if(o){let l;const a=o.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u<a.length;u++)l=c[a[u]],l.lookupType===i&&r.push(l);if(r.length===0&&s){l={lookupType:i,lookupFlag:0,subtables:[],markFilteringSet:void 0};const u=c.length;return c.push(l),a.push(u),[l]}}return r},getGlyphClass:function(n,e){switch(n.format){case 1:return n.startGlyph<=e&&e<n.startGlyph+n.classes.length?n.classes[e-n.startGlyph]:0;case 2:const t=xl(n.ranges,e);return t?t.classId:0}},getCoverageIndex:function(n,e){switch(n.format){case 1:const t=Il(n.glyphs,e);return t>=0?t:-1;case 2:const i=xl(n.ranges,e);return i?i.index+e-i.start:-1}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;i<t.length;i++){const s=t[i],o=s.start,r=s.end;for(let l=o;l<=r;l++)e.push(l)}return e}}};function kn(n){Dn.call(this,n,"gpos")}kn.prototype=Dn.prototype,kn.prototype.init=function(){const n=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(n)},kn.prototype.getKerningValue=function(n,e,t){for(let i=0;i<n.length;i++){const s=n[i].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 p=0;p<a.length;p++){let h=a[p];if(h.secondGlyph===t)return h.value1&&h.value1.xAdvance||0}break;case 2:const c=this.getGlyphClass(r.classDef1,e),u=this.getGlyphClass(r.classDef2,t),f=r.classRecords[c][u];return f.value1&&f.value1.xAdvance||0}}}return 0},kn.prototype.getKerningTables=function(n,e){if(this.font.tables.gpos)return this.getLookupTables(n,e,"kern",2)};function Ve(n){Dn.call(this,n,"gsub")}function yA(n,e){const t=n.length;if(t!==e.length)return!1;for(let i=0;i<t;i++)if(n[i]!==e[i])return!1;return!0}function Bl(n,e,t){const i=n.subtables;for(let s=0;s<i.length;s++){const o=i[s];if(o.substFormat===e)return o}if(t)return i.push(t),t}Ve.prototype=Dn.prototype,Ve.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Ve.prototype.getSingle=function(n,e,t){const i=[],s=this.getLookupTables(e,t,n,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],c=this.expandCoverage(a.coverage);let u;if(a.substFormat===1){const f=a.deltaGlyphId;for(u=0;u<c.length;u++){const p=c[u];i.push({sub:p,by:p+f})}}else{const f=a.substitute;for(u=0;u<c.length;u++)i.push({sub:c[u],by:f[u]})}}}return i},Ve.prototype.getAlternates=function(n,e,t){const i=[],s=this.getLookupTables(e,t,n,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],c=this.expandCoverage(a.coverage),u=a.alternateSets;for(let f=0;f<c.length;f++)i.push({sub:c[f],by:u[f]})}}return i},Ve.prototype.getLigatures=function(n,e,t){const i=[],s=this.getLookupTables(e,t,n,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],c=this.expandCoverage(a.coverage),u=a.ligatureSets;for(let f=0;f<c.length;f++){const p=c[f],h=u[f];for(let A=0;A<h.length;A++){const C=h[A];i.push({sub:[p].concat(C.components),by:C.ligGlyph})}}}}return i},Ve.prototype.addSingle=function(n,e,t,i){const s=this.getLookupTables(t,i,n,1,!0)[0],o=Bl(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});ie.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},Ve.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],o=Bl(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ie.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},Ve.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let o=s.subtables[0];o||(o={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=o),ie.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 c=this.binSearch(o.coverage.glyphs,r);if(c>=0){const u=o.ligatureSets[c];for(let f=0;f<u.length;f++)if(yA(u[f].components,l))return;u.push(a)}else c=-1-c,o.coverage.glyphs.splice(c,0,r),o.ligatureSets.splice(c,0,[a])},Ve.prototype.getFeature=function(n,e,t){if(/ss\d\d/.test(n))return this.getSingle(n,e,t);switch(n){case"aalt":case"salt":return this.getSingle(n,e,t).concat(this.getAlternates(n,e,t));case"dlig":case"liga":case"rlig":return this.getLigatures(n,e,t)}},Ve.prototype.add=function(n,e,t,i){if(/ss\d\d/.test(n))return this.addSingle(n,e,t,i);switch(n){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(n,e,t,i):this.addAlternate(n,e,t,i);case"dlig":case"liga":case"rlig":return this.addLigature(n,e,t,i)}};function CA(){return typeof window<"u"}function EA(n){const e=new ArrayBuffer(n.length),t=new Uint8Array(e);for(let i=0;i<n.length;++i)t[i]=n[i];return e}function wA(n){const e=new Buffer(n.byteLength),t=new Uint8Array(n);for(let i=0;i<e.length;++i)e[i]=t[i];return e}function ln(n,e){if(!n)throw e}function Sl(n,e,t,i,s){let o;return(e&i)>0?(o=n.parseByte(),(e&s)===0&&(o=-o),o=t+o):(e&s)>0?o=t:o=t+n.parseShort(),o}function bA(n,e,t){const i=new q.Parser(e,t);n.numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,o;if(n.numberOfContours>0){const r=n.endPointIndices=[];for(let a=0;a<n.numberOfContours;a+=1)r.push(i.parseUShort());n.instructionLength=i.parseUShort(),n.instructions=[];for(let a=0;a<n.instructionLength;a+=1)n.instructions.push(i.parseByte());const l=r[r.length-1]+1;s=[];for(let a=0;a<l;a+=1)if(o=i.parseByte(),s.push(o),(o&8)>0){const c=i.parseByte();for(let u=0;u<c;u+=1)s.push(o),a+=1}if(ie.argument(s.length===l,"Bad flags."),r.length>0){const a=[];let c;if(l>0){for(let p=0;p<l;p+=1)o=s[p],c={},c.onCurve=!!(o&1),c.lastPointOfContour=r.indexOf(p)>=0,a.push(c);let u=0;for(let p=0;p<l;p+=1)o=s[p],c=a[p],c.x=Sl(i,o,u,2,16),u=c.x;let f=0;for(let p=0;p<l;p+=1)o=s[p],c=a[p],c.y=Sl(i,o,f,4,32),f=c.y}n.points=a}else n.points=[]}else if(n.numberOfContours===0)n.points=[];else{n.isComposite=!0,n.points=[],n.components=[];let r=!0;for(;r;){s=i.parseUShort();const l={glyphIndex:i.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(l.dx=i.parseShort(),l.dy=i.parseShort()):l.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(l.dx=i.parseChar(),l.dy=i.parseChar()):l.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?l.xScale=l.yScale=i.parseF2Dot14():(s&64)>0?(l.xScale=i.parseF2Dot14(),l.yScale=i.parseF2Dot14()):(s&128)>0&&(l.xScale=i.parseF2Dot14(),l.scale01=i.parseF2Dot14(),l.scale10=i.parseF2Dot14(),l.yScale=i.parseF2Dot14()),n.components.push(l),r=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let l=0;l<n.instructionLength;l+=1)n.instructions.push(i.parseByte())}}}function to(n,e){const t=[];for(let i=0;i<n.length;i+=1){const s=n[i],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 vA(n){const e=[];let t=[];for(let i=0;i<n.length;i+=1){const s=n[i];t.push(s),s.lastPointOfContour&&(e.push(t),t=[])}return ie.argument(t.length===0,"There are still points left in the current contour."),e}function Ml(n){const e=new Ie;if(!n)return e;const t=vA(n);for(let i=0;i<t.length;++i){const s=t[i];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 c=l;o.onCurve||((r.x+o.x)*.5,(r.y+o.y)*.5),l.onCurve||(c={x:(r.x+l.x)*.5,y:(r.y+l.y)*.5}),e.quadraticCurveTo(r.x,r.y,c.x,c.y)}e.closePath()}return e}function IA(n,e){if(e.isComposite)for(let t=0;t<e.components.length;t+=1){const i=e.components[t],s=n.get(i.glyphIndex);if(s.getPath(),s.points){let o;if(i.matchedPoints===void 0)o=to(s.points,i);else{if(i.matchedPoints[0]>e.points.length-1||i.matchedPoints[1]>s.points.length-1)throw Error("Matched points out of range in "+e.name);const r=e.points[i.matchedPoints[0]];let l=s.points[i.matchedPoints[1]];const a={xScale:i.xScale,scale01:i.scale01,scale10:i.scale10,yScale:i.yScale,dx:0,dy:0};l=to([l],a)[0],a.dx=r.x-l.x,a.dy=r.y-l.y,o=to(s.points,a)}e.points=e.points.concat(o)}}return Ml(e.points)}function xA(n,e,t,i){const s=new rn.GlyphSet(i);for(let o=0;o<t.length-1;o+=1){const r=t[o],l=t[o+1];r!==l?s.push(o,rn.ttfGlyphLoader(i,o,bA,n,e+r,IA)):s.push(o,rn.glyphLoader(i,o))}return s}const Tl={getPath:Ml,parse:xA};let Dl,Ot,kl,no;function Pl(n){this.font=n,this.getCommands=function(e){return Tl.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function BA(n){return n}function Fl(n){return Math.sign(n)*Math.round(Math.abs(n))}function SA(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function MA(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function TA(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function DA(n){return Math.sign(n)*Math.floor(Math.abs(n))}const Rl=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},nt={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,o,r,l,a,c,u;if(!i||i===this){if(s=n.xo-e.xo,o=n.xo-t.xo,a=e.x-e.xo,c=t.x-t.xo,r=Math.abs(s),l=Math.abs(o),u=r+l,u===0){n.x=n.xo+(a+c)/2;return}n.x=n.xo+(a*l+c*r)/u;return}if(s=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),a=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),r=Math.abs(s),l=Math.abs(o),u=r+l,u===0){nt.setRelative(n,n,(a+c)/2,i,!0);return}nt.setRelative(n,n,(a*l+c*r)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*i.x,a=r+t*i.y;n.x=l+(n.y-a)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},lt={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,o,r,l,a,c,u;if(!i||i===this){if(s=n.yo-e.yo,o=n.yo-t.yo,a=e.y-e.yo,c=t.y-t.yo,r=Math.abs(s),l=Math.abs(o),u=r+l,u===0){n.y=n.yo+(a+c)/2;return}n.y=n.yo+(a*l+c*r)/u;return}if(s=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),a=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),r=Math.abs(s),l=Math.abs(o),u=r+l,u===0){lt.setRelative(n,n,(a+c)/2,i,!0);return}lt.setRelative(n,n,(a*l+c*r)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*i.x,a=r+t*i.y;n.y=a+i.normalSlope*(n.x-l)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze(nt),Object.freeze(lt);function Pn(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Pn.prototype.distance=function(n,e,t,i){return this.x*nt.distance(n,e,t,i)+this.y*lt.distance(n,e,t,i)},Pn.prototype.interpolate=function(n,e,t,i){let s,o,r,l,a,c,u;if(r=i.distance(n,e,!0,!0),l=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),o=i.distance(t,t,!1,!0),a=Math.abs(r),c=Math.abs(l),u=a+c,u===0){this.setRelative(n,n,(s+o)/2,i,!0);return}this.setRelative(n,n,(s*c+o*a)/u,i,!0)},Pn.prototype.setRelative=function(n,e,t,i,s){i=i||this;const o=s?e.xo:e.x,r=s?e.yo:e.y,l=o+t*i.x,a=r+t*i.y,c=i.normalSlope,u=this.slope,f=n.x,p=n.y;n.x=(u*f-c*l+a-p)/(u-c),n.y=u*(n.x-f)+p},Pn.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function Fn(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?nt:n===0&&e===1?lt:new Pn(n,e)}function ct(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}ct.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e},ct.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};const Rn=Object.freeze(new ct(0,0)),kA={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function wt(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=nt,this.round=Fl}}Pl.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){wt.prototype=kA,s=this._fpgmState=new wt("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,Q.DEBUG&&(console.log("---EXEC FPGM---"),s.step=-1);try{Ot(s)}catch(r){console.log("Hinting error in FPGM:"+r),this._errorState=3;return}}wt.prototype=s,i=this._prepState=new wt("prep",t.tables.prep),i.ppem=e;const o=t.tables.cvt;if(o){const r=i.cvt=new Array(o.length),l=e/t.unitsPerEm;for(let a=0;a<o.length;a++)r[a]=o[a]*l}else i.cvt=[];Q.DEBUG&&(console.log("---EXEC PREP---"),i.step=-1);try{Ot(i)}catch(r){this._errorState<2&&console.log("Hinting error in PREP:"+r),this._errorState=2}}if(!(this._errorState>1))try{return kl(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},kl=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,o,r,l;if(wt.prototype=e,!s)l=new wt("glyf",n.instructions),Q.DEBUG&&(console.log("---EXEC GLYPH---"),l.step=-1),no(n,l,t,i),r=l.gZone;else{const a=e.font;r=[],o=[];for(let c=0;c<s.length;c++){const u=s[c],f=a.glyphs.get(u.glyphIndex);l=new wt("glyf",f.instructions),Q.DEBUG&&(console.log("---EXEC COMP "+c+"---"),l.step=-1),no(f,l,t,i);const p=Math.round(u.dx*t),h=Math.round(u.dy*i),A=l.gZone,C=l.contours;for(let y=0;y<A.length;y++){const E=A[y];E.xTouched=E.yTouched=!1,E.xo=E.x=E.x+p,E.yo=E.y=E.y+h}const m=r.length;r.push.apply(r,A);for(let y=0;y<C.length;y++)o.push(C[y]+m)}n.instructions&&!l.inhibitGridFit&&(l=new wt("glyf",n.instructions),l.gZone=l.z0=l.z1=l.z2=r,l.contours=o,r.push(new ct(0,0),new ct(Math.round(n.advanceWidth*t),0)),Q.DEBUG&&(console.log("---EXEC COMPOSITE---"),l.step=-1),Ot(l),r.length-=2)}return r},no=function(n,e,t,i){const s=n.points||[],o=s.length,r=e.gZone=e.z0=e.z1=e.z2=[],l=e.contours=[];let a;for(let f=0;f<o;f++)a=s[f],r[f]=new ct(a.x*t,a.y*i,a.lastPointOfContour,a.onCurve);let c,u;for(let f=0;f<o;f++)a=r[f],c||(c=a,l.push(f)),a.lastPointOfContour?(a.nextPointOnContour=c,c.prevPointOnContour=a,c=void 0):(u=r[f+1],a.nextPointOnContour=u,u.prevPointOnContour=a);if(!e.inhibitGridFit){if(Q.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(let f=0;f<o;f++)console.log(f,r[f].x,r[f].y)}if(r.push(new ct(0,0),new ct(Math.round(n.advanceWidth*t),0)),Ot(e),r.length-=2,Q.DEBUG){console.log("FINISHED GLYPH",e.stack);for(let f=0;f<o;f++)console.log(f,r[f].x,r[f].y)}}},Ot=function(n){let e=n.prog;if(!e)return;const t=e.length;let i;for(n.ip=0;n.ip<t;n.ip++){if(Q.DEBUG&&n.step++,i=Dl[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function Ti(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t<e.length;t++)e[t]=new ct(0,0)}function Ol(n,e){const t=n.prog;let i=n.ip,s=1,o;do if(o=t[++i],o===88)s++;else if(o===89)s--;else if(o===64)i+=t[i+1]+1;else if(o===65)i+=2*t[i+1]+1;else if(o>=176&&o<=183)i+=o-176+1;else if(o>=184&&o<=191)i+=(o-184+1)*2;else if(e&&s===1&&o===27)break;while(s>0);n.ip=i}function Ll(n,e){Q.DEBUG&&console.log(e.step,"SVTCA["+n.axis+"]"),e.fv=e.pv=e.dpv=n}function Nl(n,e){Q.DEBUG&&console.log(e.step,"SPVTCA["+n.axis+"]"),e.pv=e.dpv=n}function Ul(n,e){Q.DEBUG&&console.log(e.step,"SFVTCA["+n.axis+"]"),e.fv=n}function _l(n,e){const t=e.stack,i=t.pop(),s=t.pop(),o=e.z2[i],r=e.z1[s];Q.DEBUG&&console.log("SPVTL["+n+"]",i,s);let l,a;n?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.pv=e.dpv=Fn(l,a)}function Ql(n,e){const t=e.stack,i=t.pop(),s=t.pop(),o=e.z2[i],r=e.z1[s];Q.DEBUG&&console.log("SFVTL["+n+"]",i,s);let l,a;n?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.fv=Fn(l,a)}function PA(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"SPVFS[]",t,i),n.pv=n.dpv=Fn(i,t)}function FA(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"SPVFS[]",t,i),n.fv=Fn(i,t)}function RA(n){const e=n.stack,t=n.pv;Q.DEBUG&&console.log(n.step,"GPV[]"),e.push(t.x*16384),e.push(t.y*16384)}function OA(n){const e=n.stack,t=n.fv;Q.DEBUG&&console.log(n.step,"GFV[]"),e.push(t.x*16384),e.push(t.y*16384)}function LA(n){n.fv=n.pv,Q.DEBUG&&console.log(n.step,"SFVTPV[]")}function NA(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),o=e.pop(),r=e.pop(),l=n.z0,a=n.z1,c=l[t],u=l[i],f=a[s],p=a[o],h=n.z2[r];Q.DEBUG&&console.log("ISECT[], ",t,i,s,o,r);const A=c.x,C=c.y,m=u.x,y=u.y,E=f.x,I=f.y,S=p.x,k=p.y,B=(A-m)*(I-k)-(C-y)*(E-S),x=A*y-C*m,g=E*k-I*S;h.x=(x*(E-S)-g*(A-m))/B,h.y=(x*(I-k)-g*(C-y))/B}function UA(n){n.rp0=n.stack.pop(),Q.DEBUG&&console.log(n.step,"SRP0[]",n.rp0)}function _A(n){n.rp1=n.stack.pop(),Q.DEBUG&&console.log(n.step,"SRP1[]",n.rp1)}function QA(n){n.rp2=n.stack.pop(),Q.DEBUG&&console.log(n.step,"SRP2[]",n.rp2)}function HA(n){const e=n.stack.pop();switch(Q.DEBUG&&console.log(n.step,"SZP0[]",e),n.zp0=e,e){case 0:n.tZone||Ti(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function GA(n){const e=n.stack.pop();switch(Q.DEBUG&&console.log(n.step,"SZP1[]",e),n.zp1=e,e){case 0:n.tZone||Ti(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function YA(n){const e=n.stack.pop();switch(Q.DEBUG&&console.log(n.step,"SZP2[]",e),n.zp2=e,e){case 0:n.tZone||Ti(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function VA(n){const e=n.stack.pop();switch(Q.DEBUG&&console.log(n.step,"SZPS[]",e),n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Ti(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function WA(n){n.loop=n.stack.pop(),Q.DEBUG&&console.log(n.step,"SLOOP[]",n.loop)}function zA(n){Q.DEBUG&&console.log(n.step,"RTG[]"),n.round=Fl}function jA(n){Q.DEBUG&&console.log(n.step,"RTHG[]"),n.round=MA}function $A(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"SMD[]",e),n.minDis=e/64}function KA(n){Q.DEBUG&&console.log(n.step,"ELSE[]"),Ol(n,!1)}function qA(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"JMPR[]",e),n.ip+=e-1}function XA(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"SCVTCI[]",e),n.cvCutIn=e/64}function JA(n){const e=n.stack;Q.DEBUG&&console.log(n.step,"DUP[]"),e.push(e[e.length-1])}function io(n){Q.DEBUG&&console.log(n.step,"POP[]"),n.stack.pop()}function ZA(n){Q.DEBUG&&console.log(n.step,"CLEAR[]"),n.stack.length=0}function ey(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"SWAP[]"),e.push(t),e.push(i)}function ty(n){const e=n.stack;Q.DEBUG&&console.log(n.step,"DEPTH[]"),e.push(e.length)}function ny(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"LOOPCALL[]",t,i);const s=n.ip,o=n.prog;n.prog=n.funcs[t];for(let r=0;r<i;r++)Ot(n),Q.DEBUG&&console.log(++n.step,r+1<i?"next loopcall":"done loopcall",r);n.ip=s,n.prog=o}function iy(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"CALL[]",e);const t=n.ip,i=n.prog;n.prog=n.funcs[e],Ot(n),n.ip=t,n.prog=i,Q.DEBUG&&console.log(++n.step,"returning from",e)}function sy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"CINDEX[]",t),e.push(e[e.length-t])}function oy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"MINDEX[]",t),e.push(e.splice(e.length-t,1)[0])}function ry(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),o=i;for(Q.DEBUG&&console.log(n.step,"FDEF[]",s);t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(o+1,i)}function Hl(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,o=e.pv;Q.DEBUG&&console.log(e.step,"MDAP["+n+"]",t);let r=o.distance(i,Rn);n&&(r=e.round(r)),s.setRelative(i,Rn,r,o),s.touch(i),e.rp0=e.rp1=t}function Gl(n,e){const t=e.z2,i=t.length-2;let s,o,r;Q.DEBUG&&console.log(e.step,"IUP["+n.axis+"]");for(let l=0;l<i;l++)s=t[l],!n.touched(s)&&(o=s.prevTouched(n),o!==s&&(r=s.nextTouched(n),o===r&&n.setRelative(s,s,n.distance(o,o,!1,!0),n,!0),n.interpolate(s,o,r,n)))}function Yl(n,e){const t=e.stack,i=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[i],o=e.fv,r=e.pv;let l=e.loop;const a=e.z2;for(;l--;){const c=t.pop(),u=a[c],f=r.distance(s,s,!1,!0);o.setRelative(u,u,f,r),o.touch(u),Q.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-l)+": ":"")+"SHP["+(n?"rp1":"rp2")+"]",c)}e.loop=1}function Vl(n,e){const t=e.stack,i=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[i],o=e.fv,r=e.pv,l=t.pop(),a=e.z2[e.contours[l]];let c=a;Q.DEBUG&&console.log(e.step,"SHC["+n+"]",l);const u=r.distance(s,s,!1,!0);do c!==s&&o.setRelative(c,c,u,r),c=c.nextPointOnContour;while(c!==a)}function Wl(n,e){const t=e.stack,i=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[i],o=e.fv,r=e.pv,l=t.pop();Q.DEBUG&&console.log(e.step,"SHZ["+n+"]",l);let a;switch(l){case 0:a=e.tZone;break;case 1:a=e.gZone;break;default:throw new Error("Invalid zone")}let c;const u=r.distance(s,s,!1,!0),f=a.length-2;for(let p=0;p<f;p++)c=a[p],o.setRelative(c,c,u,r)}function ay(n){const e=n.stack;let t=n.loop;const i=n.fv,s=e.pop()/64,o=n.z2;for(;t--;){const r=e.pop(),l=o[r];Q.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-t)+": ":"")+"SHPIX[]",r,s),i.setRelative(l,l,s),i.touch(l)}n.loop=1}function ly(n){const e=n.stack,t=n.rp1,i=n.rp2;let s=n.loop;const o=n.z0[t],r=n.z1[i],l=n.fv,a=n.dpv,c=n.z2;for(;s--;){const u=e.pop(),f=c[u];Q.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-s)+": ":"")+"IP[]",u,t,"<->",i),l.interpolate(f,o,r,a),l.touch(f)}n.loop=1}function zl(n,e){const t=e.stack,i=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,i,a),l.touch(o),Q.DEBUG&&console.log(e.step,"MSIRP["+n+"]",i,s),e.rp1=e.rp0,e.rp2=s,n&&(e.rp0=s)}function cy(n){const e=n.stack,t=n.rp0,i=n.z0[t];let s=n.loop;const o=n.fv,r=n.pv,l=n.z1;for(;s--;){const a=e.pop(),c=l[a];Q.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-s)+": ":"")+"ALIGNRP[]",a),o.setRelative(c,i,0,r),o.touch(c)}n.loop=1}function dy(n){Q.DEBUG&&console.log(n.step,"RTDG[]"),n.round=SA}function jl(n,e){const t=e.stack,i=t.pop(),s=t.pop(),o=e.z0[s],r=e.fv,l=e.pv;let a=e.cvt[i];Q.DEBUG&&console.log(e.step,"MIAP["+n+"]",i,"(",a,")",s);let c=l.distance(o,Rn);n&&(Math.abs(c-a)<e.cvCutIn&&(c=a),c=e.round(c)),r.setRelative(o,Rn,c,l),e.zp0===0&&(o.xo=o.x,o.yo=o.y),r.touch(o),e.rp0=e.rp1=s}function uy(n){const e=n.prog;let t=n.ip;const i=n.stack,s=e[++t];Q.DEBUG&&console.log(n.step,"NPUSHB[]",s);for(let o=0;o<s;o++)i.push(e[++t]);n.ip=t}function hy(n){let e=n.ip;const t=n.prog,i=n.stack,s=t[++e];Q.DEBUG&&console.log(n.step,"NPUSHW[]",s);for(let o=0;o<s;o++){let r=t[++e]<<8|t[++e];r&32768&&(r=-((r^65535)+1)),i.push(r)}n.ip=e}function fy(n){const e=n.stack;let t=n.store;t||(t=n.store=[]);const i=e.pop(),s=e.pop();Q.DEBUG&&console.log(n.step,"WS",i,s),t[s]=i}function py(n){const e=n.stack,t=n.store,i=e.pop();Q.DEBUG&&console.log(n.step,"RS",i);const s=t&&t[i]||0;e.push(s)}function gy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"WCVTP",t,i),n.cvt[i]=t/64}function my(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"RCVT",t),e.push(n.cvt[t]*64)}function $l(n,e){const t=e.stack,i=t.pop(),s=e.z2[i];Q.DEBUG&&console.log(e.step,"GC["+n+"]",i),t.push(e.dpv.distance(s,Rn,n,!1)*64)}function Kl(n,e){const t=e.stack,i=t.pop(),s=t.pop(),o=e.z1[i],r=e.z0[s],l=e.dpv.distance(r,o,n,n);Q.DEBUG&&console.log(e.step,"MD["+n+"]",i,s,"->",l),e.stack.push(Math.round(l*64))}function Ay(n){Q.DEBUG&&console.log(n.step,"MPPEM[]"),n.stack.push(n.ppem)}function yy(n){Q.DEBUG&&console.log(n.step,"FLIPON[]"),n.autoFlip=!0}function Cy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"LT[]",t,i),e.push(i<t?1:0)}function Ey(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"LTEQ[]",t,i),e.push(i<=t?1:0)}function wy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"GT[]",t,i),e.push(i>t?1:0)}function by(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"GTEQ[]",t,i),e.push(i>=t?1:0)}function vy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"EQ[]",t,i),e.push(t===i?1:0)}function Iy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"NEQ[]",t,i),e.push(t!==i?1:0)}function xy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"ODD[]",t),e.push(Math.trunc(t)%2?1:0)}function By(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"EVEN[]",t),e.push(Math.trunc(t)%2?0:1)}function Sy(n){let e=n.stack.pop();Q.DEBUG&&console.log(n.step,"IF[]",e),e||(Ol(n,!0),Q.DEBUG&&console.log(n.step,"EIF[]"))}function My(n){Q.DEBUG&&console.log(n.step,"EIF[]")}function Ty(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"AND[]",t,i),e.push(t&&i?1:0)}function Dy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"OR[]",t,i),e.push(t||i?1:0)}function ky(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"NOT[]",t),e.push(t?0:1)}function so(n,e){const t=e.stack,i=t.pop(),s=e.fv,o=e.pv,r=e.ppem,l=e.deltaBase+(n-1)*16,a=e.deltaShift,c=e.z0;Q.DEBUG&&console.log(e.step,"DELTAP["+n+"]",i,t);for(let u=0;u<i;u++){const f=t.pop(),p=t.pop();if(l+((p&240)>>4)!==r)continue;let A=(p&15)-8;A>=0&&A++,Q.DEBUG&&console.log(e.step,"DELTAPFIX",f,"by",A*a);const C=c[f];s.setRelative(C,C,A*a,o)}}function Py(n){const t=n.stack.pop();Q.DEBUG&&console.log(n.step,"SDB[]",t),n.deltaBase=t}function Fy(n){const t=n.stack.pop();Q.DEBUG&&console.log(n.step,"SDS[]",t),n.deltaShift=Math.pow(.5,t)}function Ry(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"ADD[]",t,i),e.push(i+t)}function Oy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"SUB[]",t,i),e.push(i-t)}function Ly(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"DIV[]",t,i),e.push(i*64/t)}function Ny(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"MUL[]",t,i),e.push(i*t/64)}function Uy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"ABS[]",t),e.push(Math.abs(t))}function _y(n){const e=n.stack;let t=e.pop();Q.DEBUG&&console.log(n.step,"NEG[]",t),e.push(-t)}function Qy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"FLOOR[]",t),e.push(Math.floor(t/64)*64)}function Hy(n){const e=n.stack,t=e.pop();Q.DEBUG&&console.log(n.step,"CEILING[]",t),e.push(Math.ceil(t/64)*64)}function Di(n,e){const t=e.stack,i=t.pop();Q.DEBUG&&console.log(e.step,"ROUND[]"),t.push(e.round(i/64)*64)}function Gy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"WCVTF[]",t,i),n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function oo(n,e){const t=e.stack,i=t.pop(),s=e.ppem,o=e.deltaBase+(n-1)*16,r=e.deltaShift;Q.DEBUG&&console.log(e.step,"DELTAC["+n+"]",i,t);for(let l=0;l<i;l++){const a=t.pop(),c=t.pop();if(o+((c&240)>>4)!==s)continue;let f=(c&15)-8;f>=0&&f++;const p=f*r;Q.DEBUG&&console.log(e.step,"DELTACFIX",a,"by",p),e.cvt[a]+=p}}function Yy(n){let e=n.stack.pop();Q.DEBUG&&console.log(n.step,"SROUND[]",e),n.round=Rl;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(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function Vy(n){let e=n.stack.pop();Q.DEBUG&&console.log(n.step,"S45ROUND[]",e),n.round=Rl;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(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function Wy(n){Q.DEBUG&&console.log(n.step,"ROFF[]"),n.round=BA}function zy(n){Q.DEBUG&&console.log(n.step,"RUTG[]"),n.round=TA}function jy(n){Q.DEBUG&&console.log(n.step,"RDTG[]"),n.round=DA}function $y(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"SCANCTRL[]",e)}function ql(n,e){const t=e.stack,i=t.pop(),s=t.pop(),o=e.z2[i],r=e.z1[s];Q.DEBUG&&console.log(e.step,"SDPVTL["+n+"]",i,s);let l,a;n?(l=o.y-r.y,a=r.x-o.x):(l=r.x-o.x,a=r.y-o.y),e.dpv=Fn(l,a)}function Ky(n){const e=n.stack,t=e.pop();let i=0;Q.DEBUG&&console.log(n.step,"GETINFO[]",t),t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function qy(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();Q.DEBUG&&console.log(n.step,"ROLL[]"),e.push(i),e.push(t),e.push(s)}function Xy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"MAX[]",t,i),e.push(Math.max(i,t))}function Jy(n){const e=n.stack,t=e.pop(),i=e.pop();Q.DEBUG&&console.log(n.step,"MIN[]",t,i),e.push(Math.min(i,t))}function Zy(n){const e=n.stack.pop();Q.DEBUG&&console.log(n.step,"SCANTYPE[]",e)}function e0(n){const e=n.stack.pop();let t=n.stack.pop();switch(Q.DEBUG&&console.log(n.step,"INSTCTRL[]",e,t),e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function bt(n,e){const t=e.stack,i=e.prog;let s=e.ip;Q.DEBUG&&console.log(e.step,"PUSHB["+n+"]");for(let o=0;o<n;o++)t.push(i[++s]);e.ip=s}function vt(n,e){let t=e.ip;const i=e.prog,s=e.stack;Q.DEBUG&&console.log(e.ip,"PUSHW["+n+"]");for(let o=0;o<n;o++){let r=i[++t]<<8|i[++t];r&32768&&(r=-((r^65535)+1)),s.push(r)}e.ip=t}function K(n,e,t,i,s,o){const r=o.stack,l=n&&r.pop(),a=r.pop(),c=o.rp0,u=o.z0[c],f=o.z1[a],p=o.minDis,h=o.fv,A=o.dpv;let C,m,y,E;m=C=A.distance(f,u,!0,!0),y=m>=0?1:-1,m=Math.abs(m),n&&(E=o.cvt[l],i&&Math.abs(m-E)<o.cvCutIn&&(m=E)),t&&m<p&&(m=p),i&&(m=o.round(m)),h.setRelative(f,u,y*m,A),h.touch(f),Q.DEBUG&&console.log(o.step,(n?"MIRP[":"MDRP[")+(e?"M":"m")+(t?">":"_")+(i?"R":"_")+(s===0?"Gr":s===1?"Bl":s===2?"Wh":"")+"]",n?l+"("+o.cvt[l]+","+E+")":"",a,"(d =",C,"->",y*m,")"),o.rp1=o.rp0,o.rp2=a,e&&(o.rp0=a)}Dl=[Ll.bind(void 0,lt),Ll.bind(void 0,nt),Nl.bind(void 0,lt),Nl.bind(void 0,nt),Ul.bind(void 0,lt),Ul.bind(void 0,nt),_l.bind(void 0,0),_l.bind(void 0,1),Ql.bind(void 0,0),Ql.bind(void 0,1),PA,FA,RA,OA,LA,NA,UA,_A,QA,HA,GA,YA,VA,WA,zA,jA,$A,KA,qA,XA,void 0,void 0,JA,io,ZA,ey,ty,sy,oy,void 0,void 0,void 0,ny,iy,ry,void 0,Hl.bind(void 0,0),Hl.bind(void 0,1),Gl.bind(void 0,lt),Gl.bind(void 0,nt),Yl.bind(void 0,0),Yl.bind(void 0,1),Vl.bind(void 0,0),Vl.bind(void 0,1),Wl.bind(void 0,0),Wl.bind(void 0,1),ay,ly,zl.bind(void 0,0),zl.bind(void 0,1),cy,dy,jl.bind(void 0,0),jl.bind(void 0,1),uy,hy,fy,py,gy,my,$l.bind(void 0,0),$l.bind(void 0,1),void 0,Kl.bind(void 0,0),Kl.bind(void 0,1),Ay,void 0,yy,void 0,void 0,Cy,Ey,wy,by,vy,Iy,xy,By,Sy,My,Ty,Dy,ky,so.bind(void 0,1),Py,Fy,Ry,Oy,Ly,Ny,Uy,_y,Qy,Hy,Di.bind(void 0,0),Di.bind(void 0,1),Di.bind(void 0,2),Di.bind(void 0,3),void 0,void 0,void 0,void 0,Gy,so.bind(void 0,2),so.bind(void 0,3),oo.bind(void 0,1),oo.bind(void 0,2),oo.bind(void 0,3),Yy,Vy,void 0,void 0,Wy,void 0,zy,jy,io,io,void 0,void 0,void 0,void 0,void 0,$y,ql.bind(void 0,0),ql.bind(void 0,1),Ky,void 0,qy,Xy,Jy,Zy,e0,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,bt.bind(void 0,1),bt.bind(void 0,2),bt.bind(void 0,3),bt.bind(void 0,4),bt.bind(void 0,5),bt.bind(void 0,6),bt.bind(void 0,7),bt.bind(void 0,8),vt.bind(void 0,1),vt.bind(void 0,2),vt.bind(void 0,3),vt.bind(void 0,4),vt.bind(void 0,5),vt.bind(void 0,6),vt.bind(void 0,7),vt.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 t0=Array.from||(n=>n.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g)||[]);function ue(n){n=n||{},n.empty||(ln(n.familyName,"When creating a new Font object, familyName is required."),ln(n.styleName,"When creating a new Font object, styleName is required."),ln(n.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),ln(n.ascender,"When creating a new Font object, ascender is required."),ln(n.descender,"When creating a new Font object, descender is required."),ln(n.descender<0,"Descender should be negative (e.g. -512)."),this.names={fontFamily:{en:n.familyName||" "},fontSubfamily:{en:n.styleName||" "},fullName:{en:n.fullName||n.familyName+" "+n.styleName},postScriptName:{en:n.postScriptName||(n.familyName+n.styleName).replace(/\s/g,"")},designer:{en:n.designer||" "},designerURL:{en:n.designerURL||" "},manufacturer:{en:n.manufacturer||" "},manufacturerURL:{en:n.manufacturerURL||" "},license:{en:n.license||" "},licenseURL:{en:n.licenseURL||" "},version:{en:n.version||"Version 0.1"},description:{en:n.description||" "},copyright:{en:n.copyright||" "},trademark:{en:n.trademark||" "}},this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.tables={os2:{usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,fsSelection:n.fsSelection||this.fsSelectionValues.REGULAR}}),this.supported=!0,this.glyphs=new rn.GlyphSet(this,n.glyphs||[]),this.encoding=new Wa(this),this.position=new kn(this),this.substitution=new Ve(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 Pl(this)}})}ue.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)!==null},ue.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)},ue.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},ue.prototype.stringToGlyphs=function(n,e){e=e||this.defaultRenderOptions;const t=t0(n),i=[];for(let l=0;l<t.length;l+=1){const a=t[l];i.push(this.charToGlyphIndex(a))}let s=i.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 c=0;c<s;c+=1)for(let u=0;u<a.length;u++){const f=a[u],p=f.sub,h=p.length;let A=0;for(;A<h&&p[A]===i[c+A];)A++;A===h&&(i.splice(c,h,f.by),s=s-h+1)}}const o=new Array(s),r=this.glyphs.get(0);for(let l=0;l<s;l+=1)o[l]=this.glyphs.get(i[l])||r;return o},ue.prototype.nameToGlyphIndex=function(n){return this.glyphNames.nameToGlyphIndex(n)},ue.prototype.nameToGlyph=function(n){const e=this.nameToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},ue.prototype.glyphIndexToName=function(n){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(n):""},ue.prototype.getKerningValue=function(n,e){n=n.index||n,e=e.index||e;const t=this.position.defaultKerningTables;return t?this.position.getKerningValue(t,n,e):this.kerningPairs[n+","+e]||0},ue.prototype.defaultRenderOptions={kerning:!0,features:{liga:!0,rlig:!0}},ue.prototype.forEachGlyph=function(n,e,t,i,s,o){e=e!==void 0?e:0,t=t!==void 0?t:0,i=i!==void 0?i:72,s=s||this.defaultRenderOptions;const r=1/this.unitsPerEm*i,l=this.stringToGlyphs(n,s);let a;if(s.kerning){const c=s.script||this.position.getDefaultScriptName();a=this.position.getKerningTables(c,s.language)}for(let c=0;c<l.length;c+=1){const u=l[c];if(o.call(this,u,e,t,i,s),u.advanceWidth&&(e+=u.advanceWidth*r),s.kerning&&c<l.length-1){const f=a?this.position.getKerningValue(a,u.index,l[c+1].index):this.getKerningValue(u,l[c+1]);e+=f*r}s.letterSpacing?e+=s.letterSpacing*i:s.tracking&&(e+=s.tracking/1e3*i)}return e},ue.prototype.getPath=function(n,e,t,i,s){const o=new Ie;return this.forEachGlyph(n,e,t,i,s,function(r,l,a,c){const u=r.getPath(l,a,c,s,this);o.extend(u)}),o},ue.prototype.getPaths=function(n,e,t,i,s){const o=[];return this.forEachGlyph(n,e,t,i,s,function(r,l,a,c){const u=r.getPath(l,a,c,s,this);o.push(u)}),o},ue.prototype.getAdvanceWidth=function(n,e,t){return this.forEachGlyph(n,0,0,e,t,function(){})},ue.prototype.draw=function(n,e,t,i,s,o){this.getPath(e,t,i,s,o).draw(n)},ue.prototype.drawPoints=function(n,e,t,i,s,o){this.forEachGlyph(e,t,i,s,o,function(r,l,a,c){r.drawPoints(n,l,a,c)})},ue.prototype.drawMetrics=function(n,e,t,i,s,o){this.forEachGlyph(e,t,i,s,o,function(r,l,a,c){r.drawMetrics(n,l,a,c)})},ue.prototype.getEnglishName=function(n){const e=this.names[n];if(e)return e.en},ue.prototype.validate=function(){const n=this;function e(i,s){}function t(i){const s=n.getEnglishName(i);s&&s.trim().length>0}t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),this.unitsPerEm>0},ue.prototype.toTables=function(){return AA.fontToTable(this)},ue.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},ue.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s<e.length;s++)i[s]=e[s];return t},ue.prototype.download=function(n){const e=this.getEnglishName("fontFamily"),t=this.getEnglishName("fontSubfamily");n=n||e.replace(/\s/g,"")+"-"+t+".otf";const i=this.toArrayBuffer();if(CA())if(window.URL=window.URL||window.webkitURL,window.URL){const s=new DataView(i),o=new Blob([s],{type:"font/opentype"});let r=document.createElement("a");r.href=window.URL.createObjectURL(o),r.download=n;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=wA(i);s.writeFileSync(n,o)}},ue.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},ue.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},ue.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function Xl(n,e){const t=JSON.stringify(n);let i=256;for(let s in e){let o=parseInt(s);if(!(!o||o<256)){if(JSON.stringify(e[s])===t)return o;i<=o&&(i=o+1)}}return e[i]=n,i}function n0(n,e,t){const i=Xl(e.name,t);return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:i}]}function i0(n,e,t){const i={},s=new q.Parser(n,e);return i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1),i.name=t[s.parseUShort()]||{},i}function s0(n,e,t,i){const s=Xl(e.name,i),o=[{name:"nameID_"+n,type:"USHORT",value:s},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r<t.length;++r){const l=t[r].tag;o.push({name:"axis_"+n+" "+l,type:"FIXED",value:e.coordinates[l]<<16})}return o}function o0(n,e,t,i){const s={},o=new q.Parser(n,e);s.name=i[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 r0(n,e){const t=new Z.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:n.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:n.instances.length},{name:"instanceSize",type:"USHORT",value:4+n.axes.length*4}]);t.offsetToData=t.sizeOf();for(let i=0;i<n.axes.length;i++)t.fields=t.fields.concat(n0(i,n.axes[i],e));for(let i=0;i<n.instances.length;i++)t.fields=t.fields.concat(s0(i,n.instances[i],n.axes,e));return t}function a0(n,e,t){const i=new q.Parser(n,e),s=i.parseULong();ie.argument(s===65536,"Unsupported fvar table version.");const o=i.parseOffset16();i.skip("uShort",1);const r=i.parseUShort(),l=i.parseUShort(),a=i.parseUShort(),c=i.parseUShort(),u=[];for(let h=0;h<r;h++)u.push(i0(n,e+o+h*l,t));const f=[],p=e+o+r*l;for(let h=0;h<a;h++)f.push(o0(n,p+h*c,u,t));return{axes:u,instances:f}}const l0={make:r0,parse:a0},We=new Array(10);We[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(H.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(H.coverage),values:this.parseValueRecordList()};ie.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},We[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();ie.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(H.coverage),s=this.parseUShort(),o=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:o,pairSets:this.parseList(H.pointer(H.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(o)}})))};if(t===2){const r=this.parsePointer(H.classDef),l=this.parsePointer(H.classDef),a=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:o,classDef1:r,classDef2:l,class1Count:a,class2Count:c,classRecords:this.parseList(a,H.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(o)}}))}}},We[3]=function(){return{error:"GPOS Lookup 3 not supported"}},We[4]=function(){return{error:"GPOS Lookup 4 not supported"}},We[5]=function(){return{error:"GPOS Lookup 5 not supported"}},We[6]=function(){return{error:"GPOS Lookup 6 not supported"}},We[7]=function(){return{error:"GPOS Lookup 7 not supported"}},We[8]=function(){return{error:"GPOS Lookup 8 not supported"}},We[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function c0(n,e){e=e||0;const t=new H(n,e),i=t.parseVersion(1);return ie.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(We)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(We),variations:t.parseFeatureVariationsList()}}const d0=new Array(10);function u0(n){return new Z.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new Z.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new Z.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new Z.LookupList(n.lookups,d0)}])}const h0={parse:c0,make:u0};function f0(n){const e={};n.skip("uShort");const t=n.parseUShort();ie.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s<i;s+=1){const o=n.parseUShort(),r=n.parseUShort(),l=n.parseShort();e[o+","+r]=l}return e}function p0(n){const e={};n.skip("uShort"),n.parseULong()>1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const o=n.parseUShort();n.skip("uShort",3);for(let r=0;r<o;r+=1){const l=n.parseUShort(),a=n.parseUShort(),c=n.parseShort();e[l+","+a]=c}}return e}function g0(n,e){const t=new q.Parser(n,e),i=t.parseUShort();if(i===0)return f0(t);if(i===1)return p0(t);throw new Error("Unsupported kern table version ("+i+").")}const m0={parse:g0};function A0(n,e,t,i){const s=new q.Parser(n,e),o=i?s.parseUShort:s.parseULong,r=[];for(let l=0;l<t+1;l+=1){let a=o.call(s);i&&(a*=2),r.push(a)}return r}const y0={parse:A0};function C0(n,e){require("fs").readFile(n,function(i,s){if(i)return e(i.message);e(null,EA(s))})}function E0(n,e){const t=new XMLHttpRequest;t.open("get",n,!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 Jl(n,e){const t=[];let i=12;for(let s=0;s<e;s+=1){const o=q.getTag(n,i),r=q.getULong(n,i+4),l=q.getULong(n,i+8),a=q.getULong(n,i+12);t.push({tag:o,checksum:r,offset:l,length:a,compression:!1}),i+=16}return t}function w0(n,e){const t=[];let i=44;for(let s=0;s<e;s+=1){const o=q.getTag(n,i),r=q.getULong(n,i+4),l=q.getULong(n,i+8),a=q.getULong(n,i+12);let c;l<a?c="WOFF":c=!1,t.push({tag:o,offset:r,compression:c,compressedLength:l,length:a}),i+=20}return t}function ve(n,e){if(e.compression==="WOFF"){const t=new Uint8Array(n.buffer,e.offset+2,e.compressedLength-2),i=new Uint8Array(e.length);if(Zg(t,i),i.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");return{data:new DataView(i.buffer,0),offset:0}}else return{data:n,offset:e.offset}}function b0(n){let e,t;const i=new ue({empty:!0}),s=new DataView(n,0);let o,r=[];const l=q.getTag(s,0);if(l==="\0\0\0"||l==="true"||l==="typ1")i.outlinesFormat="truetype",o=q.getUShort(s,4),r=Jl(s,o);else if(l==="OTTO")i.outlinesFormat="cff",o=q.getUShort(s,4),r=Jl(s,o);else if(l==="wOFF"){const k=q.getTag(s,4);if(k==="\0\0\0")i.outlinesFormat="truetype";else if(k==="OTTO")i.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+l);o=q.getUShort(s,12),r=w0(s,o)}else throw new Error("Unsupported OpenType signature "+l);let a,c,u,f,p,h,A,C,m,y,E;for(let k=0;k<o;k+=1){const B=r[k];let x;switch(B.tag){case"cmap":x=ve(s,B),i.tables.cmap=Va.parse(x.data,x.offset),i.encoding=new za(i.tables.cmap);break;case"cvt ":x=ve(s,B),E=new q.Parser(x.data,x.offset),i.tables.cvt=E.parseShortList(B.length/2);break;case"fvar":c=B;break;case"fpgm":x=ve(s,B),E=new q.Parser(x.data,x.offset),i.tables.fpgm=E.parseByteList(B.length);break;case"head":x=ve(s,B),i.tables.head=ol.parse(x.data,x.offset),i.unitsPerEm=i.tables.head.unitsPerEm,e=i.tables.head.indexToLocFormat;break;case"hhea":x=ve(s,B),i.tables.hhea=rl.parse(x.data,x.offset),i.ascender=i.tables.hhea.ascender,i.descender=i.tables.hhea.descender,i.numberOfHMetrics=i.tables.hhea.numberOfHMetrics;break;case"hmtx":h=B;break;case"ltag":x=ve(s,B),t=ll.parse(x.data,x.offset);break;case"maxp":x=ve(s,B),i.tables.maxp=cl.parse(x.data,x.offset),i.numGlyphs=i.tables.maxp.numGlyphs;break;case"name":m=B;break;case"OS/2":x=ve(s,B),i.tables.os2=Js.parse(x.data,x.offset);break;case"post":x=ve(s,B),i.tables.post=Al.parse(x.data,x.offset),i.glyphNames=new zs(i.tables.post);break;case"prep":x=ve(s,B),E=new q.Parser(x.data,x.offset),i.tables.prep=E.parseByteList(B.length);break;case"glyf":u=B;break;case"loca":C=B;break;case"CFF ":a=B;break;case"kern":A=B;break;case"GPOS":f=B;break;case"GSUB":p=B;break;case"meta":y=B;break}}const I=ve(s,m);if(i.tables.name=ml.parse(I.data,I.offset,t),i.names=i.tables.name,u&&C){const k=e===0,B=ve(s,C),x=y0.parse(B.data,B.offset,i.numGlyphs,k),g=ve(s,u);i.glyphs=Tl.parse(g.data,g.offset,x,i)}else if(a){const k=ve(s,a);sl.parse(k.data,k.offset,i)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");const S=ve(s,h);if(al.parse(S.data,S.offset,i.numberOfHMetrics,i.numGlyphs,i.glyphs),ym(i),A){const k=ve(s,A);i.kerningPairs=m0.parse(k.data,k.offset)}else i.kerningPairs={};if(f){const k=ve(s,f);i.tables.gpos=h0.parse(k.data,k.offset),i.position.init()}if(p){const k=ve(s,p);i.tables.gsub=yl.parse(k.data,k.offset)}if(c){const k=ve(s,c);i.tables.fvar=l0.parse(k.data,k.offset,i.names)}if(y){const k=ve(s,y);i.tables.meta=Cl.parse(k.data,k.offset),i.metas=i.tables.meta}return i}function v0(n,e){(typeof window>"u"?C0:E0)(n,function(s,o){if(s)return e(s);let r;try{r=b0(o)}catch(l){return e(l,null)}return e(null,r)})}const ro=1e-12;function On(n){if(!Array.isArray(n)||n.length===0)return n||[];const e=n[0],t=n[n.length-1];if(!e||!t||e.length<2||t.length<2)return n;const i=e[0]??0,s=e[1]??0,o=t[0]??0,r=t[1]??0;return(Math.abs(i-o)>ro||Math.abs(s-r)>ro)&&n.push([i,s]),n}function Lt(n){let e=0;if(!n)return 0;for(let t=0;t<n.length-1;t++){const i=n[t],s=n[t+1];if(!i||!s)continue;const o=i[0]??0,r=i[1]??0,l=s[0]??0,a=s[1]??0;e+=o*a-l*r}return e/2}function ki(n,e=ro){const t=[];if(!n)return t;for(const i of n){if(!i||i.length<2)continue;const s=t[t.length-1],o=i[0]??0,r=i[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 I0(n,e,t,i,s=16){const o=[],r=n?.[0]??0,l=n?.[1]??0,a=t?.[0]??0,c=t?.[1]??0,u=i?.[0]??0,f=i?.[1]??0,p=e?.[0]??0,h=e?.[1]??0;for(let A=0;A<=s;A++){const C=A/s,m=1-C,y=m*m*m*r+3*m*m*C*a+3*m*C*C*u+C*C*C*p,E=m*m*m*l+3*m*m*C*c+3*m*C*C*f+C*C*C*h;o.push([y,E])}return o}function Zl(n,e){if(!n||!e)return!1;const t=n[0]??0,i=n[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 c=l[0]??0,u=l[1]??0,f=a[0]??0,p=a[1]??0;u>i!=p>i&&t<(f-c)*(i-u)/(p-u+0)+c&&(s=!s)}return s}function ao(n){return n?(Lt(n)<0&&n.reverse(),On(n),n):[]}function x0(n){return n?(Lt(n)>0&&n.reverse(),On(n),n):[]}function ec(n,e=16){if(!n||!Array.isArray(n.commands))return[];const t=[];let i=[];for(const s of n.commands){let o=function(l){const a=l.x!==void 0?l.x:0,c=l.y!==void 0?-l.y:0;return[a,c]};const r=s.type;if(r==="M")i.length&&t.push(ki(i)),i=[o(s)];else if(r==="L")i.push(o(s));else if(r==="Q"){const a=i[i.length-1]||o(s),c=[],u=s.x??0,f=s.y??0,p=s.x1??0,h=s.y1??0,A=a[0]??0,C=a[1]??0;for(let m=1;m<=e;m++){const y=m/e,E=1-y,I=E*E*A+2*E*y*p+y*y*u,S=E*E*C+2*E*y*h+y*y*-f;c.push([I,S])}c.length?i.push(...c):i.push(o(s))}else if(r==="C"){const a=i[i.length-1]||o(s),c=[s.x1||0,-(s.y1||0)],u=[s.x2||0,-(s.y2||0)],f=[s.x||0,-(s.y||0)],p=I0(a,f,c,u,e);p.length>1?i.push(...p.slice(1)):i.push(f)}else r==="Z"||r==="z"?(i.length&&t.push(ki(i)),i=[]):s.x!==void 0&&s.y!==void 0&&i.push(o(s))}return i.length&&t.push(ki(i)),t.map(s=>On(s)).filter(s=>s&&s.length>=4)}function lo(n,e){if(!n)return null;const t=n.map(i=>On(i.slice()));return{type:"Feature",geometry:{type:"Polygon",coordinates:t},properties:{...e.properties||{},rings:t.length,polygons:1}}}function B0(n,e,t={}){t=Object.assign({sampleSegments:16,simplifyTolerance:0,epsArea:1e-24,debug:!1,scale:1,widthScale:.6,fillWinding:"auto"},t||{scale:1});const i=!!t.debug;if(!n||!n.geometry||!Array.isArray(n.geometry.coordinates))return{type:"FeatureCollection",features:[]};const s=n.geometry.coordinates,o=n.properties||{},r=o.text||o.label||"",l=o.rotation??0,a=t.sampleSegments||16,c=t.epsArea||1e-24,f=o.height/.9||1,p=(t.scale||1)*f,h=-l*Math.PI/180,A=Math.cos(h),C=Math.sin(h),m=o.attachmentPoint||"bottom-left",y=[];if(!e||typeof e.getPaths!="function")return{type:"FeatureCollection",features:y};const E=e.getPaths(r,0,0,t.fontSize||1)||[];let I=[];for(const L of E){const G=ec(L,a);for(const N of G)if(N)for(const v of N)v&&I.push(v)}let S=1/0,k=1/0,B=-1/0,x=-1/0;for(const L of I){if(!L)continue;const G=L[0]??0,N=L[1]??0;S=Math.min(S,G),k=Math.min(k,N),B=Math.max(B,G),x=Math.max(x,N)}const g=B-S,R=x-k;let M=0,F=0;switch(m){case"top-left":M=0,F=-R;break;case"top-center":M=-g/2,F=R;break;case"top-right":M=-g,F=R;break;case"center-left":M=0,F=R/2;break;case"center":M=-g/2,F=R/2;break;case"center-right":M=-g,F=R/2;break;case"bottom-left":M=0,F=0;break;case"bottom-center":M=-g/2,F=0;break;case"bottom-right":M=-g,F=0;break;default:M=0,F=0}for(const L of E){const G=ec(L,a);if(!G||G.length===0)continue;const N=G.map(P=>{if(!P)return[];const _=P.map(O=>{if(!O)return[0,0];let D=(O[0]??0)+M,U=(O[1]??0)+F;D=D*(t.widthScale||.6);const V=D*A-U*C,$=D*C+U*A;return[s[0]+V*p,s[1]+$*p]});return On(ki(_))}).filter(P=>P&&P.length>=4&&Math.abs(Lt(P))>c);if(N.length===0)continue;let v=1;if(t.fillWinding==="positive")v=1;else if(t.fillWinding==="negative")v=-1;else{let P=0,_=-1;for(let U=0;U<N.length;U++){const V=N[U];if(!V)continue;const $=Lt(V);Math.abs($)>_&&(_=Math.abs($),P=U)}const O=N[P],D=O?Lt(O):0;v=D>=0?1:-1,i&&console.log("[simple] auto fillSign=",v,"largest signed area=",D)}const w=N.map((P,_)=>({idx:_,ring:P,signedArea:Lt(P),absArea:Math.abs(Lt(P))}));for(const P of w)P.isFilled=P.signedArea*v>0,i&&console.log("[simple] ring",P.idx,"signedArea=",P.signedArea.toExponential(),"isFilled=",P.isFilled);const b=w.filter(P=>P.isFilled).sort((P,_)=>P.absArea-_.absArea),T=w.filter(P=>!P.isFilled).sort((P,_)=>_.absArea-P.absArea);for(const P of b)P.holes=[];for(const P of T){const _=(function(D){let U=0,V=0;if(!D||D.length===0)return[0,0];for(const $ of D)$&&(U+=$[0]??0,V+=$[1]??0);return[U/D.length,V/D.length]})(P.ring);let O=null;for(const D of b)Zl(_,D.ring)&&(O===null||D.absArea<O.absArea&&D.idx<P.idx||D.absArea>O.absArea&&D.idx<P.idx&&T.length==1)&&(O=D);if(O){if(O.absArea<P.absArea&&T.length>1)for(const D of b)Zl(_,D.ring)&&D.absArea>P.absArea&&D.holes.push(P.ring);else O.holes.push(P.ring);P.assigned=!0}else P.assigned=!1,i&&console.log("[simple] hole not assigned idx=",P.idx)}for(const P of b){const _=ao(P.ring.slice()),O=(P.holes||[]).map(D=>x0(D.slice()));y.push(lo([_,...O],n))}for(const P of T)P.assigned||y.push(lo([ao(P.ring.slice())],n));if(b.length===0)for(const P of w)y.push(lo([ao(P.ring.slice())],n))}return{type:"FeatureCollection",features:y}}class S0 extends tt{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,i=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=i.getCatesian3FromPX(s.position);o&&(i.positions=[o],i._centerCoord=o,i.createLabel(o,function(){i.endCreate(e)}))},t.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(function(s){if(!s||!s.position)return;i.getCatesian3FromPX(s.position)&&i.state},t.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(function(s){!s||!s.position||i.endCreate()},t.ScreenSpaceEventType.RIGHT_CLICK)}catch(t){console.error("启动创建标签功能时出错:",t),e&&e(null)}}createLabel(e,t){const i=window.Cesium||this.viewer._cesiumWidget.cesium||this.viewer.scene.cesium,s=this;if(!e){console.error("创建标签时位置参数无效"),t&&t();return}if(!i){console.error("创建标签时无法获取Cesium对象"),t&&t();return}this.clearPolygonEntities(),v0(this.fontUrl,(o,r)=>{try{if(o){console.error("加载字体失败:",o),t&&t();return}const l=i.Cartographic.fromCartesian(e),a=i.Math.toDegrees(l.longitude),c=i.Math.toDegrees(l.latitude),u={type:"Feature",geometry:{type:"Point",coordinates:[a,c]},properties:{text:s.labelText||"",rotation:0}},f={sampleSegments:16,fontSize:s.fontSize,scale:10},p=B0(u,r,f);if(!p||!p.features||!Array.isArray(p.features)){console.error("文本转换为多边形失败"),t&&t();return}s.drawGeoJsonLocal(p,[a,c],1,r),s.entity={_centerCoord:s._centerCoord,_plotInstance:s._plotInstance,position:e,label:{text:s.labelText},updatePosition:function(h){s.updatePositions([h])},getPosition:function(){return s._centerCoord},type:s.type,objId:s.objId,isDraggable:!0,setPosition:function(h){s._centerCoord=h,s.positions[0]=h,s.createLabel(h)}},s.addClickEditHandler(),t&&t()}catch(l){console.error("创建文本标签时发生错误:",l);try{s.clearPolygonEntities()}catch(a){console.error("清理标签多边形实体时出错:",a)}t&&t()}})}drawGeoJsonLocal(e,t,i=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),c=o.Transforms.eastNorthUpToFixedFrame(a),u=i*1;this.clearPolygonEntities();let f=[];for(const I of e.features||[]){if(!I||!I.geometry||I.geometry.type!=="Polygon")continue;const S=I.geometry.coordinates||[];for(const k of S)k&&Array.isArray(k)&&(f=f.concat(k))}let p=1/0,h=1/0,A=-1/0,C=-1/0;for(const I of f)Array.isArray(I)&&I.length>=2&&(p=Math.min(p,I[0]),h=Math.min(h,I[1]),A=Math.max(A,I[0]),C=Math.max(C,I[1]));const m=(p+A)/2,y=(h+C)/2,E=I=>{const S=(I[0]-m)*u,k=(I[1]-y)*u,B=new o.Cartesian3(S,k,0);return o.Matrix4.multiplyByPoint(c,B,new o.Cartesian3)};for(const I of e.features||[]){if(!I||!I.geometry||I.geometry.type!=="Polygon")continue;const S=I.geometry.coordinates||[];if(S.length>0)try{const k=S[0]||[];if(k.length===0)continue;const B=k.map(E);let x;if(S.length>1){const R=S.slice(1).map(M=>!M||!Array.isArray(M)||M.length===0?null:new o.PolygonHierarchy(M.map(E))).filter(Boolean);x=new o.PolygonHierarchy(B,R)}else x=new o.PolygonHierarchy(B);const g=this.viewer.entities.add({polygon:{hierarchy:x,material:o.Color.fromCssColorString(this.color||"#000000"),outline:!1},_labelOwner:this.objId});this.polygonEntities.push(g)}catch(k){console.warn("创建多边形实体时出错:",k);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(i){if(!i||!i.position)return;const s=e.viewer.scene.pick(i.position);t.defined(s)&&s.id&&s.id._labelOwner===e.objId&&(i.preventDefault(),e.editText())},t.ScreenSpaceEventType.LEFT_CLICK),this.editHandler.setInputAction(function(i){if(!i||!i.position)return;const s=e.viewer.scene.pick(i.position);t.defined(s)&&s.id&&s.id._labelOwner===e.objId&&(i.preventDefault(),e.openStyleEditor())},t.ScreenSpaceEventType.RIGHT_CLICK)}editText(){const e=this;(function(i,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=i,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 c=document.createElement("div");c.style.display="flex",c.style.justifyContent="flex-end",c.style.gap="10px";const u=document.createElement("button");u.textContent="取消",u.addEventListener("click",function(){document.body.removeChild(o),s(null)});const f=document.createElement("button");f.textContent="确认",f.addEventListener("click",function(){document.body.removeChild(o),s(a.value)}),c.appendChild(u),c.appendChild(f),r.appendChild(l),r.appendChild(a),r.appendChild(c),o.appendChild(r),document.body.appendChild(o),a.focus();const p=function(h){h.key==="Escape"&&(document.body.removeChild(o),document.removeEventListener("keydown",p),s(null))};document.addEventListener("keydown",p)})(this.labelText,function(i){i!==null&&(e.labelText=i||"点击编辑文本",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 i=t.Cartesian3.add(this._centerCoord,e,new t.Cartesian3);this.updatePositions([i])}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(i,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 c=document.createElement("label");c.textContent="文本颜色: ",c.style.display="block",c.style.marginBottom="5px";const u=document.createElement("input");u.type="color",u.value=i.color,u.style.width="50px",a.appendChild(c),a.appendChild(u);const f=document.createElement("div");f.style.marginBottom="15px";const p=document.createElement("label");p.textContent="字体大小: ",p.style.display="block",p.style.marginBottom="5px";const h=document.createElement("input");h.type="number",h.value=i.fontSize,h.min="8",h.max="200",h.step="1",h.style.width="100%",h.style.padding="5px",h.style.boxSizing="border-box",f.appendChild(p),f.appendChild(h);const A=document.createElement("div");A.style.display="flex",A.style.justifyContent="flex-end",A.style.gap="10px",A.style.marginTop="20px";const C=document.createElement("button");C.textContent="取消",C.addEventListener("click",function(){document.body.removeChild(o),s(null)});const m=document.createElement("button");m.textContent="确认",m.addEventListener("click",function(){document.body.removeChild(o),s({color:u.value,fontSize:parseInt(h.value)})}),A.appendChild(C),A.appendChild(m),r.appendChild(l),r.appendChild(a),r.appendChild(f),r.appendChild(A),o.appendChild(r),document.body.appendChild(o);const y=function(E){E.key==="Escape"&&(document.body.removeChild(o),document.removeEventListener("keydown",y),s(null))};document.addEventListener("keydown",y)})(this.getStyle(),function(i){i&&e.setStyle(i)})}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 M0 extends tt{constructor(e,t){super(e,t),this.type="point",this.viewer=e;let i={color:Cesium.Color.AQUA,pixelSize:10,outlineWidth:1};this.style=Object.assign(i,t||{}),this.position=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new yt(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(i){let s=t.getCatesian3FromPX(i.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(i){t.prompt.update(i.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 i=e instanceof Cesium.Cartesian3?e:Cesium.Cartesian3.fromDegrees(e[0],e[1],e[2]);this.position=i,i&&(this.entity=this.createPoint(i),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,i=t.color.getValue();e.colorAlpha=i.alpha,e.color=new Cesium.Color(i.red,i.green,i.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?ce.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,i;this.modifyHandler.setInputAction(function(s){let o=t.viewer.scene.pick(s.position);Cesium.defined(o)&&o.id&&(i=o.id,t.forbidDrawWorld(!0))},Cesium.ScreenSpaceEventType.LEFT_DOWN),this.modifyHandler.setInputAction(function(s){if(!i)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){i&&(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 T0 extends tt{constructor(e,t){super(e,t),this.type="polygon",this.viewer=e,this.entity=null,this.polyline=null;let i={outlineColor:"#000000",outlineWidth:2};this.style=Object.assign(i,t||{}),this.outline=null}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new yt(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(i){let s=t.getCatesian3FromPX(i.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(i){if(t.positions.length<1){t.prompt.update(i.endPosition,"单击开始绘制"),t.state="startCreate";return}t.prompt&&t.prompt.update(i.endPosition,"双击结束,右键取消上一步");let s=t.getCatesian3FromPX(i.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(i){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(i.endPosition,"单击开始绘制"),t.positions=[],t.movePush=!1))},Cesium.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(function(i){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 i=e[0]instanceof Cesium.Cartesian3?e:ce.lnglatsToCartesians(e);if(i){this.entity=this.createPolygon(),this.polyline=this.createPolyline(),this.polyline.show=this.style.outline,this.positions=i;for(let s=0;s<i.length;s++){let o=i[s],r=Cesium.Cartographic.fromCartesian(i[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 i=this.polyline.polyline;if(i&&this.polyline.show){e.outlineWidth=i.width.getValue(),e.outline=!0;let s=i.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 D0 extends tt{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 yt(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(i){const s=t.getCatesian3FromPX(i.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(i){if(!t.entity){t.prompt?.update(i.endPosition,"单击开始绘制");return}t.prompt?.update(i.endPosition,"单击结束");const s=t.getCatesian3FromPX(i.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(i){const s=t.viewer.scene.pick(i.position);if(!s?.id)return;t.modifyPoint=s.id;const o=t.getCatesian3FromPX(i.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(i){if(!t.modifyPoint)return;const s=t.getCatesian3FromPX(i.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,i=this._calcCornerCartesian("rightup"),s=this.rightdown;return[e,s,i,t,e]}_calcCornerCartesian(e){const t=Cesium.Ellipsoid.WGS84,i=t.cartesianToCartographic(this.leftup),s=t.cartesianToCartographic(this.rightdown),o=Math.min(i.longitude,s.longitude),r=Math.max(i.longitude,s.longitude),l=Math.min(i.latitude,s.latitude),a=Math.max(i.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 i=Cesium.Ellipsoid.WGS84,s=i.cartesianToCartographic(this.leftup),o=i.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),c=Math.max(s.latitude,o.latitude);const u=i.cartesianToCartographic(e);t==="leftdown"?(r=u.longitude,a=u.latitude):(l=u.longitude,c=u.latitude),this.leftup=Cesium.Cartesian3.fromRadians(r,c),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 i=t.x-e.x,s=t.y-e.y,o=t.z-e.z;this.leftup=new Cesium.Cartesian3(this.leftup.x+i,this.leftup.y+s,this.leftup.z+o),this.rightdown=new Cesium.Cartesian3(this.rightdown.x+i,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"),c=this._calcCornerCartesian("rightup");this.leftdownPoint=this.createPoint(a),this.leftdownPoint.typeAttr="leftdown",this.leftdownPoint.show=this.state==="editing",this.rightupPoint=this.createPoint(c),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?ce.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 i=t.color instanceof Cesium.Color?t.color:Cesium.Color.fromCssColorString(t.color||"#00FF00");t.colorAlpha!=null&&(i=i.withAlpha(t.colorAlpha)),this.entity.polyline.material=i,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 i=e[0]instanceof Cesium.Cartesian3?e:ce.lnglatsToCartesians(e);if(!i||i.length<2)return!1;if(i.length===2)this.leftup=Cesium.Cartesian3.clone(i[0]),this.rightdown=Cesium.Cartesian3.clone(i[1]);else if(i.length>=4){let s=1/0,o=1/0,r=-1/0,l=-1/0;i.forEach(a=>{const c=Cesium.Ellipsoid.WGS84.cartesianToCartographic(a);c&&(s=Math.min(s,c.longitude),o=Math.min(o,c.latitude),r=Math.max(r,c.longitude),l=Math.max(l,c.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 k0 extends tt{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],i=this.createPoint(t);this.style.clampToGround&&(i.point.heightReference=1),i.wz=this.controlPoints.length,this.controlPoints.push(i)}}start(e){!this.prompt&&this.promptStyle.show&&(this.prompt=new yt(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(i){let s=t.getCatesian3FromPX(i.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(i){if(t.state="creating",t.positions.length<1){t.prompt.update(i.endPosition,"单击开始绘制"),t.state="startCreate";return}t.prompt.update(i.endPosition,"右键取消上一步,双击结束");let s=t.getCatesian3FromPX(i.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(i){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(i.endPosition,"单击开始绘制"),t.movePush=!1,t.positions=[]))},Cesium.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(function(i){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 i=e[0]instanceof Cesium.Cartesian3?e:util.lnglatsToCartesians(e);if(i){this.entity=this.createPolyline(this.style),this.positions=i,t&&t(this.entity);for(let s=0;s<i.length;s++){let o=i[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 i=t.material.color.getValue();e.colorAlpha=i.alpha,e.color=new Cesium.Color(i.red,i.green,i.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 i=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"||(i=s),i}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],i=this.createPoint(t);this.style.clampToGround&&(i.point.heightReference=1),i.wz=this.controlPoints.length,this.controlPoints.push(i)}}getPositions(e){return e?util.cartesiansToLnglats(this.positions,this.viewer):this.positions}}class P0 extends tt{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(()=>Oa).then(({default:i})=>{this.prompt=new i(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(i){t.state="creating",t.isDrawing=!0,t.forbidDrawWorld(!0),t.positions=[],t._stagingBuffer.length=0,t.lastAddPosition=null;let s=t._fastPick(i.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(i){if(!t.isDrawing){t.prompt&&i&&i.endPosition&&t.prompt.update(i.endPosition,"单击开始绘制");return}if(t.prompt&&i&&i.endPosition&&t.prompt.update(i.endPosition,"松键结束"),!i||!i.endPosition||t.positions.length+t._stagingBuffer.length>=t.maxPositions)return;let s=t._fastPick(i.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(i){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(i){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,i=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(i)}_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 i=this.viewer.camera.getPickRay(e);let s=null;return i&&(s=this.viewer.scene.globe.pick(i,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 i=this.viewer.camera.getPickRay(e);i&&(t=this.viewer.scene.globe.pick(i,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 i=e;if(t>0){const l=(u,f)=>{if(!u||u.length<2)return u;f=Math.max(1,f|0);const p=[u[0]],h=u.length;for(let A=0;A<h-1;A++){const C=A>0?u[A-1]:u[A],m=u[A],y=u[A+1],E=A+2<h?u[A+2]:u[A+1];for(let I=1;I<f;I++){const S=I/f,k=S*S,B=k*S,x=-.5*C.x+1.5*m.x-1.5*y.x+.5*E.x,g=-.5*C.y+1.5*m.y-1.5*y.y+.5*E.y,R=-.5*C.z+1.5*m.z-1.5*y.z+.5*E.z,M=C.x-2.5*m.x+2*y.x-.5*E.x,F=C.y-2.5*m.y+2*y.y-.5*E.y,L=C.z-2.5*m.z+2*y.z-.5*E.z,G=-.5*C.x+.5*y.x,N=-.5*C.y+.5*y.y,v=-.5*C.z+.5*y.z,w=m.x,b=m.y,T=m.z,P=x*B+M*k+G*S+w,_=g*B+F*k+N*S+b,O=R*B+L*k+v*S+T;p.push(new Cesium.Cartesian3(P,_,O))}p.push(y)}return p},a=Math.max(1,Number(this.style.curveResolution)||1);i.length<200&&a>1&&(i=l(i,a));const c=u=>{if(!u||u.length<2)return u;const f=[];f.push(u[0]);for(let p=0;p<u.length-1;p++){const h=u[p],A=u[p+1],C=new Cesium.Cartesian3(h.x*.75+A.x*.25,h.y*.75+A.y*.25,h.z*.75+A.z*.25),m=new Cesium.Cartesian3(h.x*.25+A.x*.75,h.y*.25+A.y*.75,h.z*.25+A.z*.75);f.push(C),f.push(m)}return f.push(u[u.length-1]),f};i=i.slice(),i.length<300&&(i=c(i),t===2&&i.length<300&&(i=c(i)))}const s=(Number(this.style.angleThreshold)||6)*(Math.PI/180),o=this.positions,r=(l,a,c,u)=>{if(!l||!a||!c)return!1;const f=a.x-l.x,p=a.y-l.y,h=a.z-l.z,A=c.x-a.x,C=c.y-a.y,m=c.z-a.z,y=Math.hypot(f,p,h),E=Math.hypot(A,C,m);if(y===0||E===0)return!1;const I=(f*A+p*C+h*m)/(y*E),S=Math.max(-1,Math.min(1,I)),k=Math.acos(S);return Math.abs(k)<=u};for(let l=0;l<i.length;l++){const a=i[l];if(o.length===0){o.push(Cesium.Cartesian3.clone(a));continue}const c=o[o.length-1];if(!(Cesium.Cartesian3.distance(c,a)<=this.minDistance*.5)){if(o.length>=2){const f=o[o.length-2],p=o[o.length-1],h=a;if(r(f,p,h,s)){o.pop(),o.push(Cesium.Cartesian3.clone(h));continue}}if(o.push(Cesium.Cartesian3.clone(a)),o.length>this.maxPositions){const f=o.length-this.maxPositions;f>0&&o.splice(0,f)}}}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(i=>Cesium.Cartesian3.clone(i));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),i=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 i.objId=this.objId||null,this.entity=i,i}getMaterial(e,t){t=t||{};try{let i=t.color||Cesium.Color.RED;typeof i=="string"&&(i=Cesium.Color.fromCssColorString(i));const s=t.colorAlpha!==void 0?t.colorAlpha:1;return i=i.withAlpha(s),i}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(i=>Cesium.Cartesian3.clone(i)):t=ce&&ce.lnglatsToCartesians?ce.lnglatsToCartesians(e):e,!t||t.length===0)return!1;this.positions=t.map(i=>Cesium.Cartesian3.clone(i)),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 i=e[0]instanceof Cesium.Cartesian3?e:ce.lnglatsToCartesians(e);if(!i||i.length<1)return!1;this.positions=i.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 F0 extends tt{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(()=>Oa).then(({default:i})=>{this.prompt=new i(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(i){if(t.state==="startCreate"){t.state="creating",t._finalized=!1;let s=t.getCatesian3FromPX(i.position);if(!s)return;t.positions=[t.Cesium.Cartesian3.clone(s),t.Cesium.Cartesian3.clone(s)],t._createLineEntity(),t._createArrowEntity(),t._createControlPoints(),t.prompt&&i&&i.position&&t.prompt.update(i.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(i){if(t.state==="startCreate"){t.prompt&&i&&i.endPosition&&t.prompt.update(i.endPosition,"单击开始绘制");return}if(t.state==="creating"){let s=t.getCatesian3FromPX(i.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(i=>{try{t.viewer.entities.remove(i)}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 i=this.Cesium.Cartesian3.distance(e,t);if(i<=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:i*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 c=this.Cesium.Transforms.eastNorthUpToFixedFrame(t),u=this.Cesium.Matrix4.getColumn(c,2,new this.Cesium.Cartesian3),f=new this.Cesium.Cartesian3(a.x-u.x*this.Cesium.Cartesian3.dot(a,u),a.y-u.y*this.Cesium.Cartesian3.dot(a,u),a.z-u.z*this.Cesium.Cartesian3.dot(a,u));let p;this.Cesium.Cartesian3.magnitudeSquared(f)<1e-6?p=this.Cesium.Matrix4.getColumn(c,0,new this.Cesium.Cartesian3):(this.Cesium.Cartesian3.normalize(f,f),p=this.Cesium.Cartesian3.cross(u,f,new this.Cesium.Cartesian3),this.Cesium.Cartesian3.normalize(p,p));const h=this.Cesium.Cartesian3.multiplyByScalar(a,-l,new this.Cesium.Cartesian3),A=this.Cesium.Cartesian3.add(t,h,new this.Cesium.Cartesian3),C=this.style.arrowWidthScale!==void 0?this.style.arrowWidthScale:1,m=Math.sin(this.arrowAngle)*l*C,y=this.Cesium.Cartesian3.multiplyByScalar(p,m,new this.Cesium.Cartesian3),E=this.Cesium.Cartesian3.multiplyByScalar(p,-m,new this.Cesium.Cartesian3),I=this.Cesium.Cartesian3.add(A,y,new this.Cesium.Cartesian3),S=this.Cesium.Cartesian3.add(A,E,new this.Cesium.Cartesian3);return[t,I,S,t]}_createLineEntity(){if(this.lineEntity){try{this.viewer.entities.remove(this.lineEntity)}catch{}this.lineEntity=null}const e=this,t=this._getMaterial(),i=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:i,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(),i=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:i,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 i=t.positions[0],s=t.positions[1];return t._computeArrowPositions(i,s)},!1)}catch{}if(!this._editRenderHandler){this._editRenderHandler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);const t=this;this._editRenderHandler.setInputAction(function(i){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 i=e[0],s=e[1];if(!(i instanceof this.Cesium.Cartesian3))if(Array.isArray(i)&&i.length>=2)i=this.Cesium.Cartesian3.fromDegrees(i[0],i[1]),s=this.Cesium.Cartesian3.fromDegrees(s[0],s[1]);else return!1;return this.positions=[this.Cesium.Cartesian3.clone(i),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],i=e[1];if(!(t instanceof this.Cesium.Cartesian3))if(Array.isArray(t)&&t.length>=2)t=this.Cesium.Cartesian3.fromDegrees(t[0],t[1]),i=this.Cesium.Cartesian3.fromDegrees(i[0],i[1]);else return!1;return this.positions=[this.Cesium.Cartesian3.clone(t),this.Cesium.Cartesian3.clone(i)],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 R0{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 i=this.createByType(e);if(i)return i.attr=e||{},i.start(function(s){t.nowDrawEntityObj=void 0,t.entityObjArr.push(i),e.success&&e.success(i,s),t.endCreateFun&&t.endCreateFun(i,s),e.show==!1&&i.setVisible(!1),t.canEdit&&t.fireEdit&&(i.startEdit(function(){t.editingFun&&t.editingFun(i,i.entity)}),t.nowEditEntityObj=i,t.startEditFun&&t.startEditFun(i,s))}),this.nowDrawEntityObj=i,i}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,i=this.createByType(e);if(i)return i.attr=e,i.createByPositions(e.positions,function(s){t.entityObjArr.push(i),i.setStyle(e.style),e.success&&e.success(i,s),t.endCreateFun&&t.endCreateFun(i,s),e.show==!1&&i.setVisible(!1),t.canEdit&&t.fireEdit&&(i.startEdit(function(){t.editingFun&&t.editingFun(i,i.entity)}),t.startEditFun&&t.startEditFun(i,s),t.nowEditEntityObj=i)}),i}createByGeojson(e){let{features:t}=e,i=[];for(let s=0;s<t.length;s++){let o=t[s];const{properties:r,geometry:l}=o;let a=r.plotType;const c=l.type,u=l.coordinates;let f=[],p="";switch(c){case"LineString":f=ce.lnglatsToCartesians(u),p="polyline";break;case"Polygon":f=ce.lnglatsToCartesians(u[0]),p="polygon";break;case"Point":f=ce.lnglatsToCartesians([u])[0],p=a;break}this.fireEdit=!1;let h=this.createByPositions({type:p,styleType:a,positions:f,style:r.style});h&&i.push(h)}return i}toGeojson(){let e={type:"FeatureCollection",features:[]};if(this.entityObjArr.length==0)return null;for(let t=0;t<this.entityObjArr.length;t++){let i=this.entityObjArr[t],s=i.getPositions(!0),o=[];for(let c=0;c<s.length;c++)o.push([s[c][0],s[c][1]]);let r=i.getStyle(),l=this.transType(i.type),a={type:"Feature",properties:{plotType:i.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,i.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 i={};if(t)for(let s=0;s<this.entityObjArr.length;s++){let o=this.entityObjArr[s];if(o.attr[e]==t){i.entityObj=o,i.index=s;break}}else for(let s=0;s<this.entityObjArr.length;s++){let o=this.entityObjArr[s];if(o.attr.id==e){i.entityObj=o,i.index=s;break}}return i}setVisible(e,t){let i=this.getEntityObjByField("id",e);i.entityObj&&i.entityObj.setVisible(t)}getEntityObjByObjId(e){if(!e)return;let t={};for(let i=0;i<this.entityObjArr.length;i++){let s=this.entityObjArr[i];if(s.objId==e){t.entityObj=s,t.index=i;break}}return t}getEntityObjById(e){if(!e)return;let t={};for(let i=0;i<this.entityObjArr.length;i++){let s=this.entityObjArr[i];if(s.attr.id==e){t.entityObj=s,t.index=i;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 i=e.viewer.scene.drillPick(t.position)||[];let s=-1,o;for(let r=0;r<i.length&&s===-1;r++){const l=i[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 i=e.viewer.scene.drillPick(t.position)||[];let s;for(let o=0;o<i.length;o++){const r=i[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 i=window.document.createElement("span");i.style.background="rgba(0,0,0,0.5)",i.style.position="absolute",i.style.color="white",i.style.left=e.x+10+"px",i.style.top=e.y+10+"px",i.style.padding="4px",i.style.cursor="pointer",i.id="easy3d-plot-delete",i.setAttribute("objId",t),i.innerHTML="删除",window.document.getElementById(this.viewer.container.id).appendChild(i);const o=window.document.getElementById("easy3d-plot-delete");if(!o)return;let r=this;o.addEventListener("click",l=>{let a=i.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,i="";return e=e||{},e.type=="polyline"&&(t=new k0(this.viewer,e.style),i="折线_"),e.type=="freehandLine"&&(t=new P0(this.viewer,e.style),i="手绘线_"),e.type=="polygon"&&(t=new T0(this.viewer,e.style),i="面_"),e.type=="billboard"&&(t=new $g(this.viewer,e.style),i="图标_"),(e.type=="circle"||e.type=="ellipse")&&(t=new Kg(this.viewer,e.style),i="圆_"),e.type=="rectangle"&&(t=new D0(this.viewer,e.style),i="矩形_"),e.type=="gltfModel"&&(t=new qg(this.viewer,e.style),i="模型_"),e.type=="point"&&(t=new M0(this.viewer,e.style),i="点_"),e.type=="label"&&(t=new S0(this.viewer,e.style),i="文字_"),e.type=="arrow"&&(t=new F0(this.viewer,e.style)),t&&(t.name=i+new Date().getTime()),t}}class tc{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 R0(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 i=null;if(t._plotInstance&&typeof t._plotInstance.syncFromEntity=="function")try{t._plotInstance.syncFromEntity();const s=t._plotInstance;s.leftup&&s.rightdown&&(i=this.Cesium.Cartesian3.midpoint(s.leftup,s.rightdown,new this.Cesium.Cartesian3))}catch(s){console.warn("plotInstance.syncFromEntity failed",s)}if(!i){if(e.positions&&e.positions.length)i=this.calculateCenter(e.positions);else if(t.position&&t.position.getValue)i=t.position.getValue();else if(t.polyline&&t.polyline.positions&&t.polyline.positions.getValue){const s=t.polyline.positions.getValue();i=this.calculateCenter(s)}else if(t.polygon&&t.polygon.hierarchy&&t.polygon.hierarchy.getValue){const s=t.polygon.hierarchy.getValue().positions;i=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;i=this.Cesium.Cartesian3.fromRadians(o,r,0)}catch{}}i&&(this.centerHandle=this.viewer.entities.add({position:i,point:{pixelSize:10,color:this.Cesium.Color.WHITE,outlineColor:this.Cesium.Color.BLUE,outlineWidth:2}}),this.addDragHandler(e,i))}calculateCenter(e){if(!e||e.length===0)return null;const t=e.map(r=>r);let i=0,s=0,o=0;for(let r=0;r<t.length;r++)i+=t[r].x,s+=t[r].y,o+=t[r].z;return new this.Cesium.Cartesian3(i/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 i=t.polyline.positions.getValue();return Array.isArray(i)?i.slice():[]}if(t.polygon&&t.polygon.hierarchy&&t.polygon.hierarchy.getValue){const i=t.polygon.hierarchy.getValue();return i&&i.positions?i.positions.slice():[]}if(t.position&&t.position.getValue)return[t.position.getValue()];if(t.rectangle&&t.rectangle.coordinates&&t.rectangle.coordinates.getValue){const i=t.rectangle.coordinates.getValue();return[this.Cesium.Cartesian3.fromDegrees(i.west,i.south),this.Cesium.Cartesian3.fromDegrees(i.east,i.south),this.Cesium.Cartesian3.fromDegrees(i.east,i.north),this.Cesium.Cartesian3.fromDegrees(i.west,i.north)]}return[]}addDragHandler(e,t){if(console.log("移动线段"),this._dragHandler){try{this._dragHandler.destroy()}catch{}this._dragHandler=null}let i=!1,s,o=0;const r=16,l=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);this._dragHandler=l;const a=c=>{let u;try{u=this.viewer.scene.pickPosition(c)}catch{}if(!this.Cesium.defined(u)){const f=this.viewer.camera.getPickRay(c);f&&(u=this.viewer.scene.globe.pick(f,this.viewer.scene))}return this.Cesium.defined(u)||(u=this.viewer.scene.camera.pickEllipsoid(c,this.viewer.scene.globe.ellipsoid)),u};l.setInputAction(c=>{let u=!1;const f=this.viewer.scene.drillPick(c.position)||[];for(let p=0;p<f.length;p++){const h=f[p].id;if(h&&h===this.centerHandle){u=!0;break}}if(u){i=!0;const p=a(c.position);this.Cesium.defined(p)&&(s=p.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(c=>{if(!i||!this.Cesium.defined(s))return;const u=performance.now();if(u-o<r)return;o=u;const f=a(c.endPosition);if(!this.Cesium.defined(f))return;const p=this.Cesium.Cartesian3.subtract(f,s,new this.Cesium.Cartesian3);if(this.centerHandle&&this.centerHandle.position&&this.centerHandle.position.setValue){const h=this.centerHandle.position.getValue(this.Cesium.JulianDate.now());if(h){const A=this.Cesium.Cartesian3.add(h,p,new this.Cesium.Cartesian3);this.centerHandle.position.setValue(A)}}this.moveEntity(e,p);try{this.viewer.scene.requestRender()}catch{}s=f.clone()},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE),l.setInputAction(()=>{if(i){i=!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 c=e.getEntity();if(c.state="done",c&&c.rectangle&&c.rectangle.coordinates)try{const u=c.rectangle.coordinates.getValue?c.rectangle.coordinates.getValue():c.rectangle.coordinates;u&&c.rectangle.coordinates.setValue(u)}catch(u){console.warn("Failed to refresh rectangle coordinates",u)}e&&this.selectedEntityObj!==e&&this.showEntityOutline(e)}},this.Cesium.ScreenSpaceEventType.LEFT_UP)}moveEntity(e,t){const i=e.getEntity();if(!i)return;const s=o=>this.Cesium.Cartesian3.add(o,t,new this.Cesium.Cartesian3);if(i.position){const o=i.position.getValue?i.position.getValue():i.position,r=s(o);i.position.setValue?i.position.setValue(r):i.position=r,i.state="moving",e.positions&&e.positions.length===1&&(e.positions[0]=r);return}if(i.polyline){if(i._plotInstance&&i._plotInstance.type==="rectangle"&&typeof i._plotInstance.updatePositions=="function")try{const l=new this.Cesium.Cartesian3(t.x,t.y,t.z);if(i._plotInstance.updatePositions([l]))return}catch(l){console.warn("Failed to update rectangle positions:",l)}if(i._plotInstance&&i._plotInstance.type==="circle"&&typeof i._plotInstance.updatePositions=="function")try{const l=new this.Cesium.Cartesian3(t.x,t.y,t.z);if(i._plotInstance.updatePositions([l]))return}catch(l){console.warn("Failed to update circle positions:",l)}const r=(e.positions&&Array.isArray(e.positions)?e.positions:i.polyline.positions.getValue?i.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),i.polyline&&i.polyline.positions)try{i.polyline.positions instanceof this.Cesium.CallbackProperty||(i.polyline.positions=r)}catch{i.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 i=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:!i},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(c=>({x:c.x,y:c.y,z:c.z}));else{const c=o.getEntity?o.getEntity():o;if(c)try{if(c.polyline&&c.polyline.positions&&c.polyline.positions.getValue){const u=c.polyline.positions.getValue(this.viewer.clock.currentTime);Array.isArray(u)&&(a=u.map(f=>({x:f.x,y:f.y,z:f.z})))}else if(c.rectangle&&c.rectangle.coordinates&&c.rectangle.coordinates.getValue){const u=c.rectangle.coordinates.getValue(this.viewer.clock.currentTime);a=[{west:u.west,south:u.south,east:u.east,north:u.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 c=o.getEntity?o.getEntity():o;if(c&&c._plotInstance&&c._plotInstance.type==="circle"&&c._plotInstance.center&&c._plotInstance.radiusPoint){const u=c._plotInstance;a=[{x:u.center.x,y:u.center.y,z:u.center.z},{x:u.radiusPoint.x,y:u.radiusPoint.y,z:u.radiusPoint.z}]}else if(o.positions&&Array.isArray(o.positions)&&o.positions.length)a=o.positions.map(u=>({x:u.x,y:u.y,z:u.z}));else if(c)try{if(c.polyline&&c.polyline.positions&&c.polyline.positions.getValue){const u=c.polyline.positions.getValue(this.viewer.clock.currentTime);Array.isArray(u)&&(a=u.map(f=>({x:f.x,y:f.y,z:f.z})))}else if(c.ellipse&&c.ellipse.center&&c.ellipse.center.getValue&&c.ellipse.semiMajorAxis&&c.ellipse.semiMajorAxis.getValue){const u=c.ellipse.center.getValue(this.viewer.clock.currentTime),f=c.ellipse.semiMajorAxis.getValue(this.viewer.clock.currentTime);if(u&&f){const p={x:u.x,y:u.y,z:u.z||0},h={x:p.x+f,y:p.y,z:p.z};a=[p,h]}}}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 c={};try{const u=a.label.fillColor&&a.label.fillColor.getValue?a.label.fillColor.getValue(this.viewer.clock.currentTime):a.label.fillColor;u&&(c.color=u)}catch{}a.label.font&&(c.font=a.label.font),l.style=c}}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 c=a.label.text.getValue?a.label.text.getValue(this.viewer.clock.currentTime):a.label.text;c&&(l.text=c)}}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 c=a.position.getValue(this.viewer.clock.currentTime);c&&(l.position={x:c.x,y:c.y,z:c.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 c={};try{const u=a.billboard.image&&a.billboard.image.getValue?a.billboard.image.getValue(this.viewer.clock.currentTime):a.billboard.image;if(u){if(typeof u=="string")c.image=u;else if(u&&u.src)try{const f=u;if(typeof document<"u"&&f instanceof HTMLImageElement){const p=document.createElement("canvas");p.width=f.naturalWidth||f.width||1,p.height=f.naturalHeight||f.height||1;const h=p.getContext("2d");h?(h.drawImage(f,0,0),c.image=p.toDataURL()):c.image=f.src}else c.image=u.src}catch{c.image=u.src}}}catch{}a.billboard.width&&(c.width=a.billboard.width),a.billboard.height&&(c.height=a.billboard.height),l.style=c}}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 c=a.position.getValue(this.viewer.clock.currentTime);c&&(l.position={x:c.x,y:c.y,z:c.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 i={version:"1.0",exportTime:new Date().toISOString(),totalEntities:e.length,annotations:t},s=JSON.stringify(i);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 i=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 c=a.style.color;a.style.color=`rgba(${Math.round(c.red*255)}, ${Math.round(c.green*255)}, ${Math.round(c.blue*255)}, ${c.alpha||1})`}if(a.style.outlineColor&&typeof a.style.outlineColor=="object"){const c=a.style.outlineColor;a.style.outlineColor=`rgba(${Math.round(c.red*255)}, ${Math.round(c.green*255)}, ${Math.round(c.blue*255)}, ${c.alpha||1})`}}switch(l){case"freehand":case"polyline":case"arrow":if(a.positions&&a.positions.length>0){const c=a.positions.map(p=>p&&typeof p=="object"?new this.Cesium.Cartesian3(p.x,p.y,p.z):p),u={type:l==="freehand"?"freehandLine":l,style:a.style||{},positions:c,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))},f=this.drawTool.createByPositions(u);if(f&&f.getEntity()){s++,f.isEdit=!0;const p=f.getEntity();p&&!p._plotInstance&&(p._plotInstance=f),p&&!p.objId&&(p.objId=f.objId),console.log(`Loaded ${l} entity with objId: ${f.objId}`)}}break;case"rectangle":{try{if(a.positions&&a.positions.length){let c=[];if(a.positions[0]&&a.positions[0].x!==void 0)c=a.positions.map(u=>new this.Cesium.Cartesian3(u.x,u.y,u.z!==void 0?u.z:0));else if(a.positions[0]&&a.positions[0].west!==void 0){const u=a.positions[0];c=[this.Cesium.Cartesian3.fromRadians(u.west,u.south),this.Cesium.Cartesian3.fromRadians(u.east,u.south),this.Cesium.Cartesian3.fromRadians(u.east,u.north),this.Cesium.Cartesian3.fromRadians(u.west,u.north),this.Cesium.Cartesian3.fromRadians(u.west,u.south)]}if(c.length){const u=JSON.parse(JSON.stringify(a.style||{}));if(u.color&&typeof u.color=="string"&&!u.color.startsWith("rgba"))try{const h=JSON.parse(u.color);h.red!==void 0&&(u.color=`rgba(${Math.round(h.red*255)}, ${Math.round(h.green*255)}, ${Math.round(h.blue*255)}, ${h.alpha||1})`)}catch{}const f={type:"rectangle",positions:c,style:u,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let p=null;try{p=this.drawTool.createByPositions(f)}catch(h){console.warn("drawTool.createByPositions(rectangle) failed",h)}if(p){s++,p.isEdit=!0;const h=p.getEntity?p.getEntity():p.entity||p;h&&(h._plotInstance=p,h.objId=p.objId||a.id,h.pickable=!0,h.polyline&&(h.polyline.pickWidth=10),console.log(`Loaded rectangle entity with objId: ${h.objId}, color: ${u.color}`))}}}}catch(c){console.warn("load rectangle failed",c)}break}case"text":if(a.position){const c=a.text||"文字标注",u={type:"label",style:a.style||{},text:c,position:new this.Cesium.Cartesian3(a.position.x,a.position.y,a.position.z||0)};u.style.fontSize||(u.style.fontSize=14),u.style.fontFamily||(u.style.fontFamily="Arial");let f;try{!u.positions&&u.position&&(u.positions=u.position),f=this.drawTool.createByPositions(u),!f&&this.drawTool.startText&&(console.log("使用startText创建文字"),this.drawTool.startText(u.style),this.drawTool.currentEntity&&(this.drawTool.currentEntity.text=c,this.drawTool.currentEntity.position=u.position,f=this.drawTool.currentEntity))}catch(p){console.log("创建文字失败",p)}if(!f)try{const p=this.viewer.entities.add({position:u.position,label:Object.assign({text:c,font:u.style&&u.style.font||"14pt Source Han Sans CN",fillColor:u.style&&u.style.fillColor||this.Cesium.Color.WHITE,outlineColor:u.style&&u.style.outlineColor||this.Cesium.Color.BLACK,outlineWidth:u.style&&u.style.outlineWidth||2,verticalOrigin:u.style&&u.style.verticalOrigin||this.Cesium.VerticalOrigin.BOTTOM,pixelOffset:u.style&&u.style.pixelOffset||new this.Cesium.Cartesian2(0,-10)},u.style&&u.style.label?u.style.label:{})}),h={getEntity:()=>p,entity:p,style:u.style||{},type:"label",objId:a.id||`label_${Date.now()}_${Math.random().toFixed(3)}`,isEdit:!0,destroy:()=>this.viewer.entities.remove(p)};try{p.objId=h.objId}catch{}this.drawTool&&(this.drawTool.entityObjArr||(this.drawTool.entityObjArr=[]),this.drawTool.entityObjArr.push(h)),f=h}catch(p){console.warn("回退创建文字实体失败",p)}f&&(s++,f.isEdit=!0)}break;case"image":if(a.position){const c={type:"billboard",style:a.style||{},position:new this.Cesium.Cartesian3(a.position.x,a.position.y,a.position.z||0)};c.style.image||(console.log("使用默认图片占位符"),c.style.image="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgdmlld0JveD0iMCAwIDUwIDUwIj48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNlNTMyMzIiLz48L3N2Zz4="),c.style.width||(c.style.width=50),c.style.height||(c.style.height=50);let u;try{!c.positions&&c.position&&(c.positions=c.position),u=this.drawTool.createByPositions(c),!u&&this.drawTool.startImage&&(console.log("使用startImage创建图片"),this.drawTool.startImage(c.style.image,c.style),this.drawTool.currentEntity&&(this.drawTool.currentEntity.position=c.position,u=this.drawTool.currentEntity))}catch(f){console.log("创建图片失败",f)}if(!u)try{const f=c.style&&c.style.image?c.style.image:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgdmlld0JveD0iMCAwIDUwIDUwIj48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNlNTMyMzIiLz48L3N2Zz4=",p=this.viewer.entities.add({position:c.position,billboard:{image:f,width:c.style&&c.style.width?c.style.width:50,height:c.style&&c.style.height?c.style.height:50,verticalOrigin:c.style&&c.style.verticalOrigin||this.Cesium.VerticalOrigin.CENTER,scale:c.style&&c.style.scale||1}}),h={getEntity:()=>p,entity:p,style:c.style||{},type:"billboard",objId:a.id||`billboard_${Date.now()}_${Math.random().toFixed(3)}`,isEdit:!0,destroy:()=>this.viewer.entities.remove(p)};try{p.objId=h.objId}catch{}this.drawTool&&(this.drawTool.entityObjArr||(this.drawTool.entityObjArr=[]),this.drawTool.entityObjArr.push(h)),u=h}catch(f){console.warn("回退创建图片实体失败",f)}u&&(s++,u.isEdit=!0)}break;case"ellipse":case"circle":{try{const c=JSON.parse(JSON.stringify(a.style||{}));if(c.color&&typeof c.color=="string"&&!c.color.startsWith("rgba"))try{const p=JSON.parse(c.color);p.red!==void 0&&(c.color=`rgba(${Math.round(p.red*255)}, ${Math.round(p.green*255)}, ${Math.round(p.blue*255)}, ${p.alpha||1})`)}catch{}let u=[],f=!1;if(a.positions&&a.positions.length&&(a.positions[0]&&a.positions[0].x!==void 0&&(u=a.positions.map(p=>new this.Cesium.Cartesian3(p.x,p.y,p.z!==void 0?p.z:0))),u.length)){const p={type:l,positions:u,style:c,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let h=null;try{if(h=this.drawTool.createByPositions(p),h){s++,h.isEdit=!0;const A=h.getEntity?h.getEntity():h.entity||h;A&&(A._plotInstance=h,A.objId=h.objId||a.id,A.pickable=!0,A.polyline&&(A.polyline.pickWidth=10),console.log(`Loaded ${l} entity with objId: ${A.objId} using positions`)),f=!0}}catch(A){console.warn(`drawTool.createByPositions(${l}) failed`,A)}}if(!f&&a.center&&a.radius)try{const p=new this.Cesium.Cartesian3(a.center.x,a.center.y,a.center.z||0),h=this.Cesium.Cartesian3.add(p,new this.Cesium.Cartesian3(a.radius,0,0),new this.Cesium.Cartesian3),C={type:l,positions:[p,h],style:c,id:a.id||+(new Date().getTime()+""+Number(Math.random()*1e3).toFixed(0))};let m=null;try{if(m=this.drawTool.createByPositions(C),m){s++,m.isEdit=!0;const y=m.getEntity?m.getEntity():m.entity||m;y&&(y._plotInstance=m,y.objId=m.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(p){console.warn(`Fallback creation for ${l} failed`,p)}}catch(c){console.warn(`load ${l} failed`,c)}break}default:console.log(`尝试加载未知类型实体: ${l}`);break}})};return Object.keys(i).forEach(r=>{o(i[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 i;try{i=this.Cesium.Color.fromCssColorString(e)}catch(s){console.warn("Invalid color format:",e,s),i=e}if(t.polyline)try{t.polyline.material=new this.Cesium.ColorMaterialProperty(i)}catch{t.polyline.material=i}else if(t.polygon)try{t.polygon.material=new this.Cesium.ColorMaterialProperty(i)}catch{t.polygon.material=i}else if(t.rectangle){const s=t.rectangle.outline,o=t.rectangle.outlineWidth;try{t.rectangle.material=new this.Cesium.ColorMaterialProperty(i)}catch{t.rectangle.material=i}t.rectangle.outlineColor=i,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=i,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 i=2;if(typeof e=="number")i=e;else switch(e){case"thin":i=2;break;case"medium":i=4;break;case"thick":i=8;break}if(t.polyline)t.polyline.width=i;else if(t.polygon&&t.polygon.outline)t.polygon.outlineWidth=i;else if(t.rectangle&&t.rectangle.outline)t.rectangle.outlineWidth=i;else if((t.ellipse||t.circle)&&(t.ellipse?.outline||t.circle?.outline)){const s=t.ellipse||t.circle;s.outlineWidth=i}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 nc{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 i=this.cesium;this.originalDoubleClickAction=this.viewer.screenSpaceEventHandler.getInputAction(i.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.viewer.screenSpaceEventHandler.removeInputAction(i.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(i=>{const s=this.getPickPosition(i.position);s&&this.addPoint(s)},t.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(i=>{const s=this.getPickPosition(i.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 i=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(i),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 c=t.Transforms.eastNorthUpToFixedFrame(s),u=t.Matrix4.inverse(c,new t.Matrix4),f=t.Matrix4.multiplyByPoint(u,o,new t.Cartesian3),p=f.x,h=f.y,A=f.z,C=t.Matrix4.getColumn(c,0,new t.Cartesian3),m=t.Matrix4.getColumn(c,1,new t.Cartesian3),y=t.Cartesian3.multiplyByScalar(C,p,new t.Cartesian3),E=t.Cartesian3.add(s,y,new t.Cartesian3),I=t.Cartesian3.multiplyByScalar(m,h,new t.Cartesian3),S=t.Cartesian3.add(E,I,new t.Cartesian3);if(this.viewer.scene.mode!==t.SceneMode.SCENE2D){const k=this.viewer.entities.add({polyline:{positions:[s,E],width:2,material:new t.PolylineDashMaterialProperty({color:t.Color.RED}),depthFailMaterial:new t.PolylineDashMaterialProperty({color:new t.Color(1,0,0,.5)})}}),B=this.viewer.entities.add({polyline:{positions:[E,S],width:2,material:new t.PolylineDashMaterialProperty({color:t.Color.GREEN}),depthFailMaterial:new t.PolylineDashMaterialProperty({color:new t.Color(0,1,0,.5)})}}),x=this.viewer.entities.add({polyline:{positions:[S,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(k,B,x)}this.onMeasure({type:"distance",dx:p,dy:h,dz:A,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 i=this.activePoints[this.activePoints.length-1];this.addLabel(i,`Total: ${this.formatDistance(t)}`)}else if(this.type==="area"&&this.activePoints.length>=3){const t=this.calculateArea(this.activePoints),i=this.calculateCenter(this.activePoints);this.addLabel(i,`面积: ${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 i=this.viewer.entities.add({polyline:{positions:t,width:2,material:e.Color.YELLOW,depthFailMaterial:e.Color.YELLOW}});this.measureEntities.push(i)}else if(this.type==="area"){const t=[...this.activePoints];this.viewer.entities.remove(this.activeShape);const i=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(i)}this.activeShape=null}this.activePoints=[],this.type=null,this.cursorPosition=null}getPickPosition(e){const t=this.cesium;let i;try{i=this.viewer.scene.pickPosition(e)}catch{}if(!i||!t.defined(i)){const s=this.viewer.camera.getPickRay(e);s&&(i=this.viewer.scene.globe.pick(s,this.viewer.scene))}if((!i||!t.defined(i))&&(i=this.viewer.scene.camera.pickEllipsoid(e,this.viewer.scene.globe.ellipsoid)),!i||!t.defined(i))return null;if(this.isSnapping){const s=this.snapToVertex(e);if(s)i=s;else{const o=this.snapTo3DTileFeature(e);o&&(i=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}}))),i}snapTo3DTileFeature(e){const t=this.cesium,i=10,s=[{x:0,y:0},{x:-i,y:0},{x:i,y:0},{x:0,y:-i},{x:0,y:i},{x:-i,y:-i},{x:i,y:-i},{x:-i,y:i},{x:i,y:i}];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 c=this.viewer.scene.pickPosition(l);if(c)return c}catch{}}return null}snapToVertex(e){const t=this.cesium,i=this.viewer.entities.values;let s=20,o=null;for(let r=0;r<i.length;r++){const l=i[r];if(!l.show)continue;let a=[];if(l.polyline&&l.polyline.positions){const c=l.polyline.positions.getValue(t.JulianDate.now());c&&(a=c)}else if(l.polygon&&l.polygon.hierarchy){const c=l.polygon.hierarchy.getValue(t.JulianDate.now());c&&c.positions&&(a=c.positions)}else if(l.position){const c=l.position.getValue(t.JulianDate.now());c&&(a=[c])}else if(l.rectangle&&l.rectangle.coordinates){const c=l.rectangle.coordinates.getValue(t.JulianDate.now());c&&(a=[t.Cartesian3.fromRadians(c.west,c.south),t.Cartesian3.fromRadians(c.east,c.south),t.Cartesian3.fromRadians(c.east,c.north),t.Cartesian3.fromRadians(c.west,c.north)])}for(let c=0;c<a.length;c++){const u=a[c];try{const f=this.viewer.scene.cartesianToCanvasCoordinates(u);if(f){const p=t.Cartesian2.distance(f,e);p<s&&(s=p,o=u)}}catch{}}}return o}addLabel(e,t){const i=this.cesium,s=this.viewer.entities.add({position:e,label:{text:t,font:"14px sans-serif",fillColor:i.Color.WHITE,style:i.LabelStyle.FILL_AND_OUTLINE,outlineWidth:2,verticalOrigin:i.VerticalOrigin.BOTTOM,pixelOffset:new i.Cartesian2(0,-10),disableDepthTestDistance:Number.POSITIVE_INFINITY,showBackground:!0,backgroundColor:new i.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,i){const s=this.cesium,o=s.Cartesian3.subtract(e,t,new s.Cartesian3),r=s.Cartesian3.subtract(i,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)),c=Math.acos(a);return s.Math.toDegrees(c)}calculateArea(e){const t=this.cesium;if(e.length<3)return 0;const i=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,i,new t.Cartesian3),c=t.Cartesian3.subtract(l,i,new t.Cartesian3),u=t.Cartesian3.cross(a,c,new t.Cartesian3);t.Cartesian3.add(s,u,s)}return t.Cartesian3.magnitude(s)*.5}calculateCenter(e){const t=this.cesium;if(!e||e.length===0)return null;let i=0,s=0,o=0;for(let r=0;r<e.length;r++)i+=e[r].x,s+=e[r].y,o+=e[r].z;return new t.Cartesian3(i/e.length,s/e.length,o/e.length)}formatArea(e){return e>1e6?`${(e/1e6).toFixed(2)} km²`:`${e.toFixed(2)} m²`}}class O0{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 i=this.cesium.Color.fromCssColorString(e);i?(this.viewer.scene.backgroundColor=i,this.viewer.scene.globe.baseColor=i):(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"),i=new Promise((s,o)=>setTimeout(()=>o(new Error("ArcGIS Terrain request timed out")),5e3));this.viewer.terrainProvider=await Promise.race([t,i])}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(i){console.error("Failed to enable terrain (both ArcGIS and Ion failed):",i),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,i=t.screenSpaceCameraController;t.postProcessStages.fxaa.enabled=!1,this.setBackgroundColor("#000000"),this.setGlobeColor("#000000"),this.viewer.imageryLayers.removeAll(),this.setGlobeEnvironmentVisible(!0),t.globe.depthTestAgainstTerrain=!1,this.viewer.terrainProvider=new e.EllipsoidTerrainProvider,i.zoomFactor=8,i.enableZoomInertia=!1,i.minimumZoomDistance=.1,i.maximumZoomDistance=1e6,i.enableTilt=!1,i.enableLook=!1,i.enableCollisionDetection=!0,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),c=0,u=Math.abs(o.heading-l);((u>Math.PI?Math.abs(u-2*Math.PI):u)>r||Math.abs(o.pitch-a)>r||Math.abs(o.roll-c)>r)&&o.setView({orientation:{heading:l,pitch:a,roll:c}})};this._removeCameraLockListener=this.viewer.scene.postRender.addEventListener(s)}_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}async changeBaseMap(e,t){if(this.is2d){this.viewer.imageryLayers.removeAll();return}const i=Date.now();this.lastBaseMapRequestId=i;const s=this.viewer.imageryLayers,o=[];if(e==="tianditu"){const r=t?.token||"c25f14fb6bd4397cf8fe45144ff768d6",l=t?.layerType||"img_w",a=l.split("_"),c=a[0]||"img",u=a[1]||"w";let f="";c==="img"?f="cia":c==="vec"?f="cva":c==="ter"&&(f="cta");const p=f?`${f}_${u}`:"";o.push(new this.cesium.WebMapTileServiceImageryProvider({url:`https://{s}.tianditu.gov.cn/${l}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${c}&STYLE=default&TILEMATRIXSET=${u}&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=${r}`,layer:c,style:"default",format:"tiles",tileMatrixSetID:u,maximumLevel:18,subdomains:["t0","t1","t2","t3","t4","t5","t6","t7"]})),t.showAnnotation!==!1&&p&&o.push(new this.cesium.WebMapTileServiceImageryProvider({url:`https://{s}.tianditu.gov.cn/${p}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${f}&STYLE=default&TILEMATRIXSET=${u}&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=${r}`,layer:f,style:"default",format:"tiles",tileMatrixSetID:u,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((u,f)=>setTimeout(()=>f(new Error("ArcGIS metadata request timed out")),3e3)),c=await Promise.race([l,a]);o.push(c)}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!==i){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 i=this.cesium.JulianDate.fromDate(t);this.viewer.clock.currentTime=i}setModelColorAdjustment(e){if(this.is2d)return;const t=this.viewer,i=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,c=!!i.CustomShader;for(let u=0;u<a;++u){const f=l.get(u);if(f instanceof i.Cesium3DTileset)if(c)if(f.customShader&&f.customShader.isModelAdjustment)e.brightness!==void 0&&f.customShader.setUniform("u_brightness",s),e.contrast!==void 0&&f.customShader.setUniform("u_contrast",o),e.saturation!==void 0&&f.customShader.setUniform("u_saturation",r);else{const p=new i.CustomShader({uniforms:{u_brightness:{type:i.UniformType.FLOAT,value:s},u_contrast:{type:i.UniformType.FLOAT,value:o},u_saturation:{type:i.UniformType.FLOAT,value:r}},fragmentShaderText:`
99
99
  void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {
100
100
  // 1. 亮度 (Brightness) - RGB 乘法
101
101
  material.diffuse *= u_brightness;