UnZipTerrainData.js 28.5 KB
/**
 * 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(){!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=o(),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,a)}function r(e){this.then=e}function i(e){var n=new r(function(n){try{return t(n?n(e):e)}catch(r){return a(r)}});return n}function a(e){var n=new r(function(n,r){try{return r?t(r(e)):a(e)}catch(i){return a(i)}});return n}function o(){function e(e,t,n){return d(e,t,n)}function n(e){return m(e)}function i(e){return m(a(e))}function s(e){return h(e)}var f,u,c,l,d,h,m;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=[],d=function(e,t,n){var r,i;return r=o(),i="function"==typeof n?function(e){try{r.progress(n(e))}catch(t){r.progress(t)}}:function(e){r.progress(e)},c.push(function(n){n.then(e,t).then(r.resolve,r.reject,i)}),l.push(i),r.promise},h=function(e){return w(l,e),e},m=function(e){return e=t(e),d=e.then,m=t,h=k,w(c,e),l=c=p,e},f}function s(e){return e&&"function"==typeof e.then}function f(t,n,r,i,a){return b(2,arguments),e(t,function(t){function s(e){w(e)}function f(e){m(e)}var u,c,l,d,h,m,w,b,g,v;if(g=t.length>>>0,u=Math.max(0,Math.min(n,g)),l=[],c=g-u+1,d=[],h=o(),u)for(b=h.progress,w=function(e){d.push(e),--c||(m=w=k,h.reject(d))},m=function(e){l.push(e),--u||(m=w=k,h.resolve(l))},v=0;g>v;++v)v in t&&e(t[v],f,s,b);else h.resolve(l);return h.then(r,i,a)})}function u(e,t,n,r){function i(e){return t?t(e[0]):e[0]}return f(e,1,i,n,r)}function c(e,t,n,r){return b(1,arguments),d(e,g).then(t,n,r)}function l(){return d(arguments,g)}function d(t,n){return e(t,function(t){var r,i,a,s,f,u;if(a=i=t.length>>>0,r=[],u=o(),a)for(s=function(t,i){e(t,n).then(function(e){r[i]=e,--a||u.resolve(r)},u.reject)},f=0;i>f;f++)f in t?s(t[f],f):--a;else u.resolve(r);return u.promise})}function h(t,n){var r=_.call(arguments,1);return e(t,function(t){var i;return i=t.length,r[0]=function(t,r,a){return e(t,function(t){return e(r,function(e){return n(t,e,a,i)})})},v.apply(t,r)})}function m(t,n,r){var i=arguments.length>2;return e(t,function(e){return e=i?r:e,n.resolve(e),e},function(e){return n.reject(e),a(e)},n.progress)}function w(e,t){for(var n,r=0;n=e[r++];)n(t)}function b(e,t){for(var n,r=t.length;r>e;)if(n=t[--r],null!=n&&"function"!=typeof n)throw new Error("arg "+r+" must be a function")}function k(){}function g(e){return e}var v,_,p;return e.defer=o,e.resolve=t,e.reject=n,e.join=l,e.all=c,e.map=d,e.reduce=h,e.any=u,e.some=f,e.chain=m,e.isPromise=s,r.prototype={always:function(e,t){return this.then(e,e,t)},otherwise:function(e){return this.then(p,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(p,t)})})}},_=[].slice,v=[].reduce||function(e){var t,n,r,i,a;if(a=0,t=Object(this),i=t.length>>>0,n=arguments,n.length<=1)for(;;){if(a in t){r=t[a++];break}if(++a>=i)throw new TypeError}else r=n[1];for(;i>a;++a)a in t&&(r=e(r,t[a],a,t));return r},e})}("function"==typeof define&&define.amd?define:function(e){"object"==typeof exports?module.exports=e():this.when=e()}),define("Core/defined",[],function(){"use strict";function e(e){return void 0!==e&&null!==e}return e}),define("Core/freezeObject",["./defined"],function(e){"use strict";var t=Object.freeze;return e(t)||(t=function(e){return e}),t}),define("Core/defaultValue",["./freezeObject"],function(e){"use strict";function t(e,t){return void 0!==e&&null!==e?e:t}return t.EMPTY_OBJECT=e({}),t}),define("Core/formatError",["./defined"],function(e){"use strict";function t(t){var n,r=t.name,i=t.message;n=e(r)&&e(i)?r+": "+i:t.toString();var a=t.stack;return e(a)&&(n+="\n"+a),n}return t}),define("Workers/createTaskProcessorWorker",["../ThirdParty/when","../Core/defaultValue","../Core/defined","../Core/formatError"],function(e,t,n,r){"use strict";function i(t,n,r){var i;try{return i=t(n,r)}catch(a){return e.reject(a)}}function a(a){var o;return function(s){var f=s.data,u=[],c={id:f.id,result:void 0,error:void 0};return e(i(a,f.parameters,u)).then(function(e){c.result=e}).otherwise(function(e){e instanceof Error?c.error={name:e.name,message:e.message,stack:e.stack}:c.error=e}).always(function(){n(o)||(o=t(self.webkitPostMessage,self.postMessage)),f.canTransferArrayBuffer||(u.length=0);try{o(c,u)}catch(e){c.result=void 0,c.error="postMessage failed with error: "+r(e)+"\n  with responseMessage: "+JSON.stringify(c),o(c)}})}}return a}),function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define("ThirdParty/pako_inflate",[],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.pako=e()}}(function(){return function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var f="function"==typeof require&&require;if(!s&&f)return f(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[o]={exports:{}};t[o][0].call(c.exports,function(e){var n=t[o][1][e];return i(n?n:e)},c,c.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray)return void e.set(t.subarray(n,n+r),i);for(var a=0;r>a;a++)e[i+a]=t[n+a]},flattenChunks:function(e){var t,n,r,i,a,o;for(r=0,t=0,n=e.length;n>t;t++)r+=e[t].length;for(o=new Uint8Array(r),i=0,t=0,n=e.length;n>t;t++)a=e[t],o.set(a,i),i+=a.length;return o}},a={arraySet:function(e,t,n,r,i){for(var a=0;r>a;a++)e[i+a]=t[n+a]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,i)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,a))},n.setTyped(r)},{}],2:[function(e,t,n){"use strict";function r(e,t){if(65537>t&&(e.subarray&&o||!e.subarray&&a))return String.fromCharCode.apply(null,i.shrinkBuf(e,t));for(var n="",r=0;t>r;r++)n+=String.fromCharCode(e[r]);return n}var i=e("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(s){a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(s){o=!1}for(var f=new i.Buf8(256),u=0;256>u;u++)f[u]=u>=252?6:u>=248?5:u>=240?4:u>=224?3:u>=192?2:1;f[254]=f[254]=1,n.string2buf=function(e){var t,n,r,a,o,s=e.length,f=0;for(a=0;s>a;a++)n=e.charCodeAt(a),55296===(64512&n)&&s>a+1&&(r=e.charCodeAt(a+1),56320===(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),a++)),f+=128>n?1:2048>n?2:65536>n?3:4;for(t=new i.Buf8(f),o=0,a=0;f>o;a++)n=e.charCodeAt(a),55296===(64512&n)&&s>a+1&&(r=e.charCodeAt(a+1),56320===(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),a++)),128>n?t[o++]=n:2048>n?(t[o++]=192|n>>>6,t[o++]=128|63&n):65536>n?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|63&n):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=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;r>n;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,i,a,o,s=t||e.length,u=new Array(2*s);for(i=0,n=0;s>n;)if(a=e[n++],128>a)u[i++]=a;else if(o=f[a],o>4)u[i++]=65533,n+=o-1;else{for(a&=2===o?31:3===o?15:7;o>1&&s>n;)a=a<<6|63&e[n++],o--;o>1?u[i++]=65533:65536>a?u[i++]=a:(a-=65536,u[i++]=55296|a>>10&1023,u[i++]=56320|1023&a)}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 0>n?t:0===n?t:n+f[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,a=e>>>16&65535|0,o=0;0!==n;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<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(){for(var e,t=[],n=0;256>n;n++){e=n;for(var r=0;8>r;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}function i(e,t,n,r){var i=a,o=r+n;e^=-1;for(var s=r;o>s;s++)e=e>>>8^i[255&(e^t[s])];return-1^e}var a=r();t.exports=i},{}],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";var r=30,i=12;t.exports=function(e,t){var n,a,o,s,f,u,c,l,d,h,m,w,b,k,g,v,_,p,y,x,E,S,B,Z,A;n=e.state,a=e.next_in,Z=e.input,o=a+(e.avail_in-5),s=e.next_out,A=e.output,f=s-(t-e.avail_out),u=s+(e.avail_out-257),c=n.dmax,l=n.wsize,d=n.whave,h=n.wnext,m=n.window,w=n.hold,b=n.bits,k=n.lencode,g=n.distcode,v=(1<<n.lenbits)-1,_=(1<<n.distbits)-1;e:do{15>b&&(w+=Z[a++]<<b,b+=8,w+=Z[a++]<<b,b+=8),p=k[w&v];t:for(;;){if(y=p>>>24,w>>>=y,b-=y,y=p>>>16&255,0===y)A[s++]=65535&p;else{if(!(16&y)){if(0===(64&y)){p=k[(65535&p)+(w&(1<<y)-1)];continue t}if(32&y){n.mode=i;break e}e.msg="invalid literal/length code",n.mode=r;break e}x=65535&p,y&=15,y&&(y>b&&(w+=Z[a++]<<b,b+=8),x+=w&(1<<y)-1,w>>>=y,b-=y),15>b&&(w+=Z[a++]<<b,b+=8,w+=Z[a++]<<b,b+=8),p=g[w&_];n:for(;;){if(y=p>>>24,w>>>=y,b-=y,y=p>>>16&255,!(16&y)){if(0===(64&y)){p=g[(65535&p)+(w&(1<<y)-1)];continue n}e.msg="invalid distance code",n.mode=r;break e}if(E=65535&p,y&=15,y>b&&(w+=Z[a++]<<b,b+=8,y>b&&(w+=Z[a++]<<b,b+=8)),E+=w&(1<<y)-1,E>c){e.msg="invalid distance too far back",n.mode=r;break e}if(w>>>=y,b-=y,y=s-f,E>y){if(y=E-y,y>d&&n.sane){e.msg="invalid distance too far back",n.mode=r;break e}if(S=0,B=m,0===h){if(S+=l-y,x>y){x-=y;do A[s++]=m[S++];while(--y);S=s-E,B=A}}else if(y>h){if(S+=l+h-y,y-=h,x>y){x-=y;do A[s++]=m[S++];while(--y);if(S=0,x>h){y=h,x-=y;do A[s++]=m[S++];while(--y);S=s-E,B=A}}}else if(S+=h-y,x>y){x-=y;do A[s++]=m[S++];while(--y);S=s-E,B=A}for(;x>2;)A[s++]=B[S++],A[s++]=B[S++],A[s++]=B[S++],x-=3;x&&(A[s++]=B[S++],x>1&&(A[s++]=B[S++]))}else{S=s-E;do A[s++]=A[S++],A[s++]=A[S++],A[s++]=A[S++],x-=3;while(x>2);x&&(A[s++]=A[S++],x>1&&(A[s++]=A[S++]))}break}}break}}while(o>a&&u>s);x=b>>3,a-=x,b-=x<<3,w&=(1<<b)-1,e.next_in=a,e.next_out=s,e.avail_in=o>a?5+(o-a):5-(a-o),e.avail_out=u>s?257+(u-s):257-(s-u),n.hold=w,n.bits=b}},{}],8:[function(e,t,n){"use strict";function r(e){return(e>>>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 g.Buf16(320),this.work=new g.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(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=j,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new g.Buf32(we),t.distcode=t.distdyn=new g.Buf32(be),t.sane=1,t.back=-1,C):T}function o(e){var t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,a(e)):T}function s(e,t){var n,r;return e&&e.state?(r=e.state,0>t?(n=0,t=-t):(n=(t>>4)+1,48>t&&(t&=15)),t&&(8>t||t>15)?T:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,o(e))):T}function f(e,t){var n,r;return e?(r=new i,e.state=r,r.window=null,n=s(e,t),n!==C&&(e.state=null),n):T}function u(e){return f(e,ge)}function c(e){if(ve){var t;for(b=new g.Buf32(512),k=new g.Buf32(32),t=0;144>t;)e.lens[t++]=8;for(;256>t;)e.lens[t++]=9;for(;280>t;)e.lens[t++]=7;for(;288>t;)e.lens[t++]=8;for(y(E,e.lens,0,288,b,0,e.work,{bits:9}),t=0;32>t;)e.lens[t++]=5;y(S,e.lens,0,32,k,0,e.work,{bits:5}),ve=!1}e.lencode=b,e.lenbits=9,e.distcode=k,e.distbits=5}function l(e,t,n,r){var i,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new g.Buf8(a.wsize)),r>=a.wsize?(g.arraySet(a.window,t,n-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>r&&(i=r),g.arraySet(a.window,t,n-r,i,a.wnext),r-=i,r?(g.arraySet(a.window,t,n-r,r,0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}function d(e,t){var n,i,a,o,s,f,u,d,h,m,w,b,k,we,be,ke,ge,ve,_e,pe,ye,xe,Ee,Se,Be=0,Ze=new g.Buf8(4),Ae=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return T;n=e.state,n.mode===G&&(n.mode=J),s=e.next_out,a=e.output,u=e.avail_out,o=e.next_in,i=e.input,f=e.avail_in,d=n.hold,h=n.bits,m=f,w=u,xe=C;e:for(;;)switch(n.mode){case j:if(0===n.wrap){n.mode=J;break}for(;16>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}if(2&n.wrap&&35615===d){n.check=0,Ze[0]=255&d,Ze[1]=d>>>8&255,n.check=_(n.check,Ze,2,0),d=0,h=0,n.mode=D;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",n.mode=de;break}if((15&d)!==I){e.msg="unknown compression method",n.mode=de;break}if(d>>>=4,h-=4,ye=(15&d)+8,0===n.wbits)n.wbits=ye;else if(ye>n.wbits){e.msg="invalid window size",n.mode=de;break}n.dmax=1<<ye,e.adler=n.check=1,n.mode=512&d?W:G,d=0,h=0;break;case D:for(;16>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}if(n.flags=d,(255&n.flags)!==I){e.msg="unknown compression method",n.mode=de;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=de;break}n.head&&(n.head.text=d>>8&1),512&n.flags&&(Ze[0]=255&d,Ze[1]=d>>>8&255,n.check=_(n.check,Ze,2,0)),d=0,h=0,n.mode=F;case F:for(;32>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}n.head&&(n.head.time=d),512&n.flags&&(Ze[0]=255&d,Ze[1]=d>>>8&255,Ze[2]=d>>>16&255,Ze[3]=d>>>24&255,n.check=_(n.check,Ze,4,0)),d=0,h=0,n.mode=L;case L:for(;16>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}n.head&&(n.head.xflags=255&d,n.head.os=d>>8),512&n.flags&&(Ze[0]=255&d,Ze[1]=d>>>8&255,n.check=_(n.check,Ze,2,0)),d=0,h=0,n.mode=M;case M:if(1024&n.flags){for(;16>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}n.length=d,n.head&&(n.head.extra_len=d),512&n.flags&&(Ze[0]=255&d,Ze[1]=d>>>8&255,n.check=_(n.check,Ze,2,0)),d=0,h=0}else n.head&&(n.head.extra=null);n.mode=H;case H:if(1024&n.flags&&(b=n.length,b>f&&(b=f),b&&(n.head&&(ye=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),g.arraySet(n.head.extra,i,o,b,ye)),512&n.flags&&(n.check=_(n.check,i,b,o)),f-=b,o+=b,n.length-=b),n.length))break e;n.length=0,n.mode=P;case P:if(2048&n.flags){if(0===f)break e;b=0;do ye=i[o+b++],n.head&&ye&&n.length<65536&&(n.head.name+=String.fromCharCode(ye));while(ye&&f>b);if(512&n.flags&&(n.check=_(n.check,i,b,o)),f-=b,o+=b,ye)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=K;case K:if(4096&n.flags){if(0===f)break e;b=0;do ye=i[o+b++],n.head&&ye&&n.length<65536&&(n.head.comment+=String.fromCharCode(ye));while(ye&&f>b);if(512&n.flags&&(n.check=_(n.check,i,b,o)),f-=b,o+=b,ye)break e}else n.head&&(n.head.comment=null);n.mode=Y;case Y:if(512&n.flags){for(;16>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}if(d!==(65535&n.check)){e.msg="header crc mismatch",n.mode=de;break}d=0,h=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=G;break;case W:for(;32>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}e.adler=n.check=r(d),d=0,h=0,n.mode=q;case q:if(0===n.havedict)return e.next_out=s,e.avail_out=u,e.next_in=o,e.avail_in=f,n.hold=d,n.bits=h,O;e.adler=n.check=1,n.mode=G;case G:if(t===Z||t===A)break e;case J:if(n.last){d>>>=7&h,h-=7&h,n.mode=ue;break}for(;3>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}switch(n.last=1&d,d>>>=1,h-=1,3&d){case 0:n.mode=V;break;case 1:if(c(n),n.mode=ne,t===A){d>>>=2,h-=2;break e}break;case 2:n.mode=$;break;case 3:e.msg="invalid block type",n.mode=de}d>>>=2,h-=2;break;case V:for(d>>>=7&h,h-=7&h;32>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}if((65535&d)!==(d>>>16^65535)){e.msg="invalid stored block lengths",n.mode=de;break}if(n.length=65535&d,d=0,h=0,n.mode=X,t===A)break e;case X:n.mode=Q;case Q:if(b=n.length){if(b>f&&(b=f),b>u&&(b=u),0===b)break e;g.arraySet(a,i,o,b,s),f-=b,o+=b,u-=b,s+=b,n.length-=b;break}n.mode=G;break;case $:for(;14>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}if(n.nlen=(31&d)+257,d>>>=5,h-=5,n.ndist=(31&d)+1,d>>>=5,h-=5,n.ncode=(15&d)+4,d>>>=4,h-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=de;break}n.have=0,n.mode=ee;case ee:for(;n.have<n.ncode;){for(;3>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}n.lens[Ae[n.have++]]=7&d,d>>>=3,h-=3}for(;n.have<19;)n.lens[Ae[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,Ee={bits:n.lenbits},xe=y(x,n.lens,0,19,n.lencode,0,n.work,Ee),n.lenbits=Ee.bits,xe){e.msg="invalid code lengths set",n.mode=de;break}n.have=0,n.mode=te;case te:for(;n.have<n.nlen+n.ndist;){for(;Be=n.lencode[d&(1<<n.lenbits)-1],be=Be>>>24,ke=Be>>>16&255,ge=65535&Be,!(h>=be);){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}if(16>ge)d>>>=be,h-=be,n.lens[n.have++]=ge;else{if(16===ge){for(Se=be+2;Se>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}if(d>>>=be,h-=be,0===n.have){e.msg="invalid bit length repeat",n.mode=de;break}ye=n.lens[n.have-1],b=3+(3&d),d>>>=2,h-=2}else if(17===ge){for(Se=be+3;Se>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}d>>>=be,h-=be,ye=0,b=3+(7&d),d>>>=3,h-=3}else{for(Se=be+7;Se>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}d>>>=be,h-=be,ye=0,b=11+(127&d),d>>>=7,h-=7}if(n.have+b>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=de;break}for(;b--;)n.lens[n.have++]=ye}}if(n.mode===de)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=de;break}if(n.lenbits=9,Ee={bits:n.lenbits},xe=y(E,n.lens,0,n.nlen,n.lencode,0,n.work,Ee),n.lenbits=Ee.bits,xe){e.msg="invalid literal/lengths set",n.mode=de;break}if(n.distbits=6,n.distcode=n.distdyn,Ee={bits:n.distbits},xe=y(S,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,Ee),n.distbits=Ee.bits,xe){e.msg="invalid distances set",n.mode=de;break}if(n.mode=ne,t===A)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=o,e.avail_in=f,n.hold=d,n.bits=h,p(e,w),s=e.next_out,a=e.output,u=e.avail_out,o=e.next_in,i=e.input,f=e.avail_in,d=n.hold,h=n.bits,n.mode===G&&(n.back=-1);break}for(n.back=0;Be=n.lencode[d&(1<<n.lenbits)-1],be=Be>>>24,ke=Be>>>16&255,ge=65535&Be,!(h>=be);){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}if(ke&&0===(240&ke)){for(ve=be,_e=ke,pe=ge;Be=n.lencode[pe+((d&(1<<ve+_e)-1)>>ve)],be=Be>>>24,ke=Be>>>16&255,ge=65535&Be,!(h>=ve+be);){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}d>>>=ve,h-=ve,n.back+=ve}if(d>>>=be,h-=be,n.back+=be,n.length=ge,0===ke){n.mode=fe;break}if(32&ke){n.back=-1,n.mode=G;break}if(64&ke){e.msg="invalid literal/length code",n.mode=de;break}n.extra=15&ke,n.mode=ie;case ie:if(n.extra){for(Se=n.extra;Se>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}n.length+=d&(1<<n.extra)-1,d>>>=n.extra,h-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=ae;case ae:for(;Be=n.distcode[d&(1<<n.distbits)-1],be=Be>>>24,ke=Be>>>16&255,ge=65535&Be,!(h>=be);){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}if(0===(240&ke)){for(ve=be,_e=ke,pe=ge;Be=n.distcode[pe+((d&(1<<ve+_e)-1)>>ve)],be=Be>>>24,ke=Be>>>16&255,ge=65535&Be,!(h>=ve+be);){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}d>>>=ve,h-=ve,n.back+=ve}if(d>>>=be,h-=be,n.back+=be,64&ke){e.msg="invalid distance code",n.mode=de;break}n.offset=ge,n.extra=15&ke,n.mode=oe;case oe:if(n.extra){for(Se=n.extra;Se>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}n.offset+=d&(1<<n.extra)-1,d>>>=n.extra,h-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=de;break}n.mode=se;case se:if(0===u)break e;if(b=w-u,n.offset>b){if(b=n.offset-b,b>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=de;break}b>n.wnext?(b-=n.wnext,k=n.wsize-b):k=n.wnext-b,b>n.length&&(b=n.length),we=n.window}else we=a,k=s-n.offset,b=n.length;b>u&&(b=u),u-=b,n.length-=b;do a[s++]=we[k++];while(--b);0===n.length&&(n.mode=re);break;case fe:if(0===u)break e;a[s++]=n.length,u--,n.mode=re;break;case ue:if(n.wrap){for(;32>h;){if(0===f)break e;f--,d|=i[o++]<<h,h+=8}if(w-=u,e.total_out+=w,n.total+=w,w&&(e.adler=n.check=n.flags?_(n.check,a,w,s-w):v(n.check,a,w,s-w)),w=u,(n.flags?d:r(d))!==n.check){e.msg="incorrect data check",n.mode=de;break}d=0,h=0}n.mode=ce;case ce:if(n.wrap&&n.flags){for(;32>h;){if(0===f)break e;f--,d+=i[o++]<<h,h+=8}if(d!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=de;break}d=0,h=0}n.mode=le;case le:xe=z;break e;case de:xe=N;break e;case he:return R;case me:default:return T}return e.next_out=s,e.avail_out=u,e.next_in=o,e.avail_in=f,n.hold=d,n.bits=h,(n.wsize||w!==e.avail_out&&n.mode<de&&(n.mode<ue||t!==B))&&l(e,e.output,e.next_out,w-e.avail_out)?(n.mode=he,R):(m-=e.avail_in,w-=e.avail_out,e.total_in+=m,e.total_out+=w,n.total+=w,n.wrap&&w&&(e.adler=n.check=n.flags?_(n.check,a,w,e.next_out-w):v(n.check,a,w,e.next_out-w)),e.data_type=n.bits+(n.last?64:0)+(n.mode===G?128:0)+(n.mode===ne||n.mode===X?256:0),(0===m&&0===w||t===B)&&xe===C&&(xe=U),xe)}function h(e){if(!e||!e.state)return T;var t=e.state;return t.window&&(t.window=null),e.state=null,C}function m(e,t){var n;return e&&e.state?(n=e.state,0===(2&n.wrap)?T:(n.head=t,t.done=!1,C)):T}function w(e,t){var n,r,i,a=t.length;return e&&e.state?(n=e.state,0!==n.wrap&&n.mode!==q?T:n.mode===q&&(r=1,r=v(r,t,a,0),r!==n.check)?N:(i=l(e,t,a,a))?(n.mode=he,R):(n.havedict=1,C)):T}var b,k,g=e("../utils/common"),v=e("./adler32"),_=e("./crc32"),p=e("./inffast"),y=e("./inftrees"),x=0,E=1,S=2,B=4,Z=5,A=6,C=0,z=1,O=2,T=-2,N=-3,R=-4,U=-5,I=8,j=1,D=2,F=3,L=4,M=5,H=6,P=7,K=8,Y=9,W=10,q=11,G=12,J=13,V=14,X=15,Q=16,$=17,ee=18,te=19,ne=20,re=21,ie=22,ae=23,oe=24,se=25,fe=26,ue=27,ce=28,le=29,de=30,he=31,me=32,we=852,be=592,ke=15,ge=ke,ve=!0;n.inflateReset=o,n.inflateReset2=s,n.inflateResetKeep=a,n.inflateInit=u,n.inflateInit2=f,n.inflate=d,n.inflateEnd=h,n.inflateGetHeader=m,n.inflateSetDictionary=w,n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,n){"use strict";var r=e("../utils/common"),i=15,a=852,o=592,s=0,f=1,u=2,c=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],d=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],h=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,n,m,w,b,k,g){var v,_,p,y,x,E,S,B,Z,A=g.bits,C=0,z=0,O=0,T=0,N=0,R=0,U=0,I=0,j=0,D=0,F=null,L=0,M=new r.Buf16(i+1),H=new r.Buf16(i+1),P=null,K=0;for(C=0;i>=C;C++)M[C]=0;for(z=0;m>z;z++)M[t[n+z]]++;for(N=A,T=i;T>=1&&0===M[T];T--);if(N>T&&(N=T),0===T)return w[b++]=20971520,w[b++]=20971520,g.bits=1,0;for(O=1;T>O&&0===M[O];O++);for(O>N&&(N=O),I=1,C=1;i>=C;C++)if(I<<=1,I-=M[C],0>I)return-1;if(I>0&&(e===s||1!==T))return-1;for(H[1]=0,C=1;i>C;C++)H[C+1]=H[C]+M[C];for(z=0;m>z;z++)0!==t[n+z]&&(k[H[t[n+z]]++]=z);if(e===s?(F=P=k,E=19):e===f?(F=c,L-=257,P=l,K-=257,E=256):(F=d,P=h,E=-1),D=0,z=0,C=O,x=b,R=N,U=0,p=-1,j=1<<N,y=j-1,e===f&&j>a||e===u&&j>o)return 1;for(;;){S=C-U,k[z]<E?(B=0,Z=k[z]):k[z]>E?(B=P[K+k[z]],Z=F[L+k[z]]):(B=96,Z=0),v=1<<C-U,_=1<<R,O=_;do _-=v,w[x+(D>>U)+_]=S<<24|B<<16|Z|0;while(0!==_);for(v=1<<C-1;D&v;)v>>=1;if(0!==v?(D&=v-1,D+=v):D=0,z++,0===--M[C]){if(C===T)break;C=t[n+k[z]]}if(C>N&&(D&y)!==p){for(0===U&&(U=N),x+=O,R=C-U,I=1<<R;T>R+U&&(I-=M[R+U],!(0>=I));)R++,I<<=1;if(j+=1<<R,e===f&&j>a||e===u&&j>o)return 1;p=D&y,w[p]=N<<24|R<<16|x-b|0}}return 0!==D&&(w[x+D]=C-U<<24|64<<16|0),g.bits=N,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=o.inflateInit2(this.strm,t.windowBits);if(n!==u.Z_OK)throw new Error(c[n]);this.header=new d,o.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 a(e,t){return t=t||{},t.raw=!0,i(e,t)}var o=e("./zlib/inflate"),s=e("./utils/common"),f=e("./utils/strings"),u=e("./zlib/constants"),c=e("./zlib/messages"),l=e("./zlib/zstream"),d=e("./zlib/gzheader"),h=Object.prototype.toString;r.prototype.push=function(e,t){var n,r,i,a,c,l,d=this.strm,m=this.options.chunkSize,w=this.options.dictionary,b=!1;if(this.ended)return!1;r=t===~~t?t:t===!0?u.Z_FINISH:u.Z_NO_FLUSH,"string"==typeof e?d.input=f.binstring2buf(e):"[object ArrayBuffer]"===h.call(e)?d.input=new Uint8Array(e):d.input=e,d.next_in=0,d.avail_in=d.input.length;do{if(0===d.avail_out&&(d.output=new s.Buf8(m),d.next_out=0,d.avail_out=m),n=o.inflate(d,u.Z_NO_FLUSH),n===u.Z_NEED_DICT&&w&&(l="string"==typeof w?f.string2buf(w):"[object ArrayBuffer]"===h.call(w)?new Uint8Array(w):w,n=o.inflateSetDictionary(this.strm,l)),n===u.Z_BUF_ERROR&&b===!0&&(n=u.Z_OK,b=!1),n!==u.Z_STREAM_END&&n!==u.Z_OK)return this.onEnd(n),this.ended=!0,!1;d.next_out&&(0===d.avail_out||n===u.Z_STREAM_END||0===d.avail_in&&(r===u.Z_FINISH||r===u.Z_SYNC_FLUSH))&&("string"===this.options.to?(i=f.utf8border(d.output,d.next_out),a=d.next_out-i,c=f.buf2string(d.output,i),d.next_out=a,d.avail_out=m-a,a&&s.arraySet(d.output,d.output,i,a,0),this.onData(c)):this.onData(s.shrinkBuf(d.output,d.next_out))),0===d.avail_in&&0===d.avail_out&&(b=!0)}while((d.avail_in>0||0===d.avail_out)&&n!==u.Z_STREAM_END);return n===u.Z_STREAM_END&&(r=u.Z_FINISH),r===u.Z_FINISH?(n=o.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===u.Z_OK):r===u.Z_SYNC_FLUSH?(this.onEnd(u.Z_OK),d.avail_out=0,!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=a,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")}),define("Workers/UnZipTerrainData",["./createTaskProcessorWorker","../ThirdParty/pako_inflate"],function(e,t){"use strict";function n(e,n){var r=e.data,i=new Uint8Array(r),a=t.inflate(i).buffer;return n.push(a),{data:new Uint8Array(a)}}return e(n)})}();