@arcgis/core 4.34.0-next.47 → 4.34.0-next.49

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 (143) hide show
  1. package/analysis/ElevationProfileUnits.js +1 -1
  2. package/analysis/support/elevationProfileLineTypes.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{6ce2f86b9b1d2f2b8675.js → 0874b88d5ae7c2b78b3b.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{90a97ffba604c1c35532.js → 0b52c0ca432761076076.js} +65 -65
  6. package/assets/esri/core/workers/chunks/0c129b78e5cfe96795e1.js +1 -0
  7. package/assets/esri/core/workers/chunks/{9f869b331dff505b6b55.js → 1d234c057a6671acc59f.js} +1 -1
  8. package/assets/esri/core/workers/chunks/4cc982c99d84e896d535.js +1 -0
  9. package/assets/esri/core/workers/chunks/4e2b125e6e3945985a54.js +1 -0
  10. package/assets/esri/core/workers/chunks/5a016dcd3192d42d363e.js +1 -0
  11. package/assets/esri/core/workers/chunks/{574ea32d6c257e0d2079.js → 5b0c42bb95d81085061d.js} +1 -1
  12. package/assets/esri/core/workers/chunks/6130bc641aa7c1bcaaa8.js +1 -0
  13. package/assets/esri/core/workers/chunks/72ecf49d03bb24bf0998.js +1 -0
  14. package/assets/esri/core/workers/chunks/781b59ba0cabe78bc122.js +1 -0
  15. package/assets/esri/core/workers/chunks/{28a85997c9003cacdefb.js → 8e3c09c3524654830b14.js} +1 -1
  16. package/assets/esri/core/workers/chunks/ad93a2621f75270f06cb.js +1 -0
  17. package/assets/esri/core/workers/chunks/bd7e303dd64a27ba6846.js +1 -0
  18. package/assets/esri/core/workers/chunks/cb8f2ce22274990b359c.js +1 -0
  19. package/assets/esri/core/workers/chunks/{0b67b16d7e6c030bcfc7.js → d4766c97d97554b3b408.js} +1 -1
  20. package/assets/esri/core/workers/chunks/ddd6597a66ec6b972f9c.js +1 -0
  21. package/chunks/LineSeries.js +1 -1
  22. package/chunks/Theme.js +1 -1
  23. package/chunks/chartUtilsAm5.js +1 -1
  24. package/config.js +1 -1
  25. package/core/lang.js +1 -1
  26. package/core/timeUtils.js +1 -1
  27. package/editing/sharedTemplates/support/sharedTemplateErrors.js +1 -1
  28. package/interfaces.d.ts +44 -10
  29. package/kernel.js +1 -1
  30. package/layers/LinkChartLayer.js +1 -1
  31. package/layers/orientedImagery/transformations/updateElevationUtils.js +1 -1
  32. package/layers/orientedImagery/transformations/utils.js +1 -1
  33. package/layers/save/featureLayerUtils.js +1 -1
  34. package/layers/support/rasterDatasets/pixelReader.js +1 -1
  35. package/libs/linkchartlayout/LinkChartLayout.js +1 -1
  36. package/libs/parquet/parquet.js +1 -1
  37. package/networks/UtilityNetwork.js +1 -1
  38. package/networks/support/UtilityNetworkLookupHelper.js +1 -1
  39. package/networks/support/networkFieldUtils.js +1 -1
  40. package/networks/support/typeUtils.js +1 -1
  41. package/package.json +4 -4
  42. package/rest/networks/support/CircuitLocation.js +5 -0
  43. package/rest/networks/support/CircuitSection.js +5 -0
  44. package/rest/support/Query.js +1 -1
  45. package/rest/support/RelationshipQuery.js +1 -1
  46. package/rest/utils.js +1 -1
  47. package/support/revision.js +1 -1
  48. package/support/webSceneUtils.js +1 -1
  49. package/symbols/cim/utils.js +1 -1
  50. package/views/2d/LabelManager.js +1 -1
  51. package/views/2d/engine/flow/utils.js +1 -1
  52. package/views/2d/engine/imagery/RasterBitmap.js +1 -1
  53. package/views/2d/engine/webgl/DisplayId.js +1 -1
  54. package/views/2d/engine/webgl/animations/instructions.js +1 -1
  55. package/views/2d/engine/webgl/mesh/templates/templateUtils.js +1 -1
  56. package/views/2d/interactive/editingTools.js +1 -1
  57. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  58. package/views/2d/layers/features/FeatureContainer.js +1 -1
  59. package/views/2d/layers/features/RenderState.js +1 -1
  60. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  61. package/views/2d/layers/features/sources/strategies/chunks/ParquetSourceChunk.js +1 -1
  62. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  63. package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
  64. package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +5 -0
  65. package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
  66. package/views/3d/analysis/VolumeMeasurement/CutFillVolumeMeasurementComputation.js +1 -1
  67. package/views/3d/analysis/VolumeMeasurement/CutFillVolumeMeasurementController.js +1 -1
  68. package/views/3d/environment/SunLighting.js +1 -1
  69. package/views/3d/layers/FlowSubView3D.js +1 -1
  70. package/views/3d/layers/I3SMeshView3D.js +1 -1
  71. package/views/3d/layers/graphics/Graphics3DSymbolLayerFactory.js +1 -1
  72. package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
  73. package/views/3d/terrain/terrainUtils.js +1 -1
  74. package/views/3d/webgl-engine/core/FBOCacheFormats.js +1 -1
  75. package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
  76. package/views/3d/webgl-engine/core/shaderModules/Matrix4sPassUniform.js +1 -1
  77. package/views/3d/webgl-engine/lib/Program.js +1 -1
  78. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  79. package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
  80. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  81. package/views/analysis/ElevationProfile/ElevationProfileController.js +5 -0
  82. package/views/analysis/ElevationProfile/ElevationProfileLineComputation.js +5 -0
  83. package/views/analysis/ElevationProfile/ElevationProfileLineGroundComputation.js +5 -0
  84. package/views/analysis/ElevationProfile/ElevationProfileLineInputComputation.js +5 -0
  85. package/views/analysis/ElevationProfile/ElevationProfileLineQueryComputation.js +5 -0
  86. package/views/analysis/ElevationProfile/ProfileGenerationError.js +5 -0
  87. package/views/analysis/ElevationProfile/constants.js +5 -0
  88. package/views/analysis/ElevationProfile/elevationQuerySourceUtils.js +5 -0
  89. package/views/analysis/ElevationProfile/geometryUtils.js +5 -0
  90. package/views/analysis/ElevationProfile/profileUtils.js +5 -0
  91. package/views/analysis/ElevationProfile/statisticsUtils.js +5 -0
  92. package/views/analysis/ElevationProfile/traversalUtils.js +5 -0
  93. package/views/analysis/ElevationProfile/unitUtils.js +5 -0
  94. package/views/analysis/ElevationProfileResult.js +1 -1
  95. package/views/support/LayerLayerViewInfo.js +1 -1
  96. package/views/support/highlightOptionsUtils.js +1 -1
  97. package/views/webgl/Program.js +1 -1
  98. package/views/webgl/textureUtils.js +1 -1
  99. package/webscene/SunLighting.js +1 -1
  100. package/widgets/Daylight/DaylightViewModel.js +1 -1
  101. package/widgets/Daylight/support/daylightUtils.js +1 -1
  102. package/widgets/Editor/EditorViewModel.js +1 -1
  103. package/widgets/Editor/support/SketchController.js +1 -1
  104. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  105. package/widgets/FeatureTable/FieldColumn.js +1 -1
  106. package/widgets/FeatureTable/Grid/Column.js +1 -1
  107. package/widgets/FeatureTable.js +1 -1
  108. package/widgets/Features/FeaturesViewModel.js +1 -1
  109. package/widgets/Legend/support/sizeRampUtils.js +1 -1
  110. package/widgets/OrientedImageryViewer/constants.js +1 -1
  111. package/widgets/OrientedImageryViewer/navigation/errors.js +1 -1
  112. package/widgets/OrientedImageryViewer.js +1 -1
  113. package/widgets/ShadowCast/css.js +1 -1
  114. package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
  115. package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
  116. package/widgets/UtilityNetworkTraceAnalysis/UtilityNetworkTraceAnalysisViewModel.js +1 -1
  117. package/widgets/smartMapping/SmartMappingSliderViewModel.js +1 -1
  118. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  119. package/widgets/support/SelectionList.js +1 -1
  120. package/arcade/credentials.js +0 -5
  121. package/arcade/featureset/support/Guid.js +0 -5
  122. package/arcade/request.js +0 -5
  123. package/arcade/serviceAreaMetaData.js +0 -5
  124. package/assets/esri/core/workers/chunks/45b450c045d5fadf71b6.js +0 -1
  125. package/assets/esri/core/workers/chunks/4f5e72993a4f5180d703.js +0 -1
  126. package/assets/esri/core/workers/chunks/516b30778cd54d29e362.js +0 -1
  127. package/assets/esri/core/workers/chunks/53e166944a42af027345.js +0 -1
  128. package/assets/esri/core/workers/chunks/576792b5e1e13084adba.js +0 -1
  129. package/assets/esri/core/workers/chunks/5f7dc9657803ae3140a6.js +0 -1
  130. package/assets/esri/core/workers/chunks/8d51b6823ef5d290c670.js +0 -1
  131. package/assets/esri/core/workers/chunks/947085d176bd3a930e6f.js +0 -1
  132. package/assets/esri/core/workers/chunks/b1b6300451cc4ccefd46.js +0 -1
  133. package/assets/esri/core/workers/chunks/d09ded9fb621491e2466.js +0 -1
  134. package/assets/esri/core/workers/chunks/eb61b47df99a54a364c8.js +0 -1
  135. package/rest/versionManagement/support/GetVersionInfosResult.js +0 -5
  136. package/symbols/cim/quantizeTime.js +0 -5
  137. package/undoredo/support/DataEditingContext.js +0 -5
  138. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/WriterRegistry.js +0 -5
  139. package/views/2d/interactive/editingTools/MediaTransformToolsWrapper.js +0 -5
  140. package/views/2d/layers/features/sources/strategies/chunks/FeatureSourceEndChunk.js +0 -5
  141. package/views/3d/webgl-engine/core/shaderLibrary/util/RgbaFloat16Encoding.glsl.js +0 -25
  142. package/webscene/spec-certification/index.js +0 -5
  143. package/widgets/HighlightConfigurator.js +0 -5
@@ -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{memoize as o}from"../../../core/memoize.js";import{watch as r}from"../../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as t}from"../../../core/unitUtils.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 n}from"../../../core/accessorSupport/decorators/subclass.js";import{ElevationProfileLineComputation as s}from"./ElevationProfileLineComputation.js";import{getGroundMinDemResolution as a}from"./elevationQuerySourceUtils.js";let l=class extends s{constructor(){super(...arguments),this.type="ground",this.numSamplesForPreview=50,this.numSamplesPerChunk=1e3,this._getQueryElevationDependencies=o((e,o)=>({ground:e,groundLayers:o}))}get minDemResolution(){return a(this._ground)}get available(){return!0===this._ground?.layers.some(e=>e.visible)}initialize(){this.addHandles([r(()=>this._queryElevationDependencies,()=>this.onInvalidate(this))])}async queryElevation(e,o){const r=this._queryElevationDependencies;if(null==r)throw new Error("ElevationProfileLineGround: no dependencies");const{ground:i}=r;if(null==i)throw new Error("No ground configured in the view");const n=await i.queryElevation(e,o),s=t(e.spatialReference),a=t(i.layers.at(0).spatialReference);if(s!==a){const e=n.geometry;e.points=e.points.map(([e,r,t])=>[e,r,t===o.noDataValue?t:t*a/s])}return n}get _queryElevationDependencies(){return this._getQueryElevationDependencies(this._ground,this._ground?.layers?.toArray())}get _ground(){return this.controller.view?.map?.ground}};e([i()],l.prototype,"minDemResolution",null),e([i()],l.prototype,"available",null),e([i()],l.prototype,"_queryElevationDependencies",null),e([i()],l.prototype,"_ground",null),l=e([n("esri.views.analysis.ElevationProfile.ElevationProfileLineGroundComputation")],l);export{l as ElevationProfileLineGroundComputation};
@@ -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{memoize as t}from"../../../core/memoize.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as r}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{GeometryDescriptor as n}from"../../../layers/support/ElevationQuery.js";import{getGraphicEffectiveElevationInfo as s}from"../../../support/elevationInfoUtils.js";import{ElevationProfileLineComputation as a}from"./ElevationProfileLineComputation.js";import{getInputGraphic as l}from"./geometryUtils.js";let p=class extends a{constructor(){super(...arguments),this.type="input",this.numSamplesForPreview=50,this.numSamplesPerChunk=500,this._getQueryElevationDependenciesMemoized=t((e,t,o,r,i)=>e&&o?{elevationInfo:e,visibleLayers:t,view:o,stationary:r,spatialReference:i}:null)}get available(){return!this.controller.analysisViewData.inputIsSketched}initialize(){const e=()=>this.onInvalidate(this);this.addHandles([o(()=>this._queryElevationDependencies,e),this.controller.onElevationChange(e)])}async queryElevation(e,{noDataValue:t,signal:o}){const r=this._queryElevationDependencies;if(null==r)throw new Error("ElevationProfileLineInput: no dependencies");const{view:i,elevationInfo:s,spatialReference:a}=r;if("on-the-ground"===s.mode&&"3d"===i.type&&a){const r=await n.fromGeometry(e).project(a,o);if(!r)return{geometry:e,noDataValue:t};const s=i.elevationProvider;return r.coordinates.forEach(e=>{e.z=s.getElevation(e.x,e.y,0,a,"ground")??0}),{geometry:r.export(),noDataValue:t}}return{geometry:e,noDataValue:t}}get _queryElevationDependencies(){const{view:e}=this.controller;return this._getQueryElevationDependenciesMemoized(this._elevationInfo,this._visibleLayers,e,e.stationary,e.spatialReference)}get _elevationInfo(){const e=l(this.controller.analysis.input);return e?s(e):null}get _visibleLayers(){return this.controller.view?.map?.allLayers?.filter(e=>e.visible).toArray()??[]}};e([r()],p.prototype,"available",null),e([r()],p.prototype,"_queryElevationDependencies",null),e([r()],p.prototype,"_elevationInfo",null),e([r()],p.prototype,"_visibleLayers",null),p=e([i("esri.views.analysis.ElevationProfile.ElevationProfileLineInputComputation")],p);export{p as ElevationProfileLineInputComputation};
@@ -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{watch as o,sync as r}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 t}from"../../../core/accessorSupport/decorators/subclass.js";import{ElevationProfileLineComputation as s}from"./ElevationProfileLineComputation.js";import{getQuerySourceMinDemResolution as l}from"./elevationQuerySourceUtils.js";let n=class extends s{constructor(){super(...arguments),this.type="query",this.numSamplesForPreview=50,this.numSamplesPerChunk=500}get minDemResolution(){return l(this.profileLine.source)}get available(){const{source:e}=this.profileLine;return!!e&&(null==e.visible||e.visible)&&(null==e.layers||e.layers.some(e=>e.visible))}initialize(){this.addHandles(o(()=>this.profileLine.source,()=>this.onInvalidate(this),r))}queryElevation(e,o){if(!this.profileLine.source)throw new Error("No source configured for the elevation profile line");return this.profileLine.source.queryElevation(e,o)}};e([i({readOnly:!0})],n.prototype,"minDemResolution",null),e([i()],n.prototype,"available",null),n=e([t("esri.views.analysis.ElevationProfile.ElevationProfileLineQueryComputation")],n);export{n as ElevationProfileLineQueryComputation};
@@ -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
+ const e="ProfileGenerationError";class r extends Error{constructor(r){super("profile could not be generated",{cause:r}),this.type=e}}export{r as ProfileGenerationError};
@@ -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{convertUnit as e}from"../../../core/unitUtils.js";let t={noDataValue:-5e5,defaultQueryOptions:()=>({noDataValue:t.noDataValue,demResolution:"auto",maximumAutoTileRequests:150,ignoreInvisibleLayers:!0}),updateThrottleMillis:100,delayAfterPreviewMillis:500,defaultDemResolution:e(10,"centimeters","meters"),densificationMaxSamples:3e3,largeChartSamples:1e4,maxTotalSamples:1e5,maxChartRatio:300,minSlopeSampleDistance:10,formatPrecision:1,profileLinesUpdateThrottleMillis:100,hoveredPointsStyle:{size:14,borderStyle:"solid",borderWidth:3,borderColor:"#ffffff",boxShadow:"0px 0px 0px 5px rgba(255,255,255,0.2)"}};function a(){return t}function i(e){t=e}const l={progress:1,hasZ:!1,samples:[],statistics:null,spatialReference:null};export{l as errorResult,a as getConfig,i as setConfig};
@@ -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{isSome as n,min as r}from"../../../core/arrayUtils.js";import{getMetersPerUnitForSR as l}from"../../../core/unitUtils.js";import{isGround as t}from"../../../support/groundInstanceUtils.js";function u(n){if(null==n)return null;if(t(n))return o(n);const r=n.tileInfo;if(null==r)return null;const u=r.lods?.at(-1);return null==u?null:u.resolution*l(r.spatialReference)}function o(l){if(null==l)return null;const t=l.layers.items.map(e).filter(n);return r(t)??null}function e(n){return n&&"tileInfo"in n?u(n):null}export{o as getGroundMinDemResolution,u as getQuerySourceMinDemResolution};
@@ -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{floatEqualUlp as e,lerp as t}from"../../../core/mathUtils.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/unitUtils.js";import{distance as o,lerp as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{m as i}from"../../../chunks/vec32.js";import a from"../../../geometry/Polyline.js";import{initializeProjection as c,project as u}from"../../../geometry/projectionUtils.js";import l from"../../../geometry/SpatialReference.js";import{geodesicLengths as f,isSupported as h,inverseGeodeticSolver as p,directGeodeticSolver as m}from"../../../geometry/support/geodesicUtils.js";import{getElevationOffset as d}from"../../../support/elevationInfoUtils.js";import{ProfileGenerationError as g}from"./ProfileGenerationError.js";async function y(e,t,o,s,i,a,h){let p,m,d;const y=e.spatialReference,j=y.isGeographic||y.isWebMercator;let v=0;if(!j){const{execute:t}=await import("../../../geometry/operators/lengthOperator.js");n(h),v=t(e,{unit:"meters"}),n(h)}const P=1/r(s);if(j){await c([{source:y,dest:s},{source:y,dest:l.WGS84}],h);const n=L(e);p=f([n],"meters")[0];const r=w(p,i);if(q(e,p,r)>a)throw new g("too-complex");const j=R(n,t,o);({densifiedPath:m,distances:d}=z(j,r,P)),m=u(m,s)}else{await c([{source:y,dest:s}],h),p=v;const r=w(p,i);if(q(e,p,r)>a)throw new g("too-complex");const l=R(e,t,o);({densifiedPath:m,distances:d}=A(l,r,P)),n(h),m=u(m,s)}return{densifiedPath:m,pathLength:p*P,distances:d}}function w(e,t){const n=e/t.densificationMaxSamples;return Math.max(t.samplingDistance,n)}function R(e,t,n){if(null==t)return P(e);const r=e.spatialReference,o=t.mode,s=d(t,r);let i=null;switch(n.type){case"2d":i=j(e,o,s);break;case"3d":i=v(e,o,s,n)}return null==i?P(e):new a({hasZ:!0,hasM:!1,spatialReference:r,paths:Z(e.paths,i)})}function j({hasZ:e},t,n){return"absolute-height"===t?e?([e,t,r])=>[e,t,r+n]:([e,t])=>[e,t,n]:null}function v({spatialReference:e,hasZ:t},n,r,{elevationProvider:o}){const s=(t,n,r,s)=>o?.getElevation(t,n,r,e,s)??0;switch(n){case"on-the-ground":return([e,t])=>[e,t,s(e,t,0,"ground")];case"absolute-height":return t?([e,t,n])=>[e,t,n+r]:([e,t])=>[e,t,r];case"relative-to-ground":return t?([e,t,n])=>[e,t,n+s(e,t,n,"ground")+r]:([e,t])=>[e,t,s(e,t,0,"ground")+r];case"relative-to-scene":return t?([e,t,n])=>[e,t,n+s(e,t,n,"scene")+r]:([e,t])=>[e,t,s(e,t,0,"scene")+r];default:return null}}function P(e){return e.hasZ?new a({hasZ:!1,hasM:!1,spatialReference:e.spatialReference,paths:Z(e.paths,([e,t])=>[e,t])}):e}function Z(e,t){const n=e.length,r=new Array(n);for(let o=0;o<n;++o){const n=e[o],s=n.length,i=new Array(n.length);r[o]=i;for(let e=0;e<s;++e)i[e]=t(n[e])}return r}function x(e){return null!=e&&"polyline"===e.type&&e.paths.length>0&&e.paths.every(e=>e.length>=2)}function M(e){return U(e)?e:null}function S(e){return U(e)?e.geometry:e}function U(e){return null!=e&&"geometry"in e}function b(t,n,o,s,i){const{spatialReference:c,hasZ:u}=t,l={from:null,to:null,distance:0,azimuth:0,reverseAzimuth:0,spatialReference:c,metersPerSR:r(c)},f=[],h=[];let p=0;for(let r=0;r<t.paths.length;++r){const a=t.paths[r],c=new Array,u=new Array;let m=0;for(let t=1;t<a.length;++t){const r=a[t-1],f=a[t],h=s(l,r,f);let d;for(d=m;d<h.distance&&!e(d,h.distance);d+=n)c.push(i(h,d)),u.push((p+d)*o);m=d-h.distance,p+=h.distance,c.push(f),u.push(p*o)}f[r]=c,h[r]=u}return{densifiedPath:new a({spatialReference:c,hasZ:u,paths:f}),distances:h}}function A(e,t,n){const{hasZ:r}=e;return b(e,t,n,W,r?I:D)}function z(e,t,n){const{hasZ:r}=e;return b(e,t,n,G,r?E:k)}function G(e,t,n){return e.distance=0,p(e,t,n,e.spatialReference),e.from=t,e.to=n,e}function W(e,t,n){return e.from=t,e.to=n,e.distance=o(n,t)*e.metersPerSR,e}function k({from:e,azimuth:t,spatialReference:n},r){return m([0,0],e,t,r,n)}function E({from:e,to:n,azimuth:r,distance:o,spatialReference:s},i){const a=i/o,c=[0,0,t(e[2],n[2],a)];return m(c,e,r,i,s),c}function D({from:e,to:t,distance:n},r){return s([0,0],e,t,r/n)}function I({from:e,to:t,distance:n},r){return i([0,0,0],e,t,r/n)}function L(e){return h(e.spatialReference)?e:u(e,l.WGS84)}function O(e){return e.paths.reduce((e,t)=>e+t.length,0)}function q(e,t,n){return O(e)+Math.floor(t/n)+Math.max(0,e.paths.reduce(e=>1+e,0)-1)}export{O as countPoints,y as densifyPath,S as getInputGeometry,M as getInputGraphic,x as isValidInputPath,R as toAbsoluteHeightElevation};
@@ -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{splitIntoChunks as e}from"../../../core/arrayUtils.js";import{lerp as t}from"../../../core/mathUtils.js";import{throwIfAborted as r,throwIfNotAbortError as o,after as n,isAbortError as s}from"../../../core/promiseUtils.js";import i from"../../../geometry/Multipoint.js";import{unnormalizedCoordinate as l}from"../../../geometry/support/coordsUtils.js";import{getInfo as a}from"../../../geometry/support/spatialReferenceUtils.js";import{getConfig as c,errorResult as u}from"./constants.js";import{isValidInputPath as p,countPoints as f,densifyPath as m}from"./geometryUtils.js";import{ProfileGenerationError as d}from"./ProfileGenerationError.js";import{getStatistics as h}from"./statisticsUtils.js";import{breadthFirstBinaryPartitioning as y}from"./traversalUtils.js";import{ScheduledQueueProcessor as g}from"../../support/ScheduledQueueProcessor.js";import{TaskPriority as w}from"../../support/Scheduler.js";async function*v(e,t){const{view:o,geometry:s,elevationInfo:i,providers:l,options:a}=e,u=o.spatialReference;if(!u||null==s||!p(s))throw new d("invalid-geometry");const h=l.length;if(0===h)return null;const y=Math.round(a.maxTotalSamples/h);if(f(s)>y)throw new d("too-complex");const g=await m(s,i,o,u,a,y,t);let w=0;const v=new Array(h),j=new Array(h);for(let r=0;r<h;r++){const o=S(g);v[r]=o,w+=o.samples.length;const n={...e,provider:l[r],result:o,densificationResult:g};j[r]=P(n,t)[Symbol.iterator]()}if(w>a.maxTotalSamples)throw new d("too-complex");const R=await Promise.all(j.map(e=>{const t=e.next();return!0===t.done?Promise.resolve(null):t.value}));r(t);for(let r=0;r<h;r++)v[r]=R[r];yield v,await n(e.delayAfterPreview??c().delayAfterPreviewMillis,null,t.signal);const Z=[];try{let e;do{e=!1;for(let t=0;t<h;t++){const r=j[t].next();!1===r.done&&(Z.push({resultPromise:r.value,index:t}),e=!0)}}while(e)}finally{j.forEach(e=>e.return?.())}for(const{resultPromise:n,index:c}of Z)v[c]=await n,r(t),yield v;for(const r of v)null!=r&&(r.progress=1);yield v}function*P(t,r){const{densificationResult:o}=t,n={...t,abortOptions:r,densificationResult:o},s=y(0,n.result.samples.length),i=s.slice(0,n.provider.numSamplesForPreview);yield j(n,i,!0);const l=e(s,n.provider.numSamplesPerChunk);for(const e of l)yield j(n,e,!1)}async function j({densificationResult:e,result:t,provider:r,queue:o,abortOptions:n,cache:l},a,p){const{densifiedPath:f,pathLength:m}=e,d=t.spatialReference,{samples:h}=t,y=[];for(let s=0;s<a.length;s++){const e=h[a[s]];y[s]=e.coordinate}try{return await o.push({geometry:new i({spatialReference:d,points:y,hasZ:f.hasZ}),provider:r,indices:a,preview:p,result:t,queryOptions:{...c().defaultQueryOptions(),minDemResolution:p?Math.round(m/r.numSamplesForPreview):Math.round(m/h.length),cache:l}},n),{...t}}catch(g){return s(g)?null:u}}function R(e){return new g({priority:w.ELEVATION_PROFILE,concurrency:1,scheduler:e,process:async e=>{r(e.queryOptions);try{await Z(e)}catch(t){o(t)}}})}async function Z({geometry:e,provider:t,indices:r,preview:o,result:n,queryOptions:s}){if(0===r.length)return;const i=(await M(t,e,s)).geometry,{hasZ:l,points:a}=i,c=s.noDataValue,{samples:u}=n;for(let p=0;p<r.length;p++){const e=u[r[p]];if(e.isHole)continue;const t=l?a[p][2]:null;null===t||t===c?e.sampledZ=null:(n.hasZ=!0,e.sampledZ=t),e.sampled=!0}x(u),n.progress=o?0:n.progress+r.length/u.length,n.statistics=h(n.samples,n.spatialReference)}function x(e){const t=e.length-1;let r=0;for(let o=1;o<=t;o++){(e[o].sampled||o===t)&&(O(e,r,o),r=o)}}function O(e,r,o){if(o-r===1)return;const n=e[r],s=n.sampledZ,i=e[o],l=i.sampledZ;if(null==s||null==l){for(let t=r+1;t<o;t++)e[t].sampledZ=null;return}const a=n.distance,c=i.distance-a;for(let u=r+1;u<o;u++){const r=e[u],o=(r.distance-a)/c;r.sampledZ=t(s,l,o)}}function S({densifiedPath:e,distances:t}){const r=e.spatialReference,o=a(r),n=e.paths,s=n.length,i=[];let c=null,u=0;for(let a=0;a<s;a++){const e=n[a],r=e.length,s=t[a];for(let t=0;t<r;t++){const r=e[t],n=s[t];o&&(r[0]=l(r[0],o.valid[0],o.valid[1])),c&&0===t&&U(i,c,r,u,n),i.push(q(r,n)),c=r,u=n}}return{progress:0,samples:i,hasZ:!1,statistics:null,spatialReference:r}}function U(e,t,r,o,n){e.push(E(t,o)),e.push(E(r,n))}function q(e,t){return{coordinate:e,distance:t,sampledZ:null,sampled:!1,isHole:!1}}function E(e,t){return{coordinate:e,distance:t,sampledZ:null,sampled:!0,isHole:!0}}async function M(e,t,r){try{return await e.queryElevation(t,r)}catch(o){throw new d("elevation-query-error")}}function A(e,t,r){if(!e||0===e.length)return;const o=e.length-1,n=e[0];if(t<=r(n))return n;const s=e[o];if(t>=r(s))return s;let i=0,l=0,a=o;for(;i<a;){l=i+Math.floor((a-i)/2);const n=e[l],s=r(n);if(s===t)return n;if(t<s){if(l>0){const o=e[l-1],i=r(o);if(t>i)return t-i>=s-t?n:o}a=l}else{if(l<o){const o=e[l+1],i=r(o);if(t<i)return t-s>=i-t?o:n}i=l+1}}return e[l]}export{A as binaryFindClosest,R as createProfileQueue,P as generateProfile,v as generateProfiles,x as interpolateElevations};
@@ -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{isSome as t}from"../../../core/arrayUtils.js";import{getMetersPerUnitForSR as n,getMetersPerVerticalUnitForSR as e,convertUnit as l}from"../../../core/unitUtils.js";import{getConfig as a}from"./constants.js";function i(t,i){const o=t.length;if(0===o)return null;const s=t[0],m=s.sampledZ;let c=m,p=m,h=0,E=0,f=null,g=null,x=null!=m?m:0,_=0,S=0,d=null!=m?1:0,C=0,D=0;const N=n(i),P=e(i),H=a().minSlopeSampleDistance/N,Z=2*H,j=new v,y=new v,M=()=>{G(),j.copy(y),y.reset()},w=(t,n)=>{M(),t>0&&t-j.start<=Z&&(t=j.start+H),y.restart(t,n)},G=()=>{if(j.isHole||y.isHole)return;const t=y.avgElevation-j.avgElevation,n=y.start-j.start,e=t*P,a=n*N,i=l(Math.atan2(e,a),"radians","degrees");i>0?(_+=i,f=u(f,i),C++):i<0&&(S-=i,g=u(g,-i),D++)};null!=s.sampledZ&&w(s.distance,s.sampledZ);for(let n=1;n<o;++n){const e=t[n-1],l=t[n],a=l.sampledZ;if(null==a){y.isHole||M();continue}d++,x+=a,c=r(c,a),p=u(p,a),y.isHole||l.distance-y.start>=H?w(l.distance,a):y.insert(a);const i=e.sampledZ;if(null!=i){const t=a-i;t>0?h+=t:t<0&&(E-=t)}}return M(),0===d?null:{maxDistance:t[o-1].distance,minElevation:c,maxElevation:p,avgElevation:0===d?null:x/d,elevationGain:h,elevationLoss:E,maxPositiveSlope:f,maxNegativeSlope:g,avgPositiveSlope:0===C?null:_/C,avgNegativeSlope:0===D?null:S/D}}function o(n){const e=n.filter(t),l=e.length;if(0===l)return null;const a=e[0];if(1===l)return a;let i=a.maxDistance,o=a.minElevation,s=a.maxElevation,m=a.maxPositiveSlope,v=a.maxNegativeSlope;for(let t=1;t<e.length;++t){const n=e[t];i=u(i,n.maxDistance),o=r(o,n.minElevation),s=u(s,n.maxElevation),m=u(m,n.maxPositiveSlope),v=u(v,n.maxNegativeSlope)}return{maxDistance:i,minElevation:o,maxElevation:s,avgElevation:null,elevationGain:null,elevationLoss:null,maxPositiveSlope:m,maxNegativeSlope:v,avgPositiveSlope:null,avgNegativeSlope:null}}function s(t){let l=null,a=null,i=null;for(const o of t){if(null==o)continue;const{statistics:t,spatialReference:s}=o;if(null==t)continue;const v=n(s);l=u(l,m(t.maxDistance,v));const c=e(s);i=r(i,m(t.minElevation,c)),a=u(a,m(t.maxElevation,c))}return{minDistance:0,maxDistance:l??0,minElevation:i??0,maxElevation:a??0}}function r(t,n){return null==n?t:null!=t?Math.min(t,n):n}function u(t,n){return null==n?t:null!=t?Math.max(t,n):n}function m(t,n){return null!=t&&null!=n?t*n:null}class v{constructor(){this._start=0,this._totalElevation=0,this._sampleCount=0}get avgElevation(){return this._totalElevation/this._sampleCount}get isHole(){return 0===this._sampleCount}get start(){return this._start}copy(t){this._start=t._start,this._sampleCount=t._sampleCount,this._totalElevation=t._totalElevation}reset(){this._start=0,this._sampleCount=0,this._totalElevation=0}restart(t,n){this._start=t,this._sampleCount=1,this._totalElevation=n}insert(t){++this._sampleCount,this._totalElevation+=t}}export{s as getBoundsInMeters,i as getStatistics,o as mergeStatistics};
@@ -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
+ function n(n,o,t=[]){if(n>=o)return t;t.push(n);if(o-n<2)return t;const r=o-1;t.push(r);const u=e(n+1,r);for(;;){const n=u.next();if(n.done)break;t.push(n.value)}return t}function*e(n,o){if(n>=o)return;const t=n+Math.floor((o-n)/2);yield t;const r=e(n,t),u=e(t+1,o);for(;;){const n=r.next(),e=u.next();if(n.done&&e.done)break;n.done||(yield n.value),e.done||(yield e.value)}}export{n as breadthFirstBinaryPartitioning};
@@ -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{getMetersPerUnitForSR as e,getMetersPerVerticalUnitForSR as n,convertUnit as t}from"../../../core/unitUtils.js";function l(t,l){if(null==t||null==l)return null;const{samples:i,spatialReference:s}=t,{distance:v,elevation:r}=l,u=e(s),c=n(s),m=i.length,p=new Array(m);for(let e=0;e<m;++e){const n=i[e],t=n.sampledZ,l=n.coordinate;p[e]={x:l[0],y:l[1],z:t,distance:a(n.distance,u,v),elevation:o(t,c,r)}}return p}function i(t,l){if(null==t||null==l||null==t.statistics||null==t.spatialReference)return null;const{distance:i,elevation:s}=l,{statistics:v,spatialReference:r}=t,u=e(r),c=n(r);return{maxDistance:a(v.maxDistance,u,i),minElevation:o(v.minElevation,c,s),maxElevation:o(v.maxElevation,c,s),avgElevation:o(v.avgElevation,c,s),elevationGain:o(v.elevationGain,c,s),elevationLoss:o(v.elevationLoss,c,s),maxPositiveSlope:v.maxPositiveSlope,maxNegativeSlope:v.maxNegativeSlope,avgPositiveSlope:v.avgPositiveSlope,avgNegativeSlope:v.avgNegativeSlope}}function a(e,n,l){return null==e?null:t(e*n,"meters",l)}function o(e,n,l){return null==e?null:t(e*n,"meters",l)}export{l as convertSamples,i as convertStatistics};
@@ -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 o}from"tslib";import{Clonable as r}from"../../core/Clonable.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 t}from"../../core/accessorSupport/decorators/subclass.js";let e=class extends r{constructor(o){super(o),this.available=!1,this.error=null,this.progress=0,this.samples=[],this.statistics=null}};o([s()],e.prototype,"available",void 0),o([s()],e.prototype,"error",void 0),o([s()],e.prototype,"progress",void 0),o([s()],e.prototype,"samples",void 0),o([s()],e.prototype,"statistics",void 0),e=o([t("esri.views.analysis.ElevationProfileResult")],e);const i=e;export{i as default};
5
+ import{__decorate as t}from"tslib";import{Clonable as e}from"../../core/Clonable.js";import{memoize as r}from"../../core/memoize.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 s}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../geometry/Point.js";import{binaryFindClosest as i}from"./ElevationProfile/profileUtils.js";import{convertSamples as n,convertStatistics as p}from"./ElevationProfile/unitUtils.js";let a=class extends e{constructor(t){super(t),this.available=!1,this.error=null,this._getSamplesMemoized=r((t,e)=>n(t,e)),this._getStatisticsMemoized=r((t,e)=>p(t,e)),this.rawResult=null}get progress(){return null!=this.rawResult&&this.profileLine.enabled?this.rawResult.progress:0}get samples(){return this._getSamplesMemoized(this.rawResult,this.controller.effectiveUnits)}get statistics(){return this._getStatisticsMemoized(this.rawResult,this.controller.effectiveUnits)}get hoveredPoint(){const t=this.controller.analysisViewData.hoveredPosition;if(null==t)return null;const{rawResult:e,samples:r}=this;if(null==r||null==e)return null;const o=r.length;if(0===o)return null;const s=r[o-1].distance,n=i(r,t*s,t=>t.distance);if(null==n)return null;const{x:p,y:a,z:u}=n;return null==u?null:new l({x:p,y:a,z:u,spatialReference:e.spatialReference})}};t([o()],a.prototype,"available",void 0),t([o()],a.prototype,"error",void 0),t([o()],a.prototype,"progress",null),t([o()],a.prototype,"samples",null),t([o()],a.prototype,"statistics",null),t([o({constructOnly:!0})],a.prototype,"controller",void 0),t([o({constructOnly:!0})],a.prototype,"profileLine",void 0),t([o()],a.prototype,"rawResult",void 0),t([o()],a.prototype,"hoveredPoint",null),a=t([s("esri.views.analysis.ElevationProfileResult")],a);export{a 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 e from"../../core/Error.js";import{removeMaybe as r}from"../../core/maybe.js";import{createResolver as t,onAbort as i,throwIfAborted as l}from"../../core/promiseUtils.js";import a from"../../layers/Layer.js";function o(e){return"tryRecycleWith"in e}class s{constructor(r,l,a){this.layer=r,this.view=l,this.layerViewImporter=a,this._controller=new AbortController,this._deferred=t(),this._started=!1,this.done=!1,this.promise=this._deferred.promise,i(this._controller.signal,()=>{this._recycleController?.abort();const t=new e("cancelled:layerview-create","layerview creation cancelled",{layer:r});this._deferred.reject(t)})}tryRecycle(e){if(!this.done||!this.layerView||!o(this.layerView))return null;this._recycleController?.abort(),this._recycleController=new AbortController;const r=this.layer.type,t=this._recycleController.signal;for(let i=0;i<e.length;i++){const a=e[i];if(a.type!==r)continue;const o=this.layerView.tryRecycleWith(a,{signal:t});if(o){e.splice(i,1),this.layer=a;const r=this.layerView,s=r.view;return this.promise=o.then(()=>(l(t),a.emit("layerview-destroy",{view:s,layerView:r}),s.emit("layerview-destroy",{view:s,layerView:r}),a.emit("layerview-create",{view:s,layerView:r}),s.emit("layerview-create",{view:s,layerView:r}),r)),this.promise}}return null}destroy(){this._controller.abort();const{layerView:e}=this;if(e){const{layer:r,view:t}=this;r.emit("layerview-destroy",{view:t,layerView:e}),t.emit("layerview-destroy",{layer:r,layerView:e})}this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null,this._map=null}async start(){const{view:t}=this;if(this._started||!t.map)return;this._started=!0;const{_controller:{signal:a},layer:o}=this;this._map=t.map;try{let n,w;if(await o.load({signal:a}),o.prefetchResources&&await o.prefetchResources({signal:a}),y(o))n=await o.createLayerView(t,{signal:a});else{if(!this.layerViewImporter.hasLayerViewModule(o))throw new e("layer:view-not-supported","No layerview implementation was found");const r=await this.layerViewImporter.importLayerView(o);l(a),n="default"in r?new r.default({layer:o,view:t}):new r({layer:o,view:t})}const c=()=>{w=r(w),n.destroyed||n.destroy(),this.done=!0};w=i(a,c),l(a);try{await n.when()}catch(s){throw c(),s}const h=this._map?.allLayers?.includes(o);if(!h)return c(),void this._deferred.reject(new e("view:no-layerview-for-layer","The layer has been removed from the map",{layer:o}));this.layerView=n,o.emit("layerview-create",{view:t,layerView:n}),t.emit("layerview-create",{layer:o,layerView:n}),this.done=!0,this._deferred.resolve(n)}catch(s){o.emit("layerview-create-error",{view:t,error:s}),t.emit("layerview-create-error",{layer:o,error:s}),this.done=!0,this._deferred.reject(new e("layerview:create-error","layerview creation failed",{layer:o,error:s}))}}}function y(e){return e.createLayerView!==a.prototype.createLayerView}export{s as LayerLayerViewInfo};
5
+ import e from"../../core/Error.js";import{removeMaybe as r}from"../../core/maybe.js";import{createResolver as t,onAbort as i,throwIfAborted as l}from"../../core/promiseUtils.js";import a from"../../layers/Layer.js";function s(e){return"tryRecycleWith"in e}class o{constructor(r,l,a){this.layer=r,this.view=l,this.layerViewImporter=a,this._controller=new AbortController,this._deferred=t(),this._started=!1,this.done=!1,this.promise=this._deferred.promise,i(this._controller.signal,()=>{this._recycleController?.abort();const t=new e("cancelled:layerview-create","layerview creation cancelled",{layer:r});this._deferred.reject(t)})}tryRecycle(e){if(!this.done||!this.layerView||!s(this.layerView))return null;this._recycleController?.abort(),this._recycleController=new AbortController;const r=this.layer.type,t=this._recycleController.signal;for(let i=0;i<e.length;i++){const a=e[i];if(a.type!==r)continue;const s=this.layerView.tryRecycleWith(a,{signal:t});if(s){e.splice(i,1),this.layer=a;const r=this.layerView,o=r.view;return this.promise=s.then(()=>(l(t),a.emit("layerview-destroy",{view:o,layerView:r}),o.emit("layerview-destroy",{view:o,layerView:r}),a.emit("layerview-create",{view:o,layerView:r}),o.emit("layerview-create",{view:o,layerView:r}),r)),this.promise}}return null}destroy(){this._controller.abort();const{layerView:e}=this;if(e){const{layer:r,view:t}=this;r.emit("layerview-destroy",{view:t,layerView:e}),t.emit("layerview-destroy",{layer:r,layerView:e})}this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null,this._map=null,this.promise=null,this._deferred=null}async start(){const{view:t}=this;if(this._started||!t.map)return;this._started=!0;const{_controller:{signal:a},layer:s}=this;this._map=t.map;try{let n,w;if(await s.load({signal:a}),s.prefetchResources&&await s.prefetchResources({signal:a}),y(s))n=await s.createLayerView(t,{signal:a});else{if(!this.layerViewImporter.hasLayerViewModule(s))throw new e("layer:view-not-supported","No layerview implementation was found");const r=await this.layerViewImporter.importLayerView(s);l(a),n="default"in r?new r.default({layer:s,view:t}):new r({layer:s,view:t})}const c=()=>{w=r(w),n.destroyed||n.destroy(),this.done=!0};w=i(a,c),l(a);try{await n.when()}catch(o){throw c(),o}const h=this._map?.allLayers?.includes(s);if(!h)return c(),void this._deferred.reject(new e("view:no-layerview-for-layer","The layer has been removed from the map",{layer:s}));this.layerView=n,s.emit("layerview-create",{view:t,layerView:n}),t.emit("layerview-create",{layer:s,layerView:n}),this.done=!0,this._deferred.resolve(n)}catch(o){s.emit("layerview-create-error",{view:t,error:o}),t.emit("layerview-create-error",{layer:s,error:o}),this.done=!0,this._deferred.reject(new e("layerview:create-error","layerview creation failed",{layer:s,error:o}))}}}function y(e){return e.createLayerView!==a.prototype.createLayerView}export{o as LayerLayerViewInfo};
@@ -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 o from"../../core/Collection.js";import{defaultHighlightName as n,temporaryHighlightColor as r,temporaryHighlightName as t}from"./HighlightDefaults.js";import e from"./HighlightOptions.js";function i(){return new o([new e({name:n}),new e({name:t,color:r})])}function m(o){return o?.name??n}export{i as createInitialHighlightOptions,m as getHighlightName};
5
+ import{defaultHighlightName as t}from"./HighlightDefaults.js";function r(r){return r?.name??t}export{r as getHighlightName};
@@ -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 has from"../../core/has.js";import{webglValidateShadersEnabled as t,webglDebugEnabled as e}from"./checkWebGLError.js";import{ResourceType as o}from"./enums.js";import{transpileShader as i}from"./ShaderTranspiler.js";const n=4294967295,r=!!has("esri-tests-disable-gpu-memory-measurements");class s{constructor(e,s,m,h,f=new Map,_=[]){this._context=e,this._refCount=1,this._compiled=!1,this._linesOfCode=0,this._nameToUniformLocation=new Map,this._nameToUniform1=new Map,this._nameToUniform1v=new Map,this._nameToUniform2=new Map,this._nameToUniform3=new Map,this._nameToUniform4=new Map,this._nameToUniformMatrix3=new Map,this._nameToUniformMatrix4=new Map,e||console.error("RenderingContext isn't initialized!"),0===s.length&&console.error("Shaders source should not be empty!"),s=i(s,35633),m=i(m,35632),this._vShader=a(this._context,35633,s),this._fShader=a(this._context,35632,m),c.enabled&&(this._linesOfCode=s.match(/\n/g).length+m.match(/\n/g).length+2,e.instanceCounter.increment(o.LinesOfCode,this._vShader,this._linesOfCode)),this._vShader&&this._fShader||console.error("Error loading shaders!"),e.instanceCounter.increment(o.Shader,this),t()&&(this.vertexShader=s,this.fragmentShader=m),this.usedMemory=r?0:s.length+m.length;const l=this._context.gl,g=l.createProgram();l.attachShader(g,this._vShader),l.attachShader(g,this._fShader),h.forEach((t,e)=>l.bindAttribLocation(g,t,e)),this.hasTransformFeedbackVaryings=!!_?.length,this.hasTransformFeedbackVaryings&&l.transformFeedbackVaryings(g,_,l.SEPARATE_ATTRIBS),l.linkProgram(g),t()&&!l.getProgramParameter(g,l.LINK_STATUS)&&console.error(`Could not link shader\nvalidated: ${l.getProgramParameter(g,l.VALIDATE_STATUS)}, gl error ${l.getError()}, vertex: ${l.getShaderParameter(this._vShader,l.COMPILE_STATUS)}, fragment: ${l.getShaderParameter(this._fShader,l.COMPILE_STATUS)}, info log: ${l.getProgramInfoLog(g)}, vertex source: ${this.vertexShader}, fragment source: ${this.fragmentShader}`);for(const[t,o]of f){const e=l.getUniformBlockIndex(g,t);e<n&&l.uniformBlockBinding(g,e,o)}this._glName=g,e.instanceCounter.increment(o.Program,this)}get glName(){return this._glName}get hasGLName(){return null!=this._glName}get compiled(){return!!this._compiled||(this._context.capabilities.parallelShaderCompile&&null!=this.glName?(this._compiled=!!this._context.gl.getProgramParameter(this.glName,37297),this._compiled):(this._compiled=!0,!0))}dispose(){if(--this._refCount>0)return;const t=this._context.gl,e=this._context.instanceCounter;this._nameToUniformLocation.forEach(t=>t&&e.decrement(o.Uniform,t)),this._nameToUniformLocation.clear(),this._vShader&&(this._linesOfCode>0&&(e.decrement(o.LinesOfCode,this._vShader,this._linesOfCode),this._linesOfCode=0),t.deleteShader(this._vShader),this._vShader=null,e.decrement(o.Shader,this)),this._fShader&&(t.deleteShader(this._fShader),this._fShader=null),this._glName&&(t.deleteProgram(this._glName),this._glName=null,e.decrement(o.Program,this))}ref(){++this._refCount}_getUniformLocation(t){const e=this._nameToUniformLocation.get(t);if(void 0!==e)return e;if(this.glName){const e=this._context.gl.getUniformLocation(this.glName,t);return this._nameToUniformLocation.set(t,e),e&&this._context.instanceCounter.increment(o.Uniform,e),e}return null}hasUniform(t){return null!=this._getUniformLocation(t)}setUniform1i(t,e,o){_(o,e);const i=this._nameToUniform1.get(t);void 0!==i&&e===i||(this._context.gl.uniform1i(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1iv(t,e,o){l(o,e),f(this._nameToUniform1v,t,e)&&this._context.gl.uniform1iv(this._getUniformLocation(t),e)}setUniform2iv(t,e,o){l(o,e),f(this._nameToUniform2,t,e)&&this._context.gl.uniform2iv(this._getUniformLocation(t),e)}setUniform3iv(t,e,o){l(o,e),f(this._nameToUniform3,t,e)&&this._context.gl.uniform3iv(this._getUniformLocation(t),e)}setUniform4iv(t,e,o){l(o,e),f(this._nameToUniform4,t,e)&&this._context.gl.uniform4iv(this._getUniformLocation(t),e)}setUniform1f(t,e,o){_(o,e);const i=this._nameToUniform1.get(t);void 0!==i&&e===i||(this._context.gl.uniform1f(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1fv(t,e,o){l(o,e),f(this._nameToUniform1v,t,e)&&this._context.gl.uniform1fv(this._getUniformLocation(t),e)}setUniform2f(t,e,o,i){_(i,e,o);const n=this._nameToUniform2.get(t);void 0===n?(this._context.gl.uniform2f(this._getUniformLocation(t),e,o),this._nameToUniform2.set(t,[e,o])):e===n[0]&&o===n[1]||(this._context.gl.uniform2f(this._getUniformLocation(t),e,o),n[0]=e,n[1]=o)}setUniform2fv(t,e,o){l(o,e),f(this._nameToUniform2,t,e)&&this._context.gl.uniform2fv(this._getUniformLocation(t),e)}setUniform3f(t,e,o,i,n){_(n,e,o,i);const r=this._nameToUniform3.get(t);void 0===r?(this._context.gl.uniform3f(this._getUniformLocation(t),e,o,i),this._nameToUniform3.set(t,[e,o,i])):e===r[0]&&o===r[1]&&i===r[2]||(this._context.gl.uniform3f(this._getUniformLocation(t),e,o,i),r[0]=e,r[1]=o,r[2]=i)}setUniform3fv(t,e,o){l(o,e);const i=this._getUniformLocation(t);null!=i&&f(this._nameToUniform3,t,e)&&this._context.gl.uniform3fv(i,e)}setUniform4f(t,e,o,i,n,r){_(r,e,o,i,n);const s=this._nameToUniform4.get(t);void 0===s?(this._context.gl.uniform4f(this._getUniformLocation(t),e,o,i,n),this._nameToUniform4.set(t,[e,o,i,n])):void 0!==s&&e===s[0]&&o===s[1]&&i===s[2]&&n===s[3]||(this._context.gl.uniform4f(this._getUniformLocation(t),e,o,i,n),s[0]=e,s[1]=o,s[2]=i,s[3]=n)}setUniform4fv(t,e,o){l(o,e);const i=this._getUniformLocation(t);null!=i&&f(this._nameToUniform4,t,e)&&this._context.gl.uniform4fv(i,e)}setUniformMatrix3fv(t,e,o=!1,i){l(i,e);const n=this._getUniformLocation(t);null!=n&&f(this._nameToUniformMatrix3,t,e)&&this._context.gl.uniformMatrix3fv(n,o,e)}setUniformMatrix4fv(t,e,o=!1,i){l(i,e);const n=this._getUniformLocation(t);null!=n&&f(this._nameToUniformMatrix4,t,e)&&this._context.gl.uniformMatrix4fv(n,o,e)}stop(){}}function a(e,o,i){const n=e.gl,r=n.createShader(o);return n.shaderSource(r,i),n.compileShader(r),t()&&!n.getShaderParameter(r,n.COMPILE_STATUS)&&(console.error("Compile error in ".concat(35633===o?"vertex":"fragment"," shader")),console.error(n.getShaderInfoLog(r)),console.error(m(i))),r}function m(t){let e=2;return t.replaceAll("\n",()=>"\n"+h(e++)+":")}function h(t){return t>=1e3?t.toString():(" "+t).slice(-3)}function f(t,e,o){const i=t.get(e);if(!i)return t.set(e,Array.from(o)),!0;const n=o.length;if(i.length!==n)return t.set(e,Array.from(o)),!0;for(let r=0;r<n;++r){const t=o[r];if(i[r]!==t){for(i[r]=t;r<n;++r)i[r]=o[r];return!0}}return!1}const c={enabled:!1},_=e()?(t,...e)=>l(t,e):()=>{},l=e()?(t,e)=>{if(t?.supportsNaN)return;const o=e.length;for(let i=0;i<o;++i){const t=e[i];Number.isNaN(t)&&console.error(`Got ${t} as uniform value from ${(new Error).stack}`)}}:()=>{};export{s as Program,c as test};
5
+ import has from"../../core/has.js";import{webglValidateShadersEnabled as t,webglDebugEnabled as e}from"./checkWebGLError.js";import{ResourceType as o}from"./enums.js";import{transpileShader as i}from"./ShaderTranspiler.js";const n=4294967295,r=!!has("esri-tests-disable-gpu-memory-measurements");class s{constructor(e,s,m,h,f=new Map,l=[]){this._context=e,this._refCount=1,this._compiled=!1,this._linesOfCode=0,this._nameToUniformLocation=new Map,this._nameToUniform1=new Map,this._nameToUniform1v=new Map,this._nameToUniform2=new Map,this._nameToUniform3=new Map,this._nameToUniform4=new Map,this._nameToUniformMatrix3=new Map,this._nameToUniformMatrix4=new Map,e||console.error("RenderingContext isn't initialized!"),0===s.length&&console.error("Shaders source should not be empty!"),s=i(s,35633),m=i(m,35632),this._vShader=a(this._context,35633,s),this._fShader=a(this._context,35632,m),c.enabled&&(this._linesOfCode=s.match(/\n/g).length+m.match(/\n/g).length+2,e.instanceCounter.increment(o.LinesOfCode,this._vShader,this._linesOfCode)),this._vShader&&this._fShader||console.error("Error loading shaders!"),e.instanceCounter.increment(o.Shader,this),t()&&(this.vertexShader=s,this.fragmentShader=m),this.usedMemory=r?0:s.length+m.length;const _=this._context.gl,g=_.createProgram();_.attachShader(g,this._vShader),_.attachShader(g,this._fShader),h.forEach((t,e)=>_.bindAttribLocation(g,t,e)),this.hasTransformFeedbackVaryings=!!l?.length,this.hasTransformFeedbackVaryings&&_.transformFeedbackVaryings(g,l,_.SEPARATE_ATTRIBS),_.linkProgram(g),t()&&!_.getProgramParameter(g,_.LINK_STATUS)&&console.error(`Could not link shader\nvalidated: ${_.getProgramParameter(g,_.VALIDATE_STATUS)}, gl error ${_.getError()}, vertex: ${_.getShaderParameter(this._vShader,_.COMPILE_STATUS)}, fragment: ${_.getShaderParameter(this._fShader,_.COMPILE_STATUS)}, info log: ${_.getProgramInfoLog(g)}, vertex source: ${this.vertexShader}, fragment source: ${this.fragmentShader}`);for(const[t,o]of f){const e=_.getUniformBlockIndex(g,t);e<n&&_.uniformBlockBinding(g,e,o)}this._glName=g,e.instanceCounter.increment(o.Program,this)}get glName(){return this._glName}get hasGLName(){return null!=this._glName}get compiled(){return!!this._compiled||(this._context.capabilities.parallelShaderCompile&&null!=this.glName?(this._compiled=!!this._context.gl.getProgramParameter(this.glName,37297),this._compiled):(this._compiled=!0,!0))}dispose(){if(--this._refCount>0)return;const t=this._context.gl,e=this._context.instanceCounter;this._nameToUniformLocation.forEach(t=>t&&e.decrement(o.Uniform,t)),this._nameToUniformLocation.clear(),this._vShader&&(this._linesOfCode>0&&(e.decrement(o.LinesOfCode,this._vShader,this._linesOfCode),this._linesOfCode=0),t.deleteShader(this._vShader),this._vShader=null,e.decrement(o.Shader,this)),this._fShader&&(t.deleteShader(this._fShader),this._fShader=null),this._glName&&(t.deleteProgram(this._glName),this._glName=null,e.decrement(o.Program,this))}ref(){++this._refCount}_getUniformLocation(t){const e=this._nameToUniformLocation.get(t);if(void 0!==e)return e;if(this.glName){const e=this._context.gl.getUniformLocation(this.glName,t);return this._nameToUniformLocation.set(t,e),e&&this._context.instanceCounter.increment(o.Uniform,e),e}return null}hasUniform(t){return null!=this._getUniformLocation(t)}setUniform1i(t,e,o){l(o,e);const i=this._nameToUniform1.get(t);void 0!==i&&e===i||(this._context.gl.uniform1i(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1iv(t,e,o){_(o,e),f(this._nameToUniform1v,t,e)&&this._context.gl.uniform1iv(this._getUniformLocation(t),e)}setUniform2iv(t,e,o){_(o,e),f(this._nameToUniform2,t,e)&&this._context.gl.uniform2iv(this._getUniformLocation(t),e)}setUniform3iv(t,e,o){_(o,e),f(this._nameToUniform3,t,e)&&this._context.gl.uniform3iv(this._getUniformLocation(t),e)}setUniform4iv(t,e,o){_(o,e),f(this._nameToUniform4,t,e)&&this._context.gl.uniform4iv(this._getUniformLocation(t),e)}setUniform1f(t,e,o){l(o,e);const i=this._nameToUniform1.get(t);void 0!==i&&e===i||(this._context.gl.uniform1f(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1fv(t,e,o){_(o,e),f(this._nameToUniform1v,t,e)&&this._context.gl.uniform1fv(this._getUniformLocation(t),e)}setUniform2f(t,e,o,i){l(i,e,o);const n=this._nameToUniform2.get(t);void 0===n?(this._context.gl.uniform2f(this._getUniformLocation(t),e,o),this._nameToUniform2.set(t,[e,o])):e===n[0]&&o===n[1]||(this._context.gl.uniform2f(this._getUniformLocation(t),e,o),n[0]=e,n[1]=o)}setUniform2fv(t,e,o){_(o,e),f(this._nameToUniform2,t,e)&&this._context.gl.uniform2fv(this._getUniformLocation(t),e)}setUniform3f(t,e,o,i,n){l(n,e,o,i);const r=this._nameToUniform3.get(t);void 0===r?(this._context.gl.uniform3f(this._getUniformLocation(t),e,o,i),this._nameToUniform3.set(t,[e,o,i])):e===r[0]&&o===r[1]&&i===r[2]||(this._context.gl.uniform3f(this._getUniformLocation(t),e,o,i),r[0]=e,r[1]=o,r[2]=i)}setUniform3fv(t,e,o){_(o,e);const i=this._getUniformLocation(t);null!=i&&f(this._nameToUniform3,t,e)&&this._context.gl.uniform3fv(i,e)}setUniform4f(t,e,o,i,n,r){l(r,e,o,i,n);const s=this._nameToUniform4.get(t);void 0===s?(this._context.gl.uniform4f(this._getUniformLocation(t),e,o,i,n),this._nameToUniform4.set(t,[e,o,i,n])):void 0!==s&&e===s[0]&&o===s[1]&&i===s[2]&&n===s[3]||(this._context.gl.uniform4f(this._getUniformLocation(t),e,o,i,n),s[0]=e,s[1]=o,s[2]=i,s[3]=n)}setUniform4fv(t,e,o){_(o,e);const i=this._getUniformLocation(t);null!=i&&f(this._nameToUniform4,t,e)&&this._context.gl.uniform4fv(i,e)}setUniformMatrix3fv(t,e,o=!1,i){_(i,e);const n=this._getUniformLocation(t);null!=n&&f(this._nameToUniformMatrix3,t,e)&&this._context.gl.uniformMatrix3fv(n,o,e)}setUniformMatrix4fv(t,e,o=!1,i){_(i,e);const n=this._getUniformLocation(t);if(null!=n){const i=this._nameToUniformMatrix4,r=i.get(t);let s=!1;if(r){const o=e.length;if(r.length!==o)i.set(t,Array.from(e)),s=!0;else for(let t=0;t<o;++t){const i=e[t];if(r[t]!==i){for(r[t]=i;t<o;++t)r[t]=e[t];s=!0;break}}}else i.set(t,Array.from(e)),s=!0;s&&this._context.gl.uniformMatrix4fv(n,o,e)}}setUniformMatrices4fv(t,e,o=!1,i){_(i,e);const n=this._getUniformLocation(t);null!=n&&f(this._nameToUniformMatrix4,t,e)&&this._context.gl.uniformMatrix4fv(n,o,e)}stop(){}}function a(e,o,i){const n=e.gl,r=n.createShader(o);return n.shaderSource(r,i),n.compileShader(r),t()&&!n.getShaderParameter(r,n.COMPILE_STATUS)&&(console.error("Compile error in ".concat(35633===o?"vertex":"fragment"," shader")),console.error(n.getShaderInfoLog(r)),console.error(m(i))),r}function m(t){let e=2;return t.replaceAll("\n",()=>"\n"+h(e++)+":")}function h(t){return t>=1e3?t.toString():(" "+t).slice(-3)}function f(t,e,o){const i=t.get(e);if(!i)return t.set(e,Array.from(o)),!0;const n=o.length;if(i.length!==n)return t.set(e,Array.from(o)),!0;for(let r=0;r<n;++r){const t=o[r];if(i[r]!==t){for(i[r]=t;r<n;++r)i[r]=o[r];return!0}}return!1}const c={enabled:!1},l=e()?(t,...e)=>_(t,e):()=>{},_=e()?(t,e)=>{if(t?.supportsNaN)return;const o=e.length;for(let i=0;i<o;++i){const t=e[i];Number.isNaN(t)&&console.error(`Got ${t} as uniform value from ${(new Error).stack}`)}}:()=>{};export{s as Program,c as test};
@@ -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 t from"../../core/Error.js";import e from"../../core/Logger.js";import{hasValue as r}from"../../core/object.js";import{PixelType as n,SizedPixelFormat as o,SizedDepthStencilFormat as i,SizedDepthFormat as u,CompressedTextureFormat as a,sizedPixelFormatValues as l}from"./enums.js";const c=()=>e.getLogger("esri/views/webgl/textureUtils");function s(t){const{width:e,height:r,depth:n}=t;(null!=e&&e<0||null!=r&&r<0||null!=n&&n<0)&&c().error("Negative dimension parameters are not allowed!");const{internalFormat:o}=t;if(o&&(m(o)||p(o))){const{linearFilterDepth:e,compareEnabled:r,samplingMode:n,hasMipmap:o}=t;o&&c().error("Depth textures cannot have mipmaps"),e?9729!==n&&9728!==n&&c().error("Depth textures cannot sample mipmaps"):(9728!==n&&c().error("Depth textures without filtering must use NEAREST filtering"),r&&c().error("Depth textures without filtering cannot use compare function"))}}function h(t){return l.includes(t)}function m(t){return r(u,t)}function p(t){return r(i,t)}function f(t){return null!=t&&r(a,t)}function d(t){return null!=t&&"type"in t&&"compressed"===t.type}function g(t){return f(t.descriptor.internalFormat)}function w(t){return null!=t&&"byteLength"in t}function F(t){return null!=t&&!d(t)&&!w(t)}function x(t){return 32879===t||35866===t}function E(t,e,r,n=1){let o=Math.max(e,r);return 32879===t&&(o=Math.max(o,n)),Math.floor(Math.log2(o))+1}function T(e){if(null!=e.internalFormat)return e.internalFormat;switch(e.dataType){case n.FLOAT:switch(e.pixelFormat){case 6408:return o.RGBA32F;case 6407:return o.RGB32F;default:throw new t("texture:unknown-format","Unable to derive format")}case n.UNSIGNED_BYTE:switch(e.pixelFormat){case 6408:return o.RGBA8;case 6407:return o.RGB8}}const{pixelFormat:r}=e;return e.internalFormat=34041===r?i.DEPTH24_STENCIL8:6402===r?u.DEPTH_COMPONENT24:r,e.internalFormat}function D(t){let e="width"in t?t.width:t.codedWidth,r="height"in t?t.height:t.codedHeight;const n=1;return t instanceof HTMLVideoElement&&(e=t.videoWidth,r=t.videoHeight),{width:e,height:r,depth:n}}export{E as calcMipmapLevels,T as deriveInternalFormat,D as getDimensions,x as is3DTarget,w as isArrayBufferView,d as isCompressedData,f as isCompressedFormat,g as isCompressedTexture,m as isSizedDepthFormat,p as isSizedDepthStencilFormat,h as isSizedPixelFormat,F as isTexImageSource,s as validateTexture};
5
+ import t from"../../core/Error.js";import e from"../../core/Logger.js";import{hasValue as r}from"../../core/object.js";import{PixelType as n,SizedPixelFormat as o,SizedDepthStencilFormat as i,SizedDepthFormat as u,CompressedTextureFormat as a,sizedPixelFormatValues as l}from"./enums.js";const c=()=>e.getLogger("esri/views/webgl/textureUtils");function s(t){const{width:e,height:r,depth:n}=t;(null!=e&&e<0||null!=r&&r<0||null!=n&&n<0)&&c().error("Negative dimension parameters are not allowed!");const{internalFormat:o}=t;if(o&&(m(o)||p(o))){const{linearFilterDepth:e,compareEnabled:r,samplingMode:n,hasMipmap:o}=t;o&&c().error("Depth textures cannot have mipmaps"),e?9729!==n&&9728!==n&&c().error("Depth textures cannot sample mipmaps"):(9728!==n&&c().error("Depth textures without filtering must use NEAREST filtering"),r&&c().error("Depth textures without filtering cannot use compare function"))}}function h(t){return l.includes(t)}function m(t){return r(u,t)}function p(t){return r(i,t)}function f(t){return null!=t&&r(a,t)}function d(t){return null!=t&&"type"in t&&"compressed"===t.type}function g(t){return null!=t&&"byteLength"in t}function w(t){return null!=t&&!d(t)&&!g(t)}function x(t){return 32879===t||35866===t}function F(t,e,r,n=1){let o=Math.max(e,r);return 32879===t&&(o=Math.max(o,n)),Math.floor(Math.log2(o))+1}function E(e){if(null!=e.internalFormat)return e.internalFormat;switch(e.dataType){case n.FLOAT:switch(e.pixelFormat){case 6408:return o.RGBA32F;case 6407:return o.RGB32F;default:throw new t("texture:unknown-format","Unable to derive format")}case n.UNSIGNED_BYTE:switch(e.pixelFormat){case 6408:return o.RGBA8;case 6407:return o.RGB8}}const{pixelFormat:r}=e;return e.internalFormat=34041===r?i.DEPTH24_STENCIL8:6402===r?u.DEPTH_COMPONENT24:r,e.internalFormat}function T(t){let e="width"in t?t.width:t.codedWidth,r="height"in t?t.height:t.codedHeight;const n=1;return t instanceof HTMLVideoElement&&(e=t.videoWidth,r=t.videoHeight),{width:e,height:r,depth:n}}export{F as calcMipmapLevels,E as deriveInternalFormat,T as getDimensions,x as is3DTarget,g as isArrayBufferView,d as isCompressedData,f as isCompressedFormat,m as isSizedDepthFormat,p as isSizedDepthStencilFormat,h as isSizedPixelFormat,w as isTexImageSource,s as validateTexture};
@@ -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{JSONSupport as t}from"../core/JSONSupport.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{reader as o}from"../core/accessorSupport/decorators/reader.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{writer as a}from"../core/accessorSupport/decorators/writer.js";var d;let i=class extends t{static{d=this}constructor(...e){super(...e),this.type="sun",this.date=null,this.directShadowsEnabled=!1,this.displayUTCOffset=null}readDate(e,t){return null!=t.datetime&&new Date(t.datetime)||null}writeDate(e,t,r){t[r]=e.getTime()}readDirectShadowsEnabled(e,t){return!!t.directShadows}writedirectShadowsEnabled(e,t,r){e&&(t[r]=e)}writeDisplayUTCOffset(e,t){null!=e&&(t.displayUTCOffset=e)}clone(){return new d(this.cloneConstructProperties())}cloneConstructProperties(){const e={directShadowsEnabled:this.directShadowsEnabled,displayUTCOffset:null!=this.displayUTCOffset?this.displayUTCOffset:null};return null!=this.date&&(e.date=new Date(this.date.getTime())),e}};e([r({readOnly:!0,type:["sun"],json:{write:!0}})],i.prototype,"type",void 0),e([r({type:Date,json:{type:Number,write:{target:"datetime"}}})],i.prototype,"date",void 0),e([o("date",["datetime"])],i.prototype,"readDate",null),e([a("date")],i.prototype,"writeDate",null),e([r({type:Boolean,json:{default:!1,write:{target:"directShadows"}}})],i.prototype,"directShadowsEnabled",void 0),e([o("directShadowsEnabled",["directShadows"])],i.prototype,"readDirectShadowsEnabled",null),e([a("directShadowsEnabled")],i.prototype,"writedirectShadowsEnabled",null),e([r({type:Number,json:{write:!0}})],i.prototype,"displayUTCOffset",void 0),e([a("displayUTCOffset")],i.prototype,"writeDisplayUTCOffset",null),i=d=e([s("esri.webscene.SunLighting")],i);const p=i;export{p as default};
5
+ import{__decorate as e}from"tslib";import{JSONSupport as t}from"../core/JSONSupport.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{reader as o}from"../core/accessorSupport/decorators/reader.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{writer as a}from"../core/accessorSupport/decorators/writer.js";var d;let i=class extends t{static{d=this}constructor(...e){super(...e),this.type="sun",this.date=null,this.directShadowsEnabled=!1,this.displayUTCOffset=null}readDate(e,t){return null!=t.datetime&&new Date(t.datetime)||null}writeDate(e,t,r){t[r]=e.getTime()}readDirectShadowsEnabled(e,t){return!!t.directShadows}writedirectShadowsEnabled(e,t,r){e&&(t[r]=e)}writeDisplayUTCOffset(e,t){null!=e&&(t.displayUTCOffset=e)}clone(){return new d(this.cloneConstructProperties())}cloneConstructProperties(){const e={directShadowsEnabled:this.directShadowsEnabled,displayUTCOffset:null!=this.displayUTCOffset?this.displayUTCOffset:null};return null!=this.date&&(e.date=new Date(this.date)),e}};e([r({readOnly:!0,type:["sun"],json:{write:!0}})],i.prototype,"type",void 0),e([r({type:Date,json:{type:Number,write:{target:"datetime"}}})],i.prototype,"date",void 0),e([o("date",["datetime"])],i.prototype,"readDate",null),e([a("date")],i.prototype,"writeDate",null),e([r({type:Boolean,json:{default:!1,write:{target:"directShadows"}}})],i.prototype,"directShadowsEnabled",void 0),e([o("directShadowsEnabled",["directShadows"])],i.prototype,"readDirectShadowsEnabled",null),e([a("directShadowsEnabled")],i.prototype,"writedirectShadowsEnabled",null),e([r({type:Number,json:{write:!0}})],i.prototype,"displayUTCOffset",void 0),e([a("displayUTCOffset")],i.prototype,"writeDisplayUTCOffset",null),i=d=e([s("esri.webscene.SunLighting")],i);const p=i;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 t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{makeHandle as i}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{removeMaybe as s}from"../../core/maybe.js";import{when as l,watch as a,on as o,initial as r,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as g}from"../../core/scheduling.js";import{truncateLocalTime as d,isValidDate as p,resetUTCDate as u,offsetDate as c}from"../../core/timeUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../views/3d/environment/SunLighting.js";import f from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as D}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as w,sliderPosToDateTime as T,getSeasonFromDate as S,getNorthernHemisphereSeason as U,getSeasonDate as v,calculatePlaySpeed as L}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as P}from"./support/SliderWithDropdownViewModel.js";import{formatSliderLabel as b,getSunriseAndSunsetTimes as C}from"../support/timeWidgetUtils.js";let O=class extends e{constructor(t){super(t),this.view=null,this.timeSliderViewModel=new P({min:0,max:1439,values:[0],labelFormatFunction:b,inputFormatFunction:b}),this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._lastTime=null,this._sunrise=null,this._sunset=null,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._lastLightingUpdate=0,this._lightingUpdateHandle=null}initialize(){this.addHandles([l(()=>this.view,t=>t.when(()=>this._updateLighting()),r),a(()=>{const t=this._lighting;return"sun"===t?.type?t.date:null},t=>this._scheduleLightingUpdate(t)),o(()=>this._lighting,"timezone-will-change",t=>this._timezoneWillChange(t),{onListenerAdd:()=>this._timezoneWillChange(null)}),a(()=>!0===this.view?.stationary,()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()},r),a(()=>{const t=this.timeSliderViewModel;return{vm:t,state:t.state,sliderPosition:this.timeSliderPosition}},({vm:t,state:e,sliderPosition:i})=>{"ready"===e&&t.setValue(0,i)}),a(()=>this.timeSliderViewModel?.utcOffset,t=>{null!=t&&(this.utcOffset=t)}),a(()=>({utcOffset:this.utcOffset,sliderViewModel:this.timeSliderViewModel}),({utcOffset:t,sliderViewModel:e})=>{e&&(e.utcOffset=t)},h),a(()=>this.timeSliderViewModel.timezonePickerOpen,()=>this.stopPlaying()),a(()=>this.timeSliderViewModel.values,t=>this._setTimeSliderPosition(t?.[0]??0,{forceLightingUpdate:!1}))])}destroy(){this._cancelLightingUpdate(),this.view=null}get isSupported(){return null==this.view||"3d"===this.view.type}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(t){t!==this.utcOffset&&null!=this._lighting&&"virtual"!==this._lighting.type&&(this._lighting.displayUTCOffset=t,this._updateLighting())}get localDate(){return d(this._lightingDateDisplay)}set localDate(t){this.view?.ready?p(t)&&t.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=u(this._lightingDateDisplay,t)):n.getLogger(this).error("The localDate property cannot be set before the view and the widget are ready.")}get timeSliderPosition(){return w(this._lightingDateDisplay)}set timeSliderPosition(t){this.view?.ready&&"ready"===this.timeSliderViewModel?.state?this._setTimeSliderPosition(t,{forceLightingUpdate:!0}):n.getLogger(this).error("The timeSliderPosition property cannot be set before the view and the widget are ready.")}_setTimeSliderPosition(t,e){Math.abs(t-this.timeSliderPosition)<=1/60||(this.stopPlaying(),this._onUserDateTimeChange(),e.forceLightingUpdate&&(this._cancelLightingUpdate(),this._updateLighting()),this._lightingDateDisplay=T(this._lightingDateDisplay,t))}_timezoneFromCamera(t,e){if(null==e||!t.cameraTrackingEnabled)return 0;const i=D([e.longitude,e.latitude]);return null==i?0:Math.round(i.hours+i.minutes/60+i.seconds/3600)}get directShadowsEnabled(){return this._lighting?.directShadowsEnabled??!1}set directShadowsEnabled(t){const e=this._lighting;e&&(e.directShadowsEnabled=t)}get sunLightingEnabled(){return"sun"===this._lightingType}set sunLightingEnabled(t){const e=this._environment;if(t===this._get("sunLightingEnabled")||null==e)return;const i=e.lighting,n=this._oldLighting;this._oldLighting=i;const s={directShadowsEnabled:i.directShadowsEnabled,cameraTrackingEnabled:i.cameraTrackingEnabled},l=t?"sun":"virtual";let a;a=null!=n&&n.type===l?n:t?new _:new f,a.set(s),e.lighting=a,t||(this.stopPlaying(),this.timeSliderViewModel.timezonePickerOpen=!1)}set playingState(t){this.playingState!==t&&(this._set("playingState",t),"none"!==t&&this.sunLightingEnabled&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._onUserDateTimeChange()))}get dayPlaying(){return"day"===this.playingState}set dayPlaying(t){t?this.playingState="day":this.dayPlaying&&(this.playingState="none")}get yearPlaying(){return"year"===this.playingState}set yearPlaying(t){t?this.playingState="year":this.yearPlaying&&(this.playingState="none")}get currentSeason(){return S(this.localDate,this._currentHemisphere)}set currentSeason(t){this.stopPlaying(),this._onUserDateTimeChange();const e=U(t,this._currentHemisphere);this.localDate=v(this.localDate,e,0)}get _currentHemisphere(){const t=this.view?.camera?.position?.latitude;return null==t||t>=0?0:1}get _environment(){return this.view?.environment}get _lighting(){return this._environment?.lighting}get _lightingType(){return this._lighting?.type}get _lightingDateDisplay(){return c(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,"hours")}set _lightingDateDisplay(t){const e=this._lighting;if(null==e||!this.sunLightingEnabled||"virtual"===e.type||!p(t))return;const i=e.date,n=c(t,-this._cachedDisplayUTCOffset,"hours");n.getTime()!==i.getTime()&&(e.date=n,this._updateLighting())}stopPlaying(){this.playingState="none"}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}onDateChange(t){this.dayPlaying=!1,this.localDate=t,this._onUserDateTimeChange()}_updateLighting(t){const e=Date.now();this._lastLightingUpdate=e;const{view:i}=this,n=this._lighting;if(null==i||null==n||"virtual"===n.type)return;t??=n.date;const s=n.displayUTCOffset,l=null!=s?s:this._timezoneFromCamera(n,i.camera?.position);this._cachedLightingDateUTC.getTime()!==t.getTime()&&(this._cachedLightingDateUTC=new Date(t.getTime())),this._cachedDisplayUTCOffset!==l&&(this._cachedDisplayUTCOffset=l)}_timezoneWillChange(t){const e=this._lighting;if(null==e||"virtual"===e.type||!e.cameraTrackingEnabled)return;let i;if(t)i=t.timezoneOffset;else{if(null!=e.displayUTCOffset)return;i=_.calculateTimezoneOffset(e.positionTimezoneInfo)}e.displayUTCOffset=i,this._scheduleLightingUpdate()}_scheduleLightingUpdate(t){if(t&&(this._lightingUpdateHandle=s(this._lightingUpdateHandle),!p(t)))return;if(this._lightingUpdateHandle)return;const e=Date.now()-this._lastLightingUpdate,n=this.lightingUpdateInterval-e;let l=null;const a=()=>{this._updateLighting(t),this._lightingUpdateHandle===l&&(this._lightingUpdateHandle=null)};if(n<=0)this._lightingUpdateHandle=l=g(a);else{const t=setTimeout(a,n);this._lightingUpdateHandle=l=i(()=>clearTimeout(t))}}_cancelLightingUpdate(){this._lightingUpdateHandle=s(this._lightingUpdateHandle)}_play(){const t=this._lighting;if(null==t||!this.sunLightingEnabled||"virtual"===t.type)return;const e=t.date;if(this.dayPlaying||this.yearPlaying){const i=Date.now()-(this._lastTime??0);if(this.dayPlaying){this._lastTime=Date.now();const n=L(this._sunrise,this._sunset,e)*this.playSpeedMultiplier/100*i;if(n>0){let i=new Date(e.getTime()+n);const s=t.displayUTCOffset??0;if(((i.getUTCHours()+s)%24+24)%24<((e.getUTCHours()+s)%24+24)%24){const t=864e5;i=new Date(e.getTime()+n-t)}t.date=i}}else{if(i>1e3){this._lastTime=Date.now();const i=(e.getUTCMonth()+1)%12,n=new Date(e.getTime());n.setUTCMonth(i),t.date=n}}requestAnimationFrame(()=>this._play())}}_updateSunriseAndSunset(){const t=this._lighting;if(null==t||"virtual"===t.type||!this.sunLightingEnabled)return;const e=this.view?.camera?.position;if(null==e)return;const{latitude:i,longitude:n}=e,{date:s,displayUTCOffset:l}=t,a=C(s,i,n,l??0);a&&(this._sunrise=new Date(a.sunrise),this._sunset=new Date(a.sunset))}_onUserDateTimeChange(){this.emit("user-date-time-change",{})}};t([y()],O.prototype,"view",void 0),t([y({type:P,nonNullable:!0})],O.prototype,"timeSliderViewModel",void 0),t([y()],O.prototype,"isSupported",null),t([y()],O.prototype,"lightingUpdateInterval",void 0),t([y()],O.prototype,"utcOffset",null),t([y({type:Date})],O.prototype,"localDate",null),t([y()],O.prototype,"timeSliderPosition",null),t([y()],O.prototype,"directShadowsEnabled",null),t([y()],O.prototype,"sunLightingEnabled",null),t([y({type:["none","day","year"],value:"none"})],O.prototype,"playingState",null),t([y()],O.prototype,"dayPlaying",null),t([y()],O.prototype,"yearPlaying",null),t([y()],O.prototype,"playSpeedMultiplier",void 0),t([y()],O.prototype,"currentSeason",null),t([y()],O.prototype,"_lastTime",void 0),t([y()],O.prototype,"_sunrise",void 0),t([y()],O.prototype,"_sunset",void 0),t([y()],O.prototype,"_cachedLightingDateUTC",void 0),t([y()],O.prototype,"_cachedDisplayUTCOffset",void 0),t([y()],O.prototype,"_currentHemisphere",null),t([y()],O.prototype,"_environment",null),t([y()],O.prototype,"_lighting",null),t([y()],O.prototype,"_lightingType",null),t([y()],O.prototype,"_lightingDateDisplay",null),O=t([m("esri.widgets.Daylight.DaylightViewModel")],O);const E=O;export{E as default};
5
+ import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{makeHandle as i}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{removeMaybe as s}from"../../core/maybe.js";import{when as l,watch as a,on as o,initial as r,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as g}from"../../core/scheduling.js";import{truncateLocalTime as d,isValidDate as p,resetUTCDate as u,offsetDate as c}from"../../core/timeUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../views/3d/environment/SunLighting.js";import f from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as D}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as w,sliderPosToDateTime as S,getSeasonFromDate as U,getNorthernHemisphereSeason as T,getSeasonDate as v,calculatePlaySpeed as L}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as P}from"./support/SliderWithDropdownViewModel.js";import{formatSliderLabel as b,getSunriseAndSunsetTimes as C}from"../support/timeWidgetUtils.js";let O=class extends e{constructor(t){super(t),this.view=null,this.timeSliderViewModel=new P({min:0,max:1439,values:[0],labelFormatFunction:b,inputFormatFunction:b}),this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._lastTime=null,this._sunrise=null,this._sunset=null,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._lastLightingUpdate=0,this._lightingUpdateHandle=null}initialize(){this.addHandles([l(()=>this.view,t=>t.when(()=>this._updateLighting()),r),a(()=>{const t=this._lighting;return"sun"===t?.type?t.date:null},t=>this._scheduleLightingUpdate(t)),o(()=>this._lighting,"timezone-will-change",t=>this._timezoneWillChange(t),{onListenerAdd:()=>this._timezoneWillChange(null)}),a(()=>!0===this.view?.stationary,()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()},r),a(()=>{const t=this.timeSliderViewModel;return{vm:t,state:t.state,sliderPosition:this.timeSliderPosition}},({vm:t,state:e,sliderPosition:i})=>{"ready"===e&&t.setValue(0,i)}),a(()=>this.timeSliderViewModel?.utcOffset,t=>{null!=t&&(this.utcOffset=t)}),a(()=>({utcOffset:this.utcOffset,sliderViewModel:this.timeSliderViewModel}),({utcOffset:t,sliderViewModel:e})=>{e&&(e.utcOffset=t)},h),a(()=>this.timeSliderViewModel.timezonePickerOpen,()=>this.stopPlaying()),a(()=>this.timeSliderViewModel.values,t=>this._setTimeSliderPosition(t?.[0]??0,{forceLightingUpdate:!1}))])}destroy(){this._cancelLightingUpdate(),this.view=null}get isSupported(){return null==this.view||"3d"===this.view.type}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(t){t!==this.utcOffset&&null!=this._lighting&&"virtual"!==this._lighting.type&&(this._lighting.displayUTCOffset=t,this._updateLighting())}get localDate(){return d(this._lightingDateDisplay)}set localDate(t){this.view?.ready?p(t)&&t.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=u(this._lightingDateDisplay,t)):n.getLogger(this).error("The localDate property cannot be set before the view and the widget are ready.")}get timeSliderPosition(){return w(this._lightingDateDisplay)}set timeSliderPosition(t){this.view?.ready&&"ready"===this.timeSliderViewModel?.state?this._setTimeSliderPosition(t,{forceLightingUpdate:!0}):n.getLogger(this).error("The timeSliderPosition property cannot be set before the view and the widget are ready.")}_setTimeSliderPosition(t,e){Math.abs(t-this.timeSliderPosition)<=1/60||(this.stopPlaying(),this._onUserDateTimeChange(),e.forceLightingUpdate&&(this._cancelLightingUpdate(),this._updateLighting()),this._lightingDateDisplay=S(this._lightingDateDisplay,t))}_timezoneFromCamera(t,e){if(null==e||!t.cameraTrackingEnabled)return 0;const i=D([e.longitude,e.latitude]);return null==i?0:Math.round(i.hours+i.minutes/60+i.seconds/3600)}get directShadowsEnabled(){return this._lighting?.directShadowsEnabled??!1}set directShadowsEnabled(t){const e=this._lighting;e&&(e.directShadowsEnabled=t)}get sunLightingEnabled(){return"sun"===this._lightingType}set sunLightingEnabled(t){const e=this._environment;if(t===this._get("sunLightingEnabled")||null==e)return;const i=e.lighting,n=this._oldLighting;this._oldLighting=i;const s={directShadowsEnabled:i.directShadowsEnabled,cameraTrackingEnabled:i.cameraTrackingEnabled},l=t?"sun":"virtual";let a;a=null!=n&&n.type===l?n:t?new _:new f,a.set(s),e.lighting=a,t||(this.stopPlaying(),this.timeSliderViewModel.timezonePickerOpen=!1)}set playingState(t){this.playingState!==t&&(this._set("playingState",t),"none"!==t&&this.sunLightingEnabled&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._onUserDateTimeChange()))}get dayPlaying(){return"day"===this.playingState}set dayPlaying(t){t?this.playingState="day":this.dayPlaying&&(this.playingState="none")}get yearPlaying(){return"year"===this.playingState}set yearPlaying(t){t?this.playingState="year":this.yearPlaying&&(this.playingState="none")}get currentSeason(){return U(this.localDate,this._currentHemisphere)}set currentSeason(t){this.stopPlaying(),this._onUserDateTimeChange();const e=T(t,this._currentHemisphere);this.localDate=v(this.localDate,e,0)}get _currentHemisphere(){const t=this.view?.camera?.position?.latitude;return null==t||t>=0?0:1}get _environment(){return this.view?.environment}get _lighting(){return this._environment?.lighting}get _lightingType(){return this._lighting?.type}get _lightingDateDisplay(){return c(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,"hours")}set _lightingDateDisplay(t){const e=this._lighting;if(null==e||!this.sunLightingEnabled||"virtual"===e.type||!p(t))return;const i=e.date,n=c(t,-this._cachedDisplayUTCOffset,"hours");n.getTime()!==i.getTime()&&(e.date=n,this._updateLighting())}stopPlaying(){this.playingState="none"}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}onDateChange(t){this.dayPlaying=!1,this.localDate=t,this._onUserDateTimeChange()}_updateLighting(t){const e=Date.now();this._lastLightingUpdate=e;const{view:i}=this,n=this._lighting;if(null==i||null==n||"virtual"===n.type)return;t??=n.date;const s=n.displayUTCOffset,l=null!=s?s:this._timezoneFromCamera(n,i.camera?.position);this._cachedLightingDateUTC.getTime()!==t.getTime()&&(this._cachedLightingDateUTC=new Date(t)),this._cachedDisplayUTCOffset!==l&&(this._cachedDisplayUTCOffset=l)}_timezoneWillChange(t){const e=this._lighting;if(null==e||"virtual"===e.type||!e.cameraTrackingEnabled)return;let i;if(t)i=t.timezoneOffset;else{if(null!=e.displayUTCOffset)return;i=_.calculateTimezoneOffset(e.positionTimezoneInfo)}e.displayUTCOffset=i,this._scheduleLightingUpdate()}_scheduleLightingUpdate(t){if(t&&(this._lightingUpdateHandle=s(this._lightingUpdateHandle),!p(t)))return;if(this._lightingUpdateHandle)return;const e=Date.now()-this._lastLightingUpdate,n=this.lightingUpdateInterval-e;let l=null;const a=()=>{this._updateLighting(t),this._lightingUpdateHandle===l&&(this._lightingUpdateHandle=null)};if(n<=0)this._lightingUpdateHandle=l=g(a);else{const t=setTimeout(a,n);this._lightingUpdateHandle=l=i(()=>clearTimeout(t))}}_cancelLightingUpdate(){this._lightingUpdateHandle=s(this._lightingUpdateHandle)}_play(){const t=this._lighting;if(null==t||!this.sunLightingEnabled||"virtual"===t.type)return;const e=t.date;if(this.dayPlaying||this.yearPlaying){const i=Date.now()-(this._lastTime??0);if(this.dayPlaying){this._lastTime=Date.now();const n=L(this._sunrise,this._sunset,e)*this.playSpeedMultiplier/100*i;if(n>0){let i=new Date(e.getTime()+n);const s=t.displayUTCOffset??0;if(((i.getUTCHours()+s)%24+24)%24<((e.getUTCHours()+s)%24+24)%24){const t=864e5;i=new Date(e.getTime()+n-t)}t.date=i}}else{if(i>1e3){this._lastTime=Date.now();const i=(e.getUTCMonth()+1)%12,n=new Date(e);n.setUTCMonth(i),t.date=n}}requestAnimationFrame(()=>this._play())}}_updateSunriseAndSunset(){const t=this._lighting;if(null==t||"virtual"===t.type||!this.sunLightingEnabled)return;const e=this.view?.camera?.position;if(null==e)return;const{latitude:i,longitude:n}=e,{date:s,displayUTCOffset:l}=t,a=C(s,i,n,l??0);a&&(this._sunrise=new Date(a.sunrise),this._sunset=new Date(a.sunset))}_onUserDateTimeChange(){this.emit("user-date-time-change",{})}};t([y()],O.prototype,"view",void 0),t([y({type:P,nonNullable:!0})],O.prototype,"timeSliderViewModel",void 0),t([y()],O.prototype,"isSupported",null),t([y()],O.prototype,"lightingUpdateInterval",void 0),t([y()],O.prototype,"utcOffset",null),t([y({type:Date})],O.prototype,"localDate",null),t([y()],O.prototype,"timeSliderPosition",null),t([y()],O.prototype,"directShadowsEnabled",null),t([y()],O.prototype,"sunLightingEnabled",null),t([y({type:["none","day","year"],value:"none"})],O.prototype,"playingState",null),t([y()],O.prototype,"dayPlaying",null),t([y()],O.prototype,"yearPlaying",null),t([y()],O.prototype,"playSpeedMultiplier",void 0),t([y()],O.prototype,"currentSeason",null),t([y()],O.prototype,"_lastTime",void 0),t([y()],O.prototype,"_sunrise",void 0),t([y()],O.prototype,"_sunset",void 0),t([y()],O.prototype,"_cachedLightingDateUTC",void 0),t([y()],O.prototype,"_cachedDisplayUTCOffset",void 0),t([y()],O.prototype,"_currentHemisphere",null),t([y()],O.prototype,"_environment",null),t([y()],O.prototype,"_lighting",null),t([y()],O.prototype,"_lightingType",null),t([y()],O.prototype,"_lightingDateDisplay",null),O=t([m("esri.widgets.Daylight.DaylightViewModel")],O);const E=O;export{E 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{timeSinceUTCMidnight as t,makeUTCTime as n}from"../../../core/timeUtils.js";const e={spring:{dayOfMonth:20,month:2},summer:{dayOfMonth:21,month:5},fall:{dayOfMonth:23,month:8},winter:{dayOfMonth:21,month:11}},i=["spring","summer","fall","winter"];function r(t,n,i){const r=u(n,i),{dayOfMonth:m,month:o}=e[r],s=new Date(t.getTime());return s.setMonth(o,m),s}function m(t,n){return u(o(t),n)}function o(t){const n=t.getTime(),e=r(t,"spring",0).getTime(),i=r(t,"summer",0).getTime(),m=r(t,"fall",0).getTime(),o=r(t,"winter",0).getTime();return n>=e&&n<i?"spring":n>=i&&n<m?"summer":n>=m&&n<o?"fall":"winter"}function u(t,n){return 0===n?t:s(t)}function s(t){const n=i.indexOf(t);return i[(n+2)%4]}function f(t,e){return n(t,e,"minutes")}function c(n){return t(n,"minutes")}function g(t,n,e){const i=12e5,r=i/4,m=18e5,o=r/3*2,u=72e5;if(null==t||null==n||isNaN(t.getTime())&&isNaN(n.getTime()))return r;const s=e.getTime(),f=t.getTime(),c=n.getTime(),g=f-u/2,l=f+u/2,a=c-u/3*2,h=c+u/3;let T=r;return s>=g&&s<=l?T=s-g<=i?m-(s-g)/i*(m-o):l-s<=i/2?r-(l-s)/i*2*(r-o):o:s>=a&&s<=h?T=s-a<=i/2?r-(s-a)/i*2*(r-o):h-s<=i?m-(h-s)/i*(m-o):o:(s<f||s>c)&&(T=m),T}export{g as calculatePlaySpeed,c as dateTimeToSliderPos,s as flipSeasonHemisphere,u as getNorthernHemisphereSeason,r as getSeasonDate,m as getSeasonFromDate,i as orderedSeasons,f as sliderPosToDateTime};
5
+ import{timeSinceUTCMidnight as t,makeUTCTime as n}from"../../../core/timeUtils.js";const e={spring:{dayOfMonth:20,month:2},summer:{dayOfMonth:21,month:5},fall:{dayOfMonth:23,month:8},winter:{dayOfMonth:21,month:11}},i=["spring","summer","fall","winter"];function r(t,n,i){const r=u(n,i),{dayOfMonth:o,month:m}=e[r],s=new Date(t);return s.setMonth(m,o),s}function o(t,n){return u(m(t),n)}function m(t){const n=t.getTime(),e=r(t,"spring",0).getTime(),i=r(t,"summer",0).getTime(),o=r(t,"fall",0).getTime(),m=r(t,"winter",0).getTime();return n>=e&&n<i?"spring":n>=i&&n<o?"summer":n>=o&&n<m?"fall":"winter"}function u(t,n){return 0===n?t:s(t)}function s(t){const n=i.indexOf(t);return i[(n+2)%4]}function f(t,e){return n(t,e,"minutes")}function c(n){return t(n,"minutes")}function g(t,n,e){const i=12e5,r=i/4,o=18e5,m=r/3*2,u=72e5;if(null==t||null==n||isNaN(t.getTime())&&isNaN(n.getTime()))return r;const s=e.getTime(),f=t.getTime(),c=n.getTime(),g=f-u/2,l=f+u/2,a=c-u/3*2,h=c+u/3;let T=r;return s>=g&&s<=l?T=s-g<=i?o-(s-g)/i*(o-m):l-s<=i/2?r-(l-s)/i*2*(r-m):m:s>=a&&s<=h?T=s-a<=i/2?r-(s-a)/i*2*(r-m):h-s<=i?o-(h-s)/i*(o-m):m:(s<f||s>c)&&(T=o),T}export{g as calculatePlaySpeed,c as dateTimeToSliderPos,s as flipSeasonHemisphere,u as getNorthernHemisphereSeason,r as getSeasonDate,o as getSeasonFromDate,i as orderedSeasons,f as sliderPosToDateTime};
@@ -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{unique as t,isSome as i}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import s from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import d from"../../core/Logger.js";import{destroyMaybe as p,abortMaybe as c,removeMaybe as u}from"../../core/maybe.js";import{throwIfAborted as h,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as E}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isEditableLayer as T}from"../../layers/support/editableLayers.js";import{isFeatureLayer as V,isSubtypeGroupLayer as S,getOwningPortalUrl as L}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import A from"../../views/SelectionManager.js";import U from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as C}from"../../views/interactive/snapping/SnappingManager.js";import O from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as j}from"../../views/support/selectionUtils.js";import P from"../Attachments/AttachmentsViewModel.js";import R from"./CreateFeaturesWorkflow.js";import H from"./UpdateFeaturesWorkflow.js";import q from"./UpdateWorkflow.js";import{getLayersFromWorkflow as G,isCreateFeaturesWorkflow as x,isUpdateRecordWorkflow as D,isUpdateFeaturesWorkflow as B,isUpdateWorkflow as N,makeMultipleSourceLayersError as Q,whenEditorLayerView as z}from"./workflowUtils.js";import Z from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as $}from"../FeatureTemplates/featureTemplatesUtils.js";import J from"../FeatureTemplates/FeatureTemplatesViewModel.js";import K from"../Sketch/SketchViewModel.js";import X from"../Spinner/SpinnerViewModel.js";import{goTo as Y}from"../support/goToUtils.js";import{isFeatureItem as ee,isLayerItem as te}from"../support/SelectionList/selectionListUtils.js";import ie from"../support/SelectionList/SelectionListViewModel.js";import ae from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function re(e,t){return e?.find(e=>e.layer===t)}let oe=class extends n{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new b({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new F,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new P({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new J({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new K({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new ie,this.selectionManager=new A,this.selectionToolbarViewModel=new ae({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new U,this.snappingOptions=new O({attributeRulesEnabled:!0}),this.spinnerViewModel=new X,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;this._candidateCommitted||"update"!==i?.type||(i.data.rootFeature=e,t&&(i.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,a=i?.filter(e=>!!t?.includes(e.layer));return[t,a,this.layerInfos]},()=>this._updateEditorItems(),g),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),k),m(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),m(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),m(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),y(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this.selectionManager.showHighlight=!e),y(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),k),m(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),f(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),f(()=>this.page,(e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i},g),y(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),m(()=>this.featureTemplatesViewModel,"select",async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const a={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(a);await this.startCreateFeaturesWorkflowAtFeatureCreation(a)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},g),m(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),m(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i="update"===t?.type,a=G(t),r=i?t?.activeWorkflow?.parentLayer??void 0:void 0,o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:a[0],layers:a,parentLayer:r})},v),f(()=>this.view,e=>{if(this._snappingManager=p(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new C({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},g),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},g),m(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),f(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:a})=>{t.view=e,i.view=e,a.view=e},g),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},g)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then(()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null}),this._updateItemsTask=c(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=u(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new r;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new r;for(const t of this.editorItems)j(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return x(e)?e.pendingFeatures.length:D(e)&&e.data.edits.feature?1:B(e)?e.data.features.length:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&N(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some(e=>e.supportsCreateFeaturesWorkflow)}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some(e=>e.supportsUpdateWorkflow)}get canUpdateVisible(){return this.editorItems.some(e=>e.supportsUpdateWorkflow&&e.visible)}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter(e=>"scene"===e.type||!e.isTable)}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:"update-features"===e?.type?e.formViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type||"update-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeLeafWorkflow:e}=this;if(D(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.featureFormViewModel.disabled;if(B(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(D(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!B(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await _(()=>!this.updating),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,a=i?this.findEditorItemForLayer(i):void 0;if(!a?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow({initialFeature:t,layer:a.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",r),await r.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");if(t(e.map(e=>e.sourceLayer??e.layer)).length>1)throw Q();const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateFeaturesWorkflow(e);this._set("activeWorkflow",t),await t.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.rootFeature=e,t.addHandles(m(()=>t,"commit",()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)})),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount)throw new s("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new s("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.visibleFeatureItems.map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}async deleteFeatureFromWorkflow(){o(d.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;return N(e)?e.deleteActiveFeature():B(e)?e.deleteAndCommit():void this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}findEditorItemForLayer(e){return this.editorItems.find(t=>t.layer===e)}itemHasInvalidFormTemplate(e){return null!=e&&!0===this.findEditorItemForLayer(e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:t,sketchViewModel:a}=this;if(!t)return;const r=e??a?.createGraphic;if(r)"mesh"===r.geometry?.type?Y(t,r.geometry):Y(t,r);else{const e=a?.updateGraphics?.toArray();"3d"===t.type&&e?.some(e=>"mesh"===e.geometry?.type)?Y(t,e.map(e=>e.geometry).filter(i)):e&&Y(t,e)}}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){ee(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){if(ee(e))await this.startUpdateWorkflowAtFeatureEdit(e.graphic);else if(te(e)){const t=e.featureItems.filter(e=>e.visible).map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,a=i.editableLayers.toArray(),r=i.allTables.toArray().filter(e=>V(e)||S(e));return await Promise.allSettled([...a.flatMap(e=>this._getLayerLoadPromise(e)),...r.flatMap(e=>this._getLayerLoadPromise(e))]),h(e),[...a.reverse(),...r.reverse()].filter(e=>T(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return S(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){c(this._updateItemsTask);const{view:e}=this,t=a(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const a=[],r=[],o=[],{layerInfos:s}=this;for(const l of i){const t=re(s,l),i=await z(e,l).catch(()=>null);(t?a:i?r:o).push(new Z({layer:l,layerInfo:t,layerView:i}))}s?.length&&a.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...a,...r,...o];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))});this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){c(this._updateTemplatesTask);const e=a(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const a=await E(i.toArray(),this.view,e);for(const{layer:e,templates:i}of a)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const a of e){const e=t.get(a);e&&e.length>0&&i.push($(a,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return R.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow(e){const t=H.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return t.addHandles(m(()=>t,"commit",()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)})),t}_createUpdateWorkflow(e){return q.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_addAttachments(e,t){const i=t.map(t=>this._addAttachment(e,t.feature,t.attachment))??[];return Promise.all(i)}async _addAttachment(e,t,i){let a=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(a=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,a)),a}async _applyEdits(e,t,i){let a=null;const r=e.url?await L(e.url):null,o={returnServiceEditsOption:(!r||!I(r))&&!RegExp("/hosted/","i").test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const r=await z(i,e).catch(()=>null);return a=await e.applyEdits(t,o),r&&await _(()=>!r.updating),a}),a}async _applyEditsFeatureService(e,t,i){let a=null;return await this._queueOperation(async()=>a=await e.applyEdits(t,i)),a}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then(e=>(Array.isArray(e)?e.forEach(e=>this._handleEditsResultError(e)):this._handleEditsResultError(e),e)).catch(i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const a={error:i,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])}).then(()=>{t(e,this._activityQueue)})}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:a}=e,r=t.find(e=>!!e.error)||a.find(e=>!!e.error)||i.find(e=>!!e.error);if(r)throw r.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:a}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,a??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=this.findEditorItemForLayer(e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){d.getLogger(this).error(new s(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:a}=this,r="ready"===this.state,o=1===i.length;if(this._queuedSelectionTool=void 0,r&&o&&(0===a.count&&"add"===t||"replace"===t))return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":a.updateSelection({current:[],added:[],removed:i});break;case"replace":a.clear(),a.updateSelection({current:i,added:[],removed:[]});break;case"add":a.updateSelection({current:i,added:[],removed:[]})}}};e([M()],oe.prototype,"_featureTemplatesLayersAndTables",null),e([M()],oe.prototype,"_queuedSelectionTool",void 0),e([M()],oe.prototype,"_snappingManager",void 0),e([M()],oe.prototype,"_selectionSources",null),e([M()],oe.prototype,"activeFeatureCount",null),e([M({readOnly:!0})],oe.prototype,"activeWorkflow",void 0),e([M()],oe.prototype,"activeLeafWorkflow",null),e([M({readOnly:!0})],oe.prototype,"_activityQueue",void 0),e([M({readOnly:!0})],oe.prototype,"canCreate",null),e([M()],oe.prototype,"canCreateVisible",null),e([M({readOnly:!0})],oe.prototype,"canUpdate",null),e([M()],oe.prototype,"canUpdateVisible",null),e([M()],oe.prototype,"featureTemplatesLayers",null),e([M()],oe.prototype,"editorItems",void 0),e([M()],oe.prototype,"effectiveSelectionManager",null),e([M({readOnly:!0})],oe.prototype,"failures",void 0),e([M()],oe.prototype,"hideTemplatesForInactiveLayers",void 0),e([M({type:P})],oe.prototype,"attachmentsViewModel",void 0),e([M()],oe.prototype,"featureFormViewModel",null),e([M()],oe.prototype,"formViewModel",null),e([M()],oe.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([M({type:J})],oe.prototype,"featureTemplatesViewModel",void 0),e([M()],oe.prototype,"labelOptions",null),e([M()],oe.prototype,"layerInfos",void 0),e([M()],oe.prototype,"ownSketchViewModel",void 0),e([M()],oe.prototype,"selectionListViewModel",void 0),e([M()],oe.prototype,"selectionManager",void 0),e([M()],oe.prototype,"selectionToolbarViewModel",void 0),e([M()],oe.prototype,"sketchOptions",void 0),e([M()],oe.prototype,"sketchViewModel",null),e([M({type:O,nonNullable:!0})],oe.prototype,"snappingOptions",void 0),e([M()],oe.prototype,"spinnerViewModel",void 0),e([M()],oe.prototype,"state",null),e([M({readOnly:!0})],oe.prototype,"syncing",null),e([M()],oe.prototype,"updating",null),e([M()],oe.prototype,"tooltipOptions",null),e([M()],oe.prototype,"valueOptions",null),e([M()],oe.prototype,"view",null),e([M()],oe.prototype,"canZoomTo",null),e([M()],oe.prototype,"pageStack",void 0),e([M()],oe.prototype,"showDiscardEditsPrompt",void 0),e([M()],oe.prototype,"_candidateCommitted",void 0),e([M()],oe.prototype,"page",null),e([M()],oe.prototype,"featureFormDisabled",null),e([M()],oe.prototype,"featureFormHasAssociation",null),e([M()],oe.prototype,"canGoBack",null),e([M()],oe.prototype,"shouldShowDeleteButton",null),e([M()],oe.prototype,"hasPendingEdits",null),e([M()],oe.prototype,"snappingManager",null),oe=e([W("esri.widgets.Editor.EditorViewModel")],oe);const se=oe;export{se as default};
5
+ import{__decorate as e}from"tslib";import{unique as t,isSome as i}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import s from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import d from"../../core/Logger.js";import{destroyMaybe as p,abortMaybe as c,removeMaybe as u}from"../../core/maybe.js";import{throwIfAborted as h,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as b}from"../../editing/templateUtils.js";import E from"../../layers/GraphicsLayer.js";import{isEditableLayer as T}from"../../layers/support/editableLayers.js";import{isFeatureLayer as V,isSubtypeGroupLayer as S,getOwningPortalUrl as L}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import A from"../../views/SelectionManager.js";import U from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as C}from"../../views/interactive/snapping/SnappingManager.js";import O from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as j}from"../../views/support/selectionUtils.js";import P from"../Attachments/AttachmentsViewModel.js";import R from"./CreateFeaturesWorkflow.js";import H from"./UpdateFeaturesWorkflow.js";import q from"./UpdateWorkflow.js";import{getLayersFromWorkflow as G,isCreateFeaturesWorkflow as x,isUpdateRecordWorkflow as D,isUpdateFeaturesWorkflow as B,isUpdateWorkflow as N,makeMultipleSourceLayersError as Q,whenEditorLayerView as z}from"./workflowUtils.js";import Z from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as $}from"../FeatureTemplates/featureTemplatesUtils.js";import J from"../FeatureTemplates/FeatureTemplatesViewModel.js";import K from"../Sketch/SketchViewModel.js";import X from"../Spinner/SpinnerViewModel.js";import{goTo as Y}from"../support/goToUtils.js";import{isFeatureItem as ee,isLayerItem as te}from"../support/SelectionList/selectionListUtils.js";import ie from"../support/SelectionList/SelectionListViewModel.js";import ae from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function re(e,t){return e?.find(e=>e.layer===t)}let oe=class extends n{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new E({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new F,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new P({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new J({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new K({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new ie,this.selectionManager=new A,this.selectionToolbarViewModel=new ae({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new U,this.snappingOptions=new O({attributeRulesEnabled:!0}),this.spinnerViewModel=new X,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;this._candidateCommitted||"update"!==i?.type||(i.data.rootFeature=e,t&&(i.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,a=i?.filter(e=>!!t?.includes(e.layer));return[t,a,this.layerInfos]},()=>this._updateEditorItems(),g),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),k),m(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),m(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),m(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),y(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this.selectionManager.showHighlight=!e),y(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),k),m(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),f(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),f(()=>this.page,(e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i},g),y(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),m(()=>this.featureTemplatesViewModel,"select",async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const a={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(a);await this.startCreateFeaturesWorkflowAtFeatureCreation(a)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},g),m(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),m(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i="update"===t?.type,a=G(t),r=i?t?.activeWorkflow?.parentLayer??void 0:void 0,o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:a[0],layers:a,parentLayer:r})},v),f(()=>this.view,e=>{if(this._snappingManager=p(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new C({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},g),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},g),m(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),f(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:a})=>{t.view=e,i.view=e,a.view=e},g),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},g)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then(()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null}),this._updateItemsTask=c(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=u(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new r;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new r;for(const t of this.editorItems)j(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return x(e)?e.pendingFeatures.length:D(e)&&e.data.edits.feature?1:B(e)?e.data.features.length:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&N(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some(e=>e.supportsCreateFeaturesWorkflow)}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some(e=>e.supportsUpdateWorkflow)}get canUpdateVisible(){return this.editorItems.some(e=>e.supportsUpdateWorkflow&&e.visible)}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter(e=>"scene"===e.type||!e.isTable)}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:"update-features"===e?.type?e.formViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type||"update-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeLeafWorkflow:e}=this;if(D(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.featureFormViewModel.disabled;if(B(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(D(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!B(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await _(()=>!this.updating),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,a=i?this.findEditorItemForLayer(i):void 0;if(!a?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow({initialFeature:t,layer:a.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",r),await r.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");if(t(e.map(e=>e.sourceLayer??e.layer)).length>1)throw Q();const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateFeaturesWorkflow(e);this._set("activeWorkflow",t),await t.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.rootFeature=e,t.addHandles(m(()=>t,"commit",()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)})),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount)throw new s("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new s("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.visibleFeatureItems.map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}async deleteFeatureFromWorkflow(){o(d.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;return N(e)?e.deleteActiveFeature():B(e)?e.deleteAndCommit():void this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}findEditorItemForLayer(e){return this.editorItems.find(t=>t.layer===e)}itemHasInvalidFormTemplate(e){return null!=e&&!0===this.findEditorItemForLayer(e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:t,sketchViewModel:a}=this;if(!t)return;const r=e??a?.createGraphic;if(r)"mesh"===r.geometry?.type?Y(t,r.geometry):Y(t,r);else{const e=a?.updateGraphics?.toArray();"3d"===t.type&&e?.some(e=>"mesh"===e.geometry?.type)?Y(t,e.map(e=>e.geometry).filter(i)):e&&Y(t,e)}}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){ee(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){if(ee(e))await this.startUpdateWorkflowAtFeatureEdit(e.graphic);else if(te(e)){const t=e.featureItems.filter(e=>e.visible).map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,a=i.editableLayers.toArray(),r=i.allTables.toArray().filter(e=>V(e)||S(e));return await Promise.allSettled([...a.flatMap(e=>this._getLayerLoadPromise(e)),...r.flatMap(e=>this._getLayerLoadPromise(e))]),h(e),[...a.reverse(),...r.reverse()].filter(e=>T(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return S(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){c(this._updateItemsTask);const{view:e}=this,t=a(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const a=[],r=[],o=[],{layerInfos:s}=this;for(const l of i){const t=re(s,l),i=await z(e,l).catch(()=>null);(t?a:i?r:o).push(new Z({layer:l,layerInfo:t,layerView:i}))}s?.length&&a.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...a,...r,...o];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))});this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){c(this._updateTemplatesTask);const e=a(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const a=await b(i.toArray(),this.view,e);for(const{layer:e,templates:i}of a)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const a of e){const e=t.get(a);e&&e.length>0&&i.push($(a,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return R.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow(e){const t=H.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return t.addHandles(m(()=>t,"commit",()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)})),t}_createUpdateWorkflow(e){return q.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_addAttachments(e,t){const i=t.map(t=>this._addAttachment(e,t.feature,t.attachment))??[];return Promise.all(i)}async _addAttachment(e,t,i){let a=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(a=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,a)),a}async _applyEdits(e,t,i){let a=null;const r=e.url?await L(e.url):null,o={returnServiceEditsOption:(!r||!I(r))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const r=await z(i,e).catch(()=>null);return a=await e.applyEdits(t,o),r&&await _(()=>!r.updating),a}),a}async _applyEditsFeatureService(e,t,i){let a=null;return await this._queueOperation(async()=>a=await e.applyEdits(t,i)),a}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then(e=>(Array.isArray(e)?e.forEach(e=>this._handleEditsResultError(e)):this._handleEditsResultError(e),e)).catch(i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const a={error:i,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])}).then(()=>{t(e,this._activityQueue)})}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:a}=e,r=t.find(e=>!!e.error)||a.find(e=>!!e.error)||i.find(e=>!!e.error);if(r)throw r.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:a}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,a??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=this.findEditorItemForLayer(e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){d.getLogger(this).error(new s(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:a}=this,r="ready"===this.state,o=1===i.length;if(this._queuedSelectionTool=void 0,r&&o&&(0===a.count&&"add"===t||"replace"===t))return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":a.updateSelection({current:[],added:[],removed:i});break;case"replace":a.clear(),a.updateSelection({current:i,added:[],removed:[]});break;case"add":a.updateSelection({current:i,added:[],removed:[]})}}};e([M()],oe.prototype,"_featureTemplatesLayersAndTables",null),e([M()],oe.prototype,"_queuedSelectionTool",void 0),e([M()],oe.prototype,"_snappingManager",void 0),e([M()],oe.prototype,"_selectionSources",null),e([M()],oe.prototype,"activeFeatureCount",null),e([M({readOnly:!0})],oe.prototype,"activeWorkflow",void 0),e([M()],oe.prototype,"activeLeafWorkflow",null),e([M({readOnly:!0})],oe.prototype,"_activityQueue",void 0),e([M({readOnly:!0})],oe.prototype,"canCreate",null),e([M()],oe.prototype,"canCreateVisible",null),e([M({readOnly:!0})],oe.prototype,"canUpdate",null),e([M()],oe.prototype,"canUpdateVisible",null),e([M()],oe.prototype,"featureTemplatesLayers",null),e([M()],oe.prototype,"editorItems",void 0),e([M()],oe.prototype,"effectiveSelectionManager",null),e([M({readOnly:!0})],oe.prototype,"failures",void 0),e([M()],oe.prototype,"hideTemplatesForInactiveLayers",void 0),e([M({type:P})],oe.prototype,"attachmentsViewModel",void 0),e([M()],oe.prototype,"featureFormViewModel",null),e([M()],oe.prototype,"formViewModel",null),e([M()],oe.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([M({type:J})],oe.prototype,"featureTemplatesViewModel",void 0),e([M()],oe.prototype,"labelOptions",null),e([M()],oe.prototype,"layerInfos",void 0),e([M()],oe.prototype,"ownSketchViewModel",void 0),e([M()],oe.prototype,"selectionListViewModel",void 0),e([M()],oe.prototype,"selectionManager",void 0),e([M()],oe.prototype,"selectionToolbarViewModel",void 0),e([M()],oe.prototype,"sketchOptions",void 0),e([M()],oe.prototype,"sketchViewModel",null),e([M({type:O,nonNullable:!0})],oe.prototype,"snappingOptions",void 0),e([M()],oe.prototype,"spinnerViewModel",void 0),e([M()],oe.prototype,"state",null),e([M({readOnly:!0})],oe.prototype,"syncing",null),e([M()],oe.prototype,"updating",null),e([M()],oe.prototype,"tooltipOptions",null),e([M()],oe.prototype,"valueOptions",null),e([M()],oe.prototype,"view",null),e([M()],oe.prototype,"canZoomTo",null),e([M()],oe.prototype,"pageStack",void 0),e([M()],oe.prototype,"showDiscardEditsPrompt",void 0),e([M()],oe.prototype,"_candidateCommitted",void 0),e([M()],oe.prototype,"page",null),e([M()],oe.prototype,"featureFormDisabled",null),e([M()],oe.prototype,"featureFormHasAssociation",null),e([M()],oe.prototype,"canGoBack",null),e([M()],oe.prototype,"shouldShowDeleteButton",null),e([M()],oe.prototype,"hasPendingEdits",null),e([M()],oe.prototype,"snappingManager",null),oe=e([W("esri.widgets.Editor.EditorViewModel")],oe);const se=oe;export{se 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{isSome as i}from"../../../core/arrayUtils.js";import s from"../../../core/Error.js";import{abortHandle as r}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import{whenOnce as o,watch as n}from"../../../core/reactiveUtils.js";import{first as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../core/support/UpdatingHandles.js";import d from"../../../layers/GraphicsLayer.js";import u from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as y,updateGraphicSymbolWhenRequired as m,setVisualVariablesAndElevationInfoForUpdate as w,swapForEditingSession as g,visualVariableInteractiveUpdate as f,getSizeVariableAttribute as v,getRotationVariableAttribute as _}from"../workflowUtils.js";import b from"../../Sketch/SketchViewModel.js";const k=Symbol();let L=class extends t{constructor(e){super(e),this.features=[],this.sketchOptions=new u,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this._sketchGraphics=new Map,this._sketchLayer=null,this._updatingHandles=new h,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=y(this.sourceLayer),this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),e.destroy(),this.viewModel.destroy()}get updating(){return this._updatingHandles.updating}async enter(){throw new Error("enter() not implemented")}async exit(){throw new Error("exit() not implemented")}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale,r=this._updatingHandles;for(const a of e){const e=this._sketchGraphics.get(a),o=a.getAttribute(t);if(!e||e.getAttribute(t)===o)continue;e.setAttribute(t,o);const n=this._visualVariableAttributes.get(a);null==n?.size||n.size.isUpdatingInteractively||n.size.field!==t||n.size.setInitialValue(o),null==n?.rotation||n.rotation.isUpdatingInteractively||n.rotation.field!==t||n.rotation.setInitialValue(o),r.addPromise(m(e,i,s))}}async startUpdatingFeatures(e,t,s){const{_sketchGraphics:a,sourceLayer:n,view:l,viewModel:c,_webStyleCache:p}=this,h=e.map(e=>a.get(e)).filter(i),d={};this.removeHandles(k),c.complete();let u=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(await w({sketchViewModel:c,graphic:h[0],sourceLayer:n,visualVariables:i,webStyleCache:p}),"point"===n.geometryType&&(d.enableRotation=null!=i.rotation,d.enableScaling=null!=i.size,u=async e=>{const r=e.graphics[0];f(l,r,e,i)&&(s?.([{feature:t,attributes:r.attributes}],e),this._updatingHandles.addPromise(m(r,p,"2d"===l.type?l.scale:null)))}))}else d.tool="move";const y=()=>c.update(h,d),g=c.on("update",s=>{if("complete"===s.state){if(null===l.activeTool)return void y();const e=new AbortController,t=r(e);return this.addHandles(t,k),void this._updatingHandles.addPromise(o(()=>null===l.activeTool,e.signal).then(async()=>{e.signal.aborted||(e.abort(),await y())}))}const n=e.map(e=>{const t=a.get(e);return t?{feature:e,geometry:t.geometry}:null}).filter(i);t(n,s),u?.(s)});await y(),this.addHandles(g,k),c.addHandles(g)}_initializeSketchGraphics(){const{features:e,_sketchGraphics:t,sourceLayer:i,_visualVariableAttributes:s}=this,r=this._visualVariablesForLayer,a=r.rotation?.field,o=r.size?.field,n={rotation:a?i.getField(a):null,size:o?i.getField(o):null},l=!(!n.rotation&&!n.size);for(const c of e)t.set(c,c.clone()),l&&s.set(c,z(r,n))}_initializeSketchLayer(){const{view:e}=this,t=new d({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide",title:"SketchController layer"});this._sketchLayer=t,e.map.add(t),this._updatingHandles.addPromise(e.whenLayerView(t))}async _initializeSketchViewModel(){const{_sketchGraphics:e,view:t,_webStyleCache:i}=this,s=Array.from(e.entries()),r=new b({allowDeleteKey:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},layer:this._sketchLayer,sketchOptions:this.sketchOptions,snappingManager:this.snappingManager,updateOnGraphicClick:!1,view:this.view});this.viewModel=r;const o=a(e=>Promise.all(s.map(([,t])=>m(t,i,e))));await o("2d"===t.type?t.scale:null),"2d"===t.type&&this.addHandles(n(()=>t.scale,e=>o(e))),this.addHandles(await Promise.all(s.map(([e,t])=>g(r,e,t))))}};function S({features:e,sketchOptions:t,snappingManager:i,view:r}){const a=new Set(e.map(e=>e.sourceLayer));if(1!==a.size)throw new s("editor:features-must-belong-to-same-layer","All features must belong to the same layer.");const o=l(a);return new L({view:r,features:e,sketchOptions:t,snappingManager:i,sourceLayer:o})}function z({rotation:e,size:t},i){return{rotation:e?_(e,i.rotation):null,size:t?v(t,i.size):null}}e([c()],L.prototype,"features",void 0),e([c()],L.prototype,"sketchOptions",void 0),e([c()],L.prototype,"snappingManager",void 0),e([c()],L.prototype,"sourceLayer",void 0),e([c()],L.prototype,"updating",null),e([c()],L.prototype,"view",void 0),e([c()],L.prototype,"viewModel",void 0),e([c()],L.prototype,"_sketchGraphics",void 0),e([c()],L.prototype,"_sketchLayer",void 0),e([c()],L.prototype,"_visualVariablesForLayer",void 0),L=e([p("esri.widgets.Editor.support.SketchController")],L);export{L as SketchController,S as createSketchController};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import{abortHandle as s}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import{whenOnce as r,watch as o}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../../core/support/UpdatingHandles.js";import p from"../../../layers/GraphicsLayer.js";import d from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as h,updateGraphicSymbolWhenRequired as u,setVisualVariablesAndElevationInfoForUpdate as y,swapForEditingSession as m,visualVariableInteractiveUpdate as w,getSizeVariableAttribute as v,getRotationVariableAttribute as g}from"../workflowUtils.js";import f from"../../Sketch/SketchViewModel.js";const _=Symbol();let b=class extends t{constructor(e){super(e),this.features=[],this.sketchOptions=new d,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this._sketchGraphics=new Map,this._sketchLayer=null,this._updatingHandles=new c,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=h(this.sourceLayer),this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),e.destroy(),this.viewModel.destroy()}get updating(){return this._updatingHandles.updating}async enter(){throw new Error("enter() not implemented")}async exit(){throw new Error("exit() not implemented")}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale,a=this._updatingHandles;for(const r of e){const e=this._sketchGraphics.get(r),o=r.getAttribute(t);if(!e||e.getAttribute(t)===o)continue;e.setAttribute(t,o);const n=this._visualVariableAttributes.get(r);null==n?.size||n.size.isUpdatingInteractively||n.size.field!==t||n.size.setInitialValue(o),null==n?.rotation||n.rotation.isUpdatingInteractively||n.rotation.field!==t||n.rotation.setInitialValue(o),a.addPromise(u(e,i,s))}}async startUpdatingFeatures(e,t,a){const{_sketchGraphics:o,sourceLayer:n,view:l,viewModel:c,_webStyleCache:p}=this,d=e.map(e=>o.get(e)).filter(i),h={};this.removeHandles(_),c.complete();let m=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(await y({sketchViewModel:c,graphic:d[0],sourceLayer:n,visualVariables:i,webStyleCache:p}),"point"===n.geometryType&&(h.enableRotation=null!=i.rotation,h.enableScaling=null!=i.size,m=async e=>{const s=e.graphics[0];w(l,s,e,i)&&(a?.([{feature:t,attributes:s.attributes}],e),this._updatingHandles.addPromise(u(s,p,"2d"===l.type?l.scale:null)))}))}else h.tool="move";const v=()=>c.update(d,h),g=c.on("update",a=>{if("complete"===a.state){if(null===l.activeTool)return void v();const e=new AbortController,t=s(e);return this.addHandles(t,_),void this._updatingHandles.addPromise(r(()=>null===l.activeTool,e.signal).then(async()=>{e.signal.aborted||(e.abort(),await v())}))}const n=e.map(e=>{const t=o.get(e);return t?{feature:e,geometry:t.geometry}:null}).filter(i);t(n,a),m?.(a)});await v(),this.addHandles(g,_),c.addHandles(g)}_initializeSketchGraphics(){const{features:e,_sketchGraphics:t,sourceLayer:i,_visualVariableAttributes:s}=this,a=this._visualVariablesForLayer,r=a.rotation?.field,o=a.size?.field,n={rotation:r?i.getField(r):null,size:o?i.getField(o):null},l=!(!n.rotation&&!n.size);for(const c of e)t.set(c,c.clone()),l&&s.set(c,k(a,n))}_initializeSketchLayer(){const{view:e}=this,t=new p({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide",title:"SketchController layer"});this._sketchLayer=t,e.map.add(t),this._updatingHandles.addPromise(e.whenLayerView(t))}async _initializeSketchViewModel(){const{_sketchGraphics:e,view:t,_webStyleCache:i}=this,s=Array.from(e.entries()),r=new f({allowDeleteKey:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},layer:this._sketchLayer,sketchOptions:this.sketchOptions,snappingManager:this.snappingManager,updateOnGraphicClick:!1,view:this.view});this.viewModel=r;const n=a(e=>Promise.all(s.map(([,t])=>u(t,i,e))));await n("2d"===t.type?t.scale:null),"2d"===t.type&&this.addHandles(o(()=>t.scale,e=>n(e))),this.addHandles(await Promise.all(s.map(([e,t])=>m(r,e,t))))}};function k({rotation:e,size:t},i){return{rotation:e?g(e,i.rotation):null,size:t?v(t,i.size):null}}e([n()],b.prototype,"features",void 0),e([n()],b.prototype,"sketchOptions",void 0),e([n()],b.prototype,"snappingManager",void 0),e([n()],b.prototype,"sourceLayer",void 0),e([n()],b.prototype,"updating",null),e([n()],b.prototype,"view",void 0),e([n()],b.prototype,"viewModel",void 0),e([n()],b.prototype,"_sketchGraphics",void 0),e([n()],b.prototype,"_sketchLayer",void 0),e([n()],b.prototype,"_visualVariablesForLayer",void 0),b=e([l("esri.widgets.Editor.support.SketchController")],b);export{b as SketchController};