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