define("udx.utility.activity",["udx.utility","async","jquery"],function(){function a(c){return console.debug("udx.utility.activity","new Activity"),this.settings=b.defaults(c,{ajax:null,id:null,activity:"",args:{},poll:15e3,timeout:5e3,protocol:"ajax",format:"json",headers:{},onStart:function(){},onCreate:function(){},onPoll:function(){},onComplete:function(){},onError:function(){},onTimeout:function(){}}),this._timers={create:(new Date).getTime(),poll:void 0},a.instances[this.settings.id]=this}console.debug("udx.utility.activity","loaded");var b=(require("async").auto,require("async").series,require("udx.utility"));return Object.defineProperties(a.prototype,{create:{value:function(){console.debug("udx.utility.activity","createActivity");var a=this;return jQuery.ajax({url:a.settings.ajax,timeout:a.settings.timeout,async:!0,cache:!1,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",dataType:a.settings.format||"json",headers:a.settings.headers||{},data:b.extend({id:a.settings.id,activity:a.settings.type,event:"create"},a.settings.args),error:function c(c){console.debug("udx.utility.activity","create","::error",c),a.settings.onStart(new Error("Activity Start Error: "+c))},complete:function(b,c){console.debug("udx.utility.activity","create","::complete",c),b.responseJSON&&a.settings.onCreate(null,b.responseJSON),a._timers.poll=window.setInterval(a.poll.bind(a),a.settings.poll)}}),this},enumerable:!0,configurable:!0,writable:!0},start:{value:function(){console.debug("udx.utility.activity","startActivity");var a=this;return jQuery.ajax({url:a.settings.ajax,timeout:a.settings.timeout,async:!0,cache:!1,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",dataType:a.settings.format||"json",headers:a.settings.headers||{},data:b.extend({id:a.settings.id,activity:a.settings.type,event:"start"},a.settings.args),error:function c(c){console.debug("udx.utility.activity","start","::error",c),a.settings.onStart(new Error("Activity Start Error: "+c))},complete:function(b,c){console.debug("udx.utility.activity","start","complete",c),b.responseJSON&&a.settings.onStart(null,b.responseJSON),a._timers.poll=window.setInterval(a.poll.bind(a),a.settings.poll)}}),this},enumerable:!0,configurable:!0,writable:!0},poll:{value:function(){return this},enumerable:!0,configurable:!0,writable:!0},recover:{value:function(){return console.debug("udx.utility.activity","recoverActivity"),this},enumerable:!0,configurable:!0,writable:!0}}),Object.defineProperties(a,{create:{value:function(){return new a(arguments[0])},enumerable:!0,configurable:!0,writable:!0},instances:{value:{},enumerable:!1,configurable:!0,writable:!0}}),a});