/** * Cesium - https://github.com/AnalyticalGraphicsInc/cesium * * Copyright 2011-2017 Cesium Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Columbus View (Pat. Pend.) * * Portions licensed separately. * See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details. */ /** @license when.js - https://github.com/cujojs/when MIT License (c) copyright B Cavalier & J Hann * A lightweight CommonJS Promises/A and when() implementation * when is part of the cujo.js family of libraries (http://cujojs.com/) * * Licensed under the MIT License at: * http://www.opensource.org/licenses/mit-license.php * * @version 1.7.1 */ !function(){define("Core/defined",[],function(){"use strict";function e(e){return void 0!==e&&null!==e}return e}),define("Core/DeveloperError",["./defined"],function(e){"use strict";function t(e){this.name="DeveloperError",this.message=e;var t;try{throw new Error}catch(e){t=e.stack}this.stack=t}return e(Object.create)&&(t.prototype=Object.create(Error.prototype),t.prototype.constructor=t),t.prototype.toString=function(){var t=this.name+": "+this.message;return e(this.stack)&&(t+="\n"+this.stack.toString()),t},t.throwInstantiationError=function(){throw new t("This function defines an interface and should not be called directly.")},t}),define("Core/Check",["./defined","./DeveloperError"],function(e,t){"use strict";function n(e){return e+" is required, actual value was undefined"}function r(e,t,n){return"Expected "+n+" to be typeof "+t+", actual typeof was "+e}var i={};return i.typeOf={},i.defined=function(r,i){if(!e(i))throw new t(n(r))},i.typeOf.func=function(e,n){if("function"!=typeof n)throw new t(r(typeof n,"function",e))},i.typeOf.string=function(e,n){if("string"!=typeof n)throw new t(r(typeof n,"string",e))},i.typeOf.number=function(e,n){if("number"!=typeof n)throw new t(r(typeof n,"number",e))},i.typeOf.number.lessThan=function(e,n,r){if(i.typeOf.number(e,n),n>=r)throw new t("Expected "+e+" to be less than "+r+", actual value was "+n)},i.typeOf.number.lessThanOrEquals=function(e,n,r){if(i.typeOf.number(e,n),n>r)throw new t("Expected "+e+" to be less than or equal to "+r+", actual value was "+n)},i.typeOf.number.greaterThan=function(e,n,r){if(i.typeOf.number(e,n),n<=r)throw new t("Expected "+e+" to be greater than "+r+", actual value was "+n)},i.typeOf.number.greaterThanOrEquals=function(e,n,r){if(i.typeOf.number(e,n),n=w&&(b=(b+8)%24,u=b);l=252?6:f>=248?5:f>=240?4:f>=224?3:f>=192?2:1;s[254]=s[254]=1,n.string2buf=function(e){var t,n,r,o,a,s=e.length,f=0;for(o=0;o>>6,t[a++]=128|63&n):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|63&n):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|63&n);return t},n.buf2binstring=function(e){return r(e,e.length)},n.binstring2buf=function(e){for(var t=new i.Buf8(e.length),n=0,r=t.length;n4)u[i++]=65533,n+=a-1;else{for(o&=2===a?31:3===a?15:7;a>1&&n1?u[i++]=65533:o<65536?u[i++]=o:(o-=65536,u[i++]=55296|o>>10&1023,u[i++]=56320|1023&o)}return r(u,i)},n.utf8border=function(e,t){var n;for(t=t||e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0?t:0===n?t:n+s[e[n]]>t?n:t}},{"./common":1}],3:[function(e,t,n){"use strict";function r(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==n;){a=n>2e3?2e3:n,n-=a;do{i=i+t[r++]|0,o=o+i|0}while(--a);i%=65521,o%=65521}return i|o<<16|0}t.exports=r},{}],4:[function(e,t,n){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(e,t,n){"use strict";function r(e,t,n,r){var o=i,a=r+n;e^=-1;for(var s=r;s>>8^o[255&(e^t[s])];return-1^e}var i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=r},{}],6:[function(e,t,n){"use strict";function r(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}t.exports=r},{}],7:[function(e,t,n){"use strict";t.exports=function(e,t){var n,r,i,o,a,s,f,u,c,l,h,d,w,b,m,g,p,v,k,y,_,E,x,T,S;n=e.state,r=e.next_in,T=e.input,i=r+(e.avail_in-5),o=e.next_out,S=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),f=n.dmax,u=n.wsize,c=n.whave,l=n.wnext,h=n.window,d=n.hold,w=n.bits,b=n.lencode,m=n.distcode,g=(1<>>24,d>>>=k,w-=k,0===(k=v>>>16&255))S[o++]=65535&v;else{if(!(16&k)){if(0==(64&k)){v=b[(65535&v)+(d&(1<>>=k,w-=k),w<15&&(d+=T[r++]<>>24,d>>>=k,w-=k,!(16&(k=v>>>16&255))){if(0==(64&k)){v=m[(65535&v)+(d&(1<f){e.msg="invalid distance too far back",n.mode=30;break e}if(d>>>=k,w-=k,k=o-a,_>k){if((k=_-k)>c&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(E=0,x=h,0===l){if(E+=u-k,k2;)S[o++]=x[E++],S[o++]=x[E++],S[o++]=x[E++],y-=3;y&&(S[o++]=x[E++],y>1&&(S[o++]=x[E++]))}else{E=o-_;do{S[o++]=S[E++],S[o++]=S[E++],S[o++]=S[E++],y-=3}while(y>2);y&&(S[o++]=S[E++],y>1&&(S[o++]=S[E++]))}break}}break}}while(r>3,r-=y,w-=y<<3,d&=(1<>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function i(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new p.Buf16(320),this.work=new p.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function o(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=z,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new p.Buf32(be),t.distcode=t.distdyn=new p.Buf32(me),t.sane=1,t.back=-1,A):U}function a(e){var t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,o(e)):U}function s(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?U:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,a(e))):U}function f(e,t){var n,r;return e?(r=new i,e.state=r,r.window=null,n=s(e,t),n!==A&&(e.state=null),n):U}function u(e){return f(e,ge)}function c(e){if(pe){var t;for(m=new p.Buf32(512),g=new p.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(_(x,e.lens,0,288,m,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;_(T,e.lens,0,32,g,0,e.work,{bits:5}),pe=!1}e.lencode=m,e.lenbits=9,e.distcode=g,e.distbits=5}function l(e,t,n,r){var i,o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(p.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),p.arraySet(o.window,t,n-r,i,o.wnext),r-=i,r?(p.arraySet(o.window,t,n-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=k(n.check,Oe,2,0),h=0,d=0,n.mode=j;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&h)<<8)+(h>>8))%31){e.msg="incorrect header check",n.mode=he;break}if((15&h)!==N){e.msg="unknown compression method",n.mode=he;break}if(h>>>=4,d-=4,_e=8+(15&h),0===n.wbits)n.wbits=_e;else if(_e>n.wbits){e.msg="invalid window size",n.mode=he;break}n.dmax=1<<_e,e.adler=n.check=1,n.mode=512&h?K:G,h=0,d=0;break;case j:for(;d<16;){if(0===f)break e;f--,h+=i[a++]<>8&1),512&n.flags&&(Oe[0]=255&h,Oe[1]=h>>>8&255,n.check=k(n.check,Oe,2,0)),h=0,d=0,n.mode=P;case P:for(;d<32;){if(0===f)break e;f--,h+=i[a++]<>>8&255,Oe[2]=h>>>16&255,Oe[3]=h>>>24&255,n.check=k(n.check,Oe,4,0)),h=0,d=0,n.mode=F;case F:for(;d<16;){if(0===f)break e;f--,h+=i[a++]<>8),512&n.flags&&(Oe[0]=255&h,Oe[1]=h>>>8&255,n.check=k(n.check,Oe,2,0)),h=0,d=0,n.mode=M;case M:if(1024&n.flags){for(;d<16;){if(0===f)break e;f--,h+=i[a++]<>>8&255,n.check=k(n.check,Oe,2,0)),h=0,d=0}else n.head&&(n.head.extra=null);n.mode=L;case L:if(1024&n.flags&&(m=n.length,m>f&&(m=f),m&&(n.head&&(_e=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),p.arraySet(n.head.extra,i,a,m,_e)),512&n.flags&&(n.check=k(n.check,i,m,a)),f-=m,a+=m,n.length-=m),n.length))break e;n.length=0,n.mode=H;case H:if(2048&n.flags){if(0===f)break e;m=0;do{_e=i[a+m++],n.head&&_e&&n.length<65536&&(n.head.name+=String.fromCharCode(_e))}while(_e&&m>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=G;break;case K:for(;d<32;){if(0===f)break e;f--,h+=i[a++]<>>=7&d,d-=7&d,n.mode=ue;break}for(;d<3;){if(0===f)break e;f--,h+=i[a++]<>>=1,d-=1,3&h){case 0:n.mode=J;break;case 1:if(c(n),n.mode=ne,t===B){h>>>=2,d-=2;break e}break;case 2:n.mode=$;break;case 3:e.msg="invalid block type",n.mode=he}h>>>=2,d-=2;break;case J:for(h>>>=7&d,d-=7&d;d<32;){if(0===f)break e;f--,h+=i[a++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=he;break}if(n.length=65535&h,h=0,d=0,n.mode=Q,t===B)break e;case Q:n.mode=X;case X:if(m=n.length){if(m>f&&(m=f),m>u&&(m=u),0===m)break e;p.arraySet(o,i,a,m,s),f-=m,a+=m,u-=m,s+=m,n.length-=m;break}n.mode=G;break;case $:for(;d<14;){if(0===f)break e;f--,h+=i[a++]<>>=5,d-=5,n.ndist=1+(31&h),h>>>=5,d-=5,n.ncode=4+(15&h),h>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=he;break}n.have=0,n.mode=ee;case ee:for(;n.have>>=3,d-=3}for(;n.have<19;)n.lens[Be[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,xe={bits:n.lenbits},Ee=_(E,n.lens,0,19,n.lencode,0,n.work,xe),n.lenbits=xe.bits,Ee){e.msg="invalid code lengths set",n.mode=he;break}n.have=0,n.mode=te;case te:for(;n.have>>24,ge=Se>>>16&255,pe=65535&Se,!(me<=d);){if(0===f)break e;f--,h+=i[a++]<>>=me,d-=me,n.lens[n.have++]=pe;else{if(16===pe){for(Te=me+2;d>>=me,d-=me,0===n.have){e.msg="invalid bit length repeat",n.mode=he;break}_e=n.lens[n.have-1],m=3+(3&h),h>>>=2,d-=2}else if(17===pe){for(Te=me+3;d>>=me,d-=me,_e=0,m=3+(7&h),h>>>=3,d-=3}else{for(Te=me+7;d>>=me,d-=me,_e=0,m=11+(127&h),h>>>=7,d-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=he;break}for(;m--;)n.lens[n.have++]=_e}}if(n.mode===he)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=he;break}if(n.lenbits=9,xe={bits:n.lenbits},Ee=_(x,n.lens,0,n.nlen,n.lencode,0,n.work,xe),n.lenbits=xe.bits,Ee){e.msg="invalid literal/lengths set",n.mode=he;break}if(n.distbits=6,n.distcode=n.distdyn,xe={bits:n.distbits},Ee=_(T,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,xe),n.distbits=xe.bits,Ee){e.msg="invalid distances set",n.mode=he;break}if(n.mode=ne,t===B)break e;case ne:n.mode=re;case re:if(f>=6&&u>=258){e.next_out=s,e.avail_out=u,e.next_in=a,e.avail_in=f,n.hold=h,n.bits=d,y(e,b),s=e.next_out,o=e.output,u=e.avail_out,a=e.next_in,i=e.input,f=e.avail_in,h=n.hold,d=n.bits,n.mode===G&&(n.back=-1);break}for(n.back=0;Se=n.lencode[h&(1<>>24,ge=Se>>>16&255,pe=65535&Se,!(me<=d);){if(0===f)break e;f--,h+=i[a++]<>ve)],me=Se>>>24,ge=Se>>>16&255,pe=65535&Se,!(ve+me<=d);){if(0===f)break e;f--,h+=i[a++]<>>=ve,d-=ve,n.back+=ve}if(h>>>=me,d-=me,n.back+=me,n.length=pe,0===ge){n.mode=fe;break}if(32&ge){n.back=-1,n.mode=G;break}if(64&ge){e.msg="invalid literal/length code",n.mode=he;break}n.extra=15&ge,n.mode=ie;case ie:if(n.extra){for(Te=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=oe;case oe:for(;Se=n.distcode[h&(1<>>24,ge=Se>>>16&255,pe=65535&Se,!(me<=d);){if(0===f)break e;f--,h+=i[a++]<>ve)],me=Se>>>24,ge=Se>>>16&255,pe=65535&Se,!(ve+me<=d);){if(0===f)break e;f--,h+=i[a++]<>>=ve,d-=ve,n.back+=ve}if(h>>>=me,d-=me,n.back+=me,64&ge){e.msg="invalid distance code",n.mode=he;break}n.offset=pe,n.extra=15&ge,n.mode=ae;case ae:if(n.extra){for(Te=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=he;break}n.mode=se;case se:if(0===u)break e;if(m=b-u,n.offset>m){if((m=n.offset-m)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=he;break}m>n.wnext?(m-=n.wnext,g=n.wsize-m):g=n.wnext-m,m>n.length&&(m=n.length),be=n.window}else be=o,g=s-n.offset,m=n.length;m>u&&(m=u),u-=m,n.length-=m;do{o[s++]=be[g++]}while(--m);0===n.length&&(n.mode=re);break;case fe:if(0===u)break e;o[s++]=n.length,u--,n.mode=re;break;case ue:if(n.wrap){for(;d<32;){if(0===f)break e;f--,h|=i[a++]<=1&&0===D[S];S--);if(O>S&&(O=S),0===S)return u[c++]=20971520,u[c++]=20971520,h.bits=1,0;for(T=1;T0&&(0===e||1!==S))return-1;for(N[1]=0,E=1;E<15;E++)N[E+1]=N[E]+D[E];for(x=0;x852||2===e&&R>592)return 1;for(;;){v=E-A,l[x]p?(k=z[j+l[x]],y=I[Z+l[x]]):(k=96,y=0),d=1<>A)+w]=v<<24|k<<16|y|0}while(0!==w);for(d=1<>=1;if(0!==d?(U&=d-1,U+=d):U=0,x++,0==--D[E]){if(E===S)break;E=t[n+l[x]]}if(E>O&&(U&m)!==b){for(0===A&&(A=O),g+=T,B=E-A,C=1<852||2===e&&R>592)return 1;b=U&m,u[b]=O<<24|B<<16|g-c|0}}return 0!==U&&(u[g+U]=E-A<<24|64<<16|0),h.bits=O,0}},{"../utils/common":1}],10:[function(e,t,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(e,t,n){"use strict";function r(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}t.exports=r},{}],"/lib/inflate.js":[function(e,t,n){"use strict";function r(e){if(!(this instanceof r))return new r(e);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var n=a.inflateInit2(this.strm,t.windowBits);if(n!==u.Z_OK)throw new Error(c[n]);this.header=new h,a.inflateGetHeader(this.strm,this.header)}function i(e,t){var n=new r(t);if(n.push(e,!0),n.err)throw n.msg||c[n.err];return n.result}function o(e,t){return t=t||{},t.raw=!0,i(e,t)}var a=e("./zlib/inflate"),s=e("./utils/common"),f=e("./utils/strings"),u=e("./zlib/constants"),c=e("./zlib/messages"),l=e("./zlib/zstream"),h=e("./zlib/gzheader"),d=Object.prototype.toString;r.prototype.push=function(e,t){var n,r,i,o,c,l,h=this.strm,w=this.options.chunkSize,b=this.options.dictionary,m=!1;if(this.ended)return!1;r=t===~~t?t:!0===t?u.Z_FINISH:u.Z_NO_FLUSH,"string"==typeof e?h.input=f.binstring2buf(e):"[object ArrayBuffer]"===d.call(e)?h.input=new Uint8Array(e):h.input=e,h.next_in=0,h.avail_in=h.input.length;do{if(0===h.avail_out&&(h.output=new s.Buf8(w),h.next_out=0,h.avail_out=w),n=a.inflate(h,u.Z_NO_FLUSH),n===u.Z_NEED_DICT&&b&&(l="string"==typeof b?f.string2buf(b):"[object ArrayBuffer]"===d.call(b)?new Uint8Array(b):b,n=a.inflateSetDictionary(this.strm,l)),n===u.Z_BUF_ERROR&&!0===m&&(n=u.Z_OK,m=!1),n!==u.Z_STREAM_END&&n!==u.Z_OK)return this.onEnd(n),this.ended=!0,!1;h.next_out&&(0!==h.avail_out&&n!==u.Z_STREAM_END&&(0!==h.avail_in||r!==u.Z_FINISH&&r!==u.Z_SYNC_FLUSH)||("string"===this.options.to?(i=f.utf8border(h.output,h.next_out),o=h.next_out-i,c=f.buf2string(h.output,i),h.next_out=o,h.avail_out=w-o,o&&s.arraySet(h.output,h.output,i,o,0),this.onData(c)):this.onData(s.shrinkBuf(h.output,h.next_out)))),0===h.avail_in&&0===h.avail_out&&(m=!0)}while((h.avail_in>0||0===h.avail_out)&&n!==u.Z_STREAM_END);return n===u.Z_STREAM_END&&(r=u.Z_FINISH),r===u.Z_FINISH?(n=a.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===u.Z_OK):r!==u.Z_SYNC_FLUSH||(this.onEnd(u.Z_OK),h.avail_out=0,!0)},r.prototype.onData=function(e){this.chunks.push(e)},r.prototype.onEnd=function(e){e===u.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=r,n.inflate=i,n.inflateRaw=o,n.ungzip=i},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")}),function(e){"use strict";e("ThirdParty/when",[],function(){function e(e,n,r,i){return t(e).then(n,r,i)}function t(e){var t,n;return e instanceof r?t=e:s(e)?(n=a(),e.then(function(e){n.resolve(e)},function(e){n.reject(e)},function(e){n.progress(e)}),t=n.promise):t=i(e),t}function n(t){return e(t,o)}function r(e){this.then=e}function i(e){return new r(function(n){try{return t(n?n(e):e)}catch(e){return o(e)}})}function o(e){return new r(function(n,r){try{return r?t(r(e)):o(e)}catch(e){return o(e)}})}function a(){function e(e,t,n){return h(e,t,n)}function n(e){return w(e)}function i(e){return w(o(e))}function s(e){return d(e)}var f,u,c,l,h,d,w;return u=new r(e),f={then:e,resolve:n,reject:i,progress:s,promise:u,resolver:{resolve:n,reject:i,progress:s}},c=[],l=[],h=function(e,t,n){var r,i;return r=a(),i="function"==typeof n?function(e){try{r.progress(n(e))}catch(e){r.progress(e)}}:function(e){r.progress(e)},c.push(function(n){n.then(e,t).then(r.resolve,r.reject,i)}),l.push(i),r.promise},d=function(e){return b(l,e),e},w=function(e){return e=t(e),h=e.then,w=t,d=g,b(c,e),l=c=y,e},f}function s(e){return e&&"function"==typeof e.then}function f(t,n,r,i,o){return m(2,arguments),e(t,function(t){function s(e){b(e)}function f(e){w(e)}var u,c,l,h,d,w,b,m,p,v;if(p=t.length>>>0,u=Math.max(0,Math.min(n,p)),l=[],c=p-u+1,h=[],d=a(),u)for(m=d.progress,b=function(e){h.push(e),--c||(w=b=g,d.reject(h))},w=function(e){l.push(e),--u||(w=b=g,d.resolve(l))},v=0;v>>0,r=[],u=a(),o)for(s=function(t,i){e(t,n).then(function(e){r[i]=e,--o||u.resolve(r)},u.reject)},f=0;f2;return e(t,function(e){return e=i?r:e,n.resolve(e),e},function(e){return n.reject(e),o(e)},n.progress)}function b(e,t){for(var n,r=0;n=e[r++];)n(t)}function m(e,t){for(var n,r=t.length;r>e;)if(null!=(n=t[--r])&&"function"!=typeof n)throw new Error("arg "+r+" must be a function")}function g(){}function p(e){return e}var v,k,y;return e.defer=a,e.resolve=t,e.reject=n,e.join=l,e.all=c,e.map=h,e.reduce=d,e.any=u,e.some=f,e.chain=w,e.isPromise=s,r.prototype={always:function(e,t){return this.then(e,e,t)},otherwise:function(e){return this.then(y,e)},yield:function(e){return this.then(function(){return e})},spread:function(e){return this.then(function(t){return c(t,function(t){return e.apply(y,t)})})}},k=[].slice,v=[].reduce||function(e){var t,n,r,i,o;if(o=0,t=Object(this),i=t.length>>>0,n=arguments,n.length<=1)for(;;){if(o in t){r=t[o++];break}if(++o>=i)throw new TypeError}else r=n[1];for(;o