@cesium/engine 18.3.1-ion.1 → 20.0.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.
Files changed (192) hide show
  1. package/Build/ThirdParty/Workers/pako_deflate.min.js +3 -3
  2. package/Build/ThirdParty/Workers/pako_inflate.min.js +3 -3
  3. package/Build/ThirdParty/Workers/z-worker-pako.js +80 -89
  4. package/Build/Workers/{chunk-G7F2CKBW.js → chunk-22LUVCO3.js} +2 -2
  5. package/Build/Workers/{chunk-AIBIEA2N.js → chunk-3BO4XBWM.js} +12 -12
  6. package/Build/Workers/{chunk-LPLMZKZS.js → chunk-3SQPZVG4.js} +1 -1
  7. package/Build/Workers/{chunk-KQ7OYXT6.js → chunk-4O5SZ2RE.js} +3 -3
  8. package/Build/Workers/{chunk-EF747DYS.js → chunk-4UIKSIEZ.js} +9 -9
  9. package/Build/Workers/{chunk-LDFRBRJO.js → chunk-5FZEM66Y.js} +12 -12
  10. package/Build/Workers/{chunk-Z7UO3S7L.js → chunk-5G56VVL3.js} +10 -10
  11. package/Build/Workers/{chunk-KUVAFSVU.js → chunk-5GKRDXYJ.js} +12 -12
  12. package/Build/Workers/{chunk-GIRJEZHU.js → chunk-5W4EBNO3.js} +14 -14
  13. package/Build/Workers/{chunk-XMFKOU5X.js → chunk-67RLCIDP.js} +7 -7
  14. package/Build/Workers/{chunk-ACOAKTBU.js → chunk-74VODBWB.js} +4 -4
  15. package/Build/Workers/{chunk-QTFE5TBC.js → chunk-7HOD2LGH.js} +10 -10
  16. package/Build/Workers/{chunk-GOSJZP7N.js → chunk-D25QOWHR.js} +1 -1
  17. package/Build/Workers/{chunk-5UWLMG6V.js → chunk-D63DK275.js} +7 -7
  18. package/Build/Workers/{chunk-4JMMKZ4N.js → chunk-EHOOC4HJ.js} +5 -5
  19. package/Build/Workers/{chunk-PFTYXAVG.js → chunk-ELI5ZYDR.js} +5 -5
  20. package/Build/Workers/{chunk-RQRKALHB.js → chunk-FGF4ETPY.js} +9 -9
  21. package/Build/Workers/{chunk-YPMSP4IH.js → chunk-FKWL63D4.js} +5 -5
  22. package/Build/Workers/{chunk-IC5M3JRR.js → chunk-FLH3ZH2X.js} +4 -4
  23. package/Build/Workers/{chunk-5DF22LFV.js → chunk-HDOFAYEE.js} +16 -16
  24. package/Build/Workers/{chunk-37V6UO2J.js → chunk-HHUHFFYN.js} +5 -5
  25. package/Build/Workers/{chunk-GSLSXQGX.js → chunk-IHUXLSNT.js} +5 -4
  26. package/Build/Workers/{chunk-K4HUWRWA.js → chunk-IJM2HVTV.js} +1 -1
  27. package/Build/Workers/{chunk-AKLRSDAY.js → chunk-IPXMWP5Z.js} +6 -6
  28. package/Build/Workers/{chunk-G6I5XO4E.js → chunk-IWKYS6RV.js} +6 -6
  29. package/Build/Workers/{chunk-RVQ7LHW3.js → chunk-JMX3P7DE.js} +8 -8
  30. package/Build/Workers/{chunk-OQNQNBEM.js → chunk-JQSMAZAT.js} +9 -9
  31. package/Build/Workers/{chunk-GGNZKIG3.js → chunk-JRLT2FQV.js} +8 -8
  32. package/Build/Workers/{chunk-GK5WVMVN.js → chunk-KRXL3KZL.js} +13 -13
  33. package/Build/Workers/{chunk-OVXYMPQ7.js → chunk-KWB7PPVO.js} +2 -2
  34. package/Build/Workers/{chunk-DG4CHTQN.js → chunk-M62PWLGC.js} +16 -16
  35. package/Build/Workers/{chunk-T3UE5LOS.js → chunk-MSLO3MQF.js} +5 -5
  36. package/Build/Workers/{chunk-ZGH3R3CO.js → chunk-MZZK44UI.js} +6 -6
  37. package/Build/Workers/{chunk-3T2QV5NN.js → chunk-NB2NKFJL.js} +6 -6
  38. package/Build/Workers/{chunk-W2EMENZQ.js → chunk-NJYFQE5B.js} +1 -1
  39. package/Build/Workers/{chunk-GG2NLIC6.js → chunk-O2O4FYNI.js} +2 -2
  40. package/Build/Workers/{chunk-6HT3OW6S.js → chunk-PZEPLREA.js} +2 -2
  41. package/Build/Workers/{chunk-MYMBUYST.js → chunk-S2RSJJQI.js} +4 -4
  42. package/Build/Workers/{chunk-QBRCP474.js → chunk-S3UYLP3X.js} +8 -8
  43. package/Build/Workers/{chunk-JVSY3BGV.js → chunk-TH3P77KJ.js} +5 -5
  44. package/Build/Workers/{chunk-4HDG7AFU.js → chunk-UGSQJYGE.js} +6 -6
  45. package/Build/Workers/{chunk-SMVRX64E.js → chunk-UUXOFY6G.js} +12 -12
  46. package/Build/Workers/{chunk-DPG3EG2U.js → chunk-V36BVRDX.js} +11 -11
  47. package/Build/Workers/{chunk-3HRMP3V7.js → chunk-VJ2DNCFT.js} +4 -4
  48. package/Build/Workers/{chunk-DH3XQXDD.js → chunk-VQUVJWBK.js} +4 -4
  49. package/Build/Workers/{chunk-AJANTRVW.js → chunk-VWQWZ7OL.js} +5 -5
  50. package/Build/Workers/{chunk-XPXBRZXF.js → chunk-VXBNLAG4.js} +7 -7
  51. package/Build/Workers/{chunk-GXEQK7P4.js → chunk-W3KNMQT2.js} +6 -6
  52. package/Build/Workers/{chunk-5RUDB5R4.js → chunk-WIGH3CPD.js} +2 -2
  53. package/Build/Workers/{chunk-GMNXNBM4.js → chunk-XVHLXVN3.js} +1 -1
  54. package/Build/Workers/{chunk-KSNUH6WJ.js → chunk-YHB3RNF2.js} +4 -4
  55. package/Build/Workers/{chunk-BTXGNWFF.js → chunk-ZSHDRKLT.js} +4 -4
  56. package/Build/Workers/combineGeometry.js +21 -21
  57. package/Build/Workers/createBoxGeometry.js +15 -15
  58. package/Build/Workers/createBoxOutlineGeometry.js +13 -13
  59. package/Build/Workers/createCircleGeometry.js +23 -23
  60. package/Build/Workers/createCircleOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
  62. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
  63. package/Build/Workers/createCorridorGeometry.js +26 -26
  64. package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
  65. package/Build/Workers/createCylinderGeometry.js +17 -17
  66. package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
  67. package/Build/Workers/createEllipseGeometry.js +23 -23
  68. package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
  69. package/Build/Workers/createEllipsoidGeometry.js +16 -16
  70. package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
  71. package/Build/Workers/createFrustumGeometry.js +15 -15
  72. package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
  73. package/Build/Workers/createGeometry.js +21 -21
  74. package/Build/Workers/createGroundPolylineGeometry.js +19 -19
  75. package/Build/Workers/createPlaneGeometry.js +13 -13
  76. package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
  77. package/Build/Workers/createPolygonGeometry.js +29 -29
  78. package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
  79. package/Build/Workers/createPolylineGeometry.js +22 -22
  80. package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
  81. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
  82. package/Build/Workers/createRectangleGeometry.js +24 -24
  83. package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
  84. package/Build/Workers/createSimplePolylineGeometry.js +20 -20
  85. package/Build/Workers/createSphereGeometry.js +16 -16
  86. package/Build/Workers/createSphereOutlineGeometry.js +15 -15
  87. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  88. package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
  89. package/Build/Workers/createVectorTileGeometries.js +21 -21
  90. package/Build/Workers/createVectorTilePoints.js +11 -11
  91. package/Build/Workers/createVectorTilePolygons.js +19 -19
  92. package/Build/Workers/createVectorTilePolylines.js +12 -12
  93. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
  94. package/Build/Workers/createVerticesFromHeightmap.js +25 -25
  95. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
  96. package/Build/Workers/createWallGeometry.js +21 -21
  97. package/Build/Workers/createWallOutlineGeometry.js +20 -20
  98. package/Build/Workers/decodeDraco.js +10 -10
  99. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  100. package/Build/Workers/decodeI3S.js +9 -9
  101. package/Build/Workers/gaussianSplatSorter.js +4 -4
  102. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  103. package/Build/Workers/transcodeKTX2.js +17 -16
  104. package/Build/Workers/transferTypedArrayTest.js +1 -1
  105. package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
  106. package/LICENSE.md +32 -25
  107. package/Source/Core/Ellipsoid.js +9 -0
  108. package/Source/Core/ITwinPlatform.js +8 -1
  109. package/Source/Core/Ion.js +1 -1
  110. package/Source/Core/IonResource.js +14 -8
  111. package/Source/Core/ScreenSpaceEventHandler.js +3 -3
  112. package/Source/Core/addAllToArray.js +40 -0
  113. package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +54 -26
  114. package/Source/Renderer/Context.js +8 -4
  115. package/Source/Renderer/Renderbuffer.js +4 -2
  116. package/Source/Renderer/Sampler.js +13 -0
  117. package/Source/Renderer/ShaderBuilder.js +7 -6
  118. package/Source/Renderer/SharedContext.js +186 -0
  119. package/Source/Renderer/Texture.js +4 -5
  120. package/Source/Renderer/Texture3D.js +17 -7
  121. package/Source/Scene/ArcGisMapService.js +1 -1
  122. package/Source/Scene/BillboardCollection.js +1 -1
  123. package/Source/Scene/BingMapsImageryProvider.js +1 -1
  124. package/Source/Scene/Cesium3DTileBatchTable.js +6 -4
  125. package/Source/Scene/Cesium3DTileContentFactory.js +7 -16
  126. package/Source/Scene/Cesium3DTileStyle.js +4 -3
  127. package/Source/Scene/Cesium3DTileset.js +2 -2
  128. package/Source/Scene/ConditionsExpression.js +3 -2
  129. package/Source/Scene/GaussianSplat3DTileContent.js +253 -9
  130. package/Source/Scene/GaussianSplatPrimitive.js +167 -15
  131. package/Source/Scene/GltfLoader.js +23 -4
  132. package/Source/Scene/GltfPipeline/ForEach.js +7 -7
  133. package/Source/Scene/GltfPipeline/addDefaults.js +1 -2
  134. package/Source/Scene/GltfPipeline/addToArray.js +2 -0
  135. package/Source/Scene/GltfPipeline/findAccessorMinMax.js +1 -1
  136. package/Source/Scene/GltfPipeline/getComponentReader.js +16 -16
  137. package/Source/Scene/GltfPipeline/moveTechniqueRenderStates.js +1 -1
  138. package/Source/Scene/GltfPipeline/moveTechniquesToExtension.js +3 -3
  139. package/Source/Scene/GltfPipeline/parseGlb.js +1 -1
  140. package/Source/Scene/GltfPipeline/readAccessorPacked.js +2 -2
  141. package/Source/Scene/GltfPipeline/removeUnusedElements.js +5 -6
  142. package/Source/Scene/GltfPipeline/updateAccessorComponentTypes.js +1 -1
  143. package/Source/Scene/GltfPipeline/updateVersion.js +13 -13
  144. package/Source/Scene/GltfSpzLoader.js +3 -1
  145. package/Source/Scene/GltfVertexBufferLoader.js +56 -2
  146. package/Source/Scene/HeightReference.js +1 -1
  147. package/Source/Scene/ITwinData.js +49 -25
  148. package/Source/Scene/ImageBasedLighting.js +6 -2
  149. package/Source/Scene/ImageryLayer.js +10 -10
  150. package/Source/Scene/MetadataTableProperty.js +2 -1
  151. package/Source/Scene/Model/ClassificationModelDrawCommand.js +7 -6
  152. package/Source/Scene/Model/GeoJsonLoader.js +3 -1
  153. package/Source/Scene/Model/ImageryConfiguration.js +1 -0
  154. package/Source/Scene/Model/ImageryPipelineStage.js +8 -2
  155. package/Source/Scene/Model/InstancingPipelineStage.js +3 -8
  156. package/Source/Scene/Model/MaterialPipelineStage.js +10 -1
  157. package/Source/Scene/Model/Model.js +3 -0
  158. package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +8 -2
  159. package/Source/Scene/Model/ModelImagery.js +3 -0
  160. package/Source/Scene/Model/ModelSceneGraph.js +2 -1
  161. package/Source/Scene/Model/ModelUtility.js +1 -0
  162. package/Source/Scene/Model/PntsLoader.js +7 -3
  163. package/Source/Scene/Picking.js +41 -1
  164. package/Source/Scene/PntsParser.js +6 -3
  165. package/Source/Scene/Primitive.js +0 -1
  166. package/Source/Scene/PrimitiveCollection.js +32 -6
  167. package/Source/Scene/PrimitiveLoadPlan.js +1 -37
  168. package/Source/Scene/PropertyTable.js +7 -12
  169. package/Source/Scene/Scene.js +41 -32
  170. package/Source/Scene/ScreenSpaceCameraController.js +2 -0
  171. package/Source/Scene/VertexAttributeSemantic.js +4 -2
  172. package/Source/Scene/WebMapServiceImageryProvider.js +3 -2
  173. package/Source/Scene/WebMapTileServiceImageryProvider.js +0 -22
  174. package/Source/Scene/getMeshPrimitives.js +72 -0
  175. package/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.glsl +2 -1
  176. package/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.js +2 -1
  177. package/Source/Shaders/EllipsoidVS.glsl +4 -4
  178. package/Source/Shaders/EllipsoidVS.js +4 -4
  179. package/Source/Shaders/FXAA3_11.glsl +2 -0
  180. package/Source/Shaders/FXAA3_11.js +2 -0
  181. package/Source/Shaders/GlobeVS.glsl +2 -1
  182. package/Source/Shaders/GlobeVS.js +2 -1
  183. package/Source/Shaders/PrimitiveGaussianSplatFS.glsl +5 -5
  184. package/Source/Shaders/PrimitiveGaussianSplatFS.js +5 -5
  185. package/Source/Shaders/PrimitiveGaussianSplatVS.glsl +102 -5
  186. package/Source/Shaders/PrimitiveGaussianSplatVS.js +102 -5
  187. package/Source/Shaders/SkyAtmosphereVS.glsl +2 -1
  188. package/Source/Shaders/SkyAtmosphereVS.js +2 -1
  189. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  190. package/index.d.ts +191 -54
  191. package/index.js +93 -90
  192. package/package.json +4 -4
