diff --git a/dist/fits-reader/fits-reader.js b/dist/fits-reader/fits-reader.js index f247081..e20f7fa 100644 --- a/dist/fits-reader/fits-reader.js +++ b/dist/fits-reader/fits-reader.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.FITSReader=e():t.FITSReader=e()}(this,(()=>(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function n(t,e){for(var r=0;rdt});var i=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.cardIndex=0,this.primary=e,this.extension=!1,this.extensionType=null},(e=[{key:"verifyOrder",value:function(t,e){e!==this.cardIndex&&console.warn("".concat(t," should appear at index ").concat(this.cardIndex," in the FITS header"))}},{key:"verifyBetween",value:function(t,e,r,n){if(!(e>=r&&e<=n))throw"The ".concat(t," value of ").concat(e," is not between ").concat(r," and ").concat(n)}},{key:"verifyBoolean",value:function(t){return"T"===t}},{key:"SIMPLE",value:function(t){return this.primary=!0,this.verifyOrder("SIMPLE",0),this.verifyBoolean(t)}},{key:"XTENSION",value:function(t){return this.extension=!0,this.extensionType=t,this.verifyOrder("XTENSION",0),this.extensionType}},{key:"BITPIX",value:function(t){var e="BITPIX";if(t=parseInt(t),this.verifyOrder(e,1),![8,16,32,-32,-64].includes(t))throw"".concat(e," value ").concat(t," is not permitted");return t}},{key:"NAXIS",value:function(t,e){var r="NAXIS";if(t=parseInt(t),!e&&(this.verifyOrder(r,2),this.verifyBetween(r,t,0,999),this.extension&&["TABLE","BINTABLE"].includes(this.extensionType))&&2!==t)throw"".concat(r," must be ").concat(2," for TABLE and BINTABLE extensions");return t}},{key:"PCOUNT",value:function(t){var e="PCOUNT";t=parseInt(t);var r=3+this.NAXIS();if(this.verifyOrder(e,r),this.extension&&["IMAGE","TABLE"].includes(this.extensionType)&&0!==t)throw"".concat(e," must be ").concat(0," for the ").concat(this.extensionType," extensions");return t}},{key:"GCOUNT",value:function(t){var e="GCOUNT";t=parseInt(t);var r=3+this.NAXIS()+1;if(this.verifyOrder(e,r),this.extension&&["IMAGE","TABLE","BINTABLE"].includes(this.extensionType)&&1!==t)throw"".concat(e," must be ").concat(1," for the ").concat(this.extensionType," extensions");return t}},{key:"EXTEND",value:function(t,e){if(!e)throw"EXTEND must only appear in the primary header";return this.verifyBoolean(t)}},{key:"BSCALE",value:function(t){return parseFloat(t)}},{key:"BZERO",value:function(t){return parseFloat(t)}},{key:"BLANK",value:function(t){return t=parseInt(t),this.get("BITPIX")>0||console.warn("BLANK is not to be used for BITPIX = ".concat(this.get("BITPIX"))),t}},{key:"DATAMIN",value:function(t){return parseFloat(t)}},{key:"DATAMAX",value:function(t){return parseFloat(t)}},{key:"EXTVER",value:function(t){return parseInt(t)}},{key:"EXTLEVEL",value:function(t){return parseInt(t)}},{key:"TFIELDS",value:function(t){return t=parseInt(t),this.verifyBetween("TFIELDS",t,0,999),t}},{key:"TBCOL",value:function(t,e){return t=parseInt(t),this.verifyBetween("TBCOL",e,0,this.get("TFIELDS")),t}},{key:"ZIMAGE",value:function(t){return this.verifyBoolean(t)}},{key:"ZCMPTYPE",value:function(t){if(!["GZIP_1","RICE_1","PLIO_1","HCOMPRESS_1"].includes(t))throw"ZCMPTYPE value ".concat(t," is not permitted");if("RICE_1"!==t)throw"Compress type ".concat(t," is not yet implement");return t}},{key:"ZBITPIX",value:function(t){if(t=parseInt(t),![8,16,32,64,-32,-64].includes(t))throw"ZBITPIX value ".concat(t," is not permitted");return t}},{key:"ZNAXIS",value:function(t,e){return t=parseInt(t),e||this.verifyBetween("ZNAXIS",t,0,999),t}},{key:"ZTILE",value:function(t){return parseInt(t)}},{key:"ZSIMPLE",value:function(t){return"T"===t}},{key:"ZPCOUNT",value:function(t){return parseInt(t)}},{key:"ZGCOUNT",value:function(t){return parseInt(t)}},{key:"ZDITHER0",value:function(t){return parseInt(t)}}])&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],s=!0,f=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);s=!0);}catch(t){f=!0,o=t}finally{try{if(!s&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(f)throw o}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return s(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:null;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),c(this,"arrayPattern",/(\D+)(\d+)/),c(this,"maxLines",600),this.headerVerify=r,this.supportedCards=null,this.primary=r.primary,this.extension=!this.primary,null!=r){var n=Object.getOwnPropertyNames(Object.getPrototypeOf(this.headerVerify));this.supportedCards=n.filter((function(t){return"function"==typeof r[t]}))}this.cards={},this.cards.COMMENT=[],this.cards.HISTORY=[],this.cardIndex=0,this.block=e,this.readBlock(e)},(e=[{key:"get",value:function(t){return this.contains(t)?this.cards[t].value:null}},{key:"set",value:function(t,e,r){return r=r||"",this.cards[t]={index:this.cardIndex,value:e,comment:r},this.cardIndex+=1}},{key:"contains",value:function(t){return this.cards.hasOwnProperty(t)}},{key:"readLine",value:function(t){var e,r,n,o;if(""!==(n=t.slice(0,8).trim())){if(r=t.slice(8,10),o=t.slice(10),"= "===r){var i=a(o.split(" /"),2);return o=i[0],e=i[1],"'"===(o=o.trim())[0]?o=o.slice(1,-1).trim():"T"!==o&&"F"!==o&&(o=parseFloat(o)),o=this.validate(n,o),this.set(n,o,e)}"COMMENT"!==n&&"HISTORY"!==n||this.cards[n].push(o.trim())}}},{key:"validate",value:function(t,e){var r,n,o;if(n=null,r=t,o=this.arrayPattern.test(t)){var i=a(this.arrayPattern.exec(t).slice(1),2);r=i[0],n=i[1]}return r in this.supportedCards&&(e=this.headerVerify[r](e,o,n)),e}},{key:"readBlock",value:function(t){var e,r,n,o,i,u;for(u=[],e=r=0,i=(o=(o=t.length/80)=i;e=0<=i?++r:--r)n=t.slice(80*e,80*(e+1)),u.push(this.readLine(n));return u}},{key:"hasDataUnit",value:function(){return 0!==this.get("NAXIS")}},{key:"getDataLength",value:function(){var t,e,r,n;if(!this.hasDataUnit())return 0;for(r=[],t=e=1,n=this.get("NAXIS");1<=n?e<=n:e>=n;t=1<=n?++e:--e)r.push(this.get("NAXIS".concat(t)));return r.reduce((function(t,e){return t*e}))*Math.abs(this.get("BITPIX"))/8+this.get("PCOUNT")}},{key:"getDataType",value:function(){switch(this.extensionType||(this.extensionType=null),this.cards.XTENSION&&(this.extensionType=this.cards.XTENSION.value),this.extensionType){case"BINTABLE":return this.contains("ZIMAGE")?"CompressedImage":"BinaryTable";case"TABLE":return"Table";default:return this.hasDataUnit()?"Image":null}}},{key:"isPrimary",value:function(){return this.primary}},{key:"isExtension",value:function(){return this.extension}}])&&f(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function p(t,e){for(var r=0;r>8},J:function(t){return(255&t)<<24|(65280&t)<<8|t>>8&65280|t>>24&255}},(k=B(k="swapEndian"))in P?Object.defineProperty(P,k,{value:A,enumerable:!0,configurable:!0,writable:!0}):P[k]=A;var _=function(t){function e(t,r){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,r){(e=U(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(n=C(this,e,[t,r]),"maxMemory",1048576),n.rowByteSize=t.get("NAXIS1"),n.rows=t.get("NAXIS2"),n.cols=t.get("TFIELDS"),n.length=n.rowByteSize*n.rows,n.heapLength=t.get("PCOUNT"),n.columns=n.getColumns(t),null!=n.buffer?(n.rowsInMemory=n._rowsInMemoryBuffer,n.heap=n.buffer.slice(n.length,n.length+n.heapLength)):(n.rowsInMemory=n._rowsInMemoryBlob,n.firstRowInBuffer=n.lastRowInBuffer=0,n.nRowsInBuffer=Math.floor(n.maxMemory/n.rowByteSize)),n.accessors=[],n.descriptors=[],n.elementByteLengths=[],n.setAccessors(t),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&F(t,e)}(e,t),r=e,n=[{key:"_rowsInMemoryBuffer",value:function(){return!0}},{key:"_rowsInMemoryBlob",value:function(t,e){return!(tthis.lastRowInBuffer)}},{key:"getColumns",value:function(t){var e,r,n,o,i;for(e=[],r=n=1,i=this.cols;1<=i?n<=i:n>=i;r=1<=i?++n:--n){if(o="TTYPE".concat(r),!t.contains(o))return null;e.push(t.get(o))}return e}},{key:"getColumn",value:function(t,e,r){var n,o,i,u,a,s,f,c,l,y,h=this;return null!=this.blob?(c=this.columns.indexOf(t),u=this.descriptors[c],n=this.accessors[c],this.elementByteLengths[c],a=0===(a=this.elementByteLengths.slice(0,c)).length?0:a.reduce((function(t,e){return t+e})),i=null!=this.typedArray[u]?new this.typedArray[u](this.rows):[],y=~~(this.maxMemory/this.rowByteSize),y=Math.min(y,this.rows),s=this.rows/y,l=Math.floor(s)===s?s:Math.floor(s)+1,f=0,c=0,o=function(t,r){var u,s,p,b;for(u=t.byteLength/h.rowByteSize,b=new DataView(t),s=a;u--;)i[f]=n(b,s)[0],f+=1,s+=h.rowByteSize;if(c+=1,l-=1)return p=c*y,h.getTableBuffer(p,y,o,r);h.invoke(e,r,i)},this.getTableBuffer(0,y,o,r)):(o=function(r,n){return i=r.map((function(e){return e[t]})),h.invoke(e,n,i)},this.getRows(0,this.rows,o,r))}},{key:"getTableBuffer",value:function(t,e,r,n){var o,i,u,a,s=this;return e=Math.min(this.rows-t,e),u=(o=t*this.rowByteSize)+e*this.rowByteSize,i=this.blob.slice(o,u),(a=new FileReader).row=t,a.number=e,a.onloadend=function(t){return s.invoke(r,n,t.target.result)},a.readAsArrayBuffer(i)}},{key:"getRows",value:function(t,e,r,n){var o,i,u,a,s,f,c=this;return this.rowsInMemory(t,t+e)?(null!=this.blob?u=this.buffer:(a=(o=t*this.rowByteSize)+e*this.rowByteSize,u=this.buffer.slice(o,a)),f=this._getRows(u,e),this.invoke(r,n,f),f):(a=(o=t*this.rowByteSize)+Math.max(this.nRowsInBuffer*this.rowByteSize,e*this.rowByteSize),i=this.blob.slice(o,a),(s=new FileReader).row=t,s.number=e,s.onloadend=function(o){var i;return i=o.target,c.buffer=i.result,c.firstRowInBuffer=c.lastRowInBuffer=i.row,c.lastRowInBuffer+=i.number,c.getRows(t,e,r,n)},s.readAsArrayBuffer(i))}}],n&&L(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(j);function M(t){return M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(t)}function R(t,e){for(var r=0;r=u;n=1<=u?++o:--o)r=t.get("TFORM".concat(n)),t.get("TTYPE".concat(n)),e=i.exec(r)[1],a.push(function(t){var e;return e=function(e){return s.dataAccessors[t](e)},s.accessors.push(e)}(e));return a}},{key:"_getRows",value:function(t){var e,r,n,o,i,u,a,s,f,c,l,y,h,p,b,v,m,d,g;for(y=t.byteLength/this.rowByteSize,r=new Uint8Array(t),m=[],i=a=0,p=y-1;0<=p?a<=p:a>=p;i=0<=p?++a:--a){for(o=(n=i*this.rowByteSize)+this.rowByteSize,c="",l=0,s=(d=r.subarray(n,o)).length;lt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=1;)e.push(t&r?1:0),r/=2;return e}},{key:"getFromHeap",value:function(t,e,r){var n,o,i;return i=t.getInt32(e),e+=4,n=t.getInt32(e),e+=4,o=this.heap.slice(n,n+i),[new this.typedArray[r](o),e]}},{key:"setAccessors",value:function(t){var r,n,o,i,u,a,s,f,c,l,y,h=this;for(f=/(\d*)([P|Q]*)([L|X|B|I|J|K|A|E|D|C|M]{1})/,l=[],i=a=1,c=this.cols;1<=c?a<=c:a>=c;i=1<=c?++a:--a)o=t.get("TFORM".concat(i)),y=t.get("TTYPE".concat(i)),s=f.exec(o),r=parseInt(s[1])||1,u=s[2],n=s[3],l.push(function(t,r){var n,o;if(h.descriptors.push(t),h.elementByteLengths.push(e.offsets[t]*r),u)switch(y){case"COMPRESSED_DATA":n=function(e,r){var n,o,i=V(h.getFromHeap(e,r,t),2);return n=i[0],r=i[1],o=new h.typedArray[h.algorithmParameters.BYTEPIX](h.ztile[0]),Decompress.Rice(n,h.algorithmParameters.BLOCKSIZE,h.algorithmParameters.BYTEPIX,o,h.ztile[0],Decompress.RiceSetup),[o,r]};break;case"GZIP_COMPRESSED_DATA":n=function(t,e){var r;for(r=new Float32Array(h.width),i=r.length;i--;)r[i]=NaN;return[r,e]};break;default:n=function(e,r){return h.getFromHeap(e,r,t)}}else 1===r?n=function(e,r){var n=V(h.dataAccessors[t](e,r),2);return[n[0],r=n[1]]}:"X"===t?(o=Math.log(r)/Math.log(2),n=function(t,e){var n,i,u,a,s,f,c;for(u=t.buffer.slice(e,e+o),i=[],c=0,f=(s=new Uint8Array(u)).length;c=0&&t(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function n(t,e){for(var r=0;rdt});var i=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.cardIndex=0,this.primary=e,this.extension=!1,this.extensionType=null},(e=[{key:"verifyOrder",value:function(t,e){e!==this.cardIndex&&console.warn("".concat(t," should appear at index ").concat(this.cardIndex," in the FITS header"))}},{key:"verifyBetween",value:function(t,e,r,n){if(!(e>=r&&e<=n))throw"The ".concat(t," value of ").concat(e," is not between ").concat(r," and ").concat(n)}},{key:"verifyBoolean",value:function(t){return"T"===t}},{key:"SIMPLE",value:function(t){return this.primary=!0,this.verifyOrder("SIMPLE",0),this.verifyBoolean(t)}},{key:"XTENSION",value:function(t){return this.extension=!0,this.extensionType=t,this.verifyOrder("XTENSION",0),this.extensionType}},{key:"BITPIX",value:function(t){var e="BITPIX";if(t=parseInt(t),this.verifyOrder(e,1),![8,16,32,-32,-64].includes(t))throw"".concat(e," value ").concat(t," is not permitted");return t}},{key:"NAXIS",value:function(t,e){var r="NAXIS";if(t=parseInt(t),!e&&(this.verifyOrder(r,2),this.verifyBetween(r,t,0,999),this.extension&&["TABLE","BINTABLE"].includes(this.extensionType))&&2!==t)throw"".concat(r," must be ").concat(2," for TABLE and BINTABLE extensions");return t}},{key:"PCOUNT",value:function(t){var e="PCOUNT";t=parseInt(t);var r=3+this.NAXIS();if(this.verifyOrder(e,r),this.extension&&["IMAGE","TABLE"].includes(this.extensionType)&&0!==t)throw"".concat(e," must be ").concat(0," for the ").concat(this.extensionType," extensions");return t}},{key:"GCOUNT",value:function(t){var e="GCOUNT";t=parseInt(t);var r=3+this.NAXIS()+1;if(this.verifyOrder(e,r),this.extension&&["IMAGE","TABLE","BINTABLE"].includes(this.extensionType)&&1!==t)throw"".concat(e," must be ").concat(1," for the ").concat(this.extensionType," extensions");return t}},{key:"EXTEND",value:function(t,e){if(!e)throw"EXTEND must only appear in the primary header";return this.verifyBoolean(t)}},{key:"BSCALE",value:function(t){return parseFloat(t)}},{key:"BZERO",value:function(t){return parseFloat(t)}},{key:"BLANK",value:function(t){return t=parseInt(t),this.get("BITPIX")>0||console.warn("BLANK is not to be used for BITPIX = ".concat(this.get("BITPIX"))),t}},{key:"DATAMIN",value:function(t){return parseFloat(t)}},{key:"DATAMAX",value:function(t){return parseFloat(t)}},{key:"EXTVER",value:function(t){return parseInt(t)}},{key:"EXTLEVEL",value:function(t){return parseInt(t)}},{key:"TFIELDS",value:function(t){return t=parseInt(t),this.verifyBetween("TFIELDS",t,0,999),t}},{key:"TBCOL",value:function(t,e){return t=parseInt(t),this.verifyBetween("TBCOL",e,0,this.get("TFIELDS")),t}},{key:"ZIMAGE",value:function(t){return this.verifyBoolean(t)}},{key:"ZCMPTYPE",value:function(t){if(!["GZIP_1","RICE_1","PLIO_1","HCOMPRESS_1"].includes(t))throw"ZCMPTYPE value ".concat(t," is not permitted");if("RICE_1"!==t)throw"Compress type ".concat(t," is not yet implement");return t}},{key:"ZBITPIX",value:function(t){if(t=parseInt(t),![8,16,32,64,-32,-64].includes(t))throw"ZBITPIX value ".concat(t," is not permitted");return t}},{key:"ZNAXIS",value:function(t,e){return t=parseInt(t),e||this.verifyBetween("ZNAXIS",t,0,999),t}},{key:"ZTILE",value:function(t){return parseInt(t)}},{key:"ZSIMPLE",value:function(t){return"T"===t}},{key:"ZPCOUNT",value:function(t){return parseInt(t)}},{key:"ZGCOUNT",value:function(t){return parseInt(t)}},{key:"ZDITHER0",value:function(t){return parseInt(t)}}])&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],s=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);s=!0);}catch(t){c=!0,o=t}finally{try{if(!s&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return s(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:null;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),f(this,"arrayPattern",/(\D+)(\d+)/),f(this,"maxLines",600),this.headerVerify=r,this.supportedCards=null,this.primary=r.primary,this.extension=!this.primary,null!=r){var n=Object.getOwnPropertyNames(Object.getPrototypeOf(this.headerVerify));this.supportedCards=n.filter((function(t){return"function"==typeof r[t]}))}this.cards={},this.cards.COMMENT=[],this.cards.HISTORY=[],this.cardIndex=0,this.block=e,this.readBlock(e)},(e=[{key:"get",value:function(t){return this.contains(t)?this.cards[t].value:null}},{key:"set",value:function(t,e,r){return r=r||"",this.cards[t]={index:this.cardIndex,value:e,comment:r},this.cardIndex+=1}},{key:"contains",value:function(t){return this.cards.hasOwnProperty(t)}},{key:"readLine",value:function(t){var e,r,n,o;if(""!==(n=t.slice(0,8).trim())){if(r=t.slice(8,10),o=t.slice(10),"= "===r){var i=a(o.split(" /"),2);return o=i[0],e=i[1],"'"===(o=o.trim())[0]?o=o.slice(1,-1).trim():"T"!==o&&"F"!==o&&(o=parseFloat(o)),o=this.validate(n,o),this.set(n,o,e)}"COMMENT"!==n&&"HISTORY"!==n||this.cards[n].push(o.trim())}}},{key:"validate",value:function(t,e){var r,n,o;if(n=null,r=t,o=this.arrayPattern.test(t)){var i=a(this.arrayPattern.exec(t).slice(1),2);r=i[0],n=i[1]}return r in this.supportedCards&&(e=this.headerVerify[r](e,o,n)),e}},{key:"readBlock",value:function(t){var e,r,n,o,i,u;for(u=[],e=r=0,i=(o=(o=t.length/80)=i;e=0<=i?++r:--r)n=t.slice(80*e,80*(e+1)),u.push(this.readLine(n));return u}},{key:"hasDataUnit",value:function(){return 0!==this.get("NAXIS")}},{key:"getDataLength",value:function(){var t,e,r,n;if(!this.hasDataUnit())return 0;for(r=[],t=e=1,n=this.get("NAXIS");1<=n?e<=n:e>=n;t=1<=n?++e:--e)r.push(this.get("NAXIS".concat(t)));return r.reduce((function(t,e){return t*e}))*Math.abs(this.get("BITPIX"))/8+this.get("PCOUNT")}},{key:"getDataType",value:function(){switch(this.extensionType||(this.extensionType=null),this.cards.XTENSION&&(this.extensionType=this.cards.XTENSION.value),this.extensionType){case"BINTABLE":return this.contains("ZIMAGE")?"CompressedImage":"BinaryTable";case"TABLE":return"Table";default:return this.hasDataUnit()?"Image":null}}},{key:"isPrimary",value:function(){return this.primary}},{key:"isExtension",value:function(){return this.extension}}])&&c(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function p(t,e){for(var r=0;r>8},J:function(t){return(255&t)<<24|(65280&t)<<8|t>>8&65280|t>>24&255}},(k=B(k="swapEndian"))in P?Object.defineProperty(P,k,{value:A,enumerable:!0,configurable:!0,writable:!0}):P[k]=A;var _=function(t){function e(t,r){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,r){(e=U(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(n=C(this,e,[t,r]),"maxMemory",1048576),n.rowByteSize=t.get("NAXIS1"),n.rows=t.get("NAXIS2"),n.cols=t.get("TFIELDS"),n.length=n.rowByteSize*n.rows,n.heapLength=t.get("PCOUNT"),n.columns=n.getColumns(t),null!=n.buffer?(n.rowsInMemory=n._rowsInMemoryBuffer,n.heap=n.buffer.slice(n.length,n.length+n.heapLength)):(n.rowsInMemory=n._rowsInMemoryBlob,n.firstRowInBuffer=n.lastRowInBuffer=0,n.nRowsInBuffer=Math.floor(n.maxMemory/n.rowByteSize)),n.accessors=[],n.descriptors=[],n.elementByteLengths=[],n.setAccessors(t),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&F(t,e)}(e,t),r=e,n=[{key:"_rowsInMemoryBuffer",value:function(){return!0}},{key:"_rowsInMemoryBlob",value:function(t,e){return!(tthis.lastRowInBuffer)}},{key:"getColumns",value:function(t){var e,r,n,o,i;for(e=[],r=n=1,i=this.cols;1<=i?n<=i:n>=i;r=1<=i?++n:--n){if(o="TTYPE".concat(r),!t.contains(o))return null;e.push(t.get(o))}return e}},{key:"getColumn",value:function(t,e,r){var n,o,i,u,a,s,c,f,l,y,h=this;return null!=this.blob?(f=this.columns.indexOf(t),u=this.descriptors[f],n=this.accessors[f],this.elementByteLengths[f],a=0===(a=this.elementByteLengths.slice(0,f)).length?0:a.reduce((function(t,e){return t+e})),i=null!=this.typedArray[u]?new this.typedArray[u](this.rows):[],y=~~(this.maxMemory/this.rowByteSize),y=Math.min(y,this.rows),s=this.rows/y,l=Math.floor(s)===s?s:Math.floor(s)+1,c=0,f=0,o=function(t,r){var u,s,p,b;for(u=t.byteLength/h.rowByteSize,b=new DataView(t),s=a;u--;)i[c]=n(b,s)[0],c+=1,s+=h.rowByteSize;if(f+=1,l-=1)return p=f*y,h.getTableBuffer(p,y,o,r);h.invoke(e,r,i)},this.getTableBuffer(0,y,o,r)):(o=function(r,n){return i=r.map((function(e){return e[t]})),h.invoke(e,n,i)},this.getRows(0,this.rows,o,r))}},{key:"getTableBuffer",value:function(t,e,r,n){var o,i,u,a,s=this;return e=Math.min(this.rows-t,e),u=(o=t*this.rowByteSize)+e*this.rowByteSize,i=this.blob.slice(o,u),(a=new FileReader).row=t,a.number=e,a.onloadend=function(t){return s.invoke(r,n,t.target.result)},a.readAsArrayBuffer(i)}},{key:"getRows",value:function(t,e,r,n){var o,i,u,a,s,c,f=this;return this.rowsInMemory(t,t+e)?(null!=this.blob?u=this.buffer:(a=(o=t*this.rowByteSize)+e*this.rowByteSize,u=this.buffer.slice(o,a)),c=this._getRows(u,e),this.invoke(r,n,c),c):(a=(o=t*this.rowByteSize)+Math.max(this.nRowsInBuffer*this.rowByteSize,e*this.rowByteSize),i=this.blob.slice(o,a),(s=new FileReader).row=t,s.number=e,s.onloadend=function(o){var i;return i=o.target,f.buffer=i.result,f.firstRowInBuffer=f.lastRowInBuffer=i.row,f.lastRowInBuffer+=i.number,f.getRows(t,e,r,n)},s.readAsArrayBuffer(i))}}],n&&L(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(j);function M(t){return M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(t)}function R(t,e){for(var r=0;r=u;n=1<=u?++o:--o)r=t.get("TFORM".concat(n)),t.get("TTYPE".concat(n)),e=i.exec(r)[1],a.push(function(t){var e;return e=function(e){return s.dataAccessors[t](e)},s.accessors.push(e)}(e));return a}},{key:"_getRows",value:function(t){var e,r,n,o,i,u,a,s,c,f,l,y,h,p,b,v,m,d,g;for(y=t.byteLength/this.rowByteSize,r=new Uint8Array(t),m=[],i=a=0,p=y-1;0<=p?a<=p:a>=p;i=0<=p?++a:--a){for(o=(n=i*this.rowByteSize)+this.rowByteSize,f="",l=0,s=(d=r.subarray(n,o)).length;lt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=1;)e.push(t&r?1:0),r/=2;return e}},{key:"getFromHeap",value:function(t,e,r){var n,o,i;return i=t.getInt32(e),e+=4,n=t.getInt32(e),e+=4,o=this.heap.slice(n,n+i),[new this.typedArray[r](o),e]}},{key:"setAccessors",value:function(t){var r,n,o,i,u,a,s,c,f,l,y,h=this;for(c=/(\d*)([P|Q]*)([L|X|B|I|J|K|A|E|D|C|M]{1})/,l=[],i=a=1,f=this.cols;1<=f?a<=f:a>=f;i=1<=f?++a:--a)o=t.get("TFORM".concat(i)),y=t.get("TTYPE".concat(i)),s=c.exec(o),r=parseInt(s[1])||1,u=s[2],n=s[3],l.push(function(t,r){var n,o;if(h.descriptors.push(t),h.elementByteLengths.push(e.offsets[t]*r),u)switch(y){case"COMPRESSED_DATA":n=function(e,r){var n,o,i=V(h.getFromHeap(e,r,t),2);return n=i[0],r=i[1],o=new h.typedArray[h.algorithmParameters.BYTEPIX](h.ztile[0]),Decompress.Rice(n,h.algorithmParameters.BLOCKSIZE,h.algorithmParameters.BYTEPIX,o,h.ztile[0],Decompress.RiceSetup),[o,r]};break;case"GZIP_COMPRESSED_DATA":n=function(t,e){var r;for(r=new Float32Array(h.width),i=r.length;i--;)r[i]=NaN;return[r,e]};break;default:n=function(e,r){return h.getFromHeap(e,r,t)}}else 1===r?n=function(e,r){var n=V(h.dataAccessors[t](e,r),2);return[n[0],r=n[1]]}:"X"===t?(o=Math.log(r)/Math.log(2),n=function(t,e){var n,i,u,a,s,c,f;for(u=t.buffer.slice(e,e+o),i=[],f=0,c=(s=new Uint8Array(u)).length;f=0&&t