astro-viewer 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("astroviewer",[],t):"object"==typeof exports?exports.astroviewer=t():e.astroviewer=t()}(self,()=>(()=>{"use strict";var e={146:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Source=void 0;const s=i(1138),a=r(i(4382));t.Source=class{_point;_name;_details;_h_pix;_shapesize;_brightnessFactor;constructor(e,t=[]){this._point=e,this._details=t,this._shapesize=16,this._brightnessFactor=-99,this.computeHealpixPixel()}getDetailByindex(e){if(!(e<0||e>=this._details.length))return this._details[e]}get details(){return this._details}computeHealpixPixel(){const e=a.default.getHealpix(a.default.nsideForSelection),t=new s.Vec3(this._point.x,this._point.y,this._point.z),i=new s.Pointing(t,!1);this._h_pix=e.ang2pix(i,!1)}get point(){return this._point}get name(){return this._name}get healpixPixel(){return this._h_pix}get shapeSize(){return this._shapesize}set shapeSize(e){this._shapesize=e}get brightnessFactor(){return this._brightnessFactor}set brightnessFactor(e){this._brightnessFactor=e}}},149:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZShaderProgram=void 0;const r=i(619);t.XYZShaderProgram=class{locations;_webgl;_shaderProgram;_colorMapBlockIndex=null;_colorMapBuffer=null;_runtimeColorMap;_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};constructor(e){this._webgl=e,this.locations={pMatrix:null,mMatrix:null,vMatrix:null,sampler:null,colorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();if(!t)throw new Error("Could not create XYZ shader program");this._shaderProgram=t,this.initShaders()}return e.useProgram(this._shaderProgram),this._shaderProgram}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setRuntimeColorMap(e){this._runtimeColorMap=e}enableShaders(e,t,i,r=0){const s=this._webgl,a=this.shaderProgram;s.useProgram(a),this.locations.pMatrix=s.getUniformLocation(a,"uPMatrix"),this.locations.mMatrix=s.getUniformLocation(a,"uMMatrix"),this.locations.vMatrix=s.getUniformLocation(a,"uVMatrix"),this.locations.sampler=s.getUniformLocation(a,"uSampler"),this.locations.colorMapIdx=s.getUniformLocation(a,"cmapIdx"),this.locations.vertexPositionAttribute=s.getAttribLocation(a,"aVertexPosition"),this.locations.textureCoordAttribute=s.getAttribLocation(a,"aTextureCoord"),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t),s.uniformMatrix4fv(this.locations.mMatrix,!1,i),s.uniform1i(this.locations.sampler,0),s.uniform1i(this.locations.colorMapIdx,r),r>=2&&this.uploadColorMap(r)}initShaders(){const e=this._webgl,t=this.compileShader(e.VERTEX_SHADER,"#version 300 es\n in vec3 aVertexPosition;\n in vec2 aTextureCoord;\n uniform mat4 uPMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uMMatrix;\n out vec2 vTextureCoord;\n void main(void) {\n vTextureCoord = aTextureCoord;\n gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);\n }"),i=this.compileShader(e.FRAGMENT_SHADER,"#version 300 es\n precision mediump float;\n in vec2 vTextureCoord;\n uniform sampler2D uSampler;\n uniform int cmapIdx;\n\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n out vec4 outColor;\n\n void main(void) {\n vec4 color = texture(uSampler, vTextureCoord);\n\n if (cmapIdx == 1) {\n float gray = 0.21 * color.r + 0.71 * color.g + 0.07 * color.b;\n outColor = vec4(vec3(gray), color.a);\n return;\n }\n\n if (cmapIdx >= 2) {\n int rIndex = int(clamp(color.r * 255.0, 0.0, 255.0));\n int gIndex = int(clamp(color.g * 255.0, 0.0, 255.0));\n int bIndex = int(clamp(color.b * 255.0, 0.0, 255.0));\n\n outColor = vec4(\n r_palette[rIndex] / 256.0,\n g_palette[gIndex] / 256.0,\n b_palette[bIndex] / 256.0,\n color.a\n );\n return;\n }\n\n outColor = color;\n }");if(e.attachShader(this._shaderProgram,t),e.attachShader(this._shaderProgram,i),e.linkProgram(this._shaderProgram),!e.getProgramParameter(this._shaderProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._shaderProgram)||"Could not initialise XYZ shaders");this.initColorMapBuffer()}compileShader(e,t){const i=this._webgl,r=i.createShader(e);if(!r)throw new Error("Could not create XYZ shader");if(i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(r)||"XYZ shader compile error");return r}initColorMapBuffer(){const e=this._webgl,t=this._shaderProgram,i=e.getUniformBlockIndex(t,"colormap");if(i===e.INVALID_INDEX)return void(this._colorMapBlockIndex=null);this._colorMapBlockIndex=i;const r=["r_palette","g_palette","b_palette"],s=e.getUniformIndices(t,r),a=e.getActiveUniforms(t,s,e.UNIFORM_OFFSET);r.forEach((e,t)=>{this._colorMapVariableInfo[e]={index:s[t],offset:a[t]}}),this._colorMapBuffer=e.createBuffer(),e.bindBuffer(e.UNIFORM_BUFFER,this._colorMapBuffer),e.bufferData(e.UNIFORM_BUFFER,12288,e.STATIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,0,this._colorMapBuffer),e.uniformBlockBinding(t,i,0)}uploadColorMap(e){if(!this._colorMapBuffer||null===this._colorMapBlockIndex)return;const t=this.getColorMap(e);if(!t)return;const i=this._webgl,r=this.shaderProgram;i.uniformBlockBinding(r,this._colorMapBlockIndex,0),i.bindBuffer(i.UNIFORM_BUFFER,this._colorMapBuffer);const s=this._colorMapVariableInfo;i.bufferSubData(i.UNIFORM_BUFFER,s.r_palette.offset,t.r,0),i.bufferSubData(i.UNIFORM_BUFFER,s.g_palette.offset,t.g,0),i.bufferSubData(i.UNIFORM_BUFFER,s.b_palette.offset,t.b,0),i.bindBuffer(i.UNIFORM_BUFFER,null)}getColorMap(e){switch(e){case 2:return r.ColorMaps.planck;case 3:return r.ColorMaps.cmb;case 4:return r.ColorMaps.rainbow;case 5:return r.ColorMaps.eosb;case 6:return r.ColorMaps.cubehelix;case 7:return r.ColorMaps.hot;case 8:return r.ColorMaps.gray;default:return this._runtimeColorMap}}}},229:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fovHelper=void 0;class i{static LEVEL_HYSTERESIS=.12;static HIPS_ORDER_MIN_FOV={0:179,1:90,2:30,3:20,4:6,5:3.2,6:1.6,7:.85,8:.42,9:.21,10:.12,11:.06,12:.015,13:0};getHiPSNorder(e,t){const r=this.getRawHiPSNorder(e);if(void 0===t||t===r)return r;if(r>t){const r=i.HIPS_ORDER_MIN_FOV[t];if(r>0&&e>r*(1-i.LEVEL_HYSTERESIS))return t}else{const s=i.HIPS_ORDER_MIN_FOV[r];if(s>0&&e<s*(1+i.LEVEL_HYSTERESIS))return t}return r}getRawHiPSNorder(e){return e>=179?0:e>=90?1:e>=30?2:e>=20?3:e>=6?4:e>=3.2?5:e>=1.6?6:e>=.85?7:e>=.42?8:e>=.21?9:e>=.12?10:e>=.06?11:e>=.015?12:13}getRADegSteps(e,t=!1){let i,r;return t&&e<.21||e>=179?(i=10,r=10):e>=25?(i=9,r=9):e>=12.5?(i=8,r=8):e>=6?(i=6,r=6):e>=3.2?(i=5,r=5):e>=1.6?(i=4,r=4):e>=.85?(i=3,r=3):e>=.42?(i=2,r=2):e>=.21?(i=1,r=1):e>=.12?(i=.5,r=.5):e>=.06?(i=.25,r=.25):(i=10,r=10),{raStep:i,decStep:r}}getRefOrder(e){switch(e){case 0:case 1:case 2:case 3:return e+6;case 4:case 5:case 6:case 7:return e+5;case 8:return e+4;default:return e+3}}}t.fovHelper=new i,t.default=i},592:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintSetGL=void 0;const s=i(2475),a=i(7930),o=i(8909),n=i(6553),h=r(i(2930)),l=i(8145),c=i(5403);class u{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;static CONVEXPOLY_ELEM_SIZE=3;_kind="FootprintSetGL";_ready;_name;_description;extHoveredIndexes;oldMouseCoords;healpixDensityMap;totConvexPoints;vertexCataloguePositionBuffer;indexBuffer;hoveredVertexPositionBuffer;hoveredIndexBuffer;selectedVertexPositionBuffer;selectedIndexBuffer;indexes;footprintPolygons=[];vertexCataloguePosition;totPoints;nPrimitiveFlags=0;hoveredIndexes;hoveredElementIndexes;_hoveredFootprints=[];hoveredVertexPosition;totHoveredPoints;nHoveredPrimitiveFlags=0;selectedIndexes;selectedElementIndexes;_selectedFootprints=[];selectedVertexPosition;totSelectedPoints;nSlectedPrimitiveFlags=0;_shapeColor="#00fff2ff";_coordsType=l.CoordsType.ASTRO;_bufferInitialised=!1;_webgl;_isVisible=!0;_metadataManager;_providerUrl;_footprintShaderProgram;_visibleTilesManager;constructor(e,t,i,r,s,a){this._webgl=s,this._ready=!1,this._visibleTilesManager=a,this.TYPE="FOOTPRINT_SET",this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=r,this.initFootprintArrays(),this.oldMouseCoords=null,this._footprintShaderProgram=new o.FootprintShaderProgram(this._webgl),this._footprintShaderProgram.shaderProgram}initFootprintArrays(){this.footprintPolygons=[],this.indexes=new Uint32Array,this.vertexCataloguePosition=new Float32Array,this.totPoints=0,this.totConvexPoints=0,this.extHoveredIndexes=new Uint32Array,this._hoveredFootprints=[],this.hoveredVertexPosition=new Float32Array,this.totHoveredPoints=0,this.hoveredIndexes=[],this.hoveredElementIndexes=new Uint32Array,this._selectedFootprints=[],this.selectedVertexPosition=new Float32Array,this.totSelectedPoints=0,this.selectedIndexes=[],this.selectedElementIndexes=new Uint32Array}initGLBuffers(){this._webgl&&(this.vertexCataloguePositionBuffer=this._webgl.createBuffer(),this.indexBuffer=this._webgl.createBuffer(),this.hoveredVertexPositionBuffer=this._webgl.createBuffer(),this.hoveredIndexBuffer=this._webgl.createBuffer(),this.selectedVertexPositionBuffer=this._webgl.createBuffer(),this.selectedIndexBuffer=this._webgl.createBuffer())}setIsVisible(e){this._isVisible=e}get isVisible(){return this._isVisible}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get metadataManager(){return this._metadataManager}addFootprint(e){this.footprintPolygons.push(e)}addFootprints(e,t){this._ready=!1,this._metadataManager=new c.MetadataManager(t);const i=this._metadataManager.selectedOutlineColumn?.index??-1;if(i<0)throw new Error("geomColumn or its index is undefined in footprintsetProps");for(let t=0;t<e.length;t++)if(null!==e[t][i]){const r=new s.Footprint(e[t][i],e[t],void 0,this._coordsType);r._valid&&(this.addFootprint(r),this.totPoints+=r.totPoints,this.totConvexPoints+=r.totConvexPoints)}this._ready=!0,this._bufferInitialised=!1}clearFootprints(){this.initFootprintArrays()}initBuffer(){if(!this._webgl)return;this.initGLBuffers();const e=this.footprintPolygons.length;let t=e-1;for(let i=0;i<e;i++)t+=this.footprintPolygons[i].polygons.length-1;this.indexes=new Uint32Array(this.totPoints+t+1);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this.vertexCataloguePosition=new Float32Array(3*this.totPoints);let r=0,s=0;this.nPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this.footprintPolygons[t].polygons;t>0&&(this.indexes[s++]=i,this.nPrimitiveFlags++);for(const t of e){t!==e[0]&&(this.indexes[s++]=i,this.nPrimitiveFlags++);for(const e of t)this.vertexCataloguePosition[r++]=1*e.x,this.vertexCataloguePosition[r++]=1*e.y,this.vertexCataloguePosition[r++]=1*e.z,this.indexes[s++]=Math.floor((r-1)/3)}}this.indexes[this.indexes.length-1]=i,this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexes,this._webgl.STATIC_DRAW),this._bufferInitialised=!0,console.log("Buffer initialized")}checkSelection(e){if(!e.x||!e.y||!e.z)return;if(!e.computeNpix())return;this._hoveredFootprints=[],this.totHoveredPoints=0;const t=new n.Point({x:e.x,y:e.y,z:e.z},l.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const i=this.footprintPolygons[e];if(i.selectionObj&&h.default.checkPointInsidePolygon5(i.selectionObj,t)){const e=[...i.details],t=this._metadataManager.selectedOutlineColumn?.index??-1;t>=0&&e.splice(t,1),this._hoveredFootprints.push(i),this.totHoveredPoints+=i.totPoints}}this.initHoveringBuffer()}get hoveredFootprints(){return{metadata:this._metadataManager,footprints:this._hoveredFootprints,tableName:this._name,description:this._description,provider:this._providerUrl}}get selectedFootprints(){return this._selectedFootprints}checkClicking(e){if(null==e.x||null==e.y||null==e.z)return[];const t=[],i=new n.Point({x:e.x,y:e.y,z:e.z},l.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const r=this.footprintPolygons[e];r.selectionObj&&h.default.checkPointInsidePolygon5(r.selectionObj,i)&&t.push(e)}return t}setSelectedIndexes(e){e.forEach(e=>{e<0||e>=this.footprintPolygons.length||(this.selectedIndexes.includes(e)?this.selectedIndexes.splice(this.selectedIndexes.indexOf(e),1):this.selectedIndexes.push(e))}),this.refreshSelectedFootprints()}refreshSelectedFootprints(){if(this._selectedFootprints=this.selectedIndexes.map(e=>this.footprintPolygons[e]).filter(e=>Boolean(e)),this.totSelectedPoints=this._selectedFootprints.reduce((e,t)=>e+t.totPoints,0),0===this._selectedFootprints.length)return this.selectedVertexPosition=new Float32Array,this.selectedElementIndexes=new Uint32Array,void(this.nSlectedPrimitiveFlags=0);this.initSelectionBuffer()}getFootprintsFromPointer(e){const t=this.checkClicking(e);if(!t.length)return{footprints:[],pickedIndexes:[]};const i=[];return t.forEach(e=>{const t=this.footprintPolygons[e];t&&i.push(t)}),i.length?{footprints:i,pickedIndexes:t}:null}selectPrimaryFootprintFromClick(e){const t=this.getFootprintsFromPointer(e),i=t?.pickedIndexes??[];if(this.setSelectedIndexes(i),!i.length)return{footprints:[],selectionState:[]};const r=[],s=[];return i.forEach(e=>{const t=this.footprintPolygons[e];if(!t)return;const i=this.selectedIndexes.includes(e);r.push({footprint:t,selected:i}),s.push(t)}),s.length?{footprints:s,selectionState:r}:null}FootprintPolygonMatches(e,t){if(e===t)return!0;const i=e.convexPolygons,r=t.convexPolygons;if(i!==r||i!==r)return!1;if(e.details.length!==t.details.length)return!1;for(let i=0;i<e.details.length;i++)if(!Object.is(e.details[i],t.details[i]))return!1;return!0}findFootprintPolygonIndex(e){const t=this.footprintPolygons.indexOf(e);return t>=0?t:this.footprintPolygons.findIndex(t=>this.FootprintPolygonMatches(t,e))}extHighlightFootprint(e,t){const i=this.findFootprintPolygonIndex(e);if(i<0)return;const r=i*u.ELEM_SIZE;if(t)this.hoveredIndexes.includes(i)||this.hoveredIndexes.push(i);else{if(r+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(i);e>=0&&this.hoveredIndexes.splice(e,1)}}extAddPolygons2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findFootprintPolygonIndex(e);if(t<0)return;const i=t*u.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(i+4>=this.vertexCataloguePosition.length)return;const e=this.selectedIndexes.indexOf(t);e>=0&&this.selectedIndexes.splice(e,1)}else this.selectedIndexes.push(t);this.refreshSelectedFootprints()}initHoveringBuffer(){if(!this._webgl)return;if(0==this._hoveredFootprints.length)return;let e=this._hoveredFootprints.length,t=e-1;for(let i=0;i<e;i++)t+=this._hoveredFootprints[i].polygons.length-1;this.hoveredElementIndexes=new Uint32Array(this.totHoveredPoints+t);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this.hoveredVertexPosition=new Float32Array(3*this.totHoveredPoints);let r=0,s=0;this.nHoveredPrimitiveFlags=0;for(let t=0;t<e;t++){let e=this._hoveredFootprints[t].polygons;t>0&&(this.hoveredElementIndexes[s]=i,this.nHoveredPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.hoveredElementIndexes[s]=i,this.nHoveredPrimitiveFlags+=1,s+=1);const a=e[t];for(let e=0;e<a.length;e++){const t=a[e];this.hoveredVertexPosition[r]=1*t.x,this.hoveredVertexPosition[r+1]=1*t.y,this.hoveredVertexPosition[r+2]=1*t.z,this.hoveredElementIndexes[s]=Math.floor(r/3),s+=1,r+=3}}}}initSelectionBuffer(){if(!this._webgl)return;if(0==this._selectedFootprints.length)return;const e=this._selectedFootprints.length;let t=e-1;for(let i=0;i<e;i++)t+=this._selectedFootprints[i].polygons.length-1;this.selectedElementIndexes=new Uint32Array(this.totSelectedPoints+t);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this.selectedVertexPosition=new Float32Array(3*this.totSelectedPoints);let r=0,s=0;this.nSlectedPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this._selectedFootprints[t].polygons;t>0&&(this.selectedElementIndexes[s]=i,this.nSlectedPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.selectedElementIndexes[s]=i,this.nSlectedPrimitiveFlags+=1,s+=1);const a=e[t];for(let e=0;e<a.length;e++){const t=a[e];this.selectedVertexPosition[r]=1*t.x,this.selectedVertexPosition[r+1]=1*t.y,this.selectedVertexPosition[r+2]=1*t.z,this.selectedElementIndexes[s]=Math.floor(r/3),s+=1,r+=3}}}}changeColor(e){this._shapeColor=e}draw(e,t,i,r){if(!this.isVisible)return;if(!this._ready)return;if(!i)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;if(this._footprintShaderProgram.enableShaders(r,e,i),null!=t&&t.xyz!=this.oldMouseCoords&&this.checkSelection(t),this._hoveredFootprints.length>0){const e=(0,a.colorHex2RGB)("#00FF00"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.hoveredVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.hoveredVertexPosition.length/3+this.nHoveredPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}if(this._selectedFootprints.length>0){const e=(0,a.colorHex2RGB)("#ECB462"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.selectedVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.selectedVertexPosition.length/3+this.nSlectedPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);const s=[...(0,a.colorHex2RGB)(this._shapeColor),1];this._webgl.uniform4f(this._footprintShaderProgram.locations.color,...s),this._webgl.drawElements(this._webgl.LINE_LOOP,this.indexes.length,this._webgl.UNSIGNED_INT,0),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,null),this.oldMouseCoords=t.xyz}}t.FootprintSetGL=u},619:(e,t)=>{function i(e,i){if(!Array.isArray(i))throw new Error(`Channel "${e}" must be an array.`);if(i.length!==t.COLOR_MAP_SAMPLE_COUNT)throw new Error(`Channel "${e}" must contain exactly ${t.COLOR_MAP_SAMPLE_COUNT} samples.`);for(let t=0;t<i.length;t+=1){const r=i[t];if(!Number.isFinite(r))throw new Error(`Channel "${e}" contains a non-finite value at index ${t}.`);if(r<0||r>255)throw new Error(`Channel "${e}" contains an out-of-range value at index ${t}. Expected 0..255.`)}}function r(e){const i=new Float32Array(4*t.COLOR_MAP_SAMPLE_COUNT);for(let r=0;r<t.COLOR_MAP_SAMPLE_COUNT;r+=1)i[4*r]=e[r];return i}Object.defineProperty(t,"__esModule",{value:!0}),t.ColorMaps=t.COLOR_MAP_SAMPLE_COUNT=void 0,t.createColorMapFromSamples=function(e,t){const s=e.trim();if(!s)throw new Error("Color map name must not be empty.");return i("r",t.r),i("g",t.g),i("b",t.b),{name:s,r:r(t.r),g:r(t.g),b:r(t.b)}},t.COLOR_MAP_SAMPLE_COUNT=256,t.ColorMaps={grayscale:{name:"grayscale",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},native:{name:"native",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},planck:{name:"planck",r:new Float32Array([0,0,0,0,.769231,0,0,0,1.53846,0,0,0,2.30769,0,0,0,3.07692,0,0,0,3.84615,0,0,0,4.61538,0,0,0,5.38462,0,0,0,6.15385,0,0,0,6.92308,0,0,0,7.69231,0,0,0,8.46154,0,0,0,9.23077,0,0,0,10,0,0,0,11.5385,0,0,0,13.0769,0,0,0,14.6154,0,0,0,16.1538,0,0,0,17.6923,0,0,0,19.2308,0,0,0,20.7692,0,0,0,22.3077,0,0,0,23.8462,0,0,0,25.3846,0,0,0,26.9231,0,0,0,28.4615,0,0,0,30,0,0,0,33.8462,0,0,0,37.6923,0,0,0,41.5385,0,0,0,45.3846,0,0,0,49.2308,0,0,0,53.0769,0,0,0,56.9231,0,0,0,60.7692,0,0,0,64.6154,0,0,0,68.4615,0,0,0,72.3077,0,0,0,76.1538,0,0,0,80,0,0,0,88.5385,0,0,0,97.0769,0,0,0,105.615,0,0,0,114.154,0,0,0,122.692,0,0,0,131.231,0,0,0,139.769,0,0,0,148.308,0,0,0,156.846,0,0,0,165.385,0,0,0,173.923,0,0,0,182.462,0,0,0,191,0,0,0,193.846,0,0,0,196.692,0,0,0,199.538,0,0,0,202.385,0,0,0,205.231,0,0,0,208.077,0,0,0,210.923,0,0,0,213.769,0,0,0,216.615,0,0,0,219.462,0,0,0,222.308,0,0,0,225.154,0,0,0,228,0,0,0,229.182,0,0,0,230.364,0,0,0,231.545,0,0,0,232.727,0,0,0,233.909,0,0,0,235.091,0,0,0,236.273,0,0,0,237.455,0,0,0,238.636,0,0,0,239.818,0,0,0,241,0,0,0,241,0,0,0,241.364,0,0,0,241.727,0,0,0,242.091,0,0,0,242.455,0,0,0,242.818,0,0,0,243.182,0,0,0,243.545,0,0,0,243.909,0,0,0,244.273,0,0,0,244.636,0,0,0,245,0,0,0,245.231,0,0,0,245.462,0,0,0,245.692,0,0,0,245.923,0,0,0,246.154,0,0,0,246.385,0,0,0,246.615,0,0,0,246.846,0,0,0,247.077,0,0,0,247.308,0,0,0,247.538,0,0,0,247.769,0,0,0,248,0,0,0,248.146,0,0,0,248.292,0,0,0,248.438,0,0,0,248.585,0,0,0,248.731,0,0,0,248.877,0,0,0,249.023,0,0,0,249.169,0,0,0,249.315,0,0,0,249.462,0,0,0,249.608,0,0,0,249.754,0,0,0,249.9,0,0,0,249.312,0,0,0,248.723,0,0,0,248.135,0,0,0,247.546,0,0,0,246.958,0,0,0,246.369,0,0,0,245.781,0,0,0,245.192,0,0,0,244.604,0,0,0,244.015,0,0,0,243.427,0,0,0,242.838,0,0,0,242.25,0,0,0,239.308,0,0,0,236.365,0,0,0,233.423,0,0,0,230.481,0,0,0,227.538,0,0,0,224.596,0,0,0,221.654,0,0,0,218.712,0,0,0,215.769,0,0,0,212.827,0,0,0,209.885,0,0,0,206.942,0,0,0,204,0,0,0,201,0,0,0,198,0,0,0,195,0,0,0,192,0,0,0,189,0,0,0,186,0,0,0,183,0,0,0,180,0,0,0,177,0,0,0,174,0,0,0,171,0,0,0,168,0,0,0,165,0,0,0,161.077,0,0,0,157.154,0,0,0,153.231,0,0,0,149.308,0,0,0,145.385,0,0,0,141.462,0,0,0,137.538,0,0,0,133.615,0,0,0,129.692,0,0,0,125.769,0,0,0,121.846,0,0,0,117.923,0,0,0,114,0,0,0,115.038,0,0,0,116.077,0,0,0,117.115,0,0,0,118.154,0,0,0,119.192,0,0,0,120.231,0,0,0,121.269,0,0,0,122.308,0,0,0,123.346,0,0,0,124.385,0,0,0,125.423,0,0,0,126.462,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),g:new Float32Array([0,0,0,0,1.53846,0,0,0,3.07692,0,0,0,4.61538,0,0,0,6.15385,0,0,0,7.69231,0,0,0,9.23077,0,0,0,10.7692,0,0,0,12.3077,0,0,0,13.8462,0,0,0,15.3846,0,0,0,16.9231,0,0,0,18.4615,0,0,0,20,0,0,0,32.6154,0,0,0,45.2308,0,0,0,57.8462,0,0,0,70.4615,0,0,0,83.0769,0,0,0,95.6923,0,0,0,108.308,0,0,0,120.923,0,0,0,133.538,0,0,0,146.154,0,0,0,158.769,0,0,0,171.385,0,0,0,184,0,0,0,187.923,0,0,0,191.846,0,0,0,195.769,0,0,0,199.692,0,0,0,203.615,0,0,0,207.538,0,0,0,211.462,0,0,0,215.385,0,0,0,219.308,0,0,0,223.231,0,0,0,227.154,0,0,0,231.077,0,0,0,235,0,0,0,235.308,0,0,0,235.615,0,0,0,235.923,0,0,0,236.231,0,0,0,236.538,0,0,0,236.846,0,0,0,237.154,0,0,0,237.462,0,0,0,237.769,0,0,0,238.077,0,0,0,238.385,0,0,0,238.692,0,0,0,239,0,0,0,239.077,0,0,0,239.154,0,0,0,239.231,0,0,0,239.308,0,0,0,239.385,0,0,0,239.462,0,0,0,239.538,0,0,0,239.615,0,0,0,239.692,0,0,0,239.769,0,0,0,239.846,0,0,0,239.923,0,0,0,240,0,0,0,240.091,0,0,0,240.182,0,0,0,240.273,0,0,0,240.364,0,0,0,240.455,0,0,0,240.545,0,0,0,240.636,0,0,0,240.727,0,0,0,240.818,0,0,0,240.909,0,0,0,241,0,0,0,241,0,0,0,240.909,0,0,0,240.818,0,0,0,240.727,0,0,0,240.636,0,0,0,240.545,0,0,0,240.455,0,0,0,240.364,0,0,0,240.273,0,0,0,240.182,0,0,0,240.091,0,0,0,240,0,0,0,239.615,0,0,0,239.231,0,0,0,238.846,0,0,0,238.462,0,0,0,238.077,0,0,0,237.692,0,0,0,237.308,0,0,0,236.923,0,0,0,236.538,0,0,0,236.154,0,0,0,235.769,0,0,0,235.385,0,0,0,235,0,0,0,232.615,0,0,0,230.231,0,0,0,227.846,0,0,0,225.462,0,0,0,223.077,0,0,0,220.692,0,0,0,218.308,0,0,0,215.923,0,0,0,213.538,0,0,0,211.154,0,0,0,208.769,0,0,0,206.385,0,0,0,204,0,0,0,200.077,0,0,0,196.154,0,0,0,192.231,0,0,0,188.308,0,0,0,184.385,0,0,0,180.462,0,0,0,176.538,0,0,0,172.615,0,0,0,168.692,0,0,0,164.769,0,0,0,160.846,0,0,0,156.923,0,0,0,153,0,0,0,147.115,0,0,0,141.231,0,0,0,135.346,0,0,0,129.462,0,0,0,123.577,0,0,0,117.692,0,0,0,111.808,0,0,0,105.923,0,0,0,100.038,0,0,0,94.1538,0,0,0,88.2692,0,0,0,82.3846,0,0,0,76.5,0,0,0,73.0769,0,0,0,69.6538,0,0,0,66.2308,0,0,0,62.8077,0,0,0,59.3846,0,0,0,55.9615,0,0,0,52.5385,0,0,0,49.1154,0,0,0,45.6923,0,0,0,42.2692,0,0,0,38.8462,0,0,0,35.4231,0,0,0,32,0,0,0,29.5385,0,0,0,27.0769,0,0,0,24.6154,0,0,0,22.1538,0,0,0,19.6923,0,0,0,17.2308,0,0,0,14.7692,0,0,0,12.3077,0,0,0,9.84615,0,0,0,7.38462,0,0,0,4.92308,0,0,0,2.46154,0,0,0,0,0,0,0,9.80769,0,0,0,19.6154,0,0,0,29.4231,0,0,0,39.2308,0,0,0,49.0385,0,0,0,58.8462,0,0,0,68.6538,0,0,0,78.4615,0,0,0,88.2692,0,0,0,98.0769,0,0,0,107.885,0,0,0,117.692,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254.615,0,0,0,254.231,0,0,0,253.846,0,0,0,253.462,0,0,0,253.077,0,0,0,252.692,0,0,0,252.308,0,0,0,251.923,0,0,0,251.538,0,0,0,251.154,0,0,0,250.769,0,0,0,250.385,0,0,0,250,0,0,0,249.615,0,0,0,249.231,0,0,0,248.846,0,0,0,248.462,0,0,0,248.077,0,0,0,247.692,0,0,0,247.308,0,0,0,246.923,0,0,0,246.538,0,0,0,246.154,0,0,0,245.769,0,0,0,245.385,0,0,0,245,0,0,0,242,0,0,0,239,0,0,0,236,0,0,0,233,0,0,0,230,0,0,0,227,0,0,0,224,0,0,0,221,0,0,0,218,0,0,0,215,0,0,0,212,0,0,0,212,0,0,0,208.636,0,0,0,205.273,0,0,0,201.909,0,0,0,198.545,0,0,0,195.182,0,0,0,191.818,0,0,0,188.455,0,0,0,185.091,0,0,0,181.727,0,0,0,178.364,0,0,0,175,0,0,0,171.538,0,0,0,168.077,0,0,0,164.615,0,0,0,161.154,0,0,0,157.692,0,0,0,154.231,0,0,0,150.769,0,0,0,147.308,0,0,0,143.846,0,0,0,140.385,0,0,0,136.923,0,0,0,133.462,0,0,0,130,0,0,0,122.942,0,0,0,115.885,0,0,0,108.827,0,0,0,101.769,0,0,0,94.7115,0,0,0,87.6539,0,0,0,80.5962,0,0,0,73.5385,0,0,0,66.4808,0,0,0,59.4231,0,0,0,52.3654,0,0,0,45.3077,0,0,0,38.25,0,0,0,36.2885,0,0,0,34.3269,0,0,0,32.3654,0,0,0,30.4038,0,0,0,28.4423,0,0,0,26.4808,0,0,0,24.5192,0,0,0,22.5577,0,0,0,20.5962,0,0,0,18.6346,0,0,0,16.6731,0,0,0,14.7115,0,0,0,12.75,0,0,0,11.7692,0,0,0,10.7885,0,0,0,9.80769,0,0,0,8.82692,0,0,0,7.84615,0,0,0,6.86539,0,0,0,5.88461,0,0,0,4.90385,0,0,0,3.92308,0,0,0,2.94231,0,0,0,1.96154,0,0,0,.980769,0,0,0,0,0,0,0,2.46154,0,0,0,4.92308,0,0,0,7.38462,0,0,0,9.84616,0,0,0,12.3077,0,0,0,14.7692,0,0,0,17.2308,0,0,0,19.6923,0,0,0,22.1538,0,0,0,24.6154,0,0,0,27.0769,0,0,0,29.5385,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,41.3077,0,0,0,50.6154,0,0,0,59.9231,0,0,0,69.2308,0,0,0,78.5385,0,0,0,87.8462,0,0,0,97.1539,0,0,0,106.462,0,0,0,115.769,0,0,0,125.077,0,0,0,134.385,0,0,0,143.692,0,0,0,153,0,0,0,156.923,0,0,0,160.846,0,0,0,164.769,0,0,0,168.692,0,0,0,172.615,0,0,0,176.538,0,0,0,180.462,0,0,0,184.385,0,0,0,188.308,0,0,0,192.231,0,0,0,196.154,0,0,0,200.077,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.838,0,0,0,243.427,0,0,0,244.015,0,0,0,244.604,0,0,0,245.192,0,0,0,245.781,0,0,0,246.369,0,0,0,246.958,0,0,0,247.546,0,0,0,248.135,0,0,0,248.723,0,0,0,249.312,0,0,0,249.9,0,0,0,250.096,0,0,0,250.292,0,0,0,250.488,0,0,0,250.685,0,0,0,250.881,0,0,0,251.077,0,0,0,251.273,0,0,0,251.469,0,0,0,251.665,0,0,0,251.862,0,0,0,252.058,0,0,0,252.254,0,0,0,252.45,0,0,0,252.682,0,0,0,252.914,0,0,0,253.145,0,0,0,253.377,0,0,0,253.609,0,0,0,253.841,0,0,0,254.073,0,0,0,254.305,0,0,0,254.536,0,0,0,254.768,0,0,0,255,0,0,0])},cmb:{name:"cmb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,12,0,0,0,18,0,0,0,24,0,0,0,30,0,0,0,36,0,0,0,42,0,0,0,48,0,0,0,54,0,0,0,60,0,0,0,66,0,0,0,72,0,0,0,78,0,0,0,85,0,0,0,91,0,0,0,97,0,0,0,103,0,0,0,109,0,0,0,115,0,0,0,121,0,0,0,127,0,0,0,133,0,0,0,139,0,0,0,145,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,170,0,0,0,176,0,0,0,182,0,0,0,188,0,0,0,194,0,0,0,200,0,0,0,206,0,0,0,212,0,0,0,218,0,0,0,224,0,0,0,230,0,0,0,236,0,0,0,242,0,0,0,248,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,251,0,0,0,247,0,0,0,244,0,0,0,240,0,0,0,236,0,0,0,233,0,0,0,229,0,0,0,226,0,0,0,222,0,0,0,218,0,0,0,215,0,0,0,211,0,0,0,208,0,0,0,204,0,0,0,200,0,0,0,197,0,0,0,193,0,0,0,190,0,0,0,186,0,0,0,182,0,0,0,179,0,0,0,175,0,0,0,172,0,0,0,168,0,0,0,164,0,0,0,161,0,0,0,157,0,0,0,154,0,0,0,150,0,0,0,146,0,0,0,143,0,0,0,139,0,0,0,136,0,0,0,132,0,0,0,128,0,0,0,125,0,0,0,121,0,0,0,118,0,0,0,114,0,0,0,110,0,0,0,107,0,0,0,103,0,0,0,100,0,0,0]),g:new Float32Array([0,0,0,0,2,0,0,0,5,0,0,0,8,0,0,0,10,0,0,0,13,0,0,0,16,0,0,0,18,0,0,0,21,0,0,0,24,0,0,0,26,0,0,0,29,0,0,0,32,0,0,0,34,0,0,0,37,0,0,0,40,0,0,0,42,0,0,0,45,0,0,0,48,0,0,0,50,0,0,0,53,0,0,0,56,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,66,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,80,0,0,0,82,0,0,0,85,0,0,0,88,0,0,0,90,0,0,0,93,0,0,0,96,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,106,0,0,0,109,0,0,0,112,0,0,0,114,0,0,0,117,0,0,0,119,0,0,0,122,0,0,0,124,0,0,0,127,0,0,0,129,0,0,0,132,0,0,0,134,0,0,0,137,0,0,0,139,0,0,0,142,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,152,0,0,0,155,0,0,0,157,0,0,0,160,0,0,0,162,0,0,0,165,0,0,0,167,0,0,0,170,0,0,0,172,0,0,0,175,0,0,0,177,0,0,0,180,0,0,0,182,0,0,0,185,0,0,0,188,0,0,0,190,0,0,0,193,0,0,0,195,0,0,0,198,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,208,0,0,0,210,0,0,0,213,0,0,0,215,0,0,0,218,0,0,0,221,0,0,0,221,0,0,0,221,0,0,0,222,0,0,0,222,0,0,0,222,0,0,0,223,0,0,0,223,0,0,0,224,0,0,0,224,0,0,0,224,0,0,0,225,0,0,0,225,0,0,0,225,0,0,0,226,0,0,0,226,0,0,0,227,0,0,0,227,0,0,0,227,0,0,0,228,0,0,0,228,0,0,0,229,0,0,0,229,0,0,0,229,0,0,0,230,0,0,0,230,0,0,0,230,0,0,0,231,0,0,0,231,0,0,0,232,0,0,0,232,0,0,0,232,0,0,0,233,0,0,0,233,0,0,0,233,0,0,0,234,0,0,0,234,0,0,0,235,0,0,0,235,0,0,0,235,0,0,0,236,0,0,0,236,0,0,0,237,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,227,0,0,0,226,0,0,0,225,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,215,0,0,0,214,0,0,0,213,0,0,0,211,0,0,0,210,0,0,0,209,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,195,0,0,0,194,0,0,0,193,0,0,0,191,0,0,0,190,0,0,0,189,0,0,0,187,0,0,0,186,0,0,0,185,0,0,0,183,0,0,0,182,0,0,0,181,0,0,0,180,0,0,0,177,0,0,0,175,0,0,0,172,0,0,0,170,0,0,0,167,0,0,0,165,0,0,0,162,0,0,0,160,0,0,0,157,0,0,0,155,0,0,0,152,0,0,0,150,0,0,0,147,0,0,0,145,0,0,0,142,0,0,0,140,0,0,0,137,0,0,0,135,0,0,0,132,0,0,0,130,0,0,0,127,0,0,0,125,0,0,0,122,0,0,0,120,0,0,0,117,0,0,0,115,0,0,0,112,0,0,0,110,0,0,0,107,0,0,0,105,0,0,0,102,0,0,0,100,0,0,0,97,0,0,0,95,0,0,0,92,0,0,0,90,0,0,0,87,0,0,0,85,0,0,0,82,0,0,0,80,0,0,0,77,0,0,0,75,0,0,0,73,0,0,0,71,0,0,0,69,0,0,0,68,0,0,0,66,0,0,0,64,0,0,0,62,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,54,0,0,0,52,0,0,0,50,0,0,0,48,0,0,0,47,0,0,0,45,0,0,0,43,0,0,0,41,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,34,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,26,0,0,0,24,0,0,0,22,0,0,0,20,0,0,0,19,0,0,0,17,0,0,0,15,0,0,0,13,0,0,0,12,0,0,0,10,0,0,0,8,0,0,0,6,0,0,0,5,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254,0,0,0,253,0,0,0,252,0,0,0,251,0,0,0,250,0,0,0,249,0,0,0,248,0,0,0,247,0,0,0,246,0,0,0,245,0,0,0,245,0,0,0,244,0,0,0,243,0,0,0,242,0,0,0,241,0,0,0,240,0,0,0,239,0,0,0,238,0,0,0,237,0,0,0,236,0,0,0,236,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,232,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,228,0,0,0,227,0,0,0,226,0,0,0,226,0,0,0,225,0,0,0,224,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,220,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,217,0,0,0,211,0,0,0,206,0,0,0,201,0,0,0,196,0,0,0,191,0,0,0,186,0,0,0,181,0,0,0,176,0,0,0,171,0,0,0,166,0,0,0,161,0,0,0,156,0,0,0,151,0,0,0,146,0,0,0,141,0,0,0,136,0,0,0,131,0,0,0,126,0,0,0,121,0,0,0,116,0,0,0,111,0,0,0,105,0,0,0,100,0,0,0,95,0,0,0,90,0,0,0,85,0,0,0,80,0,0,0,75,0,0,0,70,0,0,0,65,0,0,0,60,0,0,0,55,0,0,0,50,0,0,0,45,0,0,0,40,0,0,0,35,0,0,0,30,0,0,0,25,0,0,0,20,0,0,0,15,0,0,0,10,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},rainbow:{name:"rainbow",r:new Float32Array([0,0,0,0,4,0,0,0,9,0,0,0,13,0,0,0,18,0,0,0,22,0,0,0,27,0,0,0,31,0,0,0,36,0,0,0,40,0,0,0,45,0,0,0,50,0,0,0,54,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,68,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,79,0,0,0,80,0,0,0,82,0,0,0,83,0,0,0,85,0,0,0,84,0,0,0,86,0,0,0,87,0,0,0,88,0,0,0,86,0,0,0,87,0,0,0,87,0,0,0,87,0,0,0,85,0,0,0,84,0,0,0,84,0,0,0,84,0,0,0,83,0,0,0,79,0,0,0,78,0,0,0,77,0,0,0,76,0,0,0,71,0,0,0,70,0,0,0,68,0,0,0,66,0,0,0,60,0,0,0,58,0,0,0,55,0,0,0,53,0,0,0,46,0,0,0,43,0,0,0,40,0,0,0,36,0,0,0,33,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,12,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,33,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,80,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,101,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,123,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,153,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,169,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,212,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,16,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,38,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,84,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,106,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,127,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,152,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,195,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,216,0,0,0,220,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,250,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,221,0,0,0,216,0,0,0,212,0,0,0,208,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,161,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,119,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,85,0,0,0,80,0,0,0,76,0,0,0,72,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,51,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,29,0,0,0,21,0,0,0,17,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0]),b:new Float32Array([0,0,0,0,3,0,0,0,7,0,0,0,10,0,0,0,14,0,0,0,19,0,0,0,23,0,0,0,28,0,0,0,32,0,0,0,38,0,0,0,43,0,0,0,48,0,0,0,53,0,0,0,59,0,0,0,63,0,0,0,68,0,0,0,72,0,0,0,77,0,0,0,81,0,0,0,86,0,0,0,91,0,0,0,95,0,0,0,100,0,0,0,104,0,0,0,109,0,0,0,113,0,0,0,118,0,0,0,122,0,0,0,127,0,0,0,132,0,0,0,136,0,0,0,141,0,0,0,145,0,0,0,150,0,0,0,154,0,0,0,159,0,0,0,163,0,0,0,168,0,0,0,173,0,0,0,177,0,0,0,182,0,0,0,186,0,0,0,191,0,0,0,195,0,0,0,200,0,0,0,204,0,0,0,209,0,0,0,214,0,0,0,218,0,0,0,223,0,0,0,227,0,0,0,232,0,0,0,236,0,0,0,241,0,0,0,245,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,225,0,0,0,220,0,0,0,216,0,0,0,212,0,0,0,203,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,157,0,0,0,152,0,0,0,148,0,0,0,144,0,0,0,135,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,114,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,84,0,0,0,80,0,0,0,76,0,0,0,67,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,46,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},eosb:{name:"eosb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,18,0,0,0,27,0,0,0,36,0,0,0,45,0,0,0,49,0,0,0,57,0,0,0,72,0,0,0,81,0,0,0,91,0,0,0,100,0,0,0,109,0,0,0,118,0,0,0,127,0,0,0,136,0,0,0,131,0,0,0,139,0,0,0,163,0,0,0,173,0,0,0,182,0,0,0,191,0,0,0,200,0,0,0,209,0,0,0,218,0,0,0,227,0,0,0,213,0,0,0,221,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,253,0,0,0,251,0,0,0,249,0,0,0,247,0,0,0,245,0,0,0,243,0,0,0,241,0,0,0,215,0,0,0,214,0,0,0,235,0,0,0,234,0,0,0,232,0,0,0,230,0,0,0,228,0,0,0,226,0,0,0,224,0,0,0,222,0,0,0,198,0,0,0,196,0,0,0,216,0,0,0,215,0,0,0,213,0,0,0,211,0,0,0,209,0,0,0,207,0,0,0,205,0,0,0,203,0,0,0,181,0,0,0,179,0,0,0,197,0,0,0,196,0,0,0,194,0,0,0,192,0,0,0,190,0,0,0,188,0,0,0,186,0,0,0,184,0,0,0,164,0,0,0,162,0,0,0,178,0,0,0,176,0,0,0,175,0,0,0,173,0,0,0,171,0,0,0,169,0,0,0,167,0,0,0,165,0,0,0,147,0,0,0,145,0,0,0,159,0,0,0,157,0,0,0,156,0,0,0,154,0,0,0,152,0,0,0,150,0,0,0,148,0,0,0,146,0,0,0,130,0,0,0,128,0,0,0,140,0,0,0,138,0,0,0,137,0,0,0,135,0,0,0,133,0,0,0,131,0,0,0,129,0,0,0,127,0,0,0,113,0,0,0,111,0,0,0,121,0,0,0,119,0,0,0,117,0,0,0,117,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,15,0,0,0,23,0,0,0,31,0,0,0,39,0,0,0,47,0,0,0,55,0,0,0,57,0,0,0,64,0,0,0,79,0,0,0,87,0,0,0,95,0,0,0,103,0,0,0,111,0,0,0,119,0,0,0,127,0,0,0,135,0,0,0,129,0,0,0,136,0,0,0,159,0,0,0,167,0,0,0,175,0,0,0,183,0,0,0,191,0,0,0,199,0,0,0,207,0,0,0,215,0,0,0,200,0,0,0,207,0,0,0,239,0,0,0,247,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,250,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,225,0,0,0,198,0,0,0,195,0,0,0,212,0,0,0,208,0,0,0,204,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,182,0,0,0,160,0,0,0,156,0,0,0,169,0,0,0,165,0,0,0,161,0,0,0,157,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,122,0,0,0,118,0,0,0,127,0,0,0,125,0,0,0,123,0,0,0,121,0,0,0,119,0,0,0,116,0,0,0,114,0,0,0,112,0,0,0,99,0,0,0,97,0,0,0,106,0,0,0,104,0,0,0,102,0,0,0,99,0,0,0,97,0,0,0,95,0,0,0,93,0,0,0,91,0,0,0,80,0,0,0,78,0,0,0,84,0,0,0,82,0,0,0,80,0,0,0,78,0,0,0,76,0,0,0,74,0,0,0,72,0,0,0,70,0,0,0,61,0,0,0,59,0,0,0,63,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,53,0,0,0,50,0,0,0,48,0,0,0,42,0,0,0,40,0,0,0,42,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,19,0,0,0,16,0,0,0,14,0,0,0,12,0,0,0,13,0,0,0,8,0,0,0,6,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),b:new Float32Array([116,0,0,0,121,0,0,0,127,0,0,0,131,0,0,0,136,0,0,0,140,0,0,0,144,0,0,0,148,0,0,0,153,0,0,0,157,0,0,0,145,0,0,0,149,0,0,0,170,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,195,0,0,0,199,0,0,0,183,0,0,0,187,0,0,0,212,0,0,0,216,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,238,0,0,0,242,0,0,0,221,0,0,0,225,0,0,0,255,0,0,0,247,0,0,0,239,0,0,0,231,0,0,0,223,0,0,0,215,0,0,0,207,0,0,0,199,0,0,0,172,0,0,0,164,0,0,0,175,0,0,0,167,0,0,0,159,0,0,0,151,0,0,0,143,0,0,0,135,0,0,0,127,0,0,0,119,0,0,0,100,0,0,0,93,0,0,0,95,0,0,0,87,0,0,0,79,0,0,0,71,0,0,0,63,0,0,0,55,0,0,0,47,0,0,0,39,0,0,0,28,0,0,0,21,0,0,0,15,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},cubehelix:{name:"cubehelix",r:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,24,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,24,0,0,0,24,0,0,0,24,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,20,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,27,0,0,0,27,0,0,0,28,0,0,0,30,0,0,0,31,0,0,0,32,0,0,0,33,0,0,0,35,0,0,0,36,0,0,0,38,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,49,0,0,0,51,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,60,0,0,0,62,0,0,0,65,0,0,0,67,0,0,0,70,0,0,0,72,0,0,0,75,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,89,0,0,0,92,0,0,0,95,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,107,0,0,0,110,0,0,0,113,0,0,0,116,0,0,0,120,0,0,0,123,0,0,0,126,0,0,0,129,0,0,0,132,0,0,0,135,0,0,0,138,0,0,0,141,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,153,0,0,0,155,0,0,0,158,0,0,0,161,0,0,0,164,0,0,0,166,0,0,0,169,0,0,0,171,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,181,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,199,0,0,0,201,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,207,0,0,0,208,0,0,0,209,0,0,0,209,0,0,0,210,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,210,0,0,0,210,0,0,0,210,0,0,0,209,0,0,0,208,0,0,0,208,0,0,0,207,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,205,0,0,0,204,0,0,0,203,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,201,0,0,0,200,0,0,0,199,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,197,0,0,0,196,0,0,0,196,0,0,0,195,0,0,0,195,0,0,0,194,0,0,0,194,0,0,0,194,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,194,0,0,0,194,0,0,0,195,0,0,0,195,0,0,0,196,0,0,0,196,0,0,0,197,0,0,0,198,0,0,0,199,0,0,0,200,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,208,0,0,0,209,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,217,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,223,0,0,0,225,0,0,0,227,0,0,0,229,0,0,0,231,0,0,0,232,0,0,0,234,0,0,0,236,0,0,0,238,0,0,0,240,0,0,0,242,0,0,0,244,0,0,0,245,0,0,0,247,0,0,0,249,0,0,0,251,0,0,0,253,0,0,0,255]),g:new Float32Array([0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,11,0,0,0,11,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,28,0,0,0,29,0,0,0,31,0,0,0,32,0,0,0,34,0,0,0,35,0,0,0,37,0,0,0,38,0,0,0,40,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,46,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,58,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,73,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,79,0,0,0,81,0,0,0,83,0,0,0,84,0,0,0,86,0,0,0,88,0,0,0,89,0,0,0,91,0,0,0,92,0,0,0,94,0,0,0,95,0,0,0,97,0,0,0,98,0,0,0,99,0,0,0,101,0,0,0,102,0,0,0,103,0,0,0,104,0,0,0,106,0,0,0,107,0,0,0,108,0,0,0,109,0,0,0,110,0,0,0,111,0,0,0,112,0,0,0,113,0,0,0,114,0,0,0,114,0,0,0,115,0,0,0,116,0,0,0,116,0,0,0,117,0,0,0,118,0,0,0,118,0,0,0,119,0,0,0,119,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,123,0,0,0,123,0,0,0,124,0,0,0,124,0,0,0,125,0,0,0,125,0,0,0,126,0,0,0,127,0,0,0,127,0,0,0,128,0,0,0,129,0,0,0,130,0,0,0,131,0,0,0,131,0,0,0,132,0,0,0,133,0,0,0,135,0,0,0,136,0,0,0,137,0,0,0,138,0,0,0,139,0,0,0,140,0,0,0,142,0,0,0,143,0,0,0,144,0,0,0,146,0,0,0,147,0,0,0,149,0,0,0,150,0,0,0,152,0,0,0,154,0,0,0,155,0,0,0,157,0,0,0,158,0,0,0,160,0,0,0,162,0,0,0,164,0,0,0,165,0,0,0,167,0,0,0,169,0,0,0,171,0,0,0,172,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,180,0,0,0,182,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,208,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,216,0,0,0,218,0,0,0,219,0,0,0,221,0,0,0,222,0,0,0,224,0,0,0,225,0,0,0,226,0,0,0,228,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,232,0,0,0,233,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,247,0,0,0,248,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,250,0,0,0,251,0,0,0,251,0,0,0,252,0,0,0,252,0,0,0,253,0,0,0,253,0,0,0,254,0,0,0,255,0,0,0]),b:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,11,0,0,0,13,0,0,0,15,0,0,0,17,0,0,0,19,0,0,0,21,0,0,0,23,0,0,0,25,0,0,0,27,0,0,0,29,0,0,0,31,0,0,0,33,0,0,0,35,0,0,0,37,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,54,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,63,0,0,0,65,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,70,0,0,0,71,0,0,0,72,0,0,0,73,0,0,0,74,0,0,0,74,0,0,0,75,0,0,0,76,0,0,0,76,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,76,0,0,0,76,0,0,0,75,0,0,0,75,0,0,0,74,0,0,0,73,0,0,0,73,0,0,0,72,0,0,0,71,0,0,0,70,0,0,0,69,0,0,0,68,0,0,0,67,0,0,0,66,0,0,0,66,0,0,0,65,0,0,0,64,0,0,0,63,0,0,0,61,0,0,0,60,0,0,0,59,0,0,0,58,0,0,0,58,0,0,0,57,0,0,0,56,0,0,0,55,0,0,0,54,0,0,0,53,0,0,0,52,0,0,0,51,0,0,0,51,0,0,0,50,0,0,0,49,0,0,0,49,0,0,0,48,0,0,0,48,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,48,0,0,0,48,0,0,0,49,0,0,0,50,0,0,0,50,0,0,0,51,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,65,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,88,0,0,0,91,0,0,0,94,0,0,0,96,0,0,0,99,0,0,0,102,0,0,0,105,0,0,0,108,0,0,0,111,0,0,0,114,0,0,0,117,0,0,0,120,0,0,0,124,0,0,0,127,0,0,0,130,0,0,0,133,0,0,0,136,0,0,0,140,0,0,0,143,0,0,0,146,0,0,0,149,0,0,0,153,0,0,0,156,0,0,0,159,0,0,0,162,0,0,0,165,0,0,0,169,0,0,0,172,0,0,0,175,0,0,0,178,0,0,0,181,0,0,0,184,0,0,0,186,0,0,0,189,0,0,0,192,0,0,0,195,0,0,0,197,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,210,0,0,0,212,0,0,0,214,0,0,0,216,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,224,0,0,0,226,0,0,0,227,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,233,0,0,0,234,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,241,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,252,0,0,0,253,0,0,0,255,0,0,0])},hot:{name:"hot",r:new Float32Array([0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.30769,4.61538,6.92308,9.23077,11.5385,13.8462,16.1538,18.4615,20.7692,23.0769,25.3846,27.6923,30,32.3077,34.6154,36.9231,39.2308,41.5385,43.8462,46.1538,48.4615,50.7692,53.0769,55.3846,57.6923,60,62.3077,64.6154,66.9231,69.2308,71.5385,73.8462,76.1538,78.4615,80.7692,83.0769,85.3846,87.6923,90,92.3077,94.6154,96.9231,99.2308,101.538,103.846,106.154,108.462,110.769,113.077,115.385,117.692,120,122.308,124.615,126.923,129.231,131.538,133.846,136.154,138.462,140.769,143.077,145.385,147.692,150,152.308,154.615,156.923,159.231,161.538,163.846,166.154,168.462,170.769,173.077,175.385,177.692,180,182.308,184.615,186.923,189.231,191.538,193.846,196.154,198.462,200.769,203.077,205.385,207.692,210,212.308,214.615,216.923,219.231,221.538,223.846,226.154,228.462,230.769,233.077,235.385,237.692,240,242.308,244.615,246.923,249.231,251.538,253.846,255,255,255,255,255,255,255]),b:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.980769,1.96154,2.94231,3.92308,4.90385,5.88461,6.86539,7.84615,8.82692,9.80769,10.7885,11.7692,12.75,13.7308,14.7115,15.6923,16.6731,17.6538,18.6346,19.6154,20.5962,21.5769,22.5577,23.5385,24.5192,25.5,26.4808,27.4615,28.4423,29.4231,30.4038,31.3846,32.3654,33.3462,34.3269,35.3077,36.2885,37.2692,38.25,39.2308,40.2115,41.1923,42.1731,43.1538,44.1346,45.1154,46.0962,47.0769,48.0577,49.0385,50.0192,51,51.9808,52.9615,53.9423,54.9231,55.9038,56.8846,57.8654,58.8462,59.8269,60.8077,61.7885,62.7692,63.75,64.7308,65.7115,66.6923,67.6731,68.6538,69.6346,70.6154,71.5962,72.5769,73.5577,74.5385,75.5192,76.5,77.4808,78.4615,79.4423,80.4231,81.4038,82.3846,83.3654,84.3462,85.3269,86.3077,87.2885,88.2692,89.25,90.2308,91.2115,92.1923,93.1731,94.1538,95.1346,96.1154,97.0962,98.0769,99.0577,100.038,101.019,102,102.981,103.962,104.942,105.923,106.904,107.885,108.865,109.846,110.827,111.808,112.788,113.769,114.75,115.731,116.711,117.692,118.673,119.654,120.634,121.615,122.596,123.577,124.557,125.538,126.519,127.5])},gray:{name:"gray",r:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),g:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),b:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255])}},t.default=t.ColorMaps},772:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AstroViewer=void 0;const s=r(i(4723)),a=i(5087),o=i(1232),n=i(592),h=i(2919),l=r(i(619)),c=i(5409),u=i(8868),d=i(5781),_=i(9022);t.AstroViewer=class{astroSphere;canvas;webgl;rafId=null;webglContextList=new Map;viewfinderEl=null;viewfinderVisible=h.bootSetup.showViewfinder;viewfinderColor="rgba(75,148,226,0.68)";run(){return this.tick()}createCatalogue(e,t,i,r){return new o.CatalogueGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showCatalogue(e){this.astroSphere.showCatalogue(e)}hideCatalogue(e,t){e.setIsVisible(t)}deleteCatalogue(e){this.astroSphere.deleteCatalogue(e)}changeCatalogueRA(e,t){return e.changeMetaRA(t),e}changeCatalogueDec(e,t){return e.changeMetaDec(t),e}changeCatalogueColor(e,t){return e.changeColor(t),e}setCatalogueShapeHue(e,t){return e.changeMetaShapeHue(t),e}setCatalogueShapeSize(e,t){return e.changeMetaShapeSize(t),e}createFootprintSet(e,t,i,r){return new n.FootprintSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideFootprintSet(e,t){e.setIsVisible(t)}deleteFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}createTerraPointSet(e,t,i,r){return new d.TerraPointSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraPointSet(e){this.astroSphere.showCatalogue(e)}hideTerraPointSet(e,t){e.setIsVisible(t)}deleteTerraPointSet(e){this.astroSphere.deleteCatalogue(e)}createTerraFootprintSet(e,t,i,r){return new _.TerraFootprintSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideTerraFootprintSet(e,t){e.setIsVisible(t)}deleteTerraFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}changeFootprintSetColor(e,t){e.changeColor(t)}getHoveredFootprints(){return this.astroSphere.getHoveredFootprints()}getDefaultHiPSURL(){return h.bootSetup.defaultHipsUrl}activateHiPS(e){this.astroSphere.activateHiPS(e)}activateXYZ(e){this.astroSphere.activateXYZ(e)}activateXYZ2(e){const t=new u.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver);this.astroSphere.activateXYZ2(t)}activateWMTS(e){this.astroSphere.activateWMTS(e)}setXYZMaxConcurrentRequests(e){c.xyzTileRequestScheduler.setMaxConcurrent(e)}getXYZMaxConcurrentRequests(){return c.xyzTileRequestScheduler.getMaxConcurrent()}getXYZDebugStats(){return this.astroSphere.getXYZDebugStats()}getHiPSDebugStats(){return this.astroSphere.getHiPSDebugStats()}async loadHiPS(e){const t=e.endsWith("/")?e:e+"/",i=await fetch(t+"properties");if(!i.ok)throw new Error(`HTTP ${i.status} fetching properties`);const r=await i.text(),s=new a.HiPSDescriptor(r,t);return this.astroSphere.activateHiPS(s),s.surveyName}changeColorMap(e){const t=l.default[e];this.astroSphere.changeColorMap(t)}changeCustomColorMap(e){this.astroSphere.changeColorMap(e)}getActiveHiPS(){return this.astroSphere.activeHiPS}getActiveXYZ(){return this.astroSphere.activeXYZ}setCamera(e){this.astroSphere.setCamera(e)}setCameraPosition(e){this.astroSphere.setCameraPosition(e)}setCameraMatrix(e){this.astroSphere.setCameraMatrix(e)}restoreAstroViewerState(e,t){this.astroSphere.applyFullCameraState(e,t)}getCurrentAstroViewerStatus(){return this.astroSphere.getCurrentStatus()}goTo(e,t){this.astroSphere.goTo(e,t)}getActiveCoordinateMode(){return this.astroSphere.getActiveCoordinateMode()}getCenterCoordinates(){return this.astroSphere.getCentralPointCoordinates()}getCoordinatesFromMouse(){return this.astroSphere.getLastMousePointCoordinates()}setModelMatrix(e){this.astroSphere.healpixGrid.setModelMatrix(e)}toggleHealpixGrid(){this.astroSphere.healpixGrid.toggleShowGrid()}isHealpixGridVisible(){return this.astroSphere.healpixGrid.isVisible()}toggleEquatorialGrid(){return this.astroSphere.equatorialGrid.toggleShowGrid()}isEquatorialGridVisible(){return this.astroSphere.equatorialGrid.isVisible()}toggleLonLatGrid(){return this.astroSphere.toggleLonLatGrid()}isLonLatGridVisible(){return this.astroSphere.isLonLatGridVisible()}setEastWestRotationLocked(e){this.astroSphere.setEastWestRotationLocked(e)}isEastWestRotationLocked(){return this.astroSphere.isEastWestRotationLocked()}setNorthSouthRotationLocked(e){this.astroSphere.setNorthSouthRotationLocked(e)}isNorthSouthRotationLocked(){return this.astroSphere.isNorthSouthRotationLocked()}resetAxesOrientation(){this.astroSphere.resetAxesOrientation()}setKeepCameraNorthUp(e){this.astroSphere.setKeepCameraNorthUp(e)}isKeepCameraNorthUp(){return this.astroSphere.isKeepCameraNorthUp()}getFoV(){return this.astroSphere.getFoV()}getFoVPolygon(){return this.astroSphere.getFoVPolygon()}changeFoV(e){this.astroSphere.changeFoV(e)}changeFoV2(e){this.astroSphere.changeFoV2(e)}changeFoV3(e){this.astroSphere.changeFoV3(e)}getInsideSphere(){return this.astroSphere.getInsideSphere()}toggleInsideSphere(){this.astroSphere.toggleInsideSphere()}toggleViewfinder(){return this.viewfinderVisible=!this.viewfinderVisible,this.syncViewfinderVisibility(),this.viewfinderVisible}setViewfinderVisible(e){this.viewfinderVisible=e,this.syncViewfinderVisibility()}isViewfinderVisible(){return this.viewfinderVisible}setViewfinderColor(e){this.viewfinderColor=e,this.syncViewfinderColor()}getViewfinderColor(){return this.viewfinderColor}setRotationSensitivity(e){this.astroSphere.setCameraRotationSensitivity(e)}getRotationSensitivity(){return this.astroSphere.getCameraRotationSensitivity()}setZoomSensitivity(e){this.astroSphere.setZoomSensitivity(e)}getZoomSensitivity(){return this.astroSphere.getZoomSensitivity()}constructor(e){this.init(e),this.webglContextList=new Map}init(e){console.log("init webgl"),this.canvas=e,this.initViewfinder();const t=this.canvas.getContext("webgl2",{alpha:!1});if(!t)throw alert("Could not initialise WebGL, sorry :-("),new Error("WebGL2 not available");this.webgl=t;try{this.webgl.clearColor(0,.06274509792,50*.00392156862,.7)}catch(e){console.log("Error instantiating WebGL context")}this.initListeners(),this.astroSphere=new s.default(this.canvas,this.webgl)}initViewfinder(){const e=this.canvas.parentElement;if(!e)return;"static"===window.getComputedStyle(e).position&&(e.style.position="relative");const t=document.createElement("div");t.setAttribute("data-astro-viewfinder","true"),t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.width="44px",t.style.height="44px",t.style.transform="translate(-50%, -50%)",t.style.pointerEvents="none",t.style.zIndex="1",t.style.boxSizing="border-box";const i=[{left:"50%",top:"7px",width:"1px",height:"11px",transform:"translateX(-50%)"},{left:"50%",bottom:"7px",width:"1px",height:"11px",transform:"translateX(-50%)"},{left:"7px",top:"50%",width:"11px",height:"1px",transform:"translateY(-50%)"},{right:"7px",top:"50%",width:"11px",height:"1px",transform:"translateY(-50%)"}];for(const e of i){const i=document.createElement("div");i.style.position="absolute",i.style.left=e.left??"auto",i.style.right=e.right??"auto",i.style.top=e.top??"auto",i.style.bottom=e.bottom??"auto",i.style.width=e.width,i.style.height=e.height,i.style.transform=e.transform,i.style.background="currentColor",i.style.borderRadius="999px",i.style.boxShadow="0 0 0 1px rgba(0, 0, 0, 0.14)",t.appendChild(i)}e.appendChild(t),this.viewfinderEl=t,this.syncViewfinderVisibility(),this.syncViewfinderColor()}syncViewfinderVisibility(){this.viewfinderEl&&(this.viewfinderEl.style.display=this.viewfinderVisible?"block":"none")}syncViewfinderColor(){this.viewfinderEl&&(this.viewfinderEl.style.color=this.viewfinderColor)}initListeners(){console.log("inside initListeners");const e=()=>{console.log("[resizeCanvas]");const e=this.canvas.getBoundingClientRect(),t=window.devicePixelRatio||1,i=Math.max(1,Math.floor(e.width*t)),r=Math.max(1,Math.floor(e.height*t));this.canvas.width===i&&this.canvas.height===r||(this.canvas.width=i,this.canvas.height=r,this.webgl.viewport(0,0,this.canvas.width,this.canvas.height))};"ResizeObserver"in window&&new ResizeObserver(()=>{e()}).observe(this.canvas),window.addEventListener("resize",e),this.canvas.addEventListener("webglcontextlost",e=>{console.log("[handleContextLost]"),e.preventDefault(),null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)},!1),this.canvas.addEventListener("webglcontextrestored",e=>{console.log("[handleContextRestored]"),this.webgl.clearColor(0,.06274509792,50*.00392156862,.7),this.webgl.enable(this.webgl.DEPTH_TEST),this.rafId=requestAnimationFrame(()=>this.tick())},!1),e()}tick(){return this.drawScene(),this.rafId=requestAnimationFrame(()=>this.tick()),this.rafId}drawScene(){this.astroSphere.draw(this.canvas)}}},1072:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataColumn=t.ColumnType=void 0,function(e){e.STRING="STRING",e.NUMBER="NUMBER",e.GEOM_RA="GEOM_RA",e.GEOM_DEC="GEOM_DEC",e.GEOM_FOOTPRINT="GEOM_FOOTPRINT",e.MAIN_NAME="MAIN_NAME"}(i||(t.ColumnType=i={})),t.MetadataColumn=class{_index;_name;_description="";_columnType;_unit;_details=new Map;constructor(e){if(!e.name)throw new Error("No name column defined.");if(this._name=e.name,e.index<0||isNaN(e.index))throw new Error("No index column defined.");this._index=e.index,this._columnType=e.columnType??i.STRING,this._unit=e.unit??"",this._description=e.description??"",e.details&&(this._details=new Map(e.details))}get details(){return new Map(this._details)}getDetail(e,t){return this._details.has(e)?this._details.get(e):t}getString(e,t=""){const i=this._details.get(e);return"string"==typeof i?i:t}getNumber(e,t=NaN){const i=this._details.get(e);return"number"==typeof i?i:t}setDetail(e,t){this._details.set(e,t)}setDetails(e){const t=e instanceof Map?e.entries():Object.entries(e);for(const[e,i]of t)this._details.set(e,i)}detailKeys(){return Array.from(this._details.keys())}detailValues(){return Array.from(this._details.values())}detailEntries(){return Array.from(this._details.entries())}get name(){return this._name}get description(){return this._description}get columnType(){return this._columnType}get index(){return this._index}get unit(){return this._unit}toJSON(){return{name:this._name,description:this._description,columnType:this._columnType,index:this._index,unit:this._unit,details:Object.fromEntries(this._details)}}}},1138:(e,t,i)=>{i.r(t),i.d(t,{CircleFinder:()=>l,Constants:()=>r,Fxyf:()=>c,Healpix:()=>_,Hploc:()=>n,Pointing:()=>a,RangeSet:()=>u,Vec3:()=>h,Xyf:()=>d,Zphi:()=>o,pstack:()=>s});class r{}r.halfpi=1.5707963267948966,r.inv_halfpi=2/Math.PI,r.twopi=2*Math.PI,r.inv_twopi=1/(2*Math.PI);class s{constructor(e){this.p=new Array(e),this.o=new Int32Array(e),this.s=0,this.m=0}push(e,t){this.p[this.s]=e,this.o[this.s]=t,++this.s}pop(){--this.s}popToMark(){this.s=this.m}size(){return this.s}mark(){this.m=this.s}otop(){return this.o[this.s-1]}ptop(){return this.p[this.s-1]}}class a{constructor(e,t,i,r){null!=e?(this.theta=n.atan2(Math.sqrt(e.x*e.x+e.y*e.y),e.z),this.phi=t?-n.atan2(e.y,e.x):n.atan2(e.y,e.x),this.phi<0&&(this.phi=this.phi+2*Math.PI),this.phi>=2*Math.PI&&(this.phi=this.phi-2*Math.PI)):(this.theta=i,this.phi=r)}}class o{constructor(e,t){this.z=e,this.phi=t}}class n{constructor(e){n.PI4_A=.7853981554508209,n.PI4_B=7.946627356147928e-9,n.PI4_C=3061616997868383e-32,n.M_1_PI=.3183098861837907,e&&(this.sth=0,this.have_sth=!1,this.z=n.cos(e.theta),this._phi=e.phi,Math.abs(this.z)>.99&&(this.sth=n.sin(e.theta),this.have_sth=!0))}setZ(e){this.z=e}get phi(){return this._phi}set phi(e){this._phi=e}setSth(e){this.sth=e}toPointing(e){const t=this.have_sth?this.sth:Math.sqrt((1-this.z)*(1+this.z));return new a(null,!1,n.atan2(t,this.z),this._phi)}toVec3(){var e=this.have_sth?this.sth:Math.sqrt((1-this.z)*(1+this.z));return new h(e*n.cos(this.phi),e*n.sin(this.phi),this.z)}toZphi(){return new o(this.z,this.phi)}static sin(e){let t=e*n.M_1_PI,i=Math.floor(t<0?t-.5:t+.5),r=4*i;return e-=r*n.PI4_A,e-=r*n.PI4_B,e-=r*n.PI4_C,1&i&&(e=-e),this.sincoshelper(e)}static cos(e){let t=e*n.M_1_PI-.5,i=1+2*Math.floor(t<0?t-.5:t+.5),r=2*i;return e-=r*n.PI4_A,e-=r*n.PI4_B,e-=r*n.PI4_C,2&i||(e=-e),n.sincoshelper(e)}static sincoshelper(e){let t=e*e,i=-7972559550090379e-33;return i=i*t+2810099727108632e-30,i=i*t-7647122191181588e-28,i=i*t+1.605904306056645e-10,i=i*t-2.5052108376350205e-8,i=i*t+27557319223919875e-22,i=i*t-.00019841269841269616,i=i*t+.00833333333333333,i=i*t-.16666666666666666,t*i*e+e}static asin(e){return n.mulsign(n.atan2k(Math.abs(e),Math.sqrt((1+e)*(1-e))),e)}static acos(e){return n.mulsign(n.atan2k(Math.sqrt((1+e)*(1-e)),Math.abs(e)),e)+(e<0?Math.PI:0)}static mulsign(e,t){return n.copySign(1,t)*e}static copySign(e,t){return t<0?-Math.abs(e):Math.abs(e)}static atanhelper(e){let t=e*e,i=-1887960084630735e-20;return i=i*t+.00020985007664581698,i=i*t-.0011061183148667248,i=i*t+.003700267441887131,i=i*t-.008898961958876555,i=i*t+.016599329773529202,i=i*t-.025451762493231264,i=i*t+.03378525800013531,i=i*t-.04076291912768365,i=i*t+.04666671500778406,i=i*t-.052367485230348246,i=i*t+.05876663929266736,i=i*t-.06665735793610805,i=i*t+.07692195383117696,i=i*t-.09090899500824501,i=i*t+.11111110564826142,i=i*t-.1428571426677133,i=i*t+.19999999999659127,i=i*t-.3333333333333111,i*t*e+e}static atan2k(e,t){let i=0;if(t<0&&(t=-t,i=-2),e>t){let r=t;t=e,e=-r,i+=1}return n.atanhelper(e/t)+i*(Math.PI/2)}static atan2(e,t){let i=n.atan2k(Math.abs(e),t);return i=n.mulsign(i,t),(n.isinf(t)||0==t)&&(i=Math.PI/2-(n.isinf(t)?n.copySign(1,t)*(Math.PI/2):0)),n.isinf(e)&&(i=Math.PI/2-(n.isinf(t)?n.copySign(1,t)*(1*Math.PI/4):0)),0==e&&(i=-1==n.copySign(1,t)?Math.PI:0),n.isnan(t)||n.isnan(e)?NaN:n.mulsign(i,e)}static isnan(e){return e!=e}static isinf(e){return Math.abs(e)===1/0}}n.PI4_A=.7853981554508209,n.PI4_B=7.946627356147928e-9,n.PI4_C=3061616997868383e-32,n.M_1_PI=.3183098861837907;class h{constructor(e,t,i){if(e instanceof a){let t=e,i=n.sin(t.theta);this.x=i*n.cos(t.phi),this.y=i*n.sin(t.phi),this.z=n.cos(t.theta)}else this.x=e,this.y=t,this.z=i}getX(){return this.x}getY(){return this.y}getZ(){return this.z}scale(e){this.x*=e,this.y*=e,this.z*=e}cross(e){return new h(this.y*e.z-e.y*this.z,this.z*e.x-e.z*this.x,this.x*e.y-e.x*this.y)}add(e){return new h(this.x+e.x,this.y+e.y,this.z+e.z)}normalize(){let e=1/this.length();this.x*=e,this.y*=e,this.z*=e}norm(){let e=1/this.length();return new h(this.x*e,this.y*e,this.z*e)}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}sub(e){return new h(this.x-e.x,this.y-e.y,this.z-e.z)}angle(e){return n.atan2(this.cross(e).length(),this.dot(e))}flip(){this.x*=-1,this.y*=-1,this.z*=-1}static pointing2Vec3(e){let t=n.sin(e.theta),i=t*n.cos(e.phi),r=t*n.sin(e.phi),s=n.cos(e.theta);return new h(i,r,s)}}class l{constructor(e){let t=e.length;if(t>=2){this.center=e[0].add(e[1]),this.center.normalize(),this.cosrad=e[0].dot(this.center);for(let i=2;i<t;++i)e[i].dot(this.center)<this.cosrad&&this.getCircle(e,i)}else console.log("too few points")}getCircle(e,t){this.center=e[0].add(e[t]),this.center.normalize(),this.cosrad=e[0].dot(this.center);for(let i=1;i<t;++i)e[i].dot(this.center)<this.cosrad&&this.getCircle2(e,i,t)}getCircle2(e,t,i){this.center=e[t].add(e[i]),this.center.normalize(),this.cosrad=e[t].dot(this.center);for(let r=0;r<t;++r)e[r].dot(this.center)<this.cosrad&&(this.center=e[t].sub(e[r]).cross(e[i].sub(e[r])),this.center.normalize(),this.cosrad=e[r].dot(this.center),this.cosrad<0&&(this.center.flip(),this.cosrad=-this.cosrad))}getCenter(){return new h(this.center.x,this.center.y,this.center.z)}getCosrad(){return this.cosrad}}class c{constructor(e,t,i){this.fx=e,this.fy=t,this.face=i,this.jrll=new Uint8Array([2,2,2,2,3,3,3,3,4,4,4,4]),this.jpll=new Uint8Array([1,3,5,7,0,2,4,6,1,3,5,7]),this.halfpi=Math.PI/2}toHploc(){let e,t=new n,i=this.jrll[this.face]-this.fx-this.fy;if(i<1){e=i;let r=e*e/3;t.z=1-r,t.z>.99&&(t.sth=Math.sqrt(r*(2-r)),t.have_sth=!0)}else if(i>3){e=4-i;let r=e*e/3;t.z=r-1,t.z<-.99&&(t.sth=Math.sqrt(r*(2-r)),t.have_sth=!0)}else e=1,t.z=2*(2-i)/3;let r=this.jpll[this.face]*e+this.fx-this.fy;return r<0&&(r+=8),r>=8&&(r-=8),t.phi=e<1e-15?0:.5*this.halfpi*r/e,t}toVec3(){return this.toHploc().toVec3()}}class u{constructor(e){e<0&&console.error("capacity must be positive"),this.r=new Int32Array(e<<1),this.sz=0}append(e){this.append1(e,e+1)}append1(e,t){if(e>=t)return;if(this.sz>0&&e<=this.r[this.sz-1])return e<this.r[this.sz-2]&&console.error("bad append operation"),void(t>this.r[this.sz-1]&&(this.r[this.sz-1]=t));let i=this.sz+2;if(this.r.length<i){let e=Math.max(2*this.r.length,i),t=new Int32Array(e);t.set(this.r),this.r=t}this.r[this.sz]=e,this.r[this.sz+1]=t,this.sz+=2}ensureCapacity(e){this.r.length<e&&this.resize(Math.max(2*this.r.length,e))}resize(e){if(e<this.sz&&console.error("requested array size too small"),e==this.r.length)return;new Int32Array(e);let t=this.r.slice(0,this.sz+1);this.r=t}}class d{constructor(e,t,i){this.ix=e,this.iy=t,this.face=i}}class _{constructor(e){this.order_max=29,this.inv_halfpi=2/Math.PI,this.twothird=2/3,this.ns_max=Math.pow(2,this.order_max),this.ctab=new Uint16Array([0,1,256,257,2,3,258,259,512,513,768,769,514,515,770,771,4,5,260,261,6,7,262,263,516,517,772,773,518,519,774,775,1024,1025,1280,1281,1026,1027,1282,1283,1536,1537,1792,1793,1538,1539,1794,1795,1028,1029,1284,1285,1030,1031,1286,1287,1540,1541,1796,1797,1542,1543,1798,1799,8,9,264,265,10,11,266,267,520,521,776,777,522,523,778,779,12,13,268,269,14,15,270,271,524,525,780,781,526,527,782,783,1032,1033,1288,1289,1034,1035,1290,1291,1544,1545,1800,1801,1546,1547,1802,1803,1036,1037,1292,1293,1038,1039,1294,1295,1548,1549,1804,1805,1550,1551,1806,1807,2048,2049,2304,2305,2050,2051,2306,2307,2560,2561,2816,2817,2562,2563,2818,2819,2052,2053,2308,2309,2054,2055,2310,2311,2564,2565,2820,2821,2566,2567,2822,2823,3072,3073,3328,3329,3074,3075,3330,3331,3584,3585,3840,3841,3586,3587,3842,3843,3076,3077,3332,3333,3078,3079,3334,3335,3588,3589,3844,3845,3590,3591,3846,3847,2056,2057,2312,2313,2058,2059,2314,2315,2568,2569,2824,2825,2570,2571,2826,2827,2060,2061,2316,2317,2062,2063,2318,2319,2572,2573,2828,2829,2574,2575,2830,2831,3080,3081,3336,3337,3082,3083,3338,3339,3592,3593,3848,3849,3594,3595,3850,3851,3084,3085,3340,3341,3086,3087,3342,3343,3596,3597,3852,3853,3598,3599,3854,3855]),this.utab=new Uint16Array([0,1,4,5,16,17,20,21,64,65,68,69,80,81,84,85,256,257,260,261,272,273,276,277,320,321,324,325,336,337,340,341,1024,1025,1028,1029,1040,1041,1044,1045,1088,1089,1092,1093,1104,1105,1108,1109,1280,1281,1284,1285,1296,1297,1300,1301,1344,1345,1348,1349,1360,1361,1364,1365,4096,4097,4100,4101,4112,4113,4116,4117,4160,4161,4164,4165,4176,4177,4180,4181,4352,4353,4356,4357,4368,4369,4372,4373,4416,4417,4420,4421,4432,4433,4436,4437,5120,5121,5124,5125,5136,5137,5140,5141,5184,5185,5188,5189,5200,5201,5204,5205,5376,5377,5380,5381,5392,5393,5396,5397,5440,5441,5444,5445,5456,5457,5460,5461,16384,16385,16388,16389,16400,16401,16404,16405,16448,16449,16452,16453,16464,16465,16468,16469,16640,16641,16644,16645,16656,16657,16660,16661,16704,16705,16708,16709,16720,16721,16724,16725,17408,17409,17412,17413,17424,17425,17428,17429,17472,17473,17476,17477,17488,17489,17492,17493,17664,17665,17668,17669,17680,17681,17684,17685,17728,17729,17732,17733,17744,17745,17748,17749,20480,20481,20484,20485,20496,20497,20500,20501,20544,20545,20548,20549,20560,20561,20564,20565,20736,20737,20740,20741,20752,20753,20756,20757,20800,20801,20804,20805,20816,20817,20820,20821,21504,21505,21508,21509,21520,21521,21524,21525,21568,21569,21572,21573,21584,21585,21588,21589,21760,21761,21764,21765,21776,21777,21780,21781,21824,21825,21828,21829,21840,21841,21844,21845]),this.jrll=new Int16Array([2,2,2,2,3,3,3,3,4,4,4,4]),this.jpll=new Int16Array([1,3,5,7,0,2,4,6,1,3,5,7]),this.xoffset=new Int16Array([-1,-1,0,1,1,1,0,-1]),this.yoffset=new Int16Array([0,1,1,1,0,-1,-1,-1]),this.facearray=[new Int16Array([8,9,10,11,-1,-1,-1,-1,10,11,8,9]),new Int16Array([5,6,7,4,8,9,10,11,9,10,11,8]),new Int16Array([-1,-1,-1,-1,5,6,7,4,-1,-1,-1,-1]),new Int16Array([4,5,6,7,11,8,9,10,11,8,9,10]),new Int16Array([0,1,2,3,4,5,6,7,8,9,10,11]),new Int16Array([1,2,3,0,0,1,2,3,5,6,7,4]),new Int16Array([-1,-1,-1,-1,7,4,5,6,-1,-1,-1,-1]),new Int16Array([3,0,1,2,3,0,1,2,4,5,6,7]),new Int16Array([2,3,0,1,-1,-1,-1,-1,0,1,2,3])],this.swaparray=[new Int16Array([0,0,3]),new Int16Array([0,0,6]),new Int16Array([0,0,0]),new Int16Array([0,0,5]),new Int16Array([0,0,0]),new Int16Array([5,0,0]),new Int16Array([0,0,0]),new Int16Array([6,0,0]),new Int16Array([3,0,0])],e<=this.ns_max&&e>0&&(this.nside=e,this.npface=this.nside*this.nside,this.npix=12*this.npface,this.order=this.nside2order(this.nside),this.nl2=2*this.nside,this.nl3=3*this.nside,this.nl4=4*this.nside,this.fact2=4/this.npix,this.fact1=(this.nside<<1)*this.fact2,this.ncap=2*this.nside*(this.nside-1)),this.bn=[],this.mpr=[],this.cmpr=[],this.smpr=[]}computeBn(){for(let e=0;e<=this.order_max;++e)this.bn[e]=new _(1<<e),this.mpr[e]=this.bn[e].maxPixrad(),this.cmpr[e]=n.cos(this.mpr[e]),this.smpr[e]=n.sin(this.mpr[e])}getNPix(){return this.npix}getBoundaries(e){let t=new Array,i=this.nest2xyf(e),r=.5/this.nside,s=(i.ix+.5)/this.nside,a=(i.iy+.5)/this.nside;return t[0]=new c(s+r,a+r,i.face).toVec3(),t[1]=new c(s-r,a+r,i.face).toVec3(),t[2]=new c(s-r,a-r,i.face).toVec3(),t[3]=new c(s+r,a-r,i.face).toVec3(),t}getBoundariesWithStep(e,t){let i=new Array,r=this.nest2xyf(e),s=.5/this.nside,a=(r.ix+.5)/this.nside,o=(r.iy+.5)/this.nside,n=1/(this.nside*t);for(let e=0;e<t;e++)i[e]=new c(a+s-e*n,o+s,r.face).toVec3(),i[e+t]=new c(a-s,o+s-e*n,r.face).toVec3(),i[e+2*t]=new c(a-s+e*n,o-s,r.face).toVec3(),i[e+3*t]=new c(a+s,o-s+e*n,r.face).toVec3();return i}getPointsForXyfNoStep(e,t,i){let r=new Array,s=new d(e,t,i),a=.5/this.nside,o=(s.ix+.5)/this.nside,n=(s.iy+.5)/this.nside;return r[0]=new c(o+a,n+a,s.face).toVec3(),r[1]=new c(o-a,n+a,s.face).toVec3(),r[2]=new c(o-a,n-a,s.face).toVec3(),r[3]=new c(o+a,n-a,s.face).toVec3(),r}getPointsForXyf(e,t,i,r){let s=i*Math.pow(2,this.order),a=new Array,o=new d(e,t,r),n=.5/s,h=(o.ix+.5)/s,l=(o.iy+.5)/s;return a[0]=new c(h+n,l+n,o.face).toVec3(),a[1]=new c(h-n,l+n,o.face).toVec3(),a[2]=new c(h-n,l-n,o.face).toVec3(),a[3]=new c(h+n,l-n,o.face).toVec3(),a}neighbours(e){let t=new Int32Array(8),i=this.nest2xyf(e),r=i.ix,s=i.iy,a=i.face;var o=this.nside-1;if(r>0&&r<o&&s>0&&s<o){let e=Math.floor(a<<2*this.order),i=this.spread_bits(r),o=this.spread_bits(s)<<1,n=this.spread_bits(r+1),h=this.spread_bits(s+1)<<1,l=this.spread_bits(r-1),c=this.spread_bits(s-1)<<1;t[0]=e+l+o,t[1]=e+l+h,t[2]=e+i+h,t[3]=e+n+h,t[4]=e+n+o,t[5]=e+n+c,t[6]=e+i+c,t[7]=e+l+c}else for(let e=0;e<8;++e){let i=r+this.xoffset[e],o=s+this.yoffset[e],n=4;i<0?(i+=this.nside,n-=1):i>=this.nside&&(i-=this.nside,n+=1),o<0?(o+=this.nside,n-=3):o>=this.nside&&(o-=this.nside,n+=3);let h=this.facearray[n][a];if(h>=0){let r=this.swaparray[n][a>>>2];if((1&r)>0&&(i=Math.floor(this.nside-i-1)),(2&r)>0&&(o=Math.floor(this.nside-o-1)),(4&r)>0){let e=i;i=o,o=e}t[e]=this.xyf2nest(i,o,h)}else t[e]=-1}return t}nside2order(e){return e&e-1?-1:Math.log2(e)}nest2xyf(e){let t=Math.floor(e&this.npface-1);return new d(this.compress_bits(t),this.compress_bits(t>>1),Math.floor(e>>2*this.order))}xyf2nest(e,t,i){return Math.floor(i<<2*this.order)+this.spread_bits(e)+(this.spread_bits(t)<<1)}loc2pix(e){let t,i=e.z,r=e.phi,s=Math.abs(i),a=this.fmodulo(r*this.inv_halfpi,4);if(s<=this.twothird){let e=this.nside*(.5+a),r=this.nside*(.75*i),s=Math.floor(e-r),o=Math.floor(e+r),n=Math.floor(s>>>this.order),h=Math.floor(o>>>this.order),l=Math.floor(n==h?4|n:n<h?n:h+8),c=Math.floor(o&this.nside-1),u=Math.floor(this.nside-(s&this.nside-1)-1);t=this.xyf2nest(c,u,l)}else{let r=Math.min(3,Math.floor(a)),o=a-r,n=s<.99||!e.have_sth?this.nside*Math.sqrt(3*(1-s)):this.nside*e.sth/Math.sqrt((1+s)/3),h=Math.floor(o*n),l=Math.floor((1-o)*n);h>=this.nside&&(h=this.nside-1),l>=this.nside&&(l=this.nside-1),t=i>=0?this.xyf2nest(Math.floor(this.nside-l-1),Math.floor(this.nside-h-1),r):this.xyf2nest(Math.floor(h),Math.floor(l),r+8)}return t}pix2vec(e){return this.pix2loc(e).toVec3()}pix2zphi(e){return this.pix2loc(e).toZphi()}pix2ang(e,t){return this.pix2loc(e).toPointing(t)}pix2loc(e){let t,i=new n(void 0),s=this.nest2xyf(e),a=(this.jrll[s.face]<<this.order)-s.ix-s.iy-1;if(a<this.nside){t=a;let e=t*t*this.fact2;i.z=1-e,i.z>.99&&(i.sth=Math.sqrt(e*(2-e)),i.have_sth=!0)}else if(a>this.nl3){t=this.nl4-a;let e=t*t*this.fact2;i.z=e-1,i.z<-.99&&(i.sth=Math.sqrt(e*(2-e)),i.have_sth=!0)}else t=this.nside,i.z=(this.nl2-a)*this.fact1;let o=this.jpll[s.face]*t+s.ix-s.iy;return o<0&&(o+=8*t),i.phi=t==this.nside?.75*r.halfpi*o*this.fact1:.5*r.halfpi*o/t,i}za2vec(e,t){const i=Math.sqrt(1-e*e),r=i*Math.cos(t),s=i*Math.sin(t);return new h(r,s,e)}ang2vec(e,t){const i=Math.cos(e);return this.za2vec(i,t)}vec2ang(e){const{z:t,a:i}=this.vec2za(e.getX(),e.getY(),e.getZ());return{theta:Math.acos(t),phi:i}}vec2za(e,t,i){const r=e*e+t*t;if(0==r)return{z:i<0?-1:1,a:0};{const s=Math.PI/2,a=(Math.atan2(t,e)+s)%s;return{z:i/=Math.sqrt(i*i+r),a}}}ang2pix(e,t){return this.loc2pix(new n(e))}fmodulo(e,t){if(e>=0)return e<t?e:e%t;var i=e%t+t;return i===t?0:i}compress_bits(e){var t=Math.floor(21845&e)|Math.floor((1431633920&e)>>>15);return this.ctab[255&t]|this.ctab[t>>>8]<<4}spread_bits(e){return Math.floor(this.utab[255&e])|Math.floor(this.utab[e>>>8&255]<<16)|Math.floor(this.utab[e>>>16&255]<<32)|Math.floor(this.utab[e>>>24&255]<<48)}queryPolygonInclusive(e,t){let i=0!=t,s=e.length;if(!(s>=3))return void console.log("not enough vertices in polygon");let o=new Array;for(let t=0;t<s;++t)o[t]=h.pointing2Vec3(e[t]);let c=new Array,u=0,d=0,_=!1;for(;d<o.length;){let e=o[d],t=null,i=null;d==o.length-1?(i=o[1],t=o[0]):d==o.length-2?(i=o[0],t=o[d+1]):(t=o[d+1],i=o[d+2]),c[d]=e.cross(t).norm();let r=c[d].dot(i);if(0==d)u=r<0?-1:1,new a(e),_=!1;else{if(u*r<0){new a(t),o.splice(d+1,1),c.splice(d,1),_=!0,d-=1;continue}new a(e),_=!1}c[d].scale(u),d+=1}s=o.length;let f=new Array(i?s+1:s);if(f=f.fill(r.halfpi),i){let e=new l(o);c[s]=e.getCenter(),f[s]=n.acos(e.getCosrad())}return this.queryMultiDisc(c,f,t)}queryMultiDisc(e,t,i){this.computeBn();let r=0!=i,a=e.length;if(a!=t.length)return void console.error("inconsistent input arrays");let o=new u(8),h=0;r&&(Math.pow(2,this.order_max-this.order)>=i||console.error("invalid oversampling factor"),i&i-1&&console.error("oversampling factor must be a power of 2"),h=this.ilog2(i));let l,c,d=this.order+h,_=new Array(d+1);for(l=0;l<=d;++l){_[l]=new Array(a);let e=this.bn[l].maxPixrad();for(c=0;c<a;++c)_[l][c]=new Float64Array(3),_[l][c][0]=t[c]+e>Math.PI?-1:n.cos(t[c]+e),_[l][c][1]=0==l?n.cos(t[c]):_[0][c][1],_[l][c][2]=t[c]-e<0?1:n.cos(t[c]-e)}let f=new s(12+3*d);for(let e=0;e<12;e++)f.push(11-e,0);for(;f.size()>0;){let t=f.ptop(),i=f.otop();f.pop();let s=this.bn[i].pix2vec(t),n=3;for(let t=0;t<a&&n>0;++t){let r=s.dot(e[t]);for(let e=0;e<n;++e)r<_[i][t][e]&&(n=e)}n>0&&this.check_pixel(i,d,n,o,t,f,r)}return o}ilog2(e){let t=Math.max(e,1);return 31-Math.clz32(t)}cosdist_zphi(e,t,i,r){return e*i+n.cos(t-r)*Math.sqrt((1-e*e)*(1-i*i))}check_pixel(e,t,i,r,s,a,o){if(0!=i)if(e<this.order)if(i>=3){let t=2*(this.order-e);r.append1(s<<t,s+1<<t)}else for(let t=0;t<4;++t)a.push(4*s+3-t,e+1);else if(e>this.order)if(i>=2)r.append(s>>>2*(e-this.order)),a.popToMark();else if(e<t)for(let t=0;t<4;++t)a.push(4*s+3-t,e+1);else r.append(s>>>2*(e-this.order)),a.popToMark();else if(i>=2)r.append(s);else if(o)if(this.order<t){a.mark();for(let t=0;t<4;++t)a.push(4*s+3-t,e+1)}else r.append(s)}maxPixrad(){let e=new o(2/3,Math.PI/this.nl4),t=this.convertZphi2xyz(e),i=new h(t[0],t[1],t[2]),r=1-1/this.nside;r*=r;let s=new o(1-r/3,0),a=this.convertZphi2xyz(s),n=new h(a[0],a[1],a[2]);return i.angle(n)}convertZphi2xyz(e){let t=Math.sqrt((1-e.z)*(1+e.z));return[t*n.cos(e.phi),t*n.sin(e.phi),e.z]}queryDiscInclusive(e,t,i){this.computeBn();let r=0!=i,a=new u;if(t>=Math.PI)return a.append1(0,this.npix),a;let o=0;r&&(i&i-1&&console.error("oversampling factor must be a power of 2"),o=this.ilog2(i));let l=Math.min(this.order_max,this.order+o),c=h.pointing2Vec3(e),d=new Array(l+1),_=new Array(l+1),f=n.cos(t),g=n.sin(t);for(let e=0;e<=l;e++){let i=this.mpr[e],r=this.cmpr[e],s=this.smpr[e];d[e]=t+i>Math.PI?-1:f*r-g*s,_[e]=t-i<0?1:f*r+g*s}let p=new s(12+3*l);for(let e=0;e<12;e++)p.push(11-e,0);for(;p.size()>0;){let t=p.ptop(),i=p.otop();p.pop();let s=this.bn[i].pix2zphi(t),o=this.cosdist_zphi(c.z,e.phi,s.z,s.phi);if(o>d[i]){let e=o<f?1:o<=_[i]?2:3;this.check_pixel(i,l,e,a,t,p,r)}}return a}}},1229:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=t.Source=t.WMTSAdapter=t.XYZMap=t.HiPS=t.createColorMapFromSamples=t.COLOR_MAP_SAMPLE_COUNT=t.ColorMaps=t.GeoJSONParser=t.CoordsType=t.FoVUtils=t.CartesianOpts=t.PointInitOpts=t.AstroOpts=t.SphericalOpts=t.Point=t.ColumnType=t.MetadataInit=t.MetadataColumn=t.MetadataManager=t.TerraFootprintSetGL=t.TerraPointSetGL=t.CatalogueGL=t.FootprintSetGL=t.HoveredFootprintDetail=t.SphereFoV=t.FoV=t.HiPSDescriptor=t.AstroViewer=void 0;var s=i(772);Object.defineProperty(t,"AstroViewer",{enumerable:!0,get:function(){return s.AstroViewer}});var a=i(5087);Object.defineProperty(t,"HiPSDescriptor",{enumerable:!0,get:function(){return a.HiPSDescriptor}});var o=i(5803);Object.defineProperty(t,"FoV",{enumerable:!0,get:function(){return o.SphereFoV}});var n=i(5803);Object.defineProperty(t,"SphereFoV",{enumerable:!0,get:function(){return n.SphereFoV}});var h=i(592);Object.defineProperty(t,"HoveredFootprintDetail",{enumerable:!0,get:function(){return h.HoveredFootprintDetail}}),Object.defineProperty(t,"FootprintSetGL",{enumerable:!0,get:function(){return h.FootprintSetGL}});var l=i(1232);Object.defineProperty(t,"CatalogueGL",{enumerable:!0,get:function(){return l.CatalogueGL}});var c=i(5781);Object.defineProperty(t,"TerraPointSetGL",{enumerable:!0,get:function(){return c.TerraPointSetGL}});var u=i(9022);Object.defineProperty(t,"TerraFootprintSetGL",{enumerable:!0,get:function(){return u.TerraFootprintSetGL}});var d=i(5403);Object.defineProperty(t,"MetadataManager",{enumerable:!0,get:function(){return d.MetadataManager}});var _=i(1072);Object.defineProperty(t,"MetadataColumn",{enumerable:!0,get:function(){return _.MetadataColumn}}),Object.defineProperty(t,"MetadataInit",{enumerable:!0,get:function(){return _.MetadataInit}}),Object.defineProperty(t,"ColumnType",{enumerable:!0,get:function(){return _.ColumnType}});var f=i(6553);Object.defineProperty(t,"Point",{enumerable:!0,get:function(){return f.Point}}),Object.defineProperty(t,"SphericalOpts",{enumerable:!0,get:function(){return f.SphericalOpts}}),Object.defineProperty(t,"AstroOpts",{enumerable:!0,get:function(){return f.AstroOpts}}),Object.defineProperty(t,"PointInitOpts",{enumerable:!0,get:function(){return f.PointInitOpts}}),Object.defineProperty(t,"CartesianOpts",{enumerable:!0,get:function(){return f.CartesianOpts}});var g=i(8083);Object.defineProperty(t,"FoVUtils",{enumerable:!0,get:function(){return g.FoVUtils}});var p=i(8145);Object.defineProperty(t,"CoordsType",{enumerable:!0,get:function(){return p.CoordsType}});var m=i(8755);Object.defineProperty(t,"GeoJSONParser",{enumerable:!0,get:function(){return r(m).default}});var x=i(619);Object.defineProperty(t,"ColorMaps",{enumerable:!0,get:function(){return x.ColorMaps}}),Object.defineProperty(t,"COLOR_MAP_SAMPLE_COUNT",{enumerable:!0,get:function(){return x.COLOR_MAP_SAMPLE_COUNT}}),Object.defineProperty(t,"createColorMapFromSamples",{enumerable:!0,get:function(){return x.createColorMapFromSamples}});var M=i(3726);Object.defineProperty(t,"HiPS",{enumerable:!0,get:function(){return M.HiPS}});var v=i(1741);Object.defineProperty(t,"XYZMap",{enumerable:!0,get:function(){return v.XYZMap}});var b=i(3956);Object.defineProperty(t,"WMTSAdapter",{enumerable:!0,get:function(){return b.WMTSAdapter}});var S=i(146);Object.defineProperty(t,"Source",{enumerable:!0,get:function(){return S.Source}});var P=i(2475);Object.defineProperty(t,"Footprint",{enumerable:!0,get:function(){return P.Footprint}}),console.log("astroviewer UMD loaded")},1232:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueGL=void 0;const r=i(146),s=i(6553),a=i(8145),o=i(7930),n=i(3559),h=i(5403);class l{_kind="CatalogueGL";static ELEM_SIZE=6;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;static STANDARD_SHAPE_SIZE=10;static STANDARD_SHAPE_HUE=3;_ready;_name;_description;_sources;vertexCataloguePositionBuffer=null;vertexhoveredCataloguePositionBuffer=null;vertexCataloguePosition;_bufferInitialised=!1;_webgl;hoveredIndexes;selectedIndexes;extHoveredIndexes;_oldMouseCoords;_metadataManager;_isVisible=!0;_shapeColor="#8F00FF";_healpixDensityMap;_providerUrl;_catalogueShaderProgram;_visibleTilesManager;constructor(e,t,i,r,s,a){this._webgl=s,this._ready=!1,this._visibleTilesManager=a,this.TYPE="SOURCE_CATALOGUE",this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=r,this._sources=[],this.vertexCataloguePosition=new Float32Array(0),this.hoveredIndexes=[],this.selectedIndexes=[],this.extHoveredIndexes=[],this._oldMouseCoords=null,this._healpixDensityMap=new Map,this._catalogueShaderProgram=new n.CatalogueShaderProgram(this._webgl),this._catalogueShaderProgram.shaderProgram,this._isVisible=!0}setIsVisible(e){this._isVisible=e}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get isVisible(){return this._isVisible}minMax(e){if(!this._sources.length)return{min:0,max:0};let t=this._sources[0].details[e];if(isNaN(Number(t)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain only number values`),{min:0,max:0};let i=t;for(const r of this._sources){const s=r.details[e];if(isNaN(Number(s)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain number only values`),{min:0,max:0};s<t&&(t=s),s>i&&(i=s)}return{min:Number(t),max:Number(i)}}get metadataManager(){return this._metadataManager}changeMetaRA(e){this._metadataManager.selectedRaColumn=e}changeMetaDec(e){this._metadataManager.selectedDecColumn=e}changeColor(e){this._shapeColor=e}changeMetaShapeSize(e){if(!this._webgl)return;if(e==h.MetadataManager.STANDARD_SIZE){this._metadataManager.resetShapeColumn();for(const e of this._sources){const t=l.STANDARD_SHAPE_SIZE;e.shapeSize=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedShapeColumn=e;const i=this._metadataManager.selectedShapeColumn?.index??-1;if(i<0)return void(t&&(this._metadataManager.selectedShapeColumn=t));const r=this.minMax(i);if(r.min!=r.max){for(const e of this._sources){const t=Number(e.getDetailByindex(i)),s=Number(r.min),a=Number(r.max),o=(t-s)/Math.max(1e-12,a-s)*12+8;e.shapeSize=o}this._bufferInitialised=!1}else console.warn(`${r} min and max are equals. No resizing will be applied.`)}changeMetaShapeHue(e){if(!this._webgl)return;if(e==h.MetadataManager.STANDARD_HUE){this._metadataManager.resetHueColumn();for(const e of this._sources){const t=l.STANDARD_SHAPE_HUE;e.brightnessFactor=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedHueColumn=e;const i=this._metadataManager.selectedHueColumn?.index??-1;if(i<0)return void(t&&(this._metadataManager.selectedHueColumn=t));const r=this.minMax(i);if(r.min!=r.max){for(const e of this._sources){const t=Number(e.getDetailByindex(i)),s=Number(r.min),a=Number(r.max),o=(t-s)/Math.max(1e-12,a-s);e.brightnessFactor=-(2*o-1)}this._bufferInitialised=!1}else console.warn(`${r} min and max are equals. No resizing will be applied.`)}get sources(){return this._sources}addSource(e){this._sources.push(e)}addSources(e,t){this._ready=!1,this._sources=[],this._metadataManager=new h.MetadataManager(t);const i=this._metadataManager.selectedRaColumn?.index??-1,o=this._metadataManager.selectedDecColumn?.index??-1;if(i<0||o<0)throw new Error(`(ra, dec) idx not defined (${i}, ${o}) `);for(let t=0;t<e.length;t++){const n=new s.Point({raDeg:e[t][i],decDeg:e[t][o]},a.CoordsType.ASTRO),h=new r.Source(n,e[t]);h.shapeSize=h.shapeSize??l.STANDARD_SHAPE_SIZE,h.brightnessFactor=3,this.addSource(h),this._metadataManager.selectedHueColumn?.name&&this.changeMetaShapeHue(this._metadataManager.selectedHueColumn.name),this._metadataManager.selectedShapeColumn?.name&&this.changeMetaShapeSize(this._metadataManager.selectedShapeColumn.name)}this._ready=!0,this._bufferInitialised=!1}clearSources(){this._sources=[],this.hoveredIndexes=[],this._healpixDensityMap.clear(),this.vertexCataloguePosition=new Float32Array(0)}sourceMatches(e,t){if(e===t)return!0;const i=e.point,r=t.point;if(i.raDeg!==r.raDeg||i.decDeg!==r.decDeg)return!1;if(e.details.length!==t.details.length)return!1;for(let i=0;i<e.details.length;i++)if(!Object.is(e.details[i],t.details[i]))return!1;return!0}findSourceIndex(e){const t=this._sources.indexOf(e);return t>=0?t:this._sources.findIndex(t=>this.sourceMatches(t,e))}extHighlightSource(e,t){const i=this.findSourceIndex(e);if(i<0)return;const r=i*l.ELEM_SIZE;if(t)this.hoveredIndexes.includes(i)||this.hoveredIndexes.push(i);else{if(r+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(i);e>=0&&(this.hoveredIndexes.splice(e,1),this.vertexCataloguePosition[r+3]=0,this.vertexCataloguePosition[r+4]=this._sources[i]?.shapeSize??l.STANDARD_SHAPE_SIZE)}}extAddSources2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findSourceIndex(e);if(t<0)return;const i=t*l.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(i+4>=this.vertexCataloguePosition.length)return;const e=this.selectedIndexes.indexOf(t);e>=0&&(this.selectedIndexes.splice(e,1),this.vertexCataloguePosition[i+3]=0,this.vertexCataloguePosition[i+4]=this._sources[t]?.shapeSize??l.STANDARD_SHAPE_SIZE)}else this.selectedIndexes.push(t)}initBuffer(){this.vertexCataloguePositionBuffer=this._webgl.createBuffer(),this.vertexhoveredCataloguePositionBuffer=this._webgl.createBuffer(),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer);const e=this._sources.length;this.vertexCataloguePosition=new Float32Array(e*l.ELEM_SIZE);let t=0;for(let i=0;i<e;i++){const e=this._sources[i],r=e.healpixPixel,s=this._healpixDensityMap.get(r);s?s.includes(i)||s.push(i):this._healpixDensityMap.set(r,[i]),this.vertexCataloguePosition[t+0]=e.point.x,this.vertexCataloguePosition[t+1]=e.point.y,this.vertexCataloguePosition[t+2]=e.point.z,this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=e.shapeSize??l.STANDARD_SHAPE_SIZE,this.vertexCataloguePosition[t+5]=e.brightnessFactor??0,t+=l.ELEM_SIZE}this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._bufferInitialised=!0}getSelectionRadius(){switch(this._visibleTilesManager.getVisibleOrder()){case 0:case 1:case 2:return.01;case 3:case 4:case 5:return.005;case 6:case 7:case 8:return.001;case 9:return 5e-4;default:return 1e-4}}checkClicking(e){if(null==e.x||null==e.y||null==e.z)return console.log("CatalogueGL.checkClicking: missing mouse coords"),[];const t=[],i=e.computeNpix();if(null!=i&&this._healpixDensityMap.has(i)){const r=this._healpixDensityMap.get(i),s=this.getSelectionRadius();for(let i=0;i<r.length;i++){const a=r[i],o=this._sources[a];if(!o)continue;const n=o.point.x-e.x,h=o.point.y-e.y,l=o.point.z-e.z;Math.sqrt(n*n+h*h+l*l)<=s&&t.push(a)}}return t}setSelectedIndexes(e){e.forEach(e=>{if(e<0||e>=this._sources.length)return;const t=e*l.ELEM_SIZE;t+4>=this.vertexCataloguePosition.length||(this.selectedIndexes.includes(e)?(this.selectedIndexes.splice(this.selectedIndexes.indexOf(e),1),this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??l.STANDARD_SHAPE_SIZE):(this.selectedIndexes.push(e),this.vertexCataloguePosition[t+3]=2,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??l.STANDARD_SHAPE_SIZE))})}getSourcesFromPointer(e){const t=this.checkClicking(e);if(!t.length)return{sources:[],pickedIndexes:[]};const i=[];return t.forEach(e=>{const t=this._sources[e];t&&i.push(t)}),i.length?{sources:i,pickedIndexes:t}:null}selectPrimarySourceFromClick(e){const t=this.getSourcesFromPointer(e),i=t?.pickedIndexes??[];if(this.setSelectedIndexes(i),!i.length)return{sources:[],selectionState:[]};const r=[],s=[];return i.forEach(e=>{const t=this._sources[e];if(!t)return;const i=this.selectedIndexes.includes(e);r.push({source:t,selected:i}),s.push(t)}),s.length?{sources:s,selectionState:r}:null}getPrimaryHoveredSource(){if(!this.hoveredIndexes.length)return null;const e=this.hoveredIndexes[0];return this._sources[e]??null}checkHovering(e){if(null==e.x||null==e.y||null==e.z)return console.log("CatalogueGL.checkHovering: missing mouse coords"),[];const t=[],i=e.computeNpix();if(null!=i&&this._healpixDensityMap.has(i)){const r=this._healpixDensityMap.get(i),s=this.getSelectionRadius();for(let i=0;i<r.length;i++){const a=r[i],o=this._sources[a];if(!o)continue;const n=o.point.x-e.x,h=o.point.y-e.y,l=o.point.z-e.z;Math.sqrt(n*n+h*h+l*l)<=s&&t.push(a)}}return t}draw(e,t,i,r){if(!this.isVisible)return;if(!this._ready)return;if(!i)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;this._catalogueShaderProgram.enableShaders(r,e,i),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.position,3,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.position),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.hovered,1,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,3*l.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.hovered),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.pointSize,1,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,4*l.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.pointSize),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.brightness,1,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,5*l.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.brightness);const s=(0,o.colorHex2RGB)(this._shapeColor);this._catalogueShaderProgram.locations.color&&this._webgl.uniform4f(this._catalogueShaderProgram.locations.color,s[0],s[1],s[2],1);for(let e=0;e<this.selectedIndexes.length;e++){const t=this.selectedIndexes[e],i=t*l.ELEM_SIZE;this.vertexCataloguePosition[i+3]=2,this.vertexCataloguePosition[i+4]=this._sources[t].shapeSize}for(let e=0;e<this.hoveredIndexes.length;e++){const t=this.hoveredIndexes[e]*l.ELEM_SIZE;this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=this._sources[this.hoveredIndexes[e]].shapeSize}null!=t&&t.xyz!==this._oldMouseCoords&&(this.hoveredIndexes=this.checkHovering(t));for(let e=0;e<this.hoveredIndexes.length;e++){const t=this.hoveredIndexes[e],i=t*l.ELEM_SIZE;this.vertexCataloguePosition[i+3]=1,this.vertexCataloguePosition[i+4]=this._sources[t].shapeSize}this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW);const a=this.vertexCataloguePosition.length/l.ELEM_SIZE;this._webgl.drawArrays(this._webgl.POINTS,0,a),this._oldMouseCoords=t.xyz}}t.CatalogueGL=l},1375:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZTile=void 0;const r=i(8819);t.XYZTile=class{_coord;_url;_webgl;_shaderProgram;_meshBuilder;_gpuMesh;_texture=null;_image;_ready=!1;_loading=!1;_aborted=!1;_failedUntil=0;_lastUsedAt=0;_createdAt=Date.now();constructor(e,t,i,s,a=new r.XYZMeshBuilder,o=16){this._coord=e,this._url=t,this._webgl=i,this._shaderProgram=s,this._meshBuilder=a;const n=this._meshBuilder.buildTileMesh(e,o);this._gpuMesh=this._meshBuilder.uploadMesh(n,this._webgl),this.initImage()}get coord(){return this._coord}get ready(){return this._ready}get loading(){return this._loading}get failedUntil(){return this._failedUntil}get lastUsedAt(){return this._lastUsedAt}get createdAt(){return this._createdAt}touch(){this._lastUsedAt=Date.now()}initImage(){if(this._loading||this._ready||this._aborted)return;const e=Date.now();if(this._failedUntil>e)return;this._loading=!0;const t=new Image;this._image=t,t.crossOrigin="anonymous",t.onload=()=>this.imageLoaded(),t.onerror=()=>{this._ready=!1,this._loading=!1,this._failedUntil=Date.now()+3e4},t.src=this._url}imageLoaded(){this._image&&!this._aborted&&(this.textureLoaded(this._image),this._loading=!1,this._failedUntil=0,this._ready=!0)}textureLoaded(e){const t=this._webgl;this._shaderProgram.enableProgram();const i=t.createTexture();if(!i)throw new Error(`Could not create XYZ texture for ${this.key}`);this._texture=i,t.activeTexture(t.TEXTURE0),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)}draw(e,t,i,r){return this.touch(),!(!this._ready||!this._texture||this._aborted||(this.drawWithGpuMesh(this._gpuMesh,e,t,i,r),0))}drawRemapped(e,t,i,r,s){return this.touch(),!(!this._ready||!this._texture||this._aborted||(this.drawWithGpuMesh(e,t,i,r,s),0))}dispose(){const e=this._webgl;this._texture&&(e.deleteTexture(this._texture),this._texture=null),this._gpuMesh.positionBuffer&&(e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh.positionBuffer=null),this._gpuMesh.uvBuffer&&(e.deleteBuffer(this._gpuMesh.uvBuffer),this._gpuMesh.uvBuffer=null),this._gpuMesh.indexBuffer&&(e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh.indexBuffer=null),this._image=void 0,this._ready=!1,this._loading=!1,this._aborted=!0}drawWithGpuMesh(e,t,i,r,s){if(!this._texture)return;const a=this._webgl;this._shaderProgram.enableShaders(t,i,r,s),a.bindBuffer(a.ARRAY_BUFFER,e.positionBuffer),a.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,a.FLOAT,!1,0,0),a.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),a.bindBuffer(a.ARRAY_BUFFER,e.uvBuffer),a.vertexAttribPointer(this._shaderProgram.locations.textureCoordAttribute,2,a.FLOAT,!1,0,0),a.enableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,this._texture),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,e.indexBuffer),a.drawElements(a.TRIANGLES,e.indexCount,e.indexType,0),a.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),a.disableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute)}get key(){return`${this._coord.z}/${this._coord.x}/${this._coord.y}`}}},1741:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMap=void 0;const r=i(4735),s=i(6937),a=i(8284),o=i(619),n=i(8124),h=i(149),l=i(2737),c=i(3174),u=i(8819);class d extends r.AbstractSkyEntity{_xyzShaderProgram;_descriptor;_visibleTilesManager;_tileBuffer;_meshBuilder;_baseurl;_zoom;_latLonGrid;_colorMapIdx=0;_colorMap=o.ColorMaps.native;constructor(e,t,i,r,o,c){super(e,t,i,r,o.name,c,!1),this._descriptor=o,this._xyzShaderProgram=new h.XYZShaderProgram(c),this._meshBuilder=new u.XYZMeshBuilder,this._tileBuffer=new l.XYZTileBuffer(1),this.initGL(c),this._latLonGrid=new n.LatLonGrid(e,t,i,r,"LatLonGrid",this._webgl),this._visibleTilesManager=new s.XYZVisibleTilesManager,this._baseurl=o.url,this.initShaders(),this._zoom=a.xyzFovHelper.getZoom(180)}changeColorMap(e){switch(this._colorMap=e,e.name){case"grayscale":this._colorMapIdx=1,this._colorMap=o.ColorMaps.grayscale;break;case"planck":this._colorMapIdx=2,this._colorMap=o.ColorMaps.planck;break;case"cmb":this._colorMapIdx=3,this._colorMap=o.ColorMaps.cmb;break;case"rainbow":this._colorMapIdx=4,this._colorMap=o.ColorMaps.rainbow;break;case"eosb":this._colorMapIdx=5,this._colorMap=o.ColorMaps.eosb;break;case"cubehelix":this._colorMapIdx=6,this._colorMap=o.ColorMaps.cubehelix;break;case"hot":this._colorMapIdx=7,this._colorMap=o.ColorMaps.hot;break;case"gray":this._colorMapIdx=8,this._colorMap=o.ColorMaps.gray;break;case"native":this._colorMapIdx=0,this._colorMap=o.ColorMaps.native;break;default:this._colorMapIdx=9,this._colorMap=e}}initShaders(){this._xyzShaderProgram.enableProgram()}isLonLatGridVisible(){return this._latLonGrid.isVisible()}toggleLonLatGrid(){return this._latLonGrid.toggleShowGrid()}getFoV(){return this._latLonGrid.getFoV()}refresh(e){const t=this._latLonGrid.refreshFoV(e);this._zoom=a.xyzFovHelper.getZoom(t)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const i=e.pMatrix;if(!i)return;this.refresh(e);const r=this.getModelMatrix();this._xyzShaderProgram.setRuntimeColorMap(this._colorMap);const s=this._visibleTilesManager.computeVisibleTiles(this._zoom,this,this._webgl,e.camera,e.pMatrix),a=s.visibleTiles,o=s.ancestorsMap,n=this._tileBuffer.ensureTiles(this.getTilesToEnsure(a,o),e=>this.createTile(e));this._tileBuffer.evictCached(this._descriptor.maxCachedTiles);for(const e of n){const a=this._tileBuffer.getActiveTile(e);if(!a||a.coord.z!==s.currentZoom)continue;if(a.draw(i,t,r,this._colorMapIdx))continue;const n=this.findBestAvailableAncestor(a.coord);n?.draw(s.currentZoom,[a.coord],o,i,t,r,this._colorMapIdx)}this._latLonGrid.draw(e)}createTile(e){return new c.XYZAnchestorTile(e,this.resolveTileUrl(e),this._webgl,this._xyzShaderProgram,this._meshBuilder,this._descriptor.segmentsPerSide)}getTilesToEnsure(e,t){const i=new Map;for(const t of e)i.set(this.tileKey(t),t);for(const e of t.values())i.set(this.tileKey(e),e);return Array.from(i.values())}findBestAvailableAncestor(e){for(let t=e.z-1;t>=0;t--){const i=e.z-t,r={z:t,x:e.x>>i,y:e.y>>i},s=this._tileBuffer.getAnyTile(this.tileKey(r));if(s?.ready)return s}return null}resolveTileUrl(e){const t=this._descriptor.urlResolver;if(t)return t(e);const i=2**e.z,r=this._descriptor.flipY?i-1-e.y:e.y,s=this._descriptor.subdomains,a=s.length>0?s[Math.abs(e.x+e.y+e.z)%s.length]:"";return this._baseurl.replace(/\{z\}/g,String(e.z)).replace(/\{x\}/g,String(e.x)).replace(/\{y\}/g,String(r)).replace(/\{s\}/g,a??"")}getDebugStats(){const e=Array.from(this._tileBuffer.activeTiles.values(),e=>e.tile),t=Array.from(this._tileBuffer.cachedTiles.values(),e=>e.tile),i=[...e,...t],r=this._visibleTilesManager.selection;return{cacheSize:this._tileBuffer.size,visibleTileCount:r.visibleTiles.length,currentTileCount:e.filter(e=>e.coord.z===r.currentZoom).length,fallbackTileCount:r.ancestorsMap.size,coreTileCount:r.visibleTiles.length,coverageTileCount:r.visibleTiles.length,readyTileCount:i.filter(e=>e.ready).length,loadingTileCount:i.filter(e=>e.loading).length,coolingDownTileCount:0,currentZoom:r.currentZoom,tileSelectionKey:r.key,isSettling:!1,coarseTileCount:r.ancestorsMap.size,hasPendingSelection:!1,pendingSelectionKey:null}}tileKey(e){return`${e.z}/${e.x}/${e.y}`}}t.XYZMap=d},1961:(e,t,i)=>{i.r(t),i.d(t,{glMatrix:()=>r,mat2:()=>s,mat2d:()=>a,mat3:()=>o,mat4:()=>n,quat:()=>c,quat2:()=>u,vec2:()=>d,vec3:()=>h,vec4:()=>l});var r={};i.r(r),i.d(r,{ANGLE_ORDER:()=>p,ARRAY_TYPE:()=>f,EPSILON:()=>_,RANDOM:()=>g,equals:()=>P,round:()=>m,setMatrixArrayType:()=>x,toDegree:()=>S,toRadian:()=>b});var s={};i.r(s),i.d(s,{LDU:()=>G,add:()=>H,adjoint:()=>F,clone:()=>T,copy:()=>w,create:()=>y,determinant:()=>D,equals:()=>X,exactEquals:()=>k,frob:()=>U,fromRotation:()=>V,fromScaling:()=>N,fromValues:()=>A,identity:()=>C,invert:()=>I,mul:()=>j,multiply:()=>L,multiplyScalar:()=>q,multiplyScalarAndAdd:()=>Z,rotate:()=>B,scale:()=>O,set:()=>E,str:()=>z,sub:()=>W,subtract:()=>Y,transpose:()=>R});var a={};i.r(a),i.d(a,{add:()=>_e,clone:()=>K,copy:()=>Q,create:()=>$,determinant:()=>re,equals:()=>xe,exactEquals:()=>me,frob:()=>de,fromRotation:()=>he,fromScaling:()=>le,fromTranslation:()=>ce,fromValues:()=>ee,identity:()=>J,invert:()=>ie,mul:()=>Me,multiply:()=>se,multiplyScalar:()=>ge,multiplyScalarAndAdd:()=>pe,rotate:()=>ae,scale:()=>oe,set:()=>te,str:()=>ue,sub:()=>ve,subtract:()=>fe,translate:()=>ne});var o={};i.r(o),i.d(o,{add:()=>Xe,adjoint:()=>Re,clone:()=>Pe,copy:()=>ye,create:()=>be,determinant:()=>Ie,equals:()=>$e,exactEquals:()=>We,frob:()=>ke,fromMat2d:()=>ze,fromMat4:()=>Se,fromQuat:()=>Ue,fromRotation:()=>Ve,fromScaling:()=>Ne,fromTranslation:()=>Oe,fromValues:()=>Te,identity:()=>Ce,invert:()=>Ee,mul:()=>Ke,multiply:()=>Fe,multiplyScalar:()=>Ze,multiplyScalarAndAdd:()=>je,normalFromMat4:()=>Ge,projection:()=>He,rotate:()=>Le,scale:()=>Be,set:()=>we,str:()=>Ye,sub:()=>Qe,subtract:()=>qe,translate:()=>De,transpose:()=>Ae});var n={};i.r(n),i.d(n,{add:()=>Yt,adjoint:()=>nt,clone:()=>et,copy:()=>tt,create:()=>Je,decompose:()=>Ct,determinant:()=>ht,equals:()=>jt,exactEquals:()=>Zt,frob:()=>Ht,fromQuat:()=>Rt,fromQuat2:()=>Pt,fromRotation:()=>xt,fromRotationTranslation:()=>St,fromRotationTranslationScale:()=>At,fromRotationTranslationScaleOrigin:()=>Et,fromScaling:()=>mt,fromTranslation:()=>pt,fromValues:()=>it,fromXRotation:()=>Mt,fromYRotation:()=>vt,fromZRotation:()=>bt,frustum:()=>It,getRotation:()=>wt,getScaling:()=>Tt,getTranslation:()=>yt,identity:()=>st,invert:()=>ot,lookAt:()=>zt,mul:()=>Wt,multiply:()=>lt,multiplyScalar:()=>Xt,multiplyScalarAndAdd:()=>qt,ortho:()=>Vt,orthoNO:()=>Ot,orthoZO:()=>Nt,perspective:()=>Dt,perspectiveFromFieldOfView:()=>Bt,perspectiveNO:()=>Ft,perspectiveZO:()=>Lt,rotate:()=>dt,rotateX:()=>_t,rotateY:()=>ft,rotateZ:()=>gt,scale:()=>ut,set:()=>rt,str:()=>Gt,sub:()=>$t,subtract:()=>kt,targetTo:()=>Ut,translate:()=>ct,transpose:()=>at});var h={};i.r(h),i.d(h,{add:()=>ri,angle:()=>Di,bezier:()=>Ti,ceil:()=>ni,clone:()=>Qt,copy:()=>ti,create:()=>Kt,cross:()=>bi,dist:()=>Hi,distance:()=>fi,div:()=>Gi,divide:()=>oi,dot:()=>vi,equals:()=>Vi,exactEquals:()=>Oi,floor:()=>hi,forEach:()=>qi,fromValues:()=>ei,hermite:()=>yi,inverse:()=>xi,len:()=>ki,length:()=>Jt,lerp:()=>Si,max:()=>ci,min:()=>li,mul:()=>Ui,multiply:()=>ai,negate:()=>mi,normalize:()=>Mi,random:()=>wi,rotateX:()=>Ri,rotateY:()=>Ii,rotateZ:()=>Fi,round:()=>ui,scale:()=>di,scaleAndAdd:()=>_i,set:()=>ii,slerp:()=>Pi,sqrDist:()=>Yi,sqrLen:()=>Xi,squaredDistance:()=>gi,squaredLength:()=>pi,str:()=>Bi,sub:()=>zi,subtract:()=>si,transformMat3:()=>Ai,transformMat4:()=>Ci,transformQuat:()=>Ei,zero:()=>Li});var l={};i.r(l),i.d(l,{add:()=>Qi,ceil:()=>ir,clone:()=>ji,copy:()=>$i,create:()=>Zi,cross:()=>mr,dist:()=>Er,distance:()=>lr,div:()=>Ar,divide:()=>tr,dot:()=>pr,equals:()=>Tr,exactEquals:()=>yr,floor:()=>rr,forEach:()=>Dr,fromValues:()=>Wi,inverse:()=>fr,len:()=>Ir,length:()=>ur,lerp:()=>xr,max:()=>ar,min:()=>sr,mul:()=>Cr,multiply:()=>er,negate:()=>_r,normalize:()=>gr,random:()=>Mr,round:()=>or,scale:()=>nr,scaleAndAdd:()=>hr,set:()=>Ki,sqrDist:()=>Rr,sqrLen:()=>Fr,squaredDistance:()=>cr,squaredLength:()=>dr,str:()=>Pr,sub:()=>wr,subtract:()=>Ji,transformMat4:()=>vr,transformQuat:()=>br,zero:()=>Sr});var c={};i.r(c),i.d(c,{add:()=>ss,calculateW:()=>Yr,clone:()=>es,conjugate:()=>$r,copy:()=>is,create:()=>Lr,dot:()=>ns,equals:()=>gs,exactEquals:()=>fs,exp:()=>kr,fromEuler:()=>Qr,fromMat3:()=>Kr,fromValues:()=>ts,getAngle:()=>Nr,getAxisAngle:()=>Vr,identity:()=>Br,invert:()=>Wr,len:()=>cs,length:()=>ls,lerp:()=>hs,ln:()=>Xr,mul:()=>as,multiply:()=>zr,normalize:()=>_s,pow:()=>qr,random:()=>jr,rotateX:()=>Ur,rotateY:()=>Gr,rotateZ:()=>Hr,rotationTo:()=>Ss,scale:()=>os,set:()=>rs,setAxes:()=>ys,setAxisAngle:()=>Or,slerp:()=>Zr,sqlerp:()=>Ps,sqrLen:()=>ds,squaredLength:()=>us,str:()=>Jr});var u={};i.r(u),i.d(u,{add:()=>js,clone:()=>ws,conjugate:()=>ta,copy:()=>Ds,create:()=>Ts,dot:()=>Qs,equals:()=>la,exactEquals:()=>ha,fromMat4:()=>Fs,fromRotation:()=>Is,fromRotationTranslation:()=>Es,fromRotationTranslationValues:()=>As,fromTranslation:()=>Rs,fromValues:()=>Cs,getDual:()=>Vs,getReal:()=>Os,getTranslation:()=>Us,identity:()=>Ls,invert:()=>ea,len:()=>ra,length:()=>ia,lerp:()=>Js,mul:()=>$s,multiply:()=>Ws,normalize:()=>oa,rotateAroundAxis:()=>Zs,rotateByQuatAppend:()=>Xs,rotateByQuatPrepend:()=>qs,rotateX:()=>Hs,rotateY:()=>Ys,rotateZ:()=>ks,scale:()=>Ks,set:()=>Bs,setDual:()=>zs,setReal:()=>Ns,sqrLen:()=>aa,squaredLength:()=>sa,str:()=>na,translate:()=>Gs});var d={};i.r(d),i.d(d,{add:()=>ga,angle:()=>Ha,ceil:()=>Ma,clone:()=>ua,copy:()=>_a,create:()=>ca,cross:()=>La,dist:()=>Qa,distance:()=>wa,div:()=>Ka,divide:()=>xa,dot:()=>Da,equals:()=>Za,exactEquals:()=>qa,floor:()=>va,forEach:()=>to,fromValues:()=>da,inverse:()=>Ia,len:()=>ja,length:()=>Aa,lerp:()=>Ba,max:()=>Sa,min:()=>ba,mul:()=>$a,multiply:()=>ma,negate:()=>Ra,normalize:()=>Fa,random:()=>Oa,rotate:()=>Ga,round:()=>Pa,scale:()=>ya,scaleAndAdd:()=>Ta,set:()=>fa,signedAngle:()=>Ya,sqrDist:()=>Ja,sqrLen:()=>eo,squaredDistance:()=>Ca,squaredLength:()=>Ea,str:()=>Xa,sub:()=>Wa,subtract:()=>pa,transformMat2:()=>Va,transformMat2d:()=>Na,transformMat3:()=>za,transformMat4:()=>Ua,zero:()=>ka});var _=1e-6,f="undefined"!=typeof Float32Array?Float32Array:Array,g=Math.random,p="zyx";function m(e){return e>=0?Math.round(e):e%.5==0?Math.floor(e):Math.round(e)}function x(e){f=e}var M=Math.PI/180,v=180/Math.PI;function b(e){return e*M}function S(e){return e*v}function P(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_;return Math.abs(e-t)<=i*Math.max(1,Math.abs(e),Math.abs(t))}function y(){var e=new f(4);return f!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function T(e){var t=new f(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function w(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function C(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function A(e,t,i,r){var s=new f(4);return s[0]=e,s[1]=t,s[2]=i,s[3]=r,s}function E(e,t,i,r,s){return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e}function R(e,t){if(e===t){var i=t[1];e[1]=t[2],e[2]=i}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e}function I(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=i*a-s*r;return o?(o=1/o,e[0]=a*o,e[1]=-r*o,e[2]=-s*o,e[3]=i*o,e):null}function F(e,t){var i=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=i,e}function D(e){return e[0]*e[3]-e[2]*e[1]}function L(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=i[0],h=i[1],l=i[2],c=i[3];return e[0]=r*n+a*h,e[1]=s*n+o*h,e[2]=r*l+a*c,e[3]=s*l+o*c,e}function B(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(i),h=Math.cos(i);return e[0]=r*h+a*n,e[1]=s*h+o*n,e[2]=r*-n+a*h,e[3]=s*-n+o*h,e}function O(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=i[0],h=i[1];return e[0]=r*n,e[1]=s*n,e[2]=a*h,e[3]=o*h,e}function V(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=-i,e[3]=r,e}function N(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e}function z(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function U(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3])}function G(e,t,i,r){return e[2]=r[2]/r[0],i[0]=r[0],i[1]=r[1],i[3]=r[3]-e[2]*i[1],[e,t,i]}function H(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e}function Y(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e}function k(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function X(e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=t[0],n=t[1],h=t[2],l=t[3];return Math.abs(i-o)<=_*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-n)<=_*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(s-h)<=_*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(a-l)<=_*Math.max(1,Math.abs(a),Math.abs(l))}function q(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function Z(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e}var j=L,W=Y;function $(){var e=new f(6);return f!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e}function K(e){var t=new f(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t}function Q(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function J(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e}function ee(e,t,i,r,s,a){var o=new f(6);return o[0]=e,o[1]=t,o[2]=i,o[3]=r,o[4]=s,o[5]=a,o}function te(e,t,i,r,s,a,o){return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e[4]=a,e[5]=o,e}function ie(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=i*a-r*s;return h?(h=1/h,e[0]=a*h,e[1]=-r*h,e[2]=-s*h,e[3]=i*h,e[4]=(s*n-a*o)*h,e[5]=(r*o-i*n)*h,e):null}function re(e){return e[0]*e[3]-e[1]*e[2]}function se(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=i[0],c=i[1],u=i[2],d=i[3],_=i[4],f=i[5];return e[0]=r*l+a*c,e[1]=s*l+o*c,e[2]=r*u+a*d,e[3]=s*u+o*d,e[4]=r*_+a*f+n,e[5]=s*_+o*f+h,e}function ae(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=Math.sin(i),c=Math.cos(i);return e[0]=r*c+a*l,e[1]=s*c+o*l,e[2]=r*-l+a*c,e[3]=s*-l+o*c,e[4]=n,e[5]=h,e}function oe(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=i[0],c=i[1];return e[0]=r*l,e[1]=s*l,e[2]=a*c,e[3]=o*c,e[4]=n,e[5]=h,e}function ne(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=i[0],c=i[1];return e[0]=r,e[1]=s,e[2]=a,e[3]=o,e[4]=r*l+a*c+n,e[5]=s*l+o*c+h,e}function he(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=-i,e[3]=r,e[4]=0,e[5]=0,e}function le(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e}function ce(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e}function ue(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"}function de(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+1)}function _e(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e}function fe(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e}function ge(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e}function pe(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e}function me(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]}function xe(e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=t[0],l=t[1],c=t[2],u=t[3],d=t[4],f=t[5];return Math.abs(i-h)<=_*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(r-l)<=_*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(s-c)<=_*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-u)<=_*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(o-d)<=_*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(n-f)<=_*Math.max(1,Math.abs(n),Math.abs(f))}var Me=se,ve=fe;function be(){var e=new f(9);return f!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Se(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}function Pe(e){var t=new f(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function ye(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function Te(e,t,i,r,s,a,o,n,h){var l=new f(9);return l[0]=e,l[1]=t,l[2]=i,l[3]=r,l[4]=s,l[5]=a,l[6]=o,l[7]=n,l[8]=h,l}function we(e,t,i,r,s,a,o,n,h,l){return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e[4]=a,e[5]=o,e[6]=n,e[7]=h,e[8]=l,e}function Ce(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function Ae(e,t){if(e===t){var i=t[1],r=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=r,e[7]=s}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function Ee(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=c*o-n*l,d=-c*a+n*h,_=l*a-o*h,f=i*u+r*d+s*_;return f?(f=1/f,e[0]=u*f,e[1]=(-c*r+s*l)*f,e[2]=(n*r-s*o)*f,e[3]=d*f,e[4]=(c*i-s*h)*f,e[5]=(-n*i+s*a)*f,e[6]=_*f,e[7]=(-l*i+r*h)*f,e[8]=(o*i-r*a)*f,e):null}function Re(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8];return e[0]=o*c-n*l,e[1]=s*l-r*c,e[2]=r*n-s*o,e[3]=n*h-a*c,e[4]=i*c-s*h,e[5]=s*a-i*n,e[6]=a*l-o*h,e[7]=r*h-i*l,e[8]=i*o-r*a,e}function Ie(e){var t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],n=e[6],h=e[7],l=e[8];return t*(l*a-o*h)+i*(-l*s+o*n)+r*(h*s-a*n)}function Fe(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=i[0],_=i[1],f=i[2],g=i[3],p=i[4],m=i[5],x=i[6],M=i[7],v=i[8];return e[0]=d*r+_*o+f*l,e[1]=d*s+_*n+f*c,e[2]=d*a+_*h+f*u,e[3]=g*r+p*o+m*l,e[4]=g*s+p*n+m*c,e[5]=g*a+p*h+m*u,e[6]=x*r+M*o+v*l,e[7]=x*s+M*n+v*c,e[8]=x*a+M*h+v*u,e}function De(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=i[0],_=i[1];return e[0]=r,e[1]=s,e[2]=a,e[3]=o,e[4]=n,e[5]=h,e[6]=d*r+_*o+l,e[7]=d*s+_*n+c,e[8]=d*a+_*h+u,e}function Le(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=Math.sin(i),_=Math.cos(i);return e[0]=_*r+d*o,e[1]=_*s+d*n,e[2]=_*a+d*h,e[3]=_*o-d*r,e[4]=_*n-d*s,e[5]=_*h-d*a,e[6]=l,e[7]=c,e[8]=u,e}function Be(e,t,i){var r=i[0],s=i[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function Oe(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e}function Ve(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function Ne(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function ze(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e}function Ue(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=i+i,n=r+r,h=s+s,l=i*o,c=r*o,u=r*n,d=s*o,_=s*n,f=s*h,g=a*o,p=a*n,m=a*h;return e[0]=1-u-f,e[3]=c-m,e[6]=d+p,e[1]=c+m,e[4]=1-l-f,e[7]=_-g,e[2]=d-p,e[5]=_+g,e[8]=1-l-u,e}function Ge(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],f=t[12],g=t[13],p=t[14],m=t[15],x=i*n-r*o,M=i*h-s*o,v=i*l-a*o,b=r*h-s*n,S=r*l-a*n,P=s*l-a*h,y=c*g-u*f,T=c*p-d*f,w=c*m-_*f,C=u*p-d*g,A=u*m-_*g,E=d*m-_*p,R=x*E-M*A+v*C+b*w-S*T+P*y;return R?(R=1/R,e[0]=(n*E-h*A+l*C)*R,e[1]=(h*w-o*E-l*T)*R,e[2]=(o*A-n*w+l*y)*R,e[3]=(s*A-r*E-a*C)*R,e[4]=(i*E-s*w+a*T)*R,e[5]=(r*w-i*A-a*y)*R,e[6]=(g*P-p*S+m*b)*R,e[7]=(p*v-f*P-m*M)*R,e[8]=(f*S-g*v+m*x)*R,e):null}function He(e,t,i){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/i,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e}function Ye(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"}function ke(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8])}function Xe(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e[8]=t[8]+i[8],e}function qe(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e[6]=t[6]-i[6],e[7]=t[7]-i[7],e[8]=t[8]-i[8],e}function Ze(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*i,e}function je(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e[6]=t[6]+i[6]*r,e[7]=t[7]+i[7]*r,e[8]=t[8]+i[8]*r,e}function We(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]}function $e(e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=e[6],l=e[7],c=e[8],u=t[0],d=t[1],f=t[2],g=t[3],p=t[4],m=t[5],x=t[6],M=t[7],v=t[8];return Math.abs(i-u)<=_*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(r-d)<=_*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(s-f)<=_*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(a-g)<=_*Math.max(1,Math.abs(a),Math.abs(g))&&Math.abs(o-p)<=_*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(n-m)<=_*Math.max(1,Math.abs(n),Math.abs(m))&&Math.abs(h-x)<=_*Math.max(1,Math.abs(h),Math.abs(x))&&Math.abs(l-M)<=_*Math.max(1,Math.abs(l),Math.abs(M))&&Math.abs(c-v)<=_*Math.max(1,Math.abs(c),Math.abs(v))}var Ke=Fe,Qe=qe;function Je(){var e=new f(16);return f!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function et(e){var t=new f(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function tt(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function it(e,t,i,r,s,a,o,n,h,l,c,u,d,_,g,p){var m=new f(16);return m[0]=e,m[1]=t,m[2]=i,m[3]=r,m[4]=s,m[5]=a,m[6]=o,m[7]=n,m[8]=h,m[9]=l,m[10]=c,m[11]=u,m[12]=d,m[13]=_,m[14]=g,m[15]=p,m}function rt(e,t,i,r,s,a,o,n,h,l,c,u,d,_,f,g,p){return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e[4]=a,e[5]=o,e[6]=n,e[7]=h,e[8]=l,e[9]=c,e[10]=u,e[11]=d,e[12]=_,e[13]=f,e[14]=g,e[15]=p,e}function st(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function at(e,t){if(e===t){var i=t[1],r=t[2],s=t[3],a=t[6],o=t[7],n=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=i,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=a,e[11]=t[14],e[12]=s,e[13]=o,e[14]=n}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function ot(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],f=t[12],g=t[13],p=t[14],m=t[15],x=i*n-r*o,M=i*h-s*o,v=i*l-a*o,b=r*h-s*n,S=r*l-a*n,P=s*l-a*h,y=c*g-u*f,T=c*p-d*f,w=c*m-_*f,C=u*p-d*g,A=u*m-_*g,E=d*m-_*p,R=x*E-M*A+v*C+b*w-S*T+P*y;return R?(R=1/R,e[0]=(n*E-h*A+l*C)*R,e[1]=(s*A-r*E-a*C)*R,e[2]=(g*P-p*S+m*b)*R,e[3]=(d*S-u*P-_*b)*R,e[4]=(h*w-o*E-l*T)*R,e[5]=(i*E-s*w+a*T)*R,e[6]=(p*v-f*P-m*M)*R,e[7]=(c*P-d*v+_*M)*R,e[8]=(o*A-n*w+l*y)*R,e[9]=(r*w-i*A-a*y)*R,e[10]=(f*S-g*v+m*x)*R,e[11]=(u*v-c*S-_*x)*R,e[12]=(n*T-o*C-h*y)*R,e[13]=(i*C-r*T+s*y)*R,e[14]=(g*M-f*b-p*x)*R,e[15]=(c*b-u*M+d*x)*R,e):null}function nt(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],f=t[12],g=t[13],p=t[14],m=t[15],x=i*n-r*o,M=i*h-s*o,v=i*l-a*o,b=r*h-s*n,S=r*l-a*n,P=s*l-a*h,y=c*g-u*f,T=c*p-d*f,w=c*m-_*f,C=u*p-d*g,A=u*m-_*g,E=d*m-_*p;return e[0]=n*E-h*A+l*C,e[1]=s*A-r*E-a*C,e[2]=g*P-p*S+m*b,e[3]=d*S-u*P-_*b,e[4]=h*w-o*E-l*T,e[5]=i*E-s*w+a*T,e[6]=p*v-f*P-m*M,e[7]=c*P-d*v+_*M,e[8]=o*A-n*w+l*y,e[9]=r*w-i*A-a*y,e[10]=f*S-g*v+m*x,e[11]=u*v-c*S-_*x,e[12]=n*T-o*C-h*y,e[13]=i*C-r*T+s*y,e[14]=g*M-f*b-p*x,e[15]=c*b-u*M+d*x,e}function ht(e){var t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],n=e[6],h=e[7],l=e[8],c=e[9],u=e[10],d=e[11],_=e[12],f=e[13],g=e[14],p=t*o-i*a,m=t*n-r*a,x=i*n-r*o,M=l*f-c*_,v=l*g-u*_,b=c*g-u*f;return h*(t*b-i*v+r*M)-s*(a*b-o*v+n*M)+e[15]*(l*x-c*m+u*p)-d*(_*x-f*m+g*p)}function lt(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=t[9],_=t[10],f=t[11],g=t[12],p=t[13],m=t[14],x=t[15],M=i[0],v=i[1],b=i[2],S=i[3];return e[0]=M*r+v*n+b*u+S*g,e[1]=M*s+v*h+b*d+S*p,e[2]=M*a+v*l+b*_+S*m,e[3]=M*o+v*c+b*f+S*x,M=i[4],v=i[5],b=i[6],S=i[7],e[4]=M*r+v*n+b*u+S*g,e[5]=M*s+v*h+b*d+S*p,e[6]=M*a+v*l+b*_+S*m,e[7]=M*o+v*c+b*f+S*x,M=i[8],v=i[9],b=i[10],S=i[11],e[8]=M*r+v*n+b*u+S*g,e[9]=M*s+v*h+b*d+S*p,e[10]=M*a+v*l+b*_+S*m,e[11]=M*o+v*c+b*f+S*x,M=i[12],v=i[13],b=i[14],S=i[15],e[12]=M*r+v*n+b*u+S*g,e[13]=M*s+v*h+b*d+S*p,e[14]=M*a+v*l+b*_+S*m,e[15]=M*o+v*c+b*f+S*x,e}function ct(e,t,i){var r,s,a,o,n,h,l,c,u,d,_,f,g=i[0],p=i[1],m=i[2];return t===e?(e[12]=t[0]*g+t[4]*p+t[8]*m+t[12],e[13]=t[1]*g+t[5]*p+t[9]*m+t[13],e[14]=t[2]*g+t[6]*p+t[10]*m+t[14],e[15]=t[3]*g+t[7]*p+t[11]*m+t[15]):(r=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=t[9],_=t[10],f=t[11],e[0]=r,e[1]=s,e[2]=a,e[3]=o,e[4]=n,e[5]=h,e[6]=l,e[7]=c,e[8]=u,e[9]=d,e[10]=_,e[11]=f,e[12]=r*g+n*p+u*m+t[12],e[13]=s*g+h*p+d*m+t[13],e[14]=a*g+l*p+_*m+t[14],e[15]=o*g+c*p+f*m+t[15]),e}function ut(e,t,i){var r=i[0],s=i[1],a=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function dt(e,t,i,r){var s,a,o,n,h,l,c,u,d,f,g,p,m,x,M,v,b,S,P,y,T,w,C,A,E=r[0],R=r[1],I=r[2],F=Math.sqrt(E*E+R*R+I*I);return F<_?null:(E*=F=1/F,R*=F,I*=F,s=Math.sin(i),o=1-(a=Math.cos(i)),n=t[0],h=t[1],l=t[2],c=t[3],u=t[4],d=t[5],f=t[6],g=t[7],p=t[8],m=t[9],x=t[10],M=t[11],v=E*E*o+a,b=R*E*o+I*s,S=I*E*o-R*s,P=E*R*o-I*s,y=R*R*o+a,T=I*R*o+E*s,w=E*I*o+R*s,C=R*I*o-E*s,A=I*I*o+a,e[0]=n*v+u*b+p*S,e[1]=h*v+d*b+m*S,e[2]=l*v+f*b+x*S,e[3]=c*v+g*b+M*S,e[4]=n*P+u*y+p*T,e[5]=h*P+d*y+m*T,e[6]=l*P+f*y+x*T,e[7]=c*P+g*y+M*T,e[8]=n*w+u*C+p*A,e[9]=h*w+d*C+m*A,e[10]=l*w+f*C+x*A,e[11]=c*w+g*C+M*A,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function _t(e,t,i){var r=Math.sin(i),s=Math.cos(i),a=t[4],o=t[5],n=t[6],h=t[7],l=t[8],c=t[9],u=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=a*s+l*r,e[5]=o*s+c*r,e[6]=n*s+u*r,e[7]=h*s+d*r,e[8]=l*s-a*r,e[9]=c*s-o*r,e[10]=u*s-n*r,e[11]=d*s-h*r,e}function ft(e,t,i){var r=Math.sin(i),s=Math.cos(i),a=t[0],o=t[1],n=t[2],h=t[3],l=t[8],c=t[9],u=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*s-l*r,e[1]=o*s-c*r,e[2]=n*s-u*r,e[3]=h*s-d*r,e[8]=a*r+l*s,e[9]=o*r+c*s,e[10]=n*r+u*s,e[11]=h*r+d*s,e}function gt(e,t,i){var r=Math.sin(i),s=Math.cos(i),a=t[0],o=t[1],n=t[2],h=t[3],l=t[4],c=t[5],u=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*s+l*r,e[1]=o*s+c*r,e[2]=n*s+u*r,e[3]=h*s+d*r,e[4]=l*s-a*r,e[5]=c*s-o*r,e[6]=u*s-n*r,e[7]=d*s-h*r,e}function pt(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function mt(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function xt(e,t,i){var r,s,a,o=i[0],n=i[1],h=i[2],l=Math.sqrt(o*o+n*n+h*h);return l<_?null:(o*=l=1/l,n*=l,h*=l,r=Math.sin(t),a=1-(s=Math.cos(t)),e[0]=o*o*a+s,e[1]=n*o*a+h*r,e[2]=h*o*a-n*r,e[3]=0,e[4]=o*n*a-h*r,e[5]=n*n*a+s,e[6]=h*n*a+o*r,e[7]=0,e[8]=o*h*a+n*r,e[9]=n*h*a-o*r,e[10]=h*h*a+s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Mt(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r,e[6]=i,e[7]=0,e[8]=0,e[9]=-i,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function vt(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=0,e[2]=-i,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=i,e[9]=0,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function bt(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=0,e[4]=-i,e[5]=r,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function St(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=r+r,h=s+s,l=a+a,c=r*n,u=r*h,d=r*l,_=s*h,f=s*l,g=a*l,p=o*n,m=o*h,x=o*l;return e[0]=1-(_+g),e[1]=u+x,e[2]=d-m,e[3]=0,e[4]=u-x,e[5]=1-(c+g),e[6]=f+p,e[7]=0,e[8]=d+m,e[9]=f-p,e[10]=1-(c+_),e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}function Pt(e,t){var i=new f(3),r=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=r*r+s*s+a*a+o*o;return u>0?(i[0]=2*(n*o+c*r+h*a-l*s)/u,i[1]=2*(h*o+c*s+l*r-n*a)/u,i[2]=2*(l*o+c*a+n*s-h*r)/u):(i[0]=2*(n*o+c*r+h*a-l*s),i[1]=2*(h*o+c*s+l*r-n*a),i[2]=2*(l*o+c*a+n*s-h*r)),St(e,t,i),e}function yt(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Tt(e,t){var i=t[0],r=t[1],s=t[2],a=t[4],o=t[5],n=t[6],h=t[8],l=t[9],c=t[10];return e[0]=Math.sqrt(i*i+r*r+s*s),e[1]=Math.sqrt(a*a+o*o+n*n),e[2]=Math.sqrt(h*h+l*l+c*c),e}function wt(e,t){var i=new f(3);Tt(i,t);var r=1/i[0],s=1/i[1],a=1/i[2],o=t[0]*r,n=t[1]*s,h=t[2]*a,l=t[4]*r,c=t[5]*s,u=t[6]*a,d=t[8]*r,_=t[9]*s,g=t[10]*a,p=o+c+g,m=0;return p>0?(m=2*Math.sqrt(p+1),e[3]=.25*m,e[0]=(u-_)/m,e[1]=(d-h)/m,e[2]=(n-l)/m):o>c&&o>g?(m=2*Math.sqrt(1+o-c-g),e[3]=(u-_)/m,e[0]=.25*m,e[1]=(n+l)/m,e[2]=(d+h)/m):c>g?(m=2*Math.sqrt(1+c-o-g),e[3]=(d-h)/m,e[0]=(n+l)/m,e[1]=.25*m,e[2]=(u+_)/m):(m=2*Math.sqrt(1+g-o-c),e[3]=(n-l)/m,e[0]=(d+h)/m,e[1]=(u+_)/m,e[2]=.25*m),e}function Ct(e,t,i,r){t[0]=r[12],t[1]=r[13],t[2]=r[14];var s=r[0],a=r[1],o=r[2],n=r[4],h=r[5],l=r[6],c=r[8],u=r[9],d=r[10];i[0]=Math.sqrt(s*s+a*a+o*o),i[1]=Math.sqrt(n*n+h*h+l*l),i[2]=Math.sqrt(c*c+u*u+d*d);var _=1/i[0],f=1/i[1],g=1/i[2],p=s*_,m=a*f,x=o*g,M=n*_,v=h*f,b=l*g,S=c*_,P=u*f,y=d*g,T=p+v+y,w=0;return T>0?(w=2*Math.sqrt(T+1),e[3]=.25*w,e[0]=(b-P)/w,e[1]=(S-x)/w,e[2]=(m-M)/w):p>v&&p>y?(w=2*Math.sqrt(1+p-v-y),e[3]=(b-P)/w,e[0]=.25*w,e[1]=(m+M)/w,e[2]=(S+x)/w):v>y?(w=2*Math.sqrt(1+v-p-y),e[3]=(S-x)/w,e[0]=(m+M)/w,e[1]=.25*w,e[2]=(b+P)/w):(w=2*Math.sqrt(1+y-p-v),e[3]=(m-M)/w,e[0]=(S+x)/w,e[1]=(b+P)/w,e[2]=.25*w),e}function At(e,t,i,r){var s=t[0],a=t[1],o=t[2],n=t[3],h=s+s,l=a+a,c=o+o,u=s*h,d=s*l,_=s*c,f=a*l,g=a*c,p=o*c,m=n*h,x=n*l,M=n*c,v=r[0],b=r[1],S=r[2];return e[0]=(1-(f+p))*v,e[1]=(d+M)*v,e[2]=(_-x)*v,e[3]=0,e[4]=(d-M)*b,e[5]=(1-(u+p))*b,e[6]=(g+m)*b,e[7]=0,e[8]=(_+x)*S,e[9]=(g-m)*S,e[10]=(1-(u+f))*S,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}function Et(e,t,i,r,s){var a=t[0],o=t[1],n=t[2],h=t[3],l=a+a,c=o+o,u=n+n,d=a*l,_=a*c,f=a*u,g=o*c,p=o*u,m=n*u,x=h*l,M=h*c,v=h*u,b=r[0],S=r[1],P=r[2],y=s[0],T=s[1],w=s[2],C=(1-(g+m))*b,A=(_+v)*b,E=(f-M)*b,R=(_-v)*S,I=(1-(d+m))*S,F=(p+x)*S,D=(f+M)*P,L=(p-x)*P,B=(1-(d+g))*P;return e[0]=C,e[1]=A,e[2]=E,e[3]=0,e[4]=R,e[5]=I,e[6]=F,e[7]=0,e[8]=D,e[9]=L,e[10]=B,e[11]=0,e[12]=i[0]+y-(C*y+R*T+D*w),e[13]=i[1]+T-(A*y+I*T+L*w),e[14]=i[2]+w-(E*y+F*T+B*w),e[15]=1,e}function Rt(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=i+i,n=r+r,h=s+s,l=i*o,c=r*o,u=r*n,d=s*o,_=s*n,f=s*h,g=a*o,p=a*n,m=a*h;return e[0]=1-u-f,e[1]=c+m,e[2]=d-p,e[3]=0,e[4]=c-m,e[5]=1-l-f,e[6]=_+g,e[7]=0,e[8]=d+p,e[9]=_-g,e[10]=1-l-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function It(e,t,i,r,s,a,o){var n=1/(i-t),h=1/(s-r),l=1/(a-o);return e[0]=2*a*n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*h,e[6]=0,e[7]=0,e[8]=(i+t)*n,e[9]=(s+r)*h,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e}function Ft(e,t,i,r,s){var a=1/Math.tan(t/2);if(e[0]=a/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=s&&s!==1/0){var o=1/(r-s);e[10]=(s+r)*o,e[14]=2*s*r*o}else e[10]=-1,e[14]=-2*r;return e}var Dt=Ft;function Lt(e,t,i,r,s){var a=1/Math.tan(t/2);if(e[0]=a/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=s&&s!==1/0){var o=1/(r-s);e[10]=s*o,e[14]=s*r*o}else e[10]=-1,e[14]=-r;return e}function Bt(e,t,i,r){var s=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),n=Math.tan(t.rightDegrees*Math.PI/180),h=2/(o+n),l=2/(s+a);return e[0]=h,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-n)*h*.5,e[9]=(s-a)*l*.5,e[10]=r/(i-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*i/(i-r),e[15]=0,e}function Ot(e,t,i,r,s,a,o){var n=1/(t-i),h=1/(r-s),l=1/(a-o);return e[0]=-2*n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+i)*n,e[13]=(s+r)*h,e[14]=(o+a)*l,e[15]=1,e}var Vt=Ot;function Nt(e,t,i,r,s,a,o){var n=1/(t-i),h=1/(r-s),l=1/(a-o);return e[0]=-2*n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+i)*n,e[13]=(s+r)*h,e[14]=a*l,e[15]=1,e}function zt(e,t,i,r){var s,a,o,n,h,l,c,u,d,f,g=t[0],p=t[1],m=t[2],x=r[0],M=r[1],v=r[2],b=i[0],S=i[1],P=i[2];return Math.abs(g-b)<_&&Math.abs(p-S)<_&&Math.abs(m-P)<_?st(e):(c=g-b,u=p-S,d=m-P,s=M*(d*=f=1/Math.sqrt(c*c+u*u+d*d))-v*(u*=f),a=v*(c*=f)-x*d,o=x*u-M*c,(f=Math.sqrt(s*s+a*a+o*o))?(s*=f=1/f,a*=f,o*=f):(s=0,a=0,o=0),n=u*o-d*a,h=d*s-c*o,l=c*a-u*s,(f=Math.sqrt(n*n+h*h+l*l))?(n*=f=1/f,h*=f,l*=f):(n=0,h=0,l=0),e[0]=s,e[1]=n,e[2]=c,e[3]=0,e[4]=a,e[5]=h,e[6]=u,e[7]=0,e[8]=o,e[9]=l,e[10]=d,e[11]=0,e[12]=-(s*g+a*p+o*m),e[13]=-(n*g+h*p+l*m),e[14]=-(c*g+u*p+d*m),e[15]=1,e)}function Ut(e,t,i,r){var s=t[0],a=t[1],o=t[2],n=r[0],h=r[1],l=r[2],c=s-i[0],u=a-i[1],d=o-i[2],_=c*c+u*u+d*d;_>0&&(c*=_=1/Math.sqrt(_),u*=_,d*=_);var f=h*d-l*u,g=l*c-n*d,p=n*u-h*c;return(_=f*f+g*g+p*p)>0&&(f*=_=1/Math.sqrt(_),g*=_,p*=_),e[0]=f,e[1]=g,e[2]=p,e[3]=0,e[4]=u*p-d*g,e[5]=d*f-c*p,e[6]=c*g-u*f,e[7]=0,e[8]=c,e[9]=u,e[10]=d,e[11]=0,e[12]=s,e[13]=a,e[14]=o,e[15]=1,e}function Gt(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"}function Ht(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function Yt(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e[8]=t[8]+i[8],e[9]=t[9]+i[9],e[10]=t[10]+i[10],e[11]=t[11]+i[11],e[12]=t[12]+i[12],e[13]=t[13]+i[13],e[14]=t[14]+i[14],e[15]=t[15]+i[15],e}function kt(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e[6]=t[6]-i[6],e[7]=t[7]-i[7],e[8]=t[8]-i[8],e[9]=t[9]-i[9],e[10]=t[10]-i[10],e[11]=t[11]-i[11],e[12]=t[12]-i[12],e[13]=t[13]-i[13],e[14]=t[14]-i[14],e[15]=t[15]-i[15],e}function Xt(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12]*i,e[13]=t[13]*i,e[14]=t[14]*i,e[15]=t[15]*i,e}function qt(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e[6]=t[6]+i[6]*r,e[7]=t[7]+i[7]*r,e[8]=t[8]+i[8]*r,e[9]=t[9]+i[9]*r,e[10]=t[10]+i[10]*r,e[11]=t[11]+i[11]*r,e[12]=t[12]+i[12]*r,e[13]=t[13]+i[13]*r,e[14]=t[14]+i[14]*r,e[15]=t[15]+i[15]*r,e}function Zt(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function jt(e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=e[6],l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],g=e[12],p=e[13],m=e[14],x=e[15],M=t[0],v=t[1],b=t[2],S=t[3],P=t[4],y=t[5],T=t[6],w=t[7],C=t[8],A=t[9],E=t[10],R=t[11],I=t[12],F=t[13],D=t[14],L=t[15];return Math.abs(i-M)<=_*Math.max(1,Math.abs(i),Math.abs(M))&&Math.abs(r-v)<=_*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(s-b)<=_*Math.max(1,Math.abs(s),Math.abs(b))&&Math.abs(a-S)<=_*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(o-P)<=_*Math.max(1,Math.abs(o),Math.abs(P))&&Math.abs(n-y)<=_*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(h-T)<=_*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(l-w)<=_*Math.max(1,Math.abs(l),Math.abs(w))&&Math.abs(c-C)<=_*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(u-A)<=_*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(d-E)<=_*Math.max(1,Math.abs(d),Math.abs(E))&&Math.abs(f-R)<=_*Math.max(1,Math.abs(f),Math.abs(R))&&Math.abs(g-I)<=_*Math.max(1,Math.abs(g),Math.abs(I))&&Math.abs(p-F)<=_*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(m-D)<=_*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(x-L)<=_*Math.max(1,Math.abs(x),Math.abs(L))}var Wt=lt,$t=kt;function Kt(){var e=new f(3);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Qt(e){var t=new f(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Jt(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function ei(e,t,i){var r=new f(3);return r[0]=e,r[1]=t,r[2]=i,r}function ti(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ii(e,t,i,r){return e[0]=t,e[1]=i,e[2]=r,e}function ri(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function si(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function ai(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function oi(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e}function ni(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function hi(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function li(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e}function ci(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e}function ui(e,t){return e[0]=m(t[0]),e[1]=m(t[1]),e[2]=m(t[2]),e}function di(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function _i(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function fi(e,t){var i=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2];return Math.sqrt(i*i+r*r+s*s)}function gi(e,t){var i=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2];return i*i+r*r+s*s}function pi(e){var t=e[0],i=e[1],r=e[2];return t*t+i*i+r*r}function mi(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function xi(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function Mi(e,t){var i=t[0],r=t[1],s=t[2],a=i*i+r*r+s*s;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function vi(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function bi(e,t,i){var r=t[0],s=t[1],a=t[2],o=i[0],n=i[1],h=i[2];return e[0]=s*h-a*n,e[1]=a*o-r*h,e[2]=r*n-s*o,e}function Si(e,t,i,r){var s=t[0],a=t[1],o=t[2];return e[0]=s+r*(i[0]-s),e[1]=a+r*(i[1]-a),e[2]=o+r*(i[2]-o),e}function Pi(e,t,i,r){var s=Math.acos(Math.min(Math.max(vi(t,i),-1),1)),a=Math.sin(s),o=Math.sin((1-r)*s)/a,n=Math.sin(r*s)/a;return e[0]=o*t[0]+n*i[0],e[1]=o*t[1]+n*i[1],e[2]=o*t[2]+n*i[2],e}function yi(e,t,i,r,s,a){var o=a*a,n=o*(2*a-3)+1,h=o*(a-2)+a,l=o*(a-1),c=o*(3-2*a);return e[0]=t[0]*n+i[0]*h+r[0]*l+s[0]*c,e[1]=t[1]*n+i[1]*h+r[1]*l+s[1]*c,e[2]=t[2]*n+i[2]*h+r[2]*l+s[2]*c,e}function Ti(e,t,i,r,s,a){var o=1-a,n=o*o,h=a*a,l=n*o,c=3*a*n,u=3*h*o,d=h*a;return e[0]=t[0]*l+i[0]*c+r[0]*u+s[0]*d,e[1]=t[1]*l+i[1]*c+r[1]*u+s[1]*d,e[2]=t[2]*l+i[2]*c+r[2]*u+s[2]*d,e}function wi(e,t){t=void 0===t?1:t;var i=2*g()*Math.PI,r=2*g()-1,s=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(i)*s,e[1]=Math.sin(i)*s,e[2]=r*t,e}function Ci(e,t,i){var r=t[0],s=t[1],a=t[2],o=i[3]*r+i[7]*s+i[11]*a+i[15];return o=o||1,e[0]=(i[0]*r+i[4]*s+i[8]*a+i[12])/o,e[1]=(i[1]*r+i[5]*s+i[9]*a+i[13])/o,e[2]=(i[2]*r+i[6]*s+i[10]*a+i[14])/o,e}function Ai(e,t,i){var r=t[0],s=t[1],a=t[2];return e[0]=r*i[0]+s*i[3]+a*i[6],e[1]=r*i[1]+s*i[4]+a*i[7],e[2]=r*i[2]+s*i[5]+a*i[8],e}function Ei(e,t,i){var r=i[0],s=i[1],a=i[2],o=i[3],n=t[0],h=t[1],l=t[2],c=s*l-a*h,u=a*n-r*l,d=r*h-s*n;return c+=c,u+=u,d+=d,e[0]=n+o*c+s*d-a*u,e[1]=h+o*u+a*c-r*d,e[2]=l+o*d+r*u-s*c,e}function Ri(e,t,i,r){var s=[],a=[];return s[0]=t[0]-i[0],s[1]=t[1]-i[1],s[2]=t[2]-i[2],a[0]=s[0],a[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),a[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),e[0]=a[0]+i[0],e[1]=a[1]+i[1],e[2]=a[2]+i[2],e}function Ii(e,t,i,r){var s=[],a=[];return s[0]=t[0]-i[0],s[1]=t[1]-i[1],s[2]=t[2]-i[2],a[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),a[1]=s[1],a[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),e[0]=a[0]+i[0],e[1]=a[1]+i[1],e[2]=a[2]+i[2],e}function Fi(e,t,i,r){var s=[],a=[];return s[0]=t[0]-i[0],s[1]=t[1]-i[1],s[2]=t[2]-i[2],a[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),a[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),a[2]=s[2],e[0]=a[0]+i[0],e[1]=a[1]+i[1],e[2]=a[2]+i[2],e}function Di(e,t){var i=e[0],r=e[1],s=e[2],a=t[0],o=t[1],n=t[2],h=Math.sqrt((i*i+r*r+s*s)*(a*a+o*o+n*n)),l=h&&vi(e,t)/h;return Math.acos(Math.min(Math.max(l,-1),1))}function Li(e){return e[0]=0,e[1]=0,e[2]=0,e}function Bi(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"}function Oi(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Vi(e,t){var i=e[0],r=e[1],s=e[2],a=t[0],o=t[1],n=t[2];return Math.abs(i-a)<=_*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-o)<=_*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-n)<=_*Math.max(1,Math.abs(s),Math.abs(n))}var Ni,zi=si,Ui=ai,Gi=oi,Hi=fi,Yi=gi,ki=Jt,Xi=pi,qi=(Ni=Kt(),function(e,t,i,r,s,a){var o,n;for(t||(t=3),i||(i=0),n=r?Math.min(r*t+i,e.length):e.length,o=i;o<n;o+=t)Ni[0]=e[o],Ni[1]=e[o+1],Ni[2]=e[o+2],s(Ni,Ni,a),e[o]=Ni[0],e[o+1]=Ni[1],e[o+2]=Ni[2];return e});function Zi(){var e=new f(4);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function ji(e){var t=new f(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function Wi(e,t,i,r){var s=new f(4);return s[0]=e,s[1]=t,s[2]=i,s[3]=r,s}function $i(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Ki(e,t,i,r,s){return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e}function Qi(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e}function Ji(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e}function er(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}function tr(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e[3]=t[3]/i[3],e}function ir(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e}function rr(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e}function sr(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e[3]=Math.min(t[3],i[3]),e}function ar(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e[3]=Math.max(t[3],i[3]),e}function or(e,t){return e[0]=m(t[0]),e[1]=m(t[1]),e[2]=m(t[2]),e[3]=m(t[3]),e}function nr(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function hr(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e}function lr(e,t){var i=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2],a=t[3]-e[3];return Math.sqrt(i*i+r*r+s*s+a*a)}function cr(e,t){var i=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2],a=t[3]-e[3];return i*i+r*r+s*s+a*a}function ur(e){var t=e[0],i=e[1],r=e[2],s=e[3];return Math.sqrt(t*t+i*i+r*r+s*s)}function dr(e){var t=e[0],i=e[1],r=e[2],s=e[3];return t*t+i*i+r*r+s*s}function _r(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e}function fr(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e}function gr(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=i*i+r*r+s*s+a*a;return o>0&&(o=1/Math.sqrt(o)),e[0]=i*o,e[1]=r*o,e[2]=s*o,e[3]=a*o,e}function pr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function mr(e,t,i,r){var s=i[0]*r[1]-i[1]*r[0],a=i[0]*r[2]-i[2]*r[0],o=i[0]*r[3]-i[3]*r[0],n=i[1]*r[2]-i[2]*r[1],h=i[1]*r[3]-i[3]*r[1],l=i[2]*r[3]-i[3]*r[2],c=t[0],u=t[1],d=t[2],_=t[3];return e[0]=u*l-d*h+_*n,e[1]=-c*l+d*o-_*a,e[2]=c*h-u*o+_*s,e[3]=-c*n+u*a-d*s,e}function xr(e,t,i,r){var s=t[0],a=t[1],o=t[2],n=t[3];return e[0]=s+r*(i[0]-s),e[1]=a+r*(i[1]-a),e[2]=o+r*(i[2]-o),e[3]=n+r*(i[3]-n),e}function Mr(e,t){var i,r,s,a,o,n,h;t=void 0===t?1:t,o=(i=2*(h=g())-1)*i+(r=(4*g()-2)*Math.sqrt(h*-h+h))*r,n=(s=2*(h=g())-1)*s+(a=(4*g()-2)*Math.sqrt(h*-h+h))*a;var l=Math.sqrt((1-o)/n);return e[0]=t*i,e[1]=t*r,e[2]=t*s*l,e[3]=t*a*l,e}function vr(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3];return e[0]=i[0]*r+i[4]*s+i[8]*a+i[12]*o,e[1]=i[1]*r+i[5]*s+i[9]*a+i[13]*o,e[2]=i[2]*r+i[6]*s+i[10]*a+i[14]*o,e[3]=i[3]*r+i[7]*s+i[11]*a+i[15]*o,e}function br(e,t,i){var r=i[0],s=i[1],a=i[2],o=i[3],n=t[0],h=t[1],l=t[2],c=s*l-a*h,u=a*n-r*l,d=r*h-s*n;return c+=c,u+=u,d+=d,e[0]=n+o*c+s*d-a*u,e[1]=h+o*u+a*c-r*d,e[2]=l+o*d+r*u-s*c,e[3]=t[3],e}function Sr(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function Pr(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function yr(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function Tr(e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=t[0],n=t[1],h=t[2],l=t[3];return Math.abs(i-o)<=_*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-n)<=_*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(s-h)<=_*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(a-l)<=_*Math.max(1,Math.abs(a),Math.abs(l))}var wr=Ji,Cr=er,Ar=tr,Er=lr,Rr=cr,Ir=ur,Fr=dr,Dr=function(){var e=Zi();return function(t,i,r,s,a,o){var n,h;for(i||(i=4),r||(r=0),h=s?Math.min(s*i+r,t.length):t.length,n=r;n<h;n+=i)e[0]=t[n],e[1]=t[n+1],e[2]=t[n+2],e[3]=t[n+3],a(e,e,o),t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3];return t}}();function Lr(){var e=new f(4);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Br(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Or(e,t,i){i*=.5;var r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function Vr(e,t){var i=2*Math.acos(t[3]),r=Math.sin(i/2);return r>_?(e[0]=t[0]/r,e[1]=t[1]/r,e[2]=t[2]/r):(e[0]=1,e[1]=0,e[2]=0),i}function Nr(e,t){var i=ns(e,t);return Math.acos(2*i*i-1)}function zr(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=i[0],h=i[1],l=i[2],c=i[3];return e[0]=r*c+o*n+s*l-a*h,e[1]=s*c+o*h+a*n-r*l,e[2]=a*c+o*l+r*h-s*n,e[3]=o*c-r*n-s*h-a*l,e}function Ur(e,t,i){i*=.5;var r=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(i),h=Math.cos(i);return e[0]=r*h+o*n,e[1]=s*h+a*n,e[2]=a*h-s*n,e[3]=o*h-r*n,e}function Gr(e,t,i){i*=.5;var r=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(i),h=Math.cos(i);return e[0]=r*h-a*n,e[1]=s*h+o*n,e[2]=a*h+r*n,e[3]=o*h-s*n,e}function Hr(e,t,i){i*=.5;var r=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(i),h=Math.cos(i);return e[0]=r*h+s*n,e[1]=s*h-r*n,e[2]=a*h+o*n,e[3]=o*h-a*n,e}function Yr(e,t){var i=t[0],r=t[1],s=t[2];return e[0]=i,e[1]=r,e[2]=s,e[3]=Math.sqrt(Math.abs(1-i*i-r*r-s*s)),e}function kr(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=Math.sqrt(i*i+r*r+s*s),n=Math.exp(a),h=o>0?n*Math.sin(o)/o:0;return e[0]=i*h,e[1]=r*h,e[2]=s*h,e[3]=n*Math.cos(o),e}function Xr(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=Math.sqrt(i*i+r*r+s*s),n=o>0?Math.atan2(o,a)/o:0;return e[0]=i*n,e[1]=r*n,e[2]=s*n,e[3]=.5*Math.log(i*i+r*r+s*s+a*a),e}function qr(e,t,i){return Xr(e,t),os(e,e,i),kr(e,e),e}function Zr(e,t,i,r){var s,a,o,n,h,l=t[0],c=t[1],u=t[2],d=t[3],f=i[0],g=i[1],p=i[2],m=i[3];return(a=l*f+c*g+u*p+d*m)<0&&(a=-a,f=-f,g=-g,p=-p,m=-m),1-a>_?(s=Math.acos(a),o=Math.sin(s),n=Math.sin((1-r)*s)/o,h=Math.sin(r*s)/o):(n=1-r,h=r),e[0]=n*l+h*f,e[1]=n*c+h*g,e[2]=n*u+h*p,e[3]=n*d+h*m,e}function jr(e){var t=g(),i=g(),r=g(),s=Math.sqrt(1-t),a=Math.sqrt(t);return e[0]=s*Math.sin(2*Math.PI*i),e[1]=s*Math.cos(2*Math.PI*i),e[2]=a*Math.sin(2*Math.PI*r),e[3]=a*Math.cos(2*Math.PI*r),e}function Wr(e,t){var i=t[0],r=t[1],s=t[2],a=t[3],o=i*i+r*r+s*s+a*a,n=o?1/o:0;return e[0]=-i*n,e[1]=-r*n,e[2]=-s*n,e[3]=a*n,e}function $r(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Kr(e,t){var i,r=t[0]+t[4]+t[8];if(r>0)i=Math.sqrt(r+1),e[3]=.5*i,i=.5/i,e[0]=(t[5]-t[7])*i,e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{var s=0;t[4]>t[0]&&(s=1),t[8]>t[3*s+s]&&(s=2);var a=(s+1)%3,o=(s+2)%3;i=Math.sqrt(t[3*s+s]-t[3*a+a]-t[3*o+o]+1),e[s]=.5*i,i=.5/i,e[3]=(t[3*a+o]-t[3*o+a])*i,e[a]=(t[3*a+s]+t[3*s+a])*i,e[o]=(t[3*o+s]+t[3*s+o])*i}return e}function Qr(e,t,i,r){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:p,a=Math.PI/360;t*=a,r*=a,i*=a;var o=Math.sin(t),n=Math.cos(t),h=Math.sin(i),l=Math.cos(i),c=Math.sin(r),u=Math.cos(r);switch(s){case"xyz":e[0]=o*l*u+n*h*c,e[1]=n*h*u-o*l*c,e[2]=n*l*c+o*h*u,e[3]=n*l*u-o*h*c;break;case"xzy":e[0]=o*l*u-n*h*c,e[1]=n*h*u-o*l*c,e[2]=n*l*c+o*h*u,e[3]=n*l*u+o*h*c;break;case"yxz":e[0]=o*l*u+n*h*c,e[1]=n*h*u-o*l*c,e[2]=n*l*c-o*h*u,e[3]=n*l*u+o*h*c;break;case"yzx":e[0]=o*l*u+n*h*c,e[1]=n*h*u+o*l*c,e[2]=n*l*c-o*h*u,e[3]=n*l*u-o*h*c;break;case"zxy":e[0]=o*l*u-n*h*c,e[1]=n*h*u+o*l*c,e[2]=n*l*c+o*h*u,e[3]=n*l*u-o*h*c;break;case"zyx":e[0]=o*l*u-n*h*c,e[1]=n*h*u+o*l*c,e[2]=n*l*c-o*h*u,e[3]=n*l*u+o*h*c;break;default:throw new Error("Unknown angle order "+s)}return e}function Jr(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}var es=ji,ts=Wi,is=$i,rs=Ki,ss=Qi,as=zr,os=nr,ns=pr,hs=xr,ls=ur,cs=ls,us=dr,ds=us,_s=gr,fs=yr;function gs(e,t){return Math.abs(pr(e,t))>=1-_}var ps,ms,xs,Ms,vs,bs,Ss=(ps=Kt(),ms=ei(1,0,0),xs=ei(0,1,0),function(e,t,i){var r=vi(t,i);return r<-.999999?(bi(ps,ms,t),ki(ps)<1e-6&&bi(ps,xs,t),Mi(ps,ps),Or(e,ps,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(bi(ps,t,i),e[0]=ps[0],e[1]=ps[1],e[2]=ps[2],e[3]=1+r,_s(e,e))}),Ps=(Ms=Lr(),vs=Lr(),function(e,t,i,r,s,a){return Zr(Ms,t,s,a),Zr(vs,i,r,a),Zr(e,Ms,vs,2*a*(1-a)),e}),ys=(bs=be(),function(e,t,i,r){return bs[0]=i[0],bs[3]=i[1],bs[6]=i[2],bs[1]=r[0],bs[4]=r[1],bs[7]=r[2],bs[2]=-t[0],bs[5]=-t[1],bs[8]=-t[2],_s(e,Kr(e,bs))});function Ts(){var e=new f(8);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e}function ws(e){var t=new f(8);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t}function Cs(e,t,i,r,s,a,o,n){var h=new f(8);return h[0]=e,h[1]=t,h[2]=i,h[3]=r,h[4]=s,h[5]=a,h[6]=o,h[7]=n,h}function As(e,t,i,r,s,a,o){var n=new f(8);n[0]=e,n[1]=t,n[2]=i,n[3]=r;var h=.5*s,l=.5*a,c=.5*o;return n[4]=h*r+l*i-c*t,n[5]=l*r+c*e-h*i,n[6]=c*r+h*t-l*e,n[7]=-h*e-l*t-c*i,n}function Es(e,t,i){var r=.5*i[0],s=.5*i[1],a=.5*i[2],o=t[0],n=t[1],h=t[2],l=t[3];return e[0]=o,e[1]=n,e[2]=h,e[3]=l,e[4]=r*l+s*h-a*n,e[5]=s*l+a*o-r*h,e[6]=a*l+r*n-s*o,e[7]=-r*o-s*n-a*h,e}function Rs(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e}function Is(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e}function Fs(e,t){var i=Lr();wt(i,t);var r=new f(3);return yt(r,t),Es(e,i,r),e}function Ds(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function Ls(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e}function Bs(e,t,i,r,s,a,o,n,h){return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e[4]=a,e[5]=o,e[6]=n,e[7]=h,e}var Os=is;function Vs(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e}var Ns=is;function zs(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e}function Us(e,t){var i=t[4],r=t[5],s=t[6],a=t[7],o=-t[0],n=-t[1],h=-t[2],l=t[3];return e[0]=2*(i*l+a*o+r*h-s*n),e[1]=2*(r*l+a*n+s*o-i*h),e[2]=2*(s*l+a*h+i*n-r*o),e}function Gs(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=.5*i[0],h=.5*i[1],l=.5*i[2],c=t[4],u=t[5],d=t[6],_=t[7];return e[0]=r,e[1]=s,e[2]=a,e[3]=o,e[4]=o*n+s*l-a*h+c,e[5]=o*h+a*n-r*l+u,e[6]=o*l+r*h-s*n+d,e[7]=-r*n-s*h-a*l+_,e}function Hs(e,t,i){var r=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=n*o+c*r+h*a-l*s,d=h*o+c*s+l*r-n*a,_=l*o+c*a+n*s-h*r,f=c*o-n*r-h*s-l*a;return Ur(e,t,i),r=e[0],s=e[1],a=e[2],o=e[3],e[4]=u*o+f*r+d*a-_*s,e[5]=d*o+f*s+_*r-u*a,e[6]=_*o+f*a+u*s-d*r,e[7]=f*o-u*r-d*s-_*a,e}function Ys(e,t,i){var r=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=n*o+c*r+h*a-l*s,d=h*o+c*s+l*r-n*a,_=l*o+c*a+n*s-h*r,f=c*o-n*r-h*s-l*a;return Gr(e,t,i),r=e[0],s=e[1],a=e[2],o=e[3],e[4]=u*o+f*r+d*a-_*s,e[5]=d*o+f*s+_*r-u*a,e[6]=_*o+f*a+u*s-d*r,e[7]=f*o-u*r-d*s-_*a,e}function ks(e,t,i){var r=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=n*o+c*r+h*a-l*s,d=h*o+c*s+l*r-n*a,_=l*o+c*a+n*s-h*r,f=c*o-n*r-h*s-l*a;return Hr(e,t,i),r=e[0],s=e[1],a=e[2],o=e[3],e[4]=u*o+f*r+d*a-_*s,e[5]=d*o+f*s+_*r-u*a,e[6]=_*o+f*a+u*s-d*r,e[7]=f*o-u*r-d*s-_*a,e}function Xs(e,t,i){var r=i[0],s=i[1],a=i[2],o=i[3],n=t[0],h=t[1],l=t[2],c=t[3];return e[0]=n*o+c*r+h*a-l*s,e[1]=h*o+c*s+l*r-n*a,e[2]=l*o+c*a+n*s-h*r,e[3]=c*o-n*r-h*s-l*a,n=t[4],h=t[5],l=t[6],c=t[7],e[4]=n*o+c*r+h*a-l*s,e[5]=h*o+c*s+l*r-n*a,e[6]=l*o+c*a+n*s-h*r,e[7]=c*o-n*r-h*s-l*a,e}function qs(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=i[0],h=i[1],l=i[2],c=i[3];return e[0]=r*c+o*n+s*l-a*h,e[1]=s*c+o*h+a*n-r*l,e[2]=a*c+o*l+r*h-s*n,e[3]=o*c-r*n-s*h-a*l,n=i[4],h=i[5],l=i[6],c=i[7],e[4]=r*c+o*n+s*l-a*h,e[5]=s*c+o*h+a*n-r*l,e[6]=a*c+o*l+r*h-s*n,e[7]=o*c-r*n-s*h-a*l,e}function Zs(e,t,i,r){if(Math.abs(r)<_)return Ds(e,t);var s=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);r*=.5;var a=Math.sin(r),o=a*i[0]/s,n=a*i[1]/s,h=a*i[2]/s,l=Math.cos(r),c=t[0],u=t[1],d=t[2],f=t[3];e[0]=c*l+f*o+u*h-d*n,e[1]=u*l+f*n+d*o-c*h,e[2]=d*l+f*h+c*n-u*o,e[3]=f*l-c*o-u*n-d*h;var g=t[4],p=t[5],m=t[6],x=t[7];return e[4]=g*l+x*o+p*h-m*n,e[5]=p*l+x*n+m*o-g*h,e[6]=m*l+x*h+g*n-p*o,e[7]=x*l-g*o-p*n-m*h,e}function js(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e}function Ws(e,t,i){var r=t[0],s=t[1],a=t[2],o=t[3],n=i[4],h=i[5],l=i[6],c=i[7],u=t[4],d=t[5],_=t[6],f=t[7],g=i[0],p=i[1],m=i[2],x=i[3];return e[0]=r*x+o*g+s*m-a*p,e[1]=s*x+o*p+a*g-r*m,e[2]=a*x+o*m+r*p-s*g,e[3]=o*x-r*g-s*p-a*m,e[4]=r*c+o*n+s*l-a*h+u*x+f*g+d*m-_*p,e[5]=s*c+o*h+a*n-r*l+d*x+f*p+_*g-u*m,e[6]=a*c+o*l+r*h-s*n+_*x+f*m+u*p-d*g,e[7]=o*c-r*n-s*h-a*l+f*x-u*g-d*p-_*m,e}var $s=Ws;function Ks(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e}var Qs=ns;function Js(e,t,i,r){var s=1-r;return Qs(t,i)<0&&(r=-r),e[0]=t[0]*s+i[0]*r,e[1]=t[1]*s+i[1]*r,e[2]=t[2]*s+i[2]*r,e[3]=t[3]*s+i[3]*r,e[4]=t[4]*s+i[4]*r,e[5]=t[5]*s+i[5]*r,e[6]=t[6]*s+i[6]*r,e[7]=t[7]*s+i[7]*r,e}function ea(e,t){var i=sa(t);return e[0]=-t[0]/i,e[1]=-t[1]/i,e[2]=-t[2]/i,e[3]=t[3]/i,e[4]=-t[4]/i,e[5]=-t[5]/i,e[6]=-t[6]/i,e[7]=t[7]/i,e}function ta(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e[4]=-t[4],e[5]=-t[5],e[6]=-t[6],e[7]=t[7],e}var ia=ls,ra=ia,sa=us,aa=sa;function oa(e,t){var i=sa(t);if(i>0){i=Math.sqrt(i);var r=t[0]/i,s=t[1]/i,a=t[2]/i,o=t[3]/i,n=t[4],h=t[5],l=t[6],c=t[7],u=r*n+s*h+a*l+o*c;e[0]=r,e[1]=s,e[2]=a,e[3]=o,e[4]=(n-r*u)/i,e[5]=(h-s*u)/i,e[6]=(l-a*u)/i,e[7]=(c-o*u)/i}return e}function na(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"}function ha(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]}function la(e,t){var i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=e[6],l=e[7],c=t[0],u=t[1],d=t[2],f=t[3],g=t[4],p=t[5],m=t[6],x=t[7];return Math.abs(i-c)<=_*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(r-u)<=_*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(s-d)<=_*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(a-f)<=_*Math.max(1,Math.abs(a),Math.abs(f))&&Math.abs(o-g)<=_*Math.max(1,Math.abs(o),Math.abs(g))&&Math.abs(n-p)<=_*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(h-m)<=_*Math.max(1,Math.abs(h),Math.abs(m))&&Math.abs(l-x)<=_*Math.max(1,Math.abs(l),Math.abs(x))}function ca(){var e=new f(2);return f!=Float32Array&&(e[0]=0,e[1]=0),e}function ua(e){var t=new f(2);return t[0]=e[0],t[1]=e[1],t}function da(e,t){var i=new f(2);return i[0]=e,i[1]=t,i}function _a(e,t){return e[0]=t[0],e[1]=t[1],e}function fa(e,t,i){return e[0]=t,e[1]=i,e}function ga(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e}function pa(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e}function ma(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e}function xa(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e}function Ma(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e}function va(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e}function ba(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e}function Sa(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e}function Pa(e,t){return e[0]=m(t[0]),e[1]=m(t[1]),e}function ya(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function Ta(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e}function wa(e,t){var i=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(i*i+r*r)}function Ca(e,t){var i=t[0]-e[0],r=t[1]-e[1];return i*i+r*r}function Aa(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function Ea(e){var t=e[0],i=e[1];return t*t+i*i}function Ra(e,t){return e[0]=-t[0],e[1]=-t[1],e}function Ia(e,t){return e[0]=1/t[0],e[1]=1/t[1],e}function Fa(e,t){var i=t[0],r=t[1],s=i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e}function Da(e,t){return e[0]*t[0]+e[1]*t[1]}function La(e,t,i){var r=t[0]*i[1]-t[1]*i[0];return e[0]=e[1]=0,e[2]=r,e}function Ba(e,t,i,r){var s=t[0],a=t[1];return e[0]=s+r*(i[0]-s),e[1]=a+r*(i[1]-a),e}function Oa(e,t){t=void 0===t?1:t;var i=2*g()*Math.PI;return e[0]=Math.cos(i)*t,e[1]=Math.sin(i)*t,e}function Va(e,t,i){var r=t[0],s=t[1];return e[0]=i[0]*r+i[2]*s,e[1]=i[1]*r+i[3]*s,e}function Na(e,t,i){var r=t[0],s=t[1];return e[0]=i[0]*r+i[2]*s+i[4],e[1]=i[1]*r+i[3]*s+i[5],e}function za(e,t,i){var r=t[0],s=t[1];return e[0]=i[0]*r+i[3]*s+i[6],e[1]=i[1]*r+i[4]*s+i[7],e}function Ua(e,t,i){var r=t[0],s=t[1];return e[0]=i[0]*r+i[4]*s+i[12],e[1]=i[1]*r+i[5]*s+i[13],e}function Ga(e,t,i,r){var s=t[0]-i[0],a=t[1]-i[1],o=Math.sin(r),n=Math.cos(r);return e[0]=s*n-a*o+i[0],e[1]=s*o+a*n+i[1],e}function Ha(e,t){var i=e[0],r=e[1],s=t[0],a=t[1];return Math.abs(Math.atan2(r*s-i*a,i*s+r*a))}function Ya(e,t){var i=e[0],r=e[1],s=t[0],a=t[1];return Math.atan2(i*a-r*s,i*s+r*a)}function ka(e){return e[0]=0,e[1]=0,e}function Xa(e){return"vec2("+e[0]+", "+e[1]+")"}function qa(e,t){return e[0]===t[0]&&e[1]===t[1]}function Za(e,t){var i=e[0],r=e[1],s=t[0],a=t[1];return Math.abs(i-s)<=_*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-a)<=_*Math.max(1,Math.abs(r),Math.abs(a))}var ja=Aa,Wa=pa,$a=ma,Ka=xa,Qa=wa,Ja=Ca,eo=Ea,to=function(){var e=ca();return function(t,i,r,s,a,o){var n,h;for(i||(i=2),r||(r=0),h=s?Math.min(s*i+r,t.length):t.length,n=r;n<h;n+=i)e[0]=t[n],e[1]=t[n+1],a(e,e,o),t[n]=e[0],t[n+1]=e[1];return t}}()},2056:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VisibleTilesManager=void 0;const s=r(i(4382)),a=i(1138),o=r(i(4639)),n=i(4006),h=i(1961),l=i(2919);t.VisibleTilesManager=class{_visibleTilesByOrder;_ancestorsMap;initialised;_galVisibleTilesByOrder;_galAncestorsMap;_galacticMatrixInverted;_galacticMatrix;insideSphere=l.bootSetup.insideSphere;_tileBuffer;_healpixGrid;_webgl;constructor(e,t,i){this._webgl=e,this._healpixGrid=i,this._visibleTilesByOrder={pixels:[],order:0},this._ancestorsMap=new Map,this.initialised=!1,this._galVisibleTilesByOrder={pixels:[],order:0},this._galAncestorsMap=new Map,this._galacticMatrixInverted=h.mat4.create(),this._galacticMatrix=h.mat4.create(),h.mat4.set(this._galacticMatrixInverted,-.054876,-.873437,-.483835,0,.494109,-.44483,.746982,-0,-.867666,-.198076,.455984,0,0,0,0,1),h.mat4.invert(this._galacticMatrix,this._galacticMatrixInverted),this._tileBuffer=new n.TileBuffer(1,e,t,this)}get healpixGrid(){return this._healpixGrid}get tileBuffer(){return this._tileBuffer}init(e){this.initialised=!0,this.insideSphere=e}getVisibleOrder(){return this._healpixGrid.visibleorder}computeVisiblePixels(e,t,i,r){if(!this.initialised)return;s.default.insideSphere&&e<3&&(e=3),this._ancestorsMap.set(e,[]),this._galAncestorsMap.set(e,[]);let n=[],l=[];if(0===e){const t=s.default.getHealpix(0).getNPix();for(let i=0;i<t;i++)n.push(i),this._ancestorsMap.get(e).push(i),l.push(i),this._galAncestorsMap.get(e).push(i)}else{const c=s.default.getHealpix(e),u=t.canvas.width,d=t.canvas.height;for(let t=0;t<=u;t+=u/30)for(let s=0;s<=d;s+=d/30){const u=o.default.getIntersectionPointWithSingleModel(t,s,this._healpixGrid,this._webgl,i,r);if(u.length>0){const t=h.vec4.create();h.vec4.transformMat4(t,[u[0],u[1],u[2],1],this._galacticMatrix);const i=new a.Pointing(new a.Vec3(t[0],t[1],t[2])),r=c.ang2pix(i),s=new a.Pointing(new a.Vec3(u[0],u[1],u[2])),o=c.ang2pix(s);n.includes(o)||(n.push(o),this._ancestorsMap.get(e).push(o),this._tileBuffer.addTile(e,o)),l.includes(r)||(l.push(r),this._galAncestorsMap.get(e).push(r),this._tileBuffer.addGalTile(e,r))}}}this._visibleTilesByOrder={pixels:n,order:e},this._galVisibleTilesByOrder={pixels:l,order:e};for(let t=1;t<e;t++){const i=e-t,r=this._ancestorsMap.get(i)??[];this._ancestorsMap.set(i,r);for(let e=0;e<n.length;e++){const s=n[e]>>2*t;r.includes(s)||(r.push(s),this._tileBuffer.addTile(i,s))}}for(let t=1;t<e;t++){const i=e-t,r=this._galAncestorsMap.get(i)??[];this._galAncestorsMap.set(i,r);for(let e=0;e<l.length;e++){const s=l[e]>>2*t;r.includes(s)||(r.push(s),this._tileBuffer.addGalTile(i,s))}}}get visibleTilesByOrder(){return this._visibleTilesByOrder}get ancestorsMap(){return this._ancestorsMap}get galVisibleTilesByOrder(){return this._galVisibleTilesByOrder}get galAncestorsMap(){return this._galAncestorsMap}get visibleOrder(){return this._visibleTilesByOrder.order}}},2166:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const r=i(1961),s=85.0511287798066;class a{static getRayFromMouse(e,t,i,s,o){const n=s.canvas.getBoundingClientRect(),h=[2*e/n.width-1,1-2*t/n.height,-1,1],l=r.mat4.create();r.mat4.invert(l,i);const c=[0,0,0,0];a.mat4MultiplyVec4(l,h,c);const u=[c[0],c[1],-1,0],d=r.mat4.create();r.mat4.invert(d,o);const _=[0,0,0,0];a.mat4MultiplyVec4(d,u,_);const f=r.vec3.fromValues(_[0],_[1],_[2]);return r.vec3.normalize(f,f),f}static raySphere(e,t,i){let s=-1;const a=r.vec3.create();r.vec3.subtract(a,e,i.center);const o=r.vec3.dot(t,a),n=o*o-(r.vec3.dot(a,a)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-o+e,i=-o-e;(t>=0||i>=0)&&(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-o;e>=0&&(s=e)}return s}static getIntersectionPointWithModel(e,t,i,s,o,n){const h=o.getCameraMatrix(),l=a.getRayFromMouse(e,t,n,s,h),c=a.raySphere(o.getCameraPosition(),l,i);if(c<0)return null;const u=r.vec3.create();r.vec3.scale(u,l,c),r.vec3.add(u,o.getCameraPosition(),u);const d=[u[0],u[1],u[2],1],_=[0,0,0,0];return a.mat4MultiplyVec4(i.getModelMatrixInverse(),d,_),[_[0],_[1],_[2]]}static getLonLatFromMouse(e,t,i,r,s,o){const n=a.getIntersectionPointWithModel(e,t,i,r,s,o);return n?a.modelPointToLonLat(n):null}static getTileFromMouse(e,t,i,r,s,o,n){const h=a.getLonLatFromMouse(e,t,r,s,o,n);return h&&a.isMercatorLatitude(h.latDeg)?a.lonLatToTile(h.lonDeg,h.latDeg,i):null}static getVisibleTilesFromViewport(e,t,i,r,s,o=9,n=2){const h=i.canvas.getBoundingClientRect(),l=Math.max(2,Math.floor(o)),c=Math.max(2*l+1,21),u=Math.max(0,Math.floor(n)),d=[],_=(o,n)=>{const h=a.getTileFromMouse(o,n,e,t,i,r,s);h&&(d.push(h),d.push(...a.getNeighborTiles(h,u)))};for(let e=0;e<l;e++){const t=1===l?h.height/2:e/(l-1)*h.height;for(let e=0;e<l;e++)_(1===l?h.width/2:e/(l-1)*h.width,t)}for(let e=0;e<c;e++){const t=1===c?.5:e/(c-1),i=t*h.width,r=t*h.height;_(i,0),_(i,h.height),_(0,r),_(h.width,r)}return a.fillSmallTileGaps(a.deduplicateTiles(d))}static modelPointToLonLat(e){const[t,i,r]=e,s=Math.hypot(t,i,r);return Number.isFinite(s)&&0!==s?{lonDeg:180*Math.atan2(i,t)/Math.PI,latDeg:180*Math.asin(Math.max(-1,Math.min(1,r/s)))/Math.PI}:{lonDeg:0,latDeg:0}}static lonLatToTile(e,t,i){const r=Math.max(0,Math.floor(i)),s=2**r,o=Math.floor((e+180)/360*s),n=Math.floor(a.latToTileY(t,r));return{z:r,x:a.wrapTileX(o,s),y:a.clampTileY(n,s)}}static getNeighborTiles(e,t=1){const i=2**e.z,r=[],s=Math.max(0,Math.floor(t));for(let t=-s;t<=s;t++)for(let o=-s;o<=s;o++)r.push({z:e.z,x:a.wrapTileX(e.x+t,i),y:a.clampTileY(e.y+o,i)});return a.deduplicateTiles(r)}static deduplicateTiles(e){const t=new Map;for(const i of e)t.set(`${i.z}/${i.x}/${i.y}`,i);return Array.from(t.values())}static fillSmallTileGaps(e){if(0===e.length)return e;const t=e[0].z,i=2**t,r=new Map,s=e=>{r.set((e=>`${e.z}/${e.x}/${e.y}`)(e),e)},o=(e,s)=>s>=0&&s<i&&r.has(`${t}/${a.wrapTileX(e,i)}/${s}`);for(const t of e)s(t);for(const r of e){const e=r.x,n=r.y;o(e-2,n)&&!o(e-1,n)&&s({z:t,x:a.wrapTileX(e-1,i),y:n}),o(e+2,n)&&!o(e+1,n)&&s({z:t,x:a.wrapTileX(e+1,i),y:n}),o(e,n-2)&&!o(e,n-1)&&s({z:t,x:e,y:n-1}),o(e,n+2)&&!o(e,n+1)&&s({z:t,x:e,y:n+1})}return Array.from(r.values())}static latToTileY(e,t){const i=Math.max(-85.0511287798066,Math.min(s,e))*Math.PI/180,r=2**t;return(1-Math.asinh(Math.tan(i))/Math.PI)/2*r}static isMercatorLatitude(e){return Math.abs(e)<=s}static wrapTileX(e,t){return(e%t+t)%t}static clampTileY(e,t){return Math.max(0,Math.min(t-1,e))}static mat4MultiplyVec4(e,t,i){const r=t[0],s=t[1],a=t[2],o=t[3];return i[0]=e[0]*r+e[4]*s+e[8]*a+e[12]*o,i[1]=e[1]*r+e[5]*s+e[9]*a+e[13]*o,i[2]=e[2]*r+e[6]*s+e[10]*a+e[14]*o,i[3]=e[3]*r+e[7]*s+e[11]*a+e[15]*o,i}}t.default=a},2368:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382));t.default=class{_ready=!1;_hips;_format;_baseurl;_isGalacticHips;_order=3;opacity=1;_hipsShaderIndex=0;_texture=null;_image;_texurl;_textureLoaded=!1;_maxTiles=0;_numFacesXTile=0;_numFaces=0;vertexPosition;vertexPositionBuffer;vertexIndexBuffer;vidx=0;_webgl;_tileBuffer;_hipsShaderProgram;constructor(e,t,i,r){this._tileBuffer=i,this._hips=e,this._webgl=t,this._format=e.format,this._baseurl=e.baseURL,this._isGalacticHips=e.isGalacticHips,this._hipsShaderProgram=r,this.initImage()}initImage(){this._image=new Image,this._texurl=`${this._baseurl}/Norder3/Allsky.${this._format}`,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{console.error("File not found? %s",this._texurl)},this._image.setAttribute("crossorigin","anonymous"),this._image.src=this._texurl}imageLoaded(){this.textureLoaded(),this.initModelBuffer(),this._textureLoaded=!0,this._ready=!0}textureLoaded(){this._hipsShaderProgram.enableProgram();const e=this._webgl;this._texture=e.createTexture(),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.bindTexture(e.TEXTURE_2D,this._texture),e.isTexture(this._texture)||console.log("error in texture"),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.bindTexture(e.TEXTURE_2D,this._texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._image),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.generateMipmap(e.TEXTURE_2D)}initModelBuffer(){const e=this._webgl,t=this._order+1,i=s.default.getHealpix(this._order);this._maxTiles=i.getNPix();const r=s.default.getHealpix(t);this._numFacesXTile=4,this._numFaces=this._numFacesXTile*this._maxTiles,this.vertexPosition=new Float32Array(20*this._numFaces);let a=0,o=0;this.vidx=0;for(let e=0;e<this._maxTiles;e++){const t=i.nest2xyf(e),s=t.ix<<1,n=2+(t.ix<<1),h=t.iy<<1,l=2+(t.iy<<1);this.setupPositionAndTexture4Quadrant(a,o,s,s+(n-s)/2,h,h+(l-h)/2,r,t,0,0),this.setupPositionAndTexture4Quadrant(a,o,s+(n-s)/2,n,h,h+(l-h)/2,r,t,0,1),this.setupPositionAndTexture4Quadrant(a,o,s,s+(n-s)/2,h+(l-h)/2,l,r,t,1,0),this.setupPositionAndTexture4Quadrant(a,o,s+(n-s)/2,n,h+(l-h)/2,l,r,t,1,1),a++,27===a&&(o++,a=0)}const n=new Uint16Array(6*this._numFaces);let h=0;for(let e=0;e<this._numFaces;e++)n[6*e]=h,n[6*e+1]=h+1,n[6*e+2]=h+3,n[6*e+3]=h+1,n[6*e+4]=h+2,n[6*e+5]=h+3,h+=4;this.vertexPositionBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vertexPositionBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertexPosition,e.STATIC_DRAW),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,n,e.STATIC_DRAW)}setupPositionAndTexture4Quadrant(e,t,i,r,s,a,o,n,h,l){let c=[];const u=2**(o.order-3),d=1/(27*u),_=1/(29*u),f=d/64,g=_/64,p=u*d*e+d*h,m=u*_*t+_*l;for(let e=i;e<r;e++)for(let t=s;t<a;t++)c=o.getPointsForXyfNoStep(e,t,n.face),this.vertexPosition[20*this.vidx]=c[0].x,this.vertexPosition[20*this.vidx+1]=c[0].y,this.vertexPosition[20*this.vidx+2]=c[0].z,this.vertexPosition[20*this.vidx+3]=d+p-f,this.vertexPosition[20*this.vidx+4]=1-(_+m)+g,this.vertexPosition[20*this.vidx+5]=c[1].x,this.vertexPosition[20*this.vidx+6]=c[1].y,this.vertexPosition[20*this.vidx+7]=c[1].z,this.vertexPosition[20*this.vidx+8]=d+p-f,this.vertexPosition[20*this.vidx+9]=1-m-g,this.vertexPosition[20*this.vidx+10]=c[2].x,this.vertexPosition[20*this.vidx+11]=c[2].y,this.vertexPosition[20*this.vidx+12]=c[2].z,this.vertexPosition[20*this.vidx+13]=p+f,this.vertexPosition[20*this.vidx+14]=1-m-g,this.vertexPosition[20*this.vidx+15]=c[3].x,this.vertexPosition[20*this.vidx+16]=c[3].y,this.vertexPosition[20*this.vidx+17]=c[3].z,this.vertexPosition[20*this.vidx+18]=p+f,this.vertexPosition[20*this.vidx+19]=1-(_+m)+g,this.vidx++}draw(e,t,i,r,s,a){if(!this._ready)return!1;let o=[];if(e>=this._order){const n=this.drawChildren(e,t,i,r,s,a);n&&(o=n)}const n=this._webgl;this._hipsShaderProgram.enableShaders(i,r,s,a),n.enableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.enableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),n.activeTexture(n.TEXTURE0+this._hipsShaderIndex),n.bindTexture(n.TEXTURE_2D,this._texture),n.uniform1f(this._hipsShaderProgram.locations.textureAlpha,this.opacity),n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBuffer),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),n.vertexAttribPointer(this._hipsShaderProgram.locations.vertexPositionAttribute,3,n.FLOAT,!1,20,0),n.vertexAttribPointer(this._hipsShaderProgram.locations.textureCoordAttribute,2,n.FLOAT,!1,20,12);for(let e=0;e<this._maxTiles;e++)o.includes(e)||n.drawElements(n.TRIANGLES,6*this._numFacesXTile,n.UNSIGNED_SHORT,12*e*this._numFacesXTile);return n.disableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.disableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),!0}drawChildren(e,t,i,r,s,a){const o=this._order;if(!t.has(o))return;const n=t.get(o),h=[];for(let l=0;l<n.length;l++){const c=n[l],u=this._isGalacticHips?this._tileBuffer.getGalTile(c,o,this._hips):this._tileBuffer.getTile(c,o,this._hips);u.draw(e,t,i,r,s,a,this._hipsShaderProgram),u.getReadyState()&&h.push(c)}return h}}},2475:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=void 0;const s=r(i(2930)),a=r(i(9665)),o=i(8145);class n{_polygons=[];_convexPolygons=[];_stcs;_valid=!1;_details;_totPoints=0;_totConvexPoints=0;_npix256;_footprintsPointsOrder;_coordsType;_selectionObj;_identifier;_center;constructor(e,t=[],i,r=o.CoordsType.ASTRO){this._coordsType=r,e?(this._stcs=e.toUpperCase(),this._details=t,this._totPoints=0,this._totConvexPoints=0,this._footprintsPointsOrder=i,this.computePoints(),this._selectionObj=this.computeSelectionObject(),this._valid=!0):this._details=[]}static fromPolygons(e,t=[],i=o.CoordsType.ASTRO){const r=new n(void 0,[],void 0,i);return r._polygons=e,r._details=t,r._totPoints=e.reduce((e,t)=>e+t.length,0),r._totConvexPoints=0,r._coordsType=i,r._selectionObj=r.computeSelectionObject(),r._valid=r._totPoints>0,r}computeSelectionObject(){return s.default.computeSelectionObject(this._polygons)}computePoints(){const e=a.default.parseSTCS(this._stcs,{coordsType:this._coordsType});this._polygons=e.polygons,this._totPoints=e.totpoints}get valid(){return this._valid}get totPoints(){return this._totPoints}get totConvexPoints(){return this._totConvexPoints}get polygons(){return this._polygons}get convexPolygons(){return this._convexPolygons}get identifier(){return this._identifier}get center(){return this._center}get pixels(){return this._npix256}get details(){return this._details}get selectionObj(){return this._selectionObj}}t.Footprint=n},2737:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZTileBuffer=void 0;class i{_tiles=new Map;_cachedTiles=new Map;_cacheAliveMilliSeconds;_cleanerId;constructor(e=1){this._cacheAliveMilliSeconds=60*e*1e3,"undefined"!=typeof window&&(this._cleanerId=window.setInterval(()=>{this.cacheCleaner()},1e4))}get activeTiles(){return this._tiles}get cachedTiles(){return this._cachedTiles}get size(){return this._tiles.size+this._cachedTiles.size}ensureTiles(e,t){const i=[];for(const r of e){const e=this.getTile(r,t);this.touchTile(e),i.push(this.key(r))}return this.syncVisibleTiles(i),i}getTile(e,t){const i=this.key(e);if(this._tiles.has(i))return this._tiles.get(i).tile;if(this._cachedTiles.has(i)){const e=this._cachedTiles.get(i);return e.cacheTime0=void 0,this._tiles.set(i,e),this._cachedTiles.delete(i),e.tile}const r=t(e);return this._tiles.set(i,{tile:r}),r}getActiveTile(e){return this._tiles.get(e)?.tile??null}getAnyTile(e){return this._tiles.get(e)?.tile??this._cachedTiles.get(e)?.tile??null}getActiveTiles(){return Array.from(this._tiles.values(),e=>e.tile)}syncVisibleTiles(e){const t=new Set(e);for(const[e,i]of this._tiles)t.has(e)?this.touchTile(i.tile):(i.cacheTime0=Date.now(),this._cachedTiles.set(e,i),this._tiles.delete(e))}evictCached(e){if(this.size<=e)return;const t=Array.from(this._cachedTiles.entries()).sort((e,t)=>this.getTileAgeScore(e[1].tile)-this.getTileAgeScore(t[1].tile));for(const[i,r]of t){if(this.size<=e)break;r.tile.loading||(r.tile.dispose?.(),this._cachedTiles.delete(i))}}dispose(){void 0!==this._cleanerId&&"undefined"!=typeof window&&(window.clearInterval(this._cleanerId),this._cleanerId=void 0);for(const e of this._tiles.values())e.tile.dispose?.();for(const e of this._cachedTiles.values())e.tile.dispose?.();this._tiles.clear(),this._cachedTiles.clear()}key(e){return i.key(e)}static key(e){return`${e.z}/${e.x}/${e.y}`}cacheCleaner(){const e=Date.now();for(const[t,i]of this._cachedTiles){const r=i.cacheTime0;void 0===r||e-r<=this._cacheAliveMilliSeconds||i.tile.loading||(i.tile.dispose?.(),this._cachedTiles.delete(t))}}touchTile(e){e.touch?.()}getTileAgeScore(e){const t=e.lastUsedAt??0,i=e.createdAt??t;return Math.min(t||i,i)}}t.XYZTileBuffer=i},2885:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382)),a=i(229);t.default=class{_hips;_tileno;_baseurl;_order;_ready=!1;_format;_isGalacticHips;opacity=1;_hipsShaderIndex=0;_pixels=[];_texture=null;_image;_texurl="";vertexPosition;vertexPositionBuffer;vertexIndices;vertexIndexBuffer;_tileBuffer;_hipsShaderProgram;_webgl;constructor(e,t,i,r,s,a){this._hipsShaderProgram=s,this._tileBuffer=r,this._hips=i,this._tileno=e,this._webgl=a,this._format=i.format,this._baseurl=i.baseURL,this._isGalacticHips=i.isGalacticHips,this._order=t,this.initImage()}destroyIntervals(){}initImage(){const e=1e4*Math.floor(this._tileno/1e4);this._texurl=`${this._baseurl}/Norder${this._order}/Dir${e}/Npix${this._tileno}.${this._format}`,this._image=new Image,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{console.error("File not found? %s",this._texurl)},this._image.crossOrigin="anonymous",this._image.src=this._texurl}imageLoaded(){this.textureLoaded(),this.initModelBuffer();const e=this._webgl;e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.bindTexture(e.TEXTURE_2D,this._texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._image),this._ready=!0}textureLoaded(){this._hipsShaderProgram.enableProgram();const e=this._webgl;this._texture=e.createTexture(),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.bindTexture(e.TEXTURE_2D,this._texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.isTexture(this._texture)||console.log("error in texture")}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=a.fovHelper.getRefOrder(this._order),i=s.default.getHealpix(this._order).nest2xyf(this._tileno),r=t-this._order,o=i.ix<<r,n=(i.ix<<r)+(1<<r),h=i.iy<<r,l=(i.iy<<r)+(1<<r),c=s.default.getHealpix(t);this._pixels=[],this.setupPositionAndTexture4Quadrant(o,n/2,h,l/2,0,c,r,i),this.setupPositionAndTexture4Quadrant(n/2,n,h,l/2,1,c,r,i),this.setupPositionAndTexture4Quadrant(o,n/2,l/2,l,2,c,r,i),this.setupPositionAndTexture4Quadrant(n/2,n,l/2,l,3,c,r,i);const u=this.vertexPosition[0].length/20;this.vertexIndices=this.computeVertexIndices(u),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint16Array(6*e);let i=0;for(let r=0;r<e;r++)t[6*r]=i,t[6*r+1]=i+1,t[6*r+2]=i+2,t[6*r+3]=i+2,t[6*r+4]=i+3,t[6*r+5]=i,i+=4;return t}setupPositionAndTexture4Quadrant2(e,t,i,r,s,a,o,n){this.vertexPosition[s]=new Float32Array(20*(t-e)*(r-i));const h=1/(1<<o);let l=0;for(let c=e;c<t;c++)for(let e=i;e<r;e++){const t=a.getPointsForXyfNoStep(c,e,n.face),i=e-(n.iy<<o),r=c-(n.ix<<o);this.vertexPosition[s][20*l]=t[0].x,this.vertexPosition[s][20*l+1]=t[0].y,this.vertexPosition[s][20*l+2]=t[0].z,this.vertexPosition[s][20*l+3]=h+h*i,this.vertexPosition[s][20*l+4]=1-(h+h*r),this.vertexPosition[s][20*l+5]=t[1].x,this.vertexPosition[s][20*l+6]=t[1].y,this.vertexPosition[s][20*l+7]=t[1].z,this.vertexPosition[s][20*l+8]=h+h*i,this.vertexPosition[s][20*l+9]=1-h*r,this.vertexPosition[s][20*l+10]=t[2].x,this.vertexPosition[s][20*l+11]=t[2].y,this.vertexPosition[s][20*l+12]=t[2].z,this.vertexPosition[s][20*l+13]=h*i,this.vertexPosition[s][20*l+14]=1-h*r,this.vertexPosition[s][20*l+15]=t[3].x,this.vertexPosition[s][20*l+16]=t[3].y,this.vertexPosition[s][20*l+17]=t[3].z,this.vertexPosition[s][20*l+18]=h*i,this.vertexPosition[s][20*l+19]=1-(h+h*r),l++}this.vertexPositionBuffer[s]=this._webgl.createBuffer(),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexPositionBuffer[s]),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexPosition[s],this._webgl.STATIC_DRAW)}setupPositionAndTexture4Quadrant(e,t,i,r,s,a,o,n){const h=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(r-i));const l=1/(1<<o);let c=0;for(let h=e;h<t;h++)for(let e=i;e<r;e++){const t=a.xyf2nest(h,e,n.face);this._pixels.push(t);const i=a.getBoundaries(t),r=e-(n.iy<<o),u=h-(n.ix<<o);this.vertexPosition[s][20*c]=i[0].x,this.vertexPosition[s][20*c+1]=i[0].y,this.vertexPosition[s][20*c+2]=i[0].z,this.vertexPosition[s][20*c+3]=l+l*r,this.vertexPosition[s][20*c+4]=1-(l+l*u),this.vertexPosition[s][20*c+5]=i[1].x,this.vertexPosition[s][20*c+6]=i[1].y,this.vertexPosition[s][20*c+7]=i[1].z,this.vertexPosition[s][20*c+8]=l+l*r,this.vertexPosition[s][20*c+9]=1-l*u,this.vertexPosition[s][20*c+10]=i[2].x,this.vertexPosition[s][20*c+11]=i[2].y,this.vertexPosition[s][20*c+12]=i[2].z,this.vertexPosition[s][20*c+13]=l*r,this.vertexPosition[s][20*c+14]=1-l*u,this.vertexPosition[s][20*c+15]=i[3].x,this.vertexPosition[s][20*c+16]=i[3].y,this.vertexPosition[s][20*c+17]=i[3].z,this.vertexPosition[s][20*c+18]=l*r,this.vertexPosition[s][20*c+19]=1-(l+l*u),c++}this.vertexPositionBuffer[s]=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,this.vertexPositionBuffer[s]),h.bufferData(h.ARRAY_BUFFER,this.vertexPosition[s],h.STATIC_DRAW)}draw(e,t,i,r,s,a){if(!this._ready)return!1;let o=new Set([0,1,2,3]);if(e>this._order){const n=this.drawChildren(e,t,i,r,s,a);n&&(o=n)}this._hipsShaderProgram.enableShaders(i,r,s,a);const n=this._webgl;n.enableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.enableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),n.activeTexture(n.TEXTURE0+this._hipsShaderIndex),n.bindTexture(n.TEXTURE_2D,this._texture),n.uniform1f(this._hipsShaderProgram.locations.textureAlpha,this.opacity),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);const h=this.vertexIndices.length;return o.forEach(e=>{n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBuffer[e]),n.vertexAttribPointer(this._hipsShaderProgram.locations.vertexPositionAttribute,3,n.FLOAT,!1,20,0),n.vertexAttribPointer(this._hipsShaderProgram.locations.textureCoordAttribute,2,n.FLOAT,!1,20,12),n.drawElements(n.TRIANGLES,h,n.UNSIGNED_SHORT,0)}),n.disableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.disableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),!0}drawChildren(e,t,i,r,s,a){const o=new Set([0,1,2,3]),n=this._order+1;if(t.has(n)){for(let h=0;h<4;h++){const l=(this._tileno<<2)+h;if(t.get(n).includes(l)){const h=this._isGalacticHips?this._tileBuffer.getGalTile(l,n,this._hips):this._tileBuffer.getTile(l,n,this._hips);h.draw(e,t,i,r,s,a,this._hipsShaderProgram),h._ready&&o.delete(h._tileno-(this._tileno<<2))}}return o}}}},2919:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bootSetup=t.tapRepos=t.hipsNodes=void 0,t.hipsNodes=["https://skies.esac.esa.int/","https://alasky.cds.unistra.fr/"],t.tapRepos=["https://sky.esa.int/esasky-tap/tap/"],t.bootSetup={insideSphere:!1,defaultHips:"",camera_fov_deg:34,camera_fov_rad:34*Math.PI/180,inside_camera_fov_deg:60,inside_camera_fov_rad:60*Math.PI/180,camera_near_plane:1e-5,camera_far_plane:2.5,corsProxyUrl:"http://localhost:4000/",useCORSProxy:!1,maxDecimals:15,defaultHipsUrl:"https://cdn.skies.esac.esa.int/DSSColor/",version:"Astrobrowser v1.0.0",debug:!1,insideView:!1,showViewfinder:!0}},2930:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(6553),a=r(i(7559)),o=i(8145);class n{static orthodromicDistance(e,t){return Math.acos(Math.sin(e.decDeg*Math.PI/180)*Math.sin(t.decDeg*Math.PI/180)+Math.cos(e.decDeg*Math.PI/180)*Math.cos(t.decDeg*Math.PI/180)*Math.cos((t.raDeg-e.raDeg)*Math.PI/180))}static computeSelectionObject(e){let t,i,r,s,o=[],h=0,l=0;if(e[0][0].decDeg>=10?l=1:e[0][0].decDeg<=-10?l=-1:h=1,0===h){const a=n.projectIn2D(e[0][0]);t=r=a.x,i=s=a.y;for(const a of e){const e=[];for(const c of a){if(c.decDeg>10*l&&-1===l||c.decDeg<10*l&&1===l){h=1,o=[];break}const a=n.projectIn2D(c);e.push(a),a.x>t&&(t=a.x),a.y>i&&(i=a.y),a.x<r&&(r=a.x),a.y<s&&(s=a.y)}o.push(e)}}if(0===h)return{poly4selection:o,flag:h,maxx:t,maxy:i,minx:r,miny:s};const c=180;let u=e[0][0].raDeg<c;t=r=e[0][0].raDeg,i=s=e[0][0].decDeg;for(const n of e){const e=[];for(const l of n){const n=new a.default(l.raDeg,l.decDeg);if(e.push(n),l.raDeg>t&&(t=l.raDeg),l.decDeg>i&&(i=l.decDeg),l.raDeg<r&&(r=l.raDeg),l.decDeg<s&&(s=l.decDeg),l.raDeg>=c&&u||l.raDeg<=c&&!u){h=2,o=[];break}}o.push(e)}if(1===h)return{poly4selection:o,flag:h,maxx:t,maxy:i,minx:r,miny:s};let d=e[0][0].raDeg;t=d>=c?d-360:d,i=e[0][0].decDeg,r=t,s=i;for(const n of e){const e=[];for(const o of n){const n=o.raDeg>=c?o.raDeg-360:o.raDeg;n>t&&(t=n),o.decDeg>i&&(i=o.decDeg),n<r&&(r=n),o.decDeg<s&&(s=o.decDeg),e.push(new a.default(n,o.decDeg))}o.push(e)}return{poly4selection:o,flag:h,maxx:t,maxy:i,minx:r,miny:s}}static stereographic(e){const t=Number(e.xyz[0]),i=Number(e.xyz[1]),r=Number(e.xyz[2]);return{x:2*t/(1-r),y:2*i/(1-r)}}static projectIn2D(e){const t=n.stereographic(e);return new a.default(t.x,t.y)}static checkPointInsidePolygon5(e,t){let i;if(0===e.flag)i=n.projectIn2D(t);else if(1===e.flag)i=new a.default(t.raDeg,t.decDeg);else{const e=180,r=t.raDeg>=e?t.raDeg-360:t.raDeg;i=new a.default(r,t.decDeg)}const r=new a.default(i.x,i.y+2*Math.abs(e.maxy-e.miny));if(i.x>e.maxx||i.x<e.minx||i.y>e.maxy||i.y<e.miny)return!1;for(const t of e.poly4selection){let e=0;for(let s=0;s<t.length-1;s++){const a=t[s],o=t[s+1],n=(o.y-a.y)*(r.x-i.x)-(o.x-a.x)*(r.y-i.y),h=(o.x-a.x)*(i.y-a.y)-(o.y-a.y)*(i.x-a.x),l=(r.x-i.x)*(i.y-a.y)-(r.y-i.y)*(i.x-a.x);if(0!==n){const t=h/n,i=l/n;t>=0&&t<=1&&i>=0&&i<=1&&e++}}{const s=t[t.length-1],a=t[0],o=(a.y-s.y)*(r.x-i.x)-(a.x-s.x)*(r.y-i.y),n=(a.x-s.x)*(i.y-s.y)-(a.y-s.y)*(i.x-s.x),h=(r.x-i.x)*(i.y-s.y)-(r.y-i.y)*(i.x-s.x);if(0!==o){const t=n/o,i=h/o;t>=0&&t<=1&&i>=0&&i<=1&&e++}}if(e%2==1)return!0}return!1}static checkPointInsidePolygon4(e,t){const i=n.projectIn2D(t);let r=t.raDeg+15;r>360&&(r=t.raDeg-15);const a=new s.Point({raDeg:r,decDeg:t.decDeg},o.CoordsType.ASTRO),h=n.projectIn2D(a);for(const t of e){let e=0;for(let r=0;r<t.length-1;r++){const s=n.projectIn2D(t[r]),a=n.projectIn2D(t[r+1]),o=(a.y-s.y)*(h.x-i.x)-(a.x-s.x)*(h.y-i.y),l=(a.x-s.x)*(i.y-s.y)-(a.y-s.y)*(i.x-s.x),c=(h.x-i.x)*(i.y-s.y)-(h.y-i.y)*(i.x-s.x);if(0!==o){const t=l/o,i=c/o;t>=0&&t<=1&&i>=0&&i<=1&&e++}}{const r=n.projectIn2D(t[t.length-1]),s=n.projectIn2D(t[0]),a=(s.y-r.y)*(h.x-i.x)-(s.x-r.x)*(h.y-i.y),o=(s.x-r.x)*(i.y-r.y)-(s.y-r.y)*(i.x-r.x),l=(h.x-i.x)*(i.y-r.y)-(h.y-i.y)*(i.x-r.x);if(0!==a){const t=o/a,i=l/a;t>=0&&t<=1&&i>=0&&i<=1&&e++}}if(e%2==1)return!0}return!1}}t.default=n},3174:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZAncestorTile=t.XYZAnchestorTile=void 0;const r=i(8819),s=i(1375);class a extends s.XYZTile{_ancestorMeshBuilder;_ancestorWebgl;_segmentsPerSide;_meshCache=new Map;constructor(e,t,i,s,a=new r.XYZMeshBuilder,o=16){super(e,t,i,s,a,o),this._ancestorMeshBuilder=a,this._ancestorWebgl=i,this._segmentsPerSide=o}draw(e,t,i,r,s,a,o){if("number"!=typeof e)return super.draw(e,t,i,r);if(!s||!a||void 0===o)return!1;const n=t,h=i,l=r;let c=!1;if(e<=this.coord.z)return super.draw(l,s,a,o);for(const e of n){if(!this.isAncestorOf(e))continue;const t=`${this.coord.z}/${this.coord.x}/${this.coord.y}`;if(!h.has(t))continue;const i=this.getRemappedMesh(e);c=super.drawRemapped(i,l,s,a,o)||c}return c}dispose(){for(const e of this._meshCache.values())e.positionBuffer&&this._ancestorWebgl.deleteBuffer(e.positionBuffer),e.uvBuffer&&this._ancestorWebgl.deleteBuffer(e.uvBuffer),e.indexBuffer&&this._ancestorWebgl.deleteBuffer(e.indexBuffer);this._meshCache.clear(),super.dispose()}getRemappedMesh(e){const t=`${e.z}/${e.x}/${e.y}->${this.coord.z}/${this.coord.x}/${this.coord.y}`,i=this._meshCache.get(t);if(i)return i;const r=this._ancestorMeshBuilder.buildAncestorMesh(e,this.coord,this._segmentsPerSide),s=this._ancestorMeshBuilder.uploadMesh(r,this._ancestorWebgl);return this._meshCache.set(t,s),s}isAncestorOf(e){if(e.z<=this.coord.z)return e.z===this.coord.z&&e.x===this.coord.x&&e.y===this.coord.y;const t=e.z-this.coord.z;return e.x>>t===this.coord.x&&e.y>>t===this.coord.y}}t.XYZAnchestorTile=a,t.XYZAncestorTile=a},3559:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueShaderProgram=void 0;const s=i(1961),a=r(i(5947));t.CatalogueShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix"},this.gl_attributes={vertex_pos:"aCatPosition",vertex_selected:"a_selected",point_size:"a_pointsize",point_hue:"a_brightness"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,hovered:-1,pointSize:-1,brightness:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=a.default.catalogueFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const i=a.default.catalogueVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),console.log("VS log:",e.getShaderInfoLog(this._vertexShader)||"ok"),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this.shaderProgram,this._vertexShader),e.attachShader(this.shaderProgram,this._fragmentShader),e.linkProgram(this.shaderProgram),e.getProgramParameter(this.shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this.shaderProgram),this.locations.position=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.hovered=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_selected),this.locations.pointSize=e.getAttribLocation(this.shaderProgram,this.gl_attributes.point_size),this.locations.brightness=e.getAttribLocation(this.shaderProgram,this.gl_attributes.point_hue),this.locations.color=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.vertex_color)):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableShaders(e,t,i){const r=this._webgl;r.useProgram(this.shaderProgram),this.locations.pMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let a=s.mat4.create();a=s.mat4.multiply(a,i,t),r.uniformMatrix4fv(this.locations.pMatrix,!1,e),r.uniformMatrix4fv(this.locations.mvMatrix,!1,a)}}},3726:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPS=void 0;const s=i(4735),a=i(229),o=r(i(619)),n=r(i(2885)),h=r(i(2368));class l extends s.AbstractSkyEntity{_ancestorTiles;_allSkyTile;_descriptor;_format;_baseurl;_maxorder;_minorder;_visibleorder=3;_allSky=!0;samplerIdx=0;colorMapIdx=0;colorMap=o.default.native;_healpixGrid;get maxOrder(){return this._maxorder}get minOrder(){return this._minorder}get baseURL(){return this._baseurl}get format(){return this._format}get propertiesRawText(){return this._descriptor.propertiesRawText}get properties(){return this._descriptor.properties}constructor(e,t,i,r,s,o,l){super(e,t,i,r,s.surveyName,o,s.isGalactic),this._descriptor=s,this.initGL(o),this._healpixGrid=l,this._healpixGrid.visibleTilesManager.tileBuffer.addHiPS(this),console.log("HiPS frame "+s.hipsFrame),console.log("HiPS minOrder "+s.minOrder),this._format=s.imgFormats[0],this._baseurl=s.url,this._maxorder=s.maxOrder,this._minorder=s.minOrder,this.initShaders();let c=a.fovHelper.getHiPSNorder(180);if(this._visibleorder=Math.min(c,this._maxorder),this._ancestorTiles=[],this._allSkyTile=null,this._allSky=!0,this._allSky)this._allSkyTile=new h.default(this,this._webgl,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram);else for(let e=0;e<12;e++)this._ancestorTiles.push(new n.default(e,0,this,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram,this._webgl))}getProperty(e){return this._descriptor.getProperty(e)}changeFormat(e){this._format=e,this._tileBuffer?.clearAll&&this._tileBuffer.clearAll(),this._tileBuffer&&(this._tileBuffer._format=this._format);const t=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder:this._healpixGrid.visibleTilesManager.visibleTilesByOrder;this._tileBuffer?.updateTiles&&this._tileBuffer.updateTiles(t.pixels,t.order)}changeColorMap(e){switch(console.log("HiPS.changeColorMap -> shaderProgram",super.hipsShaderProgram.shaderProgram),this.colorMap=e,e.name){case"grayscale":this.colorMapIdx=1,this.colorMap=o.default.grayscale,super.hipsShaderProgram.setGrayscaleShader();break;case"planck":this.colorMapIdx=2,this.colorMap=o.default.planck,super.hipsShaderProgram.setColorMapShader();break;case"cmb":this.colorMapIdx=3,this.colorMap=o.default.cmb,super.hipsShaderProgram.setColorMapShader();break;case"rainbow":this.colorMapIdx=4,this.colorMap=o.default.rainbow,super.hipsShaderProgram.setColorMapShader();break;case"eosb":this.colorMapIdx=5,this.colorMap=o.default.eosb,super.hipsShaderProgram.setColorMapShader();break;case"cubehelix":this.colorMapIdx=6,this.colorMap=o.default.cubehelix,super.hipsShaderProgram.setColorMapShader();break;case"hot":this.colorMapIdx=7,this.colorMap=o.default.hot,super.hipsShaderProgram.setColorMapShader();break;case"gray":this.colorMapIdx=8,this.colorMap=o.default.gray,super.hipsShaderProgram.setColorMapShader();break;case"native":this.colorMapIdx=0,this.colorMap=o.default.native,super.hipsShaderProgram.setNativeShader();break;default:this.colorMapIdx=9,this.colorMap=e,super.hipsShaderProgram.setColorMapShader()}}initShaders(){super.hipsShaderProgram.enableProgram()}getCurrentHealpixOrder(){return this._visibleorder}getDebugStats(){const e=this._healpixGrid.visibleTilesManager.tileBuffer,t=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder:this._healpixGrid.visibleTilesManager.visibleTilesByOrder;return{activeBaseLayer:"hips",hipsName:this._descriptor.surveyName,hipsUrl:this._baseurl,isGalactic:this.isGalacticHips,currentOrder:t.order,visibleTileCount:t.pixels.length,activeTileCount:e.activeTileCount,cachedTileCount:e.cachedTileCount,cacheSize:e.size,readyTileCount:e.readyTileCount,loadingTileCount:e.loadingTileCount}}refresh(e){const t=e.fovDeg??this._healpixGrid.getMinFoV(),i=Number.isFinite(t)&&t>0?t:1e-6;this._visibleorder=Math.min(a.fovHelper.getHiPSNorder(i,this._visibleorder),this._maxorder)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const i=e.pMatrix;if(!i)return;this.refresh(e);const r=this.getModelMatrix();if(super.hipsShaderProgram.setRuntimeColorMap(this.colorMap),this._allSky&&this._allSkyTile)return void(this.isGalacticHips?this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.galAncestorsMap,i,t,r,this.colorMapIdx):this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.ancestorsMap,i,t,r,this.colorMapIdx));const s=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order:this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,a=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galAncestorsMap:this._healpixGrid.visibleTilesManager.ancestorsMap;this._ancestorTiles.forEach(e=>{e.draw(s,a,i,t,r,this.colorMapIdx)})}}t.HiPS=l},3956:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WMTSAdapter=void 0,t.WMTSAdapter=class{_config;constructor(e){this._config=e}toXYZLayerConfig(){const e=this.getInferredMaxZoom();return{urlTemplate:this._config.urlTemplate??this._config.baseUrl,minZoom:this._config.minZoom,maxZoom:e,segmentsPerSide:this._config.segmentsPerSide,tileSize:this._config.tileSize,maxCachedTiles:this._config.maxCachedTiles,subdomains:this._config.subdomains,attribution:this._config.attribution,flipY:this._config.flipY,urlResolver:e=>this.getTileUrl(e)}}getInferredMaxZoom(){const e=this._config.matrixLabels?.length??0,t=e>0?e-1:void 0;return null==t?this._config.maxZoom:null==this._config.maxZoom?t:Math.min(this._config.maxZoom,t)}getTileUrl(e){return"rest"===this._config.requestEncoding?this.buildRestUrl(e):this.buildKvpUrl(e)}buildRestUrl(e){var t,i;return(t=this._config.urlTemplate??this._config.baseUrl,i=this.getCommonTokenValues(e),Object.entries(i).reduce((e,[t,i])=>e.replace(new RegExp(`\\{${t}\\}`,"g"),i),t)).replace(/(?<!:)\/{2,}/g,"/")}buildKvpUrl(e){const t=new URL(this._config.baseUrl),i=this.getCommonTokenValues(e),r=t.searchParams;r.set("SERVICE","WMTS"),r.set("REQUEST","GetTile"),r.set("VERSION",this._config.version??"1.0.0"),r.set("LAYER",this._config.layer),r.set("STYLE",this._config.style??"default"),r.set("FORMAT",this._config.format??"image/png"),r.set("TILEMATRIXSET",this._config.tileMatrixSet),r.set("TILEMATRIX",i.TileMatrix),r.set("TILEROW",i.TileRow),r.set("TILECOL",i.TileCol);for(const[e,t]of Object.entries(this._config.dimensions??{}))r.set(e,t);return t.toString()}getCommonTokenValues(e){const t=2**e.z,i=this._config.flipY?t-1-e.y:e.y,r=this._config.matrixLabels?.[e.z]??String(e.z),s=this._config.format??"image/png",a=s.replace(/^image\//,"");return{Layer:this._config.layer,Style:this._config.style??"default",Time:this._config.time??"",TileMatrixSet:this._config.tileMatrixSet,TileMatrix:r,TileRow:String(i),TileCol:String(e.x),Format:a,TileFormat:s,TileFormatExtension:a,...Object.fromEntries(Object.entries(this._config.dimensions??{}).map(([e,t])=>[e,t]))}}}},4006:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TileBuffer=void 0;const s=r(i(8256));t.TileBuffer=class{_tiles;_cachedTiles;_activeHiPS;_galTiles;_galCachedTiles;_galActiveHiPS;_cacheAliveMilliSeconds;_cleanerId;_webgl;_visibleTileManager;_hipsShaderProgram;constructor(e=1,t,i,r){this._hipsShaderProgram=i,this._visibleTileManager=r,this._webgl=t,this._tiles=new Map,this._cachedTiles=new Map,this._activeHiPS=new Map,this._galTiles=new Map,this._galCachedTiles=new Map,this._galActiveHiPS=new Map,this._cacheAliveMilliSeconds=60*e*1e3,this._cleanerId=window.setInterval(()=>{this.cacheCleaner()},1e4)}addHiPS(e){this._activeHiPS.has(e)?console.error("HiPS already present in TileBuffer"):this._activeHiPS.set(e,new Map)}addGalHiPS(e){this._galActiveHiPS.has(e)?console.error("HiPS already present in TileBuffer"):this._galActiveHiPS.set(e,new Map)}addTile(e,t){for(const i of this._activeHiPS.keys())e>i.maxOrder||this.getTile(t,e,i)}addGalTile(e,t){for(const i of this._galActiveHiPS.keys())e>i.maxOrder||this.getGalTile(t,e,i)}getTile(e,t,i){const r=this.key(t,e,i.baseURL);if(!this._tiles.has(r))if(this._cachedTiles.has(r)){const e=this._cachedTiles.get(r);this._tiles.set(r,e),this._cachedTiles.delete(r),e.resetCacheTime0()}else{const a=new s.default(e,t,i,this,this._webgl,this._visibleTileManager);this._tiles.set(r,a)}return this._tiles.get(r)}getGalTile(e,t,i){const r=this.key(t,e,i.baseURL);if(!this._galTiles.has(r))if(this._galCachedTiles.has(r)){const e=this._galCachedTiles.get(r);this._galTiles.set(r,e),this._galCachedTiles.delete(r),e.resetCacheTime0()}else{const a=new s.default(e,t,i,this,this._webgl,this._visibleTileManager);this._galTiles.set(r,a)}return this._galTiles.get(r)}moveTileToCache(e,t,i){const r=this.key(t,e,i.baseURL);if(this._tiles.has(r)){const e=this._tiles.get(r);e.setCacheTime0(),this._cachedTiles.set(r,e),this._tiles.delete(r)}if(this._galTiles.has(r)){const e=this._galTiles.get(r);e.setCacheTime0(),this._galCachedTiles.set(r,e),this._galTiles.delete(r)}}cacheCleaner(){const e=Date.now();for(const[t,i]of this._cachedTiles){const r=i.cacheTime0;!i.inView&&void 0!==r&&e-r>this._cacheAliveMilliSeconds&&(i.destroyIntervals(),this._cachedTiles.delete(t))}for(const[t,i]of this._galCachedTiles){const r=i.cacheTime0;!i.inView&&void 0!==r&&e-r>this._cacheAliveMilliSeconds&&(i.destroyIntervals(),this._galCachedTiles.delete(t))}}key(e,t,i){return`${e}#${t}#${i}`}dispose(){window.clearInterval(this._cleanerId)}get size(){return this._tiles.size+this._cachedTiles.size+this._galTiles.size+this._galCachedTiles.size}get activeTileCount(){return this._tiles.size+this._galTiles.size}get cachedTileCount(){return this._cachedTiles.size+this._galCachedTiles.size}get readyTileCount(){let e=0;for(const t of this._tiles.values())t.getReadyState()&&e++;for(const t of this._galTiles.values())t.getReadyState()&&e++;for(const t of this._cachedTiles.values())t.getReadyState()&&e++;for(const t of this._galCachedTiles.values())t.getReadyState()&&e++;return e}get loadingTileCount(){let e=0;for(const t of this._tiles.values())t.isLoading()&&e++;for(const t of this._galTiles.values())t.isLoading()&&e++;for(const t of this._cachedTiles.values())t.isLoading()&&e++;for(const t of this._galCachedTiles.values())t.isLoading()&&e++;return e}}},4382:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const r=i(1138),s=i(2919),a=new class{_healpix;_selectionnside;_useCORSProxy;_corsProxyUrl;_maxDecimals;_debug;_insideSphere;_version;constructor(){this._useCORSProxy=s.bootSetup.useCORSProxy,this._corsProxyUrl=s.bootSetup.corsProxyUrl,this._maxDecimals=s.bootSetup.maxDecimals,this._debug=s.bootSetup.debug,this._insideSphere=s.bootSetup.insideView,this._version=s.bootSetup.version,this._healpix={},this._selectionnside=32}init(){console.log("Global.init()")}get version(){return this._version}set corsProxyUrl(e){this._corsProxyUrl=e}get corsProxyUrl(){return this._corsProxyUrl}get useCORSProxy(){return this._useCORSProxy}set useCORSProxy(e){this._useCORSProxy=e}get debug(){return this._debug}getHealpix(e){return void 0===this._healpix[e]&&(this._healpix[e]=new r.Healpix(Math.pow(2,e))),this._healpix[e]}get MAX_DECIMALS(){return this._maxDecimals}set insideSphere(e){this._insideSphere=e}get insideSphere(){return this._insideSphere}get nsideForSelection(){return this._selectionnside}};t.default=a},4396:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(1961),a=i(1138),o=r(i(4382)),n=i(7930);t.default=class{_xyz=null;_raDecDeg=null;_phiThetaDeg=null;raHMS;decDMS;constructor(e,t,i){null!=e&&(this._xyz=e),null!=t&&(this._raDecDeg=t),null!=i&&(this._phiThetaDeg=i),this._raDecDeg&&(this.raHMS=(0,n.raDegToHMS)(this._raDecDeg.ra),this.decDMS=(0,n.decDegToDMS)(this._raDecDeg.dec))}computeNpix(){if(!this._xyz)return null;const e=o.default.getHealpix(o.default.nsideForSelection),t=new a.Vec3(this._xyz[0],this._xyz[1],this._xyz[2]),i=new a.Pointing(t,!1);return e.ang2pix(i,!1)}update(e){const t=(i=e,Array.isArray(i)?s.vec3.fromValues(i[0],i[1],i[2]):i);var i;const r=(0,n.cartesianToSpherical)(t),a=(0,n.sphericalToAstroDeg)(r.phi,r.theta);this._xyz=[t[0],t[1],t[2]],this._phiThetaDeg=r,this._raDecDeg=a,this.raHMS=(0,n.raDegToHMS)(a.ra),this.decDMS=(0,n.decDegToDMS)(a.dec)}clear(){this._xyz=null,this._raDecDeg=null,this._phiThetaDeg=null,this.raHMS=void 0,this.decDMS=void 0}get xyz(){return this._xyz}get x(){return this._xyz?this._xyz[0]:null}get y(){return this._xyz?this._xyz[1]:null}get z(){return this._xyz?this._xyz[2]:null}get ra(){return this._raDecDeg?this._raDecDeg.ra:null}get dec(){return this._raDecDeg?this._raDecDeg.dec:null}get phi(){return this._phiThetaDeg?this._phiThetaDeg.phi:null}get theta(){return this._phiThetaDeg?this._phiThetaDeg.theta:null}get raDecDeg(){return this._raDecDeg}get phiThetaDeg(){return this._phiThetaDeg}}},4595:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HealpixGrid=void 0;const s=i(4735),a=r(i(4382)),o=i(1961),n=i(229),h=i(8083),l=i(5803),c=i(8145),u=i(6553),d=r(i(4707)),_=r(i(2930)),f=r(i(5361)),g=i(7930),p=i(2056),m=i(2919);class x extends s.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_visibleorder=0;showGrid=!1;_shaderProgram;fragmentShader;vertexShader;defaultColor="#ec0acaff";gridText=new f.default("healpix");_attribLocations={position:0,selected:1,pointSize:2,color:3};_nPrimitiveFlags=0;_vertexCataloguePositionBuffer;_indexBuffer;_vertexCataloguePosition=new Float32Array(0);_indexes=new Uint32Array(0);_fovObj;static INITIAL_FOV=180;static RADIUS=1;static INITIAL_POSITION=[0,0,0];static INITIAL_PhiRad=0;static INITIAL_ThetaRad=0;_visibleTilesManager;constructor(e){super(x.RADIUS,x.INITIAL_POSITION,x.INITIAL_PhiRad,x.INITIAL_ThetaRad,"healpix-grid",e),this.init(),this._visibleTilesManager=new p.VisibleTilesManager(this._webgl,super.hipsShaderProgram,this),this._visibleTilesManager.init(m.bootSetup.insideSphere)}init(){console.log("HealpixGridSingleton.init()"),this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders();const e=n.fovHelper.getHiPSNorder(x.INITIAL_FOV);this._visibleorder=e,this._nPrimitiveFlags=0,this._vertexCataloguePositionBuffer=super.webgl.createBuffer(),this._indexBuffer=super.webgl.createBuffer(),this._vertexCataloguePosition=new Float32Array(0),this._fovObj=new l.SphereFoV(super.webgl)}get fovObj(){return this._fovObj}get RADIUS(){return x.RADIUS}get INITIAL_POSITION(){return x.INITIAL_POSITION}get INITIAL_PhiRad(){return x.INITIAL_PhiRad}get INITIAL_ThetaRad(){return x.INITIAL_ThetaRad}refreshFoV(e,t){return this._fovObj.getFoV(a.default.insideSphere,this,e,t)}getFoV(){return this._fovObj}getMinFoV(){return this._fovObj.minFoV}initShaders(){const e=super.webgl,t=d.default.healpixGridFS();if(this.fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this.fragmentShader,t),e.compileShader(this.fragmentShader),!e.getShaderParameter(this.fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this.fragmentShader)||"Fragment shader compile error");const i=d.default.healpixGridVS();this.vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this.vertexShader,i),e.compileShader(this.vertexShader),e.getShaderParameter(this.vertexShader,e.COMPILE_STATUS)?(e.attachShader(this._shaderProgram,this.vertexShader),e.attachShader(this._shaderProgram,this.fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this._shaderProgram)):alert(e.getShaderInfoLog(this.vertexShader)||"Vertex shader compile error")}initBuffers(e,t){this._nPrimitiveFlags=0;const i=a.default.getHealpix(t),r=a.default.getHealpix(t+1),s=a.default.getHealpix(t+2);let o=0,n=0;this._indexes=new Uint32Array(17*e.length),this._vertexCataloguePosition=new Float32Array(48*e.length);for(let t=0;t<e.length;t++){const a=i.getBoundaries(e[t]),h=e[t]<<2,l=h+1,c=h+2,u=h+3,d=r.getBoundaries(h),_=r.getBoundaries(u),f=e=>{this._vertexCataloguePosition[o]=1*e.x,this._vertexCataloguePosition[o+1]=1*e.y,this._vertexCataloguePosition[o+2]=1*e.z,this._indexes[n]=Math.floor(o/3),n+=1,o+=3};f(a[0]);let g=3+(u<<2),p=s.getBoundaries(g);f(p[1]),f(_[1]);let m=2+(c<<2);p=s.getBoundaries(m),f(p[0]),f(a[1]),f(p[2]),f(d[1]);let x=h<<2;p=s.getBoundaries(x),f(p[1]),f(a[2]),f(p[3]),f(d[3]);let M=1+(l<<2);p=s.getBoundaries(M),f(p[2]),f(a[3]),f(p[0]),f(_[3]),p=s.getBoundaries(g),f(p[3]),this._indexes[n]=4294967295,this._nPrimitiveFlags+=1,n+=1}}refresh(e,t){this.refreshFoV(e,t);const i=this.getMinFoV();this._visibleorder=n.fovHelper.getHiPSNorder(i,this._visibleorder)}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const s=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),a=r.getUniformLocation(this._shaderProgram,"uPMatrix"),n=super.webgl.getUniformLocation(this._shaderProgram,"u_fragcolor");this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition");let h=o.mat4.create();if(h=o.mat4.multiply(h,i,e),s&&r.uniformMatrix4fv(s,!1,h),a&&r.uniformMatrix4fv(a,!1,t),n){const e=(0,g.colorHex2RGB)(this.defaultColor);r.uniform4f(n,e[0],e[1],e[2],1)}}isVisible(){return this.showGrid}toggleShowGrid(){this.showGrid=!this.showGrid}get visibleTilesManager(){return this._visibleTilesManager}draw(e){const t=super.webgl,i=this.getModelMatrix(),r=e.camera;if(!r)return;const s=r.getCameraMatrix(),l=e.pMatrix;if(!l)return;const d=e.fovDeg??this.getMinFoV(),f=Number.isFinite(d)&&d>0?d:1e-6;if(this._visibleorder=n.fovHelper.getHiPSNorder(f,this._visibleorder),!this.showGrid)return void this.gridText.resetDivSets();const g=this._visibleTilesManager.visibleTilesByOrder,p=g.pixels,m=g.order;this.initBuffers(p,m),this.enableShader(i,l,s),t.bindBuffer(t.ARRAY_BUFFER,this._vertexCataloguePositionBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertexCataloguePosition,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,x.ELEM_SIZE,t.FLOAT,!1,x.BYTES_X_ELEM*x.ELEM_SIZE,0),t.enableVertexAttribArray(this._attribLocations.position),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this._indexes,t.STATIC_DRAW),t.drawElements(t.LINE_LOOP,this._vertexCataloguePosition.length/3+this._nPrimitiveFlags,t.UNSIGNED_INT,0),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);let M=o.mat4.create();M=o.mat4.multiply(M,s,i);let v=o.mat4.create();v=o.mat4.multiply(v,l,M);const b=h.FoVUtils.getCenterJ2000(t.canvas,this,this._webgl,r,l),S=this.getMinFoV()*Math.PI/180/2;for(let e=0;e<p.length;e++){const i=a.default.getHealpix(this._visibleorder).pix2vec(p[e]),r=new u.Point({x:i.x,y:i.y,z:i.z},c.CoordsType.CARTESIAN);if(_.default.orthodromicDistance(b,r)<S){const r=[i.x,i.y,i.z,1],s=o.vec4.create();o.vec4.transformMat4(s,r,v),s[0]/=s[3],s[1]/=s[3];const a=t.canvas.getBoundingClientRect(),n=a.left+(.5*s[0]+.5)*a.width,h=a.top+(-.5*s[1]+.5)*a.height;this.gridText.addHPXDivSet(this._visibleorder+"/"+p[e],n,h)}}this.gridText.resetDivSets(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}get visibleorder(){return this._visibleorder}}t.HealpixGrid=x},4639:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const r=i(1961);class s{static lastNearestVisibleObjectIdx=-1;static getNearestVisibleObjectIdx(){return this.lastNearestVisibleObjectIdx}static getRayFromMouse(e,t,i,a,o){const n=a.canvas.getBoundingClientRect(),h=t,l=[2*e/n.width-1,1-2*h/n.height,-1,1],c=r.mat4.create();r.mat4.invert(c,i);const u=[0,0,0,0];s.mat4MultiplyVec4(c,l,u);const d=[u[0],u[1],-1,0],_=r.mat4.create();r.mat4.invert(_,o);const f=[0,0,0,0];s.mat4MultiplyVec4(_,d,f);const g=r.vec3.fromValues(f[0],f[1],f[2]);return r.vec3.normalize(g,g),g}static mat4MultiplyVec4(e,t,i){const r=t[0],s=t[1],a=t[2],o=t[3];return i[0]=e[0]*r+e[4]*s+e[8]*a+e[12]*o,i[1]=e[1]*r+e[5]*s+e[9]*a+e[13]*o,i[2]=e[2]*r+e[6]*s+e[10]*a+e[14]*o,i[3]=e[3]*r+e[7]*s+e[11]*a+e[15]*o,i}static raySphere(e,t,i){let s=-1;const a=r.vec3.create();r.vec3.subtract(a,e,i.center);const o=r.vec3.dot(t,a),n=o*o-(r.vec3.dot(a,a)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-o+e,i=-o-e;t<0&&i<0||(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-o;e>=0&&(s=e)}return s}static getIntersectionPointWithSingleModel(e,t,i,a,o,n){const h=o.getCameraMatrix(),l=s.getRayFromMouse(e,t,n,a,h),c=s.raySphere(o.getCameraPosition(),l,i);let u=[];if(c>=0){const e=r.vec3.create();r.vec3.scale(e,l,c),r.vec3.add(e,o.getCameraPosition(),e);const t=[e[0],e[1],e[2],1],a=[0,0,0,0];s.mat4MultiplyVec4(i.getModelMatrixInverse(),t,a),u=[a[0],a[1],a[2]]}return u}}t.default=s},4707:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{static healpixGridVS(){return"#version 300 es\n in vec4 aCatPosition;\n uniform mat4 uMVMatrix;\n uniform mat4 uPMatrix;\n\n void main() {\n gl_Position = uPMatrix * uMVMatrix * aCatPosition;\n gl_PointSize = 7.0;\n }"}static healpixGridFS(){return"#version 300 es\n precision mediump float;\n\n uniform vec4 u_fragcolor;\n out vec4 fragColor;\n\n void main() {\n // fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n fragColor = u_fragcolor;\n }"}}},4723:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(2919),a=r(i(7734)),o=r(i(4639)),n=r(i(4382)),h=r(i(4396)),l=i(7930),c=i(3726),u=i(9685),d=i(6553),_=i(8083),f=i(9839),g=i(4595),p=i(8145),m=r(i(619)),x=i(5409),M=i(3956),v=i(8868),b=i(1741),S=i(1961);class P{static MIN_WHEEL_SCALE=.85;static MAX_WHEEL_SCALE=1.8;_camera;_perspectiveMatrixManager;centralPoinCoords;mousePointCoords;canvas;_healpixGrid;_equatorialGrid;mouseHelper;mouseDown=!1;lastMouseX=null;lastMouseY=null;inertiaX=0;inertiaY=0;zoomInertia=0;pointerDownX=null;pointerDownY=null;pointerDownAt=0;_activeHiPS=null;_activeXYZ2=null;_activeBaseLayer=null;startup=!0;fov;activeCatalogues=[];activeFootprintSets=[];_webgl;_selectedColorMap;_cameraStatusChanged=!1;lastCameraChangedAt=0;lastCameraMotionAt=0;lastHoveredSource=null;lastHoveredCatalogue=null;zoomSensitivity=1;lockedEastWestRaDeg=null;lockedNorthSouthDecDeg=null;keepCameraNorthUp=!0;constructor(e,t){console.log("[AstroSphere] new instance for canvas",e.id),this._webgl=t,this.mouseHelper=new h.default,this.canvas=e,this._selectedColorMap=m.default.native,n.default.insideSphere=s.bootSetup.insideSphere,this.initCamera(),this._healpixGrid=new g.HealpixGrid(this._webgl),this._perspectiveMatrixManager=new u.PerspectiveMatrixManager(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._equatorialGrid=new f.EquatorialGrid(this._webgl,this._healpixGrid),this._equatorialGrid.init(this._healpixGrid.getMinFoV()),this.updateCentralPoint(),this.startup=!0,this.addEventListeners(e),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV)}initCamera(){s.bootSetup.insideSphere?this._camera=new a.default([0,0,-.005],!0):this._camera=new a.default([0,0,4],!1)}setCamera(e){this._camera=e}setCameraRotationSensitivity(e){this._camera.setRotationSensitivity(e)}getCameraRotationSensitivity(){return this._camera.getRotationSensitivity()}get healpixGrid(){return this._healpixGrid}get equatorialGrid(){return this._equatorialGrid}updateCentralPoint(){const e=this.getPhiThetaDeg(this.canvas),t=(0,l.sphericalToAstroDeg)(e.phi,e.theta),i=(0,l.raDegToHMS)(t.ra),r=(0,l.decDegToDMS)(t.dec);return this.centralPoinCoords={astroDeg:t,sphericalDeg:e,raHMS:i,decDMS:r},this.centralPoinCoords}updateLastMousePoint(){const e={phi:this.mouseHelper.phi,theta:this.mouseHelper.theta},t={ra:this.mouseHelper.ra,dec:this.mouseHelper.dec},i=this.mouseHelper.raHMS,r=this.mouseHelper.decDMS;return this.mousePointCoords={astroDeg:t,sphericalDeg:e,raHMS:i,decDMS:r},this.mousePointCoords}clearLastMousePoint(){this.mousePointCoords=void 0}getCentralPointCoordinates(){return this.centralPoinCoords}getLastMousePointCoordinates(){return this.mousePointCoords}clamp(e,t,i){return Math.min(i,Math.max(t,e))}computeZoomStep(e,t){const i=t<0?-1:1,r=this.clamp(Math.abs(t)/120,P.MIN_WHEEL_SCALE,P.MAX_WHEEL_SCALE);return i*this.clamp(.0012+.0025*Math.sqrt(Math.max(e,0)),.0012,.04)*r*this.zoomSensitivity}setZoomSensitivity(e){this.zoomSensitivity=this.clamp(e,.2,3)}getZoomSensitivity(){return this.zoomSensitivity}filterRotationDeltaByAstroLocks(e,t){const i=this._camera.isRotationLockedY(),r=this._camera.isRotationLockedX();if(!i&&!r)return{deltaX:e,deltaY:t};const s=o.default.getIntersectionPointWithSingleModel(this.canvas.clientWidth/2,this.canvas.clientHeight/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!s||s.length<3)return{deltaX:e,deltaY:t};const a=S.vec3.normalize(S.vec3.create(),S.vec3.fromValues(s[0],s[1],s[2])),n=S.vec3.fromValues(0,0,1),h=S.vec3.cross(S.vec3.create(),n,a);S.vec3.length(h)<1e-6?S.vec3.set(h,1,0,0):S.vec3.normalize(h,h);const l=S.vec3.scale(S.vec3.create(),a,S.vec3.dot(n,a)),c=S.vec3.subtract(S.vec3.create(),n,l);S.vec3.length(c)<1e-6&&S.vec3.cross(c,a,h),S.vec3.normalize(c,c);const u=this.projectModelDirectionToScreen(a,h),d=this.projectModelDirectionToScreen(a,c);if(!u||!d)return{deltaX:e,deltaY:t};let _=e,f=t;if(i){const e=_*u.x+f*u.y;_-=e*u.x,f-=e*u.y}if(r){const e=_*d.x+f*d.y;_-=e*d.x,f-=e*d.y}return{deltaX:_,deltaY:f}}projectModelDirectionToScreen(e,t){const i=S.vec3.scaleAndAdd(S.vec3.create(),e,t,.01),r=this.projectModelPointToScreen(e),s=this.projectModelPointToScreen(i);if(!r||!s)return null;const a=s.x-r.x,o=s.y-r.y,n=Math.hypot(a,o);return n<1e-6?null:{x:a/n,y:o/n}}projectModelPointToScreen(e){const t=this._camera.getCameraMatrix(),i=this._healpixGrid.getModelMatrix(),r=S.mat4.create(),s=S.mat4.create();S.mat4.multiply(r,t,i),S.mat4.multiply(s,this._perspectiveMatrixManager.pMatrix,r);const a=S.vec4.fromValues(e[0],e[1],e[2],1);return S.vec4.transformMat4(a,a,s),Math.abs(a[3])<1e-6?null:{x:a[0]/a[3],y:-a[1]/a[3]}}enforceAstronomicalRotationLocks(){if(null==this.lockedEastWestRaDeg&&null==this.lockedNorthSouthDecDeg)return!1;const e=this.updateCentralPoint();if(!e)return!1;const t=this.lockedEastWestRaDeg??e.astroDeg.ra,i=this.lockedNorthSouthDecDeg??e.astroDeg.dec;return(Math.abs(t-e.astroDeg.ra)>1e-6||Math.abs(i-e.astroDeg.dec)>1e-6)&&(this._camera.goTo(t,i),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}enforceCameraNorthUp(){if(!this.keepCameraNorthUp)return!1;const e=this.updateCentralPoint();return!!e&&(this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}emitCameraChanged(e){if(!this._activeHiPS)return;if(!this._healpixGrid?.fovObj)return;const t=this.getCurrentStatus();t&&this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:t,bubbles:!0,composed:!0}))}addEventListeners(e){n.default.debug&&console.log("[AstroSphere::addEventListeners]");const t=e.getBoundingClientRect();this.lastMouseX=t.left,this.lastMouseY=t.top,console.log("[AstroSphere] registering pointer and wheel listeners on canvas"),e.onpointerdown=t=>{e.setPointerCapture(t.pointerId),this.mouseDown=!0;const i=e.getBoundingClientRect();this.lastMouseX=t.clientX-i.left,this.lastMouseY=t.clientY-i.top,this.pointerDownX=this.lastMouseX,this.pointerDownY=this.lastMouseY,this.pointerDownAt=Date.now();const r=o.default.getIntersectionPointWithSingleModel(this.lastMouseX,this.lastMouseY,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return r&&r.length>0?(this.mouseHelper.update(r),this.updateLastMousePoint()):this.clearLastMousePoint(),t.preventDefault(),!1},e.onpointerup=t=>{if(e.releasePointerCapture(t.pointerId),this.mouseDown=!1,document.body.style.cursor="auto",0!==t.button)return t.preventDefault(),!1;const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top;this.lastMouseX=r,this.lastMouseY=s;const a=Math.hypot(r-(this.pointerDownX??r),s-(this.pointerDownY??s)),n=Date.now()-this.pointerDownAt;if(a<=4&&n<=250){const e=o.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(e&&e.length>0){this.mouseHelper.update(e),this.updateLastMousePoint();for(const e of this.activeCatalogues){const t=e.selectPrimarySourceFromClick(this.mouseHelper);t?.sources.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("source-clicked",{detail:{source:t.sources,selectionState:t.selectionState,catalogue:e},bubbles:!0,composed:!0}))}for(const e of this.activeFootprintSets){const t=e.selectPrimaryFootprintFromClick(this.mouseHelper);t?.footprints.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-clicked",{detail:{footprint:t.footprints,selectionState:t.selectionState,footprintSet:e},bubbles:!0,composed:!0}))}}}else this.clearLastMousePoint()},e.onpointermove=t=>{const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top,a=r,h=s;if(this._healpixGrid){if(this.mouseDown){document.body.style.cursor="grab";const t=n.default.insideSphere?-1:1,i=n.default.insideSphere?10:1,r=t*i*(a-(this.lastMouseX??a))*Math.PI/e.width,s=t*i*(h-(this.lastMouseY??h))*Math.PI/e.height,o=this.filterRotationDeltaByAstroLocks(r,s);this.inertiaX+=.1*o.deltaX,this.inertiaY+=.1*o.deltaY,this.updateCentralPoint()}else{const e=o.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);e&&e.length>0?(this.mouseHelper.update(e),this.updateLastMousePoint()):this.clearLastMousePoint()}this.centralPoinCoords||this.updateCentralPoint(),this.lastMouseX=a,this.lastMouseY=h,this._cameraStatusChanged=!0,t.preventDefault()}},e.onpointerleave=()=>{this.clearLastMousePoint(),this._cameraStatusChanged=!0,this.emitCameraChanged("pointerleave")},console.log("[AstroSphere] adding wheel event listener with passive: false"),e.addEventListener("wheel",e=>{const t=this._healpixGrid.getMinFoV(),i=this.computeZoomStep(t,e.deltaY);this.zoomInertia=0,this._camera.zoom(i),this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this._cameraStatusChanged=!0,this.emitCameraChanged("wheel"),e.preventDefault()},{passive:!1}),e.addEventListener("contextmenu",t=>{t.preventDefault();const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top,a=o.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!a||0===a.length)return!1;this.mouseHelper.update(a),this.updateLastMousePoint();for(const e of this.activeCatalogues){const i=e.getSourcesFromPointer(this.mouseHelper);if(i?.sources.length){this._webgl.canvas.dispatchEvent(new CustomEvent("source-contextmenu",{detail:{source:i.sources,catalogue:e,clientX:t.clientX,clientY:t.clientY},bubbles:!0,composed:!0}));break}}for(const e of this.activeFootprintSets){const i=e.getFootprintsFromPointer(this.mouseHelper);if(i?.footprints.length){this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-contextmenu",{detail:{footprint:i.footprints,footprintSet:e,clientX:t.clientX,clientY:t.clientY},bubbles:!0,composed:!0}));break}}return!1}),console.log("[AstroSphere] registering global keydown listener on document"),document.addEventListener("keydown",e=>{if(e.ctrlKey)switch(e.key){case"1":this._camera.clearRotationLock();break;case"2":this._camera.setRotationLock({x:!0,y:!1,z:!1});break;case"3":this._camera.setRotationLock({x:!1,y:!0,z:!1});break;case"4":this._camera.setRotationLock({x:!1,y:!1,z:!0})}},{capture:!0})}getPhiThetaDeg(e){const t=e.getBoundingClientRect(),i=t.width,r=t.height,s=o.default.getIntersectionPointWithSingleModel(i/2,r/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return(0,l.cartesianToSpherical)(s)}collectViewportSphericalSamples(e=5){const t=this.canvas.getBoundingClientRect(),i=t.width,r=t.height,s=[];for(let t=0;t<e;t++){const a=1===e?i/2:t/(e-1)*i;for(let t=0;t<e;t++){const i=1===e?r/2:t/(e-1)*r,n=o.default.getIntersectionPointWithSingleModel(a,i,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);n&&n.length>0&&s.push((0,l.cartesianToSpherical)(n))}}return s}activateHiPS(e){this._activeHiPS=new c.HiPS(1,[0,0,0],0,0,e,this._webgl,this._healpixGrid),this._activeBaseLayer="hips"}activateXYZ(e){this.activateXYZ2(new v.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver)),this._activeBaseLayer="xyz"}activateXYZ2(e){this._activeXYZ2=new b.XYZMap(1,[0,0,0],0,0,e,this._webgl),this._activeBaseLayer="xyz"}activateWMTS(e){const t=new M.WMTSAdapter(e).toXYZLayerConfig();this._activeXYZ2=new b.XYZMap(1,[0,0,0],0,0,new v.XYZMapDescriptor(e.layer?`WMTS ${e.layer}`:"WMTS Earth2 Layer",t.urlTemplate,t.minZoom??0,t.maxZoom??8,t.segmentsPerSide??48,t.maxCachedTiles??384,8,t.urlResolver),this._webgl),this._activeBaseLayer="xyz"}async showCatalogue(e){return e&&this.activeCatalogues.push(e),e}deleteCatalogue(e){this.activeCatalogues=this.activeCatalogues.filter(t=>t!==e)}async showFootprintSet(e){return e&&this.activeFootprintSets.push(e),e}deleteFootprintSet(e){this.activeFootprintSets=this.activeFootprintSets.filter(t=>t!==e)}getHoveredFootprints(){let e=[];return this.activeFootprintSets.forEach(t=>{e.push(t.hoveredFootprints)}),e}goTo(e,t){this._camera.goTo(e,t)}getActiveCoordinateMode(){return"xyz"===this._activeBaseLayer?"lonlat":"hips"===this._activeBaseLayer&&this._activeHiPS?.isGalacticHips?"galactic":"equatorial"}resetAxesOrientation(){const e=this.updateCentralPoint();e&&(this.inertiaX=0,this.inertiaY=0,this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),this._cameraStatusChanged=!0)}setKeepCameraNorthUp(e){this.keepCameraNorthUp=e,e&&this.resetAxesOrientation()}isKeepCameraNorthUp(){return this.keepCameraNorthUp}getFoV(){return"xyz"===this._activeBaseLayer&&this._activeXYZ2?this._activeXYZ2.getFoV():this.fov}getFoVPolygon(){if(null==this.healpixGrid)throw new Error(`healpixGrid is ${this.healpixGrid}`);return _.FoVUtils.getFoVPolygon(this._camera,this.canvas,this._healpixGrid,this._healpixGrid,this._webgl,this._perspectiveMatrixManager.pMatrix)}changeFoV(e){const t=this._healpixGrid.getFoV().computeDistanceFromAngle(e);this._camera.translate(t),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV)}changeFoV2(e){const t=this._healpixGrid.getFoV().computeCameraPositionForFoV(e);this._camera.setCameraPosition(t)}changeFoV3(e){const t=this._healpixGrid.getFoV().computeCameraPositionForAngularDiameter(e);this._camera.setCameraPosition(t),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,!1)}getInsideSphere(){return n.default.insideSphere}toggleInsideSphere(){const e=this.updateCentralPoint();this.inertiaX=0,this.inertiaY=0,this.zoomInertia=0,n.default.insideSphere=!n.default.insideSphere,this._camera.toggleInsideSphere(),this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.updateCentralPoint(),this.lastCameraMotionAt=performance.now(),this._cameraStatusChanged=!0,this.emitCameraChanged("inside-sphere-toggle"),requestAnimationFrame(()=>this.draw(this.canvas))}setCameraPosition(e){this._camera.setCameraPosition(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}setCameraMatrix(e){this._camera.setCameraMatrix(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}_refreshingStatus=!1;applyFullCameraState(e,t){this._refreshingStatus=!0,this._camera=e.camera,this._healpixGrid.setModelMatrix(e.mMatrix),this._perspectiveMatrixManager.pMatrix=e.pMatrix,this.setCameraMatrix(e.vMatrix),t&&this._activeHiPS?.changeColorMap(e.colorMap),this._refreshingStatus=!1}getCurrentStatus(){this.updateCentralPoint();const e=this.centralPoinCoords?.astroDeg.ra,t=this.centralPoinCoords?.astroDeg.dec;return null==e||null==t?null:{fovDeg:this.fov.minFoV,fovXDeg:this.fov.xFoV,fovYDeg:this.fov.yFoV,position:this._camera.getCameraPosition(),vMatrix:this._camera.getCameraMatrix(),pMatrix:this._perspectiveMatrixManager.pMatrix,mMatrix:this._healpixGrid.getModelMatrix(),camera:this._camera,timestamp:performance.now(),centralPoint:new d.Point({raDeg:e,decDeg:t},p.CoordsType.ASTRO),mouseHoverPoint:this.mousePointCoords,colorMap:this._selectedColorMap,getFoVPolygon:[]}}changeColorMap(e){(this._activeHiPS||this._activeXYZ2)&&(this._selectedColorMap=e,this._activeHiPS?.changeColorMap(e),this._activeXYZ2?.changeColorMap(e))}prevFov=0;prevCentralRaDeg=null;prevCentralDecDeg=null;get activeHiPS(){return this._activeHiPS}get activeXYZ(){return this._activeXYZ2}isLonLatGridVisible(){return this._activeXYZ2?.isLonLatGridVisible()??!1}toggleLonLatGrid(){return this._activeXYZ2?.toggleLonLatGrid()??!1}setEastWestRotationLocked(e){this._camera.setRotationLock({y:e}),e&&(this.inertiaX=0),this.lockedEastWestRaDeg=e?this.updateCentralPoint()?.astroDeg.ra??null:null}isEastWestRotationLocked(){return this._camera.isRotationLockedY()}setNorthSouthRotationLocked(e){this._camera.setRotationLock({x:e}),e&&(this.inertiaY=0),this.lockedNorthSouthDecDeg=e?this.updateCentralPoint()?.astroDeg.dec??null:null}isNorthSouthRotationLocked(){return this._camera.isRotationLockedX()}getXYZDebugStats(){return{activeBaseLayer:this._activeBaseLayer,layer:this._activeXYZ2?.getDebugStats()??null,requests:x.xyzTileRequestScheduler.getDebugStats()}}getHiPSDebugStats(){return this._activeHiPS?this._activeHiPS.getDebugStats():null}draw(e){if(this._refreshingStatus)return;if(!this._webgl)return;if(!this._activeHiPS&&!this._activeXYZ2)return;if(!this._healpixGrid||0===Object.keys(this._healpixGrid).length)return;if(void 0===this._healpixGrid.fovObj)return;this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere);let t=!1,i=0,r=0;if(this._webgl.viewport(0,0,this._webgl.drawingBufferWidth,this._webgl.drawingBufferHeight),this._webgl.clear(this._webgl.COLOR_BUFFER_BIT|this._webgl.DEPTH_BUFFER_BIT),0!==this.zoomInertia&&(Math.abs(this.zoomInertia)>1e-4?(this._camera.zoom(this.zoomInertia),this.zoomInertia*=.95,this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.prevFov!==this.fov.minFoV&&(this.centralPoinCoords||(this.centralPoinCoords=this.updateCentralPoint()),this.prevFov=this.fov.minFoV)):this.zoomInertia=0,this._cameraStatusChanged=!0),this.mouseDown||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02){t=!0;const a=this.filterRotationDeltaByAstroLocks(this.inertiaX,this.inertiaY);r=a.deltaX,i=a.deltaY,this.inertiaX=.95*a.deltaX,this.inertiaY=.95*a.deltaY,this._camera.rotate(r,i),this.lastCameraMotionAt=performance.now(),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.enforceAstronomicalRotationLocks()||this.enforceCameraNorthUp()}else this.inertiaY=0,this.inertiaX=0;const a=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix);if(Number.isFinite(a.minFoV)&&a.minFoV>0&&(this.fov=a,this._camera.refreshFoV(this.fov.minFoV),this.prevFov=this.fov.minFoV),t){const e=this.updateCentralPoint(),t=e.astroDeg.ra,i=e.astroDeg.dec,r=null===this.prevCentralRaDeg||Math.abs(t-this.prevCentralRaDeg)>1e-5,s=null===this.prevCentralDecDeg||Math.abs(i-this.prevCentralDecDeg)>1e-5;(r||s)&&(this.prevCentralRaDeg=t,this.prevCentralDecDeg=i)}if(this._cameraStatusChanged){const e=performance.now(),t=!this.mouseDown||e-this.lastCameraChangedAt>100,i=t?this.getCurrentStatus():null;i&&(this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:i,bubbles:!0,composed:!0})),this.lastCameraChangedAt=e),!this.startup&&t&&(this._cameraStatusChanged=!1)}if(this._webgl.disable(this._webgl.DEPTH_TEST),this._webgl.enable(this._webgl.BLEND),this._webgl.enable(this._webgl.CULL_FACE),this._webgl.cullFace(n.default.insideSphere?this._webgl.FRONT:this._webgl.BACK),this._webgl.blendFunc(this._webgl.SRC_ALPHA,this._webgl.ONE_MINUS_SRC_ALPHA),"hips"===this._activeBaseLayer&&this._activeHiPS){const e=Math.min(this._healpixGrid.visibleorder,this._activeHiPS.maxOrder);this._healpixGrid.visibleTilesManager.computeVisiblePixels(e,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix)}const o=this.fov?.minFoV??this._healpixGrid.getMinFoV(),h=performance.now(),c=this.mouseDown||Math.abs(this.zoomInertia)>1e-4||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02||h-this.lastCameraMotionAt<220,u={fovDeg:o,camera:this._camera,pMatrix:this._perspectiveMatrixManager.pMatrix,centerSphericalDeg:this.updateCentralPoint().sphericalDeg,fovPolygon:void 0,viewportSphericalSamples:void 0,cameraMoving:c};if("hips"===this._activeBaseLayer&&this._activeHiPS?.draw(u),"xyz"===this._activeBaseLayer&&this._activeXYZ2?.draw(u),this._healpixGrid.draw(u),this._equatorialGrid.draw(u),this._webgl.enable(this._webgl.DEPTH_TEST),this._webgl.disable(this._webgl.CULL_FACE),this.startup){this.startup=!1;const t=this.getPhiThetaDeg(e),i=(0,l.sphericalToAstroDeg)(t.phi,t.theta),r=(0,l.raDegToHMS)(i.ra),s=(0,l.decDegToDMS)(i.dec);this.prevFov=this.fov?.minFoV??this._healpixGrid.getMinFoV(),this._cameraStatusChanged=!0,console.log("(startup coords)",{raDeg:i.ra,decDeg:i.dec,raHMS:r,decDMS:s})}this.activeCatalogues.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.emitHoveredSourceIfChanged(),this.activeFootprintSets.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)})}emitHoveredSourceIfChanged(){let e=null,t=null;for(const i of this.activeCatalogues){const r=i.getPrimaryHoveredSource();if(r){e=r,t=i;break}}e===this.lastHoveredSource&&t===this.lastHoveredCatalogue||(this.lastHoveredSource=e,this.lastHoveredCatalogue=t,this._webgl.canvas.dispatchEvent(new CustomEvent("source-hovered",{detail:{source:e,catalogue:t},bubbles:!0,composed:!0})))}}t.default=P},4735:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractSkyEntity=void 0;const r=i(1961),s=i(7786);t.AbstractSkyEntity=class{refreshMe=!1;fovX_deg=180;fovY_deg=180;xRad;yRad;prevFoV=this.fovX_deg;_name;center;radius;isGalacticHips;vertexTextureCoordBuffer=null;vertexPositionBuffer=null;vertexIndexBuffer=null;shaderProgram=null;T=r.mat4.create();R=r.mat4.create();modelMatrix=r.mat4.create();inverseModelMatrix=r.mat4.create();galacticMatrixInverted=r.mat4.create();_webgl;_hipsShaderProgram;constructor(e,t,i,a,o,n,h){this._webgl=n,this.xRad=i,this.yRad=a,this._name=o,this.center=r.vec3.clone(t),this.radius=e,this.isGalacticHips=!!h,r.mat4.set(this.galacticMatrixInverted,-.054875582456588745,-.8734370470046997,-.48383501172065735,0,.49410945177078247,-.4448296129703522,.7469822764396667,0,-.8676661849021912,-.19807636737823486,.4559837877750397,0,0,0,0,1),this._hipsShaderProgram=new s.HiPSShaderProgram(this._webgl)}get name(){return this._name}get hipsShaderProgram(){return this._hipsShaderProgram}get webgl(){return this._webgl}initGL(e){this.vertexTextureCoordBuffer=e.createBuffer(),this.vertexPositionBuffer=e.createBuffer(),this.vertexIndexBuffer=e.createBuffer(),this.shaderProgram=e.createProgram(),this.T=r.mat4.create(),this.R=r.mat4.create(),this.modelMatrix=r.mat4.create(),this.inverseModelMatrix=r.mat4.create(),this.translate(this.center),this.rotate(this.xRad,this.yRad)}translate(e){r.mat4.translate(this.T,this.T,e),this.refreshModelMatrix()}rotate(e,t){r.mat4.rotate(this.R,this.R,t,[0,0,1]),r.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshModelMatrix()}rotateFromZero(e,t){r.mat4.identity(this.R),r.mat4.rotate(this.R,this.R,e,[1,0,0]),r.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshModelMatrix()}refreshModelMatrix(){const e=r.mat4.create();r.mat4.invert(e,this.R),r.mat4.multiply(this.modelMatrix,this.T,e),this.isGalacticHips&&r.mat4.multiply(this.modelMatrix,this.modelMatrix,this.galacticMatrixInverted)}getModelMatrixInverse(){return r.mat4.identity(this.inverseModelMatrix),r.mat4.invert(this.inverseModelMatrix,this.modelMatrix),this.inverseModelMatrix}getModelMatrix(){return this.modelMatrix}setModelMatrix(e){this.modelMatrix=e}setGeometryNeedsToBeRefreshed(){this.refreshGeometryOnFoVChanged=!1}rotateX(e,t){const i=Math.cos(t),r=Math.sin(t),s=e[1],a=e[5],o=e[9];return e[1]=e[1]*i-e[2]*r,e[5]=e[5]*i-e[6]*r,e[9]=e[9]*i-e[10]*r,e[2]=e[2]*i+s*r,e[6]=e[6]*i+a*r,e[10]=e[10]*i+o*r,e}rotateY(e,t){const i=Math.cos(t),r=Math.sin(t),s=e[0],a=e[4],o=e[8];return e[0]=i*e[0]+r*e[2],e[4]=i*e[4]+r*e[6],e[8]=i*e[8]+r*e[10],e[2]=i*e[2]-r*s,e[6]=i*e[6]-r*a,e[10]=i*e[10]-r*o,e}}},5087:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSDescriptor=void 0,t.HiPSDescriptor=class{_minOrder=3;_imgformats=[];_datarange={min:void 0,max:void 0};_maxOrder;_tilewidth;_hipsFrame;_hipsName="NONAME";_hipsurl;_emMin;_emMax;_isGalctic=!1;_propertiesRawText;_propertiesMap=new Map;constructor(e,t){this._hipsurl=t,this._propertiesRawText=e;const i=e.split(/\r\n|\n/);for(const e of i){const t=e.trim();if(!t||t.startsWith("#"))continue;const i=t.slice(0,t.indexOf("=")).trim(),r=this.getValue(t);if(i&&void 0!==r&&this._propertiesMap.set(i,r),t.startsWith("hips_tile_format")||t.startsWith("format")){const e=this.getValue(t)?.replace(/jpeg/gi,"jpg")??"";this._imgformats=e.split(/\s+/).filter(Boolean)}else if(t.startsWith("hips_data_range")){const e=this.getValue(t);if(e){const[t,i]=e.split(/\s+/);this._datarange.min=parseFloat(t),this._datarange.max=parseFloat(i)}}else if(t.startsWith("hips_tile_width")){const e=Number(this.getValue(t));this._tilewidth=Number.isFinite(e)?e:void 0}else if(t.startsWith("hips_order_min")){const e=Number(this.getValue(t));this._minOrder=Number.isFinite(e)?e:this._minOrder}else if(t.startsWith("hips_order")||t.startsWith("maxOrder")){const e=Number(this.getValue(t));this._maxOrder=Number.isFinite(e)?e:this._maxOrder}else if(t.startsWith("hips_frame")||t.startsWith("frame"))this._hipsFrame=this.getValue(t);else if(t.startsWith("obs_collection")||t.startsWith("label"))this._hipsName=this.getValue(t)??this._hipsName;else if(t.startsWith("em_min")){const e=Number(this.getValue(t));this._emMin=Number.isFinite(e)?e:void 0}else if(t.startsWith("em_max")){const e=Number(this.getValue(t));this._emMax=Number.isFinite(e)?e:void 0}}if(this._hipsName||console.warn(`[HiPSDescriptor] hipsName not defined in properties of ${this._hipsurl}. Defaulting to 'NONAME'.`),this._hipsFrame||(console.warn(`[HiPSDescriptor] hips_frame not defined in properties of ${this._hipsurl}. Defaulting to 'equatorial'.`),this._hipsFrame="equatorial"),this._isGalctic=this._hipsFrame.toLowerCase().includes("gal"),void 0===this._maxOrder||0===this._imgformats.length)throw new Error(`[HiPSDescriptor] Invalid properties for ${this._hipsurl}. maxOrder=${this._maxOrder}, imgFormats.length=${this._imgformats.length}`)}getValue(e){const t=e.indexOf("=");if(!(t<0))return e.slice(t+1).trim()}get propertiesRawText(){return this._propertiesRawText}get properties(){return new Map(this._propertiesMap)}getProperty(e){return this._propertiesMap.get(e)}get surveyName(){return this._hipsName}get url(){return this._hipsurl}get maxOrder(){return this._maxOrder}get minOrder(){return this._minOrder}get imgFormats(){return this._imgformats}get hipsFrame(){return this._hipsFrame}get isGalactic(){return this._isGalctic}get emMin(){return this._emMin}get emMax(){return this._emMax}get tileWidth(){return this._tilewidth}get dataRange(){return this._datarange}}},5361:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class i{static layers=new Map;layer;constructor(e="equatorial"){this.layer=e,i.getLayerState(e)}initHtml(){i.getLayerState(this.layer)}resetDivSets(e=this.layer){const t=i.getLayerState(e);for(;t.divSetNdx<t.divSets.length;++t.divSetNdx)t.divSets[t.divSetNdx].style.display="none";t.divSetNdx=0}addHPXDivSet(e,t,i){this.addLabel("healpix",e,t+25,i,"hpx")}addEqDivSet(e,t,i,r){this.addLabel("equatorial",e,"ra"===r?t+25:t,"ra"===r?i:i+25,r)}addLonLatDivSet(e,t,i,r){this.addLabel("lonlat",e,"lon"===r?t+25:t,"lon"===r?i:i+25,r)}addLabel(e,t,r,s,a){const o=i.getLayerState(e);if(!o.container)return;let n=o.divSets[o.divSetNdx++];if(!n){const e=document.createElement("div"),t=document.createTextNode("");e.appendChild(t),o.container.appendChild(e),n={div:e,textNode:t,style:e.style},o.divSets.push(n)}n.div.className=this.classNameForKind(a),n.style.display="block",n.style.left=`${Math.floor(r)}px`,n.style.top=`${Math.floor(s)}px`,n.textNode.nodeValue=t}classNameForKind(e){switch(e){case"dec":return"floating-div-dec";case"lat":return"floating-div-lat";case"lon":return"floating-div-lon";default:return"floating-div-ra"}}static getLayerState(e){const t=i.layers.get(e);if(t)return t.container||(t.container=i.resolveContainer(e)),t;const r={container:i.resolveContainer(e),divSets:[],divSetNdx:0};return i.layers.set(e,r),r}static resolveContainer(e){return"healpix"===e?document.querySelector("#gridhpx"):document.querySelector("#gridcoords")}}t.default=i},5403:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataManager=void 0;const r=i(1072);t.MetadataManager=class{static STANDARD_SIZE="STANDARD_SIZE";static STANDARD_HUE="STANDARD_HUE";_outlineColumnList=[];_raColumnList=[];_decColumnList=[];_shapeColumnList=[];_hueColumnList=[];_selectedOutlineColumn;_selectedRaColumn;_selectedDecColumn;_selectedShapeColumn;_selectedHueColumn;_selectedNameColumn;_columns=[];constructor(e){e.forEach(e=>{e.columnType==r.ColumnType.NUMBER&&(this.addHueColumn(e),this.addShapeColumn(e)),e.columnType==r.ColumnType.GEOM_RA&&this.addRaColumn(e),e.columnType==r.ColumnType.GEOM_DEC&&this.addDecColumn(e),e.columnType==r.ColumnType.GEOM_FOOTPRINT&&this.addOutlineColumn(e),e.columnType==r.ColumnType.MAIN_NAME&&(this._selectedNameColumn=e),this._columns.push(e)})}addOutlineColumn(e){this._outlineColumnList.push(e),this._selectedOutlineColumn=e}addRaColumn(e){this._selectedRaColumn=this._selectedRaColumn||e,this._raColumnList.push(e)}addDecColumn(e){this._selectedDecColumn=this._selectedDecColumn||e,this._decColumnList.push(e)}addHueColumn(e){this._hueColumnList.push(e)}addShapeColumn(e){this._shapeColumnList.push(e)}get selectedRaColumn(){return this._selectedRaColumn}get selectedDecColumn(){return this._selectedDecColumn}get selectedHueColumn(){return this._selectedHueColumn}get selectedShapeColumn(){return this._selectedShapeColumn}get selectedOutlineColumn(){return this._selectedOutlineColumn}get selectedNameColumn(){return this._selectedNameColumn}get columns(){return this._columns}get raColumnList(){return this._raColumnList}get decColumnList(){return this._decColumnList}get outlineColumnList(){return this._outlineColumnList}get hueColumnList(){return this._hueColumnList}get shapeColumnList(){return this._shapeColumnList}set selectedRaColumn(e){this._selectedRaColumn=this._raColumnList.find(t=>t.name===e)||this._selectedRaColumn}set selectedDecColumn(e){this._selectedDecColumn=this._decColumnList.find(t=>t.name===e)||this._selectedDecColumn}set selectedOutlineColumn(e){this._selectedOutlineColumn=this._outlineColumnList.find(t=>t.name===e)||this._selectedOutlineColumn}set selectedHueColumn(e){this._selectedHueColumn=this._hueColumnList.find(t=>t.name===e)}set selectedShapeColumn(e){this._selectedShapeColumn=this._shapeColumnList.find(t=>t.name===e)}set selectedNameColumn(e){this._selectedNameColumn=this._columns.find(t=>t.name===e)}resetShapeColumn(){this._selectedShapeColumn=void 0}resetHueColumn(){this._selectedHueColumn=void 0}}},5409:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.xyzTileRequestScheduler=t.XYZTileRequestScheduler=t.XYZTileRequestError=void 0;class i extends Error{cooldownMs;retryable;constructor(e,t,i=!0){super(e),this.name="XYZTileRequestError",this.cooldownMs=t,this.retryable=i}}t.XYZTileRequestError=i;class r{_maxConcurrent;_activeCount=0;_queue=[];_inflight=new Map;_hostBackoff=new Map;_sequence=0;constructor(e=4){this._maxConcurrent=e}setMaxConcurrent(e){this._maxConcurrent=Math.max(1,Math.floor(e)),this.pump()}getMaxConcurrent(){return this._maxConcurrent}getDebugStats(){const e=Date.now(),t=Array.from(this._hostBackoff.entries()).map(([t,i])=>({host:t,cooldownMs:Math.max(0,i.cooldownUntil-e),consecutiveFailures:i.consecutiveFailures})).filter(e=>e.cooldownMs>0||e.consecutiveFailures>0).sort((e,t)=>t.cooldownMs-e.cooldownMs);return{activeRequests:this._activeCount,queuedRequests:this._queue.length,inflightRequests:this._inflight.size,maxConcurrentRequests:this._maxConcurrent,highestQueuedPriority:this._queue[0]?.priority??null,hostsInBackoff:t}}load(e,t=0){const r=this._inflight.get(e);if(r)return r;const s=this.getHostCooldown(e),a=Date.now();if(s>a)return Promise.reject(new i(`Cooldown active for ${new URL(e).host}`,s-a));const o=new Promise((i,r)=>{this._queue.push({url:e,resolve:i,reject:r,priority:t,sequence:this._sequence++}),this._queue.sort((e,t)=>t.priority-e.priority||e.sequence-t.sequence),this.pump()}).finally(()=>{this._inflight.delete(e)});return this._inflight.set(e,o),o}pump(){for(;this._activeCount<this._maxConcurrent&&this._queue.length>0;){const e=this._queue.shift();if(!e)return;const t=this.getHostCooldown(e.url),r=Date.now();t>r?e.reject(new i(`Cooldown active for ${new URL(e.url).host}`,t-r)):(this._activeCount+=1,this.fetchBlob(e).then(e.resolve).catch(e.reject).finally(()=>{this._activeCount-=1,this.pump()}))}}async fetchBlob(e){try{const t=await fetch(e.url,{mode:"cors",cache:"force-cache"});if(!t.ok){const r=429===t.status||t.status>=500,s=this.registerFailure(e.url,r);throw new i(`HTTP ${t.status} loading ${e.url}`,r?s:3e5,r)}return this.registerSuccess(e.url),await t.blob()}catch(t){if(t instanceof i)throw t;const r=this.registerFailure(e.url,!1);throw new i(`Network/CORS failure loading ${e.url}`,r,!0)}}getHostCooldown(e){try{return this._hostBackoff.get(new URL(e).host)?.cooldownUntil??0}catch{return 0}}registerSuccess(e){try{const t=new URL(e).host;this._hostBackoff.set(t,{cooldownUntil:0,consecutiveFailures:0})}catch{}}registerFailure(e,t){if(!t)return 0;try{const t=new URL(e).host,i=(this._hostBackoff.get(t)??{cooldownUntil:0,consecutiveFailures:0}).consecutiveFailures+1,r=4e3,s=Math.min(12e4,r*2**Math.min(i-1,5));return this._hostBackoff.set(t,{cooldownUntil:Date.now()+s,consecutiveFailures:i}),s}catch{return 3e4}}}t.XYZTileRequestScheduler=r,t.xyzTileRequestScheduler=new r},5781:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TerraPointSetGL=void 0;const r=i(1232);class s extends r.CatalogueGL{_kind="TerraPointSetGL"}t.TerraPointSetGL=s},5803:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SphereFoV=void 0;const r=i(1961),s=i(7930);class a{static MIN_FOV_DEG=1e-6;fovXDeg=180;fovYDeg=180;ratio=0;_minFoV=180;_webgl;_lastModel=null;_lastCamera=null;constructor(e){this._webgl=e}getFoV(e,t,i,r){this._lastModel=t,this._lastCamera=i;const s=this._webgl.canvas;if(!s)return this.fovXDeg=180,this.fovYDeg=180,this._minFoV=this.minFoV,this;const a=s.getBoundingClientRect(),o=a.width,n=a.height;return this.fovXDeg=this.computeAngle(0,n/2,e,t,i,r).angleDeg,this.fovYDeg=this.computeAngle(o/2,0,e,t,i,r).angleDeg,this._minFoV=this.minFoV,this.ratio=this.computeRatio(i),this}computeRatio(e){const t=e.getCameraPosition();return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])/this.fovYDeg}get minFoV(){const e=this.fovYDeg<=this.fovXDeg?this.fovYDeg:this.fovXDeg;return this._minFoV=Math.max(e,a.MIN_FOV_DEG),this._minFoV}get xFoV(){return this.fovXDeg}get yFoV(){return this.fovYDeg}computeDistanceFromAngle(e){return e*this.ratio}changeMinFov(e){this.fovYDeg<=this.fovXDeg?this.fovYDeg=e:this.fovXDeg=e,this.minFoV}computeCameraPositionForMinFoV(e){return this.computeCameraPositionForFoV(e)}computeCameraPositionForFoV(e){return this.computeCameraPositionForAngularDiameter(e)}computeCameraPositionForAngularDiameter(e){if(!this._lastModel||!this._lastCamera)return[0,0,0];const t=1e-6,i=Math.max(t,Math.min(180-t,e))*Math.PI/360,s=Math.sin(i);if(s<=0)return[0,0,0];const a=this._lastModel,o=this._lastCamera,n=Math.max(a.radius/s,a.radius+1e-4),h=o.getCameraPosition(),l=r.vec3.fromValues(h[0]-a.center[0],h[1]-a.center[1],h[2]-a.center[2]);return r.vec3.length(l)<t?r.vec3.set(l,0,0,1):r.vec3.normalize(l,l),[a.center[0]+l[0]*n,a.center[1]+l[1]*n,a.center[2]+l[2]*n]}computeAngle(e,t,i,r,s,a){const o=this._webgl.canvas.getBoundingClientRect(),n=this.getIntersectionPointWithModel(o.width/2,o.height/2,r,s,a),h=this.getIntersectionPointWithModel(e,t,r,s,a);return n&&h?{angleDeg:2*this.computeAngularDistanceDeg(n.point,h.point),distance:h.distance}:{angleDeg:180,distance:-1}}computeAngularDistanceDeg(e,t){const i=r.vec3.normalize(r.vec3.create(),e),a=r.vec3.normalize(r.vec3.create(),t),o=r.vec3.dot(i,a),n=r.vec3.cross(r.vec3.create(),i,a),h=Math.atan2(r.vec3.length(n),Math.min(1,Math.max(-1,o)));return(0,s.radToDeg)(h)}getIntersectionPointWithModel(e,t,i,s,a){const o=this.getRayFromMouse(e,t,a,s.getCameraMatrix()),n=this.raySphere(s.getCameraPosition(),o,i);if(n<0)return null;const h=r.vec3.create();r.vec3.scale(h,o,n),r.vec3.add(h,s.getCameraPosition(),h);const l=[h[0],h[1],h[2],1],c=[0,0,0,0];return this.mat4MultiplyVec4(i.getModelMatrixInverse(),l,c),{point:r.vec3.fromValues(c[0],c[1],c[2]),distance:n}}getRayFromMouse(e,t,i,s){const a=this._webgl.canvas.getBoundingClientRect(),o=[2*e/a.width-1,1-2*t/a.height,-1,1],n=r.mat4.create();r.mat4.invert(n,i);const h=[0,0,0,0];this.mat4MultiplyVec4(n,o,h);const l=[h[0],h[1],-1,0],c=r.mat4.create();r.mat4.invert(c,s);const u=[0,0,0,0];this.mat4MultiplyVec4(c,l,u);const d=r.vec3.fromValues(u[0],u[1],u[2]);return r.vec3.normalize(d,d),d}raySphere(e,t,i){let s=-1;const a=r.vec3.create();r.vec3.subtract(a,e,i.center);const o=r.vec3.dot(t,a),n=o*o-(r.vec3.dot(a,a)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-o+e,i=-o-e;(t>=0||i>=0)&&(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-o;e>=0&&(s=e)}return s}mat4MultiplyVec4(e,t,i){i[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],i[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],i[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],i[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3]}}t.SphereFoV=a},5947:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{static catalogueVS(){return"#version 300 es\n in vec4 aCatPosition;\n in float a_selected;\n in float a_pointsize;\n in float a_brightness;\n\n out float v_selected;\n out float v_brightness;\n out lowp vec4 vColor; // not used\n\n uniform mat4 uPMatrix;\n uniform mat4 uMVMatrix;\n\n void main() {\n\n gl_Position = (uPMatrix * uMVMatrix * aCatPosition);\n gl_PointSize = a_pointsize;\n v_selected = a_selected;\n v_brightness = a_brightness;\n }"}static catalogueFS(){return"#version 300 es\n precision mediump float;\n \n #ifdef GL_OES_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n #endif\n\n // https://www.desultoryquest.com/blog/drawing-anti-aliased-circular-points-using-opengl-slash-webgl/\n\n // precision mediump float;\n\n in float v_selected;\n in float v_brightness;\n\n uniform vec4 u_fragcolor;\n\n out vec4 fragColor;\n\n // varying float v_selected;\n // varying float v_brightness;\n\n const float EPSILON = 1e-10;\n \n vec3 RGBtoHCV(in vec3 rgb) {\n // RGB [0..1] to Hue-Chroma-Value [0..1]\n // Based on work by Sam Hocevar and Emil Persson\n vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1., 2. / 3.) : vec4(rgb.gb, 0., -1. / 3.);\n vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);\n float c = q.x - min(q.w, q.y);\n float h = abs((q.w - q.y) / (6. * c + EPSILON) + q.z);\n return vec3(h, c, q.x);\n }\n\n vec3 RGBtoHSL(in vec3 rgb) {\n // RGB [0..1] to Hue-Saturation-Lightness [0..1]\n vec3 hcv = RGBtoHCV(rgb);\n //vec3 hcv = vec3(1., 1., 1.);\n float z = hcv.z - hcv.y * 0.5;\n float s = hcv.y / (1. - abs(z * 2. - 1.) + EPSILON);\n return vec3(hcv.x, s, z);\n }\n\n vec3 HUEtoRGB(in float hue){\n // Hue [0..1] to RGB [0..1]\n // See http://www.chilliant.com/rgb2hsv.html\n vec3 rgb = abs(hue * 6. - vec3(3, 2, 4)) * vec3(1, -1, -1) + vec3(-1, 2, 2);\n return clamp(rgb, 0., 1.);\n }\n\n vec3 HSLtoRGB(in vec3 hsl) {\n // Hue-Saturation-Lightness [0..1] to RGB [0..1]\n vec3 rgb = HUEtoRGB(hsl.x);\n float c = (1. - abs(2. * hsl.z - 1.)) * hsl.y;\n return (rgb - 0.5) * c + hsl.z;\n }\n \n void main() {\n\n float r = 0.0, delta = 0.0, alpha = 1.0;\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n r = dot(cxy, cxy);\n if (r > 1.0) {\n discard;\n }\n\n #ifdef GL_OES_standard_derivatives\n delta = fwidth(r);\n alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);\n #endif\n\n if (v_selected == 1.0){\n // gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * (alpha);\n fragColor = vec4(1.0, 0.0, 0.0, 1.0) * (alpha);\n } else if (v_selected == 2.0){\n // gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0) * (alpha);\n fragColor = vec4(1.0, 1.0, 0.0, 1.0) * (alpha);\n }else{\n if (r < 0.4) {\n discard;\n }\n if ( v_brightness >= -1.0 && v_brightness <= 1.0) {\n // Round-trip RGB->HSL->RGB with time-dependent lightness\n vec3 hsl = RGBtoHSL(vec3(u_fragcolor));\n //hsl.z = pow(hsl.z, sin(iTime) + 1.5);\n // hsl.z = pow(hsl.z, v_brightness + 1.5);\n hsl.z = pow(hsl.z, v_brightness + 1.5);\n vec3 hslcolor = HSLtoRGB(hsl);\n // gl_FragColor = vec4(hslcolor, u_fragcolor[3]) * (alpha);\n fragColor = vec4(hslcolor, u_fragcolor[3]) * (alpha);\n } else {\n // gl_FragColor = u_fragcolor * (alpha);\n fragColor = u_fragcolor * (alpha);\n }\n }\n }"}static footprintVS(){return"#version 300 es\n precision highp float;\n\n layout(location = 0) in vec4 aCatPosition;\n\n uniform float u_pointsize;\n uniform mat4 uMVMatrix;\n uniform mat4 uPMatrix;\n\n void main() {\n gl_Position = uPMatrix * uMVMatrix * aCatPosition;\n gl_PointSize = u_pointsize; // Works in WebGL2\n }"}static footprintFS(){return"#version 300 es\n precision mediump float;\n\n uniform vec4 u_fragcolor;\n out vec4 fragColor;\n\n void main() {\n fragColor = u_fragcolor;\n }"}static hipsVS(){return"#version 300 es\n in vec3 aVertexPosition;\n in vec2 aTextureCoord;\n\n uniform mat4 uMMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uPMatrix;\n\n out vec2 vTextureCoord;\n\n void main() {\n gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);\n vTextureCoord = aTextureCoord;\n }"}static hipsNativeFS(){return"#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n uniform sampler2D uSampler0;\n uniform sampler2D uSampler1;\n uniform sampler2D uSampler2;\n uniform sampler2D uSampler3;\n uniform sampler2D uSampler4;\n uniform sampler2D uSampler5;\n uniform sampler2D uSampler6;\n uniform sampler2D uSampler7;\n\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0){\n vec4 mycolor;\n #if __VERSION__ > 120\n vec4 color0 = texture(uSampler0, vTextureCoord);\n #else\n vec4 color0 = texture2D(uSampler0, vTextureCoord);\n #endif\n mycolor = color0;\n finalColor += mycolor.rgb * uFactor0;\n } else if (uFactor7 >= 0.0){\n finalColor = vec3(1.0, 0.0, 0.0);\n }\n fragColor = vec4(finalColor, 1.0);\n }"}static hipsGrayscaleFS(){return"#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n uniform sampler2D uSampler0;\n uniform sampler2D uSampler1;\n uniform sampler2D uSampler2;\n uniform sampler2D uSampler3;\n uniform sampler2D uSampler4;\n uniform sampler2D uSampler5;\n uniform sampler2D uSampler6;\n uniform sampler2D uSampler7;\n\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0){\n #if __VERSION__ > 120\n vec4 color0 = texture(uSampler0, vTextureCoord);\n #else\n vec4 color0 = texture2D(uSampler0, vTextureCoord);\n #endif\n float gray = 0.21 * color0.r + 0.71 * color0.g + 0.07 * color0.b;\n finalColor = color0.rgb * (1.0 - uFactor0) + vec3(gray) * uFactor0;\n }\n if (uFactor1 >= 0.0){\n #if __VERSION__ > 120\n vec4 color1 = texture(uSampler1, vTextureCoord);\n #else\n vec4 color1 = texture2D(uSampler1, vTextureCoord);\n #endif\n finalColor += color1.rgb * uFactor1;\n }\n if (uFactor2 >= 0.0){\n #if __VERSION__ > 120\n vec4 color2 = texture(uSampler2, vTextureCoord);\n #else\n vec4 color2 = texture2D(uSampler2, vTextureCoord);\n #endif\n finalColor += color2.rgb * uFactor2;\n }\n if (uFactor3 >= 0.0){\n #if __VERSION__ > 120\n vec4 color3 = texture(uSampler3, vTextureCoord);\n #else\n vec4 color3 = texture2D(uSampler3, vTextureCoord);\n #endif\n finalColor += color3.rgb * uFactor3;\n }\n if (uFactor4 >= 0.0){\n #if __VERSION__ > 120\n vec4 color4 = texture(uSampler4, vTextureCoord);\n #else\n vec4 color4 = texture2D(uSampler4, vTextureCoord);\n #endif\n finalColor += color4.rgb * uFactor4;\n }\n if (uFactor5 >= 0.0){\n #if __VERSION__ > 120\n vec4 color5 = texture(uSampler5, vTextureCoord);\n #else\n vec4 color5 = texture2D(uSampler5, vTextureCoord);\n #endif\n finalColor += color5.rgb * uFactor5;\n }\n if (uFactor6 >= 0.0){\n #if __VERSION__ > 120\n vec4 color6 = texture(uSampler6, vTextureCoord);\n #else\n vec4 color6 = texture2D(uSampler6, vTextureCoord);\n #endif\n finalColor += color6.rgb * uFactor6;\n }\n if (uFactor7 >= 0.0){\n #if __VERSION__ > 120\n vec4 color7 = texture(uSampler7, vTextureCoord);\n #else\n vec4 color7 = texture2D(uSampler7, vTextureCoord);\n #endif\n finalColor += color7.rgb * uFactor7;\n }\n fragColor = vec4(finalColor, 1.0);\n }"}static hipsColorMapFS(){return"#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n // UBO\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n uniform sampler2D uSampler0;\n uniform float uFactor0;\n\n out vec4 fragColor;\n\n void main() {\n #if __VERSION__ > 120\n vec4 color0 = texture(uSampler0, vTextureCoord);\n #else\n vec4 color0 = texture2D(uSampler0, vTextureCoord);\n #endif\n\n int x = int(color0.r * 255.0);\n float px = r_palette[x] / 256.0;\n\n int y = int(color0.g * 255.0);\n float py = g_palette[y] / 256.0;\n\n int z = int(color0.b * 255.0);\n float pz = b_palette[z] / 256.0;\n\n // uFactor0 reserved for future blending if needed\n fragColor = vec4(px, py, pz, 1.0);\n }"}}},6553:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Point=void 0;const s=i(1961),a=i(7930),o=i(8145),n=r(i(4382));class h{_x;_y;_z;_xyz;_raDeg;_decDeg;_raRad;_decRad;_raDecDeg;_lonLatDeg;constructor(e,t){this._xyz=[0,0,0],this._raDecDeg=[0,0];const i=n.default.MAX_DECIMALS??12;if(t===o.CoordsType.CARTESIAN){const{x:t,y:r,z:s}=e;this._x=Number(t.toFixed(i)),this._y=Number(r.toFixed(i)),this._z=Number(s.toFixed(i)),this._xyz=[this._x,this._y,this._z];const[a,o]=this.computeAstroCoords();this._raDeg=Number(a),this._decDeg=Number(o),this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180,this._raDecDeg=[this._raDeg,this._decDeg]}else if(t===o.CoordsType.ASTRO){const{raDeg:t,decDeg:r}=e;this._raDeg=Number(t),this._decDeg=Number(r),this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,a,o]=this.computeCartesianCoords();this._x=Number(s.toFixed(i)),this._y=Number(a.toFixed(i)),this._z=Number(o.toFixed(i)),this._xyz=[this._x,this._y,this._z]}else if(t===o.CoordsType.GEOGRAPHIC){const{lonDeg:t,latDeg:r}=e;this._lonLatDeg=[Number(t),Number(r)],this._raDeg=this._lonLatDeg[0],this._decDeg=this._lonLatDeg[1],this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,a,o]=this.computeCartesianCoords();this._x=Number(s.toFixed(i)),this._y=Number(a.toFixed(i)),this._z=Number(o.toFixed(i)),this._xyz=[this._x,this._y,this._z]}else t===o.CoordsType.SPHERICAL?(console.log(`${o.CoordsType.SPHERICAL} not implemented yet`),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0):(console.error("CoordsType "+String(t)+" not recognised."),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0)}computeAstroCoords(){const e=(0,a.cartesianToSpherical)(s.vec3.fromValues(this._xyz[0],this._xyz[1],this._xyz[2])),t=(0,a.sphericalToAstroDeg)(e.phi,e.theta);return[t.ra,t.dec]}computeCartesianCoords(){const e=(0,a.astroDegToSpherical)(this._raDeg,this._decDeg),[t,i,r]=(0,a.sphericalToCartesian)(e.phi,e.theta,1);return[t,i,r]}computeHealpixPhiTheta(){return(0,a.astroDegToSpherical)(this._raDeg,this._decDeg)}scale(e){return new h({x:this.x*e,y:this.y*e,z:this.z*e},o.CoordsType.CARTESIAN)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}cross(e){return new h({x:this.y*e.z-e.y*this.z,y:this.z*e.x-e.z*this.x,z:this.x*e.y-e.x*this.y},o.CoordsType.CARTESIAN)}norm(){const e=1/this.length();return new h({x:this.x*e,y:this.y*e,z:this.z*e},o.CoordsType.CARTESIAN)}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}subtract(e){return new h({x:this.x-e.x,y:this.y-e.y,z:this.z-e.z},o.CoordsType.CARTESIAN)}add(e){return new h({x:this.x+e.x,y:this.y+e.y,z:this.z+e.z},o.CoordsType.CARTESIAN)}get x(){return this._x}get y(){return this._y}get z(){return this._z}get xyz(){return this._xyz}get raDeg(){return this._raDeg}get decDeg(){return this._decDeg}get raDecDeg(){return this._raDecDeg}get lonDeg(){return this._lonLatDeg?.[0]??this._raDeg}get latDeg(){return this._lonLatDeg?.[1]??this._decDeg}get lonLatDeg(){return this._lonLatDeg??[this._raDeg,this._decDeg]}toADQL(){return`${this._raDecDeg[0]},${this._raDecDeg[1]}`}toString(){return`(raDeg, decDeg) => (${this._raDecDeg[0]},${this._raDecDeg[1]}) (x, y,z) => (${this._xyz[0]},${this._xyz[1]},${this._xyz[2]})`}}t.Point=h},6937:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XYZVisibleTilesManager=void 0;const s=r(i(2166));t.XYZVisibleTilesManager=class{_ancestorsMap=new Map;_visibleTilesMap=new Map;_visibleTiles=[];_selection={key:"0:",currentZoom:0,visibleTiles:[],visibleTilesMap:new Map,ancestorsMap:new Map};get ancestorsMap(){return this._ancestorsMap}get visibleTiles(){return this._visibleTiles}get visibleTilesMap(){return this._visibleTilesMap}get selection(){return this._selection}computeVisibleTiles(e,t,i,r,a,o=9,n=2){return this._visibleTiles=s.default.getVisibleTilesFromViewport(e,t,i,r,a,o,n),this._visibleTilesMap=this.buildTileMap(this._visibleTiles),this.refreshAncestorsMap(this._visibleTiles),this._selection={key:this.buildSelectionKey(e,this._visibleTiles),currentZoom:e,visibleTiles:this._visibleTiles,visibleTilesMap:this._visibleTilesMap,ancestorsMap:this._ancestorsMap},this._selection}refreshAncestorsMap(e){this._ancestorsMap.clear();for(const t of e)for(let e=t.z-1;e>=0;e--){const i=t.z-e,r={z:e,x:t.x>>i,y:t.y>>i};this._ancestorsMap.set(`${r.z}/${r.x}/${r.y}`,r)}}buildTileMap(e){const t=new Map;for(const i of e)t.set(this.key(i),i);return t}buildSelectionKey(e,t){return`${e}:${t.map(e=>`${e.x}/${e.y}`).join("|")}`}key(e){return`${e.z}/${e.x}/${e.y}`}}},7559:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{_x;_y;constructor(e,t){this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}}},7734:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(1961),a=i(7930),o=r(i(4382));t.default=class{insideSphere=!1;cam_pos=s.vec3.create();cam_speed=1;vMatrix=s.mat4.create();T=s.mat4.create();R=s.mat4.create();FoV=180;previousFoV=180;move=s.vec3.create();phi=0;theta=0;rotationSensitivity=1;lockRotX=!1;lockRotY=!1;lockRotZ=!1;constructor(e,t){this.init(e,t)}init(e,t){this.insideSphere=t,this.cam_pos=s.vec3.clone(e),this.vMatrix=s.mat4.create(),this.T=s.mat4.create(),this.R=s.mat4.create(),s.mat4.translate(this.T,this.T,[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]),this.FoV=this.previousFoV=180,this.move=s.vec3.clone([0,0,0]),this.goTo(0,0)}goTo(e,t){this.goToPhiTheta((0,a.astroDegToSpherical)(e,t))}goToPhiTheta(e){const t=(0,a.sphericalToCartesian)(e.phi,e.theta,this.cam_pos[2]),i=s.vec3.normalize(s.vec3.create(),s.vec3.fromValues(t[0],t[1],t[2])),r=s.vec3.fromValues(0,0,1),o=s.vec3.scale(s.vec3.create(),i,s.vec3.dot(r,i)),n=s.vec3.subtract(s.vec3.create(),r,o);s.vec3.length(n)<1e-6?s.vec3.set(n,0,1,0):s.vec3.normalize(n,n);let h=s.mat4.create();h=s.mat4.translate(h,h,s.vec3.fromValues(t[0],t[1],t[2]));const l=[h[12],h[13],h[14]];h=s.mat4.targetTo(h,l,[0,0,0],n),this.R=s.mat4.clone(h),this.R[12]=0,this.R[13]=0,this.R[14]=0;const c=s.mat4.create();0!==this.cam_pos[2]&&s.mat4.invert(c,h),this.vMatrix=c}toggleInsideSphere(){this.insideSphere=o.default.insideSphere,o.default.insideSphere?(this.cam_pos[0]=0,this.cam_pos[1]=0,this.cam_pos[2]=-.005):this.cam_pos[2]=2+this.cam_pos[2],s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}zoom(e){if(this.move=s.vec3.clone([0,0,0]),this.move[2]+=this.cam_speed*e,o.default.insideSphere)this.cam_pos[2]+this.move[2]>=-.005&&e>0?(this.cam_pos[2]=-.005,e=0):this.cam_pos[2]+this.move[2]<=-.9885&&e<0?(this.cam_pos[2]=-.9885,e=0):this.cam_pos[2]+=this.move[2];else{const t=Math.max(this.cam_pos[2]-1,1e-6),i=Math.min(1,t/.3),r=.015+.985*Math.pow(i,1.2);this.move[2]*=r,this.cam_pos[2]+this.move[2]<=1.000001&&e<0?this.cam_pos[2]=1.000001:this.cam_pos[2]+=this.move[2]}const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}moveAlongView(e){const t=s.mat4.create();s.mat4.invert(t,this.R);const i=s.vec3.fromValues(0,0,-1),r=s.vec3.create();s.vec3.transformMat4(r,i,t);const a=Math.hypot(r[0],r[1],r[2]);a>0&&(r[0]/=a,r[1]/=a,r[2]/=a),this.cam_pos[0]+=r[0]*e,this.cam_pos[1]+=r[1]*e,this.cam_pos[2]+=r[2]*e;const o=s.mat4.create();s.mat4.translate(this.T,o,this.cam_pos),this.refreshViewMatrix()}translate(e){this.cam_pos[2]=e+1;const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}rotateX(e){if(this.lockRotX)return;const t=.01*e;this.theta+=t,s.mat4.rotate(this.R,this.R,t,[1,0,0]),this.refreshViewMatrix()}rotateY(e){if(this.lockRotY)return;const t=.01*e;this.phi+=t,s.mat4.rotate(this.R,this.R,t,[0,1,0]),this.refreshViewMatrix()}rotateZ(e){if(this.lockRotZ)return;const t=.01*e;s.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshViewMatrix()}rotateXRadian(e){this.lockRotX||(s.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshViewMatrix())}rotateYRadian(e){this.lockRotY||(this.phi+=e,s.mat4.rotate(this.R,this.R,e,[0,1,0]),this.refreshViewMatrix())}rotateZRadian(e){this.lockRotZ||(s.mat4.rotate(this.R,this.R,e,[0,0,1]),this.refreshViewMatrix())}rotate(e,t){if(this.lockRotZ)return;const i=Math.sqrt(e*e+t*t);if(0===i)return;const r=this.getCameraPosition(),a=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),o=Math.max(a-1,1e-6),n=Math.min(1,o/.45),h=.02+.98*Math.pow(n,1.55),l=Math.min(1,this.FoV/18),c=i*h*(.06+1.55*Math.pow(l,.52))/1.9*this.rotationSensitivity;let u=t,d=e;const _=Math.sqrt(u*u+d*d);0!==_&&(u/=_,d/=_,s.mat4.rotate(this.R,this.R,-c,[u,d,0]),this.refreshViewMatrix())}setRotationSensitivity(e){this.rotationSensitivity=Math.min(3,Math.max(.2,e))}getRotationSensitivity(){return this.rotationSensitivity}refreshViewMatrix(){const e=s.mat4.create(),t=s.mat4.create();s.mat4.invert(e,this.T),s.mat4.invert(t,this.R),s.mat4.multiply(this.vMatrix,e,t)}refreshFoV(e){this.previousFoV=this.FoV,this.FoV=e}getCameraMatrix(){return this.vMatrix}getCameraPosition(){const e=s.mat4.create();return s.mat4.invert(e,this.vMatrix)?[e[12],e[13],e[14]]:[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]}setCameraMatrix(e){this.vMatrix=e}setCameraPosition(e){this.cam_pos=s.vec3.fromValues(e[0],e[1],e[2]),s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}getCameraAngle(){const[e,t,i]=this.getCameraPosition(),r=s.vec3.fromValues(e,t,i),o=(0,a.cartesianToSpherical)(r);return console.log("[Camera::getCameraAngle]",o),o}setRotationLock(e){void 0!==e.x&&(this.lockRotX=e.x),void 0!==e.y&&(this.lockRotY=e.y),void 0!==e.z&&(this.lockRotZ=e.z)}clearRotationLock(){this.lockRotX=this.lockRotY=this.lockRotZ=!1}isRotationLockedX(){return this.lockRotX}isRotationLockedY(){return this.lockRotY}isRotationLockedZ(){return this.lockRotZ}}},7786:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSShaderProgram=void 0;const s=r(i(5947)),a=i(619);t.HiPSShaderProgram=class{_colorMapBlockIndex=null;_runtimeColorMap;_shaderProgram;_vertexShader;_fragmentShader;_UBO_colorMapBuffer=null;_UBO_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={sampler:"uSampler0",factor:"uFactor0",m_perspective:"uPMatrix",m_model:"uMMatrix",m_view:"uVMatrix",colormapIdx:"cmapIdx",colormap_red:"r",colormap_green:"g",colormap_blue:"b"},this.gl_attributes={vertex_pos:"aVertexPosition",text_coords:"aTextureCoord"},this.locations={pMatrix:null,mMatrix:null,vMatrix:null,sampler:null,textureAlpha:null,clorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;return this._shaderProgram||(this._shaderProgram=e.createProgram(),this.initShaders()),e.useProgram(this._shaderProgram),this._shaderProgram}setRuntimeColorMap(e){this._runtimeColorMap=e}initShaders(){const e=this._webgl,t=s.default.hipsNativeFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const i=s.default.hipsVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this._shaderProgram,this._vertexShader),e.attachShader(this._shaderProgram,this._fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders")):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setGrayscaleShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=s.default.hipsGrayscaleFS();this.changeFSShader(e)}setNativeShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=s.default.hipsNativeFS();this.changeFSShader(e)}setColorMapShader(){const e=this._webgl;e.detachShader(this.shaderProgram,this._fragmentShader);const t=s.default.hipsColorMapFS();this.changeFSShader(t);const i=e.getUniformBlockIndex(this.shaderProgram,"colormap");if(i===e.INVALID_INDEX)return console.warn('HiPSShaderProgram: uniform block "colormap" not found in hipsColorMapFS()'),this._colorMapBlockIndex=null,void(this._UBO_colorMapBuffer=null);this._colorMapBlockIndex=i;const r=["r_palette","g_palette","b_palette"],a=e.getUniformIndices(this.shaderProgram,r),o=e.getActiveUniforms(this.shaderProgram,a,e.UNIFORM_OFFSET);if(!this._UBO_colorMapBuffer){this._UBO_colorMapBuffer=e.createBuffer(),e.bindBuffer(e.UNIFORM_BUFFER,this._UBO_colorMapBuffer);const t=12288;e.bufferData(e.UNIFORM_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,0,this._UBO_colorMapBuffer)}r.forEach((e,t)=>{this._UBO_colorMapVariableInfo[e]={index:a[t],offset:o[t]}})}changeFSShader(e){const t=this._webgl;this._fragmentShader=t.createShader(t.FRAGMENT_SHADER),t.shaderSource(this._fragmentShader,e),t.compileShader(this._fragmentShader),t.getShaderParameter(this._fragmentShader,t.COMPILE_STATUS)?(t.attachShader(this.shaderProgram,this._fragmentShader),t.linkProgram(this.shaderProgram),t.getProgramParameter(this.shaderProgram,t.LINK_STATUS)||alert("Could not initialise shaders"),t.useProgram(this.shaderProgram)):alert(t.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error")}enableShaders(e,t,i,r){const s=this._webgl;if(s.useProgram(this.shaderProgram),this.locations.pMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model),this.locations.vMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_view),this.locations.sampler=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.sampler),this.locations.textureAlpha=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.factor),this.locations.clorMapIdx=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.colormapIdx),s.uniform1i(this.locations.clorMapIdx,r),this.locations.sampler&&s.uniform1i(this.locations.sampler,0),this.locations.vertexPositionAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.textureCoordAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.text_coords),r>=2&&this._UBO_colorMapBuffer&&null!==this._colorMapBlockIndex){let e;if(s.uniformBlockBinding(this.shaderProgram,this._colorMapBlockIndex,0),s.bindBuffer(s.UNIFORM_BUFFER,this._UBO_colorMapBuffer),2===r?e={r:a.ColorMaps.planck.r,g:a.ColorMaps.planck.g,b:a.ColorMaps.planck.b}:3===r?e={r:a.ColorMaps.cmb.r,g:a.ColorMaps.cmb.g,b:a.ColorMaps.cmb.b}:4===r?e={r:a.ColorMaps.rainbow.r,g:a.ColorMaps.rainbow.g,b:a.ColorMaps.rainbow.b}:5===r?e={r:a.ColorMaps.eosb.r,g:a.ColorMaps.eosb.g,b:a.ColorMaps.eosb.b}:6===r?e={r:a.ColorMaps.cubehelix.r,g:a.ColorMaps.cubehelix.g,b:a.ColorMaps.cubehelix.b}:7===r?e={r:a.ColorMaps.hot.r,g:a.ColorMaps.hot.g,b:a.ColorMaps.hot.b}:8===r&&(e={r:a.ColorMaps.gray.r,g:a.ColorMaps.gray.g,b:a.ColorMaps.gray.b}),e||(e=this._runtimeColorMap),e){const t=this._UBO_colorMapVariableInfo;s.bufferSubData(s.UNIFORM_BUFFER,t.r_palette.offset,e.r,0),s.bufferSubData(s.UNIFORM_BUFFER,t.g_palette.offset,e.g,0),s.bufferSubData(s.UNIFORM_BUFFER,t.b_palette.offset,e.b,0)}s.bindBuffer(s.UNIFORM_BUFFER,null)}s.uniformMatrix4fv(this.locations.mMatrix,!1,i),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t)}}},7930:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cartesianToSpherical=function(e){const t=r.vec3.dot(e,e),i=Math.sqrt(t);let s=Math.acos(e[2]/i);s=a(s);let o=Math.atan2(e[1],e[0]);return o=a(o),o<0&&(o+=360),{phi:o,theta:s}},t.colorHex2RGB=function(e){const t=e.substring(1,3),i=e.substring(3,5),r=e.substring(5,7),s=parseInt(t,16),a=parseInt(i,16),o=parseInt(r,16),n=(s/255).toFixed(2),h=(a/255).toFixed(2),l=(o/255).toFixed(2);return[parseFloat(n),parseFloat(h),parseFloat(l)]},t.degToRad=s,t.radToDeg=a,t.sphericalToAstroDeg=function(e,t){let i=e;return i<0&&(i+=360),{ra:i,dec:90-t}},t.sphericalToCartesian=function(e,t,i=1){return[i*Math.sin(s(t))*Math.cos(s(e)),i*Math.sin(s(t))*Math.sin(s(e)),i*Math.cos(s(t))]},t.astroDegToSpherical=function(e,t){let i=e;return i<0&&(i+=360),{phi:i,theta:90-t}},t.raDegToHMS=function(e){const t=Math.floor(e/15),i=Math.floor(60*(e/15-t));return{h:t,m:i,s:3600*(e/15-t-i/60)}},t.decDegToDMS=function(e){let t=1;e<0&&(t=-1);const i=Math.abs(e);let r=Math.trunc(i);const s=Math.trunc(60*(i-r)),a=3600*(i-r-s/60);return r*=t,{d:r,m:s,s:a}};const r=i(1961);function s(e){return e/180*Math.PI}function a(e){return 180*e/Math.PI}},8083:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FoVUtils=void 0;const s=i(6553),a=r(i(4639)),o=i(8145),n=i(1961);class h{getMinFoV(){return this._fovY_deg<=this._fovX_deg?this._fovY_deg:this._fovX_deg}static getFoVPolygon(e,t,i,r,s,o){const l=e.getCameraMatrix(),c=i.getModelMatrix(),u=t.clientWidth,d=t.clientHeight;let _=[];if(a.default.getIntersectionPointWithSingleModel(0,0,r,s,e,o).length>0)_=h.getScreenCornersIntersection(o,e,t,r,s);else{let t=n.mat4.create();t=n.mat4.multiply(t,l,c),t=n.mat4.multiply(t,o,t);const i=[t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]],f=[t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]],g=[t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]],p=[t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]],m=a.default.getIntersectionPointWithSingleModel(u/2,0,r,s,e,o),x=a.default.getIntersectionPointWithSingleModel(u,d/2,r,s,e,o);if(0===m.length&&0===x.length){const e=h.getNearestSpherePoint(i),t=h.getNearestSpherePoint(f),r=h.getNearestSpherePoint(p),s=h.getNearestSpherePoint(g),a=h.computeMiddlePoint(r[0],e[0])[0],o=h.computeMiddlePoint(e[0],s[0])[0],n=h.computeMiddlePoint(s[0],t[0])[0],l=h.computeMiddlePoint(t[0],r[0])[0];_.push(e[0],o,s[0],n,t[0],l,r[0],a)}else if(0===m.length){const e=h.getNearestSpherePoint(i),r=h.getNearestSpherePoint(f),s=h.getFrustumIntersectionWithSphere(t,p,f,i),a=h.getFrustumIntersectionWithSphere(t,g,i,f),o=h.computeMiddlePoint(s[1],e[0])[0],n=h.computeMiddlePoint(e[0],a[0])[0],l=h.computeMiddlePoint(a[1],r[0])[0],c=h.computeMiddlePoint(r[0],s[0])[0];_.push(e[0],n,a[0],a[1],l,r[0],c,s[0],s[1],o)}else if(0===x.length){const e=h.getFrustumIntersectionWithSphere(t,i,p,g),r=h.getFrustumIntersectionWithSphere(t,f,g,p),s=h.getNearestSpherePoint(p),a=h.getNearestSpherePoint(g),o=h.computeMiddlePoint(s[0],e[0])[0],n=h.computeMiddlePoint(e[1],a[0])[0],l=h.computeMiddlePoint(a[0],r[0])[0],c=h.computeMiddlePoint(r[1],s[0])[0];_.push(e[0],e[1],n,a[0],l,r[0],r[1],c,s[0],o)}else{const e=h.getFrustumIntersectionWithSphere(t,i,p,g),r=h.getFrustumIntersectionWithSphere(t,f,g,p),s=h.getFrustumIntersectionWithSphere(t,p,f,i),a=h.getFrustumIntersectionWithSphere(t,g,i,f);_.push(e[0],e[1],a[0],a[1],r[0],r[1],s[0],s[1])}}return _}static getScreenCornersIntersection(e,t,i,r,n){const h=i.clientWidth,l=i.clientHeight,c=a.default.getIntersectionPointWithSingleModel(0,0,r,n,t,e),u=a.default.getIntersectionPointWithSingleModel(h/2,0,r,n,t,e),d=a.default.getIntersectionPointWithSingleModel(h,0,r,n,t,e),_=a.default.getIntersectionPointWithSingleModel(h,l/2,r,n,t,e),f=a.default.getIntersectionPointWithSingleModel(h,l,r,n,t,e),g=a.default.getIntersectionPointWithSingleModel(h/2,l,r,n,t,e),p=a.default.getIntersectionPointWithSingleModel(0,l,r,n,t,e),m=a.default.getIntersectionPointWithSingleModel(0,l/2,r,n,t,e),x=[],M=e=>{e.length>0&&x.push(new s.Point({x:e[0],y:e[1],z:e[2]},o.CoordsType.CARTESIAN))};return M(c),M(u),M(d),M(_),M(f),M(g),M(p),M(m),x}static getCenterJ2000(e,t,i,r,n){const h=e.clientWidth,l=e.clientHeight,c=a.default.getIntersectionPointWithSingleModel(h/2,l/2,t,i,r,n);if(c.length<=0)throw Error("Central point is null");return new s.Point({x:c[0],y:c[1],z:c[2]},o.CoordsType.CARTESIAN)}static computeMiddlePoint(e,t){const i=(e.x+t.x)/2,r=(e.y+t.y)/2,a=(e.z+t.z)/2,n=Math.hypot(i,r,a)||1,h=i/n,l=r/n,c=a/n;return[new s.Point({x:h,y:l,z:c},o.CoordsType.CARTESIAN)]}static getNearestSpherePoint(e){const[t,i,r,a]=e,n=1/Math.sqrt(t*t+i*i+r*r),h=1*n,l=-1*n,c=[t*h,i*h,r*h],u=[t*l,i*l,r*l],d=Math.sqrt(t*t+i*i+r*r)||1,_=Math.abs(t*c[0]+i*c[1]+r*c[2]+a)/d<=Math.abs(t*u[0]+i*u[1]+r*u[2]+a)/d?c:u;return[new s.Point({x:_[0],y:_[1],z:_[2]},o.CoordsType.CARTESIAN)]}static getFrustumIntersectionWithSphere(e,t,i,r){const[a,n,h,l]=t,c=a*a+n*n+h*h||1,u=-a*l/c,d=-n*l/c,_=-h*l/c,f=Math.abs(l)/Math.sqrt(c),g=[];if(1>f){const e=Math.sqrt(1-f*f),t=t=>{const[i,r,s,a]=t,o=1/Math.sqrt(i*i+r*r+s*s),n=e*o,h=-e*o,l=[u+i*n,d+r*n,_+s*n],c=[u+i*h,d+r*h,_+s*h],f=Math.sqrt(i*i+r*r+s*s)||1;return Math.abs(i*l[0]+r*l[1]+s*l[2]+a)/f<=Math.abs(i*c[0]+r*c[1]+s*c[2]+a)/f?l:c},a=t(i),n=t(r);g.push(new s.Point({x:a[0],y:a[1],z:a[2]},o.CoordsType.CARTESIAN),new s.Point({x:n[0],y:n[1],z:n[2]},o.CoordsType.CARTESIAN))}else 1===f&&g.push(new s.Point({x:u,y:d,z:_},o.CoordsType.CARTESIAN),new s.Point({x:u,y:d,z:_},o.CoordsType.CARTESIAN));return g}static getAstroFoVPolygon(e){return e.map(e=>e.toADQL()).join(",")}}t.FoVUtils=h},8124:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LatLonGrid=void 0;const s=i(1961),a=i(4735),o=i(8284),n=r(i(4707)),h=i(7930),l=i(5803),c=r(i(4382)),u=r(i(5361));class d extends a.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_shaderProgram;_vertexShader;_fragmentShader;_attribLocations={position:0};_lonVertexPositionBuffer;_latVertexPositionBuffer;_lonStep=10;_latStep=10;_segmentStep=1;_fovObj;_fovDeg=180;_showGrid=!0;_lonArray=[];_latArray=[];_bufferKey="";defaultColor="#41d4d4";gridText=new u.default("lonlat");constructor(e,t,i,r,s,a){super(e,t,i,r,s,a),this._fovObj=new l.SphereFoV(a),this.init()}init(){this.initGL(super.webgl);const e=super.webgl;this._shaderProgram=e.createProgram(),this.initShaders(),this._lonVertexPositionBuffer=e.createBuffer(),this._latVertexPositionBuffer=e.createBuffer(),this.initBuffers(this._fovDeg)}initShaders(){const e=super.webgl,t=n.default.healpixGridFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(t),void alert(t)}const i=n.default.healpixGridVS();if(this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),!e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(t),void alert(t)}e.attachShader(this._shaderProgram,this._vertexShader),e.attachShader(this._shaderProgram,this._fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this._shaderProgram)}initBuffers(e,t,i=!1){const r=o.xyzFovHelper.getLonLatSteps(e,i);this._lonStep=r.lonStep,this._latStep=r.latStep,this._segmentStep=Math.max(Math.min(this._lonStep,this._latStep),.25),this._lonArray=[],this._latArray=[];const s=t?{lon:this.normalizeLon(t.phi>180?t.phi-360:t.phi),lat:90-t.theta}:null,a=!!s&&!i&&e<2,n=a?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._lonStep):this.buildLonRange(0,180,this._lonStep),h=a?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._latStep):this.buildLatRange(0,90,this._latStep),l=a&&s?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._segmentStep):this.buildLatRange(0,90,this._segmentStep),c=a&&s?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._segmentStep):this.buildLonRange(0,180,this._segmentStep);for(const e of n){const t=[];for(const i of l)t.push(...this.lonLatToCartesian(e,Math.min(i,90)));this._lonArray.push(new Float32Array(t))}for(const e of h){const t=[];if(!(e<=-90||e>=90)){for(const i of c)t.push(...this.lonLatToCartesian(Math.min(i,180),e));this._latArray.push(new Float32Array(t))}}}buildLonRange(e,t,i){const r=[],s=Math.floor((e-t)/i)*i,a=Math.ceil((e+t)/i)*i;for(let e=s;e<=a;e+=i)r.push(this.normalizeLon(e));return r}buildLatRange(e,t,i){const r=[],s=Math.max(-90,Math.floor((e-t)/i)*i),a=Math.min(90,Math.ceil((e+t)/i)*i);for(let e=s;e<=a;e+=i)r.push(e);return r}lonLatToCartesian(e,t){const i=(0,h.degToRad)(e),r=(0,h.degToRad)(t),s=Math.cos(r);return[s*Math.cos(i),s*Math.sin(i),Math.sin(r)]}refresh(e,t){const i=!!t.cameraMoving,r=o.xyzFovHelper.getLonLatSteps(e,i),s=t.centerSphericalDeg,a=!!s&&!i&&e<2,n=s?this.normalizeLon(s.phi>180?s.phi-360:s.phi):0,h=s?90-s.theta:0,l=a?`${this.roundToStep(n,Math.max(r.lonStep,e))}:${this.roundToStep(h,Math.max(r.latStep,e))}`:"global",c=`${i?"coarse":"settled"}:${r.lonStep}:${r.latStep}:${l}`;this._bufferKey!==c&&(this._fovDeg=e,this._bufferKey=c,this.initBuffers(this._fovDeg,t.centerSphericalDeg,i))}refreshFoV(e){return e.camera&&e.pMatrix?(this._fovObj.getFoV(c.default.insideSphere,this,e.camera,e.pMatrix),this.refresh(this._fovObj.minFoV,e),this._fovObj.minFoV):this._fovDeg}getMinFoVDeg(){return this._fovObj.minFoV}getFoV(){return this._fovObj}isVisible(){return this._showGrid}toggleShowGrid(){return this._showGrid=!this._showGrid,this._showGrid}setShowGrid(e){this._showGrid=e}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const a=s.mat4.create();s.mat4.multiply(a,i,e);const o=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),n=r.getUniformLocation(this._shaderProgram,"uPMatrix"),l=r.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition"),o&&r.uniformMatrix4fv(o,!1,a),n&&r.uniformMatrix4fv(n,!1,t),l){const e=(0,h.colorHex2RGB)(this.defaultColor);r.uniform4f(l,e[0],e[1],e[2],1)}}draw(e){if(!this._showGrid)return void this.gridText.resetDivSets();const t=super.webgl,i=e.camera;if(!i)return;const r=e.pMatrix;if(!r)return;this.refreshFoV(e);const s=i.getCameraMatrix();if(!s)return;const a=this.getModelMatrix();this.enableShader(a,r,s);for(const e of this._lonArray)t.bindBuffer(t.ARRAY_BUFFER,this._lonVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_STRIP,0,e.length/d.ELEM_SIZE);for(const e of this._latArray)t.bindBuffer(t.ARRAY_BUFFER,this._latVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_LOOP,0,e.length/d.ELEM_SIZE);this.drawLabels(e,a,r,s),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}drawLabels(e,t,i,r){const s=e.centerSphericalDeg;if(!s)return void this.gridText.resetDivSets();const a=this.normalizeLon(s.phi>180?s.phi-360:s.phi),o=90-s.theta,n=this.normalizeLon(this.roundToStep(a,this._lonStep)),h=Math.max(-90+this._latStep,Math.min(90-this._latStep,this.roundToStep(o,this._latStep))),l=this.lonLatToCartesian(n,Math.max(-80,Math.min(80,o))),c=this.lonLatToCartesian(a,h),u=this.projectPointToScreen(l,t,i,r);u&&this.gridText.addLonLatDivSet(`${n.toFixed(0)}° lon`,u.x,u.y,"lon");const d=this.projectPointToScreen(c,t,i,r);d&&this.gridText.addLonLatDivSet(`${h.toFixed(0)}° lat`,d.x,d.y,"lat"),this.gridText.resetDivSets()}projectPointToScreen(e,t,i,r){const a=s.mat4.create(),o=s.mat4.create();s.mat4.multiply(a,r,t),s.mat4.multiply(o,i,a);const n=s.vec4.fromValues(e[0],e[1],e[2],1);if(s.vec4.transformMat4(n,n,o),Math.abs(n[3])<1e-6)return null;if(n[0]/=n[3],n[1]/=n[3],n[0]<-1||n[0]>1||n[1]<-1||n[1]>1)return null;const h=super.webgl.canvas.getBoundingClientRect();return{x:h.left+(.5*n[0]+.5)*h.width,y:h.top+(-.5*n[1]+.5)*h.height}}roundToStep(e,t){return t<=0?e:Math.round(e/t)*t}normalizeLon(e){let t=e;for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}t.LatLonGrid=d},8145:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.CoordsType=void 0,function(e){e.CARTESIAN="cartesian",e.SPHERICAL="spherical",e.ASTRO="astro",e.GEOGRAPHIC="geographic"}(i||(t.CoordsType=i={}))},8256:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382)),a=i(229);t.default=class{_hips;_tileno;_baseurl;_order;_format;_maxorder;_isGalacticHips;_ready=!1;_abort=!1;_image;_textureLoaded=!1;_texture;_texurl="";_hipsShaderIndex=0;_cacheTime0;_inView=!0;_amIStillInFoV_requsetID;vertexPosition=[];vertexPositionBuffer=[];vertexIndices=new Uint16Array;vertexIndexBuffer;_tileBuffer;opacity=1;_webgl;_visibleTileManager;constructor(e,t,i,r,s,a){this._visibleTileManager=a,this._webgl=s,this._tileBuffer=r,this._hips=i,this._tileno=e,this._format=i.format,this._baseurl=i.baseURL,this._maxorder=i.maxOrder,this._isGalacticHips=i.isGalacticHips,this._order=t,this._amIStillInFoV_requsetID=window.setInterval(()=>{this.amIStillInFoV()},5e3),this.initImage()}destroyIntervals(){window.clearInterval(this._amIStillInFoV_requsetID)}getReadyState(){return this._ready}isLoading(){return!this._ready&&!this._abort}get cacheTime0(){return this._cacheTime0}resetCacheTime0(){this._cacheTime0=void 0}setCacheTime0(){this._cacheTime0=(new Date).getTime()}initImage(){if(this._order>this._maxorder)return this._ready=!1,this._abort=!0,this.destroyIntervals(),void console.warn(`[Tile] Skipping tile request above max order: requested order ${this._order}, max order ${this._maxorder}, url ${this._baseurl}`);this._image=new Image;const e=1e4*Math.floor(this._tileno/1e4);this._texurl=`${this._baseurl}/Norder${this._order}/Dir${e}/Npix${this._tileno}.${this._format}`,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{this._ready=!1,this._abort=!0,this.destroyIntervals()},this._image.crossOrigin="anonymous",this._image.src=this._texurl}imageLoaded(){this._ready=!0}textureLoaded(e){e.enableProgram();const t=this._webgl;this._texture=t.createTexture(),t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,this._texture),t.isTexture(this._texture)||console.log("error in texture"),t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.bindTexture(t.TEXTURE_2D,this._texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this._image),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.isTexture(this._texture)||console.warn("Texture creation failed"),this.initModelBuffer(),this._textureLoaded=!0}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=a.fovHelper.getRefOrder(this._order),i=s.default.getHealpix(this._order).nest2xyf(this._tileno),r=t-this._order,o=i.ix<<r,n=(i.ix<<r)+(1<<r),h=i.iy<<r,l=(i.iy<<r)+(1<<r),c=s.default.getHealpix(t);this.setupPositionAndTexture4Quadrant2(o,o+(n-o)/2,h,h+(l-h)/2,0,c,r,i),this.setupPositionAndTexture4Quadrant2(o+(n-o)/2,n,h,h+(l-h)/2,1,c,r,i),this.setupPositionAndTexture4Quadrant2(o,o+(n-o)/2,h+(l-h)/2,l,2,c,r,i),this.setupPositionAndTexture4Quadrant2(o+(n-o)/2,n,h+(l-h)/2,l,3,c,r,i);const u=this.vertexPosition[0].length/20,d=this.computeVertexIndices(u);d.length>65535?this.vertexIndices=new Uint32Array(d):this.vertexIndices=new Uint16Array(d),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint32Array(6*e);let i=0;for(let r=0;r<e;r++){const e=i;t[6*r]=e,t[6*r+1]=e+1,t[6*r+2]=e+2,t[6*r+3]=e+2,t[6*r+4]=e+3,t[6*r+5]=e,i+=4}return t}setupPositionAndTexture4Quadrant2(e,t,i,r,s,a,o,n){const h=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(r-i));const l=1/(1<<o);let c=0;for(let h=e;h<t;h++)for(let e=i;e<r;e++){const t=a.getPointsForXyfNoStep(h,e,n.face),i=e-(n.iy<<o),r=h-(n.ix<<o);this.vertexPosition[s][20*c]=t[0].x,this.vertexPosition[s][20*c+1]=t[0].y,this.vertexPosition[s][20*c+2]=t[0].z,this.vertexPosition[s][20*c+3]=l+l*i+0,this.vertexPosition[s][20*c+4]=1-(l+l*r)-0,this.vertexPosition[s][20*c+5]=t[1].x,this.vertexPosition[s][20*c+6]=t[1].y,this.vertexPosition[s][20*c+7]=t[1].z,this.vertexPosition[s][20*c+8]=l+l*i+0,this.vertexPosition[s][20*c+9]=1-l*r+0,this.vertexPosition[s][20*c+10]=t[2].x,this.vertexPosition[s][20*c+11]=t[2].y,this.vertexPosition[s][20*c+12]=t[2].z,this.vertexPosition[s][20*c+13]=l*i-0,this.vertexPosition[s][20*c+14]=1-l*r+0,this.vertexPosition[s][20*c+15]=t[3].x,this.vertexPosition[s][20*c+16]=t[3].y,this.vertexPosition[s][20*c+17]=t[3].z,this.vertexPosition[s][20*c+18]=l*i-0,this.vertexPosition[s][20*c+19]=1-(l+l*r)-0,c++}this.vertexPositionBuffer[s]=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,this.vertexPositionBuffer[s]),h.bufferData(h.ARRAY_BUFFER,this.vertexPosition[s],h.STATIC_DRAW)}get inView(){return this._inView}moveToCache(){this._tileBuffer.moveTileToCache(this._tileno,this._order,this._hips),this._inView=!1,this.destroyIntervals()}amIStillInFoV(){this._textureLoaded&&(this._ready=!0),this._isGalacticHips?(this._visibleTileManager.galAncestorsMap.has(this._order)&&(this._visibleTileManager.galAncestorsMap.get(this._order).includes(this._tileno)?this._inView=!0:this.moveToCache()),this._order==this._visibleTileManager.visibleOrder&&(this._visibleTileManager.galVisibleTilesByOrder.pixels.includes(this._tileno)?this._inView=!0:this.moveToCache())):(this._visibleTileManager.ancestorsMap.has(this._order)&&(this._visibleTileManager.ancestorsMap.get(this._order).includes(this._tileno)?this._inView=!0:this.moveToCache()),this._order==this._visibleTileManager.visibleOrder&&(this._visibleTileManager.visibleTilesByOrder.pixels.includes(this._tileno)?this._inView=!0:this.moveToCache()))}draw(e,t,i,r,s,a,o){if(!this._ready||this._abort)return;this._textureLoaded||this.textureLoaded(o);let n=new Set([0,1,2,3]);if(e>this._order&&this._order<this._maxorder){const h=this.drawChildren(e,t,i,r,s,a,o);h&&(n=h)}const h=this._webgl;o.enableShaders(i,r,s,a),h.enableVertexAttribArray(o.locations.vertexPositionAttribute),h.enableVertexAttribArray(o.locations.textureCoordAttribute),h.activeTexture(h.TEXTURE0+this._hipsShaderIndex),h.bindTexture(h.TEXTURE_2D,this._texture),h.uniform1f(o.locations.textureAlpha,this.opacity),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);const l=this.vertexIndices.length,c=this.vertexIndices instanceof Uint32Array?h.UNSIGNED_INT:h.UNSIGNED_SHORT;n.forEach(e=>{h.bindBuffer(h.ARRAY_BUFFER,this.vertexPositionBuffer[e]),h.vertexAttribPointer(o.locations.vertexPositionAttribute,3,h.FLOAT,!1,20,0),h.vertexAttribPointer(o.locations.textureCoordAttribute,2,h.FLOAT,!1,20,12),h.drawElements(h.TRIANGLES,l,c,0)}),h.disableVertexAttribArray(o.locations.vertexPositionAttribute),h.disableVertexAttribArray(o.locations.textureCoordAttribute)}drawChildren(e,t,i,r,s,a,o){const n=new Set([0,1,2,3]),h=this._order+1;if(t.has(h)){for(let l=0;l<4;l++){const c=(this._tileno<<2)+l;if(t.get(h).includes(c)){const l=this._isGalacticHips?this._tileBuffer.getGalTile(c,h,this._hips):this._tileBuffer.getTile(c,h,this._hips);l.draw(e,t,i,r,s,a,o),l._ready&&n.delete(c-(this._tileno<<2))}}return n}}}},8284:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.xyzFovHelper=void 0;class i{static LEVEL_HYSTERESIS=.12;static ZOOM_MIN_FOV={2:179,3:90,4:30,5:20,6:6,7:3.2,8:1.6,9:.85,10:.42,11:.21,12:.12,13:.06,14:.015,15:0};getZoom(e,t){const r=this.getRawZoom(e);if(void 0===t||t===r)return r;if(r>t){const r=i.ZOOM_MIN_FOV[t];if(r>0&&e>r*(1-i.LEVEL_HYSTERESIS))return t}else{const s=i.ZOOM_MIN_FOV[r];if(s>0&&e<s*(1+i.LEVEL_HYSTERESIS))return t}return r}getRawZoom(e){return e>=179?2:e>=90?3:e>=30?4:e>=20?5:e>=6?6:e>=3.2?7:e>=1.6?8:e>=.85?9:e>=.42?10:e>=.21?11:e>=.12?12:e>=.06?13:e>=.015?14:15}getLonLatSteps(e,t=!1){let i,r;return t&&e<.21||e>=179?(i=10,r=10):e>=25?(i=9,r=9):e>=12.5?(i=8,r=8):e>=6?(i=6,r=6):e>=3.2?(i=5,r=5):e>=1.6?(i=4,r=4):e>=.85?(i=3,r=3):e>=.42?(i=2,r=2):e>=.21?(i=1,r=1):e>=.12?(i=.5,r=.5):e>=.06?(i=.25,r=.25):(i=10,r=10),{lonStep:i,latStep:r}}}t.xyzFovHelper=new i,t.default=i},8755:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const r=i(8145),s=i(6553);class a{static isGeoJSON(e){if(!e||"object"!=typeof e)return!1;const t=e.type;return"FeatureCollection"===t||"Feature"===t||"Polygon"===t||"MultiPolygon"===t||"GeometryCollection"===t}static parseGeoJSON(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON root must be an object");const t=e;if("FeatureCollection"===t.type){if(!Array.isArray(t.features))throw new Error("GeoJSON FeatureCollection has no features array");return t.features.flatMap(e=>a.parseFeature(e))}if("Feature"===t.type)return a.parseFeature(t);if("Polygon"===t.type||"MultiPolygon"===t.type||"GeometryCollection"===t.type)return a.parseGeometry(t,{});throw new Error(`Unsupported GeoJSON type: ${t.type??"unknown"}`)}static parseFeature(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON feature must be an object");const t=e;if("Feature"!==t.type)throw new Error("GeoJSON feature has invalid type");return t.geometry?a.parseGeometry(t.geometry,t.properties??{},t.id):[]}static parseGeometry(e,t,i){return"Polygon"===e.type?[{id:i,geometryType:"Polygon",properties:t,polygons:a.parsePolygonCoordinates(e.coordinates)}]:"MultiPolygon"===e.type?[{id:i,geometryType:"MultiPolygon",properties:t,polygons:a.parseMultiPolygonCoordinates(e.coordinates)}]:"GeometryCollection"===e.type&&Array.isArray(e.geometries)?e.geometries.flatMap(e=>a.parseGeometry(e,t,i)):[]}static parseMultiPolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON MultiPolygon coordinates must be an array");return e.flatMap(e=>a.parsePolygonCoordinates(e))}static parsePolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON Polygon coordinates must be an array");return e.map(e=>a.parseLinearRing(e)).filter(e=>e.length>=3)}static parseLinearRing(e){if(!Array.isArray(e))throw new Error("GeoJSON linear ring must be an array");const t=e.map(e=>a.parsePosition(e));if(t.length>1){const e=t[0],i=t[t.length-1];e.lonDeg===i.lonDeg&&e.latDeg===i.latDeg&&t.pop()}return t}static parsePosition(e){if(!Array.isArray(e)||e.length<2)throw new Error("GeoJSON position must be [longitude, latitude]");const[t,i]=e;if(!Number.isFinite(t)||!Number.isFinite(i))throw new Error("GeoJSON position contains non-finite longitude/latitude");return new s.Point({lonDeg:t,latDeg:i},r.CoordsType.GEOGRAPHIC)}}t.default=a},8819:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMeshBuilder=void 0;const r=i(7930);function s(e){const t=Math.PI*(1-2*e);return 180*Math.atan(Math.sinh(t))/Math.PI}function a(e){return e<0?e+360:e}t.XYZMeshBuilder=class{buildTileMesh(e,t=16){const i=Math.max(1,Math.floor(t)),o=i+1,n=o*o,h=new Float32Array(3*n),l=new Float32Array(2*n),c=2**e.z;let u=0,d=0;for(let t=0;t<=i;t++){const o=t/i,n=(e.y+o)/c,_=90-Math.max(-85.0511287798066,Math.min(85.0511287798066,s(n)));for(let t=0;t<=i;t++){const s=t/i,n=a((e.x+s)/c*360-180),[f,g,p]=(0,r.sphericalToCartesian)(n,_,1);h[u++]=f,h[u++]=g,h[u++]=p,l[d++]=s,l[d++]=1-o}}const _=new Uint32Array(i*i*2*3);let f=0;for(let e=0;e<i;e++)for(let t=0;t<i;t++){const i=e*o+t,r=i+1,s=i+o,a=s+1;_[f++]=i,_[f++]=s,_[f++]=r,_[f++]=r,_[f++]=s,_[f++]=a}return{positions:h,uvs:l,indices:_.length>65535?_:new Uint16Array(_)}}buildAncestorMesh(e,t,i=16){const r=this.buildTileMesh(e,i),s=e.z-t.z,a=2**s,o=e.x-(t.x<<s),n=e.y-(t.y<<s),h=new Float32Array(r.uvs.length);for(let e=0;e<r.uvs.length;e+=2){const t=r.uvs[e]??0,i=1-(r.uvs[e+1]??0);h[e]=(o+t)/a,h[e+1]=1-(n+i)/a}return{positions:r.positions,uvs:h,indices:r.indices}}uploadMesh(e,t){const i=t.createBuffer(),r=t.createBuffer(),s=t.createBuffer(),a=e.indices instanceof Uint32Array?t.UNSIGNED_INT:t.UNSIGNED_SHORT;return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.uvs,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),{positionBuffer:i,uvBuffer:r,indexBuffer:s,indexCount:e.indices.length,indexType:a}}}},8868:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMapDescriptor=void 0,t.XYZMapDescriptor=class{_name;_url;_urlResolver;_minZoom;_maxZoom;_segmentsPerSide;_tileSize;_maxCachedTiles;_interactionDebounceMs;_subdomains;_attribution;_flipY;_maxConcurrentLoads;constructor(e,t,i=0,r=8,s=16,a=384,o=8,n){this._name=e,this._url=t,this._urlResolver=n,this._minZoom=i,this._maxZoom=r,this._segmentsPerSide=s,this._maxCachedTiles=a,this._interactionDebounceMs=100,this._subdomains=["a","b","c"],this._attribution="",this._flipY=!1,this._maxConcurrentLoads=o}get url(){return this._url}get urlResolver(){return this._urlResolver}get name(){return this._name}get minZoom(){return this._minZoom}get maxZoom(){return this._maxZoom}get segmentsPerSide(){return this._segmentsPerSide}get maxCachedTiles(){return this._maxCachedTiles}get interactionDebounceMs(){return this._interactionDebounceMs}get subdomains(){return this._subdomains}get attribution(){return this._attribution}get flipY(){return this._flipY}get maxConcurrentLoads(){return this._maxConcurrentLoads}}},8909:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintShaderProgram=void 0;const s=i(1961),a=r(i(5947));t.FootprintShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix",point_size:"u_pointsize"},this.gl_attributes={vertex_pos:"aCatPosition"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,pointSize:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=a.default.footprintFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const i=a.default.footprintVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),console.log("VS log:",e.getShaderInfoLog(this._vertexShader)||"ok"),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this.shaderProgram,this._vertexShader),e.attachShader(this.shaderProgram,this._fragmentShader),e.linkProgram(this.shaderProgram),e.getProgramParameter(this.shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this.shaderProgram),this.locations.position=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.pointSize=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.point_size),this.locations.color=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.vertex_color)):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableShaders(e,t,i){const r=this._webgl;r.useProgram(this.shaderProgram),this.locations.pMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let a=s.mat4.create();a=s.mat4.multiply(a,i,t),r.uniformMatrix4fv(this.locations.pMatrix,!1,e),r.uniformMatrix4fv(this.locations.mvMatrix,!1,a)}}},9022:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TerraFootprintSetGL=void 0;const r=i(592),s=i(8145),a=i(2475),o=i(1072),n=i(5403),h=i(1072);class l extends r.FootprintSetGL{_kind="TerraFootprintSetGL";_coordsType=s.CoordsType.GEOGRAPHIC;addGeoJSONFeatures(e){this._ready=!1,this.clearFootprints(),this._metadataManager=new n.MetadataManager(this.createGeoJSONMetadataColumns(e));for(const t of e){const e=a.Footprint.fromPolygons(t.polygons,this.createGeoJSONDetails(t),s.CoordsType.GEOGRAPHIC);e.valid&&(this.addFootprint(e),this.totPoints+=e.totPoints,this.totConvexPoints+=e.totConvexPoints)}this._ready=!0,this._bufferInitialised=!1}createGeoJSONMetadataColumns(e){const t=new Set;return e.forEach(e=>Object.keys(e.properties).forEach(e=>t.add(e))),Array.from(t).map((t,i)=>{const r=e.map(e=>e.properties[t]).filter(e=>null!=e&&""!==e),s=r.length>0&&r.every(e=>"number"==typeof e||!Number.isNaN(Number(e))),a=/^name$|nome|denominazione|label|title/i.test(t);return new o.MetadataColumn({index:i,name:t,columnType:a?h.ColumnType.MAIN_NAME:s?h.ColumnType.NUMBER:h.ColumnType.STRING,unit:""})})}createGeoJSONDetails(e){return Object.entries(e.properties).map(([e,t])=>({key:e,value:"number"==typeof t?t:String(t??"")}))}}t.TerraFootprintSetGL=l},9665:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(6553),a=i(8145),o=r(i(4382));class n{static parseSTCS(e,t={}){const i=n.cleanStcs(e);return i.includes("POLYGON")?n.parsePolygon(i,t):i.includes("CIRCLE")?n.parseCircle(i,t):(console.warn("STCS not recognised"),{totpoints:0,polygons:[]})}static cleanStcs(e){let t=e.toUpperCase();return t=t.replace(/'ICRS'/g,"").replace(/\bICRS\b/g,"").replace(/\bJ2000\b/g,"").replace(/\bUNION\b/g,"").replace(/\bTOPOCENTER\b/g,""),t=t.replace(/[()]/g,""),t=t.replace(/ {2,}/g," ").trim(),t}static parsePolygon(e,t={}){let i=0;const r=[],n=o.default.MAX_DECIMALS??12,h=t.coordsType??a.CoordsType.ASTRO,l=e.split("POLYGON ");for(let e=1;e<l.length;e++){const t=[],o=l[e].trim().split(" "),c=Number(parseFloat(o[0]).toFixed(n)),u=Number(parseFloat(o[1]).toFixed(n)),d=Number(parseFloat(o[o.length-2]).toFixed(n)),_=Number(parseFloat(o[o.length-1]).toFixed(n));if(c===d&&u===_&&o.splice(o.length-2,2),o.length>2){for(let e=0;e<o.length-1;e+=2){const r=Number(parseFloat(o[e]).toFixed(n)),l=Number(parseFloat(o[e+1]).toFixed(n)),c=h===a.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:r,latDeg:l},a.CoordsType.GEOGRAPHIC):new s.Point({raDeg:r,decDeg:l},a.CoordsType.ASTRO);t.push(c),i+=1}r.push(t)}}return{totpoints:i,polygons:r}}static parseCircle(e,t={}){let i=0;const r=[],o=t.coordsType??a.CoordsType.ASTRO,n=e.split("CIRCLE ");for(let e=1;e<n.length;e++){const t=[],h=n[e].trim().split(" "),l=Number(h[0]),c=Number(h[1]),u=Number(h[2]),d=24,_=2*Math.PI/d;for(let e=d;e>0;e--){const r=u*Math.cos(e*_)+l,n=u*Math.sin(e*_)+c,h=o===a.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:r,latDeg:n},a.CoordsType.GEOGRAPHIC):new s.Point({raDeg:r,decDeg:n},a.CoordsType.ASTRO);t.push(h),i+=1}r.push(t)}return{totpoints:i,polygons:r}}}t.default=n},9685:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PerspectiveMatrixManager=void 0;const r=i(1961),s=i(2919);t.PerspectiveMatrixManager=class{_pMatrix;_aspectRatio=1;constructor(e,t,i,r=.1,s){this._pMatrix=this.computePerspectiveMatrix(e,t,i,r,s)}get pMatrix(){return this._pMatrix}set pMatrix(e){this._pMatrix=e}computePerspectiveMatrix(e,t,i,a=.1,o){this._aspectRatio=e.width/e.height;const n=r.mat4.create();let h;if(o)h=1.1;else{const e=t.getCameraMatrix(),i=-Number(e[14]),r=1,s=Math.sqrt(Math.max(i**2-r**2,0)),a=Math.atan2(s,r),o=s*Math.sin(a);h=o>0?o:r}const l=o?s.bootSetup.inside_camera_fov_deg:i,c=o?Math.max(a,.001):a;return r.mat4.perspective(n,l*Math.PI/180,this._aspectRatio,c,h),this._pMatrix=n,n}}},9839:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.EquatorialGrid=void 0;const s=i(1961),a=i(229),o=i(7930),n=r(i(4707)),h=i(6553),l=i(8145),c=i(8083),u=r(i(5361)),d=i(4595),_=i(4735);class f extends _.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;showGrid=!1;_shaderProgram;_vertexShader;_fragmentShader;defaultColor="#41d421";gridText=new u.default("equatorial");_attribLocations={position:0,selected:1,pointSize:2,color:3};_phiVertexPositionBuffer;_thetaVertexPositionBuffer;_fov;_phiStep=0;_phiStepRad=0;_thetaStep=0;_thetaStepRad=0;_phiArray=[];_thetaArray=[];_bufferKey="";_dec4Labels=new Map;_ra4Labels=new Map;_healpixGrid;constructor(e,t){super(d.HealpixGrid.RADIUS,d.HealpixGrid.INITIAL_POSITION,d.HealpixGrid.INITIAL_PhiRad,d.HealpixGrid.INITIAL_ThetaRad,"equatorial-grid",e),this._healpixGrid=t}init(e){this._fov=e,this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders(),this._phiVertexPositionBuffer=super.webgl.createBuffer(),this._thetaVertexPositionBuffer=super.webgl.createBuffer(),this.initBuffers(this._fov)}initShaders(){const e=n.default.healpixGridFS();if(this._fragmentShader=super.webgl.createShader(super.webgl.FRAGMENT_SHADER),super.webgl.shaderSource(this._fragmentShader,e),super.webgl.compileShader(this._fragmentShader),!super.webgl.getShaderParameter(this._fragmentShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(e),void alert(e)}const t=n.default.healpixGridVS();if(this._vertexShader=super.webgl.createShader(super.webgl.VERTEX_SHADER),super.webgl.shaderSource(this._vertexShader,t),super.webgl.compileShader(this._vertexShader),!super.webgl.getShaderParameter(this._vertexShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(e),void alert(e)}super.webgl.attachShader(this._shaderProgram,this._vertexShader),super.webgl.attachShader(this._shaderProgram,this._fragmentShader),super.webgl.linkProgram(this._shaderProgram),super.webgl.getProgramParameter(this._shaderProgram,super.webgl.LINK_STATUS)||alert("Could not initialise shaders"),super.webgl.useProgram(this._shaderProgram)}initBuffers(e,t=!1){const i=a.fovHelper.getRADegSteps(e,t),r=i.raStep,s=i.decStep;this._phiStep=r,this._phiStepRad=(0,o.degToRad)(r),this._thetaStep=s,this._thetaStepRad=(0,o.degToRad)(s),this._ra4Labels=new Map,this._dec4Labels=new Map,this._phiArray=[],this._thetaArray=[];for(let e=s;e<180;e+=s){const t=new Float32Array(360/r*3),i=(0,o.degToRad)(e);for(let e=0;e<360;e+=r){const s=(0,o.degToRad)(e),a=1*Math.sin(i)*Math.cos(s),n=1*Math.sin(i)*Math.sin(s),h=1*Math.cos(i),l=Math.floor(e/r);t[3*l+0]=a,t[3*l+1]=n,t[3*l+2]=h,this._dec4Labels.has(e)||this._dec4Labels.set(e,[]),this._dec4Labels.get(e).push([a,n,h])}this._phiArray.push(t)}for(let e=0;e<360;e+=r){const t=new Float32Array(360/s*3),i=(0,o.degToRad)(e);for(let e=0;e<360;e+=s){const r=(0,o.degToRad)(e),a=1*Math.sin(r)*Math.cos(i),n=1*Math.sin(r)*Math.sin(i),h=1*Math.cos(r),l=Math.floor(e/s);t[3*l+0]=a,t[3*l+1]=n,t[3*l+2]=h;const c=90-e;this._ra4Labels.has(c)||this._ra4Labels.set(c,[]),this._ra4Labels.get(c).push([a,n,h])}this._thetaArray.push(t)}}refresh(e,t=!1){const i=a.fovHelper.getRADegSteps(e,t),r=`${t?"coarse":"settled"}:${i.raStep}:${i.decStep}`;this._bufferKey!==r&&(this._fov=e,this._bufferKey=r,this.initBuffers(this._fov,t))}vectorDistance(e,t){const i=e.x-t.x,r=e.y-t.y,s=e.z-t.z;return Math.sqrt(i*i+r*r+s*s)}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const a=s.mat4.create();s.mat4.multiply(a,i,e);const n=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),h=r.getUniformLocation(this._shaderProgram,"uPMatrix"),l=r.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition"),n&&r.uniformMatrix4fv(n,!1,a),h&&r.uniformMatrix4fv(h,!1,t),l){const e=(0,o.colorHex2RGB)(this.defaultColor);r.uniform4f(l,e[0],e[1],e[2],1)}}isVisible(){return this.showGrid}toggleShowGrid(){this.showGrid=!this.showGrid}draw(e){const t=e.fovDeg;if(!t)return;const i=super.webgl,r=this.getModelMatrix(),a=e.camera;if(!a)return;const n=a.getCameraMatrix(),u=e.pMatrix;if(!u)return;if(!n)return;if(0===this._thetaArray.length)return;if(this.refresh(t,!!e.cameraMoving),!this.showGrid)return void this.gridText.resetDivSets();this.enableShader(r,u,n);for(let e=0;e<this._phiArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._phiVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._phiArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._phiStep);for(let e=0;e<this._thetaArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._thetaVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._thetaArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._thetaStep);const d=c.FoVUtils.getCenterJ2000(i.canvas,this._healpixGrid,this._webgl,a,u),_=s.mat4.create();s.mat4.multiply(_,n,r);const f=s.mat4.create();s.mat4.multiply(f,u,_);for(const[e,t]of this._dec4Labels.entries())if(Math.abs(e-d.raDeg)<=this._phiStep)for(let e=0;e<t.length;e++){const[i,r,a]=t[e],o=[i,r,a,1],n=new h.Point({x:i,y:r,z:a},l.CoordsType.CARTESIAN).decDeg;if(Math.abs(n-d.decDeg)<60){const e=s.vec4.create();s.vec4.transformMat4(e,o,f),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),i=t.left+(.5*e[0]+.5)*t.width,r=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(n.toFixed(2),i,r,"dec")}}for(const[e,t]of this._ra4Labels.entries())if(Math.abs(e-d.decDeg)<=this._thetaStep)for(let e=0;e<t.length;e++){const[i,r,a]=t[e],n=[i,r,a,1],c=new h.Point({x:i,y:r,z:a},l.CoordsType.CARTESIAN),u=this.vectorDistance(c,d),_=c.raDeg;if(u<(0,o.degToRad)(50)){const e=s.vec4.create();s.vec4.transformMat4(e,n,f),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),i=t.left+(.5*e[0]+.5)*t.width,r=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(_.toFixed(2),i,r,"ra")}}this.gridText.resetDivSets(),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null)}}t.EquatorialGrid=f}},t={};function i(r){var s=t[r];if(void 0!==s)return s.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,i),a.exports}return i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i(1229)})());
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("astroviewer",[],t):"object"==typeof exports?exports.astroviewer=t():e.astroviewer=t()}(self,()=>(()=>{"use strict";var e={146:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Source=void 0;const s=r(1138),a=i(r(4382));t.Source=class{_point;_name;_details;_h_pix;_shapesize;_brightnessFactor;constructor(e,t=[]){this._point=e,this._details=t,this._shapesize=16,this._brightnessFactor=-99,this.computeHealpixPixel()}getDetailByindex(e){if(!(e<0||e>=this._details.length))return this._details[e]}get details(){return this._details}computeHealpixPixel(){const e=a.default.getHealpix(a.default.nsideForSelection),t=new s.Vec3(this._point.x,this._point.y,this._point.z),r=new s.Pointing(t,!1);this._h_pix=e.ang2pix(r,!1)}get point(){return this._point}get name(){return this._name}get healpixPixel(){return this._h_pix}get shapeSize(){return this._shapesize}set shapeSize(e){this._shapesize=e}get brightnessFactor(){return this._brightnessFactor}set brightnessFactor(e){this._brightnessFactor=e}}},149:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZShaderProgram=void 0;const i=r(619);t.XYZShaderProgram=class{locations;_webgl;_shaderProgram;_colorMapBlockIndex=null;_colorMapBuffer=null;_runtimeColorMap;_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};constructor(e){this._webgl=e,this.locations={pMatrix:null,mMatrix:null,vMatrix:null,sampler:null,colorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();if(!t)throw new Error("Could not create XYZ shader program");this._shaderProgram=t,this.initShaders()}return e.useProgram(this._shaderProgram),this._shaderProgram}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setRuntimeColorMap(e){this._runtimeColorMap=e}enableShaders(e,t,r,i=0){const s=this._webgl,a=this.shaderProgram;s.useProgram(a),this.locations.pMatrix=s.getUniformLocation(a,"uPMatrix"),this.locations.mMatrix=s.getUniformLocation(a,"uMMatrix"),this.locations.vMatrix=s.getUniformLocation(a,"uVMatrix"),this.locations.sampler=s.getUniformLocation(a,"uSampler"),this.locations.colorMapIdx=s.getUniformLocation(a,"cmapIdx"),this.locations.vertexPositionAttribute=s.getAttribLocation(a,"aVertexPosition"),this.locations.textureCoordAttribute=s.getAttribLocation(a,"aTextureCoord"),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t),s.uniformMatrix4fv(this.locations.mMatrix,!1,r),s.uniform1i(this.locations.sampler,0),s.uniform1i(this.locations.colorMapIdx,i),i>=2&&this.uploadColorMap(i)}initShaders(){const e=this._webgl,t=this.compileShader(e.VERTEX_SHADER,"#version 300 es\n in vec3 aVertexPosition;\n in vec2 aTextureCoord;\n uniform mat4 uPMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uMMatrix;\n out vec2 vTextureCoord;\n void main(void) {\n vTextureCoord = aTextureCoord;\n gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);\n }"),r=this.compileShader(e.FRAGMENT_SHADER,"#version 300 es\n precision mediump float;\n in vec2 vTextureCoord;\n uniform sampler2D uSampler;\n uniform int cmapIdx;\n\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n out vec4 outColor;\n\n void main(void) {\n vec4 color = texture(uSampler, vTextureCoord);\n\n if (cmapIdx == 1) {\n float gray = 0.21 * color.r + 0.71 * color.g + 0.07 * color.b;\n outColor = vec4(vec3(gray), color.a);\n return;\n }\n\n if (cmapIdx >= 2) {\n int rIndex = int(clamp(color.r * 255.0, 0.0, 255.0));\n int gIndex = int(clamp(color.g * 255.0, 0.0, 255.0));\n int bIndex = int(clamp(color.b * 255.0, 0.0, 255.0));\n\n outColor = vec4(\n r_palette[rIndex] / 256.0,\n g_palette[gIndex] / 256.0,\n b_palette[bIndex] / 256.0,\n color.a\n );\n return;\n }\n\n outColor = color;\n }");if(e.attachShader(this._shaderProgram,t),e.attachShader(this._shaderProgram,r),e.linkProgram(this._shaderProgram),!e.getProgramParameter(this._shaderProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._shaderProgram)||"Could not initialise XYZ shaders");this.initColorMapBuffer()}compileShader(e,t){const r=this._webgl,i=r.createShader(e);if(!i)throw new Error("Could not create XYZ shader");if(r.shaderSource(i,t),r.compileShader(i),!r.getShaderParameter(i,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(i)||"XYZ shader compile error");return i}initColorMapBuffer(){const e=this._webgl,t=this._shaderProgram,r=e.getUniformBlockIndex(t,"colormap");if(r===e.INVALID_INDEX)return void(this._colorMapBlockIndex=null);this._colorMapBlockIndex=r;const i=["r_palette","g_palette","b_palette"],s=e.getUniformIndices(t,i),a=e.getActiveUniforms(t,s,e.UNIFORM_OFFSET);i.forEach((e,t)=>{this._colorMapVariableInfo[e]={index:s[t],offset:a[t]}}),this._colorMapBuffer=e.createBuffer(),e.bindBuffer(e.UNIFORM_BUFFER,this._colorMapBuffer),e.bufferData(e.UNIFORM_BUFFER,12288,e.STATIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,0,this._colorMapBuffer),e.uniformBlockBinding(t,r,0)}uploadColorMap(e){if(!this._colorMapBuffer||null===this._colorMapBlockIndex)return;const t=this.getColorMap(e);if(!t)return;const r=this._webgl,i=this.shaderProgram;r.uniformBlockBinding(i,this._colorMapBlockIndex,0),r.bindBuffer(r.UNIFORM_BUFFER,this._colorMapBuffer);const s=this._colorMapVariableInfo;r.bufferSubData(r.UNIFORM_BUFFER,s.r_palette.offset,t.r,0),r.bufferSubData(r.UNIFORM_BUFFER,s.g_palette.offset,t.g,0),r.bufferSubData(r.UNIFORM_BUFFER,s.b_palette.offset,t.b,0),r.bindBuffer(r.UNIFORM_BUFFER,null)}getColorMap(e){switch(e){case 2:return i.ColorMaps.planck;case 3:return i.ColorMaps.cmb;case 4:return i.ColorMaps.rainbow;case 5:return i.ColorMaps.eosb;case 6:return i.ColorMaps.cubehelix;case 7:return i.ColorMaps.hot;case 8:return i.ColorMaps.gray;default:return this._runtimeColorMap}}}},229:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fovHelper=void 0;class r{static LEVEL_HYSTERESIS=.12;static HIPS_ORDER_MIN_FOV={0:179,1:90,2:30,3:20,4:6,5:3.2,6:1.6,7:.85,8:.42,9:.21,10:.12,11:.06,12:.015,13:0};getHiPSNorder(e,t){const i=this.getRawHiPSNorder(e);if(void 0===t||t===i)return i;if(i>t){const i=r.HIPS_ORDER_MIN_FOV[t];if(i>0&&e>i*(1-r.LEVEL_HYSTERESIS))return t}else{const s=r.HIPS_ORDER_MIN_FOV[i];if(s>0&&e<s*(1+r.LEVEL_HYSTERESIS))return t}return i}getRawHiPSNorder(e){return e>=179?0:e>=90?1:e>=30?2:e>=20?3:e>=6?4:e>=3.2?5:e>=1.6?6:e>=.85?7:e>=.42?8:e>=.21?9:e>=.12?10:e>=.06?11:e>=.015?12:13}getRADegSteps(e,t=!1){let r,i;return t&&e<.21||e>=179?(r=10,i=10):e>=25?(r=9,i=9):e>=12.5?(r=8,i=8):e>=6?(r=6,i=6):e>=3.2?(r=5,i=5):e>=1.6?(r=4,i=4):e>=.85?(r=3,i=3):e>=.42?(r=2,i=2):e>=.21?(r=1,i=1):e>=.12?(r=.5,i=.5):e>=.06?(r=.25,i=.25):(r=10,i=10),{raStep:r,decStep:i}}getRefOrder(e){switch(e){case 0:case 1:case 2:case 3:return e+6;case 4:case 5:case 6:case 7:return e+5;case 8:return e+4;default:return e+3}}}t.fovHelper=new r,t.default=r},592:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintSetGL=void 0;const s=r(2475),a=r(7930),o=r(8909),n=r(6553),h=i(r(2930)),l=r(8145),c=r(5403);class u{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;static CONVEXPOLY_ELEM_SIZE=3;_kind="FootprintSetGL";_ready;_name;_description;extHoveredIndexes;oldMouseCoords;healpixDensityMap;totConvexPoints;vertexCataloguePositionBuffer;indexBuffer;hoveredVertexPositionBuffer;hoveredIndexBuffer;selectedVertexPositionBuffer;selectedIndexBuffer;indexes;footprintPolygons=[];vertexCataloguePosition;totPoints;nPrimitiveFlags=0;hoveredIndexes;hoveredElementIndexes;_hoveredFootprints=[];hoveredVertexPosition;totHoveredPoints;nHoveredPrimitiveFlags=0;selectedIndexes;selectedElementIndexes;_selectedFootprints=[];selectedVertexPosition;totSelectedPoints;nSlectedPrimitiveFlags=0;_shapeColor="#00fff2ff";_coordsType=l.CoordsType.ASTRO;_bufferInitialised=!1;_webgl;_isVisible=!0;_metadataManager;_providerUrl;_footprintShaderProgram;_visibleTilesManager;constructor(e,t,r,i,s,a){this._webgl=s,this._ready=!1,this._visibleTilesManager=a,this.TYPE="FOOTPRINT_SET",this._name=e,this._description=t,this._providerUrl=r,this._metadataManager=i,this.initFootprintArrays(),this.oldMouseCoords=null,this._footprintShaderProgram=new o.FootprintShaderProgram(this._webgl),this._footprintShaderProgram.shaderProgram}initFootprintArrays(){this.footprintPolygons=[],this.indexes=new Uint32Array,this.vertexCataloguePosition=new Float32Array,this.totPoints=0,this.totConvexPoints=0,this.extHoveredIndexes=new Uint32Array,this._hoveredFootprints=[],this.hoveredVertexPosition=new Float32Array,this.totHoveredPoints=0,this.hoveredIndexes=[],this.hoveredElementIndexes=new Uint32Array,this._selectedFootprints=[],this.selectedVertexPosition=new Float32Array,this.totSelectedPoints=0,this.selectedIndexes=[],this.selectedElementIndexes=new Uint32Array}initGLBuffers(){this._webgl&&(this.vertexCataloguePositionBuffer=this._webgl.createBuffer(),this.indexBuffer=this._webgl.createBuffer(),this.hoveredVertexPositionBuffer=this._webgl.createBuffer(),this.hoveredIndexBuffer=this._webgl.createBuffer(),this.selectedVertexPositionBuffer=this._webgl.createBuffer(),this.selectedIndexBuffer=this._webgl.createBuffer())}setIsVisible(e){this._isVisible=e}get isVisible(){return this._isVisible}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get metadataManager(){return this._metadataManager}addFootprint(e){this.footprintPolygons.push(e)}addFootprints(e,t){this._ready=!1,this._metadataManager=new c.MetadataManager(t);const r=this._metadataManager.selectedOutlineColumn?.index??-1;if(r<0)throw new Error("geomColumn or its index is undefined in footprintsetProps");for(let t=0;t<e.length;t++)if(null!==e[t][r]){const i=new s.Footprint(e[t][r],e[t],void 0,this._coordsType);i._valid&&(this.addFootprint(i),this.totPoints+=i.totPoints,this.totConvexPoints+=i.totConvexPoints)}this._ready=!0,this._bufferInitialised=!1}clearFootprints(){this.initFootprintArrays()}initBuffer(){if(!this._webgl)return;this.initGLBuffers();const e=this.footprintPolygons.length;let t=e-1;for(let r=0;r<e;r++)t+=this.footprintPolygons[r].polygons.length-1;this.indexes=new Uint32Array(this.totPoints+t+1);const r=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this.vertexCataloguePosition=new Float32Array(3*this.totPoints);let i=0,s=0;this.nPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this.footprintPolygons[t].polygons;t>0&&(this.indexes[s++]=r,this.nPrimitiveFlags++);for(const t of e){t!==e[0]&&(this.indexes[s++]=r,this.nPrimitiveFlags++);for(const e of t)this.vertexCataloguePosition[i++]=1*e.x,this.vertexCataloguePosition[i++]=1*e.y,this.vertexCataloguePosition[i++]=1*e.z,this.indexes[s++]=Math.floor((i-1)/3)}}this.indexes[this.indexes.length-1]=r,this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexes,this._webgl.STATIC_DRAW),this._bufferInitialised=!0,console.log("Buffer initialized")}checkSelection(e){if(!e.x||!e.y||!e.z)return;if(!e.computeNpix())return;this._hoveredFootprints=[],this.totHoveredPoints=0;const t=new n.Point({x:e.x,y:e.y,z:e.z},l.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const r=this.footprintPolygons[e];if(r.selectionObj&&h.default.checkPointInsidePolygon5(r.selectionObj,t)){const e=[...r.details],t=this._metadataManager.selectedOutlineColumn?.index??-1;t>=0&&e.splice(t,1),this._hoveredFootprints.push(r),this.totHoveredPoints+=r.totPoints}}this.initHoveringBuffer()}get hoveredFootprints(){return{metadata:this._metadataManager,footprints:this._hoveredFootprints,tableName:this._name,description:this._description,provider:this._providerUrl}}get selectedFootprints(){return this._selectedFootprints}checkClicking(e){if(null==e.x||null==e.y||null==e.z)return[];const t=[],r=new n.Point({x:e.x,y:e.y,z:e.z},l.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const i=this.footprintPolygons[e];i.selectionObj&&h.default.checkPointInsidePolygon5(i.selectionObj,r)&&t.push(e)}return t}setSelectedIndexes(e){e.forEach(e=>{e<0||e>=this.footprintPolygons.length||(this.selectedIndexes.includes(e)?this.selectedIndexes.splice(this.selectedIndexes.indexOf(e),1):this.selectedIndexes.push(e))}),this.refreshSelectedFootprints()}refreshSelectedFootprints(){if(this._selectedFootprints=this.selectedIndexes.map(e=>this.footprintPolygons[e]).filter(e=>Boolean(e)),this.totSelectedPoints=this._selectedFootprints.reduce((e,t)=>e+t.totPoints,0),0===this._selectedFootprints.length)return this.selectedVertexPosition=new Float32Array,this.selectedElementIndexes=new Uint32Array,void(this.nSlectedPrimitiveFlags=0);this.initSelectionBuffer()}getFootprintsFromPointer(e){const t=this.checkClicking(e);if(!t.length)return{footprints:[],pickedIndexes:[]};const r=[];return t.forEach(e=>{const t=this.footprintPolygons[e];t&&r.push(t)}),r.length?{footprints:r,pickedIndexes:t}:null}selectPrimaryFootprintFromClick(e){const t=this.getFootprintsFromPointer(e),r=t?.pickedIndexes??[];if(this.setSelectedIndexes(r),!r.length)return{footprints:[],selectionState:[]};const i=[],s=[];return r.forEach(e=>{const t=this.footprintPolygons[e];if(!t)return;const r=this.selectedIndexes.includes(e);i.push({footprint:t,selected:r}),s.push(t)}),s.length?{footprints:s,selectionState:i}:null}FootprintPolygonMatches(e,t){if(e===t)return!0;const r=e.convexPolygons,i=t.convexPolygons;if(r!==i||r!==i)return!1;if(e.details.length!==t.details.length)return!1;for(let r=0;r<e.details.length;r++)if(!Object.is(e.details[r],t.details[r]))return!1;return!0}findFootprintPolygonIndex(e){const t=this.footprintPolygons.indexOf(e);return t>=0?t:this.footprintPolygons.findIndex(t=>this.FootprintPolygonMatches(t,e))}extHighlightFootprint(e,t){const r=this.findFootprintPolygonIndex(e);if(r<0)return;const i=r*u.ELEM_SIZE;if(t)this.hoveredIndexes.includes(r)||this.hoveredIndexes.push(r);else{if(i+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(r);e>=0&&this.hoveredIndexes.splice(e,1)}}extAddPolygons2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findFootprintPolygonIndex(e);if(t<0)return;const r=t*u.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(r+4>=this.vertexCataloguePosition.length)return;const e=this.selectedIndexes.indexOf(t);e>=0&&this.selectedIndexes.splice(e,1)}else this.selectedIndexes.push(t);this.refreshSelectedFootprints()}initHoveringBuffer(){if(!this._webgl)return;if(0==this._hoveredFootprints.length)return;let e=this._hoveredFootprints.length,t=e-1;for(let r=0;r<e;r++)t+=this._hoveredFootprints[r].polygons.length-1;this.hoveredElementIndexes=new Uint32Array(this.totHoveredPoints+t);const r=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this.hoveredVertexPosition=new Float32Array(3*this.totHoveredPoints);let i=0,s=0;this.nHoveredPrimitiveFlags=0;for(let t=0;t<e;t++){let e=this._hoveredFootprints[t].polygons;t>0&&(this.hoveredElementIndexes[s]=r,this.nHoveredPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.hoveredElementIndexes[s]=r,this.nHoveredPrimitiveFlags+=1,s+=1);const a=e[t];for(let e=0;e<a.length;e++){const t=a[e];this.hoveredVertexPosition[i]=1*t.x,this.hoveredVertexPosition[i+1]=1*t.y,this.hoveredVertexPosition[i+2]=1*t.z,this.hoveredElementIndexes[s]=Math.floor(i/3),s+=1,i+=3}}}}initSelectionBuffer(){if(!this._webgl)return;if(0==this._selectedFootprints.length)return;const e=this._selectedFootprints.length;let t=e-1;for(let r=0;r<e;r++)t+=this._selectedFootprints[r].polygons.length-1;this.selectedElementIndexes=new Uint32Array(this.totSelectedPoints+t);const r=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this.selectedVertexPosition=new Float32Array(3*this.totSelectedPoints);let i=0,s=0;this.nSlectedPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this._selectedFootprints[t].polygons;t>0&&(this.selectedElementIndexes[s]=r,this.nSlectedPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.selectedElementIndexes[s]=r,this.nSlectedPrimitiveFlags+=1,s+=1);const a=e[t];for(let e=0;e<a.length;e++){const t=a[e];this.selectedVertexPosition[i]=1*t.x,this.selectedVertexPosition[i+1]=1*t.y,this.selectedVertexPosition[i+2]=1*t.z,this.selectedElementIndexes[s]=Math.floor(i/3),s+=1,i+=3}}}}changeColor(e){this._shapeColor=e}draw(e,t,r,i){if(!this.isVisible)return;if(!this._ready)return;if(!r)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;if(this._footprintShaderProgram.enableShaders(i,e,r),null!=t&&t.xyz!=this.oldMouseCoords&&this.checkSelection(t),this._hoveredFootprints.length>0){const e=(0,a.colorHex2RGB)("#00FF00"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.hoveredVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.hoveredVertexPosition.length/3+this.nHoveredPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}if(this._selectedFootprints.length>0){const e=(0,a.colorHex2RGB)("#ECB462"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.selectedVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.selectedVertexPosition.length/3+this.nSlectedPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);const s=[...(0,a.colorHex2RGB)(this._shapeColor),1];this._webgl.uniform4f(this._footprintShaderProgram.locations.color,...s),this._webgl.drawElements(this._webgl.LINE_LOOP,this.indexes.length,this._webgl.UNSIGNED_INT,0),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,null),this.oldMouseCoords=t.xyz}}t.FootprintSetGL=u},619:(e,t)=>{function r(e,r){if(!Array.isArray(r))throw new Error(`Channel "${e}" must be an array.`);if(r.length!==t.COLOR_MAP_SAMPLE_COUNT)throw new Error(`Channel "${e}" must contain exactly ${t.COLOR_MAP_SAMPLE_COUNT} samples.`);for(let t=0;t<r.length;t+=1){const i=r[t];if(!Number.isFinite(i))throw new Error(`Channel "${e}" contains a non-finite value at index ${t}.`);if(i<0||i>255)throw new Error(`Channel "${e}" contains an out-of-range value at index ${t}. Expected 0..255.`)}}function i(e){const r=new Float32Array(4*t.COLOR_MAP_SAMPLE_COUNT);for(let i=0;i<t.COLOR_MAP_SAMPLE_COUNT;i+=1)r[4*i]=e[i];return r}Object.defineProperty(t,"__esModule",{value:!0}),t.ColorMaps=t.COLOR_MAP_SAMPLE_COUNT=void 0,t.createColorMapFromSamples=function(e,t){const s=e.trim();if(!s)throw new Error("Color map name must not be empty.");return r("r",t.r),r("g",t.g),r("b",t.b),{name:s,r:i(t.r),g:i(t.g),b:i(t.b)}},t.COLOR_MAP_SAMPLE_COUNT=256,t.ColorMaps={grayscale:{name:"grayscale",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},native:{name:"native",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},planck:{name:"planck",r:new Float32Array([0,0,0,0,.769231,0,0,0,1.53846,0,0,0,2.30769,0,0,0,3.07692,0,0,0,3.84615,0,0,0,4.61538,0,0,0,5.38462,0,0,0,6.15385,0,0,0,6.92308,0,0,0,7.69231,0,0,0,8.46154,0,0,0,9.23077,0,0,0,10,0,0,0,11.5385,0,0,0,13.0769,0,0,0,14.6154,0,0,0,16.1538,0,0,0,17.6923,0,0,0,19.2308,0,0,0,20.7692,0,0,0,22.3077,0,0,0,23.8462,0,0,0,25.3846,0,0,0,26.9231,0,0,0,28.4615,0,0,0,30,0,0,0,33.8462,0,0,0,37.6923,0,0,0,41.5385,0,0,0,45.3846,0,0,0,49.2308,0,0,0,53.0769,0,0,0,56.9231,0,0,0,60.7692,0,0,0,64.6154,0,0,0,68.4615,0,0,0,72.3077,0,0,0,76.1538,0,0,0,80,0,0,0,88.5385,0,0,0,97.0769,0,0,0,105.615,0,0,0,114.154,0,0,0,122.692,0,0,0,131.231,0,0,0,139.769,0,0,0,148.308,0,0,0,156.846,0,0,0,165.385,0,0,0,173.923,0,0,0,182.462,0,0,0,191,0,0,0,193.846,0,0,0,196.692,0,0,0,199.538,0,0,0,202.385,0,0,0,205.231,0,0,0,208.077,0,0,0,210.923,0,0,0,213.769,0,0,0,216.615,0,0,0,219.462,0,0,0,222.308,0,0,0,225.154,0,0,0,228,0,0,0,229.182,0,0,0,230.364,0,0,0,231.545,0,0,0,232.727,0,0,0,233.909,0,0,0,235.091,0,0,0,236.273,0,0,0,237.455,0,0,0,238.636,0,0,0,239.818,0,0,0,241,0,0,0,241,0,0,0,241.364,0,0,0,241.727,0,0,0,242.091,0,0,0,242.455,0,0,0,242.818,0,0,0,243.182,0,0,0,243.545,0,0,0,243.909,0,0,0,244.273,0,0,0,244.636,0,0,0,245,0,0,0,245.231,0,0,0,245.462,0,0,0,245.692,0,0,0,245.923,0,0,0,246.154,0,0,0,246.385,0,0,0,246.615,0,0,0,246.846,0,0,0,247.077,0,0,0,247.308,0,0,0,247.538,0,0,0,247.769,0,0,0,248,0,0,0,248.146,0,0,0,248.292,0,0,0,248.438,0,0,0,248.585,0,0,0,248.731,0,0,0,248.877,0,0,0,249.023,0,0,0,249.169,0,0,0,249.315,0,0,0,249.462,0,0,0,249.608,0,0,0,249.754,0,0,0,249.9,0,0,0,249.312,0,0,0,248.723,0,0,0,248.135,0,0,0,247.546,0,0,0,246.958,0,0,0,246.369,0,0,0,245.781,0,0,0,245.192,0,0,0,244.604,0,0,0,244.015,0,0,0,243.427,0,0,0,242.838,0,0,0,242.25,0,0,0,239.308,0,0,0,236.365,0,0,0,233.423,0,0,0,230.481,0,0,0,227.538,0,0,0,224.596,0,0,0,221.654,0,0,0,218.712,0,0,0,215.769,0,0,0,212.827,0,0,0,209.885,0,0,0,206.942,0,0,0,204,0,0,0,201,0,0,0,198,0,0,0,195,0,0,0,192,0,0,0,189,0,0,0,186,0,0,0,183,0,0,0,180,0,0,0,177,0,0,0,174,0,0,0,171,0,0,0,168,0,0,0,165,0,0,0,161.077,0,0,0,157.154,0,0,0,153.231,0,0,0,149.308,0,0,0,145.385,0,0,0,141.462,0,0,0,137.538,0,0,0,133.615,0,0,0,129.692,0,0,0,125.769,0,0,0,121.846,0,0,0,117.923,0,0,0,114,0,0,0,115.038,0,0,0,116.077,0,0,0,117.115,0,0,0,118.154,0,0,0,119.192,0,0,0,120.231,0,0,0,121.269,0,0,0,122.308,0,0,0,123.346,0,0,0,124.385,0,0,0,125.423,0,0,0,126.462,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),g:new Float32Array([0,0,0,0,1.53846,0,0,0,3.07692,0,0,0,4.61538,0,0,0,6.15385,0,0,0,7.69231,0,0,0,9.23077,0,0,0,10.7692,0,0,0,12.3077,0,0,0,13.8462,0,0,0,15.3846,0,0,0,16.9231,0,0,0,18.4615,0,0,0,20,0,0,0,32.6154,0,0,0,45.2308,0,0,0,57.8462,0,0,0,70.4615,0,0,0,83.0769,0,0,0,95.6923,0,0,0,108.308,0,0,0,120.923,0,0,0,133.538,0,0,0,146.154,0,0,0,158.769,0,0,0,171.385,0,0,0,184,0,0,0,187.923,0,0,0,191.846,0,0,0,195.769,0,0,0,199.692,0,0,0,203.615,0,0,0,207.538,0,0,0,211.462,0,0,0,215.385,0,0,0,219.308,0,0,0,223.231,0,0,0,227.154,0,0,0,231.077,0,0,0,235,0,0,0,235.308,0,0,0,235.615,0,0,0,235.923,0,0,0,236.231,0,0,0,236.538,0,0,0,236.846,0,0,0,237.154,0,0,0,237.462,0,0,0,237.769,0,0,0,238.077,0,0,0,238.385,0,0,0,238.692,0,0,0,239,0,0,0,239.077,0,0,0,239.154,0,0,0,239.231,0,0,0,239.308,0,0,0,239.385,0,0,0,239.462,0,0,0,239.538,0,0,0,239.615,0,0,0,239.692,0,0,0,239.769,0,0,0,239.846,0,0,0,239.923,0,0,0,240,0,0,0,240.091,0,0,0,240.182,0,0,0,240.273,0,0,0,240.364,0,0,0,240.455,0,0,0,240.545,0,0,0,240.636,0,0,0,240.727,0,0,0,240.818,0,0,0,240.909,0,0,0,241,0,0,0,241,0,0,0,240.909,0,0,0,240.818,0,0,0,240.727,0,0,0,240.636,0,0,0,240.545,0,0,0,240.455,0,0,0,240.364,0,0,0,240.273,0,0,0,240.182,0,0,0,240.091,0,0,0,240,0,0,0,239.615,0,0,0,239.231,0,0,0,238.846,0,0,0,238.462,0,0,0,238.077,0,0,0,237.692,0,0,0,237.308,0,0,0,236.923,0,0,0,236.538,0,0,0,236.154,0,0,0,235.769,0,0,0,235.385,0,0,0,235,0,0,0,232.615,0,0,0,230.231,0,0,0,227.846,0,0,0,225.462,0,0,0,223.077,0,0,0,220.692,0,0,0,218.308,0,0,0,215.923,0,0,0,213.538,0,0,0,211.154,0,0,0,208.769,0,0,0,206.385,0,0,0,204,0,0,0,200.077,0,0,0,196.154,0,0,0,192.231,0,0,0,188.308,0,0,0,184.385,0,0,0,180.462,0,0,0,176.538,0,0,0,172.615,0,0,0,168.692,0,0,0,164.769,0,0,0,160.846,0,0,0,156.923,0,0,0,153,0,0,0,147.115,0,0,0,141.231,0,0,0,135.346,0,0,0,129.462,0,0,0,123.577,0,0,0,117.692,0,0,0,111.808,0,0,0,105.923,0,0,0,100.038,0,0,0,94.1538,0,0,0,88.2692,0,0,0,82.3846,0,0,0,76.5,0,0,0,73.0769,0,0,0,69.6538,0,0,0,66.2308,0,0,0,62.8077,0,0,0,59.3846,0,0,0,55.9615,0,0,0,52.5385,0,0,0,49.1154,0,0,0,45.6923,0,0,0,42.2692,0,0,0,38.8462,0,0,0,35.4231,0,0,0,32,0,0,0,29.5385,0,0,0,27.0769,0,0,0,24.6154,0,0,0,22.1538,0,0,0,19.6923,0,0,0,17.2308,0,0,0,14.7692,0,0,0,12.3077,0,0,0,9.84615,0,0,0,7.38462,0,0,0,4.92308,0,0,0,2.46154,0,0,0,0,0,0,0,9.80769,0,0,0,19.6154,0,0,0,29.4231,0,0,0,39.2308,0,0,0,49.0385,0,0,0,58.8462,0,0,0,68.6538,0,0,0,78.4615,0,0,0,88.2692,0,0,0,98.0769,0,0,0,107.885,0,0,0,117.692,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254.615,0,0,0,254.231,0,0,0,253.846,0,0,0,253.462,0,0,0,253.077,0,0,0,252.692,0,0,0,252.308,0,0,0,251.923,0,0,0,251.538,0,0,0,251.154,0,0,0,250.769,0,0,0,250.385,0,0,0,250,0,0,0,249.615,0,0,0,249.231,0,0,0,248.846,0,0,0,248.462,0,0,0,248.077,0,0,0,247.692,0,0,0,247.308,0,0,0,246.923,0,0,0,246.538,0,0,0,246.154,0,0,0,245.769,0,0,0,245.385,0,0,0,245,0,0,0,242,0,0,0,239,0,0,0,236,0,0,0,233,0,0,0,230,0,0,0,227,0,0,0,224,0,0,0,221,0,0,0,218,0,0,0,215,0,0,0,212,0,0,0,212,0,0,0,208.636,0,0,0,205.273,0,0,0,201.909,0,0,0,198.545,0,0,0,195.182,0,0,0,191.818,0,0,0,188.455,0,0,0,185.091,0,0,0,181.727,0,0,0,178.364,0,0,0,175,0,0,0,171.538,0,0,0,168.077,0,0,0,164.615,0,0,0,161.154,0,0,0,157.692,0,0,0,154.231,0,0,0,150.769,0,0,0,147.308,0,0,0,143.846,0,0,0,140.385,0,0,0,136.923,0,0,0,133.462,0,0,0,130,0,0,0,122.942,0,0,0,115.885,0,0,0,108.827,0,0,0,101.769,0,0,0,94.7115,0,0,0,87.6539,0,0,0,80.5962,0,0,0,73.5385,0,0,0,66.4808,0,0,0,59.4231,0,0,0,52.3654,0,0,0,45.3077,0,0,0,38.25,0,0,0,36.2885,0,0,0,34.3269,0,0,0,32.3654,0,0,0,30.4038,0,0,0,28.4423,0,0,0,26.4808,0,0,0,24.5192,0,0,0,22.5577,0,0,0,20.5962,0,0,0,18.6346,0,0,0,16.6731,0,0,0,14.7115,0,0,0,12.75,0,0,0,11.7692,0,0,0,10.7885,0,0,0,9.80769,0,0,0,8.82692,0,0,0,7.84615,0,0,0,6.86539,0,0,0,5.88461,0,0,0,4.90385,0,0,0,3.92308,0,0,0,2.94231,0,0,0,1.96154,0,0,0,.980769,0,0,0,0,0,0,0,2.46154,0,0,0,4.92308,0,0,0,7.38462,0,0,0,9.84616,0,0,0,12.3077,0,0,0,14.7692,0,0,0,17.2308,0,0,0,19.6923,0,0,0,22.1538,0,0,0,24.6154,0,0,0,27.0769,0,0,0,29.5385,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,41.3077,0,0,0,50.6154,0,0,0,59.9231,0,0,0,69.2308,0,0,0,78.5385,0,0,0,87.8462,0,0,0,97.1539,0,0,0,106.462,0,0,0,115.769,0,0,0,125.077,0,0,0,134.385,0,0,0,143.692,0,0,0,153,0,0,0,156.923,0,0,0,160.846,0,0,0,164.769,0,0,0,168.692,0,0,0,172.615,0,0,0,176.538,0,0,0,180.462,0,0,0,184.385,0,0,0,188.308,0,0,0,192.231,0,0,0,196.154,0,0,0,200.077,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.838,0,0,0,243.427,0,0,0,244.015,0,0,0,244.604,0,0,0,245.192,0,0,0,245.781,0,0,0,246.369,0,0,0,246.958,0,0,0,247.546,0,0,0,248.135,0,0,0,248.723,0,0,0,249.312,0,0,0,249.9,0,0,0,250.096,0,0,0,250.292,0,0,0,250.488,0,0,0,250.685,0,0,0,250.881,0,0,0,251.077,0,0,0,251.273,0,0,0,251.469,0,0,0,251.665,0,0,0,251.862,0,0,0,252.058,0,0,0,252.254,0,0,0,252.45,0,0,0,252.682,0,0,0,252.914,0,0,0,253.145,0,0,0,253.377,0,0,0,253.609,0,0,0,253.841,0,0,0,254.073,0,0,0,254.305,0,0,0,254.536,0,0,0,254.768,0,0,0,255,0,0,0])},cmb:{name:"cmb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,12,0,0,0,18,0,0,0,24,0,0,0,30,0,0,0,36,0,0,0,42,0,0,0,48,0,0,0,54,0,0,0,60,0,0,0,66,0,0,0,72,0,0,0,78,0,0,0,85,0,0,0,91,0,0,0,97,0,0,0,103,0,0,0,109,0,0,0,115,0,0,0,121,0,0,0,127,0,0,0,133,0,0,0,139,0,0,0,145,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,170,0,0,0,176,0,0,0,182,0,0,0,188,0,0,0,194,0,0,0,200,0,0,0,206,0,0,0,212,0,0,0,218,0,0,0,224,0,0,0,230,0,0,0,236,0,0,0,242,0,0,0,248,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,251,0,0,0,247,0,0,0,244,0,0,0,240,0,0,0,236,0,0,0,233,0,0,0,229,0,0,0,226,0,0,0,222,0,0,0,218,0,0,0,215,0,0,0,211,0,0,0,208,0,0,0,204,0,0,0,200,0,0,0,197,0,0,0,193,0,0,0,190,0,0,0,186,0,0,0,182,0,0,0,179,0,0,0,175,0,0,0,172,0,0,0,168,0,0,0,164,0,0,0,161,0,0,0,157,0,0,0,154,0,0,0,150,0,0,0,146,0,0,0,143,0,0,0,139,0,0,0,136,0,0,0,132,0,0,0,128,0,0,0,125,0,0,0,121,0,0,0,118,0,0,0,114,0,0,0,110,0,0,0,107,0,0,0,103,0,0,0,100,0,0,0]),g:new Float32Array([0,0,0,0,2,0,0,0,5,0,0,0,8,0,0,0,10,0,0,0,13,0,0,0,16,0,0,0,18,0,0,0,21,0,0,0,24,0,0,0,26,0,0,0,29,0,0,0,32,0,0,0,34,0,0,0,37,0,0,0,40,0,0,0,42,0,0,0,45,0,0,0,48,0,0,0,50,0,0,0,53,0,0,0,56,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,66,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,80,0,0,0,82,0,0,0,85,0,0,0,88,0,0,0,90,0,0,0,93,0,0,0,96,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,106,0,0,0,109,0,0,0,112,0,0,0,114,0,0,0,117,0,0,0,119,0,0,0,122,0,0,0,124,0,0,0,127,0,0,0,129,0,0,0,132,0,0,0,134,0,0,0,137,0,0,0,139,0,0,0,142,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,152,0,0,0,155,0,0,0,157,0,0,0,160,0,0,0,162,0,0,0,165,0,0,0,167,0,0,0,170,0,0,0,172,0,0,0,175,0,0,0,177,0,0,0,180,0,0,0,182,0,0,0,185,0,0,0,188,0,0,0,190,0,0,0,193,0,0,0,195,0,0,0,198,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,208,0,0,0,210,0,0,0,213,0,0,0,215,0,0,0,218,0,0,0,221,0,0,0,221,0,0,0,221,0,0,0,222,0,0,0,222,0,0,0,222,0,0,0,223,0,0,0,223,0,0,0,224,0,0,0,224,0,0,0,224,0,0,0,225,0,0,0,225,0,0,0,225,0,0,0,226,0,0,0,226,0,0,0,227,0,0,0,227,0,0,0,227,0,0,0,228,0,0,0,228,0,0,0,229,0,0,0,229,0,0,0,229,0,0,0,230,0,0,0,230,0,0,0,230,0,0,0,231,0,0,0,231,0,0,0,232,0,0,0,232,0,0,0,232,0,0,0,233,0,0,0,233,0,0,0,233,0,0,0,234,0,0,0,234,0,0,0,235,0,0,0,235,0,0,0,235,0,0,0,236,0,0,0,236,0,0,0,237,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,227,0,0,0,226,0,0,0,225,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,215,0,0,0,214,0,0,0,213,0,0,0,211,0,0,0,210,0,0,0,209,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,195,0,0,0,194,0,0,0,193,0,0,0,191,0,0,0,190,0,0,0,189,0,0,0,187,0,0,0,186,0,0,0,185,0,0,0,183,0,0,0,182,0,0,0,181,0,0,0,180,0,0,0,177,0,0,0,175,0,0,0,172,0,0,0,170,0,0,0,167,0,0,0,165,0,0,0,162,0,0,0,160,0,0,0,157,0,0,0,155,0,0,0,152,0,0,0,150,0,0,0,147,0,0,0,145,0,0,0,142,0,0,0,140,0,0,0,137,0,0,0,135,0,0,0,132,0,0,0,130,0,0,0,127,0,0,0,125,0,0,0,122,0,0,0,120,0,0,0,117,0,0,0,115,0,0,0,112,0,0,0,110,0,0,0,107,0,0,0,105,0,0,0,102,0,0,0,100,0,0,0,97,0,0,0,95,0,0,0,92,0,0,0,90,0,0,0,87,0,0,0,85,0,0,0,82,0,0,0,80,0,0,0,77,0,0,0,75,0,0,0,73,0,0,0,71,0,0,0,69,0,0,0,68,0,0,0,66,0,0,0,64,0,0,0,62,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,54,0,0,0,52,0,0,0,50,0,0,0,48,0,0,0,47,0,0,0,45,0,0,0,43,0,0,0,41,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,34,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,26,0,0,0,24,0,0,0,22,0,0,0,20,0,0,0,19,0,0,0,17,0,0,0,15,0,0,0,13,0,0,0,12,0,0,0,10,0,0,0,8,0,0,0,6,0,0,0,5,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254,0,0,0,253,0,0,0,252,0,0,0,251,0,0,0,250,0,0,0,249,0,0,0,248,0,0,0,247,0,0,0,246,0,0,0,245,0,0,0,245,0,0,0,244,0,0,0,243,0,0,0,242,0,0,0,241,0,0,0,240,0,0,0,239,0,0,0,238,0,0,0,237,0,0,0,236,0,0,0,236,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,232,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,228,0,0,0,227,0,0,0,226,0,0,0,226,0,0,0,225,0,0,0,224,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,220,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,217,0,0,0,211,0,0,0,206,0,0,0,201,0,0,0,196,0,0,0,191,0,0,0,186,0,0,0,181,0,0,0,176,0,0,0,171,0,0,0,166,0,0,0,161,0,0,0,156,0,0,0,151,0,0,0,146,0,0,0,141,0,0,0,136,0,0,0,131,0,0,0,126,0,0,0,121,0,0,0,116,0,0,0,111,0,0,0,105,0,0,0,100,0,0,0,95,0,0,0,90,0,0,0,85,0,0,0,80,0,0,0,75,0,0,0,70,0,0,0,65,0,0,0,60,0,0,0,55,0,0,0,50,0,0,0,45,0,0,0,40,0,0,0,35,0,0,0,30,0,0,0,25,0,0,0,20,0,0,0,15,0,0,0,10,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},rainbow:{name:"rainbow",r:new Float32Array([0,0,0,0,4,0,0,0,9,0,0,0,13,0,0,0,18,0,0,0,22,0,0,0,27,0,0,0,31,0,0,0,36,0,0,0,40,0,0,0,45,0,0,0,50,0,0,0,54,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,68,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,79,0,0,0,80,0,0,0,82,0,0,0,83,0,0,0,85,0,0,0,84,0,0,0,86,0,0,0,87,0,0,0,88,0,0,0,86,0,0,0,87,0,0,0,87,0,0,0,87,0,0,0,85,0,0,0,84,0,0,0,84,0,0,0,84,0,0,0,83,0,0,0,79,0,0,0,78,0,0,0,77,0,0,0,76,0,0,0,71,0,0,0,70,0,0,0,68,0,0,0,66,0,0,0,60,0,0,0,58,0,0,0,55,0,0,0,53,0,0,0,46,0,0,0,43,0,0,0,40,0,0,0,36,0,0,0,33,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,12,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,33,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,80,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,101,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,123,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,153,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,169,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,212,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,16,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,38,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,84,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,106,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,127,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,152,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,195,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,216,0,0,0,220,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,250,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,221,0,0,0,216,0,0,0,212,0,0,0,208,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,161,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,119,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,85,0,0,0,80,0,0,0,76,0,0,0,72,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,51,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,29,0,0,0,21,0,0,0,17,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0]),b:new Float32Array([0,0,0,0,3,0,0,0,7,0,0,0,10,0,0,0,14,0,0,0,19,0,0,0,23,0,0,0,28,0,0,0,32,0,0,0,38,0,0,0,43,0,0,0,48,0,0,0,53,0,0,0,59,0,0,0,63,0,0,0,68,0,0,0,72,0,0,0,77,0,0,0,81,0,0,0,86,0,0,0,91,0,0,0,95,0,0,0,100,0,0,0,104,0,0,0,109,0,0,0,113,0,0,0,118,0,0,0,122,0,0,0,127,0,0,0,132,0,0,0,136,0,0,0,141,0,0,0,145,0,0,0,150,0,0,0,154,0,0,0,159,0,0,0,163,0,0,0,168,0,0,0,173,0,0,0,177,0,0,0,182,0,0,0,186,0,0,0,191,0,0,0,195,0,0,0,200,0,0,0,204,0,0,0,209,0,0,0,214,0,0,0,218,0,0,0,223,0,0,0,227,0,0,0,232,0,0,0,236,0,0,0,241,0,0,0,245,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,225,0,0,0,220,0,0,0,216,0,0,0,212,0,0,0,203,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,157,0,0,0,152,0,0,0,148,0,0,0,144,0,0,0,135,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,114,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,84,0,0,0,80,0,0,0,76,0,0,0,67,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,46,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},eosb:{name:"eosb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,18,0,0,0,27,0,0,0,36,0,0,0,45,0,0,0,49,0,0,0,57,0,0,0,72,0,0,0,81,0,0,0,91,0,0,0,100,0,0,0,109,0,0,0,118,0,0,0,127,0,0,0,136,0,0,0,131,0,0,0,139,0,0,0,163,0,0,0,173,0,0,0,182,0,0,0,191,0,0,0,200,0,0,0,209,0,0,0,218,0,0,0,227,0,0,0,213,0,0,0,221,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,253,0,0,0,251,0,0,0,249,0,0,0,247,0,0,0,245,0,0,0,243,0,0,0,241,0,0,0,215,0,0,0,214,0,0,0,235,0,0,0,234,0,0,0,232,0,0,0,230,0,0,0,228,0,0,0,226,0,0,0,224,0,0,0,222,0,0,0,198,0,0,0,196,0,0,0,216,0,0,0,215,0,0,0,213,0,0,0,211,0,0,0,209,0,0,0,207,0,0,0,205,0,0,0,203,0,0,0,181,0,0,0,179,0,0,0,197,0,0,0,196,0,0,0,194,0,0,0,192,0,0,0,190,0,0,0,188,0,0,0,186,0,0,0,184,0,0,0,164,0,0,0,162,0,0,0,178,0,0,0,176,0,0,0,175,0,0,0,173,0,0,0,171,0,0,0,169,0,0,0,167,0,0,0,165,0,0,0,147,0,0,0,145,0,0,0,159,0,0,0,157,0,0,0,156,0,0,0,154,0,0,0,152,0,0,0,150,0,0,0,148,0,0,0,146,0,0,0,130,0,0,0,128,0,0,0,140,0,0,0,138,0,0,0,137,0,0,0,135,0,0,0,133,0,0,0,131,0,0,0,129,0,0,0,127,0,0,0,113,0,0,0,111,0,0,0,121,0,0,0,119,0,0,0,117,0,0,0,117,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,15,0,0,0,23,0,0,0,31,0,0,0,39,0,0,0,47,0,0,0,55,0,0,0,57,0,0,0,64,0,0,0,79,0,0,0,87,0,0,0,95,0,0,0,103,0,0,0,111,0,0,0,119,0,0,0,127,0,0,0,135,0,0,0,129,0,0,0,136,0,0,0,159,0,0,0,167,0,0,0,175,0,0,0,183,0,0,0,191,0,0,0,199,0,0,0,207,0,0,0,215,0,0,0,200,0,0,0,207,0,0,0,239,0,0,0,247,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,250,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,225,0,0,0,198,0,0,0,195,0,0,0,212,0,0,0,208,0,0,0,204,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,182,0,0,0,160,0,0,0,156,0,0,0,169,0,0,0,165,0,0,0,161,0,0,0,157,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,122,0,0,0,118,0,0,0,127,0,0,0,125,0,0,0,123,0,0,0,121,0,0,0,119,0,0,0,116,0,0,0,114,0,0,0,112,0,0,0,99,0,0,0,97,0,0,0,106,0,0,0,104,0,0,0,102,0,0,0,99,0,0,0,97,0,0,0,95,0,0,0,93,0,0,0,91,0,0,0,80,0,0,0,78,0,0,0,84,0,0,0,82,0,0,0,80,0,0,0,78,0,0,0,76,0,0,0,74,0,0,0,72,0,0,0,70,0,0,0,61,0,0,0,59,0,0,0,63,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,53,0,0,0,50,0,0,0,48,0,0,0,42,0,0,0,40,0,0,0,42,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,19,0,0,0,16,0,0,0,14,0,0,0,12,0,0,0,13,0,0,0,8,0,0,0,6,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),b:new Float32Array([116,0,0,0,121,0,0,0,127,0,0,0,131,0,0,0,136,0,0,0,140,0,0,0,144,0,0,0,148,0,0,0,153,0,0,0,157,0,0,0,145,0,0,0,149,0,0,0,170,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,195,0,0,0,199,0,0,0,183,0,0,0,187,0,0,0,212,0,0,0,216,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,238,0,0,0,242,0,0,0,221,0,0,0,225,0,0,0,255,0,0,0,247,0,0,0,239,0,0,0,231,0,0,0,223,0,0,0,215,0,0,0,207,0,0,0,199,0,0,0,172,0,0,0,164,0,0,0,175,0,0,0,167,0,0,0,159,0,0,0,151,0,0,0,143,0,0,0,135,0,0,0,127,0,0,0,119,0,0,0,100,0,0,0,93,0,0,0,95,0,0,0,87,0,0,0,79,0,0,0,71,0,0,0,63,0,0,0,55,0,0,0,47,0,0,0,39,0,0,0,28,0,0,0,21,0,0,0,15,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},cubehelix:{name:"cubehelix",r:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,24,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,24,0,0,0,24,0,0,0,24,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,20,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,27,0,0,0,27,0,0,0,28,0,0,0,30,0,0,0,31,0,0,0,32,0,0,0,33,0,0,0,35,0,0,0,36,0,0,0,38,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,49,0,0,0,51,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,60,0,0,0,62,0,0,0,65,0,0,0,67,0,0,0,70,0,0,0,72,0,0,0,75,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,89,0,0,0,92,0,0,0,95,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,107,0,0,0,110,0,0,0,113,0,0,0,116,0,0,0,120,0,0,0,123,0,0,0,126,0,0,0,129,0,0,0,132,0,0,0,135,0,0,0,138,0,0,0,141,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,153,0,0,0,155,0,0,0,158,0,0,0,161,0,0,0,164,0,0,0,166,0,0,0,169,0,0,0,171,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,181,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,199,0,0,0,201,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,207,0,0,0,208,0,0,0,209,0,0,0,209,0,0,0,210,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,210,0,0,0,210,0,0,0,210,0,0,0,209,0,0,0,208,0,0,0,208,0,0,0,207,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,205,0,0,0,204,0,0,0,203,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,201,0,0,0,200,0,0,0,199,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,197,0,0,0,196,0,0,0,196,0,0,0,195,0,0,0,195,0,0,0,194,0,0,0,194,0,0,0,194,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,194,0,0,0,194,0,0,0,195,0,0,0,195,0,0,0,196,0,0,0,196,0,0,0,197,0,0,0,198,0,0,0,199,0,0,0,200,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,208,0,0,0,209,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,217,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,223,0,0,0,225,0,0,0,227,0,0,0,229,0,0,0,231,0,0,0,232,0,0,0,234,0,0,0,236,0,0,0,238,0,0,0,240,0,0,0,242,0,0,0,244,0,0,0,245,0,0,0,247,0,0,0,249,0,0,0,251,0,0,0,253,0,0,0,255]),g:new Float32Array([0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,11,0,0,0,11,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,28,0,0,0,29,0,0,0,31,0,0,0,32,0,0,0,34,0,0,0,35,0,0,0,37,0,0,0,38,0,0,0,40,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,46,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,58,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,73,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,79,0,0,0,81,0,0,0,83,0,0,0,84,0,0,0,86,0,0,0,88,0,0,0,89,0,0,0,91,0,0,0,92,0,0,0,94,0,0,0,95,0,0,0,97,0,0,0,98,0,0,0,99,0,0,0,101,0,0,0,102,0,0,0,103,0,0,0,104,0,0,0,106,0,0,0,107,0,0,0,108,0,0,0,109,0,0,0,110,0,0,0,111,0,0,0,112,0,0,0,113,0,0,0,114,0,0,0,114,0,0,0,115,0,0,0,116,0,0,0,116,0,0,0,117,0,0,0,118,0,0,0,118,0,0,0,119,0,0,0,119,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,123,0,0,0,123,0,0,0,124,0,0,0,124,0,0,0,125,0,0,0,125,0,0,0,126,0,0,0,127,0,0,0,127,0,0,0,128,0,0,0,129,0,0,0,130,0,0,0,131,0,0,0,131,0,0,0,132,0,0,0,133,0,0,0,135,0,0,0,136,0,0,0,137,0,0,0,138,0,0,0,139,0,0,0,140,0,0,0,142,0,0,0,143,0,0,0,144,0,0,0,146,0,0,0,147,0,0,0,149,0,0,0,150,0,0,0,152,0,0,0,154,0,0,0,155,0,0,0,157,0,0,0,158,0,0,0,160,0,0,0,162,0,0,0,164,0,0,0,165,0,0,0,167,0,0,0,169,0,0,0,171,0,0,0,172,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,180,0,0,0,182,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,208,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,216,0,0,0,218,0,0,0,219,0,0,0,221,0,0,0,222,0,0,0,224,0,0,0,225,0,0,0,226,0,0,0,228,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,232,0,0,0,233,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,247,0,0,0,248,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,250,0,0,0,251,0,0,0,251,0,0,0,252,0,0,0,252,0,0,0,253,0,0,0,253,0,0,0,254,0,0,0,255,0,0,0]),b:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,11,0,0,0,13,0,0,0,15,0,0,0,17,0,0,0,19,0,0,0,21,0,0,0,23,0,0,0,25,0,0,0,27,0,0,0,29,0,0,0,31,0,0,0,33,0,0,0,35,0,0,0,37,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,54,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,63,0,0,0,65,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,70,0,0,0,71,0,0,0,72,0,0,0,73,0,0,0,74,0,0,0,74,0,0,0,75,0,0,0,76,0,0,0,76,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,76,0,0,0,76,0,0,0,75,0,0,0,75,0,0,0,74,0,0,0,73,0,0,0,73,0,0,0,72,0,0,0,71,0,0,0,70,0,0,0,69,0,0,0,68,0,0,0,67,0,0,0,66,0,0,0,66,0,0,0,65,0,0,0,64,0,0,0,63,0,0,0,61,0,0,0,60,0,0,0,59,0,0,0,58,0,0,0,58,0,0,0,57,0,0,0,56,0,0,0,55,0,0,0,54,0,0,0,53,0,0,0,52,0,0,0,51,0,0,0,51,0,0,0,50,0,0,0,49,0,0,0,49,0,0,0,48,0,0,0,48,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,48,0,0,0,48,0,0,0,49,0,0,0,50,0,0,0,50,0,0,0,51,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,65,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,88,0,0,0,91,0,0,0,94,0,0,0,96,0,0,0,99,0,0,0,102,0,0,0,105,0,0,0,108,0,0,0,111,0,0,0,114,0,0,0,117,0,0,0,120,0,0,0,124,0,0,0,127,0,0,0,130,0,0,0,133,0,0,0,136,0,0,0,140,0,0,0,143,0,0,0,146,0,0,0,149,0,0,0,153,0,0,0,156,0,0,0,159,0,0,0,162,0,0,0,165,0,0,0,169,0,0,0,172,0,0,0,175,0,0,0,178,0,0,0,181,0,0,0,184,0,0,0,186,0,0,0,189,0,0,0,192,0,0,0,195,0,0,0,197,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,210,0,0,0,212,0,0,0,214,0,0,0,216,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,224,0,0,0,226,0,0,0,227,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,233,0,0,0,234,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,241,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,252,0,0,0,253,0,0,0,255,0,0,0])},hot:{name:"hot",r:new Float32Array([0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.30769,4.61538,6.92308,9.23077,11.5385,13.8462,16.1538,18.4615,20.7692,23.0769,25.3846,27.6923,30,32.3077,34.6154,36.9231,39.2308,41.5385,43.8462,46.1538,48.4615,50.7692,53.0769,55.3846,57.6923,60,62.3077,64.6154,66.9231,69.2308,71.5385,73.8462,76.1538,78.4615,80.7692,83.0769,85.3846,87.6923,90,92.3077,94.6154,96.9231,99.2308,101.538,103.846,106.154,108.462,110.769,113.077,115.385,117.692,120,122.308,124.615,126.923,129.231,131.538,133.846,136.154,138.462,140.769,143.077,145.385,147.692,150,152.308,154.615,156.923,159.231,161.538,163.846,166.154,168.462,170.769,173.077,175.385,177.692,180,182.308,184.615,186.923,189.231,191.538,193.846,196.154,198.462,200.769,203.077,205.385,207.692,210,212.308,214.615,216.923,219.231,221.538,223.846,226.154,228.462,230.769,233.077,235.385,237.692,240,242.308,244.615,246.923,249.231,251.538,253.846,255,255,255,255,255,255,255]),b:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.980769,1.96154,2.94231,3.92308,4.90385,5.88461,6.86539,7.84615,8.82692,9.80769,10.7885,11.7692,12.75,13.7308,14.7115,15.6923,16.6731,17.6538,18.6346,19.6154,20.5962,21.5769,22.5577,23.5385,24.5192,25.5,26.4808,27.4615,28.4423,29.4231,30.4038,31.3846,32.3654,33.3462,34.3269,35.3077,36.2885,37.2692,38.25,39.2308,40.2115,41.1923,42.1731,43.1538,44.1346,45.1154,46.0962,47.0769,48.0577,49.0385,50.0192,51,51.9808,52.9615,53.9423,54.9231,55.9038,56.8846,57.8654,58.8462,59.8269,60.8077,61.7885,62.7692,63.75,64.7308,65.7115,66.6923,67.6731,68.6538,69.6346,70.6154,71.5962,72.5769,73.5577,74.5385,75.5192,76.5,77.4808,78.4615,79.4423,80.4231,81.4038,82.3846,83.3654,84.3462,85.3269,86.3077,87.2885,88.2692,89.25,90.2308,91.2115,92.1923,93.1731,94.1538,95.1346,96.1154,97.0962,98.0769,99.0577,100.038,101.019,102,102.981,103.962,104.942,105.923,106.904,107.885,108.865,109.846,110.827,111.808,112.788,113.769,114.75,115.731,116.711,117.692,118.673,119.654,120.634,121.615,122.596,123.577,124.557,125.538,126.519,127.5])},gray:{name:"gray",r:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),g:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),b:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255])}},t.default=t.ColorMaps},772:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AstroViewer=void 0;const s=i(r(4723)),a=r(5087),o=r(1232),n=r(592),h=r(2919),l=i(r(619)),c=r(5409),u=r(8868),d=r(5781),_=r(9022),f=r(847);t.AstroViewer=class{astroSphere;canvas;webgl;rafId=null;webglContextList=new Map;viewfinderEl=null;viewfinderVisible=h.bootSetup.showViewfinder;viewfinderColor="rgba(75,148,226,0.68)";run(){return this.tick()}createCatalogue(e,t,r,i){return new o.CatalogueGL(e,t,r,i,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showCatalogue(e){this.astroSphere.showCatalogue(e)}hideCatalogue(e,t){e.setIsVisible(t)}deleteCatalogue(e){this.astroSphere.deleteCatalogue(e)}changeCatalogueRA(e,t){return e.changeMetaRA(t),e}changeCatalogueDec(e,t){return e.changeMetaDec(t),e}changeCatalogueColor(e,t){return e.changeColor(t),e}setCatalogueShapeHue(e,t){return e.changeMetaShapeHue(t),e}setCatalogueShapeSize(e,t){return e.changeMetaShapeSize(t),e}createFootprintSet(e,t,r,i){return new n.FootprintSetGL(e,t,r,i,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideFootprintSet(e,t){e.setIsVisible(t)}deleteFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}createTerraPointSet(e,t,r,i){return new d.TerraPointSetGL(e,t,r,i,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraPointSet(e){this.astroSphere.showCatalogue(e)}hideTerraPointSet(e,t){e.setIsVisible(t)}deleteTerraPointSet(e){this.astroSphere.deleteCatalogue(e)}createTerraFootprintSet(e,t,r,i){return new _.TerraFootprintSetGL(e,t,r,i,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideTerraFootprintSet(e,t){e.setIsVisible(t)}deleteTerraFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}changeFootprintSetColor(e,t){e.changeColor(t)}getHoveredFootprints(){return this.astroSphere.getHoveredFootprints()}getDefaultHiPSURL(){return h.bootSetup.defaultHipsUrl}activateHiPS(e){this.astroSphere.activateHiPS(e)}activateXYZ(e){this.astroSphere.activateXYZ(e)}activateXYZ2(e){const t=new u.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver);this.astroSphere.activateXYZ2(t)}activateWMTS(e){this.astroSphere.activateWMTS(e)}activateMeshHiPS(e){this.astroSphere.activateMeshHiPS(new f.MeshHiPSDescriptor(e))}setXYZMaxConcurrentRequests(e){c.xyzTileRequestScheduler.setMaxConcurrent(e)}getXYZMaxConcurrentRequests(){return c.xyzTileRequestScheduler.getMaxConcurrent()}getXYZDebugStats(){return this.astroSphere.getXYZDebugStats()}getHiPSDebugStats(){return this.astroSphere.getHiPSDebugStats()}getMeshHiPSDebugStats(){return this.astroSphere.getMeshHiPSDebugStats()}async loadHiPS(e){const t=e.endsWith("/")?e:e+"/",r=await fetch(t+"properties");if(!r.ok)throw new Error(`HTTP ${r.status} fetching properties`);const i=await r.text(),s=new a.HiPSDescriptor(i,t);return this.astroSphere.activateHiPS(s),s.surveyName}async loadMeshHiPS(e,t={}){const r=e.endsWith("/")?e:e+"/";let i="";const s=await fetch(r+"properties");if(s.ok)i=await s.text();else{const e=await fetch(r+"properties.json");if(!e.ok)throw new Error(`HTTP ${e.status} fetching MeshHiPS properties`);const t=await e.json();i=Object.entries(t).map(([e,t])=>`${e}=${String(t)}`).join("\n")}const a=new f.MeshHiPSDescriptor({...t,baseUrl:r},i);return this.astroSphere.activateMeshHiPS(a),a.name}changeColorMap(e){const t=l.default[e];this.astroSphere.changeColorMap(t)}changeCustomColorMap(e){this.astroSphere.changeColorMap(e)}getActiveHiPS(){return this.astroSphere.activeHiPS}getActiveXYZ(){return this.astroSphere.activeXYZ}setCamera(e){this.astroSphere.setCamera(e)}setCameraPosition(e){this.astroSphere.setCameraPosition(e)}setCameraMatrix(e){this.astroSphere.setCameraMatrix(e)}restoreAstroViewerState(e,t){this.astroSphere.applyFullCameraState(e,t)}getCurrentAstroViewerStatus(){return this.astroSphere.getCurrentStatus()}goTo(e,t){this.astroSphere.goTo(e,t)}getActiveCoordinateMode(){return this.astroSphere.getActiveCoordinateMode()}getCenterCoordinates(){return this.astroSphere.getCentralPointCoordinates()}getCoordinatesFromMouse(){return this.astroSphere.getLastMousePointCoordinates()}setModelMatrix(e){this.astroSphere.healpixGrid.setModelMatrix(e)}toggleHealpixGrid(){this.astroSphere.healpixGrid.toggleShowGrid()}isHealpixGridVisible(){return this.astroSphere.healpixGrid.isVisible()}toggleEquatorialGrid(){return this.astroSphere.equatorialGrid.toggleShowGrid()}isEquatorialGridVisible(){return this.astroSphere.equatorialGrid.isVisible()}toggleLonLatGrid(){return this.astroSphere.toggleLonLatGrid()}isLonLatGridVisible(){return this.astroSphere.isLonLatGridVisible()}setEastWestRotationLocked(e){this.astroSphere.setEastWestRotationLocked(e)}isEastWestRotationLocked(){return this.astroSphere.isEastWestRotationLocked()}setNorthSouthRotationLocked(e){this.astroSphere.setNorthSouthRotationLocked(e)}isNorthSouthRotationLocked(){return this.astroSphere.isNorthSouthRotationLocked()}resetAxesOrientation(){this.astroSphere.resetAxesOrientation()}setKeepCameraNorthUp(e){this.astroSphere.setKeepCameraNorthUp(e)}isKeepCameraNorthUp(){return this.astroSphere.isKeepCameraNorthUp()}getFoV(){return this.astroSphere.getFoV()}getFoVPolygon(){return this.astroSphere.getFoVPolygon()}changeFoV(e){this.astroSphere.changeFoV(e)}changeFoV2(e){this.astroSphere.changeFoV2(e)}changeFoV3(e){this.astroSphere.changeFoV3(e)}getInsideSphere(){return this.astroSphere.getInsideSphere()}toggleInsideSphere(){this.astroSphere.toggleInsideSphere()}toggleViewfinder(){return this.viewfinderVisible=!this.viewfinderVisible,this.syncViewfinderVisibility(),this.viewfinderVisible}setViewfinderVisible(e){this.viewfinderVisible=e,this.syncViewfinderVisibility()}isViewfinderVisible(){return this.viewfinderVisible}setViewfinderColor(e){this.viewfinderColor=e,this.syncViewfinderColor()}getViewfinderColor(){return this.viewfinderColor}setRotationSensitivity(e){this.astroSphere.setCameraRotationSensitivity(e)}getRotationSensitivity(){return this.astroSphere.getCameraRotationSensitivity()}setZoomSensitivity(e){this.astroSphere.setZoomSensitivity(e)}getZoomSensitivity(){return this.astroSphere.getZoomSensitivity()}constructor(e){this.init(e),this.webglContextList=new Map}init(e){console.log("init webgl"),this.canvas=e,this.initViewfinder();const t=this.canvas.getContext("webgl2",{alpha:!1});if(!t)throw alert("Could not initialise WebGL, sorry :-("),new Error("WebGL2 not available");this.webgl=t;try{this.webgl.clearColor(0,.06274509792,50*.00392156862,.7)}catch(e){console.log("Error instantiating WebGL context")}this.initListeners(),this.astroSphere=new s.default(this.canvas,this.webgl)}initViewfinder(){const e=this.canvas.parentElement;if(!e)return;"static"===window.getComputedStyle(e).position&&(e.style.position="relative");const t=document.createElement("div");t.setAttribute("data-astro-viewfinder","true"),t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.width="44px",t.style.height="44px",t.style.transform="translate(-50%, -50%)",t.style.pointerEvents="none",t.style.zIndex="1",t.style.boxSizing="border-box";const r=[{left:"50%",top:"7px",width:"1px",height:"11px",transform:"translateX(-50%)"},{left:"50%",bottom:"7px",width:"1px",height:"11px",transform:"translateX(-50%)"},{left:"7px",top:"50%",width:"11px",height:"1px",transform:"translateY(-50%)"},{right:"7px",top:"50%",width:"11px",height:"1px",transform:"translateY(-50%)"}];for(const e of r){const r=document.createElement("div");r.style.position="absolute",r.style.left=e.left??"auto",r.style.right=e.right??"auto",r.style.top=e.top??"auto",r.style.bottom=e.bottom??"auto",r.style.width=e.width,r.style.height=e.height,r.style.transform=e.transform,r.style.background="currentColor",r.style.borderRadius="999px",r.style.boxShadow="0 0 0 1px rgba(0, 0, 0, 0.14)",t.appendChild(r)}e.appendChild(t),this.viewfinderEl=t,this.syncViewfinderVisibility(),this.syncViewfinderColor()}syncViewfinderVisibility(){this.viewfinderEl&&(this.viewfinderEl.style.display=this.viewfinderVisible?"block":"none")}syncViewfinderColor(){this.viewfinderEl&&(this.viewfinderEl.style.color=this.viewfinderColor)}initListeners(){console.log("inside initListeners");const e=()=>{console.log("[resizeCanvas]");const e=this.canvas.getBoundingClientRect(),t=window.devicePixelRatio||1,r=Math.max(1,Math.floor(e.width*t)),i=Math.max(1,Math.floor(e.height*t));this.canvas.width===r&&this.canvas.height===i||(this.canvas.width=r,this.canvas.height=i,this.webgl.viewport(0,0,this.canvas.width,this.canvas.height))};"ResizeObserver"in window&&new ResizeObserver(()=>{e()}).observe(this.canvas),window.addEventListener("resize",e),this.canvas.addEventListener("webglcontextlost",e=>{console.log("[handleContextLost]"),e.preventDefault(),null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)},!1),this.canvas.addEventListener("webglcontextrestored",e=>{console.log("[handleContextRestored]"),this.webgl.clearColor(0,.06274509792,50*.00392156862,.7),this.webgl.enable(this.webgl.DEPTH_TEST),this.rafId=requestAnimationFrame(()=>this.tick())},!1),e()}tick(){return this.drawScene(),this.rafId=requestAnimationFrame(()=>this.tick()),this.rafId}drawScene(){this.astroSphere.draw(this.canvas)}}},847:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPSDescriptor=void 0,t.MeshHiPSDescriptor=class{_name="MeshHiPS";_baseUrl;_minOrder=0;_maxOrder=0;_selectedOrder;_fixedOrder=!1;_maxCachedTiles=384;_color=[.32,.34,.36,1];_wireframe=!1;_propertiesRawText="";_propertiesMap=new Map;_meshRadius=null;constructor(e,t=""){if(this._baseUrl=this.normalizeBaseUrl(e.baseUrl),this._propertiesRawText=t,this.parseProperties(t),this._name=e.name??this._propertiesMap.get("obs_collection")??this._propertiesMap.get("label")??this._name,this._minOrder=e.minOrder??this.readNumber("hips_order_min",this._minOrder),this._maxOrder=e.maxOrder??this.readNumber("hips_order",this.readNumber("hips_order_max",this._maxOrder)),this._fixedOrder=void 0!==e.order,this._selectedOrder=e.order??this._minOrder,this._maxCachedTiles=e.maxCachedTiles??this._maxCachedTiles,e.color)this._color=e.color;else if(this._propertiesMap.has("mesh_color")){const e=(this._propertiesMap.get("mesh_color")||"").split(/[,\s]+/).map(e=>Number(e)).filter(Number.isFinite);if(e.length>=3){let[t,r,i,s]=e;(t>1||r>1||i>1)&&(t/=255,r/=255,i/=255),Number.isFinite(s)||(s=1),this._color=[t,r,i,s]}}else this._color=this._color;if(this._wireframe=e.wireframe??this._wireframe,this._selectedOrder=this.clampOrder(this._selectedOrder),Number.isFinite(e.meshRadius))this._meshRadius=e.meshRadius;else{const e=this.readNumber("mesh_radius",NaN);if(!Number.isFinite(e))throw new Error('Missing mandatory property "mesh_radius" in MeshHiPS properties');this._meshRadius=e}}get name(){return this._name}get baseUrl(){return this._baseUrl}get minOrder(){return this._minOrder}get maxOrder(){return this._maxOrder}get selectedOrder(){return this._selectedOrder}get fixedOrder(){return this._fixedOrder}get maxCachedTiles(){return this._maxCachedTiles}get color(){return this._color}get wireframe(){return this._wireframe}get propertiesRawText(){return this._propertiesRawText}get properties(){return new Map(this._propertiesMap)}get meshRadius(){return this._meshRadius}getProperty(e){return this._propertiesMap.get(e)}getTileUrl(e,t){const r=1e4*Math.floor(t/1e4);return`${this._baseUrl}Norder${e}/Dir${r}/Npix${t}.obj`}parseProperties(e){const t=e.split(/\r\n|\n/);for(const e of t){const t=e.trim();if(!t||t.startsWith("#"))continue;const r=t.indexOf("=");r<0||this._propertiesMap.set(t.slice(0,r).trim(),t.slice(r+1).trim())}}readNumber(e,t){const r=Number(this._propertiesMap.get(e));return Number.isFinite(r)?r:t}clampOrder(e){return Math.max(this._minOrder,Math.min(this._maxOrder,e))}normalizeBaseUrl(e){return e.endsWith("/")?e:`${e}/`}}},1072:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataColumn=t.ColumnType=void 0,function(e){e.STRING="STRING",e.NUMBER="NUMBER",e.GEOM_RA="GEOM_RA",e.GEOM_DEC="GEOM_DEC",e.GEOM_FOOTPRINT="GEOM_FOOTPRINT",e.MAIN_NAME="MAIN_NAME"}(r||(t.ColumnType=r={})),t.MetadataColumn=class{_index;_name;_description="";_columnType;_unit;_details=new Map;constructor(e){if(!e.name)throw new Error("No name column defined.");if(this._name=e.name,e.index<0||isNaN(e.index))throw new Error("No index column defined.");this._index=e.index,this._columnType=e.columnType??r.STRING,this._unit=e.unit??"",this._description=e.description??"",e.details&&(this._details=new Map(e.details))}get details(){return new Map(this._details)}getDetail(e,t){return this._details.has(e)?this._details.get(e):t}getString(e,t=""){const r=this._details.get(e);return"string"==typeof r?r:t}getNumber(e,t=NaN){const r=this._details.get(e);return"number"==typeof r?r:t}setDetail(e,t){this._details.set(e,t)}setDetails(e){const t=e instanceof Map?e.entries():Object.entries(e);for(const[e,r]of t)this._details.set(e,r)}detailKeys(){return Array.from(this._details.keys())}detailValues(){return Array.from(this._details.values())}detailEntries(){return Array.from(this._details.entries())}get name(){return this._name}get description(){return this._description}get columnType(){return this._columnType}get index(){return this._index}get unit(){return this._unit}toJSON(){return{name:this._name,description:this._description,columnType:this._columnType,index:this._index,unit:this._unit,details:Object.fromEntries(this._details)}}}},1138:(e,t,r)=>{r.r(t),r.d(t,{CircleFinder:()=>l,Constants:()=>i,Fxyf:()=>c,Healpix:()=>_,Hploc:()=>n,Pointing:()=>a,RangeSet:()=>u,Vec3:()=>h,Xyf:()=>d,Zphi:()=>o,pstack:()=>s});class i{}i.halfpi=1.5707963267948966,i.inv_halfpi=2/Math.PI,i.twopi=2*Math.PI,i.inv_twopi=1/(2*Math.PI);class s{constructor(e){this.p=new Array(e),this.o=new Int32Array(e),this.s=0,this.m=0}push(e,t){this.p[this.s]=e,this.o[this.s]=t,++this.s}pop(){--this.s}popToMark(){this.s=this.m}size(){return this.s}mark(){this.m=this.s}otop(){return this.o[this.s-1]}ptop(){return this.p[this.s-1]}}class a{constructor(e,t,r,i){null!=e?(this.theta=n.atan2(Math.sqrt(e.x*e.x+e.y*e.y),e.z),this.phi=t?-n.atan2(e.y,e.x):n.atan2(e.y,e.x),this.phi<0&&(this.phi=this.phi+2*Math.PI),this.phi>=2*Math.PI&&(this.phi=this.phi-2*Math.PI)):(this.theta=r,this.phi=i)}}class o{constructor(e,t){this.z=e,this.phi=t}}class n{constructor(e){n.PI4_A=.7853981554508209,n.PI4_B=7.946627356147928e-9,n.PI4_C=3061616997868383e-32,n.M_1_PI=.3183098861837907,e&&(this.sth=0,this.have_sth=!1,this.z=n.cos(e.theta),this._phi=e.phi,Math.abs(this.z)>.99&&(this.sth=n.sin(e.theta),this.have_sth=!0))}setZ(e){this.z=e}get phi(){return this._phi}set phi(e){this._phi=e}setSth(e){this.sth=e}toPointing(e){const t=this.have_sth?this.sth:Math.sqrt((1-this.z)*(1+this.z));return new a(null,!1,n.atan2(t,this.z),this._phi)}toVec3(){var e=this.have_sth?this.sth:Math.sqrt((1-this.z)*(1+this.z));return new h(e*n.cos(this.phi),e*n.sin(this.phi),this.z)}toZphi(){return new o(this.z,this.phi)}static sin(e){let t=e*n.M_1_PI,r=Math.floor(t<0?t-.5:t+.5),i=4*r;return e-=i*n.PI4_A,e-=i*n.PI4_B,e-=i*n.PI4_C,1&r&&(e=-e),this.sincoshelper(e)}static cos(e){let t=e*n.M_1_PI-.5,r=1+2*Math.floor(t<0?t-.5:t+.5),i=2*r;return e-=i*n.PI4_A,e-=i*n.PI4_B,e-=i*n.PI4_C,2&r||(e=-e),n.sincoshelper(e)}static sincoshelper(e){let t=e*e,r=-7972559550090379e-33;return r=r*t+2810099727108632e-30,r=r*t-7647122191181588e-28,r=r*t+1.605904306056645e-10,r=r*t-2.5052108376350205e-8,r=r*t+27557319223919875e-22,r=r*t-.00019841269841269616,r=r*t+.00833333333333333,r=r*t-.16666666666666666,t*r*e+e}static asin(e){return n.mulsign(n.atan2k(Math.abs(e),Math.sqrt((1+e)*(1-e))),e)}static acos(e){return n.mulsign(n.atan2k(Math.sqrt((1+e)*(1-e)),Math.abs(e)),e)+(e<0?Math.PI:0)}static mulsign(e,t){return n.copySign(1,t)*e}static copySign(e,t){return t<0?-Math.abs(e):Math.abs(e)}static atanhelper(e){let t=e*e,r=-1887960084630735e-20;return r=r*t+.00020985007664581698,r=r*t-.0011061183148667248,r=r*t+.003700267441887131,r=r*t-.008898961958876555,r=r*t+.016599329773529202,r=r*t-.025451762493231264,r=r*t+.03378525800013531,r=r*t-.04076291912768365,r=r*t+.04666671500778406,r=r*t-.052367485230348246,r=r*t+.05876663929266736,r=r*t-.06665735793610805,r=r*t+.07692195383117696,r=r*t-.09090899500824501,r=r*t+.11111110564826142,r=r*t-.1428571426677133,r=r*t+.19999999999659127,r=r*t-.3333333333333111,r*t*e+e}static atan2k(e,t){let r=0;if(t<0&&(t=-t,r=-2),e>t){let i=t;t=e,e=-i,r+=1}return n.atanhelper(e/t)+r*(Math.PI/2)}static atan2(e,t){let r=n.atan2k(Math.abs(e),t);return r=n.mulsign(r,t),(n.isinf(t)||0==t)&&(r=Math.PI/2-(n.isinf(t)?n.copySign(1,t)*(Math.PI/2):0)),n.isinf(e)&&(r=Math.PI/2-(n.isinf(t)?n.copySign(1,t)*(1*Math.PI/4):0)),0==e&&(r=-1==n.copySign(1,t)?Math.PI:0),n.isnan(t)||n.isnan(e)?NaN:n.mulsign(r,e)}static isnan(e){return e!=e}static isinf(e){return Math.abs(e)===1/0}}n.PI4_A=.7853981554508209,n.PI4_B=7.946627356147928e-9,n.PI4_C=3061616997868383e-32,n.M_1_PI=.3183098861837907;class h{constructor(e,t,r){if(e instanceof a){let t=e,r=n.sin(t.theta);this.x=r*n.cos(t.phi),this.y=r*n.sin(t.phi),this.z=n.cos(t.theta)}else this.x=e,this.y=t,this.z=r}getX(){return this.x}getY(){return this.y}getZ(){return this.z}scale(e){this.x*=e,this.y*=e,this.z*=e}cross(e){return new h(this.y*e.z-e.y*this.z,this.z*e.x-e.z*this.x,this.x*e.y-e.x*this.y)}add(e){return new h(this.x+e.x,this.y+e.y,this.z+e.z)}normalize(){let e=1/this.length();this.x*=e,this.y*=e,this.z*=e}norm(){let e=1/this.length();return new h(this.x*e,this.y*e,this.z*e)}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}sub(e){return new h(this.x-e.x,this.y-e.y,this.z-e.z)}angle(e){return n.atan2(this.cross(e).length(),this.dot(e))}flip(){this.x*=-1,this.y*=-1,this.z*=-1}static pointing2Vec3(e){let t=n.sin(e.theta),r=t*n.cos(e.phi),i=t*n.sin(e.phi),s=n.cos(e.theta);return new h(r,i,s)}}class l{constructor(e){let t=e.length;if(t>=2){this.center=e[0].add(e[1]),this.center.normalize(),this.cosrad=e[0].dot(this.center);for(let r=2;r<t;++r)e[r].dot(this.center)<this.cosrad&&this.getCircle(e,r)}else console.log("too few points")}getCircle(e,t){this.center=e[0].add(e[t]),this.center.normalize(),this.cosrad=e[0].dot(this.center);for(let r=1;r<t;++r)e[r].dot(this.center)<this.cosrad&&this.getCircle2(e,r,t)}getCircle2(e,t,r){this.center=e[t].add(e[r]),this.center.normalize(),this.cosrad=e[t].dot(this.center);for(let i=0;i<t;++i)e[i].dot(this.center)<this.cosrad&&(this.center=e[t].sub(e[i]).cross(e[r].sub(e[i])),this.center.normalize(),this.cosrad=e[i].dot(this.center),this.cosrad<0&&(this.center.flip(),this.cosrad=-this.cosrad))}getCenter(){return new h(this.center.x,this.center.y,this.center.z)}getCosrad(){return this.cosrad}}class c{constructor(e,t,r){this.fx=e,this.fy=t,this.face=r,this.jrll=new Uint8Array([2,2,2,2,3,3,3,3,4,4,4,4]),this.jpll=new Uint8Array([1,3,5,7,0,2,4,6,1,3,5,7]),this.halfpi=Math.PI/2}toHploc(){let e,t=new n,r=this.jrll[this.face]-this.fx-this.fy;if(r<1){e=r;let i=e*e/3;t.z=1-i,t.z>.99&&(t.sth=Math.sqrt(i*(2-i)),t.have_sth=!0)}else if(r>3){e=4-r;let i=e*e/3;t.z=i-1,t.z<-.99&&(t.sth=Math.sqrt(i*(2-i)),t.have_sth=!0)}else e=1,t.z=2*(2-r)/3;let i=this.jpll[this.face]*e+this.fx-this.fy;return i<0&&(i+=8),i>=8&&(i-=8),t.phi=e<1e-15?0:.5*this.halfpi*i/e,t}toVec3(){return this.toHploc().toVec3()}}class u{constructor(e){e<0&&console.error("capacity must be positive"),this.r=new Int32Array(e<<1),this.sz=0}append(e){this.append1(e,e+1)}append1(e,t){if(e>=t)return;if(this.sz>0&&e<=this.r[this.sz-1])return e<this.r[this.sz-2]&&console.error("bad append operation"),void(t>this.r[this.sz-1]&&(this.r[this.sz-1]=t));let r=this.sz+2;if(this.r.length<r){let e=Math.max(2*this.r.length,r),t=new Int32Array(e);t.set(this.r),this.r=t}this.r[this.sz]=e,this.r[this.sz+1]=t,this.sz+=2}ensureCapacity(e){this.r.length<e&&this.resize(Math.max(2*this.r.length,e))}resize(e){if(e<this.sz&&console.error("requested array size too small"),e==this.r.length)return;new Int32Array(e);let t=this.r.slice(0,this.sz+1);this.r=t}}class d{constructor(e,t,r){this.ix=e,this.iy=t,this.face=r}}class _{constructor(e){this.order_max=29,this.inv_halfpi=2/Math.PI,this.twothird=2/3,this.ns_max=Math.pow(2,this.order_max),this.ctab=new Uint16Array([0,1,256,257,2,3,258,259,512,513,768,769,514,515,770,771,4,5,260,261,6,7,262,263,516,517,772,773,518,519,774,775,1024,1025,1280,1281,1026,1027,1282,1283,1536,1537,1792,1793,1538,1539,1794,1795,1028,1029,1284,1285,1030,1031,1286,1287,1540,1541,1796,1797,1542,1543,1798,1799,8,9,264,265,10,11,266,267,520,521,776,777,522,523,778,779,12,13,268,269,14,15,270,271,524,525,780,781,526,527,782,783,1032,1033,1288,1289,1034,1035,1290,1291,1544,1545,1800,1801,1546,1547,1802,1803,1036,1037,1292,1293,1038,1039,1294,1295,1548,1549,1804,1805,1550,1551,1806,1807,2048,2049,2304,2305,2050,2051,2306,2307,2560,2561,2816,2817,2562,2563,2818,2819,2052,2053,2308,2309,2054,2055,2310,2311,2564,2565,2820,2821,2566,2567,2822,2823,3072,3073,3328,3329,3074,3075,3330,3331,3584,3585,3840,3841,3586,3587,3842,3843,3076,3077,3332,3333,3078,3079,3334,3335,3588,3589,3844,3845,3590,3591,3846,3847,2056,2057,2312,2313,2058,2059,2314,2315,2568,2569,2824,2825,2570,2571,2826,2827,2060,2061,2316,2317,2062,2063,2318,2319,2572,2573,2828,2829,2574,2575,2830,2831,3080,3081,3336,3337,3082,3083,3338,3339,3592,3593,3848,3849,3594,3595,3850,3851,3084,3085,3340,3341,3086,3087,3342,3343,3596,3597,3852,3853,3598,3599,3854,3855]),this.utab=new Uint16Array([0,1,4,5,16,17,20,21,64,65,68,69,80,81,84,85,256,257,260,261,272,273,276,277,320,321,324,325,336,337,340,341,1024,1025,1028,1029,1040,1041,1044,1045,1088,1089,1092,1093,1104,1105,1108,1109,1280,1281,1284,1285,1296,1297,1300,1301,1344,1345,1348,1349,1360,1361,1364,1365,4096,4097,4100,4101,4112,4113,4116,4117,4160,4161,4164,4165,4176,4177,4180,4181,4352,4353,4356,4357,4368,4369,4372,4373,4416,4417,4420,4421,4432,4433,4436,4437,5120,5121,5124,5125,5136,5137,5140,5141,5184,5185,5188,5189,5200,5201,5204,5205,5376,5377,5380,5381,5392,5393,5396,5397,5440,5441,5444,5445,5456,5457,5460,5461,16384,16385,16388,16389,16400,16401,16404,16405,16448,16449,16452,16453,16464,16465,16468,16469,16640,16641,16644,16645,16656,16657,16660,16661,16704,16705,16708,16709,16720,16721,16724,16725,17408,17409,17412,17413,17424,17425,17428,17429,17472,17473,17476,17477,17488,17489,17492,17493,17664,17665,17668,17669,17680,17681,17684,17685,17728,17729,17732,17733,17744,17745,17748,17749,20480,20481,20484,20485,20496,20497,20500,20501,20544,20545,20548,20549,20560,20561,20564,20565,20736,20737,20740,20741,20752,20753,20756,20757,20800,20801,20804,20805,20816,20817,20820,20821,21504,21505,21508,21509,21520,21521,21524,21525,21568,21569,21572,21573,21584,21585,21588,21589,21760,21761,21764,21765,21776,21777,21780,21781,21824,21825,21828,21829,21840,21841,21844,21845]),this.jrll=new Int16Array([2,2,2,2,3,3,3,3,4,4,4,4]),this.jpll=new Int16Array([1,3,5,7,0,2,4,6,1,3,5,7]),this.xoffset=new Int16Array([-1,-1,0,1,1,1,0,-1]),this.yoffset=new Int16Array([0,1,1,1,0,-1,-1,-1]),this.facearray=[new Int16Array([8,9,10,11,-1,-1,-1,-1,10,11,8,9]),new Int16Array([5,6,7,4,8,9,10,11,9,10,11,8]),new Int16Array([-1,-1,-1,-1,5,6,7,4,-1,-1,-1,-1]),new Int16Array([4,5,6,7,11,8,9,10,11,8,9,10]),new Int16Array([0,1,2,3,4,5,6,7,8,9,10,11]),new Int16Array([1,2,3,0,0,1,2,3,5,6,7,4]),new Int16Array([-1,-1,-1,-1,7,4,5,6,-1,-1,-1,-1]),new Int16Array([3,0,1,2,3,0,1,2,4,5,6,7]),new Int16Array([2,3,0,1,-1,-1,-1,-1,0,1,2,3])],this.swaparray=[new Int16Array([0,0,3]),new Int16Array([0,0,6]),new Int16Array([0,0,0]),new Int16Array([0,0,5]),new Int16Array([0,0,0]),new Int16Array([5,0,0]),new Int16Array([0,0,0]),new Int16Array([6,0,0]),new Int16Array([3,0,0])],e<=this.ns_max&&e>0&&(this.nside=e,this.npface=this.nside*this.nside,this.npix=12*this.npface,this.order=this.nside2order(this.nside),this.nl2=2*this.nside,this.nl3=3*this.nside,this.nl4=4*this.nside,this.fact2=4/this.npix,this.fact1=(this.nside<<1)*this.fact2,this.ncap=2*this.nside*(this.nside-1)),this.bn=[],this.mpr=[],this.cmpr=[],this.smpr=[]}computeBn(){for(let e=0;e<=this.order_max;++e)this.bn[e]=new _(1<<e),this.mpr[e]=this.bn[e].maxPixrad(),this.cmpr[e]=n.cos(this.mpr[e]),this.smpr[e]=n.sin(this.mpr[e])}getNPix(){return this.npix}getBoundaries(e){let t=new Array,r=this.nest2xyf(e),i=.5/this.nside,s=(r.ix+.5)/this.nside,a=(r.iy+.5)/this.nside;return t[0]=new c(s+i,a+i,r.face).toVec3(),t[1]=new c(s-i,a+i,r.face).toVec3(),t[2]=new c(s-i,a-i,r.face).toVec3(),t[3]=new c(s+i,a-i,r.face).toVec3(),t}getBoundariesWithStep(e,t){let r=new Array,i=this.nest2xyf(e),s=.5/this.nside,a=(i.ix+.5)/this.nside,o=(i.iy+.5)/this.nside,n=1/(this.nside*t);for(let e=0;e<t;e++)r[e]=new c(a+s-e*n,o+s,i.face).toVec3(),r[e+t]=new c(a-s,o+s-e*n,i.face).toVec3(),r[e+2*t]=new c(a-s+e*n,o-s,i.face).toVec3(),r[e+3*t]=new c(a+s,o-s+e*n,i.face).toVec3();return r}getPointsForXyfNoStep(e,t,r){let i=new Array,s=new d(e,t,r),a=.5/this.nside,o=(s.ix+.5)/this.nside,n=(s.iy+.5)/this.nside;return i[0]=new c(o+a,n+a,s.face).toVec3(),i[1]=new c(o-a,n+a,s.face).toVec3(),i[2]=new c(o-a,n-a,s.face).toVec3(),i[3]=new c(o+a,n-a,s.face).toVec3(),i}getPointsForXyf(e,t,r,i){let s=r*Math.pow(2,this.order),a=new Array,o=new d(e,t,i),n=.5/s,h=(o.ix+.5)/s,l=(o.iy+.5)/s;return a[0]=new c(h+n,l+n,o.face).toVec3(),a[1]=new c(h-n,l+n,o.face).toVec3(),a[2]=new c(h-n,l-n,o.face).toVec3(),a[3]=new c(h+n,l-n,o.face).toVec3(),a}neighbours(e){let t=new Int32Array(8),r=this.nest2xyf(e),i=r.ix,s=r.iy,a=r.face;var o=this.nside-1;if(i>0&&i<o&&s>0&&s<o){let e=Math.floor(a<<2*this.order),r=this.spread_bits(i),o=this.spread_bits(s)<<1,n=this.spread_bits(i+1),h=this.spread_bits(s+1)<<1,l=this.spread_bits(i-1),c=this.spread_bits(s-1)<<1;t[0]=e+l+o,t[1]=e+l+h,t[2]=e+r+h,t[3]=e+n+h,t[4]=e+n+o,t[5]=e+n+c,t[6]=e+r+c,t[7]=e+l+c}else for(let e=0;e<8;++e){let r=i+this.xoffset[e],o=s+this.yoffset[e],n=4;r<0?(r+=this.nside,n-=1):r>=this.nside&&(r-=this.nside,n+=1),o<0?(o+=this.nside,n-=3):o>=this.nside&&(o-=this.nside,n+=3);let h=this.facearray[n][a];if(h>=0){let i=this.swaparray[n][a>>>2];if((1&i)>0&&(r=Math.floor(this.nside-r-1)),(2&i)>0&&(o=Math.floor(this.nside-o-1)),(4&i)>0){let e=r;r=o,o=e}t[e]=this.xyf2nest(r,o,h)}else t[e]=-1}return t}nside2order(e){return e&e-1?-1:Math.log2(e)}nest2xyf(e){let t=Math.floor(e&this.npface-1);return new d(this.compress_bits(t),this.compress_bits(t>>1),Math.floor(e>>2*this.order))}xyf2nest(e,t,r){return Math.floor(r<<2*this.order)+this.spread_bits(e)+(this.spread_bits(t)<<1)}loc2pix(e){let t,r=e.z,i=e.phi,s=Math.abs(r),a=this.fmodulo(i*this.inv_halfpi,4);if(s<=this.twothird){let e=this.nside*(.5+a),i=this.nside*(.75*r),s=Math.floor(e-i),o=Math.floor(e+i),n=Math.floor(s>>>this.order),h=Math.floor(o>>>this.order),l=Math.floor(n==h?4|n:n<h?n:h+8),c=Math.floor(o&this.nside-1),u=Math.floor(this.nside-(s&this.nside-1)-1);t=this.xyf2nest(c,u,l)}else{let i=Math.min(3,Math.floor(a)),o=a-i,n=s<.99||!e.have_sth?this.nside*Math.sqrt(3*(1-s)):this.nside*e.sth/Math.sqrt((1+s)/3),h=Math.floor(o*n),l=Math.floor((1-o)*n);h>=this.nside&&(h=this.nside-1),l>=this.nside&&(l=this.nside-1),t=r>=0?this.xyf2nest(Math.floor(this.nside-l-1),Math.floor(this.nside-h-1),i):this.xyf2nest(Math.floor(h),Math.floor(l),i+8)}return t}pix2vec(e){return this.pix2loc(e).toVec3()}pix2zphi(e){return this.pix2loc(e).toZphi()}pix2ang(e,t){return this.pix2loc(e).toPointing(t)}pix2loc(e){let t,r=new n(void 0),s=this.nest2xyf(e),a=(this.jrll[s.face]<<this.order)-s.ix-s.iy-1;if(a<this.nside){t=a;let e=t*t*this.fact2;r.z=1-e,r.z>.99&&(r.sth=Math.sqrt(e*(2-e)),r.have_sth=!0)}else if(a>this.nl3){t=this.nl4-a;let e=t*t*this.fact2;r.z=e-1,r.z<-.99&&(r.sth=Math.sqrt(e*(2-e)),r.have_sth=!0)}else t=this.nside,r.z=(this.nl2-a)*this.fact1;let o=this.jpll[s.face]*t+s.ix-s.iy;return o<0&&(o+=8*t),r.phi=t==this.nside?.75*i.halfpi*o*this.fact1:.5*i.halfpi*o/t,r}za2vec(e,t){const r=Math.sqrt(1-e*e),i=r*Math.cos(t),s=r*Math.sin(t);return new h(i,s,e)}ang2vec(e,t){const r=Math.cos(e);return this.za2vec(r,t)}vec2ang(e){const{z:t,a:r}=this.vec2za(e.getX(),e.getY(),e.getZ());return{theta:Math.acos(t),phi:r}}vec2za(e,t,r){const i=e*e+t*t;if(0==i)return{z:r<0?-1:1,a:0};{const s=Math.PI/2,a=(Math.atan2(t,e)+s)%s;return{z:r/=Math.sqrt(r*r+i),a}}}ang2pix(e,t){return this.loc2pix(new n(e))}fmodulo(e,t){if(e>=0)return e<t?e:e%t;var r=e%t+t;return r===t?0:r}compress_bits(e){var t=Math.floor(21845&e)|Math.floor((1431633920&e)>>>15);return this.ctab[255&t]|this.ctab[t>>>8]<<4}spread_bits(e){return Math.floor(this.utab[255&e])|Math.floor(this.utab[e>>>8&255]<<16)|Math.floor(this.utab[e>>>16&255]<<32)|Math.floor(this.utab[e>>>24&255]<<48)}queryPolygonInclusive(e,t){let r=0!=t,s=e.length;if(!(s>=3))return void console.log("not enough vertices in polygon");let o=new Array;for(let t=0;t<s;++t)o[t]=h.pointing2Vec3(e[t]);let c=new Array,u=0,d=0,_=!1;for(;d<o.length;){let e=o[d],t=null,r=null;d==o.length-1?(r=o[1],t=o[0]):d==o.length-2?(r=o[0],t=o[d+1]):(t=o[d+1],r=o[d+2]),c[d]=e.cross(t).norm();let i=c[d].dot(r);if(0==d)u=i<0?-1:1,new a(e),_=!1;else{if(u*i<0){new a(t),o.splice(d+1,1),c.splice(d,1),_=!0,d-=1;continue}new a(e),_=!1}c[d].scale(u),d+=1}s=o.length;let f=new Array(r?s+1:s);if(f=f.fill(i.halfpi),r){let e=new l(o);c[s]=e.getCenter(),f[s]=n.acos(e.getCosrad())}return this.queryMultiDisc(c,f,t)}queryMultiDisc(e,t,r){this.computeBn();let i=0!=r,a=e.length;if(a!=t.length)return void console.error("inconsistent input arrays");let o=new u(8),h=0;i&&(Math.pow(2,this.order_max-this.order)>=r||console.error("invalid oversampling factor"),r&r-1&&console.error("oversampling factor must be a power of 2"),h=this.ilog2(r));let l,c,d=this.order+h,_=new Array(d+1);for(l=0;l<=d;++l){_[l]=new Array(a);let e=this.bn[l].maxPixrad();for(c=0;c<a;++c)_[l][c]=new Float64Array(3),_[l][c][0]=t[c]+e>Math.PI?-1:n.cos(t[c]+e),_[l][c][1]=0==l?n.cos(t[c]):_[0][c][1],_[l][c][2]=t[c]-e<0?1:n.cos(t[c]-e)}let f=new s(12+3*d);for(let e=0;e<12;e++)f.push(11-e,0);for(;f.size()>0;){let t=f.ptop(),r=f.otop();f.pop();let s=this.bn[r].pix2vec(t),n=3;for(let t=0;t<a&&n>0;++t){let i=s.dot(e[t]);for(let e=0;e<n;++e)i<_[r][t][e]&&(n=e)}n>0&&this.check_pixel(r,d,n,o,t,f,i)}return o}ilog2(e){let t=Math.max(e,1);return 31-Math.clz32(t)}cosdist_zphi(e,t,r,i){return e*r+n.cos(t-i)*Math.sqrt((1-e*e)*(1-r*r))}check_pixel(e,t,r,i,s,a,o){if(0!=r)if(e<this.order)if(r>=3){let t=2*(this.order-e);i.append1(s<<t,s+1<<t)}else for(let t=0;t<4;++t)a.push(4*s+3-t,e+1);else if(e>this.order)if(r>=2)i.append(s>>>2*(e-this.order)),a.popToMark();else if(e<t)for(let t=0;t<4;++t)a.push(4*s+3-t,e+1);else i.append(s>>>2*(e-this.order)),a.popToMark();else if(r>=2)i.append(s);else if(o)if(this.order<t){a.mark();for(let t=0;t<4;++t)a.push(4*s+3-t,e+1)}else i.append(s)}maxPixrad(){let e=new o(2/3,Math.PI/this.nl4),t=this.convertZphi2xyz(e),r=new h(t[0],t[1],t[2]),i=1-1/this.nside;i*=i;let s=new o(1-i/3,0),a=this.convertZphi2xyz(s),n=new h(a[0],a[1],a[2]);return r.angle(n)}convertZphi2xyz(e){let t=Math.sqrt((1-e.z)*(1+e.z));return[t*n.cos(e.phi),t*n.sin(e.phi),e.z]}queryDiscInclusive(e,t,r){this.computeBn();let i=0!=r,a=new u;if(t>=Math.PI)return a.append1(0,this.npix),a;let o=0;i&&(r&r-1&&console.error("oversampling factor must be a power of 2"),o=this.ilog2(r));let l=Math.min(this.order_max,this.order+o),c=h.pointing2Vec3(e),d=new Array(l+1),_=new Array(l+1),f=n.cos(t),g=n.sin(t);for(let e=0;e<=l;e++){let r=this.mpr[e],i=this.cmpr[e],s=this.smpr[e];d[e]=t+r>Math.PI?-1:f*i-g*s,_[e]=t-r<0?1:f*i+g*s}let p=new s(12+3*l);for(let e=0;e<12;e++)p.push(11-e,0);for(;p.size()>0;){let t=p.ptop(),r=p.otop();p.pop();let s=this.bn[r].pix2zphi(t),o=this.cosdist_zphi(c.z,e.phi,s.z,s.phi);if(o>d[r]){let e=o<f?1:o<=_[r]?2:3;this.check_pixel(r,l,e,a,t,p,i)}}return a}}},1229:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=t.Source=t.MeshHiPSDescriptor=t.MeshHiPS=t.WMTSAdapter=t.XYZMap=t.HiPS=t.createColorMapFromSamples=t.COLOR_MAP_SAMPLE_COUNT=t.ColorMaps=t.GeoJSONParser=t.CoordsType=t.FoVUtils=t.CartesianOpts=t.PointInitOpts=t.AstroOpts=t.SphericalOpts=t.Point=t.ColumnType=t.MetadataInit=t.MetadataColumn=t.MetadataManager=t.TerraFootprintSetGL=t.TerraPointSetGL=t.CatalogueGL=t.FootprintSetGL=t.HoveredFootprintDetail=t.SphereFoV=t.FoV=t.HiPSDescriptor=t.AstroViewer=void 0;var s=r(772);Object.defineProperty(t,"AstroViewer",{enumerable:!0,get:function(){return s.AstroViewer}});var a=r(5087);Object.defineProperty(t,"HiPSDescriptor",{enumerable:!0,get:function(){return a.HiPSDescriptor}});var o=r(5803);Object.defineProperty(t,"FoV",{enumerable:!0,get:function(){return o.SphereFoV}});var n=r(5803);Object.defineProperty(t,"SphereFoV",{enumerable:!0,get:function(){return n.SphereFoV}});var h=r(592);Object.defineProperty(t,"HoveredFootprintDetail",{enumerable:!0,get:function(){return h.HoveredFootprintDetail}}),Object.defineProperty(t,"FootprintSetGL",{enumerable:!0,get:function(){return h.FootprintSetGL}});var l=r(1232);Object.defineProperty(t,"CatalogueGL",{enumerable:!0,get:function(){return l.CatalogueGL}});var c=r(5781);Object.defineProperty(t,"TerraPointSetGL",{enumerable:!0,get:function(){return c.TerraPointSetGL}});var u=r(9022);Object.defineProperty(t,"TerraFootprintSetGL",{enumerable:!0,get:function(){return u.TerraFootprintSetGL}});var d=r(5403);Object.defineProperty(t,"MetadataManager",{enumerable:!0,get:function(){return d.MetadataManager}});var _=r(1072);Object.defineProperty(t,"MetadataColumn",{enumerable:!0,get:function(){return _.MetadataColumn}}),Object.defineProperty(t,"MetadataInit",{enumerable:!0,get:function(){return _.MetadataInit}}),Object.defineProperty(t,"ColumnType",{enumerable:!0,get:function(){return _.ColumnType}});var f=r(6553);Object.defineProperty(t,"Point",{enumerable:!0,get:function(){return f.Point}}),Object.defineProperty(t,"SphericalOpts",{enumerable:!0,get:function(){return f.SphericalOpts}}),Object.defineProperty(t,"AstroOpts",{enumerable:!0,get:function(){return f.AstroOpts}}),Object.defineProperty(t,"PointInitOpts",{enumerable:!0,get:function(){return f.PointInitOpts}}),Object.defineProperty(t,"CartesianOpts",{enumerable:!0,get:function(){return f.CartesianOpts}});var g=r(8083);Object.defineProperty(t,"FoVUtils",{enumerable:!0,get:function(){return g.FoVUtils}});var p=r(8145);Object.defineProperty(t,"CoordsType",{enumerable:!0,get:function(){return p.CoordsType}});var m=r(8755);Object.defineProperty(t,"GeoJSONParser",{enumerable:!0,get:function(){return i(m).default}});var M=r(619);Object.defineProperty(t,"ColorMaps",{enumerable:!0,get:function(){return M.ColorMaps}}),Object.defineProperty(t,"COLOR_MAP_SAMPLE_COUNT",{enumerable:!0,get:function(){return M.COLOR_MAP_SAMPLE_COUNT}}),Object.defineProperty(t,"createColorMapFromSamples",{enumerable:!0,get:function(){return M.createColorMapFromSamples}});var x=r(3726);Object.defineProperty(t,"HiPS",{enumerable:!0,get:function(){return x.HiPS}});var v=r(1741);Object.defineProperty(t,"XYZMap",{enumerable:!0,get:function(){return v.XYZMap}});var b=r(3956);Object.defineProperty(t,"WMTSAdapter",{enumerable:!0,get:function(){return b.WMTSAdapter}});var S=r(6878);Object.defineProperty(t,"MeshHiPS",{enumerable:!0,get:function(){return S.MeshHiPS}});var P=r(847);Object.defineProperty(t,"MeshHiPSDescriptor",{enumerable:!0,get:function(){return P.MeshHiPSDescriptor}});var y=r(146);Object.defineProperty(t,"Source",{enumerable:!0,get:function(){return y.Source}});var T=r(2475);Object.defineProperty(t,"Footprint",{enumerable:!0,get:function(){return T.Footprint}}),console.log("astroviewer UMD loaded")},1232:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueGL=void 0;const i=r(146),s=r(6553),a=r(8145),o=r(7930),n=r(3559),h=r(5403);class l{_kind="CatalogueGL";static ELEM_SIZE=6;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;static STANDARD_SHAPE_SIZE=10;static STANDARD_SHAPE_HUE=3;_ready;_name;_description;_sources;vertexCataloguePositionBuffer=null;vertexhoveredCataloguePositionBuffer=null;vertexCataloguePosition;_bufferInitialised=!1;_webgl;hoveredIndexes;selectedIndexes;extHoveredIndexes;_oldMouseCoords;_metadataManager;_isVisible=!0;_shapeColor="#8F00FF";_healpixDensityMap;_providerUrl;_catalogueShaderProgram;_visibleTilesManager;constructor(e,t,r,i,s,a){this._webgl=s,this._ready=!1,this._visibleTilesManager=a,this.TYPE="SOURCE_CATALOGUE",this._name=e,this._description=t,this._providerUrl=r,this._metadataManager=i,this._sources=[],this.vertexCataloguePosition=new Float32Array(0),this.hoveredIndexes=[],this.selectedIndexes=[],this.extHoveredIndexes=[],this._oldMouseCoords=null,this._healpixDensityMap=new Map,this._catalogueShaderProgram=new n.CatalogueShaderProgram(this._webgl),this._catalogueShaderProgram.shaderProgram,this._isVisible=!0}setIsVisible(e){this._isVisible=e}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get isVisible(){return this._isVisible}minMax(e){if(!this._sources.length)return{min:0,max:0};let t=this._sources[0].details[e];if(isNaN(Number(t)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain only number values`),{min:0,max:0};let r=t;for(const i of this._sources){const s=i.details[e];if(isNaN(Number(s)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain number only values`),{min:0,max:0};s<t&&(t=s),s>r&&(r=s)}return{min:Number(t),max:Number(r)}}get metadataManager(){return this._metadataManager}changeMetaRA(e){this._metadataManager.selectedRaColumn=e}changeMetaDec(e){this._metadataManager.selectedDecColumn=e}changeColor(e){this._shapeColor=e}changeMetaShapeSize(e){if(!this._webgl)return;if(e==h.MetadataManager.STANDARD_SIZE){this._metadataManager.resetShapeColumn();for(const e of this._sources){const t=l.STANDARD_SHAPE_SIZE;e.shapeSize=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedShapeColumn=e;const r=this._metadataManager.selectedShapeColumn?.index??-1;if(r<0)return void(t&&(this._metadataManager.selectedShapeColumn=t));const i=this.minMax(r);if(i.min!=i.max){for(const e of this._sources){const t=Number(e.getDetailByindex(r)),s=Number(i.min),a=Number(i.max),o=(t-s)/Math.max(1e-12,a-s)*12+8;e.shapeSize=o}this._bufferInitialised=!1}else console.warn(`${i} min and max are equals. No resizing will be applied.`)}changeMetaShapeHue(e){if(!this._webgl)return;if(e==h.MetadataManager.STANDARD_HUE){this._metadataManager.resetHueColumn();for(const e of this._sources){const t=l.STANDARD_SHAPE_HUE;e.brightnessFactor=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedHueColumn=e;const r=this._metadataManager.selectedHueColumn?.index??-1;if(r<0)return void(t&&(this._metadataManager.selectedHueColumn=t));const i=this.minMax(r);if(i.min!=i.max){for(const e of this._sources){const t=Number(e.getDetailByindex(r)),s=Number(i.min),a=Number(i.max),o=(t-s)/Math.max(1e-12,a-s);e.brightnessFactor=-(2*o-1)}this._bufferInitialised=!1}else console.warn(`${i} min and max are equals. No resizing will be applied.`)}get sources(){return this._sources}addSource(e){this._sources.push(e)}addSources(e,t){this._ready=!1,this._sources=[],this._metadataManager=new h.MetadataManager(t);const r=this._metadataManager.selectedRaColumn?.index??-1,o=this._metadataManager.selectedDecColumn?.index??-1;if(r<0||o<0)throw new Error(`(ra, dec) idx not defined (${r}, ${o}) `);for(let t=0;t<e.length;t++){const n=new s.Point({raDeg:e[t][r],decDeg:e[t][o]},a.CoordsType.ASTRO),h=new i.Source(n,e[t]);h.shapeSize=h.shapeSize??l.STANDARD_SHAPE_SIZE,h.brightnessFactor=3,this.addSource(h),this._metadataManager.selectedHueColumn?.name&&this.changeMetaShapeHue(this._metadataManager.selectedHueColumn.name),this._metadataManager.selectedShapeColumn?.name&&this.changeMetaShapeSize(this._metadataManager.selectedShapeColumn.name)}this._ready=!0,this._bufferInitialised=!1}clearSources(){this._sources=[],this.hoveredIndexes=[],this._healpixDensityMap.clear(),this.vertexCataloguePosition=new Float32Array(0)}sourceMatches(e,t){if(e===t)return!0;const r=e.point,i=t.point;if(r.raDeg!==i.raDeg||r.decDeg!==i.decDeg)return!1;if(e.details.length!==t.details.length)return!1;for(let r=0;r<e.details.length;r++)if(!Object.is(e.details[r],t.details[r]))return!1;return!0}findSourceIndex(e){const t=this._sources.indexOf(e);return t>=0?t:this._sources.findIndex(t=>this.sourceMatches(t,e))}extHighlightSource(e,t){const r=this.findSourceIndex(e);if(r<0)return;const i=r*l.ELEM_SIZE;if(t)this.hoveredIndexes.includes(r)||this.hoveredIndexes.push(r);else{if(i+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(r);e>=0&&(this.hoveredIndexes.splice(e,1),this.vertexCataloguePosition[i+3]=0,this.vertexCataloguePosition[i+4]=this._sources[r]?.shapeSize??l.STANDARD_SHAPE_SIZE)}}extAddSources2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findSourceIndex(e);if(t<0)return;const r=t*l.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(r+4>=this.vertexCataloguePosition.length)return;const e=this.selectedIndexes.indexOf(t);e>=0&&(this.selectedIndexes.splice(e,1),this.vertexCataloguePosition[r+3]=0,this.vertexCataloguePosition[r+4]=this._sources[t]?.shapeSize??l.STANDARD_SHAPE_SIZE)}else this.selectedIndexes.push(t)}initBuffer(){this.vertexCataloguePositionBuffer=this._webgl.createBuffer(),this.vertexhoveredCataloguePositionBuffer=this._webgl.createBuffer(),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer);const e=this._sources.length;this.vertexCataloguePosition=new Float32Array(e*l.ELEM_SIZE);let t=0;for(let r=0;r<e;r++){const e=this._sources[r],i=e.healpixPixel,s=this._healpixDensityMap.get(i);s?s.includes(r)||s.push(r):this._healpixDensityMap.set(i,[r]),this.vertexCataloguePosition[t+0]=e.point.x,this.vertexCataloguePosition[t+1]=e.point.y,this.vertexCataloguePosition[t+2]=e.point.z,this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=e.shapeSize??l.STANDARD_SHAPE_SIZE,this.vertexCataloguePosition[t+5]=e.brightnessFactor??0,t+=l.ELEM_SIZE}this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._bufferInitialised=!0}getSelectionRadius(){switch(this._visibleTilesManager.getVisibleOrder()){case 0:case 1:case 2:return.01;case 3:case 4:case 5:return.005;case 6:case 7:case 8:return.001;case 9:return 5e-4;default:return 1e-4}}checkClicking(e){if(null==e.x||null==e.y||null==e.z)return console.log("CatalogueGL.checkClicking: missing mouse coords"),[];const t=[],r=e.computeNpix();if(null!=r&&this._healpixDensityMap.has(r)){const i=this._healpixDensityMap.get(r),s=this.getSelectionRadius();for(let r=0;r<i.length;r++){const a=i[r],o=this._sources[a];if(!o)continue;const n=o.point.x-e.x,h=o.point.y-e.y,l=o.point.z-e.z;Math.sqrt(n*n+h*h+l*l)<=s&&t.push(a)}}return t}setSelectedIndexes(e){e.forEach(e=>{if(e<0||e>=this._sources.length)return;const t=e*l.ELEM_SIZE;t+4>=this.vertexCataloguePosition.length||(this.selectedIndexes.includes(e)?(this.selectedIndexes.splice(this.selectedIndexes.indexOf(e),1),this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??l.STANDARD_SHAPE_SIZE):(this.selectedIndexes.push(e),this.vertexCataloguePosition[t+3]=2,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??l.STANDARD_SHAPE_SIZE))})}getSourcesFromPointer(e){const t=this.checkClicking(e);if(!t.length)return{sources:[],pickedIndexes:[]};const r=[];return t.forEach(e=>{const t=this._sources[e];t&&r.push(t)}),r.length?{sources:r,pickedIndexes:t}:null}selectPrimarySourceFromClick(e){const t=this.getSourcesFromPointer(e),r=t?.pickedIndexes??[];if(this.setSelectedIndexes(r),!r.length)return{sources:[],selectionState:[]};const i=[],s=[];return r.forEach(e=>{const t=this._sources[e];if(!t)return;const r=this.selectedIndexes.includes(e);i.push({source:t,selected:r}),s.push(t)}),s.length?{sources:s,selectionState:i}:null}getPrimaryHoveredSource(){if(!this.hoveredIndexes.length)return null;const e=this.hoveredIndexes[0];return this._sources[e]??null}checkHovering(e){if(null==e.x||null==e.y||null==e.z)return console.log("CatalogueGL.checkHovering: missing mouse coords"),[];const t=[],r=e.computeNpix();if(null!=r&&this._healpixDensityMap.has(r)){const i=this._healpixDensityMap.get(r),s=this.getSelectionRadius();for(let r=0;r<i.length;r++){const a=i[r],o=this._sources[a];if(!o)continue;const n=o.point.x-e.x,h=o.point.y-e.y,l=o.point.z-e.z;Math.sqrt(n*n+h*h+l*l)<=s&&t.push(a)}}return t}draw(e,t,r,i){if(!this.isVisible)return;if(!this._ready)return;if(!r)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;this._catalogueShaderProgram.enableShaders(i,e,r),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.position,3,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.position),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.hovered,1,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,3*l.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.hovered),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.pointSize,1,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,4*l.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.pointSize),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.brightness,1,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,5*l.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.brightness);const s=(0,o.colorHex2RGB)(this._shapeColor);this._catalogueShaderProgram.locations.color&&this._webgl.uniform4f(this._catalogueShaderProgram.locations.color,s[0],s[1],s[2],1);for(let e=0;e<this.selectedIndexes.length;e++){const t=this.selectedIndexes[e],r=t*l.ELEM_SIZE;this.vertexCataloguePosition[r+3]=2,this.vertexCataloguePosition[r+4]=this._sources[t].shapeSize}for(let e=0;e<this.hoveredIndexes.length;e++){const t=this.hoveredIndexes[e]*l.ELEM_SIZE;this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=this._sources[this.hoveredIndexes[e]].shapeSize}null!=t&&t.xyz!==this._oldMouseCoords&&(this.hoveredIndexes=this.checkHovering(t));for(let e=0;e<this.hoveredIndexes.length;e++){const t=this.hoveredIndexes[e],r=t*l.ELEM_SIZE;this.vertexCataloguePosition[r+3]=1,this.vertexCataloguePosition[r+4]=this._sources[t].shapeSize}this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW);const a=this.vertexCataloguePosition.length/l.ELEM_SIZE;this._webgl.drawArrays(this._webgl.POINTS,0,a),this._oldMouseCoords=t.xyz}}t.CatalogueGL=l},1375:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZTile=void 0;const i=r(8819);t.XYZTile=class{_coord;_url;_webgl;_shaderProgram;_meshBuilder;_gpuMesh;_texture=null;_image;_ready=!1;_loading=!1;_aborted=!1;_failedUntil=0;_lastUsedAt=0;_createdAt=Date.now();constructor(e,t,r,s,a=new i.XYZMeshBuilder,o=16){this._coord=e,this._url=t,this._webgl=r,this._shaderProgram=s,this._meshBuilder=a;const n=this._meshBuilder.buildTileMesh(e,o);this._gpuMesh=this._meshBuilder.uploadMesh(n,this._webgl),this.initImage()}get coord(){return this._coord}get ready(){return this._ready}get loading(){return this._loading}get failedUntil(){return this._failedUntil}get lastUsedAt(){return this._lastUsedAt}get createdAt(){return this._createdAt}touch(){this._lastUsedAt=Date.now()}initImage(){if(this._loading||this._ready||this._aborted)return;const e=Date.now();if(this._failedUntil>e)return;this._loading=!0;const t=new Image;this._image=t,t.crossOrigin="anonymous",t.onload=()=>this.imageLoaded(),t.onerror=()=>{this._ready=!1,this._loading=!1,this._failedUntil=Date.now()+3e4},t.src=this._url}imageLoaded(){this._image&&!this._aborted&&(this.textureLoaded(this._image),this._loading=!1,this._failedUntil=0,this._ready=!0)}textureLoaded(e){const t=this._webgl;this._shaderProgram.enableProgram();const r=t.createTexture();if(!r)throw new Error(`Could not create XYZ texture for ${this.key}`);this._texture=r,t.activeTexture(t.TEXTURE0),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)}draw(e,t,r,i){return this.touch(),!(!this._ready||!this._texture||this._aborted||(this.drawWithGpuMesh(this._gpuMesh,e,t,r,i),0))}drawRemapped(e,t,r,i,s){return this.touch(),!(!this._ready||!this._texture||this._aborted||(this.drawWithGpuMesh(e,t,r,i,s),0))}dispose(){const e=this._webgl;this._texture&&(e.deleteTexture(this._texture),this._texture=null),this._gpuMesh.positionBuffer&&(e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh.positionBuffer=null),this._gpuMesh.uvBuffer&&(e.deleteBuffer(this._gpuMesh.uvBuffer),this._gpuMesh.uvBuffer=null),this._gpuMesh.indexBuffer&&(e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh.indexBuffer=null),this._image=void 0,this._ready=!1,this._loading=!1,this._aborted=!0}drawWithGpuMesh(e,t,r,i,s){if(!this._texture)return;const a=this._webgl;this._shaderProgram.enableShaders(t,r,i,s),a.bindBuffer(a.ARRAY_BUFFER,e.positionBuffer),a.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,a.FLOAT,!1,0,0),a.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),a.bindBuffer(a.ARRAY_BUFFER,e.uvBuffer),a.vertexAttribPointer(this._shaderProgram.locations.textureCoordAttribute,2,a.FLOAT,!1,0,0),a.enableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,this._texture),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,e.indexBuffer),a.drawElements(a.TRIANGLES,e.indexCount,e.indexType,0),a.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),a.disableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute)}get key(){return`${this._coord.z}/${this._coord.x}/${this._coord.y}`}}},1741:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMap=void 0;const i=r(4735),s=r(6937),a=r(8284),o=r(619),n=r(8124),h=r(149),l=r(2737),c=r(3174),u=r(8819);class d extends i.AbstractSkyEntity{_xyzShaderProgram;_descriptor;_visibleTilesManager;_tileBuffer;_meshBuilder;_baseurl;_zoom;_latLonGrid;_colorMapIdx=0;_colorMap=o.ColorMaps.native;constructor(e,t,r,i,o,c){super(e,t,r,i,o.name,c,!1),this._descriptor=o,this._xyzShaderProgram=new h.XYZShaderProgram(c),this._meshBuilder=new u.XYZMeshBuilder,this._tileBuffer=new l.XYZTileBuffer(1),this.initGL(c),this._latLonGrid=new n.LatLonGrid(e,t,r,i,"LatLonGrid",this._webgl),this._visibleTilesManager=new s.XYZVisibleTilesManager,this._baseurl=o.url,this.initShaders(),this._zoom=a.xyzFovHelper.getZoom(180)}changeColorMap(e){switch(this._colorMap=e,e.name){case"grayscale":this._colorMapIdx=1,this._colorMap=o.ColorMaps.grayscale;break;case"planck":this._colorMapIdx=2,this._colorMap=o.ColorMaps.planck;break;case"cmb":this._colorMapIdx=3,this._colorMap=o.ColorMaps.cmb;break;case"rainbow":this._colorMapIdx=4,this._colorMap=o.ColorMaps.rainbow;break;case"eosb":this._colorMapIdx=5,this._colorMap=o.ColorMaps.eosb;break;case"cubehelix":this._colorMapIdx=6,this._colorMap=o.ColorMaps.cubehelix;break;case"hot":this._colorMapIdx=7,this._colorMap=o.ColorMaps.hot;break;case"gray":this._colorMapIdx=8,this._colorMap=o.ColorMaps.gray;break;case"native":this._colorMapIdx=0,this._colorMap=o.ColorMaps.native;break;default:this._colorMapIdx=9,this._colorMap=e}}initShaders(){this._xyzShaderProgram.enableProgram()}isLonLatGridVisible(){return this._latLonGrid.isVisible()}toggleLonLatGrid(){return this._latLonGrid.toggleShowGrid()}getFoV(){return this._latLonGrid.getFoV()}refresh(e){const t=this._latLonGrid.refreshFoV(e);this._zoom=a.xyzFovHelper.getZoom(t)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const r=e.pMatrix;if(!r)return;this.refresh(e);const i=this.getModelMatrix();this._xyzShaderProgram.setRuntimeColorMap(this._colorMap);const s=this._visibleTilesManager.computeVisibleTiles(this._zoom,this,this._webgl,e.camera,e.pMatrix),a=s.visibleTiles,o=s.ancestorsMap,n=this._tileBuffer.ensureTiles(this.getTilesToEnsure(a,o),e=>this.createTile(e));this._tileBuffer.evictCached(this._descriptor.maxCachedTiles);for(const e of n){const a=this._tileBuffer.getActiveTile(e);if(!a||a.coord.z!==s.currentZoom)continue;if(a.draw(r,t,i,this._colorMapIdx))continue;const n=this.findBestAvailableAncestor(a.coord);n?.draw(s.currentZoom,[a.coord],o,r,t,i,this._colorMapIdx)}this._latLonGrid.draw(e)}createTile(e){return new c.XYZAnchestorTile(e,this.resolveTileUrl(e),this._webgl,this._xyzShaderProgram,this._meshBuilder,this._descriptor.segmentsPerSide)}getTilesToEnsure(e,t){const r=new Map;for(const t of e)r.set(this.tileKey(t),t);for(const e of t.values())r.set(this.tileKey(e),e);return Array.from(r.values())}findBestAvailableAncestor(e){for(let t=e.z-1;t>=0;t--){const r=e.z-t,i={z:t,x:e.x>>r,y:e.y>>r},s=this._tileBuffer.getAnyTile(this.tileKey(i));if(s?.ready)return s}return null}resolveTileUrl(e){const t=this._descriptor.urlResolver;if(t)return t(e);const r=2**e.z,i=this._descriptor.flipY?r-1-e.y:e.y,s=this._descriptor.subdomains,a=s.length>0?s[Math.abs(e.x+e.y+e.z)%s.length]:"";return this._baseurl.replace(/\{z\}/g,String(e.z)).replace(/\{x\}/g,String(e.x)).replace(/\{y\}/g,String(i)).replace(/\{s\}/g,a??"")}getDebugStats(){const e=Array.from(this._tileBuffer.activeTiles.values(),e=>e.tile),t=Array.from(this._tileBuffer.cachedTiles.values(),e=>e.tile),r=[...e,...t],i=this._visibleTilesManager.selection;return{cacheSize:this._tileBuffer.size,visibleTileCount:i.visibleTiles.length,currentTileCount:e.filter(e=>e.coord.z===i.currentZoom).length,fallbackTileCount:i.ancestorsMap.size,coreTileCount:i.visibleTiles.length,coverageTileCount:i.visibleTiles.length,readyTileCount:r.filter(e=>e.ready).length,loadingTileCount:r.filter(e=>e.loading).length,coolingDownTileCount:0,currentZoom:i.currentZoom,tileSelectionKey:i.key,isSettling:!1,coarseTileCount:i.ancestorsMap.size,hasPendingSelection:!1,pendingSelectionKey:null}}tileKey(e){return`${e.z}/${e.x}/${e.y}`}}t.XYZMap=d},1961:(e,t,r)=>{r.r(t),r.d(t,{glMatrix:()=>i,mat2:()=>s,mat2d:()=>a,mat3:()=>o,mat4:()=>n,quat:()=>c,quat2:()=>u,vec2:()=>d,vec3:()=>h,vec4:()=>l});var i={};r.r(i),r.d(i,{ANGLE_ORDER:()=>p,ARRAY_TYPE:()=>f,EPSILON:()=>_,RANDOM:()=>g,equals:()=>P,round:()=>m,setMatrixArrayType:()=>M,toDegree:()=>S,toRadian:()=>b});var s={};r.r(s),r.d(s,{LDU:()=>H,add:()=>G,adjoint:()=>I,clone:()=>T,copy:()=>w,create:()=>y,determinant:()=>D,equals:()=>X,exactEquals:()=>k,frob:()=>z,fromRotation:()=>V,fromScaling:()=>N,fromValues:()=>A,identity:()=>C,invert:()=>F,mul:()=>Z,multiply:()=>L,multiplyScalar:()=>q,multiplyScalarAndAdd:()=>j,rotate:()=>B,scale:()=>O,set:()=>E,str:()=>U,sub:()=>W,subtract:()=>Y,transpose:()=>R});var a={};r.r(a),r.d(a,{add:()=>_e,clone:()=>K,copy:()=>Q,create:()=>$,determinant:()=>ie,equals:()=>Me,exactEquals:()=>me,frob:()=>de,fromRotation:()=>he,fromScaling:()=>le,fromTranslation:()=>ce,fromValues:()=>ee,identity:()=>J,invert:()=>re,mul:()=>xe,multiply:()=>se,multiplyScalar:()=>ge,multiplyScalarAndAdd:()=>pe,rotate:()=>ae,scale:()=>oe,set:()=>te,str:()=>ue,sub:()=>ve,subtract:()=>fe,translate:()=>ne});var o={};r.r(o),r.d(o,{add:()=>Xe,adjoint:()=>Re,clone:()=>Pe,copy:()=>ye,create:()=>be,determinant:()=>Fe,equals:()=>$e,exactEquals:()=>We,frob:()=>ke,fromMat2d:()=>Ue,fromMat4:()=>Se,fromQuat:()=>ze,fromRotation:()=>Ve,fromScaling:()=>Ne,fromTranslation:()=>Oe,fromValues:()=>Te,identity:()=>Ce,invert:()=>Ee,mul:()=>Ke,multiply:()=>Ie,multiplyScalar:()=>je,multiplyScalarAndAdd:()=>Ze,normalFromMat4:()=>He,projection:()=>Ge,rotate:()=>Le,scale:()=>Be,set:()=>we,str:()=>Ye,sub:()=>Qe,subtract:()=>qe,translate:()=>De,transpose:()=>Ae});var n={};r.r(n),r.d(n,{add:()=>Yt,adjoint:()=>nt,clone:()=>et,copy:()=>tt,create:()=>Je,decompose:()=>Ct,determinant:()=>ht,equals:()=>Zt,exactEquals:()=>jt,frob:()=>Gt,fromQuat:()=>Rt,fromQuat2:()=>Pt,fromRotation:()=>Mt,fromRotationTranslation:()=>St,fromRotationTranslationScale:()=>At,fromRotationTranslationScaleOrigin:()=>Et,fromScaling:()=>mt,fromTranslation:()=>pt,fromValues:()=>rt,fromXRotation:()=>xt,fromYRotation:()=>vt,fromZRotation:()=>bt,frustum:()=>Ft,getRotation:()=>wt,getScaling:()=>Tt,getTranslation:()=>yt,identity:()=>st,invert:()=>ot,lookAt:()=>Ut,mul:()=>Wt,multiply:()=>lt,multiplyScalar:()=>Xt,multiplyScalarAndAdd:()=>qt,ortho:()=>Vt,orthoNO:()=>Ot,orthoZO:()=>Nt,perspective:()=>Dt,perspectiveFromFieldOfView:()=>Bt,perspectiveNO:()=>It,perspectiveZO:()=>Lt,rotate:()=>dt,rotateX:()=>_t,rotateY:()=>ft,rotateZ:()=>gt,scale:()=>ut,set:()=>it,str:()=>Ht,sub:()=>$t,subtract:()=>kt,targetTo:()=>zt,translate:()=>ct,transpose:()=>at});var h={};r.r(h),r.d(h,{add:()=>ir,angle:()=>Dr,bezier:()=>Tr,ceil:()=>nr,clone:()=>Qt,copy:()=>tr,create:()=>Kt,cross:()=>br,dist:()=>Gr,distance:()=>fr,div:()=>Hr,divide:()=>or,dot:()=>vr,equals:()=>Vr,exactEquals:()=>Or,floor:()=>hr,forEach:()=>qr,fromValues:()=>er,hermite:()=>yr,inverse:()=>Mr,len:()=>kr,length:()=>Jt,lerp:()=>Sr,max:()=>cr,min:()=>lr,mul:()=>zr,multiply:()=>ar,negate:()=>mr,normalize:()=>xr,random:()=>wr,rotateX:()=>Rr,rotateY:()=>Fr,rotateZ:()=>Ir,round:()=>ur,scale:()=>dr,scaleAndAdd:()=>_r,set:()=>rr,slerp:()=>Pr,sqrDist:()=>Yr,sqrLen:()=>Xr,squaredDistance:()=>gr,squaredLength:()=>pr,str:()=>Br,sub:()=>Ur,subtract:()=>sr,transformMat3:()=>Ar,transformMat4:()=>Cr,transformQuat:()=>Er,zero:()=>Lr});var l={};r.r(l),r.d(l,{add:()=>Qr,ceil:()=>ri,clone:()=>Zr,copy:()=>$r,create:()=>jr,cross:()=>mi,dist:()=>Ei,distance:()=>li,div:()=>Ai,divide:()=>ti,dot:()=>pi,equals:()=>Ti,exactEquals:()=>yi,floor:()=>ii,forEach:()=>Di,fromValues:()=>Wr,inverse:()=>fi,len:()=>Fi,length:()=>ui,lerp:()=>Mi,max:()=>ai,min:()=>si,mul:()=>Ci,multiply:()=>ei,negate:()=>_i,normalize:()=>gi,random:()=>xi,round:()=>oi,scale:()=>ni,scaleAndAdd:()=>hi,set:()=>Kr,sqrDist:()=>Ri,sqrLen:()=>Ii,squaredDistance:()=>ci,squaredLength:()=>di,str:()=>Pi,sub:()=>wi,subtract:()=>Jr,transformMat4:()=>vi,transformQuat:()=>bi,zero:()=>Si});var c={};r.r(c),r.d(c,{add:()=>ss,calculateW:()=>Yi,clone:()=>es,conjugate:()=>$i,copy:()=>rs,create:()=>Li,dot:()=>ns,equals:()=>gs,exactEquals:()=>fs,exp:()=>ki,fromEuler:()=>Qi,fromMat3:()=>Ki,fromValues:()=>ts,getAngle:()=>Ni,getAxisAngle:()=>Vi,identity:()=>Bi,invert:()=>Wi,len:()=>cs,length:()=>ls,lerp:()=>hs,ln:()=>Xi,mul:()=>as,multiply:()=>Ui,normalize:()=>_s,pow:()=>qi,random:()=>Zi,rotateX:()=>zi,rotateY:()=>Hi,rotateZ:()=>Gi,rotationTo:()=>Ss,scale:()=>os,set:()=>is,setAxes:()=>ys,setAxisAngle:()=>Oi,slerp:()=>ji,sqlerp:()=>Ps,sqrLen:()=>ds,squaredLength:()=>us,str:()=>Ji});var u={};r.r(u),r.d(u,{add:()=>Zs,clone:()=>ws,conjugate:()=>ta,copy:()=>Ds,create:()=>Ts,dot:()=>Qs,equals:()=>la,exactEquals:()=>ha,fromMat4:()=>Is,fromRotation:()=>Fs,fromRotationTranslation:()=>Es,fromRotationTranslationValues:()=>As,fromTranslation:()=>Rs,fromValues:()=>Cs,getDual:()=>Vs,getReal:()=>Os,getTranslation:()=>zs,identity:()=>Ls,invert:()=>ea,len:()=>ia,length:()=>ra,lerp:()=>Js,mul:()=>$s,multiply:()=>Ws,normalize:()=>oa,rotateAroundAxis:()=>js,rotateByQuatAppend:()=>Xs,rotateByQuatPrepend:()=>qs,rotateX:()=>Gs,rotateY:()=>Ys,rotateZ:()=>ks,scale:()=>Ks,set:()=>Bs,setDual:()=>Us,setReal:()=>Ns,sqrLen:()=>aa,squaredLength:()=>sa,str:()=>na,translate:()=>Hs});var d={};r.r(d),r.d(d,{add:()=>ga,angle:()=>Ga,ceil:()=>xa,clone:()=>ua,copy:()=>_a,create:()=>ca,cross:()=>La,dist:()=>Qa,distance:()=>wa,div:()=>Ka,divide:()=>Ma,dot:()=>Da,equals:()=>ja,exactEquals:()=>qa,floor:()=>va,forEach:()=>to,fromValues:()=>da,inverse:()=>Fa,len:()=>Za,length:()=>Aa,lerp:()=>Ba,max:()=>Sa,min:()=>ba,mul:()=>$a,multiply:()=>ma,negate:()=>Ra,normalize:()=>Ia,random:()=>Oa,rotate:()=>Ha,round:()=>Pa,scale:()=>ya,scaleAndAdd:()=>Ta,set:()=>fa,signedAngle:()=>Ya,sqrDist:()=>Ja,sqrLen:()=>eo,squaredDistance:()=>Ca,squaredLength:()=>Ea,str:()=>Xa,sub:()=>Wa,subtract:()=>pa,transformMat2:()=>Va,transformMat2d:()=>Na,transformMat3:()=>Ua,transformMat4:()=>za,zero:()=>ka});var _=1e-6,f="undefined"!=typeof Float32Array?Float32Array:Array,g=Math.random,p="zyx";function m(e){return e>=0?Math.round(e):e%.5==0?Math.floor(e):Math.round(e)}function M(e){f=e}var x=Math.PI/180,v=180/Math.PI;function b(e){return e*x}function S(e){return e*v}function P(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_;return Math.abs(e-t)<=r*Math.max(1,Math.abs(e),Math.abs(t))}function y(){var e=new f(4);return f!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function T(e){var t=new f(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function w(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function C(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function A(e,t,r,i){var s=new f(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=i,s}function E(e,t,r,i,s){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e}function R(e,t){if(e===t){var r=t[1];e[1]=t[2],e[2]=r}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e}function F(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=r*a-s*i;return o?(o=1/o,e[0]=a*o,e[1]=-i*o,e[2]=-s*o,e[3]=r*o,e):null}function I(e,t){var r=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=r,e}function D(e){return e[0]*e[3]-e[2]*e[1]}function L(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=r[0],h=r[1],l=r[2],c=r[3];return e[0]=i*n+a*h,e[1]=s*n+o*h,e[2]=i*l+a*c,e[3]=s*l+o*c,e}function B(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(r),h=Math.cos(r);return e[0]=i*h+a*n,e[1]=s*h+o*n,e[2]=i*-n+a*h,e[3]=s*-n+o*h,e}function O(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=r[0],h=r[1];return e[0]=i*n,e[1]=s*n,e[2]=a*h,e[3]=o*h,e}function V(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=-r,e[3]=i,e}function N(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e}function U(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function z(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3])}function H(e,t,r,i){return e[2]=i[2]/i[0],r[0]=i[0],r[1]=i[1],r[3]=i[3]-e[2]*r[1],[e,t,r]}function G(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function Y(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function k(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function X(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=t[0],n=t[1],h=t[2],l=t[3];return Math.abs(r-o)<=_*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-n)<=_*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(s-h)<=_*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(a-l)<=_*Math.max(1,Math.abs(a),Math.abs(l))}function q(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function j(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e}var Z=L,W=Y;function $(){var e=new f(6);return f!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e}function K(e){var t=new f(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t}function Q(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function J(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e}function ee(e,t,r,i,s,a){var o=new f(6);return o[0]=e,o[1]=t,o[2]=r,o[3]=i,o[4]=s,o[5]=a,o}function te(e,t,r,i,s,a,o){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e[4]=a,e[5]=o,e}function re(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=r*a-i*s;return h?(h=1/h,e[0]=a*h,e[1]=-i*h,e[2]=-s*h,e[3]=r*h,e[4]=(s*n-a*o)*h,e[5]=(i*o-r*n)*h,e):null}function ie(e){return e[0]*e[3]-e[1]*e[2]}function se(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=r[0],c=r[1],u=r[2],d=r[3],_=r[4],f=r[5];return e[0]=i*l+a*c,e[1]=s*l+o*c,e[2]=i*u+a*d,e[3]=s*u+o*d,e[4]=i*_+a*f+n,e[5]=s*_+o*f+h,e}function ae(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=Math.sin(r),c=Math.cos(r);return e[0]=i*c+a*l,e[1]=s*c+o*l,e[2]=i*-l+a*c,e[3]=s*-l+o*c,e[4]=n,e[5]=h,e}function oe(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=r[0],c=r[1];return e[0]=i*l,e[1]=s*l,e[2]=a*c,e[3]=o*c,e[4]=n,e[5]=h,e}function ne(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=r[0],c=r[1];return e[0]=i,e[1]=s,e[2]=a,e[3]=o,e[4]=i*l+a*c+n,e[5]=s*l+o*c+h,e}function he(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=-r,e[3]=i,e[4]=0,e[5]=0,e}function le(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e}function ce(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e}function ue(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"}function de(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+1)}function _e(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e}function fe(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e}function ge(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e}function pe(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e}function me(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]}function Me(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=t[0],l=t[1],c=t[2],u=t[3],d=t[4],f=t[5];return Math.abs(r-h)<=_*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(i-l)<=_*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(s-c)<=_*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-u)<=_*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(o-d)<=_*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(n-f)<=_*Math.max(1,Math.abs(n),Math.abs(f))}var xe=se,ve=fe;function be(){var e=new f(9);return f!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Se(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}function Pe(e){var t=new f(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function ye(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function Te(e,t,r,i,s,a,o,n,h){var l=new f(9);return l[0]=e,l[1]=t,l[2]=r,l[3]=i,l[4]=s,l[5]=a,l[6]=o,l[7]=n,l[8]=h,l}function we(e,t,r,i,s,a,o,n,h,l){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e[4]=a,e[5]=o,e[6]=n,e[7]=h,e[8]=l,e}function Ce(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function Ae(e,t){if(e===t){var r=t[1],i=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=i,e[7]=s}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function Ee(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=c*o-n*l,d=-c*a+n*h,_=l*a-o*h,f=r*u+i*d+s*_;return f?(f=1/f,e[0]=u*f,e[1]=(-c*i+s*l)*f,e[2]=(n*i-s*o)*f,e[3]=d*f,e[4]=(c*r-s*h)*f,e[5]=(-n*r+s*a)*f,e[6]=_*f,e[7]=(-l*r+i*h)*f,e[8]=(o*r-i*a)*f,e):null}function Re(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8];return e[0]=o*c-n*l,e[1]=s*l-i*c,e[2]=i*n-s*o,e[3]=n*h-a*c,e[4]=r*c-s*h,e[5]=s*a-r*n,e[6]=a*l-o*h,e[7]=i*h-r*l,e[8]=r*o-i*a,e}function Fe(e){var t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],n=e[6],h=e[7],l=e[8];return t*(l*a-o*h)+r*(-l*s+o*n)+i*(h*s-a*n)}function Ie(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=r[0],_=r[1],f=r[2],g=r[3],p=r[4],m=r[5],M=r[6],x=r[7],v=r[8];return e[0]=d*i+_*o+f*l,e[1]=d*s+_*n+f*c,e[2]=d*a+_*h+f*u,e[3]=g*i+p*o+m*l,e[4]=g*s+p*n+m*c,e[5]=g*a+p*h+m*u,e[6]=M*i+x*o+v*l,e[7]=M*s+x*n+v*c,e[8]=M*a+x*h+v*u,e}function De(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=r[0],_=r[1];return e[0]=i,e[1]=s,e[2]=a,e[3]=o,e[4]=n,e[5]=h,e[6]=d*i+_*o+l,e[7]=d*s+_*n+c,e[8]=d*a+_*h+u,e}function Le(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=Math.sin(r),_=Math.cos(r);return e[0]=_*i+d*o,e[1]=_*s+d*n,e[2]=_*a+d*h,e[3]=_*o-d*i,e[4]=_*n-d*s,e[5]=_*h-d*a,e[6]=l,e[7]=c,e[8]=u,e}function Be(e,t,r){var i=r[0],s=r[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function Oe(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e}function Ve(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=0,e[3]=-r,e[4]=i,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function Ne(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function Ue(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e}function ze(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=r+r,n=i+i,h=s+s,l=r*o,c=i*o,u=i*n,d=s*o,_=s*n,f=s*h,g=a*o,p=a*n,m=a*h;return e[0]=1-u-f,e[3]=c-m,e[6]=d+p,e[1]=c+m,e[4]=1-l-f,e[7]=_-g,e[2]=d-p,e[5]=_+g,e[8]=1-l-u,e}function He(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],f=t[12],g=t[13],p=t[14],m=t[15],M=r*n-i*o,x=r*h-s*o,v=r*l-a*o,b=i*h-s*n,S=i*l-a*n,P=s*l-a*h,y=c*g-u*f,T=c*p-d*f,w=c*m-_*f,C=u*p-d*g,A=u*m-_*g,E=d*m-_*p,R=M*E-x*A+v*C+b*w-S*T+P*y;return R?(R=1/R,e[0]=(n*E-h*A+l*C)*R,e[1]=(h*w-o*E-l*T)*R,e[2]=(o*A-n*w+l*y)*R,e[3]=(s*A-i*E-a*C)*R,e[4]=(r*E-s*w+a*T)*R,e[5]=(i*w-r*A-a*y)*R,e[6]=(g*P-p*S+m*b)*R,e[7]=(p*v-f*P-m*x)*R,e[8]=(f*S-g*v+m*M)*R,e):null}function Ge(e,t,r){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/r,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e}function Ye(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"}function ke(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8])}function Xe(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e}function qe(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e}function je(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e}function Ze(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e[6]=t[6]+r[6]*i,e[7]=t[7]+r[7]*i,e[8]=t[8]+r[8]*i,e}function We(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]}function $e(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=e[6],l=e[7],c=e[8],u=t[0],d=t[1],f=t[2],g=t[3],p=t[4],m=t[5],M=t[6],x=t[7],v=t[8];return Math.abs(r-u)<=_*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(i-d)<=_*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(s-f)<=_*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(a-g)<=_*Math.max(1,Math.abs(a),Math.abs(g))&&Math.abs(o-p)<=_*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(n-m)<=_*Math.max(1,Math.abs(n),Math.abs(m))&&Math.abs(h-M)<=_*Math.max(1,Math.abs(h),Math.abs(M))&&Math.abs(l-x)<=_*Math.max(1,Math.abs(l),Math.abs(x))&&Math.abs(c-v)<=_*Math.max(1,Math.abs(c),Math.abs(v))}var Ke=Ie,Qe=qe;function Je(){var e=new f(16);return f!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function et(e){var t=new f(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function tt(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function rt(e,t,r,i,s,a,o,n,h,l,c,u,d,_,g,p){var m=new f(16);return m[0]=e,m[1]=t,m[2]=r,m[3]=i,m[4]=s,m[5]=a,m[6]=o,m[7]=n,m[8]=h,m[9]=l,m[10]=c,m[11]=u,m[12]=d,m[13]=_,m[14]=g,m[15]=p,m}function it(e,t,r,i,s,a,o,n,h,l,c,u,d,_,f,g,p){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e[4]=a,e[5]=o,e[6]=n,e[7]=h,e[8]=l,e[9]=c,e[10]=u,e[11]=d,e[12]=_,e[13]=f,e[14]=g,e[15]=p,e}function st(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function at(e,t){if(e===t){var r=t[1],i=t[2],s=t[3],a=t[6],o=t[7],n=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=a,e[11]=t[14],e[12]=s,e[13]=o,e[14]=n}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function ot(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],f=t[12],g=t[13],p=t[14],m=t[15],M=r*n-i*o,x=r*h-s*o,v=r*l-a*o,b=i*h-s*n,S=i*l-a*n,P=s*l-a*h,y=c*g-u*f,T=c*p-d*f,w=c*m-_*f,C=u*p-d*g,A=u*m-_*g,E=d*m-_*p,R=M*E-x*A+v*C+b*w-S*T+P*y;return R?(R=1/R,e[0]=(n*E-h*A+l*C)*R,e[1]=(s*A-i*E-a*C)*R,e[2]=(g*P-p*S+m*b)*R,e[3]=(d*S-u*P-_*b)*R,e[4]=(h*w-o*E-l*T)*R,e[5]=(r*E-s*w+a*T)*R,e[6]=(p*v-f*P-m*x)*R,e[7]=(c*P-d*v+_*x)*R,e[8]=(o*A-n*w+l*y)*R,e[9]=(i*w-r*A-a*y)*R,e[10]=(f*S-g*v+m*M)*R,e[11]=(u*v-c*S-_*M)*R,e[12]=(n*T-o*C-h*y)*R,e[13]=(r*C-i*T+s*y)*R,e[14]=(g*x-f*b-p*M)*R,e[15]=(c*b-u*x+d*M)*R,e):null}function nt(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],f=t[12],g=t[13],p=t[14],m=t[15],M=r*n-i*o,x=r*h-s*o,v=r*l-a*o,b=i*h-s*n,S=i*l-a*n,P=s*l-a*h,y=c*g-u*f,T=c*p-d*f,w=c*m-_*f,C=u*p-d*g,A=u*m-_*g,E=d*m-_*p;return e[0]=n*E-h*A+l*C,e[1]=s*A-i*E-a*C,e[2]=g*P-p*S+m*b,e[3]=d*S-u*P-_*b,e[4]=h*w-o*E-l*T,e[5]=r*E-s*w+a*T,e[6]=p*v-f*P-m*x,e[7]=c*P-d*v+_*x,e[8]=o*A-n*w+l*y,e[9]=i*w-r*A-a*y,e[10]=f*S-g*v+m*M,e[11]=u*v-c*S-_*M,e[12]=n*T-o*C-h*y,e[13]=r*C-i*T+s*y,e[14]=g*x-f*b-p*M,e[15]=c*b-u*x+d*M,e}function ht(e){var t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],n=e[6],h=e[7],l=e[8],c=e[9],u=e[10],d=e[11],_=e[12],f=e[13],g=e[14],p=t*o-r*a,m=t*n-i*a,M=r*n-i*o,x=l*f-c*_,v=l*g-u*_,b=c*g-u*f;return h*(t*b-r*v+i*x)-s*(a*b-o*v+n*x)+e[15]*(l*M-c*m+u*p)-d*(_*M-f*m+g*p)}function lt(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=t[9],_=t[10],f=t[11],g=t[12],p=t[13],m=t[14],M=t[15],x=r[0],v=r[1],b=r[2],S=r[3];return e[0]=x*i+v*n+b*u+S*g,e[1]=x*s+v*h+b*d+S*p,e[2]=x*a+v*l+b*_+S*m,e[3]=x*o+v*c+b*f+S*M,x=r[4],v=r[5],b=r[6],S=r[7],e[4]=x*i+v*n+b*u+S*g,e[5]=x*s+v*h+b*d+S*p,e[6]=x*a+v*l+b*_+S*m,e[7]=x*o+v*c+b*f+S*M,x=r[8],v=r[9],b=r[10],S=r[11],e[8]=x*i+v*n+b*u+S*g,e[9]=x*s+v*h+b*d+S*p,e[10]=x*a+v*l+b*_+S*m,e[11]=x*o+v*c+b*f+S*M,x=r[12],v=r[13],b=r[14],S=r[15],e[12]=x*i+v*n+b*u+S*g,e[13]=x*s+v*h+b*d+S*p,e[14]=x*a+v*l+b*_+S*m,e[15]=x*o+v*c+b*f+S*M,e}function ct(e,t,r){var i,s,a,o,n,h,l,c,u,d,_,f,g=r[0],p=r[1],m=r[2];return t===e?(e[12]=t[0]*g+t[4]*p+t[8]*m+t[12],e[13]=t[1]*g+t[5]*p+t[9]*m+t[13],e[14]=t[2]*g+t[6]*p+t[10]*m+t[14],e[15]=t[3]*g+t[7]*p+t[11]*m+t[15]):(i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=t[9],_=t[10],f=t[11],e[0]=i,e[1]=s,e[2]=a,e[3]=o,e[4]=n,e[5]=h,e[6]=l,e[7]=c,e[8]=u,e[9]=d,e[10]=_,e[11]=f,e[12]=i*g+n*p+u*m+t[12],e[13]=s*g+h*p+d*m+t[13],e[14]=a*g+l*p+_*m+t[14],e[15]=o*g+c*p+f*m+t[15]),e}function ut(e,t,r){var i=r[0],s=r[1],a=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function dt(e,t,r,i){var s,a,o,n,h,l,c,u,d,f,g,p,m,M,x,v,b,S,P,y,T,w,C,A,E=i[0],R=i[1],F=i[2],I=Math.sqrt(E*E+R*R+F*F);return I<_?null:(E*=I=1/I,R*=I,F*=I,s=Math.sin(r),o=1-(a=Math.cos(r)),n=t[0],h=t[1],l=t[2],c=t[3],u=t[4],d=t[5],f=t[6],g=t[7],p=t[8],m=t[9],M=t[10],x=t[11],v=E*E*o+a,b=R*E*o+F*s,S=F*E*o-R*s,P=E*R*o-F*s,y=R*R*o+a,T=F*R*o+E*s,w=E*F*o+R*s,C=R*F*o-E*s,A=F*F*o+a,e[0]=n*v+u*b+p*S,e[1]=h*v+d*b+m*S,e[2]=l*v+f*b+M*S,e[3]=c*v+g*b+x*S,e[4]=n*P+u*y+p*T,e[5]=h*P+d*y+m*T,e[6]=l*P+f*y+M*T,e[7]=c*P+g*y+x*T,e[8]=n*w+u*C+p*A,e[9]=h*w+d*C+m*A,e[10]=l*w+f*C+M*A,e[11]=c*w+g*C+x*A,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function _t(e,t,r){var i=Math.sin(r),s=Math.cos(r),a=t[4],o=t[5],n=t[6],h=t[7],l=t[8],c=t[9],u=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=a*s+l*i,e[5]=o*s+c*i,e[6]=n*s+u*i,e[7]=h*s+d*i,e[8]=l*s-a*i,e[9]=c*s-o*i,e[10]=u*s-n*i,e[11]=d*s-h*i,e}function ft(e,t,r){var i=Math.sin(r),s=Math.cos(r),a=t[0],o=t[1],n=t[2],h=t[3],l=t[8],c=t[9],u=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*s-l*i,e[1]=o*s-c*i,e[2]=n*s-u*i,e[3]=h*s-d*i,e[8]=a*i+l*s,e[9]=o*i+c*s,e[10]=n*i+u*s,e[11]=h*i+d*s,e}function gt(e,t,r){var i=Math.sin(r),s=Math.cos(r),a=t[0],o=t[1],n=t[2],h=t[3],l=t[4],c=t[5],u=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*s+l*i,e[1]=o*s+c*i,e[2]=n*s+u*i,e[3]=h*s+d*i,e[4]=l*s-a*i,e[5]=c*s-o*i,e[6]=u*s-n*i,e[7]=d*s-h*i,e}function pt(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function mt(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Mt(e,t,r){var i,s,a,o=r[0],n=r[1],h=r[2],l=Math.sqrt(o*o+n*n+h*h);return l<_?null:(o*=l=1/l,n*=l,h*=l,i=Math.sin(t),a=1-(s=Math.cos(t)),e[0]=o*o*a+s,e[1]=n*o*a+h*i,e[2]=h*o*a-n*i,e[3]=0,e[4]=o*n*a-h*i,e[5]=n*n*a+s,e[6]=h*n*a+o*i,e[7]=0,e[8]=o*h*a+n*i,e[9]=n*h*a-o*i,e[10]=h*h*a+s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function xt(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function vt(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function bt(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function St(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=i+i,h=s+s,l=a+a,c=i*n,u=i*h,d=i*l,_=s*h,f=s*l,g=a*l,p=o*n,m=o*h,M=o*l;return e[0]=1-(_+g),e[1]=u+M,e[2]=d-m,e[3]=0,e[4]=u-M,e[5]=1-(c+g),e[6]=f+p,e[7]=0,e[8]=d+m,e[9]=f-p,e[10]=1-(c+_),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Pt(e,t){var r=new f(3),i=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=i*i+s*s+a*a+o*o;return u>0?(r[0]=2*(n*o+c*i+h*a-l*s)/u,r[1]=2*(h*o+c*s+l*i-n*a)/u,r[2]=2*(l*o+c*a+n*s-h*i)/u):(r[0]=2*(n*o+c*i+h*a-l*s),r[1]=2*(h*o+c*s+l*i-n*a),r[2]=2*(l*o+c*a+n*s-h*i)),St(e,t,r),e}function yt(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Tt(e,t){var r=t[0],i=t[1],s=t[2],a=t[4],o=t[5],n=t[6],h=t[8],l=t[9],c=t[10];return e[0]=Math.sqrt(r*r+i*i+s*s),e[1]=Math.sqrt(a*a+o*o+n*n),e[2]=Math.sqrt(h*h+l*l+c*c),e}function wt(e,t){var r=new f(3);Tt(r,t);var i=1/r[0],s=1/r[1],a=1/r[2],o=t[0]*i,n=t[1]*s,h=t[2]*a,l=t[4]*i,c=t[5]*s,u=t[6]*a,d=t[8]*i,_=t[9]*s,g=t[10]*a,p=o+c+g,m=0;return p>0?(m=2*Math.sqrt(p+1),e[3]=.25*m,e[0]=(u-_)/m,e[1]=(d-h)/m,e[2]=(n-l)/m):o>c&&o>g?(m=2*Math.sqrt(1+o-c-g),e[3]=(u-_)/m,e[0]=.25*m,e[1]=(n+l)/m,e[2]=(d+h)/m):c>g?(m=2*Math.sqrt(1+c-o-g),e[3]=(d-h)/m,e[0]=(n+l)/m,e[1]=.25*m,e[2]=(u+_)/m):(m=2*Math.sqrt(1+g-o-c),e[3]=(n-l)/m,e[0]=(d+h)/m,e[1]=(u+_)/m,e[2]=.25*m),e}function Ct(e,t,r,i){t[0]=i[12],t[1]=i[13],t[2]=i[14];var s=i[0],a=i[1],o=i[2],n=i[4],h=i[5],l=i[6],c=i[8],u=i[9],d=i[10];r[0]=Math.sqrt(s*s+a*a+o*o),r[1]=Math.sqrt(n*n+h*h+l*l),r[2]=Math.sqrt(c*c+u*u+d*d);var _=1/r[0],f=1/r[1],g=1/r[2],p=s*_,m=a*f,M=o*g,x=n*_,v=h*f,b=l*g,S=c*_,P=u*f,y=d*g,T=p+v+y,w=0;return T>0?(w=2*Math.sqrt(T+1),e[3]=.25*w,e[0]=(b-P)/w,e[1]=(S-M)/w,e[2]=(m-x)/w):p>v&&p>y?(w=2*Math.sqrt(1+p-v-y),e[3]=(b-P)/w,e[0]=.25*w,e[1]=(m+x)/w,e[2]=(S+M)/w):v>y?(w=2*Math.sqrt(1+v-p-y),e[3]=(S-M)/w,e[0]=(m+x)/w,e[1]=.25*w,e[2]=(b+P)/w):(w=2*Math.sqrt(1+y-p-v),e[3]=(m-x)/w,e[0]=(S+M)/w,e[1]=(b+P)/w,e[2]=.25*w),e}function At(e,t,r,i){var s=t[0],a=t[1],o=t[2],n=t[3],h=s+s,l=a+a,c=o+o,u=s*h,d=s*l,_=s*c,f=a*l,g=a*c,p=o*c,m=n*h,M=n*l,x=n*c,v=i[0],b=i[1],S=i[2];return e[0]=(1-(f+p))*v,e[1]=(d+x)*v,e[2]=(_-M)*v,e[3]=0,e[4]=(d-x)*b,e[5]=(1-(u+p))*b,e[6]=(g+m)*b,e[7]=0,e[8]=(_+M)*S,e[9]=(g-m)*S,e[10]=(1-(u+f))*S,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Et(e,t,r,i,s){var a=t[0],o=t[1],n=t[2],h=t[3],l=a+a,c=o+o,u=n+n,d=a*l,_=a*c,f=a*u,g=o*c,p=o*u,m=n*u,M=h*l,x=h*c,v=h*u,b=i[0],S=i[1],P=i[2],y=s[0],T=s[1],w=s[2],C=(1-(g+m))*b,A=(_+v)*b,E=(f-x)*b,R=(_-v)*S,F=(1-(d+m))*S,I=(p+M)*S,D=(f+x)*P,L=(p-M)*P,B=(1-(d+g))*P;return e[0]=C,e[1]=A,e[2]=E,e[3]=0,e[4]=R,e[5]=F,e[6]=I,e[7]=0,e[8]=D,e[9]=L,e[10]=B,e[11]=0,e[12]=r[0]+y-(C*y+R*T+D*w),e[13]=r[1]+T-(A*y+F*T+L*w),e[14]=r[2]+w-(E*y+I*T+B*w),e[15]=1,e}function Rt(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=r+r,n=i+i,h=s+s,l=r*o,c=i*o,u=i*n,d=s*o,_=s*n,f=s*h,g=a*o,p=a*n,m=a*h;return e[0]=1-u-f,e[1]=c+m,e[2]=d-p,e[3]=0,e[4]=c-m,e[5]=1-l-f,e[6]=_+g,e[7]=0,e[8]=d+p,e[9]=_-g,e[10]=1-l-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ft(e,t,r,i,s,a,o){var n=1/(r-t),h=1/(s-i),l=1/(a-o);return e[0]=2*a*n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*h,e[6]=0,e[7]=0,e[8]=(r+t)*n,e[9]=(s+i)*h,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e}function It(e,t,r,i,s){var a=1/Math.tan(t/2);if(e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=s&&s!==1/0){var o=1/(i-s);e[10]=(s+i)*o,e[14]=2*s*i*o}else e[10]=-1,e[14]=-2*i;return e}var Dt=It;function Lt(e,t,r,i,s){var a=1/Math.tan(t/2);if(e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=s&&s!==1/0){var o=1/(i-s);e[10]=s*o,e[14]=s*i*o}else e[10]=-1,e[14]=-i;return e}function Bt(e,t,r,i){var s=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),n=Math.tan(t.rightDegrees*Math.PI/180),h=2/(o+n),l=2/(s+a);return e[0]=h,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-n)*h*.5,e[9]=(s-a)*l*.5,e[10]=i/(r-i),e[11]=-1,e[12]=0,e[13]=0,e[14]=i*r/(r-i),e[15]=0,e}function Ot(e,t,r,i,s,a,o){var n=1/(t-r),h=1/(i-s),l=1/(a-o);return e[0]=-2*n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*n,e[13]=(s+i)*h,e[14]=(o+a)*l,e[15]=1,e}var Vt=Ot;function Nt(e,t,r,i,s,a,o){var n=1/(t-r),h=1/(i-s),l=1/(a-o);return e[0]=-2*n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+r)*n,e[13]=(s+i)*h,e[14]=a*l,e[15]=1,e}function Ut(e,t,r,i){var s,a,o,n,h,l,c,u,d,f,g=t[0],p=t[1],m=t[2],M=i[0],x=i[1],v=i[2],b=r[0],S=r[1],P=r[2];return Math.abs(g-b)<_&&Math.abs(p-S)<_&&Math.abs(m-P)<_?st(e):(c=g-b,u=p-S,d=m-P,s=x*(d*=f=1/Math.sqrt(c*c+u*u+d*d))-v*(u*=f),a=v*(c*=f)-M*d,o=M*u-x*c,(f=Math.sqrt(s*s+a*a+o*o))?(s*=f=1/f,a*=f,o*=f):(s=0,a=0,o=0),n=u*o-d*a,h=d*s-c*o,l=c*a-u*s,(f=Math.sqrt(n*n+h*h+l*l))?(n*=f=1/f,h*=f,l*=f):(n=0,h=0,l=0),e[0]=s,e[1]=n,e[2]=c,e[3]=0,e[4]=a,e[5]=h,e[6]=u,e[7]=0,e[8]=o,e[9]=l,e[10]=d,e[11]=0,e[12]=-(s*g+a*p+o*m),e[13]=-(n*g+h*p+l*m),e[14]=-(c*g+u*p+d*m),e[15]=1,e)}function zt(e,t,r,i){var s=t[0],a=t[1],o=t[2],n=i[0],h=i[1],l=i[2],c=s-r[0],u=a-r[1],d=o-r[2],_=c*c+u*u+d*d;_>0&&(c*=_=1/Math.sqrt(_),u*=_,d*=_);var f=h*d-l*u,g=l*c-n*d,p=n*u-h*c;return(_=f*f+g*g+p*p)>0&&(f*=_=1/Math.sqrt(_),g*=_,p*=_),e[0]=f,e[1]=g,e[2]=p,e[3]=0,e[4]=u*p-d*g,e[5]=d*f-c*p,e[6]=c*g-u*f,e[7]=0,e[8]=c,e[9]=u,e[10]=d,e[11]=0,e[12]=s,e[13]=a,e[14]=o,e[15]=1,e}function Ht(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"}function Gt(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function Yt(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function kt(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function Xt(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}function qt(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e[6]=t[6]+r[6]*i,e[7]=t[7]+r[7]*i,e[8]=t[8]+r[8]*i,e[9]=t[9]+r[9]*i,e[10]=t[10]+r[10]*i,e[11]=t[11]+r[11]*i,e[12]=t[12]+r[12]*i,e[13]=t[13]+r[13]*i,e[14]=t[14]+r[14]*i,e[15]=t[15]+r[15]*i,e}function jt(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function Zt(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=e[6],l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],g=e[12],p=e[13],m=e[14],M=e[15],x=t[0],v=t[1],b=t[2],S=t[3],P=t[4],y=t[5],T=t[6],w=t[7],C=t[8],A=t[9],E=t[10],R=t[11],F=t[12],I=t[13],D=t[14],L=t[15];return Math.abs(r-x)<=_*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(i-v)<=_*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(s-b)<=_*Math.max(1,Math.abs(s),Math.abs(b))&&Math.abs(a-S)<=_*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(o-P)<=_*Math.max(1,Math.abs(o),Math.abs(P))&&Math.abs(n-y)<=_*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(h-T)<=_*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(l-w)<=_*Math.max(1,Math.abs(l),Math.abs(w))&&Math.abs(c-C)<=_*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(u-A)<=_*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(d-E)<=_*Math.max(1,Math.abs(d),Math.abs(E))&&Math.abs(f-R)<=_*Math.max(1,Math.abs(f),Math.abs(R))&&Math.abs(g-F)<=_*Math.max(1,Math.abs(g),Math.abs(F))&&Math.abs(p-I)<=_*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(m-D)<=_*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(M-L)<=_*Math.max(1,Math.abs(M),Math.abs(L))}var Wt=lt,$t=kt;function Kt(){var e=new f(3);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Qt(e){var t=new f(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Jt(e){var t=e[0],r=e[1],i=e[2];return Math.sqrt(t*t+r*r+i*i)}function er(e,t,r){var i=new f(3);return i[0]=e,i[1]=t,i[2]=r,i}function tr(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function rr(e,t,r,i){return e[0]=t,e[1]=r,e[2]=i,e}function ir(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function sr(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function ar(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function or(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function nr(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function hr(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function lr(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function cr(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function ur(e,t){return e[0]=m(t[0]),e[1]=m(t[1]),e[2]=m(t[2]),e}function dr(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function _r(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e}function fr(e,t){var r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return Math.sqrt(r*r+i*i+s*s)}function gr(e,t){var r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return r*r+i*i+s*s}function pr(e){var t=e[0],r=e[1],i=e[2];return t*t+r*r+i*i}function mr(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Mr(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function xr(e,t){var r=t[0],i=t[1],s=t[2],a=r*r+i*i+s*s;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function vr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function br(e,t,r){var i=t[0],s=t[1],a=t[2],o=r[0],n=r[1],h=r[2];return e[0]=s*h-a*n,e[1]=a*o-i*h,e[2]=i*n-s*o,e}function Sr(e,t,r,i){var s=t[0],a=t[1],o=t[2];return e[0]=s+i*(r[0]-s),e[1]=a+i*(r[1]-a),e[2]=o+i*(r[2]-o),e}function Pr(e,t,r,i){var s=Math.acos(Math.min(Math.max(vr(t,r),-1),1)),a=Math.sin(s),o=Math.sin((1-i)*s)/a,n=Math.sin(i*s)/a;return e[0]=o*t[0]+n*r[0],e[1]=o*t[1]+n*r[1],e[2]=o*t[2]+n*r[2],e}function yr(e,t,r,i,s,a){var o=a*a,n=o*(2*a-3)+1,h=o*(a-2)+a,l=o*(a-1),c=o*(3-2*a);return e[0]=t[0]*n+r[0]*h+i[0]*l+s[0]*c,e[1]=t[1]*n+r[1]*h+i[1]*l+s[1]*c,e[2]=t[2]*n+r[2]*h+i[2]*l+s[2]*c,e}function Tr(e,t,r,i,s,a){var o=1-a,n=o*o,h=a*a,l=n*o,c=3*a*n,u=3*h*o,d=h*a;return e[0]=t[0]*l+r[0]*c+i[0]*u+s[0]*d,e[1]=t[1]*l+r[1]*c+i[1]*u+s[1]*d,e[2]=t[2]*l+r[2]*c+i[2]*u+s[2]*d,e}function wr(e,t){t=void 0===t?1:t;var r=2*g()*Math.PI,i=2*g()-1,s=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(r)*s,e[1]=Math.sin(r)*s,e[2]=i*t,e}function Cr(e,t,r){var i=t[0],s=t[1],a=t[2],o=r[3]*i+r[7]*s+r[11]*a+r[15];return o=o||1,e[0]=(r[0]*i+r[4]*s+r[8]*a+r[12])/o,e[1]=(r[1]*i+r[5]*s+r[9]*a+r[13])/o,e[2]=(r[2]*i+r[6]*s+r[10]*a+r[14])/o,e}function Ar(e,t,r){var i=t[0],s=t[1],a=t[2];return e[0]=i*r[0]+s*r[3]+a*r[6],e[1]=i*r[1]+s*r[4]+a*r[7],e[2]=i*r[2]+s*r[5]+a*r[8],e}function Er(e,t,r){var i=r[0],s=r[1],a=r[2],o=r[3],n=t[0],h=t[1],l=t[2],c=s*l-a*h,u=a*n-i*l,d=i*h-s*n;return c+=c,u+=u,d+=d,e[0]=n+o*c+s*d-a*u,e[1]=h+o*u+a*c-i*d,e[2]=l+o*d+i*u-s*c,e}function Rr(e,t,r,i){var s=[],a=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],a[0]=s[0],a[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),a[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e}function Fr(e,t,r,i){var s=[],a=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],a[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),a[1]=s[1],a[2]=s[2]*Math.cos(i)-s[0]*Math.sin(i),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e}function Ir(e,t,r,i){var s=[],a=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],a[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),a[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),a[2]=s[2],e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e}function Dr(e,t){var r=e[0],i=e[1],s=e[2],a=t[0],o=t[1],n=t[2],h=Math.sqrt((r*r+i*i+s*s)*(a*a+o*o+n*n)),l=h&&vr(e,t)/h;return Math.acos(Math.min(Math.max(l,-1),1))}function Lr(e){return e[0]=0,e[1]=0,e[2]=0,e}function Br(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"}function Or(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Vr(e,t){var r=e[0],i=e[1],s=e[2],a=t[0],o=t[1],n=t[2];return Math.abs(r-a)<=_*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-o)<=_*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-n)<=_*Math.max(1,Math.abs(s),Math.abs(n))}var Nr,Ur=sr,zr=ar,Hr=or,Gr=fr,Yr=gr,kr=Jt,Xr=pr,qr=(Nr=Kt(),function(e,t,r,i,s,a){var o,n;for(t||(t=3),r||(r=0),n=i?Math.min(i*t+r,e.length):e.length,o=r;o<n;o+=t)Nr[0]=e[o],Nr[1]=e[o+1],Nr[2]=e[o+2],s(Nr,Nr,a),e[o]=Nr[0],e[o+1]=Nr[1],e[o+2]=Nr[2];return e});function jr(){var e=new f(4);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Zr(e){var t=new f(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function Wr(e,t,r,i){var s=new f(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=i,s}function $r(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Kr(e,t,r,i,s){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e}function Qr(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function Jr(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function ei(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function ti(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e}function ri(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e}function ii(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e}function si(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e}function ai(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e}function oi(e,t){return e[0]=m(t[0]),e[1]=m(t[1]),e[2]=m(t[2]),e[3]=m(t[3]),e}function ni(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function hi(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e}function li(e,t){var r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2],a=t[3]-e[3];return Math.sqrt(r*r+i*i+s*s+a*a)}function ci(e,t){var r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2],a=t[3]-e[3];return r*r+i*i+s*s+a*a}function ui(e){var t=e[0],r=e[1],i=e[2],s=e[3];return Math.sqrt(t*t+r*r+i*i+s*s)}function di(e){var t=e[0],r=e[1],i=e[2],s=e[3];return t*t+r*r+i*i+s*s}function _i(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e}function fi(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e}function gi(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=r*r+i*i+s*s+a*a;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=i*o,e[2]=s*o,e[3]=a*o,e}function pi(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function mi(e,t,r,i){var s=r[0]*i[1]-r[1]*i[0],a=r[0]*i[2]-r[2]*i[0],o=r[0]*i[3]-r[3]*i[0],n=r[1]*i[2]-r[2]*i[1],h=r[1]*i[3]-r[3]*i[1],l=r[2]*i[3]-r[3]*i[2],c=t[0],u=t[1],d=t[2],_=t[3];return e[0]=u*l-d*h+_*n,e[1]=-c*l+d*o-_*a,e[2]=c*h-u*o+_*s,e[3]=-c*n+u*a-d*s,e}function Mi(e,t,r,i){var s=t[0],a=t[1],o=t[2],n=t[3];return e[0]=s+i*(r[0]-s),e[1]=a+i*(r[1]-a),e[2]=o+i*(r[2]-o),e[3]=n+i*(r[3]-n),e}function xi(e,t){var r,i,s,a,o,n,h;t=void 0===t?1:t,o=(r=2*(h=g())-1)*r+(i=(4*g()-2)*Math.sqrt(h*-h+h))*i,n=(s=2*(h=g())-1)*s+(a=(4*g()-2)*Math.sqrt(h*-h+h))*a;var l=Math.sqrt((1-o)/n);return e[0]=t*r,e[1]=t*i,e[2]=t*s*l,e[3]=t*a*l,e}function vi(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3];return e[0]=r[0]*i+r[4]*s+r[8]*a+r[12]*o,e[1]=r[1]*i+r[5]*s+r[9]*a+r[13]*o,e[2]=r[2]*i+r[6]*s+r[10]*a+r[14]*o,e[3]=r[3]*i+r[7]*s+r[11]*a+r[15]*o,e}function bi(e,t,r){var i=r[0],s=r[1],a=r[2],o=r[3],n=t[0],h=t[1],l=t[2],c=s*l-a*h,u=a*n-i*l,d=i*h-s*n;return c+=c,u+=u,d+=d,e[0]=n+o*c+s*d-a*u,e[1]=h+o*u+a*c-i*d,e[2]=l+o*d+i*u-s*c,e[3]=t[3],e}function Si(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function Pi(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function yi(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function Ti(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=t[0],n=t[1],h=t[2],l=t[3];return Math.abs(r-o)<=_*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-n)<=_*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(s-h)<=_*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(a-l)<=_*Math.max(1,Math.abs(a),Math.abs(l))}var wi=Jr,Ci=ei,Ai=ti,Ei=li,Ri=ci,Fi=ui,Ii=di,Di=function(){var e=jr();return function(t,r,i,s,a,o){var n,h;for(r||(r=4),i||(i=0),h=s?Math.min(s*r+i,t.length):t.length,n=i;n<h;n+=r)e[0]=t[n],e[1]=t[n+1],e[2]=t[n+2],e[3]=t[n+3],a(e,e,o),t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3];return t}}();function Li(){var e=new f(4);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Bi(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Oi(e,t,r){r*=.5;var i=Math.sin(r);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(r),e}function Vi(e,t){var r=2*Math.acos(t[3]),i=Math.sin(r/2);return i>_?(e[0]=t[0]/i,e[1]=t[1]/i,e[2]=t[2]/i):(e[0]=1,e[1]=0,e[2]=0),r}function Ni(e,t){var r=ns(e,t);return Math.acos(2*r*r-1)}function Ui(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=r[0],h=r[1],l=r[2],c=r[3];return e[0]=i*c+o*n+s*l-a*h,e[1]=s*c+o*h+a*n-i*l,e[2]=a*c+o*l+i*h-s*n,e[3]=o*c-i*n-s*h-a*l,e}function zi(e,t,r){r*=.5;var i=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(r),h=Math.cos(r);return e[0]=i*h+o*n,e[1]=s*h+a*n,e[2]=a*h-s*n,e[3]=o*h-i*n,e}function Hi(e,t,r){r*=.5;var i=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(r),h=Math.cos(r);return e[0]=i*h-a*n,e[1]=s*h+o*n,e[2]=a*h+i*n,e[3]=o*h-s*n,e}function Gi(e,t,r){r*=.5;var i=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(r),h=Math.cos(r);return e[0]=i*h+s*n,e[1]=s*h-i*n,e[2]=a*h+o*n,e[3]=o*h-a*n,e}function Yi(e,t){var r=t[0],i=t[1],s=t[2];return e[0]=r,e[1]=i,e[2]=s,e[3]=Math.sqrt(Math.abs(1-r*r-i*i-s*s)),e}function ki(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=Math.sqrt(r*r+i*i+s*s),n=Math.exp(a),h=o>0?n*Math.sin(o)/o:0;return e[0]=r*h,e[1]=i*h,e[2]=s*h,e[3]=n*Math.cos(o),e}function Xi(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=Math.sqrt(r*r+i*i+s*s),n=o>0?Math.atan2(o,a)/o:0;return e[0]=r*n,e[1]=i*n,e[2]=s*n,e[3]=.5*Math.log(r*r+i*i+s*s+a*a),e}function qi(e,t,r){return Xi(e,t),os(e,e,r),ki(e,e),e}function ji(e,t,r,i){var s,a,o,n,h,l=t[0],c=t[1],u=t[2],d=t[3],f=r[0],g=r[1],p=r[2],m=r[3];return(a=l*f+c*g+u*p+d*m)<0&&(a=-a,f=-f,g=-g,p=-p,m=-m),1-a>_?(s=Math.acos(a),o=Math.sin(s),n=Math.sin((1-i)*s)/o,h=Math.sin(i*s)/o):(n=1-i,h=i),e[0]=n*l+h*f,e[1]=n*c+h*g,e[2]=n*u+h*p,e[3]=n*d+h*m,e}function Zi(e){var t=g(),r=g(),i=g(),s=Math.sqrt(1-t),a=Math.sqrt(t);return e[0]=s*Math.sin(2*Math.PI*r),e[1]=s*Math.cos(2*Math.PI*r),e[2]=a*Math.sin(2*Math.PI*i),e[3]=a*Math.cos(2*Math.PI*i),e}function Wi(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=r*r+i*i+s*s+a*a,n=o?1/o:0;return e[0]=-r*n,e[1]=-i*n,e[2]=-s*n,e[3]=a*n,e}function $i(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Ki(e,t){var r,i=t[0]+t[4]+t[8];if(i>0)r=Math.sqrt(i+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var s=0;t[4]>t[0]&&(s=1),t[8]>t[3*s+s]&&(s=2);var a=(s+1)%3,o=(s+2)%3;r=Math.sqrt(t[3*s+s]-t[3*a+a]-t[3*o+o]+1),e[s]=.5*r,r=.5/r,e[3]=(t[3*a+o]-t[3*o+a])*r,e[a]=(t[3*a+s]+t[3*s+a])*r,e[o]=(t[3*o+s]+t[3*s+o])*r}return e}function Qi(e,t,r,i){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:p,a=Math.PI/360;t*=a,i*=a,r*=a;var o=Math.sin(t),n=Math.cos(t),h=Math.sin(r),l=Math.cos(r),c=Math.sin(i),u=Math.cos(i);switch(s){case"xyz":e[0]=o*l*u+n*h*c,e[1]=n*h*u-o*l*c,e[2]=n*l*c+o*h*u,e[3]=n*l*u-o*h*c;break;case"xzy":e[0]=o*l*u-n*h*c,e[1]=n*h*u-o*l*c,e[2]=n*l*c+o*h*u,e[3]=n*l*u+o*h*c;break;case"yxz":e[0]=o*l*u+n*h*c,e[1]=n*h*u-o*l*c,e[2]=n*l*c-o*h*u,e[3]=n*l*u+o*h*c;break;case"yzx":e[0]=o*l*u+n*h*c,e[1]=n*h*u+o*l*c,e[2]=n*l*c-o*h*u,e[3]=n*l*u-o*h*c;break;case"zxy":e[0]=o*l*u-n*h*c,e[1]=n*h*u+o*l*c,e[2]=n*l*c+o*h*u,e[3]=n*l*u-o*h*c;break;case"zyx":e[0]=o*l*u-n*h*c,e[1]=n*h*u+o*l*c,e[2]=n*l*c-o*h*u,e[3]=n*l*u+o*h*c;break;default:throw new Error("Unknown angle order "+s)}return e}function Ji(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}var es=Zr,ts=Wr,rs=$r,is=Kr,ss=Qr,as=Ui,os=ni,ns=pi,hs=Mi,ls=ui,cs=ls,us=di,ds=us,_s=gi,fs=yi;function gs(e,t){return Math.abs(pi(e,t))>=1-_}var ps,ms,Ms,xs,vs,bs,Ss=(ps=Kt(),ms=er(1,0,0),Ms=er(0,1,0),function(e,t,r){var i=vr(t,r);return i<-.999999?(br(ps,ms,t),kr(ps)<1e-6&&br(ps,Ms,t),xr(ps,ps),Oi(e,ps,Math.PI),e):i>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(br(ps,t,r),e[0]=ps[0],e[1]=ps[1],e[2]=ps[2],e[3]=1+i,_s(e,e))}),Ps=(xs=Li(),vs=Li(),function(e,t,r,i,s,a){return ji(xs,t,s,a),ji(vs,r,i,a),ji(e,xs,vs,2*a*(1-a)),e}),ys=(bs=be(),function(e,t,r,i){return bs[0]=r[0],bs[3]=r[1],bs[6]=r[2],bs[1]=i[0],bs[4]=i[1],bs[7]=i[2],bs[2]=-t[0],bs[5]=-t[1],bs[8]=-t[2],_s(e,Ki(e,bs))});function Ts(){var e=new f(8);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e}function ws(e){var t=new f(8);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t}function Cs(e,t,r,i,s,a,o,n){var h=new f(8);return h[0]=e,h[1]=t,h[2]=r,h[3]=i,h[4]=s,h[5]=a,h[6]=o,h[7]=n,h}function As(e,t,r,i,s,a,o){var n=new f(8);n[0]=e,n[1]=t,n[2]=r,n[3]=i;var h=.5*s,l=.5*a,c=.5*o;return n[4]=h*i+l*r-c*t,n[5]=l*i+c*e-h*r,n[6]=c*i+h*t-l*e,n[7]=-h*e-l*t-c*r,n}function Es(e,t,r){var i=.5*r[0],s=.5*r[1],a=.5*r[2],o=t[0],n=t[1],h=t[2],l=t[3];return e[0]=o,e[1]=n,e[2]=h,e[3]=l,e[4]=i*l+s*h-a*n,e[5]=s*l+a*o-i*h,e[6]=a*l+i*n-s*o,e[7]=-i*o-s*n-a*h,e}function Rs(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e}function Fs(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e}function Is(e,t){var r=Li();wt(r,t);var i=new f(3);return yt(i,t),Es(e,r,i),e}function Ds(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function Ls(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e}function Bs(e,t,r,i,s,a,o,n,h){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e[4]=a,e[5]=o,e[6]=n,e[7]=h,e}var Os=rs;function Vs(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e}var Ns=rs;function Us(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e}function zs(e,t){var r=t[4],i=t[5],s=t[6],a=t[7],o=-t[0],n=-t[1],h=-t[2],l=t[3];return e[0]=2*(r*l+a*o+i*h-s*n),e[1]=2*(i*l+a*n+s*o-r*h),e[2]=2*(s*l+a*h+r*n-i*o),e}function Hs(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=.5*r[0],h=.5*r[1],l=.5*r[2],c=t[4],u=t[5],d=t[6],_=t[7];return e[0]=i,e[1]=s,e[2]=a,e[3]=o,e[4]=o*n+s*l-a*h+c,e[5]=o*h+a*n-i*l+u,e[6]=o*l+i*h-s*n+d,e[7]=-i*n-s*h-a*l+_,e}function Gs(e,t,r){var i=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=n*o+c*i+h*a-l*s,d=h*o+c*s+l*i-n*a,_=l*o+c*a+n*s-h*i,f=c*o-n*i-h*s-l*a;return zi(e,t,r),i=e[0],s=e[1],a=e[2],o=e[3],e[4]=u*o+f*i+d*a-_*s,e[5]=d*o+f*s+_*i-u*a,e[6]=_*o+f*a+u*s-d*i,e[7]=f*o-u*i-d*s-_*a,e}function Ys(e,t,r){var i=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=n*o+c*i+h*a-l*s,d=h*o+c*s+l*i-n*a,_=l*o+c*a+n*s-h*i,f=c*o-n*i-h*s-l*a;return Hi(e,t,r),i=e[0],s=e[1],a=e[2],o=e[3],e[4]=u*o+f*i+d*a-_*s,e[5]=d*o+f*s+_*i-u*a,e[6]=_*o+f*a+u*s-d*i,e[7]=f*o-u*i-d*s-_*a,e}function ks(e,t,r){var i=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=n*o+c*i+h*a-l*s,d=h*o+c*s+l*i-n*a,_=l*o+c*a+n*s-h*i,f=c*o-n*i-h*s-l*a;return Gi(e,t,r),i=e[0],s=e[1],a=e[2],o=e[3],e[4]=u*o+f*i+d*a-_*s,e[5]=d*o+f*s+_*i-u*a,e[6]=_*o+f*a+u*s-d*i,e[7]=f*o-u*i-d*s-_*a,e}function Xs(e,t,r){var i=r[0],s=r[1],a=r[2],o=r[3],n=t[0],h=t[1],l=t[2],c=t[3];return e[0]=n*o+c*i+h*a-l*s,e[1]=h*o+c*s+l*i-n*a,e[2]=l*o+c*a+n*s-h*i,e[3]=c*o-n*i-h*s-l*a,n=t[4],h=t[5],l=t[6],c=t[7],e[4]=n*o+c*i+h*a-l*s,e[5]=h*o+c*s+l*i-n*a,e[6]=l*o+c*a+n*s-h*i,e[7]=c*o-n*i-h*s-l*a,e}function qs(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=r[0],h=r[1],l=r[2],c=r[3];return e[0]=i*c+o*n+s*l-a*h,e[1]=s*c+o*h+a*n-i*l,e[2]=a*c+o*l+i*h-s*n,e[3]=o*c-i*n-s*h-a*l,n=r[4],h=r[5],l=r[6],c=r[7],e[4]=i*c+o*n+s*l-a*h,e[5]=s*c+o*h+a*n-i*l,e[6]=a*c+o*l+i*h-s*n,e[7]=o*c-i*n-s*h-a*l,e}function js(e,t,r,i){if(Math.abs(i)<_)return Ds(e,t);var s=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);i*=.5;var a=Math.sin(i),o=a*r[0]/s,n=a*r[1]/s,h=a*r[2]/s,l=Math.cos(i),c=t[0],u=t[1],d=t[2],f=t[3];e[0]=c*l+f*o+u*h-d*n,e[1]=u*l+f*n+d*o-c*h,e[2]=d*l+f*h+c*n-u*o,e[3]=f*l-c*o-u*n-d*h;var g=t[4],p=t[5],m=t[6],M=t[7];return e[4]=g*l+M*o+p*h-m*n,e[5]=p*l+M*n+m*o-g*h,e[6]=m*l+M*h+g*n-p*o,e[7]=M*l-g*o-p*n-m*h,e}function Zs(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e}function Ws(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=r[4],h=r[5],l=r[6],c=r[7],u=t[4],d=t[5],_=t[6],f=t[7],g=r[0],p=r[1],m=r[2],M=r[3];return e[0]=i*M+o*g+s*m-a*p,e[1]=s*M+o*p+a*g-i*m,e[2]=a*M+o*m+i*p-s*g,e[3]=o*M-i*g-s*p-a*m,e[4]=i*c+o*n+s*l-a*h+u*M+f*g+d*m-_*p,e[5]=s*c+o*h+a*n-i*l+d*M+f*p+_*g-u*m,e[6]=a*c+o*l+i*h-s*n+_*M+f*m+u*p-d*g,e[7]=o*c-i*n-s*h-a*l+f*M-u*g-d*p-_*m,e}var $s=Ws;function Ks(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e}var Qs=ns;function Js(e,t,r,i){var s=1-i;return Qs(t,r)<0&&(i=-i),e[0]=t[0]*s+r[0]*i,e[1]=t[1]*s+r[1]*i,e[2]=t[2]*s+r[2]*i,e[3]=t[3]*s+r[3]*i,e[4]=t[4]*s+r[4]*i,e[5]=t[5]*s+r[5]*i,e[6]=t[6]*s+r[6]*i,e[7]=t[7]*s+r[7]*i,e}function ea(e,t){var r=sa(t);return e[0]=-t[0]/r,e[1]=-t[1]/r,e[2]=-t[2]/r,e[3]=t[3]/r,e[4]=-t[4]/r,e[5]=-t[5]/r,e[6]=-t[6]/r,e[7]=t[7]/r,e}function ta(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e[4]=-t[4],e[5]=-t[5],e[6]=-t[6],e[7]=t[7],e}var ra=ls,ia=ra,sa=us,aa=sa;function oa(e,t){var r=sa(t);if(r>0){r=Math.sqrt(r);var i=t[0]/r,s=t[1]/r,a=t[2]/r,o=t[3]/r,n=t[4],h=t[5],l=t[6],c=t[7],u=i*n+s*h+a*l+o*c;e[0]=i,e[1]=s,e[2]=a,e[3]=o,e[4]=(n-i*u)/r,e[5]=(h-s*u)/r,e[6]=(l-a*u)/r,e[7]=(c-o*u)/r}return e}function na(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"}function ha(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]}function la(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=e[6],l=e[7],c=t[0],u=t[1],d=t[2],f=t[3],g=t[4],p=t[5],m=t[6],M=t[7];return Math.abs(r-c)<=_*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(i-u)<=_*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(s-d)<=_*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(a-f)<=_*Math.max(1,Math.abs(a),Math.abs(f))&&Math.abs(o-g)<=_*Math.max(1,Math.abs(o),Math.abs(g))&&Math.abs(n-p)<=_*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(h-m)<=_*Math.max(1,Math.abs(h),Math.abs(m))&&Math.abs(l-M)<=_*Math.max(1,Math.abs(l),Math.abs(M))}function ca(){var e=new f(2);return f!=Float32Array&&(e[0]=0,e[1]=0),e}function ua(e){var t=new f(2);return t[0]=e[0],t[1]=e[1],t}function da(e,t){var r=new f(2);return r[0]=e,r[1]=t,r}function _a(e,t){return e[0]=t[0],e[1]=t[1],e}function fa(e,t,r){return e[0]=t,e[1]=r,e}function ga(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function pa(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function ma(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function Ma(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function xa(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e}function va(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e}function ba(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e}function Sa(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e}function Pa(e,t){return e[0]=m(t[0]),e[1]=m(t[1]),e}function ya(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function Ta(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e}function wa(e,t){var r=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(r*r+i*i)}function Ca(e,t){var r=t[0]-e[0],i=t[1]-e[1];return r*r+i*i}function Aa(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function Ea(e){var t=e[0],r=e[1];return t*t+r*r}function Ra(e,t){return e[0]=-t[0],e[1]=-t[1],e}function Fa(e,t){return e[0]=1/t[0],e[1]=1/t[1],e}function Ia(e,t){var r=t[0],i=t[1],s=r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e}function Da(e,t){return e[0]*t[0]+e[1]*t[1]}function La(e,t,r){var i=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=i,e}function Ba(e,t,r,i){var s=t[0],a=t[1];return e[0]=s+i*(r[0]-s),e[1]=a+i*(r[1]-a),e}function Oa(e,t){t=void 0===t?1:t;var r=2*g()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e}function Va(e,t,r){var i=t[0],s=t[1];return e[0]=r[0]*i+r[2]*s,e[1]=r[1]*i+r[3]*s,e}function Na(e,t,r){var i=t[0],s=t[1];return e[0]=r[0]*i+r[2]*s+r[4],e[1]=r[1]*i+r[3]*s+r[5],e}function Ua(e,t,r){var i=t[0],s=t[1];return e[0]=r[0]*i+r[3]*s+r[6],e[1]=r[1]*i+r[4]*s+r[7],e}function za(e,t,r){var i=t[0],s=t[1];return e[0]=r[0]*i+r[4]*s+r[12],e[1]=r[1]*i+r[5]*s+r[13],e}function Ha(e,t,r,i){var s=t[0]-r[0],a=t[1]-r[1],o=Math.sin(i),n=Math.cos(i);return e[0]=s*n-a*o+r[0],e[1]=s*o+a*n+r[1],e}function Ga(e,t){var r=e[0],i=e[1],s=t[0],a=t[1];return Math.abs(Math.atan2(i*s-r*a,r*s+i*a))}function Ya(e,t){var r=e[0],i=e[1],s=t[0],a=t[1];return Math.atan2(r*a-i*s,r*s+i*a)}function ka(e){return e[0]=0,e[1]=0,e}function Xa(e){return"vec2("+e[0]+", "+e[1]+")"}function qa(e,t){return e[0]===t[0]&&e[1]===t[1]}function ja(e,t){var r=e[0],i=e[1],s=t[0],a=t[1];return Math.abs(r-s)<=_*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-a)<=_*Math.max(1,Math.abs(i),Math.abs(a))}var Za=Aa,Wa=pa,$a=ma,Ka=Ma,Qa=wa,Ja=Ca,eo=Ea,to=function(){var e=ca();return function(t,r,i,s,a,o){var n,h;for(r||(r=2),i||(i=0),h=s?Math.min(s*r+i,t.length):t.length,n=i;n<h;n+=r)e[0]=t[n],e[1]=t[n+1],a(e,e,o),t[n]=e[0],t[n+1]=e[1];return t}}()},2056:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VisibleTilesManager=void 0;const s=i(r(4382)),a=r(1138),o=i(r(4639)),n=r(4006),h=r(1961),l=r(2919);t.VisibleTilesManager=class{_visibleTilesByOrder;_ancestorsMap;initialised;_galVisibleTilesByOrder;_galAncestorsMap;_galacticMatrixInverted;_galacticMatrix;insideSphere=l.bootSetup.insideSphere;_tileBuffer;_healpixGrid;_webgl;constructor(e,t,r){this._webgl=e,this._healpixGrid=r,this._visibleTilesByOrder={pixels:[],order:0},this._ancestorsMap=new Map,this.initialised=!1,this._galVisibleTilesByOrder={pixels:[],order:0},this._galAncestorsMap=new Map,this._galacticMatrixInverted=h.mat4.create(),this._galacticMatrix=h.mat4.create(),h.mat4.set(this._galacticMatrixInverted,-.054876,-.873437,-.483835,0,.494109,-.44483,.746982,-0,-.867666,-.198076,.455984,0,0,0,0,1),h.mat4.invert(this._galacticMatrix,this._galacticMatrixInverted),this._tileBuffer=new n.TileBuffer(1,e,t,this)}get healpixGrid(){return this._healpixGrid}get tileBuffer(){return this._tileBuffer}init(e){this.initialised=!0,this.insideSphere=e}getVisibleOrder(){return this._healpixGrid.visibleorder}computeVisiblePixels(e,t,r,i){if(!this.initialised)return;s.default.insideSphere&&e<3&&(e=3),this._ancestorsMap.set(e,[]),this._galAncestorsMap.set(e,[]);let n=[],l=[];if(0===e){const t=s.default.getHealpix(0).getNPix();for(let r=0;r<t;r++)n.push(r),this._ancestorsMap.get(e).push(r),l.push(r),this._galAncestorsMap.get(e).push(r)}else{const c=s.default.getHealpix(e),u=t.canvas.width,d=t.canvas.height;for(let t=0;t<=u;t+=u/30)for(let s=0;s<=d;s+=d/30){const u=o.default.getIntersectionPointWithSingleModel(t,s,this._healpixGrid,this._webgl,r,i);if(u.length>0){const t=h.vec4.create();h.vec4.transformMat4(t,[u[0],u[1],u[2],1],this._galacticMatrix);const r=new a.Pointing(new a.Vec3(t[0],t[1],t[2])),i=c.ang2pix(r),s=new a.Pointing(new a.Vec3(u[0],u[1],u[2])),o=c.ang2pix(s);n.includes(o)||(n.push(o),this._ancestorsMap.get(e).push(o),this._tileBuffer.addTile(e,o)),l.includes(i)||(l.push(i),this._galAncestorsMap.get(e).push(i),this._tileBuffer.addGalTile(e,i))}}}this._visibleTilesByOrder={pixels:n,order:e},this._galVisibleTilesByOrder={pixels:l,order:e};for(let t=1;t<e;t++){const r=e-t,i=this._ancestorsMap.get(r)??[];this._ancestorsMap.set(r,i);for(let e=0;e<n.length;e++){const s=n[e]>>2*t;i.includes(s)||(i.push(s),this._tileBuffer.addTile(r,s))}}for(let t=1;t<e;t++){const r=e-t,i=this._galAncestorsMap.get(r)??[];this._galAncestorsMap.set(r,i);for(let e=0;e<l.length;e++){const s=l[e]>>2*t;i.includes(s)||(i.push(s),this._tileBuffer.addGalTile(r,s))}}}get visibleTilesByOrder(){return this._visibleTilesByOrder}get ancestorsMap(){return this._ancestorsMap}get galVisibleTilesByOrder(){return this._galVisibleTilesByOrder}get galAncestorsMap(){return this._galAncestorsMap}get visibleOrder(){return this._visibleTilesByOrder.order}}},2166:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(1961),s=85.0511287798066;class a{static getRayFromMouse(e,t,r,s,o){const n=s.canvas.getBoundingClientRect(),h=[2*e/n.width-1,1-2*t/n.height,-1,1],l=i.mat4.create();i.mat4.invert(l,r);const c=[0,0,0,0];a.mat4MultiplyVec4(l,h,c);const u=[c[0],c[1],-1,0],d=i.mat4.create();i.mat4.invert(d,o);const _=[0,0,0,0];a.mat4MultiplyVec4(d,u,_);const f=i.vec3.fromValues(_[0],_[1],_[2]);return i.vec3.normalize(f,f),f}static raySphere(e,t,r){let s=-1;const a=i.vec3.create();i.vec3.subtract(a,e,r.center);const o=i.vec3.dot(t,a),n=o*o-(i.vec3.dot(a,a)-r.radius*r.radius);if(n>0){const e=Math.sqrt(n),t=-o+e,r=-o-e;(t>=0||r>=0)&&(s=r<0?t:Math.min(t,r))}else if(0===n){const e=-o;e>=0&&(s=e)}return s}static getIntersectionPointWithModel(e,t,r,s,o,n){const h=o.getCameraMatrix(),l=a.getRayFromMouse(e,t,n,s,h),c=a.raySphere(o.getCameraPosition(),l,r);if(c<0)return null;const u=i.vec3.create();i.vec3.scale(u,l,c),i.vec3.add(u,o.getCameraPosition(),u);const d=[u[0],u[1],u[2],1],_=[0,0,0,0];return a.mat4MultiplyVec4(r.getModelMatrixInverse(),d,_),[_[0],_[1],_[2]]}static getLonLatFromMouse(e,t,r,i,s,o){const n=a.getIntersectionPointWithModel(e,t,r,i,s,o);return n?a.modelPointToLonLat(n):null}static getTileFromMouse(e,t,r,i,s,o,n){const h=a.getLonLatFromMouse(e,t,i,s,o,n);return h&&a.isMercatorLatitude(h.latDeg)?a.lonLatToTile(h.lonDeg,h.latDeg,r):null}static getVisibleTilesFromViewport(e,t,r,i,s,o=9,n=2){const h=r.canvas.getBoundingClientRect(),l=Math.max(2,Math.floor(o)),c=Math.max(2*l+1,21),u=Math.max(0,Math.floor(n)),d=[],_=(o,n)=>{const h=a.getTileFromMouse(o,n,e,t,r,i,s);h&&(d.push(h),d.push(...a.getNeighborTiles(h,u)))};for(let e=0;e<l;e++){const t=1===l?h.height/2:e/(l-1)*h.height;for(let e=0;e<l;e++)_(1===l?h.width/2:e/(l-1)*h.width,t)}for(let e=0;e<c;e++){const t=1===c?.5:e/(c-1),r=t*h.width,i=t*h.height;_(r,0),_(r,h.height),_(0,i),_(h.width,i)}return a.fillSmallTileGaps(a.deduplicateTiles(d))}static modelPointToLonLat(e){const[t,r,i]=e,s=Math.hypot(t,r,i);return Number.isFinite(s)&&0!==s?{lonDeg:180*Math.atan2(r,t)/Math.PI,latDeg:180*Math.asin(Math.max(-1,Math.min(1,i/s)))/Math.PI}:{lonDeg:0,latDeg:0}}static lonLatToTile(e,t,r){const i=Math.max(0,Math.floor(r)),s=2**i,o=Math.floor((e+180)/360*s),n=Math.floor(a.latToTileY(t,i));return{z:i,x:a.wrapTileX(o,s),y:a.clampTileY(n,s)}}static getNeighborTiles(e,t=1){const r=2**e.z,i=[],s=Math.max(0,Math.floor(t));for(let t=-s;t<=s;t++)for(let o=-s;o<=s;o++)i.push({z:e.z,x:a.wrapTileX(e.x+t,r),y:a.clampTileY(e.y+o,r)});return a.deduplicateTiles(i)}static deduplicateTiles(e){const t=new Map;for(const r of e)t.set(`${r.z}/${r.x}/${r.y}`,r);return Array.from(t.values())}static fillSmallTileGaps(e){if(0===e.length)return e;const t=e[0].z,r=2**t,i=new Map,s=e=>{i.set((e=>`${e.z}/${e.x}/${e.y}`)(e),e)},o=(e,s)=>s>=0&&s<r&&i.has(`${t}/${a.wrapTileX(e,r)}/${s}`);for(const t of e)s(t);for(const i of e){const e=i.x,n=i.y;o(e-2,n)&&!o(e-1,n)&&s({z:t,x:a.wrapTileX(e-1,r),y:n}),o(e+2,n)&&!o(e+1,n)&&s({z:t,x:a.wrapTileX(e+1,r),y:n}),o(e,n-2)&&!o(e,n-1)&&s({z:t,x:e,y:n-1}),o(e,n+2)&&!o(e,n+1)&&s({z:t,x:e,y:n+1})}return Array.from(i.values())}static latToTileY(e,t){const r=Math.max(-85.0511287798066,Math.min(s,e))*Math.PI/180,i=2**t;return(1-Math.asinh(Math.tan(r))/Math.PI)/2*i}static isMercatorLatitude(e){return Math.abs(e)<=s}static wrapTileX(e,t){return(e%t+t)%t}static clampTileY(e,t){return Math.max(0,Math.min(t-1,e))}static mat4MultiplyVec4(e,t,r){const i=t[0],s=t[1],a=t[2],o=t[3];return r[0]=e[0]*i+e[4]*s+e[8]*a+e[12]*o,r[1]=e[1]*i+e[5]*s+e[9]*a+e[13]*o,r[2]=e[2]*i+e[6]*s+e[10]*a+e[14]*o,r[3]=e[3]*i+e[7]*s+e[11]*a+e[15]*o,r}}t.default=a},2257:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPSShaderProgram=void 0,t.MeshHiPSShaderProgram=class{_webgl;locations;_shaderProgram;constructor(e){this._webgl=e,this.locations={pMatrix:null,mMatrix:null,vMatrix:null,color:null,vertexPositionAttribute:-1,vertexNormalAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();if(!t)throw new Error("Could not create MeshHiPS shader program");this._shaderProgram=t,this.initShaders()}return e.useProgram(this._shaderProgram),this._shaderProgram}enableProgram(){this._webgl.useProgram(this.shaderProgram)}enableShaders(e,t,r,i){const s=this._webgl,a=this.shaderProgram;s.useProgram(a),this.locations.pMatrix=s.getUniformLocation(a,"uPMatrix"),this.locations.vMatrix=s.getUniformLocation(a,"uVMatrix"),this.locations.mMatrix=s.getUniformLocation(a,"uMMatrix"),this.locations.color=s.getUniformLocation(a,"uColor"),this.locations.vertexPositionAttribute=s.getAttribLocation(a,"aVertexPosition"),this.locations.vertexNormalAttribute=s.getAttribLocation(a,"aVertexNormal"),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t),s.uniformMatrix4fv(this.locations.mMatrix,!1,r),s.uniform4fv(this.locations.color,i)}initShaders(){const e=this._webgl,t=this.compileShader(e.VERTEX_SHADER,"#version 300 es\n precision mediump float;\n in vec3 aVertexPosition;\n in vec3 aVertexNormal;\n uniform mat4 uPMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uMMatrix;\n out vec3 vNormal;\n void main(void) {\n vec3 worldPos = (uMMatrix * vec4(aVertexPosition, 1.0)).xyz;\n vNormal = normalize((uMMatrix * vec4(aVertexNormal, 0.0)).xyz);\n gl_Position = uPMatrix * uVMatrix * vec4(worldPos, 1.0);\n }"),r=this.compileShader(e.FRAGMENT_SHADER,"#version 300 es\n precision mediump float;\n in vec3 vNormal;\n uniform vec4 uColor;\n out vec4 outColor;\n void main(void) {\n vec3 normal = normalize(vNormal);\n vec3 lightDir = normalize(vec3(0.45, 0.8, 0.35));\n float diffuse = max(dot(normal, lightDir), 0.0);\n float rim = pow(1.0 - max(dot(normal, vec3(0.0, 0.0, 1.0)), 0.0), 2.0);\n vec3 color = uColor.rgb * (0.24 + diffuse * 0.78) + vec3(0.16, 0.24, 0.20) * rim;\n outColor = vec4(color, uColor.a);\n }");if(e.attachShader(this._shaderProgram,t),e.attachShader(this._shaderProgram,r),e.linkProgram(this._shaderProgram),!e.getProgramParameter(this._shaderProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._shaderProgram)||"Could not initialise MeshHiPS shaders")}compileShader(e,t){const r=this._webgl,i=r.createShader(e);if(!i)throw new Error("Could not create MeshHiPS shader");if(r.shaderSource(i,t),r.compileShader(i),!r.getShaderParameter(i,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(i)||"MeshHiPS shader compile error");return i}}},2368:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(r(4382));t.default=class{_ready=!1;_hips;_format;_baseurl;_isGalacticHips;_order=3;opacity=1;_hipsShaderIndex=0;_texture=null;_image;_texurl;_textureLoaded=!1;_maxTiles=0;_numFacesXTile=0;_numFaces=0;vertexPosition;vertexPositionBuffer;vertexIndexBuffer;vidx=0;_webgl;_tileBuffer;_hipsShaderProgram;constructor(e,t,r,i){this._tileBuffer=r,this._hips=e,this._webgl=t,this._format=e.format,this._baseurl=e.baseURL,this._isGalacticHips=e.isGalacticHips,this._hipsShaderProgram=i,this.initImage()}initImage(){this._image=new Image,this._texurl=`${this._baseurl}/Norder3/Allsky.${this._format}`,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{console.error("File not found? %s",this._texurl)},this._image.setAttribute("crossorigin","anonymous"),this._image.src=this._texurl}imageLoaded(){this.textureLoaded(),this.initModelBuffer(),this._textureLoaded=!0,this._ready=!0}textureLoaded(){this._hipsShaderProgram.enableProgram();const e=this._webgl;this._texture=e.createTexture(),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.bindTexture(e.TEXTURE_2D,this._texture),e.isTexture(this._texture)||console.log("error in texture"),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.bindTexture(e.TEXTURE_2D,this._texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._image),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.generateMipmap(e.TEXTURE_2D)}initModelBuffer(){const e=this._webgl,t=this._order+1,r=s.default.getHealpix(this._order);this._maxTiles=r.getNPix();const i=s.default.getHealpix(t);this._numFacesXTile=4,this._numFaces=this._numFacesXTile*this._maxTiles,this.vertexPosition=new Float32Array(20*this._numFaces);let a=0,o=0;this.vidx=0;for(let e=0;e<this._maxTiles;e++){const t=r.nest2xyf(e),s=t.ix<<1,n=2+(t.ix<<1),h=t.iy<<1,l=2+(t.iy<<1);this.setupPositionAndTexture4Quadrant(a,o,s,s+(n-s)/2,h,h+(l-h)/2,i,t,0,0),this.setupPositionAndTexture4Quadrant(a,o,s+(n-s)/2,n,h,h+(l-h)/2,i,t,0,1),this.setupPositionAndTexture4Quadrant(a,o,s,s+(n-s)/2,h+(l-h)/2,l,i,t,1,0),this.setupPositionAndTexture4Quadrant(a,o,s+(n-s)/2,n,h+(l-h)/2,l,i,t,1,1),a++,27===a&&(o++,a=0)}const n=new Uint16Array(6*this._numFaces);let h=0;for(let e=0;e<this._numFaces;e++)n[6*e]=h,n[6*e+1]=h+1,n[6*e+2]=h+3,n[6*e+3]=h+1,n[6*e+4]=h+2,n[6*e+5]=h+3,h+=4;this.vertexPositionBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vertexPositionBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertexPosition,e.STATIC_DRAW),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,n,e.STATIC_DRAW)}setupPositionAndTexture4Quadrant(e,t,r,i,s,a,o,n,h,l){let c=[];const u=2**(o.order-3),d=1/(27*u),_=1/(29*u),f=d/64,g=_/64,p=u*d*e+d*h,m=u*_*t+_*l;for(let e=r;e<i;e++)for(let t=s;t<a;t++)c=o.getPointsForXyfNoStep(e,t,n.face),this.vertexPosition[20*this.vidx]=c[0].x,this.vertexPosition[20*this.vidx+1]=c[0].y,this.vertexPosition[20*this.vidx+2]=c[0].z,this.vertexPosition[20*this.vidx+3]=d+p-f,this.vertexPosition[20*this.vidx+4]=1-(_+m)+g,this.vertexPosition[20*this.vidx+5]=c[1].x,this.vertexPosition[20*this.vidx+6]=c[1].y,this.vertexPosition[20*this.vidx+7]=c[1].z,this.vertexPosition[20*this.vidx+8]=d+p-f,this.vertexPosition[20*this.vidx+9]=1-m-g,this.vertexPosition[20*this.vidx+10]=c[2].x,this.vertexPosition[20*this.vidx+11]=c[2].y,this.vertexPosition[20*this.vidx+12]=c[2].z,this.vertexPosition[20*this.vidx+13]=p+f,this.vertexPosition[20*this.vidx+14]=1-m-g,this.vertexPosition[20*this.vidx+15]=c[3].x,this.vertexPosition[20*this.vidx+16]=c[3].y,this.vertexPosition[20*this.vidx+17]=c[3].z,this.vertexPosition[20*this.vidx+18]=p+f,this.vertexPosition[20*this.vidx+19]=1-(_+m)+g,this.vidx++}draw(e,t,r,i,s,a){if(!this._ready)return!1;let o=[];if(e>=this._order){const n=this.drawChildren(e,t,r,i,s,a);n&&(o=n)}const n=this._webgl;this._hipsShaderProgram.enableShaders(r,i,s,a),n.enableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.enableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),n.activeTexture(n.TEXTURE0+this._hipsShaderIndex),n.bindTexture(n.TEXTURE_2D,this._texture),n.uniform1f(this._hipsShaderProgram.locations.textureAlpha,this.opacity),n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBuffer),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),n.vertexAttribPointer(this._hipsShaderProgram.locations.vertexPositionAttribute,3,n.FLOAT,!1,20,0),n.vertexAttribPointer(this._hipsShaderProgram.locations.textureCoordAttribute,2,n.FLOAT,!1,20,12);for(let e=0;e<this._maxTiles;e++)o.includes(e)||n.drawElements(n.TRIANGLES,6*this._numFacesXTile,n.UNSIGNED_SHORT,12*e*this._numFacesXTile);return n.disableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.disableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),!0}drawChildren(e,t,r,i,s,a){const o=this._order;if(!t.has(o))return;const n=t.get(o),h=[];for(let l=0;l<n.length;l++){const c=n[l],u=this._isGalacticHips?this._tileBuffer.getGalTile(c,o,this._hips):this._tileBuffer.getTile(c,o,this._hips);u.draw(e,t,r,i,s,a,this._hipsShaderProgram),u.getReadyState()&&h.push(c)}return h}}},2475:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=void 0;const s=i(r(2930)),a=i(r(9665)),o=r(8145);class n{_polygons=[];_convexPolygons=[];_stcs;_valid=!1;_details;_totPoints=0;_totConvexPoints=0;_npix256;_footprintsPointsOrder;_coordsType;_selectionObj;_identifier;_center;constructor(e,t=[],r,i=o.CoordsType.ASTRO){this._coordsType=i,e?(this._stcs=e.toUpperCase(),this._details=t,this._totPoints=0,this._totConvexPoints=0,this._footprintsPointsOrder=r,this.computePoints(),this._selectionObj=this.computeSelectionObject(),this._valid=!0):this._details=[]}static fromPolygons(e,t=[],r=o.CoordsType.ASTRO){const i=new n(void 0,[],void 0,r);return i._polygons=e,i._details=t,i._totPoints=e.reduce((e,t)=>e+t.length,0),i._totConvexPoints=0,i._coordsType=r,i._selectionObj=i.computeSelectionObject(),i._valid=i._totPoints>0,i}computeSelectionObject(){return s.default.computeSelectionObject(this._polygons)}computePoints(){const e=a.default.parseSTCS(this._stcs,{coordsType:this._coordsType});this._polygons=e.polygons,this._totPoints=e.totpoints}get valid(){return this._valid}get totPoints(){return this._totPoints}get totConvexPoints(){return this._totConvexPoints}get polygons(){return this._polygons}get convexPolygons(){return this._convexPolygons}get identifier(){return this._identifier}get center(){return this._center}get pixels(){return this._npix256}get details(){return this._details}get selectionObj(){return this._selectionObj}}t.Footprint=n},2737:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZTileBuffer=void 0;class r{_tiles=new Map;_cachedTiles=new Map;_cacheAliveMilliSeconds;_cleanerId;constructor(e=1){this._cacheAliveMilliSeconds=60*e*1e3,"undefined"!=typeof window&&(this._cleanerId=window.setInterval(()=>{this.cacheCleaner()},1e4))}get activeTiles(){return this._tiles}get cachedTiles(){return this._cachedTiles}get size(){return this._tiles.size+this._cachedTiles.size}ensureTiles(e,t){const r=[];for(const i of e){const e=this.getTile(i,t);this.touchTile(e),r.push(this.key(i))}return this.syncVisibleTiles(r),r}getTile(e,t){const r=this.key(e);if(this._tiles.has(r))return this._tiles.get(r).tile;if(this._cachedTiles.has(r)){const e=this._cachedTiles.get(r);return e.cacheTime0=void 0,this._tiles.set(r,e),this._cachedTiles.delete(r),e.tile}const i=t(e);return this._tiles.set(r,{tile:i}),i}getActiveTile(e){return this._tiles.get(e)?.tile??null}getAnyTile(e){return this._tiles.get(e)?.tile??this._cachedTiles.get(e)?.tile??null}getActiveTiles(){return Array.from(this._tiles.values(),e=>e.tile)}syncVisibleTiles(e){const t=new Set(e);for(const[e,r]of this._tiles)t.has(e)?this.touchTile(r.tile):(r.cacheTime0=Date.now(),this._cachedTiles.set(e,r),this._tiles.delete(e))}evictCached(e){if(this.size<=e)return;const t=Array.from(this._cachedTiles.entries()).sort((e,t)=>this.getTileAgeScore(e[1].tile)-this.getTileAgeScore(t[1].tile));for(const[r,i]of t){if(this.size<=e)break;i.tile.loading||(i.tile.dispose?.(),this._cachedTiles.delete(r))}}dispose(){void 0!==this._cleanerId&&"undefined"!=typeof window&&(window.clearInterval(this._cleanerId),this._cleanerId=void 0);for(const e of this._tiles.values())e.tile.dispose?.();for(const e of this._cachedTiles.values())e.tile.dispose?.();this._tiles.clear(),this._cachedTiles.clear()}key(e){return r.key(e)}static key(e){return`${e.z}/${e.x}/${e.y}`}cacheCleaner(){const e=Date.now();for(const[t,r]of this._cachedTiles){const i=r.cacheTime0;void 0===i||e-i<=this._cacheAliveMilliSeconds||r.tile.loading||(r.tile.dispose?.(),this._cachedTiles.delete(t))}}touchTile(e){e.touch?.()}getTileAgeScore(e){const t=e.lastUsedAt??0,r=e.createdAt??t;return Math.min(t||r,r)}}t.XYZTileBuffer=r},2885:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(r(4382)),a=r(229);t.default=class{_hips;_tileno;_baseurl;_order;_ready=!1;_format;_isGalacticHips;opacity=1;_hipsShaderIndex=0;_pixels=[];_texture=null;_image;_texurl="";vertexPosition;vertexPositionBuffer;vertexIndices;vertexIndexBuffer;_tileBuffer;_hipsShaderProgram;_webgl;constructor(e,t,r,i,s,a){this._hipsShaderProgram=s,this._tileBuffer=i,this._hips=r,this._tileno=e,this._webgl=a,this._format=r.format,this._baseurl=r.baseURL,this._isGalacticHips=r.isGalacticHips,this._order=t,this.initImage()}destroyIntervals(){}initImage(){const e=1e4*Math.floor(this._tileno/1e4);this._texurl=`${this._baseurl}/Norder${this._order}/Dir${e}/Npix${this._tileno}.${this._format}`,this._image=new Image,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{console.error("File not found? %s",this._texurl)},this._image.crossOrigin="anonymous",this._image.src=this._texurl}imageLoaded(){this.textureLoaded(),this.initModelBuffer();const e=this._webgl;e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.bindTexture(e.TEXTURE_2D,this._texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._image),this._ready=!0}textureLoaded(){this._hipsShaderProgram.enableProgram();const e=this._webgl;this._texture=e.createTexture(),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.bindTexture(e.TEXTURE_2D,this._texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.isTexture(this._texture)||console.log("error in texture")}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=a.fovHelper.getRefOrder(this._order),r=s.default.getHealpix(this._order).nest2xyf(this._tileno),i=t-this._order,o=r.ix<<i,n=(r.ix<<i)+(1<<i),h=r.iy<<i,l=(r.iy<<i)+(1<<i),c=s.default.getHealpix(t);this._pixels=[],this.setupPositionAndTexture4Quadrant(o,n/2,h,l/2,0,c,i,r),this.setupPositionAndTexture4Quadrant(n/2,n,h,l/2,1,c,i,r),this.setupPositionAndTexture4Quadrant(o,n/2,l/2,l,2,c,i,r),this.setupPositionAndTexture4Quadrant(n/2,n,l/2,l,3,c,i,r);const u=this.vertexPosition[0].length/20;this.vertexIndices=this.computeVertexIndices(u),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint16Array(6*e);let r=0;for(let i=0;i<e;i++)t[6*i]=r,t[6*i+1]=r+1,t[6*i+2]=r+2,t[6*i+3]=r+2,t[6*i+4]=r+3,t[6*i+5]=r,r+=4;return t}setupPositionAndTexture4Quadrant2(e,t,r,i,s,a,o,n){this.vertexPosition[s]=new Float32Array(20*(t-e)*(i-r));const h=1/(1<<o);let l=0;for(let c=e;c<t;c++)for(let e=r;e<i;e++){const t=a.getPointsForXyfNoStep(c,e,n.face),r=e-(n.iy<<o),i=c-(n.ix<<o);this.vertexPosition[s][20*l]=t[0].x,this.vertexPosition[s][20*l+1]=t[0].y,this.vertexPosition[s][20*l+2]=t[0].z,this.vertexPosition[s][20*l+3]=h+h*r,this.vertexPosition[s][20*l+4]=1-(h+h*i),this.vertexPosition[s][20*l+5]=t[1].x,this.vertexPosition[s][20*l+6]=t[1].y,this.vertexPosition[s][20*l+7]=t[1].z,this.vertexPosition[s][20*l+8]=h+h*r,this.vertexPosition[s][20*l+9]=1-h*i,this.vertexPosition[s][20*l+10]=t[2].x,this.vertexPosition[s][20*l+11]=t[2].y,this.vertexPosition[s][20*l+12]=t[2].z,this.vertexPosition[s][20*l+13]=h*r,this.vertexPosition[s][20*l+14]=1-h*i,this.vertexPosition[s][20*l+15]=t[3].x,this.vertexPosition[s][20*l+16]=t[3].y,this.vertexPosition[s][20*l+17]=t[3].z,this.vertexPosition[s][20*l+18]=h*r,this.vertexPosition[s][20*l+19]=1-(h+h*i),l++}this.vertexPositionBuffer[s]=this._webgl.createBuffer(),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexPositionBuffer[s]),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexPosition[s],this._webgl.STATIC_DRAW)}setupPositionAndTexture4Quadrant(e,t,r,i,s,a,o,n){const h=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(i-r));const l=1/(1<<o);let c=0;for(let h=e;h<t;h++)for(let e=r;e<i;e++){const t=a.xyf2nest(h,e,n.face);this._pixels.push(t);const r=a.getBoundaries(t),i=e-(n.iy<<o),u=h-(n.ix<<o);this.vertexPosition[s][20*c]=r[0].x,this.vertexPosition[s][20*c+1]=r[0].y,this.vertexPosition[s][20*c+2]=r[0].z,this.vertexPosition[s][20*c+3]=l+l*i,this.vertexPosition[s][20*c+4]=1-(l+l*u),this.vertexPosition[s][20*c+5]=r[1].x,this.vertexPosition[s][20*c+6]=r[1].y,this.vertexPosition[s][20*c+7]=r[1].z,this.vertexPosition[s][20*c+8]=l+l*i,this.vertexPosition[s][20*c+9]=1-l*u,this.vertexPosition[s][20*c+10]=r[2].x,this.vertexPosition[s][20*c+11]=r[2].y,this.vertexPosition[s][20*c+12]=r[2].z,this.vertexPosition[s][20*c+13]=l*i,this.vertexPosition[s][20*c+14]=1-l*u,this.vertexPosition[s][20*c+15]=r[3].x,this.vertexPosition[s][20*c+16]=r[3].y,this.vertexPosition[s][20*c+17]=r[3].z,this.vertexPosition[s][20*c+18]=l*i,this.vertexPosition[s][20*c+19]=1-(l+l*u),c++}this.vertexPositionBuffer[s]=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,this.vertexPositionBuffer[s]),h.bufferData(h.ARRAY_BUFFER,this.vertexPosition[s],h.STATIC_DRAW)}draw(e,t,r,i,s,a){if(!this._ready)return!1;let o=new Set([0,1,2,3]);if(e>this._order){const n=this.drawChildren(e,t,r,i,s,a);n&&(o=n)}this._hipsShaderProgram.enableShaders(r,i,s,a);const n=this._webgl;n.enableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.enableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),n.activeTexture(n.TEXTURE0+this._hipsShaderIndex),n.bindTexture(n.TEXTURE_2D,this._texture),n.uniform1f(this._hipsShaderProgram.locations.textureAlpha,this.opacity),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);const h=this.vertexIndices.length;return o.forEach(e=>{n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBuffer[e]),n.vertexAttribPointer(this._hipsShaderProgram.locations.vertexPositionAttribute,3,n.FLOAT,!1,20,0),n.vertexAttribPointer(this._hipsShaderProgram.locations.textureCoordAttribute,2,n.FLOAT,!1,20,12),n.drawElements(n.TRIANGLES,h,n.UNSIGNED_SHORT,0)}),n.disableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.disableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),!0}drawChildren(e,t,r,i,s,a){const o=new Set([0,1,2,3]),n=this._order+1;if(t.has(n)){for(let h=0;h<4;h++){const l=(this._tileno<<2)+h;if(t.get(n).includes(l)){const h=this._isGalacticHips?this._tileBuffer.getGalTile(l,n,this._hips):this._tileBuffer.getTile(l,n,this._hips);h.draw(e,t,r,i,s,a,this._hipsShaderProgram),h._ready&&o.delete(h._tileno-(this._tileno<<2))}}return o}}}},2919:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bootSetup=t.tapRepos=t.hipsNodes=void 0,t.hipsNodes=["https://skies.esac.esa.int/","https://alasky.cds.unistra.fr/"],t.tapRepos=["https://sky.esa.int/esasky-tap/tap/"],t.bootSetup={insideSphere:!1,defaultHips:"",camera_fov_deg:34,camera_fov_rad:34*Math.PI/180,inside_camera_fov_deg:60,inside_camera_fov_rad:60*Math.PI/180,camera_near_plane:1e-5,camera_far_plane:2.5,corsProxyUrl:"http://localhost:4000/",useCORSProxy:!1,maxDecimals:15,defaultHipsUrl:"https://cdn.skies.esac.esa.int/DSSColor/",version:"Astrobrowser v1.0.0",debug:!1,insideView:!1,showViewfinder:!0}},2930:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6553),a=i(r(7559)),o=r(8145);class n{static orthodromicDistance(e,t){return Math.acos(Math.sin(e.decDeg*Math.PI/180)*Math.sin(t.decDeg*Math.PI/180)+Math.cos(e.decDeg*Math.PI/180)*Math.cos(t.decDeg*Math.PI/180)*Math.cos((t.raDeg-e.raDeg)*Math.PI/180))}static computeSelectionObject(e){let t,r,i,s,o=[],h=0,l=0;if(e[0][0].decDeg>=10?l=1:e[0][0].decDeg<=-10?l=-1:h=1,0===h){const a=n.projectIn2D(e[0][0]);t=i=a.x,r=s=a.y;for(const a of e){const e=[];for(const c of a){if(c.decDeg>10*l&&-1===l||c.decDeg<10*l&&1===l){h=1,o=[];break}const a=n.projectIn2D(c);e.push(a),a.x>t&&(t=a.x),a.y>r&&(r=a.y),a.x<i&&(i=a.x),a.y<s&&(s=a.y)}o.push(e)}}if(0===h)return{poly4selection:o,flag:h,maxx:t,maxy:r,minx:i,miny:s};const c=180;let u=e[0][0].raDeg<c;t=i=e[0][0].raDeg,r=s=e[0][0].decDeg;for(const n of e){const e=[];for(const l of n){const n=new a.default(l.raDeg,l.decDeg);if(e.push(n),l.raDeg>t&&(t=l.raDeg),l.decDeg>r&&(r=l.decDeg),l.raDeg<i&&(i=l.raDeg),l.decDeg<s&&(s=l.decDeg),l.raDeg>=c&&u||l.raDeg<=c&&!u){h=2,o=[];break}}o.push(e)}if(1===h)return{poly4selection:o,flag:h,maxx:t,maxy:r,minx:i,miny:s};let d=e[0][0].raDeg;t=d>=c?d-360:d,r=e[0][0].decDeg,i=t,s=r;for(const n of e){const e=[];for(const o of n){const n=o.raDeg>=c?o.raDeg-360:o.raDeg;n>t&&(t=n),o.decDeg>r&&(r=o.decDeg),n<i&&(i=n),o.decDeg<s&&(s=o.decDeg),e.push(new a.default(n,o.decDeg))}o.push(e)}return{poly4selection:o,flag:h,maxx:t,maxy:r,minx:i,miny:s}}static stereographic(e){const t=Number(e.xyz[0]),r=Number(e.xyz[1]),i=Number(e.xyz[2]);return{x:2*t/(1-i),y:2*r/(1-i)}}static projectIn2D(e){const t=n.stereographic(e);return new a.default(t.x,t.y)}static checkPointInsidePolygon5(e,t){let r;if(0===e.flag)r=n.projectIn2D(t);else if(1===e.flag)r=new a.default(t.raDeg,t.decDeg);else{const e=180,i=t.raDeg>=e?t.raDeg-360:t.raDeg;r=new a.default(i,t.decDeg)}const i=new a.default(r.x,r.y+2*Math.abs(e.maxy-e.miny));if(r.x>e.maxx||r.x<e.minx||r.y>e.maxy||r.y<e.miny)return!1;for(const t of e.poly4selection){let e=0;for(let s=0;s<t.length-1;s++){const a=t[s],o=t[s+1],n=(o.y-a.y)*(i.x-r.x)-(o.x-a.x)*(i.y-r.y),h=(o.x-a.x)*(r.y-a.y)-(o.y-a.y)*(r.x-a.x),l=(i.x-r.x)*(r.y-a.y)-(i.y-r.y)*(r.x-a.x);if(0!==n){const t=h/n,r=l/n;t>=0&&t<=1&&r>=0&&r<=1&&e++}}{const s=t[t.length-1],a=t[0],o=(a.y-s.y)*(i.x-r.x)-(a.x-s.x)*(i.y-r.y),n=(a.x-s.x)*(r.y-s.y)-(a.y-s.y)*(r.x-s.x),h=(i.x-r.x)*(r.y-s.y)-(i.y-r.y)*(r.x-s.x);if(0!==o){const t=n/o,r=h/o;t>=0&&t<=1&&r>=0&&r<=1&&e++}}if(e%2==1)return!0}return!1}static checkPointInsidePolygon4(e,t){const r=n.projectIn2D(t);let i=t.raDeg+15;i>360&&(i=t.raDeg-15);const a=new s.Point({raDeg:i,decDeg:t.decDeg},o.CoordsType.ASTRO),h=n.projectIn2D(a);for(const t of e){let e=0;for(let i=0;i<t.length-1;i++){const s=n.projectIn2D(t[i]),a=n.projectIn2D(t[i+1]),o=(a.y-s.y)*(h.x-r.x)-(a.x-s.x)*(h.y-r.y),l=(a.x-s.x)*(r.y-s.y)-(a.y-s.y)*(r.x-s.x),c=(h.x-r.x)*(r.y-s.y)-(h.y-r.y)*(r.x-s.x);if(0!==o){const t=l/o,r=c/o;t>=0&&t<=1&&r>=0&&r<=1&&e++}}{const i=n.projectIn2D(t[t.length-1]),s=n.projectIn2D(t[0]),a=(s.y-i.y)*(h.x-r.x)-(s.x-i.x)*(h.y-r.y),o=(s.x-i.x)*(r.y-i.y)-(s.y-i.y)*(r.x-i.x),l=(h.x-r.x)*(r.y-i.y)-(h.y-r.y)*(r.x-i.x);if(0!==a){const t=o/a,r=l/a;t>=0&&t<=1&&r>=0&&r<=1&&e++}}if(e%2==1)return!0}return!1}}t.default=n},3174:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZAncestorTile=t.XYZAnchestorTile=void 0;const i=r(8819),s=r(1375);class a extends s.XYZTile{_ancestorMeshBuilder;_ancestorWebgl;_segmentsPerSide;_meshCache=new Map;constructor(e,t,r,s,a=new i.XYZMeshBuilder,o=16){super(e,t,r,s,a,o),this._ancestorMeshBuilder=a,this._ancestorWebgl=r,this._segmentsPerSide=o}draw(e,t,r,i,s,a,o){if("number"!=typeof e)return super.draw(e,t,r,i);if(!s||!a||void 0===o)return!1;const n=t,h=r,l=i;let c=!1;if(e<=this.coord.z)return super.draw(l,s,a,o);for(const e of n){if(!this.isAncestorOf(e))continue;const t=`${this.coord.z}/${this.coord.x}/${this.coord.y}`;if(!h.has(t))continue;const r=this.getRemappedMesh(e);c=super.drawRemapped(r,l,s,a,o)||c}return c}dispose(){for(const e of this._meshCache.values())e.positionBuffer&&this._ancestorWebgl.deleteBuffer(e.positionBuffer),e.uvBuffer&&this._ancestorWebgl.deleteBuffer(e.uvBuffer),e.indexBuffer&&this._ancestorWebgl.deleteBuffer(e.indexBuffer);this._meshCache.clear(),super.dispose()}getRemappedMesh(e){const t=`${e.z}/${e.x}/${e.y}->${this.coord.z}/${this.coord.x}/${this.coord.y}`,r=this._meshCache.get(t);if(r)return r;const i=this._ancestorMeshBuilder.buildAncestorMesh(e,this.coord,this._segmentsPerSide),s=this._ancestorMeshBuilder.uploadMesh(i,this._ancestorWebgl);return this._meshCache.set(t,s),s}isAncestorOf(e){if(e.z<=this.coord.z)return e.z===this.coord.z&&e.x===this.coord.x&&e.y===this.coord.y;const t=e.z-this.coord.z;return e.x>>t===this.coord.x&&e.y>>t===this.coord.y}}t.XYZAnchestorTile=a,t.XYZAncestorTile=a},3559:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueShaderProgram=void 0;const s=r(1961),a=i(r(5947));t.CatalogueShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix"},this.gl_attributes={vertex_pos:"aCatPosition",vertex_selected:"a_selected",point_size:"a_pointsize",point_hue:"a_brightness"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,hovered:-1,pointSize:-1,brightness:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=a.default.catalogueFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const r=a.default.catalogueVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,r),e.compileShader(this._vertexShader),console.log("VS log:",e.getShaderInfoLog(this._vertexShader)||"ok"),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this.shaderProgram,this._vertexShader),e.attachShader(this.shaderProgram,this._fragmentShader),e.linkProgram(this.shaderProgram),e.getProgramParameter(this.shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this.shaderProgram),this.locations.position=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.hovered=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_selected),this.locations.pointSize=e.getAttribLocation(this.shaderProgram,this.gl_attributes.point_size),this.locations.brightness=e.getAttribLocation(this.shaderProgram,this.gl_attributes.point_hue),this.locations.color=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.vertex_color)):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableShaders(e,t,r){const i=this._webgl;i.useProgram(this.shaderProgram),this.locations.pMatrix=i.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=i.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let a=s.mat4.create();a=s.mat4.multiply(a,r,t),i.uniformMatrix4fv(this.locations.pMatrix,!1,e),i.uniformMatrix4fv(this.locations.mvMatrix,!1,a)}}},3726:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPS=void 0;const s=r(4735),a=r(229),o=i(r(619)),n=i(r(2885)),h=i(r(2368));class l extends s.AbstractSkyEntity{_ancestorTiles;_allSkyTile;_descriptor;_format;_baseurl;_maxorder;_minorder;_visibleorder=3;_allSky=!0;samplerIdx=0;colorMapIdx=0;colorMap=o.default.native;_healpixGrid;get maxOrder(){return this._maxorder}get minOrder(){return this._minorder}get baseURL(){return this._baseurl}get format(){return this._format}get propertiesRawText(){return this._descriptor.propertiesRawText}get properties(){return this._descriptor.properties}constructor(e,t,r,i,s,o,l){super(e,t,r,i,s.surveyName,o,s.isGalactic),this._descriptor=s,this.initGL(o),this._healpixGrid=l,this._healpixGrid.visibleTilesManager.tileBuffer.addHiPS(this),console.log("HiPS frame "+s.hipsFrame),console.log("HiPS minOrder "+s.minOrder),this._format=s.imgFormats[0],this._baseurl=s.url,this._maxorder=s.maxOrder,this._minorder=s.minOrder,this.initShaders();let c=a.fovHelper.getHiPSNorder(180);if(this._visibleorder=Math.min(c,this._maxorder),this._ancestorTiles=[],this._allSkyTile=null,this._allSky=!0,this._allSky)this._allSkyTile=new h.default(this,this._webgl,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram);else for(let e=0;e<12;e++)this._ancestorTiles.push(new n.default(e,0,this,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram,this._webgl))}getProperty(e){return this._descriptor.getProperty(e)}changeFormat(e){this._format=e,this._tileBuffer?.clearAll&&this._tileBuffer.clearAll(),this._tileBuffer&&(this._tileBuffer._format=this._format);const t=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder:this._healpixGrid.visibleTilesManager.visibleTilesByOrder;this._tileBuffer?.updateTiles&&this._tileBuffer.updateTiles(t.pixels,t.order)}changeColorMap(e){switch(console.log("HiPS.changeColorMap -> shaderProgram",super.hipsShaderProgram.shaderProgram),this.colorMap=e,e.name){case"grayscale":this.colorMapIdx=1,this.colorMap=o.default.grayscale,super.hipsShaderProgram.setGrayscaleShader();break;case"planck":this.colorMapIdx=2,this.colorMap=o.default.planck,super.hipsShaderProgram.setColorMapShader();break;case"cmb":this.colorMapIdx=3,this.colorMap=o.default.cmb,super.hipsShaderProgram.setColorMapShader();break;case"rainbow":this.colorMapIdx=4,this.colorMap=o.default.rainbow,super.hipsShaderProgram.setColorMapShader();break;case"eosb":this.colorMapIdx=5,this.colorMap=o.default.eosb,super.hipsShaderProgram.setColorMapShader();break;case"cubehelix":this.colorMapIdx=6,this.colorMap=o.default.cubehelix,super.hipsShaderProgram.setColorMapShader();break;case"hot":this.colorMapIdx=7,this.colorMap=o.default.hot,super.hipsShaderProgram.setColorMapShader();break;case"gray":this.colorMapIdx=8,this.colorMap=o.default.gray,super.hipsShaderProgram.setColorMapShader();break;case"native":this.colorMapIdx=0,this.colorMap=o.default.native,super.hipsShaderProgram.setNativeShader();break;default:this.colorMapIdx=9,this.colorMap=e,super.hipsShaderProgram.setColorMapShader()}}initShaders(){super.hipsShaderProgram.enableProgram()}getCurrentHealpixOrder(){return this._visibleorder}getDebugStats(){const e=this._healpixGrid.visibleTilesManager.tileBuffer,t=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder:this._healpixGrid.visibleTilesManager.visibleTilesByOrder;return{activeBaseLayer:"hips",hipsName:this._descriptor.surveyName,hipsUrl:this._baseurl,isGalactic:this.isGalacticHips,currentOrder:t.order,visibleTileCount:t.pixels.length,activeTileCount:e.activeTileCount,cachedTileCount:e.cachedTileCount,cacheSize:e.size,readyTileCount:e.readyTileCount,loadingTileCount:e.loadingTileCount}}refresh(e){const t=e.fovDeg??this._healpixGrid.getMinFoV(),r=Number.isFinite(t)&&t>0?t:1e-6;this._visibleorder=Math.min(a.fovHelper.getHiPSNorder(r,this._visibleorder),this._maxorder)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const r=e.pMatrix;if(!r)return;this.refresh(e);const i=this.getModelMatrix();if(super.hipsShaderProgram.setRuntimeColorMap(this.colorMap),this._allSky&&this._allSkyTile)return void(this.isGalacticHips?this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.galAncestorsMap,r,t,i,this.colorMapIdx):this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.ancestorsMap,r,t,i,this.colorMapIdx));const s=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order:this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,a=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galAncestorsMap:this._healpixGrid.visibleTilesManager.ancestorsMap;this._ancestorTiles.forEach(e=>{e.draw(s,a,r,t,i,this.colorMapIdx)})}}t.HiPS=l},3956:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WMTSAdapter=void 0,t.WMTSAdapter=class{_config;constructor(e){this._config=e}toXYZLayerConfig(){const e=this.getInferredMaxZoom();return{urlTemplate:this._config.urlTemplate??this._config.baseUrl,minZoom:this._config.minZoom,maxZoom:e,segmentsPerSide:this._config.segmentsPerSide,tileSize:this._config.tileSize,maxCachedTiles:this._config.maxCachedTiles,subdomains:this._config.subdomains,attribution:this._config.attribution,flipY:this._config.flipY,urlResolver:e=>this.getTileUrl(e)}}getInferredMaxZoom(){const e=this._config.matrixLabels?.length??0,t=e>0?e-1:void 0;return null==t?this._config.maxZoom:null==this._config.maxZoom?t:Math.min(this._config.maxZoom,t)}getTileUrl(e){return"rest"===this._config.requestEncoding?this.buildRestUrl(e):this.buildKvpUrl(e)}buildRestUrl(e){var t,r;return(t=this._config.urlTemplate??this._config.baseUrl,r=this.getCommonTokenValues(e),Object.entries(r).reduce((e,[t,r])=>e.replace(new RegExp(`\\{${t}\\}`,"g"),r),t)).replace(/(?<!:)\/{2,}/g,"/")}buildKvpUrl(e){const t=new URL(this._config.baseUrl),r=this.getCommonTokenValues(e),i=t.searchParams;i.set("SERVICE","WMTS"),i.set("REQUEST","GetTile"),i.set("VERSION",this._config.version??"1.0.0"),i.set("LAYER",this._config.layer),i.set("STYLE",this._config.style??"default"),i.set("FORMAT",this._config.format??"image/png"),i.set("TILEMATRIXSET",this._config.tileMatrixSet),i.set("TILEMATRIX",r.TileMatrix),i.set("TILEROW",r.TileRow),i.set("TILECOL",r.TileCol);for(const[e,t]of Object.entries(this._config.dimensions??{}))i.set(e,t);return t.toString()}getCommonTokenValues(e){const t=2**e.z,r=this._config.flipY?t-1-e.y:e.y,i=this._config.matrixLabels?.[e.z]??String(e.z),s=this._config.format??"image/png",a=s.replace(/^image\//,"");return{Layer:this._config.layer,Style:this._config.style??"default",Time:this._config.time??"",TileMatrixSet:this._config.tileMatrixSet,TileMatrix:i,TileRow:String(r),TileCol:String(e.x),Format:a,TileFormat:s,TileFormatExtension:a,...Object.fromEntries(Object.entries(this._config.dimensions??{}).map(([e,t])=>[e,t]))}}}},4006:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TileBuffer=void 0;const s=i(r(8256));t.TileBuffer=class{_tiles;_cachedTiles;_activeHiPS;_galTiles;_galCachedTiles;_galActiveHiPS;_cacheAliveMilliSeconds;_cleanerId;_webgl;_visibleTileManager;_hipsShaderProgram;constructor(e=1,t,r,i){this._hipsShaderProgram=r,this._visibleTileManager=i,this._webgl=t,this._tiles=new Map,this._cachedTiles=new Map,this._activeHiPS=new Map,this._galTiles=new Map,this._galCachedTiles=new Map,this._galActiveHiPS=new Map,this._cacheAliveMilliSeconds=60*e*1e3,this._cleanerId=window.setInterval(()=>{this.cacheCleaner()},1e4)}addHiPS(e){this._activeHiPS.has(e)?console.error("HiPS already present in TileBuffer"):this._activeHiPS.set(e,new Map)}addGalHiPS(e){this._galActiveHiPS.has(e)?console.error("HiPS already present in TileBuffer"):this._galActiveHiPS.set(e,new Map)}addTile(e,t){for(const r of this._activeHiPS.keys())e>r.maxOrder||this.getTile(t,e,r)}addGalTile(e,t){for(const r of this._galActiveHiPS.keys())e>r.maxOrder||this.getGalTile(t,e,r)}getTile(e,t,r){const i=this.key(t,e,r.baseURL);if(!this._tiles.has(i))if(this._cachedTiles.has(i)){const e=this._cachedTiles.get(i);this._tiles.set(i,e),this._cachedTiles.delete(i),e.resetCacheTime0()}else{const a=new s.default(e,t,r,this,this._webgl,this._visibleTileManager);this._tiles.set(i,a)}return this._tiles.get(i)}getGalTile(e,t,r){const i=this.key(t,e,r.baseURL);if(!this._galTiles.has(i))if(this._galCachedTiles.has(i)){const e=this._galCachedTiles.get(i);this._galTiles.set(i,e),this._galCachedTiles.delete(i),e.resetCacheTime0()}else{const a=new s.default(e,t,r,this,this._webgl,this._visibleTileManager);this._galTiles.set(i,a)}return this._galTiles.get(i)}moveTileToCache(e,t,r){const i=this.key(t,e,r.baseURL);if(this._tiles.has(i)){const e=this._tiles.get(i);e.setCacheTime0(),this._cachedTiles.set(i,e),this._tiles.delete(i)}if(this._galTiles.has(i)){const e=this._galTiles.get(i);e.setCacheTime0(),this._galCachedTiles.set(i,e),this._galTiles.delete(i)}}cacheCleaner(){const e=Date.now();for(const[t,r]of this._cachedTiles){const i=r.cacheTime0;!r.inView&&void 0!==i&&e-i>this._cacheAliveMilliSeconds&&(r.destroyIntervals(),this._cachedTiles.delete(t))}for(const[t,r]of this._galCachedTiles){const i=r.cacheTime0;!r.inView&&void 0!==i&&e-i>this._cacheAliveMilliSeconds&&(r.destroyIntervals(),this._galCachedTiles.delete(t))}}key(e,t,r){return`${e}#${t}#${r}`}dispose(){window.clearInterval(this._cleanerId)}get size(){return this._tiles.size+this._cachedTiles.size+this._galTiles.size+this._galCachedTiles.size}get activeTileCount(){return this._tiles.size+this._galTiles.size}get cachedTileCount(){return this._cachedTiles.size+this._galCachedTiles.size}get readyTileCount(){let e=0;for(const t of this._tiles.values())t.getReadyState()&&e++;for(const t of this._galTiles.values())t.getReadyState()&&e++;for(const t of this._cachedTiles.values())t.getReadyState()&&e++;for(const t of this._galCachedTiles.values())t.getReadyState()&&e++;return e}get loadingTileCount(){let e=0;for(const t of this._tiles.values())t.isLoading()&&e++;for(const t of this._galTiles.values())t.isLoading()&&e++;for(const t of this._cachedTiles.values())t.isLoading()&&e++;for(const t of this._galCachedTiles.values())t.isLoading()&&e++;return e}}},4322:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OBJMeshParser=void 0;class r{static parse(e){const t=[],i=[],s=[],a=e.split(/\r\n|\n/);for(const e of a){const a=e.trim();if(a&&!a.startsWith("#")){if(a.startsWith("v ")){const e=a.split(/\s+/);if(e.length<4)continue;t.push(Number(e[1]),Number(e[2]),Number(e[3])),s.push(0,0,0);continue}if(a.startsWith("f ")){const e=a.slice(2).trim().split(/\s+/).map(e=>Number(e.split("/")[0])).filter(e=>Number.isInteger(e)&&0!==e);if(e.length<3)continue;const s=r.resolveIndex(e[0],t.length/3);for(let a=1;a<e.length-1;a++)i.push(s,r.resolveIndex(e[a],t.length/3),r.resolveIndex(e[a+1],t.length/3))}}}return r.computeVertexNormals(t,i,s),{positions:new Float32Array(t),normals:new Float32Array(s),indices:new Uint32Array(i)}}static computeVertexNormals(e,t,r){for(let i=0;i<t.length;i+=3){const s=t[i],a=t[i+1],o=t[i+2],n=e[3*s],h=e[3*s+1],l=e[3*s+2],c=e[3*a]-n,u=e[3*a+1]-h,d=e[3*a+2]-l,_=e[3*o]-n,f=e[3*o+1]-h,g=e[3*o+2]-l,p=u*g-d*f,m=d*_-c*g,M=c*f-u*_;r[3*s]+=p,r[3*s+1]+=m,r[3*s+2]+=M,r[3*a]+=p,r[3*a+1]+=m,r[3*a+2]+=M,r[3*o]+=p,r[3*o+1]+=m,r[3*o+2]+=M}for(let e=0;e<r.length;e+=3){const t=r[e],i=r[e+1],s=r[e+2],a=Math.hypot(t,i,s)||1;r[e]=t/a,r[e+1]=i/a,r[e+2]=s/a}}static resolveIndex(e,t){return e>0?e-1:t+e}}t.OBJMeshParser=r},4382:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(1138),s=r(2919),a=new class{_healpix;_selectionnside;_useCORSProxy;_corsProxyUrl;_maxDecimals;_debug;_insideSphere;_version;constructor(){this._useCORSProxy=s.bootSetup.useCORSProxy,this._corsProxyUrl=s.bootSetup.corsProxyUrl,this._maxDecimals=s.bootSetup.maxDecimals,this._debug=s.bootSetup.debug,this._insideSphere=s.bootSetup.insideView,this._version=s.bootSetup.version,this._healpix={},this._selectionnside=32}init(){console.log("Global.init()")}get version(){return this._version}set corsProxyUrl(e){this._corsProxyUrl=e}get corsProxyUrl(){return this._corsProxyUrl}get useCORSProxy(){return this._useCORSProxy}set useCORSProxy(e){this._useCORSProxy=e}get debug(){return this._debug}getHealpix(e){return void 0===this._healpix[e]&&(this._healpix[e]=new i.Healpix(Math.pow(2,e))),this._healpix[e]}get MAX_DECIMALS(){return this._maxDecimals}set insideSphere(e){this._insideSphere=e}get insideSphere(){return this._insideSphere}get nsideForSelection(){return this._selectionnside}};t.default=a},4396:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(1961),a=r(1138),o=i(r(4382)),n=r(7930);t.default=class{_xyz=null;_raDecDeg=null;_phiThetaDeg=null;raHMS;decDMS;constructor(e,t,r){null!=e&&(this._xyz=e),null!=t&&(this._raDecDeg=t),null!=r&&(this._phiThetaDeg=r),this._raDecDeg&&(this.raHMS=(0,n.raDegToHMS)(this._raDecDeg.ra),this.decDMS=(0,n.decDegToDMS)(this._raDecDeg.dec))}computeNpix(){if(!this._xyz)return null;const e=o.default.getHealpix(o.default.nsideForSelection),t=new a.Vec3(this._xyz[0],this._xyz[1],this._xyz[2]),r=new a.Pointing(t,!1);return e.ang2pix(r,!1)}update(e){const t=(r=e,Array.isArray(r)?s.vec3.fromValues(r[0],r[1],r[2]):r);var r;const i=(0,n.cartesianToSpherical)(t),a=(0,n.sphericalToAstroDeg)(i.phi,i.theta);this._xyz=[t[0],t[1],t[2]],this._phiThetaDeg=i,this._raDecDeg=a,this.raHMS=(0,n.raDegToHMS)(a.ra),this.decDMS=(0,n.decDegToDMS)(a.dec)}clear(){this._xyz=null,this._raDecDeg=null,this._phiThetaDeg=null,this.raHMS=void 0,this.decDMS=void 0}get xyz(){return this._xyz}get x(){return this._xyz?this._xyz[0]:null}get y(){return this._xyz?this._xyz[1]:null}get z(){return this._xyz?this._xyz[2]:null}get ra(){return this._raDecDeg?this._raDecDeg.ra:null}get dec(){return this._raDecDeg?this._raDecDeg.dec:null}get phi(){return this._phiThetaDeg?this._phiThetaDeg.phi:null}get theta(){return this._phiThetaDeg?this._phiThetaDeg.theta:null}get raDecDeg(){return this._raDecDeg}get phiThetaDeg(){return this._phiThetaDeg}}},4595:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HealpixGrid=void 0;const s=r(4735),a=i(r(4382)),o=r(1961),n=r(229),h=r(8083),l=r(5803),c=r(8145),u=r(6553),d=i(r(4707)),_=i(r(2930)),f=i(r(5361)),g=r(7930),p=r(2056),m=r(2919);class M extends s.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_visibleorder=0;showGrid=!1;_shaderProgram;fragmentShader;vertexShader;defaultColor="#ec0acaff";gridText=new f.default("healpix");_attribLocations={position:0,selected:1,pointSize:2,color:3};_nPrimitiveFlags=0;_vertexCataloguePositionBuffer;_indexBuffer;_vertexCataloguePosition=new Float32Array(0);_indexes=new Uint32Array(0);_fovObj;static INITIAL_FOV=180;static RADIUS=1;static INITIAL_POSITION=[0,0,0];static INITIAL_PhiRad=0;static INITIAL_ThetaRad=0;_visibleTilesManager;constructor(e){super(M.RADIUS,M.INITIAL_POSITION,M.INITIAL_PhiRad,M.INITIAL_ThetaRad,"healpix-grid",e),this.init(),this._visibleTilesManager=new p.VisibleTilesManager(this._webgl,super.hipsShaderProgram,this),this._visibleTilesManager.init(m.bootSetup.insideSphere)}init(){console.log("HealpixGridSingleton.init()"),this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders();const e=n.fovHelper.getHiPSNorder(M.INITIAL_FOV);this._visibleorder=e,this._nPrimitiveFlags=0,this._vertexCataloguePositionBuffer=super.webgl.createBuffer(),this._indexBuffer=super.webgl.createBuffer(),this._vertexCataloguePosition=new Float32Array(0),this._fovObj=new l.SphereFoV(super.webgl)}get fovObj(){return this._fovObj}get RADIUS(){return M.RADIUS}get INITIAL_POSITION(){return M.INITIAL_POSITION}get INITIAL_PhiRad(){return M.INITIAL_PhiRad}get INITIAL_ThetaRad(){return M.INITIAL_ThetaRad}refreshFoV(e,t){return this._fovObj.getFoV(a.default.insideSphere,this,e,t)}getFoV(){return this._fovObj}getMinFoV(){return this._fovObj.minFoV}initShaders(){const e=super.webgl,t=d.default.healpixGridFS();if(this.fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this.fragmentShader,t),e.compileShader(this.fragmentShader),!e.getShaderParameter(this.fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this.fragmentShader)||"Fragment shader compile error");const r=d.default.healpixGridVS();this.vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this.vertexShader,r),e.compileShader(this.vertexShader),e.getShaderParameter(this.vertexShader,e.COMPILE_STATUS)?(e.attachShader(this._shaderProgram,this.vertexShader),e.attachShader(this._shaderProgram,this.fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this._shaderProgram)):alert(e.getShaderInfoLog(this.vertexShader)||"Vertex shader compile error")}initBuffers(e,t){this._nPrimitiveFlags=0;const r=a.default.getHealpix(t),i=a.default.getHealpix(t+1),s=a.default.getHealpix(t+2);let o=0,n=0;this._indexes=new Uint32Array(17*e.length),this._vertexCataloguePosition=new Float32Array(48*e.length);for(let t=0;t<e.length;t++){const a=r.getBoundaries(e[t]),h=e[t]<<2,l=h+1,c=h+2,u=h+3,d=i.getBoundaries(h),_=i.getBoundaries(u),f=e=>{this._vertexCataloguePosition[o]=1*e.x,this._vertexCataloguePosition[o+1]=1*e.y,this._vertexCataloguePosition[o+2]=1*e.z,this._indexes[n]=Math.floor(o/3),n+=1,o+=3};f(a[0]);let g=3+(u<<2),p=s.getBoundaries(g);f(p[1]),f(_[1]);let m=2+(c<<2);p=s.getBoundaries(m),f(p[0]),f(a[1]),f(p[2]),f(d[1]);let M=h<<2;p=s.getBoundaries(M),f(p[1]),f(a[2]),f(p[3]),f(d[3]);let x=1+(l<<2);p=s.getBoundaries(x),f(p[2]),f(a[3]),f(p[0]),f(_[3]),p=s.getBoundaries(g),f(p[3]),this._indexes[n]=4294967295,this._nPrimitiveFlags+=1,n+=1}}refresh(e,t){this.refreshFoV(e,t);const r=this.getMinFoV();this._visibleorder=n.fovHelper.getHiPSNorder(r,this._visibleorder)}enableShader(e,t,r){const i=super.webgl;i.useProgram(this._shaderProgram);const s=i.getUniformLocation(this._shaderProgram,"uMVMatrix"),a=i.getUniformLocation(this._shaderProgram,"uPMatrix"),n=super.webgl.getUniformLocation(this._shaderProgram,"u_fragcolor");this._attribLocations.position=i.getAttribLocation(this._shaderProgram,"aCatPosition");let h=o.mat4.create();if(h=o.mat4.multiply(h,r,e),s&&i.uniformMatrix4fv(s,!1,h),a&&i.uniformMatrix4fv(a,!1,t),n){const e=(0,g.colorHex2RGB)(this.defaultColor);i.uniform4f(n,e[0],e[1],e[2],1)}}isVisible(){return this.showGrid}toggleShowGrid(){this.showGrid=!this.showGrid}get visibleTilesManager(){return this._visibleTilesManager}draw(e){const t=super.webgl,r=this.getModelMatrix(),i=e.camera;if(!i)return;const s=i.getCameraMatrix(),l=e.pMatrix;if(!l)return;const d=e.fovDeg??this.getMinFoV(),f=Number.isFinite(d)&&d>0?d:1e-6;if(this._visibleorder=n.fovHelper.getHiPSNorder(f,this._visibleorder),!this.showGrid)return void this.gridText.resetDivSets();const g=this._visibleTilesManager.visibleTilesByOrder,p=g.pixels,m=g.order;this.initBuffers(p,m),this.enableShader(r,l,s),t.bindBuffer(t.ARRAY_BUFFER,this._vertexCataloguePositionBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertexCataloguePosition,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,M.ELEM_SIZE,t.FLOAT,!1,M.BYTES_X_ELEM*M.ELEM_SIZE,0),t.enableVertexAttribArray(this._attribLocations.position),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this._indexes,t.STATIC_DRAW),t.drawElements(t.LINE_LOOP,this._vertexCataloguePosition.length/3+this._nPrimitiveFlags,t.UNSIGNED_INT,0),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);let x=o.mat4.create();x=o.mat4.multiply(x,s,r);let v=o.mat4.create();v=o.mat4.multiply(v,l,x);const b=h.FoVUtils.getCenterJ2000(t.canvas,this,this._webgl,i,l),S=this.getMinFoV()*Math.PI/180/2;for(let e=0;e<p.length;e++){const r=a.default.getHealpix(this._visibleorder).pix2vec(p[e]),i=new u.Point({x:r.x,y:r.y,z:r.z},c.CoordsType.CARTESIAN);if(_.default.orthodromicDistance(b,i)<S){const i=[r.x,r.y,r.z,1],s=o.vec4.create();o.vec4.transformMat4(s,i,v),s[0]/=s[3],s[1]/=s[3];const a=t.canvas.getBoundingClientRect(),n=a.left+(.5*s[0]+.5)*a.width,h=a.top+(-.5*s[1]+.5)*a.height;this.gridText.addHPXDivSet(this._visibleorder+"/"+p[e],n,h)}}this.gridText.resetDivSets(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}get visibleorder(){return this._visibleorder}}t.HealpixGrid=M},4639:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(1961);class s{static lastNearestVisibleObjectIdx=-1;static getNearestVisibleObjectIdx(){return this.lastNearestVisibleObjectIdx}static getRayFromMouse(e,t,r,a,o){const n=a.canvas.getBoundingClientRect(),h=t,l=[2*e/n.width-1,1-2*h/n.height,-1,1],c=i.mat4.create();i.mat4.invert(c,r);const u=[0,0,0,0];s.mat4MultiplyVec4(c,l,u);const d=[u[0],u[1],-1,0],_=i.mat4.create();i.mat4.invert(_,o);const f=[0,0,0,0];s.mat4MultiplyVec4(_,d,f);const g=i.vec3.fromValues(f[0],f[1],f[2]);return i.vec3.normalize(g,g),g}static mat4MultiplyVec4(e,t,r){const i=t[0],s=t[1],a=t[2],o=t[3];return r[0]=e[0]*i+e[4]*s+e[8]*a+e[12]*o,r[1]=e[1]*i+e[5]*s+e[9]*a+e[13]*o,r[2]=e[2]*i+e[6]*s+e[10]*a+e[14]*o,r[3]=e[3]*i+e[7]*s+e[11]*a+e[15]*o,r}static raySphere(e,t,r){let s=-1;const a=i.vec3.create();i.vec3.subtract(a,e,r.center);const o=i.vec3.dot(t,a),n=o*o-(i.vec3.dot(a,a)-r.radius*r.radius);if(n>0){const e=Math.sqrt(n),t=-o+e,r=-o-e;t<0&&r<0||(s=r<0?t:Math.min(t,r))}else if(0===n){const e=-o;e>=0&&(s=e)}return s}static getIntersectionPointWithSingleModel(e,t,r,a,o,n){const h=o.getCameraMatrix(),l=s.getRayFromMouse(e,t,n,a,h),c=s.raySphere(o.getCameraPosition(),l,r);let u=[];if(c>=0){const e=i.vec3.create();i.vec3.scale(e,l,c),i.vec3.add(e,o.getCameraPosition(),e);const t=[e[0],e[1],e[2],1],a=[0,0,0,0];s.mat4MultiplyVec4(r.getModelMatrixInverse(),t,a),u=[a[0],a[1],a[2]]}return u}}t.default=s},4707:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{static healpixGridVS(){return"#version 300 es\n in vec4 aCatPosition;\n uniform mat4 uMVMatrix;\n uniform mat4 uPMatrix;\n\n void main() {\n gl_Position = uPMatrix * uMVMatrix * aCatPosition;\n gl_PointSize = 7.0;\n }"}static healpixGridFS(){return"#version 300 es\n precision mediump float;\n\n uniform vec4 u_fragcolor;\n out vec4 fragColor;\n\n void main() {\n // fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n fragColor = u_fragcolor;\n }"}}},4723:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(2919),a=i(r(7734)),o=i(r(4639)),n=i(r(4382)),h=i(r(4396)),l=r(7930),c=r(3726),u=r(9685),d=r(6553),_=r(8083),f=r(9839),g=r(4595),p=r(8145),m=i(r(619)),M=r(5409),x=r(3956),v=r(8868),b=r(1741),S=r(6878),P=r(1961);class y{static MIN_WHEEL_SCALE=.85;static MAX_WHEEL_SCALE=1.8;_camera;_perspectiveMatrixManager;centralPoinCoords;mousePointCoords;canvas;_healpixGrid;_equatorialGrid;mouseHelper;mouseDown=!1;lastMouseX=null;lastMouseY=null;inertiaX=0;inertiaY=0;zoomInertia=0;pointerDownX=null;pointerDownY=null;pointerDownAt=0;_activeHiPS=null;_activeXYZ2=null;_activeMeshHiPS=null;_activeBaseLayer=null;startup=!0;fov;activeCatalogues=[];activeFootprintSets=[];_webgl;_selectedColorMap;_cameraStatusChanged=!1;lastCameraChangedAt=0;lastCameraMotionAt=0;lastHoveredSource=null;lastHoveredCatalogue=null;zoomSensitivity=1;lockedEastWestRaDeg=null;lockedNorthSouthDecDeg=null;keepCameraNorthUp=!0;constructor(e,t){console.log("[AstroSphere] new instance for canvas",e.id),this._webgl=t,this.mouseHelper=new h.default,this.canvas=e,this._selectedColorMap=m.default.native,n.default.insideSphere=s.bootSetup.insideSphere,this.initCamera(),this._healpixGrid=new g.HealpixGrid(this._webgl),this._perspectiveMatrixManager=new u.PerspectiveMatrixManager(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._equatorialGrid=new f.EquatorialGrid(this._webgl,this._healpixGrid),this._equatorialGrid.init(this._healpixGrid.getMinFoV()),this.updateCentralPoint(),this.startup=!0,this.addEventListeners(e),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV)}initCamera(){s.bootSetup.insideSphere?this._camera=new a.default([0,0,-.005],!0):this._camera=new a.default([0,0,4],!1)}setCamera(e){this._camera=e}setCameraRotationSensitivity(e){this._camera.setRotationSensitivity(e)}getCameraRotationSensitivity(){return this._camera.getRotationSensitivity()}get healpixGrid(){return this._healpixGrid}get equatorialGrid(){return this._equatorialGrid}updateCentralPoint(){const e=this.getPhiThetaDeg(this.canvas),t=(0,l.sphericalToAstroDeg)(e.phi,e.theta),r=(0,l.raDegToHMS)(t.ra),i=(0,l.decDegToDMS)(t.dec);return this.centralPoinCoords={astroDeg:t,sphericalDeg:e,raHMS:r,decDMS:i},this.centralPoinCoords}updateLastMousePoint(){const e={phi:this.mouseHelper.phi,theta:this.mouseHelper.theta},t={ra:this.mouseHelper.ra,dec:this.mouseHelper.dec},r=this.mouseHelper.raHMS,i=this.mouseHelper.decDMS;return this.mousePointCoords={astroDeg:t,sphericalDeg:e,raHMS:r,decDMS:i},this.mousePointCoords}clearLastMousePoint(){this.mousePointCoords=void 0}getCentralPointCoordinates(){return this.centralPoinCoords}getLastMousePointCoordinates(){return this.mousePointCoords}clamp(e,t,r){return Math.min(r,Math.max(t,e))}computeZoomStep(e,t){const r=t<0?-1:1,i=this.clamp(Math.abs(t)/120,y.MIN_WHEEL_SCALE,y.MAX_WHEEL_SCALE);return r*this.clamp(.0012+.0025*Math.sqrt(Math.max(e,0)),.0012,.04)*i*this.zoomSensitivity}setZoomSensitivity(e){this.zoomSensitivity=this.clamp(e,.2,3)}getZoomSensitivity(){return this.zoomSensitivity}filterRotationDeltaByAstroLocks(e,t){const r=this._camera.isRotationLockedY(),i=this._camera.isRotationLockedX();if(!r&&!i)return{deltaX:e,deltaY:t};const s=o.default.getIntersectionPointWithSingleModel(this.canvas.clientWidth/2,this.canvas.clientHeight/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!s||s.length<3)return{deltaX:e,deltaY:t};const a=P.vec3.normalize(P.vec3.create(),P.vec3.fromValues(s[0],s[1],s[2])),n=P.vec3.fromValues(0,0,1),h=P.vec3.cross(P.vec3.create(),n,a);P.vec3.length(h)<1e-6?P.vec3.set(h,1,0,0):P.vec3.normalize(h,h);const l=P.vec3.scale(P.vec3.create(),a,P.vec3.dot(n,a)),c=P.vec3.subtract(P.vec3.create(),n,l);P.vec3.length(c)<1e-6&&P.vec3.cross(c,a,h),P.vec3.normalize(c,c);const u=this.projectModelDirectionToScreen(a,h),d=this.projectModelDirectionToScreen(a,c);if(!u||!d)return{deltaX:e,deltaY:t};let _=e,f=t;if(r){const e=_*u.x+f*u.y;_-=e*u.x,f-=e*u.y}if(i){const e=_*d.x+f*d.y;_-=e*d.x,f-=e*d.y}return{deltaX:_,deltaY:f}}projectModelDirectionToScreen(e,t){const r=P.vec3.scaleAndAdd(P.vec3.create(),e,t,.01),i=this.projectModelPointToScreen(e),s=this.projectModelPointToScreen(r);if(!i||!s)return null;const a=s.x-i.x,o=s.y-i.y,n=Math.hypot(a,o);return n<1e-6?null:{x:a/n,y:o/n}}projectModelPointToScreen(e){const t=this._camera.getCameraMatrix(),r=this._healpixGrid.getModelMatrix(),i=P.mat4.create(),s=P.mat4.create();P.mat4.multiply(i,t,r),P.mat4.multiply(s,this._perspectiveMatrixManager.pMatrix,i);const a=P.vec4.fromValues(e[0],e[1],e[2],1);return P.vec4.transformMat4(a,a,s),Math.abs(a[3])<1e-6?null:{x:a[0]/a[3],y:-a[1]/a[3]}}enforceAstronomicalRotationLocks(){if(null==this.lockedEastWestRaDeg&&null==this.lockedNorthSouthDecDeg)return!1;const e=this.updateCentralPoint();if(!e)return!1;const t=this.lockedEastWestRaDeg??e.astroDeg.ra,r=this.lockedNorthSouthDecDeg??e.astroDeg.dec;return(Math.abs(t-e.astroDeg.ra)>1e-6||Math.abs(r-e.astroDeg.dec)>1e-6)&&(this._camera.goTo(t,r),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}enforceCameraNorthUp(){if(!this.keepCameraNorthUp)return!1;const e=this.updateCentralPoint();return!!e&&(this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}emitCameraChanged(e){if(!this._activeHiPS&&!this._activeXYZ2&&!this._activeMeshHiPS)return;if(!this._healpixGrid?.fovObj)return;const t=this.getCurrentStatus();t&&this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:t,bubbles:!0,composed:!0}))}addEventListeners(e){n.default.debug&&console.log("[AstroSphere::addEventListeners]");const t=e.getBoundingClientRect();this.lastMouseX=t.left,this.lastMouseY=t.top,console.log("[AstroSphere] registering pointer and wheel listeners on canvas"),e.onpointerdown=t=>{e.setPointerCapture(t.pointerId),this.mouseDown=!0;const r=e.getBoundingClientRect();this.lastMouseX=t.clientX-r.left,this.lastMouseY=t.clientY-r.top,this.pointerDownX=this.lastMouseX,this.pointerDownY=this.lastMouseY,this.pointerDownAt=Date.now();const i=o.default.getIntersectionPointWithSingleModel(this.lastMouseX,this.lastMouseY,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return i&&i.length>0?(this.mouseHelper.update(i),this.updateLastMousePoint()):this.clearLastMousePoint(),t.preventDefault(),!1},e.onpointerup=t=>{if(e.releasePointerCapture(t.pointerId),this.mouseDown=!1,document.body.style.cursor="auto",0!==t.button)return t.preventDefault(),!1;const r=e.getBoundingClientRect(),i=t.clientX-r.left,s=t.clientY-r.top;this.lastMouseX=i,this.lastMouseY=s;const a=Math.hypot(i-(this.pointerDownX??i),s-(this.pointerDownY??s)),n=Date.now()-this.pointerDownAt;if(a<=4&&n<=250){const e=o.default.getIntersectionPointWithSingleModel(i,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(e&&e.length>0){this.mouseHelper.update(e),this.updateLastMousePoint();for(const e of this.activeCatalogues){const t=e.selectPrimarySourceFromClick(this.mouseHelper);t?.sources.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("source-clicked",{detail:{source:t.sources,selectionState:t.selectionState,catalogue:e},bubbles:!0,composed:!0}))}for(const e of this.activeFootprintSets){const t=e.selectPrimaryFootprintFromClick(this.mouseHelper);t?.footprints.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-clicked",{detail:{footprint:t.footprints,selectionState:t.selectionState,footprintSet:e},bubbles:!0,composed:!0}))}}}else this.clearLastMousePoint()},e.onpointermove=t=>{const r=e.getBoundingClientRect(),i=t.clientX-r.left,s=t.clientY-r.top,a=i,h=s;if(this._healpixGrid){if(this.mouseDown){document.body.style.cursor="grab";const t=n.default.insideSphere?-1:1,r=n.default.insideSphere?10:1,i=t*r*(a-(this.lastMouseX??a))*Math.PI/e.width,s=t*r*(h-(this.lastMouseY??h))*Math.PI/e.height,o=this.filterRotationDeltaByAstroLocks(i,s);this.inertiaX+=.1*o.deltaX,this.inertiaY+=.1*o.deltaY,this.updateCentralPoint()}else{const e=o.default.getIntersectionPointWithSingleModel(i,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);e&&e.length>0?(this.mouseHelper.update(e),this.updateLastMousePoint()):this.clearLastMousePoint()}this.centralPoinCoords||this.updateCentralPoint(),this.lastMouseX=a,this.lastMouseY=h,this._cameraStatusChanged=!0,t.preventDefault()}},e.onpointerleave=()=>{this.clearLastMousePoint(),this._cameraStatusChanged=!0,this.emitCameraChanged("pointerleave")},console.log("[AstroSphere] adding wheel event listener with passive: false"),e.addEventListener("wheel",e=>{const t=this._healpixGrid.getMinFoV(),r=this.computeZoomStep(t,e.deltaY);this.zoomInertia=0,this._camera.zoom(r),this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this._cameraStatusChanged=!0,this.emitCameraChanged("wheel"),e.preventDefault()},{passive:!1}),e.addEventListener("contextmenu",t=>{t.preventDefault();const r=e.getBoundingClientRect(),i=t.clientX-r.left,s=t.clientY-r.top,a=o.default.getIntersectionPointWithSingleModel(i,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!a||0===a.length)return!1;this.mouseHelper.update(a),this.updateLastMousePoint();for(const e of this.activeCatalogues){const r=e.getSourcesFromPointer(this.mouseHelper);if(r?.sources.length){this._webgl.canvas.dispatchEvent(new CustomEvent("source-contextmenu",{detail:{source:r.sources,catalogue:e,clientX:t.clientX,clientY:t.clientY},bubbles:!0,composed:!0}));break}}for(const e of this.activeFootprintSets){const r=e.getFootprintsFromPointer(this.mouseHelper);if(r?.footprints.length){this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-contextmenu",{detail:{footprint:r.footprints,footprintSet:e,clientX:t.clientX,clientY:t.clientY},bubbles:!0,composed:!0}));break}}return!1}),console.log("[AstroSphere] registering global keydown listener on document"),document.addEventListener("keydown",e=>{if(e.ctrlKey)switch(e.key){case"1":this._camera.clearRotationLock();break;case"2":this._camera.setRotationLock({x:!0,y:!1,z:!1});break;case"3":this._camera.setRotationLock({x:!1,y:!0,z:!1});break;case"4":this._camera.setRotationLock({x:!1,y:!1,z:!0})}},{capture:!0})}getPhiThetaDeg(e){const t=e.getBoundingClientRect(),r=t.width,i=t.height,s=o.default.getIntersectionPointWithSingleModel(r/2,i/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return(0,l.cartesianToSpherical)(s)}collectViewportSphericalSamples(e=5){const t=this.canvas.getBoundingClientRect(),r=t.width,i=t.height,s=[];for(let t=0;t<e;t++){const a=1===e?r/2:t/(e-1)*r;for(let t=0;t<e;t++){const r=1===e?i/2:t/(e-1)*i,n=o.default.getIntersectionPointWithSingleModel(a,r,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);n&&n.length>0&&s.push((0,l.cartesianToSpherical)(n))}}return s}activateHiPS(e){this._activeHiPS=new c.HiPS(1,[0,0,0],0,0,e,this._webgl,this._healpixGrid),this._activeBaseLayer="hips"}activateXYZ(e){this.activateXYZ2(new v.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver)),this._activeBaseLayer="xyz"}activateXYZ2(e){this._activeXYZ2=new b.XYZMap(1,[0,0,0],0,0,e,this._webgl),this._activeBaseLayer="xyz"}activateMeshHiPS(e){this._activeMeshHiPS=new S.MeshHiPS(e.meshRadius,[0,0,0],0,0,e,this._webgl,this._healpixGrid),this._activeBaseLayer="meships"}activateWMTS(e){const t=new x.WMTSAdapter(e).toXYZLayerConfig();this._activeXYZ2=new b.XYZMap(1,[0,0,0],0,0,new v.XYZMapDescriptor(e.layer?`WMTS ${e.layer}`:"WMTS Earth2 Layer",t.urlTemplate,t.minZoom??0,t.maxZoom??8,t.segmentsPerSide??48,t.maxCachedTiles??384,8,t.urlResolver),this._webgl),this._activeBaseLayer="xyz"}async showCatalogue(e){return e&&this.activeCatalogues.push(e),e}deleteCatalogue(e){this.activeCatalogues=this.activeCatalogues.filter(t=>t!==e)}async showFootprintSet(e){return e&&this.activeFootprintSets.push(e),e}deleteFootprintSet(e){this.activeFootprintSets=this.activeFootprintSets.filter(t=>t!==e)}getHoveredFootprints(){let e=[];return this.activeFootprintSets.forEach(t=>{e.push(t.hoveredFootprints)}),e}goTo(e,t){this._camera.goTo(e,t)}getActiveCoordinateMode(){return"xyz"===this._activeBaseLayer?"lonlat":"hips"===this._activeBaseLayer&&this._activeHiPS?.isGalacticHips?"galactic":"equatorial"}resetAxesOrientation(){const e=this.updateCentralPoint();e&&(this.inertiaX=0,this.inertiaY=0,this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),this._cameraStatusChanged=!0)}setKeepCameraNorthUp(e){this.keepCameraNorthUp=e,e&&this.resetAxesOrientation()}isKeepCameraNorthUp(){return this.keepCameraNorthUp}getFoV(){return"xyz"===this._activeBaseLayer&&this._activeXYZ2?this._activeXYZ2.getFoV():this.fov}getFoVPolygon(){if(null==this.healpixGrid)throw new Error(`healpixGrid is ${this.healpixGrid}`);return _.FoVUtils.getFoVPolygon(this._camera,this.canvas,this._healpixGrid,this._healpixGrid,this._webgl,this._perspectiveMatrixManager.pMatrix)}changeFoV(e){const t=this._healpixGrid.getFoV().computeDistanceFromAngle(e);this._camera.translate(t),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV)}changeFoV2(e){const t=this._healpixGrid.getFoV().computeCameraPositionForFoV(e);this._camera.setCameraPosition(t)}changeFoV3(e){const t=this._healpixGrid.getFoV().computeCameraPositionForAngularDiameter(e);this._camera.setCameraPosition(t),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,!1)}getInsideSphere(){return n.default.insideSphere}toggleInsideSphere(){const e=this.updateCentralPoint();this.inertiaX=0,this.inertiaY=0,this.zoomInertia=0,n.default.insideSphere=!n.default.insideSphere,this._camera.toggleInsideSphere(),this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.updateCentralPoint(),this.lastCameraMotionAt=performance.now(),this._cameraStatusChanged=!0,this.emitCameraChanged("inside-sphere-toggle"),requestAnimationFrame(()=>this.draw(this.canvas))}setCameraPosition(e){this._camera.setCameraPosition(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}setCameraMatrix(e){this._camera.setCameraMatrix(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}_refreshingStatus=!1;applyFullCameraState(e,t){this._refreshingStatus=!0,this._camera=e.camera,this._healpixGrid.setModelMatrix(e.mMatrix),this._perspectiveMatrixManager.pMatrix=e.pMatrix,this.setCameraMatrix(e.vMatrix),t&&this._activeHiPS?.changeColorMap(e.colorMap),this._refreshingStatus=!1}getCurrentStatus(){this.updateCentralPoint();const e=this.centralPoinCoords?.astroDeg.ra,t=this.centralPoinCoords?.astroDeg.dec;if(null==e||null==t)return null;let r=[];try{r=this.getFoVPolygon()}catch(e){console.warn("[AstroSphere] getCurrentStatus: FoV polygon is not available.",e)}return{fovDeg:this.fov.minFoV,fovXDeg:this.fov.xFoV,fovYDeg:this.fov.yFoV,position:this._camera.getCameraPosition(),vMatrix:this._camera.getCameraMatrix(),pMatrix:this._perspectiveMatrixManager.pMatrix,mMatrix:this._healpixGrid.getModelMatrix(),camera:this._camera,timestamp:performance.now(),centralPoint:new d.Point({raDeg:e,decDeg:t},p.CoordsType.ASTRO),mouseHoverPoint:this.mousePointCoords,colorMap:this._selectedColorMap,getFoVPolygon:r}}changeColorMap(e){(this._activeHiPS||this._activeXYZ2||this._activeMeshHiPS)&&(this._selectedColorMap=e,this._activeHiPS?.changeColorMap(e),this._activeXYZ2?.changeColorMap(e))}prevFov=0;prevCentralRaDeg=null;prevCentralDecDeg=null;get activeHiPS(){return this._activeHiPS}get activeXYZ(){return this._activeXYZ2}get activeMeshHiPS(){return this._activeMeshHiPS}isLonLatGridVisible(){return this._activeXYZ2?.isLonLatGridVisible()??!1}toggleLonLatGrid(){return this._activeXYZ2?.toggleLonLatGrid()??!1}setEastWestRotationLocked(e){this._camera.setRotationLock({y:e}),e&&(this.inertiaX=0),this.lockedEastWestRaDeg=e?this.updateCentralPoint()?.astroDeg.ra??null:null}isEastWestRotationLocked(){return this._camera.isRotationLockedY()}setNorthSouthRotationLocked(e){this._camera.setRotationLock({x:e}),e&&(this.inertiaY=0),this.lockedNorthSouthDecDeg=e?this.updateCentralPoint()?.astroDeg.dec??null:null}isNorthSouthRotationLocked(){return this._camera.isRotationLockedX()}getXYZDebugStats(){return{activeBaseLayer:this._activeBaseLayer,layer:this._activeXYZ2?.getDebugStats()??null,requests:M.xyzTileRequestScheduler.getDebugStats()}}getHiPSDebugStats(){return this._activeHiPS?this._activeHiPS.getDebugStats():null}getMeshHiPSDebugStats(){return this._activeMeshHiPS?this._activeMeshHiPS.getDebugStats():null}draw(e){if(this._refreshingStatus)return;if(!this._webgl)return;if(!this._activeHiPS&&!this._activeXYZ2&&!this._activeMeshHiPS)return;if(!this._healpixGrid||0===Object.keys(this._healpixGrid).length)return;if(void 0===this._healpixGrid.fovObj)return;this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere);let t=!1,r=0,i=0;if(this._webgl.viewport(0,0,this._webgl.drawingBufferWidth,this._webgl.drawingBufferHeight),this._webgl.clear(this._webgl.COLOR_BUFFER_BIT|this._webgl.DEPTH_BUFFER_BIT),0!==this.zoomInertia&&(Math.abs(this.zoomInertia)>1e-4?(this._camera.zoom(this.zoomInertia),this.zoomInertia*=.95,this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.prevFov!==this.fov.minFoV&&(this.centralPoinCoords||(this.centralPoinCoords=this.updateCentralPoint()),this.prevFov=this.fov.minFoV)):this.zoomInertia=0,this._cameraStatusChanged=!0),this.mouseDown||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02){t=!0;const a=this.filterRotationDeltaByAstroLocks(this.inertiaX,this.inertiaY);i=a.deltaX,r=a.deltaY,this.inertiaX=.95*a.deltaX,this.inertiaY=.95*a.deltaY,this._camera.rotate(i,r),this.lastCameraMotionAt=performance.now(),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.enforceAstronomicalRotationLocks()||this.enforceCameraNorthUp()}else this.inertiaY=0,this.inertiaX=0;const a=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix);if(Number.isFinite(a.minFoV)&&a.minFoV>0&&(this.fov=a,this._camera.refreshFoV(this.fov.minFoV),this.prevFov=this.fov.minFoV),t){const e=this.updateCentralPoint(),t=e.astroDeg.ra,r=e.astroDeg.dec,i=null===this.prevCentralRaDeg||Math.abs(t-this.prevCentralRaDeg)>1e-5,s=null===this.prevCentralDecDeg||Math.abs(r-this.prevCentralDecDeg)>1e-5;(i||s)&&(this.prevCentralRaDeg=t,this.prevCentralDecDeg=r)}if(this._cameraStatusChanged){const e=performance.now(),t=!this.mouseDown||e-this.lastCameraChangedAt>100,r=t?this.getCurrentStatus():null;r&&(this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:r,bubbles:!0,composed:!0})),this.lastCameraChangedAt=e),!this.startup&&t&&(this._cameraStatusChanged=!1)}if(this._webgl.disable(this._webgl.DEPTH_TEST),this._webgl.enable(this._webgl.BLEND),this._webgl.enable(this._webgl.CULL_FACE),this._webgl.cullFace(n.default.insideSphere?this._webgl.FRONT:this._webgl.BACK),this._webgl.blendFunc(this._webgl.SRC_ALPHA,this._webgl.ONE_MINUS_SRC_ALPHA),"hips"===this._activeBaseLayer&&this._activeHiPS){const e=Math.min(this._healpixGrid.visibleorder,this._activeHiPS.maxOrder);this._healpixGrid.visibleTilesManager.computeVisiblePixels(e,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix)}if("meships"===this._activeBaseLayer&&this._activeMeshHiPS){const e=this._activeMeshHiPS.refreshOrder(this.fov?.minFoV??this._healpixGrid.getMinFoV());this._healpixGrid.visibleTilesManager.computeVisiblePixels(e,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix)}const o=this.fov?.minFoV??this._healpixGrid.getMinFoV(),h=performance.now(),c=this.mouseDown||Math.abs(this.zoomInertia)>1e-4||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02||h-this.lastCameraMotionAt<220,u={fovDeg:o,camera:this._camera,pMatrix:this._perspectiveMatrixManager.pMatrix,centerSphericalDeg:this.updateCentralPoint().sphericalDeg,fovPolygon:void 0,viewportSphericalSamples:void 0,cameraMoving:c};if("hips"===this._activeBaseLayer&&this._activeHiPS?.draw(u),"xyz"===this._activeBaseLayer&&this._activeXYZ2?.draw(u),"meships"===this._activeBaseLayer&&this._activeMeshHiPS?.draw(u),this._healpixGrid.draw(u),this._equatorialGrid.draw(u),this._webgl.enable(this._webgl.DEPTH_TEST),this._webgl.disable(this._webgl.CULL_FACE),this.startup){this.startup=!1;const t=this.getPhiThetaDeg(e),r=(0,l.sphericalToAstroDeg)(t.phi,t.theta),i=(0,l.raDegToHMS)(r.ra),s=(0,l.decDegToDMS)(r.dec);this.prevFov=this.fov?.minFoV??this._healpixGrid.getMinFoV(),this._cameraStatusChanged=!0,console.log("(startup coords)",{raDeg:r.ra,decDeg:r.dec,raHMS:i,decDMS:s})}this.activeCatalogues.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.emitHoveredSourceIfChanged(),this.activeFootprintSets.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)})}emitHoveredSourceIfChanged(){let e=null,t=null;for(const r of this.activeCatalogues){const i=r.getPrimaryHoveredSource();if(i){e=i,t=r;break}}e===this.lastHoveredSource&&t===this.lastHoveredCatalogue||(this.lastHoveredSource=e,this.lastHoveredCatalogue=t,this._webgl.canvas.dispatchEvent(new CustomEvent("source-hovered",{detail:{source:e,catalogue:t},bubbles:!0,composed:!0})))}}t.default=y},4735:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractSkyEntity=void 0;const i=r(1961),s=r(7786);t.AbstractSkyEntity=class{refreshMe=!1;fovX_deg=180;fovY_deg=180;xRad;yRad;prevFoV=this.fovX_deg;_name;center;radius;isGalacticHips;vertexTextureCoordBuffer=null;vertexPositionBuffer=null;vertexIndexBuffer=null;shaderProgram=null;T=i.mat4.create();R=i.mat4.create();modelMatrix=i.mat4.create();inverseModelMatrix=i.mat4.create();galacticMatrixInverted=i.mat4.create();_webgl;_hipsShaderProgram;constructor(e,t,r,a,o,n,h){this._webgl=n,this.xRad=r,this.yRad=a,this._name=o,this.center=i.vec3.clone(t),this.radius=e,this.isGalacticHips=!!h,i.mat4.set(this.galacticMatrixInverted,-.054875582456588745,-.8734370470046997,-.48383501172065735,0,.49410945177078247,-.4448296129703522,.7469822764396667,0,-.8676661849021912,-.19807636737823486,.4559837877750397,0,0,0,0,1),this._hipsShaderProgram=new s.HiPSShaderProgram(this._webgl)}get name(){return this._name}get hipsShaderProgram(){return this._hipsShaderProgram}get webgl(){return this._webgl}initGL(e){this.vertexTextureCoordBuffer=e.createBuffer(),this.vertexPositionBuffer=e.createBuffer(),this.vertexIndexBuffer=e.createBuffer(),this.shaderProgram=e.createProgram(),this.T=i.mat4.create(),this.R=i.mat4.create(),this.modelMatrix=i.mat4.create(),this.inverseModelMatrix=i.mat4.create(),this.translate(this.center),this.rotate(this.xRad,this.yRad)}translate(e){i.mat4.translate(this.T,this.T,e),this.refreshModelMatrix()}rotate(e,t){i.mat4.rotate(this.R,this.R,t,[0,0,1]),i.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshModelMatrix()}rotateFromZero(e,t){i.mat4.identity(this.R),i.mat4.rotate(this.R,this.R,e,[1,0,0]),i.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshModelMatrix()}refreshModelMatrix(){const e=i.mat4.create();i.mat4.invert(e,this.R),i.mat4.multiply(this.modelMatrix,this.T,e),this.isGalacticHips&&i.mat4.multiply(this.modelMatrix,this.modelMatrix,this.galacticMatrixInverted)}getModelMatrixInverse(){return i.mat4.identity(this.inverseModelMatrix),i.mat4.invert(this.inverseModelMatrix,this.modelMatrix),this.inverseModelMatrix}getModelMatrix(){return this.modelMatrix}setModelMatrix(e){this.modelMatrix=e}setGeometryNeedsToBeRefreshed(){this.refreshGeometryOnFoVChanged=!1}rotateX(e,t){const r=Math.cos(t),i=Math.sin(t),s=e[1],a=e[5],o=e[9];return e[1]=e[1]*r-e[2]*i,e[5]=e[5]*r-e[6]*i,e[9]=e[9]*r-e[10]*i,e[2]=e[2]*r+s*i,e[6]=e[6]*r+a*i,e[10]=e[10]*r+o*i,e}rotateY(e,t){const r=Math.cos(t),i=Math.sin(t),s=e[0],a=e[4],o=e[8];return e[0]=r*e[0]+i*e[2],e[4]=r*e[4]+i*e[6],e[8]=r*e[8]+i*e[10],e[2]=r*e[2]-i*s,e[6]=r*e[6]-i*a,e[10]=r*e[10]-i*o,e}}},5087:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSDescriptor=void 0,t.HiPSDescriptor=class{_minOrder=3;_imgformats=[];_datarange={min:void 0,max:void 0};_maxOrder;_tilewidth;_hipsFrame;_hipsName="NONAME";_hipsurl;_emMin;_emMax;_isGalctic=!1;_propertiesRawText;_propertiesMap=new Map;constructor(e,t){this._hipsurl=t,this._propertiesRawText=e;const r=e.split(/\r\n|\n/);for(const e of r){const t=e.trim();if(!t||t.startsWith("#"))continue;const r=t.slice(0,t.indexOf("=")).trim(),i=this.getValue(t);if(r&&void 0!==i&&this._propertiesMap.set(r,i),t.startsWith("hips_tile_format")||t.startsWith("format")){const e=this.getValue(t)?.replace(/jpeg/gi,"jpg")??"";this._imgformats=e.split(/\s+/).filter(Boolean)}else if(t.startsWith("hips_data_range")){const e=this.getValue(t);if(e){const[t,r]=e.split(/\s+/);this._datarange.min=parseFloat(t),this._datarange.max=parseFloat(r)}}else if(t.startsWith("hips_tile_width")){const e=Number(this.getValue(t));this._tilewidth=Number.isFinite(e)?e:void 0}else if(t.startsWith("hips_order_min")){const e=Number(this.getValue(t));this._minOrder=Number.isFinite(e)?e:this._minOrder}else if(t.startsWith("hips_order")||t.startsWith("maxOrder")){const e=Number(this.getValue(t));this._maxOrder=Number.isFinite(e)?e:this._maxOrder}else if(t.startsWith("hips_frame")||t.startsWith("frame"))this._hipsFrame=this.getValue(t);else if(t.startsWith("obs_collection")||t.startsWith("label"))this._hipsName=this.getValue(t)??this._hipsName;else if(t.startsWith("em_min")){const e=Number(this.getValue(t));this._emMin=Number.isFinite(e)?e:void 0}else if(t.startsWith("em_max")){const e=Number(this.getValue(t));this._emMax=Number.isFinite(e)?e:void 0}}if(this._hipsName||console.warn(`[HiPSDescriptor] hipsName not defined in properties of ${this._hipsurl}. Defaulting to 'NONAME'.`),this._hipsFrame||(console.warn(`[HiPSDescriptor] hips_frame not defined in properties of ${this._hipsurl}. Defaulting to 'equatorial'.`),this._hipsFrame="equatorial"),this._isGalctic=this._hipsFrame.toLowerCase().includes("gal"),void 0===this._maxOrder||0===this._imgformats.length)throw new Error(`[HiPSDescriptor] Invalid properties for ${this._hipsurl}. maxOrder=${this._maxOrder}, imgFormats.length=${this._imgformats.length}`)}getValue(e){const t=e.indexOf("=");if(!(t<0))return e.slice(t+1).trim()}get propertiesRawText(){return this._propertiesRawText}get properties(){return new Map(this._propertiesMap)}getProperty(e){return this._propertiesMap.get(e)}get surveyName(){return this._hipsName}get url(){return this._hipsurl}get maxOrder(){return this._maxOrder}get minOrder(){return this._minOrder}get imgFormats(){return this._imgformats}get hipsFrame(){return this._hipsFrame}get isGalactic(){return this._isGalctic}get emMin(){return this._emMin}get emMax(){return this._emMax}get tileWidth(){return this._tilewidth}get dataRange(){return this._datarange}}},5361:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class r{static layers=new Map;layer;constructor(e="equatorial"){this.layer=e,r.getLayerState(e)}initHtml(){r.getLayerState(this.layer)}resetDivSets(e=this.layer){const t=r.getLayerState(e);for(;t.divSetNdx<t.divSets.length;++t.divSetNdx)t.divSets[t.divSetNdx].style.display="none";t.divSetNdx=0}addHPXDivSet(e,t,r){this.addLabel("healpix",e,t+25,r,"hpx")}addEqDivSet(e,t,r,i){this.addLabel("equatorial",e,"ra"===i?t+25:t,"ra"===i?r:r+25,i)}addLonLatDivSet(e,t,r,i){this.addLabel("lonlat",e,"lon"===i?t+25:t,"lon"===i?r:r+25,i)}addLabel(e,t,i,s,a){const o=r.getLayerState(e);if(!o.container)return;let n=o.divSets[o.divSetNdx++];if(!n){const e=document.createElement("div"),t=document.createTextNode("");e.appendChild(t),o.container.appendChild(e),n={div:e,textNode:t,style:e.style},o.divSets.push(n)}n.div.className=this.classNameForKind(a),n.style.display="block",n.style.left=`${Math.floor(i)}px`,n.style.top=`${Math.floor(s)}px`,n.textNode.nodeValue=t}classNameForKind(e){switch(e){case"dec":return"floating-div-dec";case"lat":return"floating-div-lat";case"lon":return"floating-div-lon";default:return"floating-div-ra"}}static getLayerState(e){const t=r.layers.get(e);if(t)return t.container||(t.container=r.resolveContainer(e)),t;const i={container:r.resolveContainer(e),divSets:[],divSetNdx:0};return r.layers.set(e,i),i}static resolveContainer(e){return"healpix"===e?document.querySelector("#gridhpx"):document.querySelector("#gridcoords")}}t.default=r},5403:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataManager=void 0;const i=r(1072);t.MetadataManager=class{static STANDARD_SIZE="STANDARD_SIZE";static STANDARD_HUE="STANDARD_HUE";_outlineColumnList=[];_raColumnList=[];_decColumnList=[];_shapeColumnList=[];_hueColumnList=[];_selectedOutlineColumn;_selectedRaColumn;_selectedDecColumn;_selectedShapeColumn;_selectedHueColumn;_selectedNameColumn;_columns=[];constructor(e){e.forEach(e=>{e.columnType==i.ColumnType.NUMBER&&(this.addHueColumn(e),this.addShapeColumn(e)),e.columnType==i.ColumnType.GEOM_RA&&this.addRaColumn(e),e.columnType==i.ColumnType.GEOM_DEC&&this.addDecColumn(e),e.columnType==i.ColumnType.GEOM_FOOTPRINT&&this.addOutlineColumn(e),e.columnType==i.ColumnType.MAIN_NAME&&(this._selectedNameColumn=e),this._columns.push(e)})}addOutlineColumn(e){this._outlineColumnList.push(e),this._selectedOutlineColumn=e}addRaColumn(e){this._selectedRaColumn=this._selectedRaColumn||e,this._raColumnList.push(e)}addDecColumn(e){this._selectedDecColumn=this._selectedDecColumn||e,this._decColumnList.push(e)}addHueColumn(e){this._hueColumnList.push(e)}addShapeColumn(e){this._shapeColumnList.push(e)}get selectedRaColumn(){return this._selectedRaColumn}get selectedDecColumn(){return this._selectedDecColumn}get selectedHueColumn(){return this._selectedHueColumn}get selectedShapeColumn(){return this._selectedShapeColumn}get selectedOutlineColumn(){return this._selectedOutlineColumn}get selectedNameColumn(){return this._selectedNameColumn}get columns(){return this._columns}get raColumnList(){return this._raColumnList}get decColumnList(){return this._decColumnList}get outlineColumnList(){return this._outlineColumnList}get hueColumnList(){return this._hueColumnList}get shapeColumnList(){return this._shapeColumnList}set selectedRaColumn(e){this._selectedRaColumn=this._raColumnList.find(t=>t.name===e)||this._selectedRaColumn}set selectedDecColumn(e){this._selectedDecColumn=this._decColumnList.find(t=>t.name===e)||this._selectedDecColumn}set selectedOutlineColumn(e){this._selectedOutlineColumn=this._outlineColumnList.find(t=>t.name===e)||this._selectedOutlineColumn}set selectedHueColumn(e){this._selectedHueColumn=this._hueColumnList.find(t=>t.name===e)}set selectedShapeColumn(e){this._selectedShapeColumn=this._shapeColumnList.find(t=>t.name===e)}set selectedNameColumn(e){this._selectedNameColumn=this._columns.find(t=>t.name===e)}resetShapeColumn(){this._selectedShapeColumn=void 0}resetHueColumn(){this._selectedHueColumn=void 0}}},5409:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.xyzTileRequestScheduler=t.XYZTileRequestScheduler=t.XYZTileRequestError=void 0;class r extends Error{cooldownMs;retryable;constructor(e,t,r=!0){super(e),this.name="XYZTileRequestError",this.cooldownMs=t,this.retryable=r}}t.XYZTileRequestError=r;class i{_maxConcurrent;_activeCount=0;_queue=[];_inflight=new Map;_hostBackoff=new Map;_sequence=0;constructor(e=4){this._maxConcurrent=e}setMaxConcurrent(e){this._maxConcurrent=Math.max(1,Math.floor(e)),this.pump()}getMaxConcurrent(){return this._maxConcurrent}getDebugStats(){const e=Date.now(),t=Array.from(this._hostBackoff.entries()).map(([t,r])=>({host:t,cooldownMs:Math.max(0,r.cooldownUntil-e),consecutiveFailures:r.consecutiveFailures})).filter(e=>e.cooldownMs>0||e.consecutiveFailures>0).sort((e,t)=>t.cooldownMs-e.cooldownMs);return{activeRequests:this._activeCount,queuedRequests:this._queue.length,inflightRequests:this._inflight.size,maxConcurrentRequests:this._maxConcurrent,highestQueuedPriority:this._queue[0]?.priority??null,hostsInBackoff:t}}load(e,t=0){const i=this._inflight.get(e);if(i)return i;const s=this.getHostCooldown(e),a=Date.now();if(s>a)return Promise.reject(new r(`Cooldown active for ${new URL(e).host}`,s-a));const o=new Promise((r,i)=>{this._queue.push({url:e,resolve:r,reject:i,priority:t,sequence:this._sequence++}),this._queue.sort((e,t)=>t.priority-e.priority||e.sequence-t.sequence),this.pump()}).finally(()=>{this._inflight.delete(e)});return this._inflight.set(e,o),o}pump(){for(;this._activeCount<this._maxConcurrent&&this._queue.length>0;){const e=this._queue.shift();if(!e)return;const t=this.getHostCooldown(e.url),i=Date.now();t>i?e.reject(new r(`Cooldown active for ${new URL(e.url).host}`,t-i)):(this._activeCount+=1,this.fetchBlob(e).then(e.resolve).catch(e.reject).finally(()=>{this._activeCount-=1,this.pump()}))}}async fetchBlob(e){try{const t=await fetch(e.url,{mode:"cors",cache:"force-cache"});if(!t.ok){const i=429===t.status||t.status>=500,s=this.registerFailure(e.url,i);throw new r(`HTTP ${t.status} loading ${e.url}`,i?s:3e5,i)}return this.registerSuccess(e.url),await t.blob()}catch(t){if(t instanceof r)throw t;const i=this.registerFailure(e.url,!1);throw new r(`Network/CORS failure loading ${e.url}`,i,!0)}}getHostCooldown(e){try{return this._hostBackoff.get(new URL(e).host)?.cooldownUntil??0}catch{return 0}}registerSuccess(e){try{const t=new URL(e).host;this._hostBackoff.set(t,{cooldownUntil:0,consecutiveFailures:0})}catch{}}registerFailure(e,t){if(!t)return 0;try{const t=new URL(e).host,r=(this._hostBackoff.get(t)??{cooldownUntil:0,consecutiveFailures:0}).consecutiveFailures+1,i=4e3,s=Math.min(12e4,i*2**Math.min(r-1,5));return this._hostBackoff.set(t,{cooldownUntil:Date.now()+s,consecutiveFailures:r}),s}catch{return 3e4}}}t.XYZTileRequestScheduler=i,t.xyzTileRequestScheduler=new i},5781:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TerraPointSetGL=void 0;const i=r(1232);class s extends i.CatalogueGL{_kind="TerraPointSetGL"}t.TerraPointSetGL=s},5803:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SphereFoV=void 0;const i=r(1961),s=r(7930);class a{static MIN_FOV_DEG=1e-6;fovXDeg=180;fovYDeg=180;ratio=0;_minFoV=180;_webgl;_lastModel=null;_lastCamera=null;constructor(e){this._webgl=e}getFoV(e,t,r,i){this._lastModel=t,this._lastCamera=r;const s=this._webgl.canvas;if(!s)return this.fovXDeg=180,this.fovYDeg=180,this._minFoV=this.minFoV,this;const a=s.getBoundingClientRect(),o=a.width,n=a.height;return this.fovXDeg=this.computeAngle(0,n/2,e,t,r,i).angleDeg,this.fovYDeg=this.computeAngle(o/2,0,e,t,r,i).angleDeg,this._minFoV=this.minFoV,this.ratio=this.computeRatio(r),this}computeRatio(e){const t=e.getCameraPosition();return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])/this.fovYDeg}get minFoV(){const e=this.fovYDeg<=this.fovXDeg?this.fovYDeg:this.fovXDeg;return this._minFoV=Math.max(e,a.MIN_FOV_DEG),this._minFoV}get xFoV(){return this.fovXDeg}get yFoV(){return this.fovYDeg}computeDistanceFromAngle(e){return e*this.ratio}changeMinFov(e){this.fovYDeg<=this.fovXDeg?this.fovYDeg=e:this.fovXDeg=e,this.minFoV}computeCameraPositionForMinFoV(e){return this.computeCameraPositionForFoV(e)}computeCameraPositionForFoV(e){return this.computeCameraPositionForAngularDiameter(e)}computeCameraPositionForAngularDiameter(e){if(!this._lastModel||!this._lastCamera)return[0,0,0];const t=1e-6,r=Math.max(t,Math.min(180-t,e))*Math.PI/360,s=Math.sin(r);if(s<=0)return[0,0,0];const a=this._lastModel,o=this._lastCamera,n=Math.max(a.radius/s,a.radius+1e-4),h=o.getCameraPosition(),l=i.vec3.fromValues(h[0]-a.center[0],h[1]-a.center[1],h[2]-a.center[2]);return i.vec3.length(l)<t?i.vec3.set(l,0,0,1):i.vec3.normalize(l,l),[a.center[0]+l[0]*n,a.center[1]+l[1]*n,a.center[2]+l[2]*n]}computeAngle(e,t,r,i,s,a){const o=this._webgl.canvas.getBoundingClientRect(),n=this.getIntersectionPointWithModel(o.width/2,o.height/2,i,s,a),h=this.getIntersectionPointWithModel(e,t,i,s,a);return n&&h?{angleDeg:2*this.computeAngularDistanceDeg(n.point,h.point),distance:h.distance}:{angleDeg:180,distance:-1}}computeAngularDistanceDeg(e,t){const r=i.vec3.normalize(i.vec3.create(),e),a=i.vec3.normalize(i.vec3.create(),t),o=i.vec3.dot(r,a),n=i.vec3.cross(i.vec3.create(),r,a),h=Math.atan2(i.vec3.length(n),Math.min(1,Math.max(-1,o)));return(0,s.radToDeg)(h)}getIntersectionPointWithModel(e,t,r,s,a){const o=this.getRayFromMouse(e,t,a,s.getCameraMatrix()),n=this.raySphere(s.getCameraPosition(),o,r);if(n<0)return null;const h=i.vec3.create();i.vec3.scale(h,o,n),i.vec3.add(h,s.getCameraPosition(),h);const l=[h[0],h[1],h[2],1],c=[0,0,0,0];return this.mat4MultiplyVec4(r.getModelMatrixInverse(),l,c),{point:i.vec3.fromValues(c[0],c[1],c[2]),distance:n}}getRayFromMouse(e,t,r,s){const a=this._webgl.canvas.getBoundingClientRect(),o=[2*e/a.width-1,1-2*t/a.height,-1,1],n=i.mat4.create();i.mat4.invert(n,r);const h=[0,0,0,0];this.mat4MultiplyVec4(n,o,h);const l=[h[0],h[1],-1,0],c=i.mat4.create();i.mat4.invert(c,s);const u=[0,0,0,0];this.mat4MultiplyVec4(c,l,u);const d=i.vec3.fromValues(u[0],u[1],u[2]);return i.vec3.normalize(d,d),d}raySphere(e,t,r){let s=-1;const a=i.vec3.create();i.vec3.subtract(a,e,r.center);const o=i.vec3.dot(t,a),n=o*o-(i.vec3.dot(a,a)-r.radius*r.radius);if(n>0){const e=Math.sqrt(n),t=-o+e,r=-o-e;(t>=0||r>=0)&&(s=r<0?t:Math.min(t,r))}else if(0===n){const e=-o;e>=0&&(s=e)}return s}mat4MultiplyVec4(e,t,r){r[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],r[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],r[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],r[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3]}}t.SphereFoV=a},5947:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{static catalogueVS(){return"#version 300 es\n in vec4 aCatPosition;\n in float a_selected;\n in float a_pointsize;\n in float a_brightness;\n\n out float v_selected;\n out float v_brightness;\n out lowp vec4 vColor; // not used\n\n uniform mat4 uPMatrix;\n uniform mat4 uMVMatrix;\n\n void main() {\n\n gl_Position = (uPMatrix * uMVMatrix * aCatPosition);\n gl_PointSize = a_pointsize;\n v_selected = a_selected;\n v_brightness = a_brightness;\n }"}static catalogueFS(){return"#version 300 es\n precision mediump float;\n \n #ifdef GL_OES_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n #endif\n\n // https://www.desultoryquest.com/blog/drawing-anti-aliased-circular-points-using-opengl-slash-webgl/\n\n // precision mediump float;\n\n in float v_selected;\n in float v_brightness;\n\n uniform vec4 u_fragcolor;\n\n out vec4 fragColor;\n\n // varying float v_selected;\n // varying float v_brightness;\n\n const float EPSILON = 1e-10;\n \n vec3 RGBtoHCV(in vec3 rgb) {\n // RGB [0..1] to Hue-Chroma-Value [0..1]\n // Based on work by Sam Hocevar and Emil Persson\n vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1., 2. / 3.) : vec4(rgb.gb, 0., -1. / 3.);\n vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);\n float c = q.x - min(q.w, q.y);\n float h = abs((q.w - q.y) / (6. * c + EPSILON) + q.z);\n return vec3(h, c, q.x);\n }\n\n vec3 RGBtoHSL(in vec3 rgb) {\n // RGB [0..1] to Hue-Saturation-Lightness [0..1]\n vec3 hcv = RGBtoHCV(rgb);\n //vec3 hcv = vec3(1., 1., 1.);\n float z = hcv.z - hcv.y * 0.5;\n float s = hcv.y / (1. - abs(z * 2. - 1.) + EPSILON);\n return vec3(hcv.x, s, z);\n }\n\n vec3 HUEtoRGB(in float hue){\n // Hue [0..1] to RGB [0..1]\n // See http://www.chilliant.com/rgb2hsv.html\n vec3 rgb = abs(hue * 6. - vec3(3, 2, 4)) * vec3(1, -1, -1) + vec3(-1, 2, 2);\n return clamp(rgb, 0., 1.);\n }\n\n vec3 HSLtoRGB(in vec3 hsl) {\n // Hue-Saturation-Lightness [0..1] to RGB [0..1]\n vec3 rgb = HUEtoRGB(hsl.x);\n float c = (1. - abs(2. * hsl.z - 1.)) * hsl.y;\n return (rgb - 0.5) * c + hsl.z;\n }\n \n void main() {\n\n float r = 0.0, delta = 0.0, alpha = 1.0;\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n r = dot(cxy, cxy);\n if (r > 1.0) {\n discard;\n }\n\n #ifdef GL_OES_standard_derivatives\n delta = fwidth(r);\n alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);\n #endif\n\n if (v_selected == 1.0){\n // gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * (alpha);\n fragColor = vec4(1.0, 0.0, 0.0, 1.0) * (alpha);\n } else if (v_selected == 2.0){\n // gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0) * (alpha);\n fragColor = vec4(1.0, 1.0, 0.0, 1.0) * (alpha);\n }else{\n if (r < 0.4) {\n discard;\n }\n if ( v_brightness >= -1.0 && v_brightness <= 1.0) {\n // Round-trip RGB->HSL->RGB with time-dependent lightness\n vec3 hsl = RGBtoHSL(vec3(u_fragcolor));\n //hsl.z = pow(hsl.z, sin(iTime) + 1.5);\n // hsl.z = pow(hsl.z, v_brightness + 1.5);\n hsl.z = pow(hsl.z, v_brightness + 1.5);\n vec3 hslcolor = HSLtoRGB(hsl);\n // gl_FragColor = vec4(hslcolor, u_fragcolor[3]) * (alpha);\n fragColor = vec4(hslcolor, u_fragcolor[3]) * (alpha);\n } else {\n // gl_FragColor = u_fragcolor * (alpha);\n fragColor = u_fragcolor * (alpha);\n }\n }\n }"}static footprintVS(){return"#version 300 es\n precision highp float;\n\n layout(location = 0) in vec4 aCatPosition;\n\n uniform float u_pointsize;\n uniform mat4 uMVMatrix;\n uniform mat4 uPMatrix;\n\n void main() {\n gl_Position = uPMatrix * uMVMatrix * aCatPosition;\n gl_PointSize = u_pointsize; // Works in WebGL2\n }"}static footprintFS(){return"#version 300 es\n precision mediump float;\n\n uniform vec4 u_fragcolor;\n out vec4 fragColor;\n\n void main() {\n fragColor = u_fragcolor;\n }"}static hipsVS(){return"#version 300 es\n in vec3 aVertexPosition;\n in vec2 aTextureCoord;\n\n uniform mat4 uMMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uPMatrix;\n\n out vec2 vTextureCoord;\n\n void main() {\n gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);\n vTextureCoord = aTextureCoord;\n }"}static hipsNativeFS(){return"#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n uniform sampler2D uSampler0;\n uniform sampler2D uSampler1;\n uniform sampler2D uSampler2;\n uniform sampler2D uSampler3;\n uniform sampler2D uSampler4;\n uniform sampler2D uSampler5;\n uniform sampler2D uSampler6;\n uniform sampler2D uSampler7;\n\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0){\n vec4 mycolor;\n #if __VERSION__ > 120\n vec4 color0 = texture(uSampler0, vTextureCoord);\n #else\n vec4 color0 = texture2D(uSampler0, vTextureCoord);\n #endif\n mycolor = color0;\n finalColor += mycolor.rgb * uFactor0;\n } else if (uFactor7 >= 0.0){\n finalColor = vec3(1.0, 0.0, 0.0);\n }\n fragColor = vec4(finalColor, 1.0);\n }"}static hipsGrayscaleFS(){return"#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n uniform sampler2D uSampler0;\n uniform sampler2D uSampler1;\n uniform sampler2D uSampler2;\n uniform sampler2D uSampler3;\n uniform sampler2D uSampler4;\n uniform sampler2D uSampler5;\n uniform sampler2D uSampler6;\n uniform sampler2D uSampler7;\n\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0){\n #if __VERSION__ > 120\n vec4 color0 = texture(uSampler0, vTextureCoord);\n #else\n vec4 color0 = texture2D(uSampler0, vTextureCoord);\n #endif\n float gray = 0.21 * color0.r + 0.71 * color0.g + 0.07 * color0.b;\n finalColor = color0.rgb * (1.0 - uFactor0) + vec3(gray) * uFactor0;\n }\n if (uFactor1 >= 0.0){\n #if __VERSION__ > 120\n vec4 color1 = texture(uSampler1, vTextureCoord);\n #else\n vec4 color1 = texture2D(uSampler1, vTextureCoord);\n #endif\n finalColor += color1.rgb * uFactor1;\n }\n if (uFactor2 >= 0.0){\n #if __VERSION__ > 120\n vec4 color2 = texture(uSampler2, vTextureCoord);\n #else\n vec4 color2 = texture2D(uSampler2, vTextureCoord);\n #endif\n finalColor += color2.rgb * uFactor2;\n }\n if (uFactor3 >= 0.0){\n #if __VERSION__ > 120\n vec4 color3 = texture(uSampler3, vTextureCoord);\n #else\n vec4 color3 = texture2D(uSampler3, vTextureCoord);\n #endif\n finalColor += color3.rgb * uFactor3;\n }\n if (uFactor4 >= 0.0){\n #if __VERSION__ > 120\n vec4 color4 = texture(uSampler4, vTextureCoord);\n #else\n vec4 color4 = texture2D(uSampler4, vTextureCoord);\n #endif\n finalColor += color4.rgb * uFactor4;\n }\n if (uFactor5 >= 0.0){\n #if __VERSION__ > 120\n vec4 color5 = texture(uSampler5, vTextureCoord);\n #else\n vec4 color5 = texture2D(uSampler5, vTextureCoord);\n #endif\n finalColor += color5.rgb * uFactor5;\n }\n if (uFactor6 >= 0.0){\n #if __VERSION__ > 120\n vec4 color6 = texture(uSampler6, vTextureCoord);\n #else\n vec4 color6 = texture2D(uSampler6, vTextureCoord);\n #endif\n finalColor += color6.rgb * uFactor6;\n }\n if (uFactor7 >= 0.0){\n #if __VERSION__ > 120\n vec4 color7 = texture(uSampler7, vTextureCoord);\n #else\n vec4 color7 = texture2D(uSampler7, vTextureCoord);\n #endif\n finalColor += color7.rgb * uFactor7;\n }\n fragColor = vec4(finalColor, 1.0);\n }"}static hipsColorMapFS(){return"#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n // UBO\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n uniform sampler2D uSampler0;\n uniform float uFactor0;\n\n out vec4 fragColor;\n\n void main() {\n #if __VERSION__ > 120\n vec4 color0 = texture(uSampler0, vTextureCoord);\n #else\n vec4 color0 = texture2D(uSampler0, vTextureCoord);\n #endif\n\n int x = int(color0.r * 255.0);\n float px = r_palette[x] / 256.0;\n\n int y = int(color0.g * 255.0);\n float py = g_palette[y] / 256.0;\n\n int z = int(color0.b * 255.0);\n float pz = b_palette[z] / 256.0;\n\n // uFactor0 reserved for future blending if needed\n fragColor = vec4(px, py, pz, 1.0);\n }"}}},6553:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Point=void 0;const s=r(1961),a=r(7930),o=r(8145),n=i(r(4382));class h{_x;_y;_z;_xyz;_raDeg;_decDeg;_raRad;_decRad;_raDecDeg;_lonLatDeg;constructor(e,t){this._xyz=[0,0,0],this._raDecDeg=[0,0];const r=n.default.MAX_DECIMALS??12;if(t===o.CoordsType.CARTESIAN){const{x:t,y:i,z:s}=e;this._x=Number(t.toFixed(r)),this._y=Number(i.toFixed(r)),this._z=Number(s.toFixed(r)),this._xyz=[this._x,this._y,this._z];const[a,o]=this.computeAstroCoords();this._raDeg=Number(a),this._decDeg=Number(o),this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180,this._raDecDeg=[this._raDeg,this._decDeg]}else if(t===o.CoordsType.ASTRO){const{raDeg:t,decDeg:i}=e;this._raDeg=Number(t),this._decDeg=Number(i),this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,a,o]=this.computeCartesianCoords();this._x=Number(s.toFixed(r)),this._y=Number(a.toFixed(r)),this._z=Number(o.toFixed(r)),this._xyz=[this._x,this._y,this._z]}else if(t===o.CoordsType.GEOGRAPHIC){const{lonDeg:t,latDeg:i}=e;this._lonLatDeg=[Number(t),Number(i)],this._raDeg=this._lonLatDeg[0],this._decDeg=this._lonLatDeg[1],this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,a,o]=this.computeCartesianCoords();this._x=Number(s.toFixed(r)),this._y=Number(a.toFixed(r)),this._z=Number(o.toFixed(r)),this._xyz=[this._x,this._y,this._z]}else t===o.CoordsType.SPHERICAL?(console.log(`${o.CoordsType.SPHERICAL} not implemented yet`),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0):(console.error("CoordsType "+String(t)+" not recognised."),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0)}computeAstroCoords(){const e=(0,a.cartesianToSpherical)(s.vec3.fromValues(this._xyz[0],this._xyz[1],this._xyz[2])),t=(0,a.sphericalToAstroDeg)(e.phi,e.theta);return[t.ra,t.dec]}computeCartesianCoords(){const e=(0,a.astroDegToSpherical)(this._raDeg,this._decDeg),[t,r,i]=(0,a.sphericalToCartesian)(e.phi,e.theta,1);return[t,r,i]}computeHealpixPhiTheta(){return(0,a.astroDegToSpherical)(this._raDeg,this._decDeg)}scale(e){return new h({x:this.x*e,y:this.y*e,z:this.z*e},o.CoordsType.CARTESIAN)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}cross(e){return new h({x:this.y*e.z-e.y*this.z,y:this.z*e.x-e.z*this.x,z:this.x*e.y-e.x*this.y},o.CoordsType.CARTESIAN)}norm(){const e=1/this.length();return new h({x:this.x*e,y:this.y*e,z:this.z*e},o.CoordsType.CARTESIAN)}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}subtract(e){return new h({x:this.x-e.x,y:this.y-e.y,z:this.z-e.z},o.CoordsType.CARTESIAN)}add(e){return new h({x:this.x+e.x,y:this.y+e.y,z:this.z+e.z},o.CoordsType.CARTESIAN)}get x(){return this._x}get y(){return this._y}get z(){return this._z}get xyz(){return this._xyz}get raDeg(){return this._raDeg}get decDeg(){return this._decDeg}get raDecDeg(){return this._raDecDeg}get lonDeg(){return this._lonLatDeg?.[0]??this._raDeg}get latDeg(){return this._lonLatDeg?.[1]??this._decDeg}get lonLatDeg(){return this._lonLatDeg??[this._raDeg,this._decDeg]}toADQL(){return`${this._raDecDeg[0]},${this._raDecDeg[1]}`}toString(){return`(raDeg, decDeg) => (${this._raDecDeg[0]},${this._raDecDeg[1]}) (x, y,z) => (${this._xyz[0]},${this._xyz[1]},${this._xyz[2]})`}}t.Point=h},6878:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPS=void 0;const i=r(4735),s=r(229),a=r(2257),o=r(8170);class n extends i.AbstractSkyEntity{_descriptor;_healpixGrid;_shaderProgram;_tiles=new Map;_currentOrder;_visibleTiles=[];_coverageTiles=[];constructor(e,t,r,i,s,o,n){super(e,t,r,i,s.name,o,!1),this._descriptor=s,this._healpixGrid=n,this.initGL(o),this._shaderProgram=new a.MeshHiPSShaderProgram(o),this._shaderProgram.enableProgram(),this._currentOrder=s.selectedOrder}get currentOrder(){return this._currentOrder}get maxOrder(){return this._descriptor.maxOrder}get minOrder(){return this._descriptor.minOrder}get baseURL(){return this._descriptor.baseUrl}get propertiesRawText(){return this._descriptor.propertiesRawText}get properties(){return this._descriptor.properties}getProperty(e){return this._descriptor.getProperty(e)}refreshOrder(e){if(this._descriptor.fixedOrder)return this._currentOrder=this._descriptor.selectedOrder,this._currentOrder;const t=Number.isFinite(e)&&e>0?e:this._healpixGrid.getMinFoV(),r=Number.isFinite(t)&&t>0?t:1e-6,i=s.fovHelper.getHiPSNorder(r,this._currentOrder);return this._currentOrder=Math.max(this._descriptor.minOrder,Math.min(this._descriptor.maxOrder,i)),this._currentOrder}draw(e){const t=e.camera.getCameraMatrix();if(!t||!e.pMatrix)return;this.refreshOrder(e.fovDeg),this._visibleTiles=this.resolveVisibleTiles(),this._coverageTiles=this.resolveCoverageTiles(this._visibleTiles),this.ensureTiles(this._coverageTiles),this.evictCached();const r=this._webgl,i=e.pMatrix,s=this.getModelMatrix(),a=r.isEnabled(r.CULL_FACE),o=r.isEnabled(r.DEPTH_TEST),n=r.getParameter(r.DEPTH_WRITEMASK),h=r.getParameter(r.DEPTH_FUNC);r.enable(r.DEPTH_TEST),r.depthMask(!0),r.depthFunc(r.LEQUAL),r.disable(r.CULL_FACE);const l=this.groupTilesByOrder(this._coverageTiles),c=Array.from(l.keys()).sort((e,t)=>e-t);for(const e of c)for(const r of l.get(e)??[])this._tiles.get(this.tileKey(r))?.draw(i,t,s,this._descriptor.color,this._descriptor.wireframe);a&&r.enable(r.CULL_FACE),o||r.disable(r.DEPTH_TEST),r.depthFunc(h),r.depthMask(n)}getDebugStats(){const e=Array.from(this._tiles.values());return{activeBaseLayer:"meships",meshHiPSName:this._descriptor.name,meshHiPSUrl:this._descriptor.baseUrl,currentOrder:this._currentOrder,visibleTileCount:this._visibleTiles.length,coverageTileCount:this._coverageTiles.length,cacheSize:this._tiles.size,readyTileCount:e.filter(e=>e.ready).length,loadingTileCount:e.filter(e=>e.loading).length,failedTileCount:e.filter(e=>e.failed).length}}resolveVisibleTiles(){const e=this._healpixGrid.visibleTilesManager,t=e?.visibleTilesByOrder,r=t?.order===this._currentOrder&&Array.isArray(t.pixels)?t.pixels:[];if(r.length>0)return r.map(e=>({order:this._currentOrder,ipix:e}));const i=12*4**this._currentOrder;return Array.from({length:i},(e,t)=>({order:this._currentOrder,ipix:t}))}resolveCoverageTiles(e){const t=new Map,r=e=>{e.order<this._descriptor.minOrder||e.order>this._descriptor.maxOrder||t.set(this.tileKey(e),e)};for(const t of e){r(t);for(let e=t.order-1;e>=this._descriptor.minOrder;e--){const i=2*(t.order-e);r({order:e,ipix:t.ipix>>i})}}const i=this._healpixGrid.visibleTilesManager,s=i?.ancestorsMap;if(s)for(const[e,t]of s)if(!(e<this._descriptor.minOrder||e>this._descriptor.maxOrder))for(const i of t)r({order:e,ipix:i});return Array.from(t.values())}groupTilesByOrder(e){const t=new Map;for(const r of e){const e=t.get(r.order)??[];e.push(r),t.set(r.order,e)}return t}ensureTiles(e){for(const t of e){const e=this.tileKey(t);this._tiles.has(e)||this._tiles.set(e,new o.MeshHiPSTile(t,this._descriptor.getTileUrl(t.order,t.ipix),this._webgl,this._shaderProgram))}}evictCached(){const e=this._descriptor.maxCachedTiles;if(this._tiles.size<=e)return;const t=new Set(this._coverageTiles.map(e=>this.tileKey(e))),r=Array.from(this._tiles.entries()).filter(([e])=>!t.has(e)).sort((e,t)=>e[1].lastUsedAt-t[1].lastUsedAt);for(;this._tiles.size>e&&r.length>0;){const[e,t]=r.shift();t.dispose(),this._tiles.delete(e)}}tileKey(e){return`${e.order}/${e.ipix}`}}t.MeshHiPS=n},6937:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XYZVisibleTilesManager=void 0;const s=i(r(2166));t.XYZVisibleTilesManager=class{_ancestorsMap=new Map;_visibleTilesMap=new Map;_visibleTiles=[];_selection={key:"0:",currentZoom:0,visibleTiles:[],visibleTilesMap:new Map,ancestorsMap:new Map};get ancestorsMap(){return this._ancestorsMap}get visibleTiles(){return this._visibleTiles}get visibleTilesMap(){return this._visibleTilesMap}get selection(){return this._selection}computeVisibleTiles(e,t,r,i,a,o=9,n=2){return this._visibleTiles=s.default.getVisibleTilesFromViewport(e,t,r,i,a,o,n),this._visibleTilesMap=this.buildTileMap(this._visibleTiles),this.refreshAncestorsMap(this._visibleTiles),this._selection={key:this.buildSelectionKey(e,this._visibleTiles),currentZoom:e,visibleTiles:this._visibleTiles,visibleTilesMap:this._visibleTilesMap,ancestorsMap:this._ancestorsMap},this._selection}refreshAncestorsMap(e){this._ancestorsMap.clear();for(const t of e)for(let e=t.z-1;e>=0;e--){const r=t.z-e,i={z:e,x:t.x>>r,y:t.y>>r};this._ancestorsMap.set(`${i.z}/${i.x}/${i.y}`,i)}}buildTileMap(e){const t=new Map;for(const r of e)t.set(this.key(r),r);return t}buildSelectionKey(e,t){return`${e}:${t.map(e=>`${e.x}/${e.y}`).join("|")}`}key(e){return`${e.z}/${e.x}/${e.y}`}}},7559:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{_x;_y;constructor(e,t){this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}}},7734:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(1961),a=r(7930),o=i(r(4382));t.default=class{insideSphere=!1;cam_pos=s.vec3.create();cam_speed=1;vMatrix=s.mat4.create();T=s.mat4.create();R=s.mat4.create();FoV=180;previousFoV=180;move=s.vec3.create();phi=0;theta=0;rotationSensitivity=1;lockRotX=!1;lockRotY=!1;lockRotZ=!1;constructor(e,t){this.init(e,t)}init(e,t){this.insideSphere=t,this.cam_pos=s.vec3.clone(e),this.vMatrix=s.mat4.create(),this.T=s.mat4.create(),this.R=s.mat4.create(),s.mat4.translate(this.T,this.T,[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]),this.FoV=this.previousFoV=180,this.move=s.vec3.clone([0,0,0]),this.goTo(0,0)}goTo(e,t){this.goToPhiTheta((0,a.astroDegToSpherical)(e,t))}goToPhiTheta(e){const t=(0,a.sphericalToCartesian)(e.phi,e.theta,this.cam_pos[2]),r=s.vec3.normalize(s.vec3.create(),s.vec3.fromValues(t[0],t[1],t[2])),i=s.vec3.fromValues(0,0,1),o=s.vec3.scale(s.vec3.create(),r,s.vec3.dot(i,r)),n=s.vec3.subtract(s.vec3.create(),i,o);s.vec3.length(n)<1e-6?s.vec3.set(n,0,1,0):s.vec3.normalize(n,n);let h=s.mat4.create();h=s.mat4.translate(h,h,s.vec3.fromValues(t[0],t[1],t[2]));const l=[h[12],h[13],h[14]];h=s.mat4.targetTo(h,l,[0,0,0],n),this.R=s.mat4.clone(h),this.R[12]=0,this.R[13]=0,this.R[14]=0;const c=s.mat4.create();0!==this.cam_pos[2]&&s.mat4.invert(c,h),this.vMatrix=c}toggleInsideSphere(){this.insideSphere=o.default.insideSphere,o.default.insideSphere?(this.cam_pos[0]=0,this.cam_pos[1]=0,this.cam_pos[2]=-.005):this.cam_pos[2]=2+this.cam_pos[2],s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}zoom(e){if(this.move=s.vec3.clone([0,0,0]),this.move[2]+=this.cam_speed*e,o.default.insideSphere)this.cam_pos[2]+this.move[2]>=-.005&&e>0?(this.cam_pos[2]=-.005,e=0):this.cam_pos[2]+this.move[2]<=-.9885&&e<0?(this.cam_pos[2]=-.9885,e=0):this.cam_pos[2]+=this.move[2];else{const t=Math.max(this.cam_pos[2]-1,1e-6),r=Math.min(1,t/.3),i=.015+.985*Math.pow(r,1.2);this.move[2]*=i,this.cam_pos[2]+this.move[2]<=1.000001&&e<0?this.cam_pos[2]=1.000001:this.cam_pos[2]+=this.move[2]}const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}moveAlongView(e){const t=s.mat4.create();s.mat4.invert(t,this.R);const r=s.vec3.fromValues(0,0,-1),i=s.vec3.create();s.vec3.transformMat4(i,r,t);const a=Math.hypot(i[0],i[1],i[2]);a>0&&(i[0]/=a,i[1]/=a,i[2]/=a),this.cam_pos[0]+=i[0]*e,this.cam_pos[1]+=i[1]*e,this.cam_pos[2]+=i[2]*e;const o=s.mat4.create();s.mat4.translate(this.T,o,this.cam_pos),this.refreshViewMatrix()}translate(e){this.cam_pos[2]=e+1;const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}rotateX(e){if(this.lockRotX)return;const t=.01*e;this.theta+=t,s.mat4.rotate(this.R,this.R,t,[1,0,0]),this.refreshViewMatrix()}rotateY(e){if(this.lockRotY)return;const t=.01*e;this.phi+=t,s.mat4.rotate(this.R,this.R,t,[0,1,0]),this.refreshViewMatrix()}rotateZ(e){if(this.lockRotZ)return;const t=.01*e;s.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshViewMatrix()}rotateXRadian(e){this.lockRotX||(s.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshViewMatrix())}rotateYRadian(e){this.lockRotY||(this.phi+=e,s.mat4.rotate(this.R,this.R,e,[0,1,0]),this.refreshViewMatrix())}rotateZRadian(e){this.lockRotZ||(s.mat4.rotate(this.R,this.R,e,[0,0,1]),this.refreshViewMatrix())}rotate(e,t){if(this.lockRotZ)return;const r=Math.sqrt(e*e+t*t);if(0===r)return;const i=this.getCameraPosition(),a=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]),o=Math.max(a-1,1e-6),n=Math.min(1,o/.45),h=.02+.98*Math.pow(n,1.55),l=Math.min(1,this.FoV/18),c=r*h*(.06+1.55*Math.pow(l,.52))/1.9*this.rotationSensitivity;let u=t,d=e;const _=Math.sqrt(u*u+d*d);0!==_&&(u/=_,d/=_,s.mat4.rotate(this.R,this.R,-c,[u,d,0]),this.refreshViewMatrix())}setRotationSensitivity(e){this.rotationSensitivity=Math.min(3,Math.max(.2,e))}getRotationSensitivity(){return this.rotationSensitivity}refreshViewMatrix(){const e=s.mat4.create(),t=s.mat4.create();s.mat4.invert(e,this.T),s.mat4.invert(t,this.R),s.mat4.multiply(this.vMatrix,e,t)}refreshFoV(e){this.previousFoV=this.FoV,this.FoV=e}getCameraMatrix(){return this.vMatrix}getCameraPosition(){const e=s.mat4.create();return s.mat4.invert(e,this.vMatrix)?[e[12],e[13],e[14]]:[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]}setCameraMatrix(e){this.vMatrix=e}setCameraPosition(e){this.cam_pos=s.vec3.fromValues(e[0],e[1],e[2]),s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}getCameraAngle(){const[e,t,r]=this.getCameraPosition(),i=s.vec3.fromValues(e,t,r),o=(0,a.cartesianToSpherical)(i);return console.log("[Camera::getCameraAngle]",o),o}setRotationLock(e){void 0!==e.x&&(this.lockRotX=e.x),void 0!==e.y&&(this.lockRotY=e.y),void 0!==e.z&&(this.lockRotZ=e.z)}clearRotationLock(){this.lockRotX=this.lockRotY=this.lockRotZ=!1}isRotationLockedX(){return this.lockRotX}isRotationLockedY(){return this.lockRotY}isRotationLockedZ(){return this.lockRotZ}}},7786:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSShaderProgram=void 0;const s=i(r(5947)),a=r(619);t.HiPSShaderProgram=class{_colorMapBlockIndex=null;_runtimeColorMap;_shaderProgram;_vertexShader;_fragmentShader;_UBO_colorMapBuffer=null;_UBO_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={sampler:"uSampler0",factor:"uFactor0",m_perspective:"uPMatrix",m_model:"uMMatrix",m_view:"uVMatrix",colormapIdx:"cmapIdx",colormap_red:"r",colormap_green:"g",colormap_blue:"b"},this.gl_attributes={vertex_pos:"aVertexPosition",text_coords:"aTextureCoord"},this.locations={pMatrix:null,mMatrix:null,vMatrix:null,sampler:null,textureAlpha:null,clorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;return this._shaderProgram||(this._shaderProgram=e.createProgram(),this.initShaders()),e.useProgram(this._shaderProgram),this._shaderProgram}setRuntimeColorMap(e){this._runtimeColorMap=e}initShaders(){const e=this._webgl,t=s.default.hipsNativeFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const r=s.default.hipsVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,r),e.compileShader(this._vertexShader),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this._shaderProgram,this._vertexShader),e.attachShader(this._shaderProgram,this._fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders")):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setGrayscaleShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=s.default.hipsGrayscaleFS();this.changeFSShader(e)}setNativeShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=s.default.hipsNativeFS();this.changeFSShader(e)}setColorMapShader(){const e=this._webgl;e.detachShader(this.shaderProgram,this._fragmentShader);const t=s.default.hipsColorMapFS();this.changeFSShader(t);const r=e.getUniformBlockIndex(this.shaderProgram,"colormap");if(r===e.INVALID_INDEX)return console.warn('HiPSShaderProgram: uniform block "colormap" not found in hipsColorMapFS()'),this._colorMapBlockIndex=null,void(this._UBO_colorMapBuffer=null);this._colorMapBlockIndex=r;const i=["r_palette","g_palette","b_palette"],a=e.getUniformIndices(this.shaderProgram,i),o=e.getActiveUniforms(this.shaderProgram,a,e.UNIFORM_OFFSET);if(!this._UBO_colorMapBuffer){this._UBO_colorMapBuffer=e.createBuffer(),e.bindBuffer(e.UNIFORM_BUFFER,this._UBO_colorMapBuffer);const t=12288;e.bufferData(e.UNIFORM_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,0,this._UBO_colorMapBuffer)}i.forEach((e,t)=>{this._UBO_colorMapVariableInfo[e]={index:a[t],offset:o[t]}})}changeFSShader(e){const t=this._webgl;this._fragmentShader=t.createShader(t.FRAGMENT_SHADER),t.shaderSource(this._fragmentShader,e),t.compileShader(this._fragmentShader),t.getShaderParameter(this._fragmentShader,t.COMPILE_STATUS)?(t.attachShader(this.shaderProgram,this._fragmentShader),t.linkProgram(this.shaderProgram),t.getProgramParameter(this.shaderProgram,t.LINK_STATUS)||alert("Could not initialise shaders"),t.useProgram(this.shaderProgram)):alert(t.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error")}enableShaders(e,t,r,i){const s=this._webgl;if(s.useProgram(this.shaderProgram),this.locations.pMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model),this.locations.vMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_view),this.locations.sampler=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.sampler),this.locations.textureAlpha=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.factor),this.locations.clorMapIdx=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.colormapIdx),s.uniform1i(this.locations.clorMapIdx,i),this.locations.sampler&&s.uniform1i(this.locations.sampler,0),this.locations.vertexPositionAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.textureCoordAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.text_coords),i>=2&&this._UBO_colorMapBuffer&&null!==this._colorMapBlockIndex){let e;if(s.uniformBlockBinding(this.shaderProgram,this._colorMapBlockIndex,0),s.bindBuffer(s.UNIFORM_BUFFER,this._UBO_colorMapBuffer),2===i?e={r:a.ColorMaps.planck.r,g:a.ColorMaps.planck.g,b:a.ColorMaps.planck.b}:3===i?e={r:a.ColorMaps.cmb.r,g:a.ColorMaps.cmb.g,b:a.ColorMaps.cmb.b}:4===i?e={r:a.ColorMaps.rainbow.r,g:a.ColorMaps.rainbow.g,b:a.ColorMaps.rainbow.b}:5===i?e={r:a.ColorMaps.eosb.r,g:a.ColorMaps.eosb.g,b:a.ColorMaps.eosb.b}:6===i?e={r:a.ColorMaps.cubehelix.r,g:a.ColorMaps.cubehelix.g,b:a.ColorMaps.cubehelix.b}:7===i?e={r:a.ColorMaps.hot.r,g:a.ColorMaps.hot.g,b:a.ColorMaps.hot.b}:8===i&&(e={r:a.ColorMaps.gray.r,g:a.ColorMaps.gray.g,b:a.ColorMaps.gray.b}),e||(e=this._runtimeColorMap),e){const t=this._UBO_colorMapVariableInfo;s.bufferSubData(s.UNIFORM_BUFFER,t.r_palette.offset,e.r,0),s.bufferSubData(s.UNIFORM_BUFFER,t.g_palette.offset,e.g,0),s.bufferSubData(s.UNIFORM_BUFFER,t.b_palette.offset,e.b,0)}s.bindBuffer(s.UNIFORM_BUFFER,null)}s.uniformMatrix4fv(this.locations.mMatrix,!1,r),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t)}}},7930:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cartesianToSpherical=function(e){const t=i.vec3.dot(e,e),r=Math.sqrt(t);let s=Math.acos(e[2]/r);s=a(s);let o=Math.atan2(e[1],e[0]);return o=a(o),o<0&&(o+=360),{phi:o,theta:s}},t.colorHex2RGB=function(e){const t=e.substring(1,3),r=e.substring(3,5),i=e.substring(5,7),s=parseInt(t,16),a=parseInt(r,16),o=parseInt(i,16),n=(s/255).toFixed(2),h=(a/255).toFixed(2),l=(o/255).toFixed(2);return[parseFloat(n),parseFloat(h),parseFloat(l)]},t.degToRad=s,t.radToDeg=a,t.sphericalToAstroDeg=function(e,t){let r=e;return r<0&&(r+=360),{ra:r,dec:90-t}},t.sphericalToCartesian=function(e,t,r=1){return[r*Math.sin(s(t))*Math.cos(s(e)),r*Math.sin(s(t))*Math.sin(s(e)),r*Math.cos(s(t))]},t.astroDegToSpherical=function(e,t){let r=e;return r<0&&(r+=360),{phi:r,theta:90-t}},t.raDegToHMS=function(e){const t=Math.floor(e/15),r=Math.floor(60*(e/15-t));return{h:t,m:r,s:3600*(e/15-t-r/60)}},t.decDegToDMS=function(e){let t=1;e<0&&(t=-1);const r=Math.abs(e);let i=Math.trunc(r);const s=Math.trunc(60*(r-i)),a=3600*(r-i-s/60);return i*=t,{d:i,m:s,s:a}};const i=r(1961);function s(e){return e/180*Math.PI}function a(e){return 180*e/Math.PI}},8083:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FoVUtils=void 0;const s=r(6553),a=i(r(4639)),o=r(8145),n=r(1961);class h{getMinFoV(){return this._fovY_deg<=this._fovX_deg?this._fovY_deg:this._fovX_deg}static getFoVPolygon(e,t,r,i,s,o){const l=e.getCameraMatrix(),c=r.getModelMatrix(),u=t.clientWidth,d=t.clientHeight;let _=[];if(a.default.getIntersectionPointWithSingleModel(0,0,i,s,e,o).length>0)_=h.getScreenCornersIntersection(o,e,t,i,s);else{let t=n.mat4.create();t=n.mat4.multiply(t,l,c),t=n.mat4.multiply(t,o,t);const r=[t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]],f=[t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]],g=[t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]],p=[t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]],m=a.default.getIntersectionPointWithSingleModel(u/2,0,i,s,e,o),M=a.default.getIntersectionPointWithSingleModel(u,d/2,i,s,e,o);if(0===m.length&&0===M.length){const e=h.getNearestSpherePoint(r),t=h.getNearestSpherePoint(f),i=h.getNearestSpherePoint(p),s=h.getNearestSpherePoint(g),a=h.computeMiddlePoint(i[0],e[0])[0],o=h.computeMiddlePoint(e[0],s[0])[0],n=h.computeMiddlePoint(s[0],t[0])[0],l=h.computeMiddlePoint(t[0],i[0])[0];_.push(e[0],o,s[0],n,t[0],l,i[0],a)}else if(0===m.length){const e=h.getNearestSpherePoint(r),i=h.getNearestSpherePoint(f),s=h.getFrustumIntersectionWithSphere(t,p,f,r),a=h.getFrustumIntersectionWithSphere(t,g,r,f),o=h.computeMiddlePoint(s[1],e[0])[0],n=h.computeMiddlePoint(e[0],a[0])[0],l=h.computeMiddlePoint(a[1],i[0])[0],c=h.computeMiddlePoint(i[0],s[0])[0];_.push(e[0],n,a[0],a[1],l,i[0],c,s[0],s[1],o)}else if(0===M.length){const e=h.getFrustumIntersectionWithSphere(t,r,p,g),i=h.getFrustumIntersectionWithSphere(t,f,g,p),s=h.getNearestSpherePoint(p),a=h.getNearestSpherePoint(g),o=h.computeMiddlePoint(s[0],e[0])[0],n=h.computeMiddlePoint(e[1],a[0])[0],l=h.computeMiddlePoint(a[0],i[0])[0],c=h.computeMiddlePoint(i[1],s[0])[0];_.push(e[0],e[1],n,a[0],l,i[0],i[1],c,s[0],o)}else{const e=h.getFrustumIntersectionWithSphere(t,r,p,g),i=h.getFrustumIntersectionWithSphere(t,f,g,p),s=h.getFrustumIntersectionWithSphere(t,p,f,r),a=h.getFrustumIntersectionWithSphere(t,g,r,f);_.push(e[0],e[1],a[0],a[1],i[0],i[1],s[0],s[1])}}return _}static getScreenCornersIntersection(e,t,r,i,n){const h=r.clientWidth,l=r.clientHeight,c=a.default.getIntersectionPointWithSingleModel(0,0,i,n,t,e),u=a.default.getIntersectionPointWithSingleModel(h/2,0,i,n,t,e),d=a.default.getIntersectionPointWithSingleModel(h,0,i,n,t,e),_=a.default.getIntersectionPointWithSingleModel(h,l/2,i,n,t,e),f=a.default.getIntersectionPointWithSingleModel(h,l,i,n,t,e),g=a.default.getIntersectionPointWithSingleModel(h/2,l,i,n,t,e),p=a.default.getIntersectionPointWithSingleModel(0,l,i,n,t,e),m=a.default.getIntersectionPointWithSingleModel(0,l/2,i,n,t,e),M=[],x=e=>{e.length>0&&M.push(new s.Point({x:e[0],y:e[1],z:e[2]},o.CoordsType.CARTESIAN))};return x(c),x(u),x(d),x(_),x(f),x(g),x(p),x(m),M}static getCenterJ2000(e,t,r,i,n){const h=e.clientWidth,l=e.clientHeight,c=a.default.getIntersectionPointWithSingleModel(h/2,l/2,t,r,i,n);if(c.length<=0)throw Error("Central point is null");return new s.Point({x:c[0],y:c[1],z:c[2]},o.CoordsType.CARTESIAN)}static computeMiddlePoint(e,t){const r=(e.x+t.x)/2,i=(e.y+t.y)/2,a=(e.z+t.z)/2,n=Math.hypot(r,i,a)||1,h=r/n,l=i/n,c=a/n;return[new s.Point({x:h,y:l,z:c},o.CoordsType.CARTESIAN)]}static getNearestSpherePoint(e){const[t,r,i,a]=e,n=1/Math.sqrt(t*t+r*r+i*i),h=1*n,l=-1*n,c=[t*h,r*h,i*h],u=[t*l,r*l,i*l],d=Math.sqrt(t*t+r*r+i*i)||1,_=Math.abs(t*c[0]+r*c[1]+i*c[2]+a)/d<=Math.abs(t*u[0]+r*u[1]+i*u[2]+a)/d?c:u;return[new s.Point({x:_[0],y:_[1],z:_[2]},o.CoordsType.CARTESIAN)]}static getFrustumIntersectionWithSphere(e,t,r,i){const[a,n,h,l]=t,c=a*a+n*n+h*h||1,u=-a*l/c,d=-n*l/c,_=-h*l/c,f=Math.abs(l)/Math.sqrt(c),g=[];if(1>f){const e=Math.sqrt(1-f*f),t=t=>{const[r,i,s,a]=t,o=1/Math.sqrt(r*r+i*i+s*s),n=e*o,h=-e*o,l=[u+r*n,d+i*n,_+s*n],c=[u+r*h,d+i*h,_+s*h],f=Math.sqrt(r*r+i*i+s*s)||1;return Math.abs(r*l[0]+i*l[1]+s*l[2]+a)/f<=Math.abs(r*c[0]+i*c[1]+s*c[2]+a)/f?l:c},a=t(r),n=t(i);g.push(new s.Point({x:a[0],y:a[1],z:a[2]},o.CoordsType.CARTESIAN),new s.Point({x:n[0],y:n[1],z:n[2]},o.CoordsType.CARTESIAN))}else 1===f&&g.push(new s.Point({x:u,y:d,z:_},o.CoordsType.CARTESIAN),new s.Point({x:u,y:d,z:_},o.CoordsType.CARTESIAN));return g}static getAstroFoVPolygon(e){return e.map(e=>e.toADQL()).join(",")}}t.FoVUtils=h},8124:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LatLonGrid=void 0;const s=r(1961),a=r(4735),o=r(8284),n=i(r(4707)),h=r(7930),l=r(5803),c=i(r(4382)),u=i(r(5361));class d extends a.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_shaderProgram;_vertexShader;_fragmentShader;_attribLocations={position:0};_lonVertexPositionBuffer;_latVertexPositionBuffer;_lonStep=10;_latStep=10;_segmentStep=1;_fovObj;_fovDeg=180;_showGrid=!0;_lonArray=[];_latArray=[];_bufferKey="";defaultColor="#41d4d4";gridText=new u.default("lonlat");constructor(e,t,r,i,s,a){super(e,t,r,i,s,a),this._fovObj=new l.SphereFoV(a),this.init()}init(){this.initGL(super.webgl);const e=super.webgl;this._shaderProgram=e.createProgram(),this.initShaders(),this._lonVertexPositionBuffer=e.createBuffer(),this._latVertexPositionBuffer=e.createBuffer(),this.initBuffers(this._fovDeg)}initShaders(){const e=super.webgl,t=n.default.healpixGridFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(t),void alert(t)}const r=n.default.healpixGridVS();if(this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,r),e.compileShader(this._vertexShader),!e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(t),void alert(t)}e.attachShader(this._shaderProgram,this._vertexShader),e.attachShader(this._shaderProgram,this._fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this._shaderProgram)}initBuffers(e,t,r=!1){const i=o.xyzFovHelper.getLonLatSteps(e,r);this._lonStep=i.lonStep,this._latStep=i.latStep,this._segmentStep=Math.max(Math.min(this._lonStep,this._latStep),.25),this._lonArray=[],this._latArray=[];const s=t?{lon:this.normalizeLon(t.phi>180?t.phi-360:t.phi),lat:90-t.theta}:null,a=!!s&&!r&&e<2,n=a?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._lonStep):this.buildLonRange(0,180,this._lonStep),h=a?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._latStep):this.buildLatRange(0,90,this._latStep),l=a&&s?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._segmentStep):this.buildLatRange(0,90,this._segmentStep),c=a&&s?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._segmentStep):this.buildLonRange(0,180,this._segmentStep);for(const e of n){const t=[];for(const r of l)t.push(...this.lonLatToCartesian(e,Math.min(r,90)));this._lonArray.push(new Float32Array(t))}for(const e of h){const t=[];if(!(e<=-90||e>=90)){for(const r of c)t.push(...this.lonLatToCartesian(Math.min(r,180),e));this._latArray.push(new Float32Array(t))}}}buildLonRange(e,t,r){const i=[],s=Math.floor((e-t)/r)*r,a=Math.ceil((e+t)/r)*r;for(let e=s;e<=a;e+=r)i.push(this.normalizeLon(e));return i}buildLatRange(e,t,r){const i=[],s=Math.max(-90,Math.floor((e-t)/r)*r),a=Math.min(90,Math.ceil((e+t)/r)*r);for(let e=s;e<=a;e+=r)i.push(e);return i}lonLatToCartesian(e,t){const r=(0,h.degToRad)(e),i=(0,h.degToRad)(t),s=Math.cos(i);return[s*Math.cos(r),s*Math.sin(r),Math.sin(i)]}refresh(e,t){const r=!!t.cameraMoving,i=o.xyzFovHelper.getLonLatSteps(e,r),s=t.centerSphericalDeg,a=!!s&&!r&&e<2,n=s?this.normalizeLon(s.phi>180?s.phi-360:s.phi):0,h=s?90-s.theta:0,l=a?`${this.roundToStep(n,Math.max(i.lonStep,e))}:${this.roundToStep(h,Math.max(i.latStep,e))}`:"global",c=`${r?"coarse":"settled"}:${i.lonStep}:${i.latStep}:${l}`;this._bufferKey!==c&&(this._fovDeg=e,this._bufferKey=c,this.initBuffers(this._fovDeg,t.centerSphericalDeg,r))}refreshFoV(e){return e.camera&&e.pMatrix?(this._fovObj.getFoV(c.default.insideSphere,this,e.camera,e.pMatrix),this.refresh(this._fovObj.minFoV,e),this._fovObj.minFoV):this._fovDeg}getMinFoVDeg(){return this._fovObj.minFoV}getFoV(){return this._fovObj}isVisible(){return this._showGrid}toggleShowGrid(){return this._showGrid=!this._showGrid,this._showGrid}setShowGrid(e){this._showGrid=e}enableShader(e,t,r){const i=super.webgl;i.useProgram(this._shaderProgram);const a=s.mat4.create();s.mat4.multiply(a,r,e);const o=i.getUniformLocation(this._shaderProgram,"uMVMatrix"),n=i.getUniformLocation(this._shaderProgram,"uPMatrix"),l=i.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=i.getAttribLocation(this._shaderProgram,"aCatPosition"),o&&i.uniformMatrix4fv(o,!1,a),n&&i.uniformMatrix4fv(n,!1,t),l){const e=(0,h.colorHex2RGB)(this.defaultColor);i.uniform4f(l,e[0],e[1],e[2],1)}}draw(e){if(!this._showGrid)return void this.gridText.resetDivSets();const t=super.webgl,r=e.camera;if(!r)return;const i=e.pMatrix;if(!i)return;this.refreshFoV(e);const s=r.getCameraMatrix();if(!s)return;const a=this.getModelMatrix();this.enableShader(a,i,s);for(const e of this._lonArray)t.bindBuffer(t.ARRAY_BUFFER,this._lonVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_STRIP,0,e.length/d.ELEM_SIZE);for(const e of this._latArray)t.bindBuffer(t.ARRAY_BUFFER,this._latVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_LOOP,0,e.length/d.ELEM_SIZE);this.drawLabels(e,a,i,s),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}drawLabels(e,t,r,i){const s=e.centerSphericalDeg;if(!s)return void this.gridText.resetDivSets();const a=this.normalizeLon(s.phi>180?s.phi-360:s.phi),o=90-s.theta,n=this.normalizeLon(this.roundToStep(a,this._lonStep)),h=Math.max(-90+this._latStep,Math.min(90-this._latStep,this.roundToStep(o,this._latStep))),l=this.lonLatToCartesian(n,Math.max(-80,Math.min(80,o))),c=this.lonLatToCartesian(a,h),u=this.projectPointToScreen(l,t,r,i);u&&this.gridText.addLonLatDivSet(`${n.toFixed(0)}° lon`,u.x,u.y,"lon");const d=this.projectPointToScreen(c,t,r,i);d&&this.gridText.addLonLatDivSet(`${h.toFixed(0)}° lat`,d.x,d.y,"lat"),this.gridText.resetDivSets()}projectPointToScreen(e,t,r,i){const a=s.mat4.create(),o=s.mat4.create();s.mat4.multiply(a,i,t),s.mat4.multiply(o,r,a);const n=s.vec4.fromValues(e[0],e[1],e[2],1);if(s.vec4.transformMat4(n,n,o),Math.abs(n[3])<1e-6)return null;if(n[0]/=n[3],n[1]/=n[3],n[0]<-1||n[0]>1||n[1]<-1||n[1]>1)return null;const h=super.webgl.canvas.getBoundingClientRect();return{x:h.left+(.5*n[0]+.5)*h.width,y:h.top+(-.5*n[1]+.5)*h.height}}roundToStep(e,t){return t<=0?e:Math.round(e/t)*t}normalizeLon(e){let t=e;for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}t.LatLonGrid=d},8145:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.CoordsType=void 0,function(e){e.CARTESIAN="cartesian",e.SPHERICAL="spherical",e.ASTRO="astro",e.GEOGRAPHIC="geographic"}(r||(t.CoordsType=r={}))},8170:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPSTile=void 0;const i=r(4322);t.MeshHiPSTile=class{coord;_url;_webgl;_shaderProgram;_gpuMesh=null;_ready=!1;_loading=!1;_failed=!1;_lastUsedAt=0;_createdAt=Date.now();constructor(e,t,r,i){this.coord=e,this._url=t,this._webgl=r,this._shaderProgram=i,this.load()}get ready(){return this._ready}get loading(){return this._loading}get failed(){return this._failed}get lastUsedAt(){return this._lastUsedAt}get createdAt(){return this._createdAt}touch(){this._lastUsedAt=Date.now()}draw(e,t,r,i,s){if(this.touch(),!this._ready||!this._gpuMesh)return!1;const a=this._webgl;return this._shaderProgram.enableShaders(e,t,r,i),a.bindBuffer(a.ARRAY_BUFFER,this._gpuMesh.positionBuffer),a.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,a.FLOAT,!1,0,0),a.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&(a.bindBuffer(a.ARRAY_BUFFER,this._gpuMesh.normalBuffer),a.vertexAttribPointer(this._shaderProgram.locations.vertexNormalAttribute,3,a.FLOAT,!1,0,0),a.enableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute)),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,s?this._gpuMesh.lineIndexBuffer:this._gpuMesh.indexBuffer),a.drawElements(s?a.LINES:a.TRIANGLES,s?this._gpuMesh.lineIndexCount:this._gpuMesh.indexCount,this._gpuMesh.indexType,0),a.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&a.disableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute),!0}dispose(){const e=this._webgl;this._gpuMesh?.positionBuffer&&e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh?.normalBuffer&&e.deleteBuffer(this._gpuMesh.normalBuffer),this._gpuMesh?.indexBuffer&&e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh?.lineIndexBuffer&&e.deleteBuffer(this._gpuMesh.lineIndexBuffer),this._gpuMesh=null,this._ready=!1,this._loading=!1}async load(){if(!this._loading&&!this._ready){this._loading=!0;try{const e=await fetch(this._url);if(!e.ok)throw new Error(`HTTP ${e.status} fetching ${this._url}`);const t=i.OBJMeshParser.parse(await e.text());this._gpuMesh=this.uploadMesh(t),this._ready=!0,this._failed=!1}catch(e){console.warn("[MeshHiPSTile] load failed",this._url,e),this._failed=!0,this._ready=!1}finally{this._loading=!1}}}uploadMesh(e){const t=this._webgl,r=t.createBuffer(),i=t.createBuffer(),s=t.createBuffer(),a=t.createBuffer();if(!(r&&i&&s&&a))throw new Error(`Could not create MeshHiPS buffers for ${this.key}`);const o=this.buildLineIndices(e.indices);return t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.normals,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,a),t.bufferData(t.ELEMENT_ARRAY_BUFFER,o,t.STATIC_DRAW),{positionBuffer:r,normalBuffer:i,indexBuffer:s,lineIndexBuffer:a,indexCount:e.indices.length,lineIndexCount:o.length,indexType:t.UNSIGNED_INT}}buildLineIndices(e){const t=new Uint32Array(2*e.length);let r=0;for(let i=0;i<e.length;i+=3){const s=e[i],a=e[i+1],o=e[i+2];t[r++]=s,t[r++]=a,t[r++]=a,t[r++]=o,t[r++]=o,t[r++]=s}return t}get key(){return`${this.coord.order}/${this.coord.ipix}`}}},8256:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(r(4382)),a=r(229);t.default=class{_hips;_tileno;_baseurl;_order;_format;_maxorder;_isGalacticHips;_ready=!1;_abort=!1;_image;_textureLoaded=!1;_texture;_texurl="";_hipsShaderIndex=0;_cacheTime0;_inView=!0;_amIStillInFoV_requsetID;vertexPosition=[];vertexPositionBuffer=[];vertexIndices=new Uint16Array;vertexIndexBuffer;_tileBuffer;opacity=1;_webgl;_visibleTileManager;constructor(e,t,r,i,s,a){this._visibleTileManager=a,this._webgl=s,this._tileBuffer=i,this._hips=r,this._tileno=e,this._format=r.format,this._baseurl=r.baseURL,this._maxorder=r.maxOrder,this._isGalacticHips=r.isGalacticHips,this._order=t,this._amIStillInFoV_requsetID=window.setInterval(()=>{this.amIStillInFoV()},5e3),this.initImage()}destroyIntervals(){window.clearInterval(this._amIStillInFoV_requsetID)}getReadyState(){return this._ready}isLoading(){return!this._ready&&!this._abort}get cacheTime0(){return this._cacheTime0}resetCacheTime0(){this._cacheTime0=void 0}setCacheTime0(){this._cacheTime0=(new Date).getTime()}initImage(){if(this._order>this._maxorder)return this._ready=!1,this._abort=!0,this.destroyIntervals(),void console.warn(`[Tile] Skipping tile request above max order: requested order ${this._order}, max order ${this._maxorder}, url ${this._baseurl}`);this._image=new Image;const e=1e4*Math.floor(this._tileno/1e4);this._texurl=`${this._baseurl}/Norder${this._order}/Dir${e}/Npix${this._tileno}.${this._format}`,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{this._ready=!1,this._abort=!0,this.destroyIntervals()},this._image.crossOrigin="anonymous",this._image.src=this._texurl}imageLoaded(){this._ready=!0}textureLoaded(e){e.enableProgram();const t=this._webgl;this._texture=t.createTexture(),t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,this._texture),t.isTexture(this._texture)||console.log("error in texture"),t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.bindTexture(t.TEXTURE_2D,this._texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this._image),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.isTexture(this._texture)||console.warn("Texture creation failed"),this.initModelBuffer(),this._textureLoaded=!0}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=a.fovHelper.getRefOrder(this._order),r=s.default.getHealpix(this._order).nest2xyf(this._tileno),i=t-this._order,o=r.ix<<i,n=(r.ix<<i)+(1<<i),h=r.iy<<i,l=(r.iy<<i)+(1<<i),c=s.default.getHealpix(t);this.setupPositionAndTexture4Quadrant2(o,o+(n-o)/2,h,h+(l-h)/2,0,c,i,r),this.setupPositionAndTexture4Quadrant2(o+(n-o)/2,n,h,h+(l-h)/2,1,c,i,r),this.setupPositionAndTexture4Quadrant2(o,o+(n-o)/2,h+(l-h)/2,l,2,c,i,r),this.setupPositionAndTexture4Quadrant2(o+(n-o)/2,n,h+(l-h)/2,l,3,c,i,r);const u=this.vertexPosition[0].length/20,d=this.computeVertexIndices(u);d.length>65535?this.vertexIndices=new Uint32Array(d):this.vertexIndices=new Uint16Array(d),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint32Array(6*e);let r=0;for(let i=0;i<e;i++){const e=r;t[6*i]=e,t[6*i+1]=e+1,t[6*i+2]=e+2,t[6*i+3]=e+2,t[6*i+4]=e+3,t[6*i+5]=e,r+=4}return t}setupPositionAndTexture4Quadrant2(e,t,r,i,s,a,o,n){const h=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(i-r));const l=1/(1<<o);let c=0;for(let h=e;h<t;h++)for(let e=r;e<i;e++){const t=a.getPointsForXyfNoStep(h,e,n.face),r=e-(n.iy<<o),i=h-(n.ix<<o);this.vertexPosition[s][20*c]=t[0].x,this.vertexPosition[s][20*c+1]=t[0].y,this.vertexPosition[s][20*c+2]=t[0].z,this.vertexPosition[s][20*c+3]=l+l*r+0,this.vertexPosition[s][20*c+4]=1-(l+l*i)-0,this.vertexPosition[s][20*c+5]=t[1].x,this.vertexPosition[s][20*c+6]=t[1].y,this.vertexPosition[s][20*c+7]=t[1].z,this.vertexPosition[s][20*c+8]=l+l*r+0,this.vertexPosition[s][20*c+9]=1-l*i+0,this.vertexPosition[s][20*c+10]=t[2].x,this.vertexPosition[s][20*c+11]=t[2].y,this.vertexPosition[s][20*c+12]=t[2].z,this.vertexPosition[s][20*c+13]=l*r-0,this.vertexPosition[s][20*c+14]=1-l*i+0,this.vertexPosition[s][20*c+15]=t[3].x,this.vertexPosition[s][20*c+16]=t[3].y,this.vertexPosition[s][20*c+17]=t[3].z,this.vertexPosition[s][20*c+18]=l*r-0,this.vertexPosition[s][20*c+19]=1-(l+l*i)-0,c++}this.vertexPositionBuffer[s]=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,this.vertexPositionBuffer[s]),h.bufferData(h.ARRAY_BUFFER,this.vertexPosition[s],h.STATIC_DRAW)}get inView(){return this._inView}moveToCache(){this._tileBuffer.moveTileToCache(this._tileno,this._order,this._hips),this._inView=!1,this.destroyIntervals()}amIStillInFoV(){this._textureLoaded&&(this._ready=!0),this._isGalacticHips?(this._visibleTileManager.galAncestorsMap.has(this._order)&&(this._visibleTileManager.galAncestorsMap.get(this._order).includes(this._tileno)?this._inView=!0:this.moveToCache()),this._order==this._visibleTileManager.visibleOrder&&(this._visibleTileManager.galVisibleTilesByOrder.pixels.includes(this._tileno)?this._inView=!0:this.moveToCache())):(this._visibleTileManager.ancestorsMap.has(this._order)&&(this._visibleTileManager.ancestorsMap.get(this._order).includes(this._tileno)?this._inView=!0:this.moveToCache()),this._order==this._visibleTileManager.visibleOrder&&(this._visibleTileManager.visibleTilesByOrder.pixels.includes(this._tileno)?this._inView=!0:this.moveToCache()))}draw(e,t,r,i,s,a,o){if(!this._ready||this._abort)return;this._textureLoaded||this.textureLoaded(o);let n=new Set([0,1,2,3]);if(e>this._order&&this._order<this._maxorder){const h=this.drawChildren(e,t,r,i,s,a,o);h&&(n=h)}const h=this._webgl;o.enableShaders(r,i,s,a),h.enableVertexAttribArray(o.locations.vertexPositionAttribute),h.enableVertexAttribArray(o.locations.textureCoordAttribute),h.activeTexture(h.TEXTURE0+this._hipsShaderIndex),h.bindTexture(h.TEXTURE_2D,this._texture),h.uniform1f(o.locations.textureAlpha,this.opacity),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);const l=this.vertexIndices.length,c=this.vertexIndices instanceof Uint32Array?h.UNSIGNED_INT:h.UNSIGNED_SHORT;n.forEach(e=>{h.bindBuffer(h.ARRAY_BUFFER,this.vertexPositionBuffer[e]),h.vertexAttribPointer(o.locations.vertexPositionAttribute,3,h.FLOAT,!1,20,0),h.vertexAttribPointer(o.locations.textureCoordAttribute,2,h.FLOAT,!1,20,12),h.drawElements(h.TRIANGLES,l,c,0)}),h.disableVertexAttribArray(o.locations.vertexPositionAttribute),h.disableVertexAttribArray(o.locations.textureCoordAttribute)}drawChildren(e,t,r,i,s,a,o){const n=new Set([0,1,2,3]),h=this._order+1;if(t.has(h)){for(let l=0;l<4;l++){const c=(this._tileno<<2)+l;if(t.get(h).includes(c)){const l=this._isGalacticHips?this._tileBuffer.getGalTile(c,h,this._hips):this._tileBuffer.getTile(c,h,this._hips);l.draw(e,t,r,i,s,a,o),l._ready&&n.delete(c-(this._tileno<<2))}}return n}}}},8284:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.xyzFovHelper=void 0;class r{static LEVEL_HYSTERESIS=.12;static ZOOM_MIN_FOV={2:179,3:90,4:30,5:20,6:6,7:3.2,8:1.6,9:.85,10:.42,11:.21,12:.12,13:.06,14:.015,15:0};getZoom(e,t){const i=this.getRawZoom(e);if(void 0===t||t===i)return i;if(i>t){const i=r.ZOOM_MIN_FOV[t];if(i>0&&e>i*(1-r.LEVEL_HYSTERESIS))return t}else{const s=r.ZOOM_MIN_FOV[i];if(s>0&&e<s*(1+r.LEVEL_HYSTERESIS))return t}return i}getRawZoom(e){return e>=179?2:e>=90?3:e>=30?4:e>=20?5:e>=6?6:e>=3.2?7:e>=1.6?8:e>=.85?9:e>=.42?10:e>=.21?11:e>=.12?12:e>=.06?13:e>=.015?14:15}getLonLatSteps(e,t=!1){let r,i;return t&&e<.21||e>=179?(r=10,i=10):e>=25?(r=9,i=9):e>=12.5?(r=8,i=8):e>=6?(r=6,i=6):e>=3.2?(r=5,i=5):e>=1.6?(r=4,i=4):e>=.85?(r=3,i=3):e>=.42?(r=2,i=2):e>=.21?(r=1,i=1):e>=.12?(r=.5,i=.5):e>=.06?(r=.25,i=.25):(r=10,i=10),{lonStep:r,latStep:i}}}t.xyzFovHelper=new r,t.default=r},8755:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(8145),s=r(6553);class a{static isGeoJSON(e){if(!e||"object"!=typeof e)return!1;const t=e.type;return"FeatureCollection"===t||"Feature"===t||"Polygon"===t||"MultiPolygon"===t||"GeometryCollection"===t}static parseGeoJSON(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON root must be an object");const t=e;if("FeatureCollection"===t.type){if(!Array.isArray(t.features))throw new Error("GeoJSON FeatureCollection has no features array");return t.features.flatMap(e=>a.parseFeature(e))}if("Feature"===t.type)return a.parseFeature(t);if("Polygon"===t.type||"MultiPolygon"===t.type||"GeometryCollection"===t.type)return a.parseGeometry(t,{});throw new Error(`Unsupported GeoJSON type: ${t.type??"unknown"}`)}static parseFeature(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON feature must be an object");const t=e;if("Feature"!==t.type)throw new Error("GeoJSON feature has invalid type");return t.geometry?a.parseGeometry(t.geometry,t.properties??{},t.id):[]}static parseGeometry(e,t,r){return"Polygon"===e.type?[{id:r,geometryType:"Polygon",properties:t,polygons:a.parsePolygonCoordinates(e.coordinates)}]:"MultiPolygon"===e.type?[{id:r,geometryType:"MultiPolygon",properties:t,polygons:a.parseMultiPolygonCoordinates(e.coordinates)}]:"GeometryCollection"===e.type&&Array.isArray(e.geometries)?e.geometries.flatMap(e=>a.parseGeometry(e,t,r)):[]}static parseMultiPolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON MultiPolygon coordinates must be an array");return e.flatMap(e=>a.parsePolygonCoordinates(e))}static parsePolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON Polygon coordinates must be an array");return e.map(e=>a.parseLinearRing(e)).filter(e=>e.length>=3)}static parseLinearRing(e){if(!Array.isArray(e))throw new Error("GeoJSON linear ring must be an array");const t=e.map(e=>a.parsePosition(e));if(t.length>1){const e=t[0],r=t[t.length-1];e.lonDeg===r.lonDeg&&e.latDeg===r.latDeg&&t.pop()}return t}static parsePosition(e){if(!Array.isArray(e)||e.length<2)throw new Error("GeoJSON position must be [longitude, latitude]");const[t,r]=e;if(!Number.isFinite(t)||!Number.isFinite(r))throw new Error("GeoJSON position contains non-finite longitude/latitude");return new s.Point({lonDeg:t,latDeg:r},i.CoordsType.GEOGRAPHIC)}}t.default=a},8819:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMeshBuilder=void 0;const i=r(7930);function s(e){const t=Math.PI*(1-2*e);return 180*Math.atan(Math.sinh(t))/Math.PI}function a(e){return e<0?e+360:e}t.XYZMeshBuilder=class{buildTileMesh(e,t=16){const r=Math.max(1,Math.floor(t)),o=r+1,n=o*o,h=new Float32Array(3*n),l=new Float32Array(2*n),c=2**e.z;let u=0,d=0;for(let t=0;t<=r;t++){const o=t/r,n=(e.y+o)/c,_=90-Math.max(-85.0511287798066,Math.min(85.0511287798066,s(n)));for(let t=0;t<=r;t++){const s=t/r,n=a((e.x+s)/c*360-180),[f,g,p]=(0,i.sphericalToCartesian)(n,_,1);h[u++]=f,h[u++]=g,h[u++]=p,l[d++]=s,l[d++]=1-o}}const _=new Uint32Array(r*r*2*3);let f=0;for(let e=0;e<r;e++)for(let t=0;t<r;t++){const r=e*o+t,i=r+1,s=r+o,a=s+1;_[f++]=r,_[f++]=s,_[f++]=i,_[f++]=i,_[f++]=s,_[f++]=a}return{positions:h,uvs:l,indices:_.length>65535?_:new Uint16Array(_)}}buildAncestorMesh(e,t,r=16){const i=this.buildTileMesh(e,r),s=e.z-t.z,a=2**s,o=e.x-(t.x<<s),n=e.y-(t.y<<s),h=new Float32Array(i.uvs.length);for(let e=0;e<i.uvs.length;e+=2){const t=i.uvs[e]??0,r=1-(i.uvs[e+1]??0);h[e]=(o+t)/a,h[e+1]=1-(n+r)/a}return{positions:i.positions,uvs:h,indices:i.indices}}uploadMesh(e,t){const r=t.createBuffer(),i=t.createBuffer(),s=t.createBuffer(),a=e.indices instanceof Uint32Array?t.UNSIGNED_INT:t.UNSIGNED_SHORT;return t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.uvs,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),{positionBuffer:r,uvBuffer:i,indexBuffer:s,indexCount:e.indices.length,indexType:a}}}},8868:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMapDescriptor=void 0,t.XYZMapDescriptor=class{_name;_url;_urlResolver;_minZoom;_maxZoom;_segmentsPerSide;_tileSize;_maxCachedTiles;_interactionDebounceMs;_subdomains;_attribution;_flipY;_maxConcurrentLoads;constructor(e,t,r=0,i=8,s=16,a=384,o=8,n){this._name=e,this._url=t,this._urlResolver=n,this._minZoom=r,this._maxZoom=i,this._segmentsPerSide=s,this._maxCachedTiles=a,this._interactionDebounceMs=100,this._subdomains=["a","b","c"],this._attribution="",this._flipY=!1,this._maxConcurrentLoads=o}get url(){return this._url}get urlResolver(){return this._urlResolver}get name(){return this._name}get minZoom(){return this._minZoom}get maxZoom(){return this._maxZoom}get segmentsPerSide(){return this._segmentsPerSide}get maxCachedTiles(){return this._maxCachedTiles}get interactionDebounceMs(){return this._interactionDebounceMs}get subdomains(){return this._subdomains}get attribution(){return this._attribution}get flipY(){return this._flipY}get maxConcurrentLoads(){return this._maxConcurrentLoads}}},8909:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintShaderProgram=void 0;const s=r(1961),a=i(r(5947));t.FootprintShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix",point_size:"u_pointsize"},this.gl_attributes={vertex_pos:"aCatPosition"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,pointSize:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=a.default.footprintFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const r=a.default.footprintVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,r),e.compileShader(this._vertexShader),console.log("VS log:",e.getShaderInfoLog(this._vertexShader)||"ok"),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this.shaderProgram,this._vertexShader),e.attachShader(this.shaderProgram,this._fragmentShader),e.linkProgram(this.shaderProgram),e.getProgramParameter(this.shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this.shaderProgram),this.locations.position=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.pointSize=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.point_size),this.locations.color=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.vertex_color)):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableShaders(e,t,r){const i=this._webgl;i.useProgram(this.shaderProgram),this.locations.pMatrix=i.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=i.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let a=s.mat4.create();a=s.mat4.multiply(a,r,t),i.uniformMatrix4fv(this.locations.pMatrix,!1,e),i.uniformMatrix4fv(this.locations.mvMatrix,!1,a)}}},9022:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TerraFootprintSetGL=void 0;const i=r(592),s=r(8145),a=r(2475),o=r(1072),n=r(5403),h=r(1072);class l extends i.FootprintSetGL{_kind="TerraFootprintSetGL";_coordsType=s.CoordsType.GEOGRAPHIC;addGeoJSONFeatures(e){this._ready=!1,this.clearFootprints(),this._metadataManager=new n.MetadataManager(this.createGeoJSONMetadataColumns(e));for(const t of e){const e=a.Footprint.fromPolygons(t.polygons,this.createGeoJSONDetails(t),s.CoordsType.GEOGRAPHIC);e.valid&&(this.addFootprint(e),this.totPoints+=e.totPoints,this.totConvexPoints+=e.totConvexPoints)}this._ready=!0,this._bufferInitialised=!1}createGeoJSONMetadataColumns(e){const t=new Set;return e.forEach(e=>Object.keys(e.properties).forEach(e=>t.add(e))),Array.from(t).map((t,r)=>{const i=e.map(e=>e.properties[t]).filter(e=>null!=e&&""!==e),s=i.length>0&&i.every(e=>"number"==typeof e||!Number.isNaN(Number(e))),a=/^name$|nome|denominazione|label|title/i.test(t);return new o.MetadataColumn({index:r,name:t,columnType:a?h.ColumnType.MAIN_NAME:s?h.ColumnType.NUMBER:h.ColumnType.STRING,unit:""})})}createGeoJSONDetails(e){return Object.entries(e.properties).map(([e,t])=>({key:e,value:"number"==typeof t?t:String(t??"")}))}}t.TerraFootprintSetGL=l},9665:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6553),a=r(8145),o=i(r(4382));class n{static parseSTCS(e,t={}){const r=n.cleanStcs(e);return r.includes("POLYGON")?n.parsePolygon(r,t):r.includes("CIRCLE")?n.parseCircle(r,t):(console.warn("STCS not recognised"),{totpoints:0,polygons:[]})}static cleanStcs(e){let t=e.toUpperCase();return t=t.replace(/'ICRS'/g,"").replace(/\bICRS\b/g,"").replace(/\bJ2000\b/g,"").replace(/\bUNION\b/g,"").replace(/\bTOPOCENTER\b/g,""),t=t.replace(/[()]/g,""),t=t.replace(/ {2,}/g," ").trim(),t}static parsePolygon(e,t={}){let r=0;const i=[],n=o.default.MAX_DECIMALS??12,h=t.coordsType??a.CoordsType.ASTRO,l=e.split("POLYGON ");for(let e=1;e<l.length;e++){const t=[],o=l[e].trim().split(" "),c=Number(parseFloat(o[0]).toFixed(n)),u=Number(parseFloat(o[1]).toFixed(n)),d=Number(parseFloat(o[o.length-2]).toFixed(n)),_=Number(parseFloat(o[o.length-1]).toFixed(n));if(c===d&&u===_&&o.splice(o.length-2,2),o.length>2){for(let e=0;e<o.length-1;e+=2){const i=Number(parseFloat(o[e]).toFixed(n)),l=Number(parseFloat(o[e+1]).toFixed(n)),c=h===a.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:i,latDeg:l},a.CoordsType.GEOGRAPHIC):new s.Point({raDeg:i,decDeg:l},a.CoordsType.ASTRO);t.push(c),r+=1}i.push(t)}}return{totpoints:r,polygons:i}}static parseCircle(e,t={}){let r=0;const i=[],o=t.coordsType??a.CoordsType.ASTRO,n=e.split("CIRCLE ");for(let e=1;e<n.length;e++){const t=[],h=n[e].trim().split(" "),l=Number(h[0]),c=Number(h[1]),u=Number(h[2]),d=24,_=2*Math.PI/d;for(let e=d;e>0;e--){const i=u*Math.cos(e*_)+l,n=u*Math.sin(e*_)+c,h=o===a.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:i,latDeg:n},a.CoordsType.GEOGRAPHIC):new s.Point({raDeg:i,decDeg:n},a.CoordsType.ASTRO);t.push(h),r+=1}i.push(t)}return{totpoints:r,polygons:i}}}t.default=n},9685:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PerspectiveMatrixManager=void 0;const i=r(1961),s=r(2919);t.PerspectiveMatrixManager=class{_pMatrix;_aspectRatio=1;constructor(e,t,r,i=.1,s){this._pMatrix=this.computePerspectiveMatrix(e,t,r,i,s)}get pMatrix(){return this._pMatrix}set pMatrix(e){this._pMatrix=e}computePerspectiveMatrix(e,t,r,a=.1,o){this._aspectRatio=e.width/e.height;const n=i.mat4.create();let h;if(o)h=1.1;else{const e=t.getCameraMatrix(),r=-Number(e[14]),i=1,s=Math.sqrt(Math.max(r**2-i**2,0)),a=Math.atan2(s,i),o=s*Math.sin(a);h=o>0?o:i}const l=o?s.bootSetup.inside_camera_fov_deg:r,c=o?Math.max(a,.001):a;return i.mat4.perspective(n,l*Math.PI/180,this._aspectRatio,c,h),this._pMatrix=n,n}}},9839:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.EquatorialGrid=void 0;const s=r(1961),a=r(229),o=r(7930),n=i(r(4707)),h=r(6553),l=r(8145),c=r(8083),u=i(r(5361)),d=r(4595),_=r(4735);class f extends _.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;showGrid=!1;_shaderProgram;_vertexShader;_fragmentShader;defaultColor="#41d421";gridText=new u.default("equatorial");_attribLocations={position:0,selected:1,pointSize:2,color:3};_phiVertexPositionBuffer;_thetaVertexPositionBuffer;_fov;_phiStep=0;_phiStepRad=0;_thetaStep=0;_thetaStepRad=0;_phiArray=[];_thetaArray=[];_bufferKey="";_dec4Labels=new Map;_ra4Labels=new Map;_healpixGrid;constructor(e,t){super(d.HealpixGrid.RADIUS,d.HealpixGrid.INITIAL_POSITION,d.HealpixGrid.INITIAL_PhiRad,d.HealpixGrid.INITIAL_ThetaRad,"equatorial-grid",e),this._healpixGrid=t}init(e){this._fov=e,this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders(),this._phiVertexPositionBuffer=super.webgl.createBuffer(),this._thetaVertexPositionBuffer=super.webgl.createBuffer(),this.initBuffers(this._fov)}initShaders(){const e=n.default.healpixGridFS();if(this._fragmentShader=super.webgl.createShader(super.webgl.FRAGMENT_SHADER),super.webgl.shaderSource(this._fragmentShader,e),super.webgl.compileShader(this._fragmentShader),!super.webgl.getShaderParameter(this._fragmentShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(e),void alert(e)}const t=n.default.healpixGridVS();if(this._vertexShader=super.webgl.createShader(super.webgl.VERTEX_SHADER),super.webgl.shaderSource(this._vertexShader,t),super.webgl.compileShader(this._vertexShader),!super.webgl.getShaderParameter(this._vertexShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(e),void alert(e)}super.webgl.attachShader(this._shaderProgram,this._vertexShader),super.webgl.attachShader(this._shaderProgram,this._fragmentShader),super.webgl.linkProgram(this._shaderProgram),super.webgl.getProgramParameter(this._shaderProgram,super.webgl.LINK_STATUS)||alert("Could not initialise shaders"),super.webgl.useProgram(this._shaderProgram)}initBuffers(e,t=!1){const r=a.fovHelper.getRADegSteps(e,t),i=r.raStep,s=r.decStep;this._phiStep=i,this._phiStepRad=(0,o.degToRad)(i),this._thetaStep=s,this._thetaStepRad=(0,o.degToRad)(s),this._ra4Labels=new Map,this._dec4Labels=new Map,this._phiArray=[],this._thetaArray=[];for(let e=s;e<180;e+=s){const t=new Float32Array(360/i*3),r=(0,o.degToRad)(e);for(let e=0;e<360;e+=i){const s=(0,o.degToRad)(e),a=1*Math.sin(r)*Math.cos(s),n=1*Math.sin(r)*Math.sin(s),h=1*Math.cos(r),l=Math.floor(e/i);t[3*l+0]=a,t[3*l+1]=n,t[3*l+2]=h,this._dec4Labels.has(e)||this._dec4Labels.set(e,[]),this._dec4Labels.get(e).push([a,n,h])}this._phiArray.push(t)}for(let e=0;e<360;e+=i){const t=new Float32Array(360/s*3),r=(0,o.degToRad)(e);for(let e=0;e<360;e+=s){const i=(0,o.degToRad)(e),a=1*Math.sin(i)*Math.cos(r),n=1*Math.sin(i)*Math.sin(r),h=1*Math.cos(i),l=Math.floor(e/s);t[3*l+0]=a,t[3*l+1]=n,t[3*l+2]=h;const c=90-e;this._ra4Labels.has(c)||this._ra4Labels.set(c,[]),this._ra4Labels.get(c).push([a,n,h])}this._thetaArray.push(t)}}refresh(e,t=!1){const r=a.fovHelper.getRADegSteps(e,t),i=`${t?"coarse":"settled"}:${r.raStep}:${r.decStep}`;this._bufferKey!==i&&(this._fov=e,this._bufferKey=i,this.initBuffers(this._fov,t))}vectorDistance(e,t){const r=e.x-t.x,i=e.y-t.y,s=e.z-t.z;return Math.sqrt(r*r+i*i+s*s)}enableShader(e,t,r){const i=super.webgl;i.useProgram(this._shaderProgram);const a=s.mat4.create();s.mat4.multiply(a,r,e);const n=i.getUniformLocation(this._shaderProgram,"uMVMatrix"),h=i.getUniformLocation(this._shaderProgram,"uPMatrix"),l=i.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=i.getAttribLocation(this._shaderProgram,"aCatPosition"),n&&i.uniformMatrix4fv(n,!1,a),h&&i.uniformMatrix4fv(h,!1,t),l){const e=(0,o.colorHex2RGB)(this.defaultColor);i.uniform4f(l,e[0],e[1],e[2],1)}}isVisible(){return this.showGrid}toggleShowGrid(){this.showGrid=!this.showGrid}draw(e){const t=e.fovDeg;if(!t)return;const r=super.webgl,i=this.getModelMatrix(),a=e.camera;if(!a)return;const n=a.getCameraMatrix(),u=e.pMatrix;if(!u)return;if(!n)return;if(0===this._thetaArray.length)return;if(this.refresh(t,!!e.cameraMoving),!this.showGrid)return void this.gridText.resetDivSets();this.enableShader(i,u,n);for(let e=0;e<this._phiArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._phiVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._phiArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._phiStep);for(let e=0;e<this._thetaArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._thetaVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._thetaArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._thetaStep);const d=c.FoVUtils.getCenterJ2000(r.canvas,this._healpixGrid,this._webgl,a,u),_=s.mat4.create();s.mat4.multiply(_,n,i);const f=s.mat4.create();s.mat4.multiply(f,u,_);for(const[e,t]of this._dec4Labels.entries())if(Math.abs(e-d.raDeg)<=this._phiStep)for(let e=0;e<t.length;e++){const[r,i,a]=t[e],o=[r,i,a,1],n=new h.Point({x:r,y:i,z:a},l.CoordsType.CARTESIAN).decDeg;if(Math.abs(n-d.decDeg)<60){const e=s.vec4.create();s.vec4.transformMat4(e,o,f),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),r=t.left+(.5*e[0]+.5)*t.width,i=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(n.toFixed(2),r,i,"dec")}}for(const[e,t]of this._ra4Labels.entries())if(Math.abs(e-d.decDeg)<=this._thetaStep)for(let e=0;e<t.length;e++){const[r,i,a]=t[e],n=[r,i,a,1],c=new h.Point({x:r,y:i,z:a},l.CoordsType.CARTESIAN),u=this.vectorDistance(c,d),_=c.raDeg;if(u<(0,o.degToRad)(50)){const e=s.vec4.create();s.vec4.transformMat4(e,n,f),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),r=t.left+(.5*e[0]+.5)*t.width,i=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(_.toFixed(2),r,i,"ra")}}this.gridText.resetDivSets(),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}}t.EquatorialGrid=f}},t={};function r(i){var s=t[i];if(void 0!==s)return s.exports;var a=t[i]={exports:{}};return e[i].call(a.exports,a,a.exports,r),a.exports}return r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(1229)})());