UNPKG

@inweb/viewer-three

Version:

JavaScript library for rendering CAD and BIM files in a browser using Three.js

49 lines (45 loc) 260 kB
/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a // license agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('@inweb/viewer-three'), require('three'), require('@inweb/viewer-core')) : typeof define === 'function' && define.amd ? define(['@inweb/viewer-three', 'three', '@inweb/viewer-core'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ODA.Three, global.THREE, global.ODA.Three)); })(this, (function (viewerThree, e, viewerCore) { 'use strict'; function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n.default = e; return Object.freeze(n); } var e__namespace = /*#__PURE__*/_interopNamespaceDefault(e); var t={324:(e,t,n)=>{n.r(t),n.d(t,{default:()=>i});const i="precision highp float;\r\nprecision highp int;\r\n\r\n// Uniforms for projection, screen size, and texture sampler\r\nuniform mat4 projectionMatrix;\r\nuniform float screenWidth;\r\nuniform float screenHeight;\r\nuniform sampler2D map;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n\t// Calculate pixel offsets\r\n\tfloat dx = 1.0 / screenWidth;\r\n\tfloat dy = 1.0 / screenHeight;\r\n\r\n\t// Average the color of the 9 surrounding pixels\r\n\tvec3 color = texture2D(map, vUv + vec2(-dx, -dy)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( 0.0, -dy)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( dx, -dy)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2(-dx, 0.0)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( 0.0, 0.0)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( dx, 0.0)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2(-dx, dy)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( 0.0, dy)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( dx, dy)).rgb;\r\n\r\n\t// Set the output color with alpha = 1.0\r\n\tgl_FragColor = vec4(color / 9.0, 1.0);\r\n}\r\n";},652:(e,t,n)=>{n.r(t),n.d(t,{default:()=>i});const i="// Vertex shader for blur effect.\r\nprecision highp float; // Use high precision for floats.\r\nprecision highp int; // Use high precision for ints.\r\n\r\nattribute vec3 position; // Vertex position.\r\nattribute vec2 uv; // Texture coordinate.\r\n\r\nuniform mat4 modelViewMatrix; // Model-view transformation.\r\nuniform mat4 projectionMatrix; // Projection transformation.\r\n\r\nvarying vec2 vUv; // Pass uv coordinates to fragment shader.\r\n\r\nvoid main() {\r\n\t// Pass the texture coordinate.\r\n\tvUv = uv;\r\n\r\n\t// Compute the vertex position.\r\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\r\n}";},650:(e,t,n)=>{n.d(t,{A:()=>i});const i="// Set precision for floats and ints\r\nprecision highp float;\r\nprecision highp int;\r\n\r\n// Uniforms for camera, projection and point parameters\r\nuniform mat4 viewMatrix;\r\nuniform vec3 cameraPosition;\r\nuniform mat4 projectionMatrix;\r\nuniform float opacity;\r\nuniform bool useOrthographicCamera;\r\nuniform float blendHardness;\r\nuniform float blendDepthSupplement;\r\nuniform float fov;\r\nuniform float spacing;\r\nuniform float pcIndex;\r\nuniform float screenWidth;\r\nuniform float screenHeight;\r\nuniform float far;\r\nuniform sampler2D depthMap;\r\n\r\nout vec4 fragColor;\r\n\r\n#ifdef highlight_point\r\n\t// Color used to highlight a point\r\n\tuniform vec4 highlightedPointColor;\r\n#endif\r\n\r\n#ifdef new_format\r\n\tin vec4 vColor;\r\n#else\r\n\tin vec3 vColor;\r\n#endif\r\n\r\n#if !defined(color_type_point_index)\r\n\t// Opacity attribute when not using point index color type\r\n\tin float vOpacity;\r\n#endif\r\n\r\n#if defined(weighted_splats)\r\n\t// Linear depth value for weighted splats\r\n\tin float vLinearDepth;\r\n#endif\r\n\r\n#ifdef use_edl\r\n\t// Log depth for EDL rendering\r\n\tin float vLogDepth;\r\n#endif\r\n\r\nin vec3 vViewPosition;\r\n#if defined(weighted_splats) || defined(paraboloid_point_shape)\r\n\t// Radius for point shapes\r\n\tin float vRadius;\r\n#endif\r\n\r\n#if defined(color_type_phong) && (MAX_POINT_LIGHTS > 0 || MAX_DIR_LIGHTS > 0)\r\n\t// Normal for Phong shading\r\n\tin vec3 vNormal;\r\n#endif\r\n\r\n#ifdef highlight_point\r\n\t// Highlight flag for the point\r\n\tin float vHighlight;\r\n#endif\r\n\r\nfloat specularStrength = 1.0;\r\n\r\nvoid main() {\r\n\t// Choose the proper color format\r\n\t#ifdef new_format\r\n\t\tvec3 actualColor = vColor.xyz;\r\n\t#else\r\n\t\tvec3 actualColor = vColor;\r\n\t#endif\r\n\tvec3 color = actualColor;\r\n\r\n\t// Precompute normalized point coordinate if needed\r\n\t#if defined(circle_point_shape) || defined(paraboloid_point_shape) || defined(weighted_splats)\r\n\t\tvec2 pc = 2.0 * gl_PointCoord - 1.0;\r\n\t#endif\r\n\r\n\t// Discard fragments outside circle for certain shapes\r\n\t#if defined(circle_point_shape) || defined(weighted_splats)\r\n\t\tif(dot(pc, pc) > 1.0) discard;\r\n\t#endif\r\n\r\n\t// Depth comparison for weighted splats\r\n\t#if defined(weighted_splats)\r\n\t\tvec2 uv = gl_FragCoord.xy / vec2(screenWidth, screenHeight);\r\n\t\tif(vLinearDepth > texture2D(depthMap, uv).r + vRadius + blendDepthSupplement) discard;\r\n\t#endif\r\n\r\n\t// Lighting calculations for Phong shading\r\n\t#if defined(color_type_phong)\r\n\t\t#if MAX_POINT_LIGHTS > 0 || MAX_DIR_LIGHTS > 0\r\n\t\t\tvec3 normal = normalize(vNormal);\r\n\t\t\tnormal.z = abs(normal.z);\r\n\t\t\tvec3 viewDir = normalize(vViewPosition);\r\n\t\t#endif\r\n\r\n\t\t#if MAX_POINT_LIGHTS > 0\r\n\t\t\tvec3 pointDiffuse = vec3(0.0);\r\n\t\t\tvec3 pointSpecular = vec3(0.0);\r\n\t\t\t// Loop through each point light\r\n\t\t\tfor(int i = 0; i < MAX_POINT_LIGHTS; i++) {\r\n\t\t\t\tvec4 lPos = viewMatrix * vec4(pointLightPosition[i], 1.0);\r\n\t\t\t\tvec3 lVector = normalize(lPos.xyz + vViewPosition);\r\n\t\t\t\tfloat lDistance = (pointLightDistance[i] > 0.0)\r\n\t\t\t\t\t? 1.0 - min(length(lVector)/pointLightDistance[i], 1.0)\r\n\t\t\t\t\t: 1.0;\r\n\t\t\t\tfloat dotVal = dot(normal, lVector);\r\n\t\t\t\t#ifdef WRAP_AROUND\r\n\t\t\t\t\t// Use wrap around lighting if enabled\r\n\t\t\t\t\tfloat fullW = max(dotVal, 0.0);\r\n\t\t\t\t\tfloat halfW = max(0.5 * dotVal + 0.5, 0.0);\r\n\t\t\t\t\tfloat diffuseW = mix(fullW, halfW, wrapRGB);\r\n\t\t\t\t#else\r\n\t\t\t\t\tfloat diffuseW = max(dotVal, 0.0);\r\n\t\t\t\t#endif\r\n\t\t\t\tpointDiffuse += diffuse * pointLightColor[i] * diffuseW * lDistance;\r\n\t\t\t\tvec3 halfVec = normalize(lVector + viewDir);\r\n\t\t\t\tfloat specW = specularStrength * max(pow(max(dot(normal, halfVec), 0.0), shininess), 0.0);\r\n\t\t\t\tfloat normFactor = (shininess + 2.0) / 8.0;\r\n\t\t\t\tvec3 schlick = specular + (vec3(1.0)-specular)*pow(max(1.0-dot(lVector, halfVec), 0.0), 5.0);\r\n\t\t\t\tpointSpecular += schlick * pointLightColor[i] * specW * diffuseW * lDistance * normFactor;\r\n\t\t\t\t// Disable specular effect if required\r\n\t\t\t\tpointSpecular = vec3(0.0);\r\n\t\t\t}\r\n\t\t#endif\r\n\r\n\t\t#if MAX_DIR_LIGHTS > 0\r\n\t\t\tvec3 dirDiffuse = vec3(0.0);\r\n\t\t\tvec3 dirSpecular = vec3(0.0);\r\n\t\t\t// Loop through each directional light\r\n\t\t\tfor(int i = 0; i < MAX_DIR_LIGHTS; i++) {\r\n\t\t\t\tvec4 lDir = viewMatrix * vec4(directionalLightDirection[i], 0.0);\r\n\t\t\t\tvec3 dVector = normalize(lDir.xyz);\r\n\t\t\t\tfloat dotVal = dot(normal, dVector);\r\n\t\t\t\t#ifdef WRAP_AROUND\r\n\t\t\t\t\tfloat fullW = max(dotVal, 0.0);\r\n\t\t\t\t\tfloat halfW = max(0.5 * dotVal + 0.5, 0.0);\r\n\t\t\t\t\tfloat diffuseW = mix(fullW, halfW, wrapRGB);\r\n\t\t\t\t#else\r\n\t\t\t\t\tfloat diffuseW = max(dotVal, 0.0);\r\n\t\t\t\t#endif\r\n\t\t\t\tdirDiffuse += diffuse * directionalLightColor[i] * diffuseW;\r\n\t\t\t\tvec3 halfVec = normalize(dVector + viewDir);\r\n\t\t\t\tfloat specW = specularStrength * max(pow(max(dot(normal, halfVec), 0.0), shininess), 0.0);\r\n\t\t\t\tfloat normFactor = (shininess + 2.0) / 8.0;\r\n\t\t\t\tvec3 schlick = specular + (vec3(1.0)-specular)*pow(max(1.0-dot(dVector, halfVec), 0.0), 5.0);\r\n\t\t\t\tdirSpecular += schlick * directionalLightColor[i] * specW * diffuseW * normFactor;\r\n\t\t\t}\r\n\t\t#endif\r\n\r\n\t\t// Combine lighting contributions from both light types\r\n\t\tvec3 totalDiffuse = vec3(0.0);\r\n\t\tvec3 totalSpecular = vec3(0.0);\r\n\t\t#if MAX_POINT_LIGHTS > 0\r\n\t\t\ttotalDiffuse += pointDiffuse;\r\n\t\t\ttotalSpecular += pointSpecular;\r\n\t\t#endif\r\n\t\t#if MAX_DIR_LIGHTS > 0\r\n\t\t\ttotalDiffuse += dirDiffuse;\r\n\t\t\ttotalSpecular += dirSpecular;\r\n\t\t#endif\r\n\t\tfragColor.xyz = fragColor.xyz * (emissive + totalDiffuse + ambientLightColor * ambient) + totalSpecular;\r\n\t#endif\r\n\r\n\t// Handle weighted splats or default opacity and color\r\n\t#if defined(weighted_splats)\r\n\t\tfloat wx = 2.0 * length(pc);\r\n\t\tfloat w = exp(-wx * wx * 0.5);\r\n\t\tfragColor.rgb *= w;\r\n\t\tfragColor.a = w;\r\n\t#else\r\n\t\t#if defined(color_type_point_index)\r\n\t\t\tfragColor = vec4(color, pcIndex / 255.0);\r\n\t\t#else\r\n\t\t\tfragColor = vec4(color, vOpacity);\r\n\t\t#endif\r\n\t#endif\r\n\r\n\t// Compute depth from view position\r\n\tvec4 pos = vec4(vViewPosition, 1.0);\r\n\t#if defined(paraboloid_point_shape)\r\n\t\tif(!useOrthographicCamera){\r\n\t\t\t// Adjust depth based on point shape\r\n\t\t\tpos.z += -dot(pc, pc) * vRadius;\r\n\t\t}\r\n\t#endif\r\n\r\n\tfloat linearDepth = -pos.z;\r\n\tvec4 clipPos = projectionMatrix * pos;\r\n\tclipPos /= clipPos.w;\r\n\t#if defined(use_log_depth)\r\n\t\t// Logarithmic depth\r\n\t\tgl_FragDepth = log2(linearDepth + 1.0) * log(2.0) / log(far + 1.0);\r\n\t#else\r\n\t\t// Standard depth computation\r\n\t\tgl_FragDepth = (clipPos.z + 1.0) / 2.0;\r\n\t#endif\r\n\r\n\t#if defined(color_type_depth)\r\n\t\t// Render depth information into color channels\r\n\t\tfragColor.r = linearDepth;\r\n\t\tfragColor.g = clipPos.z;\r\n\t#endif\r\n\r\n\t#if defined(use_edl)\r\n\t\t// For EDL, pass the log depth\r\n\t\tfragColor.a = vLogDepth;\r\n\t#endif\r\n\r\n\t#if defined(highlight_point)\r\n\t\t// Override color for highlighted points\r\n\t\tif(vHighlight > 0.0) {\r\n\t\t\tfragColor = highlightedPointColor;\r\n\t\t}\r\n\t#endif\r\n}\r\n";},26:(e,t,n)=>{n.d(t,{A:()=>i});const i="precision highp float;\r\nprecision highp int;\r\n\r\n#define max_clip_boxes 30 // Maximum number of clipping boxes\r\n\r\n// Input Attributes\r\nin vec3 position;\r\nin vec3 normal;\r\nin float intensity;\r\nin float classification;\r\nin float returnNumber;\r\nin float numberOfReturns;\r\nin float pointSourceID;\r\nin vec4 indices;\r\n\r\n\r\n// Uniforms\r\nuniform mat4 modelMatrix;\r\nuniform mat4 modelViewMatrix;\r\nuniform mat4 projectionMatrix;\r\nuniform mat4 viewMatrix;\r\nuniform mat3 normalMatrix;\r\n\r\nuniform float pcIndex;\r\n\r\nuniform float screenWidth;\r\nuniform float screenHeight;\r\nuniform float fov;\r\nuniform float spacing;\r\nuniform float viewScale;\r\n\r\nuniform bool useOrthographicCamera;\r\nuniform float orthoWidth;\r\nuniform float orthoHeight;\r\n\r\n#if defined use_clip_box\r\n\tuniform mat4 clipBoxes[max_clip_boxes]; // Clipping box transforms\r\n#endif\r\n\r\nuniform float heightMin;\r\nuniform float heightMax;\r\nuniform float size; // Base pixel size\r\nuniform float minSize; // Minimum point size\r\nuniform float maxSize; // Maximum point size\r\nuniform float octreeSize;\r\nuniform vec3 bbSize;\r\nuniform vec3 uColor;\r\nuniform float opacity;\r\nuniform float clipBoxCount;\r\nuniform float level;\r\nuniform float vnStart;\r\nuniform bool isLeafNode;\r\n\r\nuniform float filterByNormalThreshold;\r\nuniform vec2 intensityRange;\r\nuniform float opacityAttenuation;\r\nuniform float intensityGamma;\r\nuniform float intensityContrast;\r\nuniform float intensityBrightness;\r\nuniform float rgbGamma;\r\nuniform float rgbContrast;\r\nuniform float rgbBrightness;\r\nuniform float transition;\r\nuniform float wRGB;\r\nuniform float wIntensity;\r\nuniform float wElevation;\r\nuniform float wClassification;\r\nuniform float wReturnNumber;\r\nuniform float wSourceID;\r\n\r\nuniform sampler2D visibleNodes;\r\nuniform sampler2D gradient;\r\nuniform sampler2D classificationLUT;\r\nuniform sampler2D depthMap;\r\n\r\n#ifdef highlight_point\r\n\tuniform vec3 highlightedPointCoordinate;\r\n\tuniform bool enablePointHighlighting;\r\n\tuniform float highlightedPointScale;\r\n#endif\r\n\r\n#ifdef new_format\r\n\tin vec4 rgba;\r\n\tout vec4 vColor;\r\n#else\r\n\tin vec3 color;\r\n\tout vec3 vColor;\r\n#endif\r\n\r\n#if !defined(color_type_point_index)\r\n\tout float vOpacity;\r\n#endif\r\n\r\n#if defined(weighted_splats)\r\n\tout float vLinearDepth;\r\n#endif\r\n\r\n#ifdef use_edl\r\n\tout float vLogDepth;\r\n#endif\r\n\r\nout vec3 vViewPosition;\r\n\r\n#if defined(weighted_splats) || defined(paraboloid_point_shape)\r\n\tout float vRadius;\r\n#endif\r\n\r\n#if defined(color_type_phong) && (MAX_POINT_LIGHTS > 0 || MAX_DIR_LIGHTS > 0)\r\n\tout vec3 vNormal;\r\n#endif\r\n\r\n#ifdef highlight_point\r\n\tout float vHighlight;\r\n#endif\r\n\r\n\r\n// OCTREE LOD FUNCTIONS\r\n#if (defined(adaptive_point_size) || defined(color_type_lod)) && defined(tree_type_octree)\r\n\r\n// Returns count of bits set up to a given index\r\nint numberOfOnes(int number, int index) {\r\n\tint numOnes = 0;\r\n\tint tmp = 128;\r\n\tfor (int i = 7; i >= 0; i--) {\r\n\t\tif (number >= tmp) {\r\n\t\t\tnumber -= tmp;\r\n\t\t\tif (i <= index) { numOnes++; }\r\n\t\t}\r\n\t\ttmp /= 2;\r\n\t}\r\n\treturn numOnes;\r\n}\r\n\r\n// Checks if bit at specific index is set\r\nbool isBitSet(int number, int index){\r\n\tint powi = (index == 0) ? 1 :\r\n\t\t\t (index == 1) ? 2 :\r\n\t\t\t (index == 2) ? 4 :\r\n\t\t\t (index == 3) ? 8 :\r\n\t\t\t (index == 4) ? 16 :\r\n\t\t\t (index == 5) ? 32 :\r\n\t\t\t (index == 6) ? 64 : 128;\r\n\treturn mod(float(number / powi), 2.0) != 0.0;\r\n}\r\n\r\n// Computes level-of-detail based on octree visibility\r\nfloat getLOD() {\r\n\tvec3 offset = vec3(0.0);\r\n\tint iOffset = int(vnStart);\r\n\tfloat depth = level;\r\n\r\n\tfor (float i = 0.0; i <= 30.0; i++) {\r\n\t\tfloat nodeSizeAtLevel = octreeSize / pow(2.0, i + level);\r\n\t\tvec3 index3d = floor((position - offset) / nodeSizeAtLevel + 0.5);\r\n\t\tint index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));\r\n\t\t\r\n\t\tvec4 value = texture(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));\r\n\t\tint mask = int(round(value.r * 255.0));\r\n\r\n\t\tif (isBitSet(mask, index)) {\r\n\t\t\tint advanceG = int(round(value.g * 255.0)) * 256;\r\n\t\t\tint advanceB = int(round(value.b * 255.0));\r\n\t\t\tint advanceChild = numberOfOnes(mask, index - 1);\r\n\t\t\tint advance = advanceG + advanceB + advanceChild;\r\n\t\t\tiOffset += advance;\r\n\t\t\tdepth++;\r\n\t\t} else {\r\n\t\t\treturn value.a * 255.0;\r\n\t\t}\r\n\t\toffset += (vec3(1.0) * nodeSizeAtLevel * 0.5) * index3d;\r\n\t}\r\n\treturn depth;\r\n}\r\n\r\nfloat getPointSizeAttenuation() {\r\n\treturn 0.5 * pow(2.0, getLOD());\r\n}\r\n\r\n#endif\r\n\r\n\r\n// KD-TREE LOD FUNCTIONS\r\n\r\n#if (defined(adaptive_point_size) || defined(color_type_lod)) && defined(tree_type_kdtree)\r\n\r\nfloat getLOD() {\r\n\tvec3 offset = vec3(0.0);\r\n\tfloat intOffset = 0.0;\r\n\tfloat depth = 0.0;\r\n\tvec3 size_ = bbSize;\r\n\tvec3 pos = position;\r\n\t\t\r\n\tfor (float i = 0.0; i <= 1000.0; i++) {\r\n\t\tvec4 value = texture(visibleNodes, vec2(intOffset / 2048.0, 0.0));\r\n\t\tint children = int(value.r * 255.0);\r\n\t\tfloat next = value.g * 255.0;\r\n\t\tint split = int(value.b * 255.0);\r\n\t\t\r\n\t\tif (next == 0.0) { return depth; }\r\n\t\t\r\n\t\tvec3 splitv = (split == 1) ? vec3(1.0, 0.0, 0.0) :\r\n\t\t\t\t\t (split == 2) ? vec3(0.0, 1.0, 0.0) :\r\n\t\t\t\t\t (split == 4) ? vec3(0.0, 0.0, 1.0) : vec3(0.0);\r\n\t\t\r\n\t\tintOffset += next;\r\n\t\t\r\n\t\tfloat factor = length((pos * splitv) / size_);\r\n\t\tif (factor < 0.5) {\r\n\t\t\tif (children == 0 || children == 2) { return depth; }\r\n\t\t} else {\r\n\t\t\tpos -= size_ * splitv * 0.5;\r\n\t\t\tif (children == 0 || children == 1) { return depth; }\r\n\t\t\tif (children == 3) { intOffset += 1.0; }\r\n\t\t}\r\n\t\tsize_ *= ((1.0 - (splitv + 1.0) / 2.0) + 0.5);\r\n\t\tdepth++;\r\n\t}\r\n\treturn depth;\t\r\n}\r\n\r\nfloat getPointSizeAttenuation() {\r\n\treturn 0.5 * pow(1.3, getLOD());\r\n}\r\n\r\n#endif\r\n\r\n\r\n// COLOR/BRIGHTNESS FUNCTIONS\r\n\r\nfloat getContrastFactor(float contrast) {\r\n\treturn 1.0158730158730156 * (contrast + 1.0) / (1.0158730158730156 - contrast);\r\n}\r\n\r\n#ifndef new_format\r\n// Adjusts RGB values with gamma, contrast and brightness factors\r\nvec3 getRGB() {\r\n\t#if defined(use_rgb_gamma_contrast_brightness)\r\n\t\tvec3 rgb = pow(color, vec3(rgbGamma));\r\n\t\trgb += rgbBrightness;\r\n\t\trgb = (rgb - 0.5) * getContrastFactor(rgbContrast) + 0.5;\r\n\t\treturn clamp(rgb, 0.0, 1.0);\r\n\t#else\r\n\t\treturn color;\r\n\t#endif\r\n}\r\n#endif\r\n\r\n// Adjusts intensity value based on settings\r\nfloat getIntensity() {\r\n\tfloat w = (intensity - intensityRange.x) / (intensityRange.y - intensityRange.x);\r\n\tw = pow(w, intensityGamma) + intensityBrightness;\r\n\tw = (w - 0.5) * getContrastFactor(intensityContrast) + 0.5;\r\n\treturn clamp(w, 0.0, 1.0);\r\n}\r\n\r\n// Maps elevation to a gradient color\r\nvec3 getElevation() {\r\n\tvec4 world = modelMatrix * vec4(position, 1.0);\r\n\tfloat w = (world.z - heightMin) / (heightMax - heightMin);\r\n\treturn texture(gradient, vec2(w, 1.0 - w)).rgb;\r\n}\r\n\r\n// Gets classification color and transparency from texture LUT\r\nvec4 getClassification() {\r\n\tvec2 uv = vec2(classification / 255.0, 0.5);\r\n\treturn texture(classificationLUT, uv);\r\n}\r\n\r\n// Returns color based on number of returns and return number\r\nvec3 getReturnNumber() {\r\n\treturn (numberOfReturns == 1.0) ? vec3(1.0, 1.0, 0.0) :\r\n\t\t (returnNumber == 1.0) ? vec3(1.0, 0.0, 0.0) :\r\n\t\t (returnNumber == numberOfReturns) ? vec3(0.0, 0.0, 1.0) :\r\n\t\t\t\t\t\t\t\t\t\tvec3(0.0, 1.0, 0.0);\r\n}\r\n\r\n// Gets source ID color from gradient\r\nvec3 getSourceID() {\r\n\tfloat w = mod(pointSourceID, 10.0) / 10.0;\r\n\treturn texture(gradient, vec2(w, 1.0 - w)).rgb;\r\n}\r\n\r\n#ifndef new_format\r\n// Combines multiple color sources into one composite color\r\nvec3 getCompositeColor() {\r\n\tvec3 c = wRGB * getRGB();\r\n\tfloat w = wRGB;\r\n\tc += wIntensity * getIntensity() * vec3(1.0);\r\n\tw += wIntensity;\r\n\tc += wElevation * getElevation();\r\n\tw += wElevation;\r\n\tc += wReturnNumber * getReturnNumber();\r\n\tw += wReturnNumber;\r\n\tc += wSourceID * getSourceID();\r\n\tw += wSourceID;\r\n\r\n\tvec4 cl = wClassification * getClassification();\r\n\tc += cl.a * cl.rgb;\r\n\tw += wClassification * cl.a;\r\n\r\n\tc /= w;\r\n\tif (w == 0.0) {\r\n\t\tgl_Position = vec4(100.0, 100.0, 100.0, 0.0);\r\n\t}\r\n\treturn c;\r\n}\r\n#endif\r\n\r\n#ifdef new_format\r\n// sRGB conversion functions\r\nvec4 fromLinear(vec4 linearRGB) {\r\n\tbvec4 cutoff = lessThan(linearRGB, vec4(0.0031308));\r\n\treturn mix(linearRGB * vec4(12.92), vec4(1.055) * pow(linearRGB, vec4(1.0/2.4)) - vec4(0.055), cutoff);\r\n} \r\nvec4 toLinear(vec4 sRGB) {\r\n\tbvec4 cutoff = lessThan(sRGB, vec4(0.04045));\r\n\treturn mix(sRGB/vec4(12.92), pow((sRGB + vec4(0.055))/vec4(1.055), vec4(2.4)), cutoff);\r\n}\r\n#else\r\nvec3 fromLinear(vec3 linearRGB) {\r\n\tbvec3 cutoff = lessThan(linearRGB, vec3(0.0031308));\r\n\treturn mix(linearRGB * vec3(12.92), vec3(1.055) * pow(linearRGB, vec3(1.0/2.4)) - vec3(0.055), cutoff);\r\n}\r\nvec3 toLinear(vec3 sRGB) {\r\n\tbvec3 cutoff = lessThan(sRGB, vec3(0.04045));\r\n\treturn mix(sRGB/vec3(12.92), pow((sRGB + vec3(0.055))/vec3(1.055), vec3(2.4)), cutoff);\r\n}\r\n#endif\r\n\r\nvoid main() {\r\n\t// Compute model-view position and projected position\r\n\tvec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\r\n\tgl_Position = projectionMatrix * mvPosition;\r\n\tvViewPosition = mvPosition.xyz;\r\n\r\n\t#if defined weighted_splats\r\n\t\tvLinearDepth = gl_Position.w;\r\n\t#endif\r\n\r\n\t#if defined(color_type_phong) && (MAX_POINT_LIGHTS > 0 || MAX_DIR_LIGHTS > 0)\r\n\t\tvNormal = normalize(normalMatrix * normal);\r\n\t#endif\r\n\r\n\t#ifdef use_edl\r\n\t\tvLogDepth = log2(-mvPosition.z);\r\n\t#endif\r\n\r\n\r\n\t// POINT SIZE COMPUTATION\r\n\tfloat tanHalfFOV = tan(fov * 0.5);\r\n\tfloat projFactor = -0.5 * screenHeight / (tanHalfFOV * mvPosition.z);\r\n\t// Scale compensation based on transformation difference \r\n\tfloat scale = length(modelViewMatrix * vec4(0, 0, 0, 1) - modelViewMatrix * vec4(spacing, 0, 0, 1)) / spacing;\r\n\tprojFactor *= scale;\r\n\t\r\n\tfloat pointSize = 1.0;\r\n\t#if defined fixed_point_size\r\n\t\tpointSize = size;\r\n\t#elif defined attenuated_point_size\r\n\t\tpointSize = useOrthographicCamera ? size : size * spacing * projFactor;\r\n\t#elif defined adaptive_point_size\r\n\t\tfloat worldSpaceSize = 2.0 * size * spacing / getPointSizeAttenuation();\r\n\t\tpointSize = useOrthographicCamera ? (worldSpaceSize / orthoWidth) * screenWidth : worldSpaceSize * projFactor;\r\n\t#endif\r\n\r\n\tpointSize = clamp(pointSize, minSize, maxSize);\r\n\t#if defined(weighted_splats) || defined(paraboloid_point_shape)\r\n\t\tvRadius = pointSize / projFactor;\r\n\t#endif\r\n\t\r\n\tpointSize *= viewScale;\r\n\tgl_PointSize = pointSize;\r\n\r\n\r\n\t// HIGHLIGHTING\r\n\t#ifdef highlight_point\r\n\t\tvec4 mPosition = modelMatrix * vec4(position, 1.0);\r\n\t\tif (enablePointHighlighting &&\r\n\t\t\tabs(mPosition.x - highlightedPointCoordinate.x) < 0.0001 &&\r\n\t\t\tabs(mPosition.y - highlightedPointCoordinate.y) < 0.0001 &&\r\n\t\t\tabs(mPosition.z - highlightedPointCoordinate.z) < 0.0001) {\r\n\t\t\tvHighlight = 1.0;\r\n\t\t\tgl_PointSize = pointSize * highlightedPointScale;\r\n\t\t} else {\r\n\t\t\tvHighlight = 0.0;\r\n\t\t}\r\n\t#endif\r\n\r\n\r\n\t// OPACITY\r\n\t#ifndef color_type_point_index\r\n\t\t#ifdef attenuated_opacity\r\n\t\t\tvOpacity = opacity * exp(-length(-mvPosition.xyz) / opacityAttenuation);\r\n\t\t#else\r\n\t\t\tvOpacity = opacity;\r\n\t\t#endif\r\n\t#endif\r\n\r\n\r\n\t// NORMAL FILTERING\r\n\t#ifdef use_filter_by_normal\r\n\t\tif(abs((modelViewMatrix * vec4(normal, 0.0)).z) > filterByNormalThreshold) {\r\n\t\t\tgl_Position = vec4(0.0, 0.0, 2.0, 1.0); // Cull point\r\n\t\t}\r\n\t#endif\r\n\r\n\r\n\t// POINT COLOR SELECTION\r\n\t#ifdef new_format\r\n\t\tvColor = rgba;\r\n\t#elif defined color_type_rgb\r\n\t\tvColor = getRGB();\r\n\t#elif defined color_type_height\r\n\t\tvColor = getElevation();\r\n\t#elif defined color_type_rgb_height\r\n\t\tvec3 cHeight = getElevation();\r\n\t\tvColor = mix(getRGB(), cHeight, transition);\r\n\t#elif defined color_type_depth\r\n\t\tfloat linearDepth = -mvPosition.z;\r\n\t\tfloat expDepth = (gl_Position.z / gl_Position.w) * 0.5 + 0.5;\r\n\t\tvColor = vec3(linearDepth, expDepth, 0.0);\r\n\t#elif defined color_type_intensity\r\n\t\tfloat w = getIntensity();\r\n\t\tvColor = vec3(w);\r\n\t#elif defined color_type_intensity_gradient\r\n\t\tfloat w = getIntensity();\r\n\t\tvColor = texture(gradient, vec2(w, 1.0 - w)).rgb;\r\n\t#elif defined color_type_color\r\n\t\tvColor = uColor;\r\n\t#elif defined color_type_lod\r\n\t\tfloat w = getLOD() / 10.0;\r\n\t\tvColor = texture(gradient, vec2(w, 1.0 - w)).rgb;\r\n\t#elif defined color_type_point_index\r\n\t\tvColor = indices.rgb;\r\n\t#elif defined color_type_classification\r\n\t\tvec4 cl = getClassification();\r\n\t\tvColor = cl.rgb;\r\n\t#elif defined color_type_return_number\r\n\t\tvColor = getReturnNumber();\r\n\t#elif defined color_type_source\r\n\t\tvColor = getSourceID();\r\n\t#elif defined color_type_normal\r\n\t\tvColor = (modelMatrix * vec4(normal, 0.0)).xyz;\r\n\t#elif defined color_type_phong\r\n\t\tvColor = color;\r\n\t#elif defined color_type_composite\r\n\t\tvColor = getCompositeColor();\r\n\t#endif\r\n\t\r\n\t#if !defined color_type_composite && defined color_type_classification\r\n\t\tif (getClassification().a == 0.0) {\r\n\t\t\tgl_Position = vec4(100.0, 100.0, 100.0, 0.0); // Cull point if classification alpha is zero\r\n\t\t\treturn;\r\n\t\t}\r\n\t#endif\r\n\r\n\r\n\t// CLIPPING\r\n\t#if defined use_clip_box\r\n\t\tbool insideAny = false;\r\n\t\tfor (int i = 0; i < max_clip_boxes; i++) {\r\n\t\t\tif (i == int(clipBoxCount)) break;\r\n\t\t\tvec4 clipPosition = clipBoxes[i] * modelMatrix * vec4(position, 1.0);\r\n\t\t\tbool inside = abs(clipPosition.x) <= 0.5 && abs(clipPosition.y) <= 0.5 && abs(clipPosition.z) <= 0.5;\r\n\t\t\tinsideAny = insideAny || inside;\r\n\t\t}\r\n\r\n\t\t#if defined clip_outside\r\n\t\t\tif (!insideAny) { gl_Position = vec4(1000.0); } // Cull if outside any clip box\r\n\t\t#elif defined clip_inside\r\n\t\t\tif (insideAny) { gl_Position = vec4(1000.0); } // Cull if inside any clip box\r\n\t\t#elif defined clip_highlight_inside && !defined(color_type_depth)\r\n\t\t\tif (!insideAny) { /* additional processing if needed */ }\r\n\t\t#endif\r\n\r\n\t\t#if defined clip_highlight_inside\r\n\t\t\tif (insideAny) { vColor.r += 0.5; }\r\n\t\t#endif\r\n\t#endif\r\n\r\n\r\n\t// COLOR ENCODING ADJUSTMENTS\r\n\t#if defined(output_color_encoding_sRGB) && defined(input_color_encoding_linear) && !defined(color_type_point_index)\r\n\t\tvColor = toLinear(vColor);\r\n\t#endif\r\n\r\n\t#if defined(output_color_encoding_linear) && defined(input_color_encoding_sRGB) && !defined(color_type_point_index)\r\n\t\tvColor = fromLinear(vColor);\r\n\t#endif\r\n}\r\n";},512:e=>{e.exports=function(e,t,n,i){var r=self||window;try{try{var o;try{o=new r.Blob([e]);}catch(t){(o=new(r.BlobBuilder||r.WebKitBlobBuilder||r.MozBlobBuilder||r.MSBlobBuilder)).append(e),o=o.getBlob();}var a=r.URL||r.webkitURL,s=a.createObjectURL(o),l=new r[t](s,n);return a.revokeObjectURL(s),l}catch(i){return new r[t]("data:application/javascript,".concat(encodeURIComponent(e)),n)}}catch(e){if(!i)throw Error("Inline worker is not supported");return new r[t](i,n)}};},290:(e,t,n)=>{n.d(t,{A:()=>r});var i=n(512);function r(){return i('const e={DATA_TYPE_DOUBLE:{ordinal:0,name:"double",size:8},DATA_TYPE_FLOAT:{ordinal:1,name:"float",size:4},DATA_TYPE_INT8:{ordinal:2,name:"int8",size:1},DATA_TYPE_UINT8:{ordinal:3,name:"uint8",size:1},DATA_TYPE_INT16:{ordinal:4,name:"int16",size:2},DATA_TYPE_UINT16:{ordinal:5,name:"uint16",size:2},DATA_TYPE_INT32:{ordinal:6,name:"int32",size:4},DATA_TYPE_UINT32:{ordinal:7,name:"uint32",size:4},DATA_TYPE_INT64:{ordinal:8,name:"int64",size:8},DATA_TYPE_UINT64:{ordinal:9,name:"uint64",size:8}};let t=0;for(let n in e)e[t]=e[n],t++;class n{constructor(e,t,n,i=[1/0,-1/0]){this.name=e,this.type=t,this.numElements=n,this.range=i,this.byteSize=this.numElements*this.type.size,this.description=""}}new n("POSITION_CARTESIAN",e.DATA_TYPE_FLOAT,3),new n("COLOR_PACKED",e.DATA_TYPE_INT8,4),new n("COLOR_PACKED",e.DATA_TYPE_INT8,4),new n("COLOR_PACKED",e.DATA_TYPE_INT8,3),new n("NORMAL_FLOATS",e.DATA_TYPE_FLOAT,3),new n("INTENSITY",e.DATA_TYPE_UINT16,1),new n("CLASSIFICATION",e.DATA_TYPE_UINT8,1),new n("NORMAL_SPHEREMAPPED",e.DATA_TYPE_UINT8,2),new n("NORMAL_OCT16",e.DATA_TYPE_UINT8,2),new n("NORMAL",e.DATA_TYPE_FLOAT,3),new n("RETURN_NUMBER",e.DATA_TYPE_UINT8,1),new n("NUMBER_OF_RETURNS",e.DATA_TYPE_UINT8,1),new n("SOURCE_ID",e.DATA_TYPE_UINT16,1),new n("INDICES",e.DATA_TYPE_UINT32,1),new n("SPACING",e.DATA_TYPE_FLOAT,1),new n("GPS_TIME",e.DATA_TYPE_DOUBLE,1);const i=function(){var e=new Int8Array(0);function t(e){this.data=e,this.offset=0}var n=Int32Array.from([256,402,436,468,500,534,566,598,630,662,694,726,758,790,822,854,886,920,952,984,1016,1048,1080]),i=Int32Array.from([1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15]),a=Int32Array.from([0,3,2,1,0,0,0,0,0,0,3,3,3,3,3,3]),o=Int32Array.from([0,0,0,0,-1,1,-2,2,-3,3,-1,1,-2,2,-3,3]),r=Int32Array.from([131072,131076,131075,196610,131072,131076,131075,262145,131072,131076,131075,196610,131072,131076,131075,262149]),s=Int32Array.from([0,0,0,0,0,4096,9216,21504,35840,44032,53248,63488,74752,87040,93696,100864,104704,106752,108928,113536,115968,118528,119872,121280,122016]),l=Int32Array.from([0,0,0,0,10,10,11,11,10,10,10,10,10,9,9,8,7,7,8,7,7,6,6,5,5]),c=Int32Array.from([1,5,9,13,17,25,33,41,49,65,81,97,113,145,177,209,241,305,369,497,753,1265,2289,4337,8433,16625]),d=Int32Array.from([2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,7,8,9,10,11,12,13,24]),h=Int16Array.from([0,0,0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,7,8,9,10,12,14,24]),f=Int16Array.from([0,0,0,0,0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,7,8,9,10,24]),u=new Int16Array(2816);function p(e){for(var t=-1,n=16;n>0;)e>>>n!=0&&(t+=n,e>>>=n),n>>=1;return t+e}function m(e,t,n){return 16+t+2*(n<<e)}function g(e,t,n){if(e<n+(2<<t))throw"maxDistance is too small";var i=4+(e-n>>t),a=p(i)-1;return((a-1<<1|i>>a&1)-1<<t)+(1<<t)+n+16}function P(e){if(e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),0!=U(e,1)){var t=U(e,3);return 0==t?1:U(e,t)+(1<<t)}return 0}function $(e,t,n){var i=e[t],a=n.accumulator32>>>n.bitOffset,o=e[i+=255&a]>>16,r=65535&e[i];return o<=8?(n.bitOffset+=o,r):(i+=r,i+=(a&(1<<o)-1)>>>8,n.bitOffset+=8+(e[i]>>16),65535&e[i])}function b(e,t,n){n.bitOffset>=16&&(n.accumulator32=n.shortBuffer[n.halfOffset++]<<16|n.accumulator32>>>16,n.bitOffset-=16);var i=$(e,t,n),a=d[i];return n.bitOffset>=16&&(n.accumulator32=n.shortBuffer[n.halfOffset++]<<16|n.accumulator32>>>16,n.bitOffset-=16),c[i]+(a<=16?U(n,a):_(n,a))}function v(e,t){for(var n=e[t];t>0;t--)e[t]=e[t-1];e[0]=n}function y(e,t,n,a,o){o.halfOffset>2030&&N(o),o.bitOffset>=16&&(o.accumulator32=o.shortBuffer[o.halfOffset++]<<16|o.accumulator32>>>16,o.bitOffset-=16);var s=U(o,2);return 1==s?function(e,t,n,i,a){for(var o=new Int32Array(t),r=new Int32Array(4),s=1+p(e-1),l=U(a,2)+1,c=0;c<l;c++){a.bitOffset>=16&&(a.accumulator32=a.shortBuffer[a.halfOffset++]<<16|a.accumulator32>>>16,a.bitOffset-=16);var d=U(a,s);if(d>=t)throw"Can\'t readHuffmanCode";r[c]=d}!function(e,t){for(var n=0;n<t-1;++n)for(var i=n+1;i<t;++i)if(e[n]==e[i])throw"Duplicate simple Huffman code symbol"}(r,l);var h=l;switch(4==l&&(h+=U(a,1)),h){case 1:o[r[0]]=1;break;case 2:o[r[0]]=1,o[r[1]]=1;break;case 3:o[r[0]]=1,o[r[1]]=2,o[r[2]]=2;break;case 4:o[r[0]]=2,o[r[1]]=2,o[r[2]]=2,o[r[3]]=2;break;case 5:o[r[0]]=1,o[r[1]]=2,o[r[2]]=3,o[r[3]]=3}return L(n,i,8,o,t)}(e,t,n,a,o):function(e,t,n,a,o){for(var s=new Int32Array(e),l=new Int32Array(18),c=32,d=0,h=t;h<18&&c>0;h++){var f=i[h];o.bitOffset>=16&&(o.accumulator32=o.shortBuffer[o.halfOffset++]<<16|o.accumulator32>>>16,o.bitOffset-=16);var u=o.accumulator32>>>o.bitOffset&15;o.bitOffset+=r[u]>>16;var p=65535&r[u];l[f]=p,0!=p&&(c-=32>>p,d++)}if(0!=c&&1!=d)throw"Corrupted Huffman code histogram";return function(e,t,n,i){var a=0,o=8,r=0,s=0,l=32768,c=new Int32Array(33);for(L(c,c.length-1,5,e,18);a<t&&l>0;){i.halfOffset>2030&&N(i),i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16);var d=i.accumulator32>>>i.bitOffset&31;i.bitOffset+=c[d]>>16;var h=65535&c[d];if(h<16)r=0,n[a++]=h,0!=h&&(o=h,l-=32768>>h);else{var f=h-14,u=0;16==h&&(u=o),s!=u&&(r=0,s=u);var p=r;r>0&&(r-=2,r<<=f),i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16);var m=(r+=U(i,f)+3)-p;if(a+m>t)throw"symbol + repeatDelta > numSymbols";for(var g=0;g<m;g++)n[a++]=s;0!=s&&(l-=m<<15-s)}}if(0!=l)throw"Unused space";n.fill(0,a,t)}(l,e,s,o),L(n,a,8,s,e)}(t,s,n,a,o)}function X(e,t,i){i.halfOffset>2030&&N(i);var a=P(i)+1;if(1==a)return t.fill(0,0,e),a;i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16);var o=0;0!=U(i,1)&&(o=U(i,4)+1);var r=a+o,s=n[r+31>>5],l=new Int32Array(s+1),c=l.length-1;y(r,r,l,c,i);for(var d=0;d<e;){i.halfOffset>2030&&N(i),i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16);var h=$(l,c,i);if(0==h)t[d]=0,d++;else if(h<=o){i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16);for(var f=(1<<h)+U(i,h);0!=f;){if(d>=e)throw"Corrupted context map";t[d]=0,d++,f--}}else t[d]=h-o,d++}return i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16),1==U(i,1)&&function(e,t){for(var n=new Int32Array(256),i=0;i<256;i++)n[i]=i;for(i=0;i<t;i++){var a=255&e[i];e[i]=n[a],0!=a&&v(n,a)}}(t,e),a}function w(e,t,n){var i=e.rings,a=4+2*t;e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16);var o=$(e.blockTrees,2*t,e),r=b(e.blockTrees,2*t+1,e);return 1==o?o=i[a+1]+1:0==o?o=i[a]:o-=2,o>=n&&(o-=n),i[a]=i[a+1],i[a+1]=o,r}function Y(e){e.literalBlockLength=w(e,0,e.numLiteralBlockTypes);var t=e.rings[5];e.contextMapSlice=t<<6,e.literalTreeIdx=255&e.contextMap[e.contextMapSlice];var n=e.contextModes[t];e.contextLookupOffset1=n<<9,e.contextLookupOffset2=e.contextLookupOffset1+256}function Q(e){e.commandBlockLength=w(e,1,e.numCommandBlockTypes),e.commandTreeIdx=e.rings[7]}function x(e){e.distanceBlockLength=w(e,2,e.numDistanceBlockTypes),e.distContextMapSlice=e.rings[9]<<2}function k(e){if(0!=e.inputEnd)return e.nextRunningState=10,void(e.runningState=12);e.literalTreeGroup=new Int32Array(0),e.commandTreeGroup=new Int32Array(0),e.distanceTreeGroup=new Int32Array(0),e.halfOffset>2030&&N(e),function(e){if(e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),e.inputEnd=U(e,1),e.metaBlockLength=0,e.isUncompressed=0,e.isMetadata=0,0==e.inputEnd||0==U(e,1)){var t=U(e,2)+4;if(7==t){if(e.isMetadata=1,0!=U(e,1))throw"Corrupted reserved bit";var n=U(e,2);if(0==n)return;for(var i=0;i<n;i++){if(e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),0==(a=U(e,8))&&i+1==n&&n>1)throw"Exuberant nibble";e.metaBlockLength|=a<<8*i}}else for(i=0;i<t;i++){var a;if(e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),0==(a=U(e,4))&&i+1==t&&t>4)throw"Exuberant nibble";e.metaBlockLength|=a<<4*i}e.metaBlockLength++,0==e.inputEnd&&(e.isUncompressed=U(e,1))}}(e),0==e.metaBlockLength&&0==e.isMetadata||(0!=e.isUncompressed||0!=e.isMetadata?(H(e),e.runningState=0!=e.isMetadata?5:6):e.runningState=3,0==e.isMetadata&&(e.expectedTotalSize+=e.metaBlockLength,e.expectedTotalSize>1<<30&&(e.expectedTotalSize=1<<30),e.ringBufferSize<e.maxRingBufferSize&&function(e){var t=e.maxRingBufferSize;if(t>e.expectedTotalSize){for(var n=e.expectedTotalSize;t>>1>n;)t>>=1;0==e.inputEnd&&t<16384&&e.maxRingBufferSize>=16384&&(t=16384)}if(!(t<=e.ringBufferSize)){var i=new Int8Array(t+37);0!=e.ringBuffer.length&&i.set(e.ringBuffer.subarray(0,0+e.ringBufferSize),0),e.ringBuffer=i,e.ringBufferSize=t}}(e)))}function C(e,t,n){var i=e.blockTrees[2*t];if(n<=1)return e.blockTrees[2*t+1]=i,e.blockTrees[2*t+2]=i,1<<28;var a=n+2;return i+=y(a,a,e.blockTrees,2*t,e),e.blockTrees[2*t+1]=i,i+=y(26,26,e.blockTrees,2*t+1,e),e.blockTrees[2*t+2]=i,b(e.blockTrees,2*t+1,e)}function A(e){e.numLiteralBlockTypes=P(e)+1,e.literalBlockLength=C(e,0,e.numLiteralBlockTypes),e.numCommandBlockTypes=P(e)+1,e.commandBlockLength=C(e,1,e.numCommandBlockTypes),e.numDistanceBlockTypes=P(e)+1,e.distanceBlockLength=C(e,2,e.numDistanceBlockTypes),e.halfOffset>2030&&N(e),e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),e.distancePostfixBits=U(e,2),e.numDirectDistanceCodes=U(e,4)<<e.distancePostfixBits,e.distancePostfixMask=(1<<e.distancePostfixBits)-1,e.contextModes=new Int8Array(e.numLiteralBlockTypes);for(var t=0;t<e.numLiteralBlockTypes;){for(var n=V(t+96,e.numLiteralBlockTypes);t<n;++t)e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),e.contextModes[t]=U(e,2);e.halfOffset>2030&&N(e)}e.contextMap=new Int8Array(e.numLiteralBlockTypes<<6);var i=X(e.numLiteralBlockTypes<<6,e.contextMap,e);e.trivialLiteralContext=1;for(var a=0;a<e.numLiteralBlockTypes<<6;a++)if(e.contextMap[a]!=a>>6){e.trivialLiteralContext=0;break}e.distContextMap=new Int8Array(e.numDistanceBlockTypes<<2);var o=X(e.numDistanceBlockTypes<<2,e.distContextMap,e);e.literalTreeGroup=I(256,256,i,e),e.commandTreeGroup=I(704,704,e.numCommandBlockTypes,e);var r=m(e.distancePostfixBits,e.numDirectDistanceCodes,24),s=r;1==e.isLargeWindow&&(r=m(e.distancePostfixBits,e.numDirectDistanceCodes,62),s=g(2147483644,e.distancePostfixBits,e.numDirectDistanceCodes)),e.distanceTreeGroup=I(r,s,o,e),function(e,t){for(var n=e.distExtraBits,i=e.distOffset,a=e.distancePostfixBits,o=e.numDirectDistanceCodes,r=1<<a,s=1,l=0,c=16,d=0;d<o;++d)n[c]=0,i[c]=d+1,++c;for(;c<t;){var h=o+((2+l<<s)-4<<a)+1;for(d=0;d<r;++d)n[c]=s,i[c]=h+d,++c;s+=l,l^=1}}(e,s),e.contextMapSlice=0,e.distContextMapSlice=0,e.contextLookupOffset1=512*e.contextModes[0],e.contextLookupOffset2=e.contextLookupOffset1+256,e.literalTreeIdx=0,e.commandTreeIdx=0,e.rings[4]=1,e.rings[5]=0,e.rings[6]=1,e.rings[7]=0,e.rings[8]=1,e.rings[9]=0}function T(e){var t=e.ringBuffer;if(e.metaBlockLength<=0)return F(e),void(e.runningState=2);var n=V(e.ringBufferSize-e.pos,e.metaBlockLength);if(function(e,t,n,i){if(7&e.bitOffset)throw"Unaligned copyBytes";for(;32!=e.bitOffset&&0!=i;)t[n++]=e.accumulator32>>>e.bitOffset,e.bitOffset+=8,i--;if(0!=i){var a=V(W(e),i>>1);if(a>0){var o=e.halfOffset<<1,r=a<<1;t.set(e.byteBuffer.subarray(o,o+r),n),n+=r,i-=r,e.halfOffset+=a}if(0!=i)if(W(e)>0){for(e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16);0!=i;)t[n++]=e.accumulator32>>>e.bitOffset,e.bitOffset+=8,i--;M(e,0)}else for(;i>0;){var s=Z(e.input,t,n,i);if(-1==s)throw"Unexpected end of input";n+=s,i-=s}}}(e,t,e.pos,n),e.metaBlockLength-=n,e.pos+=n,e.pos==e.ringBufferSize)return e.nextRunningState=6,void(e.runningState=12);F(e),e.runningState=2}function B(e){var t=V(e.outputLength-e.outputUsed,e.ringBufferBytesReady-e.ringBufferBytesWritten);return 0!=t&&(e.output.set(e.ringBuffer.subarray(e.ringBufferBytesWritten,e.ringBufferBytesWritten+t),e.outputOffset+e.outputUsed),e.outputUsed+=t,e.ringBufferBytesWritten+=t),e.outputUsed<e.outputLength?1:0}function I(e,t,i,a){for(var o=n[t+31>>5],r=new Int32Array(i+i*o),s=i,l=0;l<i;++l)r[l]=s,s+=y(e,t,r,l,a);return r}function O(e){var t=e.ringBufferSize;return 0!=e.isEager&&(t=V(t,e.ringBufferBytesWritten+e.outputLength-e.outputUsed)),t}function S(t){if(0==t.runningState)throw"Can\'t decompress until initialized";if(11==t.runningState)throw"Can\'t decompress after close";if(1==t.runningState){var n=function(e){var t=e.isLargeWindow;if(e.isLargeWindow=0,e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),0==U(e,1))return 16;var n=U(e,3);return 0!=n?17+n:0!=(n=U(e,3))?1==n?0==t?-1:(e.isLargeWindow=1,1==U(e,1)||(n=U(e,6))<10||n>30?-1:n):8+n:17}(t);if(-1==n)throw"Invalid \'windowBits\' code";t.maxRingBufferSize=1<<n,t.maxBackwardDistance=t.maxRingBufferSize-16,t.runningState=2}for(var i=O(t),r=t.ringBufferSize-1,c=t.ringBuffer;10!=t.runningState;)switch(t.runningState){case 2:if(t.metaBlockLength<0)throw"Invalid metablock length";k(t),i=O(t),r=t.ringBufferSize-1,c=t.ringBuffer;continue;case 3:A(t),t.runningState=4;case 4:if(t.metaBlockLength<=0){t.runningState=2;continue}t.halfOffset>2030&&N(t),0==t.commandBlockLength&&Q(t),t.commandBlockLength--,t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16);var d=$(t.commandTreeGroup,t.commandTreeIdx,t)<<2,h=u[d],f=u[d+1],p=u[d+2];t.distanceCode=u[d+3],t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16);var m=255&h;t.insertLength=f+(m<=16?U(t,m):_(t,m)),t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16),m=h>>8,t.copyLength=p+(m<=16?U(t,m):_(t,m)),t.j=0,t.runningState=7;case 7:if(0!=t.trivialLiteralContext){for(;t.j<t.insertLength;)if(t.halfOffset>2030&&N(t),0==t.literalBlockLength&&Y(t),t.literalBlockLength--,t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16),c[t.pos]=$(t.literalTreeGroup,t.literalTreeIdx,t),t.pos++,t.j++,t.pos>=i){t.nextRunningState=7,t.runningState=12;break}}else for(var g=255&c[t.pos-1&r],P=255&c[t.pos-2&r];t.j<t.insertLength;){t.halfOffset>2030&&N(t),0==t.literalBlockLength&&Y(t);var b=G[t.contextLookupOffset1+g]|G[t.contextLookupOffset2+P],v=255&t.contextMap[t.contextMapSlice+b];if(t.literalBlockLength--,P=g,t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16),g=$(t.literalTreeGroup,v,t),c[t.pos]=g,t.pos++,t.j++,t.pos>=i){t.nextRunningState=7,t.runningState=12;break}}if(7!=t.runningState)continue;if(t.metaBlockLength-=t.insertLength,t.metaBlockLength<=0){t.runningState=4;continue}var y=t.distanceCode;if(y<0)t.distance=t.rings[t.distRbIdx];else{t.halfOffset>2030&&N(t),0==t.distanceBlockLength&&x(t),t.distanceBlockLength--,t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16);var X=255&t.distContextMap[t.distContextMapSlice+y];if((y=$(t.distanceTreeGroup,X,t))<16){var w=t.distRbIdx+a[y]&3;if(t.distance=t.rings[w]+o[y],t.distance<0)throw"Negative distance"}else{var C;m=t.distExtraBits[y],t.bitOffset+m<=32?C=U(t,m):(t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16),C=m<=16?U(t,m):_(t,m)),t.distance=t.distOffset[y]+(C<<t.distancePostfixBits)}}if(t.maxDistance!=t.maxBackwardDistance&&t.pos<t.maxBackwardDistance?t.maxDistance=t.pos:t.maxDistance=t.maxBackwardDistance,t.distance>t.maxDistance){t.runningState=9;continue}if(y>0&&(t.distRbIdx=t.distRbIdx+1&3,t.rings[t.distRbIdx]=t.distance),t.copyLength>t.metaBlockLength)throw"Invalid backward reference";t.j=0,t.runningState=8;case 8:var I=t.pos-t.distance&r,S=t.pos,q=t.copyLength-t.j,D=I+q,z=S+q;if(D<r&&z<r){if(q<12||D>S&&z>I)for(var L=0;L<q;L+=4)c[S++]=c[I++],c[S++]=c[I++],c[S++]=c[I++],c[S++]=c[I++];else c.copyWithin(S,I,D);t.j+=q,t.metaBlockLength-=q,t.pos+=q}else for(;t.j<t.copyLength;)if(c[t.pos]=c[t.pos-t.distance&r],t.metaBlockLength--,t.pos++,t.j++,t.pos>=i){t.nextRunningState=8,t.runningState=12;break}8==t.runningState&&(t.runningState=4);continue;case 9:if(t.distance>2147483644)throw"Invalid backward reference";if(!(t.copyLength>=4&&t.copyLength<=24))throw"Invalid backward reference";var R=s[t.copyLength],F=t.distance-t.maxDistance-1,W=l[t.copyLength],J=F>>>W;if(R+=(F&(1<<W)-1)*t.copyLength,!(J<121))throw"Invalid backward reference";var K=E(c,t.pos,e,R,t.copyLength,j,J);if(t.pos+=K,t.metaBlockLength-=K,t.pos>=i){t.nextRunningState=4,t.runningState=12;continue}t.runningState=4;continue;case 5:for(;t.metaBlockLength>0;)t.halfOffset>2030&&N(t),t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16),U(t,8),t.metaBlockLength--;t.runningState=2;continue;case 6:T(t);continue;case 12:t.ringBufferBytesReady=V(t.pos,t.ringBufferSize),t.runningState=13;case 13:if(0==B(t))return;t.pos>=t.maxBackwardDistance&&(t.maxDistance=t.maxBackwardDistance),t.pos>=t.ringBufferSize&&(t.pos>t.ringBufferSize&&c.copyWithin(0,t.ringBufferSize,t.pos),t.pos&=r,t.ringBufferBytesWritten=0),t.runningState=t.nextRunningState;continue;default:throw"Unexpected state "+t.runningState}if(10==t.runningState){if(t.metaBlockLength<0)throw"Invalid metablock length";H(t),M(t,1)}}!function(e){var t=new Int16Array(24),n=new Int16Array(24);n[0]=2;for(var i=0;i<23;++i)t[i+1]=t[i]+(1<<h[i]),n[i+1]=n[i]+(1<<f[i]);for(var a=0;a<704;++a){var o=a>>>6,r=-4;o>=2&&(o-=2,r=0);var s=(170064>>>2*o&3)<<3|a>>>3&7,l=(156228>>>2*o&3)<<3|7&a,c=n[l],d=r+(c>4?3:c-2),u=4*a;e[u+0]=h[s]|f[l]<<8,e[u+1]=t[s],e[u+2]=n[l],e[u+3]=d}}(u);var j=new function(){this.numTransforms=0,this.triplets=new Int32Array(0),this.prefixSuffixStorage=new Int8Array(0),this.prefixSuffixHeads=new Int32Array(0),this.params=new Int16Array(0),this.numTransforms=121,this.triplets=new Int32Array(363),this.params=new Int16Array(121),this.prefixSuffixStorage=new Int8Array(167),this.prefixSuffixHeads=new Int32Array(51)}(121,167,50);function E(e,t,n,i,a,o,r){var s=t,l=o.triplets,c=o.prefixSuffixStorage,d=o.prefixSuffixHeads,h=3*r,f=l[h],u=l[h+1],p=l[h+2],m=d[f],g=d[f+1],P=d[p],$=d[p+1],b=u-11,v=u-0;for((b<1||b>9)&&(b=0),(v<1||v>9)&&(v=0);m!=g;)e[s++]=c[m++];b>a&&(b=a),i+=b,a-=b;for(var y=a-=v;y>0;)e[s++]=n[i++],y--;if(10==u||11==u){var X=s-a;for(10==u&&(a=1);a>0;)(x=255&e[X])<192?(x>=97&&x<=122&&(e[X]^=32),X+=1,a-=1):x<224?(e[X+1]^=32,X+=2,a-=2):(e[X+2]^=5,X+=3,a-=3)}else if(21==u||22==u)for(var w=s-a,Y=o.params[r],Q=16777216-(32768&Y)+(32767&Y);a>0;){var x,k=1;if((x=255&e[w])<128)Q+=x,e[w]=127&Q;else if(x<192);else if(x<224)a>=2?(Q+=63&(C=e[w+1])|(31&x)<<6,e[w]=192|Q>>6&31,e[w+1]=192&C|63&Q,k=2):k=a;else if(x<240)if(a>=3){var C=e[w+1];Q+=63&(A=e[w+2])|(63&C)<<6|(15&x)<<12,e[w]=224|Q>>12&15,e[w+1]=192&C|Q>>6&63,e[w+2]=192&A|63&Q,k=3}else k=a;else if(x<248)if(a>=4){C=e[w+1];var A=e[w+2],T=e[w+3];Q+=63&T|(63&A)<<6|(63&C)<<12|(7&x)<<18,e[w]=240|Q>>18&7,e[w+1]=192&C|Q>>12&63,e[w+2]=192&A|Q>>6&63,e[w+3]=192&T|63&Q,k=4}else k=a;w+=k,a-=k,21==u&&(a=0)}for(;P!=$;)e[s++]=c[P++];return s-t}function q(e,t){for(var n=1<<t-1;e&n;)n>>=1;return(e&n-1)+n}function D(e,t,n,i,a){do{e[t+(i-=n)]=a}while(i>0)}function z(e,t,n){for(var i=1<<t-n;t<15&&!((i-=e[t])<=0);)t++,i<<=1;return t-n}function L(e,t,n,i,a){var o,r,s=e[t],l=new Int32Array(a),c=new Int32Array(16),d=new Int32Array(16);for(r=0;r<a;r++)c[i[r]]++;d[1]=0;for(var h=1;h<15;h++)d[h+1]=d[h]+c[h];for(r=0;r<a;r++)0!=i[r]&&(l[d[i[r]]++]=r);var f=n,u=1<<f,p=u;if(1==d[15]){for(o=0;o<p;o++)e[s+o]=l[0];return p}o=0,r=0,h=1;for(var m=2;h<=n;h++,m<<=1)for(;c[h]>0;c[h]--)D(e,s+o,m,u,h<<16|l[r++]),o=q(o,h);var g=p-1,P=-1,$=s;for(h=n+1,m=2;h<=15;h++,m<<=1)for(;c[h]>0;c[h]--)(o&g)!=P&&($+=u,p+=u=1<<(f=z(c,h,n)),e[s+(P=o&g)]=f+n<<16|$-s-P),D(e,$+(o>>n),m,u,h-n<<16|l[r++]),o=q(o,h);return p}function N(e){if(0!=e.endOfStreamReached){if(W(e)>=-2)return;throw"No more input"}var t=e.halfOffset<<1,n=4096-t;for(e.byteBuffer.copyWithin(0,t,4096),e.halfOffset=0;n<4096;){var i=4096-n,a=Z(e.input,e.byteBuffer,n,i);if(a<=0){e.endOfStreamReached=1,e.tailBytes=n,n+=1;break}n+=a}!function(e,t){for(var n=e.byteBuffer,i=t>>1,a=e.shortBuffer,o=0;o<i;++o)a[o]=255&n[2*o]|(255&n[2*o+1])<<8}(e,n)}function M(e,t){if(0!=e.endOfStreamReached){var n=(e.halfOffset<<1)+(e.bitOffset+7>>3)-4;if(n>e.tailBytes)throw"Read after end";if(0!=t&&n!=e.tailBytes)throw"Unused bytes after end"}}function U(e,t){var n=e.accumulator32>>>e.bitOffset&(1<<t)-1;return e.bitOffset+=t,n}function _(e,t){var n=U(e,16);return e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16,n|U(e,t-16)<<16}function R(e){e.halfOffset>2030&&N(e),M(e,0),e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16,e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16}function F(e){32==e.bitOffset&&R(e)}function H(e){var t=32-e.bitOffset&7;if(0!=t&&0!=U(e,t))throw"Corrupted padding bits"}function W(e){var t=2048;return 0!=e.endOfStreamReached&&(t=e.tailBytes+1>>1),t-e.halfOffset}!function(e,t,n,i){for(var a=1,o=0,r=0;r<217;++r){var s=i.charCodeAt(r);35==s?t[a++]=o:e[o++]=s}for(r=0;r<363;++r)n[r]=" !! ! , *! &! \\" ! ) * * - ! # ! #!*! + ,$ ! - % . / # 0 1 . \\" 2 3!* 4% ! # / 5 6 7 8 0 1 & $ 9 + : ; < \' != > ?! 4 @ 4 2 & A *# ( B C& ) % ) !*# *-% A +! *. D! %\' & E *6 F G% ! *A *% H! D I!+! J!+ K +- *4! A L!*4 M N +6 O!*% +.! K *G P +%( ! G *D +D Q +# *K!*G!+D!+# +G +A +4!+% +K!+4!*D!+K!*K".charCodeAt(r)-32}(j.prefixSuffixStorage,j.prefixSuffixHeads,j.triplets,\'# #s #, #e #.# the #.com/# # of # and # in # to #"#">#\\n#]# for # a # that #. # with #\\\'# from # by #. The # on # as # is #ing #\\n\\t#:#ed #(# at #ly #="# of the #. This #,# not #er #al #=\\\'#ful #ive #less #est #ize #ous #\');var G=new Int32Array(2048);function J(){this.ringBuffer=new Int8Array(0),this.contextModes=new Int8Array(0),this.contextMap=new Int8Array(0),this.distContextMap=new Int8Array(0),this.distExtraBits=new Int8Array(0),this.output=new Int8Array(0),this.byteBuffer=new Int8Array(0),this.shortBuffer=new Int16Array(0),this.intBuffer=new Int32Array(0),this.rings=new Int32Array(0),this.blockTrees=new Int32Array(0),this.literalTreeGroup=new Int32Array(0),this.commandTreeGroup=new Int32Array(0),this.distanceTreeGroup=new In