@arcgis/core 4.33.0-next.20250206 → 4.33.0-next.20250208

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 (195) hide show
  1. package/applications/Components/styleUtils.js +1 -1
  2. package/applications/Components/webStyleSymbolUtils.js +1 -1
  3. package/arcade/treeAnalysis.js +1 -1
  4. package/arcade.js +1 -1
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/{5b20ee64248f2d5c937f.js → 08980b1ad3d5d67c6390.js} +1 -1
  7. package/assets/esri/core/workers/chunks/0a8e388e96af44deeabb.js +1 -0
  8. package/assets/esri/core/workers/chunks/{38cd7745b8ef1b8b6196.js → 12d6baeffd55a98a7c75.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{b1f5344e57ee679a7e81.js → 140d0c4285c6978103ea.js} +7 -7
  10. package/assets/esri/core/workers/chunks/143a193fa3a6e645c8ac.js +1 -0
  11. package/assets/esri/core/workers/chunks/{2a7f5d09cdc0333fa4bd.js → 2611adb4f328f95ee508.js} +1 -1
  12. package/assets/esri/core/workers/chunks/2def7db73a776e759dae.js +1 -0
  13. package/assets/esri/core/workers/chunks/308ec51ff4a66f7fcb0d.js.LICENSE.txt +1 -1
  14. package/assets/esri/core/workers/chunks/{72cf9192292e5c85c6df.js → 32d3657dcae89b740f8b.js} +2 -2
  15. package/assets/esri/core/workers/chunks/{72cf9192292e5c85c6df.js.LICENSE.txt → 32d3657dcae89b740f8b.js.LICENSE.txt} +1 -1
  16. package/assets/esri/core/workers/chunks/354531dc2f0dea2ad96f.js.LICENSE.txt +1 -1
  17. package/assets/esri/core/workers/chunks/35e4af82a08b4eadbfab.js +1 -0
  18. package/assets/esri/core/workers/chunks/369a2b8484a8807bde38.js +1 -0
  19. package/assets/esri/core/workers/chunks/4040158835f9036967cd.js +2 -0
  20. package/assets/esri/core/workers/chunks/{1a2e1a414e651e988435.js.LICENSE.txt → 4040158835f9036967cd.js.LICENSE.txt} +1 -6
  21. package/assets/esri/core/workers/chunks/53810519ff5922b42cd2.js +1 -0
  22. package/assets/esri/core/workers/chunks/{15f850c9a1154fc57e5a.js → 5721557a1d8eab23a55b.js} +1 -1
  23. package/assets/esri/core/workers/chunks/594d923400fd74881833.js +1 -0
  24. package/assets/esri/core/workers/chunks/{32f5f00aab55ef16dcf1.js → 5b85f9da022742f602e2.js} +1 -1
  25. package/assets/esri/core/workers/chunks/62a1d60ad4bf6469c4dd.js +1 -0
  26. package/assets/esri/core/workers/chunks/{bab541feca7ab4d3f993.js → 6ea02ff25f051c08e6c3.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{81aa8cc289fd02ca4da6.js → 7058001bf66f9f3d5d45.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{e8ae8a11d8439e2a66ad.js → 706f867a9034d62a8ef7.js} +1 -1
  29. package/assets/esri/core/workers/chunks/77764ca90bdd13ee2167.js.LICENSE.txt +1 -1
  30. package/assets/esri/core/workers/chunks/{1ab83753d9eec0463461.js → 7b367bb0ed9c218ca595.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{8e334fa440ae542e2e34.js → 7e49ddb5a2182f2c9ca6.js} +1 -1
  32. package/assets/esri/core/workers/chunks/8191dd3d7451b2e7b95e.js +1 -0
  33. package/assets/esri/core/workers/chunks/8c32cee395da0a7b9a8e.js +1 -0
  34. package/assets/esri/core/workers/chunks/{48ecc5a74fecbb2b9c6f.js → 8d8f5f08d730270e1165.js} +1 -1
  35. package/assets/esri/core/workers/chunks/94225d92afbdb10dfedb.js +1 -0
  36. package/assets/esri/core/workers/chunks/94490937dca566fe2640.js +1 -0
  37. package/assets/esri/core/workers/chunks/{b9ce0049e27a3e1ed9f9.js → 9b2fab133786e5d47631.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{28374a64790342e1b5ae.js → 9d61590c4d21c7421925.js} +1 -1
  39. package/assets/esri/core/workers/chunks/b21b152fa15896577242.js.LICENSE.txt +1 -1
  40. package/assets/esri/core/workers/chunks/{5a25cef6355fd20e44e7.js → b765670b47d209d7655a.js} +2 -2
  41. package/assets/esri/core/workers/chunks/{5a25cef6355fd20e44e7.js.LICENSE.txt → b765670b47d209d7655a.js.LICENSE.txt} +1 -1
  42. package/assets/esri/core/workers/chunks/b97673755cd2cc5164e8.js +1 -0
  43. package/assets/esri/core/workers/chunks/bb9ab85a135d211637f6.js +1 -0
  44. package/assets/esri/core/workers/chunks/c26ffbff1115e76bcb0f.js +1 -0
  45. package/assets/esri/core/workers/chunks/c38c154062cd838dd144.js +1 -0
  46. package/assets/esri/core/workers/chunks/d29c3bf29fcd7fa31f1a.js +1 -0
  47. package/assets/esri/core/workers/chunks/d339dee99c4820b63f39.js +1 -0
  48. package/assets/esri/core/workers/chunks/de1f3c4b8000c2d73013.js +1 -0
  49. package/assets/esri/core/workers/chunks/{4decfae8bc5e80878bdd.js → de4384b5833a60e88e31.js} +1 -1
  50. package/assets/esri/core/workers/chunks/e37e5d2e233d7f6ccd52.js +314 -0
  51. package/assets/esri/core/workers/chunks/e4b3f2d5c43518b0cde7.js +1 -0
  52. package/assets/esri/core/workers/chunks/e5e3b6d00d27b5bb354f.js +1 -0
  53. package/assets/esri/core/workers/chunks/e93dea6b112ce8e2779b.js +1 -0
  54. package/assets/esri/core/workers/chunks/edb580ce96da6fd66503.js +1 -0
  55. package/assets/esri/core/workers/chunks/f14b318bab5efcf43419.js +1 -0
  56. package/assets/esri/core/workers/chunks/{24e47f748f0e4f815c6e.js → f32ca4381e804cc3481e.js} +1 -1
  57. package/assets/esri/core/workers/chunks/f9070edd8e0b2a57af79.js +1 -0
  58. package/assets/esri/themes/base/widgets/_ItemList.scss +6 -0
  59. package/assets/esri/themes/dark/main.css +1 -1
  60. package/assets/esri/themes/light/main.css +1 -1
  61. package/assets/esri/themes/light/view.css +1 -1
  62. package/chunks/ImageMaterial.glsl.js +4 -4
  63. package/geometry/Mesh.js +1 -1
  64. package/geometry/support/Indices.js +1 -1
  65. package/geometry/support/meshUtils/deduplicate.js +1 -1
  66. package/geometry/support/meshVertexSpaceUtils.js +1 -1
  67. package/geometry/support/triangulationUtils.js +1 -1
  68. package/interfaces.d.ts +61 -84
  69. package/layers/FeatureLayer.js +1 -1
  70. package/layers/SubtypeGroupLayer.js +1 -1
  71. package/layers/WCSLayer.js +1 -1
  72. package/layers/graphics/data/QueryEngineCapabilities.js +1 -1
  73. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  74. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  75. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  76. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  77. package/layers/graphics/sources/support/sourceUtils.js +1 -1
  78. package/layers/mixins/BlendLayer.js +1 -1
  79. package/layers/mixins/FeatureLayerBase.js +1 -1
  80. package/layers/mixins/OperationalLayer.js +1 -1
  81. package/layers/mixins/operationalLayerModuleMap.js +1 -1
  82. package/layers/support/SubtypeSublayer.js +1 -1
  83. package/layers/support/arcadeUtils.js +1 -1
  84. package/layers/support/commonProperties.js +1 -1
  85. package/layers/support/layersCreator.js +1 -1
  86. package/package.json +2 -2
  87. package/portal/support/layersLoader.js +1 -1
  88. package/portal/support/loadUtils.js +1 -1
  89. package/rest/imageService.js +1 -1
  90. package/rest/support/ImageSampleParameters.js +1 -1
  91. package/rest/support/ImageSampleResult.js +1 -1
  92. package/rest/support/ImageVolumeResult.js +1 -1
  93. package/support/TablesMixin.js +1 -1
  94. package/support/arcadeUtils.js +1 -1
  95. package/support/revision.js +1 -1
  96. package/symbols/WebStyleSymbol.js +1 -1
  97. package/symbols/cim/cimAnalyzer.js +1 -1
  98. package/symbols/cim/fitVectorMarker.js +5 -0
  99. package/symbols/support/previewCIMSymbol.js +1 -1
  100. package/symbols/support/previewSymbol3D.js +1 -1
  101. package/symbols/support/previewWebStyleSymbol.js +1 -1
  102. package/symbols/support/styleUtils.js +1 -1
  103. package/symbols/support/symbolUtils.js +1 -1
  104. package/symbols/support/utils.js +1 -1
  105. package/symbols/support/webStyleAcceptedFormats.js +5 -0
  106. package/symbols/support/webStyleSymbolUtils.js +1 -1
  107. package/views/2d/engine/webgl/TextureManager.js +1 -1
  108. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  109. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  110. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  111. package/views/2d/layers/features/sources/strategies/DrillDownTileLoadStrategy.js +1 -1
  112. package/views/2d/layers/features/sources/strategies/PagedTileLoadStrategy.js +1 -1
  113. package/views/2d/layers/features/sources/strategies/ParquetLoadStrategy.js +1 -1
  114. package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +1 -1
  115. package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
  116. package/views/3d/glTF/internal/resourceUtils.js +1 -1
  117. package/views/3d/layers/MediaLayerView3D.js +1 -1
  118. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  119. package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
  120. package/views/3d/layers/graphics/Labeler.js +1 -1
  121. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
  122. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  123. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
  124. package/views/3d/layers/graphics/pipeline/PipelineCommand.js +1 -1
  125. package/views/3d/layers/graphics/pipeline/featureData/FeatureData.js +1 -1
  126. package/views/3d/layers/graphics/pipeline/featureData/processingUtils.js +1 -1
  127. package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
  128. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  129. package/views/3d/layers/graphics/pipeline/rendering/LodRenderer.js +1 -1
  130. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
  131. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandEncoder.js +1 -1
  132. package/views/3d/layers/graphics/pipeline/rendering/RenderGeometryBufferWriter.js +1 -1
  133. package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
  134. package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
  135. package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
  136. package/views/3d/layers/graphics/pipeline/symbolization/primitiveObjectUtils.js +1 -1
  137. package/views/3d/layers/graphics/pipeline/utils.js +5 -0
  138. package/views/3d/layers/graphics/webStyleUtils.js +1 -1
  139. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  140. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  141. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  142. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  143. package/views/3d/webgl-engine/materials/DefaultBufferWriter.js +1 -1
  144. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  145. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  146. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  147. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  148. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  149. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  150. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  151. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  152. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  153. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  154. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  155. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  156. package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
  157. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  158. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  159. package/widgets/Editor/EditorViewModel.js +1 -1
  160. package/widgets/Editor/UpdateWorkflow.js +1 -1
  161. package/widgets/Editor/VisibleElements.js +1 -1
  162. package/widgets/Editor/components/FeatureList.js +1 -1
  163. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  164. package/widgets/Editor/workflowUtils.js +1 -1
  165. package/widgets/Editor.js +1 -1
  166. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  167. package/widgets/Sketch.js +1 -1
  168. package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
  169. package/assets/esri/core/workers/chunks/07bff9e742f3e5877f3f.js +0 -1
  170. package/assets/esri/core/workers/chunks/1100d9d114287b6443e2.js +0 -1
  171. package/assets/esri/core/workers/chunks/1a2e1a414e651e988435.js +0 -2
  172. package/assets/esri/core/workers/chunks/287362f9af132fafe4de.js +0 -1
  173. package/assets/esri/core/workers/chunks/2adc533dadcb018a9755.js +0 -1
  174. package/assets/esri/core/workers/chunks/2ea5e5e6c4660a06b516.js +0 -1
  175. package/assets/esri/core/workers/chunks/3984bf01f055fc42bfbf.js +0 -1
  176. package/assets/esri/core/workers/chunks/41cd1a5c99ab3bbd1fb4.js +0 -1
  177. package/assets/esri/core/workers/chunks/5e7f16b312077ca8c18d.js +0 -1
  178. package/assets/esri/core/workers/chunks/6ec108bd955e064256b5.js +0 -1
  179. package/assets/esri/core/workers/chunks/6ef2514a6b7bbfb8e37d.js +0 -1
  180. package/assets/esri/core/workers/chunks/7b11bf5799ecb3640b48.js +0 -314
  181. package/assets/esri/core/workers/chunks/81efe1f47fd41b7a5cc1.js +0 -1
  182. package/assets/esri/core/workers/chunks/82d26884127ed772cc4b.js +0 -1
  183. package/assets/esri/core/workers/chunks/918bdba41fa470cf77fd.js +0 -1
  184. package/assets/esri/core/workers/chunks/91d2bdfa6e34c10b7f50.js +0 -1
  185. package/assets/esri/core/workers/chunks/92871ebb339a7b6ff29c.js +0 -1
  186. package/assets/esri/core/workers/chunks/991e0f619f1f81f94d56.js +0 -1
  187. package/assets/esri/core/workers/chunks/9a27824d94df702e6e28.js +0 -1
  188. package/assets/esri/core/workers/chunks/b3f9d7a676076a7557f5.js +0 -1
  189. package/assets/esri/core/workers/chunks/c1fd87af3129873369fd.js +0 -1
  190. package/assets/esri/core/workers/chunks/c4c2b94e5cee7b824093.js +0 -1
  191. package/assets/esri/core/workers/chunks/c85374360ac5e169af16.js +0 -1
  192. package/assets/esri/core/workers/chunks/c94ec324ecad77c53a87.js +0 -1
  193. package/assets/esri/core/workers/chunks/d175953337fa655dc6b0.js +0 -1
  194. package/assets/esri/core/workers/chunks/e26dc0c1654316bb1558.js +0 -1
  195. package/assets/esri/core/workers/chunks/fe817283bbcbca8fb296.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{isSome as e}from"../../../core/arrayUtils.js";import{getDisplayFieldName as t}from"../../../layers/support/fieldUtils.js";import{loadPanelContentComponents as r,PanelContentSection as l,PanelContent as o}from"./PanelContent.js";import{ItemList as a}from"../../support/ItemList.js";import"../../support/widgetUtils.js";import{tsx as s}from"../../support/jsxFactory.js";const i=()=>r();function n({editorItems:t,filterText:r,id:i,messagesTemplates:n,onFilterTextChange:m,onSelectFeature:c,workflow:u}){const f=new Map,p=u.data.candidates;let y=0;p.map((e=>({label:d(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((({label:e,data:l})=>{const o=r.toLowerCase(),{title:a}=l.layer,s=t.find((e=>e.layer===l.sourceLayer));return s?s.supportsUpdateWorkflow&&(!o||e?.toLowerCase().includes(o)||a?.toLowerCase().includes(o)):null})).filter(e).forEach((e=>{y++;const t=e.data.layer;f.has(t)?f.get(t)?.items.push(e):f.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=t.toArray().map((({layer:e})=>f.get(e))).filter(e),I=y>10||r.length>0;return s(o,{key:"feature-list"},s(l,null,a({enableListScroll:!1,filterEnabled:I,filterText:r,id:i,items:h,messages:{filterPlaceholder:n.filterPlaceholder,noItems:n.noItems,noMatches:n.noMatches},onFilterChange:e=>m(e),onItemMouseEnter:e=>c(e.data),onItemMouseLeave:()=>c(null),onItemSelect:e=>c(e.data,!0)})))}function d(e){const r=e.layer;if(!r)return null;const l=r.fieldsIndex.get(r.objectIdField),o=l.alias||l.name,{attributes:a}=e,s=t(r);return s&&a[s]&&`${a[s]}`||`${o}: ${a[l.name]}`}export{n as FeatureList,i as loadFeatureListComponents};
5
+ import{isSome as e}from"../../../core/arrayUtils.js";import{getDisplayFieldName as t}from"../../../layers/support/fieldUtils.js";import{loadPanelContentComponents as o,PanelContentSection as r,PanelContent as a}from"./PanelContent.js";import{loadCalciteComponents as s}from"../../support/componentsUtils.js";import{ItemList as l}from"../../support/ItemList.js";import"../../support/widgetUtils.js";import{tsx as n}from"../../support/jsxFactory.js";const i=()=>Promise.all([o(),s({action:()=>import("@esri/calcite-components/dist/components/calcite-action")})]);function c({editorItems:t,filterText:o,id:s,messagesTemplates:i,onFilterTextChange:c,onSelectFeature:p,onZoomTo:u,workflow:f,editorMessages:y}){const j=new Map,I=f.data.candidates;let b=0;I.map((e=>({label:m(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((({label:e,data:r})=>{const a=o.toLowerCase(),{title:s}=r.layer,l=t.find((e=>e.layer===r.sourceLayer));return l?l.supportsUpdateWorkflow&&(!a||e?.toLowerCase().includes(a)||s?.toLowerCase().includes(a)):null})).filter(e).forEach((e=>{b++;const t=e.data.layer;j.has(t)?j.get(t)?.items.push(e):j.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const g=t.toArray().map((({layer:e})=>j.get(e))).filter(e),h=b>10||o.length>0;return n(a,{key:"feature-list"},n(r,null,l({enableListScroll:!1,filterEnabled:h,filterText:o,id:s,items:g,messages:{filterPlaceholder:i.filterPlaceholder,noItems:i.noItems,noMatches:i.noMatches},onFilterChange:e=>c(e),onItemMouseEnter:e=>p(e.data),onItemMouseLeave:()=>p(null),onItemSelect:e=>p(e.data,!0),renderItemActionEnd:e=>d(e.data,u,y.zoomTo)})))}function m(e){const o=e.layer;if(!o)return null;const r=o.fieldsIndex.get(o.objectIdField),a=r.alias||r.name,{attributes:s}=e,l=t(o);return l&&s[l]&&`${s[l]}`||`${a}: ${s[r.name]}`}function d(e,t,o){return n("calcite-action",{appearance:"transparent",icon:"zoom-to-object",onclick:()=>t(e),scale:"s",slot:"actions-end",text:o,title:o})}export{c as FeatureList,i as loadFeatureListComponents};
@@ -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{substitute as e}from"../../../intl/substitute.js";import{loadFooterActionsComponents as t,FooterActions as o}from"./FooterActions.js";import{loadNoticesComponents as n,Notices as a}from"./Notices.js";import{loadPanelContentComponents as s,PanelContentSection as i,PanelContentSectionGroup as r,PanelContent as l}from"./PanelContent.js";import u from"./PendingFeatureList.js";import{Heading as d,incrementHeadingLevel as p}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{tsx as c,tsxFragment as m}from"../../support/jsxFactory.js";const f=()=>Promise.all([t(),n(),s()]);function h({editorViewModel:t,headingLevel:n,messages:s,messagesCommon:f,onDelete:h,onDeleteAssociation:y,onSave:g,renderAttachments:w,renderFeatureForm:b,renderSketchToolbar:k}){const{activeLeafWorkflow:v,activeWorkflow:F,featureFormViewModel:A,syncing:j}=t;if(!v||!F||!A)return null;const S=v.type.includes("update"),C=S&&!v.hasPendingEdits||j||A.updating,L=S?f.update:f.create,P="create-features"===v?.type?v.numPendingFeatures:0,D="create-features"!==v?.type||!!v.data.selectedPendingFeature,T=P>1?e(s.createFeaturesTemplate,{numFeatures:P}):L,H="shouldShowAttachments"in v&&v.shouldShowAttachments&&!A.activeRelationshipInput,x=A.inputs.every((e=>!e.visible))&&!H,B=x?c(i,null,"create-features"===v.type?c(u,{headingLevel:n,key:"pending-feature-list",workflow:v}):void 0):c(i,{key:"panel-content-section"},c(a,{messages:s,workflow:F}),c(r,null,D||"create-features"!==v.type?b():c(u,{headingLevel:n,key:"pending-feature-list",workflow:v}),H?c("div",{key:"attachments"},c(d,{level:p(n)},s.attachments),w()):null)),I={onClick:g,disabled:C,label:T,type:"button"},M={appearance:"outline",onClick:h,disabled:j,kind:"danger",label:f.delete,type:"button"},V={...M,onClick:y,label:s.deleteAssociationTitle,type:"button"},W={...M,primaryLabel:f.delete,primaryText:f.delete,dropdownItems:[{onClick:y,label:s.deleteAssociationTitle}],type:"split-button"};return c(m,null,x||"create-features"===v.type||"update"===v.type?k():void 0,c(l,{key:"attribute-panel-content"},B),c(o,{buttons:[I,t.shouldShowDeleteButton&&!t.featureFormHasAssociation?M:void 0,!t.shouldShowDeleteButton&&t.featureFormHasAssociation?V:void 0,t.shouldShowDeleteButton&&t.featureFormHasAssociation?W:void 0]}))}export{h as UpdateFeaturePanelContent,f as loadUpdateFeaturePanelContentComponents};
5
+ import{substitute as e}from"../../../intl/substitute.js";import{loadFooterActionsComponents as t,FooterActions as o}from"./FooterActions.js";import{loadNoticesComponents as n,Notices as i}from"./Notices.js";import{loadPanelContentComponents as s,PanelContentSection as a,PanelContentSectionGroup as r,PanelContent as l}from"./PanelContent.js";import u from"./PendingFeatureList.js";import{Heading as d,incrementHeadingLevel as p}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{tsx as c,tsxFragment as m}from"../../support/jsxFactory.js";const f=()=>Promise.all([t(),n(),s()]);function h({editorViewModel:t,headingLevel:n,messages:s,messagesCommon:f,onDelete:h,onDeleteAssociation:y,onSave:g,renderAttachments:w,renderFeatureForm:b,renderSketchToolbar:k}){const{activeLeafWorkflow:v,activeWorkflow:F,featureFormViewModel:A,syncing:j}=t;if(!v||!F||!A)return null;const S=v.type.includes("update"),C=S&&!v.hasPendingEdits||j||A.updating,L=S?f.update:f.create,P="create-features"===v?.type?v.numPendingFeatures:0,D="create-features"!==v?.type||!!v.data.selectedPendingFeature,T=P>1?e(s.createFeaturesTemplate,{numFeatures:P}):L,H="shouldShowAttachments"in v&&v.shouldShowAttachments&&!A.activeRelationshipInput,x=A.inputs.every((e=>!e.visible))&&!H,B=x?c(a,null,"create-features"===v.type?c(u,{headingLevel:n,key:"pending-feature-list",workflow:v}):void 0):c(a,{key:"panel-content-section"},c(i,{messages:s,workflow:F}),c(r,null,D||"create-features"!==v.type?b():c(u,{headingLevel:n,key:"pending-feature-list",workflow:v}),H?c("div",{key:"attachments"},c(d,{level:p(n)},s.attachments),w()):null)),I={onClick:g,disabled:C,label:T,type:"button"},M={appearance:"outline",onClick:h,disabled:j,kind:"danger",label:f.delete,type:"button"},V={...M,onClick:y,label:s.deleteAssociationTitle,type:"button"},W={...M,primaryLabel:f.delete,primaryText:f.delete,dropdownItems:[{onClick:y,label:s.deleteAssociationTitle}],type:"split-button"};return c(m,null,x?k():void 0,c(l,{key:"attribute-panel-content"},B),c(o,{buttons:[I,t.shouldShowDeleteButton&&!t.featureFormHasAssociation?M:void 0,!t.shouldShowDeleteButton&&t.featureFormHasAssociation?V:void 0,t.shouldShowDeleteButton&&t.featureFormHasAssociation?W:void 0]}))}export{h as UpdateFeaturePanelContent,f as loadUpdateFeaturePanelContentComponents};
@@ -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{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?"feature-reduction-popup":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"feature-reduction-popup":{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};
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};
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};
@@ -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 s from"../../../core/Clonable.js";import r from"../../../core/Collection.js";import a from"../../../core/Identifiable.js";import{ignoreAbortErrors as i,debounce as n}from"../../../core/promiseUtils.js";import c from"../../../core/ReactiveMap.js";import{watch as l,initial as u}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 y}from"../../../core/accessorSupport/decorators/subclass.js";import h from"../../../rest/networks/support/NetworkElement.js";import p from"../../../rest/support/Query.js";import{featureUtilityNetworkFields as g}from"../../Feature/FeatureUtilityNetworkAssociations/resources.js";import{findUtilityNetwork as m}from"../../Feature/support/featureUtils.js";const w=100;let b=class extends(s.ClonableMixin(a.IdentifiableMixin(o))){constructor(t){super(t),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.networkSourceIdsInUse=new Set,this.source="popup",this.description=null,this.graphic=null,this.layer=null,this.map=null,this.featureCount=0,this.associationTypes=null,this.showAllEnabled=!1,this.title=null,this.attachmentsFeatureCount=0,this.structureFeatureCount=0,this.contentFeatureCount=0,this.containerFeatureCount=0,this.connectivityFeatureCount=0,this._queryOpenAssociationType=async()=>{this.activeAssociationType&&await this._queryDebounced(this.activeAssociationType)},this._cancelQuery=()=>{const{_queryAbortController:t}=this;t&&t.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:t}=this;t&&t.abort(),this._queryFeatureCountAbortController=null},this._queryController=async t=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await i(this._query(t)),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const t=new AbortController;this._queryFeatureCountAbortController=t,await i(this._queryFeatureCount()),this._queryFeatureCountAbortController===t&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryDebounced=n(this._queryController,w),this._queryFeatureCountDebounced=n(this._queryFeatureCountController,w)}initialize(){this.addHandles([l((()=>[this.graphic,this.layer,this.map,this.associationTypes,this.objectId,this.globalId,this.canQuery]),(()=>this.refresh()),u),l((()=>this.activeAssociationType),(t=>this._queryDebounced(t)),u)])}destroy(){this._cancelQuery(),this._cancelQueryFeatureCount(),this._destroyAssociatedFeatureViewModels()}get supportsCacheHint(){return!!this.layer?.capabilities?.query?.supportsCacheHint}get canLoad(){return!!this.map&&!!this.associationTypes&&"string"==typeof this.globalId}get canQuery(){const t=this.layer?.capabilities?.query;return!!this.associationTypes&&"string"==typeof this.globalId&&!!t?.supportsPagination}set displayCount(t){const e=0,o=3;this._set("displayCount",Math.max(t??o,e))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get globalId(){return(this.globalIdField&&this.graphic?.attributes?.[this.globalIdField])??null}get globalIdField(){const{layer:t}=this;return"subtype-sublayer"===t?.type&&t?.parent?t.parent.globalIdField??null:t?.globalIdField??null}get activeAssociationType(){return this._get("activeAssociationType")}set activeAssociationType(t){t&&!this.associationTypes.includes(t)||this._set("activeAssociationType",t)}get state(){const{_queryAbortController:t,_queryFeatureCountAbortController:e,_queryPageAbortController:o,canQuery:s,_loaded:r,canLoad:a}=this;return e||a&&!r?"loading":t||o?"querying":s&&0!==this.featureCount?"ready":"disabled"}get utilityNetwork(){const{layer:t,map:e}=this;return t?.loaded&&e?"subtype-sublayer"===t?.type&&t?.parent?m(e,t.parent)??null:m(e,t)??null:null}get attachmentsAssociations(){return this._get("attachmentsAssociations")||new r}get structureAssociations(){return this._get("structureAssociations")||new r}get contentAssociations(){return this._get("contentAssociations")||new r}get containerAssociations(){return this._get("containerAssociations")||new r}get connectivityAssociations(){return this._get("connectivityAssociations")||new r}get associationFeatures(){return this._get("associationFeatures")||new c}get associationViewModels(){return this._get("associationViewModels")||new Map}async refresh(){await this._queryFeatureCountDebounced(),await this._queryOpenAssociationType()}getFeatureCountForAssociationType(t){switch(t){case"attachment":return this.attachmentsFeatureCount;case"structure":return this.structureFeatureCount;case"content":return this.contentFeatureCount;case"container":return this.containerFeatureCount;case"connectivity":return this.connectivityFeatureCount}}_destroyAssociatedFeatureViewModels(){this.associationViewModels.forEach((t=>t.destroyAll()))}async _loadUtiltyNetworks(){const t=this.map;if(!t)return;await Promise.allSettled(t.utilityNetworks?.map((async t=>{await t.load()}))??[]);const e=this.utilityNetwork;if(e){const o=t=>{if("layerId"in t&&e.isUtilityLayer(t)){const o=e.getSourceIdByLayerId(t.layerId);null!==o&&this.networkSourceIdsInUse.add(o)}};this._set("networkSourceIdsInUse",new Set),t.allLayers.forEach(o),t.allTables.forEach(o)}}async _findLayersBySourceId(t){const{utilityNetwork:e,map:o}=this,s=t=>{const o=t;if(!t.url)return!1;if(o.layerId===r){return t.url.replace(/\/\d+$/,"")===e?.featureServiceUrl}return!1};await(e?.load());const r=e.getLayerIdBySourceId(t),a=o.allLayers.filter(s),i=o.allTables.filter(s),n=a.concat(i).toArray();return await Promise.allSettled(n.map((t=>t.load()))),n}_clearAssociations(){this.attachmentsAssociations.removeAll(),this.structureAssociations.removeAll(),this.contentAssociations.removeAll(),this.containerAssociations.removeAll(),this.connectivityAssociations.removeAll()}_clearFeatures(){this.associationFeatures.forEach((t=>t.removeAll())),this.associationFeatures.clear()}_getAssociationsByType(t){switch(t){case"attachment":return this.attachmentsAssociations;case"structure":return this.structureAssociations;case"connectivity":return this.connectivityAssociations;case"container":return this.containerAssociations;case"content":return this.contentAssociations}}async _queryLayer(t,e,o,s,r){const a=t.fieldsIndex.get(g.assetGroup),i=t.fieldsIndex.get(g.assetType),n=null!=o,c=null!=s,l="("+e.map((t=>`'${t}'`)).join(", ")+")",u=n?` AND ${a?.name} = ${o}`:"",d=n&&c?` AND ${i?.name} = ${s}`:"",y=`${t.globalIdField} IN ${l}`+u+d,h=new p({outFields:["*"],cacheHint:this.supportsCacheHint,where:y});return await this._queryAll(h,t,{signal:r?.signal})}async _createAssociationFeatureObjects(t,e,o,s,r,a){if(0===t.length)return[];const i=new Map;for(const[c,l]of e){const t=await this._findLayersBySourceId(c);for(const e of t){(await this._queryLayer(e,l,s,r,a)).forEach((t=>{const o=t.layer&&"formTemplate"in t.layer?t.layer.formTemplate:null;if(("popup"===this.source?t.getEffectivePopupTemplate():o)&&t.layer){const o=i.get(t.attributes[e.globalIdField])??[];o.push(t),i.set(t.attributes[e.globalIdField],o)}}))}}const n=[];return t.toArray().forEach((t=>{const{fromNetworkElement:e,toNetworkElement:s}=t,r=e.globalId===o?s:e;(i.get(r.globalId)??[]).forEach((e=>{const o=this.utilityNetwork?.getTerminalById(r?.terminalId)?.name;n.push({association:t,feature:e,terminalName:o})}))})),n}_parseFeatureObjects(t,e){t.forEach((t=>{const o=t?.feature,s=o.layer,a=e.get(s)??new r;a.add(t),e.set(s,a)}))}async _queryAll(t,e,o){const s=[];let r=0,a=!1;t.num=e.sourceJSON?.maxRecordCount??2e3;do{t.start=r;const i=await e.queryFeatures(t,o);s.push(...i.features),a=i.exceededTransferLimit,a&&(r+=i.features.length)}while(a);return s}async _queryAssociations(t){const{layer:e,globalId:o,associationTypes:s,utilityNetwork:r,canQuery:a}=this;if(await Promise.allSettled([e?.load(),r?.load()]),this._clearAssociations(),!(a&&e&&s&&r&&o))return;const i=new h({globalId:o,networkSourceId:r?.getSourceIdByLayerId(e?.layerId??e?.parent?.layerId)}),n=new Set;s.forEach((t=>{switch(t.type){case"attachment":case"structure":n.add("attachment");break;case"container":case"content":n.add("containment");break;case"connectivity":n.add("connectivity"),n.add("junction-junction-connectivity"),n.add("junction-edge-from-connectivity"),n.add("junction-edge-midspan-connectivity"),n.add("junction-edge-to-connectivity")}}));const c=await(r?.queryAssociations({elements:[i],types:Array.from(n)},{signal:t?.signal})),l=new Map,u=new Map;s.forEach((t=>{u.set(t.type,t),l.set(t.type,[])})),c?.forEach((t=>{const{toNetworkElement:e,fromNetworkElement:s}=t;switch(t.associationType){case"connectivity":case"junction-junction-connectivity":case"junction-edge-from-connectivity":case"junction-edge-midspan-connectivity":case"junction-edge-to-connectivity":if(s?.globalId===o){if(null!=u.get("connectivity")?.associatedNetworkSourceId&&u.get("connectivity")?.associatedNetworkSourceId!==e?.networkSourceId)break;l.get("connectivity").push(e.globalId)}else{if(null!=u.get("connectivity")?.associatedNetworkSourceId&&u.get("connectivity")?.associatedNetworkSourceId!==s?.networkSourceId)break;l.get("connectivity")?.push(s.globalId)}this.connectivityAssociations.add(t);break;case"containment":if(s?.globalId===o){if(null!=u.get("content")?.associatedNetworkSourceId&&u.get("content")?.associatedNetworkSourceId!==e?.networkSourceId)break;l.get("content")?.push(e.globalId),this.contentAssociations.add(t)}else{if(null!=u.get("container")?.associatedNetworkSourceId&&u.get("container")?.associatedNetworkSourceId!==s?.networkSourceId)break;l.get("container")?.push(s.globalId),this.containerAssociations.add(t)}break;case"attachment":if(s?.globalId===o){if(null!=u.get("attachment")?.associatedNetworkSourceId&&u.get("attachment")?.associatedNetworkSourceId!==e?.networkSourceId)break;l.get("attachment")?.push(e.globalId),this.attachmentsAssociations.add(t)}else{if(null!=u.get("structure")?.associatedNetworkSourceId&&u.get("structure")?.associatedNetworkSourceId!==s?.networkSourceId)break;l.get("structure")?.push(s.globalId),this.structureAssociations.add(t)}}}));const d=s.map((async e=>{const{associatedNetworkSourceId:o,associatedAssetGroup:s,associatedAssetType:r}=e,a=l.get(e.type),i=null!=s?await this._countAssociatedFeatures(o,a,s,r,t):a.length;switch(e.type){case"attachment":this._set("attachmentsFeatureCount",i);break;case"structure":this._set("structureFeatureCount",i);break;case"content":this._set("contentFeatureCount",i);break;case"container":this._set("containerFeatureCount",i);break;case"connectivity":this._set("connectivityFeatureCount",i)}}));await Promise.allSettled(d)}async _countAssociatedFeatureCount(t,e,o,s,r){const a=t.fieldsIndex.get(g.assetGroup),i=t.fieldsIndex.get(g.assetType),n=null!=s,c="("+e.map((t=>`'${t}'`)).join(", ")+")",l=` AND ${a?.name} = ${o}`,u=n?` AND ${i?.name} = ${s}`:"",d=`${t.globalIdField} IN ${c}`+l+u;return t.queryFeatureCount({where:d,outFields:["*"],returnGeometry:!1},{signal:r?.signal})}async _countAssociatedFeatures(t,e,o,s,r){if(0===e.length)return 0;const a=(await this._findLayersBySourceId(t)).map((async t=>this._countAssociatedFeatureCount(t,e,o,s,r)));return(await Promise.all(a)).reduce(((t,e)=>t+e),0)}async _queryAssociatedFeatures(t,e){const{layer:o,globalId:s,associationTypes:r,utilityNetwork:a,canQuery:i,associationFeatures:n}=this;if(await Promise.allSettled([o?.load(),a?.load()]),!(i&&o&&r&&a))return;const c=this._getAssociationsByType(t.type),{associatedAssetGroup:l,associatedAssetType:u}=t,d=new Map;c.forEach((t=>{const{fromNetworkElement:e,toNetworkElement:o}=t,{networkSourceId:r,elementGlobalId:a}=e.globalId===s?{networkSourceId:o.networkSourceId,elementGlobalId:o.globalId}:{networkSourceId:e.networkSourceId,elementGlobalId:e.globalId},i=d.get(r)||[];i.push(a),d.set(r,i)}));const y=await this._createAssociationFeatureObjects(c,d,s,l,u,e);this._parseFeatureObjects(y,n)}async _queryFeatureCount(){await this._loadUtiltyNetworks();const{_queryFeatureCountAbortController:t,canQuery:e}=this;e?(await this._queryAssociations(t),this._set("featureCount",this.attachmentsFeatureCount+this.structureFeatureCount+this.contentFeatureCount+this.containerFeatureCount+this.connectivityFeatureCount)):this._set("featureCount",0)}async _query(t){if(!t)return;await this._loadUtiltyNetworks();const{_queryAbortController:e}=this;this._destroyAssociatedFeatureViewModels(),this._clearFeatures(),0!==this.featureCount&&(this.destroyed||await this._queryAssociatedFeatures(t,{signal:e?.signal}))}};t([d()],b.prototype,"_loaded",void 0),t([d()],b.prototype,"_queryAbortController",void 0),t([d()],b.prototype,"_queryPageAbortController",void 0),t([d()],b.prototype,"_queryFeatureCountAbortController",void 0),t([d({readOnly:!0})],b.prototype,"supportsCacheHint",null),t([d({readOnly:!0})],b.prototype,"canLoad",null),t([d({readOnly:!0})],b.prototype,"canQuery",null),t([d()],b.prototype,"networkSourceIdsInUse",void 0),t([d({constructOnly:!0})],b.prototype,"source",void 0),t([d()],b.prototype,"description",void 0),t([d({value:3})],b.prototype,"displayCount",null),t([d({type:e})],b.prototype,"graphic",void 0),t([d()],b.prototype,"layer",void 0),t([d()],b.prototype,"map",void 0),t([d({readOnly:!0})],b.prototype,"objectId",null),t([d({readOnly:!0})],b.prototype,"objectIdField",null),t([d({readOnly:!0})],b.prototype,"globalId",null),t([d({readOnly:!0})],b.prototype,"globalIdField",null),t([d()],b.prototype,"featureCount",void 0),t([d()],b.prototype,"associationTypes",void 0),t([d()],b.prototype,"activeAssociationType",null),t([d()],b.prototype,"showAllEnabled",void 0),t([d()],b.prototype,"state",null),t([d()],b.prototype,"title",void 0),t([d({readOnly:!0})],b.prototype,"utilityNetwork",null),t([d({readOnly:!0})],b.prototype,"attachmentsFeatureCount",void 0),t([d({readOnly:!0})],b.prototype,"structureFeatureCount",void 0),t([d({readOnly:!0})],b.prototype,"attachmentsAssociations",null),t([d({readOnly:!0})],b.prototype,"structureAssociations",null),t([d({readOnly:!0})],b.prototype,"contentFeatureCount",void 0),t([d({readOnly:!0})],b.prototype,"containerFeatureCount",void 0),t([d({readOnly:!0})],b.prototype,"contentAssociations",null),t([d({readOnly:!0})],b.prototype,"containerAssociations",null),t([d({readOnly:!0})],b.prototype,"connectivityFeatureCount",void 0),t([d({readOnly:!0})],b.prototype,"connectivityAssociations",null),t([d({readOnly:!0})],b.prototype,"associationFeatures",null),t([d({readOnly:!0})],b.prototype,"associationViewModels",null),b=t([y("esri.widgets.support.UtilityNetworkAssociations.UtilityNetworkAssociationsViewModel")],b);const A=b;export{A as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import s from"../../../core/Clonable.js";import r from"../../../core/Collection.js";import a from"../../../core/Identifiable.js";import{ignoreAbortErrors as i,debounce as n}from"../../../core/promiseUtils.js";import c from"../../../core/ReactiveMap.js";import{watch as l,initial as u}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 y}from"../../../core/accessorSupport/decorators/subclass.js";import h from"../../../rest/networks/support/NetworkElement.js";import p from"../../../rest/support/Query.js";import{featureUtilityNetworkFields as g}from"../../Feature/FeatureUtilityNetworkAssociations/resources.js";import{findUtilityNetwork as m}from"../../Feature/support/featureUtils.js";const w=100;let b=class extends(s.ClonableMixin(a.IdentifiableMixin(o))){constructor(t){super(t),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.networkSourceIdsInUse=new Set,this.source="popup",this.description=null,this.graphic=null,this.layer=null,this.map=null,this.featureCount=0,this.associationTypes=null,this.showAllEnabled=!1,this.title=null,this.attachmentsFeatureCount=0,this.structureFeatureCount=0,this.contentFeatureCount=0,this.containerFeatureCount=0,this.connectivityFeatureCount=0,this._queryOpenAssociationType=async()=>{this.activeAssociationType&&await this._queryDebounced(this.activeAssociationType)},this._cancelQuery=()=>{const{_queryAbortController:t}=this;t&&t.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:t}=this;t&&t.abort(),this._queryFeatureCountAbortController=null},this._queryController=async t=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await i(this._query(t)),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const t=new AbortController;this._queryFeatureCountAbortController=t,await i(this._queryFeatureCount()),this._queryFeatureCountAbortController===t&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryDebounced=n(this._queryController,w),this._queryFeatureCountDebounced=n(this._queryFeatureCountController,w)}initialize(){this.addHandles([l((()=>[this.graphic,this.layer,this.map,this.associationTypes,this.objectId,this.globalId,this.canQuery]),(()=>this.refresh()),u),l((()=>this.activeAssociationType),(t=>this._queryDebounced(t)),u)])}destroy(){this._cancelQuery(),this._cancelQueryFeatureCount(),this._destroyAssociatedFeatureViewModels()}get supportsCacheHint(){return!!this.layer?.capabilities?.query?.supportsCacheHint}get canLoad(){return!!this.map&&!!this.associationTypes&&"string"==typeof this.globalId}get canQuery(){const t=this.layer?.capabilities?.query;return!!this.associationTypes&&"string"==typeof this.globalId&&!!t?.supportsPagination}set displayCount(t){const e=0,o=3;this._set("displayCount",Math.max(t??o,e))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get globalId(){return(this.globalIdField&&this.graphic?.attributes?.[this.globalIdField])??null}get globalIdField(){const{layer:t}=this;return"subtype-sublayer"===t?.type&&t?.parent?t.parent.globalIdField??null:t?.globalIdField??null}get activeAssociationType(){return this._get("activeAssociationType")}set activeAssociationType(t){t&&!this.associationTypes.includes(t)||this._set("activeAssociationType",t)}get state(){const{_queryAbortController:t,_queryFeatureCountAbortController:e,_queryPageAbortController:o,canQuery:s,_loaded:r,canLoad:a}=this;return e||a&&!r?"loading":t||o?"querying":s&&0!==this.featureCount?"ready":"disabled"}get utilityNetwork(){const{layer:t,map:e}=this;return t?.loaded&&e?"subtype-sublayer"===t?.type&&t?.parent?m(e,t.parent)??null:m(e,t)??null:null}get attachmentsAssociations(){return this._get("attachmentsAssociations")||new r}get structureAssociations(){return this._get("structureAssociations")||new r}get contentAssociations(){return this._get("contentAssociations")||new r}get containerAssociations(){return this._get("containerAssociations")||new r}get connectivityAssociations(){return this._get("connectivityAssociations")||new r}get associationFeatures(){return this._get("associationFeatures")||new c}get associationViewModels(){return this._get("associationViewModels")||new Map}async refresh(){await this._queryFeatureCountDebounced(),await this._queryOpenAssociationType()}getFeatureCountForAssociationType(t){switch(t){case"attachment":return this.attachmentsFeatureCount;case"structure":return this.structureFeatureCount;case"content":return this.contentFeatureCount;case"container":return this.containerFeatureCount;case"connectivity":return this.connectivityFeatureCount}}_destroyAssociatedFeatureViewModels(){this.associationViewModels.forEach((t=>t.destroyAll()))}async _loadUtiltyNetworks(){const t=this.map;if(!t)return;await Promise.allSettled(t.utilityNetworks?.map((async t=>{await t.load()}))??[]);const e=this.utilityNetwork;if(e){const o=t=>{if("layerId"in t&&e.isUtilityLayer(t)){const o=e.getSourceIdByLayerId(t.layerId);null!==o&&this.networkSourceIdsInUse.add(o)}};this._set("networkSourceIdsInUse",new Set),t.allLayers.forEach(o),t.allTables.forEach(o)}}async _findLayersBySourceId(t){const{utilityNetwork:e,map:o}=this,s=t=>{const o=t;if(!t.url)return!1;if(o.layerId===r){return t.url.replace(/\/\d+$/,"")===e?.featureServiceUrl}return!1};await(e?.load());const r=e.getLayerIdBySourceId(t),a=o.allLayers.filter(s),i=o.allTables.filter(s),n=a.concat(i).toArray();return await Promise.allSettled(n.map((t=>t.load()))),n}_clearAssociations(){this.attachmentsAssociations.removeAll(),this.structureAssociations.removeAll(),this.contentAssociations.removeAll(),this.containerAssociations.removeAll(),this.connectivityAssociations.removeAll()}_clearFeatures(){this.associationFeatures.forEach((t=>t.removeAll())),this.associationFeatures.clear()}_getAssociationsByType(t){switch(t){case"attachment":return this.attachmentsAssociations;case"structure":return this.structureAssociations;case"connectivity":return this.connectivityAssociations;case"container":return this.containerAssociations;case"content":return this.contentAssociations}}async _queryLayer(t,e,o,s,r){const a=t.fieldsIndex.get(g.assetGroup),i=t.fieldsIndex.get(g.assetType),n=null!=o,c=null!=s,l="("+e.map((t=>`'${t}'`)).join(", ")+")",u=n?` AND ${a?.name} = ${o}`:"",d=n&&c?` AND ${i?.name} = ${s}`:"",y=`${t.globalIdField} IN ${l}`+u+d,h=new p({outFields:["*"],cacheHint:this.supportsCacheHint,where:y});return await this._queryAll(h,t,{signal:r?.signal})}async _createAssociationFeatureObjects(t,e,o,s,r,a){if(0===t.length)return[];const i=new Map;for(const[c,l]of e){const t=await this._findLayersBySourceId(c);for(const e of t){(await this._queryLayer(e,l,s,r,a)).forEach((t=>{if("popup"===this.source?t.layer&&t.getEffectivePopupTemplate():!!t.layer){const o=i.get(t.attributes[e.globalIdField])??[];o.push(t),i.set(t.attributes[e.globalIdField],o)}}))}}const n=[];return t.toArray().forEach((t=>{const{fromNetworkElement:e,toNetworkElement:s}=t,r=e.globalId===o?s:e;(i.get(r.globalId)??[]).forEach((e=>{const o=this.utilityNetwork?.getTerminalById(r?.terminalId)?.name;n.push({association:t,feature:e,terminalName:o})}))})),n}_parseFeatureObjects(t,e){t.forEach((t=>{const o=t?.feature,s=o.layer,a=e.get(s)??new r;a.add(t),e.set(s,a)}))}async _queryAll(t,e,o){const s=[];let r=0,a=!1;t.num=e.sourceJSON?.maxRecordCount??2e3;do{t.start=r;const i=await e.queryFeatures(t,o);s.push(...i.features),a=i.exceededTransferLimit,a&&(r+=i.features.length)}while(a);return s}async _queryAssociations(t){const{layer:e,globalId:o,associationTypes:s,utilityNetwork:r,canQuery:a}=this;if(await Promise.allSettled([e?.load(),r?.load()]),this._clearAssociations(),!(a&&e&&s&&r&&o))return;const i=new h({globalId:o,networkSourceId:r?.getSourceIdByLayerId(e?.layerId??e?.parent?.layerId)}),n=new Set;s.forEach((t=>{switch(t.type){case"attachment":case"structure":n.add("attachment");break;case"container":case"content":n.add("containment");break;case"connectivity":n.add("connectivity"),n.add("junction-junction-connectivity"),n.add("junction-edge-from-connectivity"),n.add("junction-edge-midspan-connectivity"),n.add("junction-edge-to-connectivity")}}));const c=await(r?.queryAssociations({elements:[i],types:Array.from(n)},{signal:t?.signal})),l=new Map,u=new Map;s.forEach((t=>{u.set(t.type,t),l.set(t.type,[])})),c?.forEach((t=>{const{toNetworkElement:e,fromNetworkElement:s}=t;switch(t.associationType){case"connectivity":case"junction-junction-connectivity":case"junction-edge-from-connectivity":case"junction-edge-midspan-connectivity":case"junction-edge-to-connectivity":if(s?.globalId===o){if(null!=u.get("connectivity")?.associatedNetworkSourceId&&u.get("connectivity")?.associatedNetworkSourceId!==e?.networkSourceId)break;l.get("connectivity").push(e.globalId)}else{if(null!=u.get("connectivity")?.associatedNetworkSourceId&&u.get("connectivity")?.associatedNetworkSourceId!==s?.networkSourceId)break;l.get("connectivity")?.push(s.globalId)}this.connectivityAssociations.add(t);break;case"containment":if(s?.globalId===o){if(null!=u.get("content")?.associatedNetworkSourceId&&u.get("content")?.associatedNetworkSourceId!==e?.networkSourceId)break;l.get("content")?.push(e.globalId),this.contentAssociations.add(t)}else{if(null!=u.get("container")?.associatedNetworkSourceId&&u.get("container")?.associatedNetworkSourceId!==s?.networkSourceId)break;l.get("container")?.push(s.globalId),this.containerAssociations.add(t)}break;case"attachment":if(s?.globalId===o){if(null!=u.get("attachment")?.associatedNetworkSourceId&&u.get("attachment")?.associatedNetworkSourceId!==e?.networkSourceId)break;l.get("attachment")?.push(e.globalId),this.attachmentsAssociations.add(t)}else{if(null!=u.get("structure")?.associatedNetworkSourceId&&u.get("structure")?.associatedNetworkSourceId!==s?.networkSourceId)break;l.get("structure")?.push(s.globalId),this.structureAssociations.add(t)}}}));const d=s.map((async e=>{const{associatedNetworkSourceId:o,associatedAssetGroup:s,associatedAssetType:r}=e,a=l.get(e.type),i=null!=s?await this._countAssociatedFeatures(o,a,s,r,t):a.length;switch(e.type){case"attachment":this._set("attachmentsFeatureCount",i);break;case"structure":this._set("structureFeatureCount",i);break;case"content":this._set("contentFeatureCount",i);break;case"container":this._set("containerFeatureCount",i);break;case"connectivity":this._set("connectivityFeatureCount",i)}}));await Promise.allSettled(d)}async _countAssociatedFeatureCount(t,e,o,s,r){const a=t.fieldsIndex.get(g.assetGroup),i=t.fieldsIndex.get(g.assetType),n=null!=s,c="("+e.map((t=>`'${t}'`)).join(", ")+")",l=` AND ${a?.name} = ${o}`,u=n?` AND ${i?.name} = ${s}`:"",d=`${t.globalIdField} IN ${c}`+l+u;return t.queryFeatureCount({where:d,outFields:["*"],returnGeometry:!1},{signal:r?.signal})}async _countAssociatedFeatures(t,e,o,s,r){if(0===e.length)return 0;const a=(await this._findLayersBySourceId(t)).map((async t=>this._countAssociatedFeatureCount(t,e,o,s,r)));return(await Promise.all(a)).reduce(((t,e)=>t+e),0)}async _queryAssociatedFeatures(t,e){const{layer:o,globalId:s,associationTypes:r,utilityNetwork:a,canQuery:i,associationFeatures:n}=this;if(await Promise.allSettled([o?.load(),a?.load()]),!(i&&o&&r&&a))return;const c=this._getAssociationsByType(t.type),{associatedAssetGroup:l,associatedAssetType:u}=t,d=new Map;c.forEach((t=>{const{fromNetworkElement:e,toNetworkElement:o}=t,{networkSourceId:r,elementGlobalId:a}=e.globalId===s?{networkSourceId:o.networkSourceId,elementGlobalId:o.globalId}:{networkSourceId:e.networkSourceId,elementGlobalId:e.globalId},i=d.get(r)||[];i.push(a),d.set(r,i)}));const y=await this._createAssociationFeatureObjects(c,d,s,l,u,e);this._parseFeatureObjects(y,n)}async _queryFeatureCount(){await this._loadUtiltyNetworks();const{_queryFeatureCountAbortController:t,canQuery:e}=this;e?(await this._queryAssociations(t),this._set("featureCount",this.attachmentsFeatureCount+this.structureFeatureCount+this.contentFeatureCount+this.containerFeatureCount+this.connectivityFeatureCount)):this._set("featureCount",0)}async _query(t){if(!t)return;await this._loadUtiltyNetworks();const{_queryAbortController:e}=this;this._destroyAssociatedFeatureViewModels(),this._clearFeatures(),0!==this.featureCount&&(this.destroyed||await this._queryAssociatedFeatures(t,{signal:e?.signal}))}};t([d()],b.prototype,"_loaded",void 0),t([d()],b.prototype,"_queryAbortController",void 0),t([d()],b.prototype,"_queryPageAbortController",void 0),t([d()],b.prototype,"_queryFeatureCountAbortController",void 0),t([d({readOnly:!0})],b.prototype,"supportsCacheHint",null),t([d({readOnly:!0})],b.prototype,"canLoad",null),t([d({readOnly:!0})],b.prototype,"canQuery",null),t([d()],b.prototype,"networkSourceIdsInUse",void 0),t([d({constructOnly:!0})],b.prototype,"source",void 0),t([d()],b.prototype,"description",void 0),t([d({value:3})],b.prototype,"displayCount",null),t([d({type:e})],b.prototype,"graphic",void 0),t([d()],b.prototype,"layer",void 0),t([d()],b.prototype,"map",void 0),t([d({readOnly:!0})],b.prototype,"objectId",null),t([d({readOnly:!0})],b.prototype,"objectIdField",null),t([d({readOnly:!0})],b.prototype,"globalId",null),t([d({readOnly:!0})],b.prototype,"globalIdField",null),t([d()],b.prototype,"featureCount",void 0),t([d()],b.prototype,"associationTypes",void 0),t([d()],b.prototype,"activeAssociationType",null),t([d()],b.prototype,"showAllEnabled",void 0),t([d()],b.prototype,"state",null),t([d()],b.prototype,"title",void 0),t([d({readOnly:!0})],b.prototype,"utilityNetwork",null),t([d({readOnly:!0})],b.prototype,"attachmentsFeatureCount",void 0),t([d({readOnly:!0})],b.prototype,"structureFeatureCount",void 0),t([d({readOnly:!0})],b.prototype,"attachmentsAssociations",null),t([d({readOnly:!0})],b.prototype,"structureAssociations",null),t([d({readOnly:!0})],b.prototype,"contentFeatureCount",void 0),t([d({readOnly:!0})],b.prototype,"containerFeatureCount",void 0),t([d({readOnly:!0})],b.prototype,"contentAssociations",null),t([d({readOnly:!0})],b.prototype,"containerAssociations",null),t([d({readOnly:!0})],b.prototype,"connectivityFeatureCount",void 0),t([d({readOnly:!0})],b.prototype,"connectivityAssociations",null),t([d({readOnly:!0})],b.prototype,"associationFeatures",null),t([d({readOnly:!0})],b.prototype,"associationViewModels",null),b=t([y("esri.widgets.support.UtilityNetworkAssociations.UtilityNetworkAssociationsViewModel")],b);const A=b;export{A as default};