diff --git a/CHANGELOG.md b/CHANGELOG.md
index 756bd37..0517fc1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# 1.2.2
- Fix module.json to remove v10 warnings (by @TooPick).
+- Fix dependabot security warnings.
# 1.2.1
diff --git a/modules/dungeondraw-bundle.min.js b/modules/dungeondraw-bundle.min.js
index 81e02be..0bbaad4 100644
--- a/modules/dungeondraw-bundle.min.js
+++ b/modules/dungeondraw-bundle.min.js
@@ -1,9 +1,9 @@
-const e="dungeon-draw";class t{static register(){game.settings.register(e,"allowTrustedPlayer",{name:game.i18n.localize("DD.SettingAllowTrustedPlayers"),scope:"world",default:!0,type:Boolean,config:!0}),game.settings.register(e,"3DCanvasEnabled",{name:game.i18n.localize("DD.SettingSupport3DCanvas"),scope:"world",default:!0,type:Boolean,config:!0}),game.settings.register(e,"snapToGrid",{name:game.i18n.localize("DD.SettingSnapToGrid"),scope:"client",default:!0,type:Boolean,config:!0,onChange:e=>{canvas.dungeon.options.snapToGrid=e}}),game.settings.register(e,"releaseNotesVersion",{name:"Last version we showed release notes.",scope:"client",default:"",type:String,config:!1}),game.settings.register(e,"customThemes",{name:"Custom themes data.",scope:"client",default:"{}",type:String,config:!1}),game.settings.register(e,"themePainterTheme",{name:"Theme painter theme key.",scope:"client",default:"module.cavern",type:String,config:!1})}static threeDCanvasEnabled(){return game.settings.get(e,"3DCanvasEnabled")}static snapToGrid(){return game.settings.get(e,"snapToGrid")}}const n=()=>{try{const t=game.settings.get(e,"customThemes"),n=JSON.parse(t);return Object.keys(n).forEach((e=>{n[e].config=foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},n[e].config)})),n}catch(e){return console.log(e),{}}},i=t=>{const n=JSON.stringify(t);game.settings.set(e,"customThemes",n)},r=()=>game.settings.get(e,"themePainterTheme"),o=t=>game.settings.set(e,"themePainterTheme",t),s={default:{name:"Default",config:{doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8}},arcPavement:{name:"Arc Pavement",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#111111",floorTexture:"modules/dungeon-draw/assets/textures/Arc_Pavement_001_basecolor.jpg",invisibleWallThickness:10,wallColor:"#111111",wallThickness:12})},basicBlack:{name:"Basic Black",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#0D0D0D",doorFillOpacity:0,exteriorShadowOpacity:0,interiorShadowOpacity:0,invisibleWallColor:"#0D0D0D",floorColor:"#FFFFFF",sceneBackgroundColor:"#0D0D0D",sceneGridOpacity:1,secretDoorSColor:"#0D0D0D",wallColor:"#0D0D0D"})},cavern:{name:"Cavern",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#2B2D2F",invisibleWallThickness:10,floorTexture:"modules/dungeon-draw/assets/textures/Stylized_Stone_Floor_002_bw.jpg",wallColor:"#2B2D2F",wallThickness:12})},checkerboard:{name:"Checkerboard",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorFillColor:"#C2BFB0",floorTexture:"modules/dungeon-draw/assets/textures/sci_fi_texture_150_by_llexandro_d939vk9.png",invisibleWallFillColor:"#C2BFB0",invisibleWallThickness:8,secretDoorSColor:"#C2BFB0",wallThickness:10})},cobblestone:{name:"Cobblestone",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#222222",doorFillColor:"#FFFFFF",floorTexture:"modules/dungeon-draw/assets/textures/Cobblestone_001_COLOR.jpg",invisibleWallColor:"#222222",invisibleWallFillColor:"#FFFFFF",invisibleWallThickness:10,secretDoorSColor:"#FFFFFF",wallColor:"#222222",wallThickness:12})},dirt:{name:"Dirt",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#1a1714",doorFillColor:"#8d7862",floorTexture:"modules/dungeon-draw/assets/textures/Ground_Dirt_007_basecolor.jpg",invisibleWallColor:"#1a1714",invisibleWallFillColor:"#8d7862",invisibleWallThickness:8,secretDoorSColor:"#8d7862",wallColor:"#1a1714",wallThickness:10})},dungeonSquares:{name:"Dungeon Squares",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#111111",floorTexture:"modules/dungeon-draw/assets/textures/outdoor+stone+tiles+pavement.jpg",invisibleWallColor:"#111111",invisibleWallThickness:10,wallColor:"#111111",wallThickness:12})},grass:{name:"Grass",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#72471d",doorFillColor:"#eee8c1",floorTexture:"modules/dungeon-draw/assets/textures/Grass_001_COLOR.jpg",invisibleWallColor:"#72471d",invisibleWallFillColor:"#eee8c1",invisibleWallThickness:10,secretDoorSColor:"#eee8c1",wallColor:"#72471d",wallThickness:10})},groovyCarpet:{name:"Groovy Carpet",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#2B2D2F",floorTexture:"modules/dungeon-draw/assets/textures/Fabric_Rug_006_basecolor.jpg",invisibleWallColor:"#2B2D2F",invisibleWallThickness:10,wallColor:"#2B2D2F",wallThickness:12})},hexagon:{name:"Hexagons",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#282828",doorFillColor:"#D1BD8A",floorTexture:"modules/dungeon-draw/assets/textures/Rocks_Hexagons_002_basecolor.jpg",invisibleWallColor:"#282828",invisibleWallFillColor:"#D1BD8A",invisibleWallThickness:10,secretDoorSColor:"#D1BD8A",wallColor:"#282828",wallThickness:12})},marble:{name:"Marble",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#686882",floorTexture:"modules/dungeon-draw/assets/textures/Marble_Tiles_001_basecolor.jpg",invisibleWallColor:"#686882",wallColor:"#686882"})},metalGrid:{name:"Metal Grid",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#27251A",doorFillColor:"#AAAAAA",floorTexture:"modules/dungeon-draw/assets/textures/Sci-fi_Floor_002_basecolor.jpg",invisibleWallColor:"#27251A",invisibleWallFillColor:"#AAAAAA",secretDoorSColor:"#AAAAAA",wallColor:"#27251A"})},metalSquares:{name:"Metal Squares",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorFillColor:"#C0C0C0",floorTexture:"modules/dungeon-draw/assets/textures/sci_fi_texture_212_by_llexandro_dcuxgum.png",invisibleWallFillColor:"#C0C0C0",secretDoorSColor:"#C0C0C0"})},moldvayBlue:{name:"Moldvay Blue",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#3A9FF2",doorFillOpacity:0,doorThickness:35,exteriorShadowOpacity:0,floorColor:"#FFFFFF",interiorShadowOpacity:0,invisibleWallColor:"#3A9FF2",invisibleWallFillOpacity:0,sceneBackgroundColor:"#3A9FF2",sceneGridColor:"#3A9FF2",sceneGridOpacity:1,secretDoorSColor:"#3A9FF2",wallColor:"#3A9FF2"})},neonBlueprint:{name:"Neon Blueprint",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#3A9FF2",doorFillOpacity:0,doorThickness:35,exteriorShadowColor:"#18495E",floorColor:"#142A3B",interiorShadowColor:"#1B7FAB",invisibleWallColor:"#3A9FF2",invisibleWallFillOpacity:0,invisibleWallLineThickness:1,invisibleWallThickness:6,sceneBackgroundColor:"#171008",sceneGridColor:"#4C89A1",sceneGridOpacity:1,secretDoorSColor:"#3A9FF2",wallColor:"#63C9E6",wallThickness:4})},ruddyPaper:{name:"Ruddy Paper",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#913B55",doorFillColor:"#FADEE6",floorTexture:"modules/dungeon-draw/assets/textures/Paper_Recycled_001_COLOR.jpg",floorTextureTint:"#F9FAE6",exteriorShadowOpacity:0,interiorShadowOpacity:0,invisibleWallColor:"#913B55",invisibleWallFillColor:"#FADEE6",sceneBackgroundColor:"#EBD3BC",sceneGridColor:"#594026",sceneGridOpacity:1,secretDoorSColor:"#913B55",wallColor:"#9A6D54"})},water:{name:"Water",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#203246",floorTexture:"modules/dungeon-draw/assets/textures/Water_001_COLOR.jpg",invisibleWallColor:"#203246",invisibleWallLineThickness:1,invisibleWallThickness:4,wallColor:"#203246",wallThickness:5})},woodPlanks:{name:"Wood Planks",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#332211",floorTexture:"modules/dungeon-draw/assets/textures/Old_Wooden_Plank_Seamless_Texture_765.jpg",invisibleWallColor:"#332211",invisibleWallThickness:13,wallColor:"#332211",wallTexture:"modules/dungeon-draw/assets/textures/Bark_002_bw.jpg",wallTextureTint:"#7e5935",wallThickness:15})},xenomorph:{name:"Xenomorph",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#8AF0F0",doorFillColor:"#255151",doorLineThickness:5,doorThickness:20,exteriorShadowColor:"#00838C",floorColor:"#255151",interiorShadowColor:"#00838C",invisibleWallColor:"#8AF0F0",invisibleWallFillColor:"#255151",invisibleWallLineThickness:1,invisibleWallThickness:6,sceneBackgroundColor:"#002222",sceneGridColor:"#ffffff",sceneGridOpacity:1,secretDoorSColor:"#8AF0F0",wallColor:"#8AF0F0",wallThickness:4})}};class a extends FormApplication{constructor(e){super(),this.themeKey=e}static get defaultOptions(){return foundry.utils.mergeObject(super.defaultOptions,{id:"dd-theme-sheet",classes:["sheet"],template:"modules/dungeon-draw/templates/theme-sheet.html",width:480,height:t.threeDCanvasEnabled()?1160:1040,tabs:[{navSelector:".tabs",contentSelector:"form",initial:"position"}]})}get title(){return game.i18n.localize("DD.ThemeSheetTitle")}getData(){const e=n()[this.themeKey],i=t.threeDCanvasEnabled();return{config:e.config,themeName:e.name,threeDCanvasEnabled:i}}async _updateObject(e,t){const r=n(),o=t.themeName;delete t.themeName,r[this.themeKey]={name:o,config:t},i(r),await(canvas.dungeon.dungeon?.refresh())}}class l extends FormApplication{constructor(e="settings"){super(),this._tabs[0].active=e}static get defaultOptions(){return foundry.utils.mergeObject(super.defaultOptions,{id:"dd-config-sheet",classes:["sheet"],template:"modules/dungeon-draw/templates/config-sheet.html",width:480,height:t.threeDCanvasEnabled()?1220:1100,tabs:[{navSelector:".tabs",contentSelector:"form",initial:"position"}]})}get title(){return game.i18n.localize("DD.ConfigSheetTitle")}getData(){let e=canvas.dungeon.dungeon?.state().config;e||(e={doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8});const i=n(),o=Object.keys(i).sort(),a=Object.keys(s).sort(),l=r(),c=t.threeDCanvasEnabled();return{config:e,customThemes:i,customThemeKeys:o,themes:s,themeKeys:a,themePainterThemeKey:l,threeDCanvasEnabled:c}}async _updateObject(e,t){delete t.customThemeName,delete t.themePainterTheme,canvas.dungeon.dungeon?.setConfig(t),game.user.isGM&&await canvas.scene.update({backgroundColor:t.sceneBackgroundColor,gridAlpha:t.sceneGridAlpha,gridColor:t.sceneGridColor})}async close(e){await super.close(e),this.preview&&(this.preview.removeChildren(),this.preview=null)}activateListeners(e){super.activateListeners(e),e.find('button[name="resetDefault"]').click(this._onResetDefaults.bind(this)),e.find(".dd-theme-name").click(this._onThemeNameClick.bind(this)),e.find(".dd-save-as-theme-button").click(this._onSaveAsThemeClick.bind(this)),e.find(".dd-theme-edit").click(this._onEditThemeClick.bind(this)),e.find(".dd-theme-copy").click(this._onCopyThemeClick.bind(this)),e.find(".dd-theme-delete").click(this._onDeleteThemeClick.bind(this)),e.find('select[name="themePainterThemeKey"]').change(this._onThemePainterThemeSelect.bind(this)),e.find(".dd-export-themes-button").click(this._onExportThemesClick.bind(this)),e.find(".dd-import-themes-button").click(this._onImportThemesClick.bind(this))}_onResetDefaults(e){e.preventDefault(),canvas.dungeon.dungeon?.setConfig({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8}),canvas.dungeon.dungeon.refresh(),this.render()}async _onThemeNameClick(e){e.preventDefault();const t=$(e.currentTarget).parent(".dd-theme-row"),i=t.data("theme");let r;if("custom"===t.data("themetype")){r=n()[i]}else r=s[i];const o={...r.config};await(canvas.dungeon.dungeon?.setConfig(o)),game.user.isGM&&await canvas.scene.update({backgroundColor:o.sceneBackgroundColor,gridAlpha:o.sceneGridAlpha,gridColor:o.sceneGridColor}),this.render()}async _onSaveAsThemeClick(e){e.preventDefault();const t=$(e.currentTarget).closest(".form-fields").children(".saveAsThemeName").val(),r=this._getSubmitData();delete r.saveAsThemeName,delete r.themePainterThemeKey;const o=n();o[t]={name:t,config:r},i(o),this._tabs[0].active="themes",this.render()}async _onEditThemeClick(e){e.preventDefault();const t=$(e.currentTarget).closest(".dd-theme-row").data("theme");new a(t).render(!0)}_onCopyThemeClick(e){e.preventDefault();const t=$(e.currentTarget).closest(".dd-theme-row").data("theme"),r=n(),o=r[t],s=JSON.parse(JSON.stringify(o));let a,l=1,c=!1;for(;!c;)a=`${o.name} (${l})`,a in r?l++:c=!0;s.name=a,r[a]=s,i(r),this.render()}_onDeleteThemeClick(e){e.preventDefault();const t=$(e.currentTarget).closest(".dd-theme-row").data("theme"),r=n();delete r[t],i(r),this.render()}_onExportThemesClick(e){e.preventDefault();const t=JSON.stringify(n(),null,2);saveDataToFile(t,"application/json","dd-custom-themes.json")}async _onImportThemesClick(e){e.preventDefault(),new Dialog({title:game.i18n.localize("DD.ImportCustomThemes"),content:await renderTemplate("modules/dungeon-draw/templates/import-data.html",{hint:game.i18n.localize("DD.ImportCustomThemesHint")}),buttons:{import:{icon:'',label:game.i18n.localize("DD.Import"),callback:e=>{const t=e.find("form")[0];if(!t.data.files.length)return ui.notifications.error("You did not upload a data file!");readTextFromFile(t.data.files[0]).then((e=>{const r=JSON.parse(e);if(t.wipe.checked)i(r);else{const e=n(),t=foundry.utils.mergeObject(e,r);i(t)}this.render()}))}},no:{icon:'',label:game.i18n.localize("DD.Cancel")}},default:"import"},{width:400}).render(!0)}_onThemePainterThemeSelect(e){const t=$(e.currentTarget).val();o(t)}}class c extends Error{constructor(e){super(e),this.name=Object.keys({Exception:c})[0]}toString(){return this.message}}class h extends c{constructor(e){super(e),this.name=Object.keys({IllegalArgumentException:h})[0]}}class u{filter(e){}}function d(){}function m(){}function g(){}class f{static equalsWithTolerance(e,t,n){return Math.abs(e-t)<=n}}class p{constructor(e,t){this.low=t||0,this.high=e||0}static toBinaryString(e){let t,n="";for(t=2147483648;t>0;t>>>=1)n+=(e.high&t)===t?"1":"0";for(t=2147483648;t>0;t>>>=1)n+=(e.low&t)===t?"1":"0";return n}}function _(){}function y(){}_.NaN=NaN,_.isNaN=e=>Number.isNaN(e),_.isInfinite=e=>!Number.isFinite(e),_.MAX_VALUE=Number.MAX_VALUE,_.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,_.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,"function"==typeof Float64Array&&"function"==typeof Int32Array?function(){const e=2146435072,t=new Float64Array(1),n=new Int32Array(t.buffer);_.doubleToLongBits=function(i){t[0]=i;let r=0|n[0],o=0|n[1];return(o&e)===e&&0!=(1048575&o)&&0!==r&&(r=0,o=2146959360),new p(o,r)},_.longBitsToDouble=function(e){return n[0]=e.low,n[1]=e.high,t[0]}}():function(){const e=1023,t=Math.log2,n=Math.floor,i=Math.pow,r=function(){for(let e=53;e>0;e--){const r=i(2,e)-1;if(n(t(r))+1===e)return r}return 0}();_.doubleToLongBits=function(o){let s,a,l,c,h,u,d,m,g;if(o<0||1/o===Number.NEGATIVE_INFINITY?(u=1<<31,o=-o):u=0,0===o)return g=0,m=u,new p(m,g);if(o===1/0)return g=0,m=2146435072|u,new p(m,g);if(o!=o)return g=0,m=2146959360,new p(m,g);if(c=0,g=0,s=n(o),s>1)if(s<=r)c=n(t(s)),c<=20?(g=0,m=s<<20-c&1048575):(l=c-20,a=i(2,l),g=s%a<<32-l,m=s/a&1048575);else for(l=s,g=0;a=l/2,l=n(a),0!==l;)c++,g>>>=1,g|=(1&m)<<31,m>>>=1,a!==l&&(m|=524288);if(d=c+e,h=0===s,s=o-s,c<52&&0!==s)for(l=0;;){if(a=2*s,a>=1?(s=a-1,h?(d--,h=!1):(l<<=1,l|=1,c++)):(s=a,h?0==--d&&(c++,h=!1):(l<<=1,c++)),20===c)m|=l,l=0;else if(52===c){g|=l;break}if(1===a){c<20?m|=l<<20-c:c<52&&(g|=l<<52-c);break}}return m|=d<<20,m|=u,new p(m,g)},_.longBitsToDouble=function(t){let n,r,o,s;const a=t.high,l=t.low,c=a&1<<31?-1:1;for(o=((2146435072&a)>>20)-e,s=0,r=1<<19,n=1;n<=20;n++)a&r&&(s+=i(2,-n)),r>>>=1;for(r=1<<31,n=21;n<=52;n++)l&r&&(s+=i(2,-n)),r>>>=1;if(-1023===o){if(0===s)return 0*c;o=-1022}else{if(1024===o)return 0===s?c/0:NaN;s+=1}return c*s*i(2,o)}}();class b extends c{constructor(e){super(e),this.name=Object.keys({RuntimeException:b})[0]}}class C extends b{constructor(){super(),C.constructor_.apply(this,arguments)}static constructor_(){if(0===arguments.length)b.constructor_.call(this);else if(1===arguments.length){const e=arguments[0];b.constructor_.call(this,e)}}}class x{static shouldNeverReachHere(){if(0===arguments.length)x.shouldNeverReachHere(null);else if(1===arguments.length){const e=arguments[0];throw new C("Should never reach here"+(null!==e?": "+e:""))}}static isTrue(){if(1===arguments.length){const e=arguments[0];x.isTrue(e,null)}else if(2===arguments.length){const e=arguments[1];if(!arguments[0])throw null===e?new C:new C(e)}}static equals(){if(2===arguments.length){const e=arguments[0],t=arguments[1];x.equals(e,t,null)}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];if(!t.equals(e))throw new C("Expected "+e+" but encountered "+t+(null!==n?": "+n:""))}}}const v=new ArrayBuffer(8),S=new Float64Array(v),T=new Int32Array(v);class I{constructor(){I.constructor_.apply(this,arguments)}static constructor_(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)I.constructor_.call(this,0,0);else if(1===arguments.length){const e=arguments[0];I.constructor_.call(this,e.x,e.y,e.getZ())}else if(2===arguments.length){const e=arguments[0],t=arguments[1];I.constructor_.call(this,e,t,I.NULL_ORDINATE)}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];this.x=e,this.y=t,this.z=n}}static hashCode(e){return S[0]=e,T[0]^T[1]}getM(){return _.NaN}setOrdinate(e,t){switch(e){case I.X:this.x=t;break;case I.Y:this.y=t;break;case I.Z:this.setZ(t);break;default:throw new h("Invalid ordinate index: "+e)}}equals2D(){if(1===arguments.length){const e=arguments[0];return this.x===e.x&&this.y===e.y}if(2===arguments.length){const e=arguments[0],t=arguments[1];return!!f.equalsWithTolerance(this.x,e.x,t)&&!!f.equalsWithTolerance(this.y,e.y,t)}}setM(e){throw new h("Invalid ordinate index: "+I.M)}getZ(){return this.z}getOrdinate(e){switch(e){case I.X:return this.x;case I.Y:return this.y;case I.Z:return this.getZ()}throw new h("Invalid ordinate index: "+e)}equals3D(e){return this.x===e.x&&this.y===e.y&&(this.getZ()===e.getZ()||_.isNaN(this.getZ())&&_.isNaN(e.getZ()))}equals(e){return e instanceof I&&this.equals2D(e)}equalInZ(e,t){return f.equalsWithTolerance(this.getZ(),e.getZ(),t)}setX(e){this.x=e}compareTo(e){const t=e;return this.xt.x?1:this.yt.y?1:0}getX(){return this.x}setZ(e){this.z=e}clone(){try{return null}catch(e){if(e instanceof CloneNotSupportedException)return x.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw e}}copy(){return new I(this)}toString(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}distance3D(e){const t=this.x-e.x,n=this.y-e.y,i=this.getZ()-e.getZ();return Math.sqrt(t*t+n*n+i*i)}getY(){return this.y}setY(e){this.y=e}distance(e){const t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}hashCode(){let e=17;return e=37*e+I.hashCode(this.x),e=37*e+I.hashCode(this.y),e}setCoordinate(e){this.x=e.x,this.y=e.y,this.z=e.getZ()}get interfaces_(){return[d,m,g]}}class w{constructor(){w.constructor_.apply(this,arguments)}static constructor_(){if(this._dimensionsToTest=2,0===arguments.length)w.constructor_.call(this,2);else if(1===arguments.length){const e=arguments[0];if(2!==e&&3!==e)throw new h("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e}}static compare(e,t){return et?1:_.isNaN(e)?_.isNaN(t)?0:-1:_.isNaN(t)?1:0}compare(e,t){const n=w.compare(e.x,t.x);if(0!==n)return n;const i=w.compare(e.y,t.y);if(0!==i)return i;if(this._dimensionsToTest<=2)return 0;return w.compare(e.getZ(),t.getZ())}get interfaces_(){return[y]}}I.DimensionalComparator=w,I.NULL_ORDINATE=_.NaN,I.X=0,I.Y=1,I.Z=2,I.M=3;class E{constructor(){E.constructor_.apply(this,arguments)}static constructor_(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof I){const e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else if(arguments[0]instanceof E){const e=arguments[0];this.init(e)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.init(e.x,t.x,e.y,t.y)}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];this.init(e,t,n,i)}}static intersects(){if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];return n.x>=(e.xt.x?e.x:t.x)&&n.y>=(e.yt.y?e.y:t.y)}if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];let r=Math.min(n.x,i.x),o=Math.max(n.x,i.x),s=Math.min(e.x,t.x),a=Math.max(e.x,t.x);return!(s>o)&&(!(ao)&&!(ae._minx?this._minx:e._minx,n=this._miny>e._miny?this._miny:e._miny,i=this._maxx=this._minx&&e.getMaxX()<=this._maxx&&e.getMinY()>=this._miny&&e.getMaxY()<=this._maxy)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];return!this.isNull()&&(e>=this._minx&&e<=this._maxx&&t>=this._miny&&t<=this._maxy)}}intersects(){if(1===arguments.length){if(arguments[0]instanceof E){const e=arguments[0];return!this.isNull()&&!e.isNull()&&!(e._minx>this._maxx||e._maxxthis._maxy||e._maxythis._maxx)return!1;if((e.x>t.x?e.x:t.x)this._maxy)return!1;return!((e.y>t.y?e.y:t.y)this._maxx||ethis._maxy||tthis._maxx&&(this._maxx=e._maxx),e._minythis._maxy&&(this._maxy=e._maxy))}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.isNull()?(this._minx=e,this._maxx=e,this._miny=t,this._maxy=t):(ethis._maxx&&(this._maxx=e),tthis._maxy&&(this._maxy=t))}}minExtent(){if(this.isNull())return 0;const e=this.getWidth(),t=this.getHeight();return et._minx?1:this._minyt._miny?1:this._maxxt._maxx?1:this._maxyt._maxy?1:0}translate(e,t){if(this.isNull())return null;this.init(this.getMinX()+e,this.getMaxX()+e,this.getMinY()+t,this.getMaxY()+t)}copy(){return new E(this)}toString(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"}setToNull(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1}disjoint(e){return!(!this.isNull()&&!e.isNull())||(e._minx>this._maxx||e._maxxthis._maxy||e._maxyt?e:t}expandBy(){if(1===arguments.length){const e=arguments[0];this.expandBy(e,e)}else if(2===arguments.length){const e=arguments[0],t=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=t,this._maxy+=t,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}contains(){if(1===arguments.length){if(arguments[0]instanceof E){const e=arguments[0];return this.covers(e)}if(arguments[0]instanceof I){const e=arguments[0];return this.covers(e)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];return this.covers(e,t)}}centre(){return this.isNull()?null:new I((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}init(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof I){const e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else if(arguments[0]instanceof E){const e=arguments[0];this._minx=e._minx,this._maxx=e._maxx,this._miny=e._miny,this._maxy=e._maxy}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.init(e.x,t.x,e.y,t.y)}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];ee._maxx&&(t=this._minx-e._maxx);let n=0;return this._maxye._maxy&&(n=this._miny-e._maxy),0===t?n:0===n?t:Math.sqrt(t*t+n*n)}hashCode(){let e=17;return e=37*e+I.hashCode(this._minx),e=37*e+I.hashCode(this._maxx),e=37*e+I.hashCode(this._miny),e=37*e+I.hashCode(this._maxy),e}get interfaces_(){return[d,g]}}class A{constructor(){A.constructor_.apply(this,arguments)}isGeometryCollection(){return this.getTypeCode()===A.TYPECODE_GEOMETRYCOLLECTION}getFactory(){return this._factory}getGeometryN(e){return this}getArea(){return 0}isRectangle(){return!1}equalsExact(e){return this===e||this.equalsExact(e,0)}geometryChanged(){this.apply(A.geometryChangedFilter)}geometryChangedAction(){this._envelope=null}equalsNorm(e){return null!==e&&this.norm().equalsExact(e.norm())}getLength(){return 0}getNumGeometries(){return 1}compareTo(){let e;if(1===arguments.length){const t=arguments[0];return e=t,this.getTypeCode()!==e.getTypeCode()?this.getTypeCode()-e.getTypeCode():this.isEmpty()&&e.isEmpty()?0:this.isEmpty()?-1:e.isEmpty()?1:this.compareToSameClass(t)}if(2===arguments.length){const t=arguments[0],n=arguments[1];return e=t,this.getTypeCode()!==e.getTypeCode()?this.getTypeCode()-e.getTypeCode():this.isEmpty()&&e.isEmpty()?0:this.isEmpty()?-1:e.isEmpty()?1:this.compareToSameClass(t,n)}}getUserData(){return this._userData}getSRID(){return this._SRID}getEnvelope(){return this.getFactory().toGeometry(this.getEnvelopeInternal())}checkNotGeometryCollection(e){if(e.getTypeCode()===A.TYPECODE_GEOMETRYCOLLECTION)throw new h("This method does not support GeometryCollection arguments")}equal(e,t,n){return 0===n?e.equals(t):e.distance(t)<=n}norm(){const e=this.copy();return e.normalize(),e}reverse(){const e=this.reverseInternal();return null!=this.envelope&&(e.envelope=this.envelope.copy()),e.setSRID(this.getSRID()),e}copy(){const e=this.copyInternal();return e.envelope=null==this._envelope?null:this._envelope.copy(),e._SRID=this._SRID,e._userData=this._userData,e}getPrecisionModel(){return this._factory.getPrecisionModel()}getEnvelopeInternal(){return null===this._envelope&&(this._envelope=this.computeEnvelopeInternal()),new E(this._envelope)}setSRID(e){this._SRID=e}setUserData(e){this._userData=e}compare(e,t){const n=e.iterator(),i=t.iterator();for(;n.hasNext()&&i.hasNext();){const e=n.next(),t=i.next(),r=e.compareTo(t);if(0!==r)return r}return n.hasNext()?1:i.hasNext()?-1:0}hashCode(){return this.getEnvelopeInternal().hashCode()}isEquivalentClass(e){return this.getClass()===e.getClass()}isGeometryCollectionOrDerived(){return this.getTypeCode()===A.TYPECODE_GEOMETRYCOLLECTION||this.getTypeCode()===A.TYPECODE_MULTIPOINT||this.getTypeCode()===A.TYPECODE_MULTILINESTRING||this.getTypeCode()===A.TYPECODE_MULTIPOLYGON}get interfaces_(){return[m,d,g]}getClass(){return A}static hasNonEmptyElements(e){for(let t=0;t-1}class D{}class R{getM(e){if(this.hasM()){const t=this.getDimension()-this.getMeasures();return this.getOrdinate(e,t)}return _.NaN}setOrdinate(e,t,n){}getZ(e){return this.hasZ()?this.getOrdinate(e,2):_.NaN}size(){}getOrdinate(e,t){}getCoordinate(){}getCoordinateCopy(e){}createCoordinate(){}getDimension(){}hasM(){return this.getMeasures()>0}getX(e){}hasZ(){return this.getDimension()-this.getMeasures()>2}getMeasures(){return 0}expandEnvelope(e){}copy(){}getY(e){}toCoordinateArray(){}get interfaces_(){return[m]}}R.X=0,R.Y=1,R.Z=2,R.M=3;class P{static copyCoord(e,t,n,i){const r=Math.min(e.getDimension(),n.getDimension());for(let o=0;o0)&&(i=t,n=r)}return n}}static extend(e,t,n){const i=e.create(n,t.getDimension()),r=t.size();if(P.copy(t,0,i,0,r),r>0)for(let e=r;e0)&&(t=i)}return t}}class L extends c{constructor(e){super(e),this.name=Object.keys({UnsupportedOperationException:L})[0]}}class O{static isWhitespace(e){return e<=32&&e>=0||127===e}static toUpperCase(e){return e.toUpperCase()}}class F{static toDimensionSymbol(e){switch(e){case F.FALSE:return F.SYM_FALSE;case F.TRUE:return F.SYM_TRUE;case F.DONTCARE:return F.SYM_DONTCARE;case F.P:return F.SYM_P;case F.L:return F.SYM_L;case F.A:return F.SYM_A}throw new h("Unknown dimension value: "+e)}static toDimensionValue(e){switch(O.toUpperCase(e)){case F.SYM_FALSE:return F.FALSE;case F.SYM_TRUE:return F.TRUE;case F.SYM_DONTCARE:return F.DONTCARE;case F.SYM_P:return F.P;case F.SYM_L:return F.L;case F.SYM_A:return F.A}throw new h("Unknown dimension symbol: "+e)}}F.P=0,F.L=1,F.A=2,F.FALSE=-1,F.TRUE=-2,F.DONTCARE=-3,F.SYM_FALSE="F",F.SYM_TRUE="T",F.SYM_DONTCARE="*",F.SYM_P="0",F.SYM_L="1",F.SYM_A="2";class k{filter(e){}}class B{filter(e,t){}isDone(){}isGeometryChanged(){}}class G extends A{constructor(){super(),G.constructor_.apply(this,arguments)}static constructor_(){if(this._points=null,0===arguments.length);else if(2===arguments.length){const e=arguments[0],t=arguments[1];A.constructor_.call(this,t),this.init(e)}}computeEnvelopeInternal(){return this.isEmpty()?new E:this._points.expandEnvelope(new E)}isRing(){return this.isClosed()&&this.isSimple()}getCoordinates(){return this._points.toCoordinateArray()}copyInternal(){return new G(this._points.copy(),this._factory)}equalsExact(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof A){const e=arguments[0],t=arguments[1];if(!this.isEquivalentClass(e))return!1;const n=e;if(this._points.size()!==n._points.size())return!1;for(let e=0;e0){const e=this._points.copy();P.reverse(e),this._points=e}return null}}}getCoordinate(){return this.isEmpty()?null:this._points.getCoordinate(0)}getBoundaryDimension(){return this.isClosed()?F.FALSE:0}isClosed(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}reverseInternal(){const e=this._points.copy();return P.reverse(e),this.getFactory().createLineString(e)}getEndPoint(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}getTypeCode(){return A.TYPECODE_LINESTRING}getDimension(){return 1}getLength(){return class{static ofLine(e){const t=e.size();if(t<=1)return 0;let n=0;const i=new I;e.getCoordinate(0,i);let r=i.x,o=i.y;for(let s=1;s= 2)");this._points=e}isCoordinate(e){for(let t=0;t=this.size())throw new W;return this.array[e]}isEmpty(){return 0===this.array.length}sort(e){e?this.array.sort(((t,n)=>e.compare(t,n))):this.array.sort()}size(){return this.array.length}toArray(){return this.array.slice()}remove(e){for(let t=0,n=this.array.length;t=1){if(this.get(this.size()-1).equals2D(e))return null}super.add.call(this,e)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){const e=arguments[0],t=arguments[1];return this.add(e,t),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){const e=arguments[0],t=arguments[1];if(arguments[2])for(let n=0;n=0;n--)this.add(e[n],t);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof I){const e=arguments[0],t=arguments[1];if(!arguments[2]){const n=this.size();if(n>0){if(e>0){if(this.get(e-1).equals2D(t))return null}if(ei&&(r=-1);for(let o=n;o!==i;o+=r)this.add(e[o],t);return!0}}closeRing(){if(this.size()>0){const e=this.get(0).copy();this.add(e,!1)}}}Y.coordArrayType=new Array(0).fill(null);class q{create(){if(1===arguments.length)arguments[0]instanceof Array||N(arguments[0],R);else if(2===arguments.length);else if(3===arguments.length){const e=arguments[0],t=arguments[1];return this.create(e,t)}}}class K{}class X extends A{constructor(){super(),X.constructor_.apply(this,arguments)}static constructor_(){this._coordinates=null;const e=arguments[0],t=arguments[1];A.constructor_.call(this,t),this.init(e)}computeEnvelopeInternal(){if(this.isEmpty())return new E;const e=new E;return e.expandToInclude(this._coordinates.getX(0),this._coordinates.getY(0)),e}getCoordinates(){return this.isEmpty()?[]:[this.getCoordinate()]}copyInternal(){return new X(this._coordinates.copy(),this._factory)}equalsExact(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof A){const e=arguments[0],t=arguments[1];return!!this.isEquivalentClass(e)&&(!(!this.isEmpty()||!e.isEmpty())||this.isEmpty()===e.isEmpty()&&this.equal(e.getCoordinate(),this.getCoordinate(),t))}return super.equalsExact.apply(this,arguments)}normalize(){}getCoordinate(){return 0!==this._coordinates.size()?this._coordinates.getCoordinate(0):null}getBoundaryDimension(){return F.FALSE}reverseInternal(){return this.getFactory().createPoint(this._coordinates.copy())}getTypeCode(){return A.TYPECODE_POINT}getDimension(){return 0}getNumPoints(){return this.isEmpty()?0:1}getX(){if(null===this.getCoordinate())throw new IllegalStateException("getX called on empty Point");return this.getCoordinate().x}compareToSameClass(){if(1===arguments.length){const e=arguments[0];return this.getCoordinate().compareTo(e.getCoordinate())}if(2===arguments.length){const e=arguments[0];return arguments[1].compare(this._coordinates,e._coordinates)}}apply(){if(N(arguments[0],M)){const e=arguments[0];if(this.isEmpty())return null;e.filter(this.getCoordinate())}else if(N(arguments[0],B)){const e=arguments[0];if(this.isEmpty())return null;e.filter(this._coordinates,0),e.isGeometryChanged()&&this.geometryChanged()}else if(N(arguments[0],k)){arguments[0].filter(this)}else if(N(arguments[0],u)){arguments[0].filter(this)}}getBoundary(){return this.getFactory().createGeometryCollection()}getGeometryType(){return A.TYPENAME_POINT}getCoordinateSequence(){return this._coordinates}getY(){if(null===this.getCoordinate())throw new IllegalStateException("getY called on empty Point");return this.getCoordinate().y}isEmpty(){return 0===this._coordinates.size()}init(e){null===e&&(e=this.getFactory().getCoordinateSequenceFactory().create([])),x.isTrue(e.size()<=1),this._coordinates=e}isSimple(){return!0}get interfaces_(){return[K]}}class J{static ofRing(){if(arguments[0]instanceof Array){const e=arguments[0];return Math.abs(J.ofRingSigned(e))}if(N(arguments[0],R)){const e=arguments[0];return Math.abs(J.ofRingSigned(e))}}static ofRingSigned(){if(arguments[0]instanceof Array){const e=arguments[0];if(e.length<3)return 0;let t=0;const n=e[0].x;for(let i=1;ie.compareTo(t)));else if(2===arguments.length)e.sort(((e,t)=>arguments[1].compare(e,t)));else if(3===arguments.length){const t=e.slice(arguments[1],arguments[2]);t.sort();const n=e.slice(0,arguments[1]).concat(t,e.slice(arguments[2],e.length));e.splice(0,e.length);for(const t of n)e.push(t)}else if(4===arguments.length){const t=e.slice(arguments[1],arguments[2]);t.sort(((e,t)=>arguments[3].compare(e,t)));const n=e.slice(0,arguments[1]).concat(t,e.slice(arguments[2],e.length));e.splice(0,e.length);for(const t of n)e.push(t)}}static asList(e){const t=new j;for(const n of e)t.add(n);return t}static copyOf(e,t){return e.slice(0,t)}}class Q{constructor(e){this.str=e}append(e){this.str+=e}setCharAt(e,t){this.str=this.str.substr(0,e)+t+this.str.substr(e+1)}toString(){return this.str}}class ee{constructor(e){this.value=e}intValue(){return this.value}compareTo(e){return this.valuee?1:0}static compare(e,t){return et?1:0}static isNan(e){return Number.isNaN(e)}static valueOf(e){return new ee(e)}}class te{constructor(){te.constructor_.apply(this,arguments)}static constructor_(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){const e=arguments[0];this.init(e)}else if(arguments[0]instanceof te){const e=arguments[0];this.init(e)}else if("string"==typeof arguments[0]){const e=arguments[0];te.constructor_.call(this,te.parse(e))}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.init(e,t)}}static determinant(){if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];return te.determinant(te.valueOf(e),te.valueOf(t),te.valueOf(n),te.valueOf(i))}if(arguments[3]instanceof te&&arguments[2]instanceof te&&arguments[0]instanceof te&&arguments[1]instanceof te){const e=arguments[1],t=arguments[2],n=arguments[3];return arguments[0].multiply(n).selfSubtract(e.multiply(t))}}static sqr(e){return te.valueOf(e).selfMultiply(e)}static valueOf(){if("string"==typeof arguments[0]){const e=arguments[0];return te.parse(e)}if("number"==typeof arguments[0]){return new te(arguments[0])}}static sqrt(e){return te.valueOf(e).sqrt()}static parse(e){let t=0;const n=e.length;for(;O.isWhitespace(e.charAt(t));)t++;let i=!1;if(t=n);){const n=e.charAt(t);if(t++,O.isDigit(n)){const e=n-"0";r.selfMultiply(te.TEN),r.selfAdd(e),o++}else{if("."!==n){if("e"===n||"E"===n){const n=e.substring(t);try{a=ee.parseInt(n)}catch(t){throw t instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+n+" in string "+e):t}break}throw new NumberFormatException("Unexpected character '"+n+"' at position "+t+" in string "+e)}s=o,l=!0}}let c=r;l||(s=o);const h=o-s-a;if(0===h)c=r;else if(h>0){const e=te.TEN.pow(h);c=r.divide(e)}else if(h<0){const e=te.TEN.pow(-h);c=r.multiply(e)}return i?c.negate():c}static createNaN(){return new te(_.NaN,_.NaN)}static copy(e){return new te(e)}static magnitude(e){const t=Math.abs(e),n=Math.log(t)/Math.log(10);let i=Math.trunc(Math.floor(n));return 10*Math.pow(10,i)<=t&&(i+=1),i}static stringOfChar(e,t){const n=new Q;for(let i=0;i9?(r=!0,l="9"):l="0"+i,s.append(l),n=n.subtract(te.valueOf(i)).multiply(te.TEN),r&&n.selfAdd(te.TEN);let c=!0;const h=te.magnitude(n._hi);if(h<0&&Math.abs(h)>=a-t&&(c=!1),!c)break}return t[0]=i,s.toString()}sqr(){return this.multiply(this)}doubleValue(){return this._hi+this._lo}subtract(){if(arguments[0]instanceof te){const e=arguments[0];return this.add(e.negate())}if("number"==typeof arguments[0]){const e=arguments[0];return this.add(-e)}}equals(){if(1===arguments.length&&arguments[0]instanceof te){const e=arguments[0];return this._hi===e._hi&&this._lo===e._lo}}isZero(){return 0===this._hi&&0===this._lo}selfSubtract(){if(arguments[0]instanceof te){const e=arguments[0];return this.isNaN()?this:this.selfAdd(-e._hi,-e._lo)}if("number"==typeof arguments[0]){const e=arguments[0];return this.isNaN()?this:this.selfAdd(-e,0)}}getSpecialNumberString(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}min(e){return this.le(e)?this:e}selfDivide(){if(1===arguments.length){if(arguments[0]instanceof te){const e=arguments[0];return this.selfDivide(e._hi,e._lo)}if("number"==typeof arguments[0]){const e=arguments[0];return this.selfDivide(e,0)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];let n=null,i=null,r=null,o=null,s=null,a=null,l=null,c=null;return s=this._hi/e,a=te.SPLIT*s,n=a-s,c=te.SPLIT*e,n=a-n,i=s-n,r=c-e,l=s*e,r=c-r,o=e-r,c=n*r-l+n*o+i*r+i*o,a=(this._hi-l-c+this._lo-s*t)/e,c=s+a,this._hi=c,this._lo=s-c+a,this}}dump(){return"DD<"+this._hi+", "+this._lo+">"}divide(){if(arguments[0]instanceof te){const e=arguments[0];let t=null,n=null,i=null,r=null,o=null,s=null,a=null,l=null;o=this._hi/e._hi,s=te.SPLIT*o,t=s-o,l=te.SPLIT*e._hi,t=s-t,n=o-t,i=l-e._hi,a=o*e._hi,i=l-i,r=e._hi-i,l=t*i-a+t*r+n*i+n*r,s=(this._hi-a-l+this._lo-o*e._lo)/e._hi,l=o+s;return new te(l,o-l+s)}if("number"==typeof arguments[0]){const e=arguments[0];return _.isNaN(e)?te.createNaN():te.copy(this).selfDivide(e,0)}}ge(e){return this._hi>e._hi||this._hi===e._hi&&this._lo>=e._lo}pow(e){if(0===e)return te.valueOf(1);let t=new te(this),n=te.valueOf(1),i=Math.abs(e);if(i>1)for(;i>0;)i%2==1&&n.selfMultiply(t),i/=2,i>0&&(t=t.sqr());else n=t;return e<0?n.reciprocal():n}ceil(){if(this.isNaN())return te.NaN;const e=Math.ceil(this._hi);let t=0;return e===this._hi&&(t=Math.ceil(this._lo)),new te(e,t)}compareTo(e){const t=e;return this._hit._hi?1:this._lot._lo?1:0}rint(){if(this.isNaN())return this;return this.add(.5).floor()}setValue(){if(arguments[0]instanceof te){const e=arguments[0];return this.init(e),this}if("number"==typeof arguments[0]){const e=arguments[0];return this.init(e),this}}max(e){return this.ge(e)?this:e}sqrt(){if(this.isZero())return te.valueOf(0);if(this.isNegative())return te.NaN;const e=1/Math.sqrt(this._hi),t=this._hi*e,n=te.valueOf(t),i=this.subtract(n.sqr())._hi*(.5*e);return n.add(i)}selfAdd(){if(1===arguments.length){if(arguments[0]instanceof te){const e=arguments[0];return this.selfAdd(e._hi,e._lo)}if("number"==typeof arguments[0]){const e=arguments[0];let t=null,n=null,i=null,r=null,o=null,s=null;return i=this._hi+e,o=i-this._hi,r=i-o,r=e-o+(this._hi-r),s=r+this._lo,t=i+s,n=s+(i-t),this._hi=t+n,this._lo=n+(t-this._hi),this}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];let n=null,i=null,r=null,o=null,s=null,a=null,l=null,c=null;s=this._hi+e,r=this._lo+t,l=s-this._hi,c=r-this._lo,a=s-l,o=r-c,a=e-l+(this._hi-a),o=t-c+(this._lo-o),l=a+r,n=s+l,i=l+(s-n),l=o+i;const h=n+l,u=l+(n-h);return this._hi=h,this._lo=u,this}}selfMultiply(){if(1===arguments.length){if(arguments[0]instanceof te){const e=arguments[0];return this.selfMultiply(e._hi,e._lo)}if("number"==typeof arguments[0]){const e=arguments[0];return this.selfMultiply(e,0)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];let n=null,i=null,r=null,o=null,s=null,a=null;s=te.SPLIT*this._hi,n=s-this._hi,a=te.SPLIT*e,n=s-n,i=this._hi-n,r=a-e,s=this._hi*e,r=a-r,o=e-r,a=n*r-s+n*o+i*r+i*o+(this._hi*t+this._lo*e);const l=s+a;n=s-l;const c=a+n;return this._hi=l,this._lo=c,this}}selfSqr(){return this.selfMultiply(this)}floor(){if(this.isNaN())return te.NaN;const e=Math.floor(this._hi);let t=0;return e===this._hi&&(t=Math.floor(this._lo)),new te(e,t)}negate(){return this.isNaN()?this:new te(-this._hi,-this._lo)}clone(){try{return null}catch(e){if(e instanceof CloneNotSupportedException)return null;throw e}}multiply(){if(arguments[0]instanceof te){const e=arguments[0];return e.isNaN()?te.createNaN():te.copy(this).selfMultiply(e)}if("number"==typeof arguments[0]){const e=arguments[0];return _.isNaN(e)?te.createNaN():te.copy(this).selfMultiply(e,0)}}isNaN(){return _.isNaN(this._hi)}intValue(){return Math.trunc(this._hi)}toString(){const e=te.magnitude(this._hi);return e>=-3&&e<=20?this.toStandardNotation():this.toSciNotation()}toStandardNotation(){const e=this.getSpecialNumberString();if(null!==e)return e;const t=new Array(1).fill(null),n=this.extractSignificantDigits(!0,t),i=t[0]+1;let r=n;if("."===n.charAt(0))r="0"+n;else if(i<0)r="0."+te.stringOfChar("0",-i)+n;else if(-1===n.indexOf(".")){const e=i-n.length;r=n+te.stringOfChar("0",e)+".0"}return this.isNegative()?"-"+r:r}reciprocal(){let e=null,t=null,n=null,i=null,r=null,o=null,s=null,a=null;r=1/this._hi,o=te.SPLIT*r,e=o-r,a=te.SPLIT*this._hi,e=o-e,t=r-e,n=a-this._hi,s=r*this._hi,n=a-n,i=this._hi-n,a=e*n-s+e*i+t*n+t*i,o=(1-s-a-r*this._lo)/this._hi;const l=r+o;return new te(l,r-l+o)}toSciNotation(){if(this.isZero())return te.SCI_NOT_ZERO;const e=this.getSpecialNumberString();if(null!==e)return e;const t=new Array(1).fill(null),n=this.extractSignificantDigits(!1,t),i=te.SCI_NOT_EXPONENT_CHAR+t[0];if("0"===n.charAt(0))throw new IllegalStateException("Found leading zero: "+n);let r="";n.length>1&&(r=n.substring(1));const o=n.charAt(0)+"."+r;return this.isNegative()?"-"+o+i:o+i}abs(){return this.isNaN()?te.NaN:this.isNegative()?this.negate():new te(this)}isPositive(){return this._hi>0||0===this._hi&&this._lo>0}lt(e){return this._hie._hi||this._hi===e._hi&&this._lo>e._lo}isNegative(){return this._hi<0||0===this._hi&&this._lo<0}trunc(){return this.isNaN()?te.NaN:this.isPositive()?this.floor():this.ceil()}signum(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0}get interfaces_(){return[g,d,m]}}te.PI=new te(3.141592653589793,12246467991473532e-32),te.TWO_PI=new te(6.283185307179586,24492935982947064e-32),te.PI_2=new te(1.5707963267948966,6123233995736766e-32),te.E=new te(2.718281828459045,14456468917292502e-32),te.NaN=new te(_.NaN,_.NaN),te.EPS=123259516440783e-46,te.SPLIT=134217729,te.MAX_PRINT_DIGITS=32,te.TEN=te.valueOf(10),te.ONE=te.valueOf(1),te.SCI_NOT_EXPONENT_CHAR="E",te.SCI_NOT_ZERO="0.0E0";class ne{static orientationIndex(e,t,n){const i=ne.orientationIndexFilter(e,t,n);if(i<=1)return i;const r=te.valueOf(t.x).selfAdd(-e.x),o=te.valueOf(t.y).selfAdd(-e.y),s=te.valueOf(n.x).selfAdd(-t.x),a=te.valueOf(n.y).selfAdd(-t.y);return r.selfMultiply(a).selfSubtract(o.selfMultiply(s)).signum()}static signOfDet2x2(){if(arguments[3]instanceof te&&arguments[2]instanceof te&&arguments[0]instanceof te&&arguments[1]instanceof te){const e=arguments[1],t=arguments[2],n=arguments[3];return arguments[0].multiply(n).selfSubtract(e.multiply(t)).signum()}if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3],r=te.valueOf(e),o=te.valueOf(t),s=te.valueOf(n),a=te.valueOf(i);return r.multiply(a).selfSubtract(o.multiply(s)).signum()}}static intersection(e,t,n,i){const r=new te(e.y).selfSubtract(t.y),o=new te(t.x).selfSubtract(e.x),s=new te(e.x).selfMultiply(t.y).selfSubtract(new te(t.x).selfMultiply(e.y)),a=new te(n.y).selfSubtract(i.y),l=new te(i.x).selfSubtract(n.x),c=new te(n.x).selfMultiply(i.y).selfSubtract(new te(i.x).selfMultiply(n.y)),h=o.multiply(c).selfSubtract(l.multiply(s)),u=a.multiply(s).selfSubtract(r.multiply(c)),d=r.multiply(l).selfSubtract(a.multiply(o)),m=h.selfDivide(d).doubleValue(),g=u.selfDivide(d).doubleValue();return _.isNaN(m)||_.isInfinite(m)||_.isNaN(g)||_.isInfinite(g)?null:new I(m,g)}static orientationIndexFilter(e,t,n){let i=null;const r=(e.x-n.x)*(t.y-n.y),o=(e.y-n.y)*(t.x-n.x),s=r-o;if(r>0){if(o<=0)return ne.signum(s);i=r+o}else{if(!(r<0))return ne.signum(s);if(o>=0)return ne.signum(s);i=-r-o}const a=ne.DP_SAFE_EPSILON*i;return s>=a||-s>=a?ne.signum(s):2}static signum(e){return e>0?1:e<0?-1:0}}ne.DP_SAFE_EPSILON=1e-15;class ie{static index(e,t,n){return ne.orientationIndex(e,t,n)}static isCCW(){if(arguments[0]instanceof Array){const e=arguments[0],t=e.length-1;if(t<3)throw new h("Ring has fewer than 4 points, so orientation cannot be determined");let n=e[0],i=0;for(let r=1;r<=t;r++){const t=e[r];t.y>n.y&&(n=t,i=r)}let r=i;do{r-=1,r<0&&(r=t)}while(e[r].equals2D(n)&&r!==i);let o=i;do{o=(o+1)%t}while(e[o].equals2D(n)&&o!==i);const s=e[r],a=e[o];if(s.equals2D(n)||a.equals2D(n)||s.equals2D(a))return!1;const l=ie.index(s,n,a);let c=null;return c=0===l?s.x>a.x:l>0,c}if(N(arguments[0],R)){const e=arguments[0],t=e.size()-1;if(t<3)throw new h("Ring has fewer than 4 points, so orientation cannot be determined");let n=e.getCoordinate(0),i=0;for(let r=1;r<=t;r++){const t=e.getCoordinate(r);t.y>n.y&&(n=t,i=r)}let r=null,o=i;do{o-=1,o<0&&(o=t),r=e.getCoordinate(o)}while(r.equals2D(n)&&o!==i);let s=null,a=i;do{a=(a+1)%t,s=e.getCoordinate(a)}while(s.equals2D(n)&&a!==i);if(r.equals2D(n)||s.equals2D(n)||r.equals2D(s))return!1;const l=ie.index(r,n,s);let c=null;return c=0===l?r.x>s.x:l>0,c}}}ie.CLOCKWISE=-1,ie.RIGHT=ie.CLOCKWISE,ie.COUNTERCLOCKWISE=1,ie.LEFT=ie.COUNTERCLOCKWISE,ie.COLLINEAR=0,ie.STRAIGHT=ie.COLLINEAR;class re{}class oe extends A{constructor(){super(),oe.constructor_.apply(this,arguments)}static constructor_(){this._shell=null,this._holes=null;let e=arguments[0],t=arguments[1],n=arguments[2];if(A.constructor_.call(this,n),null===e&&(e=this.getFactory().createLinearRing()),null===t&&(t=[]),A.hasNullElements(t))throw new h("holes must not contain null elements");if(e.isEmpty()&&A.hasNonEmptyElements(t))throw new h("shell is empty but holes are not");this._shell=e,this._holes=t}computeEnvelopeInternal(){return this._shell.getEnvelopeInternal()}getCoordinates(){if(this.isEmpty())return[];const e=new Array(this.getNumPoints()).fill(null);let t=-1;const n=this._shell.getCoordinates();for(let i=0;i=1&&this.getCoordinateSequence().size()= 4)")}getGeometryType(){return A.TYPENAME_LINEARRING}}de.MINIMUM_VALID_SIZE=4;class me extends I{constructor(){super(),me.constructor_.apply(this,arguments)}static constructor_(){if(0===arguments.length)I.constructor_.call(this);else if(1===arguments.length){if(arguments[0]instanceof me){const e=arguments[0];I.constructor_.call(this,e.x,e.y)}else if(arguments[0]instanceof I){const e=arguments[0];I.constructor_.call(this,e.x,e.y)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];I.constructor_.call(this,e,t,I.NULL_ORDINATE)}}setOrdinate(e,t){switch(e){case me.X:this.x=t;break;case me.Y:this.y=t;break;default:throw new h("Invalid ordinate index: "+e)}}getZ(){return I.NULL_ORDINATE}getOrdinate(e){switch(e){case me.X:return this.x;case me.Y:return this.y}throw new h("Invalid ordinate index: "+e)}setZ(e){throw new h("CoordinateXY dimension 2 does not support z-ordinate")}copy(){return new me(this)}toString(){return"("+this.x+", "+this.y+")"}setCoordinate(e){this.x=e.x,this.y=e.y,this.z=e.getZ()}}me.X=0,me.Y=1,me.Z=-1,me.M=-1;class ge extends I{constructor(){super(),ge.constructor_.apply(this,arguments)}static constructor_(){if(this._m=null,0===arguments.length)I.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof ge){const e=arguments[0];I.constructor_.call(this,e.x,e.y),this._m=e._m}else if(arguments[0]instanceof I){const e=arguments[0];I.constructor_.call(this,e.x,e.y),this._m=this.getM()}}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];I.constructor_.call(this,e,t,I.NULL_ORDINATE),this._m=n}}getM(){return this._m}setOrdinate(e,t){switch(e){case ge.X:this.x=t;break;case ge.Y:this.y=t;break;case ge.M:this._m=t;break;default:throw new h("Invalid ordinate index: "+e)}}setM(e){this._m=e}getZ(){return I.NULL_ORDINATE}getOrdinate(e){switch(e){case ge.X:return this.x;case ge.Y:return this.y;case ge.M:return this._m}throw new h("Invalid ordinate index: "+e)}setZ(e){throw new h("CoordinateXY dimension 2 does not support z-ordinate")}copy(){return new ge(this)}toString(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}setCoordinate(e){this.x=e.x,this.y=e.y,this.z=e.getZ(),this._m=e.getM()}}ge.X=0,ge.Y=1,ge.Z=-1,ge.M=2;class fe extends I{constructor(){super(),fe.constructor_.apply(this,arguments)}static constructor_(){if(this._m=null,0===arguments.length)I.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof fe){const e=arguments[0];I.constructor_.call(this,e),this._m=e._m}else if(arguments[0]instanceof I){const e=arguments[0];I.constructor_.call(this,e),this._m=this.getM()}}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];I.constructor_.call(this,e,t,n),this._m=i}}getM(){return this._m}setOrdinate(e,t){switch(e){case I.X:this.x=t;break;case I.Y:this.y=t;break;case I.Z:this.z=t;break;case I.M:this._m=t;break;default:throw new h("Invalid ordinate index: "+e)}}setM(e){this._m=e}getOrdinate(e){switch(e){case I.X:return this.x;case I.Y:return this.y;case I.Z:return this.getZ();case I.M:return this.getM()}throw new h("Invalid ordinate index: "+e)}copy(){return new fe(this)}toString(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}setCoordinate(e){this.x=e.x,this.y=e.y,this.z=e.getZ(),this._m=e.getM()}}class pe{static measures(e){return e instanceof me?0:e instanceof ge||e instanceof fe?1:0}static dimension(e){return e instanceof me?2:e instanceof ge?3:e instanceof fe?4:3}static create(){if(1===arguments.length){const e=arguments[0];return pe.create(e,0)}if(2===arguments.length){const e=arguments[0],t=arguments[1];return 2===e?new me:3===e&&0===t?new I:3===e&&1===t?new ge:4===e&&1===t?new fe:new I}}}class _e{static log10(e){const t=Math.log(e);return _.isInfinite(t)||_.isNaN(t)?t:t/_e.LOG_10}static min(e,t,n,i){let r=e;return tn?n:e}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){const e=arguments[0],t=arguments[1],n=arguments[2];return en?n:e}}static wrap(e,t){return e<0?t- -e%t:e%t}static max(){if(3===arguments.length){const e=arguments[1],t=arguments[2];let n=arguments[0];return e>n&&(n=e),t>n&&(n=t),n}if(4===arguments.length){const e=arguments[1],t=arguments[2],n=arguments[3];let i=arguments[0];return e>i&&(i=e),t>i&&(i=t),n>i&&(i=n),i}}static average(e,t){return(e+t)/2}}_e.LOG_10=Math.log(10);class ye{static arraycopy(e,t,n,i,r){let o=0;for(let s=t;s=e?t:[]}static indexOf(e,t){for(let n=0;n0)&&(t=e[n]);return t}static extract(e,t,n){t=_e.clamp(t,0,e.length);let i=(n=_e.clamp(n,-1,e.length))-t+1;n<0&&(i=0),t>=e.length&&(i=0),ni.length)return 1;if(0===n.length)return 0;const r=be.compare(n,i);return be.isEqualReversed(n,i)?0:r}OLDcompare(e,t){const n=e,i=t;if(n.lengthi.length)return 1;if(0===n.length)return 0;const r=be.increasingDirection(n),o=be.increasingDirection(i);let s=r>0?0:n.length-1,a=o>0?0:n.length-1;for(let e=0;e0){const e=new Ce(17*this._coordinates.length);e.append("("),e.append(this._coordinates[0]);for(let t=1;t3&&(e=3),e<2&&(e=2),new xe(arguments[0],e)}if(3===arguments.length){let e=arguments[2],t=arguments[1]-e;return e>1&&(e=1),t>3&&(t=3),t<2&&(t=2),new xe(arguments[0],t+e,e)}}}get interfaces_(){return[q,g]}}ve.instanceObject=new ve;class Se extends he{constructor(){super(),Se.constructor_.apply(this,arguments)}static constructor_(){const e=arguments[0],t=arguments[1];he.constructor_.call(this,e,t)}copyInternal(){const e=new Array(this._geometries.length).fill(null);for(let t=0;te.add(t))),e}size(){return this.map.size()}}class Ae{constructor(){Ae.constructor_.apply(this,arguments)}static constructor_(){if(this._modelType=null,this._scale=null,0===arguments.length)this._modelType=Ae.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof Me){const e=arguments[0];this._modelType=e,e===Ae.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){const e=arguments[0];this._modelType=Ae.FIXED,this.setScale(e)}else if(arguments[0]instanceof Ae){const e=arguments[0];this._modelType=e._modelType,this._scale=e._scale}}static mostPrecise(e,t){return e.compareTo(t)>=0?e:t}equals(e){if(!(e instanceof Ae))return!1;const t=e;return this._modelType===t._modelType&&this._scale===t._scale}compareTo(e){const t=e,n=this.getMaximumSignificantDigits(),i=t.getMaximumSignificantDigits();return ee.compare(n,i)}getScale(){return this._scale}isFloating(){return this._modelType===Ae.FLOATING||this._modelType===Ae.FLOATING_SINGLE}getType(){return this._modelType}toString(){let e="UNKNOWN";return this._modelType===Ae.FLOATING?e="Floating":this._modelType===Ae.FLOATING_SINGLE?e="Floating-Single":this._modelType===Ae.FIXED&&(e="Fixed (Scale="+this.getScale()+")"),e}makePrecise(){if("number"==typeof arguments[0]){const e=arguments[0];if(_.isNaN(e))return e;if(this._modelType===Ae.FLOATING_SINGLE){return e}return this._modelType===Ae.FIXED?Math.round(e*this._scale)/this._scale:e}if(arguments[0]instanceof I){const e=arguments[0];if(this._modelType===Ae.FLOATING)return null;e.x=this.makePrecise(e.x),e.y=this.makePrecise(e.y)}}getMaximumSignificantDigits(){let e=16;return this._modelType===Ae.FLOATING?e=16:this._modelType===Ae.FLOATING_SINGLE?e=6:this._modelType===Ae.FIXED&&(e=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),e}setScale(e){this._scale=Math.abs(e)}get interfaces_(){return[g,d]}}class Me{constructor(){Me.constructor_.apply(this,arguments)}static constructor_(){this._name=null;const e=arguments[0];this._name=e,Me.nameToTypeMap.put(e,this)}readResolve(){return Me.nameToTypeMap.get(this._name)}toString(){return this._name}get interfaces_(){return[g]}}Me.nameToTypeMap=new Ee,Ae.Type=Me,Ae.FIXED=new Me("FIXED"),Ae.FLOATING=new Me("FLOATING"),Ae.FLOATING_SINGLE=new Me("FLOATING SINGLE"),Ae.maximumPreciseValue=9007199254740992;class Ne extends he{constructor(){super(),Ne.constructor_.apply(this,arguments)}static constructor_(){const e=arguments[0],t=arguments[1];he.constructor_.call(this,e,t)}copyInternal(){const e=new Array(this._geometries.length).fill(null);for(let t=0;t1){if(r instanceof oe)return this.createMultiPolygon(De.toPolygonArray(e));if(r instanceof G)return this.createMultiLineString(De.toLineStringArray(e));if(r instanceof X)return this.createMultiPoint(De.toPointArray(e));x.shouldNeverReachHere("Unhandled geometry type: "+r.getGeometryType())}return r}createMultiPointFromCoords(e){return this.createMultiPoint(null!==e?this.getCoordinateSequenceFactory().create(e):null)}createPoint(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof I){const e=arguments[0];return this.createPoint(null!==e?this.getCoordinateSequenceFactory().create([e]):null)}if(N(arguments[0],R)){return new X(arguments[0],this)}}}getCoordinateSequenceFactory(){return this._coordinateSequenceFactory}createPolygon(){if(0===arguments.length)return this.createPolygon(null,null);if(1===arguments.length){if(N(arguments[0],R)){const e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof Array){const e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof de){const e=arguments[0];return this.createPolygon(e,null)}}else if(2===arguments.length){return new oe(arguments[0],arguments[1],this)}}getSRID(){return this._SRID}createGeometryCollection(){if(0===arguments.length)return new he(null,this);if(1===arguments.length){return new he(arguments[0],this)}}getPrecisionModel(){return this._precisionModel}createLinearRing(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){const e=arguments[0];return this.createLinearRing(null!==e?this.getCoordinateSequenceFactory().create(e):null)}if(N(arguments[0],R)){return new de(arguments[0],this)}}}createMultiPolygon(){if(0===arguments.length)return new Se(null,this);if(1===arguments.length){return new Se(arguments[0],this)}}createMultiPoint(){if(0===arguments.length)return new ue(null,this);if(1===arguments.length){if(arguments[0]instanceof Array){return new ue(arguments[0],this)}if(N(arguments[0],R)){const e=arguments[0];if(null===e)return this.createMultiPoint(new Array(0).fill(null));const t=new Array(e.size()).fill(null);for(let n=0;n0&&i<4&&!this._preserveType?this._factory.createLineString(n):this._factory.createLinearRing(n)}}class Pe{static intersection(e,t,n,i){const r=e.xt.x?e.x:t.x,a=e.y>t.y?e.y:t.y,l=n.xi.x?n.x:i.x,u=n.y>i.y?n.y:i.y,d=((r>l?r:l)+(sc?o:c)+(a1||a<0||a>1)&&(r=!0)}}else r=!0;return r?_e.min(Le.pointToSegment(e,n,i),Le.pointToSegment(t,n,i),Le.pointToSegment(n,e,t),Le.pointToSegment(i,e,t)):0}static pointToSegment(e,t,n){if(t.x===n.x&&t.y===n.y)return e.distance(t);const i=(n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y),r=((e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y))/i;if(r<=0)return e.distance(t);if(r>=1)return e.distance(n);const o=((t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y))/i;return Math.abs(o)*Math.sqrt(i)}static pointToLinePerpendicular(e,t,n){const i=(n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y),r=((t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y))/i;return Math.abs(r)*Math.sqrt(i)}static pointToSegmentString(e,t){if(0===t.length)throw new h("Line array must contain at least one vertex");let n=e.distance(t[0]);for(let i=0;i="a"&&e<="z"||e>="A"&&e<="Z"}isNumeric_(e,t){return e>="0"&&e<="9"||"."==e&&!(void 0!==t&&t)}isWhiteSpace_(e){return" "==e||"\t"==e||"\r"==e||"\n"==e}nextChar_(){return this.wkt.charAt(++this.index_)}nextToken(){const e=this.nextChar_(),t=this.index_;let n,i=e;if("("==e)n=We;else if(","==e)n=je;else if(")"==e)n=He;else if(this.isNumeric_(e)||"-"==e)n=Ue,i=this.readNumber_();else if(this.isAlpha_(e))n=ze,i=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(""!==e)throw new Error("Unexpected character: "+e);n=Ve}return{position:t,value:i,type:n}}readNumber_(){let e;const t=this.index_;let n=!1,i=!1;do{"."==e?n=!0:"e"!=e&&"E"!=e||(i=!0),e=this.nextChar_()}while(this.isNumeric_(e,n)||!i&&("e"==e||"E"==e)||i&&("-"==e||"+"==e));return parseFloat(this.wkt.substring(t,this.index_--))}readText_(){let e;const t=this.index_;do{e=this.nextChar_()}while(this.isAlpha_(e));return this.wkt.substring(t,this.index_--).toUpperCase()}}class Ke{constructor(e,t){this.lexer_=e,this.token_,this.layout_=Oe,this.factory=t}consume_(){this.token_=this.lexer_.nextToken()}isTokenType(e){return this.token_.type==e}match(e){const t=this.isTokenType(e);return t&&this.consume_(),t}parse(){this.consume_();return this.parseGeometry_()}parseGeometryLayout_(){let e=Oe;const t=this.token_;if(this.isTokenType(ze)){const n=t.value;"Z"===n?e=Fe:"M"===n?e=ke:"ZM"===n&&(e=Be),e!==Oe&&this.consume_()}return e}parseGeometryCollectionText_(){if(this.match(We)){const e=[];do{e.push(this.parseGeometry_())}while(this.match(je));if(this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(We)){const e=this.parsePoint_();if(this.match(He))return e}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(We)){const e=this.parsePointList_();if(this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(We)){const e=this.parseLineStringTextList_();if(this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(We)){let e;if(e=this.token_.type==We?this.parsePointTextList_():this.parsePointList_(),this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(We)){const e=this.parseLineStringTextList_();if(this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(We)){const e=this.parsePolygonTextList_();if(this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parsePoint_(){const e=[],t=this.layout_.length;for(let n=0;nnew I(...e),n=n=>{const i=n.map((n=>e.createLinearRing(n.map(t))));return i.length>1?e.createPolygon(i[0],i.slice(1)):e.createPolygon(i[0])},i=this.token_;if(this.match(ze)){const r=i.value;if(this.layout_=this.parseGeometryLayout_(),"GEOMETRYCOLLECTION"==r){const t=this.parseGeometryCollectionText_();return e.createGeometryCollection(t)}switch(r){case"POINT":{const t=this.parsePointText_();return t?e.createPoint(new I(...t)):e.createPoint()}case"LINESTRING":{const n=this.parseLineStringText_().map(t);return e.createLineString(n)}case"LINEARRING":{const n=this.parseLineStringText_().map(t);return e.createLinearRing(n)}case"POLYGON":{const t=this.parsePolygonText_();return t&&0!==t.length?n(t):e.createPolygon()}case"MULTIPOINT":{const n=this.parseMultiPointText_();if(!n||0===n.length)return e.createMultiPoint();const i=n.map(t).map((t=>e.createPoint(t)));return e.createMultiPoint(i)}case"MULTILINESTRING":{const n=this.parseMultiLineStringText_().map((n=>e.createLineString(n.map(t))));return e.createMultiLineString(n)}case"MULTIPOLYGON":{const t=this.parseMultiPolygonText_();if(!t||0===t.length)return e.createMultiPolygon();const i=t.map(n);return e.createMultiPolygon(i)}default:throw new Error("Invalid geometry type: "+r)}}throw new Error(this.formatErrorMessage_())}}function Xe(e){if(e.isEmpty())return"";const t=e.getCoordinate(),n=[t.x,t.y];return void 0===t.z||Number.isNaN(t.z)||n.push(t.z),void 0===t.m||Number.isNaN(t.m)||n.push(t.m),n.join(" ")}function Je(e){const t=e.getCoordinates().map((e=>{const t=[e.x,e.y];return void 0===e.z||Number.isNaN(e.z)||t.push(e.z),void 0===e.m||Number.isNaN(e.m)||t.push(e.m),t})),n=[];for(let e=0,i=t.length;e0&&(t+=" "+i),e.isEmpty())return t+" EMPTY";return t+" ("+n(e)+")"}class et{constructor(e){this.geometryFactory=e||new De,this.precisionModel=this.geometryFactory.getPrecisionModel()}read(e){const t=new qe(e);return new Ke(t,this.geometryFactory).parse()}write(e){return $e(e)}}class tt{constructor(e){this.parser=new et(e)}write(e){return this.parser.write(e)}static toLineString(e,t){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+e.x+" "+e.y+", "+t.x+" "+t.y+" )"}}class nt{constructor(){nt.constructor_.apply(this,arguments)}static constructor_(){this._result=null,this._inputLines=Array(2).fill().map((()=>Array(2))),this._intPt=new Array(2).fill(null),this._intLineIndex=null,this._isProper=null,this._pa=null,this._pb=null,this._precisionModel=null,this._intPt[0]=new I,this._intPt[1]=new I,this._pa=this._intPt[0],this._pb=this._intPt[1],this._result=0}static computeEdgeDistance(e,t,n){const i=Math.abs(n.x-t.x),r=Math.abs(n.y-t.y);let o=-1;if(e.equals(t))o=0;else if(e.equals(n))o=i>r?i:r;else{const n=Math.abs(e.x-t.x),s=Math.abs(e.y-t.y);o=i>r?n:s,0!==o||e.equals(t)||(o=Math.max(n,s))}return x.isTrue(!(0===o&&!e.equals(t)),"Bad distance calculation"),o}static nonRobustComputeEdgeDistance(e,t,n){const i=e.x-t.x,r=e.y-t.y,o=Math.sqrt(i*i+r*r);return x.isTrue(!(0===o&&!e.equals(t)),"Invalid distance calculation"),o}getIndexAlongSegment(e,t){return this.computeIntLineIndex(),this._intLineIndex[e][t]}getTopologySummary(){const e=new Ce;return this.isEndPoint()&&e.append(" endpoint"),this._isProper&&e.append(" proper"),this.isCollinear()&&e.append(" collinear"),e.toString()}computeIntersection(e,t,n,i){this._inputLines[0][0]=e,this._inputLines[0][1]=t,this._inputLines[1][0]=n,this._inputLines[1][1]=i,this._result=this.computeIntersect(e,t,n,i)}getIntersectionNum(){return this._result}computeIntLineIndex(){if(0===arguments.length)null===this._intLineIndex&&(this._intLineIndex=Array(2).fill().map((()=>Array(2))),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){const e=arguments[0];this.getEdgeDistance(e,0)>this.getEdgeDistance(e,1)?(this._intLineIndex[e][0]=0,this._intLineIndex[e][1]=1):(this._intLineIndex[e][0]=1,this._intLineIndex[e][1]=0)}}isProper(){return this.hasIntersection()&&this._isProper}setPrecisionModel(e){this._precisionModel=e}isInteriorIntersection(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){const e=arguments[0];for(let t=0;t1e-4&&ye.out.println("Distance = "+r.distance(o))}intersectionSafe(e,t,n,i){let r=Pe.intersection(e,t,n,i);return null===r&&(r=it.nearestEndpoint(e,t,n,i)),r}computeCollinearIntersection(e,t,n,i){const r=E.intersects(e,t,n),o=E.intersects(e,t,i),s=E.intersects(n,i,e),a=E.intersects(n,i,t);return r&&o?(this._intPt[0]=n,this._intPt[1]=i,nt.COLLINEAR_INTERSECTION):s&&a?(this._intPt[0]=e,this._intPt[1]=t,nt.COLLINEAR_INTERSECTION):r&&s?(this._intPt[0]=n,this._intPt[1]=e,!n.equals(e)||o||a?nt.COLLINEAR_INTERSECTION:nt.POINT_INTERSECTION):r&&a?(this._intPt[0]=n,this._intPt[1]=t,!n.equals(t)||o||s?nt.COLLINEAR_INTERSECTION:nt.POINT_INTERSECTION):o&&s?(this._intPt[0]=i,this._intPt[1]=e,!i.equals(e)||r||a?nt.COLLINEAR_INTERSECTION:nt.POINT_INTERSECTION):o&&a?(this._intPt[0]=i,this._intPt[1]=t,!i.equals(t)||r||s?nt.COLLINEAR_INTERSECTION:nt.POINT_INTERSECTION):nt.NO_INTERSECTION}computeIntersect(e,t,n,i){if(this._isProper=!1,!E.intersects(e,t,n,i))return nt.NO_INTERSECTION;const r=ie.index(e,t,n),o=ie.index(e,t,i);if(r>0&&o>0||r<0&&o<0)return nt.NO_INTERSECTION;const s=ie.index(n,i,e),a=ie.index(n,i,t);if(s>0&&a>0||s<0&&a<0)return nt.NO_INTERSECTION;return 0===r&&0===o&&0===s&&0===a?this.computeCollinearIntersection(e,t,n,i):(0===r||0===o||0===s||0===a?(this._isProper=!1,e.equals2D(n)||e.equals2D(i)?this._intPt[0]=e:t.equals2D(n)||t.equals2D(i)?this._intPt[0]=t:0===r?this._intPt[0]=new I(n):0===o?this._intPt[0]=new I(i):0===s?this._intPt[0]=new I(e):0===a&&(this._intPt[0]=new I(t))):(this._isProper=!0,this._intPt[0]=this.intersection(e,t,n,i)),nt.POINT_INTERSECTION)}}class rt{constructor(){rt.constructor_.apply(this,arguments)}static constructor_(){if(this.p0=null,this.p1=null,0===arguments.length)rt.constructor_.call(this,new I,new I);else if(1===arguments.length){const e=arguments[0];rt.constructor_.call(this,e.p0,e.p1)}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.p0=e,this.p1=t}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];rt.constructor_.call(this,new I(e,t),new I(n,i))}}static midPoint(e,t){return new I((e.x+t.x)/2,(e.y+t.y)/2)}minX(){return Math.min(this.p0.x,this.p1.x)}orientationIndex(){if(arguments[0]instanceof rt){const e=arguments[0],t=ie.index(this.p0,this.p1,e.p0),n=ie.index(this.p0,this.p1,e.p1);return t>=0&&n>=0||t<=0&&n<=0?Math.max(t,n):0}if(arguments[0]instanceof I){const e=arguments[0];return ie.index(this.p0,this.p1,e)}}toGeometry(e){return e.createLineString([this.p0,this.p1])}isVertical(){return this.p0.x===this.p1.x}equals(e){if(!(e instanceof rt))return!1;const t=e;return this.p0.equals(t.p0)&&this.p1.equals(t.p1)}intersection(e){const t=new it;return t.computeIntersection(this.p0,this.p1,e.p0,e.p1),t.hasIntersection()?t.getIntersection(0):null}project(){if(arguments[0]instanceof I){const e=arguments[0];if(e.equals(this.p0)||e.equals(this.p1))return new I(e);const t=this.projectionFactor(e),n=new I;return n.x=this.p0.x+t*(this.p1.x-this.p0.x),n.y=this.p0.y+t*(this.p1.y-this.p0.y),n}if(arguments[0]instanceof rt){const e=arguments[0],t=this.projectionFactor(e.p0),n=this.projectionFactor(e.p1);if(t>=1&&n>=1)return null;if(t<=0&&n<=0)return null;let i=this.project(e.p0);t<0&&(i=this.p0),t>1&&(i=this.p1);let r=this.project(e.p1);return n<0&&(r=this.p0),n>1&&(r=this.p1),new rt(i,r)}}normalize(){this.p1.compareTo(this.p0)<0&&this.reverse()}angle(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)}getCoordinate(e){return 0===e?this.p0:this.p1}distancePerpendicular(e){return Le.pointToLinePerpendicular(e,this.p0,this.p1)}minY(){return Math.min(this.p0.y,this.p1.y)}midPoint(){return rt.midPoint(this.p0,this.p1)}projectionFactor(e){if(e.equals(this.p0))return 0;if(e.equals(this.p1))return 1;const t=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,i=t*t+n*n;if(i<=0)return _.NaN;return((e.x-this.p0.x)*t+(e.y-this.p0.y)*n)/i}closestPoints(e){const t=this.intersection(e);if(null!==t)return[t,t];const n=new Array(2).fill(null);let i=_.MAX_VALUE,r=null;const o=this.closestPoint(e.p0);i=o.distance(e.p0),n[0]=o,n[1]=e.p0;const s=this.closestPoint(e.p1);r=s.distance(e.p1),r0&&t<1)return this.project(e);return this.p0.distance(e)1||_.isNaN(t))&&(t=1),t}toString(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"}isHorizontal(){return this.p0.y===this.p1.y}reflect(e){const t=this.p1.getY()-this.p0.getY(),n=this.p0.getX()-this.p1.getX(),i=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),r=t*t+n*n,o=t*t-n*n,s=e.getX(),a=e.getY();return new I((-o*s-2*t*n*a-2*t*i)/r,(o*a-2*t*n*s-2*n*i)/r)}distance(){if(arguments[0]instanceof rt){const e=arguments[0];return Le.segmentToSegment(this.p0,this.p1,e.p0,e.p1)}if(arguments[0]instanceof I){const e=arguments[0];return Le.pointToSegment(e,this.p0,this.p1)}}pointAlong(e){const t=new I;return t.x=this.p0.x+e*(this.p1.x-this.p0.x),t.y=this.p0.y+e*(this.p1.y-this.p0.y),t}hashCode(){let e=_.doubleToLongBits(this.p0.x);e^=31*_.doubleToLongBits(this.p0.y);const t=Math.trunc(e)^Math.trunc(e>>32);let n=_.doubleToLongBits(this.p1.x);n^=31*_.doubleToLongBits(this.p1.y);return t^(Math.trunc(n)^Math.trunc(n>>32))}get interfaces_(){return[d,g]}}class ot{constructor(e){this.parser=new et(e||new De)}read(e){return this.parser.read(e)}}class st{constructor(){st.constructor_.apply(this,arguments)}static constructor_(){if(this._quadrantSegments=st.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=st.CAP_ROUND,this._joinStyle=st.JOIN_ROUND,this._mitreLimit=st.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=st.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){const e=arguments[0];this.setQuadrantSegments(e)}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.setQuadrantSegments(e),this.setEndCapStyle(t)}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];this.setQuadrantSegments(e),this.setEndCapStyle(t),this.setJoinStyle(n),this.setMitreLimit(i)}}static bufferDistanceError(e){const t=Math.PI/2/e;return 1-Math.cos(t/2)}getEndCapStyle(){return this._endCapStyle}isSingleSided(){return this._isSingleSided}setQuadrantSegments(e){this._quadrantSegments=e,0===this._quadrantSegments&&(this._joinStyle=st.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=st.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),e<=0&&(this._quadrantSegments=1),this._joinStyle!==st.JOIN_ROUND&&(this._quadrantSegments=st.DEFAULT_QUADRANT_SEGMENTS)}getJoinStyle(){return this._joinStyle}setJoinStyle(e){this._joinStyle=e}setSimplifyFactor(e){this._simplifyFactor=e<0?0:e}getSimplifyFactor(){return this._simplifyFactor}getQuadrantSegments(){return this._quadrantSegments}setEndCapStyle(e){this._endCapStyle=e}getMitreLimit(){return this._mitreLimit}setMitreLimit(e){this._mitreLimit=e}setSingleSided(e){this._isSingleSided=e}}st.CAP_ROUND=1,st.CAP_FLAT=2,st.CAP_SQUARE=3,st.JOIN_ROUND=1,st.JOIN_MITRE=2,st.JOIN_BEVEL=3,st.DEFAULT_QUADRANT_SEGMENTS=8,st.DEFAULT_MITRE_LIMIT=5,st.DEFAULT_SIMPLIFY_FACTOR=.01;class at{static toLocationSymbol(e){switch(e){case at.EXTERIOR:return"e";case at.BOUNDARY:return"b";case at.INTERIOR:return"i";case at.NONE:return"-"}throw new h("Unknown location value: "+e)}}at.INTERIOR=0,at.BOUNDARY=1,at.EXTERIOR=2,at.NONE=-1;class lt{static opposite(e){return e===lt.LEFT?lt.RIGHT:e===lt.RIGHT?lt.LEFT:e}}lt.ON=0,lt.LEFT=1,lt.RIGHT=2;class ct extends c{constructor(e){super(e),this.name=Object.keys({EmptyStackException:ct})[0]}}class ht extends H{constructor(){super(),this.array=[]}add(e){return this.array.push(e),!0}get(e){if(e<0||e>=this.size())throw new W;return this.array[e]}push(e){return this.array.push(e),e}pop(){if(0===this.array.length)throw new ct;return this.array.pop()}peek(){if(0===this.array.length)throw new ct;return this.array[this.array.length-1]}empty(){return 0===this.array.length}isEmpty(){return this.empty()}search(e){return this.array.indexOf(e)}size(){return this.array.length}toArray(){return this.array.slice()}}class ut{constructor(){ut.constructor_.apply(this,arguments)}static constructor_(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}getCoordinate(){return this._minCoord}getRightmostSide(e,t){let n=this.getRightmostSideOfSegment(e,t);return n<0&&(n=this.getRightmostSideOfSegment(e,t-1)),n<0&&(this._minCoord=null,this.checkForRightmostCoordinate(e)),n}findRightmostEdgeAtVertex(){const e=this._minDe.getEdge().getCoordinates();x.isTrue(this._minIndex>0&&this._minIndexthis._minCoord.y&&n.y>this._minCoord.y&&i===ie.CLOCKWISE)&&(r=!0),r&&(this._minIndex=this._minIndex-1)}getRightmostSideOfSegment(e,t){const n=e.getEdge().getCoordinates();if(t<0||t+1>=n.length)return-1;if(n[t].y===n[t+1].y)return-1;let i=lt.LEFT;return n[t].ythis._minCoord.x)&&(this._minDe=e,this._minIndex=n,this._minCoord=t[n])}findRightmostEdgeAtNode(){const e=this._minDe.getNode().getEdges();this._minDe=e.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}findEdge(e){for(let t=e.iterator();t.hasNext();){const e=t.next();e.isForward()&&this.checkForRightmostCoordinate(e)}x.isTrue(0!==this._minIndex||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this._minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe;this.getRightmostSide(this._minDe,this._minIndex)===lt.LEFT&&(this._orientedDe=this._minDe.getSym())}}class dt extends b{constructor(e,t){super(t?e+" [ "+t+" ]":e),this.pt=t?new I(t):void 0,this.name=Object.keys({TopologyException:dt})[0]}getCoordinate(){return this.pt}}class mt{constructor(){this.array=[]}addLast(e){this.array.push(e)}removeFirst(){return this.array.shift()}isEmpty(){return 0===this.array.length}}class gt{constructor(){gt.constructor_.apply(this,arguments)}static constructor_(){this._finder=null,this._dirEdgeList=new j,this._nodes=new j,this._rightMostCoord=null,this._env=null,this._finder=new ut}clearVisitedEdges(){for(let e=this._dirEdgeList.iterator();e.hasNext();){e.next().setVisited(!1)}}getRightmostCoordinate(){return this._rightMostCoord}computeNodeDepth(e){let t=null;for(let n=e.getEdges().iterator();n.hasNext();){const e=n.next();if(e.isVisited()||e.getSym().isVisited()){t=e;break}}if(null===t)throw new dt("unable to find edge to compute depths at "+e.getCoordinate());e.getEdges().computeDepths(t);for(let t=e.getEdges().iterator();t.hasNext();){const e=t.next();e.setVisited(!0),this.copySymDepths(e)}}computeDepth(e){this.clearVisitedEdges();const t=this._finder.getEdge();t.getNode(),t.getLabel(),t.setEdgeDepths(lt.RIGHT,e),this.copySymDepths(t),this.computeDepths(t)}create(e){this.addReachable(e),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()}findResultEdges(){for(let e=this._dirEdgeList.iterator();e.hasNext();){const t=e.next();t.getDepth(lt.RIGHT)>=1&&t.getDepth(lt.LEFT)<=0&&!t.isInteriorAreaEdge()&&t.setInResult(!0)}}computeDepths(e){const t=new Ie,n=new mt,i=e.getNode();for(n.addLast(i),t.add(i),e.setVisited(!0);!n.isEmpty();){const e=n.removeFirst();t.add(e),this.computeNodeDepth(e);for(let i=e.getEdges().iterator();i.hasNext();){const e=i.next().getSym();if(e.isVisited())continue;const r=e.getNode();t.contains(r)||(n.addLast(r),t.add(r))}}}compareTo(e){const t=e;return this._rightMostCoord.xt._rightMostCoord.x?1:0}getEnvelope(){if(null===this._env){const e=new E;for(let t=this._dirEdgeList.iterator();t.hasNext();){const n=t.next().getEdge().getCoordinates();for(let t=0;ti&&(n=t.x,i=e.x),this._p.x>=n&&this._p.x<=i&&(this._isPointOnSegment=!0),null}if(e.y>this._p.y&&t.y<=this._p.y||t.y>this._p.y&&e.y<=this._p.y){let n=ie.index(e,t,this._p);if(n===ie.COLLINEAR)return this._isPointOnSegment=!0,null;t.ythis.location.length){const e=new Array(3).fill(null);e[lt.ON]=this.location[lt.ON],e[lt.LEFT]=at.NONE,e[lt.RIGHT]=at.NONE,this.location=e}for(let t=0;t1&&e.append(at.toLocationSymbol(this.location[lt.LEFT])),e.append(at.toLocationSymbol(this.location[lt.ON])),this.location.length>1&&e.append(at.toLocationSymbol(this.location[lt.RIGHT])),e.toString()}setLocations(e,t,n){this.location[lt.ON]=e,this.location[lt.LEFT]=t,this.location[lt.RIGHT]=n}get(e){return e1}isAnyNull(){for(let e=0;ethis._maxNodeDegree&&(this._maxNodeDegree=t),e=this.getNext(e)}while(e!==this._startDe);this._maxNodeDegree*=2}addPoints(e,t,n){const i=e.getCoordinates();if(t){let e=1;n&&(e=0);for(let t=e;t=0;t--)this._pts.add(i[t])}}isHole(){return this._isHole}setInResult(){let e=this._startDe;do{e.getEdge().setInResult(!0),e=e.getNext()}while(e!==this._startDe)}containsPoint(e){const t=this.getLinearRing();if(!t.getEnvelopeInternal().contains(e))return!1;if(!pt.isInRing(e,t.getCoordinates()))return!1;for(let t=this._holes.iterator();t.hasNext();){if(t.next().containsPoint(e))return!1}return!0}addHole(e){this._holes.add(e)}isShell(){return null===this._shell}getLabel(){return this._label}getEdges(){return this._edges}getMaxNodeDegree(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree}getShell(){return this._shell}mergeLabel(){if(1===arguments.length){const e=arguments[0];this.mergeLabel(e,0),this.mergeLabel(e,1)}else if(2===arguments.length){const e=arguments[1],t=arguments[0].getLocation(e,lt.RIGHT);if(t===at.NONE)return null;if(this._label.getLocation(e)===at.NONE)return this._label.setLocation(e,t),null}}setShell(e){this._shell=e,null!==e&&e.addHole(this)}toPolygon(e){const t=new Array(this._holes.size()).fill(null);for(let e=0;e=2,"found partial label"),this.computeIM(e)}isInResult(){return this._isInResult}isVisited(){return this._isVisited}}class St extends vt{constructor(){super(),St.constructor_.apply(this,arguments)}static constructor_(){this._coord=null,this._edges=null;const e=arguments[0],t=arguments[1];this._coord=e,this._edges=t,this._label=new yt(0,at.NONE)}isIncidentEdgeInResult(){for(let e=this.getEdges().getEdges().iterator();e.hasNext();){if(e.next().getEdge().isInResult())return!0}return!1}isIsolated(){return 1===this._label.getGeometryCount()}getCoordinate(){return this._coord}print(e){e.println("node "+this._coord+" lbl: "+this._label)}computeIM(e){}computeMergedLocation(e,t){let n=at.NONE;if(n=this._label.getLocation(t),!e.isNull(t)){const i=e.getLocation(t);n!==at.BOUNDARY&&(n=i)}return n}setLabel(){if(2!==arguments.length||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return super.setLabel.apply(this,arguments);{const e=arguments[0],t=arguments[1];null===this._label?this._label=new yt(e,t):this._label.setLocation(e,t)}}getEdges(){return this._edges}mergeLabel(){if(arguments[0]instanceof St){const e=arguments[0];this.mergeLabel(e._label)}else if(arguments[0]instanceof yt){const e=arguments[0];for(let t=0;t<2;t++){const n=this.computeMergedLocation(e,t);this._label.getLocation(t)===at.NONE&&this._label.setLocation(t,n)}}}add(e){this._edges.insert(e),e.setNode(this)}setLabelBoundary(e){if(null===this._label)return null;let t=at.NONE;null!==this._label&&(t=this._label.getLocation(e));let n=null;switch(t){case at.BOUNDARY:n=at.INTERIOR;break;case at.INTERIOR:default:n=at.BOUNDARY}this._label.setLocation(e,n)}}class Tt extends Te{}function It(e){return null==e?0:e.color}function wt(e){return null==e?null:e.parent}function Et(e,t){null!==e&&(e.color=t)}function At(e){return null==e?null:e.left}function Mt(e){return null==e?null:e.right}class Nt extends Tt{constructor(){super(),this.root_=null,this.size_=0}get(e){let t=this.root_;for(;null!==t;){const n=e.compareTo(t.key);if(n<0)t=t.left;else{if(!(n>0))return t.value;t=t.right}}return null}put(e,t){if(null===this.root_)return this.root_={key:e,value:t,left:null,right:null,parent:null,color:0,getValue(){return this.value},getKey(){return this.key}},this.size_=1,null;let n,i,r=this.root_;do{if(n=r,i=e.compareTo(r.key),i<0)r=r.left;else{if(!(i>0)){const e=r.value;return r.value=t,e}r=r.right}}while(null!==r);const o={key:e,left:null,right:null,value:t,parent:n,color:0,getValue(){return this.value},getKey(){return this.key}};return i<0?n.left=o:n.right=o,this.fixAfterInsertion(o),this.size_++,null}fixAfterInsertion(e){let t;for(e.color=1;null!=e&&e!==this.root_&&1===e.parent.color;)wt(e)===At(wt(wt(e)))?(t=Mt(wt(wt(e))),1===It(t)?(Et(wt(e),0),Et(t,0),Et(wt(wt(e)),1),e=wt(wt(e))):(e===Mt(wt(e))&&(e=wt(e),this.rotateLeft(e)),Et(wt(e),0),Et(wt(wt(e)),1),this.rotateRight(wt(wt(e))))):(t=At(wt(wt(e))),1===It(t)?(Et(wt(e),0),Et(t,0),Et(wt(wt(e)),1),e=wt(wt(e))):(e===At(wt(e))&&(e=wt(e),this.rotateRight(e)),Et(wt(e),0),Et(wt(wt(e)),1),this.rotateLeft(wt(wt(e)))));this.root_.color=0}values(){const e=new j;let t=this.getFirstEntry();if(null!==t)for(e.add(t.value);null!==(t=Nt.successor(t));)e.add(t.value);return e}entrySet(){const e=new Ie;let t=this.getFirstEntry();if(null!==t)for(e.add(t);null!==(t=Nt.successor(t));)e.add(t);return e}rotateLeft(e){if(null!=e){const t=e.right;e.right=t.left,null!=t.left&&(t.left.parent=e),t.parent=e.parent,null==e.parent?this.root_=t:e.parent.left===e?e.parent.left=t:e.parent.right=t,t.left=e,e.parent=t}}rotateRight(e){if(null!=e){const t=e.left;e.left=t.right,null!=t.right&&(t.right.parent=e),t.parent=e.parent,null==e.parent?this.root_=t:e.parent.right===e?e.parent.right=t:e.parent.left=t,t.right=e,e.parent=t}}getFirstEntry(){let e=this.root_;if(null!=e)for(;null!=e.left;)e=e.left;return e}static successor(e){let t;if(null===e)return null;if(null!==e.right){for(t=e.right;null!==t.left;)t=t.left;return t}{t=e.parent;let n=e;for(;null!==t&&n===t.right;)n=t,t=t.parent;return t}}size(){return this.size_}containsKey(e){let t=this.root_;for(;null!==t;){const n=e.compareTo(t.key);if(n<0)t=t.left;else{if(!(n>0))return!0;t=t.right}}return!1}}class Dt{constructor(){Dt.constructor_.apply(this,arguments)}static constructor_(){this.nodeMap=new Nt,this.nodeFact=null;const e=arguments[0];this.nodeFact=e}find(e){return this.nodeMap.get(e)}addNode(){if(arguments[0]instanceof I){const e=arguments[0];let t=this.nodeMap.get(e);return null===t&&(t=this.nodeFact.createNode(e),this.nodeMap.put(e,t)),t}if(arguments[0]instanceof St){const e=arguments[0],t=this.nodeMap.get(e.getCoordinate());return null===t?(this.nodeMap.put(e.getCoordinate(),e),e):(t.mergeLabel(e),t)}}print(e){for(let t=this.iterator();t.hasNext();){t.next().print(e)}}iterator(){return this.nodeMap.values().iterator()}values(){return this.nodeMap.values()}getBoundaryNodes(e){const t=new j;for(let n=this.iterator();n.hasNext();){const i=n.next();i.getLabel().getLocation(e)===at.BOUNDARY&&t.add(i)}return t}add(e){const t=e.getCoordinate();this.addNode(t).add(e)}}class Rt{static isNorthern(e){return e===Rt.NE||e===Rt.NW}static isOpposite(e,t){if(e===t)return!1;return 2===(e-t+4)%4}static commonHalfPlane(e,t){if(e===t)return e;if(2===(e-t+4)%4)return-1;const n=et?e:t)?3:n}static isInHalfPlane(e,t){return t===Rt.SE?e===Rt.SE||e===Rt.SW:e===t||e===t+1}static quadrant(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){const e=arguments[0],t=arguments[1];if(0===e&&0===t)throw new h("Cannot compute the quadrant for point ( "+e+", "+t+" )");return e>=0?t>=0?Rt.NE:Rt.SE:t>=0?Rt.NW:Rt.SW}if(arguments[0]instanceof I&&arguments[1]instanceof I){const e=arguments[0],t=arguments[1];if(t.x===e.x&&t.y===e.y)throw new h("Cannot compute the quadrant for two identical points "+e);return t.x>=e.x?t.y>=e.y?Rt.NE:Rt.SE:t.y>=e.y?Rt.NW:Rt.SW}}}Rt.NE=0,Rt.NW=1,Rt.SW=2,Rt.SE=3;class Pt{constructor(){Pt.constructor_.apply(this,arguments)}static constructor_(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,1===arguments.length){const e=arguments[0];this._edge=e}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];Pt.constructor_.call(this,e,t,n,null)}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];Pt.constructor_.call(this,e),this.init(t,n),this._label=i}}compareDirection(e){return this._dx===e._dx&&this._dy===e._dy?0:this._quadrant>e._quadrant?1:this._quadrant2){e.linkDirectedEdgesForMinimalEdgeRings();const i=e.buildMinimalRings(),r=this.findShell(i);null!==r?(this.placePolygonHoles(r,i),t.add(r)):n.addAll(i)}else i.add(e)}return i}buildMaximalEdgeRings(e){const t=new j;for(let n=e.iterator();n.hasNext();){const e=n.next();if(e.isInResult()&&e.getLabel().isArea()&&null===e.getEdgeRing()){const n=new xt(e,this._geometryFactory);t.add(n),n.setInResult()}}return t}placePolygonHoles(e,t){for(let n=t.iterator();n.hasNext();){const t=n.next();t.isHole()&&t.setShell(e)}}getPolygons(){return this.computePolygons(this._shellList)}findShell(e){let t=0,n=null;for(let i=e.iterator();i.hasNext();){const e=i.next();e.isHole()||(n=e,t++)}return x.isTrue(t<=1,"found two shells in MinimalEdgeRing list"),n}add(){if(1===arguments.length){const e=arguments[0];this.add(e.getEdgeEnds(),e.getNodes())}else if(2===arguments.length){const e=arguments[0],t=arguments[1];Ft.linkResultDirectedEdges(t);const n=this.buildMaximalEdgeRings(e),i=new j,r=this.buildMinimalEdgeRings(n,this._shellList,i);this.sortShellsAndHoles(r,this._shellList,i),this.placeFreeHoles(this._shellList,i)}}}class Bt{getBounds(){}}class Gt{constructor(){Gt.constructor_.apply(this,arguments)}static constructor_(){this._bounds=null,this._item=null;const e=arguments[0],t=arguments[1];this._bounds=e,this._item=t}getItem(){return this._item}getBounds(){return this._bounds}get interfaces_(){return[Bt,g]}}class zt{constructor(){zt.constructor_.apply(this,arguments)}static constructor_(){this._size=null,this._items=null,this._size=0,this._items=new j,this._items.add(null)}poll(){if(this.isEmpty())return null;const e=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),e}size(){return this._size}reorder(e){let t=null;const n=this._items.get(e);for(;2*e<=this._size&&(t=2*e,t!==this._size&&this._items.get(t+1).compareTo(this._items.get(t))<0&&t++,this._items.get(t).compareTo(n)<0);e=t)this._items.set(e,this._items.get(t));this._items.set(e,n)}clear(){this._size=0,this._items.clear()}peek(){if(this.isEmpty())return null;return this._items.get(1)}isEmpty(){return 0===this._size}add(e){this._items.add(null),this._size+=1;let t=this._size;for(this._items.set(0,e);e.compareTo(this._items.get(Math.trunc(t/2)))<0;t/=2)this._items.set(t,this._items.get(Math.trunc(t/2)));this._items.set(t,e)}}class Wt{insert(e,t){}remove(e,t){}query(){}}class Ht{constructor(){Ht.constructor_.apply(this,arguments)}static constructor_(){if(this._childBoundables=new j,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){const e=arguments[0];this._level=e}}getLevel(){return this._level}size(){return this._childBoundables.size()}getChildBoundables(){return this._childBoundables}addChildBoundable(e){x.isTrue(null===this._bounds),this._childBoundables.add(e)}isEmpty(){return this._childBoundables.isEmpty()}getBounds(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds}get interfaces_(){return[Bt,g]}}const Ut={reverseOrder:function(){return{compare:(e,t)=>t.compareTo(e)}},min:function(e){return Ut.sort(e),e.get(0)},sort:function(e,t){const n=e.toArray();t?Z.sort(n,t):Z.sort(n);const i=e.iterator();for(let e=0,t=n.length;eVt.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,e,t),null):(this.expand(this._boundable2,this._boundable1,!0,e,t),null);if(n)return this.expand(this._boundable1,this._boundable2,!1,e,t),null;if(i)return this.expand(this._boundable2,this._boundable1,!0,e,t),null;throw new h("neither boundable is composite")}isLeaves(){return!(Vt.isComposite(this._boundable1)||Vt.isComposite(this._boundable2))}compareTo(e){const t=e;return this._distancet._distance?1:0}expand(e,t,n,i,r){for(let o=e.getChildBoundables().iterator();o.hasNext();){const e=o.next();let s=null;s=n?new Vt(t,e,this._itemDistance):new Vt(e,t,this._itemDistance),s.getDistance()1,"Node capacity must be greater than 1"),this._nodeCapacity=e}}static compareDoubles(e,t){return e>t?1:e-2),t.getLevel()===e)return n.add(t),null;for(let i=t.getChildBoundables().iterator();i.hasNext();){const t=i.next();t instanceof Ht?this.boundablesAtLevel(e,t,n):(x.isTrue(t instanceof Gt),-1===e&&n.add(t))}return null}}query(){if(1===arguments.length){const e=arguments[0];this.build();const t=new j;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.queryInternal(e,this._root,t),t}if(2===arguments.length){const e=arguments[0],t=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.queryInternal(e,this._root,t)}}build(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0}getRoot(){return this.build(),this._root}remove(){if(2===arguments.length){const e=arguments[0],t=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.remove(e,this._root,t)}if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];let i=this.removeItem(t,n);if(i)return!0;let r=null;for(let o=t.getChildBoundables().iterator();o.hasNext();){const t=o.next();if(this.getIntersectsOp().intersects(t.getBounds(),e)&&(t instanceof Ht&&(i=this.remove(e,t,n),i))){r=t;break}}return null!==r&&r.getChildBoundables().isEmpty()&&t.getChildBoundables().remove(r),i}}createHigherLevels(e,t){x.isTrue(!e.isEmpty());const n=this.createParentBoundables(e,t+1);return 1===n.size()?n.get(0):this.createHigherLevels(n,t+1)}depth(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(1===arguments.length){let e=0;for(let t=arguments[0].getChildBoundables().iterator();t.hasNext();){const n=t.next();if(n instanceof Ht){const t=this.depth(n);t>e&&(e=t)}}return e+1}}createParentBoundables(e,t){x.isTrue(!e.isEmpty());const n=new j;n.add(this.createNode(t));const i=new j(e);Ut.sort(i,this.getComparator());for(let e=i.iterator();e.hasNext();){const i=e.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(t)),this.lastNode(n).addChildBoundable(i)}return n}isEmpty(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}get interfaces_(){return[g]}}qt.IntersectsOp=function(){},qt.DEFAULT_NODE_CAPACITY=10;class Kt{distance(e,t){}}class Xt extends qt{constructor(){super(),Xt.constructor_.apply(this,arguments)}static constructor_(){if(0===arguments.length)Xt.constructor_.call(this,Xt.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){const e=arguments[0];qt.constructor_.call(this,e)}}static centreX(e){return Xt.avg(e.getMinX(),e.getMaxX())}static avg(e,t){return(e+t)/2}static getItems(e){const t=new Array(e.size()).fill(null);let n=0;for(;!e.isEmpty();){const i=e.poll();t[n]=i.getBoundable(0).getItem(),n++}return t}static centreY(e){return Xt.avg(e.getMinY(),e.getMaxY())}createParentBoundablesFromVerticalSlices(e,t){x.isTrue(e.length>0);const n=new j;for(let i=0;i=0;){const e=i.poll(),o=e.getDistance();if(o>=n)break;if(e.isLeaves())if(r.size()o&&(r.poll(),r.add(e));n=r.peek().getDistance()}else e.expandToQueue(i,n)}return Xt.getItems(r)}}createNode(e){return new Jt(e)}size(){return 0===arguments.length?super.size.call(this):super.size.apply(this,arguments)}insert(){if(!(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof E))return super.insert.apply(this,arguments);{const e=arguments[0],t=arguments[1];if(e.isNull())return null;super.insert.call(this,e,t)}}getIntersectsOp(){return Xt.intersectsOp}verticalSlices(e,t){const n=Math.trunc(Math.ceil(e.size()/t)),i=new Array(t).fill(null),r=e.iterator();for(let e=0;e0;){const e=i.poll(),r=e.getDistance();if(r>=t)break;e.isLeaves()?(t=r,n=e):e.expandToQueue(i,t)}return null===n?null:[n.getBoundable(0).getItem(),n.getBoundable(1).getItem()]}}else{if(2===arguments.length){const e=arguments[0],t=arguments[1];if(this.isEmpty()||e.isEmpty())return null;const n=new Vt(this.getRoot(),e.getRoot(),t);return this.nearestNeighbour(n)}if(3===arguments.length){const e=arguments[2],t=new Gt(arguments[0],arguments[1]),n=new Vt(this.getRoot(),t,e);return this.nearestNeighbour(n)[0]}if(4===arguments.length){const e=arguments[2],t=arguments[3],n=new Gt(arguments[0],arguments[1]),i=new Vt(this.getRoot(),n,e);return this.nearestNeighbourK(i,t)}}}isWithinDistance(){if(2===arguments.length){const e=arguments[0],t=arguments[1];let n=_.POSITIVE_INFINITY;const i=new zt;for(i.add(e);!i.isEmpty();){const e=i.poll(),r=e.getDistance();if(r>t)return!1;if(e.maximumDistance()<=t)return!0;if(e.isLeaves()){if(n=r,n<=t)return!0}else e.expandToQueue(i,n)}return!1}if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=new Vt(this.getRoot(),e.getRoot(),t);return this.isWithinDistance(i,n)}}get interfaces_(){return[Wt,g]}}class Jt extends Ht{constructor(){super(),Jt.constructor_.apply(this,arguments)}static constructor_(){const e=arguments[0];Ht.constructor_.call(this,e)}computeBounds(){let e=null;for(let t=this.getChildBoundables().iterator();t.hasNext();){const n=t.next();null===e?e=new E(n.getBounds()):e.expandToInclude(n.getBounds())}return e}}Xt.STRtreeNode=Jt,Xt.xComparator=new class{get interfaces_(){return[y]}compare(e,t){return qt.compareDoubles(Xt.centreX(e.getBounds()),Xt.centreX(t.getBounds()))}},Xt.yComparator=new class{get interfaces_(){return[y]}compare(e,t){return qt.compareDoubles(Xt.centreY(e.getBounds()),Xt.centreY(t.getBounds()))}},Xt.intersectsOp=new class{get interfaces_(){return[IntersectsOp]}intersects(e,t){return e.intersects(t)}},Xt.DEFAULT_NODE_CAPACITY=10;class Zt{static relativeSign(e,t){return et?1:0}static compare(e,t,n){if(t.equals2D(n))return 0;const i=Zt.relativeSign(t.x,n.x),r=Zt.relativeSign(t.y,n.y);switch(e){case 0:return Zt.compareValue(i,r);case 1:return Zt.compareValue(r,i);case 2:return Zt.compareValue(r,-i);case 3:return Zt.compareValue(-i,r);case 4:return Zt.compareValue(-i,-r);case 5:return Zt.compareValue(-r,-i);case 6:return Zt.compareValue(-r,i);case 7:return Zt.compareValue(i,-r)}return x.shouldNeverReachHere("invalid octant value"),0}static compareValue(e,t){return e<0?-1:e>0?1:t<0?-1:t>0?1:0}}class Qt{constructor(){Qt.constructor_.apply(this,arguments)}static constructor_(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];this._segString=e,this.coord=new I(t),this.segmentIndex=n,this._segmentOctant=i,this._isInterior=!t.equals2D(e.getCoordinate(n))}getCoordinate(){return this.coord}print(e){e.print(this.coord),e.print(" seg # = "+this.segmentIndex)}compareTo(e){const t=e;return this.segmentIndext.segmentIndex?1:this.coord.equals2D(t.coord)?0:this._isInterior?t._isInterior?Zt.compare(this._segmentOctant,this.coord,t.coord):1:-1}isEndPoint(e){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===e}toString(){return this.segmentIndex+":"+this.coord.toString()}isInterior(){return this._isInterior}get interfaces_(){return[d]}}class $t{hasNext(){}next(){}remove(){}}class en{constructor(){en.constructor_.apply(this,arguments)}static constructor_(){this._nodeMap=new Nt,this._edge=null;const e=arguments[0];this._edge=e}getSplitCoordinates(){const e=new Y;this.addEndpoints();const t=this.iterator();let n=t.next();for(;t.hasNext();){const i=t.next();this.addEdgeCoordinates(n,i,e),n=i}return e.toCoordinateArray()}addCollapsedNodes(){const e=new j;this.findCollapsesFromInsertedNodes(e),this.findCollapsesFromExistingVertices(e);for(let t=e.iterator();t.hasNext();){const e=t.next().intValue();this.add(this._edge.getCoordinate(e),e)}}createSplitEdgePts(e,t){let n=t.segmentIndex-e.segmentIndex+2;if(2===n)return[new I(e.coord),new I(t.coord)];const i=this._edge.getCoordinate(t.segmentIndex),r=t.isInterior()||!t.coord.equals2D(i);r||n--;const o=new Array(n).fill(null);let s=0;o[s++]=new I(e.coord);for(let n=e.segmentIndex+1;n<=t.segmentIndex;n++)o[s++]=this._edge.getCoordinate(n);return r&&(o[s]=new I(t.coord)),o}print(e){e.println("Intersections:");for(let t=this.iterator();t.hasNext();){t.next().print(e)}}findCollapsesFromExistingVertices(e){for(let t=0;t=0?t>=0?n>=i?0:1:n>=i?7:6:t>=0?n>=i?3:2:n>=i?4:5}if(arguments[0]instanceof I&&arguments[1]instanceof I){const e=arguments[0],t=arguments[1],n=t.x-e.x,i=t.y-e.y;if(0===n&&0===i)throw new h("Cannot compute the octant for two identical points "+e);return tn.octant(n,i)}}}class nn{getCoordinates(){}size(){}getCoordinate(e){}isClosed(){}setData(e){}getData(){}}class rn{addIntersection(e,t){}get interfaces_(){return[nn]}}class on{constructor(){on.constructor_.apply(this,arguments)}static constructor_(){this._nodeList=new en(this),this._pts=null,this._data=null;const e=arguments[0],t=arguments[1];this._pts=e,this._data=t}static getNodedSubstrings(){if(1===arguments.length){const e=arguments[0],t=new j;return on.getNodedSubstrings(e,t),t}if(2===arguments.length){const e=arguments[1];for(let t=arguments[0].iterator();t.hasNext();){t.next().getNodeList().addSplitEdges(e)}}}getCoordinates(){return this._pts}size(){return this._pts.length}getCoordinate(e){return this._pts[e]}isClosed(){return this._pts[0].equals(this._pts[this._pts.length-1])}getSegmentOctant(e){return e===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(e),this.getCoordinate(e+1))}setData(e){this._data=e}safeOctant(e,t){return e.equals2D(t)?0:tn.octant(e,t)}getData(){return this._data}addIntersection(){if(2===arguments.length){const e=arguments[0],t=arguments[1];this.addIntersectionNode(e,t)}else if(4===arguments.length){const e=arguments[1],t=arguments[3],n=new I(arguments[0].getIntersection(t));this.addIntersection(n,e)}}toString(){return tt.toLineString(new xe(this._pts))}getNodeList(){return this._nodeList}addIntersectionNode(e,t){let n=t;const i=n+1;if(i=e.length-1)return e.length-1;const i=Rt.quadrant(e[n],e[n+1]);let r=t+1;for(;rn.getId()&&(n.computeOverlaps(i,e),this._nOverlaps++),this._segInt.isDone())return null}}}}class dn extends sn{constructor(){super(),dn.constructor_.apply(this,arguments)}static constructor_(){this._si=null;const e=arguments[0];this._si=e}overlap(){if(4!==arguments.length)return super.overlap.apply(this,arguments);{const e=arguments[1],t=arguments[2],n=arguments[3],i=arguments[0].getContext(),r=t.getContext();this._si.processIntersections(i,e,r,n)}}}un.SegmentOverlapAction=dn;class mn{constructor(){mn.constructor_.apply(this,arguments)}static constructor_(){this._inputLine=null,this._distanceTol=null,this._isDeleted=null,this._angleOrientation=ie.COUNTERCLOCKWISE;const e=arguments[0];this._inputLine=e}static simplify(e,t){return new mn(e).simplify(t)}isDeletable(e,t,n,i){const r=this._inputLine[e],o=this._inputLine[t],s=this._inputLine[n];return!!this.isConcave(r,o,s)&&(!!this.isShallow(r,o,s,i)&&this.isShallowSampled(r,o,e,n,i))}deleteShallowConcavities(){let e=1,t=this.findNextNonDeletedIndex(e),n=this.findNextNonDeletedIndex(t),i=!1;for(;n=0;t--)this.addPt(e[t])}isRedundant(e){if(this._ptList.size()<1)return!1;const t=this._ptList.get(this._ptList.size()-1);return e.distance(t)Math.PI;)e-=fn.PI_TIMES_2;for(;e<=-Math.PI;)e+=fn.PI_TIMES_2;return e}static angle(){if(1===arguments.length){const e=arguments[0];return Math.atan2(e.y,e.x)}if(2===arguments.length){const e=arguments[0],t=arguments[1],n=t.x-e.x,i=t.y-e.y;return Math.atan2(i,n)}}static isAcute(e,t,n){const i=e.x-t.x,r=e.y-t.y;return i*(n.x-t.x)+r*(n.y-t.y)>0}static isObtuse(e,t,n){const i=e.x-t.x,r=e.y-t.y;return i*(n.x-t.x)+r*(n.y-t.y)<0}static interiorAngle(e,t,n){const i=fn.angle(t,e),r=fn.angle(t,n);return Math.abs(r-i)}static normalizePositive(e){if(e<0){for(;e<0;)e+=fn.PI_TIMES_2;e>=fn.PI_TIMES_2&&(e=0)}else{for(;e>=fn.PI_TIMES_2;)e-=fn.PI_TIMES_2;e<0&&(e=0)}return e}static angleBetween(e,t,n){const i=fn.angle(t,e),r=fn.angle(t,n);return fn.diff(i,r)}static diff(e,t){let n=null;return n=eMath.PI&&(n=2*Math.PI-n),n}static toRadians(e){return e*Math.PI/180}static getTurn(e,t){const n=Math.sin(t-e);return n>0?fn.COUNTERCLOCKWISE:n<0?fn.CLOCKWISE:fn.NONE}static angleBetweenOriented(e,t,n){const i=fn.angle(t,e),r=fn.angle(t,n)-i;return r<=-Math.PI?r+fn.PI_TIMES_2:r>Math.PI?r-fn.PI_TIMES_2:r}}fn.PI_TIMES_2=2*Math.PI,fn.PI_OVER_2=Math.PI/2,fn.PI_OVER_4=Math.PI/4,fn.COUNTERCLOCKWISE=ie.COUNTERCLOCKWISE,fn.CLOCKWISE=ie.CLOCKWISE,fn.NONE=ie.COLLINEAR;class pn{constructor(){pn.constructor_.apply(this,arguments)}static constructor_(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new rt,this._seg1=new rt,this._offset0=new rt,this._offset1=new rt,this._side=0,this._hasNarrowConcaveAngle=!1;const e=arguments[0],t=arguments[1],n=arguments[2];this._precisionModel=e,this._bufParams=t,this._li=new it,this._filletAngleQuantum=Math.PI/2/t.getQuadrantSegments(),t.getQuadrantSegments()>=8&&t.getJoinStyle()===st.JOIN_ROUND&&(this._closingSegLengthFactor=pn.MAX_CLOSING_SEG_LEN_FACTOR),this.init(n)}addNextSegment(e,t){if(this._s0=this._s1,this._s1=this._s2,this._s2=e,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;const n=ie.index(this._s0,this._s1,this._s2),i=n===ie.CLOCKWISE&&this._side===lt.LEFT||n===ie.COUNTERCLOCKWISE&&this._side===lt.RIGHT;0===n?this.addCollinear(t):i?this.addOutsideTurn(n,t):this.addInsideTurn(n,t)}addLineEndCap(e,t){const n=new rt(e,t),i=new rt;this.computeOffsetSegment(n,lt.LEFT,this._distance,i);const r=new rt;this.computeOffsetSegment(n,lt.RIGHT,this._distance,r);const o=t.x-e.x,s=t.y-e.y,a=Math.atan2(s,o);switch(this._bufParams.getEndCapStyle()){case st.CAP_ROUND:this._segList.addPt(i.p1),this.addDirectedFillet(t,a+Math.PI/2,a-Math.PI/2,ie.CLOCKWISE,this._distance),this._segList.addPt(r.p1);break;case st.CAP_FLAT:this._segList.addPt(i.p1),this._segList.addPt(r.p1);break;case st.CAP_SQUARE:const e=new I;e.x=Math.abs(this._distance)*Math.cos(a),e.y=Math.abs(this._distance)*Math.sin(a);const n=new I(i.p1.x+e.x,i.p1.y+e.y),o=new I(r.p1.x+e.x,r.p1.y+e.y);this._segList.addPt(n),this._segList.addPt(o)}}getCoordinates(){return this._segList.getCoordinates()}addMitreJoin(e,t,n,i){const r=Pe.intersection(t.p0,t.p1,n.p0,n.p1);if(null!==r){if((i<=0?1:r.distance(e)/Math.abs(i))<=this._bufParams.getMitreLimit())return this._segList.addPt(r),null}this.addLimitedMitreJoin(t,n,i,this._bufParams.getMitreLimit())}addOutsideTurn(e,t){if(this._offset0.p1.distance(this._offset1.p0)=h&&(a-=2*Math.PI),this._segList.addPt(t),this.addDirectedFillet(e,a,h,i,r),this._segList.addPt(n)}addLastSegment(){this._segList.addPt(this._offset1.p1)}initSideSegments(e,t,n){this._s1=e,this._s2=t,this._side=n,this._seg1.setCoordinates(e,t),this.computeOffsetSegment(this._seg1,n,this._distance,this._offset1)}addLimitedMitreJoin(e,t,n,i){const r=this._seg0.p1,o=fn.angle(r,this._seg0.p0),s=fn.angleBetweenOriented(this._seg0.p0,r,this._seg1.p1)/2,a=fn.normalize(o+s),l=fn.normalize(a+Math.PI),c=i*n,h=n-c*Math.abs(Math.sin(s)),u=r.x+c*Math.cos(l),d=r.y+c*Math.sin(l),m=new I(u,d),g=new rt(r,m),f=g.pointAlongOffset(1,h),p=g.pointAlongOffset(1,-h);this._side===lt.LEFT?(this._segList.addPt(f),this._segList.addPt(p)):(this._segList.addPt(p),this._segList.addPt(f))}addDirectedFillet(e,t,n,i,r){const o=i===ie.CLOCKWISE?-1:1,s=Math.abs(t-n),a=Math.trunc(s/this._filletAngleQuantum+.5);if(a<1)return null;const l=s/a,c=new I;for(let n=0;n0){const e=new I((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(e);const t=new I((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(t)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}createCircle(e){const t=new I(e.x+this._distance,e.y);this._segList.addPt(t),this.addDirectedFillet(e,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}addBevelJoin(e,t){this._segList.addPt(e.p1),this._segList.addPt(t.p0)}init(e){this._distance=e,this._maxCurveSegmentError=e*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new gn,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(e*pn.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}addCollinear(e){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2);this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===st.JOIN_BEVEL||this._bufParams.getJoinStyle()===st.JOIN_MITRE?(e&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,ie.CLOCKWISE,this._distance))}closeRing(){this._segList.closeRing()}hasNarrowConcaveAngle(){return this._hasNarrowConcaveAngle}}pn.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,pn.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,pn.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,pn.MAX_CLOSING_SEG_LEN_FACTOR=80;class _n{constructor(){_n.constructor_.apply(this,arguments)}static constructor_(){this._distance=0,this._precisionModel=null,this._bufParams=null;const e=arguments[0],t=arguments[1];this._precisionModel=e,this._bufParams=t}static copyCoordinates(e){const t=new Array(e.length).fill(null);for(let n=0;n=0;e--)n.addNextSegment(t[e],!0)}else{n.addSegments(e,!1);const t=mn.simplify(e,i),r=t.length-1;n.initSideSegments(t[0],t[1],lt.LEFT),n.addFirstSegment();for(let e=2;e<=r;e++)n.addNextSegment(t[e],!0)}n.addLastSegment(),n.closeRing()}computeRingBufferCurve(e,t,n){let i=this.simplifyTolerance(this._distance);t===lt.RIGHT&&(i=-i);const r=mn.simplify(e,i),o=r.length-1;n.initSideSegments(r[o-1],r[0],t);for(let e=1;e<=o;e++){const t=1!==e;n.addNextSegment(r[e],t)}n.closeRing()}computeLineBufferCurve(e,t){const n=this.simplifyTolerance(this._distance),i=mn.simplify(e,n),r=i.length-1;t.initSideSegments(i[0],i[1],lt.LEFT);for(let e=2;e<=r;e++)t.addNextSegment(i[e],!0);t.addLastSegment(),t.addLineEndCap(i[r-1],i[r]);const o=mn.simplify(e,-n),s=o.length-1;t.initSideSegments(o[s],o[s-1],lt.LEFT);for(let e=s-2;e>=0;e--)t.addNextSegment(o[e],!0);t.addLastSegment(),t.addLineEndCap(o[1],o[0]),t.closeRing()}computePointCurve(e,t){switch(this._bufParams.getEndCapStyle()){case st.CAP_ROUND:t.createCircle(e);break;case st.CAP_SQUARE:t.createSquare(e)}}getLineCurve(e,t){if(this._distance=t,this.isLineOffsetEmpty(t))return null;const n=Math.abs(t),i=this.getSegGen(n);if(e.length<=1)this.computePointCurve(e[0],i);else if(this._bufParams.isSingleSided()){const n=t<0;this.computeSingleSidedBufferCurve(e,n,i)}else this.computeLineBufferCurve(e,i);return i.getCoordinates()}getBufferParameters(){return this._bufParams}simplifyTolerance(e){return e*this._bufParams.getSimplifyFactor()}getRingCurve(e,t,n){if(this._distance=n,e.length<=2)return this.getLineCurve(e,n);if(0===n)return _n.copyCoordinates(e);const i=this.getSegGen(n);return this.computeRingBufferCurve(e,t,i),i.getCoordinates()}computeOffsetCurve(e,t,n){const i=this.simplifyTolerance(this._distance);if(t){const t=mn.simplify(e,-i),r=t.length-1;n.initSideSegments(t[r],t[r-1],lt.LEFT),n.addFirstSegment();for(let e=r-2;e>=0;e--)n.addNextSegment(t[e],!0)}else{const t=mn.simplify(e,i),r=t.length-1;n.initSideSegments(t[0],t[1],lt.LEFT),n.addFirstSegment();for(let e=2;e<=r;e++)n.addNextSegment(t[e],!0)}n.addLastSegment()}isLineOffsetEmpty(e){return 0===e||e<0&&!this._bufParams.isSingleSided()}getSegGen(e){return new pn(this._precisionModel,this._bufParams,e)}}class yn{constructor(){yn.constructor_.apply(this,arguments)}static constructor_(){this._subgraphs=null,this._seg=new rt;const e=arguments[0];this._subgraphs=e}findStabbedSegments(){if(1===arguments.length){const e=arguments[0],t=new j;for(let n=this._subgraphs.iterator();n.hasNext();){const i=n.next(),r=i.getEnvelope();e.yr.getMaxY()||this.findStabbedSegments(e,i.getDirectedEdges(),t)}return t}if(3===arguments.length)if(N(arguments[2],H)&&arguments[0]instanceof I&&arguments[1]instanceof Lt){const e=arguments[0],t=arguments[1],n=arguments[2],i=t.getEdge().getCoordinates();for(let r=0;rthis._seg.p1.y&&this._seg.reverse();if(Math.max(this._seg.p0.x,this._seg.p1.x)this._seg.p1.y)continue;if(ie.index(this._seg.p0,this._seg.p1,e)===ie.RIGHT)continue;let o=t.getDepth(lt.LEFT);this._seg.p0.equals(i[r])||(o=t.getDepth(lt.RIGHT));const s=new bn(this._seg,o);n.add(s)}}else if(N(arguments[2],H)&&arguments[0]instanceof I&&N(arguments[1],H)){const e=arguments[0],t=arguments[2];for(let n=arguments[1].iterator();n.hasNext();){const i=n.next();i.isForward()&&this.findStabbedSegments(e,i,t)}}}getDepth(e){const t=this.findStabbedSegments(e);if(0===t.size())return 0;return Ut.min(t)._leftDepth}}class bn{constructor(){bn.constructor_.apply(this,arguments)}static constructor_(){this._upwardSeg=null,this._leftDepth=null;const e=arguments[0],t=arguments[1];this._upwardSeg=new rt(e),this._leftDepth=t}compareTo(e){const t=e;if(this._upwardSeg.minX()>=t._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=t._upwardSeg.minX())return-1;let n=this._upwardSeg.orientationIndex(t._upwardSeg);return 0!==n?n:(n=-1*t._upwardSeg.orientationIndex(this._upwardSeg),0!==n?n:this._upwardSeg.compareTo(t._upwardSeg))}compareX(e,t){const n=e.p0.compareTo(t.p0);return 0!==n?n:e.p1.compareTo(t.p1)}toString(){return this._upwardSeg.toString()}get interfaces_(){return[d]}}yn.DepthSegment=bn;class Cn extends c{constructor(){super(),Cn.constructor_.apply(this,arguments)}static constructor_(){c.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}class xn{constructor(){xn.constructor_.apply(this,arguments)}static constructor_(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){const e=arguments[0];this.x=e.x,this.y=e.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){const e=arguments[0],t=arguments[1];this.x=e,this.y=t,this.w=1}else if(arguments[0]instanceof xn&&arguments[1]instanceof xn){const e=arguments[0],t=arguments[1];this.x=e.y*t.w-t.y*e.w,this.y=t.x*e.w-e.x*t.w,this.w=e.x*t.y-t.x*e.y}else if(arguments[0]instanceof I&&arguments[1]instanceof I){const e=arguments[0],t=arguments[1];this.x=e.y-t.y,this.y=t.x-e.x,this.w=e.x*t.y-t.x*e.y}}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];this.x=e,this.y=t,this.w=n}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3],r=e.y-t.y,o=t.x-e.x,s=e.x*t.y-t.x*e.y,a=n.y-i.y,l=i.x-n.x,c=n.x*i.y-i.x*n.y;this.x=o*c-l*s,this.y=a*s-r*c,this.w=r*l-a*o}}getY(){const e=this.y/this.w;if(_.isNaN(e)||_.isInfinite(e))throw new Cn;return e}getX(){const e=this.x/this.w;if(_.isNaN(e)||_.isInfinite(e))throw new Cn;return e}getCoordinate(){const e=new I;return e.x=this.getX(),e.y=this.getY(),e}}class vn{constructor(){vn.constructor_.apply(this,arguments)}static constructor_(){this.p0=null,this.p1=null,this.p2=null;const e=arguments[0],t=arguments[1],n=arguments[2];this.p0=e,this.p1=t,this.p2=n}static area(e,t,n){return Math.abs(((n.x-e.x)*(t.y-e.y)-(t.x-e.x)*(n.y-e.y))/2)}static signedArea(e,t,n){return((n.x-e.x)*(t.y-e.y)-(t.x-e.x)*(n.y-e.y))/2}static det(e,t,n,i){return e*i-t*n}static interpolateZ(e,t,n,i){const r=t.x,o=t.y,s=n.x-r,a=i.x-r,l=n.y-o,c=i.y-o,h=s*c-a*l,u=e.x-r,d=e.y-o,m=(c*u-a*d)/h,g=(-l*u+s*d)/h;return t.getZ()+m*(n.getZ()-t.getZ())+g*(i.getZ()-t.getZ())}static longestSideLength(e,t,n){const i=e.distance(t),r=t.distance(n),o=n.distance(e);let s=i;return r>s&&(s=r),o>s&&(s=o),s}static circumcentreDD(e,t,n){const i=te.valueOf(e.x).subtract(n.x),r=te.valueOf(e.y).subtract(n.y),o=te.valueOf(t.x).subtract(n.x),s=te.valueOf(t.y).subtract(n.y),a=te.determinant(i,r,o,s).multiply(2),l=i.sqr().add(r.sqr()),c=o.sqr().add(s.sqr()),h=te.determinant(r,l,s,c),u=te.determinant(i,l,o,c),d=te.valueOf(n.x).subtract(h.divide(a)).doubleValue(),m=te.valueOf(n.y).add(u.divide(a)).doubleValue();return new I(d,m)}static isAcute(e,t,n){return!!fn.isAcute(e,t,n)&&(!!fn.isAcute(t,n,e)&&!!fn.isAcute(n,e,t))}static circumcentre(e,t,n){const i=n.x,r=n.y,o=e.x-i,s=e.y-r,a=t.x-i,l=t.y-r,c=2*vn.det(o,s,a,l),h=vn.det(s,o*o+s*s,l,a*a+l*l),u=vn.det(o,o*o+s*s,a,a*a+l*l);return new I(i-h/c,r+u/c)}static perpendicularBisector(e,t){const n=t.x-e.x,i=t.y-e.y,r=new xn(e.x+n/2,e.y+i/2,1),o=new xn(e.x-i+n/2,e.y+n+i/2,1);return new xn(r,o)}static angleBisector(e,t,n){const i=t.distance(e),r=i/(i+t.distance(n)),o=n.x-e.x,s=n.y-e.y;return new I(e.x+r*o,e.y+r*s)}static area3D(e,t,n){const i=t.x-e.x,r=t.y-e.y,o=t.getZ()-e.getZ(),s=n.x-e.x,a=n.y-e.y,l=n.getZ()-e.getZ(),c=r*l-o*a,h=o*s-i*l,u=i*a-r*s,d=c*c+h*h+u*u;return Math.sqrt(d)/2}static centroid(e,t,n){const i=(e.x+t.x+n.x)/3,r=(e.y+t.y+n.y)/3;return new I(i,r)}static inCentre(e,t,n){const i=t.distance(n),r=e.distance(n),o=e.distance(t),s=i+r+o,a=(i*e.x+r*t.x+o*n.x)/s,l=(i*e.y+r*t.y+o*n.y)/s;return new I(a,l)}area(){return vn.area(this.p0,this.p1,this.p2)}signedArea(){return vn.signedArea(this.p0,this.p1,this.p2)}interpolateZ(e){if(null===e)throw new h("Supplied point is null.");return vn.interpolateZ(e,this.p0,this.p1,this.p2)}longestSideLength(){return vn.longestSideLength(this.p0,this.p1,this.p2)}isAcute(){return vn.isAcute(this.p0,this.p1,this.p2)}circumcentre(){return vn.circumcentre(this.p0,this.p1,this.p2)}area3D(){return vn.area3D(this.p0,this.p1,this.p2)}centroid(){return vn.centroid(this.p0,this.p1,this.p2)}inCentre(){return vn.inCentre(this.p0,this.p1,this.p2)}}class Sn{constructor(){Sn.constructor_.apply(this,arguments)}static constructor_(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new j;const e=arguments[0],t=arguments[1],n=arguments[2];this._inputGeom=e,this._distance=t,this._curveBuilder=n}addRingSide(e,t,n,i,r){if(0===t&&e.length=de.MINIMUM_VALID_SIZE&&ie.isCCW(e)&&(o=r,s=i,n=lt.opposite(n));const a=this._curveBuilder.getRingCurve(e,n,t);this.addCurve(a,o,s)}addRingBothSides(e,t){this.addRingSide(e,t,lt.LEFT,at.EXTERIOR,at.INTERIOR),this.addRingSide(e,t,lt.RIGHT,at.INTERIOR,at.EXTERIOR)}addPoint(e){if(this._distance<=0)return null;const t=e.getCoordinates(),n=this._curveBuilder.getLineCurve(t,this._distance);this.addCurve(n,at.EXTERIOR,at.INTERIOR)}addPolygon(e){let t=this._distance,n=lt.LEFT;this._distance<0&&(t=-this._distance,n=lt.RIGHT);const i=e.getExteriorRing(),r=be.removeRepeatedPoints(i.getCoordinates());if(this._distance<0&&this.isErodedCompletely(i,this._distance))return null;if(this._distance<=0&&r.length<3)return null;this.addRingSide(r,t,n,at.EXTERIOR,at.INTERIOR);for(let i=0;i0&&this.isErodedCompletely(r,-this._distance)||this.addRingSide(o,t,lt.opposite(n),at.INTERIOR,at.EXTERIOR)}}isTriangleErodedCompletely(e,t){const n=new vn(e[0],e[1],e[2]),i=n.inCentre();return Le.pointToSegment(i,n.p0,n.p1)r}addCollection(e){for(let t=0;t=this._max)throw new U;const e=this._parent.getGeometryN(this._index++);return e instanceof he?(this._subcollectionIterator=new In(e),this._subcollectionIterator.next()):e}remove(){throw new L(this.getClass().getName())}hasNext(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}get interfaces_(){return[$t]}}class wn{constructor(){wn.constructor_.apply(this,arguments)}static constructor_(){this._geom=null;const e=arguments[0];this._geom=e}static locatePointInPolygon(e,t){if(t.isEmpty())return at.EXTERIOR;const n=t.getExteriorRing(),i=wn.locatePointInRing(e,n);if(i!==at.INTERIOR)return i;for(let n=0;n=0;n--){const i=this._edgeList.get(n),r=i.getSym();null===t&&(t=r),null!==e&&r.setNext(e),e=i}t.setNext(e)}computeDepths(){if(1===arguments.length){const e=arguments[0],t=this.findIndex(e),n=e.getDepth(lt.LEFT),i=e.getDepth(lt.RIGHT),r=this.computeDepths(t+1,this._edgeList.size(),n);if(this.computeDepths(0,t,r)!==i)throw new dt("depth mismatch at "+e.getCoordinate())}else if(3===arguments.length){const e=arguments[1];let t=arguments[2];for(let n=arguments[0];n=0;r--){const o=this._resultAreaEdgeList.get(r),s=o.getSym();switch(null===t&&o.getEdgeRing()===e&&(t=o),i){case this._SCANNING_FOR_INCOMING:if(s.getEdgeRing()!==e)continue;n=s,i=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(o.getEdgeRing()!==e)continue;n.setNextMin(o),i=this._SCANNING_FOR_INCOMING}}i===this._LINKING_TO_OUTGOING&&(x.isTrue(null!==t,"found null for first outgoing dirEdge"),x.isTrue(t.getEdgeRing()===e,"unable to link last incoming dirEdge"),n.setNextMin(t))}getOutgoingDegree(){if(0===arguments.length){let e=0;for(let t=this.iterator();t.hasNext();){t.next().isInResult()&&e++}return e}if(1===arguments.length){const e=arguments[0];let t=0;for(let n=this.iterator();n.hasNext();){n.next().getEdgeRing()===e&&t++}return t}}getLabel(){return this._label}findCoveredLineEdges(){let e=at.NONE;for(let t=this.iterator();t.hasNext();){const n=t.next(),i=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){e=at.INTERIOR;break}if(i.isInResult()){e=at.EXTERIOR;break}}}if(e===at.NONE)return null;let t=e;for(let e=this.iterator();e.hasNext();){const n=e.next(),i=n.getSym();n.isLineEdge()?n.getEdge().setCovered(t===at.INTERIOR):(n.isInResult()&&(t=at.EXTERIOR),i.isInResult()&&(t=at.INTERIOR))}}computeLabelling(e){super.computeLabelling.call(this,e),this._label=new yt(at.NONE);for(let e=this.iterator();e.hasNext();){const t=e.next().getEdge().getLabel();for(let e=0;e<2;e++){const n=t.getLocation(e);n!==at.INTERIOR&&n!==at.BOUNDARY||this._label.setLocation(e,at.INTERIOR)}}}}class Mn extends Ot{constructor(){super()}createNode(e){return new St(e,new An)}}class Nn{constructor(){Nn.constructor_.apply(this,arguments)}static constructor_(){this._pts=null,this._orientation=null;const e=arguments[0];this._pts=e,this._orientation=Nn.orientation(e)}static orientation(e){return 1===be.increasingDirection(e)}static compareOriented(e,t,n,i){const r=t?1:-1,o=i?1:-1,s=t?e.length:-1,a=i?n.length:-1;let l=t?0:e.length-1,c=i?0:n.length-1;for(;;){const t=e[l].compareTo(n[c]);if(0!==t)return t;l+=r,c+=o;const i=l===s,h=c===a;if(i&&!h)return-1;if(!i&&h)return 1;if(i&&h)return 0}}compareTo(e){const t=e;return Nn.compareOriented(this._pts,this._orientation,t._pts,t._orientation)}get interfaces_(){return[d]}}class Dn{constructor(){Dn.constructor_.apply(this,arguments)}static constructor_(){this._edges=new j,this._ocaMap=new Nt}print(e){e.print("MULTILINESTRING ( ");for(let t=0;t0&&e.print(","),e.print("(");const i=n.getCoordinates();for(let t=0;t0&&e.print(","),e.print(i[t].x+" "+i[t].y);e.println(")")}e.print(") ")}addAll(e){for(let t=e.iterator();t.hasNext();)this.add(t.next())}findEdgeIndex(e){for(let t=0;t0||!t.coord.equals2D(i);r||n--;const o=new Array(n).fill(null);let s=0;o[s++]=new I(e.coord);for(let n=e.segmentIndex+1;n<=t.segmentIndex;n++)o[s++]=this.edge.pts[n];return r&&(o[s]=t.coord),new Wn(o,new yt(this.edge._label))}add(e,t,n){const i=new Ln(e,t,n),r=this._nodeMap.get(i);return null!==r?r:(this._nodeMap.put(i,i),i)}isIntersection(e){for(let t=this.iterator();t.hasNext();){if(t.next().coord.equals(e))return!0}return!1}}class Fn{constructor(){Fn.constructor_.apply(this,arguments)}static constructor_(){if(this._matrix=null,0===arguments.length)this._matrix=Array(3).fill().map((()=>Array(3))),this.setAll(F.FALSE);else if(1===arguments.length)if("string"==typeof arguments[0]){const e=arguments[0];Fn.constructor_.call(this),this.set(e)}else if(arguments[0]instanceof Fn){const e=arguments[0];Fn.constructor_.call(this),this._matrix[at.INTERIOR][at.INTERIOR]=e._matrix[at.INTERIOR][at.INTERIOR],this._matrix[at.INTERIOR][at.BOUNDARY]=e._matrix[at.INTERIOR][at.BOUNDARY],this._matrix[at.INTERIOR][at.EXTERIOR]=e._matrix[at.INTERIOR][at.EXTERIOR],this._matrix[at.BOUNDARY][at.INTERIOR]=e._matrix[at.BOUNDARY][at.INTERIOR],this._matrix[at.BOUNDARY][at.BOUNDARY]=e._matrix[at.BOUNDARY][at.BOUNDARY],this._matrix[at.BOUNDARY][at.EXTERIOR]=e._matrix[at.BOUNDARY][at.EXTERIOR],this._matrix[at.EXTERIOR][at.INTERIOR]=e._matrix[at.EXTERIOR][at.INTERIOR],this._matrix[at.EXTERIOR][at.BOUNDARY]=e._matrix[at.EXTERIOR][at.BOUNDARY],this._matrix[at.EXTERIOR][at.EXTERIOR]=e._matrix[at.EXTERIOR][at.EXTERIOR]}}static matches(){if(Number.isInteger(arguments[0])&&"string"==typeof arguments[1]){const e=arguments[0],t=arguments[1];return t===F.SYM_DONTCARE||(t===F.SYM_TRUE&&(e>=0||e===F.TRUE)||(t===F.SYM_FALSE&&e===F.FALSE||(t===F.SYM_P&&e===F.P||(t===F.SYM_L&&e===F.L||t===F.SYM_A&&e===F.A))))}if("string"==typeof arguments[0]&&"string"==typeof arguments[1]){const e=arguments[1];return new Fn(arguments[0]).matches(e)}}static isTrue(e){return e>=0||e===F.TRUE}isIntersects(){return!this.isDisjoint()}isCovers(){return(Fn.isTrue(this._matrix[at.INTERIOR][at.INTERIOR])||Fn.isTrue(this._matrix[at.INTERIOR][at.BOUNDARY])||Fn.isTrue(this._matrix[at.BOUNDARY][at.INTERIOR])||Fn.isTrue(this._matrix[at.BOUNDARY][at.BOUNDARY]))&&this._matrix[at.EXTERIOR][at.INTERIOR]===F.FALSE&&this._matrix[at.EXTERIOR][at.BOUNDARY]===F.FALSE}isCoveredBy(){return(Fn.isTrue(this._matrix[at.INTERIOR][at.INTERIOR])||Fn.isTrue(this._matrix[at.INTERIOR][at.BOUNDARY])||Fn.isTrue(this._matrix[at.BOUNDARY][at.INTERIOR])||Fn.isTrue(this._matrix[at.BOUNDARY][at.BOUNDARY]))&&this._matrix[at.INTERIOR][at.EXTERIOR]===F.FALSE&&this._matrix[at.BOUNDARY][at.EXTERIOR]===F.FALSE}set(){if(1===arguments.length){const e=arguments[0];for(let t=0;t=0&&t>=0&&this.setAtLeast(e,t,n)}isWithin(){return Fn.isTrue(this._matrix[at.INTERIOR][at.INTERIOR])&&this._matrix[at.INTERIOR][at.EXTERIOR]===F.FALSE&&this._matrix[at.BOUNDARY][at.EXTERIOR]===F.FALSE}isTouches(e,t){return e>t?this.isTouches(t,e):(e===F.A&&t===F.A||e===F.L&&t===F.L||e===F.L&&t===F.A||e===F.P&&t===F.A||e===F.P&&t===F.L)&&(this._matrix[at.INTERIOR][at.INTERIOR]===F.FALSE&&(Fn.isTrue(this._matrix[at.INTERIOR][at.BOUNDARY])||Fn.isTrue(this._matrix[at.BOUNDARY][at.INTERIOR])||Fn.isTrue(this._matrix[at.BOUNDARY][at.BOUNDARY])))}isOverlaps(e,t){return e===F.P&&t===F.P||e===F.A&&t===F.A?Fn.isTrue(this._matrix[at.INTERIOR][at.INTERIOR])&&Fn.isTrue(this._matrix[at.INTERIOR][at.EXTERIOR])&&Fn.isTrue(this._matrix[at.EXTERIOR][at.INTERIOR]):e===F.L&&t===F.L&&(1===this._matrix[at.INTERIOR][at.INTERIOR]&&Fn.isTrue(this._matrix[at.INTERIOR][at.EXTERIOR])&&Fn.isTrue(this._matrix[at.EXTERIOR][at.INTERIOR]))}isEquals(e,t){return e===t&&(Fn.isTrue(this._matrix[at.INTERIOR][at.INTERIOR])&&this._matrix[at.INTERIOR][at.EXTERIOR]===F.FALSE&&this._matrix[at.BOUNDARY][at.EXTERIOR]===F.FALSE&&this._matrix[at.EXTERIOR][at.INTERIOR]===F.FALSE&&this._matrix[at.EXTERIOR][at.BOUNDARY]===F.FALSE)}toString(){const e=new Ce("123456789");for(let t=0;t<3;t++)for(let n=0;n<3;n++)e.setCharAt(3*t+n,F.toDimensionSymbol(this._matrix[t][n]));return e.toString()}setAll(e){for(let t=0;t<3;t++)for(let n=0;n<3;n++)this._matrix[t][n]=e}get(e,t){return this._matrix[e][t]}transpose(){let e=this._matrix[1][0];return this._matrix[1][0]=this._matrix[0][1],this._matrix[0][1]=e,e=this._matrix[2][0],this._matrix[2][0]=this._matrix[0][2],this._matrix[0][2]=e,e=this._matrix[2][1],this._matrix[2][1]=this._matrix[1][2],this._matrix[1][2]=e,this}matches(e){if(9!==e.length)throw new h("Should be length 9: "+e);for(let t=0;t<3;t++)for(let n=0;n<3;n++)if(!Fn.matches(this._matrix[t][n],e.charAt(3*t+n)))return!1;return!0}add(e){for(let t=0;t<3;t++)for(let n=0;n<3;n++)this.setAtLeast(t,n,e.get(t,n))}isDisjoint(){return this._matrix[at.INTERIOR][at.INTERIOR]===F.FALSE&&this._matrix[at.INTERIOR][at.BOUNDARY]===F.FALSE&&this._matrix[at.BOUNDARY][at.INTERIOR]===F.FALSE&&this._matrix[at.BOUNDARY][at.BOUNDARY]===F.FALSE}isCrosses(e,t){return e===F.P&&t===F.L||e===F.P&&t===F.A||e===F.L&&t===F.A?Fn.isTrue(this._matrix[at.INTERIOR][at.INTERIOR])&&Fn.isTrue(this._matrix[at.INTERIOR][at.EXTERIOR]):e===F.L&&t===F.P||e===F.A&&t===F.P||e===F.A&&t===F.L?Fn.isTrue(this._matrix[at.INTERIOR][at.INTERIOR])&&Fn.isTrue(this._matrix[at.EXTERIOR][at.INTERIOR]):e===F.L&&t===F.L&&0===this._matrix[at.INTERIOR][at.INTERIOR]}get interfaces_(){return[m]}}class kn{constructor(){kn.constructor_.apply(this,arguments)}static constructor_(){if(this._data=null,this._size=0,0===arguments.length)kn.constructor_.call(this,10);else if(1===arguments.length){const e=arguments[0];this._data=new Array(e).fill(null)}}size(){return this._size}addAll(e){return null===e||0===e.length?null:(this.ensureCapacity(this._size+e.length),ye.arraycopy(e,0,this._data,this._size,e.length),void(this._size+=e.length))}ensureCapacity(e){if(e<=this._data.length)return null;const t=Math.max(e,2*this._data.length);this._data=Z.copyOf(this._data,t)}toArray(){const e=new Array(this._size).fill(null);return ye.arraycopy(this._data,0,e,0,this._size),e}add(e){this.ensureCapacity(this._size+1),this._data[this._size]=e,++this._size}}class Bn{static toIntArray(e){const t=new Array(e.size()).fill(null);for(let n=0;nn?t:n}getMinX(e){const t=this.pts[this.startIndex[e]].x,n=this.pts[this.startIndex[e+1]].x;return tArray(3)));for(let e=0;e<2;e++)for(let t=0;t<3;t++)this._depth[e][t]=zn.NULL_VALUE}static depthAtLocation(e){return e===at.EXTERIOR?0:e===at.INTERIOR?1:zn.NULL_VALUE}getDepth(e,t){return this._depth[e][t]}setDepth(e,t,n){this._depth[e][t]=n}isNull(){if(0===arguments.length){for(let e=0;e<2;e++)for(let t=0;t<3;t++)if(this._depth[e][t]!==zn.NULL_VALUE)return!1;return!0}if(1===arguments.length){const e=arguments[0];return this._depth[e][1]===zn.NULL_VALUE}if(2===arguments.length){const e=arguments[0],t=arguments[1];return this._depth[e][t]===zn.NULL_VALUE}}normalize(){for(let e=0;e<2;e++)if(!this.isNull(e)){let t=this._depth[e][1];this._depth[e][2]t&&(i=1),this._depth[e][n]=i}}}getDelta(e){return this._depth[e][lt.RIGHT]-this._depth[e][lt.LEFT]}getLocation(e,t){return this._depth[e][t]<=0?at.EXTERIOR:at.INTERIOR}toString(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]}add(){if(1===arguments.length){const e=arguments[0];for(let t=0;t<2;t++)for(let n=1;n<3;n++){const i=e.getLocation(t,n);i!==at.EXTERIOR&&i!==at.INTERIOR||(this.isNull(t,n)?this._depth[t][n]=zn.depthAtLocation(i):this._depth[t][n]+=zn.depthAtLocation(i))}}else if(3===arguments.length){const e=arguments[0],t=arguments[1];arguments[2]===at.INTERIOR&&this._depth[e][t]++}}}zn.NULL_VALUE=-1;class Wn extends vt{constructor(){super(),Wn.constructor_.apply(this,arguments)}static constructor_(){if(this.pts=null,this._env=null,this.eiList=new On(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new zn,this._depthDelta=0,1===arguments.length){const e=arguments[0];Wn.constructor_.call(this,e,null)}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.pts=e,this._label=t}}static updateIM(){if(!(2===arguments.length&&arguments[1]instanceof Fn&&arguments[0]instanceof yt))return super.updateIM.apply(this,arguments);{const e=arguments[0],t=arguments[1];t.setAtLeastIfValid(e.getLocation(0,lt.ON),e.getLocation(1,lt.ON),1),e.isArea()&&(t.setAtLeastIfValid(e.getLocation(0,lt.LEFT),e.getLocation(1,lt.LEFT),2),t.setAtLeastIfValid(e.getLocation(0,lt.RIGHT),e.getLocation(1,lt.RIGHT),2))}}getDepth(){return this._depth}getCollapsedEdge(){const e=new Array(2).fill(null);e[0]=this.pts[0],e[1]=this.pts[1];return new Wn(e,yt.toLineLabel(this._label))}isIsolated(){return this._isIsolated}getCoordinates(){return this.pts}setIsolated(e){this._isIsolated=e}setName(e){this._name=e}equals(e){if(!(e instanceof Wn))return!1;const t=e;if(this.pts.length!==t.pts.length)return!1;let n=!0,i=!0,r=this.pts.length;for(let e=0;e0?this.pts[0]:null;if(1===arguments.length){const e=arguments[0];return this.pts[e]}}print(e){e.print("edge "+this._name+": "),e.print("LINESTRING (");for(let t=0;t0&&e.print(","),e.print(this.pts[t].x+" "+this.pts[t].y);e.print(") "+this._label+" "+this._depthDelta)}computeIM(e){Wn.updateIM(this._label,e)}isCollapsed(){return!!this._label.isArea()&&(3===this.pts.length&&!!this.pts[0].equals(this.pts[2]))}isClosed(){return this.pts[0].equals(this.pts[this.pts.length-1])}getMaximumSegmentIndex(){return this.pts.length-1}getDepthDelta(){return this._depthDelta}getNumPoints(){return this.pts.length}printReverse(e){e.print("edge "+this._name+": ");for(let t=this.pts.length-1;t>=0;t--)e.print(this.pts[t]+" ");e.println("")}getMonotoneChainEdge(){return null===this._mce&&(this._mce=new Gn(this)),this._mce}getEnvelope(){if(null===this._env){this._env=new E;for(let e=0;e0&&e.append(","),e.append(this.pts[t].x+" "+this.pts[t].y);return e.append(") "+this._label+" "+this._depthDelta),e.toString()}isPointwiseEqual(e){if(this.pts.length!==e.pts.length)return!1;for(let t=0;ti||this._maxyo;if(s)return!1;const a=this.intersectsToleranceSquare(e,t);return x.isTrue(!(s&&a),"Found bad envelope test"),a}initCorners(e){const t=.5;this._minx=e.x-t,this._maxx=e.x+t,this._miny=e.y-t,this._maxy=e.y+t,this._corner[0]=new I(this._maxx,this._maxy),this._corner[1]=new I(this._minx,this._maxy),this._corner[2]=new I(this._minx,this._miny),this._corner[3]=new I(this._maxx,this._miny)}intersects(e,t){return 1===this._scaleFactor?this.intersectsScaled(e,t):(this.copyScaled(e,this._p0Scaled),this.copyScaled(t,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))}scale(e){return Math.round(e*this._scaleFactor)}getCoordinate(){return this._originalPt}copyScaled(e,t){t.x=this.scale(e.x),t.y=this.scale(e.y)}getSafeEnvelope(){if(null===this._safeEnv){const e=Vn.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new E(this._originalPt.x-e,this._originalPt.x+e,this._originalPt.y-e,this._originalPt.y+e)}return this._safeEnv}intersectsPixelClosure(e,t){return this._li.computeIntersection(e,t,this._corner[0],this._corner[1]),!!this._li.hasIntersection()||(this._li.computeIntersection(e,t,this._corner[1],this._corner[2]),!!this._li.hasIntersection()||(this._li.computeIntersection(e,t,this._corner[2],this._corner[3]),!!this._li.hasIntersection()||(this._li.computeIntersection(e,t,this._corner[3],this._corner[0]),!!this._li.hasIntersection())))}intersectsToleranceSquare(e,t){let n=!1,i=!1;return this._li.computeIntersection(e,t,this._corner[0],this._corner[1]),!!this._li.isProper()||(this._li.computeIntersection(e,t,this._corner[1],this._corner[2]),!!this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(e,t,this._corner[2],this._corner[3]),!!this._li.isProper()||(this._li.hasIntersection()&&(i=!0),this._li.computeIntersection(e,t,this._corner[3],this._corner[0]),!!this._li.isProper()||(!(!n||!i)||(!!e.equals(this._pt)||!!t.equals(this._pt))))))}addSnappedNode(e,t){const n=e.getCoordinate(t),i=e.getCoordinate(t+1);return!!this.intersects(n,i)&&(e.addIntersection(this.getCoordinate(),t),!0)}}Vn.SAFE_ENV_EXPANSION_FACTOR=.75;class Yn{constructor(){Yn.constructor_.apply(this,arguments)}static constructor_(){this.selectedSegment=new rt}select(){if(1===arguments.length);else if(2===arguments.length){const e=arguments[1];arguments[0].getLineSegment(e,this.selectedSegment),this.select(this.selectedSegment)}}}class qn{constructor(){qn.constructor_.apply(this,arguments)}static constructor_(){this._index=null;const e=arguments[0];this._index=e}snap(){if(1===arguments.length){const e=arguments[0];return this.snap(e,null,-1)}if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=e.getSafeEnvelope(),r=new Kn(e,t,n);return this._index.query(i,new class{get interfaces_(){return[Yt]}visitItem(e){e.select(i,r)}}),r.isNodeAdded()}}}class Kn extends Yn{constructor(){super(),Kn.constructor_.apply(this,arguments)}static constructor_(){this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;const e=arguments[0],t=arguments[1],n=arguments[2];this._hotPixel=e,this._parentEdge=t,this._hotPixelVertexIndex=n}isNodeAdded(){return this._isNodeAdded}select(){if(!(2===arguments.length&&Number.isInteger(arguments[1])&&arguments[0]instanceof an))return super.select.apply(this,arguments);{const e=arguments[1],t=arguments[0].getContext();if(this._parentEdge===t&&(e===this._hotPixelVertexIndex||e+1===this._hotPixelVertexIndex))return null;this._isNodeAdded|=this._hotPixel.addSnappedNode(t,e)}}}qn.HotPixelSnapAction=Kn;class Xn{constructor(){Xn.constructor_.apply(this,arguments)}static constructor_(){this._li=null,this._interiorIntersections=null;const e=arguments[0];this._li=e,this._interiorIntersections=new j}processIntersections(e,t,n,i){if(e===n&&t===i)return null;const r=e.getCoordinates()[t],o=e.getCoordinates()[t+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];if(this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(let e=0;e0?t:0),o=n-Math.trunc(Math.log(r)/Math.log(10)+1);return Math.pow(10,o)}bufferFixedPrecision(e){const t=new Un(new Jn(new Ae(1)),e.getScale()),n=new Hn(this._bufParams);n.setWorkingPrecisionModel(e),n.setNoder(t),this._resultGeometry=n.buffer(this._argGeom,this._distance)}bufferReducedPrecision(){if(0===arguments.length){for(let e=Zn.MAX_PRECISION_DIGITS;e>=0;e--){try{this.bufferReducedPrecision(e)}catch(e){if(!(e instanceof dt))throw e;this._saveException=e}if(null!==this._resultGeometry)return null}throw this._saveException}if(1===arguments.length){const e=arguments[0],t=Zn.precisionScaleFactor(this._argGeom,this._distance,e),n=new Ae(t);this.bufferFixedPrecision(n)}}computeGeometry(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;const e=this._argGeom.getFactory().getPrecisionModel();e.getType()===Ae.FIXED?this.bufferFixedPrecision(e):this.bufferReducedPrecision()}setQuadrantSegments(e){this._bufParams.setQuadrantSegments(e)}bufferOriginalPrecision(){try{const e=new Hn(this._bufParams);this._resultGeometry=e.buffer(this._argGeom,this._distance)}catch(e){if(!(e instanceof b))throw e;this._saveException=e}}getResultGeometry(e){return this._distance=e,this.computeGeometry(),this._resultGeometry}setEndCapStyle(e){this._bufParams.setEndCapStyle(e)}}Zn.CAP_ROUND=st.CAP_ROUND,Zn.CAP_BUTT=st.CAP_FLAT,Zn.CAP_FLAT=st.CAP_FLAT,Zn.CAP_SQUARE=st.CAP_SQUARE,Zn.MAX_PRECISION_DIGITS=12;class Qn{isInBoundary(e){}}class $n{isInBoundary(e){return e%2==1}get interfaces_(){return[Qn]}}class ei{isInBoundary(e){return e>0}get interfaces_(){return[Qn]}}class ti{isInBoundary(e){return e>1}get interfaces_(){return[Qn]}}class ni{isInBoundary(e){return 1===e}get interfaces_(){return[Qn]}}Qn.Mod2BoundaryNodeRule=$n,Qn.EndPointBoundaryNodeRule=ei,Qn.MultiValentEndPointBoundaryNodeRule=ti,Qn.MonoValentEndPointBoundaryNodeRule=ni,Qn.MOD2_BOUNDARY_RULE=new $n,Qn.ENDPOINT_BOUNDARY_RULE=new ei,Qn.MULTIVALENT_ENDPOINT_BOUNDARY_RULE=new ti,Qn.MONOVALENT_ENDPOINT_BOUNDARY_RULE=new ni,Qn.OGC_SFS_BOUNDARY_RULE=Qn.MOD2_BOUNDARY_RULE;class ii{constructor(){ii.constructor_.apply(this,arguments)}static constructor_(){if(this._boundaryRule=Qn.OGC_SFS_BOUNDARY_RULE,this._isIn=null,this._numBoundaries=null,0===arguments.length);else if(1===arguments.length){const e=arguments[0];if(null===e)throw new h("Rule must be non-null");this._boundaryRule=e}}locateInPolygonRing(e,t){return t.getEnvelopeInternal().intersects(e)?pt.locateInRing(e,t.getCoordinates()):at.EXTERIOR}intersects(e,t){return this.locate(e,t)!==at.EXTERIOR}updateLocationInfo(e){e===at.INTERIOR&&(this._isIn=!0),e===at.BOUNDARY&&this._numBoundaries++}computeLocation(e,t){if(t instanceof X&&this.updateLocationInfo(this.locateOnPoint(e,t)),t instanceof G)this.updateLocationInfo(this.locateOnLineString(e,t));else if(t instanceof oe)this.updateLocationInfo(this.locateInPolygon(e,t));else if(t instanceof Ne){const n=t;for(let t=0;t0||this._isIn?at.INTERIOR:at.EXTERIOR)}}class ri{constructor(){ri.constructor_.apply(this,arguments)}static constructor_(){this._pts=null,this._data=null;const e=arguments[0],t=arguments[1];this._pts=e,this._data=t}getCoordinates(){return this._pts}size(){return this._pts.length}getCoordinate(e){return this._pts[e]}isClosed(){return this._pts[0].equals(this._pts[this._pts.length-1])}getSegmentOctant(e){return e===this._pts.length-1?-1:tn.octant(this.getCoordinate(e),this.getCoordinate(e+1))}setData(e){this._data=e}getData(){return this._data}toString(){return tt.toLineString(new xe(this._pts))}get interfaces_(){return[nn]}}class oi{constructor(){oi.constructor_.apply(this,arguments)}static constructor_(){this._findAllIntersections=!1,this._isCheckEndSegmentsOnly=!1,this._keepIntersections=!0,this._isInteriorIntersectionsOnly=!1,this._li=null,this._interiorIntersection=null,this._intSegments=null,this._intersections=new j,this._intersectionCount=0;const e=arguments[0];this._li=e,this._interiorIntersection=null}static createAllIntersectionsFinder(e){const t=new oi(e);return t.setFindAllIntersections(!0),t}static isInteriorVertexIntersection(){if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[3];return(!arguments[2]||!n)&&!!e.equals2D(t)}if(8===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3],r=arguments[4],o=arguments[5],s=arguments[6],a=arguments[7];return!!oi.isInteriorVertexIntersection(e,n,r,s)||(!!oi.isInteriorVertexIntersection(e,i,r,a)||(!!oi.isInteriorVertexIntersection(t,n,o,s)||!!oi.isInteriorVertexIntersection(t,i,o,a)))}}static createInteriorIntersectionCounter(e){const t=new oi(e);return t.setInteriorIntersectionsOnly(!0),t.setFindAllIntersections(!0),t.setKeepIntersections(!1),t}static createIntersectionCounter(e){const t=new oi(e);return t.setFindAllIntersections(!0),t.setKeepIntersections(!1),t}static isEndSegment(e,t){return 0===t||t>=e.size()-2}static createAnyIntersectionFinder(e){return new oi(e)}static createInteriorIntersectionsFinder(e){const t=new oi(e);return t.setFindAllIntersections(!0),t.setInteriorIntersectionsOnly(!0),t}setCheckEndSegmentsOnly(e){this._isCheckEndSegmentsOnly=e}getIntersectionSegments(){return this._intSegments}count(){return this._intersectionCount}getIntersections(){return this._intersections}setFindAllIntersections(e){this._findAllIntersections=e}setKeepIntersections(e){this._keepIntersections=e}getIntersection(){return this._interiorIntersection}processIntersections(e,t,n,i){if(!this._findAllIntersections&&this.hasIntersection())return null;const r=e===n;if(r&&t===i)return null;if(this._isCheckEndSegmentsOnly){if(!(oi.isEndSegment(e,t)||oi.isEndSegment(n,i)))return null}const o=e.getCoordinate(t),s=e.getCoordinate(t+1),a=n.getCoordinate(i),l=n.getCoordinate(i+1),c=0===t,h=t+2===e.size(),u=0===i,d=i+2===n.size();this._li.computeIntersection(o,s,a,l);const m=this._li.hasIntersection()&&this._li.isInteriorIntersection();let g=!1;if(!this._isInteriorIntersectionsOnly){g=!(r&&Math.abs(i-t)<=1)&&oi.isInteriorVertexIntersection(o,s,a,l,c,h,u,d)}(m||g)&&(this._intSegments=new Array(4).fill(null),this._intSegments[0]=o,this._intSegments[1]=s,this._intSegments[2]=a,this._intSegments[3]=l,this._interiorIntersection=this._li.getIntersection(0),this._keepIntersections&&this._intersections.add(this._interiorIntersection),this._intersectionCount++)}hasIntersection(){return null!==this._interiorIntersection}isDone(){return!this._findAllIntersections&&null!==this._interiorIntersection}setInteriorIntersectionsOnly(e){this._isInteriorIntersectionsOnly=e}get interfaces_(){return[Rn]}}class si{constructor(){si.constructor_.apply(this,arguments)}static constructor_(){this._li=new it,this._segStrings=null,this._findAllIntersections=!1,this._segInt=null,this._isValid=!0;const e=arguments[0];this._segStrings=e}static computeIntersections(e){const t=new si(e);return t.setFindAllIntersections(!0),t.isValid(),t.getIntersections()}execute(){if(null!==this._segInt)return null;this.checkInteriorIntersections()}getIntersections(){return this._segInt.getIntersections()}isValid(){return this.execute(),this._isValid}setFindAllIntersections(e){this._findAllIntersections=e}checkInteriorIntersections(){this._isValid=!0,this._segInt=new oi(this._li),this._segInt.setFindAllIntersections(this._findAllIntersections);const e=new un;if(e.setSegmentIntersector(this._segInt),e.computeNodes(this._segStrings),this._segInt.hasIntersection())return this._isValid=!1,null}checkValid(){if(this.execute(),!this._isValid)throw new dt(this.getErrorMessage(),this._segInt.getIntersection())}getErrorMessage(){if(this._isValid)return"no intersections found";const e=this._segInt.getIntersectionSegments();return"found non-noded intersection between "+tt.toLineString(e[0],e[1])+" and "+tt.toLineString(e[2],e[3])}}class ai{constructor(){ai.constructor_.apply(this,arguments)}static constructor_(){this._nv=null;const e=arguments[0];this._nv=new si(ai.toSegmentStrings(e))}static toSegmentStrings(e){const t=new j;for(let n=e.iterator();n.hasNext();){const e=n.next();t.add(new ri(e.getCoordinates(),e))}return t}static checkValid(e){new ai(e).checkValid()}checkValid(){this._nv.checkValid()}}class li{constructor(){li.constructor_.apply(this,arguments)}static constructor_(){this._mapOp=null;const e=arguments[0];this._mapOp=e}static map(e,t){return new li(t).map(e)}map(e){const t=new j;for(let n=0;n=0&&e.add(r+1,new I(n),!1)}}findSegmentIndexToSnap(e,t){let n=_.MAX_VALUE,i=-1;for(let r=0;rt&&(t=e)}return t}if(2===arguments.length){const e=arguments[0],t=arguments[1];return Math.min(mi.computeOverlaySnapTolerance(e),mi.computeOverlaySnapTolerance(t))}}static computeSizeBasedSnapTolerance(e){const t=e.getEnvelopeInternal();return Math.min(t.getHeight(),t.getWidth())*mi.SNAP_PRECISION_FACTOR}static snapToSelf(e,t,n){return new mi(e).snapToSelf(t,n)}snapTo(e,t){const n=this.extractTargetCoordinates(e);return new gi(t,n).transform(this._srcGeom)}snapToSelf(e,t){const n=this.extractTargetCoordinates(this._srcGeom),i=new gi(e,n,!0).transform(this._srcGeom);let r=i;return t&&N(r,re)&&(r=i.buffer(0)),r}computeSnapTolerance(e){return this.computeMinimumSegmentLength(e)/10}extractTargetCoordinates(e){const t=new le,n=e.getCoordinates();for(let e=0;e>>20}static zeroLowerBits(e,t){let n="low";if(t>32&&(e.low=0,t%=32,n="high"),t>0){const i=t<32?~((1<=0;i--){if(fi.getBit(e,i)!==fi.getBit(t,i))return n;n++}return 52}}class pi{constructor(){pi.constructor_.apply(this,arguments)}static constructor_(){this._commonCoord=null,this._ccFilter=new _i}addCommonBits(e){const t=new yi(this._commonCoord);e.apply(t),e.geometryChanged()}removeCommonBits(e){if(0===this._commonCoord.x&&0===this._commonCoord.y)return e;const t=new I(this._commonCoord);t.x=-t.x,t.y=-t.y;const n=new yi(t);return e.apply(n),e.geometryChanged(),e}getCommonCoordinate(){return this._commonCoord}add(e){e.apply(this._ccFilter),this._commonCoord=this._ccFilter.getCommonCoordinate()}}class _i{constructor(){_i.constructor_.apply(this,arguments)}static constructor_(){this._commonBitsX=new fi,this._commonBitsY=new fi}filter(e){this._commonBitsX.add(e.x),this._commonBitsY.add(e.y)}getCommonCoordinate(){return new I(this._commonBitsX.getCommon(),this._commonBitsY.getCommon())}get interfaces_(){return[M]}}class yi{constructor(){yi.constructor_.apply(this,arguments)}static constructor_(){this.trans=null;const e=arguments[0];this.trans=e}filter(e,t){const n=e.getOrdinate(t,0)+this.trans.x,i=e.getOrdinate(t,1)+this.trans.y;e.setOrdinate(t,0,n),e.setOrdinate(t,1,i)}isDone(){return!1}isGeometryChanged(){return!0}get interfaces_(){return[B]}}pi.CommonCoordinateFilter=_i,pi.Translater=yi;class bi{constructor(){bi.constructor_.apply(this,arguments)}static constructor_(){this._geom=new Array(2).fill(null),this._snapTolerance=null,this._cbr=null;const e=arguments[0],t=arguments[1];this._geom[0]=e,this._geom[1]=t,this.computeSnapTolerance()}static overlayOp(e,t,n){return new bi(e,t).getResultGeometry(n)}static union(e,t){return bi.overlayOp(e,t,Fi.UNION)}static intersection(e,t){return bi.overlayOp(e,t,Fi.INTERSECTION)}static symDifference(e,t){return bi.overlayOp(e,t,Fi.SYMDIFFERENCE)}static difference(e,t){return bi.overlayOp(e,t,Fi.DIFFERENCE)}selfSnap(e){return new mi(e).snapTo(e,this._snapTolerance)}removeCommonBits(e){this._cbr=new pi,this._cbr.add(e[0]),this._cbr.add(e[1]);const t=new Array(2).fill(null);return t[0]=this._cbr.removeCommonBits(e[0].copy()),t[1]=this._cbr.removeCommonBits(e[1].copy()),t}prepareResult(e){return this._cbr.addCommonBits(e),e}getResultGeometry(e){const t=this.snap(this._geom),n=Fi.overlayOp(t[0],t[1],e);return this.prepareResult(n)}checkValid(e){e.isValid()||ye.out.println("Snapped geometry is invalid")}computeSnapTolerance(){this._snapTolerance=mi.computeOverlaySnapTolerance(this._geom[0],this._geom[1])}snap(e){const t=this.removeCommonBits(e);return mi.snap(t[0],t[1],this._snapTolerance)}}class Ci{constructor(){Ci.constructor_.apply(this,arguments)}static constructor_(){this._geom=new Array(2).fill(null);const e=arguments[0],t=arguments[1];this._geom[0]=e,this._geom[1]=t}static overlayOp(e,t,n){return new Ci(e,t).getResultGeometry(n)}static union(e,t){return Ci.overlayOp(e,t,Fi.UNION)}static intersection(e,t){return Ci.overlayOp(e,t,Fi.INTERSECTION)}static symDifference(e,t){return Ci.overlayOp(e,t,Fi.SYMDIFFERENCE)}static difference(e,t){return Ci.overlayOp(e,t,Fi.DIFFERENCE)}getResultGeometry(e){let t=null,n=!1,i=null;try{t=Fi.overlayOp(this._geom[0],this._geom[1],e);!0&&(n=!0)}catch(e){if(!(e instanceof b))throw e;i=e}if(!n)try{t=bi.overlayOp(this._geom[0],this._geom[1],e)}catch(e){throw e instanceof b?i:e}return t}}class xi{constructor(){xi.constructor_.apply(this,arguments)}static constructor_(){this.mce=null,this.chainIndex=null;const e=arguments[0],t=arguments[1];this.mce=e,this.chainIndex=t}computeIntersections(e,t){this.mce.computeIntersectsForChain(this.chainIndex,e.mce,e.chainIndex,t)}}class vi{constructor(){vi.constructor_.apply(this,arguments)}static constructor_(){if(this._label=null,this._xValue=null,this._eventType=null,this._insertEvent=null,this._deleteEventIndex=null,this._obj=null,2===arguments.length){const e=arguments[0],t=arguments[1];this._eventType=vi.DELETE,this._xValue=e,this._insertEvent=t}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];this._eventType=vi.INSERT,this._label=e,this._xValue=t,this._obj=n}}isDelete(){return this._eventType===vi.DELETE}setDeleteEventIndex(e){this._deleteEventIndex=e}getObject(){return this._obj}compareTo(e){const t=e;return this._xValuet._xValue?1:this._eventTypet._eventType?1:0}getInsertEvent(){return this._insertEvent}isInsert(){return this._eventType===vi.INSERT}isSameLabel(e){return null!==this._label&&this._label===e._label}getDeleteEventIndex(){return this._deleteEventIndex}get interfaces_(){return[d]}}vi.INSERT=1,vi.DELETE=2;class Si{constructor(){Si.constructor_.apply(this,arguments)}static constructor_(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._properIntersectionPoint=null,this._li=null,this._includeProper=null,this._recordIsolated=null,this._isSelfIntersection=null,this._numIntersections=0,this.numTests=0,this._bdyNodes=null,this._isDone=!1,this._isDoneWhenProperInt=!1;const e=arguments[0],t=arguments[1],n=arguments[2];this._li=e,this._includeProper=t,this._recordIsolated=n}static isAdjacentSegments(e,t){return 1===Math.abs(e-t)}isTrivialIntersection(e,t,n,i){if(e===n&&1===this._li.getIntersectionNum()){if(Si.isAdjacentSegments(t,i))return!0;if(e.isClosed()){const n=e.getNumPoints()-1;if(0===t&&i===n||0===i&&t===n)return!0}}return!1}getProperIntersectionPoint(){return this._properIntersectionPoint}setIsDoneIfProperInt(e){this._isDoneWhenProperInt=e}hasProperInteriorIntersection(){return this._hasProperInterior}isBoundaryPointInternal(e,t){for(let n=t.iterator();n.hasNext();){const t=n.next().getCoordinate();if(e.isIntersection(t))return!0}return!1}hasProperIntersection(){return this._hasProper}hasIntersection(){return this._hasIntersection}isDone(){return this._isDone}isBoundaryPoint(e,t){return null!==t&&(!!this.isBoundaryPointInternal(e,t[0])||!!this.isBoundaryPointInternal(e,t[1]))}setBoundaryNodes(e,t){this._bdyNodes=new Array(2).fill(null),this._bdyNodes[0]=e,this._bdyNodes[1]=t}addIntersections(e,t,n,i){if(e===n&&t===i)return null;this.numTests++;const r=e.getCoordinates()[t],o=e.getCoordinates()[t+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&(this._recordIsolated&&(e.setIsolated(!1),n.setIsolated(!1)),this._numIntersections++,this.isTrivialIntersection(e,t,n,i)||(this._hasIntersection=!0,!this._includeProper&&this._li.isProper()||(e.addIntersections(this._li,t,0),n.addIntersections(this._li,i,1)),this._li.isProper()&&(this._properIntersectionPoint=this._li.getIntersection(0).copy(),this._hasProper=!0,this._isDoneWhenProperInt&&(this._isDone=!0),this.isBoundaryPoint(this._li,this._bdyNodes)||(this._hasProperInterior=!0))))}}class Ti extends class{}{constructor(){super(),Ti.constructor_.apply(this,arguments)}static constructor_(){this.events=new j,this.nOverlaps=null}prepareEvents(){Ut.sort(this.events);for(let e=0;et||this._maxo?1:0}get interfaces_(){return[y]}};class wi extends Ii{constructor(){super(),wi.constructor_.apply(this,arguments)}static constructor_(){this._item=null;const e=arguments[0],t=arguments[1],n=arguments[2];this._min=e,this._max=t,this._item=n}query(e,t,n){if(!this.intersects(e,t))return null;n.visitItem(this._item)}}class Ei extends Ii{constructor(){super(),Ei.constructor_.apply(this,arguments)}static constructor_(){this._node1=null,this._node2=null;const e=arguments[0],t=arguments[1];this._node1=e,this._node2=t,this.buildExtent(this._node1,this._node2)}buildExtent(e,t){this._min=Math.min(e._min,t._min),this._max=Math.max(e._max,t._max)}query(e,t,n){if(!this.intersects(e,t))return null;null!==this._node1&&this._node1.query(e,t,n),null!==this._node2&&this._node2.query(e,t,n)}}class Ai{constructor(){Ai.constructor_.apply(this,arguments)}static constructor_(){this._leaves=new j,this._root=null,this._level=0}buildTree(){Ut.sort(this._leaves,new Ii.NodeComparator);let e=this._leaves,t=null,n=new j;for(;;){if(this.buildLevel(e,n),1===n.size())return n.get(0);t=e,e=n,n=t}}insert(e,t,n){if(null!==this._root)throw new IllegalStateException("Index cannot be added to once it has been queried");this._leaves.add(new wi(e,t,n))}query(e,t,n){if(this.init(),null===this._root)return null;this._root.query(e,t,n)}buildRoot(){if(null!==this._root)return null;this._root=this.buildTree()}printNode(e){ye.out.println(tt.toLineString(new I(e._min,this._level),new I(e._max,this._level)))}init(){return null!==this._root||0===this._leaves.size()?null:void this.buildRoot()}buildLevel(e,t){this._level++,t.clear();for(let n=0;n=2,"found LineString with single point"),this.insertBoundaryPoint(this._argIndex,t[0]),this.insertBoundaryPoint(this._argIndex,t[t.length-1])}getInvalidPoint(){return this._invalidPoint}getBoundaryPoints(){const e=this.getBoundaryNodes(),t=new Array(e.size()).fill(null);let n=0;for(let i=e.iterator();i.hasNext();){const e=i.next();t[n++]=e.getCoordinate().copy()}return t}getBoundaryNodes(){return null===this._boundaryNodes&&(this._boundaryNodes=this._nodes.getBoundaryNodes(this._argIndex)),this._boundaryNodes}addSelfIntersectionNode(e,t,n){if(this.isBoundaryNode(e,t))return null;n===at.BOUNDARY&&this._useBoundaryDeterminationRule?this.insertBoundaryPoint(e,t):this.insertPoint(e,t,n)}addPolygonRing(e,t,n){if(e.isEmpty())return null;const i=be.removeRepeatedPoints(e.getCoordinates());if(i.length<4)return this._hasTooFewPoints=!0,this._invalidPoint=i[0],null;let r=t,o=n;ie.isCCW(i)&&(r=n,o=t);const s=new Wn(i,new yt(this._argIndex,at.BOUNDARY,r,o));this._lineEdgeMap.put(e,s),this.insertEdge(s),this.insertPoint(this._argIndex,i[0],at.BOUNDARY)}insertPoint(e,t,n){const i=this._nodes.addNode(t),r=i.getLabel();null===r?i._label=new yt(e,n):r.setLocation(e,n)}createEdgeSetIntersector(){return new Ti}addSelfIntersectionNodes(e){for(let t=this._edges.iterator();t.hasNext();){const n=t.next(),i=n.getLabel().getLocation(e);for(let t=n.eiList.iterator();t.hasNext();){const n=t.next();this.addSelfIntersectionNode(e,n.coord,i)}}}add(){if(!(1===arguments.length&&arguments[0]instanceof A))return super.add.apply(this,arguments);{const e=arguments[0];if(e.isEmpty())return null;if(e instanceof Se&&(this._useBoundaryDeterminationRule=!1),e instanceof oe)this.addPolygon(e);else if(e instanceof G)this.addLineString(e);else if(e instanceof X)this.addPoint(e);else if(e instanceof ue)this.addCollection(e);else if(e instanceof Ne)this.addCollection(e);else if(e instanceof Se)this.addCollection(e);else{if(!(e instanceof he))throw new L(e.getGeometryType());this.addCollection(e)}}}addCollection(e){for(let t=0;t50?(null===this._areaPtLocator&&(this._areaPtLocator=new Di(this._parentGeom)),this._areaPtLocator.locate(e)):this._ptLocator.locate(e,this._parentGeom)}findEdge(){if(1===arguments.length&&arguments[0]instanceof G){const e=arguments[0];return this._lineEdgeMap.get(e)}return super.findEdge.apply(this,arguments)}}class Oi{constructor(){Oi.constructor_.apply(this,arguments)}static constructor_(){if(this._li=new it,this._resultPrecisionModel=null,this._arg=null,1===arguments.length){const e=arguments[0];this.setComputationPrecision(e.getPrecisionModel()),this._arg=new Array(1).fill(null),this._arg[0]=new Li(0,e)}else if(2===arguments.length){const e=arguments[0],t=arguments[1];Oi.constructor_.call(this,e,t,Qn.OGC_SFS_BOUNDARY_RULE)}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];e.getPrecisionModel().compareTo(t.getPrecisionModel())>=0?this.setComputationPrecision(e.getPrecisionModel()):this.setComputationPrecision(t.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new Li(0,e,n),this._arg[1]=new Li(1,t,n)}}getArgGeometry(e){return this._arg[e].getGeometry()}setComputationPrecision(e){this._resultPrecisionModel=e,this._li.setPrecisionModel(this._resultPrecisionModel)}}class Fi extends Oi{constructor(){super(),Fi.constructor_.apply(this,arguments)}static constructor_(){this._ptLocator=new ii,this._geomFact=null,this._resultGeom=null,this._graph=null,this._edgeList=new Dn,this._resultPolyList=new j,this._resultLineList=new j,this._resultPointList=new j;const e=arguments[0],t=arguments[1];Oi.constructor_.call(this,e,t),this._graph=new Ft(new Mn),this._geomFact=e.getFactory()}static overlayOp(e,t,n){return new Fi(e,t).getResultGeometry(n)}static union(e,t){if(e.isEmpty()||t.isEmpty()){if(e.isEmpty()&&t.isEmpty())return Fi.createEmptyResult(Fi.UNION,e,t,e.getFactory());if(e.isEmpty())return t.copy();if(t.isEmpty())return e.copy()}if(e.isGeometryCollection()||t.isGeometryCollection())throw new h("This method does not support GeometryCollection arguments");return Ci.overlayOp(e,t,Fi.UNION)}static intersection(e,t){if(e.isEmpty()||t.isEmpty())return Fi.createEmptyResult(Fi.INTERSECTION,e,t,e.getFactory());if(e.isGeometryCollection()){const n=t;return li.map(e,new class{get interfaces_(){return[MapOp]}map(e){return Fi.intersection(e,n)}})}return Ci.overlayOp(e,t,Fi.INTERSECTION)}static symDifference(e,t){if(e.isEmpty()||t.isEmpty()){if(e.isEmpty()&&t.isEmpty())return Fi.createEmptyResult(Fi.SYMDIFFERENCE,e,t,e.getFactory());if(e.isEmpty())return t.copy();if(t.isEmpty())return e.copy()}if(e.isGeometryCollection()||t.isGeometryCollection())throw new h("This method does not support GeometryCollection arguments");return Ci.overlayOp(e,t,Fi.SYMDIFFERENCE)}static resultDimension(e,t,n){const i=t.getDimension(),r=n.getDimension();let o=-1;switch(e){case Fi.INTERSECTION:o=Math.min(i,r);break;case Fi.UNION:o=Math.max(i,r);break;case Fi.DIFFERENCE:o=i;break;case Fi.SYMDIFFERENCE:o=Math.max(i,r)}return o}static createEmptyResult(e,t,n,i){const r=Fi.resultDimension(e,t,n);return i.createEmpty(r)}static difference(e,t){if(e.isEmpty())return Fi.createEmptyResult(Fi.DIFFERENCE,e,t,e.getFactory());if(t.isEmpty())return e.copy();if(e.isGeometryCollection()||t.isGeometryCollection())throw new h("This method does not support GeometryCollection arguments");return Ci.overlayOp(e,t,Fi.DIFFERENCE)}static isResultOfOp(){if(2===arguments.length){const e=arguments[0],t=arguments[1],n=e.getLocation(0),i=e.getLocation(1);return Fi.isResultOfOp(n,i,t)}if(3===arguments.length){let e=arguments[0],t=arguments[1],n=arguments[2];switch(e===at.BOUNDARY&&(e=at.INTERIOR),t===at.BOUNDARY&&(t=at.INTERIOR),n){case Fi.INTERSECTION:return e===at.INTERIOR&&t===at.INTERIOR;case Fi.UNION:return e===at.INTERIOR||t===at.INTERIOR;case Fi.DIFFERENCE:return e===at.INTERIOR&&t!==at.INTERIOR;case Fi.SYMDIFFERENCE:return e===at.INTERIOR&&t!==at.INTERIOR||e!==at.INTERIOR&&t===at.INTERIOR}return!1}}insertUniqueEdge(e){const t=this._edgeList.findEqualEdge(e);if(null!==t){const n=t.getLabel();let i=e.getLabel();t.isPointwiseEqual(e)||(i=new yt(e.getLabel()),i.flip());const r=t.getDepth();r.isNull()&&r.add(n),r.add(i),n.merge(i)}else this._edgeList.add(e)}getGraph(){return this._graph}cancelDuplicateResultEdges(){for(let e=this._graph.getEdgeEnds().iterator();e.hasNext();){const t=e.next(),n=t.getSym();t.isInResult()&&n.isInResult()&&(t.setInResult(!1),n.setInResult(!1))}}isCoveredByLA(e){return!!this.isCovered(e,this._resultLineList)||!!this.isCovered(e,this._resultPolyList)}computeGeometry(e,t,n,i){const r=new j;return r.addAll(e),r.addAll(t),r.addAll(n),r.isEmpty()?Fi.createEmptyResult(i,this._arg[0].getGeometry(),this._arg[1].getGeometry(),this._geomFact):this._geomFact.buildGeometry(r)}mergeSymLabels(){for(let e=this._graph.getNodes().iterator();e.hasNext();){e.next().getEdges().mergeSymLabels()}}isCovered(e,t){for(let n=t.iterator();n.hasNext();){const t=n.next();if(this._ptLocator.locate(e,t)!==at.EXTERIOR)return!0}return!1}replaceCollapsedEdges(){const e=new j;for(let t=this._edgeList.iterator();t.hasNext();){const n=t.next();n.isCollapsed()&&(t.remove(),e.add(n.getCollapsedEdge()))}this._edgeList.addAll(e)}updateNodeLabelling(){for(let e=this._graph.getNodes().iterator();e.hasNext();){const t=e.next(),n=t.getEdges().getLabel();t.getLabel().merge(n)}}getResultGeometry(e){return this.computeOverlay(e),this._resultGeom}insertUniqueEdges(e){for(let t=e.iterator();t.hasNext();){const e=t.next();this.insertUniqueEdge(e)}}computeOverlay(e){this.copyPoints(0),this.copyPoints(1),this._arg[0].computeSelfNodes(this._li,!1),this._arg[1].computeSelfNodes(this._li,!1),this._arg[0].computeEdgeIntersections(this._arg[1],this._li,!0);const t=new j;this._arg[0].computeSplitEdges(t),this._arg[1].computeSplitEdges(t),this.insertUniqueEdges(t),this.computeLabelsFromDepths(),this.replaceCollapsedEdges(),ai.checkValid(this._edgeList.getEdges()),this._graph.addEdges(this._edgeList.getEdges()),this.computeLabelling(),this.labelIncompleteNodes(),this.findResultAreaEdges(e),this.cancelDuplicateResultEdges();const n=new kt(this._geomFact);n.add(this._graph),this._resultPolyList=n.getPolygons();const i=new ci(this,this._geomFact,this._ptLocator);this._resultLineList=i.build(e);const r=new hi(this,this._geomFact,this._ptLocator);this._resultPointList=r.build(e),this._resultGeom=this.computeGeometry(this._resultPointList,this._resultLineList,this._resultPolyList,e)}labelIncompleteNode(e,t){const n=this._ptLocator.locate(e.getCoordinate(),this._arg[t].getGeometry());e.getLabel().setLocation(t,n)}copyPoints(e){for(let t=this._arg[e].getNodeIterator();t.hasNext();){const n=t.next();this._graph.addNode(n.getCoordinate()).setLabel(e,n.getLabel().getLocation(e))}}findResultAreaEdges(e){for(let t=this._graph.getEdgeEnds().iterator();t.hasNext();){const n=t.next(),i=n.getLabel();i.isArea()&&!n.isInteriorAreaEdge()&&Fi.isResultOfOp(i.getLocation(0,lt.RIGHT),i.getLocation(1,lt.RIGHT),e)&&n.setInResult(!0)}}computeLabelsFromDepths(){for(let e=this._edgeList.iterator();e.hasNext();){const t=e.next(),n=t.getLabel(),i=t.getDepth();if(!i.isNull()){i.normalize();for(let e=0;e<2;e++)n.isNull(e)||!n.isArea()||i.isNull(e)||(0===i.getDelta(e)?n.toLine(e):(x.isTrue(!i.isNull(e,lt.LEFT),"depth of LEFT side has not been initialized"),n.setLocation(e,lt.LEFT,i.getLocation(e,lt.LEFT)),x.isTrue(!i.isNull(e,lt.RIGHT),"depth of RIGHT side has not been initialized"),n.setLocation(e,lt.RIGHT,i.getLocation(e,lt.RIGHT))))}}}computeLabelling(){for(let e=this._graph.getNodes().iterator();e.hasNext();){e.next().getEdges().computeLabelling(this._arg)}this.mergeSymLabels(),this.updateNodeLabelling()}labelIncompleteNodes(){for(let e=this._graph.getNodes().iterator();e.hasNext();){const t=e.next(),n=t.getLabel();t.isIsolated()&&(n.isNull(0)?this.labelIncompleteNode(t,0):this.labelIncompleteNode(t,1)),t.getEdges().updateLabelling(n)}}isCoveredByA(e){return!!this.isCovered(e,this._resultPolyList)}}Fi.INTERSECTION=1,Fi.UNION=2,Fi.DIFFERENCE=3,Fi.SYMDIFFERENCE=4;class ki{createEdgeEndForNext(e,t,n,i){const r=n.segmentIndex+1;if(r>=e.getNumPoints()&&null===i)return null;let o=e.getCoordinate(r);null!==i&&i.segmentIndex===n.segmentIndex&&(o=i.coord);const s=new Pt(e,n.coord,o,new yt(e.getLabel()));t.add(s)}createEdgeEndForPrev(e,t,n,i){let r=n.segmentIndex;if(0===n.dist){if(0===r)return null;r--}let o=e.getCoordinate(r);null!==i&&i.segmentIndex>=r&&(o=i.coord);const s=new yt(e.getLabel());s.flip();const a=new Pt(e,n.coord,o,s);t.add(a)}computeEdgeEnds(){if(1===arguments.length){const e=arguments[0],t=new j;for(let n=e;n.hasNext();){const e=n.next();this.computeEdgeEnds(e,t)}return t}if(2===arguments.length){const e=arguments[0],t=arguments[1],n=e.getEdgeIntersectionList();n.addEndpoints();const i=n.iterator();let r=null,o=null;if(!i.hasNext())return null;let s=i.next();do{r=o,o=s,s=null,i.hasNext()&&(s=i.next()),null!==o&&(this.createEdgeEndForPrev(e,t,o,r),this.createEdgeEndForNext(e,t,o,s))}while(null!==o)}}}class Bi extends Pt{constructor(){super(),Bi.constructor_.apply(this,arguments)}static constructor_(){if(this._edgeEnds=new j,1===arguments.length){const e=arguments[0];Bi.constructor_.call(this,null,e)}else if(2===arguments.length){const e=arguments[1];Pt.constructor_.call(this,e.getEdge(),e.getCoordinate(),e.getDirectedCoordinate(),new yt(e.getLabel())),this.insert(e)}}insert(e){this._edgeEnds.add(e)}print(e){e.println("EdgeEndBundle--\x3e Label: "+this._label);for(let t=this.iterator();t.hasNext();){t.next().print(e),e.println()}}iterator(){return this._edgeEnds.iterator()}getEdgeEnds(){return this._edgeEnds}computeLabelOn(e,t){let n=0,i=!1;for(let t=this.iterator();t.hasNext();){const r=t.next().getLabel().getLocation(e);r===at.BOUNDARY&&n++,r===at.INTERIOR&&(i=!0)}let r=at.NONE;i&&(r=at.INTERIOR),n>0&&(r=Li.determineBoundary(t,n)),this._label.setLocation(e,r)}computeLabelSide(e,t){for(let n=this.iterator();n.hasNext();){const i=n.next();if(i.getLabel().isArea()){const n=i.getLabel().getLocation(e,t);if(n===at.INTERIOR)return this._label.setLocation(e,t,at.INTERIOR),null;n===at.EXTERIOR&&this._label.setLocation(e,t,at.EXTERIOR)}}}getLabel(){return this._label}computeLabelSides(e){this.computeLabelSide(e,lt.LEFT),this.computeLabelSide(e,lt.RIGHT)}updateIM(e){Wn.updateIM(this._label,e)}computeLabel(e){let t=!1;for(let e=this.iterator();e.hasNext();){e.next().getLabel().isArea()&&(t=!0)}this._label=t?new yt(at.NONE,at.NONE,at.NONE):new yt(at.NONE);for(let n=0;n<2;n++)this.computeLabelOn(n,e),t&&this.computeLabelSides(n)}}class Gi extends En{constructor(){super()}updateIM(e){for(let t=this.iterator();t.hasNext();){t.next().updateIM(e)}}insert(e){let t=this._edgeMap.get(e);null===t?(t=new Bi(e),this.insertEdgeEnd(e,t)):t.insert(e)}}class zi extends St{constructor(){super(),zi.constructor_.apply(this,arguments)}static constructor_(){const e=arguments[0],t=arguments[1];St.constructor_.call(this,e,t)}updateIMFromEdges(e){this._edges.updateIM(e)}computeIM(e){e.setAtLeastIfValid(this._label.getLocation(0),this._label.getLocation(1),0)}}class Wi extends Ot{constructor(){super()}createNode(e){return new zi(e,new Gi)}}class Hi{constructor(){Hi.constructor_.apply(this,arguments)}static constructor_(){this._li=new it,this._ptLocator=new ii,this._arg=null,this._nodes=new Dt(new Wi),this._im=null,this._isolatedEdges=new j,this._invalidPoint=null;const e=arguments[0];this._arg=e}insertEdgeEnds(e){for(let t=e.iterator();t.hasNext();){const e=t.next();this._nodes.add(e)}}computeProperIntersectionIM(e,t){const n=this._arg[0].getGeometry().getDimension(),i=this._arg[1].getGeometry().getDimension(),r=e.hasProperIntersection(),o=e.hasProperInteriorIntersection();2===n&&2===i?r&&t.setAtLeast("212101212"):2===n&&1===i?(r&&t.setAtLeast("FFF0FFFF2"),o&&t.setAtLeast("1FFFFF1FF")):1===n&&2===i?(r&&t.setAtLeast("F0FFFFFF2"),o&&t.setAtLeast("1F1FFFFFF")):1===n&&1===i&&o&&t.setAtLeast("0FFFFFFFF")}labelIsolatedEdges(e,t){for(let n=this._arg[e].getEdgeIterator();n.hasNext();){const e=n.next();e.isIsolated()&&(this.labelIsolatedEdge(e,t,this._arg[t].getGeometry()),this._isolatedEdges.add(e))}}labelIsolatedEdge(e,t,n){if(n.getDimension()>0){const i=this._ptLocator.locate(e.getCoordinate(),n);e.getLabel().setAllLocations(t,i)}else e.getLabel().setAllLocations(t,at.EXTERIOR)}computeIM(){const e=new Fn;if(e.set(at.EXTERIOR,at.EXTERIOR,2),!this._arg[0].getGeometry().getEnvelopeInternal().intersects(this._arg[1].getGeometry().getEnvelopeInternal()))return this.computeDisjointIM(e),e;this._arg[0].computeSelfNodes(this._li,!1),this._arg[1].computeSelfNodes(this._li,!1);const t=this._arg[0].computeEdgeIntersections(this._arg[1],this._li,!1);this.computeIntersectionNodes(0),this.computeIntersectionNodes(1),this.copyNodesAndLabels(0),this.copyNodesAndLabels(1),this.labelIsolatedNodes(),this.computeProperIntersectionIM(t,e);const n=new ki,i=n.computeEdgeEnds(this._arg[0].getEdgeIterator());this.insertEdgeEnds(i);const r=n.computeEdgeEnds(this._arg[1].getEdgeIterator());return this.insertEdgeEnds(r),this.labelNodeEdges(),this.labelIsolatedEdges(0,1),this.labelIsolatedEdges(1,0),this.updateIM(e),e}labelNodeEdges(){for(let e=this._nodes.iterator();e.hasNext();){e.next().getEdges().computeLabelling(this._arg)}}copyNodesAndLabels(e){for(let t=this._arg[e].getNodeIterator();t.hasNext();){const n=t.next();this._nodes.addNode(n.getCoordinate()).setLabel(e,n.getLabel().getLocation(e))}}labelIntersectionNodes(e){for(let t=this._arg[e].getEdgeIterator();t.hasNext();){const n=t.next(),i=n.getLabel().getLocation(e);for(let t=n.getEdgeIntersectionList().iterator();t.hasNext();){const n=t.next(),r=this._nodes.find(n.coord);r.getLabel().isNull(e)&&(i===at.BOUNDARY?r.setLabelBoundary(e):r.setLabel(e,at.INTERIOR))}}}labelIsolatedNode(e,t){const n=this._ptLocator.locate(e.getCoordinate(),this._arg[t].getGeometry());e.getLabel().setAllLocations(t,n)}computeIntersectionNodes(e){for(let t=this._arg[e].getEdgeIterator();t.hasNext();){const n=t.next(),i=n.getLabel().getLocation(e);for(let t=n.getEdgeIntersectionList().iterator();t.hasNext();){const n=t.next(),r=this._nodes.addNode(n.coord);i===at.BOUNDARY?r.setLabelBoundary(e):r.getLabel().isNull(e)&&r.setLabel(e,at.INTERIOR)}}}labelIsolatedNodes(){for(let e=this._nodes.iterator();e.hasNext();){const t=e.next(),n=t.getLabel();x.isTrue(n.getGeometryCount()>0,"node with empty label found"),t.isIsolated()&&(n.isNull(0)?this.labelIsolatedNode(t,0):this.labelIsolatedNode(t,1))}}updateIM(e){for(let t=this._isolatedEdges.iterator();t.hasNext();){t.next().updateIM(e)}for(let t=this._nodes.iterator();t.hasNext();){const n=t.next();n.updateIM(e),n.updateIMFromEdges(e)}}computeDisjointIM(e){const t=this._arg[0].getGeometry();t.isEmpty()||(e.set(at.INTERIOR,at.EXTERIOR,t.getDimension()),e.set(at.BOUNDARY,at.EXTERIOR,t.getBoundaryDimension()));const n=this._arg[1].getGeometry();n.isEmpty()||(e.set(at.EXTERIOR,at.INTERIOR,n.getDimension()),e.set(at.EXTERIOR,at.BOUNDARY,n.getBoundaryDimension()))}}class Ui{constructor(){Ui.constructor_.apply(this,arguments)}static constructor_(){this._rectEnv=null;const e=arguments[0];this._rectEnv=e.getEnvelopeInternal()}static contains(e,t){return new Ui(e).contains(t)}isContainedInBoundary(e){if(e instanceof oe)return!1;if(e instanceof X)return this.isPointContainedInBoundary(e);if(e instanceof G)return this.isLineStringContainedInBoundary(e);for(let t=0;t0){const n=e;e=t,t=n}let i=!1;return t.y>e.y&&(i=!0),i?this._li.computeIntersection(e,t,this._diagDown0,this._diagDown1):this._li.computeIntersection(e,t,this._diagUp0,this._diagUp1),!!this._li.hasIntersection()}}class Vi{constructor(){Vi.constructor_.apply(this,arguments)}static constructor_(){this._isDone=!1}applyTo(e){for(let t=0;t=this._rectEnv.getMinX()&&t.getMaxX()<=this._rectEnv.getMaxX()||t.getMinY()>=this._rectEnv.getMinY()&&t.getMaxY()<=this._rectEnv.getMaxY()?(this._intersects=!0,null):void 0:null}intersects(){return this._intersects}}class Ki extends Vi{constructor(){super(),Ki.constructor_.apply(this,arguments)}static constructor_(){this._rectSeq=null,this._rectEnv=null,this._containsPoint=!1;const e=arguments[0];this._rectSeq=e.getExteriorRing().getCoordinateSequence(),this._rectEnv=e.getEnvelopeInternal()}isDone(){return!0===this._containsPoint}visit(e){if(!(e instanceof oe))return null;const t=e.getEnvelopeInternal();if(!this._rectEnv.intersects(t))return null;const n=new I;for(let i=0;i<4;i++)if(this._rectSeq.getCoordinate(i,n),t.contains(n)&&wn.containsPointInPolygon(n,e))return this._containsPoint=!0,null}containsPoint(){return this._containsPoint}}class Xi extends Vi{constructor(){super(),Xi.constructor_.apply(this,arguments)}static constructor_(){this._rectEnv=null,this._rectIntersector=null,this._hasIntersection=!1,this._p0=new I,this._p1=new I;const e=arguments[0];this._rectEnv=e.getEnvelopeInternal(),this._rectIntersector=new ji(this._rectEnv)}intersects(){return this._hasIntersection}isDone(){return!0===this._hasIntersection}visit(e){const t=e.getEnvelopeInternal();if(!this._rectEnv.intersects(t))return null;const n=Mi.getLines(e);this.checkIntersectionWithLineStrings(n)}checkIntersectionWithLineStrings(e){for(let t=e.iterator();t.hasNext();){const e=t.next();if(this.checkIntersectionWithSegments(e),this._hasIntersection)return null}}checkIntersectionWithSegments(e){const t=e.getCoordinateSequence();for(let e=1;e0)&&(!!e.getEnvelopeInternal().covers(t.getEnvelopeInternal())&&(!!e.isRectangle()||new Ji(e,t).getIntersectionMatrix().isCovers())))}static intersects(e,t){if(!e.getEnvelopeInternal().intersects(t.getEnvelopeInternal()))return!1;if(e.isRectangle())return Yi.intersects(e,t);if(t.isRectangle())return Yi.intersects(t,e);if(e.isGeometryCollection()||t.isGeometryCollection()){for(let n=0;n0)&&(!!e.getEnvelopeInternal().contains(t.getEnvelopeInternal())&&(e.isRectangle()?Ui.contains(e,t):new Ji(e,t).getIntersectionMatrix().isContains())))}getIntersectionMatrix(){return this._relate.computeIM()}}class Zi{get interfaces_(){return[]}getClass(){return Zi}static union(e,t){if(e.isEmpty()||t.isEmpty()){if(e.isEmpty()&&t.isEmpty())return Fi.createEmptyResult(Fi.UNION,e,t,e.getFactory());if(e.isEmpty())return t.copy();if(t.isEmpty())return e.copy()}return e.checkNotGeometryCollection(e),e.checkNotGeometryCollection(t),Ci.overlayOp(e,t,Fi.UNION)}}class Qi{constructor(){Qi.constructor_.apply(this,arguments)}static constructor_(){this._geometryFactory=new De,this._geomGraph=null,this._disconnectedRingcoord=null;const e=arguments[0];this._geomGraph=e}static findDifferentPoint(e,t){for(let n=0;n1)return this._invalidPoint=e.getEdge().getCoordinate(0),!0}}return!1}isNodeConsistentArea(){const e=this._geomGraph.computeSelfNodes(this._li,!0,!0);return e.hasProperIntersection()?(this._invalidPoint=e.getProperIntersectionPoint(),!1):(this._nodeGraph.build(this._geomGraph),this.isNodeEdgeAreaLabelsConsistent())}}class tr{constructor(){tr.constructor_.apply(this,arguments)}static constructor_(){this._graph=null,this._rings=new j,this._totalEnv=new E,this._index=null,this._nestedPt=null;const e=arguments[0];this._graph=e}buildIndex(){this._index=new Xt;for(let e=0;e=1&&(t=e.getCoordinateN(0)),this._validErr=new nr(nr.RING_NOT_CLOSED,t)}}checkShellsNotNested(e,t){for(let n=0;n=t&&(e.getMinY()>=n&&(i=3),e.getMaxY()<=n&&(i=1)),e.getMaxX()<=t&&(e.getMinY()>=n&&(i=2),e.getMaxY()<=n&&(i=0)),i}hasChildren(){for(let e=0;e<4;e++)if(null!==this._subnode[e])return!0;return!1}isPrunable(){return!(this.hasChildren()||this.hasItems())}addAllItems(e){e.addAll(this._items);for(let t=0;t<4;t++)null!==this._subnode[t]&&this._subnode[t].addAllItems(e);return e}getNodeCount(){let e=0;for(let t=0;t<4;t++)null!==this._subnode[t]&&(e+=this._subnode[t].size());return e+1}size(){let e=0;for(let t=0;t<4;t++)null!==this._subnode[t]&&(e+=this._subnode[t].size());return e+this._items.size()}addAllItemsFromOverlapping(e,t){if(!this.isSearchMatch(e))return null;t.addAll(this._items);for(let n=0;n<4;n++)null!==this._subnode[n]&&this._subnode[n].addAllItemsFromOverlapping(e,t)}visitItems(e,t){for(let e=this._items.iterator();e.hasNext();)t.visitItem(e.next())}hasItems(){return!this._items.isEmpty()}remove(e,t){if(!this.isSearchMatch(e))return!1;let n=!1;for(let i=0;i<4;i++)if(null!==this._subnode[i]&&(n=this._subnode[i].remove(e,t),n)){this._subnode[i].isPrunable()&&(this._subnode[i]=null);break}return n||(n=this._items.remove(t),n)}visit(e,t){if(!this.isSearchMatch(e))return null;this.visitItems(e,t);for(let n=0;n<4;n++)null!==this._subnode[n]&&this._subnode[n].visit(e,t)}getItems(){return this._items}depth(){let e=0;for(let t=0;t<4;t++)if(null!==this._subnode[t]){const n=this._subnode[t].depth();n>e&&(e=n)}return e+1}isEmpty(){let e=!0;if(this._items.isEmpty()){for(let t=0;t<4;t++)if(null!==this._subnode[t]&&!this._subnode[t].isEmpty()){e=!1;break}}else e=!1;return e}add(e){this._items.add(e)}get interfaces_(){return[g]}}function or(){}or.exponent=function(e){return function(e,t){let n,i,r,o;const s={32:{d:127,c:128,b:0,a:0},64:{d:32752,c:0,b:0,a:0}},a={32:8,64:11}[e];o||(n=t<0||1/t<0,isFinite(t)||(o=s[e],n&&(o.d+=1<=2;)i++,r/=2;for(;r<1&&i>0;)i--,r*=2;i<=0&&(r/=2),32===e&&i>254&&(o={d:n?255:127,c:128,b:0,a:0},i=Math.pow(2,a)-1,r=0)}return i}(64,e)-1023},or.powerOf2=function(e){return Math.pow(2,e)};class sr{constructor(){sr.constructor_.apply(this,arguments)}static constructor_(){this._pt=new I,this._level=0,this._env=null;const e=arguments[0];this.computeKey(e)}static computeQuadLevel(e){const t=e.getWidth(),n=e.getHeight(),i=t>n?t:n;return or.exponent(i)+1}getLevel(){return this._level}computeKey(){if(1===arguments.length){const e=arguments[0];for(this._level=sr.computeQuadLevel(e),this._env=new E,this.computeKey(this._level,e);!this._env.contains(e);)this._level+=1,this.computeKey(this._level,e)}else if(2===arguments.length){const e=arguments[0],t=arguments[1],n=or.powerOf2(e);this._pt.x=Math.floor(t.getMinX()/n)*n,this._pt.y=Math.floor(t.getMinY()/n)*n,this._env.init(this._pt.x,this._pt.x+n,this._pt.y,this._pt.y+n)}}getEnvelope(){return this._env}getCentre(){return new I((this._env.getMinX()+this._env.getMaxX())/2,(this._env.getMinY()+this._env.getMaxY())/2)}getPoint(){return this._pt}}class ar extends rr{constructor(){super(),ar.constructor_.apply(this,arguments)}static constructor_(){this._env=null,this._centrex=null,this._centrey=null,this._level=null;const e=arguments[0],t=arguments[1];this._env=e,this._level=t,this._centrex=(e.getMinX()+e.getMaxX())/2,this._centrey=(e.getMinY()+e.getMaxY())/2}static createNode(e){const t=new sr(e);return new ar(t.getEnvelope(),t.getLevel())}static createExpanded(e,t){const n=new E(t);null!==e&&n.expandToInclude(e._env);const i=ar.createNode(n);return null!==e&&i.insertNode(e),i}find(e){const t=rr.getSubnodeIndex(e,this._centrex,this._centrey);if(-1===t)return this;if(null!==this._subnode[t]){return this._subnode[t].find(e)}return this}isSearchMatch(e){return null!==e&&this._env.intersects(e)}getSubnode(e){return null===this._subnode[e]&&(this._subnode[e]=this.createSubnode(e)),this._subnode[e]}getEnvelope(){return this._env}getNode(e){const t=rr.getSubnodeIndex(e,this._centrex,this._centrey);if(-1!==t){return this.getSubnode(t).getNode(e)}return this}createSubnode(e){let t=0,n=0,i=0,r=0;switch(e){case 0:t=this._env.getMinX(),n=this._centrex,i=this._env.getMinY(),r=this._centrey;break;case 1:t=this._centrex,n=this._env.getMaxX(),i=this._env.getMinY(),r=this._centrey;break;case 2:t=this._env.getMinX(),n=this._centrex,i=this._centrey,r=this._env.getMaxY();break;case 3:t=this._centrex,n=this._env.getMaxX(),i=this._centrey,r=this._env.getMaxY()}const o=new E(t,n,i,r);return new ar(o,this._level-1)}insertNode(e){x.isTrue(null===this._env||this._env.contains(e._env));const t=rr.getSubnodeIndex(e._env,this._centrex,this._centrey);if(e._level===this._level-1)this._subnode[t]=e;else{const n=this.createSubnode(t);n.insertNode(e),this._subnode[t]=n}}}class lr{static isZeroWidth(e,t){const n=t-e;if(0===n)return!0;const i=n/Math.max(Math.abs(e),Math.abs(t));return or.exponent(i)<=lr.MIN_BINARY_EXPONENT}}lr.MIN_BINARY_EXPONENT=-50;class cr extends rr{constructor(){super()}insert(e,t){const n=rr.getSubnodeIndex(e,cr.origin.x,cr.origin.y);if(-1===n)return this.add(t),null;const i=this._subnode[n];if(null===i||!i.getEnvelope().contains(e)){const t=ar.createExpanded(i,e);this._subnode[n]=t}this.insertContained(this._subnode[n],e,t)}isSearchMatch(e){return!0}insertContained(e,t,n){x.isTrue(e.getEnvelope().contains(t));const i=lr.isZeroWidth(t.getMinX(),t.getMaxX()),r=lr.isZeroWidth(t.getMinY(),t.getMaxY());let o=null;o=i||r?e.find(t):e.getNode(t),o.add(n)}}cr.origin=new I(0,0);class hr{constructor(){hr.constructor_.apply(this,arguments)}static constructor_(){this._root=null,this._minExtent=1,this._root=new cr}static ensureExtent(e,t){let n=e.getMinX(),i=e.getMaxX(),r=e.getMinY(),o=e.getMaxY();return n!==i&&r!==o?e:(n===i&&(n-=t/2,i+=t/2),r===o&&(r-=t/2,o+=t/2),new E(n,i,r,o))}size(){return null!==this._root?this._root.size():0}insert(e,t){this.collectStats(e);const n=hr.ensureExtent(e,this._minExtent);this._root.insert(n,t)}query(){if(1===arguments.length){const e=arguments[0],t=new Ni;return this.query(e,t),t.getItems()}if(2===arguments.length){const e=arguments[0],t=arguments[1];this._root.visit(e,t)}}queryAll(){const e=new j;return this._root.addAllItems(e),e}remove(e,t){const n=hr.ensureExtent(e,this._minExtent);return this._root.remove(n,t)}collectStats(e){const t=e.getWidth();t0&&(this._minExtent=t);const n=e.getHeight();n0&&(this._minExtent=n)}depth(){return null!==this._root?this._root.depth():0}isEmpty(){return null===this._root||this._root.isEmpty()}get interfaces_(){return[Wt,g]}}class ur extends rt{constructor(){super(),ur.constructor_.apply(this,arguments)}static constructor_(){if(this._parent=null,this._index=null,2===arguments.length){const e=arguments[0],t=arguments[1];ur.constructor_.call(this,e,t,null,-1)}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];rt.constructor_.call(this,e,t),this._parent=n,this._index=i}}getIndex(){return this._index}getParent(){return this._parent}}class dr{constructor(){dr.constructor_.apply(this,arguments)}static constructor_(){if(this._parentLine=null,this._segs=null,this._resultSegs=new j,this._minimumSize=null,1===arguments.length){const e=arguments[0];dr.constructor_.call(this,e,2)}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this._parentLine=e,this._minimumSize=t,this.init()}}static extractCoordinates(e){const t=new Array(e.size()+1).fill(null);let n=null;for(let i=0;i=t[0]&&ithis._distanceTolerance&&(r=!1);const a=new rt;if(a.p0=this._linePts[e],a.p1=this._linePts[t],i[0]=e,i[1]=t,this.hasBadIntersection(this._line,i,a)&&(r=!1),r){const n=this.flatten(e,t);return this._line.addToResult(n),null}this.simplifySection(e,s,n),this.simplifySection(s,t,n)}hasBadOutputIntersection(e){for(let t=this._outputIndex.query(e).iterator();t.hasNext();){const n=t.next();if(this.hasInteriorIntersection(n,e))return!0}return!1}findFurthestPoint(e,t,n,i){const r=new rt;r.p0=e[t],r.p1=e[n];let o=-1,s=t;for(let i=t+1;io&&(o=n,s=i)}return i[0]=o,s}simplify(e){this._line=e,this._linePts=e.getParentCoordinates(),this.simplifySection(0,this._linePts.length-1,0)}remove(e,t,n){for(let i=t;i2*Math.PI)&&(a=2*Math.PI);const l=a/(this._nPts-1),c=new Array(this._nPts).fill(null);let h=0;for(let t=0;t2*Math.PI)&&(a=2*Math.PI);const l=a/(this._nPts-1),c=new Array(this._nPts+2).fill(null);let h=0;c[h++]=this.coord(o,s);for(let t=0;tir.isValid(e),Ir=(e,t)=>Ji.intersects(e,t),wr=(e,t)=>Zi.union(e,t),Er=(e,t)=>Ji.contains(e,t),Ar=(e,t)=>Zn.bufferOp(e,t).norm(),Mr=e=>{if(!e)return null;const t=new Ae,n=new De(t);return new tt(n).write(e)},Nr=e=>{const t=new ot,n=Dr(e);return t.read(n)},Dr=e=>{const t=[e.x,e.y,e.x+e.width,e.y,e.x+e.width,e.y+e.height,e.x,e.y+e.height,e.x,e.y];return`POLYGON((${t[0]} ${t[1]}, ${t[2]} ${t[3]}, ${t[4]} ${t[5]}, ${t[6]} ${t[7]}, ${t[8]} ${t[9]}))`},Rr=(e,t,n,i)=>(new De).createLineString([new I(e,t),new I(n,i)]),Pr=e=>{const t=e.map((e=>new I(e[0],e[1])));return(new De).createPolygon(t)},Lr=(e,t,n,i)=>{const r=new vr,o=r.coord(e,t);return r.setCentre(o),r.setWidth(n),r.setHeight(i),r.createEllipse()},Or=(e,t,n,i)=>Math.sqrt(Math.pow(n-e,2)+Math.pow(i-t,2)),Fr=(e,t,n,i)=>e-1===Fr(e,t,n,i)?[e,t]:[n,i],Br=(e,t,n,i)=>-1!==Fr(e,t,n,i)?[e,t]:[n,i],Gr=(e,t,n,i,r)=>{const o=((e,t,n,i)=>e===n?1/0:(i-t)/(n-e))(t,n,i,r),s=e/2;if(0===o)return[t,n+s,i,n+s,i,n-s,t,n-s];if(o===1/0)return[t-s,n,t-s,r,i+s,r,i+s,n];const a=Math.atan(o),l=s*Math.cos(a),c=s*Math.sin(a);return[t-c,n+l,i-c,r+l,i+c,r-l,t+c,n-l,t+l,n-c]},zr=(e,t=5)=>_r.simplify(e,t),Wr=e=>{const t=[];for(let n=0;n{const t=e.getCoordinates(),n=[];n.push(t[0]);for(let e=0;e{const o=Rr(e,t,n,i);for(const s of r){const r=Rr(s[0],s[1],s[2],s[3]);if(Er(o,r)){const r=kr(e,t,n,i),o=Br(e,t,n,i),a=kr(s[0],s[1],s[2],s[3]),l=Br(s[0],s[1],s[2],s[3]);return[[r[0],r[1],a[0],a[1]],[l[0],l[1],o[0],o[1]]]}}return[[e,t,n,i]]},jr=(e,t)=>e.c.length==t.c.length&&e.c[0]==t.c[0]&&e.c[1]==t.c[1]&&e.c[2]==t.c[2]&&e.c[3]==t.c[3]&&e.door==t.door&&JSON.stringify(e.flags)==JSON.stringify(t.flags),Vr=()=>{const t=canvas.scene.getEmbeddedCollection("Wall"),n=[];for(const i of t){i.getFlag(e,"dungeonVersion")&&n.push(i)}return n},Yr=(e,t,n)=>{let i=[];for(let r=0;r{const i=[],r=t.getExteriorRing().getCoordinates();for(let t=0;t{const n=[];for(const i of t){const t=Qr(e,i[0],i[1],i[2],i[3]);n.push(t)}return n},Xr=(e,t)=>{const n=[];for(const i of t){const t=to(e,i[0],i[1],i[2],i[3]);n.push(t)}return n},Jr=(e,t)=>{const n=[];for(const i of t){const t=$r(e,i[0],i[1],i[2],i[3]);n.push(t)}return n},Zr=(e,t)=>{const n=[];for(const i of t){const t=eo(e,i[0],i[1],i[2],i[3]);n.push(t)}return n},Qr=(n,i,r,o,s)=>{const a={c:[i,r,o,s],door:0,flags:{}};return a.flags[e]={},a.flags[e].dungeonVersion="1.0",t.threeDCanvasEnabled()&&(a.flags["levels-3d-preview"]={joinWall:!0,wallDepth:n.wallThickness,wallSidesTexture:n.threeDWallSidesTexture,wallSidesTint:n.threeDWallSidesTextureTint,wallTexture:n.threeDWallTexture,wallTint:n.threeDWallTextureTint}),a},$r=(e,n,i,r,o)=>{const s=Qr(e,n,i,r,o);return s.door=1,t.threeDCanvasEnabled()&&(s.flags["levels-3d-preview"].joinWall=!1,s.flags["levels-3d-preview"].wallTexture=e.threeDDoorTexture,s.flags["levels-3d-preview"].wallTint=e.threeDDoorTextureTint),s},eo=(e,t,n,i,r)=>{const o=Qr(e,t,n,i,r);return o.door=2,o},to=(e,t,n,i,r)=>{const o=Qr(e,t,n,i,r);return o.door=0,o.light=0,o.sight=0,o};class no{static FLAG_KEY="dungeonState";constructor(e,t,n,i,r,o,s){this.geometry=e,this.themeAreas=t,this.doors=n,this.secretDoors=i,this.interiorWalls=r,this.invisibleWalls=o,this.config=s}static startState(){return new no(null,[],[],[],[],[],{doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8})}clone(){return new no(this.geometry?this.geometry.copy():null,JSON.parse(JSON.stringify(this.themeAreas)),JSON.parse(JSON.stringify(this.doors)),this.secretDoors?[...this.secretDoors]:[],this.interiorWalls?[...this.interiorWalls]:[],this.invisibleWalls?[...this.invisibleWalls]:[],JSON.parse(JSON.stringify(this.config)))}toString(){return JSON.stringify({wkt:Mr(this.geometry),themeAreas:this.themeAreas,doors:this.doors,secretDoors:this.secretDoors,interiorWalls:this.interiorWalls,invisibleWalls:this.invisibleWalls,config:this.config})}static fromString(e){if(!e)return no.startState();const t=JSON.parse(e),n=(i=t.wkt)?(new ot).read(i):null;var i;const r=t.themeAreas?t.themeAreas:[],o=t.doors?t.doors:[],s=t.secretDoors?t.secretDoors:[],a=t.interiorWalls?t.interiorWalls:[],l=t.invisibleWalls?t.invisibleWalls:[],c=foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},t.config);return new no(n,r,o,s,a,l,c)}async saveToJournalEntry(t){const n=this.toString();await(async e=>{if(!game.user.isGM)return;let t=[];if(e.geometry){const n=zr(e.geometry,10),i=e.doors.concat(e.secretDoors,e.invisibleWalls);t=Yr(e.config,n,i)}const n=Kr(e.config,e.interiorWalls),i=Xr(e.config,e.invisibleWalls),r=Jr(e.config,e.doors),o=Zr(e.config,e.secretDoors),s=t.concat(n,i,r,o),a=Vr(),l=[],c=[];for(const e of s){let t=!1;for(const n of a)if(jr(e,n)){l.push(n),t=!0;break}t||c.push(e)}const h=l.map((e=>e.id)),u=a.filter((e=>!h.includes(e.id))).map((e=>e.id));if(c.length&&await canvas.scene.createEmbeddedDocuments("Wall",c),u.length)try{await canvas.scene.deleteEmbeddedDocuments("Wall",u)}catch(e){console.error(e)}})(this),await t.setFlag(e,"dungeonState",n)}static async loadFromJournalEntry(t){await this.maybeMigrateJournalEntry(t);const n=t.getFlag(e,"dungeonState");return no.fromString(n)}static async maybeMigrateJournalEntry(e){if(game.user.isGM)if(e.pages){const t=e.pages.find((e=>"text"===e.type));if(t?.text?.content){console.log("Migrating v10 page.text.content");const n=no.fromString(t.text.content);await n.saveToJournalEntry(e),await t.delete()}}else if(e.data.content){console.log("Migrating v9 journalEntry.data.content");const t=no.fromString(e.data.content);await t.saveToJournalEntry(e),await e.update({content:null})}}}
+const e="dungeon-draw";class t{static register(){game.settings.register(e,"allowTrustedPlayer",{name:game.i18n.localize("DD.SettingAllowTrustedPlayers"),scope:"world",default:!0,type:Boolean,config:!0}),game.settings.register(e,"3DCanvasEnabled",{name:game.i18n.localize("DD.SettingSupport3DCanvas"),scope:"world",default:!0,type:Boolean,config:!0}),game.settings.register(e,"snapToGrid",{name:game.i18n.localize("DD.SettingSnapToGrid"),scope:"client",default:!0,type:Boolean,config:!0,onChange:e=>{canvas.dungeon.options.snapToGrid=e}}),game.settings.register(e,"releaseNotesVersion",{name:"Last version we showed release notes.",scope:"client",default:"",type:String,config:!1}),game.settings.register(e,"customThemes",{name:"Custom themes data.",scope:"client",default:"{}",type:String,config:!1}),game.settings.register(e,"themePainterTheme",{name:"Theme painter theme key.",scope:"client",default:"module.cavern",type:String,config:!1})}static threeDCanvasEnabled(){return game.settings.get(e,"3DCanvasEnabled")}static snapToGrid(){return game.settings.get(e,"snapToGrid")}}const n=()=>{try{const t=game.settings.get(e,"customThemes"),n=JSON.parse(t);return Object.keys(n).forEach((e=>{n[e].config=foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},n[e].config)})),n}catch(e){return console.log(e),{}}},i=t=>{const n=JSON.stringify(t);game.settings.set(e,"customThemes",n)},r=()=>game.settings.get(e,"themePainterTheme"),o=t=>game.settings.set(e,"themePainterTheme",t),s={default:{name:"Default",config:{doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8}},arcPavement:{name:"Arc Pavement",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#111111",floorTexture:"modules/dungeon-draw/assets/textures/Arc_Pavement_001_basecolor.jpg",invisibleWallThickness:10,wallColor:"#111111",wallThickness:12})},basicBlack:{name:"Basic Black",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#0D0D0D",doorFillOpacity:0,exteriorShadowOpacity:0,interiorShadowOpacity:0,invisibleWallColor:"#0D0D0D",floorColor:"#FFFFFF",sceneBackgroundColor:"#0D0D0D",sceneGridOpacity:1,secretDoorSColor:"#0D0D0D",wallColor:"#0D0D0D"})},cavern:{name:"Cavern",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#2B2D2F",invisibleWallThickness:10,floorTexture:"modules/dungeon-draw/assets/textures/Stylized_Stone_Floor_002_bw.jpg",wallColor:"#2B2D2F",wallThickness:12})},checkerboard:{name:"Checkerboard",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorFillColor:"#C2BFB0",floorTexture:"modules/dungeon-draw/assets/textures/sci_fi_texture_150_by_llexandro_d939vk9.png",invisibleWallFillColor:"#C2BFB0",invisibleWallThickness:8,secretDoorSColor:"#C2BFB0",wallThickness:10})},cobblestone:{name:"Cobblestone",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#222222",doorFillColor:"#FFFFFF",floorTexture:"modules/dungeon-draw/assets/textures/Cobblestone_001_COLOR.jpg",invisibleWallColor:"#222222",invisibleWallFillColor:"#FFFFFF",invisibleWallThickness:10,secretDoorSColor:"#FFFFFF",wallColor:"#222222",wallThickness:12})},dirt:{name:"Dirt",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#1a1714",doorFillColor:"#8d7862",floorTexture:"modules/dungeon-draw/assets/textures/Ground_Dirt_007_basecolor.jpg",invisibleWallColor:"#1a1714",invisibleWallFillColor:"#8d7862",invisibleWallThickness:8,secretDoorSColor:"#8d7862",wallColor:"#1a1714",wallThickness:10})},dungeonSquares:{name:"Dungeon Squares",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#111111",floorTexture:"modules/dungeon-draw/assets/textures/outdoor+stone+tiles+pavement.jpg",invisibleWallColor:"#111111",invisibleWallThickness:10,wallColor:"#111111",wallThickness:12})},grass:{name:"Grass",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#72471d",doorFillColor:"#eee8c1",floorTexture:"modules/dungeon-draw/assets/textures/Grass_001_COLOR.jpg",invisibleWallColor:"#72471d",invisibleWallFillColor:"#eee8c1",invisibleWallThickness:10,secretDoorSColor:"#eee8c1",wallColor:"#72471d",wallThickness:10})},groovyCarpet:{name:"Groovy Carpet",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#2B2D2F",floorTexture:"modules/dungeon-draw/assets/textures/Fabric_Rug_006_basecolor.jpg",invisibleWallColor:"#2B2D2F",invisibleWallThickness:10,wallColor:"#2B2D2F",wallThickness:12})},hexagon:{name:"Hexagons",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#282828",doorFillColor:"#D1BD8A",floorTexture:"modules/dungeon-draw/assets/textures/Rocks_Hexagons_002_basecolor.jpg",invisibleWallColor:"#282828",invisibleWallFillColor:"#D1BD8A",invisibleWallThickness:10,secretDoorSColor:"#D1BD8A",wallColor:"#282828",wallThickness:12})},marble:{name:"Marble",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#686882",floorTexture:"modules/dungeon-draw/assets/textures/Marble_Tiles_001_basecolor.jpg",invisibleWallColor:"#686882",wallColor:"#686882"})},metalGrid:{name:"Metal Grid",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#27251A",doorFillColor:"#AAAAAA",floorTexture:"modules/dungeon-draw/assets/textures/Sci-fi_Floor_002_basecolor.jpg",invisibleWallColor:"#27251A",invisibleWallFillColor:"#AAAAAA",secretDoorSColor:"#AAAAAA",wallColor:"#27251A"})},metalSquares:{name:"Metal Squares",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorFillColor:"#C0C0C0",floorTexture:"modules/dungeon-draw/assets/textures/sci_fi_texture_212_by_llexandro_dcuxgum.png",invisibleWallFillColor:"#C0C0C0",secretDoorSColor:"#C0C0C0"})},moldvayBlue:{name:"Moldvay Blue",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#3A9FF2",doorFillOpacity:0,doorThickness:35,exteriorShadowOpacity:0,floorColor:"#FFFFFF",interiorShadowOpacity:0,invisibleWallColor:"#3A9FF2",invisibleWallFillOpacity:0,sceneBackgroundColor:"#3A9FF2",sceneGridColor:"#3A9FF2",sceneGridOpacity:1,secretDoorSColor:"#3A9FF2",wallColor:"#3A9FF2"})},neonBlueprint:{name:"Neon Blueprint",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#3A9FF2",doorFillOpacity:0,doorThickness:35,exteriorShadowColor:"#18495E",floorColor:"#142A3B",interiorShadowColor:"#1B7FAB",invisibleWallColor:"#3A9FF2",invisibleWallFillOpacity:0,invisibleWallLineThickness:1,invisibleWallThickness:6,sceneBackgroundColor:"#171008",sceneGridColor:"#4C89A1",sceneGridOpacity:1,secretDoorSColor:"#3A9FF2",wallColor:"#63C9E6",wallThickness:4})},ruddyPaper:{name:"Ruddy Paper",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#913B55",doorFillColor:"#FADEE6",floorTexture:"modules/dungeon-draw/assets/textures/Paper_Recycled_001_COLOR.jpg",floorTextureTint:"#F9FAE6",exteriorShadowOpacity:0,interiorShadowOpacity:0,invisibleWallColor:"#913B55",invisibleWallFillColor:"#FADEE6",sceneBackgroundColor:"#EBD3BC",sceneGridColor:"#594026",sceneGridOpacity:1,secretDoorSColor:"#913B55",wallColor:"#9A6D54"})},water:{name:"Water",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#203246",floorTexture:"modules/dungeon-draw/assets/textures/Water_001_COLOR.jpg",invisibleWallColor:"#203246",invisibleWallLineThickness:1,invisibleWallThickness:4,wallColor:"#203246",wallThickness:5})},woodPlanks:{name:"Wood Planks",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#332211",floorTexture:"modules/dungeon-draw/assets/textures/Old_Wooden_Plank_Seamless_Texture_765.jpg",invisibleWallColor:"#332211",invisibleWallThickness:13,wallColor:"#332211",wallTexture:"modules/dungeon-draw/assets/textures/Bark_002_bw.jpg",wallTextureTint:"#7e5935",wallThickness:15})},xenomorph:{name:"Xenomorph",config:foundry.utils.mergeObject({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8},{doorColor:"#8AF0F0",doorFillColor:"#255151",doorLineThickness:5,doorThickness:20,exteriorShadowColor:"#00838C",floorColor:"#255151",interiorShadowColor:"#00838C",invisibleWallColor:"#8AF0F0",invisibleWallFillColor:"#255151",invisibleWallLineThickness:1,invisibleWallThickness:6,sceneBackgroundColor:"#002222",sceneGridColor:"#ffffff",sceneGridOpacity:1,secretDoorSColor:"#8AF0F0",wallColor:"#8AF0F0",wallThickness:4})}};class a extends FormApplication{constructor(e){super(),this.themeKey=e}static get defaultOptions(){return foundry.utils.mergeObject(super.defaultOptions,{id:"dd-theme-sheet",classes:["sheet"],template:"modules/dungeon-draw/templates/theme-sheet.html",width:480,height:t.threeDCanvasEnabled()?1160:1040,tabs:[{navSelector:".tabs",contentSelector:"form",initial:"position"}]})}get title(){return game.i18n.localize("DD.ThemeSheetTitle")}getData(){const e=n()[this.themeKey],i=t.threeDCanvasEnabled();return{config:e.config,themeName:e.name,threeDCanvasEnabled:i}}async _updateObject(e,t){const r=n(),o=t.themeName;delete t.themeName,r[this.themeKey]={name:o,config:t},i(r),await(canvas.dungeon.dungeon?.refresh())}}class l extends FormApplication{constructor(e="settings"){super(),this._tabs[0].active=e}static get defaultOptions(){return foundry.utils.mergeObject(super.defaultOptions,{id:"dd-config-sheet",classes:["sheet"],template:"modules/dungeon-draw/templates/config-sheet.html",width:480,height:t.threeDCanvasEnabled()?1220:1100,tabs:[{navSelector:".tabs",contentSelector:"form",initial:"position"}]})}get title(){return game.i18n.localize("DD.ConfigSheetTitle")}getData(){let e=canvas.dungeon.dungeon?.state().config;e||(e={doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8});const i=n(),o=Object.keys(i).sort(),a=Object.keys(s).sort(),l=r(),c=t.threeDCanvasEnabled();return{config:e,customThemes:i,customThemeKeys:o,themes:s,themeKeys:a,themePainterThemeKey:l,threeDCanvasEnabled:c}}async _updateObject(e,t){delete t.customThemeName,delete t.themePainterTheme,canvas.dungeon.dungeon?.setConfig(t),game.user.isGM&&await canvas.scene.update({backgroundColor:t.sceneBackgroundColor,gridAlpha:t.sceneGridAlpha,gridColor:t.sceneGridColor})}async close(e){await super.close(e),this.preview&&(this.preview.removeChildren(),this.preview=null)}activateListeners(e){super.activateListeners(e),e.find('button[name="resetDefault"]').click(this._onResetDefaults.bind(this)),e.find(".dd-theme-name").click(this._onThemeNameClick.bind(this)),e.find(".dd-save-as-theme-button").click(this._onSaveAsThemeClick.bind(this)),e.find(".dd-theme-edit").click(this._onEditThemeClick.bind(this)),e.find(".dd-theme-copy").click(this._onCopyThemeClick.bind(this)),e.find(".dd-theme-delete").click(this._onDeleteThemeClick.bind(this)),e.find('select[name="themePainterThemeKey"]').change(this._onThemePainterThemeSelect.bind(this)),e.find(".dd-export-themes-button").click(this._onExportThemesClick.bind(this)),e.find(".dd-import-themes-button").click(this._onImportThemesClick.bind(this))}_onResetDefaults(e){e.preventDefault(),canvas.dungeon.dungeon?.setConfig({doorColor:"#000000",doorFillColor:"#ffffff",doorFillOpacity:1,doorLineThickness:8,doorThickness:25,exteriorShadowColor:"#000000",exteriorShadowThickness:20,exteriorShadowOpacity:.5,floorColor:"#F2EDDF",floorOpacity:1,floorTexture:"",floorTextureRotation:0,floorTextureTint:"",interiorShadowColor:"#000000",interiorShadowThickness:8,interiorShadowOpacity:.5,invisibleWallColor:"#000000",invisibleWallFillColor:"#ffffff",invisibleWallLineThickness:2,invisibleWallFillOpacity:1,invisibleWallThickness:6,matchBaseWalls:!0,sceneBackgroundColor:"#999999",sceneGridColor:"#000000",sceneGridOpacity:.2,secretDoorSColor:"#ffffff",secretDoorStyleGM:"secret",secretDoorStylePlayer:"wall",threeDDoorTexture:"modules/dungeon-draw/assets/textures/3d_arena-gate-texture.webp",threeDDoorTextureTint:"",threeDWallTexture:"",threeDWallTextureTint:"",threeDWallSidesTexture:"",threeDWallSidesTextureTint:"",wallColor:"#000000",wallTexture:"",wallTextureTint:"",wallThickness:8}),canvas.dungeon.dungeon.refresh(),this.render()}async _onThemeNameClick(e){e.preventDefault();const t=$(e.currentTarget).parent(".dd-theme-row"),i=t.data("theme");let r;if("custom"===t.data("themetype")){r=n()[i]}else r=s[i];const o={...r.config};await(canvas.dungeon.dungeon?.setConfig(o)),game.user.isGM&&await canvas.scene.update({backgroundColor:o.sceneBackgroundColor,gridAlpha:o.sceneGridAlpha,gridColor:o.sceneGridColor}),this.render()}async _onSaveAsThemeClick(e){e.preventDefault();const t=$(e.currentTarget).closest(".form-fields").children(".saveAsThemeName").val(),r=this._getSubmitData();delete r.saveAsThemeName,delete r.themePainterThemeKey;const o=n();o[t]={name:t,config:r},i(o),this._tabs[0].active="themes",this.render()}async _onEditThemeClick(e){e.preventDefault();const t=$(e.currentTarget).closest(".dd-theme-row").data("theme");new a(t).render(!0)}_onCopyThemeClick(e){e.preventDefault();const t=$(e.currentTarget).closest(".dd-theme-row").data("theme"),r=n(),o=r[t],s=JSON.parse(JSON.stringify(o));let a,l=1,c=!1;for(;!c;)a=`${o.name} (${l})`,a in r?l++:c=!0;s.name=a,r[a]=s,i(r),this.render()}_onDeleteThemeClick(e){e.preventDefault();const t=$(e.currentTarget).closest(".dd-theme-row").data("theme"),r=n();delete r[t],i(r),this.render()}_onExportThemesClick(e){e.preventDefault();const t=JSON.stringify(n(),null,2);saveDataToFile(t,"application/json","dd-custom-themes.json")}async _onImportThemesClick(e){e.preventDefault(),new Dialog({title:game.i18n.localize("DD.ImportCustomThemes"),content:await renderTemplate("modules/dungeon-draw/templates/import-data.html",{hint:game.i18n.localize("DD.ImportCustomThemesHint")}),buttons:{import:{icon:'',label:game.i18n.localize("DD.Import"),callback:e=>{const t=e.find("form")[0];if(!t.data.files.length)return ui.notifications.error("You did not upload a data file!");readTextFromFile(t.data.files[0]).then((e=>{const r=JSON.parse(e);if(t.wipe.checked)i(r);else{const e=n(),t=foundry.utils.mergeObject(e,r);i(t)}this.render()}))}},no:{icon:'',label:game.i18n.localize("DD.Cancel")}},default:"import"},{width:400}).render(!0)}_onThemePainterThemeSelect(e){const t=$(e.currentTarget).val();o(t)}}class c extends Error{constructor(e){super(e),this.name=Object.keys({Exception:c})[0]}toString(){return this.message}}class h extends c{constructor(e){super(e),this.name=Object.keys({IllegalArgumentException:h})[0]}}class u{filter(e){}}function d(){}function m(){}function g(){}class f{static equalsWithTolerance(e,t,n){return Math.abs(e-t)<=n}}class p{constructor(e,t){this.low=t||0,this.high=e||0}static toBinaryString(e){let t,n="";for(t=2147483648;t>0;t>>>=1)n+=(e.high&t)===t?"1":"0";for(t=2147483648;t>0;t>>>=1)n+=(e.low&t)===t?"1":"0";return n}}function _(){}function y(){}_.NaN=NaN,_.isNaN=e=>Number.isNaN(e),_.isInfinite=e=>!Number.isFinite(e),_.MAX_VALUE=Number.MAX_VALUE,_.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,_.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,"function"==typeof Float64Array&&"function"==typeof Int32Array?function(){const e=2146435072,t=new Float64Array(1),n=new Int32Array(t.buffer);_.doubleToLongBits=function(i){t[0]=i;let r=0|n[0],o=0|n[1];return(o&e)===e&&0!=(1048575&o)&&0!==r&&(r=0,o=2146959360),new p(o,r)},_.longBitsToDouble=function(e){return n[0]=e.low,n[1]=e.high,t[0]}}():function(){const e=1023,t=Math.log2,n=Math.floor,i=Math.pow,r=function(){for(let e=53;e>0;e--){const r=i(2,e)-1;if(n(t(r))+1===e)return r}return 0}();_.doubleToLongBits=function(o){let s,a,l,c,h,u,d,m,g;if(o<0||1/o===Number.NEGATIVE_INFINITY?(u=1<<31,o=-o):u=0,0===o)return g=0,m=u,new p(m,g);if(o===1/0)return g=0,m=2146435072|u,new p(m,g);if(o!=o)return g=0,m=2146959360,new p(m,g);if(c=0,g=0,s=n(o),s>1)if(s<=r)c=n(t(s)),c<=20?(g=0,m=s<<20-c&1048575):(l=c-20,a=i(2,l),g=s%a<<32-l,m=s/a&1048575);else for(l=s,g=0;a=l/2,l=n(a),0!==l;)c++,g>>>=1,g|=(1&m)<<31,m>>>=1,a!==l&&(m|=524288);if(d=c+e,h=0===s,s=o-s,c<52&&0!==s)for(l=0;;){if(a=2*s,a>=1?(s=a-1,h?(d--,h=!1):(l<<=1,l|=1,c++)):(s=a,h?0==--d&&(c++,h=!1):(l<<=1,c++)),20===c)m|=l,l=0;else if(52===c){g|=l;break}if(1===a){c<20?m|=l<<20-c:c<52&&(g|=l<<52-c);break}}return m|=d<<20,m|=u,new p(m,g)},_.longBitsToDouble=function(t){let n,r,o,s;const a=t.high,l=t.low,c=a&1<<31?-1:1;for(o=((2146435072&a)>>20)-e,s=0,r=1<<19,n=1;n<=20;n++)a&r&&(s+=i(2,-n)),r>>>=1;for(r=1<<31,n=21;n<=52;n++)l&r&&(s+=i(2,-n)),r>>>=1;if(-1023===o){if(0===s)return 0*c;o=-1022}else{if(1024===o)return 0===s?c/0:NaN;s+=1}return c*s*i(2,o)}}();class b extends c{constructor(e){super(e),this.name=Object.keys({RuntimeException:b})[0]}}class C extends b{constructor(){super(),C.constructor_.apply(this,arguments)}static constructor_(){if(0===arguments.length)b.constructor_.call(this);else if(1===arguments.length){const e=arguments[0];b.constructor_.call(this,e)}}}class x{static shouldNeverReachHere(){if(0===arguments.length)x.shouldNeverReachHere(null);else if(1===arguments.length){const e=arguments[0];throw new C("Should never reach here"+(null!==e?": "+e:""))}}static isTrue(){if(1===arguments.length){const e=arguments[0];x.isTrue(e,null)}else if(2===arguments.length){const e=arguments[1];if(!arguments[0])throw null===e?new C:new C(e)}}static equals(){if(2===arguments.length){const e=arguments[0],t=arguments[1];x.equals(e,t,null)}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];if(!t.equals(e))throw new C("Expected "+e+" but encountered "+t+(null!==n?": "+n:""))}}}const v=new ArrayBuffer(8),S=new Float64Array(v),T=new Int32Array(v);class I{constructor(){I.constructor_.apply(this,arguments)}static constructor_(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)I.constructor_.call(this,0,0);else if(1===arguments.length){const e=arguments[0];I.constructor_.call(this,e.x,e.y,e.getZ())}else if(2===arguments.length){const e=arguments[0],t=arguments[1];I.constructor_.call(this,e,t,I.NULL_ORDINATE)}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];this.x=e,this.y=t,this.z=n}}static hashCode(e){return S[0]=e,T[0]^T[1]}getM(){return _.NaN}setOrdinate(e,t){switch(e){case I.X:this.x=t;break;case I.Y:this.y=t;break;case I.Z:this.setZ(t);break;default:throw new h("Invalid ordinate index: "+e)}}equals2D(){if(1===arguments.length){const e=arguments[0];return this.x===e.x&&this.y===e.y}if(2===arguments.length){const e=arguments[0],t=arguments[1];return!!f.equalsWithTolerance(this.x,e.x,t)&&!!f.equalsWithTolerance(this.y,e.y,t)}}setM(e){throw new h("Invalid ordinate index: "+I.M)}getZ(){return this.z}getOrdinate(e){switch(e){case I.X:return this.x;case I.Y:return this.y;case I.Z:return this.getZ()}throw new h("Invalid ordinate index: "+e)}equals3D(e){return this.x===e.x&&this.y===e.y&&(this.getZ()===e.getZ()||_.isNaN(this.getZ())&&_.isNaN(e.getZ()))}equals(e){return e instanceof I&&this.equals2D(e)}equalInZ(e,t){return f.equalsWithTolerance(this.getZ(),e.getZ(),t)}setX(e){this.x=e}compareTo(e){const t=e;return this.xt.x?1:this.yt.y?1:0}getX(){return this.x}setZ(e){this.z=e}clone(){try{return null}catch(e){if(e instanceof CloneNotSupportedException)return x.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw e}}copy(){return new I(this)}toString(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}distance3D(e){const t=this.x-e.x,n=this.y-e.y,i=this.getZ()-e.getZ();return Math.sqrt(t*t+n*n+i*i)}getY(){return this.y}setY(e){this.y=e}distance(e){const t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}hashCode(){let e=17;return e=37*e+I.hashCode(this.x),e=37*e+I.hashCode(this.y),e}setCoordinate(e){this.x=e.x,this.y=e.y,this.z=e.getZ()}get interfaces_(){return[d,m,g]}}class w{constructor(){w.constructor_.apply(this,arguments)}static constructor_(){if(this._dimensionsToTest=2,0===arguments.length)w.constructor_.call(this,2);else if(1===arguments.length){const e=arguments[0];if(2!==e&&3!==e)throw new h("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e}}static compare(e,t){return et?1:_.isNaN(e)?_.isNaN(t)?0:-1:_.isNaN(t)?1:0}compare(e,t){const n=w.compare(e.x,t.x);if(0!==n)return n;const i=w.compare(e.y,t.y);if(0!==i)return i;if(this._dimensionsToTest<=2)return 0;return w.compare(e.getZ(),t.getZ())}get interfaces_(){return[y]}}I.DimensionalComparator=w,I.NULL_ORDINATE=_.NaN,I.X=0,I.Y=1,I.Z=2,I.M=3;class E{constructor(){E.constructor_.apply(this,arguments)}static constructor_(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof I){const e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else if(arguments[0]instanceof E){const e=arguments[0];this.init(e)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.init(e.x,t.x,e.y,t.y)}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];this.init(e,t,n,i)}}static intersects(){if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];return n.x>=(e.xt.x?e.x:t.x)&&n.y>=(e.yt.y?e.y:t.y)}if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];let r=Math.min(n.x,i.x),o=Math.max(n.x,i.x),s=Math.min(e.x,t.x),a=Math.max(e.x,t.x);return!(s>o)&&(!(ao)&&!(ae._minx?this._minx:e._minx,n=this._miny>e._miny?this._miny:e._miny,i=this._maxx=this._minx&&e.getMaxX()<=this._maxx&&e.getMinY()>=this._miny&&e.getMaxY()<=this._maxy)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];return!this.isNull()&&(e>=this._minx&&e<=this._maxx&&t>=this._miny&&t<=this._maxy)}}intersects(){if(1===arguments.length){if(arguments[0]instanceof E){const e=arguments[0];return!this.isNull()&&!e.isNull()&&!(e._minx>this._maxx||e._maxxthis._maxy||e._maxythis._maxx)return!1;if((e.x>t.x?e.x:t.x)this._maxy)return!1;return!((e.y>t.y?e.y:t.y)this._maxx||ethis._maxy||tthis._maxx&&(this._maxx=e._maxx),e._minythis._maxy&&(this._maxy=e._maxy))}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.isNull()?(this._minx=e,this._maxx=e,this._miny=t,this._maxy=t):(ethis._maxx&&(this._maxx=e),tthis._maxy&&(this._maxy=t))}}minExtent(){if(this.isNull())return 0;const e=this.getWidth(),t=this.getHeight();return et._minx?1:this._minyt._miny?1:this._maxxt._maxx?1:this._maxyt._maxy?1:0}translate(e,t){if(this.isNull())return null;this.init(this.getMinX()+e,this.getMaxX()+e,this.getMinY()+t,this.getMaxY()+t)}copy(){return new E(this)}toString(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"}setToNull(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1}disjoint(e){return!(!this.isNull()&&!e.isNull())||(e._minx>this._maxx||e._maxxthis._maxy||e._maxyt?e:t}expandBy(){if(1===arguments.length){const e=arguments[0];this.expandBy(e,e)}else if(2===arguments.length){const e=arguments[0],t=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=t,this._maxy+=t,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}contains(){if(1===arguments.length){if(arguments[0]instanceof E){const e=arguments[0];return this.covers(e)}if(arguments[0]instanceof I){const e=arguments[0];return this.covers(e)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];return this.covers(e,t)}}centre(){return this.isNull()?null:new I((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}init(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof I){const e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else if(arguments[0]instanceof E){const e=arguments[0];this._minx=e._minx,this._maxx=e._maxx,this._miny=e._miny,this._maxy=e._maxy}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.init(e.x,t.x,e.y,t.y)}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];ee._maxx&&(t=this._minx-e._maxx);let n=0;return this._maxye._maxy&&(n=this._miny-e._maxy),0===t?n:0===n?t:Math.sqrt(t*t+n*n)}hashCode(){let e=17;return e=37*e+I.hashCode(this._minx),e=37*e+I.hashCode(this._maxx),e=37*e+I.hashCode(this._miny),e=37*e+I.hashCode(this._maxy),e}get interfaces_(){return[d,g]}}class A{constructor(){A.constructor_.apply(this,arguments)}isGeometryCollection(){return this.getTypeCode()===A.TYPECODE_GEOMETRYCOLLECTION}getFactory(){return this._factory}getGeometryN(e){return this}getArea(){return 0}isRectangle(){return!1}equalsExact(e){return this===e||this.equalsExact(e,0)}geometryChanged(){this.apply(A.geometryChangedFilter)}geometryChangedAction(){this._envelope=null}equalsNorm(e){return null!==e&&this.norm().equalsExact(e.norm())}getLength(){return 0}getNumGeometries(){return 1}compareTo(){let e;if(1===arguments.length){const t=arguments[0];return e=t,this.getTypeCode()!==e.getTypeCode()?this.getTypeCode()-e.getTypeCode():this.isEmpty()&&e.isEmpty()?0:this.isEmpty()?-1:e.isEmpty()?1:this.compareToSameClass(t)}if(2===arguments.length){const t=arguments[0],n=arguments[1];return e=t,this.getTypeCode()!==e.getTypeCode()?this.getTypeCode()-e.getTypeCode():this.isEmpty()&&e.isEmpty()?0:this.isEmpty()?-1:e.isEmpty()?1:this.compareToSameClass(t,n)}}getUserData(){return this._userData}getSRID(){return this._SRID}getEnvelope(){return this.getFactory().toGeometry(this.getEnvelopeInternal())}checkNotGeometryCollection(e){if(e.getTypeCode()===A.TYPECODE_GEOMETRYCOLLECTION)throw new h("This method does not support GeometryCollection arguments")}equal(e,t,n){return 0===n?e.equals(t):e.distance(t)<=n}norm(){const e=this.copy();return e.normalize(),e}reverse(){const e=this.reverseInternal();return null!=this.envelope&&(e.envelope=this.envelope.copy()),e.setSRID(this.getSRID()),e}copy(){const e=this.copyInternal();return e.envelope=null==this._envelope?null:this._envelope.copy(),e._SRID=this._SRID,e._userData=this._userData,e}getPrecisionModel(){return this._factory.getPrecisionModel()}getEnvelopeInternal(){return null===this._envelope&&(this._envelope=this.computeEnvelopeInternal()),new E(this._envelope)}setSRID(e){this._SRID=e}setUserData(e){this._userData=e}compare(e,t){const n=e.iterator(),i=t.iterator();for(;n.hasNext()&&i.hasNext();){const e=n.next(),t=i.next(),r=e.compareTo(t);if(0!==r)return r}return n.hasNext()?1:i.hasNext()?-1:0}hashCode(){return this.getEnvelopeInternal().hashCode()}isEquivalentClass(e){return this.getClass()===e.getClass()}isGeometryCollectionOrDerived(){return this.getTypeCode()===A.TYPECODE_GEOMETRYCOLLECTION||this.getTypeCode()===A.TYPECODE_MULTIPOINT||this.getTypeCode()===A.TYPECODE_MULTILINESTRING||this.getTypeCode()===A.TYPECODE_MULTIPOLYGON}get interfaces_(){return[m,d,g]}getClass(){return A}static hasNonEmptyElements(e){for(let t=0;t-1}class D{}class R{getM(e){if(this.hasM()){const t=this.getDimension()-this.getMeasures();return this.getOrdinate(e,t)}return _.NaN}setOrdinate(e,t,n){}getZ(e){return this.hasZ()?this.getOrdinate(e,2):_.NaN}size(){}getOrdinate(e,t){}getCoordinate(){}getCoordinateCopy(e){}createCoordinate(){}getDimension(){}hasM(){return this.getMeasures()>0}getX(e){}hasZ(){return this.getDimension()-this.getMeasures()>2}getMeasures(){return 0}expandEnvelope(e){}copy(){}getY(e){}toCoordinateArray(){}get interfaces_(){return[m]}}R.X=0,R.Y=1,R.Z=2,R.M=3;class P{static copyCoord(e,t,n,i){const r=Math.min(e.getDimension(),n.getDimension());for(let o=0;o0)&&(i=t,n=r)}return n}}static extend(e,t,n){const i=e.create(n,t.getDimension()),r=t.size();if(P.copy(t,0,i,0,r),r>0)for(let e=r;e0)&&(t=i)}return t}}class L extends c{constructor(e){super(e),this.name=Object.keys({UnsupportedOperationException:L})[0]}}class O{static isWhitespace(e){return e<=32&&e>=0||127===e}static toUpperCase(e){return e.toUpperCase()}}class F{static toDimensionSymbol(e){switch(e){case F.FALSE:return F.SYM_FALSE;case F.TRUE:return F.SYM_TRUE;case F.DONTCARE:return F.SYM_DONTCARE;case F.P:return F.SYM_P;case F.L:return F.SYM_L;case F.A:return F.SYM_A}throw new h("Unknown dimension value: "+e)}static toDimensionValue(e){switch(O.toUpperCase(e)){case F.SYM_FALSE:return F.FALSE;case F.SYM_TRUE:return F.TRUE;case F.SYM_DONTCARE:return F.DONTCARE;case F.SYM_P:return F.P;case F.SYM_L:return F.L;case F.SYM_A:return F.A}throw new h("Unknown dimension symbol: "+e)}}F.P=0,F.L=1,F.A=2,F.FALSE=-1,F.TRUE=-2,F.DONTCARE=-3,F.SYM_FALSE="F",F.SYM_TRUE="T",F.SYM_DONTCARE="*",F.SYM_P="0",F.SYM_L="1",F.SYM_A="2";class k{filter(e){}}class B{filter(e,t){}isDone(){}isGeometryChanged(){}}class G extends A{constructor(){super(),G.constructor_.apply(this,arguments)}static constructor_(){if(this._points=null,0===arguments.length);else if(2===arguments.length){const e=arguments[0],t=arguments[1];A.constructor_.call(this,t),this.init(e)}}computeEnvelopeInternal(){return this.isEmpty()?new E:this._points.expandEnvelope(new E)}isRing(){return this.isClosed()&&this.isSimple()}getCoordinates(){return this._points.toCoordinateArray()}copyInternal(){return new G(this._points.copy(),this._factory)}equalsExact(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof A){const e=arguments[0],t=arguments[1];if(!this.isEquivalentClass(e))return!1;const n=e;if(this._points.size()!==n._points.size())return!1;for(let e=0;e0){const e=this._points.copy();P.reverse(e),this._points=e}return null}}}getCoordinate(){return this.isEmpty()?null:this._points.getCoordinate(0)}getBoundaryDimension(){return this.isClosed()?F.FALSE:0}isClosed(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}reverseInternal(){const e=this._points.copy();return P.reverse(e),this.getFactory().createLineString(e)}getEndPoint(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}getTypeCode(){return A.TYPECODE_LINESTRING}getDimension(){return 1}getLength(){return class{static ofLine(e){const t=e.size();if(t<=1)return 0;let n=0;const i=new I;e.getCoordinate(0,i);let r=i.x,o=i.y;for(let s=1;s= 2)");this._points=e}isCoordinate(e){for(let t=0;t=this.size())throw new W;return this.array[e]}isEmpty(){return 0===this.array.length}sort(e){e?this.array.sort(((t,n)=>e.compare(t,n))):this.array.sort()}size(){return this.array.length}toArray(){return this.array.slice()}remove(e){for(let t=0,n=this.array.length;t=1){if(this.get(this.size()-1).equals2D(e))return null}super.add.call(this,e)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){const e=arguments[0],t=arguments[1];return this.add(e,t),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){const e=arguments[0],t=arguments[1];if(arguments[2])for(let n=0;n=0;n--)this.add(e[n],t);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof I){const e=arguments[0],t=arguments[1];if(!arguments[2]){const n=this.size();if(n>0){if(e>0){if(this.get(e-1).equals2D(t))return null}if(ei&&(r=-1);for(let o=n;o!==i;o+=r)this.add(e[o],t);return!0}}closeRing(){if(this.size()>0){const e=this.get(0).copy();this.add(e,!1)}}}Y.coordArrayType=new Array(0).fill(null);class q{create(){if(1===arguments.length)arguments[0]instanceof Array||N(arguments[0],R);else if(2===arguments.length);else if(3===arguments.length){const e=arguments[0],t=arguments[1];return this.create(e,t)}}}class K{}class X extends A{constructor(){super(),X.constructor_.apply(this,arguments)}static constructor_(){this._coordinates=null;const e=arguments[0],t=arguments[1];A.constructor_.call(this,t),this.init(e)}computeEnvelopeInternal(){if(this.isEmpty())return new E;const e=new E;return e.expandToInclude(this._coordinates.getX(0),this._coordinates.getY(0)),e}getCoordinates(){return this.isEmpty()?[]:[this.getCoordinate()]}copyInternal(){return new X(this._coordinates.copy(),this._factory)}equalsExact(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof A){const e=arguments[0],t=arguments[1];return!!this.isEquivalentClass(e)&&(!(!this.isEmpty()||!e.isEmpty())||this.isEmpty()===e.isEmpty()&&this.equal(e.getCoordinate(),this.getCoordinate(),t))}return super.equalsExact.apply(this,arguments)}normalize(){}getCoordinate(){return 0!==this._coordinates.size()?this._coordinates.getCoordinate(0):null}getBoundaryDimension(){return F.FALSE}reverseInternal(){return this.getFactory().createPoint(this._coordinates.copy())}getTypeCode(){return A.TYPECODE_POINT}getDimension(){return 0}getNumPoints(){return this.isEmpty()?0:1}getX(){if(null===this.getCoordinate())throw new IllegalStateException("getX called on empty Point");return this.getCoordinate().x}compareToSameClass(){if(1===arguments.length){const e=arguments[0];return this.getCoordinate().compareTo(e.getCoordinate())}if(2===arguments.length){const e=arguments[0];return arguments[1].compare(this._coordinates,e._coordinates)}}apply(){if(N(arguments[0],M)){const e=arguments[0];if(this.isEmpty())return null;e.filter(this.getCoordinate())}else if(N(arguments[0],B)){const e=arguments[0];if(this.isEmpty())return null;e.filter(this._coordinates,0),e.isGeometryChanged()&&this.geometryChanged()}else if(N(arguments[0],k)){arguments[0].filter(this)}else if(N(arguments[0],u)){arguments[0].filter(this)}}getBoundary(){return this.getFactory().createGeometryCollection()}getGeometryType(){return A.TYPENAME_POINT}getCoordinateSequence(){return this._coordinates}getY(){if(null===this.getCoordinate())throw new IllegalStateException("getY called on empty Point");return this.getCoordinate().y}isEmpty(){return 0===this._coordinates.size()}init(e){null===e&&(e=this.getFactory().getCoordinateSequenceFactory().create([])),x.isTrue(e.size()<=1),this._coordinates=e}isSimple(){return!0}get interfaces_(){return[K]}}class J{static ofRing(){if(arguments[0]instanceof Array){const e=arguments[0];return Math.abs(J.ofRingSigned(e))}if(N(arguments[0],R)){const e=arguments[0];return Math.abs(J.ofRingSigned(e))}}static ofRingSigned(){if(arguments[0]instanceof Array){const e=arguments[0];if(e.length<3)return 0;let t=0;const n=e[0].x;for(let i=1;ie.compareTo(t)));else if(2===arguments.length)e.sort(((e,t)=>arguments[1].compare(e,t)));else if(3===arguments.length){const t=e.slice(arguments[1],arguments[2]);t.sort();const n=e.slice(0,arguments[1]).concat(t,e.slice(arguments[2],e.length));e.splice(0,e.length);for(const t of n)e.push(t)}else if(4===arguments.length){const t=e.slice(arguments[1],arguments[2]);t.sort(((e,t)=>arguments[3].compare(e,t)));const n=e.slice(0,arguments[1]).concat(t,e.slice(arguments[2],e.length));e.splice(0,e.length);for(const t of n)e.push(t)}}static asList(e){const t=new j;for(const n of e)t.add(n);return t}static copyOf(e,t){return e.slice(0,t)}}class Q{constructor(e){this.str=e}append(e){this.str+=e}setCharAt(e,t){this.str=this.str.substr(0,e)+t+this.str.substr(e+1)}toString(){return this.str}}class ee{constructor(e){this.value=e}intValue(){return this.value}compareTo(e){return this.valuee?1:0}static compare(e,t){return et?1:0}static isNan(e){return Number.isNaN(e)}static valueOf(e){return new ee(e)}}class te{constructor(){te.constructor_.apply(this,arguments)}static constructor_(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){const e=arguments[0];this.init(e)}else if(arguments[0]instanceof te){const e=arguments[0];this.init(e)}else if("string"==typeof arguments[0]){const e=arguments[0];te.constructor_.call(this,te.parse(e))}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.init(e,t)}}static determinant(){if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];return te.determinant(te.valueOf(e),te.valueOf(t),te.valueOf(n),te.valueOf(i))}if(arguments[3]instanceof te&&arguments[2]instanceof te&&arguments[0]instanceof te&&arguments[1]instanceof te){const e=arguments[1],t=arguments[2],n=arguments[3];return arguments[0].multiply(n).selfSubtract(e.multiply(t))}}static sqr(e){return te.valueOf(e).selfMultiply(e)}static valueOf(){if("string"==typeof arguments[0]){const e=arguments[0];return te.parse(e)}if("number"==typeof arguments[0]){return new te(arguments[0])}}static sqrt(e){return te.valueOf(e).sqrt()}static parse(e){let t=0;const n=e.length;for(;O.isWhitespace(e.charAt(t));)t++;let i=!1;if(t=n);){const n=e.charAt(t);if(t++,O.isDigit(n)){const e=n-"0";r.selfMultiply(te.TEN),r.selfAdd(e),o++}else{if("."!==n){if("e"===n||"E"===n){const n=e.substring(t);try{a=ee.parseInt(n)}catch(t){throw t instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+n+" in string "+e):t}break}throw new NumberFormatException("Unexpected character '"+n+"' at position "+t+" in string "+e)}s=o,l=!0}}let c=r;l||(s=o);const h=o-s-a;if(0===h)c=r;else if(h>0){const e=te.TEN.pow(h);c=r.divide(e)}else if(h<0){const e=te.TEN.pow(-h);c=r.multiply(e)}return i?c.negate():c}static createNaN(){return new te(_.NaN,_.NaN)}static copy(e){return new te(e)}static magnitude(e){const t=Math.abs(e),n=Math.log(t)/Math.log(10);let i=Math.trunc(Math.floor(n));return 10*Math.pow(10,i)<=t&&(i+=1),i}static stringOfChar(e,t){const n=new Q;for(let i=0;i9?(r=!0,l="9"):l="0"+i,s.append(l),n=n.subtract(te.valueOf(i)).multiply(te.TEN),r&&n.selfAdd(te.TEN);let c=!0;const h=te.magnitude(n._hi);if(h<0&&Math.abs(h)>=a-t&&(c=!1),!c)break}return t[0]=i,s.toString()}sqr(){return this.multiply(this)}doubleValue(){return this._hi+this._lo}subtract(){if(arguments[0]instanceof te){const e=arguments[0];return this.add(e.negate())}if("number"==typeof arguments[0]){const e=arguments[0];return this.add(-e)}}equals(){if(1===arguments.length&&arguments[0]instanceof te){const e=arguments[0];return this._hi===e._hi&&this._lo===e._lo}}isZero(){return 0===this._hi&&0===this._lo}selfSubtract(){if(arguments[0]instanceof te){const e=arguments[0];return this.isNaN()?this:this.selfAdd(-e._hi,-e._lo)}if("number"==typeof arguments[0]){const e=arguments[0];return this.isNaN()?this:this.selfAdd(-e,0)}}getSpecialNumberString(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}min(e){return this.le(e)?this:e}selfDivide(){if(1===arguments.length){if(arguments[0]instanceof te){const e=arguments[0];return this.selfDivide(e._hi,e._lo)}if("number"==typeof arguments[0]){const e=arguments[0];return this.selfDivide(e,0)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];let n=null,i=null,r=null,o=null,s=null,a=null,l=null,c=null;return s=this._hi/e,a=te.SPLIT*s,n=a-s,c=te.SPLIT*e,n=a-n,i=s-n,r=c-e,l=s*e,r=c-r,o=e-r,c=n*r-l+n*o+i*r+i*o,a=(this._hi-l-c+this._lo-s*t)/e,c=s+a,this._hi=c,this._lo=s-c+a,this}}dump(){return"DD<"+this._hi+", "+this._lo+">"}divide(){if(arguments[0]instanceof te){const e=arguments[0];let t=null,n=null,i=null,r=null,o=null,s=null,a=null,l=null;o=this._hi/e._hi,s=te.SPLIT*o,t=s-o,l=te.SPLIT*e._hi,t=s-t,n=o-t,i=l-e._hi,a=o*e._hi,i=l-i,r=e._hi-i,l=t*i-a+t*r+n*i+n*r,s=(this._hi-a-l+this._lo-o*e._lo)/e._hi,l=o+s;return new te(l,o-l+s)}if("number"==typeof arguments[0]){const e=arguments[0];return _.isNaN(e)?te.createNaN():te.copy(this).selfDivide(e,0)}}ge(e){return this._hi>e._hi||this._hi===e._hi&&this._lo>=e._lo}pow(e){if(0===e)return te.valueOf(1);let t=new te(this),n=te.valueOf(1),i=Math.abs(e);if(i>1)for(;i>0;)i%2==1&&n.selfMultiply(t),i/=2,i>0&&(t=t.sqr());else n=t;return e<0?n.reciprocal():n}ceil(){if(this.isNaN())return te.NaN;const e=Math.ceil(this._hi);let t=0;return e===this._hi&&(t=Math.ceil(this._lo)),new te(e,t)}compareTo(e){const t=e;return this._hit._hi?1:this._lot._lo?1:0}rint(){if(this.isNaN())return this;return this.add(.5).floor()}setValue(){if(arguments[0]instanceof te){const e=arguments[0];return this.init(e),this}if("number"==typeof arguments[0]){const e=arguments[0];return this.init(e),this}}max(e){return this.ge(e)?this:e}sqrt(){if(this.isZero())return te.valueOf(0);if(this.isNegative())return te.NaN;const e=1/Math.sqrt(this._hi),t=this._hi*e,n=te.valueOf(t),i=this.subtract(n.sqr())._hi*(.5*e);return n.add(i)}selfAdd(){if(1===arguments.length){if(arguments[0]instanceof te){const e=arguments[0];return this.selfAdd(e._hi,e._lo)}if("number"==typeof arguments[0]){const e=arguments[0];let t=null,n=null,i=null,r=null,o=null,s=null;return i=this._hi+e,o=i-this._hi,r=i-o,r=e-o+(this._hi-r),s=r+this._lo,t=i+s,n=s+(i-t),this._hi=t+n,this._lo=n+(t-this._hi),this}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];let n=null,i=null,r=null,o=null,s=null,a=null,l=null,c=null;s=this._hi+e,r=this._lo+t,l=s-this._hi,c=r-this._lo,a=s-l,o=r-c,a=e-l+(this._hi-a),o=t-c+(this._lo-o),l=a+r,n=s+l,i=l+(s-n),l=o+i;const h=n+l,u=l+(n-h);return this._hi=h,this._lo=u,this}}selfMultiply(){if(1===arguments.length){if(arguments[0]instanceof te){const e=arguments[0];return this.selfMultiply(e._hi,e._lo)}if("number"==typeof arguments[0]){const e=arguments[0];return this.selfMultiply(e,0)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];let n=null,i=null,r=null,o=null,s=null,a=null;s=te.SPLIT*this._hi,n=s-this._hi,a=te.SPLIT*e,n=s-n,i=this._hi-n,r=a-e,s=this._hi*e,r=a-r,o=e-r,a=n*r-s+n*o+i*r+i*o+(this._hi*t+this._lo*e);const l=s+a;n=s-l;const c=a+n;return this._hi=l,this._lo=c,this}}selfSqr(){return this.selfMultiply(this)}floor(){if(this.isNaN())return te.NaN;const e=Math.floor(this._hi);let t=0;return e===this._hi&&(t=Math.floor(this._lo)),new te(e,t)}negate(){return this.isNaN()?this:new te(-this._hi,-this._lo)}clone(){try{return null}catch(e){if(e instanceof CloneNotSupportedException)return null;throw e}}multiply(){if(arguments[0]instanceof te){const e=arguments[0];return e.isNaN()?te.createNaN():te.copy(this).selfMultiply(e)}if("number"==typeof arguments[0]){const e=arguments[0];return _.isNaN(e)?te.createNaN():te.copy(this).selfMultiply(e,0)}}isNaN(){return _.isNaN(this._hi)}intValue(){return Math.trunc(this._hi)}toString(){const e=te.magnitude(this._hi);return e>=-3&&e<=20?this.toStandardNotation():this.toSciNotation()}toStandardNotation(){const e=this.getSpecialNumberString();if(null!==e)return e;const t=new Array(1).fill(null),n=this.extractSignificantDigits(!0,t),i=t[0]+1;let r=n;if("."===n.charAt(0))r="0"+n;else if(i<0)r="0."+te.stringOfChar("0",-i)+n;else if(-1===n.indexOf(".")){const e=i-n.length;r=n+te.stringOfChar("0",e)+".0"}return this.isNegative()?"-"+r:r}reciprocal(){let e=null,t=null,n=null,i=null,r=null,o=null,s=null,a=null;r=1/this._hi,o=te.SPLIT*r,e=o-r,a=te.SPLIT*this._hi,e=o-e,t=r-e,n=a-this._hi,s=r*this._hi,n=a-n,i=this._hi-n,a=e*n-s+e*i+t*n+t*i,o=(1-s-a-r*this._lo)/this._hi;const l=r+o;return new te(l,r-l+o)}toSciNotation(){if(this.isZero())return te.SCI_NOT_ZERO;const e=this.getSpecialNumberString();if(null!==e)return e;const t=new Array(1).fill(null),n=this.extractSignificantDigits(!1,t),i=te.SCI_NOT_EXPONENT_CHAR+t[0];if("0"===n.charAt(0))throw new IllegalStateException("Found leading zero: "+n);let r="";n.length>1&&(r=n.substring(1));const o=n.charAt(0)+"."+r;return this.isNegative()?"-"+o+i:o+i}abs(){return this.isNaN()?te.NaN:this.isNegative()?this.negate():new te(this)}isPositive(){return this._hi>0||0===this._hi&&this._lo>0}lt(e){return this._hie._hi||this._hi===e._hi&&this._lo>e._lo}isNegative(){return this._hi<0||0===this._hi&&this._lo<0}trunc(){return this.isNaN()?te.NaN:this.isPositive()?this.floor():this.ceil()}signum(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0}get interfaces_(){return[g,d,m]}}te.PI=new te(3.141592653589793,12246467991473532e-32),te.TWO_PI=new te(6.283185307179586,24492935982947064e-32),te.PI_2=new te(1.5707963267948966,6123233995736766e-32),te.E=new te(2.718281828459045,14456468917292502e-32),te.NaN=new te(_.NaN,_.NaN),te.EPS=123259516440783e-46,te.SPLIT=134217729,te.MAX_PRINT_DIGITS=32,te.TEN=te.valueOf(10),te.ONE=te.valueOf(1),te.SCI_NOT_EXPONENT_CHAR="E",te.SCI_NOT_ZERO="0.0E0";class ne{static orientationIndex(e,t,n){const i=ne.orientationIndexFilter(e,t,n);if(i<=1)return i;const r=te.valueOf(t.x).selfAdd(-e.x),o=te.valueOf(t.y).selfAdd(-e.y),s=te.valueOf(n.x).selfAdd(-t.x),a=te.valueOf(n.y).selfAdd(-t.y);return r.selfMultiply(a).selfSubtract(o.selfMultiply(s)).signum()}static signOfDet2x2(){if(arguments[3]instanceof te&&arguments[2]instanceof te&&arguments[0]instanceof te&&arguments[1]instanceof te){const e=arguments[1],t=arguments[2],n=arguments[3];return arguments[0].multiply(n).selfSubtract(e.multiply(t)).signum()}if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3],r=te.valueOf(e),o=te.valueOf(t),s=te.valueOf(n),a=te.valueOf(i);return r.multiply(a).selfSubtract(o.multiply(s)).signum()}}static intersection(e,t,n,i){const r=new te(e.y).selfSubtract(t.y),o=new te(t.x).selfSubtract(e.x),s=new te(e.x).selfMultiply(t.y).selfSubtract(new te(t.x).selfMultiply(e.y)),a=new te(n.y).selfSubtract(i.y),l=new te(i.x).selfSubtract(n.x),c=new te(n.x).selfMultiply(i.y).selfSubtract(new te(i.x).selfMultiply(n.y)),h=o.multiply(c).selfSubtract(l.multiply(s)),u=a.multiply(s).selfSubtract(r.multiply(c)),d=r.multiply(l).selfSubtract(a.multiply(o)),m=h.selfDivide(d).doubleValue(),g=u.selfDivide(d).doubleValue();return _.isNaN(m)||_.isInfinite(m)||_.isNaN(g)||_.isInfinite(g)?null:new I(m,g)}static orientationIndexFilter(e,t,n){let i=null;const r=(e.x-n.x)*(t.y-n.y),o=(e.y-n.y)*(t.x-n.x),s=r-o;if(r>0){if(o<=0)return ne.signum(s);i=r+o}else{if(!(r<0))return ne.signum(s);if(o>=0)return ne.signum(s);i=-r-o}const a=ne.DP_SAFE_EPSILON*i;return s>=a||-s>=a?ne.signum(s):2}static signum(e){return e>0?1:e<0?-1:0}}ne.DP_SAFE_EPSILON=1e-15;class ie{static index(e,t,n){return ne.orientationIndex(e,t,n)}static isCCW(){if(arguments[0]instanceof Array){const e=arguments[0],t=e.length-1;if(t<3)throw new h("Ring has fewer than 4 points, so orientation cannot be determined");let n=e[0],i=0;for(let r=1;r<=t;r++){const t=e[r];t.y>n.y&&(n=t,i=r)}let r=i;do{r-=1,r<0&&(r=t)}while(e[r].equals2D(n)&&r!==i);let o=i;do{o=(o+1)%t}while(e[o].equals2D(n)&&o!==i);const s=e[r],a=e[o];if(s.equals2D(n)||a.equals2D(n)||s.equals2D(a))return!1;const l=ie.index(s,n,a);let c=null;return c=0===l?s.x>a.x:l>0,c}if(N(arguments[0],R)){const e=arguments[0],t=e.size()-1;if(t<3)throw new h("Ring has fewer than 4 points, so orientation cannot be determined");let n=e.getCoordinate(0),i=0;for(let r=1;r<=t;r++){const t=e.getCoordinate(r);t.y>n.y&&(n=t,i=r)}let r=null,o=i;do{o-=1,o<0&&(o=t),r=e.getCoordinate(o)}while(r.equals2D(n)&&o!==i);let s=null,a=i;do{a=(a+1)%t,s=e.getCoordinate(a)}while(s.equals2D(n)&&a!==i);if(r.equals2D(n)||s.equals2D(n)||r.equals2D(s))return!1;const l=ie.index(r,n,s);let c=null;return c=0===l?r.x>s.x:l>0,c}}}ie.CLOCKWISE=-1,ie.RIGHT=ie.CLOCKWISE,ie.COUNTERCLOCKWISE=1,ie.LEFT=ie.COUNTERCLOCKWISE,ie.COLLINEAR=0,ie.STRAIGHT=ie.COLLINEAR;class re{}class oe extends A{constructor(){super(),oe.constructor_.apply(this,arguments)}static constructor_(){this._shell=null,this._holes=null;let e=arguments[0],t=arguments[1],n=arguments[2];if(A.constructor_.call(this,n),null===e&&(e=this.getFactory().createLinearRing()),null===t&&(t=[]),A.hasNullElements(t))throw new h("holes must not contain null elements");if(e.isEmpty()&&A.hasNonEmptyElements(t))throw new h("shell is empty but holes are not");this._shell=e,this._holes=t}computeEnvelopeInternal(){return this._shell.getEnvelopeInternal()}getCoordinates(){if(this.isEmpty())return[];const e=new Array(this.getNumPoints()).fill(null);let t=-1;const n=this._shell.getCoordinates();for(let i=0;i=1&&this.getCoordinateSequence().size()= 4)")}getGeometryType(){return A.TYPENAME_LINEARRING}}de.MINIMUM_VALID_SIZE=4;class me extends I{constructor(){super(),me.constructor_.apply(this,arguments)}static constructor_(){if(0===arguments.length)I.constructor_.call(this);else if(1===arguments.length){if(arguments[0]instanceof me){const e=arguments[0];I.constructor_.call(this,e.x,e.y)}else if(arguments[0]instanceof I){const e=arguments[0];I.constructor_.call(this,e.x,e.y)}}else if(2===arguments.length){const e=arguments[0],t=arguments[1];I.constructor_.call(this,e,t,I.NULL_ORDINATE)}}setOrdinate(e,t){switch(e){case me.X:this.x=t;break;case me.Y:this.y=t;break;default:throw new h("Invalid ordinate index: "+e)}}getZ(){return I.NULL_ORDINATE}getOrdinate(e){switch(e){case me.X:return this.x;case me.Y:return this.y}throw new h("Invalid ordinate index: "+e)}setZ(e){throw new h("CoordinateXY dimension 2 does not support z-ordinate")}copy(){return new me(this)}toString(){return"("+this.x+", "+this.y+")"}setCoordinate(e){this.x=e.x,this.y=e.y,this.z=e.getZ()}}me.X=0,me.Y=1,me.Z=-1,me.M=-1;class ge extends I{constructor(){super(),ge.constructor_.apply(this,arguments)}static constructor_(){if(this._m=null,0===arguments.length)I.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof ge){const e=arguments[0];I.constructor_.call(this,e.x,e.y),this._m=e._m}else if(arguments[0]instanceof I){const e=arguments[0];I.constructor_.call(this,e.x,e.y),this._m=this.getM()}}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];I.constructor_.call(this,e,t,I.NULL_ORDINATE),this._m=n}}getM(){return this._m}setOrdinate(e,t){switch(e){case ge.X:this.x=t;break;case ge.Y:this.y=t;break;case ge.M:this._m=t;break;default:throw new h("Invalid ordinate index: "+e)}}setM(e){this._m=e}getZ(){return I.NULL_ORDINATE}getOrdinate(e){switch(e){case ge.X:return this.x;case ge.Y:return this.y;case ge.M:return this._m}throw new h("Invalid ordinate index: "+e)}setZ(e){throw new h("CoordinateXY dimension 2 does not support z-ordinate")}copy(){return new ge(this)}toString(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}setCoordinate(e){this.x=e.x,this.y=e.y,this.z=e.getZ(),this._m=e.getM()}}ge.X=0,ge.Y=1,ge.Z=-1,ge.M=2;class fe extends I{constructor(){super(),fe.constructor_.apply(this,arguments)}static constructor_(){if(this._m=null,0===arguments.length)I.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof fe){const e=arguments[0];I.constructor_.call(this,e),this._m=e._m}else if(arguments[0]instanceof I){const e=arguments[0];I.constructor_.call(this,e),this._m=this.getM()}}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];I.constructor_.call(this,e,t,n),this._m=i}}getM(){return this._m}setOrdinate(e,t){switch(e){case I.X:this.x=t;break;case I.Y:this.y=t;break;case I.Z:this.z=t;break;case I.M:this._m=t;break;default:throw new h("Invalid ordinate index: "+e)}}setM(e){this._m=e}getOrdinate(e){switch(e){case I.X:return this.x;case I.Y:return this.y;case I.Z:return this.getZ();case I.M:return this.getM()}throw new h("Invalid ordinate index: "+e)}copy(){return new fe(this)}toString(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}setCoordinate(e){this.x=e.x,this.y=e.y,this.z=e.getZ(),this._m=e.getM()}}class pe{static measures(e){return e instanceof me?0:e instanceof ge||e instanceof fe?1:0}static dimension(e){return e instanceof me?2:e instanceof ge?3:e instanceof fe?4:3}static create(){if(1===arguments.length){const e=arguments[0];return pe.create(e,0)}if(2===arguments.length){const e=arguments[0],t=arguments[1];return 2===e?new me:3===e&&0===t?new I:3===e&&1===t?new ge:4===e&&1===t?new fe:new I}}}class _e{static log10(e){const t=Math.log(e);return _.isInfinite(t)||_.isNaN(t)?t:t/_e.LOG_10}static min(e,t,n,i){let r=e;return tn?n:e}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){const e=arguments[0],t=arguments[1],n=arguments[2];return en?n:e}}static wrap(e,t){return e<0?t- -e%t:e%t}static max(){if(3===arguments.length){const e=arguments[1],t=arguments[2];let n=arguments[0];return e>n&&(n=e),t>n&&(n=t),n}if(4===arguments.length){const e=arguments[1],t=arguments[2],n=arguments[3];let i=arguments[0];return e>i&&(i=e),t>i&&(i=t),n>i&&(i=n),i}}static average(e,t){return(e+t)/2}}_e.LOG_10=Math.log(10);class ye{static arraycopy(e,t,n,i,r){let o=0;for(let s=t;s=e?t:[]}static indexOf(e,t){for(let n=0;n0)&&(t=e[n]);return t}static extract(e,t,n){t=_e.clamp(t,0,e.length);let i=(n=_e.clamp(n,-1,e.length))-t+1;n<0&&(i=0),t>=e.length&&(i=0),ni.length)return 1;if(0===n.length)return 0;const r=be.compare(n,i);return be.isEqualReversed(n,i)?0:r}OLDcompare(e,t){const n=e,i=t;if(n.lengthi.length)return 1;if(0===n.length)return 0;const r=be.increasingDirection(n),o=be.increasingDirection(i);let s=r>0?0:n.length-1,a=o>0?0:n.length-1;for(let e=0;e0){const e=new Ce(17*this._coordinates.length);e.append("("),e.append(this._coordinates[0]);for(let t=1;t3&&(e=3),e<2&&(e=2),new xe(arguments[0],e)}if(3===arguments.length){let e=arguments[2],t=arguments[1]-e;return e>1&&(e=1),t>3&&(t=3),t<2&&(t=2),new xe(arguments[0],t+e,e)}}}get interfaces_(){return[q,g]}}ve.instanceObject=new ve;class Se extends he{constructor(){super(),Se.constructor_.apply(this,arguments)}static constructor_(){const e=arguments[0],t=arguments[1];he.constructor_.call(this,e,t)}copyInternal(){const e=new Array(this._geometries.length).fill(null);for(let t=0;te.add(t))),e}size(){return this.map.size()}}class Ae{constructor(){Ae.constructor_.apply(this,arguments)}static constructor_(){if(this._modelType=null,this._scale=null,0===arguments.length)this._modelType=Ae.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof Me){const e=arguments[0];this._modelType=e,e===Ae.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){const e=arguments[0];this._modelType=Ae.FIXED,this.setScale(e)}else if(arguments[0]instanceof Ae){const e=arguments[0];this._modelType=e._modelType,this._scale=e._scale}}static mostPrecise(e,t){return e.compareTo(t)>=0?e:t}equals(e){if(!(e instanceof Ae))return!1;const t=e;return this._modelType===t._modelType&&this._scale===t._scale}compareTo(e){const t=e,n=this.getMaximumSignificantDigits(),i=t.getMaximumSignificantDigits();return ee.compare(n,i)}getScale(){return this._scale}isFloating(){return this._modelType===Ae.FLOATING||this._modelType===Ae.FLOATING_SINGLE}getType(){return this._modelType}toString(){let e="UNKNOWN";return this._modelType===Ae.FLOATING?e="Floating":this._modelType===Ae.FLOATING_SINGLE?e="Floating-Single":this._modelType===Ae.FIXED&&(e="Fixed (Scale="+this.getScale()+")"),e}makePrecise(){if("number"==typeof arguments[0]){const e=arguments[0];if(_.isNaN(e))return e;if(this._modelType===Ae.FLOATING_SINGLE){return e}return this._modelType===Ae.FIXED?Math.round(e*this._scale)/this._scale:e}if(arguments[0]instanceof I){const e=arguments[0];if(this._modelType===Ae.FLOATING)return null;e.x=this.makePrecise(e.x),e.y=this.makePrecise(e.y)}}getMaximumSignificantDigits(){let e=16;return this._modelType===Ae.FLOATING?e=16:this._modelType===Ae.FLOATING_SINGLE?e=6:this._modelType===Ae.FIXED&&(e=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),e}setScale(e){this._scale=Math.abs(e)}get interfaces_(){return[g,d]}}class Me{constructor(){Me.constructor_.apply(this,arguments)}static constructor_(){this._name=null;const e=arguments[0];this._name=e,Me.nameToTypeMap.put(e,this)}readResolve(){return Me.nameToTypeMap.get(this._name)}toString(){return this._name}get interfaces_(){return[g]}}Me.nameToTypeMap=new Ee,Ae.Type=Me,Ae.FIXED=new Me("FIXED"),Ae.FLOATING=new Me("FLOATING"),Ae.FLOATING_SINGLE=new Me("FLOATING SINGLE"),Ae.maximumPreciseValue=9007199254740992;class Ne extends he{constructor(){super(),Ne.constructor_.apply(this,arguments)}static constructor_(){const e=arguments[0],t=arguments[1];he.constructor_.call(this,e,t)}copyInternal(){const e=new Array(this._geometries.length).fill(null);for(let t=0;t1){if(r instanceof oe)return this.createMultiPolygon(De.toPolygonArray(e));if(r instanceof G)return this.createMultiLineString(De.toLineStringArray(e));if(r instanceof X)return this.createMultiPoint(De.toPointArray(e));x.shouldNeverReachHere("Unhandled geometry type: "+r.getGeometryType())}return r}createMultiPointFromCoords(e){return this.createMultiPoint(null!==e?this.getCoordinateSequenceFactory().create(e):null)}createPoint(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof I){const e=arguments[0];return this.createPoint(null!==e?this.getCoordinateSequenceFactory().create([e]):null)}if(N(arguments[0],R)){return new X(arguments[0],this)}}}getCoordinateSequenceFactory(){return this._coordinateSequenceFactory}createPolygon(){if(0===arguments.length)return this.createPolygon(null,null);if(1===arguments.length){if(N(arguments[0],R)){const e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof Array){const e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof de){const e=arguments[0];return this.createPolygon(e,null)}}else if(2===arguments.length){return new oe(arguments[0],arguments[1],this)}}getSRID(){return this._SRID}createGeometryCollection(){if(0===arguments.length)return new he(null,this);if(1===arguments.length){return new he(arguments[0],this)}}getPrecisionModel(){return this._precisionModel}createLinearRing(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){const e=arguments[0];return this.createLinearRing(null!==e?this.getCoordinateSequenceFactory().create(e):null)}if(N(arguments[0],R)){return new de(arguments[0],this)}}}createMultiPolygon(){if(0===arguments.length)return new Se(null,this);if(1===arguments.length){return new Se(arguments[0],this)}}createMultiPoint(){if(0===arguments.length)return new ue(null,this);if(1===arguments.length){if(arguments[0]instanceof Array){return new ue(arguments[0],this)}if(N(arguments[0],R)){const e=arguments[0];if(null===e)return this.createMultiPoint(new Array(0).fill(null));const t=new Array(e.size()).fill(null);for(let n=0;n0&&i<4&&!this._preserveType?this._factory.createLineString(n):this._factory.createLinearRing(n)}}class Pe{static intersection(e,t,n,i){const r=e.xt.x?e.x:t.x,a=e.y>t.y?e.y:t.y,l=n.xi.x?n.x:i.x,u=n.y>i.y?n.y:i.y,d=((r>l?r:l)+(sc?o:c)+(a1||a<0||a>1)&&(r=!0)}}else r=!0;return r?_e.min(Le.pointToSegment(e,n,i),Le.pointToSegment(t,n,i),Le.pointToSegment(n,e,t),Le.pointToSegment(i,e,t)):0}static pointToSegment(e,t,n){if(t.x===n.x&&t.y===n.y)return e.distance(t);const i=(n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y),r=((e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y))/i;if(r<=0)return e.distance(t);if(r>=1)return e.distance(n);const o=((t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y))/i;return Math.abs(o)*Math.sqrt(i)}static pointToLinePerpendicular(e,t,n){const i=(n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y),r=((t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y))/i;return Math.abs(r)*Math.sqrt(i)}static pointToSegmentString(e,t){if(0===t.length)throw new h("Line array must contain at least one vertex");let n=e.distance(t[0]);for(let i=0;i="a"&&e<="z"||e>="A"&&e<="Z"}isNumeric_(e,t){return e>="0"&&e<="9"||"."==e&&!(void 0!==t&&t)}isWhiteSpace_(e){return" "==e||"\t"==e||"\r"==e||"\n"==e}nextChar_(){return this.wkt.charAt(++this.index_)}nextToken(){const e=this.nextChar_(),t=this.index_;let n,i=e;if("("==e)n=We;else if(","==e)n=je;else if(")"==e)n=He;else if(this.isNumeric_(e)||"-"==e)n=Ue,i=this.readNumber_();else if(this.isAlpha_(e))n=ze,i=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(""!==e)throw new Error("Unexpected character: "+e);n=Ve}return{position:t,value:i,type:n}}readNumber_(){let e;const t=this.index_;let n=!1,i=!1;do{"."==e?n=!0:"e"!=e&&"E"!=e||(i=!0),e=this.nextChar_()}while(this.isNumeric_(e,n)||!i&&("e"==e||"E"==e)||i&&("-"==e||"+"==e));return parseFloat(this.wkt.substring(t,this.index_--))}readText_(){let e;const t=this.index_;do{e=this.nextChar_()}while(this.isAlpha_(e));return this.wkt.substring(t,this.index_--).toUpperCase()}}class qe{constructor(e,t){this.lexer_=e,this.token_,this.layout_=Oe,this.factory=t}consume_(){this.token_=this.lexer_.nextToken()}isTokenType(e){return this.token_.type==e}match(e){const t=this.isTokenType(e);return t&&this.consume_(),t}parse(){this.consume_();return this.parseGeometry_()}parseGeometryLayout_(){let e=Oe;const t=this.token_;if(this.isTokenType(ze)){const n=t.value;"Z"===n?e=Fe:"M"===n?e=ke:"ZM"===n&&(e=Be),e!==Oe&&this.consume_()}return e}parseGeometryCollectionText_(){if(this.match(We)){const e=[];do{e.push(this.parseGeometry_())}while(this.match(je));if(this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(We)){const e=this.parsePoint_();if(this.match(He))return e}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(We)){const e=this.parsePointList_();if(this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(We)){const e=this.parseLineStringTextList_();if(this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(We)){let e;if(e=this.token_.type==We?this.parsePointTextList_():this.parsePointList_(),this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(We)){const e=this.parseLineStringTextList_();if(this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(We)){const e=this.parsePolygonTextList_();if(this.match(He))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parsePoint_(){const e=[],t=this.layout_.length;for(let n=0;nnew I(...e),n=n=>{const i=n.map((n=>e.createLinearRing(n.map(t))));return i.length>1?e.createPolygon(i[0],i.slice(1)):e.createPolygon(i[0])},i=this.token_;if(this.match(ze)){const r=i.value;if(this.layout_=this.parseGeometryLayout_(),"GEOMETRYCOLLECTION"==r){const t=this.parseGeometryCollectionText_();return e.createGeometryCollection(t)}switch(r){case"POINT":{const t=this.parsePointText_();return t?e.createPoint(new I(...t)):e.createPoint()}case"LINESTRING":{const n=this.parseLineStringText_().map(t);return e.createLineString(n)}case"LINEARRING":{const n=this.parseLineStringText_().map(t);return e.createLinearRing(n)}case"POLYGON":{const t=this.parsePolygonText_();return t&&0!==t.length?n(t):e.createPolygon()}case"MULTIPOINT":{const n=this.parseMultiPointText_();if(!n||0===n.length)return e.createMultiPoint();const i=n.map(t).map((t=>e.createPoint(t)));return e.createMultiPoint(i)}case"MULTILINESTRING":{const n=this.parseMultiLineStringText_().map((n=>e.createLineString(n.map(t))));return e.createMultiLineString(n)}case"MULTIPOLYGON":{const t=this.parseMultiPolygonText_();if(!t||0===t.length)return e.createMultiPolygon();const i=t.map(n);return e.createMultiPolygon(i)}default:throw new Error("Invalid geometry type: "+r)}}throw new Error(this.formatErrorMessage_())}}function Ke(e){if(e.isEmpty())return"";const t=e.getCoordinate(),n=[t.x,t.y];return void 0===t.z||Number.isNaN(t.z)||n.push(t.z),void 0===t.m||Number.isNaN(t.m)||n.push(t.m),n.join(" ")}function Xe(e){const t=e.getCoordinates().map((e=>{const t=[e.x,e.y];return void 0===e.z||Number.isNaN(e.z)||t.push(e.z),void 0===e.m||Number.isNaN(e.m)||t.push(e.m),t})),n=[];for(let e=0,i=t.length;e0&&(t+=" "+i),e.isEmpty())return t+" EMPTY";return t+" ("+n(e)+")"}class $e{constructor(e){this.geometryFactory=e||new De,this.precisionModel=this.geometryFactory.getPrecisionModel()}read(e){const t=new Ye(e);return new qe(t,this.geometryFactory).parse()}write(e){return Qe(e)}}class et{constructor(e){this.parser=new $e(e)}write(e){return this.parser.write(e)}static toLineString(e,t){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+e.x+" "+e.y+", "+t.x+" "+t.y+" )"}}class tt{constructor(){tt.constructor_.apply(this,arguments)}static constructor_(){this._result=null,this._inputLines=Array(2).fill().map((()=>Array(2))),this._intPt=new Array(2).fill(null),this._intLineIndex=null,this._isProper=null,this._pa=null,this._pb=null,this._precisionModel=null,this._intPt[0]=new I,this._intPt[1]=new I,this._pa=this._intPt[0],this._pb=this._intPt[1],this._result=0}static computeEdgeDistance(e,t,n){const i=Math.abs(n.x-t.x),r=Math.abs(n.y-t.y);let o=-1;if(e.equals(t))o=0;else if(e.equals(n))o=i>r?i:r;else{const n=Math.abs(e.x-t.x),s=Math.abs(e.y-t.y);o=i>r?n:s,0!==o||e.equals(t)||(o=Math.max(n,s))}return x.isTrue(!(0===o&&!e.equals(t)),"Bad distance calculation"),o}static nonRobustComputeEdgeDistance(e,t,n){const i=e.x-t.x,r=e.y-t.y,o=Math.sqrt(i*i+r*r);return x.isTrue(!(0===o&&!e.equals(t)),"Invalid distance calculation"),o}getIndexAlongSegment(e,t){return this.computeIntLineIndex(),this._intLineIndex[e][t]}getTopologySummary(){const e=new Ce;return this.isEndPoint()&&e.append(" endpoint"),this._isProper&&e.append(" proper"),this.isCollinear()&&e.append(" collinear"),e.toString()}computeIntersection(e,t,n,i){this._inputLines[0][0]=e,this._inputLines[0][1]=t,this._inputLines[1][0]=n,this._inputLines[1][1]=i,this._result=this.computeIntersect(e,t,n,i)}getIntersectionNum(){return this._result}computeIntLineIndex(){if(0===arguments.length)null===this._intLineIndex&&(this._intLineIndex=Array(2).fill().map((()=>Array(2))),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){const e=arguments[0];this.getEdgeDistance(e,0)>this.getEdgeDistance(e,1)?(this._intLineIndex[e][0]=0,this._intLineIndex[e][1]=1):(this._intLineIndex[e][0]=1,this._intLineIndex[e][1]=0)}}isProper(){return this.hasIntersection()&&this._isProper}setPrecisionModel(e){this._precisionModel=e}isInteriorIntersection(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){const e=arguments[0];for(let t=0;t1e-4&&ye.out.println("Distance = "+r.distance(o))}intersectionSafe(e,t,n,i){let r=Pe.intersection(e,t,n,i);return null===r&&(r=nt.nearestEndpoint(e,t,n,i)),r}computeCollinearIntersection(e,t,n,i){const r=E.intersects(e,t,n),o=E.intersects(e,t,i),s=E.intersects(n,i,e),a=E.intersects(n,i,t);return r&&o?(this._intPt[0]=n,this._intPt[1]=i,tt.COLLINEAR_INTERSECTION):s&&a?(this._intPt[0]=e,this._intPt[1]=t,tt.COLLINEAR_INTERSECTION):r&&s?(this._intPt[0]=n,this._intPt[1]=e,!n.equals(e)||o||a?tt.COLLINEAR_INTERSECTION:tt.POINT_INTERSECTION):r&&a?(this._intPt[0]=n,this._intPt[1]=t,!n.equals(t)||o||s?tt.COLLINEAR_INTERSECTION:tt.POINT_INTERSECTION):o&&s?(this._intPt[0]=i,this._intPt[1]=e,!i.equals(e)||r||a?tt.COLLINEAR_INTERSECTION:tt.POINT_INTERSECTION):o&&a?(this._intPt[0]=i,this._intPt[1]=t,!i.equals(t)||r||s?tt.COLLINEAR_INTERSECTION:tt.POINT_INTERSECTION):tt.NO_INTERSECTION}computeIntersect(e,t,n,i){if(this._isProper=!1,!E.intersects(e,t,n,i))return tt.NO_INTERSECTION;const r=ie.index(e,t,n),o=ie.index(e,t,i);if(r>0&&o>0||r<0&&o<0)return tt.NO_INTERSECTION;const s=ie.index(n,i,e),a=ie.index(n,i,t);if(s>0&&a>0||s<0&&a<0)return tt.NO_INTERSECTION;return 0===r&&0===o&&0===s&&0===a?this.computeCollinearIntersection(e,t,n,i):(0===r||0===o||0===s||0===a?(this._isProper=!1,e.equals2D(n)||e.equals2D(i)?this._intPt[0]=e:t.equals2D(n)||t.equals2D(i)?this._intPt[0]=t:0===r?this._intPt[0]=new I(n):0===o?this._intPt[0]=new I(i):0===s?this._intPt[0]=new I(e):0===a&&(this._intPt[0]=new I(t))):(this._isProper=!0,this._intPt[0]=this.intersection(e,t,n,i)),tt.POINT_INTERSECTION)}}class it{constructor(){it.constructor_.apply(this,arguments)}static constructor_(){if(this.p0=null,this.p1=null,0===arguments.length)it.constructor_.call(this,new I,new I);else if(1===arguments.length){const e=arguments[0];it.constructor_.call(this,e.p0,e.p1)}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.p0=e,this.p1=t}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];it.constructor_.call(this,new I(e,t),new I(n,i))}}static midPoint(e,t){return new I((e.x+t.x)/2,(e.y+t.y)/2)}minX(){return Math.min(this.p0.x,this.p1.x)}orientationIndex(){if(arguments[0]instanceof it){const e=arguments[0],t=ie.index(this.p0,this.p1,e.p0),n=ie.index(this.p0,this.p1,e.p1);return t>=0&&n>=0||t<=0&&n<=0?Math.max(t,n):0}if(arguments[0]instanceof I){const e=arguments[0];return ie.index(this.p0,this.p1,e)}}toGeometry(e){return e.createLineString([this.p0,this.p1])}isVertical(){return this.p0.x===this.p1.x}equals(e){if(!(e instanceof it))return!1;const t=e;return this.p0.equals(t.p0)&&this.p1.equals(t.p1)}intersection(e){const t=new nt;return t.computeIntersection(this.p0,this.p1,e.p0,e.p1),t.hasIntersection()?t.getIntersection(0):null}project(){if(arguments[0]instanceof I){const e=arguments[0];if(e.equals(this.p0)||e.equals(this.p1))return new I(e);const t=this.projectionFactor(e),n=new I;return n.x=this.p0.x+t*(this.p1.x-this.p0.x),n.y=this.p0.y+t*(this.p1.y-this.p0.y),n}if(arguments[0]instanceof it){const e=arguments[0],t=this.projectionFactor(e.p0),n=this.projectionFactor(e.p1);if(t>=1&&n>=1)return null;if(t<=0&&n<=0)return null;let i=this.project(e.p0);t<0&&(i=this.p0),t>1&&(i=this.p1);let r=this.project(e.p1);return n<0&&(r=this.p0),n>1&&(r=this.p1),new it(i,r)}}normalize(){this.p1.compareTo(this.p0)<0&&this.reverse()}angle(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)}getCoordinate(e){return 0===e?this.p0:this.p1}distancePerpendicular(e){return Le.pointToLinePerpendicular(e,this.p0,this.p1)}minY(){return Math.min(this.p0.y,this.p1.y)}midPoint(){return it.midPoint(this.p0,this.p1)}projectionFactor(e){if(e.equals(this.p0))return 0;if(e.equals(this.p1))return 1;const t=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,i=t*t+n*n;if(i<=0)return _.NaN;return((e.x-this.p0.x)*t+(e.y-this.p0.y)*n)/i}closestPoints(e){const t=this.intersection(e);if(null!==t)return[t,t];const n=new Array(2).fill(null);let i=_.MAX_VALUE,r=null;const o=this.closestPoint(e.p0);i=o.distance(e.p0),n[0]=o,n[1]=e.p0;const s=this.closestPoint(e.p1);r=s.distance(e.p1),r0&&t<1)return this.project(e);return this.p0.distance(e)1||_.isNaN(t))&&(t=1),t}toString(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"}isHorizontal(){return this.p0.y===this.p1.y}reflect(e){const t=this.p1.getY()-this.p0.getY(),n=this.p0.getX()-this.p1.getX(),i=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),r=t*t+n*n,o=t*t-n*n,s=e.getX(),a=e.getY();return new I((-o*s-2*t*n*a-2*t*i)/r,(o*a-2*t*n*s-2*n*i)/r)}distance(){if(arguments[0]instanceof it){const e=arguments[0];return Le.segmentToSegment(this.p0,this.p1,e.p0,e.p1)}if(arguments[0]instanceof I){const e=arguments[0];return Le.pointToSegment(e,this.p0,this.p1)}}pointAlong(e){const t=new I;return t.x=this.p0.x+e*(this.p1.x-this.p0.x),t.y=this.p0.y+e*(this.p1.y-this.p0.y),t}hashCode(){let e=_.doubleToLongBits(this.p0.x);e^=31*_.doubleToLongBits(this.p0.y);const t=Math.trunc(e)^Math.trunc(e>>32);let n=_.doubleToLongBits(this.p1.x);n^=31*_.doubleToLongBits(this.p1.y);return t^(Math.trunc(n)^Math.trunc(n>>32))}get interfaces_(){return[d,g]}}class rt{constructor(e){this.parser=new $e(e||new De)}read(e){return this.parser.read(e)}}class ot{constructor(){ot.constructor_.apply(this,arguments)}static constructor_(){if(this._quadrantSegments=ot.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=ot.CAP_ROUND,this._joinStyle=ot.JOIN_ROUND,this._mitreLimit=ot.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=ot.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){const e=arguments[0];this.setQuadrantSegments(e)}else if(2===arguments.length){const e=arguments[0],t=arguments[1];this.setQuadrantSegments(e),this.setEndCapStyle(t)}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];this.setQuadrantSegments(e),this.setEndCapStyle(t),this.setJoinStyle(n),this.setMitreLimit(i)}}static bufferDistanceError(e){const t=Math.PI/2/e;return 1-Math.cos(t/2)}getEndCapStyle(){return this._endCapStyle}isSingleSided(){return this._isSingleSided}setQuadrantSegments(e){this._quadrantSegments=e,0===this._quadrantSegments&&(this._joinStyle=ot.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=ot.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),e<=0&&(this._quadrantSegments=1),this._joinStyle!==ot.JOIN_ROUND&&(this._quadrantSegments=ot.DEFAULT_QUADRANT_SEGMENTS)}getJoinStyle(){return this._joinStyle}setJoinStyle(e){this._joinStyle=e}setSimplifyFactor(e){this._simplifyFactor=e<0?0:e}getSimplifyFactor(){return this._simplifyFactor}getQuadrantSegments(){return this._quadrantSegments}setEndCapStyle(e){this._endCapStyle=e}getMitreLimit(){return this._mitreLimit}setMitreLimit(e){this._mitreLimit=e}setSingleSided(e){this._isSingleSided=e}}ot.CAP_ROUND=1,ot.CAP_FLAT=2,ot.CAP_SQUARE=3,ot.JOIN_ROUND=1,ot.JOIN_MITRE=2,ot.JOIN_BEVEL=3,ot.DEFAULT_QUADRANT_SEGMENTS=8,ot.DEFAULT_MITRE_LIMIT=5,ot.DEFAULT_SIMPLIFY_FACTOR=.01;class st{static toLocationSymbol(e){switch(e){case st.EXTERIOR:return"e";case st.BOUNDARY:return"b";case st.INTERIOR:return"i";case st.NONE:return"-"}throw new h("Unknown location value: "+e)}}st.INTERIOR=0,st.BOUNDARY=1,st.EXTERIOR=2,st.NONE=-1;class at{static opposite(e){return e===at.LEFT?at.RIGHT:e===at.RIGHT?at.LEFT:e}}at.ON=0,at.LEFT=1,at.RIGHT=2;class lt extends c{constructor(e){super(e),this.name=Object.keys({EmptyStackException:lt})[0]}}class ct extends H{constructor(){super(),this.array=[]}add(e){return this.array.push(e),!0}get(e){if(e<0||e>=this.size())throw new W;return this.array[e]}push(e){return this.array.push(e),e}pop(){if(0===this.array.length)throw new lt;return this.array.pop()}peek(){if(0===this.array.length)throw new lt;return this.array[this.array.length-1]}empty(){return 0===this.array.length}isEmpty(){return this.empty()}search(e){return this.array.indexOf(e)}size(){return this.array.length}toArray(){return this.array.slice()}}class ht{constructor(){ht.constructor_.apply(this,arguments)}static constructor_(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}getCoordinate(){return this._minCoord}getRightmostSide(e,t){let n=this.getRightmostSideOfSegment(e,t);return n<0&&(n=this.getRightmostSideOfSegment(e,t-1)),n<0&&(this._minCoord=null,this.checkForRightmostCoordinate(e)),n}findRightmostEdgeAtVertex(){const e=this._minDe.getEdge().getCoordinates();x.isTrue(this._minIndex>0&&this._minIndexthis._minCoord.y&&n.y>this._minCoord.y&&i===ie.CLOCKWISE)&&(r=!0),r&&(this._minIndex=this._minIndex-1)}getRightmostSideOfSegment(e,t){const n=e.getEdge().getCoordinates();if(t<0||t+1>=n.length)return-1;if(n[t].y===n[t+1].y)return-1;let i=at.LEFT;return n[t].ythis._minCoord.x)&&(this._minDe=e,this._minIndex=n,this._minCoord=t[n])}findRightmostEdgeAtNode(){const e=this._minDe.getNode().getEdges();this._minDe=e.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}findEdge(e){for(let t=e.iterator();t.hasNext();){const e=t.next();e.isForward()&&this.checkForRightmostCoordinate(e)}x.isTrue(0!==this._minIndex||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this._minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe;this.getRightmostSide(this._minDe,this._minIndex)===at.LEFT&&(this._orientedDe=this._minDe.getSym())}}class ut extends b{constructor(e,t){super(t?e+" [ "+t+" ]":e),this.pt=t?new I(t):void 0,this.name=Object.keys({TopologyException:ut})[0]}getCoordinate(){return this.pt}}class dt{constructor(){this.array=[]}addLast(e){this.array.push(e)}removeFirst(){return this.array.shift()}isEmpty(){return 0===this.array.length}}class mt{constructor(){mt.constructor_.apply(this,arguments)}static constructor_(){this._finder=null,this._dirEdgeList=new j,this._nodes=new j,this._rightMostCoord=null,this._env=null,this._finder=new ht}clearVisitedEdges(){for(let e=this._dirEdgeList.iterator();e.hasNext();){e.next().setVisited(!1)}}getRightmostCoordinate(){return this._rightMostCoord}computeNodeDepth(e){let t=null;for(let n=e.getEdges().iterator();n.hasNext();){const e=n.next();if(e.isVisited()||e.getSym().isVisited()){t=e;break}}if(null===t)throw new ut("unable to find edge to compute depths at "+e.getCoordinate());e.getEdges().computeDepths(t);for(let t=e.getEdges().iterator();t.hasNext();){const e=t.next();e.setVisited(!0),this.copySymDepths(e)}}computeDepth(e){this.clearVisitedEdges();const t=this._finder.getEdge();t.getNode(),t.getLabel(),t.setEdgeDepths(at.RIGHT,e),this.copySymDepths(t),this.computeDepths(t)}create(e){this.addReachable(e),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()}findResultEdges(){for(let e=this._dirEdgeList.iterator();e.hasNext();){const t=e.next();t.getDepth(at.RIGHT)>=1&&t.getDepth(at.LEFT)<=0&&!t.isInteriorAreaEdge()&&t.setInResult(!0)}}computeDepths(e){const t=new Ie,n=new dt,i=e.getNode();for(n.addLast(i),t.add(i),e.setVisited(!0);!n.isEmpty();){const e=n.removeFirst();t.add(e),this.computeNodeDepth(e);for(let i=e.getEdges().iterator();i.hasNext();){const e=i.next().getSym();if(e.isVisited())continue;const r=e.getNode();t.contains(r)||(n.addLast(r),t.add(r))}}}compareTo(e){const t=e;return this._rightMostCoord.xt._rightMostCoord.x?1:0}getEnvelope(){if(null===this._env){const e=new E;for(let t=this._dirEdgeList.iterator();t.hasNext();){const n=t.next().getEdge().getCoordinates();for(let t=0;ti&&(n=t.x,i=e.x),this._p.x>=n&&this._p.x<=i&&(this._isPointOnSegment=!0),null}if(e.y>this._p.y&&t.y<=this._p.y||t.y>this._p.y&&e.y<=this._p.y){let n=ie.index(e,t,this._p);if(n===ie.COLLINEAR)return this._isPointOnSegment=!0,null;t.ythis.location.length){const e=new Array(3).fill(null);e[at.ON]=this.location[at.ON],e[at.LEFT]=st.NONE,e[at.RIGHT]=st.NONE,this.location=e}for(let t=0;t1&&e.append(st.toLocationSymbol(this.location[at.LEFT])),e.append(st.toLocationSymbol(this.location[at.ON])),this.location.length>1&&e.append(st.toLocationSymbol(this.location[at.RIGHT])),e.toString()}setLocations(e,t,n){this.location[at.ON]=e,this.location[at.LEFT]=t,this.location[at.RIGHT]=n}get(e){return e1}isAnyNull(){for(let e=0;ethis._maxNodeDegree&&(this._maxNodeDegree=t),e=this.getNext(e)}while(e!==this._startDe);this._maxNodeDegree*=2}addPoints(e,t,n){const i=e.getCoordinates();if(t){let e=1;n&&(e=0);for(let t=e;t=0;t--)this._pts.add(i[t])}}isHole(){return this._isHole}setInResult(){let e=this._startDe;do{e.getEdge().setInResult(!0),e=e.getNext()}while(e!==this._startDe)}containsPoint(e){const t=this.getLinearRing();if(!t.getEnvelopeInternal().contains(e))return!1;if(!ft.isInRing(e,t.getCoordinates()))return!1;for(let t=this._holes.iterator();t.hasNext();){if(t.next().containsPoint(e))return!1}return!0}addHole(e){this._holes.add(e)}isShell(){return null===this._shell}getLabel(){return this._label}getEdges(){return this._edges}getMaxNodeDegree(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree}getShell(){return this._shell}mergeLabel(){if(1===arguments.length){const e=arguments[0];this.mergeLabel(e,0),this.mergeLabel(e,1)}else if(2===arguments.length){const e=arguments[1],t=arguments[0].getLocation(e,at.RIGHT);if(t===st.NONE)return null;if(this._label.getLocation(e)===st.NONE)return this._label.setLocation(e,t),null}}setShell(e){this._shell=e,null!==e&&e.addHole(this)}toPolygon(e){const t=new Array(this._holes.size()).fill(null);for(let e=0;e=2,"found partial label"),this.computeIM(e)}isInResult(){return this._isInResult}isVisited(){return this._isVisited}}class vt extends xt{constructor(){super(),vt.constructor_.apply(this,arguments)}static constructor_(){this._coord=null,this._edges=null;const e=arguments[0],t=arguments[1];this._coord=e,this._edges=t,this._label=new _t(0,st.NONE)}isIncidentEdgeInResult(){for(let e=this.getEdges().getEdges().iterator();e.hasNext();){if(e.next().getEdge().isInResult())return!0}return!1}isIsolated(){return 1===this._label.getGeometryCount()}getCoordinate(){return this._coord}print(e){e.println("node "+this._coord+" lbl: "+this._label)}computeIM(e){}computeMergedLocation(e,t){let n=st.NONE;if(n=this._label.getLocation(t),!e.isNull(t)){const i=e.getLocation(t);n!==st.BOUNDARY&&(n=i)}return n}setLabel(){if(2!==arguments.length||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return super.setLabel.apply(this,arguments);{const e=arguments[0],t=arguments[1];null===this._label?this._label=new _t(e,t):this._label.setLocation(e,t)}}getEdges(){return this._edges}mergeLabel(){if(arguments[0]instanceof vt){const e=arguments[0];this.mergeLabel(e._label)}else if(arguments[0]instanceof _t){const e=arguments[0];for(let t=0;t<2;t++){const n=this.computeMergedLocation(e,t);this._label.getLocation(t)===st.NONE&&this._label.setLocation(t,n)}}}add(e){this._edges.insert(e),e.setNode(this)}setLabelBoundary(e){if(null===this._label)return null;let t=st.NONE;null!==this._label&&(t=this._label.getLocation(e));let n=null;switch(t){case st.BOUNDARY:n=st.INTERIOR;break;case st.INTERIOR:default:n=st.BOUNDARY}this._label.setLocation(e,n)}}class St extends Te{}function Tt(e){return null==e?0:e.color}function It(e){return null==e?null:e.parent}function wt(e,t){null!==e&&(e.color=t)}function Et(e){return null==e?null:e.left}function At(e){return null==e?null:e.right}class Mt extends St{constructor(){super(),this.root_=null,this.size_=0}get(e){let t=this.root_;for(;null!==t;){const n=e.compareTo(t.key);if(n<0)t=t.left;else{if(!(n>0))return t.value;t=t.right}}return null}put(e,t){if(null===this.root_)return this.root_={key:e,value:t,left:null,right:null,parent:null,color:0,getValue(){return this.value},getKey(){return this.key}},this.size_=1,null;let n,i,r=this.root_;do{if(n=r,i=e.compareTo(r.key),i<0)r=r.left;else{if(!(i>0)){const e=r.value;return r.value=t,e}r=r.right}}while(null!==r);const o={key:e,left:null,right:null,value:t,parent:n,color:0,getValue(){return this.value},getKey(){return this.key}};return i<0?n.left=o:n.right=o,this.fixAfterInsertion(o),this.size_++,null}fixAfterInsertion(e){let t;for(e.color=1;null!=e&&e!==this.root_&&1===e.parent.color;)It(e)===Et(It(It(e)))?(t=At(It(It(e))),1===Tt(t)?(wt(It(e),0),wt(t,0),wt(It(It(e)),1),e=It(It(e))):(e===At(It(e))&&(e=It(e),this.rotateLeft(e)),wt(It(e),0),wt(It(It(e)),1),this.rotateRight(It(It(e))))):(t=Et(It(It(e))),1===Tt(t)?(wt(It(e),0),wt(t,0),wt(It(It(e)),1),e=It(It(e))):(e===Et(It(e))&&(e=It(e),this.rotateRight(e)),wt(It(e),0),wt(It(It(e)),1),this.rotateLeft(It(It(e)))));this.root_.color=0}values(){const e=new j;let t=this.getFirstEntry();if(null!==t)for(e.add(t.value);null!==(t=Mt.successor(t));)e.add(t.value);return e}entrySet(){const e=new Ie;let t=this.getFirstEntry();if(null!==t)for(e.add(t);null!==(t=Mt.successor(t));)e.add(t);return e}rotateLeft(e){if(null!=e){const t=e.right;e.right=t.left,null!=t.left&&(t.left.parent=e),t.parent=e.parent,null==e.parent?this.root_=t:e.parent.left===e?e.parent.left=t:e.parent.right=t,t.left=e,e.parent=t}}rotateRight(e){if(null!=e){const t=e.left;e.left=t.right,null!=t.right&&(t.right.parent=e),t.parent=e.parent,null==e.parent?this.root_=t:e.parent.right===e?e.parent.right=t:e.parent.left=t,t.right=e,e.parent=t}}getFirstEntry(){let e=this.root_;if(null!=e)for(;null!=e.left;)e=e.left;return e}static successor(e){let t;if(null===e)return null;if(null!==e.right){for(t=e.right;null!==t.left;)t=t.left;return t}{t=e.parent;let n=e;for(;null!==t&&n===t.right;)n=t,t=t.parent;return t}}size(){return this.size_}containsKey(e){let t=this.root_;for(;null!==t;){const n=e.compareTo(t.key);if(n<0)t=t.left;else{if(!(n>0))return!0;t=t.right}}return!1}}class Nt{constructor(){Nt.constructor_.apply(this,arguments)}static constructor_(){this.nodeMap=new Mt,this.nodeFact=null;const e=arguments[0];this.nodeFact=e}find(e){return this.nodeMap.get(e)}addNode(){if(arguments[0]instanceof I){const e=arguments[0];let t=this.nodeMap.get(e);return null===t&&(t=this.nodeFact.createNode(e),this.nodeMap.put(e,t)),t}if(arguments[0]instanceof vt){const e=arguments[0],t=this.nodeMap.get(e.getCoordinate());return null===t?(this.nodeMap.put(e.getCoordinate(),e),e):(t.mergeLabel(e),t)}}print(e){for(let t=this.iterator();t.hasNext();){t.next().print(e)}}iterator(){return this.nodeMap.values().iterator()}values(){return this.nodeMap.values()}getBoundaryNodes(e){const t=new j;for(let n=this.iterator();n.hasNext();){const i=n.next();i.getLabel().getLocation(e)===st.BOUNDARY&&t.add(i)}return t}add(e){const t=e.getCoordinate();this.addNode(t).add(e)}}class Dt{static isNorthern(e){return e===Dt.NE||e===Dt.NW}static isOpposite(e,t){if(e===t)return!1;return 2===(e-t+4)%4}static commonHalfPlane(e,t){if(e===t)return e;if(2===(e-t+4)%4)return-1;const n=et?e:t)?3:n}static isInHalfPlane(e,t){return t===Dt.SE?e===Dt.SE||e===Dt.SW:e===t||e===t+1}static quadrant(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){const e=arguments[0],t=arguments[1];if(0===e&&0===t)throw new h("Cannot compute the quadrant for point ( "+e+", "+t+" )");return e>=0?t>=0?Dt.NE:Dt.SE:t>=0?Dt.NW:Dt.SW}if(arguments[0]instanceof I&&arguments[1]instanceof I){const e=arguments[0],t=arguments[1];if(t.x===e.x&&t.y===e.y)throw new h("Cannot compute the quadrant for two identical points "+e);return t.x>=e.x?t.y>=e.y?Dt.NE:Dt.SE:t.y>=e.y?Dt.NW:Dt.SW}}}Dt.NE=0,Dt.NW=1,Dt.SW=2,Dt.SE=3;class Rt{constructor(){Rt.constructor_.apply(this,arguments)}static constructor_(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,1===arguments.length){const e=arguments[0];this._edge=e}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];Rt.constructor_.call(this,e,t,n,null)}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];Rt.constructor_.call(this,e),this.init(t,n),this._label=i}}compareDirection(e){return this._dx===e._dx&&this._dy===e._dy?0:this._quadrant>e._quadrant?1:this._quadrant2){e.linkDirectedEdgesForMinimalEdgeRings();const i=e.buildMinimalRings(),r=this.findShell(i);null!==r?(this.placePolygonHoles(r,i),t.add(r)):n.addAll(i)}else i.add(e)}return i}buildMaximalEdgeRings(e){const t=new j;for(let n=e.iterator();n.hasNext();){const e=n.next();if(e.isInResult()&&e.getLabel().isArea()&&null===e.getEdgeRing()){const n=new Ct(e,this._geometryFactory);t.add(n),n.setInResult()}}return t}placePolygonHoles(e,t){for(let n=t.iterator();n.hasNext();){const t=n.next();t.isHole()&&t.setShell(e)}}getPolygons(){return this.computePolygons(this._shellList)}findShell(e){let t=0,n=null;for(let i=e.iterator();i.hasNext();){const e=i.next();e.isHole()||(n=e,t++)}return x.isTrue(t<=1,"found two shells in MinimalEdgeRing list"),n}add(){if(1===arguments.length){const e=arguments[0];this.add(e.getEdgeEnds(),e.getNodes())}else if(2===arguments.length){const e=arguments[0],t=arguments[1];Ot.linkResultDirectedEdges(t);const n=this.buildMaximalEdgeRings(e),i=new j,r=this.buildMinimalEdgeRings(n,this._shellList,i);this.sortShellsAndHoles(r,this._shellList,i),this.placeFreeHoles(this._shellList,i)}}}class kt{getBounds(){}}class Bt{constructor(){Bt.constructor_.apply(this,arguments)}static constructor_(){this._bounds=null,this._item=null;const e=arguments[0],t=arguments[1];this._bounds=e,this._item=t}getItem(){return this._item}getBounds(){return this._bounds}get interfaces_(){return[kt,g]}}class Gt{constructor(){Gt.constructor_.apply(this,arguments)}static constructor_(){this._size=null,this._items=null,this._size=0,this._items=new j,this._items.add(null)}poll(){if(this.isEmpty())return null;const e=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),e}size(){return this._size}reorder(e){let t=null;const n=this._items.get(e);for(;2*e<=this._size&&(t=2*e,t!==this._size&&this._items.get(t+1).compareTo(this._items.get(t))<0&&t++,this._items.get(t).compareTo(n)<0);e=t)this._items.set(e,this._items.get(t));this._items.set(e,n)}clear(){this._size=0,this._items.clear()}peek(){if(this.isEmpty())return null;return this._items.get(1)}isEmpty(){return 0===this._size}add(e){this._items.add(null),this._size+=1;let t=this._size;for(this._items.set(0,e);e.compareTo(this._items.get(Math.trunc(t/2)))<0;t/=2)this._items.set(t,this._items.get(Math.trunc(t/2)));this._items.set(t,e)}}class zt{insert(e,t){}remove(e,t){}query(){}}class Wt{constructor(){Wt.constructor_.apply(this,arguments)}static constructor_(){if(this._childBoundables=new j,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){const e=arguments[0];this._level=e}}getLevel(){return this._level}size(){return this._childBoundables.size()}getChildBoundables(){return this._childBoundables}addChildBoundable(e){x.isTrue(null===this._bounds),this._childBoundables.add(e)}isEmpty(){return this._childBoundables.isEmpty()}getBounds(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds}get interfaces_(){return[kt,g]}}const Ht={reverseOrder:function(){return{compare:(e,t)=>t.compareTo(e)}},min:function(e){return Ht.sort(e),e.get(0)},sort:function(e,t){const n=e.toArray();t?Z.sort(n,t):Z.sort(n);const i=e.iterator();for(let e=0,t=n.length;ejt.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,e,t),null):(this.expand(this._boundable2,this._boundable1,!0,e,t),null);if(n)return this.expand(this._boundable1,this._boundable2,!1,e,t),null;if(i)return this.expand(this._boundable2,this._boundable1,!0,e,t),null;throw new h("neither boundable is composite")}isLeaves(){return!(jt.isComposite(this._boundable1)||jt.isComposite(this._boundable2))}compareTo(e){const t=e;return this._distancet._distance?1:0}expand(e,t,n,i,r){for(let o=e.getChildBoundables().iterator();o.hasNext();){const e=o.next();let s=null;s=n?new jt(t,e,this._itemDistance):new jt(e,t,this._itemDistance),s.getDistance()1,"Node capacity must be greater than 1"),this._nodeCapacity=e}}static compareDoubles(e,t){return e>t?1:e-2),t.getLevel()===e)return n.add(t),null;for(let i=t.getChildBoundables().iterator();i.hasNext();){const t=i.next();t instanceof Wt?this.boundablesAtLevel(e,t,n):(x.isTrue(t instanceof Bt),-1===e&&n.add(t))}return null}}query(){if(1===arguments.length){const e=arguments[0];this.build();const t=new j;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.queryInternal(e,this._root,t),t}if(2===arguments.length){const e=arguments[0],t=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.queryInternal(e,this._root,t)}}build(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0}getRoot(){return this.build(),this._root}remove(){if(2===arguments.length){const e=arguments[0],t=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.remove(e,this._root,t)}if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];let i=this.removeItem(t,n);if(i)return!0;let r=null;for(let o=t.getChildBoundables().iterator();o.hasNext();){const t=o.next();if(this.getIntersectsOp().intersects(t.getBounds(),e)&&(t instanceof Wt&&(i=this.remove(e,t,n),i))){r=t;break}}return null!==r&&r.getChildBoundables().isEmpty()&&t.getChildBoundables().remove(r),i}}createHigherLevels(e,t){x.isTrue(!e.isEmpty());const n=this.createParentBoundables(e,t+1);return 1===n.size()?n.get(0):this.createHigherLevels(n,t+1)}depth(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(1===arguments.length){let e=0;for(let t=arguments[0].getChildBoundables().iterator();t.hasNext();){const n=t.next();if(n instanceof Wt){const t=this.depth(n);t>e&&(e=t)}}return e+1}}createParentBoundables(e,t){x.isTrue(!e.isEmpty());const n=new j;n.add(this.createNode(t));const i=new j(e);Ht.sort(i,this.getComparator());for(let e=i.iterator();e.hasNext();){const i=e.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(t)),this.lastNode(n).addChildBoundable(i)}return n}isEmpty(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}get interfaces_(){return[g]}}Yt.IntersectsOp=function(){},Yt.DEFAULT_NODE_CAPACITY=10;class qt{distance(e,t){}}class Kt extends Yt{constructor(){super(),Kt.constructor_.apply(this,arguments)}static constructor_(){if(0===arguments.length)Kt.constructor_.call(this,Kt.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){const e=arguments[0];Yt.constructor_.call(this,e)}}static centreX(e){return Kt.avg(e.getMinX(),e.getMaxX())}static avg(e,t){return(e+t)/2}static getItems(e){const t=new Array(e.size()).fill(null);let n=0;for(;!e.isEmpty();){const i=e.poll();t[n]=i.getBoundable(0).getItem(),n++}return t}static centreY(e){return Kt.avg(e.getMinY(),e.getMaxY())}createParentBoundablesFromVerticalSlices(e,t){x.isTrue(e.length>0);const n=new j;for(let i=0;i=0;){const e=i.poll(),o=e.getDistance();if(o>=n)break;if(e.isLeaves())if(r.size()o&&(r.poll(),r.add(e));n=r.peek().getDistance()}else e.expandToQueue(i,n)}return Kt.getItems(r)}}createNode(e){return new Xt(e)}size(){return 0===arguments.length?super.size.call(this):super.size.apply(this,arguments)}insert(){if(!(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof E))return super.insert.apply(this,arguments);{const e=arguments[0],t=arguments[1];if(e.isNull())return null;super.insert.call(this,e,t)}}getIntersectsOp(){return Kt.intersectsOp}verticalSlices(e,t){const n=Math.trunc(Math.ceil(e.size()/t)),i=new Array(t).fill(null),r=e.iterator();for(let e=0;e0;){const e=i.poll(),r=e.getDistance();if(r>=t)break;e.isLeaves()?(t=r,n=e):e.expandToQueue(i,t)}return null===n?null:[n.getBoundable(0).getItem(),n.getBoundable(1).getItem()]}}else{if(2===arguments.length){const e=arguments[0],t=arguments[1];if(this.isEmpty()||e.isEmpty())return null;const n=new jt(this.getRoot(),e.getRoot(),t);return this.nearestNeighbour(n)}if(3===arguments.length){const e=arguments[2],t=new Bt(arguments[0],arguments[1]),n=new jt(this.getRoot(),t,e);return this.nearestNeighbour(n)[0]}if(4===arguments.length){const e=arguments[2],t=arguments[3],n=new Bt(arguments[0],arguments[1]),i=new jt(this.getRoot(),n,e);return this.nearestNeighbourK(i,t)}}}isWithinDistance(){if(2===arguments.length){const e=arguments[0],t=arguments[1];let n=_.POSITIVE_INFINITY;const i=new Gt;for(i.add(e);!i.isEmpty();){const e=i.poll(),r=e.getDistance();if(r>t)return!1;if(e.maximumDistance()<=t)return!0;if(e.isLeaves()){if(n=r,n<=t)return!0}else e.expandToQueue(i,n)}return!1}if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=new jt(this.getRoot(),e.getRoot(),t);return this.isWithinDistance(i,n)}}get interfaces_(){return[zt,g]}}class Xt extends Wt{constructor(){super(),Xt.constructor_.apply(this,arguments)}static constructor_(){const e=arguments[0];Wt.constructor_.call(this,e)}computeBounds(){let e=null;for(let t=this.getChildBoundables().iterator();t.hasNext();){const n=t.next();null===e?e=new E(n.getBounds()):e.expandToInclude(n.getBounds())}return e}}Kt.STRtreeNode=Xt,Kt.xComparator=new class{get interfaces_(){return[y]}compare(e,t){return Yt.compareDoubles(Kt.centreX(e.getBounds()),Kt.centreX(t.getBounds()))}},Kt.yComparator=new class{get interfaces_(){return[y]}compare(e,t){return Yt.compareDoubles(Kt.centreY(e.getBounds()),Kt.centreY(t.getBounds()))}},Kt.intersectsOp=new class{get interfaces_(){return[IntersectsOp]}intersects(e,t){return e.intersects(t)}},Kt.DEFAULT_NODE_CAPACITY=10;class Jt{static relativeSign(e,t){return et?1:0}static compare(e,t,n){if(t.equals2D(n))return 0;const i=Jt.relativeSign(t.x,n.x),r=Jt.relativeSign(t.y,n.y);switch(e){case 0:return Jt.compareValue(i,r);case 1:return Jt.compareValue(r,i);case 2:return Jt.compareValue(r,-i);case 3:return Jt.compareValue(-i,r);case 4:return Jt.compareValue(-i,-r);case 5:return Jt.compareValue(-r,-i);case 6:return Jt.compareValue(-r,i);case 7:return Jt.compareValue(i,-r)}return x.shouldNeverReachHere("invalid octant value"),0}static compareValue(e,t){return e<0?-1:e>0?1:t<0?-1:t>0?1:0}}class Zt{constructor(){Zt.constructor_.apply(this,arguments)}static constructor_(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];this._segString=e,this.coord=new I(t),this.segmentIndex=n,this._segmentOctant=i,this._isInterior=!t.equals2D(e.getCoordinate(n))}getCoordinate(){return this.coord}print(e){e.print(this.coord),e.print(" seg # = "+this.segmentIndex)}compareTo(e){const t=e;return this.segmentIndext.segmentIndex?1:this.coord.equals2D(t.coord)?0:this._isInterior?t._isInterior?Jt.compare(this._segmentOctant,this.coord,t.coord):1:-1}isEndPoint(e){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===e}toString(){return this.segmentIndex+":"+this.coord.toString()}isInterior(){return this._isInterior}get interfaces_(){return[d]}}class Qt{hasNext(){}next(){}remove(){}}class $t{constructor(){$t.constructor_.apply(this,arguments)}static constructor_(){this._nodeMap=new Mt,this._edge=null;const e=arguments[0];this._edge=e}getSplitCoordinates(){const e=new Y;this.addEndpoints();const t=this.iterator();let n=t.next();for(;t.hasNext();){const i=t.next();this.addEdgeCoordinates(n,i,e),n=i}return e.toCoordinateArray()}addCollapsedNodes(){const e=new j;this.findCollapsesFromInsertedNodes(e),this.findCollapsesFromExistingVertices(e);for(let t=e.iterator();t.hasNext();){const e=t.next().intValue();this.add(this._edge.getCoordinate(e),e)}}createSplitEdgePts(e,t){let n=t.segmentIndex-e.segmentIndex+2;if(2===n)return[new I(e.coord),new I(t.coord)];const i=this._edge.getCoordinate(t.segmentIndex),r=t.isInterior()||!t.coord.equals2D(i);r||n--;const o=new Array(n).fill(null);let s=0;o[s++]=new I(e.coord);for(let n=e.segmentIndex+1;n<=t.segmentIndex;n++)o[s++]=this._edge.getCoordinate(n);return r&&(o[s]=new I(t.coord)),o}print(e){e.println("Intersections:");for(let t=this.iterator();t.hasNext();){t.next().print(e)}}findCollapsesFromExistingVertices(e){for(let t=0;t=0?t>=0?n>=i?0:1:n>=i?7:6:t>=0?n>=i?3:2:n>=i?4:5}if(arguments[0]instanceof I&&arguments[1]instanceof I){const e=arguments[0],t=arguments[1],n=t.x-e.x,i=t.y-e.y;if(0===n&&0===i)throw new h("Cannot compute the octant for two identical points "+e);return en.octant(n,i)}}}class tn{getCoordinates(){}size(){}getCoordinate(e){}isClosed(){}setData(e){}getData(){}}class nn{addIntersection(e,t){}get interfaces_(){return[tn]}}class rn{constructor(){rn.constructor_.apply(this,arguments)}static constructor_(){this._nodeList=new $t(this),this._pts=null,this._data=null;const e=arguments[0],t=arguments[1];this._pts=e,this._data=t}static getNodedSubstrings(){if(1===arguments.length){const e=arguments[0],t=new j;return rn.getNodedSubstrings(e,t),t}if(2===arguments.length){const e=arguments[1];for(let t=arguments[0].iterator();t.hasNext();){t.next().getNodeList().addSplitEdges(e)}}}getCoordinates(){return this._pts}size(){return this._pts.length}getCoordinate(e){return this._pts[e]}isClosed(){return this._pts[0].equals(this._pts[this._pts.length-1])}getSegmentOctant(e){return e===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(e),this.getCoordinate(e+1))}setData(e){this._data=e}safeOctant(e,t){return e.equals2D(t)?0:en.octant(e,t)}getData(){return this._data}addIntersection(){if(2===arguments.length){const e=arguments[0],t=arguments[1];this.addIntersectionNode(e,t)}else if(4===arguments.length){const e=arguments[1],t=arguments[3],n=new I(arguments[0].getIntersection(t));this.addIntersection(n,e)}}toString(){return et.toLineString(new xe(this._pts))}getNodeList(){return this._nodeList}addIntersectionNode(e,t){let n=t;const i=n+1;if(i=e.length-1)return e.length-1;const i=Dt.quadrant(e[n],e[n+1]);let r=t+1;for(;rn.getId()&&(n.computeOverlaps(i,e),this._nOverlaps++),this._segInt.isDone())return null}}}}class un extends on{constructor(){super(),un.constructor_.apply(this,arguments)}static constructor_(){this._si=null;const e=arguments[0];this._si=e}overlap(){if(4!==arguments.length)return super.overlap.apply(this,arguments);{const e=arguments[1],t=arguments[2],n=arguments[3],i=arguments[0].getContext(),r=t.getContext();this._si.processIntersections(i,e,r,n)}}}hn.SegmentOverlapAction=un;class dn{constructor(){dn.constructor_.apply(this,arguments)}static constructor_(){this._inputLine=null,this._distanceTol=null,this._isDeleted=null,this._angleOrientation=ie.COUNTERCLOCKWISE;const e=arguments[0];this._inputLine=e}static simplify(e,t){return new dn(e).simplify(t)}isDeletable(e,t,n,i){const r=this._inputLine[e],o=this._inputLine[t],s=this._inputLine[n];return!!this.isConcave(r,o,s)&&(!!this.isShallow(r,o,s,i)&&this.isShallowSampled(r,o,e,n,i))}deleteShallowConcavities(){let e=1,t=this.findNextNonDeletedIndex(e),n=this.findNextNonDeletedIndex(t),i=!1;for(;n=0;t--)this.addPt(e[t])}isRedundant(e){if(this._ptList.size()<1)return!1;const t=this._ptList.get(this._ptList.size()-1);return e.distance(t)Math.PI;)e-=gn.PI_TIMES_2;for(;e<=-Math.PI;)e+=gn.PI_TIMES_2;return e}static angle(){if(1===arguments.length){const e=arguments[0];return Math.atan2(e.y,e.x)}if(2===arguments.length){const e=arguments[0],t=arguments[1],n=t.x-e.x,i=t.y-e.y;return Math.atan2(i,n)}}static isAcute(e,t,n){const i=e.x-t.x,r=e.y-t.y;return i*(n.x-t.x)+r*(n.y-t.y)>0}static isObtuse(e,t,n){const i=e.x-t.x,r=e.y-t.y;return i*(n.x-t.x)+r*(n.y-t.y)<0}static interiorAngle(e,t,n){const i=gn.angle(t,e),r=gn.angle(t,n);return Math.abs(r-i)}static normalizePositive(e){if(e<0){for(;e<0;)e+=gn.PI_TIMES_2;e>=gn.PI_TIMES_2&&(e=0)}else{for(;e>=gn.PI_TIMES_2;)e-=gn.PI_TIMES_2;e<0&&(e=0)}return e}static angleBetween(e,t,n){const i=gn.angle(t,e),r=gn.angle(t,n);return gn.diff(i,r)}static diff(e,t){let n=null;return n=eMath.PI&&(n=2*Math.PI-n),n}static toRadians(e){return e*Math.PI/180}static getTurn(e,t){const n=Math.sin(t-e);return n>0?gn.COUNTERCLOCKWISE:n<0?gn.CLOCKWISE:gn.NONE}static angleBetweenOriented(e,t,n){const i=gn.angle(t,e),r=gn.angle(t,n)-i;return r<=-Math.PI?r+gn.PI_TIMES_2:r>Math.PI?r-gn.PI_TIMES_2:r}}gn.PI_TIMES_2=2*Math.PI,gn.PI_OVER_2=Math.PI/2,gn.PI_OVER_4=Math.PI/4,gn.COUNTERCLOCKWISE=ie.COUNTERCLOCKWISE,gn.CLOCKWISE=ie.CLOCKWISE,gn.NONE=ie.COLLINEAR;class fn{constructor(){fn.constructor_.apply(this,arguments)}static constructor_(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new it,this._seg1=new it,this._offset0=new it,this._offset1=new it,this._side=0,this._hasNarrowConcaveAngle=!1;const e=arguments[0],t=arguments[1],n=arguments[2];this._precisionModel=e,this._bufParams=t,this._li=new nt,this._filletAngleQuantum=Math.PI/2/t.getQuadrantSegments(),t.getQuadrantSegments()>=8&&t.getJoinStyle()===ot.JOIN_ROUND&&(this._closingSegLengthFactor=fn.MAX_CLOSING_SEG_LEN_FACTOR),this.init(n)}addNextSegment(e,t){if(this._s0=this._s1,this._s1=this._s2,this._s2=e,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;const n=ie.index(this._s0,this._s1,this._s2),i=n===ie.CLOCKWISE&&this._side===at.LEFT||n===ie.COUNTERCLOCKWISE&&this._side===at.RIGHT;0===n?this.addCollinear(t):i?this.addOutsideTurn(n,t):this.addInsideTurn(n,t)}addLineEndCap(e,t){const n=new it(e,t),i=new it;this.computeOffsetSegment(n,at.LEFT,this._distance,i);const r=new it;this.computeOffsetSegment(n,at.RIGHT,this._distance,r);const o=t.x-e.x,s=t.y-e.y,a=Math.atan2(s,o);switch(this._bufParams.getEndCapStyle()){case ot.CAP_ROUND:this._segList.addPt(i.p1),this.addDirectedFillet(t,a+Math.PI/2,a-Math.PI/2,ie.CLOCKWISE,this._distance),this._segList.addPt(r.p1);break;case ot.CAP_FLAT:this._segList.addPt(i.p1),this._segList.addPt(r.p1);break;case ot.CAP_SQUARE:const e=new I;e.x=Math.abs(this._distance)*Math.cos(a),e.y=Math.abs(this._distance)*Math.sin(a);const n=new I(i.p1.x+e.x,i.p1.y+e.y),o=new I(r.p1.x+e.x,r.p1.y+e.y);this._segList.addPt(n),this._segList.addPt(o)}}getCoordinates(){return this._segList.getCoordinates()}addMitreJoin(e,t,n,i){const r=Pe.intersection(t.p0,t.p1,n.p0,n.p1);if(null!==r){if((i<=0?1:r.distance(e)/Math.abs(i))<=this._bufParams.getMitreLimit())return this._segList.addPt(r),null}this.addLimitedMitreJoin(t,n,i,this._bufParams.getMitreLimit())}addOutsideTurn(e,t){if(this._offset0.p1.distance(this._offset1.p0)=h&&(a-=2*Math.PI),this._segList.addPt(t),this.addDirectedFillet(e,a,h,i,r),this._segList.addPt(n)}addLastSegment(){this._segList.addPt(this._offset1.p1)}initSideSegments(e,t,n){this._s1=e,this._s2=t,this._side=n,this._seg1.setCoordinates(e,t),this.computeOffsetSegment(this._seg1,n,this._distance,this._offset1)}addLimitedMitreJoin(e,t,n,i){const r=this._seg0.p1,o=gn.angle(r,this._seg0.p0),s=gn.angleBetweenOriented(this._seg0.p0,r,this._seg1.p1)/2,a=gn.normalize(o+s),l=gn.normalize(a+Math.PI),c=i*n,h=n-c*Math.abs(Math.sin(s)),u=r.x+c*Math.cos(l),d=r.y+c*Math.sin(l),m=new I(u,d),g=new it(r,m),f=g.pointAlongOffset(1,h),p=g.pointAlongOffset(1,-h);this._side===at.LEFT?(this._segList.addPt(f),this._segList.addPt(p)):(this._segList.addPt(p),this._segList.addPt(f))}addDirectedFillet(e,t,n,i,r){const o=i===ie.CLOCKWISE?-1:1,s=Math.abs(t-n),a=Math.trunc(s/this._filletAngleQuantum+.5);if(a<1)return null;const l=s/a,c=new I;for(let n=0;n0){const e=new I((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(e);const t=new I((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(t)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}createCircle(e){const t=new I(e.x+this._distance,e.y);this._segList.addPt(t),this.addDirectedFillet(e,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}addBevelJoin(e,t){this._segList.addPt(e.p1),this._segList.addPt(t.p0)}init(e){this._distance=e,this._maxCurveSegmentError=e*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new mn,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(e*fn.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}addCollinear(e){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2);this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===ot.JOIN_BEVEL||this._bufParams.getJoinStyle()===ot.JOIN_MITRE?(e&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,ie.CLOCKWISE,this._distance))}closeRing(){this._segList.closeRing()}hasNarrowConcaveAngle(){return this._hasNarrowConcaveAngle}}fn.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,fn.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,fn.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,fn.MAX_CLOSING_SEG_LEN_FACTOR=80;class pn{constructor(){pn.constructor_.apply(this,arguments)}static constructor_(){this._distance=0,this._precisionModel=null,this._bufParams=null;const e=arguments[0],t=arguments[1];this._precisionModel=e,this._bufParams=t}static copyCoordinates(e){const t=new Array(e.length).fill(null);for(let n=0;n=0;e--)n.addNextSegment(t[e],!0)}else{n.addSegments(e,!1);const t=dn.simplify(e,i),r=t.length-1;n.initSideSegments(t[0],t[1],at.LEFT),n.addFirstSegment();for(let e=2;e<=r;e++)n.addNextSegment(t[e],!0)}n.addLastSegment(),n.closeRing()}computeRingBufferCurve(e,t,n){let i=this.simplifyTolerance(this._distance);t===at.RIGHT&&(i=-i);const r=dn.simplify(e,i),o=r.length-1;n.initSideSegments(r[o-1],r[0],t);for(let e=1;e<=o;e++){const t=1!==e;n.addNextSegment(r[e],t)}n.closeRing()}computeLineBufferCurve(e,t){const n=this.simplifyTolerance(this._distance),i=dn.simplify(e,n),r=i.length-1;t.initSideSegments(i[0],i[1],at.LEFT);for(let e=2;e<=r;e++)t.addNextSegment(i[e],!0);t.addLastSegment(),t.addLineEndCap(i[r-1],i[r]);const o=dn.simplify(e,-n),s=o.length-1;t.initSideSegments(o[s],o[s-1],at.LEFT);for(let e=s-2;e>=0;e--)t.addNextSegment(o[e],!0);t.addLastSegment(),t.addLineEndCap(o[1],o[0]),t.closeRing()}computePointCurve(e,t){switch(this._bufParams.getEndCapStyle()){case ot.CAP_ROUND:t.createCircle(e);break;case ot.CAP_SQUARE:t.createSquare(e)}}getLineCurve(e,t){if(this._distance=t,this.isLineOffsetEmpty(t))return null;const n=Math.abs(t),i=this.getSegGen(n);if(e.length<=1)this.computePointCurve(e[0],i);else if(this._bufParams.isSingleSided()){const n=t<0;this.computeSingleSidedBufferCurve(e,n,i)}else this.computeLineBufferCurve(e,i);return i.getCoordinates()}getBufferParameters(){return this._bufParams}simplifyTolerance(e){return e*this._bufParams.getSimplifyFactor()}getRingCurve(e,t,n){if(this._distance=n,e.length<=2)return this.getLineCurve(e,n);if(0===n)return pn.copyCoordinates(e);const i=this.getSegGen(n);return this.computeRingBufferCurve(e,t,i),i.getCoordinates()}computeOffsetCurve(e,t,n){const i=this.simplifyTolerance(this._distance);if(t){const t=dn.simplify(e,-i),r=t.length-1;n.initSideSegments(t[r],t[r-1],at.LEFT),n.addFirstSegment();for(let e=r-2;e>=0;e--)n.addNextSegment(t[e],!0)}else{const t=dn.simplify(e,i),r=t.length-1;n.initSideSegments(t[0],t[1],at.LEFT),n.addFirstSegment();for(let e=2;e<=r;e++)n.addNextSegment(t[e],!0)}n.addLastSegment()}isLineOffsetEmpty(e){return 0===e||e<0&&!this._bufParams.isSingleSided()}getSegGen(e){return new fn(this._precisionModel,this._bufParams,e)}}class _n{constructor(){_n.constructor_.apply(this,arguments)}static constructor_(){this._subgraphs=null,this._seg=new it;const e=arguments[0];this._subgraphs=e}findStabbedSegments(){if(1===arguments.length){const e=arguments[0],t=new j;for(let n=this._subgraphs.iterator();n.hasNext();){const i=n.next(),r=i.getEnvelope();e.yr.getMaxY()||this.findStabbedSegments(e,i.getDirectedEdges(),t)}return t}if(3===arguments.length)if(N(arguments[2],H)&&arguments[0]instanceof I&&arguments[1]instanceof Pt){const e=arguments[0],t=arguments[1],n=arguments[2],i=t.getEdge().getCoordinates();for(let r=0;rthis._seg.p1.y&&this._seg.reverse();if(Math.max(this._seg.p0.x,this._seg.p1.x)this._seg.p1.y)continue;if(ie.index(this._seg.p0,this._seg.p1,e)===ie.RIGHT)continue;let o=t.getDepth(at.LEFT);this._seg.p0.equals(i[r])||(o=t.getDepth(at.RIGHT));const s=new yn(this._seg,o);n.add(s)}}else if(N(arguments[2],H)&&arguments[0]instanceof I&&N(arguments[1],H)){const e=arguments[0],t=arguments[2];for(let n=arguments[1].iterator();n.hasNext();){const i=n.next();i.isForward()&&this.findStabbedSegments(e,i,t)}}}getDepth(e){const t=this.findStabbedSegments(e);if(0===t.size())return 0;return Ht.min(t)._leftDepth}}class yn{constructor(){yn.constructor_.apply(this,arguments)}static constructor_(){this._upwardSeg=null,this._leftDepth=null;const e=arguments[0],t=arguments[1];this._upwardSeg=new it(e),this._leftDepth=t}compareTo(e){const t=e;if(this._upwardSeg.minX()>=t._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=t._upwardSeg.minX())return-1;let n=this._upwardSeg.orientationIndex(t._upwardSeg);return 0!==n?n:(n=-1*t._upwardSeg.orientationIndex(this._upwardSeg),0!==n?n:this._upwardSeg.compareTo(t._upwardSeg))}compareX(e,t){const n=e.p0.compareTo(t.p0);return 0!==n?n:e.p1.compareTo(t.p1)}toString(){return this._upwardSeg.toString()}get interfaces_(){return[d]}}_n.DepthSegment=yn;class bn extends c{constructor(){super(),bn.constructor_.apply(this,arguments)}static constructor_(){c.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}class Cn{constructor(){Cn.constructor_.apply(this,arguments)}static constructor_(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){const e=arguments[0];this.x=e.x,this.y=e.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){const e=arguments[0],t=arguments[1];this.x=e,this.y=t,this.w=1}else if(arguments[0]instanceof Cn&&arguments[1]instanceof Cn){const e=arguments[0],t=arguments[1];this.x=e.y*t.w-t.y*e.w,this.y=t.x*e.w-e.x*t.w,this.w=e.x*t.y-t.x*e.y}else if(arguments[0]instanceof I&&arguments[1]instanceof I){const e=arguments[0],t=arguments[1];this.x=e.y-t.y,this.y=t.x-e.x,this.w=e.x*t.y-t.x*e.y}}else if(3===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2];this.x=e,this.y=t,this.w=n}else if(4===arguments.length){const e=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3],r=e.y-t.y,o=t.x-e.x,s=e.x*t.y-t.x*e.y,a=n.y-i.y,l=i.x-n.x,c=n.x*i.y-i.x*n.y;this.x=o*c-l*s,this.y=a*s-r*c,this.w=r*l-a*o}}getY(){const e=this.y/this.w;if(_.isNaN(e)||_.isInfinite(e))throw new bn;return e}getX(){const e=this.x/this.w;if(_.isNaN(e)||_.isInfinite(e))throw new bn;return e}getCoordinate(){const e=new I;return e.x=this.getX(),e.y=this.getY(),e}}class xn{constructor(){xn.constructor_.apply(this,arguments)}static constructor_(){this.p0=null,this.p1=null,this.p2=null;const e=arguments[0],t=arguments[1],n=arguments[2];this.p0=e,this.p1=t,this.p2=n}static area(e,t,n){return Math.abs(((n.x-e.x)*(t.y-e.y)-(t.x-e.x)*(n.y-e.y))/2)}static signedArea(e,t,n){return((n.x-e.x)*(t.y-e.y)-(t.x-e.x)*(n.y-e.y))/2}static det(e,t,n,i){return e*i-t*n}static interpolateZ(e,t,n,i){const r=t.x,o=t.y,s=n.x-r,a=i.x-r,l=n.y-o,c=i.y-o,h=s*c-a*l,u=e.x-r,d=e.y-o,m=(c*u-a*d)/h,g=(-l*u+s*d)/h;return t.getZ()+m*(n.getZ()-t.getZ())+g*(i.getZ()-t.getZ())}static longestSideLength(e,t,n){const i=e.distance(t),r=t.distance(n),o=n.distance(e);let s=i;return r>s&&(s=r),o>s&&(s=o),s}static circumcentreDD(e,t,n){const i=te.valueOf(e.x).subtract(n.x),r=te.valueOf(e.y).subtract(n.y),o=te.valueOf(t.x).subtract(n.x),s=te.valueOf(t.y).subtract(n.y),a=te.determinant(i,r,o,s).multiply(2),l=i.sqr().add(r.sqr()),c=o.sqr().add(s.sqr()),h=te.determinant(r,l,s,c),u=te.determinant(i,l,o,c),d=te.valueOf(n.x).subtract(h.divide(a)).doubleValue(),m=te.valueOf(n.y).add(u.divide(a)).doubleValue();return new I(d,m)}static isAcute(e,t,n){return!!gn.isAcute(e,t,n)&&(!!gn.isAcute(t,n,e)&&!!gn.isAcute(n,e,t))}static circumcentre(e,t,n){const i=n.x,r=n.y,o=e.x-i,s=e.y-r,a=t.x-i,l=t.y-r,c=2*xn.det(o,s,a,l),h=xn.det(s,o*o+s*s,l,a*a+l*l),u=xn.det(o,o*o+s*s,a,a*a+l*l);return new I(i-h/c,r+u/c)}static perpendicularBisector(e,t){const n=t.x-e.x,i=t.y-e.y,r=new Cn(e.x+n/2,e.y+i/2,1),o=new Cn(e.x-i+n/2,e.y+n+i/2,1);return new Cn(r,o)}static angleBisector(e,t,n){const i=t.distance(e),r=i/(i+t.distance(n)),o=n.x-e.x,s=n.y-e.y;return new I(e.x+r*o,e.y+r*s)}static area3D(e,t,n){const i=t.x-e.x,r=t.y-e.y,o=t.getZ()-e.getZ(),s=n.x-e.x,a=n.y-e.y,l=n.getZ()-e.getZ(),c=r*l-o*a,h=o*s-i*l,u=i*a-r*s,d=c*c+h*h+u*u;return Math.sqrt(d)/2}static centroid(e,t,n){const i=(e.x+t.x+n.x)/3,r=(e.y+t.y+n.y)/3;return new I(i,r)}static inCentre(e,t,n){const i=t.distance(n),r=e.distance(n),o=e.distance(t),s=i+r+o,a=(i*e.x+r*t.x+o*n.x)/s,l=(i*e.y+r*t.y+o*n.y)/s;return new I(a,l)}area(){return xn.area(this.p0,this.p1,this.p2)}signedArea(){return xn.signedArea(this.p0,this.p1,this.p2)}interpolateZ(e){if(null===e)throw new h("Supplied point is null.");return xn.interpolateZ(e,this.p0,this.p1,this.p2)}longestSideLength(){return xn.longestSideLength(this.p0,this.p1,this.p2)}isAcute(){return xn.isAcute(this.p0,this.p1,this.p2)}circumcentre(){return xn.circumcentre(this.p0,this.p1,this.p2)}area3D(){return xn.area3D(this.p0,this.p1,this.p2)}centroid(){return xn.centroid(this.p0,this.p1,this.p2)}inCentre(){return xn.inCentre(this.p0,this.p1,this.p2)}}class vn{constructor(){vn.constructor_.apply(this,arguments)}static constructor_(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new j;const e=arguments[0],t=arguments[1],n=arguments[2];this._inputGeom=e,this._distance=t,this._curveBuilder=n}addRingSide(e,t,n,i,r){if(0===t&&e.length=de.MINIMUM_VALID_SIZE&&ie.isCCW(e)&&(o=r,s=i,n=at.opposite(n));const a=this._curveBuilder.getRingCurve(e,n,t);this.addCurve(a,o,s)}addRingBothSides(e,t){this.addRingSide(e,t,at.LEFT,st.EXTERIOR,st.INTERIOR),this.addRingSide(e,t,at.RIGHT,st.INTERIOR,st.EXTERIOR)}addPoint(e){if(this._distance<=0)return null;const t=e.getCoordinates(),n=this._curveBuilder.getLineCurve(t,this._distance);this.addCurve(n,st.EXTERIOR,st.INTERIOR)}addPolygon(e){let t=this._distance,n=at.LEFT;this._distance<0&&(t=-this._distance,n=at.RIGHT);const i=e.getExteriorRing(),r=be.removeRepeatedPoints(i.getCoordinates());if(this._distance<0&&this.isErodedCompletely(i,this._distance))return null;if(this._distance<=0&&r.length<3)return null;this.addRingSide(r,t,n,st.EXTERIOR,st.INTERIOR);for(let i=0;i0&&this.isErodedCompletely(r,-this._distance)||this.addRingSide(o,t,at.opposite(n),st.INTERIOR,st.EXTERIOR)}}isTriangleErodedCompletely(e,t){const n=new xn(e[0],e[1],e[2]),i=n.inCentre();return Le.pointToSegment(i,n.p0,n.p1)r}addCollection(e){for(let t=0;t=this._max)throw new U;const e=this._parent.getGeometryN(this._index++);return e instanceof he?(this._subcollectionIterator=new Tn(e),this._subcollectionIterator.next()):e}remove(){throw new L(this.getClass().getName())}hasNext(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}get interfaces_(){return[Qt]}}class In{constructor(){In.constructor_.apply(this,arguments)}static constructor_(){this._geom=null;const e=arguments[0];this._geom=e}static locatePointInPolygon(e,t){if(t.isEmpty())return st.EXTERIOR;const n=t.getExteriorRing(),i=In.locatePointInRing(e,n);if(i!==st.INTERIOR)return i;for(let n=0;n=0;n--){const i=this._edgeList.get(n),r=i.getSym();null===t&&(t=r),null!==e&&r.setNext(e),e=i}t.setNext(e)}computeDepths(){if(1===arguments.length){const e=arguments[0],t=this.findIndex(e),n=e.getDepth(at.LEFT),i=e.getDepth(at.RIGHT),r=this.computeDepths(t+1,this._edgeList.size(),n);if(this.computeDepths(0,t,r)!==i)throw new ut("depth mismatch at "+e.getCoordinate())}else if(3===arguments.length){const e=arguments[1];let t=arguments[2];for(let n=arguments[0];n=0;r--){const o=this._resultAreaEdgeList.get(r),s=o.getSym();switch(null===t&&o.getEdgeRing()===e&&(t=o),i){case this._SCANNING_FOR_INCOMING:if(s.getEdgeRing()!==e)continue;n=s,i=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(o.getEdgeRing()!==e)continue;n.setNextMin(o),i=this._SCANNING_FOR_INCOMING}}i===this._LINKING_TO_OUTGOING&&(x.isTrue(null!==t,"found null for first outgoing dirEdge"),x.isTrue(t.getEdgeRing()===e,"unable to link last incoming dirEdge"),n.setNextMin(t))}getOutgoingDegree(){if(0===arguments.length){let e=0;for(let t=this.iterator();t.hasNext();){t.next().isInResult()&&e++}return e}if(1===arguments.length){const e=arguments[0];let t=0;for(let n=this.iterator();n.hasNext();){n.next().getEdgeRing()===e&&t++}return t}}getLabel(){return this._label}findCoveredLineEdges(){let e=st.NONE;for(let t=this.iterator();t.hasNext();){const n=t.next(),i=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){e=st.INTERIOR;break}if(i.isInResult()){e=st.EXTERIOR;break}}}if(e===st.NONE)return null;let t=e;for(let e=this.iterator();e.hasNext();){const n=e.next(),i=n.getSym();n.isLineEdge()?n.getEdge().setCovered(t===st.INTERIOR):(n.isInResult()&&(t=st.EXTERIOR),i.isInResult()&&(t=st.INTERIOR))}}computeLabelling(e){super.computeLabelling.call(this,e),this._label=new _t(st.NONE);for(let e=this.iterator();e.hasNext();){const t=e.next().getEdge().getLabel();for(let e=0;e<2;e++){const n=t.getLocation(e);n!==st.INTERIOR&&n!==st.BOUNDARY||this._label.setLocation(e,st.INTERIOR)}}}}class An extends Lt{constructor(){super()}createNode(e){return new vt(e,new En)}}class Mn{constructor(){Mn.constructor_.apply(this,arguments)}static constructor_(){this._pts=null,this._orientation=null;const e=arguments[0];this._pts=e,this._orientation=Mn.orientation(e)}static orientation(e){return 1===be.increasingDirection(e)}static compareOriented(e,t,n,i){const r=t?1:-1,o=i?1:-1,s=t?e.length:-1,a=i?n.length:-1;let l=t?0:e.length-1,c=i?0:n.length-1;for(;;){const t=e[l].compareTo(n[c]);if(0!==t)return t;l+=r,c+=o;const i=l===s,h=c===a;if(i&&!h)return-1;if(!i&&h)return 1;if(i&&h)return 0}}compareTo(e){const t=e;return Mn.compareOriented(this._pts,this._orientation,t._pts,t._orientation)}get interfaces_(){return[d]}}class Nn{constructor(){Nn.constructor_.apply(this,arguments)}static constructor_(){this._edges=new j,this._ocaMap=new Mt}print(e){e.print("MULTILINESTRING ( ");for(let t=0;t0&&e.print(","),e.print("(");const i=n.getCoordinates();for(let t=0;t