deeptwins-engine-3d 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/assets/Build/DeepTwins/Image/line.png +0 -0
- package/dist/assets/Build/DeepTwins/Image/qingtian/backav9.jpg +0 -0
- package/dist/assets/Build/DeepTwins/Image/qingtian/bottomav9.jpg +0 -0
- package/dist/assets/Build/DeepTwins/Image/qingtian/frontav9.jpg +0 -0
- package/dist/assets/Build/DeepTwins/Image/qingtian/leftav9.jpg +0 -0
- package/dist/assets/Build/DeepTwins/Image/qingtian/rightav9.jpg +0 -0
- package/dist/assets/Build/DeepTwins/Image/qingtian/topav9.jpg +0 -0
- package/dist/assets/Build/DeepTwins/Image/video-mask.png +0 -0
- package/dist/assets/Build/DeepTwins/Image/wall.png +0 -0
- package/dist/assets/Build/DeepTwins/Image/wanxia/SunSetBack.png +0 -0
- package/dist/assets/Build/DeepTwins/Image/wanxia/SunSetDown.png +0 -0
- package/dist/assets/Build/DeepTwins/Image/wanxia/SunSetFront.png +0 -0
- package/dist/assets/Build/DeepTwins/Image/wanxia/SunSetLeft.png +0 -0
- package/dist/assets/Build/DeepTwins/Image/wanxia/SunSetRight.png +0 -0
- package/dist/assets/Build/DeepTwins/Image/wanxia/SunSetUp.png +0 -0
- package/dist/assets/Build/DeepTwins/YunJing/yunjing-for-cesium.js +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_0.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_1.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_10.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_11.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_12.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_13.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_14.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_15.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_16.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_17.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_18.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_19.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_2.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_20.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_21.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_22.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_23.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_24.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_25.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_26.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_27.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_3.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_4.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_5.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_6.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_7.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_8.json +1 -0
- package/dist/assets/Build/Map3d/Assets/IAU2006_XYS/IAU2006_XYS_9.json +1 -0
- package/dist/assets/Build/Map3d/Assets/Images/bing_maps_credit.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Images/cesium_credit.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Images/google_earth_credit.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Images/ion-credit.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/LensFlare/DirtMask.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/LensFlare/StarBurst.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/0/0/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/0/1/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/1/0/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/1/0/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/1/1/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/1/1/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/1/2/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/1/2/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/1/3/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/1/3/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/0/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/0/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/0/2.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/0/3.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/1/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/1/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/1/2.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/1/3.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/2/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/2/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/2/2.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/2/3.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/3/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/3/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/3/2.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/3/3.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/4/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/4/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/4/2.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/4/3.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/5/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/5/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/5/2.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/5/3.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/6/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/6/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/6/2.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/6/3.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/7/0.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/7/1.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/7/2.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/2/7/3.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/NaturalEarthII/tilemapresource.xml +14 -0
- package/dist/assets/Build/Map3d/Assets/Textures/SkyBox/tycho2t3_80_mx.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/SkyBox/tycho2t3_80_my.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/SkyBox/tycho2t3_80_mz.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/SkyBox/tycho2t3_80_px.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/SkyBox/tycho2t3_80_py.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/SkyBox/tycho2t3_80_pz.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/airfield.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/airport.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/alcohol-shop.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/america-football.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/art-gallery.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/bakery.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/bank.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/bar.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/baseball.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/basketball.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/beer.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/bicycle.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/building.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/bus.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/cafe.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/camera.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/campsite.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/car.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/cemetery.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/cesium.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/chemist.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/cinema.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/circle-stroked.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/circle.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/city.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/clothing-store.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/college.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/commercial.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/cricket.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/cross.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/dam.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/danger.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/disability.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/dog-park.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/embassy.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/emergency-telephone.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/entrance.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/farm.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/fast-food.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/ferry.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/fire-station.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/fuel.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/garden.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/gift.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/golf.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/grocery.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/hairdresser.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/harbor.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/heart.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/heliport.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/hospital.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/ice-cream.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/industrial.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/land-use.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/laundry.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/library.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/lighthouse.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/lodging.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/logging.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/london-underground.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/marker-stroked.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/marker.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/minefield.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/mobilephone.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/monument.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/museum.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/music.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/oil-well.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/park.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/park2.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/parking-garage.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/parking.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/pharmacy.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/pitch.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/place-of-worship.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/playground.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/police.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/polling-place.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/post.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/prison.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/rail-above.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/rail-light.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/rail-metro.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/rail-underground.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/rail.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/religious-christian.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/religious-jewish.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/religious-muslim.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/restaurant.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/roadblock.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/rocket.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/school.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/scooter.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/shop.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/skiing.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/slaughterhouse.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/soccer.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/square-stroked.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/square.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/star-stroked.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/star.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/suitcase.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/swimming.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/telephone.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/tennis.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/theatre.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/toilets.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/town-hall.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/town.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/triangle-stroked.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/triangle.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/village.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/warehouse.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/waste-basket.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/water.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/wetland.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/maki/zoo.png +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/moonSmall.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/pin.svg +1 -0
- package/dist/assets/Build/Map3d/Assets/Textures/waterNormals.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/Textures/waterNormalsSmall.jpg +0 -0
- package/dist/assets/Build/Map3d/Assets/approximateTerrainHeights.json +1 -0
- package/dist/assets/Build/Map3d/Cesium.js +16071 -0
- package/dist/assets/Build/Map3d/ThirdParty/Workers/package.json +1 -0
- package/dist/assets/Build/Map3d/ThirdParty/Workers/pako_deflate.min.js +1 -0
- package/dist/assets/Build/Map3d/ThirdParty/Workers/pako_inflate.min.js +1 -0
- package/dist/assets/Build/Map3d/ThirdParty/Workers/z-worker-pako.js +1 -0
- package/dist/assets/Build/Map3d/ThirdParty/basis_transcoder.wasm +0 -0
- package/dist/assets/Build/Map3d/ThirdParty/draco_decoder.wasm +0 -0
- package/dist/assets/Build/Map3d/ThirdParty/google-earth-dbroot-parser.js +1 -0
- package/dist/assets/Build/Map3d/Widgets/Animation/Animation.css +127 -0
- package/dist/assets/Build/Map3d/Widgets/Animation/lighter.css +70 -0
- package/dist/assets/Build/Map3d/Widgets/BaseLayerPicker/BaseLayerPicker.css +108 -0
- package/dist/assets/Build/Map3d/Widgets/BaseLayerPicker/lighter.css +22 -0
- package/dist/assets/Build/Map3d/Widgets/Cesium3DTilesInspector/Cesium3DTilesInspector.css +102 -0
- package/dist/assets/Build/Map3d/Widgets/CesiumInspector/CesiumInspector.css +113 -0
- package/dist/assets/Build/Map3d/Widgets/CesiumWidget/CesiumWidget.css +119 -0
- package/dist/assets/Build/Map3d/Widgets/CesiumWidget/lighter.css +14 -0
- package/dist/assets/Build/Map3d/Widgets/FullscreenButton/FullscreenButton.css +8 -0
- package/dist/assets/Build/Map3d/Widgets/Geocoder/Geocoder.css +70 -0
- package/dist/assets/Build/Map3d/Widgets/Geocoder/lighter.css +17 -0
- package/dist/assets/Build/Map3d/Widgets/I3SBuildingSceneLayerExplorer/I3SBuildingSceneLayerExplorer.css +27 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/ArcGisMapServiceWorldHillshade.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/ArcGisMapServiceWorldImagery.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/ArcGisMapServiceWorldOcean.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/bingAerial.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/bingAerialLabels.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/bingRoads.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/blueMarble.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/earthAtNight.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/mapQuestOpenStreetMap.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/mapboxSatellite.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/mapboxStreets.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/mapboxTerrain.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/naturalEarthII.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/openStreetMap.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/sentinel-2.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/stadiaAlidadeSmooth.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/stadiaAlidadeSmoothDark.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/stamenToner.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/ImageryProviders/stamenWatercolor.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/NavigationHelp/Mouse.svg +84 -0
- package/dist/assets/Build/Map3d/Widgets/Images/NavigationHelp/MouseLeft.svg +76 -0
- package/dist/assets/Build/Map3d/Widgets/Images/NavigationHelp/MouseMiddle.svg +76 -0
- package/dist/assets/Build/Map3d/Widgets/Images/NavigationHelp/MouseRight.svg +76 -0
- package/dist/assets/Build/Map3d/Widgets/Images/NavigationHelp/Touch.svg +120 -0
- package/dist/assets/Build/Map3d/Widgets/Images/NavigationHelp/TouchDrag.svg +129 -0
- package/dist/assets/Build/Map3d/Widgets/Images/NavigationHelp/TouchRotate.svg +76 -0
- package/dist/assets/Build/Map3d/Widgets/Images/NavigationHelp/TouchTilt.svg +135 -0
- package/dist/assets/Build/Map3d/Widgets/Images/NavigationHelp/TouchZoom.svg +74 -0
- package/dist/assets/Build/Map3d/Widgets/Images/TerrainProviders/CesiumWorldTerrain.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/TerrainProviders/Ellipsoid.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/TimelineIcons.png +0 -0
- package/dist/assets/Build/Map3d/Widgets/Images/info-loading.gif +0 -0
- package/dist/assets/Build/Map3d/Widgets/InfoBox/InfoBox.css +92 -0
- package/dist/assets/Build/Map3d/Widgets/InfoBox/InfoBoxDescription.css +178 -0
- package/dist/assets/Build/Map3d/Widgets/NavigationHelpButton/NavigationHelpButton.css +93 -0
- package/dist/assets/Build/Map3d/Widgets/NavigationHelpButton/lighter.css +38 -0
- package/dist/assets/Build/Map3d/Widgets/PerformanceWatchdog/PerformanceWatchdog.css +15 -0
- package/dist/assets/Build/Map3d/Widgets/ProjectionPicker/ProjectionPicker.css +38 -0
- package/dist/assets/Build/Map3d/Widgets/SceneModePicker/SceneModePicker.css +56 -0
- package/dist/assets/Build/Map3d/Widgets/SelectionIndicator/SelectionIndicator.css +20 -0
- package/dist/assets/Build/Map3d/Widgets/Timeline/Timeline.css +103 -0
- package/dist/assets/Build/Map3d/Widgets/Timeline/lighter.css +23 -0
- package/dist/assets/Build/Map3d/Widgets/VRButton/VRButton.css +8 -0
- package/dist/assets/Build/Map3d/Widgets/Viewer/Viewer.css +107 -0
- package/dist/assets/Build/Map3d/Widgets/VoxelInspector/VoxelInspector.css +16 -0
- package/dist/assets/Build/Map3d/Widgets/lighter.css +237 -0
- package/dist/assets/Build/Map3d/Widgets/lighterShared.css +46 -0
- package/dist/assets/Build/Map3d/Widgets/shared.css +103 -0
- package/dist/assets/Build/Map3d/Widgets/widgets.css +1342 -0
- package/dist/assets/Build/Map3d/Workers/chunk-26PPBGHW.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-2H32TJK3.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-3DLZAS7T.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-4RP6ACF6.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-55B3WQ6I.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-6CSMIMD7.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-A4R6HP5H.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-AUO2K2B5.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-BAH467HD.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-BC3RBQRQ.js +28 -0
- package/dist/assets/Build/Map3d/Workers/chunk-CZ6DDD6J.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-D32DZSEC.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-DG7B7W65.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-DLCTHPIV.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-E25VRLIZ.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-E2NX4UJ2.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-EP544XEE.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-EQTQGYI2.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-FMJWH3RL.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-FSU6RZ6S.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-FZEJ65E6.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-GKS4EDRQ.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-GMF7KJHC.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-HZQ2LRMY.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-I2ICH2LD.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-I4G5DYCC.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-IIT3SHXK.js +28 -0
- package/dist/assets/Build/Map3d/Workers/chunk-JBPQP6LH.js +66 -0
- package/dist/assets/Build/Map3d/Workers/chunk-JPOF5MJM.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-K4QHJFYW.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-MDIGQ5JT.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-MNEOPOLK.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-NLPIV6OK.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-NOHRD3OR.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-NYFH7JC3.js +27 -0
- package/dist/assets/Build/Map3d/Workers/chunk-NZWLV2A4.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-OWZATOOT.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-R6A52HT4.js +27 -0
- package/dist/assets/Build/Map3d/Workers/chunk-R6YRFJ3K.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-RCLU4DVL.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-REP6L7BH.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-SOSKHJVT.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-SPFUTSGC.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-TRWH7IZP.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-TTK4OD75.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-VSCNOKDU.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-WDSHVSF7.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-WV3AQKZG.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-XDITHZHZ.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-XLESIVYV.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-YGC52UMX.js +26 -0
- package/dist/assets/Build/Map3d/Workers/chunk-ZRPUDUIP.js +26 -0
- package/dist/assets/Build/Map3d/Workers/combineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createBoxGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createBoxOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createCircleGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createCircleOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createCoplanarPolygonGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createCoplanarPolygonOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createCorridorGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createCorridorOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createCylinderGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createCylinderOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createEllipseGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createEllipseOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createEllipsoidGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createEllipsoidOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createFrustumGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createFrustumOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createGroundPolylineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createPlaneGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createPlaneOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createPolygonGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createPolygonOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createPolylineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createPolylineVolumeGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createPolylineVolumeOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createRectangleGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createRectangleOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createSimplePolylineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createSphereGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createSphereOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createTaskProcessorWorker.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createVectorTileClampedPolylines.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createVectorTileGeometries.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createVectorTilePoints.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createVectorTilePolygons.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createVectorTilePolylines.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createVerticesFromHeightmap.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createVerticesFromQuantizedTerrainMesh.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createWallGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/createWallOutlineGeometry.js +26 -0
- package/dist/assets/Build/Map3d/Workers/decodeDraco.js +26 -0
- package/dist/assets/Build/Map3d/Workers/decodeGoogleEarthEnterprisePacket.js +26 -0
- package/dist/assets/Build/Map3d/Workers/decodeI3S.js +26 -0
- package/dist/assets/Build/Map3d/Workers/transcodeKTX2.js +56 -0
- package/dist/assets/Build/Map3d/Workers/transferTypedArrayTest.js +26 -0
- package/dist/assets/Build/Map3d/Workers/upsampleQuantizedTerrainMesh.js +26 -0
- package/dist/assets/Build/Map3d/index.cjs +16071 -0
- package/dist/assets/Build/Map3d/index.js +16071 -0
- package/dist/cameraControl/ModelRoamHistory.d.ts +28 -0
- package/dist/cameraControl/ModelRoamHistory.js +290 -0
- package/dist/cameraControl/ModelRoamRealTime.d.ts +136 -0
- package/dist/cameraControl/ModelRoamRealTime.js +668 -0
- package/dist/cameraControl/ModelRoamRunTime.d.ts +32 -0
- package/dist/cameraControl/ModelRoamRunTime.js +244 -0
- package/dist/cameraControl/Roam.d.ts +19 -0
- package/dist/cameraControl/Roam.js +414 -0
- package/dist/cameraControl/Rotate.d.ts +11 -0
- package/dist/cameraControl/Rotate.js +110 -0
- package/dist/cameraControl/RotateInPlace.d.ts +11 -0
- package/dist/cameraControl/RotateInPlace.js +96 -0
- package/dist/constant.d.ts +409 -0
- package/dist/constant.js +805 -0
- package/dist/deepTwins/index.d.ts +17 -0
- package/dist/deepTwins/index.js +118 -0
- package/dist/drawer/base.d.ts +51 -0
- package/dist/drawer/base.js +179 -0
- package/dist/drawer/index.d.ts +62 -0
- package/dist/drawer/index.js +350 -0
- package/dist/drawer/painter.d.ts +41 -0
- package/dist/drawer/painter.js +115 -0
- package/dist/drawer/shape/Ellipse.d.ts +10 -0
- package/dist/drawer/shape/Ellipse.js +62 -0
- package/dist/drawer/shape/Point.d.ts +12 -0
- package/dist/drawer/shape/Point.js +59 -0
- package/dist/drawer/shape/Polygon.d.ts +10 -0
- package/dist/drawer/shape/Polygon.js +87 -0
- package/dist/drawer/shape/Polyline.d.ts +11 -0
- package/dist/drawer/shape/Polyline.js +54 -0
- package/dist/drawer/shape/Rectangle.d.ts +10 -0
- package/dist/drawer/shape/Rectangle.js +85 -0
- package/dist/drawer/typings.d.ts +106 -0
- package/dist/drawer/typings.js +1 -0
- package/dist/global.less +3 -0
- package/dist/graphicLayer/BaseEntity.d.ts +12 -0
- package/dist/graphicLayer/BaseEntity.js +45 -0
- package/dist/graphicLayer/BaseLayer.d.ts +29 -0
- package/dist/graphicLayer/BaseLayer.js +340 -0
- package/dist/graphicLayer/BasePointPrimitive.d.ts +10 -0
- package/dist/graphicLayer/BasePointPrimitive.js +41 -0
- package/dist/graphicLayer/BasePrimitive.d.ts +12 -0
- package/dist/graphicLayer/BasePrimitive.js +50 -0
- package/dist/graphicLayer/BasePrimitiveInstance.d.ts +10 -0
- package/dist/graphicLayer/BasePrimitiveInstance.js +37 -0
- package/dist/graphicLayer/BaseSource.d.ts +33 -0
- package/dist/graphicLayer/BaseSource.js +599 -0
- package/dist/graphicLayer/BillboardEntity.d.ts +7 -0
- package/dist/graphicLayer/BillboardEntity.js +109 -0
- package/dist/graphicLayer/BillboardPrimitive.d.ts +7 -0
- package/dist/graphicLayer/BillboardPrimitive.js +95 -0
- package/dist/graphicLayer/BoxEntity.d.ts +7 -0
- package/dist/graphicLayer/BoxEntity.js +102 -0
- package/dist/graphicLayer/BoxPrimitive.d.ts +5 -0
- package/dist/graphicLayer/BoxPrimitive.js +43 -0
- package/dist/graphicLayer/BoxPrimitiveInstance.d.ts +7 -0
- package/dist/graphicLayer/BoxPrimitiveInstance.js +97 -0
- package/dist/graphicLayer/EllipseEntity.d.ts +7 -0
- package/dist/graphicLayer/EllipseEntity.js +113 -0
- package/dist/graphicLayer/EllipsePrimitive.d.ts +5 -0
- package/dist/graphicLayer/EllipsePrimitive.js +42 -0
- package/dist/graphicLayer/EllipsePrimitiveInstance.d.ts +7 -0
- package/dist/graphicLayer/EllipsePrimitiveInstance.js +105 -0
- package/dist/graphicLayer/EllipsoidEntity.d.ts +7 -0
- package/dist/graphicLayer/EllipsoidEntity.js +121 -0
- package/dist/graphicLayer/EllipsoidPrimitive.d.ts +5 -0
- package/dist/graphicLayer/EllipsoidPrimitive.js +43 -0
- package/dist/graphicLayer/EllipsoidPrimitiveInstance.d.ts +7 -0
- package/dist/graphicLayer/EllipsoidPrimitiveInstance.js +117 -0
- package/dist/graphicLayer/GraphicLayerCollection.d.ts +31 -0
- package/dist/graphicLayer/GraphicLayerCollection.js +387 -0
- package/dist/graphicLayer/HtmlEntity.d.ts +19 -0
- package/dist/graphicLayer/HtmlEntity.js +179 -0
- package/dist/graphicLayer/LabelEntity.d.ts +7 -0
- package/dist/graphicLayer/LabelEntity.js +113 -0
- package/dist/graphicLayer/LabelPrimitive.d.ts +7 -0
- package/dist/graphicLayer/LabelPrimitive.js +104 -0
- package/dist/graphicLayer/ModelEntity.d.ts +7 -0
- package/dist/graphicLayer/ModelEntity.js +125 -0
- package/dist/graphicLayer/ModelPrimitive.d.ts +5 -0
- package/dist/graphicLayer/ModelPrimitive.js +46 -0
- package/dist/graphicLayer/ModelPrimitiveInstance.d.ts +7 -0
- package/dist/graphicLayer/ModelPrimitiveInstance.js +96 -0
- package/dist/graphicLayer/PointEntity.d.ts +7 -0
- package/dist/graphicLayer/PointEntity.js +97 -0
- package/dist/graphicLayer/PointPrimitive.d.ts +7 -0
- package/dist/graphicLayer/PointPrimitive.js +83 -0
- package/dist/graphicLayer/PolygonEntity.d.ts +7 -0
- package/dist/graphicLayer/PolygonEntity.js +106 -0
- package/dist/graphicLayer/PolygonPrimitive.d.ts +5 -0
- package/dist/graphicLayer/PolygonPrimitive.js +42 -0
- package/dist/graphicLayer/PolygonPrimitiveInstance.d.ts +7 -0
- package/dist/graphicLayer/PolygonPrimitiveInstance.js +103 -0
- package/dist/graphicLayer/PolylineEntity.d.ts +7 -0
- package/dist/graphicLayer/PolylineEntity.js +99 -0
- package/dist/graphicLayer/PolylinePrimitive.d.ts +5 -0
- package/dist/graphicLayer/PolylinePrimitive.js +48 -0
- package/dist/graphicLayer/PolylinePrimitiveInstance.d.ts +7 -0
- package/dist/graphicLayer/PolylinePrimitiveInstance.js +93 -0
- package/dist/graphicLayer/PolylineVolumeEntity.d.ts +7 -0
- package/dist/graphicLayer/PolylineVolumeEntity.js +107 -0
- package/dist/graphicLayer/PolylineVolumePrimitive.d.ts +5 -0
- package/dist/graphicLayer/PolylineVolumePrimitive.js +42 -0
- package/dist/graphicLayer/PolylineVolumePrimitiveInstance.d.ts +7 -0
- package/dist/graphicLayer/PolylineVolumePrimitiveInstance.js +101 -0
- package/dist/graphicLayer/WallEntity.d.ts +7 -0
- package/dist/graphicLayer/WallEntity.js +99 -0
- package/dist/graphicLayer/WallPrimitive.d.ts +5 -0
- package/dist/graphicLayer/WallPrimitive.js +42 -0
- package/dist/graphicLayer/WallPrimitiveInstance.d.ts +7 -0
- package/dist/graphicLayer/WallPrimitiveInstance.js +95 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +108 -0
- package/dist/map/Event.d.ts +12 -0
- package/dist/map/Event.js +284 -0
- package/dist/map/GroundSkyBox.d.ts +20 -0
- package/dist/map/GroundSkyBox.js +166 -0
- package/dist/map/Map.d.ts +66 -0
- package/dist/map/Map.js +658 -0
- package/dist/map/Property.d.ts +6 -0
- package/dist/map/Property.js +35 -0
- package/dist/material/CircleWaveMaterialProperty.d.ts +17 -0
- package/dist/material/CircleWaveMaterialProperty.js +108 -0
- package/dist/material/DynamicWallMaterialProperty.d.ts +45 -0
- package/dist/material/DynamicWallMaterialProperty.js +162 -0
- package/dist/material/ImageMaterial.d.ts +4 -0
- package/dist/material/ImageMaterial.js +35 -0
- package/dist/material/ImageMaterialProperty.d.ts +4 -0
- package/dist/material/ImageMaterialProperty.js +34 -0
- package/dist/material/PolylineTrailLinkMaterialProperty.d.ts +19 -0
- package/dist/material/PolylineTrailLinkMaterialProperty.js +102 -0
- package/dist/material/WeatherEffects.d.ts +16 -0
- package/dist/material/WeatherEffects.js +159 -0
- package/dist/measure/AreaMeasure.d.ts +19 -0
- package/dist/measure/AreaMeasure.js +97 -0
- package/dist/measure/AreaSurfaceMeasure.d.ts +30 -0
- package/dist/measure/AreaSurfaceMeasure.js +151 -0
- package/dist/measure/DistanceMeasure.d.ts +19 -0
- package/dist/measure/DistanceMeasure.js +91 -0
- package/dist/measure/DistanceSurfaceMeasure.d.ts +37 -0
- package/dist/measure/DistanceSurfaceMeasure.js +122 -0
- package/dist/measure/Measure.d.ts +111 -0
- package/dist/measure/Measure.js +177 -0
- package/dist/measure/index.d.ts +5 -0
- package/dist/measure/index.js +5 -0
- package/dist/measure/utils.d.ts +23 -0
- package/dist/measure/utils.js +58 -0
- package/dist/property/PositionProperty.d.ts +8 -0
- package/dist/property/PositionProperty.js +56 -0
- package/dist/tileLayer/ArcGisLayer.d.ts +5 -0
- package/dist/tileLayer/ArcGisLayer.js +41 -0
- package/dist/tileLayer/ImageryLayer.d.ts +6 -0
- package/dist/tileLayer/ImageryLayer.js +44 -0
- package/dist/tileLayer/RasterLayer.d.ts +4 -0
- package/dist/tileLayer/RasterLayer.js +23 -0
- package/dist/tileLayer/WmsLayer.d.ts +6 -0
- package/dist/tileLayer/WmsLayer.js +26 -0
- package/dist/tileLayer/WmtsLayer.d.ts +4 -0
- package/dist/tileLayer/WmtsLayer.js +23 -0
- package/dist/tool/PrimitiveCluster.d.ts +37 -0
- package/dist/tool/PrimitiveCluster.js +705 -0
- package/dist/tool/TimerInterval.d.ts +10 -0
- package/dist/tool/TimerInterval.js +58 -0
- package/dist/tool/cesiumExtends/Subscriber/index.d.ts +66 -0
- package/dist/tool/cesiumExtends/Subscriber/index.js +246 -0
- package/dist/tool/common.d.ts +36 -0
- package/dist/tool/common.js +388 -0
- package/dist/tool/heatmap.js +631 -0
- package/dist/tool/utils.d.ts +30 -0
- package/dist/tool/utils.js +235 -0
- package/dist/toolTip/index.d.ts +13 -0
- package/dist/toolTip/index.js +73 -0
- package/dist/toolTip/index.less +24 -0
- package/dist/videoFusion/BaseVideo.d.ts +23 -0
- package/dist/videoFusion/BaseVideo.js +255 -0
- package/dist/videoFusion/VideoProject.d.ts +12 -0
- package/dist/videoFusion/VideoProject.js +230 -0
- package/dist/videoFusion/VideoTexture.d.ts +5 -0
- package/dist/videoFusion/VideoTexture.js +70 -0
- package/dist/visualization/Airspace.d.ts +11 -0
- package/dist/visualization/Airspace.js +87 -0
- package/dist/visualization/BaseFrustum.d.ts +12 -0
- package/dist/visualization/BaseFrustum.js +82 -0
- package/dist/visualization/BaseHeatmap.d.ts +23 -0
- package/dist/visualization/BaseHeatmap.js +214 -0
- package/dist/visualization/Frustum.d.ts +5 -0
- package/dist/visualization/Frustum.js +132 -0
- package/dist/visualization/FrustumWithCamera.d.ts +5 -0
- package/dist/visualization/FrustumWithCamera.js +131 -0
- package/dist/visualization/Heatmap2d.d.ts +7 -0
- package/dist/visualization/Heatmap2d.js +79 -0
- package/dist/visualization/Heatmap3d.d.ts +8 -0
- package/dist/visualization/Heatmap3d.js +127 -0
- package/dist/visualization/PointCluster.d.ts +17 -0
- package/dist/visualization/PointCluster.js +181 -0
- package/package.json +103 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"use strict";var n="undefined"!=typeof document?document.currentScript:null;function i(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var r=i(e);class s extends r.Terrain{constructor(t){let e;switch(t.crs){case"gcj02":default:e="China02";break;case"wgs84":e="China84"}const n=`https://amappc.oss-cn-zhangjiakou.aliyuncs.com/gis/gaus/Terrain/${e}`;super(r.CesiumTerrainProvider.fromUrl(n))}}class o extends r.ImageryLayer{constructor(t){super(new r.UrlTemplateImageryProvider({url:"https://webst0{S}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",minimumLevel:3,maximumLevel:t?.maximumLevel||18,customTags:{S:function(t,e,n,i){return(e+n)%4+1}}}))}}var a,u,h,l,c,f,d,p,v,y,m,w,g,b,x,_,k,$,S,M,E,C,A,I,O,T,z,D,P,R,N,F,U,q=Object.defineProperty,j=Object.getOwnPropertyDescriptor,B=Object.getOwnPropertyNames,L={}.hasOwnProperty,H=(a=function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')},typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):a),V=(t,e)=>()=>(t&&(e=t(t=0)),e),W=(t,e)=>{for(var n in e)q(t,n,{get:e[n],enumerable:!0})},G=t=>((t,e,n,i)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let n of B(e))!L.call(t,n)&&void 0!==n&&q(t,n,{get:()=>e[n],enumerable:!(i=j(e,n))||i.enumerable});return t})(q({},"__esModule",{value:!0}),t),Q=V((()=>{u=new Map,h=[],l=(t,e,n)=>{if(!e||"function"!=typeof e.init||"function"!=typeof e.createInferenceSessionHandler)throw new TypeError("not a valid backend");{let i=u.get(t);if(void 0===i)u.set(t,{backend:e,priority:n});else{if(i.priority>n)return;if(i.priority===n&&i.backend!==e)throw new Error(`cannot register backend "${t}" using priority ${n}`)}if(n>=0){let e=h.indexOf(t);-1!==e&&h.splice(e,1);for(let e=0;e<h.length;e++)if(u.get(h[e]).priority<=n)return void h.splice(e,0,t);h.push(t)}}},c=async t=>{let e=u.get(t);if(!e)return"backend not found.";if(e.initialized)return e.backend;if(e.aborted)return e.error;{let n=!!e.initPromise;try{return n||(e.initPromise=e.backend.init(t)),await e.initPromise,e.initialized=!0,e.backend}catch(t){return n||(e.error=`${t}`,e.aborted=!0),e.error}finally{delete e.initPromise}}},f=async t=>{let e,n=t.executionProviders||[],i=n.map((t=>"string"==typeof t?t:t.name)),r=0===i.length?h:i,s=[],o=new Set;for(let t of r){let n=await c(t);"string"==typeof n?s.push({name:t,err:n}):(e||(e=n),e===n&&o.add(t))}if(!e)throw new Error(`no available backend found. ERR: ${s.map((t=>`[${t.name}] ${t.err}`)).join(", ")}`);for(let{name:t,err:e}of s)i.includes(t);let a=n.filter((t=>o.has("string"==typeof t?t:t.name)));return[e,new Proxy(t,{get:(t,e)=>"executionProviders"===e?a:Reflect.get(t,e)})]}})),K=V((()=>{Q()})),X=V((()=>{d="1.19.2"})),Z=V((()=>{X(),p="warning",v={wasm:{},webgl:{},webgpu:{},versions:{common:d},set logLevel(t){if(void 0!==t){if("string"!=typeof t||-1===["verbose","info","warning","error","fatal"].indexOf(t))throw new Error(`Unsupported logging level: ${t}`);p=t}},get logLevel(){return p}},Object.defineProperty(v,"logLevel",{enumerable:!0})})),Y=V((()=>{Z(),y=v})),J=V((()=>{m=(t,e)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=t.dims[3],n.height=t.dims[2];let i=n.getContext("2d");if(null!=i){let r,s;void 0!==e?.tensorLayout&&"NHWC"===e.tensorLayout?(r=t.dims[2],s=t.dims[3]):(r=t.dims[3],s=t.dims[2]);let o,a,u=void 0!==e?.format?e.format:"RGB",h=e?.norm;void 0===h||void 0===h.mean?o=[255,255,255,255]:"number"==typeof h.mean?o=[h.mean,h.mean,h.mean,h.mean]:(o=[h.mean[0],h.mean[1],h.mean[2],0],void 0!==h.mean[3]&&(o[3]=h.mean[3])),void 0===h||void 0===h.bias?a=[0,0,0,0]:"number"==typeof h.bias?a=[h.bias,h.bias,h.bias,h.bias]:(a=[h.bias[0],h.bias[1],h.bias[2],0],void 0!==h.bias[3]&&(a[3]=h.bias[3]));let l=s*r,c=0,f=l,d=2*l,p=-1;"RGBA"===u?(c=0,f=l,d=2*l,p=3*l):"RGB"===u?(c=0,f=l,d=2*l):"RBG"===u&&(c=0,d=l,f=2*l);for(let e=0;e<s;e++)for(let n=0;n<r;n++){let r=(t.data[c++]-a[0])*o[0],s=(t.data[f++]-a[1])*o[1],u=(t.data[d++]-a[2])*o[2],h=-1===p?255:(t.data[p++]-a[3])*o[3];i.fillStyle="rgba("+r+","+s+","+u+","+h+")",i.fillRect(n,e,1,1)}if("toDataURL"in n)return n.toDataURL();throw new Error("toDataURL is not supported")}throw new Error("Can not access image data")},w=(t,e)=>{let n,i=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d");if(null==i)throw new Error("Can not access image data");{let r,s,o;void 0!==e?.tensorLayout&&"NHWC"===e.tensorLayout?(r=t.dims[2],s=t.dims[1],o=t.dims[3]):(r=t.dims[3],s=t.dims[2],o=t.dims[1]);let a,u,h=void 0!==e&&void 0!==e.format?e.format:"RGB",l=e?.norm;void 0===l||void 0===l.mean?a=[255,255,255,255]:"number"==typeof l.mean?a=[l.mean,l.mean,l.mean,l.mean]:(a=[l.mean[0],l.mean[1],l.mean[2],255],void 0!==l.mean[3]&&(a[3]=l.mean[3])),void 0===l||void 0===l.bias?u=[0,0,0,0]:"number"==typeof l.bias?u=[l.bias,l.bias,l.bias,l.bias]:(u=[l.bias[0],l.bias[1],l.bias[2],0],void 0!==l.bias[3]&&(u[3]=l.bias[3]));let c=s*r;if(void 0!==e&&(void 0!==e.format&&4===o&&"RGBA"!==e.format||3===o&&"RGB"!==e.format&&"BGR"!==e.format))throw new Error("Tensor format doesn't match input tensor dims");let f=4,d=0,p=1,v=2,y=3,m=0,w=c,g=2*c,b=-1;"RGBA"===h?(m=0,w=c,g=2*c,b=3*c):"RGB"===h?(m=0,w=c,g=2*c):"RBG"===h&&(m=0,g=c,w=2*c),n=i.createImageData(r,s);for(let e=0;e<s*r;d+=f,p+=f,v+=f,y+=f,e++)n.data[d]=(t.data[m++]-u[0])*a[0],n.data[p]=(t.data[w++]-u[1])*a[1],n.data[v]=(t.data[g++]-u[2])*a[2],n.data[y]=-1===b?255:(t.data[b++]-u[3])*a[3]}return n}})),tt=V((()=>{it(),g=(t,e)=>{if(void 0===t)throw new Error("Image buffer must be defined");if(void 0===e.height||void 0===e.width)throw new Error("Image height and width must be defined");if("NHWC"===e.tensorLayout)throw new Error("NHWC Tensor layout is not supported yet");let n,i,{height:r,width:s}=e,o=e.norm??{mean:255,bias:0};n="number"==typeof o.mean?[o.mean,o.mean,o.mean,o.mean]:[o.mean[0],o.mean[1],o.mean[2],o.mean[3]??255],i="number"==typeof o.bias?[o.bias,o.bias,o.bias,o.bias]:[o.bias[0],o.bias[1],o.bias[2],o.bias[3]??0];let a=void 0!==e.format?e.format:"RGBA",u=void 0!==e.tensorFormat&&void 0!==e.tensorFormat?e.tensorFormat:"RGB",h=r*s,l="RGBA"===u?new Float32Array(4*h):new Float32Array(3*h),c=4,f=0,d=1,p=2,v=3,y=0,m=h,w=2*h,g=-1;"RGB"===a&&(c=3,f=0,d=1,p=2,v=-1),"RGBA"===u?g=3*h:"RBG"===u?(y=0,w=h,m=2*h):"BGR"===u&&(w=0,m=h,y=2*h);for(let e=0;e<h;e++,f+=c,p+=c,d+=c,v+=c)l[y++]=(t[f]+i[0])/n[0],l[m++]=(t[d]+i[1])/n[1],l[w++]=(t[p]+i[2])/n[2],-1!==g&&-1!==v&&(l[g++]=(t[v]+i[3])/n[3]);return new I("float32",l,"RGBA"===u?[1,4,r,s]:[1,3,r,s])},b=async(t,e)=>{let n,i=typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement,r=typeof ImageData<"u"&&t instanceof ImageData,s=typeof ImageBitmap<"u"&&t instanceof ImageBitmap,o="string"==typeof t,a=e??{},u=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},h=t=>t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas?t.getContext("2d"):null;if(i){let i=u();i.width=t.width,i.height=t.height;let r=h(i);if(null==r)throw new Error("Can not access image data");{let i=t.height,s=t.width;if(void 0!==e&&void 0!==e.resizedHeight&&void 0!==e.resizedWidth&&(i=e.resizedHeight,s=e.resizedWidth),void 0!==e){if(a=e,void 0!==e.tensorFormat)throw new Error("Image input config format must be RGBA for HTMLImageElement");a.tensorFormat="RGBA",a.height=i,a.width=s}else a.tensorFormat="RGBA",a.height=i,a.width=s;r.drawImage(t,0,0),n=r.getImageData(0,0,s,i).data}}else{if(!r){if(s){if(void 0===e)throw new Error("Please provide image config with format for Imagebitmap");let i=u();i.width=t.width,i.height=t.height;let r=h(i);if(null!=r){let e=t.height,i=t.width;return r.drawImage(t,0,0,i,e),n=r.getImageData(0,0,i,e).data,a.height=e,a.width=i,g(n,a)}throw new Error("Can not access image data")}if(o)return new Promise(((e,n)=>{let i=u(),r=h(i);if(!t||!r)return n();let s=new Image;s.crossOrigin="Anonymous",s.src=t,s.onload=()=>{i.width=s.width,i.height=s.height,r.drawImage(s,0,0,i.width,i.height);let t=r.getImageData(0,0,i.width,i.height);a.height=i.height,a.width=i.width,e(g(t.data,a))}}));throw new Error("Input data provided is not supported - aborted tensor creation")}{let i,r;if(void 0!==e&&void 0!==e.resizedWidth&&void 0!==e.resizedHeight?(i=e.resizedHeight,r=e.resizedWidth):(i=t.height,r=t.width),void 0!==e&&(a=e),a.format="RGBA",a.height=i,a.width=r,void 0!==e){let e=u();e.width=r,e.height=i;let s=h(e);if(null==s)throw new Error("Can not access image data");s.putImageData(t,0,0),n=s.getImageData(0,0,r,i).data}else n=t.data}}if(void 0!==n)return g(n,a);throw new Error("Input data provided is not supported - aborted tensor creation")},x=(t,e)=>{let{width:n,height:i,download:r,dispose:s}=e;return new I({location:"texture",type:"float32",texture:t,dims:[1,i,n,4],download:r,dispose:s})},_=(t,e)=>{let{dataType:n,dims:i,download:r,dispose:s}=e;return new I({location:"gpu-buffer",type:n??"float32",gpuBuffer:t,dims:i,download:r,dispose:s})},k=(t,e,n)=>new I({location:"cpu-pinned",type:t,data:e,dims:n??[e.length]})})),et=V((()=>{$=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),S=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),M=!1,E=()=>{if(!M){M=!0;let t=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,n=typeof Float16Array<"u"&&Float16Array.from;t&&($.set("int64",BigInt64Array),S.set(BigInt64Array,"int64")),e&&($.set("uint64",BigUint64Array),S.set(BigUint64Array,"uint64")),n?($.set("float16",Float16Array),S.set(Float16Array,"float16")):$.set("float16",Uint16Array)}}})),nt=V((()=>{it(),C=t=>{let e=1;for(let n=0;n<t.length;n++){let i=t[n];if("number"!=typeof i||!Number.isSafeInteger(i))throw new TypeError(`dims[${n}] must be an integer, got: ${i}`);if(i<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${i}`);e*=i}return e},A=(t,e)=>{switch(t.location){case"cpu":return new I(t.type,t.data,e);case"cpu-pinned":return new I({location:"cpu-pinned",data:t.data,type:t.type,dims:e});case"texture":return new I({location:"texture",texture:t.texture,type:t.type,dims:e});case"gpu-buffer":return new I({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${t.location} is not supported`)}}})),it=V((()=>{J(),tt(),et(),nt(),I=class{constructor(t,e,n){let i,r;if(E(),"object"==typeof t&&"location"in t)switch(this.dataLocation=t.location,i=t.type,r=t.dims,t.location){case"cpu-pinned":{let e=$.get(i);if(!e)throw new TypeError(`unsupported type "${i}" to create tensor from pinned buffer`);if(!(t.data instanceof e))throw new TypeError(`buffer should be of type ${e.name}`);this.cpuData=t.data;break}case"texture":if("float32"!==i)throw new TypeError(`unsupported type "${i}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break;case"gpu-buffer":if("float32"!==i&&"float16"!==i&&"int32"!==i&&"int64"!==i&&"uint32"!==i&&"uint8"!==i&&"bool"!==i)throw new TypeError(`unsupported type "${i}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break;default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let s,o;if("string"==typeof t)if(i=t,o=n,"string"===t){if(!Array.isArray(e))throw new TypeError("A string tensor's data must be a string array.");s=e}else{let n=$.get(t);if(void 0===n)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(e)){if("float16"===t&&n===Uint16Array)throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");s="uint64"===t||"int64"===t?n.from(e,BigInt):n.from(e)}else{if(!(e instanceof n))throw new TypeError(`A ${i} tensor's data must be type of ${n}`);s=e}}else if(o=e,Array.isArray(t)){if(0===t.length)throw new TypeError("Tensor type cannot be inferred from an empty array.");let e=typeof t[0];if("string"===e)i="string",s=t;else{if("boolean"!==e)throw new TypeError(`Invalid element type of data array: ${e}.`);i="bool",s=Uint8Array.from(t)}}else{let e=S.get(t.constructor);if(void 0===e)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);i=e,s=t}if(void 0===o)o=[s.length];else if(!Array.isArray(o))throw new TypeError("A tensor's dims must be a number array");r=o,this.cpuData=s,this.dataLocation="cpu"}let s=C(r);if(this.cpuData&&s!==this.cpuData.length)throw new Error(`Tensor's size(${s}) does not match data length(${this.cpuData.length}).`);this.type=i,this.dims=r,this.size=s}static async fromImage(t,e){return b(t,e)}static fromTexture(t,e){return x(t,e)}static fromGpuBuffer(t,e){return _(t,e)}static fromPinnedBuffer(t,e,n){return k(t,e,n)}toDataURL(t){return m(this,t)}toImageData(t){return w(this,t)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}async getData(t){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let e=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=e,t&&this.disposer&&(this.disposer(),this.disposer=void 0),e}finally{this.isDownloading=!1}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if("none"===this.dataLocation)throw new Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return A(this,t)}}})),rt=V((()=>{it(),O=I})),st=V((()=>{Z(),T=(t,e)=>{typeof v.trace>"u"?v.wasm.trace:v.trace},z=(t,e)=>{let n=(new Error).stack?.split(/\r\n|\r|\n/g)||[],i=!1;for(let r=0;r<n.length;r++){if(i&&!n[r].includes("TRACE_FUNC")){let i=`FUNC_${t}::${n[r].trim().split(" ")[1]}`;return e&&(i+=`::${e}`),void T("CPU",i)}n[r].includes("TRACE_FUNC")&&(i=!0)}},D=t=>{(typeof v.trace>"u"?!v.wasm.trace:!v.trace)||z("BEGIN",t)},P=t=>{(typeof v.trace>"u"?!v.wasm.trace:!v.trace)||z("END",t)}})),ot=V((()=>{Q(),rt(),st(),R=class t{constructor(t){this.handler=t}async run(t,e,n){D();let i={},r={};if("object"!=typeof t||null===t||t instanceof O||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if("object"==typeof e){if(null===e)throw new TypeError("Unexpected argument[1]: cannot be null.");if(e instanceof O)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(e)){if(0===e.length)throw new TypeError("'fetches' cannot be an empty array.");s=!1;for(let t of e){if("string"!=typeof t)throw new TypeError("'fetches' must be a string array or an object.");if(-1===this.outputNames.indexOf(t))throw new RangeError(`'fetches' contains invalid output name: ${t}.`);i[t]=null}if("object"==typeof n&&null!==n)r=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let t=!1,o=Object.getOwnPropertyNames(e);for(let n of this.outputNames)if(-1!==o.indexOf(n)){let r=e[n];(null===r||r instanceof O)&&(t=!0,s=!1,i[n]=r)}if(t){if("object"==typeof n&&null!==n)r=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else r=e}}else if(typeof e<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let e of this.inputNames)if(typeof t[e]>"u")throw new Error(`input '${e}' is missing in 'feeds'.`);if(s)for(let t of this.outputNames)i[t]=null;let o=await this.handler.run(t,i,r),a={};for(let t in o)if(Object.hasOwnProperty.call(o,t)){let e=o[t];a[t]=e instanceof O?e:new O(e.type,e.data,e.dims)}return P(),a}async release(){return this.handler.dispose()}static async create(e,n,i,r){D();let s,o={};if("string"==typeof e){if(s=e,"object"==typeof n&&null!==n)o=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(s=e,"object"==typeof n&&null!==n)o=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{if(!(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer))throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");{let t=e,a=0,u=e.byteLength;if("object"==typeof n&&null!==n)o=n;else if("number"==typeof n){if(a=n,!Number.isSafeInteger(a))throw new RangeError("'byteOffset' must be an integer.");if(a<0||a>=t.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${t.byteLength}).`);if(u=e.byteLength-a,"number"==typeof i){if(u=i,!Number.isSafeInteger(u))throw new RangeError("'byteLength' must be an integer.");if(u<=0||a+u>t.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${t.byteLength-a}].`);if("object"==typeof r&&null!==r)o=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(typeof i<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");s=new Uint8Array(t,a,u)}}let[a,u]=await f(o),h=await a.createInferenceSessionHandler(s,u);return P(),new t(h)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}})),at=V((()=>{ot(),N=R})),ut=V((()=>{})),ht=V((()=>{})),lt=V((()=>{})),ct=V((()=>{})),ft=V((()=>{Q(),rt(),F=class t{constructor(t,e,n){this.handler=t,this.hasOptimizerModel=e,this.hasEvalModel=n}get trainingInputNames(){return this.handler.inputNames}get trainingOutputNames(){return this.handler.outputNames}get evalInputNames(){if(this.hasEvalModel)return this.handler.evalInputNames;throw new Error("This training session has no evalModel loaded.")}get evalOutputNames(){if(this.hasEvalModel)return this.handler.evalOutputNames;throw new Error("This training session has no evalModel loaded.")}static async create(e,n){let i=e.evalModel||"",r=e.optimizerModel||"",s=n||{},[o,a]=await f(s);if(o.createTrainingSessionHandler){let n=await o.createTrainingSessionHandler(e.checkpointState,e.trainModel,i,r,a);return new t(n,!!e.optimizerModel,!!e.evalModel)}throw new Error("Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.")}typeNarrowingForRunStep(t,e,n,i,r){let s={},o={};if("object"!=typeof n||null===n||n instanceof O||Array.isArray(n))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if("object"==typeof i){if(null===i)throw new TypeError("Unexpected argument[1]: cannot be null.");if(i instanceof O)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(i)){if(0===i.length)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(let t of i){if("string"!=typeof t)throw new TypeError("'fetches' must be a string array or an object.");if(-1===e.indexOf(t))throw new RangeError(`'fetches' contains invalid output name: ${t}.`);s[t]=null}if("object"==typeof r&&null!==r)o=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else{let t=!1,n=Object.getOwnPropertyNames(i);for(let r of e)if(-1!==n.indexOf(r)){let e=i[r];(null===e||e instanceof O)&&(t=!0,a=!1,s[r]=e)}if(t){if("object"==typeof r&&null!==r)o=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else o=i}}else if(typeof i<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let e of t)if(typeof n[e]>"u")throw new Error(`input '${e}' is missing in 'feeds'.`);if(a)for(let t of e)s[t]=null;return[s,o]}convertHandlerReturnTypeToMapOfTensors(t){let e={};for(let n in t)if(Object.hasOwnProperty.call(t,n)){let i=t[n];e[n]=i instanceof O?i:new O(i.type,i.data,i.dims)}return e}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(t,e,n){let[i,r]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,t,e,n),s=await this.handler.runTrainStep(t,i,r);return this.convertHandlerReturnTypeToMapOfTensors(s)}async runOptimizerStep(t){if(!this.hasOptimizerModel)throw new Error("This TrainingSession has no OptimizerModel loaded.");await this.handler.runOptimizerStep(t||{})}async runEvalStep(t,e,n){if(this.hasEvalModel){let[i,r]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,t,e,n),s=await this.handler.runEvalStep(t,i,r);return this.convertHandlerReturnTypeToMapOfTensors(s)}throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(t=!0){return this.handler.getParametersSize(t)}async loadParametersBuffer(t,e=!0){let n=await this.getParametersSize(e);if(t.length!==4*n)throw new Error("Size of the buffer passed into loadParametersBuffer must match the number of parameters in the model. Please use getParametersSize method to check.");return this.handler.loadParametersBuffer(t,e)}async getContiguousParameters(t=!0){return this.handler.getContiguousParameters(t)}async release(){return this.handler.dispose()}}})),dt=V((()=>{ft(),U=F})),pt={};W(pt,{InferenceSession:()=>N,TRACE:()=>T,TRACE_FUNC_BEGIN:()=>D,TRACE_FUNC_END:()=>P,Tensor:()=>O,TrainingSession:()=>U,env:()=>y,registerBackend:()=>l});var vt=V((()=>{K(),Y(),at(),rt(),ut(),ht(),st(),lt(),ct(),dt()})),yt=V((()=>{})),mt={};W(mt,{default:()=>bt});var wt,gt,bt,xt=V((()=>{hl(),pu(),du(),wt="ort-wasm-proxy-worker",(gt=globalThis.self?.name===wt)&&(self.onmessage=t=>{let{type:e,in:n}=t.data;try{switch(e){case"init-wasm":qt(n.wasm).then((()=>{Ch(n).then((()=>{postMessage({type:e})}),(t=>{postMessage({type:e,err:t})}))}),(t=>{postMessage({type:e,err:t})}));break;case"init-ep":{let{epName:t,env:i}=n;Ah(i,t).then((()=>{postMessage({type:e})}),(t=>{postMessage({type:e,err:t})}));break}case"copy-from":{let{buffer:t}=n,i=Th(t);postMessage({type:e,out:i});break}case"create":{let{model:t,options:i}=n;zh(t,i).then((t=>{postMessage({type:e,out:t})}),(t=>{postMessage({type:e,err:t})}));break}case"release":Dh(n),postMessage({type:e});break;case"run":{let{sessionId:t,inputIndices:i,inputs:r,outputIndices:s,options:o}=n;Rh(t,i,r,s,new Array(s.length).fill(null),o).then((t=>{t.some((t=>"cpu"!==t[3]))?postMessage({type:e,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:e,out:t},Fh([...r,...t]))}),(t=>{postMessage({type:e,err:t})}));break}case"end-profiling":Nh(n),postMessage({type:e})}}catch(t){postMessage({type:e,err:t})}}),bt=gt?null:t=>new Worker(t??Mt,{type:"module",name:wt})})),_t={};W(_t,{default:()=>St});var kt,$t,St,Mt,Et,Ct,At,It,Ot,Tt,zt,Dt,Pt,Rt,Nt,Ft,Ut,qt,jt,Bt,Lt,Ht,Vt,Wt,Gt,Qt,Kt,Xt,Zt,Yt,Jt,te,ee,ne,ie,re,se,oe,ae,ue,he,le,ce,fe,de,pe,ve,ye,me,we,ge,be,xe,_e,ke,$e,Se,Me,Ee,Ce,Ae,Ie,Oe,Te,ze,De,Pe,Re,Ne,Fe,Ue,qe,je,Be,Le,He,Ve,We,Ge,Qe,Ke,Xe,Ze,Ye,Je,tn,en,nn,rn,sn,on,an,un,hn,ln,cn,fn,dn,pn,vn,yn,mn,wn,gn,bn,xn,_n,kn,$n,Sn,Mn,En,Cn,An,In,On,Tn,zn,Dn,Pn,Rn,Nn,Fn,Un,qn,jn,Bn,Ln,Hn,Vn,Wn,Gn,Qn,Kn,Xn,Zn,Yn,Jn,ti,ei,ni,ii,ri,si,oi,ai,ui,hi,li,ci,fi,di,pi,vi,yi,mi,wi,gi,bi,xi,_i,ki,$i,Si,Mi,Ei,Ci,Ai,Ii,Oi,Ti,zi,Di,Pi,Ri,Ni,Fi,Ui,qi,ji,Bi,Li,Hi,Vi,Wi,Gi,Qi,Ki,Xi,Zi,Yi,Ji,tr,er,nr,ir,rr,sr,or,ar,ur,hr,lr,cr,fr,dr,pr,vr,yr,mr,wr,gr,br,xr,_r,kr,$r,Sr,Mr,Er,Cr,Ar,Ir,Or,Tr,zr,Dr,Pr,Rr,Nr,Fr,Ur,qr,jr,Br,Lr,Hr,Vr,Wr,Gr,Qr,Kr,Xr,Zr,Yr,Jr,ts,es,ns,is,rs,ss,os,as,us,hs,ls,cs,fs,ds,ps,vs,ys,ms,ws,gs,bs,xs,_s,ks,$s,Ss,Ms,Es,Cs,As,Is,Os,Ts,zs,Ds,Ps,Rs,Ns,Fs,Us,qs,js,Bs,Ls,Hs,Vs,Ws,Gs,Qs,Ks,Xs,Zs,Ys,Js,to,eo,no,io,ro,so,oo,ao,uo,ho,lo,co,fo,po,vo,yo,mo,wo,go,bo,xo,_o,ko,$o,So,Mo,Eo,Co,Ao,Io,Oo,To,zo,Do,Po,Ro,No,Fo,Uo,qo,jo,Bo,Lo,Ho,Vo,Wo,Go,Qo,Ko,Xo,Zo,Yo,Jo,ta,ea,na,ia,ra,sa,oa,aa,ua,ha,la,ca,fa,da,pa,va,ya,ma,wa,ga,ba,xa,_a,ka,$a,Sa,Ma,Ea,Ca,Aa,Ia,Oa,Ta,za,Da,Pa,Ra,Na,Fa,Ua,qa,ja,Ba,La,Ha,Va,Wa,Ga,Qa,Ka,Xa,Za,Ya,Ja,tu,eu,nu,iu,ru,su,ou,au,uu,hu,lu,cu,fu=V((()=>{kt=n&&n.src||new URL("yunjing-for-cesium.js",document.baseURI).href,$t=async function(t={}){function e(){return A.buffer!=T.buffer&&L(),T}function i(){return A.buffer!=T.buffer&&L(),z}function r(){return A.buffer!=T.buffer&&L(),D}function s(){return A.buffer!=T.buffer&&L(),P}function o(){return A.buffer!=T.buffer&&L(),R}function a(){return A.buffer!=T.buffer&&L(),N}function u(){return A.buffer!=T.buffer&&L(),F}function h(){return A.buffer!=T.buffer&&L(),j}var l,c,f=Object.assign({},t),d=new Promise(((t,e)=>{l=t,c=e})),p="object"==typeof window,v="function"==typeof importScripts,y=v&&"em-pthread"==self.name;f.mountExternalData=(t,e)=>{(f.Fb||(f.Fb=new Map)).set(t,e)},f.unmountExternalData=()=>{delete f.Fb};var m=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor;let w=()=>{let t=(t,e,n)=>(...i)=>{let r=Le,s=e?.();i=t(...i);let o=e?.();return s!==o&&(t=o,n(s),e=n=null),Le!=r?new Promise(((t,e)=>{Ke={resolve:t,reject:e}})):i},e=t=>async(...e)=>{try{if(f.Eb)throw Error("Session already started");let n=f.Eb={bc:e[0],errors:[]},i=await t(...e);if(f.Eb!==n)throw Error("Session mismatch");f.Mb?.flush();let r=n.errors;if(0<r.length){let t=await Promise.all(r);if(t=t.filter((t=>t)),0<t.length)throw Error(t.join("\n"))}return i}finally{f.Eb=null}};f._=t(f._,(()=>f._),(t=>f._=t)),f.tt=e(t(f.tt,(()=>f.tt),(t=>f.tt=t))),f.et=e(t(f.et,(()=>f.et),(t=>f.et=t))),f.nt=t(f.nt,(()=>f.nt),(t=>f.nt=t)),w=void 0};f.jsepInit=(t,e)=>{if(w?.(),"webgpu"===t){[f.Mb,f.Tb,f.Xb,f.Nb,f.Wb,f.jb,f.Yb,f.$b,f.Ub,f.Vb,f.Zb]=e;let t=f.Mb;f.jsepRegisterBuffer=(e,n,i,r)=>t.registerBuffer(e,n,i,r),f.jsepGetBuffer=e=>t.getBuffer(e),f.jsepCreateDownloader=(e,n,i)=>t.createDownloader(e,n,i),f.jsepOnReleaseSession=e=>{t.onReleaseSession(e)},f.jsepOnRunStart=e=>t.onRunStart(e)}};var g,b,x=Object.assign({},f),_=(t,e)=>{throw e},k="";(p||v)&&(v?k=self.location.href:typeof document<"u"&&document.currentScript&&(k=document.currentScript.src),kt&&(k=kt),k=k.startsWith("blob:")?"":k.substr(0,k.replace(/[?#].*/,"").lastIndexOf("/")+1),v&&(b=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),g=(t,e,n)=>{var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer",i.onload=()=>{200==i.status||0==i.status&&i.response?e(i.response):n()},i.onerror=n,i.send(null)});var $,S=void 0,M=void 0;if(Object.assign(f,x),x=null,y){let t=function(e){try{var n=e.data,i=n.cmd;if("load"===i){let e=[];self.onmessage=t=>e.push(t),self.startWorker=()=>{postMessage({cmd:"loaded"});for(let n of e)t(n);self.onmessage=t};for(let t of n.handlers)f[t]&&!f[t].proxy||(f[t]=(...e)=>{postMessage({Lb:"callHandler",kc:t,args:e})},"print"==t&&(S=f[t]),"printErr"==t&&(M=f[t]));A=n.wasmMemory,L(),E(n.wasmModule)}else if("run"===i){gi(n.pthread_ptr,0,0,1,0,0),Oe(n.pthread_ptr),$t(),gt(),C||(pi(),C=!0);try{St(n.start_routine,n.arg)}catch(t){if("unwind"!=t)throw t}}else"cancel"===i?yi()&&ki(-1):"setimmediate"!==n.target&&("checkMailbox"===i?C&&Te():i&&(M(`worker: received unknown command ${i}`),M(n)))}catch(t){throw bi(),t}};var E,C=!1;M=function(...t){t=t.join(" ")},self.alert=function(...t){postMessage({Lb:"alert",text:t.join(" "),mc:yi()})},f.instantiateWasm=(t,e)=>new Promise((t=>{E=n=>{n=new WebAssembly.Instance(n,nt()),e(n),t()}})),self.onunhandledrejection=t=>{throw t.reason||t},self.onmessage=t}f.wasmBinary&&($=f.wasmBinary);var A,I,O,T,z,D,P,R,N,F,U,q,j,B=!1;function L(){var t=A.buffer;f.HEAP8=T=new Int8Array(t),f.HEAP16=D=new Int16Array(t),f.HEAPU8=z=new Uint8Array(t),f.HEAPU16=P=new Uint16Array(t),f.HEAP32=R=new Int32Array(t),f.HEAPU32=N=new Uint32Array(t),f.HEAPF32=F=new Float32Array(t),f.HEAPF64=j=new Float64Array(t),f.HEAP64=U=new BigInt64Array(t),f.HEAPU64=q=new BigUint64Array(t)}if(!y){if(!((A=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0})).buffer instanceof m))throw M("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),Error("bad memory");L()}var H=[],V=[],W=[],G=0,Q=null;function K(){if(0==--G&&Q){var t=Q;Q=null,t()}}function X(t){throw M(t="Aborted("+t+")"),B=!0,O=1,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),c(t),t}var Z,Y=t=>t.startsWith("data:application/octet-stream;base64,"),J=t=>t.startsWith("file://");function tt(t){if(t==Z&&$)return new Uint8Array($);if(b)return b(t);throw"both async and sync fetching of the wasm failed"}function et(t,e,n){return function(t){if(!$&&(p||v)){if("function"==typeof fetch&&!J(t))return fetch(t,{credentials:"same-origin"}).then((e=>{if(!e.ok)throw`failed to load wasm binary file at '${t}'`;return e.arrayBuffer()})).catch((()=>tt(t)));if(g)return new Promise(((e,n)=>{g(t,(t=>e(new Uint8Array(t))),n)}))}return Promise.resolve().then((()=>tt(t)))}(t).then((t=>WebAssembly.instantiate(t,e))).then(n,(t=>{M(`failed to asynchronously prepare wasm: ${t}`),X(t)}))}function nt(){return{a:{M:st,za:rt,b:Et,$:At,z:zt,pa:Dt,X:Ft,Z:Ut,qa:qt,na:jt,ga:Bt,ma:Lt,J:Ht,Y:Vt,V:Wt,oa:Gt,W:Qt,va:Zt,D:ie,P:se,O:de,C:ve,s:ye,p:me,E:we,y:Me,Q:Ee,ta:Ce,ja:Ae,T:ze,aa:Pe,F:Re,ia:Oe,sa:Ne,u:qe,B:Ye,o:tn,m:rn,c:ue,n:on,k:ln,Aa:cn,r:fn,f:dn,v:pn,l:vn,g:yn,i:mn,j:wn,h:gn,e:bn,da:xn,ea:Sn,fa:Mn,ba:En,ca:Cn,S:An,d:Tn,N:zn,G:Dn,K:Pn,w:Rn,ra:Fn,U:Un,t:Nn,x:qn,L:jn,R:Bn,ya:Wn,xa:Gn,ka:Zn,la:Yn,it:dt,A:Jn,I:ti,ha:ei,H:ii,a:A,wa:ct,ua:ai,q:ui}}}var it={849620:(t,e,n,r)=>{if(void 0===f||!f.Fb)return 1;if((t=Tt(t>>>0)).startsWith("./")&&(t=t.substring(2)),!(t=f.Fb.get(t)))return 2;if(r>>>=0,(e>>>=0)+(n>>>=0)>t.byteLength)return 3;try{return i().set(t.subarray(e,e+n),r>>>0),0}catch{return 4}},850121:()=>{f.Ub()},850152:()=>{f.Vb()},850181:()=>{f.Zb()},850206:t=>f.Tb(t),850239:t=>f.Xb(t),850271:(t,e,n)=>{f.Nb(t,e,n,!0)},850310:(t,e,n)=>{f.Nb(t,e,n)},850343:()=>typeof wasmOffsetConverter<"u",850400:t=>{f.jb("Abs",t,void 0)},850451:t=>{f.jb("Neg",t,void 0)},850502:t=>{f.jb("Floor",t,void 0)},850555:t=>{f.jb("Ceil",t,void 0)},850607:t=>{f.jb("Reciprocal",t,void 0)},850665:t=>{f.jb("Sqrt",t,void 0)},850717:t=>{f.jb("Exp",t,void 0)},850768:t=>{f.jb("Erf",t,void 0)},850819:t=>{f.jb("Sigmoid",t,void 0)},850874:(t,e,n)=>{f.jb("HardSigmoid",t,{alpha:e,beta:n})},850953:t=>{f.jb("Log",t,void 0)},851004:t=>{f.jb("Sin",t,void 0)},851055:t=>{f.jb("Cos",t,void 0)},851106:t=>{f.jb("Tan",t,void 0)},851157:t=>{f.jb("Asin",t,void 0)},851209:t=>{f.jb("Acos",t,void 0)},851261:t=>{f.jb("Atan",t,void 0)},851313:t=>{f.jb("Sinh",t,void 0)},851365:t=>{f.jb("Cosh",t,void 0)},851417:t=>{f.jb("Asinh",t,void 0)},851470:t=>{f.jb("Acosh",t,void 0)},851523:t=>{f.jb("Atanh",t,void 0)},851576:t=>{f.jb("Tanh",t,void 0)},851628:t=>{f.jb("Not",t,void 0)},851679:(t,e,n)=>{f.jb("Clip",t,{min:e,max:n})},851748:t=>{f.jb("Clip",t,void 0)},851800:(t,e)=>{f.jb("Elu",t,{alpha:e})},851858:t=>{f.jb("Relu",t,void 0)},851910:(t,e)=>{f.jb("LeakyRelu",t,{alpha:e})},851974:(t,e)=>{f.jb("ThresholdedRelu",t,{alpha:e})},852044:(t,e)=>{f.jb("Cast",t,{to:e})},852102:t=>{f.jb("Add",t,void 0)},852153:t=>{f.jb("Sub",t,void 0)},852204:t=>{f.jb("Mul",t,void 0)},852255:t=>{f.jb("Div",t,void 0)},852306:t=>{f.jb("Pow",t,void 0)},852357:t=>{f.jb("Equal",t,void 0)},852410:t=>{f.jb("Greater",t,void 0)},852465:t=>{f.jb("GreaterOrEqual",t,void 0)},852527:t=>{f.jb("Less",t,void 0)},852579:t=>{f.jb("LessOrEqual",t,void 0)},852638:(t,e,n,i,r)=>{f.jb("ReduceMean",t,{keepDims:!!e,noopWithEmptyAxes:!!n,axes:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},852797:(t,e,n,i,r)=>{f.jb("ReduceMax",t,{keepDims:!!e,noopWithEmptyAxes:!!n,axes:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},852955:(t,e,n,i,r)=>{f.jb("ReduceMin",t,{keepDims:!!e,noopWithEmptyAxes:!!n,axes:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},853113:(t,e,n,i,r)=>{f.jb("ReduceProd",t,{keepDims:!!e,noopWithEmptyAxes:!!n,axes:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},853272:(t,e,n,i,r)=>{f.jb("ReduceSum",t,{keepDims:!!e,noopWithEmptyAxes:!!n,axes:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},853430:(t,e,n,i,r)=>{f.jb("ReduceL1",t,{keepDims:!!e,noopWithEmptyAxes:!!n,axes:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},853587:(t,e,n,i,r)=>{f.jb("ReduceL2",t,{keepDims:!!e,noopWithEmptyAxes:!!n,axes:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},853744:(t,e,n,i,r)=>{f.jb("ReduceLogSum",t,{keepDims:!!e,noopWithEmptyAxes:!!n,axes:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},853905:(t,e,n,i,r)=>{f.jb("ReduceSumSquare",t,{keepDims:!!e,noopWithEmptyAxes:!!n,axes:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},854069:(t,e,n,i,r)=>{f.jb("ReduceLogSumExp",t,{keepDims:!!e,noopWithEmptyAxes:!!n,axes:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},854233:t=>{f.jb("Where",t,void 0)},854286:(t,e,n)=>{f.jb("Transpose",t,{perm:e?Array.from(o().subarray(e>>>0,n>>>0)):[]})},854394:(t,e,n,i)=>{f.jb("DepthToSpace",t,{blocksize:e,mode:Tt(n),format:i?"NHWC":"NCHW"})},854527:(t,e,n,i)=>{f.jb("DepthToSpace",t,{blocksize:e,mode:Tt(n),format:i?"NHWC":"NCHW"})},854660:(t,n,i,r,s,a,u,h,l,c,d,p,v,y,m)=>{f.jb("ConvTranspose",t,{format:l?"NHWC":"NCHW",autoPad:n,dilations:[i],group:r,kernelShape:[s],pads:[a,u],strides:[h],wIsConst:()=>!!e()[c>>>0],outputPadding:d?Array.from(o().subarray(d>>>0,p>>>0)):[],outputShape:v?Array.from(o().subarray(v>>>0,y>>>0)):[],activation:Tt(m)})},855061:(t,n,i,r,s,a,u,h,l,c,d,p,v,y)=>{f.jb("ConvTranspose",t,{format:h?"NHWC":"NCHW",autoPad:n,dilations:Array.from(o().subarray(i>>>0,2+(i>>>0)>>>0)),group:r,kernelShape:Array.from(o().subarray(s>>>0,2+(s>>>0)>>>0)),pads:Array.from(o().subarray(a>>>0,4+(a>>>0)>>>0)),strides:Array.from(o().subarray(u>>>0,2+(u>>>0)>>>0)),wIsConst:()=>!!e()[l>>>0],outputPadding:c?Array.from(o().subarray(c>>>0,d>>>0)):[],outputShape:p?Array.from(o().subarray(p>>>0,v>>>0)):[],activation:Tt(y)})},855626:(t,n,i,r,s,a,u,h,l,c,d,p,v,y,m)=>{f.jb("ConvTranspose",t,{format:l?"NHWC":"NCHW",autoPad:n,dilations:[i],group:r,kernelShape:[s],pads:[a,u],strides:[h],wIsConst:()=>!!e()[c>>>0],outputPadding:d?Array.from(o().subarray(d>>>0,p>>>0)):[],outputShape:v?Array.from(o().subarray(v>>>0,y>>>0)):[],activation:Tt(m)})},856027:(t,n,i,r,s,a,u,h,l,c,d,p,v,y)=>{f.jb("ConvTranspose",t,{format:h?"NHWC":"NCHW",autoPad:n,dilations:Array.from(o().subarray(i>>>0,2+(i>>>0)>>>0)),group:r,kernelShape:Array.from(o().subarray(s>>>0,2+(s>>>0)>>>0)),pads:Array.from(o().subarray(a>>>0,4+(a>>>0)>>>0)),strides:Array.from(o().subarray(u>>>0,2+(u>>>0)>>>0)),wIsConst:()=>!!e()[l>>>0],outputPadding:c?Array.from(o().subarray(c>>>0,d>>>0)):[],outputShape:p?Array.from(o().subarray(p>>>0,v>>>0)):[],activation:Tt(y)})},856592:(t,e)=>{f.jb("GlobalAveragePool",t,{format:e?"NHWC":"NCHW"})},856683:(t,e,n,i,r,s,o,a,u,h,l,c,d,p,v,y)=>{f.jb("AveragePool",t,{format:y?"NHWC":"NCHW",auto_pad:e,ceil_mode:n,count_include_pad:i,storage_order:r,dilations:[s,o],kernel_shape:[a,u],pads:[h,l,c,d],strides:[p,v]})},856967:(t,e)=>{f.jb("GlobalAveragePool",t,{format:e?"NHWC":"NCHW"})},857058:(t,e,n,i,r,s,o,a,u,h,l,c,d,p,v,y)=>{f.jb("AveragePool",t,{format:y?"NHWC":"NCHW",auto_pad:e,ceil_mode:n,count_include_pad:i,storage_order:r,dilations:[s,o],kernel_shape:[a,u],pads:[h,l,c,d],strides:[p,v]})},857342:(t,e)=>{f.jb("GlobalMaxPool",t,{format:e?"NHWC":"NCHW"})},857429:(t,e,n,i,r,s,o,a,u,h,l,c,d,p,v,y)=>{f.jb("MaxPool",t,{format:y?"NHWC":"NCHW",auto_pad:e,ceil_mode:n,count_include_pad:i,storage_order:r,dilations:[s,o],kernel_shape:[a,u],pads:[h,l,c,d],strides:[p,v]})},857709:(t,e)=>{f.jb("GlobalMaxPool",t,{format:e?"NHWC":"NCHW"})},857796:(t,e,n,i,r,s,o,a,u,h,l,c,d,p,v,y)=>{f.jb("MaxPool",t,{format:y?"NHWC":"NCHW",auto_pad:e,ceil_mode:n,count_include_pad:i,storage_order:r,dilations:[s,o],kernel_shape:[a,u],pads:[h,l,c,d],strides:[p,v]})},858076:(t,e,n,i,r)=>{f.jb("Gemm",t,{alpha:e,beta:n,transA:i,transB:r})},858180:t=>{f.jb("MatMul",t,void 0)},858234:(t,e,n,i)=>{f.jb("ArgMax",t,{keepDims:!!e,selectLastIndex:!!n,axis:i})},858342:(t,e,n,i)=>{f.jb("ArgMin",t,{keepDims:!!e,selectLastIndex:!!n,axis:i})},858450:(t,e)=>{f.jb("Softmax",t,{axis:e})},858513:(t,e)=>{f.jb("Concat",t,{axis:e})},858573:(t,e,n,i,r)=>{f.jb("Split",t,{axis:e,numOutputs:n,splitSizes:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},858713:t=>{f.jb("Expand",t,void 0)},858767:(t,e)=>{f.jb("Gather",t,{axis:Number(e)})},858838:(t,e)=>{f.jb("GatherElements",t,{axis:Number(e)})},858917:(t,e,n,i,r,s,a,u,h,l,c)=>{f.jb("Resize",t,{antialias:e,axes:n?Array.from(o().subarray(n>>>0,i>>>0)):[],coordinateTransformMode:Tt(r),cubicCoeffA:s,excludeOutside:a,extrapolationValue:u,keepAspectRatioPolicy:Tt(h),mode:Tt(l),nearestMode:Tt(c)})},859263:(t,e,n,i,r,s,a)=>{f.jb("Slice",t,{starts:e?Array.from(o().subarray(e>>>0,n>>>0)):[],ends:i?Array.from(o().subarray(i>>>0,r>>>0)):[],axes:s?Array.from(o().subarray(s>>>0,a>>>0)):[]})},859479:t=>{f.jb("Tile",t,void 0)},859531:(t,e,n)=>{f.jb("InstanceNormalization",t,{epsilon:e,format:n?"NHWC":"NCHW"})},859645:(t,e,n)=>{f.jb("InstanceNormalization",t,{epsilon:e,format:n?"NHWC":"NCHW"})},859759:t=>{f.jb("Range",t,void 0)},859812:(t,e)=>{f.jb("Einsum",t,{equation:Tt(e)})},859893:(t,e,n,i,r)=>{f.jb("Pad",t,{mode:e,value:n,pads:i?Array.from(o().subarray(i>>>0,r>>>0)):[]})},860020:(t,e,n,i,r,s)=>{f.jb("BatchNormalization",t,{epsilon:e,momentum:n,spatial:!!r,trainingMode:!!i,format:s?"NHWC":"NCHW"})},860189:(t,e,n,i,r,s)=>{f.jb("BatchNormalization",t,{epsilon:e,momentum:n,spatial:!!r,trainingMode:!!i,format:s?"NHWC":"NCHW"})},860358:(t,e,n)=>{f.jb("CumSum",t,{exclusive:Number(e),reverse:Number(n)})},860455:(t,e,n,i,r,s,a,u,h)=>{f.jb("Attention",t,{numHeads:e,isUnidirectional:n,maskFilterValue:i,scale:r,doRotary:s,qkvHiddenSizes:a?Array.from(o().subarray(Number(u)>>>0,Number(u)+a>>>0)):[],pastPresentShareBuffer:!!h})},860727:t=>{f.jb("BiasAdd",t,void 0)},860782:t=>{f.jb("BiasSplitGelu",t,void 0)},860843:t=>{f.jb("FastGelu",t,void 0)},860899:(t,n,i,r,s,a,h,l,c,d,p,v,y,m,w,g)=>{f.jb("Conv",t,{format:v?"NHWC":"NCHW",auto_pad:n,dilations:i?Array.from(o().subarray(i>>>0,r>>>0)):[],group:s,kernel_shape:a?Array.from(o().subarray(a>>>0,h>>>0)):[],pads:l?Array.from(o().subarray(l>>>0,c>>>0)):[],strides:d?Array.from(o().subarray(d>>>0,p>>>0)):[],w_is_const:()=>!!e()[y>>>0],activation:Tt(m),activation_params:w?Array.from(u().subarray(w>>>0,g>>>0)):[]})},861395:t=>{f.jb("Gelu",t,void 0)},861447:(t,e,n,i)=>{f.jb("GroupQueryAttention",t,{numHeads:e,kvNumHeads:n,scale:i})},861560:(t,e,n,i)=>{f.jb("LayerNormalization",t,{axis:e,epsilon:n,simplified:!!i})},861671:(t,e,n,i)=>{f.jb("LayerNormalization",t,{axis:e,epsilon:n,simplified:!!i})},861782:(t,e,n,i,r,s)=>{f.jb("MatMulNBits",t,{k:e,n:n,accuracyLevel:i,bits:r,blockSize:s})},861909:(t,e,n,i,r,s)=>{f.jb("MultiHeadAttention",t,{numHeads:e,isUnidirectional:n,maskFilterValue:i,scale:r,doRotary:s})},862068:(t,e)=>{f.jb("QuickGelu",t,{alpha:e})},862132:(t,e,n,i,r)=>{f.jb("RotaryEmbedding",t,{interleaved:!!e,numHeads:n,rotaryEmbeddingDim:i,scale:r})},862271:(t,e,n)=>{f.jb("SkipLayerNormalization",t,{epsilon:e,simplified:!!n})},862373:t=>{f.Yb(t)},862407:(t,e)=>f.$b(t,e,f.Eb.bc,f.Eb.errors),862519:(t,e,n)=>{f.jb("SkipLayerNormalization",t,{epsilon:e,simplified:!!n})}};function rt(t,e,n){return Ze((async()=>{await f.Wb(t,e,n)}))}function st(){return typeof wasmOffsetConverter<"u"}function ot(t){this.name="ExitStatus",this.message=`Program terminated with exit(${t})`,this.status=t}var at=t=>{t.terminate(),t.onmessage=()=>{}},ut=t=>{0==pt.length&&(xt(),bt(pt[0]));var e=pt.pop();if(!e)return 6;vt.push(e),mt[t.Ab]=e,e.Ab=t.Ab;var n={cmd:"run",start_routine:t.cc,arg:t.Pb,pthread_ptr:t.Ab};return e.postMessage(n,t.ic),0},ht=0,lt=(t,e,...n)=>{for(var i=2*n.length,r=Ci(),s=Ei(8*i),o=s>>>3,a=0;a<n.length;a++){var u=n[a];"bigint"==typeof u?(U[o+2*a]=1n,U[o+2*a+1]=u):(U[o+2*a]=0n,h()[o+2*a+1>>>0]=u)}return t=xi(t,0,i,s,e),Mi(r),t};function ct(t){if(y)return lt(0,1,t);if(O=t,!(0<ht)){for(var e of vt)at(e);for(e of pt)at(e);pt=[],vt=[],mt=[],B=!0}_(t,new ot(t))}function ft(t){if(y)return lt(1,0,t);dt(t)}var dt=t=>{if(O=t,y)throw ft(t),"unwind";ct(t)},pt=[],vt=[],yt=[],mt={},wt=t=>{var e=t.Ab;delete mt[e],pt.push(t),vt.splice(vt.indexOf(t),1),t.Ab=0,_i(e)};function gt(){yt.forEach((t=>t()))}var bt=t=>new Promise((e=>{t.onmessage=n=>{var i=(n=n.data).cmd;if(n.targetThread&&n.targetThread!=yi()){var r=mt[n.targetThread];r?r.postMessage(n,n.transferList):M(`Internal error! Worker sent a message "${i}" to target pthread ${n.targetThread}, but that thread no longer exists!`)}else"checkMailbox"===i?Te():"spawnThread"===i?ut(n):"cleanupThread"===i?wt(mt[n.thread]):"killThread"===i?(n=n.thread,i=mt[n],delete mt[n],at(i),_i(n),vt.splice(vt.indexOf(i),1),i.Ab=0):"cancelThread"===i?mt[n.thread].postMessage({cmd:"cancel"}):"loaded"===i?(t.loaded=!0,e(t)):"alert"===i?alert(`Thread ${n.threadId}: ${n.text}`):"setimmediate"===n.target?t.postMessage(n):"callHandler"===i?f[n.handler](...n.args):i&&M(`worker sent an unknown command ${i}`)},t.onerror=t=>{throw M(`worker sent an error! ${t.filename}:${t.lineno}: ${t.message}`),t};var n,i=[];for(n of[])f.hasOwnProperty(n)&&i.push(n);t.postMessage({cmd:"load",handlers:i,wasmMemory:A,wasmModule:I})}));function xt(){var t=new Worker(new URL(n&&n.src||new URL("yunjing-for-cesium.js",document.baseURI).href),{type:"module",workerData:"em-pthread",name:"em-pthread"});pt.push(t)}var _t=t=>{for(;0<t.length;)t.shift()(f)},$t=()=>{var t=yi(),e=a()[t+52>>>2>>>0];t=a()[t+56>>>2>>>0],Si(e,e-t),Mi(e)},St=(t,e)=>{ht=0,t=Ai(t,e),0<ht?O=t:ki(t)};class Mt{constructor(t){this.Ib=t-24}}function Et(t,e,n){var i=new Mt(t>>>=0);throw e>>>=0,n>>>=0,a()[i.Ib+16>>>2>>>0]=0,a()[i.Ib+4>>>2>>>0]=e,a()[i.Ib+8>>>2>>>0]=n,t}function Ct(t,e,n,i){return y?lt(2,1,t,e,n,i):At(t,e,n,i)}function At(t,e,n,i){if(t>>>=0,e>>>=0,n>>>=0,i>>>=0,void 0===m)return M("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var r=[];return y&&0===r.length?Ct(t,e,n,i):(t={cc:n,Ab:t,Pb:i,ic:r},y?(t.Lb="spawnThread",postMessage(t,r),0):ut(t))}var It=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ot=(t,e,n)=>{var i=(e>>>=0)+n;for(n=e;t[n]&&!(n>=i);)++n;if(16<n-e&&t.buffer&&It)return It.decode(t.buffer instanceof m?t.slice(e,n):t.subarray(e,n));for(i="";e<n;){var r=t[e++];if(128&r){var s=63&t[e++];if(192==(224&r))i+=String.fromCharCode((31&r)<<6|s);else{var o=63&t[e++];65536>(r=224==(240&r)?(15&r)<<12|s<<6|o:(7&r)<<18|s<<12|o<<6|63&t[e++])?i+=String.fromCharCode(r):(r-=65536,i+=String.fromCharCode(55296|r>>10,56320|1023&r))}}else i+=String.fromCharCode(r)}return i},Tt=(t,e)=>(t>>>=0)?Ot(i(),t,e):"";function zt(t,e,n){return y?lt(3,1,t,e,n):0}function Dt(t,e){if(y)return lt(4,1,t,e)}var Pt=t=>{for(var e=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);127>=i?e++:2047>=i?e+=2:55296<=i&&57343>=i?(e+=4,++n):e+=3}return e},Rt=(t,e,n,i)=>{if(!(0<i))return 0;var r=n>>>=0;i=n+i-1;for(var s=0;s<t.length;++s){var o=t.charCodeAt(s);if(55296<=o&&57343>=o&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++s)),127>=o){if(n>=i)break;e[n++>>>0]=o}else{if(2047>=o){if(n+1>=i)break;e[n++>>>0]=192|o>>6}else{if(65535>=o){if(n+2>=i)break;e[n++>>>0]=224|o>>12}else{if(n+3>=i)break;e[n++>>>0]=240|o>>18,e[n++>>>0]=128|o>>12&63}e[n++>>>0]=128|o>>6&63}e[n++>>>0]=128|63&o}}return e[n>>>0]=0,n-r},Nt=(t,e,n)=>Rt(t,i(),e,n);function Ft(t,e){if(y)return lt(5,1,t,e)}function Ut(t,e,n){if(y)return lt(6,1,t,e,n)}function qt(t,e,n){return y?lt(7,1,t,e,n):0}function jt(t,e){if(y)return lt(8,1,t,e)}function Bt(t,e,n){if(y)return lt(9,1,t,e,n)}function Lt(t,e,n,i){if(y)return lt(10,1,t,e,n,i)}function Ht(t,e,n,i){if(y)return lt(11,1,t,e,n,i)}function Vt(t,e,n,i){if(y)return lt(12,1,t,e,n,i)}function Wt(t){if(y)return lt(13,1,t)}function Gt(t,e){if(y)return lt(14,1,t,e)}function Qt(t,e,n){if(y)return lt(15,1,t,e,n)}var Kt,Xt,Zt=()=>{X("")},Yt=t=>{for(var e="";i()[t>>>0];)e+=Kt[i()[t++>>>0]];return e},Jt={},te={};function ee(t,e,n={}){if(!("argPackAdvance"in e))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(t,e,n={}){var i=e.name;if(!t)throw new Xt(`type "${i}" must have a positive integer typeid pointer`);if(te.hasOwnProperty(t)){if(n.Rb)return;throw new Xt(`Cannot register type '${i}' twice`)}te[t]=e,Jt.hasOwnProperty(t)&&(e=Jt[t],delete Jt[t],e.forEach((t=>t())))}(t,e,n)}var ne=(t,n,u)=>{switch(n){case 1:return u?t=>e()[t>>>0]:t=>i()[t>>>0];case 2:return u?t=>r()[t>>>1>>>0]:t=>s()[t>>>1>>>0];case 4:return u?t=>o()[t>>>2>>>0]:t=>a()[t>>>2>>>0];case 8:return u?t=>U[t>>>3]:t=>q[t>>>3];default:throw new TypeError(`invalid integer width (${n}): ${t}`)}};function ie(t,e,n){n>>>=0,ee(t>>>=0,{name:e=Yt(e>>>0),fromWireType:t=>t,toWireType:function(t,e){if("bigint"!=typeof e&&"number"!=typeof e)throw e=null===e?"null":"object"==(t=typeof e)||"array"===t||"function"===t?e.toString():""+e,new TypeError(`Cannot convert "${e}" to ${this.name}`);return"number"==typeof e&&(e=BigInt(e)),e},argPackAdvance:re,readValueFromPointer:ne(e,n,-1==e.indexOf("u")),Db:null})}var re=8;function se(t,e,n,r){ee(t>>>=0,{name:e=Yt(e>>>0),fromWireType:function(t){return!!t},toWireType:function(t,e){return e?n:r},argPackAdvance:re,readValueFromPointer:function(t){return this.fromWireType(i()[t>>>0])},Db:null})}var oe=[],ae=[];function ue(t){9<(t>>>=0)&&0==--ae[t+1]&&(ae[t]=void 0,oe.push(t))}var he=t=>{if(!t)throw new Xt("Cannot use deleted val. handle = "+t);return ae[t]},le=t=>{switch(t){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let e=oe.pop()||ae.length;return ae[e]=t,ae[e+1]=1,e}};function ce(t){return this.fromWireType(a()[t>>>2>>>0])}var fe={name:"emscripten::val",fromWireType:t=>{var e=he(t);return ue(t),e},toWireType:(t,e)=>le(e),argPackAdvance:re,readValueFromPointer:ce,Db:null};function de(t){return ee(t>>>0,fe)}var pe=(t,e)=>{switch(e){case 4:return function(t){return this.fromWireType(u()[t>>>2>>>0])};case 8:return function(t){return this.fromWireType(h()[t>>>3>>>0])};default:throw new TypeError(`invalid float width (${e}): ${t}`)}};function ve(t,e,n){n>>>=0,ee(t>>>=0,{name:e=Yt(e>>>0),fromWireType:t=>t,toWireType:(t,e)=>e,argPackAdvance:re,readValueFromPointer:pe(e,n),Db:null})}function ye(t,e,n,i,r){if(t>>>=0,n>>>=0,e=Yt(e>>>0),-1===r&&(r=4294967295),r=t=>t,0===i){var s=32-8*n;r=t=>t<<s>>>s}var o=e.includes("unsigned")?function(t,e){return e>>>0}:function(t,e){return e};ee(t,{name:e,fromWireType:r,toWireType:o,argPackAdvance:re,readValueFromPointer:ne(e,n,0!==i),Db:null})}function me(t,n,i){function r(t){var n=a()[t>>>2>>>0];return t=a()[t+4>>>2>>>0],new s(e().buffer,t,n)}var s=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][n];ee(t>>>=0,{name:i=Yt(i>>>0),fromWireType:r,argPackAdvance:re,readValueFromPointer:r},{Rb:!0})}function we(t,e){t>>>=0;var n="std::string"===(e=Yt(e>>>0));ee(t,{name:e,fromWireType:function(t){var e=a()[t>>>2>>>0],r=t+4;if(n)for(var s=r,o=0;o<=e;++o){var u=r+o;if(o==e||0==i()[u>>>0]){if(s=Tt(s,u-s),void 0===h)var h=s;else h+=String.fromCharCode(0),h+=s;s=u+1}}else{for(h=Array(e),o=0;o<e;++o)h[o]=String.fromCharCode(i()[r+o>>>0]);h=h.join("")}return wi(t),h},toWireType:function(t,e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));var r="string"==typeof e;if(!(r||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array))throw new Xt("Cannot pass non-string to std::string");var s=n&&r?Pt(e):e.length,o=mi(4+s+1),u=o+4;if(a()[o>>>2>>>0]=s,n&&r)Nt(e,u,s+1);else if(r)for(r=0;r<s;++r){var h=e.charCodeAt(r);if(255<h)throw wi(u),new Xt("String has UTF-16 code units that do not fit in 8 bits");i()[u+r>>>0]=h}else for(r=0;r<s;++r)i()[u+r>>>0]=e[r];return null!==t&&t.push(wi,o),o},argPackAdvance:re,readValueFromPointer:ce,Db(t){wi(t)}})}var ge=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,be=(t,e)=>{for(var n=t>>1,o=n+e/2;!(n>=o)&&s()[n>>>0];)++n;if(32<(n<<=1)-t&&ge)return ge.decode(i().slice(t,n));for(n="",o=0;!(o>=e/2);++o){var a=r()[t+2*o>>>1>>>0];if(0==a)break;n+=String.fromCharCode(a)}return n},xe=(t,e,n)=>{if(n??=2147483647,2>n)return 0;var i=e;n=(n-=2)<2*t.length?n/2:t.length;for(var s=0;s<n;++s){var o=t.charCodeAt(s);r()[e>>>1>>>0]=o,e+=2}return r()[e>>>1>>>0]=0,e-i},_e=t=>2*t.length,ke=(t,e)=>{for(var n=0,i="";!(n>=e/4);){var r=o()[t+4*n>>>2>>>0];if(0==r)break;++n,65536<=r?(r-=65536,i+=String.fromCharCode(55296|r>>10,56320|1023&r)):i+=String.fromCharCode(r)}return i},$e=(t,e,n)=>{if(e>>>=0,n??=2147483647,4>n)return 0;var i=e;n=i+n-4;for(var r=0;r<t.length;++r){var s=t.charCodeAt(r);if(55296<=s&&57343>=s&&(s=65536+((1023&s)<<10)|1023&t.charCodeAt(++r)),o()[e>>>2>>>0]=s,(e+=4)+4>n)break}return o()[e>>>2>>>0]=0,e-i},Se=t=>{for(var e=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);55296<=i&&57343>=i&&++n,e+=4}return e};function Me(t,e,n){if(t>>>=0,e>>>=0,n=Yt(n>>>=0),2===e)var i=be,r=xe,o=_e,u=t=>s()[t>>>1>>>0];else 4===e&&(i=ke,r=$e,o=Se,u=t=>a()[t>>>2>>>0]);ee(t,{name:n,fromWireType:t=>{for(var n,r=a()[t>>>2>>>0],s=t+4,o=0;o<=r;++o){var h=t+4+o*e;o!=r&&0!=u(h)||(s=i(s,h-s),void 0===n?n=s:(n+=String.fromCharCode(0),n+=s),s=h+e)}return wi(t),n},toWireType:(t,i)=>{if("string"!=typeof i)throw new Xt(`Cannot pass non-string to C++ string type ${n}`);var s=o(i),u=mi(4+s+e);return a()[u>>>2>>>0]=s/e,r(i,u+4,s+e),null!==t&&t.push(wi,u),u},argPackAdvance:re,readValueFromPointer:ce,Db(t){wi(t)}})}function Ee(t,e){ee(t>>>=0,{Sb:!0,name:e=Yt(e>>>0),argPackAdvance:0,fromWireType:()=>{},toWireType:()=>{}})}var Ce=()=>1;function Ae(t){gi(t>>>0,!v,1,!p,131072,!1),gt()}var Ie=t=>{if(!B)try{if(t(),!(0<ht))try{y?ki(O):dt(O)}catch(t){t instanceof ot||"unwind"==t||_(1,t)}}catch(t){t instanceof ot||"unwind"==t||_(1,t)}};function Oe(t){t>>>=0,"function"==typeof Atomics.jc&&(Atomics.jc(o(),t>>>2,t).value.then(Te),t+=128,Atomics.store(o(),t>>>2,1))}var Te=()=>{var t=yi();t&&(Oe(t),Ie($i))};function ze(t,e){(t>>>=0)==e>>>0?setTimeout(Te):y?postMessage({targetThread:t,cmd:"checkMailbox"}):(t=mt[t])&&t.postMessage({cmd:"checkMailbox"})}var De=[];function Pe(t,e,n,i,r){for(e>>>=0,i/=2,De.length=i,n=r>>>0>>>3,r=0;r<i;r++)De[r]=U[n+2*r]?U[n+2*r+1]:h()[n+2*r+1>>>0];return(e?it[e]:ci[t])(...De)}function Re(t){t>>>=0,y?postMessage({cmd:"cleanupThread",thread:t}):wt(mt[t])}function Ne(t){}var Fe=(t,e)=>{var n=te[t];if(void 0===n)throw t=di(t),n=Yt(t),wi(t),new Xt(`${e} has unknown type ${n}`);return n},Ue=(t,e,n)=>{var i=[];return t=t.toWireType(i,n),i.length&&(a()[e>>>2>>>0]=le(i)),t};function qe(t,e,n){return e>>>=0,n>>>=0,t=he(t>>>0),e=Fe(e,"emval::as"),Ue(e,n,t)}var je=t=>{try{t()}catch(t){X(t)}},Be=0,Le=null,He=0,Ve=[],We={},Ge={},Qe=0,Ke=null,Xe=[];function Ze(t){return function(e){if(!B){if(0===Be){var n=!1,i=!1;t().then(((t=0)=>{if(!B&&(He=t,n=!0,i)){Be=2,je((()=>Ti(Le))),typeof Browser<"u"&&Browser.Jb.Qb&&Browser.Jb.resume(),t=!1;try{var e=(a=o()[Le+8>>>2>>>0],a=fi[Ge[a]],--ht,a())}catch(a){e=a,t=!0}var r=!1;if(!Le){var s=Ke;s&&(Ke=null,(t?s.reject:s.resolve)(e),r=!0)}if(t&&!r)throw e}var a})),i=!0,n||(Be=1,Le=function(){var t=mi(65548),e=t+12;a()[t>>>2>>>0]=e,a()[t+4>>>2>>>0]=e+65536,e=Ve[0];var n=We[e];return void 0===n&&(n=Qe++,We[e]=n,Ge[n]=e),e=n,o()[t+8>>>2>>>0]=e,t}(),typeof Browser<"u"&&Browser.Jb.Qb&&Browser.Jb.pause(),je((()=>Ii(Le))))}else 2===Be?(Be=0,je(zi),wi(Le),Le=null,Xe.forEach(Ie)):X(`invalid state: ${Be}`);return He}}()}function Ye(t){return t>>>=0,Ze((()=>(t=he(t)).then(le)))}var Je=[];function tn(t,e,n,i){return n>>>=0,i>>>=0,(t=Je[t>>>0])(null,e=he(e>>>0),n,i)}var en={},nn=t=>{var e=en[t];return void 0===e?Yt(t):e};function rn(t,e,n,i,r){return n>>>=0,i>>>=0,r>>>=0,(t=Je[t>>>0])(e=he(e>>>0),e[n=nn(n)],i,r)}var sn=()=>"object"==typeof globalThis?globalThis:Function("","return this")();function on(t){return 0==(t>>>=0)?le(sn()):(t=nn(t),le(sn()[t]))}var an=t=>{var e=Je.length;return Je.push(t),e},un=(t,e)=>{for(var n=Array(t),i=0;i<t;++i)n[i]=Fe(a()[e+4*i>>>2>>>0],"parameter "+i);return n},hn=(t,e)=>Object.defineProperty(e,"name",{value:t});function ln(t,e,n){var i=(e=un(t,e>>>0)).shift();t--;var r="return function (obj, func, destructorsRef, args) {\n",s=0,o=[];0===n&&o.push("obj");for(var a=["retType"],u=[i],h=0;h<t;++h)o.push("arg"+h),a.push("argType"+h),u.push(e[h]),r+=` var arg${h} = argType${h}.readValueFromPointer(args${s?"+"+s:""});\n`,s+=e[h].argPackAdvance;return r+=` var rv = ${1===n?"new func":"func.call"}(${o.join(", ")});\n`,i.Sb||(a.push("emval_returnValue"),u.push(Ue),r+=" return emval_returnValue(retType, destructorsRef, rv);\n"),a.push(r+"};\n"),t=function(t){var e=Function;if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var n=hn(e.name||"unknownFunctionName",(function(){}));return n.prototype=e.prototype,n=new n,(t=e.apply(n,t))instanceof Object?t:n}(a)(...u),n=`methodCaller<(${e.map((t=>t.name)).join(", ")}) => ${i.name}>`,an(hn(n,t))}function cn(t){return t=nn(t>>>0),le(f[t])}function fn(t,e){return e>>>=0,t=he(t>>>0),e=he(e),le(t[e])}function dn(t){9<(t>>>=0)&&(ae[t+1]+=1)}function pn(){return le([])}function vn(t){t=he(t>>>0);for(var e=Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return le(e)}function yn(t){return le(nn(t>>>0))}function mn(){return le({})}function wn(t){for(var e=he(t>>>=0);e.length;){var n=e.pop();e.pop()(n)}ue(t)}function gn(t,e,n){e>>>=0,n>>>=0,t=he(t>>>0),e=he(e),n=he(n),t[e]=n}function bn(t,e){return e>>>=0,t=(t=Fe(t>>>0,"_emval_take_value")).readValueFromPointer(e),le(t)}function xn(t,e){t=-9007199254740992>t||9007199254740992<t?NaN:Number(t),e>>>=0,t=new Date(1e3*t),o()[e>>>2>>>0]=t.getUTCSeconds(),o()[e+4>>>2>>>0]=t.getUTCMinutes(),o()[e+8>>>2>>>0]=t.getUTCHours(),o()[e+12>>>2>>>0]=t.getUTCDate(),o()[e+16>>>2>>>0]=t.getUTCMonth(),o()[e+20>>>2>>>0]=t.getUTCFullYear()-1900,o()[e+24>>>2>>>0]=t.getUTCDay(),t=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,o()[e+28>>>2>>>0]=t}var _n=t=>t%4==0&&(t%100!=0||t%400==0),kn=[0,31,60,91,121,152,182,213,244,274,305,335],$n=[0,31,59,90,120,151,181,212,243,273,304,334];function Sn(t,e){t=-9007199254740992>t||9007199254740992<t?NaN:Number(t),e>>>=0,t=new Date(1e3*t),o()[e>>>2>>>0]=t.getSeconds(),o()[e+4>>>2>>>0]=t.getMinutes(),o()[e+8>>>2>>>0]=t.getHours(),o()[e+12>>>2>>>0]=t.getDate(),o()[e+16>>>2>>>0]=t.getMonth(),o()[e+20>>>2>>>0]=t.getFullYear()-1900,o()[e+24>>>2>>>0]=t.getDay();var n=(_n(t.getFullYear())?kn:$n)[t.getMonth()]+t.getDate()-1|0;o()[e+28>>>2>>>0]=n,o()[e+36>>>2>>>0]=-60*t.getTimezoneOffset(),n=new Date(t.getFullYear(),6,1).getTimezoneOffset();var i=new Date(t.getFullYear(),0,1).getTimezoneOffset();t=0|(n!=i&&t.getTimezoneOffset()==Math.min(i,n)),o()[e+32>>>2>>>0]=t}function Mn(t){t>>>=0;var e=new Date(o()[t+20>>>2>>>0]+1900,o()[t+16>>>2>>>0],o()[t+12>>>2>>>0],o()[t+8>>>2>>>0],o()[t+4>>>2>>>0],o()[t>>>2>>>0],0),n=o()[t+32>>>2>>>0],i=e.getTimezoneOffset(),r=new Date(e.getFullYear(),6,1).getTimezoneOffset(),s=new Date(e.getFullYear(),0,1).getTimezoneOffset(),a=Math.min(s,r);return 0>n?o()[t+32>>>2>>>0]=+(r!=s&&a==i):0<n!=(a==i)&&(r=Math.max(s,r),e.setTime(e.getTime()+6e4*((0<n?a:r)-i))),o()[t+24>>>2>>>0]=e.getDay(),n=(_n(e.getFullYear())?kn:$n)[e.getMonth()]+e.getDate()-1|0,o()[t+28>>>2>>>0]=n,o()[t>>>2>>>0]=e.getSeconds(),o()[t+4>>>2>>>0]=e.getMinutes(),o()[t+8>>>2>>>0]=e.getHours(),o()[t+12>>>2>>>0]=e.getDate(),o()[t+16>>>2>>>0]=e.getMonth(),o()[t+20>>>2>>>0]=e.getYear(),t=e.getTime(),BigInt(isNaN(t)?-1:t/1e3)}function En(t,e,n,i,r,s,o){return y?lt(16,1,t,e,n,i,r,s,o):-52}function Cn(t,e,n,i,r,s){if(y)return lt(17,1,t,e,n,i,r,s)}function An(t,e,n,i){t>>>=0,e>>>=0,n>>>=0,i>>>=0;var r=(new Date).getFullYear(),s=new Date(r,0,1),u=new Date(r,6,1);r=s.getTimezoneOffset();var h=u.getTimezoneOffset(),l=Math.max(r,h);a()[t>>>2>>>0]=60*l,o()[e>>>2>>>0]=+(r!=h),s=(t=t=>t.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1])(s),u=t(u),h<r?(Nt(s,n,17),Nt(u,i,17)):(Nt(s,i,17),Nt(u,n,17))}var In=[],On=(t,e)=>{In.length=0;for(var n;n=i()[t++>>>0];){var r=105!=n;e+=(r&=112!=n)&&e%8?4:0,In.push(112==n?a()[e>>>2>>>0]:106==n?U[e>>>3]:105==n?o()[e>>>2>>>0]:h()[e>>>3>>>0]),e+=r?8:4}return In};function Tn(t,e,n){return t>>>=0,e=On(e>>>0,n>>>0),it[t](...e)}function zn(t,e,n){return t>>>=0,e=On(e>>>0,n>>>0),it[t](...e)}var Dn=()=>{},Pn=()=>Date.now();function Rn(t,e){return M(Tt(t>>>0,e>>>0))}var Nn,Fn=()=>{throw ht+=1,"unwind"};function Un(){return 4294901760}Nn=()=>performance.timeOrigin+performance.now();var qn=()=>navigator.hardwareConcurrency;function jn(){return X("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER"),0}function Bn(t){t>>>=0;var e=i().length;if(t<=e||4294901760<t)return!1;for(var n=1;4>=n;n*=2){var r=e*(1+.2/n);r=Math.min(r,t+100663296);var s=Math;r=Math.max(t,r);t:{s=(s.min.call(s,4294901760,r+(65536-r%65536)%65536)-A.buffer.byteLength+65535)/65536;try{A.grow(s),L();var o=1;break t}catch{}o=void 0}if(o)return!0}return!1}var Ln=()=>(X("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER"),0),Hn={},Vn=t=>{t.forEach((t=>{Ln()}))};function Wn(){var t=Error().stack.toString().split("\n");return"Error"==t[0]&&t.shift(),Vn(t),Hn.Ob=Ln(),Hn.ac=t,Hn.Ob}function Gn(t,e,n){if(t>>>=0,e>>>=0,Hn.Ob==t)var i=Hn.ac;else"Error"==(i=Error().stack.toString().split("\n"))[0]&&i.shift(),Vn(i);for(var r=3;i[r]&&Ln()!=t;)++r;for(t=0;t<n&&i[t+r];++t)o()[e+4*t>>>2>>>0]=Ln();return t}var Qn,Kn={},Xn=()=>{if(!Qn){var t,e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",it:"./this.program"};for(t in Kn)void 0===Kn[t]?delete e[t]:e[t]=Kn[t];var n=[];for(t in e)n.push(`${t}=${e[t]}`);Qn=n}return Qn};function Zn(t,n){if(y)return lt(18,1,t,n);t>>>=0,n>>>=0;var i=0;return Xn().forEach(((r,s)=>{var o=n+i;for(s=a()[t+4*s>>>2>>>0]=o,o=0;o<r.length;++o)e()[s++>>>0]=r.charCodeAt(o);e()[s>>>0]=0,i+=r.length+1})),0}function Yn(t,e){if(y)return lt(19,1,t,e);t>>>=0,e>>>=0;var n=Xn();a()[t>>>2>>>0]=n.length;var i=0;return n.forEach((t=>i+=t.length+1)),a()[e>>>2>>>0]=i,0}function Jn(t){return y?lt(20,1,t):52}function ti(t,e,n,i){return y?lt(21,1,t,e,n,i):52}function ei(t,e,n,i){return y?lt(22,1,t,e,n,i):70}var ni=[null,[],[]];function ii(t,e,n,r){if(y)return lt(23,1,t,e,n,r);e>>>=0,n>>>=0,r>>>=0;for(var s=0,o=0;o<n;o++){var u=a()[e>>>2>>>0],h=a()[e+4>>>2>>>0];e+=8;for(var l=0;l<h;l++){var c=i()[u+l>>>0],f=ni[t];0===c||10===c?((1===t?S:M)(Ot(f,0)),f.length=0):f.push(c)}s+=h}return a()[r>>>2>>>0]=s,0}var ri=[31,29,31,30,31,30,31,31,30,31,30,31],si=[31,28,31,30,31,30,31,31,30,31,30,31],oi=(t,n)=>{e().set(t,n>>>0)};function ai(t,e,n,i){function r(t,e,n){for(t="number"==typeof t?t.toString():t||"";t.length<e;)t=n[0]+t;return t}function s(t,e){return r(t,e,"0")}function u(t,e){function n(t){return 0>t?-1:0<t?1:0}var i;return 0===(i=n(t.getFullYear()-e.getFullYear()))&&0===(i=n(t.getMonth()-e.getMonth()))&&(i=n(t.getDate()-e.getDate())),i}function h(t){switch(t.getDay()){case 0:return new Date(t.getFullYear()-1,11,29);case 1:return t;case 2:return new Date(t.getFullYear(),0,3);case 3:return new Date(t.getFullYear(),0,2);case 4:return new Date(t.getFullYear(),0,1);case 5:return new Date(t.getFullYear()-1,11,31);case 6:return new Date(t.getFullYear()-1,11,30)}}function l(t){var e=t.Bb;for(t=new Date(new Date(t.Cb+1900,0,1).getTime());0<e;){var n=t.getMonth(),i=(_n(t.getFullYear())?ri:si)[n];if(!(e>i-t.getDate())){t.setDate(t.getDate()+e);break}e-=i-t.getDate()+1,t.setDate(1),11>n?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return n=new Date(t.getFullYear()+1,0,4),e=h(new Date(t.getFullYear(),0,4)),n=h(n),0>=u(e,t)?0>=u(n,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}t>>>=0,e>>>=0,n>>>=0,i>>>=0;var c=a()[i+40>>>2>>>0];for(var f in i={fc:o()[i>>>2>>>0],ec:o()[i+4>>>2>>>0],Gb:o()[i+8>>>2>>>0],Kb:o()[i+12>>>2>>>0],Hb:o()[i+16>>>2>>>0],Cb:o()[i+20>>>2>>>0],ub:o()[i+24>>>2>>>0],Bb:o()[i+28>>>2>>>0],nc:o()[i+32>>>2>>>0],dc:o()[i+36>>>2>>>0],hc:c?Tt(c):""},n=Tt(n),c={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(f,"g"),c[f]);var d,p,v="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),y="January February March April May June July August September October November December".split(" ");for(f in c={"%a":t=>v[t.ub].substring(0,3),"%A":t=>v[t.ub],"%b":t=>y[t.Hb].substring(0,3),"%B":t=>y[t.Hb],"%C":t=>s((t.Cb+1900)/100|0,2),"%d":t=>s(t.Kb,2),"%e":t=>r(t.Kb,2," "),"%g":t=>l(t).toString().substring(2),"%G":l,"%H":t=>s(t.Gb,2),"%I":t=>(0==(t=t.Gb)?t=12:12<t&&(t-=12),s(t,2)),"%j":t=>{for(var e=0,n=0;n<=t.Hb-1;e+=(_n(t.Cb+1900)?ri:si)[n++]);return s(t.Kb+e,3)},"%m":t=>s(t.Hb+1,2),"%M":t=>s(t.ec,2),"%n":()=>"\n","%p":t=>0<=t.Gb&&12>t.Gb?"AM":"PM","%S":t=>s(t.fc,2),"%t":()=>"\t","%u":t=>t.ub||7,"%U":t=>s(Math.floor((t.Bb+7-t.ub)/7),2),"%V":t=>{var e=Math.floor((t.Bb+7-(t.ub+6)%7)/7);if(2>=(t.ub+371-t.Bb-2)%7&&e++,e)53==e&&(4==(n=(t.ub+371-t.Bb)%7)||3==n&&_n(t.Cb)||(e=1));else{e=52;var n=(t.ub+7-t.Bb-1)%7;(4==n||5==n&&_n(t.Cb%400-1))&&e++}return s(e,2)},"%w":t=>t.ub,"%W":t=>s(Math.floor((t.Bb+7-(t.ub+6)%7)/7),2),"%y":t=>(t.Cb+1900).toString().substring(2),"%Y":t=>t.Cb+1900,"%z":t=>(0<=(t=t.dc)?"+":"-")+("0000"+((t=Math.abs(t)/60)/60*100+t%60)).slice(-4),"%Z":t=>t.hc,"%%":()=>"%"},n=n.replace(/%%/g,"\0\0"),c)n.includes(f)&&(n=n.replace(new RegExp(f,"g"),c[f](i)));return d=n=n.replace(/\0\0/g,"%"),p=Array(Pt(d)+1),Rt(d,p,0,p.length),(f=p).length>e?0:(oi(f,t),f.length-1)}function ui(t,e,n,i){return ai(t>>>0,e>>>0,n>>>0,i>>>0)}y||function(){for(var t=f.numThreads-1;t--;)xt();H.unshift((()=>{G++,function(t){y?t():Promise.all(pt.map(bt)).then(t)}((()=>K()))}))}();for(var hi=Array(256),li=0;256>li;++li)hi[li]=String.fromCharCode(li);Kt=hi,Xt=f.BindingError=class extends Error{constructor(t){super(t),this.name="BindingError"}},f.InternalError=class extends Error{constructor(t){super(t),this.name="InternalError"}},ae.push(0,1,void 0,1,null,1,!0,1,!1,1),f.count_emval_handles=()=>ae.length/2-5-oe.length;var ci=[ct,ft,Ct,zt,Dt,Ft,Ut,qt,jt,Bt,Lt,Ht,Vt,Wt,Gt,Qt,En,Cn,Zn,Yn,Jn,ti,ei,ii],fi=function(){function t(t,e){return fi=t.exports,fi=function(){var t=fi,e={};for(let[n,i]of Object.entries(t))e[n]="function"==typeof i?(...t)=>{Ve.push(n);try{return i(...t)}finally{B||(Ve.pop(),Le&&1===Be&&0===Ve.length&&(Be=0,ht+=1,je(Oi),typeof Fibers<"u"&&Fibers.oc()))}}:i;return e}(),fi=function(){var t=fi,e=t=>e=>t(e)>>>0,n=t=>()=>t()>>>0;return(t=Object.assign({},t)).Ca=e(t.Ca),t.fb=n(t.fb),t.gb=e(t.gb),t.emscripten_main_runtime_thread_id=n(t.emscripten_main_runtime_thread_id),t.sb=e(t.sb),t.tb=n(t.tb),t}(),yt.push(fi.ib),V.unshift(fi.Ba),I=e,K(),fi}var e=nt();if(G++,f.instantiateWasm)try{return f.instantiateWasm(e,t)}catch(t){M(`Module.instantiateWasm callback failed with error: ${t}`),c(t)}return Z||=f.locateFile?Y("ort-wasm-simd-threaded.jsep.wasm")?"ort-wasm-simd-threaded.jsep.wasm":f.locateFile?f.locateFile("ort-wasm-simd-threaded.jsep.wasm",k):k+"ort-wasm-simd-threaded.jsep.wasm":new URL("ort-wasm-simd-threaded.jsep.wasm",n&&n.src||new URL("yunjing-for-cesium.js",document.baseURI).href).href,function(t,e){var n=Z;return $||"function"!=typeof WebAssembly.instantiateStreaming||Y(n)||J(n)||"function"!=typeof fetch?et(n,t,e):fetch(n,{credentials:"same-origin"}).then((i=>WebAssembly.instantiateStreaming(i,t).then(e,(function(i){return M(`wasm streaming compile failed: ${i}`),M("falling back to ArrayBuffer instantiation"),et(n,t,e)}))))}(e,(function(e){t(e.instance,e.module)})).catch(c),{}}(),di=t=>(di=fi.Ca)(t),pi=()=>(pi=fi.Da)();f.rt=(t,e)=>(f.rt=fi.Ea)(t,e),f.st=(t,e)=>(f.st=fi.Fa)(t,e),f.ot=(t,e,n,i,r,s,o,a,u,h)=>(f.ot=fi.Ga)(t,e,n,i,r,s,o,a,u,h),f.ut=(t,e)=>(f.ut=fi.Ha)(t,e),f.ht=(t,e,n)=>(f.ht=fi.Ia)(t,e,n),f.ct=(t,e,n)=>(f.ct=fi.Ja)(t,e,n),f.ft=t=>(f.ft=fi.Ka)(t),f._=(t,e,n)=>(f._=fi.La)(t,e,n),f.vt=t=>(f.vt=fi.Ma)(t),f.yt=(t,e,n)=>(f.yt=fi.Na)(t,e,n),f.wt=(t,e)=>(f.wt=fi.Oa)(t,e),f.bt=(t,e)=>(f.bt=fi.Pa)(t,e),f.xt=t=>(f.xt=fi.Qa)(t),f._t=(t,e,n,i,r,s)=>(f._t=fi.Ra)(t,e,n,i,r,s),f.kt=(t,e,n,i,r)=>(f.kt=fi.Sa)(t,e,n,i,r),f.$t=t=>(f.$t=fi.Ta)(t),f.St=(t,e,n,i)=>(f.St=fi.Ua)(t,e,n,i),f.Mt=(t,e,n)=>(f.Mt=fi.Va)(t,e,n),f.Et=t=>(f.Et=fi.Wa)(t),f.Ct=t=>(f.Ct=fi.Xa)(t),f.nt=(t,e,n)=>(f.nt=fi.Ya)(t,e,n),f.At=(t,e,n,i)=>(f.At=fi.Za)(t,e,n,i),f.It=t=>(f.It=fi.Ot)(t),f.Tt=t=>(f.Tt=fi.$a)(t),f.et=(t,e,n,i,r)=>(f.et=fi.ab)(t,e,n,i,r),f.tt=(t,e,n,i,r,s,o,a)=>(f.tt=fi.bb)(t,e,n,i,r,s,o,a),f.zt=t=>(f.zt=fi.cb)(t),f.Dt=(t,e,n)=>(f.Dt=fi.db)(t,e,n),f.Pt=t=>(f.Pt=fi.eb)(t);var vi,yi=()=>(yi=fi.fb)(),mi=f.Rt=t=>(mi=f.Rt=fi.gb)(t),wi=f.Nt=t=>(wi=f.Nt=fi.hb)(t),gi=(t,e,n,i,r,s)=>(gi=fi.kb)(t,e,n,i,r,s),bi=()=>(bi=fi.lb)(),xi=(t,e,n,i,r)=>(xi=fi.mb)(t,e,n,i,r),_i=t=>(_i=fi.nb)(t),ki=t=>(ki=fi.ob)(t),$i=()=>($i=fi.pb)(),Si=(t,e)=>(Si=fi.qb)(t,e),Mi=t=>(Mi=fi.rb)(t),Ei=t=>(Ei=fi.sb)(t),Ci=()=>(Ci=fi.tb)(),Ai=f.dynCall_ii=(t,e)=>(Ai=f.dynCall_ii=fi.vb)(t,e),Ii=t=>(Ii=fi.wb)(t),Oi=()=>(Oi=fi.xb)(),Ti=t=>(Ti=fi.yb)(t),zi=()=>(zi=fi.zb)();function Di(){0<G||(y?(l(f),y||_t(V),startWorker(f)):(_t(H),0<G||vi||(vi=!0,f.calledRun=!0,B||(y||_t(V),l(f),y||_t(W)))))}return f.Ft=862621,f.Ut=862843,f.stackSave=()=>Ci(),f.stackRestore=t=>Mi(t),f.stackAlloc=t=>Ei(t),f.UTF8ToString=Tt,f.stringToUTF8=Nt,f.lengthBytesUTF8=Pt,Q=function t(){vi||Di(),vi||(Q=t)},Di(),d},St=$t,"em-pthread"===globalThis.self?.name&&$t()})),du=V((()=>{yt(),Mt=(n&&n.src||new URL("yunjing-for-cesium.js",document.baseURI).href)??(typeof document<"u"?document.currentScript?.src:typeof self<"u"?self.location?.href:void 0),Et=typeof location>"u"?void 0:location.origin,Ct=(t,e)=>{try{let n=e??Mt;return(n?new URL(t,n):new URL(t)).origin===Et}catch{return!1}},At=async t=>{let e=await(await fetch(t,{credentials:"same-origin"})).blob();return URL.createObjectURL(e)},It=(xt(),G(mt)).default,Ot=async()=>{if(!Mt)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Ct(Mt))return[void 0,It()];let t=await At(Mt);return[t,It(t)]},Tt=(fu(),G(_t)).default,zt=async(t,e,n)=>[void 0,Tt]})),pu=V((()=>{du(),Pt=!1,Rt=!1,Nt=!1,Ft=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},Ut=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},qt=async t=>{if(Pt)return Promise.resolve();if(Rt)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Nt)throw new Error("previous call to 'initializeWebAssembly()' failed.");Rt=!0;let e=t.initTimeout,n=t.numThreads;if(!Ut())throw new Error("WebAssembly SIMD is not supported in the current environment.");let i=Ft();n>1&&!i&&(typeof self<"u"&&self.crossOriginIsolated,t.numThreads=n=1);let r=t.wasmPaths,s="string"==typeof r?r:void 0,o=r?.mjs,a=o?.href??o,u=r?.wasm,h=u?.href??u,l=t.wasmBinary,[c,f]=await zt(a,s,n>1),d=!1,p=[];if(e>0&&p.push(new Promise((t=>{setTimeout((()=>{d=!0,t()}),e)}))),p.push(new Promise(((t,e)=>{let i={numThreads:n};l?i.wasmBinary=l:(h||s)&&(i.locateFile=(t,e)=>h??(s??e)+t),f(i).then((e=>{Rt=!1,Pt=!0,Dt=e,t(),c&&URL.revokeObjectURL(c)}),(t=>{Rt=!1,Nt=!0,e(t)}))}))),await Promise.race(p),d)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},jt=()=>{if(Pt&&Dt)return Dt;throw new Error("WebAssembly is not initialized yet.")}})),vu=V((()=>{pu(),Bt=(t,e)=>{let n=jt(),i=n.lengthBytesUTF8(t)+1,r=n.Rt(i);return n.stringToUTF8(t,r,i),e.push(r),r},Lt=(t,e,n,i)=>{if("object"==typeof t&&null!==t){if(n.has(t))throw new Error("Circular reference in options");n.add(t)}Object.entries(t).forEach((([t,r])=>{let s=e?e+t:t;if("object"==typeof r)Lt(r,s+".",n,i);else if("string"==typeof r||"number"==typeof r)i(s,r.toString());else{if("boolean"!=typeof r)throw new Error("Can't handle extra config type: "+typeof r);i(s,r?"1":"0")}}))},Ht=t=>{let e=jt(),n=e.stackSave();try{let n=e.stackAlloc(8);e.st(n,n+4);let i=e.HEAP32[n/4],r=e.HEAPU32[n/4+1],s=r?e.UTF8ToString(r):"";throw new Error(`${t} ERROR_CODE: ${i}, ERROR_MESSAGE: ${s}`)}finally{e.stackRestore(n)}}})),yu=V((()=>{pu(),vu(),Vt=t=>{let e=jt(),n=0,i=[],r=t||{};try{if(void 0===t?.logSeverityLevel)r.logSeverityLevel=2;else if("number"!=typeof t.logSeverityLevel||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(void 0===t?.logVerbosityLevel)r.logVerbosityLevel=0;else if("number"!=typeof t.logVerbosityLevel||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);void 0===t?.terminate&&(r.terminate=!1);let s=0;return void 0!==t?.tag&&(s=Bt(t.tag,i)),n=e.St(r.logSeverityLevel,r.logVerbosityLevel,!!r.terminate,s),0===n&&Ht("Can't create run options."),void 0!==t?.extra&&Lt(t.extra,"",new WeakSet,((t,r)=>{let s=Bt(t,i),o=Bt(r,i);0!==e.Mt(n,s,o)&&Ht(`Can't set a run config entry: ${t} - ${r}.`)})),[n,i]}catch(t){throw 0!==n&&e.Et(n),i.forEach((t=>e.Nt(t))),t}}})),mu=V((()=>{pu(),vu(),Wt=t=>{switch(t){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${t}`)}},Gt=t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}},Qt=t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});let e=t.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1"),t.executionProviders&&t.executionProviders.some((t=>"webgpu"===("string"==typeof t?t:t.name)))&&(t.enableMemPattern=!1)},Kt=(t,e,n)=>{for(let i of e){let e="string"==typeof i?i:i.name;switch(e){case"webnn":if(e="WEBNN","string"!=typeof i){let e=i?.deviceType;if(e){let i=Bt("deviceType",n),r=Bt(e,n);0!==jt().ct(t,i,r)&&Ht(`Can't set a session config entry: 'deviceType' - ${e}.`)}}break;case"webgpu":if(e="JS","string"!=typeof i){let e=i;if(e?.preferredLayout){if("NCHW"!==e.preferredLayout&&"NHWC"!==e.preferredLayout)throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${e.preferredLayout}`);let i=Bt("preferredLayout",n),r=Bt(e.preferredLayout,n);0!==jt().ct(t,i,r)&&Ht(`Can't set a session config entry: 'preferredLayout' - ${e.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${e}`)}let r=Bt(e,n);0!==jt().ut(t,r)&&Ht(`Can't append execution provider: ${e}.`)}},Xt=t=>{let e=jt(),n=0,i=[],r=t||{};Qt(r);try{let t=Wt(r.graphOptimizationLevel??"all"),s=Gt(r.executionMode??"sequential"),o="string"==typeof r.logId?Bt(r.logId,i):0,a=r.logSeverityLevel??2;if(!Number.isInteger(a)||a<0||a>4)throw new Error(`log serverity level is not valid: ${a}`);let u=r.logVerbosityLevel??0;if(!Number.isInteger(u)||u<0||u>4)throw new Error(`log verbosity level is not valid: ${u}`);let h="string"==typeof r.optimizedModelFilePath?Bt(r.optimizedModelFilePath,i):0;if(n=e.ot(t,!!r.enableCpuMemArena,!!r.enableMemPattern,s,!!r.enableProfiling,0,o,a,u,h),0===n&&Ht("Can't create session options."),r.executionProviders&&Kt(n,r.executionProviders,i),void 0!==r.enableGraphCapture){if("boolean"!=typeof r.enableGraphCapture)throw new Error(`enableGraphCapture must be a boolean value: ${r.enableGraphCapture}`);let t=Bt("enableGraphCapture",i),s=Bt(r.enableGraphCapture.toString(),i);0!==e.ct(n,t,s)&&Ht(`Can't set a session config entry: 'enableGraphCapture' - ${r.enableGraphCapture}.`)}if(r.freeDimensionOverrides)for(let[t,s]of Object.entries(r.freeDimensionOverrides)){if("string"!=typeof t)throw new Error(`free dimension override name must be a string: ${t}`);if("number"!=typeof s||!Number.isInteger(s)||s<0)throw new Error(`free dimension override value must be a non-negative integer: ${s}`);let r=Bt(t,i);0!==e.ht(n,r,s)&&Ht(`Can't set a free dimension override: ${t} - ${s}.`)}return void 0!==r.extra&&Lt(r.extra,"",new WeakSet,((t,r)=>{let s=Bt(t,i),o=Bt(r,i);0!==e.ct(n,s,o)&&Ht(`Can't set a session config entry: ${t} - ${r}.`)})),[n,i]}catch(t){throw 0!==n&&e.ft(n),i.forEach((t=>e.Nt(t))),t}}})),wu=V((()=>{Zt=t=>{switch(t){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${t}`)}},Yt=t=>{switch(t){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${t}`)}},Jt=t=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][t],te=t=>{switch(t){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${t}`)}},ee=t=>{switch(t){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${t}`)}},ne=t=>"float32"===t||"float16"===t||"int32"===t||"int64"===t||"uint32"===t||"uint8"===t||"bool"===t,ie=t=>{switch(t){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;default:throw new Error(`unsupported data location: ${t}`)}}})),gu=V((()=>{yt(),re=async t=>{if("string"==typeof t){let e=await fetch(t);if(!e.ok)throw new Error(`failed to load external data file: ${t}`);let n=e.headers.get("Content-Length"),i=n?parseInt(n,10):0;if(i<1073741824)return new Uint8Array(await e.arrayBuffer());{if(!e.body)throw new Error(`failed to load external data file: ${t}, no response body.`);let n,r=e.body.getReader();try{n=new ArrayBuffer(i)}catch(t){if(!(t instanceof RangeError))throw t;{let t=Math.ceil(i/65536);n=new WebAssembly.Memory({initial:t,maximum:t}).buffer}}let s=0;for(;;){let{done:t,value:e}=await r.read();if(t)break;let i=e.byteLength;new Uint8Array(n,s,i).set(e),s+=i}return new Uint8Array(n,0,i)}}return t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t instanceof Uint8Array?t:new Uint8Array(t)}})),bu=V((()=>{wu(),ae=(t,e)=>{se=t,oe=e},ue=(t,e)=>{ee(t)>=ee(se)&&"function"==typeof e&&e()},he=(...t)=>{oe&&ue(...t)}})),xu=V((()=>{wu(),le=(t,e)=>new(te(e))(t)})),_u=V((()=>{})),ku=V((()=>{bu(),_u(),ce=new Map([[64,250],[128,200],[256,200],[512,200],[2048,230],[4096,200],[8192,50],[16384,50],[32768,50],[65536,50],[131072,50],[262144,50],[524288,50],[1048576,50],[2097152,30],[4194304,20],[8388608,10],[12582912,10],[16777216,10],[26214400,15],[33554432,22],[44236800,2],[58982400,6],[67108864,6],[134217728,6],[167772160,6]]),fe=[],de=t=>16*Math.ceil(t/16),pe=t=>{for(let e=0;e<fe.length;e++){let n=fe[e];if(t<=n)return n}return 16*Math.ceil(t/16)},ve=1,ye=()=>ve++,me=async(t,e,n,i)=>{let r=de(n),s=t.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});try{let o=t.getCommandEncoder();t.endComputePass(),o.copyBufferToBuffer(e,0,s,0,r),t.flush(),await s.mapAsync(GPUMapMode.READ);let a=s.getMappedRange();if(i){let t=i();return t.set(new Uint8Array(a,0,n)),t}return new Uint8Array(a.slice(0,n))}finally{s.destroy()}},we=class{constructor(t){this.backend=t,this.storageCache=new Map,this.freeBuffers=new Map,this.freeUniformBuffers=new Map,this.buffersForUploadingPending=[],this.buffersPending=[],this.externalBuffers=new Map,this.capturedPendingBuffers=new Map;for(let[t]of ce)fe.push(t),this.freeBuffers.set(t,[]),this.freeUniformBuffers.set(t,[])}upload(t,e){let n=e.buffer,i=e.byteOffset,r=e.byteLength,s=de(r),o=this.storageCache.get(t);if(!o)throw new Error("gpu data for uploading does not exist");if(o.originalSize!==r)throw new Error(`inconsistent data size. gpu data size=${o.originalSize}, data size=${r}`);let a=this.backend.device.createBuffer({mappedAtCreation:!0,size:s,usage:GPUBufferUsage.MAP_WRITE|GPUBufferUsage.COPY_SRC}),u=a.getMappedRange();new Uint8Array(u).set(new Uint8Array(n,i,r)),a.unmap();let h=this.backend.getCommandEncoder();this.backend.endComputePass(),h.copyBufferToBuffer(a,0,o.gpuData.buffer,0,s),he("verbose",(()=>`[WebGPU] GpuDataManager.upload(id=${t})`)),this.buffersForUploadingPending.push(a)}memcpy(t,e){let n=this.storageCache.get(t);if(!n)throw new Error("source gpu data for memcpy does not exist");let i=this.storageCache.get(e);if(!i)throw new Error("destination gpu data for memcpy does not exist");if(n.originalSize!==i.originalSize)throw new Error("inconsistent source and destination gpu data size");let r=de(n.originalSize),s=this.backend.getCommandEncoder();this.backend.endComputePass(),s.copyBufferToBuffer(n.gpuData.buffer,0,i.gpuData.buffer,0,r)}registerExternalBuffer(t,e,n){let i;if(n){if(i=this.externalBuffers.get(n),void 0===i)throw new Error("previous buffer is not registered");if(t===n)return he("verbose",(()=>`[WebGPU] GpuDataManager.registerExternalBuffer(size=${e}) => id=${i}, buffer is the same, skip.`)),i;if(this.backend.capturedCommandList.has(this.backend.currentSessionId))throw new Error("Registering a different external buffer under graph capture mode is not supported yet.\n Please use the previous external buffer!");this.externalBuffers.delete(n)}else i=ye();return this.storageCache.set(i,{gpuData:{id:i,type:0,buffer:t},originalSize:e}),this.externalBuffers.set(t,i),he("verbose",(()=>`[WebGPU] GpuDataManager.registerExternalBuffer(size=${e}) => id=${i}, registered.`)),i}unregisterExternalBuffer(t){let e=this.externalBuffers.get(t);void 0!==e&&(this.storageCache.delete(e),this.externalBuffers.delete(t),he("verbose",(()=>`[WebGPU] GpuDataManager.unregisterExternalBuffer() => id=${e}`)))}create(t,e=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST){let n,i=pe(t),r=(e&GPUBufferUsage.STORAGE)===GPUBufferUsage.STORAGE,s=(e&GPUBufferUsage.UNIFORM)===GPUBufferUsage.UNIFORM;if(r||s){let t=(r?this.freeBuffers:this.freeUniformBuffers).get(i);n=t&&t.length>0?t.pop():this.backend.device.createBuffer({size:i,usage:e})}else n=this.backend.device.createBuffer({size:i,usage:e});let o={id:ye(),type:0,buffer:n};return this.storageCache.set(o.id,{gpuData:o,originalSize:t}),he("verbose",(()=>`[WebGPU] GpuDataManager.create(size=${t}) => id=${o.id}`)),o}get(t){return this.storageCache.get(t)?.gpuData}release(t){let e=this.storageCache.get(t);if(!e)throw new Error("releasing data does not exist");return he("verbose",(()=>`[WebGPU] GpuDataManager.release(id=${t}), gpuDataId=${e.gpuData.id}`)),this.storageCache.delete(t),this.buffersPending.push(e.gpuData.buffer),e.originalSize}async download(t,e){let n=this.storageCache.get(t);if(!n)throw new Error("data does not exist");await me(this.backend,n.gpuData.buffer,n.originalSize,e)}refreshPendingBuffers(){for(let t of this.buffersForUploadingPending)t.destroy();if(this.buffersForUploadingPending=[],0!==this.buffersPending.length)if("default"===this.backend.sessionStatus){for(let t of this.buffersPending){let e=ce.get(t.size);if((t.usage&GPUBufferUsage.STORAGE)===GPUBufferUsage.STORAGE){let n=this.freeBuffers.get(t.size)||[];void 0===e||n.length>=e?t.destroy():n.push(t)}else if((t.usage&GPUBufferUsage.UNIFORM)===GPUBufferUsage.UNIFORM){let n=this.freeUniformBuffers.get(t.size)||[];void 0===e||n.length>=e?t.destroy():n.push(t)}else t.destroy()}this.buffersPending=[]}else{let t=this.capturedPendingBuffers.get(this.backend.currentSessionId);t||(t=[],this.capturedPendingBuffers.set(this.backend.currentSessionId,t));for(let e of this.buffersPending)t.push(e);this.buffersPending=[]}}dispose(){this.freeBuffers.forEach((t=>{t.forEach((t=>{t.destroy()}))})),this.freeUniformBuffers.forEach((t=>{t.forEach((t=>{t.destroy()}))})),this.storageCache.forEach((t=>{t.gpuData.buffer.destroy()})),this.capturedPendingBuffers.forEach((t=>{t.forEach((t=>{t.destroy()}))})),this.storageCache=new Map,this.freeBuffers=new Map,this.freeUniformBuffers=new Map,this.capturedPendingBuffers=new Map}onReleaseSession(t){let e=this.capturedPendingBuffers.get(t);e&&(e.forEach((t=>{t.destroy()})),this.capturedPendingBuffers.delete(t))}},ge=(...t)=>new we(...t)})),$u=V((()=>{be=class{constructor(t){Object.assign(this,t)}get cacheKey(){return this.key||(this.key=Object.getOwnPropertyNames(this).sort().map((t=>`${this[t]}`)).join(";")),this.key}},xe=t=>new be(t)})),Su=V((()=>{_e=class{static calcMatMulShape(t,e){return t[1]!==e[0]?void 0:[t[0],e[1]]}},ke=class{static calcShape(t,e,n=!1){let i=t.length,r=e.length;if(0===i)return e;if(0===r)return t;let s=Math.max(t.length,e.length),o=new Array(s);if(n){if(i<2||r<2)return;let n=_e.calcMatMulShape([t[i-2],t[i-1]],[e[r-2],e[r-1]]);if(void 0===n)return;[o[s-2],o[s-1]]=n}for(let a=n?3:1;a<=s;a++){let n=i-a<0?1:t[i-a],u=r-a<0?1:e[r-a];if(n!==u&&n>1&&u>1)return;let h=Math.max(n,u);if(n&&u)o[s-a]=Math.max(n,u);else{if(h>1)return;o[s-a]=0}}return o}static isValidBroadcast(t,e){let n=t.length,i=e.length;if(n>i)return!1;for(let r=1;r<=n;r++)if(1!==t[n-r]&&t[n-r]!==e[i-r])return!1;return!0}},$e=class t{static size(e){return t.getSizeFromDimensionRange(e,0,e.length)}static convertShape(t,e=4){let n=t.length;if(0===n)return[];let i=new Array(n),r=n-1;for(;r>=0;){if(t[r]%e==0){i[r]=t[r]/e;break}if(e%t[r]!=0)throw new Error("cannot convert shape");i[r]=1,e/=t[r],r--}for(r--;r>=0;r--)i[r]=t[r];return i}static sizeFromDimension(e,n){if(n<0||n>e.length)throw new Error(`invalid dimension of ${n} for sizeFromDimension as Tensor has ${e.length} dimensions.`);return t.getSizeFromDimensionRange(e,n,e.length)}static sizeToDimension(e,n){if(n<0||n>e.length)throw new Error(`invalid dimension of ${n} for sizeToDimension as Tensor has ${e.length} dimensions.`);return t.getSizeFromDimensionRange(e,0,n)}static getSizeFromDimensionRange(t,e,n){let i=1;for(let r=e;r<n;r++){if(t[r]<0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains negative values in them.");i*=t[r]}return i}static computeStrides(t){let e=t.length;if(0===e)return[];if(1===e)return[1];let n=new Array(e);n[e-1]=1,n[e-2]=t[e-1];for(let i=e-3;i>=0;--i)n[i]=n[i+1]*t[i+1];return n}static normalizeAxis(t,e){if(t<-e&&t>=e)throw new Error("unsupported axis for this operation.");return t<0?t+e:t}static normalizeAxes(t,e){return t.map((n=>this.normalizeAxis(n,e??t.length)))}static sortBasedOnPerm(t,e){return e?e.map((e=>t[e])):t.slice().reverse()}static padShape(t,e){let n=t.length;return t.map(((t,i)=>t+e[i]+e[i+n]))}static areEqual(t,e){return t.length===e.length&&t.every(((t,n)=>t===e[n]))}},Se=class t{static adjustPoolAttributes(t,e,n,i,r,s){if(!t&&n.length!==e.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(t)for(let t=0;t<e.length-2;t++)t>=n.length?n.push(e[t+2]):n[t]=e[t+2];for(let t=0;t<n.length;t++)if(t<i.length){if(i[t]<0)throw new Error("strides should be greater than or equal to 1")}else i.push(1);for(let t=0;t<n.length;t++)if(t<r.length){if(r[t]<0)throw new Error("dilations should be greater than or equal to 1")}else r.push(1);for(let t=0;t<2*n.length;t++)if(t<s.length){if(s[t]<0)throw new Error("pad should be greater than or equal to 1")}else s.push(0);for(let t=0;t<n.length;t++){if(n[t]<=0)throw new Error("kernel shapes need to be greater than 0");if(s[t]>=n[t]||s[t+n.length]>=n[t])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(e,n,i,r,s,o,a){if(a){if(s.length!==2*(e.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(n.length!==e.length-2)throw new Error("length of strides should be the length of data dimensions");if(r.length!==e.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let u=0;u<e.length-2;u++)t.adjustPadAndReturnShape(e[u+(o?1:2)],n[u],i[u],r[u],s,u,u+e.length-2,a)}}static computePoolOutputShape(e,n,i,r,s,o,a){if(n.length<=0)throw new Error("input shape must be of size greater than 0");let u=[n[0],n[1]];return t.computeShapeHelper(e,n,u,i,r,s,o,a),u}static computeConvOutputShape(e,n,i,r,s,o,a){if(e.length<=0||n.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let u=[e[0],n[0]];return t.computeShapeHelper(!1,e,u,i,r,s,o,a),u}static computeShapeHelper(e,n,i,r,s,o,a,u){if(e)for(let t=0;t<n.length-2;t++)i.push(1);else for(let e=0;e<n.length-2;e++)i.push(t.adjustPadAndReturnShape(n[e+2],r[e],s[e],o[e],a,e,e+n.length-2,u))}static adjustPadAndReturnShape(t,e,n,i,r,s,o,a){let u=n*(i-1)+1;if(!a||"NOTSET"===a)return Math.floor((t+r[s]+r[o]-u)/e+1);switch(a){case"VALID":return r[s]=0,r[o]=0,Math.floor((t-u)/e+1);case"SAME_LOWER":case"SAME_UPPER":if(1!==n)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let n=((t+e-1)/e-1)*e+i-t;return r[s]=Math.floor("SAME_LOWER"===a?(n+1)/2:n/2),r[o]=n-r[s],Math.floor((t+n-i)/e+1)}default:throw new Error("Unsupported AutoPad type")}}},Me=class{static getShapeOfGemmResult(t,e,n,i,r){if(2!==t.length||2!==n.length)throw new Error("shape need to be of size 2");let s,o,a;e?(s=t[1],o=t[0]):(s=t[0],o=t[1]);let u=-1;if(i?(a=n[0],u=1):(a=n[1],u=0),n[u]!==o)throw new Error("dimension mismatch");if(s<=0||a<=0||o<=0)throw new Error("invalid shape specified");if(r&&!ke.isValidBroadcast(r,[s,a]))throw new Error("gemm: invalid bias shape for broadcast");return[s,a,o]}},Ee=-34028234663852886e22,Ce=34028234663852886e22})),Mu=V((()=>{wu(),Su(),Ae=64,Ie=(t,e)=>{if(3===e)throw new Error("vec3 has same alignment as vec4, use vec4 instead");switch(t){case 10:return e>1?`vec${e}<f16>`:"f16";case 1:return e>1?`vec${e}<f32>`:"f32";case 6:return e>1?`vec${e}<i32>`:"i32";case 12:return e>1?`vec${e}<u32>`:"u32";case 7:if(e>1)throw new Error("currently not supported vecX of uint64 yet");return["vec2<u32>","i32"];case 13:if(e>1)throw new Error("currently not supported vecX of uint64 yet");return["vec2<u32>","u32"];case 9:if(4!==e)throw new Error("bool must be vec4");return["u32","vec4<bool>"];default:throw new Error(`Unknown data type: ${t}`)}},Oe=(t,e=1)=>{let n=Ie(t,e);return"string"==typeof n?n:n[0]},Te=(t,e=1)=>{let n=Ie(t,e);return"string"==typeof n?n:n[1]},ze=(...t)=>{let e=[];return t.forEach((t=>{0!==t.length&&e.push({type:12,data:t},{type:12,data:$e.computeStrides(t)})})),e},De=t=>t%4==0?4:t%2==0?2:1,Pe=(t="f32",e,n="0")=>e&&1!==e?`vec${e}<${t}>(${n})`:`${t}(${n})`,Re=(t,e,n)=>"f32"===t?n:1===e?`f32(${n})`:`vec${e}<f32>(${n})`,Ne=(t,e)=>4===e?`(${t}.x + ${t}.y + ${t}.z + ${t}.w)`:2===e?`(${t}.x + ${t}.y)`:3===e?`(${t}.x + ${t}.y + ${t}.z)`:t,Fe=(t,e,n,i)=>t.startsWith("uniforms.")&&n>4?"string"==typeof e?"f16"===i?`${t}[(${e}) / 8][(${e}) % 8 / 4][(${e}) % 8 % 4]`:`${t}[(${e}) / 4][(${e}) % 4]`:"f16"===i?`${t}[${Math.floor(e/8)}][${Math.floor(e%8/4)}][${e%8%4}]`:`${t}[${Math.floor(e/4)}][${e%4}]`:n>1?`${t}[${e}]`:t,Ue=(t,e,n,i,r)=>{let s="number"==typeof n,o=s?n:n.length,a=[...new Array(o).keys()],u=o<2?"u32":o<=4?`vec${o}<u32>`:`array<u32, ${o}>`,h=Ie(e,r),l="string"==typeof h?h:h[1],c="string"==typeof h?h:h[0],f={indices:u,value:l,storage:c,tensor:e},d=t=>"string"==typeof t?t:`${t}u`,p={offsetToIndices:!1,indicesToOffset:!1,broadcastedIndicesToOffset:!1,set:!1,setByIndices:!1,get:!1,getByIndices:!1},v=s?"uniforms.":"",y=`${v}${t}_shape`,m=`${v}${t}_strides`,w="";for(let t=0;t<o-1;t++)w+=`\n let dim${t} = current / ${Fe(m,t,o)};\n let rest${t} = current % ${Fe(m,t,o)};\n indices[${t}] = dim${t};\n current = rest${t};\n `;w+=`indices[${o-1}] = current;`;let g=o<2?"":`\n fn o2i_${t}(offset: u32) -> ${f.indices} {\n var indices: ${f.indices};\n var current = offset;\n ${w}\n return indices;\n }`,b=[];if(o>=2)for(let t=o-1;t>=0;t--)b.push(`${Fe(m,t,o)} * (indices[${t}])`);let x=o<2?"":`\n fn i2o_${t}(indices: ${f.indices}) -> u32 {\n return ${b.join("+")};\n }`,_=(...t)=>0===o?"0u":`${f.indices}(${t.map(d).join(",")})`,k=(t,e)=>o<2?`${t}`:`${Fe(t,e,o)}`,$={},S=(e,n)=>(()=>{if(f.storage===f.value)return`${t}[${e}]=${n};`;if("vec2<u32>"===f.storage&&"i32"===f.value)return`${t}[${e}]=vec2<u32>(u32(${n}), select(0u, 0xFFFFFFFFu, ${n} < 0));`;if("vec2<u32>"===f.storage&&"u32"===f.value)return`${t}[${e}]=vec2<u32>(u32(${n}), 0u);`;if("u32"===f.storage&&"vec4<bool>"===f.value)return`${t}[${e}]=dot(vec4<u32>(0x1, 0x100, 0x10000, 0x1000000), vec4<u32>(${n}));`;throw new Error(`not supported combination of storage type ${f.storage} and value type ${f.value} yet`)})(),M=e=>(()=>{if(f.storage===f.value)return`${t}[${e}]`;if("vec2<u32>"===f.storage&&"i32"===f.value)return`i32(${t}[${e}].x)`;if("vec2<u32>"===f.storage&&"u32"===f.value)return`u32(${t}[${e}].x)`;if("u32"===f.storage&&"vec4<bool>"===f.value)return`vec4<bool>(bool(${t}[${e}] & 0xFFu), bool(${t}[${e}] & 0xFF00u), bool(${t}[${e}] & 0xFF0000u), bool(${t}[${e}] & 0xFF000000u))`;throw new Error(`not supported combination of storage type ${f.storage} and value type ${f.value} yet`)})(),E=o<2?"":`\n fn get_${t}ByIndices(indices: ${f.indices}) -> ${l} {\n return ${M(`i2o_${t}(indices)`)};\n }`,C=o<2?"":(()=>{let e=a.map((t=>`d${t}: u32`)).join(", "),n=a.map((t=>`d${t}`)).join(", ");return`\n fn get_${t}(${e}) -> ${l} {\n return get_${t}ByIndices(${_(n)});\n }`})(),A=o<2?"":`\n fn set_${t}ByIndices(indices: ${f.indices}, value: ${l}) {\n ${S(`i2o_${t}(indices)`,"value")}\n }`,I=o<2?"":(()=>{let e=a.map((t=>`d${t}: u32`)).join(", "),n=a.map((t=>`d${t}`)).join(", ");return`\n fn set_${t}(${e}, value: ${l}) {\n set_${t}ByIndices(${_(n)}, value);\n }`})();return{impl:()=>{let t=[],e=!1;return p.offsetToIndices&&(t.push(g),e=!0),p.indicesToOffset&&(t.push(x),e=!0),p.broadcastedIndicesToOffset&&(Object.values($).forEach((e=>t.push(e))),e=!0),p.set&&(t.push(I),e=!0),p.setByIndices&&(t.push(A),e=!0),p.get&&(t.push(C),e=!0),p.getByIndices&&(t.push(E),e=!0),!s&&e&&t.unshift(`const ${y} = ${f.indices}(${n.join(",")});`,`const ${m} = ${f.indices}(${$e.computeStrides(n).join(",")});`),t.join("\n")},type:f,offsetToIndices:e=>(p.offsetToIndices=!0,o<2?e:`o2i_${t}(${e})`),indicesToOffset:e=>(p.indicesToOffset=!0,o<2?e:`i2o_${t}(${e})`),broadcastedIndicesToOffset:(e,n)=>{p.broadcastedIndicesToOffset=!0;let i=`${n.name}broadcastedIndicesTo${t}Offset`;if(i in $)return`${i}(${e})`;let r=[];for(let t=o-1;t>=0;t--){let e=n.indicesGet("outputIndices",t+n.rank-o);r.push(`${k(m,t)} * (${e} % ${k(y,t)})`)}return $[i]=`fn ${i}(outputIndices: ${n.type.indices}) -> u32 {\n return ${r.length>0?r.join("+"):"0u"};\n }`,`${i}(${e})`},indices:_,indicesGet:k,indicesSet:(t,e,n)=>o<2?`${t}=${n};`:`${Fe(t,e,o)}=${n};`,set:(...e)=>{if(e.length!==o+1)throw new Error(`indices length must be ${o}`);let n=e[o];if("string"!=typeof n)throw new Error("value must be string");let i=e.slice(0,o).map(d).join(",");return 0===o?S("0u",n):1===o?S(i[0],n):(p.set=!0,p.setByIndices=!0,p.indicesToOffset=!0,`set_${t}(${i}, ${n})`)},setByOffset:S,setByIndices:(e,n)=>o<2?S(e,n):(p.setByIndices=!0,p.indicesToOffset=!0,`set_${t}ByIndices(${e}, ${n});`),get:(...e)=>{if(e.length!==o)throw new Error(`indices length must be ${o}`);let n=e.map(d).join(",");return 0===o?M("0u"):1===o?M(n[0]):(p.get=!0,p.getByIndices=!0,p.indicesToOffset=!0,`get_${t}(${n})`)},getByOffset:M,getByIndices:e=>o<2?M(e):(p.getByIndices=!0,p.indicesToOffset=!0,`get_${t}ByIndices(${e})`),usage:i,name:t,strides:m,shape:y,rank:o}},qe=(t,e,n,i=1)=>Ue(t,e,n,"input",i),je=(t,e,n,i=1)=>Ue(t,e,n,"output",i),Be=(t,e,n,i=1)=>Ue(t,e,n,"internal",i),Le=class{constructor(t,e){this.normalizedDispatchGroup=t,this.limits=e,this.internalVariables=[],this.variables=[],this.uniforms=[],this.variableIndex=0}guardAgainstOutOfBoundsWorkgroupSizes(t){return`if (global_idx >= ${"number"==typeof t?`${t}u`:t}) { return; }`}mainStart(t=Ae){let e="number"==typeof t?t:t[0],n="number"==typeof t?1:t[1],i="number"==typeof t?1:t[2];if(e>this.limits.maxComputeWorkgroupSizeX||n>this.limits.maxComputeWorkgroupSizeY||i>this.limits.maxComputeWorkgroupSizeZ)throw new Error(`workgroup size [${e}, ${n}, ${i}] exceeds the maximum workgroup size [${this.limits.maxComputeWorkgroupSizeX}, ${this.limits.maxComputeWorkgroupSizeY}, ${this.limits.maxComputeWorkgroupSizeZ}].`);if(e*n*i>this.limits.maxComputeInvocationsPerWorkgroup)throw new Error(`workgroup size [${e}, ${n}, ${i}] exceeds the maximum workgroup invocations ${this.limits.maxComputeInvocationsPerWorkgroup}.`);let r=1===this.normalizedDispatchGroup[1]&&1===this.normalizedDispatchGroup[2];return`@compute @workgroup_size(${e}, ${n}, ${i})\n fn main(${r?"@builtin(global_invocation_id) global_id : vec3<u32>,\n @builtin(workgroup_id) workgroup_id : vec3<u32>,\n @builtin(local_invocation_id) local_id : vec3<u32>":"@builtin(global_invocation_id) global_id : vec3<u32>,\n @builtin(local_invocation_id) local_id : vec3<u32>,\n @builtin(local_invocation_index) local_idx : u32,\n @builtin(workgroup_id) workgroup_id : vec3<u32>,\n @builtin(num_workgroups) num_workgroups : vec3<u32>"}) {\n ${r?"let global_idx = global_id.x; let local_idx = local_id.x;":`let global_idx = (workgroup_id.z * num_workgroups[0] * num_workgroups[1] +\n workgroup_id.y * num_workgroups[0] + workgroup_id.x) * ${e*n*i}u + local_idx;`}\n `}appendVariableUniforms(t){0!==t.rank&&(t.shape.startsWith("uniforms.")&&this.uniforms.push({name:t.shape.replace("uniforms.",""),type:"u32",length:t.rank}),t.strides.startsWith("uniforms.")&&this.uniforms.push({name:t.strides.replace("uniforms.",""),type:"u32",length:t.rank}))}declareVariable(t,e){if("internal"===t.usage)throw new Error("cannot use internal variable with declareVariable(). use registerInternalVariables() instead.");this.variables.push(t),this.appendVariableUniforms(t);let n="input"===t.usage?"read":"read_write",i=t.type.storage;return`@group(0) @binding(${e}) var<storage, ${n}> ${t.name}: array<${i}>;`}declareVariables(...t){return t.map((t=>this.declareVariable(t,this.variableIndex++))).join("\n")}registerInternalVariable(t){if("internal"!==t.usage)throw new Error("cannot use input or output variable with registerInternalVariable(). use declareVariables() instead.");this.internalVariables.push(t),this.appendVariableUniforms(t)}registerInternalVariables(...t){return t.forEach((t=>this.registerInternalVariable(t))),this}registerUniform(t,e,n=1){return this.uniforms.push({name:t,type:e,length:n}),this}registerUniforms(t){return this.uniforms=this.uniforms.concat(t),this}uniformDeclaration(){if(0===this.uniforms.length)return"";let t=[];for(let{name:e,type:n,length:i}of this.uniforms)if(i&&i>4)"f16"===n?t.push(`@align(16) ${e}:array<mat2x4<${n}>, ${Math.ceil(i/8)}>`):t.push(`${e}:array<vec4<${n}>, ${Math.ceil(i/4)}>`);else{let r=null==i||1===i?n:`vec${i}<${n}>`;t.push(`${e}:${r}`)}return`\n struct Uniforms { ${t.join(", ")} };\n @group(0) @binding(${this.variableIndex}) var<uniform> uniforms: Uniforms;`}get additionalImplementations(){return this.uniformDeclaration()+this.variables.map((t=>t.impl())).join("\n")+this.internalVariables.map((t=>t.impl())).join("\n")}get variablesInfo(){if(0===this.uniforms.length)return;let t=t=>[12,10,1,6][["u32","f16","f32","i32"].indexOf(t)];return this.uniforms.map((e=>[t(e.type),e.length??1]))}},He=(t,e)=>new Le(t,e),Ve=(t,e)=>{let n=t.length,i=[];for(let r=0;r<n;r++){let s=n-1-r,o=t[s]||1;(e[e.length-1-r]||1)>1&&1===o&&i.unshift(s)}return i}})),Eu=V((()=>{wu(),Su(),$u(),Mu(),We=t=>{if(!t||1!==t.length)throw new Error("Transpose requires 1 input.")},Ge=(t,e)=>e&&e.length!==t?[...new Array(t).keys()].reverse():e,Qe=(t,e)=>$e.sortBasedOnPerm(t,Ge(t.length,e)),Ke=(t,e,n,i)=>{let r=[];r.push(`fn perm(i: ${i.type.indices}) -> ${n.type.indices} {\n var a: ${n.type.indices};`);for(let i=0;i<e;++i)r.push(n.indicesSet("a",t[i],`i[${i}]`));return r.push("return a;}"),r.join("\n")},Xe=(t,e)=>{let n,i=t.dataType,r=t.dims.length,s=Ge(r,e),o=Qe(t.dims,s),a=je("output",i,o.length),u=qe("a",i,r);if(2===s.length&&1===s[0]&&0===s[1]){let t=a.type.value,e=[16,16,1];n=n=>`\n ${n.registerUniform("output_size","u32").declareVariables(u,a)}\n var<workgroup> tile : array<array<${t}, ${e[0]+1}>, ${e[0]}>;\n ${n.mainStart(e)}\n var x = workgroup_id.x * ${e[0]}u + local_id.x;\n var y = workgroup_id.y * ${e[0]}u + local_id.y;\n let width = uniforms.output_shape[0];\n let height = uniforms.output_shape[1];\n if (x < width && y < height) {\n tile[local_id.y][local_id.x] = ${u.getByOffset("y * width + x")};\n }\n workgroupBarrier();\n x = workgroup_id.y * ${e[0]}u + local_id.x;\n y = workgroup_id.x * ${e[0]}u + local_id.y;\n if (x < height && y < width) {\n ${a.setByOffset("y * height + x","tile[local_id.x][local_id.y]")}\n }\n }`}else n=t=>`\n ${t.registerUniform("output_size","u32").declareVariables(u,a)}\n\n ${Ke(s,r,u,a)}\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n\n let indices = ${a.offsetToIndices("global_idx")};\n let aIndices = perm(indices);\n\n ${a.setByOffset("global_idx",u.getByIndices("aIndices"))}\n }`;return{name:"Transpose",shaderCache:{hint:`${e}`,inputDependencies:["rank"]},getRunData:t=>{let e=$e.size(o);return{outputs:[{dims:o,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(e/64)},programUniforms:[{type:12,data:e},...ze(t[0].dims,o)]}},getShaderSource:n}},Ze=(t,e)=>{We(t.inputs),t.compute(Xe(t.inputs[0],e.perm))},Ye=t=>xe({perm:t.perm})})),Cu=V((()=>{wu(),Su(),Mu(),Au(),Eu(),Je={max:"select(bestValue, candidate, candidate > bestValue)",min:"select(bestValue, candidate, candidate < bestValue)",mean:"bestValue + candidate",sum:"bestValue + candidate",prod:"bestValue * candidate",sumSquare:"bestValue + candidate * candidate",logSumExp:"bestValue + exp(candidate)",l1:"bestValue + abs(candidate)",l2:"bestValue + candidate * candidate",logSum:"bestValue + candidate"},tn={max:"select(bestValue, candidate, candidate > bestValue)",min:"select(bestValue, candidate, candidate < bestValue)",mean:"bestValue + candidate",sum:"bestValue + candidate",prod:"bestValue * candidate",sumSquare:"bestValue + candidate",logSumExp:"bestValue + candidate",l1:"bestValue + candidate",l2:"bestValue + candidate",logSum:"bestValue + candidate"},en={max:"_A[offset]",min:"_A[offset]",mean:"0",sum:"0",prod:"1",sumSquare:"0",logSumExp:"0",l1:"0",l2:"0",logSum:"0"},nn={max:"bestValue",min:"bestValue",sum:"bestValue",prod:"bestValue",sumSquare:"bestValue",logSumExp:"log(bestValue)",l1:"bestValue",l2:"sqrt(bestValue)",logSum:"log(bestValue)"},rn=(t,e)=>{let n=[];for(let i=e-t;i<e;++i)n.push(i);return n},sn=(t,e)=>{let n=[],i=t.length;for(let r=0;r<i;r++)-1===e.indexOf(r)&&n.push(t[r]);let r=e.map((e=>t[e]));return[n,r]},on=(t,e)=>{let n=t.length+e.length,i=[],r=0;for(let s=0;s<n;s++)-1===e.indexOf(s)?i.push(t[r++]):i.push(1);return i},an=(t,e)=>{for(let n=0;n<t.length;++n)if(t[t.length-n-1]!==e-1-n)return!1;return!0},un=(t,e)=>{let n=[];if(!an(t,e)){for(let i=0;i<e;++i)-1===t.indexOf(i)&&n.push(i);t.forEach((t=>n.push(t)))}return n},hn=(t,e,n,i,r,s,o)=>{let a=n[0].dims,u=$e.size(s),h=$e.size(o),l=qe("_A",n[0].dataType,a),c=je("output",r,s);return{name:t,shaderCache:e,getShaderSource:t=>`\n ${t.registerUniform("reduceSize","u32").declareVariables(l,c)}\n \n var<workgroup> aBestValues : array<f32, 32>;\n \n fn DIV_CEIL(a : u32, b : u32) -> u32 {\n return ((a - 1u) / b + 1u);\n }\n ${t.mainStart(32)}\n\n let outputIndex = global_idx / 32;\n let offset = outputIndex * uniforms.reduceSize;\n\n var bestValue = f32(${en[i]});\n let Length = uniforms.reduceSize;\n for (var k = local_idx; k < Length; k = k + 32) {\n let candidate = f32(${l.getByOffset("offset + k")});\n bestValue = ${Je[i]};\n }\n aBestValues[local_idx] = bestValue;\n workgroupBarrier();\n\n var reduceSize = min(Length, 32u);\n for (var currentSize = reduceSize / 2u; reduceSize > 1u;\n currentSize = reduceSize / 2u) {\n let interval = DIV_CEIL(reduceSize, 2u);\n if (local_idx < currentSize) {\n let candidate = aBestValues[local_idx + interval];\n bestValue = ${tn[i]};\n aBestValues[local_idx] = bestValue;\n }\n reduceSize = interval;\n workgroupBarrier();\n }\n\n if (local_idx == 0u) {\n ${c.setByOffset("outputIndex","mean"===i?`${c.type.storage}(bestValue / f32(uniforms.reduceSize))`:`${c.type.storage}(${nn[i]})`)};\n }\n }`,getRunData:()=>({outputs:[{dims:s,dataType:r}],dispatchGroup:{x:u},programUniforms:[{type:12,data:h}]})}},ln=(t,e,n,i)=>{let r=1===t.inputs.length?n:$n(t.inputs,n),s=r.axes;0===s.length&&!r.noopWithEmptyAxes&&(s=t.inputs[0].dims.map(((t,e)=>e)));let o=$e.normalizeAxes(s,t.inputs[0].dims.length),a=o,u=t.inputs[0],h=un(a,t.inputs[0].dims.length);h.length>0&&(u=t.compute(Xe(t.inputs[0],h),{inputs:[0],outputs:[-1]})[0],a=rn(a.length,u.dims.length));let[l,c]=sn(u.dims,a),f=l;r.keepDims&&(f=on(l,o)),t.compute(hn(e,{hint:r.cacheKey,inputDependencies:["type"]},[u],i,t.inputs[0].dataType,f,c),{inputs:[u]})},cn=(t,e)=>{ln(t,"ReduceMeanShared",e,"mean")},fn=(t,e)=>{ln(t,"ReduceL1Shared",e,"l1")},dn=(t,e)=>{ln(t,"ReduceL2Shared",e,"l2")},pn=(t,e)=>{ln(t,"ReduceLogSumExpShared",e,"logSumExp")},vn=(t,e)=>{ln(t,"ReduceMaxShared",e,"max")},yn=(t,e)=>{ln(t,"ReduceMinShared",e,"min")},mn=(t,e)=>{ln(t,"ReduceProdShared",e,"prod")},wn=(t,e)=>{ln(t,"ReduceSumShared",e,"sum")},gn=(t,e)=>{ln(t,"ReduceSumSquareShared",e,"sumSquare")},bn=(t,e)=>{ln(t,"ReduceLogSumShared",e,"logSum")}})),Au=V((()=>{wu(),Su(),$u(),Mu(),Cu(),xn=t=>{if(!t||0===t.length||t.length>2)throw new Error("Reduce op requires 1 or 2 inputs.");if(2===t.length&&1!==t[1].dims.length)throw new Error("Invalid axes input dims.")},_n=t=>["","",`var value = ${t.getByIndices("input_indices")};`,""],kn=(t,e,n,i,r,s,o=!1,a=!1)=>{let u=[],h=n[0].dims,l=h.length,c=$e.normalizeAxes(r,l),f=!a&&0===c.length;h.forEach(((t,e)=>{f||c.indexOf(e)>=0?o&&u.push(1):u.push(t)}));let d=u.length,p=$e.size(u);return{name:t,shaderCache:e,getShaderSource:t=>{let e=[],r=qe("_A",n[0].dataType,l),a=je("output",s,d),u=i(r,a,c),p=u[2];for(let t=0,n=0;t<l;t++)f||c.indexOf(t)>=0?(o&&n++,p=`for(var j${t}: u32 = 0; j${t} < ${h[t]}; j${t}++) {\n ${u[2].includes("last_index")?`let last_index = j${t};`:""}\n ${r.indicesSet("input_indices",t,`j${t}`)}\n ${p}\n }`):(e.push(`${r.indicesSet("input_indices",t,a.indicesGet("output_indices",n))};`),n++);return`\n\n ${t.registerUniform("output_size","u32").declareVariables(r,a)}\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n var input_indices: ${r.type.indices};\n let output_indices = ${a.offsetToIndices("global_idx")};\n\n ${e.join("\n")}\n ${u[0]} // init ops for reduce max/min\n ${u[1]}\n ${p}\n ${u[3]}\n ${4===u.length?a.setByOffset("global_idx","value"):u.slice(4).join("\n")}\n }`},getRunData:()=>({outputs:[{dims:u,dataType:s}],dispatchGroup:{x:Math.ceil(p/64)},programUniforms:[{type:12,data:p},...ze(h,u)]})}},$n=(t,e)=>{let n=[];return t[1].dims[0]>0&&t[1].getBigInt64Array().forEach((t=>n.push(Number(t)))),xe({axes:n,keepDims:e.keepDims,noopWithEmptyAxes:e.noopWithEmptyAxes})},Sn=(t,e,n,i)=>{let r=t.inputs,s=1===r.length?n:$n(r,n);t.compute(kn(e,{hint:s.cacheKey,inputDependencies:["rank"]},[r[0]],s.noopWithEmptyAxes&&0===s.axes.length?_n:i,s.axes,r[0].dataType,s.keepDims,s.noopWithEmptyAxes),{inputs:[0]})},Mn=(t,e)=>{xn(t.inputs),Sn(t,"ReduceLogSum",e,((t,e)=>[`var value = ${e.type.storage}(0);`,"",`value += ${t.getByIndices("input_indices")};`,"value = log(value);"]))},En=(t,e)=>{xn(t.inputs),Sn(t,"ReduceL1",e,((t,e)=>[`var value = ${e.type.storage}(0);`,"",`value += abs(${t.getByIndices("input_indices")});`,""]))},Cn=(t,e)=>{xn(t.inputs),Sn(t,"ReduceL2",e,((t,e)=>[`var t = ${e.type.value}(0); var value = ${e.type.value}(0);`,"",`t = ${t.getByIndices("input_indices")}; value += (t * t);`,"value = sqrt(value);"]))},An=(t,e)=>{xn(t.inputs),Sn(t,"ReduceLogSumExp",e,((t,e)=>[`var value = ${e.type.storage}(0);`,"",`value += exp(${t.getByIndices("input_indices")});`,"value = log(value);"]))},In=(t,e)=>{xn(t.inputs),Sn(t,"ReduceMax",e,((t,e,n)=>{let i=[];for(let e=0;e<t.rank;e++)(n.indexOf(e)>=0||0===n.length)&&i.push(t.indicesSet("input_indices",e,0));return[`${i.join("\n")}`,`var value = ${t.getByIndices("input_indices")};`,`value = max(value, ${t.getByIndices("input_indices")});`,""]}))},On=(t,e)=>{xn(t.inputs),Sn(t,"ReduceMean",e,((e,n,i)=>{let r=1;for(let n=0;n<e.rank;n++)(i.indexOf(n)>=0||0===i.length)&&(r*=t.inputs[0].dims[n]);return["var sum = f32(0);","",`sum += f32(${e.getByIndices("input_indices")});`,`let value = ${n.type.value}(sum / ${r});`]}))},Tn=(t,e)=>{xn(t.inputs),Sn(t,"ReduceMin",e,((t,e,n)=>{let i=[];for(let e=0;e<t.rank;e++)(n.indexOf(e)>=0||0===n.length)&&i.push(`input_indices[${e}] = 0;`);return[`${i.join("\n")}`,`var value = ${t.getByIndices("input_indices")};`,`value = min(value, ${t.getByIndices("input_indices")});`,""]}))},zn=(t,e)=>{xn(t.inputs),Sn(t,"ReduceProd",e,((t,e)=>[`var value = ${e.type.storage}(1);`,"",`value *= ${t.getByIndices("input_indices")};`,""]))},Dn=(t,e)=>{xn(t.inputs),Sn(t,"ReduceSum",e,((t,e)=>[`var value = ${e.type.storage}(0);`,"",`value += ${t.getByIndices("input_indices")};`,""]))},Pn=(t,e)=>{xn(t.inputs),Sn(t,"ReduceSumSquare",e,((t,e)=>[`var t = ${e.type.value}(0); var value = ${e.type.value}(0);`,"",`t = ${t.getByIndices("input_indices")}; value += t * t;`,""]))},Rn=(t,e,n)=>{if(0===e.length)return n;let i=1,r=1;for(let n=0;n<e.length;n++)-1===e.indexOf(n)?i*=t[n]:r*=t[n];return r<32&&i>1024},Nn=(t,e)=>{Rn(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?On(t,e):cn(t,e)},Fn=(t,e)=>{Rn(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?En(t,e):fn(t,e)},Un=(t,e)=>{Rn(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?Cn(t,e):dn(t,e)},qn=(t,e)=>{Rn(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?An(t,e):pn(t,e)},jn=(t,e)=>{Rn(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?In(t,e):vn(t,e)},Bn=(t,e)=>{Rn(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?Tn(t,e):yn(t,e)},Ln=(t,e)=>{Rn(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?zn(t,e):mn(t,e)},Hn=(t,e)=>{Rn(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?Dn(t,e):wn(t,e)},Vn=(t,e)=>{Rn(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?Pn(t,e):gn(t,e)},Wn=(t,e)=>{Rn(t.inputs[0].dims,e.axes,e.noopWithEmptyAxes)?Mn(t,e):bn(t,e)}})),Iu=V((()=>{wu(),$u(),Au(),Gn=t=>{if(!t||0===t.length||t.length>2)throw new Error("ArgMinMaxOp op requires 1 or 2 inputs.");if(1!==t[0].dataType)throw new Error("Invalid input type.")},Qn=(t,e)=>{Gn(t.inputs),t.compute(kn("ArgMin",{hint:e.cacheKey,inputDependencies:["rank"]},[t.inputs[0]],((t,n,i)=>{let r=[];for(let e=0;e<t.rank;e++)(i.indexOf(e)>=0||0===i.length)&&r.push(`input_indices[${e}] = 0;`);return[`${r.join("\n")}`,`var value = ${t.getByIndices("input_indices")};\nvar best_index : i32 = 0;`,`if (${t.getByIndices("input_indices")} ${e.selectLastIndex>0?"<=":"<"} value) {\n value = ${t.getByIndices("input_indices")};\n best_index = i32(last_index);\n }`,"",n.setByOffset("global_idx","best_index")]}),[e.axis],7,e.keepDims),{inputs:[0]})},Kn=(t,e)=>{Gn(t.inputs),t.compute(kn("argMax",{hint:e.cacheKey,inputDependencies:["rank"]},[t.inputs[0]],((t,n,i)=>{let r=[];for(let e=0;e<t.rank;e++)(i.indexOf(e)>=0||0===i.length)&&r.push(`input_indices[${e}] = 0;`);return[`${r.join("\n")}`,`var value = ${t.getByIndices("input_indices")};\nvar best_index : i32 = 0;`,`if (${t.getByIndices("input_indices")} ${e.selectLastIndex>0?">=":">"} value) {\n value = ${t.getByIndices("input_indices")};\n best_index = i32(last_index);\n }`,"",n.setByOffset("global_idx","best_index")]}),[e.axis],7,e.keepDims),{inputs:[0]})},Xn=t=>xe(t)})),Ou=V((()=>{wu(),_u(),Mu(),Zn=(t,e)=>{let n=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5];if(o&&a)throw new Error("Attention cannot have both past and relative_position_bias");if(3!==n.dims.length)throw new Error('Input "input" must have 3 dimensions');let u=n.dims[0],h=n.dims[1],l=n.dims[2];if(1!==r.dims.length)throw new Error('Input "bias" is expected to have 1 dimensions');if(2!==i.dims.length)throw new Error('Input "weights" is expected to have 2 dimensions');if(i.dims[0]!==l)throw new Error("Input 1 dimension 0 should have same length as dimension 2 of input 0");if(r.dims[0]!==i.dims[1])throw new Error('Input "bias" dimension 0 should have same length as dimension 1 of input "weights"');let c=r.dims[0]/3,f=c,d=f;if(e.qkvHiddenSizes.length>0){if(3!==e.qkvHiddenSizes.length)throw new Error("qkv_hidden_sizes attribute should have 3 elements");for(let t of e.qkvHiddenSizes)if(t%e.numHeads!=0)throw new Error("qkv_hidden_sizes should be divisible by num_heads");c=e.qkvHiddenSizes[0],f=e.qkvHiddenSizes[1],d=e.qkvHiddenSizes[2]}let p=h;if(c!==f)throw new Error("qkv_hidden_sizes first element should be same as the second");if(r.dims[0]!==c+f+d)throw new Error('Input "bias" dimension 0 should have same length as sum of Q/K/V hidden sizes');let v=0;if(o){if(f!==d)throw new Error('Input "past" expect k_hidden_size == v_hidden_size');if(5!==o.dims.length)throw new Error('Input "past" must have 5 dimensions');if(2!==o.dims[0])throw new Error('Input "past" first dimension must be 2');if(o.dims[1]!==u)throw new Error('Input "past" second dimension must be batch_size');if(o.dims[2]!==e.numHeads)throw new Error('Input "past" third dimension must be num_heads');if(o.dims[4]!==f/e.numHeads)throw new Error('Input "past" fifth dimension must be k_hidden_size / num_heads');e.pastPresentShareBuffer||(v=o.dims[3])}let y=p+v;if(s)throw new Error("Mask not supported");if(o)throw new Error("past is not supported");return{batchSize:u,sequenceLength:h,pastSequenceLength:v,kvSequenceLength:p,totalSequenceLength:y,maxSequenceLength:-1,inputHiddenSize:l,hiddenSize:c,vHiddenSize:d,headSize:Math.floor(c/e.numHeads),vHeadSize:Math.floor(d/e.numHeads),numHeads:e.numHeads,isUnidirectional:!1,pastPresentShareBuffer:!1,maskFilterValue:e.maskFilterValue,maskType:0,scale:e.scale,broadcastResPosBias:!1,passPastInKv:!1,qkvFormat:1}},Yn=(t,e,n,i)=>{let r=De(i),s=64,o=i/r;o<s?s=1:o/8<64&&(s=Math.ceil(o/8));let a=Math.ceil(i/r/s),u=[{type:e.dataType,data:1/i},{type:12,data:o},{type:12,data:a}],h=Oe(e.dataType,r),l=Te(1,r);return{name:"AttentionProbsSoftmax",shaderCache:{hint:`${s};${h};${r}`},getShaderSource:t=>{let n=je("x",e.dataType,e.dims,r),i=[{name:"d_inv",type:Te(e.dataType)},{name:"d_comp",type:"u32"},{name:"elements_per_thread",type:"u32"}];return`\n var<workgroup> thread_max: array<f32, ${s}>;\n var<workgroup> thread_sum: array<f32, ${s}>;\n ${t.registerUniforms(i).declareVariables(n)}\n ${t.mainStart([s,1,1])}\n let local_offset = local_idx * uniforms.elements_per_thread;\n let offset = workgroup_id.x * uniforms.d_comp + local_offset;\n\n var thread_max_vector = ${l}(-3.402823e+38f);\n for (var i: u32 = 0; i < uniforms.elements_per_thread && i + local_offset < uniforms.d_comp; i++) {\n thread_max_vector = max(${l}(x[offset + i]), thread_max_vector);\n }\n thread_max[local_idx] = ${(()=>{switch(r){case 1:return"thread_max_vector";case 2:return"max(thread_max_vector.x, thread_max_vector.y)";case 4:return"max(max(thread_max_vector.x, thread_max_vector.y), max(thread_max_vector.z, thread_max_vector.w))";default:throw new Error(`Unsupported components: ${r}`)}})()};\n workgroupBarrier();\n\n var max_value = f32(-3.402823e+38f);\n for (var i = 0u; i < ${s}; i++) {\n max_value = max(thread_max[i], max_value);\n }\n\n var sum_vector = ${l}(0);\n for (var i: u32 = 0; i < uniforms.elements_per_thread && i + local_offset < uniforms.d_comp; i++) {\n sum_vector += exp(${l}(x[offset + i]) - max_value);\n }\n thread_sum[local_idx] = ${(()=>{switch(r){case 1:return"sum_vector";case 2:return"sum_vector.x + sum_vector.y";case 4:return"sum_vector.x + sum_vector.y + sum_vector.z + sum_vector.w";default:throw new Error(`Unsupported components: ${r}`)}})()};\n workgroupBarrier();\n\n var sum: f32 = 0;\n for (var i = 0u; i < ${s}; i++) {\n sum += thread_sum[i];\n }\n\n if (sum == 0) {\n for (var i: u32 = 0; i < uniforms.elements_per_thread && i + local_offset < uniforms.d_comp; i++) {\n x[offset + i] = ${n.type.value}(uniforms.d_inv);\n }\n } else {\n for (var i: u32 = 0; i < uniforms.elements_per_thread && i + local_offset < uniforms.d_comp; i++) {\n var f32input = ${l}(x[offset + i]);\n x[offset + i] = ${n.type.value}(exp(f32input - max_value) / sum);\n }\n }\n }`},getRunData:()=>({outputs:[],dispatchGroup:{x:n},programUniforms:u})}},Jn=(t,e,n,i,r,s,o,a)=>{let u=a+s.kvSequenceLength,h=[s.batchSize,s.numHeads,s.sequenceLength,u],l=void 0===s.kvNumHeads&&t.outputCount>1,c=l?[s.batchSize,s.numHeads,u,s.headSize]:void 0,f=0===o.scale?1/Math.sqrt(s.headSize):o.scale,d=De(s.headSize),p=s.headSize/d,v={x:Math.ceil(u/12),y:Math.ceil(s.sequenceLength/12),z:s.batchSize*s.numHeads},y=[{type:12,data:s.sequenceLength},{type:12,data:p},{type:12,data:u},{type:12,data:s.numHeads},{type:1,data:f},{type:12,data:a},{type:12,data:s.kvSequenceLength}],m=["type","type"];i&&m.push("type"),r&&m.push("type");let w=[{dims:h,dataType:e.dataType,gpuDataType:0}];return l&&w.push({dims:c,dataType:e.dataType,gpuDataType:0}),{name:"AttentionProbs",shaderCache:{hint:`${d};${void 0!==r};${void 0!==i};${t.outputCount}`,inputDependencies:m},getRunData:()=>({outputs:w,dispatchGroup:v,programUniforms:y}),getShaderSource:t=>{let s=qe("q",e.dataType,e.dims,d),o=[s,qe("key",n.dataType,n.dims,d)];if(i){let t=qe("past_key",i.dataType,i.dims,d);o.push(t)}r&&o.push(qe("relative_position_bias",r.dataType,r.dims));let a=je("output",e.dataType,h),u=[a];l&&u.push(je("present_key",e.dataType,c,d));let f=Te(1,d);return`\n const TILE_SIZE = 12u;\n\n var<workgroup> tileQ: array<${s.type.storage}, 144>;\n var<workgroup> tileK: array<${s.type.storage}, 144>;\n ${t.registerUniforms([{name:"M",type:"u32"},{name:"K",type:"u32"},{name:"N",type:"u32"},{name:"num_heads",type:"u32"},{name:"alpha",type:"f32"},{name:"past_sequence_length",type:"u32"},{name:"kv_sequence_length",type:"u32"}]).declareVariables(...o,...u)}\n ${t.mainStart([12,12,1])}\n // x holds the N and y holds the M\n let headIdx = workgroup_id.z;\n let m = workgroup_id.y * TILE_SIZE;\n let n = workgroup_id.x * TILE_SIZE;\n let qOffset = uniforms.M * uniforms.K * headIdx + m * uniforms.K;\n ${i&&l?"\n let kOffset = uniforms.kv_sequence_length * uniforms.K * headIdx;\n let pastKeyOffset = uniforms.past_sequence_length * uniforms.K * headIdx;":"\n let kOffset = uniforms.N * uniforms.K * headIdx + n * uniforms.K;"}\n ${l?"let presentKeyOffset = headIdx * uniforms.N * uniforms.K;":""}\n var value = ${f}(0);\n for (var w: u32 = 0u; w < uniforms.K; w += TILE_SIZE) {\n if (global_id.y < uniforms.M && w + local_id.x < uniforms.K) {\n tileQ[TILE_SIZE * local_id.y + local_id.x] = q[qOffset + local_id.y * uniforms.K + w + local_id.x];\n }\n if (n + local_id.y < uniforms.N && w + local_id.x < uniforms.K) {\n var idx = TILE_SIZE * local_id.y + local_id.x;\n ${i&&l?"\n if (n + local_id.y < uniforms.past_sequence_length) {\n tileK[idx] = past_key[pastKeyOffset + (n + local_id.y) * uniforms.K + w + local_id.x];\n } else {\n tileK[idx] =\n key[kOffset + (n + local_id.y - uniforms.past_sequence_length) * uniforms.K + w + local_id.x];\n }":"tileK[idx] = key[kOffset + local_id.y * uniforms.K + w + local_id.x];"}\n ${l?"present_key[presentKeyOffset + (n + local_id.y) * uniforms.K + w + local_id.x] = tileK[idx];":""}\n }\n workgroupBarrier();\n\n for (var k: u32 = 0u; k < TILE_SIZE && w+k < uniforms.K; k++) {\n value += ${f}(tileQ[TILE_SIZE * local_id.y + k] * tileK[TILE_SIZE * local_id.x + k]);\n }\n\n workgroupBarrier();\n }\n\n let headOffset = headIdx * uniforms.M * uniforms.N;\n if (global_id.y < uniforms.M && global_id.x < uniforms.N) {\n let outputIdx = headOffset + global_id.y * uniforms.N + global_id.x;\n var sum: f32 = ${(()=>{switch(d){case 1:return"value";case 2:return"value.x + value.y";case 4:return"value.x + value.y + value.z + value.w";default:throw new Error(`Unsupported components: ${d}`)}})()};\n output[outputIdx] = ${a.type.value} (sum * uniforms.alpha) + ${r?"relative_position_bias[outputIdx]":"0.0"};\n }\n }`}}},ti=(t,e,n,i,r,s)=>{let o=s+r.kvSequenceLength,a=r.nReps?r.nReps:1,u=r.vHiddenSize*a,h=null==r.kvNumHeads&&t.outputCount>1,l=h?[r.batchSize,r.numHeads,o,r.headSize]:void 0,c=[r.batchSize,r.sequenceLength,u],f={x:Math.ceil(r.vHeadSize/12),y:Math.ceil(r.sequenceLength/12),z:r.batchSize*r.numHeads},d=[{type:12,data:r.sequenceLength},{type:12,data:o},{type:12,data:r.vHeadSize},{type:12,data:r.numHeads},{type:12,data:u},{type:12,data:s},{type:12,data:r.kvSequenceLength}],p=i?["type","type","type"]:["type","type"],v=[{dims:c,dataType:e.dataType,gpuDataType:0}];return h&&v.push({dims:l,dataType:e.dataType,gpuDataType:0}),{name:"AttentionScore",shaderCache:{hint:`${void 0!==i};${t.outputCount}`,inputDependencies:p},getRunData:()=>({outputs:v,dispatchGroup:f,programUniforms:d}),getShaderSource:t=>{let r=qe("probs",e.dataType,e.dims),s=[r,qe("v",n.dataType,n.dims)];i&&s.push(qe("past_value",i.dataType,i.dims));let o=[je("output",e.dataType,c)];return h&&o.push(je("present_value",e.dataType,l)),`\n const TILE_SIZE = 12u;\n var<workgroup> tileQ: array<${r.type.value}, 144>;\n var<workgroup> tileK: array<${r.type.value}, 144>;\n ${t.registerUniforms([{name:"M",type:"u32"},{name:"K",type:"u32"},{name:"N",type:"u32"},{name:"num_heads",type:"u32"},{name:"v_hidden_size",type:"u32"},{name:"past_sequence_length",type:"u32"},{name:"kv_sequence_length",type:"u32"}]).declareVariables(...s,...o)}\n ${t.mainStart([12,12,1])}\n let headIdx = workgroup_id.z;\n let m = global_id.y;\n let n = global_id.x;\n\n let offsetA = headIdx * (uniforms.M * uniforms.K) + m * uniforms.K;\n ${i&&h?"\n let pastValueOffset = headIdx * uniforms.N * uniforms.past_sequence_length + n;\n let vOffset = headIdx * uniforms.N * uniforms.kv_sequence_length + n;\n ":"\n let offsetB = headIdx * uniforms.N * uniforms.K + n;\n "}\n ${h?"let presentValueOffset = headIdx * uniforms.N * uniforms.K + n;":""}\n var value = ${r.type.storage}(0);\n for (var w: u32 = 0u; w < uniforms.K; w += TILE_SIZE) {\n if (m < uniforms.M && w + local_id.x < uniforms.K) {\n tileQ[TILE_SIZE * local_id.y + local_id.x] = probs[offsetA + w + local_id.x];\n }\n if (n < uniforms.N && w + local_id.y < uniforms.K) {\n var idx = TILE_SIZE * local_id.y + local_id.x;\n ${i&&h?"\n if (w + local_id.y < uniforms.past_sequence_length) {\n tileK[idx] = past_value[pastValueOffset + (w + local_id.y) * uniforms.N];\n } else {\n tileK[idx] = v[vOffset + (w + local_id.y - uniforms.past_sequence_length) * uniforms.N];\n }\n ":"\n tileK[idx] = v[offsetB + (w + local_id.y) * uniforms.N];\n "}\n ${h?"present_value[presentValueOffset + (w + local_id.y) * uniforms.N] = tileK[idx];":""}\n }\n workgroupBarrier();\n for (var k: u32 = 0u; k < TILE_SIZE && w+k < uniforms.K; k++) {\n value += tileQ[TILE_SIZE * local_id.y + k] * tileK[TILE_SIZE * k + local_id.x];\n }\n workgroupBarrier();\n }\n\n // we need to transpose output from BNSH_v to BSND_v\n let batchIdx = workgroup_id.z / uniforms.num_heads;\n let currentBatchHeadNumber = workgroup_id.z % uniforms.num_heads;\n if (m < uniforms.M && n < uniforms.N) {\n let outputIdx = batchIdx * uniforms.M * uniforms.v_hidden_size + m * uniforms.v_hidden_size\n + currentBatchHeadNumber * uniforms.N + n;\n output[outputIdx] = value;\n }\n }`}}},ei=(t,e,n,i,r,s,o,a,u,h,l)=>{let c=t.outputCount,f=void 0!==h.kvNumHeads||c>1?h.pastSequenceLength:0,d=f+h.kvSequenceLength,p=void 0===h.kvNumHeads&&c>1&&o?[e,n,o]:[e,n];u&&p.push(u);let v=t.compute(Jn(t,e,n,c>1?o:void 0,u,h,l,f),{inputs:p,outputs:void 0===h.kvNumHeads&&c>1?[-1,1]:[-1]})[0];t.compute(Yn(0,v,h.batchSize*h.numHeads*h.sequenceLength,d),{inputs:[v],outputs:[]});let y=void 0===h.kvNumHeads&&c>1&&a?[v,i,a]:[v,i];t.compute(ti(t,v,i,c>1&&a?a:void 0,h,f),{inputs:y,outputs:void 0===h.kvNumHeads&&c>1?[0,2]:[0]})},ni=(t,e)=>{let n=[e.batchSize,e.numHeads,e.sequenceLength,e.headSize],i=e.sequenceLength,r=e.inputHiddenSize,s=e.headSize,o={x:Math.ceil(e.headSize/12),y:Math.ceil(e.sequenceLength/12),z:e.batchSize*e.numHeads},a=[t.inputs[0],t.inputs[1],t.inputs[2]],u=[{type:12,data:i},{type:12,data:r},{type:12,data:s},{type:12,data:e.numHeads},{type:12,data:e.headSize},{type:12,data:e.hiddenSize},{type:12,data:e.hiddenSize+e.hiddenSize+e.vHiddenSize}];return t.compute({name:"AttentionPrepare",shaderCache:{inputDependencies:["type","type","type"]},getRunData:()=>({outputs:[{dims:n,dataType:t.inputs[0].dataType,gpuDataType:0},{dims:n,dataType:t.inputs[0].dataType,gpuDataType:0},{dims:n,dataType:t.inputs[0].dataType,gpuDataType:0}],dispatchGroup:o,programUniforms:u}),getShaderSource:t=>{let e=je("output_q",a[0].dataType,n),i=je("output_k",a[0].dataType,n),r=je("output_v",a[0].dataType,n),s=qe("input",a[0].dataType,a[0].dims),o=qe("weight",a[1].dataType,a[1].dims),u=qe("bias",a[2].dataType,a[2].dims),h=s.type.storage;return`\n const TILE_SIZE = 12u;\n var<workgroup> tileInput: array<${h}, 144>;\n var<workgroup> tileWeightQ: array<${h}, 144>;\n var<workgroup> tileWeightK: array<${h}, 144>;\n var<workgroup> tileWeightV: array<${h}, 144>;\n ${t.registerUniforms([{name:"M",type:"u32"},{name:"K",type:"u32"},{name:"N",type:"u32"},{name:"num_heads",type:"u32"},{name:"head_size",type:"u32"},{name:"hidden_size",type:"u32"},{name:"ldb",type:"u32"}]).declareVariables(s,o,u,e,i,r)}\n ${t.mainStart([12,12,1])}\n let batchIndex = workgroup_id.z / uniforms.num_heads;\n let headNumber = workgroup_id.z % uniforms.num_heads;\n let m = global_id.y;\n let n = global_id.x;\n\n let inputOffset = batchIndex * (uniforms.M * uniforms.K) + m * uniforms.K;\n let biasOffsetQ = headNumber * uniforms.head_size;\n let biasOffsetK = uniforms.hidden_size + biasOffsetQ;\n let biasOffsetV = uniforms.hidden_size + biasOffsetK;\n\n var valueQ = ${h}(0);\n var valueK = ${h}(0);\n var valueV = ${h}(0);\n for (var w: u32 = 0u; w < uniforms.K; w += TILE_SIZE) {\n if (m < uniforms.M && w + local_id.x < uniforms.K) {\n tileInput[TILE_SIZE * local_id.y + local_id.x] = input[inputOffset + w + local_id.x];\n }\n if (n < uniforms.N && w + local_id.y < uniforms.K) {\n let offset = n + (w + local_id.y) * uniforms.ldb;\n tileWeightQ[TILE_SIZE * local_id.y + local_id.x] = weight[biasOffsetQ + offset];\n tileWeightK[TILE_SIZE * local_id.y + local_id.x] = weight[biasOffsetK + offset];\n tileWeightV[TILE_SIZE * local_id.y + local_id.x] = weight[biasOffsetV + offset];\n }\n workgroupBarrier();\n for (var k: u32 = 0u; k<TILE_SIZE && w+k < uniforms.K; k++) {\n let inputTileOffset = TILE_SIZE * local_id.y + k;\n let weightTileOffset = TILE_SIZE * k + local_id.x;\n valueQ += tileInput[inputTileOffset] * tileWeightQ[weightTileOffset];\n valueK += tileInput[inputTileOffset] * tileWeightK[weightTileOffset];\n valueV += tileInput[inputTileOffset] * tileWeightV[weightTileOffset];\n }\n\n workgroupBarrier();\n }\n\n let headOffset = (m * uniforms.N + n) % uniforms.head_size;\n valueQ += bias[headOffset + biasOffsetQ];\n valueK += bias[headOffset + biasOffsetK];\n valueV += bias[headOffset + biasOffsetV];\n\n let offset = workgroup_id.z * uniforms.M * uniforms.N;\n if (m < uniforms.M && n < uniforms.N) {\n let outputIdx = offset + m * uniforms.N + n;\n output_q[outputIdx] = valueQ;\n output_k[outputIdx] = valueK;\n output_v[outputIdx] = valueV;\n }\n }`}},{inputs:a,outputs:[-1,-1,-1]})},ii=(t,e)=>{let n=Zn(t.inputs,e),[i,r,s]=ni(t,n);return ei(t,i,r,s,t.inputs[4],void 0,void 0,void 0,t.inputs[5],n,e)}})),Tu=V((()=>{vt(),wu(),Su(),$u(),Mu(),ri=(t,e)=>{if(!t||5!==t.length)throw new Error("BatchNormalization requires 5 inputs");let n=(t,e,n)=>{let i=e.length;if(i!==t.length)throw new Error(`${n}: num dimensions != ${i}`);e.forEach(((e,i)=>{if(e!==t[i])throw new Error(`${n}: dim[${i}] do not match`)}))};if(t[0].dims.length>1){let i="NHWC"===e.format?e.spatial?t[0].dims.slice(-1):t[0].dims.slice(-1).concat(t[0].dims.slice(1,t[0].dims.length-1)):t[0].dims.slice(1,e.spatial?2:void 0);n(t[1].dims,i,"Invalid input scale"),n(t[2].dims,i,"Invalid input B"),n(t[3].dims,i,"Invalid input mean"),n(t[4].dims,i,"Invalid input var")}else n(t[1].dims,[1],"Invalid input scale"),n(t[2].dims,[1],"Invalid input B"),n(t[3].dims,[1],"Invalid input mean"),n(t[4].dims,[1],"Invalid input var")},si=(t,e)=>{let{epsilon:n,spatial:i,format:r}=e,s=t[0].dims,o=i?De(s[s.length-1]):1,a="NHWC"===r&&s.length>1?o:1,u=$e.size(s)/o,h=i,l=h?s.length:s,c=qe("x",t[0].dataType,t[0].dims,o),f=qe("scale",t[1].dataType,t[1].dims,a),d=qe("bias",t[2].dataType,t[2].dims,a),p=qe("inputMean",t[3].dataType,t[3].dims,a),v=qe("inputVar",t[4].dataType,t[4].dims,a),y=je("y",t[0].dataType,l,o);return{name:"BatchNormalization",shaderCache:{hint:`${e.epsilon}_${e.format}_${i}_${o}`,inputDependencies:h?["rank","type","type","type","type"]:void 0},getShaderSource:t=>`\n const epsilon = ${n};\n ${t.registerUniform("outputSize","u32").declareVariables(c,f,d,p,v,y)}\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}\n var outputIndices = ${y.offsetToIndices(`global_idx * ${o}`)};\n ${(()=>{let t="";if(i)t=`let cOffset = ${1===s.length?"0u":"NHWC"===r?`outputIndices[${s.length-1}] / ${o}`:"outputIndices[1]"};`;else if("NCHW"===r)t=`\n ${y.indicesSet("outputIndices","0","0")}\n let cOffset = ${y.indicesToOffset("outputIndices")};`;else{t=`var cIndices = ${f.type.indices}(0);\n cIndices[0] = outputIndices[${s.length-1}];`;for(let e=1;e<f.rank;e++)t+=`cIndices[${e}] = outputIndices[${e}];`;t+=`let cOffset = ${f.indicesToOffset("cIndices")};`}return t})()}\n let scale = ${f.getByOffset("cOffset")};\n let bias = ${d.getByOffset("cOffset")};\n let inputMean = ${p.getByOffset("cOffset")};\n let inputVar = ${v.getByOffset("cOffset")};\n let x = ${c.getByOffset("global_idx")};\n let value = (x - inputMean) * inverseSqrt(inputVar + epsilon) * scale + bias;\n ${y.setByOffset("global_idx","value")}\n }`,getRunData:()=>({outputs:[{dims:t[0].dims,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(u/64)},programUniforms:h?[{type:12,data:u},...ze(s)]:[{type:12,data:u}]})}},oi=t=>xe(t),ai=(t,e)=>{let{inputs:n,outputCount:i}=t,r=oi({...e,outputCount:i});if(y.webgpu.validateInputContent&&ri(n,r),e.trainingMode)throw new Error("BatchNormalization trainingMode is not supported yet.");t.compute(si(n,r))}})),zu=V((()=>{Su(),Mu(),ui=t=>{if(3!==t[0].dims.length)throw new Error("input should have 3 dimensions");if(![320,640,1280].includes(t[0].dims[2]))throw new Error("number of channels should be 320, 640 or 1280");if(1!==t[1].dims.length)throw new Error("bias is expected to have 1 dimensions");if(t[0].dims[2]!==t[1].dims[0])throw new Error("last dimension of input and bias are not the same")},hi=t=>{let e=t[0].dims,n=t[0].dims[2],i=$e.size(e)/4,r=t[0].dataType,s=qe("input",r,e,4),o=qe("bias",r,[n],4),a=qe("residual",r,e,4),u=je("output",r,e,4);return{name:"BiasAdd",getRunData:()=>({outputs:[{dims:e,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(i/64)}}),getShaderSource:t=>`\n const channels = ${n}u / 4;\n ${t.declareVariables(s,o,a,u)}\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes(i)}\n let value = ${s.getByOffset("global_idx")}\n + ${o.getByOffset("global_idx % channels")} + ${a.getByOffset("global_idx")};\n ${u.setByOffset("global_idx","value")}\n }`}},li=t=>{ui(t.inputs),t.compute(hi(t.inputs))}})),Du=V((()=>{wu(),Su(),$u(),Mu(),ci=(t,e,n,i,r,s)=>{let o=Math.ceil(e/4),a="";a="string"==typeof r?`${r}(a)`:r("a");let u=qe("inputData",n,[o],4),h=je("outputData",i,[o],4);return`\n ${t.registerUniform("vec_size","u32").declareVariables(u,h)}\n\n ${s??""}\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.vec_size")}\n\n let a = ${u.getByOffset("global_idx")};\n ${h.setByOffset("global_idx",a)}\n }`},fi=(t,e,n,i,r,s=t.dataType)=>({name:e,shaderCache:{hint:r,inputDependencies:["type"]},getShaderSource:e=>ci(e,$e.size(t.dims),t.dataType,s,n,i),getRunData:e=>({outputs:[{dims:t.dims,dataType:s}],dispatchGroup:{x:Math.ceil($e.size(e[0].dims)/64/4)},programUniforms:[{type:12,data:Math.ceil($e.size(t.dims)/4)}]})}),di=t=>{t.compute(fi(t.inputs[0],"Abs","abs"))},pi=t=>{t.compute(fi(t.inputs[0],"Acos","acos"))},vi=t=>{t.compute(fi(t.inputs[0],"Acosh","acosh"))},yi=t=>{t.compute(fi(t.inputs[0],"Asin","asin"))},mi=t=>{t.compute(fi(t.inputs[0],"Asinh","asinh"))},wi=t=>{t.compute(fi(t.inputs[0],"Atan","atan"))},gi=t=>{t.compute(fi(t.inputs[0],"Atanh","atanh"))},bi=t=>xe(t),xi=(t,e)=>{let n;switch(e.to){case 10:n="vec4<f16>";break;case 1:n="vec4<f32>";break;case 12:n="vec4<u32>";break;case 6:n="vec4<i32>";break;case 9:n="vec4<bool>";break;default:throw new RangeError(`not supported type (specified in attribute 'to' from 'Cast' operator): ${e.to}`)}t.compute(fi(t.inputs[0],"Cast",n,void 0,e.cacheKey,e.to))},_i=t=>{let e=t.length>=2&&0!==t[1].data?t[1].getFloat32Array()[0]:Ee,n=t.length>=3&&0!==t[2].data?t[2].getFloat32Array()[0]:Ce;return xe({min:e,max:n})},ki=(t,e)=>{let n=1===t.inputs.length?e:_i(t.inputs),i=Te(t.inputs[0].dataType);t.compute(fi(t.inputs[0],"Clip",(t=>`clamp(${t}, clip_min_, clip_max_)`),`\n const clip_min_: vec4<${i}> = vec4(${i}(${n.min}));\n const clip_max_: vec4<${i}> = vec4(${i}(${n.max}));\n`,n.cacheKey),{inputs:[0]})},$i=t=>{t.compute(fi(t.inputs[0],"Ceil","ceil"))},Si=t=>{t.compute(fi(t.inputs[0],"Cos","cos"))},Mi=t=>{t.compute(fi(t.inputs[0],"Cosh","cosh"))},Ei=t=>xe(t),Ci=(t,e)=>{let n=Te(t.inputs[0].dataType);t.compute(fi(t.inputs[0],"Elu",(t=>`elu_vf32(${t})`),`\n const elu_alpha_ = ${n}(${e.alpha});\n\n fn elu_f32(a: ${n}) -> ${n} {\n return select((exp(a) - 1.0) * elu_alpha_, a, a >= 0.0);\n }\n\n fn elu_vf32(v: vec4<${n}>) -> vec4<${n}> {\n return vec4(elu_f32(v.x), elu_f32(v.y), elu_f32(v.z), elu_f32(v.w));\n }`,e.cacheKey))},Ai=(t="f32")=>`\nconst r0: ${t} = 0.3275911;\nconst r1: ${t} = 0.254829592;\nconst r2: ${t} = -0.284496736;\nconst r3: ${t} = 1.421413741;\nconst r4: ${t} = -1.453152027;\nconst r5: ${t} = 1.061405429;\n\nfn erf_vf32(v: vec4<${t}>) -> vec4<${t}> {\n let absv = abs(v);\n let x = 1.0 / (1.0 + r0 * absv);\n return sign(v) * (1.0 - ((((r5 * x + r4) * x + r3) * x + r2) * x + r1) * x * exp(-absv * absv));\n}`,Ii=t=>{let e=Te(t.inputs[0].dataType);t.compute(fi(t.inputs[0],"Erf",(t=>`erf_vf32(${t})`),Ai(e)))},Oi=t=>{t.compute(fi(t.inputs[0],"Exp","exp"))},Ti=t=>{t.compute(fi(t.inputs[0],"Floor","floor"))},zi=t=>{let e=Te(t.inputs[0].dataType);t.compute(fi(t.inputs[0],"Gelu",(t=>`0.5 * ${t} * (1.0 + erf_vf32(${t} * 0.7071067811865475))`),Ai(e)))},Di=(t,e)=>{let n=Te(t.inputs[0].dataType);t.compute(fi(t.inputs[0],"LeakyRelu",(t=>`select(leaky_relu_alpha_ * ${t}, ${t}, ${t} >= vec4<${n}>(0.0))`),`const leaky_relu_alpha_ = ${n}(${e.alpha});`,e.cacheKey))},Pi=t=>{t.compute(fi(t.inputs[0],"Not",(t=>`!${t}`)))},Ri=t=>{t.compute(fi(t.inputs[0],"Neg",(t=>`-${t}`)))},Ni=t=>{t.compute(fi(t.inputs[0],"Reciprocal",(t=>`1.0/${t}`)))},Fi=t=>{let e=Te(t.inputs[0].dataType);t.compute(fi(t.inputs[0],"Relu",(t=>`select(vec4<${e}>(0.0), ${t}, ${t} > vec4<${e}>(0.0))`)))},Ui=t=>{t.compute(fi(t.inputs[0],"Sigmoid",(t=>`(1.0 / (1.0 + exp(-${t})))`)))},qi=t=>xe(t),ji=(t,e)=>{let n=Te(t.inputs[0].dataType);t.compute(fi(t.inputs[0],"HardSigmoid",(t=>`max(vec4<${n}>(0.0), min(vec4<${n}>(1.0), ${e.alpha} * ${t} + vec4<${n}>(${e.beta})))`),void 0,e.cacheKey))},Bi=t=>{t.compute(fi(t.inputs[0],"Sin","sin"))},Li=t=>{t.compute(fi(t.inputs[0],"Sinh","sinh"))},Hi=t=>{t.compute(fi(t.inputs[0],"Sqrt","sqrt"))},Vi=t=>{t.compute(fi(t.inputs[0],"Tan","tan"))},Wi=t=>`sign(${t}) * (1 - exp(-2 * abs(${t}))) / (1 + exp(-2 * abs(${t})))`,Gi=t=>{t.compute(fi(t.inputs[0],"Tanh",Wi))},Qi=(t="f32")=>`\nconst fast_gelu_a: ${t} = 0.5;\nconst fast_gelu_b: ${t} = 0.7978845608028654;\nconst fast_gelu_c: ${t} = 0.035677408136300125;\n\nfn tanh_v(v: vec4<${t}>) -> vec4<${t}> {\n return ${Wi("v")};\n}\n`,Ki=t=>`(fast_gelu_a + fast_gelu_a * tanh_v(${t} * (fast_gelu_c * ${t} * ${t} + fast_gelu_b))) * ${t}`,Xi=t=>{let e=Te(t.inputs[0].dataType);t.compute(fi(t.inputs[0],"FastGelu",Ki,Qi(e),void 0,t.inputs[0].dataType))},Zi=(t,e)=>{let n=Te(t.inputs[0].dataType);return t.compute(fi(t.inputs[0],"ThresholdedRelu",(t=>`select(vec4<${n}>(0.0), ${t}, ${t} > thresholded_relu_alpha_)`),`const thresholded_relu_alpha_ = vec4<${n}>(${e.alpha});`,e.cacheKey)),0},Yi=t=>{t.compute(fi(t.inputs[0],"Log","log"))},Ji=(t,e)=>`\nconst alpha = vec4<${t}>(${e});\nconst one = ${t}(1.0);\nconst zero = ${t}(0.0);\n\nfn quick_gelu_impl(x: vec4<${t}>) -> vec4<${t}> {\n let v = x *alpha;\n var x1 : vec4<${t}>;\n for (var i = 0; i < 4; i = i + 1) {\n if (v[i] >= zero) {\n x1[i] = one / (one + exp(-v[i]));\n } else {\n x1[i] = one - one / (one + exp(v[i]));\n }\n }\n return x * x1;\n}\n`,tr=t=>`quick_gelu_impl(${t})`,er=(t,e)=>{let n=Te(t.inputs[0].dataType);t.compute(fi(t.inputs[0],"QuickGelu",tr,Ji(n,e.alpha),e.cacheKey,t.inputs[0].dataType))}})),Pu=V((()=>{Su(),Mu(),Du(),nr=t=>{if(3!==t[0].dims.length)throw new Error("input should have 3 dimensions");if(![2560,5120,10240].includes(t[0].dims[2]))throw new Error("hidden state should be 2560, 5120 or 10240");if(1!==t[1].dims.length)throw new Error("bias is expected to have 1 dimensions");if(t[0].dims[2]!==t[1].dims[0])throw new Error("last dimension of input and bias are not the same")},ir=t=>{let e=t[0].dims.slice();e[2]=e[2]/2;let n=qe("input",t[0].dataType,t[0].dims,4),i=qe("bias",t[0].dataType,[t[0].dims[2]],4),r=je("output",t[0].dataType,e,4),s=$e.size(e)/4,o=Oe(t[0].dataType);return{name:"BiasSplitGelu",getRunData:()=>({outputs:[{dims:e,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(s/64)}}),getShaderSource:e=>`\n const M_SQRT2 = sqrt(2.0);\n const halfChannels = ${t[0].dims[2]/4/2}u;\n\n ${e.declareVariables(n,i,r)}\n\n ${Ai(o)}\n\n ${e.mainStart()}\n ${e.guardAgainstOutOfBoundsWorkgroupSizes(s)}\n let biasIdx = global_idx % halfChannels;\n let batchIndex = global_idx / halfChannels;\n let inputOffset = biasIdx + batchIndex * halfChannels * 2;\n let valueLeft = input[inputOffset] + bias[biasIdx];\n let valueRight = input[inputOffset + halfChannels] + bias[biasIdx + halfChannels];\n let geluRight = valueRight * 0.5 * (erf_vf32(valueRight / M_SQRT2) + 1);\n\n ${r.setByOffset("global_idx","valueLeft * geluRight")}\n }`}},rr=t=>{nr(t.inputs),t.compute(ir(t.inputs))}})),Ru=V((()=>{wu(),Su(),Mu(),sr=(t,e,n,i,r,s,o,a,u,h,l,c)=>{let f,d;"string"==typeof a?f=d=(t,e)=>`${a}((${t}),(${e}))`:"function"==typeof a?f=d=a:(f=a.scalar,d=a.vector);let p,v=je("outputData",l,i.length,4),y=qe("aData",u,e.length,4),m=qe("bData",h,n.length,4);if(r)if(s){let t=1===$e.size(e),i=1===$e.size(n),r=e.length>0&&e[e.length-1]%4==0,s=n.length>0&&n[n.length-1]%4==0;p=t||i?v.setByOffset("global_idx",d(t?`${y.type.value}(${y.getByOffset("0")}.x)`:y.getByOffset("global_idx"),i?`${m.type.value}(${m.getByOffset("0")}.x)`:m.getByOffset("global_idx"))):`\n let outputIndices = ${v.offsetToIndices("global_idx * 4u")};\n let offsetA = ${y.broadcastedIndicesToOffset("outputIndices",v)};\n let offsetB = ${m.broadcastedIndicesToOffset("outputIndices",v)};\n ${v.setByOffset("global_idx",d(o||r?y.getByOffset("offsetA / 4u"):`${y.type.value}(${y.getByOffset("offsetA / 4u")}[offsetA % 4u])`,o||s?m.getByOffset("offsetB / 4u"):`${m.type.value}(${m.getByOffset("offsetB / 4u")}[offsetB % 4u])`))}\n `}else p=v.setByOffset("global_idx",d(y.getByOffset("global_idx"),m.getByOffset("global_idx")));else{if(!s)throw new Error("no necessary to use scalar implementation for element-wise binary op implementation.");let t=(t,e,n="")=>{let i=`aData[indexA${e}][componentA${e}]`,r=`bData[indexB${e}][componentB${e}]`;return`\n let outputIndices${e} = ${v.offsetToIndices(`global_idx * 4u + ${e}u`)};\n let offsetA${e} = ${y.broadcastedIndicesToOffset(`outputIndices${e}`,v)};\n let offsetB${e} = ${m.broadcastedIndicesToOffset(`outputIndices${e}`,v)};\n let indexA${e} = offsetA${e} / 4u;\n let indexB${e} = offsetB${e} / 4u;\n let componentA${e} = offsetA${e} % 4u;\n let componentB${e} = offsetB${e} % 4u;\n ${t}[${e}] = ${n}(${f(i,r)});\n `};p=9===l?`\n var data = vec4<u32>(0);\n ${t("data",0,"u32")}\n ${t("data",1,"u32")}\n ${t("data",2,"u32")}\n ${t("data",3,"u32")}\n outputData[global_idx] = dot(vec4<u32>(0x1, 0x100, 0x10000, 0x1000000), vec4<u32>(data));`:`\n ${t("outputData[global_idx]",0)}\n ${t("outputData[global_idx]",1)}\n ${t("outputData[global_idx]",2)}\n ${t("outputData[global_idx]",3)}\n `}return`\n ${t.registerUniform("vec_size","u32").declareVariables(y,m,v)}\n\n ${c??""}\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.vec_size")}\n ${p}\n }`},or=(t,e,n,i,r,s,o=n.dataType)=>{let a=!$e.areEqual(n.dims,i.dims),u=n.dims,h=$e.size(n.dims),l=!1,c=!1,f=[a];if(a){let t=ke.calcShape(n.dims,i.dims,!1);if(!t)throw new Error("Can't perform binary op on the given tensors");u=t,h=$e.size(u);let e=1===$e.size(n.dims),r=1===$e.size(i.dims),s=n.dims.length>0&&n.dims[n.dims.length-1]%4==0,o=i.dims.length>0&&i.dims[i.dims.length-1]%4==0;f.push(e),f.push(r),f.push(s),f.push(o);let a=1;for(let t=1;t<u.length;t++){let e=n.dims[n.dims.length-t]??1;if(e!==(i.dims[i.dims.length-t]??1))break;a*=e}a%4==0?(c=!0,l=!0):(e||r||s||o)&&(l=!0)}else l=!0;return f.push(l),{name:t,shaderCache:{hint:e+f.map((t=>t.toString())).join("_"),inputDependencies:["rank","rank"]},getShaderSource:t=>sr(t,n.dims,i.dims,u,l,a,c,r,n.dataType,i.dataType,o,s),getRunData:()=>({outputs:[{dims:u,dataType:o}],dispatchGroup:{x:Math.ceil(h/64/4)},programUniforms:[{type:12,data:Math.ceil($e.size(u)/4)},...ze(n.dims,i.dims,u)]})}},ar=(t,e,n,i,r,s)=>{t.compute(or(e,r??"",t.inputs[0],t.inputs[1],n,i,s))},ur=t=>{ar(t,"Add",((t,e)=>`${t}+${e}`))},hr=t=>{ar(t,"Div",((t,e)=>`${t}/${e}`))},lr=t=>{ar(t,"Equal",{scalar:(t,e)=>`u32(${t}==${e})`,vector:(t,e)=>`vec4<u32>(${t}==${e})`},void 0,void 0,9)},cr=t=>{ar(t,"Mul",((t,e)=>`${t}*${e}`))},fr=t=>{let e=qe("input",t.inputs[0].dataType,t.inputs[0].dims).type.value;ar(t,"Pow",{scalar:(t,e)=>`pow_custom(${t},${e})`,vector:(t,e)=>`pow_vector_custom(${t},${e})`},`\n fn pow_custom(a : ${e}, b : ${e}) -> ${e} {\n if (b == ${e}(0.0)) {\n return ${e}(1.0);\n } else if (a < ${e}(0.0) && f32(b) != floor(f32(b))) {\n return ${e}(pow(f32(a), f32(b))); // NaN\n }\n return select(sign(a), ${e}(1.0), round(f32(abs(b) % ${e}(2.0))) != 1.0) * ${e}(${"i32"===e?"round":""}(pow(f32(abs(a)), f32(b))));\n }\n fn pow_vector_custom(a : vec4<${e}>, b : vec4<${e}>) -> vec4<${e}> {\n // TODO: implement vectorized pow\n return vec4<${e}>(pow_custom(a.x, b.x), pow_custom(a.y, b.y), pow_custom(a.z, b.z), pow_custom(a.w, b.w));\n }\n `)},dr=t=>{ar(t,"Sub",((t,e)=>`${t}-${e}`))},pr=t=>{ar(t,"Greater",{scalar:(t,e)=>`u32(${t}>${e})`,vector:(t,e)=>`vec4<u32>(${t}>${e})`},void 0,void 0,9)},vr=t=>{ar(t,"Less",{scalar:(t,e)=>`u32(${t}<${e})`,vector:(t,e)=>`vec4<u32>(${t}<${e})`},void 0,void 0,9)},yr=t=>{ar(t,"GreaterOrEqual",{scalar:(t,e)=>`u32(${t}>=${e})`,vector:(t,e)=>`vec4<u32>(${t}>=${e})`},void 0,void 0,9)},mr=t=>{ar(t,"LessOrEqual",{scalar:(t,e)=>`u32(${t}<=${e})`,vector:(t,e)=>`vec4<u32>(${t}<=${e})`},void 0,void 0,9)}})),Nu=V((()=>{wu(),Su(),$u(),Mu(),wr=(t,e)=>{if(!t||t.length<1)throw new Error("too few inputs");let n=t[0],i=n.dataType,r=n.dims.length;t.forEach(((t,s)=>{if(0!==s){if(t.dataType!==i)throw new Error("input tensors should be one type");if(t.dims.length!==r)throw new Error("input tensors should have the same shape");t.dims.forEach(((t,i)=>{if(i!==e&&t!==n.dims[i])throw new Error("non concat dimensions must match")}))}}))},gr=(t,e)=>`\n fn calculateInputIndex(index: u32) -> u32 {\n let sizeInConcatAxis = array<u32, ${t}u>(${e});\n for (var i: u32 = 0u; i < ${t}; i += 1u ) {\n if (index < sizeInConcatAxis[i]) {\n return i;\n }\n }\n return ${t}u;\n }`,br=(t,e)=>{let n=t.length,i=[];for(let r=0;r<n;++r){let s=e.setByOffset("global_idx",t[r].getByIndices("indices"));1===n?i.push(s):0===r?i.push(`if (inputIndex == ${r}u) { ${s} }`):r===n-1?i.push(`else { ${s} }`):i.push(`else if (inputIndex == ${r}) { ${s} }`)}return i.join("\n")},xr=(t,e,n,i)=>{let r=$e.size(n),s=new Array(t.length),o=new Array(t.length),a=0,u=[],h=[],l=[{type:12,data:r}];for(let n=0;n<t.length;++n)a+=t[n].dims[e],s[n]=a,h.push(t[n].dims.length),o[n]=qe(`input${n}`,i,h[n]),u.push("rank"),l.push({type:12,data:s[n]});for(let e=0;e<t.length;++e)l.push(...ze(t[e].dims));l.push(...ze(n));let c=je("output",i,n.length),f=c.indicesGet("indices",e),d=Array.from(Array(s.length).keys()).map((t=>`uniforms.sizeInConcatAxis${t}`)).join(",");return{name:"Concat",shaderCache:{hint:`${e}`,inputDependencies:u},getRunData:()=>({outputs:[{dims:n,dataType:i}],dispatchGroup:{x:Math.ceil(r/64)},programUniforms:l}),getShaderSource:e=>`\n\n ${(()=>{e.registerUniform("outputSize","u32");for(let n=0;n<t.length;n++)e.registerUniform(`sizeInConcatAxis${n}`,"u32");return e.declareVariables(...o,c)})()}\n\n ${gr(s.length,d)}\n\n ${e.mainStart()}\n ${e.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}\n\n var indices = ${c.offsetToIndices("global_idx")};\n\n let inputIndex = calculateInputIndex(${f});\n if (inputIndex != 0u) {\n let sizeInConcatAxis = array<u32, ${s.length}u>(${d});\n ${f} -= sizeInConcatAxis[inputIndex - 1u];\n }\n\n ${br(o,c)}\n }`}},_r=(t,e)=>{let n=t.inputs,i=n[0].dims,r=$e.normalizeAxis(e.axis,i.length);wr(n,r);let s=i.slice();s[r]=n.reduce(((t,e)=>t+(e.dims.length>r?e.dims[r]:0)),0);let o=n.filter((t=>$e.size(t.dims)>0));t.compute(xr(o,r,s,n[0].dataType),{inputs:o})},kr=t=>xe({axis:t.axis})})),Fu=V((()=>{wu(),Su(),$r=(t,e,n="f32")=>{switch(t.activation){case"Relu":return`value = max(value, ${e}(0.0));`;case"Sigmoid":return`value = (${e}(1.0) / (${e}(1.0) + exp(-value)));`;case"Clip":return`value = clamp(value, ${e}(${n}(uniforms.clip_min)), ${e}(${n}(uniforms.clip_max)));`;case"HardSigmoid":return`value = max(${e}(0.0), min(${e}(1.0), ${n}(uniforms.alpha) * value + ${n}(uniforms.beta)));`;case"LeakyRelu":return`value = select(${n}(uniforms.alpha) * value, value, value >= ${e}(0.0));`;case"Tanh":return"let e2x = exp(-2.0 * abs(value));\n value = sign(value) * (1.0 - e2x) / (1.0 + e2x);\n ";case"":return"";default:throw new Error(`Unsupported activation ${t.activation}`)}},Sr=(t,e)=>{"Clip"===t.activation?e.push({type:1,data:t.clipMax},{type:1,data:t.clipMin}):"HardSigmoid"===t.activation?e.push({type:1,data:t.alpha},{type:1,data:t.beta}):"LeakyRelu"===t.activation&&e.push({type:1,data:t.alpha})},Mr=(t,e)=>{"Clip"===t.activation?e.push({name:"clip_max",type:"f32"},{name:"clip_min",type:"f32"}):"HardSigmoid"===t.activation?e.push({name:"alpha",type:"f32"},{name:"beta",type:"f32"}):"LeakyRelu"===t.activation&&e.push({name:"alpha",type:"f32"})},Er=t=>{let e=t?.activation||"";if("HardSigmoid"===e){let[n,i]=t?.activation_params||[.2,.5];return{activation:e,alpha:n,beta:i}}if("Clip"===e){let[n,i]=t?.activation_params||[Ee,Ce];return{activation:e,clipMax:i,clipMin:n}}if("LeakyRelu"===e){let[n]=t?.activation_params||[.01];return{activation:e,alpha:n}}return{activation:e}}})),Uu=V((()=>{Cr=(t,e)=>{switch(t){case 1:return e;case 2:return`vec2<${e}>`;case 3:return`vec3<${e}>`;case 4:return`vec4<${e}>`;default:throw new Error(`${t}-component is not supported.`)}},Ar=t=>`\n ${t?"value = value + getBiasByOutputCoords(coords);":""}\n `})),qu=V((()=>{Ir=t=>`\nfn getIndexFromCoords4D(coords : vec4<i32>, shape : vec4<i32>) -> i32 {\n return dot(coords, vec4<i32>(\n shape.y * shape.z * shape.w, shape.z * shape.w, shape.w, 1));\n}\nfn getOutputIndexFromCoords(coords : vec4<i32>) -> i32 {\n return dot(coords, vec4<i32>(\n i32(${t}.x), i32(${t}.y), i32(${t}.z), 1));\n}\n`})),ju=V((()=>{wu(),Su(),Mu(),Fu(),Uu(),Or=(t,e)=>t?`\n mm_Asub[inputRow][inputCol] = mm_readA(batch,\n kStart + inputRow,\n globalRowStart / innerElementSize + inputCol${e?", batchIndices":""});\n `:`\n mm_Asub[inputRow][inputCol] = mm_readA(batch,\n globalRow + innerRow,\n kStart / innerElementSize + inputCol${e?", batchIndices":""});\n `,Tr=(t,e)=>t?`\n let ACached0 = mm_Asub[k * innerElementSize][localRow];\n let ACached1 = mm_Asub[k * innerElementSize + 1][localRow];\n let ACached2 = mm_Asub[k * innerElementSize + 2][localRow];\n ${3===e?"":"let ACached3 = mm_Asub[k * innerElementSize + 3][localRow];"}\n for (var i = 0; i < rowPerThread; i = i + 1) {\n acc[i] = BCached0 * ACached0[i] + acc[i];\n acc[i] = BCached1 * ACached1[i] + acc[i];\n acc[i] = BCached2 * ACached2[i] + acc[i];\n ${3===e?"":"acc[i] = BCached3 * ACached3[i] + acc[i];"}\n }`:`\n for (var i = 0; i < rowPerThread; i = i + 1) {\n let ACached = mm_Asub[tileRow + i][k];\n acc[i] = BCached0 * ACached.x + acc[i];\n acc[i] = BCached1 * ACached.y + acc[i];\n acc[i] = BCached2 * ACached.z + acc[i];\n ${3===e?"":"acc[i] = BCached3 * ACached.w + acc[i];"}\n }`,zr=(t,e,n="f32",i,r=!1,s=32,o=!1,a=32)=>{let u=e[1]*t[1],h=e[0]*t[0],l=r?u:s,c=r?s:u,f=l/e[0],d=s/e[1];if((!r||4!==f||4!==t[1])&&(r||3!==f&&4!==f)||l%e[0]!=0||s%e[1]!=0||4!==t[0])throw new Error(`If transposeA ${r} is true, innerElementSize ${f} and workPerThread[1] ${t[1]} must be 4.\n Otherwise, innerElementSize ${f} must be 3 or 4.\n tileAWidth ${l} must be divisible by workgroupSize[0]${e[0]}. tileInner ${s} must be divisible by workgroupSize[1] ${e[1]}. colPerThread ${t[0]} must be 4.`);return`\nvar<workgroup> mm_Asub: array<array<vec${f}<${n}>, ${l/f}>, ${c}>;\nvar<workgroup> mm_Bsub: array<array<vec4<${n}>, ${h/t[0]}>, ${s}>;\n\nconst rowPerThread = ${t[1]};\nconst colPerThread = ${t[0]};\nconst innerElementSize = ${f};\nconst tileInner = ${s};\n\n@compute @workgroup_size(${e[0]}, ${e[1]}, ${e[2]})\nfn main(@builtin(local_invocation_id) localId : vec3<u32>,\n @builtin(global_invocation_id) globalId : vec3<u32>,\n @builtin(workgroup_id) workgroupId : vec3<u32>) {\n let localRow = i32(localId.y);\n let tileRow = localRow * rowPerThread;\n let tileCol = i32(localId.x);\n\n let globalRow =i32(globalId.y) * rowPerThread;\n let globalCol = i32(globalId.x);\n let batch = ${o?"0":"i32(globalId.z)"};\n ${i?`let batchIndices = ${i.offsetToIndices("u32(batch)")};`:""}\n let globalRowStart = i32(workgroupId.y) * ${u};\n\n let num_tiles = ${o?`${Math.ceil(a/s)}`:"(uniforms.dim_inner - 1) / tileInner + 1"};\n var kStart = ${o?`i32(globalId.z) * ${a}`:"0"};\n\n var acc: array<vec4<${n}>, rowPerThread>;\n\n // Loop over shared dimension.\n let tileRowB = localRow * ${d};\n for (var t = 0; t < num_tiles; t = t + 1) {\n // Load one tile of A into local memory.\n for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n let inputRow = tileRow + innerRow;\n let inputCol = tileCol;\n ${Or(r,i)}\n }\n\n // Load one tile of B into local memory.\n for (var innerRow = 0; innerRow < ${d}; innerRow = innerRow + 1) {\n let inputRow = tileRowB + innerRow;\n let inputCol = tileCol;\n mm_Bsub[inputRow][inputCol] = mm_readB(batch, kStart + inputRow, globalCol${i?", batchIndices":""});\n }\n kStart = kStart + tileInner;\n workgroupBarrier();\n\n // Compute acc values for a single thread.\n for (var k = 0; k < tileInner / innerElementSize; k = k + 1) {\n let BCached0 = mm_Bsub[k * innerElementSize][tileCol];\n let BCached1 = mm_Bsub[k * innerElementSize + 1][tileCol];\n let BCached2 = mm_Bsub[k * innerElementSize + 2][tileCol];\n ${3===f?"":"let BCached3 = mm_Bsub[k * innerElementSize + 3][tileCol];"}\n\n ${Tr(r,f)}\n }\n\n workgroupBarrier();\n }\n\n for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n mm_write(batch, globalRow + innerRow, globalCol, acc[innerRow]);\n }\n}`},Dr=(t,e)=>t?`\n mm_Asub[inputRow][inputCol] = mm_readA(batch,\n kStart + inputRow,\n globalRowStart + inputCol${e?", batchIndices":""});\n `:`\n mm_Asub[inputRow][inputCol] = mm_readA(batch,\n globalRowStart + inputRow,\n kStart + inputCol${e?", batchIndices":""});\n `,Pr=t=>t?"let ACached = mm_Asub[k][tileRow + innerRow];":"let ACached = mm_Asub[tileRow + innerRow][k];",Rr=(t,e,n="f32",i,r=!1,s=32,o=!1,a=32,u=!1)=>{let h=t[1]*e[1],l=t[0]*e[0],c=r?h:s,f=r?s:h;if(f%e[1]!=0||c%e[0]!=0||s%e[1]!=0)throw new Error(`tileAHight ${f} must be divisible by workgroupSize[1]${e[1]}, tileAWidth ${c} must be divisible by workgroupSize[0]${e[0]}, tileInner ${s} must be divisible by workgroupSize[1]${e[1]}`);let d=f/e[1],p=c/e[0],v=s/e[1],y=u?`\n let localRow = i32(localId.y);\n let localCol = i32(localId.x);\n let globalRowStart = i32(workgroupId.y) * ${h};\n let globalColStart = i32(workgroupId.x) * ${l};\n\n // Loop over shared dimension.\n for (var t = 0; t < num_tiles; t = t + 1) {\n // Load one tile of A into local memory.\n for (var inputRow = localRow; inputRow < ${f}; inputRow = inputRow + ${e[1]}) {\n for (var inputCol = localCol; inputCol < ${c}; inputCol = inputCol + ${e[0]}) {\n ${Dr(r,i)}\n }\n }\n // Load one tile of B into local memory.\n for (var inputRow = localRow; inputRow < ${s}; inputRow = inputRow + ${e[1]}) {\n for (var inputCol = localCol; inputCol < ${l}; inputCol = inputCol + ${e[0]}) {\n mm_Bsub[inputRow][inputCol] = mm_readB(batch,\n kStart + inputRow,\n globalColStart + inputCol${i?", batchIndices":""});\n }\n }\n kStart = kStart + tileInner;\n workgroupBarrier();\n\n // Compute acc values for a single thread.\n var BCached : array<${n}, colPerThread>;\n for (var k = 0; k < tileInner; k = k + 1) {\n for (var inner = 0; inner < colPerThread; inner = inner + 1) {\n BCached[inner] = mm_Bsub[k][localCol + inner * ${e[0]}];\n }\n for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n let ACached = ${r?`mm_Asub[k][localRow + innerRow * ${e[1]}];`:`mm_Asub[localRow + innerRow * ${e[1]}][k];`}\n for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {\n acc[innerRow][innerCol] = acc[innerRow][innerCol] +\n ACached * BCached[innerCol];\n }\n }\n }\n workgroupBarrier();\n }\n for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n let gRow = globalRowStart + localRow + innerRow * ${e[1]};\n for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {\n let gCol = globalColStart + localCol + innerCol * ${e[0]};\n mm_write(batch, gRow, gCol, acc[innerRow][innerCol]);\n }\n }\n `:`\nlet tileRow = i32(localId.y) * rowPerThread;\nlet tileCol = i32(localId.x) * colPerThread;\n\nlet globalRow = i32(globalId.y) * rowPerThread;\nlet globalCol = i32(globalId.x) * colPerThread;\nlet globalRowStart = i32(workgroupId.y) * ${h};\n\nlet tileRowA = i32(localId.y) * ${d};\nlet tileColA = i32(localId.x) * ${p};\nlet tileRowB = i32(localId.y) * ${v};\n// Loop over shared dimension.\nfor (var t = 0; t < num_tiles; t = t + 1) {\n // Load one tile of A into local memory.\n for (var innerRow = 0; innerRow < ${d}; innerRow = innerRow + 1) {\n for (var innerCol = 0; innerCol < ${p}; innerCol = innerCol + 1) {\n let inputRow = tileRowA + innerRow;\n let inputCol = tileColA + innerCol;\n ${Dr(r,i)}\n }\n }\n\n // Load one tile of B into local memory.\n for (var innerRow = 0; innerRow < ${v}; innerRow = innerRow + 1) {\n for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {\n let inputRow = tileRowB + innerRow;\n let inputCol = tileCol + innerCol;\n mm_Bsub[inputRow][inputCol] = mm_readB(batch,\n kStart + inputRow,\n globalCol + innerCol${i?", batchIndices":""});\n }\n }\n kStart = kStart + tileInner;\n workgroupBarrier();\n\n // Compute acc values for a single thread.\n var BCached : array<${n}, colPerThread>;\n for (var k = 0; k < tileInner; k = k + 1) {\n for (var inner = 0; inner < colPerThread; inner = inner + 1) {\n BCached[inner] = mm_Bsub[k][tileCol + inner];\n }\n\n for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n ${Pr(r)}\n for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {\n acc[innerRow][innerCol] = acc[innerRow][innerCol] + ACached * BCached[innerCol];\n }\n }\n }\n\n workgroupBarrier();\n}\n\nfor (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {\n mm_write(batch, globalRow + innerRow, globalCol + innerCol,\n acc[innerRow][innerCol]);\n }\n}\n`;return`\n var<workgroup> mm_Asub : array<array<${n}, ${c}>, ${f}>;\n var<workgroup> mm_Bsub : array<array<${n}, ${l}>, ${s}>;\n const rowPerThread = ${t[1]};\n const colPerThread = ${t[0]};\n const tileInner = ${s};\n\n@compute @workgroup_size(${e[0]}, ${e[1]}, ${e[2]})\nfn main(@builtin(local_invocation_id) localId : vec3<u32>,\n @builtin(global_invocation_id) globalId : vec3<u32>,\n @builtin(workgroup_id) workgroupId : vec3<u32>) {\n let batch = ${o?"0":"i32(globalId.z)"};\n ${i?`let batchIndices = ${i.offsetToIndices("u32(batch)")};`:""}\n let num_tiles = ${o?`${Math.ceil(a/s)}`:"(uniforms.dim_inner - 1) / tileInner + 1"};\n var kStart = ${o?`i32(globalId.z) * ${a}`:"0"};\n\n var acc : array<array<${n}, colPerThread>, rowPerThread>;\n ${y}\n }\n`},Nr=(t,e,n,i,r,s=!1)=>{let[o,a,u]=r,[h,l,c,f]=i,d=Ve(o,u),p=Ve(a,u),v=Oe(i[0].type.tensor);return`\n fn mm_readA(batch: i32, row: i32, colIn: i32, batchIndices: ${h.type.indices}) -> ${Cr(t,v)} {\n var value = ${Cr(t,v)}(0.0);\n let col = colIn * ${t};\n if(row < uniforms.dim_a_outer && col < uniforms.dim_inner)\n {\n ${(()=>{let t=l.rank,e=h.rank,n=`var aIndices: ${l.type.indices};`;for(let i=t-2-1,r=e-1;i>=0;i--,r--)n+=`\naIndices[${i}] = ${e>1?`batchIndices[${r}]`:"batchIndices"};`;return d.forEach((t=>{n+=`\naIndices[${t}] = 0;`})),n+=`\naIndices[${t-2}] = u32(row);\n aIndices[${t-1}] = u32(colIn);`,n})()}\n value = ${l.getByIndices("aIndices")};\n }\n return value;\n }\n\n fn mm_readB(batch: i32, row: i32, colIn: i32, batchIndices: ${h.type.indices}) -> ${Cr(t,v)} {\n var value = ${Cr(t,v)}(0.0);\n let col = colIn * ${t};\n if(row < uniforms.dim_inner && col < uniforms.dim_b_outer)\n {\n ${(()=>{let t=c.rank,e=h.rank,n=`var bIndices: ${c.type.indices};`;for(let i=t-2-1,r=e-1;i>=0;i--,r--)n+=`\nbIndices[${i}] = ${e>1?`batchIndices[${r}]`:"batchIndices"};`;return p.forEach((t=>{n+=`\nbIndices[${t}] = 0;`})),n+=`\nbIndices[${t-2}] = u32(row);\n bIndices[${t-1}] = u32(colIn);`,n})()}\n value = ${c.getByIndices("bIndices")};\n }\n return value;\n }\n\n fn mm_write(batch: i32, row: i32, colIn: i32, valueIn: ${Cr(t,v)}) {\n let col = colIn * ${t};\n if (row < uniforms.dim_a_outer && col < uniforms.dim_b_outer) {\n var value = valueIn;\n let coords = vec3<i32>(batch, row, colIn);\n ${e?`value = value + ${s?"bias[colIn]":`${Cr(t,v)}(bias[row])`};`:""}\n ${n}\n ${f.setByIndices("vec3<u32>(coords)","value")}\n }\n }\n `},Fr=(t,e,n,i,r=!1)=>{let s=t[0].dims,o=t[1].dims,a=s.slice(0,-2),u=o.slice(0,-2),h=i?i.slice(0,-2):n.slice(0,-2),l=$e.size(h),c=s[s.length-2],f=s[s.length-1],d=o[o.length-1],p=f%4==0&&d%4==0,v=c<=8?[4,1,1]:[4,4,1],y=[8,8,1],m=[Math.ceil(d/y[0]/v[0]),Math.ceil(c/y[1]/v[1]),Math.ceil(l/y[2]/v[2])],w=p?4:1,g=[...a,c,f/w],b=g.length,x=[...u,f,d/w],_=x.length,k=[l,c,d/w],$=[{type:6,data:c},{type:6,data:d},{type:6,data:f}];Sr(e,$),$.push(...ze(h,g,x));let S=["rank","rank"],M=t.length>2;return M&&($.push(...ze(t[2].dims)),S.push("rank")),$.push(...ze(k)),{name:"MatMul",shaderCache:{hint:`${v};${e.activation};${p};${r}`,inputDependencies:S},getRunData:()=>({outputs:[{dims:n,dataType:t[0].dataType}],dispatchGroup:{x:m[0],y:m[1],z:m[2]},programUniforms:$}),getShaderSource:n=>{let i=h.length,s=Be("batchDims",t[0].dataType,i,1),o=Oe(t[0].dataType),l=qe("a",t[0].dataType,b,w),c=qe("b",t[1].dataType,_,w),f=je("result",t[0].dataType,k.length,w),d=[l,c];if(M){let e=r?w:1;d.push(qe("bias",t[2].dataType,t[2].dims.length,e))}let m=[{name:"dim_a_outer",type:"i32"},{name:"dim_b_outer",type:"i32"},{name:"dim_inner",type:"i32"}];Mr(e,m);let g=Oe(f.type.tensor),x=$r(e,f.type.value,g),$=Nr(w,M,x,[s,l,c,f],[a,u,h],r);return`\n ${n.registerUniforms(m).registerInternalVariables(s).declareVariables(...d,f)}\n ${$}\n ${p?zr(v,y,o,s):Rr(v,y,o,s)}\n `}}}})),Bu=V((()=>{wu(),bu(),Mu(),Fu(),Uu(),qu(),ju(),Ur=(t,e,n,i,r=!1,s,o=4,a=4,u=4,h="f32")=>{let l=t?"\n let coord = vec4<i32>(batch, xRow, xCol, xCh);\n ":"\n let coord = vec4<i32>(batch, xCh, xRow, xCol);\n ",c=t?"\n let coords = vec4<i32>(\n batch,\n row / outWidth,\n row % outWidth,\n col);\n ":"\n let coords = vec4<i32>(\n batch,\n row,\n col / outWidth,\n col % outWidth);\n ",f=t?"i32(uniforms.x_shape[1])":"i32(uniforms.x_shape[2])",d=t?"i32(uniforms.x_shape[2])":"i32(uniforms.x_shape[3])",p=t?"row":"col",v=t?"col":"row",y=`\n let inChannels = i32(uniforms.w_shape[2]);\n let outWidth = ${t?"i32(uniforms.result_shape[2])":"i32(uniforms.result_shape[3])"};\n let outRow = ${p} / outWidth;\n let outCol = ${p} % outWidth;\n\n let WRow = ${v} / (i32(uniforms.w_shape[1]) * inChannels);\n let WCol = ${v} / inChannels % i32(uniforms.w_shape[1]);\n let xRow = outRow * uniforms.stride[0] + uniforms.dilation[0] * WRow - uniforms.pad[0];\n let xCol = outCol * uniforms.stride[1] + uniforms.dilation[1] * WCol - uniforms.pad[1];\n let xCh = ${v} % inChannels;\n var resData = ${Cr(o,h)}(0.0);\n // The bounds checking is always needed since we use it to pad zero for\n // the 'same' padding type.\n if (xRow >= 0 && xRow < ${f} && xCol >= 0 && xCol < ${d}) {\n ${l}\n let xIndex = getIndexFromCoords4D(coord, vec4<i32>(uniforms.x_shape));\n ${(t=>{switch(t){case 1:return"resData = x[xIndex];";case 3:return`resData = vec3<${h}>(x[xIndex], x[xIndex + 1], x[xIndex + 2]);`;case 4:return"resData = x[xIndex / 4];";default:throw new Error(`innerElementSize ${t} is not supported.`)}})(o)}\n }\n return resData;`,m=t?e&&i?`\n let col = colIn * ${o};\n ${y}`:`\n let col = colIn * ${o};\n if (row < uniforms.dim_a_outer && col < uniforms.dim_inner) {\n ${y}\n }\n return ${Cr(o,h)}(0.0);`:i&&n?`\n let col = colIn * ${o};\n ${y}`:`\n let col = colIn * ${o};\n if (row < uniforms.dim_inner && col < uniforms.dim_b_outer) {\n ${y}\n }\n return ${Cr(o,h)}(0.0);`,w=`${(t=>{switch(t){case 1:return"return w[row * i32(uniforms.w_shape[3]) + colIn];";case 4:return"return w[row * i32(uniforms.w_shape[3]) / 4 + colIn];";default:throw new Error(`innerElementSize ${t} is not supported.`)}})(a)}`,g=Cr(u,h),b=Cr(t?o:a,h),x=Cr(t?a:o,h),_=$r(s,g,h);return`\n fn mm_readA(batch: i32, row : i32, colIn : i32) -> ${b} {\n ${t?m:w}\n }\n\n fn mm_readB(batch: i32, row : i32, colIn : i32) -> ${x} {\n ${t?w:m}\n }\n\n fn mm_write(batch: i32, row : i32, colIn : i32, valueIn : ${g}) {\n let col = colIn * ${u};\n if (row < uniforms.dim_a_outer && col < uniforms.dim_b_outer)\n {\n var value = valueIn;\n let outWidth = ${t?"i32(uniforms.result_shape[2])":"i32(uniforms.result_shape[3])"};\n ${c}\n ${Ar(r)}\n ${_}\n setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], value);\n }\n }`},qr=(t,e,n,i,r,s,o,a)=>{let u="NHWC"===e.format,h=u?t[0].dims[3]:t[0].dims[1],l=n[0],c=u?n[2]:n[3],f=u?n[1]:n[2],d=u?n[3]:n[1],p=u&&(h%4==0||h%3==0)&&d%4==0,v=u?d:c*f,y=u?c*f:d,m=[8,8,1],w=i<=8?[4,1,1]:[4,4,1],g=[Math.ceil(v/m[0]/w[0]),Math.ceil(y/m[1]/w[1]),Math.ceil(l/m[2]/w[2])];he("verbose",(()=>`[conv2d_mm_webgpu] dispatch = ${g}`));let b=p?u&&h%4!=0?3:4:1,x=m[1]*w[1],_=m[0]*w[0],k=Math.max(m[0]*b,m[1]),$=i%x==0,S=r%_==0,M=s%k==0,E=p?[b,4,4]:[1,1,1],C=[{type:6,data:i},{type:6,data:r},{type:6,data:s},{type:6,data:[e.pads[0],e.pads[1]]},{type:6,data:e.strides},{type:6,data:e.dilations}];Sr(e,C),C.push(...ze(t[0].dims,t[1].dims));let A=["rank","rank"];return o&&(C.push(...ze(t[2].dims)),A.push("rank")),C.push(...ze(n)),{name:"Conv2DMatMul",shaderCache:{hint:`${e.cacheKey};${b};${p};${$};${S};${M};${x};${_};${k}`,inputDependencies:A},getRunData:()=>({outputs:[{dims:n,dataType:t[0].dataType}],dispatchGroup:{x:g[0],y:g[1],z:g[2]},programUniforms:C}),getShaderSource:i=>{let r=[{name:"dim_a_outer",type:"i32"},{name:"dim_b_outer",type:"i32"},{name:"dim_inner",type:"i32"},{name:"pad",type:"i32",length:2},{name:"stride",type:"i32",length:2},{name:"dilation",type:"i32",length:2}];Mr(e,r);let s=p?4:1,h=Oe(t[0].dataType),l=`\n fn setOutputAtIndex(flatIndex : i32, value : ${p?`vec4<${h}>`:h}) {\n result[flatIndex] = ${p?`vec4<${h}>`:h}(value);\n }\n fn setOutputAtCoords(d0 : i32, d1 : i32, d2 : i32, d3 : i32, value : ${p?`vec4<${h}>`:h}) {\n let flatIndex = getOutputIndexFromCoords(vec4<i32>(d0, d1, d2, d3));\n setOutputAtIndex(flatIndex ${p?"/ 4":""}, value);\n }`,c=[qe("x",t[0].dataType,t[0].dims.length,3===b?1:b),qe("w",t[1].dataType,t[1].dims.length,s)],f=je("result",t[0].dataType,n.length,s);if(o){let e=qe("bias",t[2].dataType,t[2].dims.length,s);c.push(e),l+=`\n fn getBiasByOutputCoords(coords : vec4<i32>) -> ${p?`vec4<${h}>`:h} {\n return bias[coords.${u?"w":"y"}${p?"/ 4":""}];\n }`}return`\n ${Ir("uniforms.result_strides")}\n //struct Uniforms { xShape : vec4<i32>, wShape : vec4<i32>, outShape : vec4<i32>,\n // outShapeStrides: vec3<i32>, filterDims : vec2<i32>, pad : vec2<i32>, stride : vec2<i32>,\n // dilation : vec2<i32>, dimAOuter : i32, dimBOuter : i32, dimInner : i32 };\n ${i.registerUniforms(r).declareVariables(...c,f)}\n ${l}\n ${Ur(u,$,S,M,o,e,E[0],E[1],E[2],h)}\n ${p?zr(w,m,h,void 0,!u,k):Rr(w,m,h,void 0,!u,k,!1,void 0,a)}`}}}})),Lu=V((()=>{wu(),bu(),Su(),Mu(),Fu(),Uu(),jr=t=>{let e=1;for(let n=0;n<t.length;n++)e*=t[n];return e},Br=t=>"number"==typeof t?[t,t,t]:t,Lr=(t,e)=>e<=1?t:t+(t-1)*(e-1),Hr=(t,e,n,i=1)=>{let r=Lr(e,i);return Math.floor((t[0]*(n-1)-n+r)/2)},Vr=(t,e,n,i,r)=>{null==r&&(r=Hr(t,e[0],i[0]));let s=[0,0,0,n];for(let n=0;n<3;n++)t[n]+2*r>=e[n]&&(s[n]=Math.trunc((t[n]-e[n]+2*r)/i[n]+1));return s},Wr=(t,e,n,i,r,s,o,a,u,h)=>{let l,c,f,d;if("VALID"===t&&(t=0),"number"==typeof t){l={top:t,bottom:t,left:t,right:t,front:t,back:t};let p=Vr([e,n,i,1],[a,u,h],1,[r,s,o],t);c=p[0],f=p[1],d=p[2]}else if(Array.isArray(t)){if(!t.every(((t,e,n)=>t===n[0])))throw Error(`Unsupported padding parameter: ${t}`);l={top:t[0],bottom:t[1],left:t[2],right:t[3],front:t[4],back:t[5]};let p=Vr([e,n,i,1],[a,u,h],1,[r,s,o],t[0]);c=p[0],f=p[1],d=p[2]}else{if("SAME_UPPER"!==t)throw Error(`Unknown padding parameter: ${t}`);{c=Math.ceil(e/r),f=Math.ceil(n/s),d=Math.ceil(i/o);let t=(c-1)*r+a-e,p=(f-1)*s+u-n,v=(d-1)*o+h-i,y=Math.floor(t/2),m=t-y,w=Math.floor(p/2),g=p-w,b=Math.floor(v/2);l={top:w,bottom:g,left:b,right:v-b,front:y,back:m}}}return{padInfo:l,outDepth:c,outHeight:f,outWidth:d}},Gr=(t,e,n,i,r,s=!1,o="channelsLast")=>{let a,u,h,l,c;if("channelsLast"===o)[a,u,h,l,c]=t;else{if("channelsFirst"!==o)throw new Error(`Unknown dataFormat ${o}`);[a,c,u,h,l]=t}let[f,,d,p,v]=e,[y,m,w]=Br(n),[g,b,x]=Br(i),_=Lr(d,g),k=Lr(p,b),$=Lr(v,x),{padInfo:S,outDepth:M,outHeight:E,outWidth:C}=Wr(r,u,h,l,y,m,w,_,k,$),A=s?f*c:f,I=[0,0,0,0,0];return"channelsFirst"===o?I=[a,A,M,E,C]:"channelsLast"===o&&(I=[a,M,E,C,A]),{batchSize:a,dataFormat:o,inDepth:u,inHeight:h,inWidth:l,inChannels:c,outDepth:M,outHeight:E,outWidth:C,outChannels:A,padInfo:S,strideDepth:y,strideHeight:m,strideWidth:w,filterDepth:d,filterHeight:p,filterWidth:v,effectiveFilterDepth:_,effectiveFilterHeight:k,effectiveFilterWidth:$,dilationDepth:g,dilationHeight:b,dilationWidth:x,inShape:t,outShape:I,filterShape:e}},Qr=(t,e,n,i,r,s)=>{let o="channelsLast"===s;o?t[0].dims[3]:t[0].dims[1];let a={x:n.map(((t,e)=>e))},u=[Math.ceil(jr(a.x.map((t=>n[t])))/64),1,1];he("verbose",(()=>`[conv3d_naive_webgpu] dispatch = ${u}`));let h=[{type:12,data:$e.size(n)},{type:12,data:i},{type:12,data:r},{type:12,data:e.strides},{type:12,data:e.dilations}];Sr(e,h),h.push(...ze(t[0].dims,t[1].dims));let l=["rank","rank"],c=3===t.length;return c&&(h.push(...ze(t[2].dims)),l.push("rank")),h.push(...ze(n)),{name:"Conv3DNaive",shaderCache:{hint:`${e.cacheKey};${o};1;${c}`,inputDependencies:l},getRunData:()=>({outputs:[{dims:n,dataType:t[0].dataType}],dispatchGroup:{x:u[0],y:u[1],z:u[2]},programUniforms:h}),getShaderSource:s=>{let a=[{name:"output_size",type:"u32"},{name:"filter_dims",type:"u32",length:i.length},{name:"pads",type:"u32",length:r.length},{name:"strides",type:"u32",length:e.strides.length},{name:"dilations",type:"u32",length:e.dilations.length}];Mr(e,a);let u=Oe(t[0].dataType),h=qe("x",t[0].dataType,t[0].dims.length,1),l=qe("W",t[1].dataType,t[1].dims.length,1),f=[h,l],d=je("result",t[0].dataType,n.length,1),p="";if(c){let e=qe("bias",t[2].dataType,t[2].dims.length,1);f.push(e),p+=`\n fn getBiasByOutputCoords(coords : array<u32, 5>) -> ${u} {\n return bias[${Fe("coords",o?4:1,5)}];\n }`}let v=Cr(1,u),y=$r(e,v,u);return`\n ${p}\n fn getX(d0 : u32, d1 : u32, d2 : u32, d3 : u32, d4 : u32) -> f32 {\n let aIndices = array<u32, 5>(d0, d1, d2, d3, d4);\n return ${h.getByIndices("aIndices")};\n }\n fn getW(d0 : u32, d1 : u32, d2 : u32, d3 : u32, d4 : u32) -> f32 {\n let aIndices = array<u32, 5>(d0, d1, d2, d3, d4);\n return ${l.getByIndices("aIndices")};\n }\n ${s.registerUniforms(a).declareVariables(...f,d)}\n ${s.mainStart()}\n ${s.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n let coords = ${d.offsetToIndices("global_idx")};\n let batch = ${Fe("coords",0,h.rank)};\n let d2 = ${Fe("coords",o?h.rank-1:1,h.rank)};\n let xFRCCorner = vec3<u32>(${Fe("coords",o?1:2,h.rank)},\n ${Fe("coords",o?2:3,h.rank)},\n ${Fe("coords",o?3:4,h.rank)}) * uniforms.strides - uniforms.pads;\n let xFCorner = xFRCCorner.x;\n let xRCorner = xFRCCorner.y;\n let xCCorner = xFRCCorner.z;\n let xShapeY = ${Fe("uniforms.x_shape",o?1:2,h.rank)};\n let xShapeZ = ${Fe("uniforms.x_shape",o?2:3,h.rank)};\n let xShapeW = ${Fe("uniforms.x_shape",o?3:4,h.rank)};\n let xShapeU = ${Fe("uniforms.x_shape",o?4:1,h.rank)};\n let inputDepthNearestVec4 = (xShapeU / 4) * 4;\n let inputDepthVec4Remainder = xShapeU % 4;\n\n var value = 0.0;\n for (var wF = 0u; wF < uniforms.filter_dims[0]; wF++) {\n let xF = xFCorner + wF * uniforms.dilations[0];\n if (xF < 0 || xF >= xShapeY) {\n continue;\n }\n\n for (var wR = 0u; wR < uniforms.filter_dims[1]; wR++) {\n let xR = xRCorner + wR * uniforms.dilations[1];\n if (xR < 0 || xR >= xShapeZ) {\n continue;\n }\n\n for (var wC = 0u; wC < uniforms.filter_dims[2]; wC++) {\n let xC = xCCorner + wC * uniforms.dilations[2];\n if (xC < 0 || xC >= xShapeW) {\n continue;\n }\n\n for (var d1 = 0u; d1 < inputDepthNearestVec4; d1 += 4) {\n ${o?"let xValues = vec4<f32>(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3));\n ":"let xValues = vec4<f32>(\n getX(batch, d1, xF, xR, xC),\n getX(batch, d1 + 1, xF, xR, xC),\n getX(batch, d1 + 2, xF, xR, xC),\n getX(batch, d1 + 3, xF, xR, xC));\n "}\n let wValues = vec4<f32>(\n getW(d2, d1, wF, wR, wC),\n getW(d2, d1 + 1, wF, wR, wC),\n getW(d2, d1 + 2, wF, wR, wC),\n getW(d2, d1 + 3, wF, wR, wC));\n value += dot(xValues, wValues);\n }\n if (inputDepthVec4Remainder == 1) {\n ${o?"value += getX(batch, xF, xR, xC, inputDepthNearestVec4)\n * getW(d2, inputDepthNearestVec4, wF, wR, wC);":"value += getX(batch, inputDepthNearestVec4, xF, xR, xC)\n * getW(d2, inputDepthNearestVec4, wF, wR, wC);"}\n } else if (inputDepthVec4Remainder == 2) {\n ${o?"let xValues = vec2<f32>(\n getX(batch, xF, xR, xC, inputDepthNearestVec4),\n getX(batch, xF, xR, xC, inputDepthNearestVec4 + 1));\n ":"let xValues = vec2<f32>(\n getX(batch, inputDepthNearestVec4, xF, xR, xC),\n getX(batch, inputDepthNearestVec4 + 1, xF, xR, xC));\n "}\n let wValues = vec2<f32>(\n getW(d2, inputDepthNearestVec4, wF, wR, wC),\n getW(d2, inputDepthNearestVec4 + 1, wF, wR, wC));\n value += dot(xValues, wValues);\n } else if (inputDepthVec4Remainder == 3) {\n ${o?"let xValues = vec3<f32>(\n getX(batch, xF, xR, xC, inputDepthNearestVec4),\n getX(batch, xF, xR, xC, inputDepthNearestVec4 + 1),\n getX(batch, xF, xR, xC, inputDepthNearestVec4 + 2));\n ":"let xValues = vec3<f32>(\n getX(batch, inputDepthNearestVec4, xF, xR, xC),\n getX(batch, inputDepthNearestVec4 + 1, xF, xR, xC),\n getX(batch, inputDepthNearestVec4 + 2, xF, xR, xC));\n "}\n let wValues = vec3<f32>(\n getW(d2, inputDepthNearestVec4, wF, wR, wC),\n getW(d2, inputDepthNearestVec4 + 1, wF, wR, wC),\n getW(d2, inputDepthNearestVec4 + 2, wF, wR, wC));\n value += dot(xValues, wValues);\n }\n }\n }\n }\n ${c?"value = value + getBiasByOutputCoords(coords)":""};\n ${y}\n result[global_idx] = f32(value);\n }`}}}})),Hu=V((()=>{wu(),Su(),Mu(),Wu(),Fu(),Kr=(t,e,n)=>{let i=t.length>2,r=i?"value += b[output_channel];":"",s=t[0].dims,o=t[1].dims,a=o[0]/e.group,u="NHWC"===e.format,h=ts(s,o,e.dilations,e.pads,e.strides,u),l=$e.size(h),c=[{type:12,data:l},{type:12,data:e.dilations},{type:12,data:[e.strides[0],e.strides[1]]},{type:12,data:[e.pads[0],e.pads[1]]},{type:12,data:a}];Sr(e,c),c.push(...ze(s,o));let f=["rank","rank"];return i&&(c.push(...ze(t[2].dims)),f.push("rank")),c.push(...ze(h)),{name:"GroupedConv",shaderCache:{hint:e.cacheKey,inputDependencies:f},getRunData:()=>({outputs:[{dims:n?n(h):h,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(l/64)},programUniforms:c}),getShaderSource:n=>{let a=je("output",t[0].dataType,h.length),l=Oe(a.type.tensor),c=$r(e,a.type.value,l),f=qe("x",t[0].dataType,s.length),d=qe("w",t[1].dataType,o.length),p=[f,d];i&&p.push(qe("b",t[2].dataType,t[2].dims.length));let v=[{name:"output_size",type:"u32"},{name:"dilations",type:"u32",length:e.dilations.length},{name:"strides",type:"u32",length:2},{name:"pads",type:"u32",length:2},{name:"output_channels_per_group",type:"u32"}];return Mr(e,v),`\n ${n.registerUniforms(v).declareVariables(...p,a)}\n\n ${n.mainStart()}\n ${n.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n\n let outputIndices = ${a.offsetToIndices("global_idx")};\n let batch: u32 = outputIndices[0];\n let output_channel: u32 = outputIndices[${u?3:1}];\n let xRCCorner: vec2<u32> = vec2<u32>(outputIndices[${u?1:2}], outputIndices[${u?2:3}]) * uniforms.strides - uniforms.pads;\n let group_id: u32 = output_channel / uniforms.output_channels_per_group;\n\n var value: ${a.type.value} = ${a.type.value}(0);\n for (var wInChannel: u32 = 0u; wInChannel < uniforms.w_shape[1]; wInChannel++) {\n let input_channel = group_id * uniforms.w_shape[1] + wInChannel;\n for (var wHeight: u32 = 0u; wHeight < uniforms.w_shape[2]; wHeight++) {\n let xHeight = xRCCorner.x + wHeight * uniforms.dilations[0];\n\n if (xHeight < 0u || xHeight >= uniforms.x_shape[${u?1:2}]) {\n continue;\n }\n\n for (var wWidth: u32 = 0u; wWidth < uniforms.w_shape[3]; wWidth++) {\n let xWidth = xRCCorner.y + wWidth * uniforms.dilations[1];\n if (xWidth < 0u || xWidth >= uniforms.x_shape[${u?2:3}]) {\n continue;\n }\n\n let xVal = ${u?f.get("batch","xHeight","xWidth","input_channel"):f.get("batch","input_channel","xHeight","xWidth")};\n let wVal = ${d.get("output_channel","wInChannel","wHeight","wWidth")};\n value += xVal*wVal;\n }\n }\n }\n ${r}\n ${c}\n ${a.setByOffset("global_idx","value")}\n }`}}},Xr=(t,e,n)=>{let i=t.length>2,r=De(n[3]),s=De(n[2]),o=$e.size(n)/r/s,a=[t[0].dims[0],t[0].dims[1],t[0].dims[2],t[0].dims[3]/r],u=[t[1].dims[0],t[1].dims[1],t[1].dims[2],t[1].dims[3]/r],h=[n[0],n[1],n[2],n[3]/r],l=[{type:12,data:o},{type:6,data:[e.strides[0],e.strides[1]]},{type:6,data:[e.pads[0],e.pads[1]]}];Sr(e,l),l.push(...ze(a,u,h));let c=(s-1)*e.strides[1]+u[1];return{name:"GroupedConv-Vectorize",shaderCache:{hint:`${e.cacheKey};${r};${s};${c};${u[0]};${u[1]}`,inputDependencies:i?["rank","rank","type"]:["rank","rank"]},getRunData:()=>({outputs:[{dims:n,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(o/64)},programUniforms:l}),getShaderSource:n=>{let o=je("output",t[0].dataType,h.length,r),l=Oe(o.type.tensor),f=$r(e,o.type.value,l),d=qe("x",t[0].dataType,a.length,r),p=qe("w",t[1].dataType,u.length,r),v=[d,p];i&&v.push(qe("b",t[2].dataType,t[2].dims,r));let y=i?"value += b[output_channel];":"",m=[{name:"output_size",type:"u32"},{name:"strides",type:"i32",length:2},{name:"pads",type:"i32",length:2}];return Mr(e,m),`\n ${n.registerUniforms(m).declareVariables(...v,o)}\n ${n.mainStart()}\n ${n.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n let width0 = uniforms.output_shape[3];\n let output_channel = global_idx % width0;\n var index1 = global_idx / width0;\n let width1 = uniforms.output_shape[2] / ${s}u;\n let col = (index1 % width1) * ${s}u;\n index1 = index1 / width1;\n let row = index1 % uniforms.output_shape[1];\n let batch = index1 / uniforms.output_shape[1];\n\n let x_corner = vec2<i32>(i32(row), i32(col)) * uniforms.strides - uniforms.pads;\n\n var x_vals: array<${d.type.value}, ${c}>;\n var values: array<${o.type.value}, ${s}>;\n let input_channel = output_channel;\n // Use constant instead of uniform can give better performance for w's height/width.\n for (var w_height: u32 = 0u; w_height < ${u[0]}; w_height++) {\n let x_height = x_corner.x + i32(w_height);\n if (x_height >= 0 && u32(x_height) < uniforms.x_shape[1]) {\n for (var i = 0; i < ${c}; i++) {\n let x_width = x_corner.y + i;\n if (x_width >= 0 && u32(x_width) < uniforms.x_shape[2]) {\n x_vals[i] = ${d.get("batch","u32(x_height)","u32(x_width)","input_channel")};\n } else {\n x_vals[i] = ${d.type.value}(0);\n }\n }\n for (var w_width: u32 = 0u; w_width < ${u[1]}; w_width++) {\n let w_val = ${p.get("w_height","w_width","0","output_channel")};\n for (var i = 0u; i < ${s}u; i++) {\n values[i] = fma(x_vals[i * u32(uniforms.strides[1]) + w_width], w_val, values[i]);\n }\n }\n }\n }\n\n for (var i = 0u; i < ${s}u; i++) {\n var value = values[i];\n ${y}\n ${f}\n ${o.set("batch","row","col + i","output_channel","value")};\n }\n }`}}}})),Vu=V((()=>{wu(),Su(),ju(),Mu(),Fu(),Zr=(t,e,n,i,r=!1)=>{let s=t[0].dims,o=t[1].dims,a=s[s.length-2],u=o[o.length-1],h=s[s.length-1],l=De(u),c=De(h),f=De(a),d=$e.size(n)/l/f,p=t.length>2,v=i?i.slice(0,-2):n.slice(0,-2),y=[$e.size(v),a,u],m=[{type:12,data:d},{type:12,data:a},{type:12,data:u},{type:12,data:h}];return Sr(e,m),m.push(...ze(v,s,o)),p&&m.push(...ze(t[2].dims)),m.push(...ze(y)),{name:"MatMulNaive",shaderCache:{hint:`${e.activation};${l};${c};${f};${r}`,inputDependencies:p?["rank","rank","rank"]:["rank","rank"]},getRunData:()=>({outputs:[{dims:n,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(d/64)},programUniforms:m}),getShaderSource:i=>{let a=Be("batch_dims",t[0].dataType,v.length),u=qe("a",t[0].dataType,s.length,c),h=qe("b",t[1].dataType,o.length,l),d=je("output",t[0].dataType,y.length,l),m=Oe(d.type.tensor),w=$r(e,d.type.value,m),g=[u,h],b="";if(p){let e=r?l:1;g.push(qe("bias",t[2].dataType,t[2].dims.length,e)),b=r?`value += bias[col / ${e}];`:`value += ${d.type.value}(bias[row + i]);`}let x=s.slice(0,-2),_=o.slice(0,-2),k=Ve(x,v),$=Ve(_,v),S=[{name:"output_size",type:"u32"},{name:"M",type:"u32"},{name:"N",type:"u32"},{name:"K",type:"u32"}];Mr(e,S);let M=(t,e)=>{let n=t.rank,i=t.name;if(2===n)return`var ${i}_indices = ${t.type.indices}(0u, 0u);`;let r=a.rank,s=`var ${i}_indices: ${t.type.indices};`;for(let t=n-2-1,e=r-1;t>=0;t--,e--)s+=`\n${i}_indices[${t}] = ${r>1?`batch_indices[${e}]`:"batch_indices"};`;return e.forEach((t=>{s+=`\n${i}_indices[${t}] = 0;`})),s+=`${i}_indices[${n-2}] = 0u;\n ${i}_indices[${n-1}] = 0u;`,s};return`\n ${i.registerUniforms(S).registerInternalVariables(a).declareVariables(...g,d)}\n ${i.mainStart()}\n ${i.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n let col = (global_idx % (uniforms.N / ${l})) * ${l};\n var index1 = global_idx / (uniforms.N / ${l});\n let stride1 = uniforms.M / ${f};\n let row = (index1 % stride1) * ${f};\n let batch = index1 / stride1;\n\n ${2===n.length?"":`let batch_indices = ${a.offsetToIndices("batch")};`}\n ${M(u,k)}\n let a_offset = ${u.indicesToOffset("a_indices")};\n ${M(h,$)}\n let b_offset = ${h.indicesToOffset("b_indices")};\n var values: array<${d.type.value}, ${f}>;\n for (var k: u32 = 0u; k < uniforms.K; k = k + ${c}) {\n ${(()=>{let t=`var a_data: ${u.type.value};`;for(let e=0;e<c;e++)t+=`\n let b_data${e} = b[(b_offset + (k + ${e}) * uniforms.N + col) / ${l}];`;for(let e=0;e<f;e++){t+=`a_data = a[(a_offset + (row + ${e}) * uniforms.K + k) / ${c}];`;for(let n=0;n<c;n++)t+=`\n values[${e}] = fma(${h.type.value}(a_data${1===c?"":`[${n}]`}), b_data${n}, values[${e}]);\n`}return t})()}\n }\n for (var i = 0u; i < ${f}u; i++) {\n var value = values[i];\n ${b}\n ${w}\n let cur_indices = ${d.type.indices}(batch, row + i, col);\n let offset = ${d.indicesToOffset("cur_indices")};\n ${d.setByOffset(`offset / ${l}`,"value")};\n }\n }\n `}}},Yr=t=>{if(!t||2!==t.length)throw new Error("MatMul requires 2 inputs.");if(t[0].dims[t[0].dims.length-1]!==t[1].dims[t[1].dims.length-2])throw new Error("shared dimension does not match.")},Jr=t=>{Yr(t.inputs);let e=ke.calcShape(t.inputs[0].dims,t.inputs[1].dims,!0);if(!e)throw new Error("Can't use matmul on the given tensors");let n=e[e.length-1],i=t.inputs[0].dims[t.inputs[0].dims.length-1];n<8&&i<8?t.compute(Zr(t.inputs,{activation:""},e)):t.compute(Fr(t.inputs,{activation:""},e))}})),Wu=V((()=>{Su(),Bu(),Lu(),ju(),Hu(),Fu(),Vu(),Eu(),ts=(t,e,n,i,r,s)=>{let o=t[0],a=t.slice(s?1:2,s?3:4),u=a.length,h=e[0],l=e.slice(2).map(((t,e)=>t+(t-1)*(n[e]-1))),c=a.map(((t,e)=>t+i[e]+i[e+u])).map(((t,e)=>Math.floor((t-l[e]+r[e])/r[e])));return c.splice(0,0,o),c.splice(s?3:1,0,h),c},es=[2,3,1,0],ns=(t,e)=>{if(!t||2!==t.length&&3!==t.length)throw new Error("Conv requires 2 or 3 inputs");if(t[0].dims.length>5)throw new Error("greater than 5D is not supported");if(t[0].dims.length!==t[1].dims.length)throw new Error("filter does not have same dimension as input");if(t[0].dims["NHWC"===e.format?t[0].dims.length-1:1]!==t[1].dims[1]*e.group)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(3===t.length&&(1!==t[2].dims.length||t[1].dims[0]!==t[2].dims[0]))throw new Error("invalid bias");let n=t[0].dims.length-2;if(e.dilations.length!==n)throw new Error(`dilations should be ${n}D`);if(e.strides.length!==n)throw new Error(`strides should be ${n}D`);if(e.pads.length!==2*n)throw new Error(`pads should be ${2*n}D`);if(0!==e.kernelShape.length&&e.kernelShape.length!==t[1].dims.length-2)throw new Error("invalid kernel shape")},is=(t,e)=>{let n=t.kernelShape.slice();for(let t=2;t<e[1].dims.length;++t)0===n[t-2]&&(n[t-2]=e[1].dims[t]);let i=t.pads.slice();Se.adjustPadsBasedOnAutoPad(e[0].dims,t.strides,t.dilations,n,i,"NHWC"===t.format,t.autoPad);let r=Object.assign({},t);return Object.assign(r,{kernelShape:n,pads:i}),r},rs=t=>{let e=Er(t),n=t.format;return{autoPad:["NOTSET","VALID","SAME_UPPER","SAME_LOWER"][t.auto_pad],format:n,dilations:t.dilations,group:t.group,kernelShape:t.kernel_shape,pads:t.pads,strides:t.strides,wIsConst:t.w_is_const(),...e,cacheKey:`${t.format};${e.activation};`}},ss=(t,e,n)=>{let i=is(n,e),r="NHWC"===n.format;if(1!==n.group){if(!t.adapterInfo.isArchitecture("ampere")&&r&&e[1].dims[0]===n.group&&1===e[1].dims[1]&&1===n.dilations[0]&&1===n.dilations[1]){let s=ts(e[0].dims,e[1].dims,n.dilations,i.pads,n.strides,r),o=t.kernelCustomData.wT??t.compute(Xe(e[1],es),{inputs:[1],outputs:[n.wIsConst?-2:-1]})[0];n.wIsConst&&!t.kernelCustomData.wT&&(t.kernelCustomData.wT=o);let a=[e[0],o];3===e.length&&a.push(e[2]),t.compute(Xr(a,i,s),{inputs:a})}else t.compute(Kr(e,i));return}let s=3===e.length,o=e[0].dims[r?1:2],a=e[0].dims[r?2:3],u=e[0].dims[r?3:1],h=e[1].dims[2],l=e[1].dims[3],c=ts(e[0].dims,e[1].dims,n.dilations,i.pads,n.strides,r),f=c[r?1:2],d=c[r?2:3],p=c[r?3:1],v=r&&h===o&&l===a&&0===n.pads[0]&&0===n.pads[1];if(v||1===h&&1===l&&1===n.dilations[0]&&1===n.dilations[1]&&1===n.strides[0]&&1===n.strides[1]&&0===n.pads[0]&&0===n.pads[1]){let h,l,y,m=c[0],w=[];if(r){let i=t.kernelCustomData.wT??t.compute(Xe(e[1],es),{inputs:[1],outputs:[n.wIsConst?-2:-1]})[0];if(n.wIsConst&&!t.kernelCustomData.wT&&(t.kernelCustomData.wT=i),v){let t=o*a*u;h=e[0].reshape([1,m,t]),l=i.reshape([1,t,p]),y=[1,m,p]}else h=e[0].reshape([m,o*a,u]),l=i.reshape([1,u,p]),y=[m,f*d,p];w.push(h),w.push(l)}else h=e[0].reshape([m,u,o*a]),l=e[1].reshape([1,p,u]),y=[m,p,f*d],w.push(l),w.push(h);s&&w.push(e[2]);let g=y[2],b=w[0].dims[w[0].dims.length-1];return void(g<8&&b<8?t.compute(Zr(w,i,c,y,r),{inputs:w}):t.compute(Fr(w,i,c,y,r),{inputs:w}))}let y=t.kernelCustomData.wT??t.compute(Xe(e[1],es),{inputs:[1],outputs:[n.wIsConst?-2:-1]})[0];n.wIsConst&&!t.kernelCustomData.wT&&(t.kernelCustomData.wT=y);let m=[e[0],y];s&&m.push(e[2]);let w=r?f*d:p,g=r?p:f*d,b=h*l*u;t.compute(qr(m,i,c,w,g,b,s,!0),{inputs:m})},os=(t,e)=>{let n="NHWC"===e.format,i=[t.inputs[0].reshape(n?[t.inputs[0].dims[0],1,t.inputs[0].dims[1],t.inputs[0].dims[2]]:[t.inputs[0].dims[0],t.inputs[0].dims[1],1,t.inputs[0].dims[2]]),t.inputs[1].reshape([t.inputs[1].dims[0],t.inputs[1].dims[1],1,t.inputs[1].dims[2]])];3===t.inputs.length&&i.push(t.inputs[2]);let r=[0,e.pads[0],0,e.pads[1]],s=[1].concat(e.strides),o=[1].concat(e.dilations),a=[1].concat(e.kernelShape),u=is({...e,pads:r,strides:s,dilations:o,kernelShape:a},i);t.compute(Kr(i,u,(t=>n?[t[0],t[2],t[3]]:[])))},as=(t,e,n)=>{let i="NHWC"===n.format?"channelsLast":"channelsFirst",r=is(n,e),s="NOTSET"===n.autoPad?n.pads:n.autoPad,o=Gr(e[0].dims,e[1].dims,n.strides,n.dilations,s,!1,i);t.compute(Qr(e,r,o.outShape,[o.filterDepth,o.filterHeight,o.filterWidth],[o.padInfo.front,o.padInfo.top,o.padInfo.left],i))},us=(t,e)=>{ns(t.inputs,e),3===t.inputs[0].dims.length?os(t,e):5===t.inputs[0].dims.length?as(t,t.inputs,e):ss(t,t.inputs,e)}})),Gu=V((()=>{wu(),bu(),Mu(),Fu(),Uu(),qu(),ju(),hs=(t,e=!1,n,i,r=4)=>{let s=t?"\n let coords = vec4<i32>(\n batch,\n row / outWidth,\n row % outWidth,\n col);\n ":"\n let coords = vec4<i32>(\n batch,\n row,\n col / outWidth,\n col % outWidth);\n ",o=t?"row":"col",a=t?"col":"row",u=`\n let inChannels = ${t?"i32(uniforms.x_shape[3])":"i32(uniforms.x_shape[1])"};\n let outWidth = ${t?"i32(uniforms.result_shape[2])":"i32(uniforms.result_shape[3])"};\n let outRow = ${o} / outWidth;\n let outCol = ${o} % outWidth;\n\n let WRow = ${a} / (uniforms.filter_dims[1] * inChannels);\n let WCol = ${a} / inChannels % uniforms.filter_dims[1];\n let xR = f32(outRow - uniforms.pads[0] + uniforms.dilations[0] * WRow) / f32(uniforms.strides[0]);\n let xC = f32(outCol - uniforms.pads[1] + uniforms.dilations[1] * WCol) / f32(uniforms.strides[1]);\n if (xR < 0.0 || xR >= f32(${t?"i32(uniforms.x_shape[1])":"i32(uniforms.x_shape[2])"}) || fract(xR) > 0.0) {\n return ${i}(0.0);\n }\n if (xC < 0.0 || xC >= f32(${t?"i32(uniforms.x_shape[2])":"i32(uniforms.x_shape[3])"}) || fract(xC) > 0.0) {\n return ${i}(0.0);\n }\n let iXR = i32(xR);\n let iXC = i32(xC);\n let xCh = ${a} % inChannels;\n ${t?"\n let coord = vec4<i32>(batch, iXR, iXC, xCh);\n ":"\n let coord = vec4<i32>(batch, xCh, iXR, iXC);\n "}\n return x[getIndexFromCoords4D(coord, vec4<i32>(uniforms.x_shape))/${r}];`,h=t?`\n let col = colIn * ${r};\n if (row < uniforms.dim_a_outer && col < uniforms.dim_inner) {\n ${u}\n }\n return ${i}(0.0);`:`\n let col = colIn * ${r};\n if (row < uniforms.dim_inner && col < uniforms.dim_b_outer) {\n ${u}\n }\n return ${i}(0.0);`,l=`\n let col = colIn * ${r};\n let inChannels = ${t?"i32(uniforms.x_shape[3])":"i32(uniforms.x_shape[1])"};\n let coordX = uniforms.filter_dims[0] - 1 - row / (uniforms.filter_dims[1] * inChannels);\n let coordY = uniforms.filter_dims[1] - 1 - (row / inChannels) % uniforms.filter_dims[1];\n if (${t?"row < uniforms.dim_inner && col < uniforms.dim_b_outer":"row < uniforms.dim_inner && col < uniforms.dim_a_outer"} && coordX >= 0 && coordY >= 0) {\n let rowInner = row % inChannels;\n let coord = vec4<i32>(coordX, coordY, col, rowInner);\n ${(t=>{switch(t){case 1:return"return w[getIndexFromCoords4D(coord, vec4<i32>(uniforms.w_shape))];";case 4:return`\n let coord1 = vec4<i32>(coordX, coordY, col + 1, rowInner);\n let coord2 = vec4<i32>(coordX, coordY, col + 2, rowInner);\n let coord3 = vec4<i32>(coordX, coordY, col + 3, rowInner);\n let v0 = w[getIndexFromCoords4D(coord, vec4<i32>(uniforms.w_shape))];\n let v1 = w[getIndexFromCoords4D(coord1, vec4<i32>(uniforms.w_shape))];\n let v2 = w[getIndexFromCoords4D(coord2, vec4<i32>(uniforms.w_shape))];\n let v3 = w[getIndexFromCoords4D(coord3, vec4<i32>(uniforms.w_shape))];\n return ${i}(v0, v1, v2, v3);\n `;default:throw new Error(`innerElementSize ${t} is not supported.`)}})(r)}\n }\n return ${i}(0.0);\n `,c=$r(n,i);return`\n fn mm_readA(batch: i32, row : i32, colIn : i32) -> ${i} {\n ${t?h:l}\n }\n\n fn mm_readB(batch: i32, row : i32, colIn : i32) -> ${i} {\n ${t?l:h}\n }\n\n fn mm_write(batch: i32, row : i32, colIn : i32, valueInput : ${i}) {\n let col = colIn * ${r};\n if (row < uniforms.dim_a_outer && col < uniforms.dim_b_outer) {\n var value = valueInput;\n let outWidth = ${t?"i32(uniforms.result_shape[2])":"i32(uniforms.result_shape[3])"};\n ${s}\n ${Ar(e)}\n ${c}\n result[getIndexFromCoords4D(coords, vec4<i32>(uniforms.result_shape))/${r}] = value;\n }\n }`},ls=(t,e,n,i,r,s,o,a)=>{let u="NHWC"===e.format,h=u?t[0].dims[3]:t[0].dims[1],l=n[0],c=u?n[2]:n[3],f=u?n[1]:n[2],d=u?n[3]:n[1],p=u&&h%4==0&&h%3&&d%4==0,v=u?d:c*f,y=u?c*f:d,m=[8,8,1],w=i<=8?[4,1,1]:[4,4,1],g=[Math.ceil(v/m[0]/w[0]),Math.ceil(y/m[1]/w[1]),Math.ceil(l/m[2]/w[2])];he("verbose",(()=>`[conv_backprop_mm_webgpu] dispatch = ${g}`));let b=p?4:1,x=Math.max(m[0]*b,m[1]),_=p?4:1,k=[e.kernelShape[u?1:2],e.kernelShape[u?2:3]],$=[k[0]+(e.dilations[0]<=1?0:(k[0]-1)*(e.dilations[0]-1)),k[1]+(e.dilations[1]<=1?0:(k[1]-1)*(e.dilations[1]-1))],S=[$[0]-1-Math.floor((e.pads[0]+e.pads[2])/2),$[1]-1-Math.floor((e.pads[1]+e.pads[3])/2)],M=[{type:6,data:i},{type:6,data:r},{type:6,data:s},{type:6,data:e.strides},{type:6,data:e.dilations},{type:6,data:k},{type:6,data:S}];Sr(e,M),M.push(...ze(t[0].dims,t[1].dims));let E=["rank","rank"];return o&&(M.push(...ze(t[2].dims)),E.push("rank")),M.push(...ze(n)),{name:"Conv2DTransposeMatMul",shaderCache:{hint:`${e.cacheKey};${w};${m};${p}`,inputDependencies:E},getRunData:()=>({outputs:[{dims:n,dataType:t[0].dataType}],dispatchGroup:{x:g[0],y:g[1],z:g[2]},programUniforms:M}),getShaderSource:i=>{let r=qe("x",t[0].dataType,t[0].dims.length,_),s=qe("w",t[1].dataType,t[1].dims.length,1),h=je("result",t[0].dataType,n.length,_),l=[r,s],c="";if(o){let e=qe("bias",t[2].dataType,t[2].dims.length,_);l.push(e),c+=`\n fn getBiasByOutputCoords(coords : vec4<i32>) -> ${e.type.value} {\n return bias[coords.${u?"w":"y"}${p?"/ 4":""}];\n }`}let f=[{name:"dim_a_outer",type:"i32"},{name:"dim_b_outer",type:"i32"},{name:"dim_inner",type:"i32"},{name:"strides",type:"i32",length:2},{name:"dilations",type:"i32",length:2},{name:"filter_dims",type:"i32",length:k.length},{name:"pads",type:"i32",length:S.length}];Mr(e,f);let d=Oe(t[0].dataType,1);if("f16"!==d&&"f32"!==d)throw new Error(`elemType ${d} is not supported.`);return`\n ${Ir("uniforms.result_strides")}\n ${i.registerUniforms(f).declareVariables(...l,h)};\n ${c}\n ${hs(u,o,e,r.type.value,b)}\n ${p?zr(w,m,d,void 0,!u,x):Rr(w,m,d,void 0,!u,x,!1,void 0,a)}`}}}})),Qu=V((()=>{wu(),bu(),Su(),Mu(),cs=(t,e,n,i,r,s=!1,o,a,u=!1)=>{let h=u?1:2,l=u?2:3,c=u?3:1,f=s?2:1,d=`\n fn setOutputAtIndex(flatIndex : u32, value : ${s?`vec4<${o}>`:o}) {\n result[flatIndex] = ${s?`vec4<${o}>`:o}(value);\n }`;i&&(d+=`\n fn getBiasByOutputCoords(coords : vec4<u32>) -> ${s?`vec4<${o}>`:o} {\n return bias[coords.${u?"w":"y"}${s?"/ 4":""}];\n }`);let p=s?4:1,v=qe("W",e[1].dataType,e[1].dims.length,p),y=qe("Dy",e[0].dataType,e[0].dims.length,p),m=[y,v];i&&m.push(qe("bias",e[2].dataType,[n[c]].length,p));let w=je("result",e[0].dataType,n.length,p),g=`{\n let batch: u32 = ${r?"global_id.z":"workgroup_id.z"} / uniforms.result_shape[1];\n let r = ${r?"global_id.z":"workgroup_id.z"} % uniforms.result_shape[1];\n let c = ${r?"global_id.y":"workgroup_id.y"} * ${f};\n let d1: u32 = ${r?"global_id.x":"workgroup_id.x"} * 4;\n\n let dyCorner = vec2<i32>(i32(r), i32(c)) - vec2<i32>(uniforms.pads);\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n var dotProd: array<vec4<${o}>, ${f}>;\n for (var i = 0; i < ${f}; i++) {\n dotProd[i] = vec4<${o}>(0.0);\n }\n for (var wR: u32 = 0; wR < uniforms.filter_dims[0]; wR = wR + 1) {\n var dyR = (${o}(dyCorner.x) + ${o}(wR)) / ${o}(uniforms.strides.x);\n let wRPerm = uniforms.filter_dims[0] - 1 - wR;\n if (dyR < 0.0 || dyR >= ${o}(uniforms.Dy_shape[1]) ||\n fract(dyR) > 0.0 || wRPerm < 0) {\n continue;\n }\n let idyR: u32 = u32(dyR);\n\n for (var wC: u32 = 0; wC < uniforms.filter_dims[1]; wC = wC + 1) {\n let dyC = (${o}(dyCorner.y) + ${o}(wC)) / ${o}(uniforms.strides.y);\n let dyC2 = (${o}(dyCorner.y) + 1.0 + ${o}(wC)) / ${o}(uniforms.strides.y);\n let wCPerm = uniforms.filter_dims[1] - 1 - wC;\n if (wCPerm < 0) {\n continue;\n }\n var bDyCVal = true;\n var bDyCVal2 = true;\n if (dyC < 0.0 || dyC >= ${o}(uniforms.Dy_shape[2]) ||\n fract(dyC) > 0.0) {\n bDyCVal = false;\n }\n if (dyC2 < 0.0 || dyC2 >= ${o}(uniforms.Dy_shape[2]) ||\n fract(dyC2) > 0.0) {\n bDyCVal2 = false;\n }\n\n let idyC: u32 = u32(dyC);\n let idyC2: u32 = u32(dyC2);\n if (bDyCVal && bDyCVal2) {\n let d2Length = uniforms.Dy_shape[3];\n for (var d2 :u32 = 0; d2 < d2Length; d2 = d2 + 4) {\n let wValue0 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1","d2")};\n let wValue1 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1 + 1","d2")};\n let wValue2 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1 + 2","d2")};\n let wValue3 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1 + 3","d2")};\n\n var xValue = ${y.get("batch","idyR","idyC","d2")};\n let tmpval = vec4<${o}>(dot(xValue, wValue0),\n dot(xValue, wValue1),\n dot(xValue, wValue2),\n dot(xValue, wValue3));\n dotProd[0] = dotProd[0] + tmpval;\n\n xValue = ${y.get("batch","idyR","idyC2","d2")};\n\n dotProd[1] = dotProd[1] + vec4<${o}>(dot(xValue, wValue0),\n dot(xValue, wValue1),\n dot(xValue, wValue2),\n dot(xValue, wValue3));\n }\n } else if (bDyCVal) {\n let d2Length = uniforms.Dy_shape[${c}];\n for (var d2: u32 = 0; d2 < d2Length; d2 = d2 + 4) {\n let wValue0 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1","d2")};\n let wValue1 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1 + 1","d2")};\n let wValue2 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1 + 2","d2")};\n let wValue3 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1 + 3","d2")};\n\n var xValue = ${y.get("batch","idyR","idyC","d2")};\n let tmpval = vec4<${o}>(dot(xValue, wValue0),\n dot(xValue, wValue1),\n dot(xValue, wValue2),\n dot(xValue, wValue3));\n dotProd[0] = dotProd[0] + tmpval;\n }\n } else if (bDyCVal2) {\n let d2Length = uniforms.Dy_shape[3];\n for (var d2: u32 = 0; d2 < d2Length; d2 = d2 + 4) {\n let wValue0 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1","d2")};\n let wValue1 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1 + 1","d2")};\n let wValue2 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1 + 2","d2")};\n let wValue3 = ${v.get("u32(wRPerm)","u32(wCPerm)","d1 + 3","d2")};\n\n var xValue = ${y.get("batch","idyR","idyC2","d2")};\n let tmpval = vec4<${o}>(dot(xValue, wValue0),\n dot(xValue, wValue1),\n dot(xValue, wValue2),\n dot(xValue, wValue3));\n dotProd[1] = dotProd[1] + tmpval;\n }\n }\n }\n }\n\n for (var i: u32 = 0; i < ${f}; i = i + 1) {\n let value = dotProd[i] + ${i?"bias[c+i]":`vec4<${o}>(0.0)`};\n ${w.set("batch","r","c + i","d1","value")};\n }\n }`,b=`\n let outputIndices = ${w.offsetToIndices("global_idx")};\n let batch = ${w.indicesGet("outputIndices",0)};\n let d1 = ${w.indicesGet("outputIndices",c)};\n let r = ${w.indicesGet("outputIndices",h)};\n let c = ${w.indicesGet("outputIndices",l)};\n let dyCorner = vec2<i32>(i32(r), i32(c)) - uniforms.pads;\n let dyRCorner = dyCorner.x;\n let dyCCorner = dyCorner.y;\n let groupId = d1 / uniforms.output_channels_per_group;\n let wOutChannel = d1 - groupId * uniforms.output_channels_per_group;\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n var dotProd = ${o}(0.0);\n for (var wR: u32 = 0; wR < uniforms.effective_filter_dims.x; wR = wR + 1) {\n if (wR % uniforms.dilations.x != 0) {\n continue;\n }\n let dyR = (${o}(dyRCorner) + ${o}(wR)) / ${o}(uniforms.strides[0]);\n let wRPerm = uniforms.filter_dims.x - 1 - wR / uniforms.dilations.x;\n if (dyR < 0.0 || dyR >= ${o}(uniforms.Dy_shape[${h}]) || fract(dyR) > 0.0 ||\n wRPerm < 0) {\n continue;\n }\n let idyR: u32 = u32(dyR);\n\n for (var wC: u32 = 0; wC < uniforms.effective_filter_dims.y; wC = wC + 1) {\n if (wC % uniforms.dilations.y != 0) {\n continue;\n }\n let dyC = (${o}(dyCCorner) + ${o}(wC)) / ${o}(uniforms.strides.y);\n let wCPerm = uniforms.filter_dims.y - 1 - wC / uniforms.dilations.y;\n if (dyC < 0.0 || dyC >= ${o}(uniforms.Dy_shape[${l}]) ||\n fract(dyC) > 0.0 || wCPerm < 0) {\n continue;\n }\n let idyC: u32 = u32(dyC);\n var inputChannel = groupId * uniforms.input_channels_per_group;\n for (var d2: u32 = 0; d2 < uniforms.input_channels_per_group; d2 = d2 + 1) {\n let xValue = ${u?y.get("batch","idyR","idyC","inputChannel"):y.get("batch","inputChannel","idyR","idyC")};\n let wValue = ${v.get("inputChannel","wOutChannel","u32(wRPerm)","u32(wCPerm)")};\n dotProd = dotProd + xValue * wValue;\n inputChannel = inputChannel + 1;\n }\n }\n }\n let value = dotProd + ${i?"bias[d1]":`${o}(0.0)`};\n ${w.setByOffset("global_idx","value")};\n `;return`\n ${t.registerUniforms(a).declareVariables(...m,w)}\n ${d}\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")};\n ${s?g:b}}`},fs=(t,e,n)=>{let i=t.length>2,r=e.outputShape,s=$e.size(r),o=[Math.ceil(s/64),1,1];he("verbose",(()=>`[conv2d_backprop_webgpu] dispatch = ${o}`));let a="NHWC"===e.format,u=["rank","rank"],h=[e.strides[0],e.strides[1]],l=[e.kernelShape[a?1:2],e.kernelShape[a?2:3]],c=[e.dilations[0],e.dilations[1]],f=[l[0]+(e.dilations[0]<=1?0:(e.kernelShape[a?1:2]-1)*(e.dilations[0]-1)),l[1]+(e.dilations[1]<=1?0:(e.kernelShape[a?2:3]-1)*(e.dilations[1]-1))],d=[f[0]-1-Math.floor((e.pads[0]+e.pads[2])/2),f[1]-1-Math.floor(e.pads[1]+e.pads[3])/2],p=e.group,v=t[1].dims,y=v[0]/p,m=v[1],w=[{type:12,data:s},{type:12,data:h},{type:12,data:l},{type:12,data:c},{type:12,data:f},{type:6,data:d},{type:12,data:y},{type:12,data:m},...ze(t[0].dims,t[1].dims)];i&&(w.push(...ze(t[2].dims)),u.push("rank")),w.push(...ze(r));let g=1===o[1]&&1===o[2];return{name:"ConvTranspose2D",shaderCache:{hint:`${e.cacheKey};`,inputDependencies:u},getRunData:()=>({dispatchGroup:{x:o[0],y:o[1],z:o[2]},outputs:[{dims:n?n(r):r,dataType:t[0].dataType}],programUniforms:w}),getShaderSource:e=>{let n=[{name:"output_size",type:"u32"},{name:"strides",type:"u32",length:h.length},{name:"filter_dims",type:"u32",length:l.length},{name:"dilations",type:"u32",length:l.length},{name:"effective_filter_dims",type:"u32",length:f.length},{name:"pads",type:"i32",length:d.length},{name:"input_channels_per_group",type:"u32"},{name:"output_channels_per_group",type:"u32"}],s=Oe(t[0].dataType);return`${cs(e,t,r,i,g,!1,s,n,a)}`}}}})),Ku=V((()=>{Gu(),Qu(),Fu(),Eu(),ds=(t,e,n,i,r,s)=>(t-1)*e+n+(i-1)*r+1-s,ps=(t,e,n,i,r)=>{let s=Math.floor(t/2);"SAME_UPPER"===e?(n[i]=s,n[r]=t-s):"SAME_LOWER"===e&&(n[i]=t-s,n[r]=s)},vs=(t,e,n,i,r,s,o,a,u,h)=>{let l=t.length-2,c=0===h.length;if(0===u.length)for(let t=0;t<l;++t)u.push(0);let f=t[0],d=e[a?3:1]*r;for(let r=0,f=t.length-l-(a?1:0);r<l;++r,++f){let a=t[f],d=c?a*o[r]:h[r],p=ds(a,o[r],s[r],e[f],n[r],d);ps(p,i,s,r,r+l),c&&h.push(o[r]*(a-1)+u[r]+(e[f]-1)*n[r]+1-s[r]-s[r+l])}h.splice(0,0,f),h.splice(a?3:1,0,d)},ys=(t,e)=>{let n=t.kernelShape.slice();if(0===t.kernelShape.length||0===t.kernelShape.reduce(((t,e)=>t*e),1)){n.length=0;for(let t=2;t<e[1].dims.length;++t)n.push(e[1].dims[t])}let i="NHWC"===t.format;n.splice(0,0,e[1].dims[0]),n.splice(i?3:1,0,e[1].dims[1]);let r=t.pads.slice(),s=t.outputShape.slice(),o=t.outputPadding.slice(),a=e[0].dims,u=t.dilations.slice();if(0===u.reduce(((t,e)=>t+e),0)){let t=e[0].dims.length-2;u=new Array(t).fill(1)}let h=t.strides.slice();if(0===h.reduce(((t,e)=>t+e),0)){let t=e[0].dims.length-2;h=new Array(t).fill(1)}vs(a,n,u,t.autoPad,t.group,r,h,i,o,s);let l=Object.assign({},t);return Object.assign(l,{kernelShape:n,pads:r,outputPadding:o,outputShape:s,dilations:u,strides:h}),l},ms=t=>{let e=Er(t),n=t.format,i=["NOTSET","VALID","SAME_UPPER","SAME_LOWER"][typeof t.autoPad>"u"?0:t.autoPad],r=t.dilations,s=t.group,o=t.kernelShape,a=t.pads,u=t.strides,h=t.wIsConst();return{autoPad:i,format:n,dilations:r,group:s,kernelShape:o,outputPadding:t.outputPadding,outputShape:t.outputShape,pads:a,strides:u,wIsConst:h,...e,cacheKey:`${t.format};${e.activation};`}},ws=(t,e)=>{if(!t||2!==t.length&&3!==t.length)throw new Error("Conv requires 2 or 3 inputs");if(4!==t[0].dims.length&&3!==t[0].dims.length)throw new Error("currently only support 2-dimensional conv");if(t[0].dims.length!==t[1].dims.length)throw new Error("filter does not have same dimension as input");if(t[0].dims["NHWC"===e.format?t[0].dims.length-1:1]!==t[1].dims[0])throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let n=t[1].dims[1]*e.group;if(3===t.length&&(1!==t[2].dims.length||t[2].dims[0]!==n))throw new Error("invalid bias");let i=t[0].dims.length-2;if(e.dilations.reduce(((t,e)=>t+e),0)>0&&e.dilations.length!==i)throw new Error(`dilations should be ${i}D`);if(e.strides.reduce(((t,e)=>t+e),0)>0&&e.strides.length!==i)throw new Error(`strides should be ${i}D`);if(e.pads.reduce(((t,e)=>t+e),0)>0&&e.pads.length!==2*i)throw new Error(`pads should be ${2*i}D`);if(e.outputPadding.length!==i&&0!==e.outputPadding.length)throw new Error(`output_padding should be ${i}D`);if(e.kernelShape.reduce(((t,e)=>t+e),0)>0&&0!==e.kernelShape.length&&e.kernelShape.length!==t[1].dims.length-2)throw new Error("invalid kernel shape");if(0!==e.outputShape.length&&e.outputShape.length!==t[0].dims.length-2)throw new Error("invalid output shape")},gs=[2,3,1,0],bs=(t,e,n)=>{let i=ys(n,e),r="NHWC"===n.format,s=i.outputShape,o=s[r?3:1],a=e[0].dims[r?3:1];if(1!==i.group||1===o&&1===a)return void t.compute(fs(e,i));let u=s[r?1:2],h=s[r?2:3],l=r?u*h:o,c=r?o:u*h,f=e[1].dims[2]*e[1].dims[3]*a,d=t.kernelCustomData.wT??t.compute(Xe(e[1],gs),{inputs:[1],outputs:[n.wIsConst?-2:-1]})[0];n.wIsConst&&!t.kernelCustomData.wT&&(t.kernelCustomData.wT=d);let p=[e[0],d],v=3===e.length;v&&(r||1!==e[2].dims.length?p.push(e[2]):p.push(e[2].reshape([e[2].dims[0],1,1]))),t.compute(ls(p,i,s,l,c,f,v,!0),{inputs:p})},xs=(t,e)=>{let n="NHWC"===e.format,i=[t.inputs[0].reshape(n?[t.inputs[0].dims[0],1,t.inputs[0].dims[1],t.inputs[0].dims[2]]:[t.inputs[0].dims[0],t.inputs[0].dims[1],1,t.inputs[0].dims[2]]),t.inputs[1].reshape([t.inputs[1].dims[0],t.inputs[1].dims[1],1,t.inputs[1].dims[2]])];3===t.inputs.length&&i.push(t.inputs[2]);let r=e.kernelShape;(0===r.length||0===r[0])&&(r=[t.inputs[1].dims[2]]);let s=e.dilations;(0===s.length||0===s[0])&&(s=[1]);let o=e.strides;(0===o.length||0===o[0])&&(o=[1]);let a=e.pads;0===a.length&&(a=[0,0]),a=[0,a[0],0,a[1]],o=[1].concat(o),s=[1].concat(s),r=[1].concat(r);let u=ys({...e,pads:a,strides:o,dilations:s,kernelShape:r},i);t.compute(fs(i,u,(t=>n?[t[0],t[2],t[3]]:[t[0],t[1],t[3]])))},_s=(t,e)=>{ws(t.inputs,e),3===t.inputs[0].dims.length?xs(t,e):bs(t,t.inputs,e)}})),Xu=V((()=>{wu(),Su(),$u(),Mu(),ks=(t,e,n,i)=>{let r=$e.size(e),s=e.length,o=qe("input",t,s),a=je("output",t,s),u=6===n.dataType?n.getInt32Array()[0]:Number(n.getBigInt64Array()[0]),h=$e.normalizeAxis(u,s);return{name:"CumSum",shaderCache:{hint:i.cacheKey,inputDependencies:["rank"]},getRunData:()=>({outputs:[{dims:e,dataType:t}],dispatchGroup:{x:Math.ceil(r/64)},programUniforms:[{type:12,data:r},{type:12,data:h},...ze(e,e)]}),getShaderSource:t=>{let e=` i32(${o.indicesGet("inputIndices","uniforms.axis")}) `,n=Fe("uniforms.input_shape","uniforms.axis",s),r=i.reverse?e+(i.exclusive?" + 1":""):"0",u=i.reverse?n:e+(i.exclusive?"":" + 1");return`\n ${t.registerUniform("outputSize","u32").registerUniform("axis","u32").declareVariables(o,a)}\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}\n var inputIndices = ${a.offsetToIndices("global_idx")};\n var sum = ${a.type.value}(0);\n let first : i32 = ${r};\n let last : i32 = ${u};\n for (var i : i32 = first; i < last; i++) {\n ${o.indicesSet("inputIndices","uniforms.axis","u32(i)")};\n sum = sum + ${o.getByIndices("inputIndices")};\n }\n ${a.setByOffset("global_idx","sum")};\n }`}}},$s=(t,e)=>{let n=t.inputs[0].dims,i=t.inputs[0].dataType,r=t.inputs[1];t.compute(ks(i,n,r,e),{inputs:[0]})},Ss=t=>{let e=1===t.exclusive,n=1===t.reverse;return xe({exclusive:e,reverse:n})}})),Zu=V((()=>{wu(),Su(),$u(),Mu(),Ms=t=>{if(!t||1!==t.length)throw new Error("DepthToSpace requires 1 input.");if(4!==t[0].dims.length)throw new Error("DepthToSpace requires 4D input.")},Es=(t,e,n,i)=>{let r=[];r.push(`fn perm(i: ${i.type.indices}) -> ${n.type.indices} {\n var a: ${n.type.indices};`);for(let i=0;i<e;++i)r.push(n.indicesSet("a",t[i],`i[${i}]`));return r.push("return a;}"),r.join("\n")},Cs=(t,e)=>{let n,i,r,s,o,a,u="NHWC"===e.format,h=e.blocksize,l="DCR"===e.mode;u?([n,i,r,s]=t.dims,o=l?[n,i,r,h,h,s/h**2]:[n,i,r,s/h**2,h,h],a=l?[0,1,3,2,4,5]:[0,1,4,2,5,3]):([n,i,r,s]=[t.dims[0],t.dims[2],t.dims[3],t.dims[1]],o=l?[n,h,h,s/h**2,i,r]:[n,s/h**2,h,h,i,r],a=l?[0,3,4,1,5,2]:[0,1,4,2,5,3]);let c=t.reshape(o),f=c.dims.length,d=t.dataType,p=qe("a",d,f),v=je("output",d,f);return{name:"DepthToSpace",shaderCache:{hint:`${t.dims};${e.blocksize};${e.mode}`,inputDependencies:["rank"]},getRunData:t=>{let e=u?[n,i*h,r*h,s/h**2]:[n,s/h**2,i*h,r*h],o=$e.size(e),l=c.dims,f=$e.sortBasedOnPerm(l,a);return{outputs:[{dims:e,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(o/64)},programUniforms:[{type:12,data:o},...ze(l,f)]}},getShaderSource:t=>`\n ${t.registerUniform("output_size","u32").declareVariables(p,v)}\n\n ${Es(a,f,p,v)}\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n\n let indices = ${v.offsetToIndices("global_idx")};\n let aIndices = perm(indices);\n\n ${v.setByOffset("global_idx",p.getByIndices("aIndices"))}\n }`}},As=(t,e)=>{Ms(t.inputs),t.compute(Cs(t.inputs[0],e))},Is=t=>xe({blocksize:t.blocksize,mode:t.mode,format:t.format})})),Yu=V((()=>{wu(),Su(),$u(),Mu(),zs="^"+(Ts="("+(Os="[a-zA-Z]|\\.\\.\\.")+")+")+"$",Ds="^("+Ts+",)*"+Ts+"$",Ps=class{constructor(t=-1){this.symbolToIndices=new Map,this.inputIndex=t}addSymbol(t,e){let n=this.symbolToIndices.get(t);void 0===n?n=[e]:n.push(e),this.symbolToIndices.set(t,n)}},Rs=class{constructor(t,e){this.equation=e,this.hasEllipsis=!1,this.symbolToInfo=new Map,this.lhs=new Array,this.outputDims=[];let[n,i]=e.includes("->")?e.split("->",2):[e,""];if(!n.match(RegExp(Ds)))throw new Error("Invalid LHS term");if(n.split(",").forEach(((e,n)=>{let i=t[n].dims.slice();if(!e.match(RegExp(zs)))throw new Error("Invalid LHS term");let r=this.processTerm(e,!0,i,n);this.lhs.push(r)})),""===i)i+=[...this.symbolToInfo.entries()].filter((([t,e])=>1===e.count||"..."===t)).map((([t])=>t)).join("");else if(!i.match(RegExp(Ts)))throw new Error("Invalid RHS");i.match(RegExp(Os,"g"))?.forEach((t=>{if("..."===t)this.outputDims=this.outputDims.concat(this.ellipsisDims);else{let e=this.symbolToInfo.get(t);if(void 0===e)throw new Error("Invalid RHS symbol");this.outputDims.push(e.dimValue)}})),this.rhs=this.processTerm(i,!1,this.outputDims)}addSymbol(t,e,n){let i=this.symbolToInfo.get(t);if(void 0!==i){if(i.dimValue!==e&&1!==i.count)throw new Error("Dimension mismatch");i.count++,i.inputIndices.push(n)}else i={count:1,dimValue:e,inputIndices:[n]};this.symbolToInfo.set(t,i)}processTerm(t,e,n,i=-1){let r=n.length,s=!1,o=[],a=0;if(!t.match(RegExp(zs))&&!e&&""!==t)throw new Error("Invalid LHS term");let u=t.match(RegExp(Os,"g")),h=new Ps(i);return u?.forEach(((t,l)=>{if("..."===t){if(s)throw new Error("Only one ellipsis is allowed per input term");s=!0;let t=r-u.length+1;if(t<0)throw new Error("Ellipsis out of bounds");if(o=n.slice(a,a+t),this.hasEllipsis){if(this.ellipsisDims.length!==o.length||this.ellipsisDims.toString()!==o.toString())throw new Error("Ellipsis dimensions mismatch")}else{if(!e)throw new Error("Ellipsis must be specified in the LHS");this.hasEllipsis=!0,this.ellipsisDims=o}for(let t=0;t<o.length;t++){let e=String.fromCharCode("0".charCodeAt(0)+t);h.addSymbol(e,l+t),this.addSymbol(e,n[a++],i)}}else h.addSymbol(t,l+(this.hasEllipsis?this.ellipsisDims.length-1:0)),this.addSymbol(t,n[a++],i)})),h}},Ns=t=>t+"_max",Fs=(t,e,n,i)=>{let r=t.map((t=>t.length)).map(((t,n)=>qe(`input${n}`,e,t))),s=$e.size(i),o=je("output",e,i.length),a=[...n.symbolToInfo.keys()].filter((t=>!n.rhs.symbolToIndices.has(t)));return{name:"Einsum",shaderCache:{hint:n.equation,inputDependencies:t.map((()=>"rank"))},getRunData:()=>{let r=a.filter((t=>n.symbolToInfo.has(t))).map((t=>({type:12,data:n.symbolToInfo.get(t)?.dimValue||0})));r.push({type:12,data:s});let o=t.map(((t,e)=>[...ze(t)])).reduce(((t,e)=>t.concat(e)),r);return o.push(...ze(i)),{outputs:[{dims:i,dataType:e}],dispatchGroup:{x:Math.ceil(s/64)},programUniforms:o}},getShaderSource:t=>{let e=[],i=[],s=[],u=[],h=[],l=n.symbolToInfo.size===n.rhs.symbolToIndices.size;n.symbolToInfo.forEach(((t,a)=>{if(n.rhs.symbolToIndices.has(a)){let i=n.rhs.symbolToIndices.get(a)?.[0];void 0!==i&&n.lhs.forEach(((n,s)=>{if(t.inputIndices.includes(s)){let t=n.symbolToIndices.get(a);if(void 0===t)throw new Error("Invalid symbol error");t.forEach((t=>{e.push(`${r[s].indicesSet(`input${s}Indices`,t,o.indicesGet("outputIndices",i))}`)}))}}))}else n.lhs.forEach(((e,n)=>{if(t.inputIndices.includes(n)){let t=e.symbolToIndices.get(a);if(void 0===t)throw new Error("Invalid symbol error");t.forEach((t=>{i.push(`${r[n].indicesSet(`input${n}Indices`,t,`${a}`)}`)})),h.push(`prod *= ${r[n].getByIndices(`input${n}Indices`)};`)}})),s.push(`for(var ${a}: u32 = 0; ${a} < uniforms.${Ns(a)}; ${a}++) {`),u.push("}")}));let c=l?[...e,`let sum = ${r.map(((t,e)=>t.getByIndices(`input${e}Indices`))).join(" * ")};`]:[...e,"var sum = 0.0;",...s,...i,"var prod = 1.0;",...h,"sum += prod;",...u];return`\n ${t.registerUniforms(a.map((t=>({name:`${Ns(t)}`,type:"u32"})))).registerUniform("outputSize","u32").declareVariables(...r,o)}\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}\n var outputIndices = ${o.offsetToIndices("global_idx")};\n ${r.map(((t,e)=>`var input${e}Indices: ${r[e].type.indices};`)).join("\n")}\n ${c.join("\n")};\n ${o.setByOffset("global_idx","sum")};\n }`}}},Us=(t,e)=>{let n=new Rs(t.inputs,e.equation),i=n.outputDims,r=t.inputs.map(((t,e)=>t.dims));t.compute(Fs(r,t.inputs[0].dataType,n,i))},qs=t=>{let e=t.equation.replace(/\s+/g,"");return xe({equation:e})}})),Ju=V((()=>{wu(),Su(),Mu(),js=t=>{if(!t||2!==t.length)throw new Error("Expand requires 2 input.");let e=t[0].dims,n=Array.from(t[1].getBigInt64Array(),Number),i=n.length<e.length?0:n.length-e.length,r=e.length<n.length?0:e.length-n.length;for(;i<n.length&&r<e.length;++i,++r)if(n[i]!==e[r]&&1!==n[i]&&1!==e[r])throw new Error("Expand requires shape to be broadcastable to input")},Bs=(t,e)=>{let n=t.length-e.length,i=[];for(let e=0;e<n;++e)i.push(t[e]);for(let r=0;r<e.length;++r)i.push(1===e[r]?t[r+n]:e[r]);return i},Ls=(t,e)=>t.length>e.length?Bs(t,e):Bs(e,t),Hs=t=>{let e=t[0].dims,n=Array.from(t[1].getBigInt64Array(),Number),i=Ls(e,n),r=t[0].dataType,s=9===r?4:1,o=Math.ceil($e.size(i)/s),a=[{type:12,data:o},...ze(e,i)];return{name:"Expand",shaderCache:{hint:`${i.length}`,inputDependencies:["rank"]},getShaderSource:t=>{let n,o=qe("input",r,e.length,s),a=je("output",r,i.length,s);if(9===r){let t=(t,e,n="")=>`\n let outputIndices${e} = ${a.offsetToIndices(`outputOffset + ${e}u`)};\n let offset${e} = ${o.broadcastedIndicesToOffset(`outputIndices${e}`,a)};\n let index${e} = offset${e} / 4u;\n let component${e} = offset${e} % 4u;\n ${t}[${e}] = ${n}(${o.getByOffset(`index${e}`)}[component${e}]);\n `;n=`\n let outputOffset = global_idx * ${s};\n var data = vec4<u32>(0);\n ${t("data",0,"u32")}\n ${t("data",1,"u32")}\n ${t("data",2,"u32")}\n ${t("data",3,"u32")}\n ${a.setByOffset("global_idx","data")}\n }`}else n=`\n let outputIndices = ${a.offsetToIndices("global_idx")};\n let inputOffset = ${o.broadcastedIndicesToOffset("outputIndices",a)};\n ${a.setByOffset("global_idx",o.getByOffset("inputOffset"))}\n }`;return`\n ${t.registerUniform("vec_size","u32").declareVariables(o,a)}\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.vec_size")}\n ${n}`},getRunData:()=>({outputs:[{dims:i,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(o/64)},programUniforms:a})}},Vs=t=>{js(t.inputs),t.compute(Hs(t.inputs),{inputs:[0]})}})),th=V((()=>{wu(),Su(),Mu(),Du(),Ws=t=>{let e=t[0].dataType,n=$e.size(t[0].dims),i=$e.size(t[1].dims),r=i%4==0;return{name:"FastGeluWithBias",shaderCache:{hint:`${r}`,inputDependencies:["type","type"]},getShaderSource:t=>{let n=qe("x",e,[1],4),i=qe("bias",e,[1],4),s=je("y",e,[1],4),o=t=>`\n let bias${t}_offset: u32 = (global_idx * 4 + ${t}) % uniforms.bias_size;\n let bias${t} = ${i.getByOffset(`bias${t}_offset / 4`)}[bias${t}_offset % 4];`,a=r?`\n let bias = ${i.getByOffset("global_idx % (uniforms.bias_size / 4)")};`:`${o(0)}${o(1)}${o(2)}${o(3)}\n let bias = ${n.type.value}(bias0, bias1, bias2, bias3);`;return`${t.registerUniforms([{name:"output_vec_size",type:"u32"},{name:"bias_size",type:"u32"}]).declareVariables(n,i,s)}\n\n ${Qi(Te(e))}\n\n ${t.mainStart(Ae)}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_vec_size")}\n\n let x = ${n.getByOffset("global_idx")};\n ${a}\n let x_in = x + bias;\n ${s.setByOffset("global_idx",Ki("x_in"))}\n }`},getRunData:t=>({outputs:[{dims:t[0].dims,dataType:t[0].dataType}],programUniforms:[{type:12,data:Math.ceil(n/4)},{type:12,data:i}],dispatchGroup:{x:Math.ceil(n/Ae/4)}})}},Gs=t=>{t.inputs.length<2||0===$e.size(t.inputs[1].dims)?Xi(t):t.compute(Ws(t.inputs))}})),eh=V((()=>{wu(),Su(),$u(),Mu(),Qs=t=>{if(!t||2!==t.length)throw new Error("Gather requires 2 inputs.")},Ks=(t,e)=>{let n=t[0].dims,i=t[1].dims,r=n.length,s=$e.normalizeAxis(e.axis,r),o=n.slice(0);o.splice(s,1,...i);let a=n[s],u=9===t[0].dataType?4:1,h=Math.ceil($e.size(o)/u),l=[{type:12,data:h},{type:6,data:a},{type:12,data:s},...ze(t[0].dims,t[1].dims,o)];return{name:"Gather",shaderCache:{hint:e.cacheKey,inputDependencies:["rank","rank"]},getRunData:()=>({outputs:[{dims:o,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(h/64)},programUniforms:l}),getShaderSource:e=>{let n,a=qe("data",t[0].dataType,t[0].dims.length,u),h=qe("inputIndices",t[1].dataType,t[1].dims.length),l=je("output",t[0].dataType,o.length,u),c=t=>{let e=i.length,n=`var indicesIndices${t} = ${h.type.indices}(0);`;for(let i=0;i<e;i++)n+=`${e>1?`indicesIndices${t}[${i}]`:`indicesIndices${t}`} = ${o.length>1?`outputIndices${t}[uniforms.axis + ${i}]`:`outputIndices${t}`};`;n+=`\n var idx${t} = ${h.getByIndices(`indicesIndices${t}`)};\n if (idx${t} < 0) {\n idx${t} = idx${t} + uniforms.axisDimLimit;\n }\n var dataIndices${t} : ${a.type.indices};\n `;for(let i=0,a=0;i<r;i++)i===s?(n+=`${r>1?`dataIndices${t}[${i}]`:`dataIndices${t}`} = u32(idx${t});`,a+=e):(n+=`${r>1?`dataIndices${t}[${i}]`:`dataIndices${t}`} = ${o.length>1?`outputIndices${t}[${a}]`:`outputIndices${t}`};`,a++);return n};if(9===t[0].dataType){let t=(t,e,n="")=>`\n let outputIndices${e} = ${l.offsetToIndices(`outputOffset + ${e}u`)};\n ${c(e)};\n let offset${e} = ${a.indicesToOffset(`dataIndices${e}`)};\n let index${e} = offset${e} / 4u;\n let component${e} = offset${e} % 4u;\n ${t}[${e}] = ${n}(${a.getByOffset(`index${e}`)}[component${e}]);\n `;n=`\n let outputOffset = global_idx * ${u};\n var value = vec4<u32>(0);\n ${t("value",0,"u32")}\n ${t("value",1,"u32")}\n ${t("value",2,"u32")}\n ${t("value",3,"u32")}\n ${l.setByOffset("global_idx","value")}\n `}else n=`\n let outputIndices = ${l.offsetToIndices("global_idx")};\n ${c("")};\n let value = ${a.getByIndices("dataIndices")};\n ${l.setByOffset("global_idx","value")};\n `;return`\n ${e.registerUniform("outputSize","u32").registerUniform("axisDimLimit","i32").registerUniform("axis","u32").declareVariables(a,h,l)}\n ${e.mainStart()}\n ${e.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}\n ${n}\n }`}}},Xs=t=>xe({axis:t.axis}),Zs=(t,e)=>{let n=t.inputs;Qs(n),t.compute(Ks(t.inputs,e))}})),nh=V((()=>{wu(),Su(),$u(),Mu(),Ys=t=>{if(!t||2!==t.length)throw new Error("GatherElements requires 2 inputs.");if(t[0].dims.length<1)throw new Error("GatherElements requires that the data input be rank >= 1.");if(t[0].dims.length!==t[1].dims.length)throw new Error("GatherElements requires that the data input and\n indices input tensors be of same rank.")},Js=(t,e)=>{let n=t[0].dims,i=t[0].dataType,r=n.length,s=t[1].dims,o=t[1].dataType,a=$e.normalizeAxis(e.axis,r),u=n[a],h=s.slice(0),l=$e.size(h),c=qe("input",i,r),f=qe("indicesInput",o,s.length),d=je("output",i,h.length),p=[{type:12,data:l},{type:6,data:u},{type:12,data:a}];return p.push(...ze(n,s,h)),{name:"GatherElements",shaderCache:{inputDependencies:["rank","rank"]},getRunData:()=>({outputs:[{dims:h,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(l/64)},programUniforms:p}),getShaderSource:t=>`\n ${t.registerUniform("outputSize","u32").registerUniform("axisDimLimit","i32").registerUniform("axis","u32").declareVariables(c,f,d)}\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}\n\n let outputIndices = ${d.offsetToIndices("global_idx")};\n\n var idx = ${f.getByOffset("global_idx")};\n if (idx < 0) {\n idx = idx + uniforms.axisDimLimit;\n }\n var inputIndices = ${c.type.indices}(outputIndices);\n ${c.indicesSet("inputIndices","uniforms.axis","u32(idx)")};\n let value = ${c.getByIndices("inputIndices")};\n\n ${d.setByOffset("global_idx","value")};\n }`}},to=t=>xe({axis:t.axis}),eo=(t,e)=>{let n=t.inputs;Ys(n),t.compute(Js(t.inputs,e))}})),ih=V((()=>{wu(),Su(),Mu(),no=t=>{if(!t)throw new Error("Input is missing");if(t.length<2||t.length>3)throw new Error("Invaid input number.");if(3===t.length&&t[2].dims.length>2)throw new Error("Invalid input shape of C");if(t[0].dataType!==t[1].dataType||3===t.length&&t[0].dataType!==t[2].dataType)throw new Error("Input types are mismatched")},io=(t,e)=>{let n=t[0].dims.slice(),i=t[1].dims.slice(),[r,s,o]=Me.getShapeOfGemmResult(n,e.transA,i,e.transB,3===t.length?t[2].dims:void 0),a=[r,s];if(!a)throw new Error("Can't use gemm on the given tensors");let u=$e.size(a),h=[{type:12,data:u},{type:12,data:r},{type:12,data:s},{type:12,data:o},{type:1,data:e.alpha},{type:1,data:e.beta}],l=["type","type"];return 3===t.length&&(h.push(...ze(t[2].dims)),l.push("rank")),h.push(...ze(a)),{name:"Gemm",shaderCache:{hint:`${e.cacheKey}`,inputDependencies:l},getRunData:()=>({outputs:[{dims:a,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(u/64)},programUniforms:h}),getShaderSource:n=>{let i="";e.transA&&e.transB?i="value += a[k * uniforms.M + m] * b[n * uniforms.K + k];":e.transA&&!e.transB?i="value += a[k * uniforms.M + m] * b[k * uniforms.N + n];":!e.transA&&e.transB?i="value += a[m * uniforms.K + k] * b[n * uniforms.K + k];":!e.transA&&!e.transB&&(i="value += a[m * uniforms.K + k] * b[k * uniforms.N + n];");let r=1===e.alpha?"":"value *= uniforms.alpha;",s=qe("a",t[0].dataType,t[0].dims),o=qe("b",t[1].dataType,t[1].dims),u=s.type.value,h=null,l=[s,o];3===t.length&&(h=qe("c",t[2].dataType,t[2].dims.length),l.push(h));let c=je("output",t[0].dataType,a.length);return l.push(c),`\n ${n.registerUniforms([{name:"output_size",type:"u32"},{name:"M",type:"u32"},{name:"N",type:"u32"},{name:"K",type:"u32"},{name:"alpha",type:"f32"},{name:"beta",type:"f32"}]).declareVariables(...l)}\n\n ${n.mainStart()}\n ${n.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n\n let m = global_idx / uniforms.N;\n let n = global_idx % uniforms.N;\n\n var value = ${u}(0);\n for (var k: u32 = 0u; k < uniforms.K; k++) {\n ${i}\n }\n\n ${r}\n ${null!=h?`let cOffset = ${h.broadcastedIndicesToOffset("vec2(m, n)",c)}; value += ${u}(uniforms.beta) * ${h.getByOffset("cOffset")};`:""}\n output[global_idx] = value;\n }`}}},ro=t=>({transA:t.transA,transB:t.transB,alpha:t.alpha,beta:t.beta,cacheKey:`${t.transA};${t.transB};${1===t.alpha}`}),so=(t,e)=>{no(t.inputs),t.compute(io(t.inputs,e))}})),rh=V((()=>{wu(),Su(),$u(),_u(),Ou(),Mu(),Eu(),oo=(t,e)=>t.length>e&&t[e].dims.length>0&&$e.size(t[e].dims)>0?t[e]:void 0,ao=(t,e)=>{let n=t[0],i=oo(t,1),r=oo(t,2),s=oo(t,3),o=oo(t,4),a=oo(t,5),u=oo(t,6),h=oo(t,7);if(3!==n.dims.length&&5!==n.dims.length)throw new Error("Input query is expected to have 3 or 5 dimensions");let l,c=n.dims[0],f=n.dims[1],d=3===n.dims.length?n.dims[2]:e.numHeads*n.dims[4],p=f,v=0,y=0,m=Math.floor(d/e.numHeads);if(u&&h){if(4!==u.dims.length)throw new Error('Input "past_key" is expected to have 4 dimensions');if(u.dims[0]!==c||u.dims[1]!==e.numHeads||u.dims[3]!==m)throw new Error('Input "past_key" shape (batch_size, num_heads, past_sequence_length, head_size)');if(h.dims[0]!==c||h.dims[1]!==e.numHeads||h.dims[3]!==m)throw new Error('Input "past_value" shape (batch_size, num_heads, past_sequence_length, head_size)');if(u.dims[2]!==h.dims[2])throw new Error('Input "past_key" and "past_value" shall have same dim 2 (past_sequence_length)');if(4!==h.dims.length)throw new Error('Input "past_value" is expected to have 4 dimensions');v=u.dims[2],y=u.dims[2]}else if(u||h)throw new Error('Input "past_key" and "past_value" shall be both present or both absent');if(i){if(3!==n.dims.length)throw new Error('Input "query" is expected to have 3 dimensions when key is given');if(i.dims.length<3||i.dims.length>5)throw new Error('Input "key" is expected to have 3, 4, or 5 dimensions');if(n.dims[0]!==i.dims[0])throw new Error('Input "query" and "key" shall have same dim 0 (batch size)');if(3===i.dims.length){if(i.dims[2]!==n.dims[2])throw new Error('Input "query" and "key" shall have same dim 2 (hidden_size)');l=2,p=i.dims[1]}else if(5===i.dims.length){if(i.dims[2]!==e.numHeads||2!==i.dims[3]||i.dims[4]!==m)throw new Error('Expect "key" shape (batch_size, kv_sequence_length, num_heads, 2, head_size) for packed kv');if(r)throw new Error('Expect "value" be none when "key" has packed kv format.');l=5,p=i.dims[1]}else{if(i.dims[1]!==e.numHeads||i.dims[3]!==m)throw new Error('Expect "key" shape (batch_size, num_heads, kv_sequence_length, head_size) for past_key');l=0,p=i.dims[2]}}else{if(3!==n.dims.length&&5!==n.dims.length)throw new Error('Input "query" is expected to have 3 or 5 dimensions when key is empty');if(5===n.dims.length&&(n.dims[2]!==e.numHeads||3!==n.dims[3]))throw new Error('Expect "query" shape (batch_size, kv_sequence_length, num_heads, 3, head_size) for packed kv');l=3}if(s){if(1!==s.dims.length)throw new Error('Input "bias" is expected to have 1 dimension');if(r&&5===n.dims.length&&2===n.dims[3])throw new Error("bias is not allowed for packed kv.")}let w=0;if(o){w=8;let t=o.dims;throw 1===t.length?t[0]===c?w=1:t[0]===3*c+2&&(w=3):2===t.length&&t[0]===c&&t[1]===p&&(w=5),8===w?new Error('Input "key_padding_mask" shape shall be (batch_size) or (batch_size, kv_sequence_length)'):new Error("Mask not supported")}let g=!1,b=d;if(r){if(3!==r.dims.length&&4!==r.dims.length)throw new Error('Input "value" is expected to have 3 or 4 dimensions');if(n.dims[0]!==r.dims[0])throw new Error('Input "query" and "value" shall have same dim 0 (batch_size)');if(3===r.dims.length){if(p!==r.dims[1])throw new Error('Input "key" and "value" shall have the same dim 1 (kv_sequence_length)');b=r.dims[2]}else{if(p!==r.dims[2])throw new Error('Input "past_key" and "past_value" shall have the same dim 2 (kv_sequence_length)');b=r.dims[1]*r.dims[3],g=!0}}let x=v+p;if(o)throw new Error("Key padding mask is not supported");if(a){if(4!==a.dims.length)throw new Error('Input "relative_position_bias" is expected to have 4 dimensions');if(a.dims[0]!==c&&1!==a.dims[0]||a.dims[1]!==e.numHeads||a.dims[2]!==f||a.dims[3]!==x)throw new Error('Input "relative_position_bias" shape (batch_size, 1, sequence_length, kv_sequence_length)')}return{batchSize:c,sequenceLength:f,pastSequenceLength:v,kvSequenceLength:p,totalSequenceLength:x,maxSequenceLength:y,inputHiddenSize:0,hiddenSize:d,vHiddenSize:b,headSize:m,vHeadSize:Math.floor(b/e.numHeads),numHeads:e.numHeads,isUnidirectional:!1,pastPresentShareBuffer:!1,maskFilterValue:e.maskFilterValue,maskType:w,scale:e.scale,broadcastResPosBias:!1,passPastInKv:g,qkvFormat:l}},uo=t=>xe({...t}),ho=xe({perm:[0,2,1,3]}),lo=(t,e,n,i,r,s,o)=>{let a=[i,r,s],u=$e.size(a),h=[{type:12,data:u},{type:12,data:o},{type:12,data:s}];return t.compute({name:"MultiHeadAttentionAddBias",shaderCache:{inputDependencies:["type","type"]},getRunData:()=>({outputs:[{dims:a,dataType:e.dataType,gpuDataType:0}],dispatchGroup:{x:Math.ceil(u/64)},programUniforms:h}),getShaderSource:t=>{let i=je("qkv_with_bias",e.dataType,a),r=qe("qkv",e.dataType,a),s=qe("bias",n.dataType,a);return`\n ${t.registerUniforms([{name:"output_size",type:"u32"},{name:"bias_offset",type:"u32"},{name:"hidden_size",type:"u32"}]).declareVariables(r,s,i)}\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n let bias_offset_idx = (global_idx % uniforms.hidden_size) + uniforms.bias_offset;\n\n qkv_with_bias[global_idx] = qkv[global_idx] + bias[bias_offset_idx];\n }`}},{inputs:[e,n],outputs:[-1]})[0]},co=(t,e,n,i,r,s,o,a)=>{let u=s;if(o){if(1===i)throw new Error("AddBiasReshape is not implemented. Please export your model with packed QKV or KV");return u=lo(t,s,o,e,i,n*r,a),u=u.reshape([e,i,n,r]),t.compute(Xe(u,ho.perm),{inputs:[u],outputs:[-1]})[0]}return 3===s.dims.length&&(u=s.reshape([e,i,n,r])),t.compute(Xe(u,ho.perm),{inputs:[u],outputs:[-1]})[0]},fo=(t,e)=>{let n=ao(t.inputs,e),i=t.inputs[0],r=oo(t.inputs,1),s=oo(t.inputs,2),o=oo(t.inputs,3),a=oo(t.inputs,4),u=oo(t.inputs,5),h=oo(t.inputs,6),l=oo(t.inputs,7);if(5===i.dims.length)throw new Error("Packed QKV is not implemented");if(5===r?.dims.length)throw new Error("Packed KV is not implemented");let c=r&&s&&4===r.dims.length&&4===s.dims.length,f=co(t,n.batchSize,n.numHeads,n.sequenceLength,n.headSize,i,o,0);if(c)return ei(t,f,r,s,a,void 0,h,l,u,n,e);if(!r||!s)throw new Error("key and value must be provided");let d=co(t,n.batchSize,n.numHeads,n.kvSequenceLength,n.headSize,r,o,n.hiddenSize),p=co(t,n.batchSize,n.numHeads,n.kvSequenceLength,n.vHeadSize,s,o,2*n.hiddenSize);ei(t,f,d,p,a,void 0,h,l,u,n,e)}})),sh=V((()=>{wu(),Su(),Mu(),po=t=>Array.from(t.getBigInt64Array(),Number),vo=t=>{if(!t||2!==t.length)throw new Error("Tile requires 2 inputs.");if(1!==t[0].dataType&&10!==t[0].dataType&&6!==t[0].dataType&&12!==t[0].dataType)throw new Error("Tile only support float, float16, int32, and uint32 data types");if(7!==t[1].dataType)throw new Error("Tile `repeats` input should be of int64 data type");if(1!==t[1].dims.length)throw new Error("Tile `repeats` input should be 1-D");if(po(t[1]).length!==t[0].dims.length)throw new Error("Tile `repeats` input should have same number of elements as rank of input data tensor")},yo=(t,e)=>{let n=[];for(let i=0;i<t.length;++i)n.push(t[i]*e[i]);return n},mo=(t,e)=>{let n=t[0].dims,i=e??po(t[1]),r=yo(n,i),s=$e.size(r),o=t[0].dataType,a=qe("input",o,n.length),u=je("output",o,r.length);return{name:"Tile",shaderCache:{hint:`${i}`,inputDependencies:["rank"]},getRunData:()=>({outputs:[{dims:r,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil(s/64)},programUniforms:[{type:12,data:s},...ze(t[0].dims,r)]}),getShaderSource:t=>`\n const inputShape = ${a.indices(...n)};\n ${t.registerUniform("output_size","u32").declareVariables(a,u)}\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n let output_indices = ${u.offsetToIndices("global_idx")};\n var input_indices: ${a.type.indices};\n for (var i = 0; i < ${n.length}; i++) {\n let input_dim_i = ${a.indicesGet("uniforms.input_shape","i")};\n let input_dim_value = ${u.indicesGet("output_indices","i")} % input_dim_i;\n\n ${a.indicesSet("input_indices","i","input_dim_value")}\n }\n ${u.setByOffset("global_idx",a.getByIndices("input_indices"))}\n }`}},wo=t=>{vo(t.inputs),t.compute(mo(t.inputs),{inputs:[0]})}})),oh=V((()=>{wu(),Su(),$u(),Ou(),Mu(),rh(),sh(),Eu(),go=(t,e)=>{let n=t[0],i=t[1],r=t[2],s=t[3],o=t[4];if(3!==n.dims.length&&5!==n.dims.length)throw new Error("Input query is expected to have 3 or 5 dimensions");let a,u=n.dims[0],h=n.dims[1],l=3===n.dims.length?n.dims[2]:e.numHeads*n.dims[4],c=h,f=0,d=0,p=Math.floor(l/e.numHeads),v=s&&0!==s.dims.length,y=o&&0!==o.dims.length;if(v&&y){if(4!==s.dims.length)throw new Error('Input "past_key" is expected to have 4 dimensions');if(4!==o.dims.length)throw new Error('Input "past_value" is expected to have 4 dimensions');f=s.dims[1],d=s.dims[1]}else if(v||y)throw new Error('Input "past_key" and "past_value" shall be both present or both absent');if(i){if(3!==n.dims.length)throw new Error('Input "query" is expected to have 3 dimensions when key is given');if(i.dims.length<3||i.dims.length>5)throw new Error('Input "key" is expected to have 3, 4, or 5 dimensions');if(n.dims[0]!==i.dims[0])throw new Error('Input "query" and "key" shall have same dim 0 (batch size)');if(3===i.dims.length){if(n.dims[2]%i.dims[2]!=0)throw new Error('Dimension 2 of "query" should be a multiple of "key"');a=2,c=i.dims[1]}else if(5===i.dims.length){if(i.dims[2]!==e.numHeads||2!==i.dims[3]||i.dims[4]!==p)throw new Error('Expect "key" shape (batch_size, kv_sequence_length, num_heads, 2, head_size) for packed kv');if(r)throw new Error('Expect "value" be none when "key" has packed kv format.');a=5,c=i.dims[1]}else{if(i.dims[1]!==e.numHeads||i.dims[3]!==p)throw new Error('Expect "key" shape (batch_size, num_heads, kv_sequence_length, head_size) for past_key');a=0,c=i.dims[2]}}else{if(3!==n.dims.length&&5!==n.dims.length)throw new Error('Input "query" is expected to have 3 or 5 dimensions when key is empty');if(5===n.dims.length&&(n.dims[2]!==e.numHeads||3!==n.dims[3]))throw new Error('Expect "query" shape (batch_size, kv_sequence_length, num_heads, 3, head_size) for packed kv');a=3}let m=!1,w=l;if(r){if(3!==r.dims.length&&4!==r.dims.length)throw new Error('Input "value" is expected to have 3 or 4 dimensions');if(n.dims[0]!==r.dims[0])throw new Error('Input "query" and "value" shall have same dim 0 (batch_size)');if(3===r.dims.length){if(c!==r.dims[1])throw new Error('Input "key" and "value" shall have the same dim 1 (kv_sequence_length)');w=r.dims[2]}else{if(c!==r.dims[2])throw new Error('Input "past_key" and "past_value" shall have the same dim 2 (kv_sequence_length)');w=r.dims[1]*r.dims[3],m=!0}}return{batchSize:u,sequenceLength:h,pastSequenceLength:f,kvSequenceLength:c,totalSequenceLength:f+c,maxSequenceLength:d,inputHiddenSize:0,hiddenSize:l,vHiddenSize:w,headSize:p,vHeadSize:Math.floor(w/e.kvNumHeads),numHeads:e.numHeads,kvNumHeads:e.kvNumHeads,nReps:e.numHeads/e.kvNumHeads,pastPresentShareBuffer:!1,maskType:0,scale:e.scale,broadcastResPosBias:!1,passPastInKv:m,qkvFormat:a,isPastkvBSNH:!0}},bo=(t,e,n,i)=>{let r=[i.batchSize,i.totalSequenceLength,i.kvNumHeads,i.headSize],s=$e.size(r)/4,o=i.totalSequenceLength,a=je("present_kv",n,r.length,4),u=qe("new_kv",t.dataType,t.dims.length,4),h=e?qe("past_kv",e.dataType,e.dims.length,4):void 0,l=Math.ceil(i.headSize/4),c={x:o,y:t.dims[0],z:1},f=e?["rank","rank"]:["rank"],d=[{type:12,data:s},{type:12,data:i.pastSequenceLength},{type:12,data:i.kvSequenceLength},{type:12,data:i.totalSequenceLength}],p=[u];h?(d.push(...ze(t.dims),...ze(e.dims),...ze(r)),p.push(h)):d.push(...ze(t.dims),...ze(r));let v=[{name:"output_size",type:"u32"},{name:"past_seqlen",type:"u32"},{name:"new_seqlen",type:"u32"},{name:"present_seqlen",type:"u32"}],y=" let new_batch_stride = uniforms.new_seqlen * num_heads * H;\n let new_row_stride = num_heads * H;\n let new_head_stride = H;\n let in_offset = b * new_batch_stride + (s - past_seqlen) * new_row_stride + n * new_head_stride + h;\n present_kv[out_offset] = new_kv[in_offset];",m=e?`if (s < past_seqlen) {\n let past_batch_stride = uniforms.past_seqlen * num_heads * H;\n var past_head_stride = uniforms.past_seqlen * H;\n if (is_bsnh) {\n past_head_stride = H;\n }\n let in_offset = b * past_batch_stride + s * row_stride + n * past_head_stride + h;\n present_kv[out_offset] = past_kv[in_offset];\n } else if (s < past_seqlen + uniforms.new_seqlen) {\n ${y}\n }`:`if (s < past_seqlen + uniforms.new_seqlen) {\n ${y}\n }`;return{name:"ConcatPastNew",shaderCache:{hint:`${i.kvNumHeads}${l}${!!e}`,inputDependencies:f},getRunData:()=>({outputs:[{dims:r,dataType:n}],dispatchGroup:c,programUniforms:d}),getShaderSource:t=>`\n\n ${t.registerUniforms(v).declareVariables(...p,a)}\n ${t.mainStart([l,i.kvNumHeads,1])}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n var indices = ${a.offsetToIndices("global_idx")};\n let h = local_id.x;\n let n = local_id.y;\n let s = workgroup_id.x;\n let b = workgroup_id.y;\n let num_heads = ${i.kvNumHeads}u;\n let H = ${l}u;\n\n let present_seqlen = uniforms.present_seqlen;\n let present_batch_stride = present_seqlen * num_heads * H;\n var row_stride = H;\n let is_bsnh = ${i.isPastkvBSNH};\n\n if (is_bsnh) {\n row_stride = num_heads * H;\n }\n var present_head_stride = present_seqlen * H;\n if (is_bsnh) {\n present_head_stride = H;\n }\n\n let past_seqlen = uniforms.past_seqlen;\n\n let out_offset = b * present_batch_stride + s * row_stride + n * present_head_stride + h;\n ${m}\n }`}},xo=t=>xe({...t}),_o=xe({perm:[0,2,1,3]}),ko=(t,e,n,i,r)=>{let s=e,o=i.kvNumHeads,a=i.nReps;return 3===e.dims.length&&0!==i.kvSequenceLength&&(s=e.reshape([i.batchSize,i.kvSequenceLength,o,i.headSize])),s=n?t.compute(bo(s,n,s.dataType,i),{inputs:[s,n],outputs:[i.isPastkvBSNH?r:-1]})[0]:t.compute(bo(s,void 0,s.dataType,i),{inputs:[s],outputs:[i.isPastkvBSNH?r:-1]})[0],1!==a&&(s=t.compute(mo([s],[1,1,1,a]),{inputs:[s],outputs:[-1]})[0],s=s.reshape([i.batchSize,i.totalSequenceLength,o*a,i.headSize])),t.compute(Xe(s,_o.perm),{inputs:[s],outputs:[-1]})[0]},$o=(t,e)=>{let n=go(t.inputs,e);if(5===t.inputs[0].dims.length)throw new Error("Packed QKV is not implemented");if(5===t.inputs[1]?.dims.length)throw new Error("Packed KV is not implemented");let i=co(t,n.batchSize,n.numHeads,n.sequenceLength,n.headSize,t.inputs[0],void 0,0),r=t.inputs[3]&&0!==t.inputs[3].dims.length?t.inputs[3]:void 0,s=t.inputs[4]&&0!==t.inputs[4].dims.length?t.inputs[4]:void 0,o=ko(t,t.inputs[1],r,n,1),a=ko(t,t.inputs[2],s,n,2);ei(t,i,o,a,void 0,void 0,void 0,void 0,void 0,n,e)}})),ah=V((()=>{wu(),Su(),Mu(),So=(t,e)=>{let n=t[0].dims,i=n,r=$e.sizeToDimension(n,2),s=$e.sizeFromDimension(n,2),o=De(s),a=s/o,u=[n[0],n[1],a],h=[{type:12,data:s},{type:12,data:a}];return h.push(...ze(u,u)),{name:"InstanceNormalization",shaderCache:{hint:`${e.epsilon};${o}`,inputDependencies:["rank","type","type"]},getRunData:()=>({outputs:[{dims:i,dataType:t[0].dataType}],dispatchGroup:{x:r},programUniforms:h}),getShaderSource:n=>{let i=qe("x",t[0].dataType,u.length,o),r=qe("scale",t[1].dataType,t[1].dims),s=qe("bias",t[2].dataType,t[2].dims),a=je("output",t[0].dataType,u.length,o),h=[i,r,s,a],l=i.type.value,c=1===o?"f32":`vec${o}<f32>`;return`\n var<workgroup> meanShared : f32;\n var<workgroup> squaredNormShared : f32;\n var<workgroup> workgroupShared : array<${c}, 64>;\n const workgroupSize = 64u;\n ${n.registerUniforms([{name:"normSize",type:"u32"},{name:"normPackedSize",type:"u32"}]).declareVariables(...h)}\n ${n.mainStart(64)}\n let norm = global_idx / workgroupSize;\n let batch = norm / uniforms.x_shape[1];\n let channel = norm % uniforms.x_shape[1];\n let localIndex = local_id.x;\n\n // initialize workgroup memory\n var initial = ${c}(0);\n for (var h = localIndex; h < uniforms.normPackedSize; h += workgroupSize) {\n initial = initial + ${c}(${i.get("batch","channel","h")});\n }\n workgroupShared[localIndex] = initial;\n workgroupBarrier();\n\n // Calculate the mean of current channel data.\n for (var currSize = workgroupSize >> 1; currSize > 0; currSize = currSize >> 1) {\n if (localIndex < currSize) {\n workgroupShared[localIndex] = workgroupShared[localIndex] + workgroupShared[localIndex + currSize];\n }\n workgroupBarrier();\n }\n if (localIndex == 0) {\n meanShared = ${Ne("workgroupShared[0]",o)} / f32(uniforms.normSize);\n }\n workgroupBarrier();\n\n // reinitialize workgroup memory.\n initial = ${c}(0);\n for (var h = localIndex; h < uniforms.normPackedSize; h += workgroupSize) {\n let deviation = ${c}(${i.get("batch","channel","h")}) - ${c}(meanShared);\n initial = initial + deviation * deviation;\n }\n workgroupShared[localIndex] = initial;\n workgroupBarrier();\n\n // Calculate the sum of square of deviation of current channel data.\n for (var currSize = workgroupSize >> 1; currSize > 0; currSize = currSize >> 1) {\n if (localIndex < currSize) {\n workgroupShared[localIndex] = workgroupShared[localIndex] + workgroupShared[localIndex + currSize];\n }\n workgroupBarrier();\n }\n if (localIndex == 0) {\n squaredNormShared = ${Ne("workgroupShared[0]",o)};\n }\n workgroupBarrier();\n\n let invStdDev = inverseSqrt(squaredNormShared / f32(uniforms.normSize) + f32(${e.epsilon}));\n let channelScale = invStdDev * f32(${r.getByOffset("channel")});\n let channelShift = f32(${s.getByOffset("channel")}) - meanShared * channelScale;\n for (var h = localIndex; h < uniforms.normPackedSize; h += workgroupSize) {\n let value = ${i.get("batch","channel","h")} * ${l}(${c}(channelScale)) + ${l}(${c}(channelShift));\n ${a.set("batch","channel","h","value")};\n }\n }`}}},Mo=(t,e,n,i,r,s,o,a)=>{let u=De(o),h=1===u?"vec2f":`mat2x${u}f`,l=1===u?"f32":`vec${u}f`,c=(t,e)=>`${h}(${t}, ${e})`,f=r*o/u,d=[{type:12,data:Math.ceil(s/64)},{type:12,data:s},{type:12,data:Math.floor(o/u)},{type:12,data:Math.floor(s*o/u)}],p=t.compute({name:"InstanceNormComputeMean",shaderCache:{hint:`${u}`,inputDependencies:["type"]},getRunData:()=>({outputs:[{dims:[r,o,64,2],dataType:1}],dispatchGroup:{x:r*o/u},programUniforms:d}),getShaderSource:t=>{let n=qe("input",e.dataType,e.dims,u);return`\n ${t.declareVariables(n)}\n @group(0) @binding(1) var<storage, read_write> output : array<${h}>;\n struct Uniforms {wg_size:u32, H:u32, C:u32, image_size:u32};\n @group(0) @binding(2) var<uniform> uniforms: Uniforms;\n\n ${t.mainStart(64)}\n let currentImageNumber = global_idx / 64 / uniforms.C;\n let currentChannelNumber = (global_idx / 64) % uniforms.C;\n let wgOffset = local_id.x * uniforms.wg_size;\n if (wgOffset >= uniforms.H) {\n return;\n }\n let wgMax = min(wgOffset + uniforms.wg_size, uniforms.H);\n\n let offset = currentImageNumber * uniforms.image_size + currentChannelNumber;\n var sum = ${Pe("f32",u)};\n var squaredSum = ${Pe("f32",u)};\n for (var i: u32 = wgOffset; i < wgMax; i++) {\n let value = ${l}(input[offset + i * uniforms.C]);\n sum += value;\n squaredSum += value * value;\n }\n output[global_idx] = ${c("sum","squaredSum")};\n }`}},{inputs:[e],outputs:[-1]})[0],v=[{type:12,data:f},{type:12,data:s},{type:12,data:Math.floor(o/u)},{type:12,data:Math.floor(64*o/u)}];return t.compute({name:"InstanceNormComputeChannelScaleShift",shaderCache:{hint:`${u};${a}`,inputDependencies:["type","type","type"]},getRunData:()=>({outputs:[{dims:[r,o,2],dataType:1}],dispatchGroup:{x:Math.ceil(f/64)},programUniforms:v}),getShaderSource:t=>{let e=qe("scale",n.dataType,n.dims,u),r=qe("bias",i.dataType,i.dims,u);return`\n @group(0) @binding(0) var<storage, read> input : array<${h}>;\n @group(0) @binding(1) var<storage, read> scale : array<${e.type.storage}>;\n @group(0) @binding(2) var<storage, read> bias : array<${r.type.storage}>;\n @group(0) @binding(3) var<storage, read_write> output : array<${h}>;\n struct Uniforms {units_of_work : u32, H: u32, C : u32, image_size : u32};\n @group(0) @binding(4) var<uniform> uniforms: Uniforms;\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.units_of_work")}\n let currentImageNumber = global_idx / uniforms.C;\n let currentChannelNumber = global_idx % uniforms.C;\n\n let offset = currentImageNumber * uniforms.image_size;\n var sum = ${Pe("f32",u)};\n var squaredSum = ${Pe("f32",u)};\n for (var i: u32 = 0; i < min(64, uniforms.H); i++) {\n let value = input[offset + i + currentChannelNumber * 64];\n sum += value[0];\n squaredSum += value[1];\n }\n sum = sum / f32(uniforms.H);\n squaredSum = squaredSum / f32(uniforms.H);\n let invStdDev = inverseSqrt(squaredSum - sum * sum + f32(${a}));\n let channelScale = invStdDev * ${l}(scale[currentChannelNumber]);\n let channelShift = ${l}(bias[currentChannelNumber]) - sum * channelScale;\n\n output[global_idx] = ${c("channelScale","channelShift")};\n }`}},{inputs:[p,n,i],outputs:[-1]})[0]},Eo=(t,e,n)=>{let i=e[0].dims,r=i,s=i[0],o=i[i.length-1],a=$e.sizeFromDimension(i,1)/o,u=De(o),h=$e.size(r)/u,l=[{type:12,data:a},{type:12,data:Math.floor(o/u)}],c=Mo(t,e[0],e[1],e[2],s,a,o,n.epsilon);t.compute({name:"InstanceNormalizationNHWC",shaderCache:{hint:`${u}`,inputDependencies:["type","type"]},getRunData:()=>({outputs:[{dims:r,dataType:e[0].dataType}],dispatchGroup:{x:Math.ceil(h/64)},programUniforms:l}),getShaderSource:t=>{let n=Oe(e[0].dataType),i=1===u?"vec2f":`mat2x${u}f`,s=1===u?n:`vec${u}<${n}>`,o=qe("input",e[0].dataType,e[0].dims,u),a=je("output",e[0].dataType,r,u);return`\n @group(0) @binding(0) var<storage, read> input : array<${o.type.storage}>;\n @group(0) @binding(1) var<storage, read> scaleInput : array<${i}>;\n @group(0) @binding(2) var<storage, read_write> output : array<${a.type.storage}>;\n struct Uniforms {H: u32, C : u32};\n @group(0) @binding(3) var<uniform> uniforms: Uniforms;\n\n ${t.mainStart()}\n let currentImageNumber = global_idx / (uniforms.C * uniforms.H);\n let currentChannelNumber = global_idx % uniforms.C;\n\n let scaleOffset = currentImageNumber * uniforms.C + currentChannelNumber;\n let scale = scaleInput[scaleOffset];\n output[global_idx] = fma(input[global_idx], ${s}(scale[0]), ${s}(scale[1]));\n }`}},{inputs:[e[0],c]})},Co=(t,e)=>{"NHWC"===e.format?Eo(t,t.inputs,e):t.compute(So(t.inputs,e))}})),uh=V((()=>{wu(),Su(),Mu(),Ao=t=>{if(!t||t.length<2)throw new Error("layerNorm requires at least 2 inputs.")},Io=(t,e,n)=>{let i=e.simplified,r=t[0].dims,s=t[1],o=!i&&t[2],a=r,u=$e.normalizeAxis(e.axis,r.length),h=$e.sizeToDimension(r,u),l=$e.sizeFromDimension(r,u),c=$e.size(s.dims),f=o?$e.size(o.dims):0;if(c!==l||o&&f!==l)throw new Error(`Size of X.shape()[axis:] == ${l}.\n Size of scale and bias (if provided) must match this.\n Got scale size of ${c} and bias size of ${f}`);let d=[];for(let t=0;t<r.length;++t)t<u?d.push(r[t]):d.push(1);let p=De(l),v=["type","type"],y=[{type:12,data:h},{type:1,data:l},{type:12,data:Math.floor(l/p)},{type:1,data:e.epsilon}];o&&v.push("type");let m=n>1,w=n>2,g=[{dims:a,dataType:t[0].dataType}];return m&&g.push({dims:d,dataType:1}),w&&g.push({dims:d,dataType:1}),{name:"LayerNormalization",shaderCache:{hint:`${p};${n};${i}`,inputDependencies:v},getRunData:()=>({outputs:g,dispatchGroup:{x:Math.ceil(h/64)},programUniforms:y}),getShaderSource:e=>{let n=Oe(t[0].dataType),r=[qe("x",t[0].dataType,t[0].dims,p),qe("scale",s.dataType,s.dims,p)];return o&&r.push(qe("bias",o.dataType,o.dims,p)),r.push(je("output",t[0].dataType,a,p)),m&&r.push(je("mean_data_output",1,d)),w&&r.push(je("inv_std_output",1,d)),`\n ${e.registerUniforms([{name:"norm_count",type:"u32"},{name:"norm_size",type:"f32"},{name:"norm_size_vectorized",type:"u32"},{name:"epsilon",type:"f32"}]).declareVariables(...r)}\n ${e.mainStart()}\n ${e.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.norm_count")}\n let offset = global_idx * uniforms.norm_size_vectorized;\n var mean_vector = ${Pe("f32",p)};\n var mean_square_vector = ${Pe("f32",p)};\n\n for (var h: u32 = 0u; h < uniforms.norm_size_vectorized; h++) {\n let value = ${Re(n,p,"x[h + offset]")};\n mean_vector += value;\n mean_square_vector += value * value;\n }\n let mean = ${Ne("mean_vector",p)} / uniforms.norm_size;\n let inv_std_dev = inverseSqrt(${Ne("mean_square_vector",p)} / uniforms.norm_size ${i?"":"- mean * mean"} + uniforms.epsilon);\n\n for (var j: u32 = 0; j < uniforms.norm_size_vectorized; j++) {\n let f32input = ${Re(n,p,"x[j + offset]")};\n let f32scale = ${Re(n,p,"scale[j]")};\n output[j + offset] = ${r[0].type.value}((f32input ${i?"":"- mean"}) * inv_std_dev * f32scale\n ${o?`+ ${Re(n,p,"bias[j]")}`:""}\n );\n }\n\n ${m?"mean_data_output[global_idx] = mean":""};\n ${w?"inv_std_output[global_idx] = inv_std_dev":""};\n }`}}},Oo=(t,e)=>{Ao(t.inputs),t.compute(Io(t.inputs,e,t.outputCount))}})),hh=V((()=>{wu(),Su(),$u(),Mu(),To=(t,e)=>{if(t.length<3||t.length>4)throw new Error("MatMulNBits requires 3 or 4 inputs");let n=t[0],i=n.dims.length;if(n.dims[i-1]!==e.k)throw new Error("The last dim of input shape does not match the k value");let r=Math.floor((e.k+e.blockSize-1)/e.blockSize),s=e.blockSize/8*e.bits,o=t[1];if(!$e.areEqual(o.dims,[e.n,r,s]))throw new Error("The second inputs must be 3D tensor with shape N X nBlocksPerCol X blobSize");let a=t[2].dims;if($e.size(a)!==e.n*r)throw new Error("scales input size error.");if(4===t.length){let n=t[3].dims,i=e.bits>4?e.n*r:e.n*Math.floor((r+1)/2);if($e.size(n)!==i)throw new Error("zeroPoints input size error.")}},zo=(t,e,n,i)=>{let r=t[0].dims,s=r.length,o=Math.floor((e.k+e.blockSize-1)/e.blockSize),a=r[s-2],u=e.k,h=e.n,l=r.slice(0,s-2),c=$e.size(l),f=e.blockSize/8*e.bits/4,d=t[0].dataType,p=De(a),v=De(e.k),y=De(f),m=Jt(d),w=a*o*m,g=Math.floor(i/w),b=o<=n[0]&&g>0,x=!b||g>=4?De(h):g>=2&&De(h)>=2?2:1,_=l.concat([a,h]),k=$e.size(_)/x/p,$=b?[]:[{type:12,data:k},{type:12,data:e.blockSize}],S=[c,a,u/v],M=$e.convertShape(t[1].dims).slice();M.splice(-1,1,f/y),$.push(...ze(S)),$.push(...ze(M)),$.push(...ze(t[2].dims)),4===t.length&&$.push(...ze($e.convertShape(t[3].dims)));let E=[c,a,h/x];return $.push(...ze(E)),{name:b?"BlockwiseMatMulNBits":"MatMulNBits",shaderCache:{hint:`${e.cacheKey};${a};${d};${t.length}`,inputDependencies:Array(t.length).fill("rank")},getRunData:()=>({outputs:[{dims:_,dataType:d}],name:b?"BlockwiseMatMulNBits":"MatMulNBits",dispatchGroup:b?{x:1,y:Math.ceil(h/x),z:c}:{x:Math.ceil(k/64)},programUniforms:$}),getShaderSource:n=>{let i=S.length,r=qe("a",t[0].dataType,i,v),s=qe("b",12,M.length,y),u=qe("scales",t[2].dataType,t[2].dims.length),l=[r,s,u],c=4===t.length?qe("zero_points",12,t[3].dims.length):void 0;c&&l.push(c);let d=E.length,m=je("output",t[0].dataType,d,x),w=Oe(t[0].dataType),g=(()=>{switch(v){case 1:return`array<${w}, 8>`;case 2:return`mat4x2<${w}>`;case 4:return`mat2x4<${w}>`;default:throw new Error(`${v}-component is not supported.`)}})(),_=`\n for (var word: u32 = 0; word < ${f}; word += ${y}) {\n ${s.indicesSet("b_indices","2","word")};\n let b_data = ${s.getByIndices("b_indices")};\n for (var i: u32 = 0; i < ${y}; i++) {\n let b_value: u32 = ${1===y?"b_data":"b_data[word + i]"};\n let b_mask: u32 = 0x0F0F0F0Fu;\n let b_value_lower: vec4<u32> = unpack4xU8(b_value & b_mask);\n let b_value_upper: vec4<u32> = unpack4xU8((b_value >> 4) & b_mask);\n let b_quantized_values = ${g}(${Array.from({length:4},((t,e)=>`${w}(b_value_lower[${e}]), ${w}(b_value_upper[${e}])`)).join(", ")});\n let b_dequantized_values = ${1===v?`${g}(${Array.from({length:8},((t,e)=>`(b_quantized_values[${e}] - zero_point) * scale`)).join(", ")});`:`(b_quantized_values - ${g}(${Array(8).fill("zero_point").join(",")})) * scale;`};\n // Number of B elements per 32-bit word is 32/bits = 32/4 = 8\n for (var m: u32 = 0; m < ${b?a:p}u; m++) {\n ${r.indicesSet("a_indices",i-2,b?"m":`row * ${p} + m`)};\n ${r.indicesSet("a_indices",i-1,"word_offset")};\n var input_offset = ${r.indicesToOffset("a_indices")};\n var a_data: ${g};\n for (var j: u32 = 0; j < ${8/v}; j++) {\n a_data[j] = ${r.getByOffset("input_offset")};\n input_offset++;\n }\n ${b?"workgroup_shared[workgroup_shared_offset + m]":"output_values[m]"}${x>1?"[c]":""} += ${Array.from({length:8/v},((t,e)=>1===v?`a_data[${e}] * b_dequantized_values[${e}]`:`dot(a_data[${e}], b_dequantized_values[${e}])`)).join(" + ")};\n }\n word_offset += ${8/v};\n }\n }`,k=c?`\n zero_point_offset += 4;\n if (zero_point_offset == 32) {\n zero_point_offset = 0;\n zero_point_index++;\n zero_point_word = ${c.getByOffset("zero_point_index")};\n }`:"";return b?`\n var<workgroup> workgroup_shared: array<${m.type.value}, ${a*o}>;\n ${n.declareVariables(...l,m)}\n ${n.mainStart([o,1,1])}\n var a_indices: ${r.type.indices};\n var block = local_id.x;\n var col = workgroup_id.y;\n var batch = workgroup_id.z;\n ${r.indicesSet("a_indices","0","batch")};\n // Two zero points are packed into one byte when uniforms.bits is 4.\n for (var c: u32 = 0; c < ${x}; c++) {\n let col_times_components_plus_c = col * ${x} + c;\n ${c?`\n var zero_point_bytes_per_col: u32 = (${o} + 1) / 2;\n var zero_point_byte_count: u32 = col_times_components_plus_c * zero_point_bytes_per_col + (block >> 0x1u);\n var zero_point_word_index: u32 = zero_point_byte_count >> 0x2u;\n var zero_point_byte_offset: u32 = zero_point_byte_count & 0x3u;\n var zero_point_nibble_offset: u32 = block & 0x1u;\n var zero_point_bits_offset: u32 = (zero_point_byte_offset << 3) + (zero_point_nibble_offset << 2);\n var zero_point_word: u32 = ${c.getByOffset("zero_point_word_index")} >> zero_point_bits_offset;`:""}\n var b_indices: ${s.type.indices};\n ${s.indicesSet("b_indices","0","col_times_components_plus_c")};\n // The scale and zero points are computed per block.\n var scales_index = col_times_components_plus_c * ${o} + block;\n let scale = ${u.getByOffset("scales_index")};\n // The default zero point is 8 for unsigned 4-bit quantization.\n let zero_point = ${w}(${c?"(zero_point_word) & 0xFu":8});\n ${s.indicesSet("b_indices","1","block")};\n var word_offset: u32 = block * ${e.blockSize/v};\n var workgroup_shared_offset: u32 = block * ${a};\n ${_}\n }\n workgroupBarrier();\n var output_indices: ${m.type.indices};\n var elements_per_thread: u32 = ${Math.ceil(a/o)};\n ${m.indicesSet("output_indices","0","batch")};\n ${m.indicesSet("output_indices",d-1,"col")};\n ${m.indicesSet("output_indices",d-2,"local_id.x * elements_per_thread")};\n var output_offset = ${m.indicesToOffset("output_indices")};\n for (var m: u32 = 0u; m < elements_per_thread; m++) {\n var row = m + local_id.x * elements_per_thread;\n if (row < ${a}) {\n var output_value: ${m.type.value} = ${m.type.value}(0);\n var workgroup_shared_offset: u32 = row;\n for (var b: u32 = 0u; b < ${o}u; b++) {\n output_value += workgroup_shared[workgroup_shared_offset];\n workgroup_shared_offset += ${a};\n }\n ${m.setByOffset("output_offset","output_value")};\n output_offset += ${h/x};\n }\n }\n }`:`\n ${n.registerUniforms([{name:"output_size",type:"u32"},{name:"block_size",type:"u32"}]).declareVariables(...l,m)}\n ${n.mainStart()}\n ${n.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n var output_values: array<${m.type.value}, ${p}>;\n var output_indices = ${m.offsetToIndices("global_idx")};\n var col = ${m.indicesGet("output_indices",d-1)};\n var row = ${m.indicesGet("output_indices",d-2)};\n var a_indices: ${r.type.indices} = output_indices;\n // Two zero points are packed into one byte because uniforms.bits <= 4.\n // zero_point_offset is either 0 or 4. It is bit offset within one byte.\n // TODO support zero_point_offset for bits > 4\n ${c?`\n var zero_point_abs_offset = col * ${x} * ((${o} + 1) / 2);\n var zero_point_index: u32 = zero_point_abs_offset / 4;\n var zero_point_word: u32 = ${c.getByOffset("zero_point_index")};\n var zero_point_offset: u32 = (zero_point_abs_offset % 4) * 8;`:""}\n var scale_index = col * ${o*x};\n var b_indices: ${s.type.indices};\n for (var c: u32 = 0; c < ${x}; c++) {\n ${s.indicesSet("b_indices","0",`col * ${x} + c`)};\n var block_offset: u32 = 0;\n for (var block: u32 = 0; block < ${o}; block++) {\n // The scale and zero points are computed per block.\n let scale = ${u.getByOffset("scale_index")};\n // The default zero point is 8 for unsigned 4-bit quantization.\n let zero_point = ${w}(${c?"extractBits(zero_point_word, zero_point_offset, 4)":8});\n ${s.indicesSet("b_indices","1","block")};\n var word_offset: u32 = block_offset;\n ${_}\n scale_index++;\n ${k}\n block_offset += uniforms.block_size / ${v};\n }\n // Drop the trailing 4 bits if the zero_poit_offset is not a byte boundary to align with the next byte.\n ${c?`if (zero_point_offset % 8 > 0) {\n ${k}\n }`:""}\n }\n for (var k: u32 = 0u; k < ${p}u; k++) {\n ${m.indicesSet("output_indices",d-2,`${p} * row + k`)};\n ${m.setByIndices("output_indices","output_values[k]")}\n }\n }`}}},Do=(t,e)=>{To(t.inputs,e);let n=t.getMaxComputeWorkgroupSizes(),i=t.getMaxComputeWorkgroupStoragesize();t.compute(zo(t.inputs,e,n,i))},Po=t=>xe(t)})),lh=V((()=>{wu(),Su(),Mu(),Ro=t=>{if(!t||t.length<1)throw new Error("Too few inputs");if(1!==t[0].dataType&&10!==t[0].dataType)throw new Error("Input type must be float or float16.");if(t.length>=2){let e=2*t[0].dims.length===t[1].dims[0];if(4===t.length&&(e=2*t[3].dims[0]===t[1].dims[0]),!e)throw new Error("The pads should be a 1D tensor of shape [2 * input_rank] or [2 * num_axes].")}},No=(t,e,n)=>{let i="";for(let r=e-1;r>=0;--r)i+=`\n k = i32(${t.indicesGet("indices",r)}) - ${Fe("uniforms.pads",r,n)};\n if (k < 0) {\n break;\n }\n if (k >= i32(${Fe("uniforms.x_shape",r,e)})) {\n break;\n }\n offset += k * i32(${Fe("uniforms.x_strides",r,e)});\n `;return`\n value = ${t.type.value}(uniforms.constant_value);\n for (var i = 0; i < 1; i++) {\n var offset = 0;\n var k = 0;\n ${i}\n value = x[offset];\n }\n `},Fo=(t,e,n)=>{let i="";for(let r=e-1;r>=0;--r)i+=`\n k = i32(${t.indicesGet("indices",r)}) - ${Fe("uniforms.pads",r,n)};\n if (k < 0) {\n k = -k;\n }\n {\n let _2n_1 = 2 * (i32(${Fe("uniforms.x_shape",r,e)}) - 1);\n k = k % _2n_1;\n if(k >= i32(${Fe("uniforms.x_shape",r,e)})) {\n k = _2n_1 - k;\n }\n }\n offset += k * i32(${Fe("uniforms.x_strides",r,e)});\n `;return`\n var offset = 0;\n var k = 0;\n ${i}\n value = x[offset];\n `},Uo=(t,e,n)=>{let i="";for(let r=e-1;r>=0;--r)i+=`\n k = i32(${t.indicesGet("indices",r)}) - ${Fe("uniforms.pads",r,n)};\n if (k < 0) {\n k = 0;\n }\n if (k >= i32(${Fe("uniforms.x_shape",r,e)})) {\n k = i32(${Fe("uniforms.x_shape",r,e)}) - 1;\n }\n offset += k * i32(${Fe("uniforms.x_strides",r,e)});\n `;return`\n var offset = 0;\n var k = 0;\n ${i}\n value = x[offset];\n `},qo=(t,e,n)=>{let i="";for(let r=e-1;r>=0;--r)i+=`\n k = i32(${t.indicesGet("indices",r)}) - ${Fe("uniforms.pads",r,n)};\n if (k < 0) {\n k += i32(${Fe("uniforms.x_shape",r,e)}]);\n }\n if (k >= i32(${Fe("uniforms.x_shape",r,e)})) {\n k -= i32(${Fe("uniforms.x_shape",r,e)});\n }\n offset += k * i32(${Fe("uniforms.x_strides",r,e)});\n `;return`\n var offset = 0;\n var k = 0;\n ${i}\n value = x[offset];\n `},jo=(t,e,n)=>{switch(n.mode){case 0:return No(t,e,n.pads.length);case 1:return Fo(t,e,n.pads.length);case 2:return Uo(t,e,n.pads.length);case 3:return qo(t,e,n.pads.length);default:throw new Error("Invalid mode")}},Bo=(t,e)=>{let n=$e.padShape(t[0].dims.slice(),e.pads),i=t[0].dims,r=[{type:12,data:$e.size(n)},{type:6,data:e.pads}];return 0===e.mode&&r.push({type:t[0].dataType,data:e.value}),r.push(...ze(t[0].dims,n)),{name:"Pad",shaderCache:{hint:`${e.mode}`,inputDependencies:["rank"]},getRunData:()=>({outputs:[{dims:n,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil($e.size(n)/64)},programUniforms:r}),getShaderSource:r=>{let s=je("output",t[0].dataType,n.length),o=qe("x",t[0].dataType,i.length),a=o.type.value,u=jo(s,i.length,e),h=[{name:"output_size",type:"u32"},{name:"pads",type:"i32",length:e.pads.length}];return 0===e.mode&&h.push({name:"constant_value",type:a}),`\n ${r.registerUniforms(h).declareVariables(o,s)}\n ${r.mainStart()}\n ${r.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n\n let indices = ${s.offsetToIndices("global_idx")};\n\n var value = ${a}(0);\n ${u}\n output[global_idx] = value;\n }`}}},Lo=(t,e)=>{if(t.length>1){let n=t[1].getBigInt64Array(),i=t.length>=3&&t[2].data?t[2].getFloat32Array()[0]:0,r=t[0].dims.length,s=new Int32Array(2*r).fill(0);if(t.length>=4){let e=t[3].getBigInt64Array();for(let t=0;t<e.length;t++)s[Number(e[t])]=Number(n[t]),s[Number(e[t])+r]=Number(n[t+e.length])}else n.forEach(((t,e)=>s[Number(e)]=Number(t)));let o=[];return s.forEach((t=>o.push(t))),{mode:e.mode,value:i,pads:o}}return e},Ho=(t,e)=>{Ro(t.inputs);let n=Lo(t.inputs,e);t.compute(Bo(t.inputs,n),{inputs:[0]})}})),ch=V((()=>{vt(),wu(),Su(),Mu(),Vo=t=>{if(y.webgpu.validateInputContent&&(!t||1!==t.length))throw new Error("Pool ops requires 1 input.")},Wo=(t,e,n)=>{let i="NHWC"===e.format,r=t.dims.slice();i&&r.splice(1,0,r.pop());let s=Object.hasOwnProperty.call(e,"dilations"),o=e.kernelShape.slice(),a=e.strides.slice(),u=s?e.dilations.slice():[],h=e.pads.slice();Se.adjustPoolAttributes(n,r,o,a,u,h);let l=Se.computePoolOutputShape(n,r,a,u,o,h,e.autoPad),c=Object.assign({},e);s?Object.assign(c,{kernelShape:o,strides:a,pads:h,dilations:u,cacheKey:e.cacheKey}):Object.assign(c,{kernelShape:o,strides:a,pads:h,cacheKey:e.cacheKey});let f=l.slice();return f.push(f.splice(1,1)[0]),[c,i?f:l]},Go=(t,e)=>{let n="NHWC"===e.format,i=[{type:12,data:$e.size(t)},{type:12,data:$e.size(e.kernelShape)}],r=[{name:"outputSize",type:"u32"},{name:"kernelSize",type:"u32"}];if(e.kernelShape.length<=2){let t=e.kernelShape[e.kernelShape.length-1],n=e.strides[e.strides.length-1],s=e.pads[e.pads.length/2-1],o=e.pads[e.pads.length-1],a=!!(s+o);i.push({type:12,data:t},{type:12,data:n},{type:12,data:s},{type:12,data:o}),r.push({name:"kw",type:"u32"},{name:"sw",type:"u32"},{name:"pwStart",type:"u32"},{name:"pwEnd",type:"u32"});let u=!1;if(2===e.kernelShape.length){let t=e.kernelShape[e.kernelShape.length-2],n=e.strides[e.strides.length-2],s=e.pads[e.pads.length/2-2],o=e.pads[e.pads.length-2];u=!!(s+o),i.push({type:12,data:t},{type:12,data:n},{type:12,data:s},{type:12,data:o}),r.push({name:"kh",type:"u32"},{name:"sh",type:"u32"},{name:"phStart",type:"u32"},{name:"phEnd",type:"u32"})}return[i,r,!0,a,u]}{if(n)throw new Error("Pooling with kernelShape.length > 2 is not supported for NHWC format.");let t=$e.computeStrides(e.kernelShape);i.push({type:12,data:t},{type:12,data:e.pads},{type:12,data:e.strides}),r.push({name:"kernelStrides",type:"u32",length:t.length},{name:"pads",type:"u32",length:e.pads.length},{name:"strides",type:"u32",length:e.strides.length});let s=e.pads.reduce(((t,e)=>t+e));return[i,r,!!s,!1,!1]}},Qo=(t,e,n,i,r,s,o,a,u,h,l,c)=>{let f="NHWC"===r.format,d=e.type.value,p=je("output",e.type.tensor,i);if(r.kernelShape.length<=2){let i="",h="",v="",y=n-(f?2:1);if(i=l?`\n for (var i: u32 = 0u; i < uniforms.kw; i++) {\n xIndices[${y}] = indices[${y}] * uniforms.sw - uniforms.pwStart + i;\n if (xIndices[${y}] < 0 || xIndices[${y}]\n >= uniforms.x_shape[${y}]) {\n pad++;\n continue;\n }\n let x_val = x[${e.indicesToOffset("xIndices")}];\n ${s}\n }`:`\n for (var i: u32 = 0u; i < uniforms.kw; i++) {\n xIndices[${y}] = indices[${y}] * uniforms.sw - uniforms.pwStart + i;\n let x_val = x[${e.indicesToOffset("xIndices")}];\n ${s}\n }`,2===r.kernelShape.length){let t=n-(f?3:2);h=c?`\n for (var j: u32 = 0u; j < uniforms.kh; j++) {\n xIndices[${t}] = indices[${t}] * uniforms.sh - uniforms.phStart + j;\n if (xIndices[${t}] < 0 || xIndices[${t}] >= uniforms.x_shape[${t}]) {\n pad += i32(uniforms.kw);\n continue;\n }\n `:`\n for (var j: u32 = 0u; j < uniforms.kh; j++) {\n xIndices[${t}] = indices[${t}] * uniforms.sh - uniforms.phStart + j;\n `,v="\n }\n "}return`\n ${t.registerUniforms(u).declareVariables(e,p)}\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}\n\n let indices = ${p.offsetToIndices("global_idx")};\n var xIndices = ${p.offsetToIndices("global_idx")};\n\n var value = ${d}(${a});\n var pad = 0;\n ${h}\n ${i}\n ${v}\n ${o}\n\n output[global_idx] = value;\n }`}{if(f)throw new Error("Pooling with kernelShape.length > 2 is not supported for NHWC format.");let i=r.kernelShape.length,l=r.pads.length,c="";return c=h?`\n if (xIndices[j] >= uniforms.x_shape[j]) {\n pad++;\n isPad = true;\n break;\n }\n }\n if (!isPad) {\n let x_val = x[${e.indicesToOffset("xIndices")}];\n ${s}\n }`:`\n }\n let x_val = x[${e.indicesToOffset("xIndices")}];\n ${s}\n `,`\n ${t.registerUniforms(u).declareVariables(e,p)}\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}\n let indices = ${p.offsetToIndices("global_idx")};\n var xIndices = ${p.offsetToIndices("global_idx")};\n\n var offsets: array<u32, ${i}>;\n\n var value = ${d}(${a});\n var pad = 0;\n var isPad = false;\n\n for (var i: u32 = 0u; i < uniforms.kernelSize; i++) {\n var offset = i;\n for (var j = 0u; j < ${i-1}u; j++) {\n offsets[j] = offset / ${Fe("uniforms.kernelStrides","j",i)};\n offset -= offsets[j] * ${Fe("uniforms.kernelStrides","j",i)};\n }\n offsets[${i-1}] = offset;\n\n isPad = false;\n for (var j = ${n-i}u; j < ${n}u; j++) {\n xIndices[j] = indices[j] * ${Fe("uniforms.strides",`j - ${n-i}u`,i)}\n + offsets[j - ${n-i}u] - ${Fe("uniforms.pads","j - 2u",l)};\n ${c}\n }\n ${o}\n\n output[global_idx] = value;\n }`}},Ko=t=>`${t.format};${t.ceilMode};${t.autoPad};${t.kernelShape.length}`,Xo=t=>`${Ko(t)};${t.countIncludePad}`,Zo=t=>`${Ko(t)};${t.storageOrder};${t.dilations}`,Yo=t=>({format:t.format,autoPad:["NOTSET","VALID","SAME_UPPER","SAME_LOWER"][t.auto_pad],ceilMode:t.ceil_mode,kernelShape:t.kernel_shape,strides:t.strides,pads:t.pads}),Jo=(t,e,n,i)=>{let[r,s]=Wo(e,i,n),o=qe("x",e.dataType,e.dims.length),a=o.type.value,u="";r.countIncludePad?u+=`value /= ${a}(uniforms.kernelSize);`:u+=`value /= ${a}(i32(uniforms.kernelSize) - pad);`;let[h,l,c,f,d]=Go(s,r);return h.push(...ze(e.dims,s)),{name:t,shaderCache:{hint:`${i.cacheKey};${c};${f};${d}`,inputDependencies:["rank"]},getRunData:()=>({outputs:[{dims:s,dataType:e.dataType}],dispatchGroup:{x:Math.ceil($e.size(s)/64)},programUniforms:h}),getShaderSource:t=>Qo(t,o,e.dims.length,s.length,r,"value += x_val;",u,0,l,c,f,d)}},ta=t=>{let e=0!==t.count_include_pad,n=Yo(t);if(0!==n.ceilMode)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");let i={countIncludePad:e,...n,cacheKey:""};return{...i,cacheKey:Xo(i)}},ea=(t,e)=>{Vo(t.inputs),t.compute(Jo("AveragePool",t.inputs[0],!1,e))},na={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[]},ia=t=>{let e=t.format;return{format:e,...na,cacheKey:e}},ra=(t,e)=>{Vo(t.inputs),t.compute(Jo("GlobalAveragePool",t.inputs[0],!0,e))},sa=(t,e,n,i)=>{let[r,s]=Wo(e,i,n),o=qe("x",e.dataType,e.dims.length),[a,u,h,l,c]=Go(s,r);return a.push(...ze(e.dims,s)),{name:t,shaderCache:{hint:`${i.cacheKey};${h};${l};${c}`,inputDependencies:["rank"]},getRunData:()=>({outputs:[{dims:s,dataType:e.dataType}],dispatchGroup:{x:Math.ceil($e.size(s)/64)},programUniforms:a}),getShaderSource:t=>Qo(t,o,e.dims.length,s.length,r,"\n value = max(x_val, value);\n ","",10===e.dataType?-65504:-1e5,u,h,l,c)}},oa=(t,e)=>{Vo(t.inputs),t.compute(sa("MaxPool",t.inputs[0],!1,e))},aa=t=>{let e=t.storage_order,n=t.dilations,i=Yo(t);if(0!==e)throw new Error("column major storage order is not yet supported for MaxPool");if(0!==i.ceilMode)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");let r={storageOrder:e,dilations:n,...i,cacheKey:""};return{...r,cacheKey:Zo(r)}},ua=t=>{let e=t.format;return{format:e,...na,cacheKey:e}},ha=(t,e)=>{Vo(t.inputs),t.compute(sa("GlobalMaxPool",t.inputs[0],!0,e))}})),fh=V((()=>{vt(),wu(),Mu(),la=(t,e,n)=>{if(t===e||t<e&&n<0||t>e&&n>0)throw new Error("Range these inputs' contents are invalid.")},ca=(t,e,n,i)=>{let r=Math.abs(Math.ceil((e-t)/n)),s=[r],o=r,a=[{type:12,data:o},{type:i,data:t},{type:i,data:n},...ze(s)];return{name:"Range",shaderCache:{hint:`${i}`},getShaderSource:t=>{let e=je("output",i,s.length),n=e.type.value,r=[{name:"outputSize",type:"u32"},{name:"start",type:n},{name:"delta",type:n}];return`\n ${t.registerUniforms(r).declareVariables(e)}\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}\n output[global_idx] = uniforms.start + ${n}(global_idx) * uniforms.delta;\n }`},getRunData:()=>({outputs:[{dims:s,dataType:i}],dispatchGroup:{x:Math.ceil(o/64)},programUniforms:a})}},fa=t=>{let e=0,n=0,i=0;6===t.inputs[0].dataType?(e=t.inputs[0].getInt32Array()[0],n=t.inputs[1].getInt32Array()[0],i=t.inputs[2].getInt32Array()[0]):1===t.inputs[0].dataType&&(e=t.inputs[0].getFloat32Array()[0],n=t.inputs[1].getFloat32Array()[0],i=t.inputs[2].getFloat32Array()[0]),y.webgpu.validateInputContent&&la(e,n,i),t.compute(ca(e,n,i,t.inputs[0].dataType),{inputs:[]})}})),dh=V((()=>{wu(),Su(),$u(),Mu(),da=(t,e)=>{if(t.every((t=>t>0||(()=>{throw new Error("Resize requires scales input values to be positive")}))),t.length>0)if("linear"===e.mode){if(!(2===t.length||3===t.length||4===t.length&&1===t[0]&&1===t[1]||4===t.length&&1===t[0]&&1===t[3]||5===t.length&&1===t[0]&&1===t[1]))throw new Error("For linear mode, Resize requires scales to be 2D, 3D, 4D with either two outermost or one innermost and\n one outermost scale values equal to 1, or 5D with two outermost scale values equal to 1")}else if("cubic"===e.mode&&!(2===t.length||4===t.length&&1===t[0]&&1===t[1]||4===t.length&&1===t[0]&&1===t[3]))throw new Error("Resize requires scales input size to be 2 or 4 for cubic mode")},pa=(t,e,n)=>{e.every((t=>t>=0&&t<n||(()=>{throw new Error("Resize requires axes input values to be positive and less than rank")})));let i=new Array(n).fill(1);return e.forEach(((e,n)=>i[e]=t[n])),i},va=(t,e,n,i,r,s)=>{let[o,a,u]=n>10?[1,2,3]:[-1,t.length>1?1:-1,-1],h=t[0].dims.length;if(o>0&&t.length>o&&t[o].dims.length>0)t[o].getFloat32Array().forEach((t=>s.push(t)));else if("tf_crop_and_resize"===e.coordinateTransformMode)throw new Error("Resize requires RoI input to be specified when coordinateTransformMode is tfCropAndResize");if(a>0&&t.length>a&&t[a].dims.length>0){if(t[a].getFloat32Array().forEach((t=>i.push(t))),0!==i.length&&i.length!==h&&n>=18&&i.length!==e.axes.length)throw new Error("Resize requires scales input size to be same as input rank or axes size for opset 18 and up");da(i,e),e.axes.length>0&&pa(i,e.axes,h).forEach(((t,e)=>i[e]=t))}if(u>0&&t.length>u&&(t[u].getBigInt64Array().forEach((t=>r.push(Number(t)))),r.length!==h||n>=18&&r.length===e.axes.length))throw new Error("Resize requires sizes input size to be same as input rank or axes size for opset 18 and up");if(e.axes.length>0){if(i.length!==e.axes.length)throw new Error('Resize requires "scales" input size to be of axes rank when axes attributes is specified');if(r.length!==e.axes.length)throw new Error('Resize requires "sizes" input size to be of rank axes rank when axes attributes is specified')}if(typeof i<"u"&&typeof r<"u"&&i.length>0&&r.length>h)throw new Error("Resize requires only of scales or sizes to be specified")},ya=(t,e)=>`fn getOriginalCoordinateFromResizedCoordinate(xResized: u32, xScale: f32, lengthResized: u32,\n lengthOriginal: u32, roiStart: f32, roiEnd: f32) -> ${e} { `+(()=>{switch(t){case"asymmetric":return`return ${e}(xResized) / ${e}(xScale);`;case"pytorch_half_pixel":return`if (lengthResized > 1) {\n return (${e}(xResized) + 0.5) / ${e}(xScale) - 0.5;\n } else {\n return 0.0;\n }`;case"tf_half_pixel_for_nn":return`return (${e}(xResized) + 0.5) / ${e}(xScale);`;case"align_corners":return`if (lengthResized == 1) {\n return 0.0;\n } else {\n // The whole part and the fractional part are calculated separately due to inaccuracy of floating\n // point division. As an example, f32(21) / f32(7) may evaluate to 2.99... instead of 3, causing an\n // offset-by-one error later in floor().\n let whole = ${e}(xResized * (lengthOriginal - 1) / (lengthResized - 1));\n let fract =\n ${e}(xResized * (lengthOriginal - 1) % (lengthResized - 1)) / ${e}(lengthResized - 1);\n return whole + fract;\n }`;case"tf_crop_and_resize":return`if (lengthResized > 1) {\n return ${e}(roiStart) * ${e}(lengthOriginal - 1) +\n (${e}(xResized) * ${e}(roiEnd - roiStart) * ${e}(lengthOriginal - 1)) /\n ${e}(lengthResized - 1);\n } else {\n return 0.5 * ${e}(roiStart + roiEnd) * ${e}(lengthOriginal - 1);\n }`;case"half_pixel_symmetric":return`const outputWidth = ${e}xScale * ${e}(lengthResized);\n const adjustment = ${e}(lengthResized) / outputWidth;\n const center = ${e}(lengthOriginal) / 2;\n const offset = center * (1 - adjustment);\n return offset + ((${e}(xResized) + 0.5) / ${e}(xScale)) - 0.5;`;case"half_pixel":return`return ((${e}(xResized) + 0.5) / ${e}(xScale)) - 0.5;`;default:throw new Error(`Coordinate transform mode ${t} is not supported`)}})()+"}",ma=(t,e,n)=>`fn getNearestPixelFromOriginal(xOriginal: ${n}, isDownSample: bool) -> ${n} {`+(()=>{switch(t){case"round_prefer_ceil":return"if (fract(xOriginal) == 0.5) { return ceil(xOriginal); } else { return round(xOriginal); }";case"floor":return"return floor(xOriginal);";case"ceil":return"return ceil(xOriginal);";case"round_prefer_floor":return"if (fract(xOriginal) == 0.5) { return floor(xOriginal); } else { return round(xOriginal); }";default:if(e<11)return"if (isDownSample) { return ceil(xOriginal); } else { return xOriginal; }";throw new Error(`Nearest mode ${t} is not supported`)}})()+"}",wa=(t,e,n)=>{let i=new Array(n).fill(0).concat(new Array(n).fill(1)),r=0===t.length?i:t.slice();return e.length>0?(e.forEach(((t,s)=>{i[t]=r[s],i[s+n]=r[e.length+s]})),i):r},ga=(t,e,n,i)=>{let r=[];if(n.length>0)if(i.length>0){if(t.forEach((t=>r.push(t))),Math.max(...i)>t.length)throw new Error("axes is out of bound");i.forEach(((t,e)=>r[t]=n[e]))}else n.forEach((t=>r.push(t)));else{if(0===e.length)throw new Error("Resize requires either scales or sizes.");r=t.map(((t,n)=>Math.round(t*e[n])))}return r},ba=(t,e,n)=>{let i=(()=>{switch(n.keepAspectRatioPolicy){case"not_larger":return n.axes.length>0?Math.min(...n.axes.map((t=>e[t])),Number.MAX_VALUE):Math.min(...e,Number.MAX_VALUE);case"not_smaller":return n.axes.length>0?Math.max(...n.axes.map((t=>e[t])),Number.MIN_VALUE):Math.max(...e,Number.MIN_VALUE);default:throw new Error(`Keep aspect ratio policy ${n.keepAspectRatioPolicy} is not supported`)}})();e.fill(1,0,e.length);let r=t.slice();return n.axes.length>0?(n.axes.forEach((t=>e[t]=i)),n.axes.forEach((n=>r[n]=Math.round(t[n]*e[n])))):(e.fill(i,0,e.length),r.forEach(((t,n)=>r[n]=Math.round(t*e[n])))),r},xa=(t,e,n,i,r)=>`\n fn calculateOriginalIndicesFromOutputIndices(output_indices: ${t.type.indices}) -> array<${t.type.value}, ${n.length}> {\n var original_indices: array<${t.type.value}, ${n.length}>;\n for (var i:u32 = 0; i < ${n.length}; i++) {\n var output_index = ${t.indicesGet("output_indices","i")};\n var scale = ${Fe("uniforms.scales","i",i)};\n var roi_low = ${Fe("uniforms.roi","i",r)};\n var roi_hi = ${Fe("uniforms.roi",`i + ${e.length}`,r)};\n if (scale == 1.0) {\n original_indices[i] = ${t.type.value}(output_index);\n } else {\n var input_shape_i = ${Fe("uniforms.input_shape","i",e.length)};\n var output_shape_i = ${Fe("uniforms.output_shape","i",n.length)};\n original_indices[i] = getOriginalCoordinateFromResizedCoordinate(output_index, scale, output_shape_i,\n input_shape_i, roi_low, roi_hi);\n }\n }\n return original_indices;\n }`,_a=(t,e,n,i,r,s,o)=>`\n fn calculateInputIndicesFromOutputIndices(output_indices: ${e.type.indices}) -> ${t.type.indices} {\n var input_indices: ${t.type.indices};\n for (var i:u32 = 0; i < ${i.length}; i++) {\n var output_index = ${e.indicesGet("output_indices","i")};\n var input_index: u32;\n var scale = ${Fe("uniforms.scales","i",r)};\n if (scale == 1.0) {\n input_index = output_index;\n } else {\n var roi_low = ${Fe("uniforms.roi","i",s)};\n var roi_hi = ${Fe("uniforms.roi",`i + ${n.length}`,s)};\n var input_shape_i = ${Fe("uniforms.input_shape","i",n.length)};\n var output_shape_i = ${Fe("uniforms.output_shape","i",i.length)};\n var original_idx = getOriginalCoordinateFromResizedCoordinate(output_index, scale, output_shape_i,\n input_shape_i, roi_low, roi_hi);\n if (!${o} || (original_idx >= 0 && original_idx < ${e.type.value}(input_shape_i))) {\n if (original_idx < 0) {\n input_index = 0;\n } else if (original_idx > ${e.type.value}(input_shape_i - 1)) {\n input_index = input_shape_i - 1;\n } else {\n input_index = u32(getNearestPixelFromOriginal(original_idx, scale < 1));\n }\n } else {\n input_index = u32(original_idx);\n }\n }\n ${t.indicesSet("input_indices","i"," input_index")}\n }\n return input_indices;\n }`,ka=(t,e)=>`\n fn checkInputIndices(input_indices: ${t.type.indices}) -> bool {\n for (var i:u32 = 0; i < ${e.length}; i++) {\n var input_index = ${t.indicesGet("input_indices","i")};\n if (input_index < 0 || input_index >= ${Fe("uniforms.input_shape","i",e.length)}) {\n return false;\n }\n }\n return true;\n }`,$a=(t,e,n,i)=>t.rank>i?`\n ${t.indicesSet("input_indices",e,"channel")};\n ${t.indicesSet("input_indices",n,"batch")};\n`:"",Sa=(t,e,n,i,r)=>{let[s,o,a,u]=2===n.length?[-1,0,1,-1]:[0,2,3,1],h=t.type.value;return`\n fn getInputValue(batch: u32, channel: u32, row: u32, col: u32) -> ${h} {\n var input_indices: ${t.type.indices};\n ${t.indicesSet("input_indices",o,`max(0, min(row, ${n[o]} - 1))`)};\n ${t.indicesSet("input_indices",a,`max(0, min(col, ${n[a]} - 1))`)};\n ${$a(t,u,s,2)}\n return ${t.getByIndices("input_indices")};\n }\n\n fn bilinearInterpolation(output_indices: ${e.type.indices}) -> ${h} {\n var originalIndices = calculateOriginalIndicesFromOutputIndices(output_indices);\n var row:${h} = originalIndices[${o}];\n var col:${h} = originalIndices[${a}];\n ${i?`if (row < 0 || row > (${n[o]} - 1) || col < 0 || col > (${n[a]} - 1)) {\n return ${r};\n }`:""};\n row = max(0, min(row, ${n[o]} - 1));\n col = max(0, min(col, ${n[a]} - 1));\n var row1: u32 = u32(row);\n var col1: u32 = u32(col);\n var row2: u32 = u32(row + 1);\n var col2: u32 = u32(col + 1);\n var channel: u32 = ${n.length>2?`u32(originalIndices[${u}])`:"0"};\n var batch: u32 = ${n.length>2?`u32(originalIndices[${s}])`:"0"};\n var x11: ${h} = getInputValue(batch, channel, row1, col1);\n var x12: ${h} = getInputValue(batch, channel, row1, col2);\n var x21: ${h} = getInputValue(batch, channel, row2, col1);\n var x22: ${h} = getInputValue(batch, channel, row2, col2);\n var dx1: ${h} = abs(row - ${h}(row1));\n var dx2: ${h} = abs(${h}(row2) - row);\n var dy1: ${h} = abs(col - ${h}(col1));\n var dy2: ${h} = abs(${h}(col2) - col);\n if (row1 == row2) {\n dx1 = 0.5;\n dx2 = 0.5;\n }\n if (col1 == col2) {\n dy1 = 0.5;\n dy2 = 0.5;\n }\n return (x11 * dx2 * dy2 + x12 * dx2 * dy1 + x21 * dx1 * dy2 + x22 * dx1 * dy1);\n }`},Ma=(t,e,n,i,r,s,o,a,u,h)=>{let l=2===n.length,[c,f]=l?[0,1]:[2,3],d=t.type.value,p=o=>{let l=o===c?"row":"col";return`\n fn ${l}CubicInterpolation(input_indices: ${t.type.indices}, output_indices: ${e.type.indices}) -> ${d} {\n var output_index = ${e.indicesGet("output_indices",o)};\n var originalIdx: ${d} = getOriginalCoordinateFromResizedCoordinate(output_index, ${r[o]},\n ${i[o]}, ${n[o]}, ${s[o]}, ${s[o]} + ${n.length});\n var fractOriginalIdx: ${d} = originalIdx - floor(originalIdx);\n var coefs = getCubicInterpolationCoefs(fractOriginalIdx);\n\n if (${a} && (originalIdx < 0 || originalIdx > (${n[o]} - 1))) {\n return ${u};\n }\n var data: array<${d}, 4> = array<${d}, 4>(0.0, 0.0, 0.0, 0.0);\n for (var i: i32 = -1; i < 3; i++) {\n var ${l}: ${d} = originalIdx + ${d}(i);\n if (${l} < 0 || ${l} >= ${n[o]}) {\n ${h?"coefs[i + 1] = 0.0;\n continue;":a?`return ${u};`:`${l} = max(0, min(${l}, ${n[o]} - 1));`};\n }\n var input_indices_copy: ${t.type.indices} = input_indices;\n ${t.indicesSet("input_indices_copy",o,`u32(${l})`)};\n data[i + 1] = ${o===c?t.getByIndices("input_indices_copy"):"rowCubicInterpolation(input_indices_copy, output_indices)"};\n }\n return cubicInterpolation1D(data, coefs);\n }`};return`\n ${p(c)};\n ${p(f)};\n fn getCubicInterpolationCoefs(s: ${d}) -> array<${d}, 4> {\n var absS = abs(s);\n var coeffs: array<${d}, 4> = array<${d}, 4>(0.0, 0.0, 0.0, 0.0);\n var oneMinusAbsS: ${d} = 1.0 - absS;\n var twoMinusAbsS: ${d} = 2.0 - absS;\n var onePlusAbsS: ${d} = 1.0 + absS;\n coeffs[0] = ((${o} * onePlusAbsS - 5 * ${o}) * onePlusAbsS + 8 * ${o}) * onePlusAbsS - 4 * ${o};\n coeffs[1] = ((${o} + 2) * absS - (${o} + 3)) * absS * absS + 1;\n coeffs[2] = ((${o} + 2) * oneMinusAbsS - (${o} + 3)) * oneMinusAbsS * oneMinusAbsS + 1;\n coeffs[3] = ((${o} * twoMinusAbsS - 5 * ${o}) * twoMinusAbsS + 8 * ${o}) * twoMinusAbsS - 4 * ${o};\n return coeffs;\n }\n\n fn cubicInterpolation1D(x: array<${d}, 4>, coefs: array<${d}, 4>) -> ${d} {\n var coefsSum: ${d} = coefs[0] + coefs[1] + coefs[2] + coefs[3];\n return (x[0] * coefs[0] + x[1] * coefs[1]+ x[2] * coefs[2]+ x[3] * coefs[3]) / coefsSum;\n }\n\n fn bicubicInterpolation(output_indices: ${e.type.indices}) -> ${d} {\n var input_indices: ${t.type.indices} = output_indices;\n return colCubicInterpolation(input_indices, output_indices);\n }\n `},Ea=(t,e,n,i,r)=>{let[s,o,a,u,h]=3===n.length?[-1,0,1,2,-1]:[0,2,3,4,1],l=t.type.value;return`\n fn getInputValue(batch: u32, channel: u32, depth:u32, height: u32, width: u32) -> ${l} {\n var input_indices: ${t.type.indices};\n ${t.indicesSet("input_indices",o,`max(0, min(depth, ${n[o]} - 1))`)};\n ${t.indicesSet("input_indices",a,`max(0, min(height, ${n[a]} - 1))`)};\n ${t.indicesSet("input_indices",u,`max(0, min(width, ${n[u]} - 1))`)};\n ${$a(t,h,s,3)}\n return ${t.getByIndices("input_indices")};\n }\n\n fn trilinearInterpolation(output_indices: ${e.type.indices}) -> ${l} {\n var originalIndices = calculateOriginalIndicesFromOutputIndices(output_indices);\n var depth:${l} = originalIndices[${o}];\n var height:${l} = originalIndices[${a}];\n var width:${l} = originalIndices[${u}];\n ${i?`if (depth < 0 || depth > (${n[o]} - 1) || height < 0 || height > (${n[a]} - 1) || width < 0 || (width > ${n[u]} - 1)) {\n return ${r};\n }`:""};\n\n depth = max(0, min(depth, ${n[o]} - 1));\n height = max(0, min(height, ${n[a]} - 1));\n width = max(0, min(width, ${n[u]} - 1));\n var depth1: u32 = u32(depth);\n var height1: u32 = u32(height);\n var width1: u32 = u32(width);\n var depth2: u32 = u32(depth + 1);\n var height2: u32 = u32(height + 1);\n var width2: u32 = u32(width + 1);\n var channel: u32 = ${n.length>3?`u32(originalIndices[${h}])`:"0"};\n var batch: u32 = ${n.length>3?`u32(originalIndices[${s}])`:"0"};\n\n var x111: ${l} = getInputValue(batch, channel, depth1, height1, width1);\n var x112: ${l} = getInputValue(batch, channel, depth1, height1, width2);\n var x121: ${l} = getInputValue(batch, channel, depth1, height2, width1);\n var x122: ${l} = getInputValue(batch, channel, depth1, height2, width2);\n var x211: ${l} = getInputValue(batch, channel, depth2, height1, width1);\n var x212: ${l} = getInputValue(batch, channel, depth2, height1, width2);\n var x221: ${l} = getInputValue(batch, channel, depth2, height2, width1);\n var x222: ${l} = getInputValue(batch, channel, depth2, height2, width2);\n var dx1: ${l} = abs(depth - ${l}(depth1));\n var dx2: ${l} = abs(${l}(depth2) - depth);\n var dy1: ${l} = abs(height - ${l}(height1));\n var dy2: ${l} = abs(${l}(height2) - height);\n var dz1: ${l} = abs(width - ${l}(width1));\n var dz2: ${l} = abs(${l}(width2) - width);\n if (depth1 == depth2) {\n dx1 = 0.5;\n dx2 = 0.5;\n }\n if (height1 == height2) {\n dy1 = 0.5;\n dy2 = 0.5;\n }\n if (width1 == width2) {\n dz1 = 0.5;\n dz2 = 0.5;\n }\n return (x111 * dx2 * dy2 * dz2 + x112 * dx2 * dy2 * dz1 + x121 * dx2 * dy1 *dz2 + x122 * dx2 * dy1 * dz1 +\n x211 * dx1 * dy2 * dz2 + x212 * dx1 * dy2 * dz1 + x221 * dx1 * dy1 *dz2 + x222 * dx1 * dy1 * dz1);\n }`},Ca=(t,e,n,i,r,s)=>{let o=t.dims,a=wa(s,e.axes,o.length),u=ga(o,i,r,e.axes),h=i.slice();0===i.length&&(h=o.map(((t,e)=>0===t?1:u[e]/t)),"stretch"!==e.keepAspectRatioPolicy&&(u=ba(o,h,e)));let l=je("output",t.dataType,u.length),c=qe("input",t.dataType,o.length),f=$e.size(u),d=o.length===u.length&&o.every(((t,e)=>t===u[e])),p="tf_crop_and_resize"===e.coordinateTransformMode,v=e.extrapolationValue,y=c.type.value;return{name:"Resize",shaderCache:{hint:`${e.cacheKey}|${n}|${h.length>0?h:""}|${r.length>0?r:""}|${a.length>0?a:""}|${d}|${o}`,inputDependencies:["rank"]},getShaderSource:t=>`\n ${d?"":`\n ${ya(e.coordinateTransformMode,y)};\n ${(()=>{switch(e.mode){case"nearest":return`\n ${ka(c,o)};\n ${ma(e.nearestMode,n,y)};\n ${_a(c,l,o,u,h.length,a.length,p)};\n `;case"linear":return`\n ${xa(l,o,u,h.length,a.length)};\n ${(()=>{if(2===o.length||4===o.length)return`${Sa(c,l,o,p,v)}`;if(3===o.length||5===o.length)return`${Ea(c,l,o,p,v)}`;throw Error("Linear mode only supports input dims 2, 3, 4 and 5 are supported in linear mode.")})()};\n `;case"cubic":return`\n ${(()=>{if(2===o.length||4===o.length)return`${Ma(c,l,o,u,h,a,e.cubicCoeffA,p,e.extrapolationValue,e.excludeOutside)}`;throw Error("Cubic mode only supports input dims 2 and 4 are supported in linear mode.")})()};\n `;default:throw Error("Invalid resize mode")}})()};\n `}\n ${t.registerUniform("output_size","u32").registerUniform("scales","f32",h.length).registerUniform("roi","f32",a.length).declareVariables(c,l)}\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.output_size")}\n ${d?"output[global_idx] = input[global_idx];":`\n let output_indices = ${l.offsetToIndices("global_idx")};\n var input_indices: ${c.type.indices};\n ${(()=>{switch(e.mode){case"nearest":return`input_indices = calculateInputIndicesFromOutputIndices(output_indices);\n if (checkInputIndices(input_indices)) {\n output[global_idx] = ${c.getByIndices("input_indices")};\n } else {\n output[global_idx] = ${e.extrapolationValue};\n }`;case"linear":return`output[global_idx] = ${2===o.length||4===o.length?"bilinearInterpolation":"trilinearInterpolation"}(output_indices);`;case"cubic":return"output[global_idx] = bicubicInterpolation(output_indices);";default:throw Error(`Unsupported resize mode: ${e.mode}`)}})()};\n`}\n }`,getRunData:()=>({outputs:[{dims:u,dataType:t.dataType}],dispatchGroup:{x:Math.ceil(f/64)},programUniforms:[{type:12,data:f},{type:1,data:h},{type:1,data:a},...ze(o,u)]})}},Aa=t=>{let e=t.customDataBuffer;return new Uint32Array(e,e.byteOffset,1)[0]},Ia=(t,e)=>{let n=[],i=[],r=[],s=Aa(t);if(0!==e.antialias)throw Error("Only default value (0) for Antialias attribute is supported");va(t.inputs,e,s,n,i,r),t.compute(Ca(t.inputs[0],e,s,n,i,r),{inputs:[0]})},Oa=t=>{let e=t.antialias,n=t.axes,i=t.coordinateTransformMode,r=t.cubicCoeffA,s=0!==t.excludeOutside,o=t.extrapolationValue,a=t.keepAspectRatioPolicy,u=t.mode,h=""===t.nearestMode?"simple":t.nearestMode;return xe({antialias:e,axes:n,coordinateTransformMode:i,cubicCoeffA:r,excludeOutside:s,extrapolationValue:o,keepAspectRatioPolicy:a,mode:u,nearestMode:h})}})),ph=V((()=>{wu(),Su(),$u(),Mu(),Ta=(t,e)=>{let[n,i,r,s]=t,{numHeads:o,rotaryEmbeddingDim:a}=e;if(3!==n.dims.length&&4!==n.dims.length)throw new Error(`Input 'x' is expected to have 3 or 4 dimensions, got ${n.dims.length}`);if(!$e.areEqual(i.dims,[])&&!$e.areEqual(i.dims,[1])&&2!==i.dims.length)throw new Error(`Input 'position_ids' is expected to have 0, 1, or 2 dimensions, got ${i.dims.length}`);if(2!==r.dims.length)throw new Error(`Input 'cos_cache' is expected to have 2 dimensions, got ${r.dims.length}`);if(2!==s.dims.length)throw new Error(`Input 'sin_cache' is expected to have 2 dimensions, got ${s.dims.length}`);if(!$e.areEqual(r.dims,s.dims))throw new Error("Inputs 'cos_cache' and 'sin_cache' are expected to have the same shape");if(a>0&&0===o)throw new Error("num_heads must be provided if rotary_embedding_dim is specified");let u=n.dims[0],h=n.dims[n.dims.length-2],l=r.dims[0],c=$e.sizeFromDimension(n.dims,1)/h,f=0===a?2*r.dims[1]:c/o;if(a>f)throw new Error("rotary_embedding_dim must be less than or equal to head_size");if(2===i.dims.length){if(u!==i.dims[0])throw new Error(`Input 'position_ids' dimension 0 should be of size batch_size, got ${i.dims[0]}`);if(h!==i.dims[1])throw new Error(`Input 'position_ids' dimension 1 should be of size sequence_length, got ${i.dims[1]}`)}if(f/2!==r.dims[1]&&a/2!==r.dims[1])throw new Error(`Input 'cos_cache' dimension 1 should be same as head_size / 2 or rotary_embedding_dim / 2, got ${r.dims[1]}`);if(h>l)throw new Error("Updating cos_cache and sin_cache in RotaryEmbedding is not currently supported")},za=(t,e)=>{let{interleaved:n,numHeads:i,rotaryEmbeddingDim:r,scale:s}=e,o=t[0].dims[0],a=$e.sizeFromDimension(t[0].dims,1),u=t[0].dims[t[0].dims.length-2],h=a/u,l=t[2].dims[1],c=0===r?2*l:h/i,f=new Array(o,u,h/c,c-l),d=$e.computeStrides(f),p=[{type:1,data:s},{type:12,data:f},{type:12,data:d},...3===t[0].dims.length?new Array({type:12,data:[a,h,c,1]}):[],...4===t[0].dims.length?new Array({type:12,data:[a,c,u*c,1]}):[],...ze(t[0].dims,t[1].dims,t[2].dims,t[3].dims,t[0].dims)];return{name:"RotaryEmbedding",shaderCache:{hint:xe({interleaved:n}).cacheKey,inputDependencies:["rank","rank","rank","rank"]},getShaderSource:e=>{let i=qe("input",t[0].dataType,t[0].dims.length),r=qe("position_ids",t[1].dataType,t[1].dims.length),s=qe("cos_cache",t[2].dataType,t[2].dims.length),o=qe("sin_cache",t[3].dataType,t[3].dims.length),a=je("output",t[0].dataType,t[0].dims.length);return e.registerUniforms([{name:"scale",type:"f32"},{name:"global_shape",type:"u32",length:f.length},{name:"global_strides",type:"u32",length:d.length},{name:"input_output_strides",type:"u32",length:d.length}]),`\n ${e.declareVariables(i,r,s,o,a)}\n\n ${e.mainStart(Ae)}\n let half_rotary_emb_dim = uniforms.${s.name}_shape[1];\n let bsnh = global_idx / uniforms.global_strides % uniforms.global_shape;\n let size = uniforms.global_shape[0] * uniforms.global_strides[0];\n ${e.guardAgainstOutOfBoundsWorkgroupSizes("size")}\n\n if (bsnh[3] < half_rotary_emb_dim) {\n let position_ids_idx =\n ${r.broadcastedIndicesToOffset("bsnh.xy",je("",r.type.tensor,2))};\n let position_id =\n u32(${r.getByOffset("position_ids_idx")}) + select(0, bsnh[1], position_ids_idx == 0);\n let i = dot(bsnh, uniforms.input_output_strides) + select(0, bsnh[3], ${n});\n let j = i + select(half_rotary_emb_dim, 1, ${n});\n let re = ${i.getByOffset("i")} * ${s.get("position_id","bsnh[3]")} -\n ${i.getByOffset("j")} * ${o.get("position_id","bsnh[3]")};\n ${a.setByOffset("i","re")}\n let im = ${i.getByOffset("i")} * ${o.get("position_id","bsnh[3]")} +\n ${i.getByOffset("j")} * ${s.get("position_id","bsnh[3]")};\n ${a.setByOffset("j","im")}\n } else {\n let k = dot(bsnh, uniforms.input_output_strides) + half_rotary_emb_dim;\n ${a.setByOffset("k",i.getByOffset("k"))}\n }\n }`},getRunData:()=>({outputs:[{dims:t[0].dims,dataType:t[0].dataType}],dispatchGroup:{x:Math.ceil($e.size(f)/Ae)},programUniforms:p})}},Da=(t,e)=>{Ta(t.inputs,e),t.compute(za(t.inputs,e))}})),vh=V((()=>{wu(),Su(),Mu(),Pa=t=>{if(!t||t.length<3)throw new Error("layerNorm requires at least 3 inputs.");let e=t[0],n=t[1],i=t[2];if(e.dataType!==n.dataType||e.dataType!==i.dataType)throw new Error("All inputs must have the same data type");if(3!==e.dims.length&&2!==e.dims.length)throw new Error("Input must be 2D or 3D");if(3!==n.dims.length&&2!==n.dims.length)throw new Error("Skip must be 2D or 3D");let r=e.dims[e.dims.length-1],s=e.dims[e.dims.length-2];if(n.dims[n.dims.length-1]!==r)throw new Error("Skip must have the same hidden size as input");if(n.dims[n.dims.length-2]!==s)throw new Error("Skip must have the same sequence length as input");if(1!==i.dims.length)throw new Error("Gamma must be 1D");if(i.dims[i.dims.length-1]!==r)throw new Error("Gamma must have the same hidden size as input");if(t.length>3){let e=t[3];if(1!==e.dims.length)throw new Error("Beta must be 1D");if(e.dims[e.dims.length-1]!==r)throw new Error("Beta must have the same hidden size as input")}if(t.length>4){let e=t[4];if(1!==e.dims.length)throw new Error("Bias must be 1D");if(e.dims[e.dims.length-1]!==r)throw new Error("Bias must have the same hidden size as input")}},Ra=(t,e,n,i)=>{let r=e.simplified,s=t[0].dims,o=$e.size(s),a=s,u=o,h=s.slice(-1)[0],l=i?s.slice(0,-1).concat(1):[],c=!r&&t.length>3,f=t.length>4,d=i&&n>1,p=i&&n>2,v=n>3,y=De(h),m=[{type:12,data:u},{type:12,data:y},{type:12,data:h},{type:1,data:e.epsilon}],w=[{dims:a,dataType:t[0].dataType}];return n>1&&w.push({dims:l,dataType:1}),n>2&&w.push({dims:l,dataType:1}),n>3&&w.push({dims:s,dataType:t[0].dataType}),{name:"SkipLayerNormalization",shaderCache:{hint:`${y};${d};${p};${v}`,inputDependencies:t.map(((t,e)=>"type"))},getShaderSource:e=>{let n=[qe("x",t[0].dataType,t[0].dims,y),qe("skip",t[1].dataType,t[1].dims,y),qe("gamma",t[2].dataType,t[2].dims,y)];c&&n.push(qe("beta",t[3].dataType,t[3].dims,y)),f&&n.push(qe("bias",t[4].dataType,t[4].dims,y)),n.push(je("output",t[0].dataType,a,y)),d&&n.push(je("mean_output",1,l)),p&&n.push(je("inv_std_output",1,l)),v&&n.push(je("input_skip_bias_sum",t[0].dataType,a,y));let i=Oe(t[0].dataType),s=Oe(1,y);return`\n\n ${e.registerUniforms([{name:"output_size",type:"u32"},{name:"components",type:"u32"},{name:"hidden_size",type:"u32"},{name:"epsilon",type:"f32"}]).declareVariables(...n)}\n var<workgroup> sum_shared : array<${s}, 64>;\n var<workgroup> sum_squared_shared : array<${s}, 64>;\n\n ${e.mainStart([64,1,1])}\n let ix = local_id.x;\n let iy = global_id.x / 64;\n\n let hidden_size_vectorized: u32 = uniforms.hidden_size / uniforms.components;\n var stride = hidden_size_vectorized / 64;\n let offset = ix * stride + iy * hidden_size_vectorized;\n let offset1d = stride * ix;\n if (ix == 63) {\n stride = hidden_size_vectorized - stride * ix;\n }\n for (var i: u32 = 0; i < stride; i++) {\n let skip_value = skip[offset + i];\n let bias_value = ${f?"bias[offset1d + i]":i+"(0.0)"};\n let input_value = x[offset + i];\n let value = input_value + skip_value + bias_value;\n ${v?"input_skip_bias_sum[offset + i] = value;":""}\n output[offset + i] = value;\n let f32_value = ${Re(i,y,"value")};\n sum_shared[ix] += f32_value;\n sum_squared_shared[ix] += f32_value * f32_value;\n }\n workgroupBarrier();\n\n var reduce_size : u32 = 64;\n for (var curr_size = reduce_size >> 1; curr_size > 0; curr_size = reduce_size >> 1) {\n reduce_size = curr_size + (reduce_size & 1);\n if (ix < curr_size) {\n sum_shared[ix] += sum_shared[ix + reduce_size];\n sum_squared_shared[ix] += sum_squared_shared[ix + reduce_size];\n }\n workgroupBarrier();\n }\n\n let sum = sum_shared[0];\n let square_sum = sum_squared_shared[0];\n let mean = ${Ne("sum",y)} / f32(uniforms.hidden_size);\n let inv_std_dev = inverseSqrt(${Ne("square_sum",y)} / f32(uniforms.hidden_size) ${r?"":"- mean * mean"} + uniforms.epsilon);\n ${d?"mean_output[global_idx] = mean;":""}\n ${p?"inv_std_output[global_idx] = inv_std_dev;":""}\n\n for (var i: u32 = 0; i < stride; i++) {\n output[offset + i] = (output[offset + i] ${r?"":`- ${i}(mean)`}) *\n ${i}(inv_std_dev) * gamma[offset1d + i]\n ${c?"+ beta[offset1d + i]":""};\n }\n }`},getRunData:()=>({outputs:w,dispatchGroup:{x:Math.ceil(u/h)},programUniforms:m})}},Na=(t,e)=>{Pa(t.inputs);let n=[0];t.outputCount>1&&n.push(-3),t.outputCount>2&&n.push(-3),t.outputCount>3&&n.push(3),t.compute(Ra(t.inputs,e,t.outputCount,!1),{outputs:n})}})),yh=V((()=>{wu(),Su(),$u(),Mu(),Fa=(t,e)=>{if(!t||t.length<1)throw new Error("too few inputs");if(0!==e.axes.length){if(e.axes.length!==e.starts.length||e.axes.length!==e.ends.length)throw new Error("axes, starts and ends must have the same length")}else if(e.starts.length!==e.ends.length)throw new Error("starts and ends must have the same length");t.slice(1).forEach(((e,n)=>{if(6!==t[n+1].dataType&&7!==t[n+1].dataType)throw new Error(`Input ${n} must be an array of int32 or int64`)}))},Ua=(t,e)=>{let n=[];if(t.length>e)if(7===t[e].dataType)t[e].getBigInt64Array().forEach((t=>n.push(Number(t))));else{if(6!==t[e].dataType)throw new Error(`Input ${e} must be an array of int32 or int64`);t[e].getInt32Array().forEach((t=>n.push(Number(t))))}return n},qa=(t,e)=>{if(t.length>1){let e=Ua(t,1),n=Ua(t,2),i=Ua(t,3);return 0===i.length&&(i=[...Array(t[0].dims.length).keys()]),xe({starts:e,ends:n,axes:i})}return e},ja=(t,e,n,i,r)=>{let s=t;return t<0&&(s+=n[i[e]]),r[e]<0?Math.max(0,Math.min(s,n[i[e]]-1)):Math.max(0,Math.min(s,n[i[e]]))},Ba=(t,e,n)=>`fn calculateInputIndices(output_indices: ${e.type.indices}) -> ${t.type.indices} {\n var input_indices: ${t.type.indices};\n var carry = 0u;\n for (var i = ${n.length}; i >= 0; i--) {\n let input_shape_i = ${Fe("uniforms.input_shape","i",n.length)};\n let steps_i = ${Fe("uniforms.steps","i",n.length)};\n let signs_i = ${Fe("uniforms.signs","i",n.length)};\n let starts_i = ${Fe("uniforms.starts","i",n.length)};\n var output_index = ${e.indicesGet("output_indices","i")};\n var input_index = output_index * steps_i + starts_i + carry;\n carry = input_index / input_shape_i;\n input_index = input_index % input_shape_i;\n if (signs_i < 0) {\n input_index = input_shape_i - input_index - 1u + starts_i;\n }\n ${t.indicesSet("input_indices","i","input_index")};\n }\n return input_indices;\n }`,La=(t,e)=>{let n=t[0].dims,i=$e.size(n),r=e.axes.length>0?$e.normalizeAxes(e.axes,n.length):[...Array(n.length).keys()],s=Ua(t,4);s.forEach((t=>0!==t||(()=>{throw new Error("step cannot be 0")}))),0===s.length&&(s=Array(r.length).fill(1));let o=e.starts.map(((t,e)=>ja(t,e,n,r,s))),a=e.ends.map(((t,e)=>ja(t,e,n,r,s)));if(r.length!==o.length||r.length!==a.length)throw new Error("start, ends and axes should have the same number of elements");if(r.length!==n.length)for(let t=0;t<n.length;++t)r.includes(t)||(o.splice(t,0,0),a.splice(t,0,n[t]),s.splice(t,0,1));let u=s.map((t=>Math.sign(t)));s.forEach(((t,e,n)=>{if(t<0){let i=(a[e]-o[e])/t,r=o[e],u=r+i*s[e];o[e]=u,a[e]=r,n[e]=-t}}));let h=n.slice(0);r.forEach(((t,e)=>{h[t]=Math.ceil((a[t]-o[t])/s[t])}));let l={dims:h,dataType:t[0].dataType},c=je("output",t[0].dataType,h.length),f=qe("input",t[0].dataType,t[0].dims.length),d=$e.size(h),p=[{name:"outputSize",type:"u32"},{name:"starts",type:"u32",length:o.length},{name:"signs",type:"i32",length:u.length},{name:"steps",type:"u32",length:s.length}],v=[{type:12,data:d},{type:12,data:o},{type:6,data:u},{type:12,data:s},...ze(t[0].dims,h)];return{name:"Slice",shaderCache:{hint:`${u.length}_${o.length}_${s.length}`,inputDependencies:["rank"]},getShaderSource:t=>`\n ${t.registerUniforms(p).declareVariables(f,c)}\n ${Ba(f,c,n)}\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}\n let output_indices = ${c.offsetToIndices("global_idx")};\n let input_indices = calculateInputIndices(output_indices);\n ${c.setByOffset("global_idx",f.getByIndices("input_indices"))}\n }`,getRunData:()=>({outputs:[l],dispatchGroup:{x:Math.ceil(i/64)},programUniforms:v})}},Ha=(t,e)=>{Fa(t.inputs,e);let n=qa(t.inputs,e);t.compute(La(t.inputs,n),{inputs:[0]})},Va=t=>{let e=t.starts,n=t.ends,i=t.axes;return xe({starts:e,ends:n,axes:i})}})),mh=V((()=>{wu(),Su(),$u(),Mu(),Wa=t=>{if(!t||1!==t.length)throw new Error("Softmax op requires 1 input.")},Ga=(t,e)=>{let n=t.dims,i=$e.size(n),r=e.axis;if(r<0&&(r=n.length+r),r<n.length-1)throw new Error("softmax only supports last axis for now.");let s=n[r],o=i/s,a=De(s),u=s/a,h=qe("x",t.dataType,t.dims,a),l=je("result",t.dataType,t.dims,a),c=h.type.value,f="f32"===Oe(t.dataType)?`var threadMax = ${c}(-3.402823e+38f);`:`var threadMax = ${c}(-65504.0h);`;return{name:"Softmax",shaderCache:{hint:`${a}`,inputDependencies:["type"]},getRunData:()=>({outputs:[{dims:n,dataType:t.dataType}],dispatchGroup:{x:o},programUniforms:[{type:6,data:u}]}),getShaderSource:t=>`\n var<workgroup> rowMaxShared : ${c};\n var<workgroup> rowSumShared : ${c};\n var<workgroup> threadShared : array<${c}, 64>;\n\n fn getValue(row: i32, col: i32, row_stride: i32) -> ${c} {\n let index = row * row_stride + col;\n return x[index];\n }\n\n fn setValue(row: i32, col: i32, row_stride: i32, value: ${c}) {\n let index = row * row_stride + col;\n result[index] = value;\n }\n ${t.registerUniform("packedCols","i32").declareVariables(h,l)}\n ${t.mainStart()}\n let gindex = i32(global_idx);\n let lindex = i32(local_idx);\n const wg = 64;\n let row = gindex / wg;\n let cols = uniforms.packedCols;\n let row_stride : i32 = uniforms.packedCols;\n\n // find the rows max\n ${f}\n for (var col = lindex; col < cols; col += wg) {\n let value = getValue(row, col, row_stride);\n threadMax = max(threadMax, value);\n }\n if (lindex < cols) {\n threadShared[lindex] = threadMax;\n }\n workgroupBarrier();\n\n var reduceSize = min(cols, wg);\n for (var currSize = reduceSize >> 1; currSize > 0; currSize = reduceSize >> 1) {\n reduceSize = currSize + (reduceSize & 1);\n if (lindex < currSize) {\n threadShared[lindex] = max(threadShared[lindex], threadShared[lindex + reduceSize]);\n }\n workgroupBarrier();\n }\n if (lindex == 0) {\n rowMaxShared = ${c}(${((t,e)=>4===e?`max(max(${t}.x, ${t}.y), max(${t}.z, ${t}.w))`:2===e?`max(${t}.x, ${t}.y)`:3===e?`max(max(${t}.x, ${t}.y), ${t}.z)`:t)("threadShared[0]",a)});\n }\n workgroupBarrier();\n\n // find the rows sum\n var threadSum = ${c}(0.0);\n for (var col = lindex; col < cols; col += wg) {\n let subExp = exp(getValue(row, col, row_stride) - rowMaxShared);\n threadSum += subExp;\n }\n threadShared[lindex] = threadSum;\n workgroupBarrier();\n\n for (var currSize = wg >> 1; currSize > 0; currSize = currSize >> 1) {\n if (lindex < currSize) {\n threadShared[lindex] = threadShared[lindex] + threadShared[lindex + currSize];\n }\n workgroupBarrier();\n }\n if (lindex == 0) {\n rowSumShared = ${c}(${Ne("threadShared[0]",a)});\n }\n workgroupBarrier();\n\n // calculate final value for each element in the row\n for (var col = lindex; col < cols; col += wg) {\n let value = exp(getValue(row, col, row_stride) - rowMaxShared) / rowSumShared;\n setValue(row, col, row_stride, value);\n }\n }`}},Qa=(t,e)=>{Wa(t.inputs),t.compute(Ga(t.inputs[0],e))},Ka=t=>xe({axis:t.axis})})),wh=V((()=>{wu(),Su(),$u(),Mu(),Xa=t=>{if(!t||t.length<1)throw new Error("too few inputs")},Za=(t,e)=>{let n=[],i=e.numOutputs;return t[1].dims[0]>0&&(t[1].getBigInt64Array().forEach((t=>n.push(Number(t)))),i=n.length),xe({numOutputs:i,axis:e.axis,splitSizes:n})},Ya=t=>`\nfn calculateOutputIndex(index: u32) -> u32 {\n for (var i: u32 = 0u; i < ${t}u; i += 1u ) {\n if (index < ${Fe("uniforms.size_in_split_axis","i",t)}) {\n return i;\n }\n }\n return ${t}u;\n}`,Ja=t=>{let e=t.length,n=[];for(let i=0;i<e;++i){let r=t[i].setByIndices("indices","input[global_idx]");1===e?n.push(r):0===i?n.push(`if (output_number == ${i}u) { ${r} }`):i===e-1?n.push(`else { ${r} }`):n.push(`else if (output_number == ${i}) { ${r} }`)}return`\n fn writeBufferData(output_number: u32, indices: ${t[0].type.indices}, global_idx: u32) {\n ${n.join("\n")}\n }`},tu=(t,e)=>{let n=t[0].dims,i=$e.size(n),r=t[0].dataType,s=$e.normalizeAxis(e.axis,n.length),o=new Array(e.numOutputs),a=qe("input",r,n.length),u=new Array(e.numOutputs),h=[],l=[],c=0,f=[{type:12,data:i}];for(let i=0;i<e.numOutputs;i++){c+=e.splitSizes[i],u[i]=c;let s=n.slice();s[e.axis]=e.splitSizes[i],l.push(s),o[i]=je(`output${i}`,r,s.length),h.push({dims:l[i],dataType:t[0].dataType})}return f.push({type:12,data:u},...ze(n,...l)),{name:"Split",shaderCache:{hint:e.cacheKey,inputDependencies:["rank"]},getShaderSource:t=>`\n ${t.registerUniform("input_size","u32").registerUniform("size_in_split_axis","u32",u.length).declareVariables(a,...o)}\n ${Ya(u.length)}\n ${Ja(o)}\n\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.input_size")}\n\n var indices = ${a.offsetToIndices("global_idx")};\n var index = ${a.indicesGet("indices",s)};\n let output_number = calculateOutputIndex(index);\n if (output_number != 0) {\n index -= ${Fe("uniforms.size_in_split_axis","output_number - 1u",u.length)};\n ${a.indicesSet("indices",s,"index")};\n }\n writeBufferData(output_number, indices, global_idx);\n }`,getRunData:()=>({outputs:h,dispatchGroup:{x:Math.ceil(i/64)},programUniforms:f})}},eu=(t,e)=>{Xa(t.inputs);let n=1===t.inputs.length?e:Za(t.inputs,e);t.compute(tu(t.inputs,n),{inputs:[0]})},nu=t=>{let e=t.axis,n=t.splitSizes,i=t.numOutputs<0?n.length:t.numOutputs;if(i!==n.length)throw new Error("numOutputs and splitSizes lengh must be equal");return xe({axis:e,numOutputs:i,splitSizes:n})}})),gh=V((()=>{wu(),Su(),Mu(),iu=(t,e,n,i,r)=>{let s,o=je("output_data",r,n.length,4),a=qe("a_data",e[1].dataType,e[1].dims.length,4),u=qe("b_data",e[2].dataType,e[2].dims.length,4),h=qe("c_data",e[0].dataType,e[0].dims.length,4),l=(t,e,n)=>`select(${e}, ${t}, ${n})`;if(i){let t=(t,e,n="")=>{let i=`a_data[index_a${e}][component_a${e}]`,r=`b_data[index_b${e}][component_b${e}]`,s=`bool(c_data[index_c${e}] & (0xffu << (component_c${e} * 8)))`;return`\n let output_indices${e} = ${o.offsetToIndices(`global_idx * 4u + ${e}u`)};\n let offset_a${e} = ${a.broadcastedIndicesToOffset(`output_indices${e}`,o)};\n let offset_b${e} = ${u.broadcastedIndicesToOffset(`output_indices${e}`,o)};\n let offset_c${e} = ${h.broadcastedIndicesToOffset(`output_indices${e}`,o)};\n let index_a${e} = offset_a${e} / 4u;\n let index_b${e} = offset_b${e} / 4u;\n let index_c${e} = offset_c${e} / 4u;\n let component_a${e} = offset_a${e} % 4u;\n let component_b${e} = offset_b${e} % 4u;\n let component_c${e} = offset_c${e} % 4u;\n ${t}[${e}] = ${n}(${l(i,r,s)});\n `};s=9===r?`\n var data = vec4<u32>(0);\n ${t("data",0,"u32")}\n ${t("data",1,"u32")}\n ${t("data",2,"u32")}\n ${t("data",3,"u32")}\n output_data[global_idx] = dot(vec4<u32>(0x1, 0x100, 0x10000, 0x1000000), vec4<u32>(data));`:`\n ${t("output_data[global_idx]",0)}\n ${t("output_data[global_idx]",1)}\n ${t("output_data[global_idx]",2)}\n ${t("output_data[global_idx]",3)}\n `}else s=o.setByOffset("global_idx",l(a.getByOffset("global_idx"),u.getByOffset("global_idx"),h.getByOffset("global_idx")));return`\n ${t.registerUniform("vec_size","u32").declareVariables(h,a,u,o)}\n ${t.mainStart()}\n ${t.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.vec_size")}\n ${s}\n }`},ru=t=>{let e=t[1].dims,n=t[2].dims,i=t[0].dims,r=t[1].dataType,s=!($e.areEqual(e,n)&&$e.areEqual(n,i)),o=e,a=$e.size(e);if(s){let t=ke.calcShape(ke.calcShape(e,n,!1),i,!1);if(!t)throw new Error("Can't perform where op on the given tensors");o=t,a=$e.size(o)}let u=Math.ceil(a/4);return{name:"Where",shaderCache:{inputDependencies:["rank","rank","rank"]},getShaderSource:e=>iu(e,t,o,s,r),getRunData:()=>({outputs:[{dims:o,dataType:r}],dispatchGroup:{x:Math.ceil(a/64/4)},programUniforms:[{type:12,data:u},...ze(i,e,n,o)]})}},su=t=>{t.compute(ru(t.inputs))}})),bh=V((()=>{Iu(),Ou(),Tu(),zu(),Pu(),Ru(),Nu(),Wu(),Ku(),Xu(),Zu(),Yu(),Ju(),th(),eh(),nh(),ih(),oh(),ah(),uh(),Vu(),hh(),rh(),lh(),ch(),fh(),Au(),dh(),ph(),vh(),yh(),mh(),wh(),sh(),Eu(),Du(),gh(),ou=new Map([["Abs",[di]],["Acos",[pi]],["Acosh",[vi]],["Add",[ur]],["ArgMax",[Kn,Xn]],["ArgMin",[Qn,Xn]],["Asin",[yi]],["Asinh",[mi]],["Atan",[wi]],["Atanh",[gi]],["Attention",[ii]],["AveragePool",[ea,ta]],["BatchNormalization",[ai]],["BiasAdd",[li]],["BiasSplitGelu",[rr]],["Cast",[xi,bi]],["Ceil",[$i]],["Clip",[ki]],["Concat",[_r,kr]],["Conv",[us,rs]],["ConvTranspose",[_s,ms]],["Cos",[Si]],["Cosh",[Mi]],["CumSum",[$s,Ss]],["DepthToSpace",[As,Is]],["Div",[hr]],["Einsum",[Us,qs]],["Elu",[Ci,Ei]],["Equal",[lr]],["Erf",[Ii]],["Exp",[Oi]],["Expand",[Vs]],["FastGelu",[Gs]],["Floor",[Ti]],["FusedConv",[us,rs]],["Gather",[Zs,Xs]],["GatherElements",[eo,to]],["Gelu",[zi]],["Gemm",[so,ro]],["GlobalAveragePool",[ra,ia]],["GlobalMaxPool",[ha,ua]],["Greater",[pr]],["GreaterOrEqual",[yr]],["GroupQueryAttention",[$o,xo]],["HardSigmoid",[ji,qi]],["InstanceNormalization",[Co]],["LayerNormalization",[Oo]],["LeakyRelu",[Di,Ei]],["Less",[vr]],["LessOrEqual",[mr]],["Log",[Yi]],["MatMul",[Jr]],["MatMulNBits",[Do,Po]],["MaxPool",[oa,aa]],["Mul",[cr]],["MultiHeadAttention",[fo,uo]],["Neg",[Ri]],["Not",[Pi]],["Pad",[Ho]],["Pow",[fr]],["QuickGelu",[er,Ei]],["Range",[fa]],["Reciprocal",[Ni]],["ReduceMin",[Bn]],["ReduceMean",[Nn]],["ReduceMax",[jn]],["ReduceSum",[Hn]],["ReduceProd",[Ln]],["ReduceL1",[Fn]],["ReduceL2",[Un]],["ReduceLogSum",[Wn]],["ReduceLogSumExp",[qn]],["ReduceSumSquare",[Vn]],["Relu",[Fi]],["Resize",[Ia,Oa]],["RotaryEmbedding",[Da]],["Sigmoid",[Ui]],["Sin",[Bi]],["Sinh",[Li]],["Slice",[Ha,Va]],["SkipLayerNormalization",[Na]],["Split",[eu,nu]],["Sqrt",[Hi]],["Softmax",[Qa,Ka]],["Sub",[dr]],["Tan",[Vi]],["Tanh",[Gi]],["ThresholdedRelu",[Zi,Ei]],["Tile",[wo]],["Transpose",[Ze,Ye]],["Where",[su]]])})),xh=V((()=>{vt(),bu(),Mu(),au=class{constructor(t){this.backend=t,this.repo=new Map,this.attributesBound=!1}getArtifact(t){return this.repo.get(t)}setArtifact(t,e){this.repo.set(t,e)}run(t,e,n,i,r){D(t.programInfo.name);let s=this.backend.device,o=this.backend.getComputePassEncoder();this.backend.writeTimestamp(2*this.backend.pendingDispatchNumber);let a=[];for(let t of e)a.push({binding:a.length,resource:{buffer:t.buffer}});for(let t of n)a.push({binding:a.length,resource:{buffer:t.buffer}});r&&a.push({binding:a.length,resource:r});let u=s.createBindGroup({layout:t.computePipeline.getBindGroupLayout(0),entries:a,label:t.programInfo.name});if("capturing"===this.backend.sessionStatus){let e={kernelId:this.backend.currentKernelId,computePipeline:t.computePipeline,bindGroup:u,dispatchGroup:i};this.backend.capturedCommandList.get(this.backend.currentSessionId).push(e)}o.setPipeline(t.computePipeline),o.setBindGroup(0,u),o.dispatchWorkgroups(...i),this.backend.writeTimestamp(2*this.backend.pendingDispatchNumber+1),this.backend.pendingDispatchNumber++,(this.backend.pendingDispatchNumber>=this.backend.maxDispatchNumber||"at-passes"===this.backend.queryType)&&this.backend.endComputePass(),this.backend.pendingDispatchNumber>=this.backend.maxDispatchNumber&&this.backend.flush(),P(t.programInfo.name)}dispose(){}build(t,e){D(t.name);let n=this.backend.device,i=[];n.features.has("shader-f16")&&i.push("enable f16;");let r=He(e,this.backend.device.limits),s=t.getShaderSource(r),o=`${i.join("\n")}\n${r.additionalImplementations}\n${s}`,a=n.createShaderModule({code:o,label:t.name});he("verbose",(()=>`[WebGPU] ${t.name} shader code: ${o}`));let u=n.createComputePipeline({compute:{module:a,entryPoint:"main"},layout:"auto",label:t.name});return P(t.name),{programInfo:t,computePipeline:u,uniformVariablesInfo:r.variablesInfo}}normalizeDispatchGroupSize(t){let e="number"==typeof t?t:t.x,n="number"==typeof t?1:t.y||1,i="number"==typeof t?1:t.z||1,r=this.backend.device.limits.maxComputeWorkgroupsPerDimension;if(e<=r&&n<=r&&i<=r)return[e,n,i];let s=e*n*i,o=Math.ceil(Math.sqrt(s));if(o>r){if(o=Math.ceil(Math.cbrt(s)),o>r)throw new Error("Total dispatch size exceeds WebGPU maximum.");return[o,o,o]}return[o,o,1]}}})),_h=V((()=>{vt(),wu(),bu(),xu(),ku(),bh(),xh(),uu=(t,e)=>{if(e.length!==t.length)throw new Error(`inputDependencies length ${e.length} is not equal to inputTensors length ${t.length}.`);let n=[];for(let i=0;i<t.length;++i){let r=t[i].dataType;switch(e[i]){case"none":n.push("");break;case"type":n.push(`${r}`);break;case"rank":{let e=t[i].dims.length;n.push(`${r};${e}`);break}case"dims":{let e=t[i].dims.join(",");n.push(`${r};${e}`);break}default:throw new Error(`unsupported input dependency: ${e[i]}`)}}return n.join("|")},hu=(t,e,n)=>{let i=t.name;return t.shaderCache?.hint&&(i+="["+t.shaderCache.hint+"]"),i+=":"+n+`:${uu(e,t.shaderCache?.inputDependencies??new Array(e.length).fill("dims"))}`,i},lu=class{constructor(t){t&&(this.architecture=t.architecture,this.vendor=t.vendor)}isArchitecture(t){return this.architecture===t}isVendor(t){return this.vendor===t}},cu=class{constructor(){this.currentSessionId=null,this.currentKernelId=null,this.commandEncoder=null,this.computePassEncoder=null,this.maxDispatchNumber=16,this.pendingDispatchNumber=0,this.pendingKernels=[],this.pendingQueries=new Map,this.sessionStatus="default",this.capturedCommandList=new Map,this.capturedPendingKernels=new Map,this.sessionExternalDataMapping=new Map}get currentKernelCustomData(){if(null===this.currentKernelId)throw new Error("currentKernelCustomData(): currentKernelId is null. (should not happen)");let t=this.kernelCustomData.get(this.currentKernelId);return t||(t={},this.kernelCustomData.set(this.currentKernelId,t)),t}async initialize(t,e){this.env=t;let n=[],i={requiredLimits:{maxComputeWorkgroupStorageSize:e.limits.maxComputeWorkgroupStorageSize,maxComputeWorkgroupsPerDimension:e.limits.maxComputeWorkgroupsPerDimension,maxStorageBufferBindingSize:e.limits.maxStorageBufferBindingSize,maxBufferSize:e.limits.maxBufferSize,maxComputeInvocationsPerWorkgroup:e.limits.maxComputeInvocationsPerWorkgroup,maxComputeWorkgroupSizeX:e.limits.maxComputeWorkgroupSizeX,maxComputeWorkgroupSizeY:e.limits.maxComputeWorkgroupSizeY,maxComputeWorkgroupSizeZ:e.limits.maxComputeWorkgroupSizeZ},requiredFeatures:n};e.features.has("chromium-experimental-timestamp-query-inside-passes")?n.push("chromium-experimental-timestamp-query-inside-passes"):e.features.has("timestamp-query")&&n.push("timestamp-query"),e.features.has("shader-f16")&&n.push("shader-f16"),this.device=await e.requestDevice(i),this.adapterInfo=new lu(e.info||await e.requestAdapterInfo()),this.gpuDataManager=ge(this),this.programManager=new au(this),this.kernels=new Map,this.kernelPersistentData=new Map,this.kernelCustomData=new Map,ae(t.logLevel,!!t.debug),this.device.onuncapturederror=t=>{t.error,GPUValidationError},Object.defineProperty(this.env.webgpu,"device",{value:this.device,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(this.env.webgpu,"adapter",{value:e,writable:!1,enumerable:!0,configurable:!1}),this.setQueryType()}dispose(){typeof this.querySet<"u"&&this.querySet.destroy(),this.gpuDataManager.dispose()}getCommandEncoder(){return this.commandEncoder||(this.commandEncoder=this.device.createCommandEncoder()),this.commandEncoder}getComputePassEncoder(){if(!this.computePassEncoder){let t=this.getCommandEncoder(),e={};"at-passes"===this.queryType&&(e.timestampWrites={querySet:this.querySet,beginningOfPassWriteIndex:2*this.pendingDispatchNumber,endOfPassWriteIndex:2*this.pendingDispatchNumber+1}),this.computePassEncoder=t.beginComputePass(e)}return this.computePassEncoder}endComputePass(){this.computePassEncoder&&(this.computePassEncoder.end(),this.computePassEncoder=null)}flush(){if(!this.commandEncoder)return;let t;D(),this.endComputePass(),"none"!==this.queryType&&(this.commandEncoder.resolveQuerySet(this.querySet,0,2*this.pendingDispatchNumber,this.queryResolveBuffer,0),t=this.device.createBuffer({size:16*this.pendingDispatchNumber,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),this.pendingQueries.set(t,this.pendingKernels),this.pendingKernels=[],this.commandEncoder.copyBufferToBuffer(this.queryResolveBuffer,0,t,0,16*this.pendingDispatchNumber)),this.device.queue.submit([this.commandEncoder.finish()]),this.gpuDataManager.refreshPendingBuffers(),this.commandEncoder=null,this.pendingDispatchNumber=0,"none"!==this.queryType&&t.mapAsync(GPUMapMode.READ).then((()=>{let e=new BigUint64Array(t.getMappedRange()),n=this.pendingQueries.get(t);for(let t=0;t<e.length/2;t++){let i=n[t],r=i.kernelId,s=this.kernels.get(r),o=s.kernelType,a=s.kernelName,u=i.programName,h=i.inputTensorViews,l=i.outputTensorViews,c=e[2*t],f=e[2*t+1];typeof this.queryTimeBase>"u"&&(this.queryTimeBase=c);let d=Number(c-this.queryTimeBase),p=Number(f-this.queryTimeBase);if(!Number.isSafeInteger(d)||!Number.isSafeInteger(p))throw new RangeError("incorrect timestamp range");if(this.env.webgpu.profiling?.ondata)this.env.webgpu.profiling.ondata({version:1,inputsMetadata:h.map((t=>({dims:t.dims,dataType:Yt(t.dataType)}))),outputsMetadata:l.map((t=>({dims:t.dims,dataType:Yt(t.dataType)}))),kernelId:r,kernelType:o,kernelName:a,programName:u,startTime:d,endTime:p});else{let t="";h.forEach(((e,n)=>{t+=`input[${n}]: [${e.dims}] | ${Yt(e.dataType)}, `}));let e="";l.forEach(((t,n)=>{e+=`output[${n}]: [${t.dims}] | ${Yt(t.dataType)}, `}))}T("GPU",`${u}::${c}::${f}`)}t.unmap(),this.pendingQueries.delete(t)})),P()}run(t,e,n,i,r,s){D(t.name);let o=[];for(let t=0;t<e.length;++t){let n=e[t].data;if(0===n)continue;let i=this.gpuDataManager.get(n);if(!i)throw new Error(`no GPU data for input: ${n}`);o.push(i)}let{outputs:a,dispatchGroup:u,programUniforms:h}=t.getRunData(e),l=0===n.length?a.map(((t,e)=>e)):n;if(l.length!==a.length)throw new Error(`Output size ${l.length} must be equal to ${a.length}.`);let c,f=[],d=[];for(let t=0;t<a.length;++t){if(!Number.isInteger(l[t])||l[t]<-3||l[t]>=s)throw new Error(`Invalid output index: ${l[t]}`);if(-3===l[t])continue;let e=-1===l[t],n=-2===l[t],o=e||n?r(a[t].dataType,a[t].dims):i(l[t],a[t].dataType,a[t].dims);if(f.push(o),0===o.data)continue;let u=this.gpuDataManager.get(o.data);if(!u)throw new Error(`no GPU data for output: ${o.data}`);if(e&&this.temporaryData.push(u),n){let t=this.kernelPersistentData.get(this.currentKernelId);t||(t=[],this.kernelPersistentData.set(this.currentKernelId,t)),t.push(u)}d.push(u)}if(o.length!==e.length||d.length!==f.length){if(0===d.length)return P(t.name),f;throw new Error(`Program ${t.name} has zero-sized tensor(s) in inputs or outputs. This is not supported now.`)}if(h){let t=0,e=[];h.forEach((n=>{let i="number"==typeof n.data?[n.data]:n.data;if(0===i.length)return;let r,s,o=10===n.type?2:4;10===n.type?(s=i.length>4?16:i.length>2?8:i.length*o,r=i.length>4?16:o*i.length):(s=i.length<=2?i.length*o:16,r=16),t=Math.ceil(t/s)*s,e.push(t);let a=10===n.type?8:4;t+=i.length>4?Math.ceil(i.length/a)*r:i.length*o}));let n=16;t=Math.ceil(t/n)*n;let i=new ArrayBuffer(t);h.forEach(((t,n)=>{let r=e[n],s="number"==typeof t.data?[t.data]:t.data;if(6===t.type)new Int32Array(i,r,s.length).set(s);else if(12===t.type)new Uint32Array(i,r,s.length).set(s);else if(10===t.type)new Uint16Array(i,r,s.length).set(s);else{if(1!==t.type)throw new Error(`Unsupported uniform type: ${Yt(t.type)}`);new Float32Array(i,r,s.length).set(s)}}));let r=this.gpuDataManager.create(t,GPUBufferUsage.COPY_DST|GPUBufferUsage.UNIFORM);this.device.queue.writeBuffer(r.buffer,0,i,0,t),this.gpuDataManager.release(r.id),c={offset:0,size:t,buffer:r.buffer}}let p=this.programManager.normalizeDispatchGroupSize(u),v=1===p[1]&&1===p[2],y=hu(t,e,v),m=this.programManager.getArtifact(y);if(m||(m=this.programManager.build(t,p),this.programManager.setArtifact(y,m),he("info",(()=>`[artifact] key: ${y}, programName: ${t.name}`))),h&&m.uniformVariablesInfo){if(h.length!==m.uniformVariablesInfo.length)throw new Error(`Uniform variables count mismatch: expect ${m.uniformVariablesInfo.length}, got ${h.length} in program "${m.programInfo.name}".`);for(let t=0;t<h.length;t++){let e=h[t],n=e.type,i="number"==typeof e.data?1:e.data.length,[r,s]=m.uniformVariablesInfo[t];if(n!==r||i!==s)throw new Error(`Uniform variable ${t} mismatch: expect type ${r} with size ${s}, got type ${n} with size ${i} in program "${m.programInfo.name}".`)}}if(he("info",(()=>`[ProgramManager] run "${t.name}" (key=${y}) with ${p[0]}x${p[1]}x${p[2]}`)),"none"!==this.queryType||"capturing"===this.sessionStatus){let t={kernelId:this.currentKernelId,programName:m.programInfo.name,inputTensorViews:e,outputTensorViews:f};this.pendingKernels.push(t),"capturing"===this.sessionStatus&&this.capturedPendingKernels.get(this.currentSessionId).push(t)}return this.programManager.run(m,o,d,p,c),P(t.name),f}upload(t,e){this.gpuDataManager.upload(t,e)}memcpy(t,e){this.gpuDataManager.memcpy(t,e)}async download(t,e){await this.gpuDataManager.download(t,e)}alloc(t){return this.gpuDataManager.create(t).id}free(t){return this.gpuDataManager.release(t)}createKernel(t,e,n,i){let r=ou.get(t);if(!r)throw new Error(`kernel not implemented: ${t}`);let s={kernelType:t,kernelName:i,kernelEntry:r[0],attributes:[r[1],n]};this.kernels.set(e,s)}releaseKernel(t){let e=this.kernelPersistentData.get(t);if(e){for(let t of e)this.gpuDataManager.release(t.id);this.kernelPersistentData.delete(t)}this.kernelCustomData.delete(t),this.kernels.delete(t)}computeKernel(t,e,n){let i=this.kernels.get(t);if(!i)throw new Error(`kernel not created: ${t}`);let r=i.kernelType,s=i.kernelName,o=i.kernelEntry,a=i.attributes;if(null!==this.currentKernelId)throw new Error(`kernel "[${r}] ${s}" is not allowed to be called recursively`);this.currentKernelId=t,a[0]&&(a[1]=a[0](a[1]),a[0]=void 0),he("info",(()=>`[WebGPU] Start to run kernel "[${r}] ${s}"...`));let u=this.env.debug;this.temporaryData=[];try{return u&&this.device.pushErrorScope("validation"),o(e,a[1]),0}catch(t){return n.push(Promise.resolve(`[WebGPU] Kernel "[${r}] ${s}" failed. ${t}`)),1}finally{u&&n.push(this.device.popErrorScope().then((t=>t?`GPU validation error for kernel "[${r}] ${s}": ${t.message}`:null)));for(let t of this.temporaryData)this.gpuDataManager.release(t.id);this.temporaryData=[],this.currentKernelId=null}}registerBuffer(t,e,n,i){let r=this.sessionExternalDataMapping.get(t);r||(r=new Map,this.sessionExternalDataMapping.set(t,r));let s=r.get(e),o=this.gpuDataManager.registerExternalBuffer(n,i,s?.[1]);return r.set(e,[o,n]),o}unregisterBuffers(t){let e=this.sessionExternalDataMapping.get(t);e&&(e.forEach((t=>this.gpuDataManager.unregisterExternalBuffer(t[1]))),this.sessionExternalDataMapping.delete(t))}getBuffer(t){let e=this.gpuDataManager.get(t);if(!e)throw new Error(`no GPU data for buffer: ${t}`);return e.buffer}createDownloader(t,e,n){return async()=>{let i=await me(this,t,e);return le(i.buffer,n)}}writeTimestamp(t){"inside-passes"===this.queryType&&this.computePassEncoder.writeTimestamp(this.querySet,t)}setQueryType(){this.queryType="none",("default"===this.env.webgpu.profiling?.mode||(typeof this.env.trace>"u"?this.env.wasm.trace:this.env.trace))&&(this.device.features.has("chromium-experimental-timestamp-query-inside-passes")?this.queryType="inside-passes":this.device.features.has("timestamp-query")&&(this.queryType="at-passes"),"none"!==this.queryType&&typeof this.querySet>"u"&&(this.querySet=this.device.createQuerySet({type:"timestamp",count:2*this.maxDispatchNumber}),this.queryResolveBuffer=this.device.createBuffer({size:16*this.maxDispatchNumber,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.QUERY_RESOLVE})))}captureBegin(){he("info","captureBegin"),this.capturedCommandList.get(this.currentSessionId)||this.capturedCommandList.set(this.currentSessionId,[]),this.capturedPendingKernels.get(this.currentSessionId)||this.capturedPendingKernels.set(this.currentSessionId,[]),this.flush(),this.sessionStatus="capturing"}captureEnd(){he("info","captureEnd"),this.flush(),this.sessionStatus="default"}replay(){he("info","replay"),this.sessionStatus="replaying";let t=this.capturedCommandList.get(this.currentSessionId),e=this.capturedPendingKernels.get(this.currentSessionId),n=t.length;this.pendingKernels=[];for(let i=0;i<n;i++){let n=this.getComputePassEncoder(),r=t[i];this.writeTimestamp(2*this.pendingDispatchNumber),n.setPipeline(r.computePipeline),n.setBindGroup(0,r.bindGroup),n.dispatchWorkgroups(...r.dispatchGroup),this.writeTimestamp(2*this.pendingDispatchNumber+1),this.pendingDispatchNumber++,"none"!==this.queryType&&this.pendingKernels.push(e[i]),(this.pendingDispatchNumber>=this.maxDispatchNumber||"at-passes"===this.queryType)&&this.endComputePass(),this.pendingDispatchNumber>=this.maxDispatchNumber&&this.flush()}this.flush(),this.sessionStatus="default"}onReleaseSession(t){this.unregisterBuffers(t),this.capturedCommandList.has(t)&&this.capturedCommandList.delete(t),this.capturedPendingKernels.has(t)&&this.capturedPendingKernels.delete(t),this.gpuDataManager.onReleaseSession(t)}onRunStart(t){this.currentSessionId=t,this.setQueryType()}}})),kh={};W(kh,{init:()=>Mh});var $h,Sh,Mh,Eh,Ch,Ah,Ih,Oh,Th,zh,Dh,Ph,Rh,Nh,Fh,Uh,qh,jh,Bh,Lh,Hh,Vh,Wh,Gh,Qh,Kh,Xh,Zh,Yh,Jh,tl,el,nl,il,rl,sl,ol,al,ul=V((()=>{wu(),_h(),bu(),Su(),$h=class t{constructor(t,e,n,i){this.module=t,this.dataType=e,this.data=n,this.dims=i}getFloat32Array(){if(1!==this.dataType)throw new Error("Invalid data type");let t=$e.size(this.dims);return 0===t?new Float32Array:new Float32Array(this.module.HEAP8.buffer,this.data,t)}getBigInt64Array(){if(7!==this.dataType)throw new Error("Invalid data type");let t=$e.size(this.dims);return 0===t?new BigInt64Array:new BigInt64Array(this.module.HEAP8.buffer,this.data,t)}getInt32Array(){if(6!==this.dataType)throw new Error("Invalid data type");let t=$e.size(this.dims);return 0===t?new Int32Array:new Int32Array(this.module.HEAP8.buffer,this.data,t)}reshape(e){if($e.size(e)!==$e.size(this.dims))throw new Error("Invalid new shape");return new t(this.module,this.dataType,this.data,e)}},Sh=class{constructor(t,e,n){this.module=t,this.backend=e,this.customDataOffset=0,this.customDataSize=0,this.adapterInfo=e.adapterInfo;let i=t.HEAPU32,r=n>>>2;this.opKernelContext=i[r++];let s=i[r++];this.outputCount=i[r++],this.customDataOffset=i[r++],this.customDataSize=i[r++];let o=[];for(let e=0;e<s;e++){let e=i[r++],n=i[r++],s=i[r++],a=[];for(let t=0;t<s;t++)a.push(i[r++]);o.push(new $h(t,e,n,a))}this.inputs=o}get kernelCustomData(){return this.backend.currentKernelCustomData}get customDataBuffer(){return this.module.HEAPU8.subarray(this.customDataOffset,this.customDataOffset+this.customDataSize)}getMaxComputeWorkgroupSizes(){return[this.backend.device.limits.maxComputeWorkgroupSizeX,this.backend.device.limits.maxComputeWorkgroupSizeY,this.backend.device.limits.maxComputeWorkgroupSizeZ]}getMaxComputeWorkgroupStoragesize(){return this.backend.device.limits.maxComputeWorkgroupStorageSize}compute(t,e){let n=e?.inputs?.map((t=>"number"==typeof t?this.inputs[t]:t))??this.inputs,i=e?.outputs??[];return this.backend.run(t,n,i,((t,e,n)=>new $h(this.module,e,this.output(t,n),n)),((t,e)=>{let n=Jt(t);if(!n)throw new Error(`Unsupported data type: ${t}`);let i=n*$e.size(e),r=i>0?this.backend.gpuDataManager.create(i).id:0;return new $h(this.module,t,r,e)}),this.outputCount)}output(t,e){let n=this.module.stackSave();try{let n=this.module.stackAlloc(4*(1+e.length)),i=n>>2;this.module.HEAPU32[i++]=e.length;for(let t=0;t<e.length;t++)this.module.HEAPU32[i++]=e[t];return this.module.Dt(this.opKernelContext,t,n)}catch(n){throw new Error(`Failed to generate kernel's output[${t}] with dims [${e}]. If you are running with pre-allocated output, please make sure the output type/dims are correct. Error: ${n}`)}finally{this.module.stackRestore(n)}}},Mh=async(t,e,n,i)=>{let r=e.jsepInit;if(!r)throw new Error("Failed to initialize JSEP. The WebAssembly module is not built with JSEP support.");if("webgpu"===t){let t=new cu;await t.initialize(n,i),r("webgpu",[t,e=>t.alloc(e),e=>t.free(e),(n,i,r,s=!1)=>{if(s)he("verbose",(()=>`[WebGPU] jsepCopyGpuToGpu: src=${n}, dst=${i}, size=${r}`)),t.memcpy(n,i);else{he("verbose",(()=>`[WebGPU] jsepCopyCpuToGpu: dataOffset=${n}, gpuDataId=${i}, size=${r}`));let s=e.HEAPU8.subarray(n>>>0,(n>>>0)+r);t.upload(i,s)}},async(n,i,r)=>{he("verbose",(()=>`[WebGPU] jsepCopyGpuToCpu: gpuDataId=${n}, dataOffset=${i}, size=${r}`)),await t.download(n,(()=>e.HEAPU8.subarray(i>>>0,(i>>>0)+r)))},(n,i,r)=>t.createKernel(n,i,r,e.UTF8ToString(e.Pt(i))),e=>t.releaseKernel(e),(n,i,r,s)=>{he("verbose",(()=>`[WebGPU] jsepRun: sessionHandle=${r}, kernel=${n}, contextDataOffset=${i}`));let o=new Sh(e,t,i);return t.computeKernel(n,o,s)},()=>t.captureBegin(),()=>t.captureEnd(),()=>t.replay()])}else r("webnn")}})),hl=V((()=>{yu(),mu(),wu(),pu(),vu(),gu(),Eh=(t,e)=>{0!==jt().rt(t,e)&&Ht("Can't initialize onnxruntime.")},Ch=async t=>{Eh(t.wasm.numThreads,ee(t.logLevel))},Ah=async(t,e)=>{{let n=(ul(),G(kh)).init;if("webgpu"===e){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");let e=t.webgpu.adapter;if(e){if("object"!=typeof e.limits||"object"!=typeof e.features||"function"!=typeof e.requestDevice)throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let n=t.webgpu.powerPreference;if(void 0!==n&&"low-power"!==n&&"high-performance"!==n)throw new Error(`Invalid powerPreference setting: "${n}"`);let i=t.webgpu.forceFallbackAdapter;if(void 0!==i&&"boolean"!=typeof i)throw new Error(`Invalid forceFallbackAdapter setting: "${i}"`);if(e=await navigator.gpu.requestAdapter({powerPreference:n,forceFallbackAdapter:i}),!e)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}await n("webgpu",jt(),t,e)}if("webnn"===e){if(typeof navigator>"u"||!navigator.ml)throw new Error("WebNN is not supported in current environment");await n("webnn",jt(),t)}}},Ih=new Map,Oh=t=>{let e=jt(),n=e.stackSave();try{let n=e.stackAlloc(8);return 0!==e.yt(t,n,n+4)&&Ht("Can't get session input/output count."),[e.HEAP32[n/4],e.HEAP32[n/4+1]]}finally{e.stackRestore(n)}},Th=t=>{let e=jt(),n=e.Rt(t.byteLength);if(0===n)throw new Error(`Can't create a session. failed to allocate a buffer of size ${t.byteLength}.`);return e.HEAPU8.set(t,n),[n,t.byteLength]},zh=async(t,e)=>{let n,i,r=jt();Array.isArray(t)?[n,i]=t:t.buffer===r.HEAPU8.buffer?[n,i]=[t.byteOffset,t.byteLength]:[n,i]=Th(t);let s=0,o=0,a=0,u=[],h=[],l=[];try{if([o,u]=Xt(e),e?.externalData&&r.mountExternalData){let t=[];for(let n of e.externalData){let e="string"==typeof n?n:n.path;t.push(re("string"==typeof n?n:n.data).then((t=>{r.mountExternalData(e,t)})))}await Promise.all(t)}for(let t of e?.executionProviders??[])if("webnn"===("string"==typeof t?t:t.name)){if(r.currentContext)throw new Error("WebNN execution provider is already set.");if("string"!=typeof t){let e=t,n=e?.context,i=e?.gpuDevice,s=e?.deviceType,o=e?.numThreads,a=e?.powerPreference;r.currentContext=n||(i?await navigator.ml.createContext(i):await navigator.ml.createContext({deviceType:s,numThreads:o,powerPreference:a}))}else r.currentContext=await navigator.ml.createContext();break}s=await r._(n,i,o),0===s&&Ht("Can't create a session."),r.currentContext&&(r.currentContext=void 0);let[t,c]=Oh(s),f=!!e?.enableGraphCapture,d=[],p=[],v=[];for(let e=0;e<t;e++){let t=r.wt(s,e);0===t&&Ht("Can't get an input name."),h.push(t),d.push(r.UTF8ToString(t))}for(let t=0;t<c;t++){let n=r.bt(s,t);0===n&&Ht("Can't get an output name."),l.push(n);let i=r.UTF8ToString(n);p.push(i);{if(f&&void 0===e?.preferredOutputLocation){v.push("gpu-buffer");continue}let t="string"==typeof e?.preferredOutputLocation?e.preferredOutputLocation:e?.preferredOutputLocation?.[i]??"cpu";if("cpu"!==t&&"cpu-pinned"!==t&&"gpu-buffer"!==t)throw new Error(`Not supported preferred output location: ${t}.`);if(f&&"gpu-buffer"!==t)throw new Error(`Not supported preferred output location: ${t}. Only 'gpu-buffer' location is supported when enableGraphCapture is true.`);v.push(t)}}let y=null;return v.some((t=>"gpu-buffer"===t))&&(a=r.Ct(s),0===a&&Ht("Can't create IO binding."),y={handle:a,outputPreferredLocations:v,outputPreferredLocationsEncoded:v.map((t=>ie(t)))}),Ih.set(s,[s,h,l,y,f,!1]),[s,d,p]}catch(t){throw h.forEach((t=>r.xt(t))),l.forEach((t=>r.xt(t))),0!==a&&r.Tt(a),0!==s&&r.vt(s),t}finally{r.Nt(n),0!==o&&r.ft(o),u.forEach((t=>r.Nt(t))),r.unmountExternalData?.()}},Dh=t=>{let e=jt(),n=Ih.get(t);if(!n)throw new Error(`cannot release session. invalid session id: ${t}`);let[i,r,s,o,a]=n;o&&(a&&e.It(o.handle),e.Tt(o.handle)),e.jsepOnReleaseSession?.(t),r.forEach((t=>e.xt(t))),s.forEach((t=>e.xt(t))),e.vt(i),Ih.delete(t)},Ph=(t,e,n,i,r,s=!1)=>{if(!t)return void e.push(0);let o,a,u=jt(),h=t[0],l=t[1],c=t[3];if("string"===h&&"gpu-buffer"===c)throw new Error("String tensor is not supported on GPU.");if(s&&"gpu-buffer"!==c)throw new Error(`External buffer must be provided for input/output index ${r} when enableGraphCapture is true.`);if("gpu-buffer"===c){let e=t[2].gpuBuffer,n=Jt(Zt(h));a=l.reduce(((t,e)=>t*e),1)*n;let s=u.jsepRegisterBuffer;if(!s)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');o=s(i,r,e,a)}else{let e=t[2];if(Array.isArray(e)){a=4*e.length,o=u.Rt(a),n.push(o);let t=o/4;for(let i=0;i<e.length;i++){if("string"!=typeof e[i])throw new TypeError(`tensor data at index ${i} is not a string`);u.HEAPU32[t++]=Bt(e[i],n)}}else a=e.byteLength,o=u.Rt(a),n.push(o),u.HEAPU8.set(new Uint8Array(e.buffer,e.byteOffset,a),o)}let f=u.stackSave(),d=u.stackAlloc(4*l.length);try{let t=d/4;l.forEach((e=>u.HEAP32[t++]=e));let n=u._t(Zt(h),o,a,d,l.length,ie(c));0===n&&Ht(`Can't create tensor for input/output. session=${i}, index=${r}.`),e.push(n)}finally{u.stackRestore(f)}},Rh=async(t,e,n,i,r,s)=>{let o=jt(),a=Ih.get(t);if(!a)throw new Error(`cannot run inference. invalid session id: ${t}`);let u=a[0],h=a[1],l=a[2],c=a[3],f=a[4],d=a[5],p=e.length,v=i.length,y=0,m=[],w=[],g=[],b=[],x=o.stackSave(),_=o.stackAlloc(4*p),k=o.stackAlloc(4*p),$=o.stackAlloc(4*v),S=o.stackAlloc(4*v);try{[y,m]=Vt(s);for(let i=0;i<p;i++)Ph(n[i],w,b,t,e[i],f);for(let e=0;e<v;e++)Ph(r[e],g,b,t,p+i[e],f);let a,x=_/4,M=k/4,E=$/4,C=S/4;for(let t=0;t<p;t++)o.HEAPU32[x++]=w[t],o.HEAPU32[M++]=h[e[t]];for(let t=0;t<v;t++)o.HEAPU32[E++]=g[t],o.HEAPU32[C++]=l[i[t]];if(c&&!d){let{handle:n,outputPreferredLocations:s,outputPreferredLocationsEncoded:a}=c;if(h.length!==p)throw new Error(`input count from feeds (${p}) is expected to be always equal to model's input count (${h.length}).`);for(let i=0;i<p;i++){let r=e[i];0!==await o.nt(n,h[r],w[i])&&Ht(`Can't bind input[${i}] for session=${t}.`)}for(let e=0;e<v;e++){let u=i[e];r[e]?.[3]?0!==o.At(n,l[u],g[e],0)&&Ht(`Can't bind pre-allocated output[${e}] for session=${t}.`):0!==o.At(n,l[u],0,a[u])&&Ht(`Can't bind output[${e}] to ${s[e]} for session=${t}.`)}Ih.set(t,[u,h,l,c,f,!0])}o.jsepOnRunStart?.(u),a=c?await o.et(u,c.handle,v,$,y):await o.tt(u,k,_,p,S,v,$,y),0!==a&&Ht("failed to call OrtRun().");let A=[];for(let t=0;t<v;t++){let e=o.HEAPU32[$/4+t];if(e===g[t]){A.push(r[t]);continue}let n,s=o.stackSave(),a=o.stackAlloc(16),u=!1,h=0;try{0!==o.kt(e,a,a+4,a+8,a+12)&&Ht(`Can't access output tensor data on index ${t}.`);let r=a/4,s=o.HEAPU32[r++];h=o.HEAPU32[r++];let l=o.HEAPU32[r++],f=o.HEAPU32[r++],d=[];for(let t=0;t<f;t++)d.push(o.HEAPU32[l/4+t]);o.xt(l);let p=d.reduce(((t,e)=>t*e),1);n=Yt(s);let v=c?.outputPreferredLocations[i[t]];if("string"===n){if("gpu-buffer"===v)throw new Error("String tensor is not supported on GPU.");let t=[],e=h/4;for(let n=0;n<p;n++){let i=o.HEAPU32[e++],r=n===p-1?void 0:o.HEAPU32[e]-i;t.push(o.UTF8ToString(i,r))}A.push([n,d,t,"cpu"])}else if("gpu-buffer"===v&&p>0){let t=o.jsepGetBuffer;if(!t)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let i=t(h),r=Jt(s);if(void 0===r||!ne(n))throw new Error(`Unsupported data type: ${n}`);u=!0,A.push([n,d,{gpuBuffer:i,download:o.jsepCreateDownloader(i,p*r,n),dispose:()=>{o.$t(e)}},"gpu-buffer"])}else{let t=new(te(n))(p);new Uint8Array(t.buffer,t.byteOffset,t.byteLength).set(o.HEAPU8.subarray(h,h+t.byteLength)),A.push([n,d,t,"cpu"])}}finally{o.stackRestore(s),"string"===n&&h&&o.Nt(h),u||o.$t(e)}}return c&&!f&&(o.It(c.handle),Ih.set(t,[u,h,l,c,f,!1])),A}finally{o.stackRestore(x),w.forEach((t=>o.$t(t))),g.forEach((t=>o.$t(t))),b.forEach((t=>o.Nt(t))),0!==y&&o.Et(y),m.forEach((t=>o.Nt(t)))}},Nh=t=>{let e=jt(),n=Ih.get(t);if(!n)throw new Error("invalid session id");let i=n[0],r=e.zt(i);0===r&&Ht("Can't get an profile file name."),e.xt(r)},Fh=t=>{let e=[];for(let n of t){let t=n[2];!Array.isArray(t)&&"buffer"in t&&e.push(t.buffer)}return e}})),ll=V((()=>{vt(),hl(),pu(),du(),Uh=()=>!!y.wasm.proxy&&typeof document<"u",jh=!1,Bh=!1,Lh=!1,Wh=new Map,Gh=(t,e)=>{let n=Wh.get(t);n?n.push(e):Wh.set(t,[e])},Qh=()=>{if(jh||!Bh||Lh||!qh)throw new Error("worker not ready")},Kh=t=>{switch(t.data.type){case"init-wasm":jh=!1,t.data.err?(Lh=!0,Vh[1](t.data.err)):(Bh=!0,Vh[0]()),Hh&&(URL.revokeObjectURL(Hh),Hh=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let e=Wh.get(t.data.type);t.data.err?e.shift()[1](t.data.err):e.shift()[0](t.data.out);break}}},Xh=async()=>{if(!Bh){if(jh)throw new Error("multiple calls to 'initWasm()' detected.");if(Lh)throw new Error("previous call to 'initWasm()' failed.");if(jh=!0,Uh())return new Promise(((t,e)=>{qh?.terminate(),Ot().then((([n,i])=>{try{(qh=i).onerror=t=>e(t),qh.onmessage=Kh,Vh=[t,e];let r={type:"init-wasm",in:y};qh.postMessage(r),Hh=n}catch(t){e(t)}}),e)}));try{await qt(y.wasm),await Ch(y),Bh=!0}catch(t){throw Lh=!0,t}finally{jh=!1}}},Zh=async t=>{if(Uh())return Qh(),new Promise(((e,n)=>{Gh("init-ep",[e,n]);let i={type:"init-ep",in:{epName:t,env:y}};qh.postMessage(i)}));await Ah(y,t)},Yh=async t=>Uh()?(Qh(),new Promise(((e,n)=>{Gh("copy-from",[e,n]);let i={type:"copy-from",in:{buffer:t}};qh.postMessage(i,[t.buffer])}))):Th(t),Jh=async(t,e)=>{if(Uh()){if(e?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Qh(),new Promise(((n,i)=>{Gh("create",[n,i]);let r={type:"create",in:{model:t,options:{...e}}},s=[];t instanceof Uint8Array&&s.push(t.buffer),qh.postMessage(r,s)}))}return zh(t,e)},tl=async t=>{if(Uh())return Qh(),new Promise(((e,n)=>{Gh("release",[e,n]);let i={type:"release",in:t};qh.postMessage(i)}));Dh(t)},el=async(t,e,n,i,r,s)=>{if(Uh()){if(n.some((t=>"cpu"!==t[3])))throw new Error("input tensor on GPU is not supported for proxy.");if(r.some((t=>t)))throw new Error("pre-allocated output tensor is not supported for proxy.");return Qh(),new Promise(((r,o)=>{Gh("run",[r,o]);let a=n,u={type:"run",in:{sessionId:t,inputIndices:e,inputs:a,outputIndices:i,options:s}};qh.postMessage(u,Fh(a))}))}return Rh(t,e,n,i,r,s)},nl=async t=>{if(Uh())return Qh(),new Promise(((e,n)=>{Gh("end-profiling",[e,n]);let i={type:"end-profiling",in:t};qh.postMessage(i)}));Nh(t)}})),cl=V((()=>{vt(),ll(),wu(),yt(),gu(),il=(t,e)=>{switch(t.location){case"cpu":return[t.type,t.dims,t.data,"cpu"];case"gpu-buffer":return[t.type,t.dims,{gpuBuffer:t.gpuBuffer},"gpu-buffer"];default:throw new Error(`invalid data location: ${t.location} for ${e()}`)}},rl=t=>{switch(t[3]){case"cpu":return new O(t[0],t[2],t[1]);case"gpu-buffer":{let e=t[0];if(!ne(e))throw new Error(`not supported data type: ${e} for deserializing GPU tensor`);let{gpuBuffer:n,download:i,dispose:r}=t[2];return O.fromGpuBuffer(n,{dataType:e,dims:t[1],download:i,dispose:r})}default:throw new Error(`invalid data location: ${t[3]}`)}},sl=class{async fetchModelAndCopyToWasmMemory(t){return Yh(await re(t))}async loadModel(t,e){let n;D(),n="string"==typeof t?await this.fetchModelAndCopyToWasmMemory(t):t,[this.sessionId,this.inputNames,this.outputNames]=await Jh(n,e),P()}async dispose(){return tl(this.sessionId)}async run(t,e,n){D();let i=[],r=[];Object.entries(t).forEach((t=>{let e=t[0],n=t[1],s=this.inputNames.indexOf(e);if(-1===s)throw new Error(`invalid input '${e}'`);i.push(n),r.push(s)}));let s=[],o=[];Object.entries(e).forEach((t=>{let e=t[0],n=t[1],i=this.outputNames.indexOf(e);if(-1===i)throw new Error(`invalid output '${e}'`);s.push(n),o.push(i)}));let a=i.map(((t,e)=>il(t,(()=>`input "${this.inputNames[r[e]]}"`)))),u=s.map(((t,e)=>t?il(t,(()=>`output "${this.outputNames[o[e]]}"`)):null)),h=await el(this.sessionId,r,a,o,u,n),l={};for(let t=0;t<h.length;t++)l[this.outputNames[o[t]]]=s[t]??rl(h[t]);return P(),l}startProfiling(){}endProfiling(){nl(this.sessionId)}}})),fl=V((()=>{vt(),ll(),cl(),du(),ol=()=>{if(("number"!=typeof y.wasm.initTimeout||y.wasm.initTimeout<0)&&(y.wasm.initTimeout=0),y.wasm.simd,"boolean"!=typeof y.wasm.proxy&&(y.wasm.proxy=!1),"boolean"!=typeof y.wasm.trace&&(y.wasm.trace=!1),"number"!=typeof y.wasm.numThreads||!Number.isInteger(y.wasm.numThreads)||y.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)y.wasm.numThreads=1;else{let t=typeof navigator>"u"?H("node:os").cpus().length:navigator.hardwareConcurrency;y.wasm.numThreads=Math.min(4,Math.ceil((t||1)/2))}},al=class{async init(t){ol(),await Xh(),await Zh(t)}async createInferenceSessionHandler(t,e){let n=new sl;return await n.loadModel(t,e),Promise.resolve(n)}}})),dl={};W(dl,{wasmBackend:()=>pl});var pl,vl=V((()=>{fl(),pl=new al}));vt(),vt(),vt();var yl=pt;{let t=(vl(),G(dl)).wasmBackend;l("webgpu",t,5),l("webnn",t,5),l("cpu",t,10),l("wasm",t,10)}Object.defineProperty(y.versions,"web",{value:"1.19.2",enumerable:!0});let ml=new Worker(URL.createObjectURL(new Blob(["(",function(){const t=262145;let e=new Uint32Array(t),n=new Uint32Array(2e7),i=new Uint32Array(2e7);self.onmessage=r=>{(async r=>{((r,s)=>{const o=r.qt,a=!!o.find((t=>t.jt)),u=r.Bt;let h=1/0,l=-1/0,c=0,f=1/0,d=0;const p=a?6:2,v=Math.floor(u/p),y=u*v;for(let t=0,e=o.length;t<e;t+=1){const e=o[t],{Lt:n,Ht:i,Vt:r,Wt:s,Gt:a,Qt:u,Kt:p}=e;c+=p,f=Math.min(f,u),d=Math.max(d,u);const v=r[2],y=r[6],m=r[10],w=r[14];for(let t=0;t<8;++t){let e=v*(1&t?i[0]:n[0])+y*(2&t?i[1]:n[1])+m*(4&t?i[2]:n[2])+w;h=Math.min(h,e),l=Math.max(l,e)}}h-=1;const m=t*(d-f+1);e=m<e.length?new Uint32Array(e.buffer,0,m):new Uint32Array(m),c<n.length?(n=new Uint32Array(n.buffer,0,c),i=new Uint32Array(i.buffer,0,c)):c>n.length&&(n=new Uint32Array(c),i=new Uint32Array(c));for(var w=0;w<m;w+=1)e[w]=0;const g=1/(l-h)*262144,b=[],x=Math.ceil(Math.log2(u*u));let _,k=0;for(let r=0,s=o.length;r<s;r+=1){const s=o[r],{Lt:a,Ht:l,Vt:c,Wt:f,Gt:m,Qt:w,Xt:_,Kt:$}=s;let S=0;for(let t=0,e=_.length;t<e;t+=1){const n=_[t];let i=b.indexOf(n._id);-1==i?(b.push(n._id),n.Zt=b.length-1):n.Zt=i;let r,s=f+"_"+t;r=t<e-1?n.Yt[s][1]*v:$-S,n.pixelOffsetInThisTexture=n.Yt[s][0]*u,n.countInThisTexture=r,n.startIdxInTile=S,S+=r}const M=d-w,E=c[2],C=c[6],A=c[10],I=c[14],O=new Float32Array(m);let T=0,z=_[T],D=z.Zt,P=z.startIdxInTile;for(let r=0;r<$;r+=1){const s=3*r,o=((E*O[s]+C*O[s+1]+A*O[s+2]+I-h)*g|0)+M*t;if(n[k]=o,_.length>1&&r>=y){const t=r/y|0;t!==T&&(T=t,z=_[T],D=z.Zt,P=z.startIdxInTile)}const a=r-P,l=z.pixelOffsetInThisTexture+(a/v|0)*u+a%v*p;i[k]=(D<<x)+l,e[o]+=1,k+=1}}for(let t=1;t<m;t+=1)e[t]+=e[t-1];_=r.Jt.length<i.length?new Int32Array(i.length):new Int32Array(r.Jt);for(let t=i.length-1;t>=0;t--){const r=n[t];_[--e[r]]=i[t]}_=_.reverse();const $=[],S=[],M=[],E=[0],C=[];o.forEach((t=>{$.push(t.Wt),S.push(t.te),C.push(t.Qt),M.push(t.Gt),E.push(t.Kt+E[E.length-1])})),E.pop(),self.postMessage({ee:s,jt:a,ne:$,ie:S,Gt:M,Yt:E,Jt:_,re:b,se:_.length-k,oe:k},[_.buffer,...M])})(r,r.ee)})(r.data)}}.toString(),")(self)"],{type:"application/javascript"})));const wl=ml;for(var gl,bl=[],xl=0;xl<256;++xl)bl.push((xl+256).toString(16).slice(1));var _l=new Uint8Array(16);function kl(){if(!gl&&!(gl="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return gl(_l)}var $l={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Sl(t,e,n){if($l.randomUUID&&!e&&!t)return $l.randomUUID();var i=(t=t||{}).random||(t.rng||kl)();return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(t,e=0){return(bl[t[e+0]]+bl[t[e+1]]+bl[t[e+2]]+bl[t[e+3]]+"-"+bl[t[e+4]]+bl[t[e+5]]+"-"+bl[t[e+6]]+bl[t[e+7]]+"-"+bl[t[e+8]]+bl[t[e+9]]+"-"+bl[t[e+10]]+bl[t[e+11]]+bl[t[e+12]]+bl[t[e+13]]+bl[t[e+14]]+bl[t[e+15]]).toLowerCase()}(i)}class Ml{static idCount=0;_id;ae;ue;he;ce;fe;_texture;Yt={};de;pe=-2;ve=0;ye=!1;constructor(t,e){this._id=Ml.idCount++,this.fe=e,this.ue=this.he=t,this.de=[[0,this.he]],this.ce=t,this._texture=new r.Texture({name:this._id,context:this.fe,internalFormat:r.WebGLConstants.RGBA32F,pixelFormat:r.WebGLConstants.RGBA,pixelDatatype:r.WebGLConstants.FLOAT,width:t,height:t,flipY:!1,sampler:new r.Sampler({minificationFilter:r.TextureMinificationFilter.NEAREST,magnificationFilter:r.TextureMagnificationFilter.NEAREST})})}me(t,e,n){const i=this.we(t.height),r=this.de[i][0];this._texture.copyFrom({xOffset:0,yOffset:r,source:t}),this.Yt[e]=[r,t.height],this.ce-=t.height,this.ae?(this.ae.x=(this.ae.x*this.ve+n.x)/(this.ve+1),this.ae.y=(this.ae.y*this.ve+n.y)/(this.ve+1),this.ae.z=(this.ae.z*this.ve+n.z)/(this.ve+1)):this.ae=n,this.ve+=1,this.be()}xe(t,e){this.ce+=this.Yt[t][1],delete this.Yt[t],this.be(),this.de.length&&this.ae?(this.ae.x=(this.ae.x*this.ve-e.x)/(this.ve-1),this.ae.y=(this.ae.y*this.ve-e.y)/(this.ve-1),this.ae.z=(this.ae.z*this.ve-e.z)/(this.ve-1)):this.ae=void 0,this.ve-=1}be(){const t=Object.values(this.Yt).map((t=>[t[0],t[0]+t[1]])).sort(((t,e)=>t[0]<e[0]?-1:1)).flat();t.unshift(0),t.push(this.he);const e=[];for(let n=0;n<t.length;n+=2)t[n]!==t[n+1]&&e.push([t[n],t[n+1]]);this.de=e}we(t){for(let e=0;e<this.de.length;e+=1)if(this.de[e][1]-this.de[e][0]>=t)return e;return-1}_e(){this.ce=this.he,this.ae=void 0,this.ve=0,this.Yt={},this.de=[[0,this.he]]}ke(){return this.ce===this.he}_destroy(){this.ye||(this.ye=!0,this._e(),this._texture.destroy(),this._texture=null)}}class El{$e=[];Se={};fe;Bt;Xt={};constructor(t,e){this.fe=t,this.Bt=e}Me(t){return t.map((t=>this.Xt[t]))}Ee(t,e,n,i){if(this.Se[i]){let r=this.Ce(t,e,n,this.Se[i]);return r||(r=this.$e.length?this.$e.pop():new Ml(this.Bt,this.fe),r.pe=i,this.Se[i].push(r),this.Xt[r._id]=r),r}{this.Se[i]=[];const t=new Ml(this.Bt,this.fe);return t.pe=i,this.Se[i].push(t),this.Xt[t._id]=t,t}}_destroy(){Object.keys(this.Se).forEach((t=>{this.Se[t].forEach((t=>{t._destroy(),delete this.Xt[t._id]})),delete this.Se[t]})),this.$e.forEach((t=>{t._destroy(),delete this.Xt[t._id]})),this.$e=[]}Ce(t,n,i,r){let s,o=1/0;for(let a=r.length-1;a>=0;a-=1){const u=r[a];if(-1!==u.we(i)){const i=e.Cartesian3.distance(t,u.ae);i<n&&i<o&&(o=i,s=u)}}return s}Ae(t){const{Xt:e}=t;e?.forEach(((e,n)=>{const i=t.Ie+"_"+n;if(e.xe(i,t.Oe),e.ke()){e._e(),this.$e.length<2?this.$e.push(e):e._destroy();const n=this.Se[t.Qt].indexOf(e);-1!==n&&this.Se[t.Qt].splice(n,1),delete this.Xt[e._id]}}))}}class Cl{Te=Sl();fe;ze=0;De;_texture;Pe;textureWidth;Re=!0;Ne;Fe={Gt:new ArrayBuffer(0),Vt:[],oe:0,Lt:[0,0,0],Ht:[0,0,0]};Ue;afterSort;qe={Jt:new Int32Array(0),ne:[],_modelMatrix:r.Matrix4.IDENTITY.clone(),Xt:[],oe:0,je:-1,Be:void 0,Le:[0],jt:!1};He=[0,0,0];constructor(t){this.fe=t.fe,this.Pe=t.Pe,this.textureWidth=Math.min(4096,this.fe._gl.getParameter(this.fe._gl.MAX_TEXTURE_SIZE)),this.Ue=new El(this.fe,this.textureWidth),wl.addEventListener("message",(t=>{this.Ve(t.data)})),t.We&&(this.Ne=t.We,this.Ge(),this.Qe()),this.He=t.He}updateData(t,e){this.Ne=t,this.He=e,this.Ge(),this.Qe()}Ve(t){const{Jt:e,Yt:n,oe:i,ee:s}=t;if(s!==this.Te)return;const o=r.Cartesian3.fromDegrees(this.Pe[0],this.Pe[1],this.Pe[2]),a=r.Transforms.eastNorthUpToFixedFrame(o);this.qe={ne:["single-model"],Jt:e,_modelMatrix:a,Xt:[this._texture],oe:i,je:this.qe.je,Be:this.qe.Be,Le:[i],jt:!1},this.Re=!0,this.afterSort&&this.afterSort(this.qe)}Qe(){if(this._texture&&this._texture.destroy(),!this.Ne)return;const t=this.textureWidth;let e=Math.ceil(this.Ne.byteLength/16/t);e=Math.pow(2,Math.ceil(Math.log2(e)));const n=new Float32Array(new ArrayBuffer(t*e*16));n.set(new Float32Array(this.Ne),0);const i=new r.Cartesian3(this.He[0],this.He[1],this.He[2]),s=this.Ue.Ee(i,600,e,4);s.me({width:t,height:e,arrayBufferView:n},"single-buffer",i),this._texture=s}_destroy(){this.qe=void 0,this.Fe=void 0}Ke(t,e){this.qe.je=t,this.qe.Be=e||void 0}Xe(t){const e=t.camera.viewMatrix,n=(new Date).getTime();let i=!1;if(!(0==this.Re||this.qe&&this.qe.Jt.buffer.detached)&&(this.ze?this.Ze(this.De,e)&&(i=!0):i=!0,i)){const i=t.camera.frustum.projectionMatrix;this.ze=n,this.De=e.clone(),this.Re=!1;const s=[this.qe.Jt.buffer],o=r.Cartesian3.fromDegrees(this.Pe[0],this.Pe[1],this.Pe[2]),a=r.Transforms.eastNorthUpToFixedFrame(o);r.Matrix4.multiply(e,a,a),r.Matrix4.multiply(i,a,a);const u={ee:this.Te,Ye:e,Jt:this.qe.Jt,Yt:[0],qt:[{Qt:0,Wt:this.Te,Gt:this.Fe.Gt,Vt:a,Lt:this.Fe.Lt,Ht:this.Fe.Ht,Kt:this.Fe.oe}]};wl.postMessage(u,s)}}Ze(t,e){let n=t[2]*e[2]+t[6]*e[6]+t[10]*e[10];const i=(t[2]**2+t[6]**2+t[10]**2)**.5,r=(e[2]**2+e[6]**2+e[10]**2)**.5;return Math.abs(n/i/r-1)>.01}Ge(){if(!this.Ne)return;const t=new Float32Array(this.Ne),e=[1/0,1/0,1/0,-1/0,-1/0,-1/0],n=new Float32Array(this.Ne.byteLength/8/4*3);for(let i=0;i<t.length;i+=8){const r=t[i],s=t[i+1],o=t[i+2];n[i/8*3]=r,n[i/8*3+1]=s,n[i/8*3+2]=o,e[0]=Math.min(e[0],r),e[1]=Math.min(e[1],s),e[2]=Math.min(e[2],o),e[3]=Math.max(e[3],r),e[4]=Math.max(e[4],s),e[5]=Math.max(e[5],o)}this.Fe.Ht=[e[0],e[1],e[2]],this.Fe.Lt=[e[3],e[4],e[5]],this.Fe.Gt=n.buffer,this.Fe.oe=n.length/3}}class Al{events;constructor(){this.events=new Map}on(t,e){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}clear(t){t?this.events.set(t,[]):this.events.clear()}off(t,e){const n=this.events.get(t);if(!n)return;const i=n.indexOf(e);-1!==i&&n.splice(i,1),0===n.length&&this.events.delete(t)}emit(t,e){const n=this.events.get(t);n&&n.forEach((t=>t(e)))}}class Il{Je;tn;en;nn;rn;We;sn=!1;ye=!1;an;un;hn=!1;classificationType=r.ClassificationType.BOTH;constructor(t,e,n){this.We=t,this.an=e,this.un=n}prePassesUpdate(t){this.un.ln}update(t){this.ye||this.sn&&this.un.sn&&(t.commandList.push(this.rn),t.commandList.push(this.Je),this.un.ln&&t.commandList.push(this.nn),t.commandList.push(this.en))}postPassesUpdate(t){}isDestroyed(){return this.ye}setBoundingVolume(t){this.Je.boundingVolume=t,this.en.boundingVolume=t,this.nn.boundingVolume=t}show(t){0==this.sn&&(this.sn=!0),this.Je.sort=t}hide(){this.sn&&(this.sn=!1)}destroy(){this.We?.Xt&&this.We?.Xt.forEach((t=>{t._destroy()})),this.Je.vertexArray.getAttribute(1).vertexBuffer.destroy(),this.Je.vertexArray.cn=[],this.Je.vertexArray.destroy(),this.un=void 0,this.We=void 0,this.ye=!0}}class Ol extends Al{fe;_scene;fn;dn;pn;vn=[];yn;Bt;mn;wn;gn;Xt=[];ln;bn;xn=new r.Cartesian2(1,1);sn=!0;en;rn;_n;kn;$n=!1;_modelMatrix;Sn;Mn;nn;constructor(t){super(),this.fe=t.scene.context,this.Bt=t.Bt,t.xn&&(this.xn=new r.Cartesian2(t.xn.brightness||1,t.xn.saturate||1)),this._n=t._n,this.kn=t.kn,this.Sn=t.Sn,this._scene=t.scene,this.ln=t.ln,this.bn=t.bn,r.FeatureDetection.supportsWebgl2&&r.FeatureDetection.supportsWebgl2(this._scene),this.wn=new r.PrimitiveCollection,this.wn.destroyPrimitives=!1,this._scene.groundPrimitives.add(this.wn),this.fn=r.ShaderProgram.fromCache({context:this.fe,vertexShaderSource:"#version 300 es\nprecision highp int;precision highp float;in vec3 position;in float pIdx;uniform vec2 viewport;uniform highp sampler2D u_txts[16];uniform mat4 u_mvs;uniform mat4 u_view;uniform mat3 u_normalMatrix;uniform ivec4 u_params;uniform int u_sltid;uniform vec4 u_sltc;uniform vec2 u_filter;out vec3 texCoord;out vec4 color;out vec4 allMap;out vec3 vPosition;out float maxScale;vec3 rgbToHls(vec3 rgb){float maxC=max(max(rgb.r,rgb.g),rgb.b);float minC=min(min(rgb.r,rgb.g),rgb.b);float h,l,s;l=(maxC+minC)/2.0f;if(maxC==minC){s=0.0f;h=0.0f;}else{float delta=maxC-minC;s=(l<0.5f)? delta/(maxC+minC): delta/(2.0f-maxC-minC);if(maxC==rgb.r){h=(rgb.g-rgb.b)/delta+(rgb.g<rgb.b ? 6.0f : 0.0f);}else if(maxC==rgb.g){h=(rgb.b-rgb.r)/delta+2.0f;}else{h=(rgb.r-rgb.g)/delta+4.0f;}h/=6.0f;}return vec3(h,l,s);}float hueToRgb(float t1,float t2,float hue){if(hue<0.0f)hue+=1.0f;if(hue>1.0f)hue-=1.0f;if(hue<1.0f/6.0f)return t1+(t2-t1)*6.0f*hue;if(hue<0.5f)return t2;if(hue<2.0f/3.0f)return t1+(t2-t1)*(2.0f/3.0f-hue)*6.0f;return t1;}vec3 hlsToRgb(vec3 hls){float h=hls.x;float l=hls.y;float s=hls.z;vec3 rgb;if(s==0.0f){rgb=vec3(l);}else{float temp2=(l<0.5f)? l*(1.0f+s): l+s-l*s;float temp1=2.0f*l-temp2;rgb.r=hueToRgb(temp1,temp2,h+1.0f/3.0f);rgb.g=hueToRgb(temp1,temp2,h);rgb.b=hueToRgb(temp1,temp2,h-1.0f/3.0f);}return rgb;}vec4 modify(vec4 color,vec2 f){vec3 hls=rgbToHls(color.xyz);hls.y*=f.x;hls.z*=f.y;hls=clamp(hls,0.0f,1.0f);return vec4(hlsToRgb(hls),color.a);}vec3 unpack111011s(uint bits){return vec3((uvec3(bits)>>uvec3(21u,11u,0u))&uvec3(0x7ffu,0x3ffu,0x7ffu))/vec3(2047.0f,1023.0f,2047.0f)*2.0f-1.0f;}void fetchScale(in uvec4 t,out float scale,out vec3 a,out vec3 b,out vec3 c){scale=uintBitsToFloat(t.x);a=unpack111011s(t.y);b=unpack111011s(t.z);c=unpack111011s(t.w);}void fetch(in uvec4 t,out vec3 a,out vec3 b,out vec3 c,out vec3 d){a=unpack111011s(t.x);b=unpack111011s(t.y);c=unpack111011s(t.z);d=unpack111011s(t.w);}void fetch(in uint t,out vec3 a){a=unpack111011s(t);}void readSHData(in uvec4 p0,in uvec4 p1,in uvec4 p2,in uvec4 p3,out vec3 sh[15],out float scale){fetchScale(p0,scale,sh[0],sh[1],sh[2]);fetch(p1,sh[3],sh[4],sh[5],sh[6]);fetch(p2,sh[7],sh[8],sh[9],sh[10]);fetch(p3,sh[11],sh[12],sh[13],sh[14]);}\n#define SH_C1 0.4886025119029199f\n#define SH_C2_0 1.0925484305920792f\n#define SH_C2_1 -1.0925484305920792f\n#define SH_C2_2 0.31539156525252005f\n#define SH_C2_3 -1.0925484305920792f\n#define SH_C2_4 0.5462742152960396f\n#define SH_C3_0 -0.5900435899266435f\n#define SH_C3_1 2.890611442640554f\n#define SH_C3_2 -0.4570457994644658f\n#define SH_C3_3 0.3731763325901154f\n#define SH_C3_4 -0.4570457994644658f\n#define SH_C3_5 1.445305721320277f\n#define SH_C3_6 -0.5900435899266435f\nvec3 evalSH(in uvec4 p0,in uvec4 p1,in uvec4 p2,in uvec4 p3,in vec3 dir){vec3 sh[15];float scale;readSHData(p0,p1,p2,p3,sh,scale);float x=dir.x;float y=dir.y;float z=dir.z;vec3 result=SH_C1*(-sh[0]*y+sh[1]*z-sh[2]*x);float xx=x*x;float yy=y*y;float zz=z*z;float xy=x*y;float yz=y*z;float xz=x*z;result+=sh[3]*(SH_C2_0*xy)*+sh[4]*(SH_C2_1*yz)+sh[5]*(SH_C2_2*(2.0f*zz-xx-yy))+sh[6]*(SH_C2_3*xz)+sh[7]*(SH_C2_4*(xx-yy));result+=sh[8]*(SH_C3_0*y*(3.0f*xx-yy))+sh[9]*(SH_C3_1*xy*z)+sh[10]*(SH_C3_2*y*(4.0f*zz-xx-yy))+sh[11]*(SH_C3_3*z*(2.0f*zz-3.0f*xx-3.0f*yy))+sh[12]*(SH_C3_4*x*(4.0f*zz-xx-yy))+sh[13]*(SH_C3_5*z*(xx-yy))+sh[14]*(SH_C3_6*x*(xx-3.0f*yy));return result*scale;}void main(){int idx=floatBitsToInt(pIdx);int px=u_params.x;int py=u_params.y;int bits=u_params.z;int tw=u_params.w;bool hasSH=px==1;int texId=idx>>bits;idx=idx&((1<<bits)-1);int v=idx/tw;int u_1=idx % tw;int u_2=u_1+1;ivec2 a=ivec2(u_1,v);highp vec4 ct;vec4 cvf;uvec4 p0,p1,p2,p3;switch(texId){case 0:ct=texelFetch(u_txts[0],a,0);a.x+=1;cvf=texelFetch(u_txts[0],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[0],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[0],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[0],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[0],a,0));}break;case 1:ct=texelFetch(u_txts[1],a,0);a.x+=1;cvf=texelFetch(u_txts[1],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[1],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[1],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[1],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[1],a,0));}break;case 2:ct=texelFetch(u_txts[2],a,0);a.x+=1;cvf=texelFetch(u_txts[2],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[2],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[2],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[2],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[2],a,0));}break;case 3:ct=texelFetch(u_txts[3],a,0);a.x+=1;cvf=texelFetch(u_txts[3],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[3],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[3],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[3],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[3],a,0));}break;case 4:ct=texelFetch(u_txts[4],a,0);a.x+=1;cvf=texelFetch(u_txts[4],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[4],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[4],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[4],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[4],a,0));}break;case 5:ct=texelFetch(u_txts[5],a,0);a.x+=1;cvf=texelFetch(u_txts[5],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[5],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[5],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[5],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[5],a,0));}break;case 6:ct=texelFetch(u_txts[6],a,0);a.x+=1;cvf=texelFetch(u_txts[6],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[6],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[6],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[6],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[6],a,0));}break;case 7:ct=texelFetch(u_txts[7],a,0);a.x+=1;cvf=texelFetch(u_txts[7],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[7],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[7],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[7],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[7],a,0));}break;case 8:ct=texelFetch(u_txts[8],a,0);a.x+=1;cvf=texelFetch(u_txts[8],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[8],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[8],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[8],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[8],a,0));}break;case 9:ct=texelFetch(u_txts[9],a,0);a.x+=1;cvf=texelFetch(u_txts[9],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[9],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[9],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[9],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[9],a,0));}break;case 10:ct=texelFetch(u_txts[10],a,0);a.x+=1;cvf=texelFetch(u_txts[10],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[10],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[10],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[10],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[10],a,0));}break;case 11:ct=texelFetch(u_txts[11],a,0);a.x+=1;cvf=texelFetch(u_txts[11],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[11],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[11],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[11],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[11],a,0));}break;case 12:ct=texelFetch(u_txts[12],a,0);a.x+=1;cvf=texelFetch(u_txts[12],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[12],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[12],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[12],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[12],a,0));}break;case 13:ct=texelFetch(u_txts[13],a,0);a.x+=1;cvf=texelFetch(u_txts[13],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[13],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[13],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[13],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[13],a,0));}break;case 14:ct=texelFetch(u_txts[14],a,0);a.x+=1;cvf=texelFetch(u_txts[14],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[14],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[14],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[14],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[14],a,0));}break;case 15:ct=texelFetch(u_txts[15],a,0);a.x+=1;cvf=texelFetch(u_txts[15],a,0);if(hasSH){a.x+=1;p0=floatBitsToUint(texelFetch(u_txts[15],a,0));a.x+=1;p1=floatBitsToUint(texelFetch(u_txts[15],a,0));a.x+=1;p2=floatBitsToUint(texelFetch(u_txts[15],a,0));a.x+=1;p3=floatBitsToUint(texelFetch(u_txts[15],a,0));}break;}vec4 splat_cam=u_mvs*vec4(ct.xyz,1);vec4 splat_proj=czm_projection*splat_cam;splat_proj.z=clamp(splat_proj.z,-abs(splat_proj.w),abs(splat_proj.w));vPosition=ct.xyz;if(splat_proj.z<-splat_proj.w){gl_Position=vec4(0.0f,0.0f,0.0f,0.0f);return;}uvec4 cov=floatBitsToUint(cvf);vec2 s1=unpackHalf2x16(cov.y),s2=unpackHalf2x16(cov.z);vec3 scale=vec3(s1.x,s1.y,s2.x);maxScale=max(max(s1.x,s1.y),s2.x);vec4 rot=vec4((cov.x)&0xffu,(cov.x>>8)&0xffu,(cov.x>>16)&0xffu,(cov.x>>24)&0xffu);rot=(rot-128.0f)/128.0f;mat3 M=mat3((1.0f-2.0f*(rot.z*rot.z+rot.w*rot.w))*scale.x,(2.0f*(rot.y*rot.z+rot.x*rot.w))*scale.x,(2.0f*(rot.y*rot.w-rot.x*rot.z))*scale.x,(2.0f*(rot.y*rot.z-rot.x*rot.w))*scale.y,(1.0f-2.0f*(rot.y*rot.y+rot.w*rot.w))*scale.y,(2.0f*(rot.z*rot.w+rot.x*rot.y))*scale.y,(2.0f*(rot.y*rot.w+rot.x*rot.z))*scale.z,(2.0f*(rot.z*rot.w-rot.x*rot.y))*scale.z,(1.0f-2.0f*(rot.y*rot.y+rot.z*rot.z))*scale.z);vec2 u1=vec2(M[0].x*M[0].x+M[1].x*M[1].x+M[2].x*M[2].x,M[0].x*M[0].y+M[1].x*M[1].y+M[2].x*M[2].y)*4.0f;vec2 u2=vec2(M[0].x*M[0].z+M[1].x*M[1].z+M[2].x*M[2].z,M[0].y*M[0].y+M[1].y*M[1].y+M[2].y*M[2].y)*4.0f;vec2 u3=vec2(M[0].y*M[0].z+M[1].y*M[1].z+M[2].y*M[2].z,M[0].z*M[0].z+M[1].z*M[1].z+M[2].z*M[2].z)*4.0f;mat3 Vrk=mat3(u1.x,u1.y,u2.x,u1.y,u2.y,u3.x,u2.x,u3.x,u3.y);float focal=viewport.x*czm_projection[0][0];mat3 J=mat3(focal/splat_cam.z,0.f,-(focal*splat_cam.x)/(splat_cam.z*splat_cam.z),0.f,focal/splat_cam.z,-(focal*splat_cam.y)/(splat_cam.z*splat_cam.z),0.f,0.f,0.f);mat3 W=transpose(mat3(u_mvs));mat3 T=W*J;mat3 cov2d=transpose(T)*Vrk*T;float diagonal1=cov2d[0][0];float offDiagonal=cov2d[0][1];float diagonal2=cov2d[1][1];float mid=0.5f*(diagonal1+diagonal2);float _radius=length(vec2((diagonal1-diagonal2)/2.0f,offDiagonal));float lambda1=mid+_radius;float lambda2=max(mid-_radius,0.1f);vec2 diagonalVector=normalize(vec2(offDiagonal,lambda1-diagonal1));vec2 v1=min(sqrt(2.0f*lambda1),1024.0f)*diagonalVector;vec2 v2=min(sqrt(2.0f*lambda2),1024.0f)*vec2(diagonalVector.y,-diagonalVector.x);color=clamp(splat_proj.z/splat_proj.w+1.0f,0.0f,1.0f)*vec4((cov.w)&0xffu,(cov.w>>8)&0xffu,(cov.w>>16)&0xffu,(cov.w>>24)&0xffu)/255.0f;if(px==1){vec3 splat_view=splat_cam.xyz/splat_cam.w;vec3 dir=normalize(splat_view*mat3(u_mvs));color.xyz+=evalSH(p0,p1,p2,p3,dir);}color=modify(color,u_filter);if((u_sltid!=0&&(floatBitsToUint(ct.w)&0xffu)==uint(u_sltid))||u_sltid==-1){if(u_sltc.a==0.0f){return;}color.rgb=mix(color.rgb,u_sltc.rgb,u_sltc.a);}texCoord=vec3(position.xy,clamp(splat_proj.z,50.0f,1000.0f));vec2 vct=vec2(splat_proj)/splat_proj.w;gl_Position=vec4((vct+position.x*v1/viewport+position.y*v2/viewport)*splat_proj.w,splat_proj.z,splat_proj.w);vec3 smallAxis=M[0]/max(0.001,scale.x);if(scale.y<scale.x&&scale.y<scale.z){smallAxis=M[1]/max(0.001,scale.y);}else if(scale.z<scale.x&&scale.z<scale.y){smallAxis=M[2]/max(0.001,scale.z);}vec3 normal=(u_normalMatrix*smallAxis);vec3 localNormal=mat3(u_view)*normal;float negMask=dot(localNormal,-splat_cam.xyz)<0.0f ?-1.0f : 1.0f;if(negMask<0.0f){localNormal=-localNormal;}float localDistance=abs(dot(localNormal.xyz,splat_cam.xyz));allMap=vec4(localNormal,localDistance);vPosition=ct.xyz;}",fragmentShaderSource:this.ln?"#version 300 es\nprecision highp int;precision highp float;in vec4 color;in vec3 texCoord;in vec4 allMap;in vec3 vPosition;in float maxScale;layout(location=0)out vec4 out_FragColor;layout(location=1)out vec4 fragNormal;layout(location=2)out vec4 fragDistance;layout(location=3)out vec4 position;void main(){float A=dot(texCoord.xy,texCoord.xy);if(A>1.0){discard;}float B=exp(-A*4.0)*color.a;out_FragColor=vec4(color.xyz,B);fragNormal=vec4(allMap.xyz,B);fragDistance=vec4(allMap.w,0,0,B);position=vec4(vPosition,1);}":"#version 300 es\nprecision highp int;precision highp float;in vec4 color;in vec3 texCoord;layout(location=0)out vec4 out_FragColor;void main(){float A=dot(texCoord.xy,texCoord.xy);if(A>1.0f){discard;}float B=exp(-A*4.0)*color.a;if(B<0.0001*texCoord.z)discard;out_FragColor=vec4(color.xyz,B);}",attributeLocations:{position:0,pIdx:1}}),this.dn=r.RenderState.fromCache({depthTest:{enabled:!1,func:r.DepthFunction.ALWAYS},depthMask:!1,blending:{enabled:!0,equationRgb:r.BlendEquation.ADD,equationAlpha:r.BlendEquation.ADD,functionSourceRgb:r.BlendFunction.SOURCE_ALPHA,functionDestinationRgb:r.BlendFunction.ONE_MINUS_SOURCE_ALPHA,functionSourceAlpha:r.BlendFunction.ONE,functionDestinationAlpha:r.BlendFunction.ONE_MINUS_SOURCE_ALPHA}}),this.pn={index:0,vertexBuffer:r.Buffer.createVertexBuffer({usage:r.BufferUsage.STATIC_DRAW,typedArray:new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,-1,0,1,1,0,-1,1,0]),context:this.fe}),componentsPerAttribute:3,componentDatatype:r.ComponentDatatype.FLOAT},this.yn=this.En(this._scene.context),this.Cn(),this.An(),this.In()}_destroy(){this._scene.primitives.remove(this.wn),this.wn=void 0,this.vn.forEach((t=>{t.destroy()})),this.vn=[]}On(t){if(!t)return void(this._modelMatrix=null);const e=r.Cartesian3.fromDegrees(t[0],t[1],t[2]),n=r.Transforms.eastNorthUpToFixedFrame(e);this._modelMatrix=n}Tn(t){this.Mn=t,this.vn.forEach((e=>{e.setBoundingVolume(t)}))}zn(t){this.kn=t}Dn(t){this._n=t}En(t){const e=new Uint8Array([255,255,255,255]);return new r.Texture({context:t,source:{width:1,height:1,arrayBufferView:e},pixelFormat:r.PixelFormat.RGBA,pixelDatatype:r.PixelDatatype.UNSIGNED_BYTE})}An(){this.rn=new r.ClearCommand({framebuffer:this.gn,color:new r.Color(0,0,0,0),depth:1,stencil:0,pass:r.Pass.GLOBE}),this.rn.Pn="clearCommand";const t=new r.VertexArray({name:"gaussian",context:this.fe,attributes:[{index:0,vertexBuffer:r.Buffer.createVertexBuffer({usage:r.BufferUsage.STATIC_DRAW,typedArray:new Float32Array([-1,-1,-1,1,1,1,-1,-1,1,1,1,-1]),context:this.fe}),componentsPerAttribute:2,componentDatatype:r.ComponentDatatype.FLOAT}]}),e="#version 300 es\n precision mediump float;\n precision mediump int;\n in vec2 position;\n out vec2 vTextCoord;\n out vec2 vFocal;\n uniform vec2 fov;\n uniform vec2 viewport;\n\n void main() {\n float xFov = fov.x;\n float yFov = fov.y;\n vFocal = vec2( \n viewport.x / (2.0 * tan(xFov / 2.0)),\n viewport.y / (2.0 * tan(yFov / 2.0))\n );\n vTextCoord = (position + 1.0) / 2.0;\n gl_Position = vec4(position, 0, 1);\n }\n ",n=r.ShaderProgram.fromCache({context:this._scene.context,vertexShaderSource1:e,vertexShaderSource:new r.ShaderSource({sources:[e]}),fragmentShaderSource:new r.ShaderSource({defines:["LOG_DEPTH_READ_ONLY"],sources:["#version 300 es\n precision mediump float;\n precision mediump int;\n in vec2 vTextCoord;\n in vec2 vFocal;\n uniform sampler2D colorTexture;\n uniform sampler2D normalTexture;\n uniform sampler2D distanceTexture;\n uniform sampler2D positionTexture;\n\n uniform mat4 projectMatrix;\n uniform mat4 u_view;\n uniform vec3 u_cameraPos;\n uniform mat4 u_model;\n uniform vec4 u_color;\n\n // 光照相关\n const float PI = 3.14159265359;\n uniform vec3 u_ambientColor; // 环境光\n uniform vec3 u_lightColor; // 方向光\n uniform vec3 u_lightDirection;\n uniform float u_lightIntensity;\n uniform float u_roughness;\n uniform float u_metallic;\n\n // uniform vec3 u_specularColor; // 高光\n // uniform float u_shininess;\n uniform vec2 fov;\n\n // 法线分布函数(GGX)\n float D_GGX(float NdotH, float roughness) {\n float a = roughness * roughness;\n float a2 = a * a;\n float denom = (NdotH * NdotH * (a2 - 1.0) + 1.0);\n return a2 / (PI * denom * denom);\n }\n\n // 几何遮蔽函数(Schlick-GGX)\n float G_SchlickGGX(float NdotV, float roughness) {\n float r = roughness + 1.0;\n float k = (r * r) / 8.0;\n return NdotV / (NdotV * (1.0 - k) + k);\n }\n\n // 菲涅尔方程(Schlick近似)\n vec3 F_Schlick(float HdotV, vec3 F0) {\n return F0 + (1.0 - F0) * pow(1.0 - HdotV, 5.0);\n }\n\n \n void main() {\n ivec2 size = textureSize(colorTexture, 0);\n ivec2 texelCoord = ivec2(vTextCoord * vec2(size));\n out_FragColor = texture(colorTexture, vTextCoord);\n vec3 normal = texelFetch(normalTexture, texelCoord, 0).xyz;\n float localDistance = texelFetch(distanceTexture, texelCoord, 0).r;\n vec3 position = texelFetch(positionTexture, texelCoord, 0).rgb;\n\n if(u_color.a > 0.0) {\n out_FragColor = u_color;\n }\n\n vec3 realNormal = inverse(mat3(u_model)) * inverse(mat3(u_view)) * normal;\n // if(out_FragColor.a > 0.01) {\n vec2 viewport = vec2(size);\n vec2 pixf = vec2(vTextCoord.x, 1.0 - vTextCoord.y) * viewport;\n vec2 ray = (pixf.xy - viewport / 2.0) / vFocal;\n\n normal.x *= -1.0;\n // float depth = localDistance / abs(dot(normal.xyz, vec3(ray, 1)) + 1.0e-8);\n // vec4 ndcDepth = projectMatrix * vec4(0, 0, -depth, 1);\n \n // float vDepth = (ndcDepth.w - czm_currentFrustum.x) + 1.0;\n // if (vDepth <= 0.9999999 || vDepth > czm_farDepthFromNearPlusOne) {\n // discard;\n // }\n // gl_FragDepth = log2(vDepth) * czm_oneOverLog2FarDepthFromNearPlusOne;\n\n\n\n\n\n // 计算光照影响\n // 计算漫反射项\n // 直接使用顶点法线(已转换到世界空间)\n vec3 N = normalize(realNormal);\n // 基础反射率(非金属默认0.04,金属使用Albedo,此处简化为灰色)\n vec3 albedo = vec3(0.7);\n vec3 F0 = mix(vec3(0.04), albedo, u_metallic);\n // 向量计算\n vec3 V = normalize(position - u_cameraPos); // 视线方向\n vec3 L = normalize(u_lightDirection); // normalize(uLightPos - position); // 光源方向\n vec3 H = normalize(V + L); // 半角向量\n \n // 点积项\n float NdotV = max(dot(N, V), 0.001);\n float NdotL = max(dot(N, L), 0.001);\n float NdotH = max(dot(N, H), 0.00);\n float HdotV = max(dot(H, V), 0.00);\n \n // BRDF计算\n float D = D_GGX(NdotH, u_roughness); // 法线分布\n float G = G_SchlickGGX(NdotV, u_roughness) * G_SchlickGGX(NdotL, u_roughness); // 几何遮蔽\n vec3 F = F_Schlick(HdotV, F0);\n\n // 镜面反射项\n vec3 numerator = D * G * F;\n float denominator = 4.0 * NdotV * NdotL;\n vec3 specular = numerator / max(denominator, 0.001);\n \n // 漫反射项(非金属才有)\n vec3 kD = (1.0 - F) * (1.0 - u_metallic);\n // vec3 kD = mix(1.0 - F, vec3(1.0), u_metallic) * (1.0 - u_metallic);\n\n vec3 diffuse = kD * albedo / PI;\n diffuse = max(diffuse, vec3(0.0)); // 防止负值\n \n // 光照贡献\n vec3 radiance = u_lightColor * NdotL * u_lightIntensity;\n vec3 lightC = (diffuse + specular) * radiance;\n\n\n // // 计算漫反射项\n // vec3 viewDirection = normalize(u_cameraPos - position);\n // vec3 diffuseTerm = u_lightColor * max(dot(realNormal, normalize(-u_lightDirection)), 0.0) * u_lightIntensity;\n\n // // 计算高光项\n // // vec3 halfwayVector = normalize(-u_lightDirection + viewDirection);\n // // float specularFactor = pow(max(dot(realNormal, halfwayVector), 0.0), u_shininess);\n // // vec3 specularTerm = u_specularColor * specularFactor;\n\n // // 计算总光照\n // vec3 totalLighting = u_ambientColor + diffuseTerm;\n\n // 计算最终颜色\n out_FragColor.rgb *= (lightC + u_ambientColor); //totalLighting;\n // out_FragColor.rgb = realNormal;\n }\n "]}),attributeLocations:{position:0}});n.Rn=!0,this.en=new r.DrawCommand({vertexArray:t,shaderProgram:n,renderState:r.RenderState.fromCache({depthMask:!1,depthTest:{enabled:!1},blending:{enabled:!0,equationRgb:r.BlendEquation.ADD,equationAlpha:r.BlendEquation.ADD,functionSourceRgb:r.BlendFunction.SOURCE_ALPHA,functionDestinationRgb:r.BlendFunction.ONE_MINUS_SOURCE_ALPHA,functionSourceAlpha:r.BlendFunction.ONE,functionDestinationAlpha:r.BlendFunction.ONE_MINUS_SOURCE_ALPHA}}),uniformMap:{colorTexture:()=>this.Xt[0],normalTexture:()=>this.Xt[1],distanceTexture:()=>this.Xt[2],positionTexture:()=>this.Xt[3],projectMatrix:()=>this._scene.camera.frustum.projectionMatrix,u_cameraPos:()=>new r.Cartesian3(this._scene.camera.positionWC.x-this.vn[0].We._modelMatrix[12],this._scene.camera.positionWC.y-this.vn[0].We._modelMatrix[13],this._scene.camera.positionWC.z-this.vn[0].We._modelMatrix[14]),u_model:()=>this.vn[0].We._modelMatrix,u_color:()=>this.Sn,u_view:()=>{const t=new r.Matrix4;r.Matrix4.multiply(this._scene.camera.viewMatrix,this.vn[0].We._modelMatrix,t);const e=new r.Matrix4;return this._scene.camera.viewMatrix.clone(e),e[12]=t[12],e[13]=t[13],e[14]=t[14],e},fov:()=>new r.Cartesian2(this._scene.camera.frustum.fov,this._scene.camera.frustum.fovy),viewport:()=>new r.Cartesian2(this._scene.context.drawingBufferWidth,this._scene.context.drawingBufferHeight),u_ambientColor:()=>this.kn&&this.kn.enable?this.kn.ambientColor:new r.Cartesian3(1,1,1),u_lightColor:()=>this.kn&&this.kn.enable?this.kn.lightColor:new r.Cartesian3(1,1,1),u_lightDirection:()=>this.kn&&this.kn.enable?this.kn.lightDirection:new r.Cartesian3(0,0,1),u_lightIntensity:()=>this.kn&&this.kn.enable?this.kn.lightIntensity:0,u_metallic:()=>this.kn&&this._n&&this.kn.enable?this._n.metallic:0,u_roughness:()=>this.kn&&this._n&&this.kn.enable?this._n.roughness:1},pass:this.bn||r.Pass.GLOBE}),this.en.Pn="color_gaussian_fullScreen";const i=r.ShaderProgram.fromCache({context:this._scene.context,vertexShaderSource:new r.ShaderSource({sources:[e]}),fragmentShaderSource:new r.ShaderSource({defines:["LOG_DEPTH_READ_ONLY"],sources:["#version 300 es\n precision mediump float;\n precision mediump int;\n in vec2 vTextCoord;\n in vec2 vFocal;\n uniform sampler2D normalTexture;\n uniform sampler2D distanceTexture;\n\n uniform mat4 projectMatrix;\n uniform mat4 u_view;\n uniform mat4 u_model;\n \n void main() {\n ivec2 size = textureSize(normalTexture, 0);\n ivec2 texelCoord = ivec2(vTextCoord * vec2(size));\n vec3 normal = texelFetch(normalTexture, texelCoord, 0).xyz;\n float localDistance = texelFetch(distanceTexture, texelCoord, 0).r;\n\n vec3 realNormal = inverse(mat3(u_model)) * inverse(mat3(u_view)) * normal;\n vec2 viewport = vec2(size);\n vec2 pixf = vec2(vTextCoord.x, 1.0 - vTextCoord.y) * viewport;\n vec2 ray = (pixf.xy - viewport / 2.0) / vFocal;\n\n normal.x *= -1.0;\n float depth = localDistance / abs(dot(normal.xyz, vec3(ray, 1)) + 1.0e-8);\n vec4 ndcDepth = projectMatrix * vec4(0, 0, -depth, 1);\n \n float vDepth = (ndcDepth.w - czm_currentFrustum.x) + 1.0;\n if (vDepth <= 0.9999999 || vDepth > czm_farDepthFromNearPlusOne) {\n discard;\n }\n gl_FragDepth = log2(vDepth) * czm_oneOverLog2FarDepthFromNearPlusOne;\n out_FragColor = vec4(vec3(vDepth), 0);\n }"]}),attributeLocations:{position:0}});this.nn=new r.DrawCommand({vertexArray:t,shaderProgram:i,renderState:r.RenderState.fromCache({depthMask:!0,depthTest:{enabled:!0},colorMask:{red:!1,green:!1,blue:!1,alpha:!1}}),uniformMap:{normalTexture:()=>this.Xt[1],distanceTexture:()=>this.Xt[2],projectMatrix:()=>this._scene.camera.frustum.projectionMatrix,u_model:()=>this.vn[0].We._modelMatrix,u_view:()=>{const t=new r.Matrix4;r.Matrix4.multiply(this._scene.camera.viewMatrix,this.vn[0].We._modelMatrix,t);const e=new r.Matrix4;return this._scene.camera.viewMatrix.clone(e),e[12]=t[12],e[13]=t[13],e[14]=t[14],e},fov:()=>new r.Cartesian2(this._scene.camera.frustum.fov,this._scene.camera.frustum.fovy),viewport:()=>new r.Cartesian2(this._scene.context.drawingBufferWidth,this._scene.context.drawingBufferHeight)},pass:r.Pass.GLOBE}),this.nn.Pn="depth_gaussian_fullScreen"}Cn(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this._scene.context,n=Math.floor(t/1),i=Math.floor(e/1),s=new r.Texture({context:this._scene.context,width:n,height:i,pixelFormat:r.PixelFormat.RGBA,pixelDatatype:r.PixelDatatype.HALF_FLOAT}),o=new r.Texture({context:this._scene.context,width:n,height:i,pixelFormat:r.PixelFormat.RGBA,pixelDatatype:r.PixelDatatype.HALF_FLOAT}),a=new r.Texture({context:this._scene.context,width:n,height:i,pixelFormat:r.PixelFormat.RGBA,pixelDatatype:r.PixelDatatype.HALF_FLOAT}),u=new r.Texture({context:this._scene.context,width:n,height:i,pixelFormat:r.PixelFormat.RGBA,pixelDatatype:r.PixelDatatype.HALF_FLOAT});this.Xt=[s,o,a,u],this.gn&&this.gn.destroy(),this.gn=new r.Framebuffer({context:this._scene.context,colorTextures:this.ln?this.Xt:[this.Xt[0]]}),this.gn.Nn=[t,e]}In(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this._scene.context;this.vn.length>0&&(this.gn.Nn[0]===t/1&&this.gn.Nn[1]===e/1||(this.Cn(),this.vn[0].Je.framebuffer=this.gn,this.vn[0].rn.framebuffer=this.gn))}Fn(){this.In()}Un(){this.sn=!1,this.wn.show=!1}_show(){this.sn=!0,this.wn.show=!0}qn(){}jn(t,e){if(e){const n=e.getAttribute(1).vertexBuffer;n.sizeInBytes<t.byteLength?(n.destroy(),e=new r.VertexArray({name:"gaussian",context:this.fe,attributes:[this.pn,{name:"pIdx",index:1,vertexBuffer:r.Buffer.createVertexBuffer({usage:r.BufferUsage.STATIC_DRAW,typedArray:t,context:this.fe}),componentsPerAttribute:1,componentDatatype:r.ComponentDatatype.FLOAT,instanceDivisor:1}]})):n?.copyFromArrayView(t)}else e=new r.VertexArray({name:"gaussian",context:this.fe,attributes:[this.pn,{name:"pIdx",index:1,vertexBuffer:r.Buffer.createVertexBuffer({usage:r.BufferUsage.STATIC_DRAW,typedArray:t,context:this.fe}),componentsPerAttribute:1,componentDatatype:r.ComponentDatatype.FLOAT,instanceDivisor:1}]});return e}Bn(t){if(!window.stopUpdate&&this.wn)if(t&&t.oe){this.wn.We=t,this.$n||this.emit("renderfirstframe",null),this.$n=!0;for(let e=0;e<1;e+=1){let n=t;if(this.vn[e]){const t=this.jn(n.Jt,this.vn[e].Je.vertexArray);this.vn[e].Je.vertexArray=t,this.vn[e].Je.instanceCount=n.oe,this.vn[e].We=n}else{this.vn[e]=new Il(n,e,this);const i={viewport:()=>new r.Cartesian2(this._scene.canvas.width,this._scene.canvas.height),u_filter:()=>this.xn,u_cameraPos:()=>new r.Cartesian3(this._scene.camera.positionWC.x-this.vn[e].We._modelMatrix[12],this._scene.camera.positionWC.y-this.vn[e].We._modelMatrix[13],this._scene.camera.positionWC.z-this.vn[e].We._modelMatrix[14]),u_normalMatrix:()=>{let t=this.vn[e].We._modelMatrix,n=r.Matrix4.getMatrix3(t,new r.Matrix3);return r.Matrix3.inverseTranspose(n,n),n},u_modelMatrix:()=>{let t=this.vn[e].We._modelMatrix;return r.Matrix4.getMatrix3(t,new r.Matrix3)},u_view:()=>{const t=new r.Matrix4;r.Matrix4.multiply(this._scene.camera.viewMatrix,this.vn[e].We._modelMatrix,t);const n=new r.Matrix4;return this._scene.camera.viewMatrix.clone(n),n[12]=t[12],n[13]=t[13],n[14]=t[14],n},u_mvs:()=>{const t=new r.Matrix4;return r.Matrix4.multiply(this._scene.camera.viewMatrix,this._modelMatrix||this.vn[e].We._modelMatrix,t),t},u_txts:()=>{const t=this.vn[e].We.Xt,n=new Array(16);return n.fill(this.yn),t.forEach(((t,e)=>{n[e]=t._texture})),n},u_params:()=>new r.Cartesian4(t.jt?1:0,Math.log2(this.Bt/2),Math.ceil(Math.log2(this.Bt*this.Bt)),this.Bt),u_sltid:()=>this.vn[e].We.je||0,u_sltc:()=>this.vn[e].We?.Be||r.Color.fromBytes(0,200,255,80)},s=this.jn(n.Jt);this.vn[e].Je=new r.DrawCommand({vertexArray:s,shaderProgram:this.fn,uniformMap:i,renderState:this.dn,pass:this.bn||r.Pass.GLOBE,instanceCount:n.oe,count:6,framebuffer:this.gn,boundingVolume:this.Mn}),this.vn[e].en=this.en,this.vn[e].rn=this.rn,this.vn[e].nn=this.nn,this.vn[e].Je.Pn="_drawCmd",this.wn.add(this.vn[e])}this.vn[e].show()}for(let t=1;t<this.vn.length;t+=1)this.vn[t].hide();this._scene.requestRender()}else this.wn&&(this.wn.show=!1)}}class Tl{Ln;Ie;We;He;Pe;un;Hn;constructor(t){this.Ln=t.viewer,this.Ie=t.url,this.We=t.data,this.He=t.deltaCenter,this.Pe=t.enuCenter;const e=this.Ln.scene;this.Hn=new Cl({fe:e.context,We:this.We,He:this.He,Pe:this.Pe||[0,0,0]}),this.un=new Ol({ln:!0,scene:e,Bt:this.Hn.textureWidth}),this.Hn.afterSort=t=>{this.un.Bn(t),this.Ln.scene.requestRender()},e.preRender.addEventListener(((t,e)=>{this.Hn.Xe(t)}),this),this.Ln.scene.requestRender()}selectedEntity(t,e){this.Hn.Ke(+t,e)}hide(){this.un.Un()}show(){this.un._show()}setData(t,e){this.Hn.updateData(t,e)}destroy(){this.Hn._destroy(),this.un._destroy()}}const zl=1e-6,Dl=[0,0,0],Pl=[0,0,0],Rl=[0,0,0],Nl=[0,0,0],Fl=[0,0,0],Ul=[0,0,0],ql=[0,0,0],jl=[0,0,0],Bl=[0,0,0],Ll=[0,0,0],Hl=[0,0,0],Vl=[0,0],Wl=[0,0,0],Gl=[0,0,0],Ql=[0,0,0],Kl=[0,0,0],Xl=[0,0,0],Zl=[0,0,0];function Yl(t,e,n,i,r,s){if(kc(e)<zl)return;xc(Wl,n,e),xc(Gl,i,e),xc(Ql,r,e),tc(t,e,Vl),Xl[1]=Vl[0],Kl[1]=Vl[1],Zl[1]=Kl[1]-Xl[1];const o=[n,i,r],a=[Wl,Gl,Ql];for(let n=0;n<3;++n){tc(t,o[n],Vl),Xl[0]=Vl[0],Kl[0]=Vl[1],tc(t,a[n],Vl),Xl[2]=Vl[0],Kl[2]=Vl[1],Zl[0]=Kl[0]-Xl[0],Zl[2]=Kl[2]-Xl[2];const i=yc(Zl);i<s.quality&&(bc(s.b0,o[n]),bc(s.b1,e),bc(s.b2,a[n]),s.quality=i)}}const Jl=[0,0,0];function tc(t,e,n){const{data:i,offsetIdx:r,strideIdx:s}=t;n[0]=Number.POSITIVE_INFINITY,n[1]=Number.NEGATIVE_INFINITY;for(let t=r;t<i.length;t+=s){const r=i[t]*e[0]+i[t+1]*e[1]+i[t+2]*e[2];n[0]=Math.min(n[0],r),n[1]=Math.max(n[1],r)}}function ec(t,e,n){bc(n.center,t),gc(n.halfSize,e,.5),n.quaternion[0]=0,n.quaternion[1]=0,n.quaternion[2]=0,n.quaternion[3]=1}const nc=[0,0,0],ic=[0,0,0],rc=[0,0,0],sc=[0,0,0],oc=[0,0,0],ac=[0,0,0];function uc(t,e,n){bc(nc,e),Math.abs(e[0])>Math.abs(e[1])&&Math.abs(e[0])>Math.abs(e[2])?nc[0]=0:Math.abs(e[1])>Math.abs(e[2])?nc[1]=0:nc[2]=0,kc(nc)<zl&&(nc[0]=nc[1]=nc[2]=1),xc(ic,e,nc),_c(ic,ic),xc(rc,e,ic),_c(rc,rc),hc(t,e,ic,rc,sc,oc),wc(ac,oc,sc),dc(e,ic,rc,sc,oc,ac,n)}function hc(t,e,n,i,r,s){tc(t,e,Vl),r[0]=Vl[0],s[0]=Vl[1],tc(t,n,Vl),r[1]=Vl[0],s[1]=Vl[1],tc(t,i,Vl),r[2]=Vl[0],s[2]=Vl[1]}const lc=[0,0,0],cc=[1,0,0,0,1,0,0,0,1],fc=[0,0,0];function dc(t,e,n,i,r,s,o){cc[0]=t[0],cc[1]=t[1],cc[2]=t[2],cc[3]=e[0],cc[4]=e[1],cc[5]=e[2],cc[6]=n[0],cc[7]=n[1],cc[8]=n[2],function(t,e){const n=e[0]+e[4]+e[8];if(n>0){let i=Math.sqrt(n+1);t[3]=.5*i,i=.5/i,t[0]=(e[5]-e[7])*i,t[1]=(e[6]-e[2])*i,t[2]=(e[1]-e[3])*i}else{let n=0;e[4]>e[0]&&(n=1),e[8]>e[3*n+n]&&(n=2);const i=(n+1)%3,r=(n+2)%3;let s=Math.sqrt(e[3*n+n]-e[3*i+i]-e[3*r+r]+1);t[n]=.5*s,s=.5/s,t[3]=(e[3*i+r]-e[3*r+i])*s,t[i]=(e[3*i+n]+e[3*n+i])*s,t[r]=(e[3*r+n]+e[3*n+r])*s}}(o.quaternion,cc),mc(fc,i,r),gc(fc,fc,.5),gc(o.center,t,fc[0]),gc(lc,e,fc[1]),mc(o.center,o.center,lc),gc(lc,n,fc[2]),mc(o.center,o.center,lc),gc(o.halfSize,s,.5)}class pc{buffer;minProj;maxProj;minVert=new Array(7);maxVert=new Array(7);constructor(t){this.buffer=new ArrayBuffer(448);let e=0;this.minProj=new Float64Array(this.buffer,e,7),e+=56,this.maxProj=new Float64Array(this.buffer,e,7),e+=56;for(let t=0;t<7;++t)this.minVert[t]=new Float64Array(this.buffer,e,3),e+=24;for(let t=0;t<7;++t)this.maxVert[t]=new Float64Array(this.buffer,e,3),e+=24;for(let t=0;t<7;++t)this.minProj[t]=Number.POSITIVE_INFINITY,this.maxProj[t]=Number.NEGATIVE_INFINITY;const n=new Array(7),i=new Array(7),{data:r,offsetIdx:s,strideIdx:o}=t;for(let t=s;t<r.length;t+=o){let e=r[t];e<this.minProj[0]&&(this.minProj[0]=e,n[0]=t),e>this.maxProj[0]&&(this.maxProj[0]=e,i[0]=t),e=r[t+1],e<this.minProj[1]&&(this.minProj[1]=e,n[1]=t),e>this.maxProj[1]&&(this.maxProj[1]=e,i[1]=t),e=r[t+2],e<this.minProj[2]&&(this.minProj[2]=e,n[2]=t),e>this.maxProj[2]&&(this.maxProj[2]=e,i[2]=t),e=r[t]+r[t+1]+r[t+2],e<this.minProj[3]&&(this.minProj[3]=e,n[3]=t),e>this.maxProj[3]&&(this.maxProj[3]=e,i[3]=t),e=r[t]+r[t+1]-r[t+2],e<this.minProj[4]&&(this.minProj[4]=e,n[4]=t),e>this.maxProj[4]&&(this.maxProj[4]=e,i[4]=t),e=r[t]-r[t+1]+r[t+2],e<this.minProj[5]&&(this.minProj[5]=e,n[5]=t),e>this.maxProj[5]&&(this.maxProj[5]=e,i[5]=t),e=r[t]-r[t+1]-r[t+2],e<this.minProj[6]&&(this.minProj[6]=e,n[6]=t),e>this.maxProj[6]&&(this.maxProj[6]=e,i[6]=t)}for(let t=0;t<7;++t){let e=n[t];bc(this.minVert[t],r,e),e=i[t],bc(this.maxVert[t],r,e)}}}class vc{b0=[1,0,0];b1=[0,1,0];b2=[0,0,1];quality=0}function yc(t){return t[0]*t[1]+t[0]*t[2]+t[1]*t[2]}function mc(t,e,n){t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2]}function wc(t,e,n){t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2]}function gc(t,e,n){t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n}function bc(t,e,n=0){t[0]=e[n+0],t[1]=e[n+1],t[2]=e[n+2]}function xc(t,e,n){const i=e[0],r=e[1],s=e[2],o=n[0],a=n[1],u=n[2];t[0]=r*u-s*a,t[1]=s*o-i*u,t[2]=i*a-r*o}function _c(t,e){const n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(n>0){const i=1/Math.sqrt(n);t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i}}function kc(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function $c(t,e){const n=e[0]-t[0],i=e[1]-t[1],r=e[2]-t[2];return n*n+i*i+r*r}function Sc(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}const Mc=(t,e)=>{const n=10**e;return Math.round(t*n)/n},Ec=(t,e,n=!1)=>{const i=t[0],r=t[1];let s,o,a,u,h=!1;const l=e.length;for(let t=0,c=l-1;t<l;c=t,t+=1){let l=!1;if(s=e[t][0],o=e[t][1],a=e[c][0],u=e[c][1],s===i&&o===r||a===i&&u===r)return!!n;if(o<r==u>=r){const t=(a-s)*(r-o)/(u-o)+s;if(i===t)return!!n;l=i<t}l&&(h=!h)}return h},Cc=(t,e)=>{var n=e[0],i=e[1],s=e[2],o=t[0],a=t[1],u=t[2];const h=r.Cartesian3.fromDegrees(o,a,u),l=r.Cartesian3.fromDegrees(n,i,s),c=r.Transforms.eastNorthUpToFixedFrame(l);var f=r.Matrix4.inverse(c,new r.Matrix4);return r.Matrix4.multiplyByPoint(f,h,new r.Cartesian3)},Ac=new r.Matrix4,Ic=new r.Matrix4,Oc=new r.Cartesian3;function Tc(t,e,n){const[i,s,o]=e;return r.Cartesian3.fromDegrees(i,s,o,void 0,Oc),r.Transforms.eastNorthUpToFixedFrame(Oc,void 0,Ic),r.Matrix4.inverseTransformation(Ic,Ac),r.Matrix4.multiplyByPoint(Ac,t,n||new r.Cartesian3)}function zc(t,e,n,i){const s=Dc(t,e,n,i),o=r.Cartographic.fromCartesian(s);return[o.longitude,o.latitude,o.height]}function Dc(t,e,n,i){if(!n){const[t,i,o]=e;var s=r.Cartesian3.fromDegrees(t,i,o);n=r.Transforms.eastNorthUpToFixedFrame(s)}return r.Matrix4.multiplyByPoint(n,t,i||new r.Cartesian3)}function Pc(t){var e=r.Cartographic.fromCartesian(t);return{lng:r.Math.toDegrees(e.longitude),lat:r.Math.toDegrees(e.latitude),height:e.height}}function Rc(t,e){const n=2*Math.PI;let i=(e=(e%n+n)%n)-(t=(t%n+n)%n);return i>Math.PI?i-=n:i<-Math.PI&&(i+=n),i}var Nc,Fc=new Float32Array(1);function Uc(t){const e=[];for(let n=0,i=t.length;n<i;n+=2)e.push(parseInt(t.substr(n,2),16)/255);return e.push(e.shift()),e}function qc(t,e){let n,i,r,s,o,a,u,h="ASDFGHJKLQWERTYUIO!sdfghjkleiu3~yr5-P&mq9`%zCN*b=8@^xpVM";for((e=e||"v5")>"v5"?(n=h.length,i=512):(n=27,h=h.substr(0,27),i=333),s=[],o=NaN,a=0,u=t.length;a<u;a++)r=t[a],r=h.indexOf(r),isNaN(o)?o=r*n:(s.push(o+r-i),o=NaN);return s}function jc(t){if(t.toArray)return t.toArray();{const e=[];let n=t.next();for(;!n.done;)e.push(n.value),n=t.next();return e}}new Int32Array(Fc.buffer);class Bc{Vn;Wn;fe;Gn;Qn;Kn=[];Xn=-1;Zn="close";Yn={};Jn=0;ti;ei;ii;oi;ai;ui;hi;li=[0,0];ci=[];fi=[1/0,1/0,1/0,-1/0,-1/0,-1/0];options={layer:void 0,inPointStyle:{color:"rgba(37,165,247,1)",radius:6,borderWidth:4,borderColor:"rgba(255,255,255,1)"},outPointStyle:{color:"rgba(247,55,37,1)",radius:6,borderWidth:4,borderColor:"rgba(255,255,255,1)"},polygonStyle:{color:"rgba(0,255,255,0.6)",borderWidth:4,borderColor:"rgba(255,255,255,1)"},model:{encoderUrl:"",decoderUrl:"",name:"model",wasmPaths:""}};constructor(t){t.viewer&&(this.Vn=t.viewer.container,this.options.inPointStyle=Object.assign(this.options.inPointStyle,t.inPointStyle),this.options.outPointStyle=Object.assign(this.options.outPointStyle,t.outPointStyle),this.options.polygonStyle=Object.assign(this.options.polygonStyle,t.polygonStyle),this.options.model=Object.assign(this.options.model,t.model),this.options.viewer=t.viewer,this.options.layer=t.layer,this.options.layer&&(this.di(),this.pi()))}show(){this.Wn.style.visibility="visible",this.Gn.style.visibility="visible"}hide(){this.Wn.style.visibility="hidden",this.Gn.style.visibility="hidden"}open(){this.Zn="open",this.Wn.style.visibility="visible",this.Gn.style.visibility="visible",this.Wn.style.pointerEvents="all",this.Wn.addEventListener("mousedown",this.yi),this.Wn.addEventListener("mouseup",this.mi),this.Vn.addEventListener("contextmenu",this.yi)}createMask(){"open"!==this.Zn&&"adding"!==this.Zn||(this.Zn="adding",this.Qn.clearRect(0,0,this.Gn.width,this.Gn.height),this.fe.clearRect(0,0,this.Wn.width,this.Wn.height),this.Wn.style.pointerEvents=this.Gn.style.pointerEvents="all",this.Xn++,this.Kn[this.Xn]=[])}async embeddings(){await this.wi(),void 0===this.ii&&await this.ti,this.hi=await this.ii}maskCompleted(){this.Qn.clearRect(0,0,this.Gn.width,this.Gn.height),this.fe.clearRect(0,0,this.Wn.width,this.Wn.height),this.Wn.style.pointerEvents=this.Gn.style.pointerEvents="none",this.gi()}highLight(t){if(!this.options.viewer)return;if(!this.ai||0===this.ai.length)return;let e=0;for(let t=0;t<this.ai.length;t++){const{centers:n,rgbas:i,sigmas:r}=this.ai[t];n&&i&&r&&(e+=n.byteLength/3*8)}const n=new ArrayBuffer(e),i=new DataView(n);let r=0;const s=[0,0,0];for(let t=0;t<this.ai.length;t++){const{centers:e,rgbas:n,sigmas:o,modelMatrix:a,count:u,indices:h}=this.ai[t];if(0===t&&(s[0]=a[12],s[1]=a[13],s[2]=a[14]),e&&n&&o){const t=new Float32Array(e),s=new Uint8Array(n),a=new Uint32Array(o);for(let e=0;e<t.length/3;e++){const n=r+e,o=t[3*e],u=t[3*e+1],h=t[3*e+2];this.fi[0]=Math.min(o,this.fi[0]),this.fi[1]=Math.min(u,this.fi[1]),this.fi[2]=Math.min(h,this.fi[2]),this.fi[3]=Math.max(o,this.fi[3]),this.fi[4]=Math.max(u,this.fi[4]),this.fi[5]=Math.max(h,this.fi[5]);const l=s[4*e],c=s[4*e+1],f=s[4*e+2],d=s[4*e+3],p=32*n;i.setFloat32(p,o,!0),i.setFloat32(p+4,u,!0),i.setFloat32(p+8,h,!0),i.setUint8(p+12,1),i.setUint8(p+15,1),i.setUint32(p+16,a[3*e],!0),i.setUint32(p+20,a[3*e+1],!0),i.setUint32(p+24,a[3*e+2],!0),i.setUint8(p+28,l),i.setUint8(p+29,c),i.setUint8(p+30,f),i.setUint8(p+31,d)}r+=u||0}}this.ui=new Tl({viewer:this.options.viewer,deltaCenter:s,enuCenter:this.options.layer?.getEnuCenter(),data:n}),this.ui.selectedEntity(-1,t)}cancelMask(){this.Zn="open",this.Jn=0,this.fe.clearRect(0,0,this.Wn.width,this.Wn.height),this.Kn[this.Xn]=[],this.Xn--}close(){this.Zn="close",this.Jn=0,this.fe.clearRect(0,0,this.Wn.width,this.Wn.height),this.Qn.clearRect(0,0,this.Gn.width,this.Gn.height),this.Kn=[],this.fi=[1/0,1/0,1/0,-1/0,-1/0,-1/0],this.Xn=-1,this.Wn.style.visibility=this.Gn.style.visibility="hidden",this.Wn.style.pointerEvents=this.Gn.style.pointerEvents="none",this.Vn.removeEventListener("contextmenu",this.yi),this.Wn.removeEventListener("mousedown",this.yi),this.Wn.removeEventListener("mouseup",this.mi)}removePoint(){"adding"===this.Zn&&this.Kn[this.Xn].length>0&&(this.Kn[this.Xn].pop(),this.xi(),this._i())}getSingleData(){return this.ai}getSingleModel(){return this.ui}lock(){this.Zn="locking",this.Wn.style.pointerEvents="all";var t=this.options.viewer.scene.screenSpaceCameraController;this.Yn={enableTranslate:t.enableTranslate,enableZoom:t.enableZoom,enableRotate:t.enableRotate,enableTilt:t.enableTilt,enableLook:t.enableLook,inertiaSpin:t.inertiaSpin,inertiaTranslate:t.inertiaTranslate,inertiaZoom:t.inertiaZoom},t.enableTranslate=!1,t.enableZoom=!1,t.enableRotate=!1,t.enableTilt=!1,t.enableLook=!1,t.inertiaSpin=0,t.inertiaTranslate=0,t.inertiaZoom=0}unlock(){this.Zn="open",this.Wn.style.pointerEvents="none";var t=this.options.viewer.scene.screenSpaceCameraController;t.enableTranslate=this.Yn.enableTranslate,t.enableZoom=this.Yn.enableZoom,t.enableRotate=this.Yn.enableRotate,t.enableTilt=this.Yn.enableTilt,t.enableLook=this.Yn.enableLook,t.inertiaSpin=this.Yn.inertiaSpin,t.inertiaTranslate=this.Yn.inertiaTranslate,t.inertiaZoom=this.Yn.inertiaZoom}ki(t){const e=this.options.layer?.getEnuCenter();if(!e)return;const n=[];for(let i=0;i<t.length;i++){const{rotation:s,scale:o,center:a}=t[i],u=new r.Cartesian3(2*o[0],2*o[1],2*o[2]),h=Dc(new r.Cartesian3(a[0],a[1],a[2]),e),l=new r.HeadingPitchRoll(s[0],s[1],s[2]),c=r.Transforms.headingPitchRollQuaternion(h,l),f=this.options.viewer?.entities.add({name:"single boxs",position:h,orientation:c,box:{dimensions:u,material:new r.Color(1,0,1,1),outline:!0,outlineWidth:5}});n.push(f)}return n}di(){const t=document.createElement("canvas"),e=document.createElement("canvas"),n=this.Vn?.getBoundingClientRect();n&&(t.width=e.width=n.width*window.devicePixelRatio,t.height=e.height=n.height*window.devicePixelRatio,t.style.cssText=e.style.cssText="\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n ",this.Vn.appendChild(e),this.Vn.appendChild(t),this.Wn=t,this.Gn=e,this.fe=t.getContext("2d")||void 0,this.Qn=e.getContext("2d")||void 0,this.In())}async _i(){const t=[],e=[];this.Kn[this.Xn].forEach((n=>{e.push(n.isIn?1:0),t.push(...n.point)})),0!==e.length&&(await this.$i(t,e),await this.Si())}async pi(){const t=this.options.model;yl.env.wasm.wasmPaths=t.wasmPaths||"../../onnx/",yl.env.wasm.numThreads=10;const e=await caches.open("onnx");await e.match(t.encoderUrl),await e.match(t.decoderUrl);const n={executionProviders:["webgpu"],enableMemPattern:!1,enableCpuMemArena:!1,extra:{session:{disable_prepacking:"1",use_device_allocator_for_initializers:"1",use_ort_model_bytes_directly:"1",use_ort_model_bytes_for_initializers:"1"}}},i=await this.Mi(t.encoderUrl),r=await this.Mi(t.decoderUrl);this.ti=await yl.InferenceSession.create(i,n),this.ei=await yl.InferenceSession.create(r,n)}async Mi(t){try{const e=await caches.open("onnx");let n=await e.match(t);if(null==n&&(await e.add(t),n=await e.match(t)),n)return await n.arrayBuffer()}catch(e){return await fetch(t).then((t=>t.arrayBuffer()))}}async $i(t,e){if(t.length>0){const n=this.ei,i=this.Ei(t,e),r=(await n.run(i)).masks;this.oi=r.toImageData()}}Ei(t,e){const n=new yl.Tensor(new Float32Array(65536),[1,1,256,256]),i=new yl.Tensor(new Float32Array([0]),[1]),r=new yl.Tensor(new Float32Array([1024,1024]),[2]),s=new yl.Tensor(new Float32Array(t),[1,t.length/2,2]),o=new yl.Tensor(new Float32Array(e),[1,e.length]);return{image_embeddings:new yl.Tensor(this.hi.image_embeddings.type,Float32Array.from(this.hi.image_embeddings.data),this.hi.image_embeddings.dims),point_coords:s,point_labels:o,mask_input:n,has_mask_input:i,orig_im_size:r}}async wi(){this.ii=void 0;const t=document.createElement("canvas");t.width=1024,t.height=1024;const e=t.getContext("2d");if(e&&this.options.viewer?.canvas){e.drawImage(this.options.viewer?.canvas,0,0,t.width,t.height);const n=e.getImageData(0,0,1024,1024),i=await yl.Tensor.fromImage(n,{resizedWidth:1024,resizedHeight:1024}),r=await this.ti;this.ii=r.run({input_image:i}),this.ii.then((()=>{}))}}mi=t=>{const e=t;if(this.li[0]!==e.clientX||this.li[1]!==e.clientY)return;const n=this.Wn?.getBoundingClientRect();if(n){const t=Math.trunc(e.clientX-n.left)*window.devicePixelRatio,i=Math.trunc(e.clientY-n.top)*window.devicePixelRatio;0===e.button?this.Ci([t,i],!0):2===e.button&&this.Ci([t,i],!1)}};yi=t=>{const e=t;e.preventDefault(),this.li=[e.clientX,e.clientY]};Ci(t,e){void 0===this.Kn[this.Xn]&&(this.Kn[this.Xn]=[]),this.Kn[this.Xn].length>5||("adding"===this.Zn&&this.Kn[this.Xn].push({isIn:e,point:[Math.trunc(t[0]/this.Wn.width*1024),Math.trunc(t[1]/this.Wn.height*1024)]}),this.xi(),this._i())}xi(){this.fe?.clearRect(0,0,this.Wn.width,this.Wn.height);for(let t=0;t<this.Kn[this.Xn].length;t++){const e=this.Kn[this.Xn][t],n=e.isIn?this.options.inPointStyle:this.options.outPointStyle;this.fe.strokeStyle=n.borderColor,this.fe.lineWidth=n.borderWidth*window.devicePixelRatio,this.fe.fillStyle=n.color,this.fe.beginPath(),this.fe.arc(e.point[0]/1024*this.Wn.width,e.point[1]/1024*this.Wn.height,n.radius*window.devicePixelRatio,0,2*Math.PI,!1),this.fe.closePath(),this.fe.stroke(),this.fe.fill()}}async Si(){const t=this.oi,e=t.data,n=this.options.polygonStyle.color.slice(5,-1).split(",");this.Qn.clearRect(0,0,this.Gn.width,this.Gn.height);for(let t=0;t<e.length;t+=4)0!==e[t]?(e[t]=+n[0],e[t+1]=+n[1],e[t+2]=+n[2],e[t+3]=255*+n[3]):e[t+3]=0;this.Qn.drawImage(await createImageBitmap(t),0,0,this.Gn.width,this.Gn.height)}gi(){if(!this.options.layer)return;const t=this.options.viewer.scene.camera.viewMatrix,e=this.options.viewer.scene.camera.frustum.projectionMatrix,n=new r.Matrix4;r.Matrix4.multiply(e,t,n),this.ci=[];let i=!1;if(this.ai&&0!==this.ai.length||0!==this.Jn||(i=!0,this.ai=this.options.layer.Ai().map((t=>({tileNum:t.Ii,modelMatrix:t._modelMatrix,centers:t.Gt,rgbas:t.Oi,sigmas:t.Ti,indices:[]})))),this.ai){const{data:t,width:e,height:s}=this.oi,o=[];for(let a=0;a<this.ai.length;a++){const u=this.ai[a];if(u.centers&&u.centers.byteLength>0&&u.rgbas&&u.sigmas){const a=[],h=[];let l=new Uint32Array(u.centers.byteLength/4);const c=[],f=new Float32Array(u.centers),d=new Uint8Array(u.rgbas),p=new Uint32Array(u.sigmas),v=new r.Matrix4;r.Matrix4.multiply(n,u.modelMatrix,v);const y=f.length,m=u.indices;let w=0;for(let n=0;n<y;n++){const o=f[3*n],u=f[3*n+1],y=f[3*n+2],g=new r.Cartesian3(o,u,y);r.Matrix4.multiplyByPoint(v,new r.Cartesian3(o,u,y),g),g.x=Math.trunc((g.x/g.z+1)/2*e),g.y=s-Math.trunc((g.y/g.z+1)/2*s),g.x>0&&g.x<e&&g.y<s&&g.y>0&&t[4*(e*g.y+g.x)+3]>0&&(i?c.push(n):m&&c.push(m[n]),a.push(o,u,y),this.ci.push([o,u,y]),h.push(d[4*n],d[4*n+1],d[4*n+2],d[4*n+3]),l[w]=p[3*n],l[w+1]=p[3*n+1],l[w+2]=p[3*n+2],w+=3)}l=l.slice(0,w),a.length>0&&o.push({centers:new Float32Array(a).buffer,rgbas:new Uint8Array(h).buffer,sigmas:l.buffer,tileNum:u.tileNum,modelMatrix:u.modelMatrix,count:a.length/3,indices:c})}}this.ai=o}}zi(t){const e={center:new Float64Array([0,0,0]),halfSize:new Float32Array([0,0,0]),quaternion:new Float32Array([0,0,0,1])};return function(t,e){const{data:n,strideIdx:i}=t,r=n.length/i;if(r<=0)return;const s=new pc(t);mc(Dl,s.minProj,s.maxProj),gc(Dl,Dl,.5),wc(Pl,s.maxProj,s.minProj);const o=yc(Pl),a=new vc;a.quality=o,r<14&&(t={data:new Float64Array(s.buffer,112,42),size:3,offsetIdx:0,strideIdx:3});const u=[0,0,0],h=[0,0,0],l=[0,0,0],c=[0,0,0],f=[0,0,0],d=[0,0,0],p=[0,0,0];switch(function(t,e,n,i,r,s,o,a,u,h,l){if(function(t,e,n){let i=$c(t.maxVert[0],t.minVert[0]),r=0;for(let e=1;e<7;++e){const n=$c(t.maxVert[e],t.minVert[e]);n>i&&(i=n,r=e)}bc(e,t.minVert[r]),bc(n,t.maxVert[r])}(t,i,r),$c(i,r)<zl)return 1;wc(o,i,r),_c(o,o);const c=function(t,e,n,i){const{data:r,offsetIdx:s,strideIdx:o}=t;let a=Number.NEGATIVE_INFINITY,u=0;for(let t=s;t<r.length;t+=o){Hl[0]=r[t]-e[0],Hl[1]=r[t+1]-e[1],Hl[2]=r[t+2]-e[2];const i=n[0]*Hl[0]+n[1]*Hl[1]+n[2]*Hl[2],s=n[0]*n[0]+n[1]*n[1]+n[2]*n[2],o=Hl[0]*Hl[0]+Hl[1]*Hl[1]+Hl[2]*Hl[2]-i*i/s;o>a&&(a=o,u=t)}return bc(i,r,u),a}(e,i,o,s);return c<zl?2:(wc(a,r,s),_c(a,a),wc(u,s,i),_c(u,u),xc(n,a,o),_c(n,n),Yl(e,n,o,a,u,h),0)}(s,t,p,u,h,l,c,f,d,a)){case 1:return void ec(Dl,Pl,e);case 2:return void uc(t,c,e)}!function(t,e,n,i,r,s,o,a,u,h){(function(t,e,n,i,r,s,o){!function(t,e,n,i,r){const{data:s,offsetIdx:o,strideIdx:a}=t;bc(i,s,o),bc(r,i),n[0]=Sc(Jl,e),n[1]=n[0];for(let t=o+a;t<s.length;t+=a){const o=s[t]*e[0]+s[t+1]*e[1]+s[t+2]*e[2];o<n[0]&&(n[0]=o,bc(i,s,t)),o>n[1]&&(n[1]=o,bc(r,s,t))}}(t,e,Vl,o,s);const a=Sc(n,e);Vl[1]-zl<=a&&(s[0]=-1/0),Vl[0]+zl>=a&&(o[0]=-1/0)})(t,e,n,0,0,Rl,Nl),void 0!==Rl[0]&&(wc(Fl,Rl,n),_c(Fl,Fl),wc(Ul,Rl,i),_c(Ul,Ul),wc(ql,Rl,r),_c(ql,ql),xc(jl,Ul,s),_c(jl,jl),xc(Bl,ql,o),_c(Bl,Bl),xc(Ll,Fl,a),_c(Ll,Ll),Yl(t,jl,s,Ul,Fl,u),Yl(t,Bl,o,ql,Ul,u),Yl(t,Ll,a,Fl,ql,u)),void 0!==Nl[0]&&(wc(Fl,Nl,n),_c(Fl,Fl),wc(Ul,Nl,i),_c(Ul,Ul),wc(ql,Nl,r),_c(ql,ql),xc(jl,Ul,s),_c(jl,jl),xc(Bl,ql,o),_c(Bl,Bl),xc(Ll,Fl,a),_c(Ll,Ll),Yl(t,jl,s,Ul,Fl,u),Yl(t,Bl,o,ql,Ul,u),Yl(t,Ll,a,Fl,ql,u))}(t,p,u,h,l,c,f,d,a),hc(t,a.b0,a.b1,a.b2,sc,oc);const v=[0,0,0];wc(v,oc,sc),a.quality=yc(v),a.quality<o?dc(a.b0,a.b1,a.b2,sc,oc,v,e):ec(Dl,Pl,e)}({data:t,size:3,offsetIdx:0,strideIdx:3},e),e}In(){window.addEventListener("resize",(()=>{const t=this.Vn?.getBoundingClientRect();t&&this.Wn&&this.Gn&&(this.Wn.width=this.Gn.width=t.width*window.devicePixelRatio,this.Wn.height=this.Gn.height=t.height*window.devicePixelRatio,this.Wn.style.cssText=this.Gn.style.cssText="\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n ")}))}}class Lc{Ln;We;Di=[];Pi;Ri;Ni;Fi;Ui;constructor(t){const e=t.viewer;this.Ln=e,this.We=t.data;const n=t.style.materialColor?t.style.materialColor:"rgba(255 165 0 0.5)",i=void 0===t.style.outline||t.style.outline;let s=t.style.outlineColor?t.style.outlineColor:"rgba(0, 0, 0, 0)";const o=t.style.outlineWidth?t.style.outlineWidth:1;!1===i&&(s="rgba(0, 0, 0, 0)"),this.Ni={materialColor:n,outline:i,outlineColor:s,outlineWidth:o};let a=[],u=[],h=0;for(let t of this.We){const e=r.Cartesian3.fromDegreesArrayHeights(t),i=new r.PolygonGeometry({polygonHierarchy:new r.PolygonHierarchy(e),perPositionHeight:!0}),o=new r.GeometryInstance({id:"polygon_"+h,geometry:i,attributes:{color:r.ColorGeometryInstanceAttribute.fromColor(r.Color.fromCssColorString(n))}});a.push(o);const l=new r.PolygonOutlineGeometry({polygonHierarchy:new r.PolygonHierarchy(e),perPositionHeight:!0});let c=new r.GeometryInstance({id:"polygonOutline_"+h,geometry:l,attributes:{color:r.ColorGeometryInstanceAttribute.fromColor(r.Color.fromCssColorString(s))}});u.push(c),h++}let l=new r.Primitive({geometryInstances:a,appearance:new r.PerInstanceColorAppearance({flat:!0,renderState:{depthTest:{enabled:!1}}})});this.Di.push(l);const c=e.scene.primitives.add(l);this.Fi=c;let f=new r.Primitive({geometryInstances:u,appearance:new r.PerInstanceColorAppearance({flat:!0})});this.Di.push(f);const d=e.scene.primitives.add(f);this.Ui=d}show(t){"all"===t.id?this.Di.forEach((t=>{t.show=!0})):this.Di.forEach((e=>{e.id===t.id&&(e.show=!0)}))}hide(t){"all"===t.id?this.Di.forEach((t=>{t.show=!1})):this.Di.forEach((e=>{e.id===t.id&&(e.show=!1)}))}styleChange(t){const e=t.style.materialColor?t.style.materialColor:"rgba(255 165 0 0.5)",n=void 0===t.style.outline||t.style.outline;let i=t.style.outlineColor?t.style.outlineColor:"rgba(0, 0, 0, 0)";const s=t.style.outlineWidth?t.style.outlineWidth:1;!1===n&&(i="rgba(0, 0, 0, 0)"),this.Ni={materialColor:e,outline:n,outlineColor:i,outlineWidth:s};const o=this.Fi._instanceIds;for(let e of o){const n=e,i="polygonOutline_"+e.split("_")[1];this.Fi.getGeometryInstanceAttributes(n).color=r.ColorGeometryInstanceAttribute.toValue(r.Color.fromCssColorString(t.style.materialColor)),this.Ui.getGeometryInstanceAttributes(i).color=r.ColorGeometryInstanceAttribute.toValue(r.Color.fromCssColorString(t.style.outlineColor))}}resetHighlight(){if(this.Pi){const{materialColor:t,outline:e,outlineColor:n,outlineWidth:i}=this.Ni;this.Fi.getGeometryInstanceAttributes(this.Pi).color=r.ColorGeometryInstanceAttribute.toValue(r.Color.fromCssColorString(t)),this.Ui.getGeometryInstanceAttributes(this.Ri).color=r.ColorGeometryInstanceAttribute.toValue(r.Color.fromCssColorString(n))}}highlight(t){var e=this.Ln.scene.pick(t.position);let n,i,s,o=r.defined(e)?e.id:void 0;if(void 0!==o){if(o.startsWith("polygon_")?(n=o,i="polygonOutline_"+o.split("_")[1],s="polygon"):o.startsWith("polygonOutline_")&&(i=o,n="polygon_"+o.split("_")[1],s="polygonOutline"),this.Pi){const{materialColor:t,outline:e,outlineColor:n,outlineWidth:i}=this.Ni;this.Fi.getGeometryInstanceAttributes(this.Pi).color=r.ColorGeometryInstanceAttribute.toValue(r.Color.fromCssColorString(t)),this.Ui.getGeometryInstanceAttributes(this.Ri).color=r.ColorGeometryInstanceAttribute.toValue(r.Color.fromCssColorString(n))}if(r.defined(e)&&(this.Pi=n,this.Ri=i,"polygon"===s)){const e=this.Fi.getGeometryInstanceAttributes(n);let s=t.style.materialColor?t.style.materialColor:null;if(s&&(e.color=r.ColorGeometryInstanceAttribute.toValue(r.Color.fromCssColorString(s))),t.style.outline){const e=this.Ui.getGeometryInstanceAttributes(i);s=t.style.outlineColor?t.style.outlineColor:null,s&&(e.color=r.ColorGeometryInstanceAttribute.toValue(r.Color.fromCssColorString(s)))}else this.Ui.getGeometryInstanceAttributes(i).color=r.ColorGeometryInstanceAttribute.toValue(r.Color.fromCssColorString("rgba(0, 0, 0, 0)"))}}}}class Hc{qi;ji=new Map;Bi=0;Li=30;Hi=null;Vi=.8;Wi=2;Gi=300;Qi=0;constructor(t){this.qi=t.qi,this.Li=t.Bi||30}Ki(t){return{Xi:t,Zi:(new Date).getTime(),Yi:0}}Ji(t,e){let n=this.ji.get(t);return n?(e||(n.Zi=(new Date).getTime(),n.Yi+=1),n.Xi):null}er(t,e){this.ji.forEach(((n,i)=>{t.call(e,n.Xi,i)}))}nr(t,e){if(this.ji.has(t)?this.ji.get(t).Xi=e:(this.Bi+=1,this.ji.set(t,this.Ki(e))),this.Bi>this.Li&&this.ir(),this.Bi>this.Li-1)return!0}rr(t){return this.ji.has(t)}sr(t){if(!this.rr(t))return null;this.Bi-=1;let e=this.ji.get(t);return this.ji.delete(t),e.Xi}_e(){this.ar(),this.ji.clear(),this.Bi=0}_destroy(){this.er(((t,e)=>{this.qi?this.qi(e,t)&&this.sr(e):this.sr(e)}),this)}ar(){this.Hi&&clearTimeout(this.Hi)}ir(){if(this.Bi>this.Li*this.Wi)this.ar(),this.ur();else{if((new Date).getTime()-this.Qi<10)return;this.ar();let t=this;this.Hi=setTimeout((function(){t.Hi=null,t.ur()}),this.Gi),this.Qi=(new Date).getTime()}}ur(){let t=Math.round(this.Li*this.Vi);if(this.Bi<t)return;let e,n=this.hr(this.Bi-t);for(let t=0,i=n.length;t<i;t+=1)e=n[t],this.qi?this.qi(e,this.ji.get(e).Xi)&&this.sr(e):this.sr(e)}lr(t,e){let n=this.ji.get(t),i=this.ji.get(e),r=n.Zi-i.Zi;return 0!==r?r:n.Yi-i.Yi}hr(t){const e=jc(this.ji.keys());return this.cr(e,t,this.lr)}cr(t,e,n){if(e<=0)return[];let i,r,s,o=0,a=t.length-1;for(;o<a;){for(i=o,r=a,s=t[e];i<=e&&r>=e;){for(;i<=e&&n.call(this,t[i],s)<0;)i+=1;for(;r>=e&&n.call(this,t[r],s)>0;)r-=1;let o=t[i];t[i]=t[r],t[r]=o,i+=1,r-=1}r<e&&(o=i),i>e&&(a=r)}return t.slice(0,e)}}function Vc(){const t=(t=0,e=0,n=0,i=1)=>[t,e,n,i],e=(t,e,n)=>{const i=e[0],r=e[1],s=e[2],o=e[3],a=n[0],u=n[1],h=n[2],l=n[3];return t[0]=i*l+o*a+r*h-s*u,t[1]=r*l+o*u+s*a-i*h,t[2]=s*l+o*h+i*u-r*a,t[3]=o*l-i*a-r*u-s*h,t},n=(t,e,n,i,r="zyx")=>{let s=.5*Math.PI/180;e*=s,n*=s,i*=s;let o=Math.sin(e),a=Math.cos(e),u=Math.sin(n),h=Math.cos(n),l=Math.sin(i),c=Math.cos(i);switch(r){case"xyz":t[0]=o*h*c+a*u*l,t[1]=a*u*c-o*h*l,t[2]=a*h*l+o*u*c,t[3]=a*h*c-o*u*l;break;case"xzy":t[0]=o*h*c-a*u*l,t[1]=a*u*c-o*h*l,t[2]=a*h*l+o*u*c,t[3]=a*h*c+o*u*l;break;case"yxz":t[0]=o*h*c+a*u*l,t[1]=a*u*c-o*h*l,t[2]=a*h*l-o*u*c,t[3]=a*h*c+o*u*l;break;case"yzx":t[0]=o*h*c+a*u*l,t[1]=a*u*c+o*h*l,t[2]=a*h*l-o*u*c,t[3]=a*h*c-o*u*l;break;case"zxy":t[0]=o*h*c-a*u*l,t[1]=a*u*c+o*h*l,t[2]=a*h*l+o*u*c,t[3]=a*h*c-o*u*l;break;case"zyx":t[0]=o*h*c-a*u*l,t[1]=a*u*c+o*h*l,t[2]=a*h*l-o*u*c,t[3]=a*h*c+o*u*l;break;default:throw new Error("Unknown angle order "+r)}return t};function i(i,r,s=0){const o=t();n(o,0,0,90+s,"xyz");const a=t();n(a,0,90-i[1],0,"xyz");const u=t();n(u,0,0,i[0],"xyz");const h=t();e(h,u,a),e(h,h,o);const l=t();n(l,0,0,-90,"xyz");const c=t();n(c,0,-(90-r[1]),0,"xyz");const f=t();n(f,0,0,-r[0],"xyz");const d=t();e(d,l,c),e(d,d,f);const p=t();return e(p,d,h),p}function r(t,e,n){const i=e[0],r=e[1],s=e[2],o=n[3]*i+n[7]*r+n[11]*s+n[15]||1;return t[0]=(n[0]*i+n[4]*r+n[8]*s+n[12])/o,t[1]=(n[1]*i+n[5]*r+n[9]*s+n[13])/o,t[2]=(n[2]*i+n[6]*r+n[10]*s+n[14])/o,t}var s=new Float32Array(1),o=new Int32Array(s.buffer);let a={};function u(t){s[0]=t;var e,n=o[0],i=n>>23&255,r=8388607&n;return 0==i?e=0:i<113?(e=0,r|=8388608,16777216&(r>>=113-i)&&(e=1,r=0)):i<142?e=i-112:(e=31,r=0),(n>>31&1)<<15|e<<10|r>>13}function h(t,e){return(u(t)|u(e)<<16)>>>0}const l=(t,e,n=!1)=>{const i=t[0],r=t[1];let s,o,a,u,h=!1;const l=e.length;for(let t=0,c=l-1;t<l;c=t,t+=1){let l=!1;if(s=e[t][0],o=e[t][1],a=e[c][0],u=e[c][1],s===i&&o===r||a===i&&u===r)return!!n;if(o<r==u>=r){const t=(a-s)*(r-o)/(u-o)+s;if(i===t)return!!n;l=i<t}l&&(h=!h)}return h},c=(t,e)=>t[0]>=e[0]&&t[1]>=e[1]&&t[2]>=e[2]&&t[0]<=e[3]&&t[1]<=e[4]&&t[2]<=e[5];function f(t,e){return!(t[3]<e[0]||e[3]<t[0]||t[4]<e[1]||e[4]<t[1]||t[5]<e[2]||e[5]<t[2])}self.onmessage=n=>{if(n.data.dr){const s=function(n,s){const{te:o,dr:a,ee:u,oe:d,Wt:p,Bt:v,pr:y,jt:m,vr:w,yr:g}=n,b=w||d,x=new Float32Array(3*b),_=new Uint8Array(4*b),k=new Uint32Array(3*b);let $=2;m&&($=6);const S=4*$,M=v||4096,E=Math.floor(M/$),C=E*M,A=Math.ceil(b/E),I=Math.ceil(A/M),O=[],T=[],z=[];for(let t=0;t<I;t+=1){const e=t==I-1?A-M*(I-1):M;O[t]=new Uint32Array(M*e*4),T[t]=new Uint8Array(O[t].buffer),z[t]=new Float32Array(O[t].buffer)}const D={x:1/0,y:1/0,z:1/0},P={x:-1/0,y:-1/0,z:-1/0};let R=0;return a.forEach((o=>{o.mr?function(o){const{Kt:a,He:u,wr:d,gr:p,_r:v=1,kr:y=0,$r:w,Pe:g,te:b}=o;let k;p&&(k=i(g,n.Pe,y));let $=[];s&&($=s.filter(((t,e)=>(t.Sr=e+1,f(t.$r,w)))));const A=new Uint32Array(d),I=A[0],N=new Float32Array(A.buffer,8,18),F=N[0],U=N[1],q=N[2],j=N[6],B=N[7],L=N[8],H=0==N[9],V=1==N[10],W=0==N[11],G=N[12],Q=N[13],K=N[14],X=N[15],Z=N[16],Y=N[17];let J,tt,et,nt,it,rt,st,ot,at;W?(J=tt=2047,et=1023,nt=Math.ceil(48*I/32),it=Math.ceil(32*I/32),rt=new Uint16Array(A.buffer,80,3*I),st=new Uint32Array(A.buffer,80+4*nt,I),ot=11,at=10):(J=tt=et=1023,nt=Math.ceil(24*I/32),it=Math.ceil(16*I/32),rt=new Uint8Array(A.buffer,80,3*I),st=new Uint16Array(A.buffer,80+4*nt,I),ot=at=10);const ut=2**(ot+at),ht=2**at,lt=[0,0,0],ct=t=>{const e=t/ut|0,n=(t-e*ut)/ht|0,i=t-e*ut-n*ht;return lt[0]=e,lt[1]=n,lt[2]=i,lt},ft=nt+it,dt=V?20:4,pt=a*dt,vt=new Uint32Array(A.buffer,80+4*ft,pt),yt=new Uint8Array(A.buffer,80+4*ft,4*pt),mt=G/J,wt=Q/tt,gt=K/et,bt=[0,0,0];let xt,_t,kt,$t,St,Mt,Et,Ct,At,It,Ot,Tt,zt,Dt,Pt,Rt,Nt,Ft,Ut,qt,jt,Bt,Lt,Ht,Vt,Wt=0;for(let n=0;n<I;n+=1){xt=rt[3*n],_t=rt[3*n+1],kt=rt[3*n+2];const i=st[n];$t=xt*G+F,St=_t*Q+U,Mt=kt*K+q;for(let n=0;n<i;n++){Et=Math.floor(R/C),Ot=Et*C,Ct=O[Et],At=T[Et],It=z[Et];const n=Wt*dt,i=vt[n];[Tt,zt,Dt]=ct(i),Tt=$t+Tt*mt+u[0],zt=St+zt*wt+u[1],Dt=Mt+Dt*gt+u[2];const s=4*(n+2);Ut=(yt[s+4]-128)/128,qt=(yt[s+5]-128)/128,jt=(yt[s+6]-128)/128,Bt=(yt[s+7]-128)/128;let o=vt[n+1];if([Lt,Ht,Vt]=ct(o),Lt=j+Lt*X,Ht=B+Ht*Z,Vt=L+Vt*Y,H&&(Lt=Math.exp(Lt),Ht=Math.exp(Ht),Vt=Math.exp(Vt)),p){[Tt,zt,Dt]=r(bt,[Tt,zt,Dt],p);const n=t(qt,jt,Bt,Ut),i=t();e(i,k,n),Ut=i[3],qt=i[0],jt=i[1],Bt=i[2],Lt*=v,Ht*=v,Vt*=v}if(Pt=yt[s+0],Rt=yt[s+1],Nt=yt[s+2],Ft=yt[s+3],Wt+=1,Ft<13)continue;x[3*R]=Tt,x[3*R+1]=zt,x[3*R+2]=Dt,D.x=Math.min(D.x,Tt),D.y=Math.min(D.y,zt),D.z=Math.min(D.z,Dt),P.x=Math.max(P.x,Tt),P.y=Math.max(P.y,zt),P.z=Math.max(P.z,Dt);const a=R-Ot,f=Math.floor(a/E)*M*4+a%E*S;It[f+0]=Tt,It[f+1]=zt,It[f+2]=Dt,At[4*(f+7)+0]=Pt,At[4*(f+7)+1]=Rt,At[4*(f+7)+2]=Nt,At[4*(f+7)+3]=Ft,_[4*R]=Pt,_[4*R+1]=Rt,_[4*R+2]=Nt,_[4*R+3]=Ft,Ct[f+5]=h(Lt,Ht),Ct[f+6]=h(Vt,0),At[4*(f+4)+0]=128*Ut+128,At[4*(f+4)+1]=128*qt+128,At[4*(f+4)+2]=128*jt+128,At[4*(f+4)+3]=128*Bt+128,At[4*(f+3)+3]=Math.ceil(10*Math.max(Lt*v,Ht*v,Vt*v));for(let t=0,e=$.length;t<e;t+=1)if(c([Tt,zt,Dt],$[t].$r)&&l([Tt,zt],$[t].Mr)){At[4*(f+3)]=$[t].Sr;break}if(m)for(let t=0;t<16;t+=1)Ct[f+8+t]=vt[n+4+t];R+=1}}}(o):y?o.Er.red?function(o){const a=null==g?1/0:g,{Kt:u,He:d,wr:p,$r:v,gr:y,_r:m=1,kr:b=0,Pe:k,Yt:$,Er:A}=o;let I;y&&(I=i(k,n.Pe,b));let N=[];s&&(N=s.filter(((t,e)=>(t.Sr=e+1,f(t.$r,v)))));const F=new DataView(p),U=[0,0,0],q=p.byteLength/u;let j=1;w&&(j=Math.ceil(u/w));for(let n=0;n<u;n+=j){const i=Math.floor(R/C),s=i*C;var B=O[i],L=T[i],H=z[i];const o=q*n;let u=F[A.x](o+$.x,!0)+d[0],f=F[A.y](o+$.y,!0)+d[1],p=F[A.z](o+$.z,!0)+(d[2]||0);if(p>a)continue;const v=R-s,w=Math.floor(v/E)*M*4+v%E*S,g=F[A.red](o+$.red,!0),b=F[A.green](o+$.green,!0),k=F[A.blue](o+$.blue,!0),j=255;_[4*R]=g,_[4*R+1]=b,_[4*R+2]=k,_[4*R+3]=j,L[4*(w+7)+0]=g,L[4*(w+7)+1]=b,L[4*(w+7)+2]=k,L[4*(w+7)+3]=j;const V=[.01,.01,.01],W=[1,0,0,0];if(y){[u,f,p]=r(U,[u,f,p],y);const n=t(W[1],W[2],W[3],W[0]),i=t();e(i,I,n),W[0]=i[3],W[1]=i[0],W[2]=i[1],W[3]=i[2],V[0]*=m,V[1]*=m,V[2]*=m}D.x=Math.min(D.x,u),D.y=Math.min(D.y,f),D.z=Math.min(D.z,p),P.x=Math.max(P.x,u),P.y=Math.max(P.y,f),P.z=Math.max(P.z,p),H[w+0]=u,H[w+1]=f,H[w+2]=p,x[3*R]=u,x[3*R+1]=f,x[3*R+2]=p,B[w+5]=h(V[0],V[1]),B[w+6]=h(V[2],0),L[4*(w+4)+0]=128*W[0]+128,L[4*(w+4)+1]=128*W[1]+128,L[4*(w+4)+2]=128*W[2]+128,L[4*(w+4)+3]=128*W[3]+128,L[4*(w+3)+3]=Math.ceil(Math.max(V[0],V[1],V[2]));for(let t=0,e=N.length;t<e;t+=1)if(c([u,f,p],N[t].$r)&&l([u,f],N[t].Mr)){L[4*(w+3)]=N[t].Sr;break}R+=1}}(o):function(o){const{Kt:a,He:u,wr:d,$r:p,gr:v,_r:y=1,kr:w=0,Pe:g,Yt:b,Er:k}=o;let $;v&&($=i(g,n.Pe,w));let A=[];s&&(A=s.filter(((t,e)=>(t.Sr=e+1,f(t.$r,p)))));const I=new Float32Array(d),N=[0,0,0],F=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],U=2047,q=1023,j=new Float32Array(1),B=new Uint32Array(j.buffer);for(let n=0;n<a;n++){const i=Math.floor(R/C),s=i*C;var L=O[i],H=T[i],V=z[i];const o=62*n;let a=I[o+0]+u[0],f=I[o+1]+u[1],d=I[o+2]+(u[2]||0);const p=R-s,w=Math.floor(p/E)*M*4+p%E*S,g=.28209479177387814,b=Math.max(0,Math.min(255,255*(.5+g*I[o+6]))),k=Math.max(0,Math.min(255,255*(.5+g*I[o+7]))),W=Math.max(0,Math.min(255,255*(.5+g*I[o+8]))),G=1/(1+Math.exp(-I[o+54]))*255;if(G<13)continue;_[4*R]=b,_[4*R+1]=k,_[4*R+2]=W,_[4*R+3]=G,H[4*(w+7)+0]=b,H[4*(w+7)+1]=k,H[4*(w+7)+2]=W,H[4*(w+7)+3]=G;const Q=[Math.exp(I[o+55]),Math.exp(I[o+56]),Math.exp(I[o+57])],K=[I[o+58],I[o+59],I[o+60],I[o+61]],X=Math.sqrt(K[0]**2+K[1]**2+K[2]**2+K[3]**2);if(K[0]/=X,K[1]/=X,K[2]/=X,K[3]/=X,v){[a,f,d]=r(N,[a,f,d],v);const n=t(K[1],K[2],K[3],K[0]),i=t();e(i,$,n),K[0]=i[3],K[1]=i[0],K[2]=i[1],K[3]=i[2],Q[0]*=y,Q[1]*=y,Q[2]*=y}D.x=Math.min(D.x,a),D.y=Math.min(D.y,f),D.z=Math.min(D.z,d),P.x=Math.max(P.x,a),P.y=Math.max(P.y,f),P.z=Math.max(P.z,d),V[w+0]=a,V[w+1]=f,V[w+2]=d,x[3*R]=a,x[3*R+1]=f,x[3*R+2]=d,L[w+5]=h(Q[0],Q[1]),L[w+6]=h(Q[2],0),H[4*(w+4)+0]=128*K[0]+128,H[4*(w+4)+1]=128*K[1]+128,H[4*(w+4)+2]=128*K[2]+128,H[4*(w+4)+3]=128*K[3]+128,H[4*(w+3)+3]=Math.ceil(Math.max(Q[0],Q[1],Q[2]));for(let t=0,e=A.length;t<e;t+=1)if(c([a,f,d],A[t].$r)&&l([a,f],A[t].Mr)){H[4*(w+3)]=A[t].Sr;break}if(m){for(let t=0;t<45;t+=1)F[t]=I[o+9+t];const t=(t,e,n)=>{const i=Math.floor(t*U+.5),r=Math.floor(e*q+.5),s=Math.floor(n*U+.5);return(i<0?0:i>U?U:i)<<21|(r<0?0:r>q?q:r)<<11|(s<0?0:s>U?U:s)};let e=Math.abs(F[0]);for(let t=1;t<45;++t){const n=Math.abs(F[t]);n>e&&(e=n)}if(0===e)continue;for(let t=0;t<45;++t)F[t]=F[t]/e*.5+.5;j[0]=e,L[w+8]=B[0],L[w+9]=t(F[0],F[15],F[30]),L[w+10]=t(F[1],F[16],F[31]),L[w+11]=t(F[2],F[17],F[32]),L[w+12]=t(F[3],F[18],F[33]),L[w+13]=t(F[4],F[19],F[34]),L[w+14]=t(F[5],F[20],F[35]),L[w+15]=t(F[6],F[21],F[36]),L[w+16]=t(F[7],F[22],F[37]),L[w+17]=t(F[8],F[23],F[38]),L[w+18]=t(F[9],F[24],F[39]),L[w+19]=t(F[10],F[25],F[40]),L[w+20]=t(F[11],F[26],F[41]),L[w+21]=t(F[12],F[27],F[42]),L[w+22]=t(F[13],F[28],F[43]),L[w+23]=t(F[14],F[29],F[44])}R+=1}}(o):function(o){const{Kt:a,He:u,wr:d,$r:p,gr:v,_r:y=1,kr:m=0,Pe:w}=o;let g;v&&(g=i(w,n.Pe,m));let b=[];s&&(b=s.filter(((t,e)=>(t.Sr=e+1,f(t.$r,p)))));const k=new Float32Array(d),$=new Uint8Array(d),A=[0,0,0];["rgb(173,221,142)","rgb(120,198,121)","rgb(65,171,93)","rgb(35,132,67)","rgb(0,104,55)","rgb(0,69,41)"].map((t=>t.slice(4,-1).split(",").map((t=>+t)))),["rgb(189,189,189)","rgb(150,150,150)","rgb(115,115,115)","rgb(82,82,82)","rgb(37,37,37)","rgb(0,0,0)"].map((t=>t.slice(4,-1).split(",").map((t=>+t)))),["rgb(254,217,118)","rgb(254,178,76)","rgb(252,78,42)","rgb(227,26,28)","rgb(189,0,38)","rgb(128,0,38)"].map((t=>t.slice(4,-1).split(",").map((t=>+t)))),["rgb(218,218,235)","rgb(158,154,200)","rgb(128,125,186)","rgb(106,81,163)","rgb(84,39,143)","rgb(63,0,125)"].map((t=>t.slice(4,-1).split(",").map((t=>+t))));const I=["rgb(255,247,251)","rgb(236,226,240)","rgb(208,209,230)","rgb(166,189,219)","rgb(103,169,207)","rgb(54,144,192)","rgb(2,129,138)","rgb(1,108,89)","rgb(1,70,54)"].reverse().map((t=>t.slice(4,-1).split(",").map((t=>+t))));I[0],I[1],I[2],I[3],I[4],I[5];for(let n=0;n<a;n++){const i=Math.floor(R/C),s=i*C;var N=O[i],F=T[i],U=z[i];let o=k[8*n+0]+u[0],a=k[8*n+1]+u[1],f=k[8*n+2]+(u[2]||0);const d=R-s,p=Math.floor(d/E)*M*4+d%E*S;let m=$[24+32*n],w=$[25+32*n],I=$[26+32*n],q=$[27+32*n];if(q<13)continue;_[4*R]=m,_[4*R+1]=w,_[4*R+2]=I,_[4*R+3]=q,F[4*(p+7)+0]=m,F[4*(p+7)+1]=w,F[4*(p+7)+2]=I,F[4*(p+7)+3]=q;const j=[k[3+8*n],k[4+8*n],k[5+8*n]],B=[($[28+32*n]-128)/128,($[29+32*n]-128)/128,($[30+32*n]-128)/128,($[31+32*n]-128)/128];if(v){[o,a,f]=r(A,[o,a,f],v);const n=t(B[1],B[2],B[3],B[0]),i=t();e(i,g,n),B[0]=i[3],B[1]=i[0],B[2]=i[1],B[3]=i[2],j[0]*=y,j[1]*=y,j[2]*=y}D.x=Math.min(D.x,o),D.y=Math.min(D.y,a),D.z=Math.min(D.z,f),P.x=Math.max(P.x,o),P.y=Math.max(P.y,a),P.z=Math.max(P.z,f),U[p+0]=o,U[p+1]=a,U[p+2]=f,x[3*R]=o,x[3*R+1]=a,x[3*R+2]=f,N[p+5]=h(j[0],j[1]),N[p+6]=h(j[2],0),F[4*(p+4)+0]=128*B[0]+128,F[4*(p+4)+1]=128*B[1]+128,F[4*(p+4)+2]=128*B[2]+128,F[4*(p+4)+3]=128*B[3]+128,F[4*(p+3)+3]=Math.ceil(Math.max(j[0],j[1],j[2]));for(let t=0,e=b.length;t<e;t+=1)if(c([o,a,f],b[t].$r)&&l([o,a],b[t].Mr)){F[4*(p+3)]=b[t].Sr;break}R+=1}}(o)})),D.x-=.5,D.y-=.5,D.z-=.5,P.x+=.5,P.y+=.5,P.z+=.5,{layerId:u,hasSH:m,key:p,uri:o,centers:x.buffer.slice(0,12*R),rgbas:_.buffer.slice(0,16*R),sigmas:k.buffer.slice(0,12*R),boundMax:Object.values(P),boundMin:Object.values(D),texdatas:O.map((t=>t.buffer)),vertexCount:R}}(n.data,a[n.data.ee]);self.postMessage(s,[s.centers,...s.texdatas,s.rgbas,s.sigmas])}else n.data.Cr&&(a[n.data.ee]=n.data.Cr)}}class Wc{Ar=[];Ir=[];Or=0;constructor(t){for(let e=0;e<t;e+=1)this.Ar.push(new Worker(URL.createObjectURL(new Blob(["(",Vc.toString(),")(self)"],{type:"application/javascript"}))))}postMessage(t,e){t.broadcast?this.Ar.forEach((n=>{n.postMessage(t,e)})):this.Ar[this.Or++%this.Ar.length].postMessage(t,e)}tryPost(){if(this.Ir.length){const t=this.Ar.find((t=>!t.isBusy));if(t){t.isBusy=!0;const e=this.Ir.shift();t.postMessage(e[0],e[1])}}}set onmessage(t){this.Ar.forEach((e=>{e.onmessage=t?e=>{t(e)}:null}))}}class Gc{Tr;zr;Dr=null;Pr;Rr=1;MAX_STORAGE_BYTES=21474836480;Nr=!0;constructor(t,e,n=[],i=20){this.Tr=t,this.zr=e,this.Pr=n.sort(((t,e)=>t.version-e.version)),this.MAX_STORAGE_BYTES=1073741824*i}async open(){return new Promise(((t,e)=>{const n=indexedDB.open(this.Tr);n.onerror=()=>e(n.error),n.onsuccess=async()=>{this.Dr=n.result,this.Rr=this.Dr.version,this.Fr(this.Dr)?(this.Dr=this.Dr,t(this.Dr)):(this.Dr.close(),t(await this.Ur())),t(this.Dr)},n.onupgradeneeded=t=>{this.Dr=n.result,this.Ur()}}))}Ur(){return new Promise(((t,e)=>{const n=this.Rr+1,i=indexedDB.open(this.Tr,n);i.onerror=()=>e(i.error),i.onsuccess=()=>{this.Dr=i.result},i.onupgradeneeded=t=>{this.Dr=i.result;const e=this.Dr.createObjectStore(this.zr,{keyPath:"id"});e.indexNames.contains("created_at")||e.createIndex("created_at","metadata.createdAt",{unique:!1}),e.indexNames.contains("last_accessed")||e.createIndex("last_accessed","metadata.lastAccessed",{unique:!1})}}))}Fr(t){try{const e=t.transaction(this.zr,"readonly").objectStore(this.zr);return["created_at","last_accessed"].every((t=>{try{return e.index(t),!0}catch{return!1}}))}catch(t){return!1}}async store(t,e,n){if(this.qr())return await this.jr(),this.Br({id:t,buffers:e,metadata:{createdAt:Date.now(),lastAccessed:Date.now(),...n}})}async Br(t){return await this.Lr(),new Promise(((e,n)=>{const i=this.Dr.transaction(this.zr,"readwrite").objectStore(this.zr).put(t);i.onsuccess=()=>e(),i.onerror=()=>n(i.error)}))}async get(t){return this.qr()?(performance.now(),await this.Lr(),new Promise(((e,n)=>{const i=this.Dr.transaction(this.zr,"readonly").objectStore(this.zr).get(t);i.onsuccess=async()=>{const n=i.result;e(n??null),n&&await this.Hr(t)},i.onerror=()=>n(i.error)}))):null}async getMultiple(t){return this.qr()?(performance.now(),await this.Lr(),new Promise(((e,n)=>{const i=this.Dr.transaction(this.zr,"readonly").objectStore(this.zr),r=new Map;let s=t.length;t.forEach((n=>{const o=i.get(n);o.onsuccess=async()=>{const i=o.result;r.set(n,i??null),s-=1,0===s&&(e(r),this.Vr(t))},o.onerror=()=>{s-=1,r.set(n,null),0===s&&e(r)}}))}))):new Map}async has(t){return!!this.qr()&&(await this.Lr(),new Promise(((e,n)=>{const i=this.Dr.transaction(this.zr,"readonly").objectStore(this.zr).count(t);i.onsuccess=()=>e(i.result>0),i.onerror=()=>n(i.error)})))}async delete(t){if(this.qr())return await this.Lr(),new Promise(((e,n)=>{const i=this.Dr.transaction(this.zr,"readwrite").objectStore(this.zr).delete(t);i.onsuccess=()=>e(),i.onerror=()=>n(i.error)}))}async clear(){return await this.Lr(),new Promise(((t,e)=>{const n=this.Dr.transaction(this.zr,"readwrite").objectStore(this.zr).clear();n.onsuccess=()=>t(),n.onerror=()=>e(n.error)}))}async Lr(){this.Dr&&this.Dr.version===this.Rr||await this.open()}qr(){return!(this.Dr&&!this.Dr.objectStoreNames.contains("tiles")||!this.Dr)}close(){this.Dr&&(this.Dr.close(),this.Dr=null)}async jr(){if(!this.Dr)return;if(!this.Nr)return;const{usage:t}=await navigator.storage.estimate();if(null!=t&&t>this.MAX_STORAGE_BYTES){const e=this.Dr.transaction(this.zr,"readwrite").objectStore(this.zr),n=e.index("last_accessed").openCursor();let i=10;this.Nr=!1,await new Promise(((r,s)=>{n.onsuccess=async()=>{const s=n.result;if(i>0&&s&&t>this.MAX_STORAGE_BYTES){const t=s.value;await e.delete(t.id),i--,i<=0&&(this.Nr=!0),s.continue()}else r()},n.onerror=()=>s(n.error)}))}}async Hr(t){if(!this.Dr)return;const e=this.Dr.transaction(this.zr,"readwrite").objectStore(this.zr),n=await new Promise(((n,i)=>{const r=e.get(t);r.onsuccess=()=>n(r.result||null),r.onerror=()=>i(r.error)}));n&&(n.metadata=n.metadata||{},n.metadata.lastAccessed=Date.now(),e.put(n))}async Vr(t){if(!this.Dr||0===t.length)return;const e=this.Dr.transaction(this.zr,"readwrite"),n=e.objectStore(this.zr);for(const e of t){const t=await new Promise(((t,i)=>{const r=n.get(e);r.onsuccess=()=>t(r.result||null),r.onerror=()=>i(r.error)}));t&&(t.metadata=t.metadata||{},t.metadata.lastAccessed=Date.now(),n.put(t))}return new Promise(((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error)}))}}!function(t){t[t.init=0]="init",t[t.loading=1]="loading",t[t.failed=2]="failed",t[t.loaded=3]="loaded",t[t.parsed=4]="parsed",t[t.destroyed=5]="destroyed"}(Nc||(Nc={}));class Qc extends Al{Ie;Te=Sl();ji;fe;_scene;Wr=null;ze=0;De;Gr="";Qr=new Map;Kr=[];Xr;Zr="splat";Yr=0;Jr=0;Bt;Re=!0;Cr;ts;es;ns;rs;ss=1;Dr;qe={Jt:new Int32Array(0),ne:[],_modelMatrix:r.Matrix4.IDENTITY.clone(),Xt:[],oe:0,je:0,Be:void 0,Le:[],jt:!1};os;Ue;us;hs;ls=!1;cs;fs;ds;ps=!1;constructor(t){super(),this.es=new Wc(t.Ar||2),this.Ie=t.Ie,this.Xr=this.Ie.substring(0,this.Ie.lastIndexOf("/")+1);const e=this.Xr.match(/\[\d(,\d+)+\]/g);let n,i;if(e&&e[0]){const t=JSON.parse(e[0]);n=e[0],i=t}this.ts=new Kc(n,i),this.ts.vs=this.vs.bind(this),this.ts.ys=this.ys.bind(this),this.ts.ws=this.ws.bind(this),this.ts.gs=this.gs.bind(this),this.ds=t.ds,this.fe=t.fe,this._scene=t._scene,this.us=t.us,this.cs=t.cs,this.hs=Math.max(1e-5,Math.min(2,t.hs||1)),this.Bt=Math.min(4096,this.fe._gl.getParameter(this.fe._gl.MAX_TEXTURE_SIZE)),this.Ue=new El(this.fe,this.Bt),this.ji=new Hc({Bi:t.bs,qi:(t,e)=>!(this.Jr===e.xs||this.qe&&-1!==this.qe.ne.indexOf(t)||this.Kr.find((e=>e.Ie==t))||(this.Ue.Ae(e),this._s(e),0))}),null!=t.ks&&t.ks>0&&(this.Dr=new Gc("AMapYunJing","tiles",[{version:1,migrate:(t,e)=>{}}],t.ks),this.Dr.open()),this.Cr=t.Cr,this.fs=t.fs,t.$s?(this.Zr=t.$s.type||"splat",this.Wr=t.$s.root,this.ts.Zr=this.Zr):this.Ss(t).then((()=>{if(t.Cr.length){const e=this.Wr.enuCenter;t.Cr.forEach((t=>{let n=1/0,i=1/0,r=-1/0,s=-1/0;t.Mr=t.polygon.map((t=>{const{x:o,y:a,z:u}=Cc([t[0],t[1],0],e);return n=Math.min(n,o),r=Math.max(r,o),i=Math.min(i,a),s=Math.max(s,a),[o,a]})),t.$r=[n,i,t.height,r,s,t.extrudedHeight]})),this.es.postMessage({broadcast:!0,ee:this.Te,Cr:t.Cr})}}));const r=t=>{t.data.ee==this.Te&&this.Ve(t.data)};this.es.onmessage=t=>{t.data.layerId==this.Te&&this.Qe(t.data)},wl.addEventListener("message",r),this.os=()=>{this.es.onmessage=null,wl.removeEventListener("message",r)}}Ms(t){this.fs=t}_s(t){t.Es=Nc.destroyed,t.wr=void 0,t.Gt=void 0,t.Xt=[]}_destroy(){this.fe=null,this.Cr=[],this.Xr="",this.Ie="",this.os(),this.os=void 0,this.qe=void 0,this.Wr=null,this.Jr=0,this.ji._destroy(),this.Ue._destroy(),this.Kr=[],this.Qr=new Map,this.ts.clear()}Cs(){if(this.Wr)return this.Wr}Ve(t){const{ne:e,Gt:n,Jt:i,se:s,oe:o,re:a,jt:u,ie:h}=t;let l=r.Matrix4.IDENTITY.clone();const c=[];e.forEach(((t,e)=>{const i=this.ji.Ji(h[e],!0);i&&(i.As=!0,i.Gt=n[e],c[e]=i.Kt,l=i._modelMatrix)})),this.qe={Jt:new Int32Array(i.buffer,4*s),ne:e,jt:u,_modelMatrix:l,Xt:this.Ue.Me(a),Le:c,oe:o,je:this.qe?.je||0,Be:this.qe?.Be},this.Re=!0,this.ns&&this.ns(this.qe)}Is(){return this.Dr}async Qe(t,e=!1){const{texdatas:n,boundMax:i,boundMin:r,layerId:s,key:o,uri:a,centers:u,rgbas:h,sigmas:l,vertexCount:c}=t,f=this.Bt,d=this.ji.Ji(a,!0);d&&(!e&&this.Dr&&await this.Dr.store(a,n,{uri:a,key:o,layerId:s,boundMax:i,boundMin:r,centers:u,vertexCount:c}),d.oe=c,d.Kt=c,d.Xt=[],d.Gt=u,d.Lt=i,d.Ht=r,n.forEach(((t,e)=>{const n=new Float32Array(t),i=t.byteLength/16/f,r={width:f,height:i,arrayBufferView:n},s=o+"_"+e,a=Math.floor(this.Bt/(d.jt?6:2)),u=Math.ceil(Math.sqrt(this.Bt*a/(this.Wr?.avgCount||15e4))),h=this.Ue.Ee(d.Oe,2**(5-d.Qt)*u*240,i,d.Qt);h.me(r,s,d.Oe),d.Xt.push(h)})),d.Es=Nc.parsed,this.rs&&this.rs())}async Ss(t){if(!this.Ie)return;let e=this.Ie;this.ts.Os&&this.ts.Ts&&(e=e.replace(this.ts.Ts,this.ts.Os[0]));const n=await fetch(e,{cache:"default",mode:"cors",credentials:"omit"});if(!document.getElementById("yunjinglogo")){const t=document.createElement("img");t.id="yunjinglogo",t.style.cssText="position: absolute; top: 5px; left: 5px;",t.width=200,t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATkAAABFCAYAAAAxdpH/AAAAAXNSR0IArs4c6QAAHk1JREFUeF7tXXn8ftWc/3w+1zLWmVTCCDFlLJWxlAlTUShbRpYwibJFmLFvY2+yZC0UqWQiZI0K2UJobClLlhYlskSFNJ7zdt6P8zyve8/3Ps89d3ue5/vrnn9+r9/3Oevn3vs+53yW90clsQAwEbm7c+6+qrq9iNxaRG6oqldP7OLOqvqNsroA9hKRYxP7mVsNwF9E5DIR+RmA75rZF0TkBFW9qIv+hz4GCQwSWF8S0KrpAriuiDwZwFNV9WZV9ef8vhCQmwGiIxH5pKq+RlW/1GINQ9NBAoME1pkE5oIcgIcDeIOq3riDdS0N5PJzB/AhVT1AVX/ewZqGLgYJDBJYcQmUghyAaznn3m5me3c4/5UAOa4HwG9U9VGqenKH6xu6GiQwSGAFJbAG5ABcH8AnVPXuHc93ZUAuAN1IVfdT1aM6XufQ3SCBQQIrJIECyAG4JoBPqeq/9TDHlQK5AHROVfdS1ff3sN6hy0ECgwRWQAIFkBuNRoeZ2RN6mtfKgVwAuj/5a+u/qup3elr30O0ggUECS5TAFOQA3F9EPt7jXFYS5ALQnamqd1LVK3tc/9D1IIFBAkuQwBjkAFzDW1K/r6q37HEOKwtyYc3PUtWDe1z/0PUggUECS5DABOQeLyKH9zz+UkEOwI9EZAtVvVrZOgH8yhshbqGqf+xZDkP3gwQGCbSUAIDNReRxAHYSkX8UkT8COMPMPiAiNJy6yRBjkHPOfUdVt2k5blXzpYAcgLNU9VAR+aGInFIxyX29w/O7qhYy/D5IYJDAciQAgJj1XADPp8+rmX1CRM4TkWuLyPYAHicivwsuYj/hLBXA7UXkuwuY8kJBzoeK/VBVXyEin2U4moj8WUQ+Om+dAD5jZrsuQBZJQwC4oYjsXFL5A/mdKqmzdVQJwK18KN6doylfpqqfXEfLGKbagwRGo9EhqrqTqu6pqj+IhwBwNefci30Y5xPpBqeqPybIPVNEXtfDfOIuFwJyAH7ir6SvFJFjRGQT59wBZvZi59xLzey/K0DuSlXdaFWurOEo/rmSOV9zlYwkADIRubmIbM2YZobPtXmfANDCf1i+DwBnmxnjpYfSQAIAqG+/d9T066r6zQbdlTYBwJj2f4l+pEvaT7sYI0RgvVpV7yIi2wKYfs/c9J1zF5kZQfDLPob9RQAe7DfG7XQ0Gh1nZg/rYhIVffQKcgDO82QBrxKRo1T1/3kKcs69ycwer6qXO+c+rqq0IFeVHVT1tKpK0QdIkoJP12mTUhfAP6jqtiW71aldn+Scc+dkWfbYaF13dM49NBqfa72OiHBuPGlSN3IzVb0m6zGaxL9omwB4uog8OGWdJeu7sapuFc2Frj5fb9JfaLMr34uSsXp5di3mmdTUP5ezsix7SlLlvz2Xh4jIB6P6L/DP7X9S+6iqNxqNDjSz50f1eOI6vqpt1e8kCOFGp6rPUNUTAqkHD2gTlzcSiOwOgAZEbri/B/BNVT2I8PctVb1D1SAd/N4LyAG4IDyod05ONwA2FREqIB832UWccz9PjMF9bN0oCFqnw3W4AzEtp4vA2FLQywLYx5/QjqwzownIjUajt5jZU+u07blu6el3vT47AKeZ2Q6pMtsAQO6uAI5V1Vup8gKKvXji9yxDBXWOv7kxZHMPVT0VwBMB7E6QS/34U+U5q16nIOcXcJGqvprXGlW9YjIogM0AkHHkOao6NjQAoPXlgsQFPLfudWu9fijRSYm0VAPIJb4ky67WN8iNRqO30Um+5jp5Aufpflr8RnkuT1V1+qFuPMuyZ0X97O+c2yHLskeHb5ogR2akyW3h70RkD686eYWq0ovitwBuB+AkgtyvVXXjOpNoWLcTkANwsapSh3horDvjFRXAZ1X1cFV9cw74HlhldMit6aWq+rI6axxArvBSj3Vnw0muzhtUv27fIOecO1lVYx1e/Yk2aAHgeDPbMwK55znnbppl2fh2EE5y9IQgT+T1VJUqErqOvGTCWwngJmP/3/UCcoE55PUi8mbq2GLZBYA7BcDpWZbRjJzfTV7q5fKSRHk3AbmrATgusf+VrOZN7+dnWfafkdxItfXG3N9ISEq91h9opheRiwFcaGbnBBedMzzpwfjE7NUI+wHYreFiuRMXFNhe18Jn/qmG/YmqPlxVOf9CCY7w65FQ9XQzu2+qPOpeV1cQ5Pbl+zQBv/x1lW4lzrmDVHU3xt17vR3fTb6DdwLw/lUBuf28Q987yh6YV2Bf4i2ebxIR8tpdOqPOpgB4Nb1cVXdWVbqLTEsNowPb1Aa51BdtqJcmgcG6mianOrU2AJC7LYAv+FvaTYJhsaCTC4YJGuR+pKrUJRPknuuc23qpIAdgi+DTsrf3aaMbQv70dSkAKq9fN0HmGQDHYyoBbmOalstozp1zF1I4iS/FAHKJguqr2gBy3Uu2LsgBIAs4WcGXUS6d3Aiiw8pXveX0SG9APKzM8BB0cLSo8gbxtRCqus9SQI4CdM69UFVpySzkiOC1xF8932pmpCr/zTwJT3Rw3ieOFpcdy1wMeC8XkQtrPKlOQA7Azb0qgIrRO9TIg1Fjms2qAvijP+0y7wUVy6Un49Seg/f59YOP3K25a/JZZFn2qGjD2sU5x41sc6/vTKHcb+VC0uUaU2WxSvVofHPO0RF+WoIyfpfouZwO4Nv5v5nZ27v0netSLp4GbgcAzNeyo4jQo+Fued17OL09RkQ28rc3Em5cz8z2WCjIUUnonKNvDn3XOMn8yY2xZ6R64t364irh0E2ERgbvKnI7VX2MNy3T+XdNAfAAEflYVX+531uDnD9W7wzgoxRyjXEXWhXAT1X1nn6jYUhMaQGwa3AWn/xOjCLnIENoNvKWbdLiXzsPXBMXkkmD0Wj0GjN79kIXFwZLWeMy5tX3mN7Vgj6GDGNsUtb4tXlrJyOG7hl19j5VPbvJAD5OnP59sbHzVarKXCxzS3ALeSUjGrxD8IfpTpJvAOBGHuTfxo03vN+/WxjI8aMXkft45zyaeqcFwBUA3mlmB6Zm1ALAKyqtqFs75w6Ozc1R/3WMDmzaCuQAXA/Aj2NTetXDW8bvPqLi87GfUSS7xn5y7KfBBtOHGKjHYRD3Vab0AHJ08D0wEuAD6JTbRKjOOYZcFpy9RSQ5iocGCN72gsPvCWZGN5XrOOe2p8M/gPea2TMnBsqFgVwsDABX+ivdkWZGBP9ZqrACwH2GkQCBxXj3eTuAc+5j3qTM01xqaQty9OMpPVWmTmDB9baisrZszDbOwOyvgez7WvrMNfY14DL73dBBLmygVHPt7pzjBnYTM/uTiJwhIkxURdCbloWDHACGXB1jZjxy0vUguYQrKgFum3Ba2k5VL5nXQU2jA7tqC3KMp1vjZ+ece58PQVlahjBVveOMEw03iRPbghxd0EXkV/5a80UzG4eCOee+p6q3yfcNgE6a/xtcUcY/BWbmqeMpabG8+T8mcOWL/IhJX2GTPKTwMs9e4/2uSsH9XYBccP+5aQAUumYUQvScc4eYGUGldgkOu5tFDfcXkYmLzzk+uP4ztTue0WBhIAdgxLAMM3s5mQHqLiAA3Cm8ogKg9YWU5d+b108Do0MXIEd/PF6Rp4W+e2a2Xd01d1k/5O+gi03Mpzfz2gHgnl7HdkA0j21ictWw4TDmlyA3LTOuJYxEeW0kn4LMZjiDEgS/kgO5y8yMRo+8nKkvrLXGLmW8Kn0BoEqIRqB8oU7toOj50MAXJ3KiquWSVfOTayPb3kHOMwU4OuQFcPt+k8mGKyoBjic4Jp8hu0ClMaEhpXvbk1wZyPF0Q4vQUos3+pBlpWDNFpFaupWySIayuFcudAbIMedt4QTmT4GdgFwY88+xUavuGpf6kHoavK4LyQByCQ8iXF94P36Zqjbmq/O+chvTDy7HxkGuKFIpVZb446ls8LcKfYAcGTSeHEJQEqfRebW7ll2jReT+3r+QxINJZZ2C3AN9Do/S/CUAjqKxKGnxK1aJV3DvlnNEyrQGkOswdjWAG2mNCBbfSnkAs+qEKypj6CYhPmQWYXhOwWw8q31DxXdbkFvDhdZGBgtoSz++5ExlHYDcmlwaXZ3kSJjovdy5oSRfyRcY1tj5o6ReLMuyWJ1QOk5dkBuNRu/pKTVppRxIsJFl2ZMqKyZW6Oy6GsDtpABubXi/xlPPX1HD/0nRTuc/xk0mlQZGhy5OcvTTIXEnfclWugRq+K1TNw0upibIMTnSP+eF4KMZyHrDEL5pHCn9CunTNKkX5kVDzbQ45zbPp8v09Ne8lhZO9ABoXCnjsJt5Wh1Arjs+uVV92TsBOVKjhOj/qWK4zYLzbiIB4JhkhpbUgml43hjesZiOqk2sma1OcmG++/hEG0eoKon8VrIE480uqnp6nQnWBLkTVTU5iLzOPGrWpcN4qZFqALlqkCN5q4hws6IDeGkiqJrPI1+dhA90IftBijNwk3HaghzDg0htwn87KUEHR9AcE3nS5cTTGZPVtdYYDY0OrU9yudPIjt7R+XmBDroQ3dGJoJp3wrC5LwRDUKl/3Lyu64AcALp8vLf5VNu39KSJXzcz0nKXlgHkZoMcg94ZHuZvT8/uOzQRwM98mOF/qWrMXtz6JWgEcgC+Ek5unfmyBEC7QTgV5ml2nuKjB+jdXKsE/vdavHBhgNYnuVoTXWeV64AclzYajY4wswL11aKWDOCXIenJmoQnuc2Ip5NCPK13PSIfIenC84VO3qX+hItaT8k4vLInqW/q6uTC9/gcESEx7UJK8Jy4r1dLdZpKoBbI0d8rgFvnDzvWwVGqzrnDsyxjjFrt4pxj7CjJMuuWAeTmSKwuyIWP5REAGDhN7v1FXOEvCyFrZLD5Zd0XwDlHSn2ySY8LfTwZpke22bp9rUr9JiAXy2ERa+kjY14SyAFgHgieihgilWTZrCOQEjcRvlhf8jzt92qalarFA2oMcoGV48E+jy39+Ao00HXksaC6tBWdY2ZHe73ZV1PHbAJyqX2vQj0f98iMYPHJ7xs+TjNOkbgK002eQ12QA3AtJmyOByAWeDXEzJNx6oTC9ZcpA2+Ub8Nrq5mR5qmzMhfk6OTplecv997Tx/cBbmGXpB/cVAcX/sb7Obnhau/CoX1TowObNwK54L5AZob4mtPZw+qjIyKdV/jS95CZzirLVQDk6LpAFotpcc69NssyXt3WbWkAcvQdLFBxMdxOVZlyspODTri98VufknbQ+m5m01N0FwIvBTkidQC347pOfRehNnVwn2Zc5eTvgQuMFMbfaLpAf62+n09O3IghoQXI0cjQWXq3pmtv0Y60S2U5XgtdpoKc3/EfxMQjLebTaVMzI8VXJZXPjBSdM+N7O51kj511BHK1MoSlLCd281okyPHkxqxVP0mZaJM6AcWZeHZqZAinikf53aKVRa6F0aHxSc45d27I99hEHEtv45w7LsuyaQD8rAmlgtx6SWQTbbrMdfeLvKohWPdvUJZXpO+HBoAeBrG/Ja/OBXr/lHl0BHI/B1DwX0wZe16dkOmeeXzHZWEgFwYjFRIDeMkWMpeht+5CYzeRXHtmx+aJqFVxzn3ER1s8qGEnta+rABgPemXZeNQxiAjD2jo54jdc06QZKebvqqr0eyoUMsSaWZz9fM1wGzjIMai9wKzhiUO/bGYkjVx4cc4xLDJ2bqY7VW2vhi5AbhECWCjI5ZD1dz7gmYR5b8nnN226YABlbiJEcMbhMVjcNe170q6F0YFdNAG50uTSge+OcZO1d962MpjVPjCnkiufls5pmRVkH/ezgYPc07zDK5MmTQv9xLIsI33WwgsAZk9jhrp8oV8q9eS1ygByCbGrAM7zKd1eJCLMYt0IiABsFIwMUx0cn5RPSkGmUJ4wxqnE2hR+xC0D4TsDORGhz8/JEZjwNEXLa2WugzZyCG0ZOsVokZgiuowpZU1y6bLxa4AcnUiX4h9XNu+Q46D0tD2p75wjnfYeUXuGnH2+g2dRuwufz4AW3UJECoCT66QinAw6gFwCyOWExWw49IBmfoXkEk5wDLaPTfHMrk3a4qac9IU5tDQ6sK8uQY4ca6cFIL+Gc4678P5l18VkQdasGDYncvgxEe+4hLwNTNA9LV2f5GpOc+nVPZFj5nMPcEOgc/BETgz232hZJ/Fgsf9tlCuE3wt1hLUOGl2AHAB++//e5cNiREqkA73IzFIz6yVNRZlohPzocW1V3ZLhVLN6CddLGifOrBppzhWVTpa8zn2yqo/U373j5ou9w+n4OA+AyY/n8c4xbq5wyjEzZuGuNR8mKBaRsivpGOTopUEiyBnB46lLa1vv+d5UPyZNHEBurSiZiNjTTv1fBPynmFkhw1Xbh1C3/Qxet2092NRi5e0I5L5qZlMG57prKavvnLso7yvXi05u3kTJDOutOwRBvgBrSmD7ZZ4GnlBKg+EDwBXcRHIdPU9VOw0byRsdnHPHxunxungwcR8JINfGpaWTKZMuPFzZaCF7ps+p2ftJjgYmESGPXlzezHSIIb9q7DRNn8mpczIA8uDFQMMPYw2P2oy6tJa+s0qInlH4WX6zLzAWe4p2ps2ME7hUddXp7wCoIiqkF6RMPTC8vc5AHYEc01nSAk+WoVonyRlz3Z6HkCjb24VmNqZd76pU6oWCF/8jvQWRCWcKyurJJAD8wRMPHhwSQV+W+zuP/oxDWwOSzrn3Zln2yK4WMunHOUfnwomQmLEnVtx2PSRPRnNPcqPR6G1m1hk/VosF7OOB7ugFgtw2IlLGVbcZ0046584gnX20ngLfXNlcPdNvaQSCP7kzT8Ch+f6YYNjMblslM+ccDV9MSpwvpNhPjgapGqPJ7wDIKF3QCTrnjsmybO86/TUAOVLJ87peiRF15lFVlxEVZlbQ2Ve1qfo9eQHMESAiT/M8Xrz2TPUW0QvFgGjmN+Aue53g6LsmHCbc7RnSwQw7nZUSo8NOddlLmkwmAeSY22KvSFb0q3usiFzeZMyKNjdnshjmSC0DkAWCHNk/ykDiugws7wHkKM+p7pFrTwkTogsQE+yo6jRjfKCi2tgb26a8dz08p8ouma8BAD0cps+SfIVm9k+VjXMV6oIcmzrnaIWfyeBSZ/zUus65l2dZRsNYZyUZ5CYj8vrpnGMYEI/M8Uc0rhZi23g94k5eKIEZgiFbyWkIU1frlZi7i8iYyjswGlBp3CpLfMrYTUDOOfeOLMvIItxLcc4xJO/2SwY5qjtOKVlgRsV5DyD3MBE5LtpMfm1mm84TsrdYFpLkhPeH+TzrpLLs5TkGsGEc992iAW6sqr9IHbQJyNG6G/IbL4QePsTIM9qp042/NsjlwO6WzjkmhH5oKjlk0Asx6P5LqQ+nTr3I6HC2mTHYuvfSBORC3op717WSpSxmToLr8VVwgSe5NbpIXoHMbOzF3wPIEZQKhiaGCZrZGsNaBIQv9GSQcd4Qcpu9IUXefdcZjUYHmhkTPOfLQ/wh4kOpYzcBuQD2WzrnmGGNagW6P7EQYNfElwI4X0QujudURm4AgCSmJACgbu83wU3n0FTqqNR1sx6tfvf32bHbkDpuB+Dp+SDbORN4oqoeXmeCderm/ZwAnNZQaXy2qp5dZ9wEkHuXmfEqVSi0JPV0Xd1EVW9QsoaxwnqBIMf8q++PAOW3ZkaDRB8gt7OIFFybQqjg1SsSkNMwFhs37twmfrrO+1NVN39DmdStSxrQFORK3tkbAuA1dovouf6BOXbLbmghNULc1cLkm0S1VPUQUn4n0aaZxUfulKbJdSKjQ3K7qGLnfnJeL7SviFRa+JpOuEY75nM4c4EgR+X40dHHcIGZbd4TyDEs7Zsl8qBubSYXnHPukhLfRfLHFfLI1pBzp1V9MvZbiUghV7G3JJ9kZrGhZOa4XYAcgM047oS1OxpspqfEVQnkPmRmvdEQ8QGISLKOYs5b2AfIUXlMi2Clla/TryPXWd6dxl/h1jC+9uEMPMPa+UMzGye3mXFdpe8l3ZbGBcDeAZSnq+FVJ8uygiEn1CUP2XklMtxKVUup3gHwKlumA6KDeuuETF08TwB3CW4bBRmY2e1S+28LciHR+FHedWe8QUUbF5NMUc9Ov9M15SoDcs65I7MsK4T50Ms8hf4m5UGWHelT2pXU6Rzkwgd4UwAMibtHw3k1ahYMMMf4DeBJjD0Onv2fi+fRE8i9QEQKPHUAvmZm9H0rBTn/MX2RmbuavBf0AJjh9nCPWXrgOW1I9fUIVS2coBo9hBaNPEkGr4d8b+4VAcu5nvC0cGXMbQzUtU/0Z5M/M1KhYJTx7PR0nB87iOcKHfTHDvIcm6GJAB49KzAgWKHp9H7WrGXOALm9VZXvZe9lYddV59wbsyxjwPG4eBeHLYOLycEkKWxrqp/hNNlEgL2AXG7d2/qX7TYLogFnrCZjH2nl5imHbCmMzaTvVaEAOMPMOLe5JTV2lZ2MRqPXm9n0mYfn/gkzox541kmOPzFp0Ue8M27pyWDGBD9IklXnHEOzNonqEKziD3xaxTlHPeyWJTKhUvwiLqVKLj38TqDiKfPvVTUGLH4/MxP0eFDcimkdoznR5a3QDzfA2KlXVZnXeGzQmOGjOO3W/36ZqjLd4xfnrd85x3pT95zQt2NeZoJkidxP7dKNhCB3oTcGdBorNmPBLws+dBTetYNhYOxiAoDH3ae2sbrOCK5u8u7RkhR7vs/tp8rw0GQSXbaZERoUg9ynzOw+VePWBLk1/oE+f+oRWZbtF0COscz3rhoz8ffdPMnDSd6QxtCs2Pm8cAUu+aimoYCJY61CtZnRGAQ5EWkaC76nt6QeXwVypM5nHKsnNPh2lTCcc7w57FRVb/I7QyDNbM/U+lX1CHLUFXXqYTxj0KlJfjQaHW1mBY9tHmkBvMfMCDK1dWsdGR049ceo6rurBJf/fUMAOZ+j9gkh6fPcpdcBOefcqZ77LOZim56UATxeRLqytk+iOWjNpVV3Wpxzh83LyB5vunWe/TLqBuZuWidLM3X1CXI8/TGbmZlx40jyQaUqyfvcnZAaPdE5yI1GozW7bU8Pbl8yYQBg9q1p3F24rzN+bUxyGe74jJogf12St3nQHTTKB1GyVlI+fa2ODNY7yJG+xyeZvl+KHqwmyOVD7CYinW4iQT9IQoTKE2TC83gR81SMRqNXkeo82oQ+Z2Z0TJ5ZAGxK1lvqAxPGWlqVkDGPiZIunDWJPkDOq4P+oqofZhytz2NCEthaxUdtPMNvJq9Jyd/aOcj5cJY1RIG1Zp9emcfP80IWrmmkBB2K/dGUTCbHRi/mmZ6R+IAULi+vzKYpvRZzSNm0fTLoKwK1zhXpyxoD8zWon4jb+JwJOy479pFzcs4xCqSMTYOp945ibs3UrGij0eiNjHaJ1npWHG8YTkd02yg4nIc8qGP6qbCp0UfzOQD28eGAayx3qc8BAK/B+wNgnPWRUbtfpmSACnHaD/T0VPRpZNjh2J9vmSUcAriBMx0oT6kE4rmbP4BbMiVjk3n7WxQNVONvic/Eh2CSJYhMxOTao36ycQFwCxHh86HhiXHw1y8xkHDcE5umIi2bHJ2B29zf6yyYuTcP8h8VFzp5wUlTTreSh8cgN6nDQH4zI3/dvJ2rjKmhztwm8znRzBgaNpRBAvzYqCyPcywsUjI0eFw6yzVjkRNZz2ONd1nnHInr6IvTWwmKyqnJm9Y8xuMxTs0zA9PnqXCSy0/E0+BcHiif31R24pjBhd9kLf+hqu9p0nBoM0hgkMBqSmAMcvSDEZGF+KyE8Wjm305Vzw3/nwtyuZMfUyXyCltI5OGcO7/MSbGOyL2ukBxlWyyLBbbOXIe6gwQGCaRLYAJypH4mawX9t3otIUh/F+/ceGoOvJJALlefPlHkiju/Q6PDUzwN81t7XfzQ+SCBQQILl8BUKQxg55BkxnqexX4xq2vVdbVsPiEJNZkjvk+laMs507udVtUka27LsYbmgwQGCSxQAgXLF/M9UMnf1/hx1EPTk1x+fuFk2JhFJXht8+r8g77WPfQ7SGCQwPIkUAC54LdEi+c47KbLMs8Xq8lJrou5Bd+fPbzRZUy0OZRBAoMENjwJrCHNDHTL1HmR8LDLwtNSIYdkFye5phP0NO5/9sHXDDz+YNM+hnaDBAYJrL4ESpmBeaIjKZ9P9vyM1FCMhKXOJMlb9EmOZJWq+jDPrPDlhHkPVQYJDBJYxxKYS38OYFcAh6gqHYbblqWDXIi7e7eZ0TI7k0Sx7UKH9oMEBgmsjgQqczwwk5GIkLiQ/mmVVDxzlrY0kGO4VoiHY+xcraS8q/OohpkMEhgk0EQClSCX7xQAmUh387FlTFPG0x1J9QiClYWkfz6DfFkOTjojPwTAYZWdpFdgHOkFgSONXFekbP59evOh5iCBQQIbigT+CsiVwM0XmXL2AAAAAElFTkSuQmCC",document.getElementsByClassName("cesium-viewer")[0].appendChild(t)}let i;try{i=await n.json()}catch(t){return void alert("加载云境模型配置文件失败")}if(i){if(this.Zr=i.type||"splat",this.ts.Zr=this.Zr,this.Wr=i.root,this.Wr.limitBounds){const t=this.Wr.limitBounds;this.Wr.limitBounds=[{height:t.minz,extrudedHeight:t.maxz-t.minz,path:t.polygon}]}else i.limitBounds&&(this.Wr.limitBounds=i.limitBounds);if(t.zs){const e=Math.floor(1073741824*t.zs/44/(this.Wr.avgCount||15e4));this.ji.Li=e}this._scene.requestRender(),this.emit("configloaded",null)}}Ds(t,e,n,i,r,s,o,a,u){let h=Math.max(t-o,0,o-i),l=Math.max(e-a,0,a-r),c=Math.max(n-u,0,u-s);return Math.sqrt(h*h+l*l+c*c)}Ps(t,e,n){const i=e.bbox;return this.Ds(i[0],i[1],i[2],i[3],i[4],n||i[5],t.x,t.y,t.z)}Rs(t,e,n,i,s,o){let a=e;const{enuCenter:u=s,bbox:h,rotate:l,scale:c,depth_Test:f,content:d,geometricError:p}=t,[v,y,m]=u,w=r.Cartesian3.fromDegrees(v,y,m),g=i?e:r.Transforms.eastNorthUpToFixedFrame(w),b=Dc(new r.Cartesian3((h[0]+h[3])/2,(h[1]+h[4])/2,(h[2]+h[5])/2),u,g);let x=!1,_=r.Matrix4.IDENTITY.clone();if(i||(x=!0,_=r.Matrix4.multiply(n,g,_)),l){x=!0;const t=r.Math.toRadians(l),e=r.Matrix4.fromRotationTranslation(r.Matrix3.fromRotationZ(t));_=r.Matrix4.multiply(_,e,_)}if(c&&1!==c){x=!0;const t=r.Matrix4.fromScale(new r.Cartesian3(c,c,c),new r.Matrix4);_=r.Matrix4.multiply(_,t,_)}return{Ns:p,$r:[h[0],h[1],h[2],h[3],h[4],h[5]],jt:!1,sn:!0,ln:f,Ii:d.coord,Oe:b,Ie:this.Xr+d.uri,Qt:d.rank,Pe:w,Fs:u,_modelMatrix:a,gr:x?_:void 0,_r:c,kr:l,Es:Nc.init,Yr:this.Yr,te:o}}Us(t,e){return t.map((t=>{const n=new r.Cartesian3(t.x,t.y,t.z),i=t.w,s=r.Matrix4.multiplyByPointAsVector(e,n,new r.Cartesian3),o=r.Cartesian3.multiplyByScalar(n,-i,new r.Cartesian3),a=r.Matrix4.multiplyByPoint(e,o,new r.Cartesian3),u=-r.Cartesian3.dot(s,a);return new r.Cartesian4(s.x,s.y,s.z,u)}))}async qs(t){if(!this.Wr)return this.Kr=[],this.Kr;this.Jr=(new Date).getTime(),this.Yr+=1;const e=this.Wr,n=new Map,i=[],s=t.camera,o=s.frustum.computeCullingVolume(s.positionWC,s.directionWC,s.upWC).planes;let a=this.Wr.enuCenter;const u=a[0],h=a[1],l=a[2],c=r.Cartesian3.fromDegrees(u,h,l),f=r.Transforms.eastNorthUpToFixedFrame(c),d=r.Matrix4.inverse(f,new r.Matrix4),p=this.Us(o,d);let v=Tc(s.positionWC,a);const y=this.cs;let m=!1;const w=(t,u=0)=>{let h=!1,l=!1,c=!1;const{enuCenter:g=a,bbox:b,geometricError:x,content:_,prism:k}=t;m=m||!!k;const $=g[0]===a[0]&&g[1]===a[1]&&g[2]===a[2];let S=p,M=v,E=f;if(!$){const t=r.Cartesian3.fromDegrees(g[0],g[1],g[2]);E=r.Transforms.eastNorthUpToFixedFrame(t);const e=r.Matrix4.inverse(E,new r.Matrix4);M=Tc(s.positionWC,g),S=this.Us(o,e)}const C=new r.Cartesian3(b[0]-y,b[1]-y,b[2]-y),A=new r.Cartesian3(b[3]+y,b[4]+y,b[5]+y),I=new r.AxisAlignedBoundingBox(C,A);if(h=new r.CullingVolume(S).computeVisibility(I)!==r.Intersect.OUTSIDE,h){let r,s;if(k){const t=k[0],e=k[1],n=[];for(let t=2;t<k.length;t+=2)n.push([k[t],k[t+1]]);r=v.z>=t&&v.z<=e&&Ec([v.x,v.y],n,!0)?0:1/0}else r=this.Ps(M,t,e.maxZ);if((0==r||r<=x*this.fs[_.uri?u:0]/this.hs)&&(l=!0),l){if(_.uri){const e=_.uri;s=this.ji.Ji(e,!1),s||(s=this.Rs(t,f,d,$,a,_.uri),this.ji.nr(e,s)),s.xs=this.Jr,n.has(e)?s.js=Math.min(s.js,r):(n.set(e,s),s.js=r)}if(t.children&&t.children.length){let e=!0,n=!1,r=!1;t.children.forEach((t=>{const[i,s,o]=w(t,_.uri?u+1:0);i&&(r=!0,o||(e=!1),"ADD"==t.refine&&(n=!0))})),e=r&&e,!e||n||"ALWAYS"==t.refine?s&&s.Es==Nc.parsed&&(c=!0,-1==i.indexOf(s)&&i.unshift(s)):c=!0}else s&&s.Es==Nc.parsed&&(c=!0,-1==i.indexOf(s)&&i.unshift(s))}}return[h,l,c]};w(e),this.Dr&&await this.Bs(n),this.Kr=i.filter((t=>t.sn&&t.oe)),m&&this.Kr.length>1&&(this.Kr=[this.Kr[this.Kr.length-1]]),this.Qr=n;const g=r.Cartographic.fromCartesian(s.positionWC);return this.Ls([180*g.longitude/Math.PI,180*g.latitude/Math.PI,g.height],this.us),this.Kr}Ze(t,e){let n=t[2]*e[2]+t[6]*e[6]+t[10]*e[10];const i=(t[2]**2+t[6]**2+t[10]**2)**.5,r=(e[2]**2+e[6]**2+e[10]**2)**.5;return Math.abs(n/i/r-1)>.01}async Bs(t){if(!this.Dr)return;const e=jc(t.values()).filter((t=>t.Es==Nc.init)),n=e.map((t=>t.te)).filter((t=>void 0!==t));if(0===n.length)return;const i=await this.Dr.getMultiple(n);for(const t of e){const e=t.te;if(e&&t.Es===Nc.init){const n=i.get(e);n&&(t.Es=Nc.loading,this.Qe({texdatas:n.buffers,...n.metadata},!0))}}}Hs(t){let e=this.Kr;if(!e.length)return;e.sort(((t,e)=>t.Qt==e.Qt?t.js>e.js?-1:1:t.Qt<e.Qt?-1:1));const n=e[e.length-1].Qt,i=this.ds;if(i&&n-e[0].Qt>=i){const t=n-i;e=e.filter((e=>e.Qt>t))}const s=t.camera.viewMatrix,o=t.camera.frustum.projectionMatrix,a=(new Date).getTime();let u=!1;if(0==this.Re||this.qe&&this.qe.Jt.buffer.detached)return;const h=e.map((t=>t.Ie)).sort().join("|");if(this.ze?((0==this.ts.Ir.length||a-this.ze>400)&&this.Gr!==h||this.Ze(this.De,s))&&(u=!0):u=!0,u){this.ze=a,this.De=s.clone(),this.Gr=h,this.Re=!1;const t=[this.qe.Jt.buffer],n={ee:this.Te,Ye:s,Jt:this.qe.Jt,Bt:this.Bt,qt:e.map((e=>{t.push(e.Gt);const n=new r.Matrix4;return r.Matrix4.multiply(s,e._modelMatrix,n),r.Matrix4.multiply(o,n,n),{Qt:e.Qt||0,Wt:e.Ie,te:e.te,Gt:e.Gt,Vt:n,jt:e.jt,Lt:e.Lt,Ht:e.Ht,Kt:e.oe,Xt:e.Xt?.map((t=>({Yt:t.Yt,_id:t._id})))}}))};wl.busy=!0,wl.postMessage(n,t)}}Vs(){if(this.Kr.length)return this.qe}async Ws(){const t=jc(this.Qr.values()).filter((t=>t.Es==Nc.init));t.sort(((t,e)=>t.Qt==e.Qt?t.js<e.js?-1:1:t.Qt<e.Qt?-1:1));let e=t;if(this.Dr){const n=t.map((t=>t.te)),i=await Promise.all(n.map((t=>this.Dr.has(t))));e=t.filter(((t,e)=>!i[e]))}this.ts.loads(e)}Gs(t,e){const n=t+"."+this.Zr,i=this.ji.Ji(n,!1);i&&(i.sn=e)}Qs(t){const{x:e,y:n,z:i}=Cc(t,this.Wr?.enuCenter);for(let t=0,o=this.Cr.length;t<o;t+=1)if(r=[e,n,i],s=this.Cr[t].$r,r[0]>=s[0]&&r[1]>=s[1]&&r[2]>=s[2]&&r[0]<=s[3]&&r[1]<=s[4]&&r[2]<=s[5]&&Ec([e,n],this.Cr[t].Mr))return this.Cr[t];var r,s;return null}Ke(t,e){if(t){for(let n=0,i=this.Cr.length;n<i;n+=1)if(this.Cr[n].id==t){this.qe.je=n+1,this.qe.Be=e?.fillColor||void 0;break}}else this.qe.je=0}Ks(){return this.Kr}vs(t,e){const n=t,i=this.ji.Ji(n,!0);if(i){if(e||this.Qr.has(n))return i.Es=Nc.loading,!0;this.ji.sr(n)}return!1}ys(t){const e=this.ji.Ji(t.uri,!0);e&&(e.Es=Nc.failed)}gs(){this.ls&&this.emit("preloadComplete",null)}ws(t){const e=this.ji.Ji(t.uri,!0);e&&(e.oe=t.totalVertexCount,e.Kt=t.totalVertexCount,e.wr=t.data,e.Es=Nc.loaded,e.jt=t.hasSH,this.es.postMessage({dr:[{$r:e.$r,wr:e.wr.buffer,He:[0,0,0],Kt:t.totalVertexCount,mr:t.isCompressed,gr:e.gr,_r:e._r,kr:e.kr,Pe:e.Fs,Yt:t.offsets,Er:t.types,Wt:e.Ie,te:e.te}],yr:this.Wr?.clipZ,pr:t.isPly,jt:t.hasSH,Pe:this.Cs()?.enuCenter,Bt:this.Bt,oe:t.totalVertexCount,vr:t.isPly&&t.types.red&&t.totalVertexCount>15e6?5e6:0,Wt:e.Ie,ee:this.Te,Ii:e.Ii,te:e.te},[e.wr.buffer]))}Ls(t,e=1e3){if(this.Wr){this.ls=!0;let n=this.Wr.enuCenter;t=t||n;const i=n[0],s=n[1],o=n[2],a=r.Cartesian3.fromDegrees(i,s,o),u=r.Transforms.eastNorthUpToFixedFrame(a),h=r.Matrix4.inverse(u,new r.Matrix4),l=Cc(t,n),c=new Map,f=i=>{for(let r=0,s=i.length;r<s;r+=1){const s=i[r],{enuCenter:o=n,content:a}=s,d=a.rank,p=o[0]===n[0]&&o[1]===n[1]&&o[2]===n[2],v=p?l:Cc(t,o);if(this.Ps(v,s)<=e){const t=this.Xr+a.uri,e=a.uri;if(e&&!this.ji.Ji(e,!0)){const i=this.Rs(s,u,h,p,n,e),r=this.ji.nr(e,i);if(c.get(d)||c.set(d,[]),c.get(d)?.push({url:t,uri:e}),r)return r}if(s.children&&f(s.children))return!0}}},d=this.Wr;f([d]),jc(c.keys()).forEach((t=>{const e=c.get(t);for(let t=0,n=e.length;t<n;t+=1)this.ts.Xs(e[t])}))}}}class Kc{Zs=12;Ir=[];Ys=[];Js=[];nr=new Set;eo=0;Zr="";Or=0;vs;ys;ws;gs;Ts;Os;no=[];constructor(t,e){this.Ts=t,this.Os=e,this.Zs=6*(this.Os?.length||1)}clear(){this.Ir=[],this.Ys=[],this.nr.clear(),this.eo=0}loads(t){t.forEach((t=>{if(this.nr.has(t.Ie)){const e=this.Ir.indexOf(t.Ie);this.Ir.splice(e,1),this.Ys.splice(e,1)}else this.nr.add(t.Ie);this.Ir.push(t.Ie),this.Ys.push(t.te)})),t.length,this.io()}Xs(t){this.nr.has(t.url)||(this.Js.push(t.url),this.no.push(t.uri),this.nr.add(t.url),this.io())}async io(){if(this.eo<this.Zs&&(this.Ir.length||this.Js.length)){this.eo++;const t=this.Zr;let e=this.Ir.shift(),n=this.Ys.shift(),i=!1;if(e||(e=this.Js.shift(),n=this.no.shift(),i=!0),this.nr.delete(e),!this.vs(n,i))return this.eo--,void this.io();let r=e;this.Os&&this.Ts&&(r=e.replace(this.Ts,this.Os[this.Or%this.Os.length]),this.Or+=1);const s=await fetch(r,{cache:"default",mode:"cors",credentials:"omit"});if(200!==s.status&&304!==s.status)return this.ys({url:e,uri:n,message:s.status}),this.eo--,void this.io();const o=parseInt(s.headers.get("content-length"));if(!o)return this.ys({url:e,uri:n,message:"empty"}),this.eo--,void this.io();const a=await s.arrayBuffer();let u,h=new Uint8Array(a),l=!1,c=!1;const f={},d={};let p=!1;if("bin"==t||e.endsWith("bin"))u=new Uint32Array(a,0,2)[1],l=!0,p=1==new Float32Array(a,8,18)[10];else if("splat"==t||e.endsWith("splat"))u=o/32;else if("ply"==t||e.endsWith(".ply")){c=!0;const t=h,e=(new TextDecoder).decode(t.slice(0,10240)),n="end_header\n",i=e.indexOf(n);u=parseInt(/element vertex (\d+)\n/.exec(e)[1]);const r={double:"getFloat64",int:"getInt32",uint:"getUint32",float:"getFloat32",short:"getInt16",ushort:"getUint16",uchar:"getUint8"};let s=0;for(let t of e.slice(0,i).split("\n").filter((t=>t.startsWith("property ")))){const[e,n,i]=t.split(" "),o=r[n]||"getInt8";f[i]=o,d[i]=s,s+=parseInt(o.replace(/[^\d]/g,""))/8}p=!!f.f_rest_44;const o=i+n.length;h=t.slice(o)}this.ws({url:e,data:h,isCompressed:l,isPly:c,totalVertexCount:u,offsets:d,types:f,hasSH:p,uri:n}),this.eo--,this.io()}else this.Ir.length||this.eo||this.gs&&this.gs()}}class Xc{ro;so="单体化图层";oo=!1;ao;uo;ho;_show=!0;lo;Ln;co;fo;qt;do;po;vo;yo;mo;wo;ve=0;constructor(t){this.co=t,this.wo=t.cb,this.Ln=t.viewer,this.qt=t.tiles,this.fo=t.api_url,this.po={},this.do=[],this.yo={},this.mo=[],this.vo=new Hc({Bi:10,qi:this.onDrop}),this.ao=new r.Event,this.uo=new r.Event,this.oo=!1,this.ho=new r.Event,this.ro=new r.EntityCollection,this.lo=new r.EntityCluster,this.init()}init(){this.wo&&this.wo(this.ro)}initMonomer(t,e,n){const i=e.points,r=e.indexes;for(let e=0;e<r.length;e+=3){const s=r[e],o=r[e+1],a=r[e+2];t.push({monomer_id:n,points:[i[s],i[o],i[a]]})}}get name(){return this.so}clock=null;get entities(){return this.ro}get isLoading(){return this.oo}get changedEvent(){return this.ao}get errorEvent(){return this.uo}get loadingEvent(){return this.ho}get show(){return this._show}set show(t){this._show=t}get clustering(){return this.lo}set clustering(t){if(!r.defined(t))throw new r.DeveloperError("value must be defined.");this.lo=t}onDrop=(t,e)=>{delete this.po[t],this.yo=[],this.mo=[],this.do=[],this.ve=0,this.ro.removeAll();for(let t in this.po)this.do=this.do.concat(this.po[t]);let n=this.ve;for(let t of this.do)this.yo[n]=t,this.initMonomer(this.mo,t,n),n++;return!0};updateData(t){for(let e of t)this.vo.rr(e)||(this.vo.nr(e,"1"),fetch(this.fo+e+"_triangle.json").then((t=>t.json())).then((t=>{this.po[e]=t,this.do=[];for(let t in this.po)this.do=this.do.concat(this.po[t]);let n=this.ve;for(let t of this.do)this.yo[n]=t,this.initMonomer(this.mo,t,n),n++})).catch((t=>{})));return!0}update(){return!0}pick(t){let e=!1,n="";for(let i of this.mo){const s=r.Cartesian3.fromDegrees(i.points[0][0],i.points[0][1],i.points[0][2]),o=r.Cartesian3.fromDegrees(i.points[1][0],i.points[1][1],i.points[1][2]),a=r.Cartesian3.fromDegrees(i.points[2][0],i.points[2][1],i.points[2][2]);if(r.IntersectionTests.rayTriangle(t,s,o,a)){e=!0,n=i.monomer_id;break}}return e?this.yo[n]:null}}class Zc{Ln;bo;ye=!1;constructor(t){const e=t.viewer;this.Ln=e,this.bo=new Xc(t),e.dataSources.add(this.bo)}setVisibility(t,e){this.bo&&(this.bo.show=e)}hide(){this.bo&&(this.bo.entities.show=!1)}show(){this.bo&&(this.bo.entities.show=!0)}destory(){this.bo&&(this.bo.entities.removeAll(),this.Ln?.dataSources.remove(this.bo),this.bo=void 0),this.ye=!0,this.Ln=void 0}getEntities(){return this.bo?.entities}pick(t){return this.bo?.pick(t)}update(t){return this.bo?.updateData(t)}}class Yc extends Al{xo;Ln;un;sn=!0;ye=!1;_o;ko=.1;$o=1/0;So=-1/0;Mo;Eo;Co;Ao={enable:!1,color:new r.Color(1,1,1),intensity:1,direction:new r.Cartesian3(1,1,1)};kn={enable:!1,ambientColor:new r.Color(.9,.9,.9),lightColor:new r.Color(1,1,1),lightIntensity:1,lightDirection:new r.Cartesian3(1,1,1)};Io={metallic:0,roughness:.8};fs=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];constructor(t){super();const e=t.viewer;this.Ln=e;const n=e.scene;this.xo=new Qc({hs:t.lodFactor||1,bs:t.cacheSize||2e3,zs:t.cacheMemorySize,us:t.loadBuffer||0,cs:t.renderBuffer||10,Ie:t.url||"",fe:n.context,Cr:t.entityInfos||[],$s:t.tileSetData||null,fs:this.fs,ds:t.maxLevelRange,Ar:t.workers,ks:t.cacheNetworkSize,_scene:n}),this.xo.on("configloaded",(()=>{this.emit("configloaded",this.xo.Cs());const t=this.xo.Cs();if(t){const{enuCenter:e,bbox:n}=t,i=Math.sqrt(Math.pow(n[3]-n[0],2)+Math.pow(n[4]-n[1],2)+Math.pow(n[5]-n[2],2))/2;new r.BoundingSphere(r.Cartesian3.fromDegrees(e[0],e[1],e[2]),i)}})),this.xo.on("todrawtile",(t=>{this.emit("todrawtile",t)})),this.Io=Object.assign(this.Io,t.material),this.Ao=Object.assign(this.Ao,t.sunLight),this.kn=Object.assign(this.kn,t.light),t.maxPitch&&this.setMaxPitch(t.maxPitch),(t.minHeight||t.minRange||t.maxRange)&&this.setMinHeight(t.minHeight,t.minRange,t.maxRange),this.un=new Ol({scene:n,ln:t.depthTest||!1,Bt:this.xo.Bt,bn:t.pass,xn:t.filter,kn:t.light,_n:t.material,Sn:t.modelColor||new r.Color(0,0,0,0)}),this.un.on("renderfirstframe",(t=>{this.emit("renderfirstframe",t)})),t.monomerConfig&&(this.Mo=new Zc({name:"单体化图层",viewer:e,tiles:[],api_url:t.monomerConfig.api_url}),this.Co=t.monomerConfig.highlight_color),this.xo.ns=t=>{this.un.Bn(t)},this.xo.rs=()=>{this.Ln?.scene.requestRender()};let i=!1;n.preRender.addEventListener((async(t,e)=>{if(this.sn&&!this.ye){if(!i){i=!0;try{const e=await this.xo.qs(t);e?.length?(this.Oo(e),this.Mo&&this.To(e),this.un._show()):this.un.Un(),await this.xo.Ws()}finally{i=!1}}this.xo.Hs(t),this.un.Fn()}}),this);const s=n.globe.render;n.globe.render=t=>{s.call(n.globe,t),this.zo(t)}}preLoad(t,e=1e3,n){if(this.Ln){this.xo.clear("preloadComplete"),this.xo.on("preloadComplete",(()=>{this.xo.clear("preloadComplete"),n&&n()}));const i=this.getCameraPos();this.xo.Cs()?this.xo.Ls(t||[i.lng,i.lat,i.height],e):this.xo.on("configloaded",(()=>{this.xo.Ls(t||[i.lng,i.lat,i.height],e)}))}}set lodFactor(t){this.xo.hs=Math.max(1e-5,Math.min(300,t)),this.Ln?.scene.requestRender()}set light(t){this.kn=t,this.un.zn(t)}get light(){return this.kn}set material(t){this.Io=t,this.un.Dn(t)}get material(){return this.Io}set sunLight(t){this.Ao={enable:t.enable,direction:this.Do()||new r.Cartesian3(1,1,1),color:t.color||this.Ao&&this.Ao.color,intensity:t.intensity},this.updateSunLight()}get sunLight(){return this.Ao}getIndexDB(){return this.xo.Is()}updateSunLight(){this.Ao&&this.Ao.enable&&(this.Ao.direction=this.Do()||new r.Cartesian3(1,1,1),this.un.zn({enable:!0,ambientColor:this.kn?.ambientColor||new r.Color(1,1,1),lightColor:this.Ao.color,lightIntensity:this.Ao.intensity,lightDirection:this.Ao.direction}))}setEnuCenter(t){this.un.On(t)}setScaleByLod(t){this.fs=t,this.xo.Ms(t)}Do(){if(!this.Ln||!this.Ln.clock)return;const t=this.getEnuCenter();if(!t)return;const e=new r.Cartesian3,n=new r.Cartesian3,i=this.Ln.clock.currentTime;r.Simon1994PlanetaryPositions.computeSunPositionInEarthInertialFrame(i,e);const s=r.Transforms.computeTemeToPseudoFixedMatrix(i);return r.Matrix3.multiplyByVector(s,e,e),r.Cartesian3.normalize(Tc(e,t,new r.Cartesian3),n),n}Oo(t){}zo(t){const e=t.commandList,n=[],i=[];for(const t of e)t.Pn?n.push(t):i.push(t);t.commandList=[...i,...n]}To(t){const e=[];if(t.length>0)for(let n of t){const t=n.Ii;if(!t)continue;const i=t[0];if(14===i)e.push(t.join("_"));else{const n=i-14,r=[t[0]-n,t[1]>>n,t[2]>>n];e.push(r.join("_"))}}const n=[...new Set(e)];this.Mo&&this.Mo.update(n)}getTileSetUrl(){return this.xo.Ie}getEnuCenter(){return this.xo.Cs()?.enuCenter}getLimitBounds(){return this.xo.Cs()?.limitBounds}getBaseHeight(){const t=this.xo.Cs();return t?Math.max(0,t.bbox[2]+t.enuCenter[2]):0}setMaxPitch(t){void 0!==t?(t=t*Math.PI/180,this._o=t,this.Ln.camera.rotateUp=function(e){t&&(e&&this.pitch+e>t+.2*Math.PI/180&&(e=t-this.pitch),r.Camera.prototype.rotateUp.call(this,e))}):(this._o=void 0,this.Ln.camera.rotateUp=r.Camera.prototype.rotateUp)}getMaxPitch(){return this._o||0}setMinHeight(t,n,i){if(void 0!==t||void 0!==n||void 0!==i){this.ko=t,this.$o=n,this.So=i;const s=this.Ln.scene,o=this.Ln;this.Ln.camera.move=function(a,u){let h;const l=s.pickFromRay({direction:a,origin:this.positionWC});if(l&&l.position?h=l.position:o?.trackedEntity&&(h=o.trackedEntity.position?.getValue(o.clock.currentTime)),h){const r=e.Cartesian3.distance(h,this.positionWC);t&&u>0&&r*Math.cos(this.pitch+Math.PI/2)<t&&(u=0),n&&u>0&&r<n&&(u=0),i&&u<0&&r>i&&(u=0)}r.Camera.prototype.move.call(this,a,u)}}else this.ko=void 0,this.$o=void 0,this.So=void 0,this.Ln.camera.move=r.Camera.prototype.move}getMinHeight(){return this.ko||0}set depthTest(t){this.un.ln=t}setVisibility(t,e){this.xo.Gs(t,e)}hide(){this.sn=!1,this.un.Un()}show(){this.sn=!0,this.un._show()}destory(){this.setMaxPitch(),this.setMinHeight(),this.xo._destroy(),this.un._destroy(),this.ye=!0,this.Ln=void 0,this.ye=!0}pickPosition(t){const e=this.Ln.scene.pickPosition(t);if(r.defined(e)){var n=r.Cartographic.fromCartesian(e),i=r.Math.toDegrees(n.longitude),s=r.Math.toDegrees(n.latitude),o=n.height;return{lnglat:{lng:Mc(i,6),lat:Mc(s,6),alt:Mc(o,1)},ecef:e,target:this}}return null}pickEntity(t){const e=this.Ln.scene.pickPosition(t);if(r.defined(e)){var n=r.Cartographic.fromCartesian(e),i=r.Math.toDegrees(n.longitude),s=r.Math.toDegrees(n.latitude),o=n.height;return this.xo.Qs([i,s,o])}return null}selectedEntity(t,e){this.xo.Ke(t,e),1==this.xo.Re&&this.un.Bn(this.xo.qe)}getCameraPos(){if(this.Ln){var t=r.Cartographic.fromCartesian(this.Ln.camera.position),e=this.Ln.camera;return{lng:r.Math.toDegrees(t.longitude),lat:r.Math.toDegrees(t.latitude),height:t.height,heading:r.Math.toDegrees(e.heading),pitch:r.Math.toDegrees(e.pitch),roll:0}}}Ai(){return this.xo.Ks()}pickMonomer(t){const e=this.Ln;if(e){const a=e.camera.getPickRay(t.position),u=e.scene.camera.positionCartographic,h=r.Math.toDegrees(u.longitude),l=r.Math.toDegrees(u.latitude);new r.Cartesian3(h,l,u.height);var n=e.camera.pickEllipsoid(new r.Cartesian2(t.position.x,t.position.y));if(n){var i=r.Cartographic.fromCartesian(n),s=r.Math.toDegrees(i.longitude),o=r.Math.toDegrees(i.latitude);if(new r.Cartesian3(s,o,0),this.Mo){const t=this.Mo.pick(a);if(t){this.Eo&&e.entities.remove(this.Eo);let n=[];const i=t.contours;for(let e of i){const i=parseFloat(e[0]),r=parseFloat(e[1]),s=t.max_height;n.push(i),n.push(r),n.push(s)}let s="RGBA(255,0,0,0.3)";return this.Co&&(s=this.Co),this.Eo=e.entities.add({name:"polygon",polygon:{hierarchy:r.Cartesian3.fromDegreesArrayHeights(n),material:r.Color.fromCssColorString(s),extrudedHeight:t.min_height,perPositionHeight:!0}}),{id:t.id,contours:t.contours,max_height:t.max_height,min_height:t.min_height}}}}}}pickMonomerReset(){const t=this.Ln;t&&this.Eo&&t.entities.remove(this.Eo)}}const Jc=new r.Cartesian3,tf=new r.Cartesian3,ef=new r.Cartesian3,nf=new r.Cartesian3(0,0,1);class rf{Po;Ro;constructor(t=1,e=1,n=.1){this.Po=new r.Cartesian3(t,e,n),this.Ro=0}No(t,e){const n=r.Cartesian3.subtract(e,t,new r.Cartesian3);n.z<0?this.Ro=r.Cartesian3.magnitude(r.Cartesian3.divideComponents(n,this.Po,n)):this.Ro=r.Cartesian3.magnitude(new r.Cartesian3(n.x,n.y,0))}Fo(t,e=!1){t=r.Cartesian3.divideComponents(t,this.Po,t),t=r.Cartesian3.normalize(t,t),t=r.Cartesian3.multiplyComponents(t,this.Po,t);const n=new r.Cartesian3;if(r.Cartesian3.multiplyByScalar(t,this.Ro,n),e&&n.z>0){const t=r.Cartesian3.dot(n,nf);r.Cartesian3.multiplyByScalar(nf,t,Jc),r.Cartesian3.multiplyByScalar(r.Cartesian3.normalize(r.Cartesian3.fromElements(n.x,n.y,0,ef),ef),this.Ro,ef),r.Cartesian3.add(n,r.Cartesian3.multiplyByScalar(r.Cartesian3.subtract(r.Cartesian3.add(ef,Jc,tf),n,tf),2,tf),tf),n.x=tf.x,n.y=tf.y}return n.x=Math.round(100*n.x)/100,n.y=Math.round(100*n.y)/100,n.z=Math.round(100*n.z)/100,n}}var sf;class of{Je;sn=!1;ye=!1;_texture;Uo;constructor(t,e){this._texture=t,this.Uo=e}update(t){this.ye||this.sn&&(this.Uo.qo()||(this._texture.jo(),t.commandList.unshift(this.Je)))}isDestroyed(){return this.ye}show(){0==this.sn&&(this.sn=!0)}hide(){this.sn&&(this.sn=!1)}destroy(){this.ye=!0,this.Je.vertexArray.getAttribute(0).vertexBuffer.destroy(),this.Je.vertexArray.cn=[],this.Je.vertexArray.destroy()}}class af{co;Bo;Lo;Ho;Vo;Wo;Go;sn=!0;Qo;Ko=!0;destroyed=!1;constructor(e){e.autoHide=null==e.autoHide?t.AUTOHIDE_MODE.AUTO:e.autoHide,e.autoHideDistance=null==e.autoHideDistance?50:e.autoHideDistance,e.autoHideAngle=null==e.autoHideAngle?15:e.autoHideAngle;const n=e.viewer;this.Qo=new rf(1,1,1),this.co=e,n.scene,this.Bo=r.Cartesian3.fromDegrees(this.co.pos[0],this.co.pos[1],this.co.pos[2]),this.Ho=r.Transforms.localFrameToFixedFrameGenerator("north","west"),(t=>new Promise(((e,n)=>{!function n(){t.terrainProvider?setTimeout((()=>{e()}),2e3):setTimeout(n,300)}()})))(this.co.viewer).then((async()=>{this.Go=(await r.sampleTerrain(this.co.viewer.terrainProvider,13,[r.Cartographic.fromCartesian(this.Bo)]))[0]?.height||0,this.Xo(),this.Zo()}))}qo(){if(this.co.autoHide==t.AUTOHIDE_MODE.NO)return!1;if(this.co.autoHide==t.AUTOHIDE_MODE.ALL||this.co.autoHide==t.AUTOHIDE_MODE.AUTO&&!this.Ko){const t=this.co.viewer.camera;if(r.Cartesian3.distance(t.positionWC,this.Bo)>this.co.autoHideDistance)return!0;if(Math.abs(r.Math.toDegrees(t.heading)-this.co.heading)>this.co.autoHideAngle)return!0;if(Math.abs(r.Math.toDegrees(t.pitch)-this.co.pitch)>this.co.autoHideAngle)return!0}return!1}getPosition(){return this.Bo}async setPos(t){this.co.pos=t,this.Bo=r.Cartesian3.fromDegrees(t[0],t[1],t[2]),this.Go=(await r.sampleTerrain(this.co.viewer.terrainProvider,13,[r.Cartographic.fromCartesian(this.Bo)]))[0]?.height||0,this.Xo()}setOpacity(t){"number"==typeof t&&(this.co.opacity=t)}setInternalParams(t,e,n){this.co.resolution=t,this.co.fov_vertical=e,this.co.fov_horizontal=n,this.Xo()}setHeadingAndPitch(t,e){const n=typeof t,i=typeof e;"number"!=n&&"undefined"!=n||"number"!=i&&"undefined"!=i||this.Xo(t,e)&&(void 0!==t&&(this.co.heading=t),void 0!==e&&(this.co.pitch=e))}Xo(t,n){const i=this.co.resolution[0]/this.co.resolution[1];var s=r.Math.toRadians(this.co.fov_vertical),o=this.co.fov_horizontal?r.Math.toRadians(this.co.fov_vertical):2*Math.atan(Math.tan(s/2)*i);t=r.Math.toRadians(null==t?this.co.heading:t),n=r.Math.toRadians(null==n?this.co.pitch:n),this.Yo(t,n,0,0,0);const a=this.Bo,u=new r.Camera(this.co.viewer.scene);u.position=this.Bo;let h=new r.HeadingPitchRoll(t,n,0),l=r.Transforms.headingPitchRollToFixedFrame(this.Bo,h,r.Ellipsoid.WGS84,this.Ho),c=r.Matrix4.multiplyByPointAsVector(l,r.Cartesian3.UNIT_X,new r.Cartesian3);u.direction=c,u.frustum.aspectRatio=i,u.frustum.fov=i>1?o:s,u.frustum.near=1,u.frustum.far=1e4,u.setView({destination:this.Bo,orientation:{heading:t,pitch:n,roll:0}});var f=u.frustum.projectionMatrix,d=r.Matrix4.multiply(u.viewMatrix,r.Matrix4.fromTranslation(a),new r.Matrix4),p=r.Matrix4.multiply(f,d,new r.Matrix4);this.Wo=p;const v=[],y=16;if(this.co.mode){const i=this.co.pos[2]-this.Go,r=new e.Cartesian3(0,0,0),u=new e.Cartesian3(0,0,-i);this.Qo.No(r,u);let h=-o/2,l=s/2,c=(-s/2-l)/y;for(let e=0;e<=y;e+=1){const i=this.Jo(t,n,0,h,l+c*e);v.push(i.x-a.x,i.y-a.y,i.z-a.z)}h=o/2;for(let e=0;e<=y;e+=1){const i=this.Jo(t,n,0,h,l+c*e);v.push(i.x-a.x,i.y-a.y,i.z-a.z)}}else{let i=-s/2,r=(s/2-i)/y,u=-o/2,h=e.Cartesian3.fromDegrees(this.co.pos[0],this.co.pos[1],this.Go);for(let e=0;e<=y;e+=1){const s=this._a(t,n,0,u,i+r*e);let o=this.tu(s);o?h=o:(o=this.eu(h,s),this.Ko=!1),v.push(o.x-a.x,o.y-a.y,o.z-a.z)}u=o/2;for(let e=0;e<=y;e+=1){const s=this._a(t,n,0,u,i+r*e);let o=this.tu(s);o?h=o:(o=this.eu(h,s),this.Ko=!1),v.push(o.x-a.x,o.y-a.y,o.z-a.z)}}if(this.Vo=v,this.Lo?.Je){const t=this.Lo.Je.vertexArray.getAttribute(0).vertexBuffer;t?.copyFromArrayView(new Float32Array(v))}return!0}eu(t,n){const i=new e.Cartesian3(0,0,0),r=Tc(t,this.co.pos);return this.Qo.No(i,r),Dc(this.Qo.Fo(n),this.co.pos)}tu(t){let n=Dc(t,this.co.pos);n=e.Cartesian3.subtract(n,this.Bo,new e.Cartesian3);var i=new r.Ray(this.Bo,n),s=new r.Ellipsoid(r.Ellipsoid.WGS84.radii.x+this.Go,r.Ellipsoid.WGS84.radii.y+this.Go,r.Ellipsoid.WGS84.radii.z+this.Go),o=r.IntersectionTests.rayEllipsoid(i,s);return o?r.Ray.getPoint(i,o.start):null}_a(t,n,i,s,o){s=Math.tan(s),o=Math.tan(o);let a=new r.Cartesian3;a=r.Cartesian3.normalize(new e.Cartesian3(s,1,o),a);let u=r.Matrix3.fromRotationX(n),h=r.Matrix3.fromRotationZ(-t),l=r.Matrix3.fromColumnMajorArray([a.x,a.y,a.z,0,0,0,0,0,0]);return l=r.Matrix3.multiply(u,l,new r.Matrix3),l=r.Matrix3.multiply(h,l,new r.Matrix3),r.Matrix3.getColumn(l,0,new e.Cartesian3)}Jo(t,e,n,i,r){const s=this._a(t,e,n,i,r);return Dc(this.Qo.Fo(s),this.co.pos)}hide(){this.sn=!1,this.Lo?.hide()}show(){this.sn=!0,this.Lo?.show()}destroy(){this.Lo?.destroy(),this.Lo=void 0,this.Wo=void 0,this.destroyed=!0}focus(t,e){(e||this.co.viewer).camera.setView({destination:this.Bo,orientation:{heading:r.Math.toRadians(this.co.heading),pitch:r.Math.toRadians(this.co.pitch),roll:0}}),t&&this.show()}Yo(t,n,i,s,o){let a=new r.HeadingPitchRoll(t,n,i),u=r.Transforms.headingPitchRollToFixedFrame(this.Bo,a,r.Ellipsoid.WGS84,this.Ho);s=Math.tan(s),o=Math.tan(o);let h=new r.Cartesian3;h=r.Cartesian3.normalize(new e.Cartesian3(1,s,o),h);let l=r.Matrix4.multiplyByPointAsVector(u,h,new r.Cartesian3);var c=new r.Ray(this.Bo,l),f=this.Go,d=new r.Ellipsoid(r.Ellipsoid.WGS84.radii.x+f,r.Ellipsoid.WGS84.radii.y+f,r.Ellipsoid.WGS84.radii.z+f),p=r.IntersectionTests.rayEllipsoid(c,d);return p?r.Ray.getPoint(c,p.start):null}Zo(){var t=document.createElement("video");t.style.cssText="position:fixed;top:0;right:0",t.width=400,t.muted=!0,t.autoplay=!0,t.loop=!0,t.style.display="none",document.body.appendChild(t),t.src=this.co.url,t.crossOrigin="anonymous",t.load(),t.play();const e=[];for(let t=0;t<16;t+=1)e.push(t,t+16+1,t+16+2),e.push(t,t+16+2,t+1);var n=new Uint16Array(e);t.addEventListener("loadeddata",(()=>{const e=this.co.viewer.scene.context,i=r.FeatureDetection.supportsWebgl2&&r.FeatureDetection.supportsWebgl2(this.co.viewer.scene),s=r.ShaderProgram.fromCache({context:e,vertexShaderSource:i?"#version 300 es\nprecision highp int;precision highp float;in vec3 position;out vec3 pos;uniform vec3 u_delta;uniform mat4 u_vp2;void main(){gl_Position=u_vp2*vec4(position,1.0f);pos=position;}":"#version 300 es\nprecision highp int;precision highp float;in vec3 position;in vec2 coord;out vec2 texCoord;void main(){gl_Position=czm_modelViewProjection*vec4(position,1.0f);texCoord=coord;}",fragmentShaderSource:i?"#version 300 es\nprecision highp float;uniform highp sampler2D u_video;uniform mat4 u_vp;uniform float u_opacity;in vec3 pos;void main(){vec4 proj=(u_vp*vec4(pos,1.0f));vec2 uv=proj.xy/proj.w+vec2(1,1);vec4 c=texture(u_video,uv/2.0f);c.a=u_opacity;out_FragColor=c;}":"#version 300 es\nprecision highp float;in vec2 texCoord;uniform highp sampler2D u_video;void main(){highp vec4 c=texelFetch(u_video,texCoord,0.0f);out_FragColor=c;}",attributeLocations:{position:0}}),o={enabled:!0,equationRgb:r.BlendEquation.ADD,equationAlpha:r.BlendEquation.ADD,functionSourceRgb:r.BlendFunction.SOURCE_ALPHA,functionDestinationRgb:r.BlendFunction.ONE_MINUS_SOURCE_ALPHA,functionSourceAlpha:r.BlendFunction.ONE,functionDestinationAlpha:r.BlendFunction.ONE_MINUS_SOURCE_ALPHA},a=r.RenderState.fromCache({depthTest:{enabled:!1},blending:o,depthMask:!0,colorMask:{red:!0,green:!0,blue:!0,alpha:!0}}),u=(()=>{const n=new r.Texture({name:"camera",context:e,source:t,flipY:!0,sampler:new r.Sampler({minificationFilter:r.TextureMinificationFilter.NEAREST,magnificationFilter:r.TextureMagnificationFilter.LINEAR})});return n.jo=()=>{n.copyFrom({source:t})},n})();this.Lo=new of(u,this),this.sn||this.Lo.hide();const h={u_video:()=>u,u_vp:()=>this.Wo,u_vp2:()=>{let t=this.co.viewer.camera.frustum.projectionMatrix;var e=r.Matrix4.multiply(this.co.viewer.camera.viewMatrix,r.Matrix4.fromTranslation(this.Bo),new r.Matrix4);return r.Matrix4.multiply(t,e,new r.Matrix4)},u_delta:()=>this.Bo,u_opacity:()=>void 0!==this.co.opacity?this.co.opacity:1},l=new r.VertexArray({name:"camera",context:e,attributes:[{index:0,vertexBuffer:r.Buffer.createVertexBuffer({usage:r.BufferUsage.STATIC_DRAW,typedArray:new Float32Array(this.Vo),context:e}),componentsPerAttribute:3,componentDatatype:r.ComponentDatatype.FLOAT}],indexBuffer:r.Buffer.createIndexBuffer({context:e,typedArray:n,usage:r.BufferUsage.STATIC_DRAW,indexDatatype:r.IndexDatatype.UNSIGNED_SHORT})}),c=new r.DrawCommand({vertexArray:l,shaderProgram:s,uniformMap:h,renderState:a,pass:r.Pass.OPAQUE,count:96});this.Lo.Je=c,this.co.viewer.scene.primitives.add(this.Lo),this.sn&&this.Lo.show()}))}}t.AUTOHIDE_MODE=void 0,(sf=t.AUTOHIDE_MODE||(t.AUTOHIDE_MODE={}))[sf.NO=0]="NO",sf[sf.ALL=1]="ALL",sf[sf.AUTO=2]="AUTO";var uf=6371008.8,hf={centimeters:100*uf,centimetres:100*uf,degrees:360/(2*Math.PI),feet:3.28084*uf,inches:39.37*uf,kilometers:uf/1e3,kilometres:uf/1e3,meters:uf,metres:uf,miles:uf/1609.344,millimeters:1e3*uf,millimetres:1e3*uf,nauticalmiles:uf/1852,radians:1,yards:1.0936*uf};function lf(t,e,n={}){const i={type:"Feature"};return(0===n.id||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=e||{},i.geometry=t,i}function cf(t,e={}){const n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=t,n}function ff(t,e="kilometers"){const n=hf[e];if(!n)throw new Error(e+" units is invalid");return t*n}function df(t){return t%360*Math.PI/180}function pf(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function vf(t,e,n){if(null!==t)for(var i,r,s,o,a,u,h,l,c=0,f=0,d=t.type,p="FeatureCollection"===d,v="Feature"===d,y=p?t.features.length:1,m=0;m<y;m++){a=(l=!!(h=p?t.features[m].geometry:v?t.geometry:t)&&"GeometryCollection"===h.type)?h.geometries.length:1;for(var w=0;w<a;w++){var g=0,b=0;if(null!==(o=l?h.geometries[w]:h)){u=o.coordinates;var x=o.type;switch(c=0,x){case null:break;case"Point":if(!1===e(u,f,m,g,b))return!1;f++,g++;break;case"LineString":case"MultiPoint":for(i=0;i<u.length;i++){if(!1===e(u[i],f,m,g,b))return!1;f++,"MultiPoint"===x&&g++}"LineString"===x&&g++;break;case"Polygon":case"MultiLineString":for(i=0;i<u.length;i++){for(r=0;r<u[i].length-c;r++){if(!1===e(u[i][r],f,m,g,b))return!1;f++}"MultiLineString"===x&&g++,"Polygon"===x&&b++}"Polygon"===x&&g++;break;case"MultiPolygon":for(i=0;i<u.length;i++){for(b=0,r=0;r<u[i].length;r++){for(s=0;s<u[i][r].length-c;s++){if(!1===e(u[i][r][s],f,m,g,b))return!1;f++}b++}g++}break;case"GeometryCollection":for(i=0;i<o.geometries.length;i++)if(!1===vf(o.geometries[i],e))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function yf(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(var n=0;n<t.features.length&&!1!==e(t.features[n],n);n++);}function mf(t,e){var n,i,r,s,o,a,u,h,l,c,f=0,d="FeatureCollection"===t.type,p="Feature"===t.type,v=d?t.features.length:1;for(n=0;n<v;n++){for(a=d?t.features[n].geometry:p?t.geometry:t,h=d?t.features[n].properties:p?t.properties:{},l=d?t.features[n].bbox:p?t.bbox:void 0,c=d?t.features[n].id:p?t.id:void 0,o=(u=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,r=0;r<o;r++)if(null!==(s=u?a.geometries[r]:a))switch(s.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(s,f,h,l,c))return!1;break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(!1===e(s.geometries[i],f,h,l,c))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,f,h,l,c))return!1;f++}}var wf="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function gf(t){return t&&t.nu&&{}.hasOwnProperty.call(t,"default")?t.default:t}var bf,xf={exports:{}},_f=(bf||(bf=1,xf.exports=function(){function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function n(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function s(t,e){return s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},s(t,e)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function a(t,e,n){return a=o()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);var r=new(Function.bind.apply(t,i));return n&&s(r,n.prototype),r},a.apply(null,arguments)}function u(t){var e="function"==typeof Map?new Map:void 0;return u=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return a(t,arguments,r(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),s(i,t)},u(t)}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t){var e=o();return function(){var n,i=r(t);if(e){var s=r(this).constructor;n=Reflect.construct(i,arguments,s)}else n=i.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}(this,n)}}function c(t,e,n){return c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}(t,e);if(i){var s=Object.getOwnPropertyDescriptor(i,e);return s.get?s.get.call(n):s.value}},c(t,e,n||t)}function f(t){return function(t){if(Array.isArray(t))return p(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||d(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t,e){if(t){if("string"==typeof t)return p(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(t,e):void 0}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function v(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=d(t))||e){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){a=!0,s=t},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw s}}}}var y=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getEndCapStyle",value:function(){return this.iu}},{key:"isSingleSided",value:function(){return this.ru}},{key:"setQuadrantSegments",value:function(t){this.su=t,0===this.su&&(this.ou=e.JOIN_BEVEL),this.su<0&&(this.ou=e.JOIN_MITRE,this.au=Math.abs(this.su)),t<=0&&(this.su=1),this.ou!==e.JOIN_ROUND&&(this.su=e.DEFAULT_QUADRANT_SEGMENTS)}},{key:"getJoinStyle",value:function(){return this.ou}},{key:"setJoinStyle",value:function(t){this.ou=t}},{key:"setSimplifyFactor",value:function(t){this.uu=t<0?0:t}},{key:"getSimplifyFactor",value:function(){return this.uu}},{key:"getQuadrantSegments",value:function(){return this.su}},{key:"setEndCapStyle",value:function(t){this.iu=t}},{key:"getMitreLimit",value:function(){return this.au}},{key:"setMitreLimit",value:function(t){this.au=t}},{key:"setSingleSided",value:function(t){this.ru=t}}],[{key:"constructor_",value:function(){if(this.su=e.DEFAULT_QUADRANT_SEGMENTS,this.iu=e.CAP_ROUND,this.ou=e.JOIN_ROUND,this.au=e.DEFAULT_MITRE_LIMIT,this.ru=!1,this.uu=e.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setQuadrantSegments(t)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(i)}else if(4===arguments.length){var r=arguments[0],s=arguments[1],o=arguments[2],a=arguments[3];this.setQuadrantSegments(r),this.setEndCapStyle(s),this.setJoinStyle(o),this.setMitreLimit(a)}}},{key:"bufferDistanceError",value:function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)}}]),e}();y.CAP_ROUND=1,y.CAP_FLAT=2,y.CAP_SQUARE=3,y.JOIN_ROUND=1,y.JOIN_MITRE=2,y.JOIN_BEVEL=3,y.DEFAULT_QUADRANT_SEGMENTS=8,y.DEFAULT_MITRE_LIMIT=5,y.DEFAULT_SIMPLIFY_FACTOR=.01;var m=function(e){i(s,e);var r=l(s);function s(e){var n;return t(this,s),(n=r.call(this,e)).name=Object.keys({Exception:s})[0],n}return n(s,[{key:"toString",value:function(){return this.message}}]),s}(u(Error)),w=function(e){i(r,e);var n=l(r);function r(e){var i;return t(this,r),(i=n.call(this,e)).name=Object.keys({IllegalArgumentException:r})[0],i}return r}(m),g=function(){function e(){t(this,e)}return n(e,[{key:"filter",value:function(t){}}]),e}();function b(){}function x(){}function _(){}var k,$,S,M,E,C,A,I=function(){function e(){t(this,e)}return n(e,null,[{key:"equalsWithTolerance",value:function(t,e,n){return Math.abs(t-e)<=n}}]),e}(),O=function(){function e(n,i){t(this,e),this.low=i||0,this.high=n||0}return n(e,null,[{key:"toBinaryString",value:function(t){var e,n="";for(e=2147483648;e>0;e>>>=1)n+=(t.high&e)===e?"1":"0";for(e=2147483648;e>0;e>>>=1)n+=(t.low&e)===e?"1":"0";return n}}]),e}();function T(){}function z(){}T.NaN=NaN,T.isNaN=function(t){return Number.isNaN(t)},T.isInfinite=function(t){return!Number.isFinite(t)},T.MAX_VALUE=Number.MAX_VALUE,T.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,T.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,"function"==typeof Float64Array&&"function"==typeof Int32Array?(E=2146435072,C=new Float64Array(1),A=new Int32Array(C.buffer),T.doubleToLongBits=function(t){C[0]=t;var e=0|A[0],n=0|A[1];return(n&E)===E&&!!(1048575&n)&&0!==e&&(e=0,n=2146959360),new O(n,e)},T.longBitsToDouble=function(t){return A[0]=t.low,A[1]=t.high,C[0]}):(k=Math.log2,$=Math.floor,S=Math.pow,M=function(){for(var t=53;t>0;t--){var e=S(2,t)-1;if($(k(e))+1===t)return e}return 0}(),T.doubleToLongBits=function(t){var e,n,i,r,s,o,a,u,h;if(t<0||1/t===Number.NEGATIVE_INFINITY?(o=1<<31,t=-t):o=0,0===t)return new O(u=o,h=0);if(t===1/0)return new O(u=2146435072|o,h=0);if(t!=t)return new O(u=2146959360,h=0);if(r=0,h=0,(e=$(t))>1)if(e<=M)(r=$(k(e)))<=20?(h=0,u=e<<20-r&1048575):(h=e%(n=S(2,i=r-20))<<32-i,u=e/n&1048575);else for(i=e,h=0;0!==(i=$(n=i/2));)r++,h>>>=1,h|=(1&u)<<31,u>>>=1,n!==i&&(u|=524288);if(a=r+1023,s=0===e,e=t-e,r<52&&0!==e)for(i=0;;){if((n=2*e)>=1?(e=n-1,s?(a--,s=!1):(i<<=1,i|=1,r++)):(e=n,s?0==--a&&(r++,s=!1):(i<<=1,r++)),20===r)u|=i,i=0;else if(52===r){h|=i;break}if(1===n){r<20?u|=i<<20-r:r<52&&(h|=i<<52-r);break}}return u|=a<<20,new O(u|=o,h)},T.longBitsToDouble=function(t){var e,n,i,r,s=t.high,o=t.low,a=s&1<<31?-1:1;for(i=((2146435072&s)>>20)-1023,r=0,n=1<<19,e=1;e<=20;e++)s&n&&(r+=S(2,-e)),n>>>=1;for(n=1<<31,e=21;e<=52;e++)o&n&&(r+=S(2,-e)),n>>>=1;if(-1023===i){if(0===r)return 0*a;i=-1022}else{if(1024===i)return 0===r?a/0:NaN;r+=1}return a*r*S(2,i)});var D=function(e){i(r,e);var n=l(r);function r(e){var i;return t(this,r),(i=n.call(this,e)).name=Object.keys({RuntimeException:r})[0],i}return r}(m),P=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),e=r.call(this),s.constructor_.apply(h(e),arguments),e}return n(s,null,[{key:"constructor_",value:function(){if(0===arguments.length)D.constructor_.call(this);else if(1===arguments.length){var t=arguments[0];D.constructor_.call(this,t)}}}]),s}(D),R=function(){function e(){t(this,e)}return n(e,null,[{key:"shouldNeverReachHere",value:function(){if(0===arguments.length)e.shouldNeverReachHere(null);else if(1===arguments.length){var t=arguments[0];throw new P("Should never reach here"+(null!==t?": "+t:""))}}},{key:"isTrue",value:function(){if(1===arguments.length){var t=arguments[0];e.isTrue(t,null)}else if(2===arguments.length){var n=arguments[1];if(!arguments[0])throw null===n?new P:new P(n)}}},{key:"equals",value:function(){if(2===arguments.length){var t=arguments[0],n=arguments[1];e.equals(t,n,null)}else if(3===arguments.length){var i=arguments[0],r=arguments[1],s=arguments[2];if(!r.equals(i))throw new P("Expected "+i+" but encountered "+r+(null!==s?": "+s:""))}}}]),e}(),N=new ArrayBuffer(8),F=new Float64Array(N),U=new Int32Array(N),q=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getM",value:function(){return T.NaN}},{key:"setOrdinate",value:function(t,n){switch(t){case e.X:this.x=n;break;case e.Y:this.y=n;break;case e.Z:this.setZ(n);break;default:throw new w("Invalid ordinate index: "+t)}}},{key:"equals2D",value:function(){if(1===arguments.length){var t=arguments[0];return this.x===t.x&&this.y===t.y}if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!I.equalsWithTolerance(this.x,e.x,n)&&!!I.equalsWithTolerance(this.y,e.y,n)}}},{key:"setM",value:function(t){throw new w("Invalid ordinate index: "+e.M)}},{key:"getZ",value:function(){return this.z}},{key:"getOrdinate",value:function(t){switch(t){case e.X:return this.x;case e.Y:return this.y;case e.Z:return this.getZ()}throw new w("Invalid ordinate index: "+t)}},{key:"equals3D",value:function(t){return this.x===t.x&&this.y===t.y&&(this.getZ()===t.getZ()||T.isNaN(this.getZ())&&T.isNaN(t.getZ()))}},{key:"equals",value:function(t){return t instanceof e&&this.equals2D(t)}},{key:"equalInZ",value:function(t,e){return I.equalsWithTolerance(this.getZ(),t.getZ(),e)}},{key:"setX",value:function(t){this.x=t}},{key:"compareTo",value:function(t){var e=t;return this.x<e.x?-1:this.x>e.x?1:this.y<e.y?-1:this.y>e.y?1:0}},{key:"getX",value:function(){return this.x}},{key:"setZ",value:function(t){this.z=t}},{key:"clone",value:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return R.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw t}}},{key:"copy",value:function(){return new e(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}},{key:"distance3D",value:function(t){var e=this.x-t.x,n=this.y-t.y,i=this.getZ()-t.getZ();return Math.sqrt(e*e+n*n+i*i)}},{key:"getY",value:function(){return this.y}},{key:"setY",value:function(t){this.y=t}},{key:"distance",value:function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)}},{key:"hashCode",value:function(){var t=17;return 37*(t=37*t+e.hashCode(this.x))+e.hashCode(this.y)}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}},{key:"interfaces_",get:function(){return[b,x,_]}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)e.constructor_.call(this,0,0);else if(1===arguments.length){var t=arguments[0];e.constructor_.call(this,t.x,t.y,t.getZ())}else if(2===arguments.length){var n=arguments[0],i=arguments[1];e.constructor_.call(this,n,i,e.NULL_ORDINATE)}else if(3===arguments.length){var r=arguments[0],s=arguments[1],o=arguments[2];this.x=r,this.y=s,this.z=o}}},{key:"hashCode",value:function(t){return F[0]=t,U[0]^U[1]}}]),e}(),j=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"compare",value:function(t,n){var i=e.compare(t.x,n.x);if(0!==i)return i;var r=e.compare(t.y,n.y);return 0!==r?r:this.hu<=2?0:e.compare(t.getZ(),n.getZ())}},{key:"interfaces_",get:function(){return[z]}}],[{key:"constructor_",value:function(){if(this.hu=2,0===arguments.length)e.constructor_.call(this,2);else if(1===arguments.length){var t=arguments[0];if(2!==t&&3!==t)throw new w("only 2 or 3 dimensions may be specified");this.hu=t}}},{key:"compare",value:function(t,e){return t<e?-1:t>e?1:T.isNaN(t)?T.isNaN(e)?0:-1:T.isNaN(e)?1:0}}]),e}();q.DimensionalComparator=j,q.NULL_ORDINATE=T.NaN,q.X=0,q.Y=1,q.Z=2,q.M=3;var B=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getArea",value:function(){return this.getWidth()*this.getHeight()}},{key:"equals",value:function(t){if(!(t instanceof e))return!1;var n=t;return this.isNull()?n.isNull():this.lu===n.getMaxX()&&this.cu===n.getMaxY()&&this.fu===n.getMinX()&&this.du===n.getMinY()}},{key:"intersection",value:function(t){if(this.isNull()||t.isNull()||!this.intersects(t))return new e;var n=this.fu>t.fu?this.fu:t.fu,i=this.du>t.du?this.du:t.du;return new e(n,this.lu<t.lu?this.lu:t.lu,i,this.cu<t.cu?this.cu:t.cu)}},{key:"isNull",value:function(){return this.lu<this.fu}},{key:"getMaxX",value:function(){return this.lu}},{key:"covers",value:function(){if(1===arguments.length){if(arguments[0]instanceof q){var t=arguments[0];return this.covers(t.x,t.y)}if(arguments[0]instanceof e){var n=arguments[0];return!this.isNull()&&!n.isNull()&&n.getMinX()>=this.fu&&n.getMaxX()<=this.lu&&n.getMinY()>=this.du&&n.getMaxY()<=this.cu}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];return!this.isNull()&&i>=this.fu&&i<=this.lu&&r>=this.du&&r<=this.cu}}},{key:"intersects",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t.fu>this.lu||t.lu<this.fu||t.du>this.cu||t.cu<this.du)}if(arguments[0]instanceof q){var n=arguments[0];return this.intersects(n.x,n.y)}}else if(2===arguments.length){if(arguments[0]instanceof q&&arguments[1]instanceof q){var i=arguments[0],r=arguments[1];return!(this.isNull()||(i.x<r.x?i.x:r.x)>this.lu||(i.x>r.x?i.x:r.x)<this.fu||(i.y<r.y?i.y:r.y)>this.cu||(i.y>r.y?i.y:r.y)<this.du)}if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var s=arguments[0],o=arguments[1];return!this.isNull()&&!(s>this.lu||s<this.fu||o>this.cu||o<this.du)}}}},{key:"getMinY",value:function(){return this.du}},{key:"getDiameter",value:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return Math.sqrt(t*t+e*e)}},{key:"getMinX",value:function(){return this.fu}},{key:"expandToInclude",value:function(){if(1===arguments.length){if(arguments[0]instanceof q){var t=arguments[0];this.expandToInclude(t.x,t.y)}else if(arguments[0]instanceof e){var n=arguments[0];if(n.isNull())return null;this.isNull()?(this.fu=n.getMinX(),this.lu=n.getMaxX(),this.du=n.getMinY(),this.cu=n.getMaxY()):(n.fu<this.fu&&(this.fu=n.fu),n.lu>this.lu&&(this.lu=n.lu),n.du<this.du&&(this.du=n.du),n.cu>this.cu&&(this.cu=n.cu))}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.isNull()?(this.fu=i,this.lu=i,this.du=r,this.cu=r):(i<this.fu&&(this.fu=i),i>this.lu&&(this.lu=i),r<this.du&&(this.du=r),r>this.cu&&(this.cu=r))}}},{key:"minExtent",value:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t<e?t:e}},{key:"getWidth",value:function(){return this.isNull()?0:this.lu-this.fu}},{key:"compareTo",value:function(t){var e=t;return this.isNull()?e.isNull()?0:-1:e.isNull()?1:this.fu<e.fu?-1:this.fu>e.fu?1:this.du<e.du?-1:this.du>e.du?1:this.lu<e.lu?-1:this.lu>e.lu?1:this.cu<e.cu?-1:this.cu>e.cu?1:0}},{key:"translate",value:function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)}},{key:"copy",value:function(){return new e(this)}},{key:"toString",value:function(){return"Env["+this.fu+" : "+this.lu+", "+this.du+" : "+this.cu+"]"}},{key:"setToNull",value:function(){this.fu=0,this.lu=-1,this.du=0,this.cu=-1}},{key:"disjoint",value:function(t){return!(!this.isNull()&&!t.isNull())||t.fu>this.lu||t.lu<this.fu||t.du>this.cu||t.cu<this.du}},{key:"getHeight",value:function(){return this.isNull()?0:this.cu-this.du}},{key:"maxExtent",value:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e}},{key:"expandBy",value:function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this.fu-=e,this.lu+=e,this.du-=n,this.cu+=n,(this.fu>this.lu||this.du>this.cu)&&this.setToNull()}}},{key:"contains",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.covers(t)}if(arguments[0]instanceof q){var n=arguments[0];return this.covers(n)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];return this.covers(i,r)}}},{key:"centre",value:function(){return this.isNull()?null:new q((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}},{key:"init",value:function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof q){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof e){var n=arguments[0];this.fu=n.fu,this.lu=n.lu,this.du=n.du,this.cu=n.cu}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.init(i.x,r.x,i.y,r.y)}else if(4===arguments.length){var s=arguments[0],o=arguments[1],a=arguments[2],u=arguments[3];s<o?(this.fu=s,this.lu=o):(this.fu=o,this.lu=s),a<u?(this.du=a,this.cu=u):(this.du=u,this.cu=a)}}},{key:"getMaxY",value:function(){return this.cu}},{key:"distance",value:function(t){if(this.intersects(t))return 0;var e=0;this.lu<t.fu?e=t.fu-this.lu:this.fu>t.lu&&(e=this.fu-t.lu);var n=0;return this.cu<t.du?n=t.du-this.cu:this.du>t.cu&&(n=this.du-t.cu),0===e?n:0===n?e:Math.sqrt(e*e+n*n)}},{key:"hashCode",value:function(){var t=17;return 37*(t=37*(t=37*(t=37*t+q.hashCode(this.fu))+q.hashCode(this.lu))+q.hashCode(this.du))+q.hashCode(this.cu)}},{key:"interfaces_",get:function(){return[b,_]}}],[{key:"constructor_",value:function(){if(this.fu=null,this.lu=null,this.du=null,this.cu=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof q){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof e){var n=arguments[0];this.init(n)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.init(i.x,r.x,i.y,r.y)}else if(4===arguments.length){var s=arguments[0],o=arguments[1],a=arguments[2],u=arguments[3];this.init(s,o,a,u)}}},{key:"intersects",value:function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.x<e.x?t.x:e.x)&&n.x<=(t.x>e.x?t.x:e.x)&&n.y>=(t.y<e.y?t.y:e.y)&&n.y<=(t.y>e.y?t.y:e.y)}if(4===arguments.length){var i=arguments[0],r=arguments[1],s=arguments[2],o=arguments[3],a=Math.min(s.x,o.x),u=Math.max(s.x,o.x),h=Math.min(i.x,r.x),l=Math.max(i.x,r.x);return!(h>u||l<a||(a=Math.min(s.y,o.y),u=Math.max(s.y,o.y),h=Math.min(i.y,r.y),l=Math.max(i.y,r.y),h>u||l<a))}}}]),e}(),L=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"isGeometryCollection",value:function(){return this.getTypeCode()===e.TYPECODE_GEOMETRYCOLLECTION}},{key:"getFactory",value:function(){return this.pu}},{key:"getGeometryN",value:function(t){return this}},{key:"getArea",value:function(){return 0}},{key:"isRectangle",value:function(){return!1}},{key:"equalsExact",value:function(t){return this===t||this.equalsExact(t,0)}},{key:"geometryChanged",value:function(){this.apply(e.geometryChangedFilter)}},{key:"geometryChangedAction",value:function(){this.vu=null}},{key:"equalsNorm",value:function(t){return null!==t&&this.norm().equalsExact(t.norm())}},{key:"getLength",value:function(){return 0}},{key:"getNumGeometries",value:function(){return 1}},{key:"compareTo",value:function(){var t;if(1===arguments.length){var e=arguments[0];return t=e,this.getTypeCode()!==t.getTypeCode()?this.getTypeCode()-t.getTypeCode():this.isEmpty()&&t.isEmpty()?0:this.isEmpty()?-1:t.isEmpty()?1:this.compareToSameClass(e)}if(2===arguments.length){var n=arguments[0],i=arguments[1];return t=n,this.getTypeCode()!==t.getTypeCode()?this.getTypeCode()-t.getTypeCode():this.isEmpty()&&t.isEmpty()?0:this.isEmpty()?-1:t.isEmpty()?1:this.compareToSameClass(n,i)}}},{key:"getUserData",value:function(){return this.yu}},{key:"getSRID",value:function(){return this.mu}},{key:"getEnvelope",value:function(){return this.getFactory().toGeometry(this.getEnvelopeInternal())}},{key:"checkNotGeometryCollection",value:function(t){if(t.getTypeCode()===e.TYPECODE_GEOMETRYCOLLECTION)throw new w("This method does not support GeometryCollection arguments")}},{key:"equal",value:function(t,e,n){return 0===n?t.equals(e):t.distance(e)<=n}},{key:"norm",value:function(){var t=this.copy();return t.normalize(),t}},{key:"reverse",value:function(){var t=this.reverseInternal();return null!=this.envelope&&(t.envelope=this.envelope.copy()),t.setSRID(this.getSRID()),t}},{key:"copy",value:function(){var t=this.copyInternal();return t.envelope=null==this.vu?null:this.vu.copy(),t.mu=this.mu,t.yu=this.yu,t}},{key:"getPrecisionModel",value:function(){return this.pu.getPrecisionModel()}},{key:"getEnvelopeInternal",value:function(){return null===this.vu&&(this.vu=this.computeEnvelopeInternal()),new B(this.vu)}},{key:"setSRID",value:function(t){this.mu=t}},{key:"setUserData",value:function(t){this.yu=t}},{key:"compare",value:function(t,e){for(var n=t.iterator(),i=e.iterator();n.hasNext()&&i.hasNext();){var r=n.next(),s=i.next(),o=r.compareTo(s);if(0!==o)return o}return n.hasNext()?1:i.hasNext()?-1:0}},{key:"hashCode",value:function(){return this.getEnvelopeInternal().hashCode()}},{key:"isEquivalentClass",value:function(t){return this.getClass()===t.getClass()}},{key:"isGeometryCollectionOrDerived",value:function(){return this.getTypeCode()===e.TYPECODE_GEOMETRYCOLLECTION||this.getTypeCode()===e.TYPECODE_MULTIPOINT||this.getTypeCode()===e.TYPECODE_MULTILINESTRING||this.getTypeCode()===e.TYPECODE_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[x,b,_]}},{key:"getClass",value:function(){return e}}],[{key:"hasNonEmptyElements",value:function(t){for(var e=0;e<t.length;e++)if(!t[e].isEmpty())return!0;return!1}},{key:"hasNullElements",value:function(t){for(var e=0;e<t.length;e++)if(null===t[e])return!0;return!1}}]),e}();L.constructor_=function(t){t&&(this.vu=null,this.yu=null,this.pu=t,this.mu=t.getSRID())},L.TYPECODE_POINT=0,L.TYPECODE_MULTIPOINT=1,L.TYPECODE_LINESTRING=2,L.TYPECODE_LINEARRING=3,L.TYPECODE_MULTILINESTRING=4,L.TYPECODE_POLYGON=5,L.TYPECODE_MULTIPOLYGON=6,L.TYPECODE_GEOMETRYCOLLECTION=7,L.TYPENAME_POINT="Point",L.TYPENAME_MULTIPOINT="MultiPoint",L.TYPENAME_LINESTRING="LineString",L.TYPENAME_LINEARRING="LinearRing",L.TYPENAME_MULTILINESTRING="MultiLineString",L.TYPENAME_POLYGON="Polygon",L.TYPENAME_MULTIPOLYGON="MultiPolygon",L.TYPENAME_GEOMETRYCOLLECTION="GeometryCollection",L.geometryChangedFilter={get interfaces_(){return[g]},filter:function(t){t.geometryChangedAction()}};var H=function(){function e(){t(this,e)}return n(e,null,[{key:"toLocationSymbol",value:function(t){switch(t){case e.EXTERIOR:return"e";case e.BOUNDARY:return"b";case e.INTERIOR:return"i";case e.NONE:return"-"}throw new w("Unknown location value: "+t)}}]),e}();H.INTERIOR=0,H.BOUNDARY=1,H.EXTERIOR=2,H.NONE=-1;var V=function(){function e(){t(this,e)}return n(e,[{key:"add",value:function(){}},{key:"addAll",value:function(){}},{key:"isEmpty",value:function(){}},{key:"iterator",value:function(){}},{key:"size",value:function(){}},{key:"toArray",value:function(){}},{key:"remove",value:function(){}}]),e}(),W=function(e){i(r,e);var n=l(r);function r(e){var i;return t(this,r),(i=n.call(this,e)).name=Object.keys({NoSuchElementException:r})[0],i}return r}(m),G=function(e){i(r,e);var n=l(r);function r(e){var i;return t(this,r),(i=n.call(this,e)).name=Object.keys({UnsupportedOperationException:r})[0],i}return r}(m),Q=function(e){i(s,e);var r=l(s);function s(){return t(this,s),r.apply(this,arguments)}return n(s,[{key:"contains",value:function(){}}]),s}(V),K=function(e,r){i(o,e);var s=l(o);function o(e){var n;return t(this,o),(n=s.call(this)).map=new Map,e instanceof V&&n.addAll(e),n}return n(o,[{key:"contains",value:function(t){var e=t.hashCode?t.hashCode():t;return!!this.map.has(e)}},{key:"add",value:function(t){var e=t.hashCode?t.hashCode():t;return!this.map.has(e)&&!!this.map.set(e,t)}},{key:"addAll",value:function(t){var e,n=v(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.add(i)}}catch(t){n.e(t)}finally{n.f()}return!0}},{key:"remove",value:function(){throw new G}},{key:"size",value:function(){return this.map.size}},{key:"isEmpty",value:function(){return 0===this.map.size}},{key:"toArray",value:function(){return Array.from(this.map.values())}},{key:"iterator",value:function(){return new X(this.map)}},{key:r,value:function(){return this.map}}]),o}(Q,Symbol.iterator),X=function(){function e(n){t(this,e),this.iterator=n.values();var i=this.iterator.next(),r=i.done,s=i.value;this.done=r,this.value=s}return n(e,[{key:"next",value:function(){if(this.done)throw new W;var t=this.value,e=this.iterator.next(),n=e.done,i=e.value;return this.done=n,this.value=i,t}},{key:"hasNext",value:function(){return!this.done}},{key:"remove",value:function(){throw new G}}]),e}(),Z=function(){function e(){t(this,e)}return n(e,null,[{key:"opposite",value:function(t){return t===e.LEFT?e.RIGHT:t===e.RIGHT?e.LEFT:t}}]),e}();Z.ON=0,Z.LEFT=1,Z.RIGHT=2;var Y=function(e){i(r,e);var n=l(r);function r(e){var i;return t(this,r),(i=n.call(this,e)).name=Object.keys({EmptyStackException:r})[0],i}return r}(m),J=function(e){i(r,e);var n=l(r);function r(e){var i;return t(this,r),(i=n.call(this,e)).name=Object.keys({IndexOutOfBoundsException:r})[0],i}return r}(m),tt=function(e){i(s,e);var r=l(s);function s(){return t(this,s),r.apply(this,arguments)}return n(s,[{key:"get",value:function(){}},{key:"set",value:function(){}},{key:"isEmpty",value:function(){}}]),s}(V),et=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),(e=r.call(this)).array=[],e}return n(s,[{key:"add",value:function(t){return this.array.push(t),!0}},{key:"get",value:function(t){if(t<0||t>=this.size())throw new J;return this.array[t]}},{key:"push",value:function(t){return this.array.push(t),t}},{key:"pop",value:function(){if(0===this.array.length)throw new Y;return this.array.pop()}},{key:"peek",value:function(){if(0===this.array.length)throw new Y;return this.array[this.array.length-1]}},{key:"empty",value:function(){return 0===this.array.length}},{key:"isEmpty",value:function(){return this.empty()}},{key:"search",value:function(t){return this.array.indexOf(t)}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}}]),s}(tt);function nt(t,e){return t.interfaces_&&t.interfaces_.indexOf(e)>-1}var it=function(){function e(n){t(this,e),this.str=n}return n(e,[{key:"append",value:function(t){this.str+=t}},{key:"setCharAt",value:function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)}},{key:"toString",value:function(){return this.str}}]),e}(),rt=function(){function e(n){t(this,e),this.value=n}return n(e,[{key:"intValue",value:function(){return this.value}},{key:"compareTo",value:function(t){return this.value<t?-1:this.value>t?1:0}}],[{key:"compare",value:function(t,e){return t<e?-1:t>e?1:0}},{key:"isNan",value:function(t){return Number.isNaN(t)}},{key:"valueOf",value:function(t){return new e(t)}}]),e}(),st=function(){function e(){t(this,e)}return n(e,null,[{key:"isWhitespace",value:function(t){return t<=32&&t>=0||127===t}},{key:"toUpperCase",value:function(t){return t.toUpperCase()}}]),e}(),ot=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"le",value:function(t){return this.wu<t.wu||this.wu===t.wu&&this.gu<=t.gu}},{key:"extractSignificantDigits",value:function(t,n){var i=this.abs(),r=e.magnitude(i.wu),s=e.TEN.pow(r);(i=i.divide(s)).gt(e.TEN)?(i=i.divide(e.TEN),r+=1):i.lt(e.ONE)&&(i=i.multiply(e.TEN),r-=1);for(var o=r+1,a=new it,u=e.MAX_PRINT_DIGITS-1,h=0;h<=u;h++){t&&h===o&&a.append(".");var l=Math.trunc(i.wu);if(l<0)break;var c=!1,f=0;l>9?(c=!0,f="9"):f="0"+l,a.append(f),i=i.subtract(e.valueOf(l)).multiply(e.TEN),c&&i.selfAdd(e.TEN);var d=!0,p=e.magnitude(i.wu);if(p<0&&Math.abs(p)>=u-h&&(d=!1),!d)break}return n[0]=r,a.toString()}},{key:"sqr",value:function(){return this.multiply(this)}},{key:"doubleValue",value:function(){return this.wu+this.gu}},{key:"subtract",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return this.add(t.negate())}if("number"==typeof arguments[0]){var n=arguments[0];return this.add(-n)}}},{key:"equals",value:function(){if(1===arguments.length&&arguments[0]instanceof e){var t=arguments[0];return this.wu===t.wu&&this.gu===t.gu}}},{key:"isZero",value:function(){return 0===this.wu&&0===this.gu}},{key:"selfSubtract",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t.wu,-t.gu)}if("number"==typeof arguments[0]){var n=arguments[0];return this.isNaN()?this:this.selfAdd(-n,0)}}},{key:"getSpecialNumberString",value:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}},{key:"min",value:function(t){return this.le(t)?this:t}},{key:"selfDivide",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.selfDivide(t.wu,t.gu)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfDivide(n,0)}}else if(2===arguments.length){var i,r,s,o,a=arguments[0],u=arguments[1],h=null,l=null,c=null,f=null;return s=this.wu/a,f=(h=(c=e.SPLIT*s)-(h=c-s))*(l=(f=e.SPLIT*a)-(l=f-a))-(o=s*a)+h*(r=a-l)+(i=s-h)*l+i*r,f=s+(c=(this.wu-o-f+this.gu-s*u)/a),this.wu=f,this.gu=s-f+c,this}}},{key:"dump",value:function(){return"DD<"+this.wu+", "+this.gu+">"}},{key:"divide",value:function(){if(arguments[0]instanceof e){var t,n,i,r,s=arguments[0],o=null,a=null,u=null,h=null;return t=(i=this.wu/s.wu)-(o=(u=e.SPLIT*i)-(o=u-i)),h=o*(a=(h=e.SPLIT*s.wu)-(a=h-s.wu))-(r=i*s.wu)+o*(n=s.wu-a)+t*a+t*n,new e(h=i+(u=(this.wu-r-h+this.gu-i*s.gu)/s.wu),i-h+u)}if("number"==typeof arguments[0]){var l=arguments[0];return T.isNaN(l)?e.createNaN():e.copy(this).selfDivide(l,0)}}},{key:"ge",value:function(t){return this.wu>t.wu||this.wu===t.wu&&this.gu>=t.gu}},{key:"pow",value:function(t){if(0===t)return e.valueOf(1);var n=new e(this),i=e.valueOf(1),r=Math.abs(t);if(r>1)for(;r>0;)r%2==1&&i.selfMultiply(n),(r/=2)>0&&(n=n.sqr());else i=n;return t<0?i.reciprocal():i}},{key:"ceil",value:function(){if(this.isNaN())return e.NaN;var t=Math.ceil(this.wu),n=0;return t===this.wu&&(n=Math.ceil(this.gu)),new e(t,n)}},{key:"compareTo",value:function(t){var e=t;return this.wu<e.wu?-1:this.wu>e.wu?1:this.gu<e.gu?-1:this.gu>e.gu?1:0}},{key:"rint",value:function(){return this.isNaN()?this:this.add(.5).floor()}},{key:"setValue",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return this.init(t),this}if("number"==typeof arguments[0]){var n=arguments[0];return this.init(n),this}}},{key:"max",value:function(t){return this.ge(t)?this:t}},{key:"sqrt",value:function(){if(this.isZero())return e.valueOf(0);if(this.isNegative())return e.NaN;var t=1/Math.sqrt(this.wu),n=this.wu*t,i=e.valueOf(n),r=.5*this.subtract(i.sqr()).wu*t;return i.add(r)}},{key:"selfAdd",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.selfAdd(t.wu,t.gu)}if("number"==typeof arguments[0]){var n,i,r,s,o,a=arguments[0],u=null;return u=(r=this.wu+a)-(s=r-this.wu),i=(o=(u=a-s+(this.wu-u))+this.gu)+(r-(n=r+o)),this.wu=n+i,this.gu=i+(n-this.wu),this}}else if(2===arguments.length){var h,l,c,f,d=arguments[0],p=arguments[1],v=null,y=null,m=null;c=this.wu+d,l=this.gu+p,y=c-(m=c-this.wu),v=l-(f=l-this.gu);var w=(h=c+(m=(y=d-m+(this.wu-y))+l))+(m=(v=p-f+(this.gu-v))+(m+(c-h))),g=m+(h-w);return this.wu=w,this.gu=g,this}}},{key:"selfMultiply",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.selfMultiply(t.wu,t.gu)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfMultiply(n,0)}}else if(2===arguments.length){var i,r,s=arguments[0],o=arguments[1],a=null,u=null,h=null,l=null;a=(h=e.SPLIT*this.wu)-this.wu,l=e.SPLIT*s,a=h-a,i=this.wu-a,u=l-s;var c=(h=this.wu*s)+(l=a*(u=l-u)-h+a*(r=s-u)+i*u+i*r+this.wu*o+this.gu*s),f=l+(a=h-c);return this.wu=c,this.gu=f,this}}},{key:"selfSqr",value:function(){return this.selfMultiply(this)}},{key:"floor",value:function(){if(this.isNaN())return e.NaN;var t=Math.floor(this.wu),n=0;return t===this.wu&&(n=Math.floor(this.gu)),new e(t,n)}},{key:"negate",value:function(){return this.isNaN()?this:new e(-this.wu,-this.gu)}},{key:"clone",value:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return null;throw t}}},{key:"multiply",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return t.isNaN()?e.createNaN():e.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){var n=arguments[0];return T.isNaN(n)?e.createNaN():e.copy(this).selfMultiply(n,0)}}},{key:"isNaN",value:function(){return T.isNaN(this.wu)}},{key:"intValue",value:function(){return Math.trunc(this.wu)}},{key:"toString",value:function(){var t=e.magnitude(this.wu);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()}},{key:"toStandardNotation",value:function(){var t=this.getSpecialNumberString();if(null!==t)return t;var n=new Array(1).fill(null),i=this.extractSignificantDigits(!0,n),r=n[0]+1,s=i;if("."===i.charAt(0))s="0"+i;else if(r<0)s="0."+e.stringOfChar("0",-r)+i;else if(-1===i.indexOf(".")){var o=r-i.length;s=i+e.stringOfChar("0",o)+".0"}return this.isNegative()?"-"+s:s}},{key:"reciprocal",value:function(){var t,n,i,r,s=null,o=null,a=null,u=null;t=(i=1/this.wu)-(s=(a=e.SPLIT*i)-(s=a-i)),o=(u=e.SPLIT*this.wu)-this.wu;var h=i+(a=(1-(r=i*this.wu)-(u=s*(o=u-o)-r+s*(n=this.wu-o)+t*o+t*n)-i*this.gu)/this.wu);return new e(h,i-h+a)}},{key:"toSciNotation",value:function(){if(this.isZero())return e.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var n=new Array(1).fill(null),i=this.extractSignificantDigits(!1,n),r=e.SCI_NOT_EXPONENT_CHAR+n[0];if("0"===i.charAt(0))throw new IllegalStateException("Found leading zero: "+i);var s="";i.length>1&&(s=i.substring(1));var o=i.charAt(0)+"."+s;return this.isNegative()?"-"+o+r:o+r}},{key:"abs",value:function(){return this.isNaN()?e.NaN:this.isNegative()?this.negate():new e(this)}},{key:"isPositive",value:function(){return this.wu>0||0===this.wu&&this.gu>0}},{key:"lt",value:function(t){return this.wu<t.wu||this.wu===t.wu&&this.gu<t.gu}},{key:"add",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return e.copy(this).selfAdd(t)}if("number"==typeof arguments[0]){var n=arguments[0];return e.copy(this).selfAdd(n)}}},{key:"init",value:function(){if(1===arguments.length){if("number"==typeof arguments[0]){var t=arguments[0];this.wu=t,this.gu=0}else if(arguments[0]instanceof e){var n=arguments[0];this.wu=n.wu,this.gu=n.gu}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.wu=i,this.gu=r}}},{key:"gt",value:function(t){return this.wu>t.wu||this.wu===t.wu&&this.gu>t.gu}},{key:"isNegative",value:function(){return this.wu<0||0===this.wu&&this.gu<0}},{key:"trunc",value:function(){return this.isNaN()?e.NaN:this.isPositive()?this.floor():this.ceil()}},{key:"signum",value:function(){return this.wu>0?1:this.wu<0?-1:this.gu>0?1:this.gu<0?-1:0}},{key:"interfaces_",get:function(){return[_,b,x]}}],[{key:"constructor_",value:function(){if(this.wu=0,this.gu=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var t=arguments[0];this.init(t)}else if(arguments[0]instanceof e){var n=arguments[0];this.init(n)}else if("string"==typeof arguments[0]){var i=arguments[0];e.constructor_.call(this,e.parse(i))}}else if(2===arguments.length){var r=arguments[0],s=arguments[1];this.init(r,s)}}},{key:"determinant",value:function(){if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],n=arguments[1],i=arguments[2],r=arguments[3];return e.determinant(e.valueOf(t),e.valueOf(n),e.valueOf(i),e.valueOf(r))}if(arguments[3]instanceof e&&arguments[2]instanceof e&&arguments[0]instanceof e&&arguments[1]instanceof e){var s=arguments[1],o=arguments[2],a=arguments[3];return arguments[0].multiply(a).selfSubtract(s.multiply(o))}}},{key:"sqr",value:function(t){return e.valueOf(t).selfMultiply(t)}},{key:"valueOf",value:function(){if("string"==typeof arguments[0]){var t=arguments[0];return e.parse(t)}if("number"==typeof arguments[0])return new e(arguments[0])}},{key:"sqrt",value:function(t){return e.valueOf(t).sqrt()}},{key:"parse",value:function(t){for(var n=0,i=t.length;st.isWhitespace(t.charAt(n));)n++;var r=!1;if(n<i){var s=t.charAt(n);"-"!==s&&"+"!==s||(n++,"-"===s&&(r=!0))}for(var o=new e,a=0,u=0,h=0,l=!1;!(n>=i);){var c=t.charAt(n);if(n++,st.isDigit(c)){var f=c-"0";o.selfMultiply(e.TEN),o.selfAdd(f),a++}else{if("."!==c){if("e"===c||"E"===c){var d=t.substring(n);try{h=rt.parseInt(d)}catch(e){throw e instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+d+" in string "+t):e}break}throw new NumberFormatException("Unexpected character '"+c+"' at position "+n+" in string "+t)}u=a,l=!0}}var p=o;l||(u=a);var v=a-u-h;if(0===v)p=o;else if(v>0){var y=e.TEN.pow(v);p=o.divide(y)}else if(v<0){var m=e.TEN.pow(-v);p=o.multiply(m)}return r?p.negate():p}},{key:"createNaN",value:function(){return new e(T.NaN,T.NaN)}},{key:"copy",value:function(t){return new e(t)}},{key:"magnitude",value:function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),i=Math.trunc(Math.floor(n));return 10*Math.pow(10,i)<=e&&(i+=1),i}},{key:"stringOfChar",value:function(t,e){for(var n=new it,i=0;i<e;i++)n.append(t);return n.toString()}}]),e}();ot.PI=new ot(3.141592653589793,12246467991473532e-32),ot.TWO_PI=new ot(6.283185307179586,24492935982947064e-32),ot.PI_2=new ot(1.5707963267948966,6123233995736766e-32),ot.E=new ot(2.718281828459045,14456468917292502e-32),ot.NaN=new ot(T.NaN,T.NaN),ot.EPS=123259516440783e-46,ot.SPLIT=134217729,ot.MAX_PRINT_DIGITS=32,ot.TEN=ot.valueOf(10),ot.ONE=ot.valueOf(1),ot.SCI_NOT_EXPONENT_CHAR="E",ot.SCI_NOT_ZERO="0.0E0";var at=function(){function e(){t(this,e)}return n(e,null,[{key:"orientationIndex",value:function(t,n,i){var r=e.orientationIndexFilter(t,n,i);if(r<=1)return r;var s=ot.valueOf(n.x).selfAdd(-t.x),o=ot.valueOf(n.y).selfAdd(-t.y),a=ot.valueOf(i.x).selfAdd(-n.x),u=ot.valueOf(i.y).selfAdd(-n.y);return s.selfMultiply(u).selfSubtract(o.selfMultiply(a)).signum()}},{key:"signOfDet2x2",value:function(){if(arguments[3]instanceof ot&&arguments[2]instanceof ot&&arguments[0]instanceof ot&&arguments[1]instanceof ot){var t=arguments[1],e=arguments[2],n=arguments[3];return arguments[0].multiply(n).selfSubtract(t.multiply(e)).signum()}if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var i=arguments[0],r=arguments[1],s=arguments[2],o=arguments[3],a=ot.valueOf(i),u=ot.valueOf(r),h=ot.valueOf(s),l=ot.valueOf(o);return a.multiply(l).selfSubtract(u.multiply(h)).signum()}}},{key:"intersection",value:function(t,e,n,i){var r=new ot(t.y).selfSubtract(e.y),s=new ot(e.x).selfSubtract(t.x),o=new ot(t.x).selfMultiply(e.y).selfSubtract(new ot(e.x).selfMultiply(t.y)),a=new ot(n.y).selfSubtract(i.y),u=new ot(i.x).selfSubtract(n.x),h=new ot(n.x).selfMultiply(i.y).selfSubtract(new ot(i.x).selfMultiply(n.y)),l=s.multiply(h).selfSubtract(u.multiply(o)),c=a.multiply(o).selfSubtract(r.multiply(h)),f=r.multiply(u).selfSubtract(a.multiply(s)),d=l.selfDivide(f).doubleValue(),p=c.selfDivide(f).doubleValue();return T.isNaN(d)||T.isInfinite(d)||T.isNaN(p)||T.isInfinite(p)?null:new q(d,p)}},{key:"orientationIndexFilter",value:function(t,n,i){var r=null,s=(t.x-i.x)*(n.y-i.y),o=(t.y-i.y)*(n.x-i.x),a=s-o;if(s>0){if(o<=0)return e.signum(a);r=s+o}else{if(!(s<0))return e.signum(a);if(o>=0)return e.signum(a);r=-s-o}var u=e.DP_SAFE_EPSILON*r;return a>=u||-a>=u?e.signum(a):2}},{key:"signum",value:function(t){return t>0?1:t<0?-1:0}}]),e}();at.DP_SAFE_EPSILON=1e-15;var ut=function(){function e(){t(this,e)}return n(e,[{key:"getM",value:function(t){if(this.hasM()){var e=this.getDimension()-this.getMeasures();return this.getOrdinate(t,e)}return T.NaN}},{key:"setOrdinate",value:function(t,e,n){}},{key:"getZ",value:function(t){return this.hasZ()?this.getOrdinate(t,2):T.NaN}},{key:"size",value:function(){}},{key:"getOrdinate",value:function(t,e){}},{key:"getCoordinate",value:function(){}},{key:"getCoordinateCopy",value:function(t){}},{key:"createCoordinate",value:function(){}},{key:"getDimension",value:function(){}},{key:"hasM",value:function(){return this.getMeasures()>0}},{key:"getX",value:function(t){}},{key:"hasZ",value:function(){return this.getDimension()-this.getMeasures()>2}},{key:"getMeasures",value:function(){return 0}},{key:"expandEnvelope",value:function(t){}},{key:"copy",value:function(){}},{key:"getY",value:function(t){}},{key:"toCoordinateArray",value:function(){}},{key:"interfaces_",get:function(){return[x]}}]),e}();ut.X=0,ut.Y=1,ut.Z=2,ut.M=3;var ht=function(){function e(){t(this,e)}return n(e,null,[{key:"index",value:function(t,e,n){return at.orientationIndex(t,e,n)}},{key:"isCCW",value:function(){if(arguments[0]instanceof Array){var t=arguments[0],n=t.length-1;if(n<3)throw new w("Ring has fewer than 4 points, so orientation cannot be determined");for(var i=t[0],r=0,s=1;s<=n;s++){var o=t[s];o.y>i.y&&(i=o,r=s)}var a=r;do{(a-=1)<0&&(a=n)}while(t[a].equals2D(i)&&a!==r);var u=r;do{u=(u+1)%n}while(t[u].equals2D(i)&&u!==r);var h=t[a],l=t[u];if(h.equals2D(i)||l.equals2D(i)||h.equals2D(l))return!1;var c=e.index(h,i,l);return 0===c?h.x>l.x:c>0}if(nt(arguments[0],ut)){var f=arguments[0],d=f.size()-1;if(d<3)throw new w("Ring has fewer than 4 points, so orientation cannot be determined");for(var p=f.getCoordinate(0),v=0,y=1;y<=d;y++){var m=f.getCoordinate(y);m.y>p.y&&(p=m,v=y)}var g=null,b=v;do{(b-=1)<0&&(b=d),g=f.getCoordinate(b)}while(g.equals2D(p)&&b!==v);var x=null,_=v;do{_=(_+1)%d,x=f.getCoordinate(_)}while(x.equals2D(p)&&_!==v);if(g.equals2D(p)||x.equals2D(p)||g.equals2D(x))return!1;var k=e.index(g,p,x);return 0===k?g.x>x.x:k>0}}}]),e}();ht.CLOCKWISE=-1,ht.RIGHT=ht.CLOCKWISE,ht.COUNTERCLOCKWISE=1,ht.LEFT=ht.COUNTERCLOCKWISE,ht.COLLINEAR=0,ht.STRAIGHT=ht.COLLINEAR;var lt=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getCoordinate",value:function(){return this.bu}},{key:"getRightmostSide",value:function(t,e){var n=this.getRightmostSideOfSegment(t,e);return n<0&&(n=this.getRightmostSideOfSegment(t,e-1)),n<0&&(this.bu=null,this.checkForRightmostCoordinate(t)),n}},{key:"findRightmostEdgeAtVertex",value:function(){var t=this.xu.getEdge().getCoordinates();R.isTrue(this._u>0&&this._u<t.length,"rightmost point expected to be interior vertex of edge");var e=t[this._u-1],n=t[this._u+1],i=ht.index(this.bu,n,e),r=!1;(e.y<this.bu.y&&n.y<this.bu.y&&i===ht.COUNTERCLOCKWISE||e.y>this.bu.y&&n.y>this.bu.y&&i===ht.CLOCKWISE)&&(r=!0),r&&(this._u=this._u-1)}},{key:"getRightmostSideOfSegment",value:function(t,e){var n=t.getEdge().getCoordinates();if(e<0||e+1>=n.length)return-1;if(n[e].y===n[e+1].y)return-1;var i=Z.LEFT;return n[e].y<n[e+1].y&&(i=Z.RIGHT),i}},{key:"getEdge",value:function(){return this.ku}},{key:"checkForRightmostCoordinate",value:function(t){for(var e=t.getEdge().getCoordinates(),n=0;n<e.length-1;n++)(null===this.bu||e[n].x>this.bu.x)&&(this.xu=t,this._u=n,this.bu=e[n])}},{key:"findRightmostEdgeAtNode",value:function(){var t=this.xu.getNode().getEdges();this.xu=t.getRightmostEdge(),this.xu.isForward()||(this.xu=this.xu.getSym(),this._u=this.xu.getEdge().getCoordinates().length-1)}},{key:"findEdge",value:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}R.isTrue(0!==this._u||this.bu.equals(this.xu.getCoordinate()),"inconsistency in rightmost processing"),0===this._u?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this.ku=this.xu,this.getRightmostSide(this.xu,this._u)===Z.LEFT&&(this.ku=this.xu.getSym())}}],[{key:"constructor_",value:function(){this._u=-1,this.bu=null,this.xu=null,this.ku=null}}]),e}(),ct=function(e){i(s,e);var r=l(s);function s(e,n){var i;return t(this,s),(i=r.call(this,n?e+" [ "+n+" ]":e)).pt=n?new q(n):void 0,i.name=Object.keys({TopologyException:s})[0],i}return n(s,[{key:"getCoordinate",value:function(){return this.pt}}]),s}(D),ft=function(){function e(){t(this,e),this.array=[]}return n(e,[{key:"addLast",value:function(t){this.array.push(t)}},{key:"removeFirst",value:function(){return this.array.shift()}},{key:"isEmpty",value:function(){return 0===this.array.length}}]),e}(),dt=function(e,r){i(o,e);var s=l(o);function o(e){var n;return t(this,o),(n=s.call(this)).array=[],e instanceof V&&n.addAll(e),n}return n(o,[{key:"interfaces_",get:function(){return[tt,V]}},{key:"ensureCapacity",value:function(){}},{key:"add",value:function(t){return 1===arguments.length?this.array.push(t):this.array.splice(arguments[0],0,arguments[1]),!0}},{key:"clear",value:function(){this.array=[]}},{key:"addAll",value:function(t){var e,n=v(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.array.push(i)}}catch(t){n.e(t)}finally{n.f()}}},{key:"set",value:function(t,e){var n=this.array[t];return this.array[t]=e,n}},{key:"iterator",value:function(){return new pt(this)}},{key:"get",value:function(t){if(t<0||t>=this.size())throw new J;return this.array[t]}},{key:"isEmpty",value:function(){return 0===this.array.length}},{key:"sort",value:function(t){t?this.array.sort((function(e,n){return t.compare(e,n)})):this.array.sort()}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"remove",value:function(t){for(var e=0,n=this.array.length;e<n;e++)if(this.array[e]===t)return!!this.array.splice(e,1);return!1}},{key:r,value:function(){return this.array.values()}}]),o}(tt,Symbol.iterator),pt=function(){function e(n){t(this,e),this.arrayList=n,this.position=0}return n(e,[{key:"next",value:function(){if(this.position===this.arrayList.size())throw new W;return this.arrayList.get(this.position++)}},{key:"hasNext",value:function(){return this.position<this.arrayList.size()}},{key:"set",value:function(t){return this.arrayList.set(this.position-1,t)}},{key:"remove",value:function(){this.arrayList.remove(this.arrayList.get(this.position))}}]),e}(),vt=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"clearVisitedEdges",value:function(){for(var t=this.$u.iterator();t.hasNext();)t.next().setVisited(!1)}},{key:"getRightmostCoordinate",value:function(){return this.Su}},{key:"computeNodeDepth",value:function(t){for(var e=null,n=t.getEdges().iterator();n.hasNext();){var i=n.next();if(i.isVisited()||i.getSym().isVisited()){e=i;break}}if(null===e)throw new ct("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(var r=t.getEdges().iterator();r.hasNext();){var s=r.next();s.setVisited(!0),this.copySymDepths(s)}}},{key:"computeDepth",value:function(t){this.clearVisitedEdges();var e=this.Mu.getEdge();e.getNode(),e.getLabel(),e.setEdgeDepths(Z.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)}},{key:"create",value:function(t){this.addReachable(t),this.Mu.findEdge(this.$u),this.Su=this.Mu.getCoordinate()}},{key:"findResultEdges",value:function(){for(var t=this.$u.iterator();t.hasNext();){var e=t.next();e.getDepth(Z.RIGHT)>=1&&e.getDepth(Z.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}}},{key:"computeDepths",value:function(t){var e=new K,n=new ft,i=t.getNode();for(n.addLast(i),e.add(i),t.setVisited(!0);!n.isEmpty();){var r=n.removeFirst();e.add(r),this.computeNodeDepth(r);for(var s=r.getEdges().iterator();s.hasNext();){var o=s.next().getSym();if(!o.isVisited()){var a=o.getNode();e.contains(a)||(n.addLast(a),e.add(a))}}}}},{key:"compareTo",value:function(t){var e=t;return this.Su.x<e.Su.x?-1:this.Su.x>e.Su.x?1:0}},{key:"getEnvelope",value:function(){if(null===this.Eu){for(var t=new B,e=this.$u.iterator();e.hasNext();)for(var n=e.next().getEdge().getCoordinates(),i=0;i<n.length-1;i++)t.expandToInclude(n[i]);this.Eu=t}return this.Eu}},{key:"addReachable",value:function(t){var e=new et;for(e.add(t);!e.empty();){var n=e.pop();this.add(n,e)}}},{key:"copySymDepths",value:function(t){var e=t.getSym();e.setDepth(Z.LEFT,t.getDepth(Z.RIGHT)),e.setDepth(Z.RIGHT,t.getDepth(Z.LEFT))}},{key:"add",value:function(t,e){t.setVisited(!0),this.Cu.add(t);for(var n=t.getEdges().iterator();n.hasNext();){var i=n.next();this.$u.add(i);var r=i.getSym().getNode();r.isVisited()||e.push(r)}}},{key:"getNodes",value:function(){return this.Cu}},{key:"getDirectedEdges",value:function(){return this.$u}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this.Mu=null,this.$u=new dt,this.Cu=new dt,this.Su=null,this.Eu=null,this.Mu=new lt}}]),e}(),yt=function(){function e(){t(this,e)}return n(e,null,[{key:"intersection",value:function(t,e,n,i){var r=t.x<e.x?t.x:e.x,s=t.y<e.y?t.y:e.y,o=t.x>e.x?t.x:e.x,a=t.y>e.y?t.y:e.y,u=n.x<i.x?n.x:i.x,h=n.y<i.y?n.y:i.y,l=n.x>i.x?n.x:i.x,c=n.y>i.y?n.y:i.y,f=((r>u?r:u)+(o<l?o:l))/2,d=((s>h?s:h)+(a<c?a:c))/2,p=t.x-f,v=t.y-d,y=e.x-f,m=e.y-d,w=n.x-f,g=n.y-d,b=i.x-f,x=i.y-d,_=v-m,k=y-p,$=p*m-y*v,S=g-x,M=b-w,E=w*x-b*g,C=_*M-S*k,A=(k*E-M*$)/C,I=(S*$-_*E)/C;return T.isNaN(A)||T.isInfinite(A)||T.isNaN(I)||T.isInfinite(I)?null:new q(A+f,I+d)}}]),e}(),mt=function(){function e(){t(this,e)}return n(e,null,[{key:"arraycopy",value:function(t,e,n,i,r){for(var s=0,o=e;o<e+r;o++)n[i+s]=t[o],s++}},{key:"getProperty",value:function(t){return{"line.separator":"\n"}[t]}}]),e}(),wt=function(){function e(){t(this,e)}return n(e,null,[{key:"log10",value:function(t){var n=Math.log(t);return T.isInfinite(n)||T.isNaN(n)?n:n/e.LOG_10}},{key:"min",value:function(t,e,n,i){var r=t;return e<r&&(r=e),n<r&&(r=n),i<r&&(r=i),r}},{key:"clamp",value:function(){if("number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1],n=arguments[2];return t<e?e:t>n?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var i=arguments[0],r=arguments[1],s=arguments[2];return i<r?r:i>s?s:i}}},{key:"wrap",value:function(t,e){return t<0?e- -t%e:t%e}},{key:"max",value:function(){if(3===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[0];return t>n&&(n=t),e>n&&(n=e),n}if(4===arguments.length){var i=arguments[1],r=arguments[2],s=arguments[3],o=arguments[0];return i>o&&(o=i),r>o&&(o=r),s>o&&(o=s),o}}},{key:"average",value:function(t,e){return(t+e)/2}}]),e}();wt.LOG_10=Math.log(10);var gt=function(){function e(){t(this,e)}return n(e,null,[{key:"segmentToSegment",value:function(t,n,i,r){if(t.equals(n))return e.pointToSegment(t,i,r);if(i.equals(r))return e.pointToSegment(r,t,n);var s=!1;if(B.intersects(t,n,i,r)){var o=(n.x-t.x)*(r.y-i.y)-(n.y-t.y)*(r.x-i.x);if(0===o)s=!0;else{var a=(t.y-i.y)*(r.x-i.x)-(t.x-i.x)*(r.y-i.y),u=((t.y-i.y)*(n.x-t.x)-(t.x-i.x)*(n.y-t.y))/o,h=a/o;(h<0||h>1||u<0||u>1)&&(s=!0)}}else s=!0;return s?wt.min(e.pointToSegment(t,i,r),e.pointToSegment(n,i,r),e.pointToSegment(i,t,n),e.pointToSegment(r,t,n)):0}},{key:"pointToSegment",value:function(t,e,n){if(e.x===n.x&&e.y===n.y)return t.distance(e);var i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),r=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/i;if(r<=0)return t.distance(e);if(r>=1)return t.distance(n);var s=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/i;return Math.abs(s)*Math.sqrt(i)}},{key:"pointToLinePerpendicular",value:function(t,e,n){var i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),r=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/i;return Math.abs(r)*Math.sqrt(i)}},{key:"pointToSegmentString",value:function(t,n){if(0===n.length)throw new w("Line array must contain at least one vertex");for(var i=t.distance(n[0]),r=0;r<n.length-1;r++){var s=e.pointToSegment(t,n[r],n[r+1]);s<i&&(i=s)}return i}}]),e}(),bt=function(){function e(){t(this,e)}return n(e,[{key:"create",value:function(){if(1===arguments.length)arguments[0]instanceof Array||nt(arguments[0],ut);else if(2===arguments.length);else if(3===arguments.length){var t=arguments[0],e=arguments[1];return this.create(t,e)}}}]),e}(),xt=function(){function e(){t(this,e)}return n(e,[{key:"filter",value:function(t){}}]),e}(),_t=function(){function e(){t(this,e)}return n(e,null,[{key:"ofLine",value:function(t){var e=t.size();if(e<=1)return 0;var n=0,i=new q;t.getCoordinate(0,i);for(var r=i.x,s=i.y,o=1;o<e;o++){t.getCoordinate(o,i);var a=i.x,u=i.y,h=a-r,l=u-s;n+=Math.sqrt(h*h+l*l),r=a,s=u}return n}}]),e}(),kt=function e(){t(this,e)},$t=function(){function e(){t(this,e)}return n(e,null,[{key:"copyCoord",value:function(t,e,n,i){for(var r=Math.min(t.getDimension(),n.getDimension()),s=0;s<r;s++)n.setOrdinate(i,s,t.getOrdinate(e,s))}},{key:"isRing",value:function(t){var e=t.size();return 0===e||!(e<=3)&&t.getOrdinate(0,ut.X)===t.getOrdinate(e-1,ut.X)&&t.getOrdinate(0,ut.Y)===t.getOrdinate(e-1,ut.Y)}},{key:"scroll",value:function(){if(2===arguments.length){if(nt(arguments[0],ut)&&Number.isInteger(arguments[1])){var t=arguments[0],n=arguments[1];e.scroll(t,n,e.isRing(t))}else if(nt(arguments[0],ut)&&arguments[1]instanceof q){var i=arguments[0],r=arguments[1],s=e.indexOf(r,i);if(s<=0)return null;e.scroll(i,s)}}else if(3===arguments.length){var o=arguments[0],a=arguments[1],u=arguments[2];if(a<=0)return null;for(var h=o.copy(),l=u?o.size()-1:o.size(),c=0;c<l;c++)for(var f=0;f<o.getDimension();f++)o.setOrdinate(c,f,h.getOrdinate((a+c)%l,f));if(u)for(var d=0;d<o.getDimension();d++)o.setOrdinate(l,d,o.getOrdinate(0,d))}}},{key:"isEqual",value:function(t,e){var n=t.size();if(n!==e.size())return!1;for(var i=Math.min(t.getDimension(),e.getDimension()),r=0;r<n;r++)for(var s=0;s<i;s++){var o=t.getOrdinate(r,s),a=e.getOrdinate(r,s);if(!(t.getOrdinate(r,s)===e.getOrdinate(r,s)||T.isNaN(o)&&T.isNaN(a)))return!1}return!0}},{key:"minCoordinateIndex",value:function(){if(1===arguments.length){var t=arguments[0];return e.minCoordinateIndex(t,0,t.size()-1)}if(3===arguments.length){for(var n=arguments[0],i=arguments[2],r=-1,s=null,o=arguments[1];o<=i;o++){var a=n.getCoordinate(o);(null===s||s.compareTo(a)>0)&&(s=a,r=o)}return r}}},{key:"extend",value:function(t,n,i){var r=t.create(i,n.getDimension()),s=n.size();if(e.copy(n,0,r,0,s),s>0)for(var o=s;o<i;o++)e.copy(n,s-1,r,o,1);return r}},{key:"reverse",value:function(t){for(var n=t.size()-1,i=Math.trunc(n/2),r=0;r<=i;r++)e.swap(t,r,n-r)}},{key:"swap",value:function(t,e,n){if(e===n)return null;for(var i=0;i<t.getDimension();i++){var r=t.getOrdinate(e,i);t.setOrdinate(e,i,t.getOrdinate(n,i)),t.setOrdinate(n,i,r)}}},{key:"copy",value:function(t,n,i,r,s){for(var o=0;o<s;o++)e.copyCoord(t,n+o,i,r+o)}},{key:"ensureValidRing",value:function(t,n){var i=n.size();return 0===i?n:i<=3?e.createClosedRing(t,n,4):n.getOrdinate(0,ut.X)===n.getOrdinate(i-1,ut.X)&&n.getOrdinate(0,ut.Y)===n.getOrdinate(i-1,ut.Y)?n:e.createClosedRing(t,n,i+1)}},{key:"indexOf",value:function(t,e){for(var n=0;n<e.size();n++)if(t.x===e.getOrdinate(n,ut.X)&&t.y===e.getOrdinate(n,ut.Y))return n;return-1}},{key:"createClosedRing",value:function(t,n,i){var r=t.create(i,n.getDimension()),s=n.size();e.copy(n,0,r,0,s);for(var o=s;o<i;o++)e.copy(n,0,r,o,1);return r}},{key:"minCoordinate",value:function(t){for(var e=null,n=0;n<t.size();n++){var i=t.getCoordinate(n);(null===e||e.compareTo(i)>0)&&(e=i)}return e}}]),e}(),St=function(){function e(){t(this,e)}return n(e,null,[{key:"toDimensionSymbol",value:function(t){switch(t){case e.FALSE:return e.SYM_FALSE;case e.TRUE:return e.SYM_TRUE;case e.DONTCARE:return e.SYM_DONTCARE;case e.P:return e.SYM_P;case e.L:return e.SYM_L;case e.A:return e.SYM_A}throw new w("Unknown dimension value: "+t)}},{key:"toDimensionValue",value:function(t){switch(st.toUpperCase(t)){case e.SYM_FALSE:return e.FALSE;case e.SYM_TRUE:return e.TRUE;case e.SYM_DONTCARE:return e.DONTCARE;case e.SYM_P:return e.P;case e.SYM_L:return e.L;case e.SYM_A:return e.A}throw new w("Unknown dimension symbol: "+t)}}]),e}();St.P=0,St.L=1,St.A=2,St.FALSE=-1,St.TRUE=-2,St.DONTCARE=-3,St.SYM_FALSE="F",St.SYM_TRUE="T",St.SYM_DONTCARE="*",St.SYM_P="0",St.SYM_L="1",St.SYM_A="2";var Mt=function(){function e(){t(this,e)}return n(e,[{key:"filter",value:function(t){}}]),e}(),Et=function(){function e(){t(this,e)}return n(e,[{key:"filter",value:function(t,e){}},{key:"isDone",value:function(){}},{key:"isGeometryChanged",value:function(){}}]),e}(),Ct=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"computeEnvelopeInternal",value:function(){return this.isEmpty()?new B:this.Kn.expandEnvelope(new B)}},{key:"isRing",value:function(){return this.isClosed()&&this.isSimple()}},{key:"getCoordinates",value:function(){return this.Kn.toCoordinateArray()}},{key:"copyInternal",value:function(){return new o(this.Kn.copy(),this.pu)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof L){var t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;var n=t;if(this.Kn.size()!==n.Kn.size())return!1;for(var i=0;i<this.Kn.size();i++)if(!this.equal(this.Kn.getCoordinate(i),n.Kn.getCoordinate(i),e))return!1;return!0}return c(r(o.prototype),"equalsExact",this).apply(this,arguments)}},{key:"normalize",value:function(){for(var t=0;t<Math.trunc(this.Kn.size()/2);t++){var e=this.Kn.size()-1-t;if(!this.Kn.getCoordinate(t).equals(this.Kn.getCoordinate(e))){if(this.Kn.getCoordinate(t).compareTo(this.Kn.getCoordinate(e))>0){var n=this.Kn.copy();$t.reverse(n),this.Kn=n}return null}}}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this.Kn.getCoordinate(0)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?St.FALSE:0}},{key:"isClosed",value:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}},{key:"reverseInternal",value:function(){var t=this.Kn.copy();return $t.reverse(t),this.getFactory().createLineString(t)}},{key:"getEndPoint",value:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}},{key:"getTypeCode",value:function(){return L.TYPECODE_LINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getLength",value:function(){return _t.ofLine(this.Kn)}},{key:"getNumPoints",value:function(){return this.Kn.size()}},{key:"compareToSameClass",value:function(){if(1===arguments.length){for(var t=arguments[0],e=0,n=0;e<this.Kn.size()&&n<t.Kn.size();){var i=this.Kn.getCoordinate(e).compareTo(t.Kn.getCoordinate(n));if(0!==i)return i;e++,n++}return e<this.Kn.size()?1:n<t.Kn.size()?-1:0}if(2===arguments.length){var r=arguments[0];return arguments[1].compare(this.Kn,r.Kn)}}},{key:"apply",value:function(){if(nt(arguments[0],xt))for(var t=arguments[0],e=0;e<this.Kn.size();e++)t.filter(this.Kn.getCoordinate(e));else if(nt(arguments[0],Et)){var n=arguments[0];if(0===this.Kn.size())return null;for(var i=0;i<this.Kn.size()&&(n.filter(this.Kn,i),!n.isDone());i++);n.isGeometryChanged()&&this.geometryChanged()}else(nt(arguments[0],Mt)||nt(arguments[0],g))&&arguments[0].filter(this)}},{key:"getBoundary",value:function(){throw new G}},{key:"isEquivalentClass",value:function(t){return t instanceof o}},{key:"getCoordinateN",value:function(t){return this.Kn.getCoordinate(t)}},{key:"getGeometryType",value:function(){return L.TYPENAME_LINESTRING}},{key:"getCoordinateSequence",value:function(){return this.Kn}},{key:"isEmpty",value:function(){return 0===this.Kn.size()}},{key:"init",value:function(t){if(null===t&&(t=this.getFactory().getCoordinateSequenceFactory().create([])),1===t.size())throw new w("Invalid number of points in LineString (found "+t.size()+" - must be 0 or >= 2)");this.Kn=t}},{key:"isCoordinate",value:function(t){for(var e=0;e<this.Kn.size();e++)if(this.Kn.getCoordinate(e).equals(t))return!0;return!1}},{key:"getStartPoint",value:function(){return this.isEmpty()?null:this.getPointN(0)}},{key:"getPointN",value:function(t){return this.getFactory().createPoint(this.Kn.getCoordinate(t))}},{key:"interfaces_",get:function(){return[kt]}}],[{key:"constructor_",value:function(){if(this.Kn=null,0===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];L.constructor_.call(this,e),this.init(t)}}}]),o}(L),At=function e(){t(this,e)},It=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"computeEnvelopeInternal",value:function(){if(this.isEmpty())return new B;var t=new B;return t.expandToInclude(this.Au.getX(0),this.Au.getY(0)),t}},{key:"getCoordinates",value:function(){return this.isEmpty()?[]:[this.getCoordinate()]}},{key:"copyInternal",value:function(){return new o(this.Au.copy(),this.pu)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof L){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&(!(!this.isEmpty()||!t.isEmpty())||this.isEmpty()===t.isEmpty()&&this.equal(t.getCoordinate(),this.getCoordinate(),e))}return c(r(o.prototype),"equalsExact",this).apply(this,arguments)}},{key:"normalize",value:function(){}},{key:"getCoordinate",value:function(){return 0!==this.Au.size()?this.Au.getCoordinate(0):null}},{key:"getBoundaryDimension",value:function(){return St.FALSE}},{key:"reverseInternal",value:function(){return this.getFactory().createPoint(this.Au.copy())}},{key:"getTypeCode",value:function(){return L.TYPECODE_POINT}},{key:"getDimension",value:function(){return 0}},{key:"getNumPoints",value:function(){return this.isEmpty()?0:1}},{key:"getX",value:function(){if(null===this.getCoordinate())throw new IllegalStateException("getX called on empty Point");return this.getCoordinate().x}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var t=arguments[0];return this.getCoordinate().compareTo(t.getCoordinate())}if(2===arguments.length){var e=arguments[0];return arguments[1].compare(this.Au,e.Au)}}},{key:"apply",value:function(){if(nt(arguments[0],xt)){var t=arguments[0];if(this.isEmpty())return null;t.filter(this.getCoordinate())}else if(nt(arguments[0],Et)){var e=arguments[0];if(this.isEmpty())return null;e.filter(this.Au,0),e.isGeometryChanged()&&this.geometryChanged()}else(nt(arguments[0],Mt)||nt(arguments[0],g))&&arguments[0].filter(this)}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return L.TYPENAME_POINT}},{key:"getCoordinateSequence",value:function(){return this.Au}},{key:"getY",value:function(){if(null===this.getCoordinate())throw new IllegalStateException("getY called on empty Point");return this.getCoordinate().y}},{key:"isEmpty",value:function(){return 0===this.Au.size()}},{key:"init",value:function(t){null===t&&(t=this.getFactory().getCoordinateSequenceFactory().create([])),R.isTrue(t.size()<=1),this.Au=t}},{key:"isSimple",value:function(){return!0}},{key:"interfaces_",get:function(){return[At]}}],[{key:"constructor_",value:function(){this.Au=null;var t=arguments[0],e=arguments[1];L.constructor_.call(this,e),this.init(t)}}]),o}(L),Ot=function(){function e(){t(this,e)}return n(e,null,[{key:"ofRing",value:function(){if(arguments[0]instanceof Array){var t=arguments[0];return Math.abs(e.ofRingSigned(t))}if(nt(arguments[0],ut)){var n=arguments[0];return Math.abs(e.ofRingSigned(n))}}},{key:"ofRingSigned",value:function(){if(arguments[0]instanceof Array){var t=arguments[0];if(t.length<3)return 0;for(var e=0,n=t[0].x,i=1;i<t.length-1;i++){var r=t[i].x-n,s=t[i+1].y;e+=r*(t[i-1].y-s)}return e/2}if(nt(arguments[0],ut)){var o=arguments[0],a=o.size();if(a<3)return 0;var u=new q,h=new q,l=new q;o.getCoordinate(0,h),o.getCoordinate(1,l);var c=h.x;l.x-=c;for(var f=0,d=1;d<a-1;d++)u.y=h.y,h.x=l.x,h.y=l.y,o.getCoordinate(d+1,l),l.x-=c,f+=h.x*(u.y-l.y);return f/2}}}]),e}(),Tt=function(){function e(){t(this,e)}return n(e,null,[{key:"sort",value:function(){var t=arguments,e=arguments[0];if(1===arguments.length)e.sort((function(t,e){return t.compareTo(e)}));else if(2===arguments.length)e.sort((function(e,n){return t[1].compare(e,n)}));else if(3===arguments.length){var n=e.slice(arguments[1],arguments[2]);n.sort();var i=e.slice(0,arguments[1]).concat(n,e.slice(arguments[2],e.length));e.splice(0,e.length);var r,s=v(i);try{for(s.s();!(r=s.n()).done;){var o=r.value;e.push(o)}}catch(t){s.e(t)}finally{s.f()}}else if(4===arguments.length){var a=e.slice(arguments[1],arguments[2]);a.sort((function(e,n){return t[3].compare(e,n)}));var u=e.slice(0,arguments[1]).concat(a,e.slice(arguments[2],e.length));e.splice(0,e.length);var h,l=v(u);try{for(l.s();!(h=l.n()).done;){var c=h.value;e.push(c)}}catch(t){l.e(t)}finally{l.f()}}}},{key:"asList",value:function(t){var e,n=new dt,i=v(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;n.add(r)}}catch(t){i.e(t)}finally{i.f()}return n}},{key:"copyOf",value:function(t,e){return t.slice(0,e)}}]),e}(),zt=function e(){t(this,e)},Dt=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"computeEnvelopeInternal",value:function(){return this.Iu.getEnvelopeInternal()}},{key:"getCoordinates",value:function(){if(this.isEmpty())return[];for(var t=new Array(this.getNumPoints()).fill(null),e=-1,n=this.Iu.getCoordinates(),i=0;i<n.length;i++)t[++e]=n[i];for(var r=0;r<this.Ou.length;r++)for(var s=this.Ou[r].getCoordinates(),o=0;o<s.length;o++)t[++e]=s[o];return t}},{key:"getArea",value:function(){var t=0;t+=Ot.ofRing(this.Iu.getCoordinateSequence());for(var e=0;e<this.Ou.length;e++)t-=Ot.ofRing(this.Ou[e].getCoordinateSequence());return t}},{key:"copyInternal",value:function(){for(var t=this.Iu.copy(),e=new Array(this.Ou.length).fill(null),n=0;n<this.Ou.length;n++)e[n]=this.Ou[n].copy();return new o(t,e,this.pu)}},{key:"isRectangle",value:function(){if(0!==this.getNumInteriorRing())return!1;if(null===this.Iu)return!1;if(5!==this.Iu.getNumPoints())return!1;for(var t=this.Iu.getCoordinateSequence(),e=this.getEnvelopeInternal(),n=0;n<5;n++){var i=t.getX(n);if(i!==e.getMinX()&&i!==e.getMaxX())return!1;var r=t.getY(n);if(r!==e.getMinY()&&r!==e.getMaxY())return!1}for(var s=t.getX(0),o=t.getY(0),a=1;a<=4;a++){var u=t.getX(a),h=t.getY(a);if(u!==s==(h!==o))return!1;s=u,o=h}return!0}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof L){var t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;var n=t,i=this.Iu,s=n.Iu;if(!i.equalsExact(s,e))return!1;if(this.Ou.length!==n.Ou.length)return!1;for(var a=0;a<this.Ou.length;a++)if(!this.Ou[a].equalsExact(n.Ou[a],e))return!1;return!0}return c(r(o.prototype),"equalsExact",this).apply(this,arguments)}},{key:"normalize",value:function(){if(0===arguments.length){this.Iu=this.normalized(this.Iu,!0);for(var t=0;t<this.Ou.length;t++)this.Ou[t]=this.normalized(this.Ou[t],!1);Tt.sort(this.Ou)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(e.isEmpty())return null;var i=e.getCoordinateSequence(),r=$t.minCoordinateIndex(i,0,i.size()-2);$t.scroll(i,r,!0),ht.isCCW(i)===n&&$t.reverse(i)}}},{key:"getCoordinate",value:function(){return this.Iu.getCoordinate()}},{key:"getNumInteriorRing",value:function(){return this.Ou.length}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"reverseInternal",value:function(){for(var t=this.getExteriorRing().reverse(),e=new Array(this.getNumInteriorRing()).fill(null),n=0;n<e.length;n++)e[n]=this.getInteriorRingN(n).reverse();return this.getFactory().createPolygon(t,e)}},{key:"getTypeCode",value:function(){return L.TYPECODE_POLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getLength",value:function(){var t=0;t+=this.Iu.getLength();for(var e=0;e<this.Ou.length;e++)t+=this.Ou[e].getLength();return t}},{key:"getNumPoints",value:function(){for(var t=this.Iu.getNumPoints(),e=0;e<this.Ou.length;e++)t+=this.Ou[e].getNumPoints();return t}},{key:"convexHull",value:function(){return this.getExteriorRing().convexHull()}},{key:"normalized",value:function(t,e){var n=t.copy();return this.normalize(n,e),n}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var t=arguments[0],e=this.Iu,n=t.Iu;return e.compareToSameClass(n)}if(2===arguments.length){var i=arguments[1],r=arguments[0],s=this.Iu,o=r.Iu,a=s.compareToSameClass(o,i);if(0!==a)return a;for(var u=this.getNumInteriorRing(),h=r.getNumInteriorRing(),l=0;l<u&&l<h;){var c=this.getInteriorRingN(l),f=r.getInteriorRingN(l),d=c.compareToSameClass(f,i);if(0!==d)return d;l++}return l<u?1:l<h?-1:0}}},{key:"apply",value:function(){if(nt(arguments[0],xt)){var t=arguments[0];this.Iu.apply(t);for(var e=0;e<this.Ou.length;e++)this.Ou[e].apply(t)}else if(nt(arguments[0],Et)){var n=arguments[0];if(this.Iu.apply(n),!n.isDone())for(var i=0;i<this.Ou.length&&(this.Ou[i].apply(n),!n.isDone());i++);n.isGeometryChanged()&&this.geometryChanged()}else if(nt(arguments[0],Mt))arguments[0].filter(this);else if(nt(arguments[0],g)){var r=arguments[0];r.filter(this),this.Iu.apply(r);for(var s=0;s<this.Ou.length;s++)this.Ou[s].apply(r)}}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();var t=new Array(this.Ou.length+1).fill(null);t[0]=this.Iu;for(var e=0;e<this.Ou.length;e++)t[e+1]=this.Ou[e];return t.length<=1?this.getFactory().createLinearRing(t[0].getCoordinateSequence()):this.getFactory().createMultiLineString(t)}},{key:"getGeometryType",value:function(){return L.TYPENAME_POLYGON}},{key:"getExteriorRing",value:function(){return this.Iu}},{key:"isEmpty",value:function(){return this.Iu.isEmpty()}},{key:"getInteriorRingN",value:function(t){return this.Ou[t]}},{key:"interfaces_",get:function(){return[zt]}}],[{key:"constructor_",value:function(){this.Iu=null,this.Ou=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(L.constructor_.call(this,n),null===t&&(t=this.getFactory().createLinearRing()),null===e&&(e=[]),L.hasNullElements(e))throw new w("holes must not contain null elements");if(t.isEmpty()&&L.hasNonEmptyElements(e))throw new w("shell is empty but holes are not");this.Iu=t,this.Ou=e}}]),o}(L),Pt=function(e){i(r,e);var n=l(r);function r(){return t(this,r),n.apply(this,arguments)}return r}(Q),Rt=function(e){i(s,e);var r=l(s);function s(e){var n;return t(this,s),(n=r.call(this)).array=[],e instanceof V&&n.addAll(e),n}return n(s,[{key:"contains",value:function(t){var e,n=v(this.array);try{for(n.s();!(e=n.n()).done;)if(0===e.value.compareTo(t))return!0}catch(t){n.e(t)}finally{n.f()}return!1}},{key:"add",value:function(t){if(this.contains(t))return!1;for(var e=0,n=this.array.length;e<n;e++)if(1===this.array[e].compareTo(t))return!!this.array.splice(e,0,t);return this.array.push(t),!0}},{key:"addAll",value:function(t){var e,n=v(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.add(i)}}catch(t){n.e(t)}finally{n.f()}return!0}},{key:"remove",value:function(){throw new G}},{key:"size",value:function(){return this.array.length}},{key:"isEmpty",value:function(){return 0===this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"iterator",value:function(){return new Nt(this.array)}}]),s}(Pt),Nt=function(){function e(n){t(this,e),this.array=n,this.position=0}return n(e,[{key:"next",value:function(){if(this.position===this.array.length)throw new W;return this.array[this.position++]}},{key:"hasNext",value:function(){return this.position<this.array.length}},{key:"remove",value:function(){throw new G}}]),e}(),Ft=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"computeEnvelopeInternal",value:function(){for(var t=new B,e=0;e<this.Tu.length;e++)t.expandToInclude(this.Tu[e].getEnvelopeInternal());return t}},{key:"getGeometryN",value:function(t){return this.Tu[t]}},{key:"getCoordinates",value:function(){for(var t=new Array(this.getNumPoints()).fill(null),e=-1,n=0;n<this.Tu.length;n++)for(var i=this.Tu[n].getCoordinates(),r=0;r<i.length;r++)t[++e]=i[r];return t}},{key:"getArea",value:function(){for(var t=0,e=0;e<this.Tu.length;e++)t+=this.Tu[e].getArea();return t}},{key:"copyInternal",value:function(){for(var t=new Array(this.Tu.length).fill(null),e=0;e<t.length;e++)t[e]=this.Tu[e].copy();return new o(t,this.pu)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof L){var t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;var n=t;if(this.Tu.length!==n.Tu.length)return!1;for(var i=0;i<this.Tu.length;i++)if(!this.Tu[i].equalsExact(n.Tu[i],e))return!1;return!0}return c(r(o.prototype),"equalsExact",this).apply(this,arguments)}},{key:"normalize",value:function(){for(var t=0;t<this.Tu.length;t++)this.Tu[t].normalize();Tt.sort(this.Tu)}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this.Tu[0].getCoordinate()}},{key:"getBoundaryDimension",value:function(){for(var t=St.FALSE,e=0;e<this.Tu.length;e++)t=Math.max(t,this.Tu[e].getBoundaryDimension());return t}},{key:"reverseInternal",value:function(){for(var t=this.Tu.length,e=new dt(t),n=0;n<t;n++)e.add(this.Tu[n].reverse());return this.getFactory().buildGeometry(e)}},{key:"getTypeCode",value:function(){return L.TYPECODE_GEOMETRYCOLLECTION}},{key:"getDimension",value:function(){for(var t=St.FALSE,e=0;e<this.Tu.length;e++)t=Math.max(t,this.Tu[e].getDimension());return t}},{key:"getLength",value:function(){for(var t=0,e=0;e<this.Tu.length;e++)t+=this.Tu[e].getLength();return t}},{key:"getNumPoints",value:function(){for(var t=0,e=0;e<this.Tu.length;e++)t+=this.Tu[e].getNumPoints();return t}},{key:"getNumGeometries",value:function(){return this.Tu.length}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var t=arguments[0],e=new Rt(Tt.asList(this.Tu)),n=new Rt(Tt.asList(t.Tu));return this.compare(e,n)}if(2===arguments.length){for(var i=arguments[1],r=arguments[0],s=this.getNumGeometries(),o=r.getNumGeometries(),a=0;a<s&&a<o;){var u=this.getGeometryN(a),h=r.getGeometryN(a),l=u.compareToSameClass(h,i);if(0!==l)return l;a++}return a<s?1:a<o?-1:0}}},{key:"apply",value:function(){if(nt(arguments[0],xt))for(var t=arguments[0],e=0;e<this.Tu.length;e++)this.Tu[e].apply(t);else if(nt(arguments[0],Et)){var n=arguments[0];if(0===this.Tu.length)return null;for(var i=0;i<this.Tu.length&&(this.Tu[i].apply(n),!n.isDone());i++);n.isGeometryChanged()&&this.geometryChanged()}else if(nt(arguments[0],Mt)){var r=arguments[0];r.filter(this);for(var s=0;s<this.Tu.length;s++)this.Tu[s].apply(r)}else if(nt(arguments[0],g)){var o=arguments[0];o.filter(this);for(var a=0;a<this.Tu.length;a++)this.Tu[a].apply(o)}}},{key:"getBoundary",value:function(){return L.checkNotGeometryCollection(this),R.shouldNeverReachHere(),null}},{key:"getGeometryType",value:function(){return L.TYPENAME_GEOMETRYCOLLECTION}},{key:"isEmpty",value:function(){for(var t=0;t<this.Tu.length;t++)if(!this.Tu[t].isEmpty())return!1;return!0}}],[{key:"constructor_",value:function(){if(this.Tu=null,0===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];if(L.constructor_.call(this,e),null===t&&(t=[]),L.hasNullElements(t))throw new w("geometries must not contain null elements");this.Tu=t}}}]),o}(L),Ut=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"copyInternal",value:function(){for(var t=new Array(this.Tu.length).fill(null),e=0;e<t.length;e++)t[e]=this.Tu[e].copy();return new o(t,this.pu)}},{key:"isValid",value:function(){return!0}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof L){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&c(r(o.prototype),"equalsExact",this).call(this,t,e)}return c(r(o.prototype),"equalsExact",this).apply(this,arguments)}},{key:"getCoordinate",value:function(){if(1===arguments.length&&Number.isInteger(arguments[0])){var t=arguments[0];return this.Tu[t].getCoordinate()}return c(r(o.prototype),"getCoordinate",this).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return St.FALSE}},{key:"getTypeCode",value:function(){return L.TYPECODE_MULTIPOINT}},{key:"getDimension",value:function(){return 0}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return L.TYPENAME_MULTIPOINT}},{key:"interfaces_",get:function(){return[At]}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Ft.constructor_.call(this,t,e)}}]),o}(Ft),qt=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"copyInternal",value:function(){return new o(this.Kn.copy(),this.pu)}},{key:"getBoundaryDimension",value:function(){return St.FALSE}},{key:"isClosed",value:function(){return!!this.isEmpty()||c(r(o.prototype),"isClosed",this).call(this)}},{key:"reverseInternal",value:function(){var t=this.Kn.copy();return $t.reverse(t),this.getFactory().createLinearRing(t)}},{key:"getTypeCode",value:function(){return L.TYPECODE_LINEARRING}},{key:"validateConstruction",value:function(){if(!this.isEmpty()&&!c(r(o.prototype),"isClosed",this).call(this))throw new w("Points of LinearRing do not form a closed linestring");if(this.getCoordinateSequence().size()>=1&&this.getCoordinateSequence().size()<o.MINIMUM_VALID_SIZE)throw new w("Invalid number of points in LinearRing (found "+this.getCoordinateSequence().size()+" - must be 0 or >= 4)")}},{key:"getGeometryType",value:function(){return L.TYPENAME_LINEARRING}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Ct.constructor_.call(this,t,e),this.validateConstruction()}}]),o}(Ct);qt.MINIMUM_VALID_SIZE=4;var jt=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),e=r.call(this),s.constructor_.apply(h(e),arguments),e}return n(s,[{key:"setOrdinate",value:function(t,e){switch(t){case s.X:this.x=e;break;case s.Y:this.y=e;break;default:throw new w("Invalid ordinate index: "+t)}}},{key:"getZ",value:function(){return q.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case s.X:return this.x;case s.Y:return this.y}throw new w("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new w("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new s(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}}],[{key:"constructor_",value:function(){if(0===arguments.length)q.constructor_.call(this);else if(1===arguments.length){if(arguments[0]instanceof s){var t=arguments[0];q.constructor_.call(this,t.x,t.y)}else if(arguments[0]instanceof q){var e=arguments[0];q.constructor_.call(this,e.x,e.y)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];q.constructor_.call(this,n,i,q.NULL_ORDINATE)}}}]),s}(q);jt.X=0,jt.Y=1,jt.Z=-1,jt.M=-1;var Bt=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),e=r.call(this),s.constructor_.apply(h(e),arguments),e}return n(s,[{key:"getM",value:function(){return this.zu}},{key:"setOrdinate",value:function(t,e){switch(t){case s.X:this.x=e;break;case s.Y:this.y=e;break;case s.M:this.zu=e;break;default:throw new w("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this.zu=t}},{key:"getZ",value:function(){return q.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case s.X:return this.x;case s.Y:return this.y;case s.M:return this.zu}throw new w("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new w("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new s(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this.zu=t.getM()}}],[{key:"constructor_",value:function(){if(this.zu=null,0===arguments.length)q.constructor_.call(this),this.zu=0;else if(1===arguments.length){if(arguments[0]instanceof s){var t=arguments[0];q.constructor_.call(this,t.x,t.y),this.zu=t.zu}else if(arguments[0]instanceof q){var e=arguments[0];q.constructor_.call(this,e.x,e.y),this.zu=this.getM()}}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];q.constructor_.call(this,n,i,q.NULL_ORDINATE),this.zu=r}}}]),s}(q);Bt.X=0,Bt.Y=1,Bt.Z=-1,Bt.M=2;var Lt=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),e=r.call(this),s.constructor_.apply(h(e),arguments),e}return n(s,[{key:"getM",value:function(){return this.zu}},{key:"setOrdinate",value:function(t,e){switch(t){case q.X:this.x=e;break;case q.Y:this.y=e;break;case q.Z:this.z=e;break;case q.M:this.zu=e;break;default:throw new w("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this.zu=t}},{key:"getOrdinate",value:function(t){switch(t){case q.X:return this.x;case q.Y:return this.y;case q.Z:return this.getZ();case q.M:return this.getM()}throw new w("Invalid ordinate index: "+t)}},{key:"copy",value:function(){return new s(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this.zu=t.getM()}}],[{key:"constructor_",value:function(){if(this.zu=null,0===arguments.length)q.constructor_.call(this),this.zu=0;else if(1===arguments.length){if(arguments[0]instanceof s){var t=arguments[0];q.constructor_.call(this,t),this.zu=t.zu}else if(arguments[0]instanceof q){var e=arguments[0];q.constructor_.call(this,e),this.zu=this.getM()}}else if(4===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],o=arguments[3];q.constructor_.call(this,n,i,r),this.zu=o}}}]),s}(q),Ht=function(){function e(){t(this,e)}return n(e,null,[{key:"measures",value:function(t){return t instanceof jt?0:t instanceof Bt||t instanceof Lt?1:0}},{key:"dimension",value:function(t){return t instanceof jt?2:t instanceof Bt?3:t instanceof Lt?4:3}},{key:"create",value:function(){if(1===arguments.length){var t=arguments[0];return e.create(t,0)}if(2===arguments.length){var n=arguments[0],i=arguments[1];return 2===n?new jt:3===n&&0===i?new q:3===n&&1===i?new Bt:4===n&&1===i?new Lt:new q}}}]),e}(),Vt=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"getCoordinate",value:function(t){return this.get(t)}},{key:"addAll",value:function(){if(2===arguments.length&&"boolean"==typeof arguments[1]&&nt(arguments[0],V)){for(var t=arguments[1],e=!1,n=arguments[0].iterator();n.hasNext();)this.add(n.next(),t),e=!0;return e}return c(r(o.prototype),"addAll",this).apply(this,arguments)}},{key:"clone",value:function(){for(var t=c(r(o.prototype),"clone",this).call(this),e=0;e<this.size();e++)t.add(e,this.get(e).clone());return t}},{key:"toCoordinateArray",value:function(){if(0===arguments.length)return this.toArray(o.coordArrayType);if(1===arguments.length){if(arguments[0])return this.toArray(o.coordArrayType);for(var t=this.size(),e=new Array(t).fill(null),n=0;n<t;n++)e[n]=this.get(t-n-1);return e}}},{key:"add",value:function(){if(1===arguments.length){var t=arguments[0];return c(r(o.prototype),"add",this).call(this,t)}if(2===arguments.length){if(arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var e=arguments[0],n=arguments[1];return this.add(e,n,!0),!0}if(arguments[0]instanceof q&&"boolean"==typeof arguments[1]){var i=arguments[0];if(!arguments[1]&&this.size()>=1&&this.get(this.size()-1).equals2D(i))return null;c(r(o.prototype),"add",this).call(this,i)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var s=arguments[0],a=arguments[1];return this.add(s,a),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var u=arguments[0],h=arguments[1];if(arguments[2])for(var l=0;l<u.length;l++)this.add(u[l],h);else for(var f=u.length-1;f>=0;f--)this.add(u[f],h);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof q){var d=arguments[0],p=arguments[1];if(!arguments[2]){var v=this.size();if(v>0){if(d>0&&this.get(d-1).equals2D(p))return null;if(d<v&&this.get(d).equals2D(p))return null}}c(r(o.prototype),"add",this).call(this,d,p)}}else if(4===arguments.length){var y=arguments[0],m=arguments[1],w=arguments[2],g=arguments[3],b=1;w>g&&(b=-1);for(var x=w;x!==g;x+=b)this.add(y[x],m);return!0}}},{key:"closeRing",value:function(){if(this.size()>0){var t=this.get(0).copy();this.add(t,!1)}}}],[{key:"constructor_",value:function(){if(0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.ensureCapacity(t.length),this.add(t,!0)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.ensureCapacity(e.length),this.add(e,n)}}}]),o}(dt);Vt.coordArrayType=new Array(0).fill(null);var Wt=function(){function e(){t(this,e)}return n(e,null,[{key:"isRing",value:function(t){return!(t.length<4||!t[0].equals2D(t[t.length-1]))}},{key:"ptNotInList",value:function(t,n){for(var i=0;i<t.length;i++){var r=t[i];if(e.indexOf(r,n)<0)return r}return null}},{key:"scroll",value:function(t,n){var i=e.indexOf(n,t);if(i<0)return null;var r=new Array(t.length).fill(null);mt.arraycopy(t,i,r,0,t.length-i),mt.arraycopy(t,0,r,t.length-i,i),mt.arraycopy(r,0,t,0,t.length)}},{key:"equals",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(t===e)return!0;if(null===t||null===e)return!1;if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].equals(e[n]))return!1;return!0}if(3===arguments.length){var i=arguments[0],r=arguments[1],s=arguments[2];if(i===r)return!0;if(null===i||null===r)return!1;if(i.length!==r.length)return!1;for(var o=0;o<i.length;o++)if(0!==s.compare(i[o],r[o]))return!1;return!0}}},{key:"intersection",value:function(t,e){for(var n=new Vt,i=0;i<t.length;i++)e.intersects(t[i])&&n.add(t[i],!0);return n.toCoordinateArray()}},{key:"measures",value:function(t){if(null===t||0===t.length)return 0;var e,n=0,i=v(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;n=Math.max(n,Ht.measures(r))}}catch(t){i.e(t)}finally{i.f()}return n}},{key:"hasRepeatedPoints",value:function(t){for(var e=1;e<t.length;e++)if(t[e-1].equals(t[e]))return!0;return!1}},{key:"removeRepeatedPoints",value:function(t){return e.hasRepeatedPoints(t)?new Vt(t,!1).toCoordinateArray():t}},{key:"reverse",value:function(t){for(var e=t.length-1,n=Math.trunc(e/2),i=0;i<=n;i++){var r=t[i];t[i]=t[e-i],t[e-i]=r}}},{key:"removeNull",value:function(t){for(var e=0,n=0;n<t.length;n++)null!==t[n]&&e++;var i=new Array(e).fill(null);if(0===e)return i;for(var r=0,s=0;s<t.length;s++)null!==t[s]&&(i[r++]=t[s]);return i}},{key:"copyDeep",value:function(){if(1===arguments.length){for(var t=arguments[0],e=new Array(t.length).fill(null),n=0;n<t.length;n++)e[n]=t[n].copy();return e}if(5===arguments.length)for(var i=arguments[0],r=arguments[1],s=arguments[2],o=arguments[3],a=arguments[4],u=0;u<a;u++)s[o+u]=i[r+u].copy()}},{key:"isEqualReversed",value:function(t,e){for(var n=0;n<t.length;n++){var i=t[n],r=e[t.length-n-1];if(0!==i.compareTo(r))return!1}return!0}},{key:"envelope",value:function(t){for(var e=new B,n=0;n<t.length;n++)e.expandToInclude(t[n]);return e}},{key:"toCoordinateArray",value:function(t){return t.toArray(e.coordArrayType)}},{key:"dimension",value:function(t){if(null===t||0===t.length)return 3;var e,n=0,i=v(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;n=Math.max(n,Ht.dimension(r))}}catch(t){i.e(t)}finally{i.f()}return n}},{key:"atLeastNCoordinatesOrNothing",value:function(t,e){return e.length>=t?e:[]}},{key:"indexOf",value:function(t,e){for(var n=0;n<e.length;n++)if(t.equals(e[n]))return n;return-1}},{key:"increasingDirection",value:function(t){for(var e=0;e<Math.trunc(t.length/2);e++){var n=t.length-1-e,i=t[e].compareTo(t[n]);if(0!==i)return i}return 1}},{key:"compare",value:function(t,e){for(var n=0;n<t.length&&n<e.length;){var i=t[n].compareTo(e[n]);if(0!==i)return i;n++}return n<e.length?-1:n<t.length?1:0}},{key:"minCoordinate",value:function(t){for(var e=null,n=0;n<t.length;n++)(null===e||e.compareTo(t[n])>0)&&(e=t[n]);return e}},{key:"extract",value:function(t,e,n){e=wt.clamp(e,0,t.length);var i=(n=wt.clamp(n,-1,t.length))-e+1;n<0&&(i=0),e>=t.length&&(i=0),n<e&&(i=0);var r=new Array(i).fill(null);if(0===i)return r;for(var s=0,o=e;o<=n;o++)r[s++]=t[o];return r}}]),e}(),Gt=function(){function e(){t(this,e)}return n(e,[{key:"compare",value:function(t,e){var n=t,i=e;return Wt.compare(n,i)}},{key:"interfaces_",get:function(){return[z]}}]),e}(),Qt=function(){function e(){t(this,e)}return n(e,[{key:"compare",value:function(t,e){var n=t,i=e;if(n.length<i.length)return-1;if(n.length>i.length)return 1;if(0===n.length)return 0;var r=Wt.compare(n,i);return Wt.isEqualReversed(n,i)?0:r}},{key:"OLDcompare",value:function(t,e){var n=t,i=e;if(n.length<i.length)return-1;if(n.length>i.length)return 1;if(0===n.length)return 0;for(var r=Wt.increasingDirection(n),s=Wt.increasingDirection(i),o=r>0?0:n.length-1,a=s>0?0:n.length-1,u=0;u<n.length;u++){var h=n[o].compareTo(i[a]);if(0!==h)return h;o+=r,a+=s}return 0}},{key:"interfaces_",get:function(){return[z]}}]),e}();Wt.ForwardComparator=Gt,Wt.BidirectionalComparator=Qt,Wt.coordArrayType=new Array(0).fill(null);var Kt=function(){function e(n){t(this,e),this.str=n}return n(e,[{key:"append",value:function(t){this.str+=t}},{key:"setCharAt",value:function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)}},{key:"toString",value:function(){return this.str}}]),e}(),Xt=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getM",value:function(t){return this.hasM()?this.Au[t].getM():T.NaN}},{key:"setOrdinate",value:function(t,e,n){switch(e){case ut.X:this.Au[t].x=n;break;case ut.Y:this.Au[t].y=n;break;default:this.Au[t].setOrdinate(e,n)}}},{key:"getZ",value:function(t){return this.hasZ()?this.Au[t].getZ():T.NaN}},{key:"size",value:function(){return this.Au.length}},{key:"getOrdinate",value:function(t,e){switch(e){case ut.X:return this.Au[t].x;case ut.Y:return this.Au[t].y;default:return this.Au[t].getOrdinate(e)}}},{key:"getCoordinate",value:function(){if(1===arguments.length){var t=arguments[0];return this.Au[t]}if(2===arguments.length){var e=arguments[0];arguments[1].setCoordinate(this.Au[e])}}},{key:"getCoordinateCopy",value:function(t){var e=this.createCoordinate();return e.setCoordinate(this.Au[t]),e}},{key:"createCoordinate",value:function(){return Ht.create(this.getDimension(),this.getMeasures())}},{key:"getDimension",value:function(){return this.Du}},{key:"getX",value:function(t){return this.Au[t].x}},{key:"getMeasures",value:function(){return this.Pu}},{key:"expandEnvelope",value:function(t){for(var e=0;e<this.Au.length;e++)t.expandToInclude(this.Au[e]);return t}},{key:"copy",value:function(){for(var t=new Array(this.size()).fill(null),n=0;n<this.Au.length;n++){var i=this.createCoordinate();i.setCoordinate(this.Au[n]),t[n]=i}return new e(t,this.Du,this.Pu)}},{key:"toString",value:function(){if(this.Au.length>0){var t=new Kt(17*this.Au.length);t.append("("),t.append(this.Au[0]);for(var e=1;e<this.Au.length;e++)t.append(", "),t.append(this.Au[e]);return t.append(")"),t.toString()}return"()"}},{key:"getY",value:function(t){return this.Au[t].y}},{key:"toCoordinateArray",value:function(){return this.Au}},{key:"interfaces_",get:function(){return[ut,_]}}],[{key:"constructor_",value:function(){if(this.Du=3,this.Pu=0,this.Au=null,1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];e.constructor_.call(this,t,Wt.dimension(t),Wt.measures(t))}else if(Number.isInteger(arguments[0])){var n=arguments[0];this.Au=new Array(n).fill(null);for(var i=0;i<n;i++)this.Au[i]=new q}else if(nt(arguments[0],ut)){var r=arguments[0];if(null===r)return this.Au=new Array(0).fill(null),null;this.Du=r.getDimension(),this.Pu=r.getMeasures(),this.Au=new Array(r.size()).fill(null);for(var s=0;s<this.Au.length;s++)this.Au[s]=r.getCoordinateCopy(s)}}else if(2===arguments.length){if(arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var o=arguments[0],a=arguments[1];e.constructor_.call(this,o,a,Wt.measures(o))}else if(Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var u=arguments[0],h=arguments[1];this.Au=new Array(u).fill(null),this.Du=h;for(var l=0;l<u;l++)this.Au[l]=Ht.create(h)}}else if(3===arguments.length)if(Number.isInteger(arguments[2])&&arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var c=arguments[0],f=arguments[1],d=arguments[2];this.Du=f,this.Pu=d,this.Au=null===c?new Array(0).fill(null):c}else if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var p=arguments[0],v=arguments[1],y=arguments[2];this.Au=new Array(p).fill(null),this.Du=v,this.Pu=y;for(var m=0;m<p;m++)this.Au[m]=this.createCoordinate()}}}]),e}(),Zt=function(){function e(){t(this,e)}return n(e,[{key:"readResolve",value:function(){return e.instance()}},{key:"create",value:function(){if(1===arguments.length){if(arguments[0]instanceof Array)return new Xt(arguments[0]);if(nt(arguments[0],ut))return new Xt(arguments[0])}else{if(2===arguments.length){var t=arguments[1];return t>3&&(t=3),t<2&&(t=2),new Xt(arguments[0],t)}if(3===arguments.length){var e=arguments[2],n=arguments[1]-e;return e>1&&(e=1),n>3&&(n=3),n<2&&(n=2),new Xt(arguments[0],n+e,e)}}}},{key:"interfaces_",get:function(){return[bt,_]}}],[{key:"instance",value:function(){return e.instanceObject}}]),e}();Zt.instanceObject=new Zt;var Yt=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"copyInternal",value:function(){for(var t=new Array(this.Tu.length).fill(null),e=0;e<t.length;e++)t[e]=this.Tu[e].copy();return new o(t,this.pu)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof L){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&c(r(o.prototype),"equalsExact",this).call(this,t,e)}return c(r(o.prototype),"equalsExact",this).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"getTypeCode",value:function(){return L.TYPECODE_MULTIPOLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();for(var t=new dt,e=0;e<this.Tu.length;e++)for(var n=this.Tu[e].getBoundary(),i=0;i<n.getNumGeometries();i++)t.add(n.getGeometryN(i));var r=new Array(t.size()).fill(null);return this.getFactory().createMultiLineString(t.toArray(r))}},{key:"getGeometryType",value:function(){return L.TYPENAME_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[zt]}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Ft.constructor_.call(this,t,e)}}]),o}(Ft),Jt=function(){function e(){t(this,e)}return n(e,[{key:"get",value:function(){}},{key:"put",value:function(){}},{key:"size",value:function(){}},{key:"values",value:function(){}},{key:"entrySet",value:function(){}}]),e}(),te=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),(e=r.call(this)).map=new Map,e}return n(s,[{key:"get",value:function(t){return this.map.get(t)||null}},{key:"put",value:function(t,e){return this.map.set(t,e),e}},{key:"values",value:function(){for(var t=new dt,e=this.map.values(),n=e.next();!n.done;)t.add(n.value),n=e.next();return t}},{key:"entrySet",value:function(){var t=new K;return this.map.entries().forEach((function(e){return t.add(e)})),t}},{key:"size",value:function(){return this.map.size()}}]),s}(Jt),ee=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"equals",value:function(t){if(!(t instanceof e))return!1;var n=t;return this.Ru===n.Ru&&this._r===n._r}},{key:"compareTo",value:function(t){var e=t,n=this.getMaximumSignificantDigits(),i=e.getMaximumSignificantDigits();return rt.compare(n,i)}},{key:"getScale",value:function(){return this._r}},{key:"isFloating",value:function(){return this.Ru===e.FLOATING||this.Ru===e.FLOATING_SINGLE}},{key:"getType",value:function(){return this.Ru}},{key:"toString",value:function(){var t="UNKNOWN";return this.Ru===e.FLOATING?t="Floating":this.Ru===e.FLOATING_SINGLE?t="Floating-Single":this.Ru===e.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t}},{key:"makePrecise",value:function(){if("number"==typeof arguments[0]){var t=arguments[0];return T.isNaN(t)||this.Ru===e.FLOATING_SINGLE?t:this.Ru===e.FIXED?Math.round(t*this._r)/this._r:t}if(arguments[0]instanceof q){var n=arguments[0];if(this.Ru===e.FLOATING)return null;n.x=this.makePrecise(n.x),n.y=this.makePrecise(n.y)}}},{key:"getMaximumSignificantDigits",value:function(){var t=16;return this.Ru===e.FLOATING?t=16:this.Ru===e.FLOATING_SINGLE?t=6:this.Ru===e.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t}},{key:"setScale",value:function(t){this._r=Math.abs(t)}},{key:"interfaces_",get:function(){return[_,b]}}],[{key:"constructor_",value:function(){if(this.Ru=null,this._r=null,0===arguments.length)this.Ru=e.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof ne){var t=arguments[0];this.Ru=t,t===e.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){var n=arguments[0];this.Ru=e.FIXED,this.setScale(n)}else if(arguments[0]instanceof e){var i=arguments[0];this.Ru=i.Ru,this._r=i._r}}},{key:"mostPrecise",value:function(t,e){return t.compareTo(e)>=0?t:e}}]),e}(),ne=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"readResolve",value:function(){return e.nameToTypeMap.get(this.so)}},{key:"toString",value:function(){return this.so}},{key:"interfaces_",get:function(){return[_]}}],[{key:"constructor_",value:function(){this.so=null;var t=arguments[0];this.so=t,e.nameToTypeMap.put(t,this)}}]),e}();ne.nameToTypeMap=new te,ee.Type=ne,ee.FIXED=new ne("FIXED"),ee.FLOATING=new ne("FLOATING"),ee.FLOATING_SINGLE=new ne("FLOATING SINGLE"),ee.maximumPreciseValue=9007199254740992;var ie=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"copyInternal",value:function(){for(var t=new Array(this.Tu.length).fill(null),e=0;e<t.length;e++)t[e]=this.Tu[e].copy();return new o(t,this.pu)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof L){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&c(r(o.prototype),"equalsExact",this).call(this,t,e)}return c(r(o.prototype),"equalsExact",this).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?St.FALSE:0}},{key:"isClosed",value:function(){if(this.isEmpty())return!1;for(var t=0;t<this.Tu.length;t++)if(!this.Tu[t].isClosed())return!1;return!0}},{key:"getTypeCode",value:function(){return L.TYPECODE_MULTILINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getBoundary",value:function(){throw new G}},{key:"getGeometryType",value:function(){return L.TYPENAME_MULTILINESTRING}},{key:"interfaces_",get:function(){return[kt]}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Ft.constructor_.call(this,t,e)}}]),o}(Ft),re=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"createEmpty",value:function(t){switch(t){case-1:return this.createGeometryCollection();case 0:return this.createPoint();case 1:return this.createLineString();case 2:return this.createPolygon();default:throw new w("Invalid dimension: "+t)}}},{key:"toGeometry",value:function(t){return t.isNull()?this.createPoint():t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new q(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new q(t.getMinX(),t.getMinY()),new q(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new q(t.getMinX(),t.getMinY()),new q(t.getMinX(),t.getMaxY()),new q(t.getMaxX(),t.getMaxY()),new q(t.getMaxX(),t.getMinY()),new q(t.getMinX(),t.getMinY())]),null)}},{key:"createLineString",value:function(){if(0===arguments.length)return this.createLineString(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLineString(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(nt(arguments[0],ut))return new Ct(arguments[0],this)}}},{key:"createMultiLineString",value:function(){return 0===arguments.length?new ie(null,this):1===arguments.length?new ie(arguments[0],this):void 0}},{key:"buildGeometry",value:function(t){for(var n=null,i=!1,r=!1,s=t.iterator();s.hasNext();){var o=s.next(),a=o.getTypeCode();null===n&&(n=a),a!==n&&(i=!0),o instanceof Ft&&(r=!0)}if(null===n)return this.createGeometryCollection();if(i||r)return this.createGeometryCollection(e.toGeometryArray(t));var u=t.iterator().next();if(t.size()>1){if(u instanceof Dt)return this.createMultiPolygon(e.toPolygonArray(t));if(u instanceof Ct)return this.createMultiLineString(e.toLineStringArray(t));if(u instanceof It)return this.createMultiPoint(e.toPointArray(t));R.shouldNeverReachHere("Unhandled geometry type: "+u.getGeometryType())}return u}},{key:"createMultiPointFromCoords",value:function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)}},{key:"createPoint",value:function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof q){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(nt(arguments[0],ut))return new It(arguments[0],this)}}},{key:"getCoordinateSequenceFactory",value:function(){return this.Nu}},{key:"createPolygon",value:function(){if(0===arguments.length)return this.createPolygon(null,null);if(1===arguments.length){if(nt(arguments[0],ut)){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Array){var e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof qt){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length)return new Dt(arguments[0],arguments[1],this)}},{key:"getSRID",value:function(){return this.mu}},{key:"createGeometryCollection",value:function(){return 0===arguments.length?new Ft(null,this):1===arguments.length?new Ft(arguments[0],this):void 0}},{key:"getPrecisionModel",value:function(){return this.Fu}},{key:"createLinearRing",value:function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(nt(arguments[0],ut))return new qt(arguments[0],this)}}},{key:"createMultiPolygon",value:function(){return 0===arguments.length?new Yt(null,this):1===arguments.length?new Yt(arguments[0],this):void 0}},{key:"createMultiPoint",value:function(){if(0===arguments.length)return new Ut(null,this);if(1===arguments.length){if(arguments[0]instanceof Array)return new Ut(arguments[0],this);if(nt(arguments[0],ut)){var t=arguments[0];if(null===t)return this.createMultiPoint(new Array(0).fill(null));for(var e=new Array(t.size()).fill(null),n=0;n<t.size();n++){var i=this.getCoordinateSequenceFactory().create(1,t.getDimension(),t.getMeasures());$t.copy(t,n,i,0,1),e[n]=this.createPoint(i)}return this.createMultiPoint(e)}}}},{key:"interfaces_",get:function(){return[_]}}],[{key:"constructor_",value:function(){if(this.Fu=null,this.Nu=null,this.mu=null,0===arguments.length)e.constructor_.call(this,new ee,0);else if(1===arguments.length){if(nt(arguments[0],bt)){var t=arguments[0];e.constructor_.call(this,new ee,0,t)}else if(arguments[0]instanceof ee){var n=arguments[0];e.constructor_.call(this,n,0,e.getDefaultCoordinateSequenceFactory())}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];e.constructor_.call(this,i,r,e.getDefaultCoordinateSequenceFactory())}else if(3===arguments.length){var s=arguments[0],o=arguments[1],a=arguments[2];this.Fu=s,this.Nu=a,this.mu=o}}},{key:"toMultiPolygonArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toGeometryArray",value:function(t){if(null===t)return null;var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"getDefaultCoordinateSequenceFactory",value:function(){return Zt.instance()}},{key:"toMultiLineStringArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toLineStringArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toMultiPointArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toLinearRingArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toPointArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"toPolygonArray",value:function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)}},{key:"createPointFromInternalCoord",value:function(t,e){return e.getPrecisionModel().makePrecise(t),e.getFactory().createPoint(t)}}]),e}(),se="XY",oe={POINT:"Point",LINE_STRING:"LineString",LINEAR_RING:"LinearRing",POLYGON:"Polygon",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon",GEOMETRY_COLLECTION:"GeometryCollection",CIRCLE:"Circle"},ae="EMPTY";for(var ue in oe)oe[ue].toUpperCase();var he=function(){function e(n){t(this,e),this.wkt=n,this.index_=-1}return n(e,[{key:"isAlpha_",value:function(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}},{key:"isNumeric_",value:function(t,e){return t>="0"&&t<="9"||"."==t&&!(void 0!==e&&e)}},{key:"isWhiteSpace_",value:function(t){return" "==t||"\t"==t||"\r"==t||"\n"==t}},{key:"nextChar_",value:function(){return this.wkt.charAt(++this.index_)}},{key:"nextToken",value:function(){var t,e=this.nextChar_(),n=this.index_,i=e;if("("==e)t=2;else if(","==e)t=5;else if(")"==e)t=3;else if(this.isNumeric_(e)||"-"==e)t=4,i=this.readNumber_();else if(this.isAlpha_(e))t=1,i=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(""!==e)throw new Error("Unexpected character: "+e);t=6}return{position:n,value:i,type:t}}},{key:"readNumber_",value:function(){var t,e=this.index_,n=!1,i=!1;do{"."==t?n=!0:"e"!=t&&"E"!=t||(i=!0),t=this.nextChar_()}while(this.isNumeric_(t,n)||!i&&("e"==t||"E"==t)||i&&("-"==t||"+"==t));return parseFloat(this.wkt.substring(e,this.index_--))}},{key:"readText_",value:function(){var t,e=this.index_;do{t=this.nextChar_()}while(this.isAlpha_(t));return this.wkt.substring(e,this.index_--).toUpperCase()}}]),e}(),le=function(){function e(n,i){t(this,e),this.lexer_=n,this.token_,this.layout_=se,this.factory=i}return n(e,[{key:"consume_",value:function(){this.token_=this.lexer_.nextToken()}},{key:"isTokenType",value:function(t){return this.token_.type==t}},{key:"match",value:function(t){var e=this.isTokenType(t);return e&&this.consume_(),e}},{key:"parse",value:function(){return this.consume_(),this.parseGeometry_()}},{key:"parseGeometryLayout_",value:function(){var t=se,e=this.token_;if(this.isTokenType(1)){var n=e.value;"Z"===n?t="XYZ":"M"===n?t="XYM":"ZM"===n&&(t="XYZM"),t!==se&&this.consume_()}return t}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(2)){var t=[];do{t.push(this.parseGeometry_())}while(this.match(5));if(this.match(3))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(2)){var t=this.parsePoint_();if(this.match(3))return t}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(2)){var t=this.parsePointList_();if(this.match(3))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(2)){var t=this.parseLineStringTextList_();if(this.match(3))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var t;if(this.match(2)){if(t=2==this.token_.type?this.parsePointTextList_():this.parsePointList_(),this.match(3))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(2)){var t=this.parseLineStringTextList_();if(this.match(3))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(2)){var t=this.parsePolygonTextList_();if(this.match(3))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePoint_",value:function(){for(var t=[],e=this.layout_.length,n=0;n<e;++n){var i=this.token_;if(!this.match(4))break;t.push(i.value)}if(t.length==e)return t;throw new Error(this.formatErrorMessage_())}},{key:"parsePointList_",value:function(){for(var t=[this.parsePoint_()];this.match(5);)t.push(this.parsePoint_());return t}},{key:"parsePointTextList_",value:function(){for(var t=[this.parsePointText_()];this.match(5);)t.push(this.parsePointText_());return t}},{key:"parseLineStringTextList_",value:function(){for(var t=[this.parseLineStringText_()];this.match(5);)t.push(this.parseLineStringText_());return t}},{key:"parsePolygonTextList_",value:function(){for(var t=[this.parsePolygonText_()];this.match(5);)t.push(this.parsePolygonText_());return t}},{key:"isEmptyGeometry_",value:function(){var t=this.isTokenType(1)&&this.token_.value==ae;return t&&this.consume_(),t}},{key:"formatErrorMessage_",value:function(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}},{key:"parseGeometry_",value:function(){var t=this.factory,e=function(t){return a(q,f(t))},n=function(n){var i=n.map((function(n){return t.createLinearRing(n.map(e))}));return i.length>1?t.createPolygon(i[0],i.slice(1)):t.createPolygon(i[0])},i=this.token_;if(this.match(1)){var r=i.value;if(this.layout_=this.parseGeometryLayout_(),"GEOMETRYCOLLECTION"==r){var s=this.parseGeometryCollectionText_();return t.createGeometryCollection(s)}switch(r){case"POINT":var o=this.parsePointText_();return o?t.createPoint(a(q,f(o))):t.createPoint();case"LINESTRING":var u=this.parseLineStringText_().map(e);return t.createLineString(u);case"LINEARRING":var h=this.parseLineStringText_().map(e);return t.createLinearRing(h);case"POLYGON":var l=this.parsePolygonText_();return l&&0!==l.length?n(l):t.createPolygon();case"MULTIPOINT":var c=this.parseMultiPointText_();if(!c||0===c.length)return t.createMultiPoint();var d=c.map(e).map((function(e){return t.createPoint(e)}));return t.createMultiPoint(d);case"MULTILINESTRING":var p=this.parseMultiLineStringText_().map((function(n){return t.createLineString(n.map(e))}));return t.createMultiLineString(p);case"MULTIPOLYGON":var v=this.parseMultiPolygonText_();if(!v||0===v.length)return t.createMultiPolygon();var y=v.map(n);return t.createMultiPolygon(y);default:throw new Error("Invalid geometry type: "+r)}}throw new Error(this.formatErrorMessage_())}}]),e}();function ce(t){if(t.isEmpty())return"";var e=t.getCoordinate(),n=[e.x,e.y];return void 0===e.z||Number.isNaN(e.z)||n.push(e.z),void 0===e.m||Number.isNaN(e.m)||n.push(e.m),n.join(" ")}function fe(t){for(var e=t.getCoordinates().map((function(t){var e=[t.x,t.y];return void 0===t.z||Number.isNaN(t.z)||e.push(t.z),void 0===t.m||Number.isNaN(t.m)||e.push(t.m),e})),n=[],i=0,r=e.length;i<r;++i)n.push(e[i].join(" "));return n.join(", ")}function de(t){var e=[];e.push("("+fe(t.getExteriorRing())+")");for(var n=0,i=t.getNumInteriorRing();n<i;++n)e.push("("+fe(t.getInteriorRingN(n))+")");return e.join(", ")}var pe={Point:ce,LineString:fe,LinearRing:fe,Polygon:de,MultiPoint:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push("("+ce(t.getGeometryN(n))+")");return e.join(", ")},MultiLineString:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push("("+fe(t.getGeometryN(n))+")");return e.join(", ")},MultiPolygon:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push("("+de(t.getGeometryN(n))+")");return e.join(", ")},GeometryCollection:function(t){for(var e=[],n=0,i=t.getNumGeometries();n<i;++n)e.push(ve(t.getGeometryN(n)));return e.join(", ")}};function ve(t){var e=t.getGeometryType(),n=pe[e];e=e.toUpperCase();var i=function(t){var e="";if(t.isEmpty())return e;var n=t.getCoordinate();return void 0===n.z||Number.isNaN(n.z)||(e+="Z"),void 0===n.m||Number.isNaN(n.m)||(e+="M"),e}(t);return i.length>0&&(e+=" "+i),t.isEmpty()?e+" "+ae:e+" ("+n(t)+")"}var ye=function(){function e(n){t(this,e),this.geometryFactory=n||new re,this.precisionModel=this.geometryFactory.getPrecisionModel()}return n(e,[{key:"read",value:function(t){var e=new he(t);return new le(e,this.geometryFactory).parse()}},{key:"write",value:function(t){return ve(t)}}]),e}(),me=function(){function e(n){t(this,e),this.parser=new ye(n)}return n(e,[{key:"write",value:function(t){return this.parser.write(t)}}],[{key:"toLineString",value:function(t,e){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+t.x+" "+t.y+", "+e.x+" "+e.y+" )"}}]),e}(),we=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getIndexAlongSegment",value:function(t,e){return this.computeIntLineIndex(),this.Uu[t][e]}},{key:"getTopologySummary",value:function(){var t=new Kt;return this.isEndPoint()&&t.append(" endpoint"),this.qu&&t.append(" proper"),this.isCollinear()&&t.append(" collinear"),t.toString()}},{key:"computeIntersection",value:function(t,e,n,i){this.ju[0][0]=t,this.ju[0][1]=e,this.ju[1][0]=n,this.ju[1][1]=i,this.Bu=this.computeIntersect(t,e,n,i)}},{key:"getIntersectionNum",value:function(){return this.Bu}},{key:"computeIntLineIndex",value:function(){if(0===arguments.length)null===this.Uu&&(this.Uu=Array(2).fill().map((function(){return Array(2)})),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){var t=arguments[0];this.getEdgeDistance(t,0)>this.getEdgeDistance(t,1)?(this.Uu[t][0]=0,this.Uu[t][1]=1):(this.Uu[t][0]=1,this.Uu[t][1]=0)}}},{key:"isProper",value:function(){return this.hasIntersection()&&this.qu}},{key:"setPrecisionModel",value:function(t){this.Fu=t}},{key:"isInteriorIntersection",value:function(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var t=arguments[0],e=0;e<this.Bu;e++)if(!this.Lu[e].equals2D(this.ju[t][0])&&!this.Lu[e].equals2D(this.ju[t][1]))return!0;return!1}}},{key:"getIntersection",value:function(t){return this.Lu[t]}},{key:"isEndPoint",value:function(){return this.hasIntersection()&&!this.qu}},{key:"hasIntersection",value:function(){return this.Bu!==e.NO_INTERSECTION}},{key:"getEdgeDistance",value:function(t,n){return e.computeEdgeDistance(this.Lu[n],this.ju[t][0],this.ju[t][1])}},{key:"isCollinear",value:function(){return this.Bu===e.COLLINEAR_INTERSECTION}},{key:"toString",value:function(){return me.toLineString(this.ju[0][0],this.ju[0][1])+" - "+me.toLineString(this.ju[1][0],this.ju[1][1])+this.getTopologySummary()}},{key:"getEndpoint",value:function(t,e){return this.ju[t][e]}},{key:"isIntersection",value:function(t){for(var e=0;e<this.Bu;e++)if(this.Lu[e].equals2D(t))return!0;return!1}},{key:"getIntersectionAlongSegment",value:function(t,e){return this.computeIntLineIndex(),this.Lu[this.Uu[t][e]]}}],[{key:"constructor_",value:function(){this.Bu=null,this.ju=Array(2).fill().map((function(){return Array(2)})),this.Lu=new Array(2).fill(null),this.Uu=null,this.qu=null,this.Hu=null,this.Vu=null,this.Fu=null,this.Lu[0]=new q,this.Lu[1]=new q,this.Hu=this.Lu[0],this.Vu=this.Lu[1],this.Bu=0}},{key:"computeEdgeDistance",value:function(t,e,n){var i=Math.abs(n.x-e.x),r=Math.abs(n.y-e.y),s=-1;if(t.equals(e))s=0;else if(t.equals(n))s=i>r?i:r;else{var o=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);0!==(s=i>r?o:a)||t.equals(e)||(s=Math.max(o,a))}return R.isTrue(!(0===s&&!t.equals(e)),"Bad distance calculation"),s}},{key:"nonRobustComputeEdgeDistance",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y,s=Math.sqrt(i*i+r*r);return R.isTrue(!(0===s&&!t.equals(e)),"Invalid distance calculation"),s}}]),e}();we.DONT_INTERSECT=0,we.DO_INTERSECT=1,we.COLLINEAR=2,we.NO_INTERSECTION=0,we.POINT_INTERSECTION=1,we.COLLINEAR_INTERSECTION=2;var ge=function(e){i(o,e);var s=l(o);function o(){return t(this,o),s.call(this)}return n(o,[{key:"isInSegmentEnvelopes",value:function(t){var e=new B(this.ju[0][0],this.ju[0][1]),n=new B(this.ju[1][0],this.ju[1][1]);return e.contains(t)&&n.contains(t)}},{key:"computeIntersection",value:function(){if(3!==arguments.length)return c(r(o.prototype),"computeIntersection",this).apply(this,arguments);var t=arguments[0],e=arguments[1],n=arguments[2];if(this.qu=!1,B.intersects(e,n,t)&&0===ht.index(e,n,t)&&0===ht.index(n,e,t))return this.qu=!0,(t.equals(e)||t.equals(n))&&(this.qu=!1),this.Bu=we.POINT_INTERSECTION,null;this.Bu=we.NO_INTERSECTION}},{key:"intersection",value:function(t,e,n,i){var r=this.intersectionSafe(t,e,n,i);return this.isInSegmentEnvelopes(r)||(r=new q(o.nearestEndpoint(t,e,n,i))),null!==this.Fu&&this.Fu.makePrecise(r),r}},{key:"checkDD",value:function(t,e,n,i,r){var s=at.intersection(t,e,n,i),o=this.isInSegmentEnvelopes(s);mt.out.println("DD in env = "+o+" --------------------- "+s),r.distance(s)>1e-4&&mt.out.println("Distance = "+r.distance(s))}},{key:"intersectionSafe",value:function(t,e,n,i){var r=yt.intersection(t,e,n,i);return null===r&&(r=o.nearestEndpoint(t,e,n,i)),r}},{key:"computeCollinearIntersection",value:function(t,e,n,i){var r=B.intersects(t,e,n),s=B.intersects(t,e,i),o=B.intersects(n,i,t),a=B.intersects(n,i,e);return r&&s?(this.Lu[0]=n,this.Lu[1]=i,we.COLLINEAR_INTERSECTION):o&&a?(this.Lu[0]=t,this.Lu[1]=e,we.COLLINEAR_INTERSECTION):r&&o?(this.Lu[0]=n,this.Lu[1]=t,!n.equals(t)||s||a?we.COLLINEAR_INTERSECTION:we.POINT_INTERSECTION):r&&a?(this.Lu[0]=n,this.Lu[1]=e,!n.equals(e)||s||o?we.COLLINEAR_INTERSECTION:we.POINT_INTERSECTION):s&&o?(this.Lu[0]=i,this.Lu[1]=t,!i.equals(t)||r||a?we.COLLINEAR_INTERSECTION:we.POINT_INTERSECTION):s&&a?(this.Lu[0]=i,this.Lu[1]=e,!i.equals(e)||r||o?we.COLLINEAR_INTERSECTION:we.POINT_INTERSECTION):we.NO_INTERSECTION}},{key:"computeIntersect",value:function(t,e,n,i){if(this.qu=!1,!B.intersects(t,e,n,i))return we.NO_INTERSECTION;var r=ht.index(t,e,n),s=ht.index(t,e,i);if(r>0&&s>0||r<0&&s<0)return we.NO_INTERSECTION;var o=ht.index(n,i,t),a=ht.index(n,i,e);return o>0&&a>0||o<0&&a<0?we.NO_INTERSECTION:0===r&&0===s&&0===o&&0===a?this.computeCollinearIntersection(t,e,n,i):(0===r||0===s||0===o||0===a?(this.qu=!1,t.equals2D(n)||t.equals2D(i)?this.Lu[0]=t:e.equals2D(n)||e.equals2D(i)?this.Lu[0]=e:0===r?this.Lu[0]=new q(n):0===s?this.Lu[0]=new q(i):0===o?this.Lu[0]=new q(t):0===a&&(this.Lu[0]=new q(e))):(this.qu=!0,this.Lu[0]=this.intersection(t,e,n,i)),we.POINT_INTERSECTION)}}],[{key:"nearestEndpoint",value:function(t,e,n,i){var r=t,s=gt.pointToSegment(t,n,i),o=gt.pointToSegment(e,n,i);return o<s&&(s=o,r=e),(o=gt.pointToSegment(n,t,e))<s&&(s=o,r=n),(o=gt.pointToSegment(i,t,e))<s&&(s=o,r=i),r}}]),o}(we),be=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"countSegment",value:function(t,e){if(t.x<this.Wu.x&&e.x<this.Wu.x)return null;if(this.Wu.x===e.x&&this.Wu.y===e.y)return this.Gu=!0,null;if(t.y===this.Wu.y&&e.y===this.Wu.y){var n=t.x,i=e.x;return n>i&&(n=e.x,i=t.x),this.Wu.x>=n&&this.Wu.x<=i&&(this.Gu=!0),null}if(t.y>this.Wu.y&&e.y<=this.Wu.y||e.y>this.Wu.y&&t.y<=this.Wu.y){var r=ht.index(t,e,this.Wu);if(r===ht.COLLINEAR)return this.Gu=!0,null;e.y<t.y&&(r=-r),r===ht.LEFT&&this.Qu++}}},{key:"isPointInPolygon",value:function(){return this.getLocation()!==H.EXTERIOR}},{key:"getLocation",value:function(){return this.Gu?H.BOUNDARY:this.Qu%2==1?H.INTERIOR:H.EXTERIOR}},{key:"isOnSegment",value:function(){return this.Gu}}],[{key:"constructor_",value:function(){this.Wu=null,this.Qu=0,this.Gu=!1;var t=arguments[0];this.Wu=t}},{key:"locatePointInRing",value:function(){if(arguments[0]instanceof q&&nt(arguments[1],ut)){for(var t=arguments[1],n=new e(arguments[0]),i=new q,r=new q,s=1;s<t.size();s++)if(t.getCoordinate(s,i),t.getCoordinate(s-1,r),n.countSegment(i,r),n.isOnSegment())return n.getLocation();return n.getLocation()}if(arguments[0]instanceof q&&arguments[1]instanceof Array){for(var o=arguments[1],a=new e(arguments[0]),u=1;u<o.length;u++){var h=o[u],l=o[u-1];if(a.countSegment(h,l),a.isOnSegment())return a.getLocation()}return a.getLocation()}}}]),e}(),xe=function(){function e(){t(this,e)}return n(e,null,[{key:"isOnLine",value:function(){if(arguments[0]instanceof q&&nt(arguments[1],ut)){for(var t=arguments[0],e=arguments[1],n=new ge,i=new q,r=new q,s=e.size(),o=1;o<s;o++)if(e.getCoordinate(o-1,i),e.getCoordinate(o,r),n.computeIntersection(t,i,r),n.hasIntersection())return!0;return!1}if(arguments[0]instanceof q&&arguments[1]instanceof Array){for(var a=arguments[0],u=arguments[1],h=new ge,l=1;l<u.length;l++){var c=u[l-1],f=u[l];if(h.computeIntersection(a,c,f),h.hasIntersection())return!0}return!1}}},{key:"locateInRing",value:function(t,e){return be.locatePointInRing(t,e)}},{key:"isInRing",value:function(t,n){return e.locateInRing(t,n)!==H.EXTERIOR}}]),e}(),_e=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"setAllLocations",value:function(t){for(var e=0;e<this.location.length;e++)this.location[e]=t}},{key:"isNull",value:function(){for(var t=0;t<this.location.length;t++)if(this.location[t]!==H.NONE)return!1;return!0}},{key:"setAllLocationsIfNull",value:function(t){for(var e=0;e<this.location.length;e++)this.location[e]===H.NONE&&(this.location[e]=t)}},{key:"isLine",value:function(){return 1===this.location.length}},{key:"merge",value:function(t){if(t.location.length>this.location.length){var e=new Array(3).fill(null);e[Z.ON]=this.location[Z.ON],e[Z.LEFT]=H.NONE,e[Z.RIGHT]=H.NONE,this.location=e}for(var n=0;n<this.location.length;n++)this.location[n]===H.NONE&&n<t.location.length&&(this.location[n]=t.location[n])}},{key:"getLocations",value:function(){return this.location}},{key:"flip",value:function(){if(this.location.length<=1)return null;var t=this.location[Z.LEFT];this.location[Z.LEFT]=this.location[Z.RIGHT],this.location[Z.RIGHT]=t}},{key:"toString",value:function(){var t=new it;return this.location.length>1&&t.append(H.toLocationSymbol(this.location[Z.LEFT])),t.append(H.toLocationSymbol(this.location[Z.ON])),this.location.length>1&&t.append(H.toLocationSymbol(this.location[Z.RIGHT])),t.toString()}},{key:"setLocations",value:function(t,e,n){this.location[Z.ON]=t,this.location[Z.LEFT]=e,this.location[Z.RIGHT]=n}},{key:"get",value:function(t){return t<this.location.length?this.location[t]:H.NONE}},{key:"isArea",value:function(){return this.location.length>1}},{key:"isAnyNull",value:function(){for(var t=0;t<this.location.length;t++)if(this.location[t]===H.NONE)return!0;return!1}},{key:"setLocation",value:function(){if(1===arguments.length){var t=arguments[0];this.setLocation(Z.ON,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.location[e]=n}}},{key:"init",value:function(t){this.location=new Array(t).fill(null),this.setAllLocations(H.NONE)}},{key:"isEqualOnSide",value:function(t,e){return this.location[e]===t.location[e]}},{key:"allPositionsEqual",value:function(t){for(var e=0;e<this.location.length;e++)if(this.location[e]!==t)return!1;return!0}}],[{key:"constructor_",value:function(){if(this.location=null,1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];this.init(t.length)}else if(Number.isInteger(arguments[0])){var n=arguments[0];this.init(1),this.location[Z.ON]=n}else if(arguments[0]instanceof e){var i=arguments[0];if(this.init(i.location.length),null!==i)for(var r=0;r<this.location.length;r++)this.location[r]=i.location[r]}}else if(3===arguments.length){var s=arguments[0],o=arguments[1],a=arguments[2];this.init(3),this.location[Z.ON]=s,this.location[Z.LEFT]=o,this.location[Z.RIGHT]=a}}}]),e}(),ke=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getGeometryCount",value:function(){var t=0;return this.elt[0].isNull()||t++,this.elt[1].isNull()||t++,t}},{key:"setAllLocations",value:function(t,e){this.elt[t].setAllLocations(e)}},{key:"isNull",value:function(t){return this.elt[t].isNull()}},{key:"setAllLocationsIfNull",value:function(){if(1===arguments.length){var t=arguments[0];this.setAllLocationsIfNull(0,t),this.setAllLocationsIfNull(1,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.elt[e].setAllLocationsIfNull(n)}}},{key:"isLine",value:function(t){return this.elt[t].isLine()}},{key:"merge",value:function(t){for(var e=0;e<2;e++)null===this.elt[e]&&null!==t.elt[e]?this.elt[e]=new _e(t.elt[e]):this.elt[e].merge(t.elt[e])}},{key:"flip",value:function(){this.elt[0].flip(),this.elt[1].flip()}},{key:"getLocation",value:function(){if(1===arguments.length){var t=arguments[0];return this.elt[t].get(Z.ON)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return this.elt[e].get(n)}}},{key:"toString",value:function(){var t=new it;return null!==this.elt[0]&&(t.append("A:"),t.append(this.elt[0].toString())),null!==this.elt[1]&&(t.append(" B:"),t.append(this.elt[1].toString())),t.toString()}},{key:"isArea",value:function(){if(0===arguments.length)return this.elt[0].isArea()||this.elt[1].isArea();if(1===arguments.length){var t=arguments[0];return this.elt[t].isArea()}}},{key:"isAnyNull",value:function(t){return this.elt[t].isAnyNull()}},{key:"setLocation",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.elt[t].setLocation(Z.ON,e)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.elt[n].setLocation(i,r)}}},{key:"isEqualOnSide",value:function(t,e){return this.elt[0].isEqualOnSide(t.elt[0],e)&&this.elt[1].isEqualOnSide(t.elt[1],e)}},{key:"allPositionsEqual",value:function(t,e){return this.elt[t].allPositionsEqual(e)}},{key:"toLine",value:function(t){this.elt[t].isArea()&&(this.elt[t]=new _e(this.elt[t].location[0]))}}],[{key:"constructor_",value:function(){if(this.elt=new Array(2).fill(null),1===arguments.length){if(Number.isInteger(arguments[0])){var t=arguments[0];this.elt[0]=new _e(t),this.elt[1]=new _e(t)}else if(arguments[0]instanceof e){var n=arguments[0];this.elt[0]=new _e(n.elt[0]),this.elt[1]=new _e(n.elt[1])}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.elt[0]=new _e(H.NONE),this.elt[1]=new _e(H.NONE),this.elt[i].setLocation(r)}else if(3===arguments.length){var s=arguments[0],o=arguments[1],a=arguments[2];this.elt[0]=new _e(s,o,a),this.elt[1]=new _e(s,o,a)}else if(4===arguments.length){var u=arguments[0],h=arguments[1],l=arguments[2],c=arguments[3];this.elt[0]=new _e(H.NONE,H.NONE,H.NONE),this.elt[1]=new _e(H.NONE,H.NONE,H.NONE),this.elt[u].setLocations(h,l,c)}}},{key:"toLineLabel",value:function(t){for(var n=new e(H.NONE),i=0;i<2;i++)n.setLocation(i,t.getLocation(i));return n}}]),e}(),$e=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"computeRing",value:function(){if(null!==this.Ku)return null;for(var t=new Array(this.Xu.size()).fill(null),e=0;e<this.Xu.size();e++)t[e]=this.Xu.get(e);this.Ku=this.Zu.createLinearRing(t),this.Yu=ht.isCCW(this.Ku.getCoordinates())}},{key:"isIsolated",value:function(){return 1===this.Ju.getGeometryCount()}},{key:"computePoints",value:function(t){this.th=t;var e=t,n=!0;do{if(null===e)throw new ct("Found null DirectedEdge");if(e.getEdgeRing()===this)throw new ct("Directed Edge visited twice during ring-building at "+e.getCoordinate());this.eh.add(e);var i=e.getLabel();R.isTrue(i.isArea()),this.mergeLabel(i),this.addPoints(e.getEdge(),e.isForward(),n),n=!1,this.setEdgeRing(e,this),e=this.getNext(e)}while(e!==this.th)}},{key:"getLinearRing",value:function(){return this.Ku}},{key:"getCoordinate",value:function(t){return this.Xu.get(t)}},{key:"computeMaxNodeDegree",value:function(){this.nh=0;var t=this.th;do{var e=t.getNode().getEdges().getOutgoingDegree(this);e>this.nh&&(this.nh=e),t=this.getNext(t)}while(t!==this.th);this.nh*=2}},{key:"addPoints",value:function(t,e,n){var i=t.getCoordinates();if(e){var r=1;n&&(r=0);for(var s=r;s<i.length;s++)this.Xu.add(i[s])}else{var o=i.length-2;n&&(o=i.length-1);for(var a=o;a>=0;a--)this.Xu.add(i[a])}}},{key:"isHole",value:function(){return this.Yu}},{key:"setInResult",value:function(){var t=this.th;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this.th)}},{key:"containsPoint",value:function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!xe.isInRing(t,e.getCoordinates()))return!1;for(var n=this.Ou.iterator();n.hasNext();)if(n.next().containsPoint(t))return!1;return!0}},{key:"addHole",value:function(t){this.Ou.add(t)}},{key:"isShell",value:function(){return null===this.Iu}},{key:"getLabel",value:function(){return this.Ju}},{key:"getEdges",value:function(){return this.eh}},{key:"getMaxNodeDegree",value:function(){return this.nh<0&&this.computeMaxNodeDegree(),this.nh}},{key:"getShell",value:function(){return this.Iu}},{key:"mergeLabel",value:function(){if(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){var e=arguments[1],n=arguments[0].getLocation(e,Z.RIGHT);if(n===H.NONE)return null;if(this.Ju.getLocation(e)===H.NONE)return this.Ju.setLocation(e,n),null}}},{key:"setShell",value:function(t){this.Iu=t,null!==t&&t.addHole(this)}},{key:"toPolygon",value:function(t){for(var e=new Array(this.Ou.size()).fill(null),n=0;n<this.Ou.size();n++)e[n]=this.Ou.get(n).getLinearRing();return t.createPolygon(this.getLinearRing(),e)}}],[{key:"constructor_",value:function(){if(this.th=null,this.nh=-1,this.eh=new dt,this.Xu=new dt,this.Ju=new ke(H.NONE),this.Ku=null,this.Yu=null,this.Iu=null,this.Ou=new dt,this.Zu=null,0===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];this.Zu=e,this.computePoints(t),this.computeRing()}}}]),e}(),Se=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),e=r.call(this),s.constructor_.apply(h(e),arguments),e}return n(s,[{key:"setEdgeRing",value:function(t,e){t.setMinEdgeRing(e)}},{key:"getNext",value:function(t){return t.getNextMin()}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];$e.constructor_.call(this,t,e)}}]),s}($e),Me=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),e=r.call(this),s.constructor_.apply(h(e),arguments),e}return n(s,[{key:"buildMinimalRings",value:function(){var t=new dt,e=this.th;do{if(null===e.getMinEdgeRing()){var n=new Se(e,this.Zu);t.add(n)}e=e.getNext()}while(e!==this.th);return t}},{key:"setEdgeRing",value:function(t,e){t.setEdgeRing(e)}},{key:"linkDirectedEdgesForMinimalEdgeRings",value:function(){var t=this.th;do{t.getNode().getEdges().linkMinimalDirectedEdges(this),t=t.getNext()}while(t!==this.th)}},{key:"getNext",value:function(t){return t.getNext()}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];$e.constructor_.call(this,t,e)}}]),s}($e),Ee=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"setVisited",value:function(t){this.ih=t}},{key:"setInResult",value:function(t){this.rh=t}},{key:"isCovered",value:function(){return this.sh}},{key:"isCoveredSet",value:function(){return this.oh}},{key:"setLabel",value:function(t){this.Ju=t}},{key:"getLabel",value:function(){return this.Ju}},{key:"setCovered",value:function(t){this.sh=t,this.oh=!0}},{key:"updateIM",value:function(t){R.isTrue(this.Ju.getGeometryCount()>=2,"found partial label"),this.computeIM(t)}},{key:"isInResult",value:function(){return this.rh}},{key:"isVisited",value:function(){return this.ih}}],[{key:"constructor_",value:function(){if(this.Ju=null,this.rh=!1,this.sh=!1,this.oh=!1,this.ih=!1,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.Ju=t}}}]),e}(),Ce=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"isIncidentEdgeInResult",value:function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();)if(t.next().getEdge().isInResult())return!0;return!1}},{key:"isIsolated",value:function(){return 1===this.Ju.getGeometryCount()}},{key:"getCoordinate",value:function(){return this.Ii}},{key:"print",value:function(t){t.println("node "+this.Ii+" lbl: "+this.Ju)}},{key:"computeIM",value:function(t){}},{key:"computeMergedLocation",value:function(t,e){var n=H.NONE;if(n=this.Ju.getLocation(e),!t.isNull(e)){var i=t.getLocation(e);n!==H.BOUNDARY&&(n=i)}return n}},{key:"setLabel",value:function(){if(2!==arguments.length||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return c(r(o.prototype),"setLabel",this).apply(this,arguments);var t=arguments[0],e=arguments[1];null===this.Ju?this.Ju=new ke(t,e):this.Ju.setLocation(t,e)}},{key:"getEdges",value:function(){return this.eh}},{key:"mergeLabel",value:function(){if(arguments[0]instanceof o){var t=arguments[0];this.mergeLabel(t.Ju)}else if(arguments[0]instanceof ke)for(var e=arguments[0],n=0;n<2;n++){var i=this.computeMergedLocation(e,n);this.Ju.getLocation(n)===H.NONE&&this.Ju.setLocation(n,i)}}},{key:"add",value:function(t){this.eh.insert(t),t.setNode(this)}},{key:"setLabelBoundary",value:function(t){if(null===this.Ju)return null;var e=H.NONE;null!==this.Ju&&(e=this.Ju.getLocation(t));var n=null;switch(e){case H.BOUNDARY:n=H.INTERIOR;break;case H.INTERIOR:default:n=H.BOUNDARY}this.Ju.setLocation(t,n)}}],[{key:"constructor_",value:function(){this.Ii=null,this.eh=null;var t=arguments[0],e=arguments[1];this.Ii=t,this.eh=e,this.Ju=new ke(0,H.NONE)}}]),o}(Ee),Ae=function(e){i(r,e);var n=l(r);function r(){return t(this,r),n.apply(this,arguments)}return r}(Jt);function Ie(t){return null==t?0:t.color}function Oe(t){return null==t?null:t.parent}function Te(t,e){null!==t&&(t.color=e)}function ze(t){return null==t?null:t.left}function De(t){return null==t?null:t.right}var Pe=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),(e=r.call(this)).root_=null,e.size_=0,e}return n(s,[{key:"get",value:function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return e.value;e=e.right}}return null}},{key:"put",value:function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,i,r=this.root_;do{if(n=r,(i=t.compareTo(r.key))<0)r=r.left;else{if(!(i>0)){var s=r.value;return r.value=e,s}r=r.right}}while(null!==r);var o={key:t,left:null,right:null,value:e,parent:n,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return i<0?n.left=o:n.right=o,this.fixAfterInsertion(o),this.size_++,null}},{key:"fixAfterInsertion",value:function(t){var e;for(t.color=1;null!=t&&t!==this.root_&&1===t.parent.color;)Oe(t)===ze(Oe(Oe(t)))?1===Ie(e=De(Oe(Oe(t))))?(Te(Oe(t),0),Te(e,0),Te(Oe(Oe(t)),1),t=Oe(Oe(t))):(t===De(Oe(t))&&(t=Oe(t),this.rotateLeft(t)),Te(Oe(t),0),Te(Oe(Oe(t)),1),this.rotateRight(Oe(Oe(t)))):1===Ie(e=ze(Oe(Oe(t))))?(Te(Oe(t),0),Te(e,0),Te(Oe(Oe(t)),1),t=Oe(Oe(t))):(t===ze(Oe(t))&&(t=Oe(t),this.rotateRight(t)),Te(Oe(t),0),Te(Oe(Oe(t)),1),this.rotateLeft(Oe(Oe(t))));this.root_.color=0}},{key:"values",value:function(){var t=new dt,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=s.successor(e));)t.add(e.value);return t}},{key:"entrySet",value:function(){var t=new K,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=s.successor(e));)t.add(e);return t}},{key:"rotateLeft",value:function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}}},{key:"rotateRight",value:function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}}},{key:"getFirstEntry",value:function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t}},{key:"size",value:function(){return this.size_}},{key:"containsKey",value:function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return!0;e=e.right}}return!1}}],[{key:"successor",value:function(t){var e;if(null===t)return null;if(null!==t.right){for(e=t.right;null!==e.left;)e=e.left;return e}e=t.parent;for(var n=t;null!==e&&n===e.right;)n=e,e=e.parent;return e}}]),s}(Ae),Re=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"find",value:function(t){return this.nodeMap.get(t)}},{key:"addNode",value:function(){if(arguments[0]instanceof q){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof Ce){var n=arguments[0],i=this.nodeMap.get(n.getCoordinate());return null===i?(this.nodeMap.put(n.getCoordinate(),n),n):(i.mergeLabel(n),i)}}},{key:"print",value:function(t){for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"iterator",value:function(){return this.nodeMap.values().iterator()}},{key:"values",value:function(){return this.nodeMap.values()}},{key:"getBoundaryNodes",value:function(t){for(var e=new dt,n=this.iterator();n.hasNext();){var i=n.next();i.getLabel().getLocation(t)===H.BOUNDARY&&e.add(i)}return e}},{key:"add",value:function(t){var e=t.getCoordinate();this.addNode(e).add(t)}}],[{key:"constructor_",value:function(){this.nodeMap=new Pe,this.nodeFact=null;var t=arguments[0];this.nodeFact=t}}]),e}(),Ne=function(){function e(){t(this,e)}return n(e,null,[{key:"isNorthern",value:function(t){return t===e.NE||t===e.NW}},{key:"isOpposite",value:function(t,e){return t!==e&&2==(t-e+4)%4}},{key:"commonHalfPlane",value:function(t,e){if(t===e)return t;if(2==(t-e+4)%4)return-1;var n=t<e?t:e;return 0===n&&3===(t>e?t:e)?3:n}},{key:"isInHalfPlane",value:function(t,n){return n===e.SE?t===e.SE||t===e.SW:t===n||t===n+1}},{key:"quadrant",value:function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],n=arguments[1];if(0===t&&0===n)throw new w("Cannot compute the quadrant for point ( "+t+", "+n+" )");return t>=0?n>=0?e.NE:e.SE:n>=0?e.NW:e.SW}if(arguments[0]instanceof q&&arguments[1]instanceof q){var i=arguments[0],r=arguments[1];if(r.x===i.x&&r.y===i.y)throw new w("Cannot compute the quadrant for two identical points "+i);return r.x>=i.x?r.y>=i.y?e.NE:e.SE:r.y>=i.y?e.NW:e.SW}}}]),e}();Ne.NE=0,Ne.NW=1,Ne.SW=2,Ne.SE=3;var Fe=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"compareDirection",value:function(t){return this.ah===t.ah&&this.uh===t.uh?0:this.hh>t.hh?1:this.hh<t.hh?-1:ht.index(t.fh,t.dh,this.dh)}},{key:"getDy",value:function(){return this.uh}},{key:"getCoordinate",value:function(){return this.fh}},{key:"setNode",value:function(t){this.ph=t}},{key:"print",value:function(t){var e=Math.atan2(this.uh,this.ah),n=this.getClass().getName(),i=n.lastIndexOf("."),r=n.substring(i+1);t.print(" "+r+": "+this.fh+" - "+this.dh+" "+this.hh+":"+e+" "+this.Ju)}},{key:"compareTo",value:function(t){var e=t;return this.compareDirection(e)}},{key:"getDirectedCoordinate",value:function(){return this.dh}},{key:"getDx",value:function(){return this.ah}},{key:"getLabel",value:function(){return this.Ju}},{key:"getEdge",value:function(){return this.yh}},{key:"getQuadrant",value:function(){return this.hh}},{key:"getNode",value:function(){return this.ph}},{key:"toString",value:function(){var t=Math.atan2(this.uh,this.ah),e=this.getClass().getName(),n=e.lastIndexOf(".");return" "+e.substring(n+1)+": "+this.fh+" - "+this.dh+" "+this.hh+":"+t+" "+this.Ju}},{key:"computeLabel",value:function(t){}},{key:"init",value:function(t,e){this.fh=t,this.dh=e,this.ah=e.x-t.x,this.uh=e.y-t.y,this.hh=Ne.quadrant(this.ah,this.uh),R.isTrue(!(0===this.ah&&0===this.uh),"EdgeEnd with identical endpoints found")}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){if(this.yh=null,this.Ju=null,this.ph=null,this.fh=null,this.dh=null,this.ah=null,this.uh=null,this.hh=null,1===arguments.length){var t=arguments[0];this.yh=t}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];e.constructor_.call(this,n,i,r,null)}else if(4===arguments.length){var s=arguments[0],o=arguments[1],a=arguments[2],u=arguments[3];e.constructor_.call(this,s),this.init(o,a),this.Ju=u}}}]),e}(),Ue=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"getNextMin",value:function(){return this.mh}},{key:"getDepth",value:function(t){return this.wh[t]}},{key:"setVisited",value:function(t){this.ih=t}},{key:"computeDirectedLabel",value:function(){this.Ju=new ke(this.yh.getLabel()),this.gh||this.Ju.flip()}},{key:"getNext",value:function(){return this.bh}},{key:"setDepth",value:function(t,e){if(-999!==this.wh[t]&&this.wh[t]!==e)throw new ct("assigned depths do not match",this.getCoordinate());this.wh[t]=e}},{key:"isInteriorAreaEdge",value:function(){for(var t=!0,e=0;e<2;e++)this.Ju.isArea(e)&&this.Ju.getLocation(e,Z.LEFT)===H.INTERIOR&&this.Ju.getLocation(e,Z.RIGHT)===H.INTERIOR||(t=!1);return t}},{key:"setNextMin",value:function(t){this.mh=t}},{key:"print",value:function(t){c(r(o.prototype),"print",this).call(this,t),t.print(" "+this.wh[Z.LEFT]+"/"+this.wh[Z.RIGHT]),t.print(" ("+this.getDepthDelta()+")"),this.rh&&t.print(" inResult")}},{key:"setMinEdgeRing",value:function(t){this.xh=t}},{key:"isLineEdge",value:function(){var t=this.Ju.isLine(0)||this.Ju.isLine(1),e=!this.Ju.isArea(0)||this.Ju.allPositionsEqual(0,H.EXTERIOR),n=!this.Ju.isArea(1)||this.Ju.allPositionsEqual(1,H.EXTERIOR);return t&&e&&n}},{key:"setEdgeRing",value:function(t){this._h=t}},{key:"getMinEdgeRing",value:function(){return this.xh}},{key:"getDepthDelta",value:function(){var t=this.yh.getDepthDelta();return this.gh||(t=-t),t}},{key:"setInResult",value:function(t){this.rh=t}},{key:"getSym",value:function(){return this.kh}},{key:"isForward",value:function(){return this.gh}},{key:"getEdge",value:function(){return this.yh}},{key:"printEdge",value:function(t){this.print(t),t.print(" "),this.gh?this.yh.print(t):this.yh.printReverse(t)}},{key:"setSym",value:function(t){this.kh=t}},{key:"setVisitedEdge",value:function(t){this.setVisited(t),this.kh.setVisited(t)}},{key:"setEdgeDepths",value:function(t,e){var n=this.getEdge().getDepthDelta();this.gh||(n=-n);var i=1;t===Z.LEFT&&(i=-1);var r=Z.opposite(t),s=e+n*i;this.setDepth(t,e),this.setDepth(r,s)}},{key:"getEdgeRing",value:function(){return this._h}},{key:"isInResult",value:function(){return this.rh}},{key:"setNext",value:function(t){this.bh=t}},{key:"isVisited",value:function(){return this.ih}}],[{key:"constructor_",value:function(){this.gh=null,this.rh=!1,this.ih=!1,this.kh=null,this.bh=null,this.mh=null,this._h=null,this.xh=null,this.wh=[0,-999,-999];var t=arguments[0],e=arguments[1];if(Fe.constructor_.call(this,t),this.gh=e,e)this.init(t.getCoordinate(0),t.getCoordinate(1));else{var n=t.getNumPoints()-1;this.init(t.getCoordinate(n),t.getCoordinate(n-1))}this.computeDirectedLabel()}},{key:"depthFactor",value:function(t,e){return t===H.EXTERIOR&&e===H.INTERIOR?1:t===H.INTERIOR&&e===H.EXTERIOR?-1:0}}]),o}(Fe),qe=function(){function e(){t(this,e)}return n(e,[{key:"createNode",value:function(t){return new Ce(t,null)}}]),e}(),je=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"printEdges",value:function(t){t.println("Edges:");for(var e=0;e<this.eh.size();e++){t.println("edge "+e+":");var n=this.eh.get(e);n.print(t),n.eiList.print(t)}}},{key:"find",value:function(t){return this.Cu.find(t)}},{key:"addNode",value:function(){if(arguments[0]instanceof Ce){var t=arguments[0];return this.Cu.addNode(t)}if(arguments[0]instanceof q){var e=arguments[0];return this.Cu.addNode(e)}}},{key:"getNodeIterator",value:function(){return this.Cu.iterator()}},{key:"linkResultDirectedEdges",value:function(){for(var t=this.Cu.iterator();t.hasNext();)t.next().getEdges().linkResultDirectedEdges()}},{key:"debugPrintln",value:function(t){mt.out.println(t)}},{key:"isBoundaryNode",value:function(t,e){var n=this.Cu.find(e);if(null===n)return!1;var i=n.getLabel();return null!==i&&i.getLocation(t)===H.BOUNDARY}},{key:"linkAllDirectedEdges",value:function(){for(var t=this.Cu.iterator();t.hasNext();)t.next().getEdges().linkAllDirectedEdges()}},{key:"matchInSameDirection",value:function(t,e,n,i){return!!t.equals(n)&&ht.index(t,e,i)===ht.COLLINEAR&&Ne.quadrant(t,e)===Ne.quadrant(n,i)}},{key:"getEdgeEnds",value:function(){return this.$h}},{key:"debugPrint",value:function(t){mt.out.print(t)}},{key:"getEdgeIterator",value:function(){return this.eh.iterator()}},{key:"findEdgeInSameDirection",value:function(t,e){for(var n=0;n<this.eh.size();n++){var i=this.eh.get(n),r=i.getCoordinates();if(this.matchInSameDirection(t,e,r[0],r[1]))return i;if(this.matchInSameDirection(t,e,r[r.length-1],r[r.length-2]))return i}return null}},{key:"insertEdge",value:function(t){this.eh.add(t)}},{key:"findEdgeEnd",value:function(t){for(var e=this.getEdgeEnds().iterator();e.hasNext();){var n=e.next();if(n.getEdge()===t)return n}return null}},{key:"addEdges",value:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();this.eh.add(n);var i=new Ue(n,!0),r=new Ue(n,!1);i.setSym(r),r.setSym(i),this.add(i),this.add(r)}}},{key:"add",value:function(t){this.Cu.add(t),this.$h.add(t)}},{key:"getNodes",value:function(){return this.Cu.values()}},{key:"findEdge",value:function(t,e){for(var n=0;n<this.eh.size();n++){var i=this.eh.get(n),r=i.getCoordinates();if(t.equals(r[0])&&e.equals(r[1]))return i}return null}}],[{key:"constructor_",value:function(){if(this.eh=new dt,this.Cu=null,this.$h=new dt,0===arguments.length)this.Cu=new Re(new qe);else if(1===arguments.length){var t=arguments[0];this.Cu=new Re(t)}}},{key:"linkResultDirectedEdges",value:function(t){for(var e=t.iterator();e.hasNext();)e.next().getEdges().linkResultDirectedEdges()}}]),e}(),Be=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"sortShellsAndHoles",value:function(t,e,n){for(var i=t.iterator();i.hasNext();){var r=i.next();r.isHole()?n.add(r):e.add(r)}}},{key:"computePolygons",value:function(t){for(var e=new dt,n=t.iterator();n.hasNext();){var i=n.next().toPolygon(this.Zu);e.add(i)}return e}},{key:"placeFreeHoles",value:function(t,n){for(var i=n.iterator();i.hasNext();){var r=i.next();if(null===r.getShell()){var s=e.findEdgeRingContaining(r,t);if(null===s)throw new ct("unable to assign hole to a shell",r.getCoordinate(0));r.setShell(s)}}}},{key:"buildMinimalEdgeRings",value:function(t,e,n){for(var i=new dt,r=t.iterator();r.hasNext();){var s=r.next();if(s.getMaxNodeDegree()>2){s.linkDirectedEdgesForMinimalEdgeRings();var o=s.buildMinimalRings(),a=this.findShell(o);null!==a?(this.placePolygonHoles(a,o),e.add(a)):n.addAll(o)}else i.add(s)}return i}},{key:"buildMaximalEdgeRings",value:function(t){for(var e=new dt,n=t.iterator();n.hasNext();){var i=n.next();if(i.isInResult()&&i.getLabel().isArea()&&null===i.getEdgeRing()){var r=new Me(i,this.Zu);e.add(r),r.setInResult()}}return e}},{key:"placePolygonHoles",value:function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next();i.isHole()&&i.setShell(t)}}},{key:"getPolygons",value:function(){return this.computePolygons(this.Sh)}},{key:"findShell",value:function(t){for(var e=0,n=null,i=t.iterator();i.hasNext();){var r=i.next();r.isHole()||(n=r,e++)}return R.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n}},{key:"add",value:function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){var e=arguments[0],n=arguments[1];je.linkResultDirectedEdges(n);var i=this.buildMaximalEdgeRings(e),r=new dt,s=this.buildMinimalEdgeRings(i,this.Sh,r);this.sortShellsAndHoles(s,this.Sh,r),this.placeFreeHoles(this.Sh,r)}}}],[{key:"constructor_",value:function(){this.Zu=null,this.Sh=new dt;var t=arguments[0];this.Zu=t}},{key:"findEdgeRingContaining",value:function(t,e){for(var n=t.getLinearRing(),i=n.getEnvelopeInternal(),r=n.getCoordinateN(0),s=null,o=null,a=e.iterator();a.hasNext();){var u=a.next(),h=u.getLinearRing(),l=h.getEnvelopeInternal();if(!l.equals(i)&&l.contains(i)){r=Wt.ptNotInList(n.getCoordinates(),h.getCoordinates());var c=!1;xe.isInRing(r,h.getCoordinates())&&(c=!0),c&&(null===s||o.contains(l))&&(o=(s=u).getLinearRing().getEnvelopeInternal())}}return s}}]),e}(),Le=function(){function e(){t(this,e)}return n(e,[{key:"getBounds",value:function(){}}]),e}(),He=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getItem",value:function(){return this.Mh}},{key:"getBounds",value:function(){return this.Eh}},{key:"interfaces_",get:function(){return[Le,_]}}],[{key:"constructor_",value:function(){this.Eh=null,this.Mh=null;var t=arguments[0],e=arguments[1];this.Eh=t,this.Mh=e}}]),e}(),Ve=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"poll",value:function(){if(this.isEmpty())return null;var t=this.Ch.get(1);return this.Ch.set(1,this.Ch.get(this.Bi)),this.Bi-=1,this.reorder(1),t}},{key:"size",value:function(){return this.Bi}},{key:"reorder",value:function(t){for(var e=null,n=this.Ch.get(t);2*t<=this.Bi&&((e=2*t)!==this.Bi&&this.Ch.get(e+1).compareTo(this.Ch.get(e))<0&&e++,this.Ch.get(e).compareTo(n)<0);t=e)this.Ch.set(t,this.Ch.get(e));this.Ch.set(t,n)}},{key:"clear",value:function(){this.Bi=0,this.Ch.clear()}},{key:"peek",value:function(){return this.isEmpty()?null:this.Ch.get(1)}},{key:"isEmpty",value:function(){return 0===this.Bi}},{key:"add",value:function(t){this.Ch.add(null),this.Bi+=1;var e=this.Bi;for(this.Ch.set(0,t);t.compareTo(this.Ch.get(Math.trunc(e/2)))<0;e/=2)this.Ch.set(e,this.Ch.get(Math.trunc(e/2)));this.Ch.set(e,t)}}],[{key:"constructor_",value:function(){this.Bi=null,this.Ch=null,this.Bi=0,this.Ch=new dt,this.Ch.add(null)}}]),e}(),We=function(){function e(){t(this,e)}return n(e,[{key:"insert",value:function(t,e){}},{key:"remove",value:function(t,e){}},{key:"query",value:function(){}}]),e}(),Ge=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getLevel",value:function(){return this.Ah}},{key:"size",value:function(){return this.Ih.size()}},{key:"getChildBoundables",value:function(){return this.Ih}},{key:"addChildBoundable",value:function(t){R.isTrue(null===this.Eh),this.Ih.add(t)}},{key:"isEmpty",value:function(){return this.Ih.isEmpty()}},{key:"getBounds",value:function(){return null===this.Eh&&(this.Eh=this.computeBounds()),this.Eh}},{key:"interfaces_",get:function(){return[Le,_]}}],[{key:"constructor_",value:function(){if(this.Ih=new dt,this.Eh=null,this.Ah=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.Ah=t}}}]),e}(),Qe={reverseOrder:function(){return{compare:function(t,e){return e.compareTo(t)}}},min:function(t){return Qe.sort(t),t.get(0)},sort:function(t,e){var n=t.toArray();e?Tt.sort(n,e):Tt.sort(n);for(var i=t.iterator(),r=0,s=n.length;r<s;r++)i.next(),i.set(n[r])},singletonList:function(t){var e=new dt;return e.add(t),e}},Ke=function(){function e(){t(this,e)}return n(e,null,[{key:"maxDistance",value:function(t,n,i,r,s,o,a,u){var h=e.distance(t,n,s,o);return h=Math.max(h,e.distance(t,n,a,u)),h=Math.max(h,e.distance(i,r,s,o)),Math.max(h,e.distance(i,r,a,u))}},{key:"distance",value:function(t,e,n,i){var r=n-t,s=i-e;return Math.sqrt(r*r+s*s)}},{key:"maximumDistance",value:function(t,n){var i=Math.min(t.getMinX(),n.getMinX()),r=Math.min(t.getMinY(),n.getMinY()),s=Math.max(t.getMaxX(),n.getMaxX()),o=Math.max(t.getMaxY(),n.getMaxY());return e.distance(i,r,s,o)}},{key:"minMaxDistance",value:function(t,n){var i=t.getMinX(),r=t.getMinY(),s=t.getMaxX(),o=t.getMaxY(),a=n.getMinX(),u=n.getMinY(),h=n.getMaxX(),l=n.getMaxY(),c=e.maxDistance(i,r,i,o,a,u,a,l);return c=Math.min(c,e.maxDistance(i,r,i,o,a,u,h,u)),c=Math.min(c,e.maxDistance(i,r,i,o,h,l,a,l)),c=Math.min(c,e.maxDistance(i,r,i,o,h,l,h,u)),c=Math.min(c,e.maxDistance(i,r,s,r,a,u,a,l)),c=Math.min(c,e.maxDistance(i,r,s,r,a,u,h,u)),c=Math.min(c,e.maxDistance(i,r,s,r,h,l,a,l)),c=Math.min(c,e.maxDistance(i,r,s,r,h,l,h,u)),c=Math.min(c,e.maxDistance(s,o,i,o,a,u,a,l)),c=Math.min(c,e.maxDistance(s,o,i,o,a,u,h,u)),c=Math.min(c,e.maxDistance(s,o,i,o,h,l,a,l)),c=Math.min(c,e.maxDistance(s,o,i,o,h,l,h,u)),c=Math.min(c,e.maxDistance(s,o,s,r,a,u,a,l)),c=Math.min(c,e.maxDistance(s,o,s,r,a,u,h,u)),c=Math.min(c,e.maxDistance(s,o,s,r,h,l,a,l)),Math.min(c,e.maxDistance(s,o,s,r,h,l,h,u))}}]),e}(),Xe=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"maximumDistance",value:function(){return Ke.maximumDistance(this.Oh.getBounds(),this.Th.getBounds())}},{key:"expandToQueue",value:function(t,n){var i=e.isComposite(this.Oh),r=e.isComposite(this.Th);if(i&&r)return e.area(this.Oh)>e.area(this.Th)?(this.expand(this.Oh,this.Th,!1,t,n),null):(this.expand(this.Th,this.Oh,!0,t,n),null);if(i)return this.expand(this.Oh,this.Th,!1,t,n),null;if(r)return this.expand(this.Th,this.Oh,!0,t,n),null;throw new w("neither boundable is composite")}},{key:"isLeaves",value:function(){return!(e.isComposite(this.Oh)||e.isComposite(this.Th))}},{key:"compareTo",value:function(t){var e=t;return this.zh<e.zh?-1:this.zh>e.zh?1:0}},{key:"expand",value:function(t,n,i,r,s){for(var o=t.getChildBoundables().iterator();o.hasNext();){var a=o.next(),u=null;(u=i?new e(n,a,this.Dh):new e(a,n,this.Dh)).getDistance()<s&&r.add(u)}}},{key:"getBoundable",value:function(t){return 0===t?this.Oh:this.Th}},{key:"getDistance",value:function(){return this.zh}},{key:"distance",value:function(){return this.isLeaves()?this.Dh.distance(this.Oh,this.Th):this.Oh.getBounds().distance(this.Th.getBounds())}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this.Oh=null,this.Th=null,this.zh=null,this.Dh=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.Oh=t,this.Th=e,this.Dh=n,this.zh=this.distance()}},{key:"area",value:function(t){return t.getBounds().getArea()}},{key:"isComposite",value:function(t){return t instanceof Ge}}]),e}(),Ze=function(){function e(){t(this,e)}return n(e,[{key:"visitItem",value:function(t){}}]),e}(),Ye=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"queryInternal",value:function(){if(nt(arguments[2],Ze)&&arguments[0]instanceof Object&&arguments[1]instanceof Ge)for(var t=arguments[0],e=arguments[2],n=arguments[1].getChildBoundables(),i=0;i<n.size();i++){var r=n.get(i);this.getIntersectsOp().intersects(r.getBounds(),t)&&(r instanceof Ge?this.queryInternal(t,r,e):r instanceof He?e.visitItem(r.getItem()):R.shouldNeverReachHere())}else if(nt(arguments[2],tt)&&arguments[0]instanceof Object&&arguments[1]instanceof Ge)for(var s=arguments[0],o=arguments[2],a=arguments[1].getChildBoundables(),u=0;u<a.size();u++){var h=a.get(u);this.getIntersectsOp().intersects(h.getBounds(),s)&&(h instanceof Ge?this.queryInternal(s,h,o):h instanceof He?o.add(h.getItem()):R.shouldNeverReachHere())}}},{key:"getNodeCapacity",value:function(){return this.Ph}},{key:"lastNode",value:function(t){return t.get(t.size()-1)}},{key:"size",value:function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.size(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();n instanceof Ge?t+=this.size(n):n instanceof He&&(t+=1)}return t}}},{key:"removeItem",value:function(t,e){for(var n=null,i=t.getChildBoundables().iterator();i.hasNext();){var r=i.next();r instanceof He&&r.getItem()===e&&(n=r)}return null!==n&&(t.getChildBoundables().remove(n),!0)}},{key:"itemsTree",value:function(){if(0===arguments.length){this.build();var t=this.itemsTree(this._root);return null===t?new dt:t}if(1===arguments.length){for(var e=arguments[0],n=new dt,i=e.getChildBoundables().iterator();i.hasNext();){var r=i.next();if(r instanceof Ge){var s=this.itemsTree(r);null!==s&&n.add(s)}else r instanceof He?n.add(r.getItem()):R.shouldNeverReachHere()}return n.size()<=0?null:n}}},{key:"insert",value:function(t,e){R.isTrue(!this.Rh,"Cannot insert items into an STR packed R-tree after it has been built."),this.Nh.add(new He(t,e))}},{key:"boundablesAtLevel",value:function(){if(1===arguments.length){var t=arguments[0],e=new dt;return this.boundablesAtLevel(t,this._root,e),e}if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];if(R.isTrue(n>-2),i.getLevel()===n)return r.add(i),null;for(var s=i.getChildBoundables().iterator();s.hasNext();){var o=s.next();o instanceof Ge?this.boundablesAtLevel(n,o,r):(R.isTrue(o instanceof He),-1===n&&r.add(o))}return null}}},{key:"query",value:function(){if(1===arguments.length){var t=arguments[0];this.build();var e=new dt;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.queryInternal(t,this._root,e),e}if(2===arguments.length){var n=arguments[0],i=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),n)&&this.queryInternal(n,this._root,i)}}},{key:"build",value:function(){if(this.Rh)return null;this._root=this.Nh.isEmpty()?this.createNode(0):this.createHigherLevels(this.Nh,-1),this.Nh=null,this.Rh=!0}},{key:"getRoot",value:function(){return this.build(),this._root}},{key:"remove",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.remove(t,this._root,e)}if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],s=this.removeItem(i,r);if(s)return!0;for(var o=null,a=i.getChildBoundables().iterator();a.hasNext();){var u=a.next();if(this.getIntersectsOp().intersects(u.getBounds(),n)&&u instanceof Ge&&(s=this.remove(n,u,r))){o=u;break}}return null!==o&&o.getChildBoundables().isEmpty()&&i.getChildBoundables().remove(o),s}}},{key:"createHigherLevels",value:function(t,e){R.isTrue(!t.isEmpty());var n=this.createParentBoundables(t,e+1);return 1===n.size()?n.get(0):this.createHigherLevels(n,e+1)}},{key:"depth",value:function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();if(n instanceof Ge){var i=this.depth(n);i>t&&(t=i)}}return t+1}}},{key:"createParentBoundables",value:function(t,e){R.isTrue(!t.isEmpty());var n=new dt;n.add(this.createNode(e));var i=new dt(t);Qe.sort(i,this.getComparator());for(var r=i.iterator();r.hasNext();){var s=r.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(e)),this.lastNode(n).addChildBoundable(s)}return n}},{key:"isEmpty",value:function(){return this.Rh?this._root.isEmpty():this.Nh.isEmpty()}},{key:"interfaces_",get:function(){return[_]}}],[{key:"constructor_",value:function(){if(this._root=null,this.Rh=!1,this.Nh=new dt,this.Ph=null,0===arguments.length)e.constructor_.call(this,e.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];R.isTrue(t>1,"Node capacity must be greater than 1"),this.Ph=t}}},{key:"compareDoubles",value:function(t,e){return t>e?1:t<e?-1:0}}]),e}();Ye.IntersectsOp=function(){},Ye.DEFAULT_NODE_CAPACITY=10;var Je=function(){function e(){t(this,e)}return n(e,[{key:"distance",value:function(t,e){}}]),e}(),tn=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"createParentBoundablesFromVerticalSlices",value:function(t,e){R.isTrue(t.length>0);for(var n=new dt,i=0;i<t.length;i++)n.addAll(this.createParentBoundablesFromVerticalSlice(t[i],e));return n}},{key:"nearestNeighbourK",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return this.nearestNeighbourK(t,T.POSITIVE_INFINITY,e)}if(3===arguments.length){var n=arguments[0],i=arguments[2],r=arguments[1],s=new Ve;s.add(n);for(var a=new Ve;!s.isEmpty()&&r>=0;){var u=s.poll(),h=u.getDistance();if(h>=r)break;u.isLeaves()?a.size()<i?a.add(u):(a.peek().getDistance()>h&&(a.poll(),a.add(u)),r=a.peek().getDistance()):u.expandToQueue(s,r)}return o.getItems(a)}}},{key:"createNode",value:function(t){return new en(t)}},{key:"size",value:function(){return 0===arguments.length?c(r(o.prototype),"size",this).call(this):c(r(o.prototype),"size",this).apply(this,arguments)}},{key:"insert",value:function(){if(!(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof B))return c(r(o.prototype),"insert",this).apply(this,arguments);var t=arguments[0],e=arguments[1];if(t.isNull())return null;c(r(o.prototype),"insert",this).call(this,t,e)}},{key:"getIntersectsOp",value:function(){return o.intersectsOp}},{key:"verticalSlices",value:function(t,e){for(var n=Math.trunc(Math.ceil(t.size()/e)),i=new Array(e).fill(null),r=t.iterator(),s=0;s<e;s++){i[s]=new dt;for(var o=0;r.hasNext()&&o<n;){var a=r.next();i[s].add(a),o++}}return i}},{key:"query",value:function(){if(1===arguments.length){var t=arguments[0];return c(r(o.prototype),"query",this).call(this,t)}if(2===arguments.length){var e=arguments[0],n=arguments[1];c(r(o.prototype),"query",this).call(this,e,n)}}},{key:"getComparator",value:function(){return o.yComparator}},{key:"createParentBoundablesFromVerticalSlice",value:function(t,e){return c(r(o.prototype),"createParentBoundables",this).call(this,t,e)}},{key:"remove",value:function(){if(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof B){var t=arguments[0],e=arguments[1];return c(r(o.prototype),"remove",this).call(this,t,e)}return c(r(o.prototype),"remove",this).apply(this,arguments)}},{key:"depth",value:function(){return 0===arguments.length?c(r(o.prototype),"depth",this).call(this):c(r(o.prototype),"depth",this).apply(this,arguments)}},{key:"createParentBoundables",value:function(t,e){R.isTrue(!t.isEmpty());var n=Math.trunc(Math.ceil(t.size()/this.getNodeCapacity())),i=new dt(t);Qe.sort(i,o.xComparator);var r=this.verticalSlices(i,Math.trunc(Math.ceil(Math.sqrt(n))));return this.createParentBoundablesFromVerticalSlices(r,e)}},{key:"nearestNeighbour",value:function(){if(1===arguments.length){if(nt(arguments[0],Je)){var t=arguments[0];if(this.isEmpty())return null;var e=new Xe(this.getRoot(),this.getRoot(),t);return this.nearestNeighbour(e)}if(arguments[0]instanceof Xe){var n=arguments[0],i=T.POSITIVE_INFINITY,r=null,s=new Ve;for(s.add(n);!s.isEmpty()&&i>0;){var o=s.poll(),a=o.getDistance();if(a>=i)break;o.isLeaves()?(i=a,r=o):o.expandToQueue(s,i)}return null===r?null:[r.getBoundable(0).getItem(),r.getBoundable(1).getItem()]}}else{if(2===arguments.length){var u=arguments[0],h=arguments[1];if(this.isEmpty()||u.isEmpty())return null;var l=new Xe(this.getRoot(),u.getRoot(),h);return this.nearestNeighbour(l)}if(3===arguments.length){var c=arguments[2],f=new He(arguments[0],arguments[1]),d=new Xe(this.getRoot(),f,c);return this.nearestNeighbour(d)[0]}if(4===arguments.length){var p=arguments[2],v=arguments[3],y=new He(arguments[0],arguments[1]),m=new Xe(this.getRoot(),y,p);return this.nearestNeighbourK(m,v)}}}},{key:"isWithinDistance",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=T.POSITIVE_INFINITY,i=new Ve;for(i.add(t);!i.isEmpty();){var r=i.poll(),s=r.getDistance();if(s>e)return!1;if(r.maximumDistance()<=e)return!0;if(r.isLeaves()){if((n=s)<=e)return!0}else r.expandToQueue(i,n)}return!1}if(3===arguments.length){var o=arguments[0],a=arguments[1],u=arguments[2],h=new Xe(this.getRoot(),o.getRoot(),a);return this.isWithinDistance(h,u)}}},{key:"interfaces_",get:function(){return[We,_]}}],[{key:"constructor_",value:function(){if(0===arguments.length)o.constructor_.call(this,o.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];Ye.constructor_.call(this,t)}}},{key:"centreX",value:function(t){return o.avg(t.getMinX(),t.getMaxX())}},{key:"avg",value:function(t,e){return(t+e)/2}},{key:"getItems",value:function(t){for(var e=new Array(t.size()).fill(null),n=0;!t.isEmpty();){var i=t.poll();e[n]=i.getBoundable(0).getItem(),n++}return e}},{key:"centreY",value:function(t){return o.avg(t.getMinY(),t.getMaxY())}}]),o}(Ye),en=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),e=r.call(this),s.constructor_.apply(h(e),arguments),e}return n(s,[{key:"computeBounds",value:function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new B(n.getBounds()):t.expandToInclude(n.getBounds())}return t}}],[{key:"constructor_",value:function(){var t=arguments[0];Ge.constructor_.call(this,t)}}]),s}(Ge);tn.STRtreeNode=en,tn.xComparator=new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[z]}},{key:"compare",value:function(t,e){return Ye.compareDoubles(tn.centreX(t.getBounds()),tn.centreX(e.getBounds()))}}]),e}()),tn.yComparator=new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[z]}},{key:"compare",value:function(t,e){return Ye.compareDoubles(tn.centreY(t.getBounds()),tn.centreY(e.getBounds()))}}]),e}()),tn.intersectsOp=new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[IntersectsOp]}},{key:"intersects",value:function(t,e){return t.intersects(e)}}]),e}()),tn.DEFAULT_NODE_CAPACITY=10;var nn=function(){function e(){t(this,e)}return n(e,null,[{key:"relativeSign",value:function(t,e){return t<e?-1:t>e?1:0}},{key:"compare",value:function(t,n,i){if(n.equals2D(i))return 0;var r=e.relativeSign(n.x,i.x),s=e.relativeSign(n.y,i.y);switch(t){case 0:return e.compareValue(r,s);case 1:return e.compareValue(s,r);case 2:return e.compareValue(s,-r);case 3:return e.compareValue(-r,s);case 4:return e.compareValue(-r,-s);case 5:return e.compareValue(-s,-r);case 6:return e.compareValue(-s,r);case 7:return e.compareValue(r,-s)}return R.shouldNeverReachHere("invalid octant value"),0}},{key:"compareValue",value:function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0}}]),e}(),rn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)}},{key:"compareTo",value:function(t){var e=t;return this.segmentIndex<e.segmentIndex?-1:this.segmentIndex>e.segmentIndex?1:this.coord.equals2D(e.coord)?0:this.Fh?e.Fh?nn.compare(this.Uh,this.coord,e.coord):1:-1}},{key:"isEndPoint",value:function(t){return 0===this.segmentIndex&&!this.Fh||this.segmentIndex===t}},{key:"toString",value:function(){return this.segmentIndex+":"+this.coord.toString()}},{key:"isInterior",value:function(){return this.Fh}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this.qh=null,this.coord=null,this.segmentIndex=null,this.Uh=null,this.Fh=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this.qh=t,this.coord=new q(e),this.segmentIndex=n,this.Uh=i,this.Fh=!e.equals2D(t.getCoordinate(n))}}]),e}(),sn=function(){function e(){t(this,e)}return n(e,[{key:"hasNext",value:function(){}},{key:"next",value:function(){}},{key:"remove",value:function(){}}]),e}(),on=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getSplitCoordinates",value:function(){var t=new Vt;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next();this.addEdgeCoordinates(n,i,t),n=i}return t.toCoordinateArray()}},{key:"addCollapsedNodes",value:function(){var t=new dt;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this.yh.getCoordinate(n),n)}}},{key:"createSplitEdgePts",value:function(t,e){var n=e.segmentIndex-t.segmentIndex+2;if(2===n)return[new q(t.coord),new q(e.coord)];var i=this.yh.getCoordinate(e.segmentIndex),r=e.isInterior()||!e.coord.equals2D(i);r||n--;var s=new Array(n).fill(null),o=0;s[o++]=new q(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)s[o++]=this.yh.getCoordinate(a);return r&&(s[o]=new q(e.coord)),s}},{key:"print",value:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"findCollapsesFromExistingVertices",value:function(t){for(var e=0;e<this.yh.size()-2;e++){var n=this.yh.getCoordinate(e);this.yh.getCoordinate(e+1);var i=this.yh.getCoordinate(e+2);n.equals2D(i)&&t.add(rt.valueOf(e+1))}}},{key:"addEdgeCoordinates",value:function(t,e,n){var i=this.createSplitEdgePts(t,e);n.add(i,!1)}},{key:"iterator",value:function(){return this.jh.values().iterator()}},{key:"addSplitEdges",value:function(t){this.addEndpoints(),this.addCollapsedNodes();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next(),r=this.createSplitEdge(n,i);t.add(r),n=i}}},{key:"findCollapseIndex",value:function(t,e,n){if(!t.coord.equals2D(e.coord))return!1;var i=e.segmentIndex-t.segmentIndex;return e.isInterior()||i--,1===i&&(n[0]=t.segmentIndex+1,!0)}},{key:"findCollapsesFromInsertedNodes",value:function(t){for(var e=new Array(1).fill(null),n=this.iterator(),i=n.next();n.hasNext();){var r=n.next();this.findCollapseIndex(i,r,e)&&t.add(rt.valueOf(e[0])),i=r}}},{key:"getEdge",value:function(){return this.yh}},{key:"addEndpoints",value:function(){var t=this.yh.size()-1;this.add(this.yh.getCoordinate(0),0),this.add(this.yh.getCoordinate(t),t)}},{key:"createSplitEdge",value:function(t,e){var n=this.createSplitEdgePts(t,e);return new ln(n,this.yh.getData())}},{key:"add",value:function(t,e){var n=new rn(this.yh,t,e,this.yh.getSegmentOctant(e)),i=this.jh.get(n);return null!==i?(R.isTrue(i.coord.equals2D(t),"Found equal nodes with different coordinates"),i):(this.jh.put(n,n),n)}},{key:"checkSplitEdgesCorrectness",value:function(t){var e=this.yh.getCoordinates(),n=t.get(0).getCoordinate(0);if(!n.equals2D(e[0]))throw new D("bad split edge start point at "+n);var i=t.get(t.size()-1).getCoordinates(),r=i[i.length-1];if(!r.equals2D(e[e.length-1]))throw new D("bad split edge end point at "+r)}}],[{key:"constructor_",value:function(){this.jh=new Pe,this.yh=null;var t=arguments[0];this.yh=t}}]),e}(),an=function(){function e(){t(this,e)}return n(e,null,[{key:"octant",value:function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],n=arguments[1];if(0===t&&0===n)throw new w("Cannot compute the octant for point ( "+t+", "+n+" )");var i=Math.abs(t),r=Math.abs(n);return t>=0?n>=0?i>=r?0:1:i>=r?7:6:n>=0?i>=r?3:2:i>=r?4:5}if(arguments[0]instanceof q&&arguments[1]instanceof q){var s=arguments[0],o=arguments[1],a=o.x-s.x,u=o.y-s.y;if(0===a&&0===u)throw new w("Cannot compute the octant for two identical points "+s);return e.octant(a,u)}}}]),e}(),un=function(){function e(){t(this,e)}return n(e,[{key:"getCoordinates",value:function(){}},{key:"size",value:function(){}},{key:"getCoordinate",value:function(t){}},{key:"isClosed",value:function(){}},{key:"setData",value:function(t){}},{key:"getData",value:function(){}}]),e}(),hn=function(){function e(){t(this,e)}return n(e,[{key:"addIntersection",value:function(t,e){}},{key:"interfaces_",get:function(){return[un]}}]),e}(),ln=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getCoordinates",value:function(){return this.Xu}},{key:"size",value:function(){return this.Xu.length}},{key:"getCoordinate",value:function(t){return this.Xu[t]}},{key:"isClosed",value:function(){return this.Xu[0].equals(this.Xu[this.Xu.length-1])}},{key:"getSegmentOctant",value:function(t){return t===this.Xu.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))}},{key:"setData",value:function(t){this.We=t}},{key:"safeOctant",value:function(t,e){return t.equals2D(e)?0:an.octant(t,e)}},{key:"getData",value:function(){return this.We}},{key:"addIntersection",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(4===arguments.length){var n=arguments[1],i=arguments[3],r=new q(arguments[0].getIntersection(i));this.addIntersection(r,n)}}},{key:"toString",value:function(){return me.toLineString(new Xt(this.Xu))}},{key:"getNodeList",value:function(){return this.Bh}},{key:"addIntersectionNode",value:function(t,e){var n=e,i=n+1;if(i<this.Xu.length){var r=this.Xu[i];t.equals2D(r)&&(n=i)}return this.Bh.add(t,n)}},{key:"addIntersections",value:function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++)this.addIntersection(t,e,n,i)}},{key:"interfaces_",get:function(){return[hn]}}],[{key:"constructor_",value:function(){this.Bh=new on(this),this.Xu=null,this.We=null;var t=arguments[0],e=arguments[1];this.Xu=t,this.We=e}},{key:"getNodedSubstrings",value:function(){if(1===arguments.length){var t=arguments[0],n=new dt;return e.getNodedSubstrings(t,n),n}if(2===arguments.length)for(var i=arguments[1],r=arguments[0].iterator();r.hasNext();)r.next().getNodeList().addSplitEdges(i)}}]),e}(),cn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"minX",value:function(){return Math.min(this.p0.x,this.p1.x)}},{key:"orientationIndex",value:function(){if(arguments[0]instanceof e){var t=arguments[0],n=ht.index(this.p0,this.p1,t.p0),i=ht.index(this.p0,this.p1,t.p1);return n>=0&&i>=0||n<=0&&i<=0?Math.max(n,i):0}if(arguments[0]instanceof q){var r=arguments[0];return ht.index(this.p0,this.p1,r)}}},{key:"toGeometry",value:function(t){return t.createLineString([this.p0,this.p1])}},{key:"isVertical",value:function(){return this.p0.x===this.p1.x}},{key:"equals",value:function(t){if(!(t instanceof e))return!1;var n=t;return this.p0.equals(n.p0)&&this.p1.equals(n.p1)}},{key:"intersection",value:function(t){var e=new ge;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null}},{key:"project",value:function(){if(arguments[0]instanceof q){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new q(t);var n=this.projectionFactor(t),i=new q;return i.x=this.p0.x+n*(this.p1.x-this.p0.x),i.y=this.p0.y+n*(this.p1.y-this.p0.y),i}if(arguments[0]instanceof e){var r=arguments[0],s=this.projectionFactor(r.p0),o=this.projectionFactor(r.p1);if(s>=1&&o>=1)return null;if(s<=0&&o<=0)return null;var a=this.project(r.p0);s<0&&(a=this.p0),s>1&&(a=this.p1);var u=this.project(r.p1);return o<0&&(u=this.p0),o>1&&(u=this.p1),new e(a,u)}}},{key:"normalize",value:function(){this.p1.compareTo(this.p0)<0&&this.reverse()}},{key:"angle",value:function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)}},{key:"getCoordinate",value:function(t){return 0===t?this.p0:this.p1}},{key:"distancePerpendicular",value:function(t){return gt.pointToLinePerpendicular(t,this.p0,this.p1)}},{key:"minY",value:function(){return Math.min(this.p0.y,this.p1.y)}},{key:"midPoint",value:function(){return e.midPoint(this.p0,this.p1)}},{key:"projectionFactor",value:function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,i=e*e+n*n;return i<=0?T.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/i}},{key:"closestPoints",value:function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),i=T.MAX_VALUE,r=null,s=this.closestPoint(t.p0);i=s.distance(t.p0),n[0]=s,n[1]=t.p0;var o=this.closestPoint(t.p1);(r=o.distance(t.p1))<i&&(i=r,n[0]=o,n[1]=t.p1);var a=t.closestPoint(this.p0);(r=a.distance(this.p0))<i&&(i=r,n[0]=this.p0,n[1]=a);var u=t.closestPoint(this.p1);return(r=u.distance(this.p1))<i&&(i=r,n[0]=this.p1,n[1]=u),n}},{key:"closestPoint",value:function(t){var e=this.projectionFactor(t);return e>0&&e<1?this.project(t):this.p0.distance(t)<this.p1.distance(t)?this.p0:this.p1}},{key:"maxX",value:function(){return Math.max(this.p0.x,this.p1.x)}},{key:"getLength",value:function(){return this.p0.distance(this.p1)}},{key:"compareTo",value:function(t){var e=t,n=this.p0.compareTo(e.p0);return 0!==n?n:this.p1.compareTo(e.p1)}},{key:"reverse",value:function(){var t=this.p0;this.p0=this.p1,this.p1=t}},{key:"equalsTopo",value:function(t){return this.p0.equals(t.p0)&&this.p1.equals(t.p1)||this.p0.equals(t.p1)&&this.p1.equals(t.p0)}},{key:"lineIntersection",value:function(t){return yt.intersection(this.p0,this.p1,t.p0,t.p1)}},{key:"maxY",value:function(){return Math.max(this.p0.y,this.p1.y)}},{key:"pointAlongOffset",value:function(t,e){var n=this.p0.x+t*(this.p1.x-this.p0.x),i=this.p0.y+t*(this.p1.y-this.p0.y),r=this.p1.x-this.p0.x,s=this.p1.y-this.p0.y,o=Math.sqrt(r*r+s*s),a=0,u=0;if(0!==e){if(o<=0)throw new IllegalStateException("Cannot compute offset from zero-length line segment");a=e*r/o,u=e*s/o}return new q(n-u,i+a)}},{key:"setCoordinates",value:function(){if(1===arguments.length){var t=arguments[0];this.setCoordinates(t.p0,t.p1)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.p0.x=e.x,this.p0.y=e.y,this.p1.x=n.x,this.p1.y=n.y}}},{key:"segmentFraction",value:function(t){var e=this.projectionFactor(t);return e<0?e=0:(e>1||T.isNaN(e))&&(e=1),e}},{key:"toString",value:function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"}},{key:"isHorizontal",value:function(){return this.p0.y===this.p1.y}},{key:"reflect",value:function(t){var e=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=e*e+n*n,s=e*e-n*n,o=t.getX(),a=t.getY();return new q((-s*o-2*e*n*a-2*e*i)/r,(s*a-2*e*n*o-2*n*i)/r)}},{key:"distance",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return gt.segmentToSegment(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof q){var n=arguments[0];return gt.pointToSegment(n,this.p0,this.p1)}}},{key:"pointAlong",value:function(t){var e=new q;return e.x=this.p0.x+t*(this.p1.x-this.p0.x),e.y=this.p0.y+t*(this.p1.y-this.p0.y),e}},{key:"hashCode",value:function(){var t=T.doubleToLongBits(this.p0.x);t^=31*T.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=T.doubleToLongBits(this.p1.x);return n^=31*T.doubleToLongBits(this.p1.y),e^Math.trunc(n)^Math.trunc(n>>32)}},{key:"interfaces_",get:function(){return[b,_]}}],[{key:"constructor_",value:function(){if(this.p0=null,this.p1=null,0===arguments.length)e.constructor_.call(this,new q,new q);else if(1===arguments.length){var t=arguments[0];e.constructor_.call(this,t.p0,t.p1)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.p0=n,this.p1=i}else if(4===arguments.length){var r=arguments[0],s=arguments[1],o=arguments[2],a=arguments[3];e.constructor_.call(this,new q(r,s),new q(o,a))}}},{key:"midPoint",value:function(t,e){return new q((t.x+e.x)/2,(t.y+e.y)/2)}}]),e}(),fn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"overlap",value:function(){if(2===arguments.length);else if(4===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[3];arguments[0].getLineSegment(t,this.Lh),e.getLineSegment(n,this.Hh),this.overlap(this.Lh,this.Hh)}}}],[{key:"constructor_",value:function(){this.Lh=new cn,this.Hh=new cn}}]),e}(),dn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getLineSegment",value:function(t,e){e.p0=this.Xu[t],e.p1=this.Xu[t+1]}},{key:"computeSelect",value:function(t,e,n,i){var r=this.Xu[e],s=this.Xu[n];if(n-e==1)return i.select(this,e),null;if(!t.intersects(r,s))return null;var o=Math.trunc((e+n)/2);e<o&&this.computeSelect(t,e,o,i),o<n&&this.computeSelect(t,o,n,i)}},{key:"getCoordinates",value:function(){for(var t=new Array(this.Vh-this.Wh+1).fill(null),e=0,n=this.Wh;n<=this.Vh;n++)t[e++]=this.Xu[n];return t}},{key:"computeOverlaps",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.computeOverlaps(this.Wh,this.Vh,t,t.Wh,t.Vh,e)}else if(6===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],s=arguments[3],o=arguments[4],a=arguments[5];if(i-n==1&&o-s==1)return a.overlap(this,n,r,s),null;if(!this.overlaps(n,i,r,s,o))return null;var u=Math.trunc((n+i)/2),h=Math.trunc((s+o)/2);n<u&&(s<h&&this.computeOverlaps(n,u,r,s,h,a),h<o&&this.computeOverlaps(n,u,r,h,o,a)),u<i&&(s<h&&this.computeOverlaps(u,i,r,s,h,a),h<o&&this.computeOverlaps(u,i,r,h,o,a))}}},{key:"setId",value:function(t){this._id=t}},{key:"select",value:function(t,e){this.computeSelect(t,this.Wh,this.Vh,e)}},{key:"getEnvelope",value:function(){if(null===this.Eu){var t=this.Xu[this.Wh],e=this.Xu[this.Vh];this.Eu=new B(t,e)}return this.Eu}},{key:"overlaps",value:function(t,e,n,i,r){return B.intersects(this.Xu[t],this.Xu[e],n.Xu[i],n.Xu[r])}},{key:"getEndIndex",value:function(){return this.Vh}},{key:"getStartIndex",value:function(){return this.Wh}},{key:"getContext",value:function(){return this.fe}},{key:"getId",value:function(){return this._id}}],[{key:"constructor_",value:function(){this.Xu=null,this.Wh=null,this.Vh=null,this.Eu=null,this.fe=null,this._id=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this.Xu=t,this.Wh=e,this.Vh=n,this.fe=i}}]),e}(),pn=function(){function e(){t(this,e)}return n(e,null,[{key:"findChainEnd",value:function(t,e){for(var n=e;n<t.length-1&&t[n].equals2D(t[n+1]);)n++;if(n>=t.length-1)return t.length-1;for(var i=Ne.quadrant(t[n],t[n+1]),r=e+1;r<t.length&&(t[r-1].equals2D(t[r])||Ne.quadrant(t[r-1],t[r])===i);)r++;return r-1}},{key:"getChains",value:function(){if(1===arguments.length){var t=arguments[0];return e.getChains(t,null)}if(2===arguments.length){var n=arguments[0],i=arguments[1],r=new dt,s=0;do{var o=e.findChainEnd(n,s),a=new dn(n,s,o,i);r.add(a),s=o}while(s<n.length-1);return r}}}]),e}(),vn=function(){function e(){t(this,e)}return n(e,[{key:"computeNodes",value:function(t){}},{key:"getNodedSubstrings",value:function(){}}]),e}(),yn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"setSegmentIntersector",value:function(t){this.Gh=t}},{key:"interfaces_",get:function(){return[vn]}}],[{key:"constructor_",value:function(){if(this.Gh=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setSegmentIntersector(t)}}}]),e}(),mn=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),e=r.call(this),s.constructor_.apply(h(e),arguments),e}return n(s,[{key:"getMonotoneChains",value:function(){return this.Qh}},{key:"getNodedSubstrings",value:function(){return ln.getNodedSubstrings(this.Kh)}},{key:"getIndex",value:function(){return this._index}},{key:"add",value:function(t){for(var e=pn.getChains(t.getCoordinates(),t).iterator();e.hasNext();){var n=e.next();n.setId(this.Xh++),this._index.insert(n.getEnvelope(),n),this.Qh.add(n)}}},{key:"computeNodes",value:function(t){this.Kh=t;for(var e=t.iterator();e.hasNext();)this.add(e.next());this.intersectChains()}},{key:"intersectChains",value:function(){for(var t=new wn(this.Gh),e=this.Qh.iterator();e.hasNext();)for(var n=e.next(),i=this._index.query(n.getEnvelope()).iterator();i.hasNext();){var r=i.next();if(r.getId()>n.getId()&&(n.computeOverlaps(r,t),this.Zh++),this.Gh.isDone())return null}}}],[{key:"constructor_",value:function(){if(this.Qh=new dt,this._index=new tn,this.Xh=0,this.Kh=null,this.Zh=0,0===arguments.length);else if(1===arguments.length){var t=arguments[0];yn.constructor_.call(this,t)}}}]),s}(yn),wn=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"overlap",value:function(){if(4!==arguments.length)return c(r(o.prototype),"overlap",this).apply(this,arguments);var t=arguments[1],e=arguments[2],n=arguments[3],i=arguments[0].getContext(),s=e.getContext();this.Yh.processIntersections(i,t,s,n)}}],[{key:"constructor_",value:function(){this.Yh=null;var t=arguments[0];this.Yh=t}}]),o}(fn);mn.SegmentOverlapAction=wn;var gn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"isDeletable",value:function(t,e,n,i){var r=this.Jh[t],s=this.Jh[e],o=this.Jh[n];return!!this.isConcave(r,s,o)&&!!this.isShallow(r,s,o,i)&&this.isShallowSampled(r,s,t,n,i)}},{key:"deleteShallowConcavities",value:function(){for(var t=1,n=this.findNextNonDeletedIndex(t),i=this.findNextNonDeletedIndex(n),r=!1;i<this.Jh.length;){var s=!1;this.isDeletable(t,n,i,this.el)&&(this.Nr[n]=e.DELETE,s=!0,r=!0),t=s?i:n,n=this.findNextNonDeletedIndex(t),i=this.findNextNonDeletedIndex(n)}return r}},{key:"isShallowConcavity",value:function(t,e,n,i){return ht.index(t,e,n)===this.nl&>.pointToSegment(e,t,n)<i}},{key:"isShallowSampled",value:function(t,n,i,r,s){var o=Math.trunc((r-i)/e.NUM_PTS_TO_CHECK);o<=0&&(o=1);for(var a=i;a<r;a+=o)if(!this.isShallow(t,n,this.Jh[a],s))return!1;return!0}},{key:"isConcave",value:function(t,e,n){return ht.index(t,e,n)===this.nl}},{key:"simplify",value:function(t){this.el=Math.abs(t),t<0&&(this.nl=ht.CLOCKWISE),this.Nr=new Array(this.Jh.length).fill(null);var e=!1;do{e=this.deleteShallowConcavities()}while(e);return this.collapseLine()}},{key:"findNextNonDeletedIndex",value:function(t){for(var n=t+1;n<this.Jh.length&&this.Nr[n]===e.DELETE;)n++;return n}},{key:"isShallow",value:function(t,e,n,i){return gt.pointToSegment(e,t,n)<i}},{key:"collapseLine",value:function(){for(var t=new Vt,n=0;n<this.Jh.length;n++)this.Nr[n]!==e.DELETE&&t.add(this.Jh[n]);return t.toCoordinateArray()}}],[{key:"constructor_",value:function(){this.Jh=null,this.el=null,this.Nr=null,this.nl=ht.COUNTERCLOCKWISE;var t=arguments[0];this.Jh=t}},{key:"simplify",value:function(t,n){return new e(t).simplify(n)}}]),e}();gn.INIT=0,gn.DELETE=1,gn.KEEP=1,gn.NUM_PTS_TO_CHECK=10;var bn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getCoordinates",value:function(){return this.il.toArray(e.COORDINATE_ARRAY_TYPE)}},{key:"setPrecisionModel",value:function(t){this.Fu=t}},{key:"addPt",value:function(t){var e=new q(t);if(this.Fu.makePrecise(e),this.isRedundant(e))return null;this.il.add(e)}},{key:"reverse",value:function(){}},{key:"addPts",value:function(t,e){if(e)for(var n=0;n<t.length;n++)this.addPt(t[n]);else for(var i=t.length-1;i>=0;i--)this.addPt(t[i])}},{key:"isRedundant",value:function(t){if(this.il.size()<1)return!1;var e=this.il.get(this.il.size()-1);return t.distance(e)<this.rl}},{key:"toString",value:function(){return(new re).createLineString(this.getCoordinates()).toString()}},{key:"closeRing",value:function(){if(this.il.size()<1)return null;var t=new q(this.il.get(0)),e=this.il.get(this.il.size()-1);if(t.equals(e))return null;this.il.add(t)}},{key:"setMinimumVertexDistance",value:function(t){this.rl=t}}],[{key:"constructor_",value:function(){this.il=null,this.Fu=null,this.rl=0,this.il=new dt}}]),e}();bn.COORDINATE_ARRAY_TYPE=new Array(0).fill(null);var xn=function(){function e(){t(this,e)}return n(e,null,[{key:"toDegrees",value:function(t){return 180*t/Math.PI}},{key:"normalize",value:function(t){for(;t>Math.PI;)t-=e.PI_TIMES_2;for(;t<=-Math.PI;)t+=e.PI_TIMES_2;return t}},{key:"angle",value:function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){var e=arguments[0],n=arguments[1],i=n.x-e.x,r=n.y-e.y;return Math.atan2(r,i)}}},{key:"isAcute",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y;return i*(n.x-e.x)+r*(n.y-e.y)>0}},{key:"isObtuse",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y;return i*(n.x-e.x)+r*(n.y-e.y)<0}},{key:"interiorAngle",value:function(t,n,i){var r=e.angle(n,t),s=e.angle(n,i);return Math.abs(s-r)}},{key:"normalizePositive",value:function(t){if(t<0){for(;t<0;)t+=e.PI_TIMES_2;t>=e.PI_TIMES_2&&(t=0)}else{for(;t>=e.PI_TIMES_2;)t-=e.PI_TIMES_2;t<0&&(t=0)}return t}},{key:"angleBetween",value:function(t,n,i){var r=e.angle(n,t),s=e.angle(n,i);return e.diff(r,s)}},{key:"diff",value:function(t,e){var n=null;return(n=t<e?e-t:t-e)>Math.PI&&(n=2*Math.PI-n),n}},{key:"toRadians",value:function(t){return t*Math.PI/180}},{key:"getTurn",value:function(t,n){var i=Math.sin(n-t);return i>0?e.COUNTERCLOCKWISE:i<0?e.CLOCKWISE:e.NONE}},{key:"angleBetweenOriented",value:function(t,n,i){var r=e.angle(n,t),s=e.angle(n,i)-r;return s<=-Math.PI?s+e.PI_TIMES_2:s>Math.PI?s-e.PI_TIMES_2:s}}]),e}();xn.PI_TIMES_2=2*Math.PI,xn.PI_OVER_2=Math.PI/2,xn.PI_OVER_4=Math.PI/4,xn.COUNTERCLOCKWISE=ht.COUNTERCLOCKWISE,xn.CLOCKWISE=ht.CLOCKWISE,xn.NONE=ht.COLLINEAR;var _n=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"addNextSegment",value:function(t,e){if(this.sl=this.ol,this.ol=this.al,this.al=t,this.ul.setCoordinates(this.sl,this.ol),this.computeOffsetSegment(this.ul,this.hl,this.zh,this.ll),this.cl.setCoordinates(this.ol,this.al),this.computeOffsetSegment(this.cl,this.hl,this.zh,this.fl),this.ol.equals(this.al))return null;var n=ht.index(this.sl,this.ol,this.al),i=n===ht.CLOCKWISE&&this.hl===Z.LEFT||n===ht.COUNTERCLOCKWISE&&this.hl===Z.RIGHT;0===n?this.addCollinear(e):i?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)}},{key:"addLineEndCap",value:function(t,e){var n=new cn(t,e),i=new cn;this.computeOffsetSegment(n,Z.LEFT,this.zh,i);var r=new cn;this.computeOffsetSegment(n,Z.RIGHT,this.zh,r);var s=e.x-t.x,o=e.y-t.y,a=Math.atan2(o,s);switch(this.dl.getEndCapStyle()){case y.CAP_ROUND:this.pl.addPt(i.p1),this.addDirectedFillet(e,a+Math.PI/2,a-Math.PI/2,ht.CLOCKWISE,this.zh),this.pl.addPt(r.p1);break;case y.CAP_FLAT:this.pl.addPt(i.p1),this.pl.addPt(r.p1);break;case y.CAP_SQUARE:var u=new q;u.x=Math.abs(this.zh)*Math.cos(a),u.y=Math.abs(this.zh)*Math.sin(a);var h=new q(i.p1.x+u.x,i.p1.y+u.y),l=new q(r.p1.x+u.x,r.p1.y+u.y);this.pl.addPt(h),this.pl.addPt(l)}}},{key:"getCoordinates",value:function(){return this.pl.getCoordinates()}},{key:"addMitreJoin",value:function(t,e,n,i){var r=yt.intersection(e.p0,e.p1,n.p0,n.p1);if(null!==r&&(i<=0?1:r.distance(t)/Math.abs(i))<=this.dl.getMitreLimit())return this.pl.addPt(r),null;this.addLimitedMitreJoin(e,n,i,this.dl.getMitreLimit())}},{key:"addOutsideTurn",value:function(t,n){if(this.ll.p1.distance(this.fl.p0)<this.zh*e.OFFSET_SEGMENT_SEPARATION_FACTOR)return this.pl.addPt(this.ll.p1),null;this.dl.getJoinStyle()===y.JOIN_MITRE?this.addMitreJoin(this.ol,this.ll,this.fl,this.zh):this.dl.getJoinStyle()===y.JOIN_BEVEL?this.addBevelJoin(this.ll,this.fl):(n&&this.pl.addPt(this.ll.p1),this.addCornerFillet(this.ol,this.ll.p1,this.fl.p0,t,this.zh),this.pl.addPt(this.fl.p0))}},{key:"createSquare",value:function(t){this.pl.addPt(new q(t.x+this.zh,t.y+this.zh)),this.pl.addPt(new q(t.x+this.zh,t.y-this.zh)),this.pl.addPt(new q(t.x-this.zh,t.y-this.zh)),this.pl.addPt(new q(t.x-this.zh,t.y+this.zh)),this.pl.closeRing()}},{key:"addSegments",value:function(t,e){this.pl.addPts(t,e)}},{key:"addFirstSegment",value:function(){this.pl.addPt(this.fl.p0)}},{key:"addCornerFillet",value:function(t,e,n,i,r){var s=e.x-t.x,o=e.y-t.y,a=Math.atan2(o,s),u=n.x-t.x,h=n.y-t.y,l=Math.atan2(h,u);i===ht.CLOCKWISE?a<=l&&(a+=2*Math.PI):a>=l&&(a-=2*Math.PI),this.pl.addPt(e),this.addDirectedFillet(t,a,l,i,r),this.pl.addPt(n)}},{key:"addLastSegment",value:function(){this.pl.addPt(this.fl.p1)}},{key:"initSideSegments",value:function(t,e,n){this.ol=t,this.al=e,this.hl=n,this.cl.setCoordinates(t,e),this.computeOffsetSegment(this.cl,n,this.zh,this.fl)}},{key:"addLimitedMitreJoin",value:function(t,e,n,i){var r=this.ul.p1,s=xn.angle(r,this.ul.p0),o=xn.angleBetweenOriented(this.ul.p0,r,this.cl.p1)/2,a=xn.normalize(s+o),u=xn.normalize(a+Math.PI),h=i*n,l=n-h*Math.abs(Math.sin(o)),c=r.x+h*Math.cos(u),f=r.y+h*Math.sin(u),d=new q(c,f),p=new cn(r,d),v=p.pointAlongOffset(1,l),y=p.pointAlongOffset(1,-l);this.hl===Z.LEFT?(this.pl.addPt(v),this.pl.addPt(y)):(this.pl.addPt(y),this.pl.addPt(v))}},{key:"addDirectedFillet",value:function(t,e,n,i,r){var s=i===ht.CLOCKWISE?-1:1,o=Math.abs(e-n),a=Math.trunc(o/this.vl+.5);if(a<1)return null;for(var u=o/a,h=new q,l=0;l<a;l++){var c=e+s*l*u;h.x=t.x+r*Math.cos(c),h.y=t.y+r*Math.sin(c),this.pl.addPt(h)}}},{key:"computeOffsetSegment",value:function(t,e,n,i){var r=e===Z.LEFT?1:-1,s=t.p1.x-t.p0.x,o=t.p1.y-t.p0.y,a=Math.sqrt(s*s+o*o),u=r*n*s/a,h=r*n*o/a;i.p0.x=t.p0.x-h,i.p0.y=t.p0.y+u,i.p1.x=t.p1.x-h,i.p1.y=t.p1.y+u}},{key:"addInsideTurn",value:function(t,n){if(this.yl.computeIntersection(this.ll.p0,this.ll.p1,this.fl.p0,this.fl.p1),this.yl.hasIntersection())this.pl.addPt(this.yl.getIntersection(0));else if(this.ml=!0,this.ll.p1.distance(this.fl.p0)<this.zh*e.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR)this.pl.addPt(this.ll.p1);else{if(this.pl.addPt(this.ll.p1),this.wl>0){var i=new q((this.wl*this.ll.p1.x+this.ol.x)/(this.wl+1),(this.wl*this.ll.p1.y+this.ol.y)/(this.wl+1));this.pl.addPt(i);var r=new q((this.wl*this.fl.p0.x+this.ol.x)/(this.wl+1),(this.wl*this.fl.p0.y+this.ol.y)/(this.wl+1));this.pl.addPt(r)}else this.pl.addPt(this.ol);this.pl.addPt(this.fl.p0)}}},{key:"createCircle",value:function(t){var e=new q(t.x+this.zh,t.y);this.pl.addPt(e),this.addDirectedFillet(t,0,2*Math.PI,-1,this.zh),this.pl.closeRing()}},{key:"addBevelJoin",value:function(t,e){this.pl.addPt(t.p1),this.pl.addPt(e.p0)}},{key:"init",value:function(t){this.zh=t,this.gl=t*(1-Math.cos(this.vl/2)),this.pl=new bn,this.pl.setPrecisionModel(this.Fu),this.pl.setMinimumVertexDistance(t*e.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}},{key:"addCollinear",value:function(t){this.yl.computeIntersection(this.sl,this.ol,this.ol,this.al),this.yl.getIntersectionNum()>=2&&(this.dl.getJoinStyle()===y.JOIN_BEVEL||this.dl.getJoinStyle()===y.JOIN_MITRE?(t&&this.pl.addPt(this.ll.p1),this.pl.addPt(this.fl.p0)):this.addCornerFillet(this.ol,this.ll.p1,this.fl.p0,ht.CLOCKWISE,this.zh))}},{key:"closeRing",value:function(){this.pl.closeRing()}},{key:"hasNarrowConcaveAngle",value:function(){return this.ml}}],[{key:"constructor_",value:function(){this.gl=0,this.vl=null,this.wl=1,this.pl=null,this.zh=0,this.Fu=null,this.dl=null,this.yl=null,this.sl=null,this.ol=null,this.al=null,this.ul=new cn,this.cl=new cn,this.ll=new cn,this.fl=new cn,this.hl=0,this.ml=!1;var t=arguments[0],n=arguments[1],i=arguments[2];this.Fu=t,this.dl=n,this.yl=new ge,this.vl=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===y.JOIN_ROUND&&(this.wl=e.MAX_CLOSING_SEG_LEN_FACTOR),this.init(i)}}]),e}();_n.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,_n.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,_n.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,_n.MAX_CLOSING_SEG_LEN_FACTOR=80;var kn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getOffsetCurve",value:function(t,e){if(this.zh=e,0===e)return null;var n=e<0,i=Math.abs(e),r=this.getSegGen(i);t.length<=1?this.computePointCurve(t[0],r):this.computeOffsetCurve(t,n,r);var s=r.getCoordinates();return n&&Wt.reverse(s),s}},{key:"computeSingleSidedBufferCurve",value:function(t,e,n){var i=this.simplifyTolerance(this.zh);if(e){n.addSegments(t,!0);var r=gn.simplify(t,-i),s=r.length-1;n.initSideSegments(r[s],r[s-1],Z.LEFT),n.addFirstSegment();for(var o=s-2;o>=0;o--)n.addNextSegment(r[o],!0)}else{n.addSegments(t,!1);var a=gn.simplify(t,i),u=a.length-1;n.initSideSegments(a[0],a[1],Z.LEFT),n.addFirstSegment();for(var h=2;h<=u;h++)n.addNextSegment(a[h],!0)}n.addLastSegment(),n.closeRing()}},{key:"computeRingBufferCurve",value:function(t,e,n){var i=this.simplifyTolerance(this.zh);e===Z.RIGHT&&(i=-i);var r=gn.simplify(t,i),s=r.length-1;n.initSideSegments(r[s-1],r[0],e);for(var o=1;o<=s;o++){var a=1!==o;n.addNextSegment(r[o],a)}n.closeRing()}},{key:"computeLineBufferCurve",value:function(t,e){var n=this.simplifyTolerance(this.zh),i=gn.simplify(t,n),r=i.length-1;e.initSideSegments(i[0],i[1],Z.LEFT);for(var s=2;s<=r;s++)e.addNextSegment(i[s],!0);e.addLastSegment(),e.addLineEndCap(i[r-1],i[r]);var o=gn.simplify(t,-n),a=o.length-1;e.initSideSegments(o[a],o[a-1],Z.LEFT);for(var u=a-2;u>=0;u--)e.addNextSegment(o[u],!0);e.addLastSegment(),e.addLineEndCap(o[1],o[0]),e.closeRing()}},{key:"computePointCurve",value:function(t,e){switch(this.dl.getEndCapStyle()){case y.CAP_ROUND:e.createCircle(t);break;case y.CAP_SQUARE:e.createSquare(t)}}},{key:"getLineCurve",value:function(t,e){if(this.zh=e,this.isLineOffsetEmpty(e))return null;var n=Math.abs(e),i=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],i);else if(this.dl.isSingleSided()){var r=e<0;this.computeSingleSidedBufferCurve(t,r,i)}else this.computeLineBufferCurve(t,i);return i.getCoordinates()}},{key:"getBufferParameters",value:function(){return this.dl}},{key:"simplifyTolerance",value:function(t){return t*this.dl.getSimplifyFactor()}},{key:"getRingCurve",value:function(t,n,i){if(this.zh=i,t.length<=2)return this.getLineCurve(t,i);if(0===i)return e.copyCoordinates(t);var r=this.getSegGen(i);return this.computeRingBufferCurve(t,n,r),r.getCoordinates()}},{key:"computeOffsetCurve",value:function(t,e,n){var i=this.simplifyTolerance(this.zh);if(e){var r=gn.simplify(t,-i),s=r.length-1;n.initSideSegments(r[s],r[s-1],Z.LEFT),n.addFirstSegment();for(var o=s-2;o>=0;o--)n.addNextSegment(r[o],!0)}else{var a=gn.simplify(t,i),u=a.length-1;n.initSideSegments(a[0],a[1],Z.LEFT),n.addFirstSegment();for(var h=2;h<=u;h++)n.addNextSegment(a[h],!0)}n.addLastSegment()}},{key:"isLineOffsetEmpty",value:function(t){return 0===t||t<0&&!this.dl.isSingleSided()}},{key:"getSegGen",value:function(t){return new _n(this.Fu,this.dl,t)}}],[{key:"constructor_",value:function(){this.zh=0,this.Fu=null,this.dl=null;var t=arguments[0],e=arguments[1];this.Fu=t,this.dl=e}},{key:"copyCoordinates",value:function(t){for(var e=new Array(t.length).fill(null),n=0;n<e.length;n++)e[n]=new q(t[n]);return e}}]),e}(),$n=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"findStabbedSegments",value:function(){if(1===arguments.length){for(var t=arguments[0],e=new dt,n=this.xl.iterator();n.hasNext();){var i=n.next(),r=i.getEnvelope();t.y<r.getMinY()||t.y>r.getMaxY()||this.findStabbedSegments(t,i.getDirectedEdges(),e)}return e}if(3===arguments.length)if(nt(arguments[2],tt)&&arguments[0]instanceof q&&arguments[1]instanceof Ue){for(var s=arguments[0],o=arguments[1],a=arguments[2],u=o.getEdge().getCoordinates(),h=0;h<u.length-1;h++)if(this._l.p0=u[h],this._l.p1=u[h+1],this._l.p0.y>this._l.p1.y&&this._l.reverse(),!(Math.max(this._l.p0.x,this._l.p1.x)<s.x||this._l.isHorizontal()||s.y<this._l.p0.y||s.y>this._l.p1.y||ht.index(this._l.p0,this._l.p1,s)===ht.RIGHT)){var l=o.getDepth(Z.LEFT);this._l.p0.equals(u[h])||(l=o.getDepth(Z.RIGHT));var c=new Sn(this._l,l);a.add(c)}}else if(nt(arguments[2],tt)&&arguments[0]instanceof q&&nt(arguments[1],tt))for(var f=arguments[0],d=arguments[2],p=arguments[1].iterator();p.hasNext();){var v=p.next();v.isForward()&&this.findStabbedSegments(f,v,d)}}},{key:"getDepth",value:function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:Qe.min(e).kl}}],[{key:"constructor_",value:function(){this.xl=null,this._l=new cn;var t=arguments[0];this.xl=t}}]),e}(),Sn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"compareTo",value:function(t){var e=t;if(this.$l.minX()>=e.$l.maxX())return 1;if(this.$l.maxX()<=e.$l.minX())return-1;var n=this.$l.orientationIndex(e.$l);return 0!==n||0!=(n=-1*e.$l.orientationIndex(this.$l))?n:this.$l.compareTo(e.$l)}},{key:"compareX",value:function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.p1)}},{key:"toString",value:function(){return this.$l.toString()}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this.$l=null,this.kl=null;var t=arguments[0],e=arguments[1];this.$l=new cn(t),this.kl=e}}]),e}();$n.DepthSegment=Sn;var Mn=function(e){i(s,e);var r=l(s);function s(){var e;return t(this,s),e=r.call(this),s.constructor_.apply(h(e),arguments),e}return n(s,null,[{key:"constructor_",value:function(){m.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}]),s}(m),En=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getY",value:function(){var t=this.y/this.w;if(T.isNaN(t)||T.isInfinite(t))throw new Mn;return t}},{key:"getX",value:function(){var t=this.x/this.w;if(T.isNaN(t)||T.isInfinite(t))throw new Mn;return t}},{key:"getCoordinate",value:function(){var t=new q;return t.x=this.getX(),t.y=this.getY(),t}}],[{key:"constructor_",value:function(){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){var t=arguments[0];this.x=t.x,this.y=t.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var n=arguments[0],i=arguments[1];this.x=n,this.y=i,this.w=1}else if(arguments[0]instanceof e&&arguments[1]instanceof e){var r=arguments[0],s=arguments[1];this.x=r.y*s.w-s.y*r.w,this.y=s.x*r.w-r.x*s.w,this.w=r.x*s.y-s.x*r.y}else if(arguments[0]instanceof q&&arguments[1]instanceof q){var o=arguments[0],a=arguments[1];this.x=o.y-a.y,this.y=a.x-o.x,this.w=o.x*a.y-a.x*o.y}}else if(3===arguments.length){var u=arguments[0],h=arguments[1],l=arguments[2];this.x=u,this.y=h,this.w=l}else if(4===arguments.length){var c=arguments[0],f=arguments[1],d=arguments[2],p=arguments[3],v=c.y-f.y,y=f.x-c.x,m=c.x*f.y-f.x*c.y,w=d.y-p.y,g=p.x-d.x,b=d.x*p.y-p.x*d.y;this.x=y*b-g*m,this.y=w*m-v*b,this.w=v*g-w*y}}}]),e}(),Cn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"area",value:function(){return e.area(this.p0,this.p1,this.p2)}},{key:"signedArea",value:function(){return e.signedArea(this.p0,this.p1,this.p2)}},{key:"interpolateZ",value:function(t){if(null===t)throw new w("Supplied point is null.");return e.interpolateZ(t,this.p0,this.p1,this.p2)}},{key:"longestSideLength",value:function(){return e.longestSideLength(this.p0,this.p1,this.p2)}},{key:"isAcute",value:function(){return e.isAcute(this.p0,this.p1,this.p2)}},{key:"circumcentre",value:function(){return e.circumcentre(this.p0,this.p1,this.p2)}},{key:"area3D",value:function(){return e.area3D(this.p0,this.p1,this.p2)}},{key:"centroid",value:function(){return e.centroid(this.p0,this.p1,this.p2)}},{key:"inCentre",value:function(){return e.inCentre(this.p0,this.p1,this.p2)}}],[{key:"constructor_",value:function(){this.p0=null,this.p1=null,this.p2=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.p0=t,this.p1=e,this.p2=n}},{key:"area",value:function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2)}},{key:"signedArea",value:function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2}},{key:"det",value:function(t,e,n,i){return t*i-e*n}},{key:"interpolateZ",value:function(t,e,n,i){var r=e.x,s=e.y,o=n.x-r,a=i.x-r,u=n.y-s,h=i.y-s,l=o*h-a*u,c=t.x-r,f=t.y-s,d=(h*c-a*f)/l,p=(-u*c+o*f)/l;return e.getZ()+d*(n.getZ()-e.getZ())+p*(i.getZ()-e.getZ())}},{key:"longestSideLength",value:function(t,e,n){var i=t.distance(e),r=e.distance(n),s=n.distance(t),o=i;return r>o&&(o=r),s>o&&(o=s),o}},{key:"circumcentreDD",value:function(t,e,n){var i=ot.valueOf(t.x).subtract(n.x),r=ot.valueOf(t.y).subtract(n.y),s=ot.valueOf(e.x).subtract(n.x),o=ot.valueOf(e.y).subtract(n.y),a=ot.determinant(i,r,s,o).multiply(2),u=i.sqr().add(r.sqr()),h=s.sqr().add(o.sqr()),l=ot.determinant(r,u,o,h),c=ot.determinant(i,u,s,h),f=ot.valueOf(n.x).subtract(l.divide(a)).doubleValue(),d=ot.valueOf(n.y).add(c.divide(a)).doubleValue();return new q(f,d)}},{key:"isAcute",value:function(t,e,n){return!!xn.isAcute(t,e,n)&&!!xn.isAcute(e,n,t)&&!!xn.isAcute(n,t,e)}},{key:"circumcentre",value:function(t,n,i){var r=i.x,s=i.y,o=t.x-r,a=t.y-s,u=n.x-r,h=n.y-s,l=2*e.det(o,a,u,h),c=e.det(a,o*o+a*a,h,u*u+h*h),f=e.det(o,o*o+a*a,u,u*u+h*h);return new q(r-c/l,s+f/l)}},{key:"perpendicularBisector",value:function(t,e){var n=e.x-t.x,i=e.y-t.y,r=new En(t.x+n/2,t.y+i/2,1),s=new En(t.x-i+n/2,t.y+n+i/2,1);return new En(r,s)}},{key:"angleBisector",value:function(t,e,n){var i=e.distance(t),r=i/(i+e.distance(n)),s=n.x-t.x,o=n.y-t.y;return new q(t.x+r*s,t.y+r*o)}},{key:"area3D",value:function(t,e,n){var i=e.x-t.x,r=e.y-t.y,s=e.getZ()-t.getZ(),o=n.x-t.x,a=n.y-t.y,u=n.getZ()-t.getZ(),h=r*u-s*a,l=s*o-i*u,c=i*a-r*o,f=h*h+l*l+c*c;return Math.sqrt(f)/2}},{key:"centroid",value:function(t,e,n){var i=(t.x+e.x+n.x)/3,r=(t.y+e.y+n.y)/3;return new q(i,r)}},{key:"inCentre",value:function(t,e,n){var i=e.distance(n),r=t.distance(n),s=t.distance(e),o=i+r+s,a=(i*t.x+r*e.x+s*n.x)/o,u=(i*t.y+r*e.y+s*n.y)/o;return new q(a,u)}}]),e}(),An=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"addRingSide",value:function(t,e,n,i,r){if(0===e&&t.length<qt.MINIMUM_VALID_SIZE)return null;var s=i,o=r;t.length>=qt.MINIMUM_VALID_SIZE&&ht.isCCW(t)&&(s=r,o=i,n=Z.opposite(n));var a=this.Sl.getRingCurve(t,n,e);this.addCurve(a,s,o)}},{key:"addRingBothSides",value:function(t,e){this.addRingSide(t,e,Z.LEFT,H.EXTERIOR,H.INTERIOR),this.addRingSide(t,e,Z.RIGHT,H.INTERIOR,H.EXTERIOR)}},{key:"addPoint",value:function(t){if(this.zh<=0)return null;var e=t.getCoordinates(),n=this.Sl.getLineCurve(e,this.zh);this.addCurve(n,H.EXTERIOR,H.INTERIOR)}},{key:"addPolygon",value:function(t){var e=this.zh,n=Z.LEFT;this.zh<0&&(e=-this.zh,n=Z.RIGHT);var i=t.getExteriorRing(),r=Wt.removeRepeatedPoints(i.getCoordinates());if(this.zh<0&&this.isErodedCompletely(i,this.zh))return null;if(this.zh<=0&&r.length<3)return null;this.addRingSide(r,e,n,H.EXTERIOR,H.INTERIOR);for(var s=0;s<t.getNumInteriorRing();s++){var o=t.getInteriorRingN(s),a=Wt.removeRepeatedPoints(o.getCoordinates());this.zh>0&&this.isErodedCompletely(o,-this.zh)||this.addRingSide(a,e,Z.opposite(n),H.INTERIOR,H.EXTERIOR)}}},{key:"isTriangleErodedCompletely",value:function(t,e){var n=new Cn(t[0],t[1],t[2]),i=n.inCentre();return gt.pointToSegment(i,n.p0,n.p1)<Math.abs(e)}},{key:"addLineString",value:function(t){if(this.Sl.isLineOffsetEmpty(this.zh))return null;var e=Wt.removeRepeatedPoints(t.getCoordinates());if(Wt.isRing(e)&&!this.Sl.getBufferParameters().isSingleSided())this.addRingBothSides(e,this.zh);else{var n=this.Sl.getLineCurve(e,this.zh);this.addCurve(n,H.EXTERIOR,H.INTERIOR)}}},{key:"addCurve",value:function(t,e,n){if(null===t||t.length<2)return null;var i=new ln(t,new ke(0,H.BOUNDARY,e,n));this.Ml.add(i)}},{key:"getCurves",value:function(){return this.add(this.El),this.Ml}},{key:"add",value:function(t){if(t.isEmpty())return null;if(t instanceof Dt)this.addPolygon(t);else if(t instanceof Ct)this.addLineString(t);else if(t instanceof It)this.addPoint(t);else if(t instanceof Ut)this.addCollection(t);else if(t instanceof ie)this.addCollection(t);else if(t instanceof Yt)this.addCollection(t);else{if(!(t instanceof Ft))throw new G(t.getGeometryType());this.addCollection(t)}}},{key:"isErodedCompletely",value:function(t,e){var n=t.getCoordinates();if(n.length<4)return e<0;if(4===n.length)return this.isTriangleErodedCompletely(n,e);var i=t.getEnvelopeInternal(),r=Math.min(i.getHeight(),i.getWidth());return e<0&&2*Math.abs(e)>r}},{key:"addCollection",value:function(t){for(var e=0;e<t.getNumGeometries();e++){var n=t.getGeometryN(e);this.add(n)}}}],[{key:"constructor_",value:function(){this.El=null,this.zh=null,this.Sl=null,this.Ml=new dt;var t=arguments[0],e=arguments[1],n=arguments[2];this.El=t,this.zh=e,this.Sl=n}}]),e}(),In=function(){function e(){t(this,e)}return n(e,[{key:"locate",value:function(t){}}]),e}(),On=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"next",value:function(){if(this.Cl)return this.Cl=!1,e.isAtomic(this.Al)&&this._index++,this.Al;if(null!==this.Il){if(this.Il.hasNext())return this.Il.next();this.Il=null}if(this._index>=this.Ol)throw new W;var t=this.Al.getGeometryN(this._index++);return t instanceof Ft?(this.Il=new e(t),this.Il.next()):t}},{key:"remove",value:function(){throw new G(this.getClass().getName())}},{key:"hasNext",value:function(){if(this.Cl)return!0;if(null!==this.Il){if(this.Il.hasNext())return!0;this.Il=null}return!(this._index>=this.Ol)}},{key:"interfaces_",get:function(){return[sn]}}],[{key:"constructor_",value:function(){this.Al=null,this.Cl=null,this.Ol=null,this._index=null,this.Il=null;var t=arguments[0];this.Al=t,this.Cl=!0,this._index=0,this.Ol=t.getNumGeometries()}},{key:"isAtomic",value:function(t){return!(t instanceof Ft)}}]),e}(),Tn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"locate",value:function(t){return e.locate(t,this.Tl)}},{key:"interfaces_",get:function(){return[In]}}],[{key:"constructor_",value:function(){this.Tl=null;var t=arguments[0];this.Tl=t}},{key:"locatePointInPolygon",value:function(t,n){if(n.isEmpty())return H.EXTERIOR;var i=n.getExteriorRing(),r=e.locatePointInRing(t,i);if(r!==H.INTERIOR)return r;for(var s=0;s<n.getNumInteriorRing();s++){var o=n.getInteriorRingN(s),a=e.locatePointInRing(t,o);if(a===H.BOUNDARY)return H.BOUNDARY;if(a===H.INTERIOR)return H.EXTERIOR}return H.INTERIOR}},{key:"locatePointInRing",value:function(t,e){return e.getEnvelopeInternal().intersects(t)?xe.locateInRing(t,e.getCoordinates()):H.EXTERIOR}},{key:"containsPointInPolygon",value:function(t,n){return H.EXTERIOR!==e.locatePointInPolygon(t,n)}},{key:"locateInGeometry",value:function(t,n){if(n instanceof Dt)return e.locatePointInPolygon(t,n);if(n instanceof Ft)for(var i=new On(n);i.hasNext();){var r=i.next();if(r!==n){var s=e.locateInGeometry(t,r);if(s!==H.EXTERIOR)return s}}return H.EXTERIOR}},{key:"isContained",value:function(t,n){return H.EXTERIOR!==e.locate(t,n)}},{key:"locate",value:function(t,n){return n.isEmpty()?H.EXTERIOR:n.getEnvelopeInternal().intersects(t)?e.locateInGeometry(t,n):H.EXTERIOR}}]),e}(),zn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getNextCW",value:function(t){this.getEdges();var e=this.zl.indexOf(t),n=e-1;return 0===e&&(n=this.zl.size()-1),this.zl.get(n)}},{key:"propagateSideLabels",value:function(t){for(var e=H.NONE,n=this.iterator();n.hasNext();){var i=n.next().getLabel();i.isArea(t)&&i.getLocation(t,Z.LEFT)!==H.NONE&&(e=i.getLocation(t,Z.LEFT))}if(e===H.NONE)return null;for(var r=e,s=this.iterator();s.hasNext();){var o=s.next(),a=o.getLabel();if(a.getLocation(t,Z.ON)===H.NONE&&a.setLocation(t,Z.ON,r),a.isArea(t)){var u=a.getLocation(t,Z.LEFT),h=a.getLocation(t,Z.RIGHT);if(h!==H.NONE){if(h!==r)throw new ct("side location conflict",o.getCoordinate());u===H.NONE&&R.shouldNeverReachHere("found single null side (at "+o.getCoordinate()+")"),r=u}else R.isTrue(a.getLocation(t,Z.LEFT)===H.NONE,"found single null side"),a.setLocation(t,Z.RIGHT,r),a.setLocation(t,Z.LEFT,r)}}}},{key:"getCoordinate",value:function(){var t=this.iterator();return t.hasNext()?t.next().getCoordinate():null}},{key:"print",value:function(t){mt.out.println("EdgeEndStar: "+this.getCoordinate());for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"isAreaLabelsConsistent",value:function(t){return this.computeEdgeEndLabels(t.getBoundaryNodeRule()),this.checkAreaLabelsConsistent(0)}},{key:"checkAreaLabelsConsistent",value:function(t){var e=this.getEdges();if(e.size()<=0)return!0;var n=e.size()-1,i=e.get(n).getLabel().getLocation(t,Z.LEFT);R.isTrue(i!==H.NONE,"Found unlabelled area edge");for(var r=i,s=this.iterator();s.hasNext();){var o=s.next().getLabel();R.isTrue(o.isArea(t),"Found non-area edge");var a=o.getLocation(t,Z.LEFT),u=o.getLocation(t,Z.RIGHT);if(a===u)return!1;if(u!==r)return!1;r=a}return!0}},{key:"findIndex",value:function(t){this.iterator();for(var e=0;e<this.zl.size();e++)if(this.zl.get(e)===t)return e;return-1}},{key:"iterator",value:function(){return this.getEdges().iterator()}},{key:"getEdges",value:function(){return null===this.zl&&(this.zl=new dt(this.Dl.values())),this.zl}},{key:"getLocation",value:function(t,e,n){return this.Pl[t]===H.NONE&&(this.Pl[t]=Tn.locate(e,n[t].getGeometry())),this.Pl[t]}},{key:"toString",value:function(){var t=new it;t.append("EdgeEndStar: "+this.getCoordinate()),t.append("\n");for(var e=this.iterator();e.hasNext();){var n=e.next();t.append(n),t.append("\n")}return t.toString()}},{key:"computeEdgeEndLabels",value:function(t){for(var e=this.iterator();e.hasNext();)e.next().computeLabel(t)}},{key:"computeLabelling",value:function(t){this.computeEdgeEndLabels(t[0].getBoundaryNodeRule()),this.propagateSideLabels(0),this.propagateSideLabels(1);for(var e=[!1,!1],n=this.iterator();n.hasNext();)for(var i=n.next().getLabel(),r=0;r<2;r++)i.isLine(r)&&i.getLocation(r)===H.BOUNDARY&&(e[r]=!0);for(var s=this.iterator();s.hasNext();)for(var o=s.next(),a=o.getLabel(),u=0;u<2;u++)if(a.isAnyNull(u)){var h=H.NONE;if(e[u])h=H.EXTERIOR;else{var l=o.getCoordinate();h=this.getLocation(u,l,t)}a.setAllLocationsIfNull(u,h)}}},{key:"getDegree",value:function(){return this.Dl.size()}},{key:"insertEdgeEnd",value:function(t,e){this.Dl.put(t,e),this.zl=null}}],[{key:"constructor_",value:function(){this.Dl=new Pe,this.zl=null,this.Pl=[H.NONE,H.NONE]}}]),e}(),Dn=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"linkResultDirectedEdges",value:function(){this.getResultAreaEdges();for(var t=null,e=null,n=this.Rl,i=0;i<this.Nl.size();i++){var r=this.Nl.get(i),s=r.getSym();if(r.getLabel().isArea())switch(null===t&&r.isInResult()&&(t=r),n){case this.Rl:if(!s.isInResult())continue;e=s,n=this.Fl;break;case this.Fl:if(!r.isInResult())continue;e.setNext(r),n=this.Rl}}if(n===this.Fl){if(null===t)throw new ct("no outgoing dirEdge found",this.getCoordinate());R.isTrue(t.isInResult(),"unable to link last incoming dirEdge"),e.setNext(t)}}},{key:"insert",value:function(t){var e=t;this.insertEdgeEnd(e,e)}},{key:"getRightmostEdge",value:function(){var t=this.getEdges(),e=t.size();if(e<1)return null;var n=t.get(0);if(1===e)return n;var i=t.get(e-1),r=n.getQuadrant(),s=i.getQuadrant();return Ne.isNorthern(r)&&Ne.isNorthern(s)?n:Ne.isNorthern(r)||Ne.isNorthern(s)?0!==n.getDy()?n:0!==i.getDy()?i:(R.shouldNeverReachHere("found two horizontal edges incident on node"),null):i}},{key:"print",value:function(t){mt.out.println("DirectedEdgeStar: "+this.getCoordinate());for(var e=this.iterator();e.hasNext();){var n=e.next();t.print("out "),n.print(t),t.println(),t.print("in "),n.getSym().print(t),t.println()}}},{key:"getResultAreaEdges",value:function(){if(null!==this.Nl)return this.Nl;this.Nl=new dt;for(var t=this.iterator();t.hasNext();){var e=t.next();(e.isInResult()||e.getSym().isInResult())&&this.Nl.add(e)}return this.Nl}},{key:"updateLabelling",value:function(t){for(var e=this.iterator();e.hasNext();){var n=e.next().getLabel();n.setAllLocationsIfNull(0,t.getLocation(0)),n.setAllLocationsIfNull(1,t.getLocation(1))}}},{key:"linkAllDirectedEdges",value:function(){this.getEdges();for(var t=null,e=null,n=this.zl.size()-1;n>=0;n--){var i=this.zl.get(n),r=i.getSym();null===e&&(e=r),null!==t&&r.setNext(t),t=i}e.setNext(t)}},{key:"computeDepths",value:function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=t.getDepth(Z.LEFT),i=t.getDepth(Z.RIGHT),r=this.computeDepths(e+1,this.zl.size(),n);if(this.computeDepths(0,e,r)!==i)throw new ct("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var s=arguments[1],o=arguments[2],a=arguments[0];a<s;a++){var u=this.zl.get(a);u.setEdgeDepths(Z.RIGHT,o),o=u.getDepth(Z.LEFT)}return o}}},{key:"mergeSymLabels",value:function(){for(var t=this.iterator();t.hasNext();){var e=t.next();e.getLabel().merge(e.getSym().getLabel())}}},{key:"linkMinimalDirectedEdges",value:function(t){for(var e=null,n=null,i=this.Rl,r=this.Nl.size()-1;r>=0;r--){var s=this.Nl.get(r),o=s.getSym();switch(null===e&&s.getEdgeRing()===t&&(e=s),i){case this.Rl:if(o.getEdgeRing()!==t)continue;n=o,i=this.Fl;break;case this.Fl:if(s.getEdgeRing()!==t)continue;n.setNextMin(s),i=this.Rl}}i===this.Fl&&(R.isTrue(null!==e,"found null for first outgoing dirEdge"),R.isTrue(e.getEdgeRing()===t,"unable to link last incoming dirEdge"),n.setNextMin(e))}},{key:"getOutgoingDegree",value:function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();)e.next().isInResult()&&t++;return t}if(1===arguments.length){for(var n=arguments[0],i=0,r=this.iterator();r.hasNext();)r.next().getEdgeRing()===n&&i++;return i}}},{key:"getLabel",value:function(){return this.Ju}},{key:"findCoveredLineEdges",value:function(){for(var t=H.NONE,e=this.iterator();e.hasNext();){var n=e.next(),i=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=H.INTERIOR;break}if(i.isInResult()){t=H.EXTERIOR;break}}}if(t===H.NONE)return null;for(var r=t,s=this.iterator();s.hasNext();){var o=s.next(),a=o.getSym();o.isLineEdge()?o.getEdge().setCovered(r===H.INTERIOR):(o.isInResult()&&(r=H.EXTERIOR),a.isInResult()&&(r=H.INTERIOR))}}},{key:"computeLabelling",value:function(t){c(r(o.prototype),"computeLabelling",this).call(this,t),this.Ju=new ke(H.NONE);for(var e=this.iterator();e.hasNext();)for(var n=e.next().getEdge().getLabel(),i=0;i<2;i++){var s=n.getLocation(i);s!==H.INTERIOR&&s!==H.BOUNDARY||this.Ju.setLocation(i,H.INTERIOR)}}}],[{key:"constructor_",value:function(){this.Nl=null,this.Ju=null,this.Rl=1,this.Fl=2}}]),o}(zn),Pn=function(e){i(s,e);var r=l(s);function s(){return t(this,s),r.call(this)}return n(s,[{key:"createNode",value:function(t){return new Ce(t,new Dn)}}]),s}(qe),Rn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"compareTo",value:function(t){var n=t;return e.compareOriented(this.Xu,this.Ul,n.Xu,n.Ul)}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this.Xu=null,this.Ul=null;var t=arguments[0];this.Xu=t,this.Ul=e.orientation(t)}},{key:"orientation",value:function(t){return 1===Wt.increasingDirection(t)}},{key:"compareOriented",value:function(t,e,n,i){for(var r=e?1:-1,s=i?1:-1,o=e?t.length:-1,a=i?n.length:-1,u=e?0:t.length-1,h=i?0:n.length-1;;){var l=t[u].compareTo(n[h]);if(0!==l)return l;var c=(u+=r)===o,f=(h+=s)===a;if(c&&!f)return-1;if(!c&&f)return 1;if(c&&f)return 0}}}]),e}(),Nn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"print",value:function(t){t.print("MULTILINESTRING ( ");for(var e=0;e<this.eh.size();e++){var n=this.eh.get(e);e>0&&t.print(","),t.print("(");for(var i=n.getCoordinates(),r=0;r<i.length;r++)r>0&&t.print(","),t.print(i[r].x+" "+i[r].y);t.println(")")}t.print(") ")}},{key:"addAll",value:function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())}},{key:"findEdgeIndex",value:function(t){for(var e=0;e<this.eh.size();e++)if(this.eh.get(e).equals(t))return e;return-1}},{key:"iterator",value:function(){return this.eh.iterator()}},{key:"getEdges",value:function(){return this.eh}},{key:"get",value:function(t){return this.eh.get(t)}},{key:"findEqualEdge",value:function(t){var e=new Rn(t.getCoordinates());return this.ql.get(e)}},{key:"add",value:function(t){this.eh.add(t);var e=new Rn(t.getCoordinates());this.ql.put(e,t)}}],[{key:"constructor_",value:function(){this.eh=new dt,this.ql=new Pe}}]),e}(),Fn=function(){function e(){t(this,e)}return n(e,[{key:"processIntersections",value:function(t,e,n,i){}},{key:"isDone",value:function(){}}]),e}(),Un=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"isTrivialIntersection",value:function(t,n,i,r){if(t===i&&1===this.yl.getIntersectionNum()){if(e.isAdjacentSegments(n,r))return!0;if(t.isClosed()){var s=t.size()-1;if(0===n&&r===s||0===r&&n===s)return!0}}return!1}},{key:"getProperIntersectionPoint",value:function(){return this.jl}},{key:"hasProperInteriorIntersection",value:function(){return this.Bl}},{key:"getLineIntersector",value:function(){return this.yl}},{key:"hasProperIntersection",value:function(){return this.Ll}},{key:"processIntersections",value:function(t,e,n,i){if(t===n&&e===i)return null;this.numTests++;var r=t.getCoordinates()[e],s=t.getCoordinates()[e+1],o=n.getCoordinates()[i],a=n.getCoordinates()[i+1];this.yl.computeIntersection(r,s,o,a),this.yl.hasIntersection()&&(this.numIntersections++,this.yl.isInteriorIntersection()&&(this.numInteriorIntersections++,this.Hl=!0),this.isTrivialIntersection(t,e,n,i)||(this.Vl=!0,t.addIntersections(this.yl,e,0),n.addIntersections(this.yl,i,1),this.yl.isProper()&&(this.numProperIntersections++,this.Ll=!0,this.Bl=!0)))}},{key:"hasIntersection",value:function(){return this.Vl}},{key:"isDone",value:function(){return!1}},{key:"hasInteriorIntersection",value:function(){return this.Hl}},{key:"interfaces_",get:function(){return[Fn]}}],[{key:"constructor_",value:function(){this.Vl=!1,this.Ll=!1,this.Bl=!1,this.Hl=!1,this.jl=null,this.yl=null,this.Wl=null,this.numIntersections=0,this.numInteriorIntersections=0,this.numProperIntersections=0,this.numTests=0;var t=arguments[0];this.yl=t}},{key:"isAdjacentSegments",value:function(t,e){return 1===Math.abs(t-e)}}]),e}(),qn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getSegmentIndex",value:function(){return this.segmentIndex}},{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex),t.println(" dist = "+this.dist)}},{key:"compareTo",value:function(t){var e=t;return this.compare(e.segmentIndex,e.dist)}},{key:"isEndPoint",value:function(t){return 0===this.segmentIndex&&0===this.dist||this.segmentIndex===t}},{key:"toString",value:function(){return this.coord+" seg # = "+this.segmentIndex+" dist = "+this.dist}},{key:"getDistance",value:function(){return this.dist}},{key:"compare",value:function(t,e){return this.segmentIndex<t?-1:this.segmentIndex>t?1:this.dist<e?-1:this.dist>e?1:0}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this.coord=null,this.segmentIndex=null,this.dist=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.coord=new q(t),this.segmentIndex=e,this.dist=n}}]),e}(),jn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"print",value:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"iterator",value:function(){return this.jh.values().iterator()}},{key:"addSplitEdges",value:function(t){this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next(),r=this.createSplitEdge(n,i);t.add(r),n=i}}},{key:"addEndpoints",value:function(){var t=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[t],t,0)}},{key:"createSplitEdge",value:function(t,e){var n=e.segmentIndex-t.segmentIndex+2,i=this.edge.pts[e.segmentIndex],r=e.dist>0||!e.coord.equals2D(i);r||n--;var s=new Array(n).fill(null),o=0;s[o++]=new q(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)s[o++]=this.edge.pts[a];return r&&(s[o]=e.coord),new Gn(s,new ke(this.edge.Ju))}},{key:"add",value:function(t,e,n){var i=new qn(t,e,n),r=this.jh.get(i);return null!==r?r:(this.jh.put(i,i),i)}},{key:"isIntersection",value:function(t){for(var e=this.iterator();e.hasNext();)if(e.next().coord.equals(t))return!0;return!1}}],[{key:"constructor_",value:function(){this.jh=new Pe,this.edge=null;var t=arguments[0];this.edge=t}}]),e}(),Bn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"isIntersects",value:function(){return!this.isDisjoint()}},{key:"isCovers",value:function(){return(e.isTrue(this.Gl[H.INTERIOR][H.INTERIOR])||e.isTrue(this.Gl[H.INTERIOR][H.BOUNDARY])||e.isTrue(this.Gl[H.BOUNDARY][H.INTERIOR])||e.isTrue(this.Gl[H.BOUNDARY][H.BOUNDARY]))&&this.Gl[H.EXTERIOR][H.INTERIOR]===St.FALSE&&this.Gl[H.EXTERIOR][H.BOUNDARY]===St.FALSE}},{key:"isCoveredBy",value:function(){return(e.isTrue(this.Gl[H.INTERIOR][H.INTERIOR])||e.isTrue(this.Gl[H.INTERIOR][H.BOUNDARY])||e.isTrue(this.Gl[H.BOUNDARY][H.INTERIOR])||e.isTrue(this.Gl[H.BOUNDARY][H.BOUNDARY]))&&this.Gl[H.INTERIOR][H.EXTERIOR]===St.FALSE&&this.Gl[H.BOUNDARY][H.EXTERIOR]===St.FALSE}},{key:"set",value:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e<t.length;e++){var n=Math.trunc(e/3),i=e%3;this.Gl[n][i]=St.toDimensionValue(t.charAt(e))}else if(3===arguments.length){var r=arguments[0],s=arguments[1],o=arguments[2];this.Gl[r][s]=o}}},{key:"isContains",value:function(){return e.isTrue(this.Gl[H.INTERIOR][H.INTERIOR])&&this.Gl[H.EXTERIOR][H.INTERIOR]===St.FALSE&&this.Gl[H.EXTERIOR][H.BOUNDARY]===St.FALSE}},{key:"setAtLeast",value:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e<t.length;e++){var n=Math.trunc(e/3),i=e%3;this.setAtLeast(n,i,St.toDimensionValue(t.charAt(e)))}else if(3===arguments.length){var r=arguments[0],s=arguments[1],o=arguments[2];this.Gl[r][s]<o&&(this.Gl[r][s]=o)}}},{key:"setAtLeastIfValid",value:function(t,e,n){t>=0&&e>=0&&this.setAtLeast(t,e,n)}},{key:"isWithin",value:function(){return e.isTrue(this.Gl[H.INTERIOR][H.INTERIOR])&&this.Gl[H.INTERIOR][H.EXTERIOR]===St.FALSE&&this.Gl[H.BOUNDARY][H.EXTERIOR]===St.FALSE}},{key:"isTouches",value:function(t,n){return t>n?this.isTouches(n,t):(t===St.A&&n===St.A||t===St.L&&n===St.L||t===St.L&&n===St.A||t===St.P&&n===St.A||t===St.P&&n===St.L)&&this.Gl[H.INTERIOR][H.INTERIOR]===St.FALSE&&(e.isTrue(this.Gl[H.INTERIOR][H.BOUNDARY])||e.isTrue(this.Gl[H.BOUNDARY][H.INTERIOR])||e.isTrue(this.Gl[H.BOUNDARY][H.BOUNDARY]))}},{key:"isOverlaps",value:function(t,n){return t===St.P&&n===St.P||t===St.A&&n===St.A?e.isTrue(this.Gl[H.INTERIOR][H.INTERIOR])&&e.isTrue(this.Gl[H.INTERIOR][H.EXTERIOR])&&e.isTrue(this.Gl[H.EXTERIOR][H.INTERIOR]):t===St.L&&n===St.L&&1===this.Gl[H.INTERIOR][H.INTERIOR]&&e.isTrue(this.Gl[H.INTERIOR][H.EXTERIOR])&&e.isTrue(this.Gl[H.EXTERIOR][H.INTERIOR])}},{key:"isEquals",value:function(t,n){return t===n&&e.isTrue(this.Gl[H.INTERIOR][H.INTERIOR])&&this.Gl[H.INTERIOR][H.EXTERIOR]===St.FALSE&&this.Gl[H.BOUNDARY][H.EXTERIOR]===St.FALSE&&this.Gl[H.EXTERIOR][H.INTERIOR]===St.FALSE&&this.Gl[H.EXTERIOR][H.BOUNDARY]===St.FALSE}},{key:"toString",value:function(){for(var t=new Kt("123456789"),e=0;e<3;e++)for(var n=0;n<3;n++)t.setCharAt(3*e+n,St.toDimensionSymbol(this.Gl[e][n]));return t.toString()}},{key:"setAll",value:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this.Gl[e][n]=t}},{key:"get",value:function(t,e){return this.Gl[t][e]}},{key:"transpose",value:function(){var t=this.Gl[1][0];return this.Gl[1][0]=this.Gl[0][1],this.Gl[0][1]=t,t=this.Gl[2][0],this.Gl[2][0]=this.Gl[0][2],this.Gl[0][2]=t,t=this.Gl[2][1],this.Gl[2][1]=this.Gl[1][2],this.Gl[1][2]=t,this}},{key:"matches",value:function(t){if(9!==t.length)throw new w("Should be length 9: "+t);for(var n=0;n<3;n++)for(var i=0;i<3;i++)if(!e.matches(this.Gl[n][i],t.charAt(3*n+i)))return!1;return!0}},{key:"add",value:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this.setAtLeast(e,n,t.get(e,n))}},{key:"isDisjoint",value:function(){return this.Gl[H.INTERIOR][H.INTERIOR]===St.FALSE&&this.Gl[H.INTERIOR][H.BOUNDARY]===St.FALSE&&this.Gl[H.BOUNDARY][H.INTERIOR]===St.FALSE&&this.Gl[H.BOUNDARY][H.BOUNDARY]===St.FALSE}},{key:"isCrosses",value:function(t,n){return t===St.P&&n===St.L||t===St.P&&n===St.A||t===St.L&&n===St.A?e.isTrue(this.Gl[H.INTERIOR][H.INTERIOR])&&e.isTrue(this.Gl[H.INTERIOR][H.EXTERIOR]):t===St.L&&n===St.P||t===St.A&&n===St.P||t===St.A&&n===St.L?e.isTrue(this.Gl[H.INTERIOR][H.INTERIOR])&&e.isTrue(this.Gl[H.EXTERIOR][H.INTERIOR]):t===St.L&&n===St.L&&0===this.Gl[H.INTERIOR][H.INTERIOR]}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){if(this.Gl=null,0===arguments.length)this.Gl=Array(3).fill().map((function(){return Array(3)})),this.setAll(St.FALSE);else if(1===arguments.length)if("string"==typeof arguments[0]){var t=arguments[0];e.constructor_.call(this),this.set(t)}else if(arguments[0]instanceof e){var n=arguments[0];e.constructor_.call(this),this.Gl[H.INTERIOR][H.INTERIOR]=n.Gl[H.INTERIOR][H.INTERIOR],this.Gl[H.INTERIOR][H.BOUNDARY]=n.Gl[H.INTERIOR][H.BOUNDARY],this.Gl[H.INTERIOR][H.EXTERIOR]=n.Gl[H.INTERIOR][H.EXTERIOR],this.Gl[H.BOUNDARY][H.INTERIOR]=n.Gl[H.BOUNDARY][H.INTERIOR],this.Gl[H.BOUNDARY][H.BOUNDARY]=n.Gl[H.BOUNDARY][H.BOUNDARY],this.Gl[H.BOUNDARY][H.EXTERIOR]=n.Gl[H.BOUNDARY][H.EXTERIOR],this.Gl[H.EXTERIOR][H.INTERIOR]=n.Gl[H.EXTERIOR][H.INTERIOR],this.Gl[H.EXTERIOR][H.BOUNDARY]=n.Gl[H.EXTERIOR][H.BOUNDARY],this.Gl[H.EXTERIOR][H.EXTERIOR]=n.Gl[H.EXTERIOR][H.EXTERIOR]}}},{key:"matches",value:function(){if(Number.isInteger(arguments[0])&&"string"==typeof arguments[1]){var t=arguments[0],n=arguments[1];return n===St.SYM_DONTCARE||n===St.SYM_TRUE&&(t>=0||t===St.TRUE)||n===St.SYM_FALSE&&t===St.FALSE||n===St.SYM_P&&t===St.P||n===St.SYM_L&&t===St.L||n===St.SYM_A&&t===St.A}if("string"==typeof arguments[0]&&"string"==typeof arguments[1]){var i=arguments[1];return new e(arguments[0]).matches(i)}}},{key:"isTrue",value:function(t){return t>=0||t===St.TRUE}}]),e}(),Ln=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"size",value:function(){return this.Bi}},{key:"addAll",value:function(t){return null===t||0===t.length?null:(this.ensureCapacity(this.Bi+t.length),mt.arraycopy(t,0,this.We,this.Bi,t.length),void(this.Bi+=t.length))}},{key:"ensureCapacity",value:function(t){if(t<=this.We.length)return null;var e=Math.max(t,2*this.We.length);this.We=Tt.copyOf(this.We,e)}},{key:"toArray",value:function(){var t=new Array(this.Bi).fill(null);return mt.arraycopy(this.We,0,t,0,this.Bi),t}},{key:"add",value:function(t){this.ensureCapacity(this.Bi+1),this.We[this.Bi]=t,++this.Bi}}],[{key:"constructor_",value:function(){if(this.We=null,this.Bi=0,0===arguments.length)e.constructor_.call(this,10);else if(1===arguments.length){var t=arguments[0];this.We=new Array(t).fill(null)}}}]),e}(),Hn=function(){function e(){t(this,e)}return n(e,[{key:"getChainStartIndices",value:function(t){var e=0,n=new Ln(Math.trunc(t.length/2));n.add(e);do{var i=this.findChainEnd(t,e);n.add(i),e=i}while(e<t.length-1);return n.toArray()}},{key:"findChainEnd",value:function(t,e){for(var n=Ne.quadrant(t[e],t[e+1]),i=e+1;i<t.length&&Ne.quadrant(t[i-1],t[i])===n;)i++;return i-1}},{key:"OLDgetChainStartIndices",value:function(t){var n=0,i=new dt;i.add(n);do{var r=this.findChainEnd(t,n);i.add(r),n=r}while(n<t.length-1);return e.toIntArray(i)}}],[{key:"toIntArray",value:function(t){for(var e=new Array(t.size()).fill(null),n=0;n<e.length;n++)e[n]=t.get(n).intValue();return e}}]),e}(),Vn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getCoordinates",value:function(){return this.pts}},{key:"getMaxX",value:function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return e>n?e:n}},{key:"getMinX",value:function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return e<n?e:n}},{key:"computeIntersectsForChain",value:function(){if(4===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this.computeIntersectsForChain(this.startIndex[t],this.startIndex[t+1],e,e.startIndex[n],e.startIndex[n+1],i)}else if(6===arguments.length){var r=arguments[0],s=arguments[1],o=arguments[2],a=arguments[3],u=arguments[4],h=arguments[5];if(s-r==1&&u-a==1)return h.addIntersections(this.e,r,o.e,a),null;if(!this.overlaps(r,s,o,a,u))return null;var l=Math.trunc((r+s)/2),c=Math.trunc((a+u)/2);r<l&&(a<c&&this.computeIntersectsForChain(r,l,o,a,c,h),c<u&&this.computeIntersectsForChain(r,l,o,c,u,h)),l<s&&(a<c&&this.computeIntersectsForChain(l,s,o,a,c,h),c<u&&this.computeIntersectsForChain(l,s,o,c,u,h))}}},{key:"overlaps",value:function(t,e,n,i,r){return B.intersects(this.pts[t],this.pts[e],n.pts[i],n.pts[r])}},{key:"getStartIndexes",value:function(){return this.startIndex}},{key:"computeIntersects",value:function(t,e){for(var n=0;n<this.startIndex.length-1;n++)for(var i=0;i<t.startIndex.length-1;i++)this.computeIntersectsForChain(n,t,i,e)}}],[{key:"constructor_",value:function(){this.e=null,this.pts=null,this.startIndex=null;var t=arguments[0];this.e=t,this.pts=t.getCoordinates();var e=new Hn;this.startIndex=e.getChainStartIndices(this.pts)}}]),e}(),Wn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getDepth",value:function(t,e){return this.wh[t][e]}},{key:"setDepth",value:function(t,e,n){this.wh[t][e]=n}},{key:"isNull",value:function(){if(0===arguments.length){for(var t=0;t<2;t++)for(var n=0;n<3;n++)if(this.wh[t][n]!==e.NULL_VALUE)return!1;return!0}if(1===arguments.length){var i=arguments[0];return this.wh[i][1]===e.NULL_VALUE}if(2===arguments.length){var r=arguments[0],s=arguments[1];return this.wh[r][s]===e.NULL_VALUE}}},{key:"normalize",value:function(){for(var t=0;t<2;t++)if(!this.isNull(t)){var e=this.wh[t][1];this.wh[t][2]<e&&(e=this.wh[t][2]),e<0&&(e=0);for(var n=1;n<3;n++){var i=0;this.wh[t][n]>e&&(i=1),this.wh[t][n]=i}}}},{key:"getDelta",value:function(t){return this.wh[t][Z.RIGHT]-this.wh[t][Z.LEFT]}},{key:"getLocation",value:function(t,e){return this.wh[t][e]<=0?H.EXTERIOR:H.INTERIOR}},{key:"toString",value:function(){return"A: "+this.wh[0][1]+","+this.wh[0][2]+" B: "+this.wh[1][1]+","+this.wh[1][2]}},{key:"add",value:function(){if(1===arguments.length)for(var t=arguments[0],n=0;n<2;n++)for(var i=1;i<3;i++){var r=t.getLocation(n,i);r!==H.EXTERIOR&&r!==H.INTERIOR||(this.isNull(n,i)?this.wh[n][i]=e.depthAtLocation(r):this.wh[n][i]+=e.depthAtLocation(r))}else if(3===arguments.length){var s=arguments[0],o=arguments[1];arguments[2]===H.INTERIOR&&this.wh[s][o]++}}}],[{key:"constructor_",value:function(){this.wh=Array(2).fill().map((function(){return Array(3)}));for(var t=0;t<2;t++)for(var n=0;n<3;n++)this.wh[t][n]=e.NULL_VALUE}},{key:"depthAtLocation",value:function(t){return t===H.EXTERIOR?0:t===H.INTERIOR?1:e.NULL_VALUE}}]),e}();Wn.NULL_VALUE=-1;var Gn=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"getDepth",value:function(){return this.wh}},{key:"getCollapsedEdge",value:function(){var t=new Array(2).fill(null);return t[0]=this.pts[0],t[1]=this.pts[1],new o(t,ke.toLineLabel(this.Ju))}},{key:"isIsolated",value:function(){return this.Ql}},{key:"getCoordinates",value:function(){return this.pts}},{key:"setIsolated",value:function(t){this.Ql=t}},{key:"setName",value:function(t){this.so=t}},{key:"equals",value:function(t){if(!(t instanceof o))return!1;var e=t;if(this.pts.length!==e.pts.length)return!1;for(var n=!0,i=!0,r=this.pts.length,s=0;s<this.pts.length;s++)if(this.pts[s].equals2D(e.pts[s])||(n=!1),this.pts[s].equals2D(e.pts[--r])||(i=!1),!n&&!i)return!1;return!0}},{key:"getCoordinate",value:function(){if(0===arguments.length)return this.pts.length>0?this.pts[0]:null;if(1===arguments.length){var t=arguments[0];return this.pts[t]}}},{key:"print",value:function(t){t.print("edge "+this.so+": "),t.print("LINESTRING (");for(var e=0;e<this.pts.length;e++)e>0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this.Ju+" "+this.Kl)}},{key:"computeIM",value:function(t){o.updateIM(this.Ju,t)}},{key:"isCollapsed",value:function(){return!!this.Ju.isArea()&&3===this.pts.length&&!!this.pts[0].equals(this.pts[2])}},{key:"isClosed",value:function(){return this.pts[0].equals(this.pts[this.pts.length-1])}},{key:"getMaximumSegmentIndex",value:function(){return this.pts.length-1}},{key:"getDepthDelta",value:function(){return this.Kl}},{key:"getNumPoints",value:function(){return this.pts.length}},{key:"printReverse",value:function(t){t.print("edge "+this.so+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")}},{key:"getMonotoneChainEdge",value:function(){return null===this.Xl&&(this.Xl=new Vn(this)),this.Xl}},{key:"getEnvelope",value:function(){if(null===this.Eu){this.Eu=new B;for(var t=0;t<this.pts.length;t++)this.Eu.expandToInclude(this.pts[t])}return this.Eu}},{key:"addIntersection",value:function(t,e,n,i){var r=new q(t.getIntersection(i)),s=e,o=t.getEdgeDistance(n,i),a=s+1;if(a<this.pts.length){var u=this.pts[a];r.equals2D(u)&&(s=a,o=0)}this.eiList.add(r,s,o)}},{key:"toString",value:function(){var t=new Kt;t.append("edge "+this.so+": "),t.append("LINESTRING (");for(var e=0;e<this.pts.length;e++)e>0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this.Ju+" "+this.Kl),t.toString()}},{key:"isPointwiseEqual",value:function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;e<this.pts.length;e++)if(!this.pts[e].equals2D(t.pts[e]))return!1;return!0}},{key:"setDepthDelta",value:function(t){this.Kl=t}},{key:"getEdgeIntersectionList",value:function(){return this.eiList}},{key:"addIntersections",value:function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++)this.addIntersection(t,e,n,i)}}],[{key:"constructor_",value:function(){if(this.pts=null,this.Eu=null,this.eiList=new jn(this),this.so=null,this.Xl=null,this.Ql=!0,this.wh=new Wn,this.Kl=0,1===arguments.length){var t=arguments[0];o.constructor_.call(this,t,null)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.pts=e,this.Ju=n}}},{key:"updateIM",value:function(){if(!(2===arguments.length&&arguments[1]instanceof Bn&&arguments[0]instanceof ke))return c(r(o),"updateIM",this).apply(this,arguments);var t=arguments[0],e=arguments[1];e.setAtLeastIfValid(t.getLocation(0,Z.ON),t.getLocation(1,Z.ON),1),t.isArea()&&(e.setAtLeastIfValid(t.getLocation(0,Z.LEFT),t.getLocation(1,Z.LEFT),2),e.setAtLeastIfValid(t.getLocation(0,Z.RIGHT),t.getLocation(1,Z.RIGHT),2))}}]),o}(Ee),Qn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"setWorkingPrecisionModel",value:function(t){this.Zl=t}},{key:"insertUniqueEdge",value:function(t){var n=this.zl.findEqualEdge(t);if(null!==n){var i=n.getLabel(),r=t.getLabel();n.isPointwiseEqual(t)||(r=new ke(t.getLabel())).flip(),i.merge(r);var s=e.depthDelta(r),o=n.getDepthDelta()+s;n.setDepthDelta(o)}else this.zl.add(t),t.setDepthDelta(e.depthDelta(t.getLabel()))}},{key:"buildSubgraphs",value:function(t,e){for(var n=new dt,i=t.iterator();i.hasNext();){var r=i.next(),s=r.getRightmostCoordinate(),o=new $n(n).getDepth(s);r.computeDepth(o),r.findResultEdges(),n.add(r),e.add(r.getDirectedEdges(),r.getNodes())}}},{key:"createSubgraphs",value:function(t){for(var e=new dt,n=t.getNodes().iterator();n.hasNext();){var i=n.next();if(!i.isVisited()){var r=new vt;r.create(i),e.add(r)}}return Qe.sort(e,Qe.reverseOrder()),e}},{key:"createEmptyResultGeometry",value:function(){return this.Yl.createPolygon()}},{key:"getNoder",value:function(t){if(null!==this.Jl)return this.Jl;var e=new mn,n=new ge;return n.setPrecisionModel(t),e.setSegmentIntersector(new Un(n)),e}},{key:"buffer",value:function(t,e){var n=this.Zl;null===n&&(n=t.getPrecisionModel()),this.Yl=t.getFactory();var i=new kn(n,this.dl),r=new An(t,e,i).getCurves();if(r.size()<=0)return this.createEmptyResultGeometry();this.computeNodedEdges(r,n),this.tc=new je(new Pn),this.tc.addEdges(this.zl.getEdges());var s=this.createSubgraphs(this.tc),o=new Be(this.Yl);this.buildSubgraphs(s,o);var a=o.getPolygons();return a.size()<=0?this.createEmptyResultGeometry():this.Yl.buildGeometry(a)}},{key:"computeNodedEdges",value:function(t,e){var n=this.getNoder(e);n.computeNodes(t);for(var i=n.getNodedSubstrings().iterator();i.hasNext();){var r=i.next(),s=r.getCoordinates();if(2!==s.length||!s[0].equals2D(s[1])){var o=r.getData(),a=new Gn(r.getCoordinates(),new ke(o));this.insertUniqueEdge(a)}}}},{key:"setNoder",value:function(t){this.Jl=t}}],[{key:"constructor_",value:function(){this.dl=null,this.Zl=null,this.Jl=null,this.Yl=null,this.tc=null,this.zl=new Nn;var t=arguments[0];this.dl=t}},{key:"depthDelta",value:function(t){var e=t.getLocation(0,Z.LEFT),n=t.getLocation(0,Z.RIGHT);return e===H.INTERIOR&&n===H.EXTERIOR?1:e===H.EXTERIOR&&n===H.INTERIOR?-1:0}},{key:"convertSegStrings",value:function(t){for(var e=new re,n=new dt;t.hasNext();){var i=t.next(),r=e.createLineString(i.getCoordinates());n.add(r)}return e.buildGeometry(n)}}]),e}(),Kn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"rescale",value:function(){if(nt(arguments[0],V))for(var t=arguments[0].iterator();t.hasNext();){var e=t.next();this.rescale(e.getCoordinates())}else if(arguments[0]instanceof Array){for(var n=arguments[0],i=0;i<n.length;i++)n[i].x=n[i].x/this.rc+this.sc,n[i].y=n[i].y/this.rc+this.oc;2===n.length&&n[0].equals2D(n[1])&&mt.out.println(n)}}},{key:"scale",value:function(){if(nt(arguments[0],V)){for(var t=arguments[0],e=new dt(t.size()),n=t.iterator();n.hasNext();){var i=n.next();e.add(new ln(this.scale(i.getCoordinates()),i.getData()))}return e}if(arguments[0]instanceof Array){for(var r=arguments[0],s=new Array(r.length).fill(null),o=0;o<r.length;o++)s[o]=new q(Math.round((r[o].x-this.sc)*this.rc),Math.round((r[o].y-this.oc)*this.rc),r[o].getZ());return Wt.removeRepeatedPoints(s)}}},{key:"isIntegerPrecision",value:function(){return 1===this.rc}},{key:"getNodedSubstrings",value:function(){var t=this.uc.getNodedSubstrings();return this.lc&&this.rescale(t),t}},{key:"computeNodes",value:function(t){var e=t;this.lc&&(e=this.scale(t)),this.uc.computeNodes(e)}},{key:"interfaces_",get:function(){return[vn]}}],[{key:"constructor_",value:function(){if(this.uc=null,this.rc=null,this.sc=null,this.oc=null,this.lc=!1,2===arguments.length){var t=arguments[0],n=arguments[1];e.constructor_.call(this,t,n,0,0)}else if(4===arguments.length){var i=arguments[0],r=arguments[1];this.uc=i,this.rc=r,this.lc=!this.isIntegerPrecision()}}}]),e}(),Xn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"checkEndPtVertexIntersections",value:function(){if(0===arguments.length)for(var t=this.vc.iterator();t.hasNext();){var e=t.next().getCoordinates();this.checkEndPtVertexIntersections(e[0],this.vc),this.checkEndPtVertexIntersections(e[e.length-1],this.vc)}else if(2===arguments.length)for(var n=arguments[0],i=arguments[1].iterator();i.hasNext();)for(var r=i.next().getCoordinates(),s=1;s<r.length-1;s++)if(r[s].equals(n))throw new D("found endpt/interior pt intersection at index "+s+" :pt "+n)}},{key:"checkInteriorIntersections",value:function(){if(0===arguments.length)for(var t=this.vc.iterator();t.hasNext();)for(var e=t.next(),n=this.vc.iterator();n.hasNext();){var i=n.next();this.checkInteriorIntersections(e,i)}else if(2===arguments.length)for(var r=arguments[0],s=arguments[1],o=r.getCoordinates(),a=s.getCoordinates(),u=0;u<o.length-1;u++)for(var h=0;h<a.length-1;h++)this.checkInteriorIntersections(r,u,s,h);else if(4===arguments.length){var l=arguments[0],c=arguments[1],f=arguments[2],d=arguments[3];if(l===f&&c===d)return null;var p=l.getCoordinates()[c],v=l.getCoordinates()[c+1],y=f.getCoordinates()[d],m=f.getCoordinates()[d+1];if(this.yl.computeIntersection(p,v,y,m),this.yl.hasIntersection()&&(this.yl.isProper()||this.hasInteriorIntersection(this.yl,p,v)||this.hasInteriorIntersection(this.yl,y,m)))throw new D("found non-noded intersection at "+p+"-"+v+" and "+y+"-"+m)}}},{key:"checkValid",value:function(){this.checkEndPtVertexIntersections(),this.checkInteriorIntersections(),this.checkCollapses()}},{key:"checkCollapses",value:function(){if(0===arguments.length)for(var t=this.vc.iterator();t.hasNext();){var e=t.next();this.checkCollapses(e)}else if(1===arguments.length)for(var n=arguments[0].getCoordinates(),i=0;i<n.length-2;i++)this.checkCollapse(n[i],n[i+1],n[i+2])}},{key:"hasInteriorIntersection",value:function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++){var r=t.getIntersection(i);if(!r.equals(e)&&!r.equals(n))return!0}return!1}},{key:"checkCollapse",value:function(t,n,i){if(t.equals(i))throw new D("found non-noded collapse at "+e.fact.createLineString([t,n,i]))}}],[{key:"constructor_",value:function(){this.yl=new ge,this.vc=null;var t=arguments[0];this.vc=t}}]),e}();Xn.fact=new re;var Zn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"intersectsScaled",value:function(t,e){var n=Math.min(t.x,e.x),i=Math.max(t.x,e.x),r=Math.min(t.y,e.y),s=Math.max(t.y,e.y),o=this.lu<n||this.fu>i||this.cu<r||this.du>s;if(o)return!1;var a=this.intersectsToleranceSquare(t,e);return R.isTrue(!(o&&a),"Found bad envelope test"),a}},{key:"initCorners",value:function(t){var e=.5;this.fu=t.x-e,this.lu=t.x+e,this.du=t.y-e,this.cu=t.y+e,this.yc[0]=new q(this.lu,this.cu),this.yc[1]=new q(this.fu,this.cu),this.yc[2]=new q(this.fu,this.du),this.yc[3]=new q(this.lu,this.du)}},{key:"intersects",value:function(t,e){return 1===this.rc?this.intersectsScaled(t,e):(this.copyScaled(t,this.wc),this.copyScaled(e,this.gc),this.intersectsScaled(this.wc,this.gc))}},{key:"scale",value:function(t){return Math.round(t*this.rc)}},{key:"getCoordinate",value:function(){return this.xc}},{key:"copyScaled",value:function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)}},{key:"getSafeEnvelope",value:function(){if(null===this._c){var t=e.SAFE_ENV_EXPANSION_FACTOR/this.rc;this._c=new B(this.xc.x-t,this.xc.x+t,this.xc.y-t,this.xc.y+t)}return this._c}},{key:"intersectsPixelClosure",value:function(t,e){return this.yl.computeIntersection(t,e,this.yc[0],this.yc[1]),!!(this.yl.hasIntersection()||(this.yl.computeIntersection(t,e,this.yc[1],this.yc[2]),this.yl.hasIntersection()||(this.yl.computeIntersection(t,e,this.yc[2],this.yc[3]),this.yl.hasIntersection()||(this.yl.computeIntersection(t,e,this.yc[3],this.yc[0]),this.yl.hasIntersection()))))}},{key:"intersectsToleranceSquare",value:function(t,e){var n=!1,i=!1;return this.yl.computeIntersection(t,e,this.yc[0],this.yc[1]),!!(this.yl.isProper()||(this.yl.computeIntersection(t,e,this.yc[1],this.yc[2]),this.yl.isProper()||(this.yl.hasIntersection()&&(n=!0),this.yl.computeIntersection(t,e,this.yc[2],this.yc[3]),this.yl.isProper()||(this.yl.hasIntersection()&&(i=!0),this.yl.computeIntersection(t,e,this.yc[3],this.yc[0]),this.yl.isProper()||n&&i||t.equals(this.$c)||e.equals(this.$c)))))}},{key:"addSnappedNode",value:function(t,e){var n=t.getCoordinate(e),i=t.getCoordinate(e+1);return!!this.intersects(n,i)&&(t.addIntersection(this.getCoordinate(),e),!0)}}],[{key:"constructor_",value:function(){this.yl=null,this.$c=null,this.xc=null,this.Sc=null,this.wc=null,this.gc=null,this.rc=null,this.fu=null,this.lu=null,this.du=null,this.cu=null,this.yc=new Array(4).fill(null),this._c=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(this.xc=t,this.$c=t,this.rc=e,this.yl=n,e<=0)throw new w("Scale factor must be non-zero");1!==e&&(this.$c=new q(this.scale(t.x),this.scale(t.y)),this.wc=new q,this.gc=new q),this.initCorners(this.$c)}}]),e}();Zn.SAFE_ENV_EXPANSION_FACTOR=.75;var Yn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"select",value:function(){if(1===arguments.length);else if(2===arguments.length){var t=arguments[1];arguments[0].getLineSegment(t,this.selectedSegment),this.select(this.selectedSegment)}}}],[{key:"constructor_",value:function(){this.selectedSegment=new cn}}]),e}(),Jn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"snap",value:function(){if(1===arguments.length){var e=arguments[0];return this.snap(e,null,-1)}if(3===arguments.length){var i=arguments[0],r=arguments[1],s=arguments[2],o=i.getSafeEnvelope(),a=new ti(i,r,s);return this._index.query(o,new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[Ze]}},{key:"visitItem",value:function(t){t.select(o,a)}}]),e}())),a.isNodeAdded()}}}],[{key:"constructor_",value:function(){this._index=null;var t=arguments[0];this._index=t}}]),e}(),ti=function(e){i(o,e);var s=l(o);function o(){var e;return t(this,o),e=s.call(this),o.constructor_.apply(h(e),arguments),e}return n(o,[{key:"isNodeAdded",value:function(){return this.Mc}},{key:"select",value:function(){if(!(2===arguments.length&&Number.isInteger(arguments[1])&&arguments[0]instanceof dn))return c(r(o.prototype),"select",this).apply(this,arguments);var t=arguments[1],e=arguments[0].getContext();if(this.Ec===e&&(t===this.Cc||t+1===this.Cc))return null;this.Mc|=this.Ac.addSnappedNode(e,t)}}],[{key:"constructor_",value:function(){this.Ac=null,this.Ec=null,this.Cc=null,this.Mc=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this.Ac=t,this.Ec=e,this.Cc=n}}]),o}(Yn);Jn.HotPixelSnapAction=ti;var ei=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"processIntersections",value:function(t,e,n,i){if(t===n&&e===i)return null;var r=t.getCoordinates()[e],s=t.getCoordinates()[e+1],o=n.getCoordinates()[i],a=n.getCoordinates()[i+1];if(this.yl.computeIntersection(r,s,o,a),this.yl.hasIntersection()&&this.yl.isInteriorIntersection()){for(var u=0;u<this.yl.getIntersectionNum();u++)this.Ic.add(this.yl.getIntersection(u));t.addIntersections(this.yl,e,0),n.addIntersections(this.yl,i,1)}}},{key:"isDone",value:function(){return!1}},{key:"getInteriorIntersections",value:function(){return this.Ic}},{key:"interfaces_",get:function(){return[Fn]}}],[{key:"constructor_",value:function(){this.yl=null,this.Ic=null;var t=arguments[0];this.yl=t,this.Ic=new dt}}]),e}(),ni=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"checkCorrectness",value:function(t){var e=ln.getNodedSubstrings(t),n=new Xn(e);try{n.checkValid()}catch(t){if(!(t instanceof m))throw t;t.printStackTrace()}}},{key:"getNodedSubstrings",value:function(){return ln.getNodedSubstrings(this.Kh)}},{key:"snapRound",value:function(t,e){var n=this.findInteriorIntersections(t,e);this.computeIntersectionSnaps(n),this.computeVertexSnaps(t)}},{key:"findInteriorIntersections",value:function(t,e){var n=new ei(e);return this.uc.setSegmentIntersector(n),this.uc.computeNodes(t),n.getInteriorIntersections()}},{key:"computeVertexSnaps",value:function(){if(nt(arguments[0],V))for(var t=arguments[0].iterator();t.hasNext();){var e=t.next();this.computeVertexSnaps(e)}else if(arguments[0]instanceof ln)for(var n=arguments[0],i=n.getCoordinates(),r=0;r<i.length;r++){var s=new Zn(i[r],this.rc,this.yl);this.Oc.snap(s,n,r)&&n.addIntersection(i[r],r)}}},{key:"computeNodes",value:function(t){this.Kh=t,this.uc=new mn,this.Oc=new Jn(this.uc.getIndex()),this.snapRound(t,this.yl)}},{key:"computeIntersectionSnaps",value:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),i=new Zn(n,this.rc,this.yl);this.Oc.snap(i)}}},{key:"interfaces_",get:function(){return[vn]}}],[{key:"constructor_",value:function(){this.Tc=null,this.yl=null,this.rc=null,this.uc=null,this.Oc=null,this.Kh=null;var t=arguments[0];this.Tc=t,this.yl=new ge,this.yl.setPrecisionModel(t),this.rc=t.getScale()}}]),e}(),ii=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"bufferFixedPrecision",value:function(t){var e=new Kn(new ni(new ee(1)),t.getScale()),n=new Qn(this.dl);n.setWorkingPrecisionModel(t),n.setNoder(e),this.zc=n.buffer(this.Dc,this.zh)}},{key:"bufferReducedPrecision",value:function(){if(0===arguments.length){for(var t=e.MAX_PRECISION_DIGITS;t>=0;t--){try{this.bufferReducedPrecision(t)}catch(t){if(!(t instanceof ct))throw t;this.Pc=t}if(null!==this.zc)return null}throw this.Pc}if(1===arguments.length){var n=arguments[0],i=e.precisionScaleFactor(this.Dc,this.zh,n),r=new ee(i);this.bufferFixedPrecision(r)}}},{key:"computeGeometry",value:function(){if(this.bufferOriginalPrecision(),null!==this.zc)return null;var t=this.Dc.getFactory().getPrecisionModel();t.getType()===ee.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()}},{key:"setQuadrantSegments",value:function(t){this.dl.setQuadrantSegments(t)}},{key:"bufferOriginalPrecision",value:function(){try{var t=new Qn(this.dl);this.zc=t.buffer(this.Dc,this.zh)}catch(t){if(!(t instanceof D))throw t;this.Pc=t}}},{key:"getResultGeometry",value:function(t){return this.zh=t,this.computeGeometry(),this.zc}},{key:"setEndCapStyle",value:function(t){this.dl.setEndCapStyle(t)}}],[{key:"constructor_",value:function(){if(this.Dc=null,this.zh=null,this.dl=new y,this.zc=null,this.Pc=null,1===arguments.length){var t=arguments[0];this.Dc=t}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.Dc=e,this.dl=n}}},{key:"bufferOp",value:function(){if(2===arguments.length){var t=arguments[1];return new e(arguments[0]).getResultGeometry(t)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof L&&"number"==typeof arguments[1]){var n=arguments[1],i=arguments[2],r=new e(arguments[0]);return r.setQuadrantSegments(i),r.getResultGeometry(n)}if(arguments[2]instanceof y&&arguments[0]instanceof L&&"number"==typeof arguments[1]){var s=arguments[1];return new e(arguments[0],arguments[2]).getResultGeometry(s)}}else if(4===arguments.length){var o=arguments[1],a=arguments[2],u=arguments[3],h=new e(arguments[0]);return h.setQuadrantSegments(a),h.setEndCapStyle(u),h.getResultGeometry(o)}}},{key:"precisionScaleFactor",value:function(t,e,n){var i=t.getEnvelopeInternal(),r=wt.max(Math.abs(i.getMaxX()),Math.abs(i.getMaxY()),Math.abs(i.getMinX()),Math.abs(i.getMinY()))+2*(e>0?e:0),s=n-Math.trunc(Math.log(r)/Math.log(10)+1);return Math.pow(10,s)}}]),e}();ii.CAP_ROUND=y.CAP_ROUND,ii.CAP_BUTT=y.CAP_FLAT,ii.CAP_FLAT=y.CAP_FLAT,ii.CAP_SQUARE=y.CAP_SQUARE,ii.MAX_PRECISION_DIGITS=12;var ri=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],si=function(){function e(n){t(this,e),this.geometryFactory=n||new re}return n(e,[{key:"read",value:function(t){var e,n=(e="string"==typeof t?JSON.parse(t):t).type;if(!oi[n])throw new Error("Unknown GeoJSON type: "+e.type);return-1!==ri.indexOf(n)?oi[n].call(this,e.coordinates):"GeometryCollection"===n?oi[n].call(this,e.geometries):oi[n].call(this,e)}},{key:"write",value:function(t){var e=t.getGeometryType();if(!ai[e])throw new Error("Geometry is not supported");return ai[e].call(this,t)}}]),e}(),oi={Feature:function(t){var e={};for(var n in t)e[n]=t[n];if(t.geometry){var i=t.geometry.type;if(!oi[i])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=oi.bbox.call(this,t.bbox)),e},FeatureCollection:function(t){var e={};if(t.features){e.features=[];for(var n=0;n<t.features.length;++n)e.features.push(this.read(t.features[n]))}return t.bbox&&(e.bbox=this.parse.bbox.call(this,t.bbox)),e},coordinates:function(t){for(var e=[],n=0;n<t.length;++n){var i=t[n];e.push(a(q,f(i)))}return e},bbox:function(t){return this.geometryFactory.createLinearRing([new q(t[0],t[1]),new q(t[2],t[1]),new q(t[2],t[3]),new q(t[0],t[3]),new q(t[0],t[1])])},Point:function(t){var e=a(q,f(t));return this.geometryFactory.createPoint(e)},MultiPoint:function(t){for(var e=[],n=0;n<t.length;++n)e.push(oi.Point.call(this,t[n]));return this.geometryFactory.createMultiPoint(e)},LineString:function(t){var e=oi.coordinates.call(this,t);return this.geometryFactory.createLineString(e)},MultiLineString:function(t){for(var e=[],n=0;n<t.length;++n)e.push(oi.LineString.call(this,t[n]));return this.geometryFactory.createMultiLineString(e)},Polygon:function(t){for(var e=oi.coordinates.call(this,t[0]),n=this.geometryFactory.createLinearRing(e),i=[],r=1;r<t.length;++r){var s=t[r],o=oi.coordinates.call(this,s),a=this.geometryFactory.createLinearRing(o);i.push(a)}return this.geometryFactory.createPolygon(n,i)},MultiPolygon:function(t){for(var e=[],n=0;n<t.length;++n){var i=t[n];e.push(oi.Polygon.call(this,i))}return this.geometryFactory.createMultiPolygon(e)},GeometryCollection:function(t){for(var e=[],n=0;n<t.length;++n){var i=t[n];e.push(this.read(i))}return this.geometryFactory.createGeometryCollection(e)}},ai={coordinate:function(t){var e=[t.x,t.y];return t.z&&e.push(t.z),t.m&&e.push(t.m),e},Point:function(t){return{type:"Point",coordinates:ai.coordinate.call(this,t.getCoordinate())}},MultiPoint:function(t){for(var e=[],n=0;n<t.Tu.length;++n){var i=t.Tu[n],r=ai.Point.call(this,i);e.push(r.coordinates)}return{type:"MultiPoint",coordinates:e}},LineString:function(t){for(var e=[],n=t.getCoordinates(),i=0;i<n.length;++i){var r=n[i];e.push(ai.coordinate.call(this,r))}return{type:"LineString",coordinates:e}},MultiLineString:function(t){for(var e=[],n=0;n<t.Tu.length;++n){var i=t.Tu[n],r=ai.LineString.call(this,i);e.push(r.coordinates)}return{type:"MultiLineString",coordinates:e}},Polygon:function(t){var e=[],n=ai.LineString.call(this,t.Iu);e.push(n.coordinates);for(var i=0;i<t.Ou.length;++i){var r=t.Ou[i],s=ai.LineString.call(this,r);e.push(s.coordinates)}return{type:"Polygon",coordinates:e}},MultiPolygon:function(t){for(var e=[],n=0;n<t.Tu.length;++n){var i=t.Tu[n],r=ai.Polygon.call(this,i);e.push(r.coordinates)}return{type:"MultiPolygon",coordinates:e}},GeometryCollection:function(t){for(var e=[],n=0;n<t.Tu.length;++n){var i=t.Tu[n],r=i.getGeometryType();e.push(ai[r].call(this,i))}return{type:"GeometryCollection",geometries:e}}};return{BufferOp:ii,GeoJSONReader:function(){function e(n){t(this,e),this.parser=new si(n||new re)}return n(e,[{key:"read",value:function(t){return this.parser.read(t)}}]),e}(),GeoJSONWriter:function(){function e(){t(this,e),this.parser=new si(this.geometryFactory)}return n(e,[{key:"write",value:function(t){return this.parser.write(t)}}]),e}()}}()),xf.exports),kf=gf(_f);function $f(){return new Sf}function Sf(){this.reset()}Sf.prototype={constructor:Sf,reset:function(){this.s=this.t=0},add:function(t){Ef(Mf,t,this.t),Ef(this,Mf.s,this.s),this.s?this.t+=Mf.t:this.s=Mf.t},valueOf:function(){return this.s}};var Mf=new Sf;function Ef(t,e,n){var i=t.s=e+n,r=i-e,s=i-r;t.t=e-s+(n-r)}var Cf=1e-6,Af=Math.PI,If=Af/2,Of=Af/4,Tf=2*Af,zf=180/Af,Df=Af/180,Pf=Math.abs,Rf=Math.atan,Nf=Math.atan2,Ff=Math.cos,Uf=Math.sin,qf=Math.sqrt;function jf(t){return t>1?0:t<-1?Af:Math.acos(t)}function Bf(t){return t>1?If:t<-1?-If:Math.asin(t)}function Lf(){}function Hf(t,e){t&&Qf.hasOwnProperty(t.type)&&Qf[t.type](t,e)}var Vf,Wf,Gf={Feature:function(t,e){Hf(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,i=-1,r=n.length;++i<r;)Hf(n[i].geometry,e)}},Qf={Sphere:function(t,e){e.sphere()},Point:function(t,e){t=t.coordinates,e.point(t[0],t[1],t[2])},MultiPoint:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)t=n[i],e.point(t[0],t[1],t[2])},LineString:function(t,e){Kf(t.coordinates,e,0)},MultiLineString:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)Kf(n[i],e,0)},Polygon:function(t,e){Xf(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)Xf(n[i],e)},GeometryCollection:function(t,e){for(var n=t.geometries,i=-1,r=n.length;++i<r;)Hf(n[i],e)}};function Kf(t,e,n){var i,r=-1,s=t.length-n;for(e.lineStart();++r<s;)i=t[r],e.point(i[0],i[1],i[2]);e.lineEnd()}function Xf(t,e){var n=-1,i=t.length;for(e.polygonStart();++n<i;)Kf(t[n],e,1);e.polygonEnd()}function Zf(t){return[Nf(t[1],t[0]),Bf(t[2])]}function Yf(t){var e=t[0],n=t[1],i=Ff(n);return[i*Ff(e),i*Uf(e),Uf(n)]}function Jf(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function td(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function ed(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function nd(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function id(t){var e=qf(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function rd(t,e){function n(n,i){return n=t(n,i),e(n[0],n[1])}return t.invert&&e.invert&&(n.invert=function(n,i){return(n=e.invert(n,i))&&t.invert(n[0],n[1])}),n}function sd(t,e){return[t>Af?t-Tf:t<-Af?t+Tf:t,e]}function od(t){return function(e,n){return[(e+=t)>Af?e-Tf:e<-Af?e+Tf:e,n]}}function ad(t){var e=od(t);return e.invert=od(-t),e}function ud(t,e){var n=Ff(t),i=Uf(t),r=Ff(e),s=Uf(e);function o(t,e){var o=Ff(e),a=Ff(t)*o,u=Uf(t)*o,h=Uf(e),l=h*n+a*i;return[Nf(u*r-l*s,a*n-h*i),Bf(l*r+u*s)]}return o.invert=function(t,e){var o=Ff(e),a=Ff(t)*o,u=Uf(t)*o,h=Uf(e),l=h*r-u*s;return[Nf(u*r+h*s,a*n+l*i),Bf(l*n-a*i)]},o}function hd(t,e){(e=Yf(e))[0]-=t,id(e);var n=jf(-e[1]);return((-e[2]<0?-n:n)+Tf-Cf)%Tf}function ld(){var t,e=[];return{point:function(e,n){t.push([e,n])},lineStart:function(){e.push(t=[])},lineEnd:Lf,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function cd(t,e){return Pf(t[0]-e[0])<Cf&&Pf(t[1]-e[1])<Cf}function fd(t,e,n,i){this.x=t,this.z=e,this.o=n,this.e=i,this.v=!1,this.n=this.p=null}function dd(t,e,n,i,r){var s,o,a=[],u=[];if(t.forEach((function(t){if(!((e=t.length-1)<=0)){var e,n,i=t[0],o=t[e];if(cd(i,o)){for(r.lineStart(),s=0;s<e;++s)r.point((i=t[s])[0],i[1]);r.lineEnd()}else a.push(n=new fd(i,t,null,!0)),u.push(n.o=new fd(i,null,n,!1)),a.push(n=new fd(o,t,null,!1)),u.push(n.o=new fd(o,null,n,!0))}})),a.length){for(u.sort(e),pd(a),pd(u),s=0,o=u.length;s<o;++s)u[s].e=n=!n;for(var h,l,c=a[0];;){for(var f=c,d=!0;f.v;)if((f=f.n)===c)return;h=f.z,r.lineStart();do{if(f.v=f.o.v=!0,f.e){if(d)for(s=0,o=h.length;s<o;++s)r.point((l=h[s])[0],l[1]);else i(f.x,f.n.x,1,r);f=f.n}else{if(d)for(h=f.p.z,s=h.length-1;s>=0;--s)r.point((l=h[s])[0],l[1]);else i(f.x,f.p.x,-1,r);f=f.p}h=(f=f.o).z,d=!d}while(!f.v);r.lineEnd()}}}function pd(t){if(e=t.length){for(var e,n,i=0,r=t[0];++i<e;)r.n=n=t[i],n.p=r,r=n;r.n=n=t[0],n.p=r}}function vd(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function yd(t){for(var e,n,i,r=t.length,s=-1,o=0;++s<r;)o+=t[s].length;for(n=new Array(o);--r>=0;)for(e=(i=t[r]).length;--e>=0;)n[--o]=i[e];return n}$f(),$f(),$f(),sd.invert=sd,1===(Vf=vd).length&&(Wf=Vf,Vf=function(t,e){return vd(Wf(t),e)});var md=1e9,wd=-md,gd=$f();function bd(t){return t}$f(),$f(),$f();var xd=1/0,_d=xd,kd=-xd,$d=kd,Sd={point:function(t,e){t<xd&&(xd=t),t>kd&&(kd=t),e<_d&&(_d=e),e>$d&&($d=e)},lineStart:Lf,lineEnd:Lf,polygonStart:Lf,polygonEnd:Lf,result:function(){var t=[[xd,_d],[kd,$d]];return kd=$d=-(_d=xd=1/0),t}};function Md(t,e,n,i){return function(r,s){var o,a,u,h=e(s),l=r.invert(i[0],i[1]),c=ld(),f=e(c),d=!1,p={point:v,lineStart:m,lineEnd:w,polygonStart:function(){p.point=g,p.lineStart=b,p.lineEnd=x,a=[],o=[]},polygonEnd:function(){p.point=v,p.lineStart=m,p.lineEnd=w,a=yd(a);var t=function(t,e){var n=e[0],i=e[1],r=[Uf(n),-Ff(n),0],s=0,o=0;gd.reset();for(var a=0,u=t.length;a<u;++a)if(l=(h=t[a]).length)for(var h,l,c=h[l-1],f=c[0],d=c[1]/2+Of,p=Uf(d),v=Ff(d),y=0;y<l;++y,f=w,p=b,v=x,c=m){var m=h[y],w=m[0],g=m[1]/2+Of,b=Uf(g),x=Ff(g),_=w-f,k=_>=0?1:-1,$=k*_,S=$>Af,M=p*b;if(gd.add(Nf(M*k*Uf($),v*x+M*Ff($))),s+=S?_+k*Tf:_,S^f>=n^w>=n){var E=td(Yf(c),Yf(m));id(E);var C=td(r,E);id(C);var A=(S^_>=0?-1:1)*Bf(C[2]);(i>A||i===A&&(E[0]||E[1]))&&(o+=S^_>=0?1:-1)}}return(s<-Cf||s<Cf&&gd<-Cf)^1&o}(o,l);a.length?(d||(s.polygonStart(),d=!0),dd(a,Cd,t,n,s)):t&&(d||(s.polygonStart(),d=!0),s.lineStart(),n(null,null,1,s),s.lineEnd()),d&&(s.polygonEnd(),d=!1),a=o=null},sphere:function(){s.polygonStart(),s.lineStart(),n(null,null,1,s),s.lineEnd(),s.polygonEnd()}};function v(e,n){var i=r(e,n);t(e=i[0],n=i[1])&&s.point(e,n)}function y(t,e){var n=r(t,e);h.point(n[0],n[1])}function m(){p.point=y,h.lineStart()}function w(){p.point=v,h.lineEnd()}function g(t,e){u.push([t,e]);var n=r(t,e);f.point(n[0],n[1])}function b(){f.lineStart(),u=[]}function x(){g(u[0][0],u[0][1]),f.lineEnd();var t,e,n,i,r=f.clean(),h=c.result(),l=h.length;if(u.pop(),o.push(u),u=null,l)if(1&r){if((e=(n=h[0]).length-1)>0){for(d||(s.polygonStart(),d=!0),s.lineStart(),t=0;t<e;++t)s.point((i=n[t])[0],i[1]);s.lineEnd()}}else l>1&&2&r&&h.push(h.pop().concat(h.shift())),a.push(h.filter(Ed))}return p}}function Ed(t){return t.length>1}function Cd(t,e){return((t=t.x)[0]<0?t[1]-If-Cf:If-t[1])-((e=e.x)[0]<0?e[1]-If-Cf:If-e[1])}$f();var Ad=Md((function(){return!0}),(function(t){var e,n=NaN,i=NaN,r=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(s,o){var a=s>0?Af:-Af,u=Pf(s-n);Pf(u-Af)<Cf?(t.point(n,i=(i+o)/2>0?If:-If),t.point(r,i),t.lineEnd(),t.lineStart(),t.point(a,i),t.point(s,i),e=0):r!==a&&u>=Af&&(Pf(n-r)<Cf&&(n-=r*Cf),Pf(s-a)<Cf&&(s-=a*Cf),i=function(t,e,n,i){var r,s,o=Uf(t-n);return Pf(o)>Cf?Rf((Uf(e)*(s=Ff(i))*Uf(n)-Uf(i)*(r=Ff(e))*Uf(t))/(r*s*o)):(e+i)/2}(n,i,s,o),t.point(r,i),t.lineEnd(),t.lineStart(),t.point(a,i),e=0),t.point(n=s,i=o),r=a},lineEnd:function(){t.lineEnd(),n=i=NaN},clean:function(){return 2-e}}}),(function(t,e,n,i){var r;if(null==t)r=n*If,i.point(-Af,r),i.point(0,r),i.point(Af,r),i.point(Af,0),i.point(Af,-r),i.point(0,-r),i.point(-Af,-r),i.point(-Af,0),i.point(-Af,r);else if(Pf(t[0]-e[0])>Cf){var s=t[0]<e[0]?Af:-Af;r=n*s/2,i.point(-s,r),i.point(0,r),i.point(s,r)}else i.point(e[0],e[1])}),[-Af,-If]);function Id(t){return function(e){var n=new Od;for(var i in t)n[i]=t[i];return n.stream=e,n}}function Od(){}function Td(t,e,n){var i=e[1][0]-e[0][0],r=e[1][1]-e[0][1],s=t.clipExtent&&t.clipExtent();t.scale(150).translate([0,0]),null!=s&&t.clipExtent(null),function(t,e){t&&Gf.hasOwnProperty(t.type)?Gf[t.type](t,e):Hf(t,e)}(n,t.stream(Sd));var o=Sd.result(),a=Math.min(i/(o[1][0]-o[0][0]),r/(o[1][1]-o[0][1])),u=+e[0][0]+(i-a*(o[1][0]+o[0][0]))/2,h=+e[0][1]+(r-a*(o[1][1]+o[0][1]))/2;return null!=s&&t.clipExtent(s),t.scale(150*a).translate([u,h])}Od.prototype={constructor:Od,point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var zd=16,Dd=Ff(30*Df);function Pd(t,e){return+e?function(t,e){function n(i,r,s,o,a,u,h,l,c,f,d,p,v,y){var m=h-i,w=l-r,g=m*m+w*w;if(g>4*e&&v--){var b=o+f,x=a+d,_=u+p,k=qf(b*b+x*x+_*_),$=Bf(_/=k),S=Pf(Pf(_)-1)<Cf||Pf(s-c)<Cf?(s+c)/2:Nf(x,b),M=t(S,$),E=M[0],C=M[1],A=E-i,I=C-r,O=w*A-m*I;(O*O/g>e||Pf((m*A+w*I)/g-.5)>.3||o*f+a*d+u*p<Dd)&&(n(i,r,s,o,a,u,E,C,S,b/=k,x/=k,_,v,y),y.point(E,C),n(E,C,S,b,x,_,h,l,c,f,d,p,v,y))}}return function(e){var i,r,s,o,a,u,h,l,c,f,d,p,v={point:y,lineStart:m,lineEnd:g,polygonStart:function(){e.polygonStart(),v.lineStart=b},polygonEnd:function(){e.polygonEnd(),v.lineStart=m}};function y(n,i){n=t(n,i),e.point(n[0],n[1])}function m(){l=NaN,v.point=w,e.lineStart()}function w(i,r){var s=Yf([i,r]),o=t(i,r);n(l,c,h,f,d,p,l=o[0],c=o[1],h=i,f=s[0],d=s[1],p=s[2],zd,e),e.point(l,c)}function g(){v.point=y,e.lineEnd()}function b(){m(),v.point=x,v.lineEnd=_}function x(t,e){w(i=t,e),r=l,s=c,o=f,a=d,u=p,v.point=w}function _(){n(l,c,h,f,d,p,r,s,i,o,a,u,zd,e),v.lineEnd=g,g()}return v}}(t,e):function(t){return Id({point:function(e,n){e=t(e,n),this.stream.point(e[0],e[1])}})}(t)}var Rd=Id({point:function(t,e){this.stream.point(t*Df,e*Df)}});function Nd(t){return function(e,n){var i=Ff(e),r=Ff(n),s=t(i*r);return[s*r*Uf(e),s*Uf(n)]}}function Fd(t){return function(e,n){var i=qf(e*e+n*n),r=t(i),s=Uf(r),o=Ff(r);return[Nf(e*s,i*o),Bf(i&&n*s/i)]}}Nd((function(t){return qf(2/(1+t))})).invert=Fd((function(t){return 2*Bf(t/2)}));var Ud=Nd((function(t){return(t=jf(t))&&t/Uf(t)}));function qd(){return(t=Ud,function(t){var e,n,i,r,s,o,a,u,h,l,c=150,f=480,d=250,p=0,v=0,y=0,m=0,w=0,g=null,b=Ad,x=null,_=bd,k=.5,$=Pd(E,k);function S(t){return[(t=s(t[0]*Df,t[1]*Df))[0]*c+n,i-t[1]*c]}function M(t){return(t=s.invert((t[0]-n)/c,(i-t[1])/c))&&[t[0]*zf,t[1]*zf]}function E(t,r){return[(t=e(t,r))[0]*c+n,i-t[1]*c]}function C(){s=rd(r=function(t,e,n){return(t%=Tf)?e||n?rd(ad(t),ud(e,n)):ad(t):e||n?ud(e,n):sd}(y,m,w),e);var t=e(p,v);return n=f-t[0]*c,i=d+t[1]*c,A()}function A(){return h=l=null,S}return S.stream=function(t){return h&&l===t?h:h=Rd(b(r,$(_(l=t))))},S.clipAngle=function(t){return arguments.length?(b=+t?function(t,e){var n=Ff(t),i=n>0,r=Pf(n)>Cf;function s(t,e){return Ff(t)*Ff(e)>n}function o(t,e,i){var r=[1,0,0],s=td(Yf(t),Yf(e)),o=Jf(s,s),a=s[0],u=o-a*a;if(!u)return!i&&t;var h=n*o/u,l=-n*a/u,c=td(r,s),f=nd(r,h);ed(f,nd(s,l));var d=c,p=Jf(f,d),v=Jf(d,d),y=p*p-v*(Jf(f,f)-1);if(!(y<0)){var m=qf(y),w=nd(d,(-p-m)/v);if(ed(w,f),w=Zf(w),!i)return w;var g,b=t[0],x=e[0],_=t[1],k=e[1];x<b&&(g=b,b=x,x=g);var $=x-b,S=Pf($-Af)<Cf;if(!S&&k<_&&(g=_,_=k,k=g),S||$<Cf?S?_+k>0^w[1]<(Pf(w[0]-b)<Cf?_:k):_<=w[1]&&w[1]<=k:$>Af^(b<=w[0]&&w[0]<=x)){var M=nd(d,(-p+m)/v);return ed(M,f),[w,Zf(M)]}}}function a(e,n){var r=i?t:Af-t,s=0;return e<-r?s|=1:e>r&&(s|=2),n<-r?s|=4:n>r&&(s|=8),s}return Md(s,(function(t){var e,n,u,h,l;return{lineStart:function(){h=u=!1,l=1},point:function(c,f){var d,p=[c,f],v=s(c,f),y=i?v?0:a(c,f):v?a(c+(c<0?Af:-Af),f):0;if(!e&&(h=u=v)&&t.lineStart(),v!==u&&(!(d=o(e,p))||cd(e,d)||cd(p,d))&&(p[0]+=Cf,p[1]+=Cf,v=s(p[0],p[1])),v!==u)l=0,v?(t.lineStart(),d=o(p,e),t.point(d[0],d[1])):(d=o(e,p),t.point(d[0],d[1]),t.lineEnd()),e=d;else if(r&&e&&i^v){var m;y&n||!(m=o(p,e,!0))||(l=0,i?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!v||e&&cd(e,p)||t.point(p[0],p[1]),e=p,u=v,n=y},lineEnd:function(){u&&t.lineEnd(),e=null},clean:function(){return l|(h&&u)<<1}}}),(function(n,i,r,s){!function(t,e,n,i,r,s){if(n){var o=Ff(e),a=Uf(e),u=i*n;null==r?(r=e+i*Tf,s=e-u/2):(r=hd(o,r),s=hd(o,s),(i>0?r<s:r>s)&&(r+=i*Tf));for(var h,l=r;i>0?l>s:l<s;l-=u)h=Zf([o,-a*Ff(l),-a*Uf(l)]),t.point(h[0],h[1])}}(s,t,e,r,n,i)}),i?[0,-t]:[-Af,t-Af])}(g=t*Df,6*Df):(g=null,Ad),A()):g*zf},S.clipExtent=function(t){return arguments.length?(_=null==t?(x=o=a=u=null,bd):function(t,e,n,i){function r(r,s){return t<=r&&r<=n&&e<=s&&s<=i}function s(r,s,a,h){var l=0,c=0;if(null==r||(l=o(r,a))!==(c=o(s,a))||u(r,s)<0^a>0)do{h.point(0===l||3===l?t:n,l>1?i:e)}while((l=(l+a+4)%4)!==c);else h.point(s[0],s[1])}function o(i,r){return Pf(i[0]-t)<Cf?r>0?0:3:Pf(i[0]-n)<Cf?r>0?2:1:Pf(i[1]-e)<Cf?r>0?1:0:r>0?3:2}function a(t,e){return u(t.x,e.x)}function u(t,e){var n=o(t,1),i=o(e,1);return n!==i?n-i:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(o){var u,h,l,c,f,d,p,v,y,m,w,g=o,b=ld(),x={point:_,lineStart:function(){x.point=k,h&&h.push(l=[]),m=!0,y=!1,p=v=NaN},lineEnd:function(){u&&(k(c,f),d&&y&&b.rejoin(),u.push(b.result())),x.point=_,y&&g.lineEnd()},polygonStart:function(){g=b,u=[],h=[],w=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,r=h.length;n<r;++n)for(var s,o,a=h[n],u=1,l=a.length,c=a[0],f=c[0],d=c[1];u<l;++u)s=f,o=d,f=(c=a[u])[0],d=c[1],o<=i?d>i&&(f-s)*(i-o)>(d-o)*(t-s)&&++e:d<=i&&(f-s)*(i-o)<(d-o)*(t-s)&&--e;return e}(),n=w&&e,r=(u=yd(u)).length;(n||r)&&(o.polygonStart(),n&&(o.lineStart(),s(null,null,1,o),o.lineEnd()),r&&dd(u,a,e,s,o),o.polygonEnd()),g=o,u=h=l=null}};function _(t,e){r(t,e)&&g.point(t,e)}function k(s,o){var a=r(s,o);if(h&&l.push([s,o]),m)c=s,f=o,d=a,m=!1,a&&(g.lineStart(),g.point(s,o));else if(a&&y)g.point(s,o);else{var u=[p=Math.max(wd,Math.min(md,p)),v=Math.max(wd,Math.min(md,v))],b=[s=Math.max(wd,Math.min(md,s)),o=Math.max(wd,Math.min(md,o))];!function(t,e,n,i,r,s){var o,a=t[0],u=t[1],h=0,l=1,c=e[0]-a,f=e[1]-u;if(o=n-a,c||!(o>0)){if(o/=c,c<0){if(o<h)return;o<l&&(l=o)}else if(c>0){if(o>l)return;o>h&&(h=o)}if(o=r-a,c||!(o<0)){if(o/=c,c<0){if(o>l)return;o>h&&(h=o)}else if(c>0){if(o<h)return;o<l&&(l=o)}if(o=i-u,f||!(o>0)){if(o/=f,f<0){if(o<h)return;o<l&&(l=o)}else if(f>0){if(o>l)return;o>h&&(h=o)}if(o=s-u,f||!(o<0)){if(o/=f,f<0){if(o>l)return;o>h&&(h=o)}else if(f>0){if(o<h)return;o<l&&(l=o)}return h>0&&(t[0]=a+h*c,t[1]=u+h*f),l<1&&(e[0]=a+l*c,e[1]=u+l*f),!0}}}}}(u,b,t,e,n,i)?a&&(g.lineStart(),g.point(s,o),w=!1):(y||(g.lineStart(),g.point(u[0],u[1])),g.point(b[0],b[1]),a||g.lineEnd(),w=!1)}p=s,v=o,y=a}return x}}(x=+t[0][0],o=+t[0][1],a=+t[1][0],u=+t[1][1]),A()):null==x?null:[[x,o],[a,u]]},S.scale=function(t){return arguments.length?(c=+t,C()):c},S.translate=function(t){return arguments.length?(f=+t[0],d=+t[1],C()):[f,d]},S.center=function(t){return arguments.length?(p=t[0]%360*Df,v=t[1]%360*Df,C()):[p*zf,v*zf]},S.rotate=function(t){return arguments.length?(y=t[0]%360*Df,m=t[1]%360*Df,w=t.length>2?t[2]%360*Df:0,C()):[y*zf,m*zf,w*zf]},S.precision=function(t){return arguments.length?($=Pd(E,k=t*t),A()):qf(k)},S.fitExtent=function(t,e){return Td(S,t,e)},S.fitSize=function(t,e){return function(t,e,n){return Td(t,[[0,0],e],n)}(S,t,e)},function(){return e=t.apply(this,arguments),S.invert=e.invert&&M,C()}}((function(){return t}))()).scale(79.4188).clipAngle(179.999);var t}function jd(t,e){return[t,e]}Ud.invert=Fd((function(t){return t})),jd.invert=jd;var{BufferOp:Bd,GeoJSONReader:Ld,GeoJSONWriter:Hd}=kf;function Vd(t,e,n){var i=(n=n||{}).units||"kilometers",r=n.steps||8;if(!t)throw new Error("geojson is required");if("object"!=typeof n)throw new Error("options must be an object");if("number"!=typeof r)throw new Error("steps must be an number");if(void 0===e)throw new Error("radius is required");if(r<=0)throw new Error("steps must be greater than 0");var s=[];switch(t.type){case"GeometryCollection":return mf(t,(function(t){var n=Wd(t,e,i,r);n&&s.push(n)})),cf(s);case"FeatureCollection":return yf(t,(function(t){var n=Wd(t,e,i,r);n&&yf(n,(function(t){t&&s.push(t)}))})),cf(s)}return Wd(t,e,i,r)}function Wd(t,e,n,i){var r=t.properties||{},s="Feature"===t.type?t.geometry:t;if("GeometryCollection"===s.type){var o=[];return mf(t,(function(t){var r=Wd(t,e,n,i);r&&o.push(r)})),cf(o)}var a=function(t){var e=function(t,e={}){const n=function(t,e={}){if(null!=t.bbox&&!0!==e.recompute)return t.bbox;const n=[1/0,1/0,-1/0,-1/0];return vf(t,(t=>{n[0]>t[0]&&(n[0]=t[0]),n[1]>t[1]&&(n[1]=t[1]),n[2]<t[0]&&(n[2]=t[0]),n[3]<t[1]&&(n[3]=t[1])})),n}(t);return function(t,e,n={}){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!pf(t[0])||!pf(t[1]))throw new Error("coordinates must contain numbers");return lf({type:"Point",coordinates:t},e,n)}([(n[0]+n[2])/2,(n[1]+n[3])/2],e.properties,e)}(t).geometry.coordinates,n=[-e[0],-e[1]];return qd().rotate(n).scale(uf)}(s),u={type:s.type,coordinates:Qd(s.coordinates,a)},h=(new Ld).read(u),l=ff(function(t,e="kilometers"){const n=hf[e];if(!n)throw new Error(e+" units is invalid");return t/n}(e,n),"meters"),c=Bd.bufferOp(h,l,i);if(!Gd((c=(new Hd).write(c)).coordinates))return lf({type:c.type,coordinates:Kd(c.coordinates,a)},r)}function Gd(t){return Array.isArray(t[0])?Gd(t[0]):isNaN(t[0])}function Qd(t,e){return"object"!=typeof t[0]?e(t):t.map((function(t){return Qd(t,e)}))}function Kd(t,e){return"object"!=typeof t[0]?e.invert(t):t.map((function(t){return Kd(t,e)}))}var Xd,Zd,Yd=Vd;class Jd extends r.Event{Rc="https://et-api.amap.com";co={viewer:void 0,adCodes:[],areas:[],clientKey:"",clientSecret:"",time:(new Date).getTime(),style:{slightColor:"#ffff00",severeColor:"#ff0000",slightWidth:5,severeWidth:5}};Nc={};Fc=[];Uc=[];qc;jc;constructor(t){super(),this.co.viewer=t.viewer||this.co.viewer,this.co.time=t.time||this.co.time,this.co.adCodes=t.adCodes||this.co.adCodes,this.co.areas=t.areas||this.co.areas,this.co.clientKey=t.clientKey||this.co.clientKey,this.co.clientSecret=t.clientSecret||this.co.clientSecret,this.co.style=Object.assign(this.co.style,t.style),this.co.viewer&&this.Bc()}getLines(){return{severe:this.qc,slight:this.jc}}destroy(){this.qc?.destroy(),this.jc?.destroy(),this.Fc=[],this.Uc=[],this.Nc=[]}show(){this.qc&&(this.qc.show=!0),this.jc&&(this.jc.show=!0)}hide(){this.qc&&(this.qc.show=!1),this.jc&&(this.jc.show=!1)}update(){this.Bc()}async Bc(){this.Nc=await this.Lc(),0!==this.Nc.length&&(this.Hc(),this.Vc())}Wc(){if(!this.co.viewer)return;const t=this.co.viewer;t.scene.preRender.addEventListener((()=>{var e=new r.EllipsoidGeodesic;let n=t.scene,i=n.canvas.clientWidth,s=n.canvas.clientHeight,o=n.camera.getPickRay(new r.Cartesian2(0,s/2)),a=n.camera.getPickRay(new r.Cartesian2(i,s/2));if(o&&a){let t=n.globe,i=t.pick(o,n),r=t.pick(a,n);if(!i)return;if(!r)return;let s=t.ellipsoid.cartesianToCartographic(i),u=t.ellipsoid.cartesianToCartographic(r);e.setEndPoints(s,u),e.surfaceDistance,this.qc}}))}Vc(){this.co.viewer&&(0!==this.Fc.length&&(this.qc=this.Gc(this.Fc,this.co.style.severeColor,this.co.style.severeWidth),this.co.viewer.scene.primitives.add(this.qc)),0!==this.Uc.length&&(this.jc=this.Gc(this.Uc,this.co.style.slightColor,this.co.style.slightWidth),this.co.viewer.scene.primitives.add(this.jc)),this.raiseEvent("loaded"))}Gc(t,e,n){const i=[];return t.forEach((t=>{const s=Yd({type:"LineString",coordinates:t.lngLats},n/2,{units:"meters"}),o=s?.geometry.coordinates;o&&i.push(new r.GeometryInstance({geometry:new r.PolygonGeometry({polygonHierarchy:new r.PolygonHierarchy(r.Cartesian3.fromDegreesArray(o.flat(3)))}),attributes:{color:r.ColorGeometryInstanceAttribute.fromColor(r.Color.fromCssColorString(e))}}))})),new r.GroundPrimitive({geometryInstances:i,asynchronous:!1})}Qc(t,e,n){const i=[];t.forEach((t=>{const e=r.Cartesian3.fromDegreesArray(t.lngLats.flat()),s=new r.GroundPolylineGeometry({positions:e,width:n});s&&i.push(new r.GeometryInstance({geometry:s}))}));const s=new r.PolylineMaterialAppearance({translucent:!1});return s.material=new r.Material({fabric:{type:"Color",uniforms:{color:r.Color.fromCssColorString(e)}}}),new r.GroundPolylinePrimitive({geometryInstances:i,appearance:s,asynchronous:!1})}Hc(){this.Nc.forEach((t=>{t.linkList.forEach((t=>{const e=t.lngLats.split(";").map((t=>{const e=t.split(",");return[+e[0],+e[1]]}));4===t.state?this.Fc.push({roadName:t.roadName,roadType:t.roadType,lngLats:e}):this.Uc.push({roadName:t.roadName,roadType:t.roadType,lngLats:e})}))}))}async Lc(){const t=Math.round((new Date).getTime()/1e3),e=`${this.co.adCodes.join("")}${this.co.clientKey}${t}`;let n=await async function(t,e){const n=new TextEncoder,i=n.encode(e),r=n.encode(t),s=await crypto.subtle.importKey("raw",i,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),o=await crypto.subtle.sign("HMAC",s,r);return Array.from(new Uint8Array(o)).map((t=>t.toString(16).padStart(2,"0"))).join("")}(e,this.co.clientSecret);const i=await fetch(`${this.Rc}/congestion/history?clientKey=${this.co.clientKey}×tamp=${t}&digest=${n.toString()}&adCodes=${this.co.adCodes.join()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({adCodes:this.co.adCodes,areas:this.co.areas,startTime:this.co.time/1e3,endTime:this.co.time/1e3+3600,pageSize:9999,queryList:[{duration:"4",roadType:"0",distance:"200",congestRate:"0",congestType:"0"},{duration:"4",roadType:"1",distance:"200",congestRate:"0",congestType:"0"},{duration:"4",roadType:"2",distance:"200",congestRate:"0",congestType:"0"},{duration:"4",roadType:"3",distance:"200",congestRate:"0",congestType:"0"},{duration:"4",roadType:"4",distance:"200",congestRate:"0",congestType:"0"},{duration:"4",roadType:"5",distance:"200",congestRate:"0",congestType:"0"},{duration:"4",roadType:"6",distance:"200",congestRate:"0",congestType:"0"},{duration:"4",roadType:"7",distance:"200",congestRate:"0",congestType:"0"},{duration:"4",roadType:"8",distance:"200",congestRate:"0",congestType:"0"},{duration:"4",roadType:"9",distance:"200",congestRate:"0",congestType:"0"}]})}),r=await i.json();if(0!==r.code)throw new Error("路况数据获取失败:",r.message);return r.data.list}}class tp extends r.Entity{co;Kc;Xc=0;Zc=0;Yc;Jc;tf;constructor(t){t.eyeOffset=t.eyeOffset||[0,0,0],t.controlOptions=t.controlOptions||{speed:10,steeringSpeed:15};const e=r.Cartesian3.fromDegrees(t.position[0],t.position[1],t.position[2]),n=new r.HeadingPitchRoll(r.Math.toRadians(t.heading-90),0,0);super({position:e,orientation:r.Transforms.headingPitchRollQuaternion(e,n),model:{uri:t.uri,scale:t.scale||1,runAnimations:t.runAnimations}}),this.co=t}ef(){const t=r.Cartesian3.fromDegrees(-123.0744619,44.0503706,5e3),e=new r.HeadingPitchRoll,n=r.Transforms.localFrameToFixedFrameGenerator("north","west");r.Transforms.headingPitchRollToFixedFrame(t,e,r.Ellipsoid.WGS84,n)}static nf=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","KeyA","KeyS","KeyD","KeyW"];static if;static rf=[];static sf=0;static af(t){const e=-1!==tp.nf.indexOf(t.code);e&&-1==tp.rf.indexOf(t.code)&&tp.rf.push(t.code),e&&!tp.sf&&(tp.sf=requestAnimationFrame(tp.uf),tp.if&&(tp.if.Jc=(new Date).getTime()))}static hf(t){const e=-1!==tp.nf.indexOf(t.code),n=tp.rf.indexOf(t.code);e&&-1!==n&&tp.rf.splice(n,1)}static uf(){tp.sf=0;const t=tp.if;if(t)if(tp.rf.length){const e=(new Date).getTime();if(t.Jc&&e-t.Jc){const n=(e-t.Jc)/1e3/3600*1e3*t.co.controlOptions.speed,i=(e-t.Jc)/1e3*t.co.controlOptions.steeringSpeed;if(t.Xc<=1){t.model.runAnimations=!0;let e=0;switch(tp.rf.sort().join(",")){case"ArrowUp":case"KeyW":e=0;break;case"ArrowDown":case"KeyS":e=180;break;case"ArrowLeft":case"KeyA":e=-90;break;case"ArrowRight":case"KeyD":e=90;break;case"ArrowDown,ArrowLeft":case"KeyA,KeyS":e=-135;break;case"ArrowDown,ArrowRight":case"KeyD,KeyS":e=135;break;case"ArrowLeft,ArrowUp":case"KeyA,KeyW":e=-45;break;case"ArrowRight,ArrowUp":case"KeyD,KeyW":e=45}const i=180*t.co.viewer.camera.heading/Math.PI+e,s=new r.HeadingPitchRoll(r.Math.toRadians(i-90),0,0);t.co.heading=i;const o=Math.sin(i*Math.PI/180)*n,a=Math.cos(i*Math.PI/180)*n,u=Dc(new r.Cartesian3(o,a,0),t.co.position),h=r.Cartographic.fromCartesian(u),l=r.Math.toDegrees(h.longitude),c=r.Math.toDegrees(h.latitude);t.co.position=[l,c,t.co.position[2]];const f=r.Cartesian3.fromDegrees(l,c,t.co.position[2]);t.position=f;const d=r.Transforms.headingPitchRollQuaternion(f,s);t.orientation=d}else{t.model.runAnimations=!1;let e=0,s=0;switch(tp.rf.sort().join(",")){case"ArrowUp":case"KeyW":s=1;break;case"ArrowDown":case"KeyS":s=-1;break;case"ArrowLeft":case"KeyA":e=-1;break;case"ArrowRight":case"KeyD":e=1;break;case"ArrowDown,ArrowLeft":case"KeyA,KeyS":e=1,s=-1;break;case"ArrowDown,ArrowRight":case"KeyD,KeyS":e=-1,s=-1;break;case"ArrowLeft,ArrowUp":case"KeyA,KeyW":e=-1,s=1;break;case"ArrowRight,ArrowUp":case"KeyD,KeyW":e=1,s=1}const o=180*t.co.viewer.camera.heading/Math.PI+i*e,a=new r.HeadingPitchRoll(r.Math.toRadians(o-90),0,0);t.co.heading=o;const u=Math.sin(o*Math.PI/180)*n*s,h=Math.cos(o*Math.PI/180)*n*s,l=Dc(new r.Cartesian3(u,h,0),t.co.position),c=r.Cartographic.fromCartesian(l),f=r.Math.toDegrees(c.longitude),d=r.Math.toDegrees(c.latitude);t.co.position=[f,d,t.co.position[2]];const p=r.Cartesian3.fromDegrees(f,d,t.co.position[2]);t.position=p;const v=r.Transforms.headingPitchRollQuaternion(p,a);t.orientation=v;const y=Dc(new r.Cartesian3(t.co.eyeOffset[0],t.co.eyeOffset[1],t.co.eyeOffset[2]),t.co.position);t.co.viewer.camera.setView({destination:y,orientation:{heading:r.Math.toRadians(t.co.heading),pitch:t.co.viewer.camera.pitch}})}}tp.sf=requestAnimationFrame(tp.uf),t.Jc=e}else t.model.runAnimations=!1,t.Jc=void 0}lf(){this.getPrimitive().ff.cf.forEach((t=>{t.runtimeChannels.forEach((t=>{t.animate(0)}))}))}getPrimitive(){if(this.Kc)return this.Kc;{const t=this.co.viewer.scene.primitives.length;for(let e=0;e<t;e+=1){const t=this.co.viewer.scene.primitives.get(e);if(t.id==this)return this.Kc=t,t}}}startControlModel(t=0){this.Zc||tp.if!==this&&(tp.if&&tp.if.stopControlModel(),tp.if=this,document.addEventListener("keydown",tp.af),document.addEventListener("keyup",tp.hf),tp.sf=requestAnimationFrame(tp.uf),this.switchTrackingMode(t))}setControlOptions(t){this.co.controlOptions=t}switchTrackingMode(t){tp.if==this&&(this.co.viewer.trackedEntity=void 0,this.Xc=t,0==t?(this.viewFrom=void 0,this.show=!0):1==t?(this.show=!0,this.co.viewFrom?this.viewFrom=new e.Cartesian3(this.co.viewFrom[0],this.co.viewFrom[1],this.co.viewFrom[2]):this.viewFrom=void 0,this.co.viewer.trackedEntity=this):(this.co.viewer.trackedEntity=this,this.show=!1,requestAnimationFrame((()=>{const t=Dc(new r.Cartesian3(this.co.eyeOffset[0],this.co.eyeOffset[1],this.co.eyeOffset[2]),this.co.position);this.co.viewer.camera.setView({destination:t,orientation:{heading:r.Math.toRadians(this.co.heading),pitch:0}})}))))}stopControlModel(){document.removeEventListener("keydown",tp.af),document.removeEventListener("keyup",tp.hf),tp.sf&&(cancelAnimationFrame(tp.sf),tp.sf=0),tp.if=void 0,tp.rf=[],this.Xc=0,this.Jc=void 0}moveAlong(t,n,i,s,o,a){if(tp.if!==this&&this.stopControlModel(),s=s||t.df(),this.Zc)return;n&&(this.co.viewFrom&&(this.viewFrom=new e.Cartesian3(this.co.viewFrom[0],this.co.viewFrom[1],this.co.viewFrom[2])),this.co.viewer.trackedEntity=this);const u=this;u.position=t.pf.getValue(s);let h=(new Date).getTime(),l=-1;this.Yc=s;const c=()=>{let n=(new Date).getTime()-h;const d=r.JulianDate.addSeconds(s,n/1e3,new r.JulianDate);this.Yc=d;const p=t.pf.getValue(d);u.position=p;const v=t.vf.getValue(d);if(u.orientation=v,p&&this.tf){const t=(this.tf?.steeringSpeed||30)*Math.PI/180,n=r.Matrix3.fromQuaternion(v),i=r.Matrix4.fromRotation(n),s=new e.Cartesian3(-this.tf.range*Math.cos(this.tf.pitch*Math.PI/180),0,-this.tf.range*Math.sin(this.tf.pitch*Math.PI/180));var y=new r.Cartesian4(s.x,s.y,s.z,1),m=r.Matrix4.multiplyByVector(i,y,new r.Cartesian4),w=new r.Cartesian3(m.x,m.y,m.z);const o=e.Cartesian3.add(p,w,new e.Cartesian3);let a=this.co.viewer.camera.pitch,u=this.co.viewer.camera.heading;const h=Pc(o),l=Pc(p),c=Math.atan2(l.lng-h.lng,l.lat-h.lat),d=this.tf.pitch*Math.PI/180;let g=u,b=a;const x=(new Date).getTime(),_=(x-f)/1e3*t;f=x,Math.abs(d-a)<_?b=d:d>a?b+=_:b-=_;const k=Rc(u,c);Math.abs(k)<_?g=c:k>0?g+=_:g-=_,this.co.viewer.camera.lookAt(p,new r.HeadingPitchRange(g,b,this.tf.range))}if(n>=t.yf)i?(h=(new Date).getTime(),this.Zc=requestAnimationFrame(c)):(this.Yc=void 0,this.Zc=0),l!==t.mf.length-1&&a?.call(u,{index:t.mf.length-1}),o?.call(u,{index:t.mf.length-1});else{if(a){const e=t.wf(d);-1!==e&&e!==l&&(l=e,a?.call(u,{index:e}))}this.Zc=requestAnimationFrame(c)}};let f=(new Date).getTime();this.Zc=requestAnimationFrame(c)}follow(t){this.tf=t?{pitch:-90,range:100,steeringSpeed:30,...t}:void 0}stopFollow(){this.tf=void 0}stopMoveAlong(){if(this.Zc)return cancelAnimationFrame(this.Zc),this.Zc=0,this.co.viewer.trackedEntity==this&&(this.co.viewer.trackedEntity=void 0),this.Yc}}class ep{pf;mf=[];yf;gf;vf;constructor(t){this.gf=t;const e=new r.SampledPositionProperty;this.yf=t[t.length-1].time.getTime()-t[0].time.getTime();for(let n=0,i=t.length;n<i;n+=1){const i=t[n],s=r.JulianDate.fromDate(i.time);this.mf.push(s);const o=r.Cartesian3.fromDegrees(i.position[0],i.position[1],i.position[2]);e.addSample(s,o)}this.vf=new r.VelocityOrientationProperty(e),this.pf=e}df(){return this.mf[0]}wf(t){for(let e=0;e<this.mf.length;e+=1)if(r.JulianDate.equalsEpsilon(this.mf[e],t,.1))return e;return-1}bf(t){return this.gf[t]}}function np(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return[...t.geometry.coordinates];if("Point"===t.type)return[...t.coordinates]}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return[...t];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ip(t,e,n={}){var i=np(t),r=np(e),s=df(r[1]-i[1]),o=df(r[0]-i[0]),a=df(i[1]),u=df(r[1]),h=Math.pow(Math.sin(s/2),2)+Math.pow(Math.sin(o/2),2)*Math.cos(a)*Math.cos(u);return ff(2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h)),n.units)}function rp(t,e={}){return function(t,n,i){var r=0;return function(t,n){!function(t,e){mf(t,(function(t,n,i,r,s){var o,a=null===t?null:t.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return!1!==e(lf(t,i,{bbox:r,id:s}),n,0)&&void 0}switch(a){case"MultiPoint":o="Point";break;case"MultiLineString":o="LineString";break;case"MultiPolygon":o="Polygon"}for(var u=0;u<t.coordinates.length;u++){var h=t.coordinates[u];if(!1===e(lf({type:o,coordinates:h},i),n,u))return!1}}))}(t,(function(t,n,i){if(t.geometry){var s=t.geometry.type;if("Point"!==s&&"MultiPoint"!==s){var o,a=0,u=0,h=0;return!1!==vf(t,(function(i,s,l,c,f){if(void 0===o||n>a||c>u||f>h)return o=i,a=n,u=c,h=f,void 0;var d=function(t,e,n={}){if(t.length<2)throw new Error("coordinates must be an array of two or more positions");return lf({type:"LineString",coordinates:t},e,n)}([o,i],t.properties);if(!1===function(t,n,i,s,o){r=((t,n)=>{const i=n.geometry.coordinates;return t+ip(i[0],i[1],e)})(r,t)}(d))return!1;o=i}))&&void 0}}}))}(t),r}(t)}class sp{Ln;xf;_f;kf;$f=0;Yn={};Sf=this.Mf.bind(this);Ef=this.Cf.bind(this);Af=this.If.bind(this);Of="";Tf=this.zf.bind(this);Df=this.Pf.bind(this);Rf=this.Nf.bind(this);Ff=!1;constructor(t){this.Ln=t.viewer,this.xf=t.line,this._f=t.moveSpeed,this.kf=0,this.Bc()}lock(){var t=this.Ln.scene.screenSpaceCameraController;this.Yn={enableTranslate:t.enableTranslate,enableZoom:t.enableZoom,enableRotate:t.enableRotate,enableTilt:t.enableTilt,enableLook:t.enableLook,inertiaSpin:t.inertiaSpin,inertiaTranslate:t.inertiaTranslate,inertiaZoom:t.inertiaZoom},t.enableTranslate=!1,t.enableRotate=!1,t.enableZoom=!1,t.enableLook=!1,t.enableTilt=!1,t.inertiaSpin=0,t.inertiaTranslate=0,t.inertiaZoom=0,this.Uf()}unlock(){var t=this.Ln.scene.screenSpaceCameraController;t.enableTranslate=this.Yn.enableTranslate,t.enableZoom=this.Yn.enableZoom,t.enableRotate=this.Yn.enableRotate,t.enableTilt=this.Yn.enableTilt,t.enableLook=this.Yn.enableLook,t.inertiaSpin=this.Yn.inertiaSpin,t.inertiaTranslate=this.Yn.inertiaTranslate,t.inertiaZoom=this.Yn.inertiaZoom}destroy(){this.unlock(),document.removeEventListener("keydown",this.Sf),document.removeEventListener("keyup",this.Ef);let t=new r.ScreenSpaceEventHandler(this.Ln.scene.canvas);t.removeInputAction(r.ScreenSpaceEventType.MIDDLE_DOWN),t.removeInputAction(r.ScreenSpaceEventType.MOUSE_MOVE),t.removeInputAction(r.ScreenSpaceEventType.MIDDLE_UP)}move(t){"forward"===t?(this.kf+=this._f,this.kf=Math.min(this.kf,this.$f)):(this.kf-=this._f,this.kf=Math.max(this.kf,0)),this.qf()}Bc(){this.$f=1e3*rp({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:this.xf}},{units:"kilometers"}),document.addEventListener("keydown",this.Sf),document.addEventListener("keyup",this.Ef),this.lock(),this.If()}Uf(){let t=new r.ScreenSpaceEventHandler(this.Ln.scene.canvas);t.setInputAction(this.Tf,r.ScreenSpaceEventType.MIDDLE_DOWN),t.setInputAction(this.Df,r.ScreenSpaceEventType.MOUSE_MOVE),t.setInputAction(this.Rf,r.ScreenSpaceEventType.MIDDLE_UP)}zf(t){this.Ff=!0}Pf(t){if(!this.Ff)return;const e=t.endPosition.x-t.startPosition.x,n=t.endPosition.y-t.startPosition.y;this.Ln.camera.setView({destination:this.Ln.camera.position,orientation:{heading:this.Ln.camera.heading-e/1e3,pitch:this.Ln.camera.pitch+n/1e3,roll:0}})}Nf(t){this.Ff=!1}qf(){const t=this.jf(this.xf,this.kf);if(t){const e=r.Cartesian3.fromDegrees(t[0],t[1],t[2]);this.Ln.camera.setView({destination:e,orientation:{heading:this.Ln.camera.heading,pitch:this.Ln.camera.pitch,roll:0}})}}Mf(t){"KeyW"===t.code?this.Of="W":"KeyS"===t.code&&(this.Of="S")}Cf(t){"KeyW"!==t.code&&"KeyS"!==t.code||(this.Of="")}If(){requestAnimationFrame(this.Af),this.Of&&("W"===this.Of&&(this.kf+=this._f,this.kf=Math.min(this.kf,this.$f)),"S"===this.Of&&(this.kf-=this._f,this.kf=Math.max(this.kf,0)),this.qf())}jf(t,e){let n=0;for(let i=1;i<t.length;i++){const r=t[i-1],s=t[i],o=1e3*ip({type:"Point",coordinates:r},{type:"Point",coordinates:s},{units:"kilometers"});if(n<=e&&n+o>e){const t=(e-n)/o;return[r[0]+(s[0]-r[0])*t,r[1]+(s[1]-r[1])*t,r[2]+(s[2]-r[2])*t]}n+=o}}}class op{Ln;co={viewer:void 0,moveRate:1,rotateRate:1};Bf=!1;Lf={moveForward:!1,moveBackward:!1,moveLeft:!1,moveRight:!1,moveUp:!1,moveDown:!1,lookUp:!1,lookDown:!1,lookLeft:!1,lookRight:!1,twistLeft:!1,twistRight:!1,zoomIn:!1,zoomOut:!1};Hf=this.af.bind(this);Vf=this.hf.bind(this);Wf=this.Gf.bind(this);constructor(t){t.viewer&&(this.Ln=t.viewer,this.co=Object.assign(this.co,t),this.Qf())}destroy(){const t=this.Ln;t&&(t.clock.onTick.removeEventListener(this.Wf),document.removeEventListener("keydown",this.Hf,!1),document.removeEventListener("keyup",this.Vf,!1),t.scene.screenSpaceCameraController.enableRotate=!0,t.scene.screenSpaceCameraController.enableTranslate=!0,t.scene.screenSpaceCameraController.enableZoom=!0,t.scene.screenSpaceCameraController.enableTilt=!0,t.scene.screenSpaceCameraController.enableLook=!0)}Qf(){this.Ln&&(document.addEventListener("keydown",this.Hf,!1),document.addEventListener("keyup",this.Vf,!1),this.Ln.clock.onTick.addEventListener(this.Wf),this.Kf())}Xf(t){switch(t){case 87:return"moveForward";case 83:return"moveBackward";case 68:return"moveRight";case 65:return"moveLeft";case 81:return"moveUp";case 69:return"moveDown";case 38:return"lookUp";case 40:return"lookDown";case 37:return"lookLeft";case 39:return"lookRight";case 96:return"twistLeft";case 110:return"twistRight";case 107:return"zoomIn";case 109:return"zoomOut";default:return}}af(t){let e=this.Xf(t.keyCode);void 0!==e&&(this.Lf[e]=!0)}hf(t){let e=this.Xf(t.keyCode);void 0!==e&&(this.Lf[e]=!1)}Gf(){if(!this.Ln)return;let t=this.Ln.camera,e=this.Ln.scene.globe.ellipsoid.cartesianToCartographic(t.position).height,n=e/40*this.co.moveRate;const i=this.Lf;i.moveForward&&t.moveForward(n),i.moveBackward&&t.moveBackward(n),i.moveLeft&&t.moveLeft(n),i.moveRight&&t.moveRight(n),i.moveUp&&t.moveUp(n),i.moveDown&&t.moveDown(n),i.lookUp&&t.lookUp(),i.lookDown&&t.lookDown(),i.lookLeft&&t.lookLeft(),i.lookRight&&t.lookRight(),i.twistLeft&&t.twistLeft(),i.twistRight&&t.twistRight(),i.zoomIn&&t.zoomIn(e/2),i.zoomOut&&t.zoomOut(e/2)}Kf(){if(!this.Ln)return;const t=this.Ln;t.scene.screenSpaceCameraController.enableRotate=!1,t.scene.screenSpaceCameraController.enableTranslate=!1,t.scene.screenSpaceCameraController.enableZoom=!1,t.scene.screenSpaceCameraController.enableTilt=!1,t.scene.screenSpaceCameraController.enableLook=!1,t.screenSpaceEventHandler.setInputAction(this.Zf,r.ScreenSpaceEventType.LEFT_DOWN),t.screenSpaceEventHandler.setInputAction(this.Yf,r.ScreenSpaceEventType.MOUSE_MOVE),t.screenSpaceEventHandler.setInputAction(this.Jf,r.ScreenSpaceEventType.LEFT_UP)}Zf=()=>{this.Bf=!0};Jf=()=>{this.Bf=!1};Yf=t=>{if(this.Ln&&this.Bf){const{startPosition:e,endPosition:n}=t,i=(n.x-e.x)/100*this.co.rotateRate,r=-(n.y-e.y)/100*this.co.rotateRate;this.Ln.camera.setView({orientation:{heading:this.Ln.camera.heading+i,pitch:this.Ln.camera.pitch+r,roll:this.Ln.camera.roll}})}}}class ap{static runningAnimation;co;status=t.CameraAnimationStatus.stop;td;ed=0;nd;rd=-1;constructor(t){this.co=t}start(e){ap.runningAnimation!==this&&ap.runningAnimation?.stop();const n=this.co.path;if(e=e||n.df(),this.status==t.CameraAnimationStatus.running)return;const i=this.co.viewer,r=n.pf.getValue(e),s=n.sd.getValue(e);i.camera.setView({destination:r,orientation:{heading:s.x,pitch:s.y,roll:s.z}}),this.nd=(new Date).getTime(),this.rd=0,this.td=e,this.status=t.CameraAnimationStatus.running,this.ed=requestAnimationFrame(this.ef)}ef=()=>{const t=this.co.path,e=(new Date).getTime();let n=e-this.nd,i=r.JulianDate.addSeconds(this.td,n/1e3,new r.JulianDate);this.td=i;const s=this.co.viewer;if(i>=t.od())this.co.repeat?(this.nd=e,this.td=t.df(),i=this.td,this.ed=requestAnimationFrame(this.ef)):(i=t.od(),this.td=void 0,this.ed=0),this.rd!==t.mf.length-1&&this.co.onReachKeyNode?.call(this,{index:t.mf.length-1}),this.co.onEnd?.call(this,{index:t.mf.length-1});else{if(this.co.onReachKeyNode){const e=t.wf(i);-1!==e&&e!==this.rd&&(this.rd=e,this.co.onReachKeyNode?.call(this,{index:e}))}this.nd=e,this.ed=requestAnimationFrame(this.ef)}const o=t.pf.getValue(i),a=t.sd.getValue(i);s.camera.setView({destination:o,orientation:{heading:a.x,pitch:a.y,roll:a.z}})};stop(){if(this.status===t.CameraAnimationStatus.running)return this.ed&&cancelAnimationFrame(this.ed),this.status=t.CameraAnimationStatus.stop,this.td}pause(){if(this.status===t.CameraAnimationStatus.running)return this.ed&&cancelAnimationFrame(this.ed),this.status=t.CameraAnimationStatus.paused,this.td}resume(e){this.status==t.CameraAnimationStatus.paused&&(this.status=t.CameraAnimationStatus.running,this.td=e,this.nd=(new Date).getTime(),this.ed=requestAnimationFrame(this.ef))}}class up{pf;sd;mf=[];gf;constructor(t,e,n){let i;i=t[0].pos?t:t.map((t=>({pos:t}))),e&&n&&this.ad(i,e,n),this.gf=i;const s=new r.SampledPositionProperty,o=new r.SampledProperty(r.Cartesian3);let a;for(let t=0,e=i.length;t<e;t+=1){const e=i[t],n=r.JulianDate.fromDate(e.time);this.mf.push(n);const u=r.Cartesian3.fromDegrees(e.pos.lng,e.pos.lat,e.pos.height);s.addSample(n,u);let h=r.Math.toRadians(e.pos.heading);const l=2*Math.PI;h=(h%l+l)%l,a&&(h=a+Rc(a,h)),a=h;const c=new r.Cartesian3(a,r.Math.toRadians(e.pos.pitch),r.Math.toRadians(e.pos.roll));o.addSample(n,c)}this.pf=s,this.sd=o}ad(t,n,i){let r=(new Date).getTime();t.forEach(((s,o)=>{let a=s;if(o>0){const s=e.Cartesian3.distance(e.Cartesian3.fromDegrees(a.pos.lng,a.pos.lat,a.pos.height),e.Cartesian3.fromDegrees(t[o-1].pos.lng,t[o-1].pos.lat,t[o-1].pos.height)),u=180*Rc(t[o-1].pos.heading,a.pos.heading)/Math.PI;r+=1e3*Math.round(Math.max(s/n,Math.abs(u)/i,Math.abs(a.pos.pitch-t[o-1].pos.pitch)/i))}t[o].time=new Date(r)}))}df(){return this.mf[0]}od(){return this.mf[this.mf.length-1]}wf(t){for(let e=0;e<this.mf.length;e+=1)if(r.JulianDate.equalsEpsilon(this.mf[e],t,.1))return e;return-1}bf(t){return this.gf[t]}}t.CameraAnimationStatus=void 0,(Xd=t.CameraAnimationStatus||(t.CameraAnimationStatus={}))[Xd.stop=0]="stop",Xd[Xd.running=1]="running",Xd[Xd.paused=2]="paused";class hp{co;Lo=new lp;constructor(t){this.co=t,this.ud()}ud(){const t=this.co.viewer.scene.context,e=r.ShaderProgram.fromCache({context:t,vertexShaderSource:"#version 300 es\nprecision highp int;precision highp float;in vec3 position;uniform mat4 u_vp2;void main(){gl_Position=u_vp2*vec4(position,1.0f);}",fragmentShaderSource:"#version 300 es\nprecision highp float;void main(){out_FragColor=vec4(1,0,0,0.3);}",attributeLocations:{position:0}}),n={enabled:!0,equationRgb:r.BlendEquation.ADD,equationAlpha:r.BlendEquation.ADD,functionSourceRgb:r.BlendFunction.SOURCE_ALPHA,functionDestinationRgb:r.BlendFunction.ONE_MINUS_SOURCE_ALPHA,functionSourceAlpha:r.BlendFunction.ONE,functionDestinationAlpha:r.BlendFunction.ONE_MINUS_SOURCE_ALPHA},i=r.RenderState.fromCache({depthTest:{enabled:!0},blending:n,depthMask:!0,colorMask:{red:!1,green:!1,blue:!1,alpha:!1}}),s=r.Cartesian3.fromDegrees(this.co.enuCenter[0],this.co.enuCenter[1],this.co.enuCenter[2]),o={u_vp2:()=>{let t=this.co.viewer.camera.frustum.projectionMatrix;const e=r.Transforms.eastNorthUpToFixedFrame(s);var n=r.Matrix4.multiply(this.co.viewer.camera.viewMatrix,e,new r.Matrix4);return r.Matrix4.multiply(t,n,new r.Matrix4)}},a=new r.VertexArray({name:"glbDepth",context:t,attributes:[{index:0,vertexBuffer:r.Buffer.createVertexBuffer({usage:r.BufferUsage.STATIC_DRAW,typedArray:new Float32Array(this.co.vertices),context:t}),componentsPerAttribute:3,componentDatatype:r.ComponentDatatype.FLOAT}],indexBuffer:r.Buffer.createIndexBuffer({context:t,typedArray:new Uint32Array(this.co.faces),usage:r.BufferUsage.STATIC_DRAW,indexDatatype:r.IndexDatatype.UNSIGNED_INT})}),u=new r.DrawCommand({vertexArray:a,shaderProgram:e,uniformMap:o,renderState:i,pass:r.Pass.OPAQUE,count:this.co.faces.length});this.Lo.Je=u,this.co.viewer.scene.primitives.add(this.Lo)}}class lp{Je;sn=!0;ye=!1;constructor(){}update(t){this.ye||this.sn&&t.commandList.push(this.Je)}isDestroyed(){return this.ye}show(){0==this.sn&&(this.sn=!0)}hide(){this.sn&&(this.sn=!1)}destroy(){this.ye=!0,this.Je.vertexArray.getAttribute(1).vertexBuffer.destroy(),this.Je.vertexArray.cn=[],this.Je.vertexArray.destroy()}}class cp extends r.Event{co={viewer:void 0,uri:"",adcode:"110000",bounds:[-90,-180,180,90],startTime:"20240901102940",endTime:"20240908102940",meshUri:"",meshEnuCenter:[120.14099999999999,30.240000000000002,0],meshHeight:0,style:{modelUri:"",modelScale:1}};Nc={};hd=[];ld;constructor(t){super(),this.co.viewer=t.viewer||this.co.viewer,this.co.meshEnuCenter=t.meshEnuCenter||this.co.meshEnuCenter,this.co.uri=t.uri||this.co.uri,this.co.meshUri=t.meshUri||this.co.meshUri,this.co.startTime=t.startTime||this.co.startTime,this.co.adcode=t.adcode||this.co.adcode,this.co.bounds=t.bounds||this.co.bounds,this.co.meshHeight=t.meshHeight||this.co.meshHeight,this.co.style=Object.assign(this.co.style,t.style),this.co.viewer&&this.Bc()}destroy(){this.Nc=[],this.hd.forEach((t=>{this.co.viewer?.entities.remove(t)}))}show(){this.hd.forEach((t=>{t.show=!0}))}hide(){this.hd.forEach((t=>{t.show=!1}))}update(){this.Bc()}async Bc(){this.Nc=await this.Lc(),this.fd(),this.dd()}fd(){const t=this.co.viewer;if(!t)return;const e=["./car0.glb","./car1.glb","./car4.glb","./car5.glb","./car6.glb","./car13.glb"];for(let n=0;n<this.Nc.length;n++){const i=this.Nc[n],s=r.Cartesian3.fromDegrees(i[0].point[0],i[0].point[1],this.co.meshHeight),o=t.entities.add({name:`Model ${n}`,position:s,orientation:r.Transforms.headingPitchRollQuaternion(s,new r.HeadingPitchRoll(0,0,0)),model:{uri:this.co.style.modelUri||e[0],scale:this.co.style.modelScale||1,heightReference:r.HeightReference.RELATIVE_TO_TERRAIN}});this.hd.push(o)}}dd(){const t=this.co.viewer;if(!t)return;let e=1/0,n=0;for(let t=0;t<this.Nc.length;t++){const i=this.Nc[t];e=Math.min(e,i[0].time),n=Math.max(n,i[i.length-1].time)}const i=r.JulianDate.now();for(let t=0;t<this.Nc.length;t++){const e=this.Nc[t],n=new r.SampledPositionProperty;for(let t=1;t<e.length;t++){const s=e[t].point,o=e[t].time,a=r.JulianDate.addSeconds(i,o,new r.JulianDate),u=r.Cartesian3.fromDegrees(s[0],s[1],this.co.meshHeight);n.addSample(a,u)}const s=this.hd[t];s.position=n;const o=new r.VelocityOrientationProperty(n,r.Ellipsoid.WGS84);s.orientation=o}const s=t.clock;s.shouldAnimate=!0,s.startTime=r.JulianDate.addSeconds(i,e,new r.JulianDate),s.currentTime=s.startTime,s.stopTime=r.JulianDate.addSeconds(i,n,new r.JulianDate),s.clockRange=r.ClockRange.LOOP_STOP,s.multiplier=1}async Lc(){const t=await fetch(this.co.uri,{method:"GET"}),e=await t.json();if(0!==e.code)throw new Error("浮动车数据获取失败:"+e.message);return e.data.trackPoint}async pd(){if(!this.co.viewer)return;const t=await this.vd();this.ld=new hp({viewer:this.co.viewer,enuCenter:this.co.meshEnuCenter,vertices:t.vertices,faces:t.faces})}async vd(){const t=await fetch(this.co.meshUri,{method:"GET"}),e=await t.json();if(!e.faces||!e.vertices)throw new Error("Mesh 模型数据获取失败:"+e.message);return e}}!function(t){t[t.distance=0]="distance",t[t.groundArea=1]="groundArea"}(Zd||(Zd={}));class fp{yd=Zd.distance;md;wd;gd=[];Es="closed";bd=[];xd;Kn=[];Ln;co;ye=!1;constructor(t,n){this.co={unit:"米",precision:.1,...n},this.Ln=t;const i=e=>{let n;return this.yd===Zd.distance?n=t.entities.add({polyline:{positions:e,width:5,material:new r.PolylineOutlineMaterialProperty({color:new r.Color(0,98/255,254/255,1),outlineColor:r.Color.WHITE,outlineWidth:2}),depthFailMaterial:new r.PolylineOutlineMaterialProperty({color:new r.Color(0,98/255,254/255,1),outlineColor:r.Color.WHITE,outlineWidth:2})}}):this.yd===Zd.groundArea&&(n=t.entities.add({polygon:{hierarchy:e,material:new r.ColorMaterialProperty(new r.Color(0,98/255,254/255,.3))}})),t.scene.requestRender(),n};this.md=new e.ScreenSpaceEventHandler(t.canvas);const s=e=>{let n=t.scene.pickPosition(e);if(!n){const i=t.scene.pick(e,1,1);!i||i.id!=this.xd&&-1===this.Kn.indexOf(i.id)||(n=i.id.position.getValue(r.JulianDate.now()))}return n};this.md.setInputAction((t=>{if("open"!==this.Es)return;const e=s(t.position);if(r.defined(e))if(this.wd){this.bd.pop();const t=this.bd[this.bd.length-1];if(this.bd.push(e,e),this.yd==Zd.distance){let n=r.Cartesian3.distance(e,t);const i=this.co.unit;if("分米"==i&&(n*=10),"厘米"==i&&(n*=100),"毫米"==i&&(n*=1e3),"dm"==i&&(n*=10),"cm"==i&&(n*=100),"mm"==i&&(n*=1e3),this.co.precision<=1){const t=Math.round(1/this.co.precision);n=Math.round(n*t)/t}else n=Math.round(n/this.co.precision)*this.co.precision;const s=new r.Cartesian3;r.Cartesian3.add(t,e,s),r.Cartesian3.divideByScalar(s,2,s),this.Kn.push(this._d(s,n+" "+i))}this.Kn.push(this.kd(e))}else{this.xd=this.kd(e);const t=[e,e],n=new r.CallbackProperty((()=>{if(this.wd)return this.yd===Zd.groundArea?new r.PolygonHierarchy(this.bd):this.bd}),!1);this.wd=i(n),this.bd=t,this.Kn.push(this.kd(e))}}),r.ScreenSpaceEventType.LEFT_CLICK),this.md.setInputAction((t=>{if("open"===this.Es&&r.defined(this.xd)){const e=s(t.endPosition);r.defined(e)&&(this.xd.position.setValue(e),this.bd.pop(),this.bd.push(e),this.Ln.scene.requestRender())}}),r.ScreenSpaceEventType.MOUSE_MOVE),this.md.setInputAction((t=>{this.$d()}),r.ScreenSpaceEventType.RIGHT_CLICK)}destroy(){this.stop(!0),this.md.destroy(),this.ye=!0}Sd(){if(this.wd)if(this.yd===Zd.distance)this.wd.polyline.positions=this.bd,this.bd.length<2?(this.Ln.entities.remove(this.wd),this.Kn.forEach((t=>{this.Ln.entities.remove(t)}))):(this.gd.push(this.wd),this.gd.push.apply(this.gd,this.Kn),this.Kn=[]);else if(this.yd===Zd.groundArea)if(this.wd.polygon.hierarchy=new r.PolygonHierarchy(this.bd),this.bd.length<3)this.Ln.entities.remove(this.wd),this.Kn.forEach((t=>{this.Ln.entities.remove(t)}));else{this.gd.push(this.wd),this.gd.push.apply(this.gd,this.Kn);const t=new r.Cartesian3;this.bd.forEach((e=>{t.x+=e.x,t.y+=e.y,t.z+=e.z})),r.Cartesian3.divideByScalar(t,this.bd.length,t),this.gd.push(this._d(t,"100")),this.Kn=[]}return this.Ln.scene.requestRender(),this.wd}kd(t){const e=this.Ln.entities.add({position:t,point:{color:new r.Color(0,98/255,254/255,1),outlineColor:r.Color.WHITE,outlineWidth:1.5,pixelSize:5}});return this.Ln.scene.requestRender(),e}_d(t,e){const n=this.Ln.entities.add({position:t,label:{text:e,font:"12px sans-serif",horizontalOrigin:r.HorizontalOrigin.CENTER,verticalOrigin:r.VerticalOrigin.CENTER,fillColor:r.Color.GHOSTWHITE,showBackground:!0,backgroundColor:new r.Color(0,98/255,254/255,1),backgroundPadding:new r.Cartesian2(4,4),pixelOffset:new r.Cartesian2(0,-20),disableDepthTestDistance:Number.POSITIVE_INFINITY}});return this.Ln.scene.requestRender(),n}$d(){"open"===this.Es&&(this.bd.pop(),this.Ln.entities.remove(this.xd),this.xd=void 0,this.Sd(),this.wd=void 0,this.bd=[])}Md(){this.ye||(this.Es="open")}distance(t=!1){this.wd&&this.$d(),this.yd=Zd.distance,this.Md()}area(t=!1){this.wd&&this.$d(),this.yd=Zd.groundArea,this.Md()}stop(t){this.Es="closed",t&&this.clear()}clear(){this.$d(),this.xd&&this.Ln.entities.remove(this.xd),this.Kn.forEach((t=>{this.Ln.entities.remove(t)})),this.wd&&this.Ln.entities.remove(this.wd),this.gd.forEach((t=>{this.Ln.entities.remove(t)})),this.Ln.scene.requestRender()}}Math.PI;const dp=180/Math.PI,pp=6378137,vp=20037508.342789244,yp=t=>{const e=t[0],n=t[1];return[e/pp*dp,(2*Math.atan(Math.exp(n/pp))-Math.PI/2)*dp]},mp=t=>2*vp/2**t,wp=yp,gp=(t,e,n)=>{const i=[-20037508.342789244,-20037508.342789244,20037508.342789244,20037508.342789244];let r;return r=void 0===n?40075016.68557849:256*Math.pow(2,n),[t=(t/r-.5)*i[2]*2,e=-(e/r-.5)*i[2]*2]},bp=t=>yp((t=>{const e=t[0],n=mp(e),i=t[1],r=t[2];return[(i+.5)*n-vp,vp-(r+.5)*n]})(t)),xp=(t,e=!1)=>{const n=t[0],i=mp(n),r=t[1],s=t[2],o=r*i-vp,a=o+i,u=vp-s*i,h=yp([o,u-i]),l=yp([a,u]),c=[h[0],h[1],l[0],l[1]];return e?[h,[l[0],h[1]],l,[h[0],l[1]]]:c};class _p{ro;so="栅格图";oo=!1;ao;uo;ho;_show=!0;lo;Ln;Ed;Cd;Ad=0;Id=0;co;constructor(t){this.co=t,this.Ln=t.viewer,this.ao=new r.Event,this.uo=new r.Event,this.Cd=new Hc({Bi:100,qi:(t,e)=>{e.entity&&this.ro.remove(e.entity)}}),this.oo=!1,this.ho=new r.Event,this.ro=new r.EntityCollection,this.lo=new r.EntityCluster,this.Ed=[[4,11,5],[4,12,5],[4,13,5],[4,11,6],[4,12,6],[4,13,6],[4,12,7],[4,13,7]]}get name(){return this.so}clock=null;get entities(){return this.ro}get isLoading(){return this.oo}get changedEvent(){return this.ao}get errorEvent(){return this.uo}get loadingEvent(){return this.ho}get show(){return this._show}set show(t){this._show=t}get clustering(){return this.lo}set clustering(t){if(!r.defined(t))throw new r.DeveloperError("value must be defined.");this.lo=t}update(){const t=(new Date).getTime();if(t-this.Ad<1e3)return!0;this.Ad=t;const e=this.ro,n=this.Ln,i=n.scene.canvas,s=new r.Cartesian2(i.clientWidth/2,i.clientHeight/2),o=n.scene.pickPosition(s);if(o){const i=n.scene.camera,s=r.Cartesian3.distance(i.positionWC,o),a=Math.min(this.co.zooms[1],Math.round(Math.log2(2400/s))+16);if(a>=this.co.zooms[0]&&this.show){const n=r.Cartographic.fromCartesian(o).height;if(n>=-400){if(e.suspendEvents(),e.removeAll(),this.co.forceUpdateTime&&this.Id){const e=Math.floor(t/(1e3*this.co.forceUpdateTime));e!==this.Id&&(this.Cd._e(),this.Id=e)}const s=i.frustum.computeCullingVolume(i.positionWC,i.directionWC,i.upWC).planes;(new Date).getTime();const o=[],u=t=>{let e=!1,h=!1;const l=xp(t),c=bp(t);let f=[c[0],c[1],n];const d=f[0],p=f[1],v=f[2],y=Cc([l[0],l[1],n],f),m=Cc([l[2],l[3],n],f),w=[y.x,y.y,y.z,m.x,m.y,Math.max(n,m.z)],g=4800*2**(16-t[0]),b=r.Cartesian3.fromDegrees(d,p,v),x=r.Transforms.eastNorthUpToFixedFrame(b),_=r.Matrix4.inverse(x,new r.Matrix4),k=s.map((t=>{const e=new r.Cartesian3(t.x,t.y,t.z),n=t.w,i=r.Matrix4.multiplyByPointAsVector(_,e,new r.Cartesian3),s=r.Cartesian3.multiplyByScalar(e,-n,new r.Cartesian3),o=r.Matrix4.multiplyByPoint(_,s,new r.Cartesian3),a=-r.Cartesian3.dot(i,o);return new r.Cartesian4(i.x,i.y,i.z,a)})),$=new r.Cartesian3(w[0],w[1],w[2]),S=new r.Cartesian3(w[3],w[4],w[5]),M=new r.AxisAlignedBoundingBox($,S);if(e=new r.CullingVolume(k).computeVisibility(M)!==r.Intersect.OUTSIDE,e){const e=((t,e,n)=>{const i=Tc(t,n);return((t,e,n,i,r,s,o,a,u)=>{let h=Math.max(t-o,0,o-i),l=Math.max(e-a,0,a-r),c=Math.max(n-u,0,u-s);return Math.sqrt(h*h+l*l+c*c)})(e[0],e[1],e[2],e[3],e[4],e[5],i.x,i.y,i.z)})(i.positionWC,w,f);if(h=e<=g,h)if(t[0]<a){const e=t[0]+1,n=[[e,t[1]<<1,t[2]<<1],[e,t[1]<<1,1+(t[2]<<1)],[e,1+(t[1]<<1),t[2]<<1],[e,1+(t[1]<<1),1+(t[2]<<1)]];for(let t=0;t<n.length;t+=1){const e=n[t];u(e)}}else o.push(t)}return[e,h,!1,!1]};for(let t=0;t<this.Ed.length;t+=1){const e=this.Ed[t];u(e)}o.forEach((t=>{t.join("_");const n=this.co.getTileUrl(t,new Date),i=this.Cd.Ji(n,!1);if(i)"loaded"==i.status&&(e.contains(i.entity)||(e.add(i.entity),this.co.viewer.scene.requestRender()));else{const i=document.createElement("img");i.crossOrigin="anonymous",i.src=n;const s=xp(t);i.onload=()=>{const o=new r.Entity({id:n,rectangle:{coordinates:r.Rectangle.fromDegrees(s[0],s[1],s[2],s[3]),material:new r.ImageMaterialProperty({image:i}),zIndex:t[0]}});e.add(o),this.co.viewer.scene.requestRender();const a=this.Cd.Ji(n,!0);a.entity=o,a.status="loaded"},i.onerror=()=>{this.Cd.Ji(n,!0).status="error"};const o={status:"loading",entity:null};this.Cd.nr(n,o)}})),e.resumeEvents()}}else e.removeAll()}return!0}}class kp{Ln;bo;ye=!1;constructor(t){const e=t.viewer;this.Ln=e,this.bo=new _p(t),e.dataSources.add(this.bo)}setVisibility(t,e){this.bo&&(this.bo.show=e)}hide(){this.bo&&(this.bo.show=!1)}show(){this.bo&&(this.bo.show=!0)}destory(){this.bo&&(this.bo.entities.removeAll(),this.Ln?.dataSources.remove(this.bo),this.bo=void 0),this.ye=!0,this.Ln=void 0}}class $p extends kp{constructor(t){super({name:"交通预测栅格图",viewer:t,forceUpdateTime:300,zooms:[8,17],getTileUrl:(t,e)=>`https://history.traffic.amap.com/traffic?type=2&day=${e.getDay()}&hh=${e.getHours()}&mm=${5*Math.floor(e.getMinutes()/5)}&x=${t[1]}&y=${t[2]}&z=${t[0]}`})}}class Sp extends kp{constructor(t){super({name:"路网栅格图",viewer:t,forceUpdateTime:0,zooms:[3,18],getTileUrl:t=>`https://wprd0${(t[1]+t[2])%4+1}.is.autonavi.com/appmaptile?x=${t[1]}&y=${t[2]}&z=${t[0]}&lang=zh_cn&size=1&scl=1&style=8`})}}class Mp{ro;so="矢量实时路况";oo=!1;ao;uo;ho;_show=!0;lo;Ln;Ed;Cd;Ad=0;Id=0;co;constructor(t){this.co=t,this.Ln=t.viewer,this.ao=new r.Event,this.uo=new r.Event,this.Cd=new Hc({Bi:100,qi:(t,e)=>{e.entity&&this.ro.remove(e.entity)}}),this.oo=!1,this.ho=new r.Event,this.ro=new r.EntityCollection,this.lo=new r.EntityCluster,this.Ed=[[4,11,5],[4,12,5],[4,13,5],[4,11,6],[4,12,6],[4,13,6],[4,12,7],[4,13,7]]}get name(){return this.so}clock=null;get entities(){return this.ro}get isLoading(){return this.oo}get changedEvent(){return this.ao}get errorEvent(){return this.uo}get loadingEvent(){return this.ho}get show(){return this._show}set show(t){this._show=t}get clustering(){return this.lo}set clustering(t){if(!r.defined(t))throw new r.DeveloperError("value must be defined.");this.lo=t}update(){const t={0:"fff93a43",1:"fffcac19",2:"ff20a962",3:"ff83171c",4:"ffadadad"},e=(new Date).getTime();if(e-this.Ad<1e3)return!0;this.Ad=e;const n=this.ro,i=this.Ln,s=i.scene.canvas,o=new r.Cartesian2(s.clientWidth/2,s.clientHeight/2),a=i.scene.pickPosition(o);if(a){const s=i.scene.camera,o=r.Cartesian3.distance(s.positionWC,a),u=Math.min(this.co.zooms[1],Math.round(Math.log2(2400/o))+16);if(u>=this.co.zooms[0]&&this.show){const i=10;r.Cartographic.fromCartesian(a).height;{n.suspendEvents(),n.removeAll();const o=Math.floor(e/12e4);o!==this.Id&&(this.Id=o);const a=s.frustum.computeCullingVolume(s.positionWC,s.directionWC,s.upWC).planes;(new Date).getTime();const h=[],l=t=>{let e=!1,n=!1;const o=xp(t),c=bp(t);let f=[c[0],c[1],i];const d=f[0],p=f[1],v=f[2],y=Cc([o[0],o[1],i],f),m=Cc([o[2],o[3],i],f),w=[y.x,y.y,y.z,m.x,m.y,Math.max(i,m.z)],g=4800*2**(16-t[0]),b=r.Cartesian3.fromDegrees(d,p,v),x=r.Transforms.eastNorthUpToFixedFrame(b),_=r.Matrix4.inverse(x,new r.Matrix4),k=a.map((t=>{const e=new r.Cartesian3(t.x,t.y,t.z),n=t.w,i=r.Matrix4.multiplyByPointAsVector(_,e,new r.Cartesian3),s=r.Cartesian3.multiplyByScalar(e,-n,new r.Cartesian3),o=r.Matrix4.multiplyByPoint(_,s,new r.Cartesian3),a=-r.Cartesian3.dot(i,o);return new r.Cartesian4(i.x,i.y,i.z,a)})),$=new r.Cartesian3(w[0],w[1],w[2]),S=new r.Cartesian3(w[3],w[4],w[5]),M=new r.AxisAlignedBoundingBox($,S);if(e=new r.CullingVolume(k).computeVisibility(M)!==r.Intersect.OUTSIDE,e){const e=((t,e,n)=>{const i=Tc(t,n);return((t,e,n,i,r,s,o,a,u)=>{let h=Math.max(t-o,0,o-i),l=Math.max(e-a,0,a-r),c=Math.max(n-u,0,u-s);return Math.sqrt(h*h+l*l+c*c)})(e[0],e[1],e[2],e[3],e[4],e[5],i.x,i.y,i.z)})(s.positionWC,w,f);if(n=e<=g,n)if(t[0]<u){const e=t[0]+1,n=[[e,t[1]<<1,t[2]<<1],[e,t[1]<<1,1+(t[2]<<1)],[e,1+(t[1]<<1),t[2]<<1],[e,1+(t[1]<<1),1+(t[2]<<1)]];for(let t=0;t<n.length;t+=1){const e=n[t];l(e)}}else h.push(t)}return[e,n,!1,!1]};for(let t=0;t<this.Ed.length;t+=1){const e=this.Ed[t];l(e)}h.forEach((e=>{const i=function(t,e,n){let i,r,s,o,a,u;return o=Math.floor(n/2),s=n-o,i=(1<<o)-1<<s,r=(1<<s)-1,u=e&i|t&r,a=t&i|e&r,[n,a,u]}(e[1],e[2],e[0]),s="https://vdata.amap.com/traffic?key="+this.co.key+"&v=YunJingCesium&t="+i,o=s+"&w="+12e4*this.Id;let a=this.Cd.Ji(s,!1),u=!1;a?("loaded"==a.status&&(a.entities.forEach((t=>{n.add(t)})),this.co.viewer.scene.requestRender()),a.Id!==this.Id&&(u=!0)):(u=!0,a={status:"loading",entities:[]},this.Cd.nr(s,a)),u&&fetch(o).then((n=>{try{n.json().then((n=>{const a=this.Cd.Ji(s,!1);if(a&&(a.status="loaded",a.entities=[],n.data)){n=(n=n.data)[i.join("_")];const s=(u=e[0],2*vp/256/Math.pow(2,u));for(let i=0,u=n.length;i<u;i++){const u=n[i],h=Uc(t[i]);for(let t=0,n=u.length;t<n;t++){const n=u[t],i=.6*n[0]*this.co.lineWidthFactor;for(let t=0,u=n[1].length;t<u;t++){const u=[],l=qc(n[1][t]);for(let t=0,n=l.length;t<n;t+=2){const n=s*(256*e[1]+l[t]),i=s*(256*e[2]+l[t+1]),o=wp(gp(n,i)),a=r.Cartesian3.fromDegrees(o[0],o[1],0);u.push(a)}const c=new r.Entity({id:o+"_"+a.entities.length,polyline:{positions:u,clampToGround:!0,material:new r.Color(...h),zIndex:e[0],width:3*i}});a.entities.push(c)}}}a.Id=this.Id}var u}))}catch(t){const e=this.Cd.Ji(s,!1);if(e)return void(e.status="loaded")}}))})),n.resumeEvents()}}else n.removeAll()}return!0}}class Ep{Ln;bo;ye=!1;constructor(t){t.zooms=t.zooms||[7,17],t.zooms=[Math.max(7,t.zooms[0]),Math.min(17,t.zooms[1])],t.lineWidthFactor=t.lineWidthFactor||1;const e=t.viewer;this.Ln=e,this.bo=new Mp(t),e.dataSources.add(this.bo)}setVisibility(t,e){this.bo&&(this.bo.show=e)}hide(){this.bo&&(this.bo.show=!1)}show(){this.bo&&(this.bo.show=!0)}destroy(){this.bo&&(this.bo.entities.removeAll(),this.Ln?.dataSources.remove(this.bo),this.bo=void 0),this.ye=!0,this.Ln=void 0}}class Cp{ro;so="单体化图层";oo=!1;ao;uo;ho;_show=!0;lo;Ln;co;fo;qt;do;po;vo;yo;wo;constructor(t){this.co=t,this.wo=t.cb,this.Ln=t.viewer,this.qt=t.tiles,this.fo=t.api_url,this.yo={},this.do=t.data,this.po={},this.vo=new Hc({Bi:10,qi:this.onDrop}),this.ao=new r.Event,this.uo=new r.Event,this.oo=!1,this.ho=new r.Event,this.ro=new r.EntityCollection,this.lo=new r.EntityCluster,this.init()}init(){for(let t of this.do)this.drawMonomer(this.ro,t,this.yo);this.wo&&this.wo(this.ro)}drawMonomer(t,e,n){const i=e.id.toString().split("@")[0];if(void 0!==n[i])return;let s=[],o=e.min_height;const a=e.contours;for(let t of a){const n=parseFloat(t[0]),i=parseFloat(t[1]);s.push(n),s.push(i),s.push(e.max_height)}t.add({name:"polygon",polygon:{hierarchy:r.Cartesian3.fromDegreesArrayHeights(s),material:r.Color.BLUE.withAlpha(.3),extrudedHeight:o,perPositionHeight:!0}}),n[i]=e}get name(){return this.so}clock=null;get entities(){return this.ro}get isLoading(){return this.oo}get changedEvent(){return this.ao}get errorEvent(){return this.uo}get loadingEvent(){return this.ho}get show(){return this._show}set show(t){this._show=t}get clustering(){return this.lo}set clustering(t){if(!r.defined(t))throw new r.DeveloperError("value must be defined.");this.lo=t}onDrop=(t,e)=>{delete this.po[t],this.yo=[],this.do=[],this.ro.removeAll();for(let t in this.po)this.do=this.do.concat(this.po[t]);for(let t of this.do)this.drawMonomer(this.ro,t,this.yo);return!0};updateData(t){for(let e of t)this.vo.rr(e)||(this.vo.nr(e,"1"),fetch(this.fo+e+".json").then((t=>t.json())).then((t=>{this.po[e]=t,this.do=[];for(let t in this.po)this.do=this.do.concat(this.po[t]);for(let t of this.do)this.drawMonomer(this.ro,t,this.yo)})).catch((t=>{})));return!0}update(){return!0}pick(t){var e=this.Ln.scene.pick(t);return e?null!=e?.id?.id?this.yo[e.id.id]:void 0:null}}class Ap{Ln;bo;ye=!1;constructor(t){const e=t.viewer;this.Ln=e,this.bo=new Cp(t),e.dataSources.add(this.bo)}setVisibility(t,e){this.bo&&(this.bo.show=e)}hide(){this.bo&&(this.bo.entities.show=!1)}show(){this.bo&&(this.bo.entities.show=!0)}destory(){this.bo&&(this.bo.entities.removeAll(),this.Ln?.dataSources.remove(this.bo),this.bo=void 0),this.ye=!0,this.Ln=void 0}getEntities(){return this.bo?.entities}update(t){return this.bo?.updateData(t)}pick(t){return this.bo?.pick(t)}}var Ip,Op,Tp=function(){if(Op)return Ip;Op=1,Ip=function(n,i){i||(i={});var r,s,o,a,u,h,l,c,f,d,p,v=null==i.cutoff?.25:i.cutoff,y=null==i.radius?8:i.radius,m=i.channel||0;if(ArrayBuffer.isView(n)||Array.isArray(n)){if(!i.width||!i.height)throw Error("For raw data width and height should be provided by options");r=i.width,s=i.height,a=n,h=i.stride?i.stride:Math.floor(n.length/r/s)}else window.HTMLCanvasElement&&n instanceof window.HTMLCanvasElement?(l=(c=n).getContext("2d"),r=c.width,s=c.height,a=(f=l.getImageData(0,0,r,s)).data,h=4):window.CanvasRenderingContext2D&&n instanceof window.CanvasRenderingContext2D?(l=n,r=(c=n.canvas).width,s=c.height,a=(f=l.getImageData(0,0,r,s)).data,h=4):window.ImageData&&n instanceof window.ImageData&&(f=n,r=n.width,s=n.height,a=f.data,h=4);if(o=Math.max(r,s),window.Uint8ClampedArray&&a instanceof window.Uint8ClampedArray||window.Uint8Array&&a instanceof window.Uint8Array)for(u=a,a=Array(r*s),d=0,p=Math.floor(u.length/h);d<p;d++)a[d]=u[d*h+m]/255;else if(1!==h)throw Error("Raw data can have only 1 value per pixel");var w=Array(r*s),g=Array(r*s),b=Array(o),x=Array(o),_=Array(o+1),k=Array(o);for(d=0,p=r*s;d<p;d++){var $=a[d];w[d]=1===$?0:0===$?t:Math.pow(Math.max(0,.5-$),2),g[d]=1===$?t:0===$?0:Math.pow(Math.max(0,$-.5),2)}e(w,r,s,b,x,k,_),e(g,r,s,b,x,k,_);var S=window.Float32Array?new Float32Array(r*s):new Array(r*s);for(d=0,p=r*s;d<p;d++)S[d]=Math.min(Math.max(1-((w[d]-g[d])/y+v),0),1);return S};var t=1e20;function e(t,e,i,r,s,o,a){for(var u=0;u<e;u++){for(var h=0;h<i;h++)r[h]=t[h*e+u];for(n(r,s,o,a,i),h=0;h<i;h++)t[h*e+u]=s[h]}for(h=0;h<i;h++){for(u=0;u<e;u++)r[u]=t[h*e+u];for(n(r,s,o,a,e),u=0;u<e;u++)t[h*e+u]=Math.sqrt(s[u])}}function n(e,n,i,r,s){i[0]=0,r[0]=-t,r[1]=+t;for(var o=1,a=0;o<s;o++){for(var u=(e[o]+o*o-(e[i[a]]+i[a]*i[a]))/(2*o-2*i[a]);u<=r[a];)a--,u=(e[o]+o*o-(e[i[a]]+i[a]*i[a]))/(2*o-2*i[a]);i[++a]=o,r[a]=u,r[a+1]=+t}for(o=0,a=0;o<s;o++){for(;r[a+1]<o;)a++;n[o]=(o-i[a])*(o-i[a])+e[i[a]]}}return Ip}(),zp=gf(Tp);function Dp(t){return t===e.HeightReference.CLAMP_TO_GROUND||t===e.HeightReference.CLAMP_TO_3D_TILE||t===e.HeightReference.CLAMP_TO_TERRAIN}const Pp=e.Billboard.SHOW_INDEX,Rp=e.Billboard.POSITION_INDEX,Np=e.Billboard.PIXEL_OFFSET_INDEX,Fp=e.Billboard.EYE_OFFSET_INDEX,Up=e.Billboard.HORIZONTAL_ORIGIN_INDEX,qp=e.Billboard.VERTICAL_ORIGIN_INDEX,jp=e.Billboard.SCALE_INDEX,Bp=e.Billboard.IMAGE_INDEX_INDEX,Lp=e.Billboard.COLOR_INDEX,Hp=e.Billboard.ROTATION_INDEX,Vp=e.Billboard.ALIGNED_AXIS_INDEX,Wp=e.Billboard.SCALE_BY_DISTANCE_INDEX,Gp=e.Billboard.TRANSLUCENCY_BY_DISTANCE_INDEX,Qp=e.Billboard.PIXEL_OFFSET_SCALE_BY_DISTANCE_INDEX,Kp=e.Billboard.DISTANCE_DISPLAY_CONDITION,Xp=e.Billboard.DISABLE_DEPTH_DISTANCE,Zp=e.Billboard.TEXTURE_COORDINATE_BOUNDS,Yp=e.Billboard.SDF_INDEX,Jp=e.Billboard.NUMBER_OF_PROPERTIES;let tv;const ev={positionHighAndScale:0,positionLowAndRotation:1,compressedAttribute0:2,compressedAttribute1:3,compressedAttribute2:4,eyeOffset:5,scaleByDistance:6,pixelOffsetScaleByDistance:7,compressedAttribute3:8,textureCoordinateBoundsOrLabelTranslate:9,a_batchId:10,sdf:11},nv={direction:0,positionHighAndScale:1,positionLowAndRotation:2,compressedAttribute0:3,compressedAttribute1:4,compressedAttribute2:5,eyeOffset:6,scaleByDistance:7,pixelOffsetScaleByDistance:8,compressedAttribute3:9,textureCoordinateBoundsOrLabelTranslate:10,a_batchId:11,sdf:12,roadDirection:13};function iv(t){t=e.defaultValue(t,e.defaultValue.EMPTY_OBJECT),this._scene=t.scene,this._batchTable=t.batchTable,this._textureAtlas=void 0,this._textureAtlasGUID=void 0,this._destroyTextureAtlas=!0,this._sp=void 0,this._spTranslucent=void 0,this._rsOpaque=void 0,this._rsTranslucent=void 0,this._vaf=void 0,this._billboards=[],this._billboardsToUpdate=[],this._billboardsToUpdateIndex=0,this._billboardsRemoved=!1,this._createVertexArray=!1,this._shaderRotation=!1,this._compiledShaderRotation=!1,this._shaderAlignedAxis=!1,this._compiledShaderAlignedAxis=!1,this._shaderScaleByDistance=!1,this._compiledShaderScaleByDistance=!1,this._shaderTranslucencyByDistance=!1,this._compiledShaderTranslucencyByDistance=!1,this._shaderPixelOffsetScaleByDistance=!1,this._compiledShaderPixelOffsetScaleByDistance=!1,this._shaderDistanceDisplayCondition=!1,this._compiledShaderDistanceDisplayCondition=!1,this._shaderDisableDepthDistance=!1,this._compiledShaderDisableDepthDistance=!1,this._shaderClampToGround=!1,this._compiledShaderClampToGround=!1,this._propertiesChanged=new Uint32Array(Jp),this._maxSize=0,this._maxEyeOffset=0,this._maxScale=1,this._maxPixelOffset=0,this._allHorizontalCenter=!0,this._allVerticalCenter=!0,this._allSizedInMeters=!0,this._baseVolume=new e.BoundingSphere,this._baseVolumeWC=new e.BoundingSphere,this._baseVolume2D=new e.BoundingSphere,this._boundingVolume=new e.BoundingSphere,this._boundingVolumeDirty=!1,this._colorCommands=[],this.show=e.defaultValue(t.show,!0),this.modelMatrix=e.Matrix4.clone(e.defaultValue(t.modelMatrix,e.Matrix4.IDENTITY)),this._modelMatrix=e.Matrix4.clone(e.Matrix4.IDENTITY),this.debugShowBoundingVolume=e.defaultValue(t.debugShowBoundingVolume,!1),this.debugShowTextureAtlas=e.defaultValue(t.debugShowTextureAtlas,!1),this.blendOption=e.defaultValue(t.blendOption,e.BlendOption.OPAQUE_AND_TRANSLUCENT),this._blendOption=void 0,this._mode=e.SceneMode.SCENE3D,this._buffersUsage=[e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW,e.BufferUsage.STATIC_DRAW],this._highlightColor=e.Color.clone(e.Color.WHITE);const n=this;this._uniforms={u_atlas:function(){return n._textureAtlas.texture},u_highlightColor:function(){return n._highlightColor}};const i=this._scene;e.defined(i)&&e.defined(i.terrainProviderChanged)&&(this._removeCallbackFunc=i.terrainProviderChanged.addEventListener((function(){const t=this._billboards,n=t.length;for(let i=0;i<n;++i)e.defined(t[i])&&t[i]._updateClamping()}),this))}function rv(t){const e=t.length;for(let n=0;n<e;++n)t[n]&&t[n]._destroy()}function sv(t){if(t._billboardsRemoved){t._billboardsRemoved=!1;const n=[],i=t._billboards,r=i.length;for(let t=0,s=0;t<r;++t){const r=i[t];e.defined(r)&&(r._index=s++,n.push(r))}t._billboards=n}}let ov;function av(t){let n=t.cache.billboardCollection_indexBufferBatched;if(e.defined(n))return n;const i=new Uint16Array(98298);for(let t=0,e=0;t<98298;t+=6,e+=4)i[t]=e,i[t+1]=e+1,i[t+2]=e+2,i[t+3]=e+0,i[t+4]=e+2,i[t+5]=e+3;return n=e.Buffer.createIndexBuffer({context:t,typedArray:i,usage:e.BufferUsage.STATIC_DRAW,indexDatatype:e.IndexDatatype.UNSIGNED_SHORT}),n.vertexArrayDestroyable=!1,t.cache.billboardCollection_indexBufferBatched=n,n}function uv(t){let n=t.cache.billboardCollection_indexBufferInstanced2;return e.defined(n)||(n=e.Buffer.createIndexBuffer({context:t,typedArray:new Uint16Array([0,1,2,0,2,3]),usage:e.BufferUsage.STATIC_DRAW,indexDatatype:e.IndexDatatype.UNSIGNED_SHORT}),n.vertexArrayDestroyable=!1,t.cache.billboardCollection_indexBufferInstanced2=n),n}function hv(t){let n=t.cache.billboardCollection_vertexBufferInstanced2;return e.defined(n)||(n=e.Buffer.createVertexBuffer({context:t,typedArray:new Float32Array([0,0,1,0,1,1,0,1]),usage:e.BufferUsage.STATIC_DRAW}),n.vertexArrayDestroyable=!1,t.cache.billboardCollection_vertexBufferInstanced2=n),n}Object.defineProperties(iv.prototype,{length:{get:function(){return sv(this),this._billboards.length}},textureAtlas:{get:function(){return this._textureAtlas},set:function(t){this._textureAtlas!==t&&(this._textureAtlas=this._destroyTextureAtlas&&this._textureAtlas&&this._textureAtlas.destroy(),this._textureAtlas=t,this._createVertexArray=!0)}},destroyTextureAtlas:{get:function(){return this._destroyTextureAtlas},set:function(t){this._destroyTextureAtlas=t}}}),iv.prototype.add=function(t){const n=new e.Billboard(t,this);return n._index=this._billboards.length,this._billboards.push(n),this._createVertexArray=!0,n},iv.prototype.remove=function(t){return!!this.contains(t)&&(this._billboards[t._index]=void 0,this._billboardsRemoved=!0,this._createVertexArray=!0,t._destroy(),!0)},iv.prototype.removeAll=function(){rv(this._billboards),this._billboards=[],this._billboardsToUpdate=[],this._billboardsToUpdateIndex=0,this._billboardsRemoved=!1,this._createVertexArray=!0},iv.prototype._updateBillboard=function(t,e){t._dirty||(this._billboardsToUpdate[this._billboardsToUpdateIndex++]=t),++this._propertiesChanged[e]},iv.prototype.contains=function(t){return e.defined(t)&&t._billboardCollection===this},iv.prototype.get=function(t){return e.Check.typeOf.number("index",t),sv(this),this._billboards[t]},iv.prototype.computeNewBuffersUsage=function(){const t=this._buffersUsage;let n=!1;const i=this._propertiesChanged;for(let r=0;r<Jp;++r){const s=0===i[r]?e.BufferUsage.STATIC_DRAW:e.BufferUsage.STREAM_DRAW;n=n||t[r]!==s,t[r]=s}return n};const lv=new e.EncodedCartesian3;function cv(t,n,i,r,s){let o;const a=r[tv.positionHighAndScale],u=r[tv.positionLowAndRotation],h=s._getActualPosition();t._mode===e.SceneMode.SCENE3D&&(e.BoundingSphere.expand(t._baseVolume,h,t._baseVolume),t._boundingVolumeDirty=!0),e.EncodedCartesian3.fromCartesian(h,lv);const l=s.scale,c=s.rotation;0!==c&&(t._shaderRotation=!0),t._maxScale=Math.max(t._maxScale,l);const f=lv.high,d=lv.low;t._instanced?(o=s._index,a(o,f.x,f.y,f.z,l),u(o,d.x,d.y,d.z,c)):(o=4*s._index,a(o+0,f.x,f.y,f.z,l),a(o+1,f.x,f.y,f.z,l),a(o+2,f.x,f.y,f.z,l),a(o+3,f.x,f.y,f.z,l),u(o+0,d.x,d.y,d.z,c),u(o+1,d.x,d.y,d.z,c),u(o+2,d.x,d.y,d.z,c),u(o+3,d.x,d.y,d.z,c))}const fv=new e.Cartesian2,dv=32768,pv=65536,vv=4096,yv=256,mv=128,wv=32,gv=8,bv=4,xv=1/256,_v=0,kv=2,$v=3,Sv=1;function Mv(t,n,i,r,s){let o;const a=r[tv.compressedAttribute0],u=s.pixelOffset,h=u.x,l=u.y,c=s._translate,f=c.x,d=c.y;t._maxPixelOffset=Math.max(t._maxPixelOffset,Math.abs(h+f),Math.abs(-l+d));const p=s.horizontalOrigin;let v=s._verticalOrigin,y=s.show&&s.clusterShow;0===s.color.alpha&&(y=!1),v===e.VerticalOrigin.BASELINE&&(v=e.VerticalOrigin.BOTTOM),t._allHorizontalCenter=t._allHorizontalCenter&&p===e.HorizontalOrigin.CENTER,t._allVerticalCenter=t._allVerticalCenter&&v===e.VerticalOrigin.CENTER;let m=0,w=0,g=0,b=0;const x=s._imageIndex;if(-1!==x){const t=i[x];if(!e.defined(t))throw new e.DeveloperError(`Invalid billboard image index: ${x}`);m=t.x,w=t.y,g=t.width,b=t.height}const _=m+g,k=w+b;let $=Math.floor(e.Math.clamp(h,-dv,dv)+dv)*mv;$+=(p+1)*wv,$+=(v+1)*gv,$+=(y?1:0)*bv;let S=Math.floor(e.Math.clamp(l,-dv,dv)+dv)*yv,M=Math.floor(e.Math.clamp(f,-dv,dv)+dv)*yv;const E=(e.Math.clamp(d,-dv,dv)+dv)*xv,C=Math.floor(E);S+=C,M+=Math.floor((E-C)*yv),fv.x=m,fv.y=w;const A=e.AttributeCompression.compressTextureCoordinates(fv);fv.x=_;const I=e.AttributeCompression.compressTextureCoordinates(fv);fv.y=k;const O=e.AttributeCompression.compressTextureCoordinates(fv);fv.x=m;const T=e.AttributeCompression.compressTextureCoordinates(fv);t._instanced?(o=s._index,a(o,$,S,M,A)):(o=4*s._index,a(o+0,$+_v,S,M,A),a(o+1,$+kv,S,M,I),a(o+2,$+$v,S,M,O),a(o+3,$+Sv,S,M,T))}function Ev(t,n,i,r,s){let o;const a=r[tv.compressedAttribute1],u=s.alignedAxis;e.Cartesian3.equals(u,e.Cartesian3.ZERO)||(t._shaderAlignedAxis=!0);let h=0,l=1,c=1,f=1;const d=s.translucencyByDistance;e.defined(d)&&(h=d.near,l=d.nearValue,c=d.far,f=d.farValue,1===l&&1===f||(t._shaderTranslucencyByDistance=!0));let p=0;const v=s._imageIndex;if(-1!==v){const t=i[v];if(!e.defined(t))throw new e.DeveloperError(`Invalid billboard image index: ${v}`);p=t.width}const y=t._textureAtlas.texture.width,m=Math.round(e.defaultValue(s.width,y*p));t._maxSize=Math.max(t._maxSize,m);let w=e.Math.clamp(m,0,pv),g=0;Math.abs(e.Cartesian3.magnitudeSquared(u)-1)<e.Math.EPSILON6&&(g=e.AttributeCompression.octEncodeFloat(u)),l=e.Math.clamp(l,0,1),l=1===l?255:255*l|0,w=w*yv+l,f=e.Math.clamp(f,0,1),f=1===f?255:255*f|0,g=g*yv+f,t._instanced?(o=s._index,a(o,w,g,h,c)):(o=4*s._index,a(o+0,w,g,h,c),a(o+1,w,g,h,c),a(o+2,w,g,h,c),a(o+3,w,g,h,c))}function Cv(t,n,i,r,s){let o;const a=r[tv.compressedAttribute2],u=s.color,h=e.defined(t._batchTable)?e.Color.WHITE:s.getPickId(n.context).color,l=s.sizeInMeters?1:0,c=Math.abs(e.Cartesian3.magnitudeSquared(s.alignedAxis)-1)<e.Math.EPSILON6?1:0;t._allSizedInMeters=t._allSizedInMeters&&1===l;let f=0;const d=s._imageIndex;if(-1!==d){const t=i[d];if(!e.defined(t))throw new e.DeveloperError(`Invalid billboard image index: ${d}`);f=t.height}const p=t._textureAtlas.texture.dimensions,v=Math.round(e.defaultValue(s.height,p.y*f));t._maxSize=Math.max(t._maxSize,v);let y=e.defaultValue(s._labelHorizontalOrigin,-2);y+=2;const m=v*bv+y;let w=e.Color.floatToByte(u.red),g=e.Color.floatToByte(u.green),b=e.Color.floatToByte(u.blue);const x=w*pv+g*yv+b;w=e.Color.floatToByte(h.red),g=e.Color.floatToByte(h.green),b=e.Color.floatToByte(h.blue);const _=w*pv+g*yv+b;let k=e.Color.floatToByte(u.alpha)*pv+e.Color.floatToByte(h.alpha)*yv;k+=2*l+c,t._instanced?(o=s._index,a(o,x,_,k,m)):(o=4*s._index,a(o+0,x,_,k,m),a(o+1,x,_,k,m),a(o+2,x,_,k,m),a(o+3,x,_,k,m))}function Av(t,n,i,r,s){let o;const a=r[tv.eyeOffset],u=s.eyeOffset;let h=u.z;if(s._heightReference!==e.HeightReference.NONE&&(h*=1.005),t._maxEyeOffset=Math.max(t._maxEyeOffset,Math.abs(u.x),Math.abs(u.y),Math.abs(h)),t._instanced){let t=0,n=0;const r=s._imageIndex;if(-1!==r){const s=i[r];if(!e.defined(s))throw new e.DeveloperError(`Invalid billboard image index: ${r}`);t=s.width,n=s.height}fv.x=t,fv.y=n;const l=e.AttributeCompression.compressTextureCoordinates(fv);o=s._index,a(o,u.x,u.y,h,l)}else o=4*s._index,a(o+0,u.x,u.y,h,0),a(o+1,u.x,u.y,h,0),a(o+2,u.x,u.y,h,0),a(o+3,u.x,u.y,h,0)}function Iv(t,n,i,r,s){let o;const a=r[tv.scaleByDistance];let u=0,h=1,l=1,c=1;const f=s.scaleByDistance;e.defined(f)&&(u=f.near,h=f.nearValue,l=f.far,c=f.farValue,1===h&&1===c||(t._shaderScaleByDistance=!0)),t._instanced?(o=s._index,a(o,u,h,l,c)):(o=4*s._index,a(o+0,u,h,l,c),a(o+1,u,h,l,c),a(o+2,u,h,l,c),a(o+3,u,h,l,c))}function Ov(t,n,i,r,s){let o;const a=r[tv.pixelOffsetScaleByDistance];let u=0,h=1,l=1,c=1;const f=s.pixelOffsetScaleByDistance;e.defined(f)&&(u=f.near,h=f.nearValue,l=f.far,c=f.farValue,1===h&&1===c||(t._shaderPixelOffsetScaleByDistance=!0)),t._instanced?(o=s._index,a(o,u,h,l,c)):(o=4*s._index,a(o+0,u,h,l,c),a(o+1,u,h,l,c),a(o+2,u,h,l,c),a(o+3,u,h,l,c))}function Tv(t,n,i,r,s){let o;const a=r[tv.compressedAttribute3];let u=0,h=Number.MAX_VALUE;const l=s.distanceDisplayCondition;e.defined(l)&&(u=l.near,h=l.far,u*=u,h*=h,t._shaderDistanceDisplayCondition=!0);let c=s.disableDepthTestDistance;const f=Dp(s.heightReference)&&n.context.depthTexture;let d,p;if(e.defined(c)||(c=f?5e3:0),c*=c,(f||c>0)&&(t._shaderDisableDepthDistance=!0,c===Number.POSITIVE_INFINITY&&(c=-1)),e.defined(s._labelDimensions))p=s._labelDimensions.x,d=s._labelDimensions.y;else{let n=0,r=0;const o=s._imageIndex;if(-1!==o){const t=i[o];if(!e.defined(t))throw new e.DeveloperError(`Invalid billboard image index: ${o}`);n=t.height,r=t.width}d=Math.round(e.defaultValue(s.height,t._textureAtlas.texture.dimensions.y*n));const a=t._textureAtlas.texture.width;p=Math.round(e.defaultValue(s.width,a*r))}const v=Math.floor(e.Math.clamp(p,0,vv)),y=Math.floor(e.Math.clamp(d,0,vv)),m=v*vv+y;t._instanced?(o=s._index,a(o,u,h,c,m)):(o=4*s._index,a(o+0,u,h,c,m),a(o+1,u,h,c,m),a(o+2,u,h,c,m),a(o+3,u,h,c,m))}function zv(t,n,i,r,s){if(Dp(s.heightReference)){const i=t._scene,r=n.context,s=n.globeTranslucencyState.translucent,o=e.defined(i.globe)&&i.globe.depthTestAgainstTerrain;t._shaderClampToGround=r.depthTexture&&!s&&o}let o;const a=r[tv.textureCoordinateBoundsOrLabelTranslate];if(e.ContextLimits.maximumVertexTextureImageUnits>0){let n=0,i=0;return e.defined(s._labelTranslate)&&(n=s._labelTranslate.x,i=s._labelTranslate.y),void(t._instanced?(o=s._index,a(o,n,i,0,0)):(o=4*s._index,a(o+0,n,i,0,0),a(o+1,n,i,0,0),a(o+2,n,i,0,0),a(o+3,n,i,0,0)))}let u=0,h=0,l=0,c=0;const f=s._imageIndex;if(-1!==f){const t=i[f];if(!e.defined(t))throw new e.DeveloperError(`Invalid billboard image index: ${f}`);u=t.x,h=t.y,l=t.width,c=t.height}const d=u+l,p=h+c;t._instanced?(o=s._index,a(o,u,h,d,p)):(o=4*s._index,a(o+0,u,h,d,p),a(o+1,u,h,d,p),a(o+2,u,h,d,p),a(o+3,u,h,d,p))}function Dv(t,n,i,r,s){if(!t._sdf)return;let o;const a=r[tv.sdf],u=s.outlineColor,h=s.outlineWidth,l=e.Color.floatToByte(u.red),c=e.Color.floatToByte(u.green),f=e.Color.floatToByte(u.blue),d=l*pv+c*yv+f,p=h/e.SDFSettings.RADIUS,v=e.Color.floatToByte(u.alpha)*pv+e.Color.floatToByte(p)*yv;t._instanced?(o=s._index,a(o,d,v)):(o=4*s._index,a(o+0,d+_v,v),a(o+1,d+kv,v),a(o+2,d+$v,v),a(o+3,d+Sv,v))}function Pv(t,n,i,r,s){cv(t,0,0,r,s),Mv(t,0,i,r,s),Ev(t,0,i,r,s),Cv(t,n,i,r,s),Av(t,0,i,r,s),Iv(t,0,0,r,s),Ov(t,0,0,r,s),Tv(t,n,i,r,s),zv(t,n,i,r,s),function(t,n,i,r,s){if(!e.defined(t._batchTable))return;const o=r[tv.a_batchId],a=s._batchIndex;let u;t._instanced?(u=s._index,o(u,a)):(u=4*s._index,o(u+0,a),o(u+1,a),o(u+2,a),o(u+3,a))}(t,0,0,r,s),Dv(t,0,0,r,s),function(t,e,n,i,r){if(!t._sdf)return;const s=i[tv.roadDirection],o=r.roadDirection;s(r._index,o.x,o.y,o.z,o.w)}(t,0,0,r,s)}function Rv(t,n,i,r,s,o){let a;r.mode===e.SceneMode.SCENE3D?(a=t._baseVolume,t._boundingVolumeDirty=!0):a=t._baseVolume2D;const u=[];for(let t=0;t<i;++t){const i=n[t],h=i.position,l=e.Billboard._computeActualPosition(i,h,r,s);e.defined(l)&&(i._setActualPosition(l),o?u.push(l):e.BoundingSphere.expand(a,l,a))}o&&e.BoundingSphere.fromPoints(u,a)}const Nv=[];iv.prototype.update=function(t){if(sv(this),!this.show)return;let n=this._billboards,i=n.length;const r=t.context;this._instanced=r.instancedArrays,tv=this._instanced?nv:ev,ov=this._instanced?uv:av;let s=this._textureAtlas;if(!e.defined(s)){s=this._textureAtlas=new e.TextureAtlas({context:r});for(let t=0;t<i;++t)n[t]._loadImage()}const o=s.textureCoordinates;if(0===o.length)return;!function(t,n){const i=n.mode,r=t._billboards,s=t._billboardsToUpdate,o=t._modelMatrix;t._createVertexArray||t._mode!==i||i!==e.SceneMode.SCENE3D&&!e.Matrix4.equals(o,t.modelMatrix)?(t._mode=i,e.Matrix4.clone(t.modelMatrix,o),t._createVertexArray=!0,i!==e.SceneMode.SCENE3D&&i!==e.SceneMode.SCENE2D&&i!==e.SceneMode.COLUMBUS_VIEW||Rv(t,r,r.length,n,o,!0)):i===e.SceneMode.MORPHING?Rv(t,r,r.length,n,o,!0):i!==e.SceneMode.SCENE2D&&i!==e.SceneMode.COLUMBUS_VIEW||Rv(t,s,t._billboardsToUpdateIndex,n,o,!1)}(this,t),n=this._billboards,i=n.length;const a=this._billboardsToUpdate,u=this._billboardsToUpdateIndex,h=this._propertiesChanged,l=s.guid,c=this._createVertexArray||this._textureAtlasGUID!==l;let f;this._textureAtlasGUID=l;const d=t.passes,p=d.pick;if(c||!p&&this.computeNewBuffersUsage()){this._createVertexArray=!1;for(let t=0;t<Jp;++t)h[t]=0;if(this._vaf=this._vaf&&this._vaf.destroy(),i>0){this._vaf=function(t,n,i,r,s,o){const a=[{index:tv.positionHighAndScale,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,usage:i[Rp]},{index:tv.positionLowAndRotation,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,usage:i[Rp]},{index:tv.compressedAttribute0,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,usage:i[Np]},{index:tv.compressedAttribute1,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,usage:i[Gp]},{index:tv.compressedAttribute2,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,usage:i[Lp]},{index:tv.eyeOffset,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,usage:i[Fp]},{index:tv.scaleByDistance,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,usage:i[Wp]},{index:tv.pixelOffsetScaleByDistance,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,usage:i[Qp]},{index:tv.compressedAttribute3,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,usage:i[Kp]},{index:tv.textureCoordinateBoundsOrLabelTranslate,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,usage:i[Zp]}];r&&a.push({index:tv.direction,componentsPerAttribute:2,componentDatatype:e.ComponentDatatype.FLOAT,vertexBuffer:hv(t)}),e.defined(s)&&a.push({index:tv.a_batchId,componentsPerAttribute:1,componentDatatype:e.ComponentDatatype.FLOAT,bufferUsage:e.BufferUsage.STATIC_DRAW}),o&&(a.push({index:tv.sdf,componentsPerAttribute:2,componentDatatype:e.ComponentDatatype.FLOAT,usage:i[Yp]}),a.push({index:tv.roadDirection,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,usage:e.BufferUsage.STATIC_DRAW}));const u=r?n:4*n;return new e.VertexArrayFacade(t,a,u,r)}(r,i,this._buffersUsage,this._instanced,this._batchTable,this._sdf),f=this._vaf.writers;for(let e=0;e<i;++e){const n=this._billboards[e];n._dirty=!1,Pv(this,t,o,f,n)}this._vaf.commit(ov(r))}this._billboardsToUpdateIndex=0}else if(u>0){const e=Nv;e.length=0,(h[Rp]||h[Hp]||h[jp])&&e.push(cv),(h[Bp]||h[Np]||h[Up]||h[qp]||h[Pp])&&(e.push(Mv),this._instanced&&e.push(Av)),(h[Bp]||h[Vp]||h[Gp])&&(e.push(Ev),e.push(Cv)),(h[Bp]||h[Lp])&&e.push(Cv),h[Fp]&&e.push(Av),h[Wp]&&e.push(Iv),h[Qp]&&e.push(Ov),(h[Kp]||h[Xp]||h[Bp]||h[Rp])&&e.push(Tv),(h[Bp]||h[Rp])&&e.push(zv),h[Yp]&&e.push(Dv);const n=e.length;if(f=this._vaf.writers,u/i>.1){for(let i=0;i<u;++i){const r=a[i];r._dirty=!1;for(let i=0;i<n;++i)e[i](this,t,o,f,r)}this._vaf.commit(ov(r))}else{for(let i=0;i<u;++i){const r=a[i];r._dirty=!1;for(let i=0;i<n;++i)e[i](this,t,o,f,r);this._instanced?this._vaf.subCommit(r._index,1):this._vaf.subCommit(4*r._index,4)}this._vaf.endSubCommits()}this._billboardsToUpdateIndex=0}if(u>1.5*i&&(a.length=i),!e.defined(this._vaf)||!e.defined(this._vaf.va))return;let v;this._boundingVolumeDirty&&(this._boundingVolumeDirty=!1,e.BoundingSphere.transform(this._baseVolume,this.modelMatrix,this._baseVolumeWC));let y=e.Matrix4.IDENTITY;t.mode===e.SceneMode.SCENE3D?(y=this.modelMatrix,v=e.BoundingSphere.clone(this._baseVolumeWC,this._boundingVolume)):v=e.BoundingSphere.clone(this._baseVolume2D,this._boundingVolume),function(t,e,n){let i=1;t._allSizedInMeters&&0===t._maxPixelOffset||(i=e.camera.getPixelSize(n,e.context.drawingBufferWidth,e.context.drawingBufferHeight));let r=i*t._maxScale*t._maxSize*2;t._allHorizontalCenter&&t._allVerticalCenter&&(r*=.5);const s=i*t._maxPixelOffset+t._maxEyeOffset;n.radius+=r+s}(this,t,v);const m=this._blendOption!==this.blendOption;if(this._blendOption=this.blendOption,m){this._blendOption===e.BlendOption.OPAQUE||this._blendOption===e.BlendOption.OPAQUE_AND_TRANSLUCENT?this._rsOpaque=e.RenderState.fromCache({depthTest:{enabled:!0,func:e.WebGLConstants.LESS},depthMask:!0}):this._rsOpaque=void 0;const t=this._blendOption===e.BlendOption.TRANSLUCENT;this._blendOption===e.BlendOption.TRANSLUCENT||this._blendOption===e.BlendOption.OPAQUE_AND_TRANSLUCENT?this._rsTranslucent=e.RenderState.fromCache({depthTest:{enabled:!1,func:t?e.WebGLConstants.LEQUAL:e.WebGLConstants.LESS},depthMask:!1,blending:e.BlendingState.ALPHA_BLEND}):this._rsTranslucent=void 0}let w,g,b,x,_;this._shaderDisableDepthDistance=this._shaderDisableDepthDistance||0!==t.minimumDisableDepthTestDistance;const k=e.ContextLimits.maximumVertexTextureImageUnits>0;if(m||this._shaderRotation!==this._compiledShaderRotation||this._shaderAlignedAxis!==this._compiledShaderAlignedAxis||this._shaderScaleByDistance!==this._compiledShaderScaleByDistance||this._shaderTranslucencyByDistance!==this._compiledShaderTranslucencyByDistance||this._shaderPixelOffsetScaleByDistance!==this._compiledShaderPixelOffsetScaleByDistance||this._shaderDistanceDisplayCondition!==this._compiledShaderDistanceDisplayCondition||this._shaderDisableDepthDistance!==this._compiledShaderDisableDepthDistance||this._shaderClampToGround!==this._compiledShaderClampToGround||this._sdf!==this._compiledSDF){w="#ifdef INSTANCED\nin vec2 direction;\n#endif\nin vec4 positionHighAndScale;in vec4 positionLowAndRotation;in vec4 compressedAttribute0;in vec4 compressedAttribute1;in vec4 compressedAttribute2;in vec4 eyeOffset;in vec4 scaleByDistance;in vec4 pixelOffsetScaleByDistance;in vec4 compressedAttribute3;in vec2 sdf;\n#if defined(VERTEX_DEPTH_CHECK) || defined(FRAGMENT_DEPTH_CHECK)\nin vec4 textureCoordinateBoundsOrLabelTranslate;\n#endif\n#ifdef VECTOR_TILE\nin float a_batchId;\n#endif\n#ifdef SDF\nin vec4 roadDirection;\n#endif\nout vec2 v_textureCoordinates;\n#ifdef FRAGMENT_DEPTH_CHECK\nout vec4 v_textureCoordinateBounds;out vec4 v_originTextureCoordinateAndTranslate;out vec4 v_compressed;out mat2 v_rotationMatrix;\n#endif\nout vec4 v_pickColor;out vec4 v_color;\n#ifdef SDF\nout vec4 v_outlineColor;out float v_outlineWidth;\n#endif\nout float v_discard;const float UPPER_BOUND=32768.0;const float SHIFT_LEFT16=65536.0;const float SHIFT_LEFT12=4096.0;const float SHIFT_LEFT8=256.0;const float SHIFT_LEFT7=128.0;const float SHIFT_LEFT5=32.0;const float SHIFT_LEFT3=8.0;const float SHIFT_LEFT2=4.0;const float SHIFT_LEFT1=2.0;const float SHIFT_RIGHT12=1.0/4096.0;const float SHIFT_RIGHT8=1.0/256.0;const float SHIFT_RIGHT7=1.0/128.0;const float SHIFT_RIGHT5=1.0/32.0;const float SHIFT_RIGHT3=1.0/8.0;const float SHIFT_RIGHT2=1.0/4.0;const float SHIFT_RIGHT1=1.0/2.0;vec4 addScreenSpaceOffset(vec4 positionEC,vec2 imageSize,float scale,vec2 direction,vec2 origin,vec2 translate,vec2 pixelOffset,vec3 alignedAxis,bool validAlignedAxis,float rotation,bool sizeInMeters,out mat2 rotationMatrix,out float mpp){vec2 halfSize=imageSize*scale*0.5;halfSize*=((direction*2.0)-1.0);vec2 originTranslate=origin*abs(halfSize);\n#if defined(ROTATION) || defined(ALIGNED_AXIS)\nif(validAlignedAxis||rotation!=0.0){float angle=rotation;if(validAlignedAxis){vec4 projectedAlignedAxis=czm_modelView3D*vec4(alignedAxis,0.0);angle+=sign(-projectedAlignedAxis.x)*acos(sign(projectedAlignedAxis.y)*(projectedAlignedAxis.y*projectedAlignedAxis.y)/(projectedAlignedAxis.x*projectedAlignedAxis.x+projectedAlignedAxis.y*projectedAlignedAxis.y));}float cosTheta=cos(angle);float sinTheta=sin(angle);rotationMatrix=mat2(cosTheta,sinTheta,-sinTheta,cosTheta);halfSize=rotationMatrix*halfSize;}else{rotationMatrix=mat2(1.0,0.0,0.0,1.0);}\n#endif\nmpp=czm_metersPerPixel(positionEC);positionEC.xy+=(originTranslate+halfSize)*czm_branchFreeTernary(sizeInMeters,1.0,mpp);positionEC.xy+=(translate+pixelOffset)*mpp;return positionEC;}float getGlobeDepth(vec4 positionEC){vec4 posWC=czm_eyeToWindowCoordinates(positionEC);float globeDepth=czm_unpackDepth(texture(czm_globeDepthTexture,posWC.xy/czm_viewport.zw));if(globeDepth==0.0){return 0.0;}vec4 eyeCoordinate=czm_windowToEyeCoordinates(posWC.xy,globeDepth);return eyeCoordinate.z/eyeCoordinate.w;}float crossProduct(vec2 a,vec2 b){return a.x*b.y-a.y*b.x;}void main(){vec3 positionHigh=positionHighAndScale.xyz;vec3 positionLow=positionLowAndRotation.xyz;float scale=positionHighAndScale.w;\n#if defined(ROTATION) || defined(ALIGNED_AXIS)\nfloat rotation=positionLowAndRotation.w;\n#else\nfloat rotation=0.0;\n#endif\nfloat compressed=compressedAttribute0.x;vec2 pixelOffset;pixelOffset.x=floor(compressed*SHIFT_RIGHT7);compressed-=pixelOffset.x*SHIFT_LEFT7;pixelOffset.x-=UPPER_BOUND;vec2 origin;origin.x=floor(compressed*SHIFT_RIGHT5);compressed-=origin.x*SHIFT_LEFT5;origin.y=floor(compressed*SHIFT_RIGHT3);compressed-=origin.y*SHIFT_LEFT3;\n#ifdef FRAGMENT_DEPTH_CHECK\nvec2 depthOrigin=origin.xy;\n#endif\norigin-=vec2(1.0);float show=floor(compressed*SHIFT_RIGHT2);compressed-=show*SHIFT_LEFT2;\n#ifdef INSTANCED\nvec2 textureCoordinatesBottomLeft=czm_decompressTextureCoordinates(compressedAttribute0.w);vec2 textureCoordinatesRange=czm_decompressTextureCoordinates(eyeOffset.w);vec2 textureCoordinates=textureCoordinatesBottomLeft+direction*textureCoordinatesRange;\n#else\nvec2 direction;direction.x=floor(compressed*SHIFT_RIGHT1);direction.y=compressed-direction.x*SHIFT_LEFT1;vec2 textureCoordinates=czm_decompressTextureCoordinates(compressedAttribute0.w);\n#endif\nfloat temp=compressedAttribute0.y*SHIFT_RIGHT8;pixelOffset.y=-(floor(temp)-UPPER_BOUND);vec2 translate;translate.y=(temp-floor(temp))*SHIFT_LEFT16;temp=compressedAttribute0.z*SHIFT_RIGHT8;translate.x=floor(temp)-UPPER_BOUND;translate.y+=(temp-floor(temp))*SHIFT_LEFT8;translate.y-=UPPER_BOUND;temp=compressedAttribute1.x*SHIFT_RIGHT8;float temp2=floor(compressedAttribute2.w*SHIFT_RIGHT2);vec2 imageSize=vec2(floor(temp),temp2);\n#ifdef FRAGMENT_DEPTH_CHECK\nfloat labelHorizontalOrigin=floor(compressedAttribute2.w-(temp2*SHIFT_LEFT2));float applyTranslate=0.0;if(labelHorizontalOrigin!=0.0){applyTranslate=1.0;labelHorizontalOrigin-=2.0;depthOrigin.x=labelHorizontalOrigin+1.0;}depthOrigin=vec2(1.0)-(depthOrigin*0.5);\n#endif\n#ifdef EYE_DISTANCE_TRANSLUCENCY\nvec4 translucencyByDistance;translucencyByDistance.x=compressedAttribute1.z;translucencyByDistance.z=compressedAttribute1.w;translucencyByDistance.y=((temp-floor(temp))*SHIFT_LEFT8)/255.0;temp=compressedAttribute1.y*SHIFT_RIGHT8;translucencyByDistance.w=((temp-floor(temp))*SHIFT_LEFT8)/255.0;\n#endif\n#if defined(VERTEX_DEPTH_CHECK) || defined(FRAGMENT_DEPTH_CHECK)\ntemp=compressedAttribute3.w;temp=temp*SHIFT_RIGHT12;vec2 dimensions;dimensions.y=(temp-floor(temp))*SHIFT_LEFT12;dimensions.x=floor(temp);\n#endif\n#ifdef ALIGNED_AXIS\nvec3 alignedAxis=czm_octDecode(floor(compressedAttribute1.y*SHIFT_RIGHT8));temp=compressedAttribute2.z*SHIFT_RIGHT5;bool validAlignedAxis=(temp-floor(temp))*SHIFT_LEFT1>0.0;\n#else\nvec3 alignedAxis=vec3(0.0);bool validAlignedAxis=false;\n#endif\nvec4 pickColor;vec4 color;temp=compressedAttribute2.y;temp=temp*SHIFT_RIGHT8;pickColor.b=(temp-floor(temp))*SHIFT_LEFT8;temp=floor(temp)*SHIFT_RIGHT8;pickColor.g=(temp-floor(temp))*SHIFT_LEFT8;pickColor.r=floor(temp);temp=compressedAttribute2.x;temp=temp*SHIFT_RIGHT8;color.b=(temp-floor(temp))*SHIFT_LEFT8;temp=floor(temp)*SHIFT_RIGHT8;color.g=(temp-floor(temp))*SHIFT_LEFT8;color.r=floor(temp);temp=compressedAttribute2.z*SHIFT_RIGHT8;bool sizeInMeters=floor((temp-floor(temp))*SHIFT_LEFT7)>0.0;temp=floor(temp)*SHIFT_RIGHT8;pickColor.a=(temp-floor(temp))*SHIFT_LEFT8;pickColor/=255.0;color.a=floor(temp);color/=255.0;vec4 p=czm_translateRelativeToEye(positionHigh,positionLow);vec4 positionEC=czm_modelViewRelativeToEye*p;\n#if defined(FRAGMENT_DEPTH_CHECK) || defined(VERTEX_DEPTH_CHECK)\nfloat eyeDepth=positionEC.z;\n#endif\npositionEC=czm_eyeOffset(positionEC,eyeOffset.xyz);positionEC.xyz*=show;vec4 rawPosition=positionEC;\n#if defined(EYE_DISTANCE_SCALING) || defined(EYE_DISTANCE_TRANSLUCENCY) || defined(EYE_DISTANCE_PIXEL_OFFSET) || defined(DISTANCE_DISPLAY_CONDITION) || defined(DISABLE_DEPTH_DISTANCE)\nfloat lengthSq;if(czm_sceneMode==czm_sceneMode2D){lengthSq=czm_eyeHeight2D.y;}else{lengthSq=dot(positionEC.xyz,positionEC.xyz);}\n#endif\n#ifdef EYE_DISTANCE_SCALING\nfloat distanceScale=czm_nearFarScalar(scaleByDistance,lengthSq);scale*=distanceScale;translate*=distanceScale;if(scale==0.0){positionEC.xyz=vec3(0.0);}\n#endif\nfloat translucency=1.0;\n#ifdef EYE_DISTANCE_TRANSLUCENCY\ntranslucency=czm_nearFarScalar(translucencyByDistance,lengthSq);if(translucency==0.0){positionEC.xyz=vec3(0.0);}\n#endif\n#ifdef EYE_DISTANCE_PIXEL_OFFSET\nfloat pixelOffsetScale=czm_nearFarScalar(pixelOffsetScaleByDistance,lengthSq);pixelOffset*=pixelOffsetScale;\n#endif\n#ifdef DISTANCE_DISPLAY_CONDITION\nfloat nearSq=compressedAttribute3.x;float farSq=compressedAttribute3.y;if(lengthSq<nearSq||lengthSq>farSq){positionEC.xyz=vec3(0.0);}\n#endif\nmat2 rotationMatrix;float mpp;\n#ifdef DISABLE_DEPTH_DISTANCE\nfloat disableDepthTestDistance=compressedAttribute3.z;\n#endif\n#ifdef VERTEX_DEPTH_CHECK\nif(lengthSq<disableDepthTestDistance){float depthsilon=10.0;vec2 labelTranslate=textureCoordinateBoundsOrLabelTranslate.xy;vec4 pEC1=addScreenSpaceOffset(positionEC,dimensions,scale,vec2(0.0),origin,labelTranslate,pixelOffset,alignedAxis,validAlignedAxis,rotation,sizeInMeters,rotationMatrix,mpp);float globeDepth1=getGlobeDepth(pEC1);if(globeDepth1!=0.0&&pEC1.z+depthsilon<globeDepth1){vec4 pEC2=addScreenSpaceOffset(positionEC,dimensions,scale,vec2(0.0,1.0),origin,labelTranslate,pixelOffset,alignedAxis,validAlignedAxis,rotation,sizeInMeters,rotationMatrix,mpp);float globeDepth2=getGlobeDepth(pEC2);if(globeDepth2!=0.0&&pEC2.z+depthsilon<globeDepth2){vec4 pEC3=addScreenSpaceOffset(positionEC,dimensions,scale,vec2(1.0),origin,labelTranslate,pixelOffset,alignedAxis,validAlignedAxis,rotation,sizeInMeters,rotationMatrix,mpp);float globeDepth3=getGlobeDepth(pEC3);if(globeDepth3!=0.0&&pEC3.z+depthsilon<globeDepth3){positionEC.xyz=vec3(0.0);}}}}\n#endif\npositionEC=addScreenSpaceOffset(positionEC,imageSize,scale,direction,origin,translate,pixelOffset,alignedAxis,validAlignedAxis,rotation,sizeInMeters,rotationMatrix,mpp);\n#ifdef SDF\nif(roadDirection.w>0.0){vec4 projectedPosition=czm_projection*rawPosition;vec4 worldPosition=czm_inverseView*rawPosition;vec4 endPosition=vec4(worldPosition.xyz+roadDirection.xyz,1.0);vec4 projectedEndPosition=czm_viewProjection*endPosition;vec4 ndcPos=projectedPosition/projectedPosition.w;vec4 ndcEndPos=projectedEndPosition/projectedEndPosition.w;vec2 screenPos=(czm_viewportTransformation*ndcPos).xy;vec2 screenEndPos=(czm_viewportTransformation*ndcEndPos).xy;vec2 screenDir=normalize(screenEndPos-screenPos);vec2 originDir=vec2(1.0,0.0);float cosThetaValue=dot(originDir,screenDir);float sign=crossProduct(originDir,screenDir);float theta=czm_branchFreeTernary(sign>0.0,1.0,-1.0)*acos(cosThetaValue);if(theta>czm_piOverTwo){theta=theta-czm_pi;}if(theta<-czm_piOverTwo){theta=theta+czm_pi;}float cosTheta=cos(theta);float sinTheta=sin(theta);mat4 T=mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,-rawPosition.x,-rawPosition.y,-rawPosition.z,1.0);mat4 R=mat4(cosTheta,sinTheta,0.0,0.0,-sinTheta,cosTheta,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);mat4 invT=mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,rawPosition.x,rawPosition.y,rawPosition.z,1.0);positionEC=invT*R*T*positionEC;}\n#endif\ngl_Position=czm_projection*positionEC;v_textureCoordinates=textureCoordinates;\n#ifdef LOG_DEPTH\nczm_vertexLogDepth();\n#endif\n#ifdef DISABLE_DEPTH_DISTANCE\nif(disableDepthTestDistance==0.0&&czm_minimumDisableDepthTestDistance!=0.0){disableDepthTestDistance=czm_minimumDisableDepthTestDistance;}if(disableDepthTestDistance!=0.0){float zclip=gl_Position.z/gl_Position.w;bool clipped=(zclip<-1.0||zclip>1.0);if(!clipped&&(disableDepthTestDistance<0.0||(lengthSq>0.0&&lengthSq<disableDepthTestDistance))){gl_Position.z=-gl_Position.w;\n#ifdef LOG_DEPTH\nv_depthFromNearPlusOne=1.0;\n#endif\n}}\n#endif\n#ifdef FRAGMENT_DEPTH_CHECK\nif(sizeInMeters){translate/=mpp;dimensions/=mpp;imageSize/=mpp;}\n#if defined(ROTATION) || defined(ALIGNED_AXIS)\nv_rotationMatrix=rotationMatrix;\n#else\nv_rotationMatrix=mat2(1.0,0.0,0.0,1.0);\n#endif\nfloat enableDepthCheck=0.0;if(lengthSq<disableDepthTestDistance){enableDepthCheck=1.0;}float dw=floor(clamp(dimensions.x,0.0,SHIFT_LEFT12));float dh=floor(clamp(dimensions.y,0.0,SHIFT_LEFT12));float iw=floor(clamp(imageSize.x,0.0,SHIFT_LEFT12));float ih=floor(clamp(imageSize.y,0.0,SHIFT_LEFT12));v_compressed.x=eyeDepth;v_compressed.y=applyTranslate*SHIFT_LEFT1+enableDepthCheck;v_compressed.z=dw*SHIFT_LEFT12+dh;v_compressed.w=iw*SHIFT_LEFT12+ih;v_originTextureCoordinateAndTranslate.xy=depthOrigin;v_originTextureCoordinateAndTranslate.zw=translate;v_textureCoordinateBounds=textureCoordinateBoundsOrLabelTranslate;\n#endif\n#ifdef SDF\nvec4 outlineColor;float outlineWidth;temp=sdf.x;temp=temp*SHIFT_RIGHT8;outlineColor.b=(temp-floor(temp))*SHIFT_LEFT8;temp=floor(temp)*SHIFT_RIGHT8;outlineColor.g=(temp-floor(temp))*SHIFT_LEFT8;outlineColor.r=floor(temp);temp=sdf.y;temp=temp*SHIFT_RIGHT8;float temp3=(temp-floor(temp))*SHIFT_LEFT8;temp=floor(temp)*SHIFT_RIGHT8;outlineWidth=(temp-floor(temp))*SHIFT_LEFT8;outlineColor.a=floor(temp);outlineColor/=255.0;v_outlineWidth=outlineWidth/255.0;v_outlineColor=outlineColor;v_outlineColor.a*=translucency;\n#endif\nv_pickColor=pickColor;v_color=color;v_color.a*=translucency;v_discard=0.0;if(lengthSq<disableDepthTestDistance){float sceneDepth=getGlobeDepth(rawPosition);if(positionEC.z+10.<sceneDepth){v_discard=1.0;}}}",g="uniform sampler2D u_atlas;\n#ifdef VECTOR_TILE\nuniform vec4 u_highlightColor;\n#endif\nin vec2 v_textureCoordinates;in vec4 v_pickColor;in vec4 v_color;\n#ifdef SDF\nin vec4 v_outlineColor;in float v_outlineWidth;\n#endif\nin float v_discard;\n#ifdef FRAGMENT_DEPTH_CHECK\nin vec4 v_textureCoordinateBounds;in vec4 v_originTextureCoordinateAndTranslate;in vec4 v_compressed;in mat2 v_rotationMatrix;const float SHIFT_LEFT12=4096.0;const float SHIFT_LEFT1=2.0;const float SHIFT_RIGHT12=1.0/4096.0;const float SHIFT_RIGHT1=1.0/2.0;float getGlobeDepth(vec2 adjustedST,vec2 depthLookupST,bool applyTranslate,vec2 dimensions,vec2 imageSize){vec2 lookupVector=imageSize*(depthLookupST-adjustedST);lookupVector=v_rotationMatrix*lookupVector;vec2 labelOffset=(dimensions-imageSize)*(depthLookupST-vec2(0.0,v_originTextureCoordinateAndTranslate.y));vec2 translation=v_originTextureCoordinateAndTranslate.zw;if(applyTranslate){translation+=(dimensions*v_originTextureCoordinateAndTranslate.xy*vec2(1.0,0.0));}vec2 st=((lookupVector-translation+labelOffset)+gl_FragCoord.xy)/czm_viewport.zw;float logDepthOrDepth=czm_unpackDepth(texture(czm_globeDepthTexture,st));if(logDepthOrDepth==0.0){return 0.0;}vec4 eyeCoordinate=czm_windowToEyeCoordinates(gl_FragCoord.xy,logDepthOrDepth);return eyeCoordinate.z/eyeCoordinate.w;}\n#endif\n#ifdef SDF\nfloat getDistance(vec2 position){return texture(u_atlas,position).r;}vec4 getSDFColor(vec2 position,float outlineWidth,vec4 outlineColor,float smoothing){float distance=getDistance(position);if(outlineWidth>0.0){float outlineEdge=clamp(SDF_EDGE-outlineWidth,0.0,SDF_EDGE);float outlineFactor=smoothstep(SDF_EDGE-smoothing,SDF_EDGE+smoothing,distance);vec4 sdfColor=mix(outlineColor,v_color,outlineFactor);float alpha=smoothstep(outlineEdge-smoothing,outlineEdge+smoothing,distance);return vec4(sdfColor.rgb,sdfColor.a*alpha);}else{float alpha=smoothstep(SDF_EDGE-smoothing,SDF_EDGE+smoothing,distance);return vec4(v_color.rgb,v_color.a*alpha);}}\n#endif\nvoid main(){if(v_discard>0.0){discard;return;}vec4 color=texture(u_atlas,v_textureCoordinates);\n#ifdef SDF\nfloat outlineWidth=v_outlineWidth;vec4 outlineColor=v_outlineColor;float distance=getDistance(v_textureCoordinates);\n#if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))\nfloat smoothing=fwidth(distance);vec2 sampleOffset=0.354*vec2(dFdx(v_textureCoordinates)+dFdy(v_textureCoordinates));vec4 center=getSDFColor(v_textureCoordinates,outlineWidth,outlineColor,smoothing);vec4 color1=getSDFColor(v_textureCoordinates+vec2(sampleOffset.x,sampleOffset.y),outlineWidth,outlineColor,smoothing);vec4 color2=getSDFColor(v_textureCoordinates+vec2(-sampleOffset.x,sampleOffset.y),outlineWidth,outlineColor,smoothing);vec4 color3=getSDFColor(v_textureCoordinates+vec2(-sampleOffset.x,-sampleOffset.y),outlineWidth,outlineColor,smoothing);vec4 color4=getSDFColor(v_textureCoordinates+vec2(sampleOffset.x,-sampleOffset.y),outlineWidth,outlineColor,smoothing);color=(center+color1+color2+color3+color4)/5.0;\n#else\nfloat smoothing=1.0/32.0;color=getSDFColor(v_textureCoordinates,outlineWidth,outlineColor,smoothing);\n#endif\ncolor=czm_gammaCorrect(color);\n#else\ncolor=czm_gammaCorrect(color);color*=czm_gammaCorrect(v_color);\n#endif\n#if !defined(OPAQUE) && !defined(TRANSLUCENT)\nif(color.a<0.005){discard;}\n#else\n#ifdef OPAQUE\nif(color.a<0.995){discard;}\n#else\nif(color.a>=0.995){discard;}\n#endif\n#endif\n#ifdef VECTOR_TILE\ncolor*=u_highlightColor;\n#endif\nout_FragColor=color;\n#ifdef LOG_DEPTH\nczm_writeLogDepth();\n#endif\n}",_=[],e.defined(this._batchTable)&&(_.push("VECTOR_TILE"),w=this._batchTable.getVertexShaderCallback(!1,"a_batchId",void 0)(w),g=this._batchTable.getFragmentShaderCallback(!1,void 0)(g)),b=new e.ShaderSource({defines:_,sources:[w]}),this._instanced&&b.defines.push("INSTANCED"),this._shaderRotation&&b.defines.push("ROTATION"),this._shaderAlignedAxis&&b.defines.push("ALIGNED_AXIS"),this._shaderScaleByDistance&&b.defines.push("EYE_DISTANCE_SCALING"),this._shaderTranslucencyByDistance&&b.defines.push("EYE_DISTANCE_TRANSLUCENCY"),this._shaderPixelOffsetScaleByDistance&&b.defines.push("EYE_DISTANCE_PIXEL_OFFSET"),this._shaderDistanceDisplayCondition&&b.defines.push("DISTANCE_DISPLAY_CONDITION"),this._shaderDisableDepthDistance&&b.defines.push("DISABLE_DEPTH_DISTANCE"),this._shaderClampToGround&&(k?b.defines.push("VERTEX_DEPTH_CHECK"):b.defines.push("FRAGMENT_DEPTH_CHECK"));const t=1-e.SDFSettings.CUTOFF;this._sdf&&b.defines.push("SDF");const n=e.defined(this._batchTable)?"VECTOR_TILE":"";this._blendOption===e.BlendOption.OPAQUE_AND_TRANSLUCENT&&(x=new e.ShaderSource({defines:["OPAQUE",n],sources:[g]}),this._shaderClampToGround&&(k?x.defines.push("VERTEX_DEPTH_CHECK"):x.defines.push("FRAGMENT_DEPTH_CHECK")),this._sdf&&(x.defines.push("SDF"),x.defines.push(`SDF_EDGE ${t}`)),this._sp=e.ShaderProgram.replaceCache({context:r,shaderProgram:this._sp,vertexShaderSource:b,fragmentShaderSource:x,attributeLocations:tv}),x=new e.ShaderSource({defines:["TRANSLUCENT",n],sources:[g]}),this._shaderClampToGround&&(k?x.defines.push("VERTEX_DEPTH_CHECK"):x.defines.push("FRAGMENT_DEPTH_CHECK")),this._sdf&&(x.defines.push("SDF"),x.defines.push(`SDF_EDGE ${t}`)),this._spTranslucent=e.ShaderProgram.replaceCache({context:r,shaderProgram:this._spTranslucent,vertexShaderSource:b,fragmentShaderSource:x,attributeLocations:tv})),this._blendOption===e.BlendOption.OPAQUE&&(x=new e.ShaderSource({defines:[n],sources:[g]}),this._shaderClampToGround&&(k?x.defines.push("VERTEX_DEPTH_CHECK"):x.defines.push("FRAGMENT_DEPTH_CHECK")),this._sdf&&(x.defines.push("SDF"),x.defines.push(`SDF_EDGE ${t}`)),this._sp=e.ShaderProgram.replaceCache({context:r,shaderProgram:this._sp,vertexShaderSource:b,fragmentShaderSource:x,attributeLocations:tv})),this._blendOption===e.BlendOption.TRANSLUCENT&&(x=new e.ShaderSource({defines:[n],sources:[g]}),this._shaderClampToGround&&(k?x.defines.push("VERTEX_DEPTH_CHECK"):x.defines.push("FRAGMENT_DEPTH_CHECK")),this._sdf&&(x.defines.push("SDF"),x.defines.push(`SDF_EDGE ${t}`)),this._spTranslucent=e.ShaderProgram.replaceCache({context:r,shaderProgram:this._spTranslucent,vertexShaderSource:b,fragmentShaderSource:x,attributeLocations:tv})),this._compiledShaderRotation=this._shaderRotation,this._compiledShaderAlignedAxis=this._shaderAlignedAxis,this._compiledShaderScaleByDistance=this._shaderScaleByDistance,this._compiledShaderTranslucencyByDistance=this._shaderTranslucencyByDistance,this._compiledShaderPixelOffsetScaleByDistance=this._shaderPixelOffsetScaleByDistance,this._compiledShaderDistanceDisplayCondition=this._shaderDistanceDisplayCondition,this._compiledShaderDisableDepthDistance=this._shaderDisableDepthDistance,this._compiledShaderClampToGround=this._shaderClampToGround,this._compiledSDF=this._sdf}const $=t.commandList;if(d.render||d.pick){const n=this._colorCommands,r=this._blendOption===e.BlendOption.OPAQUE,s=this._blendOption===e.BlendOption.OPAQUE_AND_TRANSLUCENT,o=this._vaf.va,a=o.length;let u,h=this._uniforms;e.defined(this._batchTable)?(h=this._batchTable.getUniformMapCallback()(h),u=this._batchTable.getPickId()):u="v_pickColor",n.length=a;const l=s?2*a:a;for(let t=0;t<l;++t){let a=n[t];e.defined(a)||(a=n[t]=new e.DrawCommand);const l=r||s&&t%2==0;a.pass=l||!s?e.Pass.OPAQUE:e.Pass.TRANSLUCENT,a.owner=this;const c=s?Math.floor(t/2):t;a.boundingVolume=v,a.modelMatrix=y,a.count=o[c].indicesCount,a.shaderProgram=l?this._sp:this._spTranslucent,a.uniformMap=h,a.vertexArray=o[c].va,a.renderState=l?this._rsOpaque:this._rsTranslucent,a.debugShowBoundingVolume=this.debugShowBoundingVolume,a.pickId=u,this._instanced&&(a.count=6,a.instanceCount=i),$.push(a)}this.debugShowTextureAtlas&&(e.defined(this.debugCommand)||(this.debugCommand=function(t,n){const i=n.createViewportQuadCommand("uniform sampler2D billboard_texture; \nin vec2 v_textureCoordinates; \nvoid main() \n{ \n out_FragColor = texture(billboard_texture, v_textureCoordinates); \n} \n",{uniformMap:{billboard_texture:function(){return t._textureAtlas.texture}}});return i.pass=e.Pass.OVERLAY,i}(this,t.context)),$.push(this.debugCommand))}},iv.prototype.isDestroyed=function(){return!1},iv.prototype.destroy=function(){return e.defined(this._removeCallbackFunc)&&(this._removeCallbackFunc(),this._removeCallbackFunc=void 0),this._textureAtlas=this._destroyTextureAtlas&&this._textureAtlas&&this._textureAtlas.destroy(),this._sp=this._sp&&this._sp.destroy(),this._spTranslucent=this._spTranslucent&&this._spTranslucent.destroy(),this._vaf=this._vaf&&this._vaf.destroy(),rv(this._billboards),e.destroyObject(this)};var Fv,Uv,qv={exports:{}},jv=(Fv||(Fv=1,(Uv=qv).exports&&(Uv.exports=function(){var t=3,e=4,n=12,i=13,r=16,s=17;function o(t,e){void 0===e&&(e=0);var n=t.charCodeAt(e);if(55296<=n&&n<=56319&&e<t.length-1){var i=n;return 56320<=(r=t.charCodeAt(e+1))&&r<=57343?1024*(i-55296)+(r-56320)+65536:i}if(56320<=n&&n<=57343&&e>=1){var r=n;return 55296<=(i=t.charCodeAt(e-1))&&i<=56319?1024*(i-55296)+(r-56320)+65536:r}return n}function a(o,a,u){var h=[o].concat(a).concat([u]),l=h[h.length-2],c=u,f=h.lastIndexOf(14);if(f>1&&h.slice(1,f).every((function(e){return e==t}))&&-1==[t,i,s].indexOf(o))return 2;var d=h.lastIndexOf(e);if(d>0&&h.slice(1,d).every((function(t){return t==e}))&&-1==[n,e].indexOf(l))return h.filter((function(t){return t==e})).length%2==1?3:4;if(0==l&&1==c)return 0;if(2==l||0==l||1==l)return 14==c&&a.every((function(e){return e==t}))?2:1;if(2==c||0==c||1==c)return 1;if(6==l&&(6==c||7==c||9==c||10==c))return 0;if(!(9!=l&&7!=l||7!=c&&8!=c))return 0;if((10==l||8==l)&&8==c)return 0;if(c==t||15==c)return 0;if(5==c)return 0;if(l==n)return 0;var p=-1!=h.indexOf(t)?h.lastIndexOf(t)-1:h.length-2;return-1!=[i,s].indexOf(h[p])&&h.slice(p+1,-1).every((function(e){return e==t}))&&14==c||15==l&&-1!=[r,s].indexOf(c)?0:-1!=a.indexOf(e)?2:l==e&&c==e?0:1}function u(o){return 1536<=o&&o<=1541||1757==o||1807==o||2274==o||3406==o||69821==o||70082<=o&&o<=70083||72250==o||72326<=o&&o<=72329||73030==o?n:13==o?0:10==o?1:0<=o&&o<=9||11<=o&&o<=12||14<=o&&o<=31||127<=o&&o<=159||173==o||1564==o||6158==o||8203==o||8206<=o&&o<=8207||8232==o||8233==o||8234<=o&&o<=8238||8288<=o&&o<=8292||8293==o||8294<=o&&o<=8303||55296<=o&&o<=57343||65279==o||65520<=o&&o<=65528||65529<=o&&o<=65531||113824<=o&&o<=113827||119155<=o&&o<=119162||917504==o||917505==o||917506<=o&&o<=917535||917632<=o&&o<=917759||918e3<=o&&o<=921599?2:768<=o&&o<=879||1155<=o&&o<=1159||1160<=o&&o<=1161||1425<=o&&o<=1469||1471==o||1473<=o&&o<=1474||1476<=o&&o<=1477||1479==o||1552<=o&&o<=1562||1611<=o&&o<=1631||1648==o||1750<=o&&o<=1756||1759<=o&&o<=1764||1767<=o&&o<=1768||1770<=o&&o<=1773||1809==o||1840<=o&&o<=1866||1958<=o&&o<=1968||2027<=o&&o<=2035||2070<=o&&o<=2073||2075<=o&&o<=2083||2085<=o&&o<=2087||2089<=o&&o<=2093||2137<=o&&o<=2139||2260<=o&&o<=2273||2275<=o&&o<=2306||2362==o||2364==o||2369<=o&&o<=2376||2381==o||2385<=o&&o<=2391||2402<=o&&o<=2403||2433==o||2492==o||2494==o||2497<=o&&o<=2500||2509==o||2519==o||2530<=o&&o<=2531||2561<=o&&o<=2562||2620==o||2625<=o&&o<=2626||2631<=o&&o<=2632||2635<=o&&o<=2637||2641==o||2672<=o&&o<=2673||2677==o||2689<=o&&o<=2690||2748==o||2753<=o&&o<=2757||2759<=o&&o<=2760||2765==o||2786<=o&&o<=2787||2810<=o&&o<=2815||2817==o||2876==o||2878==o||2879==o||2881<=o&&o<=2884||2893==o||2902==o||2903==o||2914<=o&&o<=2915||2946==o||3006==o||3008==o||3021==o||3031==o||3072==o||3134<=o&&o<=3136||3142<=o&&o<=3144||3146<=o&&o<=3149||3157<=o&&o<=3158||3170<=o&&o<=3171||3201==o||3260==o||3263==o||3266==o||3270==o||3276<=o&&o<=3277||3285<=o&&o<=3286||3298<=o&&o<=3299||3328<=o&&o<=3329||3387<=o&&o<=3388||3390==o||3393<=o&&o<=3396||3405==o||3415==o||3426<=o&&o<=3427||3530==o||3535==o||3538<=o&&o<=3540||3542==o||3551==o||3633==o||3636<=o&&o<=3642||3655<=o&&o<=3662||3761==o||3764<=o&&o<=3769||3771<=o&&o<=3772||3784<=o&&o<=3789||3864<=o&&o<=3865||3893==o||3895==o||3897==o||3953<=o&&o<=3966||3968<=o&&o<=3972||3974<=o&&o<=3975||3981<=o&&o<=3991||3993<=o&&o<=4028||4038==o||4141<=o&&o<=4144||4146<=o&&o<=4151||4153<=o&&o<=4154||4157<=o&&o<=4158||4184<=o&&o<=4185||4190<=o&&o<=4192||4209<=o&&o<=4212||4226==o||4229<=o&&o<=4230||4237==o||4253==o||4957<=o&&o<=4959||5906<=o&&o<=5908||5938<=o&&o<=5940||5970<=o&&o<=5971||6002<=o&&o<=6003||6068<=o&&o<=6069||6071<=o&&o<=6077||6086==o||6089<=o&&o<=6099||6109==o||6155<=o&&o<=6157||6277<=o&&o<=6278||6313==o||6432<=o&&o<=6434||6439<=o&&o<=6440||6450==o||6457<=o&&o<=6459||6679<=o&&o<=6680||6683==o||6742==o||6744<=o&&o<=6750||6752==o||6754==o||6757<=o&&o<=6764||6771<=o&&o<=6780||6783==o||6832<=o&&o<=6845||6846==o||6912<=o&&o<=6915||6964==o||6966<=o&&o<=6970||6972==o||6978==o||7019<=o&&o<=7027||7040<=o&&o<=7041||7074<=o&&o<=7077||7080<=o&&o<=7081||7083<=o&&o<=7085||7142==o||7144<=o&&o<=7145||7149==o||7151<=o&&o<=7153||7212<=o&&o<=7219||7222<=o&&o<=7223||7376<=o&&o<=7378||7380<=o&&o<=7392||7394<=o&&o<=7400||7405==o||7412==o||7416<=o&&o<=7417||7616<=o&&o<=7673||7675<=o&&o<=7679||8204==o||8400<=o&&o<=8412||8413<=o&&o<=8416||8417==o||8418<=o&&o<=8420||8421<=o&&o<=8432||11503<=o&&o<=11505||11647==o||11744<=o&&o<=11775||12330<=o&&o<=12333||12334<=o&&o<=12335||12441<=o&&o<=12442||42607==o||42608<=o&&o<=42610||42612<=o&&o<=42621||42654<=o&&o<=42655||42736<=o&&o<=42737||43010==o||43014==o||43019==o||43045<=o&&o<=43046||43204<=o&&o<=43205||43232<=o&&o<=43249||43302<=o&&o<=43309||43335<=o&&o<=43345||43392<=o&&o<=43394||43443==o||43446<=o&&o<=43449||43452==o||43493==o||43561<=o&&o<=43566||43569<=o&&o<=43570||43573<=o&&o<=43574||43587==o||43596==o||43644==o||43696==o||43698<=o&&o<=43700||43703<=o&&o<=43704||43710<=o&&o<=43711||43713==o||43756<=o&&o<=43757||43766==o||44005==o||44008==o||44013==o||64286==o||65024<=o&&o<=65039||65056<=o&&o<=65071||65438<=o&&o<=65439||66045==o||66272==o||66422<=o&&o<=66426||68097<=o&&o<=68099||68101<=o&&o<=68102||68108<=o&&o<=68111||68152<=o&&o<=68154||68159==o||68325<=o&&o<=68326||69633==o||69688<=o&&o<=69702||69759<=o&&o<=69761||69811<=o&&o<=69814||69817<=o&&o<=69818||69888<=o&&o<=69890||69927<=o&&o<=69931||69933<=o&&o<=69940||70003==o||70016<=o&&o<=70017||70070<=o&&o<=70078||70090<=o&&o<=70092||70191<=o&&o<=70193||70196==o||70198<=o&&o<=70199||70206==o||70367==o||70371<=o&&o<=70378||70400<=o&&o<=70401||70460==o||70462==o||70464==o||70487==o||70502<=o&&o<=70508||70512<=o&&o<=70516||70712<=o&&o<=70719||70722<=o&&o<=70724||70726==o||70832==o||70835<=o&&o<=70840||70842==o||70845==o||70847<=o&&o<=70848||70850<=o&&o<=70851||71087==o||71090<=o&&o<=71093||71100<=o&&o<=71101||71103<=o&&o<=71104||71132<=o&&o<=71133||71219<=o&&o<=71226||71229==o||71231<=o&&o<=71232||71339==o||71341==o||71344<=o&&o<=71349||71351==o||71453<=o&&o<=71455||71458<=o&&o<=71461||71463<=o&&o<=71467||72193<=o&&o<=72198||72201<=o&&o<=72202||72243<=o&&o<=72248||72251<=o&&o<=72254||72263==o||72273<=o&&o<=72278||72281<=o&&o<=72283||72330<=o&&o<=72342||72344<=o&&o<=72345||72752<=o&&o<=72758||72760<=o&&o<=72765||72767==o||72850<=o&&o<=72871||72874<=o&&o<=72880||72882<=o&&o<=72883||72885<=o&&o<=72886||73009<=o&&o<=73014||73018==o||73020<=o&&o<=73021||73023<=o&&o<=73029||73031==o||92912<=o&&o<=92916||92976<=o&&o<=92982||94095<=o&&o<=94098||113821<=o&&o<=113822||119141==o||119143<=o&&o<=119145||119150<=o&&o<=119154||119163<=o&&o<=119170||119173<=o&&o<=119179||119210<=o&&o<=119213||119362<=o&&o<=119364||121344<=o&&o<=121398||121403<=o&&o<=121452||121461==o||121476==o||121499<=o&&o<=121503||121505<=o&&o<=121519||122880<=o&&o<=122886||122888<=o&&o<=122904||122907<=o&&o<=122913||122915<=o&&o<=122916||122918<=o&&o<=122922||125136<=o&&o<=125142||125252<=o&&o<=125258||917536<=o&&o<=917631||917760<=o&&o<=917999?t:127462<=o&&o<=127487?e:2307==o||2363==o||2366<=o&&o<=2368||2377<=o&&o<=2380||2382<=o&&o<=2383||2434<=o&&o<=2435||2495<=o&&o<=2496||2503<=o&&o<=2504||2507<=o&&o<=2508||2563==o||2622<=o&&o<=2624||2691==o||2750<=o&&o<=2752||2761==o||2763<=o&&o<=2764||2818<=o&&o<=2819||2880==o||2887<=o&&o<=2888||2891<=o&&o<=2892||3007==o||3009<=o&&o<=3010||3014<=o&&o<=3016||3018<=o&&o<=3020||3073<=o&&o<=3075||3137<=o&&o<=3140||3202<=o&&o<=3203||3262==o||3264<=o&&o<=3265||3267<=o&&o<=3268||3271<=o&&o<=3272||3274<=o&&o<=3275||3330<=o&&o<=3331||3391<=o&&o<=3392||3398<=o&&o<=3400||3402<=o&&o<=3404||3458<=o&&o<=3459||3536<=o&&o<=3537||3544<=o&&o<=3550||3570<=o&&o<=3571||3635==o||3763==o||3902<=o&&o<=3903||3967==o||4145==o||4155<=o&&o<=4156||4182<=o&&o<=4183||4228==o||6070==o||6078<=o&&o<=6085||6087<=o&&o<=6088||6435<=o&&o<=6438||6441<=o&&o<=6443||6448<=o&&o<=6449||6451<=o&&o<=6456||6681<=o&&o<=6682||6741==o||6743==o||6765<=o&&o<=6770||6916==o||6965==o||6971==o||6973<=o&&o<=6977||6979<=o&&o<=6980||7042==o||7073==o||7078<=o&&o<=7079||7082==o||7143==o||7146<=o&&o<=7148||7150==o||7154<=o&&o<=7155||7204<=o&&o<=7211||7220<=o&&o<=7221||7393==o||7410<=o&&o<=7411||7415==o||43043<=o&&o<=43044||43047==o||43136<=o&&o<=43137||43188<=o&&o<=43203||43346<=o&&o<=43347||43395==o||43444<=o&&o<=43445||43450<=o&&o<=43451||43453<=o&&o<=43456||43567<=o&&o<=43568||43571<=o&&o<=43572||43597==o||43755==o||43758<=o&&o<=43759||43765==o||44003<=o&&o<=44004||44006<=o&&o<=44007||44009<=o&&o<=44010||44012==o||69632==o||69634==o||69762==o||69808<=o&&o<=69810||69815<=o&&o<=69816||69932==o||70018==o||70067<=o&&o<=70069||70079<=o&&o<=70080||70188<=o&&o<=70190||70194<=o&&o<=70195||70197==o||70368<=o&&o<=70370||70402<=o&&o<=70403||70463==o||70465<=o&&o<=70468||70471<=o&&o<=70472||70475<=o&&o<=70477||70498<=o&&o<=70499||70709<=o&&o<=70711||70720<=o&&o<=70721||70725==o||70833<=o&&o<=70834||70841==o||70843<=o&&o<=70844||70846==o||70849==o||71088<=o&&o<=71089||71096<=o&&o<=71099||71102==o||71216<=o&&o<=71218||71227<=o&&o<=71228||71230==o||71340==o||71342<=o&&o<=71343||71350==o||71456<=o&&o<=71457||71462==o||72199<=o&&o<=72200||72249==o||72279<=o&&o<=72280||72343==o||72751==o||72766==o||72873==o||72881==o||72884==o||94033<=o&&o<=94078||119142==o||119149==o?5:4352<=o&&o<=4447||43360<=o&&o<=43388?6:4448<=o&&o<=4519||55216<=o&&o<=55238?7:4520<=o&&o<=4607||55243<=o&&o<=55291?8:44032==o||44060==o||44088==o||44116==o||44144==o||44172==o||44200==o||44228==o||44256==o||44284==o||44312==o||44340==o||44368==o||44396==o||44424==o||44452==o||44480==o||44508==o||44536==o||44564==o||44592==o||44620==o||44648==o||44676==o||44704==o||44732==o||44760==o||44788==o||44816==o||44844==o||44872==o||44900==o||44928==o||44956==o||44984==o||45012==o||45040==o||45068==o||45096==o||45124==o||45152==o||45180==o||45208==o||45236==o||45264==o||45292==o||45320==o||45348==o||45376==o||45404==o||45432==o||45460==o||45488==o||45516==o||45544==o||45572==o||45600==o||45628==o||45656==o||45684==o||45712==o||45740==o||45768==o||45796==o||45824==o||45852==o||45880==o||45908==o||45936==o||45964==o||45992==o||46020==o||46048==o||46076==o||46104==o||46132==o||46160==o||46188==o||46216==o||46244==o||46272==o||46300==o||46328==o||46356==o||46384==o||46412==o||46440==o||46468==o||46496==o||46524==o||46552==o||46580==o||46608==o||46636==o||46664==o||46692==o||46720==o||46748==o||46776==o||46804==o||46832==o||46860==o||46888==o||46916==o||46944==o||46972==o||47e3==o||47028==o||47056==o||47084==o||47112==o||47140==o||47168==o||47196==o||47224==o||47252==o||47280==o||47308==o||47336==o||47364==o||47392==o||47420==o||47448==o||47476==o||47504==o||47532==o||47560==o||47588==o||47616==o||47644==o||47672==o||47700==o||47728==o||47756==o||47784==o||47812==o||47840==o||47868==o||47896==o||47924==o||47952==o||47980==o||48008==o||48036==o||48064==o||48092==o||48120==o||48148==o||48176==o||48204==o||48232==o||48260==o||48288==o||48316==o||48344==o||48372==o||48400==o||48428==o||48456==o||48484==o||48512==o||48540==o||48568==o||48596==o||48624==o||48652==o||48680==o||48708==o||48736==o||48764==o||48792==o||48820==o||48848==o||48876==o||48904==o||48932==o||48960==o||48988==o||49016==o||49044==o||49072==o||49100==o||49128==o||49156==o||49184==o||49212==o||49240==o||49268==o||49296==o||49324==o||49352==o||49380==o||49408==o||49436==o||49464==o||49492==o||49520==o||49548==o||49576==o||49604==o||49632==o||49660==o||49688==o||49716==o||49744==o||49772==o||49800==o||49828==o||49856==o||49884==o||49912==o||49940==o||49968==o||49996==o||50024==o||50052==o||50080==o||50108==o||50136==o||50164==o||50192==o||50220==o||50248==o||50276==o||50304==o||50332==o||50360==o||50388==o||50416==o||50444==o||50472==o||50500==o||50528==o||50556==o||50584==o||50612==o||50640==o||50668==o||50696==o||50724==o||50752==o||50780==o||50808==o||50836==o||50864==o||50892==o||50920==o||50948==o||50976==o||51004==o||51032==o||51060==o||51088==o||51116==o||51144==o||51172==o||51200==o||51228==o||51256==o||51284==o||51312==o||51340==o||51368==o||51396==o||51424==o||51452==o||51480==o||51508==o||51536==o||51564==o||51592==o||51620==o||51648==o||51676==o||51704==o||51732==o||51760==o||51788==o||51816==o||51844==o||51872==o||51900==o||51928==o||51956==o||51984==o||52012==o||52040==o||52068==o||52096==o||52124==o||52152==o||52180==o||52208==o||52236==o||52264==o||52292==o||52320==o||52348==o||52376==o||52404==o||52432==o||52460==o||52488==o||52516==o||52544==o||52572==o||52600==o||52628==o||52656==o||52684==o||52712==o||52740==o||52768==o||52796==o||52824==o||52852==o||52880==o||52908==o||52936==o||52964==o||52992==o||53020==o||53048==o||53076==o||53104==o||53132==o||53160==o||53188==o||53216==o||53244==o||53272==o||53300==o||53328==o||53356==o||53384==o||53412==o||53440==o||53468==o||53496==o||53524==o||53552==o||53580==o||53608==o||53636==o||53664==o||53692==o||53720==o||53748==o||53776==o||53804==o||53832==o||53860==o||53888==o||53916==o||53944==o||53972==o||54e3==o||54028==o||54056==o||54084==o||54112==o||54140==o||54168==o||54196==o||54224==o||54252==o||54280==o||54308==o||54336==o||54364==o||54392==o||54420==o||54448==o||54476==o||54504==o||54532==o||54560==o||54588==o||54616==o||54644==o||54672==o||54700==o||54728==o||54756==o||54784==o||54812==o||54840==o||54868==o||54896==o||54924==o||54952==o||54980==o||55008==o||55036==o||55064==o||55092==o||55120==o||55148==o||55176==o?9:44033<=o&&o<=44059||44061<=o&&o<=44087||44089<=o&&o<=44115||44117<=o&&o<=44143||44145<=o&&o<=44171||44173<=o&&o<=44199||44201<=o&&o<=44227||44229<=o&&o<=44255||44257<=o&&o<=44283||44285<=o&&o<=44311||44313<=o&&o<=44339||44341<=o&&o<=44367||44369<=o&&o<=44395||44397<=o&&o<=44423||44425<=o&&o<=44451||44453<=o&&o<=44479||44481<=o&&o<=44507||44509<=o&&o<=44535||44537<=o&&o<=44563||44565<=o&&o<=44591||44593<=o&&o<=44619||44621<=o&&o<=44647||44649<=o&&o<=44675||44677<=o&&o<=44703||44705<=o&&o<=44731||44733<=o&&o<=44759||44761<=o&&o<=44787||44789<=o&&o<=44815||44817<=o&&o<=44843||44845<=o&&o<=44871||44873<=o&&o<=44899||44901<=o&&o<=44927||44929<=o&&o<=44955||44957<=o&&o<=44983||44985<=o&&o<=45011||45013<=o&&o<=45039||45041<=o&&o<=45067||45069<=o&&o<=45095||45097<=o&&o<=45123||45125<=o&&o<=45151||45153<=o&&o<=45179||45181<=o&&o<=45207||45209<=o&&o<=45235||45237<=o&&o<=45263||45265<=o&&o<=45291||45293<=o&&o<=45319||45321<=o&&o<=45347||45349<=o&&o<=45375||45377<=o&&o<=45403||45405<=o&&o<=45431||45433<=o&&o<=45459||45461<=o&&o<=45487||45489<=o&&o<=45515||45517<=o&&o<=45543||45545<=o&&o<=45571||45573<=o&&o<=45599||45601<=o&&o<=45627||45629<=o&&o<=45655||45657<=o&&o<=45683||45685<=o&&o<=45711||45713<=o&&o<=45739||45741<=o&&o<=45767||45769<=o&&o<=45795||45797<=o&&o<=45823||45825<=o&&o<=45851||45853<=o&&o<=45879||45881<=o&&o<=45907||45909<=o&&o<=45935||45937<=o&&o<=45963||45965<=o&&o<=45991||45993<=o&&o<=46019||46021<=o&&o<=46047||46049<=o&&o<=46075||46077<=o&&o<=46103||46105<=o&&o<=46131||46133<=o&&o<=46159||46161<=o&&o<=46187||46189<=o&&o<=46215||46217<=o&&o<=46243||46245<=o&&o<=46271||46273<=o&&o<=46299||46301<=o&&o<=46327||46329<=o&&o<=46355||46357<=o&&o<=46383||46385<=o&&o<=46411||46413<=o&&o<=46439||46441<=o&&o<=46467||46469<=o&&o<=46495||46497<=o&&o<=46523||46525<=o&&o<=46551||46553<=o&&o<=46579||46581<=o&&o<=46607||46609<=o&&o<=46635||46637<=o&&o<=46663||46665<=o&&o<=46691||46693<=o&&o<=46719||46721<=o&&o<=46747||46749<=o&&o<=46775||46777<=o&&o<=46803||46805<=o&&o<=46831||46833<=o&&o<=46859||46861<=o&&o<=46887||46889<=o&&o<=46915||46917<=o&&o<=46943||46945<=o&&o<=46971||46973<=o&&o<=46999||47001<=o&&o<=47027||47029<=o&&o<=47055||47057<=o&&o<=47083||47085<=o&&o<=47111||47113<=o&&o<=47139||47141<=o&&o<=47167||47169<=o&&o<=47195||47197<=o&&o<=47223||47225<=o&&o<=47251||47253<=o&&o<=47279||47281<=o&&o<=47307||47309<=o&&o<=47335||47337<=o&&o<=47363||47365<=o&&o<=47391||47393<=o&&o<=47419||47421<=o&&o<=47447||47449<=o&&o<=47475||47477<=o&&o<=47503||47505<=o&&o<=47531||47533<=o&&o<=47559||47561<=o&&o<=47587||47589<=o&&o<=47615||47617<=o&&o<=47643||47645<=o&&o<=47671||47673<=o&&o<=47699||47701<=o&&o<=47727||47729<=o&&o<=47755||47757<=o&&o<=47783||47785<=o&&o<=47811||47813<=o&&o<=47839||47841<=o&&o<=47867||47869<=o&&o<=47895||47897<=o&&o<=47923||47925<=o&&o<=47951||47953<=o&&o<=47979||47981<=o&&o<=48007||48009<=o&&o<=48035||48037<=o&&o<=48063||48065<=o&&o<=48091||48093<=o&&o<=48119||48121<=o&&o<=48147||48149<=o&&o<=48175||48177<=o&&o<=48203||48205<=o&&o<=48231||48233<=o&&o<=48259||48261<=o&&o<=48287||48289<=o&&o<=48315||48317<=o&&o<=48343||48345<=o&&o<=48371||48373<=o&&o<=48399||48401<=o&&o<=48427||48429<=o&&o<=48455||48457<=o&&o<=48483||48485<=o&&o<=48511||48513<=o&&o<=48539||48541<=o&&o<=48567||48569<=o&&o<=48595||48597<=o&&o<=48623||48625<=o&&o<=48651||48653<=o&&o<=48679||48681<=o&&o<=48707||48709<=o&&o<=48735||48737<=o&&o<=48763||48765<=o&&o<=48791||48793<=o&&o<=48819||48821<=o&&o<=48847||48849<=o&&o<=48875||48877<=o&&o<=48903||48905<=o&&o<=48931||48933<=o&&o<=48959||48961<=o&&o<=48987||48989<=o&&o<=49015||49017<=o&&o<=49043||49045<=o&&o<=49071||49073<=o&&o<=49099||49101<=o&&o<=49127||49129<=o&&o<=49155||49157<=o&&o<=49183||49185<=o&&o<=49211||49213<=o&&o<=49239||49241<=o&&o<=49267||49269<=o&&o<=49295||49297<=o&&o<=49323||49325<=o&&o<=49351||49353<=o&&o<=49379||49381<=o&&o<=49407||49409<=o&&o<=49435||49437<=o&&o<=49463||49465<=o&&o<=49491||49493<=o&&o<=49519||49521<=o&&o<=49547||49549<=o&&o<=49575||49577<=o&&o<=49603||49605<=o&&o<=49631||49633<=o&&o<=49659||49661<=o&&o<=49687||49689<=o&&o<=49715||49717<=o&&o<=49743||49745<=o&&o<=49771||49773<=o&&o<=49799||49801<=o&&o<=49827||49829<=o&&o<=49855||49857<=o&&o<=49883||49885<=o&&o<=49911||49913<=o&&o<=49939||49941<=o&&o<=49967||49969<=o&&o<=49995||49997<=o&&o<=50023||50025<=o&&o<=50051||50053<=o&&o<=50079||50081<=o&&o<=50107||50109<=o&&o<=50135||50137<=o&&o<=50163||50165<=o&&o<=50191||50193<=o&&o<=50219||50221<=o&&o<=50247||50249<=o&&o<=50275||50277<=o&&o<=50303||50305<=o&&o<=50331||50333<=o&&o<=50359||50361<=o&&o<=50387||50389<=o&&o<=50415||50417<=o&&o<=50443||50445<=o&&o<=50471||50473<=o&&o<=50499||50501<=o&&o<=50527||50529<=o&&o<=50555||50557<=o&&o<=50583||50585<=o&&o<=50611||50613<=o&&o<=50639||50641<=o&&o<=50667||50669<=o&&o<=50695||50697<=o&&o<=50723||50725<=o&&o<=50751||50753<=o&&o<=50779||50781<=o&&o<=50807||50809<=o&&o<=50835||50837<=o&&o<=50863||50865<=o&&o<=50891||50893<=o&&o<=50919||50921<=o&&o<=50947||50949<=o&&o<=50975||50977<=o&&o<=51003||51005<=o&&o<=51031||51033<=o&&o<=51059||51061<=o&&o<=51087||51089<=o&&o<=51115||51117<=o&&o<=51143||51145<=o&&o<=51171||51173<=o&&o<=51199||51201<=o&&o<=51227||51229<=o&&o<=51255||51257<=o&&o<=51283||51285<=o&&o<=51311||51313<=o&&o<=51339||51341<=o&&o<=51367||51369<=o&&o<=51395||51397<=o&&o<=51423||51425<=o&&o<=51451||51453<=o&&o<=51479||51481<=o&&o<=51507||51509<=o&&o<=51535||51537<=o&&o<=51563||51565<=o&&o<=51591||51593<=o&&o<=51619||51621<=o&&o<=51647||51649<=o&&o<=51675||51677<=o&&o<=51703||51705<=o&&o<=51731||51733<=o&&o<=51759||51761<=o&&o<=51787||51789<=o&&o<=51815||51817<=o&&o<=51843||51845<=o&&o<=51871||51873<=o&&o<=51899||51901<=o&&o<=51927||51929<=o&&o<=51955||51957<=o&&o<=51983||51985<=o&&o<=52011||52013<=o&&o<=52039||52041<=o&&o<=52067||52069<=o&&o<=52095||52097<=o&&o<=52123||52125<=o&&o<=52151||52153<=o&&o<=52179||52181<=o&&o<=52207||52209<=o&&o<=52235||52237<=o&&o<=52263||52265<=o&&o<=52291||52293<=o&&o<=52319||52321<=o&&o<=52347||52349<=o&&o<=52375||52377<=o&&o<=52403||52405<=o&&o<=52431||52433<=o&&o<=52459||52461<=o&&o<=52487||52489<=o&&o<=52515||52517<=o&&o<=52543||52545<=o&&o<=52571||52573<=o&&o<=52599||52601<=o&&o<=52627||52629<=o&&o<=52655||52657<=o&&o<=52683||52685<=o&&o<=52711||52713<=o&&o<=52739||52741<=o&&o<=52767||52769<=o&&o<=52795||52797<=o&&o<=52823||52825<=o&&o<=52851||52853<=o&&o<=52879||52881<=o&&o<=52907||52909<=o&&o<=52935||52937<=o&&o<=52963||52965<=o&&o<=52991||52993<=o&&o<=53019||53021<=o&&o<=53047||53049<=o&&o<=53075||53077<=o&&o<=53103||53105<=o&&o<=53131||53133<=o&&o<=53159||53161<=o&&o<=53187||53189<=o&&o<=53215||53217<=o&&o<=53243||53245<=o&&o<=53271||53273<=o&&o<=53299||53301<=o&&o<=53327||53329<=o&&o<=53355||53357<=o&&o<=53383||53385<=o&&o<=53411||53413<=o&&o<=53439||53441<=o&&o<=53467||53469<=o&&o<=53495||53497<=o&&o<=53523||53525<=o&&o<=53551||53553<=o&&o<=53579||53581<=o&&o<=53607||53609<=o&&o<=53635||53637<=o&&o<=53663||53665<=o&&o<=53691||53693<=o&&o<=53719||53721<=o&&o<=53747||53749<=o&&o<=53775||53777<=o&&o<=53803||53805<=o&&o<=53831||53833<=o&&o<=53859||53861<=o&&o<=53887||53889<=o&&o<=53915||53917<=o&&o<=53943||53945<=o&&o<=53971||53973<=o&&o<=53999||54001<=o&&o<=54027||54029<=o&&o<=54055||54057<=o&&o<=54083||54085<=o&&o<=54111||54113<=o&&o<=54139||54141<=o&&o<=54167||54169<=o&&o<=54195||54197<=o&&o<=54223||54225<=o&&o<=54251||54253<=o&&o<=54279||54281<=o&&o<=54307||54309<=o&&o<=54335||54337<=o&&o<=54363||54365<=o&&o<=54391||54393<=o&&o<=54419||54421<=o&&o<=54447||54449<=o&&o<=54475||54477<=o&&o<=54503||54505<=o&&o<=54531||54533<=o&&o<=54559||54561<=o&&o<=54587||54589<=o&&o<=54615||54617<=o&&o<=54643||54645<=o&&o<=54671||54673<=o&&o<=54699||54701<=o&&o<=54727||54729<=o&&o<=54755||54757<=o&&o<=54783||54785<=o&&o<=54811||54813<=o&&o<=54839||54841<=o&&o<=54867||54869<=o&&o<=54895||54897<=o&&o<=54923||54925<=o&&o<=54951||54953<=o&&o<=54979||54981<=o&&o<=55007||55009<=o&&o<=55035||55037<=o&&o<=55063||55065<=o&&o<=55091||55093<=o&&o<=55119||55121<=o&&o<=55147||55149<=o&&o<=55175||55177<=o&&o<=55203?10:9757==o||9977==o||9994<=o&&o<=9997||127877==o||127938<=o&&o<=127940||127943==o||127946<=o&&o<=127948||128066<=o&&o<=128067||128070<=o&&o<=128080||128110==o||128112<=o&&o<=128120||128124==o||128129<=o&&o<=128131||128133<=o&&o<=128135||128170==o||128372<=o&&o<=128373||128378==o||128400==o||128405<=o&&o<=128406||128581<=o&&o<=128583||128587<=o&&o<=128591||128675==o||128692<=o&&o<=128694||128704==o||128716==o||129304<=o&&o<=129308||129310<=o&&o<=129311||129318==o||129328<=o&&o<=129337||129341<=o&&o<=129342||129489<=o&&o<=129501?i:127995<=o&&o<=127999?14:8205==o?15:9792==o||9794==o||9877<=o&&o<=9878||9992==o||10084==o||127752==o||127806==o||127859==o||127891==o||127908==o||127912==o||127979==o||127981==o||128139==o||128187<=o&&o<=128188||128295==o||128300==o||128488==o||128640==o||128658==o?r:128102<=o&&o<=128105?s:11}return this.nextBreak=function(t,e){if(void 0===e&&(e=0),e<0)return 0;if(e>=t.length-1)return t.length;for(var n,i,r=u(o(t,e)),s=[],h=e+1;h<t.length;h++)if(i=h-1,!(55296<=(n=t).charCodeAt(i)&&n.charCodeAt(i)<=56319&&56320<=n.charCodeAt(i+1)&&n.charCodeAt(i+1)<=57343)){var l=u(o(t,h));if(a(r,s,l))return h;s.push(l)}return t.length},this.splitGraphemes=function(t){for(var e,n=[],i=0;(e=this.nextBreak(t,i))<t.length;)n.push(t.slice(i,e)),i=e;return i<t.length&&n.push(t.slice(i)),n},this.iterateGraphemes=function(t){var e=0,n={next:function(){var n,i;return(i=this.nextBreak(t,e))<t.length?(n=t.slice(e,i),e=i,{value:n,done:!1}):e<t.length?(n=t.slice(e),e=t.length,{value:n,done:!1}):{value:void 0,done:!0}}.bind(this)};return"undefined"!=typeof Symbol&&Symbol.iterator&&(n[Symbol.iterator]=function(){return n}),n},this.countGraphemes=function(t){for(var e,n=0,i=0;(e=this.nextBreak(t,i))<t.length;)i=e,n++;return i<t.length&&n++,n},this})),qv.exports),Bv=gf(jv);function Lv(){this.textureInfo=void 0,this.dimensions=void 0,this.billboard=void 0}function Hv(t,e,n){this.labelCollection=t,this.index=e,this.dimensions=n}const Vv="ID_WHITE_PIXEL",Wv=new e.Cartesian2(4,4),Gv=new e.BoundingRectangle(1,1,1,1),Qv={};function Kv(t,n,i,r,s,o,a){return Qv.font=n,Qv.fillColor=i,Qv.strokeColor=r,Qv.strokeWidth=s,Qv.padding=e.SDFSettings.PADDING,a===e.VerticalOrigin.CENTER?Qv.textBaseline="middle":a===e.VerticalOrigin.TOP?Qv.textBaseline="top":Qv.textBaseline="bottom",Qv.fill=o===e.LabelStyle.FILL||o===e.LabelStyle.FILL_AND_OUTLINE,Qv.stroke=o===e.LabelStyle.OUTLINE||o===e.LabelStyle.FILL_AND_OUTLINE,Qv.backgroundColor=e.Color.BLACK,e.writeTextToCanvas(t,Qv)}function Xv(t,n){n.textureInfo=void 0,n.dimensions=void 0;const i=n.billboard;e.defined(i)&&(i.show=!1,i.image=void 0,e.defined(i._removeCallbackFunc)&&(i._removeCallbackFunc(),i._removeCallbackFunc=void 0),t._reuseBillboards&&t._spareBillboards.push(i),n.billboard=void 0)}function Zv(t,e,n,i){i.index=t.addImageSync(e,n)}const Yv=new Bv;function Jv(t,n){const i=n._renderedText,r=Yv.splitGraphemes(i),s=r.length,o=n._glyphs,a=o.length;let u,h,l;if(n._relativeSize=n._fontSize/e.SDFSettings.FONT_SIZE,s<a)for(h=s;h<a;++h)Xv(t,o[h]);o.length=s;const c=n.show&&n._showBackground&&i.split("\n").join("").length>0;let f=n._backgroundBillboard;const d=t._backgroundBillboardCollection;c?(e.defined(f)||(f=d.add({collection:t,image:Vv,imageSubRegion:Gv}),n._backgroundBillboard=f),f.color=n._backgroundColor,f.show=n._show,f.position=n._position,f.eyeOffset=n._eyeOffset,f.pixelOffset=n._pixelOffset,f.horizontalOrigin=e.HorizontalOrigin.LEFT,f.verticalOrigin=n._verticalOrigin,f.heightReference=n._heightReference,f.scale=n.totalScale,f.pickPrimitive=n,f.id=n._id,f.translucencyByDistance=n._translucencyByDistance,f.pixelOffsetScaleByDistance=n._pixelOffsetScaleByDistance,f.scaleByDistance=n._scaleByDistance,f.distanceDisplayCondition=n._distanceDisplayCondition,f.disableDepthTestDistance=n._disableDepthTestDistance,f.clusterShow=n.clusterShow):e.defined(f)&&(d.remove(f),n._backgroundBillboard=f=void 0);const p=t._glyphTextureCache;for(l=0;l<s;++l){const i=r[l],s=n._verticalOrigin,a=JSON.stringify([i,n._fontFamily,n._fontStyle,n._fontWeight,+s]);let h=p[a];if(!e.defined(h)){const r=Kv(i,`${n._fontStyle} ${n._fontWeight} ${e.SDFSettings.FONT_SIZE}px ${n._fontFamily}`,e.Color.WHITE,e.Color.WHITE,0,e.LabelStyle.FILL,s);if(h=new Hv(t,-1,r.dimensions),p[a]=h,r.width>0&&r.height>0){const n=zp(r,{cutoff:e.SDFSettings.CUTOFF,radius:e.SDFSettings.RADIUS}),s=r.getContext("2d"),o=r.width,u=r.height,l=s.getImageData(0,0,o,u);for(let t=0;t<o;t++)for(let e=0;e<u;e++){const i=e*o+t,r=255*n[i],s=4*i;l.data[s+0]=r,l.data[s+1]=r,l.data[s+2]=r,l.data[s+3]=r}s.putImageData(l,0,0)," "!==i&&Zv(t._textureAtlas,a,r,h)}}if(u=o[l],e.defined(u)?-1===h.index?Xv(t,u):e.defined(u.textureInfo)&&(u.textureInfo=void 0):(u=new Lv,o[l]=u),u.textureInfo=h,u.dimensions=h.dimensions,-1!==h.index){let i=u.billboard;const r=t._spareBillboards;e.defined(i)||(r.length>0?i=r.pop():(i=t._billboardCollection.add({collection:t}),i._labelDimensions=new e.Cartesian2,i._labelTranslate=new e.Cartesian2),u.billboard=i),i.show=n._show,i.position=n._position,i.eyeOffset=n._eyeOffset,i.pixelOffset=n._pixelOffset,i.horizontalOrigin=e.HorizontalOrigin.LEFT,i.verticalOrigin=n._verticalOrigin,i.heightReference=n._heightReference,i.scale=n.totalScale,i.pickPrimitive=n,i.id=n._id,i.image=a,i.translucencyByDistance=n._translucencyByDistance,i.pixelOffsetScaleByDistance=n._pixelOffsetScaleByDistance,i.scaleByDistance=n._scaleByDistance,i.distanceDisplayCondition=n._distanceDisplayCondition,i.disableDepthTestDistance=n._disableDepthTestDistance,i._batchIndex=n._batchIndex,i.outlineColor=n.outlineColor,i.roadDirection=n.roadDirection||Cesium.Cartesian4.ZERO.clone(),n.style===e.LabelStyle.FILL_AND_OUTLINE?(i.color=n._fillColor,i.outlineWidth=n.outlineWidth):n.style===e.LabelStyle.FILL?(i.color=n._fillColor,i.outlineWidth=0):n.style===e.LabelStyle.OUTLINE&&(i.color=e.Color.TRANSPARENT,i.outlineWidth=n.outlineWidth)}}n._repositionAllGlyphs=!0}function ty(t,n,i){return n===e.HorizontalOrigin.CENTER?-t/2:n===e.HorizontalOrigin.RIGHT?-(t+i.x):i.x}const ey=new e.Cartesian2,ny=new e.Cartesian2;function iy(t){const n=t._glyphs,i=t._renderedText;let r,s,o=0,a=0;const u=[];let h,l=Number.NEGATIVE_INFINITY,c=0,f=1;const d=n.length,p=t._backgroundBillboard,v=e.Cartesian2.clone(e.defined(p)?t._backgroundPadding:e.Cartesian2.ZERO,ny);for(v.x/=t._relativeSize,v.y/=t._relativeSize,h=0;h<d;++h)"\n"===i.charAt(h)?(u.push(o),++f,o=0):(r=n[h],s=r.dimensions,c=Math.max(c,s.height-s.descent),l=Math.max(l,s.descent),o+=s.width-s.minx,h<d-1&&(o+=n[h+1].dimensions.minx),a=Math.max(a,o));u.push(o);const y=c+l,m=t.totalScale,w=t._horizontalOrigin,g=t._verticalOrigin;let b=0,x=u[b],_=ty(x,w,v);const k=(e.defined(t._lineHeight)?t._lineHeight:1.2*t._fontSize)/t._relativeSize,$=k*(f-1);let S=a,M=y+$;e.defined(p)&&(S+=2*v.x,M+=2*v.y,p._labelHorizontalOrigin=w),ey.x=_*m,ey.y=0;let E=!0,C=0;for(h=0;h<d;++h)if("\n"===i.charAt(h))++b,C+=k,x=u[b],_=ty(x,w,v),ey.x=_*m,E=!0;else if(r=n[h],s=r.dimensions,g===e.VerticalOrigin.TOP?(ey.y=s.height-c-v.y,ey.y+=e.SDFSettings.PADDING):g===e.VerticalOrigin.CENTER?ey.y=($+s.height-c)/2:g===e.VerticalOrigin.BASELINE?(ey.y=$,ey.y-=e.SDFSettings.PADDING):(ey.y=$+l+v.y,ey.y-=e.SDFSettings.PADDING),ey.y=(ey.y-s.descent-C)*m,E&&(ey.x-=e.SDFSettings.PADDING*m,E=!1),e.defined(r.billboard)&&(r.billboard._setTranslate(ey),r.billboard._labelDimensions.x=S,r.billboard._labelDimensions.y=M,r.billboard._labelHorizontalOrigin=w),h<d-1){const t=n[h+1];ey.x+=(s.width-s.minx+t.dimensions.minx)*m}if(e.defined(p)&&i.split("\n").join("").length>0&&(_=w===e.HorizontalOrigin.CENTER?-a/2-v.x:w===e.HorizontalOrigin.RIGHT?-(a+2*v.x):0,ey.x=_*m,g===e.VerticalOrigin.TOP?ey.y=y-c-l:g===e.VerticalOrigin.CENTER?ey.y=(y-c)/2-l:g===e.VerticalOrigin.BASELINE?ey.y=-v.y-l:ey.y=0,ey.y=ey.y*m,p.width=S,p.height=M,p._setTranslate(ey),p._labelTranslate=e.Cartesian2.clone(ey,p._labelTranslate)),(A=t.heightReference)===e.HeightReference.CLAMP_TO_GROUND||A===e.HeightReference.CLAMP_TO_3D_TILE||A===e.HeightReference.CLAMP_TO_TERRAIN)for(h=0;h<d;++h){r=n[h];const t=r.billboard;e.defined(t)&&(t._labelTranslate=e.Cartesian2.clone(ey,t._labelTranslate))}var A}function ry(t,n){const i=n._glyphs;for(let e=0,n=i.length;e<n;++e)Xv(t,i[e]);e.defined(n._backgroundBillboard)&&(t._backgroundBillboardCollection.remove(n._backgroundBillboard),n._backgroundBillboard=void 0),n._labelCollection=void 0,e.defined(n._removeCallbackFunc)&&n._removeCallbackFunc(),e.destroyObject(n)}function sy(t){t=e.defaultValue(t,e.defaultValue.EMPTY_OBJECT),this.preloadSDF=!!t.preloadSDF,this.preloadSDFTextureUrl=e.defaultValue(t.preloadSDFTextureUrl,""),this.preloadSDFConfigUrl=e.defaultValue(t.preloadSDFConfigUrl,""),this._reuseBillboards=e.defaultValue(t.reuseBillboards,!0),this._scene=t.scene,this._batchTable=t.batchTable,this._textureAtlas=void 0,this._backgroundTextureAtlas=void 0,this._backgroundBillboardCollection=new iv({scene:this._scene}),this._backgroundBillboardCollection.destroyTextureAtlas=!1,this._billboardCollection=new iv({scene:this._scene,batchTable:this._batchTable}),this._billboardCollection.destroyTextureAtlas=!1,this._billboardCollection._sdf=!0,this._spareBillboards=[],this._glyphTextureCache={},this._labels=[],this._labelsToUpdate=[],this._totalGlyphCount=0,this._highlightColor=e.Color.clone(e.Color.WHITE),this.show=e.defaultValue(t.show,!0),this.modelMatrix=e.Matrix4.clone(e.defaultValue(t.modelMatrix,e.Matrix4.IDENTITY)),this.debugShowBoundingVolume=e.defaultValue(t.debugShowBoundingVolume,!1),this.blendOption=e.defaultValue(t.blendOption,e.BlendOption.OPAQUE_AND_TRANSLUCENT),this.preloadSDF?this.preload():this.preloaded=!0}Object.defineProperties(sy.prototype,{length:{get:function(){return this._labels.length}}}),sy.prototype.add=function(t){const n=new e.Label(t,this);return this._labels.push(n),this._labelsToUpdate.push(n),n},sy.prototype.remove=function(t){if(e.defined(t)&&t._labelCollection===this){const e=this._labels.indexOf(t);if(-1!==e)return this._labels.splice(e,1),ry(this,t),!0}return!1},sy.prototype.removeAll=function(){const t=this._labels;for(let e=0,n=t.length;e<n;++e)ry(this,t[e]);t.length=0},sy.prototype.contains=function(t){return e.defined(t)&&t._labelCollection===this},sy.prototype.get=function(t){if(!e.defined(t))throw new e.DeveloperError("index is required.");return this._labels[t]},sy.prototype.update=function(t){if(!this.show)return;const n=this._billboardCollection,i=this._backgroundBillboardCollection;n.modelMatrix=this.modelMatrix,n.debugShowBoundingVolume=this.debugShowBoundingVolume,i.modelMatrix=this.modelMatrix,i.debugShowBoundingVolume=this.debugShowBoundingVolume;const r=t.context;e.defined(this._textureAtlas)||(this._textureAtlas=new e.TextureAtlas({context:r}),n.textureAtlas=this._textureAtlas),e.defined(this._backgroundTextureAtlas)||(this._backgroundTextureAtlas=new e.TextureAtlas({context:r,initialSize:Wv}),i.textureAtlas=this._backgroundTextureAtlas,function(t){const e=document.createElement("canvas");e.width=Wv.x,e.height=Wv.y;const n=e.getContext("2d");n.fillStyle="#fff",n.fillRect(0,0,e.width,e.height),t.addImage(Vv,e)}(this._backgroundTextureAtlas));const s=this._labelsToUpdate.length;for(let t=0;t<s;++t){const e=this._labelsToUpdate[t];if(e.isDestroyed())continue;const n=e._glyphs.length;e._rebindAllGlyphs&&(Jv(this,e),e._rebindAllGlyphs=!1),e._repositionAllGlyphs&&(iy(e),e._repositionAllGlyphs=!1);const i=e._glyphs.length-n;this._totalGlyphCount+=i}const o=i.length>0?e.BlendOption.TRANSLUCENT:this.blendOption;n.blendOption=o,i.blendOption=o,n._highlightColor=this._highlightColor,i._highlightColor=this._highlightColor,this._labelsToUpdate.length=0,i.update(t),n.update(t)},sy.prototype.isDestroyed=function(){return!1},sy.prototype.destroy=function(){return this.removeAll(),this._billboardCollection=this._billboardCollection.destroy(),this._textureAtlas=this._textureAtlas&&this._textureAtlas.destroy(),this._backgroundBillboardCollection=this._backgroundBillboardCollection.destroy(),this._backgroundTextureAtlas=this._backgroundTextureAtlas&&this._backgroundTextureAtlas.destroy(),e.destroyObject(this)};const oy=new RegExp(/[\u0000-\u0008\u000E-\u001F\u00ad\u202a-\u206f\u200b-\u200f]/,"g"),ay={};function uy(t,e,n=0,i=t.length-1,r=ly){for(;i>n;){if(i-n>600){const s=i-n+1,o=e-n+1,a=Math.log(s),u=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*u*(s-u)/s)*(o-s/2<0?-1:1);uy(t,e,Math.max(n,Math.floor(e-o*u/s+h)),Math.min(i,Math.floor(e+(s-o)*u/s+h)),r)}const s=t[e];let o=n,a=i;for(hy(t,n,e),r(t[i],s)>0&&hy(t,n,i);o<a;){for(hy(t,o,a),o++,a--;r(t[o],s)<0;)o++;for(;r(t[a],s)>0;)a--}0===r(t[n],s)?hy(t,n,a):(a++,hy(t,a,i)),a<=e&&(n=a+1),e<=a&&(i=a-1)}}function hy(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function ly(t,e){return t<e?-1:t>e?1:0}sy.prototype.computeLabelSize=function(t){const n=`${t.fontSize}:${t.text}`;if(ay[n])return ay[n];e.defined(this._textureAtlas)||(this._textureAtlas=new e.TextureAtlas({context:this._scene.context}),this._billboardCollection.textureAtlas=this._textureAtlas);const i=t.text.replace(oy,""),r=Yv.splitGraphemes(i),s=r.length,o=[];let a,u;o.length=s;const h=this._glyphTextureCache;for(u=0;u<s;++u){const n=r[u],i=t.verticalOrigin,s=JSON.stringify([n,t.fontFamily,t.fontStyle,t.fontWeight,+i]);let l=h[s];if(!e.defined(l)){const r=Kv(n,`${t.fontStyle} ${t.fontWeight} ${e.SDFSettings.FONT_SIZE}px ${t.fontFamily}`,e.Color.WHITE,e.Color.WHITE,0,e.LabelStyle.FILL,i);if(l=new Hv(this,-1,r.dimensions),h[s]=l,r.width>0&&r.height>0){const t=zp(r,{cutoff:e.SDFSettings.CUTOFF,radius:e.SDFSettings.RADIUS}),i=r.getContext("2d"),o=r.width,a=r.height,u=i.getImageData(0,0,o,a);for(let e=0;e<o;e++)for(let n=0;n<a;n++){const i=n*o+e,r=255*t[i],s=4*i;u.data[s+0]=r,u.data[s+1]=r,u.data[s+2]=r,u.data[s+3]=r}i.putImageData(u,0,0)," "!==n&&Zv(this._textureAtlas,s,r,l)}}a=new Lv,o[u]=a,a.textureInfo=l,a.dimensions=l.dimensions}let l,c,f=0,d=0,p=Number.NEGATIVE_INFINITY,v=0,y=1;const m=o.length;for(c=0;c<m;++c)"\n"===i.charAt(c)?(++y,f=0):(a=o[c],l=a.dimensions,v=Math.max(v,l.height-l.descent),p=Math.max(p,l.descent),f+=l.width-l.minx,c<m-1&&(f+=o[c+1].dimensions.minx),d=Math.max(d,f));let w=v+p+(e.defined(t.lineHeight)?t.lineHeight:1.2*t.fontSize)/t.relativeSize*(y-1);const g={width:d*t.totalScale,height:w*t.totalScale};return ay[n]=g,g},sy.prototype.preload=async function(){const t=t=>fetch(t).then((t=>t.json()));try{const[i,r]=await Promise.all([(n=this.preloadSDFTextureUrl,new Promise(((t,e)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>{t(i)},i.onerror=()=>{e()},i.src=n}))),t(this.preloadSDFConfigUrl)]),s=new e.TextureAtlas({context:this._scene.context,initialSize:new e.Cartesian2(r.dimensions.x,r.dimensions.y)}),o=[...r.font];o.unshift("");const a={},u={};Object.keys(r.indexHash).forEach((t=>{o[0]=t;const e=JSON.stringify(o);a[e]=r.indexHash[t],u[e]=Promise.resolve(r.indexHash[t])})),s._indexHash=a,s._idHash=u,s._root=r.root,s._textureCoordinates=r.textureCoordinates.map((t=>new e.BoundingRectangle(t[0],t[1],t[2],t[3])));const h=new e.Texture({context:this._scene.context,width:r.dimensions.x,height:r.dimensions.y,pixelFormat:s._pixelFormat});h.copyFrom({width:r.dimensions.x,height:r.dimensions.y,source:i}),s._texture=h,this._textureAtlas=s,this._billboardCollection._textureAtlas=s,Object.keys(r.glyphTextureCache).forEach((t=>{o[0]=t;const e=JSON.stringify(o),n={width:r.glyphTextureCache[t][0],height:r.glyphTextureCache[t][1],ascent:r.glyphTextureCache[t][2],descent:r.glyphTextureCache[t][3],minx:r.glyphTextureCache[t][4]},i=r.glyphTextureCache[t][5];this._glyphTextureCache[e]=new Hv(this,i,n)})),this.preloaded=!0}catch(t){this._textureAtlas&&this._textureAtlas.destroy(),this._textureAtlas=void 0,this._billboardCollection._textureAtlas=void 0,this._glyphTextureCache={},this.preloaded=!0}var n};class cy{constructor(t=9){this.Od=Math.max(4,t),this.Td=Math.max(2,Math.ceil(.4*this.Od)),this.clear()}all(){return this.zd(this.data,[])}search(t){let e=this.data;const n=[];if(!ky(t,e))return n;const i=this.toBBox,r=[];for(;e;){for(let s=0;s<e.children.length;s++){const o=e.children[s],a=e.leaf?i(o):o;ky(t,a)&&(e.leaf?n.push(o):_y(t,a)?this.zd(o,n):r.push(o))}e=r.pop()}return n}collides(t){let e=this.data;if(!ky(t,e))return!1;const n=[];for(;e;){for(let i=0;i<e.children.length;i++){const r=e.children[i],s=e.leaf?this.toBBox(r):r;if(ky(t,s)){if(e.leaf||_y(t,s))return!0;n.push(r)}}e=n.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this.Td){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this.Dd(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this.Pd(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this.Rd(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this.Rd(t,this.data.height-1),this}clear(){return this.data=$y([]),this}remove(t,e){if(!t)return this;let n=this.data;const i=this.toBBox(t),r=[],s=[];let o,a,u;for(;n||r.length;){if(n||(n=r.pop(),a=r[r.length-1],o=s.pop(),u=!0),n.leaf){const i=fy(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this.Nd(r),this}u||n.leaf||!_y(n,i)?a?(o++,n=a.children[o],u=!1):n=null:(r.push(n),s.push(o),o=0,a=n,n=n.children[0])}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}zd(t,e){const n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}Dd(t,e,n,i){const r=n-e+1;let s,o=this.Od;if(r<=o)return s=$y(t.slice(e,n+1)),dy(s,this.toBBox),s;i||(i=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,i-1))),s=$y([]),s.leaf=!1,s.height=i;const a=Math.ceil(r/o),u=a*Math.ceil(Math.sqrt(o));Sy(t,e,n,u,this.compareMinX);for(let r=e;r<=n;r+=u){const e=Math.min(r+u-1,n);Sy(t,r,e,a,this.compareMinY);for(let n=r;n<=e;n+=a){const r=Math.min(n+a-1,e);s.children.push(this.Dd(t,n,r,i-1))}}return dy(s,this.toBBox),s}Fd(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){let n,i=1/0,r=1/0;for(let s=0;s<e.children.length;s++){const o=e.children[s],a=wy(o),u=by(t,o)-a;u<r?(r=u,i=a<i?a:i,n=o):u===r&&a<i&&(i=a,n=o)}e=n||e.children[0]}return e}Rd(t,e,n){const i=n?t:this.toBBox(t),r=[],s=this.Fd(i,this.data,e,r);for(s.children.push(t),vy(s,i);e>=0&&r[e].children.length>this.Od;)this.Ud(r,e),e--;this.qd(i,r,e)}Ud(t,e){const n=t[e],i=n.children.length,r=this.Td;this.jd(n,r,i);const s=this.Bd(n,r,i),o=$y(n.children.splice(s,n.children.length-s));o.height=n.height,o.leaf=n.leaf,dy(n,this.toBBox),dy(o,this.toBBox),e?t[e-1].children.push(o):this.Pd(n,o)}Pd(t,e){this.data=$y([t,e]),this.data.height=t.height+1,this.data.leaf=!1,dy(this.data,this.toBBox)}Bd(t,e,n){let i,r=1/0,s=1/0;for(let o=e;o<=n-e;o++){const e=py(t,0,o,this.toBBox),a=py(t,o,n,this.toBBox),u=xy(e,a),h=wy(e)+wy(a);u<r?(r=u,i=o,s=h<s?h:s):u===r&&h<s&&(s=h,i=o)}return i||n-e}jd(t,e,n){const i=t.leaf?this.compareMinX:yy,r=t.leaf?this.compareMinY:my;this.Ld(t,e,n,i)<this.Ld(t,e,n,r)&&t.children.sort(i)}Ld(t,e,n,i){t.children.sort(i);const r=this.toBBox,s=py(t,0,e,r),o=py(t,n-e,n,r);let a=gy(s)+gy(o);for(let i=e;i<n-e;i++){const e=t.children[i];vy(s,t.leaf?r(e):e),a+=gy(s)}for(let i=n-e-1;i>=e;i--){const e=t.children[i];vy(o,t.leaf?r(e):e),a+=gy(o)}return a}qd(t,e,n){for(let i=n;i>=0;i--)vy(e[i],t)}Nd(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():dy(t[n],this.toBBox)}}function fy(t,e,n){if(!n)return e.indexOf(t);for(let i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function dy(t,e){py(t,0,t.children.length,e,t)}function py(t,e,n,i,r){r||(r=$y(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=e;s<n;s++){const e=t.children[s];vy(r,t.leaf?i(e):e)}return r}function vy(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function yy(t,e){return t.minX-e.minX}function my(t,e){return t.minY-e.minY}function wy(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function gy(t){return t.maxX-t.minX+(t.maxY-t.minY)}function by(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function xy(t,e){const n=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),s=Math.min(t.maxY,e.maxY);return Math.max(0,r-n)*Math.max(0,s-i)}function _y(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function ky(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function $y(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Sy(t,e,n,i,r){const s=[e,n];for(;s.length;){if((n=s.pop())-(e=s.pop())<=i)continue;const o=e+Math.ceil((n-e)/i/2)*i;uy(t,o,e,n,r),s.push(e,o,o,n)}}var My,Ey,Cy,Ay,Iy,Oy,Ty={},zy=function(){if(My)return Ty;My=1;var t=Ty.Poi={};t.read=function(e,n){return e.readFields(t.Hd,{minzoom:0,maxzoom:0,pos:[],poiid:"",indoorid:"",name:"",rank:0,name_zh:"",name_en:"",name_local:"",local_lang:"",character:[],character_en:[],name_spilt:[],altitude:0},n)},t.Hd=function(t,e,n){1===t?e.minzoom=n.readVarint():2===t?e.maxzoom=n.readVarint():3===t?n.readPackedVarint(e.pos,!0):4===t?e.poiid=n.readString():5===t?e.indoorid=n.readString():6===t?e.name=n.readString():7===t?e.rank=n.readVarint():8===t?e.name_zh=n.readString():9===t?e.name_en=n.readString():10===t?e.name_local=n.readString():11===t?e.local_lang=n.readString():12===t?n.readPackedVarint(e.character):13===t?n.readPackedVarint(e.character_en):14===t?n.readPackedVarint(e.name_spilt):15===t&&(e.altitude=n.readVarint(!0))},t.write=function(t,e){t.minzoom&&e.writeVarintField(1,t.minzoom),t.maxzoom&&e.writeVarintField(2,t.maxzoom),t.pos&&e.writePackedVarint(3,t.pos),t.poiid&&e.writeStringField(4,t.poiid),t.indoorid&&e.writeStringField(5,t.indoorid),t.name&&e.writeStringField(6,t.name),t.rank&&e.writeVarintField(7,t.rank),t.name_zh&&e.writeStringField(8,t.name_zh),t.name_en&&e.writeStringField(9,t.name_en),t.name_local&&e.writeStringField(10,t.name_local),t.local_lang&&e.writeStringField(11,t.local_lang),t.character&&e.writePackedVarint(12,t.character),t.character_en&&e.writePackedVarint(13,t.character_en),t.name_spilt&&e.writePackedVarint(14,t.name_spilt),t.altitude&&e.writeVarintField(15,t.altitude)};var e=Ty.PoiSameStyle={};e.read=function(t,n){return t.readFields(e.Hd,{styleid:"",items:[],resolution:0},n)},e.Hd=function(e,n,i){1===e?n.styleid=i.readString():2===e?n.items.push(t.read(i,i.readVarint()+i.pos)):3===e&&(n.resolution=i.readVarint())},e.write=function(e,n){if(e.styleid&&n.writeStringField(1,e.styleid),e.items)for(var i=0;i<e.items.length;i++)n.writeMessage(2,t.write,e.items[i]);e.resolution&&n.writeVarintField(3,e.resolution)};var n=Ty.PoiLayer={};return n.read=function(t,e){return t.readFields(n.Hd,{poilabel:[]},e)},n.Hd=function(t,n,i){1===t&&n.poilabel.push(e.read(i,i.readVarint()+i.pos))},n.write=function(t,n){if(t.poilabel)for(var i=0;i<t.poilabel.length;i++)n.writeMessage(1,e.write,t.poilabel[i])},Ty}(),Dy=function(){if(Cy)return Ey;Cy=1;const t=2147483648,e=180;function n(t,e){const n=function(t,e,n,s){const o=r(t,e);let a=i(180),u=i(90);const h=a/(1<<o),l=u/(1<<o);return a=h>0?Math.floor(h+.5):Math.floor(h-.5),u=l>0?Math.floor(l+.5):Math.floor(l-.5),[a,u]}(t,e);return[2*n[0],2*n[1]]}function i(n){return Math.floor(n*t/e+.5)}function r(t,e){return 33-e-t}function s(n){return n*e/t}function o(t,e){const i=n(t.z,e),r=i[0],s=i[1],o=1<<t.z;return[-r/2+t.x*r/o,s/2-(t.y+1)*s/o]}function a(e,n,i){const a=o(e,n),u=r(e.z,n);for(var h=[],l=0;l<i.length;l+=2){const e=i[l]+a[0];let n=e<<u;const r=i[l+1]+a[1]<<u;e>0&&n<0&&(n=t-1);const o=s(n),c=s(r);h.push([o,c])}return h}function u(t){for(var e=0,n=2,i=t.length;n<i;n+=2)e+=((t[n]-t[n-2])**2+(t[n+1]-t[n-1])**2)**.5;return e}function h(t,e){for(var n=0,i=0,r=t.length;i<r;i+=2){var s=u(t.slice(i,i+4));if(!(s+n<e)){var o=(e-n)/s;return[Math.round(t[i]+o*(t[i+2]-t[i])),Math.round(t[i+1]+o*(t[i+3]-t[i+1])),i]}n+=s}return null}function l(t,e){e=e/180*Math.PI;let n=0,i=0,r=0;for(var s=2,o=t.length;s<o;s+=2){var a=t[s]-t[s-2],u=t[s+1]-t[s-1],h=(a**2+u**2)**.5;if(2==s)n=a,i=u,r=h;else{if(Math.acos((a*n+u*i)/h/r)>e)return!1;n=a,i=u,r=h}}return!0}return Ey={getWorldSize:n,riseLevel:function(t,e,n,s){var u=function(t,e,n){var s=t.z;const a=o(t,e),u=r(s,e);for(var h=[],l=0;l<n.length;l+=1){var c=n[l][0],f=n[l][1];f<-90&&(f=-90),f>90&&(f=90),c<-180&&(c=-180),c>180&&(c=180);let t=i(c),e=i(f);const r=t/(1<<u),s=e/(1<<u);t=r>0?Math.floor(r+.5):Math.floor(r-.5),e=s>0?Math.floor(s+.5):Math.floor(s-.5),t-=a[0],e-=a[1],h.push(t,e)}return h}(s,n-1,a(e,n,t));return u},ptsLength:u,getSmoothSlice:function(t,e,n){for(var i=function(t,e){var n=[],i=[],r=u(t);if(r>=e){for(var s=Math.floor(r/e),o=1;o<=s;o+=1)n.push(h(t,e*o));var a=[],l=[],c=0,f=void 0;for(o=0;o<n.length;o+=1){f=n[o][2]+2;var d=t.slice(c,f);l=[n[o][0],n[o][1]];for(var p=a.concat(d).concat(l),v=2;v<p.length;v+=2)p[v]===p[v-2]&&p[v+1]===p[v-1]&&(p.splice(v,2),v-=2);i.push(p),a=l,c=f}return i}}(t,e)||[],r=0;r<i.length;r+=1)l(i[r],n)||(i.splice(r,1),r-=1);return i},tileInnerCoords2LngLat:a,tileInnerCoord2LngLat:function(e,n,i,a){const u=o(e,n),h=i+u[0],l=a+u[1],c=r(e.z,n);return i=h<<c,a=l<<c,h>0&&i<0&&(i=t-1),[s(i),s(a)]}},Ey}(),Py={},Ry=function(){if(Oy)return Iy;Oy=1,Iy=e;var t=(Ay||(Ay=1,Py.read=function(t,e,n,i,r){var s,o,a=8*r-i-1,u=(1<<a)-1,h=u>>1,l=-7,c=n?r-1:0,f=n?-1:1,d=t[e+c];for(c+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+t[e+c],c+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=i;l>0;o=256*o+t[e+c],c+=f,l-=8);if(0===s)s=1-h;else{if(s===u)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),s-=h}return(d?-1:1)*o*Math.pow(2,s-i)},Py.write=function(t,e,n,i,r,s){var o,a,u,h=8*s-r-1,l=(1<<h)-1,c=l>>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:s-1,p=i?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+c>=1?f/u:f*Math.pow(2,1-c))*u>=2&&(o++,u/=2),o+c>=l?(a=0,o=l):o+c>=1?(a=(e*u-1)*Math.pow(2,r),o+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,r),o=0));r>=8;t[n+d]=255&a,d+=p,a/=256,r-=8);for(o=o<<r|a,h+=r;h>0;t[n+d]=255&o,d+=p,o/=256,h-=8);t[n+d-p]|=128*v}),Py);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var n=4294967296,i=1/n,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function s(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function o(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,n){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));n.realloc(i);for(var r=n.pos-1;r>=t;r--)n.buf[r+i]=n.buf[r]}function u(t,e){for(var n=0;n<t.length;n++)e.writeVarint(t[n])}function h(t,e){for(var n=0;n<t.length;n++)e.writeSVarint(t[n])}function l(t,e){for(var n=0;n<t.length;n++)e.writeFloat(t[n])}function c(t,e){for(var n=0;n<t.length;n++)e.writeDouble(t[n])}function f(t,e){for(var n=0;n<t.length;n++)e.writeBoolean(t[n])}function d(t,e){for(var n=0;n<t.length;n++)e.writeFixed32(t[n])}function p(t,e){for(var n=0;n<t.length;n++)e.writeSFixed32(t[n])}function v(t,e){for(var n=0;n<t.length;n++)e.writeFixed64(t[n])}function y(t,e){for(var n=0;n<t.length;n++)e.writeSFixed64(t[n])}function m(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function w(t,e,n){t[n]=e,t[n+1]=e>>>8,t[n+2]=e>>>16,t[n+3]=e>>>24}function g(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null},readFields:function(t,e,n){for(n=n||this.length;this.pos<n;){var i=this.readVarint(),r=i>>3,s=this.pos;this.type=7&i,t(r,e,this),this.pos===s&&this.skip(i)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=m(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=m(this.buf,this.pos)+m(this.buf,this.pos+4)*n;return this.pos+=8,t},readSFixed64:function(){var t=m(this.buf,this.pos)+g(this.buf,this.pos+4)*n;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,n,i=this.buf;return e=127&(n=i[this.pos++]),n<128?e:(e|=(127&(n=i[this.pos++]))<<7,n<128?e:(e|=(127&(n=i[this.pos++]))<<14,n<128?e:(e|=(127&(n=i[this.pos++]))<<21,n<128?e:function(t,e,n){var i,r,s=n.buf;if(i=(112&(r=s[n.pos++]))>>4,r<128)return o(t,i,e);if(i|=(127&(r=s[n.pos++]))<<3,r<128)return o(t,i,e);if(i|=(127&(r=s[n.pos++]))<<10,r<128)return o(t,i,e);if(i|=(127&(r=s[n.pos++]))<<17,r<128)return o(t,i,e);if(i|=(127&(r=s[n.pos++]))<<24,r<128)return o(t,i,e);if(i|=(1&(r=s[n.pos++]))<<31,r<128)return o(t,i,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(n=i[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&r?function(t,e,n){return r.decode(t.subarray(e,n))}(this.buf,e,t):function(t,e,n){for(var i="",r=e;r<n;){var s,o,a,u=t[r],h=null,l=u>239?4:u>223?3:u>191?2:1;if(r+l>n)break;1===l?u<128&&(h=u):2===l?128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)<=127&&(h=null):3===l?(s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&((h=(15&u)<<12|(63&s)<<6|63&o)<=2047||h>=55296&&h<=57343)&&(h=null)):4===l&&(s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&((h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)<=65535||h>=1114112)&&(h=null)),null===h?(h=65533,l=1):h>65535&&(h-=65536,i+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),i+=String.fromCharCode(h),r+=l}return i}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,n){if(this.type!==e.Bytes)return t.push(this.readVarint(n));var i=s(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(n));return t},readPackedSVarint:function(t){if(this.type!==e.Bytes)return t.push(this.readSVarint());var n=s(this);for(t=t||[];this.pos<n;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==e.Bytes)return t.push(this.readBoolean());var n=s(this);for(t=t||[];this.pos<n;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==e.Bytes)return t.push(this.readFloat());var n=s(this);for(t=t||[];this.pos<n;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==e.Bytes)return t.push(this.readDouble());var n=s(this);for(t=t||[];this.pos<n;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==e.Bytes)return t.push(this.readFixed32());var n=s(this);for(t=t||[];this.pos<n;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==e.Bytes)return t.push(this.readSFixed32());var n=s(this);for(t=t||[];this.pos<n;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==e.Bytes)return t.push(this.readFixed64());var n=s(this);for(t=t||[];this.pos<n;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==e.Bytes)return t.push(this.readSFixed64());var n=s(this);for(t=t||[];this.pos<n;)t.push(this.readSFixed64());return t},skip:function(t){var n=7&t;if(n===e.Varint)for(;this.buf[this.pos++]>127;);else if(n===e.Bytes)this.pos=this.readVarint()+this.pos;else if(n===e.Fixed32)this.pos+=4;else{if(n!==e.Fixed64)throw new Error("Unimplemented type: "+n);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var n=new Uint8Array(e);n.set(this.buf),this.buf=n,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),w(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),w(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),w(this.buf,-1&t,this.pos),w(this.buf,Math.floor(t*i),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),w(this.buf,-1&t,this.pos),w(this.buf,Math.floor(t*i),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var n,i;if(t>=0?(n=t%4294967296|0,i=t/4294967296|0):(i=~(-t/4294967296),4294967295^(n=~(-t%4294967296))?n=n+1|0:(n=0,i=i+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,n){n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos]=127&t}(n,0,e),function(t,e){var n=(7&t)<<4;e.buf[e.pos++]|=n|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(i,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,n){for(var i,r,s=0;s<e.length;s++){if((i=e.charCodeAt(s))>55295&&i<57344){if(!r){i>56319||s+1===e.length?(t[n++]=239,t[n++]=191,t[n++]=189):r=i;continue}if(i<56320){t[n++]=239,t[n++]=191,t[n++]=189,r=i;continue}i=r-55296<<10|i-56320|65536,r=null}else r&&(t[n++]=239,t[n++]=191,t[n++]=189,r=null);i<128?t[n++]=i:(i<2048?t[n++]=i>>6|192:(i<65536?t[n++]=i>>12|224:(t[n++]=i>>18|240,t[n++]=i>>12&63|128),t[n++]=i>>6&63|128),t[n++]=63&i|128)}return n}(this.buf,t,this.pos);var n=this.pos-e;n>=128&&a(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var n=0;n<e;n++)this.buf[this.pos++]=t[n]},writeRawMessage:function(t,e){this.pos++;var n=this.pos;t(e,this);var i=this.pos-n;i>=128&&a(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i},writeMessage:function(t,n,i){this.writeTag(t,e.Bytes),this.writeRawMessage(n,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,v,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,y,e)},writeBytesField:function(t,n){this.writeTag(t,e.Bytes),this.writeBytes(n)},writeFixed32Field:function(t,n){this.writeTag(t,e.Fixed32),this.writeFixed32(n)},writeSFixed32Field:function(t,n){this.writeTag(t,e.Fixed32),this.writeSFixed32(n)},writeFixed64Field:function(t,n){this.writeTag(t,e.Fixed64),this.writeFixed64(n)},writeSFixed64Field:function(t,n){this.writeTag(t,e.Fixed64),this.writeSFixed64(n)},writeVarintField:function(t,n){this.writeTag(t,e.Varint),this.writeVarint(n)},writeSVarintField:function(t,n){this.writeTag(t,e.Varint),this.writeSVarint(n)},writeStringField:function(t,n){this.writeTag(t,e.Bytes),this.writeString(n)},writeFloatField:function(t,n){this.writeTag(t,e.Fixed32),this.writeFloat(n)},writeDoubleField:function(t,n){this.writeTag(t,e.Fixed64),this.writeDouble(n)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Iy}(),Ny=gf(Ry);class Fy{ro;so="PoiDataSource";oo=!1;ao;uo;ho;_show=!0;lo;_scene;_id=0;We;Vd=1;Wd={};Gd;Ad=0;Qd={};tilesetUrl;tileset;SSE;constructor(t){this.ao=new r.Event,this.uo=new r.Event,this.oo=!1,this.ho=new r.Event,this.ro=new r.EntityCollection,this.lo=new r.EntityCluster,this._scene=t.scene,this.tilesetUrl=t.tileset,this.Gd=this.tilesetUrl.substring(0,this.tilesetUrl.lastIndexOf("/")),this.SSE=t.SSE,this.We=new Hc({Bi:30,qi:this.onDrop})}Kd=!1;onDrop=(t,e)=>{delete this.Wd[t],this.Kd=!0};async loadTileset(){try{const t=await fetch(this.tilesetUrl),e=await t.json();this.tileset=e}catch(t){}}getViewFrustum(){const t=this._scene.camera,e=this.tileset.metadata.enuCenterGCJ02,n=t.frustum.computeCullingVolume(t.positionWC,t.directionWC,t.upWC).planes,i=r.Cartesian3.fromDegrees(...e),s=r.Transforms.eastNorthUpToFixedFrame(i),o=r.Matrix4.inverse(s,new r.Matrix4),a=n.map((t=>{const e=new r.Cartesian3(t.x,t.y,t.z),n=t.w,i=r.Matrix4.multiplyByPointAsVector(o,e,new r.Cartesian3),s=r.Cartesian3.multiplyByScalar(e,-n,new r.Cartesian3),a=r.Matrix4.multiplyByPoint(o,s,new r.Cartesian3),u=-r.Cartesian3.dot(i,a);return new r.Cartesian4(i.x,i.y,i.z,u)}));return new r.CullingVolume(a)}getTileKey(t){return t.coord.join("-")}computeTilesToRender(){if(!this.tileset)return{};const t=this._scene.camera,e=t.frustum.sseDenominator,n=this._scene.context.drawingBufferHeight,{enuCenterGCJ02:i}=this.tileset.metadata,s=this.getViewFrustum(),o=this.tileset.root,a=Tc(t.position,i),u=t=>{const e=new r.Cartesian3(t[0],t[1],t[2]),n=new r.Cartesian3(t[0]-t[3],t[1]-t[7],t[2]-t[11]),i=new r.Cartesian3(t[0]+t[3],t[1]-t[7],t[2]-t[11]),s=new r.Cartesian3(t[0]-t[3],t[1]+t[7],t[2]-t[11]),o=new r.Cartesian3(t[0]+t[3],t[1]+t[7],t[2]-t[11]);return Math.min(r.Cartesian3.distance(a,e),r.Cartesian3.distance(a,n),r.Cartesian3.distance(a,i),r.Cartesian3.distance(a,s),r.Cartesian3.distance(a,o))},h={},l={},c=[o];for(;c.length;){let t=c.length;for(let i=0;i<t;i++){const t=c.shift(),i=t.boundingVolume.box,a=new r.Cartesian3(i[0]-i[3],i[1]-i[7],i[2]-i[11]),f=new r.Cartesian3(i[0]+i[3],i[1]+i[7],i[2]+i[11]),d=new r.AxisAlignedBoundingBox(a,f);if(s.computeVisibility(d)!==r.Intersect.OUTSIDE){const r=u(i),s=t.geometricError*n/(r*e),a=t.children.length>0;if(t===o||s>this.SSE&&a){let e;if(t.coord){const n=t.content.uri,i=n.startsWith("http")?n:this.Gd+"/"+n,r=this.getTileKey(t);h[r]=i,l[r]&&delete h[l[r]],e=r}for(let n=0;n<t.children.length;n++)c.push(t.children[n]),e&&(l[this.getTileKey(t.children[n])]=e)}else if(t.coord){const e=t.content.uri,n=e.startsWith("http")?e:this.Gd+"/"+e,i=this.getTileKey(t);h[i]=n,l[i]&&delete h[l[i]]}}}}return h}get name(){return this.so}clock=null;get entities(){return this.ro}get isLoading(){return this.oo}get changedEvent(){return this.ao}get errorEvent(){return this.uo}get loadingEvent(){return this.ho}get show(){return this._show}set show(t){this._show=t}get clustering(){return this.lo}set clustering(t){if(!r.defined(t))throw new r.DeveloperError("value must be defined.");this.lo=t}update(){const t=Date.now();if(t-this.Ad<1e3)return!0;if(this.Ad=t,!this.tileset&&2!==this.Vd)return this.loadTileset(),!0;const e=this.computeTilesToRender(),n=this.tileChanged(this.Qd,e);if(this.Qd=e,!n&&!this.Kd)return!0;this.Kd=!1;const i=Object.keys(e);for(let t=0;t<i.length;t++){const n=i[t];this.We.rr(n)||2===this.Wd[n]||this.fetchTile(n,e[n])}return!0}tileChanged(t,e){const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!0;for(let t=0;t<n.length;t++)if(!e[n[t]])return!0;return!1}async fetchTile(t,e){try{this.Wd[t]=2;const n=await fetch(e),i=await n.arrayBuffer(),s=new Ny(i),o=zy.PoiLayer.read(s),a=t.split("-").map((t=>parseInt(t,10))),u={z:a[0],x:a[1],y:a[2]};let h=[];for(let t=0;t<o.poilabel.length;t++){const e=o.poilabel[t],n=[];e.items.forEach((t=>{n.push(t.pos[0],t.pos[1])}));const i=Dy.tileInnerCoords2LngLat(u,e.resolution,n);e.items.forEach(((t,n)=>{h.push({position:r.Cartesian3.fromDegrees(i[n][0],i[n][1],t.altitude),name:t.name,rank:t.rank,poiid:t.poiid,minzoom:t.minzoom,maxzoom:t.maxzoom,id:++this._id,coord:[u.z,u.x,u.y],styleId:e.styleid,type:"poi"})}))}this.We.nr(t,h),this.Wd[t]=3,this.changedEvent.raiseEvent(t)}catch(e){this.Wd[t]=4}}getData(){const t=this.Qd,e=Object.keys(t);let n=[];for(let t=0;t<e.length;t++){const i=this.We.Ji(e[t],!1);i&&(n=n.concat(i))}return n.sort(((t,e)=>t.rank!=e.rank?t.rank<e.rank:t.coord[0]!=e.coord[0]?t.coord[0]>e.coord[0]:t.id<e.id)),n}}var Uy,qy={},jy=function(){if(Uy)return qy;Uy=1;var t=qy.Road={};t.read=function(e,n){return e.readFields(t.Hd,{minzoom:0,maxzoom:0,path:[],shield:"",shieldType:0,name:"",rank:0,name_zh:"",name_en:"",name_local:"",local_lang:"",character:[],id:0},n)},t.Hd=function(t,e,n){1===t?e.minzoom=n.readVarint():2===t?e.maxzoom=n.readVarint():3===t?n.readPackedVarint(e.path,!0):4===t?e.shield=n.readString():5===t?e.shieldType=n.readVarint():6===t?e.name=n.readString():7===t?e.rank=n.readVarint():8===t?e.name_zh=n.readString():9===t?e.name_en=n.readString():10===t?e.name_local=n.readString():11===t?e.local_lang=n.readString():12===t?n.readPackedVarint(e.character):13===t&&(e.id=n.readVarint())},t.write=function(t,e){t.minzoom&&e.writeVarintField(1,t.minzoom),t.maxzoom&&e.writeVarintField(2,t.maxzoom),t.path&&e.writePackedVarint(3,t.path),t.shield&&e.writeStringField(4,t.shield),t.shieldType&&e.writeVarintField(5,t.shieldType),t.name&&e.writeStringField(6,t.name),t.rank&&e.writeVarintField(7,t.rank),t.name_zh&&e.writeStringField(8,t.name_zh),t.name_en&&e.writeStringField(9,t.name_en),t.name_local&&e.writeStringField(10,t.name_local),t.local_lang&&e.writeStringField(11,t.local_lang),t.character&&e.writePackedVarint(12,t.character),t.id&&e.writeVarintField(13,t.id)};var e=qy.RoadSameStyle={};e.read=function(t,n){return t.readFields(e.Hd,{styleid:"",items:[],resolution:0},n)},e.Hd=function(e,n,i){1===e?n.styleid=i.readString():2===e?n.items.push(t.read(i,i.readVarint()+i.pos)):3===e&&(n.resolution=i.readVarint())},e.write=function(e,n){if(e.styleid&&n.writeStringField(1,e.styleid),e.items)for(var i=0;i<e.items.length;i++)n.writeMessage(2,t.write,e.items[i]);e.resolution&&n.writeVarintField(3,e.resolution)};var n=qy.RoadLayer={};return n.read=function(t,e){return t.readFields(n.Hd,{road:[]},e)},n.Hd=function(t,n,i){1===t&&n.road.push(e.read(i,i.readVarint()+i.pos))},n.write=function(t,n){if(t.road)for(var i=0;i<t.road.length;i++)n.writeMessage(1,e.write,t.road[i])},qy}();class By{ro;so="RoadDataSource";oo=!1;ao;uo;ho;_show=!0;lo;_scene;_id=0;We;Vd=1;Wd={};Gd;Ad=0;Qd={};tilesetUrl;tileset;SSE;constructor(t){this.ao=new r.Event,this.uo=new r.Event,this.oo=!1,this.ho=new r.Event,this.ro=new r.EntityCollection,this.lo=new r.EntityCluster,this._scene=t.scene,this.tilesetUrl=t.tileset,this.Gd=this.tilesetUrl.substring(0,this.tilesetUrl.lastIndexOf("/")),this.SSE=t.SSE,this.We=new Hc({Bi:30,qi:this.onDrop})}Kd=!1;onDrop=(t,e)=>{delete this.Wd[t],this.Kd=!0};async loadTileset(){try{const t=await fetch(this.tilesetUrl),e=await t.json();this.tileset=e}catch(t){}}getViewFrustum(){const t=this._scene.camera,e=this.tileset.metadata.enuCenterGCJ02,n=t.frustum.computeCullingVolume(t.positionWC,t.directionWC,t.upWC).planes,i=r.Cartesian3.fromDegrees(...e),s=r.Transforms.eastNorthUpToFixedFrame(i),o=r.Matrix4.inverse(s,new r.Matrix4),a=n.map((t=>{const e=new r.Cartesian3(t.x,t.y,t.z),n=t.w,i=r.Matrix4.multiplyByPointAsVector(o,e,new r.Cartesian3),s=r.Cartesian3.multiplyByScalar(e,-n,new r.Cartesian3),a=r.Matrix4.multiplyByPoint(o,s,new r.Cartesian3),u=-r.Cartesian3.dot(i,a);return new r.Cartesian4(i.x,i.y,i.z,u)}));return new r.CullingVolume(a)}getTileKey(t){return t.coord.join("-")}computeTilesToRender(){if(!this.tileset)return{};const t=this._scene.camera,e=t.frustum.sseDenominator,n=this._scene.context.drawingBufferHeight,{enuCenterGCJ02:i}=this.tileset.metadata,s=this.getViewFrustum(),o=this.tileset.root,a=Tc(t.position,i),u=t=>{const e=new r.Cartesian3(t[0],t[1],t[2]),n=new r.Cartesian3(t[0]-t[3],t[1]-t[7],t[2]-t[11]),i=new r.Cartesian3(t[0]+t[3],t[1]-t[7],t[2]-t[11]),s=new r.Cartesian3(t[0]-t[3],t[1]+t[7],t[2]-t[11]),o=new r.Cartesian3(t[0]+t[3],t[1]+t[7],t[2]-t[11]);return Math.min(r.Cartesian3.distance(a,e),r.Cartesian3.distance(a,n),r.Cartesian3.distance(a,i),r.Cartesian3.distance(a,s),r.Cartesian3.distance(a,o))},h={},l={},c=[o];for(;c.length;){let t=c.length;for(let i=0;i<t;i++){const t=c.shift(),i=t.boundingVolume.box,a=new r.Cartesian3(i[0]-i[3],i[1]-i[7],i[2]-i[11]),f=new r.Cartesian3(i[0]+i[3],i[1]+i[7],i[2]+i[11]),d=new r.AxisAlignedBoundingBox(a,f);if(s.computeVisibility(d)!==r.Intersect.OUTSIDE){const r=u(i),s=t.geometricError*n/(r*e),a=t.children.length>0;if(t===o||s>this.SSE&&a){let e;if(t.coord){const n=t.content.uri,i=n.startsWith("http")?n:this.Gd+"/"+n,r=this.getTileKey(t);h[r]=i,l[r]&&delete l[r],e=r}for(let n=0;n<t.children.length;n++)c.push(t.children[n]),e&&(l[this.getTileKey(t.children[n])]=e)}else if(t.coord){const e=t.content.uri,n=e.startsWith("http")?e:this.Gd+"/"+e,i=this.getTileKey(t);h[i]=n,l[i]&&delete l[i]}}}}return h}get name(){return this.so}clock=null;get entities(){return this.ro}get isLoading(){return this.oo}get changedEvent(){return this.ao}get errorEvent(){return this.uo}get loadingEvent(){return this.ho}get show(){return this._show}set show(t){this._show=t}get clustering(){return this.lo}set clustering(t){if(!r.defined(t))throw new r.DeveloperError("value must be defined.");this.lo=t}update(){const t=Date.now();if(t-this.Ad<1e3)return!0;if(this.Ad=t,!this.tileset&&2!==this.Vd)return this.loadTileset(),!0;const e=this.computeTilesToRender(),n=this.tileChanged(this.Qd,e);if(this.Qd=e,!n&&!this.Kd)return!0;this.Kd=!1;const i=Object.keys(e);for(let t=0;t<i.length;t++){const n=i[t];this.We.rr(n)||2===this.Wd[n]||this.fetchTile(n,e[n])}return!0}tileChanged(t,e){const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!0;for(let t=0;t<n.length;t++)if(!e[n[t]])return!0;return!1}async fetchTile(t,n){try{this.Wd[t]=2;const i=await fetch(n),r=await i.arrayBuffer(),s=new Ny(r),o=jy.RoadLayer.read(s),a=t.split("-").map((t=>parseInt(t,10))),u={z:a[0],x:a[1],y:a[2]};let h=[];for(let t=0;t<o.road.length;t++){const n=o.road[t],{resolution:i,styleid:r,items:s}=n;if(20015!==parseInt(r.split(":")[0],10))for(let t=0;t<s.length;t++){const n=s[t];if(!(n.path.length<6))if(n.shield){const{rank:t,minzoom:r,maxzoom:s,shield:o,shieldType:a,path:l}=n,c=[l[0],l[1],l[2]],f=Dy.tileInnerCoords2LngLat(u,i,[c[0],c[1]])[0],d={coord:u,name:o,styleId:`40001:${a}`,rank:t,minzoom:r,maxzoom:s,position:e.Cartesian3.fromDegrees(f[0],f[1],c[2]),id:++this._id,type:"road",subType:"guideboard"};h.push(d)}else if(n.name){const{rank:t,minzoom:s,maxzoom:o,path:a,name:l}=n,c=a.length/3,f=[];for(let t=0;t<c;t+=1)f.push(a[3*t],a[3*t+1]);const d=Dy.tileInnerCoords2LngLat(u,i,f);for(let t=0;t<c;t+=1)d[t].push(a[3*t+2]);let p=d[0],v=d[c-1];const y=e.Cartesian3.fromDegrees(p[0],p[1],p[2]),m=e.Cartesian3.fromDegrees(v[0],v[1],v[2]);let w,g,b;if(e.Cartesian3.distance(y,m)>100){if(c>2){let t,n,i=0,r=-1/0;for(let s=0;s<d.length-1;s++){const o=Math.max(d[s][2],d[s+1][2]);t=e.Cartesian3.fromDegrees(d[s][0],d[s][1],o),n=e.Cartesian3.fromDegrees(d[s+1][0],d[s+1][1],o);const a=e.Cartesian3.distance(t,n);a>r&&(r=a,i=s,w=t,g=n)}b=e.Cartesian3.midpoint(w,g,new e.Cartesian3)}else{const t=Math.max(p[2],v[2]);w=e.Cartesian3.fromDegrees(p[0],p[1],t),g=e.Cartesian3.fromDegrees(v[0],v[1],t),b=e.Cartesian3.midpoint(w,g,new e.Cartesian3)}const n=e.Cartesian3.subtract(g,w,new e.Cartesian3),i=e.Cartesian3.magnitude(n);let a;const f=1e4;a=i<f?new e.Cartesian3(w.x+f/i*n.x,w.y+f/i*n.y,w.z+f/i*n.z):g;const y={coord:u,name:l,styleId:r,rank:t,minzoom:s,maxzoom:o,position:b,start:w,end:a,id:++this._id,type:"road",subType:"roadname",path:d};h.push(y)}}}}this.We.nr(t,h),this.Wd[t]=3,this.changedEvent.raiseEvent(t)}catch(e){this.Wd[t]=4}}getData(){const t=this.Qd,e=Object.keys(t);let n=[];for(let t=0;t<e.length;t++){const i=this.We.Ji(e[t],!1);i&&(n=n.concat(i))}return n.sort(((t,e)=>t.rank!=e.rank?t.rank<e.rank:t.coord[0]!=e.coord[0]?t.coord[0]>e.coord[0]:t.id<e.id)),n}}var Ly,Hy,Vy,Wy=function(){if(Hy)return Ly;Hy=1;var t=/^\s+|\s+$/g,e=/^[-+]0x[0-9a-f]+$/i,n=/^0b[01]+$/i,i=/^0o[0-7]+$/i,r=parseInt,s="object"==typeof wf&&wf&&wf.Object===Object&&wf,o="object"==typeof self&&self&&self.Object===Object&&self,a=s||o||Function("","return this")(),u={}.toString,h=Math.max,l=Math.min,c=function(){return a.Date.now()};function f(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function d(s){if("number"==typeof s)return s;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==u.call(t)}(s))return NaN;if(f(s)){var o="function"==typeof s.valueOf?s.valueOf():s;s=f(o)?o+"":o}if("string"!=typeof s)return 0===s?s:+s;s=s.replace(t,"");var a=n.test(s);return a||i.test(s)?r(s.slice(2),a?2:8):e.test(s)?NaN:+s}return Ly=function(t,e,n){var i,r,s,o,a,u,p=0,v=!1,y=!1,m=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function w(e){var n=i,s=r;return i=r=void 0,p=e,o=t.apply(s,n)}function g(t){var n=t-u;return void 0===u||n>=e||n<0||y&&t-p>=s}function b(){var t=c();if(g(t))return x(t);a=setTimeout(b,function(t){var n=e-(t-u);return y?l(n,s-(t-p)):n}(t))}function x(t){return a=void 0,m&&i?w(t):(i=r=void 0,o)}function _(){var t=c(),n=g(t);if(i=arguments,r=this,u=t,n){if(void 0===a)return function(t){return p=t,a=setTimeout(b,e),v?w(t):o}(u);if(y)return a=setTimeout(b,e),w(u)}return void 0===a&&(a=setTimeout(b,e)),o}return e=d(e)||0,f(n)&&(v=!!n.leading,s=(y="maxWait"in n)?h(d(n.maxWait)||0,e):s,m="trailing"in n?!!n.trailing:m),_.cancel=function(){void 0!==a&&clearTimeout(a),p=0,i=u=r=a=void 0},_.flush=function(){return void 0===a?o:x(c())},_},Ly}(),Gy=gf(Wy),Qy={exports:{}},Ky=(Vy||(Vy=1,function(t){!function(){function e(t,e){document.addEventListener?t.addEventListener("scroll",e,!1):t.attachEvent("scroll",e)}function n(t){this.g=document.createElement("div"),this.g.setAttribute("aria-hidden","true"),this.g.appendChild(document.createTextNode(t)),this.h=document.createElement("span"),this.i=document.createElement("span"),this.m=document.createElement("span"),this.j=document.createElement("span"),this.l=-1,this.h.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.i.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.j.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.m.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;",this.h.appendChild(this.m),this.i.appendChild(this.j),this.g.appendChild(this.h),this.g.appendChild(this.i)}function i(t,e){t.g.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;white-space:nowrap;font-synthesis:none;font:"+e+";"}function r(t){var e=t.g.offsetWidth,n=e+100;return t.j.style.width=n+"px",t.i.scrollLeft=n,t.h.scrollLeft=t.h.scrollWidth+100,t.l!==e&&(t.l=e,!0)}function s(t,n){function i(){var t=s;r(t)&&null!==t.g.parentNode&&n(t.l)}var s=t;e(t.h,i),e(t.i,i),r(t)}function o(t,e,n){e=e||{},n=n||window,this.family=t,this.style=e.style||"normal",this.weight=e.weight||"normal",this.stretch=e.stretch||"normal",this.context=n}var a=null,u=null,h=null,l=null;function c(t){return null===l&&(l=!!t.document.fonts),l}function f(t,e){var n=t.style,i=t.weight;if(null===h){var r=document.createElement("div");try{r.style.font="condensed 100px sans-serif"}catch(t){}h=""!==r.style.font}return[n,i,h?t.stretch:"","100px",e].join(" ")}o.prototype.load=function(t,e){var r=this,o=t||"BESbswy",h=0,l=e||3e3,d=(new Date).getTime();return new Promise((function(t,e){if(c(r.context)&&!function(t){return null===u&&(c(t)&&/Apple/.test(window.navigator.vendor)?(t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))(?:\.([0-9]+))/.exec(window.navigator.userAgent),u=!!t&&603>parseInt(t[1],10)):u=!1),u}(r.context)){var p=new Promise((function(t,e){!function n(){(new Date).getTime()-d>=l?e(Error(l+"ms timeout exceeded")):r.context.document.fonts.load(f(r,'"'+r.family+'"'),o).then((function(e){1<=e.length?t():setTimeout(n,25)}),e)}()})),v=new Promise((function(t,e){h=setTimeout((function(){e(Error(l+"ms timeout exceeded"))}),l)}));Promise.race([v,p]).then((function(){clearTimeout(h),t(r)}),e)}else!function(t){document.body?t():document.addEventListener?document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e),t()})):document.attachEvent("onreadystatechange",(function e(){"interactive"!=document.readyState&&"complete"!=document.readyState||(document.detachEvent("onreadystatechange",e),t())}))}((function(){function u(){var e;(e=-1!=y&&-1!=m||-1!=y&&-1!=w||-1!=m&&-1!=w)&&((e=y!=m&&y!=w&&m!=w)||(null===a&&(e=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent),a=!!e&&(536>parseInt(e[1],10)||536===parseInt(e[1],10)&&11>=parseInt(e[2],10))),e=a&&(y==g&&m==g&&w==g||y==b&&m==b&&w==b||y==x&&m==x&&w==x)),e=!e),e&&(null!==_.parentNode&&_.parentNode.removeChild(_),clearTimeout(h),t(r))}var c=new n(o),p=new n(o),v=new n(o),y=-1,m=-1,w=-1,g=-1,b=-1,x=-1,_=document.createElement("div");_.dir="ltr",i(c,f(r,"sans-serif")),i(p,f(r,"serif")),i(v,f(r,"monospace")),_.appendChild(c.g),_.appendChild(p.g),_.appendChild(v.g),r.context.document.body.appendChild(_),g=c.g.offsetWidth,b=p.g.offsetWidth,x=v.g.offsetWidth,function t(){if((new Date).getTime()-d>=l)null!==_.parentNode&&_.parentNode.removeChild(_),e(Error(l+"ms timeout exceeded"));else{var n=r.context.document.hidden;!0!==n&&void 0!==n||(y=c.g.offsetWidth,m=p.g.offsetWidth,w=v.g.offsetWidth,u()),h=setTimeout(t,50)}}(),s(c,(function(t){y=t,u()})),i(c,f(r,'"'+r.family+'",sans-serif')),s(p,(function(t){m=t,u()})),i(p,f(r,'"'+r.family+'",serif')),s(v,(function(t){w=t,u()})),i(v,f(r,'"'+r.family+'",monospace'))}))}))},t.exports=o}()}(Qy)),Qy.exports),Xy=gf(Ky);class Zy{Ln;_scene;_labels;Xd;Zd;Yd;Jd={};tp={};disableDepthTestDistance=2e3;fontSize="20";fontFamily="AlibabaPuHuiTi";styleUrl="https://amappc.oss-cn-zhangjiakou.aliyuncs.com/gis/static/3dgs/cesiumjs-sdk/dist/style.json";styles=null;fontStyle="normal";fontWeight="800";iconSize=24;iconTextSpacing=4;lineHeight=void 0;ep;tileset;np=200;ye=!1;ip=[];rp=12e4;sp=!1;op=1e3;collisionBuffer=new r.Cartesian2(20,20);ap=0;set SSE(t){this.np=t,this.poiDataSource.SSE=this.np,this.roadDataSource.SSE=this.np}get SSE(){return this.np}poiDataSource;roadDataSource;_dirty=!0;hp=new r.Cartesian3(0,0,0);lp=new r.Cartesian3(0,0,0);preloadSDF=!0;preloadSDFTextureUrl="https://amappc.oss-cn-zhangjiakou.aliyuncs.com/gis/static/3dgs/cesiumjs-sdk/AlibabaPuHuiTi-2-55-Regular/SDF.png";preloadSDFConfigUrl="https://amappc.oss-cn-zhangjiakou.aliyuncs.com/gis/static/3dgs/cesiumjs-sdk/AlibabaPuHuiTi-2-55-Regular/SDF.json";constructor(t){this.ep=new cy,this.preloadSDF=!1!==t.preloadSDF,this._labels=new sy({blendOption:e.BlendOption.TRANSLUCENT,scene:t.viewer.scene,preloadSDF:this.preloadSDF,preloadSDFTextureUrl:this.preloadSDFTextureUrl,preloadSDFConfigUrl:this.preloadSDFConfigUrl}),this.Zd=new sy({blendOption:e.BlendOption.TRANSLUCENT,scene:t.viewer.scene,reuseBillboards:!1}),this.Xd=new iv({blendOption:e.BlendOption.TRANSLUCENT}),this.Yd=new iv({blendOption:e.BlendOption.TRANSLUCENT}),this.Ln=t.viewer,this._scene=t.viewer.scene,this.poiDataSource=new Fy({scene:this._scene,tileset:t.poiTileset,SSE:this.SSE}),this.roadDataSource=new By({scene:this._scene,tileset:t.roadTileset,SSE:this.SSE}),this.Ln.dataSources.add(this.poiDataSource),this.Ln.dataSources.add(this.roadDataSource),this.onData=Gy(this.onData,500,{maxWait:1e3}),this.poiDataSource.changedEvent.addEventListener(this.onData),this.roadDataSource.changedEvent.addEventListener(this.onData),this.cp(),this.fp(),this.Ln.camera.moveEnd.addEventListener(this.requestRender)}set show(t){this._labels.show=!!t,this.Zd.show=!!t,this.Xd.show=!!t,this.Yd.show=!!t}get show(){return this._labels.show}onData=()=>{this.ye||(this._dirty=!0,this.requestRender())};update(t){if(!this.styles||!this.show||!this.sp)return;if(!this._labels.preloaded)return;const e=this._scene.camera.position.clone(),{heading:n,pitch:i,roll:s}=this._scene.camera,o=new r.Cartesian3(n,i,s),a=r.Cartesian3.distance(e,this.hp)<1&&r.Cartesian3.equalsEpsilon(o,this.lp,Math.PI/180),u=Date.now();if(u-this.ap>this.op&&(!a||this._dirty)){this.ap=u,this.hp=e,this.lp=o,this._dirty=!1;let t=this.poiDataSource.getData();this.ip.length&&(t=[].concat(this.ip).concat(t));const n=this.roadDataSource.getData(),i=this.computeItemsToRender(t,n),{pois:r,roads:s}=i;this.updateRoads(this.tp,s),this.updatePois(this.Jd,r)}this.Yd.update(t),this.Zd.update(t),this.Xd.update(t),this._labels.update(t)}isDestroyed(){return this.ye}destroy(){this._labels.destroy(),this.Xd.destroy(),this.Zd.destroy(),this.Yd.destroy(),this.Jd={},this.tp={},this.poiDataSource.changedEvent.removeEventListener(this.onData),this.roadDataSource.changedEvent.removeEventListener(this.onData),this.ye=!0,this.Ln.camera.moveEnd.removeEventListener(this.requestRender),this.requestRender()}addPoi(t){const n=`${Math.min(Math.floor(this.getZoom()),20)}:${t.styleId}`,i={...this.styles[n]};if(i)if(0===i.layout){const e=this.iconSize*i.transform[0],n=this.iconSize*i.transform[1],s=this.getIconUrl(i.file),o=this.Xd.add({position:t.position,image:s,horizontalOrigin:r.HorizontalOrigin.CENTER,verticalOrigin:r.VerticalOrigin.CENTER,width:e,height:n,disableDepthTestDistance:this.disableDepthTestDistance});this.Jd[t.id]={icon:o}}else if(1===i.layout){const n=t.name,s={text:n,fontStyle:this.fontStyle,fontWeight:this.fontWeight,fontSize:`${i.size}`,fontFamily:this.fontFamily,verticalOrigin:e.VerticalOrigin.TOP,totalScale:i.size/e.SDFSettings.FONT_SIZE,relativeSize:i.size/e.SDFSettings.FONT_SIZE},o=this._labels.computeLabelSize(s),a=new e.Cartesian2(-o.width/2,-o.height/2),u=this.lineHeight?`/${this.lineHeight}px`:"",h=`${this.fontStyle} ${this.fontWeight} ${i.size}px${u} ${this.fontFamily}`,l=this._labels.add({position:t.position,text:n,font:h,horizontalOrigin:r.HorizontalOrigin.LEFT,verticalOrigin:r.VerticalOrigin.TOP,fillColor:r.Color.fromCssColorString(i.fill),style:r.LabelStyle.FILL_AND_OUTLINE,disableDepthTestDistance:this.disableDepthTestDistance,outlineColor:r.Color.fromCssColorString(i.haloFill),outlineWidth:i.haloRadius,pixelOffset:a});this.Jd[t.id]={label:l}}else if(2===i.layout){const n=t.name,s=this.iconSize*i.transform[0],o=this.iconSize*i.transform[1],a=this.getIconUrl(i.file),u=this.Xd.add({position:t.position,image:a,horizontalOrigin:r.HorizontalOrigin.CENTER,verticalOrigin:r.VerticalOrigin.CENTER,width:s,height:o,disableDepthTestDistance:this.disableDepthTestDistance,pixelOffset:new r.Cartesian2(0,i.shieldDy)}),h={text:n,fontStyle:this.fontStyle,fontWeight:this.fontWeight,fontSize:`${i.size}`,fontFamily:this.fontFamily,verticalOrigin:e.VerticalOrigin.TOP,totalScale:i.size/e.SDFSettings.FONT_SIZE,relativeSize:i.size/e.SDFSettings.FONT_SIZE},l=this._labels.computeLabelSize(h),c=new e.Cartesian2(-l.width/2,-l.height/2),f=this.lineHeight?`/${this.lineHeight}px`:"",d=`${this.fontStyle} ${this.fontWeight} ${i.size}px${f} ${this.fontFamily}`,p=this._labels.add({position:t.position,text:n,font:d,horizontalOrigin:r.HorizontalOrigin.LEFT,verticalOrigin:r.VerticalOrigin.TOP,fillColor:r.Color.fromCssColorString(i.fill),style:r.LabelStyle.FILL_AND_OUTLINE,disableDepthTestDistance:this.disableDepthTestDistance,outlineColor:r.Color.fromCssColorString(i.haloFill),outlineWidth:i.haloRadius,pixelOffset:c});this.Jd[t.id]={icon:u,label:p}}else if(3===i.layout){const n=t.name,s=this.iconSize*i.transform[0],o=this.iconSize*i.transform[1],a=this.getIconUrl(i.file),u=this.Xd.add({position:t.position,image:a,horizontalOrigin:r.HorizontalOrigin.CENTER,verticalOrigin:r.VerticalOrigin.CENTER,width:s,height:o,disableDepthTestDistance:t.external?1/0:this.disableDepthTestDistance,pixelOffset:new r.Cartesian2(0,i.shieldDy)}),h={text:n,fontStyle:this.fontStyle,fontWeight:this.fontWeight,fontSize:`${i.size}`,fontFamily:this.fontFamily,verticalOrigin:e.VerticalOrigin.TOP,totalScale:i.size/e.SDFSettings.FONT_SIZE,relativeSize:i.size/e.SDFSettings.FONT_SIZE},l=this._labels.computeLabelSize(h),c=new e.Cartesian2(s/2+this.iconTextSpacing,i.shieldDy-l.height/2),f=this.lineHeight?`/${this.lineHeight}px`:"",d=`${this.fontStyle} ${this.fontWeight} ${i.size}px${f} ${this.fontFamily}`,p=this._labels.add({position:t.position,text:n,font:d,horizontalOrigin:r.HorizontalOrigin.LEFT,verticalOrigin:r.VerticalOrigin.TOP,fillColor:r.Color.fromCssColorString(i.fill),style:r.LabelStyle.FILL_AND_OUTLINE,disableDepthTestDistance:t.external?1/0:this.disableDepthTestDistance,outlineColor:r.Color.fromCssColorString(i.haloFill),outlineWidth:i.haloRadius,pixelOffset:c});this.Jd[t.id]={icon:u,label:p}}}addRoad(t){const n=`${Math.min(Math.floor(this.getZoom()),20)}:${t.styleId}`,i=this.styles[n];if(!i)return;const s=t.subType;if("roadname"===s){const n=t.name,s={text:n,fontStyle:this.fontStyle,fontWeight:this.fontWeight,fontSize:`${i.size}`,fontFamily:this.fontFamily,verticalOrigin:e.VerticalOrigin.TOP,totalScale:i.size/e.SDFSettings.FONT_SIZE,relativeSize:i.size/e.SDFSettings.FONT_SIZE},o=this._labels.computeLabelSize(s),a=new e.Cartesian2(-o.width/2,-o.height/2),u=this.lineHeight?`/${this.lineHeight}px`:"",h=`${this.fontStyle} ${this.fontWeight} ${i.size}px${u} ${this.fontFamily}`,l=this.Zd.add({position:t.position,text:n,font:h,horizontalOrigin:r.HorizontalOrigin.LEFT,verticalOrigin:r.VerticalOrigin.TOP,fillColor:r.Color.fromCssColorString(i.fill),style:r.LabelStyle.FILL_AND_OUTLINE,disableDepthTestDistance:this.disableDepthTestDistance,outlineColor:r.Color.fromCssColorString(i.haloFill),outlineWidth:i.haloRadius,pixelOffset:a});l.roadDirection=new r.Cartesian4(t.end.x-t.position.x,t.end.y-t.position.y,t.end.z-t.position.z,1),this.tp[t.id]={label:l}}else if("guideboard"===s){const n=t.name,s=this.iconSize*i.transform[0],o=this.iconSize*i.transform[1],a=this.getIconUrl(i.file),u=this.Yd.add({position:t.position,image:a,horizontalOrigin:r.HorizontalOrigin.CENTER,verticalOrigin:r.VerticalOrigin.CENTER,width:s,height:o,disableDepthTestDistance:this.disableDepthTestDistance}),h={text:n,fontStyle:this.fontStyle,fontWeight:this.fontWeight,fontSize:`${i.size}`,fontFamily:this.fontFamily,verticalOrigin:e.VerticalOrigin.TOP,totalScale:i.size/e.SDFSettings.FONT_SIZE,relativeSize:i.size/e.SDFSettings.FONT_SIZE},l=this._labels.computeLabelSize(h),c=new e.Cartesian2(-l.width/2,-l.height/2),f=this.lineHeight?`/${this.lineHeight}px`:"",d=`${this.fontStyle} ${this.fontWeight} ${i.size}px${f} ${this.fontFamily}`,p=this.Zd.add({position:t.position,text:n,font:d,horizontalOrigin:r.HorizontalOrigin.LEFT,verticalOrigin:r.VerticalOrigin.TOP,fillColor:r.Color.fromCssColorString(i.fill),style:r.LabelStyle.FILL_AND_OUTLINE,disableDepthTestDistance:this.disableDepthTestDistance,outlineColor:r.Color.fromCssColorString(i.haloFill),outlineWidth:i.haloRadius,pixelOffset:c});this.tp[t.id]={icon:u,label:p}}}getIconUrl(t){return"https://amappc.oss-cn-zhangjiakou.aliyuncs.com/gis/static/3dgs/cesiumjs-sdk"+t.substring(1)}debugShowOrigin(t){this.Ln.entities.add({position:t,point:{pixelSize:1,color:r.Color.RED,outlineColor:r.Color.WHITE,outlineWidth:1}})}computeScreenSpaceSize(t){const n=this.Ln.scene.cartesianToCanvasCoordinates(t.position);if(!n)return;const i=`${Math.min(Math.floor(this.getZoom()),20)}:${t.styleId}`,s=this.styles[i];if(s){if(0===s.layout){const t=this.iconSize*s.transform[0],e=this.iconSize*s.transform[1];return new r.BoundingRectangle(n.x-t/2,n.y-e/2,t,e)}if(1===s.layout){const i={text:t.name,fontStyle:this.fontStyle,fontWeight:this.fontWeight,fontSize:`${s.size}`,fontFamily:this.fontFamily,verticalOrigin:e.VerticalOrigin.TOP,totalScale:s.size/e.SDFSettings.FONT_SIZE,relativeSize:s.size/e.SDFSettings.FONT_SIZE},o=this._labels.computeLabelSize(i);return new r.BoundingRectangle(n.x-o.width/2,n.y-o.height/2,o.width,o.height)}if(2===s.layout){const i=t.name,o=this.iconSize*s.transform[0],a=this.iconSize*s.transform[1],u={text:i,fontStyle:this.fontStyle,fontWeight:this.fontWeight,fontSize:`${s.size}`,fontFamily:this.fontFamily,verticalOrigin:e.VerticalOrigin.TOP,totalScale:s.size/e.SDFSettings.FONT_SIZE,relativeSize:s.size/e.SDFSettings.FONT_SIZE},h=this._labels.computeLabelSize(u),l=Math.max(o,h.width),c=Math.max(a,h.height);return new r.BoundingRectangle(n.x-l/2,n.y-c/2,l,c)}if(3===s.layout){const i=t.name,o=this.iconSize*s.transform[0],a=this.iconSize*s.transform[1],u={text:i,fontStyle:this.fontStyle,fontWeight:this.fontWeight,fontSize:`${s.size}`,fontFamily:this.fontFamily,verticalOrigin:e.VerticalOrigin.TOP,totalScale:s.size/e.SDFSettings.FONT_SIZE,relativeSize:s.size/e.SDFSettings.FONT_SIZE},h=this._labels.computeLabelSize(u),l=Math.max(a,h.height);return new r.BoundingRectangle(n.x-o/2,n.y-l/2+s.shieldDy,o+h.width+this.iconTextSpacing,l)}}}computeScreenSpaceSizeRoad(t){const n=this.Ln.scene,i=`${Math.min(Math.floor(this.getZoom()),20)}:${t.styleId}`,s=this.styles[i];if(s){if("guideboard"===t.subType){const i=n.cartesianToCanvasCoordinates(t.position);if(!i)return;const o=t.name,a=this.iconSize*s.transform[0],u=this.iconSize*s.transform[1],h={text:o,fontStyle:this.fontStyle,fontWeight:this.fontWeight,fontSize:`${s.size}`,fontFamily:this.fontFamily,verticalOrigin:e.VerticalOrigin.TOP,totalScale:s.size/e.SDFSettings.FONT_SIZE,relativeSize:s.size/e.SDFSettings.FONT_SIZE},l=this._labels.computeLabelSize(h),c=Math.max(a,l.width),f=Math.max(u,l.height);return new r.BoundingRectangle(i.x-c/2,i.y-f/2,c,f)}if("roadname"===t.subType){const i=n.cartesianToCanvasCoordinates(t.position),o=n.cartesianToCanvasCoordinates(t.end);if(!i||!o)return;t.screenPos=i,t.endScreenPos=o;const a=r.Cartesian2.subtract(o,i,new r.Cartesian2);a.y*=-1;const u=r.Cartesian2.normalize(a,new r.Cartesian2),h=new r.Cartesian2(1,0),l=r.Cartesian2.dot(h,u),c=(r.Cartesian2.cross(h,u)>0?1:-1)*Math.acos(l),f={text:t.name,fontStyle:this.fontStyle,fontWeight:this.fontWeight,fontSize:`${s.size}`,fontFamily:this.fontFamily,verticalOrigin:e.VerticalOrigin.TOP,totalScale:s.size/e.SDFSettings.FONT_SIZE,relativeSize:s.size/e.SDFSettings.FONT_SIZE},d=this._labels.computeLabelSize(f),p=[-d.width/2,d.height/2],v=[d.width/2,d.height/2],y=[-d.width/2,-d.height/2],m=[d.width/2,-d.height/2],w=Math.cos(c),g=Math.sin(c),b=[w*p[0]-g*p[1],g*p[0]+w*p[1]],x=[w*v[0]-g*v[1],g*v[0]+w*v[1]],_=[w*y[0]-g*y[1],g*y[0]+w*y[1]],k=[w*m[0]-g*m[1],g*m[0]+w*m[1]];return r.BoundingRectangle.fromPoints([new r.Cartesian2(i.x+b[0],i.y-b[1]),new r.Cartesian2(i.x+x[0],i.y-x[1]),new r.Cartesian2(i.x+_[0],i.y-_[1]),new r.Cartesian2(i.x+k[0],i.y-k[1])])}}}computePoiToRender(t){const e=this.getZoom();this.ep.clear();const n=new r.BoundingRectangle;n.x=0,n.y=0,n.width=this._scene.canvas.clientWidth,n.height=this._scene.canvas.clientHeight;const i=[];for(let s=0;s<t.length;s++){const o=t[s],a=20===o.maxzoom?999:o.maxzoom;if(e<o.minzoom||e>a)continue;const u=this.computeScreenSpaceSize(o);if(!u)continue;const{x:h,y:l,width:c,height:f}=u;if(n.intersect(u)===r.Intersect.OUTSIDE)continue;const d={minX:h-this.collisionBuffer.x,minY:l-this.collisionBuffer.y,maxX:h+c+this.collisionBuffer.x,maxY:l+f+this.collisionBuffer.y};this.ep.collides(d)||(this.ep.insert(d),i.push(o))}return i}computeItemsToRender(t,e){const n=this.getZoom();this.ep.clear();const i=new r.BoundingRectangle;i.x=0,i.y=0,i.width=this._scene.canvas.clientWidth,i.height=this._scene.canvas.clientHeight;const s=[];for(let t=0;t<e.length;t++){const o=e[t],a=20===o.maxzoom?999:o.maxzoom;if(n<o.minzoom||n>a)continue;const u=this.computeScreenSpaceSizeRoad(o);if(!u)continue;const{x:h,y:l,width:c,height:f}=u;if(i.intersect(u)===r.Intersect.OUTSIDE)continue;const d={minX:h-this.collisionBuffer.x,minY:l-this.collisionBuffer.y,maxX:h+c+this.collisionBuffer.x,maxY:l+f+this.collisionBuffer.y,data:o};this.ep.collides(d)||(this.ep.insert(d),s.push(o),o.bbox=u)}const o=[];for(let e=0;e<t.length;e++){const s=t[e],a=20===s.maxzoom?999:s.maxzoom;if(n<s.minzoom||n>a)continue;const u=this.computeScreenSpaceSize(s);if(!u)continue;const{x:h,y:l,width:c,height:f}=u;if(i.intersect(u)===r.Intersect.OUTSIDE)continue;const d={minX:h-this.collisionBuffer.x,minY:l-this.collisionBuffer.y,maxX:h+c+this.collisionBuffer.x,maxY:l+f+this.collisionBuffer.y,data:s};if(!s.external){if(this.ep.collides(d))continue;this.ep.insert(d)}o.push(s),s.bbox=u}return{pois:o,roads:s}}diff(t,e){const n=e.reduce(((t,e)=>(t[e.id]=e,t)),{}),i=Object.keys(t),r=[],s=[];for(let t=0;t<i.length;t++)n[i[t]]||r.push(i[t]);for(let n=0;n<e.length;n++)t[e[n].id]||s.push(e[n]);return{add:s,remove:r}}getZoom(){const t=this._scene.camera.position,e=r.Ellipsoid.WGS84.cartesianToCartographic(t).height;return Math.log2(169066473.75/e)}updateRoads(t,e){const{add:n,remove:i}=this.diff(t,e);for(let t=0;t<i.length;t++){const e=i[t],{label:n,icon:r}=this.tp[e];n&&this.Zd.remove(n),r&&this.Yd.remove(r),delete this.tp[e]}for(let t=0;t<n.length;t++){const e=n[t];this.addRoad(e)}}updatePois(t,e){const{add:n,remove:i}=this.diff(t,e);for(let t=0;t<i.length;t++){const e=i[t];if(this.Jd[e]){const{icon:t,label:n}=this.Jd[e];t&&this.Xd.remove(t),n&&this._labels.remove(n),delete this.Jd[e]}}for(let t=0;t<n.length;t++){const e=n[t];this.addPoi(e)}}cp(){const t=document.createElement("style");t.id="AlibabaPuHuiTi",t.innerHTML='\n @font-face {\n font-family: "AlibabaPuHuiTi";\n src: url("https://amappc.oss-cn-zhangjiakou.aliyuncs.com/gis/static/3dgs/cesiumjs-sdk/AlibabaPuHuiTi-2-55-Regular/AlibabaPuHuiTi-2-55-Regular.woff2")\n format("woff2");\n font-weight: normal;\n font-style: normal;\n }\n ',document.head.appendChild(t),new Xy("AlibabaPuHuiTi").load(null,this.rp).then((()=>{this.sp=!0,this.requestRender()}))}async fp(){try{const t=await fetch(this.styleUrl),e=await t.json();this.styles=e}catch(t){}}pick(t){const e={minX:t.x,minY:t.y,maxX:t.x+1,maxY:t.y+1},n=this.ep.search(e)[0];if("poi"===n?.data?.type)return n.data.poiid}setExtraPois(t){this.ip=t,this._dirty=!0,this.requestRender()}dp=null;requestRender=()=>{clearTimeout(this.dp);const t=Date.now()-this.ap;t>this.op?this.Ln.scene.requestRender():this.dp=setTimeout((()=>{this.Ln.scene.requestRender()}),this.op-t+1)}}class Yy{endpoint="https://address-search.amap.com/v3/query/place/text";constructor(){}async search(t){try{const e={method:"GET"},n=Object.keys(t).map((e=>`${e}=${encodeURIComponent(t[e])}`)).join("&"),i=this.endpoint+"?"+n,r=await fetch(i,e),s=await r.json();if(0===s.code){const t=s.pois.map((t=>{const[e,n]=t.location.split(",").map((t=>parseFloat(t))),i=parseFloat(t.height)||0;return{name:t.name,position:[e,n,i]}}));return{success:!0,data:t,message:""}}throw new Error(`Failed to fetch ${i}`)}catch(t){return{success:!1,data:[],message:t.message}}}}class Jy{ro;so="BuildingDataSource";oo=!1;ao;uo;ho;_show=!0;lo;_scene;We;Vd=1;Wd={};Gd;Ad=0;Qd={};tilesetUrl;tileset;minDistance;worker;constructor(t){this.ao=new r.Event,this.uo=new r.Event,this.oo=!1,this.ho=new r.Event,this.ro=new r.EntityCollection,this.lo=new r.EntityCluster,this._scene=t.scene,this.tilesetUrl=t.tileset,this.Gd=this.tilesetUrl.substring(0,this.tilesetUrl.lastIndexOf("/")),this.minDistance=t.minDistance,this.We=new Hc({Bi:30,qi:this.onDrop});const e=new Blob(['var factory;factory=function(){"use strict";var t="undefined"!=typeof document?document.currentScript:null;function n(t,n){return null!=t?t:n}function e(t){return null!=t}function r(t){let n;this.name="DeveloperError",this.message=t;try{throw new Error}catch(t){n=t.stack}this.stack=n}n.EMPTY_OBJECT=Object.freeze({}),e(Object.create)&&(r.prototype=Object.create(Error.prototype),r.prototype.constructor=r),r.prototype.toString=function(){let t=`${this.name}: ${this.message}`;return e(this.stack)&&(t+=`\\n${this.stack.toString()}`),t},r.throwInstantiationError=function(){throw new r("This function defines an interface and should not be called directly.")};const i={};function o(t,n,e){return`Expected ${e} to be typeof ${n}, actual typeof was ${t}`}function u(){this.t=[],this.o=[],this.u=[],this.h=!1}function s(t,n){return n-t}i.typeOf={},i.defined=function(t,n){if(!e(n))throw new r(function(t){return`${t} is required, actual value was undefined`}(t))},i.typeOf.func=function(t,n){if("function"!=typeof n)throw new r(o(typeof n,"function",t))},i.typeOf.string=function(t,n){if("string"!=typeof n)throw new r(o(typeof n,"string",t))},i.typeOf.number=function(t,n){if("number"!=typeof n)throw new r(o(typeof n,"number",t))},i.typeOf.number.lessThan=function(t,n,e){if(i.typeOf.number(t,n),n>=e)throw new r(`Expected ${t} to be less than ${e}, actual value was ${n}`)},i.typeOf.number.lessThanOrEquals=function(t,n,e){if(i.typeOf.number(t,n),n>e)throw new r(`Expected ${t} to be less than or equal to ${e}, actual value was ${n}`)},i.typeOf.number.greaterThan=function(t,n,e){if(i.typeOf.number(t,n),n<=e)throw new r(`Expected ${t} to be greater than ${e}, actual value was ${n}`)},i.typeOf.number.greaterThanOrEquals=function(t,n,e){if(i.typeOf.number(t,n),n<e)throw new r(`Expected ${t} to be greater than or equal to ${e}, actual value was ${n}`)},i.typeOf.object=function(t,n){if("object"!=typeof n)throw new r(o(typeof n,"object",t))},i.typeOf.bool=function(t,n){if("boolean"!=typeof n)throw new r(o(typeof n,"boolean",t))},i.typeOf.bigint=function(t,n){if("bigint"!=typeof n)throw new r(o(typeof n,"bigint",t))},i.typeOf.number.equals=function(t,n,e,o){if(i.typeOf.number(t,e),i.typeOf.number(n,o),e!==o)throw new r(`${t} must be equal to ${n}, the actual values are ${e} and ${o}`)},Object.defineProperties(u.prototype,{numberOfListeners:{get:function(){return this.t.length-this.u.length}}}),u.prototype.addEventListener=function(t,n){i.typeOf.func("listener",t),this.t.push(t),this.o.push(n);const e=this;return function(){e.removeEventListener(t,n)}},u.prototype.removeEventListener=function(t,n){i.typeOf.func("listener",t);const e=this.t,r=this.o;let o=-1;for(let i=0;i<e.length;i++)if(e[i]===t&&r[i]===n){o=i;break}return-1!==o&&(this.h?(this.u.push(o),e[o]=void 0,r[o]=void 0):(e.splice(o,1),r.splice(o,1)),!0)},u.prototype.raiseEvent=function(){let t;this.h=!0;const n=this.t,r=this.o;let i=n.length;for(t=0;t<i;t++)e(n[t])&&n[t].apply(r[t],arguments);const o=this.u;if(i=o.length,i>0){for(o.sort(s),t=0;t<i;t++){const e=o[t];n.splice(e,1),r.splice(e,1)}o.length=0}this.h=!1};var c,a,f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function h(t){return t&&t.l&&{}.hasOwnProperty.call(t,"default")?t.default:t}var l=function(){if(a)return c;a=1;var t=function(t){null==t&&(t=(new Date).getTime()),this.N=624,this.M=397,this.MATRIX_A=2567483615,this.UPPER_MASK=2147483648,this.LOWER_MASK=2147483647,this.mt=new Array(this.N),this.mti=this.N+1,t.constructor==Array?this.init_by_array(t,t.length):this.init_seed(t)};return t.prototype.init_seed=function(t){for(this.mt[0]=t>>>0,this.mti=1;this.mti<this.N;this.mti++)t=this.mt[this.mti-1]^this.mt[this.mti-1]>>>30,this.mt[this.mti]=(1812433253*((4294901760&t)>>>16)<<16)+1812433253*(65535&t)+this.mti,this.mt[this.mti]>>>=0},t.prototype.init_by_array=function(t,n){var e,r,i;for(this.init_seed(19650218),e=1,r=0,i=this.N>n?this.N:n;i;i--){var o=this.mt[e-1]^this.mt[e-1]>>>30;this.mt[e]=(this.mt[e]^(1664525*((4294901760&o)>>>16)<<16)+1664525*(65535&o))+t[r]+r,this.mt[e]>>>=0,r++,++e>=this.N&&(this.mt[0]=this.mt[this.N-1],e=1),r>=n&&(r=0)}for(i=this.N-1;i;i--)o=this.mt[e-1]^this.mt[e-1]>>>30,this.mt[e]=(this.mt[e]^(1566083941*((4294901760&o)>>>16)<<16)+1566083941*(65535&o))-e,this.mt[e]>>>=0,++e>=this.N&&(this.mt[0]=this.mt[this.N-1],e=1);this.mt[0]=2147483648},t.prototype.random_int=function(){var t,n=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var e;for(this.mti==this.N+1&&this.init_seed(5489),e=0;e<this.N-this.M;e++)t=this.mt[e]&this.UPPER_MASK|this.mt[e+1]&this.LOWER_MASK,this.mt[e]=this.mt[e+this.M]^t>>>1^n[1&t];for(;e<this.N-1;e++)t=this.mt[e]&this.UPPER_MASK|this.mt[e+1]&this.LOWER_MASK,this.mt[e]=this.mt[e+(this.M-this.N)]^t>>>1^n[1&t];t=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^t>>>1^n[1&t],this.mti=0}return t=this.mt[this.mti++],t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,(t^=t>>>18)>>>0},t.prototype.random_int31=function(){return this.random_int()>>>1},t.prototype.random_incl=function(){return this.random_int()*(1/4294967295)},t.prototype.random=function(){return this.random_int()*(1/4294967296)},t.prototype.random_excl=function(){return(this.random_int()+.5)*(1/4294967296)},t.prototype.random_long=function(){return(67108864*(this.random_int()>>>5)+(this.random_int()>>>6))*(1/9007199254740992)},c=t}(),d=h(l);const w={EPSILON1:.1,EPSILON2:.01,EPSILON3:.001,EPSILON4:1e-4,EPSILON5:1e-5,EPSILON6:1e-6,EPSILON7:1e-7,EPSILON8:1e-8,EPSILON9:1e-9,EPSILON10:1e-10,EPSILON11:1e-11,EPSILON12:1e-12,EPSILON13:1e-13,EPSILON14:1e-14,EPSILON15:1e-15,EPSILON16:1e-16,EPSILON17:1e-17,EPSILON18:1e-18,EPSILON19:1e-19,EPSILON20:1e-20,EPSILON21:1e-21,GRAVITATIONALPARAMETER:3986004418e5,SOLAR_RADIUS:6955e5,LUNAR_RADIUS:1737400,SIXTY_FOUR_KILOBYTES:65536,FOUR_GIGABYTES:4294967296};w.sign=n(Math.sign,(function(t){return 0==(t=+t)||t!=t?t:t>0?1:-1})),w.signNotZero=function(t){return t<0?-1:1},w.toSNorm=function(t,e){return e=n(e,255),Math.round((.5*w.clamp(t,-1,1)+.5)*e)},w.fromSNorm=function(t,e){return e=n(e,255),w.clamp(t,0,e)/e*2-1},w.normalize=function(t,n,e){return 0===(e=Math.max(e-n,0))?0:w.clamp((t-n)/e,0,1)},w.sinh=n(Math.sinh,(function(t){return(Math.exp(t)-Math.exp(-t))/2})),w.cosh=n(Math.cosh,(function(t){return(Math.exp(t)+Math.exp(-t))/2})),w.lerp=function(t,n,e){return(1-e)*t+e*n},w.PI=Math.PI,w.ONE_OVER_PI=1/Math.PI,w.PI_OVER_TWO=Math.PI/2,w.PI_OVER_THREE=Math.PI/3,w.PI_OVER_FOUR=Math.PI/4,w.PI_OVER_SIX=Math.PI/6,w.THREE_PI_OVER_TWO=3*Math.PI/2,w.TWO_PI=2*Math.PI,w.ONE_OVER_TWO_PI=1/(2*Math.PI),w.RADIANS_PER_DEGREE=Math.PI/180,w.DEGREES_PER_RADIAN=180/Math.PI,w.RADIANS_PER_ARCSECOND=w.RADIANS_PER_DEGREE/3600,w.toRadians=function(t){if(!e(t))throw new r("degrees is required.");return t*w.RADIANS_PER_DEGREE},w.toDegrees=function(t){if(!e(t))throw new r("radians is required.");return t*w.DEGREES_PER_RADIAN},w.convertLongitudeRange=function(t){if(!e(t))throw new r("angle is required.");const n=w.TWO_PI,i=t-Math.floor(t/n)*n;return i<-Math.PI?i+n:i>=Math.PI?i-n:i},w.clampToLatitudeRange=function(t){if(!e(t))throw new r("angle is required.");return w.clamp(t,-1*w.PI_OVER_TWO,w.PI_OVER_TWO)},w.negativePiToPi=function(t){if(!e(t))throw new r("angle is required.");return t>=-w.PI&&t<=w.PI?t:w.zeroToTwoPi(t+w.PI)-w.PI},w.zeroToTwoPi=function(t){if(!e(t))throw new r("angle is required.");if(t>=0&&t<=w.TWO_PI)return t;const n=w.mod(t,w.TWO_PI);return Math.abs(n)<w.EPSILON14&&Math.abs(t)>w.EPSILON14?w.TWO_PI:n},w.mod=function(t,n){if(!e(t))throw new r("m is required.");if(!e(n))throw new r("n is required.");if(0===n)throw new r("divisor cannot be 0.");return w.sign(t)===w.sign(n)&&Math.abs(t)<Math.abs(n)?t:(t%n+n)%n},w.equalsEpsilon=function(t,i,o,u){if(!e(t))throw new r("left is required.");if(!e(i))throw new r("right is required.");o=n(o,0),u=n(u,o);const s=Math.abs(t-i);return s<=u||s<=o*Math.max(Math.abs(t),Math.abs(i))},w.lessThan=function(t,n,i){if(!e(t))throw new r("first is required.");if(!e(n))throw new r("second is required.");if(!e(i))throw new r("absoluteEpsilon is required.");return t-n<-i},w.lessThanOrEquals=function(t,n,i){if(!e(t))throw new r("first is required.");if(!e(n))throw new r("second is required.");if(!e(i))throw new r("absoluteEpsilon is required.");return t-n<i},w.greaterThan=function(t,n,i){if(!e(t))throw new r("first is required.");if(!e(n))throw new r("second is required.");if(!e(i))throw new r("absoluteEpsilon is required.");return t-n>i},w.greaterThanOrEquals=function(t,n,i){if(!e(t))throw new r("first is required.");if(!e(n))throw new r("second is required.");if(!e(i))throw new r("absoluteEpsilon is required.");return t-n>-i};const m=[1];w.factorial=function(t){if("number"!=typeof t||t<0)throw new r("A number greater than or equal to 0 is required.");const n=m.length;if(t>=n){let e=m[n-1];for(let r=n;r<=t;r++){const t=e*r;m.push(t),e=t}}return m[t]},w.incrementWrap=function(t,i,o){if(o=n(o,0),!e(t))throw new r("n is required.");if(i<=o)throw new r("maximumValue must be greater than minimumValue.");return++t>i&&(t=o),t},w.isPowerOfTwo=function(t){if("number"!=typeof t||t<0||t>4294967295)throw new r("A number between 0 and (2^32)-1 is required.");return 0!==t&&!(t&t-1)},w.nextPowerOfTwo=function(t){if("number"!=typeof t||t<0||t>2147483648)throw new r("A number between 0 and 2^31 is required.");return--t,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},w.previousPowerOfTwo=function(t){if("number"!=typeof t||t<0||t>4294967295)throw new r("A number between 0 and (2^32)-1 is required.");return t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,((t|=t>>32)>>>0)-(t>>>1)},w.clamp=function(t,n,e){return i.typeOf.number("value",t),i.typeOf.number("min",n),i.typeOf.number("max",e),t<n?n:t>e?e:t};let g=new d;function v(t,e){this.x=n(t,0),this.y=n(e,0)}w.setRandomNumberSeed=function(t){if(!e(t))throw new r("seed is required.");g=new d(t)},w.nextRandomNumber=function(){return g.random()},w.randomBetween=function(t,n){return w.nextRandomNumber()*(n-t)+t},w.acosClamped=function(t){if(!e(t))throw new r("value is required.");return Math.acos(w.clamp(t,-1,1))},w.asinClamped=function(t){if(!e(t))throw new r("value is required.");return Math.asin(w.clamp(t,-1,1))},w.chordLength=function(t,n){if(!e(t))throw new r("angle is required.");if(!e(n))throw new r("radius is required.");return 2*n*Math.sin(.5*t)},w.logBase=function(t,n){if(!e(t))throw new r("number is required.");if(!e(n))throw new r("base is required.");return Math.log(t)/Math.log(n)},w.cbrt=n(Math.cbrt,(function(t){const n=Math.pow(Math.abs(t),1/3);return t<0?-n:n})),w.log2=n(Math.log2,(function(t){return Math.log(t)*Math.LOG2E})),w.fog=function(t,n){const e=t*n;return 1-Math.exp(-e*e)},w.fastApproximateAtan=function(t){return i.typeOf.number("x",t),t*(-.1784*Math.abs(t)-.0663*t*t+1.0301)},w.fastApproximateAtan2=function(t,n){let e;i.typeOf.number("x",t),i.typeOf.number("y",n);let o=Math.abs(t);e=Math.abs(n);const u=Math.max(o,e);e=Math.min(o,e);const s=e/u;if(isNaN(s))throw new r("either x or y must be nonzero");return o=w.fastApproximateAtan(s),o=Math.abs(n)>Math.abs(t)?w.PI_OVER_TWO-o:o,o=t<0?w.PI-o:o,o=n<0?-o:o,o},v.fromElements=function(t,n,r){return e(r)?(r.x=t,r.y=n,r):new v(t,n)},v.clone=function(t,n){if(e(t))return e(n)?(n.x=t.x,n.y=t.y,n):new v(t.x,t.y)},v.fromCartesian3=v.clone,v.fromCartesian4=v.clone,v.packedLength=2,v.pack=function(t,e,r){return i.typeOf.object("value",t),i.defined("array",e),r=n(r,0),e[r++]=t.x,e[r]=t.y,e},v.unpack=function(t,r,o){return i.defined("array",t),r=n(r,0),e(o)||(o=new v),o.x=t[r++],o.y=t[r],o},v.packArray=function(t,n){i.defined("array",t);const o=t.length,u=2*o;if(e(n)){if(!Array.isArray(n)&&n.length!==u)throw new r("If result is a typed array, it must have exactly array.length * 2 elements");n.length!==u&&(n.length=u)}else n=new Array(u);for(let e=0;e<o;++e)v.pack(t[e],n,2*e);return n},v.unpackArray=function(t,n){if(i.defined("array",t),i.typeOf.number.greaterThanOrEquals("array.length",t.length,2),t.length%2!=0)throw new r("array length must be a multiple of 2.");const o=t.length;e(n)?n.length=o/2:n=new Array(o/2);for(let e=0;e<o;e+=2){const r=e/2;n[r]=v.unpack(t,e,n[r])}return n},v.fromArray=v.unpack,v.maximumComponent=function(t){return i.typeOf.object("cartesian",t),Math.max(t.x,t.y)},v.minimumComponent=function(t){return i.typeOf.object("cartesian",t),Math.min(t.x,t.y)},v.minimumByComponent=function(t,n,e){return i.typeOf.object("first",t),i.typeOf.object("second",n),i.typeOf.object("result",e),e.x=Math.min(t.x,n.x),e.y=Math.min(t.y,n.y),e},v.maximumByComponent=function(t,n,e){return i.typeOf.object("first",t),i.typeOf.object("second",n),i.typeOf.object("result",e),e.x=Math.max(t.x,n.x),e.y=Math.max(t.y,n.y),e},v.clamp=function(t,n,e,r){i.typeOf.object("value",t),i.typeOf.object("min",n),i.typeOf.object("max",e),i.typeOf.object("result",r);const o=w.clamp(t.x,n.x,e.x),u=w.clamp(t.y,n.y,e.y);return r.x=o,r.y=u,r},v.magnitudeSquared=function(t){return i.typeOf.object("cartesian",t),t.x*t.x+t.y*t.y},v.magnitude=function(t){return Math.sqrt(v.magnitudeSquared(t))};const p=new v;v.distance=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),v.subtract(t,n,p),v.magnitude(p)},v.distanceSquared=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),v.subtract(t,n,p),v.magnitudeSquared(p)},v.normalize=function(t,n){i.typeOf.object("cartesian",t),i.typeOf.object("result",n);const e=v.magnitude(t);if(n.x=t.x/e,n.y=t.y/e,isNaN(n.x)||isNaN(n.y))throw new r("normalized result is not a number");return n},v.dot=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),t.x*n.x+t.y*n.y},v.cross=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),t.x*n.y-t.y*n.x},v.multiplyComponents=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x*n.x,e.y=t.y*n.y,e},v.divideComponents=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x/n.x,e.y=t.y/n.y,e},v.add=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x+n.x,e.y=t.y+n.y,e},v.subtract=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x-n.x,e.y=t.y-n.y,e},v.multiplyByScalar=function(t,n,e){return i.typeOf.object("cartesian",t),i.typeOf.number("scalar",n),i.typeOf.object("result",e),e.x=t.x*n,e.y=t.y*n,e},v.divideByScalar=function(t,n,e){return i.typeOf.object("cartesian",t),i.typeOf.number("scalar",n),i.typeOf.object("result",e),e.x=t.x/n,e.y=t.y/n,e},v.negate=function(t,n){return i.typeOf.object("cartesian",t),i.typeOf.object("result",n),n.x=-t.x,n.y=-t.y,n},v.abs=function(t,n){return i.typeOf.object("cartesian",t),i.typeOf.object("result",n),n.x=Math.abs(t.x),n.y=Math.abs(t.y),n};const y=new v;v.lerp=function(t,n,e,r){return i.typeOf.object("start",t),i.typeOf.object("end",n),i.typeOf.number("t",e),i.typeOf.object("result",r),v.multiplyByScalar(n,e,y),r=v.multiplyByScalar(t,1-e,r),v.add(y,r,r)};const b=new v,M=new v;v.angleBetween=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),v.normalize(t,b),v.normalize(n,M),w.acosClamped(v.dot(b,M))};const A=new v;function x(t,e,r){this.x=n(t,0),this.y=n(e,0),this.z=n(r,0)}v.mostOrthogonalAxis=function(t,n){i.typeOf.object("cartesian",t),i.typeOf.object("result",n);const e=v.normalize(t,A);return v.abs(e,e),e.x<=e.y?v.clone(v.UNIT_X,n):v.clone(v.UNIT_Y,n)},v.equals=function(t,n){return t===n||e(t)&&e(n)&&t.x===n.x&&t.y===n.y},v.equalsArray=function(t,n,e){return t.x===n[e]&&t.y===n[e+1]},v.equalsEpsilon=function(t,n,r,i){return t===n||e(t)&&e(n)&&w.equalsEpsilon(t.x,n.x,r,i)&&w.equalsEpsilon(t.y,n.y,r,i)},v.ZERO=Object.freeze(new v(0,0)),v.ONE=Object.freeze(new v(1,1)),v.UNIT_X=Object.freeze(new v(1,0)),v.UNIT_Y=Object.freeze(new v(0,1)),v.prototype.clone=function(t){return v.clone(this,t)},v.prototype.equals=function(t){return v.equals(this,t)},v.prototype.equalsEpsilon=function(t,n,e){return v.equalsEpsilon(this,t,n,e)},v.prototype.toString=function(){return`(${this.x}, ${this.y})`},x.fromSpherical=function(t,r){i.typeOf.object("spherical",t),e(r)||(r=new x);const o=t.clock,u=t.cone,s=n(t.magnitude,1),c=s*Math.sin(u);return r.x=c*Math.cos(o),r.y=c*Math.sin(o),r.z=s*Math.cos(u),r},x.fromElements=function(t,n,r,i){return e(i)?(i.x=t,i.y=n,i.z=r,i):new x(t,n,r)},x.clone=function(t,n){if(e(t))return e(n)?(n.x=t.x,n.y=t.y,n.z=t.z,n):new x(t.x,t.y,t.z)},x.fromCartesian4=x.clone,x.packedLength=3,x.pack=function(t,e,r){return i.typeOf.object("value",t),i.defined("array",e),r=n(r,0),e[r++]=t.x,e[r++]=t.y,e[r]=t.z,e},x.unpack=function(t,r,o){return i.defined("array",t),r=n(r,0),e(o)||(o=new x),o.x=t[r++],o.y=t[r++],o.z=t[r],o},x.packArray=function(t,n){i.defined("array",t);const o=t.length,u=3*o;if(e(n)){if(!Array.isArray(n)&&n.length!==u)throw new r("If result is a typed array, it must have exactly array.length * 3 elements");n.length!==u&&(n.length=u)}else n=new Array(u);for(let e=0;e<o;++e)x.pack(t[e],n,3*e);return n},x.unpackArray=function(t,n){if(i.defined("array",t),i.typeOf.number.greaterThanOrEquals("array.length",t.length,3),t.length%3!=0)throw new r("array length must be a multiple of 3.");const o=t.length;e(n)?n.length=o/3:n=new Array(o/3);for(let e=0;e<o;e+=3){const r=e/3;n[r]=x.unpack(t,e,n[r])}return n},x.fromArray=x.unpack,x.maximumComponent=function(t){return i.typeOf.object("cartesian",t),Math.max(t.x,t.y,t.z)},x.minimumComponent=function(t){return i.typeOf.object("cartesian",t),Math.min(t.x,t.y,t.z)},x.minimumByComponent=function(t,n,e){return i.typeOf.object("first",t),i.typeOf.object("second",n),i.typeOf.object("result",e),e.x=Math.min(t.x,n.x),e.y=Math.min(t.y,n.y),e.z=Math.min(t.z,n.z),e},x.maximumByComponent=function(t,n,e){return i.typeOf.object("first",t),i.typeOf.object("second",n),i.typeOf.object("result",e),e.x=Math.max(t.x,n.x),e.y=Math.max(t.y,n.y),e.z=Math.max(t.z,n.z),e},x.clamp=function(t,n,e,r){i.typeOf.object("value",t),i.typeOf.object("min",n),i.typeOf.object("max",e),i.typeOf.object("result",r);const o=w.clamp(t.x,n.x,e.x),u=w.clamp(t.y,n.y,e.y),s=w.clamp(t.z,n.z,e.z);return r.x=o,r.y=u,r.z=s,r},x.magnitudeSquared=function(t){return i.typeOf.object("cartesian",t),t.x*t.x+t.y*t.y+t.z*t.z},x.magnitude=function(t){return Math.sqrt(x.magnitudeSquared(t))};const E=new x;x.distance=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),x.subtract(t,n,E),x.magnitude(E)},x.distanceSquared=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),x.subtract(t,n,E),x.magnitudeSquared(E)},x.normalize=function(t,n){i.typeOf.object("cartesian",t),i.typeOf.object("result",n);const e=x.magnitude(t);if(n.x=t.x/e,n.y=t.y/e,n.z=t.z/e,isNaN(n.x)||isNaN(n.y)||isNaN(n.z))throw new r("normalized result is not a number");return n},x.dot=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),t.x*n.x+t.y*n.y+t.z*n.z},x.multiplyComponents=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x*n.x,e.y=t.y*n.y,e.z=t.z*n.z,e},x.divideComponents=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x/n.x,e.y=t.y/n.y,e.z=t.z/n.z,e},x.add=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x+n.x,e.y=t.y+n.y,e.z=t.z+n.z,e},x.subtract=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x-n.x,e.y=t.y-n.y,e.z=t.z-n.z,e},x.multiplyByScalar=function(t,n,e){return i.typeOf.object("cartesian",t),i.typeOf.number("scalar",n),i.typeOf.object("result",e),e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e},x.divideByScalar=function(t,n,e){return i.typeOf.object("cartesian",t),i.typeOf.number("scalar",n),i.typeOf.object("result",e),e.x=t.x/n,e.y=t.y/n,e.z=t.z/n,e},x.negate=function(t,n){return i.typeOf.object("cartesian",t),i.typeOf.object("result",n),n.x=-t.x,n.y=-t.y,n.z=-t.z,n},x.abs=function(t,n){return i.typeOf.object("cartesian",t),i.typeOf.object("result",n),n.x=Math.abs(t.x),n.y=Math.abs(t.y),n.z=Math.abs(t.z),n};const k=new x;x.lerp=function(t,n,e,r){return i.typeOf.object("start",t),i.typeOf.object("end",n),i.typeOf.number("t",e),i.typeOf.object("result",r),x.multiplyByScalar(n,e,k),r=x.multiplyByScalar(t,1-e,r),x.add(k,r,r)};const q=new x,$=new x;x.angleBetween=function(t,n){i.typeOf.object("left",t),i.typeOf.object("right",n),x.normalize(t,q),x.normalize(n,$);const e=x.dot(q,$),r=x.magnitude(x.cross(q,$,q));return Math.atan2(r,e)};const S=new x;x.mostOrthogonalAxis=function(t,n){i.typeOf.object("cartesian",t),i.typeOf.object("result",n);const e=x.normalize(t,S);return x.abs(e,e),e.x<=e.y?e.x<=e.z?x.clone(x.UNIT_X,n):x.clone(x.UNIT_Z,n):e.y<=e.z?x.clone(x.UNIT_Y,n):x.clone(x.UNIT_Z,n)},x.projectVector=function(t,n,e){i.defined("a",t),i.defined("b",n),i.defined("result",e);const r=x.dot(t,n)/x.dot(n,n);return x.multiplyByScalar(n,r,e)},x.equals=function(t,n){return t===n||e(t)&&e(n)&&t.x===n.x&&t.y===n.y&&t.z===n.z},x.equalsArray=function(t,n,e){return t.x===n[e]&&t.y===n[e+1]&&t.z===n[e+2]},x.equalsEpsilon=function(t,n,r,i){return t===n||e(t)&&e(n)&&w.equalsEpsilon(t.x,n.x,r,i)&&w.equalsEpsilon(t.y,n.y,r,i)&&w.equalsEpsilon(t.z,n.z,r,i)},x.cross=function(t,n,e){i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e);const r=t.x,o=t.y,u=t.z,s=n.x,c=n.y,a=n.z,f=o*a-u*c,h=u*s-r*a,l=r*c-o*s;return e.x=f,e.y=h,e.z=l,e},x.midpoint=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=.5*(t.x+n.x),e.y=.5*(t.y+n.y),e.z=.5*(t.z+n.z),e},x.fromDegrees=function(t,n,e,r,o){return i.typeOf.number("longitude",t),i.typeOf.number("latitude",n),t=w.toRadians(t),n=w.toRadians(n),x.fromRadians(t,n,e,r,o)};let I=new x,O=new x;x.m=new x(40680631590769,40680631590769,40408299984661.445),x.fromRadians=function(t,r,o,u,s){i.typeOf.number("longitude",t),i.typeOf.number("latitude",r),o=n(o,0);const c=e(u)?u.radiiSquared:x.m,a=Math.cos(r);I.x=a*Math.cos(t),I.y=a*Math.sin(t),I.z=Math.sin(r),I=x.normalize(I,I),x.multiplyComponents(c,I,O);const f=Math.sqrt(x.dot(I,O));return O=x.divideByScalar(O,f,O),I=x.multiplyByScalar(I,o,I),e(s)||(s=new x),x.add(O,I,s)},x.fromDegreesArray=function(t,n,o){if(i.defined("coordinates",t),t.length<2||t.length%2!=0)throw new r("the number of coordinates must be a multiple of 2 and at least 2");const u=t.length;e(o)?o.length=u/2:o=new Array(u/2);for(let e=0;e<u;e+=2){const r=t[e],i=t[e+1],u=e/2;o[u]=x.fromDegrees(r,i,0,n,o[u])}return o},x.fromRadiansArray=function(t,n,o){if(i.defined("coordinates",t),t.length<2||t.length%2!=0)throw new r("the number of coordinates must be a multiple of 2 and at least 2");const u=t.length;e(o)?o.length=u/2:o=new Array(u/2);for(let e=0;e<u;e+=2){const r=t[e],i=t[e+1],u=e/2;o[u]=x.fromRadians(r,i,0,n,o[u])}return o},x.fromDegreesArrayHeights=function(t,n,o){if(i.defined("coordinates",t),t.length<3||t.length%3!=0)throw new r("the number of coordinates must be a multiple of 3 and at least 3");const u=t.length;e(o)?o.length=u/3:o=new Array(u/3);for(let e=0;e<u;e+=3){const r=t[e],i=t[e+1],u=t[e+2],s=e/3;o[s]=x.fromDegrees(r,i,u,n,o[s])}return o},x.fromRadiansArrayHeights=function(t,n,o){if(i.defined("coordinates",t),t.length<3||t.length%3!=0)throw new r("the number of coordinates must be a multiple of 3 and at least 3");const u=t.length;e(o)?o.length=u/3:o=new Array(u/3);for(let e=0;e<u;e+=3){const r=t[e],i=t[e+1],u=t[e+2],s=e/3;o[s]=x.fromRadians(r,i,u,n,o[s])}return o},x.ZERO=Object.freeze(new x(0,0,0)),x.ONE=Object.freeze(new x(1,1,1)),x.UNIT_X=Object.freeze(new x(1,0,0)),x.UNIT_Y=Object.freeze(new x(0,1,0)),x.UNIT_Z=Object.freeze(new x(0,0,1)),x.prototype.clone=function(t){return x.clone(this,t)},x.prototype.equals=function(t){return x.equals(this,t)},x.prototype.equalsEpsilon=function(t,n,e){return x.equalsEpsilon(this,t,n,e)},x.prototype.toString=function(){return`(${this.x}, ${this.y}, ${this.z})`};const R=new x,P=new x;function j(t,n,i,o,u){if(!e(t))throw new r("cartesian is required.");if(!e(n))throw new r("oneOverRadii is required.");if(!e(i))throw new r("oneOverRadiiSquared is required.");if(!e(o))throw new r("centerToleranceSquared is required.");const s=t.x,c=t.y,a=t.z,f=n.x,h=n.y,l=n.z,d=s*s*f*f,m=c*c*h*h,g=a*a*l*l,v=d+m+g,p=Math.sqrt(1/v),y=x.multiplyByScalar(t,p,R);if(v<o)return isFinite(p)?x.clone(y,u):void 0;const b=i.x,M=i.y,A=i.z,E=P;E.x=y.x*b*2,E.y=y.y*M*2,E.z=y.z*A*2;let k,q,$,S,I,O,j,F,N,U,T,z=(1-p)*x.magnitude(t)/(.5*x.magnitude(E)),C=0;do{z-=C,$=1/(1+z*b),S=1/(1+z*M),I=1/(1+z*A),O=$*$,j=S*S,F=I*I,N=O*$,U=j*S,T=F*I,k=d*O+m*j+g*F-1,q=d*N*b+m*U*M+g*T*A,C=k/(-2*q)}while(Math.abs(k)>w.EPSILON12);return e(u)?(u.x=s*$,u.y=c*S,u.z=a*I,u):new x(s*$,c*S,a*I)}function F(t,e,r){this.longitude=n(t,0),this.latitude=n(e,0),this.height=n(r,0)}F.fromRadians=function(t,r,o,u){return i.typeOf.number("longitude",t),i.typeOf.number("latitude",r),o=n(o,0),e(u)?(u.longitude=t,u.latitude=r,u.height=o,u):new F(t,r,o)},F.fromDegrees=function(t,n,e,r){return i.typeOf.number("longitude",t),i.typeOf.number("latitude",n),t=w.toRadians(t),n=w.toRadians(n),F.fromRadians(t,n,e,r)};const N=new x,U=new x,T=new x;function z(t,e,r,o){e=n(e,0),r=n(r,0),o=n(o,0),i.typeOf.number.greaterThanOrEquals("x",e,0),i.typeOf.number.greaterThanOrEquals("y",r,0),i.typeOf.number.greaterThanOrEquals("z",o,0),t.v=new x(e,r,o),t.p=new x(e*e,r*r,o*o),t.A=new x(e*e*e*e,r*r*r*r,o*o*o*o),t.k=new x(0===e?0:1/e,0===r?0:1/r,0===o?0:1/o),t.q=new x(0===e?0:1/(e*e),0===r?0:1/(r*r),0===o?0:1/(o*o)),t.$=Math.min(e,r,o),t.S=Math.max(e,r,o),t.I=w.EPSILON1,0!==t.p.z&&(t.O=t.p.x/t.p.z)}function C(t,n,e){this.v=void 0,this.p=void 0,this.A=void 0,this.k=void 0,this.q=void 0,this.$=void 0,this.S=void 0,this.I=void 0,this.O=void 0,z(this,t,n,e)}F.R=new x(1/6378137,1/6378137,1/6356752.314245179),F.P=new x(1/40680631590769,1/40680631590769,1/40408299984661.445),F.j=w.EPSILON1,F.fromCartesian=function(t,n,r){const i=e(n)?n.oneOverRadii:F.R,o=e(n)?n.oneOverRadiiSquared:F.P,u=j(t,i,o,e(n)?n.I:F.j,U);if(!e(u))return;let s=x.multiplyComponents(u,o,N);s=x.normalize(s,s);const c=x.subtract(t,u,T),a=Math.atan2(s.y,s.x),f=Math.asin(s.z),h=w.sign(x.dot(c,t))*x.magnitude(c);return e(r)?(r.longitude=a,r.latitude=f,r.height=h,r):new F(a,f,h)},F.toCartesian=function(t,n,e){return i.defined("cartographic",t),x.fromRadians(t.longitude,t.latitude,t.height,n,e)},F.clone=function(t,n){if(e(t))return e(n)?(n.longitude=t.longitude,n.latitude=t.latitude,n.height=t.height,n):new F(t.longitude,t.latitude,t.height)},F.equals=function(t,n){return t===n||e(t)&&e(n)&&t.longitude===n.longitude&&t.latitude===n.latitude&&t.height===n.height},F.equalsEpsilon=function(t,r,i){return i=n(i,0),t===r||e(t)&&e(r)&&Math.abs(t.longitude-r.longitude)<=i&&Math.abs(t.latitude-r.latitude)<=i&&Math.abs(t.height-r.height)<=i},F.ZERO=Object.freeze(new F(0,0,0)),F.prototype.clone=function(t){return F.clone(this,t)},F.prototype.equals=function(t){return F.equals(this,t)},F.prototype.equalsEpsilon=function(t,n){return F.equalsEpsilon(this,t,n)},F.prototype.toString=function(){return`(${this.longitude}, ${this.latitude}, ${this.height})`},Object.defineProperties(C.prototype,{radii:{get:function(){return this.v}},radiiSquared:{get:function(){return this.p}},radiiToTheFourth:{get:function(){return this.A}},oneOverRadii:{get:function(){return this.k}},oneOverRadiiSquared:{get:function(){return this.q}},minimumRadius:{get:function(){return this.$}},maximumRadius:{get:function(){return this.S}}}),C.clone=function(t,n){if(!e(t))return;const r=t.v;return e(n)?(x.clone(r,n.v),x.clone(t.p,n.p),x.clone(t.A,n.A),x.clone(t.k,n.k),x.clone(t.q,n.q),n.$=t.$,n.S=t.S,n.I=t.I,n):new C(r.x,r.y,r.z)},C.fromCartesian3=function(t,n){return e(n)||(n=new C),e(t)?(z(n,t.x,t.y,t.z),n):n},C.WGS84=Object.freeze(new C(6378137,6378137,6356752.314245179)),C.UNIT_SPHERE=Object.freeze(new C(1,1,1)),C.MOON=Object.freeze(new C(w.LUNAR_RADIUS,w.LUNAR_RADIUS,w.LUNAR_RADIUS)),C.F=C.WGS84,Object.defineProperties(C,{default:{get:function(){return C.F},set:function(t){i.typeOf.object("value",t),C.F=t,x.m=t.radiiSquared,F.R=t.oneOverRadii,F.P=t.oneOverRadiiSquared,F.j=t.I}}}),C.prototype.clone=function(t){return C.clone(this,t)},C.packedLength=x.packedLength,C.pack=function(t,e,r){return i.typeOf.object("value",t),i.defined("array",e),r=n(r,0),x.pack(t.v,e,r),e},C.unpack=function(t,e,r){i.defined("array",t),e=n(e,0);const o=x.unpack(t,e);return C.fromCartesian3(o,r)},C.prototype.geocentricSurfaceNormal=x.normalize,C.prototype.geodeticSurfaceNormalCartographic=function(t,n){i.typeOf.object("cartographic",t);const r=t.longitude,o=t.latitude,u=Math.cos(o),s=u*Math.cos(r),c=u*Math.sin(r),a=Math.sin(o);return e(n)||(n=new x),n.x=s,n.y=c,n.z=a,x.normalize(n,n)},C.prototype.geodeticSurfaceNormal=function(t,n){if(i.typeOf.object("cartesian",t),isNaN(t.x)||isNaN(t.y)||isNaN(t.z))throw new r("cartesian has a NaN component");if(!x.equalsEpsilon(t,x.ZERO,w.EPSILON14))return e(n)||(n=new x),n=x.multiplyComponents(t,this.q,n),x.normalize(n,n)};const D=new x,B=new x;C.prototype.cartographicToCartesian=function(t,n){const r=D,i=B;this.geodeticSurfaceNormalCartographic(t,r),x.multiplyComponents(this.p,r,i);const o=Math.sqrt(x.dot(r,i));return x.divideByScalar(i,o,i),x.multiplyByScalar(r,t.height,r),e(n)||(n=new x),x.add(i,r,n)},C.prototype.cartographicArrayToCartesianArray=function(t,n){i.defined("cartographics",t);const r=t.length;e(n)?n.length=r:n=new Array(r);for(let e=0;e<r;e++)n[e]=this.cartographicToCartesian(t[e],n[e]);return n};const L=new x,_=new x,V=new x;C.prototype.cartesianToCartographic=function(t,n){const r=this.scaleToGeodeticSurface(t,_);if(!e(r))return;const i=this.geodeticSurfaceNormal(r,L),o=x.subtract(t,r,V),u=Math.atan2(i.y,i.x),s=Math.asin(i.z),c=w.sign(x.dot(o,t))*x.magnitude(o);return e(n)?(n.longitude=u,n.latitude=s,n.height=c,n):new F(u,s,c)},C.prototype.cartesianArrayToCartographicArray=function(t,n){i.defined("cartesians",t);const r=t.length;e(n)?n.length=r:n=new Array(r);for(let e=0;e<r;++e)n[e]=this.cartesianToCartographic(t[e],n[e]);return n},C.prototype.scaleToGeodeticSurface=function(t,n){return j(t,this.k,this.q,this.I,n)},C.prototype.scaleToGeocentricSurface=function(t,n){i.typeOf.object("cartesian",t),e(n)||(n=new x);const r=t.x,o=t.y,u=t.z,s=this.q,c=1/Math.sqrt(r*r*s.x+o*o*s.y+u*u*s.z);return x.multiplyByScalar(t,c,n)},C.prototype.transformPositionToScaledSpace=function(t,n){return e(n)||(n=new x),x.multiplyComponents(t,this.k,n)},C.prototype.transformPositionFromScaledSpace=function(t,n){return e(n)||(n=new x),x.multiplyComponents(t,this.v,n)},C.prototype.equals=function(t){return this===t||e(t)&&x.equals(this.v,t.v)},C.prototype.toString=function(){return this.v.toString()},C.prototype.getSurfaceNormalIntersectionWithZAxis=function(t,o,u){if(i.typeOf.object("position",t),!w.equalsEpsilon(this.v.x,this.v.y,w.EPSILON15))throw new r("Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)");i.typeOf.number.greaterThan("Ellipsoid.radii.z",this.v.z,0),o=n(o,0);const s=this.O;if(e(u)||(u=new x),u.x=0,u.y=0,u.z=t.z*(1-s),!(Math.abs(u.z)>=this.v.z-o))return u};const H=new x;C.prototype.getLocalCurvature=function(t,n){i.typeOf.object("surfacePosition",t),e(n)||(n=new v);const r=this.getSurfaceNormalIntersectionWithZAxis(t,0,H),o=x.distance(t,r),u=o*(this.minimumRadius*o/this.maximumRadius**2)**2;return v.fromElements(1/o,1/u,n)};const Y=[.14887433898163,.43339539412925,.67940956829902,.86506336668898,.97390652851717,0],Z=[.29552422471475,.26926671930999,.21908636251598,.14945134915058,.066671344308684,0];function W(t,n,e){i.typeOf.number("a",t),i.typeOf.number("b",n),i.typeOf.func("func",e);const r=.5*(n+t),o=.5*(n-t);let u=0;for(let t=0;t<5;t++){const n=o*Y[t];u+=Z[t]*(e(r+n)+e(r-n))}return u*=o,u}function Q(t,e,r,i){this.x=n(t,0),this.y=n(e,0),this.z=n(r,0),this.w=n(i,0)}C.prototype.surfaceArea=function(t){i.typeOf.object("rectangle",t);const n=t.west;let e=t.east;const r=t.south,o=t.north;for(;e<n;)e+=w.TWO_PI;const u=this.p,s=u.x,c=u.y,a=u.z,f=s*c;return W(r,o,(function(t){const r=Math.cos(t),i=Math.sin(t);return Math.cos(t)*W(n,e,(function(t){const n=Math.cos(t),e=Math.sin(t);return Math.sqrt(f*i*i+a*(c*n*n+s*e*e)*r*r)}))}))},Q.fromElements=function(t,n,r,i,o){return e(o)?(o.x=t,o.y=n,o.z=r,o.w=i,o):new Q(t,n,r,i)},Q.fromColor=function(t,n){return i.typeOf.object("color",t),e(n)?(n.x=t.red,n.y=t.green,n.z=t.blue,n.w=t.alpha,n):new Q(t.red,t.green,t.blue,t.alpha)},Q.clone=function(t,n){if(e(t))return e(n)?(n.x=t.x,n.y=t.y,n.z=t.z,n.w=t.w,n):new Q(t.x,t.y,t.z,t.w)},Q.packedLength=4,Q.pack=function(t,e,r){return i.typeOf.object("value",t),i.defined("array",e),r=n(r,0),e[r++]=t.x,e[r++]=t.y,e[r++]=t.z,e[r]=t.w,e},Q.unpack=function(t,r,o){return i.defined("array",t),r=n(r,0),e(o)||(o=new Q),o.x=t[r++],o.y=t[r++],o.z=t[r++],o.w=t[r],o},Q.packArray=function(t,n){i.defined("array",t);const o=t.length,u=4*o;if(e(n)){if(!Array.isArray(n)&&n.length!==u)throw new r("If result is a typed array, it must have exactly array.length * 4 elements");n.length!==u&&(n.length=u)}else n=new Array(u);for(let e=0;e<o;++e)Q.pack(t[e],n,4*e);return n},Q.unpackArray=function(t,n){if(i.defined("array",t),i.typeOf.number.greaterThanOrEquals("array.length",t.length,4),t.length%4!=0)throw new r("array length must be a multiple of 4.");const o=t.length;e(n)?n.length=o/4:n=new Array(o/4);for(let e=0;e<o;e+=4){const r=e/4;n[r]=Q.unpack(t,e,n[r])}return n},Q.fromArray=Q.unpack,Q.maximumComponent=function(t){return i.typeOf.object("cartesian",t),Math.max(t.x,t.y,t.z,t.w)},Q.minimumComponent=function(t){return i.typeOf.object("cartesian",t),Math.min(t.x,t.y,t.z,t.w)},Q.minimumByComponent=function(t,n,e){return i.typeOf.object("first",t),i.typeOf.object("second",n),i.typeOf.object("result",e),e.x=Math.min(t.x,n.x),e.y=Math.min(t.y,n.y),e.z=Math.min(t.z,n.z),e.w=Math.min(t.w,n.w),e},Q.maximumByComponent=function(t,n,e){return i.typeOf.object("first",t),i.typeOf.object("second",n),i.typeOf.object("result",e),e.x=Math.max(t.x,n.x),e.y=Math.max(t.y,n.y),e.z=Math.max(t.z,n.z),e.w=Math.max(t.w,n.w),e},Q.clamp=function(t,n,e,r){i.typeOf.object("value",t),i.typeOf.object("min",n),i.typeOf.object("max",e),i.typeOf.object("result",r);const o=w.clamp(t.x,n.x,e.x),u=w.clamp(t.y,n.y,e.y),s=w.clamp(t.z,n.z,e.z),c=w.clamp(t.w,n.w,e.w);return r.x=o,r.y=u,r.z=s,r.w=c,r},Q.magnitudeSquared=function(t){return i.typeOf.object("cartesian",t),t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w},Q.magnitude=function(t){return Math.sqrt(Q.magnitudeSquared(t))};const J=new Q;Q.distance=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),Q.subtract(t,n,J),Q.magnitude(J)},Q.distanceSquared=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),Q.subtract(t,n,J),Q.magnitudeSquared(J)},Q.normalize=function(t,n){i.typeOf.object("cartesian",t),i.typeOf.object("result",n);const e=Q.magnitude(t);if(n.x=t.x/e,n.y=t.y/e,n.z=t.z/e,n.w=t.w/e,isNaN(n.x)||isNaN(n.y)||isNaN(n.z)||isNaN(n.w))throw new r("normalized result is not a number");return n},Q.dot=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),t.x*n.x+t.y*n.y+t.z*n.z+t.w*n.w},Q.multiplyComponents=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x*n.x,e.y=t.y*n.y,e.z=t.z*n.z,e.w=t.w*n.w,e},Q.divideComponents=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x/n.x,e.y=t.y/n.y,e.z=t.z/n.z,e.w=t.w/n.w,e},Q.add=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x+n.x,e.y=t.y+n.y,e.z=t.z+n.z,e.w=t.w+n.w,e},Q.subtract=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x-n.x,e.y=t.y-n.y,e.z=t.z-n.z,e.w=t.w-n.w,e},Q.multiplyByScalar=function(t,n,e){return i.typeOf.object("cartesian",t),i.typeOf.number("scalar",n),i.typeOf.object("result",e),e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e.w=t.w*n,e},Q.divideByScalar=function(t,n,e){return i.typeOf.object("cartesian",t),i.typeOf.number("scalar",n),i.typeOf.object("result",e),e.x=t.x/n,e.y=t.y/n,e.z=t.z/n,e.w=t.w/n,e},Q.negate=function(t,n){return i.typeOf.object("cartesian",t),i.typeOf.object("result",n),n.x=-t.x,n.y=-t.y,n.z=-t.z,n.w=-t.w,n},Q.abs=function(t,n){return i.typeOf.object("cartesian",t),i.typeOf.object("result",n),n.x=Math.abs(t.x),n.y=Math.abs(t.y),n.z=Math.abs(t.z),n.w=Math.abs(t.w),n};const G=new Q;Q.lerp=function(t,n,e,r){return i.typeOf.object("start",t),i.typeOf.object("end",n),i.typeOf.number("t",e),i.typeOf.object("result",r),Q.multiplyByScalar(n,e,G),r=Q.multiplyByScalar(t,1-e,r),Q.add(G,r,r)};const X=new Q;Q.mostOrthogonalAxis=function(t,n){i.typeOf.object("cartesian",t),i.typeOf.object("result",n);const e=Q.normalize(t,X);return Q.abs(e,e),e.x<=e.y?e.x<=e.z?e.x<=e.w?Q.clone(Q.UNIT_X,n):Q.clone(Q.UNIT_W,n):e.z<=e.w?Q.clone(Q.UNIT_Z,n):Q.clone(Q.UNIT_W,n):e.y<=e.z?e.y<=e.w?Q.clone(Q.UNIT_Y,n):Q.clone(Q.UNIT_W,n):e.z<=e.w?Q.clone(Q.UNIT_Z,n):Q.clone(Q.UNIT_W,n)},Q.equals=function(t,n){return t===n||e(t)&&e(n)&&t.x===n.x&&t.y===n.y&&t.z===n.z&&t.w===n.w},Q.equalsArray=function(t,n,e){return t.x===n[e]&&t.y===n[e+1]&&t.z===n[e+2]&&t.w===n[e+3]},Q.equalsEpsilon=function(t,n,r,i){return t===n||e(t)&&e(n)&&w.equalsEpsilon(t.x,n.x,r,i)&&w.equalsEpsilon(t.y,n.y,r,i)&&w.equalsEpsilon(t.z,n.z,r,i)&&w.equalsEpsilon(t.w,n.w,r,i)},Q.ZERO=Object.freeze(new Q(0,0,0,0)),Q.ONE=Object.freeze(new Q(1,1,1,1)),Q.UNIT_X=Object.freeze(new Q(1,0,0,0)),Q.UNIT_Y=Object.freeze(new Q(0,1,0,0)),Q.UNIT_Z=Object.freeze(new Q(0,0,1,0)),Q.UNIT_W=Object.freeze(new Q(0,0,0,1)),Q.prototype.clone=function(t){return Q.clone(this,t)},Q.prototype.equals=function(t){return Q.equals(this,t)},Q.prototype.equalsEpsilon=function(t,n,e){return Q.equalsEpsilon(this,t,n,e)},Q.prototype.toString=function(){return`(${this.x}, ${this.y}, ${this.z}, ${this.w})`};const K=new Float32Array(1),tt=new Uint8Array(K.buffer),nt=new Uint32Array([287454020]),et=68===new Uint8Array(nt.buffer)[0];function rt(t,n,e){i.defined("array",t),i.defined("itemToFind",n),i.defined("comparator",e);let r,o,u=0,s=t.length-1;for(;u<=s;)if(r=~~((u+s)/2),o=e(t[r],n),o<0)u=r+1;else{if(!(o>0))return r;s=r-1}return~(s+1)}function it(t,n,e,r,i){this.xPoleWander=t,this.yPoleWander=n,this.xPoleOffset=e,this.yPoleOffset=r,this.ut1MinusUtc=i}function ot(t){if(null===t||isNaN(t))throw new r("year is required and must be a number.");return t%4==0&&t%100!=0||t%400==0}Q.packFloat=function(t,n){return i.typeOf.number("value",t),e(n)||(n=new Q),K[0]=t,et?(n.x=tt[0],n.y=tt[1],n.z=tt[2],n.w=tt[3]):(n.x=tt[3],n.y=tt[2],n.z=tt[1],n.w=tt[0]),n},Q.unpackFloat=function(t){return i.typeOf.object("packedFloat",t),et?(tt[0]=t.x,tt[1]=t.y,tt[2]=t.z,tt[3]=t.w):(tt[0]=t.w,tt[1]=t.z,tt[2]=t.y,tt[3]=t.x),K[0]};const ut=[31,28,31,30,31,30,31,31,30,31,30,31];function st(t,e,o,u,s,c,a,f){t=n(t,1),e=n(e,1),o=n(o,1),u=n(u,0),s=n(s,0),c=n(c,0),a=n(a,0),f=n(f,!1),i.typeOf.number.greaterThanOrEquals("Year",t,1),i.typeOf.number.lessThanOrEquals("Year",t,9999),i.typeOf.number.greaterThanOrEquals("Month",e,1),i.typeOf.number.lessThanOrEquals("Month",e,12),i.typeOf.number.greaterThanOrEquals("Day",o,1),i.typeOf.number.lessThanOrEquals("Day",o,31),i.typeOf.number.greaterThanOrEquals("Hour",u,0),i.typeOf.number.lessThanOrEquals("Hour",u,23),i.typeOf.number.greaterThanOrEquals("Minute",s,0),i.typeOf.number.lessThanOrEquals("Minute",s,59),i.typeOf.bool("IsLeapSecond",f),i.typeOf.number.greaterThanOrEquals("Second",c,0),i.typeOf.number.lessThanOrEquals("Second",c,f?60:59),i.typeOf.number.greaterThanOrEquals("Millisecond",a,0),i.typeOf.number.lessThan("Millisecond",a,1e3),function(){const n=2===e&&ot(t)?ut[e-1]+1:ut[e-1];if(o>n)throw new r("Month and Day represents invalid date")}(),this.year=t,this.month=e,this.day=o,this.hour=u,this.minute=s,this.second=c,this.millisecond=a,this.isLeapSecond=f}function ct(t,n){this.julianDate=t,this.offset=n}var at=Object.freeze({SECONDS_PER_MILLISECOND:.001,SECONDS_PER_MINUTE:60,MINUTES_PER_HOUR:60,HOURS_PER_DAY:24,SECONDS_PER_HOUR:3600,MINUTES_PER_DAY:1440,SECONDS_PER_DAY:86400,DAYS_PER_JULIAN_CENTURY:36525,PICOSECOND:1e-9,MODIFIED_JULIAN_DATE_DIFFERENCE:2400000.5}),ft=Object.freeze({UTC:0,TAI:1});const ht=new st,lt=[31,28,31,30,31,30,31,31,30,31,30,31];function dt(t,n){return It.compare(t.julianDate,n.julianDate)}const wt=new ct;function mt(t){wt.julianDate=t;const n=It.leapSeconds;let e=rt(n,wt,dt);e<0&&(e=~e),e>=n.length&&(e=n.length-1);let r=n[e].offset;e>0&&It.secondsDifference(n[e].julianDate,t)>r&&(e--,r=n[e].offset),It.addSeconds(t,r,t)}function gt(t,n){wt.julianDate=t;const e=It.leapSeconds;let r=rt(e,wt,dt);if(r<0&&(r=~r),0===r)return It.addSeconds(t,-e[0].offset,n);if(r>=e.length)return It.addSeconds(t,-e[r-1].offset,n);const i=It.secondsDifference(e[r].julianDate,t);return 0===i?It.addSeconds(t,-e[r].offset,n):i<=1?void 0:It.addSeconds(t,-e[--r].offset,n)}function vt(t,n,e){const r=n/at.SECONDS_PER_DAY|0;return t+=r,(n-=at.SECONDS_PER_DAY*r)<0&&(t--,n+=at.SECONDS_PER_DAY),e.dayNumber=t,e.secondsOfDay=n,e}function pt(t,n,e,r,i,o,u){const s=(n-14)/12|0,c=t+4800+s;let a=(1461*c/4|0)+(367*(n-2-12*s)/12|0)-(3*((c+100)/100|0)/4|0)+e-32075;(r-=12)<0&&(r+=24);const f=o+(r*at.SECONDS_PER_HOUR+i*at.SECONDS_PER_MINUTE+u*at.SECONDS_PER_MILLISECOND);return f>=43200&&(a-=1),[a,f]}const yt=/^(\\d{4})$/,bt=/^(\\d{4})-(\\d{2})$/,Mt=/^(\\d{4})-?(\\d{3})$/,At=/^(\\d{4})-?W(\\d{2})-?(\\d{1})?$/,xt=/^(\\d{4})-?(\\d{2})-?(\\d{2})$/,Et=/([Z+\\-])?(\\d{2})?:?(\\d{2})?$/,kt=/^(\\d{2})(\\.\\d+)?/.source+Et.source,qt=/^(\\d{2}):?(\\d{2})(\\.\\d+)?/.source+Et.source,$t=/^(\\d{2}):?(\\d{2}):?(\\d{2})(\\.\\d+)?/.source+Et.source,St="Invalid ISO 8601 date.";function It(t,e,r){this.dayNumber=void 0,this.secondsOfDay=void 0,t=n(t,0),e=n(e,0),r=n(r,ft.UTC);const i=0|t;vt(i,e+=(t-i)*at.SECONDS_PER_DAY,this),r===ft.UTC&&mt(this)}It.fromGregorianDate=function(t,n){if(!(t instanceof st))throw new r("date must be a valid GregorianDate.");const i=pt(t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond);return e(n)?(vt(i[0],i[1],n),mt(n),n):new It(i[0],i[1],ft.UTC)},It.fromDate=function(t,n){if(!(t instanceof Date)||isNaN(t.getTime()))throw new r("date must be a valid JavaScript Date.");const i=pt(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds());return e(n)?(vt(i[0],i[1],n),mt(n),n):new It(i[0],i[1],ft.UTC)},It.fromIso8601=function(t,n){if("string"!=typeof t)throw new r(St);let i,o=(t=t.replace(",",".")).split("T"),u=1,s=1,c=0,a=0,f=0,h=0;const l=o[0],d=o[1];let w,m,g,v;if(!e(l))throw new r(St);if(o=l.match(xt),null!==o){if(g=l.split("-").length-1,g>0&&2!==g)throw new r(St);i=+o[1],u=+o[2],s=+o[3]}else if(o=l.match(bt),null!==o)i=+o[1],u=+o[2];else if(o=l.match(yt),null!==o)i=+o[1];else{let t;if(o=l.match(Mt),null!==o){if(i=+o[1],t=+o[2],m=ot(i),t<1||m&&t>366||!m&&t>365)throw new r(St)}else{if(o=l.match(At),null===o)throw new r(St);{i=+o[1];const n=+o[2],u=+o[3]||0;if(g=l.split("-").length-1,g>0&&(!e(o[3])&&1!==g||e(o[3])&&2!==g))throw new r(St);t=7*n+u-new Date(Date.UTC(i,0,4)).getUTCDay()-3}}w=new Date(Date.UTC(i,0,1)),w.setUTCDate(t),u=w.getUTCMonth()+1,s=w.getUTCDate()}if(m=ot(i),u<1||u>12||s<1||(2!==u||!m)&&s>lt[u-1]||m&&2===u&&s>29)throw new r(St);if(e(d)){if(o=d.match($t),null!==o){if(g=d.split(":").length-1,g>0&&2!==g&&3!==g)throw new r(St);c=+o[1],a=+o[2],f=+o[3],h=1e3*+(o[4]||0),v=5}else if(o=d.match(qt),null!==o){if(g=d.split(":").length-1,g>2)throw new r(St);c=+o[1],a=+o[2],f=60*+(o[3]||0),v=4}else{if(o=d.match(kt),null===o)throw new r(St);c=+o[1],a=60*+(o[2]||0),v=3}if(a>=60||f>=61||c>24||24===c&&(a>0||f>0||h>0))throw new r(St);const t=o[v],n=+o[v+1],e=+(o[v+2]||0);switch(t){case"+":c-=n,a-=e;break;case"-":c+=n,a+=e;break;case"Z":break;default:a+=new Date(Date.UTC(i,u-1,s,c,a)).getTimezoneOffset()}}const p=60===f;for(p&&f--;a>=60;)a-=60,c++;for(;c>=24;)c-=24,s++;for(w=m&&2===u?29:lt[u-1];s>w;)s-=w,u++,u>12&&(u-=12,i++),w=m&&2===u?29:lt[u-1];for(;a<0;)a+=60,c--;for(;c<0;)c+=24,s--;for(;s<1;)u--,u<1&&(u+=12,i--),w=m&&2===u?29:lt[u-1],s+=w;const y=pt(i,u,s,c,a,f,h);return e(n)?(vt(y[0],y[1],n),mt(n)):n=new It(y[0],y[1],ft.UTC),p&&It.addSeconds(n,1,n),n},It.now=function(t){return It.fromDate(new Date,t)};const Ot=new It(0,0,ft.TAI);It.toGregorianDate=function(t,n){if(!e(t))throw new r("julianDate is required.");let i=!1,o=gt(t,Ot);e(o)||(It.addSeconds(t,-1,Ot),o=gt(Ot,Ot),i=!0);let u=o.dayNumber;const s=o.secondsOfDay;s>=43200&&(u+=1);let c=u+68569|0;const a=4*c/146097|0;c=c-((146097*a+3)/4|0)|0;const f=4e3*(c+1)/1461001|0;c=c-(1461*f/4|0)+31|0;const h=80*c/2447|0,l=c-(2447*h/80|0)|0;c=h/11|0;const d=h+2-12*c|0,w=100*(a-49)+f+c|0;let m=s/at.SECONDS_PER_HOUR|0,g=s-m*at.SECONDS_PER_HOUR;const v=g/at.SECONDS_PER_MINUTE|0;g-=v*at.SECONDS_PER_MINUTE;let p=0|g;const y=(g-p)/at.SECONDS_PER_MILLISECOND;return m+=12,m>23&&(m-=24),i&&(p+=1),e(n)?(n.year=w,n.month=d,n.day=l,n.hour=m,n.minute=v,n.second=p,n.millisecond=y,n.isLeapSecond=i,n):new st(w,d,l,m,v,p,y,i)},It.toDate=function(t){if(!e(t))throw new r("julianDate is required.");const n=It.toGregorianDate(t,ht);let i=n.second;return n.isLeapSecond&&(i-=1),new Date(Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,i,n.millisecond))},It.toIso8601=function(t,n){if(!e(t))throw new r("julianDate is required.");const i=It.toGregorianDate(t,ht);let o=i.year,u=i.month,s=i.day,c=i.hour;const a=i.minute,f=i.second,h=i.millisecond;let l;return 1e4===o&&1===u&&1===s&&0===c&&0===a&&0===f&&0===h&&(o=9999,u=12,s=31,c=24),e(n)||0===h?e(n)&&0!==n?(l=(.01*h).toFixed(n).replace(".","").slice(0,n),`${o.toString().padStart(4,"0")}-${u.toString().padStart(2,"0")}-${s.toString().padStart(2,"0")}T${c.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}.${l}Z`):`${o.toString().padStart(4,"0")}-${u.toString().padStart(2,"0")}-${s.toString().padStart(2,"0")}T${c.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}Z`:(l=(.01*h).toString().replace(".",""),`${o.toString().padStart(4,"0")}-${u.toString().padStart(2,"0")}-${s.toString().padStart(2,"0")}T${c.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}.${l}Z`)},It.clone=function(t,n){if(e(t))return e(n)?(n.dayNumber=t.dayNumber,n.secondsOfDay=t.secondsOfDay,n):new It(t.dayNumber,t.secondsOfDay,ft.TAI)},It.compare=function(t,n){if(!e(t))throw new r("left is required.");if(!e(n))throw new r("right is required.");const i=t.dayNumber-n.dayNumber;return 0!==i?i:t.secondsOfDay-n.secondsOfDay},It.equals=function(t,n){return t===n||e(t)&&e(n)&&t.dayNumber===n.dayNumber&&t.secondsOfDay===n.secondsOfDay},It.equalsEpsilon=function(t,r,i){return i=n(i,0),t===r||e(t)&&e(r)&&Math.abs(It.secondsDifference(t,r))<=i},It.totalDays=function(t){if(!e(t))throw new r("julianDate is required.");return t.dayNumber+t.secondsOfDay/at.SECONDS_PER_DAY},It.secondsDifference=function(t,n){if(!e(t))throw new r("left is required.");if(!e(n))throw new r("right is required.");return(t.dayNumber-n.dayNumber)*at.SECONDS_PER_DAY+(t.secondsOfDay-n.secondsOfDay)},It.daysDifference=function(t,n){if(!e(t))throw new r("left is required.");if(!e(n))throw new r("right is required.");return t.dayNumber-n.dayNumber+(t.secondsOfDay-n.secondsOfDay)/at.SECONDS_PER_DAY},It.computeTaiMinusUtc=function(t){wt.julianDate=t;const n=It.leapSeconds;let e=rt(n,wt,dt);return e<0&&(e=~e,--e,e<0&&(e=0)),n[e].offset},It.addSeconds=function(t,n,i){if(!e(t))throw new r("julianDate is required.");if(!e(n))throw new r("seconds is required.");if(!e(i))throw new r("result is required.");return vt(t.dayNumber,t.secondsOfDay+n,i)},It.addMinutes=function(t,n,i){if(!e(t))throw new r("julianDate is required.");if(!e(n))throw new r("minutes is required.");if(!e(i))throw new r("result is required.");const o=t.secondsOfDay+n*at.SECONDS_PER_MINUTE;return vt(t.dayNumber,o,i)},It.addHours=function(t,n,i){if(!e(t))throw new r("julianDate is required.");if(!e(n))throw new r("hours is required.");if(!e(i))throw new r("result is required.");const o=t.secondsOfDay+n*at.SECONDS_PER_HOUR;return vt(t.dayNumber,o,i)},It.addDays=function(t,n,i){if(!e(t))throw new r("julianDate is required.");if(!e(n))throw new r("days is required.");if(!e(i))throw new r("result is required.");return vt(t.dayNumber+n,t.secondsOfDay,i)},It.lessThan=function(t,n){return It.compare(t,n)<0},It.lessThanOrEquals=function(t,n){return It.compare(t,n)<=0},It.greaterThan=function(t,n){return It.compare(t,n)>0},It.greaterThanOrEquals=function(t,n){return It.compare(t,n)>=0},It.prototype.clone=function(t){return It.clone(this,t)},It.prototype.equals=function(t){return It.equals(this,t)},It.prototype.equalsEpsilon=function(t,n){return It.equalsEpsilon(this,t,n)},It.prototype.toString=function(){return It.toIso8601(this)},It.leapSeconds=[new ct(new It(2441317,43210,ft.TAI),10),new ct(new It(2441499,43211,ft.TAI),11),new ct(new It(2441683,43212,ft.TAI),12),new ct(new It(2442048,43213,ft.TAI),13),new ct(new It(2442413,43214,ft.TAI),14),new ct(new It(2442778,43215,ft.TAI),15),new ct(new It(2443144,43216,ft.TAI),16),new ct(new It(2443509,43217,ft.TAI),17),new ct(new It(2443874,43218,ft.TAI),18),new ct(new It(2444239,43219,ft.TAI),19),new ct(new It(2444786,43220,ft.TAI),20),new ct(new It(2445151,43221,ft.TAI),21),new ct(new It(2445516,43222,ft.TAI),22),new ct(new It(2446247,43223,ft.TAI),23),new ct(new It(2447161,43224,ft.TAI),24),new ct(new It(2447892,43225,ft.TAI),25),new ct(new It(2448257,43226,ft.TAI),26),new ct(new It(2448804,43227,ft.TAI),27),new ct(new It(2449169,43228,ft.TAI),28),new ct(new It(2449534,43229,ft.TAI),29),new ct(new It(2450083,43230,ft.TAI),30),new ct(new It(2450630,43231,ft.TAI),31),new ct(new It(2451179,43232,ft.TAI),32),new ct(new It(2453736,43233,ft.TAI),33),new ct(new It(2454832,43234,ft.TAI),34),new ct(new It(2456109,43235,ft.TAI),35),new ct(new It(2457204,43236,ft.TAI),36),new ct(new It(2457754,43237,ft.TAI),37)];var Rt,Pt,jt,Ft,Nt,Ut,Tt,zt={exports:{}},Ct={exports:{}},Dt=Ct.exports,Bt={exports:{}},Lt=Bt.exports,_t={exports:{}},Vt=_t.exports,Ht=(Ft||(Ft=1,Ut=zt.exports,Tt=function(t,n,e,r){var i=r&&r.URI;function o(t,n){var e=arguments.length>=1;if(!(this instanceof o))return e?arguments.length>=2?new o(t,n):new o(t):new o;if(void 0===t){if(e)throw new TypeError("undefined is not a valid argument for URI");t="undefined"!=typeof location?location.href+"":""}if(null===t&&e)throw new TypeError("null is not a valid argument for URI");return this.href(t),void 0!==n?this.absoluteTo(n):this}o.version="1.19.11";var u=o.prototype,s={}.hasOwnProperty;function c(t){return t.replace(/([.*+?^=!:${}()|[\\]\\/\\\\])/g,"\\\\$1")}function a(t){return void 0===t?"Undefined":String({}.toString.call(t)).slice(8,-1)}function f(t){return"Array"===a(t)}function h(t,n){var e,r,i={};if("RegExp"===a(n))i=null;else if(f(n))for(e=0,r=n.length;e<r;e++)i[n[e]]=!0;else i[n]=!0;for(e=0,r=t.length;e<r;e++)(i&&void 0!==i[t[e]]||!i&&n.test(t[e]))&&(t.splice(e,1),r--,e--);return t}function l(t,n){var e,r;if(f(n)){for(e=0,r=n.length;e<r;e++)if(!l(t,n[e]))return!1;return!0}var i=a(n);for(e=0,r=t.length;e<r;e++)if("RegExp"===i){if("string"==typeof t[e]&&t[e].match(n))return!0}else if(t[e]===n)return!0;return!1}function d(t,n){if(!f(t)||!f(n))return!1;if(t.length!==n.length)return!1;t.sort(),n.sort();for(var e=0,r=t.length;e<r;e++)if(t[e]!==n[e])return!1;return!0}function w(t){return t.replace(/^\\/+|\\/+$/g,"")}function m(t){return escape(t)}function g(t){return encodeURIComponent(t).replace(/[!\'()*]/g,m).replace(/\\*/g,"%2A")}o.U=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,preventInvalidHostname:o.preventInvalidHostname,duplicateQueryParameters:o.duplicateQueryParameters,escapeQuerySpace:o.escapeQuerySpace}},o.preventInvalidHostname=!1,o.duplicateQueryParameters=!1,o.escapeQuerySpace=!0,o.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,o.idn_expression=/[^a-z0-9\\._-]/i,o.punycode_expression=/(xn--)/i,o.ip4_expression=/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/,o.ip6_expression=/^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$/,o.find_uri_expression=/\\b((?:[a-z][\\w-]+:(?:\\/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}\\/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«»“”‘’]))/gi,o.findUri={start:/\\b(?:([a-z][a-z0-9.+-]*:\\/\\/)|www\\.)/gi,end:/[\\s\\r\\n]|$/,trim:/[`!()\\[\\]{};:\'".,<>?«»“”„‘’]+$/,parens:/(\\([^\\)]*\\)|\\[[^\\]]*\\]|\\{[^}]*\\}|<[^>]*>)/g},o.leading_whitespace_expression=/^[\\x00-\\x20\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]+/,o.ascii_tab_whitespace=/[\\u0009\\u000A\\u000D]+/g,o.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},o.hostProtocols=["http","https"],o.invalid_hostname_characters=/[^a-zA-Z0-9\\.\\-:_]/,o.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"},o.getDomAttribute=function(t){if(t&&t.nodeName){var n=t.nodeName.toLowerCase();if("input"!==n||"image"===t.type)return o.domAttributes[n]}},o.encode=g,o.decode=decodeURIComponent,o.iso8859=function(){o.encode=escape,o.decode=unescape},o.unicode=function(){o.encode=g,o.decode=decodeURIComponent},o.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\\/\\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"\'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/gi,map:{"%21":"!","%24":"$","%27":"\'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\\/\\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}},o.encodeQuery=function(t,n){var e=o.encode(t+"");return void 0===n&&(n=o.escapeQuerySpace),n?e.replace(/%20/g,"+"):e},o.decodeQuery=function(t,n){t+="",void 0===n&&(n=o.escapeQuerySpace);try{return o.decode(n?t.replace(/\\+/g,"%20"):t)}catch(n){return t}};var v,p={encode:"encode",decode:"decode"},y=function(t,n){return function(e){try{return o[n](e+"").replace(o.characters[t][n].expression,(function(e){return o.characters[t][n].map[e]}))}catch(t){return e}}};for(v in p)o[v+"PathSegment"]=y("pathname",p[v]),o[v+"UrnPathSegment"]=y("urnpath",p[v]);var b=function(t,n,e){return function(r){var i;i=e?function(t){return o[n](o[e](t))}:o[n];for(var u=(r+"").split(t),s=0,c=u.length;s<c;s++)u[s]=i(u[s]);return u.join(t)}};function M(t){return function(n,e){return void 0===n?this.U[t]||"":(this.U[t]=n||null,this.build(!e),this)}}function A(t,n){return function(e,r){return void 0===e?this.U[t]||"":(null!==e&&(e+="").charAt(0)===n&&(e=e.substring(1)),this.U[t]=e,this.build(!r),this)}}o.decodePath=b("/","decodePathSegment"),o.decodeUrnPath=b(":","decodeUrnPathSegment"),o.recodePath=b("/","encodePathSegment","decode"),o.recodeUrnPath=b(":","encodeUrnPathSegment","decode"),o.encodeReserved=y("reserved","encode"),o.parse=function(t,n){var e;return n||(n={preventInvalidHostname:o.preventInvalidHostname}),(e=(t=(t=t.replace(o.leading_whitespace_expression,"")).replace(o.ascii_tab_whitespace,"")).indexOf("#"))>-1&&(n.fragment=t.substring(e+1)||null,t=t.substring(0,e)),(e=t.indexOf("?"))>-1&&(n.query=t.substring(e+1)||null,t=t.substring(0,e)),"//"===(t=(t=t.replace(/^(https?|ftp|wss?)?:+[/\\\\]*/i,"$1://")).replace(/^[/\\\\]{2,}/i,"//")).substring(0,2)?(n.protocol=null,t=t.substring(2),t=o.parseAuthority(t,n)):(e=t.indexOf(":"))>-1&&(n.protocol=t.substring(0,e)||null,n.protocol&&!n.protocol.match(o.protocol_expression)?n.protocol=void 0:"//"===t.substring(e+1,e+3).replace(/\\\\/g,"/")?(t=t.substring(e+3),t=o.parseAuthority(t,n)):(t=t.substring(e+1),n.urn=!0)),n.path=t,n},o.parseHost=function(t,n){t||(t="");var e,r,i=(t=t.replace(/\\\\/g,"/")).indexOf("/");if(-1===i&&(i=t.length),"["===t.charAt(0))e=t.indexOf("]"),n.hostname=t.substring(1,e)||null,n.port=t.substring(e+2,i)||null,"/"===n.port&&(n.port=null);else{var u=t.indexOf(":"),s=t.indexOf("/"),c=t.indexOf(":",u+1);-1!==c&&(-1===s||c<s)?(n.hostname=t.substring(0,i)||null,n.port=null):(r=t.substring(0,i).split(":"),n.hostname=r[0]||null,n.port=r[1]||null)}return n.hostname&&"/"!==t.substring(i).charAt(0)&&(i++,t="/"+t),n.preventInvalidHostname&&o.ensureValidHostname(n.hostname,n.protocol),n.port&&o.ensureValidPort(n.port),t.substring(i)||"/"},o.parseAuthority=function(t,n){return t=o.parseUserinfo(t,n),o.parseHost(t,n)},o.parseUserinfo=function(t,n){var e=t;-1!==t.indexOf("\\\\")&&(t=t.replace(/\\\\/g,"/"));var r,i=t.indexOf("/"),u=t.lastIndexOf("@",i>-1?i:t.length-1);return u>-1&&(-1===i||u<i)?(r=t.substring(0,u).split(":"),n.username=r[0]?o.decode(r[0]):null,r.shift(),n.password=r[0]?o.decode(r.join(":")):null,t=e.substring(u+1)):(n.username=null,n.password=null),t},o.parseQuery=function(t,n){if(!t)return{};if(!(t=t.replace(/&+/g,"&").replace(/^\\?*&*|&+$/g,"")))return{};for(var e,r,i,u={},c=t.split("&"),a=c.length,f=0;f<a;f++)e=c[f].split("="),r=o.decodeQuery(e.shift(),n),i=e.length?o.decodeQuery(e.join("="),n):null,"__proto__"!==r&&(s.call(u,r)?("string"!=typeof u[r]&&null!==u[r]||(u[r]=[u[r]]),u[r].push(i)):u[r]=i);return u},o.build=function(t){var n="",e=!1;return t.protocol&&(n+=t.protocol+":"),t.urn||!n&&!t.hostname||(n+="//",e=!0),n+=o.buildAuthority(t)||"","string"==typeof t.path&&("/"!==t.path.charAt(0)&&e&&(n+="/"),n+=t.path),"string"==typeof t.query&&t.query&&(n+="?"+t.query),"string"==typeof t.fragment&&t.fragment&&(n+="#"+t.fragment),n},o.buildHost=function(t){var n="";return t.hostname?(o.ip6_expression.test(t.hostname)?n+="["+t.hostname+"]":n+=t.hostname,t.port&&(n+=":"+t.port),n):""},o.buildAuthority=function(t){return o.buildUserinfo(t)+o.buildHost(t)},o.buildUserinfo=function(t){var n="";return t.username&&(n+=o.encode(t.username)),t.password&&(n+=":"+o.encode(t.password)),n&&(n+="@"),n},o.buildQuery=function(t,n,e){var r,i,u,c,a="";for(i in t)if("__proto__"!==i&&s.call(t,i))if(f(t[i]))for(r={},u=0,c=t[i].length;u<c;u++)void 0!==t[i][u]&&void 0===r[t[i][u]+""]&&(a+="&"+o.buildQueryParameter(i,t[i][u],e),!0!==n&&(r[t[i][u]+""]=!0));else void 0!==t[i]&&(a+="&"+o.buildQueryParameter(i,t[i],e));return a.substring(1)},o.buildQueryParameter=function(t,n,e){return o.encodeQuery(t,e)+(null!==n?"="+o.encodeQuery(n,e):"")},o.addQuery=function(t,n,e){if("object"==typeof n)for(var r in n)s.call(n,r)&&o.addQuery(t,r,n[r]);else{if("string"!=typeof n)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");if(void 0===t[n])return void(t[n]=e);"string"==typeof t[n]&&(t[n]=[t[n]]),f(e)||(e=[e]),t[n]=(t[n]||[]).concat(e)}},o.setQuery=function(t,n,e){if("object"==typeof n)for(var r in n)s.call(n,r)&&o.setQuery(t,r,n[r]);else{if("string"!=typeof n)throw new TypeError("URI.setQuery() accepts an object, string as the name parameter");t[n]=void 0===e?null:e}},o.removeQuery=function(t,n,e){var r,i,u;if(f(n))for(r=0,i=n.length;r<i;r++)t[n[r]]=void 0;else if("RegExp"===a(n))for(u in t)n.test(u)&&(t[u]=void 0);else if("object"==typeof n)for(u in n)s.call(n,u)&&o.removeQuery(t,u,n[u]);else{if("string"!=typeof n)throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");void 0!==e?"RegExp"===a(e)?!f(t[n])&&e.test(t[n])?t[n]=void 0:t[n]=h(t[n],e):t[n]!==String(e)||f(e)&&1!==e.length?f(t[n])&&(t[n]=h(t[n],e)):t[n]=void 0:t[n]=void 0}},o.hasQuery=function(t,n,e,r){switch(a(n)){case"String":break;case"RegExp":for(var i in t)if(s.call(t,i)&&n.test(i)&&(void 0===e||o.hasQuery(t,i,e)))return!0;return!1;case"Object":for(var u in n)if(s.call(n,u)&&!o.hasQuery(t,u,n[u]))return!1;return!0;default:throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter")}switch(a(e)){case"Undefined":return n in t;case"Boolean":return e===Boolean(f(t[n])?t[n].length:t[n]);case"Function":return!!e(t[n],n,t);case"Array":return!!f(t[n])&&(r?l:d)(t[n],e);case"RegExp":return f(t[n])?!!r&&l(t[n],e):Boolean(t[n]&&t[n].match(e));case"Number":e=String(e);case"String":return f(t[n])?!!r&&l(t[n],e):t[n]===e;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter")}},o.joinPaths=function(){for(var t=[],n=[],e=0,r=0;r<arguments.length;r++){var i=new o(arguments[r]);t.push(i);for(var u=i.segment(),s=0;s<u.length;s++)"string"==typeof u[s]&&n.push(u[s]),u[s]&&e++}if(!n.length||!e)return new o("");var c=new o("").segment(n);return""!==t[0].path()&&"/"!==t[0].path().slice(0,1)||c.path("/"+c.path()),c.normalize()},o.commonPath=function(t,n){var e,r=Math.min(t.length,n.length);for(e=0;e<r;e++)if(t.charAt(e)!==n.charAt(e)){e--;break}return e<1?t.charAt(0)===n.charAt(0)&&"/"===t.charAt(0)?"/":"":("/"===t.charAt(e)&&"/"===n.charAt(e)||(e=t.substring(0,e).lastIndexOf("/")),t.substring(0,e+1))},o.withinString=function(t,n,e){e||(e={});var r=e.start||o.findUri.start,i=e.end||o.findUri.end,u=e.trim||o.findUri.trim,s=e.parens||o.findUri.parens,c=/[a-z0-9-]=["\']?$/i;for(r.lastIndex=0;;){var a=r.exec(t);if(!a)break;var f=a.index;if(e.ignoreHtml){var h=t.slice(Math.max(f-3,0),f);if(h&&c.test(h))continue}for(var l=f+t.slice(f).search(i),d=t.slice(f,l),w=-1;;){var m=s.exec(d);if(!m)break;var g=m.index+m[0].length;w=Math.max(w,g)}if(!((d=w>-1?d.slice(0,w)+d.slice(w).replace(u,""):d.replace(u,"")).length<=a[0].length||e.ignore&&e.ignore.test(d))){var v=n(d,f,l=f+d.length,t);void 0!==v?(v=String(v),t=t.slice(0,f)+v+t.slice(l),r.lastIndex=f+v.length):r.lastIndex=l}}return r.lastIndex=0,t},o.ensureValidHostname=function(n,e){var r=!!n,i=!1;if(!!e&&(i=l(o.hostProtocols,e)),i&&!r)throw new TypeError("Hostname cannot be empty, if protocol is "+e);if(n&&n.match(o.invalid_hostname_characters)){if(!t)throw new TypeError(\'Hostname "\'+n+\'" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available\');if(t.toASCII(n).match(o.invalid_hostname_characters))throw new TypeError(\'Hostname "\'+n+\'" contains characters other than [A-Z0-9.-:_]\')}},o.ensureValidPort=function(t){if(t){var n=Number(t);if(!(/^[0-9]+$/.test(n)&&n>0&&n<65536))throw new TypeError(\'Port "\'+t+\'" is not a valid port\')}},o.noConflict=function(t){if(t){var n={URI:this.noConflict()};return r.URITemplate&&"function"==typeof r.URITemplate.noConflict&&(n.URITemplate=r.URITemplate.noConflict()),r.IPv6&&"function"==typeof r.IPv6.noConflict&&(n.IPv6=r.IPv6.noConflict()),r.SecondLevelDomains&&"function"==typeof r.SecondLevelDomains.noConflict&&(n.SecondLevelDomains=r.SecondLevelDomains.noConflict()),n}return r.URI===this&&(r.URI=i),this},u.build=function(t){return!0===t?this.T=!0:(void 0===t||this.T)&&(this.C=o.build(this.U),this.T=!1),this},u.clone=function(){return new o(this)},u.valueOf=u.toString=function(){return this.build(!1).C},u.protocol=M("protocol"),u.username=M("username"),u.password=M("password"),u.hostname=M("hostname"),u.port=M("port"),u.query=A("query","?"),u.fragment=A("fragment","#"),u.search=function(t,n){var e=this.query(t,n);return"string"==typeof e&&e.length?"?"+e:e},u.hash=function(t,n){var e=this.fragment(t,n);return"string"==typeof e&&e.length?"#"+e:e},u.pathname=function(t,n){if(void 0===t||!0===t){var e=this.U.path||(this.U.hostname?"/":"");return t?(this.U.urn?o.decodeUrnPath:o.decodePath)(e):e}return this.U.urn?this.U.path=t?o.recodeUrnPath(t):"":this.U.path=t?o.recodePath(t):"/",this.build(!n),this},u.path=u.pathname,u.href=function(t,n){var e;if(void 0===t)return this.toString();this.C="",this.U=o.U();var r=t instanceof o,i="object"==typeof t&&(t.hostname||t.path||t.pathname);if(t.nodeName&&(t=t[o.getDomAttribute(t)]||"",i=!1),!r&&i&&void 0!==t.pathname&&(t=t.toString()),"string"==typeof t||t instanceof String)this.U=o.parse(String(t),this.U);else{if(!r&&!i)throw new TypeError("invalid input");var u=r?t.U:t;for(e in u)"query"!==e&&s.call(this.U,e)&&(this.U[e]=u[e]);u.query&&this.query(u.query,!1)}return this.build(!n),this},u.is=function(t){var n=!1,r=!1,i=!1,u=!1,s=!1,c=!1,a=!1,f=!this.U.urn;switch(this.U.hostname&&(f=!1,r=o.ip4_expression.test(this.U.hostname),i=o.ip6_expression.test(this.U.hostname),s=(u=!(n=r||i))&&e&&e.has(this.U.hostname),c=u&&o.idn_expression.test(this.U.hostname),a=u&&o.punycode_expression.test(this.U.hostname)),t.toLowerCase()){case"relative":return f;case"absolute":return!f;case"domain":case"name":return u;case"sld":return s;case"ip":return n;case"ip4":case"ipv4":case"inet4":return r;case"ip6":case"ipv6":case"inet6":return i;case"idn":return c;case"url":return!this.U.urn;case"urn":return!!this.U.urn;case"punycode":return a}return null};var x=u.protocol,E=u.port,k=u.hostname;u.protocol=function(t,n){if(t&&!(t=t.replace(/:(\\/\\/)?$/,"")).match(o.protocol_expression))throw new TypeError(\'Protocol "\'+t+"\\" contains characters other than [A-Z0-9.+-] or doesn\'t start with [A-Z]");return x.call(this,t,n)},u.scheme=u.protocol,u.port=function(t,n){return this.U.urn?void 0===t?"":this:(void 0!==t&&(0===t&&(t=null),t&&(":"===(t+="").charAt(0)&&(t=t.substring(1)),o.ensureValidPort(t))),E.call(this,t,n))},u.hostname=function(t,n){if(this.U.urn)return void 0===t?"":this;if(void 0!==t){var e={preventInvalidHostname:this.U.preventInvalidHostname};if("/"!==o.parseHost(t,e))throw new TypeError(\'Hostname "\'+t+\'" contains characters other than [A-Z0-9.-]\');t=e.hostname,this.U.preventInvalidHostname&&o.ensureValidHostname(t,this.U.protocol)}return k.call(this,t,n)},u.origin=function(t,n){if(this.U.urn)return void 0===t?"":this;if(void 0===t){var e=this.protocol();return this.authority()?(e?e+"://":"")+this.authority():""}var r=o(t);return this.protocol(r.protocol()).authority(r.authority()).build(!n),this},u.host=function(t,n){if(this.U.urn)return void 0===t?"":this;if(void 0===t)return this.U.hostname?o.buildHost(this.U):"";if("/"!==o.parseHost(t,this.U))throw new TypeError(\'Hostname "\'+t+\'" contains characters other than [A-Z0-9.-]\');return this.build(!n),this},u.authority=function(t,n){if(this.U.urn)return void 0===t?"":this;if(void 0===t)return this.U.hostname?o.buildAuthority(this.U):"";if("/"!==o.parseAuthority(t,this.U))throw new TypeError(\'Hostname "\'+t+\'" contains characters other than [A-Z0-9.-]\');return this.build(!n),this},u.userinfo=function(t,n){if(this.U.urn)return void 0===t?"":this;if(void 0===t){var e=o.buildUserinfo(this.U);return e?e.substring(0,e.length-1):e}return"@"!==t[t.length-1]&&(t+="@"),o.parseUserinfo(t,this.U),this.build(!n),this},u.resource=function(t,n){var e;return void 0===t?this.path()+this.search()+this.hash():(e=o.parse(t),this.U.path=e.path,this.U.query=e.query,this.U.fragment=e.fragment,this.build(!n),this)},u.subdomain=function(t,n){if(this.U.urn)return void 0===t?"":this;if(void 0===t){if(!this.U.hostname||this.is("IP"))return"";var e=this.U.hostname.length-this.domain().length-1;return this.U.hostname.substring(0,e)||""}var r=this.U.hostname.length-this.domain().length,i=this.U.hostname.substring(0,r),u=new RegExp("^"+c(i));if(t&&"."!==t.charAt(t.length-1)&&(t+="."),-1!==t.indexOf(":"))throw new TypeError("Domains cannot contain colons");return t&&o.ensureValidHostname(t,this.U.protocol),this.U.hostname=this.U.hostname.replace(u,t),this.build(!n),this},u.domain=function(t,n){if(this.U.urn)return void 0===t?"":this;if("boolean"==typeof t&&(n=t,t=void 0),void 0===t){if(!this.U.hostname||this.is("IP"))return"";var e=this.U.hostname.match(/\\./g);if(e&&e.length<2)return this.U.hostname;var r=this.U.hostname.length-this.tld(n).length-1;return r=this.U.hostname.lastIndexOf(".",r-1)+1,this.U.hostname.substring(r)||""}if(!t)throw new TypeError("cannot set domain empty");if(-1!==t.indexOf(":"))throw new TypeError("Domains cannot contain colons");if(o.ensureValidHostname(t,this.U.protocol),!this.U.hostname||this.is("IP"))this.U.hostname=t;else{var i=new RegExp(c(this.domain())+"$");this.U.hostname=this.U.hostname.replace(i,t)}return this.build(!n),this},u.tld=function(t,n){if(this.U.urn)return void 0===t?"":this;if("boolean"==typeof t&&(n=t,t=void 0),void 0===t){if(!this.U.hostname||this.is("IP"))return"";var r=this.U.hostname.lastIndexOf("."),i=this.U.hostname.substring(r+1);return!0!==n&&e&&e.list[i.toLowerCase()]&&e.get(this.U.hostname)||i}var o;if(!t)throw new TypeError("cannot set TLD empty");if(t.match(/[^a-zA-Z0-9-]/)){if(!e||!e.is(t))throw new TypeError(\'TLD "\'+t+\'" contains characters other than [A-Z0-9]\');o=new RegExp(c(this.tld())+"$"),this.U.hostname=this.U.hostname.replace(o,t)}else{if(!this.U.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");o=new RegExp(c(this.tld())+"$"),this.U.hostname=this.U.hostname.replace(o,t)}return this.build(!n),this},u.directory=function(t,n){if(this.U.urn)return void 0===t?"":this;if(void 0===t||!0===t){if(!this.U.path&&!this.U.hostname)return"";if("/"===this.U.path)return"/";var e=this.U.path.length-this.filename().length-1,r=this.U.path.substring(0,e)||(this.U.hostname?"/":"");return t?o.decodePath(r):r}var i=this.U.path.length-this.filename().length,u=this.U.path.substring(0,i),s=new RegExp("^"+c(u));return this.is("relative")||(t||(t="/"),"/"!==t.charAt(0)&&(t="/"+t)),t&&"/"!==t.charAt(t.length-1)&&(t+="/"),t=o.recodePath(t),this.U.path=this.U.path.replace(s,t),this.build(!n),this},u.filename=function(t,n){if(this.U.urn)return void 0===t?"":this;if("string"!=typeof t){if(!this.U.path||"/"===this.U.path)return"";var e=this.U.path.lastIndexOf("/"),r=this.U.path.substring(e+1);return t?o.decodePathSegment(r):r}var i=!1;"/"===t.charAt(0)&&(t=t.substring(1)),t.match(/\\.?\\//)&&(i=!0);var u=new RegExp(c(this.filename())+"$");return t=o.recodePath(t),this.U.path=this.U.path.replace(u,t),i?this.normalizePath(n):this.build(!n),this},u.suffix=function(t,n){if(this.U.urn)return void 0===t?"":this;if(void 0===t||!0===t){if(!this.U.path||"/"===this.U.path)return"";var e,r,i=this.filename(),u=i.lastIndexOf(".");return-1===u?"":(e=i.substring(u+1),r=/^[a-z0-9%]+$/i.test(e)?e:"",t?o.decodePathSegment(r):r)}"."===t.charAt(0)&&(t=t.substring(1));var s,a=this.suffix();if(a)s=t?new RegExp(c(a)+"$"):new RegExp(c("."+a)+"$");else{if(!t)return this;this.U.path+="."+o.recodePath(t)}return s&&(t=o.recodePath(t),this.U.path=this.U.path.replace(s,t)),this.build(!n),this},u.segment=function(t,n,e){var r=this.U.urn?":":"/",i=this.path(),o="/"===i.substring(0,1),u=i.split(r);if(void 0!==t&&"number"!=typeof t&&(e=n,n=t,t=void 0),void 0!==t&&"number"!=typeof t)throw new Error(\'Bad segment "\'+t+\'", must be 0-based integer\');if(o&&u.shift(),t<0&&(t=Math.max(u.length+t,0)),void 0===n)return void 0===t?u:u[t];if(null===t||void 0===u[t])if(f(n)){u=[];for(var s=0,c=n.length;s<c;s++)(n[s].length||u.length&&u[u.length-1].length)&&(u.length&&!u[u.length-1].length&&u.pop(),u.push(w(n[s])))}else(n||"string"==typeof n)&&(n=w(n),""===u[u.length-1]?u[u.length-1]=n:u.push(n));else n?u[t]=w(n):u.splice(t,1);return o&&u.unshift(""),this.path(u.join(r),e)},u.segmentCoded=function(t,n,e){var r,i,u;if("number"!=typeof t&&(e=n,n=t,t=void 0),void 0===n){if(f(r=this.segment(t,n,e)))for(i=0,u=r.length;i<u;i++)r[i]=o.decode(r[i]);else r=void 0!==r?o.decode(r):void 0;return r}if(f(n))for(i=0,u=n.length;i<u;i++)n[i]=o.encode(n[i]);else n="string"==typeof n||n instanceof String?o.encode(n):n;return this.segment(t,n,e)};var q=u.query;return u.query=function(t,n){if(!0===t)return o.parseQuery(this.U.query,this.U.escapeQuerySpace);if("function"==typeof t){var e=o.parseQuery(this.U.query,this.U.escapeQuerySpace),r=t.call(this,e);return this.U.query=o.buildQuery(r||e,this.U.duplicateQueryParameters,this.U.escapeQuerySpace),this.build(!n),this}return void 0!==t&&"string"!=typeof t?(this.U.query=o.buildQuery(t,this.U.duplicateQueryParameters,this.U.escapeQuerySpace),this.build(!n),this):q.call(this,t,n)},u.setQuery=function(t,n,e){var r=o.parseQuery(this.U.query,this.U.escapeQuerySpace);if("string"==typeof t||t instanceof String)r[t]=void 0!==n?n:null;else{if("object"!=typeof t)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");for(var i in t)s.call(t,i)&&(r[i]=t[i])}return this.U.query=o.buildQuery(r,this.U.duplicateQueryParameters,this.U.escapeQuerySpace),"string"!=typeof t&&(e=n),this.build(!e),this},u.addQuery=function(t,n,e){var r=o.parseQuery(this.U.query,this.U.escapeQuerySpace);return o.addQuery(r,t,void 0===n?null:n),this.U.query=o.buildQuery(r,this.U.duplicateQueryParameters,this.U.escapeQuerySpace),"string"!=typeof t&&(e=n),this.build(!e),this},u.removeQuery=function(t,n,e){var r=o.parseQuery(this.U.query,this.U.escapeQuerySpace);return o.removeQuery(r,t,n),this.U.query=o.buildQuery(r,this.U.duplicateQueryParameters,this.U.escapeQuerySpace),"string"!=typeof t&&(e=n),this.build(!e),this},u.hasQuery=function(t,n,e){var r=o.parseQuery(this.U.query,this.U.escapeQuerySpace);return o.hasQuery(r,t,n,e)},u.setSearch=u.setQuery,u.addSearch=u.addQuery,u.removeSearch=u.removeQuery,u.hasSearch=u.hasQuery,u.normalize=function(){return this.U.urn?this.normalizeProtocol(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},u.normalizeProtocol=function(t){return"string"==typeof this.U.protocol&&(this.U.protocol=this.U.protocol.toLowerCase(),this.build(!t)),this},u.normalizeHostname=function(e){return this.U.hostname&&(this.is("IDN")&&t?this.U.hostname=t.toASCII(this.U.hostname):this.is("IPv6")&&n&&(this.U.hostname=n.best(this.U.hostname)),this.U.hostname=this.U.hostname.toLowerCase(),this.build(!e)),this},u.normalizePort=function(t){return"string"==typeof this.U.protocol&&this.U.port===o.defaultPorts[this.U.protocol]&&(this.U.port=null,this.build(!t)),this},u.normalizePath=function(t){var n,e=this.U.path;if(!e)return this;if(this.U.urn)return this.U.path=o.recodeUrnPath(this.U.path),this.build(!t),this;if("/"===this.U.path)return this;var r,i,u="";for("/"!==(e=o.recodePath(e)).charAt(0)&&(n=!0,e="/"+e),"/.."!==e.slice(-3)&&"/."!==e.slice(-2)||(e+="/"),e=e.replace(/(\\/(\\.\\/)+)|(\\/\\.$)/g,"/").replace(/\\/{2,}/g,"/"),n&&(u=e.substring(1).match(/^(\\.\\.\\/)+/)||"")&&(u=u[0]);-1!==(r=e.search(/\\/\\.\\.(\\/|$)/));)0!==r?(-1===(i=e.substring(0,r).lastIndexOf("/"))&&(i=r),e=e.substring(0,i)+e.substring(r+3)):e=e.substring(3);return n&&this.is("relative")&&(e=u+e.substring(1)),this.U.path=e,this.build(!t),this},u.normalizePathname=u.normalizePath,u.normalizeQuery=function(t){return"string"==typeof this.U.query&&(this.U.query.length?this.query(o.parseQuery(this.U.query,this.U.escapeQuerySpace)):this.U.query=null,this.build(!t)),this},u.normalizeFragment=function(t){return this.U.fragment||(this.U.fragment=null,this.build(!t)),this},u.normalizeSearch=u.normalizeQuery,u.normalizeHash=u.normalizeFragment,u.iso8859=function(){var t=o.encode,n=o.decode;o.encode=escape,o.decode=decodeURIComponent;try{this.normalize()}finally{o.encode=t,o.decode=n}return this},u.unicode=function(){var t=o.encode,n=o.decode;o.encode=g,o.decode=unescape;try{this.normalize()}finally{o.encode=t,o.decode=n}return this},u.readable=function(){var n=this.clone();n.username("").password("").normalize();var e="";if(n.U.protocol&&(e+=n.U.protocol+"://"),n.U.hostname&&(n.is("punycode")&&t?(e+=t.toUnicode(n.U.hostname),n.U.port&&(e+=":"+n.U.port)):e+=n.host()),n.U.hostname&&n.U.path&&"/"!==n.U.path.charAt(0)&&(e+="/"),e+=n.path(!0),n.U.query){for(var r="",i=0,u=n.U.query.split("&"),s=u.length;i<s;i++){var c=(u[i]||"").split("=");r+="&"+o.decodeQuery(c[0],this.U.escapeQuerySpace).replace(/&/g,"%26"),void 0!==c[1]&&(r+="="+o.decodeQuery(c[1],this.U.escapeQuerySpace).replace(/&/g,"%26"))}e+="?"+r.substring(1)}return e+o.decodeQuery(n.hash(),!0)},u.absoluteTo=function(t){var n,e,r,i=this.clone(),u=["protocol","username","password","hostname","port"];if(this.U.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t instanceof o||(t=new o(t)),i.U.protocol)return i;if(i.U.protocol=t.U.protocol,this.U.hostname)return i;for(e=0;r=u[e];e++)i.U[r]=t.U[r];return i.U.path?(".."===i.U.path.substring(-2)&&(i.U.path+="/"),"/"!==i.path().charAt(0)&&(n=(n=t.directory())||(0===t.path().indexOf("/")?"/":""),i.U.path=(n?n+"/":"")+i.U.path,i.normalizePath())):(i.U.path=t.U.path,i.U.query||(i.U.query=t.U.query)),i.build(),i},u.relativeTo=function(t){var n,e,r,i,u,s=this.clone().normalize();if(s.U.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t=new o(t).normalize(),n=s.U,e=t.U,i=s.path(),u=t.path(),"/"!==i.charAt(0))throw new Error("URI is already relative");if("/"!==u.charAt(0))throw new Error("Cannot calculate a URI relative to another relative URI");if(n.protocol===e.protocol&&(n.protocol=null),n.username!==e.username||n.password!==e.password)return s.build();if(null!==n.protocol||null!==n.username||null!==n.password)return s.build();if(n.hostname!==e.hostname||n.port!==e.port)return s.build();if(n.hostname=null,n.port=null,i===u)return n.path="",s.build();if(!(r=o.commonPath(i,u)))return s.build();var c=e.path.substring(r.length).replace(/[^\\/]*$/,"").replace(/.*?\\//g,"../");return n.path=c+n.path.substring(r.length)||"./",s.build()},u.equals=function(t){var n,e,r,i,u,c=this.clone(),a=new o(t),h={};if(c.normalize(),a.normalize(),c.toString()===a.toString())return!0;if(r=c.query(),i=a.query(),c.query(""),a.query(""),c.toString()!==a.toString())return!1;if(r.length!==i.length)return!1;for(u in n=o.parseQuery(r,this.U.escapeQuerySpace),e=o.parseQuery(i,this.U.escapeQuerySpace),n)if(s.call(n,u)){if(f(n[u])){if(!d(n[u],e[u]))return!1}else if(n[u]!==e[u])return!1;h[u]=!0}for(u in e)if(s.call(e,u)&&!h[u])return!1;return!0},u.preventInvalidHostname=function(t){return this.U.preventInvalidHostname=!!t,this},u.duplicateQueryParameters=function(t){return this.U.duplicateQueryParameters=!!t,this},u.escapeQuerySpace=function(t){return this.U.escapeQuerySpace=!!t,this},o},(Nt=zt).exports?Nt.exports=Tt(function(){return Rt||(Rt=1,t=Ct,n=Ct.exports,function(e){var r=n&&!n.nodeType&&n,i=t&&!t.nodeType&&t,o="object"==typeof f&&f;o.global!==o&&o.window!==o&&o.self!==o||(e=o);var u,s,c=2147483647,a=36,h=26,l=38,d=700,w=/^xn--/,m=/[^\\x20-\\x7E]/,g={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=a-1,p=Math.floor,y=String.fromCharCode;function b(t){throw new RangeError(g[t])}function M(t,n){for(var e=t.length,r=[];e--;)r[e]=n(t[e]);return r}function A(t,n){var e=t.split("@"),r="";return e.length>1&&(r=e[0]+"@",t=e[1]),r+M((t=t.replace(/[\\x2E\\u3002\\uFF0E\\uFF61]/g,".")).split("."),n).join(".")}function x(t){for(var n,e,r=[],i=0,o=t.length;i<o;)(n=t.charCodeAt(i++))>=55296&&n<=56319&&i<o?56320==(64512&(e=t.charCodeAt(i++)))?r.push(((1023&n)<<10)+(1023&e)+65536):(r.push(n),i--):r.push(n);return r}function E(t){return M(t,(function(t){var n="";return t>65535&&(n+=y((t-=65536)>>>10&1023|55296),t=56320|1023&t),n+y(t)})).join("")}function k(t,n){return t+22+75*(t<26)-((0!=n)<<5)}function q(t,n,e){var r=0;for(t=e?p(t/d):t>>1,t+=p(t/n);t>v*h>>1;r+=a)t=p(t/v);return p(r+(v+1)*t/(t+l))}function $(t){var n,e,r,i,o,u,s,f,l,d,w,m=[],g=t.length,v=0,y=128,M=72;for((e=t.lastIndexOf("-"))<0&&(e=0),r=0;r<e;++r)t.charCodeAt(r)>=128&&b("not-basic"),m.push(t.charCodeAt(r));for(i=e>0?e+1:0;i<g;){for(o=v,u=1,s=a;i>=g&&b("invalid-input"),((f=(w=t.charCodeAt(i++))-48<10?w-22:w-65<26?w-65:w-97<26?w-97:a)>=a||f>p((c-v)/u))&&b("overflow"),v+=f*u,!(f<(l=s<=M?1:s>=M+h?h:s-M));s+=a)u>p(c/(d=a-l))&&b("overflow"),u*=d;M=q(v-o,n=m.length+1,0==o),p(v/n)>c-y&&b("overflow"),y+=p(v/n),v%=n,m.splice(v++,0,y)}return E(m)}function S(t){var n,e,r,i,o,u,s,f,l,d,w,m,g,v,M,A=[];for(m=(t=x(t)).length,n=128,e=0,o=72,u=0;u<m;++u)(w=t[u])<128&&A.push(y(w));for(r=i=A.length,i&&A.push("-");r<m;){for(s=c,u=0;u<m;++u)(w=t[u])>=n&&w<s&&(s=w);for(s-n>p((c-e)/(g=r+1))&&b("overflow"),e+=(s-n)*g,n=s,u=0;u<m;++u)if((w=t[u])<n&&++e>c&&b("overflow"),w==n){for(f=e,l=a;!(f<(d=l<=o?1:l>=o+h?h:l-o));l+=a)M=f-d,v=a-d,A.push(y(k(d+M%v,0))),f=p(M/v);A.push(y(k(f,0))),o=q(e,g,r==i),e=0,++r}++e,++n}return A.join("")}if(u={version:"1.3.2",ucs2:{decode:x,encode:E},decode:$,encode:S,toASCII:function(t){return A(t,(function(t){return m.test(t)?"xn--"+S(t):t}))},toUnicode:function(t){return A(t,(function(t){return w.test(t)?$(t.slice(4).toLowerCase()):t}))}},r&&i)if(t.exports==r)i.exports=u;else for(s in u)u.hasOwnProperty(s)&&(r[s]=u[s]);else e.punycode=u}(Dt)),Ct.exports;var t,n}(),function(){return Pt||(Pt=1,n=Lt,e=function(t){var n=t&&t.IPv6;return{best:function(t){var n,e,r=t.toLowerCase().split(":"),i=r.length,o=8;for(""===r[0]&&""===r[1]&&""===r[2]?(r.shift(),r.shift()):""===r[0]&&""===r[1]?r.shift():""===r[i-1]&&""===r[i-2]&&r.pop(),-1!==r[(i=r.length)-1].indexOf(".")&&(o=7),n=0;n<i&&""!==r[n];n++);if(n<o)for(r.splice(n,1,"0000");r.length<o;)r.splice(n,0,"0000");for(var u=0;u<o;u++){e=r[u].split("");for(var s=0;s<3&&"0"===e[0]&&e.length>1;s++)e.splice(0,1);r[u]=e.join("")}var c=-1,a=0,f=0,h=-1,l=!1;for(u=0;u<o;u++)l?"0"===r[u]?f+=1:(l=!1,f>a&&(c=h,a=f)):"0"===r[u]&&(l=!0,h=u,f=1);f>a&&(c=h,a=f),a>1&&r.splice(c,a,""),i=r.length;var d="";for(""===r[0]&&(d=":"),u=0;u<i&&(d+=r[u],u!==i-1);u++)d+=":";return""===r[i-1]&&(d+=":"),d},noConflict:function(){return t.IPv6===this&&(t.IPv6=n),this}}},(t=Bt).exports?t.exports=e():n.IPv6=e(n)),Bt.exports;var t,n,e}(),function(){return jt||(jt=1,n=Vt,e=function(t){var n=t&&t.SecondLevelDomains,e={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ",bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ",cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ",do:" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ",et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ",in:" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ",rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ",us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch ",com:"ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ",net:"gb jp se uk ",org:"ae",de:"com "},has:function(t){var n=t.lastIndexOf(".");if(n<=0||n>=t.length-1)return!1;var r=t.lastIndexOf(".",n-1);if(r<=0||r>=n-1)return!1;var i=e.list[t.slice(n+1)];return!!i&&i.indexOf(" "+t.slice(r+1,n)+" ")>=0},is:function(t){var n=t.lastIndexOf(".");if(n<=0||n>=t.length-1)return!1;if(t.lastIndexOf(".",n-1)>=0)return!1;var r=e.list[t.slice(n+1)];return!!r&&r.indexOf(" "+t.slice(0,n)+" ")>=0},get:function(t){var n=t.lastIndexOf(".");if(n<=0||n>=t.length-1)return null;var r=t.lastIndexOf(".",n-1);if(r<=0||r>=n-1)return null;var i=e.list[t.slice(n+1)];return i?i.indexOf(" "+t.slice(r+1,n)+" ")<0?null:t.slice(r+1):null},noConflict:function(){return t.SecondLevelDomains===this&&(t.SecondLevelDomains=n),this}};return e},(t=_t).exports?t.exports=e():n.SecondLevelDomains=e(n)),_t.exports;var t,n,e}()):Ut.URI=Tt(Ut.punycode,Ut.IPv6,Ut.SecondLevelDomains,Ut)),zt.exports),Yt=h(Ht);function Zt(t,e){if(null===t||"object"!=typeof t)return t;e=n(e,!1);const r=new t.constructor;for(const n in t)if(t.hasOwnProperty(n)){let i=t[n];e&&(i=Zt(i,e)),r[n]=i}return r}function Wt(t,r,i){i=n(i,!1);const o={},u=e(t),s=e(r);let c,a,f;if(u)for(c in t)t.hasOwnProperty(c)&&(a=t[c],s&&i&&"object"==typeof a&&r.hasOwnProperty(c)?(f=r[c],o[c]="object"==typeof f?Wt(a,f,i):a):o[c]=a);if(s)for(c in r)r.hasOwnProperty(c)&&!o.hasOwnProperty(c)&&(f=r[c],o[c]=f);return o}function Qt(){let t,n;const e=new Promise((function(e,r){t=e,n=r}));return{resolve:t,reject:n,promise:e}}function Jt(t,n){let e;return"undefined"!=typeof document&&(e=document),Jt.D(t,n,e)}Jt.D=function(t,i,o){if(!e(t))throw new r("relative uri is required.");if(!e(i)){if(void 0===o)return t;i=n(o.baseURI,o.location.href)}const u=new Yt(t);return""!==u.scheme()?u.toString():u.absoluteTo(i).toString()};const Gt={};function Xt(t,n,r){e(n)||(n=t.width),e(r)||(r=t.height);let i=Gt[n];e(i)||(i={},Gt[n]=i);let o=i[r];if(!e(o)){const t=document.createElement("canvas");t.width=n,t.height=r,o=t.getContext("2d",{willReadFrequently:!0}),o.globalCompositeOperation="copy",i[r]=o}return o.drawImage(t,0,0,n,r),o.getImageData(0,0,n,r).data}const Kt=/^blob:/i;function tn(t){return i.typeOf.string("uri",t),Kt.test(t)}let nn;const en=/^data:/i;function rn(t){return i.typeOf.string("uri",t),en.test(t)}var on=Object.freeze({UNISSUED:0,ISSUED:1,ACTIVE:2,RECEIVED:3,CANCELLED:4,FAILED:5}),un=Object.freeze({TERRAIN:0,IMAGERY:1,TILES3D:2,OTHER:3});function sn(t){t=n(t,n.EMPTY_OBJECT);const e=n(t.throttleByServer,!1),r=n(t.throttle,!1);this.url=t.url,this.requestFunction=t.requestFunction,this.cancelFunction=t.cancelFunction,this.priorityFunction=t.priorityFunction,this.priority=n(t.priority,0),this.throttle=r,this.throttleByServer=e,this.type=n(t.type,un.OTHER),this.serverKey=t.serverKey,this.state=on.UNISSUED,this.deferred=void 0,this.cancelled=!1}function cn(t,n,e){this.statusCode=t,this.response=n,this.responseHeaders=e,"string"==typeof this.responseHeaders&&(this.responseHeaders=function(t){const n={};if(!t)return n;const e=t.split("\\r\\n");for(let t=0;t<e.length;++t){const r=e[t],i=r.indexOf(": ");if(i>0){const t=r.substring(0,i),e=r.substring(i+2);n[t]=e}}return n}(this.responseHeaders))}function an(t){i.typeOf.object("options",t),i.defined("options.comparator",t.comparator),this.B=t.comparator,this.L=[],this._=0,this.V=void 0}function fn(t,n,e){const r=t[n];t[n]=t[e],t[e]=r}sn.prototype.cancel=function(){this.cancelled=!0},sn.prototype.clone=function(t){return e(t)?(t.url=this.url,t.requestFunction=this.requestFunction,t.cancelFunction=this.cancelFunction,t.priorityFunction=this.priorityFunction,t.priority=this.priority,t.throttle=this.throttle,t.throttleByServer=this.throttleByServer,t.type=this.type,t.serverKey=this.serverKey,t.state=on.UNISSUED,t.deferred=void 0,t.cancelled=!1,t):new sn(this)},cn.prototype.toString=function(){let t="Request has failed.";return e(this.statusCode)&&(t+=` Status Code: ${this.statusCode}`),t},Object.defineProperties(an.prototype,{length:{get:function(){return this._}},internalArray:{get:function(){return this.L}},maximumLength:{get:function(){return this.V},set:function(t){i.typeOf.number.greaterThanOrEquals("maximumLength",t,0);const n=this._;if(t<n){const e=this.L;for(let r=t;r<n;++r)e[r]=void 0;this._=t,e.length=t}this.V=t}},comparator:{get:function(){return this.B}}}),an.prototype.reserve=function(t){t=n(t,this._),this.L.length=t},an.prototype.heapify=function(t){t=n(t,0);const e=this._,r=this.B,i=this.L;let o=-1,u=!0;for(;u;){const n=2*(t+1),s=n-1;o=s<e&&r(i[s],i[t])<0?s:t,n<e&&r(i[n],i[o])<0&&(o=n),o!==t?(fn(i,o,t),t=o):u=!1}},an.prototype.resort=function(){const t=this._;for(let n=Math.ceil(t/2);n>=0;--n)this.heapify(n)},an.prototype.insert=function(t){i.defined("element",t);const n=this.L,r=this.B,o=this.V;let u,s=this._++;for(s<n.length?n[s]=t:n.push(t);0!==s;){const t=Math.floor((s-1)/2);if(!(r(n[s],n[t])<0))break;fn(n,s,t),s=t}return e(o)&&this._>o&&(u=n[o],this._=o),u},an.prototype.pop=function(t){if(t=n(t,0),0===this._)return;i.typeOf.number.lessThan("index",t,this._);const e=this.L,r=e[t];return fn(e,t,--this._),this.heapify(t),e[this._]=void 0,r};const hn={numberOfAttemptedRequests:0,numberOfActiveRequests:0,numberOfCancelledRequests:0,numberOfCancelledActiveRequests:0,numberOfFailedRequests:0,numberOfActiveRequestsEver:0,lastNumberOfActiveRequests:0};let ln=20;const dn=new an({comparator:function(t,n){return t.priority-n.priority}});dn.maximumLength=ln,dn.reserve(ln);const wn=[];let mn={};const gn="undefined"!=typeof document?new Yt(document.location.href):new Yt,vn=new u;function pn(){}function yn(t){e(t.priorityFunction)&&(t.priority=t.priorityFunction())}function bn(t){return t.state===on.UNISSUED&&(t.state=on.ISSUED,t.deferred=Qt()),t.deferred.promise}function Mn(t){const n=bn(t);return t.state=on.ACTIVE,wn.push(t),++hn.numberOfActiveRequests,++hn.numberOfActiveRequestsEver,++mn[t.serverKey],t.requestFunction().then(function(t){return function(n){if(t.state===on.CANCELLED)return;const e=t.deferred;--hn.numberOfActiveRequests,--mn[t.serverKey],vn.raiseEvent(),t.state=on.RECEIVED,t.deferred=void 0,e.resolve(n)}}(t)).catch(function(t){return function(n){t.state!==on.CANCELLED&&(++hn.numberOfFailedRequests,--hn.numberOfActiveRequests,--mn[t.serverKey],vn.raiseEvent(n),t.state=on.FAILED,t.deferred.reject(n))}}(t)),n}function An(t){const n=t.state===on.ACTIVE;if(t.state=on.CANCELLED,++hn.numberOfCancelledRequests,e(t.deferred)){const n=t.deferred;t.deferred=void 0,n.reject()}n&&(--hn.numberOfActiveRequests,--mn[t.serverKey],++hn.numberOfCancelledActiveRequests),e(t.cancelFunction)&&t.cancelFunction()}function xn(t){let n;this.name="RuntimeError",this.message=t;try{throw new Error}catch(t){n=t.stack}this.stack=n}pn.maximumRequests=50,pn.maximumRequestsPerServer=18,pn.requestsByServer={},pn.throttleRequests=!0,pn.debugShowStatistics=!1,pn.requestCompletedEvent=vn,Object.defineProperties(pn,{statistics:{get:function(){return hn}},priorityHeapLength:{get:function(){return ln},set:function(t){if(t<ln)for(;dn.length>t;)An(dn.pop());ln=t,dn.maximumLength=t,dn.reserve(t)}}}),pn.serverHasOpenSlots=function(t,e){e=n(e,1);const r=n(pn.requestsByServer[t],pn.maximumRequestsPerServer);return mn[t]+e<=r},pn.heapHasOpenSlots=function(t){return dn.length+t<=ln},pn.update=function(){let t,n,e=0;const r=wn.length;for(t=0;t<r;++t)n=wn[t],n.cancelled&&An(n),n.state===on.ACTIVE?e>0&&(wn[t-e]=n):++e;wn.length-=e;const i=dn.internalArray,o=dn.length;for(t=0;t<o;++t)yn(i[t]);dn.resort();const u=Math.max(pn.maximumRequests-wn.length,0);let s=0;for(;s<u&&dn.length>0;)n=dn.pop(),n.cancelled?An(n):!n.throttleByServer||pn.serverHasOpenSlots(n.serverKey)?(Mn(n),++s):An(n);pn.debugShowStatistics&&(0===hn.numberOfActiveRequests&&hn.lastNumberOfActiveRequests>0&&(hn.numberOfAttemptedRequests>0&&(hn.numberOfAttemptedRequests=0),hn.numberOfCancelledRequests>0&&(hn.numberOfCancelledRequests=0),hn.numberOfCancelledActiveRequests>0&&(hn.numberOfCancelledActiveRequests=0),hn.numberOfFailedRequests>0&&(hn.numberOfFailedRequests=0)),hn.lastNumberOfActiveRequests=hn.numberOfActiveRequests)},pn.getServerKey=function(t){i.typeOf.string("url",t);let n=new Yt(t);""===n.scheme()&&(n=n.absoluteTo(gn),n.normalize());let r=n.authority();return/:/.test(r)||(r=`${r}:${"https"===n.scheme()?"443":"80"}`),e(mn[r])||(mn[r]=0),r},pn.request=function(t){if(i.typeOf.object("request",t),i.typeOf.string("request.url",t.url),i.typeOf.func("request.requestFunction",t.requestFunction),rn(t.url)||tn(t.url))return vn.raiseEvent(),t.state=on.RECEIVED,t.requestFunction();if(++hn.numberOfAttemptedRequests,e(t.serverKey)||(t.serverKey=pn.getServerKey(t.url)),pn.throttleRequests&&t.throttleByServer&&!pn.serverHasOpenSlots(t.serverKey))return;if(!pn.throttleRequests||!t.throttle)return Mn(t);if(wn.length>=pn.maximumRequests)return;yn(t);const n=dn.insert(t);if(e(n)){if(n===t)return;An(n)}return bn(t)},pn.clearForSpecs=function(){for(;dn.length>0;)An(dn.pop());const t=wn.length;for(let n=0;n<t;++n)An(wn[n]);wn.length=0,mn={},hn.numberOfAttemptedRequests=0,hn.numberOfActiveRequests=0,hn.numberOfCancelledRequests=0,hn.numberOfCancelledActiveRequests=0,hn.numberOfFailedRequests=0,hn.numberOfActiveRequestsEver=0,hn.lastNumberOfActiveRequests=0},pn.numberOfActiveRequestsByServer=function(t){return mn[t]},pn.requestHeap=dn,e(Object.create)&&(xn.prototype=Object.create(Error.prototype),xn.prototype.constructor=xn),xn.prototype.toString=function(){let t=`${this.name}: ${this.message}`;return e(this.stack)&&(t+=`\\n${this.stack.toString()}`),t};const En={};let kn={};En.add=function(t,n){if(!e(t))throw new r("host is required.");if(!e(n)||n<=0)throw new r("port is required to be greater than 0.");const i=`${t.toLowerCase()}:${n}`;e(kn[i])||(kn[i]=!0)},En.remove=function(t,n){if(!e(t))throw new r("host is required.");if(!e(n)||n<=0)throw new r("port is required to be greater than 0.");const i=`${t.toLowerCase()}:${n}`;e(kn[i])&&delete kn[i]},En.contains=function(t){if(!e(t))throw new r("url is required.");const n=function(t){const n=new Yt(t);n.normalize();let e=n.authority();if(0!==e.length){if(n.authority(e),-1!==e.indexOf("@")){const t=e.split("@");e=t[1]}if(-1===e.indexOf(":")){let t=n.scheme();if(0===t.length&&(t=window.location.protocol,t=t.substring(0,t.length-1)),"http"===t)e+=":80";else{if("https"!==t)return;e+=":443"}}return e}}(t);return!(!e(n)||!e(kn[n]))},En.clear=function(){kn={}};const qn=function(){try{const t=new XMLHttpRequest;return t.open("GET","#",!0),t.responseType="blob","blob"===t.responseType}catch(t){return!1}}();function $n(t){"string"==typeof(t=n(t,n.EMPTY_OBJECT))&&(t={url:t}),i.typeOf.string("options.url",t.url),this.H=void 0,this.Y=Sn(t.templateValues,{}),this.Z=Sn(t.queryParameters,{}),this.headers=Sn(t.headers,{}),this.request=n(t.request,new sn),this.proxy=t.proxy,this.retryCallback=t.retryCallback,this.retryAttempts=n(t.retryAttempts,0),this.W=0,n(t.parseUrl,!0)?this.parseUrl(t.url,!0,!0):this.H=t.url,this.J=t.credits}function Sn(t,n){return e(t)?Zt(t):n}let In;function On(t,n,r){if(!r)return Wt(t,n);const i=Zt(t,!0);for(const t in n)if(n.hasOwnProperty(t)){let r=i[t];const o=n[t];e(r)?(Array.isArray(r)||(r=i[t]=[r]),i[t]=r.concat(o)):i[t]=Array.isArray(o)?o.slice():o}return i}function Rn(t){const n=t.resource,r=t.flipY,i=t.skipColorSpaceConversion,o=t.preferImageBitmap,u=n.request;u.url=n.url,u.requestFunction=function(){let t=!1;n.isDataUri||n.isBlobUri||(t=n.isCrossOriginUrl);const e=Qt();return $n.G.createImage(u,t,e,r,i,o),e.promise};const s=pn.request(u);if(e(s))return s.catch((function(t){return u.state!==on.FAILED?Promise.reject(t):n.retryOnError(t).then((function(e){return e?(u.state=on.UNISSUED,u.deferred=void 0,Rn({resource:n,flipY:r,skipColorSpaceConversion:i,preferImageBitmap:o})):Promise.reject(t)}))}))}function Pn(t,n,r){const i={};i[n]=r,t.setQueryParameters(i);const o=t.request,u=t.url;o.url=u,o.requestFunction=function(){const t=Qt();return window[r]=function(n){t.resolve(n);try{delete window[r]}catch(t){window[r]=void 0}},$n.G.loadAndExecuteScript(u,r,t),t.promise};const s=pn.request(o);if(e(s))return s.catch((function(e){return o.state!==on.FAILED?Promise.reject(e):t.retryOnError(e).then((function(i){return i?(o.state=on.UNISSUED,o.deferred=void 0,Pn(t,n,r)):Promise.reject(e)}))}))}function jn(t){if(t.state===on.ISSUED||t.state===on.ACTIVE)throw new xn("The Resource is already being fetched.");t.state=on.UNISSUED,t.deferred=void 0}$n.createIfNeeded=function(t){return t instanceof $n?t.getDerivedResource({request:t.request}):"string"!=typeof t?t:new $n({url:t})},$n.supportsImageBitmapOptions=function(){return e(In)?In:"function"!=typeof createImageBitmap?(In=Promise.resolve(!1),In):(In=$n.fetchBlob({url:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAABGdBTUEAAE4g3rEiDgAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADElEQVQI12Ng6GAAAAEUAIngE3ZiAAAAAElFTkSuQmCC"}).then((function(t){return Promise.all([createImageBitmap(t,{imageOrientation:"flipY",premultiplyAlpha:"none",colorSpaceConversion:"none"}),createImageBitmap(t)])})).then((function(t){const n=Xt(t[0]),e=Xt(t[1]);return n[1]!==e[1]})).catch((function(){return!1})),In)},Object.defineProperties($n,{isBlobSupported:{get:function(){return qn}}}),Object.defineProperties($n.prototype,{queryParameters:{get:function(){return this.Z}},templateValues:{get:function(){return this.Y}},url:{get:function(){return this.getUrlComponent(!0,!0)},set:function(t){this.parseUrl(t,!1,!1)}},extension:{get:function(){return function(t){if(!e(t))throw new r("uri is required.");const n=new Yt(t);n.normalize();let i=n.path(),o=i.lastIndexOf("/");return-1!==o&&(i=i.substr(o+1)),o=i.lastIndexOf("."),i=-1===o?"":i.substr(o+1),i}(this.H)}},isDataUri:{get:function(){return rn(this.H)}},isBlobUri:{get:function(){return tn(this.H)}},isCrossOriginUrl:{get:function(){return function(t){e(nn)||(nn=document.createElement("a")),nn.href=window.location.href;const n=nn.host,r=nn.protocol;return nn.href=t,nn.href=nn.href,r!==nn.protocol||n!==nn.host}(this.H)}},hasHeaders:{get:function(){return Object.keys(this.headers).length>0}},credits:{get:function(){return this.J}}}),$n.prototype.toString=function(){return this.getUrlComponent(!0,!0)},$n.prototype.parseUrl=function(t,n,i,o){let u=new Yt(t);const s=0===(c=u.query()).length?{}:-1===c.indexOf("=")?{[c]:void 0}:function(t){if(!e(t))throw new r("queryString is required.");const n={};if(""===t)return n;const i=t.replace(/\\+/g,"%20").split(/[&;]/);for(let t=0,r=i.length;t<r;++t){const r=i[t].split("="),o=decodeURIComponent(r[0]);let u=r[1];u=e(u)?decodeURIComponent(u):"";const s=n[o];"string"==typeof s?n[o]=[s,u]:Array.isArray(s)?s.push(u):n[o]=u}return n}(c);var c;this.Z=n?On(s,this.queryParameters,i):s,u.search(""),u.fragment(""),e(o)&&""===u.scheme()&&(u=u.absoluteTo(Jt(o))),this.H=u.toString()},$n.prototype.getUrlComponent=function(t,n){if(this.isDataUri)return this.H;let i=this.H;t&&(i=`${i}${function(t){const n=Object.keys(t);return 0===n.length?"":1!==n.length||e(t[n[0]])?`?${function(t){if(!e(t))throw new r("obj is required.");let n="";for(const e in t)if(t.hasOwnProperty(e)){const r=t[e],i=`${encodeURIComponent(e)}=`;if(Array.isArray(r))for(let t=0,e=r.length;t<e;++t)n+=`${i+encodeURIComponent(r[t])}&`;else n+=`${i+encodeURIComponent(r)}&`}return n=n.slice(0,-1),n}(t)}`:`?${n[0]}`}(this.queryParameters)}`),i=i.replace(/%7B/g,"{").replace(/%7D/g,"}");const o=this.Y;return Object.keys(o).length>0&&(i=i.replace(/{(.*?)}/g,(function(t,n){const r=o[n];return e(r)?encodeURIComponent(r):t}))),n&&e(this.proxy)&&(i=this.proxy.getURL(i)),i},$n.prototype.setQueryParameters=function(t,n){this.Z=n?On(this.Z,t,!1):On(t,this.Z,!1)},$n.prototype.appendQueryParameters=function(t){this.Z=On(t,this.Z,!0)},$n.prototype.setTemplateValues=function(t,n){this.Y=n?Wt(this.Y,t):Wt(t,this.Y)},$n.prototype.getDerivedResource=function(t){const r=this.clone();if(r.W=0,e(t.url)){const e=n(t.preserveQueryParameters,!1);r.parseUrl(t.url,!0,e,this.H)}return e(t.queryParameters)&&(r.Z=Wt(t.queryParameters,r.queryParameters)),e(t.templateValues)&&(r.Y=Wt(t.templateValues,r.templateValues)),e(t.headers)&&(r.headers=Wt(t.headers,r.headers)),e(t.proxy)&&(r.proxy=t.proxy),e(t.request)&&(r.request=t.request),e(t.retryCallback)&&(r.retryCallback=t.retryCallback),e(t.retryAttempts)&&(r.retryAttempts=t.retryAttempts),r},$n.prototype.retryOnError=function(t){const n=this.retryCallback;if("function"!=typeof n||this.W>=this.retryAttempts)return Promise.resolve(!1);const e=this;return Promise.resolve(n(this,t)).then((function(t){return++e.W,t}))},$n.prototype.clone=function(t){return e(t)?(t.H=this.H,t.Z=Zt(this.Z),t.Y=Zt(this.Y),t.headers=Zt(this.headers),t.proxy=this.proxy,t.retryCallback=this.retryCallback,t.retryAttempts=this.retryAttempts,t.W=0,t.request=this.request.clone(),t):new $n({url:this.H,queryParameters:this.queryParameters,templateValues:this.templateValues,headers:this.headers,proxy:this.proxy,retryCallback:this.retryCallback,retryAttempts:this.retryAttempts,request:this.request.clone(),parseUrl:!1,credits:e(this.credits)?this.credits.slice():void 0})},$n.prototype.getBaseUri=function(t){return function(t,n){if(!e(t))throw new r("uri is required.");let i="";const o=t.lastIndexOf("/");return-1!==o&&(i=t.substring(0,o+1)),n?(0!==(t=new Yt(t)).query().length&&(i+=`?${t.query()}`),0!==t.fragment().length&&(i+=`#${t.fragment()}`),i):i}(this.getUrlComponent(t),t)},$n.prototype.appendForwardSlash=function(){var t;this.H=(0!==(t=this.H).length&&"/"===t[t.length-1]||(t=`${t}/`),t)},$n.prototype.fetchArrayBuffer=function(){return this.fetch({responseType:"arraybuffer"})},$n.fetchArrayBuffer=function(t){return new $n(t).fetchArrayBuffer()},$n.prototype.fetchBlob=function(){return this.fetch({responseType:"blob"})},$n.fetchBlob=function(t){return new $n(t).fetchBlob()},$n.prototype.fetchImage=function(t){t=n(t,n.EMPTY_OBJECT);const r=n(t.preferImageBitmap,!1),i=n(t.preferBlob,!1),o=n(t.flipY,!1),u=n(t.skipColorSpaceConversion,!1);if(jn(this.request),!qn||this.isDataUri||this.isBlobUri||!this.hasHeaders&&!i)return Rn({resource:this,flipY:o,skipColorSpaceConversion:u,preferImageBitmap:r});const s=this.fetchBlob();if(!e(s))return;let c,a,f,h;return $n.supportsImageBitmapOptions().then((function(t){return c=t,a=c&&r,s})).then((function(t){if(!e(t))return;if(h=t,a)return $n.createImageBitmapFromBlob(t,{flipY:o,premultiplyAlpha:!1,skipColorSpaceConversion:u});const n=window.URL.createObjectURL(t);return f=new $n({url:n}),Rn({resource:f,flipY:o,skipColorSpaceConversion:u,preferImageBitmap:!1})})).then((function(t){if(e(t))return t.blob=h,a||window.URL.revokeObjectURL(f.url),t})).catch((function(t){return e(f)&&window.URL.revokeObjectURL(f.url),t.blob=h,Promise.reject(t)}))},$n.fetchImage=function(t){return new $n(t).fetchImage({flipY:t.flipY,skipColorSpaceConversion:t.skipColorSpaceConversion,preferBlob:t.preferBlob,preferImageBitmap:t.preferImageBitmap})},$n.prototype.fetchText=function(){return this.fetch({responseType:"text"})},$n.fetchText=function(t){return new $n(t).fetchText()},$n.prototype.fetchJson=function(){const t=this.fetch({responseType:"text",headers:{Accept:"application/json,*/*;q=0.01"}});if(e(t))return t.then((function(t){if(e(t))return JSON.parse(t)}))},$n.fetchJson=function(t){return new $n(t).fetchJson()},$n.prototype.fetchXML=function(){return this.fetch({responseType:"document",overrideMimeType:"text/xml"})},$n.fetchXML=function(t){return new $n(t).fetchXML()},$n.prototype.fetchJsonp=function(t){let r;t=n(t,"callback"),jn(this.request);do{r=`loadJsonp${w.nextRandomNumber().toString().substring(2,8)}`}while(e(window[r]));return Pn(this,t,r)},$n.fetchJsonp=function(t){return new $n(t).fetchJsonp(t.callbackParameterName)},$n.prototype.X=function(t){const n=this;jn(n.request);const r=n.request,i=n.url;r.url=i,r.requestFunction=function(){const o=t.responseType,u=Wt(t.headers,n.headers),s=t.overrideMimeType,c=t.method,a=t.data,f=Qt(),h=$n.G.loadWithXhr(i,o,c,a,u,f,s);return e(h)&&e(h.abort)&&(r.cancelFunction=function(){h.abort()}),f.promise};const o=pn.request(r);if(e(o))return o.then((function(t){return r.cancelFunction=void 0,t})).catch((function(e){return r.cancelFunction=void 0,r.state!==on.FAILED?Promise.reject(e):n.retryOnError(e).then((function(i){return i?(r.state=on.UNISSUED,r.deferred=void 0,n.fetch(t)):Promise.reject(e)}))}))};const Fn=/^data:(.*?)(;base64)?,(.*)$/;function Nn(t,n){const e=decodeURIComponent(n);return t?atob(e):e}function Un(t,n){const e=Nn(t,n),r=new ArrayBuffer(e.length),i=new Uint8Array(r);for(let t=0;t<e.length;t++)i[t]=e.charCodeAt(t);return r}$n.prototype.fetch=function(t){return(t=Sn(t,{})).method="GET",this.X(t)},$n.fetch=function(t){return new $n(t).fetch({responseType:t.responseType,overrideMimeType:t.overrideMimeType})},$n.prototype.delete=function(t){return(t=Sn(t,{})).method="DELETE",this.X(t)},$n.delete=function(t){return new $n(t).delete({responseType:t.responseType,overrideMimeType:t.overrideMimeType,data:t.data})},$n.prototype.head=function(t){return(t=Sn(t,{})).method="HEAD",this.X(t)},$n.head=function(t){return new $n(t).head({responseType:t.responseType,overrideMimeType:t.overrideMimeType})},$n.prototype.options=function(t){return(t=Sn(t,{})).method="OPTIONS",this.X(t)},$n.options=function(t){return new $n(t).options({responseType:t.responseType,overrideMimeType:t.overrideMimeType})},$n.prototype.post=function(t,n){return i.defined("data",t),(n=Sn(n,{})).method="POST",n.data=t,this.X(n)},$n.post=function(t){return new $n(t).post(t.data,{responseType:t.responseType,overrideMimeType:t.overrideMimeType})},$n.prototype.put=function(t,n){return i.defined("data",t),(n=Sn(n,{})).method="PUT",n.data=t,this.X(n)},$n.put=function(t){return new $n(t).put(t.data,{responseType:t.responseType,overrideMimeType:t.overrideMimeType})},$n.prototype.patch=function(t,n){return i.defined("data",t),(n=Sn(n,{})).method="PATCH",n.data=t,this.X(n)},$n.patch=function(t){return new $n(t).patch(t.data,{responseType:t.responseType,overrideMimeType:t.overrideMimeType})},$n.G={},$n.G.loadImageElement=function(t,n,e){const r=new Image;r.onload=function(){0===r.naturalWidth&&0===r.naturalHeight&&0===r.width&&0===r.height&&(r.width=300,r.height=150),e.resolve(r)},r.onerror=function(t){e.reject(t)},n&&(En.contains(t)?r.crossOrigin="use-credentials":r.crossOrigin=""),r.src=t},$n.G.createImage=function(t,n,r,i,o,u){const s=t.url;$n.supportsImageBitmapOptions().then((function(c){if(!c||!u)return void $n.G.loadImageElement(s,n,r);const a=Qt(),f=$n.G.loadWithXhr(s,"blob","GET",void 0,void 0,a,void 0,void 0,void 0);return e(f)&&e(f.abort)&&(t.cancelFunction=function(){f.abort()}),a.promise.then((function(t){if(e(t))return $n.createImageBitmapFromBlob(t,{flipY:i,premultiplyAlpha:!1,skipColorSpaceConversion:o});r.reject(new xn(`Successfully retrieved ${s} but it contained no content.`))})).then((function(t){r.resolve(t)}))})).catch((function(t){r.reject(t)}))},$n.createImageBitmapFromBlob=function(t,n){return i.defined("options",n),i.typeOf.bool("options.flipY",n.flipY),i.typeOf.bool("options.premultiplyAlpha",n.premultiplyAlpha),i.typeOf.bool("options.skipColorSpaceConversion",n.skipColorSpaceConversion),createImageBitmap(t,{imageOrientation:n.flipY?"flipY":"none",premultiplyAlpha:n.premultiplyAlpha?"premultiply":"none",colorSpaceConversion:n.skipColorSpaceConversion?"none":"default"})};const Tn="undefined"==typeof XMLHttpRequest;function zn(t){t=n(t,n.EMPTY_OBJECT),this.K=void 0,this.nt=void 0,this.rt=-1,this.ot=-1,this.ut=-1,this.ct=-1,this.ft=-1,this.ht=-1,this.lt=-1,this.dt=0,this.wt=-1,this.vt=n(t.addNewLeapSeconds,!0),e(t.data)?Dn(this,t.data):Dn(this,{columnNames:["dateIso8601","modifiedJulianDateUtc","xPoleWanderRadians","yPoleWanderRadians","ut1MinusUtcSeconds","lengthOfDayCorrectionSeconds","xCelestialPoleOffsetRadians","yCelestialPoleOffsetRadians","taiMinusUtcSeconds"],samples:[]})}function Cn(t,n){return It.compare(t.julianDate,n)}function Dn(t,n){if(!e(n.columnNames))throw new xn("Error in loaded EOP data: The columnNames property is required.");if(!e(n.samples))throw new xn("Error in loaded EOP data: The samples property is required.");const r=n.columnNames.indexOf("modifiedJulianDateUtc"),i=n.columnNames.indexOf("xPoleWanderRadians"),o=n.columnNames.indexOf("yPoleWanderRadians"),u=n.columnNames.indexOf("ut1MinusUtcSeconds"),s=n.columnNames.indexOf("xCelestialPoleOffsetRadians"),c=n.columnNames.indexOf("yCelestialPoleOffsetRadians"),a=n.columnNames.indexOf("taiMinusUtcSeconds");if(r<0||i<0||o<0||u<0||s<0||c<0||a<0)throw new xn("Error in loaded EOP data: The columnNames property must include modifiedJulianDateUtc, xPoleWanderRadians, yPoleWanderRadians, ut1MinusUtcSeconds, xCelestialPoleOffsetRadians, yCelestialPoleOffsetRadians, and taiMinusUtcSeconds columns");const f=t.nt=n.samples,h=t.K=[];let l;t.rt=r,t.ot=i,t.ut=o,t.ct=u,t.ft=s,t.ht=c,t.lt=a,t.dt=n.columnNames.length,t.wt=void 0;const d=t.vt;for(let n=0,i=f.length;n<i;n+=t.dt){const t=f[n+r],i=f[n+a],o=new It(t+at.MODIFIED_JULIAN_DATE_DIFFERENCE,i,ft.TAI);if(h.push(o),d){if(i!==l&&e(l)){const t=It.leapSeconds,n=rt(t,o,Cn);if(n<0){const e=new ct(o,i);t.splice(~n,0,e)}}l=i}}}function Bn(t,n,e,r,i){const o=e*r;i.xPoleWander=n[o+t.ot],i.yPoleWander=n[o+t.ut],i.xPoleOffset=n[o+t.ft],i.yPoleOffset=n[o+t.ht],i.ut1MinusUtc=n[o+t.ct]}function Ln(t,n,e){return n+t*(e-n)}function _n(t,n,e,r,i,o,u){const s=t.dt;if(o>n.length-1)return u.xPoleWander=0,u.yPoleWander=0,u.xPoleOffset=0,u.yPoleOffset=0,u.ut1MinusUtc=0,u;const c=n[i],a=n[o];if(c.equals(a)||r.equals(c))return Bn(t,e,i,s,u),u;if(r.equals(a))return Bn(t,e,o,s,u),u;const f=It.secondsDifference(r,c)/It.secondsDifference(a,c),h=i*s,l=o*s;let d=e[h+t.ct],w=e[l+t.ct];const m=w-d;if(m>.5||m<-.5){const n=e[h+t.lt],i=e[l+t.lt];n!==i&&(a.equals(r)?d=w:w-=i-n)}return u.xPoleWander=Ln(f,e[h+t.ot],e[l+t.ot]),u.yPoleWander=Ln(f,e[h+t.ut],e[l+t.ut]),u.xPoleOffset=Ln(f,e[h+t.ft],e[l+t.ft]),u.yPoleOffset=Ln(f,e[h+t.ht],e[l+t.ht]),u.ut1MinusUtc=Ln(f,d,w),u}function Vn(t,e,r){this.heading=n(t,0),this.pitch=n(e,0),this.roll=n(r,0)}$n.G.loadWithXhr=function(t,i,o,u,s,c,a){const f=Fn.exec(t);if(null!==f)return void c.resolve(function(t,e){e=n(e,"");const i=t[1],o=!!t[2],u=t[3];let s,c;switch(e){case"":case"text":return Nn(o,u);case"arraybuffer":return Un(o,u);case"blob":return s=Un(o,u),new Blob([s],{type:i});case"document":return c=new DOMParser,c.parseFromString(Nn(o,u),i);case"json":return JSON.parse(Nn(o,u));default:throw new r(`Unhandled responseType: ${e}`)}}(f,i));if(Tn)return void function(t,n,e,r,i,o,u){fetch(t,{method:e,headers:i}).then((async t=>{if(!t.ok){const n={};return t.headers.forEach(((t,e)=>{n[e]=t})),void o.reject(new cn(t.status,t,n))}switch(n){case"text":o.resolve(t.text());break;case"json":o.resolve(t.json());break;default:o.resolve(new Uint8Array(await t.arrayBuffer()).buffer)}})).catch((()=>{o.reject(new cn)}))}(t,i,o,0,s,c);const h=new XMLHttpRequest;if(En.contains(t)&&(h.withCredentials=!0),h.open(o,t,!0),e(a)&&e(h.overrideMimeType)&&h.overrideMimeType(a),e(s))for(const t in s)s.hasOwnProperty(t)&&h.setRequestHeader(t,s[t]);e(i)&&(h.responseType=i);let l=!1;return"string"==typeof t&&(l=0===t.indexOf("file://")||"undefined"!=typeof window&&"file://"===window.location.origin),h.onload=function(){if((h.status<200||h.status>=300)&&(!l||0!==h.status))return void c.reject(new cn(h.status,h.response,h.getAllResponseHeaders()));const t=h.response,n=h.responseType;if("HEAD"===o||"OPTIONS"===o){const t=h.getAllResponseHeaders().trim().split(/[\\r\\n]+/),n={};return t.forEach((function(t){const e=t.split(": "),r=e.shift();n[r]=e.join(": ")})),void c.resolve(n)}if(204===h.status)c.resolve(void 0);else if(!e(t)||e(i)&&n!==i)if("json"===i&&"string"==typeof t)try{c.resolve(JSON.parse(t))}catch(t){c.reject(t)}else(""===n||"document"===n)&&e(h.responseXML)&&h.responseXML.hasChildNodes()?c.resolve(h.responseXML):""!==n&&"text"!==n||!e(h.responseText)?c.reject(new xn("Invalid XMLHttpRequest response type.")):c.resolve(h.responseText);else c.resolve(t)},h.onerror=function(t){c.reject(new cn)},h.send(u),h},$n.G.loadAndExecuteScript=function(t,n,e){return function(t){const n=document.createElement("script");return n.async=!0,n.src=t,new Promise(((t,e)=>{window.crossOriginIsolated&&n.setAttribute("crossorigin","anonymous");const r=document.getElementsByTagName("head")[0];n.onload=function(){n.onload=void 0,r.removeChild(n),t()},n.onerror=function(t){e(t)},r.appendChild(n)}))}(t).catch((function(t){e.reject(t)}))},$n.yt={},$n.yt.createImage=$n.G.createImage,$n.yt.loadWithXhr=$n.G.loadWithXhr,$n.yt.loadAndExecuteScript=$n.G.loadAndExecuteScript,$n.DEFAULT=Object.freeze(new $n({url:"undefined"==typeof document?"":document.location.href.split("?")[0]})),zn.fromUrl=async function(t,e){i.defined("url",t),e=n(e,n.EMPTY_OBJECT);const r=$n.createIfNeeded(t);let o;try{o=await r.fetchJson()}catch(t){throw new xn(`An error occurred while retrieving the EOP data from the URL ${r.url}.`)}return new zn({addNewLeapSeconds:e.addNewLeapSeconds,data:o})},zn.NONE=Object.freeze({compute:function(t,n){return e(n)?(n.xPoleWander=0,n.yPoleWander=0,n.xPoleOffset=0,n.yPoleOffset=0,n.ut1MinusUtc=0):n=new it(0,0,0,0,0),n}}),zn.prototype.compute=function(t,n){if(!e(this.nt))return;if(e(n)||(n=new it(0,0,0,0,0)),0===this.nt.length)return n.xPoleWander=0,n.yPoleWander=0,n.xPoleOffset=0,n.yPoleOffset=0,n.ut1MinusUtc=0,n;const r=this.K,i=this.wt;let o=0,u=0;if(e(i)){const s=r[i],c=r[i+1],a=It.lessThanOrEquals(s,t),f=!e(c),h=f||It.greaterThanOrEquals(c,t);if(a&&h)return o=i,!f&&c.equals(t)&&++o,u=o+1,_n(this,r,this.nt,t,o,u,n),n}let s=rt(r,t,It.compare,this.rt);return s>=0?(s<r.length-1&&r[s+1].equals(t)&&++s,o=s,u=s):(u=~s,o=u-1,o<0&&(o=0)),this.wt=o,_n(this,r,this.nt,t,o,u,n),n},Vn.fromQuaternion=function(t,n){if(!e(t))throw new r("quaternion is required");e(n)||(n=new Vn);const i=2*(t.w*t.y-t.z*t.x),o=1-2*(t.x*t.x+t.y*t.y),u=2*(t.w*t.x+t.y*t.z),s=1-2*(t.y*t.y+t.z*t.z),c=2*(t.w*t.z+t.x*t.y);return n.heading=-Math.atan2(c,s),n.roll=Math.atan2(u,o),n.pitch=-w.asinClamped(i),n},Vn.fromDegrees=function(t,n,i,o){if(!e(t))throw new r("heading is required");if(!e(n))throw new r("pitch is required");if(!e(i))throw new r("roll is required");return e(o)||(o=new Vn),o.heading=t*w.RADIANS_PER_DEGREE,o.pitch=n*w.RADIANS_PER_DEGREE,o.roll=i*w.RADIANS_PER_DEGREE,o},Vn.clone=function(t,n){if(e(t))return e(n)?(n.heading=t.heading,n.pitch=t.pitch,n.roll=t.roll,n):new Vn(t.heading,t.pitch,t.roll)},Vn.equals=function(t,n){return t===n||e(t)&&e(n)&&t.heading===n.heading&&t.pitch===n.pitch&&t.roll===n.roll},Vn.equalsEpsilon=function(t,n,r,i){return t===n||e(t)&&e(n)&&w.equalsEpsilon(t.heading,n.heading,r,i)&&w.equalsEpsilon(t.pitch,n.pitch,r,i)&&w.equalsEpsilon(t.roll,n.roll,r,i)},Vn.prototype.clone=function(t){return Vn.clone(this,t)},Vn.prototype.equals=function(t){return Vn.equals(this,t)},Vn.prototype.equalsEpsilon=function(t,n,e){return Vn.equalsEpsilon(this,t,n,e)},Vn.prototype.toString=function(){return`(${this.heading}, ${this.pitch}, ${this.roll})`};const Hn=/((?:.*\\/)|^)Cesium\\.js(?:\\?|\\#|$)/;let Yn,Zn,Wn;function Qn(t){return"undefined"==typeof document?t:(e(Yn)||(Yn=document.createElement("a")),Yn.href=t,Yn.href)}function Jn(){if(e(Zn))return Zn;let n;if(n="undefined"!=typeof CESIUM_BASE_URL?CESIUM_BASE_URL:e("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:t&&t.src||new URL("building-worker.generated.js",document.baseURI).href)?Jt(".","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:t&&t.src||new URL("building-worker.generated.js",document.baseURI).href):"object"==typeof define&&e(define.amd)&&!define.amd.toUrlUndefined&&e(require.toUrl)?Jt("..",Kn("Core/buildModuleUrl.js")):function(){const t=document.getElementsByTagName("script");for(let n=0,e=t.length;n<e;++n){const e=t[n].getAttribute("src"),r=Hn.exec(e);if(null!==r)return r[1]}}(),!e(n))throw new r("Unable to determine Cesium base URL automatically, try defining a global variable called CESIUM_BASE_URL.");return Zn=new $n({url:Qn(n)}),Zn.appendForwardSlash(),Zn}function Gn(t){return Qn(require.toUrl(`../${t}`))}function Xn(t){return Jn().getDerivedResource({url:t}).url}function Kn(t){return e(Wn)||(Wn="object"==typeof define&&e(define.amd)&&!define.amd.toUrlUndefined&&e(require.toUrl)?Gn:Xn),Wn(t)}function te(t,n,e){this.x=t,this.y=n,this.s=e}function ne(t){t=n(t,n.EMPTY_OBJECT),this.bt=$n.createIfNeeded(t.xysFileUrlTemplate),this.Mt=n(t.interpolationOrder,9),this.At=n(t.sampleZeroJulianEphemerisDate,2442396.5),this.xt=new It(this.At,0,ft.TAI),this.Et=n(t.stepSizeDays,1),this.kt=n(t.samplesPerXysFile,1e3),this.qt=n(t.totalSamples,27426),this.nt=new Array(3*this.qt),this.$t=[];const e=this.Mt,r=this.St=new Array(e+1),i=this.It=new Array(e+1),o=Math.pow(this.Et,e);for(let t=0;t<=e;++t){r[t]=o,i[t]=t*this.Et;for(let n=0;n<=e;++n)n!==t&&(r[t]*=t-n);r[t]=1/r[t]}this.Ot=new Array(e+1),this.Rt=new Array(e+1)}Kn.Pt=Hn,Kn.jt=Xn,Kn.Ft=function(){Zn=void 0},Kn.setBaseUrl=function(t){Zn=$n.DEFAULT.getDerivedResource({url:t})},Kn.getCesiumBaseUrl=Jn;const ee=new It(0,0,ft.TAI);function re(t,n,e){const r=ee;return r.dayNumber=n,r.secondsOfDay=e,It.daysDifference(r,t.xt)}function ie(t,n){if(t.$t[n])return t.$t[n];let r;const i=t.bt;r=e(i)?i.getDerivedResource({templateValues:{0:n}}):new $n({url:Kn(`Assets/IAU2006_XYS/IAU2006_XYS_${n}.json`)});const o=r.fetchJson().then((function(e){t.$t[n]=!1;const r=t.nt,i=e.samples,o=n*t.kt*3;for(let t=0,n=i.length;t<n;++t)r[o+t]=i[t]}));return t.$t[n]=o,o}function oe(t,e,r,i,o,u,s,c,a){this[0]=n(t,0),this[1]=n(i,0),this[2]=n(s,0),this[3]=n(e,0),this[4]=n(o,0),this[5]=n(c,0),this[6]=n(r,0),this[7]=n(u,0),this[8]=n(a,0)}ne.prototype.preload=function(t,n,e,r){const i=re(this,t,n),o=re(this,e,r);let u=i/this.Et-this.Mt/2|0;u<0&&(u=0);let s=o/this.Et-this.Mt/2|0+this.Mt;s>=this.qt&&(s=this.qt-1);const c=u/this.kt|0,a=s/this.kt|0,f=[];for(let t=c;t<=a;++t)f.push(ie(this,t));return Promise.all(f)},ne.prototype.computeXysRadians=function(t,n,r){const i=re(this,t,n);if(i<0)return;const o=i/this.Et|0;if(o>=this.qt)return;const u=this.Mt;let s=o-(u/2|0);s<0&&(s=0);let c=s+u;c>=this.qt&&(c=this.qt-1,s=c-u,s<0&&(s=0));let a=!1;const f=this.nt;if(e(f[3*s])||(ie(this,s/this.kt|0),a=!0),e(f[3*c])||(ie(this,c/this.kt|0),a=!0),a)return;e(r)?(r.x=0,r.y=0,r.s=0):r=new te(0,0,0);const h=i-s*this.Et,l=this.Ot,d=this.St,w=this.Rt,m=this.It;let g,v;for(g=0;g<=u;++g)l[g]=h-m[g];for(g=0;g<=u;++g){for(w[g]=1,v=0;v<=u;++v)v!==g&&(w[g]*=l[v]);w[g]*=d[g];let t=3*(s+g);r.x+=w[g]*f[t++],r.y+=w[g]*f[t++],r.s+=w[g]*f[t]}return r},oe.packedLength=9,oe.pack=function(t,e,r){return i.typeOf.object("value",t),i.defined("array",e),r=n(r,0),e[r++]=t[0],e[r++]=t[1],e[r++]=t[2],e[r++]=t[3],e[r++]=t[4],e[r++]=t[5],e[r++]=t[6],e[r++]=t[7],e[r++]=t[8],e},oe.unpack=function(t,r,o){return i.defined("array",t),r=n(r,0),e(o)||(o=new oe),o[0]=t[r++],o[1]=t[r++],o[2]=t[r++],o[3]=t[r++],o[4]=t[r++],o[5]=t[r++],o[6]=t[r++],o[7]=t[r++],o[8]=t[r++],o},oe.packArray=function(t,n){i.defined("array",t);const o=t.length,u=9*o;if(e(n)){if(!Array.isArray(n)&&n.length!==u)throw new r("If result is a typed array, it must have exactly array.length * 9 elements");n.length!==u&&(n.length=u)}else n=new Array(u);for(let e=0;e<o;++e)oe.pack(t[e],n,9*e);return n},oe.unpackArray=function(t,n){if(i.defined("array",t),i.typeOf.number.greaterThanOrEquals("array.length",t.length,9),t.length%9!=0)throw new r("array length must be a multiple of 9.");const o=t.length;e(n)?n.length=o/9:n=new Array(o/9);for(let e=0;e<o;e+=9){const r=e/9;n[r]=oe.unpack(t,e,n[r])}return n},oe.clone=function(t,n){if(e(t))return e(n)?(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n):new oe(t[0],t[3],t[6],t[1],t[4],t[7],t[2],t[5],t[8])},oe.fromArray=oe.unpack,oe.fromColumnMajorArray=function(t,n){return i.defined("values",t),oe.clone(t,n)},oe.fromRowMajorArray=function(t,n){return i.defined("values",t),e(n)?(n[0]=t[0],n[1]=t[3],n[2]=t[6],n[3]=t[1],n[4]=t[4],n[5]=t[7],n[6]=t[2],n[7]=t[5],n[8]=t[8],n):new oe(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},oe.fromQuaternion=function(t,n){i.typeOf.object("quaternion",t);const r=t.x*t.x,o=t.x*t.y,u=t.x*t.z,s=t.x*t.w,c=t.y*t.y,a=t.y*t.z,f=t.y*t.w,h=t.z*t.z,l=t.z*t.w,d=t.w*t.w,w=r-c-h+d,m=2*(o-l),g=2*(u+f),v=2*(o+l),p=-r+c-h+d,y=2*(a-s),b=2*(u-f),M=2*(a+s),A=-r-c+h+d;return e(n)?(n[0]=w,n[1]=v,n[2]=b,n[3]=m,n[4]=p,n[5]=M,n[6]=g,n[7]=y,n[8]=A,n):new oe(w,m,g,v,p,y,b,M,A)},oe.fromHeadingPitchRoll=function(t,n){i.typeOf.object("headingPitchRoll",t);const r=Math.cos(-t.pitch),o=Math.cos(-t.heading),u=Math.cos(t.roll),s=Math.sin(-t.pitch),c=Math.sin(-t.heading),a=Math.sin(t.roll),f=r*o,h=-u*c+a*s*o,l=a*c+u*s*o,d=r*c,w=u*o+a*s*c,m=-a*o+u*s*c,g=-s,v=a*r,p=u*r;return e(n)?(n[0]=f,n[1]=d,n[2]=g,n[3]=h,n[4]=w,n[5]=v,n[6]=l,n[7]=m,n[8]=p,n):new oe(f,h,l,d,w,m,g,v,p)},oe.fromScale=function(t,n){return i.typeOf.object("scale",t),e(n)?(n[0]=t.x,n[1]=0,n[2]=0,n[3]=0,n[4]=t.y,n[5]=0,n[6]=0,n[7]=0,n[8]=t.z,n):new oe(t.x,0,0,0,t.y,0,0,0,t.z)},oe.fromUniformScale=function(t,n){return i.typeOf.number("scale",t),e(n)?(n[0]=t,n[1]=0,n[2]=0,n[3]=0,n[4]=t,n[5]=0,n[6]=0,n[7]=0,n[8]=t,n):new oe(t,0,0,0,t,0,0,0,t)},oe.fromCrossProduct=function(t,n){return i.typeOf.object("vector",t),e(n)?(n[0]=0,n[1]=t.z,n[2]=-t.y,n[3]=-t.z,n[4]=0,n[5]=t.x,n[6]=t.y,n[7]=-t.x,n[8]=0,n):new oe(0,-t.z,t.y,t.z,0,-t.x,-t.y,t.x,0)},oe.fromRotationX=function(t,n){i.typeOf.number("angle",t);const r=Math.cos(t),o=Math.sin(t);return e(n)?(n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=r,n[5]=o,n[6]=0,n[7]=-o,n[8]=r,n):new oe(1,0,0,0,r,-o,0,o,r)},oe.fromRotationY=function(t,n){i.typeOf.number("angle",t);const r=Math.cos(t),o=Math.sin(t);return e(n)?(n[0]=r,n[1]=0,n[2]=-o,n[3]=0,n[4]=1,n[5]=0,n[6]=o,n[7]=0,n[8]=r,n):new oe(r,0,o,0,1,0,-o,0,r)},oe.fromRotationZ=function(t,n){i.typeOf.number("angle",t);const r=Math.cos(t),o=Math.sin(t);return e(n)?(n[0]=r,n[1]=o,n[2]=0,n[3]=-o,n[4]=r,n[5]=0,n[6]=0,n[7]=0,n[8]=1,n):new oe(r,-o,0,o,r,0,0,0,1)},oe.toArray=function(t,n){return i.typeOf.object("matrix",t),e(n)?(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n):[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8]]},oe.getElementIndex=function(t,n){return i.typeOf.number.greaterThanOrEquals("row",n,0),i.typeOf.number.lessThanOrEquals("row",n,2),i.typeOf.number.greaterThanOrEquals("column",t,0),i.typeOf.number.lessThanOrEquals("column",t,2),3*t+n},oe.getColumn=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.number.greaterThanOrEquals("index",n,0),i.typeOf.number.lessThanOrEquals("index",n,2),i.typeOf.object("result",e);const r=3*n,o=t[r],u=t[r+1],s=t[r+2];return e.x=o,e.y=u,e.z=s,e},oe.setColumn=function(t,n,e,r){i.typeOf.object("matrix",t),i.typeOf.number.greaterThanOrEquals("index",n,0),i.typeOf.number.lessThanOrEquals("index",n,2),i.typeOf.object("cartesian",e),i.typeOf.object("result",r);const o=3*n;return(r=oe.clone(t,r))[o]=e.x,r[o+1]=e.y,r[o+2]=e.z,r},oe.getRow=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.number.greaterThanOrEquals("index",n,0),i.typeOf.number.lessThanOrEquals("index",n,2),i.typeOf.object("result",e);const r=t[n],o=t[n+3],u=t[n+6];return e.x=r,e.y=o,e.z=u,e},oe.setRow=function(t,n,e,r){return i.typeOf.object("matrix",t),i.typeOf.number.greaterThanOrEquals("index",n,0),i.typeOf.number.lessThanOrEquals("index",n,2),i.typeOf.object("cartesian",e),i.typeOf.object("result",r),(r=oe.clone(t,r))[n]=e.x,r[n+3]=e.y,r[n+6]=e.z,r};const ue=new x;oe.setScale=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.object("scale",n),i.typeOf.object("result",e);const r=oe.getScale(t,ue),o=n.x/r.x,u=n.y/r.y,s=n.z/r.z;return e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e[3]=t[3]*u,e[4]=t[4]*u,e[5]=t[5]*u,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*s,e};const se=new x;oe.setUniformScale=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.number("scale",n),i.typeOf.object("result",e);const r=oe.getScale(t,se),o=n/r.x,u=n/r.y,s=n/r.z;return e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e[3]=t[3]*u,e[4]=t[4]*u,e[5]=t[5]*u,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*s,e};const ce=new x;oe.getScale=function(t,n){return i.typeOf.object("matrix",t),i.typeOf.object("result",n),n.x=x.magnitude(x.fromElements(t[0],t[1],t[2],ce)),n.y=x.magnitude(x.fromElements(t[3],t[4],t[5],ce)),n.z=x.magnitude(x.fromElements(t[6],t[7],t[8],ce)),n};const ae=new x;oe.getMaximumScale=function(t){return oe.getScale(t,ae),x.maximumComponent(ae)};const fe=new x;oe.setRotation=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.object("result",e);const r=oe.getScale(t,fe);return e[0]=n[0]*r.x,e[1]=n[1]*r.x,e[2]=n[2]*r.x,e[3]=n[3]*r.y,e[4]=n[4]*r.y,e[5]=n[5]*r.y,e[6]=n[6]*r.z,e[7]=n[7]*r.z,e[8]=n[8]*r.z,e};const he=new x;oe.getRotation=function(t,n){i.typeOf.object("matrix",t),i.typeOf.object("result",n);const e=oe.getScale(t,he);return n[0]=t[0]/e.x,n[1]=t[1]/e.x,n[2]=t[2]/e.x,n[3]=t[3]/e.y,n[4]=t[4]/e.y,n[5]=t[5]/e.y,n[6]=t[6]/e.z,n[7]=t[7]/e.z,n[8]=t[8]/e.z,n},oe.multiply=function(t,n,e){i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e);const r=t[0]*n[0]+t[3]*n[1]+t[6]*n[2],o=t[1]*n[0]+t[4]*n[1]+t[7]*n[2],u=t[2]*n[0]+t[5]*n[1]+t[8]*n[2],s=t[0]*n[3]+t[3]*n[4]+t[6]*n[5],c=t[1]*n[3]+t[4]*n[4]+t[7]*n[5],a=t[2]*n[3]+t[5]*n[4]+t[8]*n[5],f=t[0]*n[6]+t[3]*n[7]+t[6]*n[8],h=t[1]*n[6]+t[4]*n[7]+t[7]*n[8],l=t[2]*n[6]+t[5]*n[7]+t[8]*n[8];return e[0]=r,e[1]=o,e[2]=u,e[3]=s,e[4]=c,e[5]=a,e[6]=f,e[7]=h,e[8]=l,e},oe.add=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e},oe.subtract=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e},oe.multiplyByVector=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.object("cartesian",n),i.typeOf.object("result",e);const r=n.x,o=n.y,u=n.z,s=t[0]*r+t[3]*o+t[6]*u,c=t[1]*r+t[4]*o+t[7]*u,a=t[2]*r+t[5]*o+t[8]*u;return e.x=s,e.y=c,e.z=a,e},oe.multiplyByScalar=function(t,n,e){return i.typeOf.object("matrix",t),i.typeOf.number("scalar",n),i.typeOf.object("result",e),e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*n,e},oe.multiplyByScale=function(t,n,e){return i.typeOf.object("matrix",t),i.typeOf.object("scale",n),i.typeOf.object("result",e),e[0]=t[0]*n.x,e[1]=t[1]*n.x,e[2]=t[2]*n.x,e[3]=t[3]*n.y,e[4]=t[4]*n.y,e[5]=t[5]*n.y,e[6]=t[6]*n.z,e[7]=t[7]*n.z,e[8]=t[8]*n.z,e},oe.multiplyByUniformScale=function(t,n,e){return i.typeOf.object("matrix",t),i.typeOf.number("scale",n),i.typeOf.object("result",e),e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*n,e},oe.negate=function(t,n){return i.typeOf.object("matrix",t),i.typeOf.object("result",n),n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n[3]=-t[3],n[4]=-t[4],n[5]=-t[5],n[6]=-t[6],n[7]=-t[7],n[8]=-t[8],n},oe.transpose=function(t,n){i.typeOf.object("matrix",t),i.typeOf.object("result",n);const e=t[0],r=t[3],o=t[6],u=t[1],s=t[4],c=t[7],a=t[2],f=t[5],h=t[8];return n[0]=e,n[1]=r,n[2]=o,n[3]=u,n[4]=s,n[5]=c,n[6]=a,n[7]=f,n[8]=h,n};const le=[1,0,0],de=[2,2,1];function we(t){let n=0;for(let e=0;e<3;++e){const r=t[oe.getElementIndex(de[e],le[e])];n+=2*r*r}return Math.sqrt(n)}function me(t,n){const e=w.EPSILON15;let r=0,i=1;for(let n=0;n<3;++n){const e=Math.abs(t[oe.getElementIndex(de[n],le[n])]);e>r&&(i=n,r=e)}let o=1,u=0;const s=le[i],c=de[i];if(Math.abs(t[oe.getElementIndex(c,s)])>e){const n=(t[oe.getElementIndex(c,c)]-t[oe.getElementIndex(s,s)])/2/t[oe.getElementIndex(c,s)];let e;e=n<0?-1/(-n+Math.sqrt(1+n*n)):1/(n+Math.sqrt(1+n*n)),o=1/Math.sqrt(1+e*e),u=e*o}return(n=oe.clone(oe.IDENTITY,n))[oe.getElementIndex(s,s)]=n[oe.getElementIndex(c,c)]=o,n[oe.getElementIndex(c,s)]=u,n[oe.getElementIndex(s,c)]=-u,n}const ge=new oe,ve=new oe;oe.computeEigenDecomposition=function(t,n){i.typeOf.object("matrix",t);const r=w.EPSILON20;let o=0,u=0;e(n)||(n={});const s=n.unitary=oe.clone(oe.IDENTITY,n.unitary),c=n.diagonal=oe.clone(t,n.diagonal),a=r*function(t){let n=0;for(let e=0;e<9;++e){const r=t[e];n+=r*r}return Math.sqrt(n)}(c);for(;u<10&&we(c)>a;)me(c,ge),oe.transpose(ge,ve),oe.multiply(c,ge,c),oe.multiply(ve,c,c),oe.multiply(s,ge,s),++o>2&&(++u,o=0);return n},oe.abs=function(t,n){return i.typeOf.object("matrix",t),i.typeOf.object("result",n),n[0]=Math.abs(t[0]),n[1]=Math.abs(t[1]),n[2]=Math.abs(t[2]),n[3]=Math.abs(t[3]),n[4]=Math.abs(t[4]),n[5]=Math.abs(t[5]),n[6]=Math.abs(t[6]),n[7]=Math.abs(t[7]),n[8]=Math.abs(t[8]),n},oe.determinant=function(t){i.typeOf.object("matrix",t);const n=t[0],e=t[3],r=t[6],o=t[1],u=t[4],s=t[7],c=t[2],a=t[5],f=t[8];return n*(u*f-a*s)+o*(a*r-e*f)+c*(e*s-u*r)},oe.inverse=function(t,n){i.typeOf.object("matrix",t),i.typeOf.object("result",n);const e=t[0],o=t[1],u=t[2],s=t[3],c=t[4],a=t[5],f=t[6],h=t[7],l=t[8],d=oe.determinant(t);if(Math.abs(d)<=w.EPSILON15)throw new r("matrix is not invertible");n[0]=c*l-h*a,n[1]=h*u-o*l,n[2]=o*a-c*u,n[3]=f*a-s*l,n[4]=e*l-f*u,n[5]=s*u-e*a,n[6]=s*h-f*c,n[7]=f*o-e*h,n[8]=e*c-s*o;const m=1/d;return oe.multiplyByScalar(n,m,n)};const pe=new oe;function ye(t,e,r,i,o,u,s,c,a,f,h,l,d,w,m,g){this[0]=n(t,0),this[1]=n(o,0),this[2]=n(a,0),this[3]=n(d,0),this[4]=n(e,0),this[5]=n(u,0),this[6]=n(f,0),this[7]=n(w,0),this[8]=n(r,0),this[9]=n(s,0),this[10]=n(h,0),this[11]=n(m,0),this[12]=n(i,0),this[13]=n(c,0),this[14]=n(l,0),this[15]=n(g,0)}oe.inverseTranspose=function(t,n){return i.typeOf.object("matrix",t),i.typeOf.object("result",n),oe.inverse(oe.transpose(t,pe),n)},oe.equals=function(t,n){return t===n||e(t)&&e(n)&&t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]&&t[4]===n[4]&&t[5]===n[5]&&t[6]===n[6]&&t[7]===n[7]&&t[8]===n[8]},oe.equalsEpsilon=function(t,r,i){return i=n(i,0),t===r||e(t)&&e(r)&&Math.abs(t[0]-r[0])<=i&&Math.abs(t[1]-r[1])<=i&&Math.abs(t[2]-r[2])<=i&&Math.abs(t[3]-r[3])<=i&&Math.abs(t[4]-r[4])<=i&&Math.abs(t[5]-r[5])<=i&&Math.abs(t[6]-r[6])<=i&&Math.abs(t[7]-r[7])<=i&&Math.abs(t[8]-r[8])<=i},oe.IDENTITY=Object.freeze(new oe(1,0,0,0,1,0,0,0,1)),oe.ZERO=Object.freeze(new oe(0,0,0,0,0,0,0,0,0)),oe.COLUMN0ROW0=0,oe.COLUMN0ROW1=1,oe.COLUMN0ROW2=2,oe.COLUMN1ROW0=3,oe.COLUMN1ROW1=4,oe.COLUMN1ROW2=5,oe.COLUMN2ROW0=6,oe.COLUMN2ROW1=7,oe.COLUMN2ROW2=8,Object.defineProperties(oe.prototype,{length:{get:function(){return oe.packedLength}}}),oe.prototype.clone=function(t){return oe.clone(this,t)},oe.prototype.equals=function(t){return oe.equals(this,t)},oe.equalsArray=function(t,n,e){return t[0]===n[e]&&t[1]===n[e+1]&&t[2]===n[e+2]&&t[3]===n[e+3]&&t[4]===n[e+4]&&t[5]===n[e+5]&&t[6]===n[e+6]&&t[7]===n[e+7]&&t[8]===n[e+8]},oe.prototype.equalsEpsilon=function(t,n){return oe.equalsEpsilon(this,t,n)},oe.prototype.toString=function(){return`(${this[0]}, ${this[3]}, ${this[6]})\\n(${this[1]}, ${this[4]}, ${this[7]})\\n(${this[2]}, ${this[5]}, ${this[8]})`},ye.packedLength=16,ye.pack=function(t,e,r){return i.typeOf.object("value",t),i.defined("array",e),r=n(r,0),e[r++]=t[0],e[r++]=t[1],e[r++]=t[2],e[r++]=t[3],e[r++]=t[4],e[r++]=t[5],e[r++]=t[6],e[r++]=t[7],e[r++]=t[8],e[r++]=t[9],e[r++]=t[10],e[r++]=t[11],e[r++]=t[12],e[r++]=t[13],e[r++]=t[14],e[r]=t[15],e},ye.unpack=function(t,r,o){return i.defined("array",t),r=n(r,0),e(o)||(o=new ye),o[0]=t[r++],o[1]=t[r++],o[2]=t[r++],o[3]=t[r++],o[4]=t[r++],o[5]=t[r++],o[6]=t[r++],o[7]=t[r++],o[8]=t[r++],o[9]=t[r++],o[10]=t[r++],o[11]=t[r++],o[12]=t[r++],o[13]=t[r++],o[14]=t[r++],o[15]=t[r],o},ye.packArray=function(t,n){i.defined("array",t);const o=t.length,u=16*o;if(e(n)){if(!Array.isArray(n)&&n.length!==u)throw new r("If result is a typed array, it must have exactly array.length * 16 elements");n.length!==u&&(n.length=u)}else n=new Array(u);for(let e=0;e<o;++e)ye.pack(t[e],n,16*e);return n},ye.unpackArray=function(t,n){if(i.defined("array",t),i.typeOf.number.greaterThanOrEquals("array.length",t.length,16),t.length%16!=0)throw new r("array length must be a multiple of 16.");const o=t.length;e(n)?n.length=o/16:n=new Array(o/16);for(let e=0;e<o;e+=16){const r=e/16;n[r]=ye.unpack(t,e,n[r])}return n},ye.clone=function(t,n){if(e(t))return e(n)?(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n):new ye(t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15])},ye.fromArray=ye.unpack,ye.fromColumnMajorArray=function(t,n){return i.defined("values",t),ye.clone(t,n)},ye.fromRowMajorArray=function(t,n){return i.defined("values",t),e(n)?(n[0]=t[0],n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=t[1],n[5]=t[5],n[6]=t[9],n[7]=t[13],n[8]=t[2],n[9]=t[6],n[10]=t[10],n[11]=t[14],n[12]=t[3],n[13]=t[7],n[14]=t[11],n[15]=t[15],n):new ye(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},ye.fromRotationTranslation=function(t,r,o){return i.typeOf.object("rotation",t),r=n(r,x.ZERO),e(o)?(o[0]=t[0],o[1]=t[1],o[2]=t[2],o[3]=0,o[4]=t[3],o[5]=t[4],o[6]=t[5],o[7]=0,o[8]=t[6],o[9]=t[7],o[10]=t[8],o[11]=0,o[12]=r.x,o[13]=r.y,o[14]=r.z,o[15]=1,o):new ye(t[0],t[3],t[6],r.x,t[1],t[4],t[7],r.y,t[2],t[5],t[8],r.z,0,0,0,1)},ye.fromTranslationQuaternionRotationScale=function(t,n,r,o){i.typeOf.object("translation",t),i.typeOf.object("rotation",n),i.typeOf.object("scale",r),e(o)||(o=new ye);const u=r.x,s=r.y,c=r.z,a=n.x*n.x,f=n.x*n.y,h=n.x*n.z,l=n.x*n.w,d=n.y*n.y,w=n.y*n.z,m=n.y*n.w,g=n.z*n.z,v=n.z*n.w,p=n.w*n.w,y=a-d-g+p,b=2*(f-v),M=2*(h+m),A=2*(f+v),x=-a+d-g+p,E=2*(w-l),k=2*(h-m),q=2*(w+l),$=-a-d+g+p;return o[0]=y*u,o[1]=A*u,o[2]=k*u,o[3]=0,o[4]=b*s,o[5]=x*s,o[6]=q*s,o[7]=0,o[8]=M*c,o[9]=E*c,o[10]=$*c,o[11]=0,o[12]=t.x,o[13]=t.y,o[14]=t.z,o[15]=1,o},ye.fromTranslationRotationScale=function(t,n){return i.typeOf.object("translationRotationScale",t),ye.fromTranslationQuaternionRotationScale(t.translation,t.rotation,t.scale,n)},ye.fromTranslation=function(t,n){return i.typeOf.object("translation",t),ye.fromRotationTranslation(oe.IDENTITY,t,n)},ye.fromScale=function(t,n){return i.typeOf.object("scale",t),e(n)?(n[0]=t.x,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=t.y,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=t.z,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n):new ye(t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1)},ye.fromUniformScale=function(t,n){return i.typeOf.number("scale",t),e(n)?(n[0]=t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=t,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=t,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n):new ye(t,0,0,0,0,t,0,0,0,0,t,0,0,0,0,1)},ye.fromRotation=function(t,n){return i.typeOf.object("rotation",t),e(n)||(n=new ye),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=0,n[4]=t[3],n[5]=t[4],n[6]=t[5],n[7]=0,n[8]=t[6],n[9]=t[7],n[10]=t[8],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n};const be=new x,Me=new x,Ae=new x;ye.fromCamera=function(t,n){i.typeOf.object("camera",t);const r=t.position,o=t.direction,u=t.up;i.typeOf.object("camera.position",r),i.typeOf.object("camera.direction",o),i.typeOf.object("camera.up",u),x.normalize(o,be),x.normalize(x.cross(be,u,Me),Me),x.normalize(x.cross(Me,be,Ae),Ae);const s=Me.x,c=Me.y,a=Me.z,f=be.x,h=be.y,l=be.z,d=Ae.x,w=Ae.y,m=Ae.z,g=r.x,v=r.y,p=r.z,y=s*-g+c*-v+a*-p,b=d*-g+w*-v+m*-p,M=f*g+h*v+l*p;return e(n)?(n[0]=s,n[1]=d,n[2]=-f,n[3]=0,n[4]=c,n[5]=w,n[6]=-h,n[7]=0,n[8]=a,n[9]=m,n[10]=-l,n[11]=0,n[12]=y,n[13]=b,n[14]=M,n[15]=1,n):new ye(s,c,a,y,d,w,m,b,-f,-h,-l,M,0,0,0,1)},ye.computePerspectiveFieldOfView=function(t,n,e,r,o){i.typeOf.number.greaterThan("fovY",t,0),i.typeOf.number.lessThan("fovY",t,Math.PI),i.typeOf.number.greaterThan("near",e,0),i.typeOf.number.greaterThan("far",r,0),i.typeOf.object("result",o);const u=1/Math.tan(.5*t),s=u/n,c=(r+e)/(e-r),a=2*r*e/(e-r);return o[0]=s,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=u,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=c,o[11]=-1,o[12]=0,o[13]=0,o[14]=a,o[15]=0,o},ye.computeOrthographicOffCenter=function(t,n,e,r,o,u,s){i.typeOf.number("left",t),i.typeOf.number("right",n),i.typeOf.number("bottom",e),i.typeOf.number("top",r),i.typeOf.number("near",o),i.typeOf.number("far",u),i.typeOf.object("result",s);let c=1/(n-t),a=1/(r-e),f=1/(u-o);const h=-(n+t)*c,l=-(r+e)*a,d=-(u+o)*f;return c*=2,a*=2,f*=-2,s[0]=c,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=a,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=f,s[11]=0,s[12]=h,s[13]=l,s[14]=d,s[15]=1,s},ye.computePerspectiveOffCenter=function(t,n,e,r,o,u,s){i.typeOf.number("left",t),i.typeOf.number("right",n),i.typeOf.number("bottom",e),i.typeOf.number("top",r),i.typeOf.number("near",o),i.typeOf.number("far",u),i.typeOf.object("result",s);const c=2*o/(n-t),a=2*o/(r-e),f=(n+t)/(n-t),h=(r+e)/(r-e),l=-(u+o)/(u-o),d=-2*u*o/(u-o);return s[0]=c,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=a,s[6]=0,s[7]=0,s[8]=f,s[9]=h,s[10]=l,s[11]=-1,s[12]=0,s[13]=0,s[14]=d,s[15]=0,s},ye.computeInfinitePerspectiveOffCenter=function(t,n,e,r,o,u){i.typeOf.number("left",t),i.typeOf.number("right",n),i.typeOf.number("bottom",e),i.typeOf.number("top",r),i.typeOf.number("near",o),i.typeOf.object("result",u);const s=2*o/(n-t),c=2*o/(r-e),a=(n+t)/(n-t),f=(r+e)/(r-e),h=-2*o;return u[0]=s,u[1]=0,u[2]=0,u[3]=0,u[4]=0,u[5]=c,u[6]=0,u[7]=0,u[8]=a,u[9]=f,u[10]=-1,u[11]=-1,u[12]=0,u[13]=0,u[14]=h,u[15]=0,u},ye.computeViewportTransformation=function(t,r,i,o){e(o)||(o=new ye),t=n(t,n.EMPTY_OBJECT);const u=n(t.x,0),s=n(t.y,0),c=n(t.width,0),a=n(t.height,0);r=n(r,0);const f=.5*c,h=.5*a,l=.5*((i=n(i,1))-r),d=f,w=h,m=l,g=u+f,v=s+h,p=r+l;return o[0]=d,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=w,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=m,o[11]=0,o[12]=g,o[13]=v,o[14]=p,o[15]=1,o},ye.computeView=function(t,n,e,r,o){return i.typeOf.object("position",t),i.typeOf.object("direction",n),i.typeOf.object("up",e),i.typeOf.object("right",r),i.typeOf.object("result",o),o[0]=r.x,o[1]=e.x,o[2]=-n.x,o[3]=0,o[4]=r.y,o[5]=e.y,o[6]=-n.y,o[7]=0,o[8]=r.z,o[9]=e.z,o[10]=-n.z,o[11]=0,o[12]=-x.dot(r,t),o[13]=-x.dot(e,t),o[14]=x.dot(n,t),o[15]=1,o},ye.toArray=function(t,n){return i.typeOf.object("matrix",t),e(n)?(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n):[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]]},ye.getElementIndex=function(t,n){return i.typeOf.number.greaterThanOrEquals("row",n,0),i.typeOf.number.lessThanOrEquals("row",n,3),i.typeOf.number.greaterThanOrEquals("column",t,0),i.typeOf.number.lessThanOrEquals("column",t,3),4*t+n},ye.getColumn=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.number.greaterThanOrEquals("index",n,0),i.typeOf.number.lessThanOrEquals("index",n,3),i.typeOf.object("result",e);const r=4*n,o=t[r],u=t[r+1],s=t[r+2],c=t[r+3];return e.x=o,e.y=u,e.z=s,e.w=c,e},ye.setColumn=function(t,n,e,r){i.typeOf.object("matrix",t),i.typeOf.number.greaterThanOrEquals("index",n,0),i.typeOf.number.lessThanOrEquals("index",n,3),i.typeOf.object("cartesian",e),i.typeOf.object("result",r);const o=4*n;return(r=ye.clone(t,r))[o]=e.x,r[o+1]=e.y,r[o+2]=e.z,r[o+3]=e.w,r},ye.getRow=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.number.greaterThanOrEquals("index",n,0),i.typeOf.number.lessThanOrEquals("index",n,3),i.typeOf.object("result",e);const r=t[n],o=t[n+4],u=t[n+8],s=t[n+12];return e.x=r,e.y=o,e.z=u,e.w=s,e},ye.setRow=function(t,n,e,r){return i.typeOf.object("matrix",t),i.typeOf.number.greaterThanOrEquals("index",n,0),i.typeOf.number.lessThanOrEquals("index",n,3),i.typeOf.object("cartesian",e),i.typeOf.object("result",r),(r=ye.clone(t,r))[n]=e.x,r[n+4]=e.y,r[n+8]=e.z,r[n+12]=e.w,r},ye.setTranslation=function(t,n,e){return i.typeOf.object("matrix",t),i.typeOf.object("translation",n),i.typeOf.object("result",e),e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=n.x,e[13]=n.y,e[14]=n.z,e[15]=t[15],e};const xe=new x;ye.setScale=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.object("scale",n),i.typeOf.object("result",e);const r=ye.getScale(t,xe),o=n.x/r.x,u=n.y/r.y,s=n.z/r.z;return e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e[3]=t[3],e[4]=t[4]*u,e[5]=t[5]*u,e[6]=t[6]*u,e[7]=t[7],e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e};const Ee=new x;ye.setUniformScale=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.number("scale",n),i.typeOf.object("result",e);const r=ye.getScale(t,Ee),o=n/r.x,u=n/r.y,s=n/r.z;return e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e[3]=t[3],e[4]=t[4]*u,e[5]=t[5]*u,e[6]=t[6]*u,e[7]=t[7],e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e};const ke=new x;ye.getScale=function(t,n){return i.typeOf.object("matrix",t),i.typeOf.object("result",n),n.x=x.magnitude(x.fromElements(t[0],t[1],t[2],ke)),n.y=x.magnitude(x.fromElements(t[4],t[5],t[6],ke)),n.z=x.magnitude(x.fromElements(t[8],t[9],t[10],ke)),n};const qe=new x;ye.getMaximumScale=function(t){return ye.getScale(t,qe),x.maximumComponent(qe)};const $e=new x;ye.setRotation=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.object("result",e);const r=ye.getScale(t,$e);return e[0]=n[0]*r.x,e[1]=n[1]*r.x,e[2]=n[2]*r.x,e[3]=t[3],e[4]=n[3]*r.y,e[5]=n[4]*r.y,e[6]=n[5]*r.y,e[7]=t[7],e[8]=n[6]*r.z,e[9]=n[7]*r.z,e[10]=n[8]*r.z,e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e};const Se=new x;ye.getRotation=function(t,n){i.typeOf.object("matrix",t),i.typeOf.object("result",n);const e=ye.getScale(t,Se);return n[0]=t[0]/e.x,n[1]=t[1]/e.x,n[2]=t[2]/e.x,n[3]=t[4]/e.y,n[4]=t[5]/e.y,n[5]=t[6]/e.y,n[6]=t[8]/e.z,n[7]=t[9]/e.z,n[8]=t[10]/e.z,n},ye.multiply=function(t,n,e){i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e);const r=t[0],o=t[1],u=t[2],s=t[3],c=t[4],a=t[5],f=t[6],h=t[7],l=t[8],d=t[9],w=t[10],m=t[11],g=t[12],v=t[13],p=t[14],y=t[15],b=n[0],M=n[1],A=n[2],x=n[3],E=n[4],k=n[5],q=n[6],$=n[7],S=n[8],I=n[9],O=n[10],R=n[11],P=n[12],j=n[13],F=n[14],N=n[15],U=r*b+c*M+l*A+g*x,T=o*b+a*M+d*A+v*x,z=u*b+f*M+w*A+p*x,C=s*b+h*M+m*A+y*x,D=r*E+c*k+l*q+g*$,B=o*E+a*k+d*q+v*$,L=u*E+f*k+w*q+p*$,_=s*E+h*k+m*q+y*$,V=r*S+c*I+l*O+g*R,H=o*S+a*I+d*O+v*R,Y=u*S+f*I+w*O+p*R,Z=s*S+h*I+m*O+y*R,W=r*P+c*j+l*F+g*N,Q=o*P+a*j+d*F+v*N,J=u*P+f*j+w*F+p*N,G=s*P+h*j+m*F+y*N;return e[0]=U,e[1]=T,e[2]=z,e[3]=C,e[4]=D,e[5]=B,e[6]=L,e[7]=_,e[8]=V,e[9]=H,e[10]=Y,e[11]=Z,e[12]=W,e[13]=Q,e[14]=J,e[15]=G,e},ye.add=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e[9]=t[9]+n[9],e[10]=t[10]+n[10],e[11]=t[11]+n[11],e[12]=t[12]+n[12],e[13]=t[13]+n[13],e[14]=t[14]+n[14],e[15]=t[15]+n[15],e},ye.subtract=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e[9]=t[9]-n[9],e[10]=t[10]-n[10],e[11]=t[11]-n[11],e[12]=t[12]-n[12],e[13]=t[13]-n[13],e[14]=t[14]-n[14],e[15]=t[15]-n[15],e},ye.multiplyTransformation=function(t,n,e){i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e);const r=t[0],o=t[1],u=t[2],s=t[4],c=t[5],a=t[6],f=t[8],h=t[9],l=t[10],d=t[12],w=t[13],m=t[14],g=n[0],v=n[1],p=n[2],y=n[4],b=n[5],M=n[6],A=n[8],x=n[9],E=n[10],k=n[12],q=n[13],$=n[14],S=r*g+s*v+f*p,I=o*g+c*v+h*p,O=u*g+a*v+l*p,R=r*y+s*b+f*M,P=o*y+c*b+h*M,j=u*y+a*b+l*M,F=r*A+s*x+f*E,N=o*A+c*x+h*E,U=u*A+a*x+l*E,T=r*k+s*q+f*$+d,z=o*k+c*q+h*$+w,C=u*k+a*q+l*$+m;return e[0]=S,e[1]=I,e[2]=O,e[3]=0,e[4]=R,e[5]=P,e[6]=j,e[7]=0,e[8]=F,e[9]=N,e[10]=U,e[11]=0,e[12]=T,e[13]=z,e[14]=C,e[15]=1,e},ye.multiplyByMatrix3=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.object("rotation",n),i.typeOf.object("result",e);const r=t[0],o=t[1],u=t[2],s=t[4],c=t[5],a=t[6],f=t[8],h=t[9],l=t[10],d=n[0],w=n[1],m=n[2],g=n[3],v=n[4],p=n[5],y=n[6],b=n[7],M=n[8],A=r*d+s*w+f*m,x=o*d+c*w+h*m,E=u*d+a*w+l*m,k=r*g+s*v+f*p,q=o*g+c*v+h*p,$=u*g+a*v+l*p,S=r*y+s*b+f*M,I=o*y+c*b+h*M,O=u*y+a*b+l*M;return e[0]=A,e[1]=x,e[2]=E,e[3]=0,e[4]=k,e[5]=q,e[6]=$,e[7]=0,e[8]=S,e[9]=I,e[10]=O,e[11]=0,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},ye.multiplyByTranslation=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.object("translation",n),i.typeOf.object("result",e);const r=n.x,o=n.y,u=n.z,s=r*t[0]+o*t[4]+u*t[8]+t[12],c=r*t[1]+o*t[5]+u*t[9]+t[13],a=r*t[2]+o*t[6]+u*t[10]+t[14];return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=s,e[13]=c,e[14]=a,e[15]=t[15],e},ye.multiplyByScale=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.object("scale",n),i.typeOf.object("result",e);const r=n.x,o=n.y,u=n.z;return 1===r&&1===o&&1===u?ye.clone(t,e):(e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=t[3],e[4]=o*t[4],e[5]=o*t[5],e[6]=o*t[6],e[7]=t[7],e[8]=u*t[8],e[9]=u*t[9],e[10]=u*t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e)},ye.multiplyByUniformScale=function(t,n,e){return i.typeOf.object("matrix",t),i.typeOf.number("scale",n),i.typeOf.object("result",e),e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3],e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7],e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},ye.multiplyByVector=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.object("cartesian",n),i.typeOf.object("result",e);const r=n.x,o=n.y,u=n.z,s=n.w,c=t[0]*r+t[4]*o+t[8]*u+t[12]*s,a=t[1]*r+t[5]*o+t[9]*u+t[13]*s,f=t[2]*r+t[6]*o+t[10]*u+t[14]*s,h=t[3]*r+t[7]*o+t[11]*u+t[15]*s;return e.x=c,e.y=a,e.z=f,e.w=h,e},ye.multiplyByPointAsVector=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.object("cartesian",n),i.typeOf.object("result",e);const r=n.x,o=n.y,u=n.z,s=t[0]*r+t[4]*o+t[8]*u,c=t[1]*r+t[5]*o+t[9]*u,a=t[2]*r+t[6]*o+t[10]*u;return e.x=s,e.y=c,e.z=a,e},ye.multiplyByPoint=function(t,n,e){i.typeOf.object("matrix",t),i.typeOf.object("cartesian",n),i.typeOf.object("result",e);const r=n.x,o=n.y,u=n.z,s=t[0]*r+t[4]*o+t[8]*u+t[12],c=t[1]*r+t[5]*o+t[9]*u+t[13],a=t[2]*r+t[6]*o+t[10]*u+t[14];return e.x=s,e.y=c,e.z=a,e},ye.multiplyByScalar=function(t,n,e){return i.typeOf.object("matrix",t),i.typeOf.number("scalar",n),i.typeOf.object("result",e),e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12]*n,e[13]=t[13]*n,e[14]=t[14]*n,e[15]=t[15]*n,e},ye.negate=function(t,n){return i.typeOf.object("matrix",t),i.typeOf.object("result",n),n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n[3]=-t[3],n[4]=-t[4],n[5]=-t[5],n[6]=-t[6],n[7]=-t[7],n[8]=-t[8],n[9]=-t[9],n[10]=-t[10],n[11]=-t[11],n[12]=-t[12],n[13]=-t[13],n[14]=-t[14],n[15]=-t[15],n},ye.transpose=function(t,n){i.typeOf.object("matrix",t),i.typeOf.object("result",n);const e=t[1],r=t[2],o=t[3],u=t[6],s=t[7],c=t[11];return n[0]=t[0],n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=e,n[5]=t[5],n[6]=t[9],n[7]=t[13],n[8]=r,n[9]=u,n[10]=t[10],n[11]=t[14],n[12]=o,n[13]=s,n[14]=c,n[15]=t[15],n},ye.abs=function(t,n){return i.typeOf.object("matrix",t),i.typeOf.object("result",n),n[0]=Math.abs(t[0]),n[1]=Math.abs(t[1]),n[2]=Math.abs(t[2]),n[3]=Math.abs(t[3]),n[4]=Math.abs(t[4]),n[5]=Math.abs(t[5]),n[6]=Math.abs(t[6]),n[7]=Math.abs(t[7]),n[8]=Math.abs(t[8]),n[9]=Math.abs(t[9]),n[10]=Math.abs(t[10]),n[11]=Math.abs(t[11]),n[12]=Math.abs(t[12]),n[13]=Math.abs(t[13]),n[14]=Math.abs(t[14]),n[15]=Math.abs(t[15]),n},ye.equals=function(t,n){return t===n||e(t)&&e(n)&&t[12]===n[12]&&t[13]===n[13]&&t[14]===n[14]&&t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[4]===n[4]&&t[5]===n[5]&&t[6]===n[6]&&t[8]===n[8]&&t[9]===n[9]&&t[10]===n[10]&&t[3]===n[3]&&t[7]===n[7]&&t[11]===n[11]&&t[15]===n[15]},ye.equalsEpsilon=function(t,r,i){return i=n(i,0),t===r||e(t)&&e(r)&&Math.abs(t[0]-r[0])<=i&&Math.abs(t[1]-r[1])<=i&&Math.abs(t[2]-r[2])<=i&&Math.abs(t[3]-r[3])<=i&&Math.abs(t[4]-r[4])<=i&&Math.abs(t[5]-r[5])<=i&&Math.abs(t[6]-r[6])<=i&&Math.abs(t[7]-r[7])<=i&&Math.abs(t[8]-r[8])<=i&&Math.abs(t[9]-r[9])<=i&&Math.abs(t[10]-r[10])<=i&&Math.abs(t[11]-r[11])<=i&&Math.abs(t[12]-r[12])<=i&&Math.abs(t[13]-r[13])<=i&&Math.abs(t[14]-r[14])<=i&&Math.abs(t[15]-r[15])<=i},ye.getTranslation=function(t,n){return i.typeOf.object("matrix",t),i.typeOf.object("result",n),n.x=t[12],n.y=t[13],n.z=t[14],n},ye.getMatrix3=function(t,n){return i.typeOf.object("matrix",t),i.typeOf.object("result",n),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[4],n[4]=t[5],n[5]=t[6],n[6]=t[8],n[7]=t[9],n[8]=t[10],n};const Ie=new oe,Oe=new oe,Re=new Q,Pe=new Q(0,0,0,1);ye.inverse=function(t,n){i.typeOf.object("matrix",t),i.typeOf.object("result",n);const e=t[0],r=t[4],o=t[8],u=t[12],s=t[1],c=t[5],a=t[9],f=t[13],h=t[2],l=t[6],d=t[10],m=t[14],g=t[3],v=t[7],p=t[11],y=t[15];let b=d*y,M=m*p,A=l*y,x=m*v,E=l*p,k=d*v,q=h*y,$=m*g,S=h*p,I=d*g,O=h*v,R=l*g;const P=b*c+x*a+E*f-(M*c+A*a+k*f),j=M*s+q*a+I*f-(b*s+$*a+S*f),F=A*s+$*c+O*f-(x*s+q*c+R*f),N=k*s+S*c+R*a-(E*s+I*c+O*a),U=M*r+A*o+k*u-(b*r+x*o+E*u),T=b*e+$*o+S*u-(M*e+q*o+I*u),z=x*e+q*r+R*u-(A*e+$*r+O*u),C=E*e+I*r+O*o-(k*e+S*r+R*o);b=o*f,M=u*a,A=r*f,x=u*c,E=r*a,k=o*c,q=e*f,$=u*s,S=e*a,I=o*s,O=e*c,R=r*s;const D=b*v+x*p+E*y-(M*v+A*p+k*y),B=M*g+q*p+I*y-(b*g+$*p+S*y),L=A*g+$*v+O*y-(x*g+q*v+R*y),_=k*g+S*v+R*p-(E*g+I*v+O*p),V=A*d+k*m+M*l-(E*m+b*l+x*d),H=S*m+b*h+$*d-(q*d+I*m+M*h),Y=q*l+R*m+x*h-(O*m+A*h+$*l),Z=O*d+E*h+I*l-(S*l+R*d+k*h);let W=e*P+r*j+o*F+u*N;if(Math.abs(W)<w.EPSILON21){if(oe.equalsEpsilon(ye.getMatrix3(t,Ie),Oe,w.EPSILON7)&&Q.equals(ye.getRow(t,3,Re),Pe))return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=0,n[11]=0,n[12]=-t[12],n[13]=-t[13],n[14]=-t[14],n[15]=1,n;throw new xn("matrix is not invertible because its determinate is zero.")}return W=1/W,n[0]=P*W,n[1]=j*W,n[2]=F*W,n[3]=N*W,n[4]=U*W,n[5]=T*W,n[6]=z*W,n[7]=C*W,n[8]=D*W,n[9]=B*W,n[10]=L*W,n[11]=_*W,n[12]=V*W,n[13]=H*W,n[14]=Y*W,n[15]=Z*W,n},ye.inverseTransformation=function(t,n){i.typeOf.object("matrix",t),i.typeOf.object("result",n);const e=t[0],r=t[1],o=t[2],u=t[4],s=t[5],c=t[6],a=t[8],f=t[9],h=t[10],l=t[12],d=t[13],w=t[14],m=-e*l-r*d-o*w,g=-u*l-s*d-c*w,v=-a*l-f*d-h*w;return n[0]=e,n[1]=u,n[2]=a,n[3]=0,n[4]=r,n[5]=s,n[6]=f,n[7]=0,n[8]=o,n[9]=c,n[10]=h,n[11]=0,n[12]=m,n[13]=g,n[14]=v,n[15]=1,n};const je=new ye;let Fe;ye.inverseTranspose=function(t,n){return i.typeOf.object("matrix",t),i.typeOf.object("result",n),ye.inverse(ye.transpose(t,je),n)},ye.IDENTITY=Object.freeze(new ye(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)),ye.ZERO=Object.freeze(new ye(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)),ye.COLUMN0ROW0=0,ye.COLUMN0ROW1=1,ye.COLUMN0ROW2=2,ye.COLUMN0ROW3=3,ye.COLUMN1ROW0=4,ye.COLUMN1ROW1=5,ye.COLUMN1ROW2=6,ye.COLUMN1ROW3=7,ye.COLUMN2ROW0=8,ye.COLUMN2ROW1=9,ye.COLUMN2ROW2=10,ye.COLUMN2ROW3=11,ye.COLUMN3ROW0=12,ye.COLUMN3ROW1=13,ye.COLUMN3ROW2=14,ye.COLUMN3ROW3=15,Object.defineProperties(ye.prototype,{length:{get:function(){return ye.packedLength}}}),ye.prototype.clone=function(t){return ye.clone(this,t)},ye.prototype.equals=function(t){return ye.equals(this,t)},ye.equalsArray=function(t,n,e){return t[0]===n[e]&&t[1]===n[e+1]&&t[2]===n[e+2]&&t[3]===n[e+3]&&t[4]===n[e+4]&&t[5]===n[e+5]&&t[6]===n[e+6]&&t[7]===n[e+7]&&t[8]===n[e+8]&&t[9]===n[e+9]&&t[10]===n[e+10]&&t[11]===n[e+11]&&t[12]===n[e+12]&&t[13]===n[e+13]&&t[14]===n[e+14]&&t[15]===n[e+15]},ye.prototype.equalsEpsilon=function(t,n){return ye.equalsEpsilon(this,t,n)},ye.prototype.toString=function(){return`(${this[0]}, ${this[4]}, ${this[8]}, ${this[12]})\\n(${this[1]}, ${this[5]}, ${this[9]}, ${this[13]})\\n(${this[2]}, ${this[6]}, ${this[10]}, ${this[14]})\\n(${this[3]}, ${this[7]}, ${this[11]}, ${this[15]})`};const Ne={requestFullscreen:void 0,exitFullscreen:void 0,fullscreenEnabled:void 0,fullscreenElement:void 0,fullscreenchange:void 0,fullscreenerror:void 0},Ue={};let Te,ze,Ce,De,Be,Le,_e,Ve,He,Ye,Ze,We,Qe,Je,Ge,Xe,Ke,tr;function nr(t){const n=t.split(".");for(let t=0,e=n.length;t<e;++t)n[t]=parseInt(n[t],10);return n}function er(){if(!e(ze)&&(ze=!1,!ur())){const t=/ Chrome\\/([\\.0-9]+)/.exec(Te.userAgent);null!==t&&(ze=!0,Ce=nr(t[1]))}return ze}function rr(){if(!e(De)&&(De=!1,!er()&&!ur()&&/ Safari\\/[\\.0-9]+/.test(Te.userAgent))){const t=/ Version\\/([\\.0-9]+)/.exec(Te.userAgent);null!==t&&(De=!0,Be=nr(t[1]))}return De}function ir(){if(!e(Le)){Le=!1;const t=/ AppleWebKit\\/([\\.0-9]+)(\\+?)/.exec(Te.userAgent);null!==t&&(Le=!0,_e=nr(t[1]),_e.isNightly=!!t[2])}return Le}function or(){if(!e(Ve)){let t;Ve=!1,"Microsoft Internet Explorer"===Te.appName?(t=/MSIE ([0-9]{1,}[\\.0-9]{0,})/.exec(Te.userAgent),null!==t&&(Ve=!0,He=nr(t[1]))):"Netscape"===Te.appName&&(t=/Trident\\/.*rv:([0-9]{1,}[\\.0-9]{0,})/.exec(Te.userAgent),null!==t&&(Ve=!0,He=nr(t[1])))}return Ve}function ur(){if(!e(Ye)){Ye=!1;const t=/ Edg\\/([\\.0-9]+)/.exec(Te.userAgent);null!==t&&(Ye=!0,Ze=nr(t[1]))}return Ye}function sr(){if(!e(We)){We=!1;const t=/Firefox\\/([\\.0-9]+)/.exec(Te.userAgent);null!==t&&(We=!0,Qe=nr(t[1]))}return We}function cr(){if(!e(tr)){const t=document.createElement("canvas");t.setAttribute("style","image-rendering: -moz-crisp-edges;image-rendering: pixelated;");const n=t.style.imageRendering;tr=e(n)&&""!==n,tr&&(Ke=n)}return tr}function ar(){if(!ar.initialized)throw new r("You must call FeatureDetection.supportsWebP.initialize and wait for the promise to resolve before calling FeatureDetection.supportsWebP");return ar.Nt}Object.defineProperties(Ue,{element:{get:function(){if(Ue.supportsFullscreen())return document[Ne.fullscreenElement]}},changeEventName:{get:function(){if(Ue.supportsFullscreen())return Ne.fullscreenchange}},errorEventName:{get:function(){if(Ue.supportsFullscreen())return Ne.fullscreenerror}},enabled:{get:function(){if(Ue.supportsFullscreen())return document[Ne.fullscreenEnabled]}},fullscreen:{get:function(){if(Ue.supportsFullscreen())return null!==Ue.element}}}),Ue.supportsFullscreen=function(){if(e(Fe))return Fe;Fe=!1;const t=document.body;if("function"==typeof t.requestFullscreen)return Ne.requestFullscreen="requestFullscreen",Ne.exitFullscreen="exitFullscreen",Ne.fullscreenEnabled="fullscreenEnabled",Ne.fullscreenElement="fullscreenElement",Ne.fullscreenchange="fullscreenchange",Ne.fullscreenerror="fullscreenerror",Fe=!0,Fe;const n=["webkit","moz","o","ms","khtml"];let r;for(let e=0,i=n.length;e<i;++e){const i=n[e];r=`${i}RequestFullscreen`,"function"==typeof t[r]?(Ne.requestFullscreen=r,Fe=!0):(r=`${i}RequestFullScreen`,"function"==typeof t[r]&&(Ne.requestFullscreen=r,Fe=!0)),r=`${i}ExitFullscreen`,"function"==typeof document[r]?Ne.exitFullscreen=r:(r=`${i}CancelFullScreen`,"function"==typeof document[r]&&(Ne.exitFullscreen=r)),r=`${i}FullscreenEnabled`,void 0!==document[r]?Ne.fullscreenEnabled=r:(r=`${i}FullScreenEnabled`,void 0!==document[r]&&(Ne.fullscreenEnabled=r)),r=`${i}FullscreenElement`,void 0!==document[r]?Ne.fullscreenElement=r:(r=`${i}FullScreenElement`,void 0!==document[r]&&(Ne.fullscreenElement=r)),r=`${i}fullscreenchange`,void 0!==document[`on${r}`]&&("ms"===i&&(r="MSFullscreenChange"),Ne.fullscreenchange=r),r=`${i}fullscreenerror`,void 0!==document[`on${r}`]&&("ms"===i&&(r="MSFullscreenError"),Ne.fullscreenerror=r)}return Fe},Ue.requestFullscreen=function(t,n){Ue.supportsFullscreen()&&t[Ne.requestFullscreen]({vrDisplay:n})},Ue.exitFullscreen=function(){Ue.supportsFullscreen()&&document[Ne.exitFullscreen]()},Ue.Ut=Ne,Te="undefined"!=typeof navigator?navigator:{},ar.Tt=void 0,ar.Nt=void 0,ar.initialize=function(){return e(ar.Tt)||(ar.Tt=new Promise((t=>{const n=new Image;n.onload=function(){ar.Nt=n.width>0&&n.height>0,t(ar.Nt)},n.onerror=function(){ar.Nt=!1,t(ar.Nt)},n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA"}))),ar.Tt},Object.defineProperties(ar,{initialized:{get:function(){return e(ar.Nt)}}});const fr=[];"undefined"!=typeof ArrayBuffer&&(fr.push(Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array),"undefined"!=typeof Uint8ClampedArray&&fr.push(Uint8ClampedArray),"undefined"!=typeof Uint8ClampedArray&&fr.push(Uint8ClampedArray),"undefined"!=typeof BigInt64Array&&fr.push(BigInt64Array),"undefined"!=typeof BigUint64Array&&fr.push(BigUint64Array));const hr={isChrome:er,chromeVersion:function(){return er()&&Ce},isSafari:rr,safariVersion:function(){return rr()&&Be},isWebkit:ir,webkitVersion:function(){return ir()&&_e},isInternetExplorer:or,internetExplorerVersion:function(){return or()&&He},isEdge:ur,edgeVersion:function(){return ur()&&Ze},isFirefox:sr,firefoxVersion:function(){return sr()&&Qe},isWindows:function(){return e(Je)||(Je=/Windows/i.test(Te.appVersion)),Je},isIPadOrIOS:function(){return e(Ge)||(Ge="iPhone"===navigator.platform||"iPod"===navigator.platform||"iPad"===navigator.platform),Ge},hardwareConcurrency:n(Te.hardwareConcurrency,3),supportsPointerEvents:function(){return e(Xe)||(Xe=!sr()&&"undefined"!=typeof PointerEvent&&(!e(Te.pointerEnabled)||Te.pointerEnabled)),Xe},supportsImageRenderingPixelated:cr,supportsWebP:ar,imageRenderingValue:function(){return cr()?Ke:void 0},typedArrayTypes:fr};function lr(t,e,r,i){this.x=n(t,0),this.y=n(e,0),this.z=n(r,0),this.w=n(i,0)}hr.supportsBasis=function(t){return hr.supportsWebAssembly()&&t.context.supportsBasis},hr.supportsFullscreen=function(){return Ue.supportsFullscreen()},hr.supportsTypedArrays=function(){return"undefined"!=typeof ArrayBuffer},hr.supportsBigInt64Array=function(){return"undefined"!=typeof BigInt64Array},hr.supportsBigUint64Array=function(){return"undefined"!=typeof BigUint64Array},hr.supportsBigInt=function(){return"undefined"!=typeof BigInt},hr.supportsWebWorkers=function(){return"undefined"!=typeof Worker},hr.supportsWebAssembly=function(){return"undefined"!=typeof WebAssembly},hr.supportsWebgl2=function(t){return i.defined("scene",t),t.context.webgl2},hr.supportsEsmWebWorkers=function(){return!sr()||parseInt(Qe)>=114};let dr=new x;lr.fromAxisAngle=function(t,n,r){i.typeOf.object("axis",t),i.typeOf.number("angle",n);const o=n/2,u=Math.sin(o);dr=x.normalize(t,dr);const s=dr.x*u,c=dr.y*u,a=dr.z*u,f=Math.cos(o);return e(r)?(r.x=s,r.y=c,r.z=a,r.w=f,r):new lr(s,c,a,f)};const wr=[1,2,0],mr=new Array(3);lr.fromRotationMatrix=function(t,n){let r,o,u,s,c;i.typeOf.object("matrix",t);const a=t[oe.COLUMN0ROW0],f=t[oe.COLUMN1ROW1],h=t[oe.COLUMN2ROW2],l=a+f+h;if(l>0)r=Math.sqrt(l+1),c=.5*r,r=.5/r,o=(t[oe.COLUMN1ROW2]-t[oe.COLUMN2ROW1])*r,u=(t[oe.COLUMN2ROW0]-t[oe.COLUMN0ROW2])*r,s=(t[oe.COLUMN0ROW1]-t[oe.COLUMN1ROW0])*r;else{const n=wr;let e=0;f>a&&(e=1),h>a&&h>f&&(e=2);const i=n[e],l=n[i];r=Math.sqrt(t[oe.getElementIndex(e,e)]-t[oe.getElementIndex(i,i)]-t[oe.getElementIndex(l,l)]+1);const d=mr;d[e]=.5*r,r=.5/r,c=(t[oe.getElementIndex(l,i)]-t[oe.getElementIndex(i,l)])*r,d[i]=(t[oe.getElementIndex(i,e)]+t[oe.getElementIndex(e,i)])*r,d[l]=(t[oe.getElementIndex(l,e)]+t[oe.getElementIndex(e,l)])*r,o=-d[0],u=-d[1],s=-d[2]}return e(n)?(n.x=o,n.y=u,n.z=s,n.w=c,n):new lr(o,u,s,c)};const gr=new lr;let vr=new lr,pr=new lr,yr=new lr;lr.fromHeadingPitchRoll=function(t,n){return i.typeOf.object("headingPitchRoll",t),yr=lr.fromAxisAngle(x.UNIT_X,t.roll,gr),pr=lr.fromAxisAngle(x.UNIT_Y,-t.pitch,n),n=lr.multiply(pr,yr,pr),vr=lr.fromAxisAngle(x.UNIT_Z,-t.heading,gr),lr.multiply(vr,n,n)};const br=new x,Mr=new x,Ar=new lr,xr=new lr,Er=new lr;lr.packedLength=4,lr.pack=function(t,e,r){return i.typeOf.object("value",t),i.defined("array",e),r=n(r,0),e[r++]=t.x,e[r++]=t.y,e[r++]=t.z,e[r]=t.w,e},lr.unpack=function(t,r,o){return i.defined("array",t),r=n(r,0),e(o)||(o=new lr),o.x=t[r],o.y=t[r+1],o.z=t[r+2],o.w=t[r+3],o},lr.packedInterpolationLength=3,lr.convertPackedArrayForInterpolation=function(t,n,r,i){lr.unpack(t,4*r,Er),lr.conjugate(Er,Er);for(let o=0,u=r-n+1;o<u;o++){const r=3*o;lr.unpack(t,4*(n+o),Ar),lr.multiply(Ar,Er,Ar),Ar.w<0&&lr.negate(Ar,Ar),lr.computeAxis(Ar,br);const u=lr.computeAngle(Ar);e(i)||(i=[]),i[r]=br.x*u,i[r+1]=br.y*u,i[r+2]=br.z*u}},lr.unpackInterpolationResult=function(t,n,r,i,o){e(o)||(o=new lr),x.fromArray(t,0,Mr);const u=x.magnitude(Mr);return lr.unpack(n,4*i,xr),0===u?lr.clone(lr.IDENTITY,Ar):lr.fromAxisAngle(Mr,u,Ar),lr.multiply(Ar,xr,o)},lr.clone=function(t,n){if(e(t))return e(n)?(n.x=t.x,n.y=t.y,n.z=t.z,n.w=t.w,n):new lr(t.x,t.y,t.z,t.w)},lr.conjugate=function(t,n){return i.typeOf.object("quaternion",t),i.typeOf.object("result",n),n.x=-t.x,n.y=-t.y,n.z=-t.z,n.w=t.w,n},lr.magnitudeSquared=function(t){return i.typeOf.object("quaternion",t),t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w},lr.magnitude=function(t){return Math.sqrt(lr.magnitudeSquared(t))},lr.normalize=function(t,n){i.typeOf.object("result",n);const e=1/lr.magnitude(t),r=t.x*e,o=t.y*e,u=t.z*e,s=t.w*e;return n.x=r,n.y=o,n.z=u,n.w=s,n},lr.inverse=function(t,n){i.typeOf.object("result",n);const e=lr.magnitudeSquared(t);return n=lr.conjugate(t,n),lr.multiplyByScalar(n,1/e,n)},lr.add=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x+n.x,e.y=t.y+n.y,e.z=t.z+n.z,e.w=t.w+n.w,e},lr.subtract=function(t,n,e){return i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e),e.x=t.x-n.x,e.y=t.y-n.y,e.z=t.z-n.z,e.w=t.w-n.w,e},lr.negate=function(t,n){return i.typeOf.object("quaternion",t),i.typeOf.object("result",n),n.x=-t.x,n.y=-t.y,n.z=-t.z,n.w=-t.w,n},lr.dot=function(t,n){return i.typeOf.object("left",t),i.typeOf.object("right",n),t.x*n.x+t.y*n.y+t.z*n.z+t.w*n.w},lr.multiply=function(t,n,e){i.typeOf.object("left",t),i.typeOf.object("right",n),i.typeOf.object("result",e);const r=t.x,o=t.y,u=t.z,s=t.w,c=n.x,a=n.y,f=n.z,h=n.w,l=s*c+r*h+o*f-u*a,d=s*a-r*f+o*h+u*c,w=s*f+r*a-o*c+u*h,m=s*h-r*c-o*a-u*f;return e.x=l,e.y=d,e.z=w,e.w=m,e},lr.multiplyByScalar=function(t,n,e){return i.typeOf.object("quaternion",t),i.typeOf.number("scalar",n),i.typeOf.object("result",e),e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e.w=t.w*n,e},lr.divideByScalar=function(t,n,e){return i.typeOf.object("quaternion",t),i.typeOf.number("scalar",n),i.typeOf.object("result",e),e.x=t.x/n,e.y=t.y/n,e.z=t.z/n,e.w=t.w/n,e},lr.computeAxis=function(t,n){i.typeOf.object("quaternion",t),i.typeOf.object("result",n);const e=t.w;if(Math.abs(e-1)<w.EPSILON6||Math.abs(e+1)<w.EPSILON6)return n.x=1,n.y=n.z=0,n;const r=1/Math.sqrt(1-e*e);return n.x=t.x*r,n.y=t.y*r,n.z=t.z*r,n},lr.computeAngle=function(t){return i.typeOf.object("quaternion",t),Math.abs(t.w-1)<w.EPSILON6?0:2*Math.acos(t.w)};let kr=new lr;lr.lerp=function(t,n,e,r){return i.typeOf.object("start",t),i.typeOf.object("end",n),i.typeOf.number("t",e),i.typeOf.object("result",r),kr=lr.multiplyByScalar(n,e,kr),r=lr.multiplyByScalar(t,1-e,r),lr.add(kr,r,r)};let qr=new lr,$r=new lr,Sr=new lr;lr.slerp=function(t,n,e,r){i.typeOf.object("start",t),i.typeOf.object("end",n),i.typeOf.number("t",e),i.typeOf.object("result",r);let o=lr.dot(t,n),u=n;if(o<0&&(o=-o,u=qr=lr.negate(n,qr)),1-o<w.EPSILON6)return lr.lerp(t,u,e,r);const s=Math.acos(o);return $r=lr.multiplyByScalar(t,Math.sin((1-e)*s),$r),Sr=lr.multiplyByScalar(u,Math.sin(e*s),Sr),r=lr.add($r,Sr,r),lr.multiplyByScalar(r,1/Math.sin(s),r)},lr.log=function(t,n){i.typeOf.object("quaternion",t),i.typeOf.object("result",n);const e=w.acosClamped(t.w);let r=0;return 0!==e&&(r=e/Math.sin(e)),x.multiplyByScalar(t,r,n)},lr.exp=function(t,n){i.typeOf.object("cartesian",t),i.typeOf.object("result",n);const e=x.magnitude(t);let r=0;return 0!==e&&(r=Math.sin(e)/e),n.x=t.x*r,n.y=t.y*r,n.z=t.z*r,n.w=Math.cos(e),n};const Ir=new x,Or=new x,Rr=new lr,Pr=new lr;lr.computeInnerQuadrangle=function(t,n,e,r){i.typeOf.object("q0",t),i.typeOf.object("q1",n),i.typeOf.object("q2",e),i.typeOf.object("result",r);const o=lr.conjugate(n,Rr);lr.multiply(o,e,Pr);const u=lr.log(Pr,Ir);lr.multiply(o,t,Pr);const s=lr.log(Pr,Or);return x.add(u,s,u),x.multiplyByScalar(u,.25,u),x.negate(u,u),lr.exp(u,Rr),lr.multiply(n,Rr,r)},lr.squad=function(t,n,e,r,o,u){i.typeOf.object("q0",t),i.typeOf.object("q1",n),i.typeOf.object("s0",e),i.typeOf.object("s1",r),i.typeOf.number("t",o),i.typeOf.object("result",u);const s=lr.slerp(t,n,o,Rr),c=lr.slerp(e,r,o,Pr);return lr.slerp(s,c,2*o*(1-o),u)};const jr=new lr,Fr=1.9011074535173003,Nr=hr.supportsTypedArrays()?new Float32Array(8):[],Ur=hr.supportsTypedArrays()?new Float32Array(8):[],Tr=hr.supportsTypedArrays()?new Float32Array(8):[],zr=hr.supportsTypedArrays()?new Float32Array(8):[];for(let t=0;t<7;++t){const n=t+1,e=2*n+1;Nr[t]=1/(n*e),Ur[t]=n/e}Nr[7]=Fr/136,Ur[7]=8*Fr/17,lr.fastSlerp=function(t,n,e,r){i.typeOf.object("start",t),i.typeOf.object("end",n),i.typeOf.number("t",e),i.typeOf.object("result",r);let o,u=lr.dot(t,n);u>=0?o=1:(o=-1,u=-u);const s=u-1,c=1-e,a=e*e,f=c*c;for(let t=7;t>=0;--t)Tr[t]=(Nr[t]*a-Ur[t])*s,zr[t]=(Nr[t]*f-Ur[t])*s;const h=o*e*(1+Tr[0]*(1+Tr[1]*(1+Tr[2]*(1+Tr[3]*(1+Tr[4]*(1+Tr[5]*(1+Tr[6]*(1+Tr[7])))))))),l=c*(1+zr[0]*(1+zr[1]*(1+zr[2]*(1+zr[3]*(1+zr[4]*(1+zr[5]*(1+zr[6]*(1+zr[7])))))))),d=lr.multiplyByScalar(t,l,jr);return lr.multiplyByScalar(n,h,r),lr.add(d,r,r)},lr.fastSquad=function(t,n,e,r,o,u){i.typeOf.object("q0",t),i.typeOf.object("q1",n),i.typeOf.object("s0",e),i.typeOf.object("s1",r),i.typeOf.number("t",o),i.typeOf.object("result",u);const s=lr.fastSlerp(t,n,o,Rr),c=lr.fastSlerp(e,r,o,Pr);return lr.fastSlerp(s,c,2*o*(1-o),u)},lr.equals=function(t,n){return t===n||e(t)&&e(n)&&t.x===n.x&&t.y===n.y&&t.z===n.z&&t.w===n.w},lr.equalsEpsilon=function(t,r,i){return i=n(i,0),t===r||e(t)&&e(r)&&Math.abs(t.x-r.x)<=i&&Math.abs(t.y-r.y)<=i&&Math.abs(t.z-r.z)<=i&&Math.abs(t.w-r.w)<=i},lr.ZERO=Object.freeze(new lr(0,0,0,0)),lr.IDENTITY=Object.freeze(new lr(0,0,0,1)),lr.prototype.clone=function(t){return lr.clone(this,t)},lr.prototype.equals=function(t){return lr.equals(this,t)},lr.prototype.equalsEpsilon=function(t,n){return lr.equalsEpsilon(this,t,n)},lr.prototype.toString=function(){return`(${this.x}, ${this.y}, ${this.z}, ${this.w})`};const Cr={},Dr={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},Br={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Lr={},_r={east:new x,north:new x,up:new x,west:new x,south:new x,down:new x};let Vr=new x,Hr=new x,Yr=new x;Cr.localFrameToFixedFrameGenerator=function(t,i){if(!Dr.hasOwnProperty(t)||!Dr[t].hasOwnProperty(i))throw new r("firstAxis and secondAxis must be east, north, up, west, south or down.");const o=Dr[t][i];let u;const s=t+i;return e(Lr[s])?u=Lr[s]:(u=function(u,s,c){if(!e(u))throw new r("origin is required.");if(isNaN(u.x)||isNaN(u.y)||isNaN(u.z))throw new r("origin has a NaN component");if(e(c)||(c=new ye),x.equalsEpsilon(u,x.ZERO,w.EPSILON14))x.unpack(Br[t],0,Vr),x.unpack(Br[i],0,Hr),x.unpack(Br[o],0,Yr);else if(w.equalsEpsilon(u.x,0,w.EPSILON14)&&w.equalsEpsilon(u.y,0,w.EPSILON14)){const n=w.sign(u.z);x.unpack(Br[t],0,Vr),"east"!==t&&"west"!==t&&x.multiplyByScalar(Vr,n,Vr),x.unpack(Br[i],0,Hr),"east"!==i&&"west"!==i&&x.multiplyByScalar(Hr,n,Hr),x.unpack(Br[o],0,Yr),"east"!==o&&"west"!==o&&x.multiplyByScalar(Yr,n,Yr)}else{(s=n(s,C.default)).geodeticSurfaceNormal(u,_r.up);const e=_r.up,r=_r.east;r.x=-u.y,r.y=u.x,r.z=0,x.normalize(r,_r.east),x.cross(e,r,_r.north),x.multiplyByScalar(_r.up,-1,_r.down),x.multiplyByScalar(_r.east,-1,_r.west),x.multiplyByScalar(_r.north,-1,_r.south),Vr=_r[t],Hr=_r[i],Yr=_r[o]}return c[0]=Vr.x,c[1]=Vr.y,c[2]=Vr.z,c[3]=0,c[4]=Hr.x,c[5]=Hr.y,c[6]=Hr.z,c[7]=0,c[8]=Yr.x,c[9]=Yr.y,c[10]=Yr.z,c[11]=0,c[12]=u.x,c[13]=u.y,c[14]=u.z,c[15]=1,c},Lr[s]=u),u},Cr.eastNorthUpToFixedFrame=Cr.localFrameToFixedFrameGenerator("east","north"),Cr.northEastDownToFixedFrame=Cr.localFrameToFixedFrameGenerator("north","east"),Cr.northUpEastToFixedFrame=Cr.localFrameToFixedFrameGenerator("north","up"),Cr.northWestUpToFixedFrame=Cr.localFrameToFixedFrameGenerator("north","west");const Zr=new lr,Wr=new x(1,1,1),Qr=new ye;Cr.headingPitchRollToFixedFrame=function(t,e,r,o,u){i.typeOf.object("HeadingPitchRoll",e),o=n(o,Cr.eastNorthUpToFixedFrame);const s=lr.fromHeadingPitchRoll(e,Zr),c=ye.fromTranslationQuaternionRotationScale(x.ZERO,s,Wr,Qr);return u=o(t,r,u),ye.multiply(u,c,u)};const Jr=new ye,Gr=new oe;Cr.headingPitchRollQuaternion=function(t,n,e,r,o){i.typeOf.object("HeadingPitchRoll",n);const u=Cr.headingPitchRollToFixedFrame(t,n,e,r,Jr),s=ye.getMatrix3(u,Gr);return lr.fromRotationMatrix(s,o)};const Xr=new x(1,1,1),Kr=new x,ti=new ye,ni=new ye,ei=new oe,ri=new lr;Cr.fixedFrameToHeadingPitchRoll=function(t,r,o,u){i.defined("transform",t),r=n(r,C.default),o=n(o,Cr.eastNorthUpToFixedFrame),e(u)||(u=new Vn);const s=ye.getTranslation(t,Kr);if(x.equals(s,x.ZERO))return u.heading=0,u.pitch=0,u.roll=0,u;let c=ye.inverseTransformation(o(s,r,ti),ti),a=ye.setScale(t,Xr,ni);a=ye.setTranslation(a,x.ZERO,a),c=ye.multiply(c,a,c);let f=lr.fromRotationMatrix(ye.getMatrix3(c,ei),ri);return f=lr.normalize(f,f),Vn.fromQuaternion(f,u)};const ii=w.TWO_PI/86400;let oi=new It;Cr.computeTemeToPseudoFixedMatrix=function(t,n){if(!e(t))throw new r("date is required.");oi=It.addSeconds(t,-It.computeTaiMinusUtc(t),oi);const i=oi.dayNumber,o=oi.secondsOfDay;let u;const s=i-2451545;u=o>=43200?(s+.5)/at.DAYS_PER_JULIAN_CENTURY:(s-.5)/at.DAYS_PER_JULIAN_CENTURY;const c=(24110.54841+u*(8640184.812866+u*(.093104+-62e-7*u)))*ii%w.TWO_PI+(72921158553e-15+11772758384668e-32*(i-2451545.5))*((o+.5*at.SECONDS_PER_DAY)%at.SECONDS_PER_DAY),a=Math.cos(c),f=Math.sin(c);return e(n)?(n[0]=a,n[1]=-f,n[2]=0,n[3]=f,n[4]=a,n[5]=0,n[6]=0,n[7]=0,n[8]=1,n):new oe(a,f,0,-f,a,0,0,0,1)},Cr.iau2006XysData=new ne,Cr.earthOrientationParameters=zn.NONE;const ui=32.184;Cr.preloadIcrfFixed=function(t){const n=t.start.dayNumber,e=t.start.secondsOfDay+ui,r=t.stop.dayNumber,i=t.stop.secondsOfDay+ui;return Cr.iau2006XysData.preload(n,e,r,i)},Cr.computeIcrfToFixedMatrix=function(t,n){if(!e(t))throw new r("date is required.");e(n)||(n=new oe);const i=Cr.computeFixedToIcrfMatrix(t,n);if(e(i))return oe.transpose(i,n)};const si=new te(0,0,0),ci=new it(0,0,0,0,0),ai=new oe,fi=new oe;Cr.computeFixedToIcrfMatrix=function(t,n){if(!e(t))throw new r("date is required.");e(n)||(n=new oe);const i=Cr.earthOrientationParameters.compute(t,ci);if(!e(i))return;const o=t.dayNumber,u=t.secondsOfDay+ui,s=Cr.iau2006XysData.computeXysRadians(o,u,si);if(!e(s))return;const c=s.x+i.xPoleOffset,a=s.y+i.yPoleOffset,f=1/(1+Math.sqrt(1-c*c-a*a)),h=ai;h[0]=1-f*c*c,h[3]=-f*c*a,h[6]=c,h[1]=-f*c*a,h[4]=1-f*a*a,h[7]=a,h[2]=-c,h[5]=-a,h[8]=1-f*(c*c+a*a);const l=oe.fromRotationZ(-s.s,fi),d=oe.multiply(h,l,ai),m=t.dayNumber-2451545,g=(t.secondsOfDay-It.computeTaiMinusUtc(t)+i.ut1MinusUtc)/at.SECONDS_PER_DAY;let v=.779057273264+g+.00273781191135448*(m+g);v=v%1*w.TWO_PI;const p=oe.fromRotationZ(v,fi),y=oe.multiply(d,p,ai),b=Math.cos(i.xPoleWander),M=Math.cos(i.yPoleWander),A=Math.sin(i.xPoleWander),x=Math.sin(i.yPoleWander);let E=o-2451545+u/at.SECONDS_PER_DAY;E/=36525;const k=-47e-6*E*w.RADIANS_PER_DEGREE/3600,q=Math.cos(k),$=Math.sin(k),S=fi;return S[0]=b*q,S[1]=b*$,S[2]=A,S[3]=-M*$+x*A*q,S[4]=M*q+x*A*$,S[5]=-x*b,S[6]=-x*$-M*A*q,S[7]=x*q-M*A*$,S[8]=M*b,oe.multiply(y,S,n)};const hi=new Q;Cr.pointToWindowCoordinates=function(t,n,e,r){return(r=Cr.pointToGLWindowCoordinates(t,n,e,r)).y=2*n[5]-r.y,r},Cr.pointToGLWindowCoordinates=function(t,n,i,o){if(!e(t))throw new r("modelViewProjectionMatrix is required.");if(!e(n))throw new r("viewportTransformation is required.");if(!e(i))throw new r("point is required.");e(o)||(o=new v);const u=hi;return ye.multiplyByVector(t,Q.fromElements(i.x,i.y,i.z,1,u),u),Q.multiplyByScalar(u,1/u.w,u),ye.multiplyByVector(n,u,u),v.fromCartesian4(u,o)};const li=new x,di=new x,wi=new x;Cr.rotationMatrixFromPositionVelocity=function(t,i,o,u){if(!e(t))throw new r("position is required.");if(!e(i))throw new r("velocity is required.");const s=n(o,C.default).geodeticSurfaceNormal(t,li);let c=x.cross(i,s,di);x.equalsEpsilon(c,x.ZERO,w.EPSILON6)&&(c=x.clone(x.UNIT_X,c));const a=x.cross(c,i,wi);return x.normalize(a,a),x.cross(i,a,c),x.negate(c,c),x.normalize(c,c),e(u)||(u=new oe),u[0]=i.x,u[1]=i.y,u[2]=i.z,u[3]=c.x,u[4]=c.y,u[5]=c.z,u[6]=a.x,u[7]=a.y,u[8]=a.z,u};const mi=new ye(0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,1),gi=new F,vi=new x,pi=new x,yi=new oe,bi=new ye,Mi=new ye;Cr.basisTo2D=function(t,n,i){if(!e(t))throw new r("projection is required.");if(!e(n))throw new r("matrix is required.");if(!e(i))throw new r("result is required.");const o=ye.getTranslation(n,pi),u=t.ellipsoid;let s;if(x.equals(o,x.ZERO))s=x.clone(x.ZERO,vi);else{const n=u.cartesianToCartographic(o,gi);s=t.project(n,vi),x.fromElements(s.z,s.x,s.y,s)}const c=Cr.eastNorthUpToFixedFrame(o,u,bi),a=ye.inverseTransformation(c,Mi),f=ye.getMatrix3(n,yi),h=ye.multiplyByMatrix3(a,f,i);return ye.multiply(mi,h,i),ye.setTranslation(i,s,i),i},Cr.ellipsoidTo2DModelMatrix=function(t,n,i){if(!e(t))throw new r("projection is required.");if(!e(n))throw new r("center is required.");if(!e(i))throw new r("result is required.");const o=t.ellipsoid,u=Cr.eastNorthUpToFixedFrame(n,o,bi),s=ye.inverseTransformation(u,Mi),c=o.cartesianToCartographic(n,gi),a=t.project(c,vi);x.fromElements(a.z,a.x,a.y,a);const f=ye.fromTranslation(a,bi);return ye.multiply(mi,s,i),ye.multiply(f,i,i),i};var Ai,xi,Ei,ki,qi,$i,Si={},Ii=function(){if(Ei)return xi;Ei=1,xi=n;var t=(Ai||(Ai=1,Si.read=function(t,n,e,r,i){var o,u,s=8*i-r-1,c=(1<<s)-1,a=c>>1,f=-7,h=e?i-1:0,l=e?-1:1,d=t[n+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=s;f>0;o=256*o+t[n+h],h+=l,f-=8);for(u=o&(1<<-f)-1,o>>=-f,f+=r;f>0;u=256*u+t[n+h],h+=l,f-=8);if(0===o)o=1-a;else{if(o===c)return u?NaN:1/0*(d?-1:1);u+=Math.pow(2,r),o-=a}return(d?-1:1)*u*Math.pow(2,o-r)},Si.write=function(t,n,e,r,i,o){var u,s,c,a=8*o-i-1,f=(1<<a)-1,h=f>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,w=r?1:-1,m=n<0||0===n&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(s=isNaN(n)?1:0,u=f):(u=Math.floor(Math.log(n)/Math.LN2),n*(c=Math.pow(2,-u))<1&&(u--,c*=2),(n+=u+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(u++,c/=2),u+h>=f?(s=0,u=f):u+h>=1?(s=(n*c-1)*Math.pow(2,i),u+=h):(s=n*Math.pow(2,h-1)*Math.pow(2,i),u=0));i>=8;t[e+d]=255&s,d+=w,s/=256,i-=8);for(u=u<<i|s,a+=i;a>0;t[e+d]=255&u,d+=w,u/=256,a-=8);t[e+d-w]|=128*m}),Si);function n(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}n.Varint=0,n.Fixed64=1,n.Bytes=2,n.Fixed32=5;var e=4294967296,r=1/e,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function o(t){return t.type===n.Bytes?t.readVarint()+t.pos:t.pos+1}function u(t,n,e){return e?4294967296*n+(t>>>0):4294967296*(n>>>0)+(t>>>0)}function s(t,n,e){var r=n<=16383?1:n<=2097151?2:n<=268435455?3:Math.floor(Math.log(n)/(7*Math.LN2));e.realloc(r);for(var i=e.pos-1;i>=t;i--)e.buf[i+r]=e.buf[i]}function c(t,n){for(var e=0;e<t.length;e++)n.writeVarint(t[e])}function a(t,n){for(var e=0;e<t.length;e++)n.writeSVarint(t[e])}function f(t,n){for(var e=0;e<t.length;e++)n.writeFloat(t[e])}function h(t,n){for(var e=0;e<t.length;e++)n.writeDouble(t[e])}function l(t,n){for(var e=0;e<t.length;e++)n.writeBoolean(t[e])}function d(t,n){for(var e=0;e<t.length;e++)n.writeFixed32(t[e])}function w(t,n){for(var e=0;e<t.length;e++)n.writeSFixed32(t[e])}function m(t,n){for(var e=0;e<t.length;e++)n.writeFixed64(t[e])}function g(t,n){for(var e=0;e<t.length;e++)n.writeSFixed64(t[e])}function v(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16)+16777216*t[n+3]}function p(t,n,e){t[e]=n,t[e+1]=n>>>8,t[e+2]=n>>>16,t[e+3]=n>>>24}function y(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16)+(t[n+3]<<24)}return n.prototype={destroy:function(){this.buf=null},readFields:function(t,n,e){for(e=e||this.length;this.pos<e;){var r=this.readVarint(),i=r>>3,o=this.pos;this.type=7&r,t(i,n,this),this.pos===o&&this.skip(r)}return n},readMessage:function(t,n){return this.readFields(t,n,this.readVarint()+this.pos)},readFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=y(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=v(this.buf,this.pos)+v(this.buf,this.pos+4)*e;return this.pos+=8,t},readSFixed64:function(){var t=v(this.buf,this.pos)+y(this.buf,this.pos+4)*e;return this.pos+=8,t},readFloat:function(){var n=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,n},readDouble:function(){var n=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,n},readVarint:function(t){var n,e,r=this.buf;return n=127&(e=r[this.pos++]),e<128?n:(n|=(127&(e=r[this.pos++]))<<7,e<128?n:(n|=(127&(e=r[this.pos++]))<<14,e<128?n:(n|=(127&(e=r[this.pos++]))<<21,e<128?n:function(t,n,e){var r,i,o=e.buf;if(r=(112&(i=o[e.pos++]))>>4,i<128)return u(t,r,n);if(r|=(127&(i=o[e.pos++]))<<3,i<128)return u(t,r,n);if(r|=(127&(i=o[e.pos++]))<<10,i<128)return u(t,r,n);if(r|=(127&(i=o[e.pos++]))<<17,i<128)return u(t,r,n);if(r|=(127&(i=o[e.pos++]))<<24,i<128)return u(t,r,n);if(r|=(1&(i=o[e.pos++]))<<31,i<128)return u(t,r,n);throw new Error("Expected varint not more than 10 bytes")}(n|=(15&(e=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,n=this.pos;return this.pos=t,t-n>=12&&i?function(t,n,e){return i.decode(t.subarray(n,e))}(this.buf,n,t):function(t,n,e){for(var r="",i=n;i<e;){var o,u,s,c=t[i],a=null,f=c>239?4:c>223?3:c>191?2:1;if(i+f>e)break;1===f?c<128&&(a=c):2===f?128==(192&(o=t[i+1]))&&(a=(31&c)<<6|63&o)<=127&&(a=null):3===f?(o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&((a=(15&c)<<12|(63&o)<<6|63&u)<=2047||a>=55296&&a<=57343)&&(a=null)):4===f&&(o=t[i+1],u=t[i+2],s=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&s)&&((a=(15&c)<<18|(63&o)<<12|(63&u)<<6|63&s)<=65535||a>=1114112)&&(a=null)),null===a?(a=65533,f=1):a>65535&&(a-=65536,r+=String.fromCharCode(a>>>10&1023|55296),a=56320|1023&a),r+=String.fromCharCode(a),i+=f}return r}(this.buf,n,t)},readBytes:function(){var t=this.readVarint()+this.pos,n=this.buf.subarray(this.pos,t);return this.pos=t,n},readPackedVarint:function(t,e){if(this.type!==n.Bytes)return t.push(this.readVarint(e));var r=o(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==n.Bytes)return t.push(this.readSVarint());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==n.Bytes)return t.push(this.readBoolean());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==n.Bytes)return t.push(this.readFloat());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==n.Bytes)return t.push(this.readDouble());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==n.Bytes)return t.push(this.readFixed32());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==n.Bytes)return t.push(this.readSFixed32());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==n.Bytes)return t.push(this.readFixed64());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==n.Bytes)return t.push(this.readSFixed64());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===n.Varint)for(;this.buf[this.pos++]>127;);else if(e===n.Bytes)this.pos=this.readVarint()+this.pos;else if(e===n.Fixed32)this.pos+=4;else{if(e!==n.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,n){this.writeVarint(t<<3|n)},realloc:function(t){for(var n=this.length||16;n<this.pos+t;)n*=2;if(n!==this.length){var e=new Uint8Array(n);e.set(this.buf),this.buf=e,this.length=n}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),p(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),p(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),p(this.buf,-1&t,this.pos),p(this.buf,Math.floor(t*r),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),p(this.buf,-1&t,this.pos),p(this.buf,Math.floor(t*r),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,n){var e,r;if(t>=0?(e=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(e=~(-t%4294967296))?e=e+1|0:(e=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn\'t fit into 10 bytes");n.realloc(10),function(t,n,e){e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos]=127&t}(e,0,n),function(t,n){var e=(7&t)<<4;n.buf[n.pos++]|=e|((t>>>=3)?128:0),t&&(n.buf[n.pos++]=127&t|((t>>>=7)?128:0),t&&(n.buf[n.pos++]=127&t|((t>>>=7)?128:0),t&&(n.buf[n.pos++]=127&t|((t>>>=7)?128:0),t&&(n.buf[n.pos++]=127&t|((t>>>=7)?128:0),t&&(n.buf[n.pos++]=127&t)))))}(r,n)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var n=this.pos;this.pos=function(t,n,e){for(var r,i,o=0;o<n.length;o++){if((r=n.charCodeAt(o))>55295&&r<57344){if(!i){r>56319||o+1===n.length?(t[e++]=239,t[e++]=191,t[e++]=189):i=r;continue}if(r<56320){t[e++]=239,t[e++]=191,t[e++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(t[e++]=239,t[e++]=191,t[e++]=189,i=null);r<128?t[e++]=r:(r<2048?t[e++]=r>>6|192:(r<65536?t[e++]=r>>12|224:(t[e++]=r>>18|240,t[e++]=r>>12&63|128),t[e++]=r>>6&63|128),t[e++]=63&r|128)}return e}(this.buf,t,this.pos);var e=this.pos-n;e>=128&&s(n,e,this),this.pos=n-1,this.writeVarint(e),this.pos+=e},writeFloat:function(n){this.realloc(4),t.write(this.buf,n,this.pos,!0,23,4),this.pos+=4},writeDouble:function(n){this.realloc(8),t.write(this.buf,n,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var n=t.length;this.writeVarint(n),this.realloc(n);for(var e=0;e<n;e++)this.buf[this.pos++]=t[e]},writeRawMessage:function(t,n){this.pos++;var e=this.pos;t(n,this);var r=this.pos-e;r>=128&&s(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,r){this.writeTag(t,n.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,n){n.length&&this.writeMessage(t,c,n)},writePackedSVarint:function(t,n){n.length&&this.writeMessage(t,a,n)},writePackedBoolean:function(t,n){n.length&&this.writeMessage(t,l,n)},writePackedFloat:function(t,n){n.length&&this.writeMessage(t,f,n)},writePackedDouble:function(t,n){n.length&&this.writeMessage(t,h,n)},writePackedFixed32:function(t,n){n.length&&this.writeMessage(t,d,n)},writePackedSFixed32:function(t,n){n.length&&this.writeMessage(t,w,n)},writePackedFixed64:function(t,n){n.length&&this.writeMessage(t,m,n)},writePackedSFixed64:function(t,n){n.length&&this.writeMessage(t,g,n)},writeBytesField:function(t,e){this.writeTag(t,n.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,n.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,n.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,n.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,n.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,n.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,n.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,n.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,n.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,n.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,n){this.writeVarintField(t,Boolean(n))}},xi}(),Oi=h(Ii),Ri={},Pi=function(){if(ki)return Ri;ki=1;var t=Ri.Ring={};t.read=function(n,e){return n.readFields(t.zt,{path:[]},e)},t.zt=function(t,n,e){1===t&&e.readPackedVarint(n.path,!0)},t.write=function(t,n){t.path&&n.writePackedVarint(1,t.path)};var n=Ri.Building={};n.read=function(t,e){return t.readFields(n.zt,{minzoom:0,maxzoom:0,path:[],height:0,indoorid:"",altitude:0},e)},n.zt=function(n,e,r){1===n?e.minzoom=r.readVarint():2===n?e.maxzoom=r.readVarint():3===n?e.path.push(t.read(r,r.readVarint()+r.pos)):4===n?e.height=r.readVarint():5===n?e.indoorid=r.readString():6===n&&(e.altitude=r.readVarint(!0))},n.write=function(n,e){if(n.minzoom&&e.writeVarintField(1,n.minzoom),n.maxzoom&&e.writeVarintField(2,n.maxzoom),n.path)for(var r=0;r<n.path.length;r++)e.writeMessage(3,t.write,n.path[r]);n.height&&e.writeVarintField(4,n.height),n.indoorid&&e.writeStringField(5,n.indoorid),n.altitude&&e.writeVarintField(6,n.altitude)};var e=Ri.BuildingSameStyle={};e.read=function(t,n){return t.readFields(e.zt,{mainkey:0,subkey:0,items:[],resolution:0},n)},e.zt=function(t,e,r){1===t?e.mainkey=r.readVarint():2===t?e.subkey=r.readVarint():3===t?e.items.push(n.read(r,r.readVarint()+r.pos)):4===t&&(e.resolution=r.readVarint())},e.write=function(t,e){if(t.mainkey&&e.writeVarintField(1,t.mainkey),t.subkey&&e.writeVarintField(2,t.subkey),t.items)for(var r=0;r<t.items.length;r++)e.writeMessage(3,n.write,t.items[r]);t.resolution&&e.writeVarintField(4,t.resolution)};var r=Ri.BuildingLayer={};return r.read=function(t,n){return t.readFields(r.zt,{building:[]},n)},r.zt=function(t,n,r){1===t&&n.building.push(e.read(r,r.readVarint()+r.pos))},r.write=function(t,n){if(t.building)for(var r=0;r<t.building.length;r++)n.writeMessage(1,e.write,t.building[r])},Ri}(),ji=function(){if($i)return qi;$i=1;const t=2147483648,n=180;function e(t,n){const e=function(t,n,e,o){const u=i(t,n);let s=r(180),c=r(90);const a=s/(1<<u),f=c/(1<<u);return s=a>0?Math.floor(a+.5):Math.floor(a-.5),c=f>0?Math.floor(f+.5):Math.floor(f-.5),[s,c]}(t,n);return[2*e[0],2*e[1]]}function r(e){return Math.floor(e*t/n+.5)}function i(t,n){return 33-n-t}function o(e){return e*n/t}function u(t,n){const r=e(t.z,n),i=r[0],o=r[1],u=1<<t.z;return[-i/2+t.x*i/u,o/2-(t.y+1)*o/u]}function s(n,e,r){const s=u(n,e),c=i(n.z,e);for(var a=[],f=0;f<r.length;f+=2){const n=r[f]+s[0];let e=n<<c;const i=r[f+1]+s[1]<<c;n>0&&e<0&&(e=t-1);const u=o(e),h=o(i);a.push([u,h])}return a}function c(t){for(var n=0,e=2,r=t.length;e<r;e+=2)n+=((t[e]-t[e-2])**2+(t[e+1]-t[e-1])**2)**.5;return n}function a(t,n){for(var e=0,r=0,i=t.length;r<i;r+=2){var o=c(t.slice(r,r+4));if(!(o+e<n)){var u=(n-e)/o;return[Math.round(t[r]+u*(t[r+2]-t[r])),Math.round(t[r+1]+u*(t[r+3]-t[r+1])),r]}e+=o}return null}function f(t,n){n=n/180*Math.PI;let e=0,r=0,i=0;for(var o=2,u=t.length;o<u;o+=2){var s=t[o]-t[o-2],c=t[o+1]-t[o-1],a=(s**2+c**2)**.5;if(2==o)e=s,r=c,i=a;else{if(Math.acos((s*e+c*r)/a/i)>n)return!1;e=s,r=c,i=a}}return!0}return qi={getWorldSize:e,riseLevel:function(t,n,e,o){return function(t,n,e){var o=t.z;const s=u(t,n),c=i(o,n);for(var a=[],f=0;f<e.length;f+=1){var h=e[f][0],l=e[f][1];l<-90&&(l=-90),l>90&&(l=90),h<-180&&(h=-180),h>180&&(h=180);let t=r(h),n=r(l);const i=t/(1<<c),o=n/(1<<c);t=i>0?Math.floor(i+.5):Math.floor(i-.5),n=o>0?Math.floor(o+.5):Math.floor(o-.5),t-=s[0],n-=s[1],a.push(t,n)}return a}(o,e-1,s(n,e,t))},ptsLength:c,getSmoothSlice:function(t,n,e){for(var r=function(t,n){var e=[],r=[],i=c(t);if(i>=n){for(var o=Math.floor(i/n),u=1;u<=o;u+=1)e.push(a(t,n*u));var s=[],f=[],h=0,l=void 0;for(u=0;u<e.length;u+=1){l=e[u][2]+2;var d=t.slice(h,l);f=[e[u][0],e[u][1]];for(var w=s.concat(d).concat(f),m=2;m<w.length;m+=2)w[m]===w[m-2]&&w[m+1]===w[m-1]&&(w.splice(m,2),m-=2);r.push(w),s=f,h=l}return r}}(t,n)||[],i=0;i<r.length;i+=1)f(r[i],e)||(r.splice(i,1),i-=1);return r},tileInnerCoords2LngLat:s,tileInnerCoord2LngLat:function(n,e,r,s){const c=u(n,e),a=r+c[0],f=s+c[1],h=i(n.z,e);return r=a<<h,s=f<<h,a>0&&r<0&&(r=t-1),[o(r),o(s)]}}}();function Fi(t,n,e=2){const r=t.length;let i=function(t,n,e,r,i){let o;if(1==function(t,n,e,r){let i=0;for(let n=0,o=e-r;n<e;n+=r)i+=(t[o]-t[n])*(t[n+1]+t[o+1]),o=n;return i}(t,0,e,r)>0)for(let n=0;n<e;n+=r)o=Gi(n/r|0,t[n],t[n+1],o);else for(let n=e-r;n>=0;n-=r)o=Gi(n/r|0,t[n],t[n+1],o);return o&&Hi(o,o.next)&&(Xi(o),o=o.next),o}(t,0,r,e);const o=[];if(!i||i.next===i.prev)return o;let u,s,c;if(t.length>80*e){u=1/0,s=1/0;let n=-1/0,i=-1/0;for(let o=e;o<r;o+=e){const e=t[o],r=t[o+1];e<u&&(u=e),r<s&&(s=r),e>n&&(n=e),r>i&&(i=r)}c=Math.max(n-u,i-s),c=0!==c?32767/c:0}return Ui(i,o,e,u,s,c,0),o}function Ni(t,n){if(!t)return t;n||(n=t);let e,r=t;do{if(e=!1,r.steiner||!Hi(r,r.next)&&0!==Vi(r.prev,r,r.next))r=r.next;else{if(Xi(r),r=n=r.prev,r===r.next)break;e=!0}}while(e||r!==n);return n}function Ui(t,n,e,r,i,o,u){if(!t)return;!u&&o&&function(t,n,e,r){let i=t;do{0===i.z&&(i.z=Bi(i.x,i.y,n,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let n,e=1;do{let r,i=t;t=null;let o=null;for(n=0;i;){n++;let u=i,s=0;for(let t=0;t<e&&(s++,u=u.nextZ,u);t++);let c=e;for(;s>0||c>0&&u;)0!==s&&(0===c||!u||i.z<=u.z)?(r=i,i=i.nextZ,s--):(r=u,u=u.nextZ,c--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;i=u}o.nextZ=null,e*=2}while(n>1)}(i)}(t,r,i,o);let s=t;for(;t.prev!==t.next;){const c=t.prev,a=t.next;if(o?zi(t,r,i,o):Ti(t))n.push(c.i,t.i,a.i),Xi(t),t=a.next,s=a.next;else if((t=a)===s){u?1===u?Ui(t=Ci(Ni(t),n),n,e,r,i,o,2):2===u&&Di(t,n,e,r,i,o):Ui(Ni(t),n,e,r,i,o,1);break}}}function Ti(t){const n=t.prev,e=t,r=t.next;if(Vi(n,e,r)>=0)return!1;const i=n.x,o=e.x,u=r.x,s=n.y,c=e.y,a=r.y,f=Math.min(i,o,u),h=Math.min(s,c,a),l=Math.max(i,o,u),d=Math.max(s,c,a);let w=r.next;for(;w!==n;){if(w.x>=f&&w.x<=l&&w.y>=h&&w.y<=d&&Li(i,s,o,c,u,a,w.x,w.y)&&Vi(w.prev,w,w.next)>=0)return!1;w=w.next}return!0}function zi(t,n,e,r){const i=t.prev,o=t,u=t.next;if(Vi(i,o,u)>=0)return!1;const s=i.x,c=o.x,a=u.x,f=i.y,h=o.y,l=u.y,d=Math.min(s,c,a),w=Math.min(f,h,l),m=Math.max(s,c,a),g=Math.max(f,h,l),v=Bi(d,w,n,e,r),p=Bi(m,g,n,e,r);let y=t.prevZ,b=t.nextZ;for(;y&&y.z>=v&&b&&b.z<=p;){if(y.x>=d&&y.x<=m&&y.y>=w&&y.y<=g&&y!==i&&y!==u&&Li(s,f,c,h,a,l,y.x,y.y)&&Vi(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,b.x>=d&&b.x<=m&&b.y>=w&&b.y<=g&&b!==i&&b!==u&&Li(s,f,c,h,a,l,b.x,b.y)&&Vi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;y&&y.z>=v;){if(y.x>=d&&y.x<=m&&y.y>=w&&y.y<=g&&y!==i&&y!==u&&Li(s,f,c,h,a,l,y.x,y.y)&&Vi(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=p;){if(b.x>=d&&b.x<=m&&b.y>=w&&b.y<=g&&b!==i&&b!==u&&Li(s,f,c,h,a,l,b.x,b.y)&&Vi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Ci(t,n){let e=t;do{const r=e.prev,i=e.next.next;!Hi(r,i)&&Yi(r,e,e.next,i)&&Qi(r,i)&&Qi(i,r)&&(n.push(r.i,e.i,i.i),Xi(e),Xi(e.next),e=t=i),e=e.next}while(e!==t);return Ni(e)}function Di(t,n,e,r,i,o){let u=t;do{let t=u.next.next;for(;t!==u.prev;){if(u.i!==t.i&&_i(u,t)){let s=Ji(u,t);return u=Ni(u,u.next),s=Ni(s,s.next),Ui(u,n,e,r,i,o,0),void Ui(s,n,e,r,i,o,0)}t=t.next}u=u.next}while(u!==t)}function Bi(t,n,e,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-e)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-r)*i|0)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function Li(t,n,e,r,i,o,u,s){return!(t===u&&n===s)&&function(t,n,e,r,i,o,u,s){return(i-u)*(n-s)>=(t-u)*(o-s)&&(t-u)*(r-s)>=(e-u)*(n-s)&&(e-u)*(o-s)>=(i-u)*(r-s)}(t,n,e,r,i,o,u,s)}function _i(t,n){return t.next.i!==n.i&&t.prev.i!==n.i&&!function(t,n){let e=t;do{if(e.i!==t.i&&e.next.i!==t.i&&e.i!==n.i&&e.next.i!==n.i&&Yi(e,e.next,t,n))return!0;e=e.next}while(e!==t);return!1}(t,n)&&(Qi(t,n)&&Qi(n,t)&&function(t,n){let e=t,r=!1;const i=(t.x+n.x)/2,o=(t.y+n.y)/2;do{e.y>o!=e.next.y>o&&e.next.y!==e.y&&i<(e.next.x-e.x)*(o-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next}while(e!==t);return r}(t,n)&&(Vi(t.prev,t,n.prev)||Vi(t,n.prev,n))||Hi(t,n)&&Vi(t.prev,t,t.next)>0&&Vi(n.prev,n,n.next)>0)}function Vi(t,n,e){return(n.y-t.y)*(e.x-n.x)-(n.x-t.x)*(e.y-n.y)}function Hi(t,n){return t.x===n.x&&t.y===n.y}function Yi(t,n,e,r){const i=Wi(Vi(t,n,e)),o=Wi(Vi(t,n,r)),u=Wi(Vi(e,r,t)),s=Wi(Vi(e,r,n));return i!==o&&u!==s||!(0!==i||!Zi(t,e,n))||!(0!==o||!Zi(t,r,n))||!(0!==u||!Zi(e,t,r))||!(0!==s||!Zi(e,n,r))}function Zi(t,n,e){return n.x<=Math.max(t.x,e.x)&&n.x>=Math.min(t.x,e.x)&&n.y<=Math.max(t.y,e.y)&&n.y>=Math.min(t.y,e.y)}function Wi(t){return t>0?1:t<0?-1:0}function Qi(t,n){return Vi(t.prev,t,t.next)<0?Vi(t,n,t.next)>=0&&Vi(t,t.prev,n)>=0:Vi(t,n,t.prev)<0||Vi(t,t.next,n)<0}function Ji(t,n){const e=Ki(t.i,t.x,t.y),r=Ki(n.i,n.x,n.y),i=t.next,o=n.prev;return t.next=n,n.prev=t,e.next=i,i.prev=e,r.next=e,e.prev=r,o.next=r,r.prev=o,r}function Gi(t,n,e,r){const i=Ki(t,n,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Xi(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ki(t,n,e){return{i:t,x:n,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}self.onmessage=function(t){!async function(t){const{coord:n,url:e,center:r}=t;try{const t=await fetch(e),i=await t.arrayBuffer(),o=new Oi(i),u=Pi.BuildingLayer.read(o),s=n.split("-").map((t=>parseInt(t,10))),c={z:s[0],x:s[1],y:s[2]},a=x.fromDegrees(...r),f=Cr.eastNorthUpToFixedFrame(a),h=ye.inverse(f,new ye);let l=[],d=[],w=[],m=[],g=0;for(let t=0;t<u.building.length;t++){const n=u.building[t];n.items.forEach((t=>{const{altitude:e,height:r}=t,i=t.path[0].path,o=ji.tileInnerCoords2LngLat(c,n.resolution,i),u=Fi(o.flat()),s=u.length/3,a=o.length,f=o.map((t=>{const n=ye.multiplyByPoint(h,x.fromDegrees(t[0],t[1],e+0),new x);return[n.x,n.y,n.z]})),v=o.map((t=>{const n=ye.multiplyByPoint(h,x.fromDegrees(t[0],t[1],e+r+0),new x);return[n.x,n.y,n.z]})),p=x.fromArray(f[0]),y=x.fromArray(v[0]),b=x.subtract(y,p,new x),M=x.normalize(b,new x),A=x.multiplyByScalar(M,-1,new x);for(let t=0;t<a;t++)w.push(A.x,A.y,A.z),m.push(0);for(let t=0;t<a;t++)w.push(M.x,M.y,M.z),m.push(0);l=l.concat(f.flat(99),v.flat(99));for(let t=0;t<s;t+=1)d.push(g+u[3*t+2]),d.push(g+u[3*t+1]),d.push(g+u[3*t]);for(let t=0;t<s;t+=1)d.push(g+a+u[3*t]),d.push(g+a+u[3*t+1]),d.push(g+a+u[3*t+2]);for(let t=0;t<a;t++){const n=v[t],e=f[t],r=f[(t+1)%a],i=v[(t+1)%a];l.push(...n),l.push(...e),l.push(...r),l.push(...i),m.push(1,1,1,1);const o=new x(n[0]-e[0],n[1]-e[1],n[2]-e[2]),u=new x(r[0]-e[0],r[1]-e[1],r[2]-e[2]),s=x.cross(u,o,new x),c=x.normalize(s,new x);w.push(c.x,c.y,c.z,c.x,c.y,c.z,c.x,c.y,c.z,c.x,c.y,c.z),d.push(g+2*a+4*t+0),d.push(g+2*a+4*t+1),d.push(g+2*a+4*t+2),d.push(g+2*a+4*t+0),d.push(g+2*a+4*t+2),d.push(g+2*a+4*t+3)}g+=6*a}))}const v={id:n,coord:[c.z,c.x,c.y],vertices:new Float32Array(l),normals:new Float32Array(w),indices:new Uint16Array(d),faces:new Float32Array(m),model:f};self.postMessage({coord:n,status:3,data:v})}catch(t){self.postMessage({coord:n,status:4})}}(t.data)}},"function"==typeof define&&define.amd?define(factory):factory();\n'],{type:"application/javascript"}),n=URL.createObjectURL(e);this.worker=new Worker(n),this.worker.addEventListener("message",this.onMessage)}Kd=!1;onDrop=(t,e)=>{delete this.Wd[t],this.Kd=!0};async loadTileset(){try{const t=await fetch(this.tilesetUrl),e=await t.json();this.tileset=e}catch(t){}}getViewFrustum(){const t=this._scene.camera,e=this.tileset.metadata.enuCenterGCJ02,n=t.frustum.computeCullingVolume(t.positionWC,t.directionWC,t.upWC).planes,i=r.Cartesian3.fromDegrees(...e),s=r.Transforms.eastNorthUpToFixedFrame(i),o=r.Matrix4.inverse(s,new r.Matrix4),a=n.map((t=>{const e=new r.Cartesian3(t.x,t.y,t.z),n=t.w,i=r.Matrix4.multiplyByPointAsVector(o,e,new r.Cartesian3),s=r.Cartesian3.multiplyByScalar(e,-n,new r.Cartesian3),a=r.Matrix4.multiplyByPoint(o,s,new r.Cartesian3),u=-r.Cartesian3.dot(i,a);return new r.Cartesian4(i.x,i.y,i.z,u)}));return new r.CullingVolume(a)}getTileKey(t){return t.coord.join("-")}computeTilesToRender(){if(!this.tileset)return{};const t=this._scene.camera,{enuCenterGCJ02:e}=this.tileset.metadata,n=this.getViewFrustum(),i=this.tileset.root,s=Tc(t.position,e),o=t=>{const e=new r.Cartesian3(t[0],t[1],t[2]),n=new r.Cartesian3(t[0]-t[3],t[1]-t[7],t[2]-t[11]),i=new r.Cartesian3(t[0]+t[3],t[1]-t[7],t[2]-t[11]),o=new r.Cartesian3(t[0]-t[3],t[1]+t[7],t[2]-t[11]),a=new r.Cartesian3(t[0]+t[3],t[1]+t[7],t[2]-t[11]);return Math.min(r.Cartesian3.distance(s,e),r.Cartesian3.distance(s,n),r.Cartesian3.distance(s,i),r.Cartesian3.distance(s,o),r.Cartesian3.distance(s,a))},a={},u=i.boundingVolume.box,h=new r.Cartesian3(u[0]-u[3],u[1]-u[7],u[2]-u[11]),l=new r.Cartesian3(u[0]+u[3],u[1]+u[7],u[2]+u[11]),c=new r.AxisAlignedBoundingBox(h,l);if(n.computeVisibility(c)===r.Intersect.OUTSIDE)return a;let f=i.children.length;for(let t=0;t<f;t++){const e=i.children[t],s=e.boundingVolume.box,u=new r.Cartesian3(s[0]-s[3],s[1]-s[7],s[2]-s[11]),h=new r.Cartesian3(s[0]+s[3],s[1]+s[7],s[2]+s[11]),l=new r.AxisAlignedBoundingBox(u,h);if(n.computeVisibility(l)!==r.Intersect.OUTSIDE&&o(s)<2e3){const t=e.content.uri,n=t.startsWith("http")?t:this.Gd+"/"+t;a[this.getTileKey(e)]=n}}return a}get name(){return this.so}clock=null;get entities(){return this.ro}get isLoading(){return this.oo}get changedEvent(){return this.ao}get errorEvent(){return this.uo}get loadingEvent(){return this.ho}get show(){return this._show}set show(t){this._show=t}get clustering(){return this.lo}set clustering(t){if(!r.defined(t))throw new r.DeveloperError("value must be defined.");this.lo=t}update(){const t=Date.now();if(t-this.Ad<1e3)return!0;if(this.Ad=t,!this.tileset&&2!==this.Vd)return this.loadTileset(),!0;const e=this.computeTilesToRender(),n=this.tileChanged(this.Qd,e);if(this.Qd=e,!n&&!this.Kd)return!0;this.Kd=!1;const i=Object.keys(e);for(let t=0;t<i.length;t++){const n=i[t];this.We.rr(n)||2===this.Wd[n]||this.worker.postMessage({coord:n,url:e[n],center:this.tileset.metadata.enuCenterGCJ02})}return this.changedEvent.raiseEvent(),!0}tileChanged(t,e){const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!0;for(let t=0;t<n.length;t++)if(!e[n[t]])return!0;return!1}getData(){const t=this.Qd,e=Object.keys(t);let n=[];for(let t=0;t<e.length;t++){const i=this.We.Ji(e[t],!1);i&&n.push(i)}return n}onMessage=t=>{const{coord:e,status:n,data:i}=t.data;3===n?(this.We.nr(e,i),this.Wd[e]=3,this.changedEvent.raiseEvent(e)):this.Wd[e]=4}}class tm{show=!0;command;attributeLocations={position:0,normal:1,face:2};data;layer;wallColor;roofColor;createCommand(t){const n=e.RenderState.fromCache({depthTest:{enabled:!0},depthMask:!0,blending:e.BlendingState.ALPHA_BLEND});var i=new e.ShaderSource({sources:["in vec3 position;in vec3 normal;in float face;out vec3 v_positionEC;out vec3 v_normalEC;out float v_face;void main(){v_positionEC=(czm_modelView*vec4(position,1.0)).xyz;v_normalEC=czm_normal*normal;v_face=face;gl_Position=czm_modelViewProjection*vec4(position,1.0);}"]}),r=new e.ShaderSource({sources:["in vec3 v_positionEC;in vec3 v_normalEC;in float v_face;uniform vec4 u_roofColor;uniform vec4 u_wallColor;void main(){float lambert=dot(czm_sunDirectionEC,v_normalEC);lambert=0.8+lambert*0.2;vec3 color=(1.0-v_face)*u_roofColor.xyz+v_face*u_wallColor.xyz;out_FragColor=vec4(color*lambert,1.0);}"]}),s={u_wallColor:()=>this.wallColor,u_roofColor:()=>this.roofColor},o=e.ShaderProgram.fromCache({context:t,vertexShaderSource:i,fragmentShaderSource:r,attributeLocations:this.attributeLocations});return new e.DrawCommand({vertexArray:this.createVertexArray(t),primitiveType:e.PrimitiveType.TRIANGLES,renderState:n,shaderProgram:o,uniformMap:s,owner:this,pass:e.Pass.OPAQUE,modelMatrix:this.data.model})}createVertexArray(t){var n=new e.Geometry({attributes:{position:new e.GeometryAttribute({componentDatatype:e.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:this.data.vertices}),normal:new e.GeometryAttribute({componentDatatype:e.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:this.data.normals}),face:new e.GeometryAttribute({componentDatatype:e.ComponentDatatype.FLOAT,componentsPerAttribute:1,values:this.data.faces})},indices:this.data.indices,primitiveType:e.PrimitiveType.TRIANGLES,boundingSphere:e.BoundingSphere.fromVertices(this.data.positions)});return e.VertexArray.fromGeometry({context:t,geometry:n,attributeLocations:this.attributeLocations,bufferUsage:e.BufferUsage.STATIC_DRAW})}constructor(t={}){this.data=t.data,this.layer=t.layer,this.wallColor=t.wallColor,this.roofColor=t.roofColor}update(t){this.show&&this.layer&&(e.defined(this.command)||(this.command=this.createCommand(t.context)),e.defined(this.command)&&t.commandList.push(this.command))}isDestroyed(){return!1}destroy(){return e.defined(this.command)&&(this.command.shaderProgram=this.command.shaderProgram&&this.command.shaderProgram.destroy()),e.destroyObject(this)}setWallColor(t){this.wallColor=t,this.command=null}setRoofColor(t){this.roofColor=t,this.command=null}}class em{show=!0;dataSource;Ln;_scene;ye=!1;pp=2e3;_dirty=!0;vp={};yp;set roofColor(t){this.yp=t,Object.keys(this.vp).forEach((e=>{this.vp[e].setRoofColor(t)})),this.requestRender()}get roofColor(){return this.yp}mp;set wallColor(t){this.mp=t,Object.keys(this.vp).forEach((e=>{this.vp[e].setWallColor(t)})),this.requestRender()}get wallColor(){return this.mp}set minDistance(t){this.pp=t,this.dataSource.minDistance=this.pp}get minDistance(){return this.pp}onData=()=>{this.ye||(this._dirty=!0,this.requestRender())};requestRender=()=>{this.Ln.scene.requestRender()};isDestroyed(){return this.ye}destroy(){this.dataSource.changedEvent.removeEventListener(this.onData),this.ye=!0,this.Ln.dataSources.remove(this.dataSource),Object.keys(this.vp).forEach((t=>{this._scene.primitives.remove(this.vp[t])})),this.requestRender()}constructor(t){this.mp=t.wallColor||new e.Color(.7,.7,.7,.7),this.yp=t.roofColor||new e.Color(.92,.92,.92,1),this.Ln=t.viewer,this._scene=t.viewer.scene,this.pp=t.minDistance||2e3,this.dataSource=new Jy({scene:this._scene,tileset:t.tileset,minDistance:this.minDistance}),this.onData=Gy(this.onData,500,{maxWait:1e3}),this.dataSource.changedEvent.addEventListener(this.onData),this.Ln.dataSources.add(this.dataSource)}wp(t,e){const n=e.reduce(((t,e)=>(t[e.id]=e,t)),{}),i=Object.keys(t),r=[],s=[];for(let t=0;t<i.length;t++)n[i[t]]||r.push(i[t]);for(let n=0;n<e.length;n++)t[e[n].id]||s.push(e[n]);return{add:s,remove:r}}update(t){const e=this.dataSource.getData(),{add:n,remove:i}=this.wp(this.vp,e);for(let t=0;t<i.length;t++){const e=i[t];this._scene.primitives.remove(this.vp[e]),delete this.vp[e]}for(let t=0;t<n.length;t++){const e=n[t].id,i=new tm({data:n[t],layer:this,wallColor:this.wallColor,roofColor:this.roofColor});this.vp[e]=i}Object.keys(this.vp).forEach((e=>{this.vp[e].update(t)}))}debugElements=[];visualizeTiles(){const t=this.dataSource.Qd,n=t=>{const[e,n,i]=t,r=Math.pow(2,e),s=360/r,o=180/r;return{bl:[n*s-180,90-(i+1)*o,0],br:[(n+1)*s-180,90-(i+1)*o,0],tl:[n*s-180,90-i*o,0],tr:[(n+1)*s-180,90-i*o,0]}},i=Object.keys(t).map((t=>t.split("-").map((t=>parseInt(t,10)))));this.debugElements.forEach((t=>this.Ln.entities.remove(t))),this.debugElements=[];for(let t=0;t<i.length;t++){const r=i[t],{bl:s,br:o,tl:a,tr:u}=n(r),h=e.Cartesian3.fromDegreesArray([s[0],s[1],o[0],o[1],u[0],u[1],a[0],a[1]]),l=this.Ln.entities.add({name:r.join("-"),polyline:{hierarchy:h,positions:h,material:e.Color.BLUE.withAlpha(.9),outline:!0,outlineColor:e.Color.RED,outlineWidth:10,width:8},disableDepthTestDistance:Number.POSITIVE_INFINITY});this.debugElements.push(l);const c=e.Cartesian3.fromDegrees((s[0]+u[0])/2,(s[1]+u[1])/2),f=this.Ln.entities.add({position:c,name:i.join("-"),label:{text:r.join("-"),fillColor:e.Color.WHITE,font:"20px sans-serif",disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.debugElements.push(f)}this.Ln.scene.requestRender()}}class nm{url;zoom;gp={};constructor(t){this.url=t?.url,this.zoom=t?.zoom||17}async sample(t,e){try{const n=function(t,e,n){const i=Math.pow(2,n),r=360/i,s=180/i;return[n,Math.floor(t/r)+i/2,i/2-Math.ceil(e/s)]}(t,e,this.zoom),i=n.join("_")+".bin",r=this.url.endsWith("/")?this.url+i:this.url+"/"+i;let s=this.gp[r];s||(s=this.bp(r));const o=await s;if(!o)return void delete this.gp[r];const{width:a,height:u,transform:h,data:l}=o,c=Math.floor((t-h[2])/h[0])+Math.floor((e-h[5])/h[4])*a;if(c>=0&&c<a*u){const t=l[c];if(-9999===t)return;return t}return}catch(t){return}}bp(t){const e=fetch(t).then((t=>{if(!t.ok)throw new Error(`HTTP status: ${t.status}`);return t.arrayBuffer()})).then((t=>{const e=new Uint32Array(t),n=e[0],i=e[1],r=new Float64Array(t,8);return{width:n,height:i,transform:[r[0],r[1],r[2],r[3],r[4],r[5]],data:new Int16Array(t,56)}})).catch((t=>null));return this.gp[t]=e,e}}class im{constructor(t){void 0===t&&(t=[0,0,0,0,0,0,0,0,0]),this.elements=t}identity(){const t=this.elements;t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1}setZero(){const t=this.elements;t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0}setTrace(t){const e=this.elements;e[0]=t.x,e[4]=t.y,e[8]=t.z}getTrace(t){void 0===t&&(t=new sm);const e=this.elements;return t.x=e[0],t.y=e[4],t.z=e[8],t}vmult(t,e){void 0===e&&(e=new sm);const n=this.elements,i=t.x,r=t.y,s=t.z;return e.x=n[0]*i+n[1]*r+n[2]*s,e.y=n[3]*i+n[4]*r+n[5]*s,e.z=n[6]*i+n[7]*r+n[8]*s,e}smult(t){for(let e=0;e<this.elements.length;e++)this.elements[e]*=t}mmult(t,e){void 0===e&&(e=new im);const n=this.elements,i=t.elements,r=e.elements,s=n[0],o=n[1],a=n[2],u=n[3],h=n[4],l=n[5],c=n[6],f=n[7],d=n[8],p=i[0],v=i[1],y=i[2],m=i[3],w=i[4],g=i[5],b=i[6],x=i[7],_=i[8];return r[0]=s*p+o*m+a*b,r[1]=s*v+o*w+a*x,r[2]=s*y+o*g+a*_,r[3]=u*p+h*m+l*b,r[4]=u*v+h*w+l*x,r[5]=u*y+h*g+l*_,r[6]=c*p+f*m+d*b,r[7]=c*v+f*w+d*x,r[8]=c*y+f*g+d*_,e}scale(t,e){void 0===e&&(e=new im);const n=this.elements,i=e.elements;for(let e=0;3!==e;e++)i[3*e+0]=t.x*n[3*e+0],i[3*e+1]=t.y*n[3*e+1],i[3*e+2]=t.z*n[3*e+2];return e}solve(t,e){void 0===e&&(e=new sm);const n=[];let i,r;for(i=0;i<12;i++)n.push(0);for(i=0;i<3;i++)for(r=0;r<3;r++)n[i+4*r]=this.elements[i+3*r];n[3]=t.x,n[7]=t.y,n[11]=t.z;let s=3;const o=s;let a,u;do{if(i=o-s,0===n[i+4*i])for(r=i+1;r<o;r++)if(0!==n[i+4*r]){a=4;do{u=4-a,n[u+4*i]+=n[u+4*r]}while(--a);break}if(0!==n[i+4*i])for(r=i+1;r<o;r++){const t=n[i+4*r]/n[i+4*i];a=4;do{u=4-a,n[u+4*r]=u<=i?0:n[u+4*r]-n[u+4*i]*t}while(--a)}}while(--s);if(e.z=n[11]/n[10],e.y=(n[7]-n[6]*e.z)/n[5],e.x=(n[3]-n[2]*e.z-n[1]*e.y)/n[0],isNaN(e.x)||isNaN(e.y)||isNaN(e.z)||e.x===1/0||e.y===1/0||e.z===1/0)throw`Could not solve equation! Got x=[${e.toString()}], b=[${t.toString()}], A=[${this.toString()}]`;return e}e(t,e,n){if(void 0===n)return this.elements[e+3*t];this.elements[e+3*t]=n}copy(t){for(let e=0;e<t.elements.length;e++)this.elements[e]=t.elements[e];return this}toString(){let t="";for(let e=0;e<9;e++)t+=this.elements[e]+",";return t}reverse(t){void 0===t&&(t=new im);const e=rm;let n,i;for(n=0;n<3;n++)for(i=0;i<3;i++)e[n+6*i]=this.elements[n+3*i];e[3]=1,e[9]=0,e[15]=0,e[4]=0,e[10]=1,e[16]=0,e[5]=0,e[11]=0,e[17]=1;let r=3;const s=r;let o,a;do{if(n=s-r,0===e[n+6*n])for(i=n+1;i<s;i++)if(0!==e[n+6*i]){o=6;do{a=6-o,e[a+6*n]+=e[a+6*i]}while(--o);break}if(0!==e[n+6*n])for(i=n+1;i<s;i++){const t=e[n+6*i]/e[n+6*n];o=6;do{a=6-o,e[a+6*i]=a<=n?0:e[a+6*i]-e[a+6*n]*t}while(--o)}}while(--r);n=2;do{i=n-1;do{const t=e[n+6*i]/e[n+6*n];o=6;do{a=6-o,e[a+6*i]=e[a+6*i]-e[a+6*n]*t}while(--o)}while(i--)}while(--n);n=2;do{const t=1/e[n+6*n];o=6;do{a=6-o,e[a+6*n]=e[a+6*n]*t}while(--o)}while(n--);n=2;do{i=2;do{if(a=e[3+i+6*n],isNaN(a)||a===1/0)throw`Could not reverse! A=[${this.toString()}]`;t.e(n,i,a)}while(i--)}while(n--);return t}setRotationFromQuaternion(t){const e=t.x,n=t.y,i=t.z,r=t.w,s=e+e,o=n+n,a=i+i,u=e*s,h=e*o,l=e*a,c=n*o,f=n*a,d=i*a,p=r*s,v=r*o,y=r*a,m=this.elements;return m[0]=1-(c+d),m[1]=h-y,m[2]=l+v,m[3]=h+y,m[4]=1-(u+d),m[5]=f-p,m[6]=l-v,m[7]=f+p,m[8]=1-(u+c),this}transpose(t){void 0===t&&(t=new im);const e=this.elements,n=t.elements;let i;return n[0]=e[0],n[4]=e[4],n[8]=e[8],i=e[1],n[1]=e[3],n[3]=i,i=e[2],n[2]=e[6],n[6]=i,i=e[5],n[5]=e[7],n[7]=i,t}}const rm=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];class sm{constructor(t,e,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=n}cross(t,e){void 0===e&&(e=new sm);const n=t.x,i=t.y,r=t.z,s=this.x,o=this.y,a=this.z;return e.x=o*r-a*i,e.y=a*n-s*r,e.z=s*i-o*n,e}set(t,e,n){return this.x=t,this.y=e,this.z=n,this}setZero(){this.x=this.y=this.z=0}vadd(t,e){if(!e)return new sm(this.x+t.x,this.y+t.y,this.z+t.z);e.x=t.x+this.x,e.y=t.y+this.y,e.z=t.z+this.z}vsub(t,e){if(!e)return new sm(this.x-t.x,this.y-t.y,this.z-t.z);e.x=this.x-t.x,e.y=this.y-t.y,e.z=this.z-t.z}crossmat(){return new im([0,-this.z,this.y,this.z,0,-this.x,-this.y,this.x,0])}normalize(){const t=this.x,e=this.y,n=this.z,i=Math.sqrt(t*t+e*e+n*n);if(i>0){const t=1/i;this.x*=t,this.y*=t,this.z*=t}else this.x=0,this.y=0,this.z=0;return i}unit(t){void 0===t&&(t=new sm);const e=this.x,n=this.y,i=this.z;let r=Math.sqrt(e*e+n*n+i*i);return r>0?(r=1/r,t.x=e*r,t.y=n*r,t.z=i*r):(t.x=1,t.y=0,t.z=0),t}length(){const t=this.x,e=this.y,n=this.z;return Math.sqrt(t*t+e*e+n*n)}lengthSquared(){return this.dot(this)}distanceTo(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,o=t.z;return Math.sqrt((r-e)*(r-e)+(s-n)*(s-n)+(o-i)*(o-i))}distanceSquared(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,o=t.z;return(r-e)*(r-e)+(s-n)*(s-n)+(o-i)*(o-i)}scale(t,e){void 0===e&&(e=new sm);const n=this.x,i=this.y,r=this.z;return e.x=t*n,e.y=t*i,e.z=t*r,e}vmul(t,e){return void 0===e&&(e=new sm),e.x=t.x*this.x,e.y=t.y*this.y,e.z=t.z*this.z,e}addScaledVector(t,e,n){return void 0===n&&(n=new sm),n.x=this.x+t*e.x,n.y=this.y+t*e.y,n.z=this.z+t*e.z,n}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isZero(){return 0===this.x&&0===this.y&&0===this.z}negate(t){return void 0===t&&(t=new sm),t.x=-this.x,t.y=-this.y,t.z=-this.z,t}tangents(t,e){const n=this.length();if(n>0){const i=om,r=1/n;i.set(this.x*r,this.y*r,this.z*r);const s=am;Math.abs(i.x)<.9?(s.set(1,0,0),i.cross(s,t)):(s.set(0,1,0),i.cross(s,t)),i.cross(t,e)}else t.set(1,0,0),e.set(0,1,0)}toString(){return`${this.x},${this.y},${this.z}`}toArray(){return[this.x,this.y,this.z]}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}lerp(t,e,n){const i=this.x,r=this.y,s=this.z;n.x=i+(t.x-i)*e,n.y=r+(t.y-r)*e,n.z=s+(t.z-s)*e}almostEquals(t,e){return void 0===e&&(e=1e-6),!(Math.abs(this.x-t.x)>e||Math.abs(this.y-t.y)>e||Math.abs(this.z-t.z)>e)}almostZero(t){return void 0===t&&(t=1e-6),!(Math.abs(this.x)>t||Math.abs(this.y)>t||Math.abs(this.z)>t)}isAntiparallelTo(t,e){return this.negate(um),um.almostEquals(t,e)}clone(){return new sm(this.x,this.y,this.z)}}sm.ZERO=new sm(0,0,0),sm.UNIT_X=new sm(1,0,0),sm.UNIT_Y=new sm(0,1,0),sm.UNIT_Z=new sm(0,0,1);const om=new sm,am=new sm,um=new sm;class hm{constructor(t){void 0===t&&(t={}),this.lowerBound=new sm,this.upperBound=new sm,t.lowerBound&&this.lowerBound.copy(t.lowerBound),t.upperBound&&this.upperBound.copy(t.upperBound)}setFromPoints(t,e,n,i){const r=this.lowerBound,s=this.upperBound,o=n;r.copy(t[0]),o&&o.vmult(r,r),s.copy(r);for(let e=1;e<t.length;e++){let n=t[e];o&&(o.vmult(n,lm),n=lm),n.x>s.x&&(s.x=n.x),n.x<r.x&&(r.x=n.x),n.y>s.y&&(s.y=n.y),n.y<r.y&&(r.y=n.y),n.z>s.z&&(s.z=n.z),n.z<r.z&&(r.z=n.z)}return e&&(e.vadd(r,r),e.vadd(s,s)),i&&(r.x-=i,r.y-=i,r.z-=i,s.x+=i,s.y+=i,s.z+=i),this}copy(t){return this.lowerBound.copy(t.lowerBound),this.upperBound.copy(t.upperBound),this}clone(){return(new hm).copy(this)}extend(t){this.lowerBound.x=Math.min(this.lowerBound.x,t.lowerBound.x),this.upperBound.x=Math.max(this.upperBound.x,t.upperBound.x),this.lowerBound.y=Math.min(this.lowerBound.y,t.lowerBound.y),this.upperBound.y=Math.max(this.upperBound.y,t.upperBound.y),this.lowerBound.z=Math.min(this.lowerBound.z,t.lowerBound.z),this.upperBound.z=Math.max(this.upperBound.z,t.upperBound.z)}overlaps(t){const e=this.lowerBound,n=this.upperBound,i=t.lowerBound,r=t.upperBound,s=i.x<=n.x&&n.x<=r.x||e.x<=r.x&&r.x<=n.x,o=i.y<=n.y&&n.y<=r.y||e.y<=r.y&&r.y<=n.y,a=i.z<=n.z&&n.z<=r.z||e.z<=r.z&&r.z<=n.z;return s&&o&&a}volume(){const t=this.lowerBound,e=this.upperBound;return(e.x-t.x)*(e.y-t.y)*(e.z-t.z)}contains(t){const e=this.lowerBound,n=this.upperBound,i=t.lowerBound,r=t.upperBound;return e.x<=i.x&&n.x>=r.x&&e.y<=i.y&&n.y>=r.y&&e.z<=i.z&&n.z>=r.z}getCorners(t,e,n,i,r,s,o,a){const u=this.lowerBound,h=this.upperBound;t.copy(u),e.set(h.x,u.y,u.z),n.set(h.x,h.y,u.z),i.set(u.x,h.y,h.z),r.set(h.x,u.y,h.z),s.set(u.x,h.y,u.z),o.set(u.x,u.y,h.z),a.copy(h)}toLocalFrame(t,e){const n=cm,i=n[0],r=n[1],s=n[2],o=n[3],a=n[4],u=n[5],h=n[6],l=n[7];this.getCorners(i,r,s,o,a,u,h,l);for(let e=0;8!==e;e++){const i=n[e];t.pointToLocal(i,i)}return e.setFromPoints(n)}toWorldFrame(t,e){const n=cm,i=n[0],r=n[1],s=n[2],o=n[3],a=n[4],u=n[5],h=n[6],l=n[7];this.getCorners(i,r,s,o,a,u,h,l);for(let e=0;8!==e;e++){const i=n[e];t.pointToWorld(i,i)}return e.setFromPoints(n)}overlapsRay(t){const{direction:e,from:n}=t,i=1/e.x,r=1/e.y,s=1/e.z,o=(this.lowerBound.x-n.x)*i,a=(this.upperBound.x-n.x)*i,u=(this.lowerBound.y-n.y)*r,h=(this.upperBound.y-n.y)*r,l=(this.lowerBound.z-n.z)*s,c=(this.upperBound.z-n.z)*s,f=Math.max(Math.max(Math.min(o,a),Math.min(u,h)),Math.min(l,c)),d=Math.min(Math.min(Math.max(o,a),Math.max(u,h)),Math.max(l,c));return!(d<0||f>d)}}const lm=new sm,cm=[new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm];class fm{constructor(){this.matrix=[]}get(t,e){let{index:n}=t,{index:i}=e;if(i>n){const t=i;i=n,n=t}return this.matrix[(n*(n+1)>>1)+i-1]}set(t,e,n){let{index:i}=t,{index:r}=e;if(r>i){const t=r;r=i,i=t}this.matrix[(i*(i+1)>>1)+r-1]=n?1:0}reset(){for(let t=0,e=this.matrix.length;t!==e;t++)this.matrix[t]=0}setNumObjects(t){this.matrix.length=t*(t-1)>>1}}class dm{addEventListener(t,e){void 0===this.xp&&(this.xp={});const n=this.xp;return void 0===n[t]&&(n[t]=[]),n[t].includes(e)||n[t].push(e),this}hasEventListener(t,e){if(void 0===this.xp)return!1;const n=this.xp;return!(void 0===n[t]||!n[t].includes(e))}hasAnyEventListener(t){return void 0!==this.xp&&void 0!==this.xp[t]}removeEventListener(t,e){if(void 0===this.xp)return this;const n=this.xp;if(void 0===n[t])return this;const i=n[t].indexOf(e);return-1!==i&&n[t].splice(i,1),this}dispatchEvent(t){if(void 0===this.xp)return this;const e=this.xp[t.type];if(void 0!==e){t.target=this;for(let n=0,i=e.length;n<i;n++)e[n].call(this,t)}return this}}class pm{constructor(t,e,n,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=1),this.x=t,this.y=e,this.z=n,this.w=i}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}toArray(){return[this.x,this.y,this.z,this.w]}setFromAxisAngle(t,e){const n=Math.sin(.5*e);return this.x=t.x*n,this.y=t.y*n,this.z=t.z*n,this.w=Math.cos(.5*e),this}toAxisAngle(t){void 0===t&&(t=new sm),this.normalize();const e=2*Math.acos(this.w),n=Math.sqrt(1-this.w*this.w);return n<.001?(t.x=this.x,t.y=this.y,t.z=this.z):(t.x=this.x/n,t.y=this.y/n,t.z=this.z/n),[t,e]}setFromVectors(t,e){if(t.isAntiparallelTo(e)){const e=vm,n=ym;t.tangents(e,n),this.setFromAxisAngle(e,Math.PI)}else{const n=t.cross(e);this.x=n.x,this.y=n.y,this.z=n.z,this.w=Math.sqrt(t.length()**2*e.length()**2)+t.dot(e),this.normalize()}return this}mult(t,e){void 0===e&&(e=new pm);const n=this.x,i=this.y,r=this.z,s=this.w,o=t.x,a=t.y,u=t.z,h=t.w;return e.x=n*h+s*o+i*u-r*a,e.y=i*h+s*a+r*o-n*u,e.z=r*h+s*u+n*a-i*o,e.w=s*h-n*o-i*a-r*u,e}inverse(t){void 0===t&&(t=new pm);const e=this.x,n=this.y,i=this.z,r=this.w;this.conjugate(t);const s=1/(e*e+n*n+i*i+r*r);return t.x*=s,t.y*=s,t.z*=s,t.w*=s,t}conjugate(t){return void 0===t&&(t=new pm),t.x=-this.x,t.y=-this.y,t.z=-this.z,t.w=this.w,t}normalize(){let t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return 0===t?(this.x=0,this.y=0,this.z=0,this.w=0):(t=1/t,this.x*=t,this.y*=t,this.z*=t,this.w*=t),this}normalizeFast(){const t=(3-(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w))/2;return 0===t?(this.x=0,this.y=0,this.z=0,this.w=0):(this.x*=t,this.y*=t,this.z*=t,this.w*=t),this}vmult(t,e){void 0===e&&(e=new sm);const n=t.x,i=t.y,r=t.z,s=this.x,o=this.y,a=this.z,u=this.w,h=u*n+o*r-a*i,l=u*i+a*n-s*r,c=u*r+s*i-o*n,f=-s*n-o*i-a*r;return e.x=h*u+f*-s+l*-a-c*-o,e.y=l*u+f*-o+c*-s-h*-a,e.z=c*u+f*-a+h*-o-l*-s,e}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this}toEuler(t,e){let n,i,r;void 0===e&&(e="YZX");const s=this.x,o=this.y,a=this.z,u=this.w;if("YZX"!==e)throw new Error(`Euler order ${e} not supported yet.`);{const t=s*o+a*u;if(t>.499&&(n=2*Math.atan2(s,u),i=Math.PI/2,r=0),t<-.499&&(n=-2*Math.atan2(s,u),i=-Math.PI/2,r=0),void 0===n){const e=s*s,h=o*o,l=a*a;n=Math.atan2(2*o*u-2*s*a,1-2*h-2*l),i=Math.asin(2*t),r=Math.atan2(2*s*u-2*o*a,1-2*e-2*l)}}t.y=n,t.z=i,t.x=r}setFromEuler(t,e,n,i){void 0===i&&(i="XYZ");const r=Math.cos(t/2),s=Math.cos(e/2),o=Math.cos(n/2),a=Math.sin(t/2),u=Math.sin(e/2),h=Math.sin(n/2);return"XYZ"===i?(this.x=a*s*o+r*u*h,this.y=r*u*o-a*s*h,this.z=r*s*h+a*u*o,this.w=r*s*o-a*u*h):"YXZ"===i?(this.x=a*s*o+r*u*h,this.y=r*u*o-a*s*h,this.z=r*s*h-a*u*o,this.w=r*s*o+a*u*h):"ZXY"===i?(this.x=a*s*o-r*u*h,this.y=r*u*o+a*s*h,this.z=r*s*h+a*u*o,this.w=r*s*o-a*u*h):"ZYX"===i?(this.x=a*s*o-r*u*h,this.y=r*u*o+a*s*h,this.z=r*s*h-a*u*o,this.w=r*s*o+a*u*h):"YZX"===i?(this.x=a*s*o+r*u*h,this.y=r*u*o+a*s*h,this.z=r*s*h-a*u*o,this.w=r*s*o-a*u*h):"XZY"===i&&(this.x=a*s*o-r*u*h,this.y=r*u*o-a*s*h,this.z=r*s*h+a*u*o,this.w=r*s*o+a*u*h),this}clone(){return new pm(this.x,this.y,this.z,this.w)}slerp(t,e,n){void 0===n&&(n=new pm);const i=this.x,r=this.y,s=this.z,o=this.w;let a,u,h,l,c,f=t.x,d=t.y,p=t.z,v=t.w;return u=i*f+r*d+s*p+o*v,u<0&&(u=-u,f=-f,d=-d,p=-p,v=-v),1-u>1e-6?(a=Math.acos(u),h=Math.sin(a),l=Math.sin((1-e)*a)/h,c=Math.sin(e*a)/h):(l=1-e,c=e),n.x=l*i+c*f,n.y=l*r+c*d,n.z=l*s+c*p,n.w=l*o+c*v,n}integrate(t,e,n,i){void 0===i&&(i=new pm);const r=t.x*n.x,s=t.y*n.y,o=t.z*n.z,a=this.x,u=this.y,h=this.z,l=this.w,c=.5*e;return i.x+=c*(r*l+s*h-o*u),i.y+=c*(s*l+o*a-r*h),i.z+=c*(o*l+r*u-s*a),i.w+=c*(-r*a-s*u-o*h),i}}const vm=new sm,ym=new sm;class mm{constructor(t){void 0===t&&(t={}),this.id=mm.idCounter++,this.type=t.type||0,this.boundingSphereRadius=0,this.collisionResponse=!t.collisionResponse||t.collisionResponse,this.collisionFilterGroup=void 0!==t.collisionFilterGroup?t.collisionFilterGroup:1,this.collisionFilterMask=void 0!==t.collisionFilterMask?t.collisionFilterMask:-1,this.material=t.material?t.material:null,this.body=null}updateBoundingSphereRadius(){throw`computeBoundingSphereRadius() not implemented for shape type ${this.type}`}volume(){throw`volume() not implemented for shape type ${this.type}`}calculateLocalInertia(t,e){throw`calculateLocalInertia() not implemented for shape type ${this.type}`}calculateWorldAABB(t,e,n,i){throw`calculateWorldAABB() not implemented for shape type ${this.type}`}}mm.idCounter=0,mm.types={SPHERE:1,PLANE:2,BOX:4,COMPOUND:8,CONVEXPOLYHEDRON:16,HEIGHTFIELD:32,PARTICLE:64,CYLINDER:128,TRIMESH:256};class wm{constructor(t){void 0===t&&(t={}),this.position=new sm,this.quaternion=new pm,t.position&&this.position.copy(t.position),t.quaternion&&this.quaternion.copy(t.quaternion)}pointToLocal(t,e){return wm.pointToLocalFrame(this.position,this.quaternion,t,e)}pointToWorld(t,e){return wm.pointToWorldFrame(this.position,this.quaternion,t,e)}vectorToWorldFrame(t,e){return void 0===e&&(e=new sm),this.quaternion.vmult(t,e),e}static pointToLocalFrame(t,e,n,i){return void 0===i&&(i=new sm),n.vsub(t,i),e.conjugate(gm),gm.vmult(i,i),i}static pointToWorldFrame(t,e,n,i){return void 0===i&&(i=new sm),e.vmult(n,i),i.vadd(t,i),i}static vectorToWorldFrame(t,e,n){return void 0===n&&(n=new sm),t.vmult(e,n),n}static vectorToLocalFrame(t,e,n,i){return void 0===i&&(i=new sm),e.w*=-1,e.vmult(n,i),e.w*=-1,i}}const gm=new pm;class bm extends mm{constructor(t){void 0===t&&(t={});const{vertices:e=[],faces:n=[],normals:i=[],axes:r,boundingSphereRadius:s}=t;super({type:mm.types.CONVEXPOLYHEDRON}),this.vertices=e,this.faces=n,this.faceNormals=i,0===this.faceNormals.length&&this.computeNormals(),s?this.boundingSphereRadius=s:this.updateBoundingSphereRadius(),this.worldVertices=[],this.worldVerticesNeedsUpdate=!0,this.worldFaceNormals=[],this.worldFaceNormalsNeedsUpdate=!0,this.uniqueAxes=r?r.slice():null,this.uniqueEdges=[],this.computeEdges()}computeEdges(){const t=this.faces,e=this.vertices,n=this.uniqueEdges;n.length=0;const i=new sm;for(let r=0;r!==t.length;r++){const s=t[r],o=s.length;for(let t=0;t!==o;t++){const r=(t+1)%o;e[s[t]].vsub(e[s[r]],i),i.normalize();let a=!1;for(let t=0;t!==n.length;t++)if(n[t].almostEquals(i)||n[t].almostEquals(i)){a=!0;break}a||n.push(i.clone())}}}computeNormals(){this.faceNormals.length=this.faces.length;for(let t=0;t<this.faces.length;t++){for(let e=0;e<this.faces[t].length;e++)if(!this.vertices[this.faces[t][e]])throw new Error(`Vertex ${this.faces[t][e]} not found!`);const e=this.faceNormals[t]||new sm;this.getFaceNormal(t,e),e.negate(e),this.faceNormals[t]=e;const n=this.vertices[this.faces[t][0]];if(e.dot(n)<0)for(let e=0;e<this.faces[t].length;e++);}}getFaceNormal(t,e){const n=this.faces[t],i=this.vertices[n[0]],r=this.vertices[n[1]],s=this.vertices[n[2]];bm.computeNormal(i,r,s,e)}static computeNormal(t,e,n,i){const r=new sm,s=new sm;e.vsub(t,s),n.vsub(e,r),r.cross(s,i),i.isZero()||i.normalize()}clipAgainstHull(t,e,n,i,r,s,o,a,u){const h=new sm;let l=-1,c=-Number.MAX_VALUE;for(let t=0;t<n.faces.length;t++){h.copy(n.faceNormals[t]),r.vmult(h,h);const e=h.dot(s);e>c&&(c=e,l=t)}const f=[];for(let t=0;t<n.faces[l].length;t++){const e=n.vertices[n.faces[l][t]],s=new sm;s.copy(e),r.vmult(s,s),i.vadd(s,s),f.push(s)}l>=0&&this.clipFaceAgainstHull(s,t,e,f,o,a,u)}findSeparatingAxis(t,e,n,i,r,s,o,a){const u=new sm,h=new sm,l=new sm,c=new sm,f=new sm,d=new sm;let p=Number.MAX_VALUE;const v=this;if(v.uniqueAxes)for(let o=0;o!==v.uniqueAxes.length;o++){n.vmult(v.uniqueAxes[o],u);const a=v.testSepAxis(u,t,e,n,i,r);if(!1===a)return!1;a<p&&(p=a,s.copy(u))}else{const a=o?o.length:v.faces.length;for(let h=0;h<a;h++){const a=o?o[h]:h;u.copy(v.faceNormals[a]),n.vmult(u,u);const l=v.testSepAxis(u,t,e,n,i,r);if(!1===l)return!1;l<p&&(p=l,s.copy(u))}}if(t.uniqueAxes)for(let o=0;o!==t.uniqueAxes.length;o++){r.vmult(t.uniqueAxes[o],h);const a=v.testSepAxis(h,t,e,n,i,r);if(!1===a)return!1;a<p&&(p=a,s.copy(h))}else{const o=a?a.length:t.faces.length;for(let u=0;u<o;u++){const o=a?a[u]:u;h.copy(t.faceNormals[o]),r.vmult(h,h);const l=v.testSepAxis(h,t,e,n,i,r);if(!1===l)return!1;l<p&&(p=l,s.copy(h))}}for(let o=0;o!==v.uniqueEdges.length;o++){n.vmult(v.uniqueEdges[o],c);for(let o=0;o!==t.uniqueEdges.length;o++)if(r.vmult(t.uniqueEdges[o],f),c.cross(f,d),!d.almostZero()){d.normalize();const o=v.testSepAxis(d,t,e,n,i,r);if(!1===o)return!1;o<p&&(p=o,s.copy(d))}}return i.vsub(e,l),l.dot(s)>0&&s.negate(s),!0}testSepAxis(t,e,n,i,r,s){bm.project(this,t,n,i,xm),bm.project(e,t,r,s,_m);const o=xm[0],a=xm[1],u=_m[0],h=_m[1];if(o<h||u<a)return!1;const l=o-h,c=u-a;return l<c?l:c}calculateLocalInertia(t,e){const n=new sm,i=new sm;this.computeLocalAABB(i,n);const r=n.x-i.x,s=n.y-i.y,o=n.z-i.z;e.x=1/12*t*(4*s*s+4*o*o),e.y=1/12*t*(4*r*r+4*o*o),e.z=1/12*t*(4*s*s+4*r*r)}getPlaneConstantOfFace(t){const e=this.faces[t],n=this.faceNormals[t],i=this.vertices[e[0]];return-n.dot(i)}clipFaceAgainstHull(t,e,n,i,r,s,o){const a=new sm,u=new sm,h=new sm,l=new sm,c=new sm,f=new sm,d=new sm,p=new sm,v=this,y=i,m=[];let w=-1,g=Number.MAX_VALUE;for(let e=0;e<v.faces.length;e++){a.copy(v.faceNormals[e]),n.vmult(a,a);const i=a.dot(t);i<g&&(g=i,w=e)}if(w<0)return;const b=v.faces[w];b.connectedFaces=[];for(let t=0;t<v.faces.length;t++)for(let e=0;e<v.faces[t].length;e++)-1!==b.indexOf(v.faces[t][e])&&t!==w&&-1===b.connectedFaces.indexOf(t)&&b.connectedFaces.push(t);const x=b.length;for(let t=0;t<x;t++){const i=v.vertices[b[t]],r=v.vertices[b[(t+1)%x]];i.vsub(r,u),h.copy(u),n.vmult(h,h),e.vadd(h,h),l.copy(this.faceNormals[w]),n.vmult(l,l),e.vadd(l,l),h.cross(l,c),c.negate(c),f.copy(i),n.vmult(f,f),e.vadd(f,f);const s=b.connectedFaces[t];d.copy(this.faceNormals[s]);const o=this.getPlaneConstantOfFace(s);p.copy(d),n.vmult(p,p);const a=o-p.dot(e);for(this.clipFaceAgainstPlane(y,m,p,a);y.length;)y.shift();for(;m.length;)y.push(m.shift())}d.copy(this.faceNormals[w]);const _=this.getPlaneConstantOfFace(w);p.copy(d),n.vmult(p,p);const k=_-p.dot(e);for(let t=0;t<y.length;t++){let e=p.dot(y[t])+k;if(e<=r&&(e=r),e<=s){const n=y[t];if(e<=1e-6){const t={point:n,normal:p,depth:e};o.push(t)}}}}clipFaceAgainstPlane(t,e,n,i){let r,s;const o=t.length;if(o<2)return e;let a=t[t.length-1],u=t[0];r=n.dot(a)+i;for(let h=0;h<o;h++){if(u=t[h],s=n.dot(u)+i,r<0)if(s<0){const t=new sm;t.copy(u),e.push(t)}else{const t=new sm;a.lerp(u,r/(r-s),t),e.push(t)}else if(s<0){const t=new sm;a.lerp(u,r/(r-s),t),e.push(t),e.push(u)}a=u,r=s}return e}computeWorldVertices(t,e){for(;this.worldVertices.length<this.vertices.length;)this.worldVertices.push(new sm);const n=this.vertices,i=this.worldVertices;for(let r=0;r!==this.vertices.length;r++)e.vmult(n[r],i[r]),t.vadd(i[r],i[r]);this.worldVerticesNeedsUpdate=!1}computeLocalAABB(t,e){const n=this.vertices;t.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),e.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let i=0;i<this.vertices.length;i++){const r=n[i];r.x<t.x?t.x=r.x:r.x>e.x&&(e.x=r.x),r.y<t.y?t.y=r.y:r.y>e.y&&(e.y=r.y),r.z<t.z?t.z=r.z:r.z>e.z&&(e.z=r.z)}}computeWorldFaceNormals(t){const e=this.faceNormals.length;for(;this.worldFaceNormals.length<e;)this.worldFaceNormals.push(new sm);const n=this.faceNormals,i=this.worldFaceNormals;for(let r=0;r!==e;r++)t.vmult(n[r],i[r]);this.worldFaceNormalsNeedsUpdate=!1}updateBoundingSphereRadius(){let t=0;const e=this.vertices;for(let n=0;n!==e.length;n++){const i=e[n].lengthSquared();i>t&&(t=i)}this.boundingSphereRadius=Math.sqrt(t)}calculateWorldAABB(t,e,n,i){const r=this.vertices;let s,o,a,u,h,l,c=new sm;for(let n=0;n<r.length;n++){c.copy(r[n]),e.vmult(c,c),t.vadd(c,c);const i=c;(void 0===s||i.x<s)&&(s=i.x),(void 0===u||i.x>u)&&(u=i.x),(void 0===o||i.y<o)&&(o=i.y),(void 0===h||i.y>h)&&(h=i.y),(void 0===a||i.z<a)&&(a=i.z),(void 0===l||i.z>l)&&(l=i.z)}n.set(s,o,a),i.set(u,h,l)}volume(){return 4*Math.PI*this.boundingSphereRadius/3}getAveragePointLocal(t){void 0===t&&(t=new sm);const e=this.vertices;for(let n=0;n<e.length;n++)t.vadd(e[n],t);return t.scale(1/e.length,t),t}transformAllPoints(t,e){const n=this.vertices.length,i=this.vertices;if(e){for(let t=0;t<n;t++){const n=i[t];e.vmult(n,n)}for(let t=0;t<this.faceNormals.length;t++){const n=this.faceNormals[t];e.vmult(n,n)}}if(t)for(let e=0;e<n;e++){const n=i[e];n.vadd(t,n)}}pointIsInside(t){const e=this.vertices,n=this.faces,i=this.faceNormals,r=new sm;this.getAveragePointLocal(r);for(let s=0;s<this.faces.length;s++){let o=i[s];const a=e[n[s][0]],u=new sm;t.vsub(a,u);const h=o.dot(u),l=new sm;r.vsub(a,l);const c=o.dot(l);if(h<0&&c>0||h>0&&c<0)return!1}return-1}static project(t,e,n,i,r){const s=t.vertices.length,o=km;let a=0,u=0;const h=$m,l=t.vertices;h.setZero(),wm.vectorToLocalFrame(n,i,e,o),wm.pointToLocalFrame(n,i,h,h);const c=h.dot(o);u=a=l[0].dot(o);for(let t=1;t<s;t++){const e=l[t].dot(o);e>a&&(a=e),e<u&&(u=e)}if(u-=c,a-=c,u>a){const t=u;u=a,a=t}r[0]=a,r[1]=u}}const xm=[],_m=[];new sm;const km=new sm,$m=new sm;class Sm extends mm{constructor(t){super({type:mm.types.BOX}),this.halfExtents=t,this.convexPolyhedronRepresentation=null,this.updateConvexPolyhedronRepresentation(),this.updateBoundingSphereRadius()}updateConvexPolyhedronRepresentation(){const t=this.halfExtents.x,e=this.halfExtents.y,n=this.halfExtents.z,i=sm,r=[new i(-t,-e,-n),new i(t,-e,-n),new i(t,e,-n),new i(-t,e,-n),new i(-t,-e,n),new i(t,-e,n),new i(t,e,n),new i(-t,e,n)],s=[new i(0,0,1),new i(0,1,0),new i(1,0,0)],o=new bm({vertices:r,faces:[[3,2,1,0],[4,5,6,7],[5,4,0,1],[2,3,7,6],[0,4,7,3],[1,2,6,5]],axes:s});this.convexPolyhedronRepresentation=o,o.material=this.material}calculateLocalInertia(t,e){return void 0===e&&(e=new sm),Sm.calculateInertia(this.halfExtents,t,e),e}static calculateInertia(t,e,n){const i=t;n.x=1/12*e*(4*i.y*i.y+4*i.z*i.z),n.y=1/12*e*(4*i.x*i.x+4*i.z*i.z),n.z=1/12*e*(4*i.y*i.y+4*i.x*i.x)}getSideNormals(t,e){const n=t,i=this.halfExtents;if(n[0].set(i.x,0,0),n[1].set(0,i.y,0),n[2].set(0,0,i.z),n[3].set(-i.x,0,0),n[4].set(0,-i.y,0),n[5].set(0,0,-i.z),void 0!==e)for(let t=0;t!==n.length;t++)e.vmult(n[t],n[t]);return n}volume(){return 8*this.halfExtents.x*this.halfExtents.y*this.halfExtents.z}updateBoundingSphereRadius(){this.boundingSphereRadius=this.halfExtents.length()}forEachWorldCorner(t,e,n){const i=this.halfExtents,r=[[i.x,i.y,i.z],[-i.x,i.y,i.z],[-i.x,-i.y,i.z],[-i.x,-i.y,-i.z],[i.x,-i.y,-i.z],[i.x,i.y,-i.z],[-i.x,i.y,-i.z],[i.x,-i.y,i.z]];for(let i=0;i<r.length;i++)Mm.set(r[i][0],r[i][1],r[i][2]),e.vmult(Mm,Mm),t.vadd(Mm,Mm),n(Mm.x,Mm.y,Mm.z)}calculateWorldAABB(t,e,n,i){const r=this.halfExtents;Em[0].set(r.x,r.y,r.z),Em[1].set(-r.x,r.y,r.z),Em[2].set(-r.x,-r.y,r.z),Em[3].set(-r.x,-r.y,-r.z),Em[4].set(r.x,-r.y,-r.z),Em[5].set(r.x,r.y,-r.z),Em[6].set(-r.x,r.y,-r.z),Em[7].set(r.x,-r.y,r.z);const s=Em[0];e.vmult(s,s),t.vadd(s,s),i.copy(s),n.copy(s);for(let r=1;r<8;r++){const s=Em[r];e.vmult(s,s),t.vadd(s,s);const o=s.x,a=s.y,u=s.z;o>i.x&&(i.x=o),a>i.y&&(i.y=a),u>i.z&&(i.z=u),o<n.x&&(n.x=o),a<n.y&&(n.y=a),u<n.z&&(n.z=u)}}}const Mm=new sm,Em=[new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm];class Cm extends dm{constructor(t){void 0===t&&(t={}),super(),this.id=Cm.idCounter++,this.index=-1,this.world=null,this.vlambda=new sm,this.collisionFilterGroup="number"==typeof t.collisionFilterGroup?t.collisionFilterGroup:1,this.collisionFilterMask="number"==typeof t.collisionFilterMask?t.collisionFilterMask:-1,this.collisionResponse="boolean"!=typeof t.collisionResponse||t.collisionResponse,this.position=new sm,this.previousPosition=new sm,this.interpolatedPosition=new sm,this.initPosition=new sm,t.position&&(this.position.copy(t.position),this.previousPosition.copy(t.position),this.interpolatedPosition.copy(t.position),this.initPosition.copy(t.position)),this.velocity=new sm,t.velocity&&this.velocity.copy(t.velocity),this.initVelocity=new sm,this.force=new sm;const e="number"==typeof t.mass?t.mass:0;this.mass=e,this.invMass=e>0?1/e:0,this.material=t.material||null,this.linearDamping="number"==typeof t.linearDamping?t.linearDamping:.01,this.type=e<=0?Cm.STATIC:Cm.DYNAMIC,typeof t.type==typeof Cm.STATIC&&(this.type=t.type),this.allowSleep=void 0===t.allowSleep||t.allowSleep,this.sleepState=Cm.AWAKE,this.sleepSpeedLimit=void 0!==t.sleepSpeedLimit?t.sleepSpeedLimit:.1,this.sleepTimeLimit=void 0!==t.sleepTimeLimit?t.sleepTimeLimit:1,this.timeLastSleepy=0,this.wakeUpAfterNarrowphase=!1,this.torque=new sm,this.quaternion=new pm,this.initQuaternion=new pm,this.previousQuaternion=new pm,this.interpolatedQuaternion=new pm,t.quaternion&&(this.quaternion.copy(t.quaternion),this.initQuaternion.copy(t.quaternion),this.previousQuaternion.copy(t.quaternion),this.interpolatedQuaternion.copy(t.quaternion)),this.angularVelocity=new sm,t.angularVelocity&&this.angularVelocity.copy(t.angularVelocity),this.initAngularVelocity=new sm,this.shapes=[],this.shapeOffsets=[],this.shapeOrientations=[],this.inertia=new sm,this.invInertia=new sm,this.invInertiaWorld=new im,this.invMassSolve=0,this.invInertiaSolve=new sm,this.invInertiaWorldSolve=new im,this.fixedRotation=void 0!==t.fixedRotation&&t.fixedRotation,this.angularDamping=void 0!==t.angularDamping?t.angularDamping:.01,this.linearFactor=new sm(1,1,1),t.linearFactor&&this.linearFactor.copy(t.linearFactor),this.angularFactor=new sm(1,1,1),t.angularFactor&&this.angularFactor.copy(t.angularFactor),this.aabb=new hm,this.aabbNeedsUpdate=!0,this.boundingRadius=0,this.wlambda=new sm,this.isTrigger=Boolean(t.isTrigger),t.shape&&this.addShape(t.shape),this.updateMassProperties()}wakeUp(){const t=this.sleepState;this.sleepState=Cm.AWAKE,this.wakeUpAfterNarrowphase=!1,t===Cm.SLEEPING&&this.dispatchEvent(Cm.wakeupEvent)}sleep(){this.sleepState=Cm.SLEEPING,this.velocity.set(0,0,0),this.angularVelocity.set(0,0,0),this.wakeUpAfterNarrowphase=!1}sleepTick(t){if(this.allowSleep){const e=this.sleepState,n=this.velocity.lengthSquared()+this.angularVelocity.lengthSquared(),i=this.sleepSpeedLimit**2;e===Cm.AWAKE&&n<i?(this.sleepState=Cm.SLEEPY,this.timeLastSleepy=t,this.dispatchEvent(Cm.sleepyEvent)):e===Cm.SLEEPY&&n>i?this.wakeUp():e===Cm.SLEEPY&&t-this.timeLastSleepy>this.sleepTimeLimit&&(this.sleep(),this.dispatchEvent(Cm.sleepEvent))}}updateSolveMassProperties(){this.sleepState===Cm.SLEEPING||this.type===Cm.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve.setZero(),this.invInertiaWorldSolve.setZero()):(this.invMassSolve=this.invMass,this.invInertiaSolve.copy(this.invInertia),this.invInertiaWorldSolve.copy(this.invInertiaWorld))}pointToLocalFrame(t,e){return void 0===e&&(e=new sm),t.vsub(this.position,e),this.quaternion.conjugate().vmult(e,e),e}vectorToLocalFrame(t,e){return void 0===e&&(e=new sm),this.quaternion.conjugate().vmult(t,e),e}pointToWorldFrame(t,e){return void 0===e&&(e=new sm),this.quaternion.vmult(t,e),e.vadd(this.position,e),e}vectorToWorldFrame(t,e){return void 0===e&&(e=new sm),this.quaternion.vmult(t,e),e}addShape(t,e,n){const i=new sm,r=new pm;return e&&i.copy(e),n&&r.copy(n),this.shapes.push(t),this.shapeOffsets.push(i),this.shapeOrientations.push(r),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,t.body=this,this}removeShape(t){const e=this.shapes.indexOf(t);return-1===e||(this.shapes.splice(e,1),this.shapeOffsets.splice(e,1),this.shapeOrientations.splice(e,1),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,t.body=null),this}updateBoundingRadius(){const t=this.shapes,e=this.shapeOffsets,n=t.length;let i=0;for(let r=0;r!==n;r++){const n=t[r];n.updateBoundingSphereRadius();const s=e[r].length(),o=n.boundingSphereRadius;s+o>i&&(i=s+o)}this.boundingRadius=i}updateAABB(){const t=this.shapes,e=this.shapeOffsets,n=this.shapeOrientations,i=t.length,r=Am,s=Im,o=this.quaternion,a=this.aabb,u=Om;for(let h=0;h!==i;h++){const i=t[h];o.vmult(e[h],r),r.vadd(this.position,r),o.mult(n[h],s),i.calculateWorldAABB(r,s,u.lowerBound,u.upperBound),0===h?a.copy(u):a.extend(u)}this.aabbNeedsUpdate=!1}updateInertiaWorld(t){const e=this.invInertia;if(e.x!==e.y||e.y!==e.z||t){const t=Tm,n=zm;t.setRotationFromQuaternion(this.quaternion),t.transpose(n),t.scale(e,t),t.mmult(n,this.invInertiaWorld)}}applyForce(t,e){if(void 0===e&&(e=new sm),this.type!==Cm.DYNAMIC)return;this.sleepState===Cm.SLEEPING&&this.wakeUp();const n=Dm;e.cross(t,n),this.force.vadd(t,this.force),this.torque.vadd(n,this.torque)}applyLocalForce(t,e){if(void 0===e&&(e=new sm),this.type!==Cm.DYNAMIC)return;const n=Pm,i=Rm;this.vectorToWorldFrame(t,n),this.vectorToWorldFrame(e,i),this.applyForce(n,i)}applyTorque(t){this.type===Cm.DYNAMIC&&(this.sleepState===Cm.SLEEPING&&this.wakeUp(),this.torque.vadd(t,this.torque))}applyImpulse(t,e){if(void 0===e&&(e=new sm),this.type!==Cm.DYNAMIC)return;this.sleepState===Cm.SLEEPING&&this.wakeUp();const n=e,i=Nm;i.copy(t),i.scale(this.invMass,i),this.velocity.vadd(i,this.velocity);const r=Fm;n.cross(t,r),this.invInertiaWorld.vmult(r,r),this.angularVelocity.vadd(r,this.angularVelocity)}applyLocalImpulse(t,e){if(void 0===e&&(e=new sm),this.type!==Cm.DYNAMIC)return;const n=Um,i=qm;this.vectorToWorldFrame(t,n),this.vectorToWorldFrame(e,i),this.applyImpulse(n,i)}updateMassProperties(){const t=jm;this.invMass=this.mass>0?1/this.mass:0;const e=this.inertia,n=this.fixedRotation;this.updateAABB(),t.set((this.aabb.upperBound.x-this.aabb.lowerBound.x)/2,(this.aabb.upperBound.y-this.aabb.lowerBound.y)/2,(this.aabb.upperBound.z-this.aabb.lowerBound.z)/2),Sm.calculateInertia(t,this.mass,e),this.invInertia.set(e.x>0&&!n?1/e.x:0,e.y>0&&!n?1/e.y:0,e.z>0&&!n?1/e.z:0),this.updateInertiaWorld(!0)}getVelocityAtWorldPoint(t,e){const n=new sm;return t.vsub(this.position,n),this.angularVelocity.cross(n,e),this.velocity.vadd(e,e),e}integrate(t,e,n){if(this.previousPosition.copy(this.position),this.previousQuaternion.copy(this.quaternion),this.type!==Cm.DYNAMIC&&this.type!==Cm.KINEMATIC||this.sleepState===Cm.SLEEPING)return;const i=this.velocity,r=this.angularVelocity,s=this.position,o=this.force,a=this.torque,u=this.quaternion,h=this.invMass,l=this.invInertiaWorld,c=this.linearFactor,f=h*t;i.x+=o.x*f*c.x,i.y+=o.y*f*c.y,i.z+=o.z*f*c.z;const d=l.elements,p=this.angularFactor,v=a.x*p.x,y=a.y*p.y,m=a.z*p.z;r.x+=t*(d[0]*v+d[1]*y+d[2]*m),r.y+=t*(d[3]*v+d[4]*y+d[5]*m),r.z+=t*(d[6]*v+d[7]*y+d[8]*m),s.x+=i.x*t,s.y+=i.y*t,s.z+=i.z*t,u.integrate(this.angularVelocity,t,this.angularFactor,u),e&&(n?u.normalizeFast():u.normalize()),this.aabbNeedsUpdate=!0,this.updateInertiaWorld()}}Cm.idCounter=0,Cm.COLLIDE_EVENT_NAME="collide",Cm.DYNAMIC=1,Cm.STATIC=2,Cm.KINEMATIC=4,Cm.AWAKE=0,Cm.SLEEPY=1,Cm.SLEEPING=2,Cm.wakeupEvent={type:"wakeup"},Cm.sleepyEvent={type:"sleepy"},Cm.sleepEvent={type:"sleep"};const Am=new sm,Im=new pm,Om=new hm,Tm=new im,zm=new im,Dm=(new im,new sm),Pm=new sm,Rm=new sm,Nm=new sm,Fm=new sm,Um=new sm,qm=new sm,jm=new sm;class Bm{constructor(){this.world=null,this.useBoundingBoxes=!1,this.dirty=!0}collisionPairs(t,e,n){throw new Error("collisionPairs not implemented for this BroadPhase class!")}needBroadphaseCollision(t,e){return!(!(t.collisionFilterGroup&e.collisionFilterMask&&e.collisionFilterGroup&t.collisionFilterMask)||(t.type&Cm.STATIC||t.sleepState===Cm.SLEEPING)&&(e.type&Cm.STATIC||e.sleepState===Cm.SLEEPING))}intersectionTest(t,e,n,i){this.useBoundingBoxes?this.doBoundingBoxBroadphase(t,e,n,i):this.doBoundingSphereBroadphase(t,e,n,i)}doBoundingSphereBroadphase(t,e,n,i){const r=Lm;e.position.vsub(t.position,r);const s=(t.boundingRadius+e.boundingRadius)**2;r.lengthSquared()<s&&(n.push(t),i.push(e))}doBoundingBoxBroadphase(t,e,n,i){t.aabbNeedsUpdate&&t.updateAABB(),e.aabbNeedsUpdate&&e.updateAABB(),t.aabb.overlaps(e.aabb)&&(n.push(t),i.push(e))}makePairsUnique(t,e){const n=Hm,i=Vm,r=Wm,s=t.length;for(let n=0;n!==s;n++)i[n]=t[n],r[n]=e[n];t.length=0,e.length=0;for(let t=0;t!==s;t++){const e=i[t].id,s=r[t].id,o=e<s?`${e},${s}`:`${s},${e}`;n[o]=t,n.keys.push(o)}for(let s=0;s!==n.keys.length;s++){const s=n.keys.pop(),o=n[s];t.push(i[o]),e.push(r[o]),delete n[s]}}setWorld(t){}static boundingSphereCheck(t,e){const n=new sm;t.position.vsub(e.position,n);const i=t.shapes[0],r=e.shapes[0];return Math.pow(i.boundingSphereRadius+r.boundingSphereRadius,2)>n.lengthSquared()}aabbQuery(t,e,n){return[]}}const Lm=new sm;new sm,new pm,new sm;const Hm={keys:[]},Vm=[],Wm=[];new sm,new sm,new sm;class Gm extends Bm{constructor(){super()}collisionPairs(t,e,n){const i=t.bodies,r=i.length;let s,o;for(let t=0;t!==r;t++)for(let r=0;r!==t;r++)s=i[t],o=i[r],this.needBroadphaseCollision(s,o)&&this.intersectionTest(s,o,e,n)}aabbQuery(t,e,n){void 0===n&&(n=[]);for(let i=0;i<t.bodies.length;i++){const r=t.bodies[i];r.aabbNeedsUpdate&&r.updateAABB(),r.aabb.overlaps(e)&&n.push(r)}return n}}class Qm{constructor(){this.rayFromWorld=new sm,this.rayToWorld=new sm,this.hitNormalWorld=new sm,this.hitPointWorld=new sm,this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}reset(){this.rayFromWorld.setZero(),this.rayToWorld.setZero(),this.hitNormalWorld.setZero(),this.hitPointWorld.setZero(),this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}abort(){this.shouldStop=!0}set(t,e,n,i,r,s,o){this.rayFromWorld.copy(t),this.rayToWorld.copy(e),this.hitNormalWorld.copy(n),this.hitPointWorld.copy(i),this.shape=r,this.body=s,this.distance=o}}let Km,Xm,Zm,Ym,Jm,tw,ew;Km=mm.types.SPHERE,Xm=mm.types.PLANE,Zm=mm.types.BOX,Ym=mm.types.CYLINDER,Jm=mm.types.CONVEXPOLYHEDRON,tw=mm.types.HEIGHTFIELD,ew=mm.types.TRIMESH;class nw{get[Km](){return this.kp}get[Xm](){return this.Sp}get[Zm](){return this.Ep}get[Ym](){return this.Ap}get[Jm](){return this.Ap}get[tw](){return this.Tp}get[ew](){return this.Dp}constructor(t,e){void 0===t&&(t=new sm),void 0===e&&(e=new sm),this.from=t.clone(),this.to=e.clone(),this.direction=new sm,this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionFilterMask=-1,this.collisionFilterGroup=-1,this.mode=nw.ANY,this.result=new Qm,this.hasHit=!1,this.callback=t=>{}}intersectWorld(t,e){return this.mode=e.mode||nw.ANY,this.result=e.result||new Qm,this.skipBackfaces=!!e.skipBackfaces,this.collisionFilterMask=void 0!==e.collisionFilterMask?e.collisionFilterMask:-1,this.collisionFilterGroup=void 0!==e.collisionFilterGroup?e.collisionFilterGroup:-1,this.checkCollisionResponse=void 0===e.checkCollisionResponse||e.checkCollisionResponse,e.from&&this.from.copy(e.from),e.to&&this.to.copy(e.to),this.callback=e.callback||(()=>{}),this.hasHit=!1,this.result.reset(),this.updateDirection(),this.getAABB(iw),rw.length=0,t.broadphase.aabbQuery(t,iw,rw),this.intersectBodies(rw),this.hasHit}intersectBody(t,e){e&&(this.result=e,this.updateDirection());const n=this.checkCollisionResponse;if(n&&!t.collisionResponse)return;if(!(this.collisionFilterGroup&t.collisionFilterMask&&t.collisionFilterGroup&this.collisionFilterMask))return;const i=aw,r=uw;for(let e=0,s=t.shapes.length;e<s;e++){const s=t.shapes[e];if((!n||s.collisionResponse)&&(t.quaternion.mult(t.shapeOrientations[e],r),t.quaternion.vmult(t.shapeOffsets[e],i),i.vadd(t.position,i),this.intersectShape(s,r,i,t),this.result.shouldStop))break}}intersectBodies(t,e){e&&(this.result=e,this.updateDirection());for(let e=0,n=t.length;!this.result.shouldStop&&e<n;e++)this.intersectBody(t[e])}updateDirection(){this.to.vsub(this.from,this.direction),this.direction.normalize()}intersectShape(t,e,n,i){const r=function(t,e,n){n.vsub(t,Aw);const i=Aw.dot(e);return e.scale(i,Iw),Iw.vadd(t,Iw),n.distanceTo(Iw)}(this.from,this.direction,n);if(r>t.boundingSphereRadius)return;const s=this[t.type];s&&s.call(this,t,e,n,i,t)}Ep(t,e,n,i,r){return this.Ap(t.convexPolyhedronRepresentation,e,n,i,r)}Sp(t,e,n,i,r){const s=this.from,o=this.to,a=this.direction,u=new sm(0,0,1);e.vmult(u,u);const h=new sm;s.vsub(n,h);const l=h.dot(u);if(o.vsub(n,h),l*h.dot(u)>0)return;if(s.distanceTo(o)<l)return;const c=u.dot(a);if(Math.abs(c)<this.precision)return;const f=new sm,d=new sm,p=new sm;s.vsub(n,f);const v=-u.dot(f)/c;a.scale(v,d),s.vadd(d,p),this.reportIntersection(u,p,r,i,-1)}getAABB(t){const{lowerBound:e,upperBound:n}=t,i=this.to,r=this.from;e.x=Math.min(i.x,r.x),e.y=Math.min(i.y,r.y),e.z=Math.min(i.z,r.z),n.x=Math.max(i.x,r.x),n.y=Math.max(i.y,r.y),n.z=Math.max(i.z,r.z)}Tp(t,e,n,i,r){t.data,t.elementSize;const s=vw;s.from.copy(this.from),s.to.copy(this.to),wm.pointToLocalFrame(n,e,s.from,s.from),wm.pointToLocalFrame(n,e,s.to,s.to),s.updateDirection();const o=yw;let a,u,h,l;a=u=0,h=l=t.data.length-1;const c=new hm;s.getAABB(c),t.getIndexOfPosition(c.lowerBound.x,c.lowerBound.y,o,!0),a=Math.max(a,o[0]),u=Math.max(u,o[1]),t.getIndexOfPosition(c.upperBound.x,c.upperBound.y,o,!0),h=Math.min(h,o[0]+1),l=Math.min(l,o[1]+1);for(let o=a;o<h;o++)for(let a=u;a<l;a++){if(this.result.shouldStop)return;if(t.getAabbAtIndex(o,a,c),c.overlapsRay(s)){if(t.getConvexTrianglePillar(o,a,!1),wm.pointToWorldFrame(n,e,t.pillarOffset,pw),this.Ap(t.pillarConvex,e,pw,i,r,dw),this.result.shouldStop)return;t.getConvexTrianglePillar(o,a,!0),wm.pointToWorldFrame(n,e,t.pillarOffset,pw),this.Ap(t.pillarConvex,e,pw,i,r,dw)}}}kp(t,e,n,i,r){const s=this.from,o=this.to,a=t.radius,u=(o.x-s.x)**2+(o.y-s.y)**2+(o.z-s.z)**2,h=2*((o.x-s.x)*(s.x-n.x)+(o.y-s.y)*(s.y-n.y)+(o.z-s.z)*(s.z-n.z)),l=h**2-4*u*((s.x-n.x)**2+(s.y-n.y)**2+(s.z-n.z)**2-a**2),c=mw,f=ww;if(!(l<0))if(0===l)s.lerp(o,l,c),c.vsub(n,f),f.normalize(),this.reportIntersection(f,c,r,i,-1);else{const t=(-h-Math.sqrt(l))/(2*u),e=(-h+Math.sqrt(l))/(2*u);if(t>=0&&t<=1&&(s.lerp(o,t,c),c.vsub(n,f),f.normalize(),this.reportIntersection(f,c,r,i,-1)),this.result.shouldStop)return;e>=0&&e<=1&&(s.lerp(o,e,c),c.vsub(n,f),f.normalize(),this.reportIntersection(f,c,r,i,-1))}}Ap(t,e,n,i,r,s){const o=gw,a=bw,u=s&&s.faceList||null,h=t.faces,l=t.vertices,c=t.faceNormals,f=this.direction,d=this.from,p=this.to,v=d.distanceTo(p),y=u?u.length:h.length,m=this.result;for(let t=0;!m.shouldStop&&t<y;t++){const s=u?u[t]:t,p=h[s],y=c[s],w=e,g=n;a.copy(l[p[0]]),w.vmult(a,a),a.vadd(g,a),a.vsub(d,a),w.vmult(y,o);const b=f.dot(o);if(Math.abs(b)<this.precision)continue;const x=o.dot(a)/b;if(!(x<0)){f.scale(x,hw),hw.vadd(d,hw),lw.copy(l[p[0]]),w.vmult(lw,lw),g.vadd(lw,lw);for(let t=1;!m.shouldStop&&t<p.length-1;t++){cw.copy(l[p[t]]),fw.copy(l[p[t+1]]),w.vmult(cw,cw),w.vmult(fw,fw),g.vadd(cw,cw),g.vadd(fw,fw);const e=hw.distanceTo(d);!nw.pointInTriangle(hw,lw,cw,fw)&&!nw.pointInTriangle(hw,cw,lw,fw)||e>v||this.reportIntersection(o,hw,r,i,s)}}}}Dp(t,e,n,i,r,s){const o=xw,a=Ew,u=Cw,h=bw,l=_w,c=kw,f=$w,d=Mw,p=Sw,v=t.indices;t.vertices;const y=this.from,m=this.to,w=this.direction;u.position.copy(n),u.quaternion.copy(e),wm.vectorToLocalFrame(n,e,w,l),wm.pointToLocalFrame(n,e,y,c),wm.pointToLocalFrame(n,e,m,f),f.x*=t.scale.x,f.y*=t.scale.y,f.z*=t.scale.z,c.x*=t.scale.x,c.y*=t.scale.y,c.z*=t.scale.z,f.vsub(c,l),l.normalize();const g=c.distanceSquared(f);t.tree.rayQuery(this,u,a);for(let s=0,u=a.length;!this.result.shouldStop&&s!==u;s++){const u=a[s];t.getNormal(u,o),t.getVertex(v[3*u],lw),lw.vsub(c,h);const f=l.dot(o),y=o.dot(h)/f;if(y<0)continue;l.scale(y,hw),hw.vadd(c,hw),t.getVertex(v[3*u+1],cw),t.getVertex(v[3*u+2],fw);const m=hw.distanceSquared(c);!nw.pointInTriangle(hw,cw,lw,fw)&&!nw.pointInTriangle(hw,lw,cw,fw)||m>g||(wm.vectorToWorldFrame(e,o,p),wm.pointToWorldFrame(n,e,hw,d),this.reportIntersection(p,d,r,i,u))}a.length=0}reportIntersection(t,e,n,i,r){const s=this.from,o=this.to,a=s.distanceTo(e),u=this.result;if(!(this.skipBackfaces&&t.dot(this.direction)>0))switch(u.hitFaceIndex=void 0!==r?r:-1,this.mode){case nw.ALL:this.hasHit=!0,u.set(s,o,t,e,n,i,a),u.hasHit=!0,this.callback(u);break;case nw.CLOSEST:(a<u.distance||!u.hasHit)&&(this.hasHit=!0,u.hasHit=!0,u.set(s,o,t,e,n,i,a));break;case nw.ANY:this.hasHit=!0,u.hasHit=!0,u.set(s,o,t,e,n,i,a),u.shouldStop=!0}}static pointInTriangle(t,e,n,i){i.vsub(e,Aw),n.vsub(e,sw),t.vsub(e,ow);const r=Aw.dot(Aw),s=Aw.dot(sw),o=Aw.dot(ow),a=sw.dot(sw),u=sw.dot(ow);let h,l;return(h=a*o-s*u)>=0&&(l=r*u-s*o)>=0&&h+l<r*a-s*s}}nw.CLOSEST=1,nw.ANY=2,nw.ALL=4;const iw=new hm,rw=[],sw=new sm,ow=new sm,aw=new sm,uw=new pm,hw=new sm,lw=new sm,cw=new sm,fw=new sm;new sm,new Qm;const dw={faceList:[0]},pw=new sm,vw=new nw,yw=[],mw=new sm,ww=new sm,gw=new sm;new sm,new sm;const bw=new sm,xw=new sm,_w=new sm,kw=new sm,$w=new sm,Sw=new sm,Mw=new sm;new hm;const Ew=[],Cw=new wm,Aw=new sm,Iw=new sm;class Ow{static defaults(t,e){void 0===t&&(t={});for(let n in e)n in t||(t[n]=e[n]);return t}}class Tw{constructor(){this.spatial=new sm,this.rotational=new sm}multiplyElement(t){return t.spatial.dot(this.spatial)+t.rotational.dot(this.rotational)}multiplyVectors(t,e){return t.dot(this.spatial)+e.dot(this.rotational)}}class zw{constructor(t,e,n,i){void 0===n&&(n=-1e6),void 0===i&&(i=1e6),this.id=zw.idCounter++,this.minForce=n,this.maxForce=i,this.bi=t,this.bj=e,this.a=0,this.b=0,this.eps=0,this.jacobianElementA=new Tw,this.jacobianElementB=new Tw,this.enabled=!0,this.multiplier=0,this.setSpookParams(1e7,4,1/60)}setSpookParams(t,e,n){const i=e,r=t,s=n;this.a=4/(s*(1+4*i)),this.b=4*i/(1+4*i),this.eps=4/(s*s*r*(1+4*i))}computeB(t,e,n){const i=this.computeGW();return-this.computeGq()*t-i*e-this.computeGiMf()*n}computeGq(){const t=this.jacobianElementA,e=this.jacobianElementB,n=this.bi,i=this.bj,r=n.position,s=i.position;return t.spatial.dot(r)+e.spatial.dot(s)}computeGW(){const t=this.jacobianElementA,e=this.jacobianElementB,n=this.bi,i=this.bj,r=n.velocity,s=i.velocity,o=n.angularVelocity,a=i.angularVelocity;return t.multiplyVectors(r,o)+e.multiplyVectors(s,a)}computeGWlambda(){const t=this.jacobianElementA,e=this.jacobianElementB,n=this.bi,i=this.bj,r=n.vlambda,s=i.vlambda,o=n.wlambda,a=i.wlambda;return t.multiplyVectors(r,o)+e.multiplyVectors(s,a)}computeGiMf(){const t=this.jacobianElementA,e=this.jacobianElementB,n=this.bi,i=this.bj,r=n.force,s=n.torque,o=i.force,a=i.torque,u=n.invMassSolve,h=i.invMassSolve;return r.scale(u,Dw),o.scale(h,Pw),n.invInertiaWorldSolve.vmult(s,Rw),i.invInertiaWorldSolve.vmult(a,Nw),t.multiplyVectors(Dw,Rw)+e.multiplyVectors(Pw,Nw)}computeGiMGt(){const t=this.jacobianElementA,e=this.jacobianElementB,n=this.bi,i=this.bj,r=n.invMassSolve,s=i.invMassSolve,o=n.invInertiaWorldSolve,a=i.invInertiaWorldSolve;let u=r+s;return o.vmult(t.rotational,Fw),u+=Fw.dot(t.rotational),a.vmult(e.rotational,Fw),u+=Fw.dot(e.rotational),u}addToWlambda(t){const e=this.jacobianElementA,n=this.jacobianElementB,i=this.bi,r=this.bj,s=Uw;i.vlambda.addScaledVector(i.invMassSolve*t,e.spatial,i.vlambda),r.vlambda.addScaledVector(r.invMassSolve*t,n.spatial,r.vlambda),i.invInertiaWorldSolve.vmult(e.rotational,s),i.wlambda.addScaledVector(t,s,i.wlambda),r.invInertiaWorldSolve.vmult(n.rotational,s),r.wlambda.addScaledVector(t,s,r.wlambda)}computeC(){return this.computeGiMGt()+this.eps}}zw.idCounter=0;const Dw=new sm,Pw=new sm,Rw=new sm,Nw=new sm,Fw=new sm,Uw=new sm;class qw extends zw{constructor(t,e,n){void 0===n&&(n=1e6),super(t,e,0,n),this.restitution=0,this.ri=new sm,this.rj=new sm,this.ni=new sm}computeB(t){const e=this.a,n=this.b,i=this.bi,r=this.bj,s=this.ri,o=this.rj,a=jw,u=Bw,h=i.velocity,l=i.angularVelocity;i.force,i.torque;const c=r.velocity,f=r.angularVelocity;r.force,r.torque;const d=Lw,p=this.jacobianElementA,v=this.jacobianElementB,y=this.ni;s.cross(y,a),o.cross(y,u),y.negate(p.spatial),a.negate(p.rotational),v.spatial.copy(y),v.rotational.copy(u),d.copy(r.position),d.vadd(o,d),d.vsub(i.position,d),d.vsub(s,d);const m=y.dot(d),w=this.restitution+1;return-m*e-(w*c.dot(y)-w*h.dot(y)+f.dot(u)-l.dot(a))*n-t*this.computeGiMf()}getImpactVelocityAlongNormal(){const t=Hw,e=Vw,n=Ww,i=Gw,r=Qw;return this.bi.position.vadd(this.ri,n),this.bj.position.vadd(this.rj,i),this.bi.getVelocityAtWorldPoint(n,t),this.bj.getVelocityAtWorldPoint(i,e),t.vsub(e,r),this.ni.dot(r)}}const jw=new sm,Bw=new sm,Lw=new sm,Hw=new sm,Vw=new sm,Ww=new sm,Gw=new sm,Qw=new sm;new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm;class Kw extends zw{constructor(t,e,n){super(t,e,-n,n),this.ri=new sm,this.rj=new sm,this.t=new sm}computeB(t){this.a;const e=this.b;this.bi,this.bj;const n=this.ri,i=this.rj,r=Xw,s=Zw,o=this.t;n.cross(o,r),i.cross(o,s);const a=this.jacobianElementA,u=this.jacobianElementB;return o.negate(a.spatial),r.negate(a.rotational),u.spatial.copy(o),u.rotational.copy(s),-this.computeGW()*e-t*this.computeGiMf()}}const Xw=new sm,Zw=new sm;class Yw{constructor(t,e,n){n=Ow.defaults(n,{friction:.3,restitution:.3,contactEquationStiffness:1e7,contactEquationRelaxation:3,frictionEquationStiffness:1e7,frictionEquationRelaxation:3}),this.id=Yw.idCounter++,this.materials=[t,e],this.friction=n.friction,this.restitution=n.restitution,this.contactEquationStiffness=n.contactEquationStiffness,this.contactEquationRelaxation=n.contactEquationRelaxation,this.frictionEquationStiffness=n.frictionEquationStiffness,this.frictionEquationRelaxation=n.frictionEquationRelaxation}}Yw.idCounter=0;class Jw{constructor(t){void 0===t&&(t={});let e="";"string"==typeof t&&(e=t,t={}),this.name=e,this.id=Jw.idCounter++,this.friction=void 0!==t.friction?t.friction:-1,this.restitution=void 0!==t.restitution?t.restitution:-1}}Jw.idCounter=0,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new nw,new sm,new sm,new sm,new sm(1,0,0),new sm(0,1,0),new sm(0,0,1),new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm,new sm;class tg{constructor(t){void 0===t&&(t={}),this.root=t.root||null,this.aabb=t.aabb?t.aabb.clone():new hm,this.data=[],this.children=[]}reset(){this.children.length=this.data.length=0}insert(t,e,n){void 0===n&&(n=0);const i=this.data;if(!this.aabb.contains(t))return!1;const r=this.children;if(n<(this.maxDepth||this.root.maxDepth)){let i=!1;r.length||(this.subdivide(),i=!0);for(let i=0;8!==i;i++)if(r[i].insert(t,e,n+1))return!0;i&&(r.length=0)}return i.push(e),!0}subdivide(){const t=this.aabb,e=t.lowerBound,n=t.upperBound,i=this.children;i.push(new tg({aabb:new hm({lowerBound:new sm(0,0,0)})}),new tg({aabb:new hm({lowerBound:new sm(1,0,0)})}),new tg({aabb:new hm({lowerBound:new sm(1,1,0)})}),new tg({aabb:new hm({lowerBound:new sm(1,1,1)})}),new tg({aabb:new hm({lowerBound:new sm(0,1,1)})}),new tg({aabb:new hm({lowerBound:new sm(0,0,1)})}),new tg({aabb:new hm({lowerBound:new sm(1,0,1)})}),new tg({aabb:new hm({lowerBound:new sm(0,1,0)})})),n.vsub(e,ng),ng.scale(.5,ng);const r=this.root||this;for(let t=0;8!==t;t++){const n=i[t];n.root=r;const s=n.aabb.lowerBound;s.x*=ng.x,s.y*=ng.y,s.z*=ng.z,s.vadd(e,s),s.vadd(ng,n.aabb.upperBound)}}aabbQuery(t,e){this.data,this.children;const n=[this];for(;n.length;){const i=n.pop();i.aabb.overlaps(t)&&[].push.apply(e,i.data),[].push.apply(n,i.children)}return e}rayQuery(t,e,n){return t.getAABB(ig),ig.toLocalFrame(e,ig),this.aabbQuery(ig,n),n}removeEmptyNodes(){for(let t=this.children.length-1;t>=0;t--)this.children[t].removeEmptyNodes(),this.children[t].children.length||this.children[t].data.length||this.children.splice(t,1)}}class eg extends tg{constructor(t,e){void 0===e&&(e={}),super({root:null,aabb:t}),this.maxDepth=void 0!==e.maxDepth?e.maxDepth:8}}const ng=new sm,ig=new hm;class rg extends mm{constructor(t,e){super({type:mm.types.TRIMESH}),this.vertices=new Float32Array(t),this.indices=new Int16Array(e),this.normals=new Float32Array(e.length),this.aabb=new hm,this.edges=null,this.scale=new sm(1,1,1),this.tree=new eg,this.updateEdges(),this.updateNormals(),this.updateAABB(),this.updateBoundingSphereRadius(),this.updateTree()}updateTree(){const t=this.tree;t.reset(),t.aabb.copy(this.aabb);const e=this.scale;t.aabb.lowerBound.x*=1/e.x,t.aabb.lowerBound.y*=1/e.y,t.aabb.lowerBound.z*=1/e.z,t.aabb.upperBound.x*=1/e.x,t.aabb.upperBound.y*=1/e.y,t.aabb.upperBound.z*=1/e.z;const n=new hm,i=new sm,r=new sm,s=new sm,o=[i,r,s];for(let e=0;e<this.indices.length/3;e++){const a=3*e;this.Pp(this.indices[a],i),this.Pp(this.indices[a+1],r),this.Pp(this.indices[a+2],s),n.setFromPoints(o),t.insert(n,e)}t.removeEmptyNodes()}getTrianglesInAABB(t,e){og.copy(t);const n=this.scale,i=n.x,r=n.y,s=n.z,o=og.lowerBound,a=og.upperBound;return o.x/=i,o.y/=r,o.z/=s,a.x/=i,a.y/=r,a.z/=s,this.tree.aabbQuery(og,e)}setScale(t){const e=this.scale.x===this.scale.y&&this.scale.y===this.scale.z,n=t.x===t.y&&t.y===t.z;e&&n||this.updateNormals(),this.scale.copy(t),this.updateAABB(),this.updateBoundingSphereRadius()}updateNormals(){const t=sg,e=this.normals;for(let n=0;n<this.indices.length/3;n++){const i=3*n,r=this.indices[i],s=this.indices[i+1],o=this.indices[i+2];this.getVertex(r,cg),this.getVertex(s,fg),this.getVertex(o,dg),rg.computeNormal(fg,cg,dg,t),e[i]=t.x,e[i+1]=t.y,e[i+2]=t.z}}updateEdges(){const t={},e=(e,n)=>{t[e<n?`${e}_${n}`:`${n}_${e}`]=!0};for(let t=0;t<this.indices.length/3;t++){const n=3*t,i=this.indices[n],r=this.indices[n+1],s=this.indices[n+2];e(i,r),e(r,s),e(s,i)}const n=Object.keys(t);this.edges=new Int16Array(2*n.length);for(let t=0;t<n.length;t++){const e=n[t].split("_");this.edges[2*t]=parseInt(e[0],10),this.edges[2*t+1]=parseInt(e[1],10)}}getEdgeVertex(t,e,n){const i=this.edges[2*t+(e?1:0)];this.getVertex(i,n)}getEdgeVector(t,e){const n=ag,i=ug;this.getEdgeVertex(t,0,n),this.getEdgeVertex(t,1,i),i.vsub(n,e)}static computeNormal(t,e,n,i){e.vsub(t,lg),n.vsub(e,hg),hg.cross(lg,i),i.isZero()||i.normalize()}getVertex(t,e){const n=this.scale;return this.Pp(t,e),e.x*=n.x,e.y*=n.y,e.z*=n.z,e}Pp(t,e){const n=3*t,i=this.vertices;return e.set(i[n],i[n+1],i[n+2])}getWorldVertex(t,e,n,i){return this.getVertex(t,i),wm.pointToWorldFrame(e,n,i,i),i}getTriangleVertices(t,e,n,i){const r=3*t;this.getVertex(this.indices[r],e),this.getVertex(this.indices[r+1],n),this.getVertex(this.indices[r+2],i)}getNormal(t,e){const n=3*t;return e.set(this.normals[n],this.normals[n+1],this.normals[n+2])}calculateLocalInertia(t,e){this.computeLocalAABB(pg);const n=pg.upperBound.x-pg.lowerBound.x,i=pg.upperBound.y-pg.lowerBound.y,r=pg.upperBound.z-pg.lowerBound.z;return e.set(1/12*t*(4*i*i+4*r*r),1/12*t*(4*n*n+4*r*r),1/12*t*(4*i*i+4*n*n))}computeLocalAABB(t){const e=t.lowerBound,n=t.upperBound,i=this.vertices.length;this.vertices;const r=vg;this.getVertex(0,r),e.copy(r),n.copy(r);for(let t=0;t!==i;t++)this.getVertex(t,r),r.x<e.x?e.x=r.x:r.x>n.x&&(n.x=r.x),r.y<e.y?e.y=r.y:r.y>n.y&&(n.y=r.y),r.z<e.z?e.z=r.z:r.z>n.z&&(n.z=r.z)}updateAABB(){this.computeLocalAABB(this.aabb)}updateBoundingSphereRadius(){let t=0;const e=this.vertices,n=new sm;for(let i=0,r=e.length/3;i!==r;i++){this.getVertex(i,n);const e=n.lengthSquared();e>t&&(t=e)}this.boundingSphereRadius=Math.sqrt(t)}calculateWorldAABB(t,e,n,i){const r=yg,s=mg;r.position=t,r.quaternion=e,this.aabb.toWorldFrame(r,s),n.copy(s.lowerBound),i.copy(s.upperBound)}volume(){return 4*Math.PI*this.boundingSphereRadius/3}static createTorus(t,e,n,i,r){void 0===t&&(t=1),void 0===e&&(e=.5),void 0===n&&(n=8),void 0===i&&(i=6),void 0===r&&(r=2*Math.PI);const s=[],o=[];for(let o=0;o<=n;o++)for(let a=0;a<=i;a++){const u=a/i*r,h=o/n*Math.PI*2,l=(t+e*Math.cos(h))*Math.cos(u),c=(t+e*Math.cos(h))*Math.sin(u),f=e*Math.sin(h);s.push(l,c,f)}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*t+e-1,r=(i+1)*(t-1)+e-1,s=(i+1)*(t-1)+e,a=(i+1)*t+e;o.push(n,r,a),o.push(r,s,a)}return new rg(s,o)}}const sg=new sm,og=new hm,ag=new sm,ug=new sm,hg=new sm,lg=new sm,cg=new sm,fg=new sm,dg=new sm,pg=new hm,vg=new sm,yg=new wm,mg=new hm;class wg{constructor(){this.equations=[]}solve(t,e){return 0}addEquation(t){!t.enabled||t.bi.isTrigger||t.bj.isTrigger||this.equations.push(t)}removeEquation(t){const e=this.equations,n=e.indexOf(t);-1!==n&&e.splice(n,1)}removeAllEquations(){this.equations.length=0}}class gg extends wg{constructor(){super(),this.iterations=10,this.tolerance=1e-7}solve(t,e){let n=0;const i=this.iterations,r=this.tolerance*this.tolerance,s=this.equations,o=s.length,a=e.bodies,u=a.length,h=t;let l,c,f,d,p,v;if(0!==o)for(let t=0;t!==u;t++)a[t].updateSolveMassProperties();const y=xg,m=_g,w=bg;y.length=o,m.length=o,w.length=o;for(let t=0;t!==o;t++){const e=s[t];w[t]=0,m[t]=e.computeB(h),y[t]=1/e.computeC()}if(0!==o){for(let t=0;t!==u;t++){const e=a[t],n=e.vlambda,i=e.wlambda;n.set(0,0,0),i.set(0,0,0)}for(n=0;n!==i;n++){d=0;for(let t=0;t!==o;t++){const e=s[t];l=m[t],c=y[t],v=w[t],p=e.computeGWlambda(),f=c*(l-p-e.eps*v),v+f<e.minForce?f=e.minForce-v:v+f>e.maxForce&&(f=e.maxForce-v),w[t]+=f,d+=f>0?f:-f,e.addToWlambda(f)}if(d*d<r)break}for(let t=0;t!==u;t++){const e=a[t],n=e.velocity,i=e.angularVelocity;e.vlambda.vmul(e.linearFactor,e.vlambda),n.vadd(e.vlambda,n),e.wlambda.vmul(e.angularFactor,e.wlambda),i.vadd(e.wlambda,i)}let t=s.length;const e=1/h;for(;t--;)s[t].multiplier=w[t]*e}return n}}const bg=[],xg=[],_g=[];Cm.STATIC;class kg{constructor(){this.objects=[],this.type=Object}release(){const t=arguments.length;for(let e=0;e!==t;e++)this.objects.push(e<0||arguments.length<=e?void 0:arguments[e]);return this}get(){return 0===this.objects.length?this.constructObject():this.objects.pop()}constructObject(){throw new Error("constructObject() not implemented in this Pool subclass yet!")}resize(t){const e=this.objects;for(;e.length>t;)e.pop();for(;e.length<t;)e.push(this.constructObject());return this}}class $g extends kg{constructor(){super(...arguments),this.type=sm}constructObject(){return new sm}}const Sg=mm.types.SPHERE,Mg=mm.types.SPHERE|mm.types.PLANE,Eg=mm.types.BOX|mm.types.BOX,Cg=mm.types.SPHERE|mm.types.BOX,Ag=mm.types.PLANE|mm.types.BOX,Ig=mm.types.CONVEXPOLYHEDRON,Og=mm.types.SPHERE|mm.types.CONVEXPOLYHEDRON,Tg=mm.types.PLANE|mm.types.CONVEXPOLYHEDRON,zg=mm.types.BOX|mm.types.CONVEXPOLYHEDRON,Dg=mm.types.SPHERE|mm.types.HEIGHTFIELD,Pg=mm.types.BOX|mm.types.HEIGHTFIELD,Rg=mm.types.CONVEXPOLYHEDRON|mm.types.HEIGHTFIELD,Ng=mm.types.PARTICLE|mm.types.SPHERE,Fg=mm.types.PLANE|mm.types.PARTICLE,Ug=mm.types.BOX|mm.types.PARTICLE,qg=mm.types.PARTICLE|mm.types.CONVEXPOLYHEDRON,jg=mm.types.CYLINDER,Bg=mm.types.SPHERE|mm.types.CYLINDER,Lg=mm.types.PLANE|mm.types.CYLINDER,Hg=mm.types.BOX|mm.types.CYLINDER,Vg=mm.types.CONVEXPOLYHEDRON|mm.types.CYLINDER,Wg=mm.types.HEIGHTFIELD|mm.types.CYLINDER,Gg=mm.types.PARTICLE|mm.types.CYLINDER,Qg=mm.types.SPHERE|mm.types.TRIMESH,Kg=mm.types.PLANE|mm.types.TRIMESH;class Xg{get[Sg](){return this.sphereSphere}get[Mg](){return this.spherePlane}get[Eg](){return this.boxBox}get[Cg](){return this.sphereBox}get[Ag](){return this.planeBox}get[Ig](){return this.convexConvex}get[Og](){return this.sphereConvex}get[Tg](){return this.planeConvex}get[zg](){return this.boxConvex}get[Dg](){return this.sphereHeightfield}get[Pg](){return this.boxHeightfield}get[Rg](){return this.convexHeightfield}get[Ng](){return this.sphereParticle}get[Fg](){return this.planeParticle}get[Ug](){return this.boxParticle}get[qg](){return this.convexParticle}get[jg](){return this.convexConvex}get[Bg](){return this.sphereConvex}get[Lg](){return this.planeConvex}get[Hg](){return this.boxConvex}get[Vg](){return this.convexConvex}get[Wg](){return this.heightfieldCylinder}get[Gg](){return this.particleCylinder}get[Qg](){return this.sphereTrimesh}get[Kg](){return this.planeTrimesh}constructor(t){this.contactPointPool=[],this.frictionEquationPool=[],this.result=[],this.frictionResult=[],this.v3pool=new $g,this.world=t,this.currentContactMaterial=t.defaultContactMaterial,this.enableFrictionReduction=!1}createContactEquation(t,e,n,i,r,s){let o;this.contactPointPool.length?(o=this.contactPointPool.pop(),o.bi=t,o.bj=e):o=new qw(t,e),o.enabled=t.collisionResponse&&e.collisionResponse&&n.collisionResponse&&i.collisionResponse;const a=this.currentContactMaterial;o.restitution=a.restitution,o.setSpookParams(a.contactEquationStiffness,a.contactEquationRelaxation,this.world.dt);const u=n.material||t.material,h=i.material||e.material;return u&&h&&u.restitution>=0&&h.restitution>=0&&(o.restitution=u.restitution*h.restitution),o.si=r||n,o.sj=s||i,o}createFrictionEquationsFromContact(t,e){const n=t.bi,i=t.bj,r=t.si,s=t.sj,o=this.world,a=this.currentContactMaterial;let u=a.friction;const h=r.material||n.material,l=s.material||i.material;if(h&&l&&h.friction>=0&&l.friction>=0&&(u=h.friction*l.friction),u>0){const r=u*(o.frictionGravity||o.gravity).length();let s=n.invMass+i.invMass;s>0&&(s=1/s);const h=this.frictionEquationPool,l=h.length?h.pop():new Kw(n,i,r*s),c=h.length?h.pop():new Kw(n,i,r*s);return l.bi=c.bi=n,l.bj=c.bj=i,l.minForce=c.minForce=-r*s,l.maxForce=c.maxForce=r*s,l.ri.copy(t.ri),l.rj.copy(t.rj),c.ri.copy(t.ri),c.rj.copy(t.rj),t.ni.tangents(l.t,c.t),l.setSpookParams(a.frictionEquationStiffness,a.frictionEquationRelaxation,o.dt),c.setSpookParams(a.frictionEquationStiffness,a.frictionEquationRelaxation,o.dt),l.enabled=c.enabled=t.enabled,e.push(l,c),!0}return!1}createFrictionFromAverage(t){let e=this.result[this.result.length-1];if(!this.createFrictionEquationsFromContact(e,this.frictionResult)||1===t)return;const n=this.frictionResult[this.frictionResult.length-2],i=this.frictionResult[this.frictionResult.length-1];Zg.setZero(),Yg.setZero(),Jg.setZero();const r=e.bi;e.bj;for(let n=0;n!==t;n++)e=this.result[this.result.length-1-n],e.bi!==r?(Zg.vadd(e.ni,Zg),Yg.vadd(e.ri,Yg),Jg.vadd(e.rj,Jg)):(Zg.vsub(e.ni,Zg),Yg.vadd(e.rj,Yg),Jg.vadd(e.ri,Jg));const s=1/t;Yg.scale(s,n.ri),Jg.scale(s,n.rj),i.ri.copy(n.ri),i.rj.copy(n.rj),Zg.normalize(),Zg.tangents(n.t,i.t)}getContacts(t,e,n,i,r,s,o){this.contactPointPool=r,this.frictionEquationPool=o,this.result=i,this.frictionResult=s;const a=nb,u=ib,h=tb,l=eb;for(let i=0,r=t.length;i!==r;i++){const r=t[i],s=e[i];let o=null;r.material&&s.material&&(o=n.getContactMaterial(r.material,s.material)||null);const c=r.type&Cm.KINEMATIC&&s.type&Cm.STATIC||r.type&Cm.STATIC&&s.type&Cm.KINEMATIC||r.type&Cm.KINEMATIC&&s.type&Cm.KINEMATIC;for(let t=0;t<r.shapes.length;t++){r.quaternion.mult(r.shapeOrientations[t],a),r.quaternion.vmult(r.shapeOffsets[t],h),h.vadd(r.position,h);const e=r.shapes[t];for(let t=0;t<s.shapes.length;t++){s.quaternion.mult(s.shapeOrientations[t],u),s.quaternion.vmult(s.shapeOffsets[t],l),l.vadd(s.position,l);const i=s.shapes[t];if(!(e.collisionFilterMask&i.collisionFilterGroup&&i.collisionFilterMask&e.collisionFilterGroup))continue;if(h.distanceTo(l)>e.boundingSphereRadius+i.boundingSphereRadius)continue;let f=null;e.material&&i.material&&(f=n.getContactMaterial(e.material,i.material)||null),this.currentContactMaterial=f||o||n.defaultContactMaterial;const d=this[e.type|i.type];if(d){let t=!1;t=e.type<i.type?d.call(this,e,i,h,l,a,u,r,s,e,i,c):d.call(this,i,e,l,h,u,a,s,r,e,i,c),t&&c&&(n.shapeOverlapKeeper.set(e.id,i.id),n.bodyOverlapKeeper.set(r.id,s.id))}}}}}sphereSphere(t,e,n,i,r,s,o,a,u,h,l){if(l)return n.distanceSquared(i)<(t.radius+e.radius)**2;const c=this.createContactEquation(o,a,t,e,u,h);i.vsub(n,c.ni),c.ni.normalize(),c.ri.copy(c.ni),c.rj.copy(c.ni),c.ri.scale(t.radius,c.ri),c.rj.scale(-e.radius,c.rj),c.ri.vadd(n,c.ri),c.ri.vsub(o.position,c.ri),c.rj.vadd(i,c.rj),c.rj.vsub(a.position,c.rj),this.result.push(c),this.createFrictionEquationsFromContact(c,this.frictionResult)}spherePlane(t,e,n,i,r,s,o,a,u,h,l){const c=this.createContactEquation(o,a,t,e,u,h);if(c.ni.set(0,0,1),s.vmult(c.ni,c.ni),c.ni.negate(c.ni),c.ni.normalize(),c.ni.scale(t.radius,c.ri),n.vsub(i,_b),c.ni.scale(c.ni.dot(_b),kb),_b.vsub(kb,c.rj),-_b.dot(c.ni)<=t.radius){if(l)return!0;const t=c.ri,e=c.rj;t.vadd(n,t),t.vsub(o.position,t),e.vadd(i,e),e.vsub(a.position,e),this.result.push(c),this.createFrictionEquationsFromContact(c,this.frictionResult)}}boxBox(t,e,n,i,r,s,o,a,u,h,l){return t.convexPolyhedronRepresentation.material=t.material,e.convexPolyhedronRepresentation.material=e.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexConvex(t.convexPolyhedronRepresentation,e.convexPolyhedronRepresentation,n,i,r,s,o,a,t,e,l)}sphereBox(t,e,n,i,r,s,o,a,u,h,l){const c=this.v3pool,f=Tb;n.vsub(i,Cb),e.getSideNormals(f,s);const d=t.radius;let p=!1;const v=Db,y=Pb,m=Rb;let w=null,g=0,b=0,x=0,_=null;for(let t=0,e=f.length;t!==e&&!1===p;t++){const e=Ab;e.copy(f[t]);const n=e.length();e.normalize();const i=Cb.dot(e);if(i<n+d&&i>0){const r=Ib,s=Ob;r.copy(f[(t+1)%3]),s.copy(f[(t+2)%3]);const o=r.length(),a=s.length();r.normalize(),s.normalize();const u=Cb.dot(r),h=Cb.dot(s);if(u<o&&u>-o&&h<a&&h>-a){const t=Math.abs(i-n-d);if((null===_||t<_)&&(_=t,b=u,x=h,w=n,v.copy(e),y.copy(r),m.copy(s),g++,l))return!0}}}if(g){p=!0;const r=this.createContactEquation(o,a,t,e,u,h);v.scale(-d,r.ri),r.ni.copy(v),r.ni.negate(r.ni),v.scale(w,v),y.scale(b,y),v.vadd(y,v),m.scale(x,m),v.vadd(m,r.rj),r.ri.vadd(n,r.ri),r.ri.vsub(o.position,r.ri),r.rj.vadd(i,r.rj),r.rj.vsub(a.position,r.rj),this.result.push(r),this.createFrictionEquationsFromContact(r,this.frictionResult)}let k=c.get();const $=zb;for(let r=0;2!==r&&!p;r++)for(let s=0;2!==s&&!p;s++)for(let c=0;2!==c&&!p;c++)if(k.set(0,0,0),r?k.vadd(f[0],k):k.vsub(f[0],k),s?k.vadd(f[1],k):k.vsub(f[1],k),c?k.vadd(f[2],k):k.vsub(f[2],k),i.vadd(k,$),$.vsub(n,$),$.lengthSquared()<d*d){if(l)return!0;p=!0;const r=this.createContactEquation(o,a,t,e,u,h);r.ri.copy($),r.ri.normalize(),r.ni.copy(r.ri),r.ri.scale(d,r.ri),r.rj.copy(k),r.ri.vadd(n,r.ri),r.ri.vsub(o.position,r.ri),r.rj.vadd(i,r.rj),r.rj.vsub(a.position,r.rj),this.result.push(r),this.createFrictionEquationsFromContact(r,this.frictionResult)}c.release(k),k=null;const S=c.get(),M=c.get(),E=c.get(),C=c.get(),A=c.get(),I=f.length;for(let r=0;r!==I&&!p;r++)for(let s=0;s!==I&&!p;s++)if(r%3!=s%3){f[s].cross(f[r],S),S.normalize(),f[r].vadd(f[s],M),E.copy(n),E.vsub(M,E),E.vsub(i,E);const c=E.dot(S);S.scale(c,C);let v=0;for(;v===r%3||v===s%3;)v++;A.copy(n),A.vsub(C,A),A.vsub(M,A),A.vsub(i,A);const y=Math.abs(c),m=A.length();if(y<f[v].length()&&m<d){if(l)return!0;p=!0;const r=this.createContactEquation(o,a,t,e,u,h);M.vadd(C,r.rj),r.rj.copy(r.rj),A.negate(r.ni),r.ni.normalize(),r.ri.copy(r.rj),r.ri.vadd(i,r.ri),r.ri.vsub(n,r.ri),r.ri.normalize(),r.ri.scale(d,r.ri),r.ri.vadd(n,r.ri),r.ri.vsub(o.position,r.ri),r.rj.vadd(i,r.rj),r.rj.vsub(a.position,r.rj),this.result.push(r),this.createFrictionEquationsFromContact(r,this.frictionResult)}}c.release(S,M,E,C,A)}planeBox(t,e,n,i,r,s,o,a,u,h,l){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,e.convexPolyhedronRepresentation.id=e.id,this.planeConvex(t,e.convexPolyhedronRepresentation,n,i,r,s,o,a,t,e,l)}convexConvex(t,e,n,i,r,s,o,a,u,h,l,c,f){const d=Zb;if(!(n.distanceTo(i)>t.boundingSphereRadius+e.boundingSphereRadius)&&t.findSeparatingAxis(e,n,r,i,s,d,c,f)){const c=[],f=Yb;t.clipAgainstHull(n,r,e,i,s,d,-100,100,c);let p=0;for(let r=0;r!==c.length;r++){if(l)return!0;const s=this.createContactEquation(o,a,t,e,u,h),v=s.ri,y=s.rj;d.negate(s.ni),c[r].normal.negate(f),f.scale(c[r].depth,f),c[r].point.vadd(f,v),y.copy(c[r].point),v.vsub(n,v),y.vsub(i,y),v.vadd(n,v),v.vsub(o.position,v),y.vadd(i,y),y.vsub(a.position,y),this.result.push(s),p++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(s,this.frictionResult)}this.enableFrictionReduction&&p&&this.createFrictionFromAverage(p)}}sphereConvex(t,e,n,i,r,s,o,a,u,h,l){const c=this.v3pool;n.vsub(i,Nb);const f=e.faceNormals,d=e.faces,p=e.vertices,v=t.radius;let y=!1;for(let r=0;r!==p.length;r++){const c=p[r],f=jb;s.vmult(c,f),i.vadd(f,f);const d=qb;if(f.vsub(n,d),d.lengthSquared()<v*v){if(l)return!0;y=!0;const r=this.createContactEquation(o,a,t,e,u,h);return r.ri.copy(d),r.ri.normalize(),r.ni.copy(r.ri),r.ri.scale(v,r.ri),f.vsub(i,r.rj),r.ri.vadd(n,r.ri),r.ri.vsub(o.position,r.ri),r.rj.vadd(i,r.rj),r.rj.vsub(a.position,r.rj),this.result.push(r),void this.createFrictionEquationsFromContact(r,this.frictionResult)}}for(let r=0,m=d.length;r!==m&&!1===y;r++){const m=f[r],w=d[r],g=Bb;s.vmult(m,g);const b=Lb;s.vmult(p[w[0]],b),b.vadd(i,b);const x=Hb;g.scale(-v,x),n.vadd(x,x);const _=Vb;x.vsub(b,_);const k=_.dot(g),$=Wb;if(n.vsub(b,$),k<0&&$.dot(g)>0){const r=[];for(let t=0,e=w.length;t!==e;t++){const e=c.get();s.vmult(p[w[t]],e),i.vadd(e,e),r.push(e)}if(Eb(r,g,n)){if(l)return!0;y=!0;const s=this.createContactEquation(o,a,t,e,u,h);g.scale(-v,s.ri),g.negate(s.ni);const f=c.get();g.scale(-k,f);const d=c.get();g.scale(-v,d),n.vsub(i,s.rj),s.rj.vadd(d,s.rj),s.rj.vadd(f,s.rj),s.rj.vadd(i,s.rj),s.rj.vsub(a.position,s.rj),s.ri.vadd(n,s.ri),s.ri.vsub(o.position,s.ri),c.release(f),c.release(d),this.result.push(s),this.createFrictionEquationsFromContact(s,this.frictionResult);for(let t=0,e=r.length;t!==e;t++)c.release(r[t]);return}for(let f=0;f!==w.length;f++){const d=c.get(),y=c.get();s.vmult(p[w[(f+1)%w.length]],d),s.vmult(p[w[(f+2)%w.length]],y),i.vadd(d,d),i.vadd(y,y);const m=Fb;y.vsub(d,m);const g=Ub;m.unit(g);const b=c.get(),x=c.get();n.vsub(d,x);const _=x.dot(g);g.scale(_,b),b.vadd(d,b);const k=c.get();if(b.vsub(n,k),_>0&&_*_<m.lengthSquared()&&k.lengthSquared()<v*v){if(l)return!0;const s=this.createContactEquation(o,a,t,e,u,h);b.vsub(i,s.rj),b.vsub(n,s.ni),s.ni.normalize(),s.ni.scale(v,s.ri),s.rj.vadd(i,s.rj),s.rj.vsub(a.position,s.rj),s.ri.vadd(n,s.ri),s.ri.vsub(o.position,s.ri),this.result.push(s),this.createFrictionEquationsFromContact(s,this.frictionResult);for(let t=0,e=r.length;t!==e;t++)c.release(r[t]);return c.release(d),c.release(y),c.release(b),c.release(k),void c.release(x)}c.release(d),c.release(y),c.release(b),c.release(k),c.release(x)}for(let t=0,e=r.length;t!==e;t++)c.release(r[t])}}}planeConvex(t,e,n,i,r,s,o,a,u,h,l){const c=Gb,f=Qb;f.set(0,0,1),r.vmult(f,f);let d=0;const p=Kb;for(let r=0;r!==e.vertices.length;r++)if(c.copy(e.vertices[r]),s.vmult(c,c),i.vadd(c,c),c.vsub(n,p),f.dot(p)<=0){if(l)return!0;const r=this.createContactEquation(o,a,t,e,u,h),s=Xb;f.scale(f.dot(p),s),c.vsub(s,s),s.vsub(n,r.ri),r.ni.copy(f),c.vsub(i,r.rj),r.ri.vadd(n,r.ri),r.ri.vsub(o.position,r.ri),r.rj.vadd(i,r.rj),r.rj.vsub(a.position,r.rj),this.result.push(r),d++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(r,this.frictionResult)}this.enableFrictionReduction&&d&&this.createFrictionFromAverage(d)}boxConvex(t,e,n,i,r,s,o,a,u,h,l){return t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexConvex(t.convexPolyhedronRepresentation,e,n,i,r,s,o,a,t,e,l)}sphereHeightfield(t,e,n,i,r,s,o,a,u,h,l){const c=e.data,f=t.radius,d=e.elementSize,p=fx,v=cx;wm.pointToLocalFrame(i,s,n,v);let y=Math.floor((v.x-f)/d)-1,m=Math.ceil((v.x+f)/d)+1,w=Math.floor((v.y-f)/d)-1,g=Math.ceil((v.y+f)/d)+1;if(m<0||g<0||y>c.length||w>c[0].length)return;y<0&&(y=0),m<0&&(m=0),w<0&&(w=0),g<0&&(g=0),y>=c.length&&(y=c.length-1),m>=c.length&&(m=c.length-1),g>=c[0].length&&(g=c[0].length-1),w>=c[0].length&&(w=c[0].length-1);const b=[];e.getRectMinMax(y,w,m,g,b);const x=b[0],_=b[1];if(v.z-f>_||v.z+f<x)return;const k=this.result;for(let u=y;u<m;u++)for(let h=w;h<g;h++){const c=k.length;let f=!1;if(e.getConvexTrianglePillar(u,h,!1),wm.pointToWorldFrame(i,s,e.pillarOffset,p),n.distanceTo(p)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&(f=this.sphereConvex(t,e.pillarConvex,n,p,r,s,o,a,t,e,l)),l&&f)return!0;if(e.getConvexTrianglePillar(u,h,!0),wm.pointToWorldFrame(i,s,e.pillarOffset,p),n.distanceTo(p)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&(f=this.sphereConvex(t,e.pillarConvex,n,p,r,s,o,a,t,e,l)),l&&f)return!0;if(k.length-c>2)return}}boxHeightfield(t,e,n,i,r,s,o,a,u,h,l){return t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexHeightfield(t.convexPolyhedronRepresentation,e,n,i,r,s,o,a,t,e,l)}convexHeightfield(t,e,n,i,r,s,o,a,u,h,l){const c=e.data,f=e.elementSize,d=t.boundingSphereRadius,p=hx,v=lx,y=ux;wm.pointToLocalFrame(i,s,n,y);let m=Math.floor((y.x-d)/f)-1,w=Math.ceil((y.x+d)/f)+1,g=Math.floor((y.y-d)/f)-1,b=Math.ceil((y.y+d)/f)+1;if(w<0||b<0||m>c.length||g>c[0].length)return;m<0&&(m=0),w<0&&(w=0),g<0&&(g=0),b<0&&(b=0),m>=c.length&&(m=c.length-1),w>=c.length&&(w=c.length-1),b>=c[0].length&&(b=c[0].length-1),g>=c[0].length&&(g=c[0].length-1);const x=[];e.getRectMinMax(m,g,w,b,x);const _=x[0],k=x[1];if(!(y.z-d>k||y.z+d<_))for(let u=m;u<w;u++)for(let h=g;h<b;h++){let c=!1;if(e.getConvexTrianglePillar(u,h,!1),wm.pointToWorldFrame(i,s,e.pillarOffset,p),n.distanceTo(p)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&(c=this.convexConvex(t,e.pillarConvex,n,p,r,s,o,a,null,null,l,v,null)),l&&c)return!0;if(e.getConvexTrianglePillar(u,h,!0),wm.pointToWorldFrame(i,s,e.pillarOffset,p),n.distanceTo(p)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&(c=this.convexConvex(t,e.pillarConvex,n,p,r,s,o,a,null,null,l,v,null)),l&&c)return!0}}sphereParticle(t,e,n,i,r,s,o,a,u,h,l){const c=nx;if(c.set(0,0,1),i.vsub(n,c),c.lengthSquared()<=t.radius*t.radius){if(l)return!0;const n=this.createContactEquation(a,o,e,t,u,h);c.normalize(),n.rj.copy(c),n.rj.scale(t.radius,n.rj),n.ni.copy(c),n.ni.negate(n.ni),n.ri.set(0,0,0),this.result.push(n),this.createFrictionEquationsFromContact(n,this.frictionResult)}}planeParticle(t,e,n,i,r,s,o,a,u,h,l){const c=Jb;c.set(0,0,1),o.quaternion.vmult(c,c);const f=tx;if(i.vsub(o.position,f),c.dot(f)<=0){if(l)return!0;const n=this.createContactEquation(a,o,e,t,u,h);n.ni.copy(c),n.ni.negate(n.ni),n.ri.set(0,0,0);const r=ex;c.scale(c.dot(i),r),i.vsub(r,r),n.rj.copy(r),this.result.push(n),this.createFrictionEquationsFromContact(n,this.frictionResult)}}boxParticle(t,e,n,i,r,s,o,a,u,h,l){return t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexParticle(t.convexPolyhedronRepresentation,e,n,i,r,s,o,a,t,e,l)}convexParticle(t,e,n,i,r,s,o,a,u,h,l){let c=-1;const f=sx,d=ax;let p=null;const v=rx;if(v.copy(i),v.vsub(n,v),r.conjugate(ix),ix.vmult(v,v),t.pointIsInside(v)){t.worldVerticesNeedsUpdate&&t.computeWorldVertices(n,r),t.worldFaceNormalsNeedsUpdate&&t.computeWorldFaceNormals(r);for(let e=0,n=t.faces.length;e!==n;e++){const n=[t.worldVertices[t.faces[e][0]]],r=t.worldFaceNormals[e];i.vsub(n[0],ox);const s=-r.dot(ox);if(null===p||Math.abs(s)<Math.abs(p)){if(l)return!0;p=s,c=e,f.copy(r)}}if(-1!==c){const r=this.createContactEquation(a,o,e,t,u,h);f.scale(p,d),d.vadd(i,d),d.vsub(n,d),r.rj.copy(d),f.negate(r.ni),r.ri.set(0,0,0);const s=r.ri,l=r.rj;s.vadd(i,s),s.vsub(a.position,s),l.vadd(n,l),l.vsub(o.position,l),this.result.push(r),this.createFrictionEquationsFromContact(r,this.frictionResult)}}}heightfieldCylinder(t,e,n,i,r,s,o,a,u,h,l){return this.convexHeightfield(e,t,i,n,s,r,a,o,u,h,l)}particleCylinder(t,e,n,i,r,s,o,a,u,h,l){return this.convexParticle(e,t,i,n,s,r,a,o,u,h,l)}sphereTrimesh(t,e,n,i,r,s,o,a,u,h,l){const c=cb,f=fb,d=db,p=pb,v=vb,y=yb,m=bb,w=lb,g=ub,b=xb;wm.pointToLocalFrame(i,s,n,v);const x=t.radius;m.lowerBound.set(v.x-x,v.y-x,v.z-x),m.upperBound.set(v.x+x,v.y+x,v.z+x),e.getTrianglesInAABB(m,b);const _=hb,k=t.radius*t.radius;for(let r=0;r<b.length;r++)for(let c=0;c<3;c++)if(e.getVertex(e.indices[3*b[r]+c],_),_.vsub(v,g),g.lengthSquared()<=k){if(w.copy(_),wm.pointToWorldFrame(i,s,w,_),_.vsub(n,g),l)return!0;let r=this.createContactEquation(o,a,t,e,u,h);r.ni.copy(g),r.ni.normalize(),r.ri.copy(r.ni),r.ri.scale(t.radius,r.ri),r.ri.vadd(n,r.ri),r.ri.vsub(o.position,r.ri),r.rj.copy(_),r.rj.vsub(a.position,r.rj),this.result.push(r),this.createFrictionEquationsFromContact(r,this.frictionResult)}for(let r=0;r<b.length;r++)for(let m=0;m<3;m++){e.getVertex(e.indices[3*b[r]+m],c),e.getVertex(e.indices[3*b[r]+(m+1)%3],f),f.vsub(c,d),v.vsub(f,y);const w=y.dot(d);v.vsub(c,y);let g=y.dot(d);if(g>0&&w<0&&(v.vsub(c,y),p.copy(d),p.normalize(),g=y.dot(p),p.scale(g,y),y.vadd(c,y),y.distanceTo(v)<t.radius)){if(l)return!0;const r=this.createContactEquation(o,a,t,e,u,h);y.vsub(v,r.ni),r.ni.normalize(),r.ni.scale(t.radius,r.ri),r.ri.vadd(n,r.ri),r.ri.vsub(o.position,r.ri),wm.pointToWorldFrame(i,s,y,y),y.vsub(a.position,r.rj),wm.vectorToWorldFrame(s,r.ni,r.ni),wm.vectorToWorldFrame(s,r.ri,r.ri),this.result.push(r),this.createFrictionEquationsFromContact(r,this.frictionResult)}}const $=mb,S=wb,M=gb,E=ab;for(let r=0,c=b.length;r!==c;r++){e.getTriangleVertices(b[r],$,S,M),e.getNormal(b[r],E),v.vsub($,y);let c=y.dot(E);if(E.scale(c,y),v.vsub(y,y),c=y.distanceTo(v),nw.pointInTriangle(y,$,S,M)&&c<t.radius){if(l)return!0;let r=this.createContactEquation(o,a,t,e,u,h);y.vsub(v,r.ni),r.ni.normalize(),r.ni.scale(t.radius,r.ri),r.ri.vadd(n,r.ri),r.ri.vsub(o.position,r.ri),wm.pointToWorldFrame(i,s,y,y),y.vsub(a.position,r.rj),wm.vectorToWorldFrame(s,r.ni,r.ni),wm.vectorToWorldFrame(s,r.ri,r.ri),this.result.push(r),this.createFrictionEquationsFromContact(r,this.frictionResult)}}b.length=0}planeTrimesh(t,e,n,i,r,s,o,a,u,h,l){const c=new sm,f=rb;f.set(0,0,1),r.vmult(f,f);for(let r=0;r<e.vertices.length/3;r++){e.getVertex(r,c);const d=new sm;d.copy(c),wm.pointToWorldFrame(i,s,d,c);const p=sb;if(c.vsub(n,p),f.dot(p)<=0){if(l)return!0;const n=this.createContactEquation(o,a,t,e,u,h);n.ni.copy(f);const i=ob;f.scale(p.dot(f),i),c.vsub(i,i),n.ri.copy(i),n.ri.vsub(o.position,n.ri),n.rj.copy(c),n.rj.vsub(a.position,n.rj),this.result.push(n),this.createFrictionEquationsFromContact(n,this.frictionResult)}}}}const Zg=new sm,Yg=new sm,Jg=new sm,tb=new sm,eb=new sm,nb=new pm,ib=new pm,rb=new sm,sb=new sm,ob=new sm,ab=new sm,ub=new sm;new sm;const hb=new sm,lb=new sm,cb=new sm,fb=new sm,db=new sm,pb=new sm,vb=new sm,yb=new sm,mb=new sm,wb=new sm,gb=new sm,bb=new hm,xb=[],_b=new sm,kb=new sm,$b=new sm,Sb=new sm,Mb=new sm;function Eb(t,e,n){let i=null;const r=t.length;for(let s=0;s!==r;s++){const o=t[s],a=$b;t[(s+1)%r].vsub(o,a);const u=Sb;a.cross(e,u);const h=Mb;n.vsub(o,h);const l=u.dot(h);if(!(null===i||l>0&&!0===i||l<=0&&!1===i))return!1;null===i&&(i=l>0)}return!0}const Cb=new sm,Ab=new sm,Ib=new sm,Ob=new sm,Tb=[new sm,new sm,new sm,new sm,new sm,new sm],zb=new sm,Db=new sm,Pb=new sm,Rb=new sm,Nb=new sm,Fb=new sm,Ub=new sm,qb=new sm,jb=new sm,Bb=new sm,Lb=new sm,Hb=new sm,Vb=new sm,Wb=new sm;new sm,new sm;const Gb=new sm,Qb=new sm,Kb=new sm,Xb=new sm,Zb=new sm,Yb=new sm,Jb=new sm,tx=new sm,ex=new sm,nx=new sm,ix=new pm,rx=new sm;new sm;const sx=new sm,ox=new sm,ax=new sm,ux=new sm,hx=new sm,lx=[0],cx=new sm,fx=new sm;class dx{constructor(){this.current=[],this.previous=[]}getKey(t,e){if(e<t){const n=e;e=t,t=n}return t<<16|e}set(t,e){const n=this.getKey(t,e),i=this.current;let r=0;for(;n>i[r];)r++;if(n!==i[r]){for(let t=i.length-1;t>=r;t--)i[t+1]=i[t];i[r]=n}}tick(){const t=this.current;this.current=this.previous,this.previous=t,this.current.length=0}getDiff(t,e){const n=this.current,i=this.previous,r=n.length,s=i.length;let o=0;for(let e=0;e<r;e++){let r=!1;const s=n[e];for(;s>i[o];)o++;r=s===i[o],r||px(t,s)}o=0;for(let t=0;t<s;t++){let r=!1;const s=i[t];for(;s>n[o];)o++;r=n[o]===s,r||px(e,s)}}}function px(t,e){t.push((4294901760&e)>>16,65535&e)}const vx=(t,e)=>t<e?`${t}-${e}`:`${e}-${t}`;class yx{constructor(){this.data={keys:[]}}get(t,e){const n=vx(t,e);return this.data[n]}set(t,e,n){const i=vx(t,e);this.get(t,e)||this.data.keys.push(i),this.data[i]=n}delete(t,e){const n=vx(t,e),i=this.data.keys.indexOf(n);-1!==i&&this.data.keys.splice(i,1),delete this.data[n]}reset(){const t=this.data,e=t.keys;for(;e.length>0;)delete t[e.pop()]}}class mx extends dm{constructor(t){void 0===t&&(t={}),super(),this.dt=-1,this.allowSleep=!!t.allowSleep,this.contacts=[],this.frictionEquations=[],this.quatNormalizeSkip=void 0!==t.quatNormalizeSkip?t.quatNormalizeSkip:0,this.quatNormalizeFast=void 0!==t.quatNormalizeFast&&t.quatNormalizeFast,this.time=0,this.stepnumber=0,this.default_dt=1/60,this.nextId=0,this.gravity=new sm,t.gravity&&this.gravity.copy(t.gravity),t.frictionGravity&&(this.frictionGravity=new sm,this.frictionGravity.copy(t.frictionGravity)),this.broadphase=void 0!==t.broadphase?t.broadphase:new Gm,this.bodies=[],this.hasActiveBodies=!1,this.solver=void 0!==t.solver?t.solver:new gg,this.constraints=[],this.narrowphase=new Xg(this),this.collisionMatrix=new fm,this.collisionMatrixPrevious=new fm,this.bodyOverlapKeeper=new dx,this.shapeOverlapKeeper=new dx,this.contactmaterials=[],this.contactMaterialTable=new yx,this.defaultMaterial=new Jw("default"),this.defaultContactMaterial=new Yw(this.defaultMaterial,this.defaultMaterial,{friction:.3,restitution:0}),this.doProfiling=!1,this.profile={solve:0,makeContactConstraints:0,broadphase:0,integrate:0,narrowphase:0},this.accumulator=0,this.subsystems=[],this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.idToBodyMap={},this.broadphase.setWorld(this)}getContactMaterial(t,e){return this.contactMaterialTable.get(t.id,e.id)}collisionMatrixTick(){const t=this.collisionMatrixPrevious;this.collisionMatrixPrevious=this.collisionMatrix,this.collisionMatrix=t,this.collisionMatrix.reset(),this.bodyOverlapKeeper.tick(),this.shapeOverlapKeeper.tick()}addConstraint(t){this.constraints.push(t)}removeConstraint(t){const e=this.constraints.indexOf(t);-1!==e&&this.constraints.splice(e,1)}rayTest(t,e,n){n instanceof Qm?this.raycastClosest(t,e,{skipBackfaces:!0},n):this.raycastAll(t,e,{skipBackfaces:!0},n)}raycastAll(t,e,n,i){return void 0===n&&(n={}),n.mode=nw.ALL,n.from=t,n.to=e,n.callback=i,wx.intersectWorld(this,n)}raycastAny(t,e,n,i){return void 0===n&&(n={}),n.mode=nw.ANY,n.from=t,n.to=e,n.result=i,wx.intersectWorld(this,n)}raycastClosest(t,e,n,i){return void 0===n&&(n={}),n.mode=nw.CLOSEST,n.from=t,n.to=e,n.result=i,wx.intersectWorld(this,n)}addBody(t){this.bodies.includes(t)||(t.index=this.bodies.length,this.bodies.push(t),t.world=this,t.initPosition.copy(t.position),t.initVelocity.copy(t.velocity),t.timeLastSleepy=this.time,t instanceof Cm&&(t.initAngularVelocity.copy(t.angularVelocity),t.initQuaternion.copy(t.quaternion)),this.collisionMatrix.setNumObjects(this.bodies.length),this.addBodyEvent.body=t,this.idToBodyMap[t.id]=t,this.dispatchEvent(this.addBodyEvent))}removeBody(t){t.world=null;const e=this.bodies.length-1,n=this.bodies,i=n.indexOf(t);if(-1!==i){n.splice(i,1);for(let t=0;t!==n.length;t++)n[t].index=t;this.collisionMatrix.setNumObjects(e),this.removeBodyEvent.body=t,delete this.idToBodyMap[t.id],this.dispatchEvent(this.removeBodyEvent)}}getBodyById(t){return this.idToBodyMap[t]}getShapeById(t){const e=this.bodies;for(let n=0;n<e.length;n++){const i=e[n].shapes;for(let e=0;e<i.length;e++){const n=i[e];if(n.id===t)return n}}return null}addContactMaterial(t){this.contactmaterials.push(t),this.contactMaterialTable.set(t.materials[0].id,t.materials[1].id,t)}removeContactMaterial(t){const e=this.contactmaterials.indexOf(t);-1!==e&&(this.contactmaterials.splice(e,1),this.contactMaterialTable.delete(t.materials[0].id,t.materials[1].id))}fixedStep(t,e){void 0===t&&(t=1/60),void 0===e&&(e=10);const n=gx.now()/1e3;if(this.lastCallTime){const i=n-this.lastCallTime;this.step(t,i,e)}else this.step(t,void 0,e);this.lastCallTime=n}step(t,e,n){if(void 0===n&&(n=10),void 0===e)this.internalStep(t),this.time+=t;else{this.accumulator+=e;const i=gx.now();let r=0;for(;this.accumulator>=t&&r<n&&(this.internalStep(t),this.accumulator-=t,r++,!(gx.now()-i>1e3*t)););this.accumulator=this.accumulator%t;const s=this.accumulator/t;for(let t=0;t!==this.bodies.length;t++){const e=this.bodies[t];e.previousPosition.lerp(e.position,s,e.interpolatedPosition),e.previousQuaternion.slerp(e.quaternion,s,e.interpolatedQuaternion),e.previousQuaternion.normalize()}this.time+=e}}internalStep(t){this.dt=t;const e=this.contacts,n=Sx,i=Mx,r=this.bodies.length,s=this.bodies,o=this.solver,a=this.gravity,u=this.doProfiling,h=this.profile,l=Cm.DYNAMIC;let c=-1/0;const f=this.constraints,d=$x;a.length();const p=a.x,v=a.y,y=a.z;let m=0;for(u&&(c=gx.now()),m=0;m!==r;m++){const t=s[m];if(t.type===l){const e=t.force,n=t.mass;e.x+=n*p,e.y+=n*v,e.z+=n*y}}for(let t=0,e=this.subsystems.length;t!==e;t++)this.subsystems[t].update();u&&(c=gx.now()),n.length=0,i.length=0,this.broadphase.collisionPairs(this,n,i),u&&(h.broadphase=gx.now()-c);let w=f.length;for(m=0;m!==w;m++){const t=f[m];if(!t.collideConnected)for(let e=n.length-1;e>=0;e-=1)(t.bodyA===n[e]&&t.bodyB===i[e]||t.bodyB===n[e]&&t.bodyA===i[e])&&(n.splice(e,1),i.splice(e,1))}this.collisionMatrixTick(),u&&(c=gx.now());const g=kx,b=e.length;for(m=0;m!==b;m++)g.push(e[m]);e.length=0;const x=this.frictionEquations.length;for(m=0;m!==x;m++)d.push(this.frictionEquations[m]);for(this.frictionEquations.length=0,this.narrowphase.getContacts(n,i,this,e,g,this.frictionEquations,d),u&&(h.narrowphase=gx.now()-c),u&&(c=gx.now()),m=0;m<this.frictionEquations.length;m++)o.addEquation(this.frictionEquations[m]);const _=e.length;for(let t=0;t!==_;t++){const n=e[t],i=n.bi,r=n.bj,s=n.si,a=n.sj;let u;u=i.material&&r.material&&this.getContactMaterial(i.material,r.material)||this.defaultContactMaterial,u.friction,i.material&&r.material&&(i.material.friction>=0&&r.material.friction>=0&&(i.material.friction,r.material.friction),i.material.restitution>=0&&r.material.restitution>=0&&(n.restitution=i.material.restitution*r.material.restitution)),o.addEquation(n),i.allowSleep&&i.type===Cm.DYNAMIC&&i.sleepState===Cm.SLEEPING&&r.sleepState===Cm.AWAKE&&r.type!==Cm.STATIC&&r.velocity.lengthSquared()+r.angularVelocity.lengthSquared()>=2*r.sleepSpeedLimit**2&&(i.wakeUpAfterNarrowphase=!0),r.allowSleep&&r.type===Cm.DYNAMIC&&r.sleepState===Cm.SLEEPING&&i.sleepState===Cm.AWAKE&&i.type!==Cm.STATIC&&i.velocity.lengthSquared()+i.angularVelocity.lengthSquared()>=2*i.sleepSpeedLimit**2&&(r.wakeUpAfterNarrowphase=!0),this.collisionMatrix.set(i,r,!0),this.collisionMatrixPrevious.get(i,r)||(_x.body=r,_x.contact=n,i.dispatchEvent(_x),_x.body=i,r.dispatchEvent(_x)),this.bodyOverlapKeeper.set(i.id,r.id),this.shapeOverlapKeeper.set(s.id,a.id)}for(this.emitContactEvents(),u&&(h.makeContactConstraints=gx.now()-c,c=gx.now()),m=0;m!==r;m++){const t=s[m];t.wakeUpAfterNarrowphase&&(t.wakeUp(),t.wakeUpAfterNarrowphase=!1)}for(w=f.length,m=0;m!==w;m++){const t=f[m];t.update();for(let e=0,n=t.equations.length;e!==n;e++){const n=t.equations[e];o.addEquation(n)}}o.solve(t,this),u&&(h.solve=gx.now()-c),o.removeAllEquations();const k=Math.pow;for(m=0;m!==r;m++){const e=s[m];if(e.type&l){const n=k(1-e.linearDamping,t),i=e.velocity;i.scale(n,i);const r=e.angularVelocity;if(r){const n=k(1-e.angularDamping,t);r.scale(n,r)}}}this.dispatchEvent(xx),u&&(c=gx.now());const $=this.stepnumber%(this.quatNormalizeSkip+1)==0,S=this.quatNormalizeFast;for(m=0;m!==r;m++)s[m].integrate(t,$,S);this.clearForces(),this.broadphase.dirty=!0,u&&(h.integrate=gx.now()-c),this.stepnumber+=1,this.dispatchEvent(bx);let M=!0;if(this.allowSleep)for(M=!1,m=0;m!==r;m++){const t=s[m];t.sleepTick(this.time),t.sleepState!==Cm.SLEEPING&&(M=!0)}this.hasActiveBodies=M}emitContactEvents(){const t=this.hasAnyEventListener("beginContact"),e=this.hasAnyEventListener("endContact");if((t||e)&&this.bodyOverlapKeeper.getDiff(Ex,Cx),t){for(let t=0,e=Ex.length;t<e;t+=2)Ax.bodyA=this.getBodyById(Ex[t]),Ax.bodyB=this.getBodyById(Ex[t+1]),this.dispatchEvent(Ax);Ax.bodyA=Ax.bodyB=null}if(e){for(let t=0,e=Cx.length;t<e;t+=2)Ix.bodyA=this.getBodyById(Cx[t]),Ix.bodyB=this.getBodyById(Cx[t+1]),this.dispatchEvent(Ix);Ix.bodyA=Ix.bodyB=null}Ex.length=Cx.length=0;const n=this.hasAnyEventListener("beginShapeContact"),i=this.hasAnyEventListener("endShapeContact");if((n||i)&&this.shapeOverlapKeeper.getDiff(Ex,Cx),n){for(let t=0,e=Ex.length;t<e;t+=2){const e=this.getShapeById(Ex[t]),n=this.getShapeById(Ex[t+1]);Ox.shapeA=e,Ox.shapeB=n,e&&(Ox.bodyA=e.body),n&&(Ox.bodyB=n.body),this.dispatchEvent(Ox)}Ox.bodyA=Ox.bodyB=Ox.shapeA=Ox.shapeB=null}if(i){for(let t=0,e=Cx.length;t<e;t+=2){const e=this.getShapeById(Cx[t]),n=this.getShapeById(Cx[t+1]);Tx.shapeA=e,Tx.shapeB=n,e&&(Tx.bodyA=e.body),n&&(Tx.bodyB=n.body),this.dispatchEvent(Tx)}Tx.bodyA=Tx.bodyB=Tx.shapeA=Tx.shapeB=null}}clearForces(){const t=this.bodies,e=t.length;for(let n=0;n!==e;n++){const e=t[n];e.force,e.torque,e.force.set(0,0,0),e.torque.set(0,0,0)}}}new hm;const wx=new nw,gx=globalThis.performance||{};if(!gx.now){let t=Date.now();gx.timing&&gx.timing.navigationStart&&(t=gx.timing.navigationStart),gx.now=()=>Date.now()-t}new sm;const bx={type:"postStep"},xx={type:"preStep"},_x={type:Cm.COLLIDE_EVENT_NAME,body:null,contact:null},kx=[],$x=[],Sx=[],Mx=[],Ex=[],Cx=[],Ax={type:"beginContact",bodyA:null,bodyB:null},Ix={type:"endContact",bodyA:null,bodyB:null},Ox={type:"beginShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null},Tx={type:"endShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null};function zx(t,e,n,i,r){let s;if(r===function(t,e,n,i){let r=0;for(let s=e,o=n-i;s<n;s+=i)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}(t,e,n,i)>0)for(let r=e;r<n;r+=i)s=e_(r/i|0,t[r],t[r+1],s);else for(let r=n-i;r>=e;r-=i)s=e_(r/i|0,t[r],t[r+1],s);return s&&Kx(s,s.next)&&(n_(s),s=s.next),s}function Dx(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!Kx(i,i.next)&&0!==Qx(i.prev,i,i.next))i=i.next;else{if(n_(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function Px(t,e,n,i,r,s,o){if(!t)return;!o&&s&&function(t,e,n,i){let r=t;do{0===r.z&&(r.z=Lx(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,n=1;do{let i,r=t;t=null;let s=null;for(e=0;r;){e++;let o=r,a=0;for(let t=0;t<n&&(a++,o=o.nextZ,o);t++);let u=n;for(;a>0||u>0&&o;)0!==a&&(0===u||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,u--),s?s.nextZ=i:t=i,i.prevZ=s,s=i;r=o}s.nextZ=null,n*=2}while(e>1)}(r)}(t,i,r,s);let a=t;for(;t.prev!==t.next;){const u=t.prev,h=t.next;if(s?Nx(t,i,r,s):Rx(t))e.push(u.i,t.i,h.i),n_(t),t=h.next,a=h.next;else if((t=h)===a){o?1===o?Px(t=Fx(Dx(t),e),e,n,i,r,s,2):2===o&&Ux(t,e,n,i,r,s):Px(Dx(t),e,n,i,r,s,1);break}}}function Rx(t){const e=t.prev,n=t,i=t.next;if(Qx(e,n,i)>=0)return!1;const r=e.x,s=n.x,o=i.x,a=e.y,u=n.y,h=i.y,l=Math.min(r,s,o),c=Math.min(a,u,h),f=Math.max(r,s,o),d=Math.max(a,u,h);let p=i.next;for(;p!==e;){if(p.x>=l&&p.x<=f&&p.y>=c&&p.y<=d&&Wx(r,a,s,u,o,h,p.x,p.y)&&Qx(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Nx(t,e,n,i){const r=t.prev,s=t,o=t.next;if(Qx(r,s,o)>=0)return!1;const a=r.x,u=s.x,h=o.x,l=r.y,c=s.y,f=o.y,d=Math.min(a,u,h),p=Math.min(l,c,f),v=Math.max(a,u,h),y=Math.max(l,c,f),m=Lx(d,p,e,n,i),w=Lx(v,y,e,n,i);let g=t.prevZ,b=t.nextZ;for(;g&&g.z>=m&&b&&b.z<=w;){if(g.x>=d&&g.x<=v&&g.y>=p&&g.y<=y&&g!==r&&g!==o&&Wx(a,l,u,c,h,f,g.x,g.y)&&Qx(g.prev,g,g.next)>=0)return!1;if(g=g.prevZ,b.x>=d&&b.x<=v&&b.y>=p&&b.y<=y&&b!==r&&b!==o&&Wx(a,l,u,c,h,f,b.x,b.y)&&Qx(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;g&&g.z>=m;){if(g.x>=d&&g.x<=v&&g.y>=p&&g.y<=y&&g!==r&&g!==o&&Wx(a,l,u,c,h,f,g.x,g.y)&&Qx(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;b&&b.z<=w;){if(b.x>=d&&b.x<=v&&b.y>=p&&b.y<=y&&b!==r&&b!==o&&Wx(a,l,u,c,h,f,b.x,b.y)&&Qx(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Fx(t,e){let n=t;do{const i=n.prev,r=n.next.next;!Kx(i,r)&&Xx(i,n,n.next,r)&&Jx(i,r)&&Jx(r,i)&&(e.push(i.i,n.i,r.i),n_(n),n_(n.next),n=t=r),n=n.next}while(n!==t);return Dx(n)}function Ux(t,e,n,i,r,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Gx(o,t)){let a=t_(o,t);return o=Dx(o,o.next),a=Dx(a,a.next),Px(o,e,n,i,r,s,0),void Px(a,e,n,i,r,s,0)}t=t.next}o=o.next}while(o!==t)}function qx(t,e){let n=t.x-e.x;return 0===n&&(n=t.y-e.y,0===n)&&(n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),n}function jx(t,e){const n=function(t,e){let n=e;const i=t.x,r=t.y;let s,o=-1/0;if(Kx(t,n))return n;do{if(Kx(t,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const t=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=i&&t>o&&(o=t,s=n.x<n.next.x?n:n.next,t===i))return s}n=n.next}while(n!==e);if(!s)return null;const a=s,u=s.x,h=s.y;let l=1/0;n=s;do{if(i>=n.x&&n.x>=u&&i!==n.x&&Vx(r<h?i:o,r,u,h,r<h?o:i,r,n.x,n.y)){const e=Math.abs(r-n.y)/(i-n.x);Jx(n,t)&&(e<l||e===l&&(n.x>s.x||n.x===s.x&&Bx(s,n)))&&(s=n,l=e)}n=n.next}while(n!==a);return s}(t,e);if(!n)return e;const i=t_(n,t);return Dx(i,i.next),Dx(n,n.next)}function Bx(t,e){return Qx(t.prev,t,e.prev)<0&&Qx(e.next,t,t.next)<0}function Lx(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Hx(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function Vx(t,e,n,i,r,s,o,a){return(r-o)*(e-a)>=(t-o)*(s-a)&&(t-o)*(i-a)>=(n-o)*(e-a)&&(n-o)*(s-a)>=(r-o)*(i-a)}function Wx(t,e,n,i,r,s,o,a){return!(t===o&&e===a)&&Vx(t,e,n,i,r,s,o,a)}function Gx(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Xx(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Jx(t,e)&&Jx(e,t)&&function(t,e){let n=t,i=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(Qx(t.prev,t,e.prev)||Qx(t,e.prev,e))||Kx(t,e)&&Qx(t.prev,t,t.next)>0&&Qx(e.prev,e,e.next)>0)}function Qx(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Kx(t,e){return t.x===e.x&&t.y===e.y}function Xx(t,e,n,i){const r=Yx(Qx(t,e,n)),s=Yx(Qx(t,e,i)),o=Yx(Qx(n,i,t)),a=Yx(Qx(n,i,e));return r!==s&&o!==a||!(0!==r||!Zx(t,n,e))||!(0!==s||!Zx(t,i,e))||!(0!==o||!Zx(n,t,i))||!(0!==a||!Zx(n,e,i))}function Zx(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Yx(t){return t>0?1:t<0?-1:0}function Jx(t,e){return Qx(t.prev,t,t.next)<0?Qx(t,e,t.next)>=0&&Qx(t,t.prev,e)>=0:Qx(t,e,t.prev)<0||Qx(t,t.next,e)<0}function t_(t,e){const n=i_(t.i,t.x,t.y),i=i_(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function e_(t,e,n,i){const r=i_(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function n_(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function i_(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}const r_=function(t,e){var n,i,r=t[0],s=t[1],o=e[0],a=e[1],u=o[0],h=o[1],l=a[0],c=a[1],f=l-u,d=c-h,p=0===f&&0===d?0:(f*(r-u)+d*(s-h))/(f*f+d*d||0);return p<=0?(n=u,i=h):p>=1?(n=l,i=c):(n=u+p*f,i=h+p*d),[n,i]},s_=function(t,e){return((t[0]-e[0])**2+(t[1]-e[1])**2)**.5},o_=function(t,e){let n=1/0;for(let i=0,r=1,s=e.length;r<s;i=r,r+=1){const s=r_(t,[e[i],e[r]]);n=Math.min(n,s_(s,t))}return n},a_=function(t,e){var n=1/0;let i;for(let r=0,s=1,o=e.length;s<o;r=s,s+=1){let o=r_(t,[e[r],e[s]]);const a=s_(o,t);a<n&&(n=a,i=o)}return i},u_=function(t,e){var n=1/0;let i;for(let r=0;r<e.length;r+=1){const s=e[r];for(let e=0,r=1,o=s.length;r<o;e=r,r+=1){let o=r_(t,[s[e],s[r]]);const a=s_(o,t);a<n&&(n=a,i=o)}}return i},h_=t=>{const e=[0,0],n=[0,0];let i=0;const r=t[0],s=t.length;for(let o=2;o<s;o++){const s=t[o-1],a=t[o];e[0]=r[0]-a[0],e[1]=r[1]-a[1],n[0]=r[0]-s[0],n[1]=r[1]-s[1],i+=e[0]*n[1]-e[1]*n[0]}return i/2},l_=function(t,e){var n=1/0;let i;for(let r=0;r<e.length;r+=1){const s=e[r];let o=u_(t,s);const a=s_(o,t);a<n&&(n=a,i=o)}return i},c_=(t,e,n=!1)=>{const i=t[0],r=t[1];let s,o,a,u,h=!1;const l=e.length;for(let t=0,c=l-1;t<l;c=t,t+=1){let l=!1;if(s=e[t][0],o=e[t][1],a=e[c][0],u=e[c][1],s===i&&o===r||a===i&&u===r)return!!n;if(o<r==u>=r){const t=(a-s)*(r-o)/(u-o)+s;if(i===t)return!!n;l=i<t}l&&(h=!h)}return h},f_=(t,e,n=!1)=>!!c_(t,e[0],n)&&!e.slice(1).find((e=>c_(t,e,!n))),d_=(t,e,n=!1)=>!!e.find((e=>f_(t,e,n))),p_=(t,e)=>{let n=0;if(t[0]===e[0])n=t[1]>e[1]?Math.PI:0;else if(t[1]===e[1])n=t[0]>e[0]?Math.PI/2:-Math.PI/2;else{const i=t[0]-e[0],r=t[1]-e[1];n=Math.atan(i/r),i>0&&r>0?n=Math.PI-n:i<0&&r<0||i>0&&r<0?n=-n:i<0&&r>0&&(n=Math.PI-n)}return n},v_=(t,e,n=0)=>{if(!e)return[];n%=e;const i=[0],r=t.length;for(let e=1;e<r;e+=1){const n=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];i[e]=i[e-1]+(n**2+r**2)**.5}const s=[];let o=0;for(let a=1;a<r;a+=1)if(i[a]-n-o*e>=e-1e-8){let r=i[a]-n-e*o;const u=Math.floor((r+1e-8)/e);o+=u,r=i[a]-n-e*o;const h=p_(t[a-1],t[a]);for(let n=0;n<u;n+=1){const o=(r+e*(u-1-n))/(i[a]-i[a-1]),l=[t[a][0]-o*(t[a][0]-t[a-1][0]),t[a][1]-o*(t[a][1]-t[a-1][1]),void 0!==t[a][2]?t[a][2]-o*(t[a][2]-t[a-1][2]):0,h];s.push(l)}}return s},y_=t=>{const e=t.length;let n=0;const i=t[e-1];let r,s,o,a=i[0],u=i[1];for(let i=0;i<e;i+=1)o=t[i],r=o[0],s=o[1],n+=(r-a)*(s+u),a=r,u=s;return n>0};function m_(t,n,i,r){const s=e.Cartesian3.subtract(i,n,new e.Cartesian3),o=e.Cartesian3.subtract(r,n,new e.Cartesian3),a=e.Cartesian3.subtract(t,n,new e.Cartesian3),u=e.Cartesian3.dot(s,a),h=e.Cartesian3.dot(o,a);if(u<=0&&h<=0)return e.Cartesian3.clone(n);const l=e.Cartesian3.subtract(t,i,new e.Cartesian3),c=e.Cartesian3.dot(s,l),f=e.Cartesian3.dot(o,l);if(c>=0&&f<=c)return e.Cartesian3.clone(i);const d=u*f-c*h;if(d<=0&&u>=0&&c<=0){const t=u/(u-c);return e.Cartesian3.add(n,e.Cartesian3.multiplyByScalar(s,t,new e.Cartesian3),new e.Cartesian3)}const p=e.Cartesian3.subtract(t,r,new e.Cartesian3),v=e.Cartesian3.dot(s,p),y=e.Cartesian3.dot(o,p);if(y>=0&&v<=y)return e.Cartesian3.clone(r);const m=v*h-u*y;if(m<=0&&h>=0&&y<=0){const t=h/(h-y);return e.Cartesian3.add(n,e.Cartesian3.multiplyByScalar(o,t,new e.Cartesian3),new e.Cartesian3)}const w=c*y-v*f;if(w<=0&&f-c>=0&&v-y>=0){const t=(f-c)/(f-c+(v-y));return e.Cartesian3.add(i,e.Cartesian3.multiplyByScalar(e.Cartesian3.subtract(r,i,new e.Cartesian3),t,new e.Cartesian3),new e.Cartesian3)}const g=1/(w+m+d),b=m*g,x=d*g;return e.Cartesian3.add(n,e.Cartesian3.add(e.Cartesian3.multiplyByScalar(s,b,new e.Cartesian3),e.Cartesian3.multiplyByScalar(o,x,new e.Cartesian3),new e.Cartesian3),new e.Cartesian3)}function w_(t,n,i){let r=null,s=1/0;const o=new e.Cartesian3,a=new e.Cartesian3,u=new e.Cartesian3;for(let h=0;h<i.length;h+=3){o.x=n[3*i[h]],o.y=n[3*i[h]+1],o.z=n[3*i[h]+2],a.x=n[3*i[h+1]],a.y=n[3*i[h+1]+1],a.z=n[3*i[h+1]+2],u.x=n[3*i[h+2]],u.y=n[3*i[h+2]+1],u.z=n[3*i[h+2]+2];const l=m_(t,o,a,u),c=e.Cartesian3.distance(t,l);c<s&&(s=c,r=l)}return{point:r,distance:s}}var g_={distance:s_,distanceToLineString:o_,closestOnSegment:r_,closestOnLineString:a_,closestOnMultiLineString:u_,closestOnMultiPolygon:l_,buff:(t,e)=>{const n=9e-6,i=t.map((t=>{const e=t.map((t=>[t[0]*n,t[1]*n])),i=e.length;return e[0][0]===e[i-1][0]&&e[0][1]===e[i-1][1]||e.push(e[0]),e})),r=Vd(function(t,e,n={}){for(const e of t){if(e.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(e[e.length-1].length!==e[0].length)throw new Error("First and last Position are not equivalent.");for(let t=0;t<e[e.length-1].length;t++)if(e[e.length-1][t]!==e[0][t])throw new Error("First and last Position are not equivalent.")}return lf({type:"Polygon",coordinates:t},e,n)}(i),e/1e3,{units:"kilometers",steps:1});if(r)return"MultiPolygon"==r.geometry.type?r.geometry.coordinates.map(((t,e)=>t.map((t=>t.map((t=>[t[0]/n,t[1]/n])))))):[r.geometry.coordinates.map((t=>t.map((t=>[t[0]/n,t[1]/n]))))]},inMultiPolygon:d_,inPolygon:f_,contain:c_,dividePathByUnit:v_,isClockwise:y_,closestPointOnMesh:w_,ringArea2D:h_};const b_={distance:s_,distanceToLineString:o_,closestOnSegment:r_,closestOnLineString:a_,closestOnMultiLineString:u_,closestOnMultiPolygon:l_,pointInMultiPolygon:d_,pointInPolygon:f_,pointInRing:c_,dividePathByUnit:v_,isClockwise:y_,closestPointOnMesh:w_,ringArea2D:h_};var x_=2*Math.PI;class __{Wn;Rp;Np;Fp;Up;qp;jp;Bp;Lp;Hp;Vp;Wp=0;fe;Gp;Qp;Kp;Xp;Zp;Yp;Jp;tv;Vn;ev;nv=0;constructor(t,e,n){this.ev=n;var i=void 0===(e=e||{}).title?"joystick":e.title,r=void 0===e.width?0:e.width,s=void 0===e.height?0:e.height;this.Gp=void 0===e.internalFillColor?"rgba(255,255,255,0.4)":e.internalFillColor,this.Qp=void 0===e.internalLineWidth?2:e.internalLineWidth,this.Kp=void 0===e.internalStrokeColor?"rgba(255,255,255,0.6)":e.internalStrokeColor,this.Xp=void 0===e.externalLineWidth?2:e.externalLineWidth,this.Zp=void 0===e.externalStrokeColor?"rgba(255,255,255,0.3)":e.externalStrokeColor,this.Yp=void 0===e.autoReturnToCenter||e.autoReturnToCenter;var o=t;o.style.touchAction="none";var a=document.createElement("canvas");this.Wn=a,a.style.width="100%",a.id=i,0===r&&(r=o.clientWidth),0===s&&(s=o.clientHeight),a.width=r,a.height=s,o.appendChild(a),this.Vn=t,this.fe=a.getContext("2d"),this.Jp=a.width/4-12,this.qp=this.Jp+20,this.tv=this.Jp+30,this.Fp=a.width/2,this.Up=a.height/2,this.Lp=a.width/10,this.Hp=-1*this.Lp,this.jp=a.height/10,this.Bp=-1*this.jp,this.Rp=this.Fp,this.Np=this.Up,this.Vn.style.display="none",this.iv(),this.rv(),this.Vp=null,this.sv=this.sv.bind(this),this.ov=this.ov.bind(this),this.av=this.av.bind(this),this.uv=this.uv.bind(this),this.hv=this.hv.bind(this),this.lv=this.lv.bind(this)}iv=()=>{this.fe.beginPath(),this.fe.arc(this.Fp,this.Up,this.tv,0,x_,!1),this.fe.shadowBlur=5,this.fe.shadowColor="white",this.fe.lineWidth=this.Xp,this.fe.strokeStyle=this.Zp,this.fe.stroke()};rv=()=>{this.fe.beginPath();const t=this.Rp-this.Fp,e=this.Np-this.Up,n=(t**2+e**2)**.5;if(n>this.qp){const i=this.qp/n;this.Rp=i*t+this.Fp,this.Np=i*e+this.Up}this.fe.arc(this.Rp,this.Np,this.Jp,0,x_,!1);var i=this.fe.createRadialGradient(this.Fp,this.Up,5,this.Fp,this.Up,200);i.addColorStop(0,this.Gp),i.addColorStop(1,this.Kp),this.fe.shadowBlur=5,this.fe.shadowColor="white",this.fe.fillStyle=i,this.fe.fill(),this.fe.lineWidth=this.Qp,this.fe.strokeStyle=this.Kp,this.fe.stroke()};uv(t){0==this.Wp&&1==t.touches.length&&(this.Wp=1)}hv(t){1===this.Wp&&1==t.touches.length&&(this.Rp=t.touches[0].pageX,this.Np=t.touches[0].pageY,"BODY"===this.Wn.offsetParent.tagName.toUpperCase()?(this.Rp-=this.Wn.offsetLeft,this.Np-=this.Wn.offsetTop):(this.Rp-=this.Wn.offsetParent.offsetLeft,this.Np-=this.Wn.offsetParent.offsetTop),this.fe.clearRect(0,0,this.Wn.width,this.Wn.height),this.iv(),this.rv())}lv(t){t.touches[0]||(this.Wp=0,this.Yp&&(this.Rp=this.Fp,this.Np=this.Up),this.fe.clearRect(0,0,this.Wn.width,this.Wn.height),this.iv(),this.rv())}sv(t){t.stopPropagation(),this.Wp=1}ov(t){1===this.Wp&&(t.stopPropagation(),this.Rp=t.pageX,this.Np=t.pageY,"BODY"===this.Wn.offsetParent.tagName.toUpperCase()?(this.Rp-=this.Wn.offsetLeft,this.Np-=this.Wn.offsetTop):(this.Rp-=this.Wn.offsetParent.offsetLeft,this.Np-=this.Wn.offsetParent.offsetTop),this.fe.clearRect(0,0,this.Wn.width,this.Wn.height),this.iv(),this.rv())}av(t){this.Wp=0,this.Yp&&(this.Rp=this.Fp,this.Np=this.Up),this.fe.clearRect(0,0,this.Wn.width,this.Wn.height),this.iv(),this.rv()}open(){"ontouchstart"in document.documentElement?(this.Wn.addEventListener("touchstart",this.uv,!0),document.addEventListener("touchmove",this.hv,!0),document.addEventListener("touchend",this.lv,!0)):(this.Wn.addEventListener("mousedown",this.sv,!0),document.addEventListener("mousemove",this.ov,!0),document.addEventListener("mouseup",this.av,!0)),this.Vn.style.display="block",this.nv=window.setInterval((()=>{this.ev({x:this.GetX(),y:this.GetY()})}),50)}close(){"ontouchstart"in document.documentElement?(this.Wn.removeEventListener("touchstart",this.uv),document.removeEventListener("touchmove",this.hv),document.removeEventListener("touchend",this.lv)):(this.Wn.removeEventListener("mousedown",this.sv),document.removeEventListener("mousemove",this.ov),document.removeEventListener("mouseup",this.av)),this.Vn.style.display="none",clearInterval(this.nv),this.nv=0}getCardinalDirection(){let t="",e=this.Rp-this.Fp,n=this.Np-this.Up;return n>=this.Bp&&n<=this.jp&&(t="C"),n<this.Bp&&(t="N"),n>this.jp&&(t="S"),e<this.Hp&&("C"===t?t="W":t+="W"),e>this.Lp&&("C"===t?t="E":t+="E"),t}GetWidth(){return this.Wn.width}GetHeight(){return this.Wn.height}GetPosX(){return this.Rp}GetPosY(){return this.Np}GetX(){return parseFloat(((this.Rp-this.Fp)/this.qp*100).toFixed())}GetY(){return parseFloat(((this.Np-this.Up)/this.qp*100*-1).toFixed())}GetDir(){return this.getCardinalDirection()}}class k_{Es="closed";co;Jc;Lf;cv=new e.Cartesian2;fv=new e.Cartesian2;md;rf;dv;pv;Qo;vv;yv=!1;mv={};xf=[];wv=0;kf=0;gv=1;Yn=!1;bv;xv;sf=0;_v=0;kv=-10;$v;Sv;Mv;Ev;Cv;constructor(t){t.isIndoor?this.Qo=new rf(1,1,.1):this.Qo=new rf(1,1,.01),t.buffer=t.buffer||.2,t.speed=t.speed||1,t.steeringSpeed=t.steeringSpeed||10,t.lookingMode=t.lookingMode||"scene",t.fixSpeedByHeight=null==t.fixSpeedByHeight||t.fixSpeedByHeight,t.isIndoor&&(t.fixSpeedByHeight=!1),this.co=t,this.yv="fixedLine"===t.lookingMode,this.gv=t.fixedLineMoveSpeed||1,this.yv&&t.cameraInfos&&(this.mv=t.cameraInfos,this.xf=t.cameraInfos.map((t=>t.position)),this.wv=1e3*rp({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:this.xf}},{units:"kilometers"}));const e=t.viewer.canvas;e.setAttribute("tabindex","0"),e.onclick=function(){e.focus()},this.rf=[],this.md=new r.ScreenSpaceEventHandler(e),this.uf=this.uf.bind(this),this.af=this.af.bind(this),this.hf=this.hf.bind(this),this.Av();const n=document.createElement("div");n.style.cssText="width:150px;height:150px;position:absolute;bottom:50px;left:0;border-radius:100%",this.vv=n,this.pv=new __(n,{width:150,height:150,externalLineWidth:1,internalLineWidth:1},this.Iv.bind(this));const i=this.co.yunjingLayer.xo.Cs();i?(this.Mv=i,this.Ov(i)):this.co.yunjingLayer.on("configloaded",(t=>{this.Mv=t,this.Ov(t)}))}Ov(t){const e=t.limitBounds;if(e){const t=[];var n=new mx;n.broadphase=new Gm,e?.forEach((e=>{const i=e.extrudedHeight;let r=[],s=[],o=[];if(e.perPositionHeight)s=e.path.map(((t,n)=>(g_.isClockwise(t)&&(t=t.reverse()),n&&o.push((o[o.length-1]||0)+e.path[n-1].length),t.map((t=>[t[0],t[1]])).flat()))),r=e.path.map((t=>t.map((t=>t[2]))));else{const t=e.height;s=e.path.map(((t,n)=>(g_.isClockwise(t)&&(t=t.reverse()),n&&o.push((o[o.length-1]||0)+e.path[n-1].length),t.map((t=>[t[0],t[1]])).flat()))),r=e.path.map((e=>e.map((e=>t))))}const a=s.flat();r=r.flat();const u=function(t,e,n=2){const i=e&&e.length,r=i?e[0]*n:t.length;let s=zx(t,0,r,n,!0);const o=[];if(!s||s.next===s.prev)return o;let a,u,h;if(i&&(s=function(t,e,n,i){const r=[];for(let n=0,s=e.length;n<s;n++){const o=zx(t,e[n]*i,n<s-1?e[n+1]*i:t.length,i,!1);o===o.next&&(o.steiner=!0),r.push(Hx(o))}r.sort(qx);for(let t=0;t<r.length;t++)n=jx(r[t],n);return n}(t,e,s,n)),t.length>80*n){a=1/0,u=1/0;let e=-1/0,i=-1/0;for(let s=n;s<r;s+=n){const n=t[s],r=t[s+1];n<a&&(a=n),r<u&&(u=r),n>e&&(e=n),r>i&&(i=r)}h=Math.max(e-a,i-u),h=0!==h?32767/h:0}return Px(s,o,n,a,u,h,0),o}(a,o),h=r.length,l=[],c=[];for(let t=0;t<a.length;t+=2)l.push(a[t],a[t+1],r[t/2]);for(let t=0;t<a.length;t+=2)l.push(a[t],a[t+1],r[t/2]+i);for(let t=0;t<u.length;t+=3)c.push(u[t],u[t+1],u[t+2]),c.push(u[t+2]+h,u[t+1]+h,u[t]+h);for(let t=0;t<h-1;t+=1)-1==o.indexOf(t+1)&&(null==o[0]||t<o[0]?c.push(t,t+h,t+1+h,t,t+1+h,t+1):c.push(t,t+1+h,t+h,t,t+1,t+1+h));const f=new rg(l,c);t.push({mesh:f,groundTriangles:u.length/3,extrudedHeight:i,maxz:Math.min(...r)+i,minz:Math.max(...r)});var d=new Cm({mass:1,position:new sm(0,0,0)});d.addShape(f),d.angularVelocity.set(0,0,.1),n.addBody(d)})),this.Ev={world:n,infos:t}}}Iv(t){if(this.dv,t.x||t.y){const e=r.Cartographic.fromCartesian(this.co.viewer.camera.positionWC,void 0,this.Tv);let n=.05*this.co.speed;this.co.fixSpeedByHeight&&(n*=Math.max(1.8,e.height-this.co.yunjingLayer.getBaseHeight())/2),"fixedLine"===this.co.lookingMode?(n*=t.y,this.moveByLine(t.y>0?"forward":"backward",t.y)):this.move([t.x,t.y,0],n,!0)}}Av(){}zv(){const t=this.co.yunjingLayer.Ai().map((t=>t.Gt));if(0===t.length)return;const e=new Set,n={},i=this.co.boxesSize||.5;for(var r=0;r<t.length;r++){const o=t[r],a=o.byteLength/4/3;if(a<=0)continue;const u=new Float32Array(o);for(var s=0;s<a;s+=1){const t=3*s,r=u[t],o=u[t+1],a=u[t+2],h=`${Math.floor(r/i)}_${Math.floor(o/i)}_${Math.floor(a/i)}`;e.has(h)?n[h]+=1:(e.add(h),n[h]=1)}}if(!(e.size<=0)){for(let t in n)n[t]<20&&e.delete(t);this.dv={isCode:!0,dis:i,codes:e}}}Dv(t){let e=this.Mv.enuCenter;const n={},i=[];t.forEach((t=>{const s=[(t[0]+t[3])/2,(t[1]+t[4])/2,(t[2]+t[5])/2],o=[Math.abs(t[0]-t[3])/1,Math.abs(t[1]-t[4])/1,Math.abs(t[2]-t[5])/1];let a=Dc(new r.Cartesian3(...s),e),u=Pc(a);const h=`${Math.round(t[0]/5)}_${Math.round(t[1]/5)}`,l={bbox:t,center:u,alt:t[5],ecef:a,size:o,radius:Math.sqrt(o[0]*o[0]+o[1]*o[1]+o[2]*o[2])/2};n[h]?n[h].push(l):n[h]=[l],i.push(l)}));const s=[],o=i.length;for(let t=0;t<o;t++){const{center:e,size:n,alt:o}=i[t],a=new r.Cartesian3(...n),u=r.Matrix4.multiplyByTranslation(r.Transforms.eastNorthUpToFixedFrame(r.Cartesian3.fromDegrees(e.lng,e.lat,e.height)),new r.Cartesian3(0,0,0),new r.Matrix4),h=new r.GeometryInstance({geometry:r.BoxGeometry.fromDimensions({vertexFormat:r.VertexFormat.POSITION_AND_NORMAL,dimensions:a}),modelMatrix:u,attributes:{color:r.ColorGeometryInstanceAttribute.fromColor(new r.Color(1,(150-Math.min(150,o))/150,(150-Math.min(150,o))/150,.6))}});s.push(h)}this.co.viewer.scene.primitives.add(new r.Primitive({geometryInstances:s,appearance:new r.PerInstanceColorAppearance({translucent:!0,closed:!0,renderState:{depthTest:{enabled:!0}}})}))}static nf=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","KeyA","KeyS","KeyD","KeyW","KeyQ","KeyE"];open(){if("openning"==this.Es)return;this.Es="openning";const t=this.co.viewer,n=t.scene;n.screenSpaceCameraController.enableRotate=!1,n.screenSpaceCameraController.enableTranslate=!1,n.screenSpaceCameraController.enableZoom=!1,n.screenSpaceCameraController.enableLook=!1,n.screenSpaceCameraController.Pv/=3,this.cv.x=this.cv.y=0,this.fv.x=this.fv.y=0,this.Lf={inertiaing:!1,looking:!1,moveForward:!1,moveBackward:!1,moveUp:!1,moveDown:!1,moveLeft:!1,moveRight:!1,dragging:!1,noObstacleAvoidance:!1};const i=this.md,s=-1!==navigator.userAgent.toLowerCase().indexOf("mobile"),o=t=>{this.Lf.inertiaing=!1,this.Lf.looking=!0,this.Lf.dragging=!1,this.fv.x=this.cv.x=t.position.x,this.fv.y=this.cv.y=t.position.y},a=()=>{this.Lf.inertiaing=!1,this.Lf.looking=!1,this.Lf.dragging=!1,this.Jc=void 0},u=t=>{this.Lf.inertiaing=!1,this.Lf.dragging=!0,this.Lf.looking=!1,this.fv.x=this.cv.x=t.position.x,this.fv.y=this.cv.y=t.position.y;const n=this.co.viewer.camera;let i;if(this.co.isIndoor)i=new e.Cartesian3(0,0,-1.5);else{const t=r.Cartographic.fromCartesian(n.positionWC,void 0,this.Tv);i=new e.Cartesian3(0,0,-(t.height-this.co.yunjingLayer.getBaseHeight()))}this.Qo.No(new e.Cartesian3,i),this.bv=this.eu(this.fv),this._v=(new Date).getTime(),this.xv=void 0},h=()=>{if(this.Lf.dragging=!1,!this.co.isIndoor&&this.xv&&(new Date).getTime()-this._v<10){this.Lf.inertiaing=!0;const t=this.co.viewer.camera,n=r.Cartographic.fromCartesian(t.positionWC,void 0,this.Tv);let i=this.kv;this.co.fixSpeedByHeight&&(i*=Math.max(1.8,n.height-this.co.yunjingLayer.getBaseHeight())/2);const s=this.xv,o=e.Cartesian2.magnitude(this.xv);let a=o/Math.abs(i);a=Math.min(1,a),i=-o/a;const u=(s.x<0?-1:1)*Math.abs(s.x/o)*i,h=(s.y<0?-1:1)*Math.abs(s.y/o)*i;this.$v=u,this.Sv=h}else this.xv=void 0;this.Jc=void 0},l=t=>{(this.Lf.looking||this.Lf.dragging)&&(this.fv=r.Cartesian2.clone(t.endPosition,this.fv)),(this.Lf.dragging||this.Lf?.inertiaing)&&this.Rv()},c=this.co.viewer.camera,f=t=>{if(this.Lf.inertiaing=!1,t.distance){if(t.distance.startPosition.y===t.distance.endPosition.y)return;t=5*(t.distance.endPosition.y-t.distance.startPosition.y)}const n=r.Cartographic.fromCartesian(c.positionWC,void 0,this.Tv),i=this.Mv.enuCenter;if(!i)return;let s=(this.co.isIndoor?1.5:Math.max(1.8,n.height-this.co.yunjingLayer.getBaseHeight()))*t/1e3;const o=new r.Cartesian3,a=r.Cartesian3.multiplyByScalar(c.directionWC,s,o);r.Cartesian3.add(c.positionWC,a,o);const u=Tc(o,i,this.Nv);if(!this.Fv(u,o)){const t=this.Uv(Tc(c.positionWC,i),a,u);if(!t)return;{const n=zc(t,i);e.Cartesian3.fromRadians(n[0],n[1],n[2],void 0,o)}}c.setView({destination:o,orientation:{heading:c.heading,pitch:c.pitch,roll:0}})};i.setInputAction(f,r.ScreenSpaceEventType.WHEEL),i.setInputAction(f,r.ScreenSpaceEventType.PINCH_MOVE),i.setInputAction(f,r.ScreenSpaceEventType.WHEEL,r.KeyboardEventModifier.SHIFT),document.addEventListener("keydown",this.af,!1),document.addEventListener("keyup",this.hf,!1),this.sf=requestAnimationFrame(this.uf),s?(t._element.appendChild(this.vv),this.pv.open(),i.setInputAction(o,r.ScreenSpaceEventType.LEFT_DOWN),i.setInputAction(a,r.ScreenSpaceEventType.LEFT_UP),i.setInputAction(l,r.ScreenSpaceEventType.MOUSE_MOVE)):(i.setInputAction(o,r.ScreenSpaceEventType.RIGHT_DOWN),i.setInputAction(o,r.ScreenSpaceEventType.RIGHT_DOWN,r.KeyboardEventModifier.SHIFT),i.setInputAction(a,r.ScreenSpaceEventType.RIGHT_UP),i.setInputAction(a,r.ScreenSpaceEventType.RIGHT_UP,r.KeyboardEventModifier.SHIFT),i.setInputAction(u,r.ScreenSpaceEventType.LEFT_DOWN),i.setInputAction(u,r.ScreenSpaceEventType.LEFT_DOWN,r.KeyboardEventModifier.SHIFT),i.setInputAction(h,r.ScreenSpaceEventType.LEFT_UP),i.setInputAction(h,r.ScreenSpaceEventType.LEFT_UP,r.KeyboardEventModifier.SHIFT),i.setInputAction(l,r.ScreenSpaceEventType.MOUSE_MOVE),i.setInputAction(l,r.ScreenSpaceEventType.MOUSE_MOVE,r.KeyboardEventModifier.SHIFT),i.setInputAction((()=>{this.Lf.inertiaing=!1}),r.ScreenSpaceEventType.MIDDLE_DOWN));const d=new e.Quaternion,p=new e.Matrix3,v=new e.Cartesian3;return c.rotate=(t,n)=>{if(n){const i=this.Mv.enuCenter,s=n,o=e.Quaternion.fromAxisAngle(t,-s,d),a=e.Matrix3.fromQuaternion(o,p);e.Matrix3.multiplyByVector(a,c.position,v);const u=c._actualTransform;r.Matrix4.multiplyByPoint(u,v,v);const h=Tc(v,i,this.Nv);if(!this.Fv(h,v))return}r.Camera.prototype.rotate.call(c,t,n)},this}close(){const t=-1!==navigator.userAgent.toLowerCase().indexOf("mobile");document.removeEventListener("keydown",this.af),document.removeEventListener("keyup",this.hf),this.sf&&cancelAnimationFrame(this.sf),this.rf=[],this.Jc=void 0;const e=this.co.viewer,n=e.scene;n.screenSpaceCameraController.enableRotate=!0,n.screenSpaceCameraController.enableTranslate=!0,n.screenSpaceCameraController.enableZoom=!0,n.screenSpaceCameraController.enableTilt=!0,n.screenSpaceCameraController.enableLook=!0,n.screenSpaceCameraController.Pv*=3;const i=this.md;t?(e._element.removeChild(this.vv),this.pv.close(),i.removeInputAction(r.ScreenSpaceEventType.LEFT_DOWN),i.removeInputAction(r.ScreenSpaceEventType.LEFT_UP),i.removeInputAction(r.ScreenSpaceEventType.MOUSE_MOVE)):(i.removeInputAction(r.ScreenSpaceEventType.RIGHT_DOWN),i.removeInputAction(r.ScreenSpaceEventType.RIGHT_DOWN,r.KeyboardEventModifier.SHIFT),i.removeInputAction(r.ScreenSpaceEventType.RIGHT_UP),i.removeInputAction(r.ScreenSpaceEventType.RIGHT_UP,r.KeyboardEventModifier.SHIFT),i.removeInputAction(r.ScreenSpaceEventType.LEFT_DOWN),i.removeInputAction(r.ScreenSpaceEventType.LEFT_DOWN,r.KeyboardEventModifier.SHIFT),i.removeInputAction(r.ScreenSpaceEventType.LEFT_UP),i.removeInputAction(r.ScreenSpaceEventType.LEFT_UP,r.KeyboardEventModifier.SHIFT),i.removeInputAction(r.ScreenSpaceEventType.MOUSE_MOVE),i.removeInputAction(r.ScreenSpaceEventType.MOUSE_MOVE,r.KeyboardEventModifier.SHIFT),i.removeInputAction(r.ScreenSpaceEventType.MIDDLE_DOWN)),i.removeInputAction(r.ScreenSpaceEventType.WHEEL),i.removeInputAction(r.ScreenSpaceEventType.PINCH_MOVE),i.removeInputAction(r.ScreenSpaceEventType.WHEEL,r.KeyboardEventModifier.SHIFT),this.co.viewer.camera.rotate=r.Camera.prototype.rotate}set speed(t){this.co.speed=t||.5}af(t){if(this.Lf.inertiaing=!1,"Shift"==t.key)return void(this.Lf.noObstacleAvoidance=!0);const e={ArrowDown:"ArrowUp",ArrowUp:"ArrowDown",ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft",KeyA:"KeyD",KeyD:"KeyA",KeyS:"KeyW",KeyW:"KeyS"};if(-1!==k_.nf.indexOf(t.code)&&-1==this.rf.indexOf(t.code)){if(e[t.code]){const n=this.rf.indexOf(e[t.code]);-1!==n&&this.rf.splice(n,1)}this.rf.push(t.code)}}hf(t){if("Shift"==t.key)return void(this.Lf.noObstacleAvoidance=!1);const e=-1!==k_.nf.indexOf(t.code),n=this.rf.indexOf(t.code);e&&-1!==n&&this.rf.splice(n,1),this.Jc=void 0}qv=new r.Ray;eu(t){const n=this.co.viewer.camera,i=r.Cartographic.fromCartesian(n.positionWC,void 0,this.Tv),s=[180*i.longitude/Math.PI,180*i.latitude/Math.PI,i.height],o=n.getPickRay(t,this.qv),a=e.Cartesian3.add(o.origin,o.direction,o.origin),u=new e.Cartesian3;let h;return e.Cartesian3.normalize(Tc(a,s,a),u),h=this.co.isIndoor?new e.Cartesian3(0,0,-1.5):new e.Cartesian3(0,0,-(i.height-this.co.yunjingLayer.getBaseHeight())),this.Qo.No(new e.Cartesian3,h),this.Qo.Fo(u,!0)}Tv=new r.Cartographic;Rv(){const t=(new Date).getTime(),n=this.Mv.enuCenter;if(!this.rf.length&&!this.Lf?.looking&&this.Lf?.dragging&&n){const i=this.co.viewer.camera,s=r.Cartographic.fromCartesian(i.positionWC,void 0,this.Tv);this.cv.x=this.fv.x,this.cv.y=this.fv.y;const o=this.eu(this.fv);if(this.bv){const a=e.Cartesian3.subtract(o,this.bv,this.Nv);if(a.x||a.y){this.xv=e.Cartesian2.multiplyByScalar(a,1e3/(t-this._v),this.xv||new e.Cartesian2);const o=r.Math.toDegrees(s.longitude),u=r.Math.toDegrees(s.latitude),h=r.Cartesian3.fromElements(-a.x,-a.y,0,this.Nv);let l=new e.Cartesian3;l=Dc(h,[o,u,s.height],void 0,l);let c=Pc(l);const f=Cc([c.lng,c.lat,s.height],n);if(this.Fv(f,l))i.setView({destination:e.Cartesian3.fromDegrees(c.lng,c.lat,s.height,void 0,l),orientation:{heading:i.heading,pitch:i.pitch,roll:0}});else{const t=this.Uv(Tc(i.positionWC,n),h,f);if(t){const r=zc(t,n);i.setView({destination:e.Cartesian3.fromRadians(r[0],r[1],s.height,void 0,l),orientation:{heading:i.heading,pitch:i.pitch,roll:0}})}}}else this.xv=void 0}this.bv=o,this._v=t}}uf(){this.sf=0;const t=this.Mv?.enuCenter;if(t){const n=this.co.viewer.camera,i=r.Cartographic.fromCartesian(n.positionWC,void 0,this.Tv);if(this.rf.length||this.Lf?.looking){let s=0,o=0,a=0;if(this.rf.length){const t=(new Date).getTime();if(this.Jc&&t-this.Jc){let e=(t-this.Jc)/1e3*this.co.speed;this.co.fixSpeedByHeight&&(e*=Math.max(1.8,i.height-this.co.yunjingLayer.getBaseHeight())/2);let r=0;switch(this.rf.sort().join(",")){case"ArrowUp":case"KeyW":r=0;break;case"ArrowDown":case"KeyS":r=180;break;case"ArrowLeft":case"KeyA":r=-90;break;case"ArrowRight":case"KeyD":r=90;break;case"ArrowDown,ArrowLeft":case"KeyA,KeyS":r=-135;break;case"ArrowDown,ArrowRight":case"KeyD,KeyS":r=135;break;case"ArrowLeft,ArrowUp":case"KeyA,KeyW":r=-45;break;case"ArrowRight,ArrowUp":case"KeyD,KeyW":r=45;break;case"KeyQ":r=0,a=1;break;case"KeyE":r=0,a=-1}r=n.heading+r*Math.PI/180,s=Math.sin(r)*e,o=Math.cos(r)*e,a&&(a*=e,s=o=0)}this.Jc=t}else this.Jc=void 0;let u=0,h=0;const l=this.co.viewer.canvas,c=l.clientWidth,f=l.clientHeight,d=(this.fv.x-this.cv.x)/c,p=-(this.fv.y-this.cv.y)/f,v=30;u=d*v*Math.PI/180*2,h=p*v*Math.PI/180,"scene"==this.co.lookingMode&&(u=-u,h=-h),this.cv.x=this.fv.x,this.cv.y=this.fv.y;const y=r.Math.toDegrees(i.longitude),m=r.Math.toDegrees(i.latitude),w=new r.Cartesian3(s,o,a);let g=Dc(w,[y,m,i.height]);const b=Tc(g,t);if(!this.Fv(b,g)){const i=this.Uv(Tc(n.positionWC,t),w,b);if(i){const n=zc(i,t);e.Cartesian3.fromRadians(n[0],n[1],n[2],void 0,g)}else g.x=n.positionWC.x,g.y=n.positionWC.y,g.z=n.positionWC.z}n.setView({destination:g,orientation:{heading:n.heading+u,pitch:Math.max(-90,Math.min(this.co.yunjingLayer.getMaxPitch(),n.pitch+h)),roll:0}})}else if(this.Lf?.inertiaing&&this.xv){const s=(new Date).getTime(),o=this.xv,a=this.$v,u=this.Sv;let h;h=Math.abs(a)>Math.abs(u)?Math.abs(o.x)/Math.abs(a):Math.abs(o.y)/Math.abs(u);let l,c,f=(s-this._v)/1e3;if(f>=h&&(f=h),l=o.x*f+.5*a*f*f,c=o.y*f+.5*u*f*f,this.xv.x=o.x+a*f,this.xv.y=o.y+u*f,l||c){const s=r.Math.toDegrees(i.longitude),o=r.Math.toDegrees(i.latitude),a=r.Cartesian3.fromElements(-l,-c,0,this.Nv);let u=Dc(a,[s,o,i.height],void 0,new e.Cartesian3);const h=Tc(u,t,this.Nv);if(!this.Fv(h,u)){const i=this.Uv(Tc(n.positionWC,t),a,h);if(i){const n=zc(i,t);e.Cartesian3.fromRadians(n[0],n[1],n[2],void 0,u)}else u.x=n.positionWC.x,u.y=n.positionWC.y,u.z=n.positionWC.z}n.setView({destination:u,orientation:{heading:n.heading,pitch:n.pitch,roll:0}})}else this.Lf.inertiaing=!1,this.xv=void 0;this._v=s}}this.sf=requestAnimationFrame(this.uf)}move(t,n,i=!0){t instanceof r.Cartesian3||(t=new r.Cartesian3(t[0],t[1],t[2])),t=r.Cartesian3.normalize(t,t);const s=this.co.viewer.camera,o=r.Matrix3.fromRotationZ(-s.heading),a=this.Mv.enuCenter;r.Matrix3.multiplyByVector(o,t,t);const u=t.x*n,h=t.y*n,l=t.z*n,c=r.Cartographic.fromCartesian(s.positionWC,void 0,this.Tv),f=r.Math.toDegrees(c.longitude),d=r.Math.toDegrees(c.latitude),p=new r.Cartesian3(u,h,l);let v=Dc(p,[f,d,c.height]);const y=Tc(v,a);if(i&&!this.Fv(y,v)){const t=this.Uv(Tc(s.positionWC,a),p,y);if(!t)return;{const n=zc(t,a);e.Cartesian3.fromRadians(n[0],n[1],n[2],void 0,v)}}s.setView({destination:v,orientation:{heading:s.heading,pitch:s.pitch,roll:0}})}setMode(t){this.co.lookingMode=t,this.yv="fixedLine"===this.co.lookingMode,this.pv.open()}moveByLine(t,e){if(!this.xf||!this.yv)return;if("forward"===t){if(this.kf+=e*this.gv,this.kf=Math.min(this.kf,this.wv),this.kf===this.wv)return!0}else if(this.kf+=e*this.gv,this.kf=Math.max(this.kf,0),0===this.kf)return!0;const{position:n,rotation:i,up:s,dir:o}=this.jf(this.xf,this.kf),a=this.co.viewer.camera;if(n&&s&&o){const t=r.Cartesian3.fromDegrees(n[0],n[1],n[2]);a.flyTo({duration:0,destination:t,orientation:{up:s,direction:o}})}else if(n&&i){const t=r.Cartesian3.fromDegrees(n[0],n[1],n[2]);a.flyTo({duration:0,destination:t,orientation:i})}return!1}jv(t){if(!this.dv||this.Lf.noObstacleAvoidance)return!1;const e=this.co.buffer;if(this.dv.isCode){const n=this.dv.dis,i=Math.floor((t.x-e)/n),r=Math.floor((t.x+e)/n),s=Math.floor((t.y-e)/n),o=Math.floor((t.y+e)/n),a=Math.floor((t.z-e)/n),u=Math.floor((t.z+e)/n);for(let t=i;t<=r;t+=1)for(let e=s;e<=o;e+=1)for(let n=a;n<=u;n+=1){const i=`${t}_${e}_${n}`;if(this.dv.codes.has(i))return!0}return!1}return this.dv.find(((n,i)=>{const r=t.x;if(r>=n[0]-e&&r<=n[3]+e){const i=t.y;if(i>=n[1]-e&&i<=n[4]+e){const i=t.z;if(i>=n[2]-e&&i<=n[5]+e)return!0}}}))}Nv=new e.Cartesian3;Bv=new e.Cartesian3;Fv(t,e){const n=Tc(this.co.viewer.camera.positionWC,this.Mv.enuCenter,this.Bv),i=this.Ev;if(i){if(this.Lf.noObstacleAvoidance)return!0;let e=!1;var r=new sm(t.x,t.y,t.z),s=new sm(t.x,t.y,t.z-1e3),o=new Qm;if(i.world.raycastClosest(r,s,{skipBackfaces:!0},o),o.hasHit&&o.body){const t=i.infos[o.body.index].extrudedHeight;o.distance<t&&(e=!0)}return!!e}return!!this.jv(n)||!this.jv(t)}Uv(t,e,n){const i=this.Ev;if(i&&this.Ev){let t,e=1/0;return i.infos.forEach((i=>{const{point:r,distance:s}=g_.closestPointOnMesh(n,i.mesh.vertices,i.mesh.indices);s<e&&(t=r,e=s)})),t}}jf(t,e){let n=0;const i=this.mv;for(let s=1;s<t.length;s++){const o=t[s-1],a=t[s],u=i[s-1],h=i[s],l=1e3*ip({type:"Point",coordinates:o},{type:"Point",coordinates:a},{units:"kilometers"});if(n<=e&&n+l>e){const t=(e-n)/l,c=[o[0]+(a[0]-o[0])*t,o[1]+(a[1]-o[1])*t,o[2]+(a[2]-o[2])*t];return u.up?{position:c,up:new r.Cartesian3(u.up[0]+(h.up[0]-u.up[0])*t,u.up[1]+(h.up[1]-u.up[1])*t,u.up[2]+(h.up[2]-u.up[2])*t),dir:new r.Cartesian3(u.dir[0]+(h.dir[0]-u.dir[0])*t,u.dir[1]+(h.dir[1]-u.dir[1])*t,u.dir[2]+(h.dir[2]-u.dir[2])*t)}:{position:c,rotation:new r.HeadingPitchRoll(i[s-1].rotation[0]+(i[s].rotation[0]-i[s-1].rotation[0])*t,i[s-1].rotation[1]+(i[s].rotation[1]-i[s-1].rotation[1])*t,i[s-1].rotation[2]+(i[s].rotation[2]-i[s-1].rotation[2])*t)}}n+=l}return{}}}class $_ extends r.Primitive{framebuffer;clearCommand;textures=[];_scene;Ln;constructor(t){if(super(t),!t.viewer)throw new Error("AMapPrimitive: viewer 属性需要在构造函数中传入!");this.Ln=t.viewer,this._scene=t.viewer.scene,this.Cn(),this.clearCommand=this.Lv()}update(t){this.In(),super.update()}getTextures(){return{color:this.framebuffer.getColorTexture(0),depth:this.framebuffer.depthTexture}}Cn(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this._scene.context,n=2*Math.floor(t),i=2*Math.floor(e),s=this._scene.context,o=new r.Texture({context:s,width:n,height:i,pixelFormat:r.PixelFormat.RGBA,pixelDatatype:r.PixelDatatype.UNSIGNED_BYTE}),a=new r.Texture({context:s,width:n,height:i,pixelFormat:r.PixelFormat.DEPTH_COMPONENT,pixelDatatype:r.PixelDatatype.UNSIGNED_INT});this.textures=[o],this.framebuffer&&this.framebuffer.destroy(),this.framebuffer=new r.Framebuffer({context:this._scene.context,colorTextures:this.textures,depthTexture:a}),this.framebuffer.Pn="AMapPrimitive",this.framebuffer.Nn=[n,i]}In(){}Lv(){return new r.ClearCommand({framebuffer:this.framebuffer,color:new r.Color(0,0,0,0),depth:1,stencil:0,pass:r.Pass.OVERLAY})}}class S_ extends Al{md;wd;gd=[];Es="closed";bd=[];xd;Kn=[];Ln;co;ye=!1;Vo;Hv;Vv=[];Wv=-1;Gv;Qv=-1;Kv=[];constructor(t){super(),this.co={},this.Ln=t,this.md=new e.ScreenSpaceEventHandler(t.canvas),this.Vo=[]}Xv(t){return this.Vv.find((e=>{const n=e.position?.getValue(r.JulianDate.now());if(n){const e=this.Ln.scene.cartesianToCanvasCoordinates(n);if(r.Cartesian2.distance(t,e)<5)return!0}return!1}))}open(t){const e=this.Ln;if(this.ye||(this.Es="open"),!this.Hv||t!=this.Hv){if(this.Sd(),t&&t.polygon){const n=t.polygon?.hierarchy?.getValue(r.JulianDate.now()).positions,i=n.length;r.Cartesian3.equals(n[0],n[i-1])&&n.pop(),this.Vo=n,t.polygon.hierarchy=new r.CallbackProperty((()=>new r.PolygonHierarchy(this.Vo)),!1),t.polyline&&(t.polyline.positions=new r.CallbackProperty((()=>this.Vo),!1)),this.Vo.forEach((t=>{const n=e.entities.add({position:t,point:{pixelSize:10,color:r.Color.YELLOW,outlineColor:r.Color.BLACK,outlineWidth:2,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.Vv.push(n)})),this.Hv=t}else this.Vo=[],this.Hv=e.entities.add({polygon:{hierarchy:new r.CallbackProperty((()=>new r.PolygonHierarchy(this.Vo)),!1),material:new r.Color(0,98/255,254/255,.5),outline:!0,outlineColor:r.Color.WHITE,outlineWidth:2},polyline:{positions:new r.CallbackProperty((()=>this.Vo),!1),material:r.Color.RED}});this.md.setInputAction((t=>{const n=e.scene.pickPosition(t.endPosition);n&&(this.Gv&&-1!==this.Qv?(this.Gv.position=n,this.Vo[this.Qv]=n):this.xd?(this.xd.position=n,this.Vo[this.Wv]=n):(this.xd=e.entities.add({position:n,point:{pixelSize:10,color:r.Color.YELLOW,outlineColor:r.Color.BLACK,outlineWidth:2,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.Vo.push(n),this.Wv=this.Vo.length-1))}),r.ScreenSpaceEventType.MOUSE_MOVE),this.md.setInputAction((t=>{this.Sd()}),r.ScreenSpaceEventType.RIGHT_DOWN),this.md.setInputAction((t=>{const n=e.scene.pickPosition(t.position);if(n)if(this.Gv)this.Gv=void 0,this.Qv=-1;else{const i=this.Xv(t.position);if(i){this.xd&&(e.entities.remove(this.xd),this.Vo.pop()),this.xd=void 0,this.Wv=-1,this.Gv=i;const t=this.Vv.indexOf(i);t!==this.Vv.length-1&&(this.Vv.unshift(...this.Vv.splice(t+1)),this.Vo.unshift(...this.Vo.splice(t+1))),this.Qv=this.Vv.length-1}else{this.Vo[this.Wv]=n;const t=e.entities.add({position:n,point:{pixelSize:10,color:r.Color.YELLOW,outlineColor:r.Color.BLACK,outlineWidth:2,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.Vv.push(t),this.xd&&e.entities.remove(this.xd),this.xd=void 0}}}),r.ScreenSpaceEventType.LEFT_CLICK)}}destroy(){this.close(!0),this.md.destroy(),this.ye=!0}Sd(){if(this.xd&&(this.Ln.entities.remove(this.xd),this.Wv=-1,this.xd=void 0,this.Vo.pop()),this.Gv&&(this.Gv=void 0,this.Qv=-1),this.Hv)return this.Vv.forEach((t=>{this.Ln.entities.remove(t)})),this.Vv=[],this.Vo.length>=3?(this.Vo.push(this.Vo[0]),this.Hv.polygon&&(this.Hv.polygon.hierarchy=this.Hv.polygon.hierarchy?.getValue(r.JulianDate.now()),this.Hv.polygon.material=new r.Color(0,150/255,254/255,.5)),this.Hv.polyline&&(this.Hv.polyline.positions=this.Hv.polyline.positions?.getValue(r.JulianDate.now()),this.Hv.polyline.material=r.Color.GREEN),this.emit("EditComplete",{polygon:this.Hv}),this.Kv.push(this.Hv),this.Vo=[],this.Hv=this.Ln.entities.add({polygon:{hierarchy:new r.CallbackProperty((()=>new r.PolygonHierarchy(this.Vo)),!1),material:new r.Color(0,98/255,254/255,.5)},polyline:{positions:new r.CallbackProperty((()=>this.Vo),!1),material:r.Color.RED}})):this.Vo=[],this.Ln.scene.requestRender(),this.wd}close(t){this.Es="closed",this.md.removeInputAction(r.ScreenSpaceEventType.LEFT_CLICK),this.md.removeInputAction(r.ScreenSpaceEventType.RIGHT_DOWN),this.md.removeInputAction(r.ScreenSpaceEventType.MOUSE_MOVE),this.Sd(),t&&this.clear()}clear(){this.Sd(),this.xd&&this.Ln.entities.remove(this.xd),this.Kv.forEach((t=>{this.Ln.entities.remove(t)})),this.Vo=[],this.Ln.scene.requestRender()}}const M_={YunJingLayer:Yc,CameraLayer:af,AMapTerrain:s,AMapSatelliteLayer:o,ENU2ECEF:Dc,ECEF2ENU:Tc,ECEF2LLA:Pc,ENU2LLA:zc,ModelEntity:tp,ModelAnimationPath:ep,AnimationPath:ep,AMapTraffic:Jd,SinglePick:Bc,SinglePlane:Lc,FixedLineViewControl:sp,CameraAnimation:ap,CameraAnimationPath:up,CameraAnimationStatus:t.CameraAnimationStatus,TrackPoint:cp,FirstViewControl:op,RangingTool:fp,TrafficHistoryLayer:$p,RoadNetLayer:Sp,TrafficLayer:Ep,PoiLayer:Zy,BuildingLayer:em,MonomerLayer:Zc,MonomerDrawLayer:Ap,FirstPersonInteraction:k_,LLA2ENU:Cc,TerrainSampler:nm,PlaceSearch:Yy,PolygonEditor:S_,Math:b_};window.YunJing=M_,t.AMapPrimitive=$_,t.AMapSatelliteLayer=o,t.AMapTerrain=s,t.AMapTraffic=Jd,t.AnimationPath=ep,t.BuildingLayer=em,t.CameraAnimation=ap,t.CameraAnimationPath=up,t.CameraLayer=af,t.ECEF2ENU=Tc,t.ECEF2LLA=Pc,t.ENU2ECEF=Dc,t.ENU2LLA=zc,t.FirstPersonInteraction=k_,t.FirstViewControl=op,t.FixedLineViewControl=sp,t.LLA2ENU=Cc,t.Math=b_,t.ModelAnimationPath=ep,t.ModelEntity=tp,t.MonomerDrawLayer=Ap,t.MonomerLayer=Zc,t.PlaceSearch=Yy,t.PoiLayer=Zy,t.PolygonEditor=S_,t.RangingTool=fp,t.RoadNetLayer=Sp,t.SinglePick=Bc,t.SinglePlane=Lc,t.TerrainSampler=nm,t.TrackPoint=cp,t.TrafficHistoryLayer=$p,t.TrafficLayer=Ep,t.YunJingLayer=Yc}({},Cesium);
|