@arcgis/core 4.33.0-next.20250205 → 4.33.0-next.20250207

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 (205) hide show
  1. package/arcade.js +1 -1
  2. package/assets/components/assets/icon/dualImageArea16.json +1 -0
  3. package/assets/components/assets/icon/dualImageArea24.json +1 -0
  4. package/assets/components/assets/icon/dualImageArea32.json +1 -0
  5. package/assets/components/assets/icon/dualImageDistance16.json +1 -0
  6. package/assets/components/assets/icon/dualImageDistance24.json +1 -0
  7. package/assets/components/assets/icon/dualImageDistance32.json +1 -0
  8. package/assets/components/assets/icon/dualImageLocation16.json +1 -0
  9. package/assets/components/assets/icon/dualImageLocation24.json +1 -0
  10. package/assets/components/assets/icon/dualImageLocation32.json +1 -0
  11. package/assets/esri/core/workers/RemoteClient.js +1 -1
  12. package/assets/esri/core/workers/chunks/{24a86c52c8bdd0b5eb4d.js → 09a99c556089c166d1f8.js} +1 -1
  13. package/assets/esri/core/workers/chunks/0a8e388e96af44deeabb.js +1 -0
  14. package/assets/esri/core/workers/chunks/12d6baeffd55a98a7c75.js +1 -0
  15. package/assets/esri/core/workers/chunks/143a193fa3a6e645c8ac.js +1 -0
  16. package/assets/esri/core/workers/chunks/{9b4f471fcd8a3b5e089f.js → 192569dfa7c0ea8dd864.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{ad215219e5eef8598745.js → 28dbbfc44cc2bdcd221d.js} +1 -1
  18. package/assets/esri/core/workers/chunks/308ec51ff4a66f7fcb0d.js.LICENSE.txt +1 -1
  19. package/assets/esri/core/workers/chunks/{72cf9192292e5c85c6df.js → 32d3657dcae89b740f8b.js} +2 -2
  20. package/assets/esri/core/workers/chunks/{72cf9192292e5c85c6df.js.LICENSE.txt → 32d3657dcae89b740f8b.js.LICENSE.txt} +1 -1
  21. package/assets/esri/core/workers/chunks/333091ab2e267652ed56.js +1 -0
  22. package/assets/esri/core/workers/chunks/354531dc2f0dea2ad96f.js.LICENSE.txt +1 -1
  23. package/assets/esri/core/workers/chunks/35e4af82a08b4eadbfab.js +1 -0
  24. package/assets/esri/core/workers/chunks/369a2b8484a8807bde38.js +1 -0
  25. package/assets/esri/core/workers/chunks/4040158835f9036967cd.js +2 -0
  26. package/assets/esri/core/workers/chunks/{1a2e1a414e651e988435.js.LICENSE.txt → 4040158835f9036967cd.js.LICENSE.txt} +1 -6
  27. package/assets/esri/core/workers/chunks/{8a1e4f65fc81aba7a704.js → 4122d10bc910e888eee1.js} +1 -1
  28. package/assets/esri/core/workers/chunks/433576983754f690bcc7.js +1 -0
  29. package/assets/esri/core/workers/chunks/459af0c3d62c3ed11c19.js +1 -0
  30. package/assets/esri/core/workers/chunks/53810519ff5922b42cd2.js +1 -0
  31. package/assets/esri/core/workers/chunks/5721557a1d8eab23a55b.js +1 -0
  32. package/assets/esri/core/workers/chunks/594d923400fd74881833.js +1 -0
  33. package/assets/esri/core/workers/chunks/{7a0415db78c68d31733f.js → 6039da57a2adedd3b83f.js} +1 -1
  34. package/assets/esri/core/workers/chunks/62a1d60ad4bf6469c4dd.js +1 -0
  35. package/assets/esri/core/workers/chunks/{81aa8cc289fd02ca4da6.js → 7058001bf66f9f3d5d45.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{e8ae8a11d8439e2a66ad.js → 706f867a9034d62a8ef7.js} +1 -1
  37. package/assets/esri/core/workers/chunks/73d03c208242778e67bf.js +1 -0
  38. package/assets/esri/core/workers/chunks/77764ca90bdd13ee2167.js.LICENSE.txt +1 -1
  39. package/assets/esri/core/workers/chunks/{1ab83753d9eec0463461.js → 7b367bb0ed9c218ca595.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{723a9fba144e2fa6d017.js → 7cb09e58bcc537ec1f7a.js} +1 -1
  41. package/assets/esri/core/workers/chunks/8191dd3d7451b2e7b95e.js +1 -0
  42. package/assets/esri/core/workers/chunks/842db06ce62758fab1e7.js +1 -0
  43. package/assets/esri/core/workers/chunks/8c32cee395da0a7b9a8e.js +1 -0
  44. package/assets/esri/core/workers/chunks/8d8f5f08d730270e1165.js +1 -0
  45. package/assets/esri/core/workers/chunks/94225d92afbdb10dfedb.js +1 -0
  46. package/assets/esri/core/workers/chunks/94490937dca566fe2640.js +1 -0
  47. package/assets/esri/core/workers/chunks/{b9ce0049e27a3e1ed9f9.js → 9b2fab133786e5d47631.js} +1 -1
  48. package/assets/esri/core/workers/chunks/9d61590c4d21c7421925.js +1 -0
  49. package/assets/esri/core/workers/chunks/{610b33b7291cffcc4e5d.js → a42ae5d5e5f66d120b4d.js} +1 -1
  50. package/assets/esri/core/workers/chunks/a5e9ea13e844a62b2a7f.js +1 -0
  51. package/assets/esri/core/workers/chunks/b21b152fa15896577242.js.LICENSE.txt +1 -1
  52. package/assets/esri/core/workers/chunks/b43d88b6e7dc4ab13599.js +1 -0
  53. package/assets/esri/core/workers/chunks/{6d5bfcc7856cafe7b043.js → b765670b47d209d7655a.js} +2 -2
  54. package/assets/esri/core/workers/chunks/{6d5bfcc7856cafe7b043.js.LICENSE.txt → b765670b47d209d7655a.js.LICENSE.txt} +1 -1
  55. package/assets/esri/core/workers/chunks/d29c3bf29fcd7fa31f1a.js +1 -0
  56. package/assets/esri/core/workers/chunks/d339dee99c4820b63f39.js +1 -0
  57. package/assets/esri/core/workers/chunks/{9c5c6ecaf5be24279fa5.js → ddc30044f61a2c2df3fe.js} +1 -1
  58. package/assets/esri/core/workers/chunks/de1f3c4b8000c2d73013.js +1 -0
  59. package/assets/esri/core/workers/chunks/e4b3f2d5c43518b0cde7.js +1 -0
  60. package/assets/esri/core/workers/chunks/e5e3b6d00d27b5bb354f.js +1 -0
  61. package/assets/esri/core/workers/chunks/ef6279f5c63ab1e88c71.js +1 -0
  62. package/assets/esri/core/workers/chunks/{0711d3ad4d403bcfdcad.js → f117a89d1f4001a1f9f0.js} +1 -1
  63. package/assets/esri/core/workers/chunks/f14b318bab5efcf43419.js +1 -0
  64. package/assets/esri/core/workers/chunks/f32ca4381e804cc3481e.js +1 -0
  65. package/assets/esri/core/workers/chunks/f9070edd8e0b2a57af79.js +1 -0
  66. package/assets/esri/core/workers/chunks/f9e48205178a5a804d38.js +1 -0
  67. package/assets/esri/themes/base/widgets/_Directions.scss +15 -6
  68. package/assets/esri/themes/base/widgets/_ItemList.scss +6 -0
  69. package/assets/esri/themes/dark/main.css +1 -1
  70. package/assets/esri/themes/light/main.css +1 -1
  71. package/assets/esri/themes/light/view.css +1 -1
  72. package/chunks/WaterSurface.glsl.js +2 -2
  73. package/geometry/operators/projectOperator.js +1 -1
  74. package/geometry/operators/shapePreservingProjectOperator.js +1 -1
  75. package/geometry/support/meshUtils/elevation.js +1 -1
  76. package/interfaces.d.ts +121 -84
  77. package/layers/FeatureLayer.js +1 -1
  78. package/layers/Layer.js +1 -1
  79. package/layers/SubtypeGroupLayer.js +1 -1
  80. package/layers/WCSLayer.js +1 -1
  81. package/layers/graphics/data/FeatureStore.js +1 -1
  82. package/layers/graphics/data/QueryEngineCapabilities.js +1 -1
  83. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  84. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  85. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  86. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  87. package/layers/graphics/sources/support/sourceUtils.js +1 -1
  88. package/layers/mixins/BlendLayer.js +1 -1
  89. package/layers/mixins/FeatureLayerBase.js +1 -1
  90. package/layers/mixins/OperationalLayer.js +1 -1
  91. package/layers/mixins/operationalLayerModuleMap.js +1 -1
  92. package/layers/ogc/wcsUtils.js +1 -1
  93. package/layers/support/RasterFunctionTemplate.js +1 -1
  94. package/layers/support/SubtypeSublayer.js +1 -1
  95. package/layers/support/arcadeUtils.js +1 -1
  96. package/layers/support/commonProperties.js +1 -1
  97. package/layers/support/layersCreator.js +1 -1
  98. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  99. package/layers/support/rasterDatasets/multipartParser.js +1 -1
  100. package/layers/support/rasterDatasets/wcsCapabilitiesParser.js +1 -1
  101. package/layers/support/rasterFunctionUtils.d.ts +2 -1
  102. package/layers/support/rasterFunctionUtils.js +1 -1
  103. package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +1 -1
  104. package/package.json +2 -2
  105. package/portal/support/layersLoader.js +1 -1
  106. package/portal/support/loadUtils.js +1 -1
  107. package/rest/imageService.js +1 -1
  108. package/rest/support/ImageSampleParameters.js +1 -1
  109. package/rest/support/ImageSampleResult.js +1 -1
  110. package/rest/support/ImageVolumeResult.js +1 -1
  111. package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
  112. package/smartMapping/support/adapters/support/histogramUtils.js +1 -1
  113. package/support/TablesMixin.js +1 -1
  114. package/support/revision.js +1 -1
  115. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  116. package/symbols/cim/cimAnalyzer.js +1 -1
  117. package/symbols/cim/fitVectorMarker.js +5 -0
  118. package/symbols/support/previewCIMSymbol.js +1 -1
  119. package/views/2d/engine/webgl/TextureManager.js +1 -1
  120. package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapResources.js +1 -1
  121. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  122. package/views/2d/layers/GraphicsLayerView2D.js +1 -1
  123. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  124. package/views/2d/layers/LayerView2D.js +1 -1
  125. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  126. package/views/2d/layers/TileLayerView2D.js +1 -1
  127. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  128. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  129. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  130. package/views/2d/layers/features/sources/strategies/DrillDownTileLoadStrategy.js +1 -1
  131. package/views/2d/layers/features/sources/strategies/PagedTileLoadStrategy.js +1 -1
  132. package/views/2d/layers/features/sources/strategies/ParquetLoadStrategy.js +1 -1
  133. package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +1 -1
  134. package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
  135. package/views/2d/layers/graphics/HighlightGraphicContainer.js +1 -1
  136. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  137. package/views/2d/layers/support/util.js +1 -1
  138. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  139. package/views/3d/layers/MediaLayerView3D.js +1 -1
  140. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  141. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  142. package/views/3d/terrain/OverlayManager.js +1 -1
  143. package/views/3d/terrain/OverlayRenderer.js +1 -1
  144. package/views/3d/terrain/TerrainSurface.js +1 -1
  145. package/views/3d/webgl-engine/Stage.js +1 -1
  146. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  147. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  148. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  149. package/views/LayerViewManager.js +1 -1
  150. package/views/SceneView.js +1 -1
  151. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  152. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileCache.js +1 -1
  153. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
  154. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  155. package/views/layers/support/MapServiceLayerViewHelper.js +1 -1
  156. package/widgets/Directions.js +1 -1
  157. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  158. package/widgets/Editor/EditorViewModel.js +1 -1
  159. package/widgets/Editor/UpdateWorkflow.js +1 -1
  160. package/widgets/Editor/VisibleElements.js +1 -1
  161. package/widgets/Editor/components/FeatureList.js +1 -1
  162. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  163. package/widgets/Editor/support/EditorItem.js +1 -1
  164. package/widgets/Editor/workflowUtils.js +1 -1
  165. package/widgets/Editor.js +1 -1
  166. package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
  167. package/widgets/Feature/FeatureViewModel.js +1 -1
  168. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  169. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  170. package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
  171. package/widgets/Sketch.js +1 -1
  172. package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
  173. package/assets/esri/core/workers/chunks/07bff9e742f3e5877f3f.js +0 -1
  174. package/assets/esri/core/workers/chunks/1a2e1a414e651e988435.js +0 -2
  175. package/assets/esri/core/workers/chunks/287362f9af132fafe4de.js +0 -1
  176. package/assets/esri/core/workers/chunks/2ea5e5e6c4660a06b516.js +0 -1
  177. package/assets/esri/core/workers/chunks/380d37ceb8cf52bad190.js +0 -1
  178. package/assets/esri/core/workers/chunks/3984bf01f055fc42bfbf.js +0 -1
  179. package/assets/esri/core/workers/chunks/39e38aab86dcee3f79be.js +0 -1
  180. package/assets/esri/core/workers/chunks/41cd1a5c99ab3bbd1fb4.js +0 -1
  181. package/assets/esri/core/workers/chunks/5e7f16b312077ca8c18d.js +0 -1
  182. package/assets/esri/core/workers/chunks/69d307758262e5d7a32e.js +0 -1
  183. package/assets/esri/core/workers/chunks/6ef2514a6b7bbfb8e37d.js +0 -1
  184. package/assets/esri/core/workers/chunks/7e4d72279cc599b7029c.js +0 -1
  185. package/assets/esri/core/workers/chunks/82d26884127ed772cc4b.js +0 -1
  186. package/assets/esri/core/workers/chunks/8438fba57e82e4cc7c11.js +0 -1
  187. package/assets/esri/core/workers/chunks/858b191c078d04232342.js +0 -1
  188. package/assets/esri/core/workers/chunks/918bdba41fa470cf77fd.js +0 -1
  189. package/assets/esri/core/workers/chunks/91d2bdfa6e34c10b7f50.js +0 -1
  190. package/assets/esri/core/workers/chunks/92155d112ebb6a4c6c6e.js +0 -1
  191. package/assets/esri/core/workers/chunks/991e0f619f1f81f94d56.js +0 -1
  192. package/assets/esri/core/workers/chunks/9a27824d94df702e6e28.js +0 -1
  193. package/assets/esri/core/workers/chunks/b1269b51cef3e11c85e3.js +0 -1
  194. package/assets/esri/core/workers/chunks/b33122adfd1fb68f7c0f.js +0 -1
  195. package/assets/esri/core/workers/chunks/bbbe5d6cb8b737811c84.js +0 -1
  196. package/assets/esri/core/workers/chunks/bf26f58210755875748c.js +0 -1
  197. package/assets/esri/core/workers/chunks/c1fd87af3129873369fd.js +0 -1
  198. package/assets/esri/core/workers/chunks/c4c2b94e5cee7b824093.js +0 -1
  199. package/assets/esri/core/workers/chunks/c85374360ac5e169af16.js +0 -1
  200. package/assets/esri/core/workers/chunks/c94ec324ecad77c53a87.js +0 -1
  201. package/assets/esri/core/workers/chunks/d175953337fa655dc6b0.js +0 -1
  202. package/assets/esri/core/workers/chunks/d8c762ca94e3a11b125d.js +0 -1
  203. package/assets/esri/core/workers/chunks/dbc447413ab40a79ba87.js +0 -1
  204. package/assets/esri/core/workers/chunks/e26dc0c1654316bb1558.js +0 -1
  205. package/assets/esri/core/workers/chunks/e410a09650530d7aad10.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import{addMany as t}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{makeHandle as n,handlesGroup as a,abortHandle as o}from"../../core/handleUtils.js";import{clone as l}from"../../core/lang.js";import{whenOrAbort as s,throwIfAborted as c,debounce as u}from"../../core/promiseUtils.js";import{watch as p,whenOnce as y}from"../../core/reactiveUtils.js";import{px2pt as d}from"../../core/screenUtils.js";import{diff as f}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as m,getAllStandardFeatureTemplatesForLayer as g}from"../../editing/templateUtils.js";import{featureHasFields as h,fixFields as b,getDisplayFieldName as w}from"../../layers/support/fieldUtils.js";import{calculateTolerance as v}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as S}from"../../renderers/support/lengthUtils.js";import{getTransformationType as j,TransformationType as I}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as U,getSize as V}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{to3D as T}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as O}from"../../symbols/support/symbolUtils.js";import{GraphicState as z}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as F}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as L}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as x,filterGraphicHits as P}from"../../views/support/hitTestSelectUtils.js";function A(e){return"update"===e.type}function k(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!G(t.renderer))return{rotation:null,size:null};let r=null,i=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=U(t,e)));1===n.length&&(r=R(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&j(t)===I.RealWorldSize&&null!=V(t,e)));return 1===a.length&&(i=C(a[0],t)),{rotation:r,size:i}}function R(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0};return{field:i,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,D((o.current+360)%360,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function E(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function M(e,t,r){if(null==t)return 0;const{symbol:i}=T(t);if(null==i||"web-style"===i.type||"cim"===i.type)return 0;const n=i.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(le.icon,(await e(n,le.icon))[0])||le.icon}case"text":return n.size||le.text;case"line":return n.size||le.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return E(await t(n,e.scale/le.viewScaleSizeFactor),r)}case"path":return(null!=n.width?n.width:n.height)||e.scale/le.viewScaleSizeFactor;case"extrude":return n.size||e.scale/le.viewScaleSizeFactor;default:return 0}}function C(e,t){const r=e.field,i=e.axis,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0},l=S[e.valueUnit]??1;let s;return s="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:r,fieldType:a,getDefault:async(e,t)=>D(s(await M(t,e,i)),a),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,D(o.current,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:ue(e.valueUnit),axis:e.axis}}function D(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function G(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function Z(e,t,r){const i=await O(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=f(e.symbol,i)&&(e.symbol=i)}function q(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};if(m(t)){switch(t.defaultTool){case"freehand":case"line":case"stream-line":return{tool:"polyline"===e?"freehandPolyline":"freehandPolygon",createOptions:{mode:"freehand"}};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:{mode:"freehand"}};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===e?"polygon":"polyline",createOptions:{mode:F}};case"circle":return{tool:"circle",createOptions:{mode:F,preserveAspectRatio:!0}};case"ellipse":return{tool:"circle",createOptions:{mode:F,preserveAspectRatio:!1}};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:{mode:F}};case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:{mode:F}};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:{mode:F}};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:{mode:F}}}}else{const r=t.drawingTool;if("circle"===r||"ellipse"===r){const e=new Map;return e.set("circle",{preserveAspectRatio:"circle"===r}),{tool:"circle",createOptions:{mode:F,optionsPerTool:e}}}if("rectangle"===r)return{tool:"rectangle",createOptions:{mode:F}};if("freehand"===r)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:{mode:F}}}return{tool:e,createOptions:{mode:F}}}async function Q(e,t,r){const i=r.layer,a=B(r);let o=null;const{view:l}=e,s="2d"===l?.type;if(await W(e,i,a,t,s?l.scale:null),s){const r=u((r=>W(e,i,a,t,r)));o=p((()=>l.scale),(e=>r(e)))}const{data:c,editing:y}=i.capabilities;e.layer.elevationInfo=i.elevationInfo;const d=q(i.geometryType,r.template);return e.defaultCreateOptions={graphicProperties:{attributes:a,sourceLayer:i},mode:d.createOptions.mode,optionsPerTool:d.createOptions.optionsPerTool,preserveAspectRatio:d.createOptions.preserveAspectRatio,hasZ:c.supportsZ,defaultZ:(s?y.zDefault:null)??e.defaultCreateOptions.defaultZ},null==r.geometryToPlace?await e.create(d.tool):await e.place(r.geometryToPlace,{graphicProperties:{attributes:a,sourceLayer:i}}),o??n()}function B(e){const{template:t}=e;if(t&&m(t))throw new i("Shared templates are not yet supported");return{...t?.prototype.attributes,...e.attributeOverrides}}async function W(t,r,i,n,a){const o=new e({sourceLayer:r,attributes:i}),{rotation:l,size:s}=k(o);let c=await O(o,{useSourceLayer:!0,webStyleCache:n,scale:a}),u=!1;for(const e of[s,l]){if(null==e)continue;null==i[e.field]&&(i[e.field]=await e.getDefault(c,t.view),u=!0)}switch(u&&(c=await O(o,{useSourceLayer:!0,webStyleCache:n,scale:a})),c?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=c;break;case"simple-line":case"line-3d":t.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=c;break;case"mesh-3d":t.meshSymbol=c}H(t.tooltipOptions,s,l)}function H(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function J(e,t){return e?.find((e=>e.layer===t))}async function K(e,t,r,i){switch(t.type){case"3d":return N(e,t,r,i);case"2d":return X(e,t,r,i)}}async function N(e,r,i,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:o}=await i.async((async()=>{const{results:t}=await s(x(r,i),n),a=new Map,o=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};P(t).forEach((({graphic:e})=>o(e).push(e)));const l=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&a.has(t)));return 0!==l.length&&i.stopPropagation(),{updatable:l,graphicsByLayer:a}}));return s(Promise.allSettled(a.map((async({layer:e})=>{const r=o.get(e),i=Y(e);if(r.every((e=>h(i,e))))return r;const a=[];for(const n of r){a.push(n.getObjectId());const e=Object.keys(n.attributes);t(i,e)}const l=e.createQuery();return l.returnGeometry=!1,l.objectIds=a,l.outFields=b(e.fieldsIndex,i),e.queryFeatures(l,{signal:n}).then((({features:e})=>e))}))),n)}async function X(e,t,r,i){if(0===e.length)return[];const{mapPoint:n}=r;if(null==n)return[];let a=null;const o=await r.async((async()=>{const{results:n}=await s(t.hitTest(r),i);if(0===n.length)return[];const o=new Set;a=P(n),a.forEach((({graphic:e})=>e&&o.add(e.layer)));const l=e.filter((e=>o.has(e.layer)&&e.supportsUpdateWorkflow));return l.length>0&&r.stopPropagation(),l}));return s(Promise.allSettled(o.map((async({layer:e})=>{const o=e.createQuery();o.returnGeometry=!1,o.outFields=Y(e);const l="renderer"in e?v({renderer:e.renderer,pointerType:r.pointerType}):0;o.geometry=L(n,l,t),o.outSpatialReference=t.spatialReference;const{features:s}=await e.queryFeatures(o,{signal:i});return a?.forEach((({graphic:t})=>{t.layer!==e||s.some((e=>e.getObjectId()===t.getObjectId()))||s.push(t)})),s}))),i)}function Y(e){return b(e.fieldsIndex,[e.objectIdField,w({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function $(e,t,r){const{sourceLayer:i}=e,n=i.createQuery();n.objectIds=[e.getAttribute(i.objectIdField)],n.outFields=["*"],n.returnM=i.capabilities.data.supportsM,n.returnZ=i.capabilities.data.supportsZ,"scene"===i.type&&null!=i.infoFor3D||(n.outSpatialReference=t);const a=await i.queryFeatures(n,{signal:r});c(r);return a.features[0]}async function _(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n,webStyleCache:a}=e;let o=!1;const{rotation:l,size:s}=n;if([l,s].forEach((async e=>{if(null==e)return;const i=t.getAttribute(e.field);if(null!=i)e.setInitialValue(i);else{const i=await e.getDefault(t.symbol,r.view);e.setInitialValue(i),t.setAttribute(e.field,i),o=!0}})),o){const e="2d"===r.view?.type?r.view.scale:null;await Z(t,a,e)}const c={multipleSelectionEnabled:!1};return"point"===i.geometryType&&(c.enableRotation=null!=l,c.enableScaling=null!=s),H(r.tooltipOptions,s,l),r.layer.elevationInfo=i.elevationInfo,r.update(t,c)}function ee(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function te(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function re(e,t,r,i,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=i.rotation,o=ee(r.toolEventInfo);if(null!=a&&null!=o){const{field:r,getValue:i}=a;"rotate-stop"===o.type?(a.isUpdatingInteractively=!1,a.setInitialValue(t.getAttribute(r))):(a.isUpdatingInteractively=!0,t.setAttribute(r,i(o.angle,e)))}const l=i.size,s=te(r.toolEventInfo);if(null!=l&&null!=s){const{field:r,getValue:i}=l;"scale-stop"===s.type?(l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r))):(l.isUpdatingInteractively=!0,t.setAttribute(r,i(s.xScale,e)))}await Z(t,n,"2d"===e.type?e.scale:null)}async function ie({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:i,view:l,onUpdate:s,webStyleCache:c,addUpdatingPromise:d,addHandle:f}){await Z(t,c,"2d"===l.type?l.scale:null);let m=null;if("2d"===i?.view?.type){const e=u((e=>Z(t,c,e)));m=p((()=>i?.view?.scale),(t=>e(t)))}const g=t.sourceLayer,h=de(l,g);await _({graphic:t,sketchViewModel:i,sourceLayer:g,visualVariables:r,webStyleCache:c});let b=null;h.then((e=>b=e)).catch((()=>{}));const w=r.size,v=r.rotation,S=p((()=>e.attributes),(async e=>{let r=!1;for(const i in e){const n=e[i];n!==t.getAttribute(i)&&(t.setAttribute(i,n),null==w||w.isUpdatingInteractively||w.field!==i||w.setInitialValue(n),null==v||v.isUpdatingInteractively||v.field!==i||v.setInitialValue(n),(null==b||b.requiredFields.includes(i))&&(r=!0))}r&&await Z(t,c,"2d"===l.type?l.scale:null)})),j=i.on("update",(async e=>{const t=e.graphics[0],n={graphic:t,sketchViewModel:i,sourceLayer:g,visualVariables:r,webStyleCache:c};if("complete"===e.state){if(null===l.activeTool)return _(n);const e=new AbortController,t=o(e);return f(t),d(y((()=>null===l.activeTool),e.signal).then((()=>(e.abort(),_(n)))))}await re(l,t,e,r,c),s(me(t),e)})),I=i.on(["undo","redo"],(async e=>{s(me(e.graphics[0]),e)}));return a([I,j,n((()=>i.cancel())),S,m])}async function ne(e,t,i){const o=e.view;e.layer.add(i);const l=t.sourceLayer,s=t.layer,u=t.getAttribute(s.objectIdField);let p=null;function d(e){p?.abort(),p=r((async t=>{const r=await de(o,l);c(t),r.setVisibility?.(u,e)}))}return await oe(o,i),d(!1),a([ae(o,i,(e=>d(!e))),n((async()=>{d(!0);try{const e=await de(o,l);await y((()=>!e.updating))}finally{e.layer.remove(i)}}))])}function ae(e,t,r){if("3d"===e.type){const i=new z({graphic:t});return a([e.trackGraphicState(i),p((()=>i.displaying),r)])}return p((()=>t.visible),r)}async function oe(e,t){if("3d"===e.type){const r=new z({graphic:t}),i=e.trackGraphicState(r);await y((()=>r.displaying||r.error)),i.remove()}else await y((()=>t.visible))}const le={icon:d(24),text:d(12),line:d(1),viewScaleSizeFactor:100};function se(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function ce(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,i=g(e);1===i.length&&"scene"!==e.type&&(r.template=i[0],t.shift())}return t}function ue(e){return"unknown"===e?null:e}function pe(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const ye=e=>/-stop/.test(e)||/vertex-/.test(e),de=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function fe(e){return"createInteractiveEditSession"in e}function me(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=l(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function ge(e){const t=e.cursor;return e.cursor="progress",n((()=>e.cursor=t))}export{ce as avoidFeatureTemplateSelectionWithOnlyOneItem,fe as canCreateInteractiveEditSession,me as cloneGraphicExceptMesh,se as createWorkflowSteps,K as fetchCandidates,$ as fetchFullFeature,J as findLayerInfo,B as getCreationAttributes,k as getVisualVariableAttributes,ye as isTerminalUpdateEventType,A as isUpdateWorkflow,pe as prepareAttachmentsForCreateFeaturesWorkflow,ie as setUpGeometryUpdate,ge as showProgressCursor,le as sizeDefaults,ue as sizeVariableUnitToLengthUnit,Q as startCreatingNewFeature,_ as startUpdatingFeatureGeometry,ne as swapForEditingSession,Z as updateGraphicSymbolWhenRequired,re as visualVariableInteractiveUpdate,de as whenEditorLayerView,oe as whenGraphicDisplayed};
