@arcgis/core 4.34.0-next.52 → 4.34.0-next.54

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 (139) hide show
  1. package/applications/Components/formatUtils.d.ts +3 -0
  2. package/applications/Components/formatUtils.js +5 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{35fc8a64674005b1d1d7.js → 0a4357af5b8c0532b439.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{e58336aafe8c95bb6831.js → 0eb728cee6e40cb30c01.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{b87ed14fde381f79bc9f.js → 17776d9d3558d45ea7b5.js} +1 -1
  7. package/assets/esri/core/workers/chunks/23f54b49742098def8ae.js +1 -0
  8. package/assets/esri/core/workers/chunks/2efa4d8fe5454f8b2a05.js +1 -0
  9. package/assets/esri/core/workers/chunks/{a69e885336eb5d2729fd.js → 3505988ce3839cdbbc98.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{46ab551bd19e52e73649.js → 3800764932a1c32cb29f.js} +1 -1
  11. package/assets/esri/core/workers/chunks/3c57b2e13628b5c1f6de.js +1 -0
  12. package/assets/esri/core/workers/chunks/435169b455fd2846799b.js +1 -0
  13. package/assets/esri/core/workers/chunks/{77493aa2118d462612a0.js → 43bd338bb0de375b9bb7.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{5a016dcd3192d42d363e.js → 5fc414fc2cfc68828c5b.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{ecd673eccf89643df07a.js → 659f7e99b2d524ef53fb.js} +2 -2
  16. package/assets/esri/core/workers/chunks/69e6000044bfb03776ac.js +1 -0
  17. package/assets/esri/core/workers/chunks/{037bc400257bc13b3ec8.js → 772e81e9162e2240a7a6.js} +1 -1
  18. package/assets/esri/core/workers/chunks/813efde41e90e652b7db.js +1 -0
  19. package/assets/esri/core/workers/chunks/82404ff7c298493ff6f4.js +1 -0
  20. package/assets/esri/core/workers/chunks/{f1de768b0a6d345f7e39.js → 8f6ff09e7d2f01b79faf.js} +1 -1
  21. package/assets/esri/core/workers/chunks/9639a6f6fab52a501bf7.js +1 -0
  22. package/assets/esri/core/workers/chunks/{cfa8b17cf1349f6ed355.js → 9e9be7f6ea32957f1088.js} +1 -1
  23. package/assets/esri/core/workers/chunks/9fef330b241f958b55df.js +1 -0
  24. package/assets/esri/core/workers/chunks/aab349d4624b78ef429f.js +1 -0
  25. package/assets/esri/core/workers/chunks/b9f5672093727c6f92c9.js +1 -0
  26. package/assets/esri/core/workers/chunks/bcc233a86e01ff1eac16.js +1 -0
  27. package/assets/esri/core/workers/chunks/cac060a187f3a27a19ba.js +1 -0
  28. package/assets/esri/core/workers/chunks/cda27c0fafd687dfa72e.js +1 -0
  29. package/assets/esri/core/workers/chunks/{82a390be9500b629f6bc.js → d0bf1fc6e3c198bc565d.js} +1 -1
  30. package/assets/esri/core/workers/chunks/dd120d562b63618e71c0.js +1 -0
  31. package/assets/esri/core/workers/chunks/dd2b5f115d156b5b212e.js +1 -0
  32. package/assets/esri/core/workers/chunks/e28d3ed65c3a76a044c8.js +1 -0
  33. package/assets/esri/core/workers/chunks/{fb4950995f6780f6c22a.js → ee0286b5f5475f2d853f.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{c5b2a261d8c216ca4a10.js → f8505bf69795f5293a79.js} +1 -1
  35. package/assets/esri/core/workers/chunks/fae6030a81cb91a91b69.js +1 -0
  36. package/assets/esri/core/workers/chunks/ff7962063d132c1ec814.js +1 -0
  37. package/assets/esri/themes/base/widgets/_FloorFilter.scss +23 -19
  38. package/assets/esri/themes/dark/main.css +1 -1
  39. package/assets/esri/themes/light/main.css +1 -1
  40. package/assets/esri/themes/light/view.css +1 -1
  41. package/config.js +1 -1
  42. package/geometry/operators/json/graphicBufferOperator.js +5 -0
  43. package/geometry/support/coordinateSystem.js +1 -1
  44. package/interfaces.d.ts +93 -185
  45. package/kernel.js +1 -1
  46. package/layers/KMLLayer.js +1 -1
  47. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  48. package/layers/graphics/data/QueryEngine.js +1 -1
  49. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  50. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  51. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  52. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  53. package/layers/support/ElevationQuery.js +1 -1
  54. package/layers/support/ExportImageParameters.js +1 -1
  55. package/networks/UtilityNetwork.js +1 -1
  56. package/networks/support/typeUtils.js +1 -1
  57. package/package.json +3 -3
  58. package/portal/Portal.js +1 -1
  59. package/renderers/support/rasterRendererHelper.js +1 -1
  60. package/renderers/support/utils.js +1 -1
  61. package/rest/featureService/FeatureService.js +1 -1
  62. package/rest/networks/support/Circuit.js +5 -0
  63. package/rest/networks/support/CircuitSection.js +1 -1
  64. package/rest/networks/support/Subcircuit.js +1 -1
  65. package/rest/print.js +1 -1
  66. package/support/revision.js +1 -1
  67. package/symbols/cim/CIMEffects.js +1 -1
  68. package/symbols/cim/effects/EffectOffset.js +1 -1
  69. package/views/2d/analysisViewModuleImportUtils.js +5 -0
  70. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  71. package/views/2d/input/MapViewInputManager.js +1 -1
  72. package/views/2d/layers/LayerView2D.js +1 -1
  73. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  74. package/views/3d/analysis/ElevationProfile/HoveredPointsVisualization.js +1 -1
  75. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  76. package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
  77. package/views/3d/analysisViewModuleImportUtils.js +5 -0
  78. package/views/3d/input/SceneInputManager.js +1 -1
  79. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  80. package/views/3d/interactive/editingTools/manipulations/MoveManipulation.js +1 -1
  81. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  82. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  83. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  84. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  85. package/views/3d/terrain/TerrainSurface.js +1 -1
  86. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  87. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  88. package/views/SceneView.js +1 -1
  89. package/views/ToolViewManager.js +1 -1
  90. package/views/View.js +1 -1
  91. package/views/View2D.js +1 -1
  92. package/views/draw/Draw.js +1 -1
  93. package/views/draw/DrawGraphicTool.js +1 -1
  94. package/views/draw/DrawOperation.js +1 -1
  95. package/views/draw/LegacyDrawManipulator.js +1 -1
  96. package/views/draw/support/Box.js +1 -1
  97. package/views/draw/support/GraphicMover.js +1 -1
  98. package/views/draw/support/Reshape.js +1 -1
  99. package/views/input/InputManager.js +1 -1
  100. package/views/input/handlers/LatestPointer.js +1 -1
  101. package/views/interactive/InteractiveToolBase.js +1 -1
  102. package/views/interactive/ToolViewManagerManipulatorState.js +1 -1
  103. package/views/interactive/Tooltip.js +1 -1
  104. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  105. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  106. package/views/layers/support/popupUtils.js +1 -1
  107. package/views/support/AnalysisViewManager.js +5 -0
  108. package/views/support/PromiseQueue.js +5 -0
  109. package/views/support/Scheduler.js +1 -1
  110. package/widgets/Feature/FeatureViewModel.js +1 -1
  111. package/widgets/FeatureTable/Grid/support/ButtonMenu.js +1 -1
  112. package/widgets/FloorFilter/css.js +1 -1
  113. package/widgets/FloorFilter.js +1 -1
  114. package/widgets/HistogramRangeSlider.js +1 -1
  115. package/widgets/Sketch/SketchViewModel.js +1 -1
  116. package/widgets/support/ItemList.js +1 -1
  117. package/assets/esri/core/workers/chunks/0874b88d5ae7c2b78b3b.js +0 -1
  118. package/assets/esri/core/workers/chunks/0c129b78e5cfe96795e1.js +0 -1
  119. package/assets/esri/core/workers/chunks/1a3a4c2c642899be37a0.js +0 -1
  120. package/assets/esri/core/workers/chunks/2b75212c31145cc07d16.js +0 -1
  121. package/assets/esri/core/workers/chunks/37a97e690786814bf0b3.js +0 -1
  122. package/assets/esri/core/workers/chunks/48e64f99720907017778.js +0 -1
  123. package/assets/esri/core/workers/chunks/4c6862ad3af947c704f7.js +0 -1
  124. package/assets/esri/core/workers/chunks/4d544e3e19ce07c2c195.js +0 -1
  125. package/assets/esri/core/workers/chunks/781b59ba0cabe78bc122.js +0 -1
  126. package/assets/esri/core/workers/chunks/8c1bd9bcfc59497de3b5.js +0 -1
  127. package/assets/esri/core/workers/chunks/8cc700da2ac58849a708.js +0 -1
  128. package/assets/esri/core/workers/chunks/9b7fee0adffeee8d45ae.js +0 -1
  129. package/assets/esri/core/workers/chunks/9d30fed26e0d84ef893b.js +0 -1
  130. package/assets/esri/core/workers/chunks/b29f0b32787edb4e75cf.js +0 -1
  131. package/assets/esri/core/workers/chunks/b877142a275188a16e17.js +0 -1
  132. package/assets/esri/core/workers/chunks/c87bb42f825c39f9cce3.js +0 -1
  133. package/assets/esri/core/workers/chunks/cc0cb4906e4419f7c4a9.js +0 -1
  134. package/assets/esri/core/workers/chunks/f667096ea325f690c4a6.js +0 -1
  135. package/assets/esri/core/workers/chunks/f9f94b5efa9a64cdb407.js +0 -1
  136. package/layers/graphics/data/executeQueryForSnapping.js +0 -5
  137. package/layers/support/PromiseQueue.js +0 -5
  138. package/views/3d/analysis/AnalysisViewManager3D.js +0 -5
  139. /package/assets/esri/core/workers/chunks/{ecd673eccf89643df07a.js.LICENSE.txt → 659f7e99b2d524ef53fb.js.LICENSE.txt} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{on as o}from"../../core/events.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as i,when as s,syncAndInitial as r,initial as l,sync as a}from"../../core/reactiveUtils.js";import{cloneScreenPoint as c,createScreenPoint as p}from"../../core/screenUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../core/support/UpdatingHandles.js";import{setCalciteModeClass as f}from"../../support/modeUtils.js";import{base as m}from"./tooltip/css.js";import{tooltipContentFactory as g}from"./tooltip/content/tooltipContentFactory.js";import{isRTL as y}from"../../widgets/support/widgetUtils.js";const v={base:`${m}`,ltr:`${m}--ltr`,rtl:`${m}--rtl`,debug:`${m}--debug`},_=20,C=16,b="bottom-end";let P=class extends e{constructor(t){super(t),this.info=null,this.options=null,this.position=null,this.content=null,this._focused=!1,this.outerContainer=document.createElement("div"),this.debug=!1,this._updatingHandles=new h,this._lastPosition=null,this._rtl=!1,this._prevXY=[0,0]}initialize(){const{outerContainer:t}=this;this.addHandles([i(()=>this.view.overlay?.surface,e=>{t.remove(),e?.appendChild(t),this._rtl=y(e)},r),i(()=>this.info,(e,o)=>{if(null!=this.content&&null!=e&&null!=o&&e.type===o.type)this.content.info=e;else{n(this.content);const o=g(this,e);o?(this.content=o,o.container&&t.appendChild(o.container),this.exitInputMode()):this.content=null}},r),i(()=>({container:this.outerContainer,style:this._outerContainerStyle}),({container:t,style:e})=>{Object.assign(t.style,e)},l),i(()=>({outerContainer:this.outerContainer,placement:this.effectivePlacement,effectiveOffset:this._effectiveOffset,rtl:this._rtl,debug:this.debug}),({outerContainer:t,placement:e,effectiveOffset:o,rtl:n,debug:i})=>{const{classList:s}=t;s.add(v.base),s.toggle(v.rtl,n),s.toggle(v.ltr,!n),s.toggle(v.debug,i),this.outerContainer.style.setProperty("--offset",`${o}px`),f(t),x(t,e)},l),s(()=>"feedback"===this.mode,()=>{this.position=null,this._clearOverride("effectivePlacement")},a),o(this.outerContainer,"paste",t=>{this.emit("paste",t)}),o(this.outerContainer,["focusin","focusout"],()=>{this._focused=this.content?.container?.contains(document.activeElement)??!1})])}destroy(){this.info=null,this.content=n(this.content),this.outerContainer.remove()}get mode(){return this.content?.mode??"feedback"}get focused(){return this._focused}get visible(){return"none"!==this._outerContainerStyle.display}get contentContainer(){return this.content?.container}get effectivePlacement(){const t=this.options?.placement;return"auto"===t?"bottom-end":t??b}get updating(){return this._updatingHandles.updating}get _screenPoint(){const{inputManager:t}=this.view;return t?.multiTouchActive?null:t?.latestPointerLocation}get _effectiveOffset(){return this.options?.offset??_}get _outerContainerStyle(){const t=this.position??this._screenPoint;if(this._lastPosition=c(t),null!=t&&null!=this.content){return{display:"block",transform:`translate(${Math.round(t.x)}px, ${Math.round(t.y)}px)`}}return{display:"none",transform:"none"}}clear(){this.info=null}async enterInputMode(t){const e=this.position??this._lastPosition??this._screenPoint,o=this.position=c(e),{effectivePlacement:n}=this;this._override("effectivePlacement",n);const i=()=>{o&&(this.position=j(this.contentContainer,o,this._effectiveOffset,this.view),Object.assign(this.outerContainer.style,this._outerContainerStyle))};await this._updatingHandles.addPromise(this.content?.enterInputMode(t,i))}async exitInputMode(t){await this._updatingHandles.addPromise(this.content?.exitInputMode(t))}onDragStart(t,e){this._prevXY=[t,e]}onDrag(t,e){const o=t-this._prevXY[0],n=e-this._prevXY[1];this._prevXY=[t,e];const{position:i}=this;if(i){const{view:s}=this,r=t-s.position[0],l=e-s.position[1];if(r<0||r>s.width||l<0||l>s.height-C)return;this.position=p(i.x+o,i.y+n)}}onDragEnd(){this._prevXY=[0,0]}};function j(t,e,o,n){if(!t||!n.container)return e;const i=t.getBoundingClientRect(),{left:s,top:r}=n.container.getBoundingClientRect();let{x:l,y:a}=e;const c=i.left-s-o;c<0&&(l-=c);const u=i.right-s+o-n.width;u>0&&(l-=u);const d=i.top-r-o;d<0&&(a-=d);const h=i.bottom-r+o-n.height;return h>0&&(a-=h),p(l,a)}t([u({nonNullable:!0})],P.prototype,"view",void 0),t([u()],P.prototype,"info",void 0),t([u()],P.prototype,"options",void 0),t([u()],P.prototype,"position",void 0),t([u()],P.prototype,"content",void 0),t([u({readOnly:!0})],P.prototype,"mode",null),t([u()],P.prototype,"_focused",void 0),t([u({readOnly:!0})],P.prototype,"focused",null),t([u({readOnly:!0})],P.prototype,"outerContainer",void 0),t([u({readOnly:!0})],P.prototype,"contentContainer",null),t([u({readOnly:!0})],P.prototype,"effectivePlacement",null),t([u()],P.prototype,"debug",void 0),t([u()],P.prototype,"updating",null),t([u()],P.prototype,"_lastPosition",void 0),t([u()],P.prototype,"_screenPoint",null),t([u()],P.prototype,"_rtl",void 0),t([u()],P.prototype,"_effectiveOffset",null),t([u()],P.prototype,"_outerContainerStyle",null),P=t([d("esri.views.interactive.Tooltip")],P);const O=["top","bottom","leading","trailing"].flatMap(t=>[w(`${t}-start`),w(t),w(`${t}-end`)]);function w(t){return`${v.base}--${t}`}function x({classList:t},e){O.forEach(e=>t.remove(e)),t.add(w(e))}export{P as default};
5
+ import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{on as o}from"../../core/events.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as i,when as s,syncAndInitial as r,initial as l,sync as a}from"../../core/reactiveUtils.js";import{cloneScreenPoint as c,createScreenPoint as p}from"../../core/screenUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../core/support/UpdatingHandles.js";import{setCalciteModeClass as f}from"../../support/modeUtils.js";import{base as m}from"./tooltip/css.js";import{tooltipContentFactory as g}from"./tooltip/content/tooltipContentFactory.js";import{isRTL as y}from"../../widgets/support/widgetUtils.js";const v={base:`${m}`,ltr:`${m}--ltr`,rtl:`${m}--rtl`,debug:`${m}--debug`},_=20,C=16,b="bottom-end";let P=class extends e{constructor(t){super(t),this.info=null,this.options=null,this.position=null,this.content=null,this._focused=!1,this.outerContainer=document.createElement("div"),this.debug=!1,this._updatingHandles=new h,this._lastPosition=null,this._rtl=!1,this._prevXY=[0,0]}initialize(){const{outerContainer:t}=this;this.addHandles([i(()=>this.view.overlay?.surface,e=>{t.remove(),e?.appendChild(t),this._rtl=y(e)},r),i(()=>this.info,(e,o)=>{if(null!=this.content&&null!=e&&null!=o&&e.type===o.type)this.content.info=e;else{n(this.content);const o=g(this,e);o?(this.content=o,o.container&&t.appendChild(o.container),this.exitInputMode()):this.content=null}},r),i(()=>({container:this.outerContainer,style:this._outerContainerStyle}),({container:t,style:e})=>{Object.assign(t.style,e)},l),i(()=>({outerContainer:this.outerContainer,placement:this.effectivePlacement,effectiveOffset:this._effectiveOffset,rtl:this._rtl,debug:this.debug}),({outerContainer:t,placement:e,effectiveOffset:o,rtl:n,debug:i})=>{const{classList:s}=t;s.add(v.base),s.toggle(v.rtl,n),s.toggle(v.ltr,!n),s.toggle(v.debug,i),this.outerContainer.style.setProperty("--offset",`${o}px`),f(t),x(t,e)},l),s(()=>"feedback"===this.mode,()=>{this.position=null,this._clearOverride("effectivePlacement")},a),o(this.outerContainer,"paste",t=>{this.emit("paste",t)}),o(this.outerContainer,["focusin","focusout"],()=>{this._focused=this.content?.container?.contains(document.activeElement)??!1})])}destroy(){this.info=null,this.content=n(this.content),this.outerContainer.remove()}get mode(){return this.content?.mode??"feedback"}get focused(){return this._focused}get visible(){return"none"!==this._outerContainerStyle.display}get contentContainer(){return this.content?.container}get effectivePlacement(){const t=this.options?.placement;return"auto"===t?"bottom-end":t??b}get updating(){return this._updatingHandles.updating}get _screenPoint(){const{inputManager:t}=this.view;return t?.multiTouchActive?null:t?.latestPointerInfo?.location}get _effectiveOffset(){return this.options?.offset??_}get _outerContainerStyle(){const t=this.position??this._screenPoint;if(this._lastPosition=c(t),null!=t&&null!=this.content){return{display:"block",transform:`translate(${Math.round(t.x)}px, ${Math.round(t.y)}px)`}}return{display:"none",transform:"none"}}clear(){this.info=null}async enterInputMode(t){const e=this.position??this._lastPosition??this._screenPoint,o=this.position=c(e),{effectivePlacement:n}=this;this._override("effectivePlacement",n);const i=()=>{o&&(this.position=j(this.contentContainer,o,this._effectiveOffset,this.view),Object.assign(this.outerContainer.style,this._outerContainerStyle))};await this._updatingHandles.addPromise(this.content?.enterInputMode(t,i))}async exitInputMode(t){await this._updatingHandles.addPromise(this.content?.exitInputMode(t))}onDragStart(t,e){this._prevXY=[t,e]}onDrag(t,e){const o=t-this._prevXY[0],n=e-this._prevXY[1];this._prevXY=[t,e];const{position:i}=this;if(i){const{view:s}=this,r=t-s.position[0],l=e-s.position[1];if(r<0||r>s.width||l<0||l>s.height-C)return;this.position=p(i.x+o,i.y+n)}}onDragEnd(){this._prevXY=[0,0]}};function j(t,e,o,n){if(!t||!n.container)return e;const i=t.getBoundingClientRect(),{left:s,top:r}=n.container.getBoundingClientRect();let{x:l,y:a}=e;const c=i.left-s-o;c<0&&(l-=c);const u=i.right-s+o-n.width;u>0&&(l-=u);const d=i.top-r-o;d<0&&(a-=d);const h=i.bottom-r+o-n.height;return h>0&&(a-=h),p(l,a)}t([u({nonNullable:!0})],P.prototype,"view",void 0),t([u()],P.prototype,"info",void 0),t([u()],P.prototype,"options",void 0),t([u()],P.prototype,"position",void 0),t([u()],P.prototype,"content",void 0),t([u({readOnly:!0})],P.prototype,"mode",null),t([u()],P.prototype,"_focused",void 0),t([u({readOnly:!0})],P.prototype,"focused",null),t([u({readOnly:!0})],P.prototype,"outerContainer",void 0),t([u({readOnly:!0})],P.prototype,"contentContainer",null),t([u({readOnly:!0})],P.prototype,"effectivePlacement",null),t([u()],P.prototype,"debug",void 0),t([u()],P.prototype,"updating",null),t([u()],P.prototype,"_lastPosition",void 0),t([u()],P.prototype,"_screenPoint",null),t([u()],P.prototype,"_rtl",void 0),t([u()],P.prototype,"_effectiveOffset",null),t([u()],P.prototype,"_outerContainerStyle",null),P=t([d("esri.views.interactive.Tooltip")],P);const O=["top","bottom","leading","trailing"].flatMap(t=>[w(`${t}-start`),w(t),w(`${t}-end`)]);function w(t){return`${v.base}--${t}`}function x({classList:t},e){O.forEach(e=>t.remove(e)),t.add(w(e))}export{P as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{removeUnordered as o}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as i,allSettledValues as n,whenOrAbort as a}from"../../../../core/promiseUtils.js";import{initial as p,watch as l,on as d}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import y from"../../../../geometry/Polygon.js";import{initializeProjection as m,canProjectWithoutEngine as g,project as f}from"../../../../geometry/projectionUtils.js";import{normalizeCentralMeridianForDisplay as _}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as v}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as S}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as w}from"../../../../layers/graphics/OptimizedFeature.js";import{executeQueryForSnapping as j}from"../../../../layers/graphics/data/executeQueryForSnapping.js";import b from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as E}from"../../../../layers/graphics/data/QueryEngine.js";import k from"../../../../layers/support/FieldsIndex.js";import{elevationContextAffectsAlignment as C}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as F}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as A,makeSnappingQuery as I}from"../snappingUtils.js";import{convertSnappingCandidate as P,makeGetGroundElevation as G}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as H}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as R}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as U}from"./symbologySnappingCandidates.js";import{TaskPriority as x}from"../../../support/Scheduler.js";const z="graphics-collections";let O=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,o=null!=e&&"3d"===e.type;if(!o||"map-notes"===t.type)return H();const r=async(o,r)=>(await a(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(o,r);return H(o,{elevationInfo:t.elevationInfo,alignPointsInFeatures:r})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return R(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,o=null!=e&&"3d"===e.type,r=this._extrudedPolygonSymbolsCount>0;return o&&"map-notes"!==t.type&&r?U(r,async(o,r)=>{const s=await e.whenLayerView(t);return i(r),s.queryForSymbologySnapping({candidates:o,spatialReference:e.spatialReference},r)}):U()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new h,this._memoizedMakeGetGroundElevation=s(G)}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources(e=>this._destroySource(e)),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add(()=>this.getGraphicsLayers(),e=>{this._updatingHandles.removeHandles(z);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",e=>this._onGraphicUpdate(e)),this._updatingHandles.addOnCollectionChange(()=>t.graphics,e=>this._onGraphicsChanged(e))],z)},p);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&e.elevationProvider&&this.addHandles([e.elevationProvider.on("elevation-change",({context:e})=>{C(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()}),l(()=>t.elevationInfo,()=>this._snappingElevationAligner.notifyElevationSourceChange(),p),d(()=>t,["edits","apply-edits","graphic-update"],()=>this._symbologySnappingFetcher.notifySymbologyChange())])}async fetchCandidates(e,t){const{point:o,coordinateHelper:{spatialReference:r}}=e,s=await n(this._mapSources(o=>this._fetchCandidatesForSource(o,e,t)));i(t);const a=this._memoizedMakeGetGroundElevation(this.view,r),p=s.flat().map(e=>P(e,a));return A(o,p),p}async _fetchCandidatesForSource(e,t,o){const r=I({parameters:t,mode:this.view?.type??"2d"}),s=await j(e.queryEngine,r,o);i(o);const n=await this._snappingElevationAligner.alignCandidates(s.candidates,t.coordinateHelper.spatialReference,o);i(o);const a=await this._symbologySnappingFetcher.fetch(n,o);i(o);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(r,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some(t=>t.graphics.includes(e.graphic)))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],o=new Map;for(const r of e)null!=r.geometry&&(this._needsInitializeProjection(r.geometry.spatialReference)?(t.push(r.geometry.spatialReference),o.set(r.uid,r)):this._add(r));this._createPendingAdd(t,o)}_createPendingAdd(e,t){if(!e.length)return;const s=r(async o=>{await m(e.map(e=>({source:e,dest:this.spatialReference})),{signal:o}),this._markLoadedSpatialReferences(e);for(const e of t.values())this._add(e)});this._updatingHandles.addPromise(s.promise);const i={task:s,graphics:t},n=()=>o(this._pendingAdds,i);s.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e){null!=t.wkid&&this._loadedWkids.add(t.wkid);const e=t.wkt2||t.wkt;e&&this._loadedWkts.add(e)}}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=y.fromExtent(t));const o=this._ensureSource(t.type);if(null==o)return;const r=this._createOptimizedFeature(e.uid,t);null!=r&&(o.featureStore.add(r),F(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){if(null!=e.wkid&&this._loadedWkids.has(e.wkid))return!1;const t=e.wkt2||e.wkt;return(!t||!this._loadedWkts.has(t))&&!g(e,this.spatialReference)}_createOptimizedFeature(e,t){const o=f(_(t),this.spatialReference);if(!o)return null;const r=this._ensureGeometryHasZ(o),s=S(r,this._hasZ,!1);return new w(s,{[Z]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},o=e.clone();switch(o.hasZ=!0,o.type){case"point":o.z=o.z??0;break;case"multipoint":o.points.forEach(t);break;case"polyline":o.paths.forEach(e=>e.forEach(t));break;case"polygon":o.rings.forEach(e=>e.forEach(t))}return o}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const o=this._createSource(e);return this._sources[e]=o,o}_createSource(e){const t=v.toJSON(e),o=this._hasZ,r=new b({geometryType:t,hasZ:o,hasM:!1});return{featureStore:r,queryEngine:new E({featureStore:r,fieldsIndex:k.fromLayerJSON({fields:[{name:Z,type:"esriFieldTypeOID",alias:Z}]}),geometryType:t,hasM:!1,hasZ:o,featureIdInfo:{type:"object-id",fieldName:Z},spatialReference:this.spatialReference,priority:x.SNAPPING,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources(t=>this._removeFromSource(t,e));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const o=t.uid;e.featureStore.has(o)&&(e.featureStore.removeById(t.uid),F(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:o,polyline:r,multipoint:s}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),null!=s&&i.push(e(s)),i}};e([c()],O.prototype,"getGraphicsLayers",void 0),e([c({constructOnly:!0})],O.prototype,"layerSource",void 0),e([c({constructOnly:!0})],O.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],O.prototype,"view",void 0),e([c({readOnly:!0})],O.prototype,"updating",null),e([c({readOnly:!0})],O.prototype,"availability",void 0),e([c()],O.prototype,"_hasZ",null),e([c()],O.prototype,"_snappingElevationAligner",null),e([c()],O.prototype,"_snappingElevationFilter",null),e([c()],O.prototype,"_symbologySnappingFetcher",null),e([c()],O.prototype,"_extrudedPolygonSymbolsCount",void 0),O=e([u("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],O);const Z="OBJECTID";export{O as GraphicsSnappingSource};
5
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{removeUnordered as o}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as i,allSettledValues as n,whenOrAbort as a}from"../../../../core/promiseUtils.js";import{initial as p,watch as l,on as d}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import y from"../../../../geometry/Polygon.js";import{initializeProjection as m,canProjectWithoutEngine as g,project as f}from"../../../../geometry/projectionUtils.js";import{normalizeCentralMeridianForDisplay as _}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as v}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as S}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as w}from"../../../../layers/graphics/OptimizedFeature.js";import j from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as b}from"../../../../layers/graphics/data/QueryEngine.js";import E from"../../../../layers/support/FieldsIndex.js";import{elevationContextAffectsAlignment as k}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as C}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as F,makeSnappingQuery as A}from"../snappingUtils.js";import{convertSnappingCandidate as I,makeGetGroundElevation as P}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as G}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as H}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as R}from"./symbologySnappingCandidates.js";import{TaskPriority as U}from"../../../support/Scheduler.js";const x="graphics-collections";let z=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,o=null!=e&&"3d"===e.type;if(!o||"map-notes"===t.type)return G();const r=async(o,r)=>(await a(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(o,r);return G(o,{elevationInfo:t.elevationInfo,alignPointsInFeatures:r})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return H(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,o=null!=e&&"3d"===e.type,r=this._extrudedPolygonSymbolsCount>0;return o&&"map-notes"!==t.type&&r?R(r,async(o,r)=>{const s=await e.whenLayerView(t);return i(r),s.queryForSymbologySnapping({candidates:o,spatialReference:e.spatialReference},r)}):R()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new h,this._memoizedMakeGetGroundElevation=s(P)}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources(e=>this._destroySource(e)),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add(()=>this.getGraphicsLayers(),e=>{this._updatingHandles.removeHandles(x);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",e=>this._onGraphicUpdate(e)),this._updatingHandles.addOnCollectionChange(()=>t.graphics,e=>this._onGraphicsChanged(e))],x)},p);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&e.elevationProvider&&this.addHandles([e.elevationProvider.on("elevation-change",({context:e})=>{k(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()}),l(()=>t.elevationInfo,()=>this._snappingElevationAligner.notifyElevationSourceChange(),p),d(()=>t,["edits","apply-edits","graphic-update"],()=>this._symbologySnappingFetcher.notifySymbologyChange())])}async fetchCandidates(e,t){const{point:o,coordinateHelper:{spatialReference:r}}=e,s=await n(this._mapSources(o=>this._fetchCandidatesForSource(o,e,t)));i(t);const a=this._memoizedMakeGetGroundElevation(this.view,r),p=s.flat().map(e=>I(e,a));return F(o,p),p}async _fetchCandidatesForSource(e,t,o){const r=A({parameters:t,mode:this.view?.type??"2d"}),s=await e.queryEngine.executeQueryForSnapping(r,o);i(o);const n=await this._snappingElevationAligner.alignCandidates(s.candidates,t.coordinateHelper.spatialReference,o);i(o);const a=await this._symbologySnappingFetcher.fetch(n,o);i(o);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(r,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some(t=>t.graphics.includes(e.graphic)))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],o=new Map;for(const r of e)null!=r.geometry&&(this._needsInitializeProjection(r.geometry.spatialReference)?(t.push(r.geometry.spatialReference),o.set(r.uid,r)):this._add(r));this._createPendingAdd(t,o)}_createPendingAdd(e,t){if(!e.length)return;const s=r(async o=>{await m(e.map(e=>({source:e,dest:this.spatialReference})),{signal:o}),this._markLoadedSpatialReferences(e);for(const e of t.values())this._add(e)});this._updatingHandles.addPromise(s.promise);const i={task:s,graphics:t},n=()=>o(this._pendingAdds,i);s.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e){null!=t.wkid&&this._loadedWkids.add(t.wkid);const e=t.wkt2||t.wkt;e&&this._loadedWkts.add(e)}}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=y.fromExtent(t));const o=this._ensureSource(t.type);if(null==o)return;const r=this._createOptimizedFeature(e.uid,t);null!=r&&(o.featureStore.add(r),C(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){if(null!=e.wkid&&this._loadedWkids.has(e.wkid))return!1;const t=e.wkt2||e.wkt;return(!t||!this._loadedWkts.has(t))&&!g(e,this.spatialReference)}_createOptimizedFeature(e,t){const o=f(_(t),this.spatialReference);if(!o)return null;const r=this._ensureGeometryHasZ(o),s=S(r,this._hasZ,!1);return new w(s,{[O]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},o=e.clone();switch(o.hasZ=!0,o.type){case"point":o.z=o.z??0;break;case"multipoint":o.points.forEach(t);break;case"polyline":o.paths.forEach(e=>e.forEach(t));break;case"polygon":o.rings.forEach(e=>e.forEach(t))}return o}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const o=this._createSource(e);return this._sources[e]=o,o}_createSource(e){const t=v.toJSON(e),o=this._hasZ,r=new j({geometryType:t,hasZ:o,hasM:!1});return{featureStore:r,queryEngine:new b({featureStore:r,fieldsIndex:E.fromLayerJSON({fields:[{name:O,type:"esriFieldTypeOID",alias:O}]}),geometryType:t,hasM:!1,hasZ:o,featureIdInfo:{type:"object-id",fieldName:O},spatialReference:this.spatialReference,priority:U.SNAPPING,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources(t=>this._removeFromSource(t,e));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const o=t.uid;e.featureStore.has(o)&&(e.featureStore.removeById(t.uid),C(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:o,polyline:r,multipoint:s}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),null!=s&&i.push(e(s)),i}};e([c()],z.prototype,"getGraphicsLayers",void 0),e([c({constructOnly:!0})],z.prototype,"layerSource",void 0),e([c({constructOnly:!0})],z.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],z.prototype,"view",void 0),e([c({readOnly:!0})],z.prototype,"updating",null),e([c({readOnly:!0})],z.prototype,"availability",void 0),e([c()],z.prototype,"_hasZ",null),e([c()],z.prototype,"_snappingElevationAligner",null),e([c()],z.prototype,"_snappingElevationFilter",null),e([c()],z.prototype,"_symbologySnappingFetcher",null),e([c()],z.prototype,"_extrudedPolygonSymbolsCount",void 0),z=e([u("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],z);const O="OBJECTID";export{z as GraphicsSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as r}from"../../../../../core/promiseUtils.js";import{watch as s,sync as a,whenOnce as n}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../../core/support/UpdatingHandles.js";import d from"../../../../../geometry/SpatialReference.js";import{fromJSON as h}from"../../../../../geometry/support/jsonUtils.js";import{executeQueryForSnapping as c}from"../../../../../layers/graphics/data/executeQueryForSnapping.js";import p from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as f}from"../../../../../layers/graphics/data/QueryEngine.js";import m from"../../../../../layers/support/TileInfo.js";import g from"../../../../../rest/support/Query.js";import y from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as _}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as S}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as F}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as v}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as I}from"./FeatureServiceTileStore.js";let w=class extends t{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=_(),this._elevationFilter=S(),this._symbologyCandidatesFetcher=F(),this._updatingHandles=new u,this._alignPointsInFeatures=async(e,t)=>{const i={query:e},s=await this.remoteClient.invoke("alignElevation",i,{signal:t});return r(t),s},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},s=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return r(t),s}}get updating(){return this._isInitializing||this._updatingHandles.updating||this._featureFetcher.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:r,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=d.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new p({...e.serviceInfo,hasZ:o,hasM:!1}),this._featureStore.estimateFeatureUsedMemory=e=>e.usedMemory,this._queryEngine=new f({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,featureIdInfo:{type:"object-id",fieldName:i},timeInfo:r}),this._featureFetcher=new v({store:new I({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:d.fromJSON(e.serviceInfo.spatialReference),customParameters:e.configuration.customParameters});const u="3d"===e.configuration.viewType;return this._elevationAligner=_(u,{elevationInfo:null!=e.elevationInfo?y.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures}),this._elevationFilter=S(u),this.addHandles([s(()=>this._featureFetcher.availability,e=>this.emit("notify-availability",{availability:e}),a),s(()=>this.updating,()=>this._notifyUpdating())]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),C}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.suspended=e,C}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.outFields=new Set(e??[]),C}async fetchCandidates(e,t){await this._whenSetup.promise,r(t);const i=j(e,this._featureStore.hasZ),s=t?.signal,a=await c(this._queryEngine,i,s);r(s);const n=await this._elevationAligner.alignCandidates(a.candidates,d.fromJSON(e.point.spatialReference)??d.WGS84,s);r(s);const o=await this._symbologyCandidatesFetcher.fetch(n,s);r(s);const l=0===o.length?n:n.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?m.fromJSON(e.tileInfo):null,C}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.refresh(),C}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await n(()=>!this.updating,t),r(t),C}async getDebugInfo(e,t){return r(t),{result:this._featureFetcher.debugInfo}}async handleEdits(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await this._updatingHandles.addPromise(this._featureFetcher.handleEdits(e)),r(t),C}async setHistoricMoment(e,t){return this._featureFetcher.setHistoricMoment(e.moment),C}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),C}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),C}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=F(e,this._getSymbologyCandidates),C}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?g.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],w.prototype,"updating",null),e([o()],w.prototype,"_isInitializing",void 0),w=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const b=w;function j(e,t){const i=!!t||void 0;if(!e.filter)return{...e,query:{where:"1=1",returnZ:i}};const{distance:r,units:s,spatialRel:a,where:n,timeExtent:o,objectIds:l}=e.filter,u={geometry:e.filter.geometry?h(e.filter.geometry):void 0,distance:r,units:s,spatialRel:a,timeExtent:o,objectIds:l,returnZ:i,where:n??"1=1"};return{...e,query:u}}const C={result:{}};export{b as default};
5
+ import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as r}from"../../../../../core/promiseUtils.js";import{watch as s,sync as a,whenOnce as n}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../../core/support/UpdatingHandles.js";import d from"../../../../../geometry/SpatialReference.js";import{fromJSON as h}from"../../../../../geometry/support/jsonUtils.js";import c from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as p}from"../../../../../layers/graphics/data/QueryEngine.js";import f from"../../../../../layers/support/TileInfo.js";import m from"../../../../../rest/support/Query.js";import g from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as y}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as _}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as S}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as F}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as v}from"./FeatureServiceTileStore.js";let I=class extends t{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=y(),this._elevationFilter=_(),this._symbologyCandidatesFetcher=S(),this._updatingHandles=new u,this._alignPointsInFeatures=async(e,t)=>{const i={query:e},s=await this.remoteClient.invoke("alignElevation",i,{signal:t});return r(t),s},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},s=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return r(t),s}}get updating(){return this._isInitializing||this._updatingHandles.updating||this._featureFetcher.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:r,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=d.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new c({...e.serviceInfo,hasZ:o,hasM:!1}),this._featureStore.estimateFeatureUsedMemory=e=>e.usedMemory,this._queryEngine=new p({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,featureIdInfo:{type:"object-id",fieldName:i},timeInfo:r}),this._featureFetcher=new F({store:new v({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:d.fromJSON(e.serviceInfo.spatialReference),customParameters:e.configuration.customParameters});const u="3d"===e.configuration.viewType;return this._elevationAligner=y(u,{elevationInfo:null!=e.elevationInfo?g.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures}),this._elevationFilter=_(u),this.addHandles([s(()=>this._featureFetcher.availability,e=>this.emit("notify-availability",{availability:e}),a),s(()=>this.updating,()=>this._notifyUpdating())]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),j}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.suspended=e,j}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.outFields=new Set(e??[]),j}async fetchCandidates(e,t){await this._whenSetup.promise,r(t);const i=b(e,this._featureStore.hasZ),s=t?.signal,a=await this._queryEngine.executeQueryForSnapping(i,s);r(s);const n=await this._elevationAligner.alignCandidates(a.candidates,d.fromJSON(e.point.spatialReference)??d.WGS84,s);r(s);const o=await this._symbologyCandidatesFetcher.fetch(n,s);r(s);const l=0===o.length?n:n.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?f.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await n(()=>!this.updating,t),r(t),j}async getDebugInfo(e,t){return r(t),{result:this._featureFetcher.debugInfo}}async handleEdits(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await this._updatingHandles.addPromise(this._featureFetcher.handleEdits(e)),r(t),j}async setHistoricMoment(e,t){return this._featureFetcher.setHistoricMoment(e.moment),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=S(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?m.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],I.prototype,"updating",null),e([o()],I.prototype,"_isInitializing",void 0),I=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],I);const w=I;function b(e,t){const i=!!t||void 0;if(!e.filter)return{...e,query:{where:"1=1",returnZ:i}};const{distance:r,units:s,spatialRel:a,where:n,timeExtent:o,objectIds:l}=e.filter,u={geometry:e.filter.geometry?h(e.filter.geometry):void 0,distance:r,units:s,spatialRel:a,timeExtent:o,objectIds:l,returnZ:i,where:n??"1=1"};return{...e,query:u}}const j={result:{}};export{w as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{getFeatureEditFields as e,fixFields as l}from"../../../layers/support/fieldUtils.js";async function p(p,n=p.popupTemplate){if(null==n)return[];const u=await n.getRequiredFields(p.fieldsIndex),{lastEditInfoEnabled:t}=n,{objectIdField:d,typeIdField:a,globalIdField:i,relationships:o}=p;if(u.includes("*"))return["*"];const s=t?e(p):[],f=l(p.fieldsIndex,[...u,...s]);return a&&f.push(a),f&&d&&p.fieldsIndex?.has(d)&&!f.includes(d)&&f.push(d),f&&i&&p.fieldsIndex?.has(i)&&!f.includes(i)&&f.push(i),o&&o.forEach(e=>{const{keyField:l}=e;f&&l&&p.fieldsIndex?.has(l)&&!f.includes(l)&&f.push(l)}),f}function n(e,l){return e&&"object"==typeof e?l?.checkPopupEnabled&&"popupEnabled"in e&&!e.popupEnabled?null:"popupTemplate"in e&&e.popupTemplate?e.popupTemplate:null!=l&&l.defaultPopupTemplateEnabled&&"defaultPopupTemplate"in e&&e.defaultPopupTemplate?e.defaultPopupTemplate:null:null}function u(e,l){return null!=n(e,{defaultPopupTemplateEnabled:l})}export{n as getFetchPopupTemplate,p as getRequiredFields,u as hasPopupTemplate};
5
+ import{getFeatureEditFields as e,fixFields as l}from"../../../layers/support/fieldUtils.js";async function p(p,n=p.popupTemplate){if(null==n)return[];const u=await n.getRequiredFields(p.fieldsIndex),{lastEditInfoEnabled:t}=n,{objectIdField:d,typeIdField:a,globalIdField:i,relationships:o}=p;if(u.includes("*"))return["*"];const s=t?e(p):[],f=l(p.fieldsIndex,[...u,...s]);return a&&f.push(a),f&&d&&p.fieldsIndex?.has(d)&&!f.includes(d)&&f.push(d),f&&i&&p.fieldsIndex?.has(i)&&!f.includes(i)&&f.push(i),o?.forEach(e=>{const{keyField:l}=e;f&&l&&p.fieldsIndex?.has(l)&&!f.includes(l)&&f.push(l)}),f}function n(e,l){return e&&"object"==typeof e?l?.checkPopupEnabled&&"popupEnabled"in e&&!e.popupEnabled?null:"popupTemplate"in e&&e.popupTemplate?e.popupTemplate:null!=l&&l.defaultPopupTemplateEnabled&&"defaultPopupTemplate"in e&&e.defaultPopupTemplate?e.defaultPopupTemplate:null:null}function u(e,l){return null!=n(e,{defaultPopupTemplateEnabled:l})}export{n as getFetchPopupTemplate,p as getRequiredFields,u as hasPopupTemplate};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{__decorate as e}from"tslib";import s from"../../core/Accessor.js";import{createTask as t}from"../../core/asyncUtils.js";import i from"../../core/Collection.js";import a from"../../core/Error.js";import{makeHandle as o}from"../../core/handleUtils.js";import"../../core/has.js";import n from"../../core/Logger.js";import{removeMaybe as r,destroyMaybe as l,abortMaybe as c}from"../../core/maybe.js";import{createAbortError as h,isAborted as w,onAbort as d,createResolver as y}from"../../core/promiseUtils.js";import{schedule as _}from"../../core/scheduling.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";const u="analyses-owner-handles";let V=class extends s{constructor(e){super(e),this._allAnalysisViews=new i,this._creatingViewCount=0,this._attachedToViewResolver=A(),this._items=new Map,this._moduleMap=new Map,this._scheduledUpdateHandle=null,this._emitOnView=(e,s)=>this.view.emit(e,s)}destroy(){this._disconnectOwners(),this._attachedToViewResolver.reject(h("AnalysisViewManager was destroyed")),this._set("view",null)}attach(){this._connectOwners(),this._attachedToViewResolver.resolve()}detach(){this._disconnectOwners(),this._attachedToViewResolver.reject(h()),this._attachedToViewResolver=A()}get updating(){return!this.view.ready||0!==this._creatingViewCount||this._allAnalysisViews.some(e=>e.updating)}get testInfo(){}async whenAnalysisView(e){await this._attachedToViewResolver.promise;const s=this._items.get(e);if(null==s||1===s.state.list){throw new a("AnalysisViewManager:no-analysisview-for-analysis","The analysis has not been added to view.analyses",{analysis:e})}return s.createAnalysisViewTask.promise}_connectOwners(){this.addHandles(this._connectAnalysesCollection(this.view.analyses),u)}_disconnectOwners(){this.removeHandles(u),this._update(),this._creatingViewCount=0}_connectAnalysesCollection(e){for(const i of e)this._addAnalysis(i);const s=e.on("after-add",e=>this._addAnalysis(e.item)),t=e.on("after-remove",e=>this._removeAnalysis(e.item));return o(()=>{s.remove(),t.remove();for(const s of e)this._removeAnalysis(s)})}_addAnalysis(e){const s=this._items.get(e);if(null==s){const s={state:{view:0,list:0},analysis:e,view:null,createAnalysisViewTask:null};this._items.set(e,s),s.createAnalysisViewTask=t(t=>this._createAnalysisViewPromise(s,t).then(s=>(this._emitOnView("analysis-view-create",{analysis:e,analysisView:s}),s),s=>{throw this._emitOnView("analysis-view-create-error",{analysis:e,error:s}),s}))}else s.state.list=0}_removeAnalysis(e){const s=this._items.get(e);null!=s?(s.state.list=1,this._scheduleUpdate()):n.getLogger(this).error("Trying to remove analysis which was not added")}_scheduleUpdate(){null==this._scheduledUpdateHandle&&(this._scheduledUpdateHandle=_(()=>this._update()))}_update(){this._scheduledUpdateHandle=r(this._scheduledUpdateHandle),this._items.forEach(e=>{if(1!==e.state.list)return;const{analysis:s,view:t}=e;switch(this._items.delete(s),e.state.view){case 0:e.createAnalysisViewTask=c(e.createAnalysisViewTask);break;case 1:null!=t&&(this._allAnalysisViews.remove(t),e.view=l(t),e.createAnalysisViewTask=null,this._emitOnView("analysis-view-destroy",{analysis:s,analysisView:t}))}})}async _createAnalysisViewPromise(e,s){const{analysis:t}=e;if(this._creatingViewCount+=1,!this._moduleMap.has(t.type))try{this._moduleMap.set(t.type,await this.importAnalysisViewModule(t))}catch(o){throw this._creatingViewCount-=1,o}if(w(s))throw this._creatingViewCount-=1,h("AnalysisView creation aborted");const i=new(this._moduleMap.get(t.type).default)({analysis:t,view:this.view});let a=!0;d(s,()=>{a&&this._destroyAnalysisView(t,i)});try{await i.when()}catch(o){throw a=!1,this._destroyAnalysisView(t,i),o}if(w(s))throw h();return a=!1,e.view=i,e.state.view=1,this._allAnalysisViews.add(i),this._creatingViewCount-=1,i}_destroyAnalysisView(e,s){s.destroyed||(this._creatingViewCount-=1,s.destroy(),this._emitOnView("analysis-view-destroy",{analysis:e,analysisView:s}))}};e([m()],V.prototype,"updating",null),e([m({constructOnly:!0})],V.prototype,"importAnalysisViewModule",void 0),e([m({constructOnly:!0})],V.prototype,"view",void 0),e([m()],V.prototype,"_allAnalysisViews",void 0),e([m()],V.prototype,"_creatingViewCount",void 0),V=e([p("esri.views.support.AnalysisViewManager")],V);const v=V;function A(){const e=y();return e.promise.catch(()=>{}),e}export{v as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{neverReached as t}from"../../core/compilerUtils.js";import e from"../../core/Logger.js";import{isAborted as s,createAbortError as r,isPromiseLike as o}from"../../core/promiseUtils.js";import{signal as a}from"../../core/signal.js";import{Yield as n}from"./Yield.js";class i{constructor(){this._tasks=new Array,this._numPendingTasks=a(0),this._readyToRun=a(!1)}get length(){return this._tasks.length}get updating(){return this._numPendingTasks.value>0}get readyToRun(){return this._readyToRun.value}_updateReadyToRun(){this._readyToRun.value=this._tasks.length>0}destroy(){this.cancelAll()}runTask(t){if(0===this.length)return n;for(;!t.done&&this._process(t);)t.madeProgress()}push(t,e,s){return this._addTask((r,o)=>new u(r,o,t,e,s),Array.prototype.push)}unshift(t,e,s){return this._addTask((r,o)=>new u(r,o,t,e,s),Array.prototype.unshift)}pushGenerator(t,e,s){return this._addTask((r,o)=>new p(r,o,t,e,s),Array.prototype.push)}_process(e){if(0===this._tasks.length)return!1;const o=this._tasks.shift();this._updateReadyToRun();try{if(s(o.signal))this._cancelTask(o,r());else switch(o.type){case 0:this._processSimple(o,e);break;case 1:this._processGenerator(o,e);break;case 2:this._processIterator(o,e);break;default:t(o)}}catch(a){o.reject(a)}return!0}cancelAll(){const t=r();for(const e of this._tasks)this._cancelTask(e,t);this._tasks.length=0,this._updateReadyToRun()}_cancelTask(t,e){if(t.abortCallback){const s=t.abortCallback(e);2===t.type&&t.iterator.return&&c(t.iterator.return()),o(s)?s.then(t.resolve,t.reject):t.resolve(s)}else 2===t.type&&t.iterator.throw&&c(t.iterator.throw(e)),t.reject(e)}_onIteratorResult(t,e){e.done?t.resolve(e.value):(this._tasks.unshift(t),this._updateReadyToRun())}_processSimple(t,e){const s=t.callback(e);o(s)?s.then(t.resolve,t.reject):t.resolve(s)}_processGenerator(t,e){const s=t.generatorFunction(e),r=new d(t.resolve,t.reject,s,t.signal,t.abortCallback);this._processIterator(r,e)}_processIterator(t,e){const s=t.iterator.next(e);o(s)?s.then(e=>this._onIteratorResult(t,e),t.reject):this._onIteratorResult(t,s)}_addTask(t,e){return new Promise((s,r)=>{const o=t(s,r);e.call(this._tasks,o),++this._numPendingTasks.value,this._updateReadyToRun()}).finally(()=>--this._numPendingTasks.value)}}function c(t){o(t)?t.then(h):h(t)}function h(t){t.done||e.getLogger("esri.layers.support.PromiseQueue").warn("Generator iterator was aborted, but it is not done.")}class l{constructor(t,e,s=void 0,r=void 0){this.resolve=t,this.reject=e,this.signal=s,this.abortCallback=r}}class u extends l{constructor(t,e,s,r,o){super(t,e,r,o),this.callback=s,this.type=0}}class p extends l{constructor(t,e,s,r,o){super(t,e,r,o),this.generatorFunction=s,this.type=1}}class d extends l{constructor(t,e,s,r,o){super(t,e,r,o),this.iterator=s,this.type=2}}export{i as PromiseQueue};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{removeUnordered as e,filterInPlace as t}from"../../core/arrayUtils.js";import s from"../../core/Handles.js";import"../../core/has.js";import r from"../../core/Logger.js";import{removeMaybe as i}from"../../core/maybe.js";import a from"../../core/PerformanceSampler.js";import{isAborted as n,createAbortError as h,when as _,isPromiseLike as u}from"../../core/promiseUtils.js";import{watch as o,initial as d,when as E}from"../../core/reactiveUtils.js";import{signal as l}from"../../core/signal.js";import{Milliseconds as c}from"../../core/time.js";import{PromiseQueue as T}from"../../layers/support/PromiseQueue.js";import m from"./debugFlags.js";import{Yield as g}from"./Yield.js";function R(){return new U}const I={RESOURCE_CONTROLLER_IMMEDIATE:"immediate",RESOURCE_CONTROLLER:"schedule",SLIDE:"slide",STREAM_DATA_LOADER:"stream loader",ELEVATION_QUERY:"elevation query",TERRAIN_SURFACE:"terrain",SURFACE_GEOMETRY_UPDATES:"surface geometry updates",LOD_RENDERER:"LoD renderer",GRAPHICS_CORE:"Graphics3D",I3S_CONTROLLER:"I3S",POINT_CLOUD_LAYER:"point cloud",FEATURE_TILE_FETCHER:"feature fetcher",STREAM_CONTROLLER:"stream controller",OVERLAY:"overlay",OVERLAY_RENDERER:"overlay renderer",STAGE:"stage",GRAPHICS_DECONFLICTOR:"graphics deconflictor",FILTER_VISIBILITY:"Graphics3D filter visibility",SCALE_VISIBILITY:"Graphics3D scale visibility",FRUSTUM_VISIBILITY:"Graphics3D frustum visibility",POINT_OF_INTEREST_FREQUENT:"POI frequent",POINT_OF_INTEREST_INFREQUENT:"POI infrequent",LABELER:"labeler",FEATURE_QUERY_ENGINE:"feature query",FEATURE_TILE_TREE:"feature tile tree",FEATURE_TILE_TREE_ACTIVE:"fast feature tile tree",ELEVATION_ALIGNMENT:"elevation alignment",ELEVATION_ALIGNMENT_SCENE:"elevation alignment scene",TEXT_TEXTURE_ATLAS:"text texture atlas",TEXTURE_UNLOAD:"texture unload",LINE_OF_SIGHT_TOOL:"line of sight tool",LINE_OF_SIGHT_TOOL_INTERACTIVE:"interactive line of sight tool",ELEVATION_PROFILE:"elevation profile",SNAPPING:"snapping",SHADOW_ACCUMULATOR:"shadow accumulator",CLOUDS_GENERATOR:"clouds generator",FLOW_GENERATOR:"flow generator",MAPVIEW_FETCH_QUEUE:"mapview fetch queue",MAPVIEW_LAYERVIEW_UPDATE:"mapview layerview update",MAPVIEW_VECTOR_TILE_PARSING_QUEUE:"mapview vector tile parsing queue",NONE:0,TEST_PRIO:1},p=0,f=new Map([[I.RESOURCE_CONTROLLER_IMMEDIATE,p],[I.RESOURCE_CONTROLLER,4],[I.SLIDE,p],[I.STREAM_DATA_LOADER,p],[I.ELEVATION_QUERY,p],[I.TERRAIN_SURFACE,1],[I.SURFACE_GEOMETRY_UPDATES,1],[I.LOD_RENDERER,2],[I.GRAPHICS_CORE,2],[I.I3S_CONTROLLER,2],[I.POINT_CLOUD_LAYER,2],[I.FEATURE_TILE_FETCHER,2],[I.STREAM_CONTROLLER,2],[I.CLOUDS_GENERATOR,2],[I.OVERLAY,4],[I.OVERLAY_RENDERER,4],[I.STAGE,4],[I.GRAPHICS_DECONFLICTOR,4],[I.FILTER_VISIBILITY,4],[I.SCALE_VISIBILITY,4],[I.FRUSTUM_VISIBILITY,4],[I.POINT_OF_INTEREST_FREQUENT,6],[I.POINT_OF_INTEREST_INFREQUENT,30],[I.LABELER,8],[I.FEATURE_QUERY_ENGINE,8],[I.FEATURE_TILE_TREE,16],[I.FEATURE_TILE_TREE_ACTIVE,p],[I.ELEVATION_ALIGNMENT,12],[I.ELEVATION_ALIGNMENT_SCENE,14],[I.TEXT_TEXTURE_ATLAS,12],[I.TEXTURE_UNLOAD,12],[I.LINE_OF_SIGHT_TOOL,16],[I.LINE_OF_SIGHT_TOOL_INTERACTIVE,p],[I.SNAPPING,p],[I.SHADOW_ACCUMULATOR,30],[I.FLOW_GENERATOR,12],[I.MAPVIEW_FETCH_QUEUE,p],[I.MAPVIEW_LAYERVIEW_UPDATE,2],[I.MAPVIEW_VECTOR_TILE_PARSING_QUEUE,p]]);function L(e){return f.has(e)?f.get(e):"number"==typeof e?e:1}const A=c(6.5),O=c(1),b=c(30),N=c(1e3/30),S=c(100),k=.9;class U{get updating(){return this._updating.value}_updatingChanged(){this._updating.value=this._tasks.some(e=>e.needsUpdate)}constructor(){this._updating=l(!0),this._microTaskQueued=!1,this._frameNumber=0,this.performanceInfo={total:new a("total"),tasks:new Map},this._frameTaskTimes=new Map,this._budget=new P,this._state=1,this._tasks=new Array,this._runQueue=new Array,this._load=0,this._idleStateCallbacks=new Array,this._idleUpdatesStartFired=!1,this._forceTask=!1,this._debug=!1,this._debugHandle=o(()=>m.SCHEDULER_LOG_SLOW_TASKS,e=>this._debug=e,d);for(const e of Object.keys(I))this.performanceInfo.tasks.set(I[e],new a(String(I[e])))}destroy(){this._tasks.forEach(e=>e.remove()),this._tasks.length=0,this._idleStateCallbacks.length=0,this._runQueue.length=0,i(this._debugHandle),this._microTaskQueued=!1,this._updatingChanged()}taskRunningChanged(e){this._updatingChanged(),e&&this._budget.remaining>0&&!this._microTaskQueued&&(this._microTaskQueued=!0,queueMicrotask(()=>{this._microTaskQueued&&(this._microTaskQueued=!1,this._budget.remaining>0&&this._schedule()&&this._runFrame())}))}registerTask(e,t){const s=new C(this,e,t);return this._tasks.push(s),this._updatingChanged(),this.performanceInfo.tasks.has(e)||this.performanceInfo.tasks.set(e,new a(e)),s}registerIdleStateCallbacks(e,t){const s={idleBegin:e,idleEnd:t};this._idleStateCallbacks.push(s),2===this.state&&this._idleUpdatesStartFired&&s.idleBegin();const r=this;return{remove:()=>this._removeIdleStateCallbacks(s),set idleBegin(e){r._idleUpdatesStartFired&&(s.idleEnd(),2===r._state&&e()),s.idleBegin=e},set idleEnd(e){s.idleEnd=e}}}get load(){return this._load}set state(e){this._state!==e&&(this._state=e,2!==this.state&&this._idleUpdatesStartFired&&(this._idleUpdatesStartFired=!1,this._idleStateCallbacks.forEach(e=>e.idleEnd())))}get state(){return this._state}frame(e){this._startFrameTaskTimes();const t=this._updateBudget(e);if(t){const e=this._budget.now();this._runFrame(),this._recordFrameTaskTimes(this._budget.now()-e)}else this._recordFrameTaskTimes(0);return t}_updateBudget(e){this._test&&(this._test.usedBudget=0),++this._frameNumber;let t=A,s=e.frameDuration,r=O;switch(this.state){case 2:t=c(0),s=c(Math.max(S,e.frameDuration)),r=b;break;case 1:s=c(Math.max(N,e.frameDuration))}return s=c(s-e.elapsedFrameTime-t),2!==this.state&&s<O&&!this._forceTask?(this._forceTask=!0,!1):(s=c(Math.max(s,r)),this._budget.reset(s),this._updateLoad(),this._schedule())}_runFrame(){switch(this._forceTask=!1,this._microTaskQueued=!1,this.state){case 2:this._idleUpdatesStartFired||(this._idleUpdatesStartFired=!0,this._idleStateCallbacks.forEach(e=>e.idleBegin())),this._runIdle();break;case 1:this._runInteracting();break;default:this._runAnimating()}this._test&&(this._test.usedBudget=this._budget.elapsed)}stopFrame(){this._budget.reset(c(0)),this._budget.madeProgress()}_removeIdleStateCallbacks(t){this._idleUpdatesStartFired&&t.idleEnd(),e(this._idleStateCallbacks,t)}removeTask(t){e(this._tasks,t),e(this._runQueue,t),this._updatingChanged()}_updateTask(e){this._tasks.forEach(t=>{t.name===e&&t.setPriority(e)})}_getState(e){if(this._runQueue.some(t=>t.name===e))return"s";let t="i";return this._tasks.forEach(s=>{s.name===e&&s.needsUpdate&&(s.schedulePriority<=1?t="r":"r"!==t&&(t="w"))}),t}_getRuntime(e){let t=0;return this._tasks.forEach(s=>{s.name===e&&(t+=s.runtime)}),t}_resetRuntimes(){this._tasks.forEach(e=>e.runtime=0)}_getRunning(){const e=new Map;if(this._tasks.forEach(t=>{t.needsUpdate&&e.set(t.name,(e.get(t.name)||0)+1)}),0===e.size)return null;let t="";return e.forEach((e,s)=>{t+=e>1?` ${e}x ${s}`:` ${s}`}),t}_runIdle(){this._run()}_runInteracting(){this._run()}_runAnimating(){this._run()}_updateLoad(){const e=this._tasks.reduce((e,t)=>t.needsUpdate?++e:e,0);this._load=this._load*k+e*(1-k)}_schedule(){for(t(this._runQueue,e=>!!e.needsUpdate||(e.schedulePriority=e.basePriority,!1)),this._tasks.forEach(e=>{e.basePriority===p&&e.needsUpdate&&!this._runQueue.includes(e)&&e.blockFrame!==this._frameNumber&&this._runQueue.unshift(e)});0===this._runQueue.length;){let e=!1,t=0;if(this._tasks.forEach(s=>{if(s.needsUpdate&&0!==s.schedulePriority&&s.basePriority!==p&&s.blockFrame!==this._frameNumber)if(e=!0,t=Math.max(t,s.basePriority),1===s.schedulePriority)s.schedulePriority=0,this._runQueue.push(s);else--s.schedulePriority}),!e)return this._updatingChanged(),!1}return this._updatingChanged(),!0}_run(){do{for(;this._runQueue.length>0;){const t=this._budget.now(),s=this._runQueue.pop();this._budget.resetProgress();try{s.task.runTask(this._budget)===g&&(s.blockFrame=this._frameNumber)}catch(e){r.getLogger("esri.views.support.Scheduler").error(`Exception in task "${s.name}"`,e),s.blockFrame=this._frameNumber}!this._budget.hasProgressed&&s.blockFrame!==this._frameNumber&&s.needsUpdate&&(s.name,I.I3S_CONTROLLER,s.blockFrame=this._frameNumber),s.schedulePriority=s.basePriority;const i=this._budget.now()-t;if(s.runtime+=i,this._frameTaskTimes.set(s.priority,this._frameTaskTimes.get(s.priority)+i),this._budget.remaining<=0)return void this._updatingChanged()}}while(this._schedule());this._updatingChanged()}_startFrameTaskTimes(){for(const e of Object.keys(I))this._frameTaskTimes.set(I[e],0)}_recordFrameTaskTimes(e){this._frameTaskTimes.forEach((e,t)=>this.performanceInfo.tasks.get(t).push(e)),this.performanceInfo.total.push(e)}get test(){return this._test}}class C{get task(){return this._task.value}get readyToRun(){return this._queue.readyToRun}get updating(){return this._queue.updating}constructor(e,t,r){this._scheduler=e,this.name=t,this.blockFrame=0,this.runtime=0,this._queue=new T,this._handles=new s,this._basePriority=L(t),this.schedulePriority=this._basePriority,this._task=l(null!=r?r:this._queue),this._handles.add(E(()=>this.task.readyToRun,t=>e.taskRunningChanged(t)))}remove(){this.processQueue(F),this._scheduler.removeTask(this),this.schedule=G.schedule,this.reschedule=G.reschedule,this.scheduleGenerator=G.scheduleGenerator,this.rescheduleGenerator=G.rescheduleGenerator,this._handles.destroy()}get basePriority(){return this._basePriority}setPriority(e){if(this.name===e)return;this.name=e;const t=L(e);this._basePriority!==p&&0===this.schedulePriority||(this.schedulePriority=t),this._basePriority=t}get priority(){return this.name}set priority(e){this.setPriority(e)}get needsUpdate(){return this.readyToRun||!this.task.destroyed&&this.task.readyToRun}schedule(e,t,s){return this._queue.push(e,t,s)}reschedule(e,t,s){return this._queue.unshift(e,t,s)}scheduleGenerator(e,t,s){return this._queue.pushGenerator(e,t,s)}rescheduleGenerator(e,t,s){return this._queue.unshiftGenerator(e,t,s)}processQueue(e){return this._queue.runTask(e)}}class P{constructor(){this._begin=performance?.now()??0,this._budget=0,this._done=!1,this._progressed=!1,this._enabled=!0}run(e){return!this.done&&(!0===e()&&this.madeProgress(),!0)}get done(){return this._done}get budget(){return this._budget}madeProgress(){return this._progressed=!0,this._done=this.elapsed>=this._budget&&this._enabled,this._done}get enabled(){return this._enabled}set enabled(e){this._enabled=e}reset(e){this._begin=this.now(),this._budget=e,this.resetProgress()}get remaining(){return Math.max(this._budget-this.elapsed,0)}now(){return performance.now()}get elapsed(){return this.now()-this._begin}resetProgress(){this._progressed=!1,this._done=!1}get hasProgressed(){return this._progressed}}const F=new P;function y(e){const t=new P;return t.reset(e),t}F.enabled=!1;class w{remove(){}processQueue(){}schedule(e,t,s){try{if(n(t)){const e=h();return s?Promise.resolve(s(e)):Promise.reject(e)}return _(e(F))}catch(r){return Promise.reject(r)}}reschedule(e,t,s){return this.schedule(e,t,s)}async scheduleGenerator(e,t,s){if(n(t)){const e=h();if(s)return s(e);throw e}const r=e(F);for(;;){const e=r.next(F),i=u(e)?await e:e;if(n(t)){const e=h();if(s)return s(e);throw e}if(i.done)return i.value}}rescheduleGenerator(e,t,s){return this.rescheduleGenerator(e,t,s)}}const G=new w;export{G as ImmediateTask,I as TaskPriority,L as getTaskPriority,y as makeBudget,R as newScheduler,F as noBudget,f as taskPriorities};
5
+ import{removeUnordered as e,filterInPlace as t}from"../../core/arrayUtils.js";import s from"../../core/Handles.js";import"../../core/has.js";import r from"../../core/Logger.js";import{removeMaybe as i}from"../../core/maybe.js";import a from"../../core/PerformanceSampler.js";import{isAborted as n,createAbortError as _,when as h,isPromiseLike as u}from"../../core/promiseUtils.js";import{watch as o,initial as d,when as E}from"../../core/reactiveUtils.js";import{signal as l}from"../../core/signal.js";import{Milliseconds as T}from"../../core/time.js";import c from"./debugFlags.js";import{PromiseQueue as m}from"./PromiseQueue.js";import{Yield as g}from"./Yield.js";function R(){return new U}const I={RESOURCE_CONTROLLER_IMMEDIATE:"immediate",RESOURCE_CONTROLLER:"schedule",SLIDE:"slide",STREAM_DATA_LOADER:"stream loader",ELEVATION_QUERY:"elevation query",TERRAIN_SURFACE:"terrain",SURFACE_GEOMETRY_UPDATES:"surface geometry updates",LOD_RENDERER:"LoD renderer",GRAPHICS_CORE:"Graphics3D",I3S_CONTROLLER:"I3S",POINT_CLOUD_LAYER:"point cloud",FEATURE_TILE_FETCHER:"feature fetcher",STREAM_CONTROLLER:"stream controller",OVERLAY:"overlay",OVERLAY_RENDERER:"overlay renderer",STAGE:"stage",GRAPHICS_DECONFLICTOR:"graphics deconflictor",FILTER_VISIBILITY:"Graphics3D filter visibility",SCALE_VISIBILITY:"Graphics3D scale visibility",FRUSTUM_VISIBILITY:"Graphics3D frustum visibility",POINT_OF_INTEREST_FREQUENT:"POI frequent",POINT_OF_INTEREST_INFREQUENT:"POI infrequent",LABELER:"labeler",FEATURE_QUERY_ENGINE:"feature query",FEATURE_TILE_TREE:"feature tile tree",FEATURE_TILE_TREE_ACTIVE:"fast feature tile tree",ELEVATION_ALIGNMENT:"elevation alignment",ELEVATION_ALIGNMENT_SCENE:"elevation alignment scene",TEXT_TEXTURE_ATLAS:"text texture atlas",TEXTURE_UNLOAD:"texture unload",LINE_OF_SIGHT_TOOL:"line of sight tool",LINE_OF_SIGHT_TOOL_INTERACTIVE:"interactive line of sight tool",ELEVATION_PROFILE:"elevation profile",SNAPPING:"snapping",SHADOW_ACCUMULATOR:"shadow accumulator",CLOUDS_GENERATOR:"clouds generator",FLOW_GENERATOR:"flow generator",MAPVIEW_FETCH_QUEUE:"mapview fetch queue",MAPVIEW_LAYERVIEW_UPDATE:"mapview layerview update",MAPVIEW_VECTOR_TILE_PARSING_QUEUE:"mapview vector tile parsing queue",NONE:0,TEST_PRIO:1},p=0,f=new Map([[I.RESOURCE_CONTROLLER_IMMEDIATE,p],[I.RESOURCE_CONTROLLER,4],[I.SLIDE,p],[I.STREAM_DATA_LOADER,p],[I.ELEVATION_QUERY,p],[I.TERRAIN_SURFACE,1],[I.SURFACE_GEOMETRY_UPDATES,1],[I.LOD_RENDERER,2],[I.GRAPHICS_CORE,2],[I.I3S_CONTROLLER,2],[I.POINT_CLOUD_LAYER,2],[I.FEATURE_TILE_FETCHER,2],[I.STREAM_CONTROLLER,2],[I.CLOUDS_GENERATOR,2],[I.OVERLAY,4],[I.OVERLAY_RENDERER,4],[I.STAGE,4],[I.GRAPHICS_DECONFLICTOR,4],[I.FILTER_VISIBILITY,4],[I.SCALE_VISIBILITY,4],[I.FRUSTUM_VISIBILITY,4],[I.POINT_OF_INTEREST_FREQUENT,6],[I.POINT_OF_INTEREST_INFREQUENT,30],[I.LABELER,8],[I.FEATURE_QUERY_ENGINE,8],[I.FEATURE_TILE_TREE,16],[I.FEATURE_TILE_TREE_ACTIVE,p],[I.ELEVATION_ALIGNMENT,12],[I.ELEVATION_ALIGNMENT_SCENE,14],[I.TEXT_TEXTURE_ATLAS,12],[I.TEXTURE_UNLOAD,12],[I.LINE_OF_SIGHT_TOOL,16],[I.LINE_OF_SIGHT_TOOL_INTERACTIVE,p],[I.SNAPPING,p],[I.SHADOW_ACCUMULATOR,30],[I.FLOW_GENERATOR,12],[I.MAPVIEW_FETCH_QUEUE,p],[I.MAPVIEW_LAYERVIEW_UPDATE,2],[I.MAPVIEW_VECTOR_TILE_PARSING_QUEUE,p]]);function L(e){return f.has(e)?f.get(e):"number"==typeof e?e:1}const A=T(6.5),O=T(1),b=T(30),N=T(1e3/30),S=T(100),k=.9;class U{get updating(){return this._updating.value}_updatingChanged(){this._updating.value=this._tasks.some(e=>e.needsUpdate)}constructor(){this._updating=l(!0),this._microTaskQueued=!1,this._frameNumber=0,this.performanceInfo={total:new a("total"),tasks:new Map},this._frameTaskTimes=new Map,this._budget=new P,this._state=1,this._tasks=new Array,this._runQueue=new Array,this._load=0,this._idleStateCallbacks=new Array,this._idleUpdatesStartFired=!1,this._forceTask=!1,this._debug=!1,this._debugHandle=o(()=>c.SCHEDULER_LOG_SLOW_TASKS,e=>this._debug=e,d);for(const e of Object.keys(I))this.performanceInfo.tasks.set(I[e],new a(String(I[e])))}destroy(){this._tasks.forEach(e=>e.remove()),this._tasks.length=0,this._idleStateCallbacks.length=0,this._runQueue.length=0,i(this._debugHandle),this._microTaskQueued=!1,this._updatingChanged()}taskRunningChanged(e){this._updatingChanged(),e&&this._budget.remaining>0&&!this._microTaskQueued&&(this._microTaskQueued=!0,queueMicrotask(()=>{this._microTaskQueued&&(this._microTaskQueued=!1,this._budget.remaining>0&&this._schedule()&&this._runFrame())}))}registerTask(e,t){const s=new C(this,e,t);return this._tasks.push(s),this._updatingChanged(),this.performanceInfo.tasks.has(e)||this.performanceInfo.tasks.set(e,new a(e)),s}registerIdleStateCallbacks(e,t){const s={idleBegin:e,idleEnd:t};this._idleStateCallbacks.push(s),2===this.state&&this._idleUpdatesStartFired&&s.idleBegin();const r=this;return{remove:()=>this._removeIdleStateCallbacks(s),set idleBegin(e){r._idleUpdatesStartFired&&(s.idleEnd(),2===r._state&&e()),s.idleBegin=e},set idleEnd(e){s.idleEnd=e}}}get load(){return this._load}set state(e){this._state!==e&&(this._state=e,2!==this.state&&this._idleUpdatesStartFired&&(this._idleUpdatesStartFired=!1,this._idleStateCallbacks.forEach(e=>e.idleEnd())))}get state(){return this._state}frame(e){this._startFrameTaskTimes();const t=this._updateBudget(e);if(t){const e=this._budget.now();this._runFrame(),this._recordFrameTaskTimes(this._budget.now()-e)}else this._recordFrameTaskTimes(0);return t}_updateBudget(e){this._test&&(this._test.usedBudget=0),++this._frameNumber;let t=A,s=e.frameDuration,r=O;switch(this.state){case 2:t=T(0),s=T(Math.max(S,e.frameDuration)),r=b;break;case 1:s=T(Math.max(N,e.frameDuration))}return s=T(s-e.elapsedFrameTime-t),2!==this.state&&s<O&&!this._forceTask?(this._forceTask=!0,!1):(s=T(Math.max(s,r)),this._budget.reset(s),this._updateLoad(),this._schedule())}_runFrame(){switch(this._forceTask=!1,this._microTaskQueued=!1,this.state){case 2:this._idleUpdatesStartFired||(this._idleUpdatesStartFired=!0,this._idleStateCallbacks.forEach(e=>e.idleBegin())),this._runIdle();break;case 1:this._runInteracting();break;default:this._runAnimating()}this._test&&(this._test.usedBudget=this._budget.elapsed)}stopFrame(){this._budget.reset(T(0)),this._budget.madeProgress()}_removeIdleStateCallbacks(t){this._idleUpdatesStartFired&&t.idleEnd(),e(this._idleStateCallbacks,t)}removeTask(t){e(this._tasks,t),e(this._runQueue,t),this._updatingChanged()}_updateTask(e){this._tasks.forEach(t=>{t.name===e&&t.setPriority(e)})}_getState(e){if(this._runQueue.some(t=>t.name===e))return"s";let t="i";return this._tasks.forEach(s=>{s.name===e&&s.needsUpdate&&(s.schedulePriority<=1?t="r":"r"!==t&&(t="w"))}),t}_getRuntime(e){let t=0;return this._tasks.forEach(s=>{s.name===e&&(t+=s.runtime)}),t}_resetRuntimes(){this._tasks.forEach(e=>e.runtime=0)}_getRunning(){const e=new Map;if(this._tasks.forEach(t=>{t.needsUpdate&&e.set(t.name,(e.get(t.name)||0)+1)}),0===e.size)return null;let t="";return e.forEach((e,s)=>{t+=e>1?` ${e}x ${s}`:` ${s}`}),t}_runIdle(){this._run()}_runInteracting(){this._run()}_runAnimating(){this._run()}_updateLoad(){const e=this._tasks.reduce((e,t)=>t.needsUpdate?++e:e,0);this._load=this._load*k+e*(1-k)}_schedule(){for(t(this._runQueue,e=>!!e.needsUpdate||(e.schedulePriority=e.basePriority,!1)),this._tasks.forEach(e=>{e.basePriority===p&&e.needsUpdate&&!this._runQueue.includes(e)&&e.blockFrame!==this._frameNumber&&this._runQueue.unshift(e)});0===this._runQueue.length;){let e=!1,t=0;if(this._tasks.forEach(s=>{if(s.needsUpdate&&0!==s.schedulePriority&&s.basePriority!==p&&s.blockFrame!==this._frameNumber)if(e=!0,t=Math.max(t,s.basePriority),1===s.schedulePriority)s.schedulePriority=0,this._runQueue.push(s);else--s.schedulePriority}),!e)return this._updatingChanged(),!1}return this._updatingChanged(),!0}_run(){do{for(;this._runQueue.length>0;){const t=this._budget.now(),s=this._runQueue.pop();this._budget.resetProgress();try{s.task.runTask(this._budget)===g&&(s.blockFrame=this._frameNumber)}catch(e){r.getLogger("esri.views.support.Scheduler").error(`Exception in task "${s.name}"`,e),s.blockFrame=this._frameNumber}!this._budget.hasProgressed&&s.blockFrame!==this._frameNumber&&s.needsUpdate&&(s.name,I.I3S_CONTROLLER,s.blockFrame=this._frameNumber),s.schedulePriority=s.basePriority;const i=this._budget.now()-t;if(s.runtime+=i,this._frameTaskTimes.set(s.priority,this._frameTaskTimes.get(s.priority)+i),this._budget.remaining<=0)return void this._updatingChanged()}}while(this._schedule());this._updatingChanged()}_startFrameTaskTimes(){for(const e of Object.keys(I))this._frameTaskTimes.set(I[e],0)}_recordFrameTaskTimes(e){this._frameTaskTimes.forEach((e,t)=>this.performanceInfo.tasks.get(t).push(e)),this.performanceInfo.total.push(e)}get test(){return this._test}}class C{get task(){return this._task.value}get readyToRun(){return this._queue.readyToRun}get updating(){return this._queue.updating}constructor(e,t,r){this._scheduler=e,this.name=t,this.blockFrame=0,this.runtime=0,this._queue=new m,this._handles=new s,this._basePriority=L(t),this.schedulePriority=this._basePriority,this._task=l(null!=r?r:this._queue),this._handles.add(E(()=>this.task.readyToRun,t=>e.taskRunningChanged(t)))}remove(){this.processQueue(F),this._scheduler.removeTask(this),this.schedule=D.schedule,this.reschedule=D.reschedule,this.scheduleGenerator=D.scheduleGenerator,this._handles.destroy()}get basePriority(){return this._basePriority}setPriority(e){if(this.name===e)return;this.name=e;const t=L(e);this._basePriority!==p&&0===this.schedulePriority||(this.schedulePriority=t),this._basePriority=t}get priority(){return this.name}set priority(e){this.setPriority(e)}get needsUpdate(){return this.readyToRun||!this.task.destroyed&&this.task.readyToRun}schedule(e,t,s){return this._queue.push(e,t,s)}reschedule(e,t,s){return this._queue.unshift(e,t,s)}scheduleGenerator(e,t,s){return this._queue.pushGenerator(e,t,s)}processQueue(e){return this._queue.runTask(e)}}class P{constructor(){this._begin=performance?.now()??0,this._budget=0,this._done=!1,this._progressed=!1,this._enabled=!0}run(e){return!this.done&&(!0===e()&&this.madeProgress(),!0)}get done(){return this._done}get budget(){return this._budget}madeProgress(){return this._progressed=!0,this._done=this.elapsed>=this._budget&&this._enabled,this._done}get enabled(){return this._enabled}set enabled(e){this._enabled=e}reset(e){this._begin=this.now(),this._budget=e,this.resetProgress()}get remaining(){return Math.max(this._budget-this.elapsed,0)}now(){return performance.now()}get elapsed(){return this.now()-this._begin}resetProgress(){this._progressed=!1,this._done=!1}get hasProgressed(){return this._progressed}}const F=new P;function y(e){const t=new P;return t.reset(e),t}F.enabled=!1;class w{remove(){}processQueue(){}schedule(e,t,s){try{if(n(t)){const e=_();return s?Promise.resolve(s(e)):Promise.reject(e)}return h(e(F))}catch(r){return Promise.reject(r)}}reschedule(e,t,s){return this.schedule(e,t,s)}async scheduleGenerator(e,t,s){if(n(t)){const e=_();if(s)return s(e);throw e}const r=e(F);for(;;){const e=r.next(F),i=u(e)?await e:e;if(n(t)){const e=_();if(s){const t=s(e);return r.return(null),t}throw r.throw(e),e}if(i.done)return i.value}}}const D=new w;export{D as ImmediateTask,I as TaskPriority,L as getTaskPriority,y as makeBudget,R as newScheduler,F as noBudget,f as taskPriorities};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import s from"../../core/Accessor.js";import{isSome as o}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{IdentifiableMixin as n}from"../../core/Identifiable.js";import l from"../../core/Logger.js";import{abortMaybe as p}from"../../core/maybe.js";import{eachAlways as c,isAbortError as d,throwIfAborted as h}from"../../core/promiseUtils.js";import{watch as u,when as f,initial as m,on as _}from"../../core/reactiveUtils.js";import{throttle as y}from"../../core/throttle.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import{cast as b}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../geometry/Point.js";import A from"../../geometry/SpatialReference.js";import I from"../../popup/content/TextContent.js";import{system as x}from"../../time/constants.js";import M from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import T from"./FeatureContent/FeatureContentViewModel.js";import F from"./FeatureExpression/FeatureExpressionViewModel.js";import E from"./FeatureFields/FeatureFieldsViewModel.js";import C from"./FeatureMedia/FeatureMediaViewModel.js";import V from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{compileExpressionInfos as j,formatArcadeValue as k}from"./support/arcadeFeatureUtils.js";import{preLayerQueryCallback as P,preRequestCallback as R,createFieldInfoMap as L,getAllFieldInfos as O,getSourceLayer as N,querySourceLayer as U,queryUpdatedFeature as Z,isRelatableFeatureSupportedLayer as S,isAssociatedFeatureSupportedLayer as B,substituteFieldsInLinksAndAttributes as H,isExpressionField as D,isRelatedField as G,formatEditInfo as q,graphicCallback as z,formatAttributes as Q}from"./support/featureUtils.js";import{queryLayerInfos as J,queryRelatedFeatures as K,setRelatedFeatures as W,getRelatedFieldInfo as X,createRelatedInfo as Y,updateRelatedInfo as $}from"./support/relatedFeatureUtils.js";import ee from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";var te;const ie=1,se="content-view-models",oe="relationship-view-models",re="association-view-models",ae={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let ne=class extends(n(s)){static{te=this}constructor(e){super(e),this._error=null,this._graphicChangedTask=null,this._evaluateExpressionAttributesTask=null,this._associationVMAbortController=null,this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...ae},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._graphicChangedThrottled=y(this._graphicChanged,()=>this.notifyChange("waitingForContent"),ie,this),this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this._evaluateExpressionAttributesThrottled=y(this._evaluateExpressionAttributes,()=>this.notifyChange("waitingForContent"),ie,this),this.addHandles([u(()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone],()=>this._graphicChangedThrottled(),m),f(()=>{if(!this._graphicChangedTask?.finished||null==this._graphicChangedTask.value)return null;const e=this._graphicChangedTask.value,t=e?.expressionInfos?.dependencies;return[e,t?.has("view-scale")?this.view?.scale:null,t?.has("view-time-extent")?this.view?.timeExtent?.start:null,t?.has("view-time-extent")?this.view?.timeExtent?.end:null]},([e])=>this._evaluateExpressionAttributesThrottled(e))])}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=p(this._graphicChangedTask),this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}static{this.interceptor=new i(P,R)}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return L(O(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return N(this.graphic)}castAbilities(e){return{...ae,...e}}get isFeatureFromTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._set("graphic",e?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??x}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){const{_graphicChangedThrottled:e,_evaluateExpressionAttributesThrottled:t,_graphicChangedTask:i,_evaluateExpressionAttributesTask:s,_associationVMAbortController:o}=this;return e.hasPendingUpdates()||t.hasPendingUpdates()||null!=i&&!i.finished||null!=s&&!s.finished||!!o}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof C&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof C&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof C&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const s=i?.objectIdField;if(!s||!e||!i)return;const o=e?.attributes?.[s];if(null==o)return;const r=[o];if(!e.geometry){const s=await U({layer:i,graphic:e,outFields:[],objectIds:r,returnGeometry:!0,spatialReference:t}),o=s?.geometry;o&&(e.geometry=o)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}_graphicChanged(){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._graphicChangedTask=p(this._graphicChangedTask),this._graphicChangedTask=r(async e=>{this._error=null,this._clear();const{graphic:t}=this;try{if(!t)return null;const{_sourceLayer:i,_effectivePopupTemplate:s}=this,o=this.spatialReference;await Z({graphic:t,popupTemplate:s,layer:i,spatialReference:o},{signal:e});const[{value:r},{value:a}]=await c([this._getContent(),this._getTitle()]),[,{value:n}]=await c([this._checkForRelatedFeatures({signal:e}),j(s?.expressionInfos,t)]);return{expressionInfos:n,content:r,title:a}}catch(i){throw d(i)||(this._error=i,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:t,popupTemplate:this._effectivePopupTemplate})),i}})}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map((e,t)=>this._compileContentElement(e,t)).filter(o):"string"==typeof e?this._compileText(new I({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(oe),this.removeHandles(se),this.contentViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),s=t?.getObjectId();return null!=i&&null!=s&&i===s}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:s,spatialReference:o,timeZone:r}=this;t?.filter(Boolean).forEach(t=>{e.some(e=>this._matchesFeature(e,t))||e.add(new te({abilities:{relationshipContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:t}))}),e.forEach(i=>{const s=t?.find(e=>this._matchesFeature(i,e));s||e.remove(i)})}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:s,contentElementViewModel:o}=e,r=s?.type;o&&r&&("fields"===r&&(this._createFieldsFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createFieldsVMParams(s,t))),"media"===r&&(this._createMediaFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createMediaVMParams(s,t))),"text"===r&&o.set(this._createTextVMParams(s)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:s,relationshipId:o,title:r,description:a}=e,{_sourceLayer:n,graphic:l,map:p}=this;if(!S(n))return;const c=new V({displayCount:i,graphic:l,orderByFields:s,relationshipId:o,layer:n,map:p,...this._compileTitleAndDesc({title:r,description:a})});return this.contentViewModels[t]=c,this.addHandles(_(()=>c.relatedFeatures,"change",()=>this._setRelatedFeaturesViewModels(c)),oe),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,s=t?.association.globalId;return null!=i&&null!=s&&i===s}_setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:s,spatialReference:o,timeZone:r}=this;e.forEach((i,s)=>{const o=t.get(s);o?i.forEach(t=>{o.find(e=>this._matchesGlobalFeature(t,e))||(i.remove(t),0===i.length&&e.delete(s))}):(i.removeAll(),e.delete(s))}),t.forEach((t,n)=>{const l=e.get(n)||new a;t?.filter(Boolean).forEach((e,t)=>{if(!l.some(t=>this._matchesGlobalFeature(t,e))){const{association:a,feature:n,terminalName:p,title:c}=e;l.add({title:c,association:a,featureViewModel:new te({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:n}),terminalName:p},t)}}),e.set(n,l)})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:s,description:o,associationTypes:r}=e,{_sourceLayer:a,graphic:n,map:l}=this;if(!B(a))return;const p=new ee({graphic:n,displayCount:i,associationTypes:r,layer:a,map:l,...this._compileTitleAndDesc({title:s,description:o})});return this.contentViewModels[t]=p,this.addHandles([u(()=>p.associationFeatures.values(),()=>this._setUpUtilityNetworkAssociationsViewModels(p.associationViewModels,p.associationFeatures,p.map))],re),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:s,map:o,spatialReference:r,view:a,location:n}=this,l=new F({expressionInfo:i,graphic:s,interceptor:te.interceptor,map:o,spatialReference:r,view:a,location:n});return this.contentViewModels[t]=l,this.addHandles(u(()=>l.contentElementViewModel,()=>this._setExpressionContentVM(l,t),m),se),e}_compileAttachments(e,t){const{graphic:i}=this,{description:s,title:o,orderByFields:r}=e;return this.contentViewModels[t]=new M({graphic:i,orderByFields:r,...this._compileTitleAndDesc({title:o,description:s})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:s,destroyer:o}=e;return this.contentViewModels[t]=new T({graphic:i,creator:s,destroyer:o}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:s,graphic:o,formattedAttributes:r}=this,a=o?.attributes,n=this._expressionAttributes,l=r.global;return{title:H({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:e}),description:H({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,s=this.formattedAttributes,o={...s?.global,...s?.content[t]},r=e?.fieldInfos||i?.fieldInfos,a=r?.filter(({fieldName:e})=>!!e&&(D(e)||G(e)||o.hasOwnProperty(e))),n=i?.expressionInfos,{description:l,title:p}=e;return{attributes:o,expressionInfos:n,fieldInfos:a,...this._compileTitleAndDesc({title:p,description:l})}}_compileFields(e,t){const i=e.clone(),s=new E(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=s,i.fieldInfos=s.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:s,_fieldInfoMap:o,_effectivePopupTemplate:r,relatedInfos:a,_sourceLayer:n,_expressionAttributes:l}=this,p=this.formattedAttributes,c=s?.attributes??{},{description:d,mediaInfos:h,title:u}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:c,isAggregate:s?.isAggregate,layer:n,fieldInfoMap:o,formattedAttributes:{...p?.global,...p?.content[t]},expressionAttributes:l,mediaInfos:h,popupTemplate:r,relatedInfos:a,...this._compileTitleAndDesc({title:u,description:d})}}_compileMedia(e,t){const i=e.clone(),s=new C(this._createMediaVMParams(e,t));return i.mediaInfos=s.formattedMediaInfos.slice(),this.contentViewModels[t]=s,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:s,_expressionAttributes:o}=this;if(e&&e.text){const r=t?.attributes??{},a=this.formattedAttributes?.global??{};e.text=H({attributes:r,fieldInfoMap:i,globalAttributes:a,expressionAttributes:o,layer:s,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new T(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:s}=this;if(!e)return;const{lastEditInfoEnabled:o}=e,r=t?.editFieldsInfo;return o&&r?q(r,i?.attributes,s,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:s,_expressionAttributes:o}=this,r=s?.attributes??{},a=this.formattedAttributes?.global??{};return H({attributes:r,fieldInfoMap:t,globalAttributes:a,expressionAttributes:o,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?z({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?z({type:"content",value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({title:e,content:t,expressionInfos:i}){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=r(async s=>{const{graphic:o,map:r,view:a,spatialReference:n,location:p}=this;try{if(!o)return;let l;if(null!=i){const e=[];for(const[t,l]of i.expressions.entries())null!=l?e.push(l.evaluate({graphic:o,interceptor:te.interceptor,location:p,map:r,options:{signal:s},spatialReference:n,view:a}).then(e=>[t,"string"==typeof e?k(e):e]).catch(()=>[t,void 0])):e.push(Promise.resolve([t,void 0]));l=Object.fromEntries(await Promise.all(e)),h(s)}this._expressionAttributes=l,this._graphicExpressionAttributes={...o.attributes,...l},this._set("formattedAttributes",this._createFormattedAttributes(t)),this._set("title",this._compileTitle(e)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(t)||null)}catch(c){d(c)||(this._error=c,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:c,graphic:o,popupTemplate:this._effectivePopupTemplate}))}})}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:s,graphic:o,relatedInfos:r,_sourceLayer:a,_fieldInfoMap:n,_graphicExpressionAttributes:l,timeZone:p}=this;i.content[t]=Q({fieldInfos:s?.fieldInfos,graphic:o,attributes:{...l,...e.attributes},layer:a,fieldInfoMap:n,relatedInfos:r,timeZone:p})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:s,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:a,_graphicExpressionAttributes:n,timeZone:l}=this;i.content[t]=Q({fieldInfos:e.fieldInfos,graphic:s,attributes:{...n,...e.attributes},layer:r,fieldInfoMap:a,relatedInfos:o,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:s,_sourceLayer:o,_fieldInfoMap:r,_graphicExpressionAttributes:a,timeZone:n}=this,l=t?.fieldInfos,p={global:Q({fieldInfos:l,graphic:i,attributes:a,layer:o,fieldInfoMap:r,relatedInfos:s,timeZone:n}),content:[]};return Array.isArray(e)&&e.forEach((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p})}),p}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,O(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:s,_sourceLayer:o}=this;s.clear();const r=null!=o?.associatedLayer?await(o?.associatedLayer.load(i)):o;if(!r||!e)return;const a=t.filter(e=>!!e.fieldName&&G(e.fieldName));if(!a?.length)return;t.forEach(e=>this._configureRelatedInfo(e,r));const n=await J({relatedInfos:s,layer:r},i);Object.keys(n).forEach(e=>{const t=s.get(e.toString()),i=n[e]?.value;t&&i&&(t.layerInfo=i.data)});const l=await K({graphic:e,relatedInfos:s,layer:r},i);Object.keys(l).forEach(e=>{W(l[e]?.value,s.get(e.toString()))})}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,s=X(e.fieldName||"");if(!s)return;const{layerId:o,fieldName:r}=s;if(!o)return;const a=i.get(o.toString())||Y(o,t);a&&($({relatedInfo:a,fieldName:r,fieldInfo:e}),this.relatedInfos.set(o,a))}};e([g()],ne.prototype,"_error",void 0),e([g()],ne.prototype,"_graphicChangedTask",void 0),e([g()],ne.prototype,"_evaluateExpressionAttributesTask",void 0),e([g()],ne.prototype,"_associationVMAbortController",void 0),e([g({readOnly:!0})],ne.prototype,"_effectivePopupTemplate",null),e([g({readOnly:!0})],ne.prototype,"_fieldInfoMap",null),e([g({readOnly:!0})],ne.prototype,"_sourceLayer",null),e([g()],ne.prototype,"abilities",void 0),e([b("abilities")],ne.prototype,"castAbilities",null),e([g({readOnly:!0})],ne.prototype,"content",void 0),e([g({readOnly:!0})],ne.prototype,"contentViewModels",void 0),e([g()],ne.prototype,"description",void 0),e([g({type:Boolean})],ne.prototype,"defaultPopupTemplateEnabled",void 0),e([g({readOnly:!0})],ne.prototype,"isFeatureFromTable",null),e([g({readOnly:!0})],ne.prototype,"state",null),e([g({readOnly:!0})],ne.prototype,"formattedAttributes",void 0),e([g({type:t,value:null})],ne.prototype,"graphic",null),e([g({readOnly:!0})],ne.prototype,"lastEditInfo",void 0),e([g({type:w})],ne.prototype,"location",void 0),e([g({readOnly:!0})],ne.prototype,"relatedInfos",void 0),e([g({type:A})],ne.prototype,"spatialReference",null),e([g()],ne.prototype,"timeZone",null),e([g({readOnly:!0})],ne.prototype,"title",void 0),e([g()],ne.prototype,"map",null),e([g({readOnly:!0})],ne.prototype,"waitingForContent",null),e([g()],ne.prototype,"view",void 0),ne=te=e([v("esri.widgets.Feature.FeatureViewModel")],ne);export{ne as default};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import s from"../../core/Accessor.js";import{isSome as o}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{IdentifiableMixin as n}from"../../core/Identifiable.js";import l from"../../core/Logger.js";import{abortMaybe as p}from"../../core/maybe.js";import{eachAlways as c,isAbortError as d,throwIfAborted as h}from"../../core/promiseUtils.js";import{watch as u,when as f,initial as m,on as _}from"../../core/reactiveUtils.js";import{throttle as y}from"../../core/throttle.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import{cast as b}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../geometry/Point.js";import A from"../../geometry/SpatialReference.js";import I from"../../popup/content/TextContent.js";import{system as x}from"../../time/constants.js";import M from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import T from"./FeatureContent/FeatureContentViewModel.js";import F from"./FeatureExpression/FeatureExpressionViewModel.js";import E from"./FeatureFields/FeatureFieldsViewModel.js";import C from"./FeatureMedia/FeatureMediaViewModel.js";import V from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{compileExpressionInfos as j,formatArcadeValue as k}from"./support/arcadeFeatureUtils.js";import{preLayerQueryCallback as P,preRequestCallback as R,createFieldInfoMap as L,getAllFieldInfos as O,getSourceLayer as N,querySourceLayer as U,queryUpdatedFeature as Z,isRelatableFeatureSupportedLayer as S,isAssociatedFeatureSupportedLayer as B,substituteFieldsInLinksAndAttributes as H,isExpressionField as D,isRelatedField as G,formatEditInfo as q,graphicCallback as z,formatAttributes as Q}from"./support/featureUtils.js";import{queryLayerInfos as J,queryRelatedFeatures as K,setRelatedFeatures as W,getRelatedFieldInfo as X,createRelatedInfo as Y,updateRelatedInfo as $}from"./support/relatedFeatureUtils.js";import ee from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";var te;const ie=1,se="content-view-models",oe="relationship-view-models",re="association-view-models",ae={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let ne=class extends(n(s)){static{te=this}constructor(e){super(e),this._error=null,this._graphicChangedTask=null,this._evaluateExpressionAttributesTask=null,this._associationVMAbortController=null,this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...ae},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.graphic=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._graphicChangedThrottled=y(this._graphicChanged,()=>this.notifyChange("waitingForContent"),ie,this),this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this._evaluateExpressionAttributesThrottled=y(this._evaluateExpressionAttributes,()=>this.notifyChange("waitingForContent"),ie,this),this.addHandles([u(()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone],()=>this._graphicChangedThrottled(),m),f(()=>{if(!this._graphicChangedTask?.finished||null==this._graphicChangedTask.value)return null;const e=this._graphicChangedTask.value,t=e?.expressionInfos?.dependencies;return[e,t?.has("view-scale")?this.view?.scale:null,t?.has("view-time-extent")?this.view?.timeExtent?.start:null,t?.has("view-time-extent")?this.view?.timeExtent?.end:null]},([e])=>this._evaluateExpressionAttributesThrottled(e))])}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=p(this._graphicChangedTask),this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}static{this.interceptor=new i(P,R)}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return L(O(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return N(this.graphic)}castAbilities(e){return{...ae,...e}}get isFeatureFromTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??x}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){const{_graphicChangedThrottled:e,_evaluateExpressionAttributesThrottled:t,_graphicChangedTask:i,_evaluateExpressionAttributesTask:s,_associationVMAbortController:o}=this;return e.hasPendingUpdates()||t.hasPendingUpdates()||null!=i&&!i.finished||null!=s&&!s.finished||!!o}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof C&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof C&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof C&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const s=i?.objectIdField;if(!s||!e||!i)return;const o=e?.attributes?.[s];if(null==o)return;const r=[o];if(!e.geometry){const s=await U({layer:i,graphic:e,outFields:[],objectIds:r,returnGeometry:!0,spatialReference:t}),o=s?.geometry;o&&(e.geometry=o)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}_graphicChanged(){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._graphicChangedTask=p(this._graphicChangedTask),this._graphicChangedTask=r(async e=>{this._error=null,this._clear();const{graphic:t}=this;try{if(!t)return null;const{_sourceLayer:i,_effectivePopupTemplate:s}=this,o=this.spatialReference;await Z({graphic:t,popupTemplate:s,layer:i,spatialReference:o},{signal:e});const[{value:r},{value:a}]=await c([this._getContent(),this._getTitle()]),[,{value:n}]=await c([this._checkForRelatedFeatures({signal:e}),j(s?.expressionInfos,t)]);return{expressionInfos:n,content:r,title:a}}catch(i){throw d(i)||(this._error=i,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:t,popupTemplate:this._effectivePopupTemplate})),i}})}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map((e,t)=>this._compileContentElement(e,t)).filter(o):"string"==typeof e?this._compileText(new I({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(oe),this.removeHandles(se),this.contentViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),s=t?.getObjectId();return null!=i&&null!=s&&i===s}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:s,spatialReference:o,timeZone:r}=this;t?.filter(Boolean).forEach(t=>{e.some(e=>this._matchesFeature(e,t))||e.add(new te({abilities:{relationshipContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:t}))}),e.forEach(i=>{const s=t?.find(e=>this._matchesFeature(i,e));s||e.remove(i)})}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:s,contentElementViewModel:o}=e,r=s?.type;o&&r&&("fields"===r&&(this._createFieldsFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createFieldsVMParams(s,t))),"media"===r&&(this._createMediaFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createMediaVMParams(s,t))),"text"===r&&o.set(this._createTextVMParams(s)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:s,relationshipId:o,title:r,description:a}=e,{_sourceLayer:n,graphic:l,map:p}=this;if(!S(n))return;const c=new V({displayCount:i,graphic:l,orderByFields:s,relationshipId:o,layer:n,map:p,...this._compileTitleAndDesc({title:r,description:a})});return this.contentViewModels[t]=c,this.addHandles(_(()=>c.relatedFeatures,"change",()=>this._setRelatedFeaturesViewModels(c)),oe),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,s=t?.association.globalId;return null!=i&&null!=s&&i===s}_setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:s,spatialReference:o,timeZone:r}=this;e.forEach((i,s)=>{const o=t.get(s);o?i.forEach(t=>{o.find(e=>this._matchesGlobalFeature(t,e))||(i.remove(t),0===i.length&&e.delete(s))}):(i.removeAll(),e.delete(s))}),t.forEach((t,n)=>{const l=e.get(n)||new a;t?.filter(Boolean).forEach((e,t)=>{if(!l.some(t=>this._matchesGlobalFeature(t,e))){const{association:a,feature:n,terminalName:p,title:c}=e;l.add({title:c,association:a,featureViewModel:new te({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:n}),terminalName:p},t)}}),e.set(n,l)})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:s,description:o,associationTypes:r}=e,{_sourceLayer:a,graphic:n,map:l}=this;if(!B(a))return;const p=new ee({graphic:n,displayCount:i,associationTypes:r,layer:a,map:l,...this._compileTitleAndDesc({title:s,description:o})});return this.contentViewModels[t]=p,this.addHandles([u(()=>p.associationFeatures.values(),()=>this._setUpUtilityNetworkAssociationsViewModels(p.associationViewModels,p.associationFeatures,p.map))],re),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:s,map:o,spatialReference:r,view:a,location:n}=this,l=new F({expressionInfo:i,graphic:s,interceptor:te.interceptor,map:o,spatialReference:r,view:a,location:n});return this.contentViewModels[t]=l,this.addHandles(u(()=>l.contentElementViewModel,()=>this._setExpressionContentVM(l,t),m),se),e}_compileAttachments(e,t){const{graphic:i}=this,{description:s,title:o,orderByFields:r}=e;return this.contentViewModels[t]=new M({graphic:i,orderByFields:r,...this._compileTitleAndDesc({title:o,description:s})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:s,destroyer:o}=e;return this.contentViewModels[t]=new T({graphic:i,creator:s,destroyer:o}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:s,graphic:o,formattedAttributes:r}=this,a=o?.attributes,n=this._expressionAttributes,l=r.global;return{title:H({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:e}),description:H({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,s=this.formattedAttributes,o={...s?.global,...s?.content[t]},r=e?.fieldInfos||i?.fieldInfos,a=r?.filter(({fieldName:e})=>!!e&&(D(e)||G(e)||o.hasOwnProperty(e))),n=i?.expressionInfos,{description:l,title:p}=e;return{attributes:o,expressionInfos:n,fieldInfos:a,...this._compileTitleAndDesc({title:p,description:l})}}_compileFields(e,t){const i=e.clone(),s=new E(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=s,i.fieldInfos=s.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:s,_fieldInfoMap:o,_effectivePopupTemplate:r,relatedInfos:a,_sourceLayer:n,_expressionAttributes:l}=this,p=this.formattedAttributes,c=s?.attributes??{},{description:d,mediaInfos:h,title:u}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:c,isAggregate:s?.isAggregate,layer:n,fieldInfoMap:o,formattedAttributes:{...p?.global,...p?.content[t]},expressionAttributes:l,mediaInfos:h,popupTemplate:r,relatedInfos:a,...this._compileTitleAndDesc({title:u,description:d})}}_compileMedia(e,t){const i=e.clone(),s=new C(this._createMediaVMParams(e,t));return i.mediaInfos=s.formattedMediaInfos.slice(),this.contentViewModels[t]=s,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:s,_expressionAttributes:o}=this;if(e&&e.text){const r=t?.attributes??{},a=this.formattedAttributes?.global??{};e.text=H({attributes:r,fieldInfoMap:i,globalAttributes:a,expressionAttributes:o,layer:s,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new T(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:s}=this;if(!e)return;const{lastEditInfoEnabled:o}=e,r=t?.editFieldsInfo;return o&&r?q(r,i?.attributes,s,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:s,_expressionAttributes:o}=this,r=s?.attributes??{},a=this.formattedAttributes?.global??{};return H({attributes:r,fieldInfoMap:t,globalAttributes:a,expressionAttributes:o,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?z({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?z({type:"content",value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({title:e,content:t,expressionInfos:i}){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=r(async s=>{const{graphic:o,map:r,view:a,spatialReference:n,location:p}=this;try{if(!o)return;let l;if(null!=i){const e=[];for(const[t,l]of i.expressions.entries())null!=l?e.push(l.evaluate({graphic:o,interceptor:te.interceptor,location:p,map:r,options:{signal:s},spatialReference:n,view:a}).then(e=>[t,"string"==typeof e?k(e):e]).catch(()=>[t,void 0])):e.push(Promise.resolve([t,void 0]));l=Object.fromEntries(await Promise.all(e)),h(s)}this._expressionAttributes=l,this._graphicExpressionAttributes={...o.attributes,...l},this._set("formattedAttributes",this._createFormattedAttributes(t)),this._set("title",this._compileTitle(e)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(t)||null)}catch(c){d(c)||(this._error=c,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:c,graphic:o,popupTemplate:this._effectivePopupTemplate}))}})}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:s,graphic:o,relatedInfos:r,_sourceLayer:a,_fieldInfoMap:n,_graphicExpressionAttributes:l,timeZone:p}=this;i.content[t]=Q({fieldInfos:s?.fieldInfos,graphic:o,attributes:{...l,...e.attributes},layer:a,fieldInfoMap:n,relatedInfos:r,timeZone:p})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:s,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:a,_graphicExpressionAttributes:n,timeZone:l}=this;i.content[t]=Q({fieldInfos:e.fieldInfos,graphic:s,attributes:{...n,...e.attributes},layer:r,fieldInfoMap:a,relatedInfos:o,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:s,_sourceLayer:o,_fieldInfoMap:r,_graphicExpressionAttributes:a,timeZone:n}=this,l=t?.fieldInfos,p={global:Q({fieldInfos:l,graphic:i,attributes:a,layer:o,fieldInfoMap:r,relatedInfos:s,timeZone:n}),content:[]};return Array.isArray(e)&&e.forEach((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p})}),p}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,O(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:s,_sourceLayer:o}=this;s.clear();const r=null!=o?.associatedLayer?await(o?.associatedLayer.load(i)):o;if(!r||!e)return;const a=t.filter(e=>!!e.fieldName&&G(e.fieldName));if(!a?.length)return;t.forEach(e=>this._configureRelatedInfo(e,r));const n=await J({relatedInfos:s,layer:r},i);Object.keys(n).forEach(e=>{const t=s.get(e.toString()),i=n[e]?.value;t&&i&&(t.layerInfo=i.data)});const l=await K({graphic:e,relatedInfos:s,layer:r},i);Object.keys(l).forEach(e=>{W(l[e]?.value,s.get(e.toString()))})}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,s=X(e.fieldName||"");if(!s)return;const{layerId:o,fieldName:r}=s;if(!o)return;const a=i.get(o.toString())||Y(o,t);a&&($({relatedInfo:a,fieldName:r,fieldInfo:e}),this.relatedInfos.set(o,a))}};e([g()],ne.prototype,"_error",void 0),e([g()],ne.prototype,"_graphicChangedTask",void 0),e([g()],ne.prototype,"_evaluateExpressionAttributesTask",void 0),e([g()],ne.prototype,"_associationVMAbortController",void 0),e([g({readOnly:!0})],ne.prototype,"_effectivePopupTemplate",null),e([g({readOnly:!0})],ne.prototype,"_fieldInfoMap",null),e([g({readOnly:!0})],ne.prototype,"_sourceLayer",null),e([g()],ne.prototype,"abilities",void 0),e([b("abilities")],ne.prototype,"castAbilities",null),e([g({readOnly:!0})],ne.prototype,"content",void 0),e([g({readOnly:!0})],ne.prototype,"contentViewModels",void 0),e([g()],ne.prototype,"description",void 0),e([g({type:Boolean})],ne.prototype,"defaultPopupTemplateEnabled",void 0),e([g({readOnly:!0})],ne.prototype,"isFeatureFromTable",null),e([g({readOnly:!0})],ne.prototype,"state",null),e([g({readOnly:!0})],ne.prototype,"formattedAttributes",void 0),e([g({type:t})],ne.prototype,"graphic",void 0),e([g({readOnly:!0})],ne.prototype,"lastEditInfo",void 0),e([g({type:w})],ne.prototype,"location",void 0),e([g({readOnly:!0})],ne.prototype,"relatedInfos",void 0),e([g({type:A})],ne.prototype,"spatialReference",null),e([g()],ne.prototype,"timeZone",null),e([g({readOnly:!0})],ne.prototype,"title",void 0),e([g()],ne.prototype,"map",null),e([g({readOnly:!0})],ne.prototype,"waitingForContent",null),e([g()],ne.prototype,"view",void 0),ne=te=e([v("esri.widgets.Feature.FeatureViewModel")],ne);export{ne as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{renderingSanitizer as t}from"../../../../core/sanitizerUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import s from"../../../Widget.js";import i from"./ButtonMenuViewModel.js";import{loadCalciteComponents as r}from"../../../support/componentsUtils.js";import{globalCss as l}from"../../../support/globalCss.js";import{storeNode as a,isActivationKey as d}from"../../../support/widgetUtils.js";import{tsx as p}from"../../../support/jsxFactory.js";const c="esri-button-menu",m={base:c,content:`${c}__content`,itemWrapper:`${c}__item-wrapper`,icon:`${c}__icon`,item:`${c}__item`,itemLabel:`${c}__item-label`,itemLabelContent:`${c}__item-label-content`,selectableMenuItem:`${c}__item--selectable`,selectedMenuItem:`${c}__item--selected`,checkbox:`${c}__checkbox`,embeddedContentWrapper:`${c}__embedded-content-wrapper`,button:`${c}__button`,buttonSelected:`${c}__button--selected`};let u=class extends s{constructor(e,t){super(e,t),this._popover=null,this.disabled=!1,this.viewModel=new i}loadDependencies(){return r({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._popover=null}get items(){return this.viewModel.items}set items(e){this.viewModel.items=e}get open(){return this.viewModel.open}set open(e){this.viewModel.open=e}render(){const{open:e}=this,t=`${this.id}-button`;return p("div",{class:this.classes(m.base,l.widget),key:"menu"},p("calcite-button",{appearance:"transparent",bind:this,class:this.classes(m.button,e&&m.buttonSelected),disabled:this.disabled,iconStart:e?"x":"ellipsis",id:t,kind:"neutral",label:this.label||"button",onclick:()=>this._toggleOpen(e),tabIndex:0}),p("calcite-popover",{afterCreate:a,afterUpdate:()=>this._popover?.reposition(),autoClose:!0,bind:this,"data-node-ref":"_popover",label:this.label||"menu",open:e,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:t,onCalcitePopoverClose:this._onPopoverClose},this._renderMenuContent()))}_onPopoverClose(){this.open=!1}_renderMenuContent(){const{id:e,open:t}=this;return p("div",{afterCreate:this._afterMenuContentNodeCreate,bind:this,class:m.content,hidden:!t,key:"esri-button-menu-content"},p("ul",{"aria-labelledby":`${e}-button`,bind:this,class:m.itemWrapper,id:`${e}-menu`,role:"menu"},this.items?.length?this._renderItems():null))}_renderItems(){return this.items?.map((e,t)=>this._renderItem(e,t))}_renderItem(e,o,n){const s=null!=n?`${this.id}-menu-item-${o}-${n}`:`${this.id}-menu-item-${o}`,i=`${s}-label`,r=this.classes(m.item,e.selectionEnabled?m.selectableMenuItem:null,e.selectionEnabled&&e.selected?m.selectedMenuItem:null);return p("li",{afterCreate:this._afterMenuItemCreate,bind:this,class:r,"data-item-index":o,"data-item-subIndex":n,for:s,key:s,onclick:t=>this._handleMenuItemInteraction(t,e),onkeydown:t=>this._handleMenuItemKeydown(t,e),role:"menuitem",tabIndex:this.disabled?-1:0},p("input",{checked:e.selected,class:m.checkbox,disabled:!0,id:s,name:s,tabIndex:-1,type:"checkbox"}),p("label",{class:m.itemLabel,for:s,id:i},p("span",{"aria-hidden":"true",class:m.icon}),p("span",{class:m.itemLabelContent},t.sanitize(e.label))),p("ul",{"aria-labelledby":i,class:m.embeddedContentWrapper,id:`${this.id}-submenu`,role:"menu"},e?.items?.map((e,t)=>this._renderItem(e,o,t))))}_handleMenuItemInteraction(e,t){t.selected=!t.selected,t.open=!(!t.selected||!t.items),t.autoCloseMenu&&this.set("open",!1),t.clickFunction&&t.clickFunction({event:e,item:t}),e.stopPropagation()}_handleMenuItemKeydown(e,t){const{key:o}=e;d(o)&&this._handleMenuItemInteraction(e,t),"Escape"===o&&(this.open=!1,e.preventDefault(),e.stopPropagation())}_afterMenuContentNodeCreate(e){e.focus()}_toggleOpen(e){this.open=!e}_afterMenuItemCreate(e){0===e["data-item-index"]&&e.focus()}};e([o()],u.prototype,"disabled",void 0),e([o()],u.prototype,"items",null),e([o()],u.prototype,"open",null),e([o()],u.prototype,"viewModel",void 0),u=e([n("esri.widgets.FeatureTable.Grid.support.ButtonMenu")],u);const b=u;export{b as default};
5
+ import{__decorate as e}from"tslib";import{renderingSanitizer as t}from"../../../../core/sanitizerUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import s from"../../../Widget.js";import i from"./ButtonMenuViewModel.js";import{loadCalciteComponents as r}from"../../../support/componentsUtils.js";import{globalCss as l}from"../../../support/globalCss.js";import{storeNode as a,isActivationKey as d}from"../../../support/widgetUtils.js";import{tsx as p}from"../../../support/jsxFactory.js";const c="esri-button-menu",m={base:c,content:`${c}__content`,itemWrapper:`${c}__item-wrapper`,icon:`${c}__icon`,item:`${c}__item`,itemLabel:`${c}__item-label`,itemLabelContent:`${c}__item-label-content`,selectableMenuItem:`${c}__item--selectable`,selectedMenuItem:`${c}__item--selected`,checkbox:`${c}__checkbox`,embeddedContentWrapper:`${c}__embedded-content-wrapper`,button:`${c}__button`,buttonSelected:`${c}__button--selected`};let u=class extends s{constructor(e,t){super(e,t),this._popover=null,this.disabled=!1,this.viewModel=new i}loadDependencies(){return r({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._popover=null}get items(){return this.viewModel.items}set items(e){this.viewModel.items=e}get open(){return this.viewModel.open}set open(e){this.viewModel.open=e}render(){const{open:e}=this,t=`${this.id}-button`;return p("div",{class:this.classes(m.base,l.widget),key:"menu"},p("calcite-button",{appearance:"transparent",bind:this,class:this.classes(m.button,e&&m.buttonSelected),disabled:this.disabled,iconStart:e?"x":"ellipsis",id:t,kind:"neutral",label:this.label||"button",onclick:()=>this._toggleOpen(e),tabIndex:0}),p("calcite-popover",{afterCreate:a,afterUpdate:()=>this._popover?.reposition(),autoClose:!0,bind:this,"data-node-ref":"_popover",label:this.label||"menu",open:e,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:t,onCalcitePopoverClose:this._onPopoverClose},this._renderMenuContent()))}_onPopoverClose(){this.open=!1}_renderMenuContent(){const{id:e,open:t}=this;return p("div",{afterCreate:this._afterMenuContentNodeCreate,bind:this,class:m.content,hidden:!t,key:"esri-button-menu-content"},p("ul",{"aria-labelledby":`${e}-button`,bind:this,class:m.itemWrapper,id:`${e}-menu`,role:"menu"},this.items?.length?this._renderItems():null))}_renderItems(){return this.items?.map((e,t)=>this._renderItem(e,t))}_renderItem(e,o,n){const s=null!=n?`${this.id}-menu-item-${o}-${n}`:`${this.id}-menu-item-${o}`,i=`${s}-label`,r=this.classes(m.item,e.selectionEnabled?m.selectableMenuItem:null,e.selectionEnabled&&e.selected?m.selectedMenuItem:null);return p("li",{afterCreate:this._afterMenuItemCreate,bind:this,class:r,"data-item-index":o,"data-item-subIndex":n,for:s,key:s,onclick:t=>this._handleMenuItemInteraction(t,e),onkeydown:t=>this._handleMenuItemKeydown(t,e),role:"menuitem",tabIndex:this.disabled?-1:0},p("input",{checked:e.selected,class:m.checkbox,disabled:!0,id:s,name:s,tabIndex:-1,type:"checkbox"}),p("label",{class:m.itemLabel,for:s,id:i},p("span",{"aria-hidden":"true",class:m.icon}),p("span",{class:m.itemLabelContent},t.sanitize(e.label))),p("ul",{"aria-labelledby":i,class:m.embeddedContentWrapper,id:`${this.id}-submenu`,role:"menu"},e?.items?.map((e,t)=>this._renderItem(e,o,t))))}_handleMenuItemInteraction(e,t){t.selected=!t.selected,t.open=!(!t.selected||!t.items),t.autoCloseMenu&&this.set("open",!1),t.clickFunction?.({event:e,item:t}),e.stopPropagation()}_handleMenuItemKeydown(e,t){const{key:o}=e;d(o)&&this._handleMenuItemInteraction(e,t),"Escape"===o&&(this.open=!1,e.preventDefault(),e.stopPropagation())}_afterMenuContentNodeCreate(e){e.focus()}_toggleOpen(e){this.open=!e}_afterMenuItemCreate(e){0===e["data-item-index"]&&e.focus()}};e([o()],u.prototype,"disabled",void 0),e([o()],u.prototype,"items",null),e([o()],u.prototype,"open",null),e([o()],u.prototype,"viewModel",void 0),u=e([n("esri.widgets.FeatureTable.Grid.support.ButtonMenu")],u);const b=u;export{b as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- const e="esri-floor-filter",t=`${e}__filter-menu`,o={floorFilter:e,floorFilterLayout:`${e}__layout--`,floorFilterPosition:`${e}__position--`,buttonContainer:`${e}__button-container`,buttonContainerLevels:`${e}__button-container--levels`,buttonInfo:`${e}__button-info`,buttonLabel:`${e}__button-label`,browseButton:`${e}__browse-button`,closeLevelsButton:`${e}__close-levels-button`,zoomButton:`${e}__zoom-button`,zoomButtonLevels:`${e}__zoom-button--levels`,minimizeToggleButton:`${e}__minimize-toggle-button`,levelsContainer:`${e}__levels-container`,levelButton:`${e}__level-button`,levelButtonActive:`${e}__level-button--active`,iconFlip:"esri-collapse__icon-flip",separator:`${e}__separator`,filterMenu:t,filterMenuHeader:`${t}-header`,filterMenuHeaderTextGroup:`${t}-header-text-group`,filterMenuHeaderText:`${t}-header-text`,filterMenuHeaderSubtext:`${t}-header-subtext`,filterMenuHeaderBack:`${t}-header-back`,filterMenuSearch:`${t}-search`,filterMenuSearchInput:`${t}-search-input`,filterMenuItems:`${t}-items`,filterMenuItemName:`${t}-item-name`,filterMenuSelectedItem:`${t}-item-name--selected`,filterMenuSite:`${t}-site`,filterMenuFacility:`${t}-facility`,selectedItemCircle:`${e}__selected-item-circle`};export{o as css};
5
+ const e="esri-floor-filter",t=`${e}__filter-menu`,o={floorFilter:e,floorFilterLayout:`${e}__layout--`,floorFilterPosition:`${e}__position--`,buttonContainer:`${e}__button-container`,buttonContainerLevels:`${e}__button-container--levels`,buttonInfo:`${e}__button-info`,buttonLabel:`${e}__button-label`,browseButton:`${e}__browse-button`,closeLevelsButton:`${e}__close-levels-button`,zoomButton:`${e}__zoom-button`,zoomButtonLevels:`${e}__zoom-button--levels`,minimizeToggleButton:`${e}__minimize-toggle-button`,levelsContainer:`${e}__levels-container`,levelButton:`${e}__level-button`,levelButtonActive:`${e}__level-button--active`,iconClose:`${e}__icon-close`,iconFlip:`${e}__icon-flip`,iconLeft:`${e}__icon-left`,iconRight:`${e}__icon-right`,separator:`${e}__separator`,filterMenu:t,filterMenuHeader:`${t}-header`,filterMenuHeaderTextGroup:`${t}-header-text-group`,filterMenuHeaderText:`${t}-header-text`,filterMenuHeaderSubtext:`${t}-header-subtext`,filterMenuHeaderBack:`${t}-header-back`,filterMenuSearch:`${t}-search`,filterMenuSearchInput:`${t}-search-input`,filterMenuItems:`${t}-items`,filterMenuItemName:`${t}-item-name`,filterMenuSelectedItem:`${t}-item-name--selected`,filterMenuSite:`${t}-site`,filterMenuFacility:`${t}-facility`,selectedItemCircle:`${e}__selected-item-circle`};export{o as css};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"../intl.js";import{watch as t}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import l from"./Widget.js";import{css as o}from"./FloorFilter/css.js";import n from"./FloorFilter/FloorFilterViewModel.js";import{globalCss as r}from"./support/globalCss.js";import{Heading as a,incrementHeadingLevel as c}from"./support/Heading.js";import{legacyIcon as h}from"./support/legacyIcon.js";import{isRTL as d,storeNode as u}from"./support/widgetUtils.js";import{messageBundle as v}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";import{substitute as p}from"../intl/substitute.js";const M=new Set(["ArrowUp","ArrowDown","End","Home"]);let f=class extends l{constructor(e,s){super(e,s),this._activeMenu=null,this._activeMenuIndex={levels:-1,menuItems:-1},this._baseNode=null,this._facilitiesListNode=null,this._levelsListNode=null,this._sitesListNode=null,this._searchInput=null,this.viewModel=new n,this.messages=null,this.messagesCommon=null,this.headingLevel=2,this._resizeObserver=new ResizeObserver(()=>this.scheduleRender()),this.addHandles(t(()=>this._searchInput,()=>this._focusSearch()))}destroy(){this._resizeObserver?.disconnect()}get enabled(){return this.viewModel.enabled}set enabled(e){this.viewModel.enabled=e}get longNames(){return this.viewModel.longNames}set longNames(e){this.viewModel.longNames=e}get minimized(){return this.viewModel.minimized}set minimized(e){this.viewModel.minimized=e}get pinnedLevels(){return this.viewModel.pinnedLevels}set pinnedLevels(e){this.viewModel.pinnedLevels=e}get site(){return this.viewModel.site}set site(e){this.viewModel.site=e}get facility(){return this.viewModel.facility}set facility(e){this.viewModel.facility=e}get level(){return this.viewModel.level}set level(e){this.viewModel.level=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"floor-plan"}set icon(e){this._overrideIfSome("icon",e)}updateWebDocument(e){return this.viewModel.updateWebDocument(e)}render(){const{longNames:e}=this,t=e&&this.viewModel.isNormalMode?"expanded":"collapsed",s=this._renderButtons(),i=this._renderFilterMenu(),l=m("div",{class:this.classes(o.separator)}),n=this._getComponentPosition(),a=this._getPosition(n),c="top-right"===n||"bottom-right"===n,h="top-left"===n||"bottom-left"===n,u=d(this.container),v=u&&h||!u&&c?i:s,p=u&&h||!u&&c?s:i;return m("div",{afterCreate:this._afterBaseNodeCreate,class:this.classes(o.floorFilter,r.widget,`${o.floorFilterLayout}${t}`,`${o.floorFilterPosition}${a}`),key:"floor-filter-menu"},v,this.viewModel?.filterMenuOpen?l:null,p)}_renderButtons(){const e=this._getComponentPosition(),t=[];return"top"===this._getPosition(e)?(t.push(this._renderBrowseButton()),t.push(this._renderLevelButtons()),t.push(this._renderCloseLevelsButton()),t.push(this._renderZoomButton()),t.push(this._renderCollapseToggleButton())):(t.push(this._renderCollapseToggleButton()),t.push(this._renderZoomButton()),t.push(this._renderCloseLevelsButton()),t.push(this._renderLevelButtons()),t.push(this._renderBrowseButton())),m("div",{class:this.classes(r.widget,o.buttonContainer),key:"button-container"},t)}_renderBrowseButton(){const{longNames:e,messages:t}=this;return m("button",{"aria-expanded":this.viewModel.filterMenuOpen.toString(),"aria-label":t.buttons.browse,bind:this,class:this.classes(r.widget,r.widgetButton,r.interactive,("loading"===this.viewModel.state||"disabled"===this.viewModel.state)&&r.buttonDisabled,o.browseButton,this.viewModel?.filterMenuOpen&&r.widgetButtonActive),key:"browse-button",onclick:this._toggleFilterMenu,title:t.buttons.browse,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("span",{class:this.classes(h.icon,h.urbanModel)}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.buttons.browse:null)))}_renderLevelButtons(){if(!this.viewModel?.filterFeatures?.levels?.levelsInfo||!this.facility)return null;const{facility:e,messagesCommon:t,messages:s}=this,i=this.viewModel?.getFacility(e),l=this.viewModel?.getFacilityLevels(e),n=l.map(e=>this._renderLevelButton(e));if(!n.length)return null;const r=i&&p(s.selector.levelsLabel,{name:`"${i.name}"`});if(this._isWebScene(this.view?.map)&&n?.length>1){const s={id:`all--${e}`,facilityId:e,shortName:t.all,longName:t.all,levelNumber:null,verticalOrder:null},i=this._renderLevelButton(s);n.push(i)}return m("ul",{afterCreate:u,"aria-label":r,bind:this,class:this.classes(o.levelsContainer),"data-id":"levels","data-node-ref":"_levelsListNode",key:"levels-button-container",onkeydown:this._handleListKeydown},n)}_renderLevelButton(e){const{longNames:t}=this,{shortName:s,longName:i,id:l}=e,n=`levels--${l}`,a=this.level===l,c=t&&this.viewModel.isNormalMode?i:s;return this.viewModel.isNormalMode||a||this.viewModel.levelsExpanded?m("li",{key:n},m("button",{bind:this,class:this.classes(r.widgetButton,a?r.widgetButtonActive:null,r.interactive,o.levelButton),"data-id":l,"data-list-id":"levels",onclick:this._levelSelected,onfocus:this._onItemFocus,type:"button"},c)):null}_renderCloseLevelsButton(){if(!this.level||this.viewModel.isNormalMode||!this.viewModel.levelsExpanded)return null;const{messagesCommon:e}=this;return m("button",{"aria-label":e.close,bind:this,class:this.classes(r.widget,r.widgetButton,r.interactive,o.closeLevelsButton),key:"close-levels-button",onclick:this._closeLevels,title:e.close,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("span",{class:this.classes(h.icon,h.close)})))}_renderZoomButton(){const{longNames:e,messages:t,facility:s,site:i}=this,l=this.viewModel?.filterMenuType,n=this.viewModel?.filterMenuOpen,a=this.viewModel?.getSite(i),c=this.viewModel?.getFacility(s),d="site"===l&&n?!a:!c;return m("button",{"aria-label":t.buttons.zoomTo,bind:this,class:this.classes(r.widget,r.widgetButton,d&&r.buttonDisabled,r.interactive,this.viewModel?.getFacilityLevels(s).length>0?o.zoomButtonLevels:o.zoomButton),key:"zoom-button",onclick:this._zoomToClicked,title:t.buttons.zoomTo,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("span",{class:this.classes(h.icon,h.zoomToObject)}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.buttons.zoomTo:null)))}_renderCollapseToggleButton(){const{longNames:e,messagesCommon:t}=this,s=e?h.collapse:h.expand,i=this.classes(h.icon,s,o.iconFlip),l=e?t.collapse:t.expand;return m("button",{"aria-label":l,bind:this,class:this.classes(r.widget,r.widgetButton,r.interactive,o.minimizeToggleButton),key:"minimize-toggle-button",onclick:this._toggleCollapsed,title:l,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("span",{class:i}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.collapse:null)))}_renderFilterMenu(){return this.viewModel?.filterMenuOpen?"site"===this.viewModel?.filterMenuType?this._renderSiteFilterMenu():"facility"===this.viewModel?.filterMenuType?this._renderFacilityFilterMenu():null:null}_renderSiteFilterMenu(){const{messages:e,messagesCommon:t}=this,s=this.site?this.viewModel?.getSite(this.site)?.name:e.selector.selectSite,i=m("div",{class:this.classes(`${o.filterMenuHeader}`),key:"filter-menu-site-header"},m("div",{class:this.classes(o.filterMenuHeaderTextGroup)},m(a,{class:this.classes(o.filterMenuHeaderText),level:this.headingLevel},s)),m("button",{bind:this,class:this.classes(h.icon,h.close),onclick:this._closeClicked,title:t.close,type:"button"})),l=this._renderSearchInput(),n=this._renderSiteItems();return m("div",{class:this.classes(o.filterMenu),key:"filter-menu-site"},i,l,n)}_renderFacilityFilterMenu(){const{messages:e,messagesCommon:t,site:s}=this,i=this.viewModel?.getSite(s)?.name,l=this.facility&&this.viewModel?.getFacility(this.facility)?.name||e.selector.selectFacility,n=this.viewModel.hasMultipleSites?m("button",{bind:this,class:this.classes(o.filterMenuHeaderBack),onclick:this._backClicked,title:t.back,type:"button"},m("span",{class:this.classes(d(this.container)?h.right:h.left)})):null,r=this.viewModel.hasMultipleSites?m(a,{class:this.classes(o.filterMenuHeaderSubtext),level:c(this.headingLevel)},i):null,u=m("div",{class:this.classes(o.filterMenuHeader),key:"filter-menu-site-header"},n,m("div",{class:this.classes(o.filterMenuHeaderTextGroup)},m(a,{class:this.classes(o.filterMenuHeaderText),level:this.headingLevel},l),r),m("button",{bind:this,class:this.classes(h.icon,h.close),onclick:this._closeClicked,title:t.close,type:"button"})),v=this._renderSearchInput(),p=this._renderFacilityItems();return m("div",{class:this.classes(o.filterMenu),key:"filter-menu-facility"},u,v,p)}_renderSearchInput(){const{messagesCommon:e}=this,t=!!(this.viewModel.searchTerm&&this.viewModel.searchTerm?.length>0);return m("div",{class:this.classes(o.filterMenuSearch),key:"filter-menu-search"},m("span",{class:this.classes(h.icon,h.search),key:"filter-menu-search-icon"}),m("input",{afterCreate:u,bind:this,class:this.classes(o.filterMenuSearchInput),"data-node-ref":"_searchInput",oninput:this._onSearchChange,onpaste:this._onSearchChange,placeholder:e.search,value:this.viewModel.searchTerm??void 0}),t?m("span",{bind:this,class:this.classes(h.icon,h.close),key:"filter-menu-search-clear",onclick:this._onSearchClear,title:e.clear}):null)}_renderBlueCircle(){return m("span",{class:this.classes(o.selectedItemCircle),key:"floor-filter__selected-item-circle"})}_renderSiteItems(){if(!this.viewModel?.filterFeatures?.sites?.sitesInfo)return null;const{messages:e}=this,t=this.viewModel.filterFeatures.sites.sitesInfo,s=this.viewModel.filterSites(t).map(e=>this._renderSiteItem(e)),i=0===s.length&&this.viewModel?.searchTerm&&m("div",{class:this.classes(r.empty)},e.noResults);return m("ul",{afterCreate:u,"aria-label":e.selector.sitesLabel,bind:this,class:this.classes(o.filterMenuItems),"data-id":"sites","data-node-ref":"_sitesListNode",key:"filter-menu-items--sites",onkeydown:this._handleListKeydown,tabIndex:-1},s,i)}_renderSiteItem(e){const{name:t,id:s}=e,i=`filter-menu-site--${s}`,l=this.site===s;return m("li",{key:i},m("button",{bind:this,class:this.classes(o.filterMenuSite),"data-id":s,"data-list-id":"sites",onclick:this._siteSelected,onfocus:this._onItemFocus,type:"button"},l?this._renderBlueCircle():null,m("span",{class:this.classes(l?o.filterMenuSelectedItem:o.filterMenuItemName)},t),m("span",{class:this.classes(d(this.container)?h.left:h.right)})))}_renderFacilityItems(){if(!this.viewModel?.filterFeatures?.facilities?.facilitiesInfo)return null;const{messages:e,site:t}=this,s=this.viewModel.getSite(t),i=this.viewModel.filterFeatures.facilities.facilitiesInfo,l=this.viewModel.filterFacilities(i).map(e=>this._renderFacilityItem(e)),n=0===l.length&&this.viewModel?.searchTerm&&m("div",{class:this.classes(r.empty)},e.noResults),a=s?p(e.selector.siteFacilitiesLabel,{name:`"${s.name}"`}):e.selector.facilitiesLabel;return m("ul",{afterCreate:u,"aria-label":a,bind:this,class:this.classes(o.filterMenuItems),"data-id":"facilities","data-node-ref":"_facilitiesListNode",key:"filter-menu-items--facilities",onkeydown:this._handleListKeydown,tabIndex:-1},l,n)}_renderFacilityItem(e){const{name:t,id:s}=e,i=`filter-menu-facility--${s}`,l=this.facility===s;return m("li",{key:i},m("button",{bind:this,class:this.classes(o.filterMenuFacility),"data-id":s,"data-list-id":"facilities",onclick:this._facilitySelected,onfocus:this._onItemFocus,type:"button"},l?this._renderBlueCircle():null,m("span",{class:this.classes(l?o.filterMenuSelectedItem:o.filterMenuItemName)},t)))}_afterBaseNodeCreate(e){this._baseNode&&this._resizeObserver?.unobserve(this._baseNode),this._baseNode=e,this._resizeObserver?.observe(this._baseNode)}_toggleCollapsed(){this.longNames=!this.longNames}_toggleFilterMenu(){const e=this.viewModel?.filterMenuOpen??!1;this.viewModel.filterMenuOpen=!e}_setFilterMenuType(e){this.viewModel.filterMenuType=e}_zoomToClicked(){if(this.site&&"site"===this.viewModel?.filterMenuType&&this.viewModel?.filterMenuOpen){const e=this.viewModel?.getSite(this.site);this.viewModel.goTo(e)}else if(this.facility){const e=this.viewModel?.getFacility(this.facility);this.viewModel.goTo(e)}else if(this.site){const e=this.viewModel?.getSite(this.site);this.viewModel.goTo(e)}}_onSearchChange(e){const t=e.target;""===t.value?this.viewModel.searchTerm=null:t.value&&this.viewModel?.searchTerm!==t.value&&(this.viewModel.searchTerm=t.value)}_onSearchClear(){this.viewModel.searchTerm=null}_closeClicked(){this.viewModel.searchTerm=null,this.viewModel.filterMenuOpen=!1}_backClicked(){this._setFilterMenuType("site"),this.viewModel.searchTerm=null}_siteSelected(e){const t=e.currentTarget.getAttribute("data-id"),s=this.viewModel.getSite(t);let i=!1;this.site!==t&&(this.facility=null,this.level=null,i=!0,this.viewModel.levelsExpanded=!1),this.site=t,this.viewModel.searchTerm=null,this._setFilterMenuType("facility"),this.viewModel.goTo(s),i&&this.viewModel.setFloors(null)}_facilitySelected(e){const t=e.currentTarget.getAttribute("data-id"),s=this.viewModel.getFacility(t);let i=!1;if(this.facility!==t){if("base-floors"===this.viewModel.filterMode){const e=this.viewModel?.getBaseLevel(s);this.level=e?e.id:null}else this.level=null;i=!0,this.viewModel.levelsExpanded=!1}if(this.facility=t,this.viewModel.goTo(s),i){const e=this.viewModel.getLevel(this.level);this.viewModel.setFloors(e)}if(!this.viewModel.isNormalMode){const e=this.viewModel.getFacilityLevels(t);e?.length>1&&(this.viewModel.levelsExpanded=!0)}setTimeout(()=>this._focusActiveLevel(),50)}_levelSelected(e){const t=e.currentTarget.getAttribute("data-id");this.level=t}_closeLevels(){this.viewModel.levelsExpanded=!1}_isWebScene(e){return"esri.WebScene"===e?.declaredClass}_getComponentPosition(){return null!=this.container?this.view?.ui?.getPosition(this.container):null}_getPosition(e){switch(e){case"bottom-right":case"bottom-left":return"bottom";default:return"top"}}_handleListKeydown(e){const t=e.currentTarget.getAttribute("data-id");let s=null;"sites"===t||"facilities"===t?(this._activeMenu!==t&&(this._activeMenuIndex.menuItems=-1),this._activeMenu=t,s="menuItems"):"levels"===t&&(s="levels");const i="sites"===t?this._sitesListNode:"facilities"===t?this._facilitiesListNode:"levels"===t?this._levelsListNode:null,{key:l}=e,o="Tab"===l,n=M.has(l);n&&e.preventDefault();const r=i?.getElementsByTagName("li");r&&0!==r.length&&(n||o)&&this._handleItemNavigation(l,e.shiftKey,r,o,s)}_handleItemNavigation(e,t,s,i,l){if(!l)return;this._activeMenuIndex[l]===s.length&&this._activeMenuIndex[l]--,-1===this._activeMenuIndex[l]&&this._activeMenuIndex[l]++;const o=this._activeMenuIndex[l];switch(e){case"Home":this._activeMenuIndex[l]=0;break;case"End":this._activeMenuIndex[l]=s.length-1;break;case"ArrowUp":this._activeMenuIndex[l]=this._activeMenuIndex[l]<=0?s.length-1:this._activeMenuIndex[l]-1;break;case"ArrowDown":this._activeMenuIndex[l]=this._activeMenuIndex[l]===s.length-1?0:this._activeMenuIndex[l]+1}if("Tab"===e&&t&&this._activeMenuIndex[l]>=0&&this._activeMenuIndex[l]--,"Tab"===e&&!t&&this._activeMenuIndex[l]<s.length&&this._activeMenuIndex[l]++,o!==this._activeMenuIndex[l]&&this._activeMenuIndex[l]>-1&&this._activeMenuIndex[l]<s.length&&!i){const e=s[this._activeMenuIndex[l]].getElementsByTagName("button"),t=1===e?.length?e[0]:null;t?.focus()}}_focusSearch(){this._searchInput?.focus()}_focusActiveLevel(){const{level:e}=this,t=this._levelsListNode,s=t?.getElementsByTagName("li");if(!e||!t||!s)return;const i=this._facilitiesListNode?.getElementsByTagName("li");this._activeMenuIndex.menuItems=i?i.length-1:-1;const l=[];for(let o=0;o<s.length;o++){const e=s[o].getElementsByTagName("button");1===e?.length&&l.push(e[0])}l.forEach((t,s)=>{t.getAttribute("data-id")===e&&(t.focus(),this._activeMenuIndex.levels=s)})}_onItemFocus(e){const t=e.currentTarget,s=t.getAttribute("data-list-id"),i=t.getAttribute("data-id"),l="sites"===s?this._sitesListNode:"facilities"===s?this._facilitiesListNode:"levels"===s?this._levelsListNode:null;if(!l)return;const o=l?.getElementsByTagName("li");if(!o)return;const n=[];Array.from(o).forEach(e=>{const t=e.getElementsByTagName("button");1===t?.length&&n.push(t[0])});let r=null;switch(s){case"sites":case"facilities":r="menuItems";break;case"levels":r="levels"}if(!r)return;const a=r;n.forEach((e,t)=>{e.getAttribute("data-id")===i&&this._activeMenuIndex[a]!==t&&(this._activeMenuIndex[a]=t)})}};e([s()],f.prototype,"_searchInput",void 0),e([s()],f.prototype,"enabled",null),e([s()],f.prototype,"longNames",null),e([s()],f.prototype,"minimized",null),e([s()],f.prototype,"pinnedLevels",null),e([s()],f.prototype,"site",null),e([s()],f.prototype,"facility",null),e([s()],f.prototype,"level",null),e([s()],f.prototype,"view",null),e([s({type:n})],f.prototype,"viewModel",void 0),e([s(),v("esri/widgets/FloorFilter/t9n/FloorFilter")],f.prototype,"messages",void 0),e([s(),v("esri/t9n/common")],f.prototype,"messagesCommon",void 0),e([s()],f.prototype,"goToOverride",null),e([s()],f.prototype,"headingLevel",void 0),e([s()],f.prototype,"icon",null),f=e([i("esri.widgets.FloorFilter")],f);const g=f;export{g as default};
5
+ import{__decorate as e}from"tslib";import"../intl.js";import{watch as t}from"../core/reactiveUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import l from"./Widget.js";import{css as o}from"./FloorFilter/css.js";import n from"./FloorFilter/FloorFilterViewModel.js";import{loadCalciteComponents as r}from"./support/componentsUtils.js";import{globalCss as a}from"./support/globalCss.js";import{Heading as c,incrementHeadingLevel as h}from"./support/Heading.js";import{isRTL as d,storeNode as u}from"./support/widgetUtils.js";import{messageBundle as v}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";import{substitute as M}from"../intl/substitute.js";const g=new Set(["ArrowUp","ArrowDown","End","Home"]);let f=class extends l{constructor(e,i){super(e,i),this._activeMenu=null,this._activeMenuIndex={levels:-1,menuItems:-1},this._baseNode=null,this._facilitiesListNode=null,this._levelsListNode=null,this._sitesListNode=null,this._searchInput=null,this.viewModel=new n,this.messages=null,this.messagesCommon=null,this.headingLevel=2,this._resizeObserver=new ResizeObserver(()=>this.scheduleRender()),this.addHandles(t(()=>this._searchInput,()=>this._focusSearch()))}loadDependencies(){return r({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon")})}destroy(){this._resizeObserver?.disconnect()}get enabled(){return this.viewModel.enabled}set enabled(e){this.viewModel.enabled=e}get longNames(){return this.viewModel.longNames}set longNames(e){this.viewModel.longNames=e}get minimized(){return this.viewModel.minimized}set minimized(e){this.viewModel.minimized=e}get pinnedLevels(){return this.viewModel.pinnedLevels}set pinnedLevels(e){this.viewModel.pinnedLevels=e}get site(){return this.viewModel.site}set site(e){this.viewModel.site=e}get facility(){return this.viewModel.facility}set facility(e){this.viewModel.facility=e}get level(){return this.viewModel.level}set level(e){this.viewModel.level=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"urban-model"}set icon(e){this._overrideIfSome("icon",e)}updateWebDocument(e){return this.viewModel.updateWebDocument(e)}render(){const{longNames:e}=this,t=e&&this.viewModel.isNormalMode?"expanded":"collapsed",i=this._renderButtons(),s=this._renderFilterMenu(),l=m("div",{class:this.classes(o.separator)}),n=this._getComponentPosition(),r=this._getPosition(n),c="top-right"===n||"bottom-right"===n,h="top-left"===n||"bottom-left"===n,u=d(this.container),v=u&&h||!u&&c?s:i,M=u&&h||!u&&c?i:s;return m("div",{afterCreate:this._afterBaseNodeCreate,class:this.classes(o.floorFilter,a.widget,`${o.floorFilterLayout}${t}`,`${o.floorFilterPosition}${r}`),key:"floor-filter-menu"},v,this.viewModel?.filterMenuOpen?l:null,M)}_renderButtons(){const e=this._getComponentPosition(),t=[];return"top"===this._getPosition(e)?(t.push(this._renderBrowseButton()),t.push(this._renderLevelButtons()),t.push(this._renderCloseLevelsButton()),t.push(this._renderZoomButton()),t.push(this._renderCollapseToggleButton())):(t.push(this._renderCollapseToggleButton()),t.push(this._renderZoomButton()),t.push(this._renderCloseLevelsButton()),t.push(this._renderLevelButtons()),t.push(this._renderBrowseButton())),m("div",{class:this.classes(a.widget,o.buttonContainer),key:"button-container"},t)}_renderBrowseButton(){const{longNames:e,messages:t}=this;return m("button",{"aria-expanded":this.viewModel.filterMenuOpen.toString(),"aria-label":t.buttons.browse,bind:this,class:this.classes(a.widget,a.widgetButton,a.interactive,("loading"===this.viewModel.state||"disabled"===this.viewModel.state)&&a.buttonDisabled,o.browseButton,this.viewModel?.filterMenuOpen&&a.widgetButtonActive),key:"browse-button",onclick:this._toggleFilterMenu,title:t.buttons.browse,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("calcite-icon",{icon:this.icon,scale:"s"}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.buttons.browse:null)))}_renderLevelButtons(){if(!this.viewModel?.filterFeatures?.levels?.levelsInfo||!this.facility)return null;const{facility:e,messagesCommon:t,messages:i}=this,s=this.viewModel?.getFacility(e),l=this.viewModel?.getFacilityLevels(e),n=l.map(e=>this._renderLevelButton(e));if(!n.length)return null;const r=s&&M(i.selector.levelsLabel,{name:`"${s.name}"`});if(this._isWebScene(this.view?.map)&&n?.length>1){const i={id:`all--${e}`,facilityId:e,shortName:t.all,longName:t.all,levelNumber:null,verticalOrder:null},s=this._renderLevelButton(i);n.push(s)}return m("ul",{afterCreate:u,"aria-label":r,bind:this,class:this.classes(o.levelsContainer),"data-id":"levels","data-node-ref":"_levelsListNode",key:"levels-button-container",onkeydown:this._handleListKeydown},n)}_renderLevelButton(e){const{longNames:t}=this,{shortName:i,longName:s,id:l}=e,n=`levels--${l}`,r=this.level===l,c=t&&this.viewModel.isNormalMode?s:i;return this.viewModel.isNormalMode||r||this.viewModel.levelsExpanded?m("li",{key:n},m("button",{bind:this,class:this.classes(a.widgetButton,r?a.widgetButtonActive:null,a.interactive,o.levelButton),"data-id":l,"data-list-id":"levels",onclick:this._levelSelected,onfocus:this._onItemFocus,type:"button"},c)):null}_renderCloseLevelsButton(){if(!this.level||this.viewModel.isNormalMode||!this.viewModel.levelsExpanded)return null;const{messagesCommon:e}=this;return m("button",{"aria-label":e.close,bind:this,class:this.classes(a.widget,a.widgetButton,a.interactive,o.closeLevelsButton),key:"close-levels-button",onclick:this._closeLevels,title:e.close,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("calcite-icon",{icon:"x"})))}_renderZoomButton(){const{longNames:e,messages:t,facility:i,site:s}=this,l=this.viewModel?.filterMenuType,n=this.viewModel?.filterMenuOpen,r=this.viewModel?.getSite(s),c=this.viewModel?.getFacility(i),h="site"===l&&n?!r:!c;return m("button",{"aria-label":t.buttons.zoomTo,bind:this,class:this.classes(a.widget,a.widgetButton,h&&a.buttonDisabled,a.interactive,this.viewModel?.getFacilityLevels(i).length>0?o.zoomButtonLevels:o.zoomButton),key:"zoom-button",onclick:this._zoomToClicked,title:t.buttons.zoomTo,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("calcite-icon",{icon:"zoom-to-object",scale:"s"}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.buttons.zoomTo:null)))}_renderCollapseToggleButton(){const{longNames:e,messagesCommon:t}=this,i=e?"chevrons-right":"chevrons-left",s=e?t.collapse:t.expand;return m("button",{"aria-label":s,bind:this,class:this.classes(a.widget,a.widgetButton,a.interactive,o.minimizeToggleButton),key:"minimize-toggle-button",onclick:this._toggleCollapsed,title:s,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("calcite-icon",{class:this.classes(o.iconFlip),icon:i,scale:"s"}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.collapse:null)))}_renderFilterMenu(){return this.viewModel?.filterMenuOpen?"site"===this.viewModel?.filterMenuType?this._renderSiteFilterMenu():"facility"===this.viewModel?.filterMenuType?this._renderFacilityFilterMenu():null:null}_renderSiteFilterMenu(){const{messages:e,messagesCommon:t}=this,i=this.site?this.viewModel?.getSite(this.site)?.name:e.selector.selectSite,s=m("div",{class:this.classes(`${o.filterMenuHeader}`),key:"filter-menu-site-header"},m("div",{class:this.classes(o.filterMenuHeaderTextGroup)},m(c,{class:this.classes(o.filterMenuHeaderText),level:this.headingLevel},i)),m("button",{bind:this,class:this.classes(o.iconClose),onclick:this._closeClicked,title:t.close,type:"button"},m("calcite-icon",{icon:"x"}))),l=this._renderSearchInput(),n=this._renderSiteItems();return m("div",{class:this.classes(o.filterMenu),key:"filter-menu-site"},s,l,n)}_renderFacilityFilterMenu(){const{messages:e,messagesCommon:t,site:i}=this,s=this.viewModel?.getSite(i)?.name,l=this.facility&&this.viewModel?.getFacility(this.facility)?.name||e.selector.selectFacility,n=this.viewModel.hasMultipleSites?m("button",{bind:this,class:this.classes(o.filterMenuHeaderBack),onclick:this._backClicked,title:t.back,type:"button"},m("calcite-icon",{class:this.classes(d(this.container)?o.iconRight:o.iconLeft),icon:d(this.container)?"chevron-right":"chevron-left"})):null,r=this.viewModel.hasMultipleSites?m(c,{class:this.classes(o.filterMenuHeaderSubtext),level:h(this.headingLevel)},s):null,a=m("div",{class:this.classes(o.filterMenuHeader),key:"filter-menu-site-header"},n,m("div",{class:this.classes(o.filterMenuHeaderTextGroup)},m(c,{class:this.classes(o.filterMenuHeaderText),level:this.headingLevel},l),r),m("button",{bind:this,class:this.classes(o.iconClose),onclick:this._closeClicked,title:t.close,type:"button"},m("calcite-icon",{icon:"x"}))),u=this._renderSearchInput(),v=this._renderFacilityItems();return m("div",{class:this.classes(o.filterMenu),key:"filter-menu-facility"},a,u,v)}_renderSearchInput(){const{messagesCommon:e}=this,t=!!(this.viewModel.searchTerm&&this.viewModel.searchTerm?.length>0);return m("div",{class:this.classes(o.filterMenuSearch),key:"filter-menu-search"},m("calcite-icon",{icon:"search",key:"filter-menu-search-icon"}),m("input",{afterCreate:u,bind:this,class:this.classes(o.filterMenuSearchInput),"data-node-ref":"_searchInput",oninput:this._onSearchChange,onpaste:this._onSearchChange,placeholder:e.search,value:this.viewModel.searchTerm??void 0}),t?m("calcite-icon",{bind:this,class:this.classes(o.iconClose),icon:"x",key:"filter-menu-search-clear",onclick:this._onSearchClear,title:e.clear}):null)}_renderBlueCircle(){return m("span",{class:this.classes(o.selectedItemCircle),key:"floor-filter__selected-item-circle"})}_renderSiteItems(){if(!this.viewModel?.filterFeatures?.sites?.sitesInfo)return null;const{messages:e}=this,t=this.viewModel.filterFeatures.sites.sitesInfo,i=this.viewModel.filterSites(t).map(e=>this._renderSiteItem(e)),s=0===i.length&&this.viewModel?.searchTerm&&m("div",{class:this.classes(a.empty)},e.noResults);return m("ul",{afterCreate:u,"aria-label":e.selector.sitesLabel,bind:this,class:this.classes(o.filterMenuItems),"data-id":"sites","data-node-ref":"_sitesListNode",key:"filter-menu-items--sites",onkeydown:this._handleListKeydown,tabIndex:-1},i,s)}_renderSiteItem(e){const{name:t,id:i}=e,s=`filter-menu-site--${i}`,l=this.site===i;return m("li",{key:s},m("button",{bind:this,class:this.classes(o.filterMenuSite),"data-id":i,"data-list-id":"sites",onclick:this._siteSelected,onfocus:this._onItemFocus,type:"button"},l?this._renderBlueCircle():null,m("span",{class:this.classes(l?o.filterMenuSelectedItem:o.filterMenuItemName)},t),m("calcite-icon",{class:this.classes(d(this.container)?o.iconLeft:o.iconRight),icon:"chevron-right",scale:"s"})))}_renderFacilityItems(){if(!this.viewModel?.filterFeatures?.facilities?.facilitiesInfo)return null;const{messages:e,site:t}=this,i=this.viewModel.getSite(t),s=this.viewModel.filterFeatures.facilities.facilitiesInfo,l=this.viewModel.filterFacilities(s).map(e=>this._renderFacilityItem(e)),n=0===l.length&&this.viewModel?.searchTerm&&m("div",{class:this.classes(a.empty)},e.noResults),r=i?M(e.selector.siteFacilitiesLabel,{name:`"${i.name}"`}):e.selector.facilitiesLabel;return m("ul",{afterCreate:u,"aria-label":r,bind:this,class:this.classes(o.filterMenuItems),"data-id":"facilities","data-node-ref":"_facilitiesListNode",key:"filter-menu-items--facilities",onkeydown:this._handleListKeydown,tabIndex:-1},l,n)}_renderFacilityItem(e){const{name:t,id:i}=e,s=`filter-menu-facility--${i}`,l=this.facility===i;return m("li",{key:s},m("button",{bind:this,class:this.classes(o.filterMenuFacility),"data-id":i,"data-list-id":"facilities",onclick:this._facilitySelected,onfocus:this._onItemFocus,type:"button"},l?this._renderBlueCircle():null,m("span",{class:this.classes(l?o.filterMenuSelectedItem:o.filterMenuItemName)},t)))}_afterBaseNodeCreate(e){this._baseNode&&this._resizeObserver?.unobserve(this._baseNode),this._baseNode=e,this._resizeObserver?.observe(this._baseNode)}_toggleCollapsed(){this.longNames=!this.longNames}_toggleFilterMenu(){const e=this.viewModel?.filterMenuOpen??!1;this.viewModel.filterMenuOpen=!e}_setFilterMenuType(e){this.viewModel.filterMenuType=e}_zoomToClicked(){if(this.site&&"site"===this.viewModel?.filterMenuType&&this.viewModel?.filterMenuOpen){const e=this.viewModel?.getSite(this.site);this.viewModel.goTo(e)}else if(this.facility){const e=this.viewModel?.getFacility(this.facility);this.viewModel.goTo(e)}else if(this.site){const e=this.viewModel?.getSite(this.site);this.viewModel.goTo(e)}}_onSearchChange(e){const t=e.target;""===t.value?this.viewModel.searchTerm=null:t.value&&this.viewModel?.searchTerm!==t.value&&(this.viewModel.searchTerm=t.value)}_onSearchClear(){this.viewModel.searchTerm=null}_closeClicked(){this.viewModel.searchTerm=null,this.viewModel.filterMenuOpen=!1}_backClicked(){this._setFilterMenuType("site"),this.viewModel.searchTerm=null}_siteSelected(e){const t=e.currentTarget.getAttribute("data-id"),i=this.viewModel.getSite(t);let s=!1;this.site!==t&&(this.facility=null,this.level=null,s=!0,this.viewModel.levelsExpanded=!1),this.site=t,this.viewModel.searchTerm=null,this._setFilterMenuType("facility"),this.viewModel.goTo(i),s&&this.viewModel.setFloors(null)}_facilitySelected(e){const t=e.currentTarget.getAttribute("data-id"),i=this.viewModel.getFacility(t);let s=!1;if(this.facility!==t){if("base-floors"===this.viewModel.filterMode){const e=this.viewModel?.getBaseLevel(i);this.level=e?e.id:null}else this.level=null;s=!0,this.viewModel.levelsExpanded=!1}if(this.facility=t,this.viewModel.goTo(i),s){const e=this.viewModel.getLevel(this.level);this.viewModel.setFloors(e)}if(!this.viewModel.isNormalMode){const e=this.viewModel.getFacilityLevels(t);e?.length>1&&(this.viewModel.levelsExpanded=!0)}setTimeout(()=>this._focusActiveLevel(),50)}_levelSelected(e){const t=e.currentTarget.getAttribute("data-id");this.level=t}_closeLevels(){this.viewModel.levelsExpanded=!1}_isWebScene(e){return"esri.WebScene"===e?.declaredClass}_getComponentPosition(){return null!=this.container?this.view?.ui?.getPosition(this.container):null}_getPosition(e){switch(e){case"bottom-right":case"bottom-left":return"bottom";default:return"top"}}_handleListKeydown(e){const t=e.currentTarget.getAttribute("data-id");let i=null;"sites"===t||"facilities"===t?(this._activeMenu!==t&&(this._activeMenuIndex.menuItems=-1),this._activeMenu=t,i="menuItems"):"levels"===t&&(i="levels");const s="sites"===t?this._sitesListNode:"facilities"===t?this._facilitiesListNode:"levels"===t?this._levelsListNode:null,{key:l}=e,o="Tab"===l,n=g.has(l);n&&e.preventDefault();const r=s?.getElementsByTagName("li");r&&0!==r.length&&(n||o)&&this._handleItemNavigation(l,e.shiftKey,r,o,i)}_handleItemNavigation(e,t,i,s,l){if(!l)return;this._activeMenuIndex[l]===i.length&&this._activeMenuIndex[l]--,-1===this._activeMenuIndex[l]&&this._activeMenuIndex[l]++;const o=this._activeMenuIndex[l];switch(e){case"Home":this._activeMenuIndex[l]=0;break;case"End":this._activeMenuIndex[l]=i.length-1;break;case"ArrowUp":this._activeMenuIndex[l]=this._activeMenuIndex[l]<=0?i.length-1:this._activeMenuIndex[l]-1;break;case"ArrowDown":this._activeMenuIndex[l]=this._activeMenuIndex[l]===i.length-1?0:this._activeMenuIndex[l]+1}if("Tab"===e&&t&&this._activeMenuIndex[l]>=0&&this._activeMenuIndex[l]--,"Tab"===e&&!t&&this._activeMenuIndex[l]<i.length&&this._activeMenuIndex[l]++,o!==this._activeMenuIndex[l]&&this._activeMenuIndex[l]>-1&&this._activeMenuIndex[l]<i.length&&!s){const e=i[this._activeMenuIndex[l]].getElementsByTagName("button"),t=1===e?.length?e[0]:null;t?.focus()}}_focusSearch(){this._searchInput?.focus()}_focusActiveLevel(){const{level:e}=this,t=this._levelsListNode,i=t?.getElementsByTagName("li");if(!e||!t||!i)return;const s=this._facilitiesListNode?.getElementsByTagName("li");this._activeMenuIndex.menuItems=s?s.length-1:-1;const l=[];for(let o=0;o<i.length;o++){const e=i[o].getElementsByTagName("button");1===e?.length&&l.push(e[0])}l.forEach((t,i)=>{t.getAttribute("data-id")===e&&(t.focus(),this._activeMenuIndex.levels=i)})}_onItemFocus(e){const t=e.currentTarget,i=t.getAttribute("data-list-id"),s=t.getAttribute("data-id"),l="sites"===i?this._sitesListNode:"facilities"===i?this._facilitiesListNode:"levels"===i?this._levelsListNode:null;if(!l)return;const o=l?.getElementsByTagName("li");if(!o)return;const n=[];Array.from(o).forEach(e=>{const t=e.getElementsByTagName("button");1===t?.length&&n.push(t[0])});let r=null;switch(i){case"sites":case"facilities":r="menuItems";break;case"levels":r="levels"}if(!r)return;const a=r;n.forEach((e,t)=>{e.getAttribute("data-id")===s&&this._activeMenuIndex[a]!==t&&(this._activeMenuIndex[a]=t)})}};e([i()],f.prototype,"_searchInput",void 0),e([i()],f.prototype,"enabled",null),e([i()],f.prototype,"longNames",null),e([i()],f.prototype,"minimized",null),e([i()],f.prototype,"pinnedLevels",null),e([i()],f.prototype,"site",null),e([i()],f.prototype,"facility",null),e([i()],f.prototype,"level",null),e([i()],f.prototype,"view",null),e([i({type:n})],f.prototype,"viewModel",void 0),e([i(),v("esri/widgets/FloorFilter/t9n/FloorFilter")],f.prototype,"messages",void 0),e([i(),v("esri/t9n/common")],f.prototype,"messagesCommon",void 0),e([i()],f.prototype,"goToOverride",null),e([i()],f.prototype,"headingLevel",void 0),e([i()],f.prototype,"icon",null),f=e([s("esri.widgets.FloorFilter")],f);const p=f;export{p as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../Color.js";import{watch as i}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{Integer as s}from"../core/accessorSupport/ensureType.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import o from"./Histogram.js";import n from"./Slider.js";import l from"./Widget.js";import d from"./HistogramRangeSlider/HistogramRangeSliderViewModel.js";import{getDeviationValues as h}from"./smartMapping/support/utils.js";import{globalCss as u}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{tsx as p}from"./support/jsxFactory.js";const g="esri-histogram-range-slider",c={base:g,sliderContainer:`${g}__slider-container`,histogramContainer:`${g}__histogram-container`,rangeTypePrefix:`${g}__range-type--`};let v=class extends l{constructor(e,i){super(e,i),this._barElements=[],this._histogram=null,this._slider=null,this.barCreatedFunction=null,this.dataLines=null,this.dataLineCreatedFunction=null,this.excludedBarColor=new t("#d7e5f0"),this.includedBarColor=new t("#599dd4"),this.messages=null,this.standardDeviationCount=1,this.viewModel=new d}initialize(){const{average:e,bins:t,hasTimeData:r,max:s,min:a,viewModel:l}=this;this._updateBarFill=this._updateBarFill.bind(this),this._histogram=new o({average:e,bins:t,barCreatedFunction:(e,t)=>{0===e&&(this._barElements=[]),this._barElements.push(t),this._updateBarFill(e,t),this.barCreatedFunction&&this.barCreatedFunction(e,t)},dataLines:this._getDataLines(),dataLineCreatedFunction:(e,t)=>{this.dataLineCreatedFunction&&this.dataLineCreatedFunction(e,t)},labelFormatFunction:this.labelFormatFunction,layout:"horizontal",max:s,min:a}),this._slider=new n({labelFormatFunction:this.labelFormatFunction,layout:"horizontal",visibleElements:{labels:!0,rangeLabels:!0},rangeLabelInputsEnabled:!r,viewModel:l}),this.addHandles([this._slider.on("max-change",e=>this.emit("max-change",e)),this._slider.on("min-change",e=>this.emit("min-change",e)),this._slider.on("segment-drag",e=>{this._updateBarFills(),this.emit("segment-drag",e)}),this._slider.on("thumb-change",e=>{this._updateBarFills(),this.emit("thumb-change",e)}),this._slider.on("thumb-drag",e=>{this._updateBarFills(),this.emit("thumb-drag",e)}),i(()=>this.bins,e=>{if(e&&this._histogram.bins){const t=this._histogram.bins.length-e.length;this._barElements.splice(-t,t)}else this._barElements=[];this._histogram.set({bins:e}),this._updateBarFills(),this.scheduleRender()}),i(()=>[this.max,this.min,this.rangeType,this.values],([e,t])=>{this._histogram.set({max:e,min:t}),this._updateBarFills(),this.scheduleRender()}),i(()=>[this.average,this.dataLines,this.standardDeviation,this.standardDeviationCount],([e])=>{this._histogram.set({average:e,dataLines:this._getDataLines()})}),i(()=>this.labelFormatFunction,e=>{this._histogram.set({labelFormatFunction:e})}),i(()=>this.hasTimeData,e=>{this._slider.set({rangeLabelInputsEnabled:!e})})])}get average(){return this.viewModel.average}set average(e){this.viewModel.average=e}get bins(){return this.viewModel.bins}set bins(e){this.viewModel.bins=e}get hasTimeData(){return this.viewModel.hasTimeData}set hasTimeData(e){this.viewModel.hasTimeData=e}get icon(){return"arrow-double-horizontal"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelFormatFunction(){return this.viewModel.labelFormatFunction}set labelFormatFunction(e){this.viewModel.labelFormatFunction=e}get max(){return this.viewModel.max}set max(e){this.viewModel.max=e}get min(){return this.viewModel.min}set min(e){this.viewModel.min=e}get precision(){return this.viewModel.precision}set precision(e){this.viewModel.precision=e}get rangeType(){return this.viewModel.rangeType}set rangeType(e){this.viewModel.rangeType=e}get standardDeviation(){return this.viewModel.standardDeviation}set standardDeviation(e){this.viewModel.standardDeviation=e}get values(){return this.viewModel.values}set values(e){this.viewModel.values=e}generateWhereClause(e){return this.viewModel.generateWhereClause(e)}render(){const{rangeType:e,viewModel:t,label:i}=this,r=this.classes(c.base,u.widget,`${c.rangeTypePrefix}${e}`,"disabled"===t.state?u.disabled:null);return p("div",{"aria-label":i,class:r},"disabled"===t.state?null:this._renderContent())}_renderContent(){return[this._renderHistogram(),this._renderSlider()]}_renderSlider(){return p("div",{class:c.sliderContainer,key:`${this.id}-slider-container`},this._slider.render())}_renderHistogram(){return p("div",{class:c.histogramContainer},this._histogram.render())}_getDataLines(){return[...this._getStandardDeviationDataLines(),...this.dataLines||[]]}_getStandardDeviationDataLines(){const{average:e,standardDeviation:t,standardDeviationCount:i}=this;return h(t,e,i).map(e=>({value:e}))}_updateBarFills(){this._barElements.forEach((e,t)=>this._updateBarFill(t,e))}_updateBarFill(e,t){t.setAttribute("fill",this._getFillForBar(e)?.toHex()??"")}_getFillForBar(e){const{bins:t,rangeType:i,values:r}=this;if(-1===e||!t?.length||!i||!r?.length)return null;const s=t[e];if(!s)return null;const{maxValue:a,minValue:o}=s,n=a-o,l=r[0]>o&&r[0]<a;switch(i){case"equal":case"not-equal":return this.includedBarColor;case"less-than":case"at-most":return l?this._getBlendedColor((r[0]-o)/n):a<=r[0]?this.includedBarColor:this.excludedBarColor;case"greater-than":case"at-least":return l?this._getBlendedColor(1-(r[0]-o)/n):o>=r[0]?this.includedBarColor:this.excludedBarColor;case"between":if(2===r.length)return r[0]>o&&r[0]<a?this._getBlendedColor(1-(r[0]-o)/n):r[1]>o&&r[1]<a?this._getBlendedColor((r[1]-o)/n):o>=r[0]&&a<=r[1]?this.includedBarColor:this.excludedBarColor;break;case"not-between":if(2===r.length)return r[0]>o&&r[0]<a?this._getBlendedColor((r[0]-o)/n):r[1]>o&&r[1]<a?this._getBlendedColor(1-(r[1]-o)/n):o>r[0]&&a<r[1]?this.excludedBarColor:this.includedBarColor}return this.includedBarColor}_getBlendedColor(e){return t.blendColors(this.excludedBarColor,this.includedBarColor,e)}};e([r()],v.prototype,"average",null),e([r()],v.prototype,"barCreatedFunction",void 0),e([r()],v.prototype,"bins",null),e([r()],v.prototype,"dataLines",void 0),e([r()],v.prototype,"dataLineCreatedFunction",void 0),e([r({type:t,json:{type:[s],write:!0}})],v.prototype,"excludedBarColor",void 0),e([r()],v.prototype,"hasTimeData",null),e([r({type:t,json:{type:[s],write:!0}})],v.prototype,"includedBarColor",void 0),e([r()],v.prototype,"icon",null),e([r()],v.prototype,"label",null),e([r()],v.prototype,"labelFormatFunction",null),e([r()],v.prototype,"max",null),e([r(),m("esri/widgets/HistogramRangeSlider/t9n/HistogramRangeSlider")],v.prototype,"messages",void 0),e([r()],v.prototype,"min",null),e([r()],v.prototype,"precision",null),e([r()],v.prototype,"rangeType",null),e([r()],v.prototype,"standardDeviation",null),e([r()],v.prototype,"standardDeviationCount",void 0),e([r()],v.prototype,"values",null),e([r({type:d})],v.prototype,"viewModel",void 0),v=e([a("esri.widgets.HistogramRangeSlider")],v);const b=v;export{b as default};
5
+ import{__decorate as e}from"tslib";import t from"../Color.js";import{watch as i}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{Integer as s}from"../core/accessorSupport/ensureType.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import o from"./Histogram.js";import n from"./Slider.js";import l from"./Widget.js";import d from"./HistogramRangeSlider/HistogramRangeSliderViewModel.js";import{getDeviationValues as h}from"./smartMapping/support/utils.js";import{globalCss as u}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{tsx as p}from"./support/jsxFactory.js";const g="esri-histogram-range-slider",c={base:g,sliderContainer:`${g}__slider-container`,histogramContainer:`${g}__histogram-container`,rangeTypePrefix:`${g}__range-type--`};let v=class extends l{constructor(e,i){super(e,i),this._barElements=[],this._histogram=null,this._slider=null,this.barCreatedFunction=null,this.dataLines=null,this.dataLineCreatedFunction=null,this.excludedBarColor=new t("#d7e5f0"),this.includedBarColor=new t("#599dd4"),this.messages=null,this.standardDeviationCount=1,this.viewModel=new d}initialize(){const{average:e,bins:t,hasTimeData:r,max:s,min:a,viewModel:l}=this;this._updateBarFill=this._updateBarFill.bind(this),this._histogram=new o({average:e,bins:t,barCreatedFunction:(e,t)=>{0===e&&(this._barElements=[]),this._barElements.push(t),this._updateBarFill(e,t),this.barCreatedFunction?.(e,t)},dataLines:this._getDataLines(),dataLineCreatedFunction:(e,t)=>{this.dataLineCreatedFunction?.(e,t)},labelFormatFunction:this.labelFormatFunction,layout:"horizontal",max:s,min:a}),this._slider=new n({labelFormatFunction:this.labelFormatFunction,layout:"horizontal",visibleElements:{labels:!0,rangeLabels:!0},rangeLabelInputsEnabled:!r,viewModel:l}),this.addHandles([this._slider.on("max-change",e=>this.emit("max-change",e)),this._slider.on("min-change",e=>this.emit("min-change",e)),this._slider.on("segment-drag",e=>{this._updateBarFills(),this.emit("segment-drag",e)}),this._slider.on("thumb-change",e=>{this._updateBarFills(),this.emit("thumb-change",e)}),this._slider.on("thumb-drag",e=>{this._updateBarFills(),this.emit("thumb-drag",e)}),i(()=>this.bins,e=>{if(e&&this._histogram.bins){const t=this._histogram.bins.length-e.length;this._barElements.splice(-t,t)}else this._barElements=[];this._histogram.set({bins:e}),this._updateBarFills(),this.scheduleRender()}),i(()=>[this.max,this.min,this.rangeType,this.values],([e,t])=>{this._histogram.set({max:e,min:t}),this._updateBarFills(),this.scheduleRender()}),i(()=>[this.average,this.dataLines,this.standardDeviation,this.standardDeviationCount],([e])=>{this._histogram.set({average:e,dataLines:this._getDataLines()})}),i(()=>this.labelFormatFunction,e=>{this._histogram.set({labelFormatFunction:e})}),i(()=>this.hasTimeData,e=>{this._slider.set({rangeLabelInputsEnabled:!e})})])}get average(){return this.viewModel.average}set average(e){this.viewModel.average=e}get bins(){return this.viewModel.bins}set bins(e){this.viewModel.bins=e}get hasTimeData(){return this.viewModel.hasTimeData}set hasTimeData(e){this.viewModel.hasTimeData=e}get icon(){return"arrow-double-horizontal"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelFormatFunction(){return this.viewModel.labelFormatFunction}set labelFormatFunction(e){this.viewModel.labelFormatFunction=e}get max(){return this.viewModel.max}set max(e){this.viewModel.max=e}get min(){return this.viewModel.min}set min(e){this.viewModel.min=e}get precision(){return this.viewModel.precision}set precision(e){this.viewModel.precision=e}get rangeType(){return this.viewModel.rangeType}set rangeType(e){this.viewModel.rangeType=e}get standardDeviation(){return this.viewModel.standardDeviation}set standardDeviation(e){this.viewModel.standardDeviation=e}get values(){return this.viewModel.values}set values(e){this.viewModel.values=e}generateWhereClause(e){return this.viewModel.generateWhereClause(e)}render(){const{rangeType:e,viewModel:t,label:i}=this,r=this.classes(c.base,u.widget,`${c.rangeTypePrefix}${e}`,"disabled"===t.state?u.disabled:null);return p("div",{"aria-label":i,class:r},"disabled"===t.state?null:this._renderContent())}_renderContent(){return[this._renderHistogram(),this._renderSlider()]}_renderSlider(){return p("div",{class:c.sliderContainer,key:`${this.id}-slider-container`},this._slider.render())}_renderHistogram(){return p("div",{class:c.histogramContainer},this._histogram.render())}_getDataLines(){return[...this._getStandardDeviationDataLines(),...this.dataLines||[]]}_getStandardDeviationDataLines(){const{average:e,standardDeviation:t,standardDeviationCount:i}=this;return h(t,e,i).map(e=>({value:e}))}_updateBarFills(){this._barElements.forEach((e,t)=>this._updateBarFill(t,e))}_updateBarFill(e,t){t.setAttribute("fill",this._getFillForBar(e)?.toHex()??"")}_getFillForBar(e){const{bins:t,rangeType:i,values:r}=this;if(-1===e||!t?.length||!i||!r?.length)return null;const s=t[e];if(!s)return null;const{maxValue:a,minValue:o}=s,n=a-o,l=r[0]>o&&r[0]<a;switch(i){case"equal":case"not-equal":return this.includedBarColor;case"less-than":case"at-most":return l?this._getBlendedColor((r[0]-o)/n):a<=r[0]?this.includedBarColor:this.excludedBarColor;case"greater-than":case"at-least":return l?this._getBlendedColor(1-(r[0]-o)/n):o>=r[0]?this.includedBarColor:this.excludedBarColor;case"between":if(2===r.length)return r[0]>o&&r[0]<a?this._getBlendedColor(1-(r[0]-o)/n):r[1]>o&&r[1]<a?this._getBlendedColor((r[1]-o)/n):o>=r[0]&&a<=r[1]?this.includedBarColor:this.excludedBarColor;break;case"not-between":if(2===r.length)return r[0]>o&&r[0]<a?this._getBlendedColor((r[0]-o)/n):r[1]>o&&r[1]<a?this._getBlendedColor(1-(r[1]-o)/n):o>r[0]&&a<r[1]?this.excludedBarColor:this.includedBarColor}return this.includedBarColor}_getBlendedColor(e){return t.blendColors(this.excludedBarColor,this.includedBarColor,e)}};e([r()],v.prototype,"average",null),e([r()],v.prototype,"barCreatedFunction",void 0),e([r()],v.prototype,"bins",null),e([r()],v.prototype,"dataLines",void 0),e([r()],v.prototype,"dataLineCreatedFunction",void 0),e([r({type:t,json:{type:[s],write:!0}})],v.prototype,"excludedBarColor",void 0),e([r()],v.prototype,"hasTimeData",null),e([r({type:t,json:{type:[s],write:!0}})],v.prototype,"includedBarColor",void 0),e([r()],v.prototype,"icon",null),e([r()],v.prototype,"label",null),e([r()],v.prototype,"labelFormatFunction",null),e([r()],v.prototype,"max",null),e([r(),m("esri/widgets/HistogramRangeSlider/t9n/HistogramRangeSlider")],v.prototype,"messages",void 0),e([r()],v.prototype,"min",null),e([r()],v.prototype,"precision",null),e([r()],v.prototype,"rangeType",null),e([r()],v.prototype,"standardDeviation",null),e([r()],v.prototype,"standardDeviationCount",void 0),e([r()],v.prototype,"values",null),e([r({type:d})],v.prototype,"viewModel",void 0),v=e([a("esri.widgets.HistogramRangeSlider")],v);const b=v;export{b as default};