@@ -12,10 +12,10 @@ void main()\n\
12
12
  // but doing it here allows us to change the radii without rewriting the vertex data, and\n\
13
13
  // allows all ellipsoids to reuse the same vertex data.\n\
14
14
  vec4 p = vec4(u_radii * position, 1.0);\n\
15
- \n\
16
- v_positionEC = (czm_modelView * p).xyz; // position in eye coordinates\n\
17
- gl_Position = czm_modelViewProjection * p; // position in clip coordinates\n\
18
- \n\
15
+ \n\
16
+ vec4 pEC = czm_modelView * p;\n\
17
+ v_positionEC = pEC.xyz; // position in eye coordinates\n\
18
+ gl_Position = czm_projection * pEC;\n\
19
19
  // With multi-frustum, when the ellipsoid primitive is positioned on the intersection of two frustums\n\
20
20
  // and close to terrain, the terrain (writes depth) in the closest frustum can overwrite part of the\n\
21
21
  // ellipsoid (does not write depth) that was rendered in the farther frustum.\n\
@@ -28,7 +28,9 @@
28
28
  */
29
29
 
30
30
  // NVIDIA GameWorks Graphics Samples GitHub link: https://github.com/NVIDIAGameWorks/GraphicsSamples
31
+ // Original source (archived): https://archive.org/details/nvidiagame-works-graphics-samples-master
31
32
  // Original FXAA 3.11 shader link: https://github.com/NVIDIAGameWorks/GraphicsSamples/blob/master/samples/es3-kepler/FXAA/FXAA3_11.h
33
+ // Shader link in fork: https://github.com/lyntel/GraphicsSamples/blob/3d30817ebeeade64fe6a4fc3aa1fe4265c29b6fd/samples/es3-kepler/FXAA/FXAA3_11.h
32
34
 
33
35
  // Steps used to integrate into Cesium:
34
36
  // * The following defines are set:
@@ -57,7 +57,9 @@ export default "/**\n\
57
57
  */\n\
58
58
  \n\
59
59
  // NVIDIA GameWorks Graphics Samples GitHub link: https://github.com/NVIDIAGameWorks/GraphicsSamples\n\
60
+ // Original source (archived): https://archive.org/details/nvidiagame-works-graphics-samples-master\n\
60
61
  // Original FXAA 3.11 shader link: https://github.com/NVIDIAGameWorks/GraphicsSamples/blob/master/samples/es3-kepler/FXAA/FXAA3_11.h\n\
62
+ // Shader link in fork: https://github.com/lyntel/GraphicsSamples/blob/3d30817ebeeade64fe6a4fc3aa1fe4265c29b6fd/samples/es3-kepler/FXAA/FXAA3_11.h\n\
61
63
  \n\
62
64
  // Steps used to integrate into Cesium:\n\
63
65
  // * The following defines are set:\n\
@@ -114,7 +114,8 @@ vec4 getPositionMorphingMode(vec3 position, float height, vec2 textureCoordinate
114
114
  float yPositionFraction = get2DYPositionFraction(textureCoordinates);
115
115
  vec4 position2DWC = vec4(height, mix(u_tileRectangle.st, u_tileRectangle.pq, vec2(textureCoordinates.x, yPositionFraction)), 1.0);
116
116
  vec4 morphPosition = czm_columbusViewMorph(position2DWC, vec4(position3DWC, 1.0), czm_morphTime);
117
- return czm_modelViewProjection * morphPosition;
117
+ vec4 morphPositionEC = czm_modelView * morphPosition;
118
+ return czm_projection * morphPositionEC;
118
119
  }
119
120
 
120
121
  #ifdef QUANTIZATION_BITS12
@@ -115,7 +115,8 @@ vec4 getPositionMorphingMode(vec3 position, float height, vec2 textureCoordinate
115
115
  float yPositionFraction = get2DYPositionFraction(textureCoordinates);\n\
116
116
  vec4 position2DWC = vec4(height, mix(u_tileRectangle.st, u_tileRectangle.pq, vec2(textureCoordinates.x, yPositionFraction)), 1.0);\n\
117
117
  vec4 morphPosition = czm_columbusViewMorph(position2DWC, vec4(position3DWC, 1.0), czm_morphTime);\n\
118
- return czm_modelViewProjection * morphPosition;\n\
118
+ vec4 morphPositionEC = czm_modelView * morphPosition;\n\
119
+ return czm_projection * morphPositionEC;\n\
119
120
  }\n\
