// All material copyright ESRI, All Rights Reserved, unless otherwise specified.// See https://js.arcgis.com/4.6/esri/copyright.txt for details.//>>builtdefine("require exports ../core/tsSupport/extendsHelper ../core/tsSupport/decorateHelper ../core/typescript dojo/_base/lang dojo/when dojo/promise/all dojo/Deferred ../geometry/support/jsonUtils ./core/messageHandler ./core/errorMessages ./core/ExtensionBase ./FeatureActionFeatures".split(" "),function(v,w,p,k,l,q,e,m,f,r,g,d,t,u){returnfunction(n){functionc(){vara=n.call(this)||this;a.mapWidgetProxy=null;a.mapWidgetId=null;a.dataSourceProxies=null;a.hasFeatureActions=!1;a.hasDefaultFeatureAction=!1;a.featureActionFeatures=null;a.dataSourceConfigs=null;returna}p(c,n);c.prototype._initializeResponseReceived=function(a){varb=this;a&&"object"===typeofa||(newf).reject(Error(d.invalidArguments));returnthis.inherited(arguments).then(function(){b.hasFeatureActions=a.supportFeatureActions;b.hasDefaultFeatureAction=a.supportDefaultFeatureAction;varh=e(b._setupMapWidgetProxy()),c=e(b._setupDataSourceProxies()),d=e(b._setupFeatureActionFeatures());returnm([h,c,d])})};c.prototype._setupDataSourceProxies=function(){vara=this;this.dataSourceConfigs||(this.dataSourceConfigs=[]);if(0!==this.dataSourceConfigs.length){varb=[];this.dataSourceConfigs.forEach(function(h){b.push(a.getDataSourceProxy(h.dataSourceId))});returnm(b).then(function(b){a.dataSourceProxies=b})}};c.prototype._setupMapWidgetProxy=function(){vara=this;if(this.mapWidgetId)returnthis.getMapWidgetProxy(this.mapWidgetId).then(function(b){a.mapWidgetProxy=b})};c.prototype._setupFeatureActionFeatures=function(){vara=this;if(this.hasFeatureActions&&0!==this.dataSourceConfigs.length){varb=this.dataSourceConfigs[0].dataSourceId;if(this.featureActionFeatures)this.featureActionFeatures.dataSourceProxy.id!==b&&(this.featureActionFeatures=null);elsereturnthis.getDataSourceProxy(b).then(function(b){a.featureActionFeatures=newu(b)})}elsethis.featureActionFeatures=null};c.prototype._messageReceived=function(a){switch(a.functionName.toLowerCase()){case"datasourceexpired":case"datasourceupdated":this._dataSourceExpired(a.args.dataSourceId);break;case"drawcomplete":this._drawComplete(a.args)}};c.prototype._dataSourceExpired=function(a){varb=this;this.getDataSourceProxy(a).then(function(a){varc=b.getDataSourceConfig(a);b.dataSourceExpired(a,c);b.emit("data-source-expired",{dataSourceProxy:a,dataSourceConfig:c})})};c.prototype.dataSourceExpired=function(a,b){};c.prototype.getDataSourceConfig=function(a){if(!this._isHostInitialized())throwError(d.hostNotReady);varb=a;"object"===typeofa&&(b=a.id);for(a=0;a<this.dataSourceConfigs.length;a++)if(this.dataSourceConfigs[a].dataSourceId===b)returnthis.dataSourceConfigs[a];returnnull};c.prototype._dataSourceRemoved=function(a){this.inherited(arguments);if(this.dataSourceConfigs){for(varb=!1,c=0;c<this.dataSourceConfigs.length&&!b;c++)this.dataSourceConfigs[c].dataSourceId===a&&(this.dataSourceConfigs.splice(c,1),b=!0);b&&this._setupFeatureActionFeatures()}};c.prototype._mapWidgetRemoved=function(a){this.inherited(arguments);this.mapWidgetProxy&&this.mapWidgetProxy.id===a&&(this.mapWidgetId=this.mapWidgetProxy=null)};c.prototype.activateDrawingToolbar=function(a,b){if(!this._isHostInitialized())return(newf).reject(Error(d.hostNotReady));b||(b=this.mapWidgetProxy);if(!b)return(newf).reject(Error(d.invalidArguments));varc=b;"object"===typeofb&&(c=b.id);returng._sendMessageWithReply({functionName:"activateDrawingToolbar",args:q.mixin({mapWidgetId:c},a)}).then(function(){return!0},function(){return!1})};c.prototype.deactivateDrawingToolbar=function(a){if(!this._isHostInitialized())throwError(d.hostNotReady);a||(a=this.mapWidgetProxy);if(!a)throwError(d.invalidArguments);varb=a;"object"===typeofa&&(b=a.id);g._sendMessage({functionName:"deactivateDrawingToolbar",args:{mapWidgetId:b}})};c.prototype._drawComplete=function(a){a.cancelled?(this.drawingToolbarDeactivated(),this.emit("drawing-toolbar-deactivated")):(a=r.fromJSON(a.geometry),this.toolbarDrawComplete(a),this.emit("toolbar-draw-complete",{geometry:a}))};c.prototype.toolbarDrawComplete=function(a){};c.prototype.drawingToolbarDeactivated=function(){};c.prototype.executeDefaultFeatureAction=function(a){if(!this._isHostInitialized())throwError(d.hostNotReady);if(this.hasDefaultFeatureAction&&Array.isArray(a)&&0!==a.length&&Array.isArray(this.dataSourceProxies)&&0!==this.dataSourceProxies.length){varb=this.dataSourceProxies[0],c=[];a.forEach(function(a){vard=a;if("object"===typeofa){if(!a.attributes||!a.attributes[b.objectIdFieldName])return;d=a.attributes[b.objectIdFieldName]}c.push(d)});0!==c.length&&g._sendMessage({functionName:"executeDefaultFeatureAction",args:{dataSourceId:b.id,objectIds:c}})}};k([l.shared("esri.opsdashboard.WidgetProxy")],c.prototype,"declaredClass",void0);returnc=k([l.subclass()],c)}(t)});