5
+ import e from"../../Graphic.js";import{addMany as t}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{makeHandle as n,handlesGroup as a,abortHandle as o}from"../../core/handleUtils.js";import{clone as l}from"../../core/lang.js";import{whenOrAbort as s,throwIfAborted as c,debounce as u}from"../../core/promiseUtils.js";import{watch as p,whenOnce as y}from"../../core/reactiveUtils.js";import{px2pt as d}from"../../core/screenUtils.js";import{diff as f}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as m,getAllStandardFeatureTemplatesForLayer as g}from"../../editing/templateUtils.js";import{featureHasFields as h,fixFields as b,getDisplayFieldName as w}from"../../layers/support/fieldUtils.js";import{calculateTolerance as v}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as S}from"../../renderers/support/lengthUtils.js";import{getTransformationType as j,TransformationType as I}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as U,getSize as V}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{to3D as T}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as O}from"../../symbols/support/symbolUtils.js";import{GraphicState as z}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as F}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as L}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as x,filterGraphicHits as P}from"../../views/support/hitTestSelectUtils.js";function A(e){return"update"===e.type}function k(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!G(t.renderer))return{rotation:null,size:null};let r=null,i=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=U(t,e)));1===n.length&&(r=R(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&j(t)===I.RealWorldSize&&null!=V(t,e)));return 1===a.length&&(i=C(a[0],t)),{rotation:r,size:i}}function R(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0};return{field:i,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,D((o.current+360)%360,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function E(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function M(e,t,r){if(null==t)return 0;const{symbol:i}=T(t);if(null==i||"web-style"===i.type||"cim"===i.type)return 0;const n=i.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(le.icon,(await e(n,le.icon))[0])||le.icon}case"text":return n.size||le.text;case"line":return n.size||le.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return E(await t(n,e.scale/le.viewScaleSizeFactor),r)}case"path":return(null!=n.width?n.width:n.height)||e.scale/le.viewScaleSizeFactor;case"extrude":return n.size||e.scale/le.viewScaleSizeFactor;default:return 0}}function C(e,t){const r=e.field,i=e.axis,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0},l=S[e.valueUnit]??1;let s;return s="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:r,fieldType:a,getDefault:async(e,t)=>D(s(await M(t,e,i)),a),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,D(o.current,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:ue(e.valueUnit),axis:e.axis}}function D(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function G(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function Z(e,t,r){const i=await O(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=f(e.symbol,i)&&(e.symbol=i)}function q(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const i={mode:F,optionsPerTool:r};if(m(t)){switch(t.defaultTool){case"freehand":case"line":case"stream-line":return{tool:"polyline"===e?"freehandPolyline":"freehandPolygon",createOptions:i};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:i};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===e?"polygon":"polyline",createOptions:i};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:i};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:i};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:i};case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:i};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:i};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:i}}}else{const n=t.drawingTool;if("circle"===n||"ellipse"===n)return r.get("circle").preserveAspectRatio="circle"===n,{tool:"circle",createOptions:i};if("rectangle"===n)return{tool:"rectangle",createOptions:i};if("freehand"===n)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:i}}return{tool:e,createOptions:i}}async function Q(e,t,r){const i=r.layer,a=B(r);let o=null;const{view:l}=e,s="2d"===l?.type;if(await W(e,i,a,t,s?l.scale:null),s){const r=u((r=>W(e,i,a,t,r)));o=p((()=>l.scale),(e=>r(e)))}const{data:c,editing:y}=i.capabilities;e.layer.elevationInfo=i.elevationInfo;const d=q(i.geometryType,r.template);return e.defaultCreateOptions={graphicProperties:{attributes:a,sourceLayer:i},mode:d.createOptions.mode,optionsPerTool:d.createOptions.optionsPerTool,preserveAspectRatio:d.createOptions.preserveAspectRatio,hasZ:c.supportsZ,defaultZ:(s?y.zDefault:null)??e.defaultCreateOptions.defaultZ},null==r.geometryToPlace?await e.create(d.tool):await e.place(r.geometryToPlace,{graphicProperties:{attributes:a,sourceLayer:i}}),o??n()}function B(e){const{template:t}=e;if(t&&m(t))throw new i("Shared templates are not yet supported");return{...t?.prototype.attributes,...e.attributeOverrides}}async function W(t,r,i,n,a){const o=new e({sourceLayer:r,attributes:i}),{rotation:l,size:s}=k(o);let c=await O(o,{useSourceLayer:!0,webStyleCache:n,scale:a}),u=!1;for(const e of[s,l]){if(null==e)continue;null==i[e.field]&&(i[e.field]=await e.getDefault(c,t.view),u=!0)}switch(u&&(c=await O(o,{useSourceLayer:!0,webStyleCache:n,scale:a})),c?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=c;break;case"simple-line":case"line-3d":t.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=c;break;case"mesh-3d":t.meshSymbol=c}H(t.tooltipOptions,s,l)}function H(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function J(e,t){return e?.find((e=>e.layer===t))}async function K(e,t,r,i){switch(t.type){case"3d":return N(e,t,r,i);case"2d":return X(e,t,r,i)}}async function N(e,r,i,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:o}=await i.async((async()=>{const{results:t}=await s(x(r,i),n),a=new Map,o=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};P(t).forEach((({graphic:e})=>o(e).push(e)));const l=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&a.has(t)));return 0!==l.length&&i.stopPropagation(),{updatable:l,graphicsByLayer:a}}));return s(Promise.allSettled(a.map((async({layer:e})=>{const r=o.get(e),i=Y(e);if(r.every((e=>h(i,e))))return r;const a=[];for(const n of r){a.push(n.getObjectId());const e=Object.keys(n.attributes);t(i,e)}const l=e.createQuery();return l.returnGeometry=!1,l.objectIds=a,l.outFields=b(e.fieldsIndex,i),e.queryFeatures(l,{signal:n}).then((({features:e})=>e))}))),n)}async function X(e,t,r,i){if(0===e.length)return[];const{mapPoint:n}=r;if(null==n)return[];let a=null;const o=await r.async((async()=>{const{results:n}=await s(t.hitTest(r),i);if(0===n.length)return[];const o=new Set;a=P(n),a.forEach((({graphic:e})=>e&&o.add(e.layer)));const l=e.filter((e=>o.has(e.layer)&&e.supportsUpdateWorkflow));return l.length>0&&r.stopPropagation(),l}));return s(Promise.allSettled(o.map((async({layer:e})=>{const o=e.createQuery();o.returnGeometry=!1,o.outFields=Y(e);const l="renderer"in e?v({renderer:e.renderer,pointerType:r.pointerType}):0;o.geometry=L(n,l,t),o.outSpatialReference=t.spatialReference;const{features:s}=await e.queryFeatures(o,{signal:i});return a?.forEach((({graphic:t})=>{t.layer!==e||s.some((e=>e.getObjectId()===t.getObjectId()))||s.push(t)})),s}))),i)}function Y(e){return b(e.fieldsIndex,[e.objectIdField,w({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function $(e,t,r){const{sourceLayer:i}=e,n=i.createQuery();n.objectIds=[e.getAttribute(i.objectIdField)],n.outFields=["*"],n.returnM=i.capabilities.data.supportsM,n.returnZ=i.capabilities.data.supportsZ,"scene"===i.type&&null!=i.infoFor3D||(n.outSpatialReference=t);const a=await i.queryFeatures(n,{signal:r});c(r);return a.features[0]}async function _(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n,webStyleCache:a}=e;let o=!1;const{rotation:l,size:s}=n;if([l,s].forEach((async e=>{if(null==e)return;const i=t.getAttribute(e.field);if(null!=i)e.setInitialValue(i);else{const i=await e.getDefault(t.symbol,r.view);e.setInitialValue(i),t.setAttribute(e.field,i),o=!0}})),o){const e="2d"===r.view?.type?r.view.scale:null;await Z(t,a,e)}const c={multipleSelectionEnabled:!1};return"point"===i.geometryType&&(c.enableRotation=null!=l,c.enableScaling=null!=s),H(r.tooltipOptions,s,l),r.layer.elevationInfo=i.elevationInfo,r.update(t,c)}function ee(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function te(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function re(e,t,r,i,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=i.rotation,o=ee(r.toolEventInfo);if(null!=a&&null!=o){const{field:r,getValue:i}=a;"rotate-stop"===o.type?(a.isUpdatingInteractively=!1,a.setInitialValue(t.getAttribute(r))):(a.isUpdatingInteractively=!0,t.setAttribute(r,i(o.angle,e)))}const l=i.size,s=te(r.toolEventInfo);if(null!=l&&null!=s){const{field:r,getValue:i}=l;"scale-stop"===s.type?(l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r))):(l.isUpdatingInteractively=!0,t.setAttribute(r,i(s.xScale,e)))}await Z(t,n,"2d"===e.type?e.scale:null)}async function ie({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:i,view:l,onUpdate:s,webStyleCache:c,addUpdatingPromise:d,addHandle:f}){await Z(t,c,"2d"===l.type?l.scale:null);let m=null;if("2d"===i?.view?.type){const e=u((e=>Z(t,c,e)));m=p((()=>i?.view?.scale),(t=>e(t)))}const g=t.sourceLayer,h=de(l,g);await _({graphic:t,sketchViewModel:i,sourceLayer:g,visualVariables:r,webStyleCache:c});let b=null;h.then((e=>b=e)).catch((()=>{}));const w=r.size,v=r.rotation,S=p((()=>e.attributes),(async e=>{let r=!1;for(const i in e){const n=e[i];n!==t.getAttribute(i)&&(t.setAttribute(i,n),null==w||w.isUpdatingInteractively||w.field!==i||w.setInitialValue(n),null==v||v.isUpdatingInteractively||v.field!==i||v.setInitialValue(n),(null==b||b.requiredFields.includes(i))&&(r=!0))}r&&await Z(t,c,"2d"===l.type?l.scale:null)})),j=i.on("update",(async e=>{const t=e.graphics[0],n={graphic:t,sketchViewModel:i,sourceLayer:g,visualVariables:r,webStyleCache:c};if("complete"===e.state){if(null===l.activeTool)return _(n);const e=new AbortController,t=o(e);return f(t),d(y((()=>null===l.activeTool),e.signal).then((()=>(e.abort(),_(n)))))}await re(l,t,e,r,c),s(me(t),e)})),I=i.on(["undo","redo"],(async e=>{s(me(e.graphics[0]),e)}));return a([I,j,n((()=>i.cancel())),S,m])}async function ne(e,t,i){const o=e.view;e.layer.add(i);const l=t.sourceLayer,s=t.layer,u=t.getAttribute(s.objectIdField);let p=null;function d(e){p?.abort(),p=r((async t=>{const r=await de(o,l);c(t),r.setVisibility?.(u,e)}))}return await oe(o,i),d(!1),a([ae(o,i,(e=>d(!e))),n((async()=>{d(!0);try{const e=await de(o,l);await y((()=>!e.updating))}finally{e.layer.remove(i)}}))])}function ae(e,t,r){if("3d"===e.type){const i=new z({graphic:t});return a([e.trackGraphicState(i),p((()=>i.displaying),r)])}return p((()=>t.visible),r)}async function oe(e,t){if("3d"===e.type){const r=new z({graphic:t}),i=e.trackGraphicState(r);await y((()=>r.displaying||r.error)),i.remove()}else await y((()=>t.visible))}const le={icon:d(24),text:d(12),line:d(1),viewScaleSizeFactor:100};function se(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function ce(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,i=g(e);1===i.length&&"scene"!==e.type&&(r.template=i[0],t.shift())}return t}function ue(e){return"unknown"===e?null:e}function pe(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const ye=e=>/-stop/.test(e)||/vertex-/.test(e),de=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function fe(e){return"createInteractiveEditSession"in e}function me(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=l(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function ge(e){const t=e.cursor;return e.cursor="progress",n((()=>e.cursor=t))}export{ce as avoidFeatureTemplateSelectionWithOnlyOneItem,fe as canCreateInteractiveEditSession,me as cloneGraphicExceptMesh,se as createWorkflowSteps,K as fetchCandidates,$ as fetchFullFeature,J as findLayerInfo,B as getCreationAttributes,k as getVisualVariableAttributes,ye as isTerminalUpdateEventType,A as isUpdateWorkflow,pe as prepareAttachmentsForCreateFeaturesWorkflow,ie as setUpGeometryUpdate,ge as showProgressCursor,le as sizeDefaults,ue as sizeVariableUnitToLengthUnit,Q as startCreatingNewFeature,_ as startUpdatingFeatureGeometry,ne as swapForEditingSession,Z as updateGraphicSymbolWhenRequired,re as visualVariableInteractiveUpdate,de as whenEditorLayerView,oe as whenGraphicDisplayed};
package/widgets/Editor.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{mappedFind as t,abortMaybe as s,destroyMaybe as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as r,initial as a,on as n,when as l}from"../core/reactiveUtils.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import m from"../views/interactive/sketch/SketchValueOptions.js";import h from"./Attachments.js";import p from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{css as v}from"./Editor/css.js";import _ from"./Editor/EditorViewModel.js";import{isModelUpload as f}from"./Editor/modelUploadUtils.js";import k from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as y,CreateFeaturesPanelContent as b}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as F,FeatureList as M}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as A,FooterActions as T}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as C,Notice as E}from"./Editor/components/Notices.js";import{loadPanelContentComponents as P,PanelContent as W,PanelContentSection as L,PanelContentMessage as j}from"./Editor/components/PanelContent.js";import{PanelToolbar as S,loadPanelToolbarComponents as I}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as U,Prompt as D}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as O,UpdateFeaturePanelContent as V}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as x,UploadDetails as B}from"./Editor/components/UploadDetails.js";import{VisibleElements as R,CreateToolVisibilityMap as G}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as z}from"./support/componentsUtils.js";import{globalCss as H}from"./support/globalCss.js";import{incrementHeadingLevel as q,Heading as N}from"./support/Heading.js";import{renderItem as K}from"./support/ItemList.js";import{connectDelayedLoading as $}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as J}from"./support/decorators/messageBundle.js";import{vmEvent as Q}from"./support/decorators/vmEvent.js";import{tsx as X}from"./support/jsxFactory.js";import{substitute as Y}from"../intl/substitute.js";const Z=Symbol("sketch-setup-handles");let ee=class extends w{constructor(e,t){super(e,t),this._featureForm=new p,this._sketchToolbar=null,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new u({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?X("calcite-icon",{class:v.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new g,this._loading=!1,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new _,this.visibleElements=new k,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?X("div",{class:v.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>X("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...o)=>{const{visibleElements:i}=this;return X("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},i.settingsMenu?X(S,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:i}):null,...o)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&f(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([r((()=>q(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),a),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),a),r((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),a),r((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),a),r((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),a),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._showPrompt({title:t.errorWarningTitle,message:Y(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}})})),r((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),r((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),r((()=>this.visibleElements.sketch),(()=>this._setupSketch()),a),$({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return Promise.all([z({flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),y(),F(),A(),C(),P(),I(),U(),O(),x()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(v.base,H.widget,H.panel);if(!t)return X("div",{class:s,key:"empty"});const{pageStack:o}=t,i=o.length-1,r=o.map(((e,t)=>this._renderPage(e,t===i)));return X("div",{class:s,key:"base"},e.flow?X("calcite-flow",{key:"flow"},r):r,this._prompt?X(D,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s)}return X("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return X(t,{heading:s.selectTemplate,key:"templates-panel",...e},X(W,{key:"feature-templates"},X(L,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:o}=this;if("create-features"!==s?.type)return null;const i=s.data.upload;return i?X(t,{heading:o.createFeatures,key:"upload-details-panel",...e},X(B,{helpMessage:this._helpMessage,messages:o,upload:i})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:o,messagesCommon:i,headingLevel:r,viewModel:a}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return X(t,{heading:o.createFeatures,key:"create-features-panel",...e},n?X(V,{editorViewModel:a,headingLevel:r,messages:o,messagesCommon:i,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):X(b,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:r}=this;return X(t,{heading:s.editFeature,key:"update-feature-panel",...e},X(V,{editorViewModel:r,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){if(!e)return null;if(e.title)return e.title;const{messagesFeature:t}=this;switch(e.type){case"attachment":return t.associationsAttachments;case"connectivity":return t.associationsConnectivity;case"structure":return t.associationsStructure;case"content":return t.associationsContents;case"container":return t.associationsContainer}}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:r}=this,a=r.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(a)??s.editFeature;return X(t,{heading:n,key:"viewing-associated-layers-panel",...e},X(V,{editorViewModel:r,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderCustomTemplateGroupContent(e){const{messages:s,viewModel:o}=this,i=t(e.group.items,(e=>o.itemHasInvalidFormTemplate(e)?s.formFieldCreateError:void 0));return i?X(E,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:o,messagesCommon:i}=this;return X(t,{heading:o.addAttachment,key:"attachment-adding-panel",...e},X(W,{key:"attachments"},this._renderAttachments()),X(T,{buttons:[{label:s.submitting?i.cancel:i.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:o,messages:i,messagesCommon:r}=this;return o?X(t,{heading:i.editAttachment,key:"attachment-editing-panel",...e},X(W,{key:"attachments"},this._renderAttachments()),o.shouldAllowAttachmentEditing?X(T,{buttons:[{label:r.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:r.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:o,visibleElements:i}=this,r=this._helpMessage;return X(t,{heading:s.widgetLabel,key:"landing-panel",...e},X(W,{key:"landing-content"},o.editorItems.length?[i.editFeaturesSection?X(L,{key:"edit-actions"},this._renderUpdateActions()):null,i.createFeaturesSection&&o.canCreateVisible?X(L,{key:"create-actions"},this._renderCreateActions()):null]:X(j,{key:"no-content"},s.noEditableLayers)),r?X("div",{class:v.helpMessage,key:"footer-actions",slot:"footer"},r):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return X("div",{class:v.updateActions,key:"update-actions"},X(N,{level:q(this.headingLevel)},e.editFeatures),X("calcite-list",{class:v.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},K({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return X("div",{key:"create-actions"},X(N,{level:q(this.headingLevel)},this.messages.createFeatures),X("div",{class:v.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const i=o.data.candidates,r=Y(this.messages.multipleFeaturesTemplate,{total:i.length});return X(t,{heading:r,key:"feature-list",...e},X(M,{editorItems:s.editorItems,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:o}){const r=i(),{view:a}=this,n=a?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>r.resolve(!0)},secondary:{label:o,action:()=>r.resolve(!1)}}}),r.promise.finally((()=>{this._clearPrompt(),n&&a?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=s(this._sketchImportAbortController),this._sketchToolbar=o(this._sketchToolbar),void this.removeHandles(Z);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const t=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new t.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new R({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new G({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([r((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),a),r((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),a),l((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),a),l((()=>!!this.messages),(()=>{this._sketchToolbar&&(this._sketchToolbar.customActions=[{icon:"zoom-to-object",text:this.messages.zoomTo,onclick:()=>this.viewModel.zoomTo(),id:"editor-custom-zoom-to",position:"before-selection-set"}])}),{once:!0,initial:!0})],Z)}finally{this._sketchImportAbortController=null}}};e([d()],ee.prototype,"_featureForm",void 0),e([d()],ee.prototype,"_sketchToolbar",void 0),e([d()],ee.prototype,"_attachments",void 0),e([d()],ee.prototype,"_featureTemplates",void 0),e([d()],ee.prototype,"_filterText",void 0),e([d()],ee.prototype,"_prompt",void 0),e([d()],ee.prototype,"_spinner",void 0),e([d()],ee.prototype,"_deleteButtonCommonInfo",null),e([d()],ee.prototype,"_loading",void 0),e([d({readOnly:!0})],ee.prototype,"activeWorkflow",null),e([d()],ee.prototype,"headingLevel",void 0),e([d()],ee.prototype,"hideTemplatesForInactiveLayers",null),e([d()],ee.prototype,"icon",null),e([d()],ee.prototype,"label",null),e([d()],ee.prototype,"labelOptions",null),e([d()],ee.prototype,"layerInfos",null),e([d(),J("esri/widgets/Editor/t9n/Editor")],ee.prototype,"messages",void 0),e([d(),J("esri/t9n/common")],ee.prototype,"messagesCommon",void 0),e([d(),J("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],ee.prototype,"messagesTemplates",void 0),e([d(),J("esri/widgets/Feature/t9n/Feature")],ee.prototype,"messagesFeature",void 0),e([d()],ee.prototype,"snappingOptions",null),e([d()],ee.prototype,"tooltipOptions",null),e([d()],ee.prototype,"supportingWidgetDefaults",void 0),e([d({type:m,nonNullable:!0})],ee.prototype,"valueOptions",null),e([d()],ee.prototype,"view",null),e([d(),Q(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],ee.prototype,"viewModel",void 0),e([d({type:k,nonNullable:!0})],ee.prototype,"visibleElements",void 0),e([d()],ee.prototype,"_helpMessage",null),ee=e([c("esri.widgets.Editor")],ee);const te=ee;export{te as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{destroyMaybe as t,mappedFind as s,abortMaybe as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as r,initial as a,on as n,when as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import m from"../views/interactive/sketch/SketchValueOptions.js";import h from"./Attachments.js";import p from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{css as v}from"./Editor/css.js";import _ from"./Editor/EditorViewModel.js";import{isModelUpload as f}from"./Editor/modelUploadUtils.js";import k from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as y,CreateFeaturesPanelContent as b}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as F,FeatureList as M}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as A,FooterActions as T}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as C,Notice as E}from"./Editor/components/Notices.js";import{loadPanelContentComponents as P,PanelContent as W,PanelContentSection as L,PanelContentMessage as j}from"./Editor/components/PanelContent.js";import{PanelToolbar as S,loadPanelToolbarComponents as I}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as U,Prompt as D}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as O,UpdateFeaturePanelContent as V}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as x,UploadDetails as B}from"./Editor/components/UploadDetails.js";import{VisibleElements as z,CreateToolVisibilityMap as R}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as G}from"./support/componentsUtils.js";import{globalCss as H}from"./support/globalCss.js";import{incrementHeadingLevel as q,Heading as N}from"./support/Heading.js";import{renderItem as Z}from"./support/ItemList.js";import{connectDelayedLoading as K}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as $}from"./support/decorators/messageBundle.js";import{vmEvent as J}from"./support/decorators/vmEvent.js";import{tsx as Q}from"./support/jsxFactory.js";import{substitute as X}from"../intl/substitute.js";const Y=Symbol("sketch-setup-handles");let ee=class extends w{constructor(e,t){super(e,t),this._featureForm=new p,this._sketchToolbar=null,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new u({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?Q("calcite-icon",{class:v.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new g,this._loading=!1,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new _,this.visibleElements=new k,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?Q("div",{class:v.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>Q("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...o)=>{const{visibleElements:i}=this;return Q("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},i.zoomToButton&&this.viewModel.canZoomTo?Q("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo}):null,i.settingsMenu?Q(S,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:i}):null,...o)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&f(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([r((()=>q(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),a),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),a),r((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),a),r((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),a),r((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),a),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._showPrompt({title:t.errorWarningTitle,message:X(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}})})),r((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),r((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),r((()=>this.visibleElements.sketch),(()=>this._setupSketch()),a),K({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._sketchToolbar=t(this._sketchToolbar)}loadDependencies(){return Promise.all([G({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),y(),F(),A(),C(),P(),I(),U(),O(),x()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(v.base,H.widget,H.panel);if(!t)return Q("div",{class:s,key:"empty"});const{pageStack:o}=t,i=o.length-1,r=o.map(((e,t)=>this._renderPage(e,t===i)));return Q("div",{class:s,key:"base"},e.flow?Q("calcite-flow",{key:"flow"},r):r,this._prompt?Q(D,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s)}return Q("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return Q(t,{heading:s.selectTemplate,key:"templates-panel",...e},Q(W,{key:"feature-templates"},Q(L,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:o}=this;if("create-features"!==s?.type)return null;const i=s.data.upload;return i?Q(t,{heading:o.createFeatures,key:"upload-details-panel",...e},Q(B,{helpMessage:this._helpMessage,messages:o,upload:i})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:o,messagesCommon:i,headingLevel:r,viewModel:a}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return Q(t,{heading:o.createFeatures,key:"create-features-panel",...e},n?Q(V,{editorViewModel:a,headingLevel:r,messages:o,messagesCommon:i,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):Q(b,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:r}=this;return Q(t,{heading:s.editFeature,key:"update-feature-panel",...e},Q(V,{editorViewModel:r,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){if(!e)return null;if(e.title)return e.title;const{messagesFeature:t}=this;switch(e.type){case"attachment":return t.associationsAttachments;case"connectivity":return t.associationsConnectivity;case"structure":return t.associationsStructure;case"content":return t.associationsContents;case"container":return t.associationsContainer}}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:r}=this,a=r.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(a)??s.editFeature;return Q(t,{heading:n,key:"viewing-associated-layers-panel",...e},Q(V,{editorViewModel:r,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:o}=this,i=s(e.group.items,(e=>o.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?Q(E,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:o,messagesCommon:i}=this;return Q(t,{heading:o.addAttachment,key:"attachment-adding-panel",...e},Q(W,{key:"attachments"},this._renderAttachments()),Q(T,{buttons:[{label:s.submitting?i.cancel:i.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:o,messages:i,messagesCommon:r}=this;return o?Q(t,{heading:i.editAttachment,key:"attachment-editing-panel",...e},Q(W,{key:"attachments"},this._renderAttachments()),o.shouldAllowAttachmentEditing?Q(T,{buttons:[{label:r.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:r.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:o,visibleElements:i}=this,r=this._helpMessage;return Q(t,{heading:s.widgetLabel,key:"landing-panel",...e},Q(W,{key:"landing-content"},o.editorItems.length?[i.editFeaturesSection?Q(L,{key:"edit-actions"},this._renderUpdateActions()):null,i.createFeaturesSection&&o.canCreateVisible?Q(L,{key:"create-actions"},this._renderCreateActions()):null]:Q(j,{key:"no-content"},s.noEditableLayers)),r?Q("div",{class:v.helpMessage,key:"footer-actions",slot:"footer"},r):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return Q("div",{class:v.updateActions,key:"update-actions"},Q(N,{level:q(this.headingLevel)},e.editFeatures),Q("calcite-list",{class:v.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},Z({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return Q("div",{key:"create-actions"},Q(N,{level:q(this.headingLevel)},this.messages.createFeatures),Q("div",{class:v.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const i=o.data.candidates,r=X(this.messages.multipleFeaturesTemplate,{total:i.length});return Q(t,{heading:r,key:"feature-list",...e},Q(M,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:o}){const r=i(),{view:a}=this,n=a?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>r.resolve(!0)},secondary:{label:o,action:()=>r.resolve(!1)}}}),r.promise.finally((()=>{this._clearPrompt(),n&&a?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(Y);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const s=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new s.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new z({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new R({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([r((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),a),r((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),a),l((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),a)],Y)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar}}};e([c()],ee.prototype,"_featureForm",void 0),e([c()],ee.prototype,"_sketchToolbar",void 0),e([c()],ee.prototype,"_attachments",void 0),e([c()],ee.prototype,"_featureTemplates",void 0),e([c()],ee.prototype,"_filterText",void 0),e([c()],ee.prototype,"_prompt",void 0),e([c()],ee.prototype,"_spinner",void 0),e([c()],ee.prototype,"_deleteButtonCommonInfo",null),e([c()],ee.prototype,"_loading",void 0),e([c({readOnly:!0})],ee.prototype,"activeWorkflow",null),e([c()],ee.prototype,"headingLevel",void 0),e([c()],ee.prototype,"hideTemplatesForInactiveLayers",null),e([c()],ee.prototype,"icon",null),e([c()],ee.prototype,"label",null),e([c()],ee.prototype,"labelOptions",null),e([c()],ee.prototype,"layerInfos",null),e([c(),$("esri/widgets/Editor/t9n/Editor")],ee.prototype,"messages",void 0),e([c(),$("esri/t9n/common")],ee.prototype,"messagesCommon",void 0),e([c(),$("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],ee.prototype,"messagesTemplates",void 0),e([c(),$("esri/widgets/Feature/t9n/Feature")],ee.prototype,"messagesFeature",void 0),e([c()],ee.prototype,"snappingOptions",null),e([c()],ee.prototype,"tooltipOptions",null),e([c()],ee.prototype,"supportingWidgetDefaults",void 0),e([c({type:m,nonNullable:!0})],ee.prototype,"valueOptions",null),e([c()],ee.prototype,"view",null),e([c(),J(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],ee.prototype,"viewModel",void 0),e([c({type:k,nonNullable:!0})],ee.prototype,"visibleElements",void 0),e([c()],ee.prototype,"_helpMessage",null),ee=e([d("esri.widgets.Editor")],ee);const te=ee;export{te as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import{watch as n,initial as r}from"../../../core/reactiveUtils.js";import{throttle as i}from"../../../core/throttle.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 l}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../geometry/Point.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import a from"../../../popup/content/FieldsContent.js";import c from"../../../popup/content/MediaContent.js";import"../../../popup/content/RelationshipContent.js";import m from"../../../popup/content/TextContent.js";import"../../../popup/content/UtilityNetworkAssociationsContent.js";import d from"../../../popup/ElementExpressionInfo.js";import h from"../FeatureContent/FeatureContentViewModel.js";import u from"../FeatureFields/FeatureFieldsViewModel.js";import f from"../FeatureMedia/FeatureMediaViewModel.js";import{loadArcade as y,createCompiledExpression as _}from"../support/arcadeFeatureUtils.js";const w=1;let j=class extends o{constructor(t){super(t),this._abortController=null,this.expressionInfo=null,this.graphic=null,this.contentElement=null,this.contentElementViewModel=null,this.interceptor=null,this.location=null,this.view=null,this._cancelQuery=()=>{const{_abortController:t}=this;t&&t.abort(),this._abortController=null},this._createVM=()=>{const t=this.contentElement?.type;this.contentElementViewModel?.destroy();const e="fields"===t?new u:"media"===t?new f:"text"===t?new h:null;this._set("contentElementViewModel",e)},this._compile=async()=>{this._cancelQuery();const t=new AbortController;this._abortController=t,await this._compileExpression(),this._abortController===t&&(this._abortController=null)},this._compileThrottled=i(this._compile,w,this),this._compileExpression=async()=>{const{expressionInfo:t,graphic:e,interceptor:o,spatialReference:n,map:r,location:i,view:s,_abortController:l}=this;if(!t||!e)return void this._set("contentElement",null);const p=await y();if(l!==this._abortController)return;const d=await _({arcade:p,expressionInfo:t,graphic:e,location:i,interceptor:o,map:r,spatialReference:n,view:s});if(!d||"esri.arcade.Dictionary"!==d.declaredClass)return void this._set("contentElement",null);const h=await d.castAsJsonAsync(l?.signal),u=h?.type,f="media"===u?c.fromJSON(h):"text"===u?m.fromJSON(h):"fields"===u?a.fromJSON(h):null;"media"===f.type&&!f.mediaInfos||"fields"===f.type&&!f.fieldInfos||"text"===f.type&&!f.text?this._set("contentElement",null):this._set("contentElement",f)},this.addHandles([n((()=>[this.expressionInfo,this.graphic,this.map,this.spatialReference,this.view]),(()=>this._compileThrottled()),r),n((()=>[this.contentElement]),(()=>this._createVM()),r)])}initialize(){this.addHandles(this._compileThrottled)}destroy(){this._cancelQuery(),this.contentElementViewModel?.destroy(),this._set("contentElementViewModel",null),this._set("contentElement",null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(t){this._override("spatialReference",t)}get state(){const{_abortController:t,contentElement:e,contentElementViewModel:o}=this;return t?"loading":e||o?"ready":"disabled"}get map(){return this.view?.map??null}set map(t){this._override("map",t)}};t([s()],j.prototype,"_abortController",void 0),t([s({type:d})],j.prototype,"expressionInfo",void 0),t([s({type:e})],j.prototype,"graphic",void 0),t([s({readOnly:!0})],j.prototype,"contentElement",void 0),t([s({readOnly:!0})],j.prototype,"contentElementViewModel",void 0),t([s()],j.prototype,"interceptor",void 0),t([s({type:p})],j.prototype,"location",void 0),t([s()],j.prototype,"spatialReference",null),t([s({readOnly:!0})],j.prototype,"state",null),t([s()],j.prototype,"map",null),t([s()],j.prototype,"view",void 0),j=t([l("esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel")],j);const C=j;export{C as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import{createTask as s}from"../../../core/asyncUtils.js";import{abortMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{watch as r,initial as a,when as l}from"../../../core/reactiveUtils.js";import{throttle as p}from"../../../core/throttle.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import h from"../../../geometry/Point.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import u from"../../../popup/content/FieldsContent.js";import d from"../../../popup/content/MediaContent.js";import"../../../popup/content/RelationshipContent.js";import f from"../../../popup/content/TextContent.js";import"../../../popup/content/UtilityNetworkAssociationsContent.js";import v from"../../../popup/ElementExpressionInfo.js";import _ from"../FeatureContent/FeatureContentViewModel.js";import y from"../FeatureFields/FeatureFieldsViewModel.js";import w from"../FeatureMedia/FeatureMediaViewModel.js";import{loadArcade as T,compileExpression as j}from"../support/arcadeFeatureUtils.js";const k=1;let g=class extends o{constructor(t){super(t),this._compileTask=null,this._evaluateTask=null,this.expressionInfo=null,this.graphic=null,this.contentElementViewModel=null,this.interceptor=null,this.location=null,this.view=null,this._createVM=()=>{const t=this.contentElement?.type;this.contentElementViewModel?.destroy();const e="fields"===t?new y:"media"===t?new w:"text"===t?new _:null;this._set("contentElementViewModel",e)},this._compileThrottled=p(this._startCompile,(()=>this.notifyChange("state")),k,this),this._evaluateThrottled=p(this._startEvaluate,(()=>this.notifyChange("state")),k,this),this.addHandles([r((()=>[this.expressionInfo,this.graphic]),(()=>this._compileThrottled()),a),r((()=>[this.contentElement]),(()=>this._createVM()),a),l((()=>{if(!this._compileTask?.finished)return null;const t=this._compileTask.value,e=t?.dependencies;return[t,this.spatialReference,this.map,this.view,e?.has("view-scale")?this.view?.scale:null,e?.has("view-time-extent")?this.view?.timeExtent?.start:null,e?.has("view-time-extent")?this.view?.timeExtent?.end:null]}),(([t])=>this._evaluateThrottled(t)))])}initialize(){this.addHandles([this._compileThrottled,this._evaluateThrottled])}destroy(){this._compileTask=i(this._compileTask),this._evaluateTask=i(this._evaluateTask),this.contentElementViewModel?.destroy(),this._set("contentElementViewModel",null)}get contentElement(){return this._evaluateTask?.value}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(t){this._override("spatialReference",t)}get state(){const{contentElement:t,contentElementViewModel:e}=this;return this._compileThrottled.hasPendingUpdates()||this._evaluateThrottled.hasPendingUpdates()||!this._compileTask?.finished||!this._evaluateTask?.finished?"loading":t||e?"ready":"disabled"}get map(){return this.view?.map??null}set map(t){this._override("map",t)}_startCompile(){this._evaluateTask=i(this._evaluateTask),this._compileTask=i(this._compileTask),this._compileTask=s((async t=>{const{expressionInfo:e,graphic:o}=this;if(!e||!o)return null;const s=await T();n(t);const i=await j({expressionInfo:e,arcade:s,graphic:o});return n(t),i}))}_startEvaluate(t){this._evaluateTask=i(this._evaluateTask),this._evaluateTask=s((async e=>{const{graphic:o}=this;if(!t||!o)return null;const{interceptor:s,spatialReference:i,map:r,location:a,view:l}=this,p=await t.evaluate({graphic:o,interceptor:s,location:a,map:r,options:{signal:e},spatialReference:i,view:l});n(e);const c=p;if(!c||"esri.arcade.Dictionary"!==c.declaredClass)return null;const m=await c.castAsJsonAsync(e);n(e);const h=m?.type,v="media"===h?d.fromJSON(m):"text"===h?f.fromJSON(m):"fields"===h?u.fromJSON(m):null;return"media"===v.type&&!v.mediaInfos||"fields"===v.type&&!v.fieldInfos||"text"===v.type&&!v.text?null:v}))}};t([c()],g.prototype,"_compileTask",void 0),t([c()],g.prototype,"_evaluateTask",void 0),t([c({type:v})],g.prototype,"expressionInfo",void 0),t([c({type:e})],g.prototype,"graphic",void 0),t([c({readOnly:!0})],g.prototype,"contentElement",null),t([c({readOnly:!0})],g.prototype,"contentElementViewModel",void 0),t([c()],g.prototype,"interceptor",void 0),t([c({type:h})],g.prototype,"location",void 0),t([c()],g.prototype,"spatialReference",null),t([c({readOnly:!0})],g.prototype,"state",null),t([c()],g.prototype,"map",null),t([c()],g.prototype,"view",void 0),g=t([m("esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel")],g);const E=g;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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import o from"../../core/Accessor.js";import{isSome as r}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import n from"../../core/Identifiable.js";import a from"../../core/Logger.js";import{isAbortError as l,eachAlways as c}from"../../core/promiseUtils.js";import{watch as p,on as d,whenOnce as u,initial as h}from"../../core/reactiveUtils.js";import{throttle as f}from"../../core/throttle.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{cast as _}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import b from"../../geometry/Point.js";import g from"../../geometry/SpatialReference.js";import A from"../../popup/content/TextContent.js";import{getFeaturePopupTitle as w}from"../../support/popupUtils.js";import{system as I}from"../../time/timeZoneUtils.js";import M from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import v from"./FeatureContent/FeatureContentViewModel.js";import F from"./FeatureExpression/FeatureExpressionViewModel.js";import C from"./FeatureFields/FeatureFieldsViewModel.js";import x from"./FeatureMedia/FeatureMediaViewModel.js";import V from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{createCompiledExpressions as T}from"./support/arcadeFeatureUtils.js";import{createFieldInfoMap as E,getAllFieldInfos as j,getSourceLayer as P,querySourceLayer as R,isRelatableFeatureSupportedLayer as L,isAssociatedFeatureSupportedLayer as O,substituteFieldsInLinksAndAttributes as Z,isExpressionField as k,isRelatedField as N,formatEditInfo as U,graphicCallback as B,queryUpdatedFeature as S,formatAttributes as H,preLayerQueryCallback as D,preRequestCallback as G}from"./support/featureUtils.js";import{queryLayerInfos as q,queryRelatedFeatures as Q,setRelatedFeatures as z,getRelatedFieldInfo as J,createRelatedInfo as K,updateRelatedInfo as W}from"./support/relatedFeatureUtils.js";import X from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";var Y;const $=1,ee="content-view-models",te="relationship-view-models",ie="association-view-models",oe={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let re=Y=class extends(n.IdentifiableMixin(o)){constructor(e){super(e),this._error=null,this._featureAbortController=null,this._associationVMAbortController=null,this._graphicChangedThrottled=f(this._graphicChanged,$,this),this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...oe},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this.addHandles(p((()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone]),(()=>this._graphicChangedThrottled()),h))}initialize(){this.addHandles(this._graphicChangedThrottled)}destroy(){this._clear(),this._cancelFeatureQuery(),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return E(j(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return P(this.graphic)}castAbilities(e){return{...oe,...e}}get isTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._featureAbortController=new AbortController,this._set("graphic",e?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??I}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){return!(!this._featureAbortController&&!this._associationVMAbortController)}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof x&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof x&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof x&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const o=i?.objectIdField;if(!o||!e||!i)return;const r=e?.attributes?.[o];if(null==r)return;const s=[r];if(!e.geometry){const o=await R({layer:i,graphic:e,outFields:[],objectIds:s,returnGeometry:!0,spatialReference:t}),r=o?.geometry;r&&(e.geometry=r)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}async _graphicChanged(){this._cancelFeatureQuery(),this._error=null,this._clear();const{graphic:e}=this;if(!e)return;const t=new AbortController;this._featureAbortController=t;try{await this._queryFeature({signal:t.signal})}catch(i){l(i)||(this._error=i,a.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:e,popupTemplate:this._effectivePopupTemplate}))}this._featureAbortController===t&&(this._featureAbortController=null)}_cancelFeatureQuery(){const{_featureAbortController:e}=this;e&&e.abort(),this._featureAbortController=null}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(((e,t)=>this._compileContentElement(e,t))).filter(r):"string"==typeof e?this._compileText(new A({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(te),this.removeHandles(ee),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),o=t?.getObjectId();return null!=i&&null!=o&&i===o}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:o,spatialReference:r,timeZone:s}=this;t?.filter(Boolean).forEach((t=>{e.some((e=>this._matchesFeature(e,t)))||e.add(new Y({abilities:{relationshipContent:!1},map:i,view:o,spatialReference:r,timeZone:s,graphic:t}))})),e.forEach((i=>{const o=t?.find((e=>this._matchesFeature(i,e)));o||e.remove(i)}))}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:o,contentElementViewModel:r}=e,s=o?.type;r&&s&&("fields"===s&&(this._createFieldsFormattedAttributes({contentElement:o,contentElementIndex:t,formattedAttributes:i}),r.set(this._createFieldsVMParams(o,t))),"media"===s&&(this._createMediaFormattedAttributes({contentElement:o,contentElementIndex:t,formattedAttributes:i}),r.set(this._createMediaVMParams(o,t))),"text"===s&&r.set(this._createTextVMParams(o)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:o,relationshipId:r,title:s,description:n}=e,{_sourceLayer:a,graphic:l,map:c}=this;if(!L(a))return;const p=new V({displayCount:i,graphic:l,orderByFields:o,relationshipId:r,layer:a,map:c,...this._compileTitleAndDesc({title:s,description:n})});return this.contentViewModels[t]=p,this.addHandles(d((()=>p.relatedFeatures),"change",(()=>this._setRelatedFeaturesViewModels(p))),te),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,o=t?.association.globalId;return null!=i&&null!=o&&i===o}async _setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:o,spatialReference:r,timeZone:n}=this;e.forEach(((i,o)=>{const r=t.get(o);r?i.forEach((t=>{r.find((e=>this._matchesGlobalFeature(t,e)))||(i.remove(t),0===i.length&&e.delete(o))})):(i.removeAll(),e.delete(o))})),t.forEach(((t,a)=>{const l=e.get(a)||new s;t?.filter(Boolean).forEach((e=>{l.some((t=>this._matchesGlobalFeature(t,e)))||l.add({association:e.association,featureViewModel:new Y({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:o,spatialReference:r,timeZone:n,graphic:e.feature}),terminalName:e.terminalName})})),e.set(a,l)}));const a=new AbortController;this._associationVMAbortController=a,await this._sortListObjectsByTitle(e,{signal:a.signal}),this._associationVMAbortController===a&&(this._associationVMAbortController=null)}async _sortListObjectsByTitle(e,t){for(const i of e.values()){const e=i.map((e=>u((()=>"ready"===e.featureViewModel.state),t?.signal)));await Promise.all(e),i.sort(this._compareByFeatureTitle)}}_compareByFeatureTitle(e,t){const i=w(e.featureViewModel),o=w(t.featureViewModel);return i.localeCompare(o,void 0,{numeric:!0})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:o,description:r,associationTypes:s}=e,{_sourceLayer:n,graphic:a,map:l}=this;if(!O(n))return;const c=new X({graphic:a,displayCount:i,associationTypes:s,layer:n,map:l,...this._compileTitleAndDesc({title:o,description:r})});return this.contentViewModels[t]=c,this.addHandles([p((()=>c.associationFeatures.values()),(()=>this._setUpUtilityNetworkAssociationsViewModels(c.associationViewModels,c.associationFeatures,c.map)))],ie),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:o,map:r,spatialReference:s,view:n,location:a}=this,l=new F({expressionInfo:i,graphic:o,interceptor:Y.interceptor,map:r,spatialReference:s,view:n,location:a});return this.contentViewModels[t]=l,this.addHandles(p((()=>l.contentElementViewModel),(()=>this._setExpressionContentVM(l,t)),h),ee),e}_compileAttachments(e,t){const{graphic:i}=this,{description:o,title:r,orderByFields:s}=e;return this.contentViewModels[t]=new M({graphic:i,orderByFields:s,...this._compileTitleAndDesc({title:r,description:o})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:o,destroyer:r}=e;return this.contentViewModels[t]=new v({graphic:i,creator:o,destroyer:r}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:o,graphic:r,formattedAttributes:s}=this,n=r?.attributes,a=this._expressionAttributes,l=s.global;return{title:Z({attributes:n,fieldInfoMap:i,globalAttributes:l,expressionAttributes:a,layer:o,text:e}),description:Z({attributes:n,fieldInfoMap:i,globalAttributes:l,expressionAttributes:a,layer:o,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,o=this.formattedAttributes,r={...o?.global,...o?.content[t]},s=e?.fieldInfos||i?.fieldInfos,n=s?.filter((({fieldName:e})=>!!e&&(k(e)||N(e)||r.hasOwnProperty(e)))),a=i?.expressionInfos,{description:l,title:c}=e;return{attributes:r,expressionInfos:a,fieldInfos:n,...this._compileTitleAndDesc({title:c,description:l})}}_compileFields(e,t){const i=e.clone(),o=new C(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=o,i.fieldInfos=o.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:o,_fieldInfoMap:r,_effectivePopupTemplate:s,relatedInfos:n,_sourceLayer:a,_expressionAttributes:l}=this,c=this.formattedAttributes,p=o?.attributes??{},{description:d,mediaInfos:u,title:h}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:p,isAggregate:o?.isAggregate,layer:a,fieldInfoMap:r,formattedAttributes:{...c?.global,...c?.content[t]},expressionAttributes:l,mediaInfos:u,popupTemplate:s,relatedInfos:n,...this._compileTitleAndDesc({title:h,description:d})}}_compileMedia(e,t){const i=e.clone(),o=new x(this._createMediaVMParams(e,t));return i.mediaInfos=o.formattedMediaInfos.slice(),this.contentViewModels[t]=o,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:o,_expressionAttributes:r}=this;if(e&&e.text){const s=t?.attributes??{},n=this.formattedAttributes?.global??{};e.text=Z({attributes:s,fieldInfoMap:i,globalAttributes:n,expressionAttributes:r,layer:o,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new v(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:o}=this;if(!e)return;const{lastEditInfoEnabled:r}=e,s=t?.editFieldsInfo;return r&&s?U(s,i?.attributes,o,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:o,_expressionAttributes:r}=this,s=o?.attributes??{},n=this.formattedAttributes?.global??{};return Z({attributes:s,fieldInfoMap:t,globalAttributes:n,expressionAttributes:r,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?B({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?B({type:"content",value:e?.content,event:{graphic:t}}):null}async _queryFeature(e){const{_featureAbortController:t,_sourceLayer:i,graphic:o,_effectivePopupTemplate:r}=this,s=this.map,n=this.view,a=this.spatialReference,l=this.location;if(t!==this._featureAbortController||!o)return;await S({graphic:o,popupTemplate:r,layer:i,spatialReference:a},e);const{content:{value:p},title:{value:d}}=await c({content:this._getContent(),title:this._getTitle()}),{expressionAttributes:{value:u}}=await c({checkForRelatedFeatures:this._checkForRelatedFeatures(e),expressionAttributes:T({expressionInfos:r?.expressionInfos,spatialReference:a,graphic:o,map:s,interceptor:Y.interceptor,view:n,options:e,location:l})});t===this._featureAbortController&&o&&(this._expressionAttributes=u,this._graphicExpressionAttributes={...o.attributes,...u},this._set("formattedAttributes",this._createFormattedAttributes(p)),this._set("title",this._compileTitle(d)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(p)||null))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:o,graphic:r,relatedInfos:s,_sourceLayer:n,_fieldInfoMap:a,_graphicExpressionAttributes:l,timeZone:c}=this;i.content[t]=H({fieldInfos:o?.fieldInfos,graphic:r,attributes:{...l,...e.attributes},layer:n,fieldInfoMap:a,relatedInfos:s,timeZone:c})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:o,relatedInfos:r,_sourceLayer:s,_fieldInfoMap:n,_graphicExpressionAttributes:a,timeZone:l}=this;i.content[t]=H({fieldInfos:e.fieldInfos,graphic:o,attributes:{...a,...e.attributes},layer:s,fieldInfoMap:n,relatedInfos:r,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:s,_graphicExpressionAttributes:n,timeZone:a}=this,l=t?.fieldInfos,c={global:H({fieldInfos:l,graphic:i,attributes:n,layer:r,fieldInfoMap:s,relatedInfos:o,timeZone:a}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:c}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:c})})),c}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,j(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:o,_sourceLayer:r}=this;o.clear();const s=null!=r?.associatedLayer?await(r?.associatedLayer.load(i)):r;if(!s||!e)return;const n=t.filter((e=>!!e.fieldName&&N(e.fieldName)));if(!n?.length)return;t.forEach((e=>this._configureRelatedInfo(e,s)));const a=await q({relatedInfos:o,layer:s},i);Object.keys(a).forEach((e=>{const t=o.get(e.toString()),i=a[e]?.value;t&&i&&(t.layerInfo=i.data)}));const l=await Q({graphic:e,relatedInfos:o,layer:s},i);Object.keys(l).forEach((e=>{z(l[e]?.value,o.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,o=J(e.fieldName||"");if(!o)return;const{layerId:r,fieldName:s}=o;if(!r)return;const n=i.get(r.toString())||K(r,t);n&&(W({relatedInfo:n,fieldName:s,fieldInfo:e}),this.relatedInfos.set(r,n))}};re.interceptor=new i(D,G),e([m()],re.prototype,"_error",void 0),e([m()],re.prototype,"_featureAbortController",void 0),e([m()],re.prototype,"_associationVMAbortController",void 0),e([m({readOnly:!0})],re.prototype,"_effectivePopupTemplate",null),e([m({readOnly:!0})],re.prototype,"_fieldInfoMap",null),e([m({readOnly:!0})],re.prototype,"_sourceLayer",null),e([m()],re.prototype,"abilities",void 0),e([_("abilities")],re.prototype,"castAbilities",null),e([m({readOnly:!0})],re.prototype,"content",void 0),e([m({readOnly:!0})],re.prototype,"contentViewModels",void 0),e([m()],re.prototype,"description",void 0),e([m({type:Boolean})],re.prototype,"defaultPopupTemplateEnabled",void 0),e([m({readOnly:!0})],re.prototype,"isTable",null),e([m({readOnly:!0})],re.prototype,"state",null),e([m({readOnly:!0})],re.prototype,"formattedAttributes",void 0),e([m({type:t,value:null})],re.prototype,"graphic",null),e([m({readOnly:!0})],re.prototype,"lastEditInfo",void 0),e([m({type:b})],re.prototype,"location",void 0),e([m({readOnly:!0})],re.prototype,"relatedInfos",void 0),e([m({type:g})],re.prototype,"spatialReference",null),e([m()],re.prototype,"timeZone",null),e([m({readOnly:!0})],re.prototype,"title",void 0),e([m()],re.prototype,"map",null),e([m({readOnly:!0})],re.prototype,"waitingForContent",null),e([m()],re.prototype,"view",void 0),re=Y=e([y("esri.widgets.Feature.FeatureViewModel")],re);const se=re;export{se as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import s from"../../core/Accessor.js";import{isSome as o}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import n from"../../core/Identifiable.js";import l from"../../core/Logger.js";import{abortMaybe as p}from"../../core/maybe.js";import{eachAlways as c,isAbortError as d,throwIfAborted as h}from"../../core/promiseUtils.js";import{watch as u,when as f,on as m,whenOnce as _,initial as y}from"../../core/reactiveUtils.js";import{throttle as g}from"../../core/throttle.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import{cast as w}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import A from"../../geometry/Point.js";import I from"../../geometry/SpatialReference.js";import M from"../../popup/content/TextContent.js";import{getFeaturePopupTitle as x}from"../../support/popupUtils.js";import{system as T}from"../../time/timeZoneUtils.js";import C from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import E from"./FeatureContent/FeatureContentViewModel.js";import F from"./FeatureExpression/FeatureExpressionViewModel.js";import V from"./FeatureFields/FeatureFieldsViewModel.js";import j from"./FeatureMedia/FeatureMediaViewModel.js";import k from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{compileExpressionInfos as P,formatArcadeValue as R}from"./support/arcadeFeatureUtils.js";import{createFieldInfoMap as L,getAllFieldInfos as O,getSourceLayer as U,querySourceLayer as Z,isRelatableFeatureSupportedLayer as N,isAssociatedFeatureSupportedLayer as B,substituteFieldsInLinksAndAttributes as S,isExpressionField as H,isRelatedField as D,formatEditInfo as G,graphicCallback as q,formatAttributes as z,preLayerQueryCallback as Q,preRequestCallback as J,queryUpdatedFeature as K}from"./support/featureUtils.js";import{queryLayerInfos as W,queryRelatedFeatures as X,setRelatedFeatures as Y,getRelatedFieldInfo as $,createRelatedInfo as ee,updateRelatedInfo as te}from"./support/relatedFeatureUtils.js";import ie from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";var se;const oe=1,re="content-view-models",ae="relationship-view-models",ne="association-view-models",le={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let pe=se=class extends(n.IdentifiableMixin(s)){constructor(e){super(e),this._error=null,this._graphicChangedTask=null,this._evaluateExpressionAttributesTask=null,this._associationVMAbortController=null,this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...le},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._graphicChangedThrottled=g(this._graphicChanged,(()=>this.notifyChange("waitingForContent")),oe,this),this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this._evaluateExpressionAttributesThrottled=g(this._evaluateExpressionAttributes,(()=>this.notifyChange("waitingForContent")),oe,this),this.addHandles([u((()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone]),(()=>this._graphicChangedThrottled()),y),f((()=>{if(!this._graphicChangedTask?.finished||null==this._graphicChangedTask.value)return null;const e=this._graphicChangedTask.value,t=e?.expressionInfos?.dependencies;return[e,t?.has("view-scale")?this.view?.scale:null,t?.has("view-time-extent")?this.view?.timeExtent?.start:null,t?.has("view-time-extent")?this.view?.timeExtent?.end:null]}),(([e])=>this._evaluateExpressionAttributesThrottled(e)))])}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=p(this._graphicChangedTask),this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return L(O(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return U(this.graphic)}castAbilities(e){return{...le,...e}}get isTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._set("graphic",e?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??T}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){const{_graphicChangedThrottled:e,_evaluateExpressionAttributesThrottled:t,_graphicChangedTask:i,_evaluateExpressionAttributesTask:s,_associationVMAbortController:o}=this;return e.hasPendingUpdates()||t.hasPendingUpdates()||null!=i&&!i.finished||null!=s&&!s.finished||!!o}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof j&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof j&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof j&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const s=i?.objectIdField;if(!s||!e||!i)return;const o=e?.attributes?.[s];if(null==o)return;const r=[o];if(!e.geometry){const s=await Z({layer:i,graphic:e,outFields:[],objectIds:r,returnGeometry:!0,spatialReference:t}),o=s?.geometry;o&&(e.geometry=o)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}_graphicChanged(){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._graphicChangedTask=p(this._graphicChangedTask),this._graphicChangedTask=r((async e=>{this._error=null,this._clear();const{graphic:t}=this;try{if(!t)return null;const{_sourceLayer:i,_effectivePopupTemplate:s}=this,o=this.spatialReference;await K({graphic:t,popupTemplate:s,layer:i,spatialReference:o},{signal:e});const[{value:r},{value:a}]=await c([this._getContent(),this._getTitle()]),[,{value:n}]=await c([this._checkForRelatedFeatures({signal:e}),P(s?.expressionInfos,t)]);return{expressionInfos:n,content:r,title:a}}catch(i){throw d(i)||(this._error=i,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:t,popupTemplate:this._effectivePopupTemplate})),i}}))}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(((e,t)=>this._compileContentElement(e,t))).filter(o):"string"==typeof e?this._compileText(new M({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(ae),this.removeHandles(re),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),s=t?.getObjectId();return null!=i&&null!=s&&i===s}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:s,spatialReference:o,timeZone:r}=this;t?.filter(Boolean).forEach((t=>{e.some((e=>this._matchesFeature(e,t)))||e.add(new se({abilities:{relationshipContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:t}))})),e.forEach((i=>{const s=t?.find((e=>this._matchesFeature(i,e)));s||e.remove(i)}))}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:s,contentElementViewModel:o}=e,r=s?.type;o&&r&&("fields"===r&&(this._createFieldsFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createFieldsVMParams(s,t))),"media"===r&&(this._createMediaFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createMediaVMParams(s,t))),"text"===r&&o.set(this._createTextVMParams(s)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:s,relationshipId:o,title:r,description:a}=e,{_sourceLayer:n,graphic:l,map:p}=this;if(!N(n))return;const c=new k({displayCount:i,graphic:l,orderByFields:s,relationshipId:o,layer:n,map:p,...this._compileTitleAndDesc({title:r,description:a})});return this.contentViewModels[t]=c,this.addHandles(m((()=>c.relatedFeatures),"change",(()=>this._setRelatedFeaturesViewModels(c))),ae),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,s=t?.association.globalId;return null!=i&&null!=s&&i===s}async _setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:s,spatialReference:o,timeZone:r}=this;e.forEach(((i,s)=>{const o=t.get(s);o?i.forEach((t=>{o.find((e=>this._matchesGlobalFeature(t,e)))||(i.remove(t),0===i.length&&e.delete(s))})):(i.removeAll(),e.delete(s))})),t.forEach(((t,n)=>{const l=e.get(n)||new a;t?.filter(Boolean).forEach((e=>{l.some((t=>this._matchesGlobalFeature(t,e)))||l.add({association:e.association,featureViewModel:new se({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:e.feature}),terminalName:e.terminalName})})),e.set(n,l)}));const n=new AbortController;this._associationVMAbortController=n,await this._sortListObjectsByTitle(e,{signal:n.signal}),this._associationVMAbortController===n&&(this._associationVMAbortController=null)}async _sortListObjectsByTitle(e,t){for(const i of e.values()){const e=i.map((e=>_((()=>"ready"===e.featureViewModel.state),t?.signal)));await Promise.all(e),i.sort(this._compareByFeatureTitle)}}_compareByFeatureTitle(e,t){const i=x(e.featureViewModel),s=x(t.featureViewModel);return i.localeCompare(s,void 0,{numeric:!0})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:s,description:o,associationTypes:r}=e,{_sourceLayer:a,graphic:n,map:l}=this;if(!B(a))return;const p=new ie({graphic:n,displayCount:i,associationTypes:r,layer:a,map:l,...this._compileTitleAndDesc({title:s,description:o})});return this.contentViewModels[t]=p,this.addHandles([u((()=>p.associationFeatures.values()),(()=>this._setUpUtilityNetworkAssociationsViewModels(p.associationViewModels,p.associationFeatures,p.map)))],ne),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:s,map:o,spatialReference:r,view:a,location:n}=this,l=new F({expressionInfo:i,graphic:s,interceptor:se.interceptor,map:o,spatialReference:r,view:a,location:n});return this.contentViewModels[t]=l,this.addHandles(u((()=>l.contentElementViewModel),(()=>this._setExpressionContentVM(l,t)),y),re),e}_compileAttachments(e,t){const{graphic:i}=this,{description:s,title:o,orderByFields:r}=e;return this.contentViewModels[t]=new C({graphic:i,orderByFields:r,...this._compileTitleAndDesc({title:o,description:s})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:s,destroyer:o}=e;return this.contentViewModels[t]=new E({graphic:i,creator:s,destroyer:o}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:s,graphic:o,formattedAttributes:r}=this,a=o?.attributes,n=this._expressionAttributes,l=r.global;return{title:S({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:e}),description:S({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,s=this.formattedAttributes,o={...s?.global,...s?.content[t]},r=e?.fieldInfos||i?.fieldInfos,a=r?.filter((({fieldName:e})=>!!e&&(H(e)||D(e)||o.hasOwnProperty(e)))),n=i?.expressionInfos,{description:l,title:p}=e;return{attributes:o,expressionInfos:n,fieldInfos:a,...this._compileTitleAndDesc({title:p,description:l})}}_compileFields(e,t){const i=e.clone(),s=new V(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=s,i.fieldInfos=s.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:s,_fieldInfoMap:o,_effectivePopupTemplate:r,relatedInfos:a,_sourceLayer:n,_expressionAttributes:l}=this,p=this.formattedAttributes,c=s?.attributes??{},{description:d,mediaInfos:h,title:u}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:c,isAggregate:s?.isAggregate,layer:n,fieldInfoMap:o,formattedAttributes:{...p?.global,...p?.content[t]},expressionAttributes:l,mediaInfos:h,popupTemplate:r,relatedInfos:a,...this._compileTitleAndDesc({title:u,description:d})}}_compileMedia(e,t){const i=e.clone(),s=new j(this._createMediaVMParams(e,t));return i.mediaInfos=s.formattedMediaInfos.slice(),this.contentViewModels[t]=s,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:s,_expressionAttributes:o}=this;if(e&&e.text){const r=t?.attributes??{},a=this.formattedAttributes?.global??{};e.text=S({attributes:r,fieldInfoMap:i,globalAttributes:a,expressionAttributes:o,layer:s,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new E(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:s}=this;if(!e)return;const{lastEditInfoEnabled:o}=e,r=t?.editFieldsInfo;return o&&r?G(r,i?.attributes,s,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:s,_expressionAttributes:o}=this,r=s?.attributes??{},a=this.formattedAttributes?.global??{};return S({attributes:r,fieldInfoMap:t,globalAttributes:a,expressionAttributes:o,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?q({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?q({type:"content",value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({title:e,content:t,expressionInfos:i}){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=r((async s=>{const{graphic:o,map:r,view:a,spatialReference:n,location:p}=this;try{if(!o)return;let l;if(null!=i){const e=[];for(const[t,l]of i.expressions.entries())null!=l?e.push(l.evaluate({graphic:o,interceptor:se.interceptor,location:p,map:r,options:{signal:s},spatialReference:n,view:a}).then((e=>[t,R(e)])).catch((()=>[t,void 0]))):e.push(Promise.resolve([t,void 0]));l=Object.fromEntries(await Promise.all(e)),h(s)}this._expressionAttributes=l,this._graphicExpressionAttributes={...o.attributes,...l},this._set("formattedAttributes",this._createFormattedAttributes(t)),this._set("title",this._compileTitle(e)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(t)||null)}catch(c){d(c)||(this._error=c,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:c,graphic:o,popupTemplate:this._effectivePopupTemplate}))}}))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:s,graphic:o,relatedInfos:r,_sourceLayer:a,_fieldInfoMap:n,_graphicExpressionAttributes:l,timeZone:p}=this;i.content[t]=z({fieldInfos:s?.fieldInfos,graphic:o,attributes:{...l,...e.attributes},layer:a,fieldInfoMap:n,relatedInfos:r,timeZone:p})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:s,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:a,_graphicExpressionAttributes:n,timeZone:l}=this;i.content[t]=z({fieldInfos:e.fieldInfos,graphic:s,attributes:{...n,...e.attributes},layer:r,fieldInfoMap:a,relatedInfos:o,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:s,_sourceLayer:o,_fieldInfoMap:r,_graphicExpressionAttributes:a,timeZone:n}=this,l=t?.fieldInfos,p={global:z({fieldInfos:l,graphic:i,attributes:a,layer:o,fieldInfoMap:r,relatedInfos:s,timeZone:n}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p})})),p}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,O(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:s,_sourceLayer:o}=this;s.clear();const r=null!=o?.associatedLayer?await(o?.associatedLayer.load(i)):o;if(!r||!e)return;const a=t.filter((e=>!!e.fieldName&&D(e.fieldName)));if(!a?.length)return;t.forEach((e=>this._configureRelatedInfo(e,r)));const n=await W({relatedInfos:s,layer:r},i);Object.keys(n).forEach((e=>{const t=s.get(e.toString()),i=n[e]?.value;t&&i&&(t.layerInfo=i.data)}));const l=await X({graphic:e,relatedInfos:s,layer:r},i);Object.keys(l).forEach((e=>{Y(l[e]?.value,s.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,s=$(e.fieldName||"");if(!s)return;const{layerId:o,fieldName:r}=s;if(!o)return;const a=i.get(o.toString())||ee(o,t);a&&(te({relatedInfo:a,fieldName:r,fieldInfo:e}),this.relatedInfos.set(o,a))}};pe.interceptor=new i(Q,J),e([b()],pe.prototype,"_error",void 0),e([b()],pe.prototype,"_graphicChangedTask",void 0),e([b()],pe.prototype,"_evaluateExpressionAttributesTask",void 0),e([b()],pe.prototype,"_associationVMAbortController",void 0),e([b({readOnly:!0})],pe.prototype,"_effectivePopupTemplate",null),e([b({readOnly:!0})],pe.prototype,"_fieldInfoMap",null),e([b({readOnly:!0})],pe.prototype,"_sourceLayer",null),e([b()],pe.prototype,"abilities",void 0),e([w("abilities")],pe.prototype,"castAbilities",null),e([b({readOnly:!0})],pe.prototype,"content",void 0),e([b({readOnly:!0})],pe.prototype,"contentViewModels",void 0),e([b()],pe.prototype,"description",void 0),e([b({type:Boolean})],pe.prototype,"defaultPopupTemplateEnabled",void 0),e([b({readOnly:!0})],pe.prototype,"isTable",null),e([b({readOnly:!0})],pe.prototype,"state",null),e([b({readOnly:!0})],pe.prototype,"formattedAttributes",void 0),e([b({type:t,value:null})],pe.prototype,"graphic",null),e([b({readOnly:!0})],pe.prototype,"lastEditInfo",void 0),e([b({type:A})],pe.prototype,"location",void 0),e([b({readOnly:!0})],pe.prototype,"relatedInfos",void 0),e([b({type:I})],pe.prototype,"spatialReference",null),e([b()],pe.prototype,"timeZone",null),e([b({readOnly:!0})],pe.prototype,"title",void 0),e([b()],pe.prototype,"map",null),e([b({readOnly:!0})],pe.prototype,"waitingForContent",null),e([b()],pe.prototype,"view",void 0),pe=se=e([v("esri.widgets.Feature.FeatureViewModel")],pe);const ce=pe;export{ce as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{isSupportedLayer as e}from"../../../arcade/featureset/support/shared.js";import r from"../../../core/Logger.js";import{eachAlways as t}from"../../../core/promiseUtils.js";import a from"../../../layers/FeatureLayer.js";import{applyTextFormattingHTML as o,htmlEntities as i}from"./featureUtils.js";import{globalCss as n}from"../../support/globalCss.js";const s="esri.widgets.Feature.support.arcadeFeatureUtils",p=()=>r.getLogger(s);function c(e){return"string"==typeof e?o(i(e)):Array.isArray(e)?l(e):"esri.arcade.Dictionary"===e?.declaredClass?u(e):e}function l(e){return`<ul class="esri-widget__list">${e.map((e=>`<li>${"string"==typeof e?o(i(e)):e}</li>`)).join("")}</ul>`}function u(e){const r=e.keys().map((r=>{const t=e.field(r);return`<tr><th>${r}</th><td>${"string"==typeof t?o(i(t)):t}</td></tr>`})).join("");return`<table class="${n.table}">${r}</table>`}function d(){return import("../../../arcade.js")}function f(e){return"createQuery"in e&&"queryFeatures"in e}async function g({graphic:e,view:r,options:t}){const{isAggregate:a,layer:o}=e;if(!a||!o||"2d"!==r?.type)return[];const i=await r.whenLayerView(o);if(!f(i))return[];const n=i.createQuery(),s=e.getObjectId();n.aggregateIds=null!=s?[s]:[];const{features:p}=await i.queryFeatures(n,t);return p}function y({layer:e,aggregatedFeatures:r,interceptor:t}){const{fields:o,objectIdField:i,geometryType:n,spatialReference:s,displayField:p}=e;return new a({fields:o,objectIdField:i,geometryType:n,spatialReference:s,displayField:p,interceptor:t,..."feature"===e.type?{templates:e.templates,typeIdField:e.typeIdField,types:e.types}:null,source:r})}async function m({expressionInfo:r,arcade:t,interceptor:a,spatialReference:o,map:i,graphic:n,location:s,view:c,options:l}){if(!r?.expression)return null;const{isAggregate:u}=n,d=(n.sourceLayer||n.layer)??void 0,f="esri.views.3d.layers.VoxelGraphic"===n.declaredClass,m=u?"feature-reduction-popup":f?"popup-voxel":"popup",w=t.createArcadeProfile(m),h=t.createArcadeExecutor(r.expression,w).catch((e=>p().error("arcade-executor-error",{error:e,expressionInfo:r}))),[v,x]=await Promise.all([g({graphic:n,view:c,options:l}),h]);if(!x)return null;const $="feature-reduction-popup"===m?y({layer:d,aggregatedFeatures:v,interceptor:a}):void 0,F="feature-reduction-popup"===m?{$aggregatedFeatures:$}:{$datastore:d?.url,$layer:null!=d&&e(d)?d:"scene"===d?.type&&null!=d.associatedLayer?d.associatedLayer:void 0,$map:i,$userInput:s,$graph:"knowledge-graph-sublayer"===d?.type?d?.parentCompositeLayer?.knowledgeGraph:void 0};f?F.$voxel=n:F.$feature=n;const j={abortSignal:l?.signal??void 0,interceptor:a??void 0,rawOutput:!0,spatialReference:o??void 0,timeZone:c?.timeZone};return await x.executeAsync(F,j).catch((e=>p().error("arcade-execution-error",{error:e,graphic:n,expressionInfo:r}))).finally((()=>$?.destroy()))}async function w({expressionInfos:e,spatialReference:r,graphic:a,interceptor:o,map:i,view:n,location:s,options:p}){if(!e?.length)return{};const l=await d(),u={};for(const t of e)u[`expression/${t.name}`]=m({expressionInfo:t,arcade:l,interceptor:o,spatialReference:r,map:i,graphic:a,location:s,view:n,options:p});const f=await t(u),g={};for(const t in f)g[t]=c(f[t].value);return g}export{m as createCompiledExpression,w as createCompiledExpressions,d as loadArcade};
5
+ import{isSupportedLayer as e}from"../../../arcade/featureset/support/shared.js";import r from"../../../core/Logger.js";import t from"../../../layers/FeatureLayer.js";import{applyTextFormattingHTML as a,htmlEntities as n}from"./featureUtils.js";import{globalCss as s}from"../../support/globalCss.js";const o="esri.widgets.Feature.support.arcadeFeatureUtils",i=()=>r.getLogger(o);function c(e){return"string"==typeof e?a(n(e)):Array.isArray(e)?p(e):"esri.arcade.Dictionary"===e?.declaredClass?u(e):e}function p(e){return`<ul class="esri-widget__list">${e.map((e=>`<li>${"string"==typeof e?a(n(e)):e}</li>`)).join("")}</ul>`}function u(e){const r=e.keys().map((r=>{const t=e.field(r);return`<tr><th>${r}</th><td>${"string"==typeof t?a(n(t)):t}</td></tr>`})).join("");return`<table class="${s.table}">${r}</table>`}async function l(){const[e,r]=await Promise.all([import("../../../arcade.js"),import("../../../arcade/arcade.js")]);return{executor:e,syntaxUtils:r}}function d(e){return"createQuery"in e&&"queryFeatures"in e}async function y({graphic:e,view:r,options:t}){const{isAggregate:a,layer:n}=e;if(!a||!n||"2d"!==r?.type)return[];const s=await r.whenLayerView(n);if(!d(s))return[];const o=s.createQuery(),i=e.getObjectId();o.aggregateIds=null!=i?[i]:[];const{features:c}=await s.queryFeatures(o,t);return c}function f({layer:e,aggregatedFeatures:r,interceptor:a}){const{fields:n,objectIdField:s,geometryType:o,spatialReference:i,displayField:c}=e;return new t({fields:n,objectIdField:s,geometryType:o,spatialReference:i,displayField:c,interceptor:a,..."feature"===e.type?{templates:e.templates,typeIdField:e.typeIdField,types:e.types}:null,source:r})}function g(e){const r="esri.views.3d.layers.VoxelGraphic"===e.declaredClass;return e.isAggregate?"popup-feature-reduction":r?"popup-voxel":"popup"}function w(e){return{scale:e?.scale,timeProperties:{currentStart:e?.timeExtent?.start,currentEnd:e?.timeExtent?.end,startIncluded:!0,endIncluded:!0}}}function m(e){return{$voxel:e}}async function x(e,r,t,a,n){let s=null;if(n.has("$aggregatedfeatures")){const n=await y({graphic:e,view:r,options:t}),o=e.sourceLayer||e.layer;s=f({layer:o,aggregatedFeatures:n,interceptor:a})}return{vars:{$feature:e,$aggregatedFeatures:s,$view:w(r)},[Symbol.dispose]:()=>s?.[Symbol.dispose]()}}function v(r,t,a,n){const s=(r.sourceLayer||r.layer)??void 0;return{$feature:r,$layer:null!=s&&e(s)?s:"scene"===s?.type&&null!=s.associatedLayer?s.associatedLayer:void 0,$map:t,$datastore:s?.url,$userInput:a,$graph:"knowledge-graph-sublayer"===s?.type?s?.parentCompositeLayer?.knowledgeGraph:void 0,$view:w(n)}}async function h(e,{graphic:r,map:t,location:a,view:n,options:s,interceptor:o,arcadeExecutor:i}){switch(e){case"popup":return{vars:v(r,t,a,n),[Symbol.dispose](){}};case"popup-feature-reduction":{const e=new Set(i.variablesUsed);return await x(r,n,s,o,e)}case"popup-voxel":return{vars:m(r),[Symbol.dispose](){}};default:throw new Error(`Unexpected profile name ${e}`)}}async function $({expressionInfo:e,arcade:{executor:r,syntaxUtils:t},graphic:a}){const n=e?.expression;if(!n)return null;const s=g(a),o=r.createArcadeProfile(s);let c;try{c=await r.createArcadeExecutor(n,o)}catch(u){return i().error("arcade-executor-error",{error:u,expressionInfo:e}),null}const p=new Set;return c.variablesUsed.includes("$view")&&(t.scriptUsesViewProperties(c.syntaxTree,["scale"])&&p.add("view-scale"),t.scriptUsesViewProperties(c.syntaxTree,["timeProperties"])&&p.add("view-time-extent")),{dependencies:p,async evaluate({graphic:r,interceptor:t,location:a,map:n,options:o,spatialReference:p,view:l}){const d=await h(s,{graphic:r,map:n,location:a,view:l,options:o,interceptor:t,arcadeExecutor:c}),y={abortSignal:o?.signal??void 0,interceptor:t??void 0,rawOutput:!0,spatialReference:p??void 0,timeZone:l?.timeZone,console(...e){i().info(...e)}};try{return await c.executeAsync(d.vars,y)}catch(u){return void i().error("arcade-execution-error",{error:u,graphic:r,expressionInfo:e})}finally{d[Symbol.dispose]()}}}}async function b(e,r){if(!e?.length)return{dependencies:new Set,expressions:new Map};const t=await l(),a=new Set,n=new Map;for(const s of e){const e=await $({expressionInfo:s,arcade:t,graphic:r});n.set(`expression/${s.name}`,e),e?.dependencies.forEach((e=>a.add(e)))}return{dependencies:a,expressions:n}}export{$ as compileExpression,b as compileExpressionInfos,c as formatArcadeValue,l as loadArcade};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{createTask as t}from"../../../../core/asyncUtils.js";import a from"../../../../core/Promise.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.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 r}from"../../../../core/accessorSupport/decorators/subclass.js";import o from"../../../../geometry/Point.js";import{load as n}from"../../../../geometry/projection.js";import{convertSphereVertexToPixelLocation as c}from"../../../../layers/orientedImagery/transformations/utils.js";import{SketchHandlerMixin as l}from"../../mixins/SketchHandlerMixin.js";let u=[],h=[],m=0,d=class extends(l(a)){constructor(e){super(e),this.type="measurement",this.measurementArray=[],this.pixelMeasurement=0,this.pixelAreaMeasurement=0,this.polygonVertices=[],this._calculationTask=null,this._distanceCalculation=0,this._areaCalculation=null}initialize(){this.addResolvingPromise(n())}async handleCreate(e){const t=e.toolEventInfo;switch(e.tool){case"polyline":this.handlePolylineEvents(e,t);break;case"polygon":this.handlePolygonEvents(e,t)}}handleDelete(e){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}handleDestroy(){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}cursorUpdatePolylineHandler(e){const{mode:t,activeViewer:a,view:s}=this.viewModel;if("none"===t||!a?.imageSize||!s?.spatialReference)return;if("default"===t)this.measurementArray.push(e.coordinates);else{const t=c(new o(e.coordinates[0],e.coordinates[1],e.coordinates[2],s.spatialReference),a.imageSize[0],a.imageSize[1]);this.measurementArray.push([t.x,t.y])}const i=h.reduce(((e,t)=>e+t),0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=i}async cursorUpdatePolygonHandler(e){const{mode:t,activeViewer:a,view:s}=this.viewModel;if(!t||!a?.imageSize||!s?.spatialReference)return;const i=e.coordinates;if(u=[...this.polygonVertices],"default"===t)u.push(i);else{const e=c(new o(i[0],i[1],i[2],this.viewModel.view?.spatialReference),a?.imageSize[0],a?.imageSize[1]);u.push([e.x,e.y])}if(u.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const r=u[0];u=u.filter(((e,t)=>0===t||t===u.length-1||JSON.stringify(e)!==JSON.stringify(r)));const n=await this._getAreaFromTask(u);n?.area&&n?.perimeter&&(m=n.area)}async handlePolylineEvents(e,t){const a=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetDistanceMeasurements(),this.viewModel.distanceMeasurementResult=0,this.viewModel.distanceAccuracyArray=[],void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic)return this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.measurementGraphic=e.graphic,void this.resetDistanceMeasurements();switch(t?.type){case"cursor-update":this.cursorUpdatePolylineHandler(t);break;case"vertex-add":if(this.measurementArray.length&&a){const e=await this._getAccuracyFromTask();e&&this.viewModel.distanceAccuracyArray.push(e)}this.vertexUpdatePolylineHandler()}const s=await this._getDistanceFromTask();this.pixelMeasurement=s??this.pixelMeasurement}async handlePolygonEvents(e,t){const a=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetAreaMeasurements(),this.viewModel.areaMeasurementResult=0,this.viewModel.areaMeasurementAccuracy=0,void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic)return this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.measurementGraphic=e.graphic,void this.resetAreaMeasurements();switch(t?.type){case"vertex-add":await this.vertexAddPolygonHandler(t,a);break;case"cursor-update":await this.cursorUpdatePolygonHandler(t)}this.viewModel.areaMeasurementResult=m>0?m:this.pixelAreaMeasurement}async vertexAddPolygonHandler(e,t){const{mode:a,activeViewer:s}=this.viewModel,i=e.added,r=i[i.length-1];if(!Array.isArray(r)||!a||!s?.imageSize)return;if("default"===a)this.polygonVertices.push(r);else{const e=c(new o(r[0],r[1],r[2],this.viewModel.view?.spatialReference),s?.imageSize[0],s?.imageSize[1]);this.polygonVertices.push([e.x,e.y])}if(this.polygonVertices.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;if(t){const e=await this._getAreaAccuracyFromTask(this.polygonVertices);this.viewModel.areaMeasurementAccuracy=e&&e>this.viewModel.areaMeasurementAccuracy?e:this.viewModel.areaMeasurementAccuracy}const n=this.polygonVertices[0];this.polygonVertices=this.polygonVertices.filter(((e,t)=>0===t||t===this.polygonVertices.length-1||JSON.stringify(e)!==JSON.stringify(n)));const l=await this._getAreaFromTask(this.polygonVertices);if(!l?.area||!l?.perimeter)return;const{area:u}=l;this.pixelAreaMeasurement=u}vertexUpdatePolylineHandler(){this.measurementArray=this.measurementArray.slice(-1);const e=h.reduce(((e,t)=>e+t),0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&h.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,h=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,m=0}async _getAreaFromTask(e){const{mode:a}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._areaCalculation=null;const i=await this.viewModel.calculateAreaMeasurement(e,a,t);s(t),this._areaCalculation=i})),await this._calculationTask.promise,this._areaCalculation}async _getDistanceFromTask(){const{mode:e}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._distanceCalculation=0;const a=await this.viewModel.calculateDistanceMeasurement(this.measurementArray,e,t);s(t),this._distanceCalculation=a})),await this._calculationTask.promise,this._distanceCalculation}async _getAccuracyFromTask(){const{mode:e}=this.viewModel;return e?(this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._distanceCalculation=0;const a="default"===e?await this.viewModel.calculateAccuracy(this.measurementArray,"distance",t):await this.viewModel.calculateAccuracyPanoramic(this.measurementArray,"distance",t);s(t),this._distanceCalculation=a})),await this._calculationTask.promise,this._distanceCalculation):null}async _getAreaAccuracyFromTask(e){const{mode:a}=this.viewModel;return a?(this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._distanceCalculation=0;const i="default"===a?await this.viewModel.calculateAccuracy(e,"area",t):await this.viewModel.calculateAccuracyPanoramic(e,"area",t);s(t),this._distanceCalculation=i})),await this._calculationTask.promise,this._distanceCalculation):null}};e([i()],d.prototype,"type",void 0),e([i()],d.prototype,"measurementArray",void 0),e([i()],d.prototype,"pixelMeasurement",void 0),e([i()],d.prototype,"pixelAreaMeasurement",void 0),e([i()],d.prototype,"polygonVertices",void 0),d=e([r("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],d);const p=d;export{p as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{createTask as t}from"../../../../core/asyncUtils.js";import a from"../../../../core/Promise.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.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 r}from"../../../../core/accessorSupport/decorators/subclass.js";import{load as o}from"../../../../geometry/projection.js";import{convertSphereVertexToPixelLocation as n}from"../../../../layers/orientedImagery/transformations/utils.js";import{SketchHandlerMixin as c}from"../../mixins/SketchHandlerMixin.js";let l=[],u=[],h=0,m=class extends(c(a)){constructor(e){super(e),this.type="measurement",this.measurementArray=[],this.pixelMeasurement=0,this.pixelAreaMeasurement=0,this.polygonVertices=[],this._calculationTask=null,this._distanceCalculation=0,this._areaCalculation=null}initialize(){this.addResolvingPromise(o())}async handleCreate(e){const t=e.toolEventInfo;switch(e.tool){case"polyline":this.handlePolylineEvents(e,t);break;case"polygon":this.handlePolygonEvents(e,t)}}handleDelete(e){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}handleDestroy(){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}cursorUpdatePolylineHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;if("default"===t)this.measurementArray.push(e.coordinates);else{const t={x:e.coordinates[0],y:e.coordinates[1],z:e.coordinates[2]},s=n(t,a.imageSize[0],a.imageSize[1]);this.measurementArray.push([s.x,s.y])}const s=u.reduce(((e,t)=>e+t),0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=s}async cursorUpdatePolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;const s=e.coordinates;if(l=[...this.polygonVertices],"default"===t)l.push(s);else{const e={x:s[0],y:s[1],z:s[2]},t=n(e,a?.imageSize[0],a?.imageSize[1]);l.push([t.x,t.y])}if(l.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const i=l[0];l=l.filter(((e,t)=>0===t||t===l.length-1||JSON.stringify(e)!==JSON.stringify(i)));const r=await this._getAreaFromTask(l);r?.area&&r?.perimeter&&(h=r.area)}async handlePolylineEvents(e,t){const a=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetDistanceMeasurements(),this.viewModel.distanceMeasurementResult=0,this.viewModel.distanceAccuracyArray=[],void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic)return this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.measurementGraphic=e.graphic,void this.resetDistanceMeasurements();switch(t?.type){case"cursor-update":this.cursorUpdatePolylineHandler(t);break;case"vertex-add":if(this.measurementArray.length&&a){const e=await this._getAccuracyFromTask();e&&this.viewModel.distanceAccuracyArray.push(e)}this.vertexUpdatePolylineHandler()}const s=await this._getDistanceFromTask();this.pixelMeasurement=s??this.pixelMeasurement}async handlePolygonEvents(e,t){const a=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetAreaMeasurements(),this.viewModel.areaMeasurementResult=0,this.viewModel.areaMeasurementAccuracy=0,void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic)return this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.measurementGraphic=e.graphic,void this.resetAreaMeasurements();switch(t?.type){case"vertex-add":await this.vertexAddPolygonHandler(t,a);break;case"cursor-update":await this.cursorUpdatePolygonHandler(t)}this.viewModel.areaMeasurementResult=h>0?h:this.pixelAreaMeasurement}async vertexAddPolygonHandler(e,t){const{mode:a,activeViewer:s}=this.viewModel,i=e.added,r=i[i.length-1];if(!Array.isArray(r)||"none"===a||!s?.imageSize)return;if("default"===a)this.polygonVertices.push(r);else{const e={x:r[0],y:r[1],z:r[2]},t=n(e,s?.imageSize[0],s?.imageSize[1]);this.polygonVertices.push([t.x,t.y])}if(this.polygonVertices.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;if(t){const e=await this._getAreaAccuracyFromTask(this.polygonVertices);this.viewModel.areaMeasurementAccuracy=e&&e>this.viewModel.areaMeasurementAccuracy?e:this.viewModel.areaMeasurementAccuracy}const o=this.polygonVertices[0];this.polygonVertices=this.polygonVertices.filter(((e,t)=>0===t||t===this.polygonVertices.length-1||JSON.stringify(e)!==JSON.stringify(o)));const c=await this._getAreaFromTask(this.polygonVertices);if(!c?.area||!c?.perimeter)return;const{area:l}=c;this.pixelAreaMeasurement=l}vertexUpdatePolylineHandler(){this.measurementArray=this.measurementArray.slice(-1);const e=u.reduce(((e,t)=>e+t),0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&u.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,u=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,h=0}async _getAreaFromTask(e){const{mode:a}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._areaCalculation=null;const i=await this.viewModel.calculateAreaMeasurement(e,a,t);s(t),this._areaCalculation=i})),await this._calculationTask.promise,this._areaCalculation}async _getDistanceFromTask(){const{mode:e}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._distanceCalculation=0;const a=await this.viewModel.calculateDistanceMeasurement(this.measurementArray,e,t);s(t),this._distanceCalculation=a})),await this._calculationTask.promise,this._distanceCalculation}async _getAccuracyFromTask(){const{mode:e}=this.viewModel;return"none"===e?null:(this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._distanceCalculation=0;const a="default"===e?await this.viewModel.calculateAccuracy(this.measurementArray,"distance",t):await this.viewModel.calculateAccuracyPanoramic(this.measurementArray,"distance",t);s(t),this._distanceCalculation=a})),await this._calculationTask.promise,this._distanceCalculation)}async _getAreaAccuracyFromTask(e){const{mode:a}=this.viewModel;return"none"===a?null:(this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._distanceCalculation=0;const i="default"===a?await this.viewModel.calculateAccuracy(e,"area",t):await this.viewModel.calculateAccuracyPanoramic(e,"area",t);s(t),this._distanceCalculation=i})),await this._calculationTask.promise,this._distanceCalculation)}};e([i()],m.prototype,"type",void 0),e([i()],m.prototype,"measurementArray",void 0),e([i()],m.prototype,"pixelMeasurement",void 0),e([i()],m.prototype,"pixelAreaMeasurement",void 0),e([i()],m.prototype,"polygonVertices",void 0),m=e([r("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],m);const d=m;export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{substitute as r}from"../../../intl/substitute.js";import s from"../../Widget.js";import{css as i}from"../css.js";import{copyToClipboard as n}from"../imageMeasurementUtils.js";import{loadCalciteComponents as c}from"../../support/componentsUtils.js";import{tsx as a}from"../../support/jsxFactory.js";let p=class extends s{constructor(o){super(o),this.messages=null}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel")})}get _renderLocation(){const{groundCoordinates:o}=this;return o?a("calcite-block",{heading:this.getLocation(),headingLevel:6},a("calcite-action",{icon:"copy-to-clipboard",onclick:()=>this.copyLocation(),slot:"control",text:"Copy"})):null}copyLocation(){const{groundCoordinates:o}=this;if(!o)return;const t=this.getLocation();t&&n(t)}getLocation(){const{groundCoordinates:o}=this;if(!o?.longitude||!o?.latitude)return"";const t={groundX:o.longitude.toFixed(3),groundY:o.latitude.toFixed(3)};return r("{groundX}° , {groundY}°",t)}render(){return a("calcite-panel",{class:i.measurementResults,key:"ground-location-container"},this._renderLocation)}};o([t()],p.prototype,"messages",void 0),o([t()],p.prototype,"groundCoordinates",void 0),o([t()],p.prototype,"_renderLocation",null),p=o([e("esri.widgets.OrientedImageryViewer.components.ImageLocationWidget")],p);const d=p;export{d as default};
5
+ import{_ as o}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{substitute as r}from"../../../intl/substitute.js";import s from"../../Widget.js";import{css as n}from"../css.js";import{copyToClipboard as i}from"../imageMeasurementUtils.js";import{loadCalciteComponents as c}from"../../support/componentsUtils.js";import{tsx as a}from"../../support/jsxFactory.js";let p=class extends s{constructor(o){super(o),this.messages=null}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel")})}get _renderLocation(){const{groundCoordinates:o}=this;return o?a("calcite-block",{heading:this.getLocation(),headingLevel:6},a("calcite-action",{icon:"copy-to-clipboard",onclick:()=>this.copyLocation(),slot:"control",text:"Copy"})):null}copyLocation(){const{groundCoordinates:o}=this;if(!o)return;const t=this.getLocation();t&&i(t)}getLocation(){const{groundCoordinates:o}=this;if(null==o?.longitude||null==o?.latitude)return"";const t={groundX:o.longitude.toFixed(3),groundY:o.latitude.toFixed(3)};return r("{groundX}° , {groundY}°",t)}render(){return a("calcite-panel",{class:n.measurementResults,key:"ground-location-container"},this._renderLocation)}};o([t()],p.prototype,"messages",void 0),o([t()],p.prototype,"groundCoordinates",void 0),o([t()],p.prototype,"_renderLocation",null),p=o([e("esri.widgets.OrientedImageryViewer.components.ImageLocationWidget")],p);const l=p;export{l as default};
package/widgets/Sketch.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{handlesGroup as o}from"../core/handleUtils.js";import i from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as l}from"../core/maybe.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as n,syncAndInitial as a,when as c}from"../core/reactiveUtils.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import u from"../views/interactive/sketch/SketchValueOptions.js";import h from"./Widget.js";import v from"./Sketch/SketchViewModel.js";import{VisibleElements as m}from"./Sketch/VisibleElements.js";import f from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import _ from"./support/SelectionToolbar.js";import y from"./support/SketchTooltipControls.js";import b from"./support/SnappingControls.js";import"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{vmEvent as w}from"./support/decorators/vmEvent.js";import{tsx as M}from"./support/jsxFactory.js";import O from"./support/SketchTooltipControls/VisibleElements.js";import{substitute as C}from"../intl/substitute.js";const k="esri-sketch",S={base:k,vertical:`${k}--vertical`,docked:`${k}-bar`,chipHorizontal:`${k}__selection-count-chip--horizontal`,chipVertical:`${k}__selection-count-chip--vertical`,chipVerticalSmall:`${k}__selection-count-chip--vertical--s`,popoverWrapper:`${k}__popover-wrapper`},I={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3-d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand"};let P=class extends h{constructor(e,t){super(e,t),this._activeCustomToolOptions=null,this._selectionToolbar=null,this._viewModelHandlesGroup=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.messages=null,this.messagesCommon=null,this.visibleElements=new m,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||new v({creationMode:e?.creationMode??"continuous"})}initialize(){const{layer:e,view:t}=this,i=new _({view:"2d"===t?.type?t:null,sources:e?[e]:null,scale:this.scale});this.addHandles([n((()=>this.viewModel),(e=>{this._viewModelHandlesGroup=s(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=o([e.on("create",(()=>this.scheduleRender())),e.on("update",(()=>this.scheduleRender())),e.on("delete",(e=>this.emit("delete",e))),e.on("undo",(()=>this.scheduleRender())),e.on("redo",(()=>this.scheduleRender())),n((()=>e.layer),(e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)})),n((()=>e.view),(e=>{this._selectionToolbar&&(this._selectionToolbar.view="2d"===e?.type?e:null)})),n((()=>e.state),(()=>this.notifyChange("state")))]))}),a),c((()=>i.activeToolInfo),(()=>this.viewModel.cancel())),i.on("complete",(e=>this._onSelectionOperationComplete(e))),n((()=>{const{selectionTools:e}=this.visibleElements;return{lassoTool:!!e?.["lasso-selection"],rectangleTool:!!e?.["rectangle-selection"]}}),(e=>{Object.assign(i.visibleElements,e)}),a)]),this._selectionToolbar=i}loadDependencies(){return g({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=s(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeToolInfo;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const t=this._effectiveAvailableCreateTools,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeToolInfo?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&l(t),this._set("viewModel",e))}get _effectiveAvailableCreateTools(){const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter((e=>!!o.createTools?.[e]));return"3d"===t?.type?i?.filter((e=>"multipoint"!==e)):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,r(this.viewModel.create(e,i))}update(e,t){return r(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this,i=this.customActions?.filter((e=>"selection-toolbar"===e.position));return M("div",null,M("div",{classes:{[S.base]:!0,[S.docked]:"docked"===e,[S.vertical]:"vertical"===t}},M(f,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),M("div",{"group-kind":"split-button",key:"selection-split-button",priority:0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),i?.map((e=>this._renderToolbarItem(e)))),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:s}=this;if(!this._calcitePopoverReferenceElement)return;const l={directionModePicker:s.directionModePicker,labelsToggle:s.labelsToggle,tooltipsToggle:s.tooltipsToggle},r="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return M("calcite-popover",{closable:!0,focusTrapDisabled:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:r,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,onCalcitePopoverBeforeClose:()=>this._popoverOpen=!1,onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:()=>this._refocusOnView()},M("div",{class:S.popoverWrapper},Object.values(l).includes(!0)?M(y,{sketchOptions:i.sketchOptions,viewType:o?.type,visibleElements:new O(l)}):void 0,s.snappingControls&&o&&t?M(b,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:s.snappingControlsElements}):void 0))}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?M(f,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return M("div",{"group-kind":"split-button",key:"undo-redo-menu",priority:10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=this.customActions?.filter((e=>"settings-before"===e.position));return this._renderToolbarItemGroup({key:"settings-menu",elements:[e?.map((e=>this._renderToolbarItem(e))),this._renderSettingsMenuButton()],slot:"actions-end"})}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter((e=>"before-selection-set"===e.position)),o=this.customActions?.filter((e=>"after-selection-set"===e.position));return[M("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:100,slot:e},this._renderFeatureCountChip()),M("div",{"allow-collapse":!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:100,slot:e},t?.map((e=>this._renderToolbarItem(e))),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map((e=>this._renderToolbarItem(e))))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderCreateToolActionGroup(){const e=this._effectiveAvailableCreateTools?.flatMap((e=>this._renderBuiltInCreateToolItem(e)))??[],t=this.customToolOptions?.flatMap((e=>this._renderCustomToolItem(e)))??[];return M("div",{"group-kind":"overflow-group",key:"create-tools-group",priority:100},e,t)}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:I[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:t,scale:o,id:i,updateGraphics:{length:s}}=this,l=C(t.selectedCount,{count:s}),r="s"===o?99:999,n=s>r?C(t.selectedCountTruncated,{truncated:r}):s,a="s"===o&&"vertical"===e,c=a?`${i}-selection-chip-small`:`${i}-selection-chip`;return[a?M("span",{classes:{[S.chipVertical]:!0,[S.chipVerticalSmall]:"s"===this.scale},id:c,tabIndex:0,title:l},n):M("calcite-chip",{appearance:"outline",class:"horizontal"===e?S.chipHorizontal:S.chipVertical,id:c,kind:"brand",label:l,scale:"l"===o?"m":"s",tabIndex:0,title:"vertical"===e?l:void 0},"vertical"===e?n:l)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItemGroup({key:e,elements:o,slot:i}){const s=o?.filter(t);if(s?.length)return M("div",{"allow-collapse":!1,"group-kind":"overflow-group",key:e,priority:1e3,slot:i},s)}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:s,active:l,flipRTL:r,afterCreate:n,afterUpdate:a,afterRemoved:c}){const p=`${this.id}-${e}`;return[M("calcite-action",{active:l,afterCreate:n,afterRemoved:c,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:r??!1,id:p,key:e,onclick:s,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const s=this._calcitePopoverReferenceElement;if(!s)return;const{bottom:l,top:r}=s.getBoundingClientRect();if("horizontal"===this.layout){const e=l<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",l-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-r+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const n=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${n}px`)}catch(t){i.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(){this.activeTool&&this.view?.focus()}};e([p()],P.prototype,"_activeCustomToolOptions",void 0),e([p()],P.prototype,"activeTool",null),e([p({readOnly:!0})],P.prototype,"activeTooltip",null),e([p({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh"]);return e.filter((e=>t.has(e)))}})],P.prototype,"availableCreateTools",void 0),e([p({readOnly:!0})],P.prototype,"createGraphic",null),e([p()],P.prototype,"creationMode",null),e([p()],P.prototype,"customToolOptions",void 0),e([p()],P.prototype,"customActions",void 0),e([p()],P.prototype,"defaultCreateOptions",null),e([p()],P.prototype,"defaultUpdateOptions",null),e([p()],P.prototype,"icon",null),e([p()],P.prototype,"label",null),e([p()],P.prototype,"labelOptions",null),e([p()],P.prototype,"layer",null),e([p({type:["horizontal","vertical"],value:"horizontal"})],P.prototype,"layout",null),e([p({value:"m"})],P.prototype,"scale",null),e([p()],P.prototype,"toolbarKind",void 0),e([p()],P.prototype,"contextualToolLocation",void 0),e([p(),T("esri/widgets/Sketch/t9n/Sketch")],P.prototype,"messages",void 0),e([p(),T("esri/t9n/common")],P.prototype,"messagesCommon",void 0),e([p()],P.prototype,"snappingOptions",null),e([p()],P.prototype,"state",null),e([p()],P.prototype,"tooltipOptions",null),e([p({readOnly:!0})],P.prototype,"updateGraphics",null),e([p({type:u,nonNullable:!0})],P.prototype,"valueOptions",null),e([p()],P.prototype,"view",null),e([p({type:v}),w(["create","update","undo","redo"])],P.prototype,"viewModel",null),e([p({type:m,nonNullable:!0})],P.prototype,"visibleElements",void 0),e([p()],P.prototype,"_effectiveAvailableCreateTools",null),e([p()],P.prototype,"_calcitePopoverReferenceElement",void 0),e([p()],P.prototype,"_relativeLocation",void 0),e([p()],P.prototype,"_popoverOpen",void 0),P=e([d("esri.widgets.Sketch")],P);const R=P;export{R as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{handlesGroup as o}from"../core/handleUtils.js";import i from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as l}from"../core/maybe.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as n,syncAndInitial as a,when as c}from"../core/reactiveUtils.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import u from"../views/interactive/sketch/SketchValueOptions.js";import h from"./Widget.js";import v from"./Sketch/SketchViewModel.js";import{VisibleElements as m}from"./Sketch/VisibleElements.js";import f from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import _ from"./support/SelectionToolbar.js";import y from"./support/SketchTooltipControls.js";import b from"./support/SnappingControls.js";import"./support/widgetUtils.js";import{messageBundle as w}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as M}from"./support/jsxFactory.js";import O from"./support/SketchTooltipControls/VisibleElements.js";import{substitute as C}from"../intl/substitute.js";const k="esri-sketch",S={base:k,vertical:`${k}--vertical`,docked:`${k}-bar`,chipHorizontal:`${k}__selection-count-chip--horizontal`,chipVertical:`${k}__selection-count-chip--vertical`,chipVerticalSmall:`${k}__selection-count-chip--vertical--s`,popoverWrapper:`${k}__popover-wrapper`},I={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3-d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand"};let P=class extends h{constructor(e,t){super(e,t),this._activeCustomToolOptions=null,this._selectionToolbar=null,this._viewModelHandlesGroup=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.messages=null,this.messagesCommon=null,this.visibleElements=new m,this._defaultViewModel=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new v({creationMode:e?.creationMode??"continuous"}))}initialize(){const{layer:e,view:t}=this,i=new _({view:"2d"===t?.type?t:null,sources:e?[e]:null,scale:this.scale});this.addHandles([n((()=>this.viewModel),(e=>{this._viewModelHandlesGroup=s(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=o([e.on("create",(()=>this.scheduleRender())),e.on("update",(()=>this.scheduleRender())),e.on("delete",(e=>this.emit("delete",e))),e.on("undo",(()=>this.scheduleRender())),e.on("redo",(()=>this.scheduleRender())),n((()=>e.layer),(e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)})),n((()=>e.view),(e=>{this._selectionToolbar&&(this._selectionToolbar.view="2d"===e?.type?e:null)})),n((()=>e.state),(()=>this.notifyChange("state")))]))}),a),c((()=>i.activeToolInfo),(()=>this.viewModel.cancel())),i.on("complete",(e=>this._onSelectionOperationComplete(e))),n((()=>{const{selectionTools:e}=this.visibleElements;return{lassoTool:!!e?.["lasso-selection"],rectangleTool:!!e?.["rectangle-selection"]}}),(e=>{Object.assign(i.visibleElements,e)}),a)]),this._selectionToolbar=i}loadDependencies(){return g({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=s(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeToolInfo;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const t=this._effectiveAvailableCreateTools,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeToolInfo?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&l(t),this._set("viewModel",e))}get _effectiveAvailableCreateTools(){const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter((e=>!!o.createTools?.[e]));return"3d"===t?.type?i?.filter((e=>"multipoint"!==e)):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,r(this.viewModel.create(e,i))}update(e,t){return r(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this,i=this.customActions?.filter((e=>"selection-toolbar"===e.position));return M("div",null,M("div",{classes:{[S.base]:!0,[S.docked]:"docked"===e,[S.vertical]:"vertical"===t}},M(f,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),M("div",{"group-kind":"split-button",key:"selection-split-button",priority:0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),i?.map((e=>this._renderToolbarItem(e)))),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:s}=this;if(!this._calcitePopoverReferenceElement)return;const l={directionModePicker:s.directionModePicker,labelsToggle:s.labelsToggle,tooltipsToggle:s.tooltipsToggle},r="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return M("calcite-popover",{closable:!0,focusTrapDisabled:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:r,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,onCalcitePopoverBeforeClose:()=>this._popoverOpen=!1,onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:()=>this._refocusOnView()},M("div",{class:S.popoverWrapper},Object.values(l).includes(!0)?M(y,{sketchOptions:i.sketchOptions,viewType:o?.type,visibleElements:new O(l)}):void 0,s.snappingControls&&o&&t?M(b,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:s.snappingControlsElements}):void 0))}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?M(f,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return M("div",{"group-kind":"split-button",key:"undo-redo-menu",priority:10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=this.customActions?.filter((e=>"settings-before"===e.position));return this._renderToolbarItemGroup({key:"settings-menu",elements:[e?.map((e=>this._renderToolbarItem(e))),this._renderSettingsMenuButton()],slot:"actions-end"})}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter((e=>"before-selection-set"===e.position)),o=this.customActions?.filter((e=>"after-selection-set"===e.position));return[M("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:100,slot:e},this._renderFeatureCountChip()),M("div",{"allow-collapse":!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:100,slot:e},t?.map((e=>this._renderToolbarItem(e))),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map((e=>this._renderToolbarItem(e))))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderCreateToolActionGroup(){const e=this._effectiveAvailableCreateTools?.flatMap((e=>this._renderBuiltInCreateToolItem(e)))??[],t=this.customToolOptions?.flatMap((e=>this._renderCustomToolItem(e)))??[];return M("div",{"group-kind":"overflow-group",key:"create-tools-group",priority:100},e,t)}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:I[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:t,scale:o,id:i,updateGraphics:{length:s}}=this,l=C(t.selectedCount,{count:s}),r="s"===o?99:999,n=s>r?C(t.selectedCountTruncated,{truncated:r}):s,a="s"===o&&"vertical"===e,c=a?`${i}-selection-chip-small`:`${i}-selection-chip`;return[a?M("span",{classes:{[S.chipVertical]:!0,[S.chipVerticalSmall]:"s"===this.scale},id:c,tabIndex:0,title:l},n):M("calcite-chip",{appearance:"outline",class:"horizontal"===e?S.chipHorizontal:S.chipVertical,id:c,kind:"brand",label:l,scale:"l"===o?"m":"s",tabIndex:0,title:"vertical"===e?l:void 0},"vertical"===e?n:l)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItemGroup({key:e,elements:o,slot:i}){const s=o?.filter(t);if(s?.length)return M("div",{"allow-collapse":!1,"group-kind":"overflow-group",key:e,priority:1e3,slot:i},s)}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:s,active:l,flipRTL:r,afterCreate:n,afterUpdate:a,afterRemoved:c}){const p=`${this.id}-${e}`;return[M("calcite-action",{active:l,afterCreate:n,afterRemoved:c,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:r??!1,id:p,key:e,onclick:s,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const s=this._calcitePopoverReferenceElement;if(!s)return;const{bottom:l,top:r}=s.getBoundingClientRect();if("horizontal"===this.layout){const e=l<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",l-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-r+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const n=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${n}px`)}catch(t){i.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(){this.activeTool&&this.view?.focus()}};e([p()],P.prototype,"_activeCustomToolOptions",void 0),e([p()],P.prototype,"activeTool",null),e([p({readOnly:!0})],P.prototype,"activeTooltip",null),e([p({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh"]);return e.filter((e=>t.has(e)))}})],P.prototype,"availableCreateTools",void 0),e([p({readOnly:!0})],P.prototype,"createGraphic",null),e([p()],P.prototype,"creationMode",null),e([p()],P.prototype,"customToolOptions",void 0),e([p()],P.prototype,"customActions",void 0),e([p()],P.prototype,"defaultCreateOptions",null),e([p()],P.prototype,"defaultUpdateOptions",null),e([p()],P.prototype,"icon",null),e([p()],P.prototype,"label",null),e([p()],P.prototype,"labelOptions",null),e([p()],P.prototype,"layer",null),e([p({type:["horizontal","vertical"],value:"horizontal"})],P.prototype,"layout",null),e([p({value:"m"})],P.prototype,"scale",null),e([p()],P.prototype,"toolbarKind",void 0),e([p()],P.prototype,"contextualToolLocation",void 0),e([p(),w("esri/widgets/Sketch/t9n/Sketch")],P.prototype,"messages",void 0),e([p(),w("esri/t9n/common")],P.prototype,"messagesCommon",void 0),e([p()],P.prototype,"snappingOptions",null),e([p()],P.prototype,"state",null),e([p()],P.prototype,"tooltipOptions",null),e([p({readOnly:!0})],P.prototype,"updateGraphics",null),e([p({type:u,nonNullable:!0})],P.prototype,"valueOptions",null),e([p()],P.prototype,"view",null),e([p({type:v}),T(["create","update","undo","redo"])],P.prototype,"viewModel",null),e([p({type:m,nonNullable:!0})],P.prototype,"visibleElements",void 0),e([p()],P.prototype,"_effectiveAvailableCreateTools",null),e([p()],P.prototype,"_defaultViewModel",void 0),e([p()],P.prototype,"_calcitePopoverReferenceElement",void 0),e([p()],P.prototype,"_relativeLocation",void 0),e([p()],P.prototype,"_popoverOpen",void 0),P=e([d("esri.widgets.Sketch")],P);const R=P;export{R as default};