// 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
define(["dojo/Evented","dojo/_base/declare","dojo/_base/lang","dojo/_base/array","esri/geometry/geometryEngine"],function(k,h,b,e,l){return h([k],{declaredClass:"layerQueryDetails",layer:null,fields:null,intersectField:null,valueIn:null,valueOut:null,numberOfRequest:0,requestComplete:0,numberOfHits:0,totalRecords:0,currentNumber:0,deferreds:[],complete:!1,hasError:!1,constructor:function(c){h.safeMixin(this,c)},addDeferred:function(c,m){c.then(b.hitch(this,function(a){a&&e.forEach(m,b.hitch(this,
function(d){e.forEach(a.features,b.hitch(this,function(f){l.intersects(d.geometry,f.geometry)&&(e.forEach(this.fields,function(g){f.attributes[g]&&(d.attributes[this.layer.label+"_"+g]=f.attributes[g])},this),d.attributes[this.intersectField]=this.valueIn,d.symbol=this.valueInSym,this.numberOfHits++)}));this.currentNumber++;this.requestComplete++}));this.currentNumber=this.currentNumber;this.requestComplete=this.requestComplete;this.numberOfHits=this.numberOfHits;this.emit("requestComplete",{layerID:this.layer.id,
currentNumber:this.currentNumber,totalRecords:this.totalRecords,intesected:this.numberOfHits,name:this.layer.label});this.isComplete()&&this.emit("complete",{layerID:this.layer.id})}),b.hitch(this,function(a){this.hasError=!0;console.log("error: "+a);this.emit("error",{layerID:this.layer.id});return a}));this.deferreds.push(c)},isComplete:function(){return this.complete=this.numberOfRequest===this.requestComplete?!0:!1}})});