// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
require({cache:{"url:esri/dijit/analysis/customgp/editors/SelectFeatureSetFromLayer.html":'\x3cdiv class\x3d"esriAnalysis"\x3e\r\n  \x3cdiv data-dojo-attach-point\x3d"inputNode"\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"layerChooseNode"\x3e\r\n    \x3c/div\x3e\r\n    \x3c!--\x3cdiv data-dojo-attach-point\x3d"drawBtnNode"\x3e\x3c/div\x3e--\x3e\r\n    \x3c/tr\x3e\r\n  \x3c/div\x3e\r\n  \x3cdiv data-dojo-attach-point\x3d"featuresetNode"\x3e\r\n  \x3c/div\x3e\r\n\x3c/div\x3e'}});
define("esri/dijit/analysis/customgp/editors/SelectFeatureSetFromLayer","dojo/_base/declare dojo/Deferred dojo/Evented dojo/_base/lang dojo/_base/array dojo/_base/connect dojo/on dijit/_TemplatedMixin ../BaseEditor dijit/form/Select dijit/form/ToggleButton dojo/text!./SelectFeatureSetFromLayer.html esri/dijit/analysis/utils esri/tasks/query esri/toolbars/draw esri/layers/FeatureLayer esri/graphic esri/symbols/PictureMarkerSymbol esri/symbols/jsonUtils".split(" "),function(m,x,n,c,g,k,l,p,q,r,t,u,
d,y,e,v,w,z,h){return m([q,p,n],{templateString:u,editorName:"SelectFeatureSetFromLayer",postCreate:function(){this.inherited(arguments);this._analysisSelect=this.spatialFilterByFeatures=new r({"class":"longInput esriMediumlabel2 esriAnalysisSelect"});this.analysisLayers=this.config.analysisLayers;this.analysisLayers=g.filter(this.analysisLayers,function(a){return this.param.defaultValue&&this.param.defaultValue.geometryType===a.geometryType},this);this.analysisLayer=this.analysisLayers[0];d.populateAnalysisLayers(this,
"analysisLayer","analysisLayers",{posIncrement:1});this.showBrowseLayers=this.widget?this.widget.showBrowseLayers:!0;this.showReadyToUseLayers=this.widget?this.widget.showReadyToUseLayers:!0;this.portalUrl=this.config.portalUrl;d.addReadyToUseLayerOption(this,[this._analysisSelect]);this.own(l(this.spatialFilterByFeatures,"change",c.hitch(this,this._onLayerChanged)));this.spatialFilterByFeatures.placeAt(this.layerChooseNode);var a=this.param.defaultValue.geometryType.toLowerCase();this._type=a=-1!==
a.indexOf("polygon")?"polygon":-1!==a.indexOf("point")?"point":"polyline";this._drawBtn=new t({"class":"esriActionButton",iconClass:"toolbarIcon "+a+"Icon"});this._drawBtn.placeAt(this.layerChooseNode);l(this._drawBtn,"change",c.hitch(this,this._handleDrawBtnChange));this._updateDrawnLayerName();this._initDefaultSymbols();this.on("add-ready-to-use-layer",c.hitch(this,function(a){this.widget&&this.widget.emit("add-ready-to-use-layer",a)}))},_updateDrawnLayerName:function(){"point"===this._type?this.set("drawnLayerName",
this.widget&&this.widget.drawPointLayerName?this.widget.drawPointLayerName:this.nls.drawnPointLayer):"polyline"===this._type?this.set("drawnLayerName",this.widget&&this.widget.drawLineLayerName?this.widget.drawLineLayerName:this.nls.drawnPolylineLayer):"polygon"===this._type?this.set("drawnLayerName",this.widget&&this.widget.drawPolyLayerName?this.widget.drawPolyLayerName:this.nls.drawnPolygonLayer):this.set("drawnLayerName",this.widget&&this.widget.drawnLayerName?this.widget.drawnLayerName:this.nls.drawnLayerName)},
_handleDrawBtnChange:function(a){a?(this.emit("drawtool-activate",{}),this._featureLayer||this._createFeatColl(),this._drawtoolbar.activate("point"===this._type?e.POINT:"polyline"===this._type?e.FREEHAND_POLYLINE:e.POLYGON)):this._drawtoolbar.deactivate()},_onLayerChanged:function(a){var b;"browse"===a?(a=this._browsedlg.browseItems.get("query"),b=this.param.defaultValue.geometryType.toLowerCase(),b=-1!==b.indexOf("point")?"point":-1!==b.indexOf("polygon")?"polygon":"line",a.custom=['tags:"'+b+'"'],
this._browsedlg.browseItems.set("query",a),this._browsedlg.show()):"browselayers"===a?(this.showGeoAnalyticsParams&&(a=this._browseLyrsdlg.browseItems.get("query"),a.types.push('type:"Big Data File Share"'),this._browseLyrsdlg.browseItems.set("query",a)),this._browseLyrsdlg.browseItems.plugIn.geometryTypes=[this.param.defaultValue.geometryType],this._browseLyrsdlg.show()):this.analysisLayer=this.analysisLayers[a]},_handleBrowseItemsSelect:function(a){a&&a.selection&&d.addAnalysisReadyLayer({item:a.selection,
layers:this.analysisLayers,layersSelect:this._analysisSelect,browseDialog:a.dialog||this._browsedlg,posIncrement:1,widget:this})},_createFeatColl:function(){this._updateDrawnLayerName();var a=this.createFeatureCollection(this.drawnLayerName);this._featureLayer=new v(a,{id:this.drawnLayerName});this.map.addLayer(this._featureLayer);k.connect(this._featureLayer,"onClick",c.hitch(this,function(a){this.map.infoWindow.setFeatures([a.graphic])}));this.widget&&this.widget.set("drawLayer",this._featureLayer)},
createFeatureCollection:function(a){var b;b={layerDefinition:null,featureSet:{features:[],geometryType:this.param.defaultValue.geometryType}};b.layerDefinition={objectIdField:"OBJECTID",templates:[],type:"Feature Layer",drawingInfo:{},name:a,hasAttachments:!1,capabilities:"Query",types:[],geometryType:this.param.defaultValue.geometryType,fields:this.param.defaultValue.fields};return b},_initDefaultSymbols:function(){var a={style:"esriSMSCircle",color:[0,0,128,128],name:"Circle",outline:{color:[0,
0,128,255],width:1},type:"esriSMS",size:18},b={style:"esriSLSSolid",color:[79,129,189,255],width:3,name:"Blue 1",type:"esriSLS"},f={style:"esriSFSSolid",color:[79,129,189,128],type:"esriSFS",outline:{style:"esriSLSSolid",color:[54,93,141,255],width:1.5,type:"esriSLS"}};this.pointSymbol||(this.pointSymbol=h.fromJson(a));this.polylineSymbol||(this.polylineSymbol=h.fromJson(b));this.polygonSymbol||(this.polygonSymbol=h.fromJson(f))},_createGraphic:function(a){var b=a.type,f=null,f="point"===b||"multipoint"===
b?this.pointSymbol:"line"===b||"polyline"===b?this.polylineSymbol:this.polygonSymbol;return new w(a,f)},_addFeatures:function(a){a=this._createGraphic(a);var b=[];this.map.graphics.add(a);b.push(a);this._featureLayer.applyEdits(b,null,null);if(0===this.analysisLayers.length||this.analysisLayers[this.analysisLayers.length-1]!==this._featureLayer)a=this.analysisLayers.push(this._featureLayer),b=this._analysisSelect.getOptions(),this._analysisSelect.removeOption(b),b=g.map(b,function(a){a.selected=!1;
return a}),b.push({value:a,label:this._featureLayer.name,selected:!0}),this._analysisSelect.addOption(b),this._onLayerChanged(a);this._drawBtn.set("checked",!1)},clear:function(){this._featureLayer&&(this.map.removeLayer(this._featureLayer),g.forEach(this.analysisLayers,function(a,b){a===this._featureLayer&&(this._analysisSelect.removeOption({value:b+1,label:this._featureLayer.name}),this.analysisLayers.splice(b,1))},this));this._handleDrawBtnChange(!1)},_setDrawnLayerNameAttr:function(a){this.drawnLayerName=
a},_getDrawnLayerNameAttr:function(){return this._featureLayer.name},_getDrawLayerAttr:function(){return this._featureLayer},getGPValue:function(){var a=this.analysisLayers[this._analysisSelect.get("value")-1];return this.wrapValueToDeferred(d.constructAnalysisInputLyrObj(a,!0))},_setMapAttr:function(a){this.map=a;this._drawtoolbar=new e(this.map);k.connect(this._drawtoolbar,"onDrawEnd",c.hitch(this,this._addFeatures))}})});