define(["jquery"],function(b){var a=function(c,g){var e=function(i){var h=c.createAnswerRequest(this.id,i);b.post(h.url,h.data).done(f).fail(d)};var d=b.proxy(g.reject,g);var f=function(h){if(h&&h.id&&h.state&&h.progress){if(h.state=="WAITING"){g.notify(h,b.proxy(e,h))}else{g.notify(h);if(h.state=="FINISHED"){g.resolve(h)}else{setTimeout(function(){var i=c.createStatusRequest(h.id);b.get(i.url,i.data).done(f).fail(d)},c.updateInterval||1000)}}}else{g.resolve(h)}};return{answerJobQuestion:e,onFailure:d,onProgress:f}};return function(c){this.resume=function(d){var f=b.Deferred();var g=a(c,f);var e=c.createStatusRequest(d);b.get(e.url,e.data).done(g.onProgress).fail(g.onFailure);return f};this.run=function(d,e){var f=b.Deferred();var g=a(c,f);b.post(d,e).done(g.onProgress).fail(g.onFailure);return f};return this}});