/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t}from"tslib";import{watch as e,sync as o}from"../../../../core/reactiveUtils.js";import{property as s,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{createViewshedPlacementPointPluginConfiguration as i}from"./ViewshedPlacementPointPlugin.js";import{PluginBase as n}from"../../../draw/plugins/PluginBase.js";let l=class extends n{constructor(t){super(t),this._downstreamPlugin=null,this._step="observer"}start(t){super.start(t),t.session.appendOrReplacePart(null,[]),this._restartDownstreamPlugin()}beforeAttachPlugin(t){return{geometryType:"point",useStandaloneSession:!0}}beforeComplete(){return{downstreamPluginCompletionMode:"target"===this._step&&this._downstreamPlugin?.hasCommittedPoint?"complete":"cancel"}}attachPlugin(t){this._downstreamPlugin=t,"target"===t.step&&this.addHandles([e(()=>t.outputMapPosition,t=>{null==t||this._isComplete||this.onTargetPreview(t)},o)],this._downstreamHandlesKey)}detachPlugin(t,e){if(this._downstreamPlugin===t&&(this._downstreamPlugin=null),this.removeHandles(this._downstreamHandlesKey),"complete"!==e)return;const o=t.outputMapPosition;if(null!=o){if("observer"===t.step)return this.onObserverComplete(o),this._step="target",void this._restartDownstreamPlugin();if(this.onTargetComplete(o),"multiple"===this.mode)return this._step="observer",void this._restartDownstreamPlugin();this._context?.requestComplete()}}_restartDownstreamPlugin(){const t=i(this._step);this._context?.requestBeginDownstreamPlugin(t,{cancelExisting:!0})}};function a(t){return{uniqueId:Symbol("viewshed-placement-root-plugin"),kind:["multipart"],geometryType:"multipoint",hidden:!0,localizationKey:"viewshed-root",icon:"point",create:()=>new l(t)}}t([s({constructOnly:!0})],l.prototype,"mode",void 0),t([s({constructOnly:!0})],l.prototype,"onObserverComplete",void 0),t([s({constructOnly:!0})],l.prototype,"onTargetComplete",void 0),t([s({constructOnly:!0})],l.prototype,"onTargetPreview",void 0),t([s()],l.prototype,"_downstreamPlugin",void 0),t([s()],l.prototype,"_step",void 0),l=t([r("esri.views.3d.analysis.Viewshed.ViewshedPlacementRootPlugin")],l);export{a as createViewshedPlacementRootPluginConfiguration};
