@arcgis/core 5.1.0-next.101 → 5.1.0-next.102

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 (104) hide show
  1. package/arcgisGlobal.d.ts +1449 -0
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{99f726f05cf80b0330ed.js → 119b84f5349f90d1dd28.js} +1 -1
  4. package/assets/esri/core/workers/chunks/15167eeb6d7dbe7e392d.js +1 -0
  5. package/assets/esri/core/workers/chunks/{156efa014b6edd9ccce9.js → 1ba37706e5d5eaabcb8e.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{7bb17d0ab1cc2b89c035.js → 1faa8a42d5a437fc40a3.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{38b1d2ffcc318ac0119d.js → 48fcc10768d93e95a04e.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{53bf9b0c2b8da12820ea.js → 55ccb8ed7325efb62091.js} +2 -2
  9. package/assets/esri/core/workers/chunks/{17de1c251242b692cf45.js → 5663df3cd1dfd4b43c73.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{5b07f3253403fe25ce5b.js → 5bc299f7f89a07a6e6a6.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{00a25dd4b057cc9f2a7e.js → 6f96ce41c47cae82e687.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{657268b3fde6da2dd735.js → 86bff154d46f8a562887.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{22fa4aa2b76573bafe21.js → 9e7c84a3a2abec4d49df.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{40ffb1aa17cbfae17b23.js → bb5512ecb5300d45d46b.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{d8c4fb66c733ab2f66d3.js → bb81da98546c4d923e0d.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{a58662698c69190a12d8.js → de25311b6d13bf1c6089.js} +2 -2
  17. package/assets/esri/core/workers/chunks/{bafe489e54f34d1841e6.js → e86c073f0b6d395c7a38.js} +1 -1
  18. package/assets/esri/core/workers/chunks/f5bd0a4f82df5e942b70.js +1 -0
  19. package/assets/esri/core/workers/chunks/{48a0e7a32ebd44045c8f.js → fa38dc5010f8630a80fe.js} +1 -1
  20. package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +125 -0
  21. package/assets/esri/themes/base/widgets/_Directions.scss +5 -1
  22. package/assets/esri/themes/dark/main.css +1 -1
  23. package/assets/esri/themes/light/main.css +1 -1
  24. package/assets/esri/themes/light/view.css +1 -1
  25. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm.json +1 -1
  26. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_en.json +1 -1
  27. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer.json +1 -1
  28. package/config.js +1 -1
  29. package/form/elements/inputs/MultipleChoiceInput.d.ts +5 -5
  30. package/form/elements/inputs/MultipleChoiceInput.js +1 -1
  31. package/interfaces.d.ts +3 -0
  32. package/kernel.js +1 -1
  33. package/layers/FeatureLayer.d.ts +29 -39
  34. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  35. package/layers/OrientedImageryLayer.d.ts +233 -0
  36. package/layers/OrientedImageryLayer.js +1 -1
  37. package/layers/VideoLayer.d.ts +35 -9
  38. package/layers/VideoLayer.js +1 -1
  39. package/layers/catalog/CatalogFootprintLayer.d.ts +147 -0
  40. package/layers/support/FeatureReductionBinning.d.ts +87 -9
  41. package/layers/support/FeatureReductionCluster.d.ts +87 -9
  42. package/layers/support/FieldConfiguration.d.ts +1 -1
  43. package/layers/support/SubtypeSublayer.d.ts +147 -0
  44. package/layers/support/TelemetryData.d.ts +5 -0
  45. package/layers/support/TelemetryData.js +1 -1
  46. package/layers/support/TelemetryDisplay.d.ts +10 -2
  47. package/layers/support/TelemetryDisplay.js +1 -1
  48. package/layers/video/VideoController.js +1 -1
  49. package/layers/video/types.d.ts +8 -1
  50. package/layers/video/videoUtils.js +1 -1
  51. package/package.json +2 -2
  52. package/portal/jsonTypes.d.ts +7 -0
  53. package/rest/print.js +1 -1
  54. package/rest/support/PrintParameters.d.ts +8 -1
  55. package/rest/support/PrintParameters.js +1 -1
  56. package/support/revision.js +1 -1
  57. package/third-party-notices.txt +4 -0
  58. package/views/2d/engine/webgl/shaderGraph/graph/GlslGraphWriter.js +1 -1
  59. package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +1 -1
  60. package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphNode.js +1 -1
  61. package/views/2d/engine/webgl/shaderGraph/graph/glsl.js +1 -1
  62. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityPolygonShader.js +1 -1
  63. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/BloomShader.js +1 -1
  64. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/AspectShader.js +1 -1
  65. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/CurvatureShader.js +1 -1
  66. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/MaskShader.js +1 -1
  67. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/RemapShader.js +1 -1
  68. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/SlopeShader.js +1 -1
  69. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
  70. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/surface.js +1 -1
  71. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  72. package/views/2d/layers/VideoLayerView2D.js +1 -1
  73. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  74. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  75. package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
  76. package/views/Viewport2DBaseMixin.js +1 -1
  77. package/widgets/Attachments/support/attachmentUtils.js +1 -1
  78. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.d.ts +8 -1
  79. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  80. package/widgets/BatchAttributeForm/attachmentUtils.js +2 -0
  81. package/widgets/BatchAttributeForm/css.js +1 -1
  82. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  83. package/widgets/BatchAttributeForm/templates/RelationshipElementTemplate.js +1 -1
  84. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  85. package/widgets/BatchAttributeForm/templates/support/hashElementTemplate.js +1 -1
  86. package/widgets/BatchAttributeForm/types.d.ts +7 -0
  87. package/widgets/BatchAttributeForm.js +1 -1
  88. package/widgets/FeatureForm/RelationshipInput.d.ts +1 -1
  89. package/widgets/FeatureTable.js +1 -1
  90. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  91. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  92. package/widgets/OrientedImageryViewer/constants.js +1 -1
  93. package/widgets/OrientedImageryViewer/types.js +1 -1
  94. package/widgets/OrientedImageryViewer/videoViewerUtils.js +1 -1
  95. package/widgets/OrientedImageryViewer.js +1 -1
  96. package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
  97. package/widgets/VideoPlayer/VideoPlayerViewModel.d.ts +9 -0
  98. package/widgets/VideoPlayer/VideoPlayerViewModel.js +1 -1
  99. package/widgets/VideoPlayer/components/PlayerControlsGroup.js +1 -1
  100. package/widgets/support/forms/formUtils.js +1 -1
  101. package/assets/esri/core/workers/chunks/43cc82373be791b7cb4c.js +0 -1
  102. package/assets/esri/core/workers/chunks/c9461568e1002ebac534.js +0 -1
  103. /package/assets/esri/core/workers/chunks/{53bf9b0c2b8da12820ea.js.LICENSE.txt → 55ccb8ed7325efb62091.js.LICENSE.txt} +0 -0
  104. /package/assets/esri/core/workers/chunks/{a58662698c69190a12d8.js.LICENSE.txt → de25311b6d13bf1c6089.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as a,when as n}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as c,subclass as d}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as g,sub as y,dot as _,set as v}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as w,freeze as x,clone as T,fromValues as j,ZEROS as C}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as O,clone as E,ONES as M}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as R,isMars as V,getReferenceEllipsoid as S,SphericalECEFSpatialReferenceLike as U}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as H}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as D}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as P}from"../../../geometry/projection/projectVectorToVector.js";import{create as I}from"../../../geometry/support/aaBoundingRect.js";import{isCGCS2000 as k}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec4f as L,BufferViewVec4u8 as A,BufferViewVec4u16 as F,BufferViewVec3f as G,BufferViewVec3u8 as B,BufferViewVec3u16 as z,BufferViewVec2f as N,BufferViewUint32 as W,BufferViewUint16 as q}from"../../../geometry/support/buffer/BufferView.js";import $ from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as X}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as Z}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as J}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as Y}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as Q,removeLayerViewFromWasm as K,getLyr3DWasm as ee}from"./Lyr3DWasm.js";import{toWasmModification as te}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as ie}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as se}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as re,alphaModeConversion as oe,faceCullingConversion as ae,wrapModeConversion as ne}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as le}from"./support/makeScheduleFunction.js";import{Tiles3DMeshIntersectionHandler as ce}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as de}from"../state/Frustum.js";import{ElevationRange as he}from"../support/ElevationRange.js";import{toBoundingRect as ue}from"../support/extentUtils.js";import{Obb as me}from"../support/orientedBoundingBox.js";import{glLayout as pe}from"../support/buffer/glUtil.js";import{ComponentGeometryParameters as be,SourceGeometry as fe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as ge}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ye}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as _e}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as ve}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as we}from"../webgl-engine/materials/pbrUtils.js";import xe from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Te,isInEffectiveScaleRange as je,validateScaleRange as Ce}from"../../support/layerViewUtils.js";import{TaskPriority as Oe}from"../../support/Scheduler.js";import{TextureCompressionTracker as Ee}from"../../support/TextureCompressionTracker.js";import{CompressedTextureFormat as Me,SizedPixelFormat as Re}from"../../webgl/enums.js";import{alphaCutoff as Ve}from"../../../webscene/support/AlphaCutoff.js";var Se;function Ue(e,t,i){if("image/vnd-ms.dds"===t)switch(i){case"Dxt1":return Me.COMPRESSED_RGB_S3TC_DXT1_EXT;case"Dxt5":return Me.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if("image/ktx2"===t)return null;switch(e){case 33319:return Re.RG8;case 6407:return Re.RGB8;case 6408:return Re.RGBA8;case 6403:return Re.R8;default:return null}}let He=class extends(J(xe)){static{Se=se}constructor(e){super(e),this[Se]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._imShading=!!has("enable-feature:im-shading"),this._imVertexNormals=!!has("enable-feature:im-vertex-normals"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._compressionTracker=new Ee,this._dbgFlags=new Set;const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._isUsedAsGroundLayer=e.layer.isUsedAsGroundLayer,this._frameTask=t.scheduler.registerTask(Oe.TILES3D,this),this._frustum=new de(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t);const i=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=i}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._workerHandle=new Z(le(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Te("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=Q(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ce(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new ie({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler});const i=this._replacesTerrain?0:1;e.elevationProvider.register(i,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([a(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),n(()=>this.fullOpacity,()=>this._opacityChange()),a(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)])});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),this._workerHandle?.destroyContextAndSelf(this.uid),K(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}get fullOpacity(){return this.layer.replacesTerrain?this.view.map.ground.opacity:1}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.layer.spatialReference,t=te(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=I();this._layerClippingArea=ue(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,X(e))}get _wasm(){return ee(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||je(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Ce(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(a=>{a.isLoaded?(e+=a.textureMemoryUsage,t+=a.vboMemoryUsage,r++):(i+=a.textureMemoryUsage,s+=a.vboMemoryUsage,o++)}),new Y(this.usedMemory,r,o,Ie(t),Ie(e),Ie(s),Ie(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return X(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new he(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new he;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantVisibleTile(e){const{view:t}=this,{spatialReference:i}=t,s=i.isWGS84||i.isWebMercator||k(i)||R(i)||V(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=S(i).radius,{eye:o,viewForward:a,near:n}=t.state.camera,l=g(w(),a),c=500,d=Math.max(o[2],c),h=d+r,u=Math.sqrt(h**2-r**2),m=Math.abs(Math.atan2(u,r))*r,p=d>.5*r?.5*Math.PI*r:m,b=w();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;y(b,s,o);const r=_(b,l);Math.abs(r)<p&&r+i>n&&r-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachTile(e){for(const t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const{componentObjects:i}of e)for(const e of i)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const{meshData:t}=e;if(!Ge(t))throw new Error("meshData not valid");const i=new Map;let s;try{s=this._createPrimitiveTextureBundles(t,i)}catch(o){throw i.forEach(e=>this._stage.removeTexture(e)),o}let r=null;try{if(r=await this._createRenderableMain(t,s),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance");const{tileObb:o,componentObjects:a,elevationRange:n}=r;let l=0,c=0,d=0;for(const e of a){const{texture:t,textureMetallicRoughness:i,textureEmissive:s,textureOcclusion:r,textureNormal:o}=e.renderable.drawParameters;l+=(t?.usedMemory??0)+(i?.usedMemory??0)+(s?.usedMemory??0)+(r?.usedMemory??0)+(o?.usedMemory??0),c+=this._collection.getObjectGPUMemoryUsage(e),d+=e.intersectionGeometry.usedMemory}const h=Array.from(i.values()),u=new Pe(e.handle,a,h,d,c,l,o,e.stableNodeId,e.nodeDepth,n);this._lyrHandleToObjects.set(e.handle,u),this._memCache.put(Le(u.handle),u);const{usedMemory:m}=u;return this._cacheMemory+=m,{memUsageBytes:m}}catch(o){throw s.forEach(e=>e.cleanup()),r?.componentObjects.forEach(e=>this._collection.destroyObject(e)),i.forEach(e=>this._stage.removeTexture(e)),o}}_createPrimitiveTextureBundles(e,t){const i=new Array,s=e.desc.prims.length;try{const r=e.desc;for(let o=0;o<s;o++){const s=r.prims[o].materialId,a=r.materials&&null!=s?r.materials[s]:null;let n=Promise.resolve(Ae),l=null,c=null,d=null,h=null,u=null;if(a){const i="Pbr"===a.lightingModel;l=this._getTexture(a.baseColorTex,e,t),c=i?this._getTexture(a.metalTex,e,t):null,d=i?this._getTexture(a.emissiveTex,e,t):null,h=i?this._getTexture(a.occlusionTex,e,t):null,u=i?this._getTexture(a.normalTex,e,t):null;const s=[l,c,d,h,u].map(e=>e?.loadPromise??null);n=Promise.all(s)}i.push(new Fe(n,l,c,d,h,u))}}catch(r){throw i.forEach(e=>e.cleanup()),r}return i}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy");const i=new Array,s=e.desc,r=e.data.buffer,o=s.prims.length,a=x(...s.origin),n=this.view.basemapTerrain.spatialReference,l=this.view.state.isGlobal;let c=p;if(l){const e=b();H(U,a,e,n),c=h(m(),e)}if(null==s.obb)throw new Error("meshData.desc.obb undefined");const d=ke(s.obb),f=l?S(this.view.spatialReference).radius:0,g=new Array;try{for(let i=0;i<o;i++){const e=s.prims[i],o=t[i];this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(e));if(null==re[e.ptype]){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive."),o.cleanup();continue}const{positionView:a,normalsData:n,colorView:l,texCoord0Data:c,indicesView:d}=this.getBufferViews(e,r);if(null==a||null==d){o.cleanup();continue}const h=a.count,u=(e,t)=>null==e||e===h||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);u(null!=c?c.length/2:void 0,"numTexcoord")&&u(l?.count,"numColors")&&u(n?.length,"normals")?g.push({componentIndex:i,positionView:a,indicesView:d,texCoord0Data:c,colorView:l,normalsData:n}):o.cleanup()}const e=c!==p,h=e?u(m(),c)??p:p,{vertexProcessingOutputs:b,obbHalfSizeAccumulator:y,elevationRange:_}=await this._workerHandle.processTiles3DVertices(g,a,f,l,c,d,this._imVertexNormals);if(this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");const v=s.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");for(const r of b){const{componentIndex:o,positionView:l,indicesView:c,layout:u,textureCoordinateType:m,interleavedVertexData:p,indices:b}=r,f=s.prims[o],g=t[o],y=d.clone(),_=pe(u),x=new Uint32Array([0,c.typedBuffer.length]),T=new be(_,this._imShading?2:0,m,e?2:0,0),j=new fe({interleavedVertexData:p,vertexCount:p.byteLength/_[0].stride,indexData:b},{positions:l.typedBuffer,indices:c.typedBuffer},x,T),C=this.view.renderSpatialReference,E=w(),M=[1,1,1];D(a,C,M,n)||this._dbg(3,"Unsupported coordinate system for IM overlay"),P(a,C,E,n);const R=v&&null!=f.materialId?v[f.materialId]:null,V=this._createComponentMaterialInitParameters(R,g);V.baseColorTexture||this._dbg(3,"No colour texture 1");const S=this._collection.createObject({toMapSpace:O(E[0],E[1],M[0],M[1]),transform:new ge(a,h),obb:y,geometry:j,elevationAlignable:!1},V);i.push(S)}i.length>0&&d.setHalfSize(y[0],y[1],y[2]);const{fullExtent:x}=this.layer;return x?.hasZ&&x.zmax&&x.zmin&&(_.minElevation=Math.max(_.minElevation,x.zmin),_.maxElevation=Math.min(_.maxElevation,x.zmax)),{tileObb:d,componentObjects:i,elevationRange:_}}catch(y){throw i.forEach(e=>this._collection.destroyObject(e)),y}}_createComponentMaterialInitParameters(e,t){const i="Pbr"===(null!=e?e.lightingModel:"Unlit");let s=M,r=Ve,o=1,a=!1,n=2,l=j(0,0,0);const c=T(we),d=t.baseColorTexture,h=t.metallicRoughnessTexture,u=t.emissionTexture,m=t.occlusionTexture,p=t.normalTexture;return e&&(s=E(e.baseColorFactor),r=e.alphaCutoff??Ve,i&&(v(c,e.metallicFactor,e.roughnessFactor,0),e.emissiveFactor&&(l=e.emissiveFactor)),o=oe[e.alphaMode],a=e.isDoubleSided,n=ae[e.faceCulling??"NotSet"]),{isIntegratedMesh:!0,baseColor:s,textureAlphaCutoff:r,mrrFactors:c,baseColorTexture:d,metallicRoughnessTexture:h,normalTexture:p,occlusionTexture:m,emissionTexture:u,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:o,doubleSided:a,cullFace:n,isGround:this.layer.replacesTerrain,emissiveBaseColor:l,usePBR:i,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Le(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,a=!1;for(let n=0;n<i;++n){if(!t[n])continue;const i=e[n],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._intersectionHandler.addTile(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),a||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Le(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let n=0;n<i;++n){const i=e[n];if(t[n])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=s.isVisible;this._visibleObjects.delete(s),s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),this._intersectionHandler.removeTile(s),e&&(this._visibleGeometryChanged(),a||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Le(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),a&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const r=i.get(s)??this._createTexture(e,t,i);return r?new ye(this._stage.renderView.textures,r.id):null}_createTexture(e,t,i){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const r=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,o=!!s.mipCount||r>1,a=ne[e.wrapMode??"None"];let n=s.alpha?6408:6407;const l=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let c=null,d=null,h=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(c=l,n=6403,d=""):"Rg8"===s.pixelFormat||"Ga8"===s.pixelFormat?(c=l,n=33319,d=""):"Rgb8"===s.pixelFormat?(c=l,n=6407,d=""):"Rgba8"===s.pixelFormat&&(c=l,n=6408,d="");break;case"Dxt1":c=l,n=6407,d="image/vnd-ms.dds";break;case"Dxt5":c=l,n=6408,d="image/vnd-ms.dds";break;case"Basis":c=l,n=6407,d="image/ktx2";break;case"Png":d="image/png",h=document.createElement("img");break;case"Jpeg":d="image/jpeg",h=document.createElement("img");break;case"Etc2":d="image/ktx",h=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(h&&d){const e=new Blob([l],{type:d});h.src=URL.createObjectURL(e),c=h}if(c&&null!=d){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker}:void 0,t=Ue(n,d,s.format),l=new _e(c,{mipmap:o,maxAnisotropy:r,encoding:d,wrap:a,pixelFormat:n,internalFormat:t??void 0,immutable:null!=t,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(l),i.set(s,l),l}return null}getBufferViews(e,t){let i,s,r,o,a;for(let l=0;l<e.atrbs.length;l++){const a=e.atrbs[l],{view:c}=a,d=void 0,h=c.byteOffset+c.byteCount;try{switch(a.sem){case"Position":3!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+c+")"):i=new G(t,c.byteOffset,d,h);break;case"Normal":if(3!==c.ncomp||"F32"!==c.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+c+")");else{const e=new G(t,c.byteOffset,d,h);o=new Uint32Array(e.count),ve(e.typedBuffer,new Int16Array(o.buffer,o.byteOffset,2*o.length))}break;case"TexCoord":2!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+c+")"):void 0===r&&(r=new N(t,c.byteOffset,d,h).typedBuffer);break;case"Color":4===c.ncomp?("F32"===c.type&&(s=new L(t,c.byteOffset,d,h)),"U8"===c.type&&(s=new A(t,c.byteOffset,d,h)),"U16"===c.type&&(s=new F(t,c.byteOffset,d,h))):3===c.ncomp&&("F32"===c.type&&(s=new G(t,c.byteOffset,d,h)),"U8"===c.type&&(s=new B(t,c.byteOffset,d,h)),"U16"===c.type&&(s=new z(t,c.byteOffset,d,h))),null==s&&this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+c+")");break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+a.sem+"). Skipping vertex attribute.")}}catch(n){this._dbg(2,"Error Creating buffer ("+n+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":a=new q(t,i.byteOffset,s,r);break;case"U32":a=new W(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==a&&null!=i){const e=i.count;a=a=e<65535?new q(new Uint16Array(e).buffer):new W(new Uint32Array(e).buffer);for(let t=0;t<e;t++)a.set(t,t)}return{positionView:i,colorView:s,texCoord0Data:r,indicesView:a,normalsData:o}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([c()],He.prototype,"fullOpacity",null),e([c({readOnly:!0})],He.prototype,"ready",null),e([c({type:[$]})],He.prototype,"_modifications",void 0),e([c()],He.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([c()],He.prototype,"layer",void 0),e([c({readOnly:!0})],He.prototype,"visibleAtCurrentScale",null),e([c({readOnly:!0})],He.prototype,"_collection",null),e([c()],He.prototype,"elevationOffset",null),e([c({readOnly:!0})],He.prototype,"visibleElevationRange",null),He=e([d("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],He);const De=He;class Pe{constructor(e,t,i,s,r,o,a,n,l,c){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=a,this.stableNodeId=n,this.nodeDepth=l,this.elevationRange=c,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;const d=w();a?.getCenter(d),this._obbCenterX=d[0],this._obbCenterY=d[1],this._obbCenterZ=d[2];const h=a?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=a?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0,this._mbsCenter=a?T(a.center):C}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],a=s-e[1],n=r-e[2],l=o*t[0]+a*t[1]+n*t[2];return o*o+a*a+n*n-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const a=this._obbCenterY-i[1];if(a>r)return!1;const n=this._obbCenterZ-i[2];if(n>r)return!1;const l=o*o+a*a+n*n;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ie(e){return Math.round(e/1048.576)/1e3}function ke(e){return new me(e.center,e.halfSize,f(...e.quaternion))}function Le(e){return`${e}`}const Ae=new Array;class Fe{constructor(e,t,i,s,r,o){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=i,this.emissionTexture=s,this.occlusionTexture=r,this.normalTexture=o}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}function Ge(e){return null!=e.data&&("string"==typeof e.desc&&(e.desc=JSON.parse(e.desc)),null!=e.desc)}export{De as default};
2
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as a,when as n}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as c,subclass as d}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as g,sub as y,dot as _,set as v}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as w,freeze as x,clone as T,fromValues as j,ZEROS as C}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as O,clone as E,ONES as M}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as R,isMars as V,getReferenceEllipsoid as S,SphericalECEFSpatialReferenceLike as U}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as H}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as D}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as P}from"../../../geometry/projection/projectVectorToVector.js";import{create as I}from"../../../geometry/support/aaBoundingRect.js";import{isCGCS2000 as k}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec4f as L,BufferViewVec4u8 as A,BufferViewVec4u16 as F,BufferViewVec3f as G,BufferViewVec3u8 as B,BufferViewVec3u16 as z,BufferViewVec2f as N,BufferViewUint32 as W,BufferViewUint16 as q}from"../../../geometry/support/buffer/BufferView.js";import $ from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as X}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as Z}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as J}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as Y}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as Q,removeLayerViewFromWasm as K,getLyr3DWasm as ee}from"./Lyr3DWasm.js";import{toWasmModification as te}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as ie}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as se}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as re,alphaModeConversion as oe,faceCullingConversion as ae,wrapModeConversion as ne}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as le}from"./support/makeScheduleFunction.js";import{Tiles3DMeshIntersectionHandler as ce}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as de}from"../state/Frustum.js";import{ElevationRange as he}from"../support/ElevationRange.js";import{toBoundingRect as ue}from"../support/extentUtils.js";import{Obb as me}from"../support/orientedBoundingBox.js";import{glLayout as pe}from"../support/buffer/glUtil.js";import{ComponentGeometryParameters as be,SourceGeometry as fe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as ge}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ye}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as _e}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as ve}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as we}from"../webgl-engine/materials/pbrUtils.js";import xe from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Te,isInEffectiveScaleRange as je,validateScaleRange as Ce}from"../../support/layerViewUtils.js";import{TaskPriority as Oe}from"../../support/Scheduler.js";import{TextureCompressionTracker as Ee}from"../../support/TextureCompressionTracker.js";import{CompressedTextureFormat as Me,SizedPixelFormat as Re}from"../../webgl/enums.js";import{alphaCutoff as Ve}from"../../../webscene/support/AlphaCutoff.js";var Se;function Ue(e,t,i){if("image/vnd-ms.dds"===t)switch(i){case"Dxt1":return Me.COMPRESSED_RGB_S3TC_DXT1_EXT;case"Dxt5":return Me.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if("image/ktx2"===t)return null;switch(e){case 33319:return Re.RG8;case 6407:return Re.RGB8;case 6408:return Re.RGBA8;case 6403:return Re.R8;default:return null}}let He=class extends(J(xe)){static{Se=se}constructor(e){super(e),this[Se]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._imShading=!!has("enable-feature:im-shading"),this._imVertexNormals=!!has("enable-feature:im-vertex-normals"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._compressionTracker=new Ee,this._dbgFlags=new Set;const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._isUsedAsGroundLayer=e.layer.isUsedAsGroundLayer,this._frameTask=t.scheduler.registerTask(Oe.TILES3D,this),this._frustum=new de(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t);const i=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=i}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._workerHandle=new Z(le(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Te("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=Q(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ce(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new ie({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler});const i=this._replacesTerrain?0:1;e.elevationProvider.register(i,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([a(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),n(()=>this.fullOpacity,()=>this._opacityChange()),a(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)])});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),this._workerHandle?.destroyContextAndSelf(this.uid),K(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}get fullOpacity(){return this.layer.replacesTerrain?this.view.map.ground.opacity:1}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.layer.spatialReference,t=te(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=I();this._layerClippingArea=ue(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,X(e))}get _wasm(){return ee(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||je(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Ce(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(a=>{a.isLoaded?(e+=a.textureMemoryUsage,t+=a.vboMemoryUsage,r++):(i+=a.textureMemoryUsage,s+=a.vboMemoryUsage,o++)}),new Y(this.usedMemory,r,o,Ie(t),Ie(e),Ie(s),Ie(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return X(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new he(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new he;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantVisibleTile(e){const{view:t}=this,{spatialReference:i}=t,s=i.isWGS84||i.isWebMercator||k(i)||R(i)||V(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=S(i).radius,{eye:o,viewForward:a,near:n}=t.state.camera,l=g(w(),a),c=500,d=Math.max(o[2],c),h=d+r,u=Math.sqrt(h**2-r**2),m=Math.abs(Math.atan2(u,r))*r,p=d>.5*r?.5*Math.PI*r:m,b=w();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;y(b,s,o);const r=_(b,l);Math.abs(r)<p&&r+i>n&&r-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachTile(e){for(const t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const{componentObjects:i}of e)for(const e of i)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const{meshData:t}=e;if(!Ge(t))throw new Error("meshData not valid");const i=new Map;let s;try{s=this._createPrimitiveTextureBundles(t,i)}catch(o){throw i.forEach(e=>this._stage.removeTexture(e)),o}let r=null;try{if(r=await this._createRenderableMain(t,s),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance");const{tileObb:o,componentObjects:a,elevationRange:n}=r;let l=0,c=0,d=0;for(const e of a){const{texture:t,textureMetallicRoughness:i,textureEmissive:s,textureOcclusion:r,textureNormal:o}=e.renderable.drawParameters;l+=(t?.usedMemory??0)+(i?.usedMemory??0)+(s?.usedMemory??0)+(r?.usedMemory??0)+(o?.usedMemory??0),c+=this._collection.getObjectGPUMemoryUsage(e),d+=e.intersectionGeometry.usedMemory}const h=Array.from(i.values()),u=new Pe(e.handle,a,h,d,c,l,o,e.stableNodeId,e.nodeDepth,n);this._lyrHandleToObjects.set(e.handle,u),this._memCache.put(Le(u.handle),u);const{usedMemory:m}=u;return this._cacheMemory+=m,{memUsageBytes:m}}catch(o){throw s.forEach(e=>e.cleanup()),r?.componentObjects.forEach(e=>this._collection.destroyObject(e)),i.forEach(e=>this._stage.removeTexture(e)),o}}_createPrimitiveTextureBundles(e,t){const i=new Array,s=e.desc.prims.length;try{const r=e.desc;for(let o=0;o<s;o++){const s=r.prims[o].materialId,a=r.materials&&null!=s?r.materials[s]:null;let n=Promise.resolve(Ae),l=null,c=null,d=null,h=null,u=null;if(a){const i="Pbr"===a.lightingModel;l=this._getTexture(a.baseColorTex,e,t),c=i?this._getTexture(a.metalTex,e,t):null,d=i?this._getTexture(a.emissiveTex,e,t):null,h=i?this._getTexture(a.occlusionTex,e,t):null,u=i?this._getTexture(a.normalTex,e,t):null;const s=[l,c,d,h,u].map(e=>e?.loadPromise??null);n=Promise.all(s)}i.push(new Fe(n,l,c,d,h,u))}}catch(r){throw i.forEach(e=>e.cleanup()),r}return i}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy");const i=new Array,s=e.desc,r=e.data.buffer,o=s.prims.length,a=x(...s.origin),n=this.view.basemapTerrain.spatialReference,l=this.view.state.isGlobal;let c=p;if(l){const e=b();H(U,a,e,n),c=h(m(),e)}if(null==s.obb)throw new Error("meshData.desc.obb undefined");const d=ke(s.obb),f=l?S(this.view.spatialReference).radius:0,g=new Array;try{for(let i=0;i<o;i++){const e=s.prims[i],o=t[i];this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(e));if(null==re[e.ptype]){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive."),o.cleanup();continue}const{positionView:a,normalsData:n,colorView:l,texCoord0Data:c,indicesView:d}=this.getBufferViews(e,r);if(null==a||null==d){o.cleanup();continue}const h=a.count,u=(e,t)=>null==e||e===h||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);u(null!=c?c.length/2:void 0,"numTexcoord")&&u(l?.count,"numColors")&&u(n?.length,"normals")?g.push({componentIndex:i,positionView:a,indicesView:d,texCoord0Data:c,colorView:l,normalsData:n}):o.cleanup()}const e=c!==p,h=e?u(m(),c)??p:p,{vertexProcessingOutputs:b,obbHalfSizeAccumulator:y,elevationRange:_}=await this._workerHandle.processTiles3DVertices(g,a,f,l,c,d,this._imVertexNormals);if(this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");const v=s.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");for(const r of b){const{componentIndex:o,positionView:l,indicesView:c,layout:u,textureCoordinateType:m,interleavedVertexData:p,indices:b}=r,f=s.prims[o],g=t[o],y=d.clone(),_=pe(u),x=new Uint32Array([0,c.typedBuffer.length]),T=new be(_,this._imShading?2:0,m,e?2:0,0),j=new fe({interleavedVertexData:p,vertexCount:p.byteLength/_[0].stride,indexData:b},{positions:l.typedBuffer,indices:c.typedBuffer},x,T),C=this.view.renderSpatialReference,E=w(),M=[1,1,1];D(a,C,M,n)||this._dbg(3,"Unsupported coordinate system for IM overlay"),P(a,C,E,n);const R=v&&null!=f.materialId?v[f.materialId]:null,V=this._createComponentMaterialInitParameters(R,g);V.baseColorTexture||this._dbg(3,"No colour texture 1");const S=this._collection.createObject({toMapSpace:O(E[0],E[1],M[0],M[1]),transform:new ge(a,h),obb:y,geometry:j,elevationAlignable:!1},V);i.push(S)}i.length>0&&d.setHalfSize(y[0],y[1],y[2]);const{fullExtent:x}=this.layer;return x?.hasZ&&x.zmax&&x.zmin&&(_.minElevation=Math.max(_.minElevation,x.zmin),_.maxElevation=Math.min(_.maxElevation,x.zmax)),{tileObb:d,componentObjects:i,elevationRange:_}}catch(y){throw i.forEach(e=>this._collection.destroyObject(e)),y}}_createComponentMaterialInitParameters(e,t){const i="Pbr"===(null!=e?e.lightingModel:"Unlit");let s=M,r=Ve,o=1,a=!1,n=2,l=j(0,0,0);const c=T(we),d=t.baseColorTexture,h=t.metallicRoughnessTexture,u=t.emissionTexture,m=t.occlusionTexture,p=t.normalTexture;return e&&(s=E(e.baseColorFactor),r=e.alphaCutoff??Ve,i&&(v(c,e.metallicFactor,e.roughnessFactor,0),e.emissiveFactor&&(l=e.emissiveFactor)),o=oe[e.alphaMode],a=e.isDoubleSided,n=ae[e.faceCulling??"NotSet"]),{isIntegratedMesh:!0,baseColor:s,textureAlphaCutoff:r,mrrFactors:c,baseColorTexture:d,metallicRoughnessTexture:h,normalTexture:p,occlusionTexture:m,emissionTexture:u,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:o,doubleSided:a,cullFace:n,isGround:this.layer.replacesTerrain,emissiveBaseColor:l,usePBR:i,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Le(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,a=!1;for(let n=0;n<i;++n){if(!t[n])continue;const i=e[n],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._intersectionHandler.addTile(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),a||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Le(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let n=0;n<i;++n){const i=e[n];if(t[n])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=s.isVisible;this._visibleObjects.delete(s),s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),this._intersectionHandler.removeTile(s),e&&(this._visibleGeometryChanged(),a||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Le(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),a&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const r=i.get(s)??this._createTexture(e,t,i);return r?new ye(this._stage.renderView.textures,r.id):null}_createTexture(e,t,i){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const r=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,o=!!s.mipCount||r>1,a=ne[e.wrapMode??"None"];let n=s.alpha?6408:6407;const l=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let c=null,d=null,h=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(c=l,n=6403,d=""):"Rg8"===s.pixelFormat||"Ga8"===s.pixelFormat?(c=l,n=33319,d=""):"Rgb8"===s.pixelFormat?(c=l,n=6407,d=""):"Rgba8"===s.pixelFormat&&(c=l,n=6408,d="");break;case"Dxt1":c=l,n=6407,d="image/vnd-ms.dds";break;case"Dxt5":c=l,n=6408,d="image/vnd-ms.dds";break;case"Basis":c=l,n=6407,d="image/ktx2";break;case"Png":d="image/png",h=document.createElement("img");break;case"Jpeg":d="image/jpeg",h=document.createElement("img");break;case"Etc2":d="image/ktx",h=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(h&&d){const e=new Blob([l],{type:d});h.src=URL.createObjectURL(e),c=h}if(c&&null!=d){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker}:void 0,t=Ue(n,d,s.format),l=new _e(c,{mipmap:o,maxAnisotropy:r,encoding:d,wrap:a,pixelFormat:n,internalFormat:t??void 0,immutable:null!=t,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(l),i.set(s,l),l}return null}getBufferViews(e,t){let i,s,r,o,a;for(let l=0;l<e.atrbs.length;l++){const a=e.atrbs[l],{view:c}=a,d=void 0,h=c.byteOffset+c.byteCount;try{switch(a.sem){case"Position":3!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+c+")"):i=new G(t,c.byteOffset,d,h);break;case"Normal":if(3!==c.ncomp||"F32"!==c.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+c+")");else{const e=new G(t,c.byteOffset,d,h);o=new Uint32Array(e.count),ve(e.typedBuffer,new Int16Array(o.buffer,o.byteOffset,2*o.length))}break;case"TexCoord":2!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+c+")"):void 0===r&&(r=new N(t,c.byteOffset,d,h).typedBuffer);break;case"Color":4===c.ncomp?("F32"===c.type&&(s=new L(t,c.byteOffset,d,h)),"U8"===c.type&&(s=new A(t,c.byteOffset,d,h)),"U16"===c.type&&(s=new F(t,c.byteOffset,d,h))):3===c.ncomp&&("F32"===c.type&&(s=new G(t,c.byteOffset,d,h)),"U8"===c.type&&(s=new B(t,c.byteOffset,d,h)),"U16"===c.type&&(s=new z(t,c.byteOffset,d,h))),null==s&&this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+c+")");break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+a.sem+"). Skipping vertex attribute.")}}catch(n){this._dbg(2,"Error Creating buffer ("+n+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":a=new q(t,i.byteOffset,s,r);break;case"U32":a=new W(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==a&&null!=i){const e=i.count;a=a=e<65535?new q(new Uint16Array(e).buffer):new W(new Uint32Array(e).buffer);for(let t=0;t<e;t++)a.set(t,t)}return{positionView:i,colorView:s,texCoord0Data:r,indicesView:a,normalsData:o}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([c()],He.prototype,"fullOpacity",null),e([c({readOnly:!0})],He.prototype,"ready",null),e([c({type:[$]})],He.prototype,"_modifications",void 0),e([c()],He.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([c()],He.prototype,"layer",void 0),e([c({readOnly:!0})],He.prototype,"visibleAtCurrentScale",null),e([c({readOnly:!0})],He.prototype,"_collection",null),e([c()],He.prototype,"elevationOffset",null),e([c({readOnly:!0})],He.prototype,"visibleElevationRange",null),He=e([d("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],He);const De=He;class Pe{constructor(e,t,i,s,r,o,a,n,l,c){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=a,this.stableNodeId=n,this.nodeDepth=l,this.elevationRange=c,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;const d=w();a?.getCenter(d),this._obbCenterX=d[0],this._obbCenterY=d[1],this._obbCenterZ=d[2];const h=a?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=a?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0,this._mbsCenter=a?T(a.center):C}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],a=s-e[1],n=r-e[2],l=o*t[0]+a*t[1]+n*t[2];return o*o+a*a+n*n-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const a=this._obbCenterY-i[1];if(a>r)return!1;const n=this._obbCenterZ-i[2];if(n>r)return!1;const l=o*o+a*a+n*n;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;const c=s-t;return c>0&&l<=c*c||(this.obb?.intersectSphere(e)??!0)}}function Ie(e){return Math.round(e/1048.576)/1e3}function ke(e){return new me(e.center,e.halfSize,f(...e.quaternion))}function Le(e){return`${e}`}const Ae=new Array;class Fe{constructor(e,t,i,s,r,o){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=i,this.emissionTexture=s,this.occlusionTexture=r,this.normalTexture=o}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}function Ge(e){return null!=e.data&&("string"==typeof e.desc&&(e.desc=JSON.parse(e.desc)),null!=e.desc)}export{De as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{sub as n,set as t,copy as i,cross as o,normalize as e}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as s,setMax as r,create as f}from"../../../../geometry/support/aaBoundingBox.js";import{assert as u}from"./Util.js";class a{constructor(n=0,t=!1,i=!0){this.tolerance=n,this.isVerticalRay=t,this.normalRequired=i}}const l=f();function h(t,i,o,e,c,s){if(!t.visible)return;const r=n(F,e,o),{tolerance:f}=i,l=new a(f,!1,i.options.normalRequired);if(t.boundingInfo)u(0===t.type),p(t.boundingInfo,o,r,f,c,l,s);else{const n=t.positionAttribute,i=t.primitivePositionIndices;T(o,r,0,i.length/3,i,n.data,n.stride,c,l,s)}}const m=c();function p(n,t,i,o,e,c,f){if(null==n)return;const u=C(i,m);if(s(l,n.bbMin),r(l,n.bbMax),null!=e&&e.applyToAabb(l),U(l,t,u,o)){const{primitiveIndices:s,position:r}=n,u=s?s.length:r.indices.length/3;if(u>z){const s=n.getChildren();if(void 0!==s){for(const n of s)p(n,t,i,o,e,c,f);return}}q(t,i,0,u,r.indices,r.data,r.stride,s,e,c,f)}}const b=c();function M(t,i,o,e,c,s,r,f,u){const{data:a,stride:l}=s;T(t,n(F,i,t),o,e,c,a,l,r,f,u)}function d(n,t,i,o){if(!i.visible)return;const{boundingInfo:e}=i;if(e){const{bbMin:i,bbMax:o}=e;if(n<i[0]||n>o[0]||t<i[1]||t>o[1])return}const c=i.positionAttribute,s=i.primitivePositionIndices;x(n,t,0,s.length/3,s,c,o)}function x(n,t,i,o,e,c,s){const{data:r,stride:f}=c;for(let u=i;u<o;++u){const i=3*u,o=f*e[i],c=f*e[i+1],a=f*e[i+2],l=r[o+0]-n,h=r[o+1]-t,m=r[c+0]-n,p=r[c+1]-t,b=r[a+0]-n,M=r[a+1]-t,d=b*p-M*m,x=l*M-h*b,g=m*h-p*l;(d<0||x<0||g<0)&&(d>0||x>0||g>0)||s(0,null,u)}}function g(n,t,i,o,e,c,s,r,f,u=null,a=0){const l=n[0],h=n[1],m=n[2],p=t[0],M=t[1],d=t[2];for(let x=i;x<o;++x){const n=a+(u?.[x]??x),t=3*n,i=s*e[t],o=c[i],g=c[i+1],y=c[i+2],v=s*e[t+1],q=c[v],T=c[v+1],V=c[v+2],I=s*e[t+2],R=q-o,A=T-g,B=V-y,P=c[I]-o,w=c[I+1]-g,C=c[I+2]-y,U=M*C-w*d,k=d*P-C*p,z=p*w-P*M,D=R*U+A*k+B*z,F=D*D;if(F<=E)continue;const G=l-o,H=h-g,J=m-y,K=(G*U+H*k+J*z)*D;if(K<0||K>F)continue;const L=H*B-A*J,N=J*R-B*G,O=G*A-R*H,Q=(p*L+M*N+d*O)*D;if(Q<0||K+Q>F)continue;const S=(P*L+w*N+C*O)/D;if(S>=0){f(S,r?j(R,A,B,P,w,C,b):null,n)}}}function y(n,t,i,o,e,c,s,r){const f=n[0],u=n[1],a=n[2],l=t[0],h=t[1],m=t[2];for(let p=i;p<o;++p){const n=3*p,t=n+1,i=n+2,o=c*n,M=e[o],d=e[o+1],x=e[o+2],g=c*t,y=c*i,v=e[g]-M,q=e[g+1]-d,T=e[g+2]-x,V=e[y]-M,I=e[y+1]-d,R=e[y+2]-x,A=h*R-I*m,B=m*V-R*l,P=l*I-V*h,w=v*A+q*B+T*P;if(Math.abs(w)<=D)continue;const C=f-M,U=u-d,k=a-x,z=C*A+U*B+k*P;if(w>0){if(z<0||z>w)continue}else if(z>0||z<w)continue;const E=U*T-q*k,F=k*v-T*C,G=C*q-v*U,H=l*E+h*F+m*G;if(w>0){if(H<0||z+H>w)continue}else if(H>0||z+H<w)continue;const J=(V*E+I*F+R*G)/w;if(J>=0){r(J,s?j(v,q,T,V,I,R,b):null,p)}}}function v(n,t,i,o,e,c,s,r,f,u,a,l=null,h=0){const m=n[0],p=n[1],M=n[2],d=t[0],x=t[1],g=t[2];for(let y=i;y<o;++y){const n=h+(l?.[y]??y),t=3*n,i=s*e[t],o=c[i],v=c[i+1],q=c[i+2],T=s*e[t+1],V=c[T],I=c[T+1],R=c[T+2],A=s*e[t+2],B=c[A],P=c[A+1],w=c[A+2],C=q-f,U=r/Math.sqrt(o*o+v*v+C*C),k=o+o*U,z=v+v*U,E=q+C*U,F=R-f,G=r/Math.sqrt(V*V+I*I+F*F),H=V+V*G,J=I+I*G,K=R+F*G,L=w-f,N=r/Math.sqrt(B*B+P*P+L*L),O=H-k,Q=J-z,S=K-E,W=B+B*N-k,X=P+P*N-z,Y=w+L*N-E,Z=x*Y-X*g,$=g*W-Y*d,_=d*X-W*x,nn=O*Z+Q*$+S*_;if(Math.abs(nn)<=D)continue;const tn=m-k,on=p-z,en=M-E,cn=tn*Z+on*$+en*_;if(nn>0){if(cn<0||cn>nn)continue}else if(cn>0||cn<nn)continue;const sn=on*S-Q*en,rn=en*O-S*tn,fn=tn*Q-O*on,un=d*sn+x*rn+g*fn;if(nn>0){if(un<0||cn+un>nn)continue}else if(un>0||cn+un<nn)continue;const an=(W*sn+X*rn+Y*fn)/nn;if(an>=0){a(an,u?j(O,Q,S,W,X,Y,b):null,n)}}}function q(n,t,i,o,e,c,s,r,f,u,a){const l=n[0],h=n[1],m=n[2],p=t[0],M=t[1],d=t[2],{normalRequired:x}=u;for(let g=i;g<o;++g){const n=r[g],t=3*n,i=s*e[t];let o=c[i],u=c[i+1],y=c[i+2];const v=s*e[t+1];let q=c[v],T=c[v+1],V=c[v+2];const I=s*e[t+2];let R=c[I],A=c[I+1],B=c[I+2];null!=f&&([o,u,y]=f.applyToVertex(o,u,y,g),[q,T,V]=f.applyToVertex(q,T,V,g),[R,A,B]=f.applyToVertex(R,A,B,g));const P=q-o,w=T-u,C=V-y,U=R-o,k=A-u,z=B-y,E=M*z-k*d,F=d*U-z*p,G=p*k-U*M,H=P*E+w*F+C*G;if(Math.abs(H)<=D)continue;const J=l-o,K=h-u,L=m-y,N=J*E+K*F+L*G;if(H>0){if(N<0||N>H)continue}else if(N>0||N<H)continue;const O=K*C-w*L,Q=L*P-C*J,S=J*w-P*K,W=p*O+M*Q+d*S;if(H>0){if(W<0||N+W>H)continue}else if(W>0||N+W<H)continue;const X=(U*O+k*Q+z*S)/H;if(X>=0){a(X,x?j(P,w,C,U,k,z,b):null,n)}}}function T(o,e,c,s,r,f,u,a,l,h){const m=e,p=G,b=Math.abs(m[0]),M=Math.abs(m[1]),d=Math.abs(m[2]),x=b>=M?b>=d?0:2:M>=d?1:2,g=x,y=m[g]<0?2:1,v=(x+y)%3,q=(x+(3-y))%3,T=m[v]/m[g],j=m[q]/m[g],B=1/m[g],P=V,w=I,C=R,{normalRequired:U}=l;for(let V=c;V<s;++V){const e=3*V,c=u*r[e];t(p[0],f[c+0],f[c+1],f[c+2]);const s=u*r[e+1];t(p[1],f[s+0],f[s+1],f[s+2]);const l=u*r[e+2];t(p[2],f[l+0],f[l+1],f[l+2]),a&&(i(p[0],a.applyToVertex(p[0][0],p[0][1],p[0][2],V)),i(p[1],a.applyToVertex(p[1][0],p[1][1],p[1][2],V)),i(p[2],a.applyToVertex(p[2][0],p[2][1],p[2][2],V))),n(P,p[0],o),n(w,p[1],o),n(C,p[2],o);const m=P[v]-T*P[g],b=P[q]-j*P[g],M=w[v]-T*w[g],d=w[q]-j*w[g],x=C[v]-T*C[g],y=C[q]-j*C[g],I=x*d-y*M,R=m*y-b*x,k=M*b-d*m;if((I<0||R<0||k<0)&&(I>0||R>0||k>0))continue;const z=I+R+k;if(0===z)continue;const D=I*(B*P[g])+R*(B*w[g])+k*(B*C[g]);if(D*Math.sign(z)<0)continue;const E=D/z;if(E>=0){h(E,U?A(p):null,V)}}}const V=c(),I=c(),R=c();function j(n,i,c,s,r,f,u){return t(B,n,i,c),t(P,s,r,f),o(u,B,P),e(u,u),u}function A(t){return n(B,t[1],t[0]),n(P,t[2],t[0]),o(b,B,P),e(b,b),b}const B=c(),P=c();function w(n,i,o){return t(o,1/(i[0]-n[0]),1/(i[1]-n[1]),1/(i[2]-n[2]))}function C(n,i){return t(i,1/n[0],1/n[1],1/n[2])}function U(n,t,i,o){return k(n,t,i,o,1/0)}function k(n,t,i,o,e){const c=(n[0]-o-t[0])*i[0],s=(n[3]+o-t[0])*i[0];let r=Math.min(c,s),f=Math.max(c,s);const u=(n[1]-o-t[1])*i[1],a=(n[4]+o-t[1])*i[1];if(f=Math.min(f,Math.max(u,a)),f<0)return!1;if(r=Math.max(r,Math.min(u,a)),r>f)return!1;const l=(n[2]-o-t[2])*i[2],h=(n[5]+o-t[2])*i[2];return f=Math.min(f,Math.max(l,h)),!(f<0)&&(r=Math.max(r,Math.min(l,h)),!(r>f)&&r<e)}const z=1e3,D=1e-7,E=D*D,F=c(),G=[c(),c(),c()];export{a as MeshIntersectionOptions,w as computeInvDir,C as computeInvDirFromDirection,j as computeNormalFromBarycentric,U as intersectAabbInvDir,k as intersectAabbInvDirBefore,g as intersectRayTriangles,T as intersectRayTrianglesWithDisplacementWatertight,v as intersectRayTrianglesWithVerticalOffsetENUGlobal,y as intersectRenderGeometryTriangles,h as intersectTriangleGeometry,d as intersectTriangleGeometry2D,M as intersectTriangles,x as intersectTriangles2d,D as triangleRayParallelTolerance};
2
+ import{sub as t,set as n,copy as o,cross as i,normalize as e}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as s,setMax as r,create as u}from"../../../../geometry/support/aaBoundingBox.js";import{assert as f}from"./Util.js";class a{constructor(t=0,n=!1,o=!0){this.tolerance=t,this.isVerticalRay=n,this.normalRequired=o}}const l=u();function m(n,o,i,e,c,s){if(!n.visible)return;const r=t(F,e,i),{tolerance:u}=o,l=new a(u,!1,o.options.normalRequired);if(n.boundingInfo)f(0===n.type),h(n.boundingInfo,i,r,u,c,l,s);else{const t=n.positionAttribute,o=n.primitivePositionIndices;T(i,r,0,o.length/3,o,t.data,t.stride,c,l,s)}}const p=c();function h(t,n,o,i,e,c,u){if(null==t)return;const f=C(o,p);if(s(l,t.bbMin),r(l,t.bbMax),null!=e&&e.applyToAabb(l),U(l,n,f,i)){const{primitiveIndices:s,position:r}=t,f=s?s.length:r.indices.length/3;if(f>z){const s=t.getChildren();if(void 0!==s){for(const t of s)h(t,n,o,i,e,c,u);return}}q(n,o,0,f,r.indices,r.data,r.stride,s,e,c,u)}}const d=c();function b(n,o,i,e,c,s,r,u,f){const{data:a,stride:l}=s;T(n,t(F,o,n),i,e,c,a,l,r,u,f)}function M(t,n,o,i){if(!o.visible)return;const{boundingInfo:e}=o;if(e){const{bbMin:o,bbMax:i}=e;if(t<o[0]||t>i[0]||n<o[1]||n>i[1])return}const c=o.positionAttribute,s=o.primitivePositionIndices;x(t,n,0,s.length/3,s,c,i)}function x(t,n,o,i,e,c,s){const{data:r,stride:u}=c;for(let f=o;f<i;++f){const o=3*f,i=u*e[o],c=u*e[o+1],a=u*e[o+2],l=r[i+0]-t,m=r[i+1]-n,p=r[c+0]-t,h=r[c+1]-n,d=r[a+0]-t,b=r[a+1]-n,M=d*h-b*p,x=l*b-m*d,g=p*m-h*l;(M<0||x<0||g<0)&&(M>0||x>0||g>0)||s(0,null,f)}}function g(t,n,o,i,e,c,s,r,u,f=null,a=0){const l=t[0],m=t[1],p=t[2],h=n[0],b=n[1],M=n[2];for(let x=o;x<i;++x){const t=a+(f?.[x]??x),n=3*t,o=s*e[n],i=c[o],g=c[o+1],y=c[o+2],v=s*e[n+1],q=c[v],T=c[v+1],V=c[v+2],I=s*e[n+2],R=q-i,A=T-g,B=V-y,P=c[I]-i,w=c[I+1]-g,C=c[I+2]-y,U=b*C-w*M,k=M*P-C*h,z=h*w-P*b,D=R*U+A*k+B*z,F=D*D;if(F<=E)continue;const G=l-i,H=m-g,J=p-y,K=(G*U+H*k+J*z)*D;if(K<0||K>F)continue;const L=H*B-A*J,N=J*R-B*G,O=G*A-R*H,Q=(h*L+b*N+M*O)*D;if(Q<0||K+Q>F)continue;const S=(P*L+w*N+C*O)/D;if(S>=0){u(S,r?j(R,A,B,P,w,C,d):null,t)}}}function y(t,n,o,i,e,c,s,r){const u=t[0],f=t[1],a=t[2],l=n[0],m=n[1],p=n[2];for(let h=o;h<i;++h){const t=3*h,n=t+1,o=t+2,i=c*t,b=e[i],M=e[i+1],x=e[i+2],g=c*n,y=c*o,v=e[g]-b,q=e[g+1]-M,T=e[g+2]-x,V=e[y]-b,I=e[y+1]-M,R=e[y+2]-x,A=m*R-I*p,B=p*V-R*l,P=l*I-V*m,w=v*A+q*B+T*P,C=w*w;if(C<=E)continue;const U=u-b,k=f-M,z=a-x,D=(U*A+k*B+z*P)*w;if(D<0||D>C)continue;const F=k*T-q*z,G=z*v-T*U,H=U*q-v*k,J=(l*F+m*G+p*H)*w;if(J<0||D+J>C)continue;const K=(V*F+I*G+R*H)/w;if(K>=0){r(K,s?j(v,q,T,V,I,R,d):null,h)}}}function v(t,n,o,i,e,c,s,r,u,f,a,l=null,m=0){const p=t[0],h=t[1],b=t[2],M=n[0],x=n[1],g=n[2];for(let y=o;y<i;++y){const t=m+(l?.[y]??y),n=3*t,o=s*e[n],i=c[o],v=c[o+1],q=c[o+2],T=s*e[n+1],V=c[T],I=c[T+1],R=c[T+2],A=s*e[n+2],B=c[A],P=c[A+1],w=c[A+2],C=q-u,U=r/Math.sqrt(i*i+v*v+C*C),k=i+i*U,z=v+v*U,D=q+C*U,F=R-u,G=r/Math.sqrt(V*V+I*I+F*F),H=V+V*G,J=I+I*G,K=R+F*G,L=w-u,N=r/Math.sqrt(B*B+P*P+L*L),O=H-k,Q=J-z,S=K-D,W=B+B*N-k,X=P+P*N-z,Y=w+L*N-D,Z=x*Y-X*g,$=g*W-Y*M,_=M*X-W*x,tt=O*Z+Q*$+S*_,nt=tt*tt;if(nt<=E)continue;const ot=p-k,it=h-z,et=b-D,ct=(ot*Z+it*$+et*_)*tt;if(ct<0||ct>nt)continue;const st=it*S-Q*et,rt=et*O-S*ot,ut=ot*Q-O*it,ft=(M*st+x*rt+g*ut)*tt;if(ft<0||ct+ft>nt)continue;const at=(W*st+X*rt+Y*ut)/tt;if(at>=0){a(at,f?j(O,Q,S,W,X,Y,d):null,t)}}}function q(t,n,o,i,e,c,s,r,u,f,a){const l=t[0],m=t[1],p=t[2],h=n[0],b=n[1],M=n[2],{normalRequired:x}=f;for(let g=o;g<i;++g){const t=r[g],n=3*t,o=s*e[n];let i=c[o],f=c[o+1],y=c[o+2];const v=s*e[n+1];let q=c[v],T=c[v+1],V=c[v+2];const I=s*e[n+2];let R=c[I],A=c[I+1],B=c[I+2];null!=u&&([i,f,y]=u.applyToVertex(i,f,y,g),[q,T,V]=u.applyToVertex(q,T,V,g),[R,A,B]=u.applyToVertex(R,A,B,g));const P=q-i,w=T-f,C=V-y,U=R-i,k=A-f,z=B-y,D=b*z-k*M,F=M*U-z*h,G=h*k-U*b,H=P*D+w*F+C*G,J=H*H;if(J<=E)continue;const K=l-i,L=m-f,N=p-y,O=(K*D+L*F+N*G)*H;if(O<0||O>J)continue;const Q=L*C-w*N,S=N*P-C*K,W=K*w-P*L,X=(h*Q+b*S+M*W)*H;if(X<0||O+X>J)continue;const Y=(U*Q+k*S+z*W)/H;if(Y>=0){a(Y,x?j(P,w,C,U,k,z,d):null,t)}}}function T(i,e,c,s,r,u,f,a,l,m){const p=e,h=G,d=Math.abs(p[0]),b=Math.abs(p[1]),M=Math.abs(p[2]),x=d>=b?d>=M?0:2:b>=M?1:2,g=x,y=p[g]<0?2:1,v=(x+y)%3,q=(x+(3-y))%3,T=p[v]/p[g],j=p[q]/p[g],B=1/p[g],P=V,w=I,C=R,{normalRequired:U}=l;for(let V=c;V<s;++V){const e=3*V,c=f*r[e];n(h[0],u[c+0],u[c+1],u[c+2]);const s=f*r[e+1];n(h[1],u[s+0],u[s+1],u[s+2]);const l=f*r[e+2];n(h[2],u[l+0],u[l+1],u[l+2]),a&&(o(h[0],a.applyToVertex(h[0][0],h[0][1],h[0][2],V)),o(h[1],a.applyToVertex(h[1][0],h[1][1],h[1][2],V)),o(h[2],a.applyToVertex(h[2][0],h[2][1],h[2][2],V))),t(P,h[0],i),t(w,h[1],i),t(C,h[2],i);const p=P[v]-T*P[g],d=P[q]-j*P[g],b=w[v]-T*w[g],M=w[q]-j*w[g],x=C[v]-T*C[g],y=C[q]-j*C[g],I=x*M-y*b,R=p*y-d*x,k=b*d-M*p;if((I<0||R<0||k<0)&&(I>0||R>0||k>0))continue;const z=I+R+k;if(0===z)continue;const D=I*(B*P[g])+R*(B*w[g])+k*(B*C[g]);if(D*Math.sign(z)<0)continue;const E=D/z;if(E>=0){m(E,U?A(h):null,V)}}}const V=c(),I=c(),R=c();function j(t,o,c,s,r,u,f){return n(B,t,o,c),n(P,s,r,u),i(f,B,P),e(f,f),f}function A(n){return t(B,n[1],n[0]),t(P,n[2],n[0]),i(d,B,P),e(d,d),d}const B=c(),P=c();function w(t,o,i){return n(i,1/(o[0]-t[0]),1/(o[1]-t[1]),1/(o[2]-t[2]))}function C(t,o){return n(o,1/t[0],1/t[1],1/t[2])}function U(t,n,o,i){return k(t,n,o,i,1/0)}function k(t,n,o,i,e){const c=(t[0]-i-n[0])*o[0],s=(t[3]+i-n[0])*o[0];let r=Math.min(c,s),u=Math.max(c,s);const f=(t[1]-i-n[1])*o[1],a=(t[4]+i-n[1])*o[1];if(u=Math.min(u,Math.max(f,a)),u<0)return!1;if(r=Math.max(r,Math.min(f,a)),r>u)return!1;const l=(t[2]-i-n[2])*o[2],m=(t[5]+i-n[2])*o[2];return u=Math.min(u,Math.max(l,m)),!(u<0)&&(r=Math.max(r,Math.min(l,m)),!(r>u)&&r<e)}const z=1e3,D=1e-7,E=D*D,F=c(),G=[c(),c(),c()];export{a as MeshIntersectionOptions,w as computeInvDir,C as computeInvDirFromDirection,j as computeNormalFromBarycentric,U as intersectAabbInvDir,k as intersectAabbInvDirBefore,g as intersectRayTriangles,T as intersectRayTrianglesWithDisplacementWatertight,v as intersectRayTrianglesWithVerticalOffsetENUGlobal,y as intersectRenderGeometryTriangles,m as intersectTriangleGeometry,M as intersectTriangleGeometry2D,b as intersectTriangles,x as intersectTriangles2d,D as triangleRayParallelTolerance};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{clamp as t}from"../../../../core/mathUtils.js";import{estimateNumberArrayMemory as e}from"../../../../core/memoryEstimations.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{nan as i,fromValues as r}from"../../../../geometry/support/aaBoundingBox.js";import{newContinuousIndexArray as s}from"../../../../geometry/support/Indices.js";import{MeshIntersectionOptions as a,intersectRayTriangles as o}from"./RayIntersections.js";const c=40,h=.8,d=10,l=1e-6;class m{constructor(e,i,r){this.globalTriangleVertexIndices=e,this.numTriangles=i,this.positions=r,this._rayDirection=n(),this._callback=I,this._intersectionOptions=M,this.bspNodeTree=new Array,this.triangleIndexMap=s(i);const a=x(e,i,r.data,r.stride),o=t(Math.log2(i/c),2,d),l=(t,e,n)=>{const i=u(this.triangleIndexMap,a,t,e),r=e-t;if(r<=c){const n=new g(i,void 0,0,t,e);return this.bspNodeTree.push(n),n}const{axis:s,midValue:d}=p(i),m=f(this.triangleIndexMap,a,t,e,s,d),x=(t,e)=>{if(n>o)return;const i=e-t;return i<c||i>=h*r?void 0:l(t,e,n+1)},y=new g(i,s,d,m.next,m.mid);return this.bspNodeTree.push(y),y.leftNode=x(t,m.next),y.rightNode=x(m.mid,e),y};l(0,i,0)}intersectRayTriangleRange(t,e){if(t>=e)return;const{data:n,stride:i}=this.positions;o(this._rayFrom,this._rayDirection,t,e,this.globalTriangleVertexIndices,n,i,this._intersectionOptions.normalRequired,this._callback,this.triangleIndexMap),m.numFacesTested+=e-t}intersectRay(t,e,n,i){m.numFacesTested=0;const r=t,s=e,a=s[0]-r[0],o=s[1]-r[1],c=s[2]-r[2];if(a*a+o*o+c*c<l)return;this._rayFrom=r;const h=this._rayDirection;h[0]=a,h[1]=o,h[2]=c;const d=this.triangleIndexMap.length;this._callback=i,this._intersectionOptions=n,this.intersectRayBSP(this.bspNodeTree[0],0,d),this._callback=I,this._intersectionOptions=M}intersectRayBSP(t,e,n){const i=this._rayFrom,r=this._rayDirection,s=[{node:t,rangeStart:e,rangeEnd:n}];for(;s.length>0;){const{node:t,rangeStart:e,rangeEnd:n}=s.pop();if(!y(t.aabb,i,r))continue;const a=t.axis,o=t.d;if(i[a]<o||r[a]<0){const n=e,i=t.midStartIndex;if(n<i){const e=t.leftNode;void 0!==e?s.push({node:e,rangeStart:n,rangeEnd:i}):this.intersectRayTriangleRange(n,i)}}if(this.intersectRayTriangleRange(t.midStartIndex,t.rightStartIndex),i[a]>o||r[a]>0){const e=t.rightStartIndex,i=n;if(e<i){const n=t.rightNode;void 0!==n?s.push({node:n,rangeStart:e,rangeEnd:i}):this.intersectRayTriangleRange(e,i)}}}}static{this.numFacesTested=0}get estimatedMemoryUsage(){return e(this.triangleIndexMap)}}class g{constructor(t,e,n,i,r){this.aabb=t,this.axis=e,this.d=n,this.midStartIndex=i,this.rightStartIndex=r}}function f(t,e,n,i,r,s){let a=n,o=i;for(;a<o;){const n=t[a];e[6*n+r+3]<=s?++a:(--o,t[a]=t[o],t[o]=n)}let c=a;for(o=i;c<o;){const n=t[o-1];e[6*n+r]>=s?--o:(t[o-1]=t[c],t[c]=n,++c)}return{next:a,mid:c}}function u(t,e,n,s){if(s<=n)return i;let a=6*t[n];const o=r(e[a++],e[a++],e[a++],e[a++],e[a++],e[a]);for(let i=n+1;i<s;++i){let n=6*t[i];o[0]=Math.min(o[0],e[n++]),o[1]=Math.min(o[1],e[n++]),o[2]=Math.min(o[2],e[n++]),o[3]=Math.max(o[3],e[n++]),o[4]=Math.max(o[4],e[n++]),o[5]=Math.max(o[5],e[n])}return o}function p(t){const e=t[3]-t[0],n=t[4]-t[1],i=t[5]-t[2],r=e>n?e>i?0:n>i?1:2:n>i?1:i>e?2:0;return{axis:r,midValue:(t[r]+t[r+3])/2}}function x(t,e,n,i){const r=new Array;for(let s=0;s<e;++s){const e=3*s,a=t[e]*i,o=t[e+1]*i,c=t[e+2]*i;for(let t=0;t<3;++t){const e=n[a+t],i=n[o+t],h=n[c+t];r[6*s+t]=Math.min(e,i,h),r[6*s+3+t]=Math.max(e,i,h)}}return r}function y(t,e,n){const i=e,r=n;let s=0,a=1/0;for(let o=0;o<3;++o){{const e=t[o];if(i[o]<e){if(r[o]<=l)return!1;const t=(e-i[o])/r[o];s=Math.max(s,t)}else if(r[o]<=-l){const t=(e-i[o])/r[o];a=Math.min(a,t)}if(s>a)return!1}{const e=t[o+3];if(i[o]>e){if(r[o]>=-l)return!1;const t=(e-i[o])/r[o];s=Math.max(s,t)}else if(r[o]>=l){const t=(e-i[o])/r[o];a=Math.min(a,t)}if(s>a)return!1}}return!0}const M=new a,I=()=>{};export{m as TriangleIntersectionData};
2
+ import{clamp as t}from"../../../../core/mathUtils.js";import{estimateNumberArrayMemory as e}from"../../../../core/memoryEstimations.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{nan as i,fromValues as r}from"../../../../geometry/support/aaBoundingBox.js";import{newContinuousIndexArray as s}from"../../../../geometry/support/Indices.js";import{MeshIntersectionOptions as a,intersectRayTriangles as o}from"./RayIntersections.js";const c=40,h=.8,d=10,m=1e-6;class l{constructor(e,i,r){this.globalTriangleVertexIndices=e,this.numTriangles=i,this.positions=r,this._rayDirection=n(),this._callback=I,this._intersectionOptions=M,this.bspNodeTree=new Array,this.triangleIndexMap=s(i);const a=x(e,i,r.data,r.stride),o=t(Math.log2(i/c),2,d),m=(t,e,n)=>{const i=u(this.triangleIndexMap,a,t,e),r=e-t;if(r<=c){const n=new g(i,void 0,0,t,e);return this.bspNodeTree.push(n),n}const{axis:s,midValue:d}=p(i),l=f(this.triangleIndexMap,a,t,e,s,d),x=(t,e)=>{if(n>o)return;const i=e-t;return i<c||i>=h*r?void 0:m(t,e,n+1)},y=new g(i,s,d,l.next,l.mid);return this.bspNodeTree.push(y),y.leftNode=x(t,l.next),y.rightNode=x(l.mid,e),y};m(0,i,0)}intersectRayTriangleRange(t,e){if(t>=e)return;const{data:n,stride:i}=this.positions;o(this._rayFrom,this._rayDirection,t,e,this.globalTriangleVertexIndices,n,i,this._intersectionOptions.normalRequired,this._callback,this.triangleIndexMap),l.numFacesTested+=e-t}intersectRay(t,e,n,i){l.numFacesTested=0;const r=t,s=e,a=s[0]-r[0],o=s[1]-r[1],c=s[2]-r[2];if(a*a+o*o+c*c<m)return;this._rayFrom=r;const h=this._rayDirection;h[0]=a,h[1]=o,h[2]=c;const d=this.triangleIndexMap.length;this._callback=i,this._intersectionOptions=n,this.intersectRayBSP(this.bspNodeTree[0],0,d),this._callback=I,this._intersectionOptions=M}intersectRayBSP(t,e,n){const i=this._rayFrom,r=this._rayDirection,s=[{node:t,rangeStart:e,rangeEnd:n}];for(;s.length>0;){const{node:t,rangeStart:e,rangeEnd:n}=s.pop();if(!y(t.aabb,i,r))continue;const a=t.axis,o=t.d;if(i[a]<o||r[a]<0){const n=e,i=t.midStartIndex;if(n<i){const e=t.leftNode;void 0!==e?s.push({node:e,rangeStart:n,rangeEnd:i}):this.intersectRayTriangleRange(n,i)}}if(this.intersectRayTriangleRange(t.midStartIndex,t.rightStartIndex),i[a]>o||r[a]>0){const e=t.rightStartIndex,i=n;if(e<i){const n=t.rightNode;void 0!==n?s.push({node:n,rangeStart:e,rangeEnd:i}):this.intersectRayTriangleRange(e,i)}}}}static{this.numFacesTested=0}get estimatedMemoryUsage(){return e(this.triangleIndexMap)}}class g{constructor(t,e,n,i,r){this.aabb=t,this.axis=e,this.d=n,this.midStartIndex=i,this.rightStartIndex=r}}function f(t,e,n,i,r,s){const a=r+3;let o=n,c=n,h=i;for(;c<h;){const n=t[c],i=6*n;e[i+a]<=s?(t[c]=t[o],t[o]=n,++o,++c):e[i+r]>=s?(--h,t[c]=t[h],t[h]=n):++c}return{next:o,mid:h}}function u(t,e,n,s){if(s<=n)return i;let a=6*t[n],o=e[a++],c=e[a++],h=e[a++],d=e[a++],m=e[a++],l=e[a];for(let i=n+1;i<s;++i)a=6*t[i],o=Math.min(o,e[a++]),c=Math.min(c,e[a++]),h=Math.min(h,e[a++]),d=Math.max(d,e[a++]),m=Math.max(m,e[a++]),l=Math.max(l,e[a]);return r(o,c,h,d,m,l)}function p(t){const e=t[3]-t[0],n=t[4]-t[1],i=t[5]-t[2],r=e>n?e>i?0:n>i?1:2:n>i?1:i>e?2:0;return{axis:r,midValue:(t[r]+t[r+3])/2}}function x(t,e,n,i){const r=new Float64Array(6*e);for(let s=0;s<e;++s){const e=3*s,a=t[e]*i,o=t[e+1]*i,c=t[e+2]*i;for(let t=0;t<3;++t){const e=n[a+t],i=n[o+t],h=n[c+t];r[6*s+t]=Math.min(e,i,h),r[6*s+3+t]=Math.max(e,i,h)}}return r}function y(t,e,n){const i=e,r=n;let s=0,a=1/0;for(let o=0;o<3;++o){{const e=t[o];if(i[o]<e){if(r[o]<=m)return!1;const t=(e-i[o])/r[o];s=Math.max(s,t)}else if(r[o]<=-m){const t=(e-i[o])/r[o];a=Math.min(a,t)}if(s>a)return!1}{const e=t[o+3];if(i[o]>e){if(r[o]>=-m)return!1;const t=(e-i[o])/r[o];s=Math.max(s,t)}else if(r[o]>=m){const t=(e-i[o])/r[o];a=Math.min(a,t)}if(s>a)return!1}}return!0}const M=new a,I=()=>{};export{l as TriangleIntersectionData};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../Viewpoint.js";import{watch as n,sync as i}from"../core/reactiveUtils.js";import{property as a,subclass as s}from"../core/accessorSupport/decorators.js";import o from"./2d/FrameTask.js";import r from"./2d/MapViewConstraints.js";import{ViewStateManager as l}from"./2d/ViewStateManager.js";import{StationaryManager as p}from"./2d/support/StationaryManager.js";import{ViewEvents as g}from"./input/ViewEvents.js";const h=h=>{const m=h;let d=class extends m{constructor(...t){super(...t),this.fullOpacity=1,this.stateManager=new l({constraints:new r({view:this})}),this.stationaryManager=new p,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!1,labelsAnimationTime:0,labelCollisionsEnabled:!1},this.frameTask=new o(this),this.viewEvents=new g(this),this.padding={top:0,right:0,bottom:0,left:0},this.addHandles([n(()=>this.viewpoint,()=>this.stationaryManager.flip(),i)])}get constraintsInfo(){return{lods:null,spatialReference:null}}get extent(){return this.stateManager?.extent??null}set extent(t){this.stateManager.extent=t}get state(){return this.stateManager.state}get interacting(){return!1}get stationary(){return!this.animation&&this.stationaryManager.stationary}set animation(t){const e=this._get("animation");if(t===e)return;if(e&&e.stop(),t!==this.animationManager.animation&&this.animationManager.stop(),!t||t.isFulfilled())return void this._set("animation",null);this._set("animation",t);const n=()=>{this.destroyed||t===this._get("animation")&&(this._set("animation",null),this.frameTask?.requestFrame())};t.when(n,n)}get canZoomIn(){if(!this.ready)return!1;const t=this.constraints?.effectiveMaxScale,e=this.animation?.target,n=(e&&"then"in e?void 0:e?.scale)??this.scale??0;return 0===t||n>t}get canZoomOut(){if(!this.ready)return!1;const t=this.constraints?.effectiveMinScale,e=this.animation?.target,n=(e&&"then"in e?void 0:e?.scale)??this.scale??0;return 0===t||n<t}get constraints(){return this.stateManager?.constraints}set constraints(t){t.view=this;const e=this.stateManager.constraints;this.stateManager.constraints=t,e?.destroy()}get padding(){return this.stateManager?.padding}set padding(t){this.stateManager&&(this.stateManager.padding=t)}get resizeAlign(){return this.stateManager.resizeAlign}set resizeAlign(t){this.stateManager.resizeAlign=t}get rotation(){return this.stateManager.rotation??0}set rotation(t){const{rotationEnabled:e}=this.constraints;this.constraints.rotationEnabled=!0,this.stateManager.rotation=t,this.constraints.rotationEnabled=e}get viewpoint(){return this.stateManager.viewpoint??null}set viewpoint(t){this.stateManager.viewpoint=t,this.frameTask.requestFrame()}async zoomIn(){if(this.canZoomIn)return this.mapViewNavigation.zoomIn()}async zoomOut(){if(this.canZoomOut)return this.mapViewNavigation.zoomOut()}};return t([a({readOnly:!0})],d.prototype,"animationManager",void 0),t([a({readOnly:!0})],d.prototype,"fullOpacity",void 0),t([a()],d.prototype,"stateManager",void 0),t([a()],d.prototype,"constraintsInfo",null),t([a()],d.prototype,"extent",null),t([a({readOnly:!0})],d.prototype,"state",null),t([a({readOnly:!0})],d.prototype,"mapViewNavigation",void 0),t([a()],d.prototype,"renderingOptions",void 0),t([a({readOnly:!0})],d.prototype,"interacting",null),t([a()],d.prototype,"stationary",null),t([a()],d.prototype,"animation",null),t([a({readOnly:!0})],d.prototype,"canZoomIn",null),t([a({readOnly:!0})],d.prototype,"canZoomOut",null),t([a({type:r})],d.prototype,"constraints",null),t([a()],d.prototype,"padding",null),t([a()],d.prototype,"resizeAlign",null),t([a()],d.prototype,"rotation",null),t([a({readOnly:!0})],d.prototype,"viewEvents",void 0),t([a({type:e})],d.prototype,"viewpoint",null),d=t([s("esri.views.Viewport2DBaseMixin")],d),d};export{h as Viewport2DBaseMixin};
2
+ import{__decorate as t}from"tslib";import e from"../Viewpoint.js";import{watch as n,sync as i}from"../core/reactiveUtils.js";import{property as a,subclass as s}from"../core/accessorSupport/decorators.js";import o from"./2d/FrameTask.js";import r from"./2d/MapViewConstraints.js";import{ViewStateManager as l}from"./2d/ViewStateManager.js";import{StationaryManager as p}from"./2d/support/StationaryManager.js";import{ViewEvents as g}from"./input/ViewEvents.js";const h=h=>{const m=h;let d=class extends m{constructor(...t){super(...t),this.fullOpacity=1,this.stateManager=new l({constraints:new r({view:this})}),this.stationaryManager=new p,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!1,labelsAnimationTime:0,labelCollisionsEnabled:!1},this.frameTask=new o(this),this.viewEvents=new g(this),this.padding={top:0,right:0,bottom:0,left:0},this.addHandles([n(()=>this.viewpoint,()=>this.stationaryManager.flip(),i)])}get constraintsInfo(){return{lods:null,spatialReference:null}}get extent(){return this.stateManager?.extent??null}set extent(t){this.stateManager.extent=t}get state(){return this.stateManager.state}get interacting(){return!1}get stationary(){return!this.animation&&this.stationaryManager.stationary}set animation(t){const e=this._get("animation");if(t===e)return;if(e&&e.stop(),this.animationManager&&t!==this.animationManager.animation&&this.animationManager.stop(),!t||t.isFulfilled())return void this._set("animation",null);this._set("animation",t);const n=()=>{this.destroyed||t===this._get("animation")&&(this._set("animation",null),this.frameTask?.requestFrame())};t.when(n,n)}get canZoomIn(){if(!this.ready)return!1;const t=this.constraints?.effectiveMaxScale,e=this.animation?.target,n=(e&&"then"in e?void 0:e?.scale)??this.scale??0;return 0===t||n>t}get canZoomOut(){if(!this.ready)return!1;const t=this.constraints?.effectiveMinScale,e=this.animation?.target,n=(e&&"then"in e?void 0:e?.scale)??this.scale??0;return 0===t||n<t}get constraints(){return this.stateManager?.constraints}set constraints(t){t.view=this;const e=this.stateManager.constraints;this.stateManager.constraints=t,e?.destroy()}get padding(){return this.stateManager?.padding}set padding(t){this.stateManager&&(this.stateManager.padding=t)}get resizeAlign(){return this.stateManager.resizeAlign}set resizeAlign(t){this.stateManager.resizeAlign=t}get rotation(){return this.stateManager.rotation??0}set rotation(t){const{rotationEnabled:e}=this.constraints;this.constraints.rotationEnabled=!0,this.stateManager.rotation=t,this.constraints.rotationEnabled=e}get viewpoint(){return this.stateManager.viewpoint??null}set viewpoint(t){this.stateManager.viewpoint=t,this.frameTask.requestFrame()}async zoomIn(){if(this.canZoomIn)return this.mapViewNavigation.zoomIn()}async zoomOut(){if(this.canZoomOut)return this.mapViewNavigation.zoomOut()}};return t([a({readOnly:!0})],d.prototype,"animationManager",void 0),t([a({readOnly:!0})],d.prototype,"fullOpacity",void 0),t([a()],d.prototype,"stateManager",void 0),t([a()],d.prototype,"constraintsInfo",null),t([a()],d.prototype,"extent",null),t([a({readOnly:!0})],d.prototype,"state",null),t([a({readOnly:!0})],d.prototype,"mapViewNavigation",void 0),t([a()],d.prototype,"renderingOptions",void 0),t([a({readOnly:!0})],d.prototype,"interacting",null),t([a()],d.prototype,"stationary",null),t([a()],d.prototype,"animation",null),t([a({readOnly:!0})],d.prototype,"canZoomIn",null),t([a({readOnly:!0})],d.prototype,"canZoomOut",null),t([a({type:r})],d.prototype,"constraints",null),t([a()],d.prototype,"padding",null),t([a()],d.prototype,"resizeAlign",null),t([a()],d.prototype,"rotation",null),t([a({readOnly:!0})],d.prototype,"viewEvents",void 0),t([a({type:e})],d.prototype,"viewpoint",null),d=t([s("esri.views.Viewport2DBaseMixin")],d),d};export{h as Viewport2DBaseMixin};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{getAssetUrl as i}from"../../../assets.js";function e(i){const e=i.toLowerCase();return"image/bmp"===e||"image/emf"===e||"image/exif"===e||"image/gif"===e||"image/x-icon"===e||"image/jpeg"===e||"image/png"===e||"image/tiff"===e||"image/x-wmf"===e}function p(e){const p=i("esri/themes/base/images/files/");return e?"text/plain"===e?`${p}text-32.svg`:"application/pdf"===e?`${p}pdf-32.svg`:"text/csv"===e?`${p}csv-32.svg`:"application/gpx+xml"===e?`${p}gpx-32.svg`:"application/x-dwf"===e?`${p}cad-32.svg`:"application/postscript"===e||"application/json"===e||"text/xml"===e||"model/vrml"===e?`${p}code-32.svg`:"application/x-zip-compressed"===e||"application/x-7z-compressed"===e||"application/x-gzip"===e||"application/x-tar"===e||"application/x-gtar"===e||"application/x-bzip2"===e||"application/gzip"===e||"application/x-compress"===e||"application/x-apple-diskimage"===e||"application/x-rar-compressed"===e||"application/zip"===e?`${p}zip-32.svg`:e.includes("image/")?`${p}image-32.svg`:e.includes("audio/")?`${p}sound-32.svg`:e.includes("video/")?`${p}video-32.svg`:e.includes("msexcel")||e.includes("ms-excel")||e.includes("spreadsheetml")?`${p}excel-32.svg`:e.includes("msword")||e.includes("ms-word")||e.includes("wordprocessingml")?`${p}word-32.svg`:e.includes("powerpoint")||e.includes("presentationml")?`${p}report-32.svg`:`${p}generic-32.svg`:`${p}generic-32.svg`}function a(i){return i?"text/plain"===i?"file-text":"application/pdf"===i?"file-pdf":"text/csv"===i?"file-csv":"application/gpx+xml"===i?"file-gpx":"application/x-dwf"===i?"file-cad":"application/postscript"===i||"application/json"===i||"text/xml"===i||"model/vrml"===i?"file-code":"application/x-zip-compressed"===i||"application/x-7z-compressed"===i||"application/x-gzip"===i||"application/x-tar"===i||"application/x-gtar"===i||"application/x-bzip2"===i||"application/gzip"===i||"application/x-compress"===i||"application/x-apple-diskimage"===i||"application/x-rar-compressed"===i||"application/zip"===i?"file-zip":i.includes("image/")?"file-image":i.includes("audio/")?"file-sound":i.includes("video/")?"file-video":i.includes("msexcel")||i.includes("ms-excel")||i.includes("spreadsheetml")?"file-excel":i.includes("msword")||i.includes("ms-word")||i.includes("wordprocessingml")?"file-word":i.includes("powerpoint")||i.includes("presentationml")?"file-ppt":"file":"file"}export{a as getCalciteIconForAttachment,p as getIconPath,e as isSupportedImage};
2
+ import{getAssetUrl as i}from"../../../assets.js";function e(i){return i?i.startsWith("image/")?"image":i.startsWith("audio/")?"audio":i.startsWith("video/")?"video":i.startsWith("text/")||i.startsWith("application/")||i.startsWith("model/")?"document":"unknown":"unknown"}function p(i){const e=i.toLowerCase();return"image/bmp"===e||"image/emf"===e||"image/exif"===e||"image/gif"===e||"image/x-icon"===e||"image/jpeg"===e||"image/png"===e||"image/tiff"===e||"image/x-wmf"===e}function a(e){const p=i("esri/themes/base/images/files/");return e?"text/plain"===e?`${p}text-32.svg`:"application/pdf"===e?`${p}pdf-32.svg`:"text/csv"===e?`${p}csv-32.svg`:"application/gpx+xml"===e?`${p}gpx-32.svg`:"application/x-dwf"===e?`${p}cad-32.svg`:"application/postscript"===e||"application/json"===e||"text/xml"===e||"model/vrml"===e?`${p}code-32.svg`:"application/x-zip-compressed"===e||"application/x-7z-compressed"===e||"application/x-gzip"===e||"application/x-tar"===e||"application/x-gtar"===e||"application/x-bzip2"===e||"application/gzip"===e||"application/x-compress"===e||"application/x-apple-diskimage"===e||"application/x-rar-compressed"===e||"application/zip"===e?`${p}zip-32.svg`:e.includes("image/")?`${p}image-32.svg`:e.includes("audio/")?`${p}sound-32.svg`:e.includes("video/")?`${p}video-32.svg`:e.includes("msexcel")||e.includes("ms-excel")||e.includes("spreadsheetml")?`${p}excel-32.svg`:e.includes("msword")||e.includes("ms-word")||e.includes("wordprocessingml")?`${p}word-32.svg`:e.includes("powerpoint")||e.includes("presentationml")?`${p}report-32.svg`:`${p}generic-32.svg`:`${p}generic-32.svg`}function s(i){return i?"text/plain"===i?"file-text":"application/pdf"===i?"file-pdf":"text/csv"===i?"file-csv":"application/gpx+xml"===i?"file-gpx":"application/x-dwf"===i?"file-cad":"application/postscript"===i||"application/json"===i||"text/xml"===i||"model/vrml"===i?"file-code":"application/x-zip-compressed"===i||"application/x-7z-compressed"===i||"application/x-gzip"===i||"application/x-tar"===i||"application/x-gtar"===i||"application/x-bzip2"===i||"application/gzip"===i||"application/x-compress"===i||"application/x-apple-diskimage"===i||"application/x-rar-compressed"===i||"application/zip"===i?"file-zip":i.includes("image/")?"file-image":i.includes("audio/")?"file-sound":i.includes("video/")?"file-video":i.includes("msexcel")||i.includes("ms-excel")||i.includes("spreadsheetml")?"file-excel":i.includes("msword")||i.includes("ms-word")||i.includes("wordprocessingml")?"file-word":i.includes("powerpoint")||i.includes("presentationml")?"file-ppt":"file":"file"}export{e as getAttachmentTypeCategory,s as getCalciteIconForAttachment,a as getIconPath,p as isSupportedImage};
@@ -7,7 +7,7 @@ import type FieldInput from "./inputs/FieldInput.js";
7
7
  import type { EventedAccessor } from "../../core/Evented.js";
