/*!@license
* Infragistics.Web.ClientUI infragistics.ext_threading.js 21.2.20212.99
*
* Copyright (c) 2011-2022 Infragistics Inc.
*
* http://www.infragistics.com/
*
* Depends:
*     jquery-1.4.4.js
*     jquery.ui.core.js
*     jquery.ui.widget.js
*     infragistics.util.js
*     infragistics.ext_core.js
*/
(function(factory){if(typeof define==="function"&&define.amd){define(["./infragistics.util","./infragistics.ext_core"],factory)}else{factory(igRoot)}})(function($){$.ig=$.ig||{};var $$t={};$.ig.globalDefs=$.ig.globalDefs||{};$.ig.globalDefs.$$9=$$t;var $$0=$.ig.globalDefs.$$0;var $$1=$.ig.globalDefs.$$1;var $$6=$.ig.globalDefs.$$6;$.ig.$currDefinitions=$$t;$.ig.util.bulkDefine(["Task$1:a","Task:b","TaskCompletionSource$1:c"]);var $a=$.ig.intDivide,$b=$.ig.util.cast,$c=$.ig.util.defType,$d=$.ig.util.defEnum,$e=$.ig.util.getBoxIfEnum,$f=$.ig.util.getDefaultValue,$g=$.ig.util.getEnumValue,$h=$.ig.util.getValue,$i=$.ig.util.intSToU,$j=$.ig.util.nullableEquals,$k=$.ig.util.nullableIsNull,$l=$.ig.util.nullableNotEquals,$m=$.ig.util.toNullable,$n=$.ig.util.toString$1,$o=$.ig.util.u32BitwiseAnd,$p=$.ig.util.u32BitwiseOr,$q=$.ig.util.u32BitwiseXor,$r=$.ig.util.u32LS,$s=$.ig.util.unwrapNullable,$t=$.ig.util.wrapNullable,$u=String.fromCharCode,$v=$.ig.util.castObjTo$t;$d("TaskStatus:e",false,false,{Created:0,RanToCompletion:5,Canceled:6,Faulted:7});$c("Task:b","Object",{_d:null,_b:false,_a:null,init:function(a,b){if(a>0){switch(a){case 1:this.init1.apply(this,arguments);break}return}$$t.$b.init1.call(this,1,b,null)},init1:function(a,b,c){var $self=this;$.ig.$op.init.call(this);var d=function(){};var e=function(f){if(f==null){$self._b=true}else{$self._a=new $$6.c(2,"Exception occurred during task execution",f)}};this._d=b.done(d).fail(e);this._e=c},c:function(){return this.h()==5||this.h()==7||this.h()==6},h:function(){if(this._b){return 6}switch(this._d.state()){case"pending":return 0;case"resolved":return 5;case"rejected":return 7;default:return 0}},_e:null,f:function(a){var $self=this;var b=function(){a($self)};var c=function(d){a($self)};var d=this._d.done(b).fail(c);return new $$t.b(0,d)},g:function($tNewResult,a){var $self=this;var b=new $$t.c($tNewResult,0);var c=function(){try{var d=a($self);b.e(d)}catch(e){b.d(e)}};var d=function(e){c()};var e=function(f){c()};this._d.done(d).fail(e);return b._b},$type:new $.ig.Type("Task",$.ig.$ot)},true);$c("Task$1:a","Task",{$tResult:null,init:function($tResult,a,b){var $self=this;this.$tResult=$tResult;if(!this.hasOwnProperty("$type")){this.$type=this.$type.specialize(this.$tResult)}this.i=false;$$t.$b.init1.call(this,1,a,b);var c=function(d){var e=$v($self.$tResult,d);$self.m=e;$self.i=true};var d=function(e){$self.i=true};this._d.done(c).fail(d)},i:false,m:null,n:function(){if(!this.i){throw"Result is not ready yet"}if(this._a!=null){throw this._a}return this.m},j:function(a){return $$t.$b.f.call(this,function(b){a(b)})},k:function($tNewResult,a){var b=function(c){return $e($tNewResult,a(c))};return this.l($.ig.$op.$type,b).l($tNewResult,function(c){return $v($tNewResult,c.n())})},l:function($tNewResult,a){return $$t.$b.g.call(this,$tNewResult,a)},$type:new $.ig.Type("Task$1",$$t.$b.$type)},true);$c("TaskCompletionSource$1:c","Object",{$tResult:null,_a:null,init:function($tResult,a){this.$tResult=$tResult;if(!this.hasOwnProperty("$type")){this.$type=this.$type.specialize(this.$tResult)}if(a>0){switch(a){case 1:this.init1.apply(this,arguments);break}return}$$t.$c.init1.call(this,this.$tResult,1,null)},init1:function($tResult,a,b){this.$tResult=$tResult;if(!this.hasOwnProperty("$type")){this.$type=this.$type.specialize(this.$tResult)}$.ig.$op.init.call(this);this._a=$.Deferred();this._b=new $$t.a(this.$tResult,this._a.promise(),b)},c:function(){this._a.reject(null)},d:function(a){this._a.reject(a)},e:function(a){this._a.resolve($e(this.$tResult,a))},_b:null,$type:new $.ig.Type("TaskCompletionSource$1",$.ig.$ot)},true);$c("TaskFactory:d","Object",{init:function(){$.ig.$op.init.call(this)},c:function(a,b){return new $$t.b(0,this.b(this.a(a)).always(function(){b(a)}))},d:function($tResult,a,b){var c=new $$t.c($tResult,0);this.b(this.a(a)).always(function(){try{var d=b(a);c.e(d)}catch(e){c.d(e)}});return c._b},e:function($tAntecedentResult,$tResult,a,b){var c=function(d){return $e($tResult,b(d))};return this.d($.ig.$op.$type,a,c).k($tResult,function(d){return $v($tResult,d.n())})},a:function(a){var b=new Array(a.length);for(var c=0;c<a.length;c++){b[c]=a[c]._d}return b},b:function(a){var promises_=a;var b=null;b=function(p){function whenAll(){var whenDeffered=$.Deferred();if(arguments.length===0){whenDeffered.resolve();return whenDeffered}var count=arguments.length;var resolve=true;for(var i=0;i<arguments.length;i++){arguments[i].done(function(){resolve=resolve&&true}).fail(function(){resolve=resolve&&false}).always(function(){count--;if(count<=0){if(resolve){whenDeffered.resolve()}else{whenDeffered.reject()}}})}return whenDeffered}return whenAll.apply($,p)}(promises_);return b},$type:new $.ig.Type("TaskFactory",$.ig.$ot)},true)});