@arcgis/core 4.34.0-next.90 → 4.34.0-next.92

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/interfaces.d.ts CHANGED
@@ -1996,10 +1996,10 @@ declare namespace __esri {
1996
1996
  *
1997
1997
  * Determines if the current screen size is appropriate for zoom actions.
1998
1998
  *
1999
- * @param feature The graphic feature to check.
1999
+ * @param graphic The graphic feature to check.
2000
2000
  * @param view The view associated with the popup.
2001
2001
  */
2002
- isZoomScreenSize(feature: Graphic | nullish, view: MapView | SceneView | nullish): Promise<boolean>;
2002
+ isZoomScreenSize(graphic: Graphic | nullish, view: MapView | SceneView | nullish): Promise<boolean>;
2003
2003
  }
2004
2004
 
2005
2005
  export const actionUtils: actionUtils;
@@ -5342,7 +5342,7 @@ declare namespace __esri {
5342
5342
  *
5343
5343
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-core-sql.html#sqlIn Read more...}
5344
5344
  */
5345
- sqlIn(fieldName: string, values: any): string | nullish;
5345
+ sqlIn(fieldName: string, values: (string | number)[]): string | nullish;
5346
5346
  }
5347
5347
 
5348
5348
  export const sql: sql;
@@ -9675,14 +9675,14 @@ declare namespace __esri {
9675
9675
  * Creates planar (or Euclidean) buffer polygons at a specified distance around the input geometries.
9676
9676
  *
9677
9677
  * @param geometries The buffer input geometry. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array.
9678
- * @param distance The specified distance(s) for buffering. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. When using an array of geometries as input, the length of the geometry array does not have to equal the length of the `distance` array. For example, if you pass an array of four geometries: `[g1, g2, g3, g4]` and an array with one distance: `[d1]`, all four geometries will be buffered by the single distance value. If instead you use an array of three distances: `[d1, d2, d3]`, `g1` will be buffered by `d1`, `g2` by `d2`, and `g3` and `g4` will both be buffered by `d3`. The value of the geometry array will be matched one to one with those in the distance array until the final value of the distance array is reached, in which case that value will be applied to the remaining geometries.
9678
+ * @param distances The specified distance(s) for buffering. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. When using an array of geometries as input, the length of the geometry array does not have to equal the length of the `distance` array. For example, if you pass an array of four geometries: `[g1, g2, g3, g4]` and an array with one distance: `[d1]`, all four geometries will be buffered by the single distance value. If instead you use an array of three distances: `[d1, d2, d3]`, `g1` will be buffered by `d1`, `g2` by `d2`, and `g3` and `g4` will both be buffered by `d3`. The value of the geometry array will be matched one to one with those in the distance array until the final value of the distance array is reached, in which case that value will be applied to the remaining geometries.
9679
9679
  * @param unit Measurement unit of the distance(s). Defaults to the units of the input geometries.
9680
9680
  * @param toUnionResults Determines whether the output geometries should be unioned into a single polygon.
9681
9681
  * @deprecated since 4.32. Use {@link module:esri/geometry/operators/bufferOperator bufferOperator} instead.
9682
9682
  *
9683
9683
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#buffer Read more...}
9684
9684
  */
9685
- buffer(geometries: GeometryUnion | GeometryUnion[], distance: number | number[], unit?: LinearUnits, toUnionResults?: boolean): Promise<Polygon | Polygon[]>;
9685
+ buffer(geometries: GeometryUnion | GeometryUnion[], distances: number | number[], unit?: LinearUnits, toUnionResults?: boolean): Promise<Polygon | Polygon[]>;
9686
9686
  /**
9687
9687
  * Calculates the clipped geometry from a target geometry by an envelope.
9688
9688
  *
@@ -9839,7 +9839,7 @@ declare namespace __esri {
9839
9839
  /**
9840
9840
  * Creates geodesic buffer polygons at a specified distance around the input geometries.
9841
9841
  *
9842
- * @param geometry The buffer input geometry. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array.
9842
+ * @param geometries The buffer input geometry. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array.
9843
9843
  * @param distance The specified distance(s) for buffering. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. When using an array of geometries as input, the length of the geometry array does not have to equal the length of the `distance` array. For example, if you pass an array of four geometries: `[g1, g2, g3, g4]` and an array with one distance: `[d1]`, all four geometries will be buffered by the single distance value. If instead you use an array of three distances: `[d1, d2, d3]`, `g1` will be buffered by `d1`, `g2` by `d2`, and `g3` and `g4` will both be buffered by `d3`. The value of the geometry array will be matched one to one with those in the distance array until the final value of the distance array is reached, in which case that value will be applied to the remaining geometries.
9844
9844
  * @param unit Measurement unit of the distance(s). Defaults to the units of the input geometries.
9845
9845
  * @param toUnionResults Determines whether the output geometries should merge into a single polygon.
@@ -9847,7 +9847,7 @@ declare namespace __esri {
9847
9847
  *
9848
9848
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicBuffer Read more...}
9849
9849
  */
9850
- geodesicBuffer(geometry: GeometryUnion | GeometryUnion[], distance: number | number[], unit?: LinearUnits, toUnionResults?: boolean): Promise<Polygon | Polygon[]>;
9850
+ geodesicBuffer(geometries: GeometryUnion | GeometryUnion[], distance: number | number[], unit?: LinearUnits, toUnionResults?: boolean): Promise<Polygon | Polygon[]>;
9851
9851
  /**
9852
9852
  * Returns a geodetically densified version of the input geometry.
9853
9853
  *
@@ -15400,11 +15400,11 @@ declare namespace __esri {
15400
15400
  /**
15401
15401
  * Returns the {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html OAuthInfo} configuration for the passed in Portal server URL.
15402
15402
  *
15403
- * @param url The URL to a Portal.
15403
+ * @param portalUrl The URL to a Portal.
15404
15404
  *
15405
15405
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#findOAuthInfo Read more...}
15406
15406
  */
15407
- findOAuthInfo(url: string): OAuthInfo;
15407
+ findOAuthInfo(portalUrl: string): OAuthInfo;
15408
15408
  /**
15409
15409
  * Returns information about the server that is hosting the specified URL.
15410
15410
  *
@@ -15976,11 +15976,11 @@ declare namespace __esri {
15976
15976
  * Formats a `Date` or `Number` value to a string in the current locale.
15977
15977
  *
15978
15978
  * @param value The [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object, or the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC, to be formatted.
15979
- * @param formatOptions Date format options.
15979
+ * @param options Date format options.
15980
15980
  *
15981
15981
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-intl.html#formatDate Read more...}
15982
15982
  */
15983
- formatDate(value: Date | number, formatOptions?: Intl.DateTimeFormatOptions): string;
15983
+ formatDate(value: Date | number, options?: Intl.DateTimeFormatOptions): string;
15984
15984
  /**
15985
15985
  * Formats a `date-only` field value to a string in the current locale.
15986
15986
  *
@@ -15994,11 +15994,11 @@ declare namespace __esri {
15994
15994
  * Formats a `Number` value to a string in the current locale.
15995
15995
  *
15996
15996
  * @param value Number to be formatted.
15997
- * @param formatOptions Number format options.
15997
+ * @param options Number format options.
15998
15998
  *
15999
15999
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-intl.html#formatNumber Read more...}
16000
16000
  */
16001
- formatNumber(value: number, formatOptions?: Intl.NumberFormatOptions): string;
16001
+ formatNumber(value: number, options?: Intl.NumberFormatOptions): string;
16002
16002
  /**
16003
16003
  * Formats a `time-only` field value to a string in the current locale.
16004
16004
  *
@@ -31357,12 +31357,12 @@ declare namespace __esri {
31357
31357
  /**
31358
31358
  * Query information about attachments associated with features.
31359
31359
  *
31360
- * @param attachmentQuery Specifies the attachment parameters for query.
31360
+ * @param query Specifies the attachment parameters for query.
31361
31361
  * @param options An object with the following properties.
31362
31362
  *
31363
31363
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#queryAttachments Read more...}
31364
31364
  */
31365
- queryAttachments(attachmentQuery: AttachmentQueryProperties, options?: SceneLayerQueryAttachmentsOptions): Promise<any>;
31365
+ queryAttachments(query: AttachmentQueryProperties, options?: SceneLayerQueryAttachmentsOptions): Promise<any>;
31366
31366
  /**
31367
31367
  * Queries cached statistics from the service for a given field.
31368
31368
  *
@@ -50671,11 +50671,11 @@ declare namespace __esri {
50671
50671
  /**
50672
50672
  * The network consists of sources (classes) and each source has a unique Id.
50673
50673
  *
50674
- * @param id The id of the source.
50674
+ * @param sourceId The id of the source.
50675
50675
  *
50676
50676
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-networks-Network.html#getLayerIdBySourceId Read more...}
50677
50677
  */
50678
- getLayerIdBySourceId(id: number): number | nullish;
50678
+ getLayerIdBySourceId(sourceId: number): number | nullish;
50679
50679
  /**
50680
50680
  * Groups network elements by their layerId.
50681
50681
  *
@@ -66550,13 +66550,13 @@ declare namespace __esri {
66550
66550
  * Determines the optimized routes for a fleet of vehicles that need to make deliveries.
66551
66551
  *
66552
66552
  * @param url URL to the ArcGIS Server REST resource that represents a network analysis service.
66553
- * @param params Parameters needed to configure the last mile delivery solver.
66553
+ * @param parameters Parameters needed to configure the last mile delivery solver.
66554
66554
  * @param options Processing options.
66555
66555
  * @param requestOptions Additional {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#request options} to be used for the data request.
66556
66556
  *
66557
66557
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-lastMileDelivery.html#execute Read more...}
66558
66558
  */
66559
- execute(url: string, params: LastMileDeliveryParameters, options?: lastMileDeliveryExecuteOptions, requestOptions?: RequestOptions): Promise<JobInfo>;
66559
+ execute(url: string, parameters: LastMileDeliveryParameters, options?: lastMileDeliveryExecuteOptions, requestOptions?: RequestOptions): Promise<JobInfo>;
66560
66560
  /**
66561
66561
  * Returns the credits used by the analysis.
66562
66562
  *
@@ -115873,7 +115873,7 @@ declare namespace __esri {
115873
115873
  | "awaiting-update-feature-candidate"
115874
115874
  | "creating-features"
115875
115875
  | "disabled"
115876
- | "drawing-split-geometry"
115876
+ | "drawing-splitter-geometry"
115877
115877
  | "editing-attributes"
115878
115878
  | "editing-attachment"
115879
115879
  | "editing-existing-feature"
@@ -116003,6 +116003,33 @@ declare namespace __esri {
116003
116003
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-EditorViewModel.html#startCreateFeaturesWorkflowAtFeatureTypeSelection Read more...}
116004
116004
  */
116005
116005
  startCreateFeaturesWorkflowAtFeatureTypeSelection(): Promise<void>;
116006
+ /**
116007
+ * Starts a split feature workflow for the given feature.
116008
+ *
116009
+ * @param feature The feature to be split.
116010
+ * @param options Options for the split feature workflow.
116011
+ *
116012
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-EditorViewModel.html#startSplitFeatureWorkflow Read more...}
116013
+ */
116014
+ startSplitFeatureWorkflow(feature: Graphic, options: EditorViewModelStartSplitFeatureWorkflowOptions): Promise<void>;
116015
+ /**
116016
+ * Starts a split feature workflow at the "drawing-splitter-geometry" step using the provided feature.
116017
+ *
116018
+ * @param feature The feature to be split.
116019
+ * @param sketchTool The preferred Sketch tool to use for drawing the splitter geometry.
116020
+ *
116021
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-EditorViewModel.html#startSplitFeatureWorkflowAtDrawingSplitterGeometry Read more...}
116022
+ */
116023
+ startSplitFeatureWorkflowAtDrawingSplitterGeometry(feature: Graphic, sketchTool?: "point" | "polyline" | "polygon"): Promise<void>;
116024
+ /**
116025
+ * Starts a split feature workflow at the "reviewing-features".
116026
+ *
116027
+ * @param feature The feature to be split.
116028
+ * @param splitterGeometry The geometry to use for splitting the given feature.
116029
+ *
116030
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-EditorViewModel.html#startSplitFeatureWorkflowAtReviewingFeatures Read more...}
116031
+ */
116032
+ startSplitFeatureWorkflowAtReviewingFeatures(feature: Graphic, splitterGeometry: Point | Polyline | Polygon): Promise<void>;
116006
116033
  /**
116007
116034
  * Starts an {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-UpdateFeaturesWorkflow.html UpdateFeaturesWorkflow} using
116008
116035
  * the provided features.
@@ -116105,6 +116132,12 @@ declare namespace __esri {
116105
116132
  initialFeature: Graphic;
116106
116133
  }
116107
116134
 
116135
+ export interface EditorViewModelStartSplitFeatureWorkflowOptions {
116136
+ defaultSplitterGeometryType?: "point" | "polyline" | "polygon";
116137
+ splitterGeometry?: Point | Polyline | Polygon;
116138
+ startAt?: "drawing-splitter-geometry" | "reviewing-features";
116139
+ }
116140
+
116108
116141
  export interface EditorViewModelSketchCreateEvent {
116109
116142
  detail: EditorViewModelSketchCreateEventDetail;
116110
116143
  layer: FeatureLayer | SceneLayer | SubtypeSublayer;
@@ -116158,6 +116191,83 @@ declare namespace __esri {
116158
116191
  interface EditsProperties {
116159
116192
  }
116160
116193
 
116194
+ export class SplitFeatureWorkflow extends Workflow {
116195
+ /**
116196
+ * The currently active feature.
116197
+ *
116198
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-SplitFeatureWorkflow.html#activeFeature Read more...}
116199
+ */
116200
+ readonly activeFeature: Graphic | nullish;
116201
+ /**
116202
+ * Specifies the type of geometry to be drawn by the Sketch operation that is
116203
+ * started automatically when the workflow is launched.
116204
+ *
116205
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-SplitFeatureWorkflow.html#defaultSplitterGeometryType Read more...}
116206
+ */
116207
+ defaultSplitterGeometryType: "point" | "polyline" | "polygon" | nullish;
116208
+ /**
116209
+ * The instance of
116210
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-FeatureFormViewModel.html FeatureFormViewModel} used by the
116211
+ * workflow to manage the attributes of the resulting features.
116212
+ *
116213
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-SplitFeatureWorkflow.html#featureFormViewModel Read more...}
116214
+ */
116215
+ readonly featureFormViewModel: FeatureFormViewModel;
116216
+ /**
116217
+ * The layer to which the feature being split belongs.
116218
+ *
116219
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-SplitFeatureWorkflow.html#layer Read more...}
116220
+ */
116221
+ readonly layer: GeoJSONLayer | FeatureLayer | OrientedImageryLayer | SceneLayer | SubtypeSublayer | nullish;
116222
+ /**
116223
+ * The type of the workflow.
116224
+ *
116225
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-SplitFeatureWorkflow.html#type Read more...}
116226
+ */
116227
+ readonly type: "split-feature";
116228
+ /**
116229
+ * A read-only class containing the logic used when splitting a feature using
116230
+ * the {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html Editor} widget.
116231
+ *
116232
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-SplitFeatureWorkflow.html Read more...}
116233
+ */
116234
+ constructor(properties?: SplitFeatureWorkflowProperties);
116235
+ /**
116236
+ * Sets the specified feature as the active feature in the workflow.
116237
+ *
116238
+ * @param feature The feature to set as active.
116239
+ *
116240
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-SplitFeatureWorkflow.html#setActiveFeature Read more...}
116241
+ */
116242
+ setActiveFeature(feature: Graphic): Promise<void>;
116243
+ }
116244
+
116245
+ interface SplitFeatureWorkflowProperties extends WorkflowProperties {
116246
+ /**
116247
+ * Specifies the type of geometry to be drawn by the Sketch operation that is
116248
+ * started automatically when the workflow is launched.
116249
+ *
116250
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-SplitFeatureWorkflow.html#defaultSplitterGeometryType Read more...}
116251
+ */
116252
+ defaultSplitterGeometryType?: "point" | "polyline" | "polygon" | nullish;
116253
+ }
116254
+
116255
+ /**
116256
+ * This object contains data for the {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-SplitFeatureWorkflow.html SplitFeatureWorkflow}.
116257
+ *
116258
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-SplitFeatureWorkflowData.html Read more...}
116259
+ */
116260
+ interface SplitFeatureWorkflowData {
116261
+ editorItem: EditorItem;
116262
+ existingFeatureEdits: Edits | nullish;
116263
+ newFeatureEdits: Edits | nullish;
116264
+ originalFeature: Graphic;
116265
+ splitterGeometry: Point | Polyline | Polygon | nullish;
116266
+ viewModel: EditorViewModel;
116267
+ }
116268
+
116269
+ export const SplitFeatureWorkflowData: SplitFeatureWorkflowData;
116270
+
116161
116271
  export class EditorItem extends Accessor {
116162
116272
  /**
116163
116273
  * The current {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-support-EditorItem.html#EditorEditingCapabilities editing capabilities} for the provided layer.
@@ -116223,6 +116333,12 @@ declare namespace __esri {
116223
116333
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-support-EditorItem.html#supportsCreateFeaturesWorkflow Read more...}
116224
116334
  */
116225
116335
  readonly supportsCreateFeaturesWorkflow: boolean;
116336
+ /**
116337
+ * Indicates whether the item supports starting a new {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-SplitFeatureWorkflow.html split feature} workflow based on specific conditions set within the {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html Editor}.
116338
+ *
116339
+ * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-support-EditorItem.html#supportsSplitFeatureWorkflow Read more...}
116340
+ */
116341
+ readonly supportsSplitFeatureWorkflow: boolean;
116226
116342
  /**
116227
116343
  * Indicates whether the item supports starting a new {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-UpdateWorkflow.html update workflow} based on specific conditions set within the {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html Editor}.
116228
116344
  *
@@ -116463,7 +116579,10 @@ declare namespace __esri {
116463
116579
  *
116464
116580
  * {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-Workflow.html#data Read more...}
116465
116581
  */
116466
- readonly data: CreateFeaturesWorkflowData | UpdateWorkflowData | UpdateFeaturesWorkflowData;
116582
+ readonly data: | CreateFeaturesWorkflowData
116583
+ | SplitFeatureWorkflowData
116584
+ | UpdateWorkflowData
116585
+ | UpdateFeaturesWorkflowData;
116467
116586
  /**
116468
116587
  * This property indicates whether there is a next step in the workflow.
116469
116588
  *
package/kernel.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.34/esri/copyright.txt for details.
4
4
  */
5
- import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="4.34";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="4.34.0-next.90",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
5
+ import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="4.34";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="4.34.0-next.92",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.34.0-next.90",
3
+ "version": "4.34.0-next.92",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK 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.34/esri/copyright.txt for details.
4
4
  */
5
- const c="20250920",d="5c5be205c3bfc5a6d482cebdd09cadc899dd3fe8";export{c as buildDate,d as commitHash};
5
+ const a="20250922",c="d06be9188f553b439522731a0165c23a25ed7acd";export{a as buildDate,c 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{unique as t,isSome as i}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import s from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import p from"../../core/Logger.js";import{destroyMaybe as d,abortMaybe as c,removeMaybe as u}from"../../core/maybe.js";import{throwIfAborted as h,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as v,sync as k,whenOnce as _}from"../../core/reactiveUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as T}from"../../editing/templateUtils.js";import V from"../../layers/GraphicsLayer.js";import{isEditableLayer as b}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,isSubtypeGroupLayer as S,getOwningPortalUrl as L}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import A from"../../views/SelectionManager.js";import U from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as C}from"../../views/interactive/snapping/SnappingManager.js";import O from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as j}from"../../views/support/selectionUtils.js";import P from"../Attachments/AttachmentsViewModel.js";import R from"./CreateFeaturesWorkflow.js";import H from"./UpdateFeaturesWorkflow.js";import q from"./UpdateWorkflow.js";import{getLayersFromWorkflow as G,isCreateFeaturesWorkflow as x,isUpdateRecordWorkflow as D,isUpdateFeaturesWorkflow as B,isUpdateWorkflow as N,findEditorItemForLayerOrThrow as Q,makeMultipleSourceLayersError as z,findEditorItemForLayer as Z,whenEditorLayerView as $}from"./workflowUtils.js";import J from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as K}from"../FeatureTemplates/featureTemplatesUtils.js";import X from"../FeatureTemplates/FeatureTemplatesViewModel.js";import Y from"../Sketch/SketchViewModel.js";import ee from"../Spinner/SpinnerViewModel.js";import{goTo as te}from"../support/goToUtils.js";import{isFeatureItem as ie,isLayerItem as ae}from"../support/SelectionList/selectionListUtils.js";import re from"../support/SelectionList/SelectionListViewModel.js";import oe from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function se(e,t){return e?.find(e=>e.layer===t)}let ne=class extends n{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new V({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new F,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new P({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new X({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new Y({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new re,this.selectionManager=new A,this.selectionToolbarViewModel=new oe({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new U,this.snappingOptions=new O({attributeRulesEnabled:!0}),this.spinnerViewModel=new ee,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;this._candidateCommitted||"update"!==i?.type||(i.data.rootFeature=e,t&&(i.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,a=i?.filter(e=>!!t?.includes(e.layer));return[t,a,this.layerInfos]},()=>this._updateEditorItems(),g),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),v),m(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),m(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),m(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),y(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this.selectionManager.showHighlight=!e),y(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),v),m(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),f(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),f(()=>this.page,(e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i},g),y(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),m(()=>this.featureTemplatesViewModel,"select",async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const a={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(a);await this.startCreateFeaturesWorkflowAtFeatureCreation(a)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},g),m(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),m(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i="update"===t?.type,a=G(t),r=i?t?.activeWorkflow?.parentLayer??void 0:void 0,o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:a[0],layers:a,parentLayer:r})},k),f(()=>this.view,e=>{if(this._snappingManager=d(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new C({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},g),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},g),m(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),f(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:a})=>{t.view=e,i.view=e,a.view=e},g),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},g)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then(()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null}),this._updateItemsTask=c(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=u(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new r;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new r;for(const t of this.editorItems)j(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return x(e)?e.pendingFeatures.length:D(e)&&e.data.edits.feature?1:B(e)?e.data.features.length:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&N(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some(e=>e.supportsCreateFeaturesWorkflow)}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some(e=>e.supportsUpdateWorkflow)}get canUpdateVisible(){return this.editorItems.some(e=>e.supportsUpdateWorkflow&&e.visible)}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter(e=>"scene"===e.type||!e.isTable)}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:"update-features"===e?.type?e.formViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type||"update-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeLeafWorkflow:e}=this;if(D(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.featureFormViewModel.disabled;if(B(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(D(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!B(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await _(()=>!this.updating),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,a=i?Q(this.editorItems,i):void 0;if(!a?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow({initialFeature:t,layer:a.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",r),await r.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");if(t(e.map(e=>e.sourceLayer??e.layer)).length>1)throw z();const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateFeaturesWorkflow(e);this._set("activeWorkflow",t),await t.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature",e);t.addHandles(m(()=>t,"commit",()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)})),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount)throw new s("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new s("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.visibleFeatureItems.map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}async deleteFeatureFromWorkflow(){o(p.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;return N(e)?e.deleteActiveFeature():B(e)?e.deleteAndCommit():void this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}itemHasInvalidFormTemplate(e){return null!=e&&!0===Z(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:t,sketchViewModel:a}=this;if(!t)return;const r=e??a?.createGraphic;if(r)"mesh"===r.geometry?.type?te(t,r.geometry):te(t,r);else{const e=a?.updateGraphics?.toArray();"3d"===t.type&&e?.some(e=>"mesh"===e.geometry?.type)?te(t,e.map(e=>e.geometry).filter(i)):e&&te(t,e)}}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){ie(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){if(ie(e))await this.startUpdateWorkflowAtFeatureEdit(e.graphic);else if(ae(e)){const t=e.featureItems.filter(e=>e.visible).map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,a=i.editableLayers.toArray(),r=i.allTables.toArray().filter(e=>E(e)||S(e));return await Promise.allSettled([...a.flatMap(e=>this._getLayerLoadPromise(e)),...r.flatMap(e=>this._getLayerLoadPromise(e))]),h(e),[...a.reverse(),...r.reverse()].filter(e=>b(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return S(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){c(this._updateItemsTask);const{view:e}=this,t=a(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const a=[],r=[],o=[],{layerInfos:s}=this;for(const l of i){const t=se(s,l),i=await $(e,l).catch(()=>null);(t?a:i?r:o).push(new J({layer:l,layerInfo:t,layerView:i}))}s?.length&&a.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...a,...r,...o];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))});this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){c(this._updateTemplatesTask);const e=a(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const a=await T({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of a)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const a of e){const e=t.get(a);e&&e.length>0&&i.push(K(a,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return R.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow(e){const t=H.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return t.addHandles(m(()=>t,"commit",()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)})),t}_createUpdateWorkflow(e,t){return q.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,rootFeature:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_addAttachments(e,t){const i=t.map(t=>this._addAttachment(e,t.feature,t.attachment))??[];return Promise.all(i)}async _addAttachment(e,t,i){let a=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(a=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,a)),a}async _applyEdits(e,t,i){let a=null;const r=e.url?await L(e.url):null,o={returnServiceEditsOption:(!r||!I(r))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const r=await $(i,e).catch(()=>null);return a=await e.applyEdits(t,o),r&&await _(()=>!r.updating),a}),a}async _applyEditsFeatureService(e,t,i){let a=null;return await this._queueOperation(async()=>a=await e.applyEdits(t,i)),a}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then(e=>(Array.isArray(e)?e.forEach(e=>this._handleEditsResultError(e)):this._handleEditsResultError(e),e)).catch(i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const a={error:i,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])}).then(()=>{t(e,this._activityQueue)})}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:a}=e,r=t.find(e=>!!e.error)||a.find(e=>!!e.error)||i.find(e=>!!e.error);if(r)throw r.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:a}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,a??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=Q(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){p.getLogger(this).error(new s(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:a}=this,r="ready"===this.state,o=1===i.length;if(this._queuedSelectionTool=void 0,r&&o&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":a.updateSelection({current:[],added:[],removed:i});break;case"replace":a.clear(),a.updateSelection({current:i,added:[],removed:[]});break;case"add":a.updateSelection({current:i,added:[],removed:[]})}}};e([M()],ne.prototype,"_featureTemplatesLayersAndTables",null),e([M()],ne.prototype,"_queuedSelectionTool",void 0),e([M()],ne.prototype,"_snappingManager",void 0),e([M()],ne.prototype,"_selectionSources",null),e([M()],ne.prototype,"activeFeatureCount",null),e([M({readOnly:!0})],ne.prototype,"activeWorkflow",void 0),e([M()],ne.prototype,"activeLeafWorkflow",null),e([M({readOnly:!0})],ne.prototype,"_activityQueue",void 0),e([M({readOnly:!0})],ne.prototype,"canCreate",null),e([M()],ne.prototype,"canCreateVisible",null),e([M({readOnly:!0})],ne.prototype,"canUpdate",null),e([M()],ne.prototype,"canUpdateVisible",null),e([M()],ne.prototype,"featureTemplatesLayers",null),e([M()],ne.prototype,"editorItems",void 0),e([M()],ne.prototype,"effectiveSelectionManager",null),e([M({readOnly:!0})],ne.prototype,"failures",void 0),e([M()],ne.prototype,"hideTemplatesForInactiveLayers",void 0),e([M({type:P})],ne.prototype,"attachmentsViewModel",void 0),e([M()],ne.prototype,"featureFormViewModel",null),e([M()],ne.prototype,"formViewModel",null),e([M()],ne.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([M({type:X})],ne.prototype,"featureTemplatesViewModel",void 0),e([M()],ne.prototype,"labelOptions",null),e([M()],ne.prototype,"layerInfos",void 0),e([M()],ne.prototype,"ownSketchViewModel",void 0),e([M()],ne.prototype,"selectionListViewModel",void 0),e([M()],ne.prototype,"selectionManager",void 0),e([M()],ne.prototype,"selectionToolbarViewModel",void 0),e([M()],ne.prototype,"sketchOptions",void 0),e([M()],ne.prototype,"sketchViewModel",null),e([M({type:O,nonNullable:!0})],ne.prototype,"snappingOptions",void 0),e([M()],ne.prototype,"spinnerViewModel",void 0),e([M()],ne.prototype,"state",null),e([M({readOnly:!0})],ne.prototype,"syncing",null),e([M()],ne.prototype,"updating",null),e([M()],ne.prototype,"tooltipOptions",null),e([M()],ne.prototype,"valueOptions",null),e([M()],ne.prototype,"view",null),e([M()],ne.prototype,"canZoomTo",null),e([M()],ne.prototype,"pageStack",void 0),e([M()],ne.prototype,"showDiscardEditsPrompt",void 0),e([M()],ne.prototype,"_candidateCommitted",void 0),e([M()],ne.prototype,"page",null),e([M()],ne.prototype,"featureFormDisabled",null),e([M()],ne.prototype,"featureFormHasAssociation",null),e([M()],ne.prototype,"canGoBack",null),e([M()],ne.prototype,"shouldShowDeleteButton",null),e([M()],ne.prototype,"hasPendingEdits",null),e([M()],ne.prototype,"snappingManager",null),ne=e([W("esri.widgets.Editor.EditorViewModel")],ne);const le=ne;export{le as default};
5
+ import{__decorate as e}from"tslib";import{unique as t,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import s from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{abortHandle as l,makeHandle as p}from"../../core/handleUtils.js";import d from"../../core/Logger.js";import{destroyMaybe as c,abortMaybe as u,removeMaybe as h}from"../../core/maybe.js";import{throwIfAborted as w,createResolver as f}from"../../core/promiseUtils.js";import{watch as m,on as y,when as g,syncAndInitial as k,initial as v,sync as _,whenOnce as W}from"../../core/reactiveUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as F}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as T}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as V}from"../../editing/templateUtils.js";import{getGraphicLayer as b}from"../../graphic/graphicOriginUtils.js";import E from"../../layers/GraphicsLayer.js";import{isEditableLayer as S}from"../../layers/support/editableLayers.js";import{isFeatureLayer as A,isSubtypeGroupLayer as I,getOwningPortalUrl as L}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as U}from"../../portal/support/urlUtils.js";import C from"../../views/SelectionManager.js";import O from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as j}from"../../views/interactive/snapping/SnappingManager.js";import P from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as R}from"../../views/support/selectionUtils.js";import H from"../Attachments/AttachmentsViewModel.js";import q from"./CreateFeaturesWorkflow.js";import G from"./UpdateFeaturesWorkflow.js";import x from"./UpdateWorkflow.js";import{getLayersFromWorkflow as D,isCreateFeaturesWorkflow as B,isUpdateRecordWorkflow as N,isUpdateFeaturesWorkflow as Q,isUpdateWorkflow as z,findEditorItemForLayerOrThrow as Z,assertSplitWorkflowCapabilities as $,fetchFullFeatures as J,makeMultipleSourceLayersError as K,findEditorItemForLayer as X,whenEditorLayerView as Y}from"./workflowUtils.js";import ee from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as te}from"../FeatureTemplates/featureTemplatesUtils.js";import ie from"../FeatureTemplates/FeatureTemplatesViewModel.js";import re from"../Sketch/SketchViewModel.js";import ae from"../Spinner/SpinnerViewModel.js";import{goTo as oe}from"../support/goToUtils.js";import{isFeatureItem as se,isLayerItem as ne}from"../support/SelectionList/selectionListUtils.js";import le from"../support/SelectionList/SelectionListViewModel.js";import pe from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function de(e,t){return e?.find(e=>e.layer===t)}let ce=class extends n{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new E({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new T,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new H({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new ie({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new re({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new le,this.selectionManager=new C,this.selectionToolbarViewModel=new pe({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new O,this.snappingOptions=new P({attributeRulesEnabled:!0}),this.spinnerViewModel=new ae,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;this._candidateCommitted||"update"!==i?.type||(i.data.rootFeature=e,t&&(i.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([m(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,r=i?.filter(e=>!!t?.includes(e.layer));return[t,r,this.layerInfos]},()=>this._updateEditorItems(),k),m(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),m(()=>this._selectionSources,()=>this._syncSelectionSources(),v),y(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),y(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),y(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),g(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),m(()=>this.activeWorkflow,e=>this.selectionManager.showHighlight=!e),g(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),v),y(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),m(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),m(()=>this.page,(e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i},k),g(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),y(()=>this.featureTemplatesViewModel,"select",async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const r={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(r);await this.startCreateFeaturesWorkflowAtFeatureCreation(r)}),m(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},k),y(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),y(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i="update"===t?.type,r=D(t),a=i?t?.activeWorkflow?.parentLayer??void 0:void 0,o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:r[0],layers:r,parentLayer:a})},_),m(()=>this.view,e=>{if(this._snappingManager=c(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new j({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},k),m(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},k),y(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),m(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:r})=>{t.view=e,i.view=e,r.view=e},k),m(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},k)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then(()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null}),this._updateItemsTask=u(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=h(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new a;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new a;for(const t of this.editorItems)R(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return B(e)?e.pendingFeatures.length:N(e)&&e.data.edits.feature?1:Q(e)?e.data.features.length:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&z(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some(e=>e.supportsCreateFeaturesWorkflow)}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some(e=>e.supportsUpdateWorkflow)}get canUpdateVisible(){return this.editorItems.some(e=>e.supportsUpdateWorkflow&&e.visible)}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter(e=>"scene"===e.type||!e.isTable)}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:"update-features"===e?.type?e.formViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type||"update-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeLeafWorkflow:e}=this;if(N(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.featureFormViewModel.disabled;if(Q(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(N(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!Q(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await W(()=>!this.updating),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await W(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,r=i?Z(this.editorItems,i):void 0;if(!r?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow({initialFeature:t,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",a),await a.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startSplitFeatureWorkflow(e,t={}){await W(()=>!this.updating);const{view:i}=this;if(!i)throw new s("editing:view-required","A view is required to start a split feature workflow.");const r=b(e);if(!r)throw new s("editing:layer-required","The feature must be associated with a layer to start a split feature workflow.");const a=Z(this.editorItems,r);$(a);const o=this._createUpdatingResolver(),n=new AbortController;this.addHandles(l(n));try{await this._cancelWorkflow();const a=await J([e],r,i.spatialReference,n.signal);if(0===a.length)throw new s("editing:fetch-feature","Failed to fetch the full feature from the service.");const o=this._createUpdateWorkflow("editing-existing-feature",{rootFeature:a[0],rootWorkflowOptions:{type:"split",props:t}});this._set("activeWorkflow",o),this.addHandles(this._destroyWorkflowOnCommit(o)),await o.start()}catch(p){this._logErrorAndCancelWorkflow(p)}finally{o.resolve()}}async startSplitFeatureWorkflowAtDrawingSplitterGeometry(e,t){return this.startSplitFeatureWorkflow(e,{defaultSplitterGeometryType:t,startAt:"drawing-splitter-geometry"})}async startSplitFeatureWorkflowAtReviewingFeatures(e,t){return this.startSplitFeatureWorkflow(e,{splitterGeometry:t,startAt:"reviewing-features"})}async startUpdateFeaturesWorkflow(e){if(await W(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");if(t(e.map(e=>e.sourceLayer??e.layer)).length>1)throw K();const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateFeaturesWorkflow(e);this._set("activeWorkflow",t),await t.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await W(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await W(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await W(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature",{rootFeature:e});t.addHandles(this._destroyWorkflowOnCommit(t)),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount)throw new s("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new s("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.visibleFeatureItems.map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}async deleteFeatureFromWorkflow(){o(d.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;return z(e)?e.deleteActiveFeature():Q(e)?e.deleteAndCommit():void this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}itemHasInvalidFormTemplate(e){return null!=e&&!0===X(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:t,sketchViewModel:r}=this;if(!t)return;const a=e??r?.createGraphic;if(a)"mesh"===a.geometry?.type?oe(t,a.geometry):oe(t,a);else{const e=r?.updateGraphics?.toArray();"3d"===t.type&&e?.some(e=>"mesh"===e.geometry?.type)?oe(t,e.map(e=>e.geometry).filter(i)):e&&oe(t,e)}}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){se(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){if(se(e))await this.startUpdateWorkflowAtFeatureEdit(e.graphic);else if(ne(e)){const t=e.featureItems.filter(e=>e.visible).map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),p(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,r=i.editableLayers.toArray(),a=i.allTables.toArray().filter(e=>A(e)||I(e));return await Promise.allSettled([...r.flatMap(e=>this._getLayerLoadPromise(e)),...a.flatMap(e=>this._getLayerLoadPromise(e))]),w(e),[...r.reverse(),...a.reverse()].filter(e=>S(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return I(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){u(this._updateItemsTask);const{view:e}=this,t=r(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const r=[],a=[],o=[],{layerInfos:s}=this;for(const l of i){const t=de(s,l),i=await Y(e,l).catch(()=>null);(t?r:i?a:o).push(new ee({layer:l,layerInfo:t,layerView:i}))}s?.length&&r.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...r,...a,...o];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))});this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){u(this._updateTemplatesTask);const e=r(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const r=await V({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of r)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const r of e){const e=t.get(r);e&&e.length>0&&i.push(te(r,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return q.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow(e){const t=G.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return this.addHandles(this._destroyWorkflowOnCommit(t)),t}_createUpdateWorkflow(e,t){const i=x.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,rootFeature:t?.rootFeature,rootWorkflowOptions:t?.rootWorkflowOptions,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)});return i}_addAttachments(e,t){const i=t.map(t=>this._addAttachment(e,t.feature,t.attachment))??[];return Promise.all(i)}async _addAttachment(e,t,i){let r=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(r=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,r)),r}async _applyEdits(e,t,i){let r=null;const a=e.url?await L(e.url):null,o={returnServiceEditsOption:(!a||!U(a))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const a=await Y(i,e).catch(()=>null);return r=await e.applyEdits(t,o),a&&await W(()=>!a.updating),r}),r}async _applyEditsFeatureService(e,t,i){let r=null;return await this._queueOperation(async()=>r=await e.applyEdits(t,i)),r}_destroyWorkflowOnCommit(e){return y(()=>e,"commit",()=>{e.destroy(),this.activeWorkflow===e&&this._set("activeWorkflow",null)})}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then(e=>(Array.isArray(e)?e.forEach(e=>this._handleEditsResultError(e)):this._handleEditsResultError(e),e)).catch(i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const r={error:i,retry:()=>(t(r,this.failures),this._queueOperation(e)),cancel:()=>{t(r,this.failures)}};this._set("failures",[...this.failures,r])}).then(()=>{t(e,this._activityQueue)})}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:r}=e,a=t.find(e=>!!e.error)||r.find(e=>!!e.error)||i.find(e=>!!e.error);if(a)throw a.error}}_createUpdatingResolver(){const e=f();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:r}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,r??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=Z(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){d.getLogger(this).error(new s(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:r}=this,a="ready"===this.state,o=1===i.length;if(this._queuedSelectionTool=void 0,a&&o&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":r.updateSelection({current:[],added:[],removed:i});break;case"replace":r.clear(),r.updateSelection({current:i,added:[],removed:[]});break;case"add":r.updateSelection({current:i,added:[],removed:[]})}}};e([M()],ce.prototype,"_featureTemplatesLayersAndTables",null),e([M()],ce.prototype,"_queuedSelectionTool",void 0),e([M()],ce.prototype,"_snappingManager",void 0),e([M()],ce.prototype,"_selectionSources",null),e([M()],ce.prototype,"activeFeatureCount",null),e([M({readOnly:!0})],ce.prototype,"activeWorkflow",void 0),e([M()],ce.prototype,"activeLeafWorkflow",null),e([M({readOnly:!0})],ce.prototype,"_activityQueue",void 0),e([M({readOnly:!0})],ce.prototype,"canCreate",null),e([M()],ce.prototype,"canCreateVisible",null),e([M({readOnly:!0})],ce.prototype,"canUpdate",null),e([M()],ce.prototype,"canUpdateVisible",null),e([M()],ce.prototype,"featureTemplatesLayers",null),e([M()],ce.prototype,"editorItems",void 0),e([M()],ce.prototype,"effectiveSelectionManager",null),e([M({readOnly:!0})],ce.prototype,"failures",void 0),e([M()],ce.prototype,"hideTemplatesForInactiveLayers",void 0),e([M({type:H})],ce.prototype,"attachmentsViewModel",void 0),e([M()],ce.prototype,"featureFormViewModel",null),e([M()],ce.prototype,"formViewModel",null),e([M()],ce.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([M({type:ie})],ce.prototype,"featureTemplatesViewModel",void 0),e([M()],ce.prototype,"labelOptions",null),e([M()],ce.prototype,"layerInfos",void 0),e([M()],ce.prototype,"ownSketchViewModel",void 0),e([M()],ce.prototype,"selectionListViewModel",void 0),e([M()],ce.prototype,"selectionManager",void 0),e([M()],ce.prototype,"selectionToolbarViewModel",void 0),e([M()],ce.prototype,"sketchOptions",void 0),e([M()],ce.prototype,"sketchViewModel",null),e([M({type:P,nonNullable:!0})],ce.prototype,"snappingOptions",void 0),e([M()],ce.prototype,"spinnerViewModel",void 0),e([M()],ce.prototype,"state",null),e([M({readOnly:!0})],ce.prototype,"syncing",null),e([M()],ce.prototype,"updating",null),e([M()],ce.prototype,"tooltipOptions",null),e([M()],ce.prototype,"valueOptions",null),e([M()],ce.prototype,"view",null),e([M()],ce.prototype,"canZoomTo",null),e([M()],ce.prototype,"pageStack",void 0),e([M()],ce.prototype,"showDiscardEditsPrompt",void 0),e([M()],ce.prototype,"_candidateCommitted",void 0),e([M()],ce.prototype,"page",null),e([M()],ce.prototype,"featureFormDisabled",null),e([M()],ce.prototype,"featureFormHasAssociation",null),e([M()],ce.prototype,"canGoBack",null),e([M()],ce.prototype,"shouldShowDeleteButton",null),e([M()],ce.prototype,"hasPendingEdits",null),e([M()],ce.prototype,"snappingManager",null),ce=e([F("esri.widgets.Editor.EditorViewModel")],ce);const ue=ce;export{ue as default};
@@ -0,0 +1,4 @@
1
+ import "../../interfaces";
2
+
3
+ import SplitFeatureWorkflow = __esri.SplitFeatureWorkflow;
4
+ export default SplitFeatureWorkflow;
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r}from"../../core/handleUtils.js";import"../../core/has.js";import a from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import{debounce as s}from"../../core/promiseUtils.js";import{watch as l,on as n,whenOnce as p}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import u from"../../layers/GraphicsLayer.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as m}from"../../views/support/HighlightDefaults.js";import w from"./Edits.js";import g from"./SplitFeatureWorkflowData.js";import y from"./Workflow.js";import{createWorkflowSteps as f,swapForEditingSession as _,updateGraphicSymbolWhenRequired as v,makeMinimalAttributes as F}from"./workflowUtils.js";import{getCompatibleSpitterGeometryType as M,ensureSplittableGeometry as b,makeNewFeatureAttributes as k,splitGeometry as S,isSplitterGeometry as V}from"./support/splitFeatureUtils.js";import j from"../FeatureForm/FeatureFormViewModel.js";import G from"../Sketch/SketchViewModel.js";var T;const E=()=>a.getLogger("esri.widgets.Editor.SplitFeatureWorkflow");let H=T=class extends y{constructor(e){super(e),this.defaultSplitterGeometryType=null,this.type="split-feature",this._activeFeature=null,this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._sketchViewModel=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new c({view:e,highlightName:m}):null,this._initializeFeatureFormViewModel();const t=this._initializeGraphicsLayer();this._initializeSketchViewModel(t)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel.destroy(),this._sketchViewModel.destroy(),this._highlightHelper?.destroy()}get activeFeature(){return this._activeFeature}get featureFormViewModel(){return this._formViewModel}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if("reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=M(b(s.originalFeature.geometry),s.splitterGeometry.type);if(s.splitterGeometry.type!==e)throw new t("editing:incompatible-split-geometries",`Geometry of type '${s.splitterGeometry.type}' cannot be used to split geometry of type '${s.originalFeature.geometry?.type}'.`)}const l=new T({data:new g(s),defaultSplitterGeometryType:a,onCommit:L(e.applyEdits)});return l._set("steps",T._createWorkflowSteps(l,o)),l}async enter(){}exit(){if("reviewing-features"!==this.stepId)throw new t("editing:invalid-exit-state","The SplitFeatureWorkflow can only be exited when in the 'reviewing-features' step.")}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data,a=this._highlightHelper;a?.removeAll();const o=i?r.getEditsForFeature(i):null;if(o&&(o.submittable=this._formViewModel.submittable),this._activeFeature=e,null==e)return;const s=this.data.getRoleForFeature(e);if(!s)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");a?.add(e),await this._setFeatureOnFormViewModel(e,s)}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.originalFeature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new w({feature:o});i.existingFeatureEdits=s,s.trackChanges(r),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const l=r.clone();l.geometry=e,l.attributes=k(r.attributes,i.editorItem.layer);const n=new w({feature:l});return i.newFeatureEdits=n,n.trackChanges(),await this._setFeatureOnFormViewModel(l,"new"),n.submittable=a.submittable,{featureToCreate:l,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-split-geometry"){const{data:r}=e;return f(["drawing-split-geometry","reviewing-features"],i,{"drawing-split-geometry":()=>({id:"drawing-split-geometry",async setUp(){const t=b(r.originalFeature.geometry),i=M(t,e.defaultSplitterGeometryType),a=e._sketchViewModel;e.addHandles(n(()=>a,"create",t=>{if("complete"===t.state){const o=t.graphic?.geometry;if(!V(o))return E().warn("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting."),void a.create(i);r.splitterGeometry=o,e.next()}}),this.id),await a.create(i)},async tearDown(){e.removeHandles(this.id)}}),"reviewing-features":()=>({id:"reviewing-features",async setUp(){const i=r.splitterGeometry;if(!i)throw new t("editing:missing-splitter-geometry","The `splitterGeometry` property of the workflow's data must be set in order to start the 'reviewing-features' step.");const a=await e._executeSplit(i),{featureToCreate:o,featureToUpdate:s}=await e._createAndInitializeEdits(a),l=await e._displayFeatureGraphics(s,o);e.addHandles(l,this.id)},async tearDown(){e._highlightHelper?.removeAll()}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:o}=this,n=a.viewModel.view,p=[];if(!e||!t||!n)return i();const d=s(i=>Promise.all([v(e,this._webStyleCache,i),v(t,this._webStyleCache,i)]));return await d("2d"===n.type?n.scale:null),"2d"===n.type&&p.push(l(()=>n.scale,e=>d(e))),o.add(t),p.push(i(()=>o.remove(t))),p.push(await _(o,n,a.originalFeature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{originalFeature:r}=i,a=r.geometry;if(!a)throw new t("editing:feature-has-no-geometry","Cannot split the provided feature as it has no geometry.");const o=await S(a,e);if(!o||!o.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return o}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=i?.spatialReference??e.editorItem.layer.spatialReference,a=new j({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:r,timeZone:e.timeZone});this._formViewModel=a,this.addHandles(n(()=>a,"value-change",({feature:r,fieldName:a,value:o})=>{r&&(e.getEditsForFeature(r)?.setAttribute(a,o),v(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new u({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"splitFeatureWorkflow-internal"});return this._graphicsLayer=i,t?.map.add(i),i}_initializeSketchViewModel(e){const{data:t}=this,{view:i}=t.viewModel;this._sketchViewModel=new G({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}_makeSketchController(){return{enter:async()=>{const{activeFeature:e}=this;e&&this._highlightHelper?.add(e)},exit:()=>{this._highlightHelper?.removeAll()}}}async _setFeatureOnFormViewModel(e,t){const{data:i}=this,r=this._formViewModel;r.feature=e,"existing"===t?(r.editType="UPDATE",r.overrideInitialFeature(i.originalFeature)):r.editType="INSERT",await p(()=>!r.updating)}get test(){}};e([d()],H.prototype,"activeFeature",null),e([d()],H.prototype,"defaultSplitterGeometryType",void 0),e([d()],H.prototype,"featureFormViewModel",null),e([d()],H.prototype,"layer",null),e([d()],H.prototype,"parent",null),e([d()],H.prototype,"parentLayer",null),e([d()],H.prototype,"type",void 0),e([d()],H.prototype,"updating",null),e([d()],H.prototype,"_activeFeature",void 0),e([d()],H.prototype,"_formViewModel",void 0),e([d()],H.prototype,"_graphicsLayer",void 0),e([d()],H.prototype,"_highlightHelper",void 0),e([d()],H.prototype,"_sketchViewModel",void 0),H=T=e([h("esri.widgets.Editor.SplitFeatureWorkflow")],H);const I=H;function L(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),l=i.editorItem.layer;if(null==o||null==s)throw new t("editing:missing-features","Expected both a feature to update and a feature to add for the split operation.");r?.attributesModified||(o.attributes=F(o,i.editorItem.layer)),await e(l,{addFeatures:[s],updateFeatures:[o]})}}export{I as default};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r}from"../../core/handleUtils.js";import"../../core/has.js";import a from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import{debounce as s}from"../../core/promiseUtils.js";import{watch as l,on as n,whenOnce as p}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import u from"../../layers/GraphicsLayer.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as m}from"../../views/support/HighlightDefaults.js";import w from"./Edits.js";import g from"./SplitFeatureWorkflowData.js";import y from"./Workflow.js";import{assertSplitWorkflowCapabilities as f,createWorkflowSteps as _,swapForEditingSession as v,updateGraphicSymbolWhenRequired as F,makeMinimalAttributes as M}from"./workflowUtils.js";import{getCompatibleSpitterGeometryType as k,ensureSplittableGeometry as b,makeNewFeatureAttributes as S,splitGeometry as V,isSplitterGeometry as j}from"./support/splitFeatureUtils.js";import G from"../FeatureForm/FeatureFormViewModel.js";import T from"../Sketch/SketchViewModel.js";var E;const H=()=>a.getLogger("esri.widgets.Editor.SplitFeatureWorkflow");let I=E=class extends y{constructor(e){super(e),this.defaultSplitterGeometryType=null,this.type="split-feature",this._activeFeature=null,this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._sketchViewModel=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new c({view:e,highlightName:m}):null,this._initializeFeatureFormViewModel();const t=this._initializeGraphicsLayer();this._initializeSketchViewModel(t)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel.destroy(),this._sketchViewModel.destroy(),this._highlightHelper?.destroy()}get activeFeature(){return this._activeFeature}get featureFormViewModel(){return this._formViewModel}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if(f(s.editorItem),"reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=k(b(s.originalFeature.geometry),s.splitterGeometry.type);if(s.splitterGeometry.type!==e)throw new t("editing:incompatible-split-geometries",`Geometry of type '${s.splitterGeometry.type}' cannot be used to split geometry of type '${s.originalFeature.geometry?.type}'.`)}const l=new E({data:new g(s),defaultSplitterGeometryType:a,onCommit:x(e.applyEdits)});return l._set("steps",E._createWorkflowSteps(l,o)),l}async enter(){}exit(){if("reviewing-features"!==this.stepId)throw new t("editing:invalid-exit-state","The SplitFeatureWorkflow can only be exited when in the 'reviewing-features' step.")}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data,a=this._highlightHelper;a?.removeAll();const o=i?r.getEditsForFeature(i):null;if(o&&(o.submittable=this._formViewModel.submittable),this._activeFeature=e,null==e)return;const s=this.data.getRoleForFeature(e);if(!s)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");a?.add(e),await this._setFeatureOnFormViewModel(e,s)}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.originalFeature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new w({feature:o});i.existingFeatureEdits=s,s.trackChanges(r),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const l=r.clone();l.geometry=e,l.attributes=S(r.attributes,i.editorItem.layer);const n=new w({feature:l});return i.newFeatureEdits=n,n.trackChanges(),await this._setFeatureOnFormViewModel(l,"new"),n.submittable=a.submittable,{featureToCreate:l,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-splitter-geometry"){const{data:r}=e;return _(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const t=b(r.originalFeature.geometry),i=k(t,e.defaultSplitterGeometryType),a=e._sketchViewModel;e.addHandles(n(()=>a,"create",t=>{if("complete"===t.state){e._graphicsLayer.removeAll();const o=t.graphic?.geometry;if(!j(o))return H().warn("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting."),void a.create(i);r.splitterGeometry=o,e.next()}}),this.id),await a.create(i)},async tearDown(){e.removeHandles(this.id)}}),"reviewing-features":()=>({id:"reviewing-features",async setUp(){const i=r.splitterGeometry;if(!i)throw new t("editing:missing-splitter-geometry","The `splitterGeometry` property of the workflow's data must be set in order to start the 'reviewing-features' step.");const a=await e._executeSplit(i),{featureToCreate:o,featureToUpdate:s}=await e._createAndInitializeEdits(a),l=await e._displayFeatureGraphics(s,o);e.addHandles(l,this.id)},async tearDown(){e._highlightHelper?.removeAll()}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:o}=this,n=a.viewModel.view,p=[];if(!e||!t||!n)return i();const d=s(i=>Promise.all([F(e,this._webStyleCache,i),F(t,this._webStyleCache,i)]));return await d("2d"===n.type?n.scale:null),"2d"===n.type&&p.push(l(()=>n.scale,e=>d(e))),o.add(t),p.push(i(()=>o.remove(t))),p.push(await v(o,n,a.originalFeature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{originalFeature:r}=i,a=r.geometry;if(!a)throw new t("editing:feature-has-no-geometry","Cannot split the provided feature as it has no geometry.");const o=await V(a,e);if(!o||!o.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return o}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=i?.spatialReference??e.editorItem.layer.spatialReference,a=new G({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:r,timeZone:e.timeZone});this._formViewModel=a,this.addHandles(n(()=>a,"value-change",({feature:r,fieldName:a,value:o})=>{r&&(e.getEditsForFeature(r)?.setAttribute(a,o),F(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new u({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"splitFeatureWorkflow-internal"});return this._graphicsLayer=i,t?.map.add(i),i}_initializeSketchViewModel(e){const{data:t}=this,{view:i}=t.viewModel;this._sketchViewModel=new T({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}_makeSketchController(){return{enter:async()=>{const{activeFeature:e}=this;e&&this._highlightHelper?.add(e)},exit:()=>{this._highlightHelper?.removeAll()},viewModel:this._sketchViewModel}}async _setFeatureOnFormViewModel(e,t){const{data:i}=this,r=this._formViewModel;r.feature=e,"existing"===t?(r.editType="UPDATE",r.overrideInitialFeature(i.originalFeature)):r.editType="INSERT",await p(()=>!r.updating)}get test(){}};e([d()],I.prototype,"activeFeature",null),e([d()],I.prototype,"defaultSplitterGeometryType",void 0),e([d()],I.prototype,"featureFormViewModel",null),e([d()],I.prototype,"layer",null),e([d()],I.prototype,"parent",null),e([d()],I.prototype,"parentLayer",null),e([d()],I.prototype,"type",void 0),e([d()],I.prototype,"updating",null),e([d()],I.prototype,"_activeFeature",void 0),e([d()],I.prototype,"_formViewModel",void 0),e([d()],I.prototype,"_graphicsLayer",void 0),e([d()],I.prototype,"_highlightHelper",void 0),e([d()],I.prototype,"_sketchViewModel",void 0),I=E=e([h("esri.widgets.Editor.SplitFeatureWorkflow")],I);const L=I;function x(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),l=i.editorItem.layer;if(null==o||null==s)throw new t("editing:missing-features","Expected both a feature to update and a feature to add for the split operation.");r?.attributesModified||(o.attributes=M(o,i.editorItem.layer)),await e(l,{addFeatures:[s],updateFeatures:[o]})}}export{L as default};
@@ -0,0 +1,4 @@
1
+ import "../../interfaces";
2
+
3
+ import SplitFeatureWorkflowData = __esri.SplitFeatureWorkflowData;
4
+ export default SplitFeatureWorkflowData;
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import o from"../../core/Error.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import i from"./Edits.js";import{findEditorItemForLayer as a}from"./workflowUtils.js";var p;let d=p=class extends e{constructor(t){super(t),this.association=null,this.editorItem=null,this.edits=null,this.parent=null,this.featureFormCallbacks=null,this.viewModel=null,this.readOnly=!1}get attachmentsCapabilities(){const t=this.editorItem.capabilities.update.attachments.enabled;return{editing:!0,operations:{add:t,update:t,delete:t}}}get formTemplate(){return this.editorItem.formTemplate}static async create(t){const e=p._makeConstructorProps(t);return new p(e)}static _makeConstructorProps(t){const{association:e,feature:r,parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l}=t,n=a(d.editorItems,r.sourceLayer);if(!n)throw new o("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified Graphic's layer");return{association:e,editorItem:n,edits:new i({feature:r}),parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l}}};t([r()],d.prototype,"association",void 0),t([r()],d.prototype,"attachmentsCapabilities",null),t([r({constructOnly:!0})],d.prototype,"editorItem",void 0),t([r()],d.prototype,"edits",void 0),t([r()],d.prototype,"formTemplate",null),t([r()],d.prototype,"parent",void 0),t([r()],d.prototype,"featureFormCallbacks",void 0),t([r()],d.prototype,"viewModel",void 0),t([r()],d.prototype,"readOnly",void 0),d=p=t([s("esri.widgets.Editor.UpdateRecordWorkflowData")],d);const l=d;export{l as default};
5
+ import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import o from"../../core/Error.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import i from"./Edits.js";import{findEditorItemForLayer as a}from"./workflowUtils.js";var p;let d=p=class extends e{constructor(t){super(t),this.association=null,this.editorItem=null,this.edits=null,this.parent=null,this.featureFormCallbacks=null,this.viewModel=null,this.readOnly=!1}get attachmentsCapabilities(){const t=this.editorItem.capabilities.update.attachments.enabled;return{editing:!0,operations:{add:t,update:t,delete:t}}}get formTemplate(){return this.editorItem.formTemplate}static async create(t){const e=p._makeConstructorProps(t);return new p(e)}static _makeConstructorProps(t){const{association:e,feature:r,parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l}=t,n=a(d.editorItems,r.sourceLayer);if(!n)throw new o("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified Graphic's layer");return{association:e,editorItem:n,edits:new i({feature:r}),parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l??!1}}};t([r()],d.prototype,"association",void 0),t([r()],d.prototype,"attachmentsCapabilities",null),t([r({constructOnly:!0})],d.prototype,"editorItem",void 0),t([r()],d.prototype,"edits",void 0),t([r()],d.prototype,"formTemplate",null),t([r()],d.prototype,"parent",void 0),t([r()],d.prototype,"featureFormCallbacks",void 0),t([r()],d.prototype,"viewModel",void 0),t([r()],d.prototype,"readOnly",void 0),d=p=t([s("esri.widgets.Editor.UpdateRecordWorkflowData")],d);const l=d;export{l as default};