@arcgis/core 4.33.0-next.20250219 → 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 (140) 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/0c3930e40fc9f8a84599.js +2 -0
  6. package/assets/esri/core/workers/chunks/{ccee343fb8c415b59ce3.js.LICENSE.txt → 0c3930e40fc9f8a84599.js.LICENSE.txt} +1 -1
  7. package/assets/esri/core/workers/chunks/333bb93a28209c997d8b.js +314 -0
  8. package/assets/esri/core/workers/chunks/469c50c49447f0d602c0.js +1 -0
  9. package/assets/esri/core/workers/chunks/486df1e042204b90b0dd.js.LICENSE.txt +1 -1
  10. package/assets/esri/core/workers/chunks/{c2d539359f321bba3432.js → 52c13b3c074c9f6dadde.js} +2 -2
  11. package/assets/esri/core/workers/chunks/{c2d539359f321bba3432.js.LICENSE.txt → 52c13b3c074c9f6dadde.js.LICENSE.txt} +1 -1
  12. package/assets/esri/core/workers/chunks/5693d9ce4472a4c5959f.js.LICENSE.txt +1 -1
  13. package/assets/esri/core/workers/chunks/5b56b271afb0fadf48b4.js.LICENSE.txt +1 -1
  14. package/assets/esri/core/workers/chunks/6518954889df2e781c47.js.LICENSE.txt +1 -1
  15. package/assets/esri/core/workers/chunks/68322a63ec92d33701ea.js +1 -0
  16. package/assets/esri/core/workers/chunks/aacebda644be06ad1a61.js +1 -0
  17. package/assets/esri/core/workers/chunks/ac11b2168feee63d2f09.js +1 -0
  18. package/assets/esri/core/workers/chunks/b0952b81d5be214262dd.js.LICENSE.txt +1 -1
  19. package/assets/esri/core/workers/chunks/e2df18662cc4d6e47715.js +1 -0
  20. package/assets/esri/themes/base/widgets/_Editor.scss +3 -0
  21. package/assets/esri/themes/base/widgets/_ResponsiveToolbar.scss +9 -3
  22. package/assets/esri/themes/base/widgets/_Sketch.scss +32 -24
  23. package/assets/esri/themes/dark/main.css +1 -1
  24. package/assets/esri/themes/light/main.css +1 -1
  25. package/assets/esri/themes/light/view.css +1 -1
  26. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ar.json +1 -1
  27. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bg.json +1 -1
  28. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bs.json +1 -1
  29. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ca.json +1 -1
  30. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_cs.json +1 -1
  31. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_da.json +1 -1
  32. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_de.json +1 -1
  33. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_el.json +1 -1
  34. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_es.json +1 -1
  35. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_et.json +1 -1
  36. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fi.json +1 -1
  37. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fr.json +1 -1
  38. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_he.json +1 -1
  39. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hr.json +1 -1
  40. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hu.json +1 -1
  41. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_id.json +1 -1
  42. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_it.json +1 -1
  43. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ja.json +1 -1
  44. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ko.json +1 -1
  45. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lt.json +1 -1
  46. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lv.json +1 -1
  47. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_nl.json +1 -1
  48. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_no.json +1 -1
  49. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pl.json +1 -1
  50. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-BR.json +1 -1
  51. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-PT.json +1 -1
  52. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ro.json +1 -1
  53. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ru.json +1 -1
  54. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sk.json +1 -1
  55. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sl.json +1 -1
  56. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sr.json +1 -1
  57. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sv.json +1 -1
  58. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_th.json +1 -1
  59. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_tr.json +1 -1
  60. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_uk.json +1 -1
  61. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_vi.json +1 -1
  62. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-CN.json +1 -1
  63. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-HK.json +1 -1
  64. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-TW.json +1 -1
  65. package/copyright.txt +20 -0
  66. package/interfaces.d.ts +315 -71
  67. package/layers/RouteLayer.js +1 -1
  68. package/layers/support/rasterFunctionUtils.d.ts +11 -0
  69. package/networks/UtilityNetwork.js +1 -1
  70. package/package.json +2 -2
  71. package/rest/route.js +1 -1
  72. package/rest/support/RouteParameters.js +1 -1
  73. package/rest/support/RouteSolveResult.js +1 -1
  74. package/support/revision.js +1 -1
  75. package/symbols/cim/CIMEffects.js +1 -1
  76. package/symbols/cim/effects/EffectAddControlPoints.js +1 -1
  77. package/symbols/cim/effects/EffectBuffer.js +1 -1
  78. package/symbols/cim/effects/EffectDonut.js +1 -1
  79. package/symbols/cim/effects/EffectOffset.js +1 -1
  80. package/views/2d/engine/webgl/TextureManager.js +1 -1
  81. package/views/2d/engine/webgl/Utils.js +1 -1
  82. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
  83. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  84. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  85. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  86. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  87. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  88. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  89. package/views/3d/layers/I3SMeshView3D.js +1 -1
  90. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  91. package/views/3d/layers/graphics/pipeline/Tile.js +1 -1
  92. package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
  93. package/views/3d/layers/graphics/pipeline/featureData/FeatureData.js +1 -1
  94. package/views/3d/layers/graphics/pipeline/featureData/FeatureDataSubset.js +5 -0
  95. package/views/3d/layers/graphics/pipeline/featureData/processingUtils.js +1 -1
  96. package/views/3d/layers/graphics/pipeline/featureSet/PBFPointFeatureSetView.js +1 -1
  97. package/views/3d/layers/graphics/pipeline/featureSet/TiledFeatureStore.js +1 -1
  98. package/views/3d/layers/graphics/pipeline/fetching/Tile3DFetcher.js +1 -1
  99. package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
  100. package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
  101. package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
  102. package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
  103. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  104. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentBVH.js +1 -1
  105. package/views/3d/webgl-engine/collections/Component/IndexRange/ComponentRange.js +5 -0
  106. package/views/3d/webgl-engine/lib/ComponentUtils.js +1 -1
  107. package/webmap/utils.js +1 -1
  108. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  109. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  110. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  111. package/widgets/BatchAttributeForm.js +1 -1
  112. package/widgets/Directions/DirectionsViewModel.js +1 -1
  113. package/widgets/Directions.js +1 -1
  114. package/widgets/ElevationProfile/components/LegendItem.js +1 -1
  115. package/widgets/ElevationProfile/components/SettingsButton.js +1 -1
  116. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  117. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  118. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  119. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  120. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  121. package/widgets/Legend/styles/support/utils.js +1 -1
  122. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  123. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  124. package/widgets/OrientedImageryViewer.js +1 -1
  125. package/widgets/Sketch/SketchViewModel.js +1 -1
  126. package/widgets/Sketch/support/ResponsiveToolbar/OverflowGroup.js +1 -1
  127. package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
  128. package/widgets/Sketch/support/ResponsiveToolbar/SplitButton.js +1 -1
  129. package/widgets/Sketch/support/sketchUtils.js +1 -1
  130. package/widgets/Sketch.js +1 -1
  131. package/widgets/support/UtilityNetworkAssociations/utilityNetworkUtils.js +1 -1
  132. package/assets/esri/core/workers/chunks/544ad8fa4777ba8ec177.js +0 -1
  133. package/assets/esri/core/workers/chunks/bdc9dec6a359d2e3705c.js +0 -1
  134. package/assets/esri/core/workers/chunks/bf127fe767174e2715b5.js +0 -1
  135. package/assets/esri/core/workers/chunks/ccee343fb8c415b59ce3.js +0 -2
  136. package/assets/esri/core/workers/chunks/dc68246df91af766593a.js +0 -1
  137. package/assets/esri/core/workers/chunks/e862f1b9ecafc6c92b86.js +0 -314
  138. package/assets/esri/core/workers/chunks/f06231c14c0c0e5525bd.js +0 -1
  139. package/views/3d/layers/graphics/pipeline/featureData/FeatureDataStore.js +0 -5
  140. package/views/3d/webgl-engine/collections/Component/IndexRange/ComponentRangeRunLengthEncoded.js +0 -5