120
121
  \n\
121
122
  #ifdef QUANTIZATION_BITS12\n\
@@ -8,11 +8,11 @@ void main() {
8
8
  if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;
9
9
  if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
10
10
 
11
- mediump float A = dot(v_vertPos, v_vertPos);
12
- if(A > 1.0) {
11
+ float A = -dot(v_vertPos, v_vertPos);
12
+ if (A < -4.) {
13
13
  discard;
14
14
  }
15
- mediump float scale = 4.0;
16
- mediump float B = exp(-A * scale) * (v_splatColor.a);
17
- out_FragColor = vec4(v_splatColor.rgb * B, B);
15
+
16
+ float B = exp(A * 4.) * v_splatColor.a ;
17
+ out_FragColor = vec4(v_splatColor.rgb * B , B);
18
18
  }
@@ -9,12 +9,12 @@ void main() {\n\
9
9
  if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;\n\
10
10
  if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;\n\
11
11
  \n\
12
- mediump float A = dot(v_vertPos, v_vertPos);\n\
13
- if(A > 1.0) {\n\
12
+ float A = -dot(v_vertPos, v_vertPos);\n\
13
+ if (A < -4.) {\n\
14
14
  discard;\n\
15
15
  }\n\
16
- mediump float scale = 4.0;\n\
17
- mediump float B = exp(-A * scale) * (v_splatColor.a);\n\
18
- out_FragColor = vec4(v_splatColor.rgb * B, B);\n\
16
+ \n\
17
+ float B = exp(A * 4.) * v_splatColor.a ;\n\
18
+ out_FragColor = vec4(v_splatColor.rgb * B , B);\n\
19
19
  }\n\
20
20
  ";
@@ -7,18 +7,110 @@
7
7
  //
8
8
  // Discards splats outside the view frustum or with negligible screen size.
9
9
  //
10
+ #if defined(HAS_SPHERICAL_HARMONICS)
11
+ const uint coefficientCount[3] = uint[3](3u,8u,15u);
12
+ const float SH_C1 = 0.48860251;
13
+ const float SH_C2[5] = float[5](
14
+ 1.092548430,
15
+ -1.09254843,
16
+ 0.315391565,
17
+ -1.09254843,
18
+ 0.546274215
19
+ );
20
+
21
+ const float SH_C3[7] = float[7](
22
+ -0.59004358,
23
+ 2.890611442,
24
+ -0.45704579,
25
+ 0.373176332,
26
+ -0.45704579,
27
+ 1.445305721,
28
+ -0.59004358
29
+ );
30
+
31
+ //Retrieve SH coefficient. Currently RG32UI format
32
+ uvec2 loadSHCoeff(uint splatID, int index) {
33
+ ivec2 shTexSize = textureSize(u_sphericalHarmonicsTexture, 0);
34
+ uint dims = coefficientCount[uint(u_sphericalHarmonicsDegree)-1u];
35
+ uint splatsPerRow = uint(shTexSize.x) / dims;
36
+ uint shIndex = (splatID%splatsPerRow) * dims + uint(index);
37
+ ivec2 shPosCoord = ivec2(shIndex, splatID / splatsPerRow);
38
+ return texelFetch(u_sphericalHarmonicsTexture, shPosCoord, 0).rg;
39
+ }
40
+
41
+ //Unpack RG32UI half float coefficients to vec3
42
+ vec3 halfToVec3(uvec2 packed) {
43
+ return vec3(unpackHalf2x16(packed.x), unpackHalf2x16(packed.y).x);
44
+ }
45
+
46
+ vec3 loadAndExpandSHCoeff(uint splatID, int index) {
47
+ uvec2 coeff = loadSHCoeff(splatID, index);
48
+ return halfToVec3(coeff);
49
+ }
50
+
51
+ vec3 evaluateSH(uint splatID, vec3 viewDir) {
52
+ vec3 result = vec3(0.0);
53
+ int coeffIndex = 0;
54
+ float x = viewDir.x, y = viewDir.y, z = viewDir.z;
55
+
56
+ if (u_sphericalHarmonicsDegree >= 1.) {
57
+ vec3 sh1 = loadAndExpandSHCoeff(splatID, coeffIndex++);
58
+ vec3 sh2 = loadAndExpandSHCoeff(splatID, coeffIndex++);
59
+ vec3 sh3 = loadAndExpandSHCoeff(splatID, coeffIndex++);
60
+ result += -SH_C1 * y * sh1 + SH_C1 * z * sh2 - SH_C1 * x * sh3;
61
+
62
+ if (u_sphericalHarmonicsDegree >= 2.) {
63
+ float xx = x * x;
64
+ float yy = y * y;
65
+ float zz = z * z;
66
+ float xy = x * y;
67
+ float yz = y * z;
68
+ float xz = x * z;
69
+
70
+ vec3 sh4 = loadAndExpandSHCoeff(splatID, coeffIndex++);
71
+ vec3 sh5 = loadAndExpandSHCoeff(splatID, coeffIndex++);
72
+ vec3 sh6 = loadAndExpandSHCoeff(splatID, coeffIndex++);
73
+ vec3 sh7 = loadAndExpandSHCoeff(splatID, coeffIndex++);
74
+ vec3 sh8 = loadAndExpandSHCoeff(splatID, coeffIndex++);
75
+ result += SH_C2[0] * xy * sh4 +
76
+ SH_C2[1] * yz * sh5 +
77
+ SH_C2[2] * (2.0f * zz - xx - yy) * sh6 +
78
+ SH_C2[3] * xz * sh7 +
79
+ SH_C2[4] * (xx - yy) * sh8;
80
+
81
+ if (u_sphericalHarmonicsDegree >= 3.) {
82
+ vec3 sh9 = loadAndExpandSHCoeff(splatID, coeffIndex++);
83
+ vec3 sh10 = loadAndExpandSHCoeff(splatID, coeffIndex++);
84
+ vec3 sh11 = loadAndExpandSHCoeff(splatID, coeffIndex++);
85
+ vec3 sh12 = loadAndExpandSHCoeff(splatID, coeffIndex++);
86
+ vec3 sh13 = loadAndExpandSHCoeff(splatID, coeffIndex++);
87
+ vec3 sh14 = loadAndExpandSHCoeff(splatID, coeffIndex++);
88
+ vec3 sh15 = loadAndExpandSHCoeff(splatID, coeffIndex++);
89
+ result += SH_C3[0] * y * (3.0f * xx - yy) * sh9 +
90
+ SH_C3[1] * xy * z * sh10 +
91
+ SH_C3[2] * y * (4.0f * zz - xx - yy) * sh11 +
92
+ SH_C3[3] * z * (2.0f * zz - 3.0f * xx - 3.0f * yy) * sh12 +
93
+ SH_C3[4] * x * (4.0f * zz - xx - yy) * sh13 +
94
+ SH_C3[5] * z * (xx - yy) * sh14 +
95
+ SH_C3[6] * x * (xx - 3.0f * yy) * sh15;
96
+ }
97
+ }
98
+ }
99
+ return result;
100
+ }
101
+ #endif
10
102
 
11
103
  // Transforms and projects splat covariance into screen space and extracts the major and minor axes of the Gaussian ellipsoid
12
104
  // which is used to calculate the vertex position in clip space.
13
105
  vec4 calcCovVectors(vec3 viewPos, mat3 Vrk) {
14
106
  vec4 t = vec4(viewPos, 1.0);
15
- float focal = czm_viewport.z * czm_projection[0][0];
107
+ vec2 focal = vec2(czm_projection[0][0] * czm_viewport.z, czm_projection[1][1] * czm_viewport.w);
16
108
 
17
- float J1 = focal / t.z;
18
- vec2 J2 = -J1 / t.z * t.xy;
109
+ vec2 J1 = focal / t.z;
110
+ vec2 J2 = -focal * vec2(t.x, t.y) / (t.z * t.z);
19
111
  mat3 J = mat3(
20
- J1, 0.0, J2.x,
21
- 0.0, J1, J2.y,
112
+ J1.x, 0.0, J2.x,
113
+ 0.0, J1.y, J2.y,
22
114
  0.0, 0.0, 0.0
23
115
  );
24
116
 
@@ -87,6 +179,11 @@ void main() {
87
179
 
88
180
  v_vertPos = corner ;
89
181
  v_splatColor = vec4(covariance.w & 0xffu, (covariance.w >> 8) & 0xffu, (covariance.w >> 16) & 0xffu, (covariance.w >> 24) & 0xffu) / 255.0;
182
+ #if defined(HAS_SPHERICAL_HARMONICS)
183
+ vec4 splatWC = czm_inverseView * splatViewPos;
184
+ vec3 viewDirModel = normalize(u_inverseModelRotation * (splatWC.xyz - u_cameraPositionWC.xyz));
90
185
 
186
+ v_splatColor.rgb += evaluateSH(texIdx, viewDirModel).rgb;
187
+ #endif
91
188
  v_splitDirection = u_splitDirection;
92
189
  }
@@ -8,18 +8,110 @@ export default "//\n\
8
8
  //\n\
9
9
  // Discards splats outside the view frustum or with negligible screen size.\n\
10
10
  //\n\
11
+ #if defined(HAS_SPHERICAL_HARMONICS)\n\
12
+ const uint coefficientCount[3] = uint[3](3u,8u,15u);\n\
13
+ const float SH_C1 = 0.48860251;\n\
14
+ const float SH_C2[5] = float[5](\n\
15
+ 1.092548430,\n\
16
+ -1.09254843,\n\
17
+ 0.315391565,\n\
18
+ -1.09254843,\n\
19
+ 0.546274215\n\
20
+ );\n\
21
+ \n\
22
+ const float SH_C3[7] = float[7](\n\
23
+ -0.59004358,\n\
24
+ 2.890611442,\n\
25
+ -0.45704579,\n\
26
+ 0.373176332,\n\
27
+ -0.45704579,\n\
28
+ 1.445305721,\n\
29
+ -0.59004358\n\
30
+ );\n\
31
+ \n\
32
+ //Retrieve SH coefficient. Currently RG32UI format\n\
33
+ uvec2 loadSHCoeff(uint splatID, int index) {\n\
34
+ ivec2 shTexSize = textureSize(u_sphericalHarmonicsTexture, 0);\n\
35
+ uint dims = coefficientCount[uint(u_sphericalHarmonicsDegree)-1u];\n\
36
+ uint splatsPerRow = uint(shTexSize.x) / dims;\n\
37
+ uint shIndex = (splatID%splatsPerRow) * dims + uint(index);\n\
38
+ ivec2 shPosCoord = ivec2(shIndex, splatID / splatsPerRow);\n\
39
+ return texelFetch(u_sphericalHarmonicsTexture, shPosCoord, 0).rg;\n\
40
+ }\n\
41
+ \n\
42
+ //Unpack RG32UI half float coefficients to vec3\n\
43
+ vec3 halfToVec3(uvec2 packed) {\n\
44
+ return vec3(unpackHalf2x16(packed.x), unpackHalf2x16(packed.y).x);\n\
45
+ }\n\
46
+ \n\
47
+ vec3 loadAndExpandSHCoeff(uint splatID, int index) {\n\
48
+ uvec2 coeff = loadSHCoeff(splatID, index);\n\
49
+ return halfToVec3(coeff);\n\
50
+ }\n\
51
+ \n\
52
+ vec3 evaluateSH(uint splatID, vec3 viewDir) {\n\
53
+ vec3 result = vec3(0.0);\n\
54
+ int coeffIndex = 0;\n\
55
+ float x = viewDir.x, y = viewDir.y, z = viewDir.z;\n\
56
+ \n\
57
+ if (u_sphericalHarmonicsDegree >= 1.) {\n\
58
+ vec3 sh1 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
59
+ vec3 sh2 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
60
+ vec3 sh3 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
61
+ result += -SH_C1 * y * sh1 + SH_C1 * z * sh2 - SH_C1 * x * sh3;\n\
62
+ \n\
63
+ if (u_sphericalHarmonicsDegree >= 2.) {\n\
64
+ float xx = x * x;\n\
65
+ float yy = y * y;\n\
66
+ float zz = z * z;\n\
67
+ float xy = x * y;\n\
68
+ float yz = y * z;\n\
69
+ float xz = x * z;\n\
70
+ \n\
71
+ vec3 sh4 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
72
+ vec3 sh5 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
73
+ vec3 sh6 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
74
+ vec3 sh7 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
75
+ vec3 sh8 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
76
+ result += SH_C2[0] * xy * sh4 +\n\
77
+ SH_C2[1] * yz * sh5 +\n\
78
+ SH_C2[2] * (2.0f * zz - xx - yy) * sh6 +\n\
79
+ SH_C2[3] * xz * sh7 +\n\
80
+ SH_C2[4] * (xx - yy) * sh8;\n\
81
+ \n\
82
+ if (u_sphericalHarmonicsDegree >= 3.) {\n\
83
+ vec3 sh9 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
84
+ vec3 sh10 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
85
+ vec3 sh11 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
86
+ vec3 sh12 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
87
+ vec3 sh13 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
88
+ vec3 sh14 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
89
+ vec3 sh15 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
90
+ result += SH_C3[0] * y * (3.0f * xx - yy) * sh9 +\n\
91
+ SH_C3[1] * xy * z * sh10 +\n\
92
+ SH_C3[2] * y * (4.0f * zz - xx - yy) * sh11 +\n\
93
+ SH_C3[3] * z * (2.0f * zz - 3.0f * xx - 3.0f * yy) * sh12 +\n\
94
+ SH_C3[4] * x * (4.0f * zz - xx - yy) * sh13 +\n\
95
+ SH_C3[5] * z * (xx - yy) * sh14 +\n\
96
+ SH_C3[6] * x * (xx - 3.0f * yy) * sh15;\n\
97
+ }\n\
98
+ }\n\
99
+ }\n\
100
+ return result;\n\
101
+ }\n\
102
+ #endif\n\
11
103
  \n\
12
104
  // Transforms and projects splat covariance into screen space and extracts the major and minor axes of the Gaussian ellipsoid\n\
13
105
  // which is used to calculate the vertex position in clip space.\n\
14
106
  vec4 calcCovVectors(vec3 viewPos, mat3 Vrk) {\n\
15
107
  vec4 t = vec4(viewPos, 1.0);\n\
16
- float focal = czm_viewport.z * czm_projection[0][0];\n\
108
+ vec2 focal = vec2(czm_projection[0][0] * czm_viewport.z, czm_projection[1][1] * czm_viewport.w);\n\
17
109
  \n\
18
- float J1 = focal / t.z;\n\
19
- vec2 J2 = -J1 / t.z * t.xy;\n\
110
+ vec2 J1 = focal / t.z;\n\
111
+ vec2 J2 = -focal * vec2(t.x, t.y) / (t.z * t.z);\n\
20
112
  mat3 J = mat3(\n\
21
- J1, 0.0, J2.x,\n\
22
- 0.0, J1, J2.y,\n\
113
+ J1.x, 0.0, J2.x,\n\
114
+ 0.0, J1.y, J2.y,\n\
23
115
  0.0, 0.0, 0.0\n\
24
116
  );\n\
25
117
  \n\
@@ -88,6 +180,11 @@ void main() {\n\
88
180
  \n\
89
181
  v_vertPos = corner ;\n\
90
182
  v_splatColor = vec4(covariance.w & 0xffu, (covariance.w >> 8) & 0xffu, (covariance.w >> 16) & 0xffu, (covariance.w >> 24) & 0xffu) / 255.0;\n\
183
+ #if defined(HAS_SPHERICAL_HARMONICS)\n\
184
+ vec4 splatWC = czm_inverseView * splatViewPos;\n\
185
+ vec3 viewDirModel = normalize(u_inverseModelRotation * (splatWC.xyz - u_cameraPositionWC.xyz));\n\
91
186
  \n\
187
+ v_splatColor.rgb += evaluateSH(texIdx, viewDirModel).rgb;\n\
188
+ #endif\n\
92
189
  v_splitDirection = u_splitDirection;\n\
93
190
  }";
@@ -27,5 +27,6 @@ void main(void)
27
27
  #endif
28
28
 
29
29
  v_outerPositionWC = positionWC.xyz;
30
- gl_Position = czm_modelViewProjection * position;
30
+ vec4 positionEC = czm_modelView * position;
31
+ gl_Position = czm_projection * positionEC;
31
32
  }
@@ -28,6 +28,7 @@ void main(void)\n\
28
28
  #endif\n\
29
29
  \n\
30
30
  v_outerPositionWC = positionWC.xyz;\n\
31
- gl_Position = czm_modelViewProjection * position;\n\
31
+ vec4 positionEC = czm_modelView * position;\n\
32
+ gl_Position = czm_projection * positionEC;\n\
32
33
  }\n\
33
34
  ";
@@ -1 +1 @@
1
- !function(){"use strict";const{Array:e,Object:t,Number:n,Math:s,Error:r,Uint8Array:a,Uint16Array:o,Uint32Array:i,Int32Array:c,Map:l,DataView:u,Promise:h,TextEncoder:f,crypto:p,postMessage:d,TransformStream:g,ReadableStream:w,WritableStream:y,CompressionStream:m,DecompressionStream:_}=self,b=void 0,S="undefined",v="function";class k{constructor(e){return class extends g{constructor(t,n){const s=new e(n);super({transform(e,t){t.enqueue(s.append(e))},flush(e){const t=s.flush();t&&e.enqueue(t)}})}}}}const z=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;z[e]=t}class D{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,s=0|e.length;s>n;n++)t=t>>>8^z[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class C extends g{constructor(){let e;const t=new D;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new a(4);new u(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const I={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],s=I.getPartial(n);return 32===s?e.concat(t):I._shiftRight(t,s,0|n,e.slice(0,e.length-1))},bitLength(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+I.getPartial(n)},clamp(e,t){if(32*e.length<t)return e;const n=(e=e.slice(0,s.ceil(t/32))).length;return t&=31,n>0&&t&&(e[n-1]=I.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>s.round(e/1099511627776)||32,_shiftRight(e,t,n,s){for(void 0===s&&(s=[]);t>=32;t-=32)s.push(n),n=0;if(0===t)return s.concat(e);for(let r=0;r<e.length;r++)s.push(n|e[r]>>>t),n=e[r]<<32-t;const r=e.length?e[e.length-1]:0,a=I.getPartial(r);return s.push(I.partial(t+a&31,t+a>32?n:s.pop(),1)),s}},A={bytes:{fromBits(e){const t=I.bitLength(e)/8,n=new a(t);let s;for(let r=0;t>r;r++)3&r||(s=e[r/4]),n[r]=s>>>24,s<<=8;return n},toBits(e){const t=[];let n,s=0;for(n=0;n<e.length;n++)s=s<<8|e[n],3&~n||(t.push(s),s=0);return 3&n&&t.push(I.partial(8*(3&n),s)),t}}},q=class{constructor(e){const t=this;t.blockSize=512,t._init=[1732584193,4023233417,2562383102,271733878,3285377520],t._key=[1518500249,1859775393,2400959708,3395469782],e?(t._h=e._h.slice(0),t._buffer=e._buffer.slice(0),t._length=e._length):t.reset()}reset(){const e=this;return e._h=e._init.slice(0),e._buffer=[],e._length=0,e}update(e){const t=this;"string"==typeof e&&(e=A.utf8String.toBits(e));const n=t._buffer=I.concat(t._buffer,e),s=t._length,a=t._length=s+I.bitLength(e);if(a>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const o=new i(n);let c=0;for(let e=t.blockSize+s-(t.blockSize+s&t.blockSize-1);a>=e;e+=t.blockSize)t._block(o.subarray(16*c,16*(c+1))),c+=1;return n.splice(0,16*c),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=I.concat(t,[I.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(s.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,s){return e>19?e>39?e>59?e>79?void 0:t^n^s:t&n|t&s|n&s:t^n^s:t&n|~t&s}_S(e,t){return t<<e|t>>>32-e}_block(t){const n=this,r=n._h,a=e(80);for(let e=0;16>e;e++)a[e]=t[e];let o=r[0],i=r[1],c=r[2],l=r[3],u=r[4];for(let e=0;79>=e;e++){16>e||(a[e]=n._S(1,a[e-3]^a[e-8]^a[e-14]^a[e-16]));const t=n._S(5,o)+n._f(e,i,c,l)+u+a[e]+n._key[s.floor(e/20)]|0;u=l,l=c,c=n._S(30,i),i=o,o=t}r[0]=r[0]+o|0,r[1]=r[1]+i|0,r[2]=r[2]+c|0,r[3]=r[3]+l|0,r[4]=r[4]+u|0}},R={getRandomValues(e){const t=new i(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(s.random()>.5?1:-1))};for(let r,a=0;a<e.length;a+=4){const e=n(4294967296*(r||s.random()));r=987654071*e(),t[a/4]=4294967296*e()|0}return e}},H={importKey:e=>new H.hmacSha1(A.bytes.toBits(e)),pbkdf2(e,t,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const a=1+(s>>5)<<2;let o,i,c,l,h;const f=new ArrayBuffer(a),p=new u(f);let d=0;const g=I;for(t=A.bytes.toBits(t),h=1;(a||1)>d;h++){for(o=i=e.encrypt(g.concat(t,[h])),c=1;n>c;c++)for(i=e.encrypt(i),l=0;l<i.length;l++)o[l]^=i[l];for(c=0;(a||1)>d&&c<o.length;c++)p.setInt32(d,o[c]),d+=4}return f.slice(0,s/8)},hmacSha1:class{constructor(e){const t=this,n=t._hash=q,s=[[],[]];t._baseHash=[new n,new n];const r=t._baseHash[0].blockSize/32;e.length>r&&(e=(new n).update(e).finalize());for(let t=0;r>t;t++)s[0][t]=909522486^e[t],s[1][t]=1549556828^e[t];t._baseHash[0].update(s[0]),t._baseHash[1].update(s[1]),t._resultHash=new n(t._baseHash[0])}reset(){const e=this;e._resultHash=new e._hash(e._baseHash[0]),e._updated=!1}update(e){this._updated=!0,this._resultHash.update(e)}digest(){const e=this,t=e._resultHash.finalize(),n=new e._hash(e._baseHash[1]).update(t).finalize();return e.reset(),n}encrypt(e){if(this._updated)throw new r("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},P=typeof p!=S&&typeof p.getRandomValues==v,B="Invalid password",K="Invalid signature",T="zipjs-abort-check-password";function V(e){return P?p.getRandomValues(e):R.getRandomValues(e)}const x=16,E={name:"PBKDF2"},U=t.assign({hash:{name:"HMAC"}},E),W=t.assign({iterations:1e3,hash:{name:"SHA-1"}},E),M=["deriveBits"],N=[8,12,16],O=[16,24,32],L=10,F=[0,0,0,0],j=typeof p!=S,G=j&&p.subtle,X=j&&typeof G!=S,J=A.bytes,Q=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],s=t._tables[1],a=e.length;let o,i,c,l=1;if(4!==a&&6!==a&&8!==a)throw new r("invalid aes key size");for(t._key=[i=e.slice(0),c=[]],o=a;4*a+28>o;o++){let e=i[o-1];(o%a===0||8===a&&o%a===4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],o%a===0&&(e=e<<8^e>>>24^l<<24,l=l<<1^283*(l>>7))),i[o]=i[o-a]^e}for(let e=0;o;e++,o--){const t=i[3&e?o:o-4];c[e]=4>=o||4>e?t:s[0][n[t>>>24]]^s[1][n[t>>16&255]]^s[2][n[t>>8&255]]^s[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],s=t[4],r=[],a=[];let o,i,c,l;for(let e=0;256>e;e++)a[(r[e]=e<<1^283*(e>>7))^e]=e;for(let u=o=0;!n[u];u^=i||1,o=a[o]||1){let a=o^o<<1^o<<2^o<<3^o<<4;a=a>>8^255&a^99,n[u]=a,s[a]=u,l=r[c=r[i=r[u]]];let h=16843009*l^65537*c^257*i^16843008*u,f=257*r[a]^16843008*a;for(let n=0;4>n;n++)e[n][u]=f=f<<24^f>>>8,t[n][a]=h=h<<24^h>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new r("invalid aes block size");const n=this._key[t],s=n.length/4-2,a=[0,0,0,0],o=this._tables[t],i=o[0],c=o[1],l=o[2],u=o[3],h=o[4];let f,p,d,g=e[0]^n[0],w=e[t?3:1]^n[1],y=e[2]^n[2],m=e[t?1:3]^n[3],_=4;for(let e=0;s>e;e++)f=i[g>>>24]^c[w>>16&255]^l[y>>8&255]^u[255&m]^n[_],p=i[w>>>24]^c[y>>16&255]^l[m>>8&255]^u[255&g]^n[_+1],d=i[y>>>24]^c[m>>16&255]^l[g>>8&255]^u[255&w]^n[_+2],m=i[m>>>24]^c[g>>16&255]^l[w>>8&255]^u[255&y]^n[_+3],_+=4,g=f,w=p,y=d;for(let e=0;4>e;e++)a[t?3&-e:e]=h[g>>>24]<<24^h[w>>16&255]<<16^h[y>>8&255]<<8^h[255&m]^n[_++],f=g,g=w,w=y,y=m,m=f;return a}},Y=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255&~(e>>24))e+=1<<24;else{let t=e>>16&255,n=e>>8&255,s=255&e;255===t?(t=0,255===n?(n=0,255===s?s=0:++s):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=s}return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let s;if(!(s=t.length))return[];const r=I.bitLength(t);for(let r=0;s>r;r+=4){this.incCounter(n);const s=e.encrypt(n);t[r]^=s[0],t[r+1]^=s[1],t[r+2]^=s[2],t[r+3]^=s[3]}return I.clamp(t,r)}},Z=H.hmacSha1;let $=j&&X&&typeof G.importKey==v,ee=j&&X&&typeof G.deriveBits==v;class te extends g{constructor({password:e,rawPassword:n,signed:s,encryptionStrength:o,checkPasswordOnly:i}){super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:ae(e,n),signed:s,strength:o-1,pending:new a})},async transform(e,t){const n=this,{password:s,strength:o,resolveReady:c,ready:l}=n;s?(await(async(e,t,n,s)=>{const a=await re(e,t,n,ie(s,0,N[t])),o=ie(s,N[t]);if(a[0]!=o[0]||a[1]!=o[1])throw new r(B)})(n,o,s,ie(e,0,N[o]+2)),e=ie(e,N[o]+2),i?t.error(new r(T)):c()):await l;const u=new a(e.length-L-(e.length-L)%x);t.enqueue(se(n,e,u,0,L,!0))},async flush(e){const{signed:t,ctr:n,hmac:s,pending:o,ready:i}=this;if(s&&n){await i;const c=ie(o,0,o.length-L),l=ie(o,o.length-L);let u=new a;if(c.length){const e=le(J,c);s.update(e);const t=n.update(e);u=ce(J,t)}if(t){const e=ie(ce(J,s.digest()),0,L);for(let t=0;L>t;t++)if(e[t]!=l[t])throw new r(K)}e.enqueue(u)}}})}}class ne extends g{constructor({password:e,rawPassword:n,encryptionStrength:s}){let r;super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:ae(e,n),strength:s-1,pending:new a})},async transform(e,t){const n=this,{password:s,strength:r,resolveReady:o,ready:i}=n;let c=new a;s?(c=await(async(e,t,n)=>{const s=V(new a(N[t]));return oe(s,await re(e,t,n,s))})(n,r,s),o()):await i;const l=new a(c.length+e.length-e.length%x);l.set(c,0),t.enqueue(se(n,e,l,c.length,0))},async flush(e){const{ctr:t,hmac:n,pending:s,ready:o}=this;if(n&&t){await o;let i=new a;if(s.length){const e=t.update(le(J,s));n.update(e),i=ce(J,e)}r.signature=ce(J,n.digest()).slice(0,L),e.enqueue(oe(i,r.signature))}}}),r=this}}function se(e,t,n,s,r,o){const{ctr:i,hmac:c,pending:l}=e,u=t.length-r;let h;for(l.length&&(t=oe(l,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new a(t)).set(n,0)}return e})(n,u-u%x)),h=0;u-x>=h;h+=x){const e=le(J,ie(t,h,h+x));o&&c.update(e);const r=i.update(e);o||c.update(r),n.set(ce(J,r),h+s)}return e.pending=ie(t,h),n}async function re(n,s,r,o){n.password=null;const i=await(async(e,t,n,s,r)=>{if(!$)return H.importKey(t);try{return await G.importKey("raw",t,n,!1,r)}catch(e){return $=!1,H.importKey(t)}})(0,r,U,0,M),c=await(async(e,t,n)=>{if(!ee)return H.pbkdf2(t,e.salt,W.iterations,n);try{return await G.deriveBits(e,t,n)}catch(s){return ee=!1,H.pbkdf2(t,e.salt,W.iterations,n)}})(t.assign({salt:o},W),i,8*(2*O[s]+2)),l=new a(c),u=le(J,ie(l,0,O[s])),h=le(J,ie(l,O[s],2*O[s])),f=ie(l,2*O[s]);return t.assign(n,{keys:{key:u,authentication:h,passwordVerification:f},ctr:new Y(new Q(u),e.from(F)),hmac:new Z(h)}),f}function ae(e,t){return t===b?(e=>{if(typeof f==S){const t=new a((e=unescape(encodeURIComponent(e))).length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return t}return(new f).encode(e)})(e):t}function oe(e,t){let n=e;return e.length+t.length&&(n=new a(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function ie(e,t,n){return e.subarray(t,n)}function ce(e,t){return e.fromBits(t)}function le(e,t){return e.toBits(t)}class ue extends g{constructor({password:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){t.assign(this,{password:e,passwordVerification:n}),de(this,e)},transform(e,t){const n=this;if(n.password){const t=fe(n,e.subarray(0,12));if(n.password=null,t[11]!=n.passwordVerification)throw new r(B);e=e.subarray(12)}s?t.error(new r(T)):t.enqueue(fe(n,e))}})}}class he extends g{constructor({password:e,passwordVerification:n}){super({start(){t.assign(this,{password:e,passwordVerification:n}),de(this,e)},transform(e,t){const n=this;let s,r;if(n.password){n.password=null;const t=V(new a(12));t[11]=n.passwordVerification,s=new a(e.length+t.length),s.set(pe(n,t),0),r=12}else s=new a(e.length),r=0;s.set(pe(n,e),r),t.enqueue(s)}})}}function fe(e,t){const n=new a(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],ge(e,n[s]);return n}function pe(e,t){const n=new a(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],ge(e,t[s]);return n}function de(e,n){const s=[305419896,591751049,878082192];t.assign(e,{keys:s,crcKey0:new D(s[0]),crcKey2:new D(s[2])});for(let t=0;t<n.length;t++)ge(e,n.charCodeAt(t))}function ge(e,t){let[n,r,a]=e.keys;e.crcKey0.append([t]),n=~e.crcKey0.get(),r=me(s.imul(me(r+ye(n)),134775813)+1),e.crcKey2.append([r>>>24]),a=~e.crcKey2.get(),e.keys=[n,r,a]}function we(e){const t=2|e.keys[2];return ye(s.imul(t,1^t)>>>8)}function ye(e){return 255&e}function me(e){return 4294967295&e}const _e="deflate-raw";class be extends g{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:s}){super({});const{compressed:r,encrypted:a,useCompressionStream:o,zipCrypto:i,signed:c,level:l}=e,h=this;let f,p,d=ve(super.readable);a&&!i||!c||(f=new C,d=De(d,f)),r&&(d=ze(d,o,{level:l,chunkSize:t},s,n)),a&&(i?d=De(d,new he(e)):(p=new ne(e),d=De(d,p))),ke(h,d,()=>{let e;a&&!i&&(e=p.signature),a&&!i||!c||(e=new u(f.value.buffer).getUint32(0)),h.signature=e})}}class Se extends g{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:s}){super({});const{zipCrypto:a,encrypted:o,signed:i,signature:c,compressed:l,useCompressionStream:h}=e;let f,p,d=ve(super.readable);o&&(a?d=De(d,new ue(e)):(p=new te(e),d=De(d,p))),l&&(d=ze(d,h,{chunkSize:t},s,n)),o&&!a||!i||(f=new C,d=De(d,f)),ke(this,d,()=>{if((!o||a)&&i){const e=new u(f.value.buffer);if(c!=e.getUint32(0,!1))throw new r(K)}})}}function ve(e){return De(e,new g({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function ke(e,n,s){n=De(n,new g({flush:s})),t.defineProperty(e,"readable",{get:()=>n})}function ze(e,t,n,s,r){try{e=De(e,new(t&&s?s:r)(_e,n))}catch(s){if(!t)return e;try{e=De(e,new r(_e,n))}catch(t){return e}}return e}function De(e,t){return e.pipeThrough(t)}const Ce="data",Ie="close";class Ae extends g{constructor(e,n){super({});const s=this,{codecType:r}=e;let a;r.startsWith("deflate")?a=be:r.startsWith("inflate")&&(a=Se),s.outputSize=0;let o=0;const i=new a(e,n),c=super.readable,l=new g({transform(e,t){e&&e.length&&(o+=e.length,t.enqueue(e))},flush(){t.assign(s,{inputSize:o})}}),u=new g({transform(e,t){e&&e.length&&(t.enqueue(e),s.outputSize+=e.length)},flush(){const{signature:e}=i;t.assign(s,{signature:e,inputSize:o})}});t.defineProperty(s,"readable",{get:()=>c.pipeThrough(l).pipeThrough(i).pipeThrough(u)})}}class qe extends g{constructor(e){let t;super({transform:function n(s,r){if(t){const e=new a(t.length+s.length);e.set(t),e.set(s,t.length),s=e,t=null}s.length>e?(r.enqueue(s.slice(0,e)),n(s.slice(e),r)):t=s},flush(e){t&&t.length&&e.enqueue(t)}})}}const Re=new l,He=new l;let Pe,Be=0,Ke=!0;async function Te(e){try{const{options:t,scripts:s,config:r}=e;if(s&&s.length)try{Ke?importScripts.apply(b,s):await Ve(s)}catch(e){Ke=!1,await Ve(s)}self.initCodec&&self.initCodec(),r.CompressionStreamNative=self.CompressionStream,r.DecompressionStreamNative=self.DecompressionStream,self.Deflate&&(r.CompressionStream=new k(self.Deflate)),self.Inflate&&(r.DecompressionStream=new k(self.Inflate));const a={highWaterMark:1},o=e.readable||new w({async pull(e){const t=new h(e=>Re.set(Be,e));xe({type:"pull",messageId:Be}),Be=(Be+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await t;e.enqueue(s),r&&e.close()}},a),i=e.writable||new y({async write(e){let t;const s=new h(e=>t=e);He.set(Be,t),xe({type:Ce,value:e,messageId:Be}),Be=(Be+1)%n.MAX_SAFE_INTEGER,await s}},a),c=new Ae(t,r);Pe=new AbortController;const{signal:l}=Pe;await o.pipeThrough(c).pipeThrough(new qe(r.chunkSize)).pipeTo(i,{signal:l,preventClose:!0,preventAbort:!0}),await i.getWriter().close();const{signature:u,inputSize:f,outputSize:p}=c;xe({type:Ie,result:{signature:u,inputSize:f,outputSize:p}})}catch(e){e.outputSize=0,Ee(e)}}async function Ve(e){for(const t of e)await import(t)}function xe(e){let{value:t}=e;if(t)if(t.length)try{t=new a(t),e.value=t.buffer,d(e,[e.value])}catch(t){d(e)}else d(e);else d(e)}function Ee(e=new r("Unknown error")){const{message:t,stack:n,code:s,name:a,outputSize:o}=e;d({error:{message:t,stack:n,code:s,name:a,outputSize:o}})}function Ue(e,n,s){return class{constructor(r){const o=this;var i,c;i=r,c="level",(typeof t.hasOwn===v?t.hasOwn(i,c):i.hasOwnProperty(c))&&r.level===b&&delete r.level,o.codec=new e(t.assign({},n,r)),s(o.codec,e=>{if(o.pendingData){const t=o.pendingData;o.pendingData=new a(t.length+e.length);const{pendingData:n}=o;n.set(t,0),n.set(e,t.length)}else o.pendingData=new a(e)})}append(e){return this.codec.push(e),r(this)}flush(){return this.codec.push(new a,!0),r(this)}};function r(e){if(e.pendingData){const t=e.pendingData;return e.pendingData=null,t}return new a}}addEventListener("message",({data:e})=>{const{type:t,messageId:n,value:s,done:r}=e;try{if("start"==t&&Te(e),t==Ce){const e=Re.get(n);Re.delete(n),e({value:new a(s),done:r})}if("ack"==t){const e=He.get(n);He.delete(n),e()}t==Ie&&Pe.abort()}catch(e){Ee(e)}}),self.initCodec=()=>{const{Deflate:e,Inflate:t}=((e,t={},n)=>({Deflate:Ue(e.Deflate,t.deflate,n),Inflate:Ue(e.Inflate,t.inflate,n)}))(pako,{deflate:{raw:!0},inflate:{raw:!0}},(e,t)=>e.onData=t);self.Deflate=e,self.Inflate=t}}();
1
+ !function(){"use strict";const{Array:e,Object:t,Number:n,Math:s,Error:r,Uint8Array:a,Uint16Array:o,Uint32Array:i,Int32Array:c,Map:l,DataView:u,Promise:h,TextEncoder:p,crypto:f,postMessage:d,TransformStream:g,ReadableStream:w,WritableStream:y,CompressionStream:m,DecompressionStream:_}=self,b=void 0,S="undefined",v="function";class k{constructor(e){return class extends g{constructor(t,n){const s=new e(n);super({transform(e,t){t.enqueue(s.append(e))},flush(e){const t=s.flush();t&&e.enqueue(t)}})}}}}const z=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;z[e]=t}class D{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,s=0|e.length;s>n;n++)t=t>>>8^z[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class C extends g{constructor(){let e;const t=new D;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new a(4);new u(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const I={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],s=I.getPartial(n);return 32===s?e.concat(t):I._shiftRight(t,s,0|n,e.slice(0,e.length-1))},bitLength(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+I.getPartial(n)},clamp(e,t){if(32*e.length<t)return e;const n=(e=e.slice(0,s.ceil(t/32))).length;return t&=31,n>0&&t&&(e[n-1]=I.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>s.round(e/1099511627776)||32,_shiftRight(e,t,n,s){for(void 0===s&&(s=[]);t>=32;t-=32)s.push(n),n=0;if(0===t)return s.concat(e);for(let r=0;r<e.length;r++)s.push(n|e[r]>>>t),n=e[r]<<32-t;const r=e.length?e[e.length-1]:0,a=I.getPartial(r);return s.push(I.partial(t+a&31,t+a>32?n:s.pop(),1)),s}},A={bytes:{fromBits(e){const t=I.bitLength(e)/8,n=new a(t);let s;for(let r=0;t>r;r++)3&r||(s=e[r/4]),n[r]=s>>>24,s<<=8;return n},toBits(e){const t=[];let n,s=0;for(n=0;n<e.length;n++)s=s<<8|e[n],3&~n||(t.push(s),s=0);return 3&n&&t.push(I.partial(8*(3&n),s)),t}}},q=class{constructor(e){const t=this;t.blockSize=512,t._init=[1732584193,4023233417,2562383102,271733878,3285377520],t._key=[1518500249,1859775393,2400959708,3395469782],e?(t._h=e._h.slice(0),t._buffer=e._buffer.slice(0),t._length=e._length):t.reset()}reset(){const e=this;return e._h=e._init.slice(0),e._buffer=[],e._length=0,e}update(e){const t=this;"string"==typeof e&&(e=A.utf8String.toBits(e));const n=t._buffer=I.concat(t._buffer,e),s=t._length,a=t._length=s+I.bitLength(e);if(a>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const o=new i(n);let c=0;for(let e=t.blockSize+s-(t.blockSize+s&t.blockSize-1);a>=e;e+=t.blockSize)t._block(o.subarray(16*c,16*(c+1))),c+=1;return n.splice(0,16*c),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=I.concat(t,[I.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(s.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,s){return e>19?e>39?e>59?e>79?void 0:t^n^s:t&n|t&s|n&s:t^n^s:t&n|~t&s}_S(e,t){return t<<e|t>>>32-e}_block(t){const n=this,r=n._h,a=e(80);for(let e=0;16>e;e++)a[e]=t[e];let o=r[0],i=r[1],c=r[2],l=r[3],u=r[4];for(let e=0;79>=e;e++){16>e||(a[e]=n._S(1,a[e-3]^a[e-8]^a[e-14]^a[e-16]));const t=n._S(5,o)+n._f(e,i,c,l)+u+a[e]+n._key[s.floor(e/20)]|0;u=l,l=c,c=n._S(30,i),i=o,o=t}r[0]=r[0]+o|0,r[1]=r[1]+i|0,r[2]=r[2]+c|0,r[3]=r[3]+l|0,r[4]=r[4]+u|0}},R={getRandomValues(e){const t=new i(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(s.random()>.5?1:-1))};for(let r,a=0;a<e.length;a+=4){const e=n(4294967296*(r||s.random()));r=987654071*e(),t[a/4]=4294967296*e()|0}return e}},H={importKey:e=>new H.hmacSha1(A.bytes.toBits(e)),pbkdf2(e,t,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const a=1+(s>>5)<<2;let o,i,c,l,h;const p=new ArrayBuffer(a),f=new u(p);let d=0;const g=I;for(t=A.bytes.toBits(t),h=1;(a||1)>d;h++){for(o=i=e.encrypt(g.concat(t,[h])),c=1;n>c;c++)for(i=e.encrypt(i),l=0;l<i.length;l++)o[l]^=i[l];for(c=0;(a||1)>d&&c<o.length;c++)f.setInt32(d,o[c]),d+=4}return p.slice(0,s/8)},hmacSha1:class{constructor(e){const t=this,n=t._hash=q,s=[[],[]];t._baseHash=[new n,new n];const r=t._baseHash[0].blockSize/32;e.length>r&&(e=(new n).update(e).finalize());for(let t=0;r>t;t++)s[0][t]=909522486^e[t],s[1][t]=1549556828^e[t];t._baseHash[0].update(s[0]),t._baseHash[1].update(s[1]),t._resultHash=new n(t._baseHash[0])}reset(){const e=this;e._resultHash=new e._hash(e._baseHash[0]),e._updated=!1}update(e){this._updated=!0,this._resultHash.update(e)}digest(){const e=this,t=e._resultHash.finalize(),n=new e._hash(e._baseHash[1]).update(t).finalize();return e.reset(),n}encrypt(e){if(this._updated)throw new r("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},P=typeof f!=S&&typeof f.getRandomValues==v,B="Invalid password",K="Invalid signature",T="zipjs-abort-check-password";function V(e){return P?f.getRandomValues(e):R.getRandomValues(e)}const x=16,E={name:"PBKDF2"},U=t.assign({hash:{name:"HMAC"}},E),W=t.assign({iterations:1e3,hash:{name:"SHA-1"}},E),M=["deriveBits"],N=[8,12,16],O=[16,24,32],L=10,F=[0,0,0,0],j=typeof f!=S,G=j&&f.subtle,X=j&&typeof G!=S,J=A.bytes,Q=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],s=t._tables[1],a=e.length;let o,i,c,l=1;if(4!==a&&6!==a&&8!==a)throw new r("invalid aes key size");for(t._key=[i=e.slice(0),c=[]],o=a;4*a+28>o;o++){let e=i[o-1];(o%a===0||8===a&&o%a===4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],o%a===0&&(e=e<<8^e>>>24^l<<24,l=l<<1^283*(l>>7))),i[o]=i[o-a]^e}for(let e=0;o;e++,o--){const t=i[3&e?o:o-4];c[e]=4>=o||4>e?t:s[0][n[t>>>24]]^s[1][n[t>>16&255]]^s[2][n[t>>8&255]]^s[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],s=t[4],r=[],a=[];let o,i,c,l;for(let e=0;256>e;e++)a[(r[e]=e<<1^283*(e>>7))^e]=e;for(let u=o=0;!n[u];u^=i||1,o=a[o]||1){let a=o^o<<1^o<<2^o<<3^o<<4;a=a>>8^255&a^99,n[u]=a,s[a]=u,l=r[c=r[i=r[u]]];let h=16843009*l^65537*c^257*i^16843008*u,p=257*r[a]^16843008*a;for(let n=0;4>n;n++)e[n][u]=p=p<<24^p>>>8,t[n][a]=h=h<<24^h>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new r("invalid aes block size");const n=this._key[t],s=n.length/4-2,a=[0,0,0,0],o=this._tables[t],i=o[0],c=o[1],l=o[2],u=o[3],h=o[4];let p,f,d,g=e[0]^n[0],w=e[t?3:1]^n[1],y=e[2]^n[2],m=e[t?1:3]^n[3],_=4;for(let e=0;s>e;e++)p=i[g>>>24]^c[w>>16&255]^l[y>>8&255]^u[255&m]^n[_],f=i[w>>>24]^c[y>>16&255]^l[m>>8&255]^u[255&g]^n[_+1],d=i[y>>>24]^c[m>>16&255]^l[g>>8&255]^u[255&w]^n[_+2],m=i[m>>>24]^c[g>>16&255]^l[w>>8&255]^u[255&y]^n[_+3],_+=4,g=p,w=f,y=d;for(let e=0;4>e;e++)a[t?3&-e:e]=h[g>>>24]<<24^h[w>>16&255]<<16^h[y>>8&255]<<8^h[255&m]^n[_++],p=g,g=w,w=y,y=m,m=p;return a}},Y=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255&~(e>>24))e+=1<<24;else{let t=e>>16&255,n=e>>8&255,s=255&e;255===t?(t=0,255===n?(n=0,255===s?s=0:++s):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=s}return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let s;if(!(s=t.length))return[];const r=I.bitLength(t);for(let r=0;s>r;r+=4){this.incCounter(n);const s=e.encrypt(n);t[r]^=s[0],t[r+1]^=s[1],t[r+2]^=s[2],t[r+3]^=s[3]}return I.clamp(t,r)}},Z=H.hmacSha1;let $=j&&X&&typeof G.importKey==v,ee=j&&X&&typeof G.deriveBits==v;class te extends g{constructor({password:e,rawPassword:n,signed:s,encryptionStrength:o,checkPasswordOnly:i}){super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:ae(e,n),signed:s,strength:o-1,pending:new a})},async transform(e,t){const n=this,{password:s,strength:o,resolveReady:c,ready:l}=n;s?(await(async(e,t,n,s)=>{const a=await re(e,t,n,ie(s,0,N[t])),o=ie(s,N[t]);if(a[0]!=o[0]||a[1]!=o[1])throw new r(B)})(n,o,s,ie(e,0,N[o]+2)),e=ie(e,N[o]+2),i?t.error(new r(T)):c()):await l;const u=new a(e.length-L-(e.length-L)%x);t.enqueue(se(n,e,u,0,L,!0))},async flush(e){const{signed:t,ctr:n,hmac:s,pending:o,ready:i}=this;if(s&&n){await i;const c=ie(o,0,o.length-L),l=ie(o,o.length-L);let u=new a;if(c.length){const e=le(J,c);s.update(e);const t=n.update(e);u=ce(J,t)}if(t){const e=ie(ce(J,s.digest()),0,L);for(let t=0;L>t;t++)if(e[t]!=l[t])throw new r(K)}e.enqueue(u)}}})}}class ne extends g{constructor({password:e,rawPassword:n,encryptionStrength:s}){let r;super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:ae(e,n),strength:s-1,pending:new a})},async transform(e,t){const n=this,{password:s,strength:r,resolveReady:o,ready:i}=n;let c=new a;s?(c=await(async(e,t,n)=>{const s=V(new a(N[t]));return oe(s,await re(e,t,n,s))})(n,r,s),o()):await i;const l=new a(c.length+e.length-e.length%x);l.set(c,0),t.enqueue(se(n,e,l,c.length,0))},async flush(e){const{ctr:t,hmac:n,pending:s,ready:o}=this;if(n&&t){await o;let i=new a;if(s.length){const e=t.update(le(J,s));n.update(e),i=ce(J,e)}r.signature=ce(J,n.digest()).slice(0,L),e.enqueue(oe(i,r.signature))}}}),r=this}}function se(e,t,n,s,r,o){const{ctr:i,hmac:c,pending:l}=e,u=t.length-r;let h;for(l.length&&(t=oe(l,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new a(t)).set(n,0)}return e})(n,u-u%x)),h=0;u-x>=h;h+=x){const e=le(J,ie(t,h,h+x));o&&c.update(e);const r=i.update(e);o||c.update(r),n.set(ce(J,r),h+s)}return e.pending=ie(t,h),n}async function re(n,s,r,o){n.password=null;const i=await(async(e,t,n,s,r)=>{if(!$)return H.importKey(t);try{return await G.importKey("raw",t,n,!1,r)}catch(e){return $=!1,H.importKey(t)}})(0,r,U,0,M),c=await(async(e,t,n)=>{if(!ee)return H.pbkdf2(t,e.salt,W.iterations,n);try{return await G.deriveBits(e,t,n)}catch(s){return ee=!1,H.pbkdf2(t,e.salt,W.iterations,n)}})(t.assign({salt:o},W),i,8*(2*O[s]+2)),l=new a(c),u=le(J,ie(l,0,O[s])),h=le(J,ie(l,O[s],2*O[s])),p=ie(l,2*O[s]);return t.assign(n,{keys:{key:u,authentication:h,passwordVerification:p},ctr:new Y(new Q(u),e.from(F)),hmac:new Z(h)}),p}function ae(e,t){return t===b?(e=>{if(typeof p==S){const t=new a((e=unescape(encodeURIComponent(e))).length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return t}return(new p).encode(e)})(e):t}function oe(e,t){let n=e;return e.length+t.length&&(n=new a(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function ie(e,t,n){return e.subarray(t,n)}function ce(e,t){return e.fromBits(t)}function le(e,t){return e.toBits(t)}class ue extends g{constructor({password:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){t.assign(this,{password:e,passwordVerification:n}),de(this,e)},transform(e,t){const n=this;if(n.password){const t=pe(n,e.subarray(0,12));if(n.password=null,t.at(-1)!=n.passwordVerification)throw new r(B);e=e.subarray(12)}s?t.error(new r(T)):t.enqueue(pe(n,e))}})}}class he extends g{constructor({password:e,passwordVerification:n}){super({start(){t.assign(this,{password:e,passwordVerification:n}),de(this,e)},transform(e,t){const n=this;let s,r;if(n.password){n.password=null;const t=V(new a(12));t[11]=n.passwordVerification,s=new a(e.length+t.length),s.set(fe(n,t),0),r=12}else s=new a(e.length),r=0;s.set(fe(n,e),r),t.enqueue(s)}})}}function pe(e,t){const n=new a(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],ge(e,n[s]);return n}function fe(e,t){const n=new a(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],ge(e,t[s]);return n}function de(e,n){const s=[305419896,591751049,878082192];t.assign(e,{keys:s,crcKey0:new D(s[0]),crcKey2:new D(s[2])});for(let t=0;t<n.length;t++)ge(e,n.charCodeAt(t))}function ge(e,t){let[n,r,a]=e.keys;e.crcKey0.append([t]),n=~e.crcKey0.get(),r=me(s.imul(me(r+ye(n)),134775813)+1),e.crcKey2.append([r>>>24]),a=~e.crcKey2.get(),e.keys=[n,r,a]}function we(e){const t=2|e.keys[2];return ye(s.imul(t,1^t)>>>8)}function ye(e){return 255&e}function me(e){return 4294967295&e}const _e="deflate-raw";class be extends g{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:s}){super({});const{compressed:r,encrypted:a,useCompressionStream:o,zipCrypto:i,signed:c,level:l}=e,h=this;let p,f,d=super.readable;a&&!i||!c||(p=new C,d=ze(d,p)),r&&(d=ke(d,o,{level:l,chunkSize:t},s,n)),a&&(i?d=ze(d,new he(e)):(f=new ne(e),d=ze(d,f))),ve(h,d,()=>{let e;a&&!i&&(e=f.signature),a&&!i||!c||(e=new u(p.value.buffer).getUint32(0)),h.signature=e})}}class Se extends g{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:s}){super({});const{zipCrypto:a,encrypted:o,signed:i,signature:c,compressed:l,useCompressionStream:h}=e;let p,f,d=super.readable;o&&(a?d=ze(d,new ue(e)):(f=new te(e),d=ze(d,f))),l&&(d=ke(d,h,{chunkSize:t},s,n)),o&&!a||!i||(p=new C,d=ze(d,p)),ve(this,d,()=>{if((!o||a)&&i){const e=new u(p.value.buffer);if(c!=e.getUint32(0,!1))throw new r(K)}})}}function ve(e,n,s){n=ze(n,new g({flush:s})),t.defineProperty(e,"readable",{get:()=>n})}function ke(e,t,n,s,r){try{e=ze(e,new(t&&s?s:r)(_e,n))}catch(s){if(!t)throw s;e=ze(e,new r(_e,n))}return e}function ze(e,t){return e.pipeThrough(t)}const De="data",Ce="close";class Ie extends g{constructor(e,n){super({});const s=this,{codecType:a}=e;let o;a.startsWith("deflate")?o=be:a.startsWith("inflate")&&(o=Se),s.outputSize=0;let i=0;const c=new o(e,n),l=super.readable,u=new g({transform(e,t){e&&e.length&&(i+=e.length,t.enqueue(e))},flush(){t.assign(s,{inputSize:i})}}),h=new g({transform(t,n){if(t&&t.length&&(n.enqueue(t),s.outputSize+=t.length,e.outputSize&&s.outputSize>e.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:e}=c;t.assign(s,{signature:e,inputSize:i})}});t.defineProperty(s,"readable",{get:()=>l.pipeThrough(u).pipeThrough(c).pipeThrough(h)})}}class Ae extends g{constructor(e){let t;super({transform:function n(s,r){if(t){const e=new a(t.length+s.length);e.set(t),e.set(s,t.length),s=e,t=null}s.length>e?(r.enqueue(s.slice(0,e)),n(s.slice(e),r)):t=s},flush(e){t&&t.length&&e.enqueue(t)}})}}const qe=new l,Re=new l;let He,Pe=0,Be=!0;async function Ke(e){try{const{options:t,scripts:s,config:r}=e;if(s&&s.length)try{Be?importScripts.apply(b,s):await Te(s)}catch(e){Be=!1,await Te(s)}self.initCodec&&self.initCodec(),r.CompressionStreamNative=self.CompressionStream,r.DecompressionStreamNative=self.DecompressionStream,self.Deflate&&(r.CompressionStream=new k(self.Deflate)),self.Inflate&&(r.DecompressionStream=new k(self.Inflate));const a={highWaterMark:1},o=e.readable||new w({async pull(e){const t=new h(e=>qe.set(Pe,e));Ve({type:"pull",messageId:Pe}),Pe=(Pe+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await t;e.enqueue(s),r&&e.close()}},a),i=e.writable||new y({async write(e){let t;const s=new h(e=>t=e);Re.set(Pe,t),Ve({type:De,value:e,messageId:Pe}),Pe=(Pe+1)%n.MAX_SAFE_INTEGER,await s}},a),c=new Ie(t,r);He=new AbortController;const{signal:l}=He;await o.pipeThrough(c).pipeThrough(new Ae(r.chunkSize)).pipeTo(i,{signal:l,preventClose:!0,preventAbort:!0}),await i.getWriter().close();const{signature:u,inputSize:p,outputSize:f}=c;Ve({type:Ce,result:{signature:u,inputSize:p,outputSize:f}})}catch(e){e.outputSize=0,xe(e)}}async function Te(e){for(const t of e)await import(t)}function Ve(e){let{value:t}=e;if(t)if(t.length)try{t=new a(t),e.value=t.buffer,d(e,[e.value])}catch(t){d(e)}else d(e);else d(e)}function xe(e=new r("Unknown error")){const{message:t,stack:n,code:s,name:a,outputSize:o}=e;d({error:{message:t,stack:n,code:s,name:a,outputSize:o}})}function Ee(e,n,s){return class{constructor(r){const o=this;var i,c;i=r,c="level",(typeof t.hasOwn===v?t.hasOwn(i,c):i.hasOwnProperty(c))&&r.level===b&&delete r.level,o.codec=new e(t.assign({},n,r)),s(o.codec,e=>{if(o.pendingData){const t=o.pendingData;o.pendingData=new a(t.length+e.length);const{pendingData:n}=o;n.set(t,0),n.set(e,t.length)}else o.pendingData=new a(e)})}append(e){return this.codec.push(e),r(this)}flush(){return this.codec.push(new a,!0),r(this)}};function r(e){if(e.pendingData){const t=e.pendingData;return e.pendingData=null,t}return new a}}addEventListener("message",({data:e})=>{const{type:t,messageId:n,value:s,done:r}=e;try{if("start"==t&&Ke(e),t==De){const e=qe.get(n);qe.delete(n),e({value:new a(s),done:r})}if("ack"==t){const e=Re.get(n);Re.delete(n),e()}t==Ce&&He.abort()}catch(e){xe(e)}}),self.initCodec=()=>{const{Deflate:e,Inflate:t}=((e,t={},n)=>({Deflate:Ee(e.Deflate,t.deflate,n),Inflate:Ee(e.Inflate,t.inflate,n)}))(pako,{deflate:{raw:!0},inflate:{raw:!0}},(e,t)=>e.onData=t);self.Deflate=e,self.Inflate=t}}();