// 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/_AnalysisOptions","dojo/_base/declare dojo/_base/lang dojo/dom-attr dojo/dom-class dojo/dom-construct dojo/dom-style dojo/aspect dojo/has dojo/_base/array dojo/_base/window dojo/on dojo/query dojo/number ./Settings ./SettingsViewModel ./utils dijit/Dialog dijit/form/NumberTextBox dojo/i18n!../../nls/jsapi ../../lang ../../kernel".split(" "),function(f,c,k,m,n,e,p,q,r,t,u,v,w,x,y,b,z,A,g,h,B){f=f([],{declaredClass:"esri.dijit.analysis._AnalysisOptions",showSelectFolder:!1,
showChooseExtent:!0,showHelp:!0,showCredits:!0,returnFeatureCollection:!1,showCloseIcon:!0,showSelectAnalysisLayer:!0,map:null,showReadyToUseLayers:!0,showAnalysisBusyIndicator:!0,showGeoAnalyticsParams:!1,showBrowseLayers:!1,showAnalysisModeLabel:!1,distanceDefaultUnits:"Miles",showSettings:!1,showOutputType:!1,context:{},includeRouteLayers:!1,doSaveJobInfo:!1,doSaveInStorage:!1,constructor:function(a){a.rerun&&this._initRerunProps(a)},_initRerunProps:function(a){a.OutputName&&a.OutputName.serviceProperties?
a.outputLayerName=a.OutputName.serviceProperties.name:a.resultName&&(a.outputLayerName=a.resultName);a.timeStepReference&&(a.timeReference=a.timeStepReference);this.set("extentCheck",a.extentCheck);this._numberFormatHandle=p.before(A,"_setValueAttr",function(a,b,c){a=w.format(a);return[a,b,c]});this.on("close",c.hitch(this,function(){this._numberFormatHandle&&(this._numberFormatHandle.remove(),this._numberFormatHandle=null)}))},_setShowSelectFolderAttr:function(a){!0===a&&a===this.get("returnFeatureCollection")&&
(a=!a);this.showSelectFolder=a;this._webMapFolderSelect&&this._webMapFolderSelect.set("required",a);this._chooseFolderRow&&e.set(this._chooseFolderRow,"display",!0===this.showSelectFolder?"block":"none");a&&this._webMapFolderSelect&&this.getFolderStore().then(c.hitch(this,function(a){this.folderStore=a;b.setupFoldersUI({folderStore:this.folderStore,folderId:this.folderId,folderName:this.folderName,folderSelect:this._webMapFolderSelect,username:this.portalUser?this.portalUser.username:""})}))},_getShowSelectFolderAttr:function(){return this.showSelectFolder},
_setShowChooseExtentAttr:function(a){this.showChooseExtent=a},_getShowChooseExtentAttr:function(){return this.showChooseExtent},_setExtentCheckAttr:function(a){this.extentCheck=a;h.isDefined(this._useExtentCheck)&&h.isDefined(a)&&this._useExtentCheck.set("checked",a)},_setMapAttr:function(a){this.map=a},_getMapAttr:function(){return this.map},_setShowHelpAttr:function(a){this.showHelp=a},_getShowHelpAttr:function(){return this.showHelp},_setReturnFeatureCollectionAttr:function(a){this.returnFeatureCollection=
a;this.set("showSelectFolder",!a)},_getReturnFeatureCollectionAttr:function(){return this.returnFeatureCollection},_setShowCreditsAttr:function(a){this.showCredits=a},_getShowCreditsAttr:function(){return this.showCredits},_setShowCloseIconAttr:function(a){this.showCloseIcon=a},_getShowCloseIconAttr:function(){return this.showCloseIcon},_setShowSelectAnalysisLayerAttr:function(a){this.showSelectAnalysisLayer=a;this._analysisSelect&&this._analysisSelect.set("required",a)},_getShowSelectAnalysisLayerAttr:function(){return this.showSelectAnalysisLayer},
_setIsSingleTenantAttr:function(a){this.isSingleTenant=a},_getIsSingleTenantAttr:function(){return this.isSingleTenant},_setAllowChooseLabelAttr:function(a){this.allowChooseLabel=a},_getAllowChooseLabelAttr:function(){return this.allowChooseLabel},_setTitleAttr:function(a){this.title=a;this._toolTitle&&k.set(this._toolTitle,"innerHTML",a)},_getTitleAttr:function(){return this.title=k.get(this._toolTitle,"innerHTML")},_setShowReadyToUseLayersAttr:function(a){this.showReadyToUseLayers=a},_getShowReadyToUseLayersAttr:function(a){return this.showReadyToUseLayers},
_setFolderIdAttr:function(a){this.folderId=a},_getFolderIdAttr:function(){this._webMapFolderSelect&&this.folderStore&&(this.folderId=this._webMapFolderSelect.item?this.folderStore.getValue(this._webMapFolderSelect.item,"id"):"");return this.folderId},_setFolderNameAttr:function(a){this.folderName=a},_getFolderNameAttr:function(){this._webMapFolderSelect&&this.folderStore&&this._webMapFolderSelect.item&&(this.folderName=this.folderStore.getValue(this._webMapFolderSelect.item,"name"));return this.folderName},
_setHelperServicesAttr:function(a){this.helperServices=a},_getHelperServicesAttr:function(a){return this.helperServices},_getPortalSelfAttr:function(){return this.portalSelf},_setPortalSelfAttr:function(a){this.portalSelf=a},_setShowAnalysisBusyIndicatorAttr:function(a){a&&this.own(this.on("start",c.hitch(this,function(){this.showLoadingIndicator()})),this.on("job-fail, job-result, job-cancel",c.hitch(this,function(){this.hideLoadingIndicator()})),this.on("job-status",c.hitch(this,function(a){"esriJobFailed"===
a.jobStatus&&this.hideLoadingIndicator()})))},_setShowGeoAnalyticsParamsAttr:function(a){this.showGeoAnalyticsParams=a},_getShowGeoAnalyticsParamsAttr:function(){return this.showGeoAnalyticsParams},_setShowBrowseLayersAttr:function(a){this.showBrowseLayers=a},_getShowBrowseLayersAttr:function(){return this.showBrowseLayers},showLoadingIndicator:function(){this.get("showAnalysisBusyIndicator")&&(this._saveBtn.set("iconClass","esriLoading"),this.set("disableRunAnalysis",!0))},hideLoadingIndicator:function(){this.get("showAnalysisBusyIndicator")&&
(this._saveBtn.set("iconClass",""),this.set("disableRunAnalysis",!1))},_setDistanceDefaultUnitsAttr:function(a){this.distanceDefaultUnits=a},_getDistanceDefaultUnitsAttr:function(){return this.distanceDefaultUnits},_setAnalysisModeAttr:function(a){this.analysiMode=a},_setShowAnalysisModeLabelAttr:function(a){this.showAnalysisModeLabel=a;this._titleLbl&&this._analysisModeLblNode&&(e.set(this._titleLbl,"display",this.showAnalysisModeLabel?"none":"block"),e.set(this._analysisModeLblNode,"display",this.showAnalysisModeLabel?
"flex":"none"),this.showAnalysisModeLabel&&("standard"===this.analysiMode?this.analysisModeLabel=this.i18n.standard:"bigdata"===this.analysiMode||this.showGeoAnalyticsParams?this.analysisModeLabel=this.i18n.bigData:"raster"===this.analysisMode&&(this.analysisModeLabel=this.i18n.raster),k.set(this._analysisModeCrumb,"innerHTML",this.analysisModeLabel)))},_getTimeReferenceAttr:function(){if(this._timeRefDay){var a,b,d="",c="",l="";a=this._timeRefDay.get("value");b=this._timeRefTime.get("value");a&&
(d=a.toDateString(),l="Date");b&&(c=b.toTimeString(),l="DateTime");this.set("timeReferenceType",l);a=c&&-1!==c.indexOf("GMT")?d+" "+c.substring(0,c.indexOf("GMT")+3):c?d+" "+c.split(" ")[0]+" GMT":d+" GMT";this.timeReference=(new Date(a)).getTime()}return this.timeReference},_setTimeReferenceAttr:function(a){a=new Date(a+6E4*(new Date(a)).getTimezoneOffset());this._timeRefDay&&this._timeRefDay.set("value",a);this._timeRefTime&&"DateTime"===this.timeReferenceType&&this._timeRefTime.set("value",a)},
_setTimeReferenceTypeAttr:function(a){this.timeReferenceType=a},_setSLayersAttr:function(a){this.sLayers=a},_setContextAttr:function(a){this.context=a},_setIncludeRouteLayersAttr:function(a){this.includeRouteLayers=a},_getIncludeRouteLayersAttr:function(){return this.includeRouteLayers},_setShowSettingsAttr:function(a){if(this.showSettings=a){if(!b.settingsDlg){a=t.doc.createDocumentFragment();a=n.create("div",{style:"width:200px;height:200px;"},a);var C=r.filter(this.sLayers,function(a){return a.type?
"Table"!==a.type:!0});b.settingsVM=new y({showHelp:!0,showCloseIcon:!1,showOverwriteResultOption:!1,showCloseAnalysisOption:!0,showStoreAnalysisOption:!0,showCoordinateSystems:this.analysisMode&&("raster"===this.analysisMode||"bigdata"===this.analysisMode),showProcessSR:this.analysisMode&&"bigdata"===this.analysisMode,showOutSR:this.analysisMode&&"raster"===this.analysisMode,showExtent:!0,showRasterSettings:this.analysisMode&&"raster"===this.analysisMode,showGeoAnalyticsSettings:this.analysisMode&&
"bigdata"===this.analysisMode,showHeader:!1,layers:C,showJobsHistory:!1,jobsHistoryItem:null});this.signInPromise.then(c.hitch(this,function(){b.settingsVM.set("portalUrl",this.portalUrl)}));b.settings=new x({viewModel:b.settingsVM},a);this.i18n||(this.i18n={},c.mixin(this.i18n,g.common),c.mixin(this.i18n,g.analysisTools),c.mixin(this.i18n,g.analysisMsgCodes),c.mixin(this.i18n,g.analysisSettings));b.settingsDlg=new z({title:this.i18n.analysisEnv,content:b.settings,style:"width:400px;"});b.settingsDlg.own(b.settings.on("ok-settings",
c.hitch(this,function(){b.settingsDlg.hide()})),b.settings.on("cancel-settings",c.hitch(this,function(){b.settingsDlg.hide()})))}b.settingsDlg&&(b.settingsVM.set("showRasterSettings",this.analysisMode&&"raster"===this.analysisMode),b.settingsVM.set("showGeoAnalyticsSettings",this.analysisMode&&"bigdata"===this.analysisMode),b.settingsVM.set("showCoordinateSystems",this.analysisMode&&("raster"===this.analysisMode||"bigdata"===this.analysisMode)),b.settingsVM.set("showProcessSR",this.analysisMode&&
"bigdata"===this.analysisMode),b.settingsVM.set("showOutSR",this.analysisMode&&"raster"===this.analysisMode),this.domNode&&v("[esriHelpTopic\x3d'toolDescription']",this.domNode).forEach(c.hitch(this,function(a){a&&(this._settingsLink=n.create("a",{href:"#","class":"esriAnalysisSettingsIcon"},a,"before"),u(this._settingsLink,"click",c.hitch(this,this._handleSettingsLinkClick)))})),this._settingWatchers||(this._settingWatchers=!0,a=this.get("context"),b.settingsVM.extent&&(a.extent=b.settingsVM.extent,
this._useExtentCheck&&this._useExtentCheck.set("checked",!1)),b.settingsVM.outSR&&(a.outSR=b.settingsVM.outSR),b.settingsVM.processSR&&(a.processSR=b.settingsVM.processSR),b.settingsVM.extent&&(a.extent=b.settingsVM.extent,this._useExtentCheck&&this._useExtentCheck.set("checked",!1)),b.settingsVM.cellSize&&(a.cellSize=b.settingsVM.cellSize),b.settingsVM.mask&&(a.mask=b.settingsVM.mask),b.settingsVM.snapRaster&&(a.snapRaster=b.settingsVM.snapRaster),this.set("returnFeatureCollection",b.settingsVM.returnFeatureCollection),
this.set("context",a),b.settingsVM.watch("outSR",c.hitch(this,function(a,b,c){if(a=this.get("context"))a.outSR=c,this.set("context",a)})),b.settingsVM.watch("processSR",c.hitch(this,function(a,b,c){if(a=this.get("context"))a.processSR=c,this.set("context",a)})),b.settingsVM.watch("extent",c.hitch(this,function(a,b,c){if(a=this.get("context"))a.extent=c,this.set("context",a);this._useExtentCheck&&this._useExtentCheck.set("checked",!h.isDefined(c))})),b.settingsVM.watch("cellSize",c.hitch(this,function(a,
b,c){if(a=this.get("context"))a.cellSize=c,this.set("context",a)})),b.settingsVM.watch("mask",c.hitch(this,function(a,b,c){if(a=this.get("context"))a.mask=c,this.set("context",a)})),b.settingsVM.watch("snapRaster",c.hitch(this,function(a,b,c){if(a=this.get("context"))a.snapRaster=c,this.set("context",a)})),b.settingsVM.watch("returnFeatureCollection",c.hitch(this,function(a,b,c){this.set("returnFeatureCollection",c)}))))}},_setShowOutputTypeAttr:function(a){this.showOutputType=a},_setDoSaveJobInfoAttr:function(a){this.doSaveJobInfo=
a},_setDoSaveInStorageAttr:function(a){this.doSaveInStorage=a},_getResultNameAttr:function(a){this.resultName="";this.outputLayerInput?this.resultName=this.outputLayerInput.get("value"):this._outputLayerInput&&(this.resultName=this._outputLayerInput.get("value"));return this.resultName},_setArcadeEditorAttr:function(a){this.arcadeEditor=a},_handleSettingsLinkClick:function(){this.showSettingsDlg()},showSettingsDlg:function(a){a&&a.preventDefault();this._hasPCSWarnShown&&this.showGeoAnalyticsParams&&
this._errorMessagePane&&b.hideMessages(this._errorMessagePane);b.settingsDlg.show()},_handleModeCrumbClick:function(a){a.preventDefault();this._onClose(!1)},_onFocus:function(){this.map&&"function"===typeof this.map.disableKeyboardNavigation&&this.map.disableKeyboardNavigation();this.emit("focus");this.inherited(arguments)},_onBlur:function(){this.map&&"function"===typeof this.map.enableKeyboardNavigation&&this.map.enableKeyboardNavigation();this.emit("blur");this.inherited(arguments)},_handleAtrrValueUpdate:function(a,
c,d){"0"!==d&&(a=this.get("statisticSelect"),(d=this.getOptions(d))&&d.type&&b.addStatisticsOptions({selectWidget:a,type:d.type,showGeoAnalyticsParams:this.showGeoAnalyticsParams}))},_pauseCreditLinkClick:function(a,b){b?(a.pause(),e.set(this._showCreditsLink,{color:"grey",cursor:"none"}),m.add(this._showCreditsLink,"esriAnalysisTextDisabled esriLoadingBar2")):(a.resume(),e.set(this._showCreditsLink,{color:"#21759B",cursor:"pointer"}),m.remove(this._showCreditsLink,"esriAnalysisTextDisabled esriLoadingBar2"))},
constructAnalysisInputLyrObj:function(a,c){c=h.isDefined(c)?c:this.isSingleTenant&&"ExtractData"!==this.toolName;return b.constructAnalysisInputLyrObj(a,c,!this.showGeoAnalyticsParams)}});q("extend-esri")&&c.setObject("dijit.analysis._AnalysisOptions",f,B);return f});