@arcgis/core 5.2.0-next.89 → 5.2.0-next.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/05fbd1f373cfa3724f0c.js +1 -0
  3. package/assets/esri/core/workers/chunks/{f7f2102b16d201e5f531.js → 0d2e2d90a4e4a28e2c0c.js} +1 -1
  4. package/assets/esri/core/workers/chunks/1554feab934e8e1bcd28.js +1 -0
  5. package/assets/esri/core/workers/chunks/{823dd85b008ae4db6793.js → 188c6ff5f4664827c254.js} +2 -2
  6. package/assets/esri/core/workers/chunks/{d30a7fc8dab4ebb8893b.js → 1ab8307ba9981124f669.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{5ed89c862eee1345e3af.js → 20f7b5fe64a217cb3d3d.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{013a4ee14c44eb824c7c.js → 24c44541046576fee7e0.js} +2 -2
  9. package/assets/esri/core/workers/chunks/{f3716ce04d09af31cfb1.js → 2754ba5cc094028a7a3c.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{e8b4f12dfbf568377cef.js → 3a65693964e3976d8035.js} +1 -1
  11. package/assets/esri/core/workers/chunks/423c2692df662b3dddd4.js +1 -0
  12. package/assets/esri/core/workers/chunks/{996211727ed1617162da.js → 48726010778d6004e347.js} +2 -2
  13. package/assets/esri/core/workers/chunks/{680557b8832fbdab7f46.js → 4bf7c0c874d30b1c0760.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{db180f8d25471cfa48af.js → 545bec045167c433af8f.js} +1 -1
  15. package/assets/esri/core/workers/chunks/5782c0362a1799ceef41.js +1 -0
  16. package/assets/esri/core/workers/chunks/{5bf65dbfd9c7a5ea187d.js → 5aa23b0f4521ba9a07ad.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{eda04911553cf99fb99b.js → 606ac9358f508bda94f2.js} +1 -1
  18. package/assets/esri/core/workers/chunks/625a692f00357629f609.js +1 -0
  19. package/assets/esri/core/workers/chunks/{bd2602195e265f8fdb15.js → 69c9a12c97ead8963817.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{2f3bbc1f7d4abbbeec2f.js → 6ab7bb3834841834f839.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{afa6b74d9ca9ed0154af.js → 6fd0d9431b141f2a3252.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{3f82410d9f701e7ad8eb.js → 76e7d3cde2da4bdd7820.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{ea75c23c44452f45a949.js → 7cf903db44f3647c8fd4.js} +1 -1
  24. package/assets/esri/core/workers/chunks/848a9f0e5373bbf289a5.js +1 -0
  25. package/assets/esri/core/workers/chunks/{a88bf8ae93077e1b48cf.js → 8a87e1a89a0d8c6203a7.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{a3b403f8acb90af19adb.js → 91ac9328afff8a51bd96.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{00181785a180e934bf7c.js → 91de343844ac578e7c93.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{d871572997600930e017.js → 95a3f09751bff63f4fab.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{ffe749d790320dddfa74.js → 97e41500fc2d24a88938.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{6fe7060235f601b180ea.js → 98d614d6fc9de8ebaf94.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{1e087fb13b7b0a5d6fec.js → 9d3cdfa08ef4d2805625.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{0460ea5a85e9c3c2e1b7.js → a89dbef8155d7c4354da.js} +2 -2
  33. package/assets/esri/core/workers/chunks/{e9f29019aa78f07ace66.js → aed7b80145b22c246098.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{4aefe6fd4d725a107758.js → b7ed5f130661e9ca00b9.js} +1 -1
  35. package/assets/esri/core/workers/chunks/c07d2fb9940b2c6eda9f.js +1 -0
  36. package/assets/esri/core/workers/chunks/{a8b878c12cb1a6ea012b.js → c4a0d3149947a1d2c484.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{31a0620a6028e94c7532.js → c6ec0e966106f66360d9.js} +2 -2
  38. package/assets/esri/core/workers/chunks/{5df0639839a354cb2751.js → c7f69d010f1cb32f5d37.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{23addf8b11938e0c96e9.js → cb983f65995e57fff7a1.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{f665fb4c5633e0a459d8.js → d24125a791247019e2ca.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{7b7d0e93689aab8da83d.js → d44338bf5edafa3ca926.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{2ceb07b125c84b51f02a.js → d7d5275d8b3c9430de1f.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{ce227146fcaabf088da1.js → da8a314800944706511b.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{705f459aab890fda134b.js → e018cbd97e6e0e4ca5c4.js} +1 -1
  45. package/assets/esri/core/workers/chunks/e55507e4114b34d1ef4e.js +1 -0
  46. package/assets/esri/core/workers/chunks/{6b06858bb9e976c1ef33.js → e594b6db9caee1f7b9fc.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{4057d97a4ec234978697.js → e90076ac1cf88a83a7f9.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{e40e08029325f43452d0.js → f4d351b4cd9d1aa10632.js} +1 -1
  49. package/assets/esri/core/workers/chunks/f5f5b54cab722abe88e0.js +1 -0
  50. package/assets/esri/core/workers/chunks/{d8e2d78fc4526612aad6.js → ff83d0337ac489ab08de.js} +2 -2
  51. package/config.js +1 -1
  52. package/core/EuclideanDistanceTransform.js +2 -0
  53. package/geometry/support/convexPolyhedron.js +1 -1
  54. package/geometry/support/frustumPlanes.js +2 -0
  55. package/kernel.js +1 -1
  56. package/layers/ParquetLayer.d.ts +3 -2
  57. package/layers/ParquetLayer.js +1 -1
  58. package/layers/support/dataSeriesUtils.js +1 -1
  59. package/package.json +3 -3
  60. package/popup/FeatureContentCollection.d.ts +6 -0
  61. package/popup/FeatureContentCollection.js +1 -1
  62. package/rest/support/AlgorithmicColorRamp.d.ts +2 -2
  63. package/rest/support/types.d.ts +2 -2
  64. package/smartMapping/raster/support/colorRamps.d.ts +4 -3
  65. package/support/revision.js +1 -1
  66. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  67. package/symbols/cim/CIMSymbolHelper.js +1 -1
  68. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  69. package/symbols/cim/Rasterizer.js +1 -1
  70. package/symbols/cim/cimAnalyzer.js +1 -1
  71. package/symbols/cim/rasterizingUtils.js +1 -1
  72. package/symbols/cim/utils.js +1 -1
  73. package/views/2d/engine/webgl/GlyphSDFCreator.js +1 -1
  74. package/views/2d/engine/webgl/SDFConverter.js +1 -1
  75. package/views/2d/engine/webgl/SpriteMosaic.js +1 -1
  76. package/views/2d/engine/webgl/TextureManager.js +1 -1
  77. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedTechnique.js +1 -1
  78. package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillTechnique.js +1 -1
  79. package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillTechnique.js +1 -1
  80. package/views/2d/engine/webgl/shaderGraph/techniques/fill/GradientFillTechnique.js +1 -1
  81. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternFillTechnique.js +1 -1
  82. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillTechnique.js +1 -1
  83. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
  84. package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeTechnique.js +1 -1
  85. package/views/2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js +1 -1
  86. package/views/2d/engine/webgl/shaderGraph/techniques/line/TexturedLineTechnique.js +1 -1
  87. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerTechnique.js +1 -1
  88. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterInputEvaluator.js +1 -1
  89. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextTechnique.js +1 -1
  90. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  91. package/views/2d/tiling/LODInfo.js +1 -1
  92. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  93. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  94. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  95. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  96. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  97. package/views/3d/state/Frustum.js +1 -1
  98. package/views/3d/state/controllers/RopePullController.js +1 -1
  99. package/views/3d/state/controllers/momentum/RopePullMomentumController.js +2 -0
  100. package/views/3d/support/SweptSphereVolume.js +2 -0
  101. package/views/3d/support/viewpointUtils.js +1 -1
  102. package/views/3d/terrain/PatchRenderData.js +1 -1
  103. package/views/3d/terrain/PatchRenderDataWaterproofness.js +1 -1
  104. package/views/3d/terrain/PlanarPatch.js +1 -1
  105. package/views/3d/terrain/SphericalPatch.js +1 -1
  106. package/views/3d/terrain/TerrainSurface.js +1 -1
  107. package/views/3d/terrain/Tile.js +1 -1
  108. package/views/3d/webgl/RenderCamera.js +1 -1
  109. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
  110. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentGeometryBVH.js +1 -1
  111. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  112. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  113. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  114. package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
  115. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  116. package/views/3d/webgl-engine/lib/screenPolygonIntersectionUtils.js +1 -1
  117. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  118. package/views/draw/support/managers/InteractiveHandleManager.js +1 -1
  119. package/views/navigation/RopePullMomentumEstimator.js +2 -0
  120. package/views/support/LayerLayerViewInfo.js +1 -1
  121. package/views/support/LayerViewManager.js +1 -1
  122. package/widgets/Features/FeaturesViewModel.d.ts +6 -0
  123. package/widgets/Features/FeaturesViewModel.js +1 -1
  124. package/widgets/Features.js +1 -1
  125. package/assets/esri/core/workers/chunks/028bee58f7bc19e5e39e.js +0 -1
  126. package/assets/esri/core/workers/chunks/39b6a5222f45cb8dbc94.js +0 -1
  127. package/assets/esri/core/workers/chunks/51c9bd7c03d780fadebc.js +0 -1
  128. package/assets/esri/core/workers/chunks/71308dca3fd05687e7bd.js +0 -1
  129. package/assets/esri/core/workers/chunks/8d8708789843844eb9e1.js +0 -1
  130. package/assets/esri/core/workers/chunks/9246e2468528650bdc7c.js +0 -1
  131. package/assets/esri/core/workers/chunks/94453d075ce02eff4844.js +0 -1
  132. package/assets/esri/core/workers/chunks/a176727a1148ca4fb432.js +0 -1
  133. package/assets/esri/core/workers/chunks/f106cc7f559856f69b9f.js +0 -1
  134. package/geometry/support/frustum.js +0 -2
  135. package/views/3d/layers/i3s/SweptSphereVolume.js +0 -2
  136. /package/assets/esri/core/workers/chunks/{823dd85b008ae4db6793.js.LICENSE.txt → 188c6ff5f4664827c254.js.LICENSE.txt} +0 -0
  137. /package/assets/esri/core/workers/chunks/{013a4ee14c44eb824c7c.js.LICENSE.txt → 24c44541046576fee7e0.js.LICENSE.txt} +0 -0
  138. /package/assets/esri/core/workers/chunks/{996211727ed1617162da.js.LICENSE.txt → 48726010778d6004e347.js.LICENSE.txt} +0 -0
  139. /package/assets/esri/core/workers/chunks/{0460ea5a85e9c3c2e1b7.js.LICENSE.txt → a89dbef8155d7c4354da.js.LICENSE.txt} +0 -0
  140. /package/assets/esri/core/workers/chunks/{d8e2d78fc4526612aad6.js.LICENSE.txt → ff83d0337ac489ab08de.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{add as t,transformMat4 as e,copy as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as r}from"../../../../geometry/support/frustum.js";import{create as n,fromPoints as o,copy as a}from"../../../../geometry/support/ray.js";import l from"../../webgl/RenderCamera.js";import{HUDTarget as c,HUDIntersectorResult as h}from"./HUDIntersectorResult.js";import{IntersectorOptions as f}from"./IntersectorInterfaces.js";import{IntersectorResultRay as m,compareOrderedIntersectionHits as u}from"./IntersectorResult.js";import{ObjectTarget as d}from"./ObjectTarget.js";import{PolygonIntersectionResults as y}from"./PolygonIntersectionResults.js";import{IntersectorTransform as g,getVerticalOffsetObject3D as p}from"./verticalOffsetUtils.js";const _=1e-5;class v{constructor(t){this.options=new f,this._results=new b,this.polygonResults=new y,this.transform=new g,this.camera=new l,this.screenPolygonPrimitiveProcessor=j,this.tolerance=_,this.verticalOffset=null,this._ray=n(),this._rayEnd=i(),this._rayBeginTransformed=i(),this._rayEndTransformed=i(),this.viewingMode=t??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(t,e,s){this.resetWithRay(o(t,e,this._ray),s)}resetWithRay(e,s){this.camera=s,e!==this._ray&&a(e,this._ray),0!==this.options.verticalOffset?2===this.viewingMode?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset:this.verticalOffset=null,t(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(t=null,e,s,i,r){this.point=e,this.filterPredicate=i,this.tolerance=s??_;const n=p(this.verticalOffset);if(t&&t.length>0){const e=r?t=>{r(t)&&this.intersectObject(t)}:t=>{this.intersectObject(t)};for(const s of t){const t=s.getSpatialQueryAccelerator?.();null!=t?(null!=n?t.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,e,n):t.forEachAlongRay(this._ray.origin,this._ray.direction,e),this.options.selectionMode&&this.options.hud&&t.forEachDegenerateObject(e)):s.objects.forEach(t=>e(t))}}this.sortResults()}*intersectScreenPolygon(t=null,e){if(this.verticalOffset=null,t?.length)for(const s of t){const t=s.getSpatialQueryAccelerator?.();if(null!=t)for(const s of t.intersectingFrustumValues(e.broadPhaseFrustum,t=>t.visible))yield*this._intersectScreenPolygonObject(s,e);else for(const i of s.objects.values())i.visible&&r(e.broadPhaseFrustum,i.boundingVolumeWorldSpace.bounds)&&(yield*this._intersectScreenPolygonObject(i,e))}}*intersectHUDScreenPolygon(t=null,e){if(this.verticalOffset=null,this.options.selectionMode&&this.options.hud&&t?.length)for(const s of t){const t=s.getSpatialQueryAccelerator?.(),i=t?.degenerateObjectValues()??s.objects.values();for(const s of i)yield*this._intersectScreenPolygonObject(s,e)}}*_intersectScreenPolygonObject(t,e){const s=t.geometries;if(!t.visible||!s)return;const i=t.effectiveTransformation;for(const r of s){if(!r.visible)continue;const{material:s,id:n}=r;if(!s.visible||!s.intersectScreenPolygon)continue;this.transform.setAndInvalidateLazyTransforms(i,r.transformation);const o=s.intersectScreenPolygon(r,this.transform.transform,this,e);o?.valid&&this._handleObjectScreenPolygonIntersection(o.type,new d(t,n,o.primitiveIndex),o.distance,o.point),yield}}intersectObject(t){const s=t.geometries;if(!s)return;const i=t.effectiveTransformation,r=p(this.verticalOffset);for(const n of s){if(!n.visible)continue;const{material:s,id:o}=n;if(!s.visible)continue;this.transform.setAndInvalidateLazyTransforms(i,n.transformation),e(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),e(this._rayEndTransformed,this.rayEnd,this.transform.inverse);const a=this.transform.transform;null!=r&&(r.objectTransform=this.transform),s.intersectRay(n,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(e,s,i,r,n)=>this.handleObjectIntersection({object:t,geometryId:o,primitiveIndex:r},e,s,i,a,n))}}handleObjectIntersection(t,e,s,i,r,n){if(e<0||null!=this.filterPredicate&&!this.filterPredicate(this._ray.origin,this._rayEnd,s))return;const o=n?this._results.hud:this._results;t=n?new c(t,n):t;const a=n?r=>r.set(1,t,e,s,i):n=>n.set(4,t,e,s,i,r);if((null==o.min.renderDistance||s<o.min.renderDistance)&&a(o.min),0!==this.options.store&&(null==o.max.renderDistance||s>o.max.renderDistance)&&a(o.max),2===this.options.store)if(n){const t=new h(this._ray);a(t),this._results.hud.all.push(t)}else{const t=new m(this._ray);a(t),this._results.all.push(t)}}_handleObjectScreenPolygonIntersection(t,e,s,i){s<0||(null==this.filterPredicate||null!=i&&this.filterPredicate(this.camera.eye,i,1))&&this.polygonResults.add(t,1===t&&i?new c(e,i):e,s)}sortResults(t=this._results.all){t.sort(u)}}class b{constructor(){this.min=new m(n()),this.max=new m(n()),this.hud={min:new h(n()),max:new h(n()),all:new Array},this.ground=new m(n()),this.all=[]}init(t){this.min.init(t),this.max.init(t),this.ground.init(t),this.all.length=0,this.hud.min.init(t),this.hud.max.init(t),this.hud.all.length=0}}const j={*processTriangle(t){yield t},*processLineSegment(t,e,i){s(t[0],e),s(t[1],i),yield t},validatePoint:()=>!0};export{v as Intersector,j as defaultScreenPolygonPrimitiveProcessor,_ as defaultTolerance};
2
+ import{add as t,transformMat4 as e,copy as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as r}from"../../../../geometry/support/frustumPlanes.js";import{create as n,fromPoints as o,copy as a}from"../../../../geometry/support/ray.js";import l from"../../webgl/RenderCamera.js";import{HUDTarget as c,HUDIntersectorResult as h}from"./HUDIntersectorResult.js";import{IntersectorOptions as f}from"./IntersectorInterfaces.js";import{IntersectorResultRay as m,compareOrderedIntersectionHits as u}from"./IntersectorResult.js";import{ObjectTarget as d}from"./ObjectTarget.js";import{PolygonIntersectionResults as y}from"./PolygonIntersectionResults.js";import{IntersectorTransform as g,getVerticalOffsetObject3D as p}from"./verticalOffsetUtils.js";const _=1e-5;class v{constructor(t){this.options=new f,this._results=new b,this.polygonResults=new y,this.transform=new g,this.camera=new l,this.screenPolygonPrimitiveProcessor=j,this.tolerance=_,this.verticalOffset=null,this._ray=n(),this._rayEnd=i(),this._rayBeginTransformed=i(),this._rayEndTransformed=i(),this.viewingMode=t??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(t,e,s){this.resetWithRay(o(t,e,this._ray),s)}resetWithRay(e,s){this.camera=s,e!==this._ray&&a(e,this._ray),0!==this.options.verticalOffset?2===this.viewingMode?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset:this.verticalOffset=null,t(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(t=null,e,s,i,r){this.point=e,this.filterPredicate=i,this.tolerance=s??_;const n=p(this.verticalOffset);if(t&&t.length>0){const e=r?t=>{r(t)&&this.intersectObject(t)}:t=>{this.intersectObject(t)};for(const s of t){const t=s.getSpatialQueryAccelerator?.();null!=t?(null!=n?t.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,e,n):t.forEachAlongRay(this._ray.origin,this._ray.direction,e),this.options.selectionMode&&this.options.hud&&t.forEachDegenerateObject(e)):s.objects.forEach(t=>e(t))}}this.sortResults()}*intersectScreenPolygon(t=null,e){if(this.verticalOffset=null,t?.length)for(const s of t){const t=s.getSpatialQueryAccelerator?.();if(null!=t)for(const s of t.intersectingFrustumValues(e.broadPhaseFrustum,t=>t.visible))yield*this._intersectScreenPolygonObject(s,e);else for(const i of s.objects.values())i.visible&&r(e.broadPhaseFrustum,i.boundingVolumeWorldSpace.bounds)&&(yield*this._intersectScreenPolygonObject(i,e))}}*intersectHUDScreenPolygon(t=null,e){if(this.verticalOffset=null,this.options.selectionMode&&this.options.hud&&t?.length)for(const s of t){const t=s.getSpatialQueryAccelerator?.(),i=t?.degenerateObjectValues()??s.objects.values();for(const s of i)yield*this._intersectScreenPolygonObject(s,e)}}*_intersectScreenPolygonObject(t,e){const s=t.geometries;if(!t.visible||!s)return;const i=t.effectiveTransformation;for(const r of s){if(!r.visible)continue;const{material:s,id:n}=r;if(!s.visible||!s.intersectScreenPolygon)continue;this.transform.setAndInvalidateLazyTransforms(i,r.transformation);const o=s.intersectScreenPolygon(r,this.transform.transform,this,e);o?.valid&&this._handleObjectScreenPolygonIntersection(o.type,new d(t,n,o.primitiveIndex),o.distance,o.point),yield}}intersectObject(t){const s=t.geometries;if(!s)return;const i=t.effectiveTransformation,r=p(this.verticalOffset);for(const n of s){if(!n.visible)continue;const{material:s,id:o}=n;if(!s.visible)continue;this.transform.setAndInvalidateLazyTransforms(i,n.transformation),e(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),e(this._rayEndTransformed,this.rayEnd,this.transform.inverse);const a=this.transform.transform;null!=r&&(r.objectTransform=this.transform),s.intersectRay(n,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(e,s,i,r,n)=>this.handleObjectIntersection({object:t,geometryId:o,primitiveIndex:r},e,s,i,a,n))}}handleObjectIntersection(t,e,s,i,r,n){if(e<0||null!=this.filterPredicate&&!this.filterPredicate(this._ray.origin,this._rayEnd,s))return;const o=n?this._results.hud:this._results;t=n?new c(t,n):t;const a=n?r=>r.set(1,t,e,s,i):n=>n.set(4,t,e,s,i,r);if((null==o.min.renderDistance||s<o.min.renderDistance)&&a(o.min),0!==this.options.store&&(null==o.max.renderDistance||s>o.max.renderDistance)&&a(o.max),2===this.options.store)if(n){const t=new h(this._ray);a(t),this._results.hud.all.push(t)}else{const t=new m(this._ray);a(t),this._results.all.push(t)}}_handleObjectScreenPolygonIntersection(t,e,s,i){s<0||(null==this.filterPredicate||null!=i&&this.filterPredicate(this.camera.eye,i,1))&&this.polygonResults.add(t,1===t&&i?new c(e,i):e,s)}sortResults(t=this._results.all){t.sort(u)}}class b{constructor(){this.min=new m(n()),this.max=new m(n()),this.hud={min:new h(n()),max:new h(n()),all:new Array},this.ground=new m(n()),this.all=[]}init(t){this.min.init(t),this.max.init(t),this.ground.init(t),this.all.length=0,this.hud.min.init(t),this.hud.max.init(t),this.hud.all.length=0}}const j={*processTriangle(t){yield t},*processLineSegment(t,e,i){s(t[0],e),s(t[1],i),yield t},validatePoint:()=>!0};export{v as Intersector,j as defaultScreenPolygonPrimitiveProcessor,_ as defaultTolerance};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{lerp as n,scale as r,add as i,squaredDistance as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphereCenterRadius as h,intersectsSphere as d}from"../../../../geometry/support/frustum.js";import{wrap as c}from"../../../../geometry/support/ray.js";import{Sphere as u}from"../../../../geometry/support/sphere.js";import{rayBoxTest as l}from"./Util.js";class f{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new m,this._objectCount=0,t&&(void 0!==t.maximumObjectsPerNode&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),void 0!==t.maximumDepth&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),m.clearPool(),R[0]=null,k.prune(),G.prune()}add(e){const t=Array.from(e);this._grow(t);const n=m.acquire();for(const r of t)++this._objectCount,this._isDegenerate(r)?this._degenerateObjects.add(r):(n.init(this._root),this._add(r,n));m.release(n)}remove(e,t=null){this._objectCount-=e.length;const n=m.acquire();for(const r of e){const e=t??this.objectToBoundingSphere(r);w(e.radius)?(n.init(this._root),g(r,e,n)):this._degenerateObjects.delete(r)}m.release(n),this._shrink()}update(e,t){if(!w(t.radius)&&this._isDegenerate(e))return;const n=E(e);this.remove(n,t),this.add(n)}forEachAlongRay(e,t,n){const r=c(e,t);p(this._root,e=>{if(!j(r,e))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),!0})}forEachAlongRayWithVerticalOffset(e,t,n,r){const i=c(e,t);p(this._root,e=>{if(!x(i,e,r))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),!0})}forEach(e){for(const t of this.values())e(t)}*values(){for(const e of this._nodeIteratorValues()){const t=e.node;yield*t.terminals,null!==t.residents&&(yield*t.residents)}yield*this.degenerateObjectValues()}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}*degenerateObjectValues(){yield*this._degenerateObjects.values()}findClosest(e,t,n,s=()=>!0,o=1/0){let a=1/0,c=1/0,u=null;const l=N(e,t),f=r=>{if(--o,!s(r))return;const i=this.objectToBoundingSphere(r);if(!d(n,i))return;const h=v(e,t,i.center),l=h-i.radius,f=h+i.radius;l<a&&(a=l,c=f,u=r)};return b(this._root,s=>{if(o<=0||!h(n,s.bounds.center,2*s.bounds.radius))return!1;r(I,l,2*s.halfSize),i(I,I,s.bounds.center);if(v(e,t,I)>c)return!1;const a=s.node;return a.terminals.forAll(e=>f(e)),null!==a.residents&&a.residents.forAll(e=>f(e)),!0},e,t),u}forEachInDepthRange(e,t,n,s,o,a,c){let u=-1/0,l=1/0;const f={setRange:e=>{1===n?(u=Math.max(u,e.near),l=Math.min(l,e.far)):(u=Math.max(u,-e.far),l=Math.min(l,-e.near))}};f.setRange(s);const m=v(t,n,e),_=N(t,n),p=N(t,-n),g=e=>{if(!c(e))return;const r=this.objectToBoundingSphere(e),i=v(t,n,r.center)-m,s=i-r.radius,h=i+r.radius;s>l||h<u||!d(a,r)||o(e,f)};b(this._root,e=>{if(!h(a,e.bounds.center,2*e.bounds.radius))return!1;r(I,_,2*e.halfSize),i(I,I,e.bounds.center);if(v(t,n,I)-m>l)return!1;r(I,p,2*e.halfSize),i(I,I,e.bounds.center);if(v(t,n,I)-m<u)return!1;const s=e.node;return s.terminals.forAll(e=>g(e)),null!==s.residents&&s.residents.forAll(e=>g(e)),!0},t,n)}forEachNode(e){p(this._root,t=>e(t.node,t.bounds,t.halfSize,t.depth))}forEachIntersectingFrustum(e,t,n=()=>!0){for(const r of this.intersectingFrustumValues(e,n))t(r)}*intersectingFrustumValues(e,t=()=>!0){for(const n of this._nodeIteratorValues(t=>h(e,t.bounds.center,2*t.bounds.radius))){const r=n.node;for(const n of r.terminals)t(n)&&d(e,this.objectToBoundingSphere(n))&&(yield n);if(null!==r.residents)for(const n of r.residents)t(n)&&d(e,this.objectToBoundingSphere(n))&&(yield n)}}*_nodeIteratorValues(e=()=>!0){yield*_(this._root,e)}forEachNeighbor(e,t){const n=t.radius,r=t.center,i=n=>{const r=this.objectToBoundingSphere(n);return!t.intersects(r)||e(n)};let o=!0;const a=e=>{o&&(o=i(e))};p(this._root,e=>{const t=2*e.bounds.radius,i=n+t;if(s(e.bounds.center,r)-i*i>0)return!1;const h=e.node;return h.terminals.forAll(a),o&&null!==h.residents&&h.residents.forAll(a),o}),o&&this.forEachDegenerateObject(a)}_intersectsObject(e,t){const n=this.objectToBoundingSphere(t);return!(n.radius>0)||n.intersectRay(e)}_intersectsObjectWithOffset(e,t,n){const r=this.objectToBoundingSphere(t);return!(r.radius>0)||n.applyToBoundingSphere(r).intersectRay(e)}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){const t=e.node.residents;e.node.residents=null;for(let n=0;n<t.length;n++){const r=m.acquire().init(e);this._add(t.at(n),r),m.release(r)}}_grow(e){if(y(e,e=>this.objectToBoundingSphere(e),L),w(L.radius)&&!this._fitsInsideTree(L))if(z(this._root.node))this._root.bounds.copyFrom(L),this._root.halfSize=1.25*this._root.bounds.radius,this._root.updateBoundsRadiusFromHalfSize();else{const e=this._rootBoundsForRootAsSubNode(L);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(L,e):this._growRootAsSubNode(e),m.release(e)}}_rebuildTree(e,t){C.center=t.bounds.center,C.radius=t.halfSize,y([e,C],e=>e,H);const n=m.acquire().init(this._root);this._root.initFrom(null,H,H.radius),this._root.increaseHalfSize(1.25),p(n,e=>(this.add(e.node.terminals.data),null!==e.node.residents&&this.add(e.node.residents.data),!0)),m.release(n)}_placingRootViolatesMaxDepth(e){const t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E;let n=0;return p(this._root,e=>(n=Math.max(n,e.depth),n+t<=this._maximumDepth)),n+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){const t=e.radius,n=e.center;let r=-1/0;const i=this._root.bounds.center,s=this._root.halfSize;for(let a=0;a<3;a++){const e=i[a]-s-(n[a]-t),o=n[a]+t-(i[a]+s),h=Math.max(0,Math.ceil(e/(2*s))),d=Math.max(0,Math.ceil(o/(2*s)))+1,c=2**Math.ceil(Math.log(h+d)*Math.LOG2E);r=Math.max(r,c),W[a].min=h,W[a].max=d}for(let a=0;a<3;a++){let e=W[a].min,t=W[a].max;const n=(r-(e+t))/2;e+=Math.ceil(n),t+=Math.floor(n);const o=i[a]-s-e*s*2;q.center[a]=o+(t+e)*s}const o=r*s;return q.radius=o*D,m.acquire().initFrom(null,q,o,0)}_growRootAsSubNode(e){const t=this._root.node;L.center=this._root.bounds.center,L.radius=this._root.halfSize,this._root.init(e),e.advanceTo(L,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){const e=this._findShrinkIndex();if(-1===e)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let e=null;const t=this._root.node.children;let n=0,r=0;for(;r<t.length&&null==e;)n=r++,e=t[n];for(;r<t.length;)if(t[r++])return-1;return n}_isDegenerate(e){return!w(this.objectToBoundingSphere(e).radius)}_fitsInsideTree(e){const t=this._root.bounds,n=this._root.halfSize;return e.radius<=n&&e.center[0]>=t.center[0]-n&&e.center[0]<=t.center[0]+n&&e.center[1]>=t.center[1]-n&&e.center[1]<=t.center[1]+n&&e.center[2]>=t.center[2]-n&&e.center[2]<=t.center[2]+n}_nodeToJSON(e){const t=e.children.map(e=>e?this._nodeToJSON(e):null),n=e.residents?.map(e=>this.objectToBoundingSphere(e)),r=e.terminals?.map(e=>this.objectToBoundingSphere(e));return{children:t,residents:n,terminals:r}}}class m{constructor(){this.bounds=new u,this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,n,r=this.depth){return this.node=null!=e?e:m.createEmptyNode(),t&&this.bounds.copyFrom(t),this.halfSize=n,this.depth=r,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds.radius=this.halfSize*D}advance(e){let t=this.node.children[e];t||(t=m.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;const n=A[e];return this.bounds.center[0]+=n[0]*this.halfSize,this.bounds.center[1]+=n[1]*this.halfSize,this.bounds.center[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,n=!1){for(;;){if(this.isTerminalFor(e))return t?.(this,-1),!0;if(this.isLeaf()){if(!n)return t?.(this,-1),!1;this.node.residents=null}const r=this._childIndex(e);t?.(this,r),this.advance(r)}}isLeaf(){return null!=this.node.residents}isTerminalFor(e){return e.radius>this.halfSize/2}_childIndex(e){const t=this.bounds.center;return(t[0]<e.center[0]?1:0)+(t[1]<e.center[1]?2:0)+(t[2]<e.center[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static{this._pool=new e(()=>new m)}static acquire(){return m._pool.acquire()}static release(e){m._pool.release(e)}static clearPool(){m._pool.prune()}}function*_(e,t=()=>!0){const n=[m.acquire().init(e)];for(;0!==n.length;){const e=n.pop();if(t(e)){if(yield e,!e.isLeaf())for(let t=0;t<e.node.children.length;t++){e.node.children[t]&&n.push(m.acquire().init(e).advance(t))}m.release(e)}}}function p(e,t){const n=_(e,t);for(const r of n);}function b(e,t,n,r=1){let i=m.acquire().init(e);const s=[i];for(B(n,r,J);0!==s.length;){if(i=s.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){const t=J[e];i.node.children[t]&&s.push(m.acquire().init(i).advance(t))}m.release(i)}}function g(e,t,n){k.clear();const r=n.advanceTo(t,(e,t)=>{k.push(e.node),k.push(t)})?n.node.terminals:n.node.residents;if(r.removeUnordered(e),0===r.length)for(let i=k.length-2;i>=0;i-=2){if(!S(k.data[i],k.data[i+1]))break}}function S(e,n){return n>=0&&(e.children[n]=null),!!z(e)&&(null===e.residents&&(e.residents=new t({shrink:!0})),!0)}function j(e,t){return T(t.bounds.center,2*-t.halfSize,P),T(t.bounds.center,2*t.halfSize,V),l(e.origin,e.direction,P,V)}function x(e,t,n){return T(t.bounds.center,2*-t.halfSize,P),T(t.bounds.center,2*t.halfSize,V),n.applyToMinMax(P,V),l(e.origin,e.direction,P,V)}function z(e){if(0!==e.terminals.length)return!1;if(null!==e.residents)return 0===e.residents.length;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}function O(e,t){e[0]=Math.min(e[0],t.center[0]-t.radius),e[1]=Math.min(e[1],t.center[1]-t.radius),e[2]=Math.min(e[2],t.center[2]-t.radius)}function M(e,t){e[0]=Math.max(e[0],t.center[0]+t.radius),e[1]=Math.max(e[1],t.center[1]+t.radius),e[2]=Math.max(e[2],t.center[2]+t.radius)}function T(e,t,n){n[0]=e[0]+t,n[1]=e[1]+t,n[2]=e[2]+t}function y(e,t,r){P[0]=1/0,P[1]=1/0,P[2]=1/0,V[0]=-1/0,V[1]=-1/0,V[2]=-1/0;for(const n of e){const e=t(n);w(e.radius)&&(O(P,e),M(V,e))}n(r.center,P,V,.5),r.radius=Math.max(V[0]-P[0],V[1]-P[1],V[2]-P[2])/2}function B(e,t,n){if(!G.length)for(let r=0;r<8;++r)G.push({index:0,distance:0});for(let r=0;r<8;++r){const n=A[r];G.data[r].index=r,G.data[r].distance=v(e,t,n)}G.sort((e,t)=>e.distance-t.distance);for(let r=0;r<8;++r)n[r]=G.data[r].index}function N(e,t){let n,r=1/0;for(let i=0;i<8;++i){const s=v(e,t,F[i]);s<r&&(r=s,n=F[i])}return n}function v(e,t,n){return t*(e[0]*n[0]+e[1]*n[1]+e[2]*n[2])}function w(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}const A=[o(-1,-1,-1),o(1,-1,-1),o(-1,1,-1),o(1,1,-1),o(-1,-1,1),o(1,-1,1),o(-1,1,1),o(1,1,1)],F=[o(-1,-1,-1),o(-1,-1,1),o(-1,1,-1),o(-1,1,1),o(1,-1,-1),o(1,-1,1),o(1,1,-1),o(1,1,1)],D=Math.sqrt(3),R=[null];function E(e){return R[0]=e,R}const q=new u,I=a(),P=a(),V=a(),k=new t,L=new u,C=new u,H=new u,W=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],G=new t,J=[0,0,0,0,0,0,0,0];export{f as Octree};
2
+ import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{lerp as n,scale as r,add as i,squaredDistance as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphereCenterRadius as h,intersectsSphere as d}from"../../../../geometry/support/frustumPlanes.js";import{wrap as c}from"../../../../geometry/support/ray.js";import{Sphere as u}from"../../../../geometry/support/sphere.js";import{rayBoxTest as l}from"./Util.js";class f{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new m,this._objectCount=0,t&&(void 0!==t.maximumObjectsPerNode&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),void 0!==t.maximumDepth&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),m.clearPool(),R[0]=null,k.prune(),G.prune()}add(e){const t=Array.from(e);this._grow(t);const n=m.acquire();for(const r of t)++this._objectCount,this._isDegenerate(r)?this._degenerateObjects.add(r):(n.init(this._root),this._add(r,n));m.release(n)}remove(e,t=null){this._objectCount-=e.length;const n=m.acquire();for(const r of e){const e=t??this.objectToBoundingSphere(r);w(e.radius)?(n.init(this._root),g(r,e,n)):this._degenerateObjects.delete(r)}m.release(n),this._shrink()}update(e,t){if(!w(t.radius)&&this._isDegenerate(e))return;const n=E(e);this.remove(n,t),this.add(n)}forEachAlongRay(e,t,n){const r=c(e,t);p(this._root,e=>{if(!j(r,e))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),!0})}forEachAlongRayWithVerticalOffset(e,t,n,r){const i=c(e,t);p(this._root,e=>{if(!x(i,e,r))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),!0})}forEach(e){for(const t of this.values())e(t)}*values(){for(const e of this._nodeIteratorValues()){const t=e.node;yield*t.terminals,null!==t.residents&&(yield*t.residents)}yield*this.degenerateObjectValues()}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}*degenerateObjectValues(){yield*this._degenerateObjects.values()}findClosest(e,t,n,s=()=>!0,o=1/0){let a=1/0,c=1/0,u=null;const l=N(e,t),f=r=>{if(--o,!s(r))return;const i=this.objectToBoundingSphere(r);if(!d(n,i))return;const h=v(e,t,i.center),l=h-i.radius,f=h+i.radius;l<a&&(a=l,c=f,u=r)};return b(this._root,s=>{if(o<=0||!h(n,s.bounds.center,2*s.bounds.radius))return!1;r(P,l,2*s.halfSize),i(P,P,s.bounds.center);if(v(e,t,P)>c)return!1;const a=s.node;return a.terminals.forAll(e=>f(e)),null!==a.residents&&a.residents.forAll(e=>f(e)),!0},e,t),u}forEachInDepthRange(e,t,n,s,o,a,c){let u=-1/0,l=1/0;const f={setRange:e=>{1===n?(u=Math.max(u,e.near),l=Math.min(l,e.far)):(u=Math.max(u,-e.far),l=Math.min(l,-e.near))}};f.setRange(s);const m=v(t,n,e),_=N(t,n),p=N(t,-n),g=e=>{if(!c(e))return;const r=this.objectToBoundingSphere(e),i=v(t,n,r.center)-m,s=i-r.radius,h=i+r.radius;s>l||h<u||!d(a,r)||o(e,f)};b(this._root,e=>{if(!h(a,e.bounds.center,2*e.bounds.radius))return!1;r(P,_,2*e.halfSize),i(P,P,e.bounds.center);if(v(t,n,P)-m>l)return!1;r(P,p,2*e.halfSize),i(P,P,e.bounds.center);if(v(t,n,P)-m<u)return!1;const s=e.node;return s.terminals.forAll(e=>g(e)),null!==s.residents&&s.residents.forAll(e=>g(e)),!0},t,n)}forEachNode(e){p(this._root,t=>e(t.node,t.bounds,t.halfSize,t.depth))}forEachIntersectingFrustum(e,t,n=()=>!0){for(const r of this.intersectingFrustumValues(e,n))t(r)}*intersectingFrustumValues(e,t=()=>!0){for(const n of this._nodeIteratorValues(t=>h(e,t.bounds.center,2*t.bounds.radius))){const r=n.node;for(const n of r.terminals)t(n)&&d(e,this.objectToBoundingSphere(n))&&(yield n);if(null!==r.residents)for(const n of r.residents)t(n)&&d(e,this.objectToBoundingSphere(n))&&(yield n)}}*_nodeIteratorValues(e=()=>!0){yield*_(this._root,e)}forEachNeighbor(e,t){const n=t.radius,r=t.center,i=n=>{const r=this.objectToBoundingSphere(n);return!t.intersects(r)||e(n)};let o=!0;const a=e=>{o&&(o=i(e))};p(this._root,e=>{const t=2*e.bounds.radius,i=n+t;if(s(e.bounds.center,r)-i*i>0)return!1;const h=e.node;return h.terminals.forAll(a),o&&null!==h.residents&&h.residents.forAll(a),o}),o&&this.forEachDegenerateObject(a)}_intersectsObject(e,t){const n=this.objectToBoundingSphere(t);return!(n.radius>0)||n.intersectRay(e)}_intersectsObjectWithOffset(e,t,n){const r=this.objectToBoundingSphere(t);return!(r.radius>0)||n.applyToBoundingSphere(r).intersectRay(e)}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){const t=e.node.residents;e.node.residents=null;for(let n=0;n<t.length;n++){const r=m.acquire().init(e);this._add(t.at(n),r),m.release(r)}}_grow(e){if(y(e,e=>this.objectToBoundingSphere(e),L),w(L.radius)&&!this._fitsInsideTree(L))if(z(this._root.node))this._root.bounds.copyFrom(L),this._root.halfSize=1.25*this._root.bounds.radius,this._root.updateBoundsRadiusFromHalfSize();else{const e=this._rootBoundsForRootAsSubNode(L);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(L,e):this._growRootAsSubNode(e),m.release(e)}}_rebuildTree(e,t){C.center=t.bounds.center,C.radius=t.halfSize,y([e,C],e=>e,H);const n=m.acquire().init(this._root);this._root.initFrom(null,H,H.radius),this._root.increaseHalfSize(1.25),p(n,e=>(this.add(e.node.terminals.data),null!==e.node.residents&&this.add(e.node.residents.data),!0)),m.release(n)}_placingRootViolatesMaxDepth(e){const t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E;let n=0;return p(this._root,e=>(n=Math.max(n,e.depth),n+t<=this._maximumDepth)),n+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){const t=e.radius,n=e.center;let r=-1/0;const i=this._root.bounds.center,s=this._root.halfSize;for(let a=0;a<3;a++){const e=i[a]-s-(n[a]-t),o=n[a]+t-(i[a]+s),h=Math.max(0,Math.ceil(e/(2*s))),d=Math.max(0,Math.ceil(o/(2*s)))+1,c=2**Math.ceil(Math.log(h+d)*Math.LOG2E);r=Math.max(r,c),W[a].min=h,W[a].max=d}for(let a=0;a<3;a++){let e=W[a].min,t=W[a].max;const n=(r-(e+t))/2;e+=Math.ceil(n),t+=Math.floor(n);const o=i[a]-s-e*s*2;q.center[a]=o+(t+e)*s}const o=r*s;return q.radius=o*D,m.acquire().initFrom(null,q,o,0)}_growRootAsSubNode(e){const t=this._root.node;L.center=this._root.bounds.center,L.radius=this._root.halfSize,this._root.init(e),e.advanceTo(L,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){const e=this._findShrinkIndex();if(-1===e)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let e=null;const t=this._root.node.children;let n=0,r=0;for(;r<t.length&&null==e;)n=r++,e=t[n];for(;r<t.length;)if(t[r++])return-1;return n}_isDegenerate(e){return!w(this.objectToBoundingSphere(e).radius)}_fitsInsideTree(e){const t=this._root.bounds,n=this._root.halfSize;return e.radius<=n&&e.center[0]>=t.center[0]-n&&e.center[0]<=t.center[0]+n&&e.center[1]>=t.center[1]-n&&e.center[1]<=t.center[1]+n&&e.center[2]>=t.center[2]-n&&e.center[2]<=t.center[2]+n}_nodeToJSON(e){const t=e.children.map(e=>e?this._nodeToJSON(e):null),n=e.residents?.map(e=>this.objectToBoundingSphere(e)),r=e.terminals?.map(e=>this.objectToBoundingSphere(e));return{children:t,residents:n,terminals:r}}}class m{constructor(){this.bounds=new u,this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,n,r=this.depth){return this.node=null!=e?e:m.createEmptyNode(),t&&this.bounds.copyFrom(t),this.halfSize=n,this.depth=r,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds.radius=this.halfSize*D}advance(e){let t=this.node.children[e];t||(t=m.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;const n=A[e];return this.bounds.center[0]+=n[0]*this.halfSize,this.bounds.center[1]+=n[1]*this.halfSize,this.bounds.center[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,n=!1){for(;;){if(this.isTerminalFor(e))return t?.(this,-1),!0;if(this.isLeaf()){if(!n)return t?.(this,-1),!1;this.node.residents=null}const r=this._childIndex(e);t?.(this,r),this.advance(r)}}isLeaf(){return null!=this.node.residents}isTerminalFor(e){return e.radius>this.halfSize/2}_childIndex(e){const t=this.bounds.center;return(t[0]<e.center[0]?1:0)+(t[1]<e.center[1]?2:0)+(t[2]<e.center[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static{this._pool=new e(()=>new m)}static acquire(){return m._pool.acquire()}static release(e){m._pool.release(e)}static clearPool(){m._pool.prune()}}function*_(e,t=()=>!0){const n=[m.acquire().init(e)];for(;0!==n.length;){const e=n.pop();if(t(e)){if(yield e,!e.isLeaf())for(let t=0;t<e.node.children.length;t++){e.node.children[t]&&n.push(m.acquire().init(e).advance(t))}m.release(e)}}}function p(e,t){const n=_(e,t);for(const r of n);}function b(e,t,n,r=1){let i=m.acquire().init(e);const s=[i];for(B(n,r,J);0!==s.length;){if(i=s.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){const t=J[e];i.node.children[t]&&s.push(m.acquire().init(i).advance(t))}m.release(i)}}function g(e,t,n){k.clear();const r=n.advanceTo(t,(e,t)=>{k.push(e.node),k.push(t)})?n.node.terminals:n.node.residents;if(r.removeUnordered(e),0===r.length)for(let i=k.length-2;i>=0;i-=2){if(!S(k.data[i],k.data[i+1]))break}}function S(e,n){return n>=0&&(e.children[n]=null),!!z(e)&&(null===e.residents&&(e.residents=new t({shrink:!0})),!0)}function j(e,t){return T(t.bounds.center,2*-t.halfSize,I),T(t.bounds.center,2*t.halfSize,V),l(e.origin,e.direction,I,V)}function x(e,t,n){return T(t.bounds.center,2*-t.halfSize,I),T(t.bounds.center,2*t.halfSize,V),n.applyToMinMax(I,V),l(e.origin,e.direction,I,V)}function z(e){if(0!==e.terminals.length)return!1;if(null!==e.residents)return 0===e.residents.length;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}function O(e,t){e[0]=Math.min(e[0],t.center[0]-t.radius),e[1]=Math.min(e[1],t.center[1]-t.radius),e[2]=Math.min(e[2],t.center[2]-t.radius)}function M(e,t){e[0]=Math.max(e[0],t.center[0]+t.radius),e[1]=Math.max(e[1],t.center[1]+t.radius),e[2]=Math.max(e[2],t.center[2]+t.radius)}function T(e,t,n){n[0]=e[0]+t,n[1]=e[1]+t,n[2]=e[2]+t}function y(e,t,r){I[0]=1/0,I[1]=1/0,I[2]=1/0,V[0]=-1/0,V[1]=-1/0,V[2]=-1/0;for(const n of e){const e=t(n);w(e.radius)&&(O(I,e),M(V,e))}n(r.center,I,V,.5),r.radius=Math.max(V[0]-I[0],V[1]-I[1],V[2]-I[2])/2}function B(e,t,n){if(!G.length)for(let r=0;r<8;++r)G.push({index:0,distance:0});for(let r=0;r<8;++r){const n=A[r];G.data[r].index=r,G.data[r].distance=v(e,t,n)}G.sort((e,t)=>e.distance-t.distance);for(let r=0;r<8;++r)n[r]=G.data[r].index}function N(e,t){let n,r=1/0;for(let i=0;i<8;++i){const s=v(e,t,F[i]);s<r&&(r=s,n=F[i])}return n}function v(e,t,n){return t*(e[0]*n[0]+e[1]*n[1]+e[2]*n[2])}function w(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}const A=[o(-1,-1,-1),o(1,-1,-1),o(-1,1,-1),o(1,1,-1),o(-1,-1,1),o(1,-1,1),o(-1,1,1),o(1,1,1)],F=[o(-1,-1,-1),o(-1,-1,1),o(-1,1,-1),o(-1,1,1),o(1,-1,-1),o(1,-1,1),o(1,1,-1),o(1,1,1)],D=Math.sqrt(3),R=[null];function E(e){return R[0]=e,R}const q=new u,P=a(),I=a(),V=a(),k=new t,L=new u,C=new u,H=new u,W=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],G=new t,J=[0,0,0,0,0,0,0,0];export{f as Octree};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/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{create as r,copy as s,nan as o,fromValues as i}from"../../../../geometry/support/aaBoundingBox.js";import{intersectsTransformedAabb as a}from"../../../../geometry/support/frustum.js";import{newContinuousIndexArray as c}from"../../../../geometry/support/Indices.js";import{createPositionReader as l}from"./PositionReader.js";import{MeshIntersectionOptions as h,intersectRayTriangles as g}from"./RayIntersections.js";import{forEachTriangleRangeScreenPolygonHit as m}from"./screenPolygonTriangleIntersections.js";const d=40,u=.8,y=10,_=1e-6;class p{constructor(e,r,s){this.globalTriangleVertexIndices=e,this.numTriangles=r,this.positions=s,this._rayDirection=n(),this._callback=M,this._intersectionOptions=T,this._screenPolygonCallback=R,this._screenPolygonDisplacement=null,this._screenPolygonIntersector=null,this._screenPolygonQuery=null,this._screenPolygonTransformation=null,this.bspNodeTree=new Array,this.triangleIndexMap=c(r),this._readPosition=l(s.data,e,s.stride);const o=b(e,r,s.data,s.stride),i=t(Math.log2(r/d),2,y),a=(t,e,n)=>{const r=x(this.triangleIndexMap,o,t,e),s=e-t;if(s<=d){const n=new f(r,void 0,0,t,e);return this.bspNodeTree.push(n),n}const{axis:c,midValue:l}=I(r),h=P(this.triangleIndexMap,o,t,e,c,l),g=(t,e)=>{if(n>i)return;const r=e-t;return r<d||r>=u*s?void 0:a(t,e,n+1)},m=new f(r,c,l,h.next,h.mid);return this.bspNodeTree.push(m),m.leftNode=g(t,h.next),m.rightNode=g(h.mid,e),m};a(0,r,0)}intersectRayTriangleRange(t,e){if(t>=e)return;const{data:n,stride:r}=this.positions;g(this._rayFrom,this._rayDirection,t,e,this.globalTriangleVertexIndices,n,r,this._intersectionOptions.normalRequired,this._callback,this.triangleIndexMap),p.numFacesTested+=e-t}forEachScreenPolygonHit(t,e,n,r,s){null!=t.camera&&0!==this.bspNodeTree.length&&(this._screenPolygonIntersector=t,this._screenPolygonTransformation=e,this._screenPolygonQuery=n,this._screenPolygonDisplacement=r,this._screenPolygonCallback=s,this._intersectScreenPolygonBSP(this.bspNodeTree[0],0,this.triangleIndexMap.length),this._screenPolygonCallback=R,this._screenPolygonDisplacement=null,this._screenPolygonQuery=null,this._screenPolygonTransformation=null,this._screenPolygonIntersector=null)}intersectRay(t,e,n,r){p.numFacesTested=0;const s=t,o=e,i=o[0]-s[0],a=o[1]-s[1],c=o[2]-s[2];if(i*i+a*a+c*c<_)return;this._rayFrom=s;const l=this._rayDirection;l[0]=i,l[1]=a,l[2]=c;const h=this.triangleIndexMap.length;this._callback=r,this._intersectionOptions=n,this.intersectRayBSP(this.bspNodeTree[0],0,h),this._callback=M,this._intersectionOptions=T}intersectRayBSP(t,e,n){const r=this._rayFrom,s=this._rayDirection;this._traverseBSP(t,e,n,t=>S(t.aabb,r,s),t=>{const e=t.axis;return r[e]<t.d||s[e]<0},t=>{const e=t.axis;return r[e]>t.d||s[e]>0},(t,e)=>this.intersectRayTriangleRange(t,e))}_intersectScreenPolygonTriangleRange(t,e){if(t>=e)return;const n=this._screenPolygonIntersector,r=this._screenPolygonQuery;if(null!=n&&null!=r)for(const s of m(n,this._screenPolygonTransformation,r,t,e,this._readPosition,this._screenPolygonDisplacement,this.triangleIndexMap))this._screenPolygonCallback(s.distance,s.primitiveIndex,s.point)}_intersectScreenPolygonBSP(t,e,n){const r=this._screenPolygonIntersector,s=this._screenPolygonQuery;null!=r?.camera&&null!=s&&this._traverseBSP(t,e,n,t=>this._nodeIntersectsScreenPolygonBroadPhase(t.aabb),()=>!0,()=>!0,(t,e)=>this._intersectScreenPolygonTriangleRange(t,e))}_traverseBSP(t,e,n,r,s,o,i){const a=[{node:t,rangeStart:e,rangeEnd:n}];for(;a.length>0;){const{node:t,rangeStart:e,rangeEnd:n}=a.pop();r(t)&&(s(t)&&this._traverseBSPRange(a,t.leftNode,e,t.midStartIndex,i),i(t.midStartIndex,t.rightStartIndex),o(t)&&this._traverseBSPRange(a,t.rightNode,t.rightStartIndex,n,i))}}_traverseBSPRange(t,e,n,r,s){n>=r||(void 0!==e?t.push({node:e,rangeStart:n,rangeEnd:r}):s(n,r))}_nodeIntersectsScreenPolygonBroadPhase(t){const e=this._screenPolygonQuery;if(null==e)return!1;const n=this._screenPolygonDisplacement,r=n?n.applyToAabb(s(B,t)):t;return a(e.broadPhaseFrustum,r,this._screenPolygonTransformation)}static{this.numFacesTested=0}get estimatedMemoryUsage(){return e(this.triangleIndexMap)}}class f{constructor(t,e,n,r,s){this.aabb=t,this.axis=e,this.d=n,this.midStartIndex=r,this.rightStartIndex=s}}function P(t,e,n,r,s,o){const i=s+3;let a=n,c=n,l=r;for(;c<l;){const n=t[c],r=6*n;e[r+i]<=o?(t[c]=t[a],t[a]=n,++a,++c):e[r+s]>=o?(--l,t[c]=t[l],t[l]=n):++c}return{next:a,mid:l}}function x(t,e,n,r){if(r<=n)return o;let s=6*t[n],a=e[s++],c=e[s++],l=e[s++],h=e[s++],g=e[s++],m=e[s];for(let o=n+1;o<r;++o)s=6*t[o],a=Math.min(a,e[s++]),c=Math.min(c,e[s++]),l=Math.min(l,e[s++]),h=Math.max(h,e[s++]),g=Math.max(g,e[s++]),m=Math.max(m,e[s]);return i(a,c,l,h,g,m)}function I(t){const e=t[3]-t[0],n=t[4]-t[1],r=t[5]-t[2],s=e>n?e>r?0:n>r?1:2:n>r?1:r>e?2:0;return{axis:s,midValue:(t[s]+t[s+3])/2}}function b(t,e,n,r){const s=new Float64Array(6*e);for(let o=0;o<e;++o){const e=3*o,i=t[e]*r,a=t[e+1]*r,c=t[e+2]*r;for(let t=0;t<3;++t){const e=n[i+t],r=n[a+t],l=n[c+t];s[6*o+t]=Math.min(e,r,l),s[6*o+3+t]=Math.max(e,r,l)}}return s}function S(t,e,n){const r=e,s=n;let o=0,i=1/0;for(let a=0;a<3;++a){{const e=t[a];if(r[a]<e){if(s[a]<=_)return!1;const t=(e-r[a])/s[a];o=Math.max(o,t)}else if(s[a]<=-_){const t=(e-r[a])/s[a];i=Math.min(i,t)}if(o>i)return!1}{const e=t[a+3];if(r[a]>e){if(s[a]>=-_)return!1;const t=(e-r[a])/s[a];o=Math.max(o,t)}else if(s[a]>=_){const t=(e-r[a])/s[a];i=Math.min(i,t)}if(o>i)return!1}}return!0}const T=new h,M=()=>{},R=()=>{},B=r();export{p 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{create as r,copy as s,nan as o,fromValues as i}from"../../../../geometry/support/aaBoundingBox.js";import{intersectsTransformedAabb as a}from"../../../../geometry/support/frustumPlanes.js";import{newContinuousIndexArray as c}from"../../../../geometry/support/Indices.js";import{createPositionReader as l}from"./PositionReader.js";import{MeshIntersectionOptions as h,intersectRayTriangles as g}from"./RayIntersections.js";import{forEachTriangleRangeScreenPolygonHit as m}from"./screenPolygonTriangleIntersections.js";const d=40,u=.8,y=10,_=1e-6;class p{constructor(e,r,s){this.globalTriangleVertexIndices=e,this.numTriangles=r,this.positions=s,this._rayDirection=n(),this._callback=M,this._intersectionOptions=T,this._screenPolygonCallback=R,this._screenPolygonDisplacement=null,this._screenPolygonIntersector=null,this._screenPolygonQuery=null,this._screenPolygonTransformation=null,this.bspNodeTree=new Array,this.triangleIndexMap=c(r),this._readPosition=l(s.data,e,s.stride);const o=b(e,r,s.data,s.stride),i=t(Math.log2(r/d),2,y),a=(t,e,n)=>{const r=x(this.triangleIndexMap,o,t,e),s=e-t;if(s<=d){const n=new P(r,void 0,0,t,e);return this.bspNodeTree.push(n),n}const{axis:c,midValue:l}=I(r),h=f(this.triangleIndexMap,o,t,e,c,l),g=(t,e)=>{if(n>i)return;const r=e-t;return r<d||r>=u*s?void 0:a(t,e,n+1)},m=new P(r,c,l,h.next,h.mid);return this.bspNodeTree.push(m),m.leftNode=g(t,h.next),m.rightNode=g(h.mid,e),m};a(0,r,0)}intersectRayTriangleRange(t,e){if(t>=e)return;const{data:n,stride:r}=this.positions;g(this._rayFrom,this._rayDirection,t,e,this.globalTriangleVertexIndices,n,r,this._intersectionOptions.normalRequired,this._callback,this.triangleIndexMap),p.numFacesTested+=e-t}forEachScreenPolygonHit(t,e,n,r,s){null!=t.camera&&0!==this.bspNodeTree.length&&(this._screenPolygonIntersector=t,this._screenPolygonTransformation=e,this._screenPolygonQuery=n,this._screenPolygonDisplacement=r,this._screenPolygonCallback=s,this._intersectScreenPolygonBSP(this.bspNodeTree[0],0,this.triangleIndexMap.length),this._screenPolygonCallback=R,this._screenPolygonDisplacement=null,this._screenPolygonQuery=null,this._screenPolygonTransformation=null,this._screenPolygonIntersector=null)}intersectRay(t,e,n,r){p.numFacesTested=0;const s=t,o=e,i=o[0]-s[0],a=o[1]-s[1],c=o[2]-s[2];if(i*i+a*a+c*c<_)return;this._rayFrom=s;const l=this._rayDirection;l[0]=i,l[1]=a,l[2]=c;const h=this.triangleIndexMap.length;this._callback=r,this._intersectionOptions=n,this.intersectRayBSP(this.bspNodeTree[0],0,h),this._callback=M,this._intersectionOptions=T}intersectRayBSP(t,e,n){const r=this._rayFrom,s=this._rayDirection;this._traverseBSP(t,e,n,t=>S(t.aabb,r,s),t=>{const e=t.axis;return r[e]<t.d||s[e]<0},t=>{const e=t.axis;return r[e]>t.d||s[e]>0},(t,e)=>this.intersectRayTriangleRange(t,e))}_intersectScreenPolygonTriangleRange(t,e){if(t>=e)return;const n=this._screenPolygonIntersector,r=this._screenPolygonQuery;if(null!=n&&null!=r)for(const s of m(n,this._screenPolygonTransformation,r,t,e,this._readPosition,this._screenPolygonDisplacement,this.triangleIndexMap))this._screenPolygonCallback(s.distance,s.primitiveIndex,s.point)}_intersectScreenPolygonBSP(t,e,n){const r=this._screenPolygonIntersector,s=this._screenPolygonQuery;null!=r?.camera&&null!=s&&this._traverseBSP(t,e,n,t=>this._nodeIntersectsScreenPolygonBroadPhase(t.aabb),()=>!0,()=>!0,(t,e)=>this._intersectScreenPolygonTriangleRange(t,e))}_traverseBSP(t,e,n,r,s,o,i){const a=[{node:t,rangeStart:e,rangeEnd:n}];for(;a.length>0;){const{node:t,rangeStart:e,rangeEnd:n}=a.pop();r(t)&&(s(t)&&this._traverseBSPRange(a,t.leftNode,e,t.midStartIndex,i),i(t.midStartIndex,t.rightStartIndex),o(t)&&this._traverseBSPRange(a,t.rightNode,t.rightStartIndex,n,i))}}_traverseBSPRange(t,e,n,r,s){n>=r||(void 0!==e?t.push({node:e,rangeStart:n,rangeEnd:r}):s(n,r))}_nodeIntersectsScreenPolygonBroadPhase(t){const e=this._screenPolygonQuery;if(null==e)return!1;const n=this._screenPolygonDisplacement,r=n?n.applyToAabb(s(B,t)):t;return a(e.broadPhaseFrustum,r,this._screenPolygonTransformation)}static{this.numFacesTested=0}get estimatedMemoryUsage(){return e(this.triangleIndexMap)}}class P{constructor(t,e,n,r,s){this.aabb=t,this.axis=e,this.d=n,this.midStartIndex=r,this.rightStartIndex=s}}function f(t,e,n,r,s,o){const i=s+3;let a=n,c=n,l=r;for(;c<l;){const n=t[c],r=6*n;e[r+i]<=o?(t[c]=t[a],t[a]=n,++a,++c):e[r+s]>=o?(--l,t[c]=t[l],t[l]=n):++c}return{next:a,mid:l}}function x(t,e,n,r){if(r<=n)return o;let s=6*t[n],a=e[s++],c=e[s++],l=e[s++],h=e[s++],g=e[s++],m=e[s];for(let o=n+1;o<r;++o)s=6*t[o],a=Math.min(a,e[s++]),c=Math.min(c,e[s++]),l=Math.min(l,e[s++]),h=Math.max(h,e[s++]),g=Math.max(g,e[s++]),m=Math.max(m,e[s]);return i(a,c,l,h,g,m)}function I(t){const e=t[3]-t[0],n=t[4]-t[1],r=t[5]-t[2],s=e>n?e>r?0:n>r?1:2:n>r?1:r>e?2:0;return{axis:s,midValue:(t[s]+t[s+3])/2}}function b(t,e,n,r){const s=new Float64Array(6*e);for(let o=0;o<e;++o){const e=3*o,i=t[e]*r,a=t[e+1]*r,c=t[e+2]*r;for(let t=0;t<3;++t){const e=n[i+t],r=n[a+t],l=n[c+t];s[6*o+t]=Math.min(e,r,l),s[6*o+3+t]=Math.max(e,r,l)}}return s}function S(t,e,n){const r=e,s=n;let o=0,i=1/0;for(let a=0;a<3;++a){{const e=t[a];if(r[a]<e){if(s[a]<=_)return!1;const t=(e-r[a])/s[a];o=Math.max(o,t)}else if(s[a]<=-_){const t=(e-r[a])/s[a];i=Math.min(i,t)}if(o>i)return!1}{const e=t[a+3];if(r[a]>e){if(s[a]>=-_)return!1;const t=(e-r[a])/s[a];o=Math.max(o,t)}else if(s[a]>=_){const t=(e-r[a])/s[a];i=Math.min(i,t)}if(o>i)return!1}}return!0}const T=new h,M=()=>{},R=()=>{},B=r();export{p as TriangleIntersectionData};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../core/PooledArray.js";import{multiply as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{transformMat4Z as n,transformMat4 as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{lerp as s}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as o}from"../../../../geometry/support/frustum.js";import{Sphere as h}from"../../../../geometry/support/sphere.js";import{maxScale as f}from"../../support/mathUtils.js";import{DepthRange as c}from"./DepthRange.js";import{assert as u}from"./Util.js";const l=1e4,d=100,m=500,_=500,g=.1;function p(e,t,r,n){let i=0;if(!t.some(e=>!!e.material&&(i+=e.numGeometries,i>=l)))return W.compute(e,t,n);const s=new c;return r.forEach(t=>s.union(b(e,t))),s}function b(e,t){if(!t.visible)return;const r=new c,n=t.getSpatialQueryAccelerator();return n?w(r,e,n):j(r,e,t.objects),r}function w(e,t,r){const{eye:n,viewForward:i,frustum:s}=t,a=e=>e.visible,o=r.objectCount;if(o<m)S.set(t.near,Math.min(e.near,t.far)),r.forEachInDepthRange(n,i,1,S,(r,n)=>{x(e,t,r),S.far=e.near,n.setRange(S)},s,a),S.set(Math.max(e.far,t.near),t.far),r.forEachInDepthRange(n,i,-1,S,(r,n)=>{x(e,t,r),S.near=e.far,n.setRange(S)},s,a);else{const n=Math.max(Math.min(o,_),Math.ceil(o*g)),h=r.findClosest(i,1,s,a,n),f=r.findClosest(i,-1,s,a,n);h&&f&&(v(e,t,h.boundingVolumeWorldSpace.bounds),v(e,t,f.boundingVolumeWorldSpace.bounds))}}function j(e,t,r){F.clear(),r.forEach(e=>{e.visible&&0!==e.geometries.length&&F.add(e,t)}),F.empty||(F.sort(),S.set(t.near,Math.min(e.near,t.far)),F.forEachInDepthRange(S,1,(r,n)=>{n<e.near&&x(e,t,r)}),S.set(Math.max(e.far,t.near),t.far),F.forEachInDepthRange(S,-1,(t,r,n)=>{e.far=Math.max(e.far,n)}))}function x(e,r,n){if(!n.visible)return;if(!o(r.frustum,n.boundingVolumeWorldSpace.bounds))return;const i=n.transformation,s=E;n.geometries.forEach(n=>{t(s,i,n.transformation);const a=f(s);R(e,r,n.boundingInfo,s,a)})}function R(e,t,r,n,s){if(null==r)return;i(D.center,r.sphere.center,n);const{eye:a,viewForward:h}=t,f=h[0]*(D.center[0]-a[0])+h[1]*(D.center[1]-a[1])+h[2]*(D.center[2]-a[2]);if(D.radius=r.sphere.radius*s,!(f-D.radius>e.near&&f+D.radius<e.far)&&o(t.frustum,D))if(r.sphere.radius>d&&r.children)for(const i of r.children)R(e,t,i,n,s);else N.unionDepthRangeWithAABB(e,t.viewProjectionMatrix,n,r.box)}function v(e,t,r){const n=t.eye,i=t.viewForward,s=(r.center[0]-n[0])*i[0]+(r.center[1]-n[1])*i[1]+(r.center[2]-n[2])*i[2];e.near=Math.min(e.near,s-r.radius),e.far=Math.max(e.far,s+r.radius)}class M{constructor(){this._items=new e({allocator:e=>e||{object:null,distance:0,near:0,far:0},deallocator:e=>(e.object=null,e.distance=0,e.near=0,e.far=0,e)})}get length(){return this._items.length}get empty(){return 0===this._items.length}clear(){this._items.clear()}add(e,t){const r=t.eye,n=t.viewForward,i=e.boundingVolumeWorldSpace.bounds,s=(i.center[0]-r[0])*n[0]+(i.center[1]-r[1])*n[1]+(i.center[2]-r[2])*n[2];if(!Number.isFinite(s))return;const a=this._items.pushNew();a.object=e,a.distance=s,a.near=s-i.radius,a.far=s+i.radius}sort(){this._items.sort((e,t)=>e.distance-t.distance)}forEachInDepthRange(e,t,r){if(1===t)for(let n=0;n<this._items.length;++n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}else for(let n=this._items.length-1;n>=0;--n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}}}class C{constructor(){this._geometries=new Array,this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange=new c(0,0)}compute(e,t,r){this._reset();const{viewMatrix:i}=e;t.forEach(e=>{e.forEachGeometry(e=>{if(!e.visible||0===r&&!e.castShadow)return;const t=e.boundingSphere,s=n(t.center,i),a=s-t.radius,o=s+t.radius;this._geometries.push(e),this._near.push(-o),this._far.push(-a)})});const s=new c;if(0===this._geometries.length)return s;for(let n=0;n<this._geometries.length;++n)this._near[n]>s.far&&(s.far=this._near[n]),this._near[n]>2&&this._far[n]<s.near&&(s.near=this._far[n]);const a=this._looseRange;a.near=Math.max(.5*s.near,2),a.far=2*s.far;let o=0,h=0;for(let n=0;n<this._geometries.length;++n)this._near[n]<s.near&&(this._near[n]>=a.near?s.near=this._near[n]:this._nearCandidates[o++]=n),this._far[n]>s.far&&(this._far[n]<=a.far?s.far=this._far[n]:this._farCandidates[h++]=n);if(0===this._nearCandidates.length&&0===this._farCandidates.length)return s;this._nearCandidates.sort((e,t)=>this._near[e]<this._near[t]?-1:this._near[e]>this._near[t]?1:0),this._farCandidates.sort((e,t)=>this._far[e]<this._far[t]?1:this._far[e]>this._far[t]?-1:0);for(let n=0;n<this._nearCandidates.length;++n){const t=this._nearCandidates[n];if(this._near[t]<s.near){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:i}=r;this._includeNearBoundingInfoRec(e,n,i,s)}}for(let n=0;n<this._farCandidates.length;++n){const t=this._farCandidates[n];if(this._far[t]>s.far){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:i}=r;this._includeFarBoundingInfoRec(e,n,i,s)}}return this._reset(),s}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_isOutsideSidePlanes(e,t){const{center:r,radius:n}=e;return t[0][0]*r[0]+t[0][1]*r[1]+t[0][2]*r[2]+t[0][3]>n||t[1][0]*r[0]+t[1][1]*r[1]+t[1][2]*r[2]+t[1][3]>n||t[2][0]*r[0]+t[2][1]*r[1]+t[2][2]*r[2]+t[2][3]>n||t[3][0]*r[0]+t[3][1]*r[1]+t[3][2]*r[2]+t[3][3]>n}_includeNearBoundingInfoRec(e,t,r,s){if(null==t)return;i(D.center,t.sphere.center,r),D.radius=t.sphere.radius*f(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(D,a))return;const o=D.radius,{viewMatrix:h}=e,c=n(D.center,h),u=c+o;if(!(-(c-o)<2||-u>=s.near))if(-u>this._looseRange.near)s.near=-u;else{if(o>d){const n=t.children;if(void 0!==n){for(const t of n)this._includeNearBoundingInfoRec(e,t,r,s);return}}N.unionDepthRangeWithAABB(s,e.viewProjectionMatrix,r,t.box)}}_includeFarBoundingInfoRec(e,t,r,s){if(null==t)return;i(D.center,t.sphere.center,r),D.radius=t.sphere.radius*f(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(D,a))return;const{viewMatrix:o,viewProjectionMatrix:h}=e,c=n(D.center,o)-D.radius;if(!(-c<=s.far))if(-c<this._looseRange.far)s.far=-c;else{if(D.radius>d){const n=t.children;if(void 0!==n){for(const t of n)this._includeFarBoundingInfoRec(e,t,r,s);return}}N.unionDepthRangeWithAABB(s,h,r,t.box)}}}class B{constructor(){this._modelViewProj=r(),this._clipPosition=[a(),a(),a(),a(),a(),a(),a(),a()]}unionDepthRangeWithAABB(e,r,n,i){const s=this._modelViewProj;t(s,r,n);let a=!1;for(let t=0;t<8;++t){const e=this._clipPosition[t],r=0===t||3===t||4===t||7===t?i[0]:i[3],n=0===t||1===t||4===t||5===t?i[1]:i[4],a=t<4?i[2]:i[5];e[0]=s[0]*r+s[4]*n+s[8]*a+s[12],e[1]=s[1]*r+s[5]*n+s[9]*a+s[13],e[2]=s[2]*r+s[6]*n+s[10]*a+s[14],e[3]=s[3]*r+s[7]*n+s[11]*a+s[15]}for(let t=0;t<12;++t){const r=I(this._clipPosition[A[t][0]],this._clipPosition[A[t][1]],this._clipPosition[A[t][2]]);let n=!0;for(let e=0;e<r.length;++e){if(r[e][3]>=2){n=!1;break}}if(!n){a=!0;for(let t=0;t<r.length;++t){const n=r[t][3];Number.isFinite(n)&&(e.near=Math.min(n,e.near),e.far=Math.max(n,e.far))}}}return a}}function I(e,t,r){let n=[e,t,r];for(let i=0;i<4;++i){const e=n;n=[];for(let t=0;t<e.length;++t){const r=e[t],s=e[(t+1)%e.length];P(s,i)?(P(r,i)||n.push(y(r,s,i)),n.push(s)):P(r,i)&&n.push(y(r,s,i))}}return n}function P(e,t){return 0===t?e[0]>=-e[3]:1===t?e[1]>=-e[3]:2===t?e[0]<=e[3]:3===t?e[1]<=e[3]:void u(!1)}function y(e,t,r){let n=0;return 0===r?n=(-e[3]-e[0])/(t[0]-e[0]+t[3]-e[3]):1===r?n=(-e[3]-e[1])/(t[1]-e[1]+t[3]-e[3]):2===r?n=(e[3]-e[0])/(t[0]-e[0]-t[3]+e[3]):3===r&&(n=(e[3]-e[1])/(t[1]-e[1]-t[3]+e[3])),s(a(),e,t,n)}const A=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],D=new h,E=r(),S=new c,F=new M,W=new C,N=new B;export{p as depthRangeFromScene};
2
+ import e from"../../../../core/PooledArray.js";import{multiply as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{transformMat4Z as n,transformMat4 as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{lerp as s}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as o}from"../../../../geometry/support/frustumPlanes.js";import{Sphere as h}from"../../../../geometry/support/sphere.js";import{maxScale as f}from"../../support/mathUtils.js";import{DepthRange as c}from"./DepthRange.js";import{assert as u}from"./Util.js";const l=1e4,d=100,m=500,_=500,g=.1;function p(e,t,r,n){let i=0;if(!t.some(e=>!!e.material&&(i+=e.numGeometries,i>=l)))return W.compute(e,t,n);const s=new c;return r.forEach(t=>s.union(b(e,t))),s}function b(e,t){if(!t.visible)return;const r=new c,n=t.getSpatialQueryAccelerator();return n?w(r,e,n):j(r,e,t.objects),r}function w(e,t,r){const{eye:n,viewForward:i,frustum:s}=t,a=e=>e.visible,o=r.objectCount;if(o<m)S.set(t.near,Math.min(e.near,t.far)),r.forEachInDepthRange(n,i,1,S,(r,n)=>{x(e,t,r),S.far=e.near,n.setRange(S)},s,a),S.set(Math.max(e.far,t.near),t.far),r.forEachInDepthRange(n,i,-1,S,(r,n)=>{x(e,t,r),S.near=e.far,n.setRange(S)},s,a);else{const n=Math.max(Math.min(o,_),Math.ceil(o*g)),h=r.findClosest(i,1,s,a,n),f=r.findClosest(i,-1,s,a,n);h&&f&&(v(e,t,h.boundingVolumeWorldSpace.bounds),v(e,t,f.boundingVolumeWorldSpace.bounds))}}function j(e,t,r){F.clear(),r.forEach(e=>{e.visible&&0!==e.geometries.length&&F.add(e,t)}),F.empty||(F.sort(),S.set(t.near,Math.min(e.near,t.far)),F.forEachInDepthRange(S,1,(r,n)=>{n<e.near&&x(e,t,r)}),S.set(Math.max(e.far,t.near),t.far),F.forEachInDepthRange(S,-1,(t,r,n)=>{e.far=Math.max(e.far,n)}))}function x(e,r,n){if(!n.visible)return;if(!o(r.frustum,n.boundingVolumeWorldSpace.bounds))return;const i=n.transformation,s=E;n.geometries.forEach(n=>{t(s,i,n.transformation);const a=f(s);R(e,r,n.boundingInfo,s,a)})}function R(e,t,r,n,s){if(null==r)return;i(D.center,r.sphere.center,n);const{eye:a,viewForward:h}=t,f=h[0]*(D.center[0]-a[0])+h[1]*(D.center[1]-a[1])+h[2]*(D.center[2]-a[2]);if(D.radius=r.sphere.radius*s,!(f-D.radius>e.near&&f+D.radius<e.far)&&o(t.frustum,D))if(r.sphere.radius>d&&r.children)for(const i of r.children)R(e,t,i,n,s);else N.unionDepthRangeWithAABB(e,t.viewProjectionMatrix,n,r.box)}function v(e,t,r){const n=t.eye,i=t.viewForward,s=(r.center[0]-n[0])*i[0]+(r.center[1]-n[1])*i[1]+(r.center[2]-n[2])*i[2];e.near=Math.min(e.near,s-r.radius),e.far=Math.max(e.far,s+r.radius)}class M{constructor(){this._items=new e({allocator:e=>e||{object:null,distance:0,near:0,far:0},deallocator:e=>(e.object=null,e.distance=0,e.near=0,e.far=0,e)})}get length(){return this._items.length}get empty(){return 0===this._items.length}clear(){this._items.clear()}add(e,t){const r=t.eye,n=t.viewForward,i=e.boundingVolumeWorldSpace.bounds,s=(i.center[0]-r[0])*n[0]+(i.center[1]-r[1])*n[1]+(i.center[2]-r[2])*n[2];if(!Number.isFinite(s))return;const a=this._items.pushNew();a.object=e,a.distance=s,a.near=s-i.radius,a.far=s+i.radius}sort(){this._items.sort((e,t)=>e.distance-t.distance)}forEachInDepthRange(e,t,r){if(1===t)for(let n=0;n<this._items.length;++n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}else for(let n=this._items.length-1;n>=0;--n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}}}class C{constructor(){this._geometries=new Array,this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange=new c(0,0)}compute(e,t,r){this._reset();const{viewMatrix:i}=e;t.forEach(e=>{e.forEachGeometry(e=>{if(!e.visible||0===r&&!e.castShadow)return;const t=e.boundingSphere,s=n(t.center,i),a=s-t.radius,o=s+t.radius;this._geometries.push(e),this._near.push(-o),this._far.push(-a)})});const s=new c;if(0===this._geometries.length)return s;for(let n=0;n<this._geometries.length;++n)this._near[n]>s.far&&(s.far=this._near[n]),this._near[n]>2&&this._far[n]<s.near&&(s.near=this._far[n]);const a=this._looseRange;a.near=Math.max(.5*s.near,2),a.far=2*s.far;let o=0,h=0;for(let n=0;n<this._geometries.length;++n)this._near[n]<s.near&&(this._near[n]>=a.near?s.near=this._near[n]:this._nearCandidates[o++]=n),this._far[n]>s.far&&(this._far[n]<=a.far?s.far=this._far[n]:this._farCandidates[h++]=n);if(0===this._nearCandidates.length&&0===this._farCandidates.length)return s;this._nearCandidates.sort((e,t)=>this._near[e]<this._near[t]?-1:this._near[e]>this._near[t]?1:0),this._farCandidates.sort((e,t)=>this._far[e]<this._far[t]?1:this._far[e]>this._far[t]?-1:0);for(let n=0;n<this._nearCandidates.length;++n){const t=this._nearCandidates[n];if(this._near[t]<s.near){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:i}=r;this._includeNearBoundingInfoRec(e,n,i,s)}}for(let n=0;n<this._farCandidates.length;++n){const t=this._farCandidates[n];if(this._far[t]>s.far){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:i}=r;this._includeFarBoundingInfoRec(e,n,i,s)}}return this._reset(),s}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_isOutsideSidePlanes(e,t){const{center:r,radius:n}=e;return t[0][0]*r[0]+t[0][1]*r[1]+t[0][2]*r[2]+t[0][3]>n||t[1][0]*r[0]+t[1][1]*r[1]+t[1][2]*r[2]+t[1][3]>n||t[2][0]*r[0]+t[2][1]*r[1]+t[2][2]*r[2]+t[2][3]>n||t[3][0]*r[0]+t[3][1]*r[1]+t[3][2]*r[2]+t[3][3]>n}_includeNearBoundingInfoRec(e,t,r,s){if(null==t)return;i(D.center,t.sphere.center,r),D.radius=t.sphere.radius*f(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(D,a))return;const o=D.radius,{viewMatrix:h}=e,c=n(D.center,h),u=c+o;if(!(-(c-o)<2||-u>=s.near))if(-u>this._looseRange.near)s.near=-u;else{if(o>d){const n=t.children;if(void 0!==n){for(const t of n)this._includeNearBoundingInfoRec(e,t,r,s);return}}N.unionDepthRangeWithAABB(s,e.viewProjectionMatrix,r,t.box)}}_includeFarBoundingInfoRec(e,t,r,s){if(null==t)return;i(D.center,t.sphere.center,r),D.radius=t.sphere.radius*f(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(D,a))return;const{viewMatrix:o,viewProjectionMatrix:h}=e,c=n(D.center,o)-D.radius;if(!(-c<=s.far))if(-c<this._looseRange.far)s.far=-c;else{if(D.radius>d){const n=t.children;if(void 0!==n){for(const t of n)this._includeFarBoundingInfoRec(e,t,r,s);return}}N.unionDepthRangeWithAABB(s,h,r,t.box)}}}class P{constructor(){this._modelViewProj=r(),this._clipPosition=[a(),a(),a(),a(),a(),a(),a(),a()]}unionDepthRangeWithAABB(e,r,n,i){const s=this._modelViewProj;t(s,r,n);let a=!1;for(let t=0;t<8;++t){const e=this._clipPosition[t],r=0===t||3===t||4===t||7===t?i[0]:i[3],n=0===t||1===t||4===t||5===t?i[1]:i[4],a=t<4?i[2]:i[5];e[0]=s[0]*r+s[4]*n+s[8]*a+s[12],e[1]=s[1]*r+s[5]*n+s[9]*a+s[13],e[2]=s[2]*r+s[6]*n+s[10]*a+s[14],e[3]=s[3]*r+s[7]*n+s[11]*a+s[15]}for(let t=0;t<12;++t){const r=B(this._clipPosition[A[t][0]],this._clipPosition[A[t][1]],this._clipPosition[A[t][2]]);let n=!0;for(let e=0;e<r.length;++e){if(r[e][3]>=2){n=!1;break}}if(!n){a=!0;for(let t=0;t<r.length;++t){const n=r[t][3];Number.isFinite(n)&&(e.near=Math.min(n,e.near),e.far=Math.max(n,e.far))}}}return a}}function B(e,t,r){let n=[e,t,r];for(let i=0;i<4;++i){const e=n;n=[];for(let t=0;t<e.length;++t){const r=e[t],s=e[(t+1)%e.length];I(s,i)?(I(r,i)||n.push(y(r,s,i)),n.push(s)):I(r,i)&&n.push(y(r,s,i))}}return n}function I(e,t){return 0===t?e[0]>=-e[3]:1===t?e[1]>=-e[3]:2===t?e[0]<=e[3]:3===t?e[1]<=e[3]:void u(!1)}function y(e,t,r){let n=0;return 0===r?n=(-e[3]-e[0])/(t[0]-e[0]+t[3]-e[3]):1===r?n=(-e[3]-e[1])/(t[1]-e[1]+t[3]-e[3]):2===r?n=(e[3]-e[0])/(t[0]-e[0]-t[3]+e[3]):3===r&&(n=(e[3]-e[1])/(t[1]-e[1]-t[3]+e[3])),s(a(),e,t,n)}const A=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],D=new h,E=r(),S=new c,F=new M,W=new C,N=new P;export{p as depthRangeFromScene};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{isPromiseLike as t}from"../../../../core/promiseUtils.js";import{createScreenPointArray as r}from"../../../../core/screenUtils.js";import{copy as e,add as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import n from"../../../../geometry/SpatialReference.js";import{expandWithNestedArray as s,create as i,negativeInfinity as l}from"../../../../geometry/support/aaBoundingRect.js";import{create as c,computePlanes as a,createPoints as u}from"../../../../geometry/support/frustum.js";import{create as m}from"../../../../geometry/support/ray.js";import{fromScreen as p}from"../../support/geometryUtils/ray.js";import{ScreenPolygonIntersectionQuery as f,ScreenPolygonTessellation as g}from"./IntersectorInterfaces.js";async function y(t,r){const e=j(r);if(null==e)return null;const o=s(i(l),e),n=h(t,o);return null==n?null:await f.create(e,o,n,()=>w(e))}function j(t){const e=new Array;for(const o of t){const t=e[e.length-1];null!=t&&t[0]===o[0]&&t[1]===o[1]||e.push(r(o[0],o[1]))}if(e.length>1){const t=e[0],r=e[e.length-1];t[0]===r[0]&&t[1]===r[1]&&e.pop()}return e.length<3?null:e}function h(t,n){const s=[r(n[0],n[3]),r(n[2],n[3]),r(n[2],n[1]),r(n[0],n[1])],i=u();for(let r=0;r<s.length;r++){const n=p(t,s[r],R);if(null==n)return null;e(i[r],n.origin),o(i[r+4],n.origin,n.direction)}const l=c();return a(l,i),l}const d=(()=>{let t;return async()=>await(t??=import("../../layers/graphics/tessellationUtils.js"))})();async function w(r){const{ringsToOutlinedTessellationInfo:e,tessellateOrLoad:o}=await d(),s=e([r],{hasZ:!1,ccwRingsAsHoles:!1,spatialReference:n.WebMercator});let i=o(s);if(t(i)&&(await i,i=o(s)),t(i)||!i.succeeded)return null;const{positions:l,indices:c,vertexCount:a}=i;return new g(l,c,a)}const R=m();export{y as prepareScreenPolygonIntersectionQuery};
2
+ import{isPromiseLike as t}from"../../../../core/promiseUtils.js";import{createScreenPointArray as r}from"../../../../core/screenUtils.js";import{copy as e,add as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import n from"../../../../geometry/SpatialReference.js";import{expandWithNestedArray as s,create as i,negativeInfinity as l}from"../../../../geometry/support/aaBoundingRect.js";import{create as c,computePlanes as a,createPoints as u}from"../../../../geometry/support/frustumPlanes.js";import{create as m}from"../../../../geometry/support/ray.js";import{fromScreen as p}from"../../support/geometryUtils/ray.js";import{ScreenPolygonIntersectionQuery as f,ScreenPolygonTessellation as g}from"./IntersectorInterfaces.js";async function y(t,r){const e=j(r);if(null==e)return null;const o=s(i(l),e),n=h(t,o);return null==n?null:await f.create(e,o,n,()=>w(e))}function j(t){const e=new Array;for(const o of t){const t=e[e.length-1];null!=t&&t[0]===o[0]&&t[1]===o[1]||e.push(r(o[0],o[1]))}if(e.length>1){const t=e[0],r=e[e.length-1];t[0]===r[0]&&t[1]===r[1]&&e.pop()}return e.length<3?null:e}function h(t,n){const s=[r(n[0],n[3]),r(n[2],n[3]),r(n[2],n[1]),r(n[0],n[1])],i=u();for(let r=0;r<s.length;r++){const n=p(t,s[r],R);if(null==n)return null;e(i[r],n.origin),o(i[r+4],n.origin,n.direction)}const l=c();return a(l,i),l}const d=(()=>{let t;return async()=>await(t??=import("../../layers/graphics/tessellationUtils.js"))})();async function w(r){const{ringsToOutlinedTessellationInfo:e,tessellateOrLoad:o}=await d(),s=e([r],{hasZ:!1,ccwRingsAsHoles:!1,spatialReference:n.WebMercator});let i=o(s);if(t(i)&&(await i,i=o(s)),t(i)||!i.succeeded)return null;const{positions:l,indices:c,vertexCount:a}=i;return new g(l,c,a)}const R=m();export{y as prepareScreenPolygonIntersectionQuery};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import t from"../../../../core/PooledArray.js";import{createScreenPointArray as e}from"../../../../core/screenUtils.js";import{distance as r,copy as o,set as i,transformMat4 as n,squaredDistance as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as a,create as u}from"../../../../geometry/support/aaBoundingBox.js";import{intersectsTransformedAabb as c}from"../../../../geometry/support/frustum.js";import{clipPolygon as m}from"../../../../geometry/support/plane.js";import{normalFromValues as f,closestPointFromValues as p}from"../../../../geometry/support/triangle.js";import{boundingInfoSubdivisionThreshold as d}from"./intersectionConstants.js";import{screenPolygonIntersectsTriangle as h}from"./screenPolygonOverlapUtils.js";class I{constructor(t){this.primitiveIndex=t}}class g{constructor(t){this.type=t,this.distance=Number.POSITIVE_INFINITY,this.primitiveIndex=0,this.hasNormal=!1,this.point=l(),this.normal=l()}reset(){this.distance=Number.POSITIVE_INFINITY,this.hasNormal=!1}update(t,e,r,i){this.distance=t,this.primitiveIndex=e,o(this.point,r),this.hasNormal=null!=i,null!=i&&o(this.normal,i)}updateIfCloserFromValues(t,e,r,o){t<this.distance&&this.update(t,e,r,o)}updateIfCloser(t){const{distance:e,primitiveIndex:r,point:o,normal:i}=t;this.updateIfCloserFromValues(e,r,o,t.hasNormal?i:null)}get valid(){return Number.isFinite(this.distance)}}function y(t,e,r,o,i){if(!t.visible)return null;const n=new g(4);let s;s=t.boundingInfo?b(t.readPrimitivePosition,t.boundingInfo,e,r,o,i):v(e,r,o,0,t.faceCount,t.readPrimitivePosition,i,null,0);for(const l of s)n.updateIfCloser(l);return n.valid?n:null}function*v(t,e,o,i,n,s,l,a=null,u=0){if(null==t.camera)return;const{camera:c,screenPolygonPrimitiveProcessor:p}=t;for(let d=i;d<n;++d){const t=(a?.[d]??d)+u,i=null==a?t:d,n=3*t;N(F[0],s,n+0,l,i,e),N(F[1],s,n+1,l,i,e),N(F[2],s,n+2,l,i,e);const h=O;let I;A.reset();const g=C;for(const e of p.processTriangle(F))if(g.length=0,m(c.frustum[4],e,()=>g.pushNew(),!1),!(g.length<3)){for(let t=0;t<g.length;t++)c.projectToScreen(g.at(t),V[t]);P(o,V,g.length)&&(j(c.eye,g,w),null==I&&(I=f(O,F[0],F[1],F[2])),A.updateIfCloserFromValues(r(c.eye,w),t,w,I?h:null))}A.valid&&(yield A)}}function*b(t,e,r,o,i,n){let s;if(null!=n?(a(x,e.box),n.applyToAabb(x),s=c(i.broadPhaseFrustum,x,o)):s=c(i.broadPhaseFrustum,e.box,o),!s)return;const{primitiveIndices:l}=e,u=l.length;if(u>d){const s=e.children;if(void 0!==s){for(const e of s)yield*b(t,e,r,o,i,n);return}}yield*v(r,o,i,0,u,t,n,l,0)}function N(t,e,r,o,s,l){const[a,u,c]=e(t,r);null!=o?o.applyToVertex(t,a,u,c,s):i(t,a,u,c),l&&n(t,t,l)}function P(t,e,r){for(let o=1;o<r-1;o++)if(h(t,e[0],e[o],e[o+1]))return!0;return!1}function j(t,e,r){let i=Number.POSITIVE_INFINITY;const n=e.at(0);for(let l=1;l<e.length-1;l++){p(S,t,n,e.at(l),e.at(l+1));const a=s(t,S);a<i&&(i=a,o(r,S))}}const x=u(),T=12,F=[l(),l(),l()],C=new t({allocator:t=>t??l()}),V=Array.from({length:T},()=>e()),w=l(),O=l(),S=l(),A=new g(4);export{I as DrapedHit,g as Hit,v as forEachTriangleRangeScreenPolygonHit,y as intersectTriangleGeometryScreenPolygon};
2
+ import t from"../../../../core/PooledArray.js";import{createScreenPointArray as e}from"../../../../core/screenUtils.js";import{distance as r,copy as o,set as i,transformMat4 as n,squaredDistance as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as a,create as u}from"../../../../geometry/support/aaBoundingBox.js";import{intersectsTransformedAabb as c}from"../../../../geometry/support/frustumPlanes.js";import{clipPolygon as m}from"../../../../geometry/support/plane.js";import{normalFromValues as f,closestPointFromValues as p}from"../../../../geometry/support/triangle.js";import{boundingInfoSubdivisionThreshold as d}from"./intersectionConstants.js";import{screenPolygonIntersectsTriangle as h}from"./screenPolygonOverlapUtils.js";class I{constructor(t){this.primitiveIndex=t}}class g{constructor(t){this.type=t,this.distance=Number.POSITIVE_INFINITY,this.primitiveIndex=0,this.hasNormal=!1,this.point=l(),this.normal=l()}reset(){this.distance=Number.POSITIVE_INFINITY,this.hasNormal=!1}update(t,e,r,i){this.distance=t,this.primitiveIndex=e,o(this.point,r),this.hasNormal=null!=i,null!=i&&o(this.normal,i)}updateIfCloserFromValues(t,e,r,o){t<this.distance&&this.update(t,e,r,o)}updateIfCloser(t){const{distance:e,primitiveIndex:r,point:o,normal:i}=t;this.updateIfCloserFromValues(e,r,o,t.hasNormal?i:null)}get valid(){return Number.isFinite(this.distance)}}function y(t,e,r,o,i){if(!t.visible)return null;const n=new g(4);let s;s=t.boundingInfo?b(t.readPrimitivePosition,t.boundingInfo,e,r,o,i):v(e,r,o,0,t.faceCount,t.readPrimitivePosition,i,null,0);for(const l of s)n.updateIfCloser(l);return n.valid?n:null}function*v(t,e,o,i,n,s,l,a=null,u=0){if(null==t.camera)return;const{camera:c,screenPolygonPrimitiveProcessor:p}=t;for(let d=i;d<n;++d){const t=(a?.[d]??d)+u,i=null==a?t:d,n=3*t;N(F[0],s,n+0,l,i,e),N(F[1],s,n+1,l,i,e),N(F[2],s,n+2,l,i,e);const h=O;let I;A.reset();const g=C;for(const e of p.processTriangle(F))if(g.length=0,m(c.frustum[4],e,()=>g.pushNew(),!1),!(g.length<3)){for(let t=0;t<g.length;t++)c.projectToScreen(g.at(t),V[t]);P(o,V,g.length)&&(j(c.eye,g,w),null==I&&(I=f(O,F[0],F[1],F[2])),A.updateIfCloserFromValues(r(c.eye,w),t,w,I?h:null))}A.valid&&(yield A)}}function*b(t,e,r,o,i,n){let s;if(null!=n?(a(x,e.box),n.applyToAabb(x),s=c(i.broadPhaseFrustum,x,o)):s=c(i.broadPhaseFrustum,e.box,o),!s)return;const{primitiveIndices:l}=e,u=l.length;if(u>d){const s=e.children;if(void 0!==s){for(const e of s)yield*b(t,e,r,o,i,n);return}}yield*v(r,o,i,0,u,t,n,l,0)}function N(t,e,r,o,s,l){const[a,u,c]=e(t,r);null!=o?o.applyToVertex(t,a,u,c,s):i(t,a,u,c),l&&n(t,t,l)}function P(t,e,r){for(let o=1;o<r-1;o++)if(h(t,e[0],e[o],e[o+1]))return!0;return!1}function j(t,e,r){let i=Number.POSITIVE_INFINITY;const n=e.at(0);for(let l=1;l<e.length-1;l++){p(S,t,n,e.at(l),e.at(l+1));const a=s(t,S);a<i&&(i=a,o(r,S))}}const x=u(),T=12,F=[l(),l(),l()],C=new t({allocator:t=>t??l()}),V=Array.from({length:T},()=>e()),w=l(),O=l(),S=l(),A=new g(4);export{I as DrapedHit,g as Hit,v as forEachTriangleRangeScreenPolygonHit,y as intersectTriangleGeometryScreenPolygon};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import a from"../../../../core/Collection.js";import{getOrCreateMapValue as n}from"../../../../core/MapUtils.js";import r from"../../../../core/ReactiveMap.js";import{watch as i}from"../../../../core/reactiveUtils.js";import{createScreenPoint as o}from"../../../../core/screenUtils.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{DrawManipulator as p}from"../../DrawManipulator.js";import{InteractiveHandle as d}from"../InteractiveHandle.js";import{ManipulatorCollection as u}from"../../../interactive/ManipulatorCollection.js";const c=Symbol("manipulator-handle-watch");let h=class extends t{constructor(e){super(e),this._pluginConstraintRegistry=new r,this._pluginHandleRegistry=new r,this._handleManipulatorMap=new a,this.renderer=null,this.manipulators=new u,this.view=null,this.capturingHandle=null}initialize(){super.initialize()}destroy(){this._pluginConstraintRegistry.clear(),this._pluginHandleRegistry.forEach(e=>e.drain(e=>e.destroy())),this._pluginHandleRegistry.clear(),this._handleManipulatorMap.removeAll()}get customConstraints(){return Array.from(this._pluginConstraintRegistry.values()).flatMap(e=>Array.from(e.values()))}get focusedHandle(){return this.capturingHandle??this._handleManipulatorMap.find(({handle:e,manipulator:t})=>e.dragging||t.grabbing||t.selected||t.hovering)?.handle}get handleCount(){return this._handleManipulatorMap.length}get allhandles(){return this._handleManipulatorMap.map(({handle:e})=>e).toArray()}cycleManipulator(e){const{capturingHandle:t,_handleManipulatorMap:a}=this;if(!t)return void this.followHandle(a.at(0)?.handle);const n=a.findIndex(({handle:e})=>e===t),r="forward"===e?n+1:n-1;this.followHandle(a.at(r%a.length)?.handle)}toggleFollow(){const e=this.capturingHandle;if(e)return this.releaseHandle(e),!0;const t=this._handleManipulatorMap.find(e=>"grabbable-object"!==e.handle.defaultCaptureMode)?.handle;return!!t&&(this.followHandle(t),!0)}shouldCaptureInput(e=null,t=null){const a=this.capturingHandle;return!a||(null==e||null==a.activePointerId||a.activePointerId===e)&&("touch"!==t||"pen"!==a.activePointerType)}notePointerDown(e=null,t=null){this.shouldCaptureInput(e,t)&&this.capturingHandle?.notePointerDown(e,t)}notePointerUp(e=null,t=null){this.capturingHandle?.notePointerUp(e,t)}releaseHandle(e){e&&(e.captureMode="grabbable-object",e.drawToolDragging=!1),e&&e!==this.capturingHandle||(this.capturingHandle&&(this.capturingHandle.drawToolDragging=!1,this.capturingHandle.captureMode="grabbable-object"),this.capturingHandle=null)}followHandle(e){this._handleManipulatorMap.forEach(({handle:e})=>{"grabbable-object"!==e.captureMode&&(e.captureMode="grabbable-object")}),e&&(e.captureMode="grabbable-object"===e.defaultCaptureMode?"capture-always":e.defaultCaptureMode),"grabbable-object"!==e?.captureMode&&(this.capturingHandle=e)}findHandleByManipulator(e,t){let a=null,n=Number.MAX_VALUE;return this._handleManipulatorMap.forEach(({handle:r,manipulator:i})=>{if("grabbable-object"!==r.captureMode||!i.interactive)return;const o=i.intersectionDistance(e,t);null!=o&&o<n&&(n=o,a=r)}),a}findHandleDragging(){return this._handleManipulatorMap.find(({handle:e})=>e.dragging)?.handle}async setupManipulatorForHandle(e,t,a){const{view:n}=this,{surfaceManager:r}=a,l=a.editGeometryOperations?.data.coordinateHelper;if(!n||!r||!l)return;const s=await this._createManipulator(n,this.renderer,e);this._handleManipulatorMap.push({handle:e,manipulator:s}),this.manipulators.add(s),e.addHandles([i(()=>s.dragging,t=>{e.manipulatorDragging=t,t||this.releaseHandle(e)})],c),e.following&&(this.capturingHandle=e);const p=(e.inputMapPosition&&r.mapToScreen(e.inputMapPosition,{firstPointZ:e.firstPointZ}))??e.screenPosition??t??o(n?.width/2,n.height/2);await(e?.moveTo(p,{...a,pointerType:"mouse"}))}removeManipulatorForHandle(e){const t=this._handleManipulatorMap.find(t=>t.handle===e);t&&(this.manipulators.remove(t.manipulator),this._handleManipulatorMap.remove(t),t.manipulator.destroy()),e.removeHandles(c)}registerHandle(e,t){const r=n(this._pluginHandleRegistry,e,()=>new a),i=new d(t);return r.push(i),i}unregisterHandle(e,t){const a=this._pluginHandleRegistry.get(e);a&&(t?(a.remove(t),this.removeManipulatorForHandle(t),t.destroy()):(a.drain(e=>{this.removeManipulatorForHandle(e),e.destroy()}),this._pluginHandleRegistry.delete(e)))}registerCustomConstraint(e,t,a){n(this._pluginConstraintRegistry,e,()=>new r).set(t,a)}unregisterCustomConstraint(e,t){t?this._pluginConstraintRegistry.get(e)?.delete(t):(this._pluginConstraintRegistry.get(e)?.clear(),this._pluginConstraintRegistry.delete(e))}replaceEditSessions(e,t){const a=this._pluginHandleRegistry.get(e);if(a)for(const n of a)n.editSession=t}updateAllScreenPositions(e=null){const{view:t}=this;this._handleManipulatorMap.forEach(({handle:a})=>{const n=a.outputMapPosition;n&&(a.screenPosition=e?.mapToScreen(n,{firstPointZ:a.firstPointZ})??t?.toScreen(n))})}reapplyPositions(e){this._handleManipulatorMap.forEach(({handle:t})=>t.refreshConstraint(e))}async _createManipulator(e,t,a){if("3d"===e.type){const{DrawManipulator3D:n}=await(import("../../DrawManipulator3D.js"));return new n({view:e,renderer:t,managedHandle:a})}return new p({renderer:t,managedHandle:a})}};e([l({constructOnly:!0})],h.prototype,"renderer",void 0),e([l({readOnly:!0})],h.prototype,"manipulators",void 0),e([l({constructOnly:!0})],h.prototype,"view",void 0),e([l()],h.prototype,"capturingHandle",void 0),e([l()],h.prototype,"customConstraints",null),e([l()],h.prototype,"focusedHandle",null),e([l()],h.prototype,"handleCount",null),e([l()],h.prototype,"allhandles",null),h=e([s("esri.views.draw.support.managers.InteractiveHandleManager")],h);export{h as InteractiveHandleManager};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import n from"../../../../core/Collection.js";import{getOrCreateMapValue as a}from"../../../../core/MapUtils.js";import r from"../../../../core/ReactiveMap.js";import{watch as i}from"../../../../core/reactiveUtils.js";import{createScreenPoint as o}from"../../../../core/screenUtils.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{DrawManipulator as p}from"../../DrawManipulator.js";import{InteractiveHandle as d}from"../InteractiveHandle.js";import{ManipulatorCollection as u}from"../../../interactive/ManipulatorCollection.js";const c=Symbol("manipulator-handle-watch");let h=class extends t{constructor(e){super(e),this._pluginConstraintRegistry=new r,this._pluginHandleRegistry=new r,this._handleManipulatorMap=new n,this.renderer=null,this.manipulators=new u,this.view=null,this.capturingHandle=null}initialize(){super.initialize()}destroy(){this._pluginConstraintRegistry.clear(),this._pluginHandleRegistry.forEach(e=>e.drain(e=>e.destroy())),this._pluginHandleRegistry.clear(),this._handleManipulatorMap.removeAll()}get customConstraints(){return Array.from(this._pluginConstraintRegistry.values()).flatMap(e=>Array.from(e.values()))}get focusedHandle(){return this.capturingHandle??this._handleManipulatorMap.find(({handle:e,manipulator:t})=>e.dragging||t.grabbing||t.selected||t.hovering)?.handle}get handleCount(){return this._handleManipulatorMap.length}get allhandles(){return this._handleManipulatorMap.map(({handle:e})=>e).toArray()}cycleManipulator(e){const{capturingHandle:t,_handleManipulatorMap:n}=this;if(!t)return void this.followHandle(n.at(0)?.handle);const a=n.findIndex(({handle:e})=>e===t),r="forward"===e?a+1:a-1;this.followHandle(n.at(r%n.length)?.handle)}toggleFollow(){const e=this.capturingHandle;if(e)return this.releaseHandle(e),!0;const t=this._handleManipulatorMap.find(e=>"grabbable-object"!==e.handle.defaultCaptureMode)?.handle;return!!t&&(this.followHandle(t),!0)}shouldCaptureInput(e=null,t=null){const n=this.capturingHandle;return!n||(null==e||null==n.activePointerId||n.activePointerId===e)&&("touch"!==t||"pen"!==n.activePointerType)}notePointerDown(e=null,t=null){this.shouldCaptureInput(e,t)&&this.capturingHandle?.notePointerDown(e,t)}notePointerUp(e=null,t=null){this.capturingHandle?.notePointerUp(e,t)}releaseHandle(e){e&&(e.captureMode="grabbable-object",e.drawToolDragging=!1),e&&e!==this.capturingHandle||(this.capturingHandle&&(this.capturingHandle.drawToolDragging=!1,this.capturingHandle.captureMode="grabbable-object"),this.capturingHandle=null)}followHandle(e){this._handleManipulatorMap.forEach(({handle:e})=>{"grabbable-object"!==e.captureMode&&(e.captureMode="grabbable-object")}),e&&(e.captureMode="grabbable-object"===e.defaultCaptureMode?"capture-always":e.defaultCaptureMode),"grabbable-object"!==e?.captureMode&&(this.capturingHandle=e)}findHandleByManipulator(e,t){let n=null,a=Number.MAX_VALUE;return this._handleManipulatorMap.forEach(({handle:r,manipulator:i})=>{if("grabbable-object"!==r.captureMode||!i.interactive)return;const o=i.intersectionDistance(e,t);null!=o&&o<a&&(a=o,n=r)}),n}findHandleDragging(){return this._handleManipulatorMap.find(({handle:e})=>e.dragging)?.handle}async setupManipulatorForHandle(e,t,n){const{view:a}=this,{surfaceManager:r}=n,l=n.editGeometryOperations?.data.coordinateHelper;if(!a||!r||!l)return;const s=await this._createManipulator(a,this.renderer,e);if(this.destroyed||e.destroyed)return void s.destroy();this._handleManipulatorMap.push({handle:e,manipulator:s}),this.manipulators.add(s),e.addHandles([i(()=>s.dragging,t=>{e.manipulatorDragging=t,t||this.releaseHandle(e)})],c),e.following&&(this.capturingHandle=e);const p=(e.inputMapPosition&&r.mapToScreen(e.inputMapPosition,{firstPointZ:e.firstPointZ}))??e.screenPosition??t??o(a?.width/2,a.height/2);await(e?.moveTo(p,{...n,pointerType:"mouse"}))}removeManipulatorForHandle(e){const t=this._handleManipulatorMap.find(t=>t.handle===e);t&&(this.manipulators.remove(t.manipulator),this._handleManipulatorMap.remove(t),t.manipulator.destroy()),e.removeHandles(c)}registerHandle(e,t){const r=a(this._pluginHandleRegistry,e,()=>new n),i=new d(t);return r.push(i),i}unregisterHandle(e,t){const n=this._pluginHandleRegistry.get(e);n&&(t?(n.remove(t),this.removeManipulatorForHandle(t),t.destroy()):(n.drain(e=>{this.removeManipulatorForHandle(e),e.destroy()}),this._pluginHandleRegistry.delete(e)))}registerCustomConstraint(e,t,n){a(this._pluginConstraintRegistry,e,()=>new r).set(t,n)}unregisterCustomConstraint(e,t){t?this._pluginConstraintRegistry.get(e)?.delete(t):(this._pluginConstraintRegistry.get(e)?.clear(),this._pluginConstraintRegistry.delete(e))}replaceEditSessions(e,t){const n=this._pluginHandleRegistry.get(e);if(n)for(const a of n)a.editSession=t}updateAllScreenPositions(e=null){const{view:t}=this;this._handleManipulatorMap.forEach(({handle:n})=>{const a=n.outputMapPosition;a&&(n.screenPosition=e?.mapToScreen(a,{firstPointZ:n.firstPointZ})??t?.toScreen(a))})}reapplyPositions(e){this._handleManipulatorMap.forEach(({handle:t})=>t.refreshConstraint(e))}async _createManipulator(e,t,n){if("3d"===e.type){const{DrawManipulator3D:a}=await(import("../../DrawManipulator3D.js"));return new a({view:e,renderer:t,managedHandle:n})}return new p({renderer:t,managedHandle:n})}};e([l({constructOnly:!0})],h.prototype,"renderer",void 0),e([l({readOnly:!0})],h.prototype,"manipulators",void 0),e([l({constructOnly:!0})],h.prototype,"view",void 0),e([l()],h.prototype,"capturingHandle",void 0),e([l()],h.prototype,"customConstraints",null),e([l()],h.prototype,"focusedHandle",null),e([l()],h.prototype,"handleCount",null),e([l()],h.prototype,"allhandles",null),h=e([s("esri.views.draw.support.managers.InteractiveHandleManager")],h);export{h as InteractiveHandleManager};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{set as e,length as t,scale as i}from"../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{FilteredFiniteDifference as r}from"./FilteredFiniteDifference.js";import{Momentum as n}from"./Momentum.js";class c extends n{constructor(e,t,i,s,r){super(e,t,i),this._sceneVelocity=s,this.direction=r}value(e){return super.valueFromInitialVelocity(this._sceneVelocity,e)}}class l{constructor(e=300,t=12,i=.84){this._minimumInitialVelocity=e,this._stopVelocity=t,this._friction=i,this._time=new r(.6),this._screen=[new r(.4),new r(.4)],this._scene=[new r(.6),new r(.6),new r(.6)],this._tmpDirection=s()}update(e,t,i){if(this._time.hasLastValue()){if(this._time.computeDelta(i)<.015)return}this._screen[0].update(e[0]),this._screen[1].update(e[1]),this._scene[0].update(t[0]),this._scene[1].update(t[1]),this._scene[2].update(t[2]),this._time.update(i)}reset(){this._screen[0].reset(),this._screen[1].reset(),this._scene[0].reset(),this._scene[1].reset(),this._scene[2].reset(),this._time.reset()}createMomentum(){if(!this._screen[0].hasFilteredDelta()||!this._time.hasFilteredDelta())return null;const e=this._screen[0].filteredDelta,t=this._screen[1].filteredDelta,i=null==e||null==t?0:Math.sqrt(e*e+t*t),s=this._time.filteredDelta,r=null==s||0===s?0:i/s;return Math.abs(r)<this._minimumInitialVelocity?null:this._createMomentum(r)}_createMomentum(s){e(this._tmpDirection,this._scene[0].filteredDelta??0,this._scene[1].filteredDelta??0,this._scene[2].filteredDelta??0);const r=t(this._tmpDirection);r>0&&i(this._tmpDirection,this._tmpDirection,1/r);const n=this._time.filteredDelta,l=null==n||0===n?0:r/n;return new c(s,this._stopVelocity,this._friction,l,this._tmpDirection)}}export{c as RopePullMomentum,l as RopePullMomentumEstimator};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../core/Error.js";import{removeMaybe as r}from"../../core/maybe.js";import{onAbort as t,throwIfAborted as i}from"../../core/promiseUtils.js";import l from"../../layers/Layer.js";function a(e){return"tryRecycleWith"in e}class s{constructor(r,i,l){this.layer=r,this.view=i,this.layerViewImporter=l,this._controller=new AbortController,this._started=!1,this.done=!1,this._deferred=Promise.withResolvers(),this.promise=this._deferred.promise,t(this._controller.signal,()=>{this._recycleController?.abort();const t=new e("cancelled:layerview-create","layerview creation cancelled",{layer:r});this._deferred?.reject(t)})}tryRecycle(e){if(!this.done||!this.layerView||!a(this.layerView))return null;this._recycleController?.abort(),this._recycleController=new AbortController;const r=this.layer.type,t=this._recycleController.signal;for(let l=0;l<e.length;l++){const a=e[l];if(a.type!==r)continue;const s=this.layerView.tryRecycleWith(a,{signal:t});if(s){e.splice(l,1),this.layer=a;const r=this.layerView,o=r.view;return this.promise=s.then(()=>(i(t),a.emit("layerview-destroy",{view:o,layerView:r}),o.emit("layerview-destroy",{view:o,layerView:r,layer:void 0}),a.emit("layerview-create",{view:o,layerView:r}),o.emit("layerview-create",{view:o,layerView:r,layer:void 0}),r)),this.promise}}return null}destroy(){this._controller.abort();const{layerView:e}=this;if(e){const{layer:r,view:t}=this;r.emit("layerview-destroy",{view:t,layerView:e}),t.emit("layerview-destroy",{layer:r,layerView:e})}this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null,this._map=null,this.promise=null,this._deferred=null}async start(){const{view:l}=this;if(this._started||!l.map)return;this._started=!0;const{_controller:{signal:a},layer:s}=this;this._map=l.map;try{let n,w;if(await s.load({signal:a}),s.prefetchResources&&await s.prefetchResources({signal:a}),o(s))n=await s.createLayerView(l,{signal:a});else{if(!this.layerViewImporter.hasLayerViewModule(s))throw new e("layer:view-not-supported","No layerview implementation was found");const r=await this.layerViewImporter.importLayerView(s);i(a),n="default"in r?new r.default({layer:s,view:l}):new r({layer:s,view:l})}const c=()=>{w=r(w),n.destroyed||n.destroy(),this.done=!0};w=t(a,c),i(a);try{await n.when()}catch(y){throw c(),y}const h=this._map?.allLayers?.includes(s);if(!h)return c(),void this._deferred?.reject(new e("view:no-layerview-for-layer","The layer has been removed from the map",{layer:s}));this.layerView=n,s.emit("layerview-create",{view:l,layerView:n}),l.emit("layerview-create",{layer:s,layerView:n}),this.done=!0,this._deferred?.resolve(n)}catch(y){s.emit("layerview-create-error",{view:l,error:y}),l.emit("layerview-create-error",{layer:s,error:y}),this.done=!0,this._deferred?.reject(new e("layerview:create-error","layerview creation failed",{layer:s,error:y}))}}}function o(e){return e.createLayerView!==l.prototype.createLayerView}export{s as LayerLayerViewInfo};
2
+ import e from"../../core/Error.js";import{removeMaybe as r}from"../../core/maybe.js";import{onAbort as t,throwIfAborted as i}from"../../core/promiseUtils.js";import l from"../../layers/Layer.js";function a(e){return"tryRecycleWith"in e}class s{constructor(r,i,l){this.layer=r,this.view=i,this.layerViewImporter=l,this._controller=new AbortController,this._started=!1,this.done=!1,this._deferred=Promise.withResolvers(),this.promise=this._deferred.promise,t(this._controller.signal,()=>{this._recycleController?.abort();const t=new e("cancelled:layerview-create","layerview creation cancelled",{layer:r});this._deferred?.reject(t)})}tryRecycle(e){if(!this.done||!this.layerView||!a(this.layerView))return null;this._recycleController?.abort(),this._recycleController=new AbortController;const r=this.layer.type,t=this._recycleController.signal;for(let l=0;l<e.length;l++){const a=e[l];if(a.type!==r)continue;const s=this.layerView.tryRecycleWith(a,{signal:t});if(s){e.splice(l,1),this.layer.emit("layerview-destroy",{view:this.layerView.view,layerView:this.layerView}),this.layerView.view?.emit("layerview-destroy",{view:this.layerView.view,layerView:this.layerView,layer:this.layer}),this.layer=a;const r=this.layerView,o=r.view;return this.promise=s.then(()=>(i(t),a.emit("layerview-create",{view:o,layerView:r}),o.emit("layerview-create",{view:o,layerView:r,layer:a}),r)),this.promise}}return null}destroy(){this._controller.abort();const{layerView:e}=this;if(e){const{layer:r,view:t}=this;r.emit("layerview-destroy",{view:t,layerView:e}),t.emit("layerview-destroy",{layer:r,layerView:e})}this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null,this._map=null,this.promise=null,this._deferred=null}async start(){const{view:l}=this;if(this._started||!l.map)return;this._started=!0;const{_controller:{signal:a},layer:s}=this;this._map=l.map;try{let n,w;if(await s.load({signal:a}),s.prefetchResources&&await s.prefetchResources({signal:a}),o(s))n=await s.createLayerView(l,{signal:a});else{if(!this.layerViewImporter.hasLayerViewModule(s))throw new e("layer:view-not-supported","No layerview implementation was found");const r=await this.layerViewImporter.importLayerView(s);i(a),n="default"in r?new r.default({layer:s,view:l}):new r({layer:s,view:l})}const h=()=>{w=r(w),n.destroyed||n.destroy(),this.done=!0};w=t(a,h),i(a);try{await n.when()}catch(y){throw h(),y}const c=this._map?.allLayers?.includes(s);if(!c)return h(),void this._deferred?.reject(new e("view:no-layerview-for-layer","The layer has been removed from the map",{layer:s}));this.layerView=n,s.emit("layerview-create",{view:l,layerView:n}),l.emit("layerview-create",{layer:s,layerView:n}),this.done=!0,this._deferred?.resolve(n)}catch(y){s.emit("layerview-create-error",{view:l,error:y}),l.emit("layerview-create-error",{layer:s,error:y}),this.done=!0,this._deferred?.reject(new e("layerview:create-error","layerview creation failed",{layer:s,error:y}))}}}function o(e){return e.createLayerView!==l.prototype.createLayerView}export{s as LayerLayerViewInfo};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import i from"../../core/Error.js";import t from"../../core/Logger.js";import{someMap as s}from"../../core/MapUtils.js";import{createAbortError as a,isAbortError as o}from"../../core/promiseUtils.js";import{on as n,watch as l,syncAndInitial as y}from"../../core/reactiveUtils.js";import{schedule as h}from"../../core/scheduling.js";import{property as c,subclass as p}from"../../core/accessorSupport/decorators.js";import{get as d}from"../../core/accessorSupport/get.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import{destroyMap as f}from"../../support/collectionUtils.js";import{LayerLayerViewInfo as u}from"./LayerLayerViewInfo.js";function g(e){return null!=e&&"object"==typeof e&&"layerViews"in e}let m=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new w,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)!1!==this.layerViewFilter?.(r)&&this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=Promise.withResolvers(),this._workPromise.promise.catch(()=>{})),this.removeHandles("reschedule"),this.addHandles(h(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const{map:e}=this.view;if(!e)return void this.clear();if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const a of e)if(a){if(!1===this.layerViewFilter?.(a))continue;r.add(a);const e=this._layerLayerViewInfoMap.get(a);e&&t?e.start():e||this._recyclingInfoMap.has(a)||i.push(a),"layers"in a&&a.layers&&s(a.layers)}};for(const o of this._rootCollectionNames)s(d(this,o));const a=new Array,n=e=>{const r=e.tryRecycle(i);r?(this._recyclingInfoMap.set(e.layer,e),this._watchUpdatingTracking.consumePromise(r),this.notifyChange("updating"),r.then(()=>{this._recyclingInfoMap.delete(e.layer),this._layerLayerViewInfoMap.set(e.layer,e),this._reschedule(),this.notifyChange("updating"),this.notifyChange("allLayerViews")}).catch(r=>{o(r)||(this._recyclingInfoMap.delete(e.layer),e.destroy(),this._reschedule(),this.notifyChange("updating"),this.notifyChange("allLayerViews"))})):a.push(e)};for(const o of this._layerLayerViewInfoMap.values())r.has(o.layer)||(this._layerLayerViewInfoMap.delete(o.layer),n(o));for(const o of this._recyclingInfoMap.values())r.has(o.layer)||(this._recyclingInfoMap.delete(o.layer),n(o));for(const o of i)this._createLayerView(o);this._refreshCollections(),a.forEach(e=>e.destroy());const l=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.groundLayers,e?.basemap?.referenceLayers,e?.layers].filter(e=>!!e);r.forEach(e=>"layers"in e&&l.push(e.layers)),this.addHandles(l.map(e=>this._watchUpdatingTracking.addOnCollectionChange(()=>e,this._reschedule)),"collection-change"),this._workPromise.resolve(),this._workPromise=null},this._layersToLayerViews=new Map(e.layerviewMapping)}initialize(){this.addHandles([n(()=>this.view?.map?.allLayers,"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),l(()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]},()=>this._reschedule().catch(()=>{}),y)]),this._preloadLayerViewModules(),this._reschedule().catch(()=>{})}clearHandles(){this._watchUpdatingTracking.removeAll()}destroy(){this.clear(),f(this._recyclingInfoMap),f(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(a()),this._workPromise=null)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,e=>!e.done)||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(this._clearCollections(),f(this._layerLayerViewInfoMap),f(this._recyclingInfoMap),this.notifyChange("allLayerViews"))}async whenLayerView(e){await this._reschedule();const r=this._layerLayerViewInfoMap.get(e)?.promise;if(!r){const r=this._recyclingInfoMap.get(e)?.promise;if(!r)throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e});return r}return r}isCreatingLayerViewsForLayer(e,r){this.commitProperty("updatingRemaining");const i=this._layerLayerViewInfoMap.get(e);if(!i?.done)return!0;const t=i.layerView;return!(!t||!r||t.parent===r)||!!(i.done&&t&&"layers"in e&&e.layers?.length)&&e.layers.some(e=>this.isCreatingLayerViewsForLayer(e,t))}get allLayerViews(){const e=[];for(const r of this._layerLayerViewInfoMap.values())r.layerView&&e.push(r.layerView);for(const r of this._recyclingInfoMap.values())r.layerView&&e.push(r.layerView);return e}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(d(this,e),d(this,r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining"),this.notifyChange("allLayerViews")}_clearCollections(){for(const e of this._layersToLayerViews.values())d(this,e)?.removeAll()}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void r?.removeAll();let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e?.layerView)continue;const{layerView:a}=e;a.layer=s,a.parent=i,r.at(t)!==a&&r.splice(t,0,a),"layers"in s&&g(a)&&this._populateLayerViewsOwners(s.layers,a.layerViews,a),++t}t<r.length&&r.splice(t)}_createLayerView(e){e.load().catch(()=>{}),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new u(e,this.view,this.layerViewImporter),i=r.promise?.then(()=>this._refreshCollections(),r=>{r&&(o(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this.destroyed||this._refreshCollections()});this._watchUpdatingTracking.consumePromise(i),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining"),this.notifyChange("allLayerViews")}};e([c()],m.prototype,"_workPromise",void 0),e([c({readOnly:!0})],m.prototype,"_watchUpdatingTracking",void 0),e([c({readOnly:!0})],m.prototype,"_layersToLayerViews",void 0),e([c({constructOnly:!0})],m.prototype,"layerviewMapping",void 0),e([c({readOnly:!0})],m.prototype,"_rootCollectionNames",null),e([c({constructOnly:!0})],m.prototype,"layerViewFilter",void 0),e([c()],m.prototype,"layerViewImporter",void 0),e([c({readOnly:!0})],m.prototype,"updating",null),e([c({readOnly:!0})],m.prototype,"updatingRemaining",null),e([c({constructOnly:!0})],m.prototype,"view",void 0),e([c({readOnly:!0})],m.prototype,"allLayerViews",null),m=e([p("esri.views.support.LayerViewManager")],m);const _=m;export{_ as default};
2
+ import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import i from"../../core/Error.js";import t from"../../core/Logger.js";import{someMap as s}from"../../core/MapUtils.js";import{createAbortError as o,isAbortError as a}from"../../core/promiseUtils.js";import{on as n,watch as l,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as y}from"../../core/scheduling.js";import{property as c,subclass as p}from"../../core/accessorSupport/decorators.js";import{get as d}from"../../core/accessorSupport/get.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import{destroyMap as f}from"../../support/collectionUtils.js";import{LayerLayerViewInfo as g}from"./LayerLayerViewInfo.js";function u(e){return null!=e&&"object"==typeof e&&"layerViews"in e}let m=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new w,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)!1!==this.layerViewFilter?.(r)&&this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=Promise.withResolvers(),this._workPromise.promise.catch(()=>{})),this.removeHandles("reschedule"),this.addHandles(y(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const{map:e}=this.view;if(!e)return void this.clear();if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const o of e)if(o){if(!1===this.layerViewFilter?.(o))continue;r.add(o);const e=this._layerLayerViewInfoMap.get(o);e&&t?e.start():e||this._recyclingInfoMap.has(o)||i.push(o),"layers"in o&&o.layers&&s(o.layers)}};for(const a of this._rootCollectionNames)s(d(this,a));const o=new Array,n=e=>{const r=e.tryRecycle(i);if(r){const i=e.layer;this._recyclingInfoMap.set(i,e),this._watchUpdatingTracking.consumePromise(r),this.notifyChange("updating"),r.then(()=>{this._recyclingInfoMap.get(i)===e&&e.promise===r&&(this._recyclingInfoMap.delete(i),this._layerLayerViewInfoMap.set(i,e),this._reschedule(),this.notifyChange("updating"),this.notifyChange("allLayerViews"))}).catch(t=>{this._recyclingInfoMap.get(i)!==e||e.promise!==r||a(t)||(this._recyclingInfoMap.delete(i),e.destroy(),this._reschedule(),this.notifyChange("updating"),this.notifyChange("allLayerViews"))})}else o.push(e)};for(const a of this._layerLayerViewInfoMap.values())r.has(a.layer)||(this._layerLayerViewInfoMap.delete(a.layer),n(a));for(const a of this._recyclingInfoMap.values())r.has(a.layer)||(this._recyclingInfoMap.delete(a.layer),n(a));for(const a of i)this._createLayerView(a);this._refreshCollections(),o.forEach(e=>e.destroy());const l=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.groundLayers,e?.basemap?.referenceLayers,e?.layers].filter(e=>!!e);r.forEach(e=>"layers"in e&&l.push(e.layers)),this.addHandles(l.map(e=>this._watchUpdatingTracking.addOnCollectionChange(()=>e,this._reschedule)),"collection-change"),this._workPromise.resolve(),this._workPromise=null},this._layersToLayerViews=new Map(e.layerviewMapping)}initialize(){this.addHandles([n(()=>this.view?.map?.allLayers,"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),l(()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]},()=>this._reschedule().catch(()=>{}),h)]),this._preloadLayerViewModules(),this._reschedule().catch(()=>{})}clearHandles(){this._watchUpdatingTracking.removeAll()}destroy(){this.clear(),f(this._recyclingInfoMap),f(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(o()),this._workPromise=null)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,e=>!e.done)||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(this._clearCollections(),f(this._layerLayerViewInfoMap),f(this._recyclingInfoMap),this.notifyChange("allLayerViews"))}async whenLayerView(e){await this._reschedule();const r=this._layerLayerViewInfoMap.get(e)?.promise;if(!r){const r=this._recyclingInfoMap.get(e)?.promise;if(!r)throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e});return r}return r}isCreatingLayerViewsForLayer(e,r){this.commitProperty("updatingRemaining");const i=this._layerLayerViewInfoMap.get(e);if(!i?.done)return!0;const t=i.layerView;return!(!t||!r||t.parent===r)||!!(i.done&&t&&"layers"in e&&e.layers?.length)&&e.layers.some(e=>this.isCreatingLayerViewsForLayer(e,t))}get allLayerViews(){const e=[];for(const r of this._layerLayerViewInfoMap.values())r.layerView&&e.push(r.layerView);for(const r of this._recyclingInfoMap.values())r.layerView&&e.push(r.layerView);return e}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(d(this,e),d(this,r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining"),this.notifyChange("allLayerViews")}_clearCollections(){for(const e of this._layersToLayerViews.values())d(this,e)?.removeAll()}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void r?.removeAll();let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e?.layerView)continue;const{layerView:o}=e;o.layer=s,o.parent=i,r.at(t)!==o&&r.splice(t,0,o),"layers"in s&&u(o)&&this._populateLayerViewsOwners(s.layers,o.layerViews,o),++t}t<r.length&&r.splice(t)}_createLayerView(e){e.load().catch(()=>{}),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new g(e,this.view,this.layerViewImporter),i=r.promise?.then(()=>this._refreshCollections(),r=>{r&&(a(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this.destroyed||this._refreshCollections()});this._watchUpdatingTracking.consumePromise(i),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining"),this.notifyChange("allLayerViews")}};e([c()],m.prototype,"_workPromise",void 0),e([c({readOnly:!0})],m.prototype,"_watchUpdatingTracking",void 0),e([c({readOnly:!0})],m.prototype,"_layersToLayerViews",void 0),e([c({constructOnly:!0})],m.prototype,"layerviewMapping",void 0),e([c({readOnly:!0})],m.prototype,"_rootCollectionNames",null),e([c({constructOnly:!0})],m.prototype,"layerViewFilter",void 0),e([c()],m.prototype,"layerViewImporter",void 0),e([c({readOnly:!0})],m.prototype,"updating",null),e([c({readOnly:!0})],m.prototype,"updatingRemaining",null),e([c({constructOnly:!0})],m.prototype,"view",void 0),e([c({readOnly:!0})],m.prototype,"allLayerViews",null),m=e([p("esri.views.support.LayerViewManager")],m);const _=m;export{_ as default};
@@ -544,6 +544,12 @@ export default class FeaturesViewModel extends FeaturesViewModelSuperclass {
544
544
  * @default "disabled"
545
545
  */
546
546
  get state(): State;
547
+ /**
548
+ * Indicates whether features are being streamed into the view model.
549
+ *
550
+ * @since 5.2
551
+ */
552
+ get streamingFeatures(): false;
547
553
  /**
548
554
  * Dates and times will be displayed in this time zone. By default this time zone is
549
555
  * inherited from [MapView.timeZone](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#timeZone) if the [view](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#view) property is set. When a MapView is not associated with the widget view model,
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import{deprecatedModule as r}from"../../core/deprecate.js";import s from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as n,isAbortError as l}from"../../core/promiseUtils.js";import u from"../../core/ReactiveSet.js";import{watch as h,when as c,sync as p}from"../../core/reactiveUtils.js";import{property as d,subclass as g}from"../../core/accessorSupport/decorators.js";import m from"../../geometry/Point.js";import{initializeProjection as f,project as y}from"../../geometry/projectionUtils.js";import F from"../../geometry/SpatialReference.js";import{geographicToWebMercator as _}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as w}from"../../layers/LayerConstants.js";import v from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as C}from"../../symbols/support/symbolUtils.js";import{system as b}from"../../time/constants.js";import{highlightsSupported as P}from"../../views/support/layerViewUtils.js";import S from"../Feature/FeatureViewModel.js";import{ActionsCollection as L,zoomToFeature as M,zoomToClusteredFeatures as V,browseClusteredFeatures as A}from"../Popup/actions.js";import{triggerAction as E,isClusterFeature as j,getSelectedTarget as I,removeClusteredFeaturesForBrowsing as x,displayClusterExtent as R,browseAggregateFeatures as O}from"../Popup/actionUtils.js";import{AnchorElementViewModelMixin as T}from"../support/AnchorElementViewModel.js";import{GoTo as U}from"../support/GoTo.js";const B="location-scale-handle",H=()=>[M.clone()],G=()=>[V.clone(),A.clone()];let z=null;function D(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let Z=class extends(U(T(a))){constructor(e){super(e),this._pendingPromises=new u,this._fetchFeaturesController=null,this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this._featureStreamVersion=0,this._activeFeatureStream=null,this._fetchingFeatureStream=!1,this.actions=new L,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.selectedClusterBoundaryFeature=new t({symbol:new v({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=n(async e=>{this._cancelLocationUpdate();const t=new AbortController,{signal:i}=t;this._locationUpdateController=t,await this._locationUpdate(e,{signal:i}).catch(()=>{}).finally(()=>{this._locationUpdateController===t&&(this._locationUpdateController=null)})}),e?.suppressDeprecationWarning||r(o.getLogger(this),"esri.widgets.Features.FeaturesViewModel",{version:"5.2",replacement:"Use the Features (Next) component or the @arcgis/core/popup/FeatureContentCollection module instead.",warnOnce:!0})}normalizeCtorArgs(e){const{suppressDeprecationWarning:t,...i}=e??{};return i}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),h(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),h(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),h(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),h(()=>this.location,e=>this._locationChange(e)),h(()=>this.selectedFeature,e=>this._selectedFeatureChange(e).catch(()=>{})),h(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),h(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),h(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>E({event:e,viewModel:this,view:this.view}).catch(()=>{})),c(()=>!this.waitingForResult,()=>this._waitingForResultChange(),p),h(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),h(()=>this.view?.scale,()=>this._viewScaleChange()),c(()=>!this.visible,()=>this.browseClusterEnabled=!1),h(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelLocationUpdate(),this._cancelFetchingFeatures(),this._cancelCenterAtLocation(),this._cancelFeatureStream(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new L;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:r,includeDefaultActions:s,selectedFeature:a}=this,o=s?i.concat(t):t,n=a&&("function"==typeof a.getEffectivePopupTemplate&&a.getEffectivePopupTemplate(r)||a.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(o)??o;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new L;return e.removeAll(),e.addMany(j(this.selectedFeature)?G():H()),e}get featureCount(){return this.features.length}set features(e){if(this._get("features")===e)return;const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:r,selectedFeatureIndex:s}=this,a=r&&t.length;"list"!==this.initialDisplayMode?a&&i&&-1===s?this.selectedFeatureIndex=0:a&&-1!==s||(this.selectedFeatureIndex=t.length?0:-1):(!a||a&&i===r)&&(this.selectedFeatureIndex=-1)}get featureStream(){return this._get("featureStream")||null}set featureStream(e){if(this._get("featureStream")===e)return;if(this._set("featureStream",e),this._cancelFeatureStream(),!e)return;this.promises=[];const t=this._featureStreamVersion;this._setFetchingFeatureStream(!0),this._activeFeatureStream=e,this._consumeFeatureStream(e,t).catch(()=>{})}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,r=e?.spatialReference?.isWGS84;r&&i&&(t=_(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._get("promises")!==e&&(this._cancelFeatureStream(),this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[]))}get screenLocation(){return super.screenLocation}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??b}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this._fetchingFeatureStream||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);this._cancelCenterAtLocation();const i=new AbortController,{signal:r}=i;return this._centerAtLocationController=i,t&&e?this.callGoTo({target:{target:t,scale:e.scale},options:{signal:r}}).catch(e=>{l(e)||o.getLogger(this).error(e)}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this._cancelFeatureStream(),this.set({featureStream:null,promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeaturesLegacy(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){this._cancelFeatureStream();const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&!t.featureStream&&this._setFetchFeaturesPromises(t.location).catch(()=>{});const r=["actionsMenuOpen","collapsed","shouldFocus"];for(const s of r)delete t[s];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){x(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?j(t)?(await R(this),await O(this)):o.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):o.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}async handleViewClick(e){return this._fetchFeaturesAndOpen(e)}_setFetchingFeatureStream(e){this._fetchingFeatureStream!==e&&(this._fetchingFeatureStream=e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(M.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(j(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:r}=this;r&&!this._locationUpdateController&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:r,featureViewModels:s}=this;if(null==i)return;const a=((i-1)*r+t)%t,o=a+r;s.slice(a,o).forEach((t,i)=>{t&&(t.graphic??=e[a+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:r}=this;if(!e||!r)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(r.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),j(e))return;return e.symbol=await C(e),this._selectedClusterFeature=e,void r.graphics.add(this._selectedClusterFeature)}const s=e.sourceLayer?.type;if("map-image"!==s&&"imagery"!==s&&"imagery-tile"!==s||(e.symbol=await C(e)),(i||!t)&&e.geometry){if("point"===e.geometry.type)return void(this.location=e.geometry);const t=await(import("../../geometry/operators/labelPointOperator.js"));return void(this.location=t.execute(e.geometry))}if(i&&!e.geometry){await this.centerAtLocation();const e=r.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:r,spatialReference:s,map:a,timeZone:o,location:n}=this;if(j(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let h=null;if(l.some((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h)),h)u[i]=h;else{const l=new S({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s,graphic:t===e?t:null,location:n,map:a,view:r,timeZone:o,suppressDeprecationWarning:!0});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:r}=this;if(!r)return null;await(r?.when());const s=e?.spatialReference;return s&&i?(await f(s,i,null,t),r.toScreen(e)):null}_cancelCenterAtLocation(){this._centerAtLocationController?.abort(),this._centerAtLocationController=null}_cancelFeatureStream(){this._featureStreamVersion++,this._setFetchingFeatureStream(!1);const e=this._activeFeatureStream;this._activeFeatureStream=null,this._get("featureStream")===e&&this._set("featureStream",null),e?.return&&e.return(void 0).catch(()=>{})}_cancelFetchingFeatures(){this._fetchFeaturesController?.abort(),this._fetchFeaturesController=null}async _consumeFeatureStream(e,t){try{for await(const i of e){if(t!==this._featureStreamVersion)return;this._updateFeatures([i])}}finally{this._activeFeatureStream===e&&(this._activeFeatureStream=null,this._setFetchingFeatureStream(!1))}}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:r}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:r}),{signal:r,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const r=new AbortController,{signal:s}=r;this._fetchFeaturesController=r;const a=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:s,event:i});return a.catch(()=>{}).finally(()=>{this._fetchFeaturesController===r&&(this._fetchFeaturesController=null)}),a}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e;this.removeHandles(B),this.addHandles([h(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{l(e)||o.getLogger(this).error(e)})),c(()=>!this.visible,()=>{this.removeHandles(B)},{once:!0})],B);const{pendingFeatures:r}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});return{location:t??void 0,promises:r}}async _locationUpdate(e,t){const{spatialReference:i}=this,r=this.selectedFeature?.geometry?.type,s=this.location??e;if(r&&"mesh"!==r&&i&&s&&this.selectedFeature){if("point"===r){const e=await(import("../../geometry/operators/labelPointOperator.js"));return void(this.location=e.execute(this.selectedFeature.geometry))}try{const e=this.selectedFeature;let r=e.geometry;const a=this._getHighlightLayer(e),o=e.getObjectId();if(!a||!this.view)return;if(o){const e=this.view?.allLayerViews.find(e=>e.layer.uid===a.uid);if(!e||!("queryFeatures"in e))return;const s=e.createQuery();s.outSpatialReference=i,s.objectIds=[o],s.returnGeometry=!0;const{features:n}=await e.queryFeatures(s,t);r=n[0]?.geometry}if(!r||"mesh"===r.type)return;r=y(r,i),z||(z=await Promise.all([import("../../geometry/operators/intersectsOperator.js"),import("../../geometry/operators/proximityOperator.js")]));const[n,l]=z;if(!n.execute(r,s)){const t=l.getNearestCoordinate(r,s).coordinate??s;this.selectedFeature===e&&(this.location=t)}}catch(a){l(a)||o.getLogger(this).error(a)}}}_cancelLocationUpdate(){this._locationUpdateController?.abort(),this._locationUpdateController=null}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(D(t.type,i))return e;const r=e.getObjectId();if(null!=r)return r;const s="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||w:null,a=e.attributes;return a&&s&&a[s]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:r,view:s,visible:a}=this;if(!s||!r||!a)return;const o=this._getHighlightLayer(i);if(!o)return;const n=this._getHighlightLayerView(s,o);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&P(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,o,s.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([d()],Z.prototype,"_fetchFeaturesController",void 0),e([d()],Z.prototype,"_fetchingFeatureStream",void 0),e([d({type:L})],Z.prototype,"actions",void 0),e([d({readOnly:!0})],Z.prototype,"active",null),e([d()],Z.prototype,"activeFeature",void 0),e([d({readOnly:!0})],Z.prototype,"allActions",null),e([d()],Z.prototype,"autoCloseEnabled",void 0),e([d()],Z.prototype,"browseClusterEnabled",void 0),e([d()],Z.prototype,"content",void 0),e([d({type:L,readOnly:!0})],Z.prototype,"defaultActions",null),e([d({type:Boolean})],Z.prototype,"defaultPopupTemplateEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"featureCount",null),e([d()],Z.prototype,"featurePage",void 0),e([d({value:[]})],Z.prototype,"features",null),e([d()],Z.prototype,"featuresPerPage",void 0),e([d()],Z.prototype,"featureStream",null),e([d()],Z.prototype,"featureMenuOpen",void 0),e([d()],Z.prototype,"featureMenuTitle",void 0),e([d()],Z.prototype,"featureViewModelAbilities",void 0),e([d({readOnly:!0})],Z.prototype,"featureViewModels",void 0),e([d()],Z.prototype,"highlightEnabled",void 0),e([d()],Z.prototype,"includeDefaultActions",void 0),e([d()],Z.prototype,"initialDisplayMode",void 0),e([d({type:m})],Z.prototype,"location",null),e([d()],Z.prototype,"map",null),e([d({readOnly:!0})],Z.prototype,"pendingPromisesCount",null),e([d({readOnly:!0})],Z.prototype,"promiseCount",null),e([d()],Z.prototype,"promises",null),e([d({readOnly:!0})],Z.prototype,"selectedClusterBoundaryFeature",void 0),e([d({value:null,readOnly:!0})],Z.prototype,"selectedFeature",null),e([d({value:-1})],Z.prototype,"selectedFeatureIndex",null),e([d({readOnly:!0})],Z.prototype,"selectedFeatureViewModel",null),e([d({type:F})],Z.prototype,"spatialReference",null),e([d({readOnly:!0})],Z.prototype,"state",null),e([d()],Z.prototype,"timeZone",null),e([d()],Z.prototype,"title",void 0),e([d()],Z.prototype,"updateLocationEnabled",void 0),e([d()],Z.prototype,"view",void 0),e([d()],Z.prototype,"visible",void 0),e([d({readOnly:!0})],Z.prototype,"waitingForContents",null),e([d({readOnly:!0})],Z.prototype,"waitingForResult",null),e([d()],Z.prototype,"zoomFactor",void 0),e([d()],Z.prototype,"zoomToLocation",void 0),e([d()],Z.prototype,"centerAtLocation",null),Z=e([g("esri.widgets.Features.FeaturesViewModel")],Z);export{Z as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import{deprecatedModule as r}from"../../core/deprecate.js";import s from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as n,isAbortError as l}from"../../core/promiseUtils.js";import u from"../../core/ReactiveSet.js";import{watch as h,when as c,sync as p}from"../../core/reactiveUtils.js";import{property as d,subclass as g}from"../../core/accessorSupport/decorators.js";import m from"../../geometry/Point.js";import{initializeProjection as f,project as y}from"../../geometry/projectionUtils.js";import F from"../../geometry/SpatialReference.js";import{geographicToWebMercator as _}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as w}from"../../layers/LayerConstants.js";import v from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as C}from"../../symbols/support/symbolUtils.js";import{system as b}from"../../time/constants.js";import{highlightsSupported as P}from"../../views/support/layerViewUtils.js";import S from"../Feature/FeatureViewModel.js";import{ActionsCollection as L,zoomToFeature as M,zoomToClusteredFeatures as V,browseClusteredFeatures as A}from"../Popup/actions.js";import{triggerAction as E,isClusterFeature as j,getSelectedTarget as I,removeClusteredFeaturesForBrowsing as x,displayClusterExtent as R,browseAggregateFeatures as O}from"../Popup/actionUtils.js";import{AnchorElementViewModelMixin as T}from"../support/AnchorElementViewModel.js";import{GoTo as U}from"../support/GoTo.js";const B="location-scale-handle",H=()=>[M.clone()],G=()=>[V.clone(),A.clone()];let z=null;function D(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let Z=class extends(U(T(a))){constructor(e){super(e),this._pendingPromises=new u,this._fetchFeaturesController=null,this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this._featureStreamVersion=0,this._activeFeatureStream=null,this.actions=new L,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.streamingFeatures=!1,this.selectedClusterBoundaryFeature=new t({symbol:new v({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=n(async e=>{this._cancelLocationUpdate();const t=new AbortController,{signal:i}=t;this._locationUpdateController=t,await this._locationUpdate(e,{signal:i}).catch(()=>{}).finally(()=>{this._locationUpdateController===t&&(this._locationUpdateController=null)})}),e?.suppressDeprecationWarning||r(o.getLogger(this),"esri.widgets.Features.FeaturesViewModel",{version:"5.2",replacement:"Use the Features (Next) component or the @arcgis/core/popup/FeatureContentCollection module instead.",warnOnce:!0})}normalizeCtorArgs(e){const{suppressDeprecationWarning:t,...i}=e??{};return i}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),h(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),h(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),h(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),h(()=>this.location,e=>this._locationChange(e)),h(()=>this.selectedFeature,e=>this._selectedFeatureChange(e).catch(()=>{})),h(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),h(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),h(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>E({event:e,viewModel:this,view:this.view}).catch(()=>{})),c(()=>!this.waitingForResult,()=>this._waitingForResultChange(),p),h(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),h(()=>this.view?.scale,()=>this._viewScaleChange()),c(()=>!this.visible,()=>this.browseClusterEnabled=!1),h(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelLocationUpdate(),this._cancelFetchingFeatures(),this._cancelCenterAtLocation(),this._cancelFeatureStream(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new L;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:r,includeDefaultActions:s,selectedFeature:a}=this,o=s?i.concat(t):t,n=a&&("function"==typeof a.getEffectivePopupTemplate&&a.getEffectivePopupTemplate(r)||a.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(o)??o;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new L;return e.removeAll(),e.addMany(j(this.selectedFeature)?G():H()),e}get featureCount(){return this.features.length}set features(e){if(this._get("features")===e)return;const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:r,selectedFeatureIndex:s}=this,a=r>0&&t.length>0,o=null!=this._activeFeatureStream&&t.length>0,n=a||o;"list"!==this.initialDisplayMode?n&&-1===s?this.selectedFeatureIndex=0:n&&-1!==s||(this.selectedFeatureIndex=t.length?0:-1):(!n||a&&i===r)&&(this.selectedFeatureIndex=-1)}get featureStream(){return this._get("featureStream")||null}set featureStream(e){if(this._get("featureStream")===e)return;if(this._set("featureStream",e),this._cancelFeatureStream(),!e)return;this.promises=[];const t=this._featureStreamVersion;this._activeFeatureStream=e,this._queueFeatureStreamFetching(e,t),this._consumeFeatureStream(e,t).catch(()=>{})}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,r=e?.spatialReference?.isWGS84;r&&i&&(t=_(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._get("promises")!==e&&(this._cancelFeatureStream(),this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[]))}get screenLocation(){return super.screenLocation}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??b}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.streamingFeatures||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);this._cancelCenterAtLocation();const i=new AbortController,{signal:r}=i;return this._centerAtLocationController=i,t&&e?this.callGoTo({target:{target:t,scale:e.scale},options:{signal:r}}).catch(e=>{l(e)||o.getLogger(this).error(e)}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this._cancelFeatureStream(),this.set({featureStream:null,promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeaturesLegacy(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){this._cancelFeatureStream();const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&!t.featureStream&&this._setFetchFeaturesPromises(t.location).catch(()=>{});const r=["actionsMenuOpen","collapsed","shouldFocus"];for(const s of r)delete t[s];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){x(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?j(t)?(await R(this),await O(this)):o.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):o.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}async handleViewClick(e){return this._fetchFeaturesAndOpen(e)}_setStreamingFeatures(e){this.streamingFeatures!==e&&this._set("streamingFeatures",e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(M.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(j(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:r}=this;r&&!this._locationUpdateController&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:r,featureViewModels:s}=this;if(null==i)return;const a=((i-1)*r+t)%t,o=a+r;s.slice(a,o).forEach((t,i)=>{t&&(t.graphic??=e[a+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:r}=this;if(!e||!r)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(r.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),j(e))return;return e.symbol=await C(e),this._selectedClusterFeature=e,void r.graphics.add(this._selectedClusterFeature)}const s=e.sourceLayer?.type;if("map-image"!==s&&"imagery"!==s&&"imagery-tile"!==s||(e.symbol=await C(e)),(i||!t)&&e.geometry){if("point"===e.geometry.type)return void(this.location=e.geometry);const t=await(import("../../geometry/operators/labelPointOperator.js"));return void(this.location=t.execute(e.geometry))}if(i&&!e.geometry){await this.centerAtLocation();const e=r.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&(this.promises.length>0||this.featureStream)&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:r,spatialReference:s,map:a,timeZone:o,location:n}=this;if(j(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let h=null;if(l.some((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h)),h)u[i]=h;else{const l=new S({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s,graphic:t===e?t:null,location:n,map:a,view:r,timeZone:o,suppressDeprecationWarning:!0});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:r}=this;if(!r)return null;await(r?.when());const s=e?.spatialReference;return s&&i?(await f(s,i,null,t),r.toScreen(e)):null}_cancelCenterAtLocation(){this._centerAtLocationController?.abort(),this._centerAtLocationController=null}_cancelFeatureStream(){this._featureStreamVersion++,this._setStreamingFeatures(!1);const e=this._activeFeatureStream;this._activeFeatureStream=null,this._get("featureStream")===e&&this._set("featureStream",null),e?.return&&e.return(void 0).catch(()=>{})}_cancelFetchingFeatures(){this._fetchFeaturesController?.abort(),this._fetchFeaturesController=null}async _consumeFeatureStream(e,t){try{for await(const i of e){if(t!==this._featureStreamVersion)return;this._updateFeatures([i])}}finally{this._activeFeatureStream===e&&(this._activeFeatureStream=null,this._setStreamingFeatures(!1),this._waitingForResultChange())}}_queueFeatureStreamFetching(e,t){queueMicrotask(()=>{this._activeFeatureStream===e&&t===this._featureStreamVersion&&this._setStreamingFeatures(!0)})}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:r}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:r}),{signal:r,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const r=new AbortController,{signal:s}=r;this._fetchFeaturesController=r;const a=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:s,event:i});return a.catch(()=>{}).finally(()=>{this._fetchFeaturesController===r&&(this._fetchFeaturesController=null)}),a}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e;this.removeHandles(B),this.addHandles([h(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{l(e)||o.getLogger(this).error(e)})),c(()=>!this.visible,()=>{this.removeHandles(B)},{once:!0})],B);const{pendingFeatures:r}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});return{location:t??void 0,promises:r}}async _locationUpdate(e,t){const{spatialReference:i}=this,r=this.selectedFeature?.geometry?.type,s=this.location??e;if(r&&"mesh"!==r&&i&&s&&this.selectedFeature){if("point"===r){const e=await(import("../../geometry/operators/labelPointOperator.js"));return void(this.location=e.execute(this.selectedFeature.geometry))}try{const e=this.selectedFeature;let r=e.geometry;const a=this._getHighlightLayer(e),o=e.getObjectId();if(!a||!this.view)return;if(o){const e=this.view?.allLayerViews.find(e=>e.layer.uid===a.uid);if(!e||!("queryFeatures"in e))return;const s=e.createQuery();s.outSpatialReference=i,s.objectIds=[o],s.returnGeometry=!0;const{features:n}=await e.queryFeatures(s,t);r=n[0]?.geometry}if(!r||"mesh"===r.type)return;r=y(r,i),z||(z=await Promise.all([import("../../geometry/operators/intersectsOperator.js"),import("../../geometry/operators/proximityOperator.js")]));const[n,l]=z;if(!n.execute(r,s)){const t=l.getNearestCoordinate(r,s).coordinate??s;this.selectedFeature===e&&(this.location=t)}}catch(a){l(a)||o.getLogger(this).error(a)}}}_cancelLocationUpdate(){this._locationUpdateController?.abort(),this._locationUpdateController=null}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(D(t.type,i))return e;const r=e.getObjectId();if(null!=r)return r;const s="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||w:null,a=e.attributes;return a&&s&&a[s]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:r,view:s,visible:a}=this;if(!s||!r||!a)return;const o=this._getHighlightLayer(i);if(!o)return;const n=this._getHighlightLayerView(s,o);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&P(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,o,s.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([d()],Z.prototype,"_fetchFeaturesController",void 0),e([d({type:L})],Z.prototype,"actions",void 0),e([d({readOnly:!0})],Z.prototype,"active",null),e([d()],Z.prototype,"activeFeature",void 0),e([d({readOnly:!0})],Z.prototype,"allActions",null),e([d()],Z.prototype,"autoCloseEnabled",void 0),e([d()],Z.prototype,"browseClusterEnabled",void 0),e([d()],Z.prototype,"content",void 0),e([d({type:L,readOnly:!0})],Z.prototype,"defaultActions",null),e([d({type:Boolean})],Z.prototype,"defaultPopupTemplateEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"featureCount",null),e([d()],Z.prototype,"featurePage",void 0),e([d({value:[]})],Z.prototype,"features",null),e([d()],Z.prototype,"featuresPerPage",void 0),e([d()],Z.prototype,"featureStream",null),e([d()],Z.prototype,"featureMenuOpen",void 0),e([d()],Z.prototype,"featureMenuTitle",void 0),e([d()],Z.prototype,"featureViewModelAbilities",void 0),e([d({readOnly:!0})],Z.prototype,"featureViewModels",void 0),e([d()],Z.prototype,"highlightEnabled",void 0),e([d()],Z.prototype,"includeDefaultActions",void 0),e([d()],Z.prototype,"initialDisplayMode",void 0),e([d({type:m})],Z.prototype,"location",null),e([d()],Z.prototype,"map",null),e([d({readOnly:!0})],Z.prototype,"streamingFeatures",void 0),e([d({readOnly:!0})],Z.prototype,"pendingPromisesCount",null),e([d({readOnly:!0})],Z.prototype,"promiseCount",null),e([d()],Z.prototype,"promises",null),e([d({readOnly:!0})],Z.prototype,"selectedClusterBoundaryFeature",void 0),e([d({value:null,readOnly:!0})],Z.prototype,"selectedFeature",null),e([d({value:-1})],Z.prototype,"selectedFeatureIndex",null),e([d({readOnly:!0})],Z.prototype,"selectedFeatureViewModel",null),e([d({type:F})],Z.prototype,"spatialReference",null),e([d({readOnly:!0})],Z.prototype,"state",null),e([d()],Z.prototype,"timeZone",null),e([d()],Z.prototype,"title",void 0),e([d()],Z.prototype,"updateLocationEnabled",void 0),e([d()],Z.prototype,"view",void 0),e([d()],Z.prototype,"visible",void 0),e([d({readOnly:!0})],Z.prototype,"waitingForContents",null),e([d({readOnly:!0})],Z.prototype,"waitingForResult",null),e([d()],Z.prototype,"zoomFactor",void 0),e([d()],Z.prototype,"zoomToLocation",void 0),e([d()],Z.prototype,"centerAtLocation",null),Z=e([g("esri.widgets.Features.FeaturesViewModel")],Z);export{Z as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{substitute as t,formatNumber as i}from"../intl.js";import o from"../core/Collection.js";import{deprecateWidget as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as l,initial as a,when as d}from"../core/reactiveUtils.js";import{waitAnimationFrame as c}from"../core/scheduling.js";import{throttle as u}from"../core/throttle.js";import{property as h,subclass as p}from"../core/accessorSupport/decorators.js";import{loadActionUtilsComponents as v,substituteActionImage as m,getActionStyles as g,renderAction as w}from"../support/actions/actionUtils.js";import _ from"./Feature.js";import M from"./Spinner.js";import f from"./Widget.js";import{css as F}from"./Feature/resources.js";import{FeatureContentMixin as y}from"./Feature/support/FeatureContentMixin.js";import{css as b}from"./Features/css.js";import I from"./Features/FeaturesDrillIn.js";import C from"./Features/FeaturesViewModel.js";import A from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as x}from"./Popup/actions.js";import{zoomToLocation as T}from"./Popup/actionUtils.js";import{loadCalciteComponents as N}from"./support/componentsUtils.js";import{globalCss as k}from"./support/globalCss.js";import{Heading as O}from"./support/Heading.js";import{tsx as E,messageBundle as W,vmEvent as D}from"./support/widget.js";import{setFocus as L}from"./support/widgetUtils.js";const S="selected-index",B=0,j="features-spinner";function R(e){return e?.declaredClass.startsWith("esri.layers.")??!1}let H=class extends(y(f)){constructor(e,t){super(e,t),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._spinner=null,this._feature=null,this._focusAbortController=null,this._drillInFlowItems=new o,this._drillInWidget=new I({flowItems:this._drillInFlowItems}),this._rootNode=null,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._actionBarMenuNode=null,this.collapsed=!1,this.featureNavigationTop=!1,this.headerActions=new x,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new C({suppressDeprecationWarning:!0}),this.visibleElements=new A,this._previousFeature=()=>{this.viewModel.previous()},this._nextFeature=()=>{this.viewModel.next()},this._handleFeatureBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this._openFeatureMenu()},this._handleFeatureMenuBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this.featureMenuOpen&&this._closeFeatureMenu()},this._storeRootNode=e=>{this._rootNode=e},this._displaySpinnerThrottled=u(()=>this._displaySpinner(),B),!0!==e?.suppressDeprecationWarning&&s(n.getLogger(this),"Features","arcgis-features",{version:"4.34"}),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,l(()=>this.viewModel?.active,()=>this._toggleScreenLocationEnabled()),l(()=>this.viewModel?.active,e=>this._drillInWidget.closed=!e),l(()=>this.visibleElements?.closeButton,e=>this._drillInWidget.closable=e),l(()=>this.visibleElements?.spinner,e=>this._spinnerEnabledChange(e)),l(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),l(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),l(()=>[this.viewModel?.waitingForResult,this.viewModel?.location],()=>{this._hideSpinner(),this._displaySpinnerThrottled()}),l(()=>this.viewModel?.screenLocation,()=>this._closeOpenActionMenu()),l(()=>this.selectedFeatureWidget?.viewModel,()=>this._destroyDrillInFlowItemWidgets()),l(()=>this.featureMenuOpen,()=>this._drillInWidget.selectLastFlowItem="list"===this.initialDisplayMode||!this.featureMenuOpen,a),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]},()=>this._setTitleFromFeatureWidget()),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]},()=>this._setContentFromFeatureWidget()),l(()=>this.viewModel?.featureViewModels,()=>this._featureMenuViewportScrollTop()),l(()=>this._drillInFlowItems.length,()=>this._focusFlowItemNode()),this._drillInWidget.on("close",()=>this.close()),this._drillInWidget.on("exit",()=>this._destroyDrillInFlowItemWidgets()),this._drillInWidget.on("open-feature",({feature:e})=>this._openRelatedFeature(e)),this._drillInWidget.on("zoom-to-feature",({featureWidget:e})=>T(this.viewModel,e))])}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}loadDependencies(){return Promise.all([v(),N({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})])}destroy(){this._destroyDrillInFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._drillInWidget?.destroy(),this._focusAbortController?.abort()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&!!this.viewModel.selectedFeature&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&("list"===this.initialDisplayMode||!!this.title&&!!this.content)}get active(){return this.viewModel.active}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get icon(){return null}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get featureMenuTitle(){return this.viewModel.featureMenuTitle}set featureMenuTitle(e){this.viewModel.featureMenuTitle=e}get featureStream(){return this.viewModel.featureStream}set featureStream(e){this.viewModel.featureStream=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){const e=Array.from(this._drillInFlowItems).at(-1);if(!e)return null;const{flowType:t}=e;return"feature-association"===t||"feature-relationship"===t?e.graphic??null:null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_drillInFlowItems:i,timeZone:o,spatialReference:s,map:n}=this,{selectedFeatureViewModel:r}=this.viewModel,l={title:!1};return r?(e?(e.viewModel=r,e.visibleElements=l):this._feature=new _({flowItems:i,headingLevel:t+1,timeZone:o,spatialReference:s,map:n,viewModel:r,visibleElements:l,suppressDeprecationWarning:!0}),this._feature):null}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():n.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._focusFlowItemNode():n.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(S);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(d(()=>!this.viewModel.waitingForResult,()=>this._addSelectedFeatureIndexHandle(),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return E("div",{afterCreate:this._storeRootNode,bind:this,class:this.classes(b.base,k.widget,k.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),"list"===this.initialDisplayMode?this._renderFeaturePaginationText():this._renderFeatureMenuButton()]}_renderHeader(){return this.featureNavigationTop&&this._featureNavigationVisible?E("div",{class:b.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return!this.featureNavigationTop&&this._featureNavigationVisible?E("div",{class:b.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation()):null}_renderFeaturePaginationText(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n}=o;return E("div",{class:b.paginationText,key:"feature-pagination-text"},t(e.pageText,{index:i(n+1),total:i(s)}))}_renderFeatureMenuButton(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n,pendingPromisesCount:r}=o;return E("calcite-action",{bind:this,class:b.paginationMenuButton,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:r>0,text:t(e.pageText,{index:i(n+1),total:i(s)}),textEnabled:!0,title:e.selectFeature,onclick:this._handlePaginationMenuButton})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return E("calcite-action-bar",{class:b.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},E("calcite-action-group",{scale:"s"},E("calcite-action",{class:b.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,text:e,title:e,onclick:this._previousFeature}),E("calcite-action",{icon:"chevron-right",iconFlipRtl:!0,label:t,text:t,title:t,onclick:this._nextFeature})))}_renderFeatureMenuItem(e){const{initialDisplayMode:t}=this,{selectedFeatureViewModel:i,featureViewModels:o}=this.viewModel,s=e===i,n=o.indexOf(e);return E("calcite-list-item",{bind:this,"data-feature-index":n,key:`feature-menu-item-${e.uid}`,selected:s,onblur:this._removeActiveFeature,onCalciteListItemSelect:this._selectFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature},E("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}),"list"===t?E("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}):null)}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach(e=>{const i=e?.graphic;if(!i)return;const{layer:o,sourceLayer:s}=i,n=(R(o)?o:null)||(R(s)?s:null),r=t.get(n)??[];t.set(n,[...r,e])}),t}_renderFeatureMenu(){const{messages:e,viewModel:t}=this,i=this._groupResultsByLayer(),o="list"===this.initialDisplayMode?"none":"single";return t.featureViewModels.length?E("calcite-list",{displayMode:"flat",label:e?.featuresList,selectionAppearance:"icon",selectionMode:o},Array.from(i.keys(),e=>{const t=i.get(e)?.map(e=>this._renderFeatureMenuItem(e)),o=e?e.title??this.messagesCommon.untitled:null;return this.visibleElements.featureListLayerTitle&&null!==o?E("calcite-list-item-group",{heading:o,key:e?.uid||"map-graphics"},t):t})):null}_renderHeaderAction(e,t){const i=e.title||"";return e.visible?E("calcite-action",{active:"toggle"===e.type&&e.value,bind:this,"data-action-id":e.id,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon??void 0,indicator:e.indicator,key:`header-action-${t}`,loading:e.active,slot:"header-actions-end",text:i,title:i,onclick:this._triggerHeaderAction}):null}_renderHeaderActions(){return this.headerActions.map((e,t)=>this._renderHeaderAction(e,t)).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s,_drillInFlowItems:n,initialDisplayMode:r,selectedFeature:l,featureMenuOpen:a}=this,{title:d,active:c}=this.viewModel,u=t.heading&&d?d:"";if("list"===r&&!l)return null;const h=0===n.length&&("list"===r?!!l:!a);return E("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,bind:this,class:this.classes({[b.contentFeature]:!0,[b.flowItemCollapsed]:i}),closable:t.closeButton,closed:!c,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",selected:h,onCalciteFlowItemBack:this._handleFeatureBack,onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},u?E(O,{class:this.classes(b.featuresHeading,k.heading),innerHTML:u,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),E("div",{class:this.classes(b.container,b.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,visibleElements:i,featureMenuTitle:o,messages:s,messagesCommon:n,initialDisplayMode:r,featureMenuOpen:l,selectedFeature:a,_collapseEnabled:d,_isCollapsed:c,featureNavigationTop:u,headingLevel:h}=this,{active:p,featureViewModels:v,pendingPromisesCount:m}=e,{featureMenuHeading:g}=i,w=o??s.selectFeature;if("feature"===r&&!l)return null;const _="list"===r?!a:l;return E("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,bind:this,class:this.classes({[b.flowItemCollapsed]:c}),closable:"list"===r&&i.closeButton,closed:!p,collapsed:"list"===r&&c,collapseDirection:u?"down":"up",collapsible:"list"===r&&d,description:g?t(s.total,{total:v.length}):void 0,heading:g?w:void 0,headingLevel:h,key:"feature-menu",loading:e.waitingForContents,selected:_,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleFeatureMenuBack()},onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},"list"===r?this._renderHeaderActions():null,m>0?E("calcite-loader",{class:b.loader,inline:!0,key:"feature-menu-loader",label:n.loading,slot:"header-actions-end"}):null,E("div",{class:b.container},this._renderFeatureMenu()),E("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:b.featureMenuObserver}),"feature"===r?E("calcite-button",{appearance:"transparent",slot:"footer-start",width:"full",onclick:this._handleFeatureMenuBack},n.back):null)}_renderContentContainer(){const e="list"===this.initialDisplayMode?[this._renderFeatureMenuContainer(),this._renderContentFeature(),this._drillInWidget.render()]:[this._renderContentFeature(),this._drillInWidget.render(),this._renderFeatureMenuContainer()];return this.visibleElements.flow?E("calcite-flow",{key:"content-container"},e):e}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=m({action:e,feature:this.selectedFeature}),s={[b.icon]:!!t,[b.actionImage]:!!o};return t&&(s[t]=!0),o||t?E("span",{"aria-hidden":"true",class:this.classes(b.icon,s),key:"icon",styles:g(o)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?E("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},E("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map((e,t)=>{const i=this._getActionTitle(e);return w(e,{key:`action-${t}`,title:i,text:i,textEnabled:!this._hideActionText,onclick:this._triggerAction,bind:this},this._getFallbackIcon(e))})}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?E("div",{class:F.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyDrillInFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=(await(import("../geometry/operators/labelPointOperator.js"))).execute(i);this.open({features:[t],location:null!=o?o:void 0}),this._focusFlowItemNode()}_handlePaginationMenuButton(){this._updateFeatureMenu()}_openFeatureMenu(){this._updateFeatureMenu(!0)}_closeFeatureMenu(){this._updateFeatureMenu(!1)}_updateFeatureMenu(e=!this.featureMenuOpen){this.featureMenuOpen=e,this._focusFlowItemNode()}async _focusFlowItemNode(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await r(c(e));const t=this._rootNode?.querySelector("calcite-flow-item[selected]");L(t)}_storeRootFlowItemNode(e){this._rootFlowItemNode=e}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),"feature"===this.initialDisplayMode?this._handleFeatureMenuBack():this._focusFlowItemNode()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionTitle(e){const{messages:i,selectedFeature:o,messagesCommon:s}=this,{id:n}=e,r=o?.attributes,l=e.title??"",a="zoom-to-feature"===n?t(l,{messages:i}):"remove-selected-feature"===n?t(l,{messages:s}):"zoom-to-clustered-features"===n||"browse-clustered-features"===n?t(l,{messages:i}):e.title;return a&&r?t(a,r):a??""}_onMainKeydown(e){const{key:t}=e;"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode?.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=l(()=>this.viewModel?.selectedFeatureIndex,(e,t)=>this._selectedFeatureIndexUpdated(e,t));this.addHandles(e,S)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyDrillInFlowItemWidgets(),this._rootFlowItemNode?.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find(({uid:e})=>e===i);o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex(e=>e.uid===i),n=o.at(s);"toggle"===n?.type&&(n.value=!n.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new M({view:e}),e.ui.add(this._spinner,{key:j,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_destroyDrillInFlowItemWidgets(){this._drillInFlowItems.drain(e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),"activeCategory"in e.viewModel&&(e.viewModel.activeCategory=null),e.viewModel=null,e.destroy()})}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e}=this;e&&(e.view?.ui?.remove(e,j),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([h()],H.prototype,"_drillInFlowItems",void 0),e([h()],H.prototype,"_hideActionText",null),e([h()],H.prototype,"_featureNavigationVisible",null),e([h()],H.prototype,"_isCollapsed",null),e([h()],H.prototype,"_collapseEnabled",null),e([h({readOnly:!0})],H.prototype,"active",null),e([h()],H.prototype,"collapsed",void 0),e([h()],H.prototype,"content",null),e([h()],H.prototype,"icon",null),e([h()],H.prototype,"featureMenuOpen",null),e([h()],H.prototype,"featureMenuTitle",null),e([h()],H.prototype,"featureStream",null),e([h()],H.prototype,"featureNavigationTop",void 0),e([h()],H.prototype,"features",null),e([h()],H.prototype,"goToOverride",null),e([h({type:x})],H.prototype,"headerActions",void 0),e([h()],H.prototype,"headingLevel",void 0),e([h()],H.prototype,"initialDisplayMode",null),e([h()],H.prototype,"location",null),e([h()],H.prototype,"label",null),e([h()],H.prototype,"map",null),e([h(),W("esri/widgets/Features/t9n/Features")],H.prototype,"messages",void 0),e([h(),W("esri/t9n/common")],H.prototype,"messagesCommon",void 0),e([h()],H.prototype,"promises",null),e([h()],H.prototype,"responsiveActionsEnabled",void 0),e([h({readOnly:!0})],H.prototype,"selectedFeature",null),e([h({readOnly:!0})],H.prototype,"selectedDrillInFeature",null),e([h()],H.prototype,"selectedFeatureIndex",null),e([h({readOnly:!0})],H.prototype,"selectedFeatureWidget",null),e([h()],H.prototype,"spatialReference",null),e([h()],H.prototype,"title",null),e([h()],H.prototype,"timeZone",null),e([h()],H.prototype,"updateLocationEnabled",null),e([h()],H.prototype,"view",null),e([h({type:C}),D(["triggerAction","trigger-action"])],H.prototype,"viewModel",void 0),e([h({type:A,nonNullable:!0})],H.prototype,"visibleElements",void 0),e([h()],H.prototype,"visible",null),H=e([p("esri.widgets.Features")],H);export{H as default};
2
+ import{__decorate as e}from"tslib";import{substitute as t,formatNumber as i}from"../intl.js";import o from"../core/Collection.js";import{deprecateWidget as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as l,initial as a,when as d}from"../core/reactiveUtils.js";import{waitAnimationFrame as c}from"../core/scheduling.js";import{throttle as u}from"../core/throttle.js";import{property as h,subclass as p}from"../core/accessorSupport/decorators.js";import{loadActionUtilsComponents as v,substituteActionImage as m,getActionStyles as g,renderAction as w}from"../support/actions/actionUtils.js";import _ from"./Feature.js";import M from"./Spinner.js";import f from"./Widget.js";import{css as F}from"./Feature/resources.js";import{FeatureContentMixin as y}from"./Feature/support/FeatureContentMixin.js";import{css as b}from"./Features/css.js";import I from"./Features/FeaturesDrillIn.js";import C from"./Features/FeaturesViewModel.js";import A from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as x}from"./Popup/actions.js";import{zoomToLocation as T}from"./Popup/actionUtils.js";import{loadCalciteComponents as N}from"./support/componentsUtils.js";import{globalCss as k}from"./support/globalCss.js";import{Heading as O}from"./support/Heading.js";import{tsx as E,messageBundle as W,vmEvent as D}from"./support/widget.js";import{setFocus as L}from"./support/widgetUtils.js";const S="selected-index",B=25,j="features-spinner";function R(e){return e?.declaredClass.startsWith("esri.layers.")??!1}let H=class extends(y(f)){constructor(e,t){super(e,t),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._spinner=null,this._feature=null,this._focusAbortController=null,this._drillInFlowItems=new o,this._drillInWidget=new I({flowItems:this._drillInFlowItems}),this._rootNode=null,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._actionBarMenuNode=null,this.collapsed=!1,this.featureNavigationTop=!1,this.headerActions=new x,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new C({suppressDeprecationWarning:!0}),this.visibleElements=new A,this._previousFeature=()=>{this.viewModel.previous()},this._nextFeature=()=>{this.viewModel.next()},this._handleFeatureBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this._openFeatureMenu()},this._handleFeatureMenuBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this.featureMenuOpen&&this._closeFeatureMenu()},this._storeRootNode=e=>{this._rootNode=e},this._displaySpinnerThrottled=u(()=>this._displaySpinner(),B),!0!==e?.suppressDeprecationWarning&&s(n.getLogger(this),"Features","arcgis-features",{version:"4.34"}),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,l(()=>this.viewModel?.active,()=>this._toggleScreenLocationEnabled()),l(()=>this.viewModel?.active,e=>this._drillInWidget.closed=!e),l(()=>this.visibleElements?.closeButton,e=>this._drillInWidget.closable=e),l(()=>this.visibleElements?.spinner,e=>this._spinnerEnabledChange(e)),l(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),l(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),l(()=>[this.viewModel?.waitingForResult,this.viewModel?.location],()=>{this._hideSpinner(),this._displaySpinnerThrottled()}),l(()=>this.viewModel?.screenLocation,()=>this._closeOpenActionMenu()),l(()=>this.selectedFeatureWidget?.viewModel,()=>this._destroyDrillInFlowItemWidgets()),l(()=>this.featureMenuOpen,()=>this._drillInWidget.selectLastFlowItem="list"===this.initialDisplayMode||!this.featureMenuOpen,a),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]},()=>this._setTitleFromFeatureWidget()),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]},()=>this._setContentFromFeatureWidget()),l(()=>this.viewModel?.featureViewModels,()=>this._featureMenuViewportScrollTop()),l(()=>this._drillInFlowItems.length,()=>this._focusFlowItemNode()),this._drillInWidget.on("close",()=>this.close()),this._drillInWidget.on("exit",()=>this._destroyDrillInFlowItemWidgets()),this._drillInWidget.on("open-feature",({feature:e})=>this._openRelatedFeature(e)),this._drillInWidget.on("zoom-to-feature",({featureWidget:e})=>T(this.viewModel,e))])}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}loadDependencies(){return Promise.all([v(),N({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})])}destroy(){this._destroyDrillInFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._drillInWidget?.destroy(),this._focusAbortController?.abort()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&!!this.viewModel.selectedFeature&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&("list"===this.initialDisplayMode||!!this.title&&!!this.content)}get active(){return this.viewModel.active}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get icon(){return null}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get featureMenuTitle(){return this.viewModel.featureMenuTitle}set featureMenuTitle(e){this.viewModel.featureMenuTitle=e}get featureStream(){return this.viewModel.featureStream}set featureStream(e){this.viewModel.featureStream=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){const e=Array.from(this._drillInFlowItems).at(-1);if(!e)return null;const{flowType:t}=e;return"feature-association"===t||"feature-relationship"===t?e.graphic??null:null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_drillInFlowItems:i,timeZone:o,spatialReference:s,map:n}=this,{selectedFeatureViewModel:r}=this.viewModel,l={title:!1};return r?(e?(e.viewModel=r,e.visibleElements=l):this._feature=new _({flowItems:i,headingLevel:t+1,timeZone:o,spatialReference:s,map:n,viewModel:r,visibleElements:l,suppressDeprecationWarning:!0}),this._feature):null}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():n.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._focusFlowItemNode():n.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(S);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(d(()=>!this.viewModel.waitingForResult,()=>this._addSelectedFeatureIndexHandle(),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return E("div",{afterCreate:this._storeRootNode,bind:this,class:this.classes(b.base,k.widget,k.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),"list"===this.initialDisplayMode?this._renderFeaturePaginationText():this._renderFeatureMenuButton()]}_renderHeader(){return this.featureNavigationTop&&this._featureNavigationVisible?E("div",{class:b.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return!this.featureNavigationTop&&this._featureNavigationVisible?E("div",{class:b.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation()):null}_renderFeaturePaginationText(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n}=o;return E("div",{class:b.paginationText,key:"feature-pagination-text"},t(e.pageText,{index:i(n+1),total:i(s)}))}_renderFeatureMenuButton(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n,pendingPromisesCount:r,streamingFeatures:l}=o,a=r>0||l;return E("calcite-action",{bind:this,class:b.paginationMenuButton,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:a,text:t(e.pageText,{index:i(n+1),total:i(s)}),textEnabled:!0,title:e.selectFeature,onclick:this._handlePaginationMenuButton})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return E("calcite-action-bar",{class:b.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},E("calcite-action-group",{scale:"s"},E("calcite-action",{class:b.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,text:e,title:e,onclick:this._previousFeature}),E("calcite-action",{icon:"chevron-right",iconFlipRtl:!0,label:t,text:t,title:t,onclick:this._nextFeature})))}_renderFeatureMenuItem(e){const{initialDisplayMode:t}=this,{selectedFeatureViewModel:i,featureViewModels:o}=this.viewModel,s=e===i,n=o.indexOf(e);return E("calcite-list-item",{bind:this,"data-feature-index":n,key:`feature-menu-item-${e.uid}`,selected:s,onblur:this._removeActiveFeature,onCalciteListItemSelect:this._selectFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature},E("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}),"list"===t?E("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}):null)}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach(e=>{const i=e?.graphic;if(!i)return;const{layer:o,sourceLayer:s}=i,n=(R(o)?o:null)||(R(s)?s:null),r=t.get(n)??[];t.set(n,[...r,e])}),t}_renderFeatureMenu(){const{messages:e,viewModel:t}=this,i=this._groupResultsByLayer(),o="list"===this.initialDisplayMode?"none":"single";return t.featureViewModels.length?E("calcite-list",{displayMode:"flat",label:e?.featuresList,selectionAppearance:"icon",selectionMode:o},Array.from(i.keys(),e=>{const t=i.get(e)?.map(e=>this._renderFeatureMenuItem(e)),o=e?e.title??this.messagesCommon.untitled:null;return this.visibleElements.featureListLayerTitle&&null!==o?E("calcite-list-item-group",{heading:o,key:e?.uid||"map-graphics"},t):t})):null}_renderHeaderAction(e,t){const i=e.title||"";return e.visible?E("calcite-action",{active:"toggle"===e.type&&e.value,bind:this,"data-action-id":e.id,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon??void 0,indicator:e.indicator,key:`header-action-${t}`,loading:e.active,slot:"header-actions-end",text:i,title:i,onclick:this._triggerHeaderAction}):null}_renderHeaderActions(){return this.headerActions.map((e,t)=>this._renderHeaderAction(e,t)).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s,_drillInFlowItems:n,initialDisplayMode:r,selectedFeature:l,featureMenuOpen:a}=this,{title:d,active:c}=this.viewModel,u=t.heading&&d?d:"";if("list"===r&&!l)return null;const h=0===n.length&&("list"===r?!!l:!a);return E("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,bind:this,class:this.classes({[b.contentFeature]:!0,[b.flowItemCollapsed]:i}),closable:t.closeButton,closed:!c,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",selected:h,onCalciteFlowItemBack:this._handleFeatureBack,onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},u?E(O,{class:this.classes(b.featuresHeading,k.heading),innerHTML:u,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),E("div",{class:this.classes(b.container,b.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,visibleElements:i,featureMenuTitle:o,messages:s,messagesCommon:n,initialDisplayMode:r,featureMenuOpen:l,selectedFeature:a,_collapseEnabled:d,_isCollapsed:c,featureNavigationTop:u,headingLevel:h}=this,{active:p,featureViewModels:v,pendingPromisesCount:m,streamingFeatures:g}=e,w=m>0||g,{featureMenuHeading:_}=i,M=o??s.selectFeature;if("feature"===r&&!l)return null;const f="list"===r?!a:l;return E("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,bind:this,class:this.classes({[b.flowItemCollapsed]:c}),closable:"list"===r&&i.closeButton,closed:!p,collapsed:"list"===r&&c,collapseDirection:u?"down":"up",collapsible:"list"===r&&d,description:_?t(s.total,{total:v.length}):void 0,heading:_?M:void 0,headingLevel:h,key:"feature-menu",loading:e.waitingForContents,selected:f,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleFeatureMenuBack()},onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},"list"===r?this._renderHeaderActions():null,w?E("calcite-loader",{class:b.loader,inline:!0,key:"feature-menu-loader",label:n.loading,slot:"header-actions-end"}):null,E("div",{class:b.container},this._renderFeatureMenu()),E("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:b.featureMenuObserver}),"feature"===r?E("calcite-button",{appearance:"transparent",slot:"footer-start",width:"full",onclick:this._handleFeatureMenuBack},n.back):null)}_renderContentContainer(){const e="list"===this.initialDisplayMode?[this._renderFeatureMenuContainer(),this._renderContentFeature(),this._drillInWidget.render()]:[this._renderContentFeature(),this._drillInWidget.render(),this._renderFeatureMenuContainer()];return this.visibleElements.flow?E("calcite-flow",{key:"content-container"},e):e}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=m({action:e,feature:this.selectedFeature}),s={[b.icon]:!!t,[b.actionImage]:!!o};return t&&(s[t]=!0),o||t?E("span",{"aria-hidden":"true",class:this.classes(b.icon,s),key:"icon",styles:g(o)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?E("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},E("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map((e,t)=>{const i=this._getActionTitle(e);return w(e,{key:`action-${t}`,title:i,text:i,textEnabled:!this._hideActionText,onclick:this._triggerAction,bind:this},this._getFallbackIcon(e))})}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?E("div",{class:F.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyDrillInFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=(await(import("../geometry/operators/labelPointOperator.js"))).execute(i);this.open({features:[t],location:null!=o?o:void 0}),this._focusFlowItemNode()}_handlePaginationMenuButton(){this._updateFeatureMenu()}_openFeatureMenu(){this._updateFeatureMenu(!0)}_closeFeatureMenu(){this._updateFeatureMenu(!1)}_updateFeatureMenu(e=!this.featureMenuOpen){this.featureMenuOpen=e,this._focusFlowItemNode()}async _focusFlowItemNode(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await r(c(e));const t=this._rootNode?.querySelector("calcite-flow-item[selected]");L(t)}_storeRootFlowItemNode(e){this._rootFlowItemNode=e}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),"feature"===this.initialDisplayMode?this._handleFeatureMenuBack():this._focusFlowItemNode()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionTitle(e){const{messages:i,selectedFeature:o,messagesCommon:s}=this,{id:n}=e,r=o?.attributes,l=e.title??"",a="zoom-to-feature"===n?t(l,{messages:i}):"remove-selected-feature"===n?t(l,{messages:s}):"zoom-to-clustered-features"===n||"browse-clustered-features"===n?t(l,{messages:i}):e.title;return a&&r?t(a,r):a??""}_onMainKeydown(e){const{key:t}=e;"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode?.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=l(()=>this.viewModel?.selectedFeatureIndex,(e,t)=>this._selectedFeatureIndexUpdated(e,t));this.addHandles(e,S)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyDrillInFlowItemWidgets(),this._rootFlowItemNode?.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find(({uid:e})=>e===i);o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex(e=>e.uid===i),n=o.at(s);"toggle"===n?.type&&(n.value=!n.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new M({view:e}),e.ui.add(this._spinner,{key:j,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_destroyDrillInFlowItemWidgets(){this._drillInFlowItems.drain(e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),"activeCategory"in e.viewModel&&(e.viewModel.activeCategory=null),e.viewModel=null,e.destroy()})}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e}=this;e&&(e.view?.ui?.remove(e,j),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([h()],H.prototype,"_drillInFlowItems",void 0),e([h()],H.prototype,"_hideActionText",null),e([h()],H.prototype,"_featureNavigationVisible",null),e([h()],H.prototype,"_isCollapsed",null),e([h()],H.prototype,"_collapseEnabled",null),e([h({readOnly:!0})],H.prototype,"active",null),e([h()],H.prototype,"collapsed",void 0),e([h()],H.prototype,"content",null),e([h()],H.prototype,"icon",null),e([h()],H.prototype,"featureMenuOpen",null),e([h()],H.prototype,"featureMenuTitle",null),e([h()],H.prototype,"featureStream",null),e([h()],H.prototype,"featureNavigationTop",void 0),e([h()],H.prototype,"features",null),e([h()],H.prototype,"goToOverride",null),e([h({type:x})],H.prototype,"headerActions",void 0),e([h()],H.prototype,"headingLevel",void 0),e([h()],H.prototype,"initialDisplayMode",null),e([h()],H.prototype,"location",null),e([h()],H.prototype,"label",null),e([h()],H.prototype,"map",null),e([h(),W("esri/widgets/Features/t9n/Features")],H.prototype,"messages",void 0),e([h(),W("esri/t9n/common")],H.prototype,"messagesCommon",void 0),e([h()],H.prototype,"promises",null),e([h()],H.prototype,"responsiveActionsEnabled",void 0),e([h({readOnly:!0})],H.prototype,"selectedFeature",null),e([h({readOnly:!0})],H.prototype,"selectedDrillInFeature",null),e([h()],H.prototype,"selectedFeatureIndex",null),e([h({readOnly:!0})],H.prototype,"selectedFeatureWidget",null),e([h()],H.prototype,"spatialReference",null),e([h()],H.prototype,"title",null),e([h()],H.prototype,"timeZone",null),e([h()],H.prototype,"updateLocationEnabled",null),e([h()],H.prototype,"view",null),e([h({type:C}),D(["triggerAction","trigger-action"])],H.prototype,"viewModel",void 0),e([h({type:A,nonNullable:!0})],H.prototype,"visibleElements",void 0),e([h()],H.prototype,"visible",null),H=e([p("esri.widgets.Features")],H);export{H as default};