// 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/Geoprocessing/resultrenderers/FeatureSetRenderer.html":'\x3cdiv\x3e\r\n  \x3cdiv class\x3d"output-label" data-dojo-attach-point\x3d"labelNode"\x3e\r\n    \x3cspan data-dojo-attach-point\x3d"labelContent"\x3e${nls.drawnOnMap}\x3c/span\x3e\r\n  \x3c/div\x3e\r\n  \x3cdiv class\x3d"clear-node" data-dojo-attach-point\x3d"clearNode" style\x3d"display:none"\x3e\x3c/div\x3e\r\n  \x3cdiv class\x3d"popup-menu-button" data-dojo-attach-point\x3d"exportNode" style\x3d"display:none"\x3e\x3c/div\x3e\r\n\x3c/div\x3e\r\n'}});
define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/dom-style dojo/dom-attr dojo/on dojo/dom-geometry dijit/_TemplatedMixin esri/layers/GraphicsLayer esri/layers/FeatureLayer esri/graphicsUtils esri/renderers/SimpleRenderer esri/renderers/jsonUtils esri/InfoTemplate jimu/dijit/FeatureActionPopupMenu dojo/text!./FeatureSetRenderer.html ../BaseResultRenderer ../LayerOrderUtil ./defaultSymbol ../utils".split(" "),function(t,e,g,f,n,h,u,v,w,p,x,k,q,y,z,A,B,C,l,D){return t([B,v],{baseClass:"jimu-gp-resultrenderer-base jimu-gp-renderer-draw-feature",
templateString:A,postCreate:function(){this.inherited(arguments);this.popupMenu=z.getInstance();this.value.features&&0<this.value.features.length?(this._displayText(),this._drawResultFeature(this.param,this.value)):this.value.url?(this._displayText(!0),this._addResultURL(this.param,this.value.url)):(f.set(this.clearNode,"display","none"),f.set(this.exportNode,"display","none"),this.labelContent.innerHTML=this.nls.emptyResult)},destroy:function(){this.resultLayer&&this.map.removeLayer(this.resultLayer);
this.inherited(arguments)},_displayText:function(a){f.set(this.clearNode,"display","");n.set(this.clearNode,"title",this.nls.clear);this.own(h(this.clearNode,"click",e.hitch(this,function(){this.resultLayer&&(this.map.infoWindow.isShowing&&this.map.infoWindow.hide(),this.resultLayer.clear(),this.map.removeLayer(this.resultLayer));f.set(this.exportNode,"display","none");f.set(this.clearNode,"display","none");this.labelContent.innerHTML=this.nls.cleared})));a||(f.set(this.exportNode,"display",""),n.set(this.exportNode,
"title",this.nls.exportOutput),this.own(h(this.exportNode,"click",e.hitch(this,this._showActions))))},_showActions:function(a){this.popupMenu.prepareActions(this.value,this.config.showExportButton).then(e.hitch(this,function(){var c=u.position(a.target);this.popupMenu.show(c)}))},_addResultURL:function(a,c){this.resultLayer=new p(c,{id:this.widgetUID+a.name});this.resultLayer.title=a.label||a.name;a.renderer&&(c=q.fromJson(a.renderer),!1===a.renderer._showOthersSymbol&&(c.defaultSymbol=null),this.resultLayer.setRenderer(c));
this.resultLayer.setVisibility(!0!==a.layerInvisible);this._addResultLayer(a.name);this.own(h(this.resultLayer,"load",e.hitch(this,function(b){b.layer&&b.layer.fullExtent&&this.map.setExtent(b.layer.fullExtent.expand(1.2))})))},_drawResultFeature:function(a,c){var b,d=D.useDynamicSchema(a,this.config);if(!a.popup||d)a.popup={enablePopup:!0,title:"",fields:[]};a.popup.enablePopup&&(b=new y(a.popup.title||"${Non-Exist-Field}",this._generatePopupContent(c,d)));if(this.config.shareResults&&!d){if(!a.defaultValue||
!a.defaultValue.geometryType)throw Error("Output parameter default value does not provide enough information to draw feature layer.");a.defaultValue.name=a.name;this.resultLayer=new p({layerDefinition:a.defaultValue,featureSet:null},{id:this.widgetUID+a.name,infoTemplate:b})}else this.resultLayer=new w({id:this.widgetUID+a.name,infoTemplate:b});g.forEach(c.features,function(m){this.resultLayer.add(m)},this);this.resultLayer.title=a.label||a.name;b=a.renderer;d||!b?"esriGeometryPoint"===c.geometryType||
"esriGeometryMultipoint"===c.geometryType?b=new k(l.pointSymbol):"esriGeometryPolyline"===c.geometryType?b=new k(l.lineSymbol):"esriGeometryPolygon"===c.geometryType&&(b=new k(l.polygonSymbol)):(b=q.fromJson(b),!1===a.renderer._showOthersSymbol&&(b.defaultSymbol=null));this.resultLayer.setRenderer(b);this.resultLayer.setVisibility(!0!==a.layerInvisible);this._addResultLayer(a.name);try{if(c.features&&0<c.features.length&&c.features[0].geometry){var r=x.graphicsExtent(c.features);r&&(this.resultLayer.fullExtent=
r)}}catch(m){console.error(m)}},_addResultLayer:function(a){var c=new C(this.config,this.map);try{c.calculateLayerIndex(a,this.widgetUID).then(e.hitch(this,function(b){-1!==b?this.map.addLayer(this.resultLayer,b):this.map.addLayer(this.resultLayer)}))}catch(b){console.error(b.message),console.warn("Draw result feature set on the top of map"),this.map.addLayer(this.resultLayer)}},_generatePopupContent:function(a,c){var b="";a=!c&&this.param.popup.fields&&0<this.param.popup.fields.length?g.filter(this.param.popup.fields,
e.hitch(this,function(d){return!1!==d.visible})):a.fields;g.forEach(a,function(d){b+='\x3ctr valign\x3d"top"\x3e\x3ctd class\x3d"attr-name"\x3e'+d.alias+'\x3c/td\x3e\x3ctd class\x3d"attr-value"\x3e${'+d.name+"}\x3c/td\x3e\x3c/tr\x3e"});return'\x3cdiv class\x3d"geoprocessing-popup"\x3e\x3ctable class\x3d"geoprocessing-popup-table" cellpadding\x3d"0" cellspacing\x3d"0"\x3e\x3ctbody\x3e'+b+"\x3c/tbody\x3e\x3c/table\x3e\x3c/div\x3e"}})});