@arcgis/core 5.2.0-next.26 → 5.2.0-next.28
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/WebLinkChart.js +1 -1
- package/arcade/Dictionary.js +1 -1
- package/arcade/Feature.js +1 -1
- package/arcade/Pixel.js +1 -1
- package/arcade/deepClone.js +1 -1
- package/arcade/featureset/support/FeatureSet.js +1 -1
- package/arcade/functions/geometry.js +1 -1
- package/arcade/languageUtils.js +1 -1
- package/assets/esri/core/libs/libtess/libtess-f32.wasm +0 -0
- package/assets/esri/core/libs/libtess/libtess-f64.wasm +0 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0d3c9112ae07fa4a97d6.js +1 -0
- package/assets/esri/core/workers/chunks/{75df436e6e9773bdcfc2.js → 11f47a012dd8881e3d55.js} +18 -18
- package/assets/esri/core/workers/chunks/{5ee887fc6e1e0e70e02f.js → 1664434dc7a67c8ce453.js} +1 -1
- package/assets/esri/core/workers/chunks/1837f97f720d255a1694.js +1 -0
- package/assets/esri/core/workers/chunks/1849f72f23b434e6c78d.js +1 -0
- package/assets/esri/core/workers/chunks/1893a4b344aa9b57aa8d.js +1 -0
- package/assets/esri/core/workers/chunks/209460f8aae3f9f8c9b8.js +1 -0
- package/assets/esri/core/workers/chunks/{316a3d5c7842b445e29e.js → 24704e70d1ce01ca4081.js} +1 -1
- package/assets/esri/core/workers/chunks/{8ba3e0462a9bdaae5f40.js → 25fd4d5d3af887536b3b.js} +1 -1
- package/assets/esri/core/workers/chunks/{bf9eca7dd107bdb06614.js → 2665337e1b665e7e2b70.js} +1 -1
- package/assets/esri/core/workers/chunks/29a7321fd069253c2521.js +1 -0
- package/assets/esri/core/workers/chunks/{31c4128b23968575feca.js → 31d92ba9089617aa59ab.js} +1 -1
- package/assets/esri/core/workers/chunks/390f2beee8e3f2a302e4.js +1 -0
- package/assets/esri/core/workers/chunks/3eee32db0e9a5086b9a8.js +1 -0
- package/assets/esri/core/workers/chunks/{511b9c12a7479d39dac0.js → 409bc7d69b95f7a1634c.js} +1 -1
- package/assets/esri/core/workers/chunks/47d88e1b003c4519b7b6.js +1 -0
- package/assets/esri/core/workers/chunks/4ba4fd8fa31169760fee.js +261 -0
- package/assets/esri/core/workers/chunks/{268ee59800e64baa9682.js → 4be0c64bbf2449d57ea5.js} +1 -1
- package/assets/esri/core/workers/chunks/4fc32e60e63a9c8429b9.js +1 -0
- package/assets/esri/core/workers/chunks/{e8e7cd26c43f231cdea2.js → 5189413a83faf3480e29.js} +1 -1
- package/assets/esri/core/workers/chunks/5260f623438bd84f2caa.js +1 -0
- package/assets/esri/core/workers/chunks/5363c622a0571134cadd.js +1 -0
- package/assets/esri/core/workers/chunks/{88b08b386926ec889573.js → 548842f8ba9224b15ee4.js} +1 -1
- package/assets/esri/core/workers/chunks/{30298f84bd414f9dea64.js → 5728d8440aca205e4f53.js} +1 -1
- package/assets/esri/core/workers/chunks/5c63b38160c7d063b8af.js +1 -0
- package/assets/esri/core/workers/chunks/6183a26837dc087663ad.js +1 -0
- package/assets/esri/core/workers/chunks/654a6dc13ff5be88c8b9.js +1 -0
- package/assets/esri/core/workers/chunks/{1f03e34520746e432719.js → 67f44cab103d4411dcc5.js} +1 -1
- package/assets/esri/core/workers/chunks/697e0ce10d77b90d4fee.js +1 -0
- package/assets/esri/core/workers/chunks/{8f93e6fc11a158d4f1ee.js → 7335a762412bc8c15a2f.js} +1 -1
- package/assets/esri/core/workers/chunks/{b2b342b06d502fc61ea5.js → 76789f46b2c65d219cf9.js} +1 -1
- package/assets/esri/core/workers/chunks/{fae147d03ed723ab234d.js → 78f68f7534716956f5bc.js} +1 -1
- package/assets/esri/core/workers/chunks/7b290ac2e8a567ecae4a.js +1 -0
- package/assets/esri/core/workers/chunks/7c344c339743295d11d7.js +1 -0
- package/assets/esri/core/workers/chunks/7f1babbb7ead78201ab3.js +1 -0
- package/assets/esri/core/workers/chunks/{dadf85890961bcc205eb.js → 7fcf4f3b9131c7516524.js} +1 -1
- package/assets/esri/core/workers/chunks/{292498a9c7d462d215c6.js → 86e61841df12dbe20a19.js} +1 -1
- package/assets/esri/core/workers/chunks/8980767c5b626e4dc3b9.js +1 -0
- package/assets/esri/core/workers/chunks/8aba35305368234c94f8.js +1 -0
- package/assets/esri/core/workers/chunks/{d670e134348954ce465d.js → 8b452383ba972b638a0c.js} +1 -1
- package/assets/esri/core/workers/chunks/{a3ecde3794a7db3cf283.js → 8d90bef1091204fba0f1.js} +1 -1
- package/assets/esri/core/workers/chunks/{a18cb809dd56c5537b3b.js → 8dbf9b1d8bb6817b19c1.js} +1 -1
- package/assets/esri/core/workers/chunks/8f16a358ed83d2264415.js +1 -0
- package/assets/esri/core/workers/chunks/{a454df829a72ab02c860.js → 8fd63cb38036f331a803.js} +1 -1
- package/assets/esri/core/workers/chunks/{bbcad2fde838819ffc7b.js → 906f4c0fa8135e6c2f03.js} +1 -1
- package/assets/esri/core/workers/chunks/{502464c4eab7667f6566.js → 937e347d130d469518ce.js} +1 -1
- package/assets/esri/core/workers/chunks/9508fa53da5f92a0ab70.js +30 -0
- package/assets/esri/core/workers/chunks/989937c120bdd676ec1e.js +1 -0
- package/assets/esri/core/workers/chunks/9ba705a6ddabca0f77b1.js +1 -0
- package/assets/esri/core/workers/chunks/9dcb2cbf89dcb7558432.js +1 -0
- package/assets/esri/core/workers/chunks/a2357aae79bfbb91f125.js +1 -0
- package/assets/esri/core/workers/chunks/a3ca0649edb646da0918.js +1 -0
- package/assets/esri/core/workers/chunks/a9db775210ebeee41738.js +1 -0
- package/assets/esri/core/workers/chunks/acbc14395c31f6da509e.js +1 -0
- package/assets/esri/core/workers/chunks/{8bd4c43c34aacf3b07da.js → b10f36658aa77bc3a6cf.js} +1 -1
- package/assets/esri/core/workers/chunks/b18b6bb85e52b03b85e3.js +680 -0
- package/assets/esri/core/workers/chunks/b7458bd3a2f590f32111.js +1 -0
- package/assets/esri/core/workers/chunks/b87aca8ad281870ae970.js +1 -0
- package/assets/esri/core/workers/chunks/{790462ab5f21491a4f75.js → c193b4a175a544c4fcd6.js} +1 -1
- package/assets/esri/core/workers/chunks/{d374cb2d17a2d11c500f.js → c46500cc95a84e2a5f7a.js} +1 -1
- package/assets/esri/core/workers/chunks/c8b7ffc5cb3f1493129e.js +1 -0
- package/assets/esri/core/workers/chunks/cc46261e01a985df5aab.js +1 -0
- package/assets/esri/core/workers/chunks/{d41eed41916ed0422059.js → d07261f3fb67b9a99369.js} +1 -1
- package/assets/esri/core/workers/chunks/{2d6d01913096f7cb5ff8.js → d25c37f169577a33db46.js} +1 -1
- package/assets/esri/core/workers/chunks/{04070767356c12026369.js → d61294dcc3ba41060d44.js} +1 -1
- package/assets/esri/core/workers/chunks/{f3d331da3c61af5c5a2f.js → d8ae5b61b5ae71f4796c.js} +1 -1
- package/assets/esri/core/workers/chunks/{7dec8c453fdee1968d12.js → db279d5d9c7deec554bb.js} +1 -1
- package/assets/esri/core/workers/chunks/e181d0f5562878b3dc01.js +1 -0
- package/assets/esri/core/workers/chunks/{7dbaa089c7472825b80c.js → e38d1ba15babc238b151.js} +1 -1
- package/assets/esri/core/workers/chunks/{d07068c44d560e4ce02e.js → e5d2fab228d54b18a8a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{a533d066cac26124c5ce.js → e84c13ac59e5381b77e2.js} +1 -1
- package/assets/esri/core/workers/chunks/ef5d11581a98fb333ad2.js +1 -0
- package/assets/esri/core/workers/chunks/f1d211904d5a1de93cb3.js +1 -0
- package/assets/esri/core/workers/chunks/{353c67da4b25c29360db.js → f5125925f83c979edde7.js} +2 -2
- package/assets/esri/core/workers/chunks/{928b18e13e015330d44b.js → f68b84df093f2894210b.js} +1 -1
- package/assets/esri/core/workers/chunks/{3a35779cae6a11cde51b.js → f74b6952c888d92e479e.js} +1 -1
- package/assets/esri/core/workers/chunks/f847a4846c427f671455.js +1 -0
- package/assets/esri/core/workers/chunks/{66392ff750c28064040a.js → fe20683f442294eb111b.js} +1 -1
- package/assets/esri/images/portal/gaussiansplatlayer16.png +0 -0
- package/assets/esri/images/portal/knowledgegraphlayer16.png +0 -0
- package/assets/esri/images/portal/propresentation16.png +0 -0
- package/assets/esri/images/portal/urbanproject16.png +0 -0
- package/assets/esri/images/support/loading-throb.gif +0 -0
- package/assets/esri/layers/raster/formats/lerc-wasm.wasm +0 -0
- package/assets/esri/libs/basisu/basis_encoder.wasm +0 -0
- package/assets/esri/libs/dxtEncoder/dxt_encoder.wasm +0 -0
- package/assets/esri/themes/base/colors/scss/variables.scss +131 -131
- package/assets/esri/themes/base/colors/scss/variables_dark.scss +131 -133
- package/assets/esri/themes/base/icons/style.scss +4 -5
- package/assets/esri/themes/base/icons/variables.scss +0 -0
- package/assets/esri/themes/base/images/files/archive-32.svg +0 -0
- package/assets/esri/themes/base/images/files/cad-32.svg +0 -0
- package/assets/esri/themes/base/images/files/code-32.svg +0 -0
- package/assets/esri/themes/base/images/files/csv-32.svg +0 -0
- package/assets/esri/themes/base/images/files/excel-32.svg +0 -0
- package/assets/esri/themes/base/images/files/generic-32.svg +0 -0
- package/assets/esri/themes/base/images/files/gpx-32.svg +0 -0
- package/assets/esri/themes/base/images/files/image-32.svg +0 -0
- package/assets/esri/themes/base/images/files/pdf-32.svg +0 -0
- package/assets/esri/themes/base/images/files/report-32.svg +0 -0
- package/assets/esri/themes/base/images/files/sound-32.svg +0 -0
- package/assets/esri/themes/base/images/files/text-32.svg +0 -0
- package/assets/esri/themes/base/images/files/video-32.svg +0 -0
- package/assets/esri/themes/base/images/files/word-32.svg +0 -0
- package/assets/esri/themes/base/images/files/zip-32.svg +0 -0
- package/assets/esri/themes/base/images/loading-throb.gif +0 -0
- package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +24 -0
- package/assets/esri/themes/base/widgets/_Bookmarks.scss +0 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/OITBlend.glsl.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/config.js +1 -1
- package/core/Loadable.js +1 -1
- package/core/colorUtils.js +1 -1
- package/core/has.js +1 -1
- package/core/workers/WorkerHandle.js +1 -1
- package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/meshUtils/loadExternal.js +1 -1
- package/identity/OAuthCredential.js +1 -1
- package/kernel.js +1 -1
- package/layers/AnnotationFeatureLayer.d.ts +2 -2
- package/layers/AnnotationFeatureLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/PointCloudLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/editingSupport.js +1 -1
- package/layers/graphics/sources/MemorySource.js +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/mixins/EditBusLayer.js +1 -1
- package/layers/mixins/SceneService.js +1 -1
- package/layers/support/KMLSublayer.js +1 -1
- package/layers/support/ParquetFilesData.js +1 -1
- package/layers/support/TitleCreator.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/package.json +4 -4
- package/rest/knowledgeGraph/ReplicaDefinition.d.ts +62 -6
- package/smartMapping/support/adapters/FeatureLayerBinningAdapter.js +1 -1
- package/support/ArcadeExpression.js +1 -1
- package/support/basemapUtils.js +1 -1
- package/support/revision.js +1 -1
- package/versionManagement/VersionManagementService.js +1 -1
- package/versionManagement/VersionManager.js +1 -1
- package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
- package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
- package/views/2d/engine/ParentChildStage.js +1 -1
- package/views/2d/engine/Stage.js +1 -1
- package/views/2d/engine/ThrottledCanvas.js +2 -0
- package/views/2d/engine/webgl/Profiler.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
- package/views/2d/layers/ImageryLayerView2D.js +1 -1
- package/views/2d/layers/LayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/featureLayerAdapterUtils.js +2 -0
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/camera/constraintUtils/surfaceCollision.js +1 -1
- package/views/3d/camera/constraintUtils.js +1 -1
- package/views/3d/glTF/internal/Resource.js +1 -1
- package/views/3d/glTF/loader.js +1 -1
- package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/graphics/DrivenProperties.js +2 -0
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/tessellationUtils.js +1 -1
- package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
- package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
- package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
- package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
- package/views/3d/state/GoToOperation.js +1 -1
- package/views/3d/state/SurfaceCollisionConstraint.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/PointToPointAnimationController.js +1 -1
- package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
- package/views/3d/support/renderInfoUtils/polygon.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl/ManagedFBO.js +1 -1
- package/views/3d/webgl/RenderCamera.js +1 -1
- package/views/3d/webgl/RenderNode.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
- package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphere.js +1 -1
- package/views/3d/webgl-engine/effects/clouds/CloudsComposition.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
- package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/glow/Glow.js +1 -1
- package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlendTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/lib/CutFillComputationRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/CutFillVisualizationRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/Intersector.js +1 -1
- package/views/3d/webgl-engine/lib/IntersectorInterfaces.js +1 -1
- package/views/3d/webgl-engine/lib/IntersectorResult.js +1 -1
- package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
- package/views/3d/webgl-engine/lib/PolygonIntersectionResults.js +2 -0
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
- package/views/3d/webgl-engine/lib/screenPolygonIntersectionUtils.js +2 -0
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.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/renderers/IndexLayout.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
- package/views/3d/webgl.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/View2D.js +1 -1
- package/views/Viewport2DBaseMixin.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileLineGroundComputation.js +1 -1
- package/views/draw/support/editingSessionUtils.js +1 -1
- package/views/popupAdapter.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/views/webgl/BufferObject.js +1 -1
- package/widgets/BasemapGallery/support/PortalBasemapsSource.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
- package/widgets/BatchAttributeForm/css.js +1 -1
- package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
- package/widgets/BatchAttributeForm/interfaceUtils.js +1 -1
- package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Directions/DirectionsViewModel.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/Editor/EditorViewModel.d.ts +1 -1
- package/widgets/Editor.d.ts +11 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/LinkChartLayoutSwitcher/LinkChartLayoutSwitcherViewModel.js +1 -1
- package/widgets/Locate/LocateViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/services/SuperimposeService.js +1 -1
- package/widgets/OrientedImageryViewer/support/MediaPrefetcher.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/TableList/ListItem.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/VersionManagement/VersionManagementViewModel.js +1 -1
- package/widgets/Widget.js +1 -1
- package/widgets/support/geolocationUtils.js +1 -1
- package/widgets/support/tests.js +1 -1
- package/assets/esri/core/workers/chunks/073ee52705ea326fecfb.js +0 -1
- package/assets/esri/core/workers/chunks/0e81b6aa64d5491870b2.js +0 -1
- package/assets/esri/core/workers/chunks/10112bf4b385f1955a3d.js +0 -1
- package/assets/esri/core/workers/chunks/126a8c26618425790804.js +0 -1
- package/assets/esri/core/workers/chunks/15fd30908d5db7f7136e.js +0 -261
- package/assets/esri/core/workers/chunks/1b5001bdfeecf78c33ce.js +0 -1
- package/assets/esri/core/workers/chunks/1cb1f125dccbf8c8cac9.js +0 -1
- package/assets/esri/core/workers/chunks/1d2609ce6220b5af5526.js +0 -1
- package/assets/esri/core/workers/chunks/2e7b83c8ba78cb06d611.js +0 -1
- package/assets/esri/core/workers/chunks/2ed81f1e490cb7e73405.js +0 -1
- package/assets/esri/core/workers/chunks/32f26757e36704923286.js +0 -1
- package/assets/esri/core/workers/chunks/33e86dd1a54e447fa0e3.js +0 -1
- package/assets/esri/core/workers/chunks/3529afab0c2444275d91.js +0 -1
- package/assets/esri/core/workers/chunks/36b904912cea1744d1c6.js +0 -1
- package/assets/esri/core/workers/chunks/3b4fc67f6cb7393fbd97.js +0 -1
- package/assets/esri/core/workers/chunks/3df5394b17e9659ecb8f.js +0 -1
- package/assets/esri/core/workers/chunks/4adfe7f8a8efe2cd8e80.js +0 -1
- package/assets/esri/core/workers/chunks/5b654e0dc901a7f06a9f.js +0 -1
- package/assets/esri/core/workers/chunks/6849282c4a5cd733779d.js +0 -1
- package/assets/esri/core/workers/chunks/6adc17e6e287a365ad8d.js +0 -1
- package/assets/esri/core/workers/chunks/7e23de8d9b2d938808f6.js +0 -1
- package/assets/esri/core/workers/chunks/831455798b177678720c.js +0 -1
- package/assets/esri/core/workers/chunks/856cf872d29eeaf11a71.js +0 -1
- package/assets/esri/core/workers/chunks/8ca88cfc0b9f84dc5832.js +0 -1
- package/assets/esri/core/workers/chunks/8f25d91ea7b99597124e.js +0 -1
- package/assets/esri/core/workers/chunks/93b40245378ced43ca08.js +0 -1
- package/assets/esri/core/workers/chunks/9434c76ad39c936dba90.js +0 -1
- package/assets/esri/core/workers/chunks/98dfe31e8ed9b522eaff.js +0 -1
- package/assets/esri/core/workers/chunks/a40ede4d3375184f21fe.js +0 -1
- package/assets/esri/core/workers/chunks/a8310f55de4749f973d0.js +0 -1
- package/assets/esri/core/workers/chunks/af96cbc4fb7bef726635.js +0 -1
- package/assets/esri/core/workers/chunks/affc972757798b6db002.js +0 -1
- package/assets/esri/core/workers/chunks/b419fd36337e76e2d4a3.js +0 -680
- package/assets/esri/core/workers/chunks/b91a15522692781560b4.js +0 -30
- package/assets/esri/core/workers/chunks/c9ce408675dae6a0edd1.js +0 -1
- package/assets/esri/core/workers/chunks/e73bb7c8de7412d9975c.js +0 -1
- package/assets/esri/core/workers/chunks/f23351a04643c464be84.js +0 -1
- package/assets/esri/core/workers/chunks/f2a268c69f2a5566381b.js +0 -1
- package/assets/esri/core/workers/chunks/f93facf47aba9b128fcc.js +0 -1
- package/views/2d/engine/ManagedCanvas.js +0 -2
- package/views/3d/state/controllers/SurfaceCollisionCorrectionController.js +0 -2
- /package/assets/esri/core/workers/chunks/{353c67da4b25c29360db.js.LICENSE.txt → f5125925f83c979edde7.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../../Graphic.js";import{createTask as t}from"../../../core/asyncUtils.js";import a from"../../../core/Collection.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import i from"../../../geometry/Mesh.js";import{projectAsync as n}from"../../../geometry/projectionUtils.js";import o from"../../../geometry/support/MeshComponent.js";import c from"../../../geometry/support/MeshMaterial.js";import u from"../../../geometry/support/MeshTexture.js";import l from"../../../geometry/support/MeshVertexAttributes.js";import h from"../../../symbols/FillSymbol3DLayer.js";import m from"../../../symbols/MeshSymbol3D.js";import{calculateUpdatedWmsf as f}from"../imageMeasurementUtils.js";import{validateTifOrMrfExtension as p}from"../utils.js";import _ from"../support/resolveMediaProps.js";import{computeDefaultAreaOfInterest as x,getBaseRasterLevel as d,applySphereMeshOffsetInMeters as g,applyMeshOffsetInMeters as y,getRasterFetchParameters as v,getRasterLevelSize as w,computePanoramicAreasOfInterest as R,getViewDependentRasterLevel as M,clampRasterLevelForTextureSize as I,createSuperimposeSamplePixels as P,createSuperimposeGridVertexAttributes as O}from"../support/superimposeUtils.js";const b=2,T=2,F=2,D=2,Z=1,C=[255,255,255,255];class S{constructor(e){this._properties=e,this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetPercentage=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache=new Map,this._task=null}clear(){this._destroyGraphics(this._graphics,!0),this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache.clear()}destroy(){this._task=this._task?.abort()??null,this.clear()}update(e){this._task?.abort(),this._task=t(async t=>{if(!this._canUpdate(e))return void this._resetInactiveState(e.adapter);let a=!1,r=[];try{await this._updateDefaultCameraIfNeeded(e,t),this._resetRasterTextureCacheIfNeeded(e.currentBestFeature);const i=await this._resolveMedia(e,t);if(!i)return;if(({graphics:r}=await this._createGraphics(e,i,t)),!r.length)return;await this._updateNavigation(e,t),await this._applyPersistentZOffset(r,e,t),s(t),this._replaceGraphics(r,e.mode),a=!0}finally{a||this._destroyGraphics(r,!1)}})}_canUpdate(e){const t=["default","panoramic"];return e.superimposeViewEnabled&&"image-loaded"===e.state&&"3d"===e.view?.type&&!!e.currentBestFeature&&!!e.layer&&t.includes(e.mode)}_resetInactiveState(e){e?.disableDefaultSuperimposeNavigation?.(),e?.disablePanoramicSuperimposeNavigation?.(),this.clear()}async _updateDefaultCameraIfNeeded(e,t){const{currentBestFeature:a,mode:r}=e;if(a&&"default"===r)return this._shouldUpdateDefaultCamera(r,a)?(await(e.adapter?.updateDefaultSuperimposeCamera?.({currentBestFeature:a},{signal:t})),s(t),void(this._defaultCameraFeature=a)):void 0}async _resolveMedia(e,t){const{currentBestFeature:a,layer:r,mode:i,view:n}=e;if(!a||!r||!n||"default"!==i&&"panoramic"!==i)return null;const o=await _(a.attributes,r,{signal:t});if(s(t),!o?.mediaUrl)return null;if(!p(o.datasetFormat))return this._resolveNonRasterMedia(o);const c=await this._resolveRasterMedia(o,n,t);if(!c)return null;switch(i){case"default":{const a=await this._resolveDefaultAreaOfInterest(e,o,t);return this._resolveDefaultRasterMedia(c,a,n,t)}case"panoramic":return this._resolvePanoramicRasterMedia(c,e,t)}}_resolveNonRasterMedia(e){return{areaOfInterest:null,textureUrl:this._resolveTextureUrl(e)}}async _resolveDefaultAreaOfInterest(e,t,a){const{activeImageSize:r,currentBestFeature:i,mode:n,view:o}=e;if(!("default"===n&&r&&i&&o&&p(t.datasetFormat)))return null;const c=await x(i,o,r,this._properties.pointToPixel,{signal:a});return s(a),c}async _resolveRasterMedia(e,t,a){const r=await this._loadRaster(e,{signal:a});if(s(a),!r)return null;const i=d(r,t);let n=this._cachedBaseTexture;if(!n){const e=await this._createRasterTexture(r,null,i,{signal:a});s(a),e&&(n=e,this._cachedBaseTexture=e)}return n?{baseLevel:i,baseTexture:n,raster:r}:null}async _resolveDefaultRasterMedia(e,t,a,r){const{baseLevel:i,baseTexture:n,raster:o}=e;if(!t)return{areaOfInterest:null,baseTexture:n,raster:o,texture:n};const c=d(o,a,t),u=await this._createCompositedDefaultRasterTexture(o,t,c,i,{signal:r});return s(r),{areaOfInterest:t,baseTexture:n,overlayTexture:u,raster:o,texture:u??n}}async _resolvePanoramicRasterMedia(e,t,a){const{activeImageSize:r,currentBestFeature:i,view:n}=t,{baseTexture:o,raster:c}=e;if(!r||!i||!n)return{areaOfInterest:null,baseTexture:o,raster:c,texture:o};const u=await this._createPanoramicRasterTexture(c,i,n,r,{signal:a})??o;return s(a),{areaOfInterest:null,baseTexture:o,raster:c,texture:u}}async _createGraphics(e,t,a){switch(e.mode){case"default":return this._createDefaultGraphics(e,t,a);case"panoramic":return this._createPanoramicGraphics(e,t,a)}return{graphics:[]}}async _createDefaultGraphics(e,t,a){const r=await this._createAndDrapeDefaultGraphic(e,a,{texture:t.texture,textureUrl:t.textureUrl});return{graphics:r?[r]:[]}}async _createAndDrapeDefaultGraphic(e,t,a){const{activeImageSize:r,depthImageLoaded:i,view:n}=e,{areaOfInterest:o,texture:c,textureUrl:u}=a;if(!r||!n)return null;const l=await this._createDefaultGraphic({areaOfInterest:o,depthImageLoaded:i,imageSize:r,signal:t,texture:c,textureUrl:u,view:n});return l?(s(t),l):null}async _createPanoramicGraphics(e,t,a){const r=await this._createPanoramicSuperimposeGraphic(e,t,a);return{graphics:r?[r]:[]}}async _createPanoramicSuperimposeGraphic(e,t,a){const{activeImageSize:r,currentBestFeature:s,panoramicHorizonAngles:i,view:n}=e;return n?this._createPanoramicGraphic({currentBestFeature:s??void 0,horizonAngles:i,imageSize:r,signal:a,texture:t.texture,textureUrl:t.textureUrl,view:n}):null}async _updateNavigation(e,t){const{currentBestFeature:a,mode:r,view:s}=e;if(a&&s&&"3d"===s.type)switch(r){case"default":return void this._updateDefaultNavigation(e);case"panoramic":return void await this._updatePanoramicNavigation(e,a,s,t)}}_updateDefaultNavigation(e){this._updateDefaultSuperimposeNavigation(e.adapter,e.defaultSuperimposeCameraLockEnabled)}async _updatePanoramicNavigation(e,t,a,r){e.adapter?.disableDefaultSuperimposeNavigation?.();const i=t!==this._panoramicNavigationFeature?e.panoramicCamera??a.camera:a.camera;i&&this._shouldUpdatePanoramicCamera(e.mode,t)&&(e.adapter?.disablePanoramicSuperimposeNavigation?.(),await(e.adapter?.updatePanoramicSuperimposeCamera?.({camera:i,currentBestFeature:t},{signal:r})),s(r)),this._panoramicNavigationFeature=t}_replaceGraphics(e,t){if("panoramic"===t&&this._updatePanoramicGraphicInPlace(e))return;const a=this._graphics;this._graphics=e,this._properties.overlays.addMany(e),this._destroyGraphics(a,!0)}_updatePanoramicGraphicInPlace(e){if(1!==this._graphics.length||1!==e.length)return!1;const t=this._graphics[0],a=e[0];return!(!t||!a)&&(t.geometry=a.geometry,t.symbol=a.symbol,t.visible=a.visible,a.geometry=null,a.symbol=null,r(a),!0)}_destroyGraphics(e,t){e.length&&(t&&this._properties.overlays.removeMany(e),e.forEach(e=>r(e)))}_updateDefaultSuperimposeNavigation(e,t=!0){t?e?.enableDefaultSuperimposeNavigation?.():e?.disableDefaultSuperimposeNavigation?.(),this._panoramicNavigationFeature&&e?.disablePanoramicSuperimposeNavigation?.(),this._panoramicNavigationFeature=null}_shouldUpdateDefaultCamera(e,t){return"default"===e&&t!==this._defaultCameraFeature}_shouldUpdatePanoramicCamera(e,t){return"panoramic"===e&&t!==this._panoramicNavigationFeature}setDefaultZOffsetPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._defaultZOffsetRangeInMeters*t/100,r=a-this._defaultZOffsetInMeters;this._defaultZOffsetPercentage=t,this._defaultZOffsetInMeters=a,this._applyZOffset(this._graphics,"default",r)}setPanoramicRadiusPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._panoramicZOffsetRangeInMeters*t/100,r=a-this._panoramicZOffsetInMeters;this._panoramicZOffsetPercentage=t,this._panoramicZOffsetInMeters=a,this._applyZOffset(this._graphics,"panoramic",r)}updateZOffset(e){0!==e&&(this._panoramicZOffsetInMeters+=e,this._applyZOffset(this._graphics,"panoramic",e))}_applyZOffset(e,t,a){0!==a&&e.forEach(e=>{const r=e.geometry;"mesh"===r?.type&&("panoramic"!==t?y(r,{z:a}):g(r,{radiusOffset:a}))})}async _applyPersistentZOffset(e,t,a){if("panoramic"===t.mode)return this._panoramicZOffsetRangeInMeters=await this._resolvePanoramicZOffsetRangeInMeters(t.currentBestFeature,t.view,a),this._panoramicZOffsetInMeters=this._panoramicZOffsetRangeInMeters*this._panoramicZOffsetPercentage/100,void this._applyZOffset(e,"panoramic",this._panoramicZOffsetInMeters);this._defaultZOffsetRangeInMeters=await this._resolveDefaultZOffsetRangeInMeters(e,t.currentBestFeature,t.currentBestFeatureFrustum,t.view,a),this._defaultZOffsetInMeters=this._defaultZOffsetRangeInMeters*this._defaultZOffsetPercentage/100,this._applyZOffset(e,"default",this._defaultZOffsetInMeters)}async _resolveDefaultZOffsetRangeInMeters(e,t,a,r,i){const[o]=e,c=o?.geometry,u=t.attributes.objectId;if("mesh"!==c?.type||!a)return 0;if(this._cachedDefaultFrustumObjectId!==u){const e=a.spatialReference.equals(r.spatialReference)?a:await n(a.clone(),r.spatialReference,{signal:i});if(s(i),!e||"mesh"!==e.type)return this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=0,0;this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=this._getFrustumNearPlaneAverageZ(e)}return this._cachedDefaultFrustumNearPlaneAverageZ-this._getMeshAverageZ(c)}async _resolvePanoramicZOffsetRangeInMeters(e,t,a){const r=e.attributes.objectId;if(this._cachedPanoramicRadiusObjectId!==r){const i=e.attributes.farDistance,o=e.attributes.nearDistance??i;if(!(i>0&&o>=0))return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const c=e.attributes.location,u=c.spatialReference.equals(t.spatialReference)?c:await n(c,t.spatialReference,{signal:a});if(s(a),!u)return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const l=u.spatialReference.isWebMercator?f(u.y):1;this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=(o-i)*l}return this._panoramicZOffsetRangeInMeters}_getFrustumNearPlaneAverageZ(e){const{position:t}=e.vertexAttributes;if(t.length<12)return this._getMeshAverageZ(e);let a=0;for(let r=0;r<4;r+=1)a+=t[3*r+2];return a/4}_getMeshAverageZ(e){const{position:t}=e.vertexAttributes,a=Math.floor(t.length/3);if(0===a)return 0;let r=0;for(let s=0;s<a;s+=1)r+=t[3*s+2];return r/a}_resolveTextureUrl(e){const t=new URL(e.mediaUrl);return Object.entries(e.searchParams).forEach(([e,a])=>{t.searchParams.has(e)||t.searchParams.set(e,a)}),t.toString()}_resetRasterTextureCacheIfNeeded(e){e&&e!==this._rasterTextureCacheFeature&&(this._cachedBaseTexture=null,this._rasterTextureFetchCache.clear(),this._rasterTextureCacheFeature=e)}_createImageDataFromPixelBlock(e){return new ImageData(e.getAsRGBA(),e.width,e.height)}_copyImageData(e,t,a,r,s=e.width,i=e.height){const n=e.data,o=t.data,c=e.width,u=e.height,l=t.width,h=t.height;for(let m=0;m<i;m+=1){const e=r+m;if(e<0||e>=h)continue;const t=Math.min(u-1,Math.floor(m*u/i));for(let r=0;r<s;r+=1){const i=a+r;if(i<0||i>=l)continue;const u=4*(t*c+Math.min(c-1,Math.floor(r*c/s))),h=4*(e*l+i);o[h]=n[u],o[h+1]=n[u+1],o[h+2]=n[u+2],o[h+3]=n[u+3]}}}_copyImageDataRegion(e,t,a,r,s,i,n,o){const c=e.data,u=t.data,l=e.width,h=t.width;for(let m=0;m<o;m+=1)for(let e=0;e<n;e+=1){const t=4*((r+m)*l+(a+e)),n=4*((i+m)*h+(s+e));u[n]=c[t],u[n+1]=c[t+1],u[n+2]=c[t+2],u[n+3]=c[t+3]}}async _fetchRasterTextureAtLevel(e,t,a,r){const{offset:i,size:n}=v(e,t,a),o=this._createRasterTextureExtent(i,n),c=this._createRasterTextureLevelCacheKey(e,t),u=this._getOrCreateRasterTextureLevelCache(c),l=this._getUncoveredRasterTextureExtents(o,u.patches);for(const h of l){const a=this._createRasterTextureExtentCacheKey(h);let i=u.inflight.get(a);i||(i=this._fetchRasterTexturePatch(e,t,h,r),u.inflight.set(a,i));try{const e=await i;s(r),e&&u.patches.push(e)}finally{u.inflight.delete(a)}}return this._composeRasterTextureFromCachedPatches(o,u.patches)}_getOrCreateRasterTextureLevelCache(e){let t=this._rasterTextureFetchCache.get(e);return t||(t={inflight:new Map,patches:[]},this._rasterTextureFetchCache.set(e,t)),t}_createRasterTextureLevelCacheKey(e,t){return[e.url,e.rasterInfo.width,e.rasterInfo.height,t].join(":")}_createRasterTextureExtentCacheKey(e){return[e.xmin,e.ymin,e.xmax,e.ymax].join(":")}_createRasterTextureExtent(e,t){return{xmin:e.x,ymin:e.y,xmax:e.x+t.width,ymax:e.y+t.height}}_getUncoveredRasterTextureExtents(e,t){let a=[e];for(const r of t)if(a=a.flatMap(e=>this._subtractRasterTextureExtent(e,r.extent)),!a.length)break;return a}_subtractRasterTextureExtent(e,t){const a=this._intersectRasterTextureExtents(e,t);if(!a)return[e];const r=[];return e.ymin<a.ymin&&r.push({xmin:e.xmin,ymin:e.ymin,xmax:e.xmax,ymax:a.ymin}),a.ymax<e.ymax&&r.push({xmin:e.xmin,ymin:a.ymax,xmax:e.xmax,ymax:e.ymax}),e.xmin<a.xmin&&r.push({xmin:e.xmin,ymin:a.ymin,xmax:a.xmin,ymax:a.ymax}),a.xmax<e.xmax&&r.push({xmin:a.xmax,ymin:a.ymin,xmax:e.xmax,ymax:a.ymax}),r.filter(({xmin:e,ymin:t,xmax:a,ymax:r})=>a>e&&r>t)}_intersectRasterTextureExtents(e,t){const a=Math.max(e.xmin,t.xmin),r=Math.max(e.ymin,t.ymin),s=Math.min(e.xmax,t.xmax),i=Math.min(e.ymax,t.ymax);return s>a&&i>r?{xmin:a,ymin:r,xmax:s,ymax:i}:null}async _fetchRasterTexturePatch(e,t,a,r){const{pixelBlock:i}=await e.fetchRawPixels(t,{x:a.xmin,y:a.ymin},{width:a.xmax-a.xmin,height:a.ymax-a.ymin},r);if(s(r),i)return{extent:a,imageData:this._createImageDataFromPixelBlock(i)}}_composeRasterTextureFromCachedPatches(e,t){const a=t.filter(t=>this._intersectRasterTextureExtents(e,t.extent));if(!a.length)return;const r=new ImageData(e.xmax-e.xmin,e.ymax-e.ymin);for(const s of a){const t=this._intersectRasterTextureExtents(e,s.extent);t&&this._copyImageDataRegion(s.imageData,r,t.xmin-s.extent.xmin,t.ymin-s.extent.ymin,t.xmin-e.xmin,t.ymin-e.ymin,t.xmax-t.xmin,t.ymax-t.ymin)}return r}async _loadRaster(e,t){const{loadRaster:a}=await import("../../PanoramicViewer/utils.js"),r=await a(this._resolveTextureUrl(e),t);return s(t),r}async _createCompositedDefaultRasterTexture(e,t,a,r,i){const{pyramidScalingFactor:n}=e.rasterInfo.storageInfo,o=n??b,c=w(e.rasterInfo.width,e.rasterInfo.height,a,o),l=await this._fetchRasterTextureAtLevel(e,r,null,i);if(s(i),!l)return;const h=await this._fetchRasterTextureAtLevel(e,a,t,i);if(s(i),!h)return new u({data:l});const m=new ImageData(c.width,c.height);this._copyImageData(l,m,0,0,c.width,c.height);const f=o**a,{x:p,y:_}=this._resolveRasterDrawOrigin(t,f);return this._copyImageData(h,m,p,_),new u({data:m})}async _createRasterTexture(e,t,a,r){const{maximumPyramidLevel:s}=e.rasterInfo.storageInfo,i=await this._fetchRasterTextureAtLevel(e,a??s,t,r);if(i)return new u({data:i})}async _createPanoramicRasterTexture(e,t,a,r,i){const n=await R(t,a,r,this._properties.pointToPixel,i);if(s(i),!n?.length)return this._createRasterTexture(e,null,void 0,i);const{baseLevel:o,level:c,scalingFactor:u}=this._resolvePanoramicRasterLevels(e,a,n);return o<=c?this._createRasterTexture(e,null,c,i):this._createCompositedPanoramicRasterTexture(e,n,{baseLevel:o,level:c,scalingFactor:u},i)}_resolvePanoramicRasterLevels(e,t,a){const{maximumPyramidLevel:r,pyramidScalingFactor:s}=e.rasterInfo.storageInfo,i=a.reduce((a,r)=>Math.min(a,M(e,t,r)),r),n=I(e,i),o=s??b;return{baseLevel:Math.min(r,n+T),level:n,scalingFactor:o}}async _createCompositedPanoramicRasterTexture(e,t,a,r){const{baseLevel:i,level:n,scalingFactor:o}=a,c=w(e.rasterInfo.width,e.rasterInfo.height,n,o),l=await this._fetchRasterTextureAtLevel(e,i,null,r);if(s(r),!l)return;const h=new ImageData(c.width,c.height);this._copyImageData(l,h,0,0,c.width,c.height);const m=o**n;for(const u of t){const t=await this._fetchRasterTextureAtLevel(e,n,u,r);if(s(r),!t)continue;const{x:a,y:i}=this._resolveRasterDrawOrigin(u,m);this._copyImageData(t,h,a,i)}return new u({data:h})}_resolveRasterDrawOrigin(e,t){return{x:Math.max(0,Math.floor(e.xmin/t)),y:Math.max(0,Math.floor(e.ymin/t))}}async _createFootprintMesh(e,t,a,r){if("3d"!==t.type)return null;const c=P(e,a),u=await this._properties.getMapPoint(c,r);s(r);const h=await Promise.all(u.map(e=>e.spatialReference.equals(t.spatialReference)?e:n(e,t.spatialReference,r)));if(s(r),h.some(e=>!e))return null;const{faces:m,position:f,uv:p}=O(h,e,a);return new i({vertexAttributes:new l({position:f,uv:p}),components:[new o({faces:m})],spatialReference:t.spatialReference.clone()})}async _createPanoramicGraphic(t){const{currentBestFeature:r,horizonAngles:i,signal:n,texture:o,textureUrl:c,view:u}=t;if(!t.imageSize||!r)return null;const l=this._createPanoramicMeshTexture(o,c),f=await this._resolvePanoramicMeshLocation(r,u,n);if(!f)return null;s(n);const{imageMesh:p,radiusOfSphericalMesh:_}=this._createPanoramicSphereMesh(r,f,l);return this._flipPanoramicMeshUv(p),this._rotatePanoramicMeshToHorizon(p,i),p.offset(0,0,-_),new e({geometry:p,symbol:new m({symbolLayers:new a([new h({})])})})}_createPanoramicMeshTexture(e,t){if(e)return e;if(!t)throw new Error("Missing texture URL or texture data.");return new u({url:t})}async _resolvePanoramicMeshLocation(e,t,a){const r=e.attributes.location,i=r.spatialReference.equals(t.spatialReference)?r.clone():await n(r,t.spatialReference,{signal:a});return s(a),i}_createPanoramicSphereMesh(e,t,a){const r=t.spatialReference.isWebMercator?f(t.y):1,s=e.attributes.farDistance*r,n=new c({colorTexture:a}),o=i.createSphere(t,{size:s*F,densificationFactor:D,vertexSpace:"georeferenced",material:n});return o.components?.forEach(e=>{e.material=n,e.trustSourceNormals=!0}),{imageMesh:o,radiusOfSphericalMesh:s}}_flipPanoramicMeshUv(e){const t=e.vertexAttributes,a=t.uv;if(!a)return;const r=a.length/2;for(let s=0;s<r;s++)a[2*s]=Z-a[2*s];e.vertexAttributes=t}_rotatePanoramicMeshToHorizon(e,t){if(!t)return;const[a,r,s]=t;e.rotate(-a,-r,s,{origin:e.extent.center})}async _createDefaultGraphic(t){const{texture:r,textureUrl:s}=t;if(!r&&!s)throw new Error("Missing texture URL or texture data.");if(!t.imageSize)return null;const i=await this._createFootprintMesh(t.imageSize,t.view,t.areaOfInterest,{signal:t.signal});if(!i)return null;const n=i.vertexAttributes.position,o=[];for(let e=0;e<n.length;e+=3)o.push(...C);i.vertexAttributes.color=new Uint8Array(o);const l=new c({colorTexture:r??new u({url:s})});return i.components?.forEach(e=>{e.shading="source",e.material=l}),new e({geometry:i,symbol:new m({symbolLayers:new a([new h({})])})})}}export{S as default};
|
|
2
|
+
import e from"../../../Graphic.js";import{createTask as t}from"../../../core/asyncUtils.js";import a from"../../../core/Collection.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import i from"../../../geometry/Mesh.js";import{projectAsync as n}from"../../../geometry/projectionUtils.js";import o from"../../../geometry/support/MeshComponent.js";import c from"../../../geometry/support/MeshMaterial.js";import u from"../../../geometry/support/MeshTexture.js";import h from"../../../geometry/support/MeshVertexAttributes.js";import l from"../../../symbols/FillSymbol3DLayer.js";import m from"../../../symbols/MeshSymbol3D.js";import{calculateUpdatedWmsf as f}from"../imageMeasurementUtils.js";import{validateTifOrMrfExtension as p}from"../utils.js";import _ from"../support/resolveMediaProps.js";import{computeDefaultAreaOfInterest as x,getBaseRasterLevel as d,applySphereMeshOffsetInMeters as g,applyMeshOffsetInMeters as y,getRasterFetchParameters as v,getRasterLevelSize as w,computePanoramicAreasOfInterest as R,getViewDependentRasterLevel as M,clampRasterLevelForTextureSize as I,createSuperimposeSamplePixels as P,createSuperimposeGridVertexAttributes as O}from"../support/superimposeUtils.js";const b=2,T=2,F=2,D=2,Z=8,C=1,S=[255,255,255,255];class N{constructor(e){this._properties=e,this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetPercentage=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache=new Map,this._task=null}clear(){this._destroyGraphics(this._graphics,!0),this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache.clear()}destroy(){this._task=this._task?.abort()??null,this.clear()}update(e){this._task?.abort(),this._task=t(async t=>{if(!this._canUpdate(e))return void this._resetInactiveState(e.adapter);let a=!1,r=[];try{await this._updateDefaultCameraIfNeeded(e,t),this._resetRasterTextureCacheIfNeeded(e.currentBestFeature);const i=await this._resolveMedia(e,t);if(!i)return;if(({graphics:r}=await this._createGraphics(e,i,t)),!r.length)return;await this._updateNavigation(e,t),await this._applyPersistentZOffset(r,e,t),s(t),this._replaceGraphics(r,e.mode),a=!0}finally{a||this._destroyGraphics(r,!1)}})}_canUpdate(e){const t=["default","panoramic"];return e.superimposeViewEnabled&&"image-loaded"===e.state&&"3d"===e.view?.type&&!!e.currentBestFeature&&!!e.layer&&t.includes(e.mode)}_resetInactiveState(e){e?.disableDefaultSuperimposeNavigation?.(),e?.disablePanoramicSuperimposeNavigation?.(),this.clear()}async _updateDefaultCameraIfNeeded(e,t){const{currentBestFeature:a,mode:r}=e;if(a&&"default"===r)return this._shouldUpdateDefaultCamera(r,a)?(await(e.adapter?.updateDefaultSuperimposeCamera?.({currentBestFeature:a},{signal:t})),s(t),void(this._defaultCameraFeature=a)):void 0}async _resolveMedia(e,t){const{currentBestFeature:a,layer:r,mode:i,view:n}=e;if(!a||!r||!n||"default"!==i&&"panoramic"!==i)return null;const o=await _(a.attributes,r,{signal:t});if(s(t),!o?.mediaUrl)return null;if(!p(o.datasetFormat))return this._resolveNonRasterMedia(o);const c=await this._resolveRasterMedia(o,n,t);if(!c)return null;switch(i){case"default":{const a=await this._resolveDefaultAreaOfInterest(e,o,t);return this._resolveDefaultRasterMedia(c,a,n,t)}case"panoramic":return this._resolvePanoramicRasterMedia(c,e,t)}}_resolveNonRasterMedia(e){return{areaOfInterest:null,textureUrl:this._resolveTextureUrl(e)}}async _resolveDefaultAreaOfInterest(e,t,a){const{activeImageSize:r,currentBestFeature:i,mode:n,view:o}=e;if(!("default"===n&&r&&i&&o&&p(t.datasetFormat)))return null;const c=await x(i,o,r,this._properties.pointToPixel,{signal:a});return s(a),c}async _resolveRasterMedia(e,t,a){const r=await this._loadRaster(e,{signal:a});if(s(a),!r)return null;const i=d(r,t);let n=this._cachedBaseTexture;if(!n){const e=await this._createRasterTexture(r,null,i,{signal:a});s(a),e&&(n=e,this._cachedBaseTexture=e)}return n?{baseLevel:i,baseTexture:n,raster:r}:null}async _resolveDefaultRasterMedia(e,t,a,r){const{baseLevel:i,baseTexture:n,raster:o}=e;if(!t)return{areaOfInterest:null,baseTexture:n,raster:o,texture:n};const c=d(o,a,t),u=await this._createCompositedDefaultRasterTexture(o,t,c,i,{signal:r});return s(r),{areaOfInterest:t,baseTexture:n,overlayTexture:u,raster:o,texture:u??n}}async _resolvePanoramicRasterMedia(e,t,a){const{activeImageSize:r,currentBestFeature:i,view:n}=t,{baseTexture:o,raster:c}=e;if(!r||!i||!n)return{areaOfInterest:null,baseTexture:o,raster:c,texture:o};const u=await this._createPanoramicRasterTexture(c,i,n,r,{signal:a})??o;return s(a),{areaOfInterest:null,baseTexture:o,raster:c,texture:u}}async _createGraphics(e,t,a){switch(e.mode){case"default":return this._createDefaultGraphics(e,t,a);case"panoramic":return this._createPanoramicGraphics(e,t,a)}return{graphics:[]}}async _createDefaultGraphics(e,t,a){const r=await this._createAndDrapeDefaultGraphic(e,a,{texture:t.texture,textureUrl:t.textureUrl});return{graphics:r?[r]:[]}}async _createAndDrapeDefaultGraphic(e,t,a){const{activeImageSize:r,depthImageLoaded:i,view:n}=e,{areaOfInterest:o,texture:c,textureUrl:u}=a;if(!r||!n)return null;const h=await this._createDefaultGraphic({areaOfInterest:o,depthImageLoaded:i,imageSize:r,signal:t,texture:c,textureUrl:u,view:n});return h?(s(t),h):null}async _createPanoramicGraphics(e,t,a){const r=await this._createPanoramicSuperimposeGraphic(e,t,a);return{graphics:r?[r]:[]}}async _createPanoramicSuperimposeGraphic(e,t,a){const{activeImageSize:r,currentBestFeature:s,panoramicHorizonAngles:i,view:n}=e;return n?this._createPanoramicGraphic({currentBestFeature:s??void 0,horizonAngles:i,imageSize:r,signal:a,texture:t.texture,textureUrl:t.textureUrl,view:n}):null}async _updateNavigation(e,t){const{currentBestFeature:a,mode:r,view:s}=e;if(a&&s&&"3d"===s.type)switch(r){case"default":return void this._updateDefaultNavigation(e);case"panoramic":return void await this._updatePanoramicNavigation(e,a,s,t)}}_updateDefaultNavigation(e){this._updateDefaultSuperimposeNavigation(e.adapter,e.defaultSuperimposeCameraLockEnabled)}async _updatePanoramicNavigation(e,t,a,r){e.adapter?.disableDefaultSuperimposeNavigation?.();const i=t!==this._panoramicNavigationFeature?e.panoramicCamera??a.camera:a.camera;i&&this._shouldUpdatePanoramicCamera(e.mode,t)&&(e.adapter?.disablePanoramicSuperimposeNavigation?.(),await(e.adapter?.updatePanoramicSuperimposeCamera?.({camera:i,currentBestFeature:t},{signal:r})),s(r)),this._panoramicNavigationFeature=t}_replaceGraphics(e,t){if("panoramic"===t&&this._updatePanoramicGraphicInPlace(e))return;const a=this._graphics;this._graphics=e,this._properties.overlays.addMany(e),this._destroyGraphics(a,!0)}_updatePanoramicGraphicInPlace(e){if(1!==this._graphics.length||1!==e.length)return!1;const t=this._graphics[0],a=e[0];return!(!t||!a)&&(t.geometry=a.geometry,t.symbol=a.symbol,t.visible=a.visible,a.geometry=null,a.symbol=null,r(a),!0)}_destroyGraphics(e,t){e.length&&(t&&this._properties.overlays.removeMany(e),e.forEach(e=>r(e)))}_updateDefaultSuperimposeNavigation(e,t=!0){t?e?.enableDefaultSuperimposeNavigation?.():e?.disableDefaultSuperimposeNavigation?.(),this._panoramicNavigationFeature&&e?.disablePanoramicSuperimposeNavigation?.(),this._panoramicNavigationFeature=null}_shouldUpdateDefaultCamera(e,t){return"default"===e&&t!==this._defaultCameraFeature}_shouldUpdatePanoramicCamera(e,t){return"panoramic"===e&&t!==this._panoramicNavigationFeature}setDefaultZOffsetPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._defaultZOffsetRangeInMeters*t/100,r=a-this._defaultZOffsetInMeters;this._defaultZOffsetPercentage=t,this._defaultZOffsetInMeters=a,this._applyZOffset(this._graphics,"default",r)}setPanoramicRadiusPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._panoramicZOffsetRangeInMeters*t/100,r=a-this._panoramicZOffsetInMeters;this._panoramicZOffsetPercentage=t,this._panoramicZOffsetInMeters=a,this._applyZOffset(this._graphics,"panoramic",r)}updateZOffset(e){0!==e&&(this._panoramicZOffsetInMeters+=e,this._applyZOffset(this._graphics,"panoramic",e))}_applyZOffset(e,t,a){0!==a&&e.forEach(e=>{const r=e.geometry;"mesh"===r?.type&&("panoramic"!==t?y(r,{z:a}):g(r,{radiusOffset:a}))})}async _applyPersistentZOffset(e,t,a){if("panoramic"===t.mode)return this._panoramicZOffsetRangeInMeters=await this._resolvePanoramicZOffsetRangeInMeters(t.currentBestFeature,t.view,a),this._panoramicZOffsetInMeters=this._panoramicZOffsetRangeInMeters*this._panoramicZOffsetPercentage/100,void this._applyZOffset(e,"panoramic",this._panoramicZOffsetInMeters);this._defaultZOffsetRangeInMeters=await this._resolveDefaultZOffsetRangeInMeters(e,t.currentBestFeature,t.currentBestFeatureFrustum,t.view,a),this._defaultZOffsetInMeters=this._defaultZOffsetRangeInMeters*this._defaultZOffsetPercentage/100,this._applyZOffset(e,"default",this._defaultZOffsetInMeters)}async _resolveDefaultZOffsetRangeInMeters(e,t,a,r,i){const[o]=e,c=o?.geometry,u=t.attributes.objectId;if("mesh"!==c?.type||!a)return 0;if(this._cachedDefaultFrustumObjectId!==u){const e=a.spatialReference.equals(r.spatialReference)?a:await n(a.clone(),r.spatialReference,{signal:i});if(s(i),!e||"mesh"!==e.type)return this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=0,0;this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=this._getFrustumNearPlaneAverageZ(e)}return this._cachedDefaultFrustumNearPlaneAverageZ-this._getMeshAverageZ(c)}async _resolvePanoramicZOffsetRangeInMeters(e,t,a){const r=e.attributes.objectId;if(this._cachedPanoramicRadiusObjectId!==r){const i=e.attributes.farDistance,o=Math.max(Z,e.attributes.nearDistance??i);if(!(i>0&&o>=0))return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const c=e.attributes.location,u=c.spatialReference.equals(t.spatialReference)?c:await n(c,t.spatialReference,{signal:a});if(s(a),!u)return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const h=u.spatialReference.isWebMercator?f(u.y):1;this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=(o-i)*h}return this._panoramicZOffsetRangeInMeters}_getFrustumNearPlaneAverageZ(e){const{position:t}=e.vertexAttributes;if(t.length<12)return this._getMeshAverageZ(e);let a=0;for(let r=0;r<4;r+=1)a+=t[3*r+2];return a/4}_getMeshAverageZ(e){const{position:t}=e.vertexAttributes,a=Math.floor(t.length/3);if(0===a)return 0;let r=0;for(let s=0;s<a;s+=1)r+=t[3*s+2];return r/a}_resolveTextureUrl(e){const t=new URL(e.mediaUrl);return Object.entries(e.searchParams).forEach(([e,a])=>{t.searchParams.has(e)||t.searchParams.set(e,a)}),t.toString()}_resetRasterTextureCacheIfNeeded(e){e&&e!==this._rasterTextureCacheFeature&&(this._cachedBaseTexture=null,this._rasterTextureFetchCache.clear(),this._rasterTextureCacheFeature=e)}_createImageDataFromPixelBlock(e){return new ImageData(e.getAsRGBA(),e.width,e.height)}_copyImageData(e,t,a,r,s=e.width,i=e.height){const n=e.data,o=t.data,c=e.width,u=e.height,h=t.width,l=t.height;for(let m=0;m<i;m+=1){const e=r+m;if(e<0||e>=l)continue;const t=Math.min(u-1,Math.floor(m*u/i));for(let r=0;r<s;r+=1){const i=a+r;if(i<0||i>=h)continue;const u=4*(t*c+Math.min(c-1,Math.floor(r*c/s))),l=4*(e*h+i);o[l]=n[u],o[l+1]=n[u+1],o[l+2]=n[u+2],o[l+3]=n[u+3]}}}_copyImageDataRegion(e,t,a,r,s,i,n,o){const c=e.data,u=t.data,h=e.width,l=t.width;for(let m=0;m<o;m+=1)for(let e=0;e<n;e+=1){const t=4*((r+m)*h+(a+e)),n=4*((i+m)*l+(s+e));u[n]=c[t],u[n+1]=c[t+1],u[n+2]=c[t+2],u[n+3]=c[t+3]}}async _fetchRasterTextureAtLevel(e,t,a,r){const{offset:i,size:n}=v(e,t,a),o=this._createRasterTextureExtent(i,n),c=this._createRasterTextureLevelCacheKey(e,t),u=this._getOrCreateRasterTextureLevelCache(c),h=this._getUncoveredRasterTextureExtents(o,u.patches);for(const l of h){const a=this._createRasterTextureExtentCacheKey(l);let i=u.inflight.get(a);i||(i=this._fetchRasterTexturePatch(e,t,l,r),u.inflight.set(a,i));try{const e=await i;s(r),e&&u.patches.push(e)}finally{u.inflight.delete(a)}}return this._composeRasterTextureFromCachedPatches(o,u.patches)}_getOrCreateRasterTextureLevelCache(e){let t=this._rasterTextureFetchCache.get(e);return t||(t={inflight:new Map,patches:[]},this._rasterTextureFetchCache.set(e,t)),t}_createRasterTextureLevelCacheKey(e,t){return[e.url,e.rasterInfo.width,e.rasterInfo.height,t].join(":")}_createRasterTextureExtentCacheKey(e){return[e.xmin,e.ymin,e.xmax,e.ymax].join(":")}_createRasterTextureExtent(e,t){return{xmin:e.x,ymin:e.y,xmax:e.x+t.width,ymax:e.y+t.height}}_getUncoveredRasterTextureExtents(e,t){let a=[e];for(const r of t)if(a=a.flatMap(e=>this._subtractRasterTextureExtent(e,r.extent)),!a.length)break;return a}_subtractRasterTextureExtent(e,t){const a=this._intersectRasterTextureExtents(e,t);if(!a)return[e];const r=[];return e.ymin<a.ymin&&r.push({xmin:e.xmin,ymin:e.ymin,xmax:e.xmax,ymax:a.ymin}),a.ymax<e.ymax&&r.push({xmin:e.xmin,ymin:a.ymax,xmax:e.xmax,ymax:e.ymax}),e.xmin<a.xmin&&r.push({xmin:e.xmin,ymin:a.ymin,xmax:a.xmin,ymax:a.ymax}),a.xmax<e.xmax&&r.push({xmin:a.xmax,ymin:a.ymin,xmax:e.xmax,ymax:a.ymax}),r.filter(({xmin:e,ymin:t,xmax:a,ymax:r})=>a>e&&r>t)}_intersectRasterTextureExtents(e,t){const a=Math.max(e.xmin,t.xmin),r=Math.max(e.ymin,t.ymin),s=Math.min(e.xmax,t.xmax),i=Math.min(e.ymax,t.ymax);return s>a&&i>r?{xmin:a,ymin:r,xmax:s,ymax:i}:null}async _fetchRasterTexturePatch(e,t,a,r){const{pixelBlock:i}=await e.fetchRawPixels(t,{x:a.xmin,y:a.ymin},{width:a.xmax-a.xmin,height:a.ymax-a.ymin},r);if(s(r),i)return{extent:a,imageData:this._createImageDataFromPixelBlock(i)}}_composeRasterTextureFromCachedPatches(e,t){const a=t.filter(t=>this._intersectRasterTextureExtents(e,t.extent));if(!a.length)return;const r=new ImageData(e.xmax-e.xmin,e.ymax-e.ymin);for(const s of a){const t=this._intersectRasterTextureExtents(e,s.extent);t&&this._copyImageDataRegion(s.imageData,r,t.xmin-s.extent.xmin,t.ymin-s.extent.ymin,t.xmin-e.xmin,t.ymin-e.ymin,t.xmax-t.xmin,t.ymax-t.ymin)}return r}async _loadRaster(e,t){const{loadRaster:a}=await import("../../PanoramicViewer/utils.js"),r=await a(this._resolveTextureUrl(e),t);return s(t),r}async _createCompositedDefaultRasterTexture(e,t,a,r,i){const{pyramidScalingFactor:n}=e.rasterInfo.storageInfo,o=n??b,c=w(e.rasterInfo.width,e.rasterInfo.height,a,o),h=await this._fetchRasterTextureAtLevel(e,r,null,i);if(s(i),!h)return;const l=await this._fetchRasterTextureAtLevel(e,a,t,i);if(s(i),!l)return new u({data:h});const m=new ImageData(c.width,c.height);this._copyImageData(h,m,0,0,c.width,c.height);const f=o**a,{x:p,y:_}=this._resolveRasterDrawOrigin(t,f);return this._copyImageData(l,m,p,_),new u({data:m})}async _createRasterTexture(e,t,a,r){const{maximumPyramidLevel:s}=e.rasterInfo.storageInfo,i=await this._fetchRasterTextureAtLevel(e,a??s,t,r);if(i)return new u({data:i})}async _createPanoramicRasterTexture(e,t,a,r,i){const n=await R(t,a,r,this._properties.pointToPixel,i);if(s(i),!n?.length)return this._createRasterTexture(e,null,void 0,i);const{baseLevel:o,level:c,scalingFactor:u}=this._resolvePanoramicRasterLevels(e,a,n);return o<=c?this._createRasterTexture(e,null,c,i):this._createCompositedPanoramicRasterTexture(e,n,{baseLevel:o,level:c,scalingFactor:u},i)}_resolvePanoramicRasterLevels(e,t,a){const{maximumPyramidLevel:r,pyramidScalingFactor:s}=e.rasterInfo.storageInfo,i=a.reduce((a,r)=>Math.min(a,M(e,t,r)),r),n=I(e,i),o=s??b;return{baseLevel:Math.min(r,n+T),level:n,scalingFactor:o}}async _createCompositedPanoramicRasterTexture(e,t,a,r){const{baseLevel:i,level:n,scalingFactor:o}=a,c=w(e.rasterInfo.width,e.rasterInfo.height,n,o),h=await this._fetchRasterTextureAtLevel(e,i,null,r);if(s(r),!h)return;const l=new ImageData(c.width,c.height);this._copyImageData(h,l,0,0,c.width,c.height);const m=o**n;for(const u of t){const t=await this._fetchRasterTextureAtLevel(e,n,u,r);if(s(r),!t)continue;const{x:a,y:i}=this._resolveRasterDrawOrigin(u,m);this._copyImageData(t,l,a,i)}return new u({data:l})}_resolveRasterDrawOrigin(e,t){return{x:Math.max(0,Math.floor(e.xmin/t)),y:Math.max(0,Math.floor(e.ymin/t))}}async _createFootprintMesh(e,t,a,r){if("3d"!==t.type)return null;const c=P(e,a),u=await this._properties.getMapPoint(c,r);s(r);const l=await Promise.all(u.map(e=>e.spatialReference.equals(t.spatialReference)?e:n(e,t.spatialReference,r)));if(s(r),l.some(e=>!e))return null;const{faces:m,position:f,uv:p}=O(l,e,a);return new i({vertexAttributes:new h({position:f,uv:p}),components:[new o({faces:m})],spatialReference:t.spatialReference.clone()})}async _createPanoramicGraphic(t){const{currentBestFeature:r,horizonAngles:i,signal:n,texture:o,textureUrl:c,view:u}=t;if(!t.imageSize||!r)return null;const h=this._createPanoramicMeshTexture(o,c),f=await this._resolvePanoramicMeshLocation(r,u,n);if(!f)return null;s(n);const{imageMesh:p,radiusOfSphericalMesh:_}=this._createPanoramicSphereMesh(r,f,h);return this._flipPanoramicMeshUv(p),this._rotatePanoramicMeshToHorizon(p,i),p.offset(0,0,-_),new e({geometry:p,symbol:new m({symbolLayers:new a([new l({})])})})}_createPanoramicMeshTexture(e,t){if(e)return e;if(!t)throw new Error("Missing texture URL or texture data.");return new u({url:t})}async _resolvePanoramicMeshLocation(e,t,a){const r=e.attributes.location,i=r.spatialReference.equals(t.spatialReference)?r.clone():await n(r,t.spatialReference,{signal:a});return s(a),i}_createPanoramicSphereMesh(e,t,a){const r=t.spatialReference.isWebMercator?f(t.y):1,s=e.attributes.farDistance*r,n=new c({colorTexture:a}),o=i.createSphere(t,{size:s*F,densificationFactor:D,vertexSpace:"georeferenced",material:n});return o.components?.forEach(e=>{e.material=n,e.trustSourceNormals=!0}),{imageMesh:o,radiusOfSphericalMesh:s}}_flipPanoramicMeshUv(e){const t=e.vertexAttributes,a=t.uv;if(!a)return;const r=a.length/2;for(let s=0;s<r;s++)a[2*s]=C-a[2*s];e.vertexAttributes=t}_rotatePanoramicMeshToHorizon(e,t){if(!t)return;const[a,r,s]=t;e.rotate(-a,-r,s,{origin:e.extent.center})}async _createDefaultGraphic(t){const{texture:r,textureUrl:s}=t;if(!r&&!s)throw new Error("Missing texture URL or texture data.");if(!t.imageSize)return null;const i=await this._createFootprintMesh(t.imageSize,t.view,t.areaOfInterest,{signal:t.signal});if(!i)return null;const n=i.vertexAttributes.position,o=[];for(let e=0;e<n.length;e+=3)o.push(...S);i.vertexAttributes.color=new Uint8Array(o);const h=new c({colorTexture:r??new u({url:s})});return i.components?.forEach(e=>{e.shading="source",e.material=h}),new e({geometry:i,symbol:new m({symbolLayers:new a([new l({})])})})}}export{N as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{createTask as t}from"../../../core/asyncUtils.js";import r from"../../../core/Error.js";import{LRUCache as e}from"../../../core/LRUCache.js";import{abortMaybe as i}from"../../../core/maybe.js";import{createPanoramicMedia as o,createNonPanoramicMedia as a}from"../utils.js";import s from"./resolveMediaProps.js";class
|
|
2
|
+
import{createTask as t}from"../../../core/asyncUtils.js";import r from"../../../core/Error.js";import{LRUCache as e}from"../../../core/LRUCache.js";import{abortMaybe as i}from"../../../core/maybe.js";import{createPanoramicMedia as o,createNonPanoramicMedia as a}from"../utils.js";import s from"./resolveMediaProps.js";class c{constructor(t){this._cache=new e(t?.maxEntries??20,t=>t?.destroy&&t.destroy()),this._inFlight=new Map}destroy(){this._cache.destroy(),this._inFlight.forEach(t=>t?.abort&&t.abort()),this._inFlight.clear()}enqueueDirectionalPrefetch(t,r,e=5){if(!r)return;const i=["towards","right","backwards","left"];for(const o of i){const i=n(r,o,e);for(const r of i)this.startPrefetchForNode(r,t).catch(()=>{})}}enqueueSequentialPrefetch(t,r,e=5){if(!r)return;let i=r.next,o=r.previous;for(let a=0;a<e;a++)i&&(this.startPrefetchForNode(i,t).catch(()=>{}),i=i.next),o&&(this.startPrefetchForNode(o,t).catch(()=>{}),o=o.previous)}clear(){this._cache.clear(),this._inFlight.forEach(i),this._inFlight.clear()}getCachedMedia(t){return this._cache.get(`${t}`)}async startPrefetchForNode(e,i){const c=e.id;if(!c)return;const n=`${c}`;if(this._cache.get(n))return;const h=this._inFlight.get(n);if(h){try{await h.promise}catch(f){}return}const l=t(async t=>{const c=await s(e.attributes,i,{signal:t}).catch(()=>null);if(!c||c.getDataSetFormatError)throw new r("NoMediaPropsError","Could not resolve media properties for prefetching");const{mediaUrl:h,datasetFormat:l,rotation:u,searchParams:m,mode:d,cameraHeading:g,matrix:p}=c;let F=null;F="panoramic"===d||360===e.attributes.horizontalFieldOfView?o({url:h,extension:l,matrix:p,cameraHeading:g}):a({url:h,rotation:u,customParameters:m,datasetFormat:l});try{await F.load({signal:t}),this._cache.put(n,F)}catch(f){F.destroy(),F=null}return F});this._inFlight.set(n,l);try{await l.promise}finally{this._inFlight.delete(n)}}}function n(t,e,i=5){if(!t)throw new r("MissingArgumentError"," start node is required");const o=[];let a=t,s=0;for(;a&&s<i;){const t=a[e];if(!t)break;o.push(t),a=t,s+=1}return o}export{c as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import i from"../../Camera.js";import t from"../../Ground.js";import a from"../../Map.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as d}from"../../core/mathUtils.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as c}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as g,when as u,whenOnce as y}from"../../core/reactiveUtils.js";import{property as _,subclass as v}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import w from"../../geometry/SpatialReference.js";import M from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as P}from"../../layers/orientedImagery/transformations/utils.js";import{isGraphic as R}from"../../support/graphicInstanceUtils.js";import C from"../../views/SceneView.js";import{extractHorizonAnglesFromMedia as z}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as V,defaultImageSphereSize as H,maxPanoramicViewerHFOV as k,minPanoramicViewerHFOV as G,humanBinocularHFOV as O}from"./constants.js";import b from"./PanoramicZoomConditions.js";import j from"./PanoramicZoomViewModel.js";import{meshToGraphic as x,findDiagonalFOV as A}from"./utils.js";import I from"./support/PanoramicMedia.js";import{enumeration as S}from"../../core/accessorSupport/decorators/enumeration.js";const F={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let L=class extends n{constructor(e){super(e),this._panTask=null,this._startPosition=null,this._targetPosition=null,this.tileCache=new Set,this._graphics=new M({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this.currentGraphics=new s,this.imagePyramid=null,this.imagePyramidLevel=-1,this._map=new a({ground:new t({opacity:0,navigationConstraint:null}),layers:new s([this._graphics])}),this._imageRenderer=new C({map:this._map,viewingMode:"local",camera:{position:V},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:w.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}}),this._loadController=null,this.zoomViewModel=new j({panoramicViewerViewModel:this,view:this._imageRenderer,panoramicZoomConditions:new b({})}),this.autoLoad=!1,this.clickAction="none",this.imageMeshDistance=H/2,this.imageSize=null,this.pitch=90,this.state="ready",this.updatingHandles=new f,this.yaw=0,this._addNavigationHandles=(e=!0)=>{this.imageRenderer.basemapTerrain.suspended=!0,this.removeHandles(F.navigation);const i=[this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const i=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],t=e.key;i.includes(t)&&e.stopPropagation()})];e&&i.push(this.imageRenderer.on("double-click",this._handleDoubleClick)),this.addHandles(i,F.navigation)},this._addHFOVHandles=()=>{this.removeHandles(F.fovConstraint),this.addHandles(p(()=>[this.maxHFOV,this.minHFOV],()=>{this.zoomViewModel&&(this.zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},g),F.fovConstraint)},this._addZoomHandles=()=>{this.zoomViewModel=new j({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV}),panoramicViewerViewModel:this});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this.zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController=l(this._loadController)},this._createPanTask=()=>{this._panTask?.abort(),this._panTask=r(async e=>{if(!this.imagePyramid)return;const{hfov:i,vfov:t,yaw:a,pitch:r}=this,s=this.imagePyramid.getTiles(this.imagePyramidLevel,a,r,i,t).filter(e=>!this.tileCache.has(`${e.level}/${e.row}/${e.column}`));if(!s?.length)return;const o=await Promise.all(s.map(async i=>await i.loadMesh({signal:e})));c(e);const n=o.map(x);n.forEach((e,i)=>{const t=s[i].key;e.attributes={key:t},this.tileCache.add(t)}),this.addManyGraphics(n),this.currentGraphics.addMany(n),this._panTask=null})},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:i,x:t,y:a}=e;switch(i){case"start":this._startPosition=this._targetPosition={x:t,y:a};break;case"update":this._targetPosition={x:t,y:a},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const i=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics}),t=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(R);i.results=i.results.filter(e=>"graphic"===e.type&&!t.includes(e.graphic)),this.emit("hittest-response",i)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint||!this.media)return void this.emit("pixel-location",null);const i=z(this.media),t=P(e.mapPoint,this.imageSize[0],this.imageSize[1],i);this.emit("pixel-location",{...t,spatialReference:w.WebMercator});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this.media&&(this._loadController=new AbortController,this._loadMediaInternal(this.media,this._loadController))},this._zoomIn=()=>{this.zoomViewModel?.zoomIn()},this._zoomOut=()=>{this.zoomViewModel?.zoomOut()},this.addGraphic=(e,i)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,i),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(i),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this.media=null,this._removeImageSphere()},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(i),!0},this.restoreNavigationHandles=()=>{this._addNavigationHandles(!1)}}destroy(){this._cancelLoadWithController(),this.clearImage(),this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>null!=this.media&&this.autoLoad,this._loadWithController,g),p(()=>this.fov,()=>{this._reloadCamera()},g),p(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},g),p(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},g),u(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},g),p(()=>this.clickAction,e=>{this.removeHandles(F.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},g),p(()=>this.camera,(e,i)=>{this._panTask?.abort(),e?i?.tilt===e.tilt&&i.heading===e.heading||this._createPanTask():this._panTask=null}),this.currentGraphics.on("change",()=>{const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(R),i=this.currentGraphics.map(e=>e.geometry.extent);e.forEach(e=>{e.visible=!0!==i.some(i=>i.intersects(e.geometry.extent))})})],F.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get distanceFactor(){return this.fov?1-5/this.fov:null}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this.zoomViewModel?.zoomTo(e)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*m(Math.atan(Math.tan(d(e/2))*a/Math.sqrt(1+a**2)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?A(k,e/i):k}get minHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?A(G,e/i):G}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*m(Math.atan(Math.tan(d(e/2))*(1/Math.sqrt(1+a**2))))}_clearImageSphere(){if(this.imagePyramid=null,this.imagePyramidLevel=-1,this.tileCache.clear(),!this._imageGraphic)return;const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic];this._graphics.removeMany(e),this._imageGraphic=null,e.forEach(e=>e.destroy()),this._graphics.removeMany(this.currentGraphics.toArray())}async _loadMediaInternal(e,i){if(this.state="image-loading",this._removeImageSphere(),!e)throw this.state="ready",new o("panoramic-viewer:missing-media","No media provided to load.");try{const{meshOrMeshes:t,size:a,tileKeys:r}=await e.load(i),s=e.imagePyramid;if(c(i),s){this.imagePyramid=s,this.imagePyramidLevel=s.maximumPyramidLevel;const i=t;if(!i?.length)throw this.state="image-load-error",new o("panoramic-viewer:missing-tiles","No tiles were found in the pyramid",e.url);const a=i.map(x);a.forEach((e,i)=>{const t=r?.[i];e.attributes={key:t},this.tileCache.add(t)}),this._imageGraphic=a,this._graphics.addMany(this._imageGraphic)}else{const e=t;this._imageGraphic=x(e),this._graphics.add(this._imageGraphic)}return this.state="image-loaded",y(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=A(O,e/i)}),this.imageSize=a,this.media=e,t}catch(t){throw this._clearImageSphere(),this.state="image-load-error",t}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._clearImageSphere(),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const i=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,i)),this._startPosition=this._targetPosition}async loadMedia(e,i){this.state="image-loading";const t=this.autoLoad;this.autoLoad=!1;return await this._loadMediaInternal(e,i).finally(()=>{this.autoLoad=t})}};e([_()],L.prototype,"_graphics",void 0),e([_()],L.prototype,"_imageGraphic",void 0),e([_({constructOnly:!0})],L.prototype,"currentGraphics",void 0),e([_()],L.prototype,"imagePyramid",void 0),e([_()],L.prototype,"imagePyramidLevel",void 0),e([_()],L.prototype,"_map",void 0),e([_()],L.prototype,"_imageRenderer",void 0),e([_()],L.prototype,"_loadController",void 0),e([_()],L.prototype,"zoomViewModel",void 0),e([_({type:Boolean})],L.prototype,"autoLoad",void 0),e([_({type:i})],L.prototype,"camera",null),e([S(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],L.prototype,"clickAction",void 0),e([_()],L.prototype,"distanceFactor",null),e([_({type:Number})],L.prototype,"fov",null),e([_({readOnly:!0})],L.prototype,"hfov",null),e([_({type:I})],L.prototype,"media",void 0),e([_()],L.prototype,"imageMeshDistance",void 0),e([_({readOnly:!0})],L.prototype,"imageRenderer",null),e([_()],L.prototype,"imageSize",void 0),e([_({readOnly:!0})],L.prototype,"maxHFOV",null),e([_({readOnly:!0})],L.prototype,"minHFOV",null),e([_({type:Number})],L.prototype,"pitch",void 0),e([_()],L.prototype,"state",void 0),e([_()],L.prototype,"updatingHandles",void 0),e([_()],L.prototype,"updating",null),e([_({readOnly:!0})],L.prototype,"vfov",null),e([_({type:Number})],L.prototype,"yaw",void 0),L=e([v("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],L);const T=L;export{T as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import i from"../../Camera.js";import t from"../../Ground.js";import a from"../../Map.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as d}from"../../core/mathUtils.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as c}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as g,when as u,whenOnce as y}from"../../core/reactiveUtils.js";import{property as _,subclass as v}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import w from"../../geometry/SpatialReference.js";import M from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as P}from"../../layers/orientedImagery/transformations/utils.js";import{isGraphic as R}from"../../support/graphicInstanceUtils.js";import C from"../../views/SceneView.js";import{extractHorizonAnglesFromMedia as z}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as V,defaultImageSphereSize as H,maxPanoramicViewerHFOV as k,minPanoramicViewerHFOV as G,humanBinocularHFOV as O}from"./constants.js";import b from"./PanoramicZoomConditions.js";import j from"./PanoramicZoomViewModel.js";import{meshToGraphic as x,findDiagonalFOV as A}from"./utils.js";import I from"./support/PanoramicMedia.js";import{enumeration as S}from"../../core/accessorSupport/decorators/enumeration.js";const F={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let L=class extends n{constructor(e){super(e),this._panTask=null,this._startPosition=null,this._targetPosition=null,this.tileCache=new Set,this._graphics=new M({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this.currentGraphics=new s,this.imagePyramid=null,this.imagePyramidLevel=-1,this._map=new a({ground:new t({opacity:0,navigationConstraint:null}),layers:new s([this._graphics])}),this._imageRenderer=new C({map:this._map,viewingMode:"local",camera:{position:V},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:w.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}}),this._loadController=null,this.zoomViewModel=new j({panoramicViewerViewModel:this,view:this._imageRenderer,panoramicZoomConditions:new b({})}),this.autoLoad=!1,this.clickAction="none",this.imageMeshDistance=H/2,this.imageSize=null,this.pitch=90,this.state="ready",this.updatingHandles=new f,this.yaw=0,this._addNavigationHandles=(e=!0)=>{this.imageRenderer.basemapTerrain.suspended=!0,this.removeHandles(F.navigation);const i=[this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const i=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],t=e.key;i.includes(t)&&e.stopPropagation()})];e&&i.push(this.imageRenderer.on("double-click",this._handleDoubleClick)),this.addHandles(i,F.navigation)},this._addHFOVHandles=()=>{this.removeHandles(F.fovConstraint),this.addHandles(p(()=>[this.maxHFOV,this.minHFOV],()=>{this.zoomViewModel&&(this.zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},g),F.fovConstraint)},this._addZoomHandles=()=>{this.zoomViewModel=new j({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV}),panoramicViewerViewModel:this});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this.zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController=l(this._loadController)},this._createPanTask=()=>{this._panTask?.abort(),this._panTask=r(async e=>{if(!this.imagePyramid)return;const{hfov:i,vfov:t,yaw:a,pitch:r}=this,s=this.imagePyramid.getTiles(this.imagePyramidLevel,a,r,i,t).filter(e=>!this.tileCache.has(`${e.level}/${e.row}/${e.column}`));if(!s?.length)return;const o=await Promise.all(s.map(async i=>await i.loadMesh({signal:e})));c(e);const n=o.map(x);n.forEach((e,i)=>{const t=s[i].key;e.attributes={key:t},this.tileCache.add(t)}),this.addManyGraphics(n),this.currentGraphics.addMany(n),this._panTask=null})},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:i,x:t,y:a}=e;switch(i){case"start":this._startPosition=this._targetPosition={x:t,y:a};break;case"update":this._targetPosition={x:t,y:a},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const i=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics}),t=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(R);i.results=i.results.filter(e=>"graphic"===e.type&&!t.includes(e.graphic)),this.emit("hittest-response",i)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint||!this.media)return void this.emit("pixel-location",null);const i=z(this.media),t=P(e.mapPoint,this.imageSize[0],this.imageSize[1],i);this.emit("pixel-location",{...t,spatialReference:w.WebMercator});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this.media&&(this._loadController=new AbortController,this._loadMediaInternal(this.media,this._loadController).catch(()=>{}))},this._zoomIn=()=>{this.zoomViewModel?.zoomIn()},this._zoomOut=()=>{this.zoomViewModel?.zoomOut()},this.addGraphic=(e,i)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,i),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(i),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this.media=null,this._removeImageSphere()},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(i),!0},this.restoreNavigationHandles=()=>{this._addNavigationHandles(!1)}}destroy(){this._cancelLoadWithController(),this.clearImage(),this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>null!=this.media&&this.autoLoad,this._loadWithController,g),p(()=>this.fov,()=>{this._reloadCamera()},g),p(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},g),p(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},g),u(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},g),p(()=>this.clickAction,e=>{this.removeHandles(F.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},g),p(()=>this.camera,(e,i)=>{this._panTask?.abort(),e?i?.tilt===e.tilt&&i.heading===e.heading||this._createPanTask():this._panTask=null}),this.currentGraphics.on("change",()=>{const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(R),i=this.currentGraphics.map(e=>e.geometry.extent);e.forEach(e=>{e.visible=!0!==i.some(i=>i.intersects(e.geometry.extent))})})],F.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get distanceFactor(){return this.fov?1-5/this.fov:null}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this.zoomViewModel?.zoomTo(e)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*m(Math.atan(Math.tan(d(e/2))*a/Math.sqrt(1+a**2)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?A(k,e/i):k}get minHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?A(G,e/i):G}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*m(Math.atan(Math.tan(d(e/2))*(1/Math.sqrt(1+a**2))))}_clearImageSphere(){if(this.imagePyramid=null,this.imagePyramidLevel=-1,this.tileCache.clear(),!this._imageGraphic)return;const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic];this._graphics.removeMany(e),this._imageGraphic=null,e.forEach(e=>e.destroy()),this._graphics.removeMany(this.currentGraphics.toArray())}async _loadMediaInternal(e,i){if(this.state="image-loading",this._removeImageSphere(),!e)throw this.state="ready",new o("panoramic-viewer:missing-media","No media provided to load.");try{const{meshOrMeshes:t,size:a,tileKeys:r}=await e.load(i),s=e.imagePyramid;if(c(i),s){this.imagePyramid=s,this.imagePyramidLevel=s.maximumPyramidLevel;const i=t;if(!i?.length)throw this.state="image-load-error",new o("panoramic-viewer:missing-tiles","No tiles were found in the pyramid",e.url);const a=i.map(x);a.forEach((e,i)=>{const t=r?.[i];e.attributes={key:t},this.tileCache.add(t)}),this._imageGraphic=a,this._graphics.addMany(this._imageGraphic)}else{const e=t;this._imageGraphic=x(e),this._graphics.add(this._imageGraphic)}return this.state="image-loaded",y(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=A(O,e/i)},()=>{}),this.imageSize=a,this.media=e,t}catch(t){throw this._clearImageSphere(),this.state="image-load-error",t}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._clearImageSphere(),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const i=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,i)),this._startPosition=this._targetPosition}async loadMedia(e,i){this.state="image-loading";const t=this.autoLoad;this.autoLoad=!1;return await this._loadMediaInternal(e,i).finally(()=>{this.autoLoad=t})}};e([_()],L.prototype,"_graphics",void 0),e([_()],L.prototype,"_imageGraphic",void 0),e([_({constructOnly:!0})],L.prototype,"currentGraphics",void 0),e([_()],L.prototype,"imagePyramid",void 0),e([_()],L.prototype,"imagePyramidLevel",void 0),e([_()],L.prototype,"_map",void 0),e([_()],L.prototype,"_imageRenderer",void 0),e([_()],L.prototype,"_loadController",void 0),e([_()],L.prototype,"zoomViewModel",void 0),e([_({type:Boolean})],L.prototype,"autoLoad",void 0),e([_({type:i})],L.prototype,"camera",null),e([S(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],L.prototype,"clickAction",void 0),e([_()],L.prototype,"distanceFactor",null),e([_({type:Number})],L.prototype,"fov",null),e([_({readOnly:!0})],L.prototype,"hfov",null),e([_({type:I})],L.prototype,"media",void 0),e([_()],L.prototype,"imageMeshDistance",void 0),e([_({readOnly:!0})],L.prototype,"imageRenderer",null),e([_()],L.prototype,"imageSize",void 0),e([_({readOnly:!0})],L.prototype,"maxHFOV",null),e([_({readOnly:!0})],L.prototype,"minHFOV",null),e([_({type:Number})],L.prototype,"pitch",void 0),e([_()],L.prototype,"state",void 0),e([_()],L.prototype,"updatingHandles",void 0),e([_()],L.prototype,"updating",null),e([_({readOnly:!0})],L.prototype,"vfov",null),e([_({type:Number})],L.prototype,"yaw",void 0),L=e([v("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],L);const T=L;export{T as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{isSome as e}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{EventedAccessor as o}from"../../core/Evented.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import{LoadableMixin as l}from"../../core/Loadable.js";import{EsriPromiseMixin as n}from"../../core/Promise.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as d,whenOnce as h}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as c,convertUnit as f,getMetersPerUnitForSR as y,inchesPerMeter as v}from"../../core/units.js";import{property as T,subclass as w}from"../../core/accessorSupport/decorators.js";import _ from"../../geometry/Extent.js";import I from"../../geometry/SpatialReference.js";import{formatDate as g,convertDateFormatToIntlOptions as b}from"../../intl/date.js";import{getLocaleLanguage as x}from"../../intl/locale.js";import O from"../../portal/Portal.js";import E from"../../portal/PortalQueryParams.js";import{execute as P,getPrintCache as S,getTaskInfo as L}from"../../rest/print.js";import{formatJsonMap as U}from"../../rest/support/fileFormat.js";import{fromJSON as k}from"../../rest/support/layoutTemplate.js";import C from"../../rest/support/LegendLayer.js";import j from"../../rest/support/PrintParameters.js";import{getVisibleLayerViews as F}from"../../rest/support/printTaskUtils.js";import M from"../../rest/support/PrintTemplate.js";import{getExtent as H}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as A}from"../../views/input/InputManager.js";import D from"../../views/overlay/BoxOverlayItem.js";import N from"./CustomTemplate.js";import W from"./FileLink.js";import R from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as V,valueUnitKebabDict as z}from"./utils.js";const B=[30,144,255,255],q=[237,211,23,255],G=[216,48,32,255],J=/(\/GPServer\/).+/i,$=96,Q=i.ofType(N),K=i.ofType(W),X=new a({Feet:"feet",Miles:"miles",Meters:"meters",Kilometers:"kilometers"});function Y(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find(t=>e in t)){const{customTextElements:e}=t.layoutOptions;let i=g(Date.now(),b("short-date"));"ar"===x()&&(i=""+i),e.push({date:i})}}function Z(t,e,i){const s=t.visible??!0,o=t.legendEnabled??!0;if(!s||!o)return;const a=0===e,r=t.minScale??0,l=t.maxScale??0;if(!(a||(0===r||e<=r)&&(0===l||e>=l)))return;const n=t.sublayers?.toArray();if(n)for(const p of n)Z(p,e,i);else null!=t.id&&i.push(String(t.id))}function tt(t,e,i,s){if(!e.layoutOptions)return;if(!i)return void(e.layoutOptions.legendLayers=[]);if(!t)return;let o=0;e.scalePreserved&&(o=e.outScale||t.scale);const a=F(t),r=[];for(const l of a)if(l.legendEnabled){const t="sublayers"in l.layer&&l.layer.sublayers?l.layer.sublayers.toArray():void 0,e=[];for(const i of t??[])Z(i,o,e);r.push(new C({layerId:l.layer.id,title:l.layer.title||void 0,subLayerIds:t?e:void 0,dynamicLegend:s}))}e.layoutOptions.legendLayers=r}function et(t,e,i){if(!e)return;!(e.visible===i)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:i}:t.layoutOptions.elementOverrides={[e.name]:{visible:i}})}let it=class extends(l(n(o))){constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this._portalLayoutInfoTaskUrl=null,this._customLayoutOptions=null,this._exportedFileNameMap={},this._layoutTemplateInfosCache=new Map,this._tasksInfoCache=new Map,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new Q,this.datumTransformations=null,this.defaultTemplates=new Q,this.error=null,this.exportedLinks=new K,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=O.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new Q,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.saveExportEnabled=!1,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new R}initialize(){this.addHandles([m(()=>[this.showPrintAreaEnabled,this.view],()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))}),m(()=>[this.templateOptions.layout,this.templateOptions.layoutItem],()=>{this.loaded&&this._processTemplateOptions()}),m(()=>[this.allowedFormats,this.allowedLayouts],()=>{this.loaded&&this._loadTemplateInfos()}),m(()=>this.exportedLinks,()=>{const t={};for(const{name:e,extension:i}of this.exportedLinks){if(!e||!i)continue;const s=`${e}${i}`,o=t[s];t[s]=void 0!==o?o+1:0}this._exportedFileNameMap=t},d)])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=r(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach(e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach(e=>{const[i]=Object.entries(e)[0];t?.forEach(t=>{const[s,o]=Object.entries(t)[0];i===s&&(e[i]=o)})})}}),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async print(t){const{view:e,extraParameters:i,updateDelay:o,outSpatialReference:a,datumTransformations:r}=this;if(!e)throw new s("print:view-required","view is not set");Y(t);const l=this._getOverlayItem(),n=t.scalePreserved||!this.showPrintAreaEnabled?void 0:H(new _,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[l.boxWidth,l.boxHeight]),p=new j({view:e,template:t,extent:n,extraParameters:i,updateDelay:o,outSpatialReference:a,datumTransformations:r});try{const e=!!t.layoutItem?.id&&(this.defaultTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id)||this.browseTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id));return await P(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,p,{timeout:this.printTimeout})}catch(m){throw new s("print:export-error","An error occurred while exporting the web map.",{error:m})}}async load(t){return this.addResolvingPromise(this._loadResources(t).catch(t=>this.error=t)),this}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:o,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:d,layoutItem:h,legendEnabled:u,dynamicLegendEnabled:c,northArrowEnabled:f,scale:y,scaleBarEnabled:v,scaleBarUnit:T,scaleEnabled:w,title:_,width:I}){if(!d&&!h)throw new s("print:layout-required","layout is not set");const g={};e&&(g.authorText=e),i&&(g.copyrightText=i),o&&(g.customTextElements=o),_&&(g.titleText=_),v&&T&&(g.scalebarUnit=X.toJSON(T));const b=new M({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:d,layoutItem:h,layoutOptions:g,outScale:y??0,scalePreserved:w});if(I&&(b.exportOptions.width=I),n&&(b.exportOptions.height=n),a&&(b.exportOptions.dpi=a),b.layoutOptions){tt(this.view,b,u,c);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)et(b,t,f);const i=t.scaleBar;for(const t of i)et(b,t,v);const s=t.legend;for(const t of s)et(b,t,u)}}return b}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{if("loading"===this.loadStatus&&await h(()=>this.loaded),!this.loaded)throw new s("print:load-required","PrintViewModel must be loaded before adding portal templates.");t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new N({type:"browse-template",layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(t&&t===this.getLayoutTemplateById(this.templateOptions.id))return;if(this.templateOptions.reset(),!t)return;if("map-only"===t)return void(this.templateOptions.layout="map-only");!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout||t.layoutItem?.id,i=e?this.templateCustomTextElements?.[e]:void 0;if(await this.templateOptions.applyTemplate(t,{customTextElements:i,customLayoutOptions:this._customLayoutOptions}),e&&this._serviceTemplateCustomTextElements&&!this._serviceTemplateCustomTextElements[e]&&t.layoutTemplateInfo?.layoutOptions?.customTextElements){const i=r(this._serviceTemplateCustomTextElements);i[e]=t.layoutTemplateInfo.layoutOptions.customTextElements,this._serviceTemplateCustomTextElements=Object.freeze(i)}}createExportedFileLink(t){const e=this.toPrintTemplate(this.templateOptions).format.toLowerCase(),i=e.includes("png")?"png":e,s=t+i;return this._updateExportedFileNameMap(s),new W({name:t,extension:i,count:this._exportedFileNameMap[s]})}export(t){const e=this.createExportedFileLink(t);this.exportedLinks.add(e);const i=this.print(this.toPrintTemplate(this.templateOptions)).then(t=>e.set({url:t?.url,state:"ready"})).catch(t=>e.set({error:t,state:"error"}));return this.emit("submit",{link:e,saveExportEnabled:this.saveExportEnabled}),i.then(t=>this.emit("complete",{link:t,saveExportEnabled:this.saveExportEnabled})),{link:e,promise:i}}async _loadResources(t){if(!this.destroyed){if(await this._loadUrls(t),await this._loadTemplateInfos(t),this.effectivePrintServiceUrl){const e=await S(this.effectivePrintServiceUrl,t);this.cimVersion=e?.cimVersion}await this._updateOverLayItem()}}async _loadTemplateInfos(t){const e=[...this.defaultTemplates,...this.printServiceTemplates];for(const{id:o}of e)this._templateIdToCustomTemplate.delete(o);this.defaultTemplates.removeAll(),this.printServiceTemplates.removeAll();const[i,s]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(i,s,t),this._processPrintServiceTemplatesInfo(s),await this._processTemplateOptions()}_updateExportedFileNameMap(t){void 0!==this._exportedFileNameMap[t]?this._exportedFileNameMap[t]++:this._exportedFileNameMap[t]=0}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t)if(this._customLayoutOptions={legend:this.templateOptions.legendEnabled,northArrow:this.templateOptions.northArrowEnabled,scaleBar:this.templateOptions.scaleBarEnabled},e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new N({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find(t=>t.layout===this.templateOptions.layout)??this.printServiceTemplates.find(t=>t.layout===this.templateOptions.layout);await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:i,layoutInfoTask:s}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=i?.url,this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t),s?.url&&this.effectivePrintServiceUrl!==s.url?this._portalLayoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(s.url,t):this._portalLayoutInfoTaskUrl=this._layoutInfoTaskUrl}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _getLayoutInfoTaskUrl(t,e){if(!t)return null;const i=await L(t,"GetLayoutTemplatesInfo",e);return i?t.replace(J,`$1${encodeURI(i.displayName)}`):null}_getPortalDefaultTemplates(t,e){return this.portal?.helperServices?.printTask?.templates?.filter(t=>"map_only"!==t.layout.toLowerCase()&&(!e||e.includes(k(t.layout))))?.map(e=>{const i=N.fromJSON(e);if(i.type="default-template",i.layoutInfoTaskUrl=this._layoutInfoTaskUrl,i.layout){const e=t.get(i.layout);e&&i.setLayoutTemplateInfo(e)}return i})??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{portal:e}=this,{layoutGroupQuery:i,sourceJSON:s}=e,{state:o,user:a}=s??{},{availableCredits:r=0,assignedCredits:l=0}=a??{},n="suspended"===o,p="active"===o&&r<=0&&l>0,m=a?.privileges?.includes("premium:user:print:customlayout");if(!i||n||p||!m)return[];const d=new E({query:i,disableExtraQuery:!0}),h=await this.portal.queryGroups(d,t);if(!h.total)return[];const u=h.results[0],c=new E({num:100,query:"type:Layout",sortField:u.sortField,sortOrder:u.sortOrder??void 0}),f=(await u.queryItems(c,t)).results;if(!f.length)return[];return f.map(t=>(this.portalTemplateIds.push(t.id),new N({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl})))}async _loadAllTemplates(t,e,i){let s=!1;const o=e?.layout?.choiceList;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const e=this._getPortalDefaultTemplates(t,o);s=!!e.length,this.defaultTemplates.addMany(e);const a=await this._getPortalCustomTemplates(i);this.defaultTemplates.addMany(a);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}s||t.forEach((t,e)=>{if(!o||o.includes(e)){const i=new N({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});i.setLayoutTemplateInfo(t),this.printServiceTemplates.add(i),this._templateIdToCustomTemplate.set(i.id,i)}})}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;if(e&&"map-only"!==e){const t=this.defaultTemplates.find(t=>t.layout===e)??this.printServiceTemplates.find(t=>t.layout===e)??this.defaultTemplates.at(0)??this.printServiceTemplates.at(0);this._set("defaultTemplate",t)}}async _getLayoutToLayoutTemplateInfos(t){const e=this._layoutInfoTaskUrl,i=e?this._layoutTemplateInfosCache.get(e):void 0,s=i??(e?await V(e,void 0,t):[]);!i&&e&&this._layoutTemplateInfosCache.set(e,s);const o=new Map,a={};for(const r of s){const t=k(r.layoutTemplate);o.set(t,r),a[t]=r.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(a),o}async _getPrintServiceTemplatesInfo(t){const e=this.effectivePrintServiceUrl?this._tasksInfoCache.get(this.effectivePrintServiceUrl):void 0,i=e??(this.effectivePrintServiceUrl?await L(this.effectivePrintServiceUrl,"ExportWebMap",t):void 0);if(!i)throw new s("print:unavailable-service-info","Can't fetch templates info from service");!e&&this.effectivePrintServiceUrl&&this._tasksInfoCache.set(this.effectivePrintServiceUrl,i);const{parameters:o}=i,a=o.find(({name:t})=>"Format"===t),r=o.find(({name:t})=>"Layout_Template"===t);return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const i="all"===this.allowedFormats?t.choiceList:t.choiceList.filter(t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some(e=>new RegExp(`\\b${e}\\b`,"i").test(t))),s=(i.length?i:t.choiceList).map(t=>U.fromJSON(t)).filter(e),o=U.fromJSON(t.defaultValue),a=s.some(t=>new RegExp(`\\b${o}\\b`,"i").test(t))?o:s[0];return{choiceList:s,defaultValue:a}}_getLayout(t){const i=t.choiceList.filter(t=>"map_only"!==t.toLowerCase()),s="all"===this.allowedLayouts?i:i.filter(t=>this.allowedLayouts.includes(k(t))),o=(s.length?s:i).map(k).filter(e),a=k(t.defaultValue),r=o.includes(a)?a:o.find(t=>/(?=.*letter)(?=.*landscape)/i.test(t))??o.find(t=>/(?=.*a4)(?=.*landscape)/i.test(t))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new D({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m(()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,t.dpi,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded],()=>{this._updateOverLayItem()},d),this.view?.on("drag",["Shift"],t=>this._handleDrag(t),A.WIDGET),this.view?.on("key-down",["Escape"],()=>this._resetDrag(),A.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}async _updateOverLayItem(){if(!this.view)return;await this.view.when();const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,s=this.view,o=s.spatialReference,[a,r]=s.state.paddedViewState.size,l=s.state.padding;let n=0,p=0;if("map-only"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(i){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:i,pageUnits:s}=e?.layoutTemplateInfo??{};let l=!1;if(i&&s)if(this._isFreeHand){const t=i[0]/i[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=z.fromJSON(s.toLowerCase()),e=o.unit;c(t)===c(e)?(n=f(i[0],t,e),p=f(i[1],t,e)):(l=!0,n=i[0],p=i[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const t=l?Math.min(a/n,r/p):y(o)*v*$;n*=t,p*=t}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:d}=t,h=m&&d?d/this.view.scale:1;if(e.boxWidth=n*h||a,e.boxHeight=p*h||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=q;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=q;break;case"ready":e.strokeColor=B;break;case"error":e.strokeColor=G}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:s}=t,{x:o,y:a}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),s>a?(e.y=a,e.boxHeight=s-a):(e.y=s,e.boxHeight=a-s)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(u(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([T()],it.prototype,"_serviceTemplateCustomTextElements",void 0),t([T()],it.prototype,"_templateIdToCustomTemplate",void 0),t([T()],it.prototype,"allowedFormats",void 0),t([T()],it.prototype,"allowedLayouts",void 0),t([T({type:Q})],it.prototype,"browseTemplates",void 0),t([T()],it.prototype,"cimVersion",void 0),t([T()],it.prototype,"datumTransformations",void 0),t([T({type:Q})],it.prototype,"defaultTemplates",void 0),t([T()],it.prototype,"error",void 0),t([T({type:K})],it.prototype,"exportedLinks",void 0),t([T()],it.prototype,"extraParameters",void 0),t([T()],it.prototype,"includeDefaultTemplates",void 0),t([T({readOnly:!0})],it.prototype,"effectivePrintServiceUrl",null),t([T()],it.prototype,"effectiveTemplateCustomTextElements",null),t([T({type:I})],it.prototype,"outSpatialReference",void 0),t([T({type:O})],it.prototype,"portal",void 0),t([T()],it.prototype,"portalTemplateIds",void 0),t([T({type:Q})],it.prototype,"printServiceTemplates",void 0),t([T({readOnly:!0})],it.prototype,"defaultTemplate",void 0),t([T()],it.prototype,"showPrintAreaEnabled",void 0),t([T()],it.prototype,"printServiceUrl",void 0),t([T()],it.prototype,"printTimeout",void 0),t([T()],it.prototype,"saveExportEnabled",void 0),t([T({readOnly:!0})],it.prototype,"state",null),t([T({readOnly:!0})],it.prototype,"templatesInfo",void 0),t([T()],it.prototype,"updateDelay",void 0),t([T()],it.prototype,"view",void 0),t([T()],it.prototype,"templateCustomTextElements",void 0),t([T({type:R})],it.prototype,"templateOptions",void 0),it=t([w("esri.widgets.Print.PrintViewModel")],it);const st=it;export{st as default};
|
|
2
|
+
import{__decorate as t}from"tslib";import{isSome as e}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{EventedAccessor as o}from"../../core/Evented.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import{LoadableMixin as l}from"../../core/Loadable.js";import{EsriPromiseMixin as n}from"../../core/Promise.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as h,whenOnce as d}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as c,convertUnit as f,getMetersPerUnitForSR as y,inchesPerMeter as v}from"../../core/units.js";import{property as T,subclass as w}from"../../core/accessorSupport/decorators.js";import _ from"../../geometry/Extent.js";import I from"../../geometry/SpatialReference.js";import{formatDate as g,convertDateFormatToIntlOptions as b}from"../../intl/date.js";import{getLocaleLanguage as x}from"../../intl/locale.js";import O from"../../portal/Portal.js";import E from"../../portal/PortalQueryParams.js";import{execute as P,getPrintCache as S,getTaskInfo as L}from"../../rest/print.js";import{formatJsonMap as U}from"../../rest/support/fileFormat.js";import{fromJSON as k}from"../../rest/support/layoutTemplate.js";import C from"../../rest/support/LegendLayer.js";import j from"../../rest/support/PrintParameters.js";import{getVisibleLayerViews as F}from"../../rest/support/printTaskUtils.js";import M from"../../rest/support/PrintTemplate.js";import{getExtent as H}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as A}from"../../views/input/InputManager.js";import D from"../../views/overlay/BoxOverlayItem.js";import N from"./CustomTemplate.js";import W from"./FileLink.js";import R from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as V,valueUnitKebabDict as z}from"./utils.js";const B=[30,144,255,255],q=[237,211,23,255],G=[216,48,32,255],J=/(\/GPServer\/).+/i,$=96,Q=i.ofType(N),K=i.ofType(W),X=new a({Feet:"feet",Miles:"miles",Meters:"meters",Kilometers:"kilometers"});function Y(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find(t=>e in t)){const{customTextElements:e}=t.layoutOptions;let i=g(Date.now(),b("short-date"));"ar"===x()&&(i=""+i),e.push({date:i})}}function Z(t,e,i){const s=t.visible??!0,o=t.legendEnabled??!0;if(!s||!o)return;const a=0===e,r=t.minScale??0,l=t.maxScale??0;if(!(a||(0===r||e<=r)&&(0===l||e>=l)))return;const n=t.sublayers?.toArray();if(n)for(const p of n)Z(p,e,i);else null!=t.id&&i.push(String(t.id))}function tt(t,e,i,s){if(!e.layoutOptions)return;if(!i)return void(e.layoutOptions.legendLayers=[]);if(!t)return;let o=0;e.scalePreserved&&(o=e.outScale||t.scale);const a=F(t),r=[];for(const l of a)if(l.legendEnabled){const t="sublayers"in l.layer&&l.layer.sublayers?l.layer.sublayers.toArray():void 0,e=[];for(const i of t??[])Z(i,o,e);r.push(new C({layerId:l.layer.id,title:l.layer.title||void 0,subLayerIds:t?e:void 0,dynamicLegend:s}))}e.layoutOptions.legendLayers=r}function et(t,e,i){if(!e)return;!(e.visible===i)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:i}:t.layoutOptions.elementOverrides={[e.name]:{visible:i}})}let it=class extends(l(n(o))){constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this._portalLayoutInfoTaskUrl=null,this._customLayoutOptions=null,this._exportedFileNameMap={},this._layoutTemplateInfosCache=new Map,this._tasksInfoCache=new Map,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new Q,this.datumTransformations=null,this.defaultTemplates=new Q,this.error=null,this.exportedLinks=new K,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=O.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new Q,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.saveExportEnabled=!1,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new R}initialize(){this.addHandles([m(()=>[this.showPrintAreaEnabled,this.view],()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))}),m(()=>[this.templateOptions.layout,this.templateOptions.layoutItem],()=>{this.loaded&&this._processTemplateOptions().catch(()=>{})}),m(()=>[this.allowedFormats,this.allowedLayouts],()=>{this.loaded&&this._loadTemplateInfos().catch(()=>{})}),m(()=>this.exportedLinks,()=>{const t={};for(const{name:e,extension:i}of this.exportedLinks){if(!e||!i)continue;const s=`${e}${i}`,o=t[s];t[s]=void 0!==o?o+1:0}this._exportedFileNameMap=t},h)])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=r(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach(e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach(e=>{const[i]=Object.entries(e)[0];t?.forEach(t=>{const[s,o]=Object.entries(t)[0];i===s&&(e[i]=o)})})}}),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async print(t){const{view:e,extraParameters:i,updateDelay:o,outSpatialReference:a,datumTransformations:r}=this;if(!e)throw new s("print:view-required","view is not set");Y(t);const l=this._getOverlayItem(),n=t.scalePreserved||!this.showPrintAreaEnabled?void 0:H(new _,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[l.boxWidth,l.boxHeight]),p=new j({view:e,template:t,extent:n,extraParameters:i,updateDelay:o,outSpatialReference:a,datumTransformations:r});try{const e=!!t.layoutItem?.id&&(this.defaultTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id)||this.browseTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id));return await P(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,p,{timeout:this.printTimeout})}catch(m){throw new s("print:export-error","An error occurred while exporting the web map.",{error:m})}}async load(t){return this.addResolvingPromise(this._loadResources(t).catch(t=>this.error=t)),this}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:o,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:h,layoutItem:d,legendEnabled:u,dynamicLegendEnabled:c,northArrowEnabled:f,scale:y,scaleBarEnabled:v,scaleBarUnit:T,scaleEnabled:w,title:_,width:I}){if(!h&&!d)throw new s("print:layout-required","layout is not set");const g={};e&&(g.authorText=e),i&&(g.copyrightText=i),o&&(g.customTextElements=o),_&&(g.titleText=_),v&&T&&(g.scalebarUnit=X.toJSON(T));const b=new M({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:d,layoutOptions:g,outScale:y??0,scalePreserved:w});if(I&&(b.exportOptions.width=I),n&&(b.exportOptions.height=n),a&&(b.exportOptions.dpi=a),b.layoutOptions){tt(this.view,b,u,c);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)et(b,t,f);const i=t.scaleBar;for(const t of i)et(b,t,v);const s=t.legend;for(const t of s)et(b,t,u)}}return b}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{if("loading"===this.loadStatus&&await d(()=>this.loaded),!this.loaded)throw new s("print:load-required","PrintViewModel must be loaded before adding portal templates.");t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new N({type:"browse-template",layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(t&&t===this.getLayoutTemplateById(this.templateOptions.id))return;if(this.templateOptions.reset(),!t)return;if("map-only"===t)return void(this.templateOptions.layout="map-only");!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout||t.layoutItem?.id,i=e?this.templateCustomTextElements?.[e]:void 0;if(await this.templateOptions.applyTemplate(t,{customTextElements:i,customLayoutOptions:this._customLayoutOptions}),e&&this._serviceTemplateCustomTextElements&&!this._serviceTemplateCustomTextElements[e]&&t.layoutTemplateInfo?.layoutOptions?.customTextElements){const i=r(this._serviceTemplateCustomTextElements);i[e]=t.layoutTemplateInfo.layoutOptions.customTextElements,this._serviceTemplateCustomTextElements=Object.freeze(i)}}createExportedFileLink(t){const e=this.toPrintTemplate(this.templateOptions).format.toLowerCase(),i=e.includes("png")?"png":e,s=t+i;return this._updateExportedFileNameMap(s),new W({name:t,extension:i,count:this._exportedFileNameMap[s]})}export(t){const e=this.createExportedFileLink(t);this.exportedLinks.add(e);const i=this.print(this.toPrintTemplate(this.templateOptions)).then(t=>e.set({url:t?.url,state:"ready"})).catch(t=>e.set({error:t,state:"error"}));return this.emit("submit",{link:e,saveExportEnabled:this.saveExportEnabled}),i.then(t=>this.emit("complete",{link:t,saveExportEnabled:this.saveExportEnabled})),{link:e,promise:i}}async _loadResources(t){if(!this.destroyed){if(await this._loadUrls(t),await this._loadTemplateInfos(t),this.effectivePrintServiceUrl){const e=await S(this.effectivePrintServiceUrl,t);this.cimVersion=e?.cimVersion}await this._updateOverLayItem()}}async _loadTemplateInfos(t){const e=[...this.defaultTemplates,...this.printServiceTemplates];for(const{id:o}of e)this._templateIdToCustomTemplate.delete(o);this.defaultTemplates.removeAll(),this.printServiceTemplates.removeAll();const[i,s]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(i,s,t),this._processPrintServiceTemplatesInfo(s),await this._processTemplateOptions()}_updateExportedFileNameMap(t){void 0!==this._exportedFileNameMap[t]?this._exportedFileNameMap[t]++:this._exportedFileNameMap[t]=0}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t)if(this._customLayoutOptions={legend:this.templateOptions.legendEnabled,northArrow:this.templateOptions.northArrowEnabled,scaleBar:this.templateOptions.scaleBarEnabled},e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new N({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find(t=>t.layout===this.templateOptions.layout)??this.printServiceTemplates.find(t=>t.layout===this.templateOptions.layout);await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:i,layoutInfoTask:s}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=i?.url,this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t),s?.url&&this.effectivePrintServiceUrl!==s.url?this._portalLayoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(s.url,t):this._portalLayoutInfoTaskUrl=this._layoutInfoTaskUrl}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _getLayoutInfoTaskUrl(t,e){if(!t)return null;const i=await L(t,"GetLayoutTemplatesInfo",e);return i?t.replace(J,`$1${encodeURI(i.displayName)}`):null}_getPortalDefaultTemplates(t,e){return this.portal?.helperServices?.printTask?.templates?.filter(t=>"map_only"!==t.layout.toLowerCase()&&(!e||e.includes(k(t.layout))))?.map(e=>{const i=N.fromJSON(e);if(i.type="default-template",i.layoutInfoTaskUrl=this._layoutInfoTaskUrl,i.layout){const e=t.get(i.layout);e&&i.setLayoutTemplateInfo(e)}return i})??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{portal:e}=this,{layoutGroupQuery:i,sourceJSON:s}=e,{state:o,user:a}=s??{},{availableCredits:r=0,assignedCredits:l=0}=a??{},n="suspended"===o,p="active"===o&&r<=0&&l>0,m=a?.privileges?.includes("premium:user:print:customlayout");if(!i||n||p||!m)return[];const h=new E({query:i,disableExtraQuery:!0}),d=await this.portal.queryGroups(h,t);if(!d.total)return[];const u=d.results[0],c=new E({num:100,query:"type:Layout",sortField:u.sortField,sortOrder:u.sortOrder??void 0}),f=(await u.queryItems(c,t)).results;if(!f.length)return[];return f.map(t=>(this.portalTemplateIds.push(t.id),new N({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl})))}async _loadAllTemplates(t,e,i){let s=!1;const o=e?.layout?.choiceList;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const e=this._getPortalDefaultTemplates(t,o);s=!!e.length,this.defaultTemplates.addMany(e);const a=await this._getPortalCustomTemplates(i);this.defaultTemplates.addMany(a);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}s||t.forEach((t,e)=>{if(!o||o.includes(e)){const i=new N({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});i.setLayoutTemplateInfo(t),this.printServiceTemplates.add(i),this._templateIdToCustomTemplate.set(i.id,i)}})}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;if(e&&"map-only"!==e){const t=this.defaultTemplates.find(t=>t.layout===e)??this.printServiceTemplates.find(t=>t.layout===e)??this.defaultTemplates.at(0)??this.printServiceTemplates.at(0);this._set("defaultTemplate",t)}}async _getLayoutToLayoutTemplateInfos(t){const e=this._layoutInfoTaskUrl,i=e?this._layoutTemplateInfosCache.get(e):void 0,s=i??(e?await V(e,void 0,t):[]);!i&&e&&this._layoutTemplateInfosCache.set(e,s);const o=new Map,a={};for(const r of s){const t=k(r.layoutTemplate);o.set(t,r),a[t]=r.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(a),o}async _getPrintServiceTemplatesInfo(t){const e=this.effectivePrintServiceUrl?this._tasksInfoCache.get(this.effectivePrintServiceUrl):void 0,i=e??(this.effectivePrintServiceUrl?await L(this.effectivePrintServiceUrl,"ExportWebMap",t):void 0);if(!i)throw new s("print:unavailable-service-info","Can't fetch templates info from service");!e&&this.effectivePrintServiceUrl&&this._tasksInfoCache.set(this.effectivePrintServiceUrl,i);const{parameters:o}=i,a=o.find(({name:t})=>"Format"===t),r=o.find(({name:t})=>"Layout_Template"===t);return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const i="all"===this.allowedFormats?t.choiceList:t.choiceList.filter(t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some(e=>new RegExp(`\\b${e}\\b`,"i").test(t))),s=(i.length?i:t.choiceList).map(t=>U.fromJSON(t)).filter(e),o=U.fromJSON(t.defaultValue),a=s.some(t=>new RegExp(`\\b${o}\\b`,"i").test(t))?o:s[0];return{choiceList:s,defaultValue:a}}_getLayout(t){const i=t.choiceList.filter(t=>"map_only"!==t.toLowerCase()),s="all"===this.allowedLayouts?i:i.filter(t=>this.allowedLayouts.includes(k(t))),o=(s.length?s:i).map(k).filter(e),a=k(t.defaultValue),r=o.includes(a)?a:o.find(t=>/(?=.*letter)(?=.*landscape)/i.test(t))??o.find(t=>/(?=.*a4)(?=.*landscape)/i.test(t))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new D({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m(()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,t.dpi,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded],()=>{this._updateOverLayItem()},h),this.view?.on("drag",["Shift"],t=>this._handleDrag(t),A.WIDGET),this.view?.on("key-down",["Escape"],()=>this._resetDrag(),A.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}async _updateOverLayItem(){if(!this.view)return;await this.view.when();const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,s=this.view,o=s.spatialReference,[a,r]=s.state.paddedViewState.size,l=s.state.padding;let n=0,p=0;if("map-only"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(i){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:i,pageUnits:s}=e?.layoutTemplateInfo??{};let l=!1;if(i&&s)if(this._isFreeHand){const t=i[0]/i[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=z.fromJSON(s.toLowerCase()),e=o.unit;c(t)===c(e)?(n=f(i[0],t,e),p=f(i[1],t,e)):(l=!0,n=i[0],p=i[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const t=l?Math.min(a/n,r/p):y(o)*v*$;n*=t,p*=t}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:h}=t,d=m&&h?h/this.view.scale:1;if(e.boxWidth=n*d||a,e.boxHeight=p*d||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=q;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=q;break;case"ready":e.strokeColor=B;break;case"error":e.strokeColor=G}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:s}=t,{x:o,y:a}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),s>a?(e.y=a,e.boxHeight=s-a):(e.y=s,e.boxHeight=a-s)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(u(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([T()],it.prototype,"_serviceTemplateCustomTextElements",void 0),t([T()],it.prototype,"_templateIdToCustomTemplate",void 0),t([T()],it.prototype,"allowedFormats",void 0),t([T()],it.prototype,"allowedLayouts",void 0),t([T({type:Q})],it.prototype,"browseTemplates",void 0),t([T()],it.prototype,"cimVersion",void 0),t([T()],it.prototype,"datumTransformations",void 0),t([T({type:Q})],it.prototype,"defaultTemplates",void 0),t([T()],it.prototype,"error",void 0),t([T({type:K})],it.prototype,"exportedLinks",void 0),t([T()],it.prototype,"extraParameters",void 0),t([T()],it.prototype,"includeDefaultTemplates",void 0),t([T({readOnly:!0})],it.prototype,"effectivePrintServiceUrl",null),t([T()],it.prototype,"effectiveTemplateCustomTextElements",null),t([T({type:I})],it.prototype,"outSpatialReference",void 0),t([T({type:O})],it.prototype,"portal",void 0),t([T()],it.prototype,"portalTemplateIds",void 0),t([T({type:Q})],it.prototype,"printServiceTemplates",void 0),t([T({readOnly:!0})],it.prototype,"defaultTemplate",void 0),t([T()],it.prototype,"showPrintAreaEnabled",void 0),t([T()],it.prototype,"printServiceUrl",void 0),t([T()],it.prototype,"printTimeout",void 0),t([T()],it.prototype,"saveExportEnabled",void 0),t([T({readOnly:!0})],it.prototype,"state",null),t([T({readOnly:!0})],it.prototype,"templatesInfo",void 0),t([T()],it.prototype,"updateDelay",void 0),t([T()],it.prototype,"view",void 0),t([T()],it.prototype,"templateCustomTextElements",void 0),t([T({type:R})],it.prototype,"templateOptions",void 0),it=t([w("esri.widgets.Print.PrintViewModel")],it);const st=it;export{st as default};
|
package/widgets/Print.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{formatNumber as t}from"../intl.js";import i from"../core/Collection.js";import{deprecateWidget as a}from"../core/deprecate.js";import{JSONMap as l}from"../core/jsonMap.js";import o from"../core/Logger.js";import{watch as n,on as s,whenOnce as r}from"../core/reactiveUtils.js";import{unitName as c}from"../core/unitFormatUtils.js";import{addProxy as p,hasSameOrigin as d}from"../core/urlUtils.js";import{property as m,subclass as u}from"../core/accessorSupport/decorators.js";import{ensureInteger as h}from"../core/accessorSupport/ensureType.js";import b from"../geometry/SpatialReference.js";import{isValid as _}from"../geometry/support/spatialReferenceUtils.js";import v from"../portal/Portal.js";import{reArcGISOnlineDomain as g}from"../portal/support/urlUtils.js";import{findToken as f}from"../rest/utils.js";import{formatJsonMap as y}from"../rest/support/fileFormat.js";import T from"./Widget.js";import w from"./Print/FileLink.js";import k from"./Print/PrintViewModel.js";import x from"./Print/TemplateOptions.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{globalCss as S}from"./support/globalCss.js";import{Heading as I}from"./support/Heading.js";import{legacyIcon as O}from"./support/legacyIcon.js";import{messageBundle as L,tsx as E,isRTL as $,tsxFragment as F,isActivationKey as M}from"./support/widget.js";const P="map-only",A="esri-print",R={base:A,headerTitle:`${A}__header-title`,layoutTabList:`${A}__layout-tab-list`,layoutTab:`${A}__layout-tab`,layoutSection:`${A}__layout-section`,mapOnlySection:`${A}__map-only-section`,panelItemsCentered:`${A}__panel-items--centered`,loader:`${A}__loader`,swapButton:`${A}__swap-button`,printButton:`${A}__export-button`,printButtonSection:`${A}__export-button-section`,printButtonSectionDivider:`${A}__export-button-section--divider`,templateSelectContainer:`${A}__template-select-container`,templateSelectIcon:`${A}__template-select-icon`,templateSelectError:`${A}__template-select-error`,templateSelectArrow:`${A}__template-select-arrow`,formSectionContainer:`${A}__form-section-container`,advancedOptionsSection:`${A}__advanced-options-section`,advancedOptionsContainer:`${A}__advanced-options-container`,browseTemplateButtonContainer:`${A}__browse-template-button-container`,browseTemplateButtonContainerFilter:`${A}__browse-template-button-container-filter`,exportedFilesContainer:`${A}__export-panel-container`,exportedFilesTitle:`${A}__export-title`,exportedFile:`${A}__exported-file`,exportedFileLinkTitle:`${A}__exported-file-link-title`,exportedFileLinkDescription:`${A}__exported-file-link-description`,exportedFilesEmpty:`${A}__exported-files-empty`,printWidgetContainer:`${A}__container`,content:`${A}__content`,panelContainer:`${A}__panel-container`,scaleInfoContainer:`${A}__scale-info-container`,scaleInputContainer:`${A}__scale-input-container`,scaleInput:`${A}__scale-input`,sizeContainer:`${A}__size-container`,panelError:`${A}__panel--error`,exportedFileLoader:`${A}__exported-file--loader`,exportSection:`${A}__export-section`,exportSectionCentered:`${A}__export-section--centered`,templateButtonContainer:`${A}__template-button-container`,templateDoneButton:`${A}__template-done-button`,templateSelectFlowItemContainer:`${A}__template-select-flow-item-container`,templateSelectFlowItemContent:`${A}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${A}__template-select-flow-item-list-heading`,srLabel:`${A}__sr-label`,invalidWkidText:`${A}__invalid-wkid-text`};function D(e){return!isNaN(e)&&e>0&&Number.isFinite(e)}function B(e){return e?.toLowerCase()===P}function N(e){const{state:t,extension:i}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return i?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}const V=new l({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),j=new Map([["a3-landscape","a3-landscape"],["a3-portrait","a3-portrait"],["a4-landscape","a4-landscape"],["a4-portrait","a4-portrait"],["letter-ansi-a-landscape","ansi-a-landscape"],["letter-ansi-a-portrait","ansi-a-portrait"],["tabloid-ansi-b-landscape","ansi-b-landscape"],["tabloid-ansi-b-portrait","ansi-b-portrait"]]);let U=class extends T{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._selectedTab="layoutTab",this._pendingExportScroll=!1,this._rootNode=null,this._selectedTemplate=null,this._formats=[],this._showTemplates=!1,this._isValidSpatialReference=!0,this.allowedFormatsForSaving=null,this.browseTemplateButtonOnClick=null,this.headerVisible=!0,this.headingLevel=3,this.includeOrganizationTemplates=!0,this.messagesCommon=null,this.messagesUnits=null,this.saveExportHidden=!0,this.saveAsButtonCallback=null,this.viewModel=new k,this._onInput=e=>{"layoutTab"===this._selectedTab?this.templateOptions.title=e.currentTarget.value:"mapOnlyTab"===this._selectedTab&&(this.templateOptions.fileName=e.currentTarget.value)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const i=f(this.viewModel.effectivePrintServiceUrl),a=t.url,l=document.createElement("a");if(l.target="_blank",l.href=a,l.rel="noreferrer",l.download=t.formattedName??"",!i)return l.click(),void e.stopPropagation();e.preventDefault();const o=new URL(a);o.searchParams.set("token",i),l.href=o.href,l.click(),l.href=a},a(o.getLogger(this),"Print","arcgis-print",{version:"4.33"}),this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([n(()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format],()=>{const{templatesInfo:e}=this.viewModel;if(!e)return;if(this._formats.length!==e.format.choiceList.length){const t=y.apiValues;this._formats=e.format.choiceList.map(e=>{const i=t.find(t=>new RegExp(`\\b${t}\\b`,"i").test(e))??e;return{value:i,label:e===i?e.toUpperCase():e}}).sort((e,t)=>e.label.localeCompare(t.label))}const t=this._formats.some(({value:e})=>new RegExp(`\\b${e}\\b`,"i").test(this.templateOptions.format));if(e.format.defaultValue&&!t){const t=this._formats.find(({value:t})=>new RegExp(`\\b${t}\\b`,"i").test(e.format.defaultValue))?.value;return void(t&&(this.templateOptions.format=t))}}),n(()=>[this.templateOptions.id,this.viewModel.loaded],()=>{const{layout:e}=this.templateOptions;this._selectedTab=B(e)?"mapOnlyTab":"layoutTab","layoutTab"===this._selectedTab&&this.viewModel.loaded&&(this._selectedTemplate=this.viewModel.getLayoutTemplateById(this.templateOptions.id))}),n(()=>this.templateOptions.dpi,e=>{e<=0&&(this.templateOptions.dpi=1)}),n(()=>this.viewModel.view?.scale,e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}),s(()=>this.viewModel,"submit",e=>this.emit("submit",e)),s(()=>this.viewModel,"complete",e=>this.emit("complete",e))]);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const i=setTimeout(()=>{this._awaitingServerResponse=!0,this.scheduleRender()},500);this.viewModel.load().then(()=>{clearTimeout(i),this._awaitingServerResponse=!1})}loadDependencies(){return C({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover"),link:()=>import("@esri/calcite-components/dist/components/calcite-link")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get exportedLinks(){return this.viewModel.exportedLinks}set exportedLinks(e){this.viewModel.exportedLinks=e}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get outSpatialReference(){return this.viewModel.outSpatialReference}set outSpatialReference(e){this.viewModel.outSpatialReference=e}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get saveExportEnabled(){return this.viewModel.saveExportEnabled}set saveExportEnabled(e){this.viewModel.saveExportEnabled=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:i,view:a}=this,{attributionEnabled:l,author:o,copyright:n,dpi:s,format:r,height:c,layout:p,layoutItem:d,legendEnabled:m,northArrowEnabled:u,scaleBarEnabled:v,scaleEnabled:g,scale:f,width:y}=t,T="ready"!==i.state||this._awaitingServerResponse||!(p||d),w=this._renderTitleOrFileNameSection(),k=E("div",{class:R.formSectionContainer},E("calcite-label",null,e.fileFormatTitle,E("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",topLayerDisabled:this.topLayerDisabled,onCalciteComboboxChange:({currentTarget:e})=>{this.templateOptions.format=e.selectedItems[0]?.value??"pdf"}},this._formats.map(({value:e,label:t},i)=>E("calcite-combobox-item",{heading:t,key:`file-format-${i}`,selected:e===this.templateOptions.format,value:e}))))),x=E("calcite-label",{layout:"inline"},E("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.currentTarget.checked}}),e.printPreview),C=E("div",null,E("div",{class:R.formSectionContainer},E("calcite-label",null,e.template,E("calcite-block",{class:R.templateSelectContainer,collapsible:!1,description:this._getPageSizeLabel(this._selectedTemplate),heading:this._getTemplateLabel(this._selectedTemplate,!0),key:"template-select-block",label:e.template,loading:"loading"===this._selectedTemplate?.state,tabIndex:0,onclick:()=>this._showTemplates=!0,onkeydown:e=>{"Enter"!==e.key&&" "!==e.key||(this._showTemplates=!0)}},E("calcite-icon",{class:R.templateSelectIcon,icon:(this._selectedTemplate?.layout?j.get(this._selectedTemplate.layout):null)||"custom-print",key:"template-select-icon",scale:"l",slot:"content-start"}),"error"===this._selectedTemplate?.state?E("calcite-icon",{class:R.templateSelectError,icon:"exclamation-mark-circle",key:"template-select-error",scale:"s",slot:"actions-end"}):null,E("calcite-icon",{class:R.templateSelectArrow,icon:$()?"chevron-left":"chevron-right",key:"template-select-arrow",scale:"s",slot:"actions-end"})))),x),L=E("div",{class:R.formSectionContainer},E("calcite-label",null,e.dpi,E("calcite-input-number",{bind:this,"data-input-name":"dpi",min:1,value:`${s}`,onCalciteInputNumberInput:this._updateNumberInputValue}))),F=E("div",{class:R.formSectionContainer},E("calcite-label",null,E("div",{class:R.srLabel},e.outSpatialReference,E("calcite-link",{href:"https://developers.arcgis.com/rest/services-reference/enterprise/using-spatial-references/",target:"_blank"},"(WKID)")),E("calcite-input-number",{bind:this,"data-input-name":"outSpatialReference",integer:!0,numberButtonType:"none",value:i.outSpatialReference?.wkid?.toString()??"",onCalciteInputNumberInput:({currentTarget:e})=>{const t=h(e.value);i.outSpatialReference=Number.isNaN(t)||null==t?null:new b({wkid:t}),this._isValidSpatialReference=!i.outSpatialReference||_(i.outSpatialReference)}}),this._isValidSpatialReference?null:E("div",{class:R.invalidWkidText,key:`out-sr-${i.outSpatialReference?.wkid}`},e.invalidWkid))),M=E("div",{class:this.classes(R.scaleInfoContainer,R.formSectionContainer)},E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:g,"data-option-name":"scaleEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scale),E("div",{class:R.scaleInputContainer},E("calcite-input-number",{"aria-label":e.scaleLabel,"aria-valuenow":`${f}`,bind:this,class:R.scaleInput,"data-input-name":"scale",disabled:!g,value:`${f}`,onCalciteInputNumberInput:this._updateNumberInputValue}),E("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!g,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale}))),P=E("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:R.advancedOptionsContainer,key:"advanced-section-for-layout"},M,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?E("div",{class:R.formSectionContainer,key:"author-info"},E("calcite-label",null,e.author,E("calcite-input",{bind:this,"data-input-name":"author",value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?E("div",{class:R.formSectionContainer,key:"copyright-text"},E("calcite-label",null,e.copyright,E("calcite-input",{bind:this,"data-input-name":"copyright",value:n??"",onCalciteInputInput:this._updateInputValue}))):null,L,F,this._renderCustomTextElementSection(),this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasLegend??1?E("div",{class:R.formSectionContainer,key:"legend-info"},E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:!!m,"data-option-name":"legendEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this._selectedTemplate?.mapSurroundInfoOptions?.northArrow.length?E("div",{class:R.formSectionContainer,key:"north-arrow"},E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:!!u,"data-option-name":"northArrowEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._selectedTemplate?.mapSurroundInfoOptions?.scaleBar.length?E("div",{class:R.formSectionContainer,key:"scale-bar"},E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:!!v,"data-option-name":"scaleBarEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scaleBar)):null),A=E("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:R.advancedOptionsContainer},M,L,F,E("div",{class:R.formSectionContainer},E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:l,"data-option-name":"attributionEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),D=this.exportedLinks.toArray(),B=this._renderExportedLinkItems(D),N={[R.exportSectionCentered]:!D.length},V="layoutTab"===this._selectedTab?E("section",{"aria-labelledby":`${this.id}__layoutTab`,class:R.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},E("div",{class:R.panelContainer},this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?w:null,C,"layoutTab"===this._selectedTab?k:null,E("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(R.panelContainer,R.advancedOptionsSection),collapsible:!0,disabled:!(p||d?.id),heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},P))):"mapOnlyTab"===this._selectedTab?E("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:R.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},E("div",{class:R.panelContainer},w,k,E("div",null,E("div",{class:this.classes(R.sizeContainer,R.formSectionContainer)},E("calcite-label",null,e.width,E("calcite-input-number",{bind:this,"data-input-name":"width",value:`${y}`,onCalciteInputNumberInput:this._updateNumberInputValue})),E("calcite-label",null,e.height,E("calcite-input-number",{bind:this,"data-input-name":"height",value:`${c}`,onCalciteInputNumberInput:this._updateNumberInputValue})),E("button",{"aria-label":e.swap,bind:this,class:this.classes(S.widgetButton,R.swapButton,O.swap),type:"button",onclick:this._switchInput})),x),E("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(R.panelContainer,R.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},A))):E("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(R.exportSection,N),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},E("div",{class:R.panelContainer},E("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:R.exportedFilesContainer},0===D.length?E("div",{class:R.exportedFilesEmpty},E("calcite-icon",{icon:"file",scale:"l"}),E("div",null,E(I,{class:R.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),E("div",null,e.exportHint))):B))),U="2d"!==a?.type,H=E("div",{class:R.panelError},a?U?e.sceneViewError:e.serviceError:e.noViewError),z=D.some(({state:e})=>"pending"===e),W=E("div",{class:R.content,key:"panel"},E("div",null,E("ul",{bind:this,class:R.layoutTabList,role:"tablist",onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown},E("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"layoutTab"===this._selectedTab}`,class:R.layoutTab,"data-tab-id":"layoutTab",id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),E("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"mapOnlyTab"===this._selectedTab}`,class:R.layoutTab,"data-tab-id":"mapOnlyTab",id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),E("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"exportTab"===this._selectedTab}`,class:R.layoutTab,"data-tab-id":"exportTab",id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},z?E("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),V),"exportTab"!==this._selectedTab?E("div",{class:this.classes(R.printButtonSection,!this.saveExportHidden&&this.portal?R.printButtonSectionDivider:null),key:"export-button-section"},!this.saveExportHidden&&this.portal?E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:this.saveExportEnabled,onCalciteCheckboxChange:e=>{this.saveExportEnabled=!!e.currentTarget.checked}}),e.saveExportToMyContent):null,E("calcite-button",{"aria-label":e.exportDescription,bind:this,class:this.classes(R.printButton),disabled:T||!(p||d?.id)&&!r,scale:"l",width:"full",onclick:this._handlePrintMap},e.export)):null),q=E("calcite-flow",{key:"root-flow"},E("calcite-flow-item",{bind:this,key:"root-flow-item",selected:!this._showTemplates},E("div",{class:R.printWidgetContainer},this.headerVisible?E("header",{class:R.headerTitle},e.export):null,this.error||U||!a?H:W)),this._renderChooseTemplateFlowItem()),K="initializing"===i.state,J=K?this._renderLoader():q,G={[R.panelItemsCentered]:K};return E("div",{bind:this,class:this.classes(R.base,S.widget,S.panel,G)},J)}_getPageSizeLabel(e){if(!e)return;const i=e.layoutTemplateInfo;if(!i)return;const a=V.fromJSON(i.pageUnits.toLowerCase());return`${t(i.pageSize[0])} × ${t(i.pageSize[1])} ${c(this.messagesUnits,a,"abbr")}`}_getTemplateLabel(e,t=!1){if(!e)return t?this.messages.selectTemplate:this.messages.untitled;const{label:i,layout:a,layoutItem:l}=e,o=a&&!l&&this.messages[a]?this.messages[a]:null;if(o)return o;const n=i??a??l?.id;return n?.replaceAll("_"," ")??this.messages.untitled}_getPortalTemplates(){return this.includeDefaultTemplates&&this.includeOrganizationTemplates?this.viewModel.defaultTemplates.toArray().filter(({layout:e,layoutItem:t})=>!B(e)&&!!t?.id):[]}_getDefaultTemplates(){return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter(({layout:e,layoutItem:t})=>!B(e)&&!t?.id):[]}_getPrintServiceTemplates(){return this.includeDefaultTemplates&&this._getDefaultTemplates().length?[]:this.viewModel.printServiceTemplates.toArray().filter(({layout:e})=>!B(e))}_renderLayoutTemplates(e,t=!1,i=!1){return t&&e.sort((e,t)=>(e.label??"")>(t.label??"")?1:-1),e.map(e=>E("calcite-list-item",{description:this._getPageSizeLabel(e),key:`template-${e.id}-${e.id===this.templateOptions.id}`,label:this._getTemplateLabel(e),selected:e.id===this.templateOptions.id,title:e.description??"",value:e},E("calcite-icon",{icon:(e.layout?j.get(e.layout):null)||"custom-print",slot:"content-start"}),"loading"===e.state?E("calcite-loader",{inline:!0,key:`template-loader-${e.id}`,label:"loading",scale:"s",slot:"content-end"}):null,"error"===e?.state?E("calcite-icon",{class:R.templateSelectError,icon:"exclamation-mark-circle",key:`template-error-${e.id}`,scale:"s",slot:"content-end"}):null,i?E("calcite-action",{icon:"trash",slot:"actions-end",text:"delete",onclick:()=>this.viewModel.removePortalTemplate(e)}):null))}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{messages:e}=this,t=g.test(this.portal?.url),i=this.viewModel.browseTemplates.toArray(),a=this._getPortalTemplates(),l=this._getDefaultTemplates(),o=this._getPrintServiceTemplates(),n=i.length+a.length+l.length+o.length>15,s=this.browseTemplateButtonOnClick?E("calcite-button",{appearance:"outline",class:n?R.browseTemplateButtonContainerFilter:R.browseTemplateButtonContainer,iconStart:"folder",key:"browse-template-button",slot:n?"filter-actions-end":"default",onclick:this.browseTemplateButtonOnClick},n?null:e.browseTemplates):null;return E("calcite-flow-item",{bind:this,closable:!1,heading:e.chooseTemplate,key:"template-flow-item",selected:this._showTemplates,onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},E("div",{class:R.templateSelectFlowItemContainer},E("div",{class:R.templateSelectFlowItemContent},n?null:s,E("calcite-list",{filterEnabled:n,filterProps:["label"],key:"template-list",label:e.templateList,selectionMode:"single-persist",onCalciteListChange:({currentTarget:e})=>this.viewModel.applyTemplate(e.selectedItems[0]?.value)},n?s:null,i.length?E("div",{key:"my-templates"},E("div",{class:R.templateSelectFlowItemListHeading},e.myTemplates,t?E("calcite-chip",{appearance:"outline",kind:"neutral",label:e.beta,scale:"s"},e.beta):null),this._renderLayoutTemplates(i,!0,!0)):null,a.length?E("div",{key:"org-templates"},E("div",{class:R.templateSelectFlowItemListHeading},e.organizationTemplates,t?E("calcite-chip",{appearance:"outline",kind:"neutral",label:e.beta,scale:"s"},e.beta):null),this._renderLayoutTemplates(a)):null,i.length||a.length?l.length?E("div",{key:"default-templates"},E("div",{class:R.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(l,!0)):null:this._renderLayoutTemplates(l,!0),i.length||a.length?o.length?E("div",{key:"service-templates"},E("div",{class:R.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(o)):null:this._renderLayoutTemplates(o))),E("div",{class:R.templateButtonContainer},E("calcite-button",{class:R.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?E("div",{class:R.formSectionContainer,key:"custom-text-elements"},e.map((e,t)=>{const[i,a]=Object.entries(e)[0];return"date"===i?null:E("calcite-label",{key:`custom-text-elements-${i}-${t}`},i,E("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":i,value:a??"",onCalciteInputInput:this._updateInputValue}))})):null}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:i,fileNamePlaceHolder:a}=this.messages,l="layoutTab"===this._selectedTab?e:t,o="layoutTab"===this._selectedTab?i:a,n="layoutTab"===this._selectedTab?this.templateOptions.title:this.templateOptions.fileName;return E("div",{class:R.formSectionContainer,key:l},E("calcite-label",null,l,E("calcite-input",{placeholder:o,value:n??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(e){if(!this._activeTabFocusRequested)return;const t=e.getAttribute("data-tab-id");("layoutTab"===t&&"layoutTab"===this._selectedTab||"mapOnlyTab"===t&&"mapOnlyTab"===this._selectedTab||"exportTab"===t&&"exportTab"===this._selectedTab)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[R.loader]:this._awaitingServerResponse};return E("div",{class:this.classes(e),key:"loader"})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,i){e.find(e=>{const[i]=Object.entries(e)[0];return i===t})[t]=i}_updateInputValue(e){const t=e.currentTarget,i=t.getAttribute("data-input-name"),a=!!t["data-input-custom"],{templateOptions:l}=this;a?this._updateCustomTextElementValue(l.customTextElements,i,t.value):l[i]=t.value}_updateNumberInputValue(e){const t=e.currentTarget,i=t.getAttribute("data-input-name"),{templateOptions:a}=this,l=Number(t.value);if(!D(l)){const e=a[i];return void(t.value=`${e}`)}a[i]=l}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t="layoutTab"===this._selectedTab?e.title:e.fileName,{promise:i}=this.viewModel.export(t||this.messages.untitled);this._selectedTab="exportTab",i.then(()=>this.scheduleRender())}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:i}=e,a=i-t;a>0&&(e.scrollTop=a)}_toggleInputValue(e){const t=e.target,i=t.getAttribute("data-option-name");this.templateOptions[i]=t.checked,"scaleEnabled"===i&&this._resetToCurrentScale()}_renderExportedLinkItemPopover(e){const t=this.messages,i=e.formattedName??"",{state:a}=e,l=this.saveAsButtonCallback&&"error"!==a&&this._isFormatAllowedForSaving(e.extension);return"pending"!==a&&l?E("calcite-popover",{autoClose:!0,key:`${i}-popover`,label:"Popover",offsetDistance:1,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:`${i}-popover-button`,scale:"s",topLayerDisabled:this.topLayerDisabled},E("calcite-list",{label:""},e.portalItem?E("calcite-list-item",{label:t.openItem,onCalciteListItemSelect:()=>{const t=e.portalItem;if(!t||!t.itemPageUrl)return;const i=document.createElement("a");i.target="_blank",i.href=t.itemPageUrl,i.rel="noreferrer",i.click()}},E("calcite-icon",{icon:"launch2",key:`${i}-launch-icon`,scale:"s",slot:"content-start"})):E("calcite-list-item",{label:t.saveAs,onCalciteListItemSelect:async()=>{this.saveAsButtonCallback&&(r(()=>e.portalItem).then(e=>{e.itemPageUrl&&this.scheduleRender()}),await this.saveAsButtonCallback(e))}},E("calcite-icon",{icon:"save",key:`${i}-save-icon`,scale:"s",slot:"content-start"})),E("calcite-list-item",{label:this.messagesCommon.delete,onCalciteListItemSelect:()=>this.exportedLinks.remove(e)},E("calcite-icon",{icon:"trash",key:`${i}-delete-icon`,scale:"s",slot:"content-start"})))):null}_renderExportedLinkItemContent(e){const t=this.messages,{url:i,state:a,error:l}=e,o=e.formattedName??"";let n=i||null;n&&(n=p(n));const s=d(n,location.href),r="error"===a?"print-task:cim-symbol-unsupported"===l?.name?t.exportWebMapCIMError:t.exportWebMapError:null;return E("div",{class:R.exportedFile,"data-item":e,slot:"content",onclick:this._handleLinkClick},E("div",null,E("div",{class:R.exportedFileLinkTitle},o),E("div",{class:R.exportedFileLinkDescription},"pending"===a?t.generatingExport:r||(s?t.ready:t.linkReady))),"ready"===a?E("calcite-icon",{"aria-label":`${o}. ${t.linkReady}`,icon:s?"download-to":"launch",key:`${o}-end-icon`,scale:"s",slot:"content-end"}):null)}_renderExportedLinkItemIcon(e){const t=e.formattedName??"";return"pending"===e.state?E("calcite-loader",{class:R.exportedFileLoader,inline:!0,key:`${t}-loader`,label:this.messages.generatingExport,scale:"m",slot:"content-start"}):E("calcite-icon",{icon:N(e),key:`${t}-start-icon`,scale:"s",slot:"content-start"})}_renderExportedLinkItemAction(e){const{state:t}=e,i=e.formattedName??"",a=this.saveAsButtonCallback&&"error"!==t&&this._isFormatAllowedForSaving(e.extension);return"pending"!==t?E("calcite-action",{icon:a?"ellipsis":"x",id:a?`${i}-popover-button`:void 0,key:a?`${i}-saveAs-action`:`${i}-action`,slot:"actions-end",text:a?this.messagesCommon.options:this.messagesCommon.remove,onclick:a?void 0:()=>{this.exportedLinks.remove(e)}}):null}_renderExportedLinkItem(e){const t=e.formattedName??"";return E(F,null,E("calcite-list-item",{key:t,label:t},this._renderExportedLinkItemContent(e),this._renderExportedLinkItemIcon(e),this._renderExportedLinkItemAction(e)),this._renderExportedLinkItemPopover(e))}_renderExportedLinkItems(e){return E("calcite-list",{filterEnabled:e?.length>10,label:this.messages.exportedLinksList,selectionMode:"none"},e.map(this._renderExportedLinkItem.bind(this)))}_isFormatAllowedForSaving(e){return!this.allowedFormatsForSaving||"all"===this.allowedFormatsForSaving||!(!e||!this.allowedFormatsForSaving.includes(e))}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,"mapOnlyTab"===this._selectedTab)this.viewModel.applyTemplate(P);else if("layoutTab"===this._selectedTab){const e=this._selectedTemplate??this.viewModel.defaultTemplate;this.viewModel.applyTemplate(e)}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,i=e.target.getAttribute("data-tab-id");if(M(t))return this._toggleTab(i),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(i){case"layoutTab":this._toggleTab("ArrowLeft"===t?"exportTab":"mapOnlyTab");break;case"mapOnlyTab":this._toggleTab("ArrowLeft"===t?"layoutTab":"exportTab");break;case"exportTab":this._toggleTab("ArrowLeft"===t?"mapOnlyTab":"layoutTab")}e.preventDefault(),e.stopPropagation()}}};e([m()],U.prototype,"_showTemplates",void 0),e([m()],U.prototype,"_isValidSpatialReference",void 0),e([m()],U.prototype,"allowedFormats",null),e([m()],U.prototype,"allowedFormatsForSaving",void 0),e([m()],U.prototype,"allowedLayouts",null),e([m()],U.prototype,"browseTemplateButtonOnClick",void 0),e([m()],U.prototype,"error",null),e([m({type:i.ofType(w)})],U.prototype,"exportedLinks",null),e([m()],U.prototype,"extraParameters",null),e([m()],U.prototype,"headerVisible",void 0),e([m()],U.prototype,"headingLevel",void 0),e([m()],U.prototype,"icon",null),e([m()],U.prototype,"includeDefaultTemplates",null),e([m()],U.prototype,"includeOrganizationTemplates",void 0),e([m()],U.prototype,"label",null),e([m(),L("esri/widgets/Print/t9n/Print")],U.prototype,"messages",void 0),e([m(),L("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([m(),L("esri/core/t9n/Units")],U.prototype,"messagesUnits",void 0),e([m({type:b})],U.prototype,"outSpatialReference",null),e([m({type:v})],U.prototype,"portal",null),e([m()],U.prototype,"saveExportEnabled",null),e([m()],U.prototype,"saveExportHidden",void 0),e([m()],U.prototype,"showPrintAreaEnabled",null),e([m()],U.prototype,"printServiceUrl",null),e([m()],U.prototype,"saveAsButtonCallback",void 0),e([m()],U.prototype,"templateCustomTextElements",null),e([m({type:x})],U.prototype,"templateOptions",null),e([m()],U.prototype,"view",null),e([m({type:k})],U.prototype,"viewModel",void 0),U=e([u("esri.widgets.Print")],U);const H=U;export{H as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{formatNumber as t}from"../intl.js";import i from"../core/Collection.js";import{deprecateWidget as a}from"../core/deprecate.js";import{JSONMap as l}from"../core/jsonMap.js";import o from"../core/Logger.js";import{watch as n,on as s,whenOnce as r}from"../core/reactiveUtils.js";import{unitName as c}from"../core/unitFormatUtils.js";import{addProxy as p,hasSameOrigin as d}from"../core/urlUtils.js";import{property as m,subclass as u}from"../core/accessorSupport/decorators.js";import{ensureInteger as h}from"../core/accessorSupport/ensureType.js";import b from"../geometry/SpatialReference.js";import{isValid as _}from"../geometry/support/spatialReferenceUtils.js";import v from"../portal/Portal.js";import{reArcGISOnlineDomain as g}from"../portal/support/urlUtils.js";import{findToken as f}from"../rest/utils.js";import{formatJsonMap as y}from"../rest/support/fileFormat.js";import T from"./Widget.js";import w from"./Print/FileLink.js";import k from"./Print/PrintViewModel.js";import x from"./Print/TemplateOptions.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{globalCss as S}from"./support/globalCss.js";import{Heading as I}from"./support/Heading.js";import{legacyIcon as O}from"./support/legacyIcon.js";import{messageBundle as L,tsx as E,isRTL as $,tsxFragment as F,isActivationKey as M}from"./support/widget.js";const P="map-only",A="esri-print",R={base:A,headerTitle:`${A}__header-title`,layoutTabList:`${A}__layout-tab-list`,layoutTab:`${A}__layout-tab`,layoutSection:`${A}__layout-section`,mapOnlySection:`${A}__map-only-section`,panelItemsCentered:`${A}__panel-items--centered`,loader:`${A}__loader`,swapButton:`${A}__swap-button`,printButton:`${A}__export-button`,printButtonSection:`${A}__export-button-section`,printButtonSectionDivider:`${A}__export-button-section--divider`,templateSelectContainer:`${A}__template-select-container`,templateSelectIcon:`${A}__template-select-icon`,templateSelectError:`${A}__template-select-error`,templateSelectArrow:`${A}__template-select-arrow`,formSectionContainer:`${A}__form-section-container`,advancedOptionsSection:`${A}__advanced-options-section`,advancedOptionsContainer:`${A}__advanced-options-container`,browseTemplateButtonContainer:`${A}__browse-template-button-container`,browseTemplateButtonContainerFilter:`${A}__browse-template-button-container-filter`,exportedFilesContainer:`${A}__export-panel-container`,exportedFilesTitle:`${A}__export-title`,exportedFile:`${A}__exported-file`,exportedFileLinkTitle:`${A}__exported-file-link-title`,exportedFileLinkDescription:`${A}__exported-file-link-description`,exportedFilesEmpty:`${A}__exported-files-empty`,printWidgetContainer:`${A}__container`,content:`${A}__content`,panelContainer:`${A}__panel-container`,scaleInfoContainer:`${A}__scale-info-container`,scaleInputContainer:`${A}__scale-input-container`,scaleInput:`${A}__scale-input`,sizeContainer:`${A}__size-container`,panelError:`${A}__panel--error`,exportedFileLoader:`${A}__exported-file--loader`,exportSection:`${A}__export-section`,exportSectionCentered:`${A}__export-section--centered`,templateButtonContainer:`${A}__template-button-container`,templateDoneButton:`${A}__template-done-button`,templateSelectFlowItemContainer:`${A}__template-select-flow-item-container`,templateSelectFlowItemContent:`${A}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${A}__template-select-flow-item-list-heading`,srLabel:`${A}__sr-label`,invalidWkidText:`${A}__invalid-wkid-text`};function D(e){return!isNaN(e)&&e>0&&Number.isFinite(e)}function B(e){return e?.toLowerCase()===P}function N(e){const{state:t,extension:i}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return i?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}const V=new l({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),j=new Map([["a3-landscape","a3-landscape"],["a3-portrait","a3-portrait"],["a4-landscape","a4-landscape"],["a4-portrait","a4-portrait"],["letter-ansi-a-landscape","ansi-a-landscape"],["letter-ansi-a-portrait","ansi-a-portrait"],["tabloid-ansi-b-landscape","ansi-b-landscape"],["tabloid-ansi-b-portrait","ansi-b-portrait"]]);let U=class extends T{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._selectedTab="layoutTab",this._pendingExportScroll=!1,this._rootNode=null,this._selectedTemplate=null,this._formats=[],this._showTemplates=!1,this._isValidSpatialReference=!0,this.allowedFormatsForSaving=null,this.browseTemplateButtonOnClick=null,this.headerVisible=!0,this.headingLevel=3,this.includeOrganizationTemplates=!0,this.messagesCommon=null,this.messagesUnits=null,this.saveExportHidden=!0,this.saveAsButtonCallback=null,this.viewModel=new k,this._onInput=e=>{"layoutTab"===this._selectedTab?this.templateOptions.title=e.currentTarget.value:"mapOnlyTab"===this._selectedTab&&(this.templateOptions.fileName=e.currentTarget.value)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const i=f(this.viewModel.effectivePrintServiceUrl),a=t.url,l=document.createElement("a");if(l.target="_blank",l.href=a,l.rel="noreferrer",l.download=t.formattedName??"",!i)return l.click(),void e.stopPropagation();e.preventDefault();const o=new URL(a);o.searchParams.set("token",i),l.href=o.href,l.click(),l.href=a},a(o.getLogger(this),"Print","arcgis-print",{version:"4.33"}),this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([n(()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format],()=>{const{templatesInfo:e}=this.viewModel;if(!e)return;if(this._formats.length!==e.format.choiceList.length){const t=y.apiValues;this._formats=e.format.choiceList.map(e=>{const i=t.find(t=>new RegExp(`\\b${t}\\b`,"i").test(e))??e;return{value:i,label:e===i?e.toUpperCase():e}}).sort((e,t)=>e.label.localeCompare(t.label))}const t=this._formats.some(({value:e})=>new RegExp(`\\b${e}\\b`,"i").test(this.templateOptions.format));if(e.format.defaultValue&&!t){const t=this._formats.find(({value:t})=>new RegExp(`\\b${t}\\b`,"i").test(e.format.defaultValue))?.value;return void(t&&(this.templateOptions.format=t))}}),n(()=>[this.templateOptions.id,this.viewModel.loaded],()=>{const{layout:e}=this.templateOptions;this._selectedTab=B(e)?"mapOnlyTab":"layoutTab","layoutTab"===this._selectedTab&&this.viewModel.loaded&&(this._selectedTemplate=this.viewModel.getLayoutTemplateById(this.templateOptions.id))}),n(()=>this.templateOptions.dpi,e=>{e<=0&&(this.templateOptions.dpi=1)}),n(()=>this.viewModel.view?.scale,e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}),s(()=>this.viewModel,"submit",e=>this.emit("submit",e)),s(()=>this.viewModel,"complete",e=>this.emit("complete",e))]);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const i=setTimeout(()=>{this._awaitingServerResponse=!0,this.scheduleRender()},500);this.viewModel.load().then(()=>{clearTimeout(i),this._awaitingServerResponse=!1},()=>{})}loadDependencies(){return C({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover"),link:()=>import("@esri/calcite-components/dist/components/calcite-link")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get exportedLinks(){return this.viewModel.exportedLinks}set exportedLinks(e){this.viewModel.exportedLinks=e}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get outSpatialReference(){return this.viewModel.outSpatialReference}set outSpatialReference(e){this.viewModel.outSpatialReference=e}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get saveExportEnabled(){return this.viewModel.saveExportEnabled}set saveExportEnabled(e){this.viewModel.saveExportEnabled=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:i,view:a}=this,{attributionEnabled:l,author:o,copyright:n,dpi:s,format:r,height:c,layout:p,layoutItem:d,legendEnabled:m,northArrowEnabled:u,scaleBarEnabled:v,scaleEnabled:g,scale:f,width:y}=t,T="ready"!==i.state||this._awaitingServerResponse||!(p||d),w=this._renderTitleOrFileNameSection(),k=E("div",{class:R.formSectionContainer},E("calcite-label",null,e.fileFormatTitle,E("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",topLayerDisabled:this.topLayerDisabled,onCalciteComboboxChange:({currentTarget:e})=>{this.templateOptions.format=e.selectedItems[0]?.value??"pdf"}},this._formats.map(({value:e,label:t},i)=>E("calcite-combobox-item",{heading:t,key:`file-format-${i}`,selected:e===this.templateOptions.format,value:e}))))),x=E("calcite-label",{layout:"inline"},E("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.currentTarget.checked}}),e.printPreview),C=E("div",null,E("div",{class:R.formSectionContainer},E("calcite-label",null,e.template,E("calcite-block",{class:R.templateSelectContainer,collapsible:!1,description:this._getPageSizeLabel(this._selectedTemplate),heading:this._getTemplateLabel(this._selectedTemplate,!0),key:"template-select-block",label:e.template,loading:"loading"===this._selectedTemplate?.state,tabIndex:0,onclick:()=>this._showTemplates=!0,onkeydown:e=>{"Enter"!==e.key&&" "!==e.key||(this._showTemplates=!0)}},E("calcite-icon",{class:R.templateSelectIcon,icon:(this._selectedTemplate?.layout?j.get(this._selectedTemplate.layout):null)||"custom-print",key:"template-select-icon",scale:"l",slot:"content-start"}),"error"===this._selectedTemplate?.state?E("calcite-icon",{class:R.templateSelectError,icon:"exclamation-mark-circle",key:"template-select-error",scale:"s",slot:"actions-end"}):null,E("calcite-icon",{class:R.templateSelectArrow,icon:$()?"chevron-left":"chevron-right",key:"template-select-arrow",scale:"s",slot:"actions-end"})))),x),L=E("div",{class:R.formSectionContainer},E("calcite-label",null,e.dpi,E("calcite-input-number",{bind:this,"data-input-name":"dpi",min:1,value:`${s}`,onCalciteInputNumberInput:this._updateNumberInputValue}))),F=E("div",{class:R.formSectionContainer},E("calcite-label",null,E("div",{class:R.srLabel},e.outSpatialReference,E("calcite-link",{href:"https://developers.arcgis.com/rest/services-reference/enterprise/using-spatial-references/",target:"_blank"},"(WKID)")),E("calcite-input-number",{bind:this,"data-input-name":"outSpatialReference",integer:!0,numberButtonType:"none",value:i.outSpatialReference?.wkid?.toString()??"",onCalciteInputNumberInput:({currentTarget:e})=>{const t=h(e.value);i.outSpatialReference=Number.isNaN(t)||null==t?null:new b({wkid:t}),this._isValidSpatialReference=!i.outSpatialReference||_(i.outSpatialReference)}}),this._isValidSpatialReference?null:E("div",{class:R.invalidWkidText,key:`out-sr-${i.outSpatialReference?.wkid}`},e.invalidWkid))),M=E("div",{class:this.classes(R.scaleInfoContainer,R.formSectionContainer)},E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:g,"data-option-name":"scaleEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scale),E("div",{class:R.scaleInputContainer},E("calcite-input-number",{"aria-label":e.scaleLabel,"aria-valuenow":`${f}`,bind:this,class:R.scaleInput,"data-input-name":"scale",disabled:!g,value:`${f}`,onCalciteInputNumberInput:this._updateNumberInputValue}),E("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!g,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale}))),P=E("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:R.advancedOptionsContainer,key:"advanced-section-for-layout"},M,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?E("div",{class:R.formSectionContainer,key:"author-info"},E("calcite-label",null,e.author,E("calcite-input",{bind:this,"data-input-name":"author",value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?E("div",{class:R.formSectionContainer,key:"copyright-text"},E("calcite-label",null,e.copyright,E("calcite-input",{bind:this,"data-input-name":"copyright",value:n??"",onCalciteInputInput:this._updateInputValue}))):null,L,F,this._renderCustomTextElementSection(),this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasLegend??1?E("div",{class:R.formSectionContainer,key:"legend-info"},E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:!!m,"data-option-name":"legendEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this._selectedTemplate?.mapSurroundInfoOptions?.northArrow.length?E("div",{class:R.formSectionContainer,key:"north-arrow"},E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:!!u,"data-option-name":"northArrowEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._selectedTemplate?.mapSurroundInfoOptions?.scaleBar.length?E("div",{class:R.formSectionContainer,key:"scale-bar"},E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:!!v,"data-option-name":"scaleBarEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scaleBar)):null),A=E("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:R.advancedOptionsContainer},M,L,F,E("div",{class:R.formSectionContainer},E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:l,"data-option-name":"attributionEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),D=this.exportedLinks.toArray(),B=this._renderExportedLinkItems(D),N={[R.exportSectionCentered]:!D.length},V="layoutTab"===this._selectedTab?E("section",{"aria-labelledby":`${this.id}__layoutTab`,class:R.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},E("div",{class:R.panelContainer},this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?w:null,C,"layoutTab"===this._selectedTab?k:null,E("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(R.panelContainer,R.advancedOptionsSection),collapsible:!0,disabled:!(p||d?.id),heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},P))):"mapOnlyTab"===this._selectedTab?E("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:R.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},E("div",{class:R.panelContainer},w,k,E("div",null,E("div",{class:this.classes(R.sizeContainer,R.formSectionContainer)},E("calcite-label",null,e.width,E("calcite-input-number",{bind:this,"data-input-name":"width",value:`${y}`,onCalciteInputNumberInput:this._updateNumberInputValue})),E("calcite-label",null,e.height,E("calcite-input-number",{bind:this,"data-input-name":"height",value:`${c}`,onCalciteInputNumberInput:this._updateNumberInputValue})),E("button",{"aria-label":e.swap,bind:this,class:this.classes(S.widgetButton,R.swapButton,O.swap),type:"button",onclick:this._switchInput})),x),E("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(R.panelContainer,R.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},A))):E("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(R.exportSection,N),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},E("div",{class:R.panelContainer},E("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:R.exportedFilesContainer},0===D.length?E("div",{class:R.exportedFilesEmpty},E("calcite-icon",{icon:"file",scale:"l"}),E("div",null,E(I,{class:R.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),E("div",null,e.exportHint))):B))),U="2d"!==a?.type,H=E("div",{class:R.panelError},a?U?e.sceneViewError:e.serviceError:e.noViewError),z=D.some(({state:e})=>"pending"===e),W=E("div",{class:R.content,key:"panel"},E("div",null,E("ul",{bind:this,class:R.layoutTabList,role:"tablist",onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown},E("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"layoutTab"===this._selectedTab}`,class:R.layoutTab,"data-tab-id":"layoutTab",id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),E("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"mapOnlyTab"===this._selectedTab}`,class:R.layoutTab,"data-tab-id":"mapOnlyTab",id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),E("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"exportTab"===this._selectedTab}`,class:R.layoutTab,"data-tab-id":"exportTab",id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},z?E("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),V),"exportTab"!==this._selectedTab?E("div",{class:this.classes(R.printButtonSection,!this.saveExportHidden&&this.portal?R.printButtonSectionDivider:null),key:"export-button-section"},!this.saveExportHidden&&this.portal?E("calcite-label",{layout:"inline"},E("calcite-checkbox",{bind:this,checked:this.saveExportEnabled,onCalciteCheckboxChange:e=>{this.saveExportEnabled=!!e.currentTarget.checked}}),e.saveExportToMyContent):null,E("calcite-button",{"aria-label":e.exportDescription,bind:this,class:this.classes(R.printButton),disabled:T||!(p||d?.id)&&!r,scale:"l",width:"full",onclick:this._handlePrintMap},e.export)):null),q=E("calcite-flow",{key:"root-flow"},E("calcite-flow-item",{bind:this,key:"root-flow-item",selected:!this._showTemplates},E("div",{class:R.printWidgetContainer},this.headerVisible?E("header",{class:R.headerTitle},e.export):null,this.error||U||!a?H:W)),this._renderChooseTemplateFlowItem()),K="initializing"===i.state,J=K?this._renderLoader():q,G={[R.panelItemsCentered]:K};return E("div",{bind:this,class:this.classes(R.base,S.widget,S.panel,G)},J)}_getPageSizeLabel(e){if(!e)return;const i=e.layoutTemplateInfo;if(!i)return;const a=V.fromJSON(i.pageUnits.toLowerCase());return`${t(i.pageSize[0])} × ${t(i.pageSize[1])} ${c(this.messagesUnits,a,"abbr")}`}_getTemplateLabel(e,t=!1){if(!e)return t?this.messages.selectTemplate:this.messages.untitled;const{label:i,layout:a,layoutItem:l}=e,o=a&&!l&&this.messages[a]?this.messages[a]:null;if(o)return o;const n=i??a??l?.id;return n?.replaceAll("_"," ")??this.messages.untitled}_getPortalTemplates(){return this.includeDefaultTemplates&&this.includeOrganizationTemplates?this.viewModel.defaultTemplates.toArray().filter(({layout:e,layoutItem:t})=>!B(e)&&!!t?.id):[]}_getDefaultTemplates(){return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter(({layout:e,layoutItem:t})=>!B(e)&&!t?.id):[]}_getPrintServiceTemplates(){return this.includeDefaultTemplates&&this._getDefaultTemplates().length?[]:this.viewModel.printServiceTemplates.toArray().filter(({layout:e})=>!B(e))}_renderLayoutTemplates(e,t=!1,i=!1){return t&&e.sort((e,t)=>(e.label??"")>(t.label??"")?1:-1),e.map(e=>E("calcite-list-item",{description:this._getPageSizeLabel(e),key:`template-${e.id}-${e.id===this.templateOptions.id}`,label:this._getTemplateLabel(e),selected:e.id===this.templateOptions.id,title:e.description??"",value:e},E("calcite-icon",{icon:(e.layout?j.get(e.layout):null)||"custom-print",slot:"content-start"}),"loading"===e.state?E("calcite-loader",{inline:!0,key:`template-loader-${e.id}`,label:"loading",scale:"s",slot:"content-end"}):null,"error"===e?.state?E("calcite-icon",{class:R.templateSelectError,icon:"exclamation-mark-circle",key:`template-error-${e.id}`,scale:"s",slot:"content-end"}):null,i?E("calcite-action",{icon:"trash",slot:"actions-end",text:"delete",onclick:()=>this.viewModel.removePortalTemplate(e)}):null))}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{messages:e}=this,t=g.test(this.portal?.url),i=this.viewModel.browseTemplates.toArray(),a=this._getPortalTemplates(),l=this._getDefaultTemplates(),o=this._getPrintServiceTemplates(),n=i.length+a.length+l.length+o.length>15,s=this.browseTemplateButtonOnClick?E("calcite-button",{appearance:"outline",class:n?R.browseTemplateButtonContainerFilter:R.browseTemplateButtonContainer,iconStart:"folder",key:"browse-template-button",slot:n?"filter-actions-end":"default",onclick:this.browseTemplateButtonOnClick},n?null:e.browseTemplates):null;return E("calcite-flow-item",{bind:this,closable:!1,heading:e.chooseTemplate,key:"template-flow-item",selected:this._showTemplates,onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},E("div",{class:R.templateSelectFlowItemContainer},E("div",{class:R.templateSelectFlowItemContent},n?null:s,E("calcite-list",{filterEnabled:n,filterProps:["label"],key:"template-list",label:e.templateList,selectionMode:"single-persist",onCalciteListChange:({currentTarget:e})=>this.viewModel.applyTemplate(e.selectedItems[0]?.value)},n?s:null,i.length?E("div",{key:"my-templates"},E("div",{class:R.templateSelectFlowItemListHeading},e.myTemplates,t?E("calcite-chip",{appearance:"outline",kind:"neutral",label:e.beta,scale:"s"},e.beta):null),this._renderLayoutTemplates(i,!0,!0)):null,a.length?E("div",{key:"org-templates"},E("div",{class:R.templateSelectFlowItemListHeading},e.organizationTemplates,t?E("calcite-chip",{appearance:"outline",kind:"neutral",label:e.beta,scale:"s"},e.beta):null),this._renderLayoutTemplates(a)):null,i.length||a.length?l.length?E("div",{key:"default-templates"},E("div",{class:R.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(l,!0)):null:this._renderLayoutTemplates(l,!0),i.length||a.length?o.length?E("div",{key:"service-templates"},E("div",{class:R.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(o)):null:this._renderLayoutTemplates(o))),E("div",{class:R.templateButtonContainer},E("calcite-button",{class:R.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?E("div",{class:R.formSectionContainer,key:"custom-text-elements"},e.map((e,t)=>{const[i,a]=Object.entries(e)[0];return"date"===i?null:E("calcite-label",{key:`custom-text-elements-${i}-${t}`},i,E("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":i,value:a??"",onCalciteInputInput:this._updateInputValue}))})):null}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:i,fileNamePlaceHolder:a}=this.messages,l="layoutTab"===this._selectedTab?e:t,o="layoutTab"===this._selectedTab?i:a,n="layoutTab"===this._selectedTab?this.templateOptions.title:this.templateOptions.fileName;return E("div",{class:R.formSectionContainer,key:l},E("calcite-label",null,l,E("calcite-input",{placeholder:o,value:n??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(e){if(!this._activeTabFocusRequested)return;const t=e.getAttribute("data-tab-id");("layoutTab"===t&&"layoutTab"===this._selectedTab||"mapOnlyTab"===t&&"mapOnlyTab"===this._selectedTab||"exportTab"===t&&"exportTab"===this._selectedTab)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[R.loader]:this._awaitingServerResponse};return E("div",{class:this.classes(e),key:"loader"})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,i){e.find(e=>{const[i]=Object.entries(e)[0];return i===t})[t]=i}_updateInputValue(e){const t=e.currentTarget,i=t.getAttribute("data-input-name"),a=!!t["data-input-custom"],{templateOptions:l}=this;a?this._updateCustomTextElementValue(l.customTextElements,i,t.value):l[i]=t.value}_updateNumberInputValue(e){const t=e.currentTarget,i=t.getAttribute("data-input-name"),{templateOptions:a}=this,l=Number(t.value);if(!D(l)){const e=a[i];return void(t.value=`${e}`)}a[i]=l}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t="layoutTab"===this._selectedTab?e.title:e.fileName,{promise:i}=this.viewModel.export(t||this.messages.untitled);this._selectedTab="exportTab",i.then(()=>this.scheduleRender())}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:i}=e,a=i-t;a>0&&(e.scrollTop=a)}_toggleInputValue(e){const t=e.target,i=t.getAttribute("data-option-name");this.templateOptions[i]=t.checked,"scaleEnabled"===i&&this._resetToCurrentScale()}_renderExportedLinkItemPopover(e){const t=this.messages,i=e.formattedName??"",{state:a}=e,l=this.saveAsButtonCallback&&"error"!==a&&this._isFormatAllowedForSaving(e.extension);return"pending"!==a&&l?E("calcite-popover",{autoClose:!0,key:`${i}-popover`,label:"Popover",offsetDistance:1,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:`${i}-popover-button`,scale:"s",topLayerDisabled:this.topLayerDisabled},E("calcite-list",{label:""},e.portalItem?E("calcite-list-item",{label:t.openItem,onCalciteListItemSelect:()=>{const t=e.portalItem;if(!t||!t.itemPageUrl)return;const i=document.createElement("a");i.target="_blank",i.href=t.itemPageUrl,i.rel="noreferrer",i.click()}},E("calcite-icon",{icon:"launch2",key:`${i}-launch-icon`,scale:"s",slot:"content-start"})):E("calcite-list-item",{label:t.saveAs,onCalciteListItemSelect:async()=>{this.saveAsButtonCallback&&(r(()=>e.portalItem).then(e=>{e.itemPageUrl&&this.scheduleRender()}),await this.saveAsButtonCallback(e))}},E("calcite-icon",{icon:"save",key:`${i}-save-icon`,scale:"s",slot:"content-start"})),E("calcite-list-item",{label:this.messagesCommon.delete,onCalciteListItemSelect:()=>this.exportedLinks.remove(e)},E("calcite-icon",{icon:"trash",key:`${i}-delete-icon`,scale:"s",slot:"content-start"})))):null}_renderExportedLinkItemContent(e){const t=this.messages,{url:i,state:a,error:l}=e,o=e.formattedName??"";let n=i||null;n&&(n=p(n));const s=d(n,location.href),r="error"===a?"print-task:cim-symbol-unsupported"===l?.name?t.exportWebMapCIMError:t.exportWebMapError:null;return E("div",{class:R.exportedFile,"data-item":e,slot:"content",onclick:this._handleLinkClick},E("div",null,E("div",{class:R.exportedFileLinkTitle},o),E("div",{class:R.exportedFileLinkDescription},"pending"===a?t.generatingExport:r||(s?t.ready:t.linkReady))),"ready"===a?E("calcite-icon",{"aria-label":`${o}. ${t.linkReady}`,icon:s?"download-to":"launch",key:`${o}-end-icon`,scale:"s",slot:"content-end"}):null)}_renderExportedLinkItemIcon(e){const t=e.formattedName??"";return"pending"===e.state?E("calcite-loader",{class:R.exportedFileLoader,inline:!0,key:`${t}-loader`,label:this.messages.generatingExport,scale:"m",slot:"content-start"}):E("calcite-icon",{icon:N(e),key:`${t}-start-icon`,scale:"s",slot:"content-start"})}_renderExportedLinkItemAction(e){const{state:t}=e,i=e.formattedName??"",a=this.saveAsButtonCallback&&"error"!==t&&this._isFormatAllowedForSaving(e.extension);return"pending"!==t?E("calcite-action",{icon:a?"ellipsis":"x",id:a?`${i}-popover-button`:void 0,key:a?`${i}-saveAs-action`:`${i}-action`,slot:"actions-end",text:a?this.messagesCommon.options:this.messagesCommon.remove,onclick:a?void 0:()=>{this.exportedLinks.remove(e)}}):null}_renderExportedLinkItem(e){const t=e.formattedName??"";return E(F,null,E("calcite-list-item",{key:t,label:t},this._renderExportedLinkItemContent(e),this._renderExportedLinkItemIcon(e),this._renderExportedLinkItemAction(e)),this._renderExportedLinkItemPopover(e))}_renderExportedLinkItems(e){return E("calcite-list",{filterEnabled:e?.length>10,label:this.messages.exportedLinksList,selectionMode:"none"},e.map(this._renderExportedLinkItem.bind(this)))}_isFormatAllowedForSaving(e){return!this.allowedFormatsForSaving||"all"===this.allowedFormatsForSaving||!(!e||!this.allowedFormatsForSaving.includes(e))}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,"mapOnlyTab"===this._selectedTab)this.viewModel.applyTemplate(P);else if("layoutTab"===this._selectedTab){const e=this._selectedTemplate??this.viewModel.defaultTemplate;this.viewModel.applyTemplate(e)}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,i=e.target.getAttribute("data-tab-id");if(M(t))return this._toggleTab(i),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(i){case"layoutTab":this._toggleTab("ArrowLeft"===t?"exportTab":"mapOnlyTab");break;case"mapOnlyTab":this._toggleTab("ArrowLeft"===t?"layoutTab":"exportTab");break;case"exportTab":this._toggleTab("ArrowLeft"===t?"mapOnlyTab":"layoutTab")}e.preventDefault(),e.stopPropagation()}}};e([m()],U.prototype,"_showTemplates",void 0),e([m()],U.prototype,"_isValidSpatialReference",void 0),e([m()],U.prototype,"allowedFormats",null),e([m()],U.prototype,"allowedFormatsForSaving",void 0),e([m()],U.prototype,"allowedLayouts",null),e([m()],U.prototype,"browseTemplateButtonOnClick",void 0),e([m()],U.prototype,"error",null),e([m({type:i.ofType(w)})],U.prototype,"exportedLinks",null),e([m()],U.prototype,"extraParameters",null),e([m()],U.prototype,"headerVisible",void 0),e([m()],U.prototype,"headingLevel",void 0),e([m()],U.prototype,"icon",null),e([m()],U.prototype,"includeDefaultTemplates",null),e([m()],U.prototype,"includeOrganizationTemplates",void 0),e([m()],U.prototype,"label",null),e([m(),L("esri/widgets/Print/t9n/Print")],U.prototype,"messages",void 0),e([m(),L("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([m(),L("esri/core/t9n/Units")],U.prototype,"messagesUnits",void 0),e([m({type:b})],U.prototype,"outSpatialReference",null),e([m({type:v})],U.prototype,"portal",null),e([m()],U.prototype,"saveExportEnabled",null),e([m()],U.prototype,"saveExportHidden",void 0),e([m()],U.prototype,"showPrintAreaEnabled",null),e([m()],U.prototype,"printServiceUrl",null),e([m()],U.prototype,"saveAsButtonCallback",void 0),e([m()],U.prototype,"templateCustomTextElements",null),e([m({type:x})],U.prototype,"templateOptions",null),e([m()],U.prototype,"view",null),e([m({type:k})],U.prototype,"viewModel",void 0),U=e([u("esri.widgets.Print")],U);const H=U;export{H as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import{IdentifiableMixin as l}from"../../core/Identifiable.js";import{watch as r,initial as o}from"../../core/reactiveUtils.js";import{property as n,cast as a,subclass as h}from"../../core/accessorSupport/decorators.js";import{ensureType as d}from"../../core/accessorSupport/ensureType.js";import{get as p}from"../../core/accessorSupport/get.js";import c from"../../support/actions/ActionBase.js";import y from"../../support/actions/ActionButton.js";import u from"../../support/actions/ActionToggle.js";import{canDisplayLayer as m,findLayerListMode as b,getNormalizedChildLayerProperty as f}from"../LayerList/support/layerListUtils.js";import C from"./ListItemPanel.js";var _;const g="layer",v="child-list-mode",P="hide",I=s.ofType({key:"type",defaultKeyValue:"button",base:c,typeMap:{button:y,toggle:u}}),S=s.ofType(I);let M=_=class extends(l(e)){constructor(t){super(t),this.actionsSections=new S,this.actionsOpen=!1,this.checkPublishStatusEnabled=!1,this.children=new(s.ofType(_)),this.hidden=!1,this.layer=null,this.listItemCreatedFunction=null,this.listModeDisabled=!1,this.open=!1,this.parent=null,this.sortable=!0}initialize(){if(this.addHandles([r(()=>[this.layer?.listMode,this.listModeDisabled],()=>this._watchLayerProperties(this.layer),o),r(()=>this.checkPublishStatusEnabled,t=>this._updateChildrenPublishing(t),o),r(()=>this.panel,t=>this._setListItemOnPanel(t),o)]),"function"==typeof this.listItemCreatedFunction){const t={item:this};this.listItemCreatedFunction.call(null,t)}}destroy(){this.panel?.destroy(),this.children.destroyAll()}get error(){return this.layer?.loadError}set panel(t){const e=this._get("panel");t!==e&&t&&e?.destroy(),this._set("panel",t)}castPanel(t){return this.panel?.open&&!t.hasOwnProperty("open")&&(t.open=!0),d(C,t)}get publishing(){const{layer:t,checkPublishStatusEnabled:e}=this;return(e&&t&&"publishingInfo"in t&&"publishing"===t.publishingInfo?.status)??!1}get title(){const t=p(this,"layer.layer");return(!t||t&&p(this,"layer.layer.loaded")?this.layer?.title:null)??""}set title(t){this._overrideIfSome("title",t)}clone(){return new _({actionsSections:this.actionsSections.clone(),actionsOpen:this.actionsOpen,checkPublishStatusEnabled:this.checkPublishStatusEnabled,children:this.children.clone(),hidden:this.hidden,layer:this.layer,listItemCreatedFunction:this.listItemCreatedFunction,listModeDisabled:this.listModeDisabled,open:this.open,panel:this.panel,parent:this.parent,sortable:this.sortable,title:this.title})}_updateChildrenPublishing(t){this.children?.forEach(e=>e.checkPublishStatusEnabled=t)}_setListItemOnPanel(t){t&&(t.listItem=this)}_createChildItems(t,e){return t.reverse().map(t=>e||m(t)?new _({layer:t,checkPublishStatusEnabled:this.checkPublishStatusEnabled,listItemCreatedFunction:this.listItemCreatedFunction,listModeDisabled:this.listModeDisabled,parent:this}):null).filter(i)}_createChildren(t){const{listModeDisabled:e,children:i}=this,s=t.reverse().filter(t=>!i.some(e=>e.layer===t));i.addMany(this._createChildItems(s,e))}_destroyChildren(t){const{children:e}=this,i=e.filter(e=>!!e.layer&&!t.includes(e.layer));e.destroyMany(i)}_sortChildren(t){this.children.sort((e,i)=>t.indexOf(i.layer)-t.indexOf(e.layer))}_destroyAllChildren(){this.removeHandles(v),this.children.destroyAll()}_compileChildren(t){const e=this.listModeDisabled?t:t?.filter(t=>b(t)!==P);t?.length?(this._createChildren(e),this._destroyChildren(e),this._sortChildren(e),this._watchChildLayerListMode(t)):this._destroyAllChildren()}_watchChildLayerListMode(t){this.removeHandles(v),this.listModeDisabled||this.addHandles(t.toArray().map(e=>r(()=>e.listMode,()=>this._compileChildren(t))),v)}_watchSublayerChanges(t){t&&this.addHandles(t.on("change",()=>this._compileChildren(t)),g)}_initializeChildLayers(t){this._compileChildren(t),this._watchSublayerChanges(t)}_watchLayerProperties(t){if(this.removeHandles(g),this.removeHandles(v),!t)return;t.load();if("hide-children"===(!this.listModeDisabled&&b(t)))return void this.children.destroyAll();const e=f(t);e&&this.addHandles(r(()=>t[e],i=>{t.hasOwnProperty(e)&&this._initializeChildLayers(i)},o),g)}};t([n({type:S})],M.prototype,"actionsSections",void 0),t([n()],M.prototype,"actionsOpen",void 0),t([n()],M.prototype,"checkPublishStatusEnabled",void 0),t([n({type:s.ofType(M)})],M.prototype,"children",void 0),t([n({readOnly:!0})],M.prototype,"error",null),t([n()],M.prototype,"hidden",void 0),t([n()],M.prototype,"layer",void 0),t([n()],M.prototype,"listItemCreatedFunction",void 0),t([n({nonNullable:!0})],M.prototype,"listModeDisabled",void 0),t([n()],M.prototype,"open",void 0),t([n({type:C})],M.prototype,"panel",null),t([a("panel")],M.prototype,"castPanel",null),t([n()],M.prototype,"parent",void 0),t([n({readOnly:!0})],M.prototype,"publishing",null),t([n()],M.prototype,"sortable",void 0),t([n()],M.prototype,"title",null),M=_=t([h("esri.widgets.TableList.ListItem")],M);export{M as default};
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import{IdentifiableMixin as l}from"../../core/Identifiable.js";import{watch as r,initial as o}from"../../core/reactiveUtils.js";import{property as n,cast as a,subclass as h}from"../../core/accessorSupport/decorators.js";import{ensureType as d}from"../../core/accessorSupport/ensureType.js";import{get as p}from"../../core/accessorSupport/get.js";import c from"../../support/actions/ActionBase.js";import y from"../../support/actions/ActionButton.js";import u from"../../support/actions/ActionToggle.js";import{canDisplayLayer as m,findLayerListMode as b,getNormalizedChildLayerProperty as f}from"../LayerList/support/layerListUtils.js";import C from"./ListItemPanel.js";var _;const g="layer",v="child-list-mode",P="hide",I=s.ofType({key:"type",defaultKeyValue:"button",base:c,typeMap:{button:y,toggle:u}}),S=s.ofType(I);let M=_=class extends(l(e)){constructor(t){super(t),this.actionsSections=new S,this.actionsOpen=!1,this.checkPublishStatusEnabled=!1,this.children=new(s.ofType(_)),this.hidden=!1,this.layer=null,this.listItemCreatedFunction=null,this.listModeDisabled=!1,this.open=!1,this.parent=null,this.sortable=!0}initialize(){if(this.addHandles([r(()=>[this.layer?.listMode,this.listModeDisabled],()=>this._watchLayerProperties(this.layer),o),r(()=>this.checkPublishStatusEnabled,t=>this._updateChildrenPublishing(t),o),r(()=>this.panel,t=>this._setListItemOnPanel(t),o)]),"function"==typeof this.listItemCreatedFunction){const t={item:this};this.listItemCreatedFunction.call(null,t)}}destroy(){this.panel?.destroy(),this.children.destroyAll()}get error(){return this.layer?.loadError}set panel(t){const e=this._get("panel");t!==e&&t&&e?.destroy(),this._set("panel",t)}castPanel(t){return this.panel?.open&&!t.hasOwnProperty("open")&&(t.open=!0),d(C,t)}get publishing(){const{layer:t,checkPublishStatusEnabled:e}=this;return(e&&t&&"publishingInfo"in t&&"publishing"===t.publishingInfo?.status)??!1}get title(){const t=p(this,"layer.layer");return(!t||t&&p(this,"layer.layer.loaded")?this.layer?.title:null)??""}set title(t){this._overrideIfSome("title",t)}clone(){return new _({actionsSections:this.actionsSections.clone(),actionsOpen:this.actionsOpen,checkPublishStatusEnabled:this.checkPublishStatusEnabled,children:this.children.clone(),hidden:this.hidden,layer:this.layer,listItemCreatedFunction:this.listItemCreatedFunction,listModeDisabled:this.listModeDisabled,open:this.open,panel:this.panel,parent:this.parent,sortable:this.sortable,title:this.title})}_updateChildrenPublishing(t){this.children?.forEach(e=>e.checkPublishStatusEnabled=t)}_setListItemOnPanel(t){t&&(t.listItem=this)}_createChildItems(t,e){return t.reverse().map(t=>e||m(t)?new _({layer:t,checkPublishStatusEnabled:this.checkPublishStatusEnabled,listItemCreatedFunction:this.listItemCreatedFunction,listModeDisabled:this.listModeDisabled,parent:this}):null).filter(i)}_createChildren(t){const{listModeDisabled:e,children:i}=this,s=t.reverse().filter(t=>!i.some(e=>e.layer===t));i.addMany(this._createChildItems(s,e))}_destroyChildren(t){const{children:e}=this,i=e.filter(e=>!!e.layer&&!t.includes(e.layer));e.destroyMany(i)}_sortChildren(t){this.children.sort((e,i)=>t.indexOf(i.layer)-t.indexOf(e.layer))}_destroyAllChildren(){this.removeHandles(v),this.children.destroyAll()}_compileChildren(t){const e=this.listModeDisabled?t:t?.filter(t=>b(t)!==P);t?.length?(this._createChildren(e),this._destroyChildren(e),this._sortChildren(e),this._watchChildLayerListMode(t)):this._destroyAllChildren()}_watchChildLayerListMode(t){this.removeHandles(v),this.listModeDisabled||this.addHandles(t.toArray().map(e=>r(()=>e.listMode,()=>this._compileChildren(t))),v)}_watchSublayerChanges(t){t&&this.addHandles(t.on("change",()=>this._compileChildren(t)),g)}_initializeChildLayers(t){this._compileChildren(t),this._watchSublayerChanges(t)}_watchLayerProperties(t){if(this.removeHandles(g),this.removeHandles(v),!t)return;t.load().catch(()=>{});if("hide-children"===(!this.listModeDisabled&&b(t)))return void this.children.destroyAll();const e=f(t);e&&this.addHandles(r(()=>t[e],i=>{t.hasOwnProperty(e)&&this._initializeChildLayers(i)},o),g)}};t([n({type:S})],M.prototype,"actionsSections",void 0),t([n()],M.prototype,"actionsOpen",void 0),t([n()],M.prototype,"checkPublishStatusEnabled",void 0),t([n({type:s.ofType(M)})],M.prototype,"children",void 0),t([n({readOnly:!0})],M.prototype,"error",null),t([n()],M.prototype,"hidden",void 0),t([n()],M.prototype,"layer",void 0),t([n()],M.prototype,"listItemCreatedFunction",void 0),t([n({nonNullable:!0})],M.prototype,"listModeDisabled",void 0),t([n()],M.prototype,"open",void 0),t([n({type:C})],M.prototype,"panel",null),t([a("panel")],M.prototype,"castPanel",null),t([n()],M.prototype,"parent",void 0),t([n({readOnly:!0})],M.prototype,"publishing",null),t([n()],M.prototype,"sortable",void 0),t([n()],M.prototype,"title",null),M=_=t([h("esri.widgets.TableList.ListItem")],M);export{M as default};
|