/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as i}from"tslib";import t from"../../../core/Accessor.js";import{createTask as o}from"../../../core/asyncUtils.js";import{abortMaybe as e,destroyMaybe as s}from"../../../core/maybe.js";import{whenOrAbort as l}from"../../../core/promiseUtils.js";import{watch as r,syncAndInitial as a}from"../../../core/reactiveUtils.js";import{property as n,subclass as p}from"../../../core/accessorSupport/decorators.js";let m=class extends t{constructor(i){super(i),this._implementation=null,this._loadingTask=null}initialize(){this.addHandles(r(()=>({tool:this.tool,view:this.tool.viewModel.view,visible:this.tool.visible&&!!this.tool.viewModel.view?.ready}),({tool:i,view:t,visible:o})=>{null!=t&&o?this._show(t,i):this._hide()},a))}destroy(){this._hide()}get updating(){return!(this._loadingTask?.finished??1)||(this._implementation?.updating??!1)}_show(i,t){this._loadingTask=e(this._loadingTask),this._loadingTask=o(async o=>{if("2d"===i.type){const e=import("./ElevationProfileView2D.js"),s=(await l(e,o)).ElevationProfileView2D;this._implementation=new s(i,t)}else if("3d"===i.type){const e=import("./ElevationProfileView3D.js"),s=(await l(e,o)).ElevationProfileView3D;this._implementation=new s(i,t)}})}_hide(){this._loadingTask=e(this._loadingTask),this._implementation=s(this._implementation)}};i([n()],m.prototype,"tool",void 0),i([n()],m.prototype,"updating",null),i([n()],m.prototype,"_implementation",void 0),i([n()],m.prototype,"_loadingTask",void 0),m=i([p("esri.widgets.ElevationProfile.support.ElevationProfileView")],m);export{m as ElevationProfileView};
