@arcgis/map-components
Version:
ArcGIS Map Components
2 lines • 5.77 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import a from"./HFRXDFTO.js";import{a as h}from"./PC4PAQXQ.js";import{p as c}from"./WUJCCZQC.js";export default $arcgis.t(([{forceInteractive:m},f,{property:o,subclass:g},{ignoreAbortErrors:A},{when:I,watch:v,on:O,whenOnce:F},{getDefaultUnitForView:b},{b:u,c:d,d:_,e:y}])=>{var T=Object.defineProperty,R=Object.getOwnPropertyDescriptor,n=(s,i,t,a)=>{for(var r=a>1?void 0:a?R(i,t):i,l=s.length-1,p;l>=0;l--)(p=s[l])&&(r=(a?p(i,t,r):p(r))||r);return a&&r&&T(i,t,r),r},w=Symbol("interactiveHandle"),e=class extends f{constructor(){super({}),this.operationState="inactive",this._ownsAnalysis=!1,this.shouldForceInteractive=!0,this._changeFromReconnect=!1,this._userOperationInfo=null,this._loggedUnsupportedErrorMessage=!1}initialize(){this._set("analysis",this.constructAnalysis()),this._ownsAnalysis=!0;let s=()=>{!this._changeFromReconnect&&!this._viewHasAnalysis&&(this._ownsAnalysis=!1);let i=!this._changeFromReconnect;this._changeFromReconnect=!1,i&&this._scheduleViewReconnect()};this.addHandles([I(()=>this.view?.ready&&!this.supported,()=>{this._loggedUnsupportedErrorMessage||c("error",this,this.unsupportedErrorMessage)},{sync:!0,initial:!0}),v(()=>[this.analysis,this._viewHasAnalysis],s,{sync:!0}),O(()=>this.view,"analysis-view-destroy",i=>{i.analysis===this.analysis&&s()}),v(()=>({view:this.view,ready:!!this.view?.ready,supported:this.supported}),({view:i},t)=>{let a=t?.view;i!==a&&(this._userOperationInfo=h(this._userOperationInfo),this._disconnectFromView(a)),this._scheduleViewReconnect()},{sync:!0,initial:!0})])}destroy(){this._reconnectViewTask=h(this._reconnectViewTask),this._userOperationInfo=h(this._userOperationInfo),this.analysisView!=null&&(this.analysisView.visible=void 0),this._disconnectFromView(this.view),this._set("view",null),this._ownsAnalysis&&this.analysis?.destroy()}get defaultMeasurementSystem(){return this.view?.ready?b(this.view):"metric"}get active(){return this._userOperationInfo?.state==="running"}set analysis(s){s!==this._get("analysis")&&(this._userOperationInfo=h(this._userOperationInfo),this._disconnectFromView(this.view),this._setExternalAnalysis(s),this._scheduleViewReconnect())}get connectingToView(){return!!this._reconnectViewTask}get disabled(){return!this.view?.ready||!this.supported}set hideVisualization(s){this._set("hideVisualization",s),this.analysisView&&(this.analysisView.visible=!s)}get ready(){return!!this.analysisView&&!this.connectingToView}get supported(){return!this.view||this.supportedViewType==="both"||this.view.type===this.supportedViewType}get _viewHasAnalysis(){let{view:s}=this;return s?.analyses.includes(this.analysis)===!0}clear(){this._userOperationInfo=h(this._userOperationInfo),this.clearAnalysis()}async start(s){if(this.hideVisualization){c("warn",this,"Cannot start analysis when not visible");return}this.stop(),s?.clear!==!1&&this.clear();let i={task:null,abort:null,state:"pending"},t=y(async a=>{if(i.state="wait-for-view-ready",await F(()=>this.ready,a),i.state="running",!this.analysisView||!this.view)return;this.operationState="active";let r=s?.operation?.({signal:a})??this.place({signal:a});await A(r)});return t.promise.finally(()=>{(this._userOperationInfo===i||!this._userOperationInfo)&&(this.operationState="inactive")}),i.task=t,i.abort=()=>t.abort(),this._userOperationInfo=i,await t.promise}stop(){this._userOperationInfo=h(this._userOperationInfo)}place(s){throw new Error("place() not implemented for this analysis view model")}clearAnalysis(){}onConnectToAnalysisView(s){}onDisconnectFromAnalysisView(){}_scheduleViewReconnect(){this._reconnectViewTask=h(this._reconnectViewTask);let s=y(async i=>{try{await this._reconnectView(i)}catch(t){if(u(i),!_(t)){c("warn",this,`Failed to use analysis in view model. ${String(t)}`);return}throw t}finally{s===this._reconnectViewTask&&(this._reconnectViewTask=void 0)}});this._reconnectViewTask=s}async _reconnectView(s){let{view:i}=this,t=i?.ready&&this.supported,a=this.analysis;if(this._userOperationInfo=V(this._userOperationInfo),this._disconnectFromView(i),!t||!i||!a)return;this._ownsAnalysis&&(this._changeFromReconnect=!0,i.analyses.add(a));let r=await i.whenAnalysisView(a);if(this.analysisView=r,d(s)){this._userOperationInfo=V(this._userOperationInfo);return}r.visible=!this.hideVisualization,this.shouldForceInteractive&&this.addHandles(m(r),w),this.onConnectToAnalysisView(r)}_disconnectFromView(s){this._ownsAnalysis&&s?.analyses.includes(this.analysis)&&(this._changeFromReconnect=!0,this.clearAnalysis(),s.analyses.remove(this.analysis)),this.onDisconnectFromAnalysisView(),this.removeHandles(w),this.analysisView=void 0}_setExternalAnalysis(s){this.analysisView&&!this._ownsAnalysis&&(this.analysisView.visible=void 0,this.removeHandles(w)),this.analysisView=void 0,this._ownsAnalysis=!1,this._set("analysis",s),this._changeFromReconnect=!1}};n([o()],e.prototype,"defaultMeasurementSystem",1);n([o()],e.prototype,"active",1);n([o()],e.prototype,"analysis",1);n([o()],e.prototype,"connectingToView",1);n([o()],e.prototype,"disabled",1);n([o()],e.prototype,"hideVisualization",1);n([o()],e.prototype,"operationState",2);n([o()],e.prototype,"ready",1);n([o()],e.prototype,"supported",1);n([o()],e.prototype,"view",2);n([o()],e.prototype,"_ownsAnalysis",2);n([o()],e.prototype,"_viewHasAnalysis",1);n([o()],e.prototype,"_reconnectViewTask",2);n([o()],e.prototype,"analysisView",2);n([o()],e.prototype,"shouldForceInteractive",2);e=n([g("esri.components.support.AnalysisViewModel")],e);function V(s){return s?.state==="running"?(s.abort(),null):s}return e},"applications/Components/analysisUtils","core/Accessor","core/accessorSupport/decorators","core/promiseUtils","core/reactiveUtils","applications/Components/getDefaultUnits",a)