/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../core/Error","../../../core/maybe","../../../core/promiseUtils","../../../core/reactiveUtils","../../../core/accessorSupport/decorators/property","../../../core/accessorSupport/decorators/subclass","./LayerView3D","../../layers/LayerView"],(function(e,s,i,t,a,n,r,o,l,y,c){"use strict";const u=e=>Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"})),h="analysis-view-handles";let w=function(i){function o(e){var s;return(s=i.call(this,e)||this).type="line-of-sight-3d",s._analysisModules={"line-of-sight":null},s}s._inheritsLoose(o,i);var l=o.prototype;return l.initialize=function(){this.handles.add(r.watch((()=>this.layer.analysis),(e=>{this._destroyAnalysisView(),a.isSome(e)&&this._createAnalysisView(e)}),r.syncAndInitial),h)},l.destroy=function(){this.handles.remove(h),this._destroyAnalysisView()},l.whenAnalysisView=function(){var e=s._asyncToGenerator((function*(){if(a.isSome(this.analysisView))return this.analysisView;if(a.isSome(this._createAnalysisViewTask))return this._createAnalysisViewTask.promise;throw new t("layerview:no-analysisview-for-analysis","The analysis has not been set on the LineOfSightLayer of this layer view")}));function i(){return e.apply(this,arguments)}return i}(),l.isUpdating=function(){return a.isSome(this._createAnalysisViewTask)||a.isSome(this.analysisView)&&this.analysisView.updating},l._createAnalysisView=function(e){var i=this;const t=n.createTask(function(){var a=s._asyncToGenerator((function*(s){return i.analysisView=yield i._createAnalysisViewPromise(e,s),i._createAnalysisViewTask===t&&(i._createAnalysisViewTask=null),i.analysisView}));return function(e){return a.apply(this,arguments)}}());this._createAnalysisViewTask=t},l._destroyAnalysisView=function(){this.analysisView=a.destroyMaybe(this.analysisView),this._createAnalysisViewTask=a.abortMaybe(this._createAnalysisViewTask)},l._createAnalysisViewPromise=function(){var e=s._asyncToGenerator((function*(e,s){const i=e.type;let r=this._analysisModules[i];if(a.isNone(r)){const e=yield this._loadAnalysisModule(i);this._analysisModules[i]=e,r=e}const o=new r.default({analysis:e,view:this.view,parent:this});if(yield o.when(),n.isAborted(s))throw o.destroy(),new t("layerview:no-analysisview-for-analysis","The analysis has not been added to the LineOfSightLayer of this layer view",{analysis:e});return o}));function i(s,i){return e.apply(this,arguments)}return i}(),l._loadAnalysisModule=function(s){return"line-of-sight"===s?new Promise(((s,i)=>e(["../analysis/LineOfSightAnalysisView3D"],(e=>s(u(e))),i))):null},o}(y.LayerView3D(c));i.__decorate([o.property()],w.prototype,"type",void 0),i.__decorate([o.property()],w.prototype,"layer",void 0),i.__decorate([o.property()],w.prototype,"analysisView",void 0),i.__decorate([o.property()],w.prototype,"_createAnalysisViewTask",void 0),w=i.__decorate([l.subclass("esri.views.3d.layers.LineOfSightLayerView3D")],w);return w}));