8
8
  import type { FieldValue } from "../../layers/support/fieldUtils.js";
9
9
  import type { TimeZone } from "../../time/types.js";
10
- import type { AttachmentsChangeEvent, AttributeFormSupportedLayerInfo, AttributeFormSupportedLayerUnion, BatchAttributeFormMode, BatchAttributeFormState, ValueChangeEvent, SubmitEvent } from "./types.js";
10
+ import type { AttachmentsChangeEvent, AttributeFormSupportedLayerInfo, AttributeFormSupportedLayerUnion, BatchAttributeFormMode, BatchAttributeFormState, SelectedAttachmentInfo, ValueChangeEvent, SubmitEvent } from "./types.js";
11
11
  import type { FormInput } from "./inputs/types.js";
12
12
  import type { EditType } from "../support/forms/types.js";
13
13
 
@@ -195,6 +195,8 @@ export default class BatchAttributeFormViewModel extends EventedAccessor {
195
195
  * @default false
196
196
  */
197
197
  accessor readOnly: boolean;
198
+ /** @internal */
199
+ get selectedAttachment(): SelectedAttachmentInfo | null;
198
200
  /** The set of form inputs used in `batch` editing [mode](https://developers.arcgis.com/javascript/latest/references/core/widgets/BatchAttributeForm/BatchAttributeFormViewModel/#mode). */
199
201
  get sharedForm(): BatchFormInputs;
200
202
  /**
@@ -272,6 +274,11 @@ export default class BatchAttributeFormViewModel extends EventedAccessor {
272
274
  * @returns The current attribute values for the given feature.
273
275
  */
274
276
  getValues(feature: Graphic): Graphic["attributes"];
277
+ /**
278
+ * @param value - Selected attachment info, or `null`/`undefined` to clear the selection.
279
+ * @internal
280
+ */
281
+ setSelectedAttachment(value: SelectedAttachmentInfo | null | undefined): void;
275
282
  /**
276
283
  * @param elementId - Attachment element identifier.
277
284
  * @param files - Files to stage for addition.
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{pushIfSome as t}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{abortMaybe as h,destroyMaybe as p}from"../../core/maybe.js";import{throwIfAborted as l,isAbortError as u}from"../../core/promiseUtils.js";import m from"../../core/ReactiveMap.js";import{on as c,sync as d,watch as f,whenOnce as y}from"../../core/reactiveUtils.js";import{property as g,subclass as v}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import _ from"../../geometry/SpatialReference.js";import{getGraphicLayer as A}from"../../graphic/graphicOriginUtils.js";import{system as x}from"../../time/constants.js";import{createReactiveGraphic as w,isAttributeFormSupportedLayerWithAttachments as I,layerSupportsQueryAttachments as C,queryAttachmentsForElements as E}from"./batchAttributeFormUtils.js";import{ArcadeExecutorProvider as M}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as b}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as k}from"./expressions/ExpressionsModel.js";import T from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as V}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as j,isFieldInput as H}from"./inputs/support/inputUtils.js";import L from"./templates/BatchFormTemplate.js";import{getLayerContingentValuesMetaData as B}from"./templates/support/contingentValuesUtils.js";import{createBatchFormTemplate as R}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as G,isGroupElementTemplate as U}from"./templates/support/templateUtils.js";import{isEmptyValue as S}from"../support/forms/formUtils.js";function W(e,t){return e?.find(e=>e.layer===t)}let N=class extends a{constructor(e){super(e),this._attachmentCache=new m,this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.features=new r,this._hasAsyncArcadeExpressions=!1,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.map=null,this.readOnly=!1,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new M,this._activeFormInputsByElementId=new Map,this._emptyForm=new T({inputs:[]}),this._emptyFormTemplate=new L({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new m,this._updatingHandles=new F,this._layerTemplateMap=new m,this._layerContingentValuesMap=new m,this._workingFeatures=new r,this._expressionsManager=new b({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:x}}),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.addHandles([c(()=>this.features,"after-changes",()=>{this.notifyChange("layers"),this._prepare()},d),f(()=>[this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),d),f(()=>this.activeForm,()=>this._activeFormInputsByElementId.clear(),d),f(()=>[this.activeFeature,this.activeLayer,this.activeForm],()=>{this._syncAttachments()},d)]),this._prepare()}destroy(){this._prepareTask=h(this._prepareTask),this._workingFeatures.destroyAll(),p(this._expressionsManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new m,this._emptyForm.destroy(),this._emptyFormTemplate.destroy()}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 activeLayer(){const{activeFeature:e}=this;if(!e)return null;return A(e)??null}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 hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}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"noElements";const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case"hidden:not-in-all-layers":case"hidden:no-domain-in-common":e.add("noElementsInCommon");break;case"hidden:field-definition":case"hidden:group-visibility-expression:all-features":case"hidden:visibility-expression:all-features":e.add("allElementsHidden");break;case"hidden:group-visibility-expression:some-features":case"hidden:visibility-expression:some-features":return"elementsHiddenInSome"}return e.has("allElementsHidden")?"allElementsHidden":"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&&Array.from(this._featureFormMap.values()).every(e=>e.valid)}get layers(){const e=new Set;return this.features.forEach(t=>{const s=A(t);s&&e.add(s)}),Array.from(e)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){this.submitHasBeenAttempted=!0,this.emit("submit",{name:"submit",results:this._makeSubmitResults(),valid:this.valid})}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(j(e)){const t=e.inputs.find(e=>H(e)&&!e.valid);if(t)return{input:t,groupInput:e}}if(H(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._reactiveGraphicLookup.get(e);if(!t)throw new i("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}notifyGeometriesChanged(e){const t=[];for(const s of e){const e=this._reactiveGraphicLookup.get(s);e&&(t.push(e),e.geometry=s.geometry)}this._expressionsManager.runGeometryDependentExpressions(t)}async setFieldInputValue(e,t){const s=new Set(this.invalidFeatures);await e.setValueFromUser(t),this.userHasChangedValues=!0,this._trackValidityChange(s),this.emit("value-change",{features:e.features.toArray().map(e=>e.source),fieldName:e.fieldName,name:"value-change",value:t})}async setValue(e,t){const s=this.findFieldInput(e);if(null==s)throw new i("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(s,t)}async stageAddAttachments(e,t){if(0===t.length)return[];const s=this._findAttachmentInput(e);if(!s)return[];const r=await s.stageAddAttachments(t,this._expressionsManager.arcadeContext);return this.userHasChangedValues=!0,this._emitAttachmentsChange(s),r}stageDeleteAttachment(e,t){const s=this._findAttachmentInput(e);if(!s)return;const r=this._findAttachment(s,t);r&&(s.stageDeleteAttachment(r),this.userHasChangedValues=!0,this._emitAttachmentsChange(s))}stageRenameAttachment(e,t,s){const r=this._findAttachmentInput(e);if(!r)return;const i=this._findAttachment(r,t);i&&0!==s.trim().length&&(r.stageRenameAttachment(i,s.trim()),this.userHasChangedValues=!0,this._emitAttachmentsChange(r))}async stageReplaceAttachment(e,t,s){const r=this._findAttachmentInput(e);if(!r)return;const i=this._findAttachment(r,t);i&&(await r.stageReplaceAttachment(i,s,this._expressionsManager.arcadeContext),this.userHasChangedValues=!0,this._emitAttachmentsChange(r))}clearAttachmentChanges(e){const t=this._findAttachmentInput(e);t&&(t.clearAttachmentChanges(),this._emitAttachmentsChange(t))}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}async _trackValidityChange(e){await y(()=>!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?V(t,new r([e]),this._expressionsManager):this._emptyForm}_makeSubmitResults(){const e=new Map;for(const[s,r]of this._reactiveGraphicLookup){const i=[],a=[],n=this._featureFormMap.get(r)?.allAttachmentElementInputs??[];for(const e of n)t(i,e.toSubmitEdits()),e.valid||a.push(e.template.elementId);e.set(s,{feature:s,values:{...r.attributes},invalidFields:[],attachmentEdits:i,invalidAttachmentElementIds:a})}for(const t of this.sharedForm.allFieldInputs)for(const s of t.invalidFeatures)e.get(s)?.invalidFields.push(t.fieldName);return Array.from(e.values())}_findAttachmentInput(e){const t=this.activeForm.allAttachmentElementInputs.find(t=>t.template.elementId===e);return t||n.getLogger(this).error(`Attachment input not found for elementId '${e}'`),t}_findAttachment(e,t){const s=e.findAttachment(t);return s||n.getLogger(this).error(`Attachment '${t}' not found for attachment element '${e.template.elementId}'`),s}_makeAttachmentEdits(e){const s=[];for(const r of e.allAttachmentElementInputs)t(s,r.toSubmitEdits());return s}_emitAttachmentsChange(e){const t=e.single.feature;if(!t)return;const s=this._featureFormMap.get(t);this.emit("attachments-change",{name:"attachments-change",feature:t.source,attachmentEdits:this._makeAttachmentEdits(s??this.activeForm),valid:this.valid})}_prepare(){this._hasAsyncArcadeExpressions=!1,this._prepareTask=h(this._prepareTask),this._updateWorkingFeatures(),p(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new b({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??_.WebMercator,map:this.map,timeZone:this.timeZone||"system"}});const{layers:e}=this;if(0===e.length)return;const t=s(async t=>{try{l(t);const s=new Map;for(const i of e){const e=await B(i);if(l(t),e){const t=e.fieldGroups.flatMap(e=>e.fields);this._layerContingentValuesMap.set(i,new Set(t))}else this._layerContingentValuesMap.set(i,new Set);const r=W(this.layerInfos,i),a=await R(i,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this.timeZone},r?.formTemplate);l(t),this._layerTemplateMap.set(i,a);const n=a.getExpressionExecutorsForLayer(i);if(this._expressionsManager.layerExpressionsModelMap.set(i,new k({preserveFieldValuesWhenHidden:a.preserveFieldValuesWhenHidden,executorMap:n})),!this._hasAsyncArcadeExpressions)for(const t of n.keys()){const e=n.get(t);if(this._hasAsyncArcadeExpressions=!0===(e.editableExpression?.isAsync||e.requiredExpression?.isAsync||e.valueExpression?.isAsync||e.visibilityExpression?.isAsync),this._hasAsyncArcadeExpressions)break}for(const t of a.elements){if(G(t))continue;const e=t.clone();U(e)&&(e.elements=e.elements.filter(e=>!G(e)));const{elementId:r}=e;s.has(r)?s.get(r).foldIn(e):s.set(r,e)}}if(this.hasTooManyComplexFeatures)throw new i("too-many-features-with-complex-forms","There are too many features to load into the form with the configured complexity");if(this.hasTooManyFeatures)throw new i("too-many-features","There are too many features to load into the form.");const r=new L({elements:Array.from(s.values())});this.sharedFormTemplate=r,this.sharedForm=V(r,this._workingFeatures,this._expressionsManager),await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray())}catch(s){throw u(s)||n.getLogger(this).error("Failed preparing form",s),s}});this._updatingHandles.consumePromise(t.promise),this._prepareTask=t}_updateWorkingFeatures(){this._workingFeatures.destroyAll();for(const t of this._featureFormMap.values())t.destroy();this._featureFormMap.clear(),this._attachmentCache.clear();const{features:e}=this;if(this._reactiveGraphicLookup=new m,0!==e.length){this._workingFeatures.addMany(e.map(w));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}async _syncAttachments(){const{activeFeature:e,activeLayer:t,activeForm:s}=this;if(!(e&&s&&I(t)&&C(t)))return;const r=e.getObjectId();if(null==r)return;const i=this._attachmentCache.get(t),a=s.allAttachmentElementInputs;if(!a.length)return;let n;if(i){const e=i.get(r);e&&(n=e)}if(!n){n=await E(t,r,a);o(this._attachmentCache,t,()=>new m).set(r,n)}for(const o of a)o.applyFetchedAttachments(D(o,n))}};e([g()],N.prototype,"_attachmentCache",void 0),e([g({readOnly:!0})],N.prototype,"activeFeature",null),e([g()],N.prototype,"activeFeatureIndex",void 0),e([g({readOnly:!0})],N.prototype,"activeForm",null),e([g({readOnly:!0})],N.prototype,"activeLayer",null),e([g()],N.prototype,"disabled",void 0),e([g()],N.prototype,"calculating",null),e([g()],N.prototype,"editType",void 0),e([g()],N.prototype,"features",void 0),e([g()],N.prototype,"expressionEvaluationFailed",null),e([g()],N.prototype,"hasNonActiveInvalidFeatures",null),e([g()],N.prototype,"hasAsyncArcadeExpressions",null),e([g()],N.prototype,"_hasAsyncArcadeExpressions",void 0),e([g()],N.prototype,"invalidFeatures",null),e([g()],N.prototype,"hasVisibleInputs",null),e([g()],N.prototype,"hasLayersWithContingentValues",null),e([g()],N.prototype,"maximumFeatureCount",void 0),e([g()],N.prototype,"maximumFeatureCountWithComplexForms",void 0),e([g()],N.prototype,"visibleInputs",null),e([g()],N.prototype,"map",void 0),e([g()],N.prototype,"noVisibleElementsReason",null),e([g()],N.prototype,"readOnly",void 0),e([g()],N.prototype,"spatialReference",void 0),e([g()],N.prototype,"submitHasBeenAttempted",void 0),e([g()],N.prototype,"timeZone",void 0),e([g()],N.prototype,"updating",null),e([g()],N.prototype,"valid",null),e([g()],N.prototype,"layers",null),e([g()],N.prototype,"mode",null),e([g()],N.prototype,"sharedForm",void 0),e([g()],N.prototype,"sharedFormTemplate",void 0),e([g()],N.prototype,"userHasChangedValues",void 0),e([g()],N.prototype,"layerInfos",void 0),e([g()],N.prototype,"_arcadeExecutorProvider",void 0),e([g()],N.prototype,"_prepareTask",void 0),e([g()],N.prototype,"_reactiveGraphicLookup",void 0),e([g()],N.prototype,"_layerTemplateMap",void 0),e([g()],N.prototype,"_layerContingentValuesMap",void 0),e([g()],N.prototype,"_workingFeatures",void 0),e([g()],N.prototype,"_expressionsManager",void 0),N=e([v("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],N);const O=N;function Z(e){return null!=e&&e.trim().length>0}function P(e,t){const s=e.keywords;return Z(s)&&s.toLowerCase()===t}function D(e,t){const s="attachment"===e.input?.type?e.input.attachmentAssociationType:"exact",r=e.attachmentKeyword;if("any"===s)return t;if("exactOrNone"===s){if(S(r))return t.filter(e=>!Z(e.keywords));const e=r.toLowerCase();return t.filter(t=>!Z(t.keywords)||P(t,e))}if(S(r))return t;const i=r.toLowerCase();return t.filter(e=>P(e,i))}export{O as default};
2
+ import{__decorate as e}from"tslib";import{pushIfSome as t}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{abortMaybe as h,destroyMaybe as l}from"../../core/maybe.js";import{throwIfAborted as p,isAbortError as u}from"../../core/promiseUtils.js";import m from"../../core/ReactiveMap.js";import{on as c,sync as d,watch as f,whenOnce as y}from"../../core/reactiveUtils.js";import{property as g,subclass as v}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as _}from"../../core/support/UpdatingHandles.js";import F from"../../geometry/SpatialReference.js";import{getGraphicLayer as A}from"../../graphic/graphicOriginUtils.js";import{system as x}from"../../time/constants.js";import{createReactiveGraphic as w,isAttributeFormSupportedLayerWithAttachments as I,layerSupportsQueryAttachments as C,queryAttachmentsForElements as E}from"./batchAttributeFormUtils.js";import{ArcadeExecutorProvider as M}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as b}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as k}from"./expressions/ExpressionsModel.js";import T from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as V}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as j,isFieldInput as H}from"./inputs/support/inputUtils.js";import L from"./templates/BatchFormTemplate.js";import{getLayerContingentValuesMetaData as B}from"./templates/support/contingentValuesUtils.js";import{createBatchFormTemplate as R}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as S,isGroupElementTemplate as G}from"./templates/support/templateUtils.js";import{isEmptyValue as U}from"../support/forms/formUtils.js";function W(e,t){return e?.find(e=>e.layer===t)}let N=class extends a{constructor(e){super(e),this._attachmentCache=new m,this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.features=new r,this._hasAsyncArcadeExpressions=!1,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.map=null,this.readOnly=!1,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new M,this._selectedAttachment=null,this._activeFormInputsByElementId=new Map,this._emptyForm=new T({inputs:[]}),this._emptyFormTemplate=new L({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new m,this._updatingHandles=new _,this._layerTemplateMap=new m,this._layerContingentValuesMap=new m,this._workingFeatures=new r,this._expressionsManager=new b({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:x}}),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.addHandles([c(()=>this.features,"after-changes",()=>{this.setSelectedAttachment(null),this.notifyChange("layers"),this._prepare()},d),f(()=>[this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),d),f(()=>this.activeForm,()=>{this._activeFormInputsByElementId.clear(),this._syncAttachments()},d),f(()=>this.activeFeature,()=>{this.setSelectedAttachment(null),this._syncAttachments()},d)]),this._prepare()}destroy(){this._prepareTask=h(this._prepareTask),this._workingFeatures.destroyAll(),l(this._expressionsManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new m,this._emptyForm.destroy(),this._emptyFormTemplate.destroy()}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 activeLayer(){const{activeFeature:e}=this;if(!e)return null;return A(e)??null}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 hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}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"noElements";const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case"hidden:not-in-all-layers":case"hidden:no-domain-in-common":e.add("noElementsInCommon");break;case"hidden:field-definition":case"hidden:group-visibility-expression:all-features":case"hidden:visibility-expression:all-features":e.add("allElementsHidden");break;case"hidden:group-visibility-expression:some-features":case"hidden:visibility-expression:some-features":return"elementsHiddenInSome"}return e.has("allElementsHidden")?"allElementsHidden":"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&&Array.from(this._featureFormMap.values()).every(e=>e.valid)}get layers(){const e=new Set;return this.features.forEach(t=>{const s=A(t);s&&e.add(s)}),Array.from(e)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){this.submitHasBeenAttempted=!0,this.emit("submit",{name:"submit",results:this._makeSubmitResults(),valid:this.valid})}get selectedAttachment(){return this._selectedAttachment}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(j(e)){const t=e.inputs.find(e=>H(e)&&!e.valid);if(t)return{input:t,groupInput:e}}if(H(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._reactiveGraphicLookup.get(e);if(!t)throw new i("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}notifyGeometriesChanged(e){const t=[];for(const s of e){const e=this._reactiveGraphicLookup.get(s);e&&(t.push(e),e.geometry=s.geometry)}this._expressionsManager.runGeometryDependentExpressions(t)}async setFieldInputValue(e,t){const s=new Set(this.invalidFeatures);await e.setValueFromUser(t),this.userHasChangedValues=!0,this._trackValidityChange(s),this.emit("value-change",{features:e.features.toArray().map(e=>e.source),fieldName:e.fieldName,name:"value-change",value:t})}async setValue(e,t){const s=this.findFieldInput(e);if(null==s)throw new i("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(s,t)}async stageAddAttachments(e,t){if(0===t.length)return[];const s=this._findAttachmentInput(e);if(!s)return[];const r=await s.stageAddAttachments(t,this._expressionsManager.arcadeContext);return this.userHasChangedValues=!0,this._emitAttachmentsChange(s),r}stageDeleteAttachment(e,t){const s=this._findAttachmentInput(e);if(!s)return;const r=this._findAttachment(s,t);r&&(s.stageDeleteAttachment(r),this.userHasChangedValues=!0,this._emitAttachmentsChange(s))}stageRenameAttachment(e,t,s){const r=this._findAttachmentInput(e);if(!r)return;const i=this._findAttachment(r,t);i&&0!==s.trim().length&&(r.stageRenameAttachment(i,s.trim()),this.userHasChangedValues=!0,this._emitAttachmentsChange(r))}async stageReplaceAttachment(e,t,s){const r=this._findAttachmentInput(e);if(!r)return;const i=this._findAttachment(r,t);i&&(await r.stageReplaceAttachment(i,s,this._expressionsManager.arcadeContext),this.userHasChangedValues=!0,this._emitAttachmentsChange(r))}clearAttachmentChanges(e){const t=this._findAttachmentInput(e);t&&(t.clearAttachmentChanges(),this._emitAttachmentsChange(t))}setSelectedAttachment(e){this._selectedAttachment=e??null}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}async _trackValidityChange(e){await y(()=>!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?V(t,new r([e]),this._expressionsManager):this._emptyForm}_makeSubmitResults(){const e=new Map;for(const[s,r]of this._reactiveGraphicLookup){const i=[],a=[],n=this._featureFormMap.get(r)?.allAttachmentElementInputs??[];for(const e of n)t(i,e.toSubmitEdits()),e.valid||a.push(e.template.elementId);e.set(s,{feature:s,values:{...r.attributes},invalidFields:[],attachmentEdits:i,invalidAttachmentElementIds:a})}for(const t of this.sharedForm.allFieldInputs)for(const s of t.invalidFeatures)e.get(s)?.invalidFields.push(t.fieldName);return Array.from(e.values())}_findAttachmentInput(e){const t=this.activeForm.allAttachmentElementInputs.find(t=>t.template.elementId===e);return t||n.getLogger(this).error(`Attachment input not found for elementId '${e}'`),t}_findAttachment(e,t){const s=e.findAttachment(t);return s||n.getLogger(this).error(`Attachment '${t}' not found for attachment element '${e.template.elementId}'`),s}_makeAttachmentEdits(e){const s=[];for(const r of e.allAttachmentElementInputs)t(s,r.toSubmitEdits());return s}_emitAttachmentsChange(e){const t=e.single.feature;if(!t)return;const s=this._featureFormMap.get(t);this.emit("attachments-change",{name:"attachments-change",feature:t.source,attachmentEdits:this._makeAttachmentEdits(s??this.activeForm),valid:this.valid})}_prepare(){this._hasAsyncArcadeExpressions=!1,this._prepareTask=h(this._prepareTask),this._updateWorkingFeatures(),l(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new b({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??F.WebMercator,map:this.map,timeZone:this.timeZone||"system"}});const{layers:e}=this;if(0===e.length)return;const t=s(async t=>{try{p(t);const s=new Map;for(const i of e){const e=await B(i);if(p(t),e){const t=e.fieldGroups.flatMap(e=>e.fields);this._layerContingentValuesMap.set(i,new Set(t))}else this._layerContingentValuesMap.set(i,new Set);const r=W(this.layerInfos,i),a=await R(i,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this.timeZone},r?.formTemplate);p(t),this._layerTemplateMap.set(i,a);const n=a.getExpressionExecutorsForLayer(i);if(this._expressionsManager.layerExpressionsModelMap.set(i,new k({preserveFieldValuesWhenHidden:a.preserveFieldValuesWhenHidden,executorMap:n})),!this._hasAsyncArcadeExpressions)for(const t of n.keys()){const e=n.get(t);if(this._hasAsyncArcadeExpressions=!0===(e.editableExpression?.isAsync||e.requiredExpression?.isAsync||e.valueExpression?.isAsync||e.visibilityExpression?.isAsync),this._hasAsyncArcadeExpressions)break}for(const t of a.elements){if(S(t))continue;const e=t.clone();G(e)&&(e.elements=e.elements.filter(e=>!S(e)));const{elementId:r}=e;s.has(r)?s.get(r).foldIn(e):s.set(r,e)}}if(this.hasTooManyComplexFeatures)throw new i("too-many-features-with-complex-forms","There are too many features to load into the form with the configured complexity");if(this.hasTooManyFeatures)throw new i("too-many-features","There are too many features to load into the form.");const r=new L({elements:Array.from(s.values())});this.sharedFormTemplate=r,this.sharedForm=V(r,this._workingFeatures,this._expressionsManager),await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray())}catch(s){throw u(s)||n.getLogger(this).error("Failed preparing form",s),s}});this._updatingHandles.consumePromise(t.promise),this._prepareTask=t}_updateWorkingFeatures(){this._workingFeatures.destroyAll();for(const t of this._featureFormMap.values())t.destroy();this._featureFormMap.clear(),this._attachmentCache.clear();const{features:e}=this;if(this._reactiveGraphicLookup=new m,0!==e.length){this._workingFeatures.addMany(e.map(w));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}async _syncAttachments(){const{activeFeature:e,activeLayer:t,activeForm:s}=this;if(!(e&&s&&I(t)&&C(t)))return;const r=e.getObjectId();if(null==r)return;const i=this._attachmentCache.get(t),a=s.allAttachmentElementInputs;if(!a.length)return;let n;if(i){const e=i.get(r);e&&(n=e)}if(!n){n=await E(t,r,a);o(this._attachmentCache,t,()=>new m).set(r,n)}for(const o of a)o.applyFetchedAttachments(D(o,n))}};e([g()],N.prototype,"_attachmentCache",void 0),e([g({readOnly:!0})],N.prototype,"activeFeature",null),e([g()],N.prototype,"activeFeatureIndex",void 0),e([g({readOnly:!0})],N.prototype,"activeForm",null),e([g({readOnly:!0})],N.prototype,"activeLayer",null),e([g()],N.prototype,"disabled",void 0),e([g()],N.prototype,"calculating",null),e([g()],N.prototype,"editType",void 0),e([g()],N.prototype,"features",void 0),e([g()],N.prototype,"expressionEvaluationFailed",null),e([g()],N.prototype,"hasNonActiveInvalidFeatures",null),e([g()],N.prototype,"hasAsyncArcadeExpressions",null),e([g()],N.prototype,"_hasAsyncArcadeExpressions",void 0),e([g()],N.prototype,"invalidFeatures",null),e([g()],N.prototype,"hasVisibleInputs",null),e([g()],N.prototype,"hasLayersWithContingentValues",null),e([g()],N.prototype,"maximumFeatureCount",void 0),e([g()],N.prototype,"maximumFeatureCountWithComplexForms",void 0),e([g()],N.prototype,"visibleInputs",null),e([g()],N.prototype,"map",void 0),e([g()],N.prototype,"noVisibleElementsReason",null),e([g()],N.prototype,"readOnly",void 0),e([g()],N.prototype,"spatialReference",void 0),e([g()],N.prototype,"submitHasBeenAttempted",void 0),e([g()],N.prototype,"timeZone",void 0),e([g()],N.prototype,"updating",null),e([g()],N.prototype,"valid",null),e([g()],N.prototype,"layers",null),e([g()],N.prototype,"mode",null),e([g()],N.prototype,"sharedForm",void 0),e([g()],N.prototype,"sharedFormTemplate",void 0),e([g()],N.prototype,"selectedAttachment",null),e([g()],N.prototype,"userHasChangedValues",void 0),e([g()],N.prototype,"layerInfos",void 0),e([g()],N.prototype,"_arcadeExecutorProvider",void 0),e([g()],N.prototype,"_selectedAttachment",void 0),e([g()],N.prototype,"_prepareTask",void 0),e([g()],N.prototype,"_reactiveGraphicLookup",void 0),e([g()],N.prototype,"_layerTemplateMap",void 0),e([g()],N.prototype,"_layerContingentValuesMap",void 0),e([g()],N.prototype,"_workingFeatures",void 0),e([g()],N.prototype,"_expressionsManager",void 0),N=e([v("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],N);const O=N;function Z(e){return null!=e&&e.trim().length>0}function P(e,t){const s=e.keywords;return Z(s)&&s.toLowerCase()===t}function D(e,t){const s="attachment"===e.input?.type?e.input.attachmentAssociationType:"exact",r=e.attachmentKeyword;if("any"===s)return t;if("exactOrNone"===s){if(U(r))return t.filter(e=>!Z(e.keywords));const e=r.toLowerCase();return t.filter(t=>!Z(t.keywords)||P(t,e))}if(U(r))return t;const i=r.toLowerCase();return t.filter(e=>P(e,i))}export{O as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{isString as t}from"../../support/guards.js";import{isSupportedImage as n}from"../Attachments/support/attachmentUtils.js";function r(t){return String(t.globalId||t.id||t.name)}function u(n,r,u){const{size:e,url:o}=n;if(!t(o)||!o.length)return null;const s=[];return r&&null!=u&&s.push(`w=${u}`),null==e||Number.isNaN(e)||s.push(`s=${e}`),s.length?`${o}${o.includes("?")?"&":"?"}${s.join("&")}`:o}function e(t){return n(t.contentType)}export{r as getAttachmentKey,u as getAttachmentUrl,e as isImageAttachment};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- const e="esri-batch-attribute-form",t=`${e}__group`,i=`${e}__input`,n={base:e,form:`${e}__form`,formHeader:`${e}__form-header`,noticeError:`${e}__notice-error`,label:`${e}__label`,labelTextContent:`${e}__label-text-content`,fieldInput:`${i}`,textElementInput:`${e}__text-element-input`,relationshipElementInput:`${e}__relationship-element-input`,utilityNetworkAssociationsElementInput:`${e}__utility-network-associations-element-input`,inputRadio:`${i}--radio`,placeholderRadio:`${i}--radio-placeholder`,inputRadioGroup:`${i}--radio-group`,inputRadioLabel:`${i}--radio-label`,inputDisabled:`${i}--disabled`,inputSwitch:`${i}--switch`,centeredButton:`${e}__centered-button`,description:`${e}__description-text`,dateInputContainer:`${`${e}__date`}-input-container`,block:`${e}__block`,group:t,groupSequential:`${t}--sequential`,individualElement:`${t}__individual-element`};export{n as css};
2
+ const t="esri-batch-attribute-form",e=`${t}__group`,a=`${t}__input`,i=`${t}__attachment-element`,n={base:t,form:`${t}__form`,formHeader:`${t}__form-header`,noticeError:`${t}__notice-error`,label:`${t}__label`,labelTextContent:`${t}__label-text-content`,fieldInput:`${a}`,textElementInput:`${t}__text-element-input`,attachmentElementInput:`${i}-input`,attachmentElementLabel:`${i}-label`,attachmentElementList:`${i}-list`,attachmentElementListItem:`${i}-list-item`,attachmentElementListItemStart:`${i}-list-item-start`,attachmentElementListItemThumb:`${i}-list-item-thumb`,attachmentElementListItemIcon:`${i}-list-item-icon`,attachmentElementEmptyState:`${i}-empty-state`,attachmentElementEmptyAction:`${i}-empty-action`,attachmentElementDetail:`${i}-detail`,attachmentElementDetailPreview:`${i}-detail-preview`,attachmentElementDetailPreviewImage:`${i}-detail-preview-image`,attachmentElementDetailPreviewIcon:`${i}-detail-preview-icon`,attachmentElementDetailActions:`${i}-detail-actions`,attachmentElementDetailMetadata:`${i}-detail-metadata`,attachmentElementDetailMetadataLabel:`${i}-detail-metadata-label`,attachmentElementDetailMetadataValue:`${i}-detail-metadata-value`,relationshipElementInput:`${t}__relationship-element-input`,utilityNetworkAssociationsElementInput:`${t}__utility-network-associations-element-input`,inputRadio:`${a}--radio`,placeholderRadio:`${a}--radio-placeholder`,inputRadioGroup:`${a}--radio-group`,inputRadioLabel:`${a}--radio-label`,inputDisabled:`${a}--disabled`,inputSwitch:`${a}--switch`,centeredButton:`${t}__centered-button`,description:`${t}__description-text`,dateInputContainer:`${`${t}__date`}-input-container`,block:`${t}__block`,group:e,groupSequential:`${e}--sequential`,individualElement:`${e}__individual-element`};export{n as css};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../core/Collection.js";import a from"../../../core/Logger.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import s from"../../../core/ReactiveMap.js";import i from"../../../core/ReactiveSet.js";import{generateBracedUUID as o}from"../../../core/uuid.js";import{property as r,subclass as l}from"../../../core/accessorSupport/decorators.js";import d from"../../../rest/query/support/AttachmentInfo.js";import{isAttributeFormSupportedLayer as c}from"../batchAttributeFormUtils.js";import h from"./EditableInput.js";import m from"./SingleFeatureInputAdapter.js";let p=-1,u=class extends h{constructor(t){super(t),this.attachments=[],this.group=null,this.single=new m({input:this}),this.type="attachment",this._initialAttachments=[],this._stagedAdds=new e,this._stagedDeletes=new i,this._stagedUpdates=new s}get allowUserRename(){return this.template.allowUserRename}get attachmentKeyword(){return this.template.attachmentKeyword?.trim()}get displayFilename(){return this.template.displayFilename}get feature(){return this.single.feature}get hasAttachmentChanges(){return this._stagedAdds.length>0||this._stagedUpdates.size>0||this._stagedDeletes.size>0}get input(){return this.template.input}get layer(){return this.single.layer}get maxAttachmentCount(){return this.template.maxAttachmentCount}get minAttachmentCount(){return this.template.minAttachmentCount}get useOriginalFilename(){return this.template.useOriginalFilename}get valid(){const t=this.attachments.length,e=this.minAttachmentCount??-1/0,a=this.maxAttachmentCount??1/0,n=this.hasAttachmentChanges;return!(t<e||t>a)||!n}get _expressionLayer(){const t=this.layer;if(t)return"scene"===t.type&&"associatedLayer"in t&&null!=t.associatedLayer?t.associatedLayer:"feature"===t.type?t:void 0}applyFetchedAttachments(t){this._initialAttachments=t,this._recomputeAttachments()}clearAttachmentChanges(){this._stagedAdds.removeAll(),this._stagedUpdates.clear(),this._stagedDeletes.clear(),this._recomputeAttachments()}stageAddAttachment(t){const{contentType:e,data:a,name:n}=t,s=t.globalId??o(),i=new d({contentType:e??void 0,globalId:s,id:p--,keywords:this.attachmentKeyword??void 0,name:n});return this._stagedAdds.add({globalId:s,info:i,data:a}),this._recomputeAttachments(),i}async stageAddAttachments(t,e){if(0===t.length)return[];const a=[],n=new Map,s=Date.now();for(let i=0;i<t.length;i++){const o=t[i],r=o instanceof File?o.name:`attachment-${s}_${i+1}`,l=await this._computeAttachmentFilename(r,e),d=this._makeUniqueFilenameForOperation(n,l);a.push(this.stageAddAttachment({contentType:o.type,data:o,name:d}))}return a}findAttachment(t){if(t)return this.attachments.find(e=>e.globalId===t)}stageDeleteAttachment(t){const e=t.globalId;if(!e)return;const a=this._stagedAdds.findIndex(t=>t.globalId===e);if(a>-1)return this._stagedAdds.removeAt(a),void this._recomputeAttachments();this._stagedUpdates.delete(e),this._stagedDeletes.add(e),this._recomputeAttachments()}stageRenameAttachment(t,e){const a=t.globalId;if(!a)return;const n=this._stagedAdds.find(t=>t.globalId===a);if(n)return n.info.name=e,void this._recomputeAttachments();const s=this._stagedUpdates.get(a);this._stagedUpdates.set(a,{...s,info:t,name:e}),this._recomputeAttachments()}async stageReplaceAttachment(t,e,a){const n=e instanceof File?e.name:t.name,s=await this._computeAttachmentFilename(n,a);this._stageReplaceAttachment(t,e,s)}toSubmitEdits(){const t=[],e=[],n=Array.from(this._stagedDeletes);if(0===this._stagedAdds.length&&0===this._stagedUpdates.size&&0===n.length)return null;const s=this._featureIdentifier;if(!s)return a.getLogger(this).error("Unable to build attachment edits without a valid feature and layer."),null;for(const a of this._stagedAdds)t.push({feature:s,attachment:{globalId:a.globalId,contentType:a.info.contentType,data:a.data,name:a.info.name}});for(const[a,i]of this._stagedUpdates)e.push({feature:s,attachment:{globalId:a,contentType:i.contentType,data:i.data,name:i.name}});return{label:this.template.label,attachmentKeyword:this.attachmentKeyword,add:t,delete:n,update:e}}_recomputeAttachments(){const t=this._stagedDeletes,e=[];for(const a of this._stagedAdds)e.push(a.info);for(const a of this._initialAttachments){const n=a.globalId;if(!n||!t.has(n)){if(n&&this._stagedUpdates.has(n)){const t=this._stagedUpdates.get(n),s=a.clone();null!=t.name&&(s.name=t.name),e.push(s);continue}e.push(a)}}this.attachments=e}get _featureIdentifier(){const t=this.single.feature,e=this.layer;if(!t||!c(e))return null;const a=e.objectIdField,n="globalIdField"in e?e.globalIdField:null,s=t.getGlobalId()??(n?t.getAttribute(n):void 0);if(s)return{globalId:s};const i=t.getObjectId()??t.getAttribute(a),o=Number(i);return null==i||isNaN(o)?null:{objectId:o}}async _computeAttachmentFilename(t,e){const s=this.template.filenameExpressionExecutor;if(!s)return t;const i=this.single.feature,o=i?.plainGraphic,r=this._expressionLayer,l={$originalfeature:i?.original,$editcontext:{editType:e.editType},$layer:r,$featureset:r,$datastore:r?.url,$feature:o,$map:e.map},d={rawOutput:!0,spatialReference:e.spatialReference,timeZone:e.timeZone};try{const t=s.isAsync?await s.executeAsync(l,d):s.execute(l,d);if("string"==typeof t&&t.trim().length>0)return t.trim()}catch(c){n(c)||a.getLogger(this).error("Failed evaluating attachment filename expression",c)}return t}_makeUniqueFilenameForOperation(t,e){const a=e.toLowerCase(),n=t.get(a)??0;if(t.set(a,n+1),0===n)return e;const s=e.lastIndexOf(".");return`${s>0?e.slice(0,s):e}_${n}${s>0?e.slice(s):""}`}_stageReplaceAttachment(t,e,a){const n=t.globalId;if(!n)return;const s=this._stagedAdds.find(t=>t.globalId===n);if(s)return s.data=e,s.info.name=a,s.info.contentType=e.type,void this._recomputeAttachments();const i=this._stagedUpdates.get(n);this._stagedUpdates.set(n,{...i,info:t,contentType:e.type||i?.contentType,data:e,name:a}),this._recomputeAttachments()}};t([r()],u.prototype,"allowUserRename",null),t([r()],u.prototype,"attachmentKeyword",null),t([r()],u.prototype,"attachments",void 0),t([r()],u.prototype,"displayFilename",null),t([r()],u.prototype,"feature",null),t([r()],u.prototype,"group",void 0),t([r({readOnly:!0})],u.prototype,"hasAttachmentChanges",null),t([r()],u.prototype,"input",null),t([r()],u.prototype,"layer",null),t([r()],u.prototype,"maxAttachmentCount",null),t([r()],u.prototype,"minAttachmentCount",null),t([r({readOnly:!0})],u.prototype,"single",void 0),t([r({readOnly:!0})],u.prototype,"type",void 0),t([r()],u.prototype,"useOriginalFilename",null),t([r({readOnly:!0})],u.prototype,"valid",null),t([r()],u.prototype,"_initialAttachments",void 0),t([r()],u.prototype,"_expressionLayer",null),t([r()],u.prototype,"_stagedAdds",void 0),t([r()],u.prototype,"_stagedDeletes",void 0),t([r()],u.prototype,"_stagedUpdates",void 0),t([r()],u.prototype,"_featureIdentifier",null),u=t([l("esri.widgets.BatchAttributeForm.inputs.AttachmentElementInput")],u);const g=u;export{g as default};
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Collection.js";import a from"../../../core/Logger.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import s from"../../../core/ReactiveMap.js";import i from"../../../core/ReactiveSet.js";import{generateBracedUUID as o}from"../../../core/uuid.js";import{property as r,subclass as l}from"../../../core/accessorSupport/decorators.js";import{getEffectiveLayerCapabilities as d}from"../../../layers/support/layerUtils.js";import m from"../../../rest/query/support/AttachmentInfo.js";import{isAttributeFormSupportedLayer as c}from"../batchAttributeFormUtils.js";import h from"./EditableInput.js";import p from"./SingleFeatureInputAdapter.js";let u=-1,g=class extends h{constructor(t){super(t),this.attachments=[],this.group=null,this.single=new p({input:this}),this.type="attachment",this._initialAttachments=[],this._stagedAdds=new e,this._stagedDeletes=new i,this._stagedUpdates=new s}get allowUserRename(){return this.template.allowUserRename}get attachmentKeyword(){return this.template.attachmentKeyword?.trim()}get displayFilename(){return this.template.displayFilename}get feature(){return this.single.feature}get hasAttachmentChanges(){return this._stagedAdds.length>0||this._stagedUpdates.size>0||this._stagedDeletes.size>0}get input(){return this.template.input}get layer(){return this.single.layer}get maxAttachmentCount(){return this.template.maxAttachmentCount}get minAttachmentCount(){return this.template.minAttachmentCount}get supportsResize(){const{layer:t}=this;if(!t)return!1;const e=d(t);return!!e&&("attachment"in e&&!!e.attachment?.supportsResize)}get useOriginalFilename(){return this.template.useOriginalFilename}get valid(){const t=this.attachments.length,e=this.minAttachmentCount??-1/0,a=this.maxAttachmentCount??1/0,n=this.hasAttachmentChanges;return!(t<e||t>a)||!n}get _expressionLayer(){const t=this.layer;if(t)return"scene"===t.type&&"associatedLayer"in t&&null!=t.associatedLayer?t.associatedLayer:"feature"===t.type?t:void 0}applyFetchedAttachments(t){for(const e of t)this._normalizeAttachmentName(e);this._initialAttachments=t,this._recomputeAttachments()}clearAttachmentChanges(){this._stagedAdds.removeAll(),this._stagedUpdates.clear(),this._stagedDeletes.clear(),this._recomputeAttachments()}stageAddAttachment(t){const{contentType:e,data:a,name:n}=t,s=t.globalId??o(),i=a instanceof Blob?a.size:void 0,r=n.trim(),l=new m({contentType:e??void 0,globalId:s,id:u--,keywords:this.attachmentKeyword??void 0,name:r,size:i});return this._stagedAdds.add({globalId:s,info:l,data:a}),this._recomputeAttachments(),l}async stageAddAttachments(t,e){if(0===t.length)return[];const a=[],n=new Map,s=Date.now();for(let i=0;i<t.length;i++){const o=t[i],r=o instanceof File?o.name:`attachment-${s}_${i+1}`,l=await this._computeAttachmentFilename(r,e),d=this._makeUniqueFilenameForOperation(n,l);a.push(this.stageAddAttachment({contentType:o.type,data:o,name:d}))}return a}findAttachment(t){if(t)return this.attachments.find(e=>e.globalId===t)}stageDeleteAttachment(t){const e=t.globalId;if(!e)return;const a=this._stagedAdds.findIndex(t=>t.globalId===e);if(a>-1)return this._stagedAdds.removeAt(a),void this._recomputeAttachments();this._stagedUpdates.delete(e),this._stagedDeletes.add(e),this._recomputeAttachments()}stageRenameAttachment(t,e){const a=t.globalId;if(!a)return;const n=e.trim(),s=this._stagedAdds.find(t=>t.globalId===a);if(s)return s.info.name=n,void this._recomputeAttachments();const i=this._stagedUpdates.get(a);this._stagedUpdates.set(a,{...i,info:t,name:n}),this._recomputeAttachments()}async stageReplaceAttachment(t,e,a){const n=e instanceof File?e.name:t.name,s=await this._computeAttachmentFilename(n,a);this._stageReplaceAttachment(t,e,s)}toSubmitEdits(){const t=[],e=[],n=Array.from(this._stagedDeletes);if(0===this._stagedAdds.length&&0===this._stagedUpdates.size&&0===n.length)return null;const s=this._featureIdentifier;if(!s)return a.getLogger(this).error("Unable to build attachment edits without a valid feature and layer."),null;for(const a of this._stagedAdds)t.push({feature:s,attachment:{globalId:a.globalId,contentType:a.info.contentType,data:a.data,name:a.info.name}});for(const[a,i]of this._stagedUpdates)e.push({feature:s,attachment:{globalId:a,contentType:i.contentType,data:i.data,name:i.name}});return{label:this.template.label,attachmentKeyword:this.attachmentKeyword,add:t,delete:n,update:e}}_recomputeAttachments(){const t=this._stagedDeletes,e=[];for(const a of this._stagedAdds)e.push(a.info);for(const a of this._initialAttachments){const n=a.globalId;if(!n||!t.has(n)){if(n&&this._stagedUpdates.has(n)){const t=this._stagedUpdates.get(n),s=a.clone();t.data instanceof Blob&&(s.size=t.data.size),null!=t.name&&(s.name=t.name),e.push(s);continue}e.push(a)}}this.attachments=e}get _featureIdentifier(){const t=this.single.feature,e=this.layer;if(!t||!c(e))return null;const a=e.objectIdField,n="globalIdField"in e?e.globalIdField:null,s=t.getGlobalId()??(n?t.getAttribute(n):void 0);if(s)return{globalId:s};const i=t.getObjectId()??t.getAttribute(a),o=Number(i);return null==i||isNaN(o)?null:{objectId:o}}async _computeAttachmentFilename(t,e){const s=this.template.filenameExpressionExecutor;if(!s)return t;const i=this.single.feature,o=i?.plainGraphic,r=this._expressionLayer,l={$originalfeature:i?.original,$editcontext:{editType:e.editType},$layer:r,$featureset:r,$datastore:r?.url,$feature:o,$map:e.map},d={rawOutput:!0,spatialReference:e.spatialReference,timeZone:e.timeZone};try{const t=s.isAsync?await s.executeAsync(l,d):s.execute(l,d);if("string"==typeof t&&t.trim().length>0)return t.trim()}catch(m){n(m)||a.getLogger(this).error("Failed evaluating attachment filename expression",m)}return t}_makeUniqueFilenameForOperation(t,e){const a=e.toLowerCase(),n=t.get(a)??0;if(t.set(a,n+1),0===n)return e;const s=e.lastIndexOf(".");return`${s>0?e.slice(0,s):e}_${n}${s>0?e.slice(s):""}`}_stageReplaceAttachment(t,e,a){const n=t.globalId;if(!n)return;const s=a.trim(),i=this._stagedAdds.find(t=>t.globalId===n);if(i)return i.data=e,i.info.name=s,i.info.contentType=e.type,i.info.size=e.size,void this._recomputeAttachments();const o=this._stagedUpdates.get(n);this._stagedUpdates.set(n,{...o,info:t,contentType:e.type||o?.contentType,data:e,name:s}),this._recomputeAttachments()}_normalizeAttachmentName(t){const{name:e}=t;"string"==typeof e&&(t.name=e.trim())}};t([r()],g.prototype,"allowUserRename",null),t([r()],g.prototype,"attachmentKeyword",null),t([r()],g.prototype,"attachments",void 0),t([r()],g.prototype,"displayFilename",null),t([r()],g.prototype,"feature",null),t([r()],g.prototype,"group",void 0),t([r({readOnly:!0})],g.prototype,"hasAttachmentChanges",null),t([r()],g.prototype,"input",null),t([r()],g.prototype,"layer",null),t([r()],g.prototype,"maxAttachmentCount",null),t([r()],g.prototype,"minAttachmentCount",null),t([r({readOnly:!0})],g.prototype,"single",void 0),t([r({readOnly:!0})],g.prototype,"type",void 0),t([r({readOnly:!0})],g.prototype,"supportsResize",null),t([r()],g.prototype,"useOriginalFilename",null),t([r({readOnly:!0})],g.prototype,"valid",null),t([r()],g.prototype,"_initialAttachments",void 0),t([r()],g.prototype,"_expressionLayer",null),t([r()],g.prototype,"_stagedAdds",void 0),t([r()],g.prototype,"_stagedDeletes",void 0),t([r()],g.prototype,"_stagedUpdates",void 0),t([r()],g.prototype,"_featureIdentifier",null),g=t([l("esri.widgets.BatchAttributeForm.inputs.AttachmentElementInput")],g);const f=g;export{f as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{property as e,subclass as o}from"../../../core/accessorSupport/decorators.js";import{ElementTemplateBase as r}from"./ElementTemplateBase.js";let p=class extends r{constructor(t){super(t),this.group=null,this.type="relationship"}};t([e({clonable:!1})],p.prototype,"group",void 0),t([e({readOnly:!0})],p.prototype,"type",void 0),p=t([o("esri.widgets.BatchAttributeForm.templates.RelationshipElementTemplate")],p);export{p as RelationshipElementTemplate};
2
+ import{__decorate as t}from"tslib";import{property as o,subclass as e}from"../../../core/accessorSupport/decorators.js";import{ElementTemplateBase as p}from"./ElementTemplateBase.js";let i=class extends p{constructor(t){super(t),this.displayCount=3,this.displayType="list",this.group=null,this.orderByFields=null,this.relationshipId=null,this.type="relationship"}};t([o()],i.prototype,"displayCount",void 0),t([o()],i.prototype,"displayType",void 0),t([o({clonable:!1})],i.prototype,"group",void 0),t([o()],i.prototype,"orderByFields",void 0),t([o()],i.prototype,"relationshipId",void 0),t([o({readOnly:!0})],i.prototype,"type",void 0),i=t([e("esri.widgets.BatchAttributeForm.templates.RelationshipElementTemplate")],i);export{i as RelationshipElementTemplate};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{createArcadeProfile as e,createArcadeExecutor as t}from"../../../../arcade.js";import r from"../../../../core/Error.js";import n from"../../../../core/Logger.js";import{getEffectiveFieldAlias as o}from"../../../../editing/fieldUtils.js";import i from"../../../../form/ExpressionInfo.js";import{isAttachmentElement as s,isFieldElement as a,isGroupElement as l,isRelationshipElement as m,isTextElement as d,isUtilityNetworkAssociationsElement as p}from"../../../../form/support/formUtils.js";import{getLowerCaseEditTrackingFields as c,isFieldVisibleByDefault as f}from"../../../../layers/support/fieldUtils.js";import{isSubtypeSublayer as u,isSubtypeGroupLayer as x}from"../../../../layers/support/layerUtils.js";import{unknown as y}from"../../../../time/constants.js";import{makeExpressionInfosMap as w,makeExecutorSetForFormElement as E}from"../../expressions/expressionUtils.js";import{AttachmentElementTemplate as b}from"../AttachmentElementTemplate.js";import h from"../BatchFormTemplate.js";import{FieldElementTemplate as T}from"../FieldElementTemplate.js";import{GroupElementTemplate as v}from"../GroupElementTemplate.js";import{RelationshipElementTemplate as I}from"../RelationshipElementTemplate.js";import{TextElementTemplate as g}from"../TextElementTemplate.js";import{UtilityNetworkAssociationsElementTemplate as j}from"../UtilityNetworkAssociationsElementTemplate.js";import{compileTextElementMarkdownToHTML as F}from"./textElementTemplateUtils.js";const P="expression/dea57012-47ca4b55a000-8df62742ed0c",L=e("form-attachment-filename-calculation"),A=()=>n.getLogger("esri.widgets.BatchAttributeForm.templates.templateUtils");async function U(e,t,r=e.formTemplate){return r?.elements&&r.elements.length>0?k(r,e,t):Z(e,t)}async function Z(e,{arcadeExecutorProvider:t,formTimeZone:r}){const n=new Set(c(e)),o={arcadeExecutorProvider:t,formTimeZone:r,layer:e},i=[];for(const a of e.fields)K(a,e,n)&&i.push(B(a,o));const s=await Promise.all(i);return new h({elements:s,preserveFieldValuesWhenHidden:!0})}function C(e,t){for(const r of e??[])if("group"!==r.type){if("field"===r.type){if(!1===r.editable&&!r.editableExpression)return!0;if(t.subtypeField&&(u(t)||x(t))&&r.fieldName?.toLowerCase()===t.subtypeField.toLowerCase())return!0}}else if(C(r.elements??[],t))return!0;return!1}async function k(e,t,r){let n=null;C(e.elements??[],t)&&(n=new i({title:"",name:P,expression:"false"}));const o=w(n?[...e.expressionInfos??[],n]:e.expressionInfos),s={description:e.description,elements:new Array,title:e.title,preserveFieldValuesWhenHidden:e.preserveFieldValuesWhenHidden,supportsAttachmentElements:e.supportsAttachmentElements},{elements:a}=e;if(!a)return new h(s);const{arcadeExecutorProvider:l,formTimeZone:m}=r;for(const i of a){const e=await N(i,{arcadeExecutorProvider:l,expressionInfos:o,layer:t,formTimeZone:m});e&&s.elements.push(e)}return e.supportsAttachmentElements,new h(s)}async function H(e,{arcadeExecutorProvider:r,expressionInfos:n,layer:o}){const i=n.get(e.filenameExpression),s=i?await t(i.expression,L):null,a=new b({allowUserRename:e.allowUserRename,attachmentKeyword:e.attachmentKeyword,description:e.description,displayFilename:e.displayFilename,filenameExpressionExecutor:s,input:e.input,label:e.label,maxAttachmentCount:e.maxAttachmentCount,minAttachmentCount:e.minAttachmentCount,useOriginalFilename:e.useOriginalFilename}),l=await E({element:e,expressionInfos:n,provider:r});return a.addLayer(o,l),a}async function N(e,t){return s(e)?H(e,{arcadeExecutorProvider:t.arcadeExecutorProvider,expressionInfos:t.expressionInfos,layer:t.layer}):a(e)?R(e,t):l(e)?S(e,t):m(e)?V(e,t):d(e)?W(e,t):p(e)?z(e,t):null}async function R(e,{arcadeExecutorProvider:t,expressionInfos:n,layer:o,formTimeZone:i}){const{fieldsIndex:s}=o,{description:a,domain:l,fieldName:m,hint:d,input:p,label:c}=e;if(null==m||!s.has(m))return A().warn(new r("batch-attribute-form:invalid-form-element-field",`Field element with label '${c}' does not refer to a valid field`)),null;!1!==e.editable||e.editableExpression||((e=e.clone()).editableExpression=P),o.subtypeField&&(u(o)||x(o))&&e.fieldName?.toLowerCase()===o.subtypeField.toLowerCase()&&((e=e.clone()).editableExpression=P);const f=new T({description:a,domain:l,field:s.get(m),hint:d,input:p,formTimeZone:i,layerTimeZone:O(o),label:c}),y=await E({element:e,expressionInfos:n,provider:t});return f.addLayer(o,y),f}async function S(e,t){const{arcadeExecutorProvider:r,expressionInfos:n,layer:o}=t,{description:i,label:s,initialState:a}=e,l=[];for(const p of e.elements){const e=await N(p,t);e&&l.push(e)}const m=new v({description:i,elements:l,label:s,initialState:a??"expanded"}),d=await E({element:e,expressionInfos:n,provider:r});return m.addLayer(o,d),m}async function V(e,t){const{description:r,label:n}=e,{arcadeExecutorProvider:o,expressionInfos:i,layer:s}=t,a=new I({description:r,label:n}),l=await E({element:e,expressionInfos:i,provider:o});return a.addLayer(s,l),a}async function W(e,{arcadeExecutorProvider:t,expressionInfos:r,layer:n}){const{description:o,label:i,text:s,textFormat:a}=e,{fieldsIndex:l}=n,m=s&&"markdown"===a?await F(s):s,d=new g({compiledText:m,description:o,fieldsIndex:l,label:i}),p=await E({element:e,expressionInfos:r,provider:t}),{expressionParts:c}=d;if(c.length){const e=await Promise.all(c.map(e=>{const n=r.get(e)?.expression??e;return t.getArcadeExecutor(n)}));p.textExpressions=e}return d.addLayer(n,p),d}async function z(e,t){const{associationTypes:r,description:n,label:o}=e,{arcadeExecutorProvider:i,expressionInfos:s,layer:a}=t,l=new j({associationTypes:r,description:n,label:o}),m=await E({element:e,expressionInfos:s,provider:i});return l.addLayer(a,m),l}async function B(e,{arcadeExecutorProvider:t,layer:r,formTimeZone:n}){const i=o(e,r)||e.name,s=new T({field:e,label:i,formTimeZone:n,layerTimeZone:O(r)}),a={},l=(x(r)||u(r))&&r.subtypeField&&r.subtypeField.toLowerCase()===e.name.toLowerCase();return!l&&e.editable&&r.userHasUpdateItemPrivileges&&(a.editableExpression=await t.getArcadeExecutor("true")),l&&(a.editableExpression=await t.getArcadeExecutor("false")),s.addLayer(r,a),s}function K(e,t,r){return!r.has(e.name.toLowerCase())&&f(e,t)}function O(e){return u(e)&&e.parent&&(e=e.parent),e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone?y:e&&"preferredTimeZone"in e&&e.preferredTimeZone?e.preferredTimeZone:null}export{U as createBatchFormTemplate,Z as createBatchFormTemplateFromFields};
2
+ import{createArcadeProfile as e,createArcadeExecutor as t}from"../../../../arcade.js";import r from"../../../../core/Error.js";import n from"../../../../core/Logger.js";import{getEffectiveFieldAlias as o}from"../../../../editing/fieldUtils.js";import i from"../../../../form/ExpressionInfo.js";import{isAttachmentElement as s,isFieldElement as a,isGroupElement as l,isRelationshipElement as m,isTextElement as d,isUtilityNetworkAssociationsElement as p}from"../../../../form/support/formUtils.js";import{getLowerCaseEditTrackingFields as c,isFieldVisibleByDefault as f}from"../../../../layers/support/fieldUtils.js";import{isSubtypeSublayer as u,isSubtypeGroupLayer as x}from"../../../../layers/support/layerUtils.js";import{isNumber as y}from"../../../../support/guards.js";import{unknown as w}from"../../../../time/constants.js";import{makeExpressionInfosMap as E,makeExecutorSetForFormElement as b}from"../../expressions/expressionUtils.js";import{AttachmentElementTemplate as h}from"../AttachmentElementTemplate.js";import T from"../BatchFormTemplate.js";import{FieldElementTemplate as I}from"../FieldElementTemplate.js";import{GroupElementTemplate as v}from"../GroupElementTemplate.js";import{RelationshipElementTemplate as g}from"../RelationshipElementTemplate.js";import{TextElementTemplate as F}from"../TextElementTemplate.js";import{UtilityNetworkAssociationsElementTemplate as j}from"../UtilityNetworkAssociationsElementTemplate.js";import{compileTextElementMarkdownToHTML as P}from"./textElementTemplateUtils.js";const L="expression/dea57012-47ca4b55a000-8df62742ed0c",A=e("form-attachment-filename-calculation"),C=()=>n.getLogger("esri.widgets.BatchAttributeForm.templates.templateUtils");async function U(e,t,r=e.formTemplate){return r?.elements&&r.elements.length>0?B(r,e,t):Z(e,t)}async function Z(e,{arcadeExecutorProvider:t,formTimeZone:r}){const n=new Set(c(e)),o={arcadeExecutorProvider:t,formTimeZone:r,layer:e},i=[];for(const a of e.fields)O(a,e,n)&&i.push(K(a,o));const s=await Promise.all(i);return new T({elements:s,preserveFieldValuesWhenHidden:!0})}function k(e,t){for(const r of e??[])if("group"!==r.type){if("field"===r.type){if(!1===r.editable&&!r.editableExpression)return!0;if(t.subtypeField&&(u(t)||x(t))&&r.fieldName?.toLowerCase()===t.subtypeField.toLowerCase())return!0}}else if(k(r.elements??[],t))return!0;return!1}async function B(e,t,r){let n=null;k(e.elements??[],t)&&(n=new i({title:"",name:L,expression:"false"}));const o=E(n?[...e.expressionInfos??[],n]:e.expressionInfos),s={description:e.description,elements:new Array,title:e.title,preserveFieldValuesWhenHidden:e.preserveFieldValuesWhenHidden,supportsAttachmentElements:e.supportsAttachmentElements},{elements:a}=e;if(!a)return new T(s);const{arcadeExecutorProvider:l,formTimeZone:m}=r;for(const i of a){const e=await N(i,{arcadeExecutorProvider:l,expressionInfos:o,layer:t,formTimeZone:m});e&&s.elements.push(e)}return e.supportsAttachmentElements,new T(s)}async function H(e,{arcadeExecutorProvider:r,expressionInfos:n,layer:o}){const i=n.get(e.filenameExpression),s=i?await t(i.expression,A):null,a=new h({allowUserRename:e.allowUserRename,attachmentKeyword:e.attachmentKeyword,description:e.description,displayFilename:e.displayFilename,filenameExpressionExecutor:s,input:e.input,label:e.label,maxAttachmentCount:e.maxAttachmentCount,minAttachmentCount:e.minAttachmentCount,useOriginalFilename:e.useOriginalFilename}),l=await b({element:e,expressionInfos:n,provider:r});return a.addLayer(o,l),a}async function N(e,t){return s(e)?H(e,{arcadeExecutorProvider:t.arcadeExecutorProvider,expressionInfos:t.expressionInfos,layer:t.layer}):a(e)?R(e,t):l(e)?S(e,t):m(e)?V(e,t):d(e)?W(e,t):p(e)?z(e,t):null}async function R(e,{arcadeExecutorProvider:t,expressionInfos:n,layer:o,formTimeZone:i}){const{fieldsIndex:s}=o,{description:a,domain:l,fieldName:m,hint:d,input:p,label:c}=e;if(null==m||!s.has(m))return C().warn(new r("batch-attribute-form:invalid-form-element-field",`Field element with label '${c}' does not refer to a valid field`)),null;!1!==e.editable||e.editableExpression||((e=e.clone()).editableExpression=L),o.subtypeField&&(u(o)||x(o))&&e.fieldName?.toLowerCase()===o.subtypeField.toLowerCase()&&((e=e.clone()).editableExpression=L);const f=new I({description:a,domain:l,field:s.get(m),hint:d,input:p,formTimeZone:i,layerTimeZone:G(o),label:c}),y=await b({element:e,expressionInfos:n,provider:t});return f.addLayer(o,y),f}async function S(e,t){const{arcadeExecutorProvider:r,expressionInfos:n,layer:o}=t,{description:i,label:s,initialState:a}=e,l=[];for(const p of e.elements){const e=await N(p,t);e&&l.push(e)}const m=new v({description:i,elements:l,label:s,initialState:a??"expanded"}),d=await b({element:e,expressionInfos:n,provider:r});return m.addLayer(o,d),m}async function V(e,t){const{description:r,label:n,displayCount:o,displayType:i,orderByFields:s,relationshipId:a}=e,{arcadeExecutorProvider:l,expressionInfos:m,layer:d}=t,p=new g({description:r,...y(o)&&{displayCount:o},displayType:i,label:n,orderByFields:s,relationshipId:a}),c=await b({element:e,expressionInfos:m,provider:l});return p.addLayer(d,c),p}async function W(e,{arcadeExecutorProvider:t,expressionInfos:r,layer:n}){const{description:o,label:i,text:s,textFormat:a}=e,{fieldsIndex:l}=n,m=s&&"markdown"===a?await P(s):s,d=new F({compiledText:m,description:o,fieldsIndex:l,label:i}),p=await b({element:e,expressionInfos:r,provider:t}),{expressionParts:c}=d;if(c.length){const e=await Promise.all(c.map(e=>{const n=r.get(e)?.expression??e;return t.getArcadeExecutor(n)}));p.textExpressions=e}return d.addLayer(n,p),d}async function z(e,t){const{associationTypes:r,description:n,label:o}=e,{arcadeExecutorProvider:i,expressionInfos:s,layer:a}=t,l=new j({associationTypes:r,description:n,label:o}),m=await b({element:e,expressionInfos:s,provider:i});return l.addLayer(a,m),l}async function K(e,{arcadeExecutorProvider:t,layer:r,formTimeZone:n}){const i=o(e,r)||e.name,s=new I({field:e,label:i,formTimeZone:n,layerTimeZone:G(r)}),a={},l=(x(r)||u(r))&&r.subtypeField&&r.subtypeField.toLowerCase()===e.name.toLowerCase();return!l&&e.editable&&r.userHasUpdateItemPrivileges&&(a.editableExpression=await t.getArcadeExecutor("true")),l&&(a.editableExpression=await t.getArcadeExecutor("false")),s.addLayer(r,a),s}function O(e,t,r){return!r.has(e.name.toLowerCase())&&f(e,t)}function G(e){return u(e)&&e.parent&&(e=e.parent),e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone?w:e&&"preferredTimeZone"in e&&e.preferredTimeZone?e.preferredTimeZone:null}export{U as createBatchFormTemplate,Z as createBatchFormTemplateFromFields};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{numericHash as t}from"../../../../core/string.js";import{isBarcodeScannerInput as n,isComboBoxInput as e,isRadioButtonsInput as i,isDatePickerInput as o,isDateTimePickerInput as r,isDateTimeOffsetPickerInput as $,isSwitchInput as u,isTextAreaInput as c,isTextBoxInput as l,isTimePickerInput as a,isMultipleChoiceInput as s}from"../../../../form/elements/inputs/inputUtils.js";import{isFieldElementTemplate as m,isGroupElementTemplate as f,isRelationshipElementTemplate as p,isTextElementTemplate as g,isAttachmentElementTemplate as S,isUtilityNetworkAssociationsElementTemplate as d,isExcludedFromSharedForm as h}from"./templateUtils.js";const y="",O="num:";function x(n){return m(n)?t(N(n)).toString():f(n)?t(b(n)).toString():p(n)?t(C(n)).toString():g(n)?t(V(n)).toString():S(n)?t(J(n)).toString():d(n)?t(T(n)).toString():t(JSON.stringify(n)).toString()}function N(t){return`${j(t)}.${U(t.field)}.${F(t.domain)}.${t.hint??y}.${v(t.input)}`}function b(t){const n=j(t)+`.${t.initialState}`;let e=y;for(const i of t.elements)h(i)||(e+="."+x(i).toString());return`${n}${e}`}function C(t){return`${j(t)}`}function V(t){const n=j(t),{compiledText:e}=t;return`${n}.${e??y}`}function J(t){return`${j(t)}.${t.allowUserRename}.${t.attachmentKeyword??y}.${t.displayFilename}.${w(t.input)}.${t.maxAttachmentCount??y}.${t.minAttachmentCount??y}.${t.useOriginalFilename}`}function T(t){return`${j(t)}.${A(t.associationTypes)}`}function j(t){return`${t.label??y}.${t.description??y}.${t.layerTimeZone??y}`}function v(t){if(!t)return y;const{type:m}=t;if(n(t))return m??y;if(e(t)||i(t)){const{showNoValueOption:n}=t;return`${m}.${n}.${t.noValueOptionLabel??y}`}if(o(t))return`${m}.${L(t)}`;if(r(t)){const n=t.min?.getTime(),e=t.max?.getTime(),{includeTime:i}=t;return`${m}.${n}.${e}.${i}`}if($(t)){const n=L(t),{includeTimeOffset:e,timeResolution:i}=t;return`${m}.${n}.${e}.${i}`}if(u(t)){const{offValue:n,onValue:e}=t;return`${m}.${K(n)}.${K(e)}`}if(c(t)||l(t)){return`${m}.${t.minLength?.toString()??y}.${t.maxLength?.toString()??y}`}if(a(t)){const n=L(t),{timeResolution:e}=t;return`${m}.${n}.${e}`}if(s(t)){return`${m}.${L({min:t.minSelectedChoices?.toString(),max:t.maxSelectedChoices?.toString()})}.${t.choiceDelimiter??y}.${t.includeSelectAllChoices}.${t.otherChoice?.fieldName??y}.${t.otherChoice?.label??y}.${t.otherChoice?.hint??y}.${R(t)}`}return JSON.stringify(t)}function w(t){return t?JSON.stringify(t.toJSON()):y}function A(t){return t.map(t=>JSON.stringify(t.toJSON())).sort().join(".")}function L(t){return`${t.min??y}.${t.max??y}`}function R(t){return(t.choices??[]).map(({label:t,value:n})=>`${t}.${n}`).sort().join(".")}function U(t){const n=t.name,e=t.alias??y;return`${n}.${e===n?y:e}.${t.nullable}.${t.type}.${t.length??y}.${t.defaultValue??y}.${t.description??y}.${t.editable}.${t.visible}`}function F(t){return t?"coded-value"===t.type?D(t):"range"===t.type?Z(t):JSON.stringify(t):y}function D(t){const{type:n}=t;return`${n}.${t.codedValues.map(({code:t,name:n})=>`${K(t)}.${n}`).sort().join(".")}`}function K(t){return"number"==typeof t?`${O}${t}`:t}function Z(t){const{maxValue:n,minValue:e,type:i}=t;return`${i}.${e}.${n}`}export{x as hashElementTemplate};
2
+ import{numericHash as t}from"../../../../core/string.js";import{isBarcodeScannerInput as n,isComboBoxInput as e,isRadioButtonsInput as i,isDatePickerInput as o,isDateTimePickerInput as r,isDateTimeOffsetPickerInput as $,isSwitchInput as u,isTextAreaInput as c,isTextBoxInput as l,isTimePickerInput as s,isMultipleChoiceInput as a}from"../../../../form/elements/inputs/inputUtils.js";import{isFieldElementTemplate as m,isGroupElementTemplate as f,isRelationshipElementTemplate as p,isTextElementTemplate as d,isAttachmentElementTemplate as g,isUtilityNetworkAssociationsElementTemplate as h,isExcludedFromSharedForm as S}from"./templateUtils.js";const y="",O="num:";function x(n){return m(n)?t(C(n)).toString():f(n)?t(N(n)).toString():p(n)?t(b(n)).toString():d(n)?t(T(n)).toString():g(n)?t(V(n)).toString():h(n)?t(j(n)).toString():t(JSON.stringify(n)).toString()}function C(t){return`${J(t)}.${U(t.field)}.${B(t.domain)}.${t.hint??y}.${v(t.input)}`}function N(t){const n=J(t)+`.${t.initialState}`;let e=y;for(const i of t.elements)S(i)||(e+="."+x(i).toString());return`${n}${e}`}function b(t){const{displayCount:n,displayType:e,relationshipId:i}=t;return`${J(t)}.${n}.${e}.${i}.${L(t.orderByFields??[])}`}function T(t){const n=J(t),{compiledText:e}=t;return`${n}.${e??y}`}function V(t){return`${J(t)}.${t.allowUserRename}.${t.attachmentKeyword??y}.${t.displayFilename}.${w(t.input)}.${t.maxAttachmentCount??y}.${t.minAttachmentCount??y}.${t.useOriginalFilename}`}function j(t){return`${J(t)}.${A(t.associationTypes)}`}function J(t){return`${t.label??y}.${t.description??y}.${t.layerTimeZone??y}`}function v(t){if(!t)return y;const{type:m}=t;if(n(t))return m??y;if(e(t)||i(t)){const{showNoValueOption:n}=t;return`${m}.${n}.${t.noValueOptionLabel??y}`}if(o(t))return`${m}.${F(t)}`;if(r(t)){const n=t.min?.getTime(),e=t.max?.getTime(),{includeTime:i}=t;return`${m}.${n}.${e}.${i}`}if($(t)){const n=F(t),{includeTimeOffset:e,timeResolution:i}=t;return`${m}.${n}.${e}.${i}`}if(u(t)){const{offValue:n,onValue:e}=t;return`${m}.${I(n)}.${I(e)}`}if(c(t)||l(t)){return`${m}.${t.minLength?.toString()??y}.${t.maxLength?.toString()??y}`}if(s(t)){const n=F(t),{timeResolution:e}=t;return`${m}.${n}.${e}`}if(a(t)){return`${m}.${F({min:t.minimumChoices?.toString(),max:t.maximumChoices?.toString()})}.${t.choiceDelimiter??y}.${t.includeSelectAllChoices}.${t.otherChoice?.fieldName??y}.${t.otherChoice?.label??y}.${t.otherChoice?.hint??y}.${R(t)}`}return JSON.stringify(t)}function w(t){return t?JSON.stringify(t.toJSON()):y}function A(t){return t.map(t=>JSON.stringify(t.toJSON())).sort().join(".")}function F(t){return`${t.min??y}.${t.max??y}`}function L(t){return t.map(({field:t,order:n})=>`${t}.${n}`).sort().join(".")}function R(t){return(t.choices??[]).map(({label:t,value:n})=>`${t}.${n}`).sort().join(".")}function U(t){const n=t.name,e=t.alias??y;return`${n}.${e===n?y:e}.${t.nullable}.${t.type}.${t.length??y}.${t.defaultValue??y}.${t.description??y}.${t.editable}.${t.visible}`}function B(t){return t?"coded-value"===t.type?D(t):"range"===t.type?K(t):JSON.stringify(t):y}function D(t){const{type:n}=t;return`${n}.${t.codedValues.map(({code:t,name:n})=>`${I(t)}.${n}`).sort().join(".")}`}function I(t){return"number"==typeof t?`${O}${t}`:t}function K(t){const{maxValue:n,minValue:e,type:i}=t;return`${i}.${e}.${n}`}export{x as hashElementTemplate};
@@ -156,6 +156,13 @@ export interface AttachmentsChangeEvent {
156
156
  valid: boolean;
157
157
  }
158
158
 
159
+ /**
160
+ * Selected attachment reference information.
161
+ *
162
+ * @since 5.1
163
+ */
164
+ export interface SelectedAttachmentInfo {}
165
+
159
166
  /** @since 5.0 */
160
167
  export interface ValueChangeEvent {
161
168
  /**