// 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/process/Processor","../sniff ../kernel dojo/_base/declare dojo/Deferred dojo/_base/lang dojo/_base/array dojo/Evented ../workers/RequestClient ../layers/GraphicsLayer".split(" "),function(f,h,b,n,d,c,k,l,g){b=b([k],{declaredClass:"esri.process.Processor",layers:null,results:null,passFeatures:!0,drawFeatures:!0,requireWorkerSupport:!0,fetchWithWorker:!1,workerCallback:null,workerClient:null,_started:null,_handlers:null,constructor:function(a){a=a||{};d.mixin(this,a);f("esri-workers")||
!1===this.requireWorkerSupport&&!1===a.requireWorkerSupport?(this._handlers={},this._notifyProcessStart=d.hitch(this,this._notifyProcessStart),this._sendFeaturesFromTask=d.hitch(this,this._sendFeaturesFromTask),this._sendFeaturesFromLayer=d.hitch(this,this._sendFeaturesFromLayer),!1!==a.autostart&&this.start()):(console.log("Browser doesn't support workers \x26 worker support is required for this processor"),this.addLayer=this.setMap=this.start=this.runProcess=function(){},this._disabled=!0)},addLayer:function(a,
m){var e=a._task,c=this._handlers[a.id]=[],b="complete";!1===this.drawFeatures&&(a._params.drawMode=!1);this.fetchWithWorker?(this.workerClient||(this.workerClient=l.getClient(this.workerCallback)),e.requestOptions={workerOptions:{worker:this.workerClient}},this.passFeatures&&c.push(e.on(b,d.partial(this._notifyProcessStart,a)))):this.passFeatures?(b=this.drawFeatures?"graphic-draw":"graphic-add",c.push(a.on(b,d.partial(this._sendFeaturesFromLayer,a)))):c.push(e.on(b,d.partial(this._sendFeaturesFromTask,
a)));!0!==m&&a.graphics&&this.runProcess(a.graphics,a.id)},removeLayer:function(a){c.forEach(this._handlers[a.id],function(a){a.remove()});delete this._handlers[a.id]},setMap:function(a){if(this.map)if(a!=this.map)this.unsetMap();else return;var b=this;c.forEach(this.layers,b.removeLayer);c.forEach(a.graphicsLayerIds,function(e){b.addLayer(a.getLayer(e))});this._handlers.map=[a.on("layer-add",function(a){a=a.layer;a.isInstanceOf(g)&&b.addLayer(a)}),a.on("layer-remove",function(a){a=a.layer;a.isInstanceOf(g)&&
b.removeLayer(a)})];this.map=a},unsetMap:function(){this.map&&(c.forEach(this._handlers.map,function(a){a.remove()}),delete this._handlers.map,c.forEach(this.layers,this.removeLayer),this.map=null)},start:function(){this.map?this.setMap(this.map):this.layers&&(d.isArray(this.layers)||(this.layers=[this.layers]),c.forEach(this.layers,this.addLayer));this._started=!0;this.emit("start",{processor:this});console.log("processor started")},stop:function(){this._started=!1;for(var a in this._handlers)this._handlers.hasOwnProperty(a)&&
(this._handlers[a].remove(),delete this._handlers[a]);this.emit("stop",{processor:this});console.log("processor stopped")},runProcess:function(a,b){},_sendFeaturesFromTask:function(){},_sendFeaturesFromLayer:function(){},_notifyProcessStart:function(){}});f("extend-esri")&&d.setObject("process.Processor",b,h);return b});