// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/analysis/AnalysisBase","require dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/json dojo/has dojo/json dojo/Deferred dojo/promise/all dojo/when dojo/data/ItemFileWriteStore dojo/string dojo/Evented dojo/_base/kernel dojo/Stateful ../../kernel ../../lang ../../request ../../tasks/Geoprocessor dojo/i18n!../../nls/jsapi ./utils ./storageUtils ../../IdentityManager".split(" "),function(r,p,e,l,g,y,C,n,w,D,E,t,z,A,B,h,f,k,u,q,m,x){p=p([B,z],{declaredClass:"esri.dijit.analysis.AnalysisBase",
isOutputLayerItemUpdated:!1,analysisGpServer:null,toolName:null,portalUrl:null,jobParams:null,itemParams:null,gp:null,resultParameter:null,signInPromise:null,getResultLyrInfos:!1,checkCreditLimits:!1,_jobInfo:null,_popupInfo:null,_toolServiceUrl:null,_counter:null,_analysisType:"feature",doRefreshItem:!0,doSaveJobInfo:!1,doSaveInStorage:!1,constructor:function(a){this.isOutputLayerItemUpdated=!1;this._rids=[];this._counter=0;this._popupInfo=[];a.analysisGpServer?this._signIn(a.analysisGpServer):a.portalUrl&&
(this.portalUrl=a.portalUrl,this._signIn(a.portalUrl,!0));this.i18n={};e.mixin(this.i18n,q.common);e.mixin(this.i18n,q.analysisTools);e.mixin(this.i18n,q.analysisMsgCodes);e.mixin(this.i18n,q.analysisSettings);this.signInPromise.then(e.hitch(this,this._initErrorHelpMap))},execute:function(a){this.jobParams=a.jobParams;this.jobParams.OutputName?this.itemParams=a.itemParams:(this.itemParams=null,this.jobParams.resultName=this.get("resultName"));this._analysisType=a.analysisType||"feature";f.isDefined(a.isSpatioTemporalDataStore)&&
(this._isSpatioTemporalDataStore=m.settingsVM&&m.settingsVM.datastore&&"CopyToDataStore"!==this.toolName?"BDS"===m.settingsVM.datastore:a.isSpatioTemporalDataStore);this.signInPromise.then(e.hitch(this,this._checkUser))},_checkUser:function(){var a;if(a=h.id.findCredential(this.portalUrl).userId)a=this.portalUrl+"/sharing/rest/community/users/"+a,k({url:a,content:{f:"json"}}).then(e.hitch(this,this._handleUserProfileResponse),e.hitch(this,function(a){this.emit("job-fail",{message:a.message+(a.details?
a.details.toString():""),jobParams:this.jobParams})}))},_handleUserProfileResponse:function(a){if(f.isDefined(a)&&f.isDefined(a.orgId))if(-1===l.indexOf(["account_admin","account_publisher","org_admin","org_publisher"],a.role))this.emit("job-fail",{message:this.i18n.pubRoleMsg,messageCode:"AB_0001",jobParams:this.jobParams});else if(f.isDefined(a.availableCredits)&&this.get("checkCreditLimits")){var b,d={},c;for(b in this.jobParams)this.jobParams.hasOwnProperty(b)&&("object"===typeof this.jobParams[b]?
d[b]=g.toJson(this.jobParams[b]):-1!==l.indexOf(["measurementtype"],b.toLowerCase())&&"StraightLine"!==this.jobParams[b]?(c=g.fromJson(this.jobParams[b]),d[b]=c?c.name.replace(/[\s~`!#$%\^&*+=\-\[\]\\';,\/{}|\\":<>\?]/g,""):"DrivingTime"):d[b]=this.jobParams[b]);this.getCreditsEstimate(this.toolName,d).then(e.hitch(this,function(b){var c=b&&f.isDefined(b.cost)?b.cost:b.maximumCost;f.isDefined(c)&&a.availableCredits>c?f.isDefined(this.itemParams)?this._checkServiceName(a.orgId):(this.emit("start",
this.jobParams),this._submitGpJob()):b&&b.messageCode&&b.message?(c=f.isDefined(this.i18n[b.messageCode])?this.i18n[b.messageCode]:b.message,c=f.isDefined(b.params)?t.substitute(c,b.params):c,this.emit("job-fail",{message:c,messageCode:"AB_0001",jobParams:this.jobParams})):this.emit("job-fail",{message:this.i18n.insufficientCreditsMsg,messageCode:"AB_0001",jobParams:this.jobParams})}))}else f.isDefined(this.itemParams)?this._checkServiceName(a.orgId):(this.emit("start",this.jobParams),this._submitGpJob());
else this.emit("job-fail",{message:this.i18n.orgUsrMsg,jobParams:this.jobParams})},_checkServiceName:function(a){var b;h.id.findCredential(this.portalUrl);a=this.portalUrl+"/sharing/rest/portals/"+a+"/isServiceNameAvailable";b=g.fromJson(this.jobParams.OutputName);this.isSingleTenant&&f.isDefined(b.serviceProperties)&&f.isDefined(b.serviceProperties.name)&&(b.serviceProperties.name=b.serviceProperties.name.replace(/[\s~`!#$%\^&*+=\-\[\]\\';,\/{}|\\":<>\?\.]/g,"_"),this.jobParams.OutputName=g.toJson(b));
k({url:a,content:{name:b.serviceProperties.name,type:"raster"===this._analysisType?"Image Service":"Feature Service",f:"json"}}).then(e.hitch(this,function(a){a.available?("raster"===this._analysisType?this._createImageService():this._createService(),this.emit("start",this.jobParams)):this.emit("job-fail",{message:this.i18n.servNameExists,type:"warning",messageCode:"AB_0002",jobParams:this.jobParams})}),e.hitch(this,function(a){this.emit("job-fail",{message:a.message+(a.details?a.details.toString():
""),jobParams:this.jobParams})}))},_createService:function(){var a,b,d;a=h.id.findCredential(this.portalUrl).userId;b=g.fromJson(this.jobParams.OutputName);a&&(d=this.itemParams.folder,a=this.portalUrl+"/sharing/rest/content/users/"+a+(d&&"/"!==d?"/"+d:"")+"/createService",b={createParameters:g.toJson({currentVersion:10.2,serviceDescription:"",hasVersionedData:!1,supportsDisconnectedEditing:!1,hasStaticData:!0,maxRecordCount:2E3,supportedQueryFormats:"JSON",capabilities:"Query",description:"",copyrightText:"",
allowGeometryUpdates:!1,syncEnabled:!1,editorTrackingInfo:{enableEditorTracking:!1,enableOwnershipAccessControl:!1,allowOthersToUpdate:!0,allowOthersToDelete:!0},xssPreventionInfo:{xssPreventionEnabled:!0,xssPreventionRule:"InputOnly",xssInputRule:"rejectInvalid"},tables:[],name:b.serviceProperties.name}),outputType:"featureService",f:"json"},this._isSpatioTemporalDataStore&&(d=g.fromJson(b.createParameters),d.options={dataSourceType:"spatiotemporal"},b.createParameters=g.toJson(d)),k({url:a,content:b},
{usePost:!0}).then(e.hitch(this,this._submitGpJob),e.hitch(this,this._handleCreateServiceError)))},_createImageService:function(){var a,b,d;a=h.id.findCredential(this.portalUrl).userId;b=g.fromJson(this.jobParams.OutputName);a&&(d=this.itemParams.folder,a=this.portalUrl+"/sharing/rest/content/users/"+a+(d&&"/"!==d?"/"+d:"")+"/createService",b={createParameters:g.toJson({name:b.serviceProperties.name,description:"",capabilities:"Image",properties:{path:"@",description:"",copyright:""}}),outputType:"imageService",
f:"json"},k({url:a,content:b},{usePost:!0}).then(e.hitch(this,this._submitGpJob),e.hitch(this,this._handleCreateServiceError)))},_handleCreateServiceError:function(a){this.emit("job-fail",{message:a.message+(a.details?a.details.toString():""),jobParams:this.jobParams})},_getSelf:function(a){return k({url:a+"/sharing/rest/portals/self",content:{culture:A.locale,f:"json"},callbackParamName:"callback",timeout:0},{})},_submitGpJob:function(a){var b;this.itemParams&&(this.currentGpItemId=a.itemId,b=g.fromJson(this.jobParams.OutputName),
b.serviceProperties&&(b.serviceProperties.serviceUrl=a.serviceurl),b.itemProperties={itemId:a.itemId},this.itemParams.folder&&(b.itemProperties.folderId=this.itemParams.folder),this.jobParams.OutputName=g.toJson(b));this.rerun&&this.context&&this._useExtentCheck&&!this._useExtentCheck.get("checked")&&(this.context=null);this.context&&((a=g.fromJson(this.jobParams.context))||(a={}),this.context.outSR&&!a.outSR&&(a.outSR=this.context.outSR),this.context.processSR&&!a.processSR&&(a.processSR=this.context.processSR),
this.context.extent&&!a.extent&&(a.extent=this.context.extent),"raster"===this._analysisType&&(this.context.cellSize&&!a.cellSize&&(a.cellSize=this.context.cellSize),this.context.mask&&!a.mask&&(a.mask=this.context.mask),this.context.snapRaster&&!a.snapRaster&&(a.snapRaster=this.context.snapRaster)),this.jobParams.context=g.toJson(a));this.analysisGpServer?(this._toolServiceUrl&&this.gp||this.set("toolServiceUrl",this.analysisGpServer+"/"+this.toolName),this.gp.setUpdateDelay(3E3),this.itemParams||
delete this.jobParams.resultName,this.gp.submitJob(this.jobParams,e.hitch(this,this._gpJobComplete),e.hitch(this,this._gpJobStatus),e.hitch(this,this._gpJobFailed)),this.itemParams||(this.jobParams.resultName=this.get("resultName")),this.emit("job-submit",this.jobParams)):this._getSelf(this.portalUrl).then(e.hitch(this,function(a){this.analysisGpServer=a.helperServices.analysis&&a.helperServices.analysis.url?a.helperServices.analysis.url:null;this.set("toolServiceUrl",this.analysisGpServer+"/"+this.toolName);
this.gp.setUpdateDelay(3E3);this.itemParams||delete this.jobParams.resultName;this.gp.submitJob(this.jobParams,e.hitch(this,this._gpJobComplete),e.hitch(this,this._gpJobStatus),e.hitch(this,this._gpJobFailed));this.itemParams||(this.jobParams.resultName=this.get("resultName"));this.emit("job-submit",this.jobParams)}))},_updateItem:function(a){var b,d,c;if(b=h.id.findCredential(this.portalUrl).userId)return d=this.itemParams.folder,b=this.portalUrl+"/sharing/rest/content/users/"+b+(d&&"/"!==d?"/"+
d:"")+"/items/"+this.currentGpItemId+"/update",a&&(c=a.item.properties),f.isDefined(c)||(c={}),f.isDefined(c.jobUrl)||(c.jobUrl=this._toolServiceUrl+"/jobs/"+this._jobInfo.jobId,c.jobType="GPServer",c.jobId=this._jobInfo.jobId,c.jobStatus="processing",this.itemParams.properties=c),c=e.mixin({f:"json"},this.itemParams),a&&c.folder===a.item.folder&&delete c.folder,a&&a.item&&c.tags===a.item.tags.toString()&&delete c.tags,a&&a.item&&c.snippet===a.item.snippet&&delete c.snippet,a&&a.item&&c.description===
a.item.description&&delete c.description,c.properties&&(c.properties=g.toJson(c.properties)),c.text&&(c.text=g.toJson(c.text)),a=k({url:b,content:c},{usePost:!0}),a.then(e.hitch(this,this._handleItemUpdate),e.hitch(this,this._handleUpdateItemError)),a},_handleItemUpdate:function(a){this.isOutputLayerItemUpdated=!0},_handleItemDataUpdate:function(a){},_handleUpdateItemError:function(a){this.isOutputLayerItemUpdated=!0;this.emit("job-fail",{message:a.message+(a.details?a.details.toString():""),jobParams:this.jobParams})},
_handleErrorResponse:function(a){this.emit("job-fail",a)},_refreshItem:function(){var a,b;(a=h.id.findCredential(this.portalUrl).userId)?(b=this.itemParams.folder,a=this.portalUrl+"/sharing/rest/content/users/"+a+(b&&"/"!==b?"/"+b:"")+"/items/"+this.currentGpItemId+"/refresh",a=k({url:a,content:{f:"json"}},{usePost:!0})):(a=new n,a.resolve());return a.promise},_handleItemRefresh:function(a){},_readItem:function(){var a,b;if(a=h.id.findCredential(this.portalUrl).userId)return b=this.itemParams.folder,
a=this.portalUrl+"/sharing/rest/content/users/"+a+(b&&"/"!==b?"/"+b:"")+"/items/"+this.currentGpItemId,a=k({url:a,content:{f:"json"}}),a.then(e.hitch(this,this._updateItem))},getItemInfo:function(a){if(h.id.findCredential(this.portalUrl).userId)return a=this.portalUrl+"/sharing/rest/content/items/"+a,k({url:a,content:{f:"json"}})},_gpJobStatus:function(a){a.jobParams=this.jobParams;a.resultParameter=this.resultParameter;a.returnProcessInfo=this.jobParams.returnProcessInfo;a.getResultLyrInfos=this.getResultLyrInfos;
a.currentGpItemId=this.currentGpItemId;a.itemParams=this.itemParams;"esriJobFailed"===a.jobStatus||"esriJobSucceeded"===a.jobStatus?(a.messages&&(a.message=this._buildErrorMsg(a)),this._checkTimer&&(clearInterval(this._checkTimer),this._checkTimer=null,this._gpJobComplete(a)),"esriJobFailed"===a.jobStatus&&this._deleteItem(!1)):"esriJobCancelled"===a.jobStatus&&(this.itemParams?this._deleteItem(!0):this.emit("job-cancel",a));this.doSaveJobInfo&&this.saveJobInfo(a);this.emit("job-status",a);this._jobInfo=
a;this.itemParams&&!this.isOutputLayerItemUpdated&&this._readItem()},_updateRefreshItem:function(a){var b=[],d=a[0];b.push(this._readItem(this.doRefreshItem));w(b).then(e.hitch(this,function(a){d.outputLayerName=g.fromJson(this.jobParams.OutputName).serviceProperties.name;d.value.itemId=this.currentGpItemId;d.analysisInfo={toolName:this.toolName,jobParams:this.jobParams};this.doRefreshItem?this._refreshItem().always(e.hitch(this,function(){this.emit("job-result",d)})):this.emit("job-result",d)}),
e.hitch(this,this._handleDeleteItemError))},_gpJobComplete:function(a){var b;"esriJobSucceeded"===a.jobStatus&&(a.jobParams=this.jobParams,this.emit("job-success",a),w(this._getGpResultData(a)).then(e.hitch(this,function(d){d=l.filter(d,function(a){var b=!0;f.isDefined(a.value.empty)?b=a.value.empty:f.isDefined(a.value.url)||f.isDefined(a.value.itemId)?b=!1:f.isDefined(a.value.featureSet)&&(b=!1);if(!b)return a});0===d.length?(this.currentGpItemId&&this._deleteItem(!1),this.emit("job-fail",{message:this.i18n.emptyResultInfoMsg,
type:"warning",jobParams:this.jobParams})):(f.isDefined(this.itemParams)&&this.itemParams.properties&&this.itemParams.properties.jobStatus&&"processing"===this.itemParams.properties.jobStatus&&(this.itemParams.properties.jobStatus="completed"),l.forEach(d,function(a){if(a.value.featureSet&&!a.value.url)a.value.featureSet.spatialReference=a.value.layerDefinition.spatialReference;else if(a.value.url&&-1!==a.value.url.indexOf("/FeatureServer/")&&a.value.layerInfo&&a.value.layerInfo.popupInfo){var b=
a.value.url.match(/[0-9]+$/g)[0];this._popupInfo[b]=a.value.layerInfo.popupInfo}},this),b=d[0],b.results=d,this.jobParams.returnProcessInfo?this.gp.getResultData(a.jobId,"ProcessInfo").then(e.hitch(this,function(a){var c=[];l.forEach(a.value,function(a){c.push(g.fromJson(a))},this);this.currentGpItemId?(this.itemParams.description=m.buildReport(c),this._updateRefreshItem(d)):(b.analysisReport=m.buildReport(c),b.outputLayerName=this.jobParams.resultName,this.emit("job-result",b))})):this.currentGpItemId?
this._updateRefreshItem(d):(b.outputLayerName=this.jobParams.resultName,this.emit("job-result",b)))})))},_gpJobFailed:function(a){e.clone(a).jobParams=this.jobParams;this._checkTimer&&(clearInterval(this._checkTimer),this._checkTimer=null);a.messages&&(a.message=this._buildErrorMsg(a));this.emit("job-fail",a)},_getGpResultData:function(a){var b=[],d=[];"string"===typeof this.resultParameter?d.push(this.resultParameter):this.resultParameter instanceof Array&&(d=this.resultParameter);l.forEach(d,function(c,
d){b.push(this.gp.getResultData(a.jobId,c))},this);return b},cancel:function(a){this.gp.cancelJob(a.jobId).then(e.hitch(this,function(a){"esriJobCancelled"===a.jobStatus&&(this.itemParams?this._deleteItem(!0):this.emit("job-cancel",a))}),function(a){})},checkJobStatus:function(a){this.signInPromise.then(e.hitch(this,function(){this.gp.setUpdateDelay(3E3);this._checkTimer=setInterval(e.hitch(this,this._checkStatus,a,e.hitch(this,this._gpJobStatus),e.hitch(this,this._gpJobFailed)),3E3)}))},_checkStatus:function(a,
b,d){this.gp.checkJobStatus(a,b,d)},_deleteItem:function(a){var b,d;(b=h.id.findCredential(this.portalUrl).userId)&&this.itemParams&&(d=f.isDefined(this.itemParams.folder)?this.itemParams.folder:"",b=this.portalUrl+"/sharing/rest/content/users/"+b+(d&&"/"!==d?"/"+d:"")+"/items/"+this.currentGpItemId+"/delete",k({url:b,content:{f:"json"}},{usePost:!0}).then(e.hitch(this,this._handleItemDelete,a),e.hitch(this,this._handleDeleteItemError)))},_handleItemDelete:function(a,b){a&&this.emit("job-cancel",
b)},_handleDeleteItemError:function(a){this.emit("job-fail",{message:a.message+(a.details?a.details.toString():""),jobParams:this.jobParams})},_initFolderStore:function(a,b){this._fportal=this.portalSelf?new a.Portal({url:this.portalUrl,self:this.portalSelf}):new a.Portal(this.portalUrl);this._fportal.signIn().then(e.hitch(this,function(a){this.portalUser=a;this.portalUser.getFolders().then(e.hitch(this,function(a){a=m.createFolderStore(a,this.portalUser.username);b.resolve(a)}))}))},getFolderStore:function(){var a=
new n,b,d,c,f;this.folderStore?a.resolve(this.folderStore):this.signInPromise.then(e.hitch(this,function(e){b=["../../arcgis/Portal"];d=this._counter++;c=this;this._rids&&this._rids.push(d);r(b,function(b){f=c._rids?l.indexOf(c._rids,d):-1;-1!==f&&(c._rids.splice(f,1),c._initFolderStore(b,a))})}));return a},_checkToolUrl:function(){var a=new n;this.analysisGpServer?(this._toolServiceUrl&&this.gp||this.set("toolServiceUrl",this.analysisGpServer+"/"+this.toolName),a.resolve({success:!0})):this._getSelf(this.portalUrl).then(e.hitch(this,
function(b){(this.analysisGpServer=b.helperServices.analysis&&b.helperServices.analysis.url?b.helperServices.analysis.url:null)&&this.set("toolServiceUrl",this.analysisGpServer+"/"+this.toolName);a.resolve({success:!0})}));return a},getCreditsEstimate:function(a,b){var d,c,f,g,h;c=new n;this._checkToolUrl().then(e.hitch(this,function(F){this._toolServiceUrl?h=this._toolServiceUrl:(g=this.portalUrl&&-1!==this.portalUrl.indexOf("dev")?"dev":this.portalUrl&&-1!==this.portalUrl.indexOf("qa")?"qa":"",
h="http://analysis"+g+".arcgis.com/arcgis/rest/services/tasks/GPServer/"+this.toolName);!this.showGeoAnalyticsParams&&-1!==l.indexOf(["AggregatePoints","SummarizeWithin"],a)&&b.binType?(d=h.replace(a,"TessellationCredit"),this.creditGP=new u(d),this.creditGP.setUpdateDelay(1E3),b.pointLayer?b.inputLayer=b.pointLayer:b.summaryLayer&&(b.inputLayer=b.summaryLayer),this.creditGP.submitJob(b,e.hitch(this,this._getGPCreditResult,c),e.hitch(this,this._creditGPJobFailed,c),e.hitch(this,this._creditGPJobFailed,
c))):(d=h.replace("/"+a,"/exts/Estimate/"+a),f=e.mixin({f:"json"},b),k({url:d,content:f},{usePost:!0}).then(function(a){c.resolve(a)},function(a){c.resolve(a)}))}));return c},_getGPCreditResult:function(a,b){this.creditGP.getResultData(b.jobId,"creditOutput").then(e.hitch(this,function(a,b){b&&b.value&&b.value.credits&&(b.value.cost=b.value.credits);a.resolve(b.value)},a),e.hitch(this,function(a,b){a.resolve(b)},a))},_creditGPJobFailed:function(a,b){"esriJobFailed"!==b.jobStatus&&"esriJobCancelled"!==
b.jobStatus||a.resolve(this._buildErrorMsg(b))},_signIn:function(a,b){var d,c,g,v,m;this.signInPromise=new n;b?(d=["../../arcgis/Portal"],c=this._counter++,g=this,this._rids&&this._rids.push(c),r(d,e.hitch(this,function(b){v=g._rids?l.indexOf(g._rids,c):-1;-1!==v&&(g._rids.splice(v,1),this._portal=this.portalSelf?new b.Portal({url:a,self:this.portalSelf}):new b.Portal(a),this._portal.signIn().then(e.hitch(this,function(a){this.portalUser=a;this._portal.helperServices&&this._portal.helperServices.analysis&&
this._portal.helperServices.analysis.url?(this.analysisGpServer=this._portal.helperServices.analysis.url,this.showGeoAnalyticsParams&&this._portal.helperServices.geoanalytics&&(this.analysisGpServer=this._portal.helperServices.geoanalytics.url),k({url:this.analysisGpServer,content:{f:"json"},callbackParamName:"callback"}).then(e.hitch(this,function(a){m=h.id.findCredential(this.analysisGpServer);this.signInPromise.resolve(m)}),e.hitch(this,function(a){this.signInPromise.reject(a)}))):this.signInPromise.resolve(a)}),
e.hitch(this,this._handleSignInError)))}))):k({url:a,content:{f:"json"},callbackParamName:"callback"}).then(e.hitch(this,function(b){var c;b=h.id.findCredential(a);f.isDefined(b)?(c=h.id.findServerInfo(this._toolServiceUrl),f.isDefined(c)&&f.isDefined(c.owningSystemUrl)&&(this.portalUrl=c.owningSystemUrl),this.signInPromise.resolve(b)):h.id.getCredential(a).then(e.hitch(this,function(b){b=h.id.findCredential(a);c=h.id.findServerInfo(this._toolServiceUrl);f.isDefined(c)&&f.isDefined(c.owningSystemUrl)&&
(this.portalUrl=c.owningSystemUrl);this.signInPromise.resolve(b)}),e.hitch(this,this._handleSignInError))}),e.hitch(this,this._handleSignInError));return this.signInPromise},_handleSignInError:function(a){this.emit("job-fail",{message:this.i18n.analysisSignInErrorMsg,messageCode:"AB_0003"});this.signInPromise.reject(a)},_buildErrorMsg:function(a){var b="",d=[],c,e;this.errorHelpMap||this._initErrorHelpMap();d=l.filter(a.messages,function(a){if(("esriJobMessageTypeError"===a.type||"esriJobMessageTypeWarning"===
a.type)&&-1!==a.description.indexOf("messageCode"))return a.description},this);0<d.length&&l.forEach(d,function(d){try{c=g.fromJson(d.description)}catch(G){c=d.description}e="";"esriJobMessageTypeWarning"===d.type&&(a.type="warning");c.messageCode?(e=f.isDefined(this.i18n[c.messageCode])?this.i18n[c.messageCode]:c.message,e=f.isDefined(c.params)?t.substitute(e,c.params):e,b+=e+"\x26nbsp;",(d=this._addLearnMoreErrorLink(c.messageCode))&&(b+=d)):c.error&&c.error.messageCode?(e=f.isDefined(this.i18n[c.error.messageCode])?
this.i18n[c.error.messageCode]:c.error.message,e=f.isDefined(c.error.params)?t.substitute(e,c.error.params):e,b+=e+"\x26nbsp;",(d=this._addLearnMoreErrorLink(c.error.messageCode))&&(b+=d)):b+=c+"\x26nbsp;"},this);return b},_toolServiceUrlSetter:function(a){this._toolServiceUrl=a;this.gp=new u(a)},_setToolServiceUrlAttr:function(a){this._toolServiceUrl=a;this.gp=new u(a)},checkCreditLimitsAttr:function(a){this.checkCreditLimits=a},replaceTag:function(a){return{"\x26":"\x26amp;","\x3c":"\x26lt;","\x3e":"\x26gt;"}[a]||
a},safetagsReplace:function(a){return a.replace(/[<>]/g,this.replaceTag)},saveJobInfo:function(a){var b;if(this.doSaveJobInfo&&this.currentGpItemId&&-1!==l.indexOf(["esriJobSucceeded"],a.jobStatus)){e.mixin(a.jobParams,{extentCheck:this._useExtentCheck&&this._useExtentCheck.get("checked")});l.forEach(a.messages,function(a){a.description=this.safetagsReplace(a.description)},this);a={toolName:this.toolName,jobParams:a.jobParams,timestamp:Date.now(),portalUrl:this.portalUrl,jobInfo:{jobId:a.jobId,jobStatus:a.jobStatus,
messages:a.messages,analysisServer:"bigdata"===this.analysisMode?"geoanalytics":"default"===this.analysisMode?"standard":this.analysisMode}};"CopyToDataStore"===this.toolName&&(a.jobParams.isSpatioTemporalDataStore=this._isSpatioTemporalDataStore);"bigdata"===this.analysisMode&&a.jobParams.timeStepReference&&(a.jobParams.timeReferenceType=this.get("timeReferenceType"));for(b in a.jobParams)if(a.jobParams.hasOwnProperty(b)&&f.isDefined(a.jobParams[b])){if("object"===typeof a.jobParams[b]&&a.jobParams[b].serviceToken||
"string"===typeof a.jobParams[b]&&-1!==a.jobParams[b].indexOf("serviceToken")){var d="string"===typeof a.jobParams[b]?g.fromJson(a.jobParams[b]):a.jobParams[b];d&&d.serviceToken&&(delete d.serviceToken,a.jobParams[b]="string"===typeof a.jobParams[b]?g.toJson(d):d)}if("object"===typeof a.jobParams[b]&&!e.isArray(a.jobParams[b])&&a.jobParams[b].filter||"string"===typeof a.jobParams[b]&&-1!==a.jobParams[b].search(/[<>]/g))"object"===typeof a.jobParams[b]&&a.jobParams[b].filter&&!e.isArray(a.jobParams[b])?
a.jobParams[b].filter=this.safetagsReplace(a.jobParams[b].filter):"string"===typeof a.jobParams[b]&&-1!==a.jobParams[b].search(/[<>]/g)&&(a.jobParams[b]=this.safetagsReplace(a.jobParams[b]))}b=h.id.findCredential(this.portalUrl);this.currentGpItemId&&(b={id:this.currentGpItemId,folderId:this.itemParams.folder,owner:b.userId},x.addToItemResource(b,a));this.doSaveInStorage&&x.addToStorage(a)}},_initErrorHelpMap:function(){if(this.isSingleTenant){var a=r.toUrl("./help/errorhelpmap_enterprise.json");
k({url:a}).then(e.hitch(this,function(a){this.errorHelpMap=a.map}))}},_addLearnMoreErrorLink:function(a){if(this.isSingleTenant){var b;a=this.errorHelpMap[a];var d=this&&this.portalSelf?this.portalSelf.helpBase:null,c=this.analysisGpServer&&-1!==this.analysisGpServer.indexOf("dev")?"dev":this.analysisGpServer&&-1!==this.analysisGpServer.indexOf("qa")?"uat":"";f.isDefined(a)&&(b="http://doc"+c+".arcgis.com/en/arcgis-online/analyze/"+a,this.isSingleTenant&&d?b=d+"index.html#"+a:this.isSingleTenant&&
!d&&(b="http://server"+c+".arcgis.com/en/portal/latest/use/"+a));b&&(b="\x3cbr/\x3e\x3cbr/\x3e\x3cdiv class\x3d'esriHelpPopup'\x3e\x3ca class\x3d'action zoomTo' href\x3d'"+b+"' target\x3d'_help'\x3e"+this.i18n.learnMore+"\x3c/a\x3e\x3c/div\x3e\x3cbr/\x3e\x3cbr/\x3e");return b}}});y("extend-esri")&&e.setObject("dijit.analysis.AnalysisBase",p,h);return p});