// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
require({cache:{"url:widgets/ReportFeature/SelectFeatureDialog.html":'\x3cdiv\x3e\r\n\t\x3cp style\x3d"width:90%;height:25px;margin: 20px 5px 0px 7px;"\x3e${nls.chooseALayer}: \x3c/p\x3e\r\n\t\x3cselect data-dojo-attach-point\x3d"selectLayer"  class\x3d"jimu-input" style\x3d"width:90%;height:31px;margin: 5px 5px 5px 7px;"\x3e\r\n    \x3coption value\x3d""\x3e\x3c/option\x3e\r\n  \x3c/select\x3e\r\n  \r\n  \x3cp style\x3d"display: none;" data-dojo-attach-point\x3d"clickAFeatureNode"  style\x3d"width:90%;height:25px;margin: 5px 5px 5px 7px;" \x3e${nls.clickAFeature}\x3c/p\x3e\r\n  \x3cp class\x3d"drs-loading-features" style\x3d"display: none;" data-dojo-attach-point\x3d"loadingFeaturesNode" \x3e${nls.loadingFeatures}\x3c/p\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dojo/_base/array dojo/_base/lang dojo/on dojo/string dojo/dom-construct dojo/dom-style dijit/_WidgetBase dijit/_TemplatedMixin dojo/query dojo/i18n!esri/nls/jsapi esri/main esri/layers/FeatureLayer esri/toolbars/draw esri/tasks/IdentifyTask esri/tasks/query esri/tasks/IdentifyParameters esri/symbols/SimpleMarkerSymbol esri/symbols/SimpleLineSymbol esri/symbols/SimpleFillSymbol esri/geometry/Extent esri/tasks/datareviewer/ReviewerResultsTask ./InfoWindowContent dojo/text!./SelectFeatureDialog.html".split(" "),
function(t,h,m,k,u,n,f,v,w,p,x,y,q,g,z,A,B,C,D,E,F,G,H,I){var J=new C({type:"esriSMS",style:"esriSMSCircle",size:12,xoffset:0,yoffset:0,color:[0,0,255,51],outline:{type:"esriSLS",style:"esriSLSSolid",color:[0,0,255,128],width:1}}),r=new D({type:"esriSLS",style:"esriSLSSolid",color:[0,0,255,51],width:2}),K=new E({type:"esriSFS",style:"esriSFSSolid",color:[0,0,255,26],outline:{type:"esriSLS",style:"esriSLSSolid",color:[0,0,255,128],width:1}});return t([v,w],{templateString:I,baseClass:"drs-widget-selectFeature",
buildRendering:function(){this.inherited(arguments);this._initDom()},_initDom:function(){var a=this.getLayerOptions();void 0!==a&&""!==a&&n.place(a,this.selectLayer)},postCreate:function(){this.inherited(arguments);this._initEvents()},_initEvents:function(){var a=this;this.selectionToolbar=new g(this.map);this.selectionToolbar.on("draw-end",m.hitch(this,this.addGraphic));this.own(k(this.selectLayer,"change",function(b){x.toolbars.draw.addPoint=a.nls.selectFeatureMapPoint;(b=b.target.value)?a.startSelectFeature(b):
a.cancelSelectFeature()}));this.own(k(this.map.infoWindow,"hide",function(){var b=p(".actionsPane");void 0!==b&&null!==b&&0<b.length&&(b[0].style.display="");a.emit("InfoWindowHide")}))},startSelectFeature:function(a){var b=h.filter(this.config.layers,function(c){return c.id===a});if(void 0!==b&&0<b.length&&(b=this.map.getLayer(a),void 0===b)){this.emit("Error",{},[this.nls.errorMapService]);return}this.selectionToolbar.activate(g.POINT);f.set(this.clickAFeatureNode,"display","")},addGraphic:function(a){var b=
this.selectLayer.value,c=h.filter(this.config.layers,function(e){return e.id===b});a=a.geometry;if("ArcGISMapServiceLayer"===c[0].layerType)this.identifyTask=new z(c[0].url),this._identifyFeatures(a);else{null!==this.featureLayer&&void 0!==this.featureLayer&&(this.featureLayer=null);this.featureLayer=new q(c[0].url,{outFields:["*"],mode:y.layers.FeatureLayer.MODE_SELECTION});c=new A;var d=10*(this.map.extent.getWidth()/this.map.width);a=new F(a.x-d,a.y-d,a.x+d,a.y+d,this.map.spatialReference);c.geometry=
a;this.featureLayer.selectFeatures(c,q.SELECTION_NEW,m.hitch(this,function(e){1<e.length?this.emit("Message",{},[this.nls.manyFeaturesSelected]):1===e.length?(this.selectionToolbar.deactivate(),this._onTaskComplete(e[0])):this.emit("Message",{},[this.nls.noFeatureSelected])}))}},cancelSelectFeature:function(){null!==this.selectionToolbar&&void 0!==this.selectionToolbar&&""===this.selectLayer.value&&this.selectionToolbar.deactivate();f.set(this.clickAFeatureNode,"display","none")},_identifyFeatures:function(a){var b=
this,c=new B;this.identifying||(this.identifying=!0,f.set(this.loadingFeaturesNode,"display",""),c.returnGeometry=!0,c.width=this.map.width,c.height=this.map.height,c.tolerance=3,c.geometry=a,c.mapExtent=this.map.extent,c.spatialReference=this.map.spatialReference,this.identifyTask.execute(c).then(function(d){0<d.length?(b.selectionToolbar.deactivate(),b._onTaskComplete(d[0].feature)):(f.set(b.loadingFeaturesNode,"display","none"),b.identifying=!1,this.emit("Message",{},[this.nls.noFeatureSelected]))},
function(d){b._onIdentifyError(d)}))},_onTaskComplete:function(a){var b=this;this.identifying=!1;f.set(this.loadingFeaturesNode,"display","none");if(a){var c=this.selectLayer.value,d=h.filter(this.config.layers,function(L){return L.id===c});this._selectedFeature=a;switch(a.geometry.type){case "point":a.setSymbol(J);var e=a.geometry;var l=this.map.centerAt(a.geometry);break;case "polyline":a.setSymbol(r);e=a.geometry.getExtent().getCenter();a.setSymbol(r);l=this.map.centerAt(e);break;case "polygon":a.setSymbol(K),
e=a.geometry.getCentroid(),l=this.map.centerAt(e)}l.then(function(){b._showInfoWindow(d[0].alias,e,a)})}},_showInfoWindow:function(a,b,c){var d=this;this.infoWindowContent=new H({nls:this.nls,title:this.nls.select,includeReportedBy:this.config.includeReportedBy,defaultUserName:this.config.defaultUserName,onReportSubmit:function(e){d.submitReport(e)}},n.create("div"));this.map.infoWindow.setTitle(this.nls.infoWindowTitle);this.infoWindowContent.startup();this.infoWindowContent.set("layerName",a);this.infoWindowContent.set("graphic",
c);k.once(this.map.infoWindow,"hide",function(){d.selectionToolbar.activate(g.POINT);d.map.setInfoWindowOnClick(!1)});this.map.infoWindow.destroyDijits();p(".actionsPane")[0].style.display="none";this.map.infoWindow.setContent(this.infoWindowContent.domNode);this.map.infoWindow.resize(300,600);this.map.infoWindow.show(b);this.emit("SelectFeature")},_onIdentifyError:function(a){this.identifying=!1;f.set(this.loadingFeaturesNode,"display","none");this.emit("Error",{},[this.nls.errorIdentify,a])},submitReport:function(a){var b=
this;a.sessionId=this._sessionId;this.map.infoWindow.hide();this._reviewerResultsTask.writeFeatureAsResult(a,this._selectedFeature).then(function(c,d){b._onWriteFeatureAsResultComplete(c,d)},function(c){b._onWriteFeatureAsResultError(c)})},_onWriteFeatureAsResultComplete:function(a){a&&a.success?(this.emit("Message",{},["",this.nls.reportMessage]),this.selectionToolbar.activate(g.POINT)):this.emit("Error",{}[this.nls.errorReportMessage])},_onWriteFeatureAsResultError:function(a){this.selectionToolbar.activate(g.POINT);
this.emit("Error",{},[a.message,a])},reset:function(){this.selectLayer.selectedIndex=0;this.cancelSelectFeature();void 0!==this.infoWindowContent&&null!==this.infoWindowContent&&this.infoWindowContent.destroyRecursive();this.map.setInfoWindowOnClick(!1)},setDrsUrl:function(a){this._reviewerResultsTask=new G(a)},setReviewerSession:function(a){isNaN(a)?this._sessionId=1:this._sessionId=parseInt(a,10)},getLayerOptions:function(){var a="";h.forEach(this.config.layers,function(b){!0===b.show&&(a+=u.substitute('\x3coption value\x3d"${id}"\x3e${alias}\x3c/option\x3e',
b))});return a}})});