@arcgis/core 4.24.4 → 4.24.7

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.
package/config.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.24/esri/copyright.txt for details.
4
4
  */
5
- import"./core/has.js";import{deepMerge as e}from"./core/object.js";const r={apiKey:void 0,applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(r,globalThis.esriConfig,!0),delete r.has),!r.assetsPath){const e="4.24.4";r.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}r.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(r,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),r.request.corsEnabledServers=[],r.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{r as default};
5
+ import"./core/has.js";import{deepMerge as e}from"./core/object.js";const r={apiKey:void 0,applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(r,globalThis.esriConfig,!0),delete r.has),!r.assetsPath){const e="4.24.7";r.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}r.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(r,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),r.request.corsEnabledServers=[],r.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{r as default};
package/interfaces.d.ts CHANGED
@@ -19637,7 +19637,12 @@ declare namespace __esri {
19637
19637
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CornersGeoreference.html#topRight)
19638
19638
  */
19639
19639
  topRight: Point;
19640
- type: "corners";
19640
+ /**
19641
+ * The georeference type.
19642
+ *
19643
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CornersGeoreference.html#type)
19644
+ */
19645
+ readonly type: "corners";
19641
19646
  }
19642
19647
 
19643
19648
  interface CornersGeoreferenceConstructor {
@@ -19684,7 +19689,6 @@ declare namespace __esri {
19684
19689
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CornersGeoreference.html#topRight)
19685
19690
  */
19686
19691
  topRight?: PointProperties;
19687
- type?: "corners";
19688
19692
  }
19689
19693
 
19690
19694
  interface DimensionalDefinition extends Accessor, JSONSupport {
@@ -19891,7 +19895,12 @@ declare namespace __esri {
19891
19895
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ExtentAndRotationGeoreference.html#rotation)
19892
19896
  */
19893
19897
  rotation: number;
19894
- type: "extent-and-rotation";
19898
+ /**
19899
+ * The georeference type.
19900
+ *
19901
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ExtentAndRotationGeoreference.html#type)
19902
+ */
19903
+ readonly type: "extent-and-rotation";
19895
19904
  }
19896
19905
 
19897
19906
  interface ExtentAndRotationGeoreferenceConstructor {
@@ -19922,7 +19931,6 @@ declare namespace __esri {
19922
19931
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ExtentAndRotationGeoreference.html#rotation)
19923
19932
  */
19924
19933
  rotation?: number;
19925
- type?: "extent-and-rotation";
19926
19934
  }
19927
19935
 
19928
19936
  interface FacilityLayerInfo extends Accessor, JSONSupport {
@@ -21080,7 +21088,12 @@ declare namespace __esri {
21080
21088
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageElement.html#image)
21081
21089
  */
21082
21090
  image: string | HTMLImageElement | HTMLCanvasElement | ImageData;
21083
- type: "image";
21091
+ /**
21092
+ * The element type.
21093
+ *
21094
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageElement.html#type)
21095
+ */
21096
+ readonly type: "image";
21084
21097
  }
21085
21098
 
21086
21099
  interface ImageElementConstructor {
@@ -21101,7 +21114,6 @@ declare namespace __esri {
21101
21114
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageElement.html#image)
21102
21115
  */
21103
21116
  image?: string | HTMLImageElement | HTMLCanvasElement | ImageData;
21104
- type?: "image";
21105
21117
  }
21106
21118
 
21107
21119
  interface ImageParameters extends Accessor {
@@ -24701,7 +24713,12 @@ declare namespace __esri {
24701
24713
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-VideoElement.html#content)
24702
24714
  */
24703
24715
  readonly content: any;
24704
- type: "video";
24716
+ /**
24717
+ * The element type.
24718
+ *
24719
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-VideoElement.html#type)
24720
+ */
24721
+ readonly type: "video";
24705
24722
  /**
24706
24723
  * The video element to be added to the [media layer's source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MediaLayer.html#source).
24707
24724
  *
@@ -24722,7 +24739,6 @@ declare namespace __esri {
24722
24739
  export const VideoElement: VideoElementConstructor;
24723
24740
 
24724
24741
  interface VideoElementProperties extends MediaElementBaseProperties {
24725
- type?: "video";
24726
24742
  /**
24727
24743
  * The video element to be added to the [media layer's source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MediaLayer.html#source).
24728
24744
  *
@@ -69035,7 +69051,7 @@ declare namespace __esri {
69035
69051
  *
69036
69052
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#MediaHit)
69037
69053
  */
69038
- element: ImageElement;
69054
+ element: ImageElement | VideoElement;
69039
69055
  /**
69040
69056
  * The media layer that contains the element.
69041
69057
  *
@@ -69727,7 +69743,7 @@ declare namespace __esri {
69727
69743
  *
69728
69744
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#MediaHit)
69729
69745
  */
69730
- element: ImageElement;
69746
+ element: ImageElement | VideoElement;
69731
69747
  /**
69732
69748
  * The distance from the camera position to the point geometry hit on this graphic.
69733
69749
  *
@@ -99687,6 +99703,12 @@ declare namespace __esri {
99687
99703
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#isResolved)
99688
99704
  */
99689
99705
  isResolved(): boolean;
99706
+ /**
99707
+ * Adds one or more handles which are to be tied to the lifecycle of the widget.
99708
+ *
99709
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#own)
99710
+ */
99711
+ own(handleOrHandles: WatchHandle | WatchHandle[]): void;
99690
99712
  /**
99691
99713
  * *This method is primarily used by developers when implementing custom widgets.* Executes after widget is ready for rendering.
99692
99714
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.24.4",
3
+ "version": "4.24.7",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS API for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- const c="20220629",f="424f75793a8d4dbd3ac1b1c1476f478c61e1ff6e";export{c as buildDate,f as commitHash};
5
+ const d="20220708",f="7fd01dbc0e83d753fcf101c8ff2a8d215430252d";export{d as buildDate,f as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import i from"../../../Graphic.js";import s from"../../../core/Collection.js";import{isSome as t,isNone as r}from"../../../core/maybe.js";import{watch as h,on as a,initial as o}from"../../../core/reactiveUtils.js";import"../../../core/Logger.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/set.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{LayerView2DMixin as c}from"./LayerView2D.js";import n from"./graphics/GraphicContainer.js";import l from"./graphics/GraphicsView2D.js";import g from"../../layers/LayerView.js";const d="sublayers",u="layerView",f=Object.freeze({remove(){},pause(){},resume(){}});let m=class extends(c(g)){constructor(){super(...arguments),this._highlightIds=new Map}async fetchPopupFeatures(e){return Array.from(this.graphicsViews(),(i=>i.hitTest(e).filter((e=>!!e.popupTemplate)))).flat()}*graphicsViews(){t(this._graphicsViewsFeatureCollectionMap)?yield*this._graphicsViewsFeatureCollectionMap.keys():t(this._graphicsViews)?yield*this._graphicsViews:yield*[]}async hitTest(e,i){return Array.from(this.graphicsViews(),(i=>{const s=i.hitTest(e);if(t(this._graphicsViewsFeatureCollectionMap)){const e=this._graphicsViewsFeatureCollectionMap.get(i);for(const i of s)!i.popupTemplate&&e.popupTemplate&&(i.popupTemplate=e.popupTemplate)}return s})).flat().map((i=>({type:"graphic",graphic:i,layer:this.layer,mapPoint:e})))}highlight(e){let t;return"number"==typeof e?t=[e]:e instanceof i?t=[e.uid]:Array.isArray(e)&&e.length>0?t="number"==typeof e[0]?e:e.map((e=>e&&e.uid)):s.isCollection(e)&&(t=e.map((e=>e&&e.uid)).toArray()),t=t.filter((e=>null!=e)),t.length?(this._addHighlight(t),{remove:()=>{this._removeHighlight(t)}}):f}update(e){for(const i of this.graphicsViews())i.processUpdate(e)}attach(){const e=this.view,i=()=>this.requestUpdate(),s=this.layer.featureCollections;if(t(s)&&s.length){this._graphicsViewsFeatureCollectionMap=new Map;for(const t of s){const s=new n(this.view.featuresTilingScheme);s.fadeTransitionEnabled=!0;const r=new l({view:e,graphics:t.source,renderer:t.renderer,requestUpdateCallback:i,container:s});this._graphicsViewsFeatureCollectionMap.set(r,t),this.container.addChild(r.container),this.handles.add([h((()=>t.visible),(e=>r.container.visible=e),o),h((()=>r.updating),(()=>this.notifyChange("updating")),o)],u)}this._updateHighlight()}else t(this.layer.sublayers)&&this.handles.add(a((()=>this.layer.sublayers),"change",(()=>this._createGraphicsViews()),{onListenerAdd:()=>this._createGraphicsViews(),onListenerRemove:()=>this._destroyGraphicsViews()}),d)}detach(){this._destroyGraphicsViews(),this.handles.remove(d)}moveStart(){}moveEnd(){}viewChange(){for(const e of this.graphicsViews())e.viewChange()}isUpdating(){for(const e of this.graphicsViews())if(e.updating)return!0;return!1}_destroyGraphicsViews(){this.container.removeAllChildren(),this.handles.remove(u);for(const e of this.graphicsViews())e.destroy();this._graphicsViews=null,this._graphicsViewsFeatureCollectionMap=null}_createGraphicsViews(){if(this._destroyGraphicsViews(),r(this.layer.sublayers))return;const e=[],i=this.view,s=()=>this.requestUpdate();for(const t of this.layer.sublayers){const r=new n(this.view.featuresTilingScheme);r.fadeTransitionEnabled=!0;const a=new l({view:i,graphics:t.graphics,requestUpdateCallback:s,container:r});this.handles.add([t.on("graphic-update",a.graphicUpdateHandler),h((()=>t.visible),(e=>a.container.visible=e),o),h((()=>a.updating),(()=>this.notifyChange("updating")),o)],u),this.container.addChild(a.container),e.push(a)}this._graphicsViews=e,this._updateHighlight()}_addHighlight(e){for(const i of e)if(this._highlightIds.has(i)){const e=this._highlightIds.get(i);this._highlightIds.set(i,e+1)}else this._highlightIds.set(i,1);this._updateHighlight()}_removeHighlight(e){for(const i of e)if(this._highlightIds.has(i)){const e=this._highlightIds.get(i)-1;0===e?this._highlightIds.delete(i):this._highlightIds.set(i,e)}this._updateHighlight()}_updateHighlight(){const e=Array.from(this._highlightIds.keys());for(const i of this.graphicsViews())i.setHighlight(e)}};m=e([p("esri.views.2d.layers.MapNotesLayerView2D")],m);const w=m;export{w as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import i from"../../../Graphic.js";import s from"../../../core/Collection.js";import{isSome as t,isNone as r}from"../../../core/maybe.js";import{watch as h,on as a,initial as o}from"../../../core/reactiveUtils.js";import"../../../core/Logger.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/set.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{Container as p}from"../engine/Container.js";import{GroupContainer as c}from"../engine/webgl/GroupContainer.js";import{LayerView2DMixin as l}from"./LayerView2D.js";import g from"./graphics/GraphicContainer.js";import d from"./graphics/GraphicsView2D.js";import u from"../../layers/LayerView.js";const f="sublayers",m="layerView",w=Object.freeze({remove(){},pause(){},resume(){}});let y=class extends(l(u)){constructor(){super(...arguments),this._highlightIds=new Map,this.container=new c}async fetchPopupFeatures(e){return Array.from(this.graphicsViews(),(i=>i.hitTest(e).filter((e=>!!e.popupTemplate)))).flat()}*graphicsViews(){t(this._graphicsViewsFeatureCollectionMap)?yield*this._graphicsViewsFeatureCollectionMap.keys():t(this._graphicsViews)?yield*this._graphicsViews:yield*[]}async hitTest(e,i){return Array.from(this.graphicsViews(),(i=>{const s=i.hitTest(e);if(t(this._graphicsViewsFeatureCollectionMap)){const e=this._graphicsViewsFeatureCollectionMap.get(i);for(const i of s)!i.popupTemplate&&e.popupTemplate&&(i.popupTemplate=e.popupTemplate)}return s})).flat().map((i=>({type:"graphic",graphic:i,layer:this.layer,mapPoint:e})))}highlight(e){let t;return"number"==typeof e?t=[e]:e instanceof i?t=[e.uid]:Array.isArray(e)&&e.length>0?t="number"==typeof e[0]?e:e.map((e=>e&&e.uid)):s.isCollection(e)&&(t=e.map((e=>e&&e.uid)).toArray()),t=t.filter((e=>null!=e)),t.length?(this._addHighlight(t),{remove:()=>{this._removeHighlight(t)}}):w}update(e){for(const i of this.graphicsViews())i.processUpdate(e)}attach(){const e=this.view,i=()=>this.requestUpdate(),s=this.layer.featureCollections;if(t(s)&&s.length){this._graphicsViewsFeatureCollectionMap=new Map;for(const t of s){const s=new g(this.view.featuresTilingScheme);s.fadeTransitionEnabled=!0;const r=new d({view:e,graphics:t.source,renderer:t.renderer,requestUpdateCallback:i,container:s});this._graphicsViewsFeatureCollectionMap.set(r,t),this.container.addChild(r.container),this.handles.add([h((()=>t.visible),(e=>r.container.visible=e),o),h((()=>r.updating),(()=>this.notifyChange("updating")),o)],m)}this._updateHighlight()}else t(this.layer.sublayers)&&this.handles.add(a((()=>this.layer.sublayers),"change",(()=>this._createGraphicsViews()),{onListenerAdd:()=>this._createGraphicsViews(),onListenerRemove:()=>this._destroyGraphicsViews()}),f)}detach(){this._destroyGraphicsViews(),this.handles.remove(f)}moveStart(){}moveEnd(){}viewChange(){for(const e of this.graphicsViews())e.viewChange()}isUpdating(){for(const e of this.graphicsViews())if(e.updating)return!0;return!1}_destroyGraphicsViews(){this.container.removeAllChildren(),this.handles.remove(m);for(const e of this.graphicsViews())e.destroy();this._graphicsViews=null,this._graphicsViewsFeatureCollectionMap=null}_createGraphicsViews(){if(this._destroyGraphicsViews(),r(this.layer.sublayers))return;const e=[],i=this.view,s=()=>this.requestUpdate();for(const t of this.layer.sublayers){const r=new p,a=new g(this.view.featuresTilingScheme);a.fadeTransitionEnabled=!0;const n=new d({view:i,graphics:t.graphics,requestUpdateCallback:s,container:a});this.handles.add([t.on("graphic-update",n.graphicUpdateHandler),h((()=>t.visible),(e=>n.container.visible=e),o),h((()=>n.updating),(()=>this.notifyChange("updating")),o)],m),r.addChild(n.container),this.container.addChild(r),e.push(n)}this._graphicsViews=e,this._updateHighlight()}_addHighlight(e){for(const i of e)if(this._highlightIds.has(i)){const e=this._highlightIds.get(i);this._highlightIds.set(i,e+1)}else this._highlightIds.set(i,1);this._updateHighlight()}_removeHighlight(e){for(const i of e)if(this._highlightIds.has(i)){const e=this._highlightIds.get(i)-1;0===e?this._highlightIds.delete(i):this._highlightIds.set(i,e)}this._updateHighlight()}_updateHighlight(){const e=Array.from(this._highlightIds.keys());for(const i of this.graphicsViews())i.setHighlight(e)}};y=e([n("esri.views.2d.layers.MapNotesLayerView2D")],y);const _=y;export{_ 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import i from"../../../core/Collection.js";import s from"../../../core/Error.js";import r from"../../../core/Evented.js";import o from"../../../core/Handles.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,isNone as h,isSome as c,abortMaybe as p,get as l}from"../../../core/maybe.js";import{createTask as d}from"../../../core/promiseUtils.js";import{when as m,pausable as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as g,geometryToCoordinates as u,getMidpoint as x}from"../../../geometry/support/coordsUtils.js";import f from"../../../layers/GraphicsLayer.js";import G from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as b}from"../../ViewingMode.js";import{SnappingVisualizer2D as V}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as M}from"./drawUtils.js";import w from"./GraphicMover.js";import S from"./HighlightHelper.js";import{addUniqueLayer as k}from"./layerUtils.js";import{settings as E}from"./settings.js";import{ViewEventPriorities as I}from"../../input/InputManager.js";import{SKETCH_KEYS as O}from"../../interactive/keybindings.js";import{EditGeometryOperations as C}from"../../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as R}from"../../interactive/snapping/SnappingContext.js";import j from"../../../geometry/Polyline.js";import H from"../../../geometry/Point.js";class A{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class U{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class T{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class D{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class F{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class z{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class L{constructor(e){this.added=e,this.type="vertex-select"}}class P{constructor(e){this.removed=e,this.type="vertex-deselect"}}class K{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class N{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const q=E.reshapeGraphics,B={vertices:{default:new G({style:"circle",size:q.vertex.size,color:q.vertex.color,outline:{color:q.vertex.outlineColor,width:1}}),hover:new G({style:"circle",size:q.vertex.hoverSize,color:q.vertex.hoverColor,outline:{color:q.vertex.hoverOutlineColor,width:1}}),selected:new G({style:"circle",size:q.selected.size,color:q.selected.color,outline:{color:q.selected.outlineColor,width:1}})},midpoints:{default:new G({style:"circle",size:q.midpoint.size,color:q.midpoint.color,outline:{color:q.midpoint.outlineColor,width:1}}),hover:new G({style:"circle",size:q.midpoint.size,color:q.midpoint.color,outline:{color:q.midpoint.outlineColor,width:1}})}},J="esri.views.draw.support.Reshape",Q=n.getLogger(J);let W=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._handles=new o,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingTask=null,this._stagedVertex=null,this._viewHandles=new o,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new i,this.midpointSymbol=new G({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.type="reshape",this.vertexGraphics=new i,this.view=null}initialize(){this._highlightHelper=new S({view:this.view}),this._setup(),this._handles.add([m((()=>this.view?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this._viewHandles.add(t.on("key-down",(e=>this._keyDownHandler(e)),I.TOOL))}),{once:!0,initial:!0}),v((()=>this.graphic),(()=>this.refresh())),v((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),v((()=>this.enableMidpoints),(()=>this.refresh()))])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._handles=a(this._handles),this._viewHandles=a(this._viewHandles)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=!!this.get("view.ready"),t=!(!this.get("graphic")||!this.get("layer"));return e&&t?"active":e?"ready":"disabled"}set symbols(e){const{midpoints:t=B.midpoints,vertices:i=B.vertices}=e||{};this._set("symbols",{midpoints:t,vertices:i})}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||!e||h(e.geometry))return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&g(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(h(e)||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new j({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=C.fromGeometry(t,b.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new f({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new R({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,visualizer:new V(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper.removeAll(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){c(this.snappingManager)&&this.snappingManager.doneSnapping(),c(this._snappingGraphicsLayer)&&(this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=u(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(c(e)&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:r}}=this,o=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[h,c]=e;o.push(new t({geometry:new H({x:h,y:c,spatialReference:r}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:r}}=this,o=[];return e?.forEach(((e,n)=>{e.forEach(((a,h)=>{const[c,p]=a,d=e[h+1]?h+1:0;if("polygon"===l(this.graphic.geometry,"type")||0!==d){const[a,l]=e[d],[m,v]=x([c,p],[a,l]);o.push(new t({geometry:new H({x:m,y:v,spatialReference:r}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:h,pointIndexEnd:d}}))}}))})),o}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const r=t[i],o=t[e];r.x===o.x&&r.y===o.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:r}=this,o=s.concat(i).items;e&&o.push(t),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:o,view:r,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,r=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:r?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const t=e.graphic,{dx:i,dy:s}=e;if(t===this.graphic)return this._clearSelection(),this._resetGraphics(),this._setUpOperation(e),this._emitMoveStartEvent(i,s),void("point"===this._editGeometryOperations.data.type&&this._onHandleMove(t,i,s,e,(()=>this._emitMoveEvent(i,s))));if(!this.selectedVertices.includes(t)){if(this._clearSelection(),this._isMidpoint(t)){const e=this.graphic.clone(),i=this._createVertexFromMidpoint(t);this._emitVertexAddEvent([t],e,i)}this._addToSelection(t)}this._setUpOperation(e),this._emitReshapeStartEvent(t),this._onHandleMove(t,i,s,e,(()=>this._emitReshapeEvent(t)))}_onGraphicMoveCallback(e){const{graphic:t,dx:i,dy:s}=e;this._activeOperationInfo.totalDx+=i,this._activeOperationInfo.totalDy+=s;const{operationType:r}=this._activeOperationInfo;"move"===r?"point"===this._editGeometryOperations.data.type?this._onHandleMove(t,i,s,e,(()=>this._emitMoveEvent(i,s))):this._emitMoveEvent(i,s):this._onHandleMove(t,i,s,e,(()=>this._emitReshapeEvent(t)))}_onGraphicMoveStopCallback(e){const{graphic:t,dx:i,dy:s}=e;this._activeOperationInfo.totalDx+=i,this._activeOperationInfo.totalDy+=s,this._onHandleMove(t,i,s,e,(()=>t===this.graphic?this._emitMoveStopEvent():this._emitReshapeStopEvent(t))),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._isMidpoint(t)&&this.refresh()}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:r}=t.attributes,[o,n]=e[i][s],[a,h]=e[i][r],[c,p]=x([o,n],[a,h]);t.geometry=new H({x:c,y:p,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,i,s,r){if(p(this._snappingTask),!this._snappingContext)return;const o=e.geometry,n="graphic-move-stop"===s.type;if(c(this.snappingManager)&&this.selectedVertices.length<2&&!n){const s=this.snappingManager;this._stagedVertex=s.update(o,this._snappingContext),this._syncGeometryAfterVertexMove(e,new H(this._stagedVertex),t,i,n),r(),this._snappingTask=d((async a=>{const h=await s.snap(o,this._snappingContext,a);h.valid&&(this._stagedVertex=h.apply(),this._syncGeometryAfterVertexMove(e,new H(this._stagedVertex),t,i,n),r())}))}else{const s=c(this._stagedVertex)?new H(this._stagedVertex):o;this._syncGeometryAfterVertexMove(e,s,t,i,n),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,r=!1){const o=this._editGeometryOperations.data.geometry;if("point"===o.type)e.geometry=t;else{const{x:n,y:a}=t,[h,c]=this._getIndicesForVertexGraphic(e);let p=u(o);const l=p[h].length-1;p[h][c]=[n,a],"polygon"===o.type&&(0===c?p[h][l]=[n,a]:c===l&&(p[h][0]=[n,a])),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,n,a),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===o.type),this._updateMidpointGraphicLocations(p)),this.graphic.geometry=o.clone();const d=this._getVertexFromEditGeometry(e),m=n-d.pos[0],v=a-d.pos[1];this._editGeometryOperations.moveVertices([d],m,v,0),r&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i,s){const{relatedGraphicIndices:r}=t.attributes;for(const o of r){const r=this.vertexGraphics.getItemAt(o),{pathIndex:n,pointIndex:a}=r.attributes;e[n][a]=[i,s],r.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,r){for(const o of this.selectedVertices)if(o!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=o.attributes,h=M(o.geometry,i,s,this.view),c=e[t].length-1;e[t][n]=[h.x,h.y],o.geometry=h,r&&(0===n?e[t][c]=[h.x,h.y]:n===c&&(e[t][0]=[h.x,h.y]));for(const i of a){const t=this.vertexGraphics.getItemAt(i),{pathIndex:s,pointIndex:r}=t.attributes;e[s][r]=[h.x,h.y],t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default"}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(h(s)||"polygon"!==s.type&&"polyline"!==s.type)return[];const r=s.clone(),o=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:c}=e.attributes,{x:p,y:l}=e.geometry,d=0===c?a+1:c,m=u(r);return m[n].splice(d,0,[p,l]),e.attributes={...t,pathIndex:n,pointIndex:d,relatedGraphicIndices:[]},o.push({coordinates:m[n][d],componentIndex:n,vertexIndex:d}),this.graphic.geometry=r,o}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,r=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",r);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){O.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(h(i)||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),r=i.clone();let o=u(r);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<o.length;t++){const s=o[t];for(let r=0;r<s.length;r++){const[a,h]=s[r];e===a&&i===h&&(n.push({coordinates:o[t][r],componentIndex:t,vertexIndex:r}),o[t].splice(Number(r),1))}}}if("polygon"===r.type)o=o.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,r]=e[e.length-1];return(2!==e.length||t!==s||i!==r)&&(t===s&&i===r||e.push(e[0]),!0)})),r.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);r.paths=o}this.graphic.geometry=r,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_emitMoveStartEvent(e,t){const i=new D(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new F(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const{totalDx:e,totalDy:t}=this._activeOperationInfo,i=new z(this.graphic,e,t);this.emit("move-stop",i),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(i)}_emitReshapeStartEvent(e){const t=new A(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new U(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new T(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new L(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new P(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new K(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new N(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){Q.error(new s("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([y()],W.prototype,"callbacks",void 0),e([y()],W.prototype,"enableMidpoints",void 0),e([y()],W.prototype,"enableMovement",void 0),e([y()],W.prototype,"enableVertices",void 0),e([y()],W.prototype,"graphic",void 0),e([y({value:!0})],W.prototype,"highlightsEnabled",null),e([y()],W.prototype,"layer",void 0),e([y({readOnly:!0})],W.prototype,"midpointGraphics",void 0),e([y()],W.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],W.prototype,"selectedVertices",void 0),e([y()],W.prototype,"snappingManager",void 0),e([y({readOnly:!0})],W.prototype,"state",null),e([y({value:B})],W.prototype,"symbols",null),e([y({readOnly:!0})],W.prototype,"type",void 0),e([y({readOnly:!0})],W.prototype,"vertexGraphics",void 0),e([y()],W.prototype,"view",void 0),W=e([_(J)],W);const X=W;export{X as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import i from"../../../core/Collection.js";import s from"../../../core/Error.js";import r from"../../../core/Evented.js";import o from"../../../core/Handles.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,isNone as h,isSome as c,abortMaybe as p,get as l}from"../../../core/maybe.js";import{createTask as d}from"../../../core/promiseUtils.js";import{when as m,pausable as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as g,geometryToCoordinates as u,getMidpoint as x}from"../../../geometry/support/coordsUtils.js";import f from"../../../layers/GraphicsLayer.js";import G from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as b}from"../../ViewingMode.js";import{SnappingVisualizer2D as V}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as M}from"./drawUtils.js";import w from"./GraphicMover.js";import S from"./HighlightHelper.js";import{addUniqueLayer as k}from"./layerUtils.js";import{settings as E}from"./settings.js";import{ViewEventPriorities as I}from"../../input/InputManager.js";import{SKETCH_KEYS as O}from"../../interactive/keybindings.js";import{EditGeometryOperations as C}from"../../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as R}from"../../interactive/snapping/SnappingContext.js";import j from"../../../geometry/Polyline.js";import H from"../../../geometry/Point.js";class A{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class U{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class T{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class D{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class F{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class z{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class L{constructor(e){this.added=e,this.type="vertex-select"}}class P{constructor(e){this.removed=e,this.type="vertex-deselect"}}class K{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class N{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const q=E.reshapeGraphics,B={vertices:{default:new G({style:"circle",size:q.vertex.size,color:q.vertex.color,outline:{color:q.vertex.outlineColor,width:1}}),hover:new G({style:"circle",size:q.vertex.hoverSize,color:q.vertex.hoverColor,outline:{color:q.vertex.hoverOutlineColor,width:1}}),selected:new G({style:"circle",size:q.selected.size,color:q.selected.color,outline:{color:q.selected.outlineColor,width:1}})},midpoints:{default:new G({style:"circle",size:q.midpoint.size,color:q.midpoint.color,outline:{color:q.midpoint.outlineColor,width:1}}),hover:new G({style:"circle",size:q.midpoint.size,color:q.midpoint.color,outline:{color:q.midpoint.outlineColor,width:1}})}},J="esri.views.draw.support.Reshape",Q=n.getLogger(J);let W=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._handles=new o,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingTask=null,this._stagedVertex=null,this._viewHandles=new o,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new i,this.midpointSymbol=new G({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.type="reshape",this.vertexGraphics=new i,this.view=null}initialize(){this._highlightHelper=new S({view:this.view}),this._setup(),this._handles.add([m((()=>this.view?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this._viewHandles.add(t.on("key-down",(e=>this._keyDownHandler(e)),I.TOOL))}),{once:!0,initial:!0}),v((()=>this.graphic),(()=>this.refresh())),v((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),v((()=>this.enableMidpoints),(()=>this.refresh()))])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._handles=a(this._handles),this._viewHandles=a(this._viewHandles)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=!!this.get("view.ready"),t=!(!this.get("graphic")||!this.get("layer"));return e&&t?"active":e?"ready":"disabled"}set symbols(e){const{midpoints:t=B.midpoints,vertices:i=B.vertices}=e||{};this._set("symbols",{midpoints:t,vertices:i})}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||!e||h(e.geometry))return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&g(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(h(e)||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new j({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=C.fromGeometry(t,b.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new f({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new R({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,visualizer:new V(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper.removeAll(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){c(this.snappingManager)&&this.snappingManager.doneSnapping(),c(this._snappingGraphicsLayer)&&(this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=u(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(c(e)&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:r}}=this,o=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[h,c]=e;o.push(new t({geometry:new H({x:h,y:c,spatialReference:r}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:r}}=this,o=[];return e?.forEach(((e,n)=>{e.forEach(((a,h)=>{const[c,p]=a,d=e[h+1]?h+1:0;if("polygon"===l(this.graphic.geometry,"type")||0!==d){const[a,l]=e[d],[m,v]=x([c,p],[a,l]);o.push(new t({geometry:new H({x:m,y:v,spatialReference:r}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:h,pointIndexEnd:d}}))}}))})),o}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const r=t[i],o=t[e];r.x===o.x&&r.y===o.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:r}=this,o=s.concat(i).items;e&&o.push(t),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:o,view:r,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,r=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:r?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const t=e.graphic,{dx:i,dy:s}=e;if(t===this.graphic)return this._clearSelection(),this._resetGraphics(),this._setUpOperation(e),this._emitMoveStartEvent(i,s),void("point"===this._editGeometryOperations.data.type&&this._onHandleMove(t,i,s,e,(()=>this._emitMoveEvent(i,s))));if(!this.selectedVertices.includes(t)){if(this._clearSelection(),this._isMidpoint(t)){const e=this.graphic.clone(),i=this._createVertexFromMidpoint(t);this._emitVertexAddEvent([t],e,i)}this._addToSelection(t)}this._setUpOperation(e),this._emitReshapeStartEvent(t),this._onHandleMove(t,i,s,e,(()=>this._emitReshapeEvent(t)))}_onGraphicMoveCallback(e){const{graphic:t,dx:i,dy:s}=e;this._activeOperationInfo.totalDx+=i,this._activeOperationInfo.totalDy+=s;const{operationType:r}=this._activeOperationInfo;"move"===r?"point"===this._editGeometryOperations.data.type?this._onHandleMove(t,i,s,e,(()=>this._emitMoveEvent(i,s))):this._emitMoveEvent(i,s):this._onHandleMove(t,i,s,e,(()=>this._emitReshapeEvent(t)))}_onGraphicMoveStopCallback(e){const{graphic:t,dx:i,dy:s}=e,r=t===this.graphic,o="point"!==this._editGeometryOperations.data.type;this._activeOperationInfo.totalDx+=i,this._activeOperationInfo.totalDy+=s,this._onHandleMove(t,i,s,e,(()=>r?this._emitMoveStopEvent():this._emitReshapeStopEvent(t))),r&&o||this._isMidpoint(t)?this.refresh():(this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:r}=t.attributes,[o,n]=e[i][s],[a,h]=e[i][r],[c,p]=x([o,n],[a,h]);t.geometry=new H({x:c,y:p,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,i,s,r){if(p(this._snappingTask),!this._snappingContext)return;const o=e.geometry,n="graphic-move-stop"===s.type;if(c(this.snappingManager)&&this.selectedVertices.length<2&&!n){const s=this.snappingManager;this._stagedVertex=s.update(o,this._snappingContext),this._syncGeometryAfterVertexMove(e,new H(this._stagedVertex),t,i,n),r(),this._snappingTask=d((async a=>{const h=await s.snap(o,this._snappingContext,a);h.valid&&(this._stagedVertex=h.apply(),this._syncGeometryAfterVertexMove(e,new H(this._stagedVertex),t,i,n),r())}))}else{const s=c(this._stagedVertex)?new H(this._stagedVertex):o;this._syncGeometryAfterVertexMove(e,s,t,i,n),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,r=!1){const o=this._editGeometryOperations.data.geometry;if("point"===o.type)e.geometry=t;else{const{x:n,y:a}=t,[h,c]=this._getIndicesForVertexGraphic(e);let p=u(o);const l=p[h].length-1;p[h][c]=[n,a],"polygon"===o.type&&(0===c?p[h][l]=[n,a]:c===l&&(p[h][0]=[n,a])),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,n,a),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===o.type),this._updateMidpointGraphicLocations(p)),this.graphic.geometry=o.clone();const d=this._getVertexFromEditGeometry(e),m=n-d.pos[0],v=a-d.pos[1];this._editGeometryOperations.moveVertices([d],m,v,0),r&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i,s){const{relatedGraphicIndices:r}=t.attributes;for(const o of r){const r=this.vertexGraphics.getItemAt(o),{pathIndex:n,pointIndex:a}=r.attributes;e[n][a]=[i,s],r.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,r){for(const o of this.selectedVertices)if(o!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=o.attributes,h=M(o.geometry,i,s,this.view),c=e[t].length-1;e[t][n]=[h.x,h.y],o.geometry=h,r&&(0===n?e[t][c]=[h.x,h.y]:n===c&&(e[t][0]=[h.x,h.y]));for(const i of a){const t=this.vertexGraphics.getItemAt(i),{pathIndex:s,pointIndex:r}=t.attributes;e[s][r]=[h.x,h.y],t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default"}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(h(s)||"polygon"!==s.type&&"polyline"!==s.type)return[];const r=s.clone(),o=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:c}=e.attributes,{x:p,y:l}=e.geometry,d=0===c?a+1:c,m=u(r);return m[n].splice(d,0,[p,l]),e.attributes={...t,pathIndex:n,pointIndex:d,relatedGraphicIndices:[]},o.push({coordinates:m[n][d],componentIndex:n,vertexIndex:d}),this.graphic.geometry=r,o}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,r=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",r);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){O.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(h(i)||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),r=i.clone();let o=u(r);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<o.length;t++){const s=o[t];for(let r=0;r<s.length;r++){const[a,h]=s[r];e===a&&i===h&&(n.push({coordinates:o[t][r],componentIndex:t,vertexIndex:r}),o[t].splice(Number(r),1))}}}if("polygon"===r.type)o=o.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,r]=e[e.length-1];return(2!==e.length||t!==s||i!==r)&&(t===s&&i===r||e.push(e[0]),!0)})),r.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);r.paths=o}this.graphic.geometry=r,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_emitMoveStartEvent(e,t){const i=new D(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new F(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const{totalDx:e,totalDy:t}=this._activeOperationInfo,i=new z(this.graphic,e,t);this.emit("move-stop",i),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(i)}_emitReshapeStartEvent(e){const t=new A(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new U(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new T(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new L(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new P(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new K(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new N(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){Q.error(new s("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([y()],W.prototype,"callbacks",void 0),e([y()],W.prototype,"enableMidpoints",void 0),e([y()],W.prototype,"enableMovement",void 0),e([y()],W.prototype,"enableVertices",void 0),e([y()],W.prototype,"graphic",void 0),e([y({value:!0})],W.prototype,"highlightsEnabled",null),e([y()],W.prototype,"layer",void 0),e([y({readOnly:!0})],W.prototype,"midpointGraphics",void 0),e([y()],W.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],W.prototype,"selectedVertices",void 0),e([y()],W.prototype,"snappingManager",void 0),e([y({readOnly:!0})],W.prototype,"state",null),e([y({value:B})],W.prototype,"symbols",null),e([y({readOnly:!0})],W.prototype,"type",void 0),e([y({readOnly:!0})],W.prototype,"vertexGraphics",void 0),e([y()],W.prototype,"view",void 0),W=e([_(J)],W);const X=W;export{X 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as i}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{HandleOwnerMixin as t}from"../../core/HandleOwner.js";import{isSome as s,isNone as r,unwrap as o}from"../../core/maybe.js";import{watch as n,syncAndInitial as l,initial as p}from"../../core/reactiveUtils.js";import{aliasOf as a}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";const d=["visibility"];let h=class extends(t(e)){constructor(i){super(i),this._expressionTrackingHandles=new Map,this.arcade=null,this.visibilityExpression=null,this.description=null,this.expressionTrackingProvider=null,this.feature=null,this.groupElement=null,this.label=null,this.spatialReference=null}initialize(){this.own([...d.map((i=>n((()=>this.get(`${i}Function`)),(e=>{s(e)?this._registerExpressionWithTrackingProvider(i):this._unregisterExpressionWithTrackingProvider(i)}),l))),n((()=>this.visible),(i=>{const{inputFields:e}=this;if(!e||e.length<1)return;const t=!!i&&void 0;for(const s of e)s.required=t}),p)])}destroy(){for(const i of this._expressionTrackingHandles.values())i.remove()}set visibilityFunction(i){this._set("visibilityFunction",i),s(i)?this._registerExpressionWithTrackingProvider("visibility"):this._unregisterExpressionWithTrackingProvider("visibility")}get evaluatedVisibilityExpression(){const{visibilityFunction:i,spatialReference:e}=this;if(r(i))return;const{arcade:t}=this,s=t.arcadeUtils.getViewInfo({spatialReference:o(e)});return t.arcadeUtils.executeFunction(i,t.arcadeUtils.createExecContext(this.feature,s))}get inputFields(){return this._get("inputFields")}set inputFields(i){this.handles.removeAll(),i&&this.handles.add(i.map((i=>n((()=>i.visible),(()=>this._dirtyEvaluatedVisibilityExpression()))))),this._set("inputFields",i)}get state(){return s(this.groupElement)&&this.groupElement.initialState||"expanded"}set state(i){r(i)?this._clearOverride("state"):this._override("state",i)}get visible(){return!1!==this.evaluatedVisibilityExpression&&this.inputFields&&this.inputFields.some((i=>i.visible))}_registerExpressionWithTrackingProvider(i){const{_expressionTrackingHandles:e,expressionTrackingProvider:t}=this;if(r(t)||e.has(i))return;const s=`evaluated${v(i)}Expression`,o=t.registerExpression((()=>this.notifyChange(s)));e.set(i,o)}_unregisterExpressionWithTrackingProvider(i){const{_expressionTrackingHandles:e}=this,t=e.get(i);t&&(t.remove(),e.delete(i))}_dirtyEvaluatedVisibilityExpression(){const{groupElement:i}=this;s(i)&&i.visibilityExpression&&this.notifyChange("evaluatedVisibilityExpression")}};i([c()],h.prototype,"arcade",void 0),i([a("groupElement.visibilityExpression")],h.prototype,"visibilityExpression",void 0),i([c()],h.prototype,"visibilityFunction",null),i([c()],h.prototype,"evaluatedVisibilityExpression",null),i([a("groupElement.description")],h.prototype,"description",void 0),i([c()],h.prototype,"expressionTrackingProvider",void 0),i([c()],h.prototype,"feature",void 0),i([c()],h.prototype,"groupElement",void 0),i([c()],h.prototype,"inputFields",null),i([a("groupElement.label")],h.prototype,"label",void 0),i([c()],h.prototype,"spatialReference",void 0),i([c()],h.prototype,"state",null),i([c()],h.prototype,"visible",null),h=i([u("esri.widgets.FeatureForm.InputFieldGroup")],h);const v=i=>i.charAt(0).toUpperCase()+i.slice(1),g=h;export{g as default};
5
+ import{_ as i}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{HandleOwnerMixin as t}from"../../core/HandleOwner.js";import{isSome as s,isNone as r,unwrap as o}from"../../core/maybe.js";import{watch as n,syncAndInitial as l}from"../../core/reactiveUtils.js";import{aliasOf as p}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";const u=["visibility"];let d=class extends(t(e)){constructor(i){super(i),this._expressionTrackingHandles=new Map,this.arcade=null,this.visibilityExpression=null,this.description=null,this.expressionTrackingProvider=null,this.feature=null,this.groupElement=null,this.label=null,this.spatialReference=null}initialize(){this.own([...u.map((i=>n((()=>this.get(`${i}Function`)),(e=>{s(e)?this._registerExpressionWithTrackingProvider(i):this._unregisterExpressionWithTrackingProvider(i)}),l))),n((()=>[this.visible,this.inputFields]),(([i])=>{const{inputFields:e}=this,t=!!i&&void 0;for(const s of e)s.required=t}),{initial:!0,equals:(i,e)=>e[0]===i[0]&&e[1]===i[1]})])}destroy(){for(const i of this._expressionTrackingHandles.values())i.remove()}set visibilityFunction(i){this._set("visibilityFunction",i),s(i)?this._registerExpressionWithTrackingProvider("visibility"):this._unregisterExpressionWithTrackingProvider("visibility")}get evaluatedVisibilityExpression(){const{visibilityFunction:i,spatialReference:e}=this;if(r(i))return;const{arcade:t}=this,s=t.arcadeUtils.getViewInfo({spatialReference:o(e)});return t.arcadeUtils.executeFunction(i,t.arcadeUtils.createExecContext(this.feature,s))}get inputFields(){return this._get("inputFields")}set inputFields(i){this.handles.removeAll(),i&&this.handles.add(i.map((i=>n((()=>i.visible),(()=>this._dirtyEvaluatedVisibilityExpression()))))),this._set("inputFields",i)}get state(){return s(this.groupElement)&&this.groupElement.initialState||"expanded"}set state(i){r(i)?this._clearOverride("state"):this._override("state",i)}get visible(){return!1!==this.evaluatedVisibilityExpression&&this.inputFields&&this.inputFields.some((i=>i.visible))}_registerExpressionWithTrackingProvider(i){const{_expressionTrackingHandles:e,expressionTrackingProvider:t}=this;if(r(t)||e.has(i))return;const s=`evaluated${h(i)}Expression`,o=t.registerExpression((()=>this.notifyChange(s)));e.set(i,o)}_unregisterExpressionWithTrackingProvider(i){const{_expressionTrackingHandles:e}=this,t=e.get(i);t&&(t.remove(),e.delete(i))}_dirtyEvaluatedVisibilityExpression(){const{groupElement:i}=this;s(i)&&i.visibilityExpression&&this.notifyChange("evaluatedVisibilityExpression")}};i([a()],d.prototype,"arcade",void 0),i([p("groupElement.visibilityExpression")],d.prototype,"visibilityExpression",void 0),i([a()],d.prototype,"visibilityFunction",null),i([a()],d.prototype,"evaluatedVisibilityExpression",null),i([p("groupElement.description")],d.prototype,"description",void 0),i([a()],d.prototype,"expressionTrackingProvider",void 0),i([a()],d.prototype,"feature",void 0),i([a()],d.prototype,"groupElement",void 0),i([a()],d.prototype,"inputFields",null),i([p("groupElement.label")],d.prototype,"label",void 0),i([a()],d.prototype,"spatialReference",void 0),i([a()],d.prototype,"state",null),i([a()],d.prototype,"visible",null),d=i([c("esri.widgets.FeatureForm.InputFieldGroup")],d);const h=i=>i.charAt(0).toUpperCase()+i.slice(1),v=d;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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import s from"../../core/Error.js";import r from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import l from"../../core/Logger.js";import{isSome as a}from"../../core/maybe.js";import{when as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/Point.js";import{getObjectIdsFromElements as p,getFeaturesFromLayers as u}from"../../networks/support/utils.js";import{trace as g}from"../../rest/networks/trace.js";import d from"../../rest/networks/support/TraceLocation.js";import m from"../../rest/networks/support/TraceParameters.js";import{GeometryHandler as y}from"./support/GeometryHandler.js";import{GraphicHandler as f}from"./support/GraphicHandler.js";const _="esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel",w=l.getLogger(_);let b=class extends(i(r.EventedAccessor)){constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._geometryHandler=null,this._graphicHandler=null,this._highlightHandler=[],this._traces=[],this._traceResults=[],this._unObject=null,this._watchHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.flags=[],this.gdbVersion="sde.DEFAULT",this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0}initialize(){this._geometryHandler=new y,this._graphicHandler=new f}destroy(){this.view=null}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&w.error(new s("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e)}addFlagByHit(e,t){return new Promise(((s,r)=>{this.view.popup.autoOpenEnabled=!1,this._clickHandler&&this._clickHandler.remove(),this.emit("add-flag",{type:e}),this._clickHandler=this.view.on("click",(i=>{this.queryFlagByHitTest(i,e,t).then((r=>{this.view.popup.autoOpenEnabled=!0,this._clickHandler.remove(),this.emit("add-flag-complete",{type:e,symbol:t}),s(r)})).catch((s=>{this.view.popup.autoOpenEnabled=!0,this._clickHandler.remove(),this.emit("add-flag-error",{type:e,symbol:t}),r(s)}))}))}))}async addFlagsOnLoad(){return new Promise((e=>{const t=[];this._watchHandler=o((()=>!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})}))}async addResultGraphicToView(e,t){for(const s in e.results.aggregatedGeometry)if("line,multipoint,polygon".includes(s)&&null!==e.results.aggregatedGeometry[s]){e.results.aggregatedGeometry[s].spatialReference=this._unObject.spatialReference,e.graphicEnabled=!0;const r=await this._geometryHandler.projectGeometry(e.results.aggregatedGeometry[s],this.view.spatialReference),i={globalid:e.trace.globalId};if(null!==r){const e=this._graphicHandler.makeGraphic(r,t.color,i,this.view.spatialReference);this.view.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 m({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._unObject.networkServiceUrl,r).then((e=>{if(e.hasOwnProperty("results")){const s={...e};if(null!==s.results){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))}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)}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.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]};let t=[];return this._flags.some((e=>"starting-point"===e.type))?(t=this._traces.filter((e=>e.selected)),t.length<=0&&(e.status=!1,e.issues=["noTrace"])):(t=this._traces.filter((e=>!0===e.selected)),t.length>0?(e.status=!1,e.issues=["noStart"]):(e.status=!1,e.issues=["noStart","noTrace"])),e}checkSelectionExist(){let e=!1;return this._highlightHandler.some((t=>{t&&(e=!0)})),e}clearResult(e){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]),t=t.filter((t=>t.trace.globalId!==e.globalId))}this._traceResults=t,0===t.length?(this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}executeTrace(e,t,s){const r=this._processFlags(s.traceLocations);return s.traceLocations=r,g(t,s).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success"}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message})))}getValidSources(){let e=[];const t=this._unObject.dataElement.domainNetworks;for(const s of t)e=e.concat(s.junctionSources),e=e.concat(s.edgeSources);return e}async loadUtilityNetwork(){await this.view.when();const e=this.view.map;if(e.utilityNetworks?.length){const s=e.utilityNetworks.getItemAt(0);await s.load(),this._unObject=s;try{await e.loadAll(),this._populateOutfields()}catch(t){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.elements&&(s=s.concat(t.results.elements))})),this.selectResults([...new Set(s)])}async queryFeaturesById(e){const s=p(this._unObject,e),r=this._getUniqueMapLayerViews(this.view),i={layerUrl:s[0].layerUrl,objectIds:s[0].objectIds,outFields:["*"]},l=r.filter((e=>e.layer.parsedUrl.path===s[0].layerUrl));if(l.length>0){const e=(await Promise.all(l.map((async e=>{const s=new t,r=e.layer;s.add(r);const l={layers:s,layerInfos:[i],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return(await u(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=>{if(e.length>0){const r=[...this._flags],i=s;return e.forEach((e=>{const s=e.graphic,l=s.attributes.hasOwnProperty("GLOBALID")?s.attributes.GLOBALID:s.attributes.globalid;if(r.filter((e=>e.globalId===l)).length<=0){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,i);this.view.graphics.add(e),r.push({...s,type:t,globalId:s.attributes.globalid?s.attributes.globalid:s.attributes.GLOBALID,details:s,mapGraphic:e,id:r.length+1})}else if(null!==s.percentAlong){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,i);this.view.graphics.add(e),r.push({...s,type:t,globalId:s.attributes.globalid?s.attributes.globalid:s.attributes.GLOBALID,details:s,mapGraphic:e,id:r.length+1})}})),this._flags=r,!0}return!1}))}removeResultGraphicFromView(e){const t=this.view.graphics;e.graphicEnabled=!1;t.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId)).forEach((e=>{this.view.graphics.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}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.removeSelection(),this.emit("clear-selection",{resultSet:[]}))}selectFeaturesById(e){const t=p(this._unObject,e);this._getUniqueMapLayerViews(this.view).forEach((e=>{e.layer.parsedUrl.path===t[0].layerUrl&&this._highlightHandler.push(e.highlight(t[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._unObject.hasOwnProperty("sharedNamedTraceConfigurations")&&(this._traces=[...this._unObject.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((e=>"feature"===e.layer.type||"group"===e.layer.type)).forEach((e=>{"group"===e.type?e.layerViews.forEach((e=>{t.push(e)})):t.some((t=>t.layer.layerId===e.layer.layerId))||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 d({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:s,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}));else{const s=new d({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:null,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}})),t}_getDisplayField(e){const t=e.layer;let s=t.displayField,r="";for(const i in e.attributes){const l=i.toLowerCase();if(l===s.toLowerCase())if(r=e.attributes[i],"assetgroup"===l||"assettype"===l){let i=e.attributes[t.typeIdField.toUpperCase()];i||(i=e.attributes[t.typeIdField.toLowerCase()]),s=t.typeIdField,r=this._checkSubtype(t,i)}else r=this._checkDomain(t.fields,i,r)}return{field:s,value:r}}_checkSubtype(e,t){let s=t;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&&null!==i[0].domain){const e=i[0].domain.codedValues.filter((e=>e.code===s));e.length>0&&(r=e[0].name)}return r}_groupBy(e,t){return e.reduce(((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e)),{})}_groupResultsByNetworkSource(e){if(e.length>0){if(e[0].hasOwnProperty("results")){const t=e[0].results.elements;return this._groupBy(t,"networkSourceId")}return this._groupBy(e,"networkSourceId")}if(e.hasOwnProperty("results")){const t=e.results.elements;return this._groupBy(t,"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&&a(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._unObject){const e=this._unObject.getTerminalConfiguration(r.graphic),t=this._getDisplayField(r.graphic);r.graphic.terminalId=e?e.terminals[0].id?e.terminals[0].id:null:1,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=e||null,r.graphic.selectedTerminals=[e?e.terminals[0].id?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()],b.prototype,"_activeProgress",void 0),e([n()],b.prototype,"_flags",void 0),e([n()],b.prototype,"_traces",void 0),e([n()],b.prototype,"_traceResults",void 0),e([n()],b.prototype,"defaultGraphicColor",void 0),e([n()],b.prototype,"flags",void 0),e([n()],b.prototype,"gdbVersion",void 0),e([n()],b.prototype,"selectedTraces",void 0),e([n()],b.prototype,"selectOnComplete",void 0),e([n()],b.prototype,"showGraphicsOnComplete",void 0),e([n()],b.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],b.prototype,"state",null),e([n({value:null})],b.prototype,"view",null),b=e([c(_)],b);const v=b;export{v as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import s from"../../core/Error.js";import r from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import l from"../../core/Logger.js";import{isSome as a}from"../../core/maybe.js";import{when as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/Point.js";import{getObjectIdsFromElements as p,getFeaturesFromLayers as u}from"../../networks/support/utils.js";import{trace as g}from"../../rest/networks/trace.js";import d from"../../rest/networks/support/TraceLocation.js";import m from"../../rest/networks/support/TraceParameters.js";import{GeometryHandler as y}from"./support/GeometryHandler.js";import{GraphicHandler as f}from"./support/GraphicHandler.js";const _="esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel",w=l.getLogger(_);let b=class extends(i(r.EventedAccessor)){constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._geometryHandler=null,this._graphicHandler=null,this._highlightHandler=[],this._traces=[],this._traceResults=[],this._unObject=null,this._watchHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.flags=[],this.gdbVersion="sde.DEFAULT",this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0}initialize(){this._geometryHandler=new y,this._graphicHandler=new f}destroy(){this.view=null}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&w.error(new s("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e)}addFlagByHit(e,t){return new Promise(((s,r)=>{this.view.popup.autoOpenEnabled=!1,this._clickHandler&&this._clickHandler.remove(),this.emit("add-flag",{type:e}),this._clickHandler=this.view.on("click",(i=>{this.queryFlagByHitTest(i,e,t).then((r=>{this.view.popup.autoOpenEnabled=!0,this._clickHandler.remove(),this.emit("add-flag-complete",{type:e,symbol:t}),s(r)})).catch((s=>{this.view.popup.autoOpenEnabled=!0,this._clickHandler.remove(),this.emit("add-flag-error",{type:e,symbol:t}),r(s)}))}))}))}async addFlagsOnLoad(){return new Promise((e=>{const t=[];this._watchHandler=o((()=>!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})}))}async addResultGraphicToView(e,t){for(const s in e.results.aggregatedGeometry)if("line,multipoint,polygon".includes(s)&&null!==e.results.aggregatedGeometry[s]){e.results.aggregatedGeometry[s].spatialReference=this._unObject.spatialReference,e.graphicEnabled=!0;const r=await this._geometryHandler.projectGeometry(e.results.aggregatedGeometry[s],this.view.spatialReference),i={globalid:e.trace.globalId};if(null!==r){const e=this._graphicHandler.makeGraphic(r,t.color,i,this.view.spatialReference);this.view.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 m({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._unObject.networkServiceUrl,r).then((e=>{if(e.hasOwnProperty("results")){const s={...e};if(null!==s.results){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))}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)}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.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]};let t=[];return this._flags.some((e=>"starting-point"===e.type))?(t=this._traces.filter((e=>e.selected)),t.length<=0&&(e.status=!1,e.issues=["noTrace"])):(t=this._traces.filter((e=>!0===e.selected)),t.length>0?(e.status=!1,e.issues=["noStart"]):(e.status=!1,e.issues=["noStart","noTrace"])),e}checkSelectionExist(){let e=!1;return this._highlightHandler.some((t=>{t&&(e=!0)})),e}clearResult(e){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]),t=t.filter((t=>t.trace.globalId!==e.globalId))}this._traceResults=t,0===t.length?(this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}executeTrace(e,t,s){const r=this._processFlags(s.traceLocations);return s.traceLocations=r,g(t,s).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success"}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message})))}getValidSources(){let e=[];const t=this._unObject.dataElement.domainNetworks;for(const s of t)e=e.concat(s.junctionSources),e=e.concat(s.edgeSources);return e}async loadUtilityNetwork(){await this.view.when();const e=this.view.map;if(e.utilityNetworks?.length){const s=e.utilityNetworks.getItemAt(0);await s.load(),this._unObject=s;try{await e.loadAll(),this._populateOutfields()}catch(t){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.elements&&(s=s.concat(t.results.elements))})),this.selectResults([...new Set(s)])}async queryFeaturesById(e){const s=p(this._unObject,e),r=this._getUniqueMapLayerViews(this.view),i={layerUrl:s[0].layerUrl,objectIds:s[0].objectIds,outFields:["*"]},l=r.filter((e=>e.layer?.parsedUrl?.path===s[0].layerUrl));if(l.length>0){const e=(await Promise.all(l.map((async e=>{const s=new t,r=e.layer;s.add(r);const l={layers:s,layerInfos:[i],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return(await u(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=>{if(e.length>0){const r=[...this._flags],i=s;return e.forEach((e=>{const s=e.graphic,l=s.attributes.hasOwnProperty("GLOBALID")?s.attributes.GLOBALID:s.attributes.globalid;if(r.filter((e=>e.globalId===l)).length<=0){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,i);this.view.graphics.add(e),r.push({...s,type:t,globalId:s.attributes.globalid?s.attributes.globalid:s.attributes.GLOBALID,details:s,mapGraphic:e,id:r.length+1})}else if(null!==s.percentAlong){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,i);this.view.graphics.add(e),r.push({...s,type:t,globalId:s.attributes.globalid?s.attributes.globalid:s.attributes.GLOBALID,details:s,mapGraphic:e,id:r.length+1})}})),this._flags=r,!0}return!1}))}removeResultGraphicFromView(e){const t=this.view.graphics;e.graphicEnabled=!1;t.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId)).forEach((e=>{this.view.graphics.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}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.removeSelection(),this.emit("clear-selection",{resultSet:[]}))}selectFeaturesById(e){const t=p(this._unObject,e);this._getUniqueMapLayerViews(this.view).forEach((e=>{e.layer?.parsedUrl?.path===t[0].layerUrl&&this._highlightHandler.push(e.highlight(t[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._unObject.hasOwnProperty("sharedNamedTraceConfigurations")&&(this._traces=[...this._unObject.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((e=>"feature"===e.layer.type||"group"===e.layer.type)).forEach((e=>{"group"===e.type?e.layerViews.forEach((e=>{t.push(e)})):t.some((t=>t.layer.layerId===e.layer.layerId))||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 d({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:s,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}));else{const s=new d({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:null,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}})),t}_getDisplayField(e){const t=e.layer;let s=t.displayField,r="";for(const i in e.attributes){const l=i.toLowerCase();if(l===s.toLowerCase())if(r=e.attributes[i],"assetgroup"===l||"assettype"===l){let i=e.attributes[t.typeIdField.toUpperCase()];i||(i=e.attributes[t.typeIdField.toLowerCase()]),s=t.typeIdField,r=this._checkSubtype(t,i)}else r=this._checkDomain(t.fields,i,r)}return{field:s,value:r}}_checkSubtype(e,t){let s=t;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&&null!==i[0].domain){const e=i[0].domain.codedValues.filter((e=>e.code===s));e.length>0&&(r=e[0].name)}return r}_groupBy(e,t){return e.reduce(((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e)),{})}_groupResultsByNetworkSource(e){if(e.length>0){if(e[0].hasOwnProperty("results")){const t=e[0].results.elements;return this._groupBy(t,"networkSourceId")}return this._groupBy(e,"networkSourceId")}if(e.hasOwnProperty("results")){const t=e.results.elements;return this._groupBy(t,"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&&a(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._unObject){const e=this._unObject.getTerminalConfiguration(r.graphic),t=this._getDisplayField(r.graphic);r.graphic.terminalId=e?e.terminals[0].id?e.terminals[0].id:null:1,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=e||null,r.graphic.selectedTerminals=[e?e.terminals[0].id?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()],b.prototype,"_activeProgress",void 0),e([n()],b.prototype,"_flags",void 0),e([n()],b.prototype,"_traces",void 0),e([n()],b.prototype,"_traceResults",void 0),e([n()],b.prototype,"defaultGraphicColor",void 0),e([n()],b.prototype,"flags",void 0),e([n()],b.prototype,"gdbVersion",void 0),e([n()],b.prototype,"selectedTraces",void 0),e([n()],b.prototype,"selectOnComplete",void 0),e([n()],b.prototype,"showGraphicsOnComplete",void 0),e([n()],b.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],b.prototype,"state",null),e([n({value:null})],b.prototype,"view",null),b=e([c(_)],b);const v=b;export{v as default};