@arcgis/core 4.33.0-next.20250218 → 4.33.0-next.20250220

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.
Files changed (216) hide show
  1. package/applications/ExperienceBuilder/sketchUtils.d.ts +1 -0
  2. package/applications/ExperienceBuilder/sketchUtils.js +1 -1
  3. package/arcade/treeAnalysis.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/{f5ce6af342c02a4b0d15.js → 030384851fa745908a6e.js} +13 -12
  6. package/assets/esri/core/workers/chunks/0c3930e40fc9f8a84599.js +2 -0
  7. package/assets/esri/core/workers/chunks/{ccee343fb8c415b59ce3.js.LICENSE.txt → 0c3930e40fc9f8a84599.js.LICENSE.txt} +1 -1
  8. package/assets/esri/core/workers/chunks/0e6762d69b7449f8a997.js +1 -0
  9. package/assets/esri/core/workers/chunks/{5ad51a68d20b0d0d404f.js → 1661ac4e1b6c6af6ee0f.js} +1 -1
  10. package/assets/esri/core/workers/chunks/186db99d05ca1183d4e9.js +1 -0
  11. package/assets/esri/core/workers/chunks/{a42ae5d5e5f66d120b4d.js → 21c7265f1f2a718de7c6.js} +1 -1
  12. package/assets/esri/core/workers/chunks/2a88909a03600349dff9.js +1 -0
  13. package/assets/esri/core/workers/chunks/333bb93a28209c997d8b.js +314 -0
  14. package/assets/esri/core/workers/chunks/469c50c49447f0d602c0.js +1 -0
  15. package/assets/esri/core/workers/chunks/486df1e042204b90b0dd.js.LICENSE.txt +1 -1
  16. package/assets/esri/core/workers/chunks/{c2d539359f321bba3432.js → 52c13b3c074c9f6dadde.js} +2 -2
  17. package/assets/esri/core/workers/chunks/{c2d539359f321bba3432.js.LICENSE.txt → 52c13b3c074c9f6dadde.js.LICENSE.txt} +1 -1
  18. package/assets/esri/core/workers/chunks/5352b374454bc4f73d55.js +1 -0
  19. package/assets/esri/core/workers/chunks/5693d9ce4472a4c5959f.js.LICENSE.txt +1 -1
  20. package/assets/esri/core/workers/chunks/5984ab09ea8010f8a874.js +1 -0
  21. package/assets/esri/core/workers/chunks/5b56b271afb0fadf48b4.js.LICENSE.txt +1 -1
  22. package/assets/esri/core/workers/chunks/6518954889df2e781c47.js.LICENSE.txt +1 -1
  23. package/assets/esri/core/workers/chunks/68322a63ec92d33701ea.js +1 -0
  24. package/assets/esri/core/workers/chunks/{ec62fffe07c4382e8796.js → 6c64ccf5f64b5025b239.js} +1 -1
  25. package/assets/esri/core/workers/chunks/717d7e9912d948e44d8d.js +1 -0
  26. package/assets/esri/core/workers/chunks/aacebda644be06ad1a61.js +1 -0
  27. package/assets/esri/core/workers/chunks/ac11b2168feee63d2f09.js +1 -0
  28. package/assets/esri/core/workers/chunks/b0952b81d5be214262dd.js.LICENSE.txt +1 -1
  29. package/assets/esri/core/workers/chunks/b9292cd91005137a2094.js +1 -0
  30. package/assets/esri/core/workers/chunks/b9d2f60b2d587a2b6cd7.js +1 -0
  31. package/assets/esri/core/workers/chunks/cf285e45c18cd4399dde.js +1 -0
  32. package/assets/esri/core/workers/chunks/{42f21349f488a14198e4.js → d4a08800c75051a5131d.js} +1 -1
  33. package/assets/esri/core/workers/chunks/e2df18662cc4d6e47715.js +1 -0
  34. package/assets/esri/core/workers/chunks/e96f4c76c8bc78a7f80f.js +1 -0
  35. package/assets/esri/core/workers/chunks/f24aef061e60d2c2f597.js +1 -0
  36. package/assets/esri/core/workers/chunks/f664cc15238c8e9856a0.js +1 -0
  37. package/assets/esri/themes/base/widgets/_Editor.scss +3 -0
  38. package/assets/esri/themes/base/widgets/_Print.scss +1 -0
  39. package/assets/esri/themes/base/widgets/_ResponsiveToolbar.scss +23 -3
  40. package/assets/esri/themes/base/widgets/_Sketch.scss +32 -24
  41. package/assets/esri/themes/dark/main.css +1 -1
  42. package/assets/esri/themes/light/main.css +1 -1
  43. package/assets/esri/themes/light/view.css +1 -1
  44. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm.json +1 -1
  45. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ar.json +1 -1
  46. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bg.json +1 -1
  47. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bs.json +1 -1
  48. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ca.json +1 -1
  49. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_cs.json +1 -1
  50. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_da.json +1 -1
  51. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_de.json +1 -1
  52. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_el.json +1 -1
  53. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_en.json +1 -1
  54. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_es.json +1 -1
  55. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_et.json +1 -1
  56. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fi.json +1 -1
  57. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fr.json +1 -1
  58. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_he.json +1 -1
  59. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hr.json +1 -1
  60. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hu.json +1 -1
  61. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_id.json +1 -1
  62. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_it.json +1 -1
  63. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ja.json +1 -1
  64. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ko.json +1 -1
  65. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lt.json +1 -1
  66. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lv.json +1 -1
  67. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_nl.json +1 -1
  68. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_no.json +1 -1
  69. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pl.json +1 -1
  70. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-BR.json +1 -1
  71. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-PT.json +1 -1
  72. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ro.json +1 -1
  73. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ru.json +1 -1
  74. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sk.json +1 -1
  75. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sl.json +1 -1
  76. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sr.json +1 -1
  77. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sv.json +1 -1
  78. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_th.json +1 -1
  79. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_tr.json +1 -1
  80. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_uk.json +1 -1
  81. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_vi.json +1 -1
  82. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-CN.json +1 -1
  83. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-HK.json +1 -1
  84. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-TW.json +1 -1
  85. package/chunks/RealisticTree.glsl.js +18 -17
  86. package/copyright.txt +91 -0
  87. package/geometry/support/meshUtils/elevation.js +1 -1
  88. package/interfaces.d.ts +493 -131
  89. package/layers/BuildingSceneLayer.js +1 -1
  90. package/layers/FeatureLayer.js +1 -1
  91. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  92. package/layers/IntegratedMeshLayer.js +1 -1
  93. package/layers/OrientedImageryLayer.js +1 -1
  94. package/layers/PointCloudLayer.js +1 -1
  95. package/layers/RouteLayer.js +1 -1
  96. package/layers/SceneLayer.js +1 -1
  97. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  98. package/layers/graphics/OptimizedGeometry.js +1 -1
  99. package/layers/graphics/featureConversionUtils.js +1 -1
  100. package/layers/support/featureLayerUtils.js +1 -1
  101. package/layers/support/rasterFunctionUtils.d.ts +11 -0
  102. package/networks/UtilityNetwork.js +1 -1
  103. package/package.json +2 -2
  104. package/portal/Portal.js +1 -1
  105. package/rest/route.js +1 -1
  106. package/rest/support/AttributeBinsGrouping.js +1 -1
  107. package/rest/support/AttributeBinsQuery.js +1 -1
  108. package/rest/support/RouteParameters.js +1 -1
  109. package/rest/support/RouteSolveResult.js +1 -1
  110. package/support/revision.js +1 -1
  111. package/symbols/cim/CIMEffects.js +1 -1
  112. package/symbols/cim/cimAnalyzer.js +1 -1
  113. package/symbols/cim/effects/EffectAddControlPoints.js +1 -1
  114. package/symbols/cim/effects/EffectBuffer.js +1 -1
  115. package/symbols/cim/effects/EffectDonut.js +1 -1
  116. package/symbols/cim/effects/EffectOffset.js +1 -1
  117. package/views/2d/FrameTask.js +1 -1
  118. package/views/2d/engine/webgl/TextureManager.js +1 -1
  119. package/views/2d/engine/webgl/Utils.js +1 -1
  120. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
  121. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  122. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  123. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  124. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  125. package/views/2d/layers/features/sources/FeatureCache.js +1 -1
  126. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  127. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  128. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  129. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  130. package/views/2d/viewpointUtils.js +1 -1
  131. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  132. package/views/3d/layers/I3SMeshView3D.js +1 -1
  133. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  134. package/views/3d/layers/graphics/pipeline/Tile.js +1 -1
  135. package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
  136. package/views/3d/layers/graphics/pipeline/featureData/FeatureData.js +1 -1
  137. package/views/3d/layers/graphics/pipeline/featureData/FeatureDataSubset.js +5 -0
  138. package/views/3d/layers/graphics/pipeline/featureData/processingUtils.js +1 -1
  139. package/views/3d/layers/graphics/pipeline/featureSet/PBFPointFeatureSetView.js +1 -1
  140. package/views/3d/layers/graphics/pipeline/featureSet/TiledFeatureStore.js +1 -1
  141. package/views/3d/layers/graphics/pipeline/fetching/Tile3DFetcher.js +1 -1
  142. package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
  143. package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
  144. package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
  145. package/views/3d/layers/support/FeatureTile.js +1 -1
  146. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  147. package/views/3d/terrain/TileRenderer.js +1 -1
  148. package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
  149. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  150. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentBVH.js +1 -1
  151. package/views/3d/webgl-engine/collections/Component/IndexRange/ComponentRange.js +5 -0
  152. package/views/3d/webgl-engine/lib/ComponentUtils.js +1 -1
  153. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  154. package/views/3d/webgl-engine/materials/renderers/BufferRange.js +1 -1
  155. package/views/VideoView.js +1 -1
  156. package/views/View2D.js +1 -1
  157. package/views/Viewport2DMixin.js +5 -0
  158. package/views/webgl/Texture.js +1 -1
  159. package/webmap/utils.js +1 -1
  160. package/widgets/BasemapLayerList.js +1 -1
  161. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  162. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  163. package/widgets/BatchAttributeForm/templates/support/contingentValuesUtils.js +5 -0
  164. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  165. package/widgets/BatchAttributeForm.js +1 -1
  166. package/widgets/CatalogLayerList.js +1 -1
  167. package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
  168. package/widgets/Directions/DirectionsViewModel.js +1 -1
  169. package/widgets/Directions.js +1 -1
  170. package/widgets/ElevationProfile/components/LegendItem.js +1 -1
  171. package/widgets/ElevationProfile/components/SettingsButton.js +1 -1
  172. package/widgets/Feature/FeatureUtilityNetworkAssociations.js +1 -1
  173. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  174. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  175. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  176. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  177. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  178. package/widgets/LayerList.js +1 -1
  179. package/widgets/Legend/styles/support/utils.js +1 -1
  180. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  181. package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
  182. package/widgets/OrientedImageryViewer/digitizationUtils.js +1 -1
  183. package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
  184. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  185. package/widgets/OrientedImageryViewer.js +1 -1
  186. package/widgets/Print.js +1 -1
  187. package/widgets/ShadowCast.js +1 -1
  188. package/widgets/Sketch/SketchViewModel.js +1 -1
  189. package/widgets/Sketch/support/ResponsiveToolbar/OverflowGroup.js +1 -1
  190. package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
  191. package/widgets/Sketch/support/ResponsiveToolbar/SplitButton.js +1 -1
  192. package/widgets/Sketch/support/sketchUtils.js +1 -1
  193. package/widgets/Sketch.js +1 -1
  194. package/widgets/VideoPlayer.js +1 -1
  195. package/widgets/support/UtilityNetworkAssociations/utilityNetworkUtils.js +1 -1
  196. package/assets/esri/core/workers/chunks/1cbea0c0b20a2963a86d.js +0 -1
  197. package/assets/esri/core/workers/chunks/238bcf6514a1f214cc8a.js +0 -1
  198. package/assets/esri/core/workers/chunks/26b5397f63dc602612f2.js +0 -1
  199. package/assets/esri/core/workers/chunks/290f613ef70590de9f15.js +0 -314
  200. package/assets/esri/core/workers/chunks/33c6fd524711efd8ef13.js +0 -1
  201. package/assets/esri/core/workers/chunks/3f077176c03a360e1edd.js +0 -1
  202. package/assets/esri/core/workers/chunks/544ad8fa4777ba8ec177.js +0 -1
  203. package/assets/esri/core/workers/chunks/6039da57a2adedd3b83f.js +0 -1
  204. package/assets/esri/core/workers/chunks/842db06ce62758fab1e7.js +0 -1
  205. package/assets/esri/core/workers/chunks/916f0ca8e3aaed5a9508.js +0 -1
  206. package/assets/esri/core/workers/chunks/bdc9dec6a359d2e3705c.js +0 -1
  207. package/assets/esri/core/workers/chunks/bf127fe767174e2715b5.js +0 -1
  208. package/assets/esri/core/workers/chunks/cb3148cf11a420d6e9ab.js +0 -1
  209. package/assets/esri/core/workers/chunks/ccee343fb8c415b59ce3.js +0 -2
  210. package/assets/esri/core/workers/chunks/d342c56558f164e9e786.js +0 -1
  211. package/assets/esri/core/workers/chunks/d3f7ff03ab5b40062d89.js +0 -1
  212. package/assets/esri/core/workers/chunks/ed89a108b032b982b12f.js +0 -1
  213. package/assets/esri/core/workers/chunks/ef6279f5c63ab1e88c71.js +0 -1
  214. package/assets/esri/core/workers/chunks/f088e7db4e7ac85aaff1.js +0 -1
  215. package/views/3d/layers/graphics/pipeline/featureData/FeatureDataStore.js +0 -5
  216. package/views/3d/webgl-engine/collections/Component/IndexRange/ComponentRangeRunLengthEncoded.js +0 -5
