import type Graphic from "../../Graphic.js";
import type Accessor from "../../core/Accessor.js";
import type EditorViewModel from "./EditorViewModel.js";
import type Edits from "./Edits.js";
import type EditorItem from "./support/EditorItem.js";
import type { SplitterGeometry } from "./types.js";

export interface SplitFeatureWorkflowDataProperties extends Partial<Pick<SplitFeatureWorkflowData, "existingFeatureEdits" | "feature" | "newFeatureEdits" | "splitterGeometry" | "viewModel">> {
  /**
   * The `EditorItem` object from `EditorViewModel` corresponding to the
   *  layer being updated.
   */
  editorItem?: EditorItem;
}

/**
 * This object contains data for the [SplitFeatureWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/SplitFeatureWorkflow/).
 * This is accessed via the property
 * [SplitFeatureWorkflow.data](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/SplitFeatureWorkflow/#data).
 *
 * @since 4.34
 * @see [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/)
 * @see [EditorViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/EditorViewModel/)
 * @see [Workflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/Workflow/)
 * @see [SplitFeatureWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/SplitFeatureWorkflow/)
 */
export default class SplitFeatureWorkflowData extends Accessor {
  constructor(properties: SplitFeatureWorkflowDataProperties);
  /**
   * The `EditorItem` object from `EditorViewModel` corresponding to the
   *  layer being updated.
   */
  get editorItem(): EditorItem;
  /**
   * Information about the feature to be updated as a result of the split operation.
   *
   * A split workflow results in two edits: the existing feature is updated to
   * have one of the geometries resulting from the split, and a new feature is
   * created with the other geometry. This property references the feature that
   * will be updated.
   *
   * @see [newFeatureEdits](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/SplitFeatureWorkflowData/#newFeatureEdits)
   */
  accessor existingFeatureEdits: Edits | null | undefined;
  /**
   * The feature to be split.
   *
   * This feature's [Graphic.attributes](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#attributes) object
   * must contain all fields for which values are set on the feature, and its
   * [Graphic.geometry](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#geometry) must be full resolution. If
   * the [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) was obtained from a layer view
   * query, it is likely that the geometry is not full resolution and that the
   * attributes do not contain all fields.
   */
  accessor feature: Graphic;
  /**
   * Information about the feature to be created as a result of the split operation.
   *
   * @see [newFeatureEdits](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/SplitFeatureWorkflowData/#newFeatureEdits)
   */
  accessor newFeatureEdits: Edits | null | undefined;
  /** The geometry to be used to split the geometry of the initial feature. */
  accessor splitterGeometry: SplitterGeometry | null | undefined;
  /** The associated [EditorViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/EditorViewModel/) for this workflow. */
  accessor viewModel: EditorViewModel;
  /**
   * Returns the instance of `Edits` corresponding to the given feature. Returns
   * the value of either [existingFeatureEdits](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/SplitFeatureWorkflowData/#existingFeatureEdits) or
   * [newFeatureEdits](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/SplitFeatureWorkflowData/#newFeatureEdits), depending on which feature is
   * passed. If `feature` is not one of the two
   * [Graphics](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) generated by the workflow, this method
   * returns `null`.
   *
   * The primary way of accessing the Graphics generated by the workflow is
   * through the [Edits.feature](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/Edits/#feature)
   * property of the [Edits](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/Edits/) objects
   * referenced by [existingFeatureEdits](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/SplitFeatureWorkflowData/#existingFeatureEdits) and
   * [newFeatureEdits](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/SplitFeatureWorkflowData/#newFeatureEdits). This method is useful if you obtain
   * one of the Graphics outside of this context and need to access the Edits
   * object it belongs to.
   *
   * @param feature - Either of the two [Graphics](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) created by the workflow.
   */
  getEditsForFeature(feature: Graphic): Edits | null;
  /**
   * Identifies whether the given [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) represents
   * the feature to be updated or the feature to be created.
   *
   * @param feature - Either of the two [Graphics](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) created by the workflow.
   * @returns The role of the feature in the split
   * operation, or `null` if the feature does not belong to this workflow.
   */
  getRoleForFeature(feature: Graphic): "existing" | "new" | null;
}