@arcgis/core 5.1.0-next.53 → 5.1.0-next.54
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/applications/Components/SketchTooltipControls.d.ts +3 -2
- package/applications/Components/SketchTooltipControls.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/097c037705ab485372ee.js +1 -0
- package/assets/esri/core/workers/chunks/0ab19ad980fda1cf402a.js +1 -0
- package/assets/esri/core/workers/chunks/0b79630ad435a7734104.js +1 -0
- package/assets/esri/core/workers/chunks/0f4759efc0982fb0ea03.js +1 -0
- package/assets/esri/core/workers/chunks/{f4d31d96681b649ddc95.js → 0ff12fe9e358100668d9.js} +1 -1
- package/assets/esri/core/workers/chunks/11fed97adc9bca0f95e9.js +1 -0
- package/assets/esri/core/workers/chunks/123e15c9e068a053d54e.js +1 -0
- package/assets/esri/core/workers/chunks/1613123918e9b0f7cfdb.js +1 -0
- package/assets/esri/core/workers/chunks/16a46688df5fad5cf8d5.js +1 -0
- package/assets/esri/core/workers/chunks/16ed8c0af8bb8b400163.js +1 -0
- package/assets/esri/core/workers/chunks/16f5cd740321a3539bf1.js +1 -0
- package/assets/esri/core/workers/chunks/173d94e162b210dee0a2.js +1 -0
- package/assets/esri/core/workers/chunks/1a198c9e17f7a058669e.js +1 -0
- package/assets/esri/core/workers/chunks/1fdd736c4932655ff1d9.js +1 -0
- package/assets/esri/core/workers/chunks/2304f7b8173cf86dd805.js +1 -0
- package/assets/esri/core/workers/chunks/2327b368673a974dee8b.js +1 -0
- package/assets/esri/core/workers/chunks/23eb204d3cb818adea32.js +1 -0
- package/assets/esri/core/workers/chunks/{eedeff8b344ff699b0b9.js → 2714ec856c2b3223425b.js} +1 -1
- package/assets/esri/core/workers/chunks/34acecd7a314fed12335.js +1 -0
- package/assets/esri/core/workers/chunks/{cdeb6aec578a1c07d663.js → 3cb0f020f9bfc6653c5d.js} +1 -1
- package/assets/esri/core/workers/chunks/42e084704dea6e4135b6.js +1 -0
- package/assets/esri/core/workers/chunks/{5b3bb636e3bec625e515.js → 4301cb9670fa7c907460.js} +1 -1
- package/assets/esri/core/workers/chunks/48eca6f51112ba80bd3b.js +1 -0
- package/assets/esri/core/workers/chunks/4c38af9ae023fde2b5cd.js +1 -0
- package/assets/esri/core/workers/chunks/4c8c69d081ed37bf5bc5.js +1 -0
- package/assets/esri/core/workers/chunks/4e7bb224bde9e5039263.js +1 -0
- package/assets/esri/core/workers/chunks/4f847a426973bd350c11.js +1 -0
- package/assets/esri/core/workers/chunks/52c90975cf22add7ee2b.js +1 -0
- package/assets/esri/core/workers/chunks/55214e1d9f3d98fa7ed9.js +1 -0
- package/assets/esri/core/workers/chunks/57dc80942e51dedd8335.js +1 -0
- package/assets/esri/core/workers/chunks/59289867cce97da74e39.js +1 -0
- package/assets/esri/core/workers/chunks/5a9620cb66c8e64e4668.js +1 -0
- package/assets/esri/core/workers/chunks/5d202f60891fcae7174d.js +1 -0
- package/assets/esri/core/workers/chunks/{f7fb121169b7e5a5adbc.js → 6666ef3fd6ce877a4509.js} +1 -1
- package/assets/esri/core/workers/chunks/69644b8a6ce340ca1159.js +1 -0
- package/assets/esri/core/workers/chunks/6ab8ed12d162d79a8c55.js +1 -0
- package/assets/esri/core/workers/chunks/796d27d1bbb2eed53cbd.js +1 -0
- package/assets/esri/core/workers/chunks/7ef1c1f765b6d423e474.js +1 -0
- package/assets/esri/core/workers/chunks/8569ae372fc64641b6b1.js +1 -0
- package/assets/esri/core/workers/chunks/929b26999321519824b9.js +1 -0
- package/assets/esri/core/workers/chunks/932a0b39d85a76377d52.js +1 -0
- package/assets/esri/core/workers/chunks/94f80c46ccf5e19038b8.js +1 -0
- package/assets/esri/core/workers/chunks/979c2f52b6d6e1e8241b.js +1 -0
- package/assets/esri/core/workers/chunks/{617328964d480d4a3a45.js → 9806cc96414065ae0afe.js} +1 -1
- package/assets/esri/core/workers/chunks/{987dc23fdc0a8c7150b9.js → a5bf2718c02a0e645013.js} +1 -1
- package/assets/esri/core/workers/chunks/a7b315a660f0f4e1d197.js +1 -0
- package/assets/esri/core/workers/chunks/a8e111a5cfd6151d5dbb.js +1 -0
- package/assets/esri/core/workers/chunks/aed45f7e7eee154a21b8.js +1 -0
- package/assets/esri/core/workers/chunks/b39b4db86a1049f0b901.js +1 -0
- package/assets/esri/core/workers/chunks/{c6a0e770c1a89d3b5913.js → b43889ed9737c27e89f1.js} +1 -1
- package/assets/esri/core/workers/chunks/b59f03c64e4965d87291.js +1 -0
- package/assets/esri/core/workers/chunks/bad82ce3f84f7efb7ab7.js +1 -0
- package/assets/esri/core/workers/chunks/bae1d6dd2376dff271e8.js +1 -0
- package/assets/esri/core/workers/chunks/bb047157f09471ecea53.js +1 -0
- package/assets/esri/core/workers/chunks/bbb9659f79511c2c4690.js +1 -0
- package/assets/esri/core/workers/chunks/bc3b22dc08c147b8d425.js +1 -0
- package/assets/esri/core/workers/chunks/be60a6e210186ff09ae2.js +1 -0
- package/assets/esri/core/workers/chunks/c03190faca955bffc8c1.js +1 -0
- package/assets/esri/core/workers/chunks/c1ad062ccc1817cbee4c.js +1 -0
- package/assets/esri/core/workers/chunks/c86b15f6a18880f921cd.js +1 -0
- package/assets/esri/core/workers/chunks/c93454e37ae0f124bcb0.js +1 -0
- package/assets/esri/core/workers/chunks/cd14b6157862f33ab116.js +1 -0
- package/assets/esri/core/workers/chunks/ce59ec4f0cfbdf780bcb.js +1 -0
- package/assets/esri/core/workers/chunks/{3c9e1ec94bbcbf494916.js → d1aa1d51662f4a01e793.js} +1 -1
- package/assets/esri/core/workers/chunks/d31e68e73527c88b8276.js +1 -0
- package/assets/esri/core/workers/chunks/{15a45e26964c2eb381a6.js → d4961d307651431328a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{81b830f0d620587966ca.js → d53c6fc10425adc2c0cf.js} +1 -1
- package/assets/esri/core/workers/chunks/d69cdee402ba4fc3735f.js +1 -0
- package/assets/esri/core/workers/chunks/d6f1ed8d8f76a32bc81d.js +1 -0
- package/assets/esri/core/workers/chunks/d7456829e404874a9e2f.js +1 -0
- package/assets/esri/core/workers/chunks/d9444dd0d40aa8332b28.js +1 -0
- package/assets/esri/core/workers/chunks/da0a61f73d45ea9e71fc.js +1 -0
- package/assets/esri/core/workers/chunks/{9ae90a4b281d4103e8bb.js → dc07dc1cd30edc0c4193.js} +1 -1
- package/assets/esri/core/workers/chunks/{fdf8fe0f50a9ae548c16.js → ddc7956d80498518551e.js} +1 -1
- package/assets/esri/core/workers/chunks/{29c91b5c9ddcea85f39a.js → e23fc5853e2f4016936b.js} +1 -1
- package/assets/esri/core/workers/chunks/e2d1d9929ed7744785a1.js +1 -0
- package/assets/esri/core/workers/chunks/e543bb228f3f9d937d43.js +1 -0
- package/assets/esri/core/workers/chunks/ec21311584e4fb13e510.js +1 -0
- package/assets/esri/core/workers/chunks/f3f26f6116ab9126c2e7.js +1 -0
- package/assets/esri/core/workers/chunks/f4472e3486fdc33abb9a.js +1 -0
- package/assets/esri/core/workers/chunks/f80f04657762666b9165.js +1 -0
- package/assets/esri/core/workers/chunks/f8ee1a99580a7da42cde.js +1 -0
- package/assets/esri/core/workers/chunks/fcda652fb5262696d59c.js +1 -0
- package/assets/esri/core/workers/chunks/fe92f54e45fd21ccd75f.js +1 -0
- package/assets/esri/core/workers/chunks/ff0cb1eec14d34214f12.js +1 -0
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
- package/chunks/OITBlend.glsl.js +2 -2
- package/chunks/ShadowHighlight.glsl.js +1 -1
- package/chunks/Viewshed.glsl.js +2 -2
- package/chunks/arcgis-knowledge-client-core-simd.js +1 -1
- package/chunks/arcgis-knowledge-client-core.js +1 -1
- package/config.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/geometry/SpatialReference.js +1 -1
- package/geometry/operators/support/apiConverter.js +1 -1
- package/geometry/support/aaBoundingBox.js +1 -1
- package/geometry/support/geometryUtils.js +1 -1
- package/kernel.js +1 -1
- package/package.json +1 -1
- package/rest/knowledgeGraph/wasmInterface/knowledgeWasmAccess.js +1 -1
- package/support/revision.js +1 -1
- package/support/tests/serviceMockDependencies.js +1 -1
- package/views/2d/engine/flow/FlowContainer.js +1 -1
- package/views/2d/engine/flow/FlowStrategy.js +1 -1
- package/views/2d/engine/flow/FlowView2D.js +1 -1
- package/views/2d/engine/flow/dataUtils.js +1 -1
- package/views/2d/engine/flow/particleConstants.js +2 -0
- package/views/2d/engine/flow/styles/Imagery.js +1 -1
- package/views/2d/engine/flow/styles/Particles.js +1 -1
- package/views/2d/engine/flow/styles/Stack.js +1 -1
- package/views/2d/engine/flow/styles/Streamlines.js +1 -1
- package/views/2d/engine/flow/utils.js +1 -1
- package/views/2d/engine/imagery/RasterVFContainer.js +1 -1
- package/views/2d/engine/webgl/Painter.js +1 -1
- package/views/2d/engine/webgl/Profiler.js +1 -1
- package/views/2d/engine/webgl/WGLContainer.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/TechniqueRegistry.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/TestTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/TextureStatisticsTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/FillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/GradientFillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternFillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/flow/FlowTechnique.js +2 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/grid/GridTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/LineTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/TexturedLineTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/magnifier/MagnifierTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterRegistry.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/opacity/OpacityTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/overlay/OverlayTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/flow/FlowImageryShader.js +2 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/flow/FlowParticlesShader.js +2 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/flow/FlowStreamlinesShader.js +2 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/flow/FlowUtils.js +2 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/tile/TileDebugInfoTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/tile/TileStencilTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueBackground.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueCircle.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueLine.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueSymbol.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/videoScreenRenderer/VideoScreenTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/layers/features/RenderState.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
- package/views/3d/layers/support/Tiles3DBVH.js +1 -1
- package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/GLMaterial.js +1 -1
- package/views/3d/webgl-engine/lib/GLMaterialLoader.js +2 -0
- package/views/3d/webgl-engine/lib/GLMaterialParameters.js +1 -1
- package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
- package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/RenderContext.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ReprojectionUniforms.js +2 -0
- package/views/3d/webgl-engine/lib/ScreenSpaceReflectionsUniforms.js +2 -0
- package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/PolygonOffset.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/CheckerBoardTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/Viewshed.glsl.js +1 -1
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/plugins/ShapePlugin.js +1 -1
- package/views/draw/support/managers/GlobalStateManager.js +1 -1
- package/views/draw/support/types.d.ts +9 -0
- package/views/interactive/SegmentLabels.js +1 -1
- package/views/webgl/AllocationTracer.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/widgets/Editor/components/Settings.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/Search/support/layerSearchUtils.js +1 -1
- package/widgets/Search/support/locatorUtils.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/support/SketchTooltipControls.js +1 -1
- package/assets/esri/core/workers/chunks/001492854799c35b53bb.js +0 -1
- package/assets/esri/core/workers/chunks/004f991251f09b36fb09.js +0 -1
- package/assets/esri/core/workers/chunks/01dd849a2d335e9f3e16.js +0 -1
- package/assets/esri/core/workers/chunks/027d733a99f50cadcf22.js +0 -1
- package/assets/esri/core/workers/chunks/03d85a706669aaf24d49.js +0 -1
- package/assets/esri/core/workers/chunks/0450133e81bce4b48b84.js +0 -1
- package/assets/esri/core/workers/chunks/085778ecd39f46324a6b.js +0 -1
- package/assets/esri/core/workers/chunks/08dce0019b52042b01fa.js +0 -1
- package/assets/esri/core/workers/chunks/0d8294982853308225da.js +0 -1
- package/assets/esri/core/workers/chunks/156aecac067213642aae.js +0 -1
- package/assets/esri/core/workers/chunks/184e9147f7a2f0ae5915.js +0 -1
- package/assets/esri/core/workers/chunks/19f59a2a97c33ff92650.js +0 -1
- package/assets/esri/core/workers/chunks/2b7d020367cb4ebb3c3d.js +0 -1
- package/assets/esri/core/workers/chunks/3104b10770903c265626.js +0 -1
- package/assets/esri/core/workers/chunks/33f00633131581e06328.js +0 -1
- package/assets/esri/core/workers/chunks/365ad1ffd496ed86637b.js +0 -1
- package/assets/esri/core/workers/chunks/3874362bf7d43adc41bb.js +0 -1
- package/assets/esri/core/workers/chunks/38dc1c4b8721efd4a165.js +0 -1
- package/assets/esri/core/workers/chunks/3e9700445518b8f9ae1b.js +0 -1
- package/assets/esri/core/workers/chunks/42f3fdad1728433b3510.js +0 -1
- package/assets/esri/core/workers/chunks/436941ec88439667022e.js +0 -1
- package/assets/esri/core/workers/chunks/4812482f28f7205b0938.js +0 -1
- package/assets/esri/core/workers/chunks/5317cbef0aac29761575.js +0 -1
- package/assets/esri/core/workers/chunks/54a9e17d6c0fef6a9146.js +0 -1
- package/assets/esri/core/workers/chunks/55985c9c48b8e1d1c634.js +0 -1
- package/assets/esri/core/workers/chunks/5e5b358e603b13b4d7d7.js +0 -1
- package/assets/esri/core/workers/chunks/63b9e4a7dad358605c38.js +0 -1
- package/assets/esri/core/workers/chunks/662932d2effd2b384b9e.js +0 -1
- package/assets/esri/core/workers/chunks/66d4cbb35d0c290150bf.js +0 -1
- package/assets/esri/core/workers/chunks/677d3674cb2c0c05fb7e.js +0 -1
- package/assets/esri/core/workers/chunks/6f58ec80abebb7bfbbb0.js +0 -1
- package/assets/esri/core/workers/chunks/7100c9038739121c2c4b.js +0 -1
- package/assets/esri/core/workers/chunks/794f604d4267e374f7dd.js +0 -1
- package/assets/esri/core/workers/chunks/7ae8f73c8e2afae98ecb.js +0 -1
- package/assets/esri/core/workers/chunks/7d4af7e2cb2f234e12eb.js +0 -1
- package/assets/esri/core/workers/chunks/807b12ace0099300b9b9.js +0 -1
- package/assets/esri/core/workers/chunks/816a4b03f2ea49238a6c.js +0 -1
- package/assets/esri/core/workers/chunks/842b442cc012d0797333.js +0 -1
- package/assets/esri/core/workers/chunks/8903ff28896bd6f34b0d.js +0 -1
- package/assets/esri/core/workers/chunks/89e9bc8789b100316136.js +0 -1
- package/assets/esri/core/workers/chunks/8afe32d3db9669f972bc.js +0 -1
- package/assets/esri/core/workers/chunks/91fd28f50477d16e294e.js +0 -1
- package/assets/esri/core/workers/chunks/953f671bdeb2ca9b9f37.js +0 -1
- package/assets/esri/core/workers/chunks/98011b93acf3d5f0b5a2.js +0 -1
- package/assets/esri/core/workers/chunks/9c7fd5db0813bdc38582.js +0 -1
- package/assets/esri/core/workers/chunks/a2fee1611319665e6aed.js +0 -1
- package/assets/esri/core/workers/chunks/a644e30f65347ce846ed.js +0 -1
- package/assets/esri/core/workers/chunks/a64daa4945923a178fe5.js +0 -1
- package/assets/esri/core/workers/chunks/a84d67c1a1008bca2075.js +0 -1
- package/assets/esri/core/workers/chunks/a85575a8d1da09280cd7.js +0 -1
- package/assets/esri/core/workers/chunks/ac4f7309a249132c22da.js +0 -1
- package/assets/esri/core/workers/chunks/aeb1900cfdd0e51cc5f8.js +0 -1
- package/assets/esri/core/workers/chunks/ba62f3aa811430787863.js +0 -1
- package/assets/esri/core/workers/chunks/c03d0091a6f385b9ce8d.js +0 -1
- package/assets/esri/core/workers/chunks/c20aaca8085ce897bd12.js +0 -1
- package/assets/esri/core/workers/chunks/c3e711dc608eedda2d14.js +0 -1
- package/assets/esri/core/workers/chunks/c4a9006cc6d2938570e0.js +0 -1
- package/assets/esri/core/workers/chunks/c692ea68509bddbf7b42.js +0 -1
- package/assets/esri/core/workers/chunks/cb8c17daec7055bf99cc.js +0 -1
- package/assets/esri/core/workers/chunks/d7439d357f68160844cb.js +0 -1
- package/assets/esri/core/workers/chunks/dd319d5fe89b275e93cf.js +0 -1
- package/assets/esri/core/workers/chunks/df3e79b56c37156e7895.js +0 -1
- package/assets/esri/core/workers/chunks/df8b80b17e371c9be4e6.js +0 -1
- package/assets/esri/core/workers/chunks/e77198f8ab47441423c5.js +0 -1
- package/assets/esri/core/workers/chunks/e786da40a1c87bed64ca.js +0 -1
- package/assets/esri/core/workers/chunks/e8aafef6342c50340a27.js +0 -1
- package/assets/esri/core/workers/chunks/ec00348d74e29f48613a.js +0 -1
- package/assets/esri/core/workers/chunks/f4201e7dcae224d0caf0.js +0 -1
- package/assets/esri/core/workers/chunks/f7cc05fbfc97b4d36eba.js +0 -1
- package/assets/esri/core/workers/chunks/f9d369a4683f88ee9d76.js +0 -1
- package/assets/esri/core/workers/chunks/fc534c94d55331578195.js +0 -1
- package/assets/esri/themes/base/colors/css/brand_colors.css +0 -76
- package/assets/esri/themes/base/colors/css/calcite_core_colors.css +0 -169
- package/assets/esri/themes/base/colors/css/calcite_core_colors_dark.css +0 -169
- package/assets/esri/themes/base/colors/css/calcite_gray_colors.css +0 -43
- package/assets/esri/themes/base/colors/css/calcite_gray_colors_dark.css +0 -43
- package/assets/esri/themes/base/colors/css/calcite_highlight_colors.css +0 -43
- package/assets/esri/themes/base/colors/css/calcite_highlight_colors_dark.css +0 -43
- package/assets/esri/themes/base/colors/css/calcite_vibrant_colors.css +0 -67
- package/assets/esri/themes/base/colors/css/calcite_vibrant_colors_dark.css +0 -67
- package/assets/esri/themes/base/colors/css/complete.css +0 -610
- package/assets/esri/themes/base/colors/css/scss/brand_colors.scss +0 -128
- package/assets/esri/themes/base/colors/css/scss/calcite_core_colors.scss +0 -289
- package/assets/esri/themes/base/colors/css/scss/calcite_core_colors_dark.scss +0 -285
- package/assets/esri/themes/base/colors/css/scss/calcite_gray_colors.scss +0 -96
- package/assets/esri/themes/base/colors/css/scss/calcite_gray_colors_dark.scss +0 -91
- package/assets/esri/themes/base/colors/css/scss/calcite_highlight_colors.scss +0 -69
- package/assets/esri/themes/base/colors/css/scss/calcite_highlight_colors_dark.scss +0 -65
- package/assets/esri/themes/base/colors/css/scss/calcite_vibrant_colors.scss +0 -128
- package/assets/esri/themes/base/colors/css/scss/calcite_vibrant_colors_dark.scss +0 -124
- package/assets/esri/themes/base/colors/css/scss/complete.scss +0 -11
- package/assets/esri/themes/base/colors/patterns_json/brand_colors.css +0 -366
- package/assets/esri/themes/base/colors/patterns_json/calcite_core_colors.css +0 -687
- package/assets/esri/themes/base/colors/patterns_json/calcite_core_colors_dark.css +0 -673
- package/assets/esri/themes/base/colors/patterns_json/calcite_gray_colors.css +0 -177
- package/assets/esri/themes/base/colors/patterns_json/calcite_gray_colors_dark.css +0 -169
- package/assets/esri/themes/base/colors/patterns_json/calcite_highlight_colors.css +0 -178
- package/assets/esri/themes/base/colors/patterns_json/calcite_highlight_colors_dark.css +0 -169
- package/assets/esri/themes/base/colors/patterns_json/calcite_vibrant_colors.css +0 -273
- package/assets/esri/themes/base/colors/patterns_json/calcite_vibrant_colors_dark.css +0 -265
- package/assets/esri/themes/base/colors/patterns_json/complete.css +0 -2847
- package/assets/esri/themes/base/colors/patterns_json/scss/brand_colors.scss +0 -464
- package/assets/esri/themes/base/colors/patterns_json/scss/calcite_core_colors.scss +0 -967
- package/assets/esri/themes/base/colors/patterns_json/scss/calcite_core_colors_dark.scss +0 -964
- package/assets/esri/themes/base/colors/patterns_json/scss/calcite_gray_colors.scss +0 -265
- package/assets/esri/themes/base/colors/patterns_json/scss/calcite_gray_colors_dark.scss +0 -263
- package/assets/esri/themes/base/colors/patterns_json/scss/calcite_highlight_colors.scss +0 -237
- package/assets/esri/themes/base/colors/patterns_json/scss/calcite_highlight_colors_dark.scss +0 -235
- package/assets/esri/themes/base/colors/patterns_json/scss/calcite_vibrant_colors.scss +0 -376
- package/assets/esri/themes/base/colors/patterns_json/scss/calcite_vibrant_colors_dark.scss +0 -347
- package/assets/esri/themes/base/colors/patterns_json/scss/complete.scss +0 -12
- package/assets/esri/themes/base/icons/readme/download.png +0 -0
- package/assets/esri/themes/base/icons/readme/import-icons.png +0 -0
- package/assets/esri/themes/base/icons/readme/import.png +0 -0
- package/assets/esri/themes/base/icons/readme/load.png +0 -0
- package/assets/esri/themes/base/icons/selection.json +0 -1
- package/assets/esri/themes/base/icons/style.css +0 -774
- package/views/2d/engine/brushes.js +0 -2
- package/views/2d/engine/flow/BrushFlow.js +0 -2
- package/views/2d/engine/rasterBrushes.js +0 -2
- package/views/2d/engine/webgl/brushes/BrushClip.js +0 -2
- package/views/2d/engine/webgl/brushes/WGLBrush.js +0 -2
- package/views/2d/engine/webgl/painter/RenderPass.js +0 -2
- package/views/2d/engine/webgl/shaders/BackgroundPrograms.js +0 -2
- package/views/2d/engine/webgl/shaders/TileInfoPrograms.js +0 -2
- package/views/3d/webgl-engine/lib/GLMaterials.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
class e{constructor(e){this._objectType=e,this._active=new Map,Error.stackTraceLimit=30}get _stack(){const e=(new Error).stack.split("\n");return e.shift(),e.shift(),e.shift(),e.join("\n")}add(e){this._active.set(e,new t(this._stack))}remove(e){this._active.delete(e)}addReference(e){const t=this._active.get(e);t&&t.retains.push(this._stack)}removeReference(e){const t=this._active.get(e);t&&t.releases.push(this._stack)}resetLog(){const e=new Map;let t="";this._active.forEach((s,{usedMemory:r})=>{e.has(s.from)||(e.set(s.from,new Map),s.retains.length>0&&(t+=` First reference count mismatch:\n Retain:\n ${s.retains.join("\n\n ")}\n\n Release: ${s.releases.join("\n\n ")}\n`));const n=e.get(s.from);n.set(
|
|
2
|
+
class e{constructor(e){this._objectType=e,this._active=new Map,Error.stackTraceLimit=30}get _stack(){const e=(new Error).stack.split("\n");return e.shift(),e.shift(),e.shift(),e.join("\n")}add(e){this._active.set(e,new t(this._stack))}remove(e){this._active.delete(e)}addReference(e){const t=this._active.get(e);t&&t.retains.push(this._stack)}removeReference(e){const t=this._active.get(e);t&&t.releases.push(this._stack)}resetLog(){const e=new Map;let t="";this._active.forEach((s,{usedMemory:r})=>{e.has(s.from)||(e.set(s.from,new Map),s.retains.length>0&&(t+=` First reference count mismatch:\n Retain:\n ${s.retains.join("\n\n ")}\n\n Release: ${s.releases.join("\n\n ")}\n`));const n=e.get(s.from),a=r??0;n.set(a,(n.get(a)??0)+1)}),this._active.clear();let s=0;const r=new Array;return e.forEach((e,t)=>{let n=0;e.forEach((e,t)=>n+=e*t),e.set(-1,n),s+=n,r.push([t,e])}),e.clear(),r.sort((e,t)=>t[1].get(-1)-e[1].get(-1)),r.reduce((e,[t,s])=>{const r=Math.round(s.get(-1)/1024);s.delete(-1);return e+=` ${r}KB from ${Array.from(s.values()).reduce((e,t)=>e+t,0)} allocations at ${t}\n`},`Total ${this._objectType} memory: ${Math.round(s/1024)}KB\n${t}`)}}class t{constructor(e){this.from=e,this.retains=new Array,this.releases=new Array}}export{e as AllocationTracer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import has from"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{Milliseconds as i}from"../../core/time.js";import{webglDebugEnabled as a,checkWebGLError as r,getErrorMessage as n,webglValidateShadersEnabled as l}from"./checkWebGLError.js";import{ContextState as h}from"./ContextState.js";import{DrawBufferNone as f,DrawBufferBack as o,baseTextureUnit as u,ResourceType as c,ColorAttachment0 as d,PrimitiveType as _}from"./enums.js";import{InstanceCounter as b}from"./InstanceCounter.js";import{Parameters as g}from"./Parameters.js";import{ProgramCache as p}from"./ProgramCache.js";import{StateTracker as m}from"./renderState.js";import B from"./Texture.js";import{WebGLDriverTest as F}from"./WebGLDriverTest.js";import{Capabilities as T}from"./capabilities/Capabilities.js";const x=()=>t.getLogger("esri.views.webgl.RenderingContext");let k=class{constructor(t,e){this.gl=t,this.instanceCounter=new b,this._programCache=new p(this),this._transformFeedbackRequestInfo=null,this._state=new h,this._numOfDrawCalls=0,this._numOfTriangles=0,this._options=e,this.configure(e)}configure(t){this._options=t,this._capabilities=new T(this.gl,t),this._parameters=new g(this.gl,this._capabilities,t),B.TEXTURE_UNIT_FOR_UPDATES=this._parameters.maxTextureImageUnits-1;const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new h,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new m({setBlending:t=>{if(t){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(t.opRgb,t.opAlpha),this.setBlendFunctionSeparate(t.srcRgb,t.dstRgb,t.srcAlpha,t.dstAlpha);const e=t.color;this.setBlendColor(e.r,e.g,e.b,e.a)}else this.setBlendingEnabled(!1)},setCulling:t=>{t?(this.setFaceCullingEnabled(!0),this.setCullFace(t.face),this.setFrontFace(t.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:t=>{t?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(t.factor,t.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:t=>{t?(this.setDepthTestEnabled(!0),this.setDepthFunction(t.func)):this.setDepthTestEnabled(!1)},setStencilTest:t=>{if(t){this.setStencilTestEnabled(!0);const e=t.function;this.setStencilFunction(e.func,e.ref,e.mask);const s=t.operation;this.setStencilOp(s.fail,s.zFail,s.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:t=>{t?(this.setDepthWriteEnabled(!0),this.setDepthRange(t.zNear,t.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:t=>{t?this.setColorMask(t.r,t.g,t.b,t.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:t=>{t?this.setStencilWriteMask(t.mask):this.setStencilWriteMask(0)}}),this.enforceState(),e(this._driverTest),this._driverTest=new F(this)}updateOptions(t){this._options={...this._options,...t},this._parameters=new g(this.gl,this._capabilities,this._options)}dispose(){this._driverTest=e(this._driverTest),this._programCache=e(this._programCache),this.bindVAO(null),this.unbindBuffer(34962),this.unbindBuffer(34963),this.unbindBuffer(35345),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(35051),this.unbindBuffer(35052),this.unbindBuffer(36662),this.unbindBuffer(36663),this._state.textureUnitMap.length=0,this._state.textureUnitSamplerMap.length=0,this._state=null,this._capabilities=null,this._stateTracker=null,a()&&this.instanceCounter.resourceInformation&&console.log(this.instanceCounter.resourceInformation)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}get programCache(){return this._programCache}setPipelineState(t){this._stateTracker.setPipeline(t)}getPipelineState(){return this._stateTracker.getPipelineState()}setBlendingEnabled(t){this._state.blend!==t&&(!0===t?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=t,this._stateTracker.invalidateBlending())}externalProgramUpdate(){this._state.program?.stop(),this._state.program=null}externalTextureUnitUpdate(t,e){for(let s=0;s<t.length;++s){const e=t[s];this._state.textureUnitMap[e]=null,this._state.textureUnitSamplerMap[e]=null}e>=0&&(this._state.activeTexture=e)}externalVertexArrayObjectUpdate(){this.gl.bindVertexArray(null),this._state.vertexArrayObject=null,this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=1032,this._state.stencilFunction.func=t,this._state.stencilFunction.ref=e,this._state.stencilFunction.mask=s,this._stateTracker.invalidateStencilTest())}setStencilFunctionSeparate(t,e,s,i){this._state.stencilFunction.face===t&&this._state.stencilFunction.func===e&&this._state.stencilFunction.ref===s&&this._state.stencilFunction.mask===i||(this.gl.stencilFuncSeparate(t,e,s,i),this._state.stencilFunction.face=t,this._state.stencilFunction.func=e,this._state.stencilFunction.ref=s,this._state.stencilFunction.mask=i,this._stateTracker.invalidateStencilTest())}setStencilWriteMask(t){this._state.stencilWriteMask!==t&&(this.gl.stencilMask(t),this._state.stencilWriteMask=t,this._stateTracker.invalidateStencilWrite())}setStencilOp(t,e,s){1032===this._state.stencilOperation.face&&this._state.stencilOperation.fail===t&&this._state.stencilOperation.zFail===e&&this._state.stencilOperation.zPass===s||(this.gl.stencilOp(t,e,s),this._state.stencilOperation.face=1032,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,s,i){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===s&&this._state.stencilOperation.zPass===i||(this.gl.stencilOpSeparate(t,e,s,i),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=s,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const s=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(u+t),this._state.activeTexture=t),s}setDrawBuffers(t){const{drawFramebuffer:e}=this._state,s=null===e,i=s?this._state.drawBuffers.defaultFramebuffer:this._state.drawBuffers.fbos.get(e)??[];if(i?.length===t.length&&i.every((e,s)=>e===t[s]))return i;if(t.length>this.parameters.maxDrawBuffers)return x().error(`Setting more active draw buffers (${t.length}) than GL.MAX_DRAW_BUFFERS allows ( ${this.parameters.maxDrawBuffers}).`),i;if(s){if(t.length>1)return x().error(`The default framebuffer can only have 1 active draw buffer but was requested with ${t.length}.`),i;if(t[0]!==o&&t[0]!==f)return x().error(`The default framebuffer can only use the constants GL.BACK or GL.NONE as draw buffers but got ${t[0]}`),i}else if(t.includes(o))return x().error("A framebuffer object can only use the constants GL.COLOR_ATTACHMENTx or GL.NONE as draw buffers."),i;return this.gl.drawBuffers(t),r(this.gl),s?this._state.drawBuffers.defaultFramebuffer=t:this._state.drawBuffers.fbos.set(e,t),i}clear(t,e=255){t&&(16384&t&&this.setColorMask(!0,!0,!0,!0),256&t&&this.setDepthWriteEnabled(!0),1024&t&&this.setStencilWriteMask(e),this.gl.clear(t))}clearFramebuffer(t,e=!1,s=!1){let i=0;if(t){const e=1e-13,s=Math.max(e,t[3]);this.setClearColor(t[0],t[1],t[2],s),i|=16384}e&&(i|=256),!1===s?s=0:(!0===s&&(s=255),i|=1024),i&&this.clear(i,s)}clearBuffer(t,e,s=6144,i){this.gl.clearBufferfv(s,t,e,i)}clearBufferInteger(t,e,s=6144,i){this.gl.clearBufferiv(s,t,e,i)}clearBufferUnsignedInteger(t,e,s=6144,i){this.gl.clearBufferuiv(s,t,e,i)}drawArrays(t,e,s){if(this._transformFeedbackRequestInfo){if(t!==this._transformFeedbackRequestInfo.primitiveType)throw new Error("DrawArrays called during transform feedback, but primitiveType does not match that of the current transform feedback request");if(null==this._state.program?.hasTransformFeedbackVaryings)throw new Error("DrawArrays called during transform feedback, but the shader program was not linked with a transform feedback varying")}if(a()&&(this._numOfDrawCalls++,this._numOfTriangles+=E(t,s),has("enable-feature:webgl-debug:textureReadWrite"))){const t=this._state.textureUnitMap;for(let e=0;e<t.length;e++){const s=t[e];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${e}`)}}this.gl.drawArrays(t,e,s),r(this.gl)}drawArraysInstanced(t,e,s,i){this.gl.drawArraysInstanced(t,e,s,i),r(this.gl)}drawElements(t,e,s,i){if(this._transformFeedbackRequestInfo)throw new Error("Cannot called drawElements during a transform feedback request");if(a()&&(this._numOfDrawCalls++,this._numOfTriangles+=E(t,e)),this.gl.drawElements(t,e,s,i),a()){const a=n(this.gl);if(a){const r=this.getBoundVAO(),n=r?.indexBuffer,l=r?.buffers,h={indexBuffer:n,vertexBuffers:l},f={mode:t,count:e,type:s,offset:i},o=n?.size??0,u=i+e,c=o<u?`. Buffer is too small. Attempted to draw index ${u} of ${o}`:"";x().error(`drawElements: ${a}${c}`,{args:f,vao:h})}}}drawElementsInstanced(t,e,s,i,a){this.gl.drawElementsInstanced(t,e,s,i,a),r(this.gl)}logInfo(){a()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){a()&&(this._numOfDrawCalls=0,this._numOfTriangles=0)}get capabilities(){return this._capabilities}setViewport(t,e,s,i){s=Math.max(Math.round(s),1),i=Math.max(Math.round(i),1);const a=this._state.viewport;a.x===t&&a.y===e&&a.width===s&&a.height===i||(a.x=t,a.y=e,a.width=s,a.height=i,this.gl.viewport(t,e,s,i))}setViewport4fv(t){this.setViewport(t[0],t[1],t[2],t[3])}restoreViewport({x:t,y:e,width:s,height:i}){this.setViewport(t,e,s,i)}getViewport(){const t=this._state.viewport;return{x:t.x,y:t.y,width:t.width,height:t.height}}useProgram(t){if(this._state.program!==t){if(t&&null==t.glName&&l())throw new Error("Attempting to use disposed or invalid Program");this._state.program?.stop(),this._state.program=t,this.gl.useProgram(t?.glName??null)}}bindTexture(t,e,s=!1,i=null){(e>=this.parameters.maxTextureImageUnits||e<0)&&x().error(`Input texture unit (${e}) is out of range of available units (0...${this.parameters.maxTextureImageUnits})\n `);const a=this._state.textureUnitMap[e],r=this._state.textureUnitSamplerMap[e],{gl:n}=this;return null==t?.glName?(null!=a&&(this.setActiveTexture(e,s),n.bindTexture(a.descriptor.target,null)),this._state.textureUnitMap[e]=null,null!=r&&(this._state.textureUnitSamplerMap[e]=null,n.bindSampler(e,null)),a):(r!==i&&(n.bindSampler(e,i?.glName??null),this._state.textureUnitSamplerMap[e]=i),s||a!==t?(this.setActiveTexture(e,s),n.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,a):(t.isDirty&&(this.setActiveTexture(e,s),t.applyChanges()),a))}unbindTexture(t){if(null!=t)for(let e=0;e<this.parameters.maxTextureImageUnits;e++)this._state.textureUnitMap[e]===t&&(this.bindTexture(null,e),this._state.textureUnitMap[e]=null)}bindFramebuffer(t,e=!1){const s=S(t);if(e||this._state.readFramebuffer!==t||this._state.drawFramebuffer!==t){if(null==t)return this.gl.bindFramebuffer(36160,null),this._state.readFramebuffer=this._state.drawFramebuffer=null,void this.setDrawBuffers(s);t.initializeAndBind(36160),this._state.readFramebuffer=t,this._state.drawFramebuffer=t,this.setDrawBuffers(s)}else this.setDrawBuffers(s)}bindFramebufferSeparate(t,e,s=!1){const i=36008===e,a=i?this._state.readFramebuffer:this._state.drawFramebuffer;(s||a!==t)&&(null==t?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),i?this._state.readFramebuffer=t??null:(this._state.drawFramebuffer=t??null,this.setDrawBuffers(S(t))))}blitFramebuffer(t,e,s=16384,i=9728,a=0,r=0,n=t.width,l=t.height,h=0,f=0,o=e.width,u=e.height){this.bindFramebufferSeparate(t,36008,!0),this.bindFramebufferSeparate(e,36009,!0),this.gl.blitFramebuffer(a,r,n,l,h,f,o,u,s,i)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case 34962:this._state.vertexBuffer=w(this.gl,t,e,this._state.vertexBuffer);break;case 34963:this._state.indexBuffer=w(this.gl,t,e,this._state.indexBuffer);break;case 35345:this._state.uniformBuffer=w(this.gl,t,e,this._state.uniformBuffer);break;case 35051:this._state.pixelPackBuffer=w(this.gl,t,e,this._state.pixelPackBuffer);break;case 35052:this._state.pixelUnpackBuffer=w(this.gl,t,e,this._state.pixelUnpackBuffer);break;case 36662:this._state.copyReadBuffer=w(this.gl,t,e,this._state.copyReadBuffer);break;case 36663:this._state.copyWriteBuffer=w(this.gl,t,e,this._state.copyWriteBuffer);break;case 35982:this._state.transformFeedbackBuffer=w(this.gl,t,e,this._state.transformFeedbackBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return x().error(`Uniform buffer binding point (${e}) is out of range (0...${this.parameters.maxUniformBufferBindings})\n `),null;const s=35345===t?this._state.uniformBufferBindingPoints:this._state.transformBufferBindingPoints;let i=s[e];return null==i&&(i={buffer:null,offset:0,size:0},s[e]=i),i}bindBufferBase(t,e,s){const i=this._getBufferBinding(t,e);null!=i&&(i.buffer===s&&0===i.offset&&0===i.size||(this.gl.bindBufferBase(t,e,s?s.glName:null),i.buffer=s,i.offset=0,i.size=0))}bindBufferRange(t,e,s,i,a){const r=this._getBufferBinding(t,e);null!=r&&(r.buffer===s&&r.offset===i&&r.size===a||(i%this._parameters.uniformBufferOffsetAlignment===0?(this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a):x().error("Uniform buffer binding offset is not a multiple of the context offset alignment")))}bindUBO(t,e,s,i){null!=e?(a()&&(i??e.byteLength)>this._parameters.maxUniformBlockSize&&x().error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==s&&void 0!==i?this.bindBufferRange(35345,t,e.buffer,s,i):this.bindBufferBase(35345,t,e.buffer)):this.bindBufferBase(35345,t,null)}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];null!=s&&s.buffer===t.buffer&&this.bindBufferBase(35345,e,null)}}unbindBuffer(t){switch(t){case 34962:this._state.vertexBuffer=w(this.gl,null,t,this._state.vertexBuffer);break;case 34963:this._state.indexBuffer=w(this.gl,null,t,this._state.indexBuffer);break;case 35345:this._state.uniformBuffer=w(this.gl,null,t,this._state.uniformBuffer);break;case 35051:this._state.pixelPackBuffer=w(this.gl,null,t,this._state.pixelPackBuffer);break;case 35052:this._state.pixelUnpackBuffer=w(this.gl,null,t,this._state.pixelUnpackBuffer);break;case 36662:this._state.copyReadBuffer=w(this.gl,null,t,this._state.copyReadBuffer);break;case 36663:this._state.copyWriteBuffer=w(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t,e){if(null==t)return this._state.vertexArrayObject?.unbind(),void(this._state.vertexArrayObject=null);this._state.vertexArrayObject!==t&&(t.bind(e),this._state.vertexArrayObject=t)}bindTransformFeedback(t){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,t.glName)}beginTransformFeedback(t,e){if(this._transformFeedbackRequestInfo)throw new Error("Already in a transform feedback request");const{gl:s}=this;s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,t.glName),s.beginTransformFeedback(e),this._transformFeedbackRequestInfo={primitiveType:e}}endTransformFeedback(){if(!this._transformFeedbackRequestInfo)throw new Error("Not in a transform feedback request");const{gl:t}=this;t.endTransformFeedback(),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),this._transformFeedbackRequestInfo=null}async clientWaitAsync(t=i(10)){const{gl:e}=this,a=e.fenceSync(37143,0);if(!a)throw new Error("Client wait failed, could not create sync object");let r;this.instanceCounter.increment(c.Sync,a),e.flush();do{await s(t),r=e.clientWaitSync(a,0,0)}while(37147===r);if(this.instanceCounter.decrement(c.Sync,a),e.deleteSync(a),37149===r)throw new Error("Client wait failed")}getBoundFramebufferObject(t=36160){return 36008===t?this._state.readFramebuffer:this._state.drawFramebuffer}temporaryBindFramebufferObject(t,e,s=!1){const i=this.getBoundFramebufferObject();try{this.bindFramebuffer(t,s),e()}finally{this.bindFramebuffer(i,s)}}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(34962),this.unbindBuffer(34963),this.unbindBuffer(35345),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(35051),this.unbindBuffer(35052),this.unbindBuffer(36662),this.unbindBuffer(36663);for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(1,0),this.setBlendEquation(32774),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(1029),this.setFrontFace(2305),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(513),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(519,0,0),this.setStencilOp(7680,7680,7680),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const{gl:t}=this;t.bindVertexArray(null);for(let s=0;s<this.parameters.maxVertexAttributes;s++)t.disableVertexAttribArray(s);this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(34962,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(34963,null),this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(35345,null);for(let s=0;s<this._parameters.maxUniformBufferBindings;s++){const e=this._state.uniformBufferBindingPoints[s];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?t.bindBufferBase(35345,s,i.glName):t.bindBufferRange(35345,s,i.glName,a,r):t.bindBufferBase(35345,s,null)}}if(this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(35051,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(35052,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(36662,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(36663,null),t.bindFramebuffer(36008,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(36008,this._state.readFramebuffer.glName),t.readBuffer(d)),t.bindFramebuffer(36009,this._state.drawFramebuffer?.glName??null),null===this._state.drawFramebuffer){const e=this._state.drawBuffers.defaultFramebuffer;t.drawBuffers(e??[o])}else{const e=this._state.drawBuffers.fbos.get(this._state.drawFramebuffer);t.drawBuffers(e??[d])}if(this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}t.useProgram(this._state.program?.glName??null),t.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),t.bindRenderbuffer(t.RENDERBUFFER,this._state.renderbuffer?.glName??null),!0===this._state.blend?t.enable(this.gl.BLEND):t.disable(this.gl.BLEND),t.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),t.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),t.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),t.clearDepth(this._state.clearDepth),t.clearStencil(this._state.clearStencil),t.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),t.cullFace(this._state.cullFace),t.depthFunc(this._state.depthFunction),t.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),t.depthMask(this._state.depthWrite),t.frontFace(this._state.frontFace),t.lineWidth(1),!0===this._state.faceCulling?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),t.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?t.enable(t.POLYGON_OFFSET_FILL):t.disable(t.POLYGON_OFFSET_FILL),t.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST),t.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),t.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),t.stencilMask(this._state.stencilWriteMask);for(let s=0;s<this.parameters.maxTextureImageUnits;s++){t.activeTexture(u+s),t.bindTexture(3553,null),t.bindTexture(34067,null),t.bindTexture(32879,null),t.bindTexture(35866,null),t.bindSampler(s,null);const e=this._state.textureUnitMap[s];null!=e&&t.bindTexture(e.descriptor.target,e.glName);const i=this._state.textureUnitSamplerMap[s];null!=i&&t.bindSampler(s,i?.glName)}t.activeTexture(u+this._state.activeTexture);const e=this._state.viewport;t.viewport(e.x,e.y,e.width,e.height),this.resetInfo()}};function w(t,e,s,i){return e?i!==e&&t.bindBuffer(s,e.glName):t.bindBuffer(s,null),e}function E(t,e){switch(t){case _.POINTS:return 2*e;case _.TRIANGLES:return e/3;case _.TRIANGLE_STRIP:case _.TRIANGLE_FAN:return e-2;default:return 0}}function S(t){return t?t.colorAttachments.length>0?t.colorAttachments:[f]:[o]}export{k as RenderingContext,S as getFramebufferDrawBuffers};
|
|
2
|
+
import has from"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{Milliseconds as i}from"../../core/time.js";import{webglDebugEnabled as a,checkWebGLError as r,getErrorMessage as n,webglValidateShadersEnabled as l}from"./checkWebGLError.js";import{ContextState as h}from"./ContextState.js";import{DrawBufferNone as f,DrawBufferBack as o,baseTextureUnit as u,ResourceType as c,ColorAttachment0 as d,PrimitiveType as _}from"./enums.js";import{InstanceCounter as b}from"./InstanceCounter.js";import{Parameters as g}from"./Parameters.js";import{ProgramCache as p}from"./ProgramCache.js";import{StateTracker as m}from"./renderState.js";import B from"./Texture.js";import{WebGLDriverTest as F}from"./WebGLDriverTest.js";import{Capabilities as T}from"./capabilities/Capabilities.js";const x=()=>t.getLogger("esri.views.webgl.RenderingContext");let k=class{constructor(t,e){this.gl=t,this.instanceCounter=new b,this._programCache=new p(this),this._transformFeedbackRequestInfo=null,this._state=new h,this._numOfDrawCalls=0,this._numOfTriangles=0,this._options=e,this.configure(e)}configure(t){this._options=t,this._capabilities=new T(this.gl,t),this._parameters=new g(this.gl,this._capabilities,t),B.TEXTURE_UNIT_FOR_UPDATES=this._parameters.maxTextureImageUnits-1;const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new h,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new m({setBlending:t=>{if(t){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(t.opRgb,t.opAlpha),this.setBlendFunctionSeparate(t.srcRgb,t.dstRgb,t.srcAlpha,t.dstAlpha);const e=t.color;this.setBlendColor(e.r,e.g,e.b,e.a)}else this.setBlendingEnabled(!1)},setCulling:t=>{t?(this.setFaceCullingEnabled(!0),this.setCullFace(t.face),this.setFrontFace(t.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:t=>{t?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(t.factor,t.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:t=>{t?(this.setDepthTestEnabled(!0),this.setDepthFunction(t.func)):this.setDepthTestEnabled(!1)},setStencilTest:t=>{if(t){this.setStencilTestEnabled(!0);const e=t.function;this.setStencilFunction(e.func,e.ref,e.mask);const s=t.operation;this.setStencilOp(s.fail,s.zFail,s.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:t=>{t?(this.setDepthWriteEnabled(!0),this.setDepthRange(t.zNear,t.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:t=>{t?this.setColorMask(t.r,t.g,t.b,t.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:t=>{t?this.setStencilWriteMask(t.mask):this.setStencilWriteMask(0)}}),this.enforceState(),e(this._driverTest),this._driverTest=new F(this)}updateOptions(t){this._options={...this._options,...t},this._parameters=new g(this.gl,this._capabilities,this._options)}dispose(){this._driverTest=e(this._driverTest),this._programCache=e(this._programCache),this.bindVAO(null),this.unbindBuffer(34962),this.unbindBuffer(34963),this.unbindBuffer(35345),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(35051),this.unbindBuffer(35052),this.unbindBuffer(36662),this.unbindBuffer(36663),this._state.textureUnitMap.length=0,this._state.textureUnitSamplerMap.length=0,this._state=null,this._capabilities=null,this._stateTracker=null;const t=this.instanceCounter.resourceInformation;a()&&t&&console.log(t)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}get programCache(){return this._programCache}setPipelineState(t){this._stateTracker.setPipeline(t)}getPipelineState(){return this._stateTracker.getPipelineState()}setBlendingEnabled(t){this._state.blend!==t&&(!0===t?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=t,this._stateTracker.invalidateBlending())}externalProgramUpdate(){this._state.program?.stop(),this._state.program=null}externalTextureUnitUpdate(t,e){for(let s=0;s<t.length;++s){const e=t[s];this._state.textureUnitMap[e]=null,this._state.textureUnitSamplerMap[e]=null}e>=0&&(this._state.activeTexture=e)}externalVertexArrayObjectUpdate(){this.gl.bindVertexArray(null),this._state.vertexArrayObject=null,this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=1032,this._state.stencilFunction.func=t,this._state.stencilFunction.ref=e,this._state.stencilFunction.mask=s,this._stateTracker.invalidateStencilTest())}setStencilFunctionSeparate(t,e,s,i){this._state.stencilFunction.face===t&&this._state.stencilFunction.func===e&&this._state.stencilFunction.ref===s&&this._state.stencilFunction.mask===i||(this.gl.stencilFuncSeparate(t,e,s,i),this._state.stencilFunction.face=t,this._state.stencilFunction.func=e,this._state.stencilFunction.ref=s,this._state.stencilFunction.mask=i,this._stateTracker.invalidateStencilTest())}setStencilWriteMask(t){this._state.stencilWriteMask!==t&&(this.gl.stencilMask(t),this._state.stencilWriteMask=t,this._stateTracker.invalidateStencilWrite())}setStencilOp(t,e,s){1032===this._state.stencilOperation.face&&this._state.stencilOperation.fail===t&&this._state.stencilOperation.zFail===e&&this._state.stencilOperation.zPass===s||(this.gl.stencilOp(t,e,s),this._state.stencilOperation.face=1032,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,s,i){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===s&&this._state.stencilOperation.zPass===i||(this.gl.stencilOpSeparate(t,e,s,i),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=s,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const s=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(u+t),this._state.activeTexture=t),s}setDrawBuffers(t){const{drawFramebuffer:e}=this._state,s=null===e,i=s?this._state.drawBuffers.defaultFramebuffer:this._state.drawBuffers.fbos.get(e)??[];if(i?.length===t.length&&i.every((e,s)=>e===t[s]))return i;if(t.length>this.parameters.maxDrawBuffers)return x().error(`Setting more active draw buffers (${t.length}) than GL.MAX_DRAW_BUFFERS allows ( ${this.parameters.maxDrawBuffers}).`),i;if(s){if(t.length>1)return x().error(`The default framebuffer can only have 1 active draw buffer but was requested with ${t.length}.`),i;if(t[0]!==o&&t[0]!==f)return x().error(`The default framebuffer can only use the constants GL.BACK or GL.NONE as draw buffers but got ${t[0]}`),i}else if(t.includes(o))return x().error("A framebuffer object can only use the constants GL.COLOR_ATTACHMENTx or GL.NONE as draw buffers."),i;return this.gl.drawBuffers(t),r(this.gl),s?this._state.drawBuffers.defaultFramebuffer=t:this._state.drawBuffers.fbos.set(e,t),i}clear(t,e=255){t&&(16384&t&&this.setColorMask(!0,!0,!0,!0),256&t&&this.setDepthWriteEnabled(!0),1024&t&&this.setStencilWriteMask(e),this.gl.clear(t))}clearFramebuffer(t,e=!1,s=!1){let i=0;if(t){const e=1e-13,s=Math.max(e,t[3]);this.setClearColor(t[0],t[1],t[2],s),i|=16384}e&&(i|=256),!1===s?s=0:(!0===s&&(s=255),i|=1024),i&&this.clear(i,s)}clearBuffer(t,e,s=6144,i){this.gl.clearBufferfv(s,t,e,i)}clearBufferInteger(t,e,s=6144,i){this.gl.clearBufferiv(s,t,e,i)}clearBufferUnsignedInteger(t,e,s=6144,i){this.gl.clearBufferuiv(s,t,e,i)}drawArrays(t,e,s){if(this._transformFeedbackRequestInfo){if(t!==this._transformFeedbackRequestInfo.primitiveType)throw new Error("DrawArrays called during transform feedback, but primitiveType does not match that of the current transform feedback request");if(null==this._state.program?.hasTransformFeedbackVaryings)throw new Error("DrawArrays called during transform feedback, but the shader program was not linked with a transform feedback varying")}if(a()&&(this._numOfDrawCalls++,this._numOfTriangles+=E(t,s),has("enable-feature:webgl-debug:textureReadWrite"))){const t=this._state.textureUnitMap;for(let e=0;e<t.length;e++){const s=t[e];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${e}`)}}this.gl.drawArrays(t,e,s),r(this.gl)}drawArraysInstanced(t,e,s,i){this.gl.drawArraysInstanced(t,e,s,i),r(this.gl)}drawElements(t,e,s,i){if(this._transformFeedbackRequestInfo)throw new Error("Cannot called drawElements during a transform feedback request");if(a()&&(this._numOfDrawCalls++,this._numOfTriangles+=E(t,e)),this.gl.drawElements(t,e,s,i),a()){const a=n(this.gl);if(a){const r=this.getBoundVAO(),n=r?.indexBuffer,l=r?.buffers,h={indexBuffer:n,vertexBuffers:l},f={mode:t,count:e,type:s,offset:i},o=n?.size??0,u=i+e,c=o<u?`. Buffer is too small. Attempted to draw index ${u} of ${o}`:"";x().error(`drawElements: ${a}${c}`,{args:f,vao:h})}}}drawElementsInstanced(t,e,s,i,a){this.gl.drawElementsInstanced(t,e,s,i,a),r(this.gl)}logInfo(){a()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){a()&&(this._numOfDrawCalls=0,this._numOfTriangles=0)}get capabilities(){return this._capabilities}setViewport(t,e,s,i){s=Math.max(Math.round(s),1),i=Math.max(Math.round(i),1);const a=this._state.viewport;a.x===t&&a.y===e&&a.width===s&&a.height===i||(a.x=t,a.y=e,a.width=s,a.height=i,this.gl.viewport(t,e,s,i))}setViewport4fv(t){this.setViewport(t[0],t[1],t[2],t[3])}restoreViewport({x:t,y:e,width:s,height:i}){this.setViewport(t,e,s,i)}getViewport(){const t=this._state.viewport;return{x:t.x,y:t.y,width:t.width,height:t.height}}useProgram(t){if(this._state.program!==t){if(t&&null==t.glName&&l())throw new Error("Attempting to use disposed or invalid Program");this._state.program?.stop(),this._state.program=t,this.gl.useProgram(t?.glName??null)}}bindTexture(t,e,s=!1,i=null){(e>=this.parameters.maxTextureImageUnits||e<0)&&x().error(`Input texture unit (${e}) is out of range of available units (0...${this.parameters.maxTextureImageUnits})\n `);const a=this._state.textureUnitMap[e],r=this._state.textureUnitSamplerMap[e],{gl:n}=this;return null==t?.glName?(null!=a&&(this.setActiveTexture(e,s),n.bindTexture(a.descriptor.target,null)),this._state.textureUnitMap[e]=null,null!=r&&(this._state.textureUnitSamplerMap[e]=null,n.bindSampler(e,null)),a):(r!==i&&(n.bindSampler(e,i?.glName??null),this._state.textureUnitSamplerMap[e]=i),s||a!==t?(this.setActiveTexture(e,s),n.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,a):(t.isDirty&&(this.setActiveTexture(e,s),t.applyChanges()),a))}unbindTexture(t){if(null!=t)for(let e=0;e<this.parameters.maxTextureImageUnits;e++)this._state.textureUnitMap[e]===t&&(this.bindTexture(null,e),this._state.textureUnitMap[e]=null)}bindFramebuffer(t,e=!1){const s=S(t);if(e||this._state.readFramebuffer!==t||this._state.drawFramebuffer!==t){if(null==t)return this.gl.bindFramebuffer(36160,null),this._state.readFramebuffer=this._state.drawFramebuffer=null,void this.setDrawBuffers(s);t.initializeAndBind(36160),this._state.readFramebuffer=t,this._state.drawFramebuffer=t,this.setDrawBuffers(s)}else this.setDrawBuffers(s)}bindFramebufferSeparate(t,e,s=!1){const i=36008===e,a=i?this._state.readFramebuffer:this._state.drawFramebuffer;(s||a!==t)&&(null==t?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),i?this._state.readFramebuffer=t??null:(this._state.drawFramebuffer=t??null,this.setDrawBuffers(S(t))))}blitFramebuffer(t,e,s=16384,i=9728,a=0,r=0,n=t.width,l=t.height,h=0,f=0,o=e.width,u=e.height){this.bindFramebufferSeparate(t,36008,!0),this.bindFramebufferSeparate(e,36009,!0),this.gl.blitFramebuffer(a,r,n,l,h,f,o,u,s,i)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case 34962:this._state.vertexBuffer=w(this.gl,t,e,this._state.vertexBuffer);break;case 34963:this._state.indexBuffer=w(this.gl,t,e,this._state.indexBuffer);break;case 35345:this._state.uniformBuffer=w(this.gl,t,e,this._state.uniformBuffer);break;case 35051:this._state.pixelPackBuffer=w(this.gl,t,e,this._state.pixelPackBuffer);break;case 35052:this._state.pixelUnpackBuffer=w(this.gl,t,e,this._state.pixelUnpackBuffer);break;case 36662:this._state.copyReadBuffer=w(this.gl,t,e,this._state.copyReadBuffer);break;case 36663:this._state.copyWriteBuffer=w(this.gl,t,e,this._state.copyWriteBuffer);break;case 35982:this._state.transformFeedbackBuffer=w(this.gl,t,e,this._state.transformFeedbackBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return x().error(`Uniform buffer binding point (${e}) is out of range (0...${this.parameters.maxUniformBufferBindings})\n `),null;const s=35345===t?this._state.uniformBufferBindingPoints:this._state.transformBufferBindingPoints;let i=s[e];return null==i&&(i={buffer:null,offset:0,size:0},s[e]=i),i}bindBufferBase(t,e,s){const i=this._getBufferBinding(t,e);null!=i&&(i.buffer===s&&0===i.offset&&0===i.size||(this.gl.bindBufferBase(t,e,s?s.glName:null),i.buffer=s,i.offset=0,i.size=0))}bindBufferRange(t,e,s,i,a){const r=this._getBufferBinding(t,e);null!=r&&(r.buffer===s&&r.offset===i&&r.size===a||(i%this._parameters.uniformBufferOffsetAlignment===0?(this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a):x().error("Uniform buffer binding offset is not a multiple of the context offset alignment")))}bindUBO(t,e,s,i){null!=e?(a()&&(i??e.byteLength)>this._parameters.maxUniformBlockSize&&x().error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==s&&void 0!==i?this.bindBufferRange(35345,t,e.buffer,s,i):this.bindBufferBase(35345,t,e.buffer)):this.bindBufferBase(35345,t,null)}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];null!=s&&s.buffer===t.buffer&&this.bindBufferBase(35345,e,null)}}unbindBuffer(t){switch(t){case 34962:this._state.vertexBuffer=w(this.gl,null,t,this._state.vertexBuffer);break;case 34963:this._state.indexBuffer=w(this.gl,null,t,this._state.indexBuffer);break;case 35345:this._state.uniformBuffer=w(this.gl,null,t,this._state.uniformBuffer);break;case 35051:this._state.pixelPackBuffer=w(this.gl,null,t,this._state.pixelPackBuffer);break;case 35052:this._state.pixelUnpackBuffer=w(this.gl,null,t,this._state.pixelUnpackBuffer);break;case 36662:this._state.copyReadBuffer=w(this.gl,null,t,this._state.copyReadBuffer);break;case 36663:this._state.copyWriteBuffer=w(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t,e){if(null==t)return this._state.vertexArrayObject?.unbind(),void(this._state.vertexArrayObject=null);this._state.vertexArrayObject!==t&&(t.bind(e),this._state.vertexArrayObject=t)}bindTransformFeedback(t){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,t.glName)}beginTransformFeedback(t,e){if(this._transformFeedbackRequestInfo)throw new Error("Already in a transform feedback request");const{gl:s}=this;s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,t.glName),s.beginTransformFeedback(e),this._transformFeedbackRequestInfo={primitiveType:e}}endTransformFeedback(){if(!this._transformFeedbackRequestInfo)throw new Error("Not in a transform feedback request");const{gl:t}=this;t.endTransformFeedback(),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),this._transformFeedbackRequestInfo=null}async clientWaitAsync(t=i(10)){const{gl:e}=this,a=e.fenceSync(37143,0);if(!a)throw new Error("Client wait failed, could not create sync object");let r;this.instanceCounter.increment(c.Sync,a),e.flush();do{await s(t),r=e.clientWaitSync(a,0,0)}while(37147===r);if(this.instanceCounter.decrement(c.Sync,a),e.deleteSync(a),37149===r)throw new Error("Client wait failed")}getBoundFramebufferObject(t=36160){return 36008===t?this._state.readFramebuffer:this._state.drawFramebuffer}temporaryBindFramebufferObject(t,e,s=!1){const i=this.getBoundFramebufferObject();try{this.bindFramebuffer(t,s),e()}finally{this.bindFramebuffer(i,s)}}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(34962),this.unbindBuffer(34963),this.unbindBuffer(35345),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(35051),this.unbindBuffer(35052),this.unbindBuffer(36662),this.unbindBuffer(36663);for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(1,0),this.setBlendEquation(32774),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(1029),this.setFrontFace(2305),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(513),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(519,0,0),this.setStencilOp(7680,7680,7680),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const{gl:t}=this;t.bindVertexArray(null);for(let s=0;s<this.parameters.maxVertexAttributes;s++)t.disableVertexAttribArray(s);this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(34962,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(34963,null),this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(35345,null);for(let s=0;s<this._parameters.maxUniformBufferBindings;s++){const e=this._state.uniformBufferBindingPoints[s];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?t.bindBufferBase(35345,s,i.glName):t.bindBufferRange(35345,s,i.glName,a,r):t.bindBufferBase(35345,s,null)}}if(this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(35051,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(35052,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(36662,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(36663,null),t.bindFramebuffer(36008,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(36008,this._state.readFramebuffer.glName),t.readBuffer(d)),t.bindFramebuffer(36009,this._state.drawFramebuffer?.glName??null),null===this._state.drawFramebuffer){const e=this._state.drawBuffers.defaultFramebuffer;t.drawBuffers(e??[o])}else{const e=this._state.drawBuffers.fbos.get(this._state.drawFramebuffer);t.drawBuffers(e??[d])}if(this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}t.useProgram(this._state.program?.glName??null),t.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),t.bindRenderbuffer(t.RENDERBUFFER,this._state.renderbuffer?.glName??null),!0===this._state.blend?t.enable(this.gl.BLEND):t.disable(this.gl.BLEND),t.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),t.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),t.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),t.clearDepth(this._state.clearDepth),t.clearStencil(this._state.clearStencil),t.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),t.cullFace(this._state.cullFace),t.depthFunc(this._state.depthFunction),t.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),t.depthMask(this._state.depthWrite),t.frontFace(this._state.frontFace),t.lineWidth(1),!0===this._state.faceCulling?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),t.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?t.enable(t.POLYGON_OFFSET_FILL):t.disable(t.POLYGON_OFFSET_FILL),t.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST),t.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),t.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),t.stencilMask(this._state.stencilWriteMask);for(let s=0;s<this.parameters.maxTextureImageUnits;s++){t.activeTexture(u+s),t.bindTexture(3553,null),t.bindTexture(34067,null),t.bindTexture(32879,null),t.bindTexture(35866,null),t.bindSampler(s,null);const e=this._state.textureUnitMap[s];null!=e&&t.bindTexture(e.descriptor.target,e.glName);const i=this._state.textureUnitSamplerMap[s];null!=i&&t.bindSampler(s,i?.glName)}t.activeTexture(u+this._state.activeTexture);const e=this._state.viewport;t.viewport(e.x,e.y,e.width,e.height),this.resetInfo()}};function w(t,e,s,i){return e?i!==e&&t.bindBuffer(s,e.glName):t.bindBuffer(s,null),e}function E(t,e){switch(t){case _.POINTS:return 2*e;case _.TRIANGLES:return e/3;case _.TRIANGLE_STRIP:case _.TRIANGLE_FAN:return e-2;default:return 0}}function S(t){return t?t.colorAttachments.length>0?t.colorAttachments:[f]:[o]}export{k as RenderingContext,S as getFramebufferDrawBuffers};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{loadCalciteComponents as t}from"../../support/componentsUtils.js";import e from"../../support/SketchTooltipControls.js";import o from"../../support/SnappingControls.js";import{tsx as i}from"../../support/widget.js";import s from"../../support/SketchTooltipControls/VisibleElements.js";import n from"../../support/SnappingControls/VisibleElements.js";const p={settingsContainer:"esri-editor__settings"},r=()=>t({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item")});function c({editorViewModel:t,messagesCommon:r,visibleElements:c}){const{snappingOptions:a,sketchOptions:l,view:m,snappingManager:g}=t,d=[],u={directionModePicker:c.directionModePicker,labelsToggle:c.labelsToggle,tooltipsToggle:c.tooltipsToggle};return Object.values(u).includes(!0)&&d.push(i(e,{sketchOptions:l,
|
|
2
|
+
import{loadCalciteComponents as t}from"../../support/componentsUtils.js";import e from"../../support/SketchTooltipControls.js";import o from"../../support/SnappingControls.js";import{tsx as i}from"../../support/widget.js";import s from"../../support/SketchTooltipControls/VisibleElements.js";import n from"../../support/SnappingControls/VisibleElements.js";const p={settingsContainer:"esri-editor__settings"},r=()=>t({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item")});function c({editorViewModel:t,messagesCommon:r,visibleElements:c}){const{snappingOptions:a,sketchOptions:l,view:m,snappingManager:g}=t,d=[],u={directionModePicker:c.directionModePicker,labelsToggle:c.labelsToggle,tooltipsToggle:c.tooltipsToggle};return Object.values(u).includes(!0)&&d.push(i(e,{sketchOptions:l,view:m,visibleElements:new s(u)})),c.snappingControls&&d.push(i(o,{afterCreate:t=>t.layerListOpen=!1,snappingManager:g,snappingOptions:a,view:m,visibleElements:c.snappingControlsElements??new n})),0===d.length?null:i("calcite-accordion",{appearance:"transparent",class:p.settingsContainer,key:"settings"},i("calcite-accordion-item",{"data-testid":"settings",heading:r.settings,iconStart:"gear"},d))}export{c as Settings,p as css,r as loadSettingsComponents};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as a,isAbortError as n}from"../../core/promiseUtils.js";import l from"../../core/ReactiveSet.js";import{watch as u,when as h,sync as c}from"../../core/reactiveUtils.js";import{property as d,subclass as p}from"../../core/accessorSupport/decorators.js";import g from"../../geometry/Point.js";import{initializeProjection as f,project as m}from"../../geometry/projectionUtils.js";import y from"../../geometry/SpatialReference.js";import{getPointFromGeometry as w}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as F}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as _}from"../../layers/LayerConstants.js";import v from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as C}from"../../symbols/support/symbolUtils.js";import{system as b}from"../../time/constants.js";import{highlightsSupported as P}from"../../views/support/layerViewUtils.js";import L from"../Feature/FeatureViewModel.js";import{ActionsCollection as M,zoomToFeature as A,zoomToClusteredFeatures as E,browseClusteredFeatures as V}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as I,getSelectedTarget as R,removeClusteredFeaturesForBrowsing as x,displayClusterExtent as O,browseAggregateFeatures as T}from"../Popup/actionUtils.js";import{AnchorElementViewModelMixin as U}from"../support/AnchorElementViewModel.js";import{GoTo as S}from"../support/GoTo.js";const B="location-scale-handle",H=()=>[A.clone()],G=()=>[E.clone(),V.clone()];let Z=null;function z(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let D=class extends(S(U(r))){constructor(e){super(e),this._pendingPromises=new l,this._fetchFeaturesController=null,this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this.actions=new M,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.selectedClusterBoundaryFeature=new t({symbol:new v({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=a(async e=>{this._cancelLocationUpdate();const t=new AbortController,{signal:i}=t;this._locationUpdateController=t,await this._locationUpdate(e,{signal:i}).catch(()=>{}).finally(()=>{this._locationUpdateController===t&&(this._locationUpdateController=null)})})}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),u(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),u(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),u(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),u(()=>this.location,e=>this._locationChange(e)),u(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),u(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),u(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),u(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>j({event:e,viewModel:this,view:this.view})),h(()=>!this.waitingForResult,()=>this._waitingForResultChange(),c),u(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),u(()=>this.view?.scale,()=>this._viewScaleChange()),h(()=>!this.visible,()=>this.browseClusterEnabled=!1),u(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelLocationUpdate(),this._cancelFetchingFeatures(),this._cancelCenterAtLocation(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new M;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new M;return e.removeAll(),e.addMany(I(this.selectedFeature)?G():H()),e}get featureCount(){return this.features.length}set features(e){if(this._get("features")===e)return;const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;"list"!==this.initialDisplayMode?o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1):(!o||o&&i===s)&&(this.selectedFeatureIndex=-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=F(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._get("promises")!==e&&(this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[]))}get screenLocation(){return super.screenLocation}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??b}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=R(this);this._cancelCenterAtLocation();const i=new AbortController,{signal:r}=i;return this._centerAtLocationController=i,t&&e?this.callGoTo({target:{target:t,scale:e.scale},options:{signal:r}}).catch(e=>{n(e)||o.getLogger(this).error(e)}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){x(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?I(t)?(await O(this),await T(this)):o.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):o.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}async handleViewClick(e){return this._fetchFeaturesAndOpen(e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(A.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(I(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&!this._locationUpdateController&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null==i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach((t,i)=>{t&&(t.graphic??=e[o+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),I(e))return;return e.symbol=await C(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await C(e)),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=w(e.geometry)}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(I(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let h=null;if(l.some((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h)),h)u[i]=h;else{const l=new L({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await f(r,i,null,t),s.toScreen(e)):null}_cancelCenterAtLocation(){this._centerAtLocationController?.abort(),this._centerAtLocationController=null}_cancelFetchingFeatures(){this._fetchFeaturesController?.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch(()=>{}).finally(()=>{this._fetchFeaturesController===s&&(this._fetchFeaturesController=null)}),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e;this.removeHandles(B),this.addHandles([u(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{n(e)||o.getLogger(this).error(e)})),h(()=>!this.visible,()=>{this.removeHandles(B)},{once:!0})],B);const{pendingFeatures:s}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});return{location:t??void 0,promises:s}}async _locationUpdate(e,t){const{spatialReference:i}=this,s=this.selectedFeature?.geometry?.type,r=this.location??e;if(s&&"mesh"!==s&&i&&r&&this.selectedFeature)if("point"!==s)try{const e=this.selectedFeature;let s=e.geometry;const o=this._getHighlightLayer(e),a=e.getObjectId();if(!o||!this.view)return;if(a){const e=this.view?.allLayerViews.find(e=>e.layer.uid===o.uid);if(!e||!("queryFeatures"in e))return;const r=e.createQuery();r.outSpatialReference=i,r.objectIds=[a],r.returnGeometry=!0;const{features:n}=await e.queryFeatures(r,t);s=n[0]?.geometry}if(!s||"mesh"===s.type)return;s=m(s,i),Z||(Z=await Promise.all([import("../../geometry/operators/intersectsOperator.js"),import("../../geometry/operators/proximityOperator.js")]));const[n,l]=Z;if(!n.execute(s,r)){const t=l.getNearestCoordinate(s,r).coordinate??r;this.selectedFeature===e&&(this.location=t)}}catch(a){n(a)||o.getLogger(this).error(a)}else this.location=w(this.selectedFeature.geometry)??r}_cancelLocationUpdate(){this._locationUpdateController?.abort(),this._locationUpdateController=null}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||_:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:s,view:r,visible:o}=this;if(!r||!s||!o)return;const a=this._getHighlightLayer(i);if(!a)return;const n=this._getHighlightLayerView(r,a);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&P(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,a,r.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([d()],D.prototype,"_fetchFeaturesController",void 0),e([d({type:M})],D.prototype,"actions",void 0),e([d({readOnly:!0})],D.prototype,"active",null),e([d()],D.prototype,"activeFeature",void 0),e([d({readOnly:!0})],D.prototype,"allActions",null),e([d()],D.prototype,"autoCloseEnabled",void 0),e([d()],D.prototype,"browseClusterEnabled",void 0),e([d()],D.prototype,"content",void 0),e([d({type:M,readOnly:!0})],D.prototype,"defaultActions",null),e([d({type:Boolean})],D.prototype,"defaultPopupTemplateEnabled",void 0),e([d({readOnly:!0})],D.prototype,"featureCount",null),e([d()],D.prototype,"featurePage",void 0),e([d({value:[]})],D.prototype,"features",null),e([d()],D.prototype,"featuresPerPage",void 0),e([d()],D.prototype,"featureMenuOpen",void 0),e([d()],D.prototype,"featureMenuTitle",void 0),e([d()],D.prototype,"featureViewModelAbilities",void 0),e([d({readOnly:!0})],D.prototype,"featureViewModels",void 0),e([d()],D.prototype,"highlightEnabled",void 0),e([d()],D.prototype,"includeDefaultActions",void 0),e([d()],D.prototype,"initialDisplayMode",void 0),e([d({type:g})],D.prototype,"location",null),e([d()],D.prototype,"map",null),e([d({readOnly:!0})],D.prototype,"pendingPromisesCount",null),e([d({readOnly:!0})],D.prototype,"promiseCount",null),e([d()],D.prototype,"promises",null),e([d({readOnly:!0})],D.prototype,"selectedClusterBoundaryFeature",void 0),e([d({value:null,readOnly:!0})],D.prototype,"selectedFeature",null),e([d({value:-1})],D.prototype,"selectedFeatureIndex",null),e([d({readOnly:!0})],D.prototype,"selectedFeatureViewModel",null),e([d({type:y})],D.prototype,"spatialReference",null),e([d({readOnly:!0})],D.prototype,"state",null),e([d()],D.prototype,"timeZone",null),e([d()],D.prototype,"title",void 0),e([d()],D.prototype,"updateLocationEnabled",void 0),e([d()],D.prototype,"view",void 0),e([d()],D.prototype,"visible",void 0),e([d({readOnly:!0})],D.prototype,"waitingForContents",null),e([d({readOnly:!0})],D.prototype,"waitingForResult",null),e([d()],D.prototype,"zoomFactor",void 0),e([d()],D.prototype,"zoomToLocation",void 0),e([d()],D.prototype,"centerAtLocation",null),D=e([p("esri.widgets.Features.FeaturesViewModel")],D);export{D as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as a,isAbortError as n}from"../../core/promiseUtils.js";import l from"../../core/ReactiveSet.js";import{watch as u,when as h,sync as c}from"../../core/reactiveUtils.js";import{property as d,subclass as p}from"../../core/accessorSupport/decorators.js";import g from"../../geometry/Point.js";import{initializeProjection as f,project as m}from"../../geometry/projectionUtils.js";import y from"../../geometry/SpatialReference.js";import{geographicToWebMercator as w}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as F}from"../../layers/LayerConstants.js";import _ from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as v}from"../../symbols/support/symbolUtils.js";import{system as C}from"../../time/constants.js";import{highlightsSupported as b}from"../../views/support/layerViewUtils.js";import P from"../Feature/FeatureViewModel.js";import{ActionsCollection as L,zoomToFeature as M,zoomToClusteredFeatures as A,browseClusteredFeatures as E}from"../Popup/actions.js";import{triggerAction as V,isClusterFeature as j,getSelectedTarget as I,removeClusteredFeaturesForBrowsing as x,displayClusterExtent as R,browseAggregateFeatures as O}from"../Popup/actionUtils.js";import{AnchorElementViewModelMixin as T}from"../support/AnchorElementViewModel.js";import{GoTo as U}from"../support/GoTo.js";const S="location-scale-handle",B=()=>[M.clone()],H=()=>[A.clone(),E.clone()];let G=null;function Z(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let z=class extends(U(T(r))){constructor(e){super(e),this._pendingPromises=new l,this._fetchFeaturesController=null,this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this.actions=new L,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.selectedClusterBoundaryFeature=new t({symbol:new _({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=a(async e=>{this._cancelLocationUpdate();const t=new AbortController,{signal:i}=t;this._locationUpdateController=t,await this._locationUpdate(e,{signal:i}).catch(()=>{}).finally(()=>{this._locationUpdateController===t&&(this._locationUpdateController=null)})})}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),u(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),u(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),u(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),u(()=>this.location,e=>this._locationChange(e)),u(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),u(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),u(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),u(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>V({event:e,viewModel:this,view:this.view})),h(()=>!this.waitingForResult,()=>this._waitingForResultChange(),c),u(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),u(()=>this.view?.scale,()=>this._viewScaleChange()),h(()=>!this.visible,()=>this.browseClusterEnabled=!1),u(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelLocationUpdate(),this._cancelFetchingFeatures(),this._cancelCenterAtLocation(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new L;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new L;return e.removeAll(),e.addMany(j(this.selectedFeature)?H():B()),e}get featureCount(){return this.features.length}set features(e){if(this._get("features")===e)return;const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;"list"!==this.initialDisplayMode?o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1):(!o||o&&i===s)&&(this.selectedFeatureIndex=-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=w(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._get("promises")!==e&&(this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[]))}get screenLocation(){return super.screenLocation}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??C}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);this._cancelCenterAtLocation();const i=new AbortController,{signal:r}=i;return this._centerAtLocationController=i,t&&e?this.callGoTo({target:{target:t,scale:e.scale},options:{signal:r}}).catch(e=>{n(e)||o.getLogger(this).error(e)}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){x(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?j(t)?(await R(this),await O(this)):o.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):o.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}async handleViewClick(e){return this._fetchFeaturesAndOpen(e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(M.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(j(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&!this._locationUpdateController&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null==i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach((t,i)=>{t&&(t.graphic??=e[o+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),j(e))return;return e.symbol=await v(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await v(e)),(i||!t)&&e.geometry){if("point"===e.geometry.type)return void(this.location=e.geometry);const t=await import("../../geometry/operators/labelPointOperator.js");return void(this.location=t.execute(e.geometry))}if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(j(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let h=null;if(l.some((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h)),h)u[i]=h;else{const l=new P({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await f(r,i,null,t),s.toScreen(e)):null}_cancelCenterAtLocation(){this._centerAtLocationController?.abort(),this._centerAtLocationController=null}_cancelFetchingFeatures(){this._fetchFeaturesController?.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch(()=>{}).finally(()=>{this._fetchFeaturesController===s&&(this._fetchFeaturesController=null)}),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e;this.removeHandles(S),this.addHandles([u(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{n(e)||o.getLogger(this).error(e)})),h(()=>!this.visible,()=>{this.removeHandles(S)},{once:!0})],S);const{pendingFeatures:s}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});return{location:t??void 0,promises:s}}async _locationUpdate(e,t){const{spatialReference:i}=this,s=this.selectedFeature?.geometry?.type,r=this.location??e;if(s&&"mesh"!==s&&i&&r&&this.selectedFeature){if("point"===s){const e=await import("../../geometry/operators/labelPointOperator.js");return void(this.location=e.execute(this.selectedFeature.geometry))}try{const e=this.selectedFeature;let s=e.geometry;const o=this._getHighlightLayer(e),a=e.getObjectId();if(!o||!this.view)return;if(a){const e=this.view?.allLayerViews.find(e=>e.layer.uid===o.uid);if(!e||!("queryFeatures"in e))return;const r=e.createQuery();r.outSpatialReference=i,r.objectIds=[a],r.returnGeometry=!0;const{features:n}=await e.queryFeatures(r,t);s=n[0]?.geometry}if(!s||"mesh"===s.type)return;s=m(s,i),G||(G=await Promise.all([import("../../geometry/operators/intersectsOperator.js"),import("../../geometry/operators/proximityOperator.js")]));const[n,l]=G;if(!n.execute(s,r)){const t=l.getNearestCoordinate(s,r).coordinate??r;this.selectedFeature===e&&(this.location=t)}}catch(a){n(a)||o.getLogger(this).error(a)}}}_cancelLocationUpdate(){this._locationUpdateController?.abort(),this._locationUpdateController=null}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(Z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||F:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:s,view:r,visible:o}=this;if(!r||!s||!o)return;const a=this._getHighlightLayer(i);if(!a)return;const n=this._getHighlightLayerView(r,a);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&b(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,a,r.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([d()],z.prototype,"_fetchFeaturesController",void 0),e([d({type:L})],z.prototype,"actions",void 0),e([d({readOnly:!0})],z.prototype,"active",null),e([d()],z.prototype,"activeFeature",void 0),e([d({readOnly:!0})],z.prototype,"allActions",null),e([d()],z.prototype,"autoCloseEnabled",void 0),e([d()],z.prototype,"browseClusterEnabled",void 0),e([d()],z.prototype,"content",void 0),e([d({type:L,readOnly:!0})],z.prototype,"defaultActions",null),e([d({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([d({readOnly:!0})],z.prototype,"featureCount",null),e([d()],z.prototype,"featurePage",void 0),e([d({value:[]})],z.prototype,"features",null),e([d()],z.prototype,"featuresPerPage",void 0),e([d()],z.prototype,"featureMenuOpen",void 0),e([d()],z.prototype,"featureMenuTitle",void 0),e([d()],z.prototype,"featureViewModelAbilities",void 0),e([d({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([d()],z.prototype,"highlightEnabled",void 0),e([d()],z.prototype,"includeDefaultActions",void 0),e([d()],z.prototype,"initialDisplayMode",void 0),e([d({type:g})],z.prototype,"location",null),e([d()],z.prototype,"map",null),e([d({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([d({readOnly:!0})],z.prototype,"promiseCount",null),e([d()],z.prototype,"promises",null),e([d({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([d({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([d({value:-1})],z.prototype,"selectedFeatureIndex",null),e([d({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([d({type:y})],z.prototype,"spatialReference",null),e([d({readOnly:!0})],z.prototype,"state",null),e([d()],z.prototype,"timeZone",null),e([d()],z.prototype,"title",void 0),e([d()],z.prototype,"updateLocationEnabled",void 0),e([d()],z.prototype,"view",void 0),e([d()],z.prototype,"visible",void 0),e([d({readOnly:!0})],z.prototype,"waitingForContents",null),e([d({readOnly:!0})],z.prototype,"waitingForResult",null),e([d()],z.prototype,"zoomFactor",void 0),e([d()],z.prototype,"zoomToLocation",void 0),e([d()],z.prototype,"centerAtLocation",null),z=e([p("esri.widgets.Features.FeaturesViewModel")],z);export{z as default};
|
package/widgets/Features.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{substitute as t,formatNumber as i}from"../intl.js";import o from"../core/Collection.js";import{deprecateWidget as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as l,initial as a,when as d}from"../core/reactiveUtils.js";import{waitAnimationFrame as c}from"../core/scheduling.js";import{throttle as u}from"../core/throttle.js";import{property as h,subclass as p}from"../core/accessorSupport/decorators.js";import{getPointFromGeometry as v}from"../geometry/support/geometryUtils.js";import{loadActionUtilsComponents as m,substituteActionImage as g,getActionStyles as w,renderAction as _}from"../support/actions/actionUtils.js";import M from"./Feature.js";import f from"./Spinner.js";import F from"./Widget.js";import{css as y}from"./Feature/resources.js";import{FeatureContentMixin as b}from"./Feature/support/FeatureContentMixin.js";import{css as I}from"./Features/css.js";import C from"./Features/FeaturesDrillIn.js";import A from"./Features/FeaturesViewModel.js";import x from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as T}from"./Popup/actions.js";import{zoomToLocation as N}from"./Popup/actionUtils.js";import{loadCalciteComponents as k}from"./support/componentsUtils.js";import{globalCss as O}from"./support/globalCss.js";import{Heading as E}from"./support/Heading.js";import{tsx as W,messageBundle as D,vmEvent as L}from"./support/widget.js";import{setFocus as B}from"./support/widgetUtils.js";const S="selected-index",j=0,R="features-spinner";function H(e){return e?.declaredClass.startsWith("esri.layers.")??!1}let V=class extends(b(F)){constructor(e,t){super(e,t),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._spinner=null,this._feature=null,this._focusAbortController=null,this._drillInFlowItems=new o,this._drillInWidget=new C({flowItems:this._drillInFlowItems}),this._rootNode=null,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._actionBarMenuNode=null,this.collapsed=!1,this.featureNavigationTop=!1,this.headerActions=new T,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new A,this.visibleElements=new x,this._previousFeature=()=>{this.viewModel.previous()},this._nextFeature=()=>{this.viewModel.next()},this._handleFeatureBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this._openFeatureMenu()},this._handleFeatureMenuBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this.featureMenuOpen&&this._closeFeatureMenu()},this._storeRootNode=e=>{this._rootNode=e},this._displaySpinnerThrottled=u(()=>this._displaySpinner(),j),!0!==e?.suppressDeprecationWarning&&s(n.getLogger(this),"Features","arcgis-features",{version:"4.34"}),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,l(()=>this.viewModel?.active,()=>this._toggleScreenLocationEnabled()),l(()=>this.viewModel?.active,e=>this._drillInWidget.closed=!e),l(()=>this.visibleElements?.closeButton,e=>this._drillInWidget.closable=e),l(()=>this.visibleElements?.spinner,e=>this._spinnerEnabledChange(e)),l(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),l(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),l(()=>[this.viewModel?.waitingForResult,this.viewModel?.location],()=>{this._hideSpinner(),this._displaySpinnerThrottled()}),l(()=>this.viewModel?.screenLocation,()=>this._closeOpenActionMenu()),l(()=>this.selectedFeatureWidget?.viewModel,()=>this._destroyDrillInFlowItemWidgets()),l(()=>this.featureMenuOpen,()=>this._drillInWidget.selectLastFlowItem="list"===this.initialDisplayMode||!this.featureMenuOpen,a),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]},()=>this._setTitleFromFeatureWidget()),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]},()=>this._setContentFromFeatureWidget()),l(()=>this.viewModel?.featureViewModels,()=>this._featureMenuViewportScrollTop()),l(()=>this._drillInFlowItems.length,()=>this._focusFlowItemNode()),this._drillInWidget.on("close",()=>this.close()),this._drillInWidget.on("exit",()=>this._destroyDrillInFlowItemWidgets()),this._drillInWidget.on("open-feature",({feature:e})=>this._openRelatedFeature(e)),this._drillInWidget.on("zoom-to-feature",({featureWidget:e})=>N(this.viewModel,e))])}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}loadDependencies(){return Promise.all([m(),k({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})])}destroy(){this._destroyDrillInFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._drillInWidget?.destroy(),this._focusAbortController?.abort()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&!!this.viewModel.selectedFeature&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&("list"===this.initialDisplayMode||!!this.title&&!!this.content)}get active(){return this.viewModel.active}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get icon(){return null}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get featureMenuTitle(){return this.viewModel.featureMenuTitle}set featureMenuTitle(e){this.viewModel.featureMenuTitle=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){const e=Array.from(this._drillInFlowItems).at(-1);if(!e)return null;const{flowType:t}=e;return"feature-association"===t||"feature-relationship"===t?e.graphic??null:null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_drillInFlowItems:i,timeZone:o,spatialReference:s,map:n}=this,{selectedFeatureViewModel:r}=this.viewModel,l={title:!1};return r?(e?(e.viewModel=r,e.visibleElements=l):this._feature=new M({flowItems:i,headingLevel:t+1,timeZone:o,spatialReference:s,map:n,viewModel:r,visibleElements:l,suppressDeprecationWarning:!0}),this._feature):null}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():n.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._focusFlowItemNode():n.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(S);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(d(()=>!this.viewModel.waitingForResult,()=>this._addSelectedFeatureIndexHandle(),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return W("div",{afterCreate:this._storeRootNode,bind:this,class:this.classes(I.base,O.widget,O.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),"list"===this.initialDisplayMode?this._renderFeaturePaginationText():this._renderFeatureMenuButton()]}_renderHeader(){return this.featureNavigationTop&&this._featureNavigationVisible?W("div",{class:I.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return!this.featureNavigationTop&&this._featureNavigationVisible?W("div",{class:I.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation()):null}_renderFeaturePaginationText(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n}=o;return W("div",{class:I.paginationText,key:"feature-pagination-text"},t(e.pageText,{index:i(n+1),total:i(s)}))}_renderFeatureMenuButton(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n,pendingPromisesCount:r}=o;return W("calcite-action",{bind:this,class:I.paginationMenuButton,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:r>0,onclick:this._handlePaginationMenuButton,text:t(e.pageText,{index:i(n+1),total:i(s)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return W("calcite-action-bar",{class:I.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},W("calcite-action-group",{scale:"s"},W("calcite-action",{class:I.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,text:e,title:e}),W("calcite-action",{icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,text:t,title:t})))}_renderFeatureMenuItem(e){const{initialDisplayMode:t}=this,{selectedFeatureViewModel:i,featureViewModels:o}=this.viewModel,s=e===i,n=o.indexOf(e);return W("calcite-list-item",{bind:this,"data-feature-index":n,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:s,onCalciteListItemSelect:this._selectFeature},W("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}),"list"===t?W("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}):null)}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach(e=>{const i=e?.graphic;if(!i)return;const{layer:o,sourceLayer:s}=i,n=(H(o)?o:null)||(H(s)?s:null),r=t.get(n)??[];t.set(n,[...r,e])}),t}_renderFeatureMenu(){const{messages:e,viewModel:t}=this,i=this._groupResultsByLayer(),o="list"===this.initialDisplayMode?"none":"single";return t.featureViewModels.length?W("calcite-list",{displayMode:"flat",label:e?.featuresList,selectionAppearance:"icon",selectionMode:o},Array.from(i.keys(),e=>{const t=i.get(e)?.map(e=>this._renderFeatureMenuItem(e)),o=e?e.title??this.messagesCommon.untitled:null;return this.visibleElements.featureListLayerTitle&&null!==o?W("calcite-list-item-group",{heading:o,key:e?.uid||"map-graphics"},t):t})):null}_renderHeaderAction(e,t){const i=e.title||"";return e.visible?W("calcite-action",{active:"toggle"===e.type&&e.value,bind:this,"data-action-id":e.id,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon??void 0,indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,slot:"header-actions-end",text:i,title:i}):null}_renderHeaderActions(){return this.headerActions.map((e,t)=>this._renderHeaderAction(e,t)).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s,_drillInFlowItems:n,initialDisplayMode:r,selectedFeature:l,featureMenuOpen:a}=this,{title:d,active:c}=this.viewModel,u=t.heading&&d?d:"";if("list"===r&&!l)return null;const h=0===n.length&&("list"===r?!!l:!a);return W("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,bind:this,class:this.classes({[I.contentFeature]:!0,[I.flowItemCollapsed]:i}),closable:t.closeButton,closed:!c,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",selected:h,onCalciteFlowItemBack:this._handleFeatureBack,onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},u?W(E,{class:this.classes(I.featuresHeading,O.heading),innerHTML:u,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),W("div",{class:this.classes(I.container,I.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,visibleElements:i,featureMenuTitle:o,messages:s,messagesCommon:n,initialDisplayMode:r,featureMenuOpen:l,selectedFeature:a,_collapseEnabled:d,_isCollapsed:c,featureNavigationTop:u,headingLevel:h}=this,{active:p,featureViewModels:v,pendingPromisesCount:m}=e,{featureMenuHeading:g}=i,w=o??s.selectFeature;if("feature"===r&&!l)return null;const _="list"===r?!a:l;return W("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,bind:this,class:this.classes({[I.flowItemCollapsed]:c}),closable:"list"===r&&i.closeButton,closed:!p,collapsed:"list"===r&&c,collapseDirection:u?"down":"up",collapsible:"list"===r&&d,description:g?t(s.total,{total:v.length}):void 0,heading:g?w:void 0,headingLevel:h,key:"feature-menu",loading:e.waitingForContents,selected:_,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleFeatureMenuBack()},onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},"list"===r?this._renderHeaderActions():null,m>0?W("calcite-loader",{class:I.loader,inline:!0,key:"feature-menu-loader",label:n.loading,slot:"header-actions-end"}):null,W("div",{class:I.container},this._renderFeatureMenu()),W("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:I.featureMenuObserver}),"feature"===r?W("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-start",width:"full"},n.back):null)}_renderContentContainer(){const e="list"===this.initialDisplayMode?[this._renderFeatureMenuContainer(),this._renderContentFeature(),this._drillInWidget.render()]:[this._renderContentFeature(),this._drillInWidget.render(),this._renderFeatureMenuContainer()];return this.visibleElements.flow?W("calcite-flow",{key:"content-container"},e):e}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=g({action:e,feature:this.selectedFeature}),s={[I.icon]:!!t,[I.actionImage]:!!o};return t&&(s[t]=!0),o||t?W("span",{"aria-hidden":"true",class:this.classes(I.icon,s),key:"icon",styles:w(o)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?W("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},W("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map((e,t)=>{const i=this._getActionTitle(e);return _(e,{key:`action-${t}`,title:i,text:i,textEnabled:!this._hideActionText,onclick:this._triggerAction,bind:this},this._getFallbackIcon(e))})}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?W("div",{class:y.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyDrillInFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=v(i);this.open({features:[t],location:null!=o?o:void 0}),this._focusFlowItemNode()}_handlePaginationMenuButton(){this._updateFeatureMenu()}_openFeatureMenu(){this._updateFeatureMenu(!0)}_closeFeatureMenu(){this._updateFeatureMenu(!1)}_updateFeatureMenu(e=!this.featureMenuOpen){this.featureMenuOpen=e,this._focusFlowItemNode()}async _focusFlowItemNode(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await r(c(e));const t=this._rootNode?.querySelector("calcite-flow-item[selected]");B(t)}_storeRootFlowItemNode(e){this._rootFlowItemNode=e}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),"feature"===this.initialDisplayMode?this._handleFeatureMenuBack():this._focusFlowItemNode()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionTitle(e){const{messages:i,selectedFeature:o,messagesCommon:s}=this,{id:n}=e,r=o?.attributes,l=e.title??"",a="zoom-to-feature"===n?t(l,{messages:i}):"remove-selected-feature"===n?t(l,{messages:s}):"zoom-to-clustered-features"===n||"browse-clustered-features"===n?t(l,{messages:i}):e.title;return a&&r?t(a,r):a??""}_onMainKeydown(e){const{key:t}=e;"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode?.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=l(()=>this.viewModel?.selectedFeatureIndex,(e,t)=>this._selectedFeatureIndexUpdated(e,t));this.addHandles(e,S)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyDrillInFlowItemWidgets(),this._rootFlowItemNode?.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find(({uid:e})=>e===i);o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex(e=>e.uid===i),n=o.at(s);"toggle"===n?.type&&(n.value=!n.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new f({view:e}),e.ui.add(this._spinner,{key:R,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_destroyDrillInFlowItemWidgets(){this._drillInFlowItems.drain(e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),"activeCategory"in e.viewModel&&(e.viewModel.activeCategory=null),e.viewModel=null,e.destroy()})}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e}=this;e&&(e.view?.ui?.remove(e,R),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([h()],V.prototype,"_drillInFlowItems",void 0),e([h()],V.prototype,"_hideActionText",null),e([h()],V.prototype,"_featureNavigationVisible",null),e([h()],V.prototype,"_isCollapsed",null),e([h()],V.prototype,"_collapseEnabled",null),e([h({readOnly:!0})],V.prototype,"active",null),e([h()],V.prototype,"collapsed",void 0),e([h()],V.prototype,"content",null),e([h()],V.prototype,"icon",null),e([h()],V.prototype,"featureMenuOpen",null),e([h()],V.prototype,"featureMenuTitle",null),e([h()],V.prototype,"featureNavigationTop",void 0),e([h()],V.prototype,"features",null),e([h()],V.prototype,"goToOverride",null),e([h({type:T})],V.prototype,"headerActions",void 0),e([h()],V.prototype,"headingLevel",void 0),e([h()],V.prototype,"initialDisplayMode",null),e([h()],V.prototype,"location",null),e([h()],V.prototype,"label",null),e([h()],V.prototype,"map",null),e([h(),D("esri/widgets/Features/t9n/Features")],V.prototype,"messages",void 0),e([h(),D("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([h()],V.prototype,"promises",null),e([h()],V.prototype,"responsiveActionsEnabled",void 0),e([h({readOnly:!0})],V.prototype,"selectedFeature",null),e([h({readOnly:!0})],V.prototype,"selectedDrillInFeature",null),e([h()],V.prototype,"selectedFeatureIndex",null),e([h({readOnly:!0})],V.prototype,"selectedFeatureWidget",null),e([h()],V.prototype,"spatialReference",null),e([h()],V.prototype,"title",null),e([h()],V.prototype,"timeZone",null),e([h()],V.prototype,"updateLocationEnabled",null),e([h()],V.prototype,"view",null),e([h({type:A}),L(["triggerAction","trigger-action"])],V.prototype,"viewModel",void 0),e([h({type:x,nonNullable:!0})],V.prototype,"visibleElements",void 0),e([h()],V.prototype,"visible",null),V=e([p("esri.widgets.Features")],V);export{V as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{substitute as t,formatNumber as i}from"../intl.js";import o from"../core/Collection.js";import{deprecateWidget as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as l,initial as a,when as d}from"../core/reactiveUtils.js";import{waitAnimationFrame as c}from"../core/scheduling.js";import{throttle as u}from"../core/throttle.js";import{property as h,subclass as p}from"../core/accessorSupport/decorators.js";import{loadActionUtilsComponents as v,substituteActionImage as m,getActionStyles as g,renderAction as w}from"../support/actions/actionUtils.js";import _ from"./Feature.js";import M from"./Spinner.js";import f from"./Widget.js";import{css as F}from"./Feature/resources.js";import{FeatureContentMixin as y}from"./Feature/support/FeatureContentMixin.js";import{css as b}from"./Features/css.js";import I from"./Features/FeaturesDrillIn.js";import C from"./Features/FeaturesViewModel.js";import A from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as x}from"./Popup/actions.js";import{zoomToLocation as T}from"./Popup/actionUtils.js";import{loadCalciteComponents as N}from"./support/componentsUtils.js";import{globalCss as k}from"./support/globalCss.js";import{Heading as O}from"./support/Heading.js";import{tsx as E,messageBundle as W,vmEvent as D}from"./support/widget.js";import{setFocus as L}from"./support/widgetUtils.js";const B="selected-index",S=0,j="features-spinner";function R(e){return e?.declaredClass.startsWith("esri.layers.")??!1}let H=class extends(y(f)){constructor(e,t){super(e,t),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._spinner=null,this._feature=null,this._focusAbortController=null,this._drillInFlowItems=new o,this._drillInWidget=new I({flowItems:this._drillInFlowItems}),this._rootNode=null,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._actionBarMenuNode=null,this.collapsed=!1,this.featureNavigationTop=!1,this.headerActions=new x,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new C,this.visibleElements=new A,this._previousFeature=()=>{this.viewModel.previous()},this._nextFeature=()=>{this.viewModel.next()},this._handleFeatureBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this._openFeatureMenu()},this._handleFeatureMenuBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this.featureMenuOpen&&this._closeFeatureMenu()},this._storeRootNode=e=>{this._rootNode=e},this._displaySpinnerThrottled=u(()=>this._displaySpinner(),S),!0!==e?.suppressDeprecationWarning&&s(n.getLogger(this),"Features","arcgis-features",{version:"4.34"}),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,l(()=>this.viewModel?.active,()=>this._toggleScreenLocationEnabled()),l(()=>this.viewModel?.active,e=>this._drillInWidget.closed=!e),l(()=>this.visibleElements?.closeButton,e=>this._drillInWidget.closable=e),l(()=>this.visibleElements?.spinner,e=>this._spinnerEnabledChange(e)),l(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),l(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),l(()=>[this.viewModel?.waitingForResult,this.viewModel?.location],()=>{this._hideSpinner(),this._displaySpinnerThrottled()}),l(()=>this.viewModel?.screenLocation,()=>this._closeOpenActionMenu()),l(()=>this.selectedFeatureWidget?.viewModel,()=>this._destroyDrillInFlowItemWidgets()),l(()=>this.featureMenuOpen,()=>this._drillInWidget.selectLastFlowItem="list"===this.initialDisplayMode||!this.featureMenuOpen,a),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]},()=>this._setTitleFromFeatureWidget()),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]},()=>this._setContentFromFeatureWidget()),l(()=>this.viewModel?.featureViewModels,()=>this._featureMenuViewportScrollTop()),l(()=>this._drillInFlowItems.length,()=>this._focusFlowItemNode()),this._drillInWidget.on("close",()=>this.close()),this._drillInWidget.on("exit",()=>this._destroyDrillInFlowItemWidgets()),this._drillInWidget.on("open-feature",({feature:e})=>this._openRelatedFeature(e)),this._drillInWidget.on("zoom-to-feature",({featureWidget:e})=>T(this.viewModel,e))])}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}loadDependencies(){return Promise.all([v(),N({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})])}destroy(){this._destroyDrillInFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._drillInWidget?.destroy(),this._focusAbortController?.abort()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&!!this.viewModel.selectedFeature&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&("list"===this.initialDisplayMode||!!this.title&&!!this.content)}get active(){return this.viewModel.active}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get icon(){return null}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get featureMenuTitle(){return this.viewModel.featureMenuTitle}set featureMenuTitle(e){this.viewModel.featureMenuTitle=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){const e=Array.from(this._drillInFlowItems).at(-1);if(!e)return null;const{flowType:t}=e;return"feature-association"===t||"feature-relationship"===t?e.graphic??null:null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_drillInFlowItems:i,timeZone:o,spatialReference:s,map:n}=this,{selectedFeatureViewModel:r}=this.viewModel,l={title:!1};return r?(e?(e.viewModel=r,e.visibleElements=l):this._feature=new _({flowItems:i,headingLevel:t+1,timeZone:o,spatialReference:s,map:n,viewModel:r,visibleElements:l,suppressDeprecationWarning:!0}),this._feature):null}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():n.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._focusFlowItemNode():n.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(B);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(d(()=>!this.viewModel.waitingForResult,()=>this._addSelectedFeatureIndexHandle(),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return E("div",{afterCreate:this._storeRootNode,bind:this,class:this.classes(b.base,k.widget,k.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),"list"===this.initialDisplayMode?this._renderFeaturePaginationText():this._renderFeatureMenuButton()]}_renderHeader(){return this.featureNavigationTop&&this._featureNavigationVisible?E("div",{class:b.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return!this.featureNavigationTop&&this._featureNavigationVisible?E("div",{class:b.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation()):null}_renderFeaturePaginationText(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n}=o;return E("div",{class:b.paginationText,key:"feature-pagination-text"},t(e.pageText,{index:i(n+1),total:i(s)}))}_renderFeatureMenuButton(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n,pendingPromisesCount:r}=o;return E("calcite-action",{bind:this,class:b.paginationMenuButton,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:r>0,onclick:this._handlePaginationMenuButton,text:t(e.pageText,{index:i(n+1),total:i(s)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return E("calcite-action-bar",{class:b.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},E("calcite-action-group",{scale:"s"},E("calcite-action",{class:b.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,text:e,title:e}),E("calcite-action",{icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,text:t,title:t})))}_renderFeatureMenuItem(e){const{initialDisplayMode:t}=this,{selectedFeatureViewModel:i,featureViewModels:o}=this.viewModel,s=e===i,n=o.indexOf(e);return E("calcite-list-item",{bind:this,"data-feature-index":n,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:s,onCalciteListItemSelect:this._selectFeature},E("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}),"list"===t?E("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}):null)}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach(e=>{const i=e?.graphic;if(!i)return;const{layer:o,sourceLayer:s}=i,n=(R(o)?o:null)||(R(s)?s:null),r=t.get(n)??[];t.set(n,[...r,e])}),t}_renderFeatureMenu(){const{messages:e,viewModel:t}=this,i=this._groupResultsByLayer(),o="list"===this.initialDisplayMode?"none":"single";return t.featureViewModels.length?E("calcite-list",{displayMode:"flat",label:e?.featuresList,selectionAppearance:"icon",selectionMode:o},Array.from(i.keys(),e=>{const t=i.get(e)?.map(e=>this._renderFeatureMenuItem(e)),o=e?e.title??this.messagesCommon.untitled:null;return this.visibleElements.featureListLayerTitle&&null!==o?E("calcite-list-item-group",{heading:o,key:e?.uid||"map-graphics"},t):t})):null}_renderHeaderAction(e,t){const i=e.title||"";return e.visible?E("calcite-action",{active:"toggle"===e.type&&e.value,bind:this,"data-action-id":e.id,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon??void 0,indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,slot:"header-actions-end",text:i,title:i}):null}_renderHeaderActions(){return this.headerActions.map((e,t)=>this._renderHeaderAction(e,t)).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s,_drillInFlowItems:n,initialDisplayMode:r,selectedFeature:l,featureMenuOpen:a}=this,{title:d,active:c}=this.viewModel,u=t.heading&&d?d:"";if("list"===r&&!l)return null;const h=0===n.length&&("list"===r?!!l:!a);return E("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,bind:this,class:this.classes({[b.contentFeature]:!0,[b.flowItemCollapsed]:i}),closable:t.closeButton,closed:!c,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",selected:h,onCalciteFlowItemBack:this._handleFeatureBack,onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},u?E(O,{class:this.classes(b.featuresHeading,k.heading),innerHTML:u,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),E("div",{class:this.classes(b.container,b.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,visibleElements:i,featureMenuTitle:o,messages:s,messagesCommon:n,initialDisplayMode:r,featureMenuOpen:l,selectedFeature:a,_collapseEnabled:d,_isCollapsed:c,featureNavigationTop:u,headingLevel:h}=this,{active:p,featureViewModels:v,pendingPromisesCount:m}=e,{featureMenuHeading:g}=i,w=o??s.selectFeature;if("feature"===r&&!l)return null;const _="list"===r?!a:l;return E("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,bind:this,class:this.classes({[b.flowItemCollapsed]:c}),closable:"list"===r&&i.closeButton,closed:!p,collapsed:"list"===r&&c,collapseDirection:u?"down":"up",collapsible:"list"===r&&d,description:g?t(s.total,{total:v.length}):void 0,heading:g?w:void 0,headingLevel:h,key:"feature-menu",loading:e.waitingForContents,selected:_,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleFeatureMenuBack()},onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},"list"===r?this._renderHeaderActions():null,m>0?E("calcite-loader",{class:b.loader,inline:!0,key:"feature-menu-loader",label:n.loading,slot:"header-actions-end"}):null,E("div",{class:b.container},this._renderFeatureMenu()),E("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:b.featureMenuObserver}),"feature"===r?E("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-start",width:"full"},n.back):null)}_renderContentContainer(){const e="list"===this.initialDisplayMode?[this._renderFeatureMenuContainer(),this._renderContentFeature(),this._drillInWidget.render()]:[this._renderContentFeature(),this._drillInWidget.render(),this._renderFeatureMenuContainer()];return this.visibleElements.flow?E("calcite-flow",{key:"content-container"},e):e}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=m({action:e,feature:this.selectedFeature}),s={[b.icon]:!!t,[b.actionImage]:!!o};return t&&(s[t]=!0),o||t?E("span",{"aria-hidden":"true",class:this.classes(b.icon,s),key:"icon",styles:g(o)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?E("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},E("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map((e,t)=>{const i=this._getActionTitle(e);return w(e,{key:`action-${t}`,title:i,text:i,textEnabled:!this._hideActionText,onclick:this._triggerAction,bind:this},this._getFallbackIcon(e))})}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?E("div",{class:F.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyDrillInFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=(await import("../geometry/operators/labelPointOperator.js")).execute(i);this.open({features:[t],location:null!=o?o:void 0}),this._focusFlowItemNode()}_handlePaginationMenuButton(){this._updateFeatureMenu()}_openFeatureMenu(){this._updateFeatureMenu(!0)}_closeFeatureMenu(){this._updateFeatureMenu(!1)}_updateFeatureMenu(e=!this.featureMenuOpen){this.featureMenuOpen=e,this._focusFlowItemNode()}async _focusFlowItemNode(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await r(c(e));const t=this._rootNode?.querySelector("calcite-flow-item[selected]");L(t)}_storeRootFlowItemNode(e){this._rootFlowItemNode=e}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),"feature"===this.initialDisplayMode?this._handleFeatureMenuBack():this._focusFlowItemNode()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionTitle(e){const{messages:i,selectedFeature:o,messagesCommon:s}=this,{id:n}=e,r=o?.attributes,l=e.title??"",a="zoom-to-feature"===n?t(l,{messages:i}):"remove-selected-feature"===n?t(l,{messages:s}):"zoom-to-clustered-features"===n||"browse-clustered-features"===n?t(l,{messages:i}):e.title;return a&&r?t(a,r):a??""}_onMainKeydown(e){const{key:t}=e;"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode?.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=l(()=>this.viewModel?.selectedFeatureIndex,(e,t)=>this._selectedFeatureIndexUpdated(e,t));this.addHandles(e,B)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyDrillInFlowItemWidgets(),this._rootFlowItemNode?.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find(({uid:e})=>e===i);o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex(e=>e.uid===i),n=o.at(s);"toggle"===n?.type&&(n.value=!n.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new M({view:e}),e.ui.add(this._spinner,{key:j,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_destroyDrillInFlowItemWidgets(){this._drillInFlowItems.drain(e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),"activeCategory"in e.viewModel&&(e.viewModel.activeCategory=null),e.viewModel=null,e.destroy()})}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e}=this;e&&(e.view?.ui?.remove(e,j),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([h()],H.prototype,"_drillInFlowItems",void 0),e([h()],H.prototype,"_hideActionText",null),e([h()],H.prototype,"_featureNavigationVisible",null),e([h()],H.prototype,"_isCollapsed",null),e([h()],H.prototype,"_collapseEnabled",null),e([h({readOnly:!0})],H.prototype,"active",null),e([h()],H.prototype,"collapsed",void 0),e([h()],H.prototype,"content",null),e([h()],H.prototype,"icon",null),e([h()],H.prototype,"featureMenuOpen",null),e([h()],H.prototype,"featureMenuTitle",null),e([h()],H.prototype,"featureNavigationTop",void 0),e([h()],H.prototype,"features",null),e([h()],H.prototype,"goToOverride",null),e([h({type:x})],H.prototype,"headerActions",void 0),e([h()],H.prototype,"headingLevel",void 0),e([h()],H.prototype,"initialDisplayMode",null),e([h()],H.prototype,"location",null),e([h()],H.prototype,"label",null),e([h()],H.prototype,"map",null),e([h(),W("esri/widgets/Features/t9n/Features")],H.prototype,"messages",void 0),e([h(),W("esri/t9n/common")],H.prototype,"messagesCommon",void 0),e([h()],H.prototype,"promises",null),e([h()],H.prototype,"responsiveActionsEnabled",void 0),e([h({readOnly:!0})],H.prototype,"selectedFeature",null),e([h({readOnly:!0})],H.prototype,"selectedDrillInFeature",null),e([h()],H.prototype,"selectedFeatureIndex",null),e([h({readOnly:!0})],H.prototype,"selectedFeatureWidget",null),e([h()],H.prototype,"spatialReference",null),e([h()],H.prototype,"title",null),e([h()],H.prototype,"timeZone",null),e([h()],H.prototype,"updateLocationEnabled",null),e([h()],H.prototype,"view",null),e([h({type:C}),D(["triggerAction","trigger-action"])],H.prototype,"viewModel",void 0),e([h({type:A,nonNullable:!0})],H.prototype,"visibleElements",void 0),e([h()],H.prototype,"visible",null),H=e([p("esri.widgets.Features")],H);export{H as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{getAssetUrl as t}from"../../assets.js";import s from"../../Graphic.js";import r from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{EventedAccessor as l}from"../../core/Evented.js";import a from"../../core/Logger.js";import{mappedFind as n}from"../../core/maybe.js";import{eachAlways as u,after as c}from"../../core/promiseUtils.js";import{watch as h,initial as p,whenOnce as g}from"../../core/reactiveUtils.js";import{property as d,subclass as m}from"../../core/accessorSupport/decorators.js";import y from"../../geometry/Point.js";import f from"../../geometry/SpatialReference.js";import{getPointFromGeometry as S,getPointWithElevation as _}from"../../geometry/support/geometryUtils.js";import v from"../../portal/Portal.js";import{isApiKeyApplicable as w}from"../../support/apiKeyUtils.js";import b from"../../symbols/PictureMarkerSymbol.js";import x from"../../symbols/SimpleFillSymbol.js";import L from"../../symbols/SimpleLineSymbol.js";import I from"../../symbols/TextSymbol.js";import{highlightsSupported as T}from"../../views/support/layerViewUtils.js";import R from"./LayerSearchSource.js";import E from"./LocatorSearchSource.js";import{SourceCollection as F}from"./types.js";import{isArcGISWorldGeocoder as P,meteredArcGISLocatorUrl as j,isProxiedArcGISWorldGeocoder as C,isMeteredArcGISWorldGeocoder as G}from"./support/locatorUtils.js";import{supported as O,getCurrentPosition as A,positionToPoint as N}from"../support/geolocationUtils.js";import{GoTo as D}from"../support/GoTo.js";function M(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const V="highlight",J=f.WGS84,U="esri/images/search/search-symbol-32.png",H=/<[\s\S]*?>/g,k=-1;let B=class extends(D(l)){constructor(e){super(e),this._defaultPopupTemplate=new r({content:"{Match_addr}"}),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultSources=new F,this.defaultSymbols={point:new b({url:t(U),size:24,width:24,height:24}),polyline:new L({color:[130,130,130,1],width:2}),polygon:new x({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=v.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.resultLocation=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new F,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){this.addHandles([h(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),p),h(()=>this.messages,()=>{this._defaultPopupTemplate.title=this.messages?.searchResult??"",this._update()},p)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=k}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:k}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:s}=this,r="function"==typeof s?s.call(null,{sources:e,defaultSources:t}):s?t.concat(e):e,o=this._get("allSources")||new F;return o.removeAll(),o.addMany(r.filter(Boolean)),o}get defaultPopupTemplate(){return this._defaultPopupTemplate}set defaultPopupTemplate(e){this._overrideIfSome("defaultPopupTemplate",e)}get locationEnabled(){return this._get("locationEnabled")||O()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=O();if(e&&!t){const e=new i("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});a.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:s}=this;if(t===k)return s??"";const r=e.at(t);return r?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultLocation",null),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const s=this._createSuggestionForSearch(e),r=(async()=>{try{await this.when();const e=await this._getResultsFromSources(s,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:s.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(r,e,s);const o=this._getFirstResult(r.results),i=s.location&&o?o.name:s.text,l=i?.replaceAll(H,"");return this._set("searchTerm",l),(s.key&&"number"==typeof s.sourceIndex||s.location)&&this._set("selectedSuggestion",s),this._set("results",r.results),this._set("resultCount",r.results.reduce((e,t)=>e+(t.results?.length??0),0)),this.emit("search-complete",r),await this._selectFirstResult(o),r}finally{this._clearSearching()}})();return this._searching=r,r}async searchNearby(e){if(!this.locationEnabled){const e=new i("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw a.getLogger(this).error(e),e}const t=(async()=>{try{const t=await A(),s=await N({position:t,view:this.view},e);return await this.search(s,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new i("select:missing-parameter","Cannot select without a searchResult.",{value:e});throw a.getLogger(this).error(t),t}const{view:t}=this,r=M(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=r?this.allSources.at(r):null;if(!o){const e=new i("select:missing-source","Cannot select without a source.",{source:o});throw a.getLogger(this).error(e),e}const l=o instanceof R?this._getLayerSourcePopupTemplate(o):o.popupTemplate,n=o.resultSymbol||this._getDefaultSymbol(e),c=M(o,"resultGraphicEnabled")?!!o.resultGraphicEnabled:this.resultGraphicEnabled,h=M(o,"autoNavigate")?!!o.autoNavigate:this.autoNavigate,p=M(o,"popupEnabled")?!!o.popupEnabled:this.popupEnabled,g=p?l||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new i("select:missing-feature","Cannot select without a feature.",{feature:d});throw a.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:v}=d,w=y?S(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?_(w,t):Promise.resolve(w)},x=await u(b),L=x.layerViewQuery.value,E=x.elevationQuery.value;n instanceof I&&(n.text=e.name);const F=t&&h?e.target||e.extent:null,P=null!=F?this._goToSearchResult(F):Promise.resolve();await P;const j=L?d:new s({geometry:y,symbol:n,attributes:m,layer:f,sourceLayer:v,popupTemplate:g});return L&&T(L)&&!p&&this._highlightFeature({graphic:j,layerView:L}),!L&&c&&t&&t.graphics.push(j),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",j),this._set("resultLocation",E),this.emit("select-result",{popupEnabled:p,result:e,source:o,sourceIndex:r}),e}async suggest(e,t,s){const r=e||this.searchTerm;this.emit("suggest-start",{searchTerm:r}),await this._suggestTimer(t,s);const o=await this._suggestImmediate(r,s);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce((e,t)=>e+(t.results?.length??0),0)??null),this.emit("suggest-complete",o),o}async when(){await g(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const s=this._updatingPromise=u([e?.load(),t?.when()]);if(this.destroyed)return;if(await s,s!==this._updatingPromise)return}this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map(e=>{if(!1===e.placefinding)return;const t=P(e.url)&&w(e.url)?{url:j}:null,s=E.fromJSON({...e,...t}),r=s.url;if(P(r)||C(r)||G(r)){const e=s.outFields??["Addr_type","Match_addr","StAddr","City"],t=(s.placeholder||this.messages?.placeholder)??"",r="number"==typeof s.defaultZoomScale?s.defaultZoomScale:2500;s.singleLineFieldName="SingleLine",s.outFields=e,s.placeholder=t,s.defaultZoomScale=r}return s.singleLineFieldName?s:void 0}).filter(o)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach(e=>e?.destroy()),this._createdFeatureLayers=[]}_getLayerSources(e,t){const s=this.view?.map;return e.map(e=>{const r=s.findLayerById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_getTableSources(e,t){const s=this.view?.map;return e.map(e=>{if(!e.id)return;const r=s.findTableById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:s,hintText:r,layers:o,tables:i}=t;if(!s)return[];return[...this._getLayerSources(o,r),...this._getTableSources(i,r)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const s=e.allSublayers.find(e=>e.id===t.subLayer);if(!s)throw new Error;const r=await(s.createFeatureLayer?.());if(!r)throw new Error;return this._createdFeatureLayers.push(r),r}async _getBuildingSubLayer(e,t){await e.load();const s=e.allSublayers.find(e=>e.id===t.subLayer);if("building-component"!==s?.type)throw new Error;if(await s.load(),null==s.associatedLayer)throw new Error;return await s.associatedLayer.load(),s}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type||"subtype-group"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(s){const t=new i("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return a.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_suggestTimer(e,t){const s=null!=e?e:this.suggestionDelay;return c(s,null,t?.signal)}_createLocationForSearch(e){return e instanceof s&&e.geometry?S(e.geometry):e instanceof y?e:Array.isArray(e)&&2===e.length?new y({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&M(e,"key")&&M(e,"text")&&M(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),s="string"==typeof e?e:this.searchTerm,{selectedSuggestion:r,selectedResult:o}=this,i=!e&&r&&o,l=i&&r.key===o.key&&r.sourceIndex===o.sourceIndex,a=i&&r.location;return l||a?r:{location:t,text:t?"":s,sourceIndex:null,key:null}}_getFirstResult(e){return n(e,({results:e})=>e?.[0])??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const s=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(r,s),r}_formatSourceResponse(e,t,s){const r=t?.value||[],o=t?.error,i=this.allSources.at(s);if(o){const t={sourceIndex:s,source:i,error:o};e.errors.push(t),a.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:s,source:i,results:r};e.results.push(t),e.numResults+=r.length}}_formatResponse(e,t,s){if(t)if(e.activeSourceIndex===k){const r=s&&M(s,"sourceIndex")&&-1!==s.sourceIndex?s.sourceIndex:void 0;t.forEach((t,s)=>{const o=void 0!==r?r:s;this._formatSourceResponse(e,t,o)})}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:s}=this,r=!e.location&&M(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!s.length){const e=new i("search:no-sources-defined","At least one source is required.",{allSources:s});throw a.getLogger(this).error(e),e}return r===k?s.forEach((s,r)=>{o.push(this._getResultsFromSource(e,r,t))}):o.push(this._getResultsFromSource(e,r,t)),u(o)}async _getSuggestionsFromSources(e,t){const{allSources:s,activeSourceIndex:r}=this,o=[];if(!s.length){const e=new i("suggest:no-sources-defined","At least one source is required.",{allSources:s});throw a.getLogger(this).error(e),e}return r===k?s.forEach((s,r)=>{o.push(this._getSuggestionsFromSource(e,r,t))}):o.push(this._getSuggestionsFromSource(e,r,t)),u(o)}async _getResultsFromSource(e,t,s){const r=null!=t?this.allSources.at(t):null;if(!r)return null;const{location:o=null}=e,i=this.view?.spatialReference??J,l=M(r,"maxResults")?r.maxResults:this.maxResults,a=!!(r instanceof R&&M(r,"exactMatch"))&&r.exactMatch,{view:n}=this;return r.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},s)}async _getSuggestionsFromSource(e,t,s){const r=this.allSources.at(t);if(!r)return null;e??="";const o=M(r,"suggestionsEnabled")?r.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=M(r,"minSuggestCharacters")?r.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||J,i=M(r,"maxSuggestions")?r.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(r instanceof R&&M(r,"exactMatch"))&&r.exactMatch;return r.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},s)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return M(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return n(this.results??[],({results:t,sourceIndex:s})=>{const r=t?.includes(e);return r?s:null})??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const s={target:{target:e},options:{signal:t.signal}};e||(s.options.animate=!1),await this.callGoTo(s),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,s=e.feature?.geometry;if(null==s)return null;switch(s.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(V)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:s,sourceLayer:r}=e,o=s??r;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:s}=e,{attributes:r,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&r?.[a])??null,u=s.highlight(n??t);this.addHandles(u,V)}_setResultFloor(e){const{view:t}=this,s=e.feature?.attributes,r=e.feature?.sourceLayer;if(r&&"floorInfo"in r&&r?.floorInfo?.floorField&&s){const e=s[r.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([d()],B.prototype,"_searching",void 0),e([d()],B.prototype,"_updatingPromise",void 0),e([d({readOnly:!0,value:null})],B.prototype,"activeSource",null),e([d()],B.prototype,"activeSourceIndex",null),e([d()],B.prototype,"allPlaceholder",null),e([d({readOnly:!0})],B.prototype,"allSources",null),e([d()],B.prototype,"autoNavigate",void 0),e([d()],B.prototype,"autoSelect",void 0),e([d({type:r})],B.prototype,"defaultPopupTemplate",null),e([d({readOnly:!0})],B.prototype,"defaultSources",void 0),e([d()],B.prototype,"defaultSymbols",void 0),e([d()],B.prototype,"includeDefaultSources",void 0),e([d()],B.prototype,"locationEnabled",null),e([d()],B.prototype,"maxInputLength",void 0),e([d()],B.prototype,"maxResults",void 0),e([d()],B.prototype,"maxSuggestions",void 0),e([d()],B.prototype,"messages",void 0),e([d()],B.prototype,"minSuggestCharacters",void 0),e([d({readOnly:!0})],B.prototype,"placeholder",null),e([d()],B.prototype,"popupEnabled",void 0),e([d({type:r})],B.prototype,"popupTemplate",void 0),e([d({type:v})],B.prototype,"portal",void 0),e([d()],B.prototype,"resultCount",void 0),e([d()],B.prototype,"resultGraphicEnabled",void 0),e([d({readOnly:!0})],B.prototype,"resultGraphic",void 0),e([d({readOnly:!0})],B.prototype,"resultLocation",void 0),e([d({readOnly:!0})],B.prototype,"results",void 0),e([d({readOnly:!0})],B.prototype,"selectedSuggestion",void 0),e([d()],B.prototype,"searchAllEnabled",void 0),e([d({readOnly:!0})],B.prototype,"selectedResult",void 0),e([d()],B.prototype,"searchTerm",null),e([d({type:F})],B.prototype,"sources",void 0),e([d({readOnly:!0})],B.prototype,"state",null),e([d()],B.prototype,"suggestionDelay",void 0),e([d()],B.prototype,"suggestionCount",void 0),e([d({readOnly:!0})],B.prototype,"suggestions",void 0),e([d()],B.prototype,"suggestionsEnabled",void 0),e([d({readOnly:!0})],B.prototype,"updating",null),e([d()],B.prototype,"view",void 0),e([d()],B.prototype,"clear",null),B=e([m("esri.widgets.Search.SearchViewModel")],B);const Q=B;export{Q as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{getAssetUrl as t}from"../../assets.js";import r from"../../Graphic.js";import s from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{EventedAccessor as l}from"../../core/Evented.js";import a from"../../core/Logger.js";import{mappedFind as n}from"../../core/maybe.js";import{eachAlways as u,after as c}from"../../core/promiseUtils.js";import{watch as h,initial as p,whenOnce as g}from"../../core/reactiveUtils.js";import{property as d,subclass as m}from"../../core/accessorSupport/decorators.js";import y from"../../geometry/Point.js";import f from"../../geometry/SpatialReference.js";import{getPointWithElevation as S}from"../../geometry/support/geometryUtils.js";import _ from"../../portal/Portal.js";import{isApiKeyApplicable as v}from"../../support/apiKeyUtils.js";import w from"../../symbols/PictureMarkerSymbol.js";import b from"../../symbols/SimpleFillSymbol.js";import x from"../../symbols/SimpleLineSymbol.js";import L from"../../symbols/TextSymbol.js";import{highlightsSupported as I}from"../../views/support/layerViewUtils.js";import T from"./LayerSearchSource.js";import R from"./LocatorSearchSource.js";import{SourceCollection as E}from"./types.js";import{isArcGISWorldGeocoder as F,meteredArcGISLocatorUrl as P,isProxiedArcGISWorldGeocoder as j,isMeteredArcGISWorldGeocoder as O}from"./support/locatorUtils.js";import{supported as C,getCurrentPosition as G,positionToPoint as A}from"../support/geolocationUtils.js";import{GoTo as N}from"../support/GoTo.js";function D(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const M="highlight",V=f.WGS84,J="esri/images/search/search-symbol-32.png",U=/<[\s\S]*?>/g,H=-1;let k=class extends(N(l)){constructor(e){super(e),this._defaultPopupTemplate=new s({content:"{Match_addr}"}),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultSources=new E,this.defaultSymbols={point:new w({url:t(J),size:24,width:24,height:24}),polyline:new x({color:[130,130,130,1],width:2}),polygon:new b({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=_.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.resultLocation=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new E,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){this.addHandles([h(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),p),h(()=>this.messages,()=>{this._defaultPopupTemplate.title=this.messages?.searchResult??"",this._update()},p)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=H}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:H}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new E;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get defaultPopupTemplate(){return this._defaultPopupTemplate}set defaultPopupTemplate(e){this._overrideIfSome("defaultPopupTemplate",e)}get locationEnabled(){return this._get("locationEnabled")||C()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=C();if(e&&!t){const e=new i("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});a.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===H)return r??"";const s=e.at(t);return s?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultLocation",null),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=(async()=>{try{const r=await this._createSuggestionForSearch(e);await this.when();const s=await this._getResultsFromSources(r,t);if(t?.signal?.aborted)return null;const o={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(o,s,r);const i=this._getFirstResult(o.results),l=r.location&&i?i.name:r.text,a=l?.replaceAll(U,"");return this._set("searchTerm",a),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",o.results),this._set("resultCount",o.results.reduce((e,t)=>e+(t.results?.length??0),0)),this.emit("search-complete",o),await this._selectFirstResult(i),o}finally{this._clearSearching()}})();return this._searching=r,r}async searchNearby(e){if(!this.locationEnabled){const e=new i("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw a.getLogger(this).error(e),e}const t=(async()=>{try{const t=await G(),r=await A({position:t,view:this.view},e);return await this.search(r,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new i("select:missing-parameter","Cannot select without a searchResult.",{value:e});throw a.getLogger(this).error(t),t}const{view:t}=this,s=D(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new i("select:missing-source","Cannot select without a source.",{source:o});throw a.getLogger(this).error(e),e}const l=o instanceof T?this._getLayerSourcePopupTemplate(o):o.popupTemplate,n=o.resultSymbol||this._getDefaultSymbol(e),c=D(o,"resultGraphicEnabled")?!!o.resultGraphicEnabled:this.resultGraphicEnabled,h=D(o,"autoNavigate")?!!o.autoNavigate:this.autoNavigate,p=D(o,"popupEnabled")?!!o.popupEnabled:this.popupEnabled,g=p?l||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new i("select:missing-feature","Cannot select without a feature.",{feature:d});throw a.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:_}=d,v=await import("../../geometry/operators/labelPointOperator.js"),w=y?v.execute(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?S(w,t):Promise.resolve(w)},x=await u(b),R=x.layerViewQuery.value,E=x.elevationQuery.value;n instanceof L&&(n.text=e.name);const F=t&&h?e.target||e.extent:null,P=null!=F?this._goToSearchResult(F):Promise.resolve();await P;const j=R?d:new r({geometry:y,symbol:n,attributes:m,layer:f,sourceLayer:_,popupTemplate:g});return R&&I(R)&&!p&&this._highlightFeature({graphic:j,layerView:R}),!R&&c&&t&&t.graphics.push(j),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",j),this._set("resultLocation",E),this.emit("select-result",{popupEnabled:p,result:e,source:o,sourceIndex:s}),e}async suggest(e,t,r){const s=e||this.searchTerm;this.emit("suggest-start",{searchTerm:s}),await this._suggestTimer(t,r);const o=await this._suggestImmediate(s,r);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce((e,t)=>e+(t.results?.length??0),0)??null),this.emit("suggest-complete",o),o}async when(){await g(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=u([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map(e=>{if(!1===e.placefinding)return;const t=F(e.url)&&v(e.url)?{url:P}:null,r=R.fromJSON({...e,...t}),s=r.url;if(F(s)||j(s)||O(s)){const e=r.outFields??["Addr_type","Match_addr","StAddr","City"],t=(r.placeholder||this.messages?.placeholder)??"",s="number"==typeof r.defaultZoomScale?r.defaultZoomScale:2500;r.singleLineFieldName="SingleLine",r.outFields=e,r.placeholder=t,r.defaultZoomScale=s}return r.singleLineFieldName?r:void 0}).filter(o)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach(e=>e?.destroy()),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map(e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=T.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map(e=>{if(!e.id)return;const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=T.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find(e=>e.id===t.subLayer);if(!r)throw new Error;const s=await(r.createFeatureLayer?.());if(!s)throw new Error;return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find(e=>e.id===t.subLayer);if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type||"subtype-group"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(r){const t=new i("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return a.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return c(r,null,t?.signal)}async _createLocationForSearch(e){if(e instanceof r&&e.geometry){return(await import("../../geometry/operators/labelPointOperator.js")).execute(e.geometry)}return e instanceof y?e:Array.isArray(e)&&2===e.length?new y({longitude:e[0],latitude:e[1]}):null}async _createSuggestionForSearch(e){if(e&&D(e,"key")&&D(e,"text")&&D(e,"sourceIndex"))return e;const t=await this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:t,text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){return n(e,({results:e})=>e?.[0])??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const r=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}_formatSourceResponse(e,t,r){const s=t?.value||[],o=t?.error,i=this.allSources.at(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),a.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===H){const s=r&&D(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)})}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&D(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new i("search:no-sources-defined","At least one source is required.",{allSources:r});throw a.getLogger(this).error(e),e}return s===H?r.forEach((r,s)=>{o.push(this._getResultsFromSource(e,s,t))}):o.push(this._getResultsFromSource(e,s,t)),u(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new i("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw a.getLogger(this).error(e),e}return s===H?r.forEach((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))}):o.push(this._getSuggestionsFromSource(e,s,t)),u(o)}async _getResultsFromSource(e,t,r){const s=null!=t?this.allSources.at(t):null;if(!s)return null;const{location:o=null}=e,i=this.view?.spatialReference??V,l=D(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof T&&D(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=D(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=D(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||V,i=D(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof T&&D(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return D(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return n(this.results??[],({results:t,sourceIndex:r})=>{const s=t?.includes(e);return s?r:null})??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const r={target:{target:e},options:{signal:t.signal}};e||(r.options.animate=!1),await this.callGoTo(r),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(null==r)return null;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(M)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:r,sourceLayer:s}=e,o=r??s;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&s?.[a])??null,u=r.highlight(n??t);this.addHandles(u,M)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([d()],k.prototype,"_searching",void 0),e([d()],k.prototype,"_updatingPromise",void 0),e([d({readOnly:!0,value:null})],k.prototype,"activeSource",null),e([d()],k.prototype,"activeSourceIndex",null),e([d()],k.prototype,"allPlaceholder",null),e([d({readOnly:!0})],k.prototype,"allSources",null),e([d()],k.prototype,"autoNavigate",void 0),e([d()],k.prototype,"autoSelect",void 0),e([d({type:s})],k.prototype,"defaultPopupTemplate",null),e([d({readOnly:!0})],k.prototype,"defaultSources",void 0),e([d()],k.prototype,"defaultSymbols",void 0),e([d()],k.prototype,"includeDefaultSources",void 0),e([d()],k.prototype,"locationEnabled",null),e([d()],k.prototype,"maxInputLength",void 0),e([d()],k.prototype,"maxResults",void 0),e([d()],k.prototype,"maxSuggestions",void 0),e([d()],k.prototype,"messages",void 0),e([d()],k.prototype,"minSuggestCharacters",void 0),e([d({readOnly:!0})],k.prototype,"placeholder",null),e([d()],k.prototype,"popupEnabled",void 0),e([d({type:s})],k.prototype,"popupTemplate",void 0),e([d({type:_})],k.prototype,"portal",void 0),e([d()],k.prototype,"resultCount",void 0),e([d()],k.prototype,"resultGraphicEnabled",void 0),e([d({readOnly:!0})],k.prototype,"resultGraphic",void 0),e([d({readOnly:!0})],k.prototype,"resultLocation",void 0),e([d({readOnly:!0})],k.prototype,"results",void 0),e([d({readOnly:!0})],k.prototype,"selectedSuggestion",void 0),e([d()],k.prototype,"searchAllEnabled",void 0),e([d({readOnly:!0})],k.prototype,"selectedResult",void 0),e([d()],k.prototype,"searchTerm",null),e([d({type:E})],k.prototype,"sources",void 0),e([d({readOnly:!0})],k.prototype,"state",null),e([d()],k.prototype,"suggestionDelay",void 0),e([d()],k.prototype,"suggestionCount",void 0),e([d({readOnly:!0})],k.prototype,"suggestions",void 0),e([d()],k.prototype,"suggestionsEnabled",void 0),e([d({readOnly:!0})],k.prototype,"updating",null),e([d()],k.prototype,"view",void 0),e([d()],k.prototype,"clear",null),k=e([m("esri.widgets.Search.SearchViewModel")],k);const B=k;export{B as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{substitute as e,formatDate as t}from"../../../intl.js";import r from"../../../core/Error.js";import{clone as i}from"../../../core/lang.js";import n from"../../../core/Logger.js";import{mappedFind as l}from"../../../core/maybe.js";import{getMetersPerUnitForSR as o}from"../../../core/units.js";import s from"../../../geometry/Polygon.js";import{
|
|
2
|
+
import{substitute as e,formatDate as t}from"../../../intl.js";import r from"../../../core/Error.js";import{clone as i}from"../../../core/lang.js";import n from"../../../core/Logger.js";import{mappedFind as l}from"../../../core/maybe.js";import{getMetersPerUnitForSR as o}from"../../../core/units.js";import s from"../../../geometry/Polygon.js";import{createExtentFromPoint as u,scaleExtent as a}from"../../../geometry/support/geometryUtils.js";import c from"../../../rest/support/FullTextSearch.js";const d=/https?:\/\/services.*\.arcgis\.com/i,f=/(?:\{([^}]+)\})/g,m=()=>n.getLogger("esri.widgets.Search.support.layerSearchUtils");function p(e,t){const{exactMatch:i=!1,location:n,maxResults:l,spatialReference:s,source:u,sourceIndex:a,suggestResult:c,view:d}=e,{layer:f,filter:p,zoomScale:y}=u,b=d?.scale,L=g(u,d),R=t?.signal;return x(f).then(()=>{const e=f.popupTemplate;return e?e.getRequiredFields(f.fieldsIndex):null}).then(e=>{const{objectIdField:t,returnZ:g}=f,x=S(u);if(!I(f,x))throw m().error("invalid-field: displayField is invalid."),new r("getResults():invalid-field","displayField is invalid.");const C=e?.length?e:[x],E=u.outFields||C,M=h(E);E.includes(t)||M||E.push(t),f.floorInfo?.floorField&&E.push(f.floorInfo.floorField);if(!(M||j(f,E)))throw m().error("invalid-field: outField is invalid."),new r("getResults():invalid-field","outField is invalid.");const N=f.createQuery(),{orderByFields:O}=u;if(O&&(N.orderByFields=O),s){N.outSpatialReference=s;const e=1/o(s);e&&(N.maxAllowableOffset=e)}const k="mesh"===f.geometryType||"multipatch"===f.geometryType,D=f.capabilities?.data?.supportsZ&&!k;if(N.returnZ=D&&!1!==g,N.returnGeometry=!0,N.multipatchOption=k?"xyFootprint":null,E&&(N.outFields=E),n)N.geometry=n;else if(c.key)N.objectIds=[c.key];else{const e=u.searchFields||[x];if(!j(f,e))throw m().error("invalid-field: search field is invalid."),new r("getResults():invalid-field","search field is invalid.");T(f)&&(N.num=l),L&&(N.geometry=L);const t=c.text?.trim();if(!t)return[];const n=c.text,{prefix:o="",suffix:s=""}=u,a=q(`${o}${n}${s}`);$(f)&&v(f,e)&&!i&&n&&(N.fullText=w({text:n,searchFields:e}));const d=A({searchTerm:a,layer:f,searchFields:e,filter:p,exactMatch:i,query:N,type:"search"});if(N.where=d,!F(N))return[]}return f.queryFeatures(N,{signal:R}).then(async e=>{const t=await import("../../../geometry/operators/labelPointOperator.js");return Z(e,d,u,a,x,b,y,t)})})}function y(e,t){const{source:i,spatialReference:n,view:l,suggestTerm:o,maxSuggestions:s,sourceIndex:u,exactMatch:a}=e,{layer:c,filter:d}=i,p=t?.signal,y=g(i,l);return x(c).then(()=>{if(!T(c))return[];const e=S(i),t=i.searchFields||[e],l=[];i.suggestionTemplate?i.suggestionTemplate.replaceAll(f,(e,t)=>(l.push(t),e)):l.push(e);const g=h(l);l.includes(c.objectIdField)||g||l.push(c.objectIdField);const x=I(c,e),b=g||j(c,l),L=j(c,t);if(!x)throw m().error("invalid-field: displayField is invalid."),new r("getSuggestions():invalid-field","displayField is invalid.");if(!b)throw m().error("invalid-field: outField is invalid."),new r("getSuggestions():invalid-field","outField is invalid.");if(!L)throw m().error("invalid-field: search field is invalid."),new r("getSuggestions():invalid-field","search field is invalid.");const R=c.createQuery(),{orderByFields:C}=i;C&&(R.orderByFields=C),R.outSpatialReference=n,R.returnGeometry=!1,R.num=s,R.outFields=l,y&&(R.geometry=y);if(!o.trim())return[];const{prefix:E="",suffix:M=""}=i,N=q(`${E}${o}${M}`);$(c)&&v(c,t)&&!a&&o&&(R.fullText=w({text:o,searchFields:t}));const O=A({searchTerm:N,layer:c,searchFields:t,filter:d,exactMatch:a,query:R,type:"suggest"});return R.where=O,F(R)?c.queryFeatures(R,{signal:p}).then(t=>B(t,i,u,e)):[]})}function g(e,t){const{filter:r,withinViewEnabled:i}=e,n=t?.extent,l=r?.geometry;return l??(i&&n?n:void 0)}function h(e){return e&&e.includes("*")}async function x(e){e&&await e.load()}function F(e){return!(!e.fullText&&!e.where)}function v(e,t){const r=e?.indexes;if(!r||!t?.length)return!1;return r.filter(e=>"FullText"===e.indexType).some(e=>{const r=e.fields?.split(",").map(e=>e.trim().toLowerCase())||[];return t.every(e=>r.includes(e.toLowerCase()))})}function w({text:e,searchFields:t}){return e.trim().split(" ").filter(e=>!!e.trim()).map(e=>new c({onFields:t,searchTerm:e,searchType:"prefix"}))}function $(e){return e?.capabilities?.query?.supportsFullTextSearch??!1}function T(e){return e?.capabilities?.query?.supportsPagination??!1}function b(e){return e?.fieldsIndex?.fields?.find(e=>"string"===e.type)?.name??""}function S(e){return e.displayField||e.layer.displayField||b(e.layer)}function j(e,t){return!(!e||!t?.length)&&t.every(t=>I(e,t))}function I(e,t){return!!e.getField(t)}function L(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!0;return!1}function R({codedValues:e},t,r){return l(e??[],e=>{const i=e.name,n=r?i:i.toLowerCase();return(r?t:t.toLowerCase())===n?e.code.toString():null})??null}function q(e){return e.replaceAll("'","''")}function C(e,t){const r=t?.where;return r?`(${e}) AND (${r})`:e}function E({currentTerm:e,field:t,filter:r,exactMatch:i,url:n,type:l}){const o=t?.type,s=t?.name;if("string"===o||"date"===o||"global-id"===o){const t=d.test(n??""),o=t&&L(e)?"N":"";if(i&&"search"===l)return C(`${s} = ${o}'${e}'`,r);if(t){return C(`${s} LIKE ${o}${`'${e}%'`}`,r)}return C(`${`LOWER(${s})`} LIKE ${o}${`'${e.toLowerCase()}%'`}`,r)}if("oid"===o||"small-integer"===o||"integer"===o||"single"===o||"double"===o){const t=Number(e);return isNaN(t)?null:C(`${s} = ${t}`,r)}return C(`${s} = ${e}`,r)}function M(e,t){return e?` OR (${t})`:`(${t})`}function A({searchTerm:e,layer:t,searchFields:r,filter:i,exactMatch:n,query:l,type:o}){const{definitionExpression:s,url:u}=t;let a="";return!l.fullText&&e&&r&&r.forEach(r=>{const l=t.getField(r),s=t.getFieldDomain?.(r),c=("coded-value"===s?.type?R(s,e,n):null)||e||null;if(null!==c){const e=E({currentTerm:c,field:l,filter:i,exactMatch:n,url:u,type:o});e&&(a+=M(a,e))}}),s&&a?`(${s}) AND (${a})`:s||a}function N(e,t){let r=null;const{codedValues:i}=e;return i&&i.length&&i.some(e=>e.code===t&&(r=e.name,!0)),r}function O(e,t){return e[t]??e[Object.keys(e).find(e=>e.toLowerCase()===t.toLowerCase())]}function k(r,i,n){const l=r.sourceLayer,{attributes:o}=r,s=l.getFieldDomain?.(n,{feature:r});if(i)return e(i,o);if(n&&o){const e=l.getField(n),r=O(o,n);return null==r?"":"coded-value"===s?.type?N(s,r)??"":"date"===e?.type?t(new Date(r)):"number"==typeof r?r.toString():"string"!=typeof r?"":r.trim()}return""}function D(e,t,r,i){const n=e.sourceLayer,{attributes:l}=e,{objectIdField:o}=n,s=o?l[o]:null;return{text:k(e,t.suggestionTemplate,i),key:s,sourceIndex:r}}function B(e,t,r,i){return e.features.map(e=>D(e,t,r,i))}function P(e){return null!=e&&null!=e.minScale&&null!=e.maxScale}function V(e,t,r,n,l,o,c,d){const f=e.clone();f.layer=e.layer;const m=e.sourceLayer,p=m?.objectIdField,y=p?e.attributes[p]:null,g=k(e,r.searchTemplate,l);null!=o&&P(m)&&(m.minScale&&m.minScale<o?o=m.minScale:m.maxScale&&m.maxScale>o&&(o=m.maxScale));const h=f.geometry?u(d.execute(f.geometry),t??void 0,o??void 0):void 0,x="number"==typeof c&&h?a(i(h),t??void 0,c):h,F=e.clone();return F.layer=e.layer,null!=x&&(F.geometry=s.fromExtent(x)),{extent:x,target:F,feature:f,key:y,name:g,sourceIndex:n}}function Z(e,t,r,i,n,l,o,s){return e.features.map(e=>V(e,t,r,i,n,l,o,s))}export{w as createFullTextSearchInfos,p as getResults,y as getSuggestions};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import e from"../../../Graphic.js";import t from"../../../geometry/Polygon.js";import{
|
|
2
|
+
import e from"../../../Graphic.js";import t from"../../../geometry/Polygon.js";import{createExtentFromPoint as o,scaleExtent as r}from"../../../geometry/support/geometryUtils.js";import{addressToLocations as s}from"../../../rest/locator/addressToLocations.js";import{locationToAddress as n}from"../../../rest/locator/locationToAddress.js";import{suggestLocations as i}from"../../../rest/locator/suggestLocations.js";import a from"../../../rest/support/AddressToLocationsParameters.js";import c from"../../../rest/support/LocationToAddressParameters.js";import u from"../../../rest/support/SuggestLocationsParameters.js";const l="Single Line Input",m=3e5;function d(e,t){return e.location?w(e,t):j(e,t)}function p(e,t){if(t.localSearchDisabled)return null;const o=e?.scale;return"number"==typeof o&&o<=m?e?.extent?.center:null}async function f(e,t){const{source:o,spatialReference:r,view:s,suggestTerm:n,maxSuggestions:a,sourceIndex:c}=e,l=new u,{apiKey:m,url:d}=o,f=S(o,s,await import("../../../geometry/operators/labelPointOperator.js")),g=t?.signal;if(!d)return null;m&&(l.apiKey=m),o.categories&&(l.categories=o.categories),r&&(l.outSpatialReference=r);const y=p(s,o);y&&(l.location=y);if(!n.trim())return null;const{prefix:x="",suffix:v=""}=o,w=`${x}${n}${v}`;return l.text=w,f&&(l.searchExtent=f),l.maxSuggestions=a,o.countryCode&&(l.countryCode=o.countryCode),i(d,l,{signal:g}).then(e=>h(e,c))}function g(e){return!!e&&/(?:geocode-api\.arcgis\.com\/arcgis\/rest\/services\/world\/geocodeserver).*/i.test(e)}function y(e){return!!e&&/(?:\/servers\/[\da-z.-]+\/rest\/services\/world\/geocodeserver).*/i.test(e)}function x(e){return!!e&&/(?:arcgis\.com\/arcgis\/rest\/services\/world\/geocodeserver).*/i.test(e)}const v="https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer";async function w(e,t){const{location:o,source:r,sourceIndex:s,spatialReference:i,view:a}=e,{apiKey:u,defaultZoomScale:l,language:m,url:d,zoomScale:p}=r;if(null==d)return[];const f=a?.scale,g=t?.signal,y=new c({language:m,location:o,apiKey:u,outSpatialReference:i});try{const e=await n(d,y,{signal:g});return $([e],{defaultZoomScale:l,scale:f,sourceIndex:s,view:a,zoomScale:p},await import("../../../geometry/operators/labelPointOperator.js"))}catch{return[]}}function S(e,t,r){const{filter:s,withinViewEnabled:n}=e,i=t?.scale,a=t?.extent,c=s?.geometry;return(c?o(r.execute(c),t??void 0,i):void 0)||(n&&a?a:void 0)}async function j(e,t){const{source:o,suggestResult:r,spatialReference:n,view:i,maxResults:c,sourceIndex:u}=e,m=o?.zoomScale,d=o?.defaultZoomScale,f=r.text?.trim();if(!f)return null;const g=!r.key&&o.prefix?o.prefix:"",y=!r.key&&o.suffix?o.suffix:"",x=`${g}${r.text}${y}`,v=new a,{apiKey:w,url:j}=o,b=i?.scale,h=await import("../../../geometry/operators/labelPointOperator.js"),I=S(o,i,h),K=t?.signal;if(w&&(v.apiKey=w),!j)return null;o.categories&&(v.categories=o.categories),o.locationType&&(v.locationType=o.locationType),n&&(v.outSpatialReference=n);const L=p(i,o);L&&(v.location=L),v.maxLocations=c,I&&(v.searchExtent=I),o.countryCode&&(v.countryCode=o.countryCode);const{key:R}=r,T=`${R}`;return R&&(v.magicKey=T),v.address={},v.address[o.singleLineFieldName||l]=x,o.outFields&&(v.outFields=o.outFields),s(j,v,{signal:K}).then(e=>$(e,{key:T,scale:b,sourceIndex:u,view:i,zoomScale:m,defaultZoomScale:d},h))}function b(e,t){return{text:e.text,key:e.magicKey,sourceIndex:t}}function h(e,t){return e.map(e=>b(e,t))}function I(s,n,i){const{key:a,scale:c,sourceIndex:u,view:l,zoomScale:m,defaultZoomScale:d}=n,{attributes:p,extent:f,location:g,address:y}=s,x=new e({geometry:g,attributes:p}),v=f||g,w=v?o(i.execute(v),l??void 0,c??void 0):void 0,S=w?"number"==typeof m?r(w,l??void 0,m):"number"==typeof d&&"point"===v?.type?r(w,l??void 0,d):w:null,j=g?`${g.x},${g.y}`:"",b=y||j,h=x.clone();return null!=S&&(h.geometry=t.fromExtent(S)),{extent:S,feature:x,target:h,key:a,name:b,sourceIndex:u}}function $(e,t,o){return e.filter(Boolean).map(e=>I(e,t,o))}export{p as getLocation,d as getResults,f as getSuggestions,x as isArcGISWorldGeocoder,g as isMeteredArcGISWorldGeocoder,y as isProxiedArcGISWorldGeocoder,v as meteredArcGISLocatorUrl};
|