@@ -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{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import{ComponentRangeRunLengthEncoded as e}from"./IndexRange/ComponentRangeRunLengthEncoded.js";import{defaultHighlightName as h}from"../../../../support/HighlightDefaults.js";class i{constructor(t,h){this.offsets=h,this._highlightsInOrder=[],this.pickability=null,this.componentHighlights=new Map,this.verticalOffsets=null,this.cachedGeometryRanges=null,this.cachedHighlightRangesMap=null,this.cachedShadowmapRanges=null;const i=this.count;this.visibility=new e(i),this.materialDataBuffer=t.getBuffer(i),this.materialDataIndices=new Uint16Array(i);for(let e=0;e<i;e++)this.materialDataIndices[e]=this.materialDataBuffer.acquireIndex()}destroy(){for(let t=0;t<this.count;t++)this.materialDataBuffer.releaseIndex(this.materialDataIndices[t])}get count(){return this.offsets.length-1}get geometryRanges(){return null==this.cachedGeometryRanges&&(this.cachedGeometryRanges=this.visibility.computeOffsetRanges(this.offsets)),this.cachedGeometryRanges}get highlightRangesMap(){return 0===this.componentHighlights.size?null:(this._updateCachedHighlightRanges(),this.cachedHighlightRangesMap)}get shadowmapRanges(){return 0===this.componentHighlights.size?this.geometryRanges:(this._updateCachedHighlightRanges(),this.cachedShadowmapRanges)}markHighlightsDirty(){this.cachedHighlightRangesMap=null,this.cachedShadowmapRanges=null}markVisibilityDirty(){this.cachedGeometryRanges=null,this.markHighlightsDirty()}updateHighlights(t){this._updateHighlightOrder(t)&&(this.markHighlightsDirty(),this._updateCachedHighlightRanges())}_updateHighlightOrder(t){const{_highlightsInOrder:e}=this;let h=e.length!==t.length;e.length=Math.min(t.length,8);for(let i=0;i<t.length;++i){const s=t.at(i).name;e.length<i?(h=!0,e.push(s)):e[i]!==s&&(e[i]=s,h=!0)}return h}_updateCachedHighlightRanges(){if(null==this.cachedHighlightRangesMap||null==this.cachedShadowmapRanges){const{highlightRangesMap:t,shadowmapRangesMap:e}=s(this.componentHighlights,this.visibility,this.offsets,this._highlightsInOrder);this.cachedHighlightRangesMap=t,this.cachedShadowmapRanges=e}}}function s(e,i,s,a){const n=new Map,g=[];if(e.size>0){let l=s.length;i.forEachComponent((i=>{let r=!1;for(let g=a.length-1;g>=0;--g){const l=a[g],c=e.get(l);if((c?.[i]??0)>0){const e=t(n,l,(()=>[])),a=s[i],g=s[i+1];e.push(a),e.push(g-a),r||=l===h;break}}return r||(l!==i-1&&(g.length>0&&g.push(s[l+1]-g[g.length-1]),g.push(s[i])),l=i),!0})),g.length>0&&g.push(s[l+1]-g[g.length-1])}return{highlightRangesMap:n,shadowmapRangesMap:g}}export{i as default};
5
+ import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import{ComponentRange as e}from"./IndexRange/ComponentRange.js";import{defaultHighlightName as h}from"../../../../support/HighlightDefaults.js";class i{constructor(t,h){this.offsets=h,this._highlightsInOrder=[],this.pickability=null,this.componentHighlights=new Map,this.verticalOffsets=null,this._cachedGeometryRanges=null,this._cachedHighlightRangesMap=null,this._cachedShadowmapRanges=null;const i=this.count;this.visibility=new e(i),this.materialDataBuffer=t.getBuffer(i),this.materialDataIndices=new Uint16Array(i);for(let e=0;e<i;e++)this.materialDataIndices[e]=this.materialDataBuffer.acquireIndex()}destroy(){for(let t=0;t<this.count;t++)this.materialDataBuffer.releaseIndex(this.materialDataIndices[t])}get count(){return this.offsets.length-1}get geometryRanges(){return null==this._cachedGeometryRanges&&(this._cachedGeometryRanges=this.visibility.computeOffsetRanges(this.offsets)),this._cachedGeometryRanges}get highlightRangesMap(){return 0===this.componentHighlights.size?null:(this._updateCachedHighlightRanges(),this._cachedHighlightRangesMap)}get shadowmapRanges(){return 0===this.componentHighlights.size?this.geometryRanges:(this._updateCachedHighlightRanges(),this._cachedShadowmapRanges)}markHighlightsDirty(){this._cachedHighlightRangesMap=null,this._cachedShadowmapRanges=null}markVisibilityDirty(){this._cachedGeometryRanges=null,this.markHighlightsDirty()}updateHighlights(t){this._updateHighlightOrder(t)&&(this.markHighlightsDirty(),this._updateCachedHighlightRanges())}_updateHighlightOrder(t){const{_highlightsInOrder:e}=this;let h=e.length!==t.length;e.length=Math.min(t.length,8);for(let i=0;i<t.length;++i){const s=t.at(i).name;e.length<i?(h=!0,e.push(s)):e[i]!==s&&(e[i]=s,h=!0)}return h}_updateCachedHighlightRanges(){if(null==this._cachedHighlightRangesMap||null==this._cachedShadowmapRanges){const{highlightRangesMap:t,shadowmapRangesMap:e}=s(this.componentHighlights,this.visibility,this.offsets,this._highlightsInOrder);this._cachedHighlightRangesMap=t,this._cachedShadowmapRanges=e}}}function s(e,i,s,a){const g=new Map,n=[];if(e.size>0){let l=s.length;i.forEachComponent((i=>{let r=!1;for(let n=a.length-1;n>=0;--n){const l=a[n],c=e.get(l);if((c?.[i]??0)>0){const e=t(g,l,(()=>[])),a=s[i],n=s[i+1];e.push(a),e.push(n-a),r||=l===h;break}}return r||(l!==i-1&&(n.length>0&&n.push(s[l+1]-n[n.length-1]),n.push(s[i])),l=i),!0})),n.length>0&&n.push(s[l+1]-n[n.length-1])}return{highlightRangesMap:g,shadowmapRangesMap:n}}export{i as ComponentData};
@@ -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/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import i from"../../../../../core/PooledArray.js";import{isTypedArray as o}from"../../../../../core/typedArrayUtil.js";import{s as n}from"../../../../../chunks/vec32.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as a}from"../../../../../geometry/support/Indices.js";import{c as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec33.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{ColorMixModeEnum as p,encodeSymbolColor as f}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as h}from"../../../support/orientedBoundingBox.js";import{glLayout as g}from"../../../support/buffer/glUtil.js";import{newLayout as d}from"../../../support/buffer/InterleavedLayout.js";import u from"./ComponentData.js";import{ComponentObject as b}from"./ComponentObject.js";import{IntersectionGeometry as y}from"./IntersectionGeometry.js";import{Renderable as v}from"./Renderable.js";import{RenderGeometry as _}from"./RenderGeometry.js";import{RenderSubmitSystem as C}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as M}from"./SourceGeometry.js";import{UniformComponentParameters as j}from"./UniformComponentParameters.js";import{ComponentParametersVarying as w,ComponentParametersUniform as x,ComponentParameterSummary as O,ComponentMaterial as D}from"./Material/ComponentMaterial.js";import{vertexAttributeLocations as A}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as R}from"./Material/shader/ComponentData.glsl.js";import{olidEnabled as S}from"../../effects/geometry/olidUtils.js";import{getVisibility as E,updateVisibilityWithCount as I}from"../../lib/ComponentUtils.js";import{assert as H}from"../../lib/Util.js";import{VertexAttribute as V}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as U}from"../../lib/verticalOffsetUtils.js";import{BufferManager as B}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as P}from"../../../../webgl/BufferObject.js";import{Usage as N,PrimitiveType as T}from"../../../../webgl/enums.js";import{VertexArrayObject as k}from"../../../../webgl/VertexArrayObject.js";const L=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class G{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new i,this._hidden=new i,this._renderSubmit=new C(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new B(e.rctx,2+(S()?1:0))}destroy(){H(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.forAll((e=>e.destroy())),this._hidden.clear()}createObject(e){const t=e.geometry,i=new u(this._componentBufferManager,a(t.componentOffsets)),o=this._createRenderable(e,i),n=new y(this._viewingMode,t.positionData,i),r=new b(e.transform,e.toMapSpace,e.obb.clone(),i,o,n);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const i=e.renderable.material;t(i),i.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,i=t.componentData.visibility.componentCount;return{visible:i,invisible:t.componentData.count-i}}setComponentData(e,t){const i=e,{renderable:o,componentData:n}=i,r=o.material,s=n.materialDataBuffer,a=n.materialDataIndices,l=new j,c=s.textureBuffer,m=new Uint8Array(4),g=new Uint32Array(m.buffer);let d=0,u=0,b=0,y=n.verticalOffsets,v=1/0,_=-1/0,C=!1,M=!1,D=0;for(let h=0;h<n.count;h++){t(h,l),d+=+(l.externalColor[3]<1),u+=+(l.externalColorMixMode===p.Replace&&1===l.externalColor[3]),b+=+l.castShadows,f(l.externalColor,l.externalColorMixMode,m),m[2]=254&m[2]|+l.castShadows,c.setData(a[h],0,m[0],m[1],m[2],m[3]),C||=h>0&&D!==g[0],D=g[0],M||=0!==l.elevationOffset,M&&null==y&&(y=new Array(h).fill(0)),null!=y&&(y[h]=l.elevationOffset),v=Math.min(v,l.elevationOffset),_=Math.max(_,l.elevationOffset),R(l.elevationOffset,m),c.setData(a[h],1,m[0],m[1],m[2],m[3]);const e=l.objectAndLayerIdColor;null!=e&&c.setData(a[h],2,e[0],e[1],e[2],e[3]),l.pickable!==E(n.pickability,h)&&(n.pickability=I(n.pickability,n.count,h,l.pickable))}n.verticalOffsets=M?y:null,i.offsetObb=M?h(i.obb,v,_,this._viewingMode,i.offsetObb??i.obb.clone()):null,C||M||S()?(r.componentParameters=new w,r.componentParameters.castShadows=W(b,n.count),r.componentParameters.transparent=W(d,n.count),r.componentParameters.opaqueOverride=W(u,n.count),r.componentParameters.texture=c,c.updateTexture()):(r.componentParameters=new x,r.componentParameters.castShadows=l.castShadows?O.All:O.None,r.componentParameters.externalColor=l.externalColor,r.componentParameters.externalColorMixMode=l.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,i,o=!1){e.intersectionGeometry.getComponentAabb(t,i);const n=e,r=n.componentData.verticalOffsets;if(o||null==r)return i;const s=r[t];if(this._viewingMode===m.Local||0===s)return i[2]+=s,i[5]+=s,i;const a=U(s);return a.localOrigin=n.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}expandRangeWithComponentObjectElevationRange(e,t,i,o){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||o.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const n=e,r=n.componentData,s=r.count,a=r.verticalOffsets,l=n.intersectionGeometry,c=this._viewingMode===m.Local,p=l.getComponentAabbs(),f=z;let h=1/0,g=-1/0;for(let m=0;m<s;m++){const e=6*m,r=a?.[m]??0;let s=1/0,l=-1/0;if(c)s=p[e+2]+r+t,l=p[e+5]+r+t;else{if(f[0]=p[e],f[1]=p[e+1],f[2]=p[e+2],f[3]=p[e+3],f[4]=p[e+4],f[5]=p[e+5],0!==r){const e=U(r);e.localOrigin=n.transform.position,e.applyToAabb(f)}const s=Math.max(Math.abs(f[3]),Math.abs(f[0])),a=Math.max(Math.abs(f[4]),Math.abs(f[1])),l=t+f[5]+i;o.expandElevationRangeValues(t+f[2],Math.sqrt(s*s+a*a+l*l)-i)}o.expandElevationRangeValues(s,l),h=Math.min(h,s),g=Math.max(g,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=h,this._elevationRangeCacheMax=g}intersect(e,t,i,o,n,r,s){const a=e,{transform:l}=a,{position:c}=l;return null!=n&&(n.localOrigin=c),a.intersectionGeometry.intersect(t,i,o,n,a.componentData.verticalOffsets,l,r,s)}addEdges(e,t,i,o,n){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.componentData.offsets;return t.addComponentObject(r,a,s,l,i,o,n)}async extractEdgeInformation(e,t,i){const o=e,n=o.componentData.visibility;if(n.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:a}=o.intersectionGeometry,m=o.componentData.offsets,{EdgeInputBufferLayout:p}=await import("../../lib/edgeRendering/bufferLayouts.js"),f=p.createBuffer(a.length/3);c(f.position.typedBuffer,a,f.position.typedBufferStride,3),l(f.position,f.position,o.transform.rotationScale),this._setComponentIndices(f.componentIndex,s,m);const h=f.count,g=this._computeVisibilityIndices(s,n,m,h);return{origin:r(o.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:g,indicesLength:g.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let o=0;for(let n=0;n<i.length-1;n++){const r=i[n],s=i[n+1];for(let i=r;i<s;i++){const n=t?t[i]:i;e.set(n,o)}o++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange(((e,t)=>(r+=i[t]-i[e],!0)));const s=o(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r):new Array(r);let a=0;return t.forEachComponentRange(((t,o)=>{const n=i[t],r=i[o];for(let i=n;i<r;i++)s[a++]=e?e[i]:i;return!0})),s}addComponentHighlight(e,i,o){const n=e.componentData,r=t(n.componentHighlights,o,(()=>new Uint32Array(n.count+1)));{const e=this._activeHighlightOptions.get(o)??0;this._activeHighlightOptions.set(o,e+1)}0===r[i]++&&(n.markHighlightsDirty(),this._notifyDirty()),r[n.count]++}removeComponentHighlight(e,t,i){const{componentData:o}=e,n=o.componentHighlights.get(i);if(void 0===n)return void L().warn("Removing non-existing highlight.");const r=n[t];if(0===r)return void L().warn("Removing non-existing highlight.");this._removeActiveHighlight(i);const s=n[o.count];if(r>1)return n[t]=r-1,void(n[o.count]=s-1);n[t]=0,1===s?o.componentHighlights.delete(i):n[o.count]=s-1,o.markHighlightsDirty(),this._notifyDirty()}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)L().warn("Removing non-existing highlight.");else{const o=i-t;o<0&&L().warn("Removing non-existing highlight."),o<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,o)}}clearHighlights(e){const{componentData:t}=e,{componentHighlights:i}=t;if(i.size>0){for(const e of i)this._removeActiveHighlight(e[0],e[1][t.count]);i.clear(),t.markHighlightsDirty(),this._notifyDirty()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const i=this._renderManager.rctx,o=e.geometry,n=o.vertices.layoutParameters,r=P.createVertex(i,N.STATIC_DRAW,o.vertices.data),s=o.indices?P.createIndex(i,N.STATIC_DRAW,o.indices):null,a=g(M(n)),l=new Uint16Array(o.vertices.count);for(let g=0;g<t.count;g++){const e=t.offsets[g],i=t.offsets[g+1],n=t.materialDataIndices[g];if(null!=o.indices)for(let t=e;t<i;t++){l[o.indices[t]]=n}else for(let t=e;t<i;t++)l[t]=n}const c=P.createVertex(i,N.STATIC_DRAW,l.buffer),m=new D(e.transform,e.toMapSpace),p=new k(i,A,new Map([["data",a],["componentIndices",q]]),new Map([["data",r],["componentIndices",c]]),s),f=new _(p,T.TRIANGLES,n,null!=s),h={cameraDepthSquared:.5,gpuMemoryEstimate:r.usedMemory+c.usedMemory+(null!=s?s.usedMemory:0)};return new v(m,f,h)}_notifyDirty(){this._renderManager.notifyDirty()}}const q=g(d().u16(V.COMPONENTINDEX));function W(e,t){return e===t?O.All:0===e?O.None:O.Some}const z=s();export{G as ComponentObjectCollection};
5
+ import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import o from"../../../../../core/PooledArray.js";import{isTypedArray as i}from"../../../../../core/typedArrayUtil.js";import{s as n}from"../../../../../chunks/vec32.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as a}from"../../../../../geometry/support/Indices.js";import{c as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec33.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{ColorMixModeEnum as f,encodeSymbolColor as h}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as p}from"../../../support/orientedBoundingBox.js";import{glLayout as g}from"../../../support/buffer/glUtil.js";import{newLayout as d}from"../../../support/buffer/InterleavedLayout.js";import{ComponentData as u}from"./ComponentData.js";import{ComponentObject as b}from"./ComponentObject.js";import{IntersectionGeometry as v}from"./IntersectionGeometry.js";import{Renderable as y}from"./Renderable.js";import{RenderGeometry as _}from"./RenderGeometry.js";import{RenderSubmitSystem as C}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as M}from"./SourceGeometry.js";import{UniformComponentParameters as j}from"./UniformComponentParameters.js";import{ComponentParametersVarying as w,ComponentParametersUniform as x,ComponentParameterSummary as O,ComponentMaterial as D}from"./Material/ComponentMaterial.js";import{vertexAttributeLocations as A}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as R}from"./Material/shader/ComponentData.glsl.js";import{olidEnabled as S}from"../../effects/geometry/olidUtils.js";import{getVisibility as E,updatePickabilityWithCount as I}from"../../lib/ComponentUtils.js";import{assert as H}from"../../lib/Util.js";import{VertexAttribute as V}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as U}from"../../lib/verticalOffsetUtils.js";import{BufferManager as B}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as P}from"../../../../webgl/BufferObject.js";import{Usage as N,PrimitiveType as T}from"../../../../webgl/enums.js";import{VertexArrayObject as L}from"../../../../webgl/VertexArrayObject.js";const k=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class G{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new o,this._hidden=new o,this._renderSubmit=new C(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new B(e.rctx,2+(S()?1:0))}destroy(){H(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.forAll((e=>e.destroy())),this._hidden.clear()}createObject(e){const t=e.geometry,o=new u(this._componentBufferManager,a(t.componentOffsets)),i=this._createRenderable(e,o),n=new v(this._viewingMode,t.positionData,o),r=new b(e.transform,e.toMapSpace,e.obb.clone(),o,i,n);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(t?(this._hidden.removeUnordered(o),this._visible.push(o)):(this._visible.removeUnordered(o),this._hidden.push(o)),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.componentData.visibility.reset(t),o.componentData.markVisibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.componentData.visibility.componentCount;return{visible:o,invisible:t.componentData.count-o}}setComponentData(e,t){const o=e,{renderable:i,componentData:n}=o,r=i.material,s=n.materialDataBuffer,a=n.materialDataIndices,l=new j,c=s.textureBuffer,m=new Uint8Array(4),g=new Uint32Array(m.buffer);let d=0,u=0,b=0,v=n.verticalOffsets,y=1/0,_=-1/0,C=!1,M=!1,D=0;for(let p=0;p<n.count;p++){t(p,l),d+=+(l.externalColor[3]<1),u+=+(l.externalColorMixMode===f.Replace&&1===l.externalColor[3]),b+=+l.castShadows,h(l.externalColor,l.externalColorMixMode,m),m[2]=254&m[2]|+l.castShadows,c.setData(a[p],0,m[0],m[1],m[2],m[3]),C||=p>0&&D!==g[0],D=g[0],M||=0!==l.elevationOffset,M&&null==v&&(v=new Array(p).fill(0)),null!=v&&(v[p]=l.elevationOffset),y=Math.min(y,l.elevationOffset),_=Math.max(_,l.elevationOffset),R(l.elevationOffset,m),c.setData(a[p],1,m[0],m[1],m[2],m[3]);const e=l.objectAndLayerIdColor;null!=e&&c.setData(a[p],2,e[0],e[1],e[2],e[3]),l.pickable!==E(n.pickability,p)&&I(n,p,l.pickable)}n.verticalOffsets=M?v:null,o.offsetObb=M?p(o.obb,y,_,this._viewingMode,o.offsetObb??o.obb.clone()):null,C||M||S()?(r.componentParameters=new w,r.componentParameters.castShadows=W(b,n.count),r.componentParameters.transparent=W(d,n.count),r.componentParameters.opaqueOverride=W(u,n.count),r.componentParameters.texture=c,c.updateTexture()):(r.componentParameters=new x,r.componentParameters.castShadows=l.castShadows?O.All:O.None,r.componentParameters.externalColor=l.externalColor,r.componentParameters.externalColorMixMode=l.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,o,i=!1){e.intersectionGeometry.getComponentAabb(t,o);const n=e,r=n.componentData.verticalOffsets;if(i||null==r)return o;const s=r[t];if(this._viewingMode===m.Local||0===s)return o[2]+=s,o[5]+=s,o;const a=U(s);return a.localOrigin=n.transform.position,a.applyToAabb(o)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}expandRangeWithComponentObjectElevationRange(e,t,o,i){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||i.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const n=e,r=n.componentData,s=r.count,a=r.verticalOffsets,l=n.intersectionGeometry,c=this._viewingMode===m.Local,f=l.getComponentAabbs(),h=z;let p=1/0,g=-1/0;for(let m=0;m<s;m++){const e=6*m,r=a?.[m]??0;let s=1/0,l=-1/0;if(c)s=f[e+2]+r+t,l=f[e+5]+r+t;else{if(h[0]=f[e],h[1]=f[e+1],h[2]=f[e+2],h[3]=f[e+3],h[4]=f[e+4],h[5]=f[e+5],0!==r){const e=U(r);e.localOrigin=n.transform.position,e.applyToAabb(h)}const s=Math.max(Math.abs(h[3]),Math.abs(h[0])),a=Math.max(Math.abs(h[4]),Math.abs(h[1])),l=t+h[5]+o;i.expandElevationRangeValues(t+h[2],Math.sqrt(s*s+a*a+l*l)-o)}i.expandElevationRangeValues(s,l),p=Math.min(p,s),g=Math.max(g,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=p,this._elevationRangeCacheMax=g}intersect(e,t,o,i,n,r,s){const a=e,{transform:l,componentData:c,intersectionGeometry:m}=a;return null!=n&&(n.localOrigin=l.position),m.intersect(t,o,i,n,c.verticalOffsets,l,r,s)}addEdges(e,t,o,i,n){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.componentData.offsets;return t.addComponentObject(r,a,s,l,o,i,n)}async extractEdgeInformation(e,t,o){const i=e,n=i.componentData.visibility;if(n.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:a}=i.intersectionGeometry,m=i.componentData.offsets,{EdgeInputBufferLayout:f}=await import("../../lib/edgeRendering/bufferLayouts.js"),h=f.createBuffer(a.length/3);c(h.position.typedBuffer,a,h.position.typedBufferStride,3),l(h.position,h.position,i.transform.rotationScale),this._setComponentIndices(h.componentIndex,s,m);const p=h.count,g=this._computeVisibilityIndices(s,n,m,p);return{origin:r(i.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:g,indicesLength:g.length,skipDeduplicate:!0,data:h,writerSettings:{reducedPrecision:!1,variants:0}},o)}}_setComponentIndices(e,t,o){let i=0;for(let n=0;n<o.length-1;n++){const r=o[n],s=o[n+1];for(let o=r;o<s;o++){const n=t?t[o]:o;e.set(n,i)}i++}}_computeVisibilityIndices(e,t,o,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange(((e,t)=>(r+=o[t]-o[e],!0)));const s=i(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r):new Array(r);let a=0;return t.forEachComponentRange(((t,i)=>{const n=o[t],r=o[i];for(let o=n;o<r;o++)s[a++]=e?e[o]:o;return!0})),s}addComponentHighlight(e,o,i){const n=e.componentData,r=t(n.componentHighlights,i,(()=>new Uint32Array(n.count+1)));{const e=this._activeHighlightOptions.get(i)??0;this._activeHighlightOptions.set(i,e+1)}0===r[o]++&&(n.markHighlightsDirty(),this._notifyDirty()),r[n.count]++}removeComponentHighlight(e,t,o){const{componentData:i}=e,n=i.componentHighlights.get(o);if(void 0===n)return void k().warn("Removing non-existing highlight.");const r=n[t];if(0===r)return void k().warn("Removing non-existing highlight.");this._removeActiveHighlight(o);const s=n[i.count];if(r>1)return n[t]=r-1,void(n[i.count]=s-1);n[t]=0,1===s?i.componentHighlights.delete(o):n[i.count]=s-1,i.markHighlightsDirty(),this._notifyDirty()}_removeActiveHighlight(e,t=1){const o=this._activeHighlightOptions.get(e);if(void 0===o)k().warn("Removing non-existing highlight.");else{const i=o-t;i<0&&k().warn("Removing non-existing highlight."),i<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,i)}}clearHighlights(e){const{componentData:t}=e,{componentHighlights:o}=t;if(o.size>0){for(const e of o)this._removeActiveHighlight(e[0],e[1][t.count]);o.clear(),t.markHighlightsDirty(),this._notifyDirty()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const o=this._renderManager.rctx,i=e.geometry,n=i.vertices.layoutParameters,r=P.createVertex(o,N.STATIC_DRAW,i.vertices.data),s=i.indices?P.createIndex(o,N.STATIC_DRAW,i.indices):null,a=g(M(n)),l=new Uint16Array(i.vertices.count);for(let g=0;g<t.count;g++){const e=t.offsets[g],o=t.offsets[g+1],n=t.materialDataIndices[g];if(null!=i.indices)for(let t=e;t<o;t++){l[i.indices[t]]=n}else for(let t=e;t<o;t++)l[t]=n}const c=P.createVertex(o,N.STATIC_DRAW,l.buffer),m=new D(e.transform,e.toMapSpace),f=new L(o,A,new Map([["data",a],["componentIndices",q]]),new Map([["data",r],["componentIndices",c]]),s),h=new _(f,T.TRIANGLES,n,null!=s),p={cameraDepthSquared:.5,gpuMemoryEstimate:r.usedMemory+c.usedMemory+(null!=s?s.usedMemory:0)};return new y(m,h,p)}_notifyDirty(){this._renderManager.notifyDirty()}}const q=g(d().u16(V.COMPONENTINDEX));function W(e,t){return e===t?O.All:0===e?O.None:O.Some}const z=s();export{G as ComponentObjectCollection};
@@ -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{c as t,a as e}from"../../../../../chunks/vec32.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as o}from"../../../../../geometry/support/aaBoundingBox.js";import{ComponentObjectElevationAgnosticComponentGeometryBVH as s,intersectTriangleRangeForComponent as i}from"./ComponentObjectElevationAgnosticComponentGeometryBVH.js";import{ElevationAgnosticBVH as r}from"./ElevationAgnosticBVH.js";import{getVisibility as a}from"../../lib/ComponentUtils.js";import{computeInvDir as c,intersectAabbInvDir as l,MeshIntersectionOptions as h}from"../../lib/RayIntersections.js";class m{constructor(t,e,o,s,i,a,c,l){this.vertexData=t,this.vertexStride=e,this.indexData=o,this._components=s,this._componentAabbs3D=i,this.geometryMinZ=a,this.planetCenterZ=c,this.localMode=l,this.maxBspNodeDepth=6,this.minElementCountForBVH=10,this.minBspNodeElementCount=3,this._ray0=f,this._ray1=u,this._invDir=n(),this._componentVerticalOffsets=null,this._verticalOffset=null,this._tolerance=0,this._intersectionOptions=D,this._callback=y,this.rayDirectionC=n(),this._componentIndexMap=null,this._bvh=new r(s.count,this),this.componentIntersectionData=new Array(s.count)}get numComponents(){return this._components.count}get minZGlobal(){return this.geometryMinZ-this.planetCenterZ}getAabbs2D(){return this.localMode?this.getAabbs2DLocal():this.getAabbs2DGlobal()}getAabbs2DGlobal(){const{numComponents:t,planetCenterZ:e,minZGlobal:n}=this,o=new Float64Array(4*t),s=this._componentAabbs3D;for(let i=0;i<t;++i){const t=6*i,r=s[t+0],a=s[t+1],c=s[t+2],l=s[t+3],h=s[t+4],m=n/(c-e),p=n/(s[t+5]-e),_=Math.min(r*m,r*p),b=Math.min(a*m,a*p),f=Math.max(l*m,l*p),u=Math.max(h*m,h*p),y=4*i;o[y+0]=_,o[y+1]=b,o[y+2]=f,o[y+3]=u}return o}getAabbs2DLocal(){const{numComponents:t}=this,e=new Float64Array(4*t),n=this._componentAabbs3D;for(let o=0;o<t;++o){const t=6*o,s=n[t+0],i=n[t+1],r=n[t+3],a=n[t+4],c=4*o;e[c+0]=s,e[c+1]=i,e[c+2]=r,e[c+3]=a}return e}intersectRay(t,e,n,o,s,i,r){const{isVerticalRay:a}=r;this._ray0=t,this._ray1=e,this._componentVerticalOffsets=n,this._verticalOffset=o,this._tolerance=i,this._intersectionOptions=r,this._componentIndexMap=this._bvh.elementIndexMap,c(t,e,this._invDir),this._callback=s,this._bvh.intersectRay(t,e,a),this._callback=y}intersectRange(t,e){const n=this._componentIndexMap,o=this._components,s=o.pickability,i=o.visibility;for(let r=t;r<e;++r){const t=n?n[r]:r;a(s,t)&&i.isVisible(t)&&this._intersectComponent(t)}}getComponentTriangleCount(t){const e=this._components.offsets,n=e[t]/3;return e[t+1]/3-n}getComponentAabb3D(t,e){const n=this._componentAabbs3D,o=6*t;return e[0]=n[o],e[1]=n[o+1],e[2]=n[o+2],e[3]=n[o+3],e[4]=n[o+4],e[5]=n[o+5],e}_intersectComponent(n){if(!a(this._components.pickability,n))return;const o=this.getComponentAabb3D(n,p);let r=!1;const{localMode:c,_componentVerticalOffsets:h,_verticalOffset:m,_ray0:f,_ray1:u,_invDir:y,planetCenterZ:D,_tolerance:C,rayDirectionC:v,componentIntersectionData:A}=this,{isVerticalRay:x}=this._intersectionOptions,d=this._components.offsets,M=t(_,f),O=t(b,u),V=h?.[n]??0,Z=V+(m?.offset??0);if(0!==Z&&(c?(M[2]=f[2]-Z,O[2]=u[2]-Z,r=!0):null!=m&&(m.componentOffset=V)),null==m||r||0===Z||m.applyToAabb(o),!l(o,M,y,C))return;e(v,O,M);const j=d[n]/3,R=d[n+1]/3,k=R-j,B=(t,e,o)=>{this._callback(t,e,n,o)},{vertexData:I,vertexStride:w,indexData:G,_intersectionOptions:E}=this,{normalRequired:F}=E;if(k>g){let t=A[n];null==t&&(t=new s(n,I,w,G,j,R,this.geometryMinZ,D,c),A[n]=t),t.intersectRay(M,O,x,r?0:Z,B,F)}else{i(M,v,j,R,G,I,w,r?0:Z,D,F,B)}}}const p=o(),_=n(),b=n(),f=n(),u=n(),y=()=>{},D=new h,g=40;export{m as ComponentObjectElevationAgnosticComponentBVH};
5
+ import{c as t,a as e}from"../../../../../chunks/vec32.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as o}from"../../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as s}from"../../../../../geometry/support/DoubleArray.js";import{ComponentObjectElevationAgnosticComponentGeometryBVH as i,intersectTriangleRangeForComponent as r}from"./ComponentObjectElevationAgnosticComponentGeometryBVH.js";import{ElevationAgnosticBVH as a}from"./ElevationAgnosticBVH.js";import{getVisibility as c}from"../../lib/ComponentUtils.js";import{computeInvDir as l,intersectAabbInvDir as m,MeshIntersectionOptions as h}from"../../lib/RayIntersections.js";class p{constructor(t,e,o,s,i,r,c,l){this.vertexData=t,this.vertexStride=e,this.indexData=o,this._components=s,this._componentAabbs3D=i,this.geometryMinZ=r,this.planetCenterZ=c,this.localMode=l,this.maxBspNodeDepth=6,this.minElementCountForBVH=10,this.minBspNodeElementCount=3,this._ray0=u,this._ray1=y,this._invDir=n(),this._componentVerticalOffsets=null,this._verticalOffset=null,this._tolerance=0,this._intersectionOptions=g,this._callback=D,this.rayDirectionC=n(),this._componentIndexMap=null,this._bvh=new a(s.count,this),this.componentIntersectionData=new Array(s.count)}get numComponents(){return this._components.count}get minZGlobal(){return this.geometryMinZ-this.planetCenterZ}getAabbs2D(){return this.localMode?this.getAabbs2DLocal():this.getAabbs2DGlobal()}getAabbs2DGlobal(){const{numComponents:t,planetCenterZ:e,minZGlobal:n}=this,o=s(4*t),i=this._componentAabbs3D;for(let s=0;s<t;++s){const t=6*s,r=i[t+0],a=i[t+1],c=i[t+2],l=i[t+3],m=i[t+4],h=n/(c-e),p=n/(i[t+5]-e),b=Math.min(r*h,r*p),_=Math.min(a*h,a*p),f=Math.max(l*h,l*p),u=Math.max(m*h,m*p),y=4*s;o[y+0]=b,o[y+1]=_,o[y+2]=f,o[y+3]=u}return o}getAabbs2DLocal(){const{numComponents:t}=this,e=s(4*t),n=this._componentAabbs3D;for(let o=0;o<t;++o){const t=6*o,s=n[t+0],i=n[t+1],r=n[t+3],a=n[t+4],c=4*o;e[c+0]=s,e[c+1]=i,e[c+2]=r,e[c+3]=a}return e}intersectRay(t,e,n,o,s,i,r){const{isVerticalRay:a}=r;this._ray0=t,this._ray1=e,this._componentVerticalOffsets=n,this._verticalOffset=o,this._tolerance=i,this._intersectionOptions=r,this._componentIndexMap=this._bvh.elementIndexMap,l(t,e,this._invDir),this._callback=s,this._bvh.intersectRay(t,e,a),this._callback=D}intersectRange(t,e){const n=this._componentIndexMap,{pickability:o,visibility:s}=this._components;for(let i=t;i<e;++i){const t=n?n[i]:i;c(o,t)&&s.isVisible(t)&&this._intersectComponent(t)}}getComponentTriangleCount(t){const e=this._components.offsets,n=e[t]/3;return e[t+1]/3-n}getComponentAabb3D(t,e){const n=this._componentAabbs3D,o=6*t;return e[0]=n[o],e[1]=n[o+1],e[2]=n[o+2],e[3]=n[o+3],e[4]=n[o+4],e[5]=n[o+5],e}_intersectComponent(n){const o=this.getComponentAabb3D(n,b);let s=!1;const{localMode:a,_componentVerticalOffsets:c,_verticalOffset:l,_ray0:h,_ray1:p,_invDir:u,planetCenterZ:y,_tolerance:D,rayDirectionC:g,componentIntersectionData:v}=this,{isVerticalRay:x}=this._intersectionOptions,A=this._components.offsets,d=t(_,h),M=t(f,p),O=c?.[n]??0,j=O+(l?.offset??0);if(0!==j&&(a?(d[2]=h[2]-j,M[2]=p[2]-j,s=!0):null!=l&&(l.componentOffset=O)),null==l||s||0===j||l.applyToAabb(o),!m(o,d,u,D))return;e(g,M,d);const V=A[n]/3,Z=A[n+1]/3,R=Z-V,B=(t,e,o)=>{this._callback(t,e,n,o)},{vertexData:I,vertexStride:k,indexData:G,_intersectionOptions:w}=this,{normalRequired:E}=w;if(R>C){let t=v[n];null==t&&(t=new i(n,I,k,G,V,Z,this.geometryMinZ,y,a),v[n]=t),t.intersectRay(d,M,x,s?0:j,B,E)}else{r(d,g,V,Z,G,I,k,s?0:j,y,E,B)}}}const b=o(),_=n(),f=n(),u=n(),y=n(),D=()=>{},g=new h,C=40;export{p as ComponentObjectElevationAgnosticComponentBVH};
@@ -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
+ class t{constructor(t){this._totalCount=t,this._componentCountCache=-1,this._indexRanges=[0,t]}allVisible(){return this.componentCount===this._totalCount}allInvisible(){return 0===this._indexRanges.length}isVisible(t){if(t<0||t>=this._totalCount)return!1;if(this.allVisible())return!0;const n=this._indexRanges;let e=0,o=n.length/2;if(t<n[2*e]||t>n[2*o]+n[2*o+1])return!1;for(;o-e>0;){const s=Math.floor(.5*(e+o)),i=n[2*s];if(t<i){if(o-e==1)return!1;o=s;continue}if(t<i+n[2*s+1])return!0;if(o-e==1)return!1;e=s+1}return!1}get componentCount(){if(-1===this._componentCountCache){const t=this._indexRanges;let n=0;for(let e=0;e<t.length;e+=2)n+=t[e+1];this._componentCountCache=n}return this._componentCountCache}reset(t){"all"===t||t.length===this._totalCount?this._indexRanges=[0,this._totalCount]:this._indexRanges=n(t),this._componentCountCache=-1}forEachComponent(t){const n=this._indexRanges;for(let e=0;e<n.length;e+=2){const o=n[e],s=o+n[e+1];for(let n=o;n<s;n++)if(!t(n))return!1}return!0}forEachComponentRange(t){const n=this._indexRanges;for(let e=0;e<n.length;e+=2){const o=n[e];if(!t(o,o+n[e+1]))return!1}return!0}computeOffsetRanges(t){const n=new Array(this._indexRanges.length),e=this._indexRanges;for(let o=0;o<e.length;o+=2){const s=e[o],i=s+e[o+1],r=t[s],h=t[i];n[o]=r,n[o+1]=h-r}return n}}function n(t){const n=new Array;if(0===t.length)return n;let e=t[0],o=1;for(let s=1;s<t.length;s++){const i=t[s];e+o===i?o+=1:(n.push(e),n.push(o),e=i,o=1)}return n.push(e),n.push(o),n}export{t as ComponentRange};
@@ -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{reallocGrowthFactor as t}from"../../../../core/arrayUtils.js";function n(n,i,e,s){if(e>=i)return n;null==n&&(n=r());const a=n.isVisibleBit;let l=n.data;const c=u(l),f=e/c|0,h=e-c*f,B=(i-1)/c|0,E=l,b=s===a;if(!(e<E.length*c)&&b){const n=f+1,i=Math.ceil(E.length*t),r=B+1;let e=Math.max(n,i);e=Math.min(e,r),l=new Uint32Array(e),l.set(E)}return f<l.length&&(l[f]=o(l[f],h,b)),n.data=l,n}function i(t,n){if(null==t)return!0;const{isVisibleBit:i,data:r}=t,o=u(r);return n<r.length*o?e(i,r,n,o):!t.isVisibleBit}function r(t=!0){return{isVisibleBit:!t,data:new Uint32Array(0)}}function e(t,n,i,r){const e=i/r|0,u=i-e*r;return s(n[e],u)===t}function u(t){const n=8;return t.BYTES_PER_ELEMENT*n}function o(t,n,i){return t&~(1<<n)|(i?1:0)<<n}function s(t,n){return!!(t&1<<n)}export{r as defaultVisibilities,i as getVisibility,n as updateVisibilityWithCount};
5
+ import{reallocGrowthFactor as t}from"../../../../core/arrayUtils.js";function n(n,i,r){const o=n.count;if(i>=o)return;n.pickability??=new Uint32Array(0);let u=n.pickability;const l=e(u),a=i/l|0,f=i-l*a,s=(o-1)/l|0,h=u;if(!(i<h.length*l)&&r){const i=a+1,r=Math.ceil(h.length*t),e=s+1;let c=Math.max(i,r);c=Math.min(c,e),n.pickability=u=new Uint32Array(c),u.set(h)}a<u.length&&(u[a]=c(u[a],f,r))}function i(t,n){if(null==t)return!0;const i=e(t);return n<t.length*i&&r(t,n,i)}function r(t,n,i){const r=n/i|0,e=n-r*i;return!!o(t[r],e)}function e(t){const n=8;return t.BYTES_PER_ELEMENT*n}function c(t,n,i){return t&~(1<<n)|(i?1:0)<<n}function o(t,n){return!!(t&1<<n)}export{i as getVisibility,n as updatePickabilityWithCount};
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{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 V from"./templates/BatchFormTemplate.js";import{getLayerContingentValuesMetaData as k}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 V({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}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 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 k(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 V({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};
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};
@@ -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 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,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?h(e,r):T(e,r)}async function T(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)I(i,e,n)&&s.push(g(i,o));const a=await Promise.all(s);return new c({elements:a,preserveFieldValuesWhenHidden:!0})}function E(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(E(t.elements??[],r))return!0;return!1}async function h(e,r){const n=e.formTemplate;if(!n)return T(e,r);let o=null;E(n.elements??[],e)&&(o=new t({title:"",name:w,expression:"false"}));const i=p(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 c(s);const{arcadeExecutorProvider:l,formTimeZone:m}=r;for(const t of a){const r=await v(t,{arcadeExecutorProvider:l,expressionInfos:i,layer:e,formTimeZone:m});r&&s.elements.push(r)}return new c(s)}async function v(r,t){return n(r)?F(r,t):o(r)?Z(r,t):(x().warn(new e("batch-attribute-form:unsupported-element-type",`Form elements of type ${r.type} are not supported`)),null)}async function F(r,{arcadeExecutorProvider:t,expressionInfos:n,layer:o,formTimeZone:i}){const{fieldsIndex:s}=o,{description:m,domain:d,fieldName:p,hint:c,input:y,label:b}=r;if(null==p||!s.has(p))return x().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(p),hint:c,input:y,formTimeZone:i,layerTimeZone:L(o),label:b};!1!==r.editable||r.editableExpression||((r=r.clone()).editableExpression=w),o.subtypeField&&(a(o)||l(o))&&r.fieldName?.toLowerCase()===o.subtypeField.toLowerCase()&&((r=r.clone()).editableExpression=w);const E=new u(T),h=await f({element:r,expressionInfos:n,provider:t});return E.addLayer(o,h),E}async function Z(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 v(p,r);e&&l.elements.push(e)}const m=new y(l),d=await f({element:e,expressionInfos:n,provider:t});return m.addLayer(o,d),m}async function g(e,{arcadeExecutorProvider:r,layer:t,formTimeZone:n}){const o=new u({field:e,label:e.alias??e.name,formTimeZone:n,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")),o.addLayer(t,i),o}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{h 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};
@@ -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"../intl.js";import"../core/has.js";import{abortHandle as t}from"../core/handleUtils.js";import{getOrCreateMapValue as i}from"../core/MapUtils.js";import{watch as n,whenOnce as o}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as r}from"../layers/support/fieldUtils.js";import{isString as l}from"../support/guards.js";import d from"./Widget.js";import{getHiddenFieldsValidationErrorMessage as p,getVisibleFieldInputValidationErrorMessage as u,isElementTemplateWithInputType as c}from"./BatchAttributeForm/batchAttributeFormUtils.js";import m from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as h}from"./BatchAttributeForm/css.js";import{VisibleElements as v}from"./BatchAttributeForm/VisibleElements.js";import{InputVisibilityCode as b,isGroupInput as f,isFieldInput as _,differentValuesString as C}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as I,prepareISOFieldValueForDateComponents as y,prepareUnixFieldValueForDateComponents as w,normalizeTimeOnlyString as F,getISOFieldValueFromDateComponents as x,getUnixFieldValueFromDateComponents as k}from"./support/dateUtils.js";import{globalCss as D}from"./support/globalCss.js";import{setFocus as M}from"./support/widgetUtils.js";import{messageBundle as O}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as V}from"./support/jsxFactory.js";import{isEmptyValue as S}from"./support/forms/formUtils.js";import{substitute as E}from"../intl/substitute.js";const U="data-element-id";let R=class extends d{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.readOnly=!1,this.viewModel=new m,this.visibleElements=new v,this.groupDisplay="all",this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._batchSwitchInputInitialValues=new Map,this._saveInput=this._saveInput.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentUpdate=this._afterDateComponentUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.features),(()=>{this._dateComponentMap.clear();const e=new AbortController;o((()=>!this.viewModel.updating),e.signal).then((()=>{this._attemptFocusOnNextRender=!0})),this.addHandles(t(e))})),n((()=>this.viewModel.activeForm),(()=>{this._batchSwitchInputInitialValues.clear()}))])}loadDependencies(){return g({input:()=>import("@esri/calcite-components/dist/components/calcite-input"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")})}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get _effectiveDisabled(){return this.disabled||this.viewModel.updating}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}goToClosestError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),setTimeout((()=>{if(!this.domNode)return;const t=this.domNode.querySelector(`[data-element-id="${e.input.template.elementId}"]`);t&&M(t)}),10)}render(){const{status:e}=this.viewModel;return"failed"===e?this._renderErrorNotice(this.messages.formFailedToLoad):this.viewModel.expressionEvaluationFailed?this._renderErrorNotice(this.messages.expressionEvaluationFailed):this.viewModel.hasLayersWithContingentValues?this._renderErrorNotice(this.messages.unsupportedContingentValues):V("div",{class:this.classes(h.base,D.widget,D.panel)},"loaded"===e?this._renderForm():"loading"===e?V("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):null)}_setDateTimeTimeZoneMap(e){const{datePart:t,elementId:n}=e.dataset,o=this._getCalciteElementFromDateTimeTimeZonePicker(e,t);if(!o)return;const a=i(this._dateComponentMap,`${n}`,(()=>({placeholder:{date:"",time:"",timeZone:""}})));switch(a.placeholder[t]=o.placeholder??"",t){case"date":a.date=e;break;case"time":a.time=e;break;case"timeZone":a.timeZone=e,a.defaultComboboxItemElements=o.selectedItems}"timeZone"===t&&(a.defaultComboboxItemElements=o.selectedItems)}_getCalciteElementFromDateTimeTimeZonePicker(e,t){const i=e.shadowRoot;return i?"timeZone"===t?i.querySelector("calcite-combobox"):i.querySelector("calcite-input-text"):null}_updateDateTimeOrTimeZoneShadowDom(e,t){const{datePart:i,elementId:n}=e.dataset,o=this._dateComponentMap.get(`${n}`);if(!o)return;const a=this._getCalciteElementFromDateTimeTimeZonePicker(e,i);if(a)switch(i){case"date":case"time":a.placeholder=t?this.messages.differentValues:o.placeholder[i];break;case"timeZone":t?(a.value="",a.placeholder=this.messages.differentValues):(!a.selectedItems.length&&o.defaultComboboxItemElements?.length&&(a.selectedItems[0]=o.defaultComboboxItemElements[0]),a.placeholder=o.placeholder[i])}}_renderErrorNotice(e){return V("div",{class:this.classes(h.base,D.widget,D.panel)},V("calcite-notice",{class:h.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},e)))}_renderForm(){return V("form",{onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderContent())}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:i}=e;let n;if(!e.submitHasBeenAttempted)return null;if(i.invalidHiddenInputs.length>0)if(n=p(i,e.mode,this.messages),"batch"===this.viewModel.mode){const e=i.invalidHiddenInputs.filter((e=>e.effectiveVisibilityCode===b.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL||e.visibilityCode===b.HIDDEN_VISIBILITY_EXPRESSION_ALL));e.length>0?n+=` (${e.map((e=>e.label)).join(", ")})`:n=null}else n+=` (${i.invalidHiddenInputs.map((e=>e.label)).join(", ")})`;else if(t)return null;return n?V("calcite-notice",{class:h.noticeError,icon:!0,kind:"danger",open:!0},V("div",{slot:"message"},n)):null}_renderContent(){if(!this.viewModel.hasVisibleInputs)return[V("calcite-notice",{class:h.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason]))];const{inputs:e}=this.viewModel.activeForm;return e.filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return f(e)?this._renderGroupInput(e):_(e)?this._renderLabeledField(e):void 0}_renderGroupInput(e){const{inputs:t,template:i,open:n}=e,o=t.filter((e=>e.visible)),a=i.label??"";return V("calcite-block",{class:this.classes(h.group,"sequential"===this.groupDisplay?h.groupSequential:null,this.disabled?h.inputDisabled:null),collapsible:!0,description:i.description??void 0,disabled:this._effectiveDisabled,heading:a,headingLevel:this.headingLevel,key:`{${i.elementId}-key}`,label:a,open:n,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0}},o.map((e=>this._renderInput(e))))}_renderLabeledField(e){const{label:t,elementId:i}=e.template,{required:n,dataType:o}=e,a=n?E(this.messages.requiredFieldLabel,{name:t}):t;return V("calcite-label",{"aria-label":a,class:h.label,key:`field--${i}`},V("div",{class:h.labelTextContent,key:"labelTextContainer"},t,n?V("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==o?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:i}=e;if("date"===i)return this._renderDateComponents(e,t);if("coded-value"===e.domain?.type){const i=e.domain;return this._renderCodedInputs({input:e,domain:i,props:t})}return"number"===i?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{compositeError:t,description:i,submittable:n}=e,o=!n&&t&&(this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId))?u(e,t,this.messages):null;return o?V("calcite-input-message",{icon:!0,status:"invalid"},o):i?V("calcite-input-message",{class:h.description,icon:!1,status:"idle"},i):null}_renderCodedInputs({input:e,domain:t,props:i}){const n=e.template.input?.type??null,o=this.viewModel.getCodedValueOptions(t);switch(n){case"switch":return this._renderSwitchField({input:e,props:i,options:o});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:o,props:i});default:return this._renderComboBoxComponent({options:o,props:i,input:e})}}_renderSwitchField({input:e,props:t,options:i}){if((this._batchSwitchInputInitialValues.get(e)===C||e.value===C)&&"batch"===this.viewModel.mode){i.unshift({name:this.messages.differentValues,value:C,disabled:!0,selected:!0});const n={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[U]:t[U]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:n,options:i})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return V("calcite-switch",{...t,checked:!!c(e.template,"switch")&&e.value===e.template.input.onValue,class:h.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInput(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:i}){const{trigger:n,dropdown:o,group:a}=i;return V("calcite-dropdown",{...o,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInput(e)},V("calcite-button",{...n},e===C?this.messages.differentValues:e),V("calcite-dropdown-group",{selectionMode:a.mode},t.map((t=>V("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name)))))}_renderComboBoxComponent({input:e,options:t,props:i}){const n=t.map((e=>this.renderComboboxItem({value:`${e.value}`,text:e.name,selected:i.value===e.value}))),o=i.placeholder===this.messages.differentValues;o&&n.push(V("calcite-combobox-item",{key:C,selected:!0,textLabel:this.messages.differentValues,value:C}));const a="INSERT"===this.viewModel.editType,s=this._touchedInputs.has(e?.template?.elementId),r=!o&&S(i.value);e.showNoValueOptionEnabled&&n.unshift(V("calcite-combobox-item",{key:"empty-option",selected:r,textLabel:e.showNoValueLabel||this.messages.empty,value:""}));const l=a&&e.showNoValueOptionEnabled&&!s?()=>{}:i.onblur,d={...i,onblur:l};return V("calcite-combobox",{...d,selectionMode:"single",value:o?C:String(i.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==C&&this._saveInput(e)}},n)}renderComboboxItem({text:e,value:t,selected:i}){return V("calcite-combobox-item",{key:t,selected:i,textLabel:e,value:t})}_renderRadioButtonGroupComponent({input:e,options:t,props:i}){const n=t.map((({name:t,value:n})=>this._renderRadioButtons({label:t,value:n,selected:n===e.value,props:i})));if(e.showNoValueOptionEnabled){const t="",o=e.showNoValueLabel||this.messages.empty,a=S(e.value);n.unshift(this._renderRadioButtons({label:o,value:t,selected:a,props:i}))}return V("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:h.inputRadioGroup,disabled:i.readOnly,key:`${i.key}-radio-group`,layout:"vertical",name:i.name,required:i.required},n,i.placeholder===this.messages.differentValues?V("calcite-label",{class:h.placeholderRadio,key:i.label,layout:"inline"},V("calcite-radio-button",{checked:!0,class:h.inputRadio,disabled:!0,name:i.placeholder,value:i.placeholder}),i.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:i,props:n}){return V("calcite-label",{class:h.inputRadioLabel,key:n.label,layout:"inline"},V("calcite-radio-button",{...n,checked:t,class:h.inputRadio,disabled:n.readOnly,name:n.label,onblur:()=>{this._focusedFieldInput=null},value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInput(e)}}),i)}_renderStringComponent(e,t){const{template:i}=e;return i.field.editable?i.input&&"text-area"===i.input.type?V("calcite-text-area",{...t,class:this.classes(h.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):V("calcite-input",{...t,class:this.classes(h.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)}):this._renderReadOnlyComponent(e)}_renderNumberComponent(e,t){const i=r(e.field);return V("calcite-input-number",{...t,integer:i,type:"number",value:i&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInput(e)})}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return V("calcite-input",{...i,class:this.classes(h.fieldInput,h.inputDisabled,h.individualElement),readOnly:!0,type:"text",value:String(t??i.value??"")})}_renderDateComponents(e,t){const{type:i}=e.field;switch(i){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,I(e.field,t.value))}}_renderDateOnlyFieldComponent(e,t){const{class:i,key:n,readOnly:o}=t,{rawMax:a,rawMin:s}=e.range;return V("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,class:i,"data-date-part":"date","data-element-id":t[U],key:`${n}-date-input`,max:l(a)?a:void 0,min:l(s)?s:void 0,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:o,value:e.value===C?"":e.value?String(e.value):"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{class:i,key:n,readOnly:o}=t;return V("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,class:i,"data-date-part":"time","data-element-id":t[U],key:`${n}-time-input`,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:o,value:e.value===C?"":e.value?String(e.value):"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{class:i,key:n,readOnly:o}=t,{rawMax:a,rawMin:s}=e.range,r=y(a),l=y(s),d=y(e.value===C?"":e.value),p=e.includeTimeOffset,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,overlayPositioning:"fixed",readOnly:o,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:h.dateInputContainer,key:`${n}-date-time-container`},V("calcite-input-date-picker",{...u,class:i,"data-date-part":"date",key:`${n}-date-input`,max:r?.date??void 0,min:l?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:d.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),V("calcite-input-time-picker",{...u,class:i,"data-date-part":"time",key:`${n}-time-input`,onblur:()=>{this._focusedFieldInput=null},value:d.time??"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),p?V("calcite-input-time-zone",{...u,class:i,"data-date-part":"timeZone",key:`${n}-timezone-input`,onblur:()=>{this._focusedFieldInput=null},value:d.timeZoneOffset??"0",onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:i,key:n,readOnly:o,min:a,max:s}=t,r=w(e.value===C?"":e.value),l=w(s),d=w(a),p=e.includeTime,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,overlayPositioning:"fixed",readOnly:o,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:h.dateInputContainer,key:`${n}-date-time-container`},V("calcite-input-date-picker",{...u,class:i,"data-date-part":"date",key:`${n}-date-input`,max:l?.date??void 0,min:d?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:r.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),p?V("calcite-input-time-picker",{...u,"data-date-part":"time",key:`${n}-time-input`,onblur:()=>{this._focusedFieldInput=null},step:1,value:r.time??"",onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}getCommonInputProps(e){const{_effectiveDisabled:t}=this,{template:i,valid:n,value:o,minLength:a,maxLength:s,required:r,fieldName:l,editable:d,userHasChangedValue:p,range:{max:u,min:c}}=e,m=!d||t;let v=i.hint??void 0,b=!1;return o===C&&(v=this.messages.differentValues,b=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":n?"false":"true",class:this.classes(h.fieldInput,m?h.inputDisabled:null),status:!p&&!this.viewModel.submitHasBeenAttempted||n?"idle":"invalid",maxLength:s&&s>-1?s:void 0,minLength:a&&a>-1?a:void 0,key:i.elementId,label:l,name:l,max:null!=u?u:void 0,min:null!=c?c:void 0,readOnly:m,onblur:this._onComponentBlur,required:r,placeholder:v,value:b?"":o??"",[U]:i.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(U))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),n=t||i;n&&this._afterComponentCreateOrUpdate(n)}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._touchedInputs.add(i.template.elementId),this._focusedFieldInput=i}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),i=this._focusedFieldInput;this._attemptFocusOnNextRender&&i===t&&(this._attemptFocusOnNextRender=!1,M(e))}_onComponentBlur(){this._focusedFieldInput=null}_parseValue(e,t){if(c(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const i of t.domain.codedValues)if(i.name===e.selectedItems[0].textContent)return i.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const i=e.value;return null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_saveInput(e){const t=this._getFieldInputFromHTMLElement(e),{elementId:n}=t.template;if(!t)return;const o=t?.value;if(c(t.template,"switch")&&"single"!==this.viewModel.mode){const e=i(this._batchSwitchInputInitialValues,t,(()=>t.value));this._batchSwitchInputInitialValues.set(t,null===e?o:e)}const a=this._parseValue(e,t);a!==o&&this.viewModel.setValue(n,a)}async _afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);await e.componentOnReady(),this._setDateTimeTimeZoneMap(e),this._updateDateTimeOrTimeZoneShadowDom(e,t.value===C),this._afterComponentCreateOrUpdate(e)}async _afterDateComponentUpdate(e){const{value:t}=this._getFieldInputFromHTMLElement(e);await e.componentOnReady(),this._updateDateTimeOrTimeZoneShadowDom(e,t===C),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:i}=e.template,n=e.field.type,o=this._dateComponentMap.get(`${i}`);if(!o)return;let a=e.value===C?void 0:e.value,s=null;"date-only"===n?s=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===n?(a=F(a),s=F(t.value)):s="timestamp-offset"===n?null!=t.value?x({dateComponent:o.date,timeComponent:o.time,oldValue:a,timeZoneComponent:o.timeZone}):null:null!=t.value?k({oldValue:a,dateComponent:o.date,timeComponent:o.time?.value===C?void 0:o.time}):null,a!==s&&(null!==s&&t.value?this.viewModel.setValue(`${i}`,s):this.viewModel.setValue(`${i}`,null))}};e([a()],R.prototype,"activeFeatureIndex",null),e([a()],R.prototype,"disabled",null),e([a()],R.prototype,"_effectiveDisabled",null),e([a()],R.prototype,"features",null),e([a()],R.prototype,"map",null),e([a()],R.prototype,"spatialReference",null),e([a()],R.prototype,"timeZone",null),e([a()],R.prototype,"headingLevel",void 0),e([a()],R.prototype,"icon",null),e([a(),O("esri/t9n/common")],R.prototype,"messagesCommon",void 0),e([a(),O("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],R.prototype,"messages",void 0),e([a()],R.prototype,"readOnly",void 0),e([a(),T(["value-change","submit"])],R.prototype,"viewModel",void 0),e([a({type:v,nonNullable:!0})],R.prototype,"visibleElements",void 0),e([a()],R.prototype,"groupDisplay",void 0),R=e([s("esri.widgets.BatchAttributeForm")],R);const L=R;export{L as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import"../core/has.js";import{abortHandle as t}from"../core/handleUtils.js";import{getOrCreateMapValue as i}from"../core/MapUtils.js";import{watch as n,whenOnce as o}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as r}from"../layers/support/fieldUtils.js";import{isString as l}from"../support/guards.js";import d from"./Widget.js";import{getHiddenFieldsValidationErrorMessage as p,getVisibleFieldInputValidationErrorMessage as u,isElementTemplateWithInputType as c}from"./BatchAttributeForm/batchAttributeFormUtils.js";import m from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as h}from"./BatchAttributeForm/css.js";import{VisibleElements as v}from"./BatchAttributeForm/VisibleElements.js";import{InputVisibilityCode as f,isGroupInput as b,isFieldInput as _,differentValuesString as C}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as I,getIntlOptionsForField as y,prepareISOFieldValueForDateComponents as F,prepareUnixFieldValueForDateComponents as w,normalizeTimeOnlyString as x,getISOFieldValueFromDateComponents as k,getUnixFieldValueFromDateComponents as D}from"./support/dateUtils.js";import{globalCss as O}from"./support/globalCss.js";import{setFocus as M}from"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{vmEvent as V}from"./support/decorators/vmEvent.js";import{tsx as S}from"./support/jsxFactory.js";import{isEmptyValue as E}from"./support/forms/formUtils.js";import{substitute as U}from"../intl/substitute.js";const R="data-element-id";let L=class extends d{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.readOnly=!1,this.viewModel=new m,this.visibleElements=new v,this.groupDisplay="all",this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._batchSwitchInputInitialValues=new Map,this._saveInput=this._saveInput.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentUpdate=this._afterDateComponentUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.features),(()=>{this._dateComponentMap.clear();const e=new AbortController;o((()=>!this.viewModel.updating),e.signal).then((()=>{this._attemptFocusOnNextRender=!0})),this.addHandles(t(e))})),n((()=>this.viewModel.activeForm),(()=>{this._batchSwitchInputInitialValues.clear()}))])}loadDependencies(){return g({input:()=>import("@esri/calcite-components/dist/components/calcite-input"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")})}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get _effectiveDisabled(){return this.disabled||this.viewModel.updating}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}goToClosestError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),setTimeout((()=>{if(!this.domNode)return;const t=this.domNode.querySelector(`[data-element-id="${e.input.template.elementId}"]`);t&&M(t)}),10)}render(){const{status:e}=this.viewModel;return"failed"===e?this._renderErrorNotice(this.messages.formFailedToLoad):this.viewModel.expressionEvaluationFailed?this._renderErrorNotice(this.messages.expressionEvaluationFailed):this.viewModel.hasLayersWithContingentValues?this._renderErrorNotice(this.messages.unsupportedContingentValues):S("div",{class:this.classes(h.base,O.widget,O.panel)},"loaded"===e?this._renderForm():"loading"===e?S("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):null)}_setDateTimeTimeZoneMap(e){const{datePart:t,elementId:n}=e.dataset,o=this._getCalciteElementFromDateTimeTimeZonePicker(e,t);if(!o)return;const a=i(this._dateComponentMap,`${n}`,(()=>({placeholder:{date:"",time:"",timeZone:""}})));switch(a.placeholder[t]=o.placeholder??"",t){case"date":a.date=e;break;case"time":a.time=e;break;case"timeZone":a.timeZone=e,a.defaultComboboxItemElements=o.selectedItems}"timeZone"===t&&(a.defaultComboboxItemElements=o.selectedItems)}_getCalciteElementFromDateTimeTimeZonePicker(e,t){const i=e.shadowRoot;return i?"timeZone"===t?i.querySelector("calcite-combobox"):i.querySelector("calcite-input-text"):null}_updateDateTimeOrTimeZoneShadowDom(e,t){const{datePart:i,elementId:n}=e.dataset,o=this._dateComponentMap.get(`${n}`);if(!o)return;const a=this._getCalciteElementFromDateTimeTimeZonePicker(e,i);if(a)switch(i){case"date":case"time":a.placeholder=t?this.messages.differentValues:o.placeholder[i];break;case"timeZone":t?(a.value="",a.placeholder=this.messages.differentValues):(!a.selectedItems.length&&o.defaultComboboxItemElements?.length&&(a.selectedItems[0]=o.defaultComboboxItemElements[0]),a.placeholder=o.placeholder[i])}}_renderErrorNotice(e){return S("div",{class:this.classes(h.base,O.widget,O.panel)},S("calcite-notice",{class:h.noticeError,icon:!0,kind:"warning",open:!0},S("div",{slot:"message"},e)))}_renderForm(){return S("form",{onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderContent())}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:i}=e;let n;if(!e.submitHasBeenAttempted)return null;if(i.invalidHiddenInputs.length>0)if(n=p(i,e.mode,this.messages),"batch"===this.viewModel.mode){const e=i.invalidHiddenInputs.filter((e=>e.effectiveVisibilityCode===f.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL||e.visibilityCode===f.HIDDEN_VISIBILITY_EXPRESSION_ALL));e.length>0?n+=` (${e.map((e=>e.label)).join(", ")})`:n=null}else n+=` (${i.invalidHiddenInputs.map((e=>e.label)).join(", ")})`;else if(t)return null;return n?S("calcite-notice",{class:h.noticeError,icon:!0,kind:"danger",open:!0},S("div",{slot:"message"},n)):null}_renderContent(){if(!this.viewModel.hasVisibleInputs)return[S("calcite-notice",{class:h.noticeError,icon:!0,kind:"warning",open:!0},S("div",{slot:"message"},this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason]))];const{inputs:e}=this.viewModel.activeForm;return e.filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return b(e)?this._renderGroupInput(e):_(e)?this._renderLabeledField(e):void 0}_renderGroupInput(e){const{inputs:t,template:i,open:n}=e,o=t.filter((e=>e.visible)),a=i.label??"";return S("calcite-block",{class:this.classes(h.group,"sequential"===this.groupDisplay?h.groupSequential:null,this.disabled?h.inputDisabled:null),collapsible:!0,description:i.description??void 0,disabled:this._effectiveDisabled,heading:a,headingLevel:this.headingLevel,key:`{${i.elementId}-key}`,label:a,open:n,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0}},o.map((e=>this._renderInput(e))))}_renderLabeledField(e){const{label:t,elementId:i}=e.template,{required:n,dataType:o}=e,a=n?U(this.messages.requiredFieldLabel,{name:t}):t;return S("calcite-label",{"aria-label":a,class:h.label,key:`field--${i}`},S("div",{class:h.labelTextContent,key:"labelTextContainer"},t,n?S("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==o?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:i}=e;return"date"===i?this._renderDateComponents(e,t):"coded-value"===e.domain?.type?this._renderCodedInputs({input:e,props:t}):"number"===i?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{compositeError:t,description:i,submittable:n}=e,o=!n&&t&&(this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId))?u(e,t,this.messages):null;return o?S("calcite-input-message",{icon:!0,status:"invalid"},o):i?S("calcite-input-message",{class:h.description,icon:!1,status:"idle"},i):null}_renderCodedInputs({input:e,props:t}){const i=e.template.input?.type??null,n=e.codedValueOptions;switch(i){case"switch":return this._renderSwitchField({input:e,props:t});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:n.flat(),props:t});default:return this._renderComboBoxComponent({options:n,props:t,input:e})}}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===C||e.value===C)&&"batch"===this.viewModel.mode){const i={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[R]:t[R]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:i,options:[{name:this.messages.differentValues,value:C,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return S("calcite-switch",{...t,checked:!!c(e.template,"switch")&&e.value===e.template.input.onValue,class:h.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInput(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:i}){const{trigger:n,dropdown:o,group:a}=i;return S("calcite-dropdown",{...o,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInput(e)},S("calcite-button",{...n},e===C?this.messages.differentValues:e),S("calcite-dropdown-group",{selectionMode:a.mode},t.map((t=>S("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name)))))}_renderComboBoxComponent({input:e,options:t,props:i}){const n="INSERT"===this.viewModel.editType,o=this._touchedInputs.has(e?.template?.elementId),a=n&&e.showNoValueOptionEnabled&&!o?()=>{}:i.onblur,s={...i,onblur:a};return S("calcite-combobox",{...s,selectionMode:"single",value:i.placeholder===this.messages.differentValues?C:String(i.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==C&&this._saveInput(e)}},this.renderComboboxOptionsList({input:e,options:t,props:i}))}renderComboboxOptionsList({input:e,options:t,props:i}){const[n,o]=t.map((e=>e.map((({name:e,value:t})=>S("calcite-combobox-item",{key:`#${t}`,selected:i.value===t,textLabel:e,value:`${t}`}))))),a=[...n];o.length>0&&a.push(S("calcite-combobox-item-group",{key:"unsupported",label:this.featureFormMessages.subtypes.unsupportedDomainGroupTitle},o));const s=i.placeholder===this.messages.differentValues,r=!s&&E(i.value);return e.showNoValueOptionEnabled&&a.unshift(S("calcite-combobox-item",{key:"empty-option",selected:r,textLabel:e.showNoValueLabel||this.messages.empty,value:""})),s&&a.unshift(S("calcite-combobox-item",{key:C,selected:!0,textLabel:this.messages.differentValues,value:C})),a}_renderRadioButtonGroupComponent({input:e,options:t,props:i}){const n=t.map((({name:t,value:n})=>this._renderRadioButtons({label:t,value:n,selected:n===e.value,props:i})));if(e.showNoValueOptionEnabled){const t="",o=e.showNoValueLabel||this.messages.empty,a=E(e.value);n.unshift(this._renderRadioButtons({label:o,value:t,selected:a,props:i}))}return S("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:h.inputRadioGroup,disabled:i.readOnly,key:`${i.key}-radio-group`,layout:"vertical",name:i.name,required:i.required},n,i.placeholder===this.messages.differentValues?S("calcite-label",{class:h.placeholderRadio,key:i.label,layout:"inline"},S("calcite-radio-button",{checked:!0,class:h.inputRadio,disabled:!0,name:i.placeholder,value:i.placeholder}),i.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:i,props:n}){return S("calcite-label",{class:h.inputRadioLabel,key:n.label,layout:"inline"},S("calcite-radio-button",{...n,afterCreate:void 0,afterUpdate:void 0,checked:t,class:h.inputRadio,disabled:n.readOnly,name:n.label,onblur:()=>{this._focusedFieldInput=null},value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInput(e)}}),i)}_renderStringComponent(e,t){const{template:i}=e;return i.field.editable?i.input&&"text-area"===i.input.type?S("calcite-text-area",{...t,class:this.classes(h.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):S("calcite-input",{...t,class:this.classes(h.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)}):this._renderReadOnlyComponent(e)}_renderNumberComponent(e,t){const i=r(e.field);return S("calcite-input-number",{...t,integer:i,type:"number",value:i&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInput(e)})}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return S("calcite-input",{...i,class:this.classes(h.fieldInput,h.inputDisabled,h.individualElement),readOnly:!0,type:"text",value:String(t??i.value??"")})}_renderDateComponents(e,t){const{type:i}=e.field;switch(i){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,I(e.field,t.value,{timeZone:e.effectiveTimeZone,...y(e.template.field)}))}}_renderDateOnlyFieldComponent(e,t){const{class:i,key:n,readOnly:o}=t,{rawMax:a,rawMin:s}=e.range;return S("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,class:i,"data-date-part":"date","data-element-id":t[R],key:`${n}-date-input`,max:l(a)?a:void 0,min:l(s)?s:void 0,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:o,value:e.value===C?"":e.value?String(e.value):"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{class:i,key:n,readOnly:o}=t;return S("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,class:i,"data-date-part":"time","data-element-id":t[R],key:`${n}-time-input`,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:o,value:e.value===C?"":e.value?String(e.value):"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{class:i,key:n,readOnly:o}=t,{rawMax:a,rawMin:s}=e.range,r=F(a),l=F(s),d=F(e.value===C?"":e.value),p=e.includeTimeOffset,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,overlayPositioning:"fixed",readOnly:o,[R]:t[R],onfocus:this._onComponentFocus};return S("div",{class:h.dateInputContainer,key:`${n}-date-time-container`},S("calcite-input-date-picker",{...u,class:i,"data-date-part":"date",key:`${n}-date-input`,max:r?.date??void 0,min:l?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:d.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),S("calcite-input-time-picker",{...u,class:i,"data-date-part":"time",key:`${n}-time-input`,onblur:()=>{this._focusedFieldInput=null},value:d.time??"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),p?S("calcite-input-time-zone",{...u,class:i,"data-date-part":"timeZone",key:`${n}-timezone-input`,onblur:()=>{this._focusedFieldInput=null},value:d.timeZoneOffset??"0",onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:i,key:n,readOnly:o,min:a,max:s}=t,r=e.effectiveTimeZone,l=w(e.value===C?"":e.value,r),d=w(s,r),p=w(a,r),u=e.includeTime,c={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,overlayPositioning:"fixed",readOnly:o,[R]:t[R],onfocus:this._onComponentFocus};return S("div",{class:h.dateInputContainer,key:`${n}-date-time-container`},S("calcite-input-date-picker",{...c,class:i,"data-date-part":"date",key:`${n}-date-input`,max:d?.date??void 0,min:p?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:l.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),u?S("calcite-input-time-picker",{...c,"data-date-part":"time",key:`${n}-time-input`,onblur:()=>{this._focusedFieldInput=null},step:1,value:l.time??"",onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}getCommonInputProps(e){const{_effectiveDisabled:t}=this,{template:i,valid:n,value:o,minLength:a,maxLength:s,required:r,fieldName:l,editable:d,userHasChangedValue:p,range:{max:u,min:c}}=e,m=!d||t;let v=i.hint??void 0,f=!1;return o===C&&(v=this.messages.differentValues,f=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":n?"false":"true",class:this.classes(h.fieldInput,m?h.inputDisabled:null),status:!p&&!this.viewModel.submitHasBeenAttempted||n?"idle":"invalid",maxLength:s&&s>-1?s:void 0,minLength:a&&a>-1?a:void 0,key:i.elementId,label:l,name:l,max:null!=u?u:void 0,min:null!=c?c:void 0,readOnly:m,onblur:this._onComponentBlur,required:r,placeholder:v,value:f?"":o??"",[R]:i.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(R))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),n=t||i;n&&this._afterComponentCreateOrUpdate(n)}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._touchedInputs.add(i.template.elementId),this._focusedFieldInput=i}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),i=this._focusedFieldInput;this._attemptFocusOnNextRender&&i===t&&(this._attemptFocusOnNextRender=!1,M(e))}_onComponentBlur(){this._focusedFieldInput=null}_parseValue(e,t){if(c(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const i of t.domain.codedValues)if(i.name===e.selectedItems[0].textContent)return i.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const i=e.value;return null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_saveInput(e){const t=this._getFieldInputFromHTMLElement(e),{elementId:n}=t.template;if(!t)return;const o=t?.value;if(c(t.template,"switch")&&"single"!==this.viewModel.mode){const e=i(this._batchSwitchInputInitialValues,t,(()=>t.value));this._batchSwitchInputInitialValues.set(t,null===e?o:e)}const a=this._parseValue(e,t);a!==o&&this.viewModel.setValue(n,a)}async _afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);await e.componentOnReady(),this._setDateTimeTimeZoneMap(e),this._updateDateTimeOrTimeZoneShadowDom(e,t.value===C),this._afterComponentCreateOrUpdate(e)}async _afterDateComponentUpdate(e){const{value:t}=this._getFieldInputFromHTMLElement(e);await e.componentOnReady(),this._updateDateTimeOrTimeZoneShadowDom(e,t===C),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:i}=e.template,n=e.field.type,o=this._dateComponentMap.get(`${i}`);if(!o)return;const a=e.effectiveTimeZone;let s=e.value===C?void 0:e.value,r=null;"date-only"===n?r=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===n?(s=x(s),r=x(t.value)):r="timestamp-offset"===n?null!=t.value?k({dateComponent:o.date,timeComponent:o.time,oldValue:s,timeZoneComponent:o.timeZone,defaultTimeZone:a}):null:null!=t.value?D({oldValue:s,dateComponent:o.date,timeZone:a,timeComponent:o.time?.value===C?void 0:o.time}):null,s!==r&&(null!==r&&t.value?this.viewModel.setValue(`${i}`,r):this.viewModel.setValue(`${i}`,null))}};e([a()],L.prototype,"activeFeatureIndex",null),e([a()],L.prototype,"disabled",null),e([a()],L.prototype,"_effectiveDisabled",null),e([a()],L.prototype,"features",null),e([a()],L.prototype,"map",null),e([a()],L.prototype,"spatialReference",null),e([a()],L.prototype,"timeZone",null),e([a()],L.prototype,"headingLevel",void 0),e([a()],L.prototype,"icon",null),e([a(),T("esri/t9n/common")],L.prototype,"messagesCommon",void 0),e([a(),T("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],L.prototype,"messages",void 0),e([a(),T("esri/widgets/FeatureForm/t9n/FeatureForm")],L.prototype,"featureFormMessages",void 0),e([a()],L.prototype,"readOnly",void 0),e([a(),V(["value-change","submit"])],L.prototype,"viewModel",void 0),e([a({type:v,nonNullable:!0})],L.prototype,"visibleElements",void 0),e([a()],L.prototype,"groupDisplay",void 0),L=e([s("esri.widgets.BatchAttributeForm")],L);const j=L;export{j 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 t from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as s,isAbortError as a}from"../../core/promiseUtils.js";import{watch as l,on as n,syncAndInitial as u,when as d}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{resolveTimeZone as p,convertDateFormatToIntlOptions as m,formatTimestamp as v}from"../../intl/date.js";import{getLocale as y,getLocaleParts as g}from"../../intl/locale.js";import{fetchServiceDescription as f}from"../../rest/networkService.js";import w from"../../rest/support/RouteParameters.js";import _ from"../../rest/support/Stop.js";import T from"../../rest/support/TravelMode.js";import{defaultDatePattern as S,defaultTimePattern as D}from"../../support/dateUtils.js";import{system as C,shortTimeZoneName as b}from"../../time/timeZoneUtils.js";import{DepartureTimeOption as M}from"./support/directionsUtils.js";import{getDefaultLocaleOptions as A}from"../support/dateUtils.js";import I from"../support/GoTo.js";import{DateTime as L,FixedOffsetZone as j,IANAZone as R}from"luxon";function P(e){return e.map((e=>({locale:e,parts:g(e)}))).filter((({parts:e})=>!!e))}function E(e,t){return e.find((({parts:e})=>F(e.language,t.language)&&e.region===t.region))?.locale??e.find((({parts:e})=>F(e.language,t.language)))?.locale}function U(e){return"esri.Graphic"===e?.declaredClass}function N(e){return"no"===e||"nb"===e}function F(e,t){return e===t||N(e)&&N(t)}function O(e){return"esri.rest.support.Stop"===e?.declaredClass}var k;!function(e){e[e.Active=0]="Active",e[e.Complete=1]="Complete",e[e.Failed=2]="Failed",e[e.Idle=3]="Idle",e[e.Suspended=4]="Suspended"}(k||(k={}));let V=class extends(I(i.EventedAccessor)){constructor(e){super(e),this._debouncedSolveHandler=s((async e=>{switch(e.type){case"create":if("complete"!==e.state)return;break;case"delete":break;case"update":switch(e.state){case"start":return void(this._networkFeatureUpdated=!1);case"active":return void(this._networkFeatureUpdated=!0);case"complete":if(!this._networkFeatureUpdated)return}}if(!((this.layer?.stops.filter((({geometry:e})=>!!e)).length??0)<2)&&this.autoSolve)try{await this.getDirections({zoomToSolvedRoute:!1})}catch(t){o.getLogger(this).error(t)}})),this._highlight=null,this._loadController=null,this._loadPromise=null,this._networkFeatureUpdated=!1,this._layerView=null,this._routeController=null,this._serviceDescriptionStatus=k.Idle,this.apiKey=void 0,this.autoSolve=!0,this.defaultTravelMode=null,this.departureIsoDate=null,this.departureIsoTime=null,this.departureOption=M.NOW,this.departureTime="now",this.lastError=null,this.lastRoute=null,this.layer=null,this.maxStops=50,this.routeParameters=new w({directionsLengthUnits:"kilometers",findBestSequence:!1,preserveFirstStop:!0,preserveLastStop:!0,returnZ:!0,useTimeWindows:!1}),this.serviceDescription=null,this.view=null}initialize(){this.addHandles([l((()=>this.layer),(e=>{if(null!=e){for(;e.stops.length<2;)e.stops.add(new _);this._set("defaultTravelMode",null),this.addHandles(d((()=>this.serviceDescription?e.routeInfo?.analysisSettings?.travelMode:null),(e=>{this.defaultTravelMode=this._resolveDefaultTravelMode(e)}),{once:!0}))}}),u),l((()=>[this.layer,this.view]),(async()=>{this._layerView=await this._getRouteLayerView()}),u),n((()=>this._layerView),["create","delete","update"],(e=>{this._debouncedSolveHandler(e).catch((e=>{if(!a(e))throw e}))}))]);const e=p(this.view?.timeZone??C),t=L.fromMillis(Date.now());this.departureIsoDate=t.toFormat(S,A(e)),this.departureIsoTime=t.toFormat(D,A(e))}get _directionsLanguage(){const e=this.serviceDescription?.directionsSupportedLanguages;if(!e)return;const t=this.routeParameters.directionsLanguage??y(),r=g(t),i=r?.language,o=r?.region;if(!i)return;return E(P(e),{language:i,region:o})}get formattedEta(){const e=this.layer?.routeInfo?.endTime,t=this.layer?.routeInfo?.endTimeOffset;if(this.departureOption===M.UNSPECIFIED||!e||!t)return null;const r=L.fromJSDate(e,{zone:j.instance(t)}),i=L.fromJSDate(e,{zone:R.create(p(this.view?.timeZone??C))}),o=L.fromJSDate(new Date,{zone:R.create(p(this.view?.timeZone??C))}),s=o.year===i.year&&o.month===i.month&&o.day===i.day,a=i.offset===t?void 0:b,l=s?void 0:m("short-date"),n=m("short-time");return v(r.toISO(),{...l,...n,timeZoneName:a})}get impedanceAttribute(){const e=this.routeParameters.travelMode?.impedanceAttributeName??this.routeParameters.impedanceAttribute??this.serviceDescription?.impedance??null;return this.getCostAttribute(e)}get selectedNetworkFeatures(){return this._layerView?.selectedNetworkFeatures??null}get selectedTravelMode(){return this.serviceDescription?this.defaultTravelMode??this.serviceDescription.defaultTravelMode??this.serviceDescription.supportedTravelModes?.[0]??null:null}set selectedTravelMode(e){this._override("selectedTravelMode",e)}get state(){if(this._routeController)return"routing";if(this.lastError)return"error";switch(this._serviceDescriptionStatus){case k.Suspended:return"unauthenticated";case k.Idle:return"disabled";case k.Active:return"initializing";case k.Failed:return"error";default:return"ready"}}get timeAttribute(){const e=this.routeParameters.travelMode?.timeAttributeName??this.routeParameters.directionsTimeAttribute??this.serviceDescription?.directionsTimeAttribute??null;return this.getCostAttribute(e)}get travelModes(){const e=this.serviceDescription?.supportedTravelModes?.slice()??[];return null==this.defaultTravelMode||e.includes(this.defaultTravelMode)||e.unshift(this.defaultTravelMode),e}async load(){if(this._loadPromise)return this._loadPromise;this._loadPromise=this._load(),await this._loadPromise,this._loadPromise=null}async highlight(e){if(this.clearHighlights(),!this.view||!this.layer)return;const t=await this.view.whenLayerView(this.layer);this._highlight=t.highlight(e)}clearHighlights(){null!=this._highlight&&(this._highlight.remove(),this._highlight=null)}centerAt(e){if(!this.view)return;const t=O(e)||U(e)?e.geometry:e;t&&this.callGoTo({target:t})}clearResults(){this._set("lastRoute",null),this.layer?.removeResult()}async create(e){await(this._layerView?.create(e))}async getDirections(e={zoomToSolvedRoute:!0}){const{apiKey:t,layer:i,state:o}=this;if(!i)throw new r("directions-view-model:missing-route-layer","A route layer must be associated with the view model.");if("unauthenticated"===o||"initializing"===o||"disabled"===o||this._serviceDescriptionStatus===k.Failed)throw new r("directions-view-model:not-loaded","Cannot get directions until view model loads.");null!=this._routeController&&(this._routeController.abort(),this._routeController=null);const{startTime:s,startTimeIsUTC:l}=this._getStartTimeParameters(),n=this.view?.spatialReference??null,u=this.routeParameters.clone();u.set({apiKey:t,directionsLanguage:this._directionsLanguage,outSpatialReference:n,startTime:s,startTimeIsUTC:l}),this.selectedTravelMode&&(u.travelMode=this.selectedTravelMode);if(i.stops.filter((({geometry:e})=>null!=e)).length<2){const e=new r("directions-view-model:not-enough-stops","Not enough stops for routing");throw this._set("lastError",e),e}this._routeController=new AbortController;const{signal:d}=this._routeController;let c=null;try{c=await i.solve(u,{signal:d})}catch(h){if(!a(h)){const e=new r("directions-view-model:unable-to-route","Unable to route to these addresses",{error:h});throw this._set("lastError",e),this.clearResults(),e}}finally{this._routeController=null}this._set("lastError",null);for(const r of c.stops)null==r.geometry&&(r.name=null);return i.update(c),this._set("lastRoute",c),e.zoomToSolvedRoute&&this.zoomToRoute(),c}getCostAttribute(e){return(this.serviceDescription?.networkDataset?.networkAttributes??[]).find((({name:t,usageType:r})=>t===e&&"cost"===r))??null}remove(e){this._layerView?.remove(e)}reset(){this.clearHighlights(),this.clearResults(),null!=this.layer&&(this.layer.removeAll(),this.layer.stops=new t([new _,new _]))}save(){if(!this.layer)throw new r("directions-view-model:missing-layer","save() requires a layer");return this.layer.save()}saveAs(e,t={}){if(!this.layer)throw new r("directions-view-model:missing-layer","saveAs() requires a layer");return this.layer.saveAs(e,t)}async startEditing(){this._layerView&&(this._layerView.interactive=!0)}async stopEditing(){this._layerView&&(this._layerView.interactive=!1)}updateDepartureTime(){if(this.departureIsoDate&&this.departureIsoTime)switch(this.departureOption){case M.NOW:this.departureTime="now";break;case M.DEPART_AT:{const e=L.fromISO(`${this.departureIsoDate}T${this.departureIsoTime}`,{zone:j.instance(0)});this.departureTime=e.toJSDate();break}case M.UNSPECIFIED:this.departureTime=null}}zoomToRoute(){const{view:e,layer:t}=this,r=t?.routeInfo?.geometry?.extent;if(!e||!r)return;const i=r.width>r.height,o=r.clone().expand(i?2:1);this.callGoTo({target:o})}async _getRouteLayerView(){return this.view&&this.layer?this.view.whenLayerView(this.layer):null}_getStartTimeParameters(){if("now"===this.departureTime){return{startTime:this.serviceDescription?.capabilities.supportsNow??!1?"now":new Date,startTimeIsUTC:!0}}return null==this.departureTime?{startTime:void 0,startTimeIsUTC:void 0}:{startTime:this.departureTime,startTimeIsUTC:!1}}async _load(){if(null==this.layer)return;null!=this._loadController&&(this._loadController.abort(),this._loadController=null),this._loadController=new AbortController;const{signal:e}=this._loadController;try{this._serviceDescriptionStatus=k.Active;const t=await f(this.layer.url,this.apiKey,{signal:e});this._set("serviceDescription",t),this._serviceDescriptionStatus=k.Complete}catch(t){if(a(t))return void(this._serviceDescriptionStatus=k.Idle);if("identity-manager:user-aborted"===t.name)return void(this._serviceDescriptionStatus=k.Suspended);const e=new r("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:t});throw this._serviceDescriptionStatus=k.Failed,this._set("lastError",e),e}finally{this._loadController=null}}_resolveDefaultTravelMode(e){if(null==this.serviceDescription)return null;const{defaultTravelMode:t,supportedTravelModes:r}=this.serviceDescription,i=/^<(?<name>.*)>$/i.exec(e.name)?.groups?.name;if(i){const o=r?.find((({name:e})=>e.toLocaleLowerCase()===i.trim().toLocaleLowerCase())),s=o??t;return T.fromJSON({...s?.toJSON(),...e.toJSON()})}const o=r?.find((({name:t})=>t.toLocaleLowerCase()===e.name.toLocaleLowerCase()));return o??t}};e([c()],V.prototype,"_directionsLanguage",null),e([c()],V.prototype,"_layerView",void 0),e([c()],V.prototype,"_routeController",void 0),e([c()],V.prototype,"_serviceDescriptionStatus",void 0),e([c()],V.prototype,"apiKey",void 0),e([c()],V.prototype,"autoSolve",void 0),e([c()],V.prototype,"defaultTravelMode",void 0),e([c()],V.prototype,"departureTime",void 0),e([c()],V.prototype,"formattedEta",null),e([c({readOnly:!0})],V.prototype,"impedanceAttribute",null),e([c()],V.prototype,"lastError",void 0),e([c({readOnly:!0})],V.prototype,"lastRoute",void 0),e([c()],V.prototype,"layer",void 0),e([c({type:Number,range:{min:2,max:50},nonNullable:!0})],V.prototype,"maxStops",void 0),e([c({type:w,nonNullable:!0})],V.prototype,"routeParameters",void 0),e([c({readOnly:!0})],V.prototype,"selectedNetworkFeatures",null),e([c({type:T})],V.prototype,"selectedTravelMode",null),e([c({readOnly:!0})],V.prototype,"serviceDescription",void 0),e([c({readOnly:!0})],V.prototype,"state",null),e([c({readOnly:!0})],V.prototype,"timeAttribute",null),e([c()],V.prototype,"travelModes",null),e([c()],V.prototype,"view",void 0),e([c()],V.prototype,"zoomToRoute",null),V=e([h("esri.widgets.Directions.DirectionsViewModel")],V);const z=V;export{z as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as s,isAbortError as a}from"../../core/promiseUtils.js";import{watch as l,on as n,syncAndInitial as u,when as d}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{resolveTimeZone as p,convertDateFormatToIntlOptions as m,formatTimestamp as v}from"../../intl/date.js";import{getLocale as y,getLocaleParts as g}from"../../intl/locale.js";import{fetchServiceDescription as f}from"../../rest/networkService.js";import w from"../../rest/support/RouteParameters.js";import _ from"../../rest/support/Stop.js";import T from"../../rest/support/TravelMode.js";import{defaultDatePattern as S,defaultTimePattern as D}from"../../support/dateUtils.js";import{system as C,shortTimeZoneName as b}from"../../time/timeZoneUtils.js";import{DepartureTimeOption as M}from"./support/directionsUtils.js";import{getDefaultLocaleOptions as A}from"../support/dateUtils.js";import I from"../support/GoTo.js";import{DateTime as L,FixedOffsetZone as j,IANAZone as R}from"luxon";function P(e){return e.map((e=>({locale:e,parts:g(e)}))).filter((({parts:e})=>!!e))}function E(e,t){return e.find((({parts:e})=>F(e.language,t.language)&&e.region===t.region))?.locale??e.find((({parts:e})=>F(e.language,t.language)))?.locale}function U(e){return"esri.Graphic"===e?.declaredClass}function N(e){return"no"===e||"nb"===e}function F(e,t){return e===t||N(e)&&N(t)}function O(e){return"esri.rest.support.Stop"===e?.declaredClass}var k;!function(e){e[e.Active=0]="Active",e[e.Complete=1]="Complete",e[e.Failed=2]="Failed",e[e.Idle=3]="Idle",e[e.Suspended=4]="Suspended"}(k||(k={}));let V=class extends(I(i.EventedAccessor)){constructor(e){super(e),this._debouncedSolveHandler=s((async e=>{switch(e.type){case"create":if("complete"!==e.state)return;break;case"delete":break;case"update":switch(e.state){case"start":return void(this._networkFeatureUpdated=!1);case"active":return void(this._networkFeatureUpdated=!0);case"complete":if(!this._networkFeatureUpdated)return}}if(!((this.layer?.stops.filter((({geometry:e})=>!!e)).length??0)<2)&&this.autoSolve)try{await this.getDirections({zoomToSolvedRoute:!1})}catch(t){o.getLogger(this).error(t)}})),this._highlight=null,this._loadController=null,this._loadPromise=null,this._networkFeatureUpdated=!1,this._layerView=null,this._routeController=null,this._serviceDescriptionStatus=k.Idle,this.apiKey=void 0,this.autoSolve=!0,this.defaultTravelMode=null,this.departureIsoDate=void 0,this.departureIsoTime=void 0,this.departureOption=M.NOW,this.departureTime="now",this.lastError=null,this.lastRoute=null,this.layer=null,this.maxStops=50,this.routeParameters=new w({directionsLengthUnits:"kilometers",findBestSequence:!1,preserveFirstStop:!0,preserveLastStop:!0,returnZ:!0,useTimeWindows:!1}),this.serviceDescription=null,this.view=null}initialize(){this.addHandles([l((()=>this.layer),(e=>{if(null!=e){for(;e.stops.length<2;)e.stops.add(new _);this._set("defaultTravelMode",null),this.addHandles(d((()=>this.serviceDescription?e.routeInfo?.analysisSettings?.travelMode:null),(e=>{this.defaultTravelMode=this._resolveDefaultTravelMode(e)}),{once:!0}))}}),u),l((()=>[this.layer,this.view]),(async()=>{this._layerView=await this._getRouteLayerView()}),u),n((()=>this._layerView),["create","delete","update"],(e=>{this._debouncedSolveHandler(e).catch((e=>{if(!a(e))throw e}))}))]);const e=p(this.view?.timeZone??C),t=L.fromMillis(Date.now());this.departureIsoDate=t.toFormat(S,A(e)),this.departureIsoTime=t.toFormat(D,A(e))}get _directionsLanguage(){const e=this.serviceDescription?.directionsSupportedLanguages;if(!e)return;const t=this.routeParameters.directionsLanguage??y(),r=g(t),i=r?.language,o=r?.region;if(!i)return;return E(P(e),{language:i,region:o})}get formattedEta(){const e=this.layer?.routeInfo?.endTime,t=this.layer?.routeInfo?.endTimeOffset;if(this.departureOption===M.UNSPECIFIED||!e||!t)return null;const r=L.fromJSDate(e,{zone:j.instance(t)}),i=L.fromJSDate(e,{zone:R.create(p(this.view?.timeZone??C))}),o=L.fromJSDate(new Date,{zone:R.create(p(this.view?.timeZone??C))}),s=o.year===i.year&&o.month===i.month&&o.day===i.day,a=i.offset===t?void 0:b,l=s?void 0:m("short-date"),n=m("short-time");return v(r.toISO(),{...l,...n,timeZoneName:a})}get impedanceAttribute(){const e=this.routeParameters.travelMode?.impedanceAttributeName??this.routeParameters.impedanceAttribute??this.serviceDescription?.impedance??null;return this.getCostAttribute(e)}get selectedNetworkFeatures(){return this._layerView?.selectedNetworkFeatures??null}get selectedTravelMode(){return this.serviceDescription?this.defaultTravelMode??this.serviceDescription.defaultTravelMode??this.serviceDescription.supportedTravelModes?.[0]??null:null}set selectedTravelMode(e){this._override("selectedTravelMode",e)}get state(){if(this._routeController)return"routing";if(this.lastError)return"error";switch(this._serviceDescriptionStatus){case k.Suspended:return"unauthenticated";case k.Idle:return"disabled";case k.Active:return"initializing";case k.Failed:return"error";default:return"ready"}}get timeAttribute(){const e=this.routeParameters.travelMode?.timeAttributeName??this.routeParameters.directionsTimeAttribute??this.serviceDescription?.directionsTimeAttribute??null;return this.getCostAttribute(e)}get travelModes(){const e=this.serviceDescription?.supportedTravelModes?.slice()??[];return null==this.defaultTravelMode||e.includes(this.defaultTravelMode)||e.unshift(this.defaultTravelMode),e}async load(){if(this._loadPromise)return this._loadPromise;this._loadPromise=this._load(),await this._loadPromise,this._loadPromise=null}async highlight(e){if(this.clearHighlights(),!this.view||!this.layer)return;const t=await this.view.whenLayerView(this.layer);this._highlight=t.highlight(e)}clearHighlights(){null!=this._highlight&&(this._highlight.remove(),this._highlight=null)}centerAt(e){if(!this.view)return;const t=O(e)||U(e)?e.geometry:e;t&&this.callGoTo({target:t})}clearResults(){this._set("lastRoute",null),this.layer?.removeResult()}async create(e){await(this._layerView?.create(e))}async getDirections(e={zoomToSolvedRoute:!0}){const{apiKey:t,layer:i,state:o}=this;if(!i)throw new r("directions-view-model:missing-route-layer","A route layer must be associated with the view model.");if("unauthenticated"===o||"initializing"===o||"disabled"===o||this._serviceDescriptionStatus===k.Failed)throw new r("directions-view-model:not-loaded","Cannot get directions until view model loads.");null!=this._routeController&&(this._routeController.abort(),this._routeController=null);const{startTime:s,startTimeIsUTC:l}=this._getStartTimeParameters(),n=this.view?.spatialReference??null,u=this.routeParameters.clone();u.set({apiKey:t,directionsLanguage:this._directionsLanguage,outSpatialReference:n,startTime:s,startTimeIsUTC:l}),this.selectedTravelMode&&(u.travelMode=this.selectedTravelMode);if(i.stops.filter((({geometry:e})=>null!=e)).length<2){const e=new r("directions-view-model:not-enough-stops","Not enough stops for routing");throw this._set("lastError",e),e}this._routeController=new AbortController;const{signal:d}=this._routeController;let c=null;try{c=await i.solve(u,{signal:d})}catch(h){if(!a(h)){const e=new r("directions-view-model:unable-to-route","Unable to route to these addresses",{error:h});throw this._set("lastError",e),this.clearResults(),e}}finally{this._routeController=null}this._set("lastError",null);for(const r of c.stops)null==r.geometry&&(r.name=null);return i.update(c),this._set("lastRoute",c),e.zoomToSolvedRoute&&this.zoomToRoute(),c}getCostAttribute(e){return(this.serviceDescription?.networkDataset?.networkAttributes??[]).find((({name:t,usageType:r})=>t===e&&"cost"===r))??null}remove(e){this._layerView?.remove(e)}reset(){this.clearHighlights(),this.clearResults(),null!=this.layer&&(this.layer.removeAll(),this.layer.stops=new t([new _,new _]))}save(){if(!this.layer)throw new r("directions-view-model:missing-layer","save() requires a layer");return this.layer.save()}saveAs(e,t={}){if(!this.layer)throw new r("directions-view-model:missing-layer","saveAs() requires a layer");return this.layer.saveAs(e,t)}async startEditing(){this._layerView&&(this._layerView.interactive=!0)}async stopEditing(){this._layerView&&(this._layerView.interactive=!1)}updateDepartureTime(){if(this.departureIsoDate&&this.departureIsoTime)switch(this.departureOption){case M.NOW:this.departureTime="now";break;case M.DEPART_AT:{const e=L.fromISO(`${this.departureIsoDate}T${this.departureIsoTime}`,{zone:j.instance(0)});this.departureTime=e.toJSDate();break}case M.UNSPECIFIED:this.departureTime=null}}zoomToRoute(){const{view:e,layer:t}=this,r=t?.routeInfo?.geometry?.extent;if(!e||!r)return;const i=r.width>r.height,o=r.clone().expand(i?2:1);this.callGoTo({target:o})}async _getRouteLayerView(){return this.view&&this.layer?this.view.whenLayerView(this.layer):null}_getStartTimeParameters(){if("now"===this.departureTime){return{startTime:this.serviceDescription?.capabilities.supportsNow??!1?"now":new Date,startTimeIsUTC:!0}}return null==this.departureTime?{startTime:void 0,startTimeIsUTC:void 0}:{startTime:this.departureTime,startTimeIsUTC:!1}}async _load(){if(null==this.layer)return;null!=this._loadController&&(this._loadController.abort(),this._loadController=null),this._loadController=new AbortController;const{signal:e}=this._loadController;try{this._serviceDescriptionStatus=k.Active;const t=await f(this.layer.url,this.apiKey,{signal:e});this._set("serviceDescription",t),this._serviceDescriptionStatus=k.Complete}catch(t){if(a(t))return void(this._serviceDescriptionStatus=k.Idle);if("identity-manager:user-aborted"===t.name)return void(this._serviceDescriptionStatus=k.Suspended);const e=new r("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:t});throw this._serviceDescriptionStatus=k.Failed,this._set("lastError",e),e}finally{this._loadController=null}}_resolveDefaultTravelMode(e){if(null==this.serviceDescription)return null;const{defaultTravelMode:t,supportedTravelModes:r}=this.serviceDescription,i=/^<(?<name>.*)>$/i.exec(e.name)?.groups?.name;if(i){const o=r?.find((({name:e})=>e.toLocaleLowerCase()===i.trim().toLocaleLowerCase())),s=o??t;return T.fromJSON({...s?.toJSON(),...e.toJSON()})}const o=r?.find((({name:t})=>t.toLocaleLowerCase()===e.name.toLocaleLowerCase()));return o??t}};e([c()],V.prototype,"_directionsLanguage",null),e([c()],V.prototype,"_layerView",void 0),e([c()],V.prototype,"_routeController",void 0),e([c()],V.prototype,"_serviceDescriptionStatus",void 0),e([c()],V.prototype,"apiKey",void 0),e([c()],V.prototype,"autoSolve",void 0),e([c()],V.prototype,"defaultTravelMode",void 0),e([c()],V.prototype,"departureTime",void 0),e([c()],V.prototype,"formattedEta",null),e([c({readOnly:!0})],V.prototype,"impedanceAttribute",null),e([c()],V.prototype,"lastError",void 0),e([c({readOnly:!0})],V.prototype,"lastRoute",void 0),e([c()],V.prototype,"layer",void 0),e([c({type:Number,range:{min:2,max:50},nonNullable:!0})],V.prototype,"maxStops",void 0),e([c({type:w,nonNullable:!0})],V.prototype,"routeParameters",void 0),e([c({readOnly:!0})],V.prototype,"selectedNetworkFeatures",null),e([c({type:T})],V.prototype,"selectedTravelMode",null),e([c({readOnly:!0})],V.prototype,"serviceDescription",void 0),e([c({readOnly:!0})],V.prototype,"state",null),e([c({readOnly:!0})],V.prototype,"timeAttribute",null),e([c()],V.prototype,"travelModes",null),e([c()],V.prototype,"view",void 0),e([c()],V.prototype,"zoomToRoute",null),V=e([h("esri.widgets.Directions.DirectionsViewModel")],V);const z=V;export{z as default};