@arcgis/core 4.27.0-rc.1 → 4.27.0-rc.2

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 (98) hide show
  1. package/README.md +2 -2
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{92e7f224a80195e606d6.js → 1f69fb9687de9ebfcf90.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{0a02ac5628d1739372c6.js → 2b55295590b4a0503749.js} +1 -1
  5. package/assets/esri/core/workers/chunks/471f6eba213412b82840.js +1 -0
  6. package/assets/esri/core/workers/chunks/{f339db2b599fa9585283.js → 5e6471dd2a08e66b47d0.js} +79 -81
  7. package/assets/esri/core/workers/chunks/{474d9b334812533bab36.js → 6cd248d065f6d1616294.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{d8bd3f498b3fa8153404.js → 6f510f28526c73ab453c.js} +1 -1
  9. package/assets/esri/core/workers/chunks/83e3d104886b48f00397.js +1 -0
  10. package/assets/esri/core/workers/chunks/{3c5a64a545272f148e93.js → 9621b7d8d951aa881686.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{b6e173eddaad4244cb5f.js → b31974524932e638df8c.js} +1 -1
  12. package/assets/esri/core/workers/chunks/da57eba2fe25495ea217.js +1 -0
  13. package/assets/esri/core/workers/chunks/dabd889e064c4e7807fa.js +1 -0
  14. package/assets/esri/core/workers/chunks/f35895e03c036d67b3ed.js +1 -0
  15. package/assets/esri/core/workers/chunks/{c6efe2e04ea6a55bb6e3.js → f6e68befe2812b90b40d.js} +1 -1
  16. package/assets/esri/themes/base/widgets/_Feature.scss +4 -0
  17. package/assets/esri/themes/base/widgets/_FeatureContent.scss +9 -2
  18. package/assets/esri/themes/base/widgets/_ScaleRangeSlider.scss +1 -0
  19. package/assets/esri/themes/dark/main.css +1 -1
  20. package/assets/esri/themes/light/main.css +1 -1
  21. package/assets/esri/themes/light/view.css +1 -1
  22. package/chunks/DefaultMaterial.glsl.js +3 -2
  23. package/chunks/ShadowCastAccumulate.glsl.js +1 -1
  24. package/core/timeUtils.js +1 -1
  25. package/geometry/Mesh.js +1 -1
  26. package/geometry/support/meshVertexSpaceUtils.js +5 -0
  27. package/interfaces.d.ts +179 -31
  28. package/kernel.js +1 -1
  29. package/layers/VideoLayer.js +1 -1
  30. package/layers/graphics/controllers/StreamController.js +1 -1
  31. package/layers/graphics/data/QueryEngine.js +1 -1
  32. package/layers/graphics/data/attributeSupport.js +1 -1
  33. package/layers/graphics/editingSupport.js +1 -1
  34. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  35. package/layers/video/VideoController.js +1 -1
  36. package/layers/video/videoUtils.js +5 -0
  37. package/package.json +1 -1
  38. package/rest/support/meshFeatureSet.js +1 -1
  39. package/smartMapping/symbology/flow.js +1 -1
  40. package/statistics/utils.js +1 -1
  41. package/support/revision.js +1 -1
  42. package/symbols/cim/CIMSymbolHelper.js +1 -1
  43. package/views/2d/layers/StreamLayerView2D.js +1 -1
  44. package/views/2d/layers/features/sources/StreamSource.js +1 -1
  45. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  46. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  47. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  48. package/views/3d/layers/I3SMeshView3D.js +1 -1
  49. package/views/3d/layers/II3SMeshView3D.js +1 -1
  50. package/views/3d/layers/SceneLayerView3D.js +1 -1
  51. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  52. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  53. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  54. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  55. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  56. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  57. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  58. package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
  59. package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +3 -9
  60. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +12 -9
  61. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +10 -10
  62. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
  63. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterDistortion.glsl.js +2 -2
  64. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +8 -8
  65. package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
  66. package/views/3d/webgl-engine/lib/ShadowHighlight.js +1 -1
  67. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  68. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  69. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  70. package/views/3d/webgl-engine/materials/pbrUtils.js +1 -1
  71. package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
  72. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  73. package/views/3d/webgl-engine/shaders/ShadowHighlightTechnique.js +1 -1
  74. package/views/draw/DrawGraphicTool.js +1 -1
  75. package/views/layers/GroupLayerView.js +1 -1
  76. package/widgets/Daylight/DaylightViewModel.js +1 -1
  77. package/widgets/Editor/EditorViewModel.js +1 -1
  78. package/widgets/Editor/UpdateWorkflow.js +1 -1
  79. package/widgets/Editor/Workflow.js +1 -1
  80. package/widgets/Editor/workflowUtils.js +1 -1
  81. package/widgets/Editor.js +1 -1
  82. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  83. package/widgets/Feature/FeatureRelationship.js +1 -1
  84. package/widgets/FeatureForm/EditableInput.d.ts +2 -2
  85. package/widgets/FeatureTable/FieldColumn.js +1 -1
  86. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  87. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  88. package/widgets/UtilityNetworkTrace/support/ResultAreaHandler.js +1 -1
  89. package/widgets/UtilityNetworkTrace.js +1 -1
  90. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  91. package/widgets/UtilityNetworkValidateTopology.js +1 -1
  92. package/widgets/ValuePicker/ValuePickerBaseComponent.js +1 -1
  93. package/widgets/ValuePicker.js +1 -1
  94. package/assets/esri/core/workers/chunks/07651ef8348f702d59ac.js +0 -1
  95. package/assets/esri/core/workers/chunks/39714837f9d3708e3806.js +0 -1
  96. package/assets/esri/core/workers/chunks/785a6c925f29bc962992.js +0 -1
  97. package/assets/esri/core/workers/chunks/90da1ed112b82712d0ef.js +0 -1
  98. package/assets/esri/core/workers/chunks/b5fc6f2044ed047c5afd.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.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as r,makeHandle as n}from"../../core/handleUtils.js";import{clone as i}from"../../core/lang.js";import{throwIfAborted as a,whenOrAbort as s,eachAlways as l}from"../../core/promiseUtils.js";import{watch as o,whenOnce as c}from"../../core/reactiveUtils.js";import{px2pt as u}from"../../core/screenUtils.js";import{diff as p}from"../../core/accessorSupport/diffUtils.js";import{getDisplayFieldName as y}from"../../layers/support/fieldUtils.js";import{calculateTolerance as f}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as d}from"../../renderers/support/lengthUtils.js";import{getTransformationType as m,TransformationType as g}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as h,getSize as b}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as w,i3sPatchingEnabled as v}from"../../support/featureFlags.js";import{to3D as S}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as j}from"../../symbols/support/symbolUtils.js";import{GraphicState as I}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as U}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as V,filterGraphicHits as F}from"../../views/support/hitTestSelectUtils.js";function T(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!O(t.renderer))return{rotation:null,size:null};let r=null,n=null;const i=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=h(t,e)));1===i.length&&(r=z(i[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&m(t)===g.RealWorldSize&&null!=b(t,e)));return 1===a.length&&(n=E(a[0],t)),{rotation:r,size:n}}function z(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=e.field,i=t.fields&&t.fields.filter((e=>e.name===n)),a=i&&1===i.length?i[0].type:"double",s={initial:0,current:0};return{field:n,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,A((s.current+360)%360,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function x(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 L(e,t,r){if(null==t)return 0;const{symbol:n}=S(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const i=n.symbolLayers.at(0);if(!i)return 0;switch(i.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return i.size||Math.min($.icon,(await e(i,$.icon))[0])||$.icon}case"text":return i.size||$.text;case"line":return i.size||$.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return x(await t(i,e.scale/$.viewScaleSizeFactor),r)}case"path":return(null!=i.width?i.width:i.height)||e.scale/$.viewScaleSizeFactor;case"extrude":return i.size||e.scale/$.viewScaleSizeFactor;default:return 0}}function E(e,t){const r=e.field,n=e.axis,i=t.fields&&t.fields.filter((e=>e.name===r)),a=i&&1===i.length?i[0].type:"double",s={updating:!1,initial:0,current:0},l=d[e.valueUnit]??1;let o;return o="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)=>A(o(await L(t,e,n)),a),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,A(s.current,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:ne(e.valueUnit),axis:e.axis}}function A(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 O(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 M(e,t){const r=await j(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t});null!=p(e.symbol,r)&&(e.symbol=r)}function R(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function k(e,t,i,a){await G(e,t,a);const s=e.on("create",(async r=>{if("cancel"===r.state)return G(e,t,a);if("complete"===r.state){const e=r.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await M(e,a),i(e)}}));return r([s,n((()=>e.cancel()))])}async function G(e,t,r){const n=t.layer,i={...t.template.prototype.attributes};await P(e,n,i,r),e.layer.elevationInfo=n.elevationInfo,await e.create(R(n.geometryType),{graphicProperties:{attributes:i,sourceLayer:n},hasZ:n.capabilities.data.supportsZ,geometryToPlace:t.geometryToPlace??void 0})}async function P(t,r,n,i){const a=new e({sourceLayer:r,attributes:n}),{rotation:s,size:l}=T(a);let o=await j(a,{useSourceLayer:!0,webStyleCache:i}),c=!1;for(const e of[l,s]){if(null==e)continue;null==n[e.field]&&(n[e.field]=await e.getDefault(o,t.view),c=!0)}switch(c&&(o=await j(a,{useSourceLayer:!0,webStyleCache:i})),o?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=o;break;case"simple-line":case"line-3d":t.polylineSymbol=o;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=o}D(t.tooltipOptions,l,s)}function D(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 C(e,t){return e?e.find((e=>e.layer===t)):void 0}async function q(e,t,r,n){if(0===e.length)return[];const{updatable:i,graphicsByLayer:a}=await r.async((async()=>{const{results:i}=await s(V(t,r),n),a=new Map,l=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};F(i).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&a.has(t)));return 0!==o.length&&r.stopPropagation(),{updatable:o,graphicsByLayer:a}}));return s(l(i.map((async({layer:e})=>{const{objectIdField:t}=e,r="displayField"in e?e.displayField:null,i=[t];null!=r&&e.fieldsIndex.has(r)&&i.push(r);const s=a.get(e);if(!!s.some((e=>i.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=i,t.returnGeometry=!1,t.objectIds=s.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:n}).then((({features:e})=>e))}return s}))),n)}async function Z(e,t,r,n){if(0===e.length)return[];let i=null;const a=await r.async((async()=>{const{results:a}=await s(t.hitTest(r),n);if(0===a.length)return[];const l=new Set;i=F(a),i.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:r})=>l.has(e)&&(t.includes("update")||t.includes("delete")||r)));return o.length>0&&r.stopPropagation(),o}));return s(l(a.map((({layer:e})=>{const a=e.objectIdField,s="displayField"in e?e.displayField:null,l=y({displayField:s,fields:e.fields}),o=[a];null!=l&&e.fieldsIndex.has(l)&&o.push(l);const c=e.createQuery();c.outFields=o,c.returnGeometry=!1;const u="renderer"in e?f({renderer:e.renderer,event:r}):0;return c.geometry=U(r.mapPoint,u,t),c.outSpatialReference=t.spatialReference,e.queryFeatures(c,{signal:n}).then((({features:t})=>(i?.forEach((({graphic:r})=>{r.layer!==e||t.some((e=>e.getObjectId()===r.getObjectId()))||t.push(r)})),t)))}))),n)}async function Q(e,t,r,n){switch(t.type){case"3d":return q(e,t,r,n);case"2d":return Z(e,t,r,n)}}async function B(e,t,r){const{sourceLayer:n}=e,i=n.createQuery();i.objectIds=[e.getAttribute(n.objectIdField)],i.outFields=["*"],i.outSpatialReference=t,i.returnM=n.capabilities.data.supportsM,i.returnZ=n.capabilities.data.supportsZ,w()&&v()&&"scene"===n.type&&null!=n.infoFor3D&&(i.returnGeometry=!0,i.formatOf3DObjects="3D_glb");const s=await n.queryFeatures(i,{signal:r});a(r);return s.features[0]}async function W(e,t,r,n,i){let a=!1;const{rotation:s,size:l}=n;[s,l].forEach((async r=>{if(null==r)return;const n=t.getAttribute(r.field);if(null!=n)r.initValue(n);else{const n=await r.getDefault(t.symbol,e.view);r.initValue(n),t.setAttribute(r.field,n),a=!0}})),a&&await M(t,i);const o={multipleSelectionEnabled:!1};return"point"===r.geometryType&&(o.enableRotation=null!=s,o.enableScaling=null!=l),D(e.tooltipOptions,l,s),e.layer.elevationInfo=r.elevationInfo,e.update(t,o)}function _(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function H(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function J(e,t,r,n,i){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=n.rotation,s=_(r.toolEventInfo);if(null!=a&&null!=s)if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.initValue();else{a.isUpdatingInteractively=!0;const{field:r,getValue:n}=a;t.setAttribute(r,n(s.angle,e))}const l=n.size,o=H(r.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:r,getValue:n}=l;t.setAttribute(r,n(o.xScale,e))}await M(t,i)}async function K(e,t,i,a,s,l){const c=pe(e);await M(c,l),a.map.add(i.layer),i.layer.add(c);const u=e.sourceLayer,p=le(a,u);await Y(a,c),await W(i,c,u,t,l);const y=N(i,e,c);let f=null;p.then((e=>f=e)).catch((()=>{}));const d=t.size,m=t.rotation,g=o((()=>e.attributes),(async e=>{let t=!1;for(const r in e){const n=e[r];n!==c.getAttribute(r)&&(c.setAttribute(r,n),null==d||d.isUpdatingInteractively||d.field!==r||d.initValue(n),null==m||m.isUpdatingInteractively||m.field!==r||m.initValue(n),(null==f||f.requiredFields.includes(r))&&(t=!0))}t&&await M(c,l)})),h=i.on("update",(async e=>{const r=e.graphics[0];if("complete"===e.state)return W(i,r,u,t,l);await J(a,r,e,t,l),s(pe(r),e)})),b=i.on(["undo","redo"],(async e=>{s(pe(e.graphics[0]),e)}));return{interactive:r([b,h,n((()=>i.cancel())),g]),visual:y}}function N(e,i,s){const l=e.view,o=i.sourceLayer,u=i.layer,p=i.getAttribute(u.objectIdField);let y=null;function f(e){y?.abort(),y=t((async t=>{const r=await le(l,o);a(t),r.setVisibility?.(p,e)}))}return f(!1),r([X(l,s,(e=>f(!e))),n((async()=>{f(!0);const t=await le(l,o);await c((()=>!t.updating)),e.layer.remove(s)}))])}function X(e,t,n){if("3d"===e.type){const i=new I({graphic:t});return r([e.trackGraphicState(i),o((()=>i.displaying),n)])}return o((()=>t.visible),n)}async function Y(e,t){if("3d"===e.type){const r=new I({graphic:t}),n=e.trackGraphicState(r);await c((()=>r.displaying)),n.remove()}else await c((()=>t.visible))}const $={icon:u(24),text:u(12),line:u(1),viewScaleSizeFactor:100};function ee(e,t,r){let n=!1;return e.filter((e=>!!n||(n=e===t,n))).map((e=>r[e]()))}function te(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function re(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const r=te(e.viewModel.featureTemplatesViewModel.items);null==r||r.supportsUpload||(e.creationInfo=r,t.shift())}return t}function ne(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function ie(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ae(e){const{creationInfo:t,viewModel:r}=e;if(!t)return!1;const{layer:n}=t,i=r.editableItems.find((e=>e.layer===n));if(i)return i.attachmentsOnCreateEnabled;const a=n.capabilities?.data,s=r.layerInfos?.find((e=>e.layer===n));return!(!(a&&"supportsAttachment"in a&&a.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const se=e=>/-stop/.test(e)||/vertex-/.test(e),le=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function oe(e){return"createInteractiveEditSession"in e}const ce=Symbol();function ue(e){return e&&"object"==typeof e&&ce in e}function pe(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=i(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function ye(e){const t=e.cursor;return e.cursor="progress",n((()=>e.cursor=t))}export{ce as UsesSketchViewModelSymbol,re as avoidFeatureTemplateSelectionWithOnlyOneItem,oe as canCreateInteractiveEditSession,pe as cloneGraphicExceptMesh,ee as createWorkflowSteps,Q as fetchCandidates,B as fetchFullFeature,C as findLayerInfo,T as getVisualVariableAttributes,se as isTerminalUpdateEventType,ie as prepareAttachmentsForCreateWorkflow,k as setUpFeatureAdd,K as setUpGeometryUpdate,ae as shouldShowAttachmentsForCreateWorkflow,ye as showProgressCursor,$ as sizeDefaults,ne as sizeVariableUnitToLengthUnit,G as startCreatingNewFeature,W as startUpdatingFeature,M as updateGraphicSymbolWhenRequired,J as visualVariableInteractiveUpdate,le as whenEditorLayerView,Y as whenGraphicDisplayed,ue as workflowUsesSketchViewModel};
5
+ import e from"../../Graphic.js";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as i,makeHandle as r}from"../../core/handleUtils.js";import{clone as n}from"../../core/lang.js";import{throwIfAborted as a,whenOrAbort as s,eachAlways as l}from"../../core/promiseUtils.js";import{watch as o,whenOnce as c}from"../../core/reactiveUtils.js";import{px2pt as u}from"../../core/screenUtils.js";import{diff as p}from"../../core/accessorSupport/diffUtils.js";import{getDisplayFieldName as y}from"../../layers/support/fieldUtils.js";import{calculateTolerance as d}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as f}from"../../renderers/support/lengthUtils.js";import{getTransformationType as m,TransformationType as h}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as g,getSize as b}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as w,i3sPatchingEnabled as v}from"../../support/featureFlags.js";import{to3D as S}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as j}from"../../symbols/support/symbolUtils.js";import{GraphicState as I}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as U}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as V,filterGraphicHits as F}from"../../views/support/hitTestSelectUtils.js";function T(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!A(t.renderer))return{rotation:null,size:null};let i=null,r=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=g(t,e)));1===n.length&&(i=z(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&m(t)===h.RealWorldSize&&null!=b(t,e)));return 1===a.length&&(r=E(a[0],t)),{rotation:i,size:r}}function z(e,t){const i="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,r=e.field,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",s={initial:0,current:0};return{field:r,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-i*e,O((s.current+360)%360,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function x(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 L(e,t,i){if(null==t)return 0;const{symbol:r}=S(t);if(null==r||"web-style"===r.type||"cim"===r.type)return 0;const n=r.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($.icon,(await e(n,$.icon))[0])||$.icon}case"text":return n.size||$.text;case"line":return n.size||$.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return x(await t(n,e.scale/$.viewScaleSizeFactor),i)}case"path":return(null!=n.width?n.width:n.height)||e.scale/$.viewScaleSizeFactor;case"extrude":return n.size||e.scale/$.viewScaleSizeFactor;default:return 0}}function E(e,t){const i=e.field,r=e.axis,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",s={updating:!1,initial:0,current:0},l=f[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:i,fieldType:a,getDefault:async(e,t)=>O(o(await L(t,e,r)),a),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,O(s.current,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:re(e.valueUnit),axis:e.axis}}function O(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 A(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 k(e,t){const i=await j(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t});null!=p(e.symbol,i)&&(e.symbol=i)}function G(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function M(e,t,n,a){await R(e,t,a);const s=e.on("create",(async i=>{if("cancel"===i.state)return R(e,t,a);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await k(e,a),n(e)}}));return i([s,r((()=>e.cancel()))])}async function R(e,t,i){const r=t.layer,n={...t.template.prototype.attributes};await C(e,r,n,i),e.layer.elevationInfo=r.elevationInfo,await e.create(G(r.geometryType),{graphicProperties:{attributes:n,sourceLayer:r},hasZ:r.capabilities.data.supportsZ,geometryToPlace:t.geometryToPlace??void 0})}async function C(t,i,r,n){const a=new e({sourceLayer:i,attributes:r}),{rotation:s,size:l}=T(a);let o=await j(a,{useSourceLayer:!0,webStyleCache:n}),c=!1;for(const e of[l,s]){if(null==e)continue;null==r[e.field]&&(r[e.field]=await e.getDefault(o,t.view),c=!0)}switch(c&&(o=await j(a,{useSourceLayer:!0,webStyleCache:n})),o?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=o;break;case"simple-line":case"line-3d":t.polylineSymbol=o;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=o}P(t.tooltipOptions,l,s)}function P(e,t,i){e.visualVariables=null!=t||null!=i?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=i?{valueType:i.fieldType,rotationType:i.rotationType??"geographic"}:null}:null}function D(e,t){return e?e.find((e=>e.layer===t)):void 0}async function q(e,t,i,r){if(0===e.length)return[];const{updatable:n,graphicsByLayer:a}=await i.async((async()=>{const{results:n}=await s(V(t,i),r),a=new Map,l=e=>{const t=e.layer,i=a.get(t);if(!i){const e=new Array;return a.set(t,e),e}return i};F(n).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&a.has(t)));return 0!==o.length&&i.stopPropagation(),{updatable:o,graphicsByLayer:a}}));return s(l(n.map((async({layer:e})=>{const{objectIdField:t}=e,i="displayField"in e?e.displayField:null,n=[t];null!=i&&e.fieldsIndex.has(i)&&n.push(i);const s=a.get(e);if(!!s.some((e=>n.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=n,t.returnGeometry=!1,t.objectIds=s.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:r}).then((({features:e})=>e))}return s}))),r)}async function Z(e,t,i,r){if(0===e.length)return[];let n=null;const a=await i.async((async()=>{const{results:a}=await s(t.hitTest(i),r);if(0===a.length)return[];const l=new Set;n=F(a),n.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:i})=>l.has(e)&&(t.includes("update")||t.includes("delete")||i)));return o.length>0&&i.stopPropagation(),o}));return s(l(a.map((({layer:e})=>{const a=e.objectIdField,s="displayField"in e?e.displayField:null,l=y({displayField:s,fields:e.fields}),o=[a];null!=l&&e.fieldsIndex.has(l)&&o.push(l);const c=e.createQuery();c.outFields=o,c.returnGeometry=!1;const u="renderer"in e?d({renderer:e.renderer,event:i}):0;return c.geometry=U(i.mapPoint,u,t),c.outSpatialReference=t.spatialReference,e.queryFeatures(c,{signal:r}).then((({features:t})=>(n?.forEach((({graphic:i})=>{i.layer!==e||t.some((e=>e.getObjectId()===i.getObjectId()))||t.push(i)})),t)))}))),r)}async function Q(e,t,i,r){switch(t.type){case"3d":return q(e,t,i,r);case"2d":return Z(e,t,i,r)}}async function B(e,t,i){const{sourceLayer:r}=e,n=r.createQuery();n.objectIds=[e.getAttribute(r.objectIdField)],n.outFields=["*"],n.outSpatialReference=t,n.returnM=r.capabilities.data.supportsM,n.returnZ=r.capabilities.data.supportsZ,w()&&v()&&"scene"===r.type&&null!=r.infoFor3D&&(n.returnGeometry=!0,n.formatOf3DObjects="3D_glb");const s=await r.queryFeatures(n,{signal:i});a(i);return s.features[0]}async function W(e,t,i,r,n){let a=!1;const{rotation:s,size:l}=r;[s,l].forEach((async i=>{if(null==i)return;const r=t.getAttribute(i.field);if(null!=r)i.initValue(r);else{const r=await i.getDefault(t.symbol,e.view);i.initValue(r),t.setAttribute(i.field,r),a=!0}})),a&&await k(t,n);const o={multipleSelectionEnabled:!1};return"point"===i.geometryType&&(o.enableRotation=null!=s,o.enableScaling=null!=l),P(e.tooltipOptions,l,s),e.layer.elevationInfo=i.elevationInfo,e.update(t,o)}function _(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function H(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function J(e,t,i,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=r.rotation,s=_(i.toolEventInfo);if(null!=a&&null!=s)if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.initValue();else{a.isUpdatingInteractively=!0;const{field:i,getValue:r}=a;t.setAttribute(i,r(s.angle,e))}const l=r.size,o=H(i.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:i,getValue:r}=l;t.setAttribute(i,r(o.xScale,e))}await k(t,n)}async function K(e,t,n,a,s,l){const c=pe(e);await k(c,l),a.map.add(n.layer),n.layer.add(c);const u=e.sourceLayer,p=le(a,u);await Y(a,c),await W(n,c,u,t,l);const y=N(n,e,c);let d=null;p.then((e=>d=e)).catch((()=>{}));const f=t.size,m=t.rotation,h=o((()=>e.attributes),(async e=>{let t=!1;for(const i in e){const r=e[i];r!==c.getAttribute(i)&&(c.setAttribute(i,r),null==f||f.isUpdatingInteractively||f.field!==i||f.initValue(r),null==m||m.isUpdatingInteractively||m.field!==i||m.initValue(r),(null==d||d.requiredFields.includes(i))&&(t=!0))}t&&await k(c,l)})),g=n.on("update",(async e=>{const i=e.graphics[0];if("complete"===e.state)return W(n,i,u,t,l);await J(a,i,e,t,l),s(pe(i),e)})),b=n.on(["undo","redo"],(async e=>{s(pe(e.graphics[0]),e)})),w=n.updateOnGraphicClick;return{visual:i([y,r((()=>{n.updateOnGraphicClick=!1}))]),interactive:i([b,g,r((()=>n.cancel())),h,r((()=>{n.updateOnGraphicClick=w}))])}}function N(e,n,s){const l=e.view,o=n.sourceLayer,u=n.layer,p=n.getAttribute(u.objectIdField);let y=null;function d(e){y?.abort(),y=t((async t=>{const i=await le(l,o);a(t),i.setVisibility?.(p,e)}))}return d(!1),i([X(l,s,(e=>d(!e))),r((async()=>{d(!0);const t=await le(l,o);await c((()=>!t.updating)),e.layer.remove(s)}))])}function X(e,t,r){if("3d"===e.type){const n=new I({graphic:t});return i([e.trackGraphicState(n),o((()=>n.displaying),r)])}return o((()=>t.visible),r)}async function Y(e,t){if("3d"===e.type){const i=new I({graphic:t}),r=e.trackGraphicState(i);await c((()=>i.displaying)),r.remove()}else await c((()=>t.visible))}const $={icon:u(24),text:u(12),line:u(1),viewScaleSizeFactor:100};function ee(e,t,i){let r=!1;return e.filter((e=>!!r||(r=e===t,r))).map((e=>i[e]()))}function te(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function ie(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const i=te(e.viewModel.featureTemplatesViewModel.items);null==i||i.supportsUpload||(e.creationInfo=i,t.shift())}return t}function re(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function ne(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ae(e){const{creationInfo:t,viewModel:i}=e;if(!t)return!1;const{layer:r}=t,n=i.editableItems.find((e=>e.layer===r));if(n)return n.attachmentsOnCreateEnabled;const a=r.capabilities?.data,s=i.layerInfos?.find((e=>e.layer===r));return!(!(a&&"supportsAttachment"in a&&a.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const se=e=>/-stop/.test(e)||/vertex-/.test(e),le=(e,t)=>{const i="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(i)};function oe(e){return"createInteractiveEditSession"in e}const ce=Symbol();function ue(e){return e&&"object"==typeof e&&ce in e}function pe(e){const t=e.geometry;if("mesh"===t?.type){const i=e.cloneShallow();return i.attributes=n(e.attributes),i.geometry=t.cloneShallow(),i.geometry.transform=t.transform?.clone()??null,i}return e.clone()}function ye(e){const t=e.cursor;return e.cursor="progress",r((()=>e.cursor=t))}export{ce as UsesSketchViewModelSymbol,ie as avoidFeatureTemplateSelectionWithOnlyOneItem,oe as canCreateInteractiveEditSession,pe as cloneGraphicExceptMesh,ee as createWorkflowSteps,Q as fetchCandidates,B as fetchFullFeature,D as findLayerInfo,T as getVisualVariableAttributes,se as isTerminalUpdateEventType,ne as prepareAttachmentsForCreateWorkflow,M as setUpFeatureAdd,K as setUpGeometryUpdate,ae as shouldShowAttachmentsForCreateWorkflow,ye as showProgressCursor,$ as sizeDefaults,re as sizeVariableUnitToLengthUnit,R as startCreatingNewFeature,W as startUpdatingFeature,k as updateGraphicSymbolWhenRequired,J as visualVariableInteractiveUpdate,le as whenEditorLayerView,Y as whenGraphicDisplayed,ue as workflowUsesSketchViewModel};
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.27/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{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as i,on as a,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as v}from"./Editor/deprecationUtils.js";import w from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import{renderItem as k,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as I}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",U=`${P}__panel`,j=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${U}-toolbar`,panelContent:`${U}-content`,panelContentMessage:`${U}-content__message`,panelContentSection:`${U}-content__section`,panelContentSectionGroup:`${U}-content__section__group`,panelContentScrimContainer:`${U}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,notice:`${P}__notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`,widgetIcon:"esri-icon-edit"},$={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function B(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let N=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new w,this.visibleElements={...$},this._renderSelectIcon=()=>L("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...n)=>{const{messagesCommon:i,viewModel:a,visibleElements:r}=this,l=a.sketchViewModel,c=a.syncing||this._attachments.submitting;return L("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},L("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[L("calcite-button",{key:"undo-button",label:i.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},i.undo),L("calcite-button",{key:"redo-button",label:i.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},i.redo)]),...n)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&y(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"continueEditing"]})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),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.previous(),this._clearPrompt())},this._onAttachmentsError=e=>{this._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([i((()=>M(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),i((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),a((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),i((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),i((()=>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"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:n}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{n(),this._clearPrompt()}}}}})),i((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),i((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=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 view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...$,...e,snappingControlsElements:{...$.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return v(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return v(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return v(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(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()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this;if(!e)return L("div",{key:"empty",class:D.base});const{state:t}=e;return L("div",{key:"base",class:D.base},L("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return L("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:n}=this;return L(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:o.selectTemplate,headingLevel:s},L("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:n,headingLevel:i,_onBack:a,viewModel:r}=this;if(!t)return null;const l=t.type,c=r.featureFormViewModel,d="update"===l&&!t.hasPendingEdits||r.syncing||c.updating,p="update"===l?o.editFeature:o.createFeatures,m="update"===l?n.update:n.create,h="create-features"===l&&"create-new"===t.createFeatureState,u="create-features"===l?t.numPendingFeatures:0,g=u>1?S(o.createFeaturesTemplate,{numFeatures:u}):m,_=t.shouldShowAttachments,f=c.inputs.every((e=>!e.visible))&&!_?this._renderMessage(S(o.clickToFinishTemplate,{button:m})):L("div",{key:"panel-content-section",class:D.panelContentSection},this._renderNotices(t),L("div",{class:D.panelContentSectionGroup},this._featureForm.render(),_&&L("div",{key:"attachments"},L(F,{level:M(i)},o.attachments),this._attachments.render())));return L(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:p,headingLevel:i,handleBack:a},L("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:h})},f,h&&L("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:d,label:g,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:n.delete}:null]))}_renderNotices(e){return[this._renderOwnerAdminNotice(e),this._renderInvalidFormTemplateNotice(e),this._renderInvalidDateFieldNotice(e)]}_renderOwnerAdminNotice(e){return e?.reliesOnOwnerAdminPrivileges&&this._renderNotice(this.messages.ownerAdminNotice)}_renderInvalidFormTemplateNotice(e){return e?.hasInvalidFormTemplate&&this._renderNotice(this.messages.formFieldUpdateError,{icon:O})}_renderInvalidDateFieldNotice(e){return e?.hasUnsupportedFields&&this._renderNotice(this.messages.formFieldUnsupportedUpdateError,{icon:O})}_renderNotice(e,t){return L("calcite-notice",{open:!0,scale:"s",class:D.notice,...t},L("div",{slot:"message"},e))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this;let o=null;return e.group.items.some((e=>(s.itemHasUnsupportedFields(e)?o=t.formFieldUnsupportedCreateError:s.itemHasInvalidFormTemplate(e)&&(o=t.formFieldCreateError),o))),o?this._renderNotice(o,{icon:O}):null}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesCommon:a}=this;return L(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:i.addAttachment,headingLevel:n,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?a.cancel:a.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:n,headingLevel:i,messages:a,messagesCommon:r}=this;return n?L(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:a.editAttachment,headingLevel:i,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),n.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return L("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return L("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:n,...i},a)=>L("calcite-button",{key:`action-${a}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...i},n))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:n}=e,i=n.secondary;let a;switch(o){case"danger":a="danger";break;case"info":a="brand";break;default:a="neutral"}const r=L("calcite-button",{afterCreate:B,appearance:"solid",key:"prompt-primary-button",kind:a,onclick:n.primary.action,scale:"m",width:i?"half":"full"},n.primary.label),l=i&&L("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:a,onclick:i.action,scale:"m",width:"half"},i.label);return L("calcite-scrim",{key:"prompt"},L("div",{class:`${D.promptContainer}--${o}`},L("div",{class:D.promptHeader},L("calcite-icon",{icon:O}),L(F,{class:D.promptHeading,level:this.headingLevel},t)),L("div",{class:D.promptMessage},s),L("div",{class:D.promptDivider}),L("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:n}=this,{canUpdate:i}=n,a=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!i&&0===a;return L(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},L("div",{key:"landing-content",class:D.panelContent},i&&L("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),a>0&&L("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&L("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,n=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return n?L("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},n):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return L("div",{key:"update-actions"},L(F,{level:M(this.headingLevel)},t.editFeatures),L("calcite-list",{selectionMode:"single",selectionAppearance:"border"},k({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return L("div",{key:"create-actions"},L(F,{level:M(t)},s.createFeatures),L("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=L("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return L("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return L("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return L("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:n}=s;return o?.template===e.template&&o?.layer===e.layer?n:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesTemplates:a,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(i.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:n}=s.layer,i=l.find((e=>e.layer===s.layer));if(!i)return null;const{attachmentsOnUpdateEnabled:a,supports:r}=i;return(r.includes("update")||r.includes("delete")||a)&&(!o||t?.toLowerCase().includes(o)||n?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return L(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:n,handleBack:o},L("div",{key:"feature-list",class:D.panelContent},L("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:a.filterPlaceholder,noItems:a.noItems,noMatches:a.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?L("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},L("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&L(I,{tooltipOptions:this.tooltipOptions}),t&&L(A,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const s=t.fieldsIndex.get(t.objectIdField),o=s.alias||s.name,{attributes:n}=e,i=m(t);return i&&n[i]&&`${n[i]}`||`${o}: ${n[s.name]}`}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const i=n(),{view:a}=this,r=a?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>i.resolve(!0)},secondary:{label:o,action:()=>i.resolve(!1)}}},i.promise.finally((()=>{this._clearPrompt(),r&&a?.focus()}))}_onSave(){this.viewModel.saveWorkflow()}_onDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={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}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.previous()):this._attachments.addAttachment().then((()=>e.previous())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.previous()):this._attachments.updateAttachment().then((()=>e.previous())))}_onAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}}};e([c()],N.prototype,"_featureForm",void 0),e([c()],N.prototype,"_attachments",void 0),e([c()],N.prototype,"_featureTemplates",void 0),e([c()],N.prototype,"_filterText",void 0),e([c()],N.prototype,"_prompt",void 0),e([c()],N.prototype,"_spinner",void 0),e([c()],N.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],N.prototype,"activeWorkflow",null),e([c()],N.prototype,"allowedWorkflows",null),e([c()],N.prototype,"useDeprecatedCreateWorkflow",null),e([c()],N.prototype,"headingLevel",void 0),e([c()],N.prototype,"iconClass",void 0),e([c()],N.prototype,"label",null),e([c()],N.prototype,"labelOptions",null),e([c()],N.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],N.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],N.prototype,"messagesTemplates",void 0),e([c()],N.prototype,"snappingOptions",null),e([c()],N.prototype,"tooltipOptions",null),e([c()],N.prototype,"supportingWidgetDefaults",void 0),e([c()],N.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],N.prototype,"viewModel",void 0),e([c()],N.prototype,"visibleElements",void 0),e([d("visibleElements")],N.prototype,"castVisibleElements",null),e([T()],N.prototype,"_onSave",null),e([T()],N.prototype,"_onDelete",null),e([T()],N.prototype,"_onBack",null),e([T()],N.prototype,"_onAttachmentAdd",null),e([T()],N.prototype,"_onAttachmentUpdate",null),e([T()],N.prototype,"_onAttachmentDelete",null),N=e([p(x)],N);const V=N;export{V as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as a,on as i,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as w}from"./Editor/deprecationUtils.js";import v from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import{renderItem as k,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as I}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",U=`${P}__panel`,j=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${U}-toolbar`,panelContent:`${U}-content`,panelContentMessage:`${U}-content__message`,panelContentSection:`${U}-content__section`,panelContentSectionGroup:`${U}-content__section__group`,panelContentScrimContainer:`${U}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,notice:`${P}__notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`,widgetIcon:"esri-icon-edit"},$={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function B(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let N=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements={...$},this._renderSelectIcon=()=>L("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...n)=>{const{messagesCommon:a,viewModel:i,visibleElements:r}=this,l=i.sketchViewModel,c=i.syncing||this._attachments.submitting;return L("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},L("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[L("calcite-button",{key:"undo-button",label:a.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},a.undo),L("calcite-button",{key:"redo-button",label:a.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},a.redo)]),...n)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&y(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"continueEditing"]})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),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._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([a((()=>M(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),a((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),i((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),a((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),a((()=>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"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:n}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{n(),this._clearPrompt()}}}}})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=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 view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...$,...e,snappingControlsElements:{...$.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return w(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return w(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return w(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(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()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this;if(!e)return L("div",{key:"empty",class:D.base});const{state:t}=e;return L("div",{key:"base",class:D.base},L("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return L("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:n}=this;return L(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:o.selectTemplate,headingLevel:s},L("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:n,headingLevel:a,_onBack:i,viewModel:r}=this;if(!t)return null;const l=t.type,c=r.featureFormViewModel,d="update"===l&&!t.hasPendingEdits||r.syncing||c.updating,p="update"===l?o.editFeature:o.createFeatures,m="update"===l?n.update:n.create,h="create-features"===l&&"create-new"===t.createFeatureState,u="create-features"===l?t.numPendingFeatures:0,g=u>1?S(o.createFeaturesTemplate,{numFeatures:u}):m,_=t.shouldShowAttachments,f=c.inputs.every((e=>!e.visible))&&!_?this._renderMessage(S(o.clickToFinishTemplate,{button:m})):L("div",{key:"panel-content-section",class:D.panelContentSection},this._renderNotices(t),L("div",{class:D.panelContentSectionGroup},this._featureForm.render(),_&&L("div",{key:"attachments"},L(F,{level:M(a)},o.attachments),this._attachments.render())));return L(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:p,headingLevel:a,handleBack:i},L("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:h})},f,h&&L("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:d,label:g,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:n.delete}:null]))}_renderNotices(e){return[this._renderOwnerAdminNotice(e),this._renderInvalidFormTemplateNotice(e),this._renderInvalidDateFieldNotice(e)]}_renderOwnerAdminNotice(e){return e?.reliesOnOwnerAdminPrivileges&&this._renderNotice(this.messages.ownerAdminNotice)}_renderInvalidFormTemplateNotice(e){return e?.hasInvalidFormTemplate&&this._renderNotice(this.messages.formFieldUpdateError,{icon:O})}_renderInvalidDateFieldNotice(e){return e?.hasUnsupportedFields&&this._renderNotice(this.messages.formFieldUnsupportedUpdateError,{icon:O})}_renderNotice(e,t){return L("calcite-notice",{open:!0,scale:"s",class:D.notice,...t},L("div",{slot:"message"},e))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this;let o=null;return e.group.items.some((e=>(s.itemHasUnsupportedFields(e)?o=t.formFieldUnsupportedCreateError:s.itemHasInvalidFormTemplate(e)&&(o=t.formFieldCreateError),o))),o?this._renderNotice(o,{icon:O}):null}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:n,messages:a,messagesCommon:i}=this;return L(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:a.addAttachment,headingLevel:n,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?i.cancel:i.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:n,headingLevel:a,messages:i,messagesCommon:r}=this;return n?L(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:i.editAttachment,headingLevel:a,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),n.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return L("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return L("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:n,...a},i)=>L("calcite-button",{key:`action-${i}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...a},n))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:n}=e,a=n.secondary;let i;switch(o){case"danger":i="danger";break;case"info":i="brand";break;default:i="neutral"}const r=L("calcite-button",{afterCreate:B,appearance:"solid",key:"prompt-primary-button",kind:i,onclick:n.primary.action,scale:"m",width:a?"half":"full"},n.primary.label),l=a&&L("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:i,onclick:a.action,scale:"m",width:"half"},a.label);return L("calcite-scrim",{key:"prompt"},L("div",{class:`${D.promptContainer}--${o}`},L("div",{class:D.promptHeader},L("calcite-icon",{icon:O}),L(F,{class:D.promptHeading,level:this.headingLevel},t)),L("div",{class:D.promptMessage},s),L("div",{class:D.promptDivider}),L("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:n}=this,{canUpdate:a}=n,i=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!a&&0===i;return L(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},L("div",{key:"landing-content",class:D.panelContent},a&&L("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),i>0&&L("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&L("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,n=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return n?L("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},n):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return L("div",{key:"update-actions"},L(F,{level:M(this.headingLevel)},t.editFeatures),L("calcite-list",{selectionMode:"single",selectionAppearance:"border"},k({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return L("div",{key:"create-actions"},L(F,{level:M(t)},s.createFeatures),L("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=L("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return L("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return L("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return L("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:n}=s;return o?.template===e.template&&o?.layer===e.layer?n:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:n,messages:a,messagesTemplates:i,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(a.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:n}=s.layer,a=l.find((e=>e.layer===s.layer));if(!a)return null;const{attachmentsOnUpdateEnabled:i,supports:r}=a;return(r.includes("update")||r.includes("delete")||i)&&(!o||t?.toLowerCase().includes(o)||n?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return L(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:n,handleBack:o},L("div",{key:"feature-list",class:D.panelContent},L("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:i.filterPlaceholder,noItems:i.noItems,noMatches:i.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?L("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},L("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&L(I,{tooltipOptions:this.tooltipOptions}),t&&L(A,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const s=t.fieldsIndex.get(t.objectIdField),o=s.alias||s.name,{attributes:n}=e,a=m(t);return a&&n[a]&&`${n[a]}`||`${o}: ${n[s.name]}`}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const a=n(),{view:i}=this,r=i?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}},a.promise.finally((()=>{this._clearPrompt(),r&&i?.focus()}))}_onSave(){this.viewModel.saveWorkflow()}_onDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={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}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))}_onAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}}};e([c()],N.prototype,"_featureForm",void 0),e([c()],N.prototype,"_attachments",void 0),e([c()],N.prototype,"_featureTemplates",void 0),e([c()],N.prototype,"_filterText",void 0),e([c()],N.prototype,"_prompt",void 0),e([c()],N.prototype,"_spinner",void 0),e([c()],N.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],N.prototype,"activeWorkflow",null),e([c()],N.prototype,"allowedWorkflows",null),e([c()],N.prototype,"useDeprecatedCreateWorkflow",null),e([c()],N.prototype,"headingLevel",void 0),e([c()],N.prototype,"iconClass",void 0),e([c()],N.prototype,"label",null),e([c()],N.prototype,"labelOptions",null),e([c()],N.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],N.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],N.prototype,"messagesTemplates",void 0),e([c()],N.prototype,"snappingOptions",null),e([c()],N.prototype,"tooltipOptions",null),e([c()],N.prototype,"supportingWidgetDefaults",void 0),e([c()],N.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],N.prototype,"viewModel",void 0),e([c()],N.prototype,"visibleElements",void 0),e([d("visibleElements")],N.prototype,"castVisibleElements",null),e([T()],N.prototype,"_onSave",null),e([T()],N.prototype,"_onDelete",null),e([T()],N.prototype,"_onBack",null),e([T()],N.prototype,"_onAttachmentAdd",null),e([T()],N.prototype,"_onAttachmentUpdate",null),e([T()],N.prototype,"_onAttachmentDelete",null),N=e([p(x)],N);const V=N;export{V 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import{ClonableMixin as l}from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import{HandleOwnerMixin as s}from"../../../core/HandleOwner.js";import{IdentifiableMixin as i}from"../../../core/Identifiable.js";import{ignoreAbortErrors as n}from"../../../core/promiseUtils.js";import{watch as u,initial as d}from"../../../core/reactiveUtils.js";import{throttle as y}from"../../../core/throttle.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as C,findRelatedLayer as g}from"../support/featureUtils.js";import{parseFormTemplateString as F,getFieldsInTitleAndDesc as _}from"../../FeatureForm/featureFormUtils.js";const b=100;let m=class extends(l(i(s(r)))){constructor(e){super(e),this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await n(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await n(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null)},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await n(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryThrottled=y(this._queryController,b,this),this._queryFeatureCountThrottled=y(this._queryFeatureCountController,b,this),this._queryPageThrottled=y(this._queryPageController,b,this),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.removeAll(),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal})))},this.handles.add([u((()=>[this.displayCount,this.graphic,this.layer,this.map,this.orderByFieldsFixedCasing,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount]),(()=>this._queryThrottled()),d),u((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageThrottled())),u((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery]),(()=>this._queryFeatureCountThrottled()))])}initialize(){this.addHandles(this._queryThrottled)}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.removeAll(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=C(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId&&e?.supportsCount&&e?.supportsPagination)}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}set displayCount(e){const t=0,r=10;this._set("displayCount",Math.min(Math.max(e,t),r))}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 relatedFeatures(){return this._get("relatedFeatures")||new a}get relatedFeatureInfos(){const{itemDescriptionFieldName:e,relatedFeatures:t,relatedLayer:r}=this;if(!t.length||!r)return[];const o=r&&"formTemplate"in r&&r.formTemplate,l=o&&o?.title||void 0;return t.map((t=>({feature:t,description:e?t.getAttribute(e):void 0,title:l?F(l,t.attributes,r.fieldsIndex):void 0}))).toArray()}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;return e?.loaded&&t&&r?g(t,e,r)??null:null}get relationship(){const{relationshipId:e,layer:t}=this;return"number"==typeof e?t?.relationships?.find((({id:t})=>t===e))??null:null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new a}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o}=this;return t?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.forEach((e=>!e.destroyed&&e.destroy())),this.relatedFeatureViewModels.removeAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t,relationshipId:r,objectId:o,_queryFeatureCountAbortController:l,canQuery:a,supportsCacheHint:s}=this;if(await(e?.load()),await(t?.load()),!a||!e||!t)return void this._set("featureCount",0);const i=t.createQuery(),n=new c({cacheHint:s,relationshipId:r,returnGeometry:!1,objectIds:[o],where:i.where??void 0}),u=await e.queryRelatedFeaturesCount(n,{signal:l?.signal});this._set("featureCount",u[o]||0)}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o}=this;!r||t<2||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{orderByFieldsFixedCasing:t,showAllEnabled:r,featuresPerPage:l,displayCount:a,layer:s,relationshipId:i,featurePage:n,featureCount:u,relatedLayer:d,supportsCacheHint:y}=this,{canQuery:h,objectId:p}=this;if(!h||!s||!d)return[];const C=r?((n-1)*l+u)%u:0,g=r?l:a,F=d.objectIdField,b=[...t.map((e=>e.field)),..._(d),F].filter(o),m=t.map((e=>`${e.field} ${e.order}`)),f=d.createQuery(),q=new c({orderByFields:m,start:C,num:g,outFields:b,cacheHint:y,relationshipId:i,returnGeometry:!1,objectIds:[p],where:f.where??void 0}),A=await s.queryRelatedFeatures(q,{signal:e?.signal}),w=A[p]?.features||[];return w.forEach((e=>{e.sourceLayer=d,e.layer=d})),w}};e([h()],m.prototype,"_queryAbortController",void 0),e([h()],m.prototype,"_queryPageAbortController",void 0),e([h()],m.prototype,"_queryFeatureCountAbortController",void 0),e([h({value:1})],m.prototype,"featurePage",null),e([h()],m.prototype,"featuresPerPage",void 0),e([h({readOnly:!0})],m.prototype,"orderByFieldsFixedCasing",null),e([h({readOnly:!0})],m.prototype,"supportsCacheHint",null),e([h({readOnly:!0})],m.prototype,"canQuery",null),e([h()],m.prototype,"description",void 0),e([h({readOnly:!0})],m.prototype,"itemDescriptionFieldName",null),e([h({value:3})],m.prototype,"displayCount",null),e([h({type:t})],m.prototype,"graphic",void 0),e([h()],m.prototype,"layer",void 0),e([h()],m.prototype,"map",void 0),e([h({readOnly:!0})],m.prototype,"objectId",null),e([h({readOnly:!0})],m.prototype,"objectIdField",null),e([h()],m.prototype,"orderByFields",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatures",null),e([h({readOnly:!0})],m.prototype,"relatedFeatureInfos",null),e([h({readOnly:!0})],m.prototype,"relatedLayer",null),e([h({readOnly:!0})],m.prototype,"relationship",null),e([h()],m.prototype,"featureCount",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatureViewModels",null),e([h()],m.prototype,"relationshipId",void 0),e([h()],m.prototype,"showAllEnabled",void 0),e([h()],m.prototype,"state",null),e([h()],m.prototype,"title",void 0),e([h()],m.prototype,"getRelatedFeatureByObjectId",null),m=e([p("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],m);const f=m;export{f as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import{ClonableMixin as l}from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import{HandleOwnerMixin as s}from"../../../core/HandleOwner.js";import{IdentifiableMixin as i}from"../../../core/Identifiable.js";import{ignoreAbortErrors as n,debounce as u}from"../../../core/promiseUtils.js";import{watch as d,initial as y}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as C,findRelatedLayer as b}from"../support/featureUtils.js";import{parseFormTemplateString as g,getFieldsInTitleAndDesc as F}from"../../FeatureForm/featureFormUtils.js";const _=100;let m=class extends(l(i(s(r)))){constructor(e){super(e),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await n(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await n(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await n(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=u(this._queryController,_),this._queryFeatureCountDebounced=u(this._queryFeatureCountController,_),this._queryPageDebounced=u(this._queryPageController,_),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this.featureCount&&(this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.removeAll(),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal}))))},this.handles.add([d((()=>[this.displayCount,this.graphic,this.layer,this.map,this.orderByFieldsFixedCasing,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount]),(()=>this._queryDebounced()),y),d((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageDebounced())),d((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery]),(()=>this._queryFeatureCountDebounced()))])}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.removeAll(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=C(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canLoad(){return!!this.map&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId&&e?.supportsCount&&e?.supportsPagination)}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}set displayCount(e){const t=0,r=10;this._set("displayCount",Math.min(Math.max(e,t),r))}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 relatedFeatures(){return this._get("relatedFeatures")||new a}get relatedFeatureInfos(){const{itemDescriptionFieldName:e,relatedFeatures:t,relatedLayer:r}=this;if(!t.length||!r)return[];const o=r&&"formTemplate"in r&&r.formTemplate,l=o&&o?.title||void 0;return t.map((t=>({feature:t,description:e?t.getAttribute(e):void 0,title:l?g(l,t.attributes,r.fieldsIndex):void 0}))).toArray()}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;return e?.loaded&&t&&r?b(t,e,r)??null:null}get relationship(){const{relationshipId:e,layer:t}=this;return"number"==typeof e?t?.relationships?.find((({id:t})=>t===e))??null:null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new a}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o,_loaded:l,canLoad:a}=this;return t||a&&!l?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.forEach((e=>!e.destroyed&&e.destroy())),this.relatedFeatureViewModels.removeAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t,relationshipId:r,objectId:o,_queryFeatureCountAbortController:l,canQuery:a,supportsCacheHint:s}=this;if(await(e?.load()),await(t?.load()),!a||!e||!t)return void this._set("featureCount",0);const i=t.createQuery(),n=new c({cacheHint:s,relationshipId:r,returnGeometry:!1,objectIds:[o],where:i.where??void 0}),u=await e.queryRelatedFeaturesCount(n,{signal:l?.signal});this._set("featureCount",u[o]||0)}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o,featureCount:l}=this;!r||t<2||!l||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{orderByFieldsFixedCasing:t,showAllEnabled:r,featuresPerPage:l,displayCount:a,layer:s,relationshipId:i,featurePage:n,featureCount:u,relatedLayer:d,supportsCacheHint:y}=this,{canQuery:h,objectId:p}=this;if(!h||!s||!d)return[];const C=r?((n-1)*l+u)%u:0,b=r?l:a,g=d.objectIdField,_=[...t.map((e=>e.field)),...F(d),g].filter(o),m=t.map((e=>`${e.field} ${e.order}`)),f=d.createQuery(),q=new c({orderByFields:m,start:C,num:b,outFields:_,cacheHint:y,relationshipId:i,returnGeometry:!1,objectIds:[p],where:f.where??void 0}),A=await s.queryRelatedFeatures(q,{signal:e?.signal}),w=A[p]?.features||[];return w.forEach((e=>{e.sourceLayer=d,e.layer=d})),w}};e([h()],m.prototype,"_loaded",void 0),e([h()],m.prototype,"_queryAbortController",void 0),e([h()],m.prototype,"_queryPageAbortController",void 0),e([h()],m.prototype,"_queryFeatureCountAbortController",void 0),e([h({value:1})],m.prototype,"featurePage",null),e([h()],m.prototype,"featuresPerPage",void 0),e([h({readOnly:!0})],m.prototype,"orderByFieldsFixedCasing",null),e([h({readOnly:!0})],m.prototype,"supportsCacheHint",null),e([h({readOnly:!0})],m.prototype,"canLoad",null),e([h({readOnly:!0})],m.prototype,"canQuery",null),e([h()],m.prototype,"description",void 0),e([h({readOnly:!0})],m.prototype,"itemDescriptionFieldName",null),e([h({value:3})],m.prototype,"displayCount",null),e([h({type:t})],m.prototype,"graphic",void 0),e([h()],m.prototype,"layer",void 0),e([h()],m.prototype,"map",void 0),e([h({readOnly:!0})],m.prototype,"objectId",null),e([h({readOnly:!0})],m.prototype,"objectIdField",null),e([h()],m.prototype,"orderByFields",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatures",null),e([h({readOnly:!0})],m.prototype,"relatedFeatureInfos",null),e([h({readOnly:!0})],m.prototype,"relatedLayer",null),e([h({readOnly:!0})],m.prototype,"relationship",null),e([h()],m.prototype,"featureCount",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatureViewModels",null),e([h()],m.prototype,"relationshipId",void 0),e([h()],m.prototype,"showAllEnabled",void 0),e([h()],m.prototype,"state",null),e([h()],m.prototype,"title",void 0),e([h()],m.prototype,"getRelatedFeatureByObjectId",null),m=e([p("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],m);const f=m;export{f 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as r,initial as i,on as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import{cast as a}from"../../core/accessorSupport/decorators/cast.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import d from"../Widget.js";import c from"./FeatureRelationship/FeatureRelationshipViewModel.js";import u from"./support/FeatureElementInfo.js";import{loadCalciteComponents as h}from"../support/componentsUtils.js";import{isRTL as p}from"../support/widgetUtils.js";import{messageBundle as m}from"../support/decorators/messageBundle.js";import{tsx as v}from"../support/jsxFactory.js";import{substitute as g}from"../../intl/substitute.js";const w="esri-feature",b=`${w}-relationship`,f={base:b,esriWidget:"esri-widget",listContainer:`${b}__list`,listContainerQuerying:`${b}__list--querying`,featureObserver:`${w}__feature-observer`,stickySpinnerContainer:`${w}__sticky-loading-container`,loadingSpinnerContainer:`${w}__loading-container`,spinner:`${w}__loading-spinner`,iconLoading:"esri-icon-loading-indicator esri-rotating"},y={title:!0,description:!0};let F=class extends d{constructor(e,t){super(e,t),this._featureElementInfo=null,this._relatedFeatureIntersectionObserverNode=null,this._relatedFeatureIntersectionObserver=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this.headingLevel=2,this.viewModel=new c,this.messages=null,this.messagesCommon=null,this.visibleElements={...y},this._increaseFeaturePage=()=>{const{state:e,showAllEnabled:t,relatedFeatures:s,featuresPerPage:r,featurePage:i}=this.viewModel;"ready"===e&&t&&s.length>=r*i&&this.viewModel.featurePage++}}initialize(){this._featureElementInfo=new u,this.addHandles([r((()=>[this.viewModel.description,this.viewModel.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),i),r((()=>[this.viewModel.state,this.viewModel.showAllEnabled,this._relatedFeatureIntersectionObserverNode]),(()=>this._handleRelatedFeatureObserverChange())),o((()=>this.viewModel.relatedFeatureViewModels),"change",(()=>this._setupRelatedFeatureViewModels()))])}loadDependencies(){return h({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js")})}destroy(){this._unobserveRelatedFeatureObserver(),this._featureElementInfo=t(this._featureElementInfo)}get displayShowAllButton(){const{showAllEnabled:e,featureCount:t,displayCount:s,state:r}=this.viewModel;return!e&&!!t&&"ready"===r&&(t>s||0===s)}get displayListItems(){return this.displayShowAllButton||this.viewModel.relatedFeatureViewModels.length>0}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get featureCountDescription(){const{messages:e}=this,{featureCount:t}=this.viewModel;return g(e?.numberRecords,{number:t})}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}castVisibleElements(e){return{...y,...e}}renderStickyLoading(){return"querying"===this.viewModel.state?v("div",{key:"sticky-loader",class:f.stickySpinnerContainer},this.renderLoadingIcon()):null}renderLoadingIcon(){return v("span",{class:this.classes(f.iconLoading,f.spinner)})}renderLoading(){return v("div",{key:"loading-container",class:f.loadingSpinnerContainer},this.renderLoadingIcon())}renderShowAllIconNode(){return v("calcite-icon",{scale:"s",icon:"list",slot:"content-end"})}renderChevronIconNode(){const e=p(this.container)?"chevron-left":"chevron-right";return v("calcite-icon",{scale:"s",icon:e,slot:"content-end"})}renderRelatedFeature(e){const{itemDescriptionFieldName:t}=this.viewModel,s=e.title;e.description=t&&e.formattedAttributes?.global[t];const r="loading"===e.state;return v("calcite-list-item",{key:e.uid,label:r?`${this.messagesCommon?.loading}…`:s,description:r?"…":e.description??"",onCalciteListItemSelect:()=>this.emit("select-record",{featureViewModel:e})},this.renderChevronIconNode())}renderShowAllListItem(){return this.displayShowAllButton?v("calcite-list-item",{key:"show-all-item",label:this.messages?.showAll,description:this.featureCountDescription,onCalciteListItemSelect:()=>this.emit("show-all-records")},this.renderShowAllIconNode()):null}renderNoRelatedFeaturesMessage(){return v("calcite-notice",{key:"no-related-features-message",icon:"information",open:!0,kind:"brand",scale:"s",width:"full"},v("div",{slot:"message"},this.messages?.noRelatedFeatures))}renderFeatureObserver(){return v("div",{key:"feature-observer",class:f.featureObserver,bind:this,afterCreate:this._relatedFeatureIntersectionObserverCreated})}renderList(){const{relatedFeatureViewModels:e}=this.viewModel;return v("calcite-list",null,e.toArray().map((e=>this.renderRelatedFeature(e))),this.renderShowAllListItem())}renderRelatedFeatures(){const{displayListItems:e}=this,{state:t}=this.viewModel;return v("div",{key:"list-container",class:this.classes(f.listContainer,{[f.listContainerQuerying]:"querying"===t})},e?this.renderList():"ready"===t?this.renderNoRelatedFeaturesMessage():null,this.renderStickyLoading(),this.renderFeatureObserver())}renderRelationshipNotFound(){return v("calcite-notice",{key:"relationship-not-found",icon:"exclamation-mark-triangle",open:!0,kind:"danger",scale:"s",width:"full"},v("div",{slot:"message"},this.messages?.relationshipNotFound))}render(){const{state:e}=this.viewModel;return v("div",{class:this.classes(f.base,f.esriWidget)},this._featureElementInfo?.render(),"loading"===e?this.renderLoading():"disabled"===e?this.renderRelationshipNotFound():this.renderRelatedFeatures())}_setupRelatedFeatureViewModels(){const{relatedFeatureViewModels:e}=this.viewModel,t="related-feature-viewmodels";this.removeHandles(t),e?.forEach((e=>{this.addHandles(r((()=>[e.title,e.state]),(()=>this.scheduleRender()),i),t)})),this.scheduleRender()}_setupFeatureElementInfo(){const{headingLevel:e,visibleElements:t}=this,s=t.description&&this.description,r=t.title&&this.title;this._featureElementInfo?.set({description:s,title:r,headingLevel:e})}async _handleRelatedFeatureObserverChange(){this._unobserveRelatedFeatureObserver();const{state:e,showAllEnabled:t}=this.viewModel;await s(0),this._relatedFeatureIntersectionObserverNode&&"ready"===e&&t&&this._relatedFeatureIntersectionObserver.observe(this._relatedFeatureIntersectionObserverNode)}_relatedFeatureIntersectionObserverCreated(e){this._relatedFeatureIntersectionObserverNode=e}_unobserveRelatedFeatureObserver(){this._relatedFeatureIntersectionObserverNode&&this._relatedFeatureIntersectionObserver.unobserve(this._relatedFeatureIntersectionObserverNode)}};e([n()],F.prototype,"_relatedFeatureIntersectionObserverNode",void 0),e([n({readOnly:!0})],F.prototype,"displayShowAllButton",null),e([n({readOnly:!0})],F.prototype,"displayListItems",null),e([n()],F.prototype,"description",null),e([n({readOnly:!0})],F.prototype,"featureCountDescription",null),e([n()],F.prototype,"headingLevel",void 0),e([n()],F.prototype,"title",null),e([n({type:c})],F.prototype,"viewModel",void 0),e([n(),m("esri/widgets/Feature/t9n/Feature")],F.prototype,"messages",void 0),e([n(),m("esri/t9n/common")],F.prototype,"messagesCommon",void 0),e([n()],F.prototype,"visibleElements",void 0),e([a("visibleElements")],F.prototype,"castVisibleElements",null),F=e([l("esri.widgets.Feature.FeatureRelationship")],F);const _=F;export{_ as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as i,initial as r,on as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import d from"../Widget.js";import c from"./FeatureRelationship/FeatureRelationshipViewModel.js";import u from"./support/FeatureElementInfo.js";import{loadCalciteComponents as h}from"../support/componentsUtils.js";import{isRTL as p}from"../support/widgetUtils.js";import{messageBundle as m}from"../support/decorators/messageBundle.js";import{tsx as v}from"../support/jsxFactory.js";import{substitute as g}from"../../intl/substitute.js";const w="esri-feature",b=`${w}-relationship`,f={base:b,esriWidget:"esri-widget",listContainer:`${b}__list`,listItem:`${b}__list-item`,listItemHidden:`${b}__list-item--hidden`,listContainerQuerying:`${b}__list--querying`,featureObserver:`${w}__feature-observer`,stickySpinnerContainer:`${w}__sticky-loading-container`,loadingSpinnerContainer:`${w}__loading-container`,spinner:`${w}__loading-spinner`,iconLoading:"esri-icon-loading-indicator esri-rotating"},y={title:!0,description:!0};let F=class extends d{constructor(e,t){super(e,t),this._featureElementInfo=null,this._relatedFeatureIntersectionObserverNode=null,this._relatedFeatureIntersectionObserver=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this.headingLevel=2,this.viewModel=new c,this.messages=null,this.messagesCommon=null,this.visibleElements={...y},this._increaseFeaturePage=()=>{const{state:e,showAllEnabled:t,relatedFeatures:s,featuresPerPage:i,featurePage:r}=this.viewModel;"ready"===e&&t&&s.length>=i*r&&this.viewModel.featurePage++}}initialize(){this._featureElementInfo=new u,this.addHandles([i((()=>[this.viewModel.description,this.viewModel.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),r),i((()=>[this.viewModel.state,this.viewModel.showAllEnabled,this._relatedFeatureIntersectionObserverNode]),(()=>this._handleRelatedFeatureObserverChange())),o((()=>this.viewModel.relatedFeatureViewModels),"change",(()=>this._setupRelatedFeatureViewModels()))])}loadDependencies(){return h({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js")})}destroy(){this._unobserveRelatedFeatureObserver(),this._featureElementInfo=t(this._featureElementInfo)}get displayShowAllButton(){const{showAllEnabled:e,featureCount:t,displayCount:s,state:i}=this.viewModel;return!e&&!!t&&"ready"===i&&(t>s||0===s)}get displayListItems(){return this.displayShowAllButton||this.viewModel.relatedFeatureViewModels.length>0}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get featureCountDescription(){const{messages:e}=this,{featureCount:t}=this.viewModel;return g(e?.numberRecords,{number:t})}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}castVisibleElements(e){return{...y,...e}}renderStickyLoading(){return"querying"===this.viewModel.state?v("div",{key:"sticky-loader",class:f.stickySpinnerContainer},this.renderLoadingIcon()):null}renderLoadingIcon(){return v("span",{class:this.classes(f.iconLoading,f.spinner)})}renderLoading(){return v("div",{key:"loading-container",class:f.loadingSpinnerContainer},this.renderLoadingIcon())}renderShowAllIconNode(){return v("calcite-icon",{scale:"s",icon:"list",slot:"content-end"})}renderChevronIconNode(){const e=p(this.container)?"chevron-left":"chevron-right";return v("calcite-icon",{scale:"s",icon:e,slot:"content-end"})}renderRelatedFeature(e){const{itemDescriptionFieldName:t}=this.viewModel,s=e.title;e.description=t&&e.formattedAttributes?.global[t];const i="loading"===e.state;return v("calcite-list-item",{class:this.classes(f.listItem,{[f.listItemHidden]:i}),key:e.uid,label:s,description:e.description??"",onCalciteListItemSelect:()=>this.emit("select-record",{featureViewModel:e})},this.renderChevronIconNode())}renderShowAllListItem(){return this.displayShowAllButton?v("calcite-list-item",{key:"show-all-item",label:this.messages?.showAll,description:this.featureCountDescription,onCalciteListItemSelect:()=>this.emit("show-all-records")},this.renderShowAllIconNode()):null}renderNoRelatedFeaturesMessage(){return v("calcite-notice",{key:"no-related-features-message",icon:"information",open:!0,kind:"brand",scale:"s",width:"full"},v("div",{slot:"message"},this.messages?.noRelatedFeatures))}renderFeatureObserver(){return v("div",{key:"feature-observer",class:f.featureObserver,bind:this,afterCreate:this._relatedFeatureIntersectionObserverCreated})}renderList(){const{relatedFeatureViewModels:e}=this.viewModel;return v("calcite-list",null,e.toArray().map((e=>this.renderRelatedFeature(e))),this.renderShowAllListItem())}renderRelatedFeatures(){const{displayListItems:e}=this,{state:t}=this.viewModel;return v("div",{key:"list-container",class:this.classes(f.listContainer,{[f.listContainerQuerying]:"querying"===t})},e?this.renderList():"ready"===t?this.renderNoRelatedFeaturesMessage():null,this.renderStickyLoading(),this.renderFeatureObserver())}renderRelationshipNotFound(){return v("calcite-notice",{key:"relationship-not-found",icon:"exclamation-mark-triangle",open:!0,kind:"danger",scale:"s",width:"full"},v("div",{slot:"message"},this.messages?.relationshipNotFound))}render(){const{state:e}=this.viewModel;return v("div",{class:this.classes(f.base,f.esriWidget)},this._featureElementInfo?.render(),"loading"===e?this.renderLoading():"disabled"===e?this.renderRelationshipNotFound():this.renderRelatedFeatures())}_setupRelatedFeatureViewModels(){const{relatedFeatureViewModels:e}=this.viewModel,t="related-feature-viewmodels";this.removeHandles(t),e?.forEach((e=>{this.addHandles(i((()=>[e.title,e.state]),(()=>this.scheduleRender()),r),t)})),this.scheduleRender()}_setupFeatureElementInfo(){const{headingLevel:e,visibleElements:t}=this,s=t.description&&this.description,i=t.title&&this.title;this._featureElementInfo?.set({description:s,title:i,headingLevel:e})}async _handleRelatedFeatureObserverChange(){this._unobserveRelatedFeatureObserver();const{state:e,showAllEnabled:t}=this.viewModel;await s(0),this._relatedFeatureIntersectionObserverNode&&"ready"===e&&t&&this._relatedFeatureIntersectionObserver.observe(this._relatedFeatureIntersectionObserverNode)}_relatedFeatureIntersectionObserverCreated(e){this._relatedFeatureIntersectionObserverNode=e}_unobserveRelatedFeatureObserver(){this._relatedFeatureIntersectionObserverNode&&this._relatedFeatureIntersectionObserver.unobserve(this._relatedFeatureIntersectionObserverNode)}};e([n()],F.prototype,"_relatedFeatureIntersectionObserverNode",void 0),e([n({readOnly:!0})],F.prototype,"displayShowAllButton",null),e([n({readOnly:!0})],F.prototype,"displayListItems",null),e([n()],F.prototype,"description",null),e([n({readOnly:!0})],F.prototype,"featureCountDescription",null),e([n()],F.prototype,"headingLevel",void 0),e([n()],F.prototype,"title",null),e([n({type:c})],F.prototype,"viewModel",void 0),e([n(),m("esri/widgets/Feature/t9n/Feature")],F.prototype,"messages",void 0),e([n(),m("esri/t9n/common")],F.prototype,"messagesCommon",void 0),e([n()],F.prototype,"visibleElements",void 0),e([l("visibleElements")],F.prototype,"castVisibleElements",null),F=e([a("esri.widgets.Feature.FeatureRelationship")],F);const _=F;export{_ as default};
@@ -1,4 +1,4 @@
1
1
  import "../../interfaces";
2
2
 
3
- import FeatureFormEditableInput = __esri.FeatureFormEditableInput;
4
- export default FeatureFormEditableInput;
3
+ import EditableInput = __esri.EditableInput;
4
+ export default EditableInput;
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as o,convertDateFormatToIntlOptions as r}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as a,formatNumber as l}from"../../intl/number.js";import s from"../../layers/support/CodedValueDomain.js";import{isEditableLayer as u}from"../../layers/support/editableLayers.js";import{isNumericField as d,isStringField as p}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as c}from"../../layers/support/layerUtils.js";import{unsupportedDateFieldTypes as m,formatDateFieldValue as h}from"../FeatureForm/featureFormUtils.js";import f from"../FeatureForm/FieldInput.js";import g from"./Grid/EditorColumn.js";import y from"../support/DatePicker.js";import v from"../support/TimePicker.js";import{renderingSanitizer as b}from"../support/widgetUtils.js";const F={cancelEdit:"Escape"},_="esri-field-column",C={headerContent:`${_}__header-content`,headerLabel:`${_}__header-label`,input:`${_}__cell-input`,inputContainer:`${_}__cell__input-container`,dateInputContainer:`${_}__cell__date-input-container`,dateInputWrapper:`${_}__cell__date-input-wrapper`,button:`${_}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},E=r("short-date-short-time"),I=r("short-date"),L={useGrouping:!0,maximumFractionDigits:20};let D=class extends g{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:b.sanitize(t)})}if(null===t)return"&nbsp;";const{config:n,field:i}=this,r=e?.item?.feature,s=this._getDomainForFeature(r);if(s)return this._getComputedDomain(t,s);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?o(t,{...e,...n}):null}if(m.has(i.type)&&t){const e=h(i,t);return b.sanitize(e)}if(d(i)){const e=n?.format?a(n.format):L;return l(parseFloat(t),e)}return b.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:t})=>!(this._inputField&&!this._inputField.valid)&&((!this.required||null!=t&&""!==t)&&e!==t),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:r}=this;if(this.removeCellContent(t),t.classList.add(C.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),r)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(C.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const r=this.createInputContainer();r.appendChild(o),this.removeCellContent(e),e.appendChild(r),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField;if(!t)return null;const n=e.value,{dataType:i,required:o}=t;return o||""!==n?"number"===i||"date"===i?parseFloat(n):"text"===i?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e&&(e.item.feature.attributes[t.path]=n)},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store)return;const i=e.item.objectId,o=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:o,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:n,layer:i,template:o}=this;if(null==n||null==i)return!1;const r=u(i),a=c(i),l=a?.operations.supportsUpdate;return!!(n.editable&&r&&l)&&(!m.has(n.type)&&(t?!(!1===o?.editable||!1===e?.editable):!(!o?.editable&&!e?.editable)))}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return null!=o&&!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,r=n?.required;return this.editable&&(!i||!0===o||!0===r)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const n=e?.item;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:r,required:a}=this,{domain:l}=this._inputField;let s;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,p()}):(s=document.createElement("input"),s.type=d(i)?"number":"text",o>-1&&(s.maxLength=o),r>0&&(s.minLength=r)),s.classList.add(C.input),s.value=t,s.required=a;let u=!1;s.onkeydown=e=>{u=e.key===F.cancelEdit},s.onblur=()=>{s.onblur=null,p()};const p=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(C.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(C.locked),e}getCellValue({path:e},t){return t?.item?.feature?.attributes?.[e]??null}_renderDateEditors(e,n,i){const{config:o,messagesCommon:r,template:a}=this,l=e?new Date(e):new Date(Date.now()),s=new y({dateInputEnabled:!0,value:l}),u=new v({value:l});i.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};t((()=>[s.value,u.value]),(()=>p()));const h=document.createElement("div"),f=document.createElement("div");s.container=h,u.container=f;const g=document.createElement("button");g.classList.add(C.button,C.saveIcon),g.onclick=()=>c(),g.title=r?.save;const b=document.createElement("button");b.classList.add(C.button,C.trashIcon),b.onclick=()=>m(),b.title=r?.clear;const F=document.createElement("div");F.classList.add(C.dateInputWrapper),F.appendChild(h),(a&&a.input&&"datetime-picker"===a.input.type&&!1!==a.input.includeTime||o&&!1!==o.includeTime)&&F.appendChild(f);const _=document.createElement("div");_.classList.add(C.dateInputContainer),_.appendChild(F),_.appendChild(g),_.appendChild(b),s.when((()=>this.grid?.notifyResize())),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(n),n.appendChild(_),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const r=document.createElement("select");return o.forEach((e=>r.add(e))),r.value=e,r}_setUpInputField(e,t){const{field:n,layer:i}=this,o=new f({feature:e,initialFeature:e.clone(),field:n,layer:i});return o.set("value",t),o}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&p(t)||"number"===n&&d(t))return!0}return!(!e||"range"!==e.type||!d(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if(!n)return null;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:r}=n,a=r===i,l=this.field.domain;if(a&&!l)return new s({name:"__internal-type-based-coded-value-domain__",codedValues:n.types?.map((({id:e,name:t})=>({code:e,name:t})))});const u=r&&null!=i&&n.getFieldDomain(i,{feature:e})||l,d=t?.domain;return this._isDomainCompatible(d)?d:u}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?r(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?I:E}};e([n({readOnly:!0})],D.prototype,"alias",null),e([n()],D.prototype,"cellValueFormatFunction",void 0),e([n()],D.prototype,"cellValueValidatorFunction",void 0),e([n()],D.prototype,"config",void 0),e([n({readOnly:!0})],D.prototype,"defaultValue",null),e([n({readOnly:!0})],D.prototype,"description",null),e([n({readOnly:!0})],D.prototype,"editable",null),e([n()],D.prototype,"editingEnabled",void 0),e([n()],D.prototype,"expressionInfos",void 0),e([n()],D.prototype,"field",void 0),e([n()],D.prototype,"formatFunction",void 0),e([n({readOnly:!0})],D.prototype,"header",null),e([n()],D.prototype,"hidden",null),e([n()],D.prototype,"headerRenderFunction",void 0),e([n()],D.prototype,"inputRenderFunction",void 0),e([n()],D.prototype,"layer",void 0),e([n({readOnly:!0})],D.prototype,"loadingMessage",null),e([n()],D.prototype,"maxLength",null),e([n()],D.prototype,"minLength",null),e([n({readOnly:!0})],D.prototype,"name",null),e([n({readOnly:!0})],D.prototype,"nullable",null),e([n()],D.prototype,"parseInputValueFunction",void 0),e([n({readOnly:!0})],D.prototype,"path",null),e([n({readOnly:!0})],D.prototype,"required",null),e([n()],D.prototype,"sortable",null),e([n()],D.prototype,"store",void 0),e([n()],D.prototype,"template",void 0),e([n()],D.prototype,"updateRowItemFunction",void 0),e([n()],D.prototype,"updateStoreItemFunction",void 0),D=e([i("esri.widgets.FeatureTable.FieldColumn")],D);const w=D;export{w as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as o,convertDateFormatToIntlOptions as r}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as a,formatNumber as l}from"../../intl/number.js";import s from"../../layers/support/CodedValueDomain.js";import{isEditableLayer as u}from"../../layers/support/editableLayers.js";import{isNumericField as d,isStringField as p}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as c}from"../../layers/support/layerUtils.js";import{unsupportedDateFieldTypes as m,formatDateFieldValue as h}from"../FeatureForm/featureFormUtils.js";import f from"../FeatureForm/FieldInput.js";import g from"./Grid/EditorColumn.js";import y from"../support/DatePicker.js";import v from"../support/TimePicker.js";import{renderingSanitizer as b}from"../support/widgetUtils.js";const F={cancelEdit:"Escape"},_="esri-field-column",C={headerContent:`${_}__header-content`,headerLabel:`${_}__header-label`,input:`${_}__cell-input`,inputContainer:`${_}__cell__input-container`,dateInputContainer:`${_}__cell__date-input-container`,dateInputWrapper:`${_}__cell__date-input-wrapper`,button:`${_}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},E=r("short-date-short-time"),I=r("short-date"),L={useGrouping:!0,maximumFractionDigits:20};let D=class extends g{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:b.sanitize(t)})}if(null===t)return"&nbsp;";const{config:n,field:i}=this,r=e?.item?.feature,s=this._getDomainForFeature(r);if(s)return this._getComputedDomain(t,s);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?o(t,{...e,...n}):null}if(m.has(i.type)&&t){const e=h(i,t);return b.sanitize(e)}if(d(i)){const e=n?.format?a(n.format):L;return l(parseFloat(t),e)}return b.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:t})=>!(this._inputField&&!this._inputField.valid)&&((!this.required||null!=t&&""!==t)&&e!==t),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:r}=this;if(this.removeCellContent(t),t.classList.add(C.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),r)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(C.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const r=this.createInputContainer();r.appendChild(o),this.removeCellContent(e),e.appendChild(r),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField;if(!t)return null;const n=e.value,{dataType:i,required:o}=t;return o||""!==n?"number"===i||"date"===i?parseFloat(n):"text"===i?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e&&(e.item.feature.attributes[t.path]=n)},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store)return;const i=e.item.objectId,o=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:o,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:n,layer:i,template:o}=this;if(null==n||null==i)return!1;const r=u(i),a=c(i),l=a?.operations.supportsUpdate;return!!(n.editable&&r&&l)&&(!m.has(n.type)&&(t?!(!1===o?.editable||!1===e?.editable):!(!o?.editable&&!e?.editable)))}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return null!=o&&!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,r=n?.required;return this.editable&&(!i||!0===o||!0===r)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const n=e?.item;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:r,required:a}=this,{domain:l}=this._inputField;let s;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,p()}):(s=document.createElement("input"),s.type=d(i)?"number":"text",o>-1&&(s.maxLength=o),r>0&&(s.minLength=r)),s.classList.add(C.input),s.value=t,s.required=a;let u=!1;s.onkeydown=e=>{u=e.key===F.cancelEdit},s.onblur=()=>{s.onblur=null,p()};const p=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(C.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(C.locked),e}getCellValue({path:e},t){return t?.item?.feature?.attributes?.[e]??null}_renderDateEditors(e,n,i){const{config:o,messagesCommon:r,template:a}=this,l=e?new Date(e):new Date(Date.now()),s=new y({dateInputEnabled:!0,value:l}),u=new v({value:l});i.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};t((()=>[s.value,u.value]),(()=>p()));const h=document.createElement("div"),f=document.createElement("div");s.container=h,u.container=f;const g=document.createElement("button");g.classList.add(C.button,C.saveIcon),g.onclick=()=>c(),g.title=r?.save;const b=document.createElement("button");b.classList.add(C.button,C.trashIcon),b.onclick=()=>m(),b.title=r?.clear;const F=document.createElement("div");F.classList.add(C.dateInputWrapper),F.appendChild(h),(a&&a.input&&"datetime-picker"===a.input.type&&!1!==a.input.includeTime||o&&!1!==o.includeTime)&&F.appendChild(f);const _=document.createElement("div");_.classList.add(C.dateInputContainer),_.appendChild(F),_.appendChild(g),_.appendChild(b),s.when((()=>{const e=s._inputOrButtonNode;e&&(e.onblur=e=>{const t=e.relatedTarget;t&&t.className.includes("esri-date-picker")||s.close(!1)}),this.grid?.notifyResize()})),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(n),n.appendChild(_),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const r=document.createElement("select");return o.forEach((e=>r.add(e))),r.value=e,r}_setUpInputField(e,t){const{field:n,layer:i}=this,o=new f({feature:e,initialFeature:e.clone(),field:n,layer:i});return o.set("value",t),o}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&p(t)||"number"===n&&d(t))return!0}return!(!e||"range"!==e.type||!d(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if(!n)return null;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:r}=n,a=r===i,l=this.field.domain;if(a&&!l)return new s({name:"__internal-type-based-coded-value-domain__",codedValues:n.types?.map((({id:e,name:t})=>({code:e,name:t})))});const u=r&&null!=i&&n.getFieldDomain(i,{feature:e})||l,d=t?.domain;return this._isDomainCompatible(d)?d:u}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?r(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?I:E}};e([n({readOnly:!0})],D.prototype,"alias",null),e([n()],D.prototype,"cellValueFormatFunction",void 0),e([n()],D.prototype,"cellValueValidatorFunction",void 0),e([n()],D.prototype,"config",void 0),e([n({readOnly:!0})],D.prototype,"defaultValue",null),e([n({readOnly:!0})],D.prototype,"description",null),e([n({readOnly:!0})],D.prototype,"editable",null),e([n()],D.prototype,"editingEnabled",void 0),e([n()],D.prototype,"expressionInfos",void 0),e([n()],D.prototype,"field",void 0),e([n()],D.prototype,"formatFunction",void 0),e([n({readOnly:!0})],D.prototype,"header",null),e([n()],D.prototype,"hidden",null),e([n()],D.prototype,"headerRenderFunction",void 0),e([n()],D.prototype,"inputRenderFunction",void 0),e([n()],D.prototype,"layer",void 0),e([n({readOnly:!0})],D.prototype,"loadingMessage",null),e([n()],D.prototype,"maxLength",null),e([n()],D.prototype,"minLength",null),e([n({readOnly:!0})],D.prototype,"name",null),e([n({readOnly:!0})],D.prototype,"nullable",null),e([n()],D.prototype,"parseInputValueFunction",void 0),e([n({readOnly:!0})],D.prototype,"path",null),e([n({readOnly:!0})],D.prototype,"required",null),e([n()],D.prototype,"sortable",null),e([n()],D.prototype,"store",void 0),e([n()],D.prototype,"template",void 0),e([n()],D.prototype,"updateRowItemFunction",void 0),e([n()],D.prototype,"updateStoreItemFunction",void 0),D=e([i("esri.widgets.FeatureTable.FieldColumn")],D);const w=D;export{w as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{id as t}from"../../kernel.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as a}from"../../core/HandleOwner.js";import l from"../../core/Logger.js";import{when as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/Point.js";import{fetchMessageBundle as u}from"../../intl/messages.js";import p from"../../layers/support/CodedValueDomain.js";import d from"../../networks/UtilityNetwork.js";import{getObjectIdsFromElements as g,getFeaturesFromLayers as m}from"../../networks/support/utils.js";import{trace as y}from"../../rest/networks/trace.js";import f from"../../rest/networks/support/TraceLocation.js";import w from"../../rest/networks/support/TraceParameters.js";import{GeometryHandler as _}from"./support/GeometryHandler.js";import{GraphicHandler as b}from"./support/GraphicHandler.js";import{ResultAreaHandler as v}from"./support/ResultAreaHandler.js";const A=()=>u("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),R=()=>u("esri/core/t9n/Units");function I(e){return e instanceof p}function F(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function T(e){return void 0!==e.layerViews}let k=class extends(a(i.EventedAccessor)){constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._geometryHandler=null,this._graphicHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._traces=[],this._traceResults=[],this._watchHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.gdbVersion="sde.DEFAULT",this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.utilityNetwork=null}initialize(){this._geometryHandler=new _,this._graphicHandler=new b,this._resultAreaHandler=new v;(async()=>{const[e,t]=await Promise.all([A(),R()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e})}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&l.getLogger(this).error(new r("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e)}addFlagByHit(e,t){const s=e=>{const t=this.view?.popup;t&&(t.autoOpenEnabled=e)};return new Promise(((r,i)=>{s(!1),this._clickHandler?.remove(),this.emit("add-flag",{type:e}),this._clickHandler=this.view?.on("click",(a=>{this.queryFlagByHitTest(a,e,t).then((i=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-complete",{type:e,symbol:t}),r(i)})).catch((r=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-error",{type:e,symbol:t}),i(r)}))}))}))}async addFlagsOnLoad(){return new Promise((e=>{const t=[];this._watchHandler=o((()=>null!=this.view&&!this.view.updating),(async()=>{if(this._flags.length>0)e(t);else{const s=this.flags.map((async e=>{if(e.mapPoint){const s=new h({x:e.mapPoint.x,y:e.mapPoint.y,spatialReference:e.mapPoint.spatialReference.wkid}),r={screenPoint:this.view.toScreen(s),mapPoint:s};await this.queryFlagByHitTest(r,e.type)||("barrier"===e.type?t.push("barrier"):t.push("starting-point"))}}));await Promise.all(s),e(t)}}),{initial:!0})}))}addResultAreaToMap(e){if(e.resultArea.show=!0,null!==e.results?.aggregatedGeometry){const t=this._geometryHandler.mergeAggregatedToGeometries(e.results?.aggregatedGeometry);if(t.length>0){const s=Array(t.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,t,s)}}else{const t=this._groupResultsByNetworkSource(e.results.elements),s=[];for(const e in t)s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((t=>{const s=[];for(const e of t)for(const t of e)for(const e of t.featureSet.features)s.push(e.geometry);const r=Array(s.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,s,r)})).catch((e=>{console.log(e)}))}}async addResultGraphicToView(e,t){const{view:s}=this,{results:r}=e;if(s&&r)for(const i in r.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=r.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const r=await this._geometryHandler.projectGeometry(l,s.spatialReference),i={globalid:e.trace.globalId};if(null!==r){const e=this._graphicHandler.makeGraphic(r,t.color,i,s.spatialReference);s.graphics.add(e)}}}}addTerminal(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||s.selectedTerminals?.push(parseInt(e,10)))})),this._flags=s}async callTrace(){const e=this._traces.filter((e=>e.selected));return e.length>0&&(this._traceResults.length>0&&this._traceResults.forEach((e=>{this.removeResultGraphicFromView(e)})),this._traceResults=[],this.removeSelection(),await Promise.all(e.map((async(e,t)=>{const s=e,r=new w({gdbVersion:this.gdbVersion,moment:null,traceType:s.traceType,traceLocations:this._flags,namedTraceConfigurationGlobalId:s.globalId,traceConfiguration:null,outSpatialReference:null,resultTypes:null});await this.executeTrace(s,this.utilityNetwork.networkServiceUrl,r).then((e=>{if(e.hasOwnProperty("results")){const s={...e};if(null!==s.results){s.resultArea={...this.resultAreaProperties};const e=[...s.results.elements];s.results.elements.length=0;const r=new Map;for(const t of e)r.has(t.globalId)||(r.set(t.globalId,!0),s.results.elements.push(t));const i=[...this._traceResults];i.splice(t,0,s),this._traceResults=i,null!==s.results&&(this.selectOnComplete&&this.mergeSelection(!0,s.trace),this.showGraphicsOnComplete&&this.addResultGraphicToView(s,s.graphicColor),this.enableResultArea&&s.resultArea.show&&this.addResultAreaToMap(s))}else{const s=[...this._traceResults];s.splice(t,0,e),this._traceResults=s}this._activeProgress=!1}else{this._activeProgress=!1;const s=[...this._traceResults];s.splice(t,0,e),this._traceResults=s}})).catch((e=>{throw this._activeProgress=!1,e}))}))),!0)}changeResultAreaColor(e,t){e.resultArea&&(e.resultArea.color??=t,this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map))}changeResultGraphicColor(e,t){const s=[...this._traceResults];s.length>0&&s.forEach((s=>{s.trace.globalId===t.trace.globalId&&(s.graphicColor=e,s.graphicEnabled=!0)})),this._traceResults=s,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach((s=>{s.type===e&&t&&s.mapGraphic&&(s.mapGraphic.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]};let t=!1;const s=this._flags.some((e=>"starting-point"===e.type)),r=this._flags.filter((e=>null!==e.allTerminals));r.length>0&&(t=r.some((e=>e.selectedTerminals.length<=0)));let i=[];return s?(i=this._traces.filter((e=>e.selected)),i.length<=0?(e.status=!1,e.issues=["noTrace"],t&&(e.status=!1,e.issues=["noTrace","noTerminalSelected"])):t&&(e.status=!1,e.issues=["noTerminalSelected"])):(i=this._traces.filter((e=>!0===e.selected)),i.length>0?(e.status=!1,e.issues=["noStart"],t&&(e.status=!1,e.issues=["noStart","noTerminalSelected"])):(e.status=!1,e.issues=["noStart","noTrace"],t&&(e.status=!1,e.issues=["noStart","noTrace","noTerminalSelected"]))),e}checkSelectionExist(){let e=!1;return this._highlightHandler.some((t=>{t&&(e=!0)})),e}clearResult(e){if(!this.view)return;let t=this._traceResults;if(t.length>0){const s=t.filter((t=>t.trace.globalId===e.globalId));s.length>0&&(this.removeResultGraphicFromView(s[0]),this.removeResultAreaToMap(s[0])),t=t.filter((t=>t.trace.globalId!==e.globalId))}this._traceResults=t,0===t.length?(this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,s){if(!this.view)return;let r=[];if(r="convexhull"===this.resultAreaProperties?.type?this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):this._resultAreaHandler?.createBuffer(t,s,e.resultArea?.unit,!0),r&&r?.length>0)for(const i of r){const t=this.getResultAreaAttributes(e,i),s=this._resultAreaHandler?.createResultAreaGraphic(i,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);this._resultAreaHandler?.addResultAreaToMap(s,this.view.map)}}executeTrace(e,t,s){const r=this._processFlags(s.traceLocations);return s.traceLocations=r,y(t,s).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date})))}getResultAreaAttributes(e,s){const{messages:r}=this,i=[],a=[];this._flags.forEach((e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+r.attributeStrings.globalid+":"+e.globalId+";"+r.attributeStrings.terminalid+":"+e.terminalId+";"+r.attributeStrings.x+":"+e.mapPoint?.x+";"+r.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)}));return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:this.gdbVersion,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:this._geometryHandler.calculateArea(s,e.resultArea?.areaUnit)}}getValidSources(){let e=[];const t=this.utilityNetwork.dataElement?.domainNetworks??[];for(const s of t)e=e.concat(s.junctionSources),e=e.concat(s.edgeSources);return e}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof d){try{const t=e.map;await t.loadAll(),this._populateOutfields()}catch(r){this._populateOutfields()}return this.utilityNetwork}return null}const t=e.map,s=t.utilityNetworks?.at(0);if(s){await s.load(),this.utilityNetwork=s;try{await t.loadAll(),this._populateOutfields()}catch(r){}finally{this._populateOutfields()}return s}return null}manageFilterBarrier(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&"barrier"===t.type&&s.id===t.id&&(s.isFilterBarrier=e)})),this._flags=s}mergeSelection(e,t){let s=[];const r=[...this._traceResults],i=t.globalId;r.forEach((t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!=t.results&&null!==t.results.elements&&(s=[...s,...t.results.elements??[]])})),this.selectResults([...new Set(s)])}async queryFeaturesById(e){const{view:t}=this;if(!t)return null;const r=g(this.utilityNetwork,e),i=this._getUniqueMapLayerViews(t),a={layerUrl:r[0].layerUrl,objectIds:r[0].objectIds,outFields:["*"]},l=i.filter((e=>e.layer?.parsedUrl?.path===r[0].layerUrl));if(l.length>0){const e=(await Promise.all(l.map((async e=>{const r=new s,i=e.layer;r.add(i);const l={layers:r,layerInfos:[a],returnGeometry:!0,outSpatialReference:t.spatialReference};return(await m(l))[0]})))).filter((e=>e.featureSet.features.length>0));return e.length>0?e:null}return null}queryFlagByHitTest(e,t,s){return this._lookupFlagByHit(e).then((e=>{const{view:r}=this;if(!r)return!1;if(e.length>0){const i=[...this._flags],a=s;return e.forEach((e=>{const s=e.graphic,l=s.attributes.hasOwnProperty("GLOBALID")?s.attributes.GLOBALID:s.attributes.globalid;if(i.filter((e=>e.globalId===l)).length<=0){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}else if(null!==s.percentAlong){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}})),this._flags=i,!0}return!1}))}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const s=t.graphics;e.graphicEnabled=!1;s.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId)).forEach((e=>{t.graphics.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}removeResultAreaGrahicsLayer(){this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map)}removeResultAreaToMap(e){e.resultArea.show=!1,this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map)}removeSelection(){this._highlightHandler.forEach((e=>{e&&e.remove()})),this._highlightHandler=[]}removeTerminal(e,t){const s=[...this._flags];s.forEach((s=>{if(s.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const r=t.selectedTerminals.indexOf(parseInt(e,10));s.selectedTerminals?.splice(r,1)}})),this._flags=s}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}reset(){this._flags=[],this._traceResults=[];const e=[...this._traces];e.forEach((e=>{e.selected=!1})),this._traces=e,this.view&&(this.view.graphics.removeAll(),this.removeResultAreaGrahicsLayer(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}))}selectFeaturesById(e){const{view:t}=this;if(!t)return;const s=g(this.utilityNetwork,e);this._getUniqueMapLayerViews(t).forEach((e=>{e.layer?.parsedUrl?.path===s[0].layerUrl&&F(e)&&this._highlightHandler.push(e.highlight(s[0].objectIds))}))}selectResults(e){if(e.length>0){this.removeSelection();const t=this._groupResultsByNetworkSource(e),s=[];for(const e in t)this.selectFeaturesById(t[e]),s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((e=>{this.emit("select-features",{resultSet:e})}))}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const s=[...this._traces];s.forEach((s=>{t===s.globalId&&(s.selected=e)})),this._traces=s}selectTracesOnLoad(){this.utilityNetwork.hasOwnProperty("sharedNamedTraceConfigurations")&&(this._traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this._traces.forEach((e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)})))}zoomToAsset(e){this.view?.goTo(e).catch((e=>console.error(e)))}_getUniqueMapLayerViews(e){const t=[];return e.layerViews.filter((({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e)).forEach((e=>{switch(e.layer.type){case"group":if(T(e))for(const s of e.layerViews)t.push(s);break;case"subtype-group":t.push(e);break;default:t.some((t=>t.layer.id===e.layer.id))||t.push(e)}})),t}_processFlags(e){const t=[];return e.forEach((e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach((s=>{const r=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:s,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}));else{const s=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:null,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}})),t}_getDisplayField(e){return"subtype-sublayer"===e?.layer?.type?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",s="";const r=e.layer;t=this._checkParentForData(r,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(s=e.attributes[i],"assetgroup"===a||"assettype"===a?s=this._checkSubtype(r,r.subtypeCode):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,r)))):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,r)))}return{field:t,value:s.toString()}}_getDisplayFieldByFeatureLayer(e){const t=e.layer;let s=t.displayField,r="";for(const i in e.attributes){const a=i.toLowerCase();if(a===s?.toLowerCase())if(r=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),s=t.typeIdField,r=this._checkSubtype(t,a),""===s&&(t.templates&&t.templates.length>0?(s=t.templates[0]?.name,r=t.templates[0]?.name):(s=t.displayField,r=e.attributes[i]))}else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,t));else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,t))}return{field:s,value:r?r.toString():""}}_checkSubtype(e,t){let s=t;if("subtype-sublayer"===e.type){const r=this._checkParentForData(e,"subtypes");r?.length>0&&r.forEach((e=>{e.code===t&&(s=e.name)}))}else if(null!=e.types&&e.types.length>0){const r=e.types.filter((e=>e.id===t));r.length>0&&(s=r[0].name)}return s}_checkDomain(e,t,s){let r=s;const i=e.filter((e=>e.name.toLowerCase()===t.toLowerCase()));if(i.length>0&&I(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter((({code:e})=>e===s));e.length>0&&(r=e[0].name)}return r}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}_groupBy(e,t){return e.reduce(((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e)),{})}_groupResultsByNetworkSource(e){if(e.length>0){return this._groupBy(e,"networkSourceId")}return[]}_lookupFlagByHit(e){return this.view.hitTest(e.screenPoint).then((t=>{const s=[];if(t.results.length>0){const r=t.results.find((e=>null!==e.layer));if(r.graphic&&null!=r.graphic.geometry)if("polyline"===r.graphic.geometry.type){const t=this._geometryHandler.getPercentageAlong(r.graphic.geometry,e.mapPoint,r.graphic.geometry.spatialReference),i=this._getDisplayField(r.graphic);r.graphic.terminalId=null,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=null,r.graphic.selectedTerminals=null,r.graphic.percentAlong=t,r.graphic.displayValue=i,r.graphic.mapPoint=r.mapPoint,s.push(r)}else if(("point"===r.graphic.geometry.type||"polygon"===r.graphic.geometry.type)&&null!==this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(r.graphic),t=this._getDisplayField(r.graphic);r.graphic.terminalId=e?e.terminals[0].id||null:1,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=e??null,r.graphic.selectedTerminals=[e?e.terminals[0].id||null:1],r.graphic.percentAlong=null,r.graphic.displayValue=t,r.graphic.mapPoint=r.mapPoint,s.push(r)}}return s}))}async _populateOutfields(){const e=this.view?.map,t=this.getValidSources();e?.layers.forEach((e=>{"group"===e.type?e.layers.forEach((e=>{t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])})):t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])}))}_removeGraphic(e){this.view?.graphics.remove(e.mapGraphic)}};e([n()],k.prototype,"_activeProgress",void 0),e([n()],k.prototype,"_flags",void 0),e([n()],k.prototype,"_traces",void 0),e([n()],k.prototype,"_traceResults",void 0),e([n()],k.prototype,"defaultGraphicColor",void 0),e([n()],k.prototype,"enableResultArea",void 0),e([n()],k.prototype,"flags",void 0),e([n()],k.prototype,"gdbVersion",void 0),e([n()],k.prototype,"messages",void 0),e([n()],k.prototype,"messagesUnits",void 0),e([n()],k.prototype,"resultAreaProperties",null),e([n()],k.prototype,"selectedTraces",void 0),e([n()],k.prototype,"selectOnComplete",void 0),e([n()],k.prototype,"showGraphicsOnComplete",void 0),e([n()],k.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],k.prototype,"state",null),e([n()],k.prototype,"utilityNetwork",void 0),e([n({value:null})],k.prototype,"view",null),k=e([c("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],k);const S=k;export{S as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{id as t}from"../../kernel.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as a}from"../../core/HandleOwner.js";import l from"../../core/Logger.js";import{when as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/Point.js";import{fetchMessageBundle as u}from"../../intl/messages.js";import p from"../../layers/support/CodedValueDomain.js";import d from"../../networks/UtilityNetwork.js";import{getObjectIdsFromElements as g,getFeaturesFromLayers as m}from"../../networks/support/utils.js";import{trace as y}from"../../rest/networks/trace.js";import f from"../../rest/networks/support/TraceLocation.js";import w from"../../rest/networks/support/TraceParameters.js";import{GeometryHandler as _}from"./support/GeometryHandler.js";import{GraphicHandler as b}from"./support/GraphicHandler.js";import{ResultAreaHandler as v}from"./support/ResultAreaHandler.js";const A=()=>u("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),R=()=>u("esri/core/t9n/Units");function I(e){return e instanceof p}function T(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function F(e){return void 0!==e.layerViews}let k=class extends(a(i.EventedAccessor)){constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._geometryHandler=null,this._graphicHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._traces=[],this._watchHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.gdbVersion="sde.DEFAULT",this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.traceResults=[],this.utilityNetwork=null}initialize(){this._geometryHandler=new _,this._graphicHandler=new b,this._resultAreaHandler=new v;(async()=>{const[e,t]=await Promise.all([A(),R()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e})}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&l.getLogger(this).error(new r("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e)}addFlagByHit(e,t){const s=e=>{this.view?.popup&&(this.view.popupEnabled=e)};return new Promise(((r,i)=>{s(!1),this._clickHandler?.remove(),this.emit("add-flag",{type:e}),this._clickHandler=this.view?.on("click",(a=>{this.queryFlagByHitTest(a,e,t).then((i=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-complete",{type:e,symbol:t}),r(i)})).catch((r=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-error",{type:e,symbol:t}),i(r)}))}))}))}async addFlagsOnLoad(){return new Promise((e=>{const t=[];this._watchHandler=o((()=>null!=this.view&&!this.view.updating),(async()=>{if(this._flags.length>0)e(t);else{const s=this.flags.map((async e=>{if(e.mapPoint){const s=new h({x:e.mapPoint.x,y:e.mapPoint.y,spatialReference:e.mapPoint.spatialReference.wkid}),r={screenPoint:this.view.toScreen(s),mapPoint:s};await this.queryFlagByHitTest(r,e.type)||("barrier"===e.type?t.push("barrier"):t.push("starting-point"))}}));await Promise.all(s),e(t)}}),{initial:!0})}))}addResultAreaToMap(e){if(e.resultArea.show=!0,null!==e.results?.aggregatedGeometry){const t=this._geometryHandler.mergeAggregatedToGeometries(e.results?.aggregatedGeometry);if(t.length>0){const s=Array(t.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,t,s)}}else{const t=this._groupResultsByNetworkSource(e.results.elements),s=[];for(const e in t)s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((t=>{const s=[];for(const e of t)for(const t of e)for(const e of t.featureSet.features)s.push(e.geometry);const r=Array(s.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,s,r)})).catch((e=>{console.log(e)}))}}async addResultGraphicToView(e,t){const{view:s}=this,{results:r}=e;if(s&&r)for(const i in r.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=r.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const r=await this._geometryHandler.projectGeometry(l,s.spatialReference),i={globalid:e.trace.globalId};if(null!==r){const e=this._graphicHandler.makeGraphic(r,t.color,i,s.spatialReference);s.graphics.add(e)}}}}addTerminal(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||s.selectedTerminals?.push(parseInt(e,10)))})),this._flags=s}async callTrace(){const e=this._traces.filter((e=>e.selected));return e.length>0&&(this.traceResults.length>0&&this.traceResults.forEach((e=>{this.removeResultGraphicFromView(e)})),this.traceResults=[],this.removeSelection(),await Promise.all(e.map((async(e,t)=>{const s=e,r=new w({gdbVersion:this.gdbVersion,moment:null,traceType:s.traceType,traceLocations:this._flags,namedTraceConfigurationGlobalId:s.globalId,traceConfiguration:null,outSpatialReference:null,resultTypes:null});await this.executeTrace(s,this.utilityNetwork.networkServiceUrl,r).then((e=>{if(e.hasOwnProperty("results")){const s={...e};if(null!==s.results){s.resultArea={...this.resultAreaProperties};const e=[...s.results.elements];s.results.elements.length=0;const r=new Map;for(const t of e)r.has(t.globalId)||(r.set(t.globalId,!0),s.results.elements.push(t));const i=[...this.traceResults];i.splice(t,0,s),this.traceResults=i,null!==s.results&&(this.selectOnComplete&&this.mergeSelection(!0,s.trace),this.showGraphicsOnComplete&&this.addResultGraphicToView(s,s.graphicColor),this.enableResultArea&&s.resultArea.show&&this.addResultAreaToMap(s))}else{const s=[...this.traceResults];s.splice(t,0,e),this.traceResults=s}this._activeProgress=!1}else{this._activeProgress=!1;const s=[...this.traceResults];s.splice(t,0,e),this.traceResults=s}})).catch((e=>{throw this._activeProgress=!1,e}))}))),!0)}changeResultAreaColor(e,t){e.resultArea&&(e.resultArea.color??=t,this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map))}changeResultGraphicColor(e,t){const s=[...this.traceResults];s.length>0&&s.forEach((s=>{s.trace.globalId===t.trace.globalId&&(s.graphicColor=e,s.graphicEnabled=!0)})),this.traceResults=s,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach((s=>{s.type===e&&t&&s.mapGraphic&&(s.mapGraphic.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]};let t=!1;const s=this._flags.some((e=>"starting-point"===e.type)),r=this._flags.filter((e=>null!==e.allTerminals));r.length>0&&(t=r.some((e=>e.selectedTerminals.length<=0)));let i=[];return s?(i=this._traces.filter((e=>e.selected)),i.length<=0?(e.status=!1,e.issues=["noTrace"],t&&(e.status=!1,e.issues=["noTrace","noTerminalSelected"])):t&&(e.status=!1,e.issues=["noTerminalSelected"])):(i=this._traces.filter((e=>!0===e.selected)),i.length>0?(e.status=!1,e.issues=["noStart"],t&&(e.status=!1,e.issues=["noStart","noTerminalSelected"])):(e.status=!1,e.issues=["noStart","noTrace"],t&&(e.status=!1,e.issues=["noStart","noTrace","noTerminalSelected"]))),e}checkSelectionExist(){let e=!1;return this._highlightHandler.some((t=>{t&&(e=!0)})),e}clearResult(e){if(!this.view)return;let t=this.traceResults;if(t.length>0){const s=t.filter((t=>t.trace.globalId===e.globalId));s.length>0&&(this.removeResultGraphicFromView(s[0]),this.removeResultAreaToMap(s[0])),t=t.filter((t=>t.trace.globalId!==e.globalId))}this.traceResults=t,0===t.length?(this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,s){if(!this.view||!this.resultAreaProperties)return;let r;if("convexhull"===this.resultAreaProperties?.type?r=this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):t&&(r=this._resultAreaHandler?.createBuffer(t,s,e.resultArea?.unit,!0)),r&&Array.isArray(r)){if(r.length>0)for(const i of r){const t=this.getResultAreaAttributes(e,i),s=this._resultAreaHandler?.createResultAreaGraphic(i,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);s&&this._resultAreaHandler?.addResultAreaToMap(s,this.view.map)}}else{const t=this.getResultAreaAttributes(e,r),s=this._resultAreaHandler?.createResultAreaGraphic(r,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);s&&this._resultAreaHandler?.addResultAreaToMap(s,this.view.map)}}executeTrace(e,t,s){const r=this._processFlags(s.traceLocations);return s.traceLocations=r,y(t,s).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date})))}getResultAreaAttributes(e,s){const{messages:r}=this,i=[],a=[];this._flags.forEach((e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+r.attributeStrings.globalid+":"+e.globalId+";"+r.attributeStrings.terminalid+":"+e.terminalId+";"+r.attributeStrings.x+":"+e.mapPoint?.x+";"+r.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)}));return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:this.gdbVersion,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:this._geometryHandler.calculateArea(s,e.resultArea?.areaUnit)}}getValidSources(){let e=[];const t=this.utilityNetwork.dataElement?.domainNetworks??[];for(const s of t)e=e.concat(s.junctionSources),e=e.concat(s.edgeSources);return e}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof d){try{const t=e.map;await t.loadAll(),this._populateOutfields()}catch(r){this._populateOutfields()}return this.utilityNetwork}return null}const t=e.map,s=t.utilityNetworks?.at(0);if(s){await s.load(),this.utilityNetwork=s;try{await t.loadAll(),this._populateOutfields()}catch(r){}finally{this._populateOutfields()}return s}return null}manageFilterBarrier(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&"barrier"===t.type&&s.id===t.id&&(s.isFilterBarrier=e)})),this._flags=s}mergeSelection(e,t){let s=[];const r=[...this.traceResults],i=t.globalId;r.forEach((t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!=t.results&&null!==t.results.elements&&(s=[...s,...t.results.elements??[]])})),this.selectResults([...new Set(s)])}async queryFeaturesById(e){const{view:t}=this;if(!t)return null;const r=g(this.utilityNetwork,e),i=this._getUniqueMapLayerViews(t),a={layerUrl:r[0].layerUrl,objectIds:r[0].objectIds,outFields:["*"]},l=i.filter((e=>e.layer?.parsedUrl?.path===r[0].layerUrl));if(l.length>0){const e=(await Promise.all(l.map((async e=>{const r=new s,i=e.layer;r.add(i);const l={layers:r,layerInfos:[a],returnGeometry:!0,outSpatialReference:t.spatialReference};return(await m(l))[0]})))).filter((e=>e.featureSet.features.length>0));return e.length>0?e:null}return null}queryFlagByHitTest(e,t,s){return this._lookupFlagByHit(e).then((e=>{const{view:r}=this;if(!r)return!1;if(e.length>0){const i=[...this._flags],a=s;return e.forEach((e=>{const s=e.graphic,l=s.attributes.hasOwnProperty("GLOBALID")?s.attributes.GLOBALID:s.attributes.globalid;if(i.filter((e=>e.globalId===l)).length<=0){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}else if(null!==s.percentAlong){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}})),this._flags=i,!0}return!1}))}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const s=t.graphics;e.graphicEnabled=!1;s.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId)).forEach((e=>{t.graphics.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}removeResultAreaGrahicsLayer(){this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map)}removeResultAreaToMap(e){e.resultArea.show=!1,this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map)}removeSelection(){this._highlightHandler.forEach((e=>{e&&e.remove()})),this._highlightHandler=[]}removeTerminal(e,t){const s=[...this._flags];s.forEach((s=>{if(s.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const r=t.selectedTerminals.indexOf(parseInt(e,10));s.selectedTerminals?.splice(r,1)}})),this._flags=s}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}reset(){this._flags=[],this.traceResults=[];const e=[...this._traces];e.forEach((e=>{e.selected=!1})),this._traces=e,this.view&&(this.view.graphics.removeAll(),this.removeResultAreaGrahicsLayer(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}))}selectFeaturesById(e){const{view:t}=this;if(!t)return;const s=g(this.utilityNetwork,e);this._getUniqueMapLayerViews(t).forEach((e=>{e.layer?.parsedUrl?.path===s[0].layerUrl&&T(e)&&this._highlightHandler.push(e.highlight(s[0].objectIds))}))}selectResults(e){if(e.length>0){this.removeSelection();const t=this._groupResultsByNetworkSource(e),s=[];for(const e in t)this.selectFeaturesById(t[e]),s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((e=>{this.emit("select-features",{resultSet:e})}))}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const s=[...this._traces];s.forEach((s=>{t===s.globalId&&(s.selected=e)})),this._traces=s}selectTracesOnLoad(){this.utilityNetwork.hasOwnProperty("sharedNamedTraceConfigurations")&&(this._traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this._traces.forEach((e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)})))}zoomToAsset(e){this.view?.goTo(e).catch((e=>console.error(e)))}_getUniqueMapLayerViews(e){const t=[];return e.layerViews.filter((({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e)).forEach((e=>{switch(e.layer.type){case"group":if(F(e))for(const s of e.layerViews)t.push(s);break;case"subtype-group":t.push(e);break;default:t.some((t=>t.layer.id===e.layer.id))||t.push(e)}})),t}_processFlags(e){const t=[];return e.forEach((e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach((s=>{const r=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:s,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}));else{const s=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:null,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}})),t}_getDisplayField(e){return"subtype-sublayer"===e?.layer?.type?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",s="";const r=e.layer;t=this._checkParentForData(r,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(s=e.attributes[i],"assetgroup"===a||"assettype"===a?s=this._checkSubtype(r,r.subtypeCode):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,r)))):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,r)))}return{field:t,value:s.toString()}}_getDisplayFieldByFeatureLayer(e){const t=e.layer;let s=t.displayField,r="";for(const i in e.attributes){const a=i.toLowerCase();if(a===s?.toLowerCase())if(r=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),s=t.typeIdField,r=this._checkSubtype(t,a),""===s&&(t.templates&&t.templates.length>0?(s=t.templates[0]?.name,r=t.templates[0]?.name):(s=t.displayField,r=e.attributes[i]))}else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,t));else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,t))}return{field:s,value:r?r.toString():""}}_checkSubtype(e,t){let s=t;if("subtype-sublayer"===e.type){const r=this._checkParentForData(e,"subtypes");r?.length>0&&r.forEach((e=>{e.code===t&&(s=e.name)}))}else if(null!=e.types&&e.types.length>0){const r=e.types.filter((e=>e.id===t));r.length>0&&(s=r[0].name)}return s}_checkDomain(e,t,s){let r=s;const i=e.filter((e=>e.name.toLowerCase()===t.toLowerCase()));if(i.length>0&&I(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter((({code:e})=>e===s));e.length>0&&(r=e[0].name)}return r}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}_groupBy(e,t){return e.reduce(((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e)),{})}_groupResultsByNetworkSource(e){if(e.length>0){return this._groupBy(e,"networkSourceId")}return[]}_lookupFlagByHit(e){return this.view.hitTest(e.screenPoint).then((t=>{const s=[];if(t.results.length>0){const r=t.results.find((e=>null!==e.layer));if(r.graphic&&null!=r.graphic.geometry)if("polyline"===r.graphic.geometry.type){const t=this._geometryHandler.getPercentageAlong(r.graphic.geometry,e.mapPoint,r.graphic.geometry.spatialReference),i=this._getDisplayField(r.graphic);r.graphic.terminalId=null,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=null,r.graphic.selectedTerminals=null,r.graphic.percentAlong=t,r.graphic.displayValue=i,r.graphic.mapPoint=r.mapPoint,s.push(r)}else if(("point"===r.graphic.geometry.type||"polygon"===r.graphic.geometry.type)&&null!==this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(r.graphic),t=this._getDisplayField(r.graphic);r.graphic.terminalId=e?e.terminals[0].id||null:1,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=e??null,r.graphic.selectedTerminals=[e?e.terminals[0].id||null:1],r.graphic.percentAlong=null,r.graphic.displayValue=t,r.graphic.mapPoint=r.mapPoint,s.push(r)}}return s}))}async _populateOutfields(){const e=this.view?.map,t=this.getValidSources();e?.layers.forEach((e=>{"group"===e.type?e.layers.forEach((e=>{t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])})):t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])}))}_removeGraphic(e){this.view?.graphics.remove(e.mapGraphic)}};e([n()],k.prototype,"_activeProgress",void 0),e([n()],k.prototype,"_flags",void 0),e([n()],k.prototype,"_traces",void 0),e([n()],k.prototype,"defaultGraphicColor",void 0),e([n()],k.prototype,"enableResultArea",void 0),e([n()],k.prototype,"flags",void 0),e([n()],k.prototype,"gdbVersion",void 0),e([n()],k.prototype,"messages",void 0),e([n()],k.prototype,"messagesUnits",void 0),e([n()],k.prototype,"resultAreaProperties",null),e([n()],k.prototype,"selectedTraces",void 0),e([n()],k.prototype,"selectOnComplete",void 0),e([n()],k.prototype,"showGraphicsOnComplete",void 0),e([n()],k.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],k.prototype,"state",null),e([n()],k.prototype,"traceResults",void 0),e([n()],k.prototype,"utilityNetwork",void 0),e([n({value:null})],k.prototype,"view",null),k=e([c("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],k);const S=k;export{S 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.27/esri/copyright.txt for details.
4
4
  */
5
- import"../../../geometry.js";import{geodesicBuffer as e,buffer as t,convexHull as r,geodesicArea as o,planarArea as n,cut as i,planarLength as s}from"../../../geometry/geometryEngine.js";import a from"../../../geometry/Polyline.js";import{project as l,load as c}from"../../../geometry/projection.js";import p from"../../../geometry/SpatialReference.js";function f(e){return"polygon"===e.type}class m{createBuffer(r,o,n,i){const s=new p({wkid:r[0]?.spatialReference?.wkid});return s.isWGS84||s.isWebMercator?e(r,o,n):t(r,o,n,i)}createConvexHull(e){return r(e,!0).filter(f)}calculateArea(e,t){const r=new p({wkid:e.spatialReference.wkid});return r.isWGS84||r.isWebMercator?parseFloat(o(e,t).toFixed(2)):parseFloat(n(e,t).toFixed(2))}mergeAggregatedToGeometries(e){const t=[],{line:r,multipoint:o,polygon:n}=e;return r&&t.push(r),o&&t.push(o),n&&t.push(n),t}getPercentageAlong(e,t,r){let o=e;const n=this._createPolyline(e.paths,r.wkid);if("point"===t.type){const e=t.x-50,a=t.x+50,c=[[e,t.y-50],[a,t.y+50]];o=this._createPolyline(c,t.spatialReference.wkid);o=l(o,r);const p=i(n,o);if(p.length>0){const e=s(n,"feet");let t;t=p[0].paths[0][0][0]===n.paths[0][0][0]?s(p[0],"feet"):s(p[1],"feet");return[t/e]}return[.5]}o=l(t,r);const a=i(n,o);if(a.length>0){const e=s(n,"feet");return[s(a[0],"feet")/e]}return[.5]}async projectGeometry(e,t){return await c(),l(e,t)}_createPolyline(e,t){return new a({hasZ:!1,hasM:!0,paths:e,spatialReference:{wkid:t}})}}export{m as GeometryHandler};
5
+ import"../../../geometry.js";import{geodesicBuffer as e,buffer as t,convexHull as r,geodesicArea as n,planarArea as o,cut as i,planarLength as s}from"../../../geometry/geometryEngine.js";import a from"../../../geometry/Polyline.js";import{project as c,load as l}from"../../../geometry/projection.js";import p from"../../../geometry/SpatialReference.js";function f(e){return"polygon"===e.type||"polyline"===e.type}function u(e){return e.hasOwnProperty("points")}function y(e){return u(e)&&2===e.points.length}class g{createBuffer(r,n,o,i){if(Array.isArray(r)){if(r.length>0){const s=p.fromJSON(r[0].spatialReference);return s.isWGS84||s.isWebMercator?e(r,n,o):t(r,n,o,i)}return}const s=p.fromJSON(r.spatialReference);return s.isWGS84||s.isWebMercator?e(r,n[0],o):t(r,n[0],o)}createConvexHull(e){if(Array.isArray(e)){if(1===e.length&&y(e[0])){const t=r(e[0]);if(f(t))return t}return r(e,!0).filter(f)}const t=r(e);if(f(t))return t}calculateArea(e,t){const r=new p({wkid:e.spatialReference.wkid});return r.isWGS84||r.isWebMercator?parseFloat(n(e,t).toFixed(2)):parseFloat(o(e,t).toFixed(2))}mergeAggregatedToGeometries(e){const t=[],{line:r,multipoint:n,polygon:o}=e;return r&&t.push(r),n&&t.push(n),o&&t.push(o),t}getPercentageAlong(e,t,r){let n=e;const o=this._createPolyline(e.paths,r.wkid);if("point"===t.type){const e=t.x-50,a=t.x+50,l=[[e,t.y-50],[a,t.y+50]];n=this._createPolyline(l,t.spatialReference.wkid);n=c(n,r);const p=i(o,n);if(p.length>0){const e=s(o,"feet");let t;t=p[0].paths[0][0][0]===o.paths[0][0][0]?s(p[0],"feet"):s(p[1],"feet");return[t/e]}return[.5]}n=c(t,r);const a=i(o,n);if(a.length>0){const e=s(o,"feet");return[s(a[0],"feet")/e]}return[.5]}async projectGeometry(e,t){return await l(),c(e,t)}_createPolyline(e,t){return new a({hasZ:!1,hasM:!0,paths:e,spatialReference:{wkid:t}})}}export{g as GeometryHandler};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import r from"../../../layers/GraphicsLayer.js";import t from"../../../symbols/SimpleFillSymbol.js";import{GeometryHandler as o}from"./GeometryHandler.js";const a="utility-network-trace-result-area";function i(e){return!!e&&"graphics"===e.type}class n{constructor(){this.traceInformation={},this._geometryHandler=new o}addResultAreaToMap(e,r){const t=this._createGraphicLayer(r);t&&i(t)&&t.add(e)}changeResultAreaColor(e,r,o){const a=this._findGraphicsByTraceId(e,o);a&&a.forEach((e=>{const o=new t({color:r.color,style:"solid",outline:{color:r.color,width:1}});e.symbol=o}))}createBuffer(e,r,t,o){return this._geometryHandler.createBuffer(e,r,t,o)}createConvexHull(e,r,t){const o=this._geometryHandler.createConvexHull(e);return r>0?this.createBuffer(o,[r],t,!1):o}createResultAreaGraphic(r,o,a,i,n,s){const c=new t({color:s.color,style:"solid",outline:{color:s.color,width:1}}),l=[];for(const e in o)l.push({fieldName:e,label:"areaStatistic"===e?i.attributeStrings[e]+" ("+n.units[a]?.abbr+")":i.attributeStrings[e],value:o[e]});return new e({geometry:r,symbol:c,attributes:o,popupTemplate:{title:o.traceName,content:[{type:"fields",fieldInfos:l}]}})}removeResultArea(e,r){const t=r.findLayerById(a);if(t&&i(t)){const o=this._findGraphicsByTraceId(e,r);o&&t.removeMany(o)}}removeResultAreaGrahicsLayer(e){if(e){const r=e.findLayerById(a);r&&i(r)&&e.remove(r)}}_createGraphicLayer(e){if(!e.findLayerById(a)){const t=new r({id:a});return e.add(t),t}const t=e.findLayerById(a);return t&&i(t)?t:null}_findGraphicsByTraceId(e,r){const t=r.findLayerById(a);if(t&&i(t)){const r=t.graphics.filter((r=>r.attributes.traceId===e));return r.length>0?r.toArray():null}return null}}export{n as ResultAreaHandler};
5
+ import e from"../../../Graphic.js";import r from"../../../layers/GraphicsLayer.js";import t from"../../../symbols/SimpleFillSymbol.js";import{GeometryHandler as o}from"./GeometryHandler.js";const a="utility-network-trace-result-area";function i(e){return!!e&&"graphics"===e.type}class n{constructor(){this.traceInformation={},this._geometryHandler=new o}addResultAreaToMap(e,r){const t=this._createGraphicLayer(r);t&&i(t)&&t.add(e)}changeResultAreaColor(e,r,o){const a=this._findGraphicsByTraceId(e,o);a&&a.forEach((e=>{const o=new t({color:r.color,style:"solid",outline:{color:r.color,width:1}});e.symbol=o}))}createBuffer(e,r,t,o){return this._geometryHandler.createBuffer(e,r,t,o)}createConvexHull(e,r,t){const o=this._geometryHandler.createConvexHull(e);return r>0&&o?this.createBuffer(o,[r],t,!1):o}createResultAreaGraphic(r,o,a,i,n,s){const c=new t({color:s.color,style:"solid",outline:{color:s.color,width:1}}),l=[];for(const e in o)l.push({fieldName:e,label:"areaStatistic"===e?i.attributeStrings[e]+" ("+n.units[a]?.abbr+")":i.attributeStrings[e],value:o[e]});return new e({geometry:r,symbol:c,attributes:o,popupTemplate:{title:o.traceName,content:[{type:"fields",fieldInfos:l}]}})}removeResultArea(e,r){const t=r.findLayerById(a);if(t&&i(t)){const o=this._findGraphicsByTraceId(e,r);o&&t.removeMany(o)}}removeResultAreaGrahicsLayer(e){if(e){const r=e.findLayerById(a);r&&i(r)&&e.remove(r)}}_createGraphicLayer(e){if(!e.findLayerById(a)){const t=new r({id:a});return e.add(t),t}const t=e.findLayerById(a);return t&&i(t)?t:null}_findGraphicsByTraceId(e,r){const t=r.findLayerById(a);if(t&&i(t)){const r=t.graphics.filter((r=>r.attributes.traceId===e));return r.length>0?r.toArray():null}return null}}export{n as ResultAreaHandler};