package/views/View2D.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Viewpoint.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import has from"../core/has.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{watch as o,sync as l,syncAndInitial as p}from"../core/reactiveUtils.js";import{initialize as h}from"../core/workers/workers.js";import{property as g}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as c}from"../core/accessorSupport/ensureType.js";import m from"../geometry/Polygon.js";import{isLoadedOrLoadFor as y}from"../geometry/projection.js";import f from"../layers/support/TileInfo.js";import{BreakpointsOwner as w}from"./BreakpointsOwner.js";import{DOMContainer as V}from"./DOMContainer.js";import{PopupView as M}from"./PopupView.js";import v from"./View.js";import b from"./2d/AnimationManager.js";import _ from"./2d/FrameTask.js";import{GoToManager as j}from"./2d/GoToManager.js";import{layerView2DImporter as S}from"./2d/layerViewModuleImportUtils.js";import O from"./2d/MapViewConstraints.js";import T from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{extentToScale as L}from"./2d/viewpointUtils.js";import{ViewStateManager as R}from"./2d/ViewStateManager.js";import k from"./2d/input/MapViewInputManager.js";import C from"./2d/layers/features/support/TileStore.js";import{createOrReuseHighlightGradient as x}from"./2d/layers/support/util.js";import{clipContainsPoint as D}from"./2d/support/clippingUtils.js";import{getDefaultHighlightOptions as E,setDefaultHighlightOptions as P}from"./2d/support/highlightOptionsUtils.js";import{hitTest as z}from"./2d/support/hitTestUtils.js";import{takeRawScreenshot as G,takeScreenshot as A}from"./2d/support/screenshotUtils.js";import{StationaryManager as U}from"./2d/support/StationaryManager.js";import{Timeline as q}from"./2d/support/Timeline.js";import I from"./navigation/Navigation.js";import N from"./navigation/NavigationActionMap.js";import F from"./support/HighlightOptions.js";import{isSupportedScreenPointEvent as W,createScreenPointFromSupportedEvent as $}from"./support/screenUtils.js";import{check as H}from"./support/WebGLRequirements.js";import B from"./ui/DefaultUI.js";import Z from"./ui/2d/DefaultUI2D.js";import{isWebMap as J}from"../webmap/utils.js";import K from"../webmap/background/ColorBackground.js";let Q,X,Y,ee,te,ie,re;async function se(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,GridView2D:a,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);X=e,Y=t,ee=i,te=r,ie=s,re=a,Q=n}let ae=class extends(w(M(V(v)))){constructor(e){super(e),this._magnifierView=null,this._gridView=null,this.stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.fullOpacity=1,this.goToManager=new j({view:this}),this.graphicsView=null,this.stateManager=new R({constraints:new O({view:this})}),this.stationaryManager=new U,this.labelManager=null,this.mapViewNavigation=null,this.navigation=new I({actionMap:new N({dragTertiary:"none"})}),this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.supersampleScreenshotsEnabled=!0,this.supportsGround=!1,this.frameTask=new _(this),this.floors=new i,this.grid=null,this.inputManager=new k({view:this}),this.map=null,this.spatialReferenceLocked=!1,this.timeline=new q,this.type="2d",this.view2dType=null,this.ui=new Z,this.test={takeScreenshot:async e=>G(this._getScreenshotView(e),e)},this.padding={top:0,right:0,bottom:0,left:0},this.addHandles([o((()=>this.viewpoint),(()=>this.stationaryManager.flip()),l),this.on("resize",(e=>this.stateManager.resize(e.width,e.height)))]),h()}destroy(){this.layerViewManager.clear(),this._set("preconditionsReady",!1),this.frameTask=n(this.frameTask),this.goToManager.destroy(),this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new C(this.featuresTilingScheme)}get constraintsInfo(){const e=this.defaultsFromMap?.tileInfo,t=this.spatialReference;return{lods:e?.spatialReference?.equals(t)?e.lods:null,spatialReference:t}}get state(){return this.stateManager.state}get initialExtentRequired(){if(!this.stateManager)return!1;const{scale:e,constraints:t,center:i,viewpoint:r,extent:s}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!s&&(t?.effectiveLODs||(a=-1),(!i||0===e&&-1===a)&&(null==r?.targetGeometry||"extent"!==r.targetGeometry.type&&!r.scale)))}get defaultsFromMapSettings(){return{required:{extent:!1,heightModelInfo:!1,tileInfo:!0},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get scheduler(){return this.frameTask.scheduler}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=e.targetGeometry,i=this.spatialReference;return y(t.spatialReference,i)}set animation(e){const t=this._get("animation");if(e===t)return;if(t&&t.stop(),e!==this.animationManager.animation&&this.animationManager.stop(),!e||e.isFulfilled())return void this._set("animation",null);this._set("animation",e);const i=()=>{this.destroyed||e===this._get("animation")&&(this._set("animation",null),this.frameTask?.requestFrame())};e.when(i,i)}get background(){return J(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){return this.stateManager?.center??null}set center(e){this.stateManager.center=e}get constraints(){return this.stateManager?.constraints}set constraints(e){e.view=this;const t=this.stateManager.constraints;this.stateManager.constraints=e,t?.destroy()}get extent(){return this.stateManager?.extent??null}set extent(e){this.stateManager.extent=e}get highlightOptions(){return E(this)}set highlightOptions(e){P(this,e)}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get rendering(){return this.stage?.renderRequested??!1}get resizeAlign(){return this.stateManager.resizeAlign}set resizeAlign(e){this.stateManager.resizeAlign=e}get resolution(){return this.stateManager.resolution??0}get rotation(){return this.stateManager.rotation??0}set rotation(e){const{rotationEnabled:t}=this.constraints;this.constraints.rotationEnabled=!0,this.stateManager.rotation=e,this.constraints.rotationEnabled=t}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get stationary(){return!this.animation&&!this.navigating&&!this.resizing&&this.stationaryManager.stationary}get tileInfo(){return this.featuresTilingScheme?.tileInfo}get updating(){const e=!(!this.magnifier.visible||null===this.magnifier.position||!this._magnifierView?.updatingHandles.updating),t=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some((e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating))||e);if(has("esri-2d-log-updating")){const i=this.allLayerViews.reduce(((e,t)=>({...e,[`${t.layer.id}(${t.layer.type})`]:!t.destroyed&&!("layerViews"in t)&&t.updating})),{});console.log(`Updating MapView: ${t}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(i)}\n-> updatingMagnifier: ${e}\n`)}return t}get viewpoint(){return this.stateManager.viewpoint??null}set viewpoint(e){this.stateManager.viewpoint=e,this.frameTask.requestFrame()}get visibleArea(){const e=this.stateManager.visibleArea;return e?new m({rings:[e.map((e=>[e[0],e[1]]))],spatialReference:this.spatialReference}):e}get zoom(){return this.stateManager.zoom??-1}set zoom(e){this.stateManager.zoom=e}get navigating(){return this.mapViewNavigation?.interacting??!1}goTo(e,t){return this.goToManager.goTo(e,t)}async hitTest(e,t){return z(this,e,t)}async takeScreenshot(e){return A(this._getScreenshotView(e),e)}toMap(e){if(!this.ready)return null;const t=W(e)?$(this,e):e;return this.stateManager.toMap(t)}toScreen(e,t){return this.stateManager.toScreen(e,t)}on(e,t,i,r){const s=this.inputManager&&this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties.spatialReference||this.defaultsFromMap?.spatialReference||null}getDefaultTimeZone(){return J(this.map)?this.map.initialViewProperties.timeZone:null}getDefaultTimeExtent(){return J(this.map)?this.map.initialViewProperties.timeExtent:null}hasLayerViewModule(e){return S.hasLayerViewModule(e)}importLayerView(e){return S.importLayerView(e)}pixelSizeAt(){return this.ready?this.resolution:(a.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}async popupHitTest(e){const t=this.toMap(e),i=await this.hitTest(e),r=this.allLayerViews.toArray().filter((i=>i.clips.every((i=>D(this,i,e,t))))).reverse(),s=new globalThis.Map(r.map((e=>[e.layer.uid,e]))),a=[];let n=0,o=0;for(;n<i.results.length||o<r.length;){const e=i.results.at(n);if(e&&"graphic"!==e.type){++n;continue}const l=s.get((e?.layer??e?.graphic.layer)?.uid);if((!e||l)&&o<r.length&&r.at(o)!==l){const e=r.at(o);"fetchPopupFeaturesAtLocation"in e&&a.push({mapPoint:t,layerView:e}),++o}else e&&(a.push({graphic:e.graphic,layerView:l}),++n)}return{hits:a,location:t}}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}async validate(){let e=H(this.type);if(has("safari")&&has("safari")<9&&(e=new s("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),null!=e)throw a.getLogger(this).warn("#validate()",e.message),e}loadAsyncDependencies(){return se()}_getDefaultViewpoint(){const{constraints:e,initialExtent:i,map:r,padding:s,size:a}=this;if(!e)return null;const n=r&&"initialViewProperties"in r?r.initialViewProperties:void 0,o=this.stateManager.getUserStartupOptions(this.size),l=n?.viewpoint,p=l?.targetGeometry?.extent??i,h=p?.center,g=l?.rotation??0,d=l?.scale||p&&L(p,[a[0]-s.left-s.right,a[1]-s.top-s.bottom]),u=o.center??h,c=o.rotation??g,m=o.scale??d;return u&&m?new t({targetGeometry:u,scale:m,rotation:c}):null}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint();this.stateManager.startup(e,this.size,this.spatialReference,this.defaultsFromMap.extent?.center),this.graphics.owner=this;const t=new Q(this.surface,{canvas:this.renderCanvas,contextOptions:{disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},renderingOptions:this.renderingOptions,timeline:this.timeline});this.stage=t,this._magnifierView=new ie,this._magnifierView.magnifier=this.magnifier,this._gridView=new re;const i=new ee({view:this});this._set("labelManager",i);const r=new b({view:this});this._set("animationManager",r);const s=new te({view:this,animationManager:r});this._set("mapViewNavigation",s),this._setupSpatialReferenceDependentProperties(),this.addHandles([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),t.on("webgl-error",(e=>this.fatalError=e.error)),o((()=>this.stationary),(e=>t.stationary=e),p),o((()=>this.background),(e=>{t.backgroundColor=e?.color,this._magnifierView.backgroundColor=e?.color}),p),o((()=>this.magnifier),(e=>this._magnifierView.magnifier=e),p),o((()=>this.grid),(e=>this._gridView.grid=e),p),o((()=>this.renderingOptions),(e=>t.renderingOptions=e),p),o((()=>this.highlights.items.map((e=>({name:e.name,options:{fillColor:e.color,haloColor:e.haloColor,fillOpacity:e.fillOpacity,haloOpacity:e.haloOpacity,haloWidth:e.haloWidth,haloBlur:e.haloBlur}})))),(()=>{t.highlightGradient=x(t.highlightGradient,this.highlights.items)}),p),o((()=>this.state.id),(()=>t.state=this.state),p)],"map-view"),this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup"),this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.removeHandles("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animation=null,this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._gridView.destroy(),this.stage.destroy(),this.stage=null,this._set("graphicsView",null),this._magnifierView=null,this._gridView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask.stop(),this.stationaryManager.clear(),this._set("ready",!1),this.stateManager.teardown()}_updateStageChildren(){this.stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this.stage.addChild(e.container)}));const e=this.graphicsView;this.stage.addChild(e.container),this.stage.addChild(this._magnifierView),this.stage.addChild(this._gridView)}_setupSpatialReferenceDependentProperties(){const e=new T(f.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new X({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new Y(e)});this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null)}_getScreenshotView(e){const{allLayerViews:t,padding:i,size:r,stage:s}=this;return{allLayerViews:t,backgroundColor:e?.ignoreBackground?null:this.background?.color,padding:i,size:r,stage:s}}_spatialReferenceChanged(e){if(this.ready){this.frameTask.stop();for(const e of this.allLayerViews)e.processDetach();this._destroySpatialReferenceDependentProperties(),this.stateManager.changeSpatialReference(e),this.stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const e of this.allLayerViews)e.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}}static{this.type="2d"}};e([g({readOnly:!0})],ae.prototype,"animationManager",void 0),e([g({constructOnly:!0})],ae.prototype,"deactivatedWebGLExtensions",void 0),e([g({constructOnly:!0})],ae.prototype,"debugWebGLExtensions",void 0),e([g({readOnly:!0})],ae.prototype,"featuresTilingScheme",void 0),e([g({readOnly:!0})],ae.prototype,"fullOpacity",void 0),e([g()],ae.prototype,"goToManager",void 0),e([g({readOnly:!0})],ae.prototype,"graphicsTileStore",null),e([g()],ae.prototype,"graphicsView",void 0),e([g()],ae.prototype,"stateManager",void 0),e([g()],ae.prototype,"constraintsInfo",null),e([g({readOnly:!0})],ae.prototype,"state",null),e([g()],ae.prototype,"initialExtentRequired",null),e([g()],ae.prototype,"labelManager",void 0),e([g({readOnly:!0})],ae.prototype,"mapViewNavigation",void 0),e([g({type:I,nonNullable:!0})],ae.prototype,"navigation",void 0),e([g({constructOnly:!0})],ae.prototype,"renderCanvas",void 0),e([g()],ae.prototype,"renderingOptions",void 0),e([g({constructOnly:!0})],ae.prototype,"supersampleScreenshotsEnabled",void 0),e([g({readOnly:!0})],ae.prototype,"supportsGround",void 0),e([g()],ae.prototype,"defaultsFromMapSettings",null),e([g({readOnly:!0})],ae.prototype,"typeSpecificPreconditionsReady",null),e([g()],ae.prototype,"animation",null),e([g({type:K})],ae.prototype,"background",null),e([g()],ae.prototype,"center",null),e([g({type:O})],ae.prototype,"constraints",null),e([g()],ae.prototype,"extent",null),e([g({type:i})],ae.prototype,"floors",void 0),e([g()],ae.prototype,"grid",void 0),e([g({type:F})],ae.prototype,"highlightOptions",null),e([g({readOnly:!0})],ae.prototype,"inputManager",void 0),e([g()],ae.prototype,"map",void 0),e([g()],ae.prototype,"padding",null),e([g({readOnly:!0})],ae.prototype,"rendering",null),e([g()],ae.prototype,"resizeAlign",null),e([g({readOnly:!0})],ae.prototype,"resolution",null),e([g()],ae.prototype,"rotation",null),e([g()],ae.prototype,"scale",null),e([g({constructOnly:!0})],ae.prototype,"spatialReferenceLocked",void 0),e([g()],ae.prototype,"stationary",null),e([g({readOnly:!0})],ae.prototype,"tileInfo",null),e([g({type:q,readOnly:!0})],ae.prototype,"timeline",void 0),e([g({readOnly:!0})],ae.prototype,"type",void 0),e([g({readOnly:!0})],ae.prototype,"updating",null),e([g({readOnly:!0})],ae.prototype,"view2dType",void 0),e([g({type:t})],ae.prototype,"viewpoint",null),e([g({readOnly:!0})],ae.prototype,"visibleArea",null),e([g()],ae.prototype,"zoom",null),e([g({readOnly:!0})],ae.prototype,"navigating",null),e([g(),d((e=>e instanceof B?e:c(Z,e)))],ae.prototype,"ui",void 0),ae=e([u("esri.views.View2D")],ae);const ne=ae;export{ne as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Viewpoint.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import has from"../core/has.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{watch as o,syncAndInitial as l}from"../core/reactiveUtils.js";import{initialize as p}from"../core/workers/workers.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import{cast as g}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as c}from"../core/accessorSupport/ensureType.js";import u from"../geometry/Polygon.js";import{isLoadedOrLoadFor as m}from"../geometry/projection.js";import y from"../layers/support/TileInfo.js";import{BreakpointsOwner as f}from"./BreakpointsOwner.js";import{DOMContainer as w}from"./DOMContainer.js";import{PopupView as V}from"./PopupView.js";import M from"./View.js";import{Viewport2DMixin as v}from"./Viewport2DMixin.js";import b from"./2d/AnimationManager.js";import{layerView2DImporter as _}from"./2d/layerViewModuleImportUtils.js";import j from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{extentToScale as S}from"./2d/viewpointUtils.js";import O from"./2d/layers/features/support/TileStore.js";import{createOrReuseHighlightGradient as L}from"./2d/layers/support/util.js";import{clipContainsPoint as R}from"./2d/support/clippingUtils.js";import{getDefaultHighlightOptions as T,setDefaultHighlightOptions as k}from"./2d/support/highlightOptionsUtils.js";import{hitTest as C}from"./2d/support/hitTestUtils.js";import{takeRawScreenshot as D,takeScreenshot as x}from"./2d/support/screenshotUtils.js";import{Timeline as P}from"./2d/support/Timeline.js";import G from"./navigation/Navigation.js";import E from"./navigation/NavigationActionMap.js";import U from"./support/HighlightOptions.js";import{isSupportedScreenPointEvent as z,createScreenPointFromSupportedEvent as I}from"./support/screenUtils.js";import{check as q}from"./support/WebGLRequirements.js";import A from"./ui/DefaultUI.js";import N from"./ui/2d/DefaultUI2D.js";import{isWebMap as W}from"../webmap/utils.js";import $ from"../webmap/background/ColorBackground.js";let F,H,B,Z,J,K,Q;async function X(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,GridView2D:a,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);H=e,B=t,Z=i,J=r,K=s,Q=a,F=n}let Y=class extends(v(f(V(w(M))))){constructor(e){super(e),this._magnifierView=null,this._gridView=null,this.stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.graphicsView=null,this.labelManager=null,this.navigation=new G({actionMap:new E({dragTertiary:"none"})}),this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.supersampleScreenshotsEnabled=!0,this.supportsGround=!1,this.floors=new i,this.grid=null,this.map=null,this.spatialReferenceLocked=!1,this.timeline=new P,this.type="2d",this.view2dType=null,this.ui=new N,this.test={takeScreenshot:async e=>D(this._getScreenshotView(e),e)},this.padding={top:0,right:0,bottom:0,left:0},p()}destroy(){this.layerViewManager.clear(),this._set("preconditionsReady",!1),this.frameTask=n(this.frameTask),this.goToManager.destroy(),this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new O(this.featuresTilingScheme)}get constraintsInfo(){const e=this.defaultsFromMap?.tileInfo,t=this.spatialReference;return{lods:e?.spatialReference?.equals(t)?e.lods:null,spatialReference:t}}get initialExtentRequired(){if(!this.stateManager)return!1;const{scale:e,constraints:t,center:i,viewpoint:r,extent:s}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!s&&(t?.effectiveLODs||(a=-1),(!i||0===e&&-1===a)&&(null==r?.targetGeometry||"extent"!==r.targetGeometry.type&&!r.scale)))}get defaultsFromMapSettings(){return{required:{extent:!1,heightModelInfo:!1,tileInfo:!0},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get scheduler(){return this.frameTask.scheduler}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=e.targetGeometry,i=this.spatialReference;return m(t.spatialReference,i)}get background(){return W(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){return this.stateManager?.center??null}set center(e){this.stateManager.center=e}get highlightOptions(){return T(this)}set highlightOptions(e){k(this,e)}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get rendering(){return this.stage?.renderRequested??!1}get resolution(){return this.stateManager.resolution??0}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get tileInfo(){return this.featuresTilingScheme?.tileInfo}get updating(){const e=!(!this.magnifier.visible||null===this.magnifier.position||!this._magnifierView?.updatingHandles.updating),t=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some((e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating))||e);if(has("esri-2d-log-updating")){const i=this.allLayerViews.reduce(((e,t)=>({...e,[`${t.layer.id}(${t.layer.type})`]:!t.destroyed&&!("layerViews"in t)&&t.updating})),{});console.log(`Updating MapView: ${t}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(i)}\n-> updatingMagnifier: ${e}\n`)}return t}get visibleArea(){const e=this.stateManager.visibleArea;return e?new u({rings:[e.map((e=>[e[0],e[1]]))],spatialReference:this.spatialReference}):e}get zoom(){return this.stateManager.zoom??-1}set zoom(e){this.stateManager.zoom=e}get navigating(){return this.mapViewNavigation?.interacting??!1}async hitTest(e,t){return C(this,e,t)}async takeScreenshot(e){return x(this._getScreenshotView(e),e)}toMap(e){if(!this.ready)return null;const t=z(e)?I(this,e):e;return this.stateManager.toMap(t)}toScreen(e,t){return this.stateManager.toScreen(e,t)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties.spatialReference||this.defaultsFromMap?.spatialReference||null}getDefaultTimeZone(){return W(this.map)?this.map.initialViewProperties.timeZone:null}getDefaultTimeExtent(){return W(this.map)?this.map.initialViewProperties.timeExtent:null}hasLayerViewModule(e){return _.hasLayerViewModule(e)}importLayerView(e){return _.importLayerView(e)}pixelSizeAt(){return this.ready?this.resolution:(a.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}async popupHitTest(e){const t=this.toMap(e),i=await this.hitTest(e),r=this.allLayerViews.toArray().filter((i=>i.clips.every((i=>R(this,i,e,t))))).reverse(),s=new globalThis.Map(r.map((e=>[e.layer.uid,e]))),a=[];let n=0,o=0;for(;n<i.results.length||o<r.length;){const e=i.results.at(n);if(e&&"graphic"!==e.type){++n;continue}const l=s.get((e?.layer??e?.graphic.layer)?.uid);if((!e||l)&&o<r.length&&r.at(o)!==l){const e=r.at(o);"fetchPopupFeaturesAtLocation"in e&&a.push({mapPoint:t,layerView:e}),++o}else e&&(a.push({graphic:e.graphic,layerView:l}),++n)}return{hits:a,location:t}}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}async validate(){let e=q(this.type);if(has("safari")&&has("safari")<9&&(e=new s("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),null!=e)throw a.getLogger(this).warn("#validate()",e.message),e}loadAsyncDependencies(){return X()}_getDefaultViewpoint(){const{constraints:e,initialExtent:i,map:r,padding:s,size:a}=this;if(!e)return null;const n=r&&"initialViewProperties"in r?r.initialViewProperties:void 0,o=this.stateManager.getUserStartupOptions(this.size),l=n?.viewpoint,p=l?.targetGeometry?.extent??i,h=p?.center,g=l?.rotation??0,d=l?.scale||p&&S(p,[a[0]-s.left-s.right,a[1]-s.top-s.bottom]),c=o.center??h,u=o.rotation??g,m=o.scale??d;return c&&m?new t({targetGeometry:c,scale:m,rotation:u}):null}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint();this.stateManager.startup(e,this.size,this.spatialReference,this.defaultsFromMap.extent?.center),this.graphics.owner=this;const t=new F(this.surface,{canvas:this.renderCanvas,contextOptions:{disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},renderingOptions:this.renderingOptions,timeline:this.timeline});this.stage=t,this._magnifierView=new K,this._magnifierView.magnifier=this.magnifier,this._gridView=new Q;const i=new Z({view:this});this._set("labelManager",i);const r=new b({view:this});this._set("animationManager",r);const s=new J({view:this,animationManager:r});this._set("mapViewNavigation",s),this._setupSpatialReferenceDependentProperties(),this.addHandles([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),t.on("webgl-error",(e=>this.fatalError=e.error)),o((()=>this.stationary),(e=>t.stationary=e),l),o((()=>this.background),(e=>{t.backgroundColor=e?.color,this._magnifierView.backgroundColor=e?.color}),l),o((()=>this.magnifier),(e=>this._magnifierView.magnifier=e),l),o((()=>this.grid),(e=>this._gridView.grid=e),l),o((()=>this.renderingOptions),(e=>t.renderingOptions=e),l),o((()=>this.highlights.items.map((e=>({name:e.name,options:{fillColor:e.color,haloColor:e.haloColor,fillOpacity:e.fillOpacity,haloOpacity:e.haloOpacity,haloWidth:e.haloWidth,haloBlur:e.haloBlur}})))),(()=>{t.highlightGradient=L(t.highlightGradient,this.highlights.items)}),l),o((()=>this.state.id),(()=>t.state=this.state),l)],"map-view"),this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup"),this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.removeHandles("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animation=null,this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._gridView.destroy(),this.stage.destroy(),this.stage=null,this._set("graphicsView",null),this._magnifierView=null,this._gridView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask.stop(),this.stationaryManager.clear(),this._set("ready",!1),this.stateManager.teardown()}_updateStageChildren(){this.stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this.stage.addChild(e.container)}));const e=this.graphicsView;this.stage.addChild(e.container),this.stage.addChild(this._magnifierView),this.stage.addChild(this._gridView)}_setupSpatialReferenceDependentProperties(){const e=new j(y.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new H({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new B(e)});this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null)}_getScreenshotView(e){const{allLayerViews:t,padding:i,size:r,stage:s}=this;return{allLayerViews:t,backgroundColor:e?.ignoreBackground?null:this.background?.color,padding:i,size:r,stage:s}}_spatialReferenceChanged(e){if(this.ready){this.frameTask.stop();for(const e of this.allLayerViews)e.processDetach();this._destroySpatialReferenceDependentProperties(),this.stateManager.changeSpatialReference(e),this.stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const e of this.allLayerViews)e.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}}static{this.type="2d"}};e([h({constructOnly:!0})],Y.prototype,"deactivatedWebGLExtensions",void 0),e([h({constructOnly:!0})],Y.prototype,"debugWebGLExtensions",void 0),e([h({readOnly:!0})],Y.prototype,"featuresTilingScheme",void 0),e([h({readOnly:!0})],Y.prototype,"graphicsTileStore",null),e([h()],Y.prototype,"graphicsView",void 0),e([h()],Y.prototype,"constraintsInfo",null),e([h()],Y.prototype,"initialExtentRequired",null),e([h()],Y.prototype,"labelManager",void 0),e([h({type:G,nonNullable:!0})],Y.prototype,"navigation",void 0),e([h({constructOnly:!0})],Y.prototype,"renderCanvas",void 0),e([h()],Y.prototype,"renderingOptions",void 0),e([h({constructOnly:!0})],Y.prototype,"supersampleScreenshotsEnabled",void 0),e([h({readOnly:!0})],Y.prototype,"supportsGround",void 0),e([h()],Y.prototype,"defaultsFromMapSettings",null),e([h({readOnly:!0})],Y.prototype,"typeSpecificPreconditionsReady",null),e([h({type:$})],Y.prototype,"background",null),e([h()],Y.prototype,"center",null),e([h({type:i})],Y.prototype,"floors",void 0),e([h()],Y.prototype,"grid",void 0),e([h({type:U})],Y.prototype,"highlightOptions",null),e([h()],Y.prototype,"map",void 0),e([h()],Y.prototype,"padding",null),e([h({readOnly:!0})],Y.prototype,"rendering",null),e([h({readOnly:!0})],Y.prototype,"resolution",null),e([h()],Y.prototype,"scale",null),e([h({constructOnly:!0})],Y.prototype,"spatialReferenceLocked",void 0),e([h({readOnly:!0})],Y.prototype,"tileInfo",null),e([h({type:P,readOnly:!0})],Y.prototype,"timeline",void 0),e([h({readOnly:!0})],Y.prototype,"type",void 0),e([h({readOnly:!0})],Y.prototype,"updating",null),e([h({readOnly:!0})],Y.prototype,"view2dType",void 0),e([h({readOnly:!0})],Y.prototype,"visibleArea",null),e([h()],Y.prototype,"zoom",null),e([h({readOnly:!0})],Y.prototype,"navigating",null),e([h(),g((e=>e instanceof A?e:c(N,e)))],Y.prototype,"ui",void 0),Y=e([d("esri.views.View2D")],Y);const ee=Y;export{ee as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ import{_ as t}from"../chunks/tslib.es6.js";import e from"../Viewpoint.js";import{watch as i,sync as n}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import r from"./2d/FrameTask.js";import{GoToManager as o}from"./2d/GoToManager.js";import p from"./2d/MapViewConstraints.js";import{ViewStateManager as g}from"./2d/ViewStateManager.js";import l from"./2d/input/MapViewInputManager.js";import{StationaryManager as h}from"./2d/support/StationaryManager.js";import{ViewEvents as d}from"./input/ViewEvents.js";const u=u=>{let m=class extends u{constructor(...t){super(...t),this.fullOpacity=1,this.stateManager=new g({constraints:new p({view:this})}),this.goToManager=new o({view:this}),this.stationaryManager=new h,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!1,labelsAnimationTime:0,labelCollisionsEnabled:!1},this.frameTask=new r(this),this.inputManager=new l({view:this}),this.viewEvents=new d(this),this.padding={top:0,right:0,bottom:0,left:0},this.addHandles([i((()=>this.viewpoint),(()=>this.stationaryManager.flip()),n),this.on("resize",(t=>this.stateManager.resize(t.width,t.height)))])}get constraintsInfo(){return{lods:null,spatialReference:null}}get extent(){return this.stateManager?.extent??null}set extent(t){this.stateManager.extent=t}get state(){return this.stateManager.state}get interacting(){return this.navigating}get stationary(){return!this.animation&&!this.navigating&&!this.resizing&&this.stationaryManager.stationary}set animation(t){const e=this._get("animation");if(t===e)return;if(e&&e.stop(),t!==this.animationManager.animation&&this.animationManager.stop(),!t||t.isFulfilled())return void this._set("animation",null);this._set("animation",t);const i=()=>{this.destroyed||t===this._get("animation")&&(this._set("animation",null),this.frameTask?.requestFrame())};t.when(i,i)}get constraints(){return this.stateManager?.constraints}set constraints(t){t.view=this;const e=this.stateManager.constraints;this.stateManager.constraints=t,e?.destroy()}get padding(){return this.stateManager?.padding}set padding(t){this.stateManager&&(this.stateManager.padding=t)}get resizeAlign(){return this.stateManager.resizeAlign}set resizeAlign(t){this.stateManager.resizeAlign=t}get rotation(){return this.stateManager.rotation??0}set rotation(t){const{rotationEnabled:e}=this.constraints;this.constraints.rotationEnabled=!0,this.stateManager.rotation=t,this.constraints.rotationEnabled=e}get viewpoint(){return this.stateManager.viewpoint??null}set viewpoint(t){this.stateManager.viewpoint=t,this.frameTask.requestFrame()}on(t,e,i,n){const a=this.inputManager&&this.viewEvents.on(t,e,i,n);return a||super.on(t,e)}hasEventListener(t){return super.hasEventListener(t)||this.viewEvents.hasHandler(t)}goTo(t,e){return this.goToManager.goTo(t,e)}};return t([a({readOnly:!0})],m.prototype,"animationManager",void 0),t([a({readOnly:!0})],m.prototype,"fullOpacity",void 0),t([a()],m.prototype,"stateManager",void 0),t([a()],m.prototype,"constraintsInfo",null),t([a()],m.prototype,"extent",null),t([a()],m.prototype,"goToManager",void 0),t([a({readOnly:!0})],m.prototype,"state",null),t([a({readOnly:!0})],m.prototype,"mapViewNavigation",void 0),t([a()],m.prototype,"renderingOptions",void 0),t([a({readOnly:!0})],m.prototype,"interacting",null),t([a()],m.prototype,"stationary",null),t([a()],m.prototype,"animation",null),t([a({type:p})],m.prototype,"constraints",null),t([a({readOnly:!0})],m.prototype,"inputManager",void 0),t([a()],m.prototype,"padding",null),t([a()],m.prototype,"resizeAlign",null),t([a()],m.prototype,"rotation",null),t([a({readOnly:!0})],m.prototype,"viewEvents",void 0),t([a({type:e})],m.prototype,"viewpoint",null),m=t([s("esri.views.Viewport2DMixin")],m),m};export{u as Viewport2DMixin};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../core/Error.js";import"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{isAbortError as r}from"../../core/promiseUtils.js";import{signal as s}from"../../core/signal.js";import{getTextureCompressionWorker as o,isCompressible as a}from"../support/TextureCompressionHelper.js";import{checkWebGLError as n}from"./checkWebGLError.js";import{TextureType as p,ResourceType as l,CompressedTextureFormat as m,TextureSamplingMode as h}from"./enums.js";import{GLObjectType as _}from"./GLObjectType.js";import{estimateMemory as d}from"./TextureDescriptor.js";import{isCompressedData as c,deriveInternalFormat as u,isTexImageSource as g,is3DTarget as T,validateTexture as x,isCompressedFormat as E,getDimensions as M,calcMipmapLevels as A,isSizedPixelFormat as I}from"./textureUtils.js";import{ValidatedTextureDescriptor as f}from"./ValidatedTextureDescriptor.js";const w=null,D=()=>e.getLogger("esri/views/webgl/Texture");let R=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}constructor(e,i=null,r=null){if(this.type=_.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,this._compressionAbortController=s(null),"context"in e)this._descriptor=e,r=i;else{const r=f.validate(e,i);if(!r)throw new t("Texture descriptor invalid");this._descriptor=r}this._descriptor.target===p.TEXTURE_CUBE_MAP?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return d(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}get isCompressing(){return null!==this._compressionAbortController.value}dispose(){this.abortCompression(),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.instanceCounter.decrement(l.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===p.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t){this._descriptor.shouldCompress=t}setData(t){return this.abortCompression(),!c(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in m&&(this._descriptor.internalFormat=void 0),this._setData(t),o()&&!c(t)&&a(t)&&this._descriptor.shouldCompress&&this.compressOnWorker(t),this.isCompressing}updateData(i,r,s,o,a,n,p=0){n||D().error("An attempt to use uninitialized data!"),this._glName||D().error("An attempt to update uninitialized texture!");const l=this._descriptor;l.internalFormat=u(l);const{context:m,pixelFormat:h,dataType:_,target:d,isImmutable:T}=l;if(T&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const x=m.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>l.width||s+a>l.height)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=m;p&&(o&&a||D().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,p)),g(n)?E.texSubImage2D(d,i,r,s,o,a,h,_,n):c(n)?E.compressedTexSubImage2D(d,i,r,s,o,a,l.internalFormat,n.levels[i]):E.texSubImage2D(d,i,r,s,o,a,h,_,n),p&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),m.bindTexture(x,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,p,l){l||D().error("An attempt to use uninitialized data!"),this._glName||D().error("An attempt to update an uninitialized texture!");const m=this._descriptor;m.internalFormat=u(m);const{context:h,pixelFormat:_,dataType:d,isImmutable:g,target:x}=m;if(g&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");T(x)||D().warn("Attempting to set 3D texture data on a non-3D texture");const E=h.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);h.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>m.width||s+n>m.height||o+p>m.depth)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=h;if(c(l))l=l.levels[i],M.compressedTexSubImage3D(x,i,r,s,o,a,n,p,m.internalFormat,l);else{const t=l;M.texSubImage3D(x,i,r,s,o,a,n,p,_,d,t)}h.bindTexture(E,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,x(i)}i.samplingMode===h.LINEAR?(this._samplingModeDirty=!0,i.samplingMode=h.LINEAR_MIPMAP_NEAREST):i.samplingMode===h.NEAREST&&(this._samplingModeDirty=!0,i.samplingMode=h.NEAREST_MIPMAP_NEAREST);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,x(e)}e.samplingMode===h.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=h.LINEAR):e.samplingMode===h.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=h.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,x(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1)}abortCompression(){this.isCompressing&&(this._compressionAbortController.value=i(this._compressionAbortController.value))}_setData(i,r){const s=this._descriptor,o=s.context?.gl;if(!o)return;n(o),this._glName||(this._glName=o.createTexture(),s.context.instanceCounter.increment(l.Texture,this)),x(s);const a=s.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);s.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),n(o);const p=r??s.target,m=T(p);if(g(i))this._setDataFromTexImageSource(i,p);else{const{width:e,height:r,depth:a}=s;if(null==e||null==r)throw new t("Width and height must be specified!");if(m&&null==a)throw new t("Depth must be specified!");if(s.internalFormat=u(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(p,s.internalFormat,s.hasMipmap,e,r,a),c(i)){if(!E(s.internalFormat))throw new t("Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,s.internalFormat,p)}else this._texImage(p,0,s.internalFormat,e,r,a,i),n(o),s.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),n(o),s.context.bindTexture(a,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=p.TEXTURE_CUBE_MAP_POSITIVE_X;e<=p.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=u(r);const s=T(e),{width:o,height:a,depth:p}=M(t);r.width&&r.height,r.width||(r.width=o),r.height||(r.height=a),s&&r.depth,s&&(r.depth=p),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,o,a,p),this._texImage(e,0,r.internalFormat,o,a,p,t),n(i),r.hasMipmap&&(this.generateMipmap(),n(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,p=A(i,s,o,a),l=Math.min(p,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,r.context.gl.TEXTURE_MAX_LEVEL,l),this._forEachMipmapLevel(((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)}),l)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!I(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const p=r?A(e,s,o,a):1;if(T(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,p,i,s,o,a)}else n.texStorage2D(e,p,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=T(e),{isImmutable:m,pixelFormat:h,dataType:_}=this._descriptor;if(m){if(null!=n){const r=n;if(l){if(null==a)throw new t("Missing depth dimension for 3D texture upload");p.texSubImage3D(e,i,0,0,0,s,o,a,h,_,r)}else p.texSubImage2D(e,i,0,0,s,o,h,_,r)}}else{const m=n;if(l){if(null==a)throw new t("Missing depth dimension for 3D texture upload");p.texImage3D(e,i,r,s,o,a,0,h,_,m)}else p.texImage2D(e,i,r,s,o,0,h,_,m)}}_compressedTexImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=T(e);if(this._descriptor.isImmutable){if(null!=n)if(l){if(null==a)throw new t("Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else p.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(l){if(null==a)throw new t("Missing depth dimension for 3D texture upload");p.compressedTexImage3D(e,i,r,s,o,a,0,n)}else p.compressedTexImage2D(e,i,r,s,o,0,n)}async compressOnWorker(t){const e=this._descriptor.context?.gl.getExtension("WEBGL_compressed_texture_etc"),i=this._descriptor.context?.gl.getExtension("WEBGL_compressed_texture_s3tc"),s=o();if(s&&(e||i)){const o=new AbortController;this._compressionAbortController.value=o;const a={data:await createImageBitmap(t),flipped:this.descriptor.flipped,width:t.width,height:t.height,hasMipmap:this._descriptor.hasMipmap,hasETC:!!e,hasS3TC:!!i};s.invoke(a,this._compressionAbortController.value.signal).then((t=>{t&&this.isCompressing&&this.glName&&(this._descriptor.internalFormat=t.internalFormat,this._setData(t.compressedTexture)),o===this._compressionAbortController.value&&(this._compressionAbortController.value=null)})).catch((t=>{r(t)||o!==this._compressionAbortController.value||(this._compressionAbortController.value=null)}))}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:a,target:n}=this._descriptor;const l=n===p.TEXTURE_3D;if(null==r||null==s||l&&null==o)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),a&&(1!==r||1!==s||l&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),l&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;i===h.LINEAR_MIPMAP_NEAREST||i===h.LINEAR_MIPMAP_LINEAR?(i=h.LINEAR,t.hasMipmap||(r=h.LINEAR)):i!==h.NEAREST_MIPMAP_NEAREST&&i!==h.NEAREST_MIPMAP_LINEAR||(i=h.NEAREST,t.hasMipmap||(r=h.NEAREST)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{R as Texture,w as tracer};
5
+ import t from"../../core/Error.js";import"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{isAbortError as r}from"../../core/promiseUtils.js";import{signal as s}from"../../core/signal.js";import{getTextureCompressionWorker as o,isCompressible as a}from"../support/TextureCompressionHelper.js";import{checkWebGLError as n}from"./checkWebGLError.js";import{TextureType as l,ResourceType as p,CompressedTextureFormat as m,TextureSamplingMode as h}from"./enums.js";import{GLObjectType as _}from"./GLObjectType.js";import{estimateMemory as d}from"./TextureDescriptor.js";import{isCompressedData as c,deriveInternalFormat as u,isTexImageSource as g,is3DTarget as T,validateTexture as x,isCompressedFormat as E,getDimensions as M,calcMipmapLevels as A,isSizedPixelFormat as I}from"./textureUtils.js";import{ValidatedTextureDescriptor as f}from"./ValidatedTextureDescriptor.js";const w=null,D=()=>e.getLogger("esri/views/webgl/Texture");let R=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}constructor(e,i=null,r=null){if(this.type=_.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,this._compressionAbortController=s(null),"context"in e)this._descriptor=e,r=i;else{const r=f.validate(e,i);if(!r)throw new t("Texture descriptor invalid");this._descriptor=r}this._descriptor.target===l.TEXTURE_CUBE_MAP?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return d(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}get isCompressing(){return null!==this._compressionAbortController.value}dispose(){this.abortCompression(),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.instanceCounter.decrement(p.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===l.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t){this._descriptor.shouldCompress=t}setData(t){this.abortCompression(),!c(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in m&&(this._descriptor.internalFormat=void 0),this._setData(t),o()&&!c(t)&&a(t)&&this._descriptor.shouldCompress&&this.compressOnWorker(t)}updateData(i,r,s,o,a,n,l=0){n||D().error("An attempt to use uninitialized data!"),this._glName||D().error("An attempt to update uninitialized texture!");const p=this._descriptor;p.internalFormat=u(p);const{context:m,pixelFormat:h,dataType:_,target:d,isImmutable:T}=p;if(T&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const x=m.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>p.width||s+a>p.height)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=m;l&&(o&&a||D().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,l)),g(n)?E.texSubImage2D(d,i,r,s,o,a,h,_,n):c(n)?E.compressedTexSubImage2D(d,i,r,s,o,a,p.internalFormat,n.levels[i]):E.texSubImage2D(d,i,r,s,o,a,h,_,n),l&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),m.bindTexture(x,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,l,p){p||D().error("An attempt to use uninitialized data!"),this._glName||D().error("An attempt to update an uninitialized texture!");const m=this._descriptor;m.internalFormat=u(m);const{context:h,pixelFormat:_,dataType:d,isImmutable:g,target:x}=m;if(g&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");T(x)||D().warn("Attempting to set 3D texture data on a non-3D texture");const E=h.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);h.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>m.width||s+n>m.height||o+l>m.depth)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=h;if(c(p))p=p.levels[i],M.compressedTexSubImage3D(x,i,r,s,o,a,n,l,m.internalFormat,p);else{const t=p;M.texSubImage3D(x,i,r,s,o,a,n,l,_,d,t)}h.bindTexture(E,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(0===i.width||0===i.height)return;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,x(i)}i.samplingMode===h.LINEAR?(this._samplingModeDirty=!0,i.samplingMode=h.LINEAR_MIPMAP_NEAREST):i.samplingMode===h.NEAREST&&(this._samplingModeDirty=!0,i.samplingMode=h.NEAREST_MIPMAP_NEAREST);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,x(e)}e.samplingMode===h.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=h.LINEAR):e.samplingMode===h.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=h.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,x(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1)}abortCompression(){this.isCompressing&&(this._compressionAbortController.value=i(this._compressionAbortController.value))}_setData(i,r){const s=this._descriptor,o=s.context?.gl;if(!o)return;n(o),this._glName||(this._glName=o.createTexture(),s.context.instanceCounter.increment(p.Texture,this)),x(s);const a=s.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);s.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),n(o);const l=r??s.target,m=T(l);if(g(i))this._setDataFromTexImageSource(i,l);else{const{width:e,height:r,depth:a}=s;if(null==e||null==r)throw new t("Width and height must be specified!");if(m&&null==a)throw new t("Depth must be specified!");if(s.internalFormat=u(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(l,s.internalFormat,s.hasMipmap,e,r,a),c(i)){if(!E(s.internalFormat))throw new t("Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,s.internalFormat,l)}else this._texImage(l,0,s.internalFormat,e,r,a,i),n(o),s.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),n(o),s.context.bindTexture(a,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=l.TEXTURE_CUBE_MAP_POSITIVE_X;e<=l.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=u(r);const s=T(e),{width:o,height:a,depth:l}=M(t);r.width&&r.height,r.width||(r.width=o),r.height||(r.height=a),s&&r.depth,s&&(r.depth=l),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,o,a,l),this._texImage(e,0,r.internalFormat,o,a,l,t),n(i),r.hasMipmap&&(this.generateMipmap(),n(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,l=A(i,s,o,a),p=Math.min(l,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,r.context.gl.TEXTURE_MAX_LEVEL,p),this._forEachMipmapLevel(((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)}),p)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!I(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const l=r?A(e,s,o,a):1;if(T(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,l,i,s,o,a)}else n.texStorage2D(e,l,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,p=T(e),{isImmutable:m,pixelFormat:h,dataType:_}=this._descriptor;if(m){if(null!=n){const r=n;if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texSubImage3D(e,i,0,0,0,s,o,a,h,_,r)}else l.texSubImage2D(e,i,0,0,s,o,h,_,r)}}else{const m=n;if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texImage3D(e,i,r,s,o,a,0,h,_,m)}else l.texImage2D(e,i,r,s,o,0,h,_,m)}}_compressedTexImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,p=T(e);if(this._descriptor.isImmutable){if(null!=n)if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else l.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexImage3D(e,i,r,s,o,a,0,n)}else l.compressedTexImage2D(e,i,r,s,o,0,n)}async compressOnWorker(t){const e=this._descriptor.context?.gl.getExtension("WEBGL_compressed_texture_etc"),i=this._descriptor.context?.gl.getExtension("WEBGL_compressed_texture_s3tc"),s=o();if(s&&(e||i)){const o=new AbortController;this._compressionAbortController.value=o;const a={data:await createImageBitmap(t),flipped:this.descriptor.flipped,width:t.width,height:t.height,hasMipmap:this._descriptor.hasMipmap,hasETC:!!e,hasS3TC:!!i};s.invoke(a,this._compressionAbortController.value.signal).then((t=>{t&&this.isCompressing&&this.glName&&(this._descriptor.internalFormat=t.internalFormat,this._setData(t.compressedTexture)),o===this._compressionAbortController.value&&(this._compressionAbortController.value=null)})).catch((t=>{r(t)||o!==this._compressionAbortController.value||(this._compressionAbortController.value=null)}))}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:a,target:n}=this._descriptor;const p=n===l.TEXTURE_3D;if(null==r||null==s||p&&null==o)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),a&&(1!==r||1!==s||p&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;i===h.LINEAR_MIPMAP_NEAREST||i===h.LINEAR_MIPMAP_LINEAR?(i=h.LINEAR,t.hasMipmap||(r=h.LINEAR)):i!==h.NEAREST_MIPMAP_NEAREST&&i!==h.NEAREST_MIPMAP_LINEAR||(i=h.NEAREST,t.hasMipmap||(r=h.NEAREST)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{R as Texture,w as tracer};
package/webmap/utils.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{Version as e}from"./Version.js";function r(e){return null!=e&&"object"==typeof e&&"declaredClass"in e&&"esri.WebMap"===e.declaredClass}const n=new e(2,32);export{n as currentVersion,r as isWebMap};
5
+ import{Version as e}from"./Version.js";function r(e){return null!=e&&"object"==typeof e&&"declaredClass"in e&&"esri.WebMap"===e.declaredClass}const n=new e(2,33);export{n as currentVersion,r as isWebMap};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import i from"../core/Identifiable.js";import s from"../core/ReactiveMap.js";import{on as o,watch as r,initial as l,syncAndInitial as n}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import p from"./BasemapLayerList/BasemapLayerListViewModel.js";import m from"./BasemapLayerList/BasemapLayerListVisibleElements.js";import{css as h}from"./BasemapLayerList/css.js";import u from"./LayerList/LayerListItem.js";import f from"./LayerList/ListItem.js";import{minFilterItems as y,getItem as g,getLayerType as _,sortLayersToIds as b,sortChildLayersToIds as L,removeDestroyedListItems as v,setFilterPredicate as I}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import{globalCss as F}from"./support/globalCss.js";import{incrementHeadingLevel as E}from"./support/Heading.js";import{calciteListFilterProps as C}from"./support/listUtils.js";import{setFocus as T}from"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as P}from"./support/decorators/vmEvent.js";import{tsx as O}from"./support/jsxFactory.js";const A=t.ofType(f),R="nested",B=".*\\S+.*",k="data-basemap-layer-type";let j=class extends(i.IdentifiableMixin(d)){constructor(e,i){super(e,i),this._baseListEl=null,this._referenceListEl=null,this._activeItem=null,this._tooltipReferenceMap=new Map,this._editTitleInput=null,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusLayerFlowItem=null,this._focusEditingFlowItem=!1,this._layerListMap=new s,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`basemap-${this.uid}`,this._openedLayersController=null,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.editingTitle=!1,this.filterPlaceholder="",this.baseFilterPredicate=null,this.baseFilterText="",this.referenceFilterPredicate=null,this.referenceFilterText="",this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.headingLevel=2,this.knowledgeGraphOptions=null,this.layerTablesEnabled=new t(["knowledge-graph"]),this.mapImageOptions=null,this.messages=null,this.messagesCommon=null,this.minFilterItems=y,this.openedLayers=new t,this.openedLayerLists=new t,this.tableList=null,this.selectedItems=new A,this.selectionMode="none",this.tileOptions=null,this.viewModel=new p,this.visibilityAppearance="default",this.visibleElements=new m,this._canMove=({dragEl:e,fromEl:t,toEl:i},s)=>{const o="pull"===s?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,r=g(e);if(!r?.sortable)return!1;const l=g(t),n=_(t),a=g(i),c=_(i),d=!!n&&!!c&&n===c,p={selected:r,from:l,to:a},m=t.group,h=i.group,u=l?.layer?.type??"",f=a?.layer?.type??"",y=new Set(["map-image","catalog","knowledge-graph"]),b="sublayer";return m&&h&&"function"==typeof o?o.call(null,p):d&&!y.has(u)&&!y.has(f)&&r?.layer?.type!==b},this._onSelectedDragItemLayerUidChange=e=>{this._selectedDragItemLayerUid=e},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._onTooltipReferenceChange=(e,t)=>{t?this._tooltipReferenceMap.set(e,t):this._tooltipReferenceMap.delete(e)},this._onTablesOpen=e=>{this.openedLayers.push(e.layer),this._focusLayerFlowItem=e.layer?.uid},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0},this._onCatalogOpen=e=>{this.openedLayers.push(e.layer?.parent),this._focusLayerFlowItem=e.layer?.uid},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(h.item)));this._activeItem=g(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:s,dragEl:o,newIndex:r}=e;if(!s||!i||t?.newIndex===r&&t?.dragEl===o&&t?.toEl===i&&t?.fromEl===s)return;this._lastDragDetail=e,this._selectedDragItemLayerUid=o.value;const l=s,n=i;if(l!==n)this._moveLayerFromChildList({toEl:n,fromEl:l,dragEl:o,newIndex:r});else{const e=Array.from(s.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(l,e)}}}initialize(){this.addHandles([o((()=>this.openedLayers),"change",(()=>this._handleOpenedLayersChange()),l),r((()=>[this.viewModel.referenceItems.toArray(),this.viewModel.baseItems.toArray()]),(()=>v(this.selectedItems)),n),r((()=>[this.baseFilterPredicate,this._baseListEl]),(()=>I(this._baseListEl,this.baseFilterPredicate))),r((()=>[this.referenceFilterPredicate,this._referenceListEl]),(()=>I(this._referenceListEl,this.referenceFilterPredicate)))])}loadDependencies(){return w({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this._tooltipReferenceMap.clear(),this._destroyOpenedLayerLists()}get _visibleBaseItems(){return this.baseItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}get _visibleReferenceItems(){return this.referenceItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}get _openedPanelItems(){return this._visibleReferenceItems.concat(this._visibleBaseItems).flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled))}get _totalBaseItems(){return this.viewModel.baseItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer?.type)))).length}get _totalReferenceItems(){return this.viewModel.referenceItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer?.type)))).length}get _baseFilterEnabled(){return this._totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this._totalReferenceItems>=this.minFilterItems&&this.visibleElements.filter}get _renderedOpenLayerFlowItems(){const{openedLayers:e}=this;return e.toArray().map(((t,i)=>this._renderLayerFlowItem(t,i===e.length-1)))}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{state:e}=this.viewModel,t={[F.hidden]:"loading"===e,[F.disabled]:"disabled"===e};return O("div",{class:this.classes(h.base,F.widget,F.panel,t)},this._renderItems())}async _createCatalogLayerList(e){const{default:t}=await import("./CatalogLayerList.js"),{headingLevel:i,catalogOptions:s,view:o,filterPlaceholder:r,minFilterItems:l,selectionMode:n,visibilityAppearance:a,_onCatalogOpen:c,_onTablesOpen:d,layerTablesEnabled:p}=this;return new t({headingLevel:i,view:o,filterPlaceholder:r,minFilterItems:l,selectionMode:n,visibilityAppearance:a,...s,catalogLayer:e,layerTablesEnabled:p,onCatalogOpen:c,onTablesOpen:d})}_getTableListParams(e){switch(e.type){case"knowledge-graph":return{...this.knowledgeGraphOptions,tables:e.tables};case"map-image":return{...this.mapImageOptions,tables:e.subtables};case"tile":return{...this.tileOptions,tables:e.subtables};default:return null}}async _createTableList(e){const{default:t}=await import("./TableList.js"),{headingLevel:i,selectionMode:s,dragEnabled:o}=this;return new t({headingLevel:i,selectionMode:s,dragEnabled:o,...this._getTableListParams(e)})}async _createFlowList(e,t){const{_layerListMap:i}=this,s=i.get(e);if(s)return s;const o="catalog"===e.type?await this._createCatalogLayerList(e):await this._createTableList(e);return t.aborted||i.set(e,o),o}async _handleOpenedLayersChange(){const{_layerListMap:e,openedLayers:t,openedLayerLists:i}=this;this._openedLayersController?.abort();const s=new AbortController,{signal:o}=s;this._openedLayersController=s,e.forEach(((i,s)=>{t.includes(s)||(i.destroy(),e.delete(s))}));const r=await Promise.all(t.map((e=>this._createFlowList(e,o))));if(o.aborted)return;i.removeAll(),i.addMany(r);const l=i.at(-1);l?"catalogLayer"in l?(this._set("catalogLayerList",l),this._set("tableList",null)):(this._set("catalogLayerList",null),this._set("tableList",l)):(this._set("catalogLayerList",null),this._set("tableList",null))}_destroyOpenedLayerLists(){this.openedLayerLists.destroyAll(),this.openedLayers.removeAll(),this._layerListMap.clear()}_renderItemTooltip(e){return e?O("calcite-tooltip",{key:`tooltip-${e.layer?.uid}`,referenceElement:this._tooltipReferenceMap.get(e.layer?.uid)},this.messages.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(){return this._visibleReferenceItems.concat(this._visibleBaseItems)?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_focusLayerFlowItemNode(e){this._focusLayerFlowItem===e.dataset.layerUid&&(this._focusLayerFlowItem=null,T(e))}_renderPanelFlowItems(){const{_openedPanelItems:e,openedLayers:t}=this;return e.toArray().map((({title:i,panel:s},o)=>{const r=()=>this._handlePanelFlowItemBack(s);return O("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:i,heading:s.title,headingLevel:this.headingLevel,key:`flow-panel-${s.uid}`,selected:!t.length&&o===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),r()}},s.render(),O("calcite-button",{appearance:"transparent",onclick:r,slot:"footer-actions",width:"full"},this.messagesCommon.back))}))}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusEditingFlowItemNode(e){this._focusEditingFlowItem&&(this._focusEditingFlowItem=!1,T(e))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,T(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,T(e))}_renderItem(e,t,i,s){return O(u,{activeItem:this._activeItem,canMove:this._canMove,css:h,displayMode:R,dragEnabled:!t&&this.dragEnabled,item:e,key:`layerListItem-${e.layer?.uid}`,layerTablesEnabled:this.layerTablesEnabled,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,parent:i,parentTitles:s,rootGroupUid:this._rootGroupUid,selectedDragItemLayerUid:this._selectedDragItemLayerUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibilityAppearance:this.visibilityAppearance,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onCatalogOpen:this._onCatalogOpen,onPanelOpen:this._onPanelOpen,onSelectedDragItemLayerUidChange:this._onSelectedDragItemLayerUidChange,onTablesOpen:this._onTablesOpen,onTooltipReferenceChange:this._onTooltipReferenceChange})}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:s}){const o=g(i),r=g(e),l=g(t),n=D(t),a=D(e);n&&a&&this.viewModel.moveListItem({targetItem:o,fromParentItem:l,toParentItem:r,newIndex:s,from:n,to:a})}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:s}=e;t.insertBefore(i,t.children[s])}_sortLayers(e,t){if(e)if(e===this._referenceListEl||e===this._baseListEl){const i=e===this._referenceListEl?"reference":"base",s="base"===i?this.view?.map?.basemap?.baseLayers:"reference"===i?this.view?.map?.basemap?.referenceLayers:null;b(s,t)}else{const i=g(e);if(!i)return;L(i,t)}}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const s=e.target.selectedItems.map((e=>g(e))).filter(Boolean);i.removeAll(),i.addMany(s)}_renderEditingInput(){const{messages:e}=this,{basemapTitle:t}=this.viewModel;return O("div",{class:h.editing},O("calcite-label",null,e.basemapTitle,O("calcite-input",{afterCreate:e=>this._editTitleInput=e,label:e.basemapTitle,name:"basemaptitle",pattern:B,placeholder:e.basemapTitle,required:!0,title:e.basemapTitle,type:"text",value:t??void 0})))}_renderCancelButton(){const{messagesCommon:{cancel:e}}=this;return O("calcite-button",{appearance:"outline",bind:this,label:e,onclick:this._toggleEditingTitle,slot:"footer",title:e,width:"full"},e)}_renderSubmitButton(){const{messagesCommon:e}=this;return O("calcite-button",{label:e.form.submit,slot:"footer",title:e.form.submit,type:"submit",width:"full"},e.form.ok)}_renderEditingForm(){return this.editingTitle?O("form",{bind:this,class:h.editingForm,onsubmit:this._formSubmit},O("calcite-flow-item",{afterCreate:this._focusEditingFlowItemNode,afterUpdate:this._focusEditingFlowItemNode,bind:this,heading:this.visibleElements.heading?this.messages.basemapTitle:void 0,headingLevel:this.headingLevel,selected:0===this.openedLayers.length&&0===this._openedPanelItems.length,onCalciteFlowItemBack:e=>{e.preventDefault(),this._toggleEditingTitle()}},this._renderEditingInput(),this._renderCancelButton(),this._renderSubmitButton())):null}_renderEditTitleButton(){const{editingTitle:e,visibleElements:t,messagesCommon:i}=this,s=i.edit;return t.editTitleButton&&!e?O("calcite-action",{bind:this,icon:"pencil",onclick:this._toggleEditingTitle,slot:"header-actions-end",text:s,title:s}):null}_renderNoLayersInfoMessage(e){return O("div",{slot:"message"},e)}_renderNoLayersInfo(e,t){return O("div",{class:h.itemMessage},O("calcite-notice",{icon:"information",key:t,kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(e)))}_renderItems(){const{collapsed:e,visible:t,visibleElements:{closeButton:i,collapseButton:s,heading:o,flow:r},messages:l,viewModel:n}=this,a=[O("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:i,closed:!t,collapsed:e,collapsible:s,heading:o?n.basemapTitle??l.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",selected:!this.editingTitle&&0===this.openedLayers.length&&0===this._openedPanelItems.length,onCalciteFlowItemClose:()=>this.visible=!1},this._renderEditTitleButton(),this._renderReferenceSection(),this._renderBaseSection()),this._renderEditingForm(),this._renderPanelFlowItems(),this._renderedOpenLayerFlowItems];return t?[r?O("calcite-flow",{key:"root-flow"},a):a,this._renderItemTooltips()]:null}_renderLayerFlowItem(e,t){const{messages:i,openedLayers:s}=this,o=e.title||this.messages.untitledLayer;return O("calcite-flow-item",{afterCreate:this._focusLayerFlowItemNode,afterUpdate:this._focusLayerFlowItemNode,bind:this,"data-layer-uid":e.uid,description:o,heading:i["catalog"===e.type?"catalogLayers":"tables"],headingLevel:this.headingLevel,key:`flow-layer-list-${e.uid}`,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),s.pop();const t=s.at(-1);t?this._focusLayerFlowItem=t.uid:this._focusRootFlowItem=!0}},this._layerListMap.get(e)?.render())}_renderList(e,t,i){const{messages:s,dragEnabled:o,selectionMode:r,filterPlaceholder:l,baseFilterText:n,referenceFilterText:a,_baseFilterEnabled:c,_referenceFilterEnabled:d,_rootGroupUid:p}=this,m="reference"===t?s.noReferenceLayers:s.noBaseLayers,u="reference"===t?d:c;return O("calcite-block",{class:h.section,collapsible:!0,heading:"reference"===t?s.referenceHeading:s.baseHeading,headingLevel:E(this.headingLevel),key:`block-${t}`,open:!0},0===e?.length?this._renderNoLayersInfo(m,t):null,O("calcite-list",{afterCreate:e=>{"reference"===t?this._referenceListEl=e:this._baseListEl=e,e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{"reference"===t?this._referenceListEl=null:this._baseListEl=null,e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),displayMode:R,filterProps:C,[k]:t,"data-layer-type":p,dragEnabled:o,filterEnabled:u,filterPlaceholder:l,filterText:u?"reference"===t?a:n:"",group:p,key:`list-${t}`,label:s.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:r,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this["reference"===t?"referenceFilterText":"baseFilterText"]=e.currentTarget?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e,i))),e?.length&&u?O("div",{class:h.filterNoResults,slot:"filter-no-results"},O("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(m))):null))}_renderBaseSection(){const{_visibleBaseItems:e}=this;return this.visibleElements.baseLayers?this._renderList(e,"base",1===e?.length):null}_renderReferenceSection(){return this.visibleElements.referenceLayers?this._renderList(this._visibleReferenceItems,"reference",!1):null}_toggleEditingTitle(){const{editingTitle:e}=this,t=!e;this.editingTitle=t,t?this._focusEditingFlowItem=!0:this._focusRootFlowItem=!0}_formSubmit(e){e.preventDefault();const t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}};function D(e){return e?.closest(`[${k}]`)?.getAttribute(k)}e([a()],j.prototype,"_baseListEl",void 0),e([a()],j.prototype,"_referenceListEl",void 0),e([a()],j.prototype,"_activeItem",void 0),e([a()],j.prototype,"_tooltipReferenceMap",void 0),e([a()],j.prototype,"_focusRootFlowItem",void 0),e([a()],j.prototype,"_focusPanelFlowItem",void 0),e([a()],j.prototype,"_focusLayerFlowItem",void 0),e([a()],j.prototype,"_focusEditingFlowItem",void 0),e([a()],j.prototype,"_layerListMap",void 0),e([a()],j.prototype,"_visibleBaseItems",null),e([a()],j.prototype,"_visibleReferenceItems",null),e([a()],j.prototype,"_openedPanelItems",null),e([a()],j.prototype,"_totalBaseItems",null),e([a()],j.prototype,"_totalReferenceItems",null),e([a()],j.prototype,"_baseFilterEnabled",null),e([a()],j.prototype,"_referenceFilterEnabled",null),e([a()],j.prototype,"_renderedOpenLayerFlowItems",null),e([a()],j.prototype,"basemapTitle",null),e([a({readOnly:!0})],j.prototype,"catalogLayerList",void 0),e([a()],j.prototype,"catalogOptions",void 0),e([a()],j.prototype,"collapsed",void 0),e([a()],j.prototype,"dragEnabled",void 0),e([a()],j.prototype,"editingTitle",void 0),e([a()],j.prototype,"filterPlaceholder",void 0),e([a()],j.prototype,"baseFilterPredicate",void 0),e([a()],j.prototype,"baseFilterText",void 0),e([a()],j.prototype,"referenceFilterPredicate",void 0),e([a()],j.prototype,"referenceFilterText",void 0),e([a()],j.prototype,"listItemCanGiveFunction",void 0),e([a()],j.prototype,"listItemCanReceiveFunction",void 0),e([a()],j.prototype,"baseListItemCreatedFunction",null),e([a()],j.prototype,"headingLevel",void 0),e([a()],j.prototype,"icon",null),e([a()],j.prototype,"knowledgeGraphOptions",void 0),e([a()],j.prototype,"label",null),e([a()],j.prototype,"layerTablesEnabled",void 0),e([a()],j.prototype,"mapImageOptions",void 0),e([a(),M("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],j.prototype,"messages",void 0),e([a(),M("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([a()],j.prototype,"minFilterItems",void 0),e([a({readOnly:!0})],j.prototype,"openedLayers",void 0),e([a({readOnly:!0})],j.prototype,"openedLayerLists",void 0),e([a()],j.prototype,"referenceListItemCreatedFunction",null),e([a({readOnly:!0})],j.prototype,"tableList",void 0),e([a({readOnly:!0})],j.prototype,"baseItems",null),e([a({readOnly:!0})],j.prototype,"referenceItems",null),e([a({type:A})],j.prototype,"selectedItems",void 0),e([a()],j.prototype,"selectionMode",void 0),e([a()],j.prototype,"tileOptions",void 0),e([a()],j.prototype,"view",null),e([P("trigger-action"),a({type:p})],j.prototype,"viewModel",void 0),e([a()],j.prototype,"visibilityAppearance",void 0),e([a({type:m,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([c("esri.widgets.BasemapLayerList")],j);const x=j;export{x as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import i from"../core/Identifiable.js";import s from"../core/ReactiveMap.js";import{on as o,watch as r,initial as l,syncAndInitial as n}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import p from"./BasemapLayerList/BasemapLayerListViewModel.js";import m from"./BasemapLayerList/BasemapLayerListVisibleElements.js";import{css as h}from"./BasemapLayerList/css.js";import u from"./LayerList/LayerListItem.js";import f from"./LayerList/ListItem.js";import{minFilterItems as y,getItem as g,getLayerType as _,sortLayersToIds as b,sortChildLayersToIds as L,removeDestroyedListItems as v,setFilterPredicate as I}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import{globalCss as F}from"./support/globalCss.js";import{incrementHeadingLevel as E}from"./support/Heading.js";import{calciteListFilterProps as C}from"./support/listUtils.js";import{setFocus as T}from"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as P}from"./support/decorators/vmEvent.js";import{tsx as O}from"./support/jsxFactory.js";const A=t.ofType(f),R="nested",B=".*\\S+.*",k="data-basemap-layer-type";let j=class extends(i.IdentifiableMixin(d)){constructor(e,i){super(e,i),this._baseListEl=null,this._referenceListEl=null,this._activeItem=null,this._tooltipReferenceMap=new Map,this._editTitleInput=null,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusLayerFlowItem=null,this._focusEditingFlowItem=!1,this._layerListMap=new s,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`basemap-${this.uid}`,this._openedLayersController=null,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.editingTitle=!1,this.filterPlaceholder="",this.baseFilterPredicate=null,this.baseFilterText="",this.referenceFilterPredicate=null,this.referenceFilterText="",this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.headingLevel=2,this.knowledgeGraphOptions=null,this.layerTablesEnabled=new t(["knowledge-graph"]),this.mapImageOptions=null,this.messages=null,this.messagesCommon=null,this.minFilterItems=y,this.openedLayers=new t,this.openedLayerLists=new t,this.tableList=null,this.selectedItems=new A,this.selectionMode="none",this.tileOptions=null,this.viewModel=new p,this.visibilityAppearance="default",this.visibleElements=new m,this._canMove=({dragEl:e,fromEl:t,toEl:i},s)=>{const o="pull"===s?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,r=g(e);if(!r?.sortable)return!1;const l=g(t),n=_(t),a=g(i),c=_(i),d=!!n&&!!c&&n===c,p={selected:r,from:l,to:a},m=t.group,h=i.group,u=l?.layer?.type??"",f=a?.layer?.type??"",y=new Set(["map-image","catalog","knowledge-graph"]),b="sublayer";return m&&h&&"function"==typeof o?o.call(null,p):d&&!y.has(u)&&!y.has(f)&&r?.layer?.type!==b},this._onSelectedDragItemLayerUidChange=e=>{this._selectedDragItemLayerUid=e},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._onTooltipReferenceChange=(e,t)=>{t?this._tooltipReferenceMap.set(e,t):this._tooltipReferenceMap.delete(e)},this._onTablesOpen=e=>{this.openedLayers.push(e.layer),this._focusLayerFlowItem=e.layer?.uid},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0},this._onCatalogOpen=e=>{this.openedLayers.push(e.layer?.parent),this._focusLayerFlowItem=e.layer?.uid},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(h.item)));this._activeItem=g(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:s,dragEl:o,newIndex:r}=e;if(!s||!i||t?.newIndex===r&&t?.dragEl===o&&t?.toEl===i&&t?.fromEl===s)return;this._lastDragDetail=e,this._selectedDragItemLayerUid=o.value;const l=s,n=i;if(l!==n)this._moveLayerFromChildList({toEl:n,fromEl:l,dragEl:o,newIndex:r});else{const e=Array.from(s.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(l,e)}}}initialize(){this.addHandles([o((()=>this.openedLayers),"change",(()=>this._handleOpenedLayersChange()),l),r((()=>[this.viewModel.referenceItems.toArray(),this.viewModel.baseItems.toArray()]),(()=>v(this.selectedItems)),n),r((()=>[this.baseFilterPredicate,this._baseListEl]),(()=>I(this._baseListEl,this.baseFilterPredicate))),r((()=>[this.referenceFilterPredicate,this._referenceListEl]),(()=>I(this._referenceListEl,this.referenceFilterPredicate)))])}loadDependencies(){return w({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this._tooltipReferenceMap.clear(),this._destroyOpenedLayerLists()}get _visibleBaseItems(){return this.baseItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}get _visibleReferenceItems(){return this.referenceItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}get _openedPanelItems(){return this._visibleReferenceItems.concat(this._visibleBaseItems).flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled))}get _totalBaseItems(){return this.viewModel.baseItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer?.type)))).length}get _totalReferenceItems(){return this.viewModel.referenceItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer?.type)))).length}get _baseFilterEnabled(){return this._totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this._totalReferenceItems>=this.minFilterItems&&this.visibleElements.filter}get _renderedOpenLayerFlowItems(){const{openedLayers:e}=this;return e.toArray().map(((t,i)=>this._renderLayerFlowItem(t,i===e.length-1)))}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{state:e}=this.viewModel,t={[F.hidden]:"loading"===e,[F.disabled]:"disabled"===e};return O("div",{class:this.classes(h.base,F.widget,F.panel,t)},this._renderItems())}async _createCatalogLayerList(e){const{default:t}=await import("./CatalogLayerList.js"),{headingLevel:i,catalogOptions:s,view:o,filterPlaceholder:r,minFilterItems:l,selectionMode:n,visibilityAppearance:a,_onCatalogOpen:c,_onTablesOpen:d,layerTablesEnabled:p}=this;return new t({headingLevel:i,view:o,filterPlaceholder:r,minFilterItems:l,selectionMode:n,visibilityAppearance:a,...s,catalogLayer:e,layerTablesEnabled:p,onCatalogOpen:c,onTablesOpen:d})}_getTableListParams(e){switch(e.type){case"knowledge-graph":return{...this.knowledgeGraphOptions,tables:e.tables};case"map-image":return{...this.mapImageOptions,tables:e.subtables};case"tile":return{...this.tileOptions,tables:e.subtables};default:return null}}async _createTableList(e){const{default:t}=await import("./TableList.js"),{headingLevel:i,selectionMode:s,dragEnabled:o}=this;return new t({headingLevel:i,selectionMode:s,dragEnabled:o,...this._getTableListParams(e)})}async _createFlowList(e,t){const{_layerListMap:i}=this,s=i.get(e);if(s)return s;const o="catalog"===e.type?await this._createCatalogLayerList(e):await this._createTableList(e);return t.aborted||i.set(e,o),o}async _handleOpenedLayersChange(){const{_layerListMap:e,openedLayers:t,openedLayerLists:i}=this;this._openedLayersController?.abort();const s=new AbortController,{signal:o}=s;this._openedLayersController=s,e.forEach(((i,s)=>{t.includes(s)||(i.destroy(),e.delete(s))}));const r=await Promise.all(t.map((e=>this._createFlowList(e,o))));if(o.aborted)return;i.removeAll(),i.addMany(r);const l=i.at(-1);l?"catalogLayer"in l?(this._set("catalogLayerList",l),this._set("tableList",null)):(this._set("catalogLayerList",null),this._set("tableList",l)):(this._set("catalogLayerList",null),this._set("tableList",null))}_destroyOpenedLayerLists(){this.openedLayerLists.destroyAll(),this.openedLayers.removeAll(),this._layerListMap.clear()}_renderItemTooltip(e){return e?O("calcite-tooltip",{key:`tooltip-${e.layer?.uid}`,overlayPositioning:"fixed",referenceElement:this._tooltipReferenceMap.get(e.layer?.uid)},this.messages.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(){return this._visibleReferenceItems.concat(this._visibleBaseItems)?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_focusLayerFlowItemNode(e){this._focusLayerFlowItem===e.dataset.layerUid&&(this._focusLayerFlowItem=null,T(e))}_renderPanelFlowItems(){const{_openedPanelItems:e,openedLayers:t}=this;return e.toArray().map((({title:i,panel:s},o)=>{const r=()=>this._handlePanelFlowItemBack(s);return O("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:i,heading:s.title,headingLevel:this.headingLevel,key:`flow-panel-${s.uid}`,selected:!t.length&&o===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),r()}},s.render(),O("calcite-button",{appearance:"transparent",onclick:r,slot:"footer-actions",width:"full"},this.messagesCommon.back))}))}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusEditingFlowItemNode(e){this._focusEditingFlowItem&&(this._focusEditingFlowItem=!1,T(e))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,T(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,T(e))}_renderItem(e,t,i,s){return O(u,{activeItem:this._activeItem,canMove:this._canMove,css:h,displayMode:R,dragEnabled:!t&&this.dragEnabled,item:e,key:`layerListItem-${e.layer?.uid}`,layerTablesEnabled:this.layerTablesEnabled,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,parent:i,parentTitles:s,rootGroupUid:this._rootGroupUid,selectedDragItemLayerUid:this._selectedDragItemLayerUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibilityAppearance:this.visibilityAppearance,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onCatalogOpen:this._onCatalogOpen,onPanelOpen:this._onPanelOpen,onSelectedDragItemLayerUidChange:this._onSelectedDragItemLayerUidChange,onTablesOpen:this._onTablesOpen,onTooltipReferenceChange:this._onTooltipReferenceChange})}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:s}){const o=g(i),r=g(e),l=g(t),n=D(t),a=D(e);n&&a&&this.viewModel.moveListItem({targetItem:o,fromParentItem:l,toParentItem:r,newIndex:s,from:n,to:a})}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:s}=e;t.insertBefore(i,t.children[s])}_sortLayers(e,t){if(e)if(e===this._referenceListEl||e===this._baseListEl){const i=e===this._referenceListEl?"reference":"base",s="base"===i?this.view?.map?.basemap?.baseLayers:"reference"===i?this.view?.map?.basemap?.referenceLayers:null;b(s,t)}else{const i=g(e);if(!i)return;L(i,t)}}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const s=e.target.selectedItems.map((e=>g(e))).filter(Boolean);i.removeAll(),i.addMany(s)}_renderEditingInput(){const{messages:e}=this,{basemapTitle:t}=this.viewModel;return O("div",{class:h.editing},O("calcite-label",null,e.basemapTitle,O("calcite-input",{afterCreate:e=>this._editTitleInput=e,label:e.basemapTitle,name:"basemaptitle",pattern:B,placeholder:e.basemapTitle,required:!0,title:e.basemapTitle,type:"text",value:t??void 0})))}_renderCancelButton(){const{messagesCommon:{cancel:e}}=this;return O("calcite-button",{appearance:"outline",bind:this,label:e,onclick:this._toggleEditingTitle,slot:"footer",title:e,width:"full"},e)}_renderSubmitButton(){const{messagesCommon:e}=this;return O("calcite-button",{label:e.form.submit,slot:"footer",title:e.form.submit,type:"submit",width:"full"},e.form.ok)}_renderEditingForm(){return this.editingTitle?O("form",{bind:this,class:h.editingForm,onsubmit:this._formSubmit},O("calcite-flow-item",{afterCreate:this._focusEditingFlowItemNode,afterUpdate:this._focusEditingFlowItemNode,bind:this,heading:this.visibleElements.heading?this.messages.basemapTitle:void 0,headingLevel:this.headingLevel,selected:0===this.openedLayers.length&&0===this._openedPanelItems.length,onCalciteFlowItemBack:e=>{e.preventDefault(),this._toggleEditingTitle()}},this._renderEditingInput(),this._renderCancelButton(),this._renderSubmitButton())):null}_renderEditTitleButton(){const{editingTitle:e,visibleElements:t,messagesCommon:i}=this,s=i.edit;return t.editTitleButton&&!e?O("calcite-action",{bind:this,icon:"pencil",onclick:this._toggleEditingTitle,slot:"header-actions-end",text:s,title:s}):null}_renderNoLayersInfoMessage(e){return O("div",{slot:"message"},e)}_renderNoLayersInfo(e,t){return O("div",{class:h.itemMessage},O("calcite-notice",{icon:"information",key:t,kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(e)))}_renderItems(){const{collapsed:e,visible:t,visibleElements:{closeButton:i,collapseButton:s,heading:o,flow:r},messages:l,viewModel:n}=this,a=[O("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:i,closed:!t,collapsed:e,collapsible:s,heading:o?n.basemapTitle??l.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",selected:!this.editingTitle&&0===this.openedLayers.length&&0===this._openedPanelItems.length,onCalciteFlowItemClose:()=>this.visible=!1},this._renderEditTitleButton(),this._renderReferenceSection(),this._renderBaseSection()),this._renderEditingForm(),this._renderPanelFlowItems(),this._renderedOpenLayerFlowItems];return t?[r?O("calcite-flow",{key:"root-flow"},a):a,this._renderItemTooltips()]:null}_renderLayerFlowItem(e,t){const{messages:i,openedLayers:s}=this,o=e.title||this.messages.untitledLayer;return O("calcite-flow-item",{afterCreate:this._focusLayerFlowItemNode,afterUpdate:this._focusLayerFlowItemNode,bind:this,"data-layer-uid":e.uid,description:o,heading:i["catalog"===e.type?"catalogLayers":"tables"],headingLevel:this.headingLevel,key:`flow-layer-list-${e.uid}`,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),s.pop();const t=s.at(-1);t?this._focusLayerFlowItem=t.uid:this._focusRootFlowItem=!0}},this._layerListMap.get(e)?.render())}_renderList(e,t,i){const{messages:s,dragEnabled:o,selectionMode:r,filterPlaceholder:l,baseFilterText:n,referenceFilterText:a,_baseFilterEnabled:c,_referenceFilterEnabled:d,_rootGroupUid:p}=this,m="reference"===t?s.noReferenceLayers:s.noBaseLayers,u="reference"===t?d:c;return O("calcite-block",{class:h.section,collapsible:!0,heading:"reference"===t?s.referenceHeading:s.baseHeading,headingLevel:E(this.headingLevel),key:`block-${t}`,open:!0},0===e?.length?this._renderNoLayersInfo(m,t):null,O("calcite-list",{afterCreate:e=>{"reference"===t?this._referenceListEl=e:this._baseListEl=e,e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{"reference"===t?this._referenceListEl=null:this._baseListEl=null,e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),displayMode:R,filterProps:C,[k]:t,"data-layer-type":p,dragEnabled:o,filterEnabled:u,filterPlaceholder:l,filterText:u?"reference"===t?a:n:"",group:p,key:`list-${t}`,label:s.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:r,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this["reference"===t?"referenceFilterText":"baseFilterText"]=e.currentTarget?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e,i))),e?.length&&u?O("div",{class:h.filterNoResults,slot:"filter-no-results"},O("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(m))):null))}_renderBaseSection(){const{_visibleBaseItems:e}=this;return this.visibleElements.baseLayers?this._renderList(e,"base",1===e?.length):null}_renderReferenceSection(){return this.visibleElements.referenceLayers?this._renderList(this._visibleReferenceItems,"reference",!1):null}_toggleEditingTitle(){const{editingTitle:e}=this,t=!e;this.editingTitle=t,t?this._focusEditingFlowItem=!0:this._focusRootFlowItem=!0}_formSubmit(e){e.preventDefault();const t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}};function D(e){return e?.closest(`[${k}]`)?.getAttribute(k)}e([a()],j.prototype,"_baseListEl",void 0),e([a()],j.prototype,"_referenceListEl",void 0),e([a()],j.prototype,"_activeItem",void 0),e([a()],j.prototype,"_tooltipReferenceMap",void 0),e([a()],j.prototype,"_focusRootFlowItem",void 0),e([a()],j.prototype,"_focusPanelFlowItem",void 0),e([a()],j.prototype,"_focusLayerFlowItem",void 0),e([a()],j.prototype,"_focusEditingFlowItem",void 0),e([a()],j.prototype,"_layerListMap",void 0),e([a()],j.prototype,"_visibleBaseItems",null),e([a()],j.prototype,"_visibleReferenceItems",null),e([a()],j.prototype,"_openedPanelItems",null),e([a()],j.prototype,"_totalBaseItems",null),e([a()],j.prototype,"_totalReferenceItems",null),e([a()],j.prototype,"_baseFilterEnabled",null),e([a()],j.prototype,"_referenceFilterEnabled",null),e([a()],j.prototype,"_renderedOpenLayerFlowItems",null),e([a()],j.prototype,"basemapTitle",null),e([a({readOnly:!0})],j.prototype,"catalogLayerList",void 0),e([a()],j.prototype,"catalogOptions",void 0),e([a()],j.prototype,"collapsed",void 0),e([a()],j.prototype,"dragEnabled",void 0),e([a()],j.prototype,"editingTitle",void 0),e([a()],j.prototype,"filterPlaceholder",void 0),e([a()],j.prototype,"baseFilterPredicate",void 0),e([a()],j.prototype,"baseFilterText",void 0),e([a()],j.prototype,"referenceFilterPredicate",void 0),e([a()],j.prototype,"referenceFilterText",void 0),e([a()],j.prototype,"listItemCanGiveFunction",void 0),e([a()],j.prototype,"listItemCanReceiveFunction",void 0),e([a()],j.prototype,"baseListItemCreatedFunction",null),e([a()],j.prototype,"headingLevel",void 0),e([a()],j.prototype,"icon",null),e([a()],j.prototype,"knowledgeGraphOptions",void 0),e([a()],j.prototype,"label",null),e([a()],j.prototype,"layerTablesEnabled",void 0),e([a()],j.prototype,"mapImageOptions",void 0),e([a(),M("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],j.prototype,"messages",void 0),e([a(),M("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([a()],j.prototype,"minFilterItems",void 0),e([a({readOnly:!0})],j.prototype,"openedLayers",void 0),e([a({readOnly:!0})],j.prototype,"openedLayerLists",void 0),e([a()],j.prototype,"referenceListItemCreatedFunction",null),e([a({readOnly:!0})],j.prototype,"tableList",void 0),e([a({readOnly:!0})],j.prototype,"baseItems",null),e([a({readOnly:!0})],j.prototype,"referenceItems",null),e([a({type:A})],j.prototype,"selectedItems",void 0),e([a()],j.prototype,"selectionMode",void 0),e([a()],j.prototype,"tileOptions",void 0),e([a()],j.prototype,"view",null),e([P("trigger-action"),a({type:p})],j.prototype,"viewModel",void 0),e([a()],j.prototype,"visibilityAppearance",void 0),e([a({type:m,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([c("esri.widgets.BasemapLayerList")],j);const x=j;export{x as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{createTask as t}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import i from"../../core/Evented.js";import a from"../../core/Logger.js";import{abortMaybe as o}from"../../core/maybe.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{on as l,watch as u,whenOnce as h,sync as m}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import v from"../../geometry/SpatialReference.js";import{system as _}from"../../time/timeZoneUtils.js";import{createReactiveGraphic as F}from"./batchAttributeFormUtils.js";import{ArcadeExecutorProvider as g}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as y}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as I}from"./expressions/ExpressionsModel.js";import{BatchFormInputs as E}from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as w}from"./inputs/support/createBatchFormInputs.js";import{NoVisibleElementCodes as b,InputVisibilityCode as x,isGroupInput as M,isFieldInput as T}from"./inputs/support/inputUtils.js";import k from"./templates/BatchFormTemplate.js";import{createBatchFormTemplate as H}from"./templates/support/createBatchFormTemplate.js";let V=class extends i.EventedAccessor{constructor(e){super(e),this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.features=new r,this.map=null,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this._arcadeExecutorProvider=new g,this._activeFormInputsByElementId=new Map,this._emptyForm=new E({inputs:[]}),this._emptyFormTemplate=new k({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new p,this._updatingHandles=new f,this._layerTemplateMap=new p,this._workingFeatures=new r,this._expressionsManager=new y({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:_}}),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.addHandles([l((()=>this.features),"after-changes",(()=>this._prepare()),{sync:!0}),u((()=>[this.features,this.map,this.timeZone,this.editType]),(()=>{this._prepare()}),m),u((()=>this.activeForm),(()=>this._activeFormInputsByElementId.clear()),m)]),this._prepare()}destroy(){this._prepareTask=o(this._prepareTask),this._workingFeatures.destroyAll(),this._expressionsManager&&this._expressionsManager.abort(),this._reactiveGraphicLookup=new p,this._emptyForm.destroy(),this._emptyFormTemplate.destroy()}get _effectiveTimeZone(){return this.timeZone??"system"}get activeFeature(){const e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;const t=this._featureFormMap.get(e);if(t)return t;const r=this._makeBatchFormInputsForFeature(e);return r!==this._emptyForm&&this._featureFormMap.set(e,r),r}get calculating(){return this._expressionsManager.calculating}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:e}=this;return this.invalidFeatures.some((t=>t!==e))}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get visibleInputs(){return this.activeForm.inputs.filter((e=>e.visible))}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return b.noElements;const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case x.HIDDEN_NOT_IN_ALL_LAYERS:case x.HIDDEN_NO_DOMAIN_IN_COMMON:e.add(b.noElementsInCommon);break;case x.HIDDEN_FIELD_DEFINITION:case x.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL:case x.HIDDEN_VISIBILITY_EXPRESSION_ALL:e.add(b.allElementsHidden);break;case x.HIDDEN_GROUP_VISIBILITY_EXPRESSION_SOME:case x.HIDDEN_VISIBILITY_EXPRESSION_SOME:return b.elementsHiddenInSome}return e.has(b.allElementsHidden)?b.allElementsHidden:b.noElementsInCommon}get status(){const e=this._prepareTask;return null==e?"not-loaded":e.finished?null!=e.error?"failed":"loaded":"loading"}get submittable(){return this.valid,!0}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid}get layers(){const e=new Set;return this.features.forEach((t=>{const r=t.sourceLayer??t.layer;e.add(r)})),Array.from(e)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){this.submitHasBeenAttempted=!0,this.emit("submit",{})}findFieldInput(e){if(null==e)return;const t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);const r=this.activeForm.allFieldInputs.find((t=>t.template.elementId===e));return void 0!==r?(t.set(e,r),r):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const e of this.visibleInputs){if(M(e)){const t=e.inputs.find((e=>!e.valid));if(t)return{input:t,groupInput:e}}if(T(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._workingFeatures.find((({original:t})=>t===e));if(!t)throw new s("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}setFieldInputValue(e,t){const r=new Set(this.invalidFeatures);e.setValueFromUser(t),this.userHasChangedValues=!0,this._trackValidityChange(r),this.emit("value-change",{features:e.features.toArray().map((e=>e.original)),fieldName:e.fieldName,name:"value-change",value:t})}setValue(e,t){const r=this.findFieldInput(e);if(null==r)throw new s("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);this.setFieldInputValue(r,t)}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}async _trackValidityChange(e){await h((()=>!1===this.calculating));const t=this.invalidFeatures;for(const r of t)!1===e.has(r)&&this._reactiveGraphicLookup.has(r)&&(this._reactiveGraphicLookup.get(r).userChangesHaveMadeInvalid=!0)}validate(){return!1}getCodedValueOptions(e){return e.codedValues.map((({name:e,code:t})=>({name:e,value:t})))}_makeBatchFormInputsForFeature(e){const t=this._layerTemplateMap.get(e.layer);return t?w(t,new r([e]),this._expressionsManager):this._emptyForm}async _prepare(){this._prepareTask=o(this._prepareTask),this._updateWorkingFeatures(),o(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new y({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??v.WebMercator,map:this.map,timeZone:this._effectiveTimeZone}});const{layers:e}=this;if(0===e.length)return;const r=t((async t=>{try{n(t);const r=new Map;for(const t of e){const e=await H(t,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this._effectiveTimeZone});this._layerTemplateMap.set(t,e),this._expressionsManager.layerExpressionsModelMap.set(t,new I({preserveFieldValuesWhenHidden:e.preserveFieldValuesWhenHidden,executorMap:e.getExpressionExecutorsForLayer(t)}));for(const t of e.elements){const{elementId:e}=t;r.has(e)?r.get(e).foldIn(t):r.set(e,t.clone())}}const s=new k({elements:Array.from(r.values())});this.sharedFormTemplate=s,this.sharedForm=w(s,this._workingFeatures,this._expressionsManager),await this._expressionsManager.runAllExpressions(this._workingFeatures)}catch(r){throw a.getLogger(this).error("Failed preparing form",r),r}}));this._updatingHandles.addPromise(r.promise),this._prepareTask=r}_updateWorkingFeatures(){this._workingFeatures.destroyAll();const{features:e}=this;if(this._reactiveGraphicLookup=new p,0!==e.length){this._workingFeatures.addMany(e.map(F));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.original,e)}}};e([d()],V.prototype,"_effectiveTimeZone",null),e([d({readOnly:!0})],V.prototype,"activeFeature",null),e([d()],V.prototype,"activeFeatureIndex",void 0),e([d({readOnly:!0})],V.prototype,"activeForm",null),e([d()],V.prototype,"disabled",void 0),e([d()],V.prototype,"calculating",null),e([d()],V.prototype,"editType",void 0),e([d()],V.prototype,"features",void 0),e([d()],V.prototype,"expressionEvaluationFailed",null),e([d()],V.prototype,"hasNonActiveInvalidFeatures",null),e([d()],V.prototype,"invalidFeatures",null),e([d()],V.prototype,"hasVisibleInputs",null),e([d()],V.prototype,"visibleInputs",null),e([d()],V.prototype,"map",void 0),e([d()],V.prototype,"noVisibleElementsReason",null),e([d()],V.prototype,"spatialReference",void 0),e([d()],V.prototype,"submitHasBeenAttempted",void 0),e([d()],V.prototype,"timeZone",void 0),e([d()],V.prototype,"updating",null),e([d()],V.prototype,"valid",null),e([d()],V.prototype,"layers",null),e([d()],V.prototype,"mode",null),e([d()],V.prototype,"sharedForm",void 0),e([d()],V.prototype,"sharedFormTemplate",void 0),e([d()],V.prototype,"userHasChangedValues",void 0),e([d()],V.prototype,"_arcadeExecutorProvider",void 0),e([d()],V.prototype,"_prepareTask",void 0),e([d()],V.prototype,"_reactiveGraphicLookup",void 0),e([d()],V.prototype,"_layerTemplateMap",void 0),e([d()],V.prototype,"_workingFeatures",void 0),e([d()],V.prototype,"_expressionsManager",void 0),V=e([c("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],V);const j=V;export{j as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{createTask as t}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import a from"../../core/Logger.js";import{abortMaybe as o}from"../../core/maybe.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{on as l,watch as u,whenOnce as h,sync as m}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import _ from"../../geometry/SpatialReference.js";import{system as g}from"../../time/timeZoneUtils.js";import{createReactiveGraphic as v}from"./batchAttributeFormUtils.js";import{ArcadeExecutorProvider as F}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as y}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as I}from"./expressions/ExpressionsModel.js";import{BatchFormInputs as E}from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as w}from"./inputs/support/createBatchFormInputs.js";import{NoVisibleElementCodes as M,InputVisibilityCode as b,isGroupInput as x,isFieldInput as T}from"./inputs/support/inputUtils.js";import k from"./templates/BatchFormTemplate.js";import{getLayerContingentValuesMetaData as V}from"./templates/support/contingentValuesUtils.js";import{createBatchFormTemplate as H}from"./templates/support/createBatchFormTemplate.js";let j=class extends i.EventedAccessor{constructor(e){super(e),this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.features=new s,this.map=null,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this._arcadeExecutorProvider=new F,this._activeFormInputsByElementId=new Map,this._emptyForm=new E({inputs:[]}),this._emptyFormTemplate=new k({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new p,this._updatingHandles=new f,this._layerTemplateMap=new p,this._layerContingentValuesMap=new p,this._workingFeatures=new s,this._expressionsManager=new y({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:g}}),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.addHandles([l((()=>this.features),"after-changes",(()=>this._prepare()),{sync:!0}),u((()=>[this.features,this.map,this.timeZone,this.editType]),(()=>{this._prepare()}),m),u((()=>this.activeForm),(()=>this._activeFormInputsByElementId.clear()),m)]),this._prepare()}destroy(){this._prepareTask=o(this._prepareTask),this._workingFeatures.destroyAll(),this._expressionsManager&&this._expressionsManager.abort(),this._reactiveGraphicLookup=new p,this._emptyForm.destroy(),this._emptyFormTemplate.destroy()}get _effectiveTimeZone(){return this.timeZone??"system"}get activeFeature(){const e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;const t=this._featureFormMap.get(e);if(t)return t;const s=this._makeBatchFormInputsForFeature(e);return s!==this._emptyForm&&this._featureFormMap.set(e,s),s}get calculating(){return this._expressionsManager.calculating}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:e}=this;return this.invalidFeatures.some((t=>t!==e))}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){for(const e of this.layers){const t=this._layerContingentValuesMap.get(e);if(t&&t.size>0)return!0}return!1}get visibleInputs(){return this.activeForm.inputs.filter((e=>e.visible))}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return M.noElements;const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case b.HIDDEN_NOT_IN_ALL_LAYERS:case b.HIDDEN_NO_DOMAIN_IN_COMMON:e.add(M.noElementsInCommon);break;case b.HIDDEN_FIELD_DEFINITION:case b.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL:case b.HIDDEN_VISIBILITY_EXPRESSION_ALL:e.add(M.allElementsHidden);break;case b.HIDDEN_GROUP_VISIBILITY_EXPRESSION_SOME:case b.HIDDEN_VISIBILITY_EXPRESSION_SOME:return M.elementsHiddenInSome}return e.has(M.allElementsHidden)?M.allElementsHidden:M.noElementsInCommon}get status(){const e=this._prepareTask;return null==e?"not-loaded":e.finished?null!=e.error?"failed":"loaded":"loading"}get submittable(){return this.valid,!0}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid}get layers(){const e=new Set;return this.features.forEach((t=>{const s=t.sourceLayer??t.layer;e.add(s)})),Array.from(e)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){this.submitHasBeenAttempted=!0,this.emit("submit",{})}findFieldInput(e){if(null==e)return;const t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);const s=this.activeForm.allFieldInputs.find((t=>t.template.elementId===e));return void 0!==s?(t.set(e,s),s):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const e of this.visibleInputs){if(x(e)){const t=e.inputs.find((e=>!e.valid));if(t)return{input:t,groupInput:e}}if(T(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._workingFeatures.find((({original:t})=>t===e));if(!t)throw new r("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}setFieldInputValue(e,t){const s=new Set(this.invalidFeatures);e.setValueFromUser(t),this.userHasChangedValues=!0,this._trackValidityChange(s),this.emit("value-change",{features:e.features.toArray().map((e=>e.original)),fieldName:e.fieldName,name:"value-change",value:t})}setValue(e,t){const s=this.findFieldInput(e);if(null==s)throw new r("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);this.setFieldInputValue(s,t)}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}async _trackValidityChange(e){await h((()=>!1===this.calculating));const t=this.invalidFeatures;for(const s of t)!1===e.has(s)&&this._reactiveGraphicLookup.has(s)&&(this._reactiveGraphicLookup.get(s).userChangesHaveMadeInvalid=!0)}validate(){return!1}_makeBatchFormInputsForFeature(e){const t=this._layerTemplateMap.get(e.layer);return t?w(t,new s([e]),this._expressionsManager):this._emptyForm}async _prepare(){this._prepareTask=o(this._prepareTask),this._updateWorkingFeatures(),o(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new y({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??_.WebMercator,map:this.map,timeZone:this._effectiveTimeZone}});const{layers:e}=this;if(0===e.length)return;const s=t((async t=>{try{n(t);const s=new Map;for(const t of e){const e=await V(t);if(e){const s=e.fieldGroups.flatMap((e=>e.fields));this._layerContingentValuesMap.set(t,new Set(s))}else this._layerContingentValuesMap.set(t,new Set);const r=await H(t,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this._effectiveTimeZone});this._layerTemplateMap.set(t,r),this._expressionsManager.layerExpressionsModelMap.set(t,new I({preserveFieldValuesWhenHidden:r.preserveFieldValuesWhenHidden,executorMap:r.getExpressionExecutorsForLayer(t)}));for(const t of r.elements){const{elementId:e}=t;s.has(e)?s.get(e).foldIn(t):s.set(e,t.clone())}}const r=new k({elements:Array.from(s.values())});this.sharedFormTemplate=r,this.sharedForm=w(r,this._workingFeatures,this._expressionsManager),await this._expressionsManager.runAllExpressions(this._workingFeatures)}catch(s){throw a.getLogger(this).error("Failed preparing form",s),s}}));this._updatingHandles.addPromise(s.promise),this._prepareTask=s}_updateWorkingFeatures(){this._workingFeatures.destroyAll();const{features:e}=this;if(this._reactiveGraphicLookup=new p,0!==e.length){this._workingFeatures.addMany(e.map(v));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.original,e)}}};e([d()],j.prototype,"_effectiveTimeZone",null),e([d({readOnly:!0})],j.prototype,"activeFeature",null),e([d()],j.prototype,"activeFeatureIndex",void 0),e([d({readOnly:!0})],j.prototype,"activeForm",null),e([d()],j.prototype,"disabled",void 0),e([d()],j.prototype,"calculating",null),e([d()],j.prototype,"editType",void 0),e([d()],j.prototype,"features",void 0),e([d()],j.prototype,"expressionEvaluationFailed",null),e([d()],j.prototype,"hasNonActiveInvalidFeatures",null),e([d()],j.prototype,"invalidFeatures",null),e([d()],j.prototype,"hasVisibleInputs",null),e([d()],j.prototype,"hasLayersWithContingentValues",null),e([d()],j.prototype,"visibleInputs",null),e([d()],j.prototype,"map",void 0),e([d()],j.prototype,"noVisibleElementsReason",null),e([d()],j.prototype,"spatialReference",void 0),e([d()],j.prototype,"submitHasBeenAttempted",void 0),e([d()],j.prototype,"timeZone",void 0),e([d()],j.prototype,"updating",null),e([d()],j.prototype,"valid",null),e([d()],j.prototype,"layers",null),e([d()],j.prototype,"mode",null),e([d()],j.prototype,"sharedForm",void 0),e([d()],j.prototype,"sharedFormTemplate",void 0),e([d()],j.prototype,"userHasChangedValues",void 0),e([d()],j.prototype,"_arcadeExecutorProvider",void 0),e([d()],j.prototype,"_prepareTask",void 0),e([d()],j.prototype,"_reactiveGraphicLookup",void 0),e([d()],j.prototype,"_layerTemplateMap",void 0),e([d()],j.prototype,"_layerContingentValuesMap",void 0),e([d()],j.prototype,"_workingFeatures",void 0),e([d()],j.prototype,"_expressionsManager",void 0),j=e([c("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],j);const L=j;export{L as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{isSome as t}from"../../../core/arrayUtils.js";import i from"../../../core/Collection.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{CodedValue as a}from"../../../layers/support/CodedValue.js";import s from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import l from"../../../layers/support/RangeDomain.js";import{getDomainRange as o,dateTimeFieldValuesToNumericRange as u,isDomainValidForField as p}from"../../../layers/support/domainUtils.js";import{isNumericField as m,isStringField as d,isTimeOnlyField as f,getFieldRange as h,isDateOnlyField as c,isTimestampOffsetField as g}from"../../../layers/support/fieldUtils.js";import{isAnyDateField as y}from"../../../smartMapping/support/utils.js";import{isNumber as _}from"../../../support/guards.js";import{EditableInput as x}from"./EditableInput.js";import{MultiFeatureError as b,visibilityCodeToBoolean as V,InputVisibilityCode as E,isFieldInputWithShowNoValueOptionInput as v,differentValuesString as D}from"./support/inputUtils.js";import{FieldInputDataTypes as F,getMaxLength as I,getMinLength as M,isEmptyValue as N,dateIsValid as w,validateFormValue as R}from"../../support/forms/formUtils.js";let S=class extends x{constructor(e){super(e),this.group=null,this.type="field",this.userHasChangedValue=!1,this._hasIntersectionWithElementFieldDomain=!1}get compositeError(){if(this.valid)return null;const{errors:e}=this;if(e.length<this.features.length)return b.DIFFERENT_ERRORS;const t=e[0];for(const i of e)if(i.error!==t.error)return b.DIFFERENT_ERRORS;return t.error}get dataType(){const{field:e}=this;return m(e)?F.Number:d(e)?F.Text:y(e)||f(e)?F.Date:F.Unsupported}get domain(){const e=this._allDomains.toArray();return this.calculateDomain(e)}get distinctValues(){if(this.featuresHaveSameValue)return[this.value];const e=new Set;for(const t of this.features)e.add(t.getAttribute(this.fieldName));return Array.from(e)}get editable(){return!!this.field.editable&&(this._evaluatedEditableExpression??!0)}get effectiveVisible(){return V(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){const{visibilityCode:e}=this;if(e!==E.VISIBLE)return e;const{group:t}=this;if(null==t)return e;const i=t.visibilityCode;return i===E.HIDDEN_VISIBILITY_EXPRESSION_ALL?E.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL:i===E.HIDDEN_VISIBILITY_EXPRESSION_SOME?E.HIDDEN_GROUP_VISIBILITY_EXPRESSION_SOME:e}get errors(){return this._validate()}get featuresHaveSameValue(){const{fieldName:e}=this,t=this.features.at(0)?.getAttribute(e);return this.features.every((i=>i.getAttribute(e)===t))}get field(){return this.template.field}get fieldName(){return this.field.name}get invalidFeatures(){return this.errors.map((e=>e.feature))}get isSubtypeField(){return this.layers.some((e=>{if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}))}get showNoValueOptionEnabled(){const{input:e}=this.template;return!this.required&&(!v(e)||!0===e?.showNoValueOption)}get showNoValueLabel(){const{input:e}=this.template;return v(e)?e?.noValueOptionLabel:null}get includeTime(){const{template:e,field:t}=this;return this.dataType===F.Date&&("time-only"===t.type||"date-only"!==t.type&&("datetime-picker"!==e.input?.type||e.input.includeTime))}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.template.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}get maxLength(){return I({dataType:this.dataType,field:this.field,input:this.template.input})}get minLength(){return M({dataType:this.dataType,field:this.field,input:this.template.input})}get range(){if("date"===this.dataType)return this._dateRange;const{domain:e,field:t}=this;if(e){const i=o(t,e);return{max:i?.max,min:i?.min}}const i=this._allDomains.toArray().every((e=>!e))?h(t):null;return{max:i?.max===Number.MAX_VALUE?null:i?.max??null,min:i?.min===-Number.MAX_VALUE?null:i?.min??null}}get required(){if(!this.editable)return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const e=this.visible&&!1!==this.group?.visible,t=this._evaluatedRequiredExpression;return!(!e||null==t)&&t}get submittable(){return(!this.required||!this.distinctValues.some((e=>N(e))))&&!!this.valid}get valid(){return 0===this.errors.length}get value(){return this.featuresHaveSameValue?this.features.at(0)?.getAttribute(this.fieldName)??null:D}get visibilityCode(){return this.field.visible?this._fieldShouldHaveDomain&&null==this.domain?E.HIDDEN_NO_DOMAIN_IN_COMMON:this._baseVisibilityCode:E.HIDDEN_FIELD_DEFINITION}get _evaluatedRequiredExpression(){let e=!1,t=!0;const i=this.template;for(const r of this.features){if(null==i.getExpressionExecutorsForLayer(r.layer)?.requiredExpression)continue;t=!1;const n=this._lookupEvaluatedExpression(r,"required");"success"===n?.status?e=e||!0===n.result:e=!0}return t?null:e}get _allDomains(){const e=this.template.domain;return this.features.map((t=>{const i=t.layer.getFieldDomain(this.fieldName,{feature:t.plainGraphic});return"range"===i?.type||"range"===e?.type?i??this.template.domain:i}))}get _fieldShouldHaveDomain(){return!!this._hasIntersectionWithElementFieldDomain||this._allDomains.some(t)}get _dateFormRange(){if("date"!==this.dataType)return{};const e=this.template.input;if(!e)return{};const{type:t}=e;let i={};if("date-picker"!==t&&"time-picker"!==t&&"datetimeoffset-picker"!==t||(i=u(this.field,e.max,e.min)),"datetime-picker"===t){const{max:t,min:r}=e;i={max:null!=t&&w(t)?t.getTime():null,min:null!=r&&w(r)?r.getTime():null}}return{min:i.min,max:i.max,rawMax:i?.rawMax??null,rawMin:i?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,template:t,field:i,domain:r}=this;if("date"!==this.dataType)return{};if(!r)return this._fieldShouldHaveDomain?{}:e;const n=o(i,r);if(!n)return e;const{max:a,min:s,rawMax:l,rawMin:u}=e,{type:p}=t.field;if("date"===p){const{max:e,min:t}=n;return{max:_(a)&&(null===e||null!=e&&a<=e)?a:e??null,min:_(s)&&(null===t||null!=t&&s>=t)?s:t??null}}if("date-only"===p||"time-only"===p||"timestamp-offset"===p){const{max:e,min:t,rawMax:i,rawMin:r}=n,o=_(a)&&l&&(null==e||a<e),p=_(s)&&u&&(null==t||s>t);return{max:o?a:e,min:p?s:t,rawMax:o?l:i,rawMin:p?u:r}}return{}}async setValueFromUser(e){this.userHasChangedValue=!0;const t=new i,r=this.fieldName;for(const i of this.features)i.getAttribute(r)!==e&&t.push(i);this._setValue(e),await this.expressionsManager.valueChanged(r,t)}_setValue(e){const{fieldName:t}=this;for(const i of this.features)i.setAttribute(t,e)}_validate(){const{dataType:e,fieldName:t,maxLength:i,minLength:r,range:n}=this,a=[];for(const s of this.features){const{layer:l}=s,o=l.getField(t)??this.field,u=l.getFieldDomain(t,{feature:s.plainGraphic}),p=this.calculateDomain([u]),m=this._requiredForFeature(s),d=s.getAttribute(t),f=R(d,{dataType:e,domain:p,field:o,maxLength:i,minLength:r,range:n,required:m});f&&a.push({error:f,feature:s.original})}return a}_editableForFeature(e){if(!this.field.editable)return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.editableExpression)return!0;const t=this._lookupEvaluatedExpression(e,"editable");return"success"===t?.status&&!0===t.result}_effectiveVisibleFeature(e){if(this.group&&!this.group.visibleForFeature(e))return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.visibilityExpression)return!0;const t=this._lookupEvaluatedExpression(e,"visibility");return"success"===t?.status&&!0===t.result}_requiredForFeature(e){if(!this._editableForFeature(e))return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const t=this._effectiveVisibleFeature(e);if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.requiredExpression)return!1;const i=this._lookupEvaluatedExpression(e,"required");return"success"!==i?.status?t:t&&!0===i.result}calculateDomain(e){const t=e.find((e=>null!=e)),i=this.template.domain;if(!t)return i&&p(this.field,i)?i:null;switch(t.type){case"coded-value":if(e.some((e=>!e))){if(!i)return null;e=e.filter((e=>null!==e))}break;case"range":e=e.filter((e=>null!==e))}if(!e.every((e=>e?.type===t?.type)))return null;let r=null;switch(t?.type){case"range":r=this._intersectRangeDomains(e);break;case"coded-value":r=this._intersectCodedValueDomains(e)}return r}_intersectCodedValueDomains(e){if(!e.length)return null;const t=new Map(e[0].codedValues.map((({code:e,name:t})=>[e,t]))),i=this.template.domain?new Map(this.template.domain.codedValues.map((({code:e,name:t})=>[e,t]))):null;for(const a of e)for(const[e,i]of t){a.codedValues.some((t=>t.code===e&&t.name===i))||t.delete(e)}let r=t;if(i){r=new Map;for(const[e,n]of i)t.has(e)&&r.set(e,n)}const n=Array.from(r.entries()).map((([e,t])=>new a({code:e,name:t})));return n.length?new s({codedValues:n}):null}_intersectRangeDomains(e){if(!e.length)return null;let t=e[0];if(e.length>1&&(t=e.reduce(((e,t)=>{const i=this._findMinMaxValuesBetweenTwoDomains(e,t);return i||null}),t)),t&&!p(this.field,t))return null;const{domain:i}=this.template;if(t&&i&&i instanceof l){const e=this._findMinMaxValuesBetweenTwoDomains(t,i);return this._hasIntersectionWithElementFieldDomain=!!e,e}return t}_getMinMaxFromRangeDomain(e){const t=e.minValue,i=e.maxValue,{field:r}=this;return c(r)||f(r)||g(r)?u(r,i,t):{min:null!=t&&"number"==typeof t?t:null,max:null!=i&&"number"==typeof i?i:null}}_findMinMaxValuesBetweenTwoDomains(e,t){const i=new l,r=this._getMinMaxFromRangeDomain(e),n=this._getMinMaxFromRangeDomain(t),{field:a}=this,s=this._getValidRangeValue(r.min,-1/0),o=this._getValidRangeValue(r.max,1/0),u=this._getValidRangeValue(n.min,-1/0),p=this._getValidRangeValue(n.max,1/0);return i.minValue=Math.max(s,u),i.maxValue=Math.min(o,p),i.minValue===-1/0||i.maxValue===1/0||i.minValue>i.maxValue?null:((c(a)||f(a)||g(a))&&(i.minValue=Number(r.min)>Number(n.min)?r.rawMin:n.rawMin,i.maxValue=Number(r.max)<Number(n.max)?r.rawMax:n.rawMax),i.name="intersection",i)}_getValidRangeValue(e,t){return _(e)?e:t}};e([r()],S.prototype,"dataType",null),e([r()],S.prototype,"domain",null),e([r()],S.prototype,"distinctValues",null),e([r()],S.prototype,"editable",null),e([r()],S.prototype,"effectiveVisible",null),e([r()],S.prototype,"effectiveVisibilityCode",null),e([r()],S.prototype,"errors",null),e([r()],S.prototype,"featuresHaveSameValue",null),e([r()],S.prototype,"field",null),e([r()],S.prototype,"fieldName",null),e([r()],S.prototype,"group",void 0),e([r()],S.prototype,"invalidFeatures",null),e([r()],S.prototype,"isSubtypeField",null),e([r()],S.prototype,"showNoValueOptionEnabled",null),e([r()],S.prototype,"includeTime",null),e([r()],S.prototype,"includeTimeOffset",null),e([r()],S.prototype,"maxLength",null),e([r()],S.prototype,"minLength",null),e([r()],S.prototype,"range",null),e([r()],S.prototype,"required",null),e([r()],S.prototype,"submittable",null),e([r({readOnly:!0})],S.prototype,"type",void 0),e([r()],S.prototype,"userHasChangedValue",void 0),e([r()],S.prototype,"valid",null),e([r()],S.prototype,"value",null),e([r()],S.prototype,"visibilityCode",null),e([r()],S.prototype,"_evaluatedRequiredExpression",null),e([r()],S.prototype,"_hasIntersectionWithElementFieldDomain",void 0),e([r()],S.prototype,"_allDomains",null),e([r()],S.prototype,"_fieldShouldHaveDomain",null),e([r()],S.prototype,"_dateFormRange",null),e([r()],S.prototype,"_dateRange",null),S=e([n("esri.widgets.BatchAttributeForm.inputs.FieldInput")],S);export{S as FieldInput};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{isSome as t}from"../../../core/arrayUtils.js";import i from"../../../core/Collection.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{CodedValue as a}from"../../../layers/support/CodedValue.js";import s from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import l from"../../../layers/support/RangeDomain.js";import{getDomainRange as o,dateTimeFieldValuesToNumericRange as u,isDomainValidForField as m}from"../../../layers/support/domainUtils.js";import{isNumericField as p,isStringField as d,isTimeOnlyField as f,getFieldRange as h,isDateOnlyField as c,isTimestampOffsetField as y}from"../../../layers/support/fieldUtils.js";import{isAnyDateField as g}from"../../../smartMapping/support/utils.js";import{isNumber as _}from"../../../support/guards.js";import{unknown as x,utc as V}from"../../../time/timeZoneUtils.js";import{EditableInput as b}from"./EditableInput.js";import{MultiFeatureError as v,visibilityCodeToBoolean as E,InputVisibilityCode as D,isFieldInputWithShowNoValueOptionInput as F,differentValuesString as I}from"./support/inputUtils.js";import{FieldInputDataTypes as M,getMaxLength as N,getMinLength as T,isEmptyValue as w,dateIsValid as R,validateFormValue as S}from"../../support/forms/formUtils.js";let L=class extends b{constructor(e){super(e),this.group=null,this.type="field",this.userHasChangedValue=!1,this._hasIntersectionWithElementFieldDomain=!1}get compositeError(){if(this.valid)return null;const{errors:e}=this;if(e.length<this.features.length)return v.DIFFERENT_ERRORS;const t=e[0];for(const i of e)if(i.error!==t.error)return v.DIFFERENT_ERRORS;return t.error}get dataType(){const{field:e}=this;return p(e)?M.Number:d(e)?M.Text:g(e)||f(e)?M.Date:M.Unsupported}get domain(){const e=this._allDomains.toArray();return this.calculateDomain(e)}get distinctValues(){if(this.featuresHaveSameValue)return[this.value];const e=new Set;for(const t of this.features)e.add(t.getAttribute(this.fieldName));return Array.from(e)}get editable(){return!!this.field.editable&&(this._evaluatedEditableExpression??!0)}get effectiveVisible(){return E(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){const{visibilityCode:e}=this;if(e!==D.VISIBLE)return e;const{group:t}=this;if(null==t)return e;const i=t.visibilityCode;return i===D.HIDDEN_VISIBILITY_EXPRESSION_ALL?D.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL:i===D.HIDDEN_VISIBILITY_EXPRESSION_SOME?D.HIDDEN_GROUP_VISIBILITY_EXPRESSION_SOME:e}get errors(){return this._validate()}get featuresHaveSameValue(){const{fieldName:e}=this,t=this.features.at(0)?.getAttribute(e);return this.features.every((i=>i.getAttribute(e)===t))}get field(){return this.template.field}get fieldName(){return this.field.name}get invalidFeatures(){return this.errors.map((e=>e.feature))}get isSubtypeField(){return this.layers.some((e=>{if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}))}get showNoValueOptionEnabled(){const{input:e}=this.template;return!this.required&&(!F(e)||!0===e?.showNoValueOption)}get showNoValueLabel(){const{input:e}=this.template;return F(e)?e?.noValueOptionLabel:null}get includeTime(){const{template:e,field:t}=this;return this.dataType===M.Date&&("time-only"===t.type||"date-only"!==t.type&&("datetime-picker"!==e.input?.type||e.input.includeTime))}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.template.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}get maxLength(){return N({dataType:this.dataType,field:this.field,input:this.template.input})}get minLength(){return T({dataType:this.dataType,field:this.field,input:this.template.input})}get range(){if("date"===this.dataType)return this._dateRange;const{domain:e,field:t}=this;if(e){const i=o(t,e);return{max:i?.max,min:i?.min}}const i=this._allDomains.toArray().every((e=>!e))?h(t):null;return{max:i?.max===Number.MAX_VALUE?null:i?.max??null,min:i?.min===-Number.MAX_VALUE?null:i?.min??null}}get required(){if(!this.editable)return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const e=this.visible&&!1!==this.group?.visible,t=this._evaluatedRequiredExpression;return!(!e||null==t)&&t}get submittable(){return(!this.required||!this.distinctValues.some((e=>w(e))))&&!!this.valid}get valid(){return 0===this.errors.length}get value(){return this.featuresHaveSameValue?this.features.at(0)?.getAttribute(this.fieldName)??null:I}get visibilityCode(){return this.field.visible?this._fieldShouldHaveDomain&&null==this.domain?D.HIDDEN_NO_DOMAIN_IN_COMMON:this._baseVisibilityCode:D.HIDDEN_FIELD_DEFINITION}get effectiveTimeZone(){const e=this.template;let t=e.formTimeZone??"system";return e.layerTimeZone?e.layerTimeZone===x?t=V:e.formTimeZone===x&&(t=e.layerTimeZone):e.formTimeZone===x&&(t=V),t}get codedValueDomainOptions(){return"coded-value"===this.domain?.type?this.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[]}get codedValueOptions(){const e=this.codedValueDomainOptions,{value:t}=this,i=null==t||t===I||e.some((e=>e.value===t))?[]:[{name:`${t}`,value:t}];return[e,i]}get _evaluatedRequiredExpression(){let e=!1,t=!0;const i=this.template;for(const r of this.features){if(null==i.getExpressionExecutorsForLayer(r.layer)?.requiredExpression)continue;t=!1;const n=this._lookupEvaluatedExpression(r,"required");"success"===n?.status?e=e||!0===n.result:e=!0}return t?null:e}get _allDomains(){const e=this.template.domain;return this.features.map((t=>{const i=t.layer.getFieldDomain(this.fieldName,{feature:t.plainGraphic});return"range"===i?.type||"range"===e?.type?i??this.template.domain:i}))}get _fieldShouldHaveDomain(){return!!this._hasIntersectionWithElementFieldDomain||this._allDomains.some(t)}get _dateFormRange(){if("date"!==this.dataType)return{};const e=this.template.input;if(!e)return{};const{type:t}=e;let i={};if("date-picker"!==t&&"time-picker"!==t&&"datetimeoffset-picker"!==t||(i=u(this.field,e.max,e.min)),"datetime-picker"===t){const{max:t,min:r}=e;i={max:null!=t&&R(t)?t.getTime():null,min:null!=r&&R(r)?r.getTime():null}}return{min:i.min,max:i.max,rawMax:i?.rawMax??null,rawMin:i?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,template:t,field:i,domain:r}=this;if("date"!==this.dataType)return{};if(!r)return this._fieldShouldHaveDomain?{}:e;const n=o(i,r);if(!n)return e;const{max:a,min:s,rawMax:l,rawMin:u}=e,{type:m}=t.field;if("date"===m){const{max:e,min:t}=n;return{max:_(a)&&(null===e||null!=e&&a<=e)?a:e??null,min:_(s)&&(null===t||null!=t&&s>=t)?s:t??null}}if("date-only"===m||"time-only"===m||"timestamp-offset"===m){const{max:e,min:t,rawMax:i,rawMin:r}=n,o=_(a)&&l&&(null==e||a<e),m=_(s)&&u&&(null==t||s>t);return{max:o?a:e,min:m?s:t,rawMax:o?l:i,rawMin:m?u:r}}return{}}async setValueFromUser(e){this.userHasChangedValue=!0;const t=new i,r=this.fieldName;for(const i of this.features)i.getAttribute(r)!==e&&t.push(i);this._setValue(e),await this.expressionsManager.valueChanged(r,t)}_setValue(e){const{fieldName:t}=this;for(const i of this.features)i.setAttribute(t,e)}_validate(){const{dataType:e,fieldName:t,maxLength:i,minLength:r,range:n}=this,a=[];for(const s of this.features){const{layer:l}=s,o=l.getField(t)??this.field,u=l.getFieldDomain(t,{feature:s.plainGraphic}),m=this.calculateDomain([u]),p=this._requiredForFeature(s),d=s.getAttribute(t),f=S(d,{dataType:e,domain:m,field:o,maxLength:i,minLength:r,range:n,required:p});f&&a.push({error:f,feature:s.original})}return a}_editableForFeature(e){if(!this.field.editable)return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.editableExpression)return!0;const t=this._lookupEvaluatedExpression(e,"editable");return"success"===t?.status&&!0===t.result}_effectiveVisibleFeature(e){if(this.group&&!this.group.visibleForFeature(e))return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.visibilityExpression)return!0;const t=this._lookupEvaluatedExpression(e,"visibility");return"success"===t?.status&&!0===t.result}_requiredForFeature(e){if(!this._editableForFeature(e))return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const t=this._effectiveVisibleFeature(e);if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.requiredExpression)return!1;const i=this._lookupEvaluatedExpression(e,"required");return"success"!==i?.status?t:t&&!0===i.result}calculateDomain(e){const t=e.find((e=>null!=e)),i=this.template.domain;if(!t)return i&&m(this.field,i)?i:null;switch(t.type){case"coded-value":if(e.some((e=>!e))){if(!i)return null;e=e.filter((e=>null!==e))}break;case"range":e=e.filter((e=>null!==e))}if(!e.every((e=>e?.type===t?.type)))return null;let r=null;switch(t?.type){case"range":r=this._intersectRangeDomains(e);break;case"coded-value":r=this._intersectCodedValueDomains(e)}return r}_intersectCodedValueDomains(e){if(!e.length)return null;const t=new Map(e[0].codedValues.map((({code:e,name:t})=>[e,t]))),i=this.template.domain?new Map(this.template.domain.codedValues.map((({code:e,name:t})=>[e,t]))):null;for(const a of e)for(const[e,i]of t){a.codedValues.some((t=>t.code===e&&t.name===i))||t.delete(e)}let r=t;if(i){r=new Map;for(const[e,n]of i)t.has(e)&&r.set(e,n)}const n=Array.from(r.entries()).map((([e,t])=>new a({code:e,name:t})));return n.length?new s({codedValues:n}):null}_intersectRangeDomains(e){if(!e.length)return null;let t=e[0];if(e.length>1&&(t=e.reduce(((e,t)=>{const i=this._findMinMaxValuesBetweenTwoDomains(e,t);return i||null}),t)),t&&!m(this.field,t))return null;const{domain:i}=this.template;if(t&&i&&i instanceof l){const e=this._findMinMaxValuesBetweenTwoDomains(t,i);return this._hasIntersectionWithElementFieldDomain=!!e,e}return t}_getMinMaxFromRangeDomain(e){const t=e.minValue,i=e.maxValue,{field:r}=this;return c(r)||f(r)||y(r)?u(r,i,t):{min:null!=t&&"number"==typeof t?t:null,max:null!=i&&"number"==typeof i?i:null}}_findMinMaxValuesBetweenTwoDomains(e,t){const i=new l,r=this._getMinMaxFromRangeDomain(e),n=this._getMinMaxFromRangeDomain(t),{field:a}=this,s=this._getValidRangeValue(r.min,-1/0),o=this._getValidRangeValue(r.max,1/0),u=this._getValidRangeValue(n.min,-1/0),m=this._getValidRangeValue(n.max,1/0);return i.minValue=Math.max(s,u),i.maxValue=Math.min(o,m),i.minValue===-1/0||i.maxValue===1/0||i.minValue>i.maxValue?null:((c(a)||f(a)||y(a))&&(i.minValue=Number(r.min)>Number(n.min)?r.rawMin:n.rawMin,i.maxValue=Number(r.max)<Number(n.max)?r.rawMax:n.rawMax),i.name="intersection",i)}_getValidRangeValue(e,t){return _(e)?e:t}};e([r()],L.prototype,"dataType",null),e([r()],L.prototype,"domain",null),e([r()],L.prototype,"distinctValues",null),e([r()],L.prototype,"editable",null),e([r()],L.prototype,"effectiveVisible",null),e([r()],L.prototype,"effectiveVisibilityCode",null),e([r()],L.prototype,"errors",null),e([r()],L.prototype,"featuresHaveSameValue",null),e([r()],L.prototype,"field",null),e([r()],L.prototype,"fieldName",null),e([r()],L.prototype,"group",void 0),e([r()],L.prototype,"invalidFeatures",null),e([r()],L.prototype,"isSubtypeField",null),e([r()],L.prototype,"showNoValueOptionEnabled",null),e([r()],L.prototype,"includeTime",null),e([r()],L.prototype,"includeTimeOffset",null),e([r()],L.prototype,"maxLength",null),e([r()],L.prototype,"minLength",null),e([r()],L.prototype,"range",null),e([r()],L.prototype,"required",null),e([r()],L.prototype,"submittable",null),e([r({readOnly:!0})],L.prototype,"type",void 0),e([r()],L.prototype,"userHasChangedValue",void 0),e([r()],L.prototype,"valid",null),e([r()],L.prototype,"value",null),e([r()],L.prototype,"visibilityCode",null),e([r()],L.prototype,"effectiveTimeZone",null),e([r()],L.prototype,"_evaluatedRequiredExpression",null),e([r()],L.prototype,"_hasIntersectionWithElementFieldDomain",void 0),e([r()],L.prototype,"_allDomains",null),e([r()],L.prototype,"_fieldShouldHaveDomain",null),e([r()],L.prototype,"_dateFormRange",null),e([r()],L.prototype,"_dateRange",null),L=e([n("esri.widgets.BatchAttributeForm.inputs.FieldInput")],L);export{L as FieldInput};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ import{getOrCreateMapValue as e}from"../../../../core/MapUtils.js";import r from"../../../../layers/support/LayerContingentValuesCache.js";import{isSubtypeSublayer as t}from"../../../../layers/support/layerUtils.js";const n=new Map;async function a(a){if(!(a=t(a)?a.parent:"feature"===a?.type?a:null))return null;const o=e(n,a,(()=>{const e=r.createLoadedLayerContingentValuesCache(a);return a.addHandles({remove(){n.delete(a)}}),e}));return await o??null}export{a as getLayerContingentValuesMetaData};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import t from"../../../../form/ExpressionInfo.js";import{isFieldElement as o,isGroupElement as n}from"../../../../form/support/formUtils.js";import{getLowerCaseEditTrackingFields as i,isFieldVisibleByDefault as s}from"../../../../layers/support/fieldUtils.js";import{isSubtypeSublayer as a,isSubtypeGroupLayer as l}from"../../../../layers/support/layerUtils.js";import{unknown as m,utc as d}from"../../../../time/timeZoneUtils.js";import{makeExpressionInfosMap as p,makeExecutorSetForFormElement as f}from"../../expressions/expressionUtils.js";import c from"../BatchFormTemplate.js";import{FieldElementTemplate as u}from"../FieldElementTemplate.js";import{GroupElementTemplate as y}from"../GroupElementTemplate.js";const w="expression/dea57012-47ca4b55a000-8df62742ed0c",x=()=>r.getLogger("esri.widgets.BatchAttributeForm.templates.templateUtils");async function b(e,r){return e.formTemplate?.elements&&e.formTemplate?.elements.length>0?E(e,r):T(e,r)}async function T(e,{arcadeExecutorProvider:r,formTimeZone:t}){const o=new Set(i(e)),n={arcadeExecutorProvider:r,editTrackingFields:o,formTimeZone:t,layer:e},s=[];for(const i of e.fields)I(i,e,o)&&s.push(g(i,n));const a=await Promise.all(s);return new c({elements:a,preserveFieldValuesWhenHidden:!0})}function h(e,r){for(const t of e??[])if("group"!==t.type){if("field"===t.type){if(!1===t.editable&&!t.editableExpression)return!0;if(r.subtypeField&&(a(r)||l(r))&&t.fieldName?.toLowerCase()===r.subtypeField.toLowerCase())return!0}}else if(h(t.elements??[],r))return!0;return!1}async function E(e,r){const o=e.formTemplate;if(!o)return T(e,r);let n=null;h(o.elements??[],e)&&(n=new t({title:"",name:w,expression:"false"}));const i=p(n?[...o.expressionInfos??[],n]:o.expressionInfos),s={description:o.description,elements:new Array,title:o.title,preserveFieldValuesWhenHidden:o.preserveFieldValuesWhenHidden},{elements:a}=o;if(!a)return new c(s);const{arcadeExecutorProvider:l,formTimeZone:m}=r;for(const t of a)try{s.elements.push(await v(t,{arcadeExecutorProvider:l,expressionInfos:i,layer:e,formTimeZone:m}))}catch(d){x().warn(d)}return new c(s)}async function v(r,t){if(o(r))return F(r,t);if(n(r))return Z(r,t);throw new e("batch-attribute-form:unsupported-element-type",`Form elements of type ${r.type} are not supported`)}async function F(r,{arcadeExecutorProvider:t,expressionInfos:o,layer:n,formTimeZone:i}){const{fieldsIndex:s}=n,{description:m,domain:d,fieldName:p,hint:c,input:y,label:x}=r;if(null==p||!s.has(p))throw new e("batch-attribute-form:invalid-form-element",`Field element with label '${x}' does not refer to a valid field`);const b={description:m,domain:d,field:s.get(p),hint:c,input:y,formTimeZone:i,layerTimeZone:L(n),label:x};!1!==r.editable||r.editableExpression||((r=r.clone()).editableExpression=w),n.subtypeField&&(a(n)||l(n))&&r.fieldName?.toLowerCase()===n.subtypeField.toLowerCase()&&((r=r.clone()).editableExpression=w);const T=new u(b),h=await f({element:r,expressionInfos:o,provider:t});return T.addLayer(n,h),T}async function Z(e,r){const{arcadeExecutorProvider:t,expressionInfos:o,layer:n}=r,{description:i,label:s,initialState:a}=e,l={description:i,elements:[],label:s,initialState:a??"expanded"};for(const p of e.elements)try{l.elements.push(await v(p,r))}catch{continue}const m=new y(l),d=await f({element:e,expressionInfos:o,provider:t});return m.addLayer(n,d),m}async function g(e,{arcadeExecutorProvider:r,layer:t,formTimeZone:o}){const n=new u({field:e,label:e.alias??e.name,formTimeZone:o,layerTimeZone:L(t)}),i={},s=(l(t)||a(t))&&t.subtypeField&&t.subtypeField.toLowerCase()===e.name.toLowerCase();return!s&&e.editable&&t.userHasUpdateItemPrivileges&&(i.editableExpression=await r.getArcadeExecutor("true")),s&&(i.editableExpression=await r.getArcadeExecutor("false")),n.addLayer(t,i),n}function I(e,r,t){return!t.has(e.name.toLowerCase())&&s(e,r)}function L(e){return a(e)&&e.parent&&(e=e.parent),e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone?m:e&&"preferredTimeZone"in e&&e.preferredTimeZone?e.preferredTimeZone:d}export{E as convertFormTemplateToBatchFormTemplate,b as createBatchFormTemplate,T as createBatchFormTemplateFromFields};
5
+ import e from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import t from"../../../../form/ExpressionInfo.js";import{isFieldElement as n,isGroupElement as o}from"../../../../form/support/formUtils.js";import{getLowerCaseEditTrackingFields as i,isFieldVisibleByDefault as s}from"../../../../layers/support/fieldUtils.js";import{isSubtypeSublayer as a,isSubtypeGroupLayer as l}from"../../../../layers/support/layerUtils.js";import{unknown as m}from"../../../../time/timeZoneUtils.js";import{makeExpressionInfosMap as d,makeExecutorSetForFormElement as p}from"../../expressions/expressionUtils.js";import f from"../BatchFormTemplate.js";import{FieldElementTemplate as c}from"../FieldElementTemplate.js";import{GroupElementTemplate as u}from"../GroupElementTemplate.js";const y="expression/dea57012-47ca4b55a000-8df62742ed0c",w=()=>r.getLogger("esri.widgets.BatchAttributeForm.templates.templateUtils");async function x(e,r){return e.formTemplate?.elements&&e.formTemplate?.elements.length>0?E(e,r):b(e,r)}async function b(e,{arcadeExecutorProvider:r,formTimeZone:t}){const n=new Set(i(e)),o={arcadeExecutorProvider:r,editTrackingFields:n,formTimeZone:t,layer:e},s=[];for(const i of e.fields)g(i,e,n)&&s.push(Z(i,o));const a=await Promise.all(s);return new f({elements:a,preserveFieldValuesWhenHidden:!0})}function T(e,r){for(const t of e??[])if("group"!==t.type){if("field"===t.type){if(!1===t.editable&&!t.editableExpression)return!0;if(r.subtypeField&&(a(r)||l(r))&&t.fieldName?.toLowerCase()===r.subtypeField.toLowerCase())return!0}}else if(T(t.elements??[],r))return!0;return!1}async function E(e,r){const n=e.formTemplate;if(!n)return b(e,r);let o=null;T(n.elements??[],e)&&(o=new t({title:"",name:y,expression:"false"}));const i=d(o?[...n.expressionInfos??[],o]:n.expressionInfos),s={description:n.description,elements:new Array,title:n.title,preserveFieldValuesWhenHidden:n.preserveFieldValuesWhenHidden},{elements:a}=n;if(!a)return new f(s);const{arcadeExecutorProvider:l,formTimeZone:m}=r;for(const t of a){const r=await h(t,{arcadeExecutorProvider:l,expressionInfos:i,layer:e,formTimeZone:m});r&&s.elements.push(r)}return new f(s)}async function h(r,t){return n(r)?v(r,t):o(r)?F(r,t):(w().warn(new e("batch-attribute-form:unsupported-element-type",`Form elements of type ${r.type} are not supported`)),null)}async function v(r,{arcadeExecutorProvider:t,expressionInfos:n,layer:o,formTimeZone:i}){const{fieldsIndex:s}=o,{description:m,domain:d,fieldName:f,hint:u,input:x,label:b}=r;if(null==f||!s.has(f))return w().warn(new e("batch-attribute-form:invalid-form-element-field",`Field element with label '${b}' does not refer to a valid field`)),null;const T={description:m,domain:d,field:s.get(f),hint:u,input:x,formTimeZone:i,layerTimeZone:I(o),label:b};!1!==r.editable||r.editableExpression||((r=r.clone()).editableExpression=y),o.subtypeField&&(a(o)||l(o))&&r.fieldName?.toLowerCase()===o.subtypeField.toLowerCase()&&((r=r.clone()).editableExpression=y);const E=new c(T),h=await p({element:r,expressionInfos:n,provider:t});return E.addLayer(o,h),E}async function F(e,r){const{arcadeExecutorProvider:t,expressionInfos:n,layer:o}=r,{description:i,label:s,initialState:a}=e,l={description:i,elements:[],label:s,initialState:a??"expanded"};for(const p of e.elements){const e=await h(p,r);e&&l.elements.push(e)}const m=new u(l),d=await p({element:e,expressionInfos:n,provider:t});return m.addLayer(o,d),m}async function Z(e,{arcadeExecutorProvider:r,layer:t,formTimeZone:n}){const o=new c({field:e,label:e.alias??e.name,formTimeZone:n,layerTimeZone:I(t)}),i={},s=(l(t)||a(t))&&t.subtypeField&&t.subtypeField.toLowerCase()===e.name.toLowerCase();return!s&&e.editable&&t.userHasUpdateItemPrivileges&&(i.editableExpression=await r.getArcadeExecutor("true")),s&&(i.editableExpression=await r.getArcadeExecutor("false")),o.addLayer(t,i),o}function g(e,r,t){return!t.has(e.name.toLowerCase())&&s(e,r)}function I(e){return a(e)&&e.parent&&(e=e.parent),e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone?m:e&&"preferredTimeZone"in e&&e.preferredTimeZone?e.preferredTimeZone:null}export{E as convertFormTemplateToBatchFormTemplate,x as createBatchFormTemplate,b as createBatchFormTemplateFromFields};