iflow-engine-base-3d 3.12.21 → 3.12.24
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.
- package/dist/bim-engine-sdk.es.js +3 -3
- package/dist/bim-engine-sdk.umd.js +521 -387
- package/dist/chunks/{engine-3d-D002ez-P.js → engine-3d-CRGDf-35.js} +1311 -1244
- package/dist/chunks/{sdk-assets-DAIj-7Ou.js → sdk-assets-Dl8936wx.js} +5 -5
- package/dist/chunks/{sdk-runtime-BBTRqiQE.js → sdk-runtime-9GTYNlYO.js} +2 -2
- package/dist/chunks/{three-vendor-ClQTDDlA.js → three-vendor-Cy618JLY.js} +7641 -7182
- package/distGaussian/gaussian.es.js +14769 -14769
- package/distGaussian/gaussian.umd.js +23 -23
- package/distGaussian/index.d.ts +80 -80
- package/package.json +7 -3
- package/dist2d/dwg-preview.css +0 -1
- package/dist2d/dwg-preview.d.ts +0 -2
- package/dist2d/dwg-preview.es.js +0 -21462
- package/dist2d/dwg-preview.umd.js +0 -242
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
(function(pt,Pe){typeof exports=="object"&&typeof module<"u"?Pe(exports,require("three"),require("opentype.js")):typeof define=="function"&&define.amd?define(["exports","three","opentype.js"],Pe):(pt=typeof globalThis<"u"?globalThis:pt||self,Pe(pt.DwgPreview={},pt.THREE,pt["{}"]))})(this,(function(pt,Pe,as){"use strict";var Ae=typeof document<"u"?document.currentScript:null;function Ei(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const j=Ei(Pe),os=Ei(as);var kt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wi(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function ls(o){if(Object.prototype.hasOwnProperty.call(o,"__esModule"))return o;var e=o.default;if(typeof e=="function"){var t=function r(){var n=!1;try{n=this instanceof r}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(o).forEach(function(r){var n=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return o[r]}})}),t}var zt={exports:{}},cs=zt.exports,Si;function us(){return Si||(Si=1,(function(o,e){(function(t,r){o.exports=r()})(cs,function(){var t=function(){function r(h){return a.appendChild(h.dom),h}function n(h){for(var m=0;m<a.children.length;m++)a.children[m].style.display=m===h?"block":"none";s=h}var s=0,a=document.createElement("div");a.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",a.addEventListener("click",function(h){h.preventDefault(),n(++s%a.children.length)},!1);var i=(performance||Date).now(),l=i,c=0,p=r(new t.Panel("FPS","#0ff","#002")),b=r(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var x=r(new t.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:a,addPanel:r,showPanel:n,begin:function(){i=(performance||Date).now()},end:function(){c++;var h=(performance||Date).now();if(b.update(h-i,200),h>l+1e3&&(p.update(1e3*c/(h-l),100),l=h,c=0,x)){var m=performance.memory;x.update(m.usedJSHeapSize/1048576,m.jsHeapSizeLimit/1048576)}return h},update:function(){i=this.end()},domElement:a,setMode:n}};return t.Panel=function(r,n,s){var a=1/0,i=0,l=Math.round,c=l(window.devicePixelRatio||1),p=80*c,b=48*c,x=3*c,h=2*c,m=3*c,d=15*c,y=74*c,u=30*c,v=document.createElement("canvas");v.width=p,v.height=b,v.style.cssText="width:80px;height:48px";var E=v.getContext("2d");return E.font="bold "+9*c+"px Helvetica,Arial,sans-serif",E.textBaseline="top",E.fillStyle=s,E.fillRect(0,0,p,b),E.fillStyle=n,E.fillText(r,x,h),E.fillRect(m,d,y,u),E.fillStyle=s,E.globalAlpha=.9,E.fillRect(m,d,y,u),{dom:v,update:function(T,_){a=Math.min(a,T),i=Math.max(i,T),E.fillStyle=s,E.globalAlpha=1,E.fillRect(0,0,p,d),E.fillStyle=n,E.fillText(l(T)+" "+r+" ("+l(a)+"-"+l(i)+")",x,h),E.drawImage(v,m+c,d,y-c,u,m,d,y-c,u),E.fillRect(m+y-c,d,c,u),E.fillStyle=s,E.globalAlpha=.9,E.fillRect(m+y-c,d,c,l((1-T/_)*u))}}},t})})(zt)),zt.exports}var hs=us();const ds=wi(hs);var et=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelLoadError="model-load-error",o.RenderStart="render-start",o.RenderEnd="render-end",o.CameraChanged="camera-changed",o.CameraReset="camera-reset",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.EntityClick="entity-click",o.LayerVisibilityChanged="layer-visibility-changed",o.LayerColorChanged="layer-color-changed",o.ViewZoomChanged="view-zoom-changed",o.ViewPanChanged="view-pan-changed",o.ToolActivated="tool-activated",o.ToolDeactivated="tool-deactivated",o.Error="error",o.Warning="warning",o))(et||{});class fs{listeners=new Map;onceListeners=new Map;debugMode=!1;constructor(e=!1){this.debugMode=e,this.initializeEvents()}initializeEvents(){Object.values(et).forEach(t=>{this.listeners.set(String(t),new Set),this.onceListeners.set(String(t),new Set)})}on(e,t){const r=String(e);return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(t),this.debugMode&&console.log(`[EventModule2d] Listener added for ${r}`),()=>this.off(r,t)}once(e,t){const r=String(e);this.onceListeners.has(r)||this.onceListeners.set(r,new Set),this.onceListeners.get(r).add(t),this.debugMode&&console.log(`[EventModule2d] Once listener added for ${r}`)}off(e,t){const r=String(e),n=this.listeners.get(r);n&&(n.delete(t),this.debugMode&&console.log(`[EventModule2d] Listener removed for ${r}`))}trigger(e,t){const r=String(e);this.debugMode&&console.log(`[EventModule2d] Triggering ${r}`,t);const n=this.listeners.get(r);n&&n.size>0&&n.forEach(a=>{try{a(t)}catch(i){console.error(`[EventModule2d] Error in listener for ${r}:`,i)}});const s=this.onceListeners.get(r);s&&s.size>0&&(s.forEach(a=>{try{a(t)}catch(i){console.error(`[EventModule2d] Error in once listener for ${r}:`,i)}}),s.clear())}removeAllListeners(){this.listeners.forEach(e=>e.clear()),this.onceListeners.forEach(e=>e.clear()),this.debugMode&&console.log("[EventModule2d] All listeners removed")}removeListenersOfType(e){const t=String(e),r=this.listeners.get(t),n=this.onceListeners.get(t);r&&r.clear(),n&&n.clear(),this.debugMode&&console.log(`[EventModule2d] All listeners removed for ${t}`)}getListenerCount(e){const t=String(e),r=this.listeners.get(t),n=this.onceListeners.get(t);return(r?.size||0)+(n?.size||0)}setDebugMode(e){this.debugMode=e}getAllEventTypes(){return Object.values(et)}dispose(){this.removeAllListeners(),this.listeners.clear(),this.onceListeners.clear(),this.debugMode&&console.log("[EventModule2d] Disposed")}}const ps=`
|
|
2
|
-
varying vec2 vWorldPos;
|
|
3
|
-
|
|
4
|
-
void main() {
|
|
5
|
-
vec4 worldPosition = modelMatrix * vec4(position, 1.0);
|
|
6
|
-
vWorldPos = worldPosition.xy;
|
|
7
|
-
gl_Position = projectionMatrix * viewMatrix * worldPosition;
|
|
8
|
-
}
|
|
9
|
-
`,gs=`
|
|
10
|
-
precision highp float;
|
|
11
|
-
|
|
12
|
-
varying vec2 vWorldPos;
|
|
13
|
-
|
|
14
|
-
uniform float minorSpacing;
|
|
15
|
-
uniform float majorStep;
|
|
16
|
-
uniform vec2 worldPerPixel;
|
|
17
|
-
uniform float minorThicknessPx;
|
|
18
|
-
uniform float majorThicknessPx;
|
|
19
|
-
uniform vec3 minorColor;
|
|
20
|
-
uniform vec3 majorColor;
|
|
21
|
-
uniform float minorOpacity;
|
|
22
|
-
uniform float majorOpacity;
|
|
23
|
-
|
|
24
|
-
float distanceToGridLine(float coord, float spacing) {
|
|
25
|
-
float halfSpacing = spacing * 0.5;
|
|
26
|
-
float wrapped = mod(coord + halfSpacing, spacing) - halfSpacing;
|
|
27
|
-
return abs(wrapped);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
void main() {
|
|
31
|
-
float spacing = max(minorSpacing, 1e-6);
|
|
32
|
-
float stepMultiplier = max(majorStep, 1.0);
|
|
33
|
-
float majorSpacing = spacing * stepMultiplier;
|
|
34
|
-
|
|
35
|
-
float distMinorX = distanceToGridLine(vWorldPos.x, spacing);
|
|
36
|
-
float distMinorY = distanceToGridLine(vWorldPos.y, spacing);
|
|
37
|
-
float distMajorX = distanceToGridLine(vWorldPos.x, majorSpacing);
|
|
38
|
-
float distMajorY = distanceToGridLine(vWorldPos.y, majorSpacing);
|
|
39
|
-
|
|
40
|
-
float minorThicknessX = max(worldPerPixel.x * minorThicknessPx, 1e-7);
|
|
41
|
-
float minorThicknessY = max(worldPerPixel.y * minorThicknessPx, 1e-7);
|
|
42
|
-
float majorThicknessX = max(worldPerPixel.x * majorThicknessPx, 1e-7);
|
|
43
|
-
float majorThicknessY = max(worldPerPixel.y * majorThicknessPx, 1e-7);
|
|
44
|
-
|
|
45
|
-
float minorMaskX = 1.0 - smoothstep(minorThicknessX, minorThicknessX * 1.5, distMinorX);
|
|
46
|
-
float minorMaskY = 1.0 - smoothstep(minorThicknessY, minorThicknessY * 1.5, distMinorY);
|
|
47
|
-
float majorMaskX = 1.0 - smoothstep(majorThicknessX, majorThicknessX * 1.5, distMajorX);
|
|
48
|
-
float majorMaskY = 1.0 - smoothstep(majorThicknessY, majorThicknessY * 1.5, distMajorY);
|
|
49
|
-
|
|
50
|
-
float majorMask = clamp(max(majorMaskX, majorMaskY), 0.0, 1.0);
|
|
51
|
-
float minorMask = clamp(max(minorMaskX, minorMaskY), 0.0, 1.0);
|
|
52
|
-
minorMask *= (1.0 - majorMask); // Prevent overlap so bold lines dominate.
|
|
53
|
-
|
|
54
|
-
vec3 color = minorColor * minorMask * minorOpacity + majorColor * majorMask * majorOpacity;
|
|
55
|
-
float alpha = minorMask * minorOpacity + majorMask * majorOpacity;
|
|
56
|
-
alpha = clamp(alpha, 0.0, 1.0);
|
|
57
|
-
|
|
58
|
-
if (alpha <= 1e-4) {
|
|
59
|
-
discard;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
gl_FragColor = vec4(color, alpha);
|
|
63
|
-
}
|
|
64
|
-
`;class ms{scene;camera;container;gridGroup;gridGeometry;gridMaterial;gridMesh;animationFrameId=null;resizeObserver;windowResizeHandler;lastState={zoom:-1,centerX:Number.NaN,centerY:Number.NaN,viewWidth:0,viewHeight:0,containerWidth:0,containerHeight:0,minorSpacing:0};largeGridColor=6052956;smallGridColor=3815994;desiredMinorPixelSize=28;coverageMultiplier=1.6;minSpacing=1e-4;minorThicknessPx=.4;majorThicknessPx=.6;minorLineOpacity=.05;majorLineOpacity=.2;baseRenderOrder=-20;gridZOffset=-.001;majorStep=5;gridUniforms={minorSpacing:{value:100},majorStep:{value:this.majorStep},worldPerPixel:{value:new j.Vector2(1,1)},minorThicknessPx:{value:this.minorThicknessPx},majorThicknessPx:{value:this.majorThicknessPx},minorColor:{value:new j.Color(this.smallGridColor)},majorColor:{value:new j.Color(this.largeGridColor)},minorOpacity:{value:this.minorLineOpacity},majorOpacity:{value:this.majorLineOpacity}};constructor(e,t,r){this.scene=e,this.camera=t,this.container=r,this.gridGroup=new j.Group,this.gridGroup.name="AdaptiveGridGroup",this.gridGroup.renderOrder=this.baseRenderOrder,this.gridGroup.visible=!0,this.gridGroup.position.set(0,0,this.gridZOffset),this.scene.add(this.gridGroup),this.createGridMesh(),this.updateGrid(!0),this.startMonitoring(),this.setupResizeObserver()}createGridMesh(){this.gridGeometry=new j.PlaneGeometry(1,1,1,1),this.gridMaterial=new j.ShaderMaterial({uniforms:this.gridUniforms,vertexShader:ps,fragmentShader:gs,transparent:!0,depthWrite:!1,depthTest:!1,side:j.DoubleSide,toneMapped:!1}),this.gridMesh=new j.Mesh(this.gridGeometry,this.gridMaterial),this.gridMesh.frustumCulled=!1,this.gridMesh.renderOrder=this.baseRenderOrder,this.gridGroup.add(this.gridMesh)}startMonitoring(){const e=()=>{this.updateGrid(),this.animationFrameId=requestAnimationFrame(e)};e()}stopMonitoring(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}setupResizeObserver(){typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(()=>this.updateGrid(!0)),this.resizeObserver.observe(this.container)):(this.windowResizeHandler=()=>this.updateGrid(!0),window.addEventListener("resize",this.windowResizeHandler))}teardownResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0),this.windowResizeHandler&&(window.removeEventListener("resize",this.windowResizeHandler),this.windowResizeHandler=void 0)}normalizeSpacing(e){const t=Math.max(e,this.minSpacing),r=Math.floor(Math.log10(t)),n=Math.pow(10,r),s=[1,2,5,10];for(const a of s){const i=a*n;if(t<=i)return i}return 10*n}updateGrid(e=!1){if(!this.gridMesh)return;const t=Math.max(1,this.container.clientWidth),r=Math.max(1,this.container.clientHeight),n=this.camera.zoom,s=this.camera.right-this.camera.left,a=this.camera.top-this.camera.bottom,i=Math.max(this.minSpacing,s/n),l=Math.max(this.minSpacing,a/n),c=this.camera.position.x,p=this.camera.position.y,b=i/t,x=l/r,h=b*this.desiredMinorPixelSize,m=this.normalizeSpacing(h),d=this.lastState;if(!e){const v=Math.abs(n-d.zoom)/Math.max(1e-4,d.zoom||1)>.02,E=Math.abs(m-d.minorSpacing)>d.minorSpacing*.05,T=Math.abs(c-d.centerX)>Math.max(m*.5,.01),_=Math.abs(p-d.centerY)>Math.max(m*.5,.01),w=Math.abs(i-d.viewWidth)>d.viewWidth*.01,g=Math.abs(l-d.viewHeight)>d.viewHeight*.01,f=t!==d.containerWidth||r!==d.containerHeight;if(!(v||E||T||_||w||g||f))return}const y=i*this.coverageMultiplier,u=l*this.coverageMultiplier;this.gridMesh.scale.set(y,u,1),this.gridMesh.position.set(c,p,0),this.gridUniforms.minorSpacing.value=m,this.gridUniforms.worldPerPixel.value.set(b,x),this.lastState={zoom:n,centerX:c,centerY:p,viewWidth:i,viewHeight:l,containerWidth:t,containerHeight:r,minorSpacing:m}}setVisible(e){this.gridGroup.visible=e}setColors(e,t){this.largeGridColor=e,this.smallGridColor=t,this.gridUniforms.majorColor.value.setHex(e),this.gridUniforms.minorColor.value.setHex(t)}setOpacity(e,t){this.minorLineOpacity=Math.max(0,Math.min(1,e)),this.majorLineOpacity=Math.max(0,Math.min(1,t)),this.gridUniforms.minorOpacity.value=this.minorLineOpacity,this.gridUniforms.majorOpacity.value=this.majorLineOpacity}dispose(){this.stopMonitoring(),this.teardownResizeObserver(),this.gridMesh&&this.gridGroup.remove(this.gridMesh),this.gridGeometry&&(this.gridGeometry.dispose(),this.gridGeometry=void 0),this.gridMaterial&&(this.gridMaterial.dispose(),this.gridMaterial=void 0),this.gridMesh=void 0}}class ys{engine;scene;options;adaptiveGrid;axesHelper;constructor(e,t){this.engine=e,this.options=t,this.scene=this.createScene(),this.initHelpers()}createScene(){const e=new j.Scene,t=this.options.backgroundColor??1710618;return e.background=new j.Color(t),e.is2D=!0,e}initHelpers(){this.options.axesEnabled&&this.createAxes()}initGrid(){this.options.gridEnabled&&this.createGrid()}createGrid(e=1e3,t=50){this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.adaptiveGrid=new ms(this.scene,this.engine.cameraModule2d.orthographicCamera,this.engine.renderModule2d.container);const r=this.options.backgroundColor??1710618;this.updateGridColorsByBackground(r)}createAxes(e=100){this.axesHelper&&this.scene.remove(this.axesHelper),this.axesHelper=new j.AxesHelper(e),this.axesHelper.rotation.z=0,this.scene.add(this.axesHelper),this.scene.remove(this.axesHelper),this.scene.add(this.axesHelper),this.axesHelper.renderOrder=999}setBackgroundColor(e){this.scene.background=new j.Color(e),this.updateGridColorsByBackground(e)}updateGridColorsByBackground(e){if(!this.adaptiveGrid)return;const t=new j.Color(e);.299*t.r+.587*t.g+.114*t.b<.5?(this.adaptiveGrid.setColors(16777215,16777215),this.adaptiveGrid.setOpacity(.2,.3)):(this.adaptiveGrid.setColors(0,0),this.adaptiveGrid.setOpacity(.05,.2))}addObject(e){this.scene.add(e)}removeObject(e){this.scene.remove(e),e instanceof j.Mesh&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}clearScene(){for(let e=this.scene.children.length-1;e>=0;e--){const t=this.scene.children[e];t!==this.axesHelper&&(this.adaptiveGrid||this.removeObject(t))}this.engine.events&&this.engine.events.trigger("scene-cleared")}getObjects(e=!1){const t=[];return this.scene.children.forEach(r=>{(e||r!==this.axesHelper)&&t.push(r)}),t}getSceneStats(){let e=0,t=0,r=0;return this.scene.children.forEach(n=>{n instanceof j.Mesh?e++:n instanceof j.Line?t++:n instanceof j.Group&&r++}),{objectCount:this.scene.children.length,meshCount:e,lineCount:t,groupCount:r}}setGridVisible(e){this.adaptiveGrid&&this.adaptiveGrid.setVisible(e)}setAxesVisible(e){this.axesHelper&&(this.axesHelper.visible=e)}dispose(){this.clearScene(),this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.axesHelper&&(this.scene.remove(this.axesHelper),this.axesHelper=void 0),this.scene.clear()}}class vs{engine;isFree;highlightModels;highlightHoverModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.highlightHoverModels=[],this.models=[]}}class xs{engine;orthographicCamera;container;frustumSize=1e3;near=.1;far=1e4;initialZoom=1;defaultPosition=new j.Vector3(0,0,1e3);constructor(e,t){this.engine=e,this.container=t,this.orthographicCamera=this.createOrthographicCamera()}createOrthographicCamera(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,r=t*e,n=new j.OrthographicCamera(-r,r,t,-t,this.near,this.far);return n.position.copy(this.defaultPosition),n.lookAt(0,0,0),n.zoom=this.initialZoom,n.updateProjectionMatrix(),n}animationId=null;animationStartTime=0;animationDuration=800;animationStartState={};animationTargetState={};fitToExtents(e,t=1.2,r=!0,n=800){const s=new j.Vector3(e.min[0],e.min[1]),a=new j.Vector3(e.max[0],e.max[1]);if(!(s.distanceTo(a)>.001)){console.warn("[CameraModule2d] Invalid extents, using default view"),this.resetView();return}const l=new j.Vector3;l.addVectors(s,a).multiplyScalar(.5);const c=new j.Vector3;c.subVectors(a,s);const b=Math.max(c.x,c.y)*t,x=this.container.clientWidth/this.container.clientHeight,h=b/2,m=h*x,d=-m,y=m,u=h,v=-h,E=l.x,T=l.y,_=1;if(!r){this.orthographicCamera.left=d,this.orthographicCamera.right=y,this.orthographicCamera.top=u,this.orthographicCamera.bottom=v,this.orthographicCamera.position.set(E,T,this.defaultPosition.z),this.orthographicCamera.zoom=_,this.orthographicCamera.updateProjectionMatrix(),this.engine.controlModule2d?.panControls&&(this.engine.controlModule2d.panControls.setPosition(E,T),this.engine.controlModule2d.panControls.setZoom(_)),this.engine.events&&this.engine.events.trigger("camera-changed",{type:"fit-to-extents",center:l,size:c});return}this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.animationStartState={left:this.orthographicCamera.left,right:this.orthographicCamera.right,top:this.orthographicCamera.top,bottom:this.orthographicCamera.bottom,x:this.orthographicCamera.position.x,y:this.orthographicCamera.position.y,zoom:this.orthographicCamera.zoom},this.animationTargetState={left:d,right:y,top:u,bottom:v,x:E,y:T,zoom:_},this.animationDuration=n,this.animationStartTime=performance.now(),this.animateFitToExtents(l,c)}easeOutCubic(e){return 1-Math.pow(1-e,3)}animateFitToExtents(e,t){const n=performance.now()-this.animationStartTime,s=Math.min(n/this.animationDuration,1),a=this.easeOutCubic(s),i=this.animationStartState,l=this.animationTargetState;this.orthographicCamera.left=this.lerp(i.left,l.left,a),this.orthographicCamera.right=this.lerp(i.right,l.right,a),this.orthographicCamera.top=this.lerp(i.top,l.top,a),this.orthographicCamera.bottom=this.lerp(i.bottom,l.bottom,a),this.orthographicCamera.position.x=this.lerp(i.x,l.x,a),this.orthographicCamera.position.y=this.lerp(i.y,l.y,a),this.orthographicCamera.zoom=this.lerp(i.zoom,l.zoom,a),this.orthographicCamera.updateProjectionMatrix(),this.engine.controlModule2d?.panControls&&(this.engine.controlModule2d.panControls.setPosition(this.orthographicCamera.position.x,this.orthographicCamera.position.y),this.engine.controlModule2d.panControls.setZoom(this.orthographicCamera.zoom)),this.engine.events&&this.engine.events.trigger("camera-changed",{type:"fit-to-extents",center:e,size:t,progress:a}),s<1?this.animationId=requestAnimationFrame(()=>this.animateFitToExtents(e,t)):this.animationId=null}lerp(e,t,r){return e+(t-e)*r}setZoom(e){this.orthographicCamera.zoom=e,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("view-zoom-changed",{zoom:e})}getZoom(){return this.orthographicCamera.zoom}setPosition(e,t){this.orthographicCamera.position.set(e,t,this.defaultPosition.z),this.engine.events&&this.engine.events.trigger("view-pan-changed",{x:e,y:t})}getPosition(){return this.orthographicCamera.position.clone()}getViewState(){return{left:this.orthographicCamera.left,right:this.orthographicCamera.right,top:this.orthographicCamera.top,bottom:this.orthographicCamera.bottom,x:this.orthographicCamera.position.x,y:this.orthographicCamera.position.y,zoom:this.orthographicCamera.zoom}}applyViewState(e){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.orthographicCamera.left=e.left,this.orthographicCamera.right=e.right,this.orthographicCamera.top=e.top,this.orthographicCamera.bottom=e.bottom,this.orthographicCamera.position.set(e.x,e.y,this.defaultPosition.z),this.orthographicCamera.zoom=e.zoom,this.orthographicCamera.updateProjectionMatrix(),this.engine.controlModule2d?.panControls&&(this.engine.controlModule2d.panControls.setPosition(e.x,e.y),this.engine.controlModule2d.panControls.setZoom(e.zoom)),this.engine.events?.trigger("camera-changed",{type:"restore-workspace-view"})}resetView(){this.orthographicCamera.position.copy(this.defaultPosition),this.orthographicCamera.zoom=this.initialZoom,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("camera-reset")}getViewBounds(){const e=this.orthographicCamera,t=e.zoom,r=e.left/t,n=e.right/t,s=e.top/t,a=e.bottom/t,i=e.position.x,l=e.position.y;return{minX:i+r,maxX:i+n,minY:l+a,maxY:l+s,width:n-r,height:s-a}}screenToWorld(e,t){const r=new j.Vector3(e/this.container.clientWidth*2-1,-(t/this.container.clientHeight)*2+1,.5);return r.unproject(this.orthographicCamera),r}worldToScreen(e,t){const r=new j.Vector3(e,t,0);return r.project(this.orthographicCamera),{x:(r.x+1)/2*this.container.clientWidth,y:-(r.y-1)/2*this.container.clientHeight}}updateAspectRatio(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,r=t*e;this.orthographicCamera.left=-r,this.orthographicCamera.right=r,this.orthographicCamera.top=t,this.orthographicCamera.bottom=-t,this.orthographicCamera.updateProjectionMatrix()}setFrustumSize(e){this.frustumSize=e,this.updateAspectRatio()}getFrustumSize(){return this.frustumSize}dispose(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.orthographicCamera=null}}const Cs="iflowbim.cn",bs=512,Es=128,ws=150,Ss=38,Kt=290,hr=190;class Ts{THREE;text;scene;camera;material;sprites=[];size;viewportWidth=0;viewportHeight=0;constructor(e,t=Cs){this.THREE=e,this.text=t,this.scene=new e.Scene,this.camera=new e.OrthographicCamera(0,1,1,0,-10,10),this.material=new e.SpriteMaterial({map:new e.CanvasTexture(this.createTextTexture()),transparent:!0,opacity:.46,depthTest:!1,depthWrite:!1,toneMapped:!1}),this.size=new e.Vector2}render(e){}dispose(){this.material.map?.dispose?.(),this.material.dispose?.(),this.sprites.length=0}createTextTexture(){const e=document.createElement("canvas");e.width=bs,e.height=Es;const t=e.getContext("2d");return t&&(t.clearRect(0,0,e.width,e.height),t.textAlign="center",t.textBaseline="middle",t.font="600 54px Arial, Helvetica, sans-serif",t.lineWidth=3,t.strokeStyle="rgba(0, 0, 0, 0.20)",t.fillStyle="rgba(255, 255, 255, 0.24)",t.strokeText(this.text,e.width/2,e.height/2),t.fillText(this.text,e.width/2,e.height/2)),e}updateLayout(e,t){if(e===this.viewportWidth&&t===this.viewportHeight)return;this.viewportWidth=e,this.viewportHeight=t,this.camera.left=-e/2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=-t/2,this.camera.updateProjectionMatrix();const r=Math.ceil(e/Kt)+2,n=Math.ceil(t/hr)+2,s=r*n;this.ensureSpriteCount(s);let a=0;const i=-e/2-Kt/2,l=-t/2-hr/2;for(let c=0;c<n;c+=1)for(let p=0;p<r;p+=1){const b=this.sprites[a],x=i+p*Kt+c%2*(Kt/2),h=l+c*hr;b.position.set(x,h,0),b.visible=!0,a+=1}for(let c=a;c<this.sprites.length;c+=1)this.sprites[c].visible=!1}ensureSpriteCount(e){for(;this.sprites.length<e;){const t=new this.THREE.Sprite(this.material);t.scale.set(ws,Ss,1),t.rotation.z=-.32,t.renderOrder=999999,this.scene.add(t),this.sprites.push(t)}}}class As{engine;renderer;container;options;watermark;antialias=!0;alpha=!1;precision="highp";constructor(e,t,r){this.engine=e,this.container=t,this.options=r,this.watermark=new Ts(j),this.renderer=this.createRenderer(),this.handleResize()}createRenderer(){const e=new j.WebGLRenderer({antialias:this.antialias,alpha:this.alpha,precision:this.precision}),t=this.container.clientWidth,r=this.container.clientHeight;return e.setSize(t,r),e.setPixelRatio(window.devicePixelRatio),e.autoClear=!0,e.sortObjects=!0,e.setClearColor(this.options.backgroundColor??1710618),this.container.appendChild(e.domElement),e}render(e,t){const r=performance.now();this.engine.events&&this.engine.events.trigger("render-start"),this.renderer.render(e,t),this.drawWatermark();const n=performance.now()-r;this.engine.events&&this.engine.events.trigger("render-end",{renderTime:n})}handleResize(){window.addEventListener("resize",()=>{this.onWindowResize()})}onWindowResize(){const e=this.container.clientWidth,t=this.container.clientHeight;this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio(),this.engine.scene&&this.engine.camera&&this.render(this.engine.scene,this.engine.camera)}setSize(e,t){this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio()}getSize(){const e=this.renderer.getSize(new j.Vector2);return{width:e.x,height:e.y}}setBackgroundColor(e){this.renderer.setClearColor(new j.Color(e))}setPixelRatio(e){this.renderer.setPixelRatio(e)}getPixelRatio(){return this.renderer.getPixelRatio()}setAntialias(e){console.warn("Antialias cannot be changed after renderer creation")}clear(e=!0,t=!0,r=!1){this.renderer.clear(e,t,r)}drawWatermark(){this.watermark.render(this.renderer)}getInfo(){const e=this.renderer.getContext();return{renderer:this.renderer.capabilities.isWebGL2?"WebGL 2.0":"WebGL 1.0",version:this.renderer.capabilities.getVersion(),vendor:this.renderer.capabilities.vendor,capabilities:{maxTextureSize:this.renderer.capabilities.maxTextureSize,maxRenderbufferSize:this.renderer.capabilities.maxRenderbufferSize,maxVertexAttribs:this.renderer.capabilities.maxVertexAttribs,maxVaryingVectors:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)}}}dispose(){window.removeEventListener("resize",this.onWindowResize.bind(this)),this.watermark.dispose(),this.renderer.dispose(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.renderer=null}}class _s extends j.EventDispatcher{object;domElement;enabled=!0;enableZoom=!0;enablePan=!0;enableDamping=!1;dampingFactor=.05;zoomSpeed=1;touchZoomSpeed=1.35;minZoom=0;maxZoom=1/0;isDragging=!1;mouseButton=-1;previousMousePosition=new j.Vector2;targetPosition=new j.Vector3;targetZoom=1;isTouchZooming=!1;previousTouchDistance=0;previousTouchCenter=new j.Vector2;lastClickTime=0;doubleClickDelay=300;constructor(e,t){super(),this.object=e,this.domElement=t||document,this.targetPosition.copy(e.position),this.targetZoom=e.zoom,this.bindEvents()}bindEvents(){this.domElement.addEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.addEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.addEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.addEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.addEventListener("wheel",this.onWheel.bind(this),{passive:!1}),this.domElement.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.addEventListener("click",this.onClick.bind(this)),this.domElement.addEventListener("touchstart",this.onTouchStart.bind(this),{passive:!1}),this.domElement.addEventListener("touchmove",this.onTouchMove.bind(this),{passive:!1}),this.domElement.addEventListener("touchend",this.onTouchEnd.bind(this)),this.domElement.addEventListener("contextmenu",e=>{e.preventDefault()})}onMouseDown(e){this.enabled&&this.enablePan&&(e.button===0||e.button===1)&&(this.isDragging=!0,this.mouseButton=e.button,this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"start"}))}onMouseMove(e){if(!this.enabled||!this.isDragging)return;const t=e.clientX-this.previousMousePosition.x,r=e.clientY-this.previousMousePosition.y,s=1/(this.targetZoom||this.object.zoom),a=this.object.top-this.object.bottom,i=this.object.right-this.object.left,l=t/this.domElement.clientWidth*i*s,c=r/this.domElement.clientHeight*a*s;this.targetPosition.x-=l,this.targetPosition.y+=c,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"change"})}onMouseUp(e){this.isDragging&&(this.isDragging=!1,this.mouseButton=-1,this.dispatchEvent({type:"end"}))}panByScreenDelta(e,t){const n=1/(this.targetZoom||this.object.zoom),s=this.object.top-this.object.bottom,a=this.object.right-this.object.left,i=e/this.domElement.clientWidth*a*n,l=t/this.domElement.clientHeight*s*n;this.targetPosition.x-=i,this.targetPosition.y+=l,this.applyImmediateIfNeeded()}zoomAroundScreenPoint(e,t,r){if(!Number.isFinite(r)||r<=0)return;const n=this.targetZoom;this.targetZoom*=r,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom));const s=this.targetZoom;if(n===s)return;const a=(this.object.right-this.object.left)/2,i=(this.object.top-this.object.bottom)/2,l=this.domElement.getBoundingClientRect(),c=(e-l.left)/l.width*2-1,p=-((t-l.top)/l.height)*2+1;this.targetPosition.x+=c*a*(1/n-1/s),this.targetPosition.y+=p*i*(1/n-1/s),this.applyImmediateIfNeeded()}applyImmediateIfNeeded(){this.enableDamping||(this.object.zoom=this.targetZoom,this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix())}onWheel(e){if(!this.enabled||!this.enableZoom)return;e.preventDefault();const t=Math.pow(1.1,-Math.sign(e.deltaY)*this.zoomSpeed),r=this.targetZoom;this.targetZoom*=t,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom));const n=this.targetZoom,s=(this.object.right-this.object.left)/2,a=(this.object.top-this.object.bottom)/2,i=this.domElement.getBoundingClientRect(),l=(e.clientX-i.left)/i.width*2-1,c=-((e.clientY-i.top)/i.height)*2+1;this.targetPosition.x+=l*s*(1/r-1/n),this.targetPosition.y+=c*a*(1/r-1/n),this.enableDamping||(this.object.zoom=n,this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}onDoubleClick(e){this.enabled&&this.dispatchEvent({type:"doubleClick",event:e})}onClick(e){const t=performance.now();t-this.lastClickTime<this.doubleClickDelay||(this.lastClickTime=t)}onTouchStart(e){if(!this.enabled||e.touches.length<1)return;if(e.preventDefault(),e.touches.length>=2){const r=e.touches[0],n=e.touches[1];this.isDragging=!1,this.isTouchZooming=!0,this.previousTouchCenter.set((r.clientX+n.clientX)*.5,(r.clientY+n.clientY)*.5),this.previousTouchDistance=Math.hypot(r.clientX-n.clientX,r.clientY-n.clientY),this.dispatchEvent({type:"start"});return}const t=e.touches[0];this.isDragging=!0,this.isTouchZooming=!1,this.previousTouchDistance=0,this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"start"})}onTouchMove(e){if(!this.enabled||!this.isDragging&&!this.isTouchZooming)return;if(e.preventDefault(),e.touches.length>=2){const b=e.touches[0],x=e.touches[1],h=(b.clientX+x.clientX)*.5,m=(b.clientY+x.clientY)*.5,d=Math.hypot(b.clientX-x.clientX,b.clientY-x.clientY);if(!this.isTouchZooming||this.previousTouchDistance<=0){this.isDragging=!1,this.isTouchZooming=!0,this.previousTouchCenter.set(h,m),this.previousTouchDistance=d;return}if(this.panByScreenDelta(h-this.previousTouchCenter.x,m-this.previousTouchCenter.y),d>0){const y=Math.pow(d/this.previousTouchDistance,this.zoomSpeed*this.touchZoomSpeed);this.zoomAroundScreenPoint(h,m,y)}this.previousTouchCenter.set(h,m),this.previousTouchDistance=d,this.dispatchEvent({type:"change"});return}if(!this.isDragging||e.touches.length!==1)return;const t=e.touches[0],r=t.clientX-this.previousMousePosition.x,n=t.clientY-this.previousMousePosition.y,a=1/this.object.zoom,i=this.object.top-this.object.bottom,l=this.object.right-this.object.left,c=r/this.domElement.clientWidth*l*a,p=n/this.domElement.clientHeight*i*a;this.targetPosition.x-=c,this.targetPosition.y+=p,this.enableDamping||this.object.position.copy(this.targetPosition),this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"change"})}onTouchEnd(e){if(e.touches.length>=2){const t=e.touches[0],r=e.touches[1];this.previousTouchCenter.set((t.clientX+r.clientX)*.5,(t.clientY+r.clientY)*.5),this.previousTouchDistance=Math.hypot(t.clientX-r.clientX,t.clientY-r.clientY);return}if(e.touches.length===1){const t=e.touches[0];this.isDragging=!0,this.isTouchZooming=!1,this.previousTouchDistance=0,this.previousMousePosition.set(t.clientX,t.clientY);return}(this.isDragging||this.isTouchZooming)&&(this.isDragging=!1,this.isTouchZooming=!1,this.previousTouchDistance=0,this.dispatchEvent({type:"end"}))}update(){if(this.enabled&&this.enableDamping){const e=1-this.dampingFactor;this.object.position.x+=(this.targetPosition.x-this.object.position.x)*e,this.object.position.y+=(this.targetPosition.y-this.object.position.y)*e,this.object.zoom+=(this.targetZoom-this.object.zoom)*e,this.object.updateProjectionMatrix()}}reset(){this.targetPosition.set(0,0,this.object.position.z),this.targetZoom=1,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"reset"})}setPosition(e,t){this.targetPosition.set(e,t,this.object.position.z),this.enableDamping||this.object.position.copy(this.targetPosition),this.dispatchEvent({type:"change"})}setZoom(e){this.targetZoom=e,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom)),this.enableDamping||(this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}dispose(){this.enabled=!1,this.domElement.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.removeEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.removeEventListener("wheel",this.onWheel.bind(this)),this.domElement.removeEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.removeEventListener("click",this.onClick.bind(this)),this.domElement.removeEventListener("touchstart",this.onTouchStart.bind(this)),this.domElement.removeEventListener("touchmove",this.onTouchMove.bind(this)),this.domElement.removeEventListener("touchend",this.onTouchEnd.bind(this))}}class Is{engine;panControls;isActive=!0;constructor(e){this.engine=e,this.panControls=this.createPanControls(),this.init()}init(){this.panControls.addEventListener("doubleClick",this.onDoubleClick.bind(this)),this.panControls.addEventListener("change",this.onChange.bind(this))}createPanControls(){const e=new _s(this.engine.camera,this.engine.renderer.domElement);return e.enableZoom=!0,e.enablePan=!0,e.enableDamping=!0,e.dampingFactor=.05,e.zoomSpeed=1,e.minZoom=0,e.maxZoom=1/0,e}onDoubleClick(e){this.engine.cameraModule2d&&this.engine.cameraModule2d.resetView()}onChange(){this.engine.events&&this.engine.events.trigger("camera-changed",{type:"user-interaction"})}active(){this.isActive=!0,this.panControls.enabled=!0}disActive(){this.isActive=!1,this.panControls.enabled=!1}update(){this.isActive&&this.panControls.update()}reset(){this.panControls.reset()}setPosition(e,t){this.panControls.setPosition(e,t)}setZoom(e){this.panControls.setZoom(e)}getZoom(){return this.panControls.object.zoom}setEnableZoom(e){this.panControls.enableZoom=e}setEnablePan(e){this.panControls.enablePan=e}setEnableDamping(e){this.panControls.enableDamping=e}setDampingFactor(e){this.panControls.dampingFactor=Math.max(0,Math.min(e,1))}setZoomSpeed(e){this.panControls.zoomSpeed=Math.max(.1,e)}setZoomLimits(e,t){this.panControls.minZoom=e,this.panControls.maxZoom=t}dispose(){this.panControls.dispose(),this.panControls=null}}class ks extends Pe.Loader{constructor(e){super(e)}load(e,t,r,n){const s=this,a=new Pe.FileLoader(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(i){const l=s.parse(JSON.parse(i));t&&t(l)},r,n)}parse(e){return new Bs(e)}}class Bs{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,r="ltr"){const n=[],s=Ms(e,t,this.data,r);for(let a=0,i=s.length;a<i;a++)n.push(...s[a].toShapes());return n}}function Ms(o,e,t,r){const n=Array.from(o),s=e/t.resolution,a=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*s,i=[];let l=0,c=0;(r=="rtl"||r=="tb")&&n.reverse();for(let p=0;p<n.length;p++){const b=n[p];if(b===`
|
|
65
|
-
`)l=0,c-=a;else{const x=Ls(b,s,l,c,t);r=="tb"?(l=0,c+=t.ascender*s):l+=x.offsetX,i.push(x.path)}}return i}function Ls(o,e,t,r,n){const s=n.glyphs[o]||n.glyphs["?"];if(!s){console.error('THREE.Font: character "'+o+'" does not exists in font family '+n.familyName+".");return}const a=new Pe.ShapePath;let i,l,c,p,b,x,h,m;if(s.o){const d=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let y=0,u=d.length;y<u;)switch(d[y++]){case"m":i=d[y++]*e+t,l=d[y++]*e+r,a.moveTo(i,l);break;case"l":i=d[y++]*e+t,l=d[y++]*e+r,a.lineTo(i,l);break;case"q":c=d[y++]*e+t,p=d[y++]*e+r,b=d[y++]*e+t,x=d[y++]*e+r,a.quadraticCurveTo(b,x,c,p);break;case"b":c=d[y++]*e+t,p=d[y++]*e+r,b=d[y++]*e+t,x=d[y++]*e+r,h=d[y++]*e+t,m=d[y++]*e+r,a.bezierCurveTo(b,x,h,m,c,p);break}}return{offsetX:s.ha*e,path:a}}class Re{static async fromUrl(e,t){const r=await fetch(e);if(!r.ok)throw new Error(`FontJsonGenerator: 无法加载 ${e} (${r.status})`);const n=await r.arrayBuffer();return Re.fromArrayBuffer(n,t)}static fromArrayBuffer(e,t){const r=os.parse(e);return Re._convert(r,t?.chars)}static toThreeFont(e){return new ks().parse(e)}static _convert(e,t){const r={},n=e.unitsPerEm,s=b=>Math.round(b),a=b=>{const x=e.charToGlyph(b);if(!x||x.index===0)return;const h=Re._commandsToTypefaceOutline(x.path.commands,s),m=x.getBoundingBox();r[b]={x_min:m.x1,x_max:m.x2,ha:x.advanceWidth??0,o:h.join(" ")}};if(t)for(const b of t)a(b);else{const b=e.tables.cmap?.glyphIndexMap??{};for(const x of Object.keys(b)){const h=Number.parseInt(x,10);h>0&&a(String.fromCodePoint(h))}}if(!r[" "]){const b=e.charToGlyph(" ");r[" "]={x_min:0,x_max:0,ha:b?.advanceWidth??Math.round(n/4),o:""}}const i=e.names,l=b=>i[b]?.en??i[b]?.zh??"",c=l("fontFamily")||"Custom Font",p=l("fontSubfamily")||"Regular";return{familyName:c,ascender:e.ascender,descender:e.descender,underlinePosition:e.tables.post?.underlinePosition??-100,underlineThickness:e.tables.post?.underlineThickness??50,boundingBox:{yMin:e.descender,xMin:0,yMax:e.ascender,xMax:n},resolution:n,original_font_information:{fontFamily:c,fontSubfamily:p},cssFontStyle:p.toLowerCase().includes("italic")?"italic":"normal",cssFontWeight:p.toLowerCase().includes("bold")?"bold":"normal",glyphs:r}}static _commandsToTypefaceOutline(e,t){const r=Re._splitContours(e),n=Re._createContourEntries(r),s=n.filter(l=>l.depth%2===0),a=n.filter(l=>l.depth%2===1),i=[];return s.sort((l,c)=>l.index-c.index).forEach(l=>{Re._appendNormalizedContour(l.contour,!0,i,t),a.filter(c=>Re._findParentSolid(c,s)===l).sort((c,p)=>c.index-p.index).forEach(c=>Re._appendNormalizedContour(c.contour,!1,i,t))}),i}static _createContourEntries(e){return e.filter(t=>t.segments.length>0).map((t,r)=>{const n=Re._samplePoint(t),s=e.reduce((a,i)=>i===t||i.points.length<3?a:Re._pointInPolygon(n,i.points)?a+1:a,0);return{contour:t,index:r,depth:s,absArea:Math.abs(Re._signedArea(t.points))}})}static _findParentSolid(e,t){const r=Re._samplePoint(e.contour);return t.filter(n=>Re._pointInPolygon(r,n.contour.points)).sort((n,s)=>n.absArea-s.absArea)[0]}static _appendNormalizedContour(e,t,r,n){const a=Re._signedArea(e.points)<0===t?e.segments:Re._reverseSegments(e.segments);Re._appendContour(a,r,n)}static _splitContours(e){const t=[];let r=null,n=null;const s=()=>{r&&r.segments.length>0&&t.push(r),r=null,n=null};return e.forEach(a=>{if(a.type==="M"){s(),n={x:a.x,y:a.y},r={segments:[],points:[n]};return}if(!r||!n)return;if(a.type==="Z"){s();return}const i={x:a.x,y:a.y};a.type==="L"?r.segments.push({type:"L",start:n,end:i}):a.type==="Q"?r.segments.push({type:"Q",start:n,end:i,x1:a.x1,y1:a.y1}):a.type==="C"&&r.segments.push({type:"C",start:n,end:i,x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2}),n=i,r.points.push(i)}),s(),t}static _appendContour(e,t,r){const n=e[0].start;t.push(`m ${r(n.x)} ${r(n.y)}`),e.forEach(s=>{s.type==="L"?t.push(`l ${r(s.end.x)} ${r(s.end.y)}`):s.type==="Q"?t.push(`q ${r(s.end.x)} ${r(s.end.y)} ${r(s.x1)} ${r(s.y1)}`):t.push(`b ${r(s.end.x)} ${r(s.end.y)} ${r(s.x1)} ${r(s.y1)} ${r(s.x2)} ${r(s.y2)}`)}),t.push("z")}static _reverseSegments(e){return e.slice().reverse().map(t=>t.type==="L"?{type:"L",start:t.end,end:t.start}:t.type==="Q"?{type:"Q",start:t.end,end:t.start,x1:t.x1,y1:t.y1}:{type:"C",start:t.end,end:t.start,x1:t.x2,y1:t.y2,x2:t.x1,y2:t.y1})}static _signedArea(e){let t=0;for(let r=0,n=e.length-1;r<e.length;n=r++)t+=e[n].x*e[r].y-e[r].x*e[n].y;return t/2}static _samplePoint(e){return e.points[0]}static _pointInPolygon(e,t){let r=!1;for(let n=0,s=t.length-1;n<t.length;s=n++){const a=t[n],i=t[s];a.y>e.y!=i.y>e.y&&e.x<(i.x-a.x)*(e.y-a.y)/(i.y-a.y)+a.x&&(r=!r)}return r}}function Ht(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var dr={exports:{}};var Ti;function Rs(){return Ti||(Ti=1,(function(o,e){(function(t){o.exports=t()})(function(){return(function t(r,n,s){function a(c,p){if(!n[c]){if(!r[c]){var b=typeof Ht=="function"&&Ht;if(!p&&b)return b(c,!0);if(i)return i(c,!0);var x=new Error("Cannot find module '"+c+"'");throw x.code="MODULE_NOT_FOUND",x}var h=n[c]={exports:{}};r[c][0].call(h.exports,function(m){var d=r[c][1][m];return a(d||m)},h,h.exports,t,r,n,s)}return n[c].exports}for(var i=typeof Ht=="function"&&Ht,l=0;l<s.length;l++)a(s[l]);return a})({1:[function(t,r,n){var s=t("./utils"),a=t("./support"),i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(l){for(var c,p,b,x,h,m,d,y=[],u=0,v=l.length,E=v,T=s.getTypeOf(l)!=="string";u<l.length;)E=v-u,b=T?(c=l[u++],p=u<v?l[u++]:0,u<v?l[u++]:0):(c=l.charCodeAt(u++),p=u<v?l.charCodeAt(u++):0,u<v?l.charCodeAt(u++):0),x=c>>2,h=(3&c)<<4|p>>4,m=1<E?(15&p)<<2|b>>6:64,d=2<E?63&b:64,y.push(i.charAt(x)+i.charAt(h)+i.charAt(m)+i.charAt(d));return y.join("")},n.decode=function(l){var c,p,b,x,h,m,d=0,y=0,u="data:";if(l.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");var v,E=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===i.charAt(64)&&E--,l.charAt(l.length-2)===i.charAt(64)&&E--,E%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=a.uint8array?new Uint8Array(0|E):new Array(0|E);d<l.length;)c=i.indexOf(l.charAt(d++))<<2|(x=i.indexOf(l.charAt(d++)))>>4,p=(15&x)<<4|(h=i.indexOf(l.charAt(d++)))>>2,b=(3&h)<<6|(m=i.indexOf(l.charAt(d++))),v[y++]=c,h!==64&&(v[y++]=p),m!==64&&(v[y++]=b);return v}},{"./support":30,"./utils":32}],2:[function(t,r,n){var s=t("./external"),a=t("./stream/DataWorker"),i=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(p,b,x,h,m){this.compressedSize=p,this.uncompressedSize=b,this.crc32=x,this.compression=h,this.compressedContent=m}c.prototype={getContentWorker:function(){var p=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),b=this;return p.on("end",function(){if(this.streamInfo.data_length!==b.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),p},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(p,b,x){return p.pipe(new i).pipe(new l("uncompressedSize")).pipe(b.compressWorker(x)).pipe(new l("compressedSize")).withStreamInfo("compression",b)},r.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,r,n){var s=t("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},n.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,r,n){var s=t("./utils"),a=(function(){for(var i,l=[],c=0;c<256;c++){i=c;for(var p=0;p<8;p++)i=1&i?3988292384^i>>>1:i>>>1;l[c]=i}return l})();r.exports=function(i,l){return i!==void 0&&i.length?s.getTypeOf(i)!=="string"?(function(c,p,b,x){var h=a,m=x+b;c^=-1;for(var d=x;d<m;d++)c=c>>>8^h[255&(c^p[d])];return-1^c})(0|l,i,i.length,0):(function(c,p,b,x){var h=a,m=x+b;c^=-1;for(var d=x;d<m;d++)c=c>>>8^h[255&(c^p.charCodeAt(d))];return-1^c})(0|l,i,i.length,0):0}},{"./utils":32}],5:[function(t,r,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(t,r,n){var s=null;s=typeof Promise<"u"?Promise:t("lie"),r.exports={Promise:s}},{lie:37}],7:[function(t,r,n){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=t("pako"),i=t("./utils"),l=t("./stream/GenericWorker"),c=s?"uint8array":"array";function p(b,x){l.call(this,"FlateWorker/"+b),this._pako=null,this._pakoAction=b,this._pakoOptions=x,this.meta={}}n.magic="\b\0",i.inherits(p,l),p.prototype.processChunk=function(b){this.meta=b.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(c,b.data),!1)},p.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},p.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},p.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var b=this;this._pako.onData=function(x){b.push({data:x,meta:b.meta})}},n.compressWorker=function(b){return new p("Deflate",b)},n.uncompressWorker=function(){return new p("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,r,n){function s(h,m){var d,y="";for(d=0;d<m;d++)y+=String.fromCharCode(255&h),h>>>=8;return y}function a(h,m,d,y,u,v){var E,T,_=h.file,w=h.compression,g=v!==c.utf8encode,f=i.transformTo("string",v(_.name)),k=i.transformTo("string",c.utf8encode(_.name)),L=_.comment,H=i.transformTo("string",v(L)),I=i.transformTo("string",c.utf8encode(L)),V=k.length!==_.name.length,A=I.length!==L.length,G="",Y="",q="",ie=_.dir,ee=_.date,le={crc32:0,compressedSize:0,uncompressedSize:0};m&&!d||(le.crc32=h.crc32,le.compressedSize=h.compressedSize,le.uncompressedSize=h.uncompressedSize);var $=0;m&&($|=8),g||!V&&!A||($|=2048);var J=0,de=0;ie&&(J|=16),u==="UNIX"?(de=798,J|=(function(te,ce){var we=te;return te||(we=ce?16893:33204),(65535&we)<<16})(_.unixPermissions,ie)):(de=20,J|=(function(te){return 63&(te||0)})(_.dosPermissions)),E=ee.getUTCHours(),E<<=6,E|=ee.getUTCMinutes(),E<<=5,E|=ee.getUTCSeconds()/2,T=ee.getUTCFullYear()-1980,T<<=4,T|=ee.getUTCMonth()+1,T<<=5,T|=ee.getUTCDate(),V&&(Y=s(1,1)+s(p(f),4)+k,G+="up"+s(Y.length,2)+Y),A&&(q=s(1,1)+s(p(H),4)+I,G+="uc"+s(q.length,2)+q);var ae="";return ae+=`
|
|
66
|
-
\0`,ae+=s($,2),ae+=w.magic,ae+=s(E,2),ae+=s(T,2),ae+=s(le.crc32,4),ae+=s(le.compressedSize,4),ae+=s(le.uncompressedSize,4),ae+=s(f.length,2),ae+=s(G.length,2),{fileRecord:b.LOCAL_FILE_HEADER+ae+f+G,dirRecord:b.CENTRAL_FILE_HEADER+s(de,2)+ae+s(H.length,2)+"\0\0\0\0"+s(J,4)+s(y,4)+f+G+H}}var i=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),p=t("../crc32"),b=t("../signature");function x(h,m,d,y){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=d,this.encodeFileName=y,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(x,l),x.prototype.push=function(h){var m=h.meta.percent||0,d=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:d?(m+100*(d-y-1))/d:100}}))},x.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var m=this.streamFiles&&!h.file.dir;if(m){var d=a(h,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:d.fileRecord,meta:{percent:0}})}else this.accumulate=!0},x.prototype.closedSource=function(h){this.accumulate=!1;var m=this.streamFiles&&!h.file.dir,d=a(h,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(d.dirRecord),m)this.push({data:(function(y){return b.DATA_DESCRIPTOR+s(y.crc32,4)+s(y.compressedSize,4)+s(y.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:d.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},x.prototype.flush=function(){for(var h=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var d=this.bytesWritten-h,y=(function(u,v,E,T,_){var w=i.transformTo("string",_(T));return b.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(u,2)+s(u,2)+s(v,4)+s(E,4)+s(w.length,2)+w})(this.dirRecords.length,d,h,this.zipComment,this.encodeFileName);this.push({data:y,meta:{percent:100}})},x.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},x.prototype.registerPrevious=function(h){this._sources.push(h);var m=this;return h.on("data",function(d){m.processChunk(d)}),h.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),h.on("error",function(d){m.error(d)}),this},x.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},x.prototype.error=function(h){var m=this._sources;if(!l.prototype.error.call(this,h))return!1;for(var d=0;d<m.length;d++)try{m[d].error(h)}catch{}return!0},x.prototype.lock=function(){l.prototype.lock.call(this);for(var h=this._sources,m=0;m<h.length;m++)h[m].lock()},r.exports=x},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,r,n){var s=t("../compressions"),a=t("./ZipFileWorker");n.generateWorker=function(i,l,c){var p=new a(l.streamFiles,c,l.platform,l.encodeFileName),b=0;try{i.forEach(function(x,h){b++;var m=(function(v,E){var T=v||E,_=s[T];if(!_)throw new Error(T+" is not a valid compression method !");return _})(h.options.compression,l.compression),d=h.options.compressionOptions||l.compressionOptions||{},y=h.dir,u=h.date;h._compressWorker(m,d).withStreamInfo("file",{name:x,dir:y,date:u,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(p)}),p.entriesCount=b}catch(x){p.error(x)}return p}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,r,n){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var i in this)typeof this[i]!="function"&&(a[i]=this[i]);return a}}(s.prototype=t("./object")).loadAsync=t("./load"),s.support=t("./support"),s.defaults=t("./defaults"),s.version="3.10.1",s.loadAsync=function(a,i){return new s().loadAsync(a,i)},s.external=t("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,r,n){var s=t("./utils"),a=t("./external"),i=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),p=t("./nodejsUtils");function b(x){return new a.Promise(function(h,m){var d=x.decompressed.getContentWorker().pipe(new c);d.on("error",function(y){m(y)}).on("end",function(){d.streamInfo.crc32!==x.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}r.exports=function(x,h){var m=this;return h=s.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:i.utf8decode}),p.isNode&&p.isStream(x)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",x,!0,h.optimizedBinaryString,h.base64).then(function(d){var y=new l(h);return y.load(d),y}).then(function(d){var y=[a.Promise.resolve(d)],u=d.files;if(h.checkCRC32)for(var v=0;v<u.length;v++)y.push(b(u[v]));return a.Promise.all(y)}).then(function(d){for(var y=d.shift(),u=y.files,v=0;v<u.length;v++){var E=u[v],T=E.fileNameStr,_=s.resolve(E.fileNameStr);m.file(_,E.decompressed,{binary:!0,optimizedBinaryString:!0,date:E.date,dir:E.dir,comment:E.fileCommentStr.length?E.fileCommentStr:null,unixPermissions:E.unixPermissions,dosPermissions:E.dosPermissions,createFolders:h.createFolders}),E.dir||(m.file(_).unsafeOriginalName=T)}return y.zipComment.length&&(m.comment=y.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,r,n){var s=t("../utils"),a=t("../stream/GenericWorker");function i(l,c){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}s.inherits(i,a),i.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(p){c.push({data:p,meta:{percent:0}})}).on("error",function(p){c.isPaused?this.generatedError=p:c.error(p)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},i.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},i.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=i},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,r,n){var s=t("readable-stream").Readable;function a(i,l,c){s.call(this,l),this._helper=i;var p=this;i.on("data",function(b,x){p.push(b)||p._helper.pause(),c&&c(x)}).on("error",function(b){p.emit("error",b)}).on("end",function(){p.push(null)})}t("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},r.exports=a},{"../utils":32,"readable-stream":16}],14:[function(t,r,n){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(t,r,n){function s(_,w,g){var f,k=i.getTypeOf(w),L=i.extend(g||{},p);L.date=L.date||new Date,L.compression!==null&&(L.compression=L.compression.toUpperCase()),typeof L.unixPermissions=="string"&&(L.unixPermissions=parseInt(L.unixPermissions,8)),L.unixPermissions&&16384&L.unixPermissions&&(L.dir=!0),L.dosPermissions&&16&L.dosPermissions&&(L.dir=!0),L.dir&&(_=u(_)),L.createFolders&&(f=y(_))&&v.call(this,f,!0);var H=k==="string"&&L.binary===!1&&L.base64===!1;g&&g.binary!==void 0||(L.binary=!H),(w instanceof b&&w.uncompressedSize===0||L.dir||!w||w.length===0)&&(L.base64=!1,L.binary=!0,w="",L.compression="STORE",k="string");var I=null;I=w instanceof b||w instanceof l?w:m.isNode&&m.isStream(w)?new d(_,w):i.prepareContent(_,w,L.binary,L.optimizedBinaryString,L.base64);var V=new x(_,I,L);this.files[_]=V}var a=t("./utf8"),i=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),p=t("./defaults"),b=t("./compressedObject"),x=t("./zipObject"),h=t("./generate"),m=t("./nodejsUtils"),d=t("./nodejs/NodejsStreamInputAdapter"),y=function(_){_.slice(-1)==="/"&&(_=_.substring(0,_.length-1));var w=_.lastIndexOf("/");return 0<w?_.substring(0,w):""},u=function(_){return _.slice(-1)!=="/"&&(_+="/"),_},v=function(_,w){return w=w!==void 0?w:p.createFolders,_=u(_),this.files[_]||s.call(this,_,null,{dir:!0,createFolders:w}),this.files[_]};function E(_){return Object.prototype.toString.call(_)==="[object RegExp]"}var T={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(_){var w,g,f;for(w in this.files)f=this.files[w],(g=w.slice(this.root.length,w.length))&&w.slice(0,this.root.length)===this.root&&_(g,f)},filter:function(_){var w=[];return this.forEach(function(g,f){_(g,f)&&w.push(f)}),w},file:function(_,w,g){if(arguments.length!==1)return _=this.root+_,s.call(this,_,w,g),this;if(E(_)){var f=_;return this.filter(function(L,H){return!H.dir&&f.test(L)})}var k=this.files[this.root+_];return k&&!k.dir?k:null},folder:function(_){if(!_)return this;if(E(_))return this.filter(function(k,L){return L.dir&&_.test(k)});var w=this.root+_,g=v.call(this,w),f=this.clone();return f.root=g.name,f},remove:function(_){_=this.root+_;var w=this.files[_];if(w||(_.slice(-1)!=="/"&&(_+="/"),w=this.files[_]),w&&!w.dir)delete this.files[_];else for(var g=this.filter(function(k,L){return L.name.slice(0,_.length)===_}),f=0;f<g.length;f++)delete this.files[g[f].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(_){var w,g={};try{if((g=i.extend(_||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=g.type.toLowerCase(),g.compression=g.compression.toUpperCase(),g.type==="binarystring"&&(g.type="string"),!g.type)throw new Error("No output type specified.");i.checkSupport(g.type),g.platform!=="darwin"&&g.platform!=="freebsd"&&g.platform!=="linux"&&g.platform!=="sunos"||(g.platform="UNIX"),g.platform==="win32"&&(g.platform="DOS");var f=g.comment||this.comment||"";w=h.generateWorker(this,g,f)}catch(k){(w=new l("error")).error(k)}return new c(w,g.type||"string",g.mimeType)},generateAsync:function(_,w){return this.generateInternalStream(_).accumulate(w)},generateNodeStream:function(_,w){return(_=_||{}).type||(_.type="nodebuffer"),this.generateInternalStream(_).toNodejsStream(w)}};r.exports=T},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(t,r,n){r.exports=t("stream")},{stream:void 0}],17:[function(t,r,n){var s=t("./DataReader");function a(i){s.call(this,i);for(var l=0;l<this.data.length;l++)i[l]=255&i[l]}t("../utils").inherits(a,s),a.prototype.byteAt=function(i){return this.data[this.zero+i]},a.prototype.lastIndexOfSignature=function(i){for(var l=i.charCodeAt(0),c=i.charCodeAt(1),p=i.charCodeAt(2),b=i.charCodeAt(3),x=this.length-4;0<=x;--x)if(this.data[x]===l&&this.data[x+1]===c&&this.data[x+2]===p&&this.data[x+3]===b)return x-this.zero;return-1},a.prototype.readAndCheckSignature=function(i){var l=i.charCodeAt(0),c=i.charCodeAt(1),p=i.charCodeAt(2),b=i.charCodeAt(3),x=this.readData(4);return l===x[0]&&c===x[1]&&p===x[2]&&b===x[3]},a.prototype.readData=function(i){if(this.checkOffset(i),i===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,l},r.exports=a},{"../utils":32,"./DataReader":18}],18:[function(t,r,n){var s=t("../utils");function a(i){this.data=i,this.length=i.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(i){this.checkIndex(this.index+i)},checkIndex:function(i){if(this.length<this.zero+i||i<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+i+"). Corrupted zip ?")},setIndex:function(i){this.checkIndex(i),this.index=i},skip:function(i){this.setIndex(this.index+i)},byteAt:function(){},readInt:function(i){var l,c=0;for(this.checkOffset(i),l=this.index+i-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=i,c},readString:function(i){return s.transformTo("string",this.readData(i))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},r.exports=a},{"../utils":32}],19:[function(t,r,n){var s=t("./Uint8ArrayReader");function a(i){s.call(this,i)}t("../utils").inherits(a,s),a.prototype.readData=function(i){this.checkOffset(i);var l=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,l},r.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,r,n){var s=t("./DataReader");function a(i){s.call(this,i)}t("../utils").inherits(a,s),a.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},a.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},a.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},a.prototype.readData=function(i){this.checkOffset(i);var l=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,l},r.exports=a},{"../utils":32,"./DataReader":18}],21:[function(t,r,n){var s=t("./ArrayReader");function a(i){s.call(this,i)}t("../utils").inherits(a,s),a.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,l},r.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(t,r,n){var s=t("../utils"),a=t("../support"),i=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),p=t("./Uint8ArrayReader");r.exports=function(b){var x=s.getTypeOf(b);return s.checkSupport(x),x!=="string"||a.uint8array?x==="nodebuffer"?new c(b):a.uint8array?new p(s.transformTo("uint8array",b)):new i(s.transformTo("array",b)):new l(b)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,r,n){n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,r,n){var s=t("./GenericWorker"),a=t("../utils");function i(l){s.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(i,s),i.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},r.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(t,r,n){var s=t("./GenericWorker"),a=t("../crc32");function i(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(i,s),i.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,r,n){var s=t("../utils"),a=t("./GenericWorker");function i(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(i,a),i.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}a.prototype.processChunk.call(this,l)},r.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(t,r,n){var s=t("../utils"),a=t("./GenericWorker");function i(l){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(p){c.dataIsReady=!0,c.data=p,c.max=p&&p.length||0,c.type=s.getTypeOf(p),c.isPaused||c._tickAndRepeat()},function(p){c.error(p)})}s.inherits(i,a),i.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(t,r,n){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,i){return this._listeners[a].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,i){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,i)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var i=this;return a.on("data",function(l){i.processChunk(l)}),a.on("end",function(){i.end()}),a.on("error",function(l){i.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,i){return this.extraStreamInfo[a]=i,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},r.exports=s},{}],29:[function(t,r,n){var s=t("../utils"),a=t("./ConvertWorker"),i=t("./GenericWorker"),l=t("../base64"),c=t("../support"),p=t("../external"),b=null;if(c.nodestream)try{b=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function x(m,d){return new p.Promise(function(y,u){var v=[],E=m._internalType,T=m._outputType,_=m._mimeType;m.on("data",function(w,g){v.push(w),d&&d(g)}).on("error",function(w){v=[],u(w)}).on("end",function(){try{var w=(function(g,f,k){switch(g){case"blob":return s.newBlob(s.transformTo("arraybuffer",f),k);case"base64":return l.encode(f);default:return s.transformTo(g,f)}})(T,(function(g,f){var k,L=0,H=null,I=0;for(k=0;k<f.length;k++)I+=f[k].length;switch(g){case"string":return f.join("");case"array":return Array.prototype.concat.apply([],f);case"uint8array":for(H=new Uint8Array(I),k=0;k<f.length;k++)H.set(f[k],L),L+=f[k].length;return H;case"nodebuffer":return Buffer.concat(f);default:throw new Error("concat : unsupported type '"+g+"'")}})(E,v),_);y(w)}catch(g){u(g)}v=[]}).resume()})}function h(m,d,y){var u=d;switch(d){case"blob":case"arraybuffer":u="uint8array";break;case"base64":u="string"}try{this._internalType=u,this._outputType=d,this._mimeType=y,s.checkSupport(u),this._worker=m.pipe(new a(u)),m.lock()}catch(v){this._worker=new i("error"),this._worker.error(v)}}h.prototype={accumulate:function(m){return x(this,m)},on:function(m,d){var y=this;return m==="data"?this._worker.on(m,function(u){d.call(y,u.data,u.meta)}):this._worker.on(m,function(){s.delay(d,arguments,y)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new b(this,{objectMode:this._outputType!=="nodebuffer"},m)}},r.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,r,n){if(n.base64=!0,n.array=!0,n.string=!0,n.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",n.nodebuffer=typeof Buffer<"u",n.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")n.blob=!1;else{var s=new ArrayBuffer(0);try{n.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),n.blob=a.getBlob("application/zip").size===0}catch{n.blob=!1}}}try{n.nodestream=!!t("readable-stream").Readable}catch{n.nodestream=!1}},{"readable-stream":16}],31:[function(t,r,n){for(var s=t("./utils"),a=t("./support"),i=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),p=0;p<256;p++)c[p]=252<=p?6:248<=p?5:240<=p?4:224<=p?3:192<=p?2:1;c[254]=c[254]=1;function b(){l.call(this,"utf-8 decode"),this.leftOver=null}function x(){l.call(this,"utf-8 encode")}n.utf8encode=function(h){return a.nodebuffer?i.newBufferFrom(h,"utf-8"):(function(m){var d,y,u,v,E,T=m.length,_=0;for(v=0;v<T;v++)(64512&(y=m.charCodeAt(v)))==55296&&v+1<T&&(64512&(u=m.charCodeAt(v+1)))==56320&&(y=65536+(y-55296<<10)+(u-56320),v++),_+=y<128?1:y<2048?2:y<65536?3:4;for(d=a.uint8array?new Uint8Array(_):new Array(_),v=E=0;E<_;v++)(64512&(y=m.charCodeAt(v)))==55296&&v+1<T&&(64512&(u=m.charCodeAt(v+1)))==56320&&(y=65536+(y-55296<<10)+(u-56320),v++),y<128?d[E++]=y:(y<2048?d[E++]=192|y>>>6:(y<65536?d[E++]=224|y>>>12:(d[E++]=240|y>>>18,d[E++]=128|y>>>12&63),d[E++]=128|y>>>6&63),d[E++]=128|63&y);return d})(h)},n.utf8decode=function(h){return a.nodebuffer?s.transformTo("nodebuffer",h).toString("utf-8"):(function(m){var d,y,u,v,E=m.length,T=new Array(2*E);for(d=y=0;d<E;)if((u=m[d++])<128)T[y++]=u;else if(4<(v=c[u]))T[y++]=65533,d+=v-1;else{for(u&=v===2?31:v===3?15:7;1<v&&d<E;)u=u<<6|63&m[d++],v--;1<v?T[y++]=65533:u<65536?T[y++]=u:(u-=65536,T[y++]=55296|u>>10&1023,T[y++]=56320|1023&u)}return T.length!==y&&(T.subarray?T=T.subarray(0,y):T.length=y),s.applyFromCharCode(T)})(h=s.transformTo(a.uint8array?"uint8array":"array",h))},s.inherits(b,l),b.prototype.processChunk=function(h){var m=s.transformTo(a.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var d=m;(m=new Uint8Array(d.length+this.leftOver.length)).set(this.leftOver,0),m.set(d,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var y=(function(v,E){var T;for((E=E||v.length)>v.length&&(E=v.length),T=E-1;0<=T&&(192&v[T])==128;)T--;return T<0||T===0?E:T+c[v[T]]>E?T:E})(m),u=m;y!==m.length&&(a.uint8array?(u=m.subarray(0,y),this.leftOver=m.subarray(y,m.length)):(u=m.slice(0,y),this.leftOver=m.slice(y,m.length))),this.push({data:n.utf8decode(u),meta:h.meta})},b.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=b,s.inherits(x,l),x.prototype.processChunk=function(h){this.push({data:n.utf8encode(h.data),meta:h.meta})},n.Utf8EncodeWorker=x},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,r,n){var s=t("./support"),a=t("./base64"),i=t("./nodejsUtils"),l=t("./external");function c(d){return d}function p(d,y){for(var u=0;u<d.length;++u)y[u]=255&d.charCodeAt(u);return y}t("setimmediate"),n.newBlob=function(d,y){n.checkSupport("blob");try{return new Blob([d],{type:y})}catch{try{var u=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return u.append(d),u.getBlob(y)}catch{throw new Error("Bug : can't construct the Blob.")}}};var b={stringifyByChunk:function(d,y,u){var v=[],E=0,T=d.length;if(T<=u)return String.fromCharCode.apply(null,d);for(;E<T;)y==="array"||y==="nodebuffer"?v.push(String.fromCharCode.apply(null,d.slice(E,Math.min(E+u,T)))):v.push(String.fromCharCode.apply(null,d.subarray(E,Math.min(E+u,T)))),E+=u;return v.join("")},stringifyByChar:function(d){for(var y="",u=0;u<d.length;u++)y+=String.fromCharCode(d[u]);return y},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,i.allocBuffer(1)).length===1}catch{return!1}})()}};function x(d){var y=65536,u=n.getTypeOf(d),v=!0;if(u==="uint8array"?v=b.applyCanBeUsed.uint8array:u==="nodebuffer"&&(v=b.applyCanBeUsed.nodebuffer),v)for(;1<y;)try{return b.stringifyByChunk(d,u,y)}catch{y=Math.floor(y/2)}return b.stringifyByChar(d)}function h(d,y){for(var u=0;u<d.length;u++)y[u]=d[u];return y}n.applyFromCharCode=x;var m={};m.string={string:c,array:function(d){return p(d,new Array(d.length))},arraybuffer:function(d){return m.string.uint8array(d).buffer},uint8array:function(d){return p(d,new Uint8Array(d.length))},nodebuffer:function(d){return p(d,i.allocBuffer(d.length))}},m.array={string:x,array:c,arraybuffer:function(d){return new Uint8Array(d).buffer},uint8array:function(d){return new Uint8Array(d)},nodebuffer:function(d){return i.newBufferFrom(d)}},m.arraybuffer={string:function(d){return x(new Uint8Array(d))},array:function(d){return h(new Uint8Array(d),new Array(d.byteLength))},arraybuffer:c,uint8array:function(d){return new Uint8Array(d)},nodebuffer:function(d){return i.newBufferFrom(new Uint8Array(d))}},m.uint8array={string:x,array:function(d){return h(d,new Array(d.length))},arraybuffer:function(d){return d.buffer},uint8array:c,nodebuffer:function(d){return i.newBufferFrom(d)}},m.nodebuffer={string:x,array:function(d){return h(d,new Array(d.length))},arraybuffer:function(d){return m.nodebuffer.uint8array(d).buffer},uint8array:function(d){return h(d,new Uint8Array(d.length))},nodebuffer:c},n.transformTo=function(d,y){if(y=y||"",!d)return y;n.checkSupport(d);var u=n.getTypeOf(y);return m[u][d](y)},n.resolve=function(d){for(var y=d.split("/"),u=[],v=0;v<y.length;v++){var E=y[v];E==="."||E===""&&v!==0&&v!==y.length-1||(E===".."?u.pop():u.push(E))}return u.join("/")},n.getTypeOf=function(d){return typeof d=="string"?"string":Object.prototype.toString.call(d)==="[object Array]"?"array":s.nodebuffer&&i.isBuffer(d)?"nodebuffer":s.uint8array&&d instanceof Uint8Array?"uint8array":s.arraybuffer&&d instanceof ArrayBuffer?"arraybuffer":void 0},n.checkSupport=function(d){if(!s[d.toLowerCase()])throw new Error(d+" is not supported by this platform")},n.MAX_VALUE_16BITS=65535,n.MAX_VALUE_32BITS=-1,n.pretty=function(d){var y,u,v="";for(u=0;u<(d||"").length;u++)v+="\\x"+((y=d.charCodeAt(u))<16?"0":"")+y.toString(16).toUpperCase();return v},n.delay=function(d,y,u){setImmediate(function(){d.apply(u||null,y||[])})},n.inherits=function(d,y){function u(){}u.prototype=y.prototype,d.prototype=new u},n.extend=function(){var d,y,u={};for(d=0;d<arguments.length;d++)for(y in arguments[d])Object.prototype.hasOwnProperty.call(arguments[d],y)&&u[y]===void 0&&(u[y]=arguments[d][y]);return u},n.prepareContent=function(d,y,u,v,E){return l.Promise.resolve(y).then(function(T){return s.blob&&(T instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(T))!==-1)&&typeof FileReader<"u"?new l.Promise(function(_,w){var g=new FileReader;g.onload=function(f){_(f.target.result)},g.onerror=function(f){w(f.target.error)},g.readAsArrayBuffer(T)}):T}).then(function(T){var _=n.getTypeOf(T);return _?(_==="arraybuffer"?T=n.transformTo("uint8array",T):_==="string"&&(E?T=a.decode(T):u&&v!==!0&&(T=(function(w){return p(w,s.uint8array?new Uint8Array(w.length):new Array(w.length))})(T))),T):l.Promise.reject(new Error("Can't read the data of '"+d+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,r,n){var s=t("./reader/readerFor"),a=t("./utils"),i=t("./signature"),l=t("./zipEntry"),c=t("./support");function p(b){this.files=[],this.loadOptions=b}p.prototype={checkSignature:function(b){if(!this.reader.readAndCheckSignature(b)){this.reader.index-=4;var x=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(x)+", expected "+a.pretty(b)+")")}},isSignature:function(b,x){var h=this.reader.index;this.reader.setIndex(b);var m=this.reader.readString(4)===x;return this.reader.setIndex(h),m},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var b=this.reader.readData(this.zipCommentLength),x=c.uint8array?"uint8array":"array",h=a.transformTo(x,b);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var b,x,h,m=this.zip64EndOfCentralSize-44;0<m;)b=this.reader.readInt(2),x=this.reader.readInt(4),h=this.reader.readData(x),this.zip64ExtensibleData[b]={id:b,length:x,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var b,x;for(b=0;b<this.files.length;b++)x=this.files[b],this.reader.setIndex(x.localHeaderOffset),this.checkSignature(i.LOCAL_FILE_HEADER),x.readLocalPart(this.reader),x.handleUTF8(),x.processAttributes()},readCentralDir:function(){var b;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(i.CENTRAL_FILE_HEADER);)(b=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(b);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var b=this.reader.lastIndexOfSignature(i.CENTRAL_DIRECTORY_END);if(b<0)throw this.isSignature(0,i.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(b);var x=b;if(this.checkSignature(i.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(b=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(b),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,i.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var m=x-h;if(0<m)this.isSignature(x,i.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(b){this.reader=s(b)},load:function(b){this.prepareReader(b),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=p},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,r,n){var s=t("./reader/readerFor"),a=t("./utils"),i=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),p=t("./compressions"),b=t("./support");function x(h,m){this.options=h,this.loadOptions=m}x.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var m,d;if(h.skip(22),this.fileNameLength=h.readInt(2),d=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(d),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((m=(function(y){for(var u in p)if(Object.prototype.hasOwnProperty.call(p,u)&&p[u].magic===y)return p[u];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new i(this.compressedSize,this.uncompressedSize,this.crc32,m,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var m=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(m),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var m,d,y,u=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<u;)m=h.readInt(2),d=h.readInt(2),y=h.readData(d),this.extraFields[m]={id:m,length:d,value:y};h.setIndex(u)},handleUTF8:function(){var h=b.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var d=a.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(d)}var y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var u=a.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(u)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var m=s(h.value);return m.readInt(1)!==1||l(this.fileName)!==m.readInt(4)?null:c.utf8decode(m.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var m=s(h.value);return m.readInt(1)!==1||l(this.fileComment)!==m.readInt(4)?null:c.utf8decode(m.readData(h.length-5))}return null}},r.exports=x},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,r,n){function s(m,d,y){this.name=m,this.dir=y.dir,this.date=y.date,this.comment=y.comment,this.unixPermissions=y.unixPermissions,this.dosPermissions=y.dosPermissions,this._data=d,this._dataBinary=y.binary,this.options={compression:y.compression,compressionOptions:y.compressionOptions}}var a=t("./stream/StreamHelper"),i=t("./stream/DataWorker"),l=t("./utf8"),c=t("./compressedObject"),p=t("./stream/GenericWorker");s.prototype={internalStream:function(m){var d=null,y="string";try{if(!m)throw new Error("No output type specified.");var u=(y=m.toLowerCase())==="string"||y==="text";y!=="binarystring"&&y!=="text"||(y="string"),d=this._decompressWorker();var v=!this._dataBinary;v&&!u&&(d=d.pipe(new l.Utf8EncodeWorker)),!v&&u&&(d=d.pipe(new l.Utf8DecodeWorker))}catch(E){(d=new p("error")).error(E)}return new a(d,y,"")},async:function(m,d){return this.internalStream(m).accumulate(d)},nodeStream:function(m,d){return this.internalStream(m||"nodebuffer").toNodejsStream(d)},_compressWorker:function(m,d){if(this._data instanceof c&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var y=this._decompressWorker();return this._dataBinary||(y=y.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(y,m,d)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof p?this._data:new i(this._data)}};for(var b=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],x=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<b.length;h++)s.prototype[b[h]]=x;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,r,n){(function(s){var a,i,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var c=0,p=new l(m),b=s.document.createTextNode("");p.observe(b,{characterData:!0}),a=function(){b.data=c=++c%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var d=s.document.createElement("script");d.onreadystatechange=function(){m(),d.onreadystatechange=null,d.parentNode.removeChild(d),d=null},s.document.documentElement.appendChild(d)}:function(){setTimeout(m,0)};else{var x=new s.MessageChannel;x.port1.onmessage=m,a=function(){x.port2.postMessage(0)}}var h=[];function m(){var d,y;i=!0;for(var u=h.length;u;){for(y=h,h=[],d=-1;++d<u;)y[d]();u=h.length}i=!1}r.exports=function(d){h.push(d)!==1||i||a()}}).call(this,typeof kt<"u"?kt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,r,n){var s=t("immediate");function a(){}var i={},l=["REJECTED"],c=["FULFILLED"],p=["PENDING"];function b(u){if(typeof u!="function")throw new TypeError("resolver must be a function");this.state=p,this.queue=[],this.outcome=void 0,u!==a&&d(this,u)}function x(u,v,E){this.promise=u,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}function h(u,v,E){s(function(){var T;try{T=v(E)}catch(_){return i.reject(u,_)}T===u?i.reject(u,new TypeError("Cannot resolve promise with itself")):i.resolve(u,T)})}function m(u){var v=u&&u.then;if(u&&(typeof u=="object"||typeof u=="function")&&typeof v=="function")return function(){v.apply(u,arguments)}}function d(u,v){var E=!1;function T(g){E||(E=!0,i.reject(u,g))}function _(g){E||(E=!0,i.resolve(u,g))}var w=y(function(){v(_,T)});w.status==="error"&&T(w.value)}function y(u,v){var E={};try{E.value=u(v),E.status="success"}catch(T){E.status="error",E.value=T}return E}(r.exports=b).prototype.finally=function(u){if(typeof u!="function")return this;var v=this.constructor;return this.then(function(E){return v.resolve(u()).then(function(){return E})},function(E){return v.resolve(u()).then(function(){throw E})})},b.prototype.catch=function(u){return this.then(null,u)},b.prototype.then=function(u,v){if(typeof u!="function"&&this.state===c||typeof v!="function"&&this.state===l)return this;var E=new this.constructor(a);return this.state!==p?h(E,this.state===c?u:v,this.outcome):this.queue.push(new x(E,u,v)),E},x.prototype.callFulfilled=function(u){i.resolve(this.promise,u)},x.prototype.otherCallFulfilled=function(u){h(this.promise,this.onFulfilled,u)},x.prototype.callRejected=function(u){i.reject(this.promise,u)},x.prototype.otherCallRejected=function(u){h(this.promise,this.onRejected,u)},i.resolve=function(u,v){var E=y(m,v);if(E.status==="error")return i.reject(u,E.value);var T=E.value;if(T)d(u,T);else{u.state=c,u.outcome=v;for(var _=-1,w=u.queue.length;++_<w;)u.queue[_].callFulfilled(v)}return u},i.reject=function(u,v){u.state=l,u.outcome=v;for(var E=-1,T=u.queue.length;++E<T;)u.queue[E].callRejected(v);return u},b.resolve=function(u){return u instanceof this?u:i.resolve(new this(a),u)},b.reject=function(u){var v=new this(a);return i.reject(v,u)},b.all=function(u){var v=this;if(Object.prototype.toString.call(u)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=u.length,T=!1;if(!E)return this.resolve([]);for(var _=new Array(E),w=0,g=-1,f=new this(a);++g<E;)k(u[g],g);return f;function k(L,H){v.resolve(L).then(function(I){_[H]=I,++w!==E||T||(T=!0,i.resolve(f,_))},function(I){T||(T=!0,i.reject(f,I))})}},b.race=function(u){var v=this;if(Object.prototype.toString.call(u)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=u.length,T=!1;if(!E)return this.resolve([]);for(var _=-1,w=new this(a);++_<E;)g=u[_],v.resolve(g).then(function(f){T||(T=!0,i.resolve(w,f))},function(f){T||(T=!0,i.reject(w,f))});var g;return w}},{immediate:36}],38:[function(t,r,n){var s={};(0,t("./lib/utils/common").assign)(s,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,r,n){var s=t("./zlib/deflate"),a=t("./utils/common"),i=t("./utils/strings"),l=t("./zlib/messages"),c=t("./zlib/zstream"),p=Object.prototype.toString,b=0,x=-1,h=0,m=8;function d(u){if(!(this instanceof d))return new d(u);this.options=a.assign({level:x,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},u||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var E=s.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(E!==b)throw new Error(l[E]);if(v.header&&s.deflateSetHeader(this.strm,v.header),v.dictionary){var T;if(T=typeof v.dictionary=="string"?i.string2buf(v.dictionary):p.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(E=s.deflateSetDictionary(this.strm,T))!==b)throw new Error(l[E]);this._dict_set=!0}}function y(u,v){var E=new d(v);if(E.push(u,!0),E.err)throw E.msg||l[E.err];return E.result}d.prototype.push=function(u,v){var E,T,_=this.strm,w=this.options.chunkSize;if(this.ended)return!1;T=v===~~v?v:v===!0?4:0,typeof u=="string"?_.input=i.string2buf(u):p.call(u)==="[object ArrayBuffer]"?_.input=new Uint8Array(u):_.input=u,_.next_in=0,_.avail_in=_.input.length;do{if(_.avail_out===0&&(_.output=new a.Buf8(w),_.next_out=0,_.avail_out=w),(E=s.deflate(_,T))!==1&&E!==b)return this.onEnd(E),!(this.ended=!0);_.avail_out!==0&&(_.avail_in!==0||T!==4&&T!==2)||(this.options.to==="string"?this.onData(i.buf2binstring(a.shrinkBuf(_.output,_.next_out))):this.onData(a.shrinkBuf(_.output,_.next_out)))}while((0<_.avail_in||_.avail_out===0)&&E!==1);return T===4?(E=s.deflateEnd(this.strm),this.onEnd(E),this.ended=!0,E===b):T!==2||(this.onEnd(b),!(_.avail_out=0))},d.prototype.onData=function(u){this.chunks.push(u)},d.prototype.onEnd=function(u){u===b&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=u,this.msg=this.strm.msg},n.Deflate=d,n.deflate=y,n.deflateRaw=function(u,v){return(v=v||{}).raw=!0,y(u,v)},n.gzip=function(u,v){return(v=v||{}).gzip=!0,y(u,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,r,n){var s=t("./zlib/inflate"),a=t("./utils/common"),i=t("./utils/strings"),l=t("./zlib/constants"),c=t("./zlib/messages"),p=t("./zlib/zstream"),b=t("./zlib/gzheader"),x=Object.prototype.toString;function h(d){if(!(this instanceof h))return new h(d);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},d||{});var y=this.options;y.raw&&0<=y.windowBits&&y.windowBits<16&&(y.windowBits=-y.windowBits,y.windowBits===0&&(y.windowBits=-15)),!(0<=y.windowBits&&y.windowBits<16)||d&&d.windowBits||(y.windowBits+=32),15<y.windowBits&&y.windowBits<48&&(15&y.windowBits)==0&&(y.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new p,this.strm.avail_out=0;var u=s.inflateInit2(this.strm,y.windowBits);if(u!==l.Z_OK)throw new Error(c[u]);this.header=new b,s.inflateGetHeader(this.strm,this.header)}function m(d,y){var u=new h(y);if(u.push(d,!0),u.err)throw u.msg||c[u.err];return u.result}h.prototype.push=function(d,y){var u,v,E,T,_,w,g=this.strm,f=this.options.chunkSize,k=this.options.dictionary,L=!1;if(this.ended)return!1;v=y===~~y?y:y===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof d=="string"?g.input=i.binstring2buf(d):x.call(d)==="[object ArrayBuffer]"?g.input=new Uint8Array(d):g.input=d,g.next_in=0,g.avail_in=g.input.length;do{if(g.avail_out===0&&(g.output=new a.Buf8(f),g.next_out=0,g.avail_out=f),(u=s.inflate(g,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&k&&(w=typeof k=="string"?i.string2buf(k):x.call(k)==="[object ArrayBuffer]"?new Uint8Array(k):k,u=s.inflateSetDictionary(this.strm,w)),u===l.Z_BUF_ERROR&&L===!0&&(u=l.Z_OK,L=!1),u!==l.Z_STREAM_END&&u!==l.Z_OK)return this.onEnd(u),!(this.ended=!0);g.next_out&&(g.avail_out!==0&&u!==l.Z_STREAM_END&&(g.avail_in!==0||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(E=i.utf8border(g.output,g.next_out),T=g.next_out-E,_=i.buf2string(g.output,E),g.next_out=T,g.avail_out=f-T,T&&a.arraySet(g.output,g.output,E,T,0),this.onData(_)):this.onData(a.shrinkBuf(g.output,g.next_out)))),g.avail_in===0&&g.avail_out===0&&(L=!0)}while((0<g.avail_in||g.avail_out===0)&&u!==l.Z_STREAM_END);return u===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(u=s.inflateEnd(this.strm),this.onEnd(u),this.ended=!0,u===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(g.avail_out=0))},h.prototype.onData=function(d){this.chunks.push(d)},h.prototype.onEnd=function(d){d===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=d,this.msg=this.strm.msg},n.Inflate=h,n.inflate=m,n.inflateRaw=function(d,y){return(y=y||{}).raw=!0,m(d,y)},n.ungzip=m},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,r,n){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";n.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var p=c.shift();if(p){if(typeof p!="object")throw new TypeError(p+"must be non-object");for(var b in p)p.hasOwnProperty(b)&&(l[b]=p[b])}}return l},n.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var a={arraySet:function(l,c,p,b,x){if(c.subarray&&l.subarray)l.set(c.subarray(p,p+b),x);else for(var h=0;h<b;h++)l[x+h]=c[p+h]},flattenChunks:function(l){var c,p,b,x,h,m;for(c=b=0,p=l.length;c<p;c++)b+=l[c].length;for(m=new Uint8Array(b),c=x=0,p=l.length;c<p;c++)h=l[c],m.set(h,x),x+=h.length;return m}},i={arraySet:function(l,c,p,b,x){for(var h=0;h<b;h++)l[x+h]=c[p+h]},flattenChunks:function(l){return[].concat.apply([],l)}};n.setTyped=function(l){l?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,a)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,i))},n.setTyped(s)},{}],42:[function(t,r,n){var s=t("./common"),a=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{i=!1}for(var l=new s.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function p(b,x){if(x<65537&&(b.subarray&&i||!b.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(b,x));for(var h="",m=0;m<x;m++)h+=String.fromCharCode(b[m]);return h}l[254]=l[254]=1,n.string2buf=function(b){var x,h,m,d,y,u=b.length,v=0;for(d=0;d<u;d++)(64512&(h=b.charCodeAt(d)))==55296&&d+1<u&&(64512&(m=b.charCodeAt(d+1)))==56320&&(h=65536+(h-55296<<10)+(m-56320),d++),v+=h<128?1:h<2048?2:h<65536?3:4;for(x=new s.Buf8(v),d=y=0;y<v;d++)(64512&(h=b.charCodeAt(d)))==55296&&d+1<u&&(64512&(m=b.charCodeAt(d+1)))==56320&&(h=65536+(h-55296<<10)+(m-56320),d++),h<128?x[y++]=h:(h<2048?x[y++]=192|h>>>6:(h<65536?x[y++]=224|h>>>12:(x[y++]=240|h>>>18,x[y++]=128|h>>>12&63),x[y++]=128|h>>>6&63),x[y++]=128|63&h);return x},n.buf2binstring=function(b){return p(b,b.length)},n.binstring2buf=function(b){for(var x=new s.Buf8(b.length),h=0,m=x.length;h<m;h++)x[h]=b.charCodeAt(h);return x},n.buf2string=function(b,x){var h,m,d,y,u=x||b.length,v=new Array(2*u);for(h=m=0;h<u;)if((d=b[h++])<128)v[m++]=d;else if(4<(y=l[d]))v[m++]=65533,h+=y-1;else{for(d&=y===2?31:y===3?15:7;1<y&&h<u;)d=d<<6|63&b[h++],y--;1<y?v[m++]=65533:d<65536?v[m++]=d:(d-=65536,v[m++]=55296|d>>10&1023,v[m++]=56320|1023&d)}return p(v,m)},n.utf8border=function(b,x){var h;for((x=x||b.length)>b.length&&(x=b.length),h=x-1;0<=h&&(192&b[h])==128;)h--;return h<0||h===0?x:h+l[b[h]]>x?h:x}},{"./common":41}],43:[function(t,r,n){r.exports=function(s,a,i,l){for(var c=65535&s|0,p=s>>>16&65535|0,b=0;i!==0;){for(i-=b=2e3<i?2e3:i;p=p+(c=c+a[l++]|0)|0,--b;);c%=65521,p%=65521}return c|p<<16|0}},{}],44:[function(t,r,n){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,r,n){var s=(function(){for(var a,i=[],l=0;l<256;l++){a=l;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;i[l]=a}return i})();r.exports=function(a,i,l,c){var p=s,b=c+l;a^=-1;for(var x=c;x<b;x++)a=a>>>8^p[255&(a^i[x])];return-1^a}},{}],46:[function(t,r,n){var s,a=t("../utils/common"),i=t("./trees"),l=t("./adler32"),c=t("./crc32"),p=t("./messages"),b=0,x=4,h=0,m=-2,d=-1,y=4,u=2,v=8,E=9,T=286,_=30,w=19,g=2*T+1,f=15,k=3,L=258,H=L+k+1,I=42,V=113,A=1,G=2,Y=3,q=4;function ie(C,R){return C.msg=p[R],R}function ee(C){return(C<<1)-(4<C?9:0)}function le(C){for(var R=C.length;0<=--R;)C[R]=0}function $(C){var R=C.state,W=R.pending;W>C.avail_out&&(W=C.avail_out),W!==0&&(a.arraySet(C.output,R.pending_buf,R.pending_out,W,C.next_out),C.next_out+=W,R.pending_out+=W,C.total_out+=W,C.avail_out-=W,R.pending-=W,R.pending===0&&(R.pending_out=0))}function J(C,R){i._tr_flush_block(C,0<=C.block_start?C.block_start:-1,C.strstart-C.block_start,R),C.block_start=C.strstart,$(C.strm)}function de(C,R){C.pending_buf[C.pending++]=R}function ae(C,R){C.pending_buf[C.pending++]=R>>>8&255,C.pending_buf[C.pending++]=255&R}function te(C,R){var W,F,O=C.max_chain_length,z=C.strstart,Q=C.prev_length,re=C.nice_match,Z=C.strstart>C.w_size-H?C.strstart-(C.w_size-H):0,ne=C.window,he=C.w_mask,oe=C.prev,pe=C.strstart+L,ve=ne[z+Q-1],me=ne[z+Q];C.prev_length>=C.good_match&&(O>>=2),re>C.lookahead&&(re=C.lookahead);do if(ne[(W=R)+Q]===me&&ne[W+Q-1]===ve&&ne[W]===ne[z]&&ne[++W]===ne[z+1]){z+=2,W++;do;while(ne[++z]===ne[++W]&&ne[++z]===ne[++W]&&ne[++z]===ne[++W]&&ne[++z]===ne[++W]&&ne[++z]===ne[++W]&&ne[++z]===ne[++W]&&ne[++z]===ne[++W]&&ne[++z]===ne[++W]&&z<pe);if(F=L-(pe-z),z=pe-L,Q<F){if(C.match_start=R,re<=(Q=F))break;ve=ne[z+Q-1],me=ne[z+Q]}}while((R=oe[R&he])>Z&&--O!=0);return Q<=C.lookahead?Q:C.lookahead}function ce(C){var R,W,F,O,z,Q,re,Z,ne,he,oe=C.w_size;do{if(O=C.window_size-C.lookahead-C.strstart,C.strstart>=oe+(oe-H)){for(a.arraySet(C.window,C.window,oe,oe,0),C.match_start-=oe,C.strstart-=oe,C.block_start-=oe,R=W=C.hash_size;F=C.head[--R],C.head[R]=oe<=F?F-oe:0,--W;);for(R=W=oe;F=C.prev[--R],C.prev[R]=oe<=F?F-oe:0,--W;);O+=oe}if(C.strm.avail_in===0)break;if(Q=C.strm,re=C.window,Z=C.strstart+C.lookahead,ne=O,he=void 0,he=Q.avail_in,ne<he&&(he=ne),W=he===0?0:(Q.avail_in-=he,a.arraySet(re,Q.input,Q.next_in,he,Z),Q.state.wrap===1?Q.adler=l(Q.adler,re,he,Z):Q.state.wrap===2&&(Q.adler=c(Q.adler,re,he,Z)),Q.next_in+=he,Q.total_in+=he,he),C.lookahead+=W,C.lookahead+C.insert>=k)for(z=C.strstart-C.insert,C.ins_h=C.window[z],C.ins_h=(C.ins_h<<C.hash_shift^C.window[z+1])&C.hash_mask;C.insert&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[z+k-1])&C.hash_mask,C.prev[z&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=z,z++,C.insert--,!(C.lookahead+C.insert<k)););}while(C.lookahead<H&&C.strm.avail_in!==0)}function we(C,R){for(var W,F;;){if(C.lookahead<H){if(ce(C),C.lookahead<H&&R===b)return A;if(C.lookahead===0)break}if(W=0,C.lookahead>=k&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+k-1])&C.hash_mask,W=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),W!==0&&C.strstart-W<=C.w_size-H&&(C.match_length=te(C,W)),C.match_length>=k)if(F=i._tr_tally(C,C.strstart-C.match_start,C.match_length-k),C.lookahead-=C.match_length,C.match_length<=C.max_lazy_match&&C.lookahead>=k){for(C.match_length--;C.strstart++,C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+k-1])&C.hash_mask,W=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart,--C.match_length!=0;);C.strstart++}else C.strstart+=C.match_length,C.match_length=0,C.ins_h=C.window[C.strstart],C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+1])&C.hash_mask;else F=i._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++;if(F&&(J(C,!1),C.strm.avail_out===0))return A}return C.insert=C.strstart<k-1?C.strstart:k-1,R===x?(J(C,!0),C.strm.avail_out===0?Y:q):C.last_lit&&(J(C,!1),C.strm.avail_out===0)?A:G}function ye(C,R){for(var W,F,O;;){if(C.lookahead<H){if(ce(C),C.lookahead<H&&R===b)return A;if(C.lookahead===0)break}if(W=0,C.lookahead>=k&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+k-1])&C.hash_mask,W=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),C.prev_length=C.match_length,C.prev_match=C.match_start,C.match_length=k-1,W!==0&&C.prev_length<C.max_lazy_match&&C.strstart-W<=C.w_size-H&&(C.match_length=te(C,W),C.match_length<=5&&(C.strategy===1||C.match_length===k&&4096<C.strstart-C.match_start)&&(C.match_length=k-1)),C.prev_length>=k&&C.match_length<=C.prev_length){for(O=C.strstart+C.lookahead-k,F=i._tr_tally(C,C.strstart-1-C.prev_match,C.prev_length-k),C.lookahead-=C.prev_length-1,C.prev_length-=2;++C.strstart<=O&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+k-1])&C.hash_mask,W=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),--C.prev_length!=0;);if(C.match_available=0,C.match_length=k-1,C.strstart++,F&&(J(C,!1),C.strm.avail_out===0))return A}else if(C.match_available){if((F=i._tr_tally(C,0,C.window[C.strstart-1]))&&J(C,!1),C.strstart++,C.lookahead--,C.strm.avail_out===0)return A}else C.match_available=1,C.strstart++,C.lookahead--}return C.match_available&&(F=i._tr_tally(C,0,C.window[C.strstart-1]),C.match_available=0),C.insert=C.strstart<k-1?C.strstart:k-1,R===x?(J(C,!0),C.strm.avail_out===0?Y:q):C.last_lit&&(J(C,!1),C.strm.avail_out===0)?A:G}function B(C,R,W,F,O){this.good_length=C,this.max_lazy=R,this.nice_length=W,this.max_chain=F,this.func=O}function U(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*g),this.dyn_dtree=new a.Buf16(2*(2*_+1)),this.bl_tree=new a.Buf16(2*(2*w+1)),le(this.dyn_ltree),le(this.dyn_dtree),le(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(f+1),this.heap=new a.Buf16(2*T+1),le(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*T+1),le(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function D(C){var R;return C&&C.state?(C.total_in=C.total_out=0,C.data_type=u,(R=C.state).pending=0,R.pending_out=0,R.wrap<0&&(R.wrap=-R.wrap),R.status=R.wrap?I:V,C.adler=R.wrap===2?0:1,R.last_flush=b,i._tr_init(R),h):ie(C,m)}function N(C){var R=D(C);return R===h&&(function(W){W.window_size=2*W.w_size,le(W.head),W.max_lazy_match=s[W.level].max_lazy,W.good_match=s[W.level].good_length,W.nice_match=s[W.level].nice_length,W.max_chain_length=s[W.level].max_chain,W.strstart=0,W.block_start=0,W.lookahead=0,W.insert=0,W.match_length=W.prev_length=k-1,W.match_available=0,W.ins_h=0})(C.state),R}function S(C,R,W,F,O,z){if(!C)return m;var Q=1;if(R===d&&(R=6),F<0?(Q=0,F=-F):15<F&&(Q=2,F-=16),O<1||E<O||W!==v||F<8||15<F||R<0||9<R||z<0||y<z)return ie(C,m);F===8&&(F=9);var re=new U;return(C.state=re).strm=C,re.wrap=Q,re.gzhead=null,re.w_bits=F,re.w_size=1<<re.w_bits,re.w_mask=re.w_size-1,re.hash_bits=O+7,re.hash_size=1<<re.hash_bits,re.hash_mask=re.hash_size-1,re.hash_shift=~~((re.hash_bits+k-1)/k),re.window=new a.Buf8(2*re.w_size),re.head=new a.Buf16(re.hash_size),re.prev=new a.Buf16(re.w_size),re.lit_bufsize=1<<O+6,re.pending_buf_size=4*re.lit_bufsize,re.pending_buf=new a.Buf8(re.pending_buf_size),re.d_buf=1*re.lit_bufsize,re.l_buf=3*re.lit_bufsize,re.level=R,re.strategy=z,re.method=W,N(C)}s=[new B(0,0,0,0,function(C,R){var W=65535;for(W>C.pending_buf_size-5&&(W=C.pending_buf_size-5);;){if(C.lookahead<=1){if(ce(C),C.lookahead===0&&R===b)return A;if(C.lookahead===0)break}C.strstart+=C.lookahead,C.lookahead=0;var F=C.block_start+W;if((C.strstart===0||C.strstart>=F)&&(C.lookahead=C.strstart-F,C.strstart=F,J(C,!1),C.strm.avail_out===0)||C.strstart-C.block_start>=C.w_size-H&&(J(C,!1),C.strm.avail_out===0))return A}return C.insert=0,R===x?(J(C,!0),C.strm.avail_out===0?Y:q):(C.strstart>C.block_start&&(J(C,!1),C.strm.avail_out),A)}),new B(4,4,8,4,we),new B(4,5,16,8,we),new B(4,6,32,32,we),new B(4,4,16,16,ye),new B(8,16,32,32,ye),new B(8,16,128,128,ye),new B(8,32,128,256,ye),new B(32,128,258,1024,ye),new B(32,258,258,4096,ye)],n.deflateInit=function(C,R){return S(C,R,v,15,8,0)},n.deflateInit2=S,n.deflateReset=N,n.deflateResetKeep=D,n.deflateSetHeader=function(C,R){return C&&C.state?C.state.wrap!==2?m:(C.state.gzhead=R,h):m},n.deflate=function(C,R){var W,F,O,z;if(!C||!C.state||5<R||R<0)return C?ie(C,m):m;if(F=C.state,!C.output||!C.input&&C.avail_in!==0||F.status===666&&R!==x)return ie(C,C.avail_out===0?-5:m);if(F.strm=C,W=F.last_flush,F.last_flush=R,F.status===I)if(F.wrap===2)C.adler=0,de(F,31),de(F,139),de(F,8),F.gzhead?(de(F,(F.gzhead.text?1:0)+(F.gzhead.hcrc?2:0)+(F.gzhead.extra?4:0)+(F.gzhead.name?8:0)+(F.gzhead.comment?16:0)),de(F,255&F.gzhead.time),de(F,F.gzhead.time>>8&255),de(F,F.gzhead.time>>16&255),de(F,F.gzhead.time>>24&255),de(F,F.level===9?2:2<=F.strategy||F.level<2?4:0),de(F,255&F.gzhead.os),F.gzhead.extra&&F.gzhead.extra.length&&(de(F,255&F.gzhead.extra.length),de(F,F.gzhead.extra.length>>8&255)),F.gzhead.hcrc&&(C.adler=c(C.adler,F.pending_buf,F.pending,0)),F.gzindex=0,F.status=69):(de(F,0),de(F,0),de(F,0),de(F,0),de(F,0),de(F,F.level===9?2:2<=F.strategy||F.level<2?4:0),de(F,3),F.status=V);else{var Q=v+(F.w_bits-8<<4)<<8;Q|=(2<=F.strategy||F.level<2?0:F.level<6?1:F.level===6?2:3)<<6,F.strstart!==0&&(Q|=32),Q+=31-Q%31,F.status=V,ae(F,Q),F.strstart!==0&&(ae(F,C.adler>>>16),ae(F,65535&C.adler)),C.adler=1}if(F.status===69)if(F.gzhead.extra){for(O=F.pending;F.gzindex<(65535&F.gzhead.extra.length)&&(F.pending!==F.pending_buf_size||(F.gzhead.hcrc&&F.pending>O&&(C.adler=c(C.adler,F.pending_buf,F.pending-O,O)),$(C),O=F.pending,F.pending!==F.pending_buf_size));)de(F,255&F.gzhead.extra[F.gzindex]),F.gzindex++;F.gzhead.hcrc&&F.pending>O&&(C.adler=c(C.adler,F.pending_buf,F.pending-O,O)),F.gzindex===F.gzhead.extra.length&&(F.gzindex=0,F.status=73)}else F.status=73;if(F.status===73)if(F.gzhead.name){O=F.pending;do{if(F.pending===F.pending_buf_size&&(F.gzhead.hcrc&&F.pending>O&&(C.adler=c(C.adler,F.pending_buf,F.pending-O,O)),$(C),O=F.pending,F.pending===F.pending_buf_size)){z=1;break}z=F.gzindex<F.gzhead.name.length?255&F.gzhead.name.charCodeAt(F.gzindex++):0,de(F,z)}while(z!==0);F.gzhead.hcrc&&F.pending>O&&(C.adler=c(C.adler,F.pending_buf,F.pending-O,O)),z===0&&(F.gzindex=0,F.status=91)}else F.status=91;if(F.status===91)if(F.gzhead.comment){O=F.pending;do{if(F.pending===F.pending_buf_size&&(F.gzhead.hcrc&&F.pending>O&&(C.adler=c(C.adler,F.pending_buf,F.pending-O,O)),$(C),O=F.pending,F.pending===F.pending_buf_size)){z=1;break}z=F.gzindex<F.gzhead.comment.length?255&F.gzhead.comment.charCodeAt(F.gzindex++):0,de(F,z)}while(z!==0);F.gzhead.hcrc&&F.pending>O&&(C.adler=c(C.adler,F.pending_buf,F.pending-O,O)),z===0&&(F.status=103)}else F.status=103;if(F.status===103&&(F.gzhead.hcrc?(F.pending+2>F.pending_buf_size&&$(C),F.pending+2<=F.pending_buf_size&&(de(F,255&C.adler),de(F,C.adler>>8&255),C.adler=0,F.status=V)):F.status=V),F.pending!==0){if($(C),C.avail_out===0)return F.last_flush=-1,h}else if(C.avail_in===0&&ee(R)<=ee(W)&&R!==x)return ie(C,-5);if(F.status===666&&C.avail_in!==0)return ie(C,-5);if(C.avail_in!==0||F.lookahead!==0||R!==b&&F.status!==666){var re=F.strategy===2?(function(Z,ne){for(var he;;){if(Z.lookahead===0&&(ce(Z),Z.lookahead===0)){if(ne===b)return A;break}if(Z.match_length=0,he=i._tr_tally(Z,0,Z.window[Z.strstart]),Z.lookahead--,Z.strstart++,he&&(J(Z,!1),Z.strm.avail_out===0))return A}return Z.insert=0,ne===x?(J(Z,!0),Z.strm.avail_out===0?Y:q):Z.last_lit&&(J(Z,!1),Z.strm.avail_out===0)?A:G})(F,R):F.strategy===3?(function(Z,ne){for(var he,oe,pe,ve,me=Z.window;;){if(Z.lookahead<=L){if(ce(Z),Z.lookahead<=L&&ne===b)return A;if(Z.lookahead===0)break}if(Z.match_length=0,Z.lookahead>=k&&0<Z.strstart&&(oe=me[pe=Z.strstart-1])===me[++pe]&&oe===me[++pe]&&oe===me[++pe]){ve=Z.strstart+L;do;while(oe===me[++pe]&&oe===me[++pe]&&oe===me[++pe]&&oe===me[++pe]&&oe===me[++pe]&&oe===me[++pe]&&oe===me[++pe]&&oe===me[++pe]&&pe<ve);Z.match_length=L-(ve-pe),Z.match_length>Z.lookahead&&(Z.match_length=Z.lookahead)}if(Z.match_length>=k?(he=i._tr_tally(Z,1,Z.match_length-k),Z.lookahead-=Z.match_length,Z.strstart+=Z.match_length,Z.match_length=0):(he=i._tr_tally(Z,0,Z.window[Z.strstart]),Z.lookahead--,Z.strstart++),he&&(J(Z,!1),Z.strm.avail_out===0))return A}return Z.insert=0,ne===x?(J(Z,!0),Z.strm.avail_out===0?Y:q):Z.last_lit&&(J(Z,!1),Z.strm.avail_out===0)?A:G})(F,R):s[F.level].func(F,R);if(re!==Y&&re!==q||(F.status=666),re===A||re===Y)return C.avail_out===0&&(F.last_flush=-1),h;if(re===G&&(R===1?i._tr_align(F):R!==5&&(i._tr_stored_block(F,0,0,!1),R===3&&(le(F.head),F.lookahead===0&&(F.strstart=0,F.block_start=0,F.insert=0))),$(C),C.avail_out===0))return F.last_flush=-1,h}return R!==x?h:F.wrap<=0?1:(F.wrap===2?(de(F,255&C.adler),de(F,C.adler>>8&255),de(F,C.adler>>16&255),de(F,C.adler>>24&255),de(F,255&C.total_in),de(F,C.total_in>>8&255),de(F,C.total_in>>16&255),de(F,C.total_in>>24&255)):(ae(F,C.adler>>>16),ae(F,65535&C.adler)),$(C),0<F.wrap&&(F.wrap=-F.wrap),F.pending!==0?h:1)},n.deflateEnd=function(C){var R;return C&&C.state?(R=C.state.status)!==I&&R!==69&&R!==73&&R!==91&&R!==103&&R!==V&&R!==666?ie(C,m):(C.state=null,R===V?ie(C,-3):h):m},n.deflateSetDictionary=function(C,R){var W,F,O,z,Q,re,Z,ne,he=R.length;if(!C||!C.state||(z=(W=C.state).wrap)===2||z===1&&W.status!==I||W.lookahead)return m;for(z===1&&(C.adler=l(C.adler,R,he,0)),W.wrap=0,he>=W.w_size&&(z===0&&(le(W.head),W.strstart=0,W.block_start=0,W.insert=0),ne=new a.Buf8(W.w_size),a.arraySet(ne,R,he-W.w_size,W.w_size,0),R=ne,he=W.w_size),Q=C.avail_in,re=C.next_in,Z=C.input,C.avail_in=he,C.next_in=0,C.input=R,ce(W);W.lookahead>=k;){for(F=W.strstart,O=W.lookahead-(k-1);W.ins_h=(W.ins_h<<W.hash_shift^W.window[F+k-1])&W.hash_mask,W.prev[F&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=F,F++,--O;);W.strstart=F,W.lookahead=k-1,ce(W)}return W.strstart+=W.lookahead,W.block_start=W.strstart,W.insert=W.lookahead,W.lookahead=0,W.match_length=W.prev_length=k-1,W.match_available=0,C.next_in=re,C.input=Z,C.avail_in=Q,W.wrap=z,h},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,r,n){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,r,n){r.exports=function(s,a){var i,l,c,p,b,x,h,m,d,y,u,v,E,T,_,w,g,f,k,L,H,I,V,A,G;i=s.state,l=s.next_in,A=s.input,c=l+(s.avail_in-5),p=s.next_out,G=s.output,b=p-(a-s.avail_out),x=p+(s.avail_out-257),h=i.dmax,m=i.wsize,d=i.whave,y=i.wnext,u=i.window,v=i.hold,E=i.bits,T=i.lencode,_=i.distcode,w=(1<<i.lenbits)-1,g=(1<<i.distbits)-1;e:do{E<15&&(v+=A[l++]<<E,E+=8,v+=A[l++]<<E,E+=8),f=T[v&w];t:for(;;){if(v>>>=k=f>>>24,E-=k,(k=f>>>16&255)===0)G[p++]=65535&f;else{if(!(16&k)){if((64&k)==0){f=T[(65535&f)+(v&(1<<k)-1)];continue t}if(32&k){i.mode=12;break e}s.msg="invalid literal/length code",i.mode=30;break e}L=65535&f,(k&=15)&&(E<k&&(v+=A[l++]<<E,E+=8),L+=v&(1<<k)-1,v>>>=k,E-=k),E<15&&(v+=A[l++]<<E,E+=8,v+=A[l++]<<E,E+=8),f=_[v&g];r:for(;;){if(v>>>=k=f>>>24,E-=k,!(16&(k=f>>>16&255))){if((64&k)==0){f=_[(65535&f)+(v&(1<<k)-1)];continue r}s.msg="invalid distance code",i.mode=30;break e}if(H=65535&f,E<(k&=15)&&(v+=A[l++]<<E,(E+=8)<k&&(v+=A[l++]<<E,E+=8)),h<(H+=v&(1<<k)-1)){s.msg="invalid distance too far back",i.mode=30;break e}if(v>>>=k,E-=k,(k=p-b)<H){if(d<(k=H-k)&&i.sane){s.msg="invalid distance too far back",i.mode=30;break e}if(V=u,(I=0)===y){if(I+=m-k,k<L){for(L-=k;G[p++]=u[I++],--k;);I=p-H,V=G}}else if(y<k){if(I+=m+y-k,(k-=y)<L){for(L-=k;G[p++]=u[I++],--k;);if(I=0,y<L){for(L-=k=y;G[p++]=u[I++],--k;);I=p-H,V=G}}}else if(I+=y-k,k<L){for(L-=k;G[p++]=u[I++],--k;);I=p-H,V=G}for(;2<L;)G[p++]=V[I++],G[p++]=V[I++],G[p++]=V[I++],L-=3;L&&(G[p++]=V[I++],1<L&&(G[p++]=V[I++]))}else{for(I=p-H;G[p++]=G[I++],G[p++]=G[I++],G[p++]=G[I++],2<(L-=3););L&&(G[p++]=G[I++],1<L&&(G[p++]=G[I++]))}break}}break}}while(l<c&&p<x);l-=L=E>>3,v&=(1<<(E-=L<<3))-1,s.next_in=l,s.next_out=p,s.avail_in=l<c?c-l+5:5-(l-c),s.avail_out=p<x?x-p+257:257-(p-x),i.hold=v,i.bits=E}},{}],49:[function(t,r,n){var s=t("../utils/common"),a=t("./adler32"),i=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),p=1,b=2,x=0,h=-2,m=1,d=852,y=592;function u(I){return(I>>>24&255)+(I>>>8&65280)+((65280&I)<<8)+((255&I)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function E(I){var V;return I&&I.state?(V=I.state,I.total_in=I.total_out=V.total=0,I.msg="",V.wrap&&(I.adler=1&V.wrap),V.mode=m,V.last=0,V.havedict=0,V.dmax=32768,V.head=null,V.hold=0,V.bits=0,V.lencode=V.lendyn=new s.Buf32(d),V.distcode=V.distdyn=new s.Buf32(y),V.sane=1,V.back=-1,x):h}function T(I){var V;return I&&I.state?((V=I.state).wsize=0,V.whave=0,V.wnext=0,E(I)):h}function _(I,V){var A,G;return I&&I.state?(G=I.state,V<0?(A=0,V=-V):(A=1+(V>>4),V<48&&(V&=15)),V&&(V<8||15<V)?h:(G.window!==null&&G.wbits!==V&&(G.window=null),G.wrap=A,G.wbits=V,T(I))):h}function w(I,V){var A,G;return I?(G=new v,(I.state=G).window=null,(A=_(I,V))!==x&&(I.state=null),A):h}var g,f,k=!0;function L(I){if(k){var V;for(g=new s.Buf32(512),f=new s.Buf32(32),V=0;V<144;)I.lens[V++]=8;for(;V<256;)I.lens[V++]=9;for(;V<280;)I.lens[V++]=7;for(;V<288;)I.lens[V++]=8;for(c(p,I.lens,0,288,g,0,I.work,{bits:9}),V=0;V<32;)I.lens[V++]=5;c(b,I.lens,0,32,f,0,I.work,{bits:5}),k=!1}I.lencode=g,I.lenbits=9,I.distcode=f,I.distbits=5}function H(I,V,A,G){var Y,q=I.state;return q.window===null&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=0,q.window=new s.Buf8(q.wsize)),G>=q.wsize?(s.arraySet(q.window,V,A-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(G<(Y=q.wsize-q.wnext)&&(Y=G),s.arraySet(q.window,V,A-G,Y,q.wnext),(G-=Y)?(s.arraySet(q.window,V,A-G,G,0),q.wnext=G,q.whave=q.wsize):(q.wnext+=Y,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=Y))),0}n.inflateReset=T,n.inflateReset2=_,n.inflateResetKeep=E,n.inflateInit=function(I){return w(I,15)},n.inflateInit2=w,n.inflate=function(I,V){var A,G,Y,q,ie,ee,le,$,J,de,ae,te,ce,we,ye,B,U,D,N,S,C,R,W,F,O=0,z=new s.Buf8(4),Q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!I||!I.state||!I.output||!I.input&&I.avail_in!==0)return h;(A=I.state).mode===12&&(A.mode=13),ie=I.next_out,Y=I.output,le=I.avail_out,q=I.next_in,G=I.input,ee=I.avail_in,$=A.hold,J=A.bits,de=ee,ae=le,R=x;e:for(;;)switch(A.mode){case m:if(A.wrap===0){A.mode=13;break}for(;J<16;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}if(2&A.wrap&&$===35615){z[A.check=0]=255&$,z[1]=$>>>8&255,A.check=i(A.check,z,2,0),J=$=0,A.mode=2;break}if(A.flags=0,A.head&&(A.head.done=!1),!(1&A.wrap)||(((255&$)<<8)+($>>8))%31){I.msg="incorrect header check",A.mode=30;break}if((15&$)!=8){I.msg="unknown compression method",A.mode=30;break}if(J-=4,C=8+(15&($>>>=4)),A.wbits===0)A.wbits=C;else if(C>A.wbits){I.msg="invalid window size",A.mode=30;break}A.dmax=1<<C,I.adler=A.check=1,A.mode=512&$?10:12,J=$=0;break;case 2:for(;J<16;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}if(A.flags=$,(255&A.flags)!=8){I.msg="unknown compression method",A.mode=30;break}if(57344&A.flags){I.msg="unknown header flags set",A.mode=30;break}A.head&&(A.head.text=$>>8&1),512&A.flags&&(z[0]=255&$,z[1]=$>>>8&255,A.check=i(A.check,z,2,0)),J=$=0,A.mode=3;case 3:for(;J<32;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}A.head&&(A.head.time=$),512&A.flags&&(z[0]=255&$,z[1]=$>>>8&255,z[2]=$>>>16&255,z[3]=$>>>24&255,A.check=i(A.check,z,4,0)),J=$=0,A.mode=4;case 4:for(;J<16;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}A.head&&(A.head.xflags=255&$,A.head.os=$>>8),512&A.flags&&(z[0]=255&$,z[1]=$>>>8&255,A.check=i(A.check,z,2,0)),J=$=0,A.mode=5;case 5:if(1024&A.flags){for(;J<16;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}A.length=$,A.head&&(A.head.extra_len=$),512&A.flags&&(z[0]=255&$,z[1]=$>>>8&255,A.check=i(A.check,z,2,0)),J=$=0}else A.head&&(A.head.extra=null);A.mode=6;case 6:if(1024&A.flags&&(ee<(te=A.length)&&(te=ee),te&&(A.head&&(C=A.head.extra_len-A.length,A.head.extra||(A.head.extra=new Array(A.head.extra_len)),s.arraySet(A.head.extra,G,q,te,C)),512&A.flags&&(A.check=i(A.check,G,te,q)),ee-=te,q+=te,A.length-=te),A.length))break e;A.length=0,A.mode=7;case 7:if(2048&A.flags){if(ee===0)break e;for(te=0;C=G[q+te++],A.head&&C&&A.length<65536&&(A.head.name+=String.fromCharCode(C)),C&&te<ee;);if(512&A.flags&&(A.check=i(A.check,G,te,q)),ee-=te,q+=te,C)break e}else A.head&&(A.head.name=null);A.length=0,A.mode=8;case 8:if(4096&A.flags){if(ee===0)break e;for(te=0;C=G[q+te++],A.head&&C&&A.length<65536&&(A.head.comment+=String.fromCharCode(C)),C&&te<ee;);if(512&A.flags&&(A.check=i(A.check,G,te,q)),ee-=te,q+=te,C)break e}else A.head&&(A.head.comment=null);A.mode=9;case 9:if(512&A.flags){for(;J<16;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}if($!==(65535&A.check)){I.msg="header crc mismatch",A.mode=30;break}J=$=0}A.head&&(A.head.hcrc=A.flags>>9&1,A.head.done=!0),I.adler=A.check=0,A.mode=12;break;case 10:for(;J<32;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}I.adler=A.check=u($),J=$=0,A.mode=11;case 11:if(A.havedict===0)return I.next_out=ie,I.avail_out=le,I.next_in=q,I.avail_in=ee,A.hold=$,A.bits=J,2;I.adler=A.check=1,A.mode=12;case 12:if(V===5||V===6)break e;case 13:if(A.last){$>>>=7&J,J-=7&J,A.mode=27;break}for(;J<3;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}switch(A.last=1&$,J-=1,3&($>>>=1)){case 0:A.mode=14;break;case 1:if(L(A),A.mode=20,V!==6)break;$>>>=2,J-=2;break e;case 2:A.mode=17;break;case 3:I.msg="invalid block type",A.mode=30}$>>>=2,J-=2;break;case 14:for($>>>=7&J,J-=7&J;J<32;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}if((65535&$)!=($>>>16^65535)){I.msg="invalid stored block lengths",A.mode=30;break}if(A.length=65535&$,J=$=0,A.mode=15,V===6)break e;case 15:A.mode=16;case 16:if(te=A.length){if(ee<te&&(te=ee),le<te&&(te=le),te===0)break e;s.arraySet(Y,G,q,te,ie),ee-=te,q+=te,le-=te,ie+=te,A.length-=te;break}A.mode=12;break;case 17:for(;J<14;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}if(A.nlen=257+(31&$),$>>>=5,J-=5,A.ndist=1+(31&$),$>>>=5,J-=5,A.ncode=4+(15&$),$>>>=4,J-=4,286<A.nlen||30<A.ndist){I.msg="too many length or distance symbols",A.mode=30;break}A.have=0,A.mode=18;case 18:for(;A.have<A.ncode;){for(;J<3;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}A.lens[Q[A.have++]]=7&$,$>>>=3,J-=3}for(;A.have<19;)A.lens[Q[A.have++]]=0;if(A.lencode=A.lendyn,A.lenbits=7,W={bits:A.lenbits},R=c(0,A.lens,0,19,A.lencode,0,A.work,W),A.lenbits=W.bits,R){I.msg="invalid code lengths set",A.mode=30;break}A.have=0,A.mode=19;case 19:for(;A.have<A.nlen+A.ndist;){for(;B=(O=A.lencode[$&(1<<A.lenbits)-1])>>>16&255,U=65535&O,!((ye=O>>>24)<=J);){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}if(U<16)$>>>=ye,J-=ye,A.lens[A.have++]=U;else{if(U===16){for(F=ye+2;J<F;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}if($>>>=ye,J-=ye,A.have===0){I.msg="invalid bit length repeat",A.mode=30;break}C=A.lens[A.have-1],te=3+(3&$),$>>>=2,J-=2}else if(U===17){for(F=ye+3;J<F;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}J-=ye,C=0,te=3+(7&($>>>=ye)),$>>>=3,J-=3}else{for(F=ye+7;J<F;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}J-=ye,C=0,te=11+(127&($>>>=ye)),$>>>=7,J-=7}if(A.have+te>A.nlen+A.ndist){I.msg="invalid bit length repeat",A.mode=30;break}for(;te--;)A.lens[A.have++]=C}}if(A.mode===30)break;if(A.lens[256]===0){I.msg="invalid code -- missing end-of-block",A.mode=30;break}if(A.lenbits=9,W={bits:A.lenbits},R=c(p,A.lens,0,A.nlen,A.lencode,0,A.work,W),A.lenbits=W.bits,R){I.msg="invalid literal/lengths set",A.mode=30;break}if(A.distbits=6,A.distcode=A.distdyn,W={bits:A.distbits},R=c(b,A.lens,A.nlen,A.ndist,A.distcode,0,A.work,W),A.distbits=W.bits,R){I.msg="invalid distances set",A.mode=30;break}if(A.mode=20,V===6)break e;case 20:A.mode=21;case 21:if(6<=ee&&258<=le){I.next_out=ie,I.avail_out=le,I.next_in=q,I.avail_in=ee,A.hold=$,A.bits=J,l(I,ae),ie=I.next_out,Y=I.output,le=I.avail_out,q=I.next_in,G=I.input,ee=I.avail_in,$=A.hold,J=A.bits,A.mode===12&&(A.back=-1);break}for(A.back=0;B=(O=A.lencode[$&(1<<A.lenbits)-1])>>>16&255,U=65535&O,!((ye=O>>>24)<=J);){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}if(B&&(240&B)==0){for(D=ye,N=B,S=U;B=(O=A.lencode[S+(($&(1<<D+N)-1)>>D)])>>>16&255,U=65535&O,!(D+(ye=O>>>24)<=J);){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}$>>>=D,J-=D,A.back+=D}if($>>>=ye,J-=ye,A.back+=ye,A.length=U,B===0){A.mode=26;break}if(32&B){A.back=-1,A.mode=12;break}if(64&B){I.msg="invalid literal/length code",A.mode=30;break}A.extra=15&B,A.mode=22;case 22:if(A.extra){for(F=A.extra;J<F;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}A.length+=$&(1<<A.extra)-1,$>>>=A.extra,J-=A.extra,A.back+=A.extra}A.was=A.length,A.mode=23;case 23:for(;B=(O=A.distcode[$&(1<<A.distbits)-1])>>>16&255,U=65535&O,!((ye=O>>>24)<=J);){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}if((240&B)==0){for(D=ye,N=B,S=U;B=(O=A.distcode[S+(($&(1<<D+N)-1)>>D)])>>>16&255,U=65535&O,!(D+(ye=O>>>24)<=J);){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}$>>>=D,J-=D,A.back+=D}if($>>>=ye,J-=ye,A.back+=ye,64&B){I.msg="invalid distance code",A.mode=30;break}A.offset=U,A.extra=15&B,A.mode=24;case 24:if(A.extra){for(F=A.extra;J<F;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}A.offset+=$&(1<<A.extra)-1,$>>>=A.extra,J-=A.extra,A.back+=A.extra}if(A.offset>A.dmax){I.msg="invalid distance too far back",A.mode=30;break}A.mode=25;case 25:if(le===0)break e;if(te=ae-le,A.offset>te){if((te=A.offset-te)>A.whave&&A.sane){I.msg="invalid distance too far back",A.mode=30;break}ce=te>A.wnext?(te-=A.wnext,A.wsize-te):A.wnext-te,te>A.length&&(te=A.length),we=A.window}else we=Y,ce=ie-A.offset,te=A.length;for(le<te&&(te=le),le-=te,A.length-=te;Y[ie++]=we[ce++],--te;);A.length===0&&(A.mode=21);break;case 26:if(le===0)break e;Y[ie++]=A.length,le--,A.mode=21;break;case 27:if(A.wrap){for(;J<32;){if(ee===0)break e;ee--,$|=G[q++]<<J,J+=8}if(ae-=le,I.total_out+=ae,A.total+=ae,ae&&(I.adler=A.check=A.flags?i(A.check,Y,ae,ie-ae):a(A.check,Y,ae,ie-ae)),ae=le,(A.flags?$:u($))!==A.check){I.msg="incorrect data check",A.mode=30;break}J=$=0}A.mode=28;case 28:if(A.wrap&&A.flags){for(;J<32;){if(ee===0)break e;ee--,$+=G[q++]<<J,J+=8}if($!==(4294967295&A.total)){I.msg="incorrect length check",A.mode=30;break}J=$=0}A.mode=29;case 29:R=1;break e;case 30:R=-3;break e;case 31:return-4;case 32:default:return h}return I.next_out=ie,I.avail_out=le,I.next_in=q,I.avail_in=ee,A.hold=$,A.bits=J,(A.wsize||ae!==I.avail_out&&A.mode<30&&(A.mode<27||V!==4))&&H(I,I.output,I.next_out,ae-I.avail_out)?(A.mode=31,-4):(de-=I.avail_in,ae-=I.avail_out,I.total_in+=de,I.total_out+=ae,A.total+=ae,A.wrap&&ae&&(I.adler=A.check=A.flags?i(A.check,Y,ae,I.next_out-ae):a(A.check,Y,ae,I.next_out-ae)),I.data_type=A.bits+(A.last?64:0)+(A.mode===12?128:0)+(A.mode===20||A.mode===15?256:0),(de==0&&ae===0||V===4)&&R===x&&(R=-5),R)},n.inflateEnd=function(I){if(!I||!I.state)return h;var V=I.state;return V.window&&(V.window=null),I.state=null,x},n.inflateGetHeader=function(I,V){var A;return I&&I.state?(2&(A=I.state).wrap)==0?h:((A.head=V).done=!1,x):h},n.inflateSetDictionary=function(I,V){var A,G=V.length;return I&&I.state?(A=I.state).wrap!==0&&A.mode!==11?h:A.mode===11&&a(1,V,G,0)!==A.check?-3:H(I,V,G,G)?(A.mode=31,-4):(A.havedict=1,x):h},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,r,n){var s=t("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],i=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(p,b,x,h,m,d,y,u){var v,E,T,_,w,g,f,k,L,H=u.bits,I=0,V=0,A=0,G=0,Y=0,q=0,ie=0,ee=0,le=0,$=0,J=null,de=0,ae=new s.Buf16(16),te=new s.Buf16(16),ce=null,we=0;for(I=0;I<=15;I++)ae[I]=0;for(V=0;V<h;V++)ae[b[x+V]]++;for(Y=H,G=15;1<=G&&ae[G]===0;G--);if(G<Y&&(Y=G),G===0)return m[d++]=20971520,m[d++]=20971520,u.bits=1,0;for(A=1;A<G&&ae[A]===0;A++);for(Y<A&&(Y=A),I=ee=1;I<=15;I++)if(ee<<=1,(ee-=ae[I])<0)return-1;if(0<ee&&(p===0||G!==1))return-1;for(te[1]=0,I=1;I<15;I++)te[I+1]=te[I]+ae[I];for(V=0;V<h;V++)b[x+V]!==0&&(y[te[b[x+V]]++]=V);if(g=p===0?(J=ce=y,19):p===1?(J=a,de-=257,ce=i,we-=257,256):(J=l,ce=c,-1),I=A,w=d,ie=V=$=0,T=-1,_=(le=1<<(q=Y))-1,p===1&&852<le||p===2&&592<le)return 1;for(;;){for(f=I-ie,L=y[V]<g?(k=0,y[V]):y[V]>g?(k=ce[we+y[V]],J[de+y[V]]):(k=96,0),v=1<<I-ie,A=E=1<<q;m[w+($>>ie)+(E-=v)]=f<<24|k<<16|L|0,E!==0;);for(v=1<<I-1;$&v;)v>>=1;if(v!==0?($&=v-1,$+=v):$=0,V++,--ae[I]==0){if(I===G)break;I=b[x+y[V]]}if(Y<I&&($&_)!==T){for(ie===0&&(ie=Y),w+=A,ee=1<<(q=I-ie);q+ie<G&&!((ee-=ae[q+ie])<=0);)q++,ee<<=1;if(le+=1<<q,p===1&&852<le||p===2&&592<le)return 1;m[T=$&_]=Y<<24|q<<16|w-d|0}}return $!==0&&(m[w+$]=I-ie<<24|64<<16|0),u.bits=Y,0}},{"../utils/common":41}],51:[function(t,r,n){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,r,n){var s=t("../utils/common"),a=0,i=1;function l(O){for(var z=O.length;0<=--z;)O[z]=0}var c=0,p=29,b=256,x=b+1+p,h=30,m=19,d=2*x+1,y=15,u=16,v=7,E=256,T=16,_=17,w=18,g=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],f=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],k=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],L=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],H=new Array(2*(x+2));l(H);var I=new Array(2*h);l(I);var V=new Array(512);l(V);var A=new Array(256);l(A);var G=new Array(p);l(G);var Y,q,ie,ee=new Array(h);function le(O,z,Q,re,Z){this.static_tree=O,this.extra_bits=z,this.extra_base=Q,this.elems=re,this.max_length=Z,this.has_stree=O&&O.length}function $(O,z){this.dyn_tree=O,this.max_code=0,this.stat_desc=z}function J(O){return O<256?V[O]:V[256+(O>>>7)]}function de(O,z){O.pending_buf[O.pending++]=255&z,O.pending_buf[O.pending++]=z>>>8&255}function ae(O,z,Q){O.bi_valid>u-Q?(O.bi_buf|=z<<O.bi_valid&65535,de(O,O.bi_buf),O.bi_buf=z>>u-O.bi_valid,O.bi_valid+=Q-u):(O.bi_buf|=z<<O.bi_valid&65535,O.bi_valid+=Q)}function te(O,z,Q){ae(O,Q[2*z],Q[2*z+1])}function ce(O,z){for(var Q=0;Q|=1&O,O>>>=1,Q<<=1,0<--z;);return Q>>>1}function we(O,z,Q){var re,Z,ne=new Array(y+1),he=0;for(re=1;re<=y;re++)ne[re]=he=he+Q[re-1]<<1;for(Z=0;Z<=z;Z++){var oe=O[2*Z+1];oe!==0&&(O[2*Z]=ce(ne[oe]++,oe))}}function ye(O){var z;for(z=0;z<x;z++)O.dyn_ltree[2*z]=0;for(z=0;z<h;z++)O.dyn_dtree[2*z]=0;for(z=0;z<m;z++)O.bl_tree[2*z]=0;O.dyn_ltree[2*E]=1,O.opt_len=O.static_len=0,O.last_lit=O.matches=0}function B(O){8<O.bi_valid?de(O,O.bi_buf):0<O.bi_valid&&(O.pending_buf[O.pending++]=O.bi_buf),O.bi_buf=0,O.bi_valid=0}function U(O,z,Q,re){var Z=2*z,ne=2*Q;return O[Z]<O[ne]||O[Z]===O[ne]&&re[z]<=re[Q]}function D(O,z,Q){for(var re=O.heap[Q],Z=Q<<1;Z<=O.heap_len&&(Z<O.heap_len&&U(z,O.heap[Z+1],O.heap[Z],O.depth)&&Z++,!U(z,re,O.heap[Z],O.depth));)O.heap[Q]=O.heap[Z],Q=Z,Z<<=1;O.heap[Q]=re}function N(O,z,Q){var re,Z,ne,he,oe=0;if(O.last_lit!==0)for(;re=O.pending_buf[O.d_buf+2*oe]<<8|O.pending_buf[O.d_buf+2*oe+1],Z=O.pending_buf[O.l_buf+oe],oe++,re===0?te(O,Z,z):(te(O,(ne=A[Z])+b+1,z),(he=g[ne])!==0&&ae(O,Z-=G[ne],he),te(O,ne=J(--re),Q),(he=f[ne])!==0&&ae(O,re-=ee[ne],he)),oe<O.last_lit;);te(O,E,z)}function S(O,z){var Q,re,Z,ne=z.dyn_tree,he=z.stat_desc.static_tree,oe=z.stat_desc.has_stree,pe=z.stat_desc.elems,ve=-1;for(O.heap_len=0,O.heap_max=d,Q=0;Q<pe;Q++)ne[2*Q]!==0?(O.heap[++O.heap_len]=ve=Q,O.depth[Q]=0):ne[2*Q+1]=0;for(;O.heap_len<2;)ne[2*(Z=O.heap[++O.heap_len]=ve<2?++ve:0)]=1,O.depth[Z]=0,O.opt_len--,oe&&(O.static_len-=he[2*Z+1]);for(z.max_code=ve,Q=O.heap_len>>1;1<=Q;Q--)D(O,ne,Q);for(Z=pe;Q=O.heap[1],O.heap[1]=O.heap[O.heap_len--],D(O,ne,1),re=O.heap[1],O.heap[--O.heap_max]=Q,O.heap[--O.heap_max]=re,ne[2*Z]=ne[2*Q]+ne[2*re],O.depth[Z]=(O.depth[Q]>=O.depth[re]?O.depth[Q]:O.depth[re])+1,ne[2*Q+1]=ne[2*re+1]=Z,O.heap[1]=Z++,D(O,ne,1),2<=O.heap_len;);O.heap[--O.heap_max]=O.heap[1],(function(me,be){var Se,Te,Ie,Ce,Le,Ue,ke=be.dyn_tree,Je=be.max_code,rt=be.stat_desc.static_tree,st=be.stat_desc.has_stree,lt=be.stat_desc.extra_bits,ct=be.stat_desc.extra_base,it=be.stat_desc.max_length,ut=0;for(Ce=0;Ce<=y;Ce++)me.bl_count[Ce]=0;for(ke[2*me.heap[me.heap_max]+1]=0,Se=me.heap_max+1;Se<d;Se++)it<(Ce=ke[2*ke[2*(Te=me.heap[Se])+1]+1]+1)&&(Ce=it,ut++),ke[2*Te+1]=Ce,Je<Te||(me.bl_count[Ce]++,Le=0,ct<=Te&&(Le=lt[Te-ct]),Ue=ke[2*Te],me.opt_len+=Ue*(Ce+Le),st&&(me.static_len+=Ue*(rt[2*Te+1]+Le)));if(ut!==0){do{for(Ce=it-1;me.bl_count[Ce]===0;)Ce--;me.bl_count[Ce]--,me.bl_count[Ce+1]+=2,me.bl_count[it]--,ut-=2}while(0<ut);for(Ce=it;Ce!==0;Ce--)for(Te=me.bl_count[Ce];Te!==0;)Je<(Ie=me.heap[--Se])||(ke[2*Ie+1]!==Ce&&(me.opt_len+=(Ce-ke[2*Ie+1])*ke[2*Ie],ke[2*Ie+1]=Ce),Te--)}})(O,z),we(ne,ve,O.bl_count)}function C(O,z,Q){var re,Z,ne=-1,he=z[1],oe=0,pe=7,ve=4;for(he===0&&(pe=138,ve=3),z[2*(Q+1)+1]=65535,re=0;re<=Q;re++)Z=he,he=z[2*(re+1)+1],++oe<pe&&Z===he||(oe<ve?O.bl_tree[2*Z]+=oe:Z!==0?(Z!==ne&&O.bl_tree[2*Z]++,O.bl_tree[2*T]++):oe<=10?O.bl_tree[2*_]++:O.bl_tree[2*w]++,ne=Z,ve=(oe=0)===he?(pe=138,3):Z===he?(pe=6,3):(pe=7,4))}function R(O,z,Q){var re,Z,ne=-1,he=z[1],oe=0,pe=7,ve=4;for(he===0&&(pe=138,ve=3),re=0;re<=Q;re++)if(Z=he,he=z[2*(re+1)+1],!(++oe<pe&&Z===he)){if(oe<ve)for(;te(O,Z,O.bl_tree),--oe!=0;);else Z!==0?(Z!==ne&&(te(O,Z,O.bl_tree),oe--),te(O,T,O.bl_tree),ae(O,oe-3,2)):oe<=10?(te(O,_,O.bl_tree),ae(O,oe-3,3)):(te(O,w,O.bl_tree),ae(O,oe-11,7));ne=Z,ve=(oe=0)===he?(pe=138,3):Z===he?(pe=6,3):(pe=7,4)}}l(ee);var W=!1;function F(O,z,Q,re){ae(O,(c<<1)+(re?1:0),3),(function(Z,ne,he,oe){B(Z),de(Z,he),de(Z,~he),s.arraySet(Z.pending_buf,Z.window,ne,he,Z.pending),Z.pending+=he})(O,z,Q)}n._tr_init=function(O){W||((function(){var z,Q,re,Z,ne,he=new Array(y+1);for(Z=re=0;Z<p-1;Z++)for(G[Z]=re,z=0;z<1<<g[Z];z++)A[re++]=Z;for(A[re-1]=Z,Z=ne=0;Z<16;Z++)for(ee[Z]=ne,z=0;z<1<<f[Z];z++)V[ne++]=Z;for(ne>>=7;Z<h;Z++)for(ee[Z]=ne<<7,z=0;z<1<<f[Z]-7;z++)V[256+ne++]=Z;for(Q=0;Q<=y;Q++)he[Q]=0;for(z=0;z<=143;)H[2*z+1]=8,z++,he[8]++;for(;z<=255;)H[2*z+1]=9,z++,he[9]++;for(;z<=279;)H[2*z+1]=7,z++,he[7]++;for(;z<=287;)H[2*z+1]=8,z++,he[8]++;for(we(H,x+1,he),z=0;z<h;z++)I[2*z+1]=5,I[2*z]=ce(z,5);Y=new le(H,g,b+1,x,y),q=new le(I,f,0,h,y),ie=new le(new Array(0),k,0,m,v)})(),W=!0),O.l_desc=new $(O.dyn_ltree,Y),O.d_desc=new $(O.dyn_dtree,q),O.bl_desc=new $(O.bl_tree,ie),O.bi_buf=0,O.bi_valid=0,ye(O)},n._tr_stored_block=F,n._tr_flush_block=function(O,z,Q,re){var Z,ne,he=0;0<O.level?(O.strm.data_type===2&&(O.strm.data_type=(function(oe){var pe,ve=4093624447;for(pe=0;pe<=31;pe++,ve>>>=1)if(1&ve&&oe.dyn_ltree[2*pe]!==0)return a;if(oe.dyn_ltree[18]!==0||oe.dyn_ltree[20]!==0||oe.dyn_ltree[26]!==0)return i;for(pe=32;pe<b;pe++)if(oe.dyn_ltree[2*pe]!==0)return i;return a})(O)),S(O,O.l_desc),S(O,O.d_desc),he=(function(oe){var pe;for(C(oe,oe.dyn_ltree,oe.l_desc.max_code),C(oe,oe.dyn_dtree,oe.d_desc.max_code),S(oe,oe.bl_desc),pe=m-1;3<=pe&&oe.bl_tree[2*L[pe]+1]===0;pe--);return oe.opt_len+=3*(pe+1)+5+5+4,pe})(O),Z=O.opt_len+3+7>>>3,(ne=O.static_len+3+7>>>3)<=Z&&(Z=ne)):Z=ne=Q+5,Q+4<=Z&&z!==-1?F(O,z,Q,re):O.strategy===4||ne===Z?(ae(O,2+(re?1:0),3),N(O,H,I)):(ae(O,4+(re?1:0),3),(function(oe,pe,ve,me){var be;for(ae(oe,pe-257,5),ae(oe,ve-1,5),ae(oe,me-4,4),be=0;be<me;be++)ae(oe,oe.bl_tree[2*L[be]+1],3);R(oe,oe.dyn_ltree,pe-1),R(oe,oe.dyn_dtree,ve-1)})(O,O.l_desc.max_code+1,O.d_desc.max_code+1,he+1),N(O,O.dyn_ltree,O.dyn_dtree)),ye(O),re&&B(O)},n._tr_tally=function(O,z,Q){return O.pending_buf[O.d_buf+2*O.last_lit]=z>>>8&255,O.pending_buf[O.d_buf+2*O.last_lit+1]=255&z,O.pending_buf[O.l_buf+O.last_lit]=255&Q,O.last_lit++,z===0?O.dyn_ltree[2*Q]++:(O.matches++,z--,O.dyn_ltree[2*(A[Q]+b+1)]++,O.dyn_dtree[2*J(z)]++),O.last_lit===O.lit_bufsize-1},n._tr_align=function(O){ae(O,2,3),te(O,E,H),(function(z){z.bi_valid===16?(de(z,z.bi_buf),z.bi_buf=0,z.bi_valid=0):8<=z.bi_valid&&(z.pending_buf[z.pending++]=255&z.bi_buf,z.bi_buf>>=8,z.bi_valid-=8)})(O)}},{"../utils/common":41}],53:[function(t,r,n){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,r,n){(function(s){(function(a,i){if(!a.setImmediate){var l,c,p,b,x=1,h={},m=!1,d=a.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(a);y=y&&y.setTimeout?y:a,l={}.toString.call(a.process)==="[object process]"?function(T){process.nextTick(function(){v(T)})}:(function(){if(a.postMessage&&!a.importScripts){var T=!0,_=a.onmessage;return a.onmessage=function(){T=!1},a.postMessage("","*"),a.onmessage=_,T}})()?(b="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",E,!1):a.attachEvent("onmessage",E),function(T){a.postMessage(b+T,"*")}):a.MessageChannel?((p=new MessageChannel).port1.onmessage=function(T){v(T.data)},function(T){p.port2.postMessage(T)}):d&&"onreadystatechange"in d.createElement("script")?(c=d.documentElement,function(T){var _=d.createElement("script");_.onreadystatechange=function(){v(T),_.onreadystatechange=null,c.removeChild(_),_=null},c.appendChild(_)}):function(T){setTimeout(v,0,T)},y.setImmediate=function(T){typeof T!="function"&&(T=new Function(""+T));for(var _=new Array(arguments.length-1),w=0;w<_.length;w++)_[w]=arguments[w+1];var g={callback:T,args:_};return h[x]=g,l(x),x++},y.clearImmediate=u}function u(T){delete h[T]}function v(T){if(m)setTimeout(v,0,T);else{var _=h[T];if(_){m=!0;try{(function(w){var g=w.callback,f=w.args;switch(f.length){case 0:g();break;case 1:g(f[0]);break;case 2:g(f[0],f[1]);break;case 3:g(f[0],f[1],f[2]);break;default:g.apply(i,f)}})(_)}finally{u(T),m=!1}}}}function E(T){T.source===a&&typeof T.data=="string"&&T.data.indexOf(b)===0&&v(+T.data.slice(b.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof kt<"u"?kt:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(dr)),dr.exports}var Ns=Rs();const Ai=wi(Ns);function _i(o){const e=String(o??"").trim().toLowerCase(),t=e.lastIndexOf(".");return t>=0?e.slice(t):""}function Ps(o){return Vs(o.webkitRelativePath||o.name)}function Ds(o){const e=URL.createObjectURL(o);return{url:e,name:o.name,extension:_i(o.name),revoke:()=>URL.revokeObjectURL(e)}}async function Us(o,e="package.zip"){const t=new Ai;o.forEach(s=>{t.file(Ps(s),s)});const r=await t.generateAsync({type:"blob"}),n=URL.createObjectURL(r);return{url:n,name:e,extension:_i(e),revoke:()=>URL.revokeObjectURL(n)}}function Vs(o){return String(o).replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+/g,"/")}const Os="__BIM_ENGINE_SDK_ASSET_BASE__",Fs="__BIM_ENGINE_SDK_ASSET_FILE_MAP__",zs="__BIM_ENGINE_SDK_ASSET_FILE_SESSION__",Ks="https://unpkg.com/iflow-engine-base@3.9.20/dist/",fr="https://__bim_engine_sdk_asset__/";function pr(){return typeof globalThis<"u"?globalThis:null}function Gt(o){return o.endsWith("/")?o:`${o}/`}function Wt(o){return String(o).replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+/g,"/")}function Ii(o){return/^(?:[a-z][a-z\d+\-.]*:)?\/\//i.test(o)||/^(?:data|blob):/i.test(o)}function Hs(o){return o.startsWith("./")||o.startsWith("../")}function jt(o,e){try{return e?new URL(o,e).toString():new URL(o).toString()}catch{return null}}function Gs(o){return o.startsWith(fr)}function gr(){const e=pr()?.[zs];return typeof e=="string"&&e?`${fr}${e}/`:null}function Ws(o){return`${gr()??fr}${Wt(o)}`}function ki(){const e=pr()?.[Fs];return e instanceof Map?e:null}function Bi(o){const e=ki();if(!e)return null;const t=Wt(o);return e.get(t)??e.get(t.toLowerCase())??null}function Mi(o){const e=ki();if(!e)return!1;const t=Wt(o).replace(/\/?$/,"/").toLowerCase();for(const r of e.keys())if(r.toLowerCase().startsWith(t))return!0;return!1}function js(o){if(!Gs(o))return null;const e=gr();if(!e||!o.startsWith(e))return null;const t=o.slice(e.length);return Bi(t)}Pe.DefaultLoadingManager.setURLModifier(o=>js(o)??o);function Li(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof location<"u"&&location.href?location.href:null}function qs(o,e){const t=Gt(o);if(Ii(t))return t;const r=qt(e)||Ys()||Li();return jt(t,r||void 0)||t}function qt(o){if(!o)return null;try{const e=Li(),t=jt(o,e||void 0)||o,r=new URL(".",t),n=r.pathname.replace(/\\/g,"/");return n.endsWith("/chunks/")?new URL("../",r).toString():e&&/\/src\//.test(n)?Gt(e):r.toString()}catch{return null}}function Ys(){if(typeof document>"u")return null;const o=document.currentScript;if(o?.src)return qt(o.src);const e=document.getElementsByTagName("script");for(let t=e.length-1;t>=0;t-=1){const r=e[t]?.src;if(r&&/(?:bim-engine-sdk|iflow-engine-base|dwg-preview|gaussian)\.(?:es|umd)\.js(?:[?#].*)?$/.test(r))return qt(r)}return null}function $s(o){const e=gr();if(e)return e;const r=pr()?.[Os];return typeof r=="string"&&r.length>0?qs(r,o):Gt(Ks)}function mt(o,e){if(Ii(o))return o;const t=Wt(o),r=Bi(t);if(r&&!o.endsWith("/"))return r;if(o.endsWith("/")||Mi(t)){const s=Ws(t);if(Mi(t))return o.endsWith("/")?Gt(s):s}if(Hs(o)){const s=jt(o,qt(e)||void 0);if(s)return s}const n=$s(e);return jt(t,n)||t}class Zs{panel=null;listEl=null;isVisible=!1;delegate;constructor(e,t){this.delegate=t,this._buildPanel(e)}show(){this.panel&&(this.panel.style.display="flex",this.isVisible=!0)}hide(){this.panel&&(this.panel.style.display="none",this.isVisible=!1)}toggle(){this.isVisible?this.hide():this.show()}refresh(){this._renderList()}_buildPanel(e){const t=document.createElement("div");t.style.cssText=`
|
|
67
|
-
position:absolute; top:10px; right:10px;
|
|
68
|
-
width:220px; max-height:480px;
|
|
69
|
-
background:var(--e2d-bg,#1e1f22);
|
|
70
|
-
border:1px solid var(--e2d-border2,#333);
|
|
71
|
-
border-radius:4px;
|
|
72
|
-
box-shadow:0 4px 16px var(--e2d-shadow,rgba(0,0,0,.6));
|
|
73
|
-
display:none; flex-direction:column;
|
|
74
|
-
z-index:100; user-select:none;
|
|
75
|
-
font-size:13px; color:var(--e2d-text,#e0e0e0);
|
|
76
|
-
font-family:system-ui,sans-serif;
|
|
77
|
-
`,this.panel=t;const r=document.createElement("div");r.style.cssText=`
|
|
78
|
-
display:flex; align-items:center; justify-content:space-between;
|
|
79
|
-
padding:8px 10px;
|
|
80
|
-
background:var(--e2d-bg3,#222);
|
|
81
|
-
border-bottom:1px solid var(--e2d-border2,#333);
|
|
82
|
-
border-radius:4px 4px 0 0; cursor:move; flex-shrink:0;
|
|
83
|
-
`;const n=document.createElement("span");n.textContent="图层",n.style.cssText="font-size:13px; font-weight:500; color:var(--e2d-text,#e0e0e0);";const s=document.createElement("button");s.textContent="×",s.style.cssText=`
|
|
84
|
-
background:none; border:none;
|
|
85
|
-
color:var(--e2d-close,#aaa);
|
|
86
|
-
font-size:18px; line-height:1; cursor:pointer; padding:0 2px;
|
|
87
|
-
transition:color 0.15s;
|
|
88
|
-
`,s.onmouseenter=()=>{s.style.color="var(--e2d-close-hover,#fff)"},s.onmouseleave=()=>{s.style.color="var(--e2d-close,#aaa)"},s.onclick=()=>this.hide(),r.appendChild(n),r.appendChild(s),this._makeDraggable(t,r);const a=this._createRow(),i=this._createEye(!0),l=document.createElement("span");l.textContent="全部图层",l.style.cssText="flex:1; font-weight:500; color:var(--e2d-text,#e0e0e0);",a.appendChild(i),a.appendChild(l),a.onclick=()=>{const x=!this.delegate.isAllVisible();this.delegate.setAllLayersVisible(x),this._renderList(),this._updateEye(i,x)};const c=document.createElement("div");c.style.cssText="height:1px; background:var(--e2d-border2,#333); margin:0 8px; flex-shrink:0;";const p=document.createElement("div");p.style.cssText=`
|
|
89
|
-
overflow-y:auto; flex:1;
|
|
90
|
-
scrollbar-width:thin;
|
|
91
|
-
scrollbar-color:var(--e2d-scrollbar,#444) transparent;
|
|
92
|
-
`,this.listEl=p,t.appendChild(r),t.appendChild(a),t.appendChild(c),t.appendChild(p);const b=this._renderList.bind(this);this._renderList=()=>{b(),this._updateEye(i,this.delegate.isAllVisible())},this._renderList(),e.style.position="relative",e.appendChild(t)}_renderList(){const e=this.listEl;if(e){e.innerHTML="";for(const t of this.delegate.getLayers()){const r=this._createRow(),n=this._createEye(t.visible),s=document.createElement("span");s.style.cssText=`
|
|
93
|
-
width:14px; height:14px; border-radius:2px; flex-shrink:0;
|
|
94
|
-
border:1px solid var(--e2d-swatch-border,#444);
|
|
95
|
-
background:${this._colorToHex(this.delegate.getDisplayColor(t.color))};
|
|
96
|
-
`;const a=document.createElement("span");a.textContent=t.name,a.style.cssText=`
|
|
97
|
-
flex:1; white-space:nowrap; overflow:hidden;
|
|
98
|
-
text-overflow:ellipsis; font-size:12px;
|
|
99
|
-
color:${t.visible?"var(--e2d-text,#ddd)":"var(--e2d-text4,#666)"};
|
|
100
|
-
transition:color 0.15s;
|
|
101
|
-
`,r.appendChild(n),r.appendChild(s),r.appendChild(a),r.onclick=()=>{const i=this.delegate.toggleLayer(t.name);this._updateEye(n,i),a.style.color=i?"var(--e2d-text,#ddd)":"var(--e2d-text4,#666)"},e.appendChild(r)}}}_createRow(){const e=document.createElement("div");return e.style.cssText=`
|
|
102
|
-
display:flex; align-items:center; gap:8px;
|
|
103
|
-
padding:5px 10px; cursor:pointer;
|
|
104
|
-
border-bottom:1px solid var(--e2d-border2,#222);
|
|
105
|
-
transition:background 0.1s;
|
|
106
|
-
`,e.onmouseenter=()=>{e.style.background="var(--e2d-bg-hover,#2a2a2a)"},e.onmouseleave=()=>{e.style.background=""},e}_createEye(e){const t=document.createElement("span");return t.style.cssText="display:flex; align-items:center; flex-shrink:0; width:16px;",this._updateEye(t,e),t}_updateEye(e,t){e.style.color=t?"var(--e2d-close,#aaa)":"var(--e2d-text4,#555)",e.innerHTML=t?`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
107
|
-
<path d="M8 3C4.5 3 1.5 8 1.5 8C1.5 8 4.5 13 8 13C11.5 13 14.5 8 14.5 8C14.5 8 11.5 3 8 3Z" stroke="currentColor" stroke-width="1.2"/>
|
|
108
|
-
<circle cx="8" cy="8" r="2" stroke="currentColor" stroke-width="1.2"/>
|
|
109
|
-
</svg>`:`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
110
|
-
<path d="M2 2L14 14" stroke="currentColor" stroke-width="1.2"/>
|
|
111
|
-
<path d="M8 3C4.5 3 1.5 8 1.5 8C2.2 9.3 3.3 10.5 4.5 11.5" stroke="currentColor" stroke-width="1.2"/>
|
|
112
|
-
<path d="M11.5 11.5C12.7 10.5 13.8 9.3 14.5 8C14.5 8 11.5 3 8 3" stroke="currentColor" stroke-width="1.2"/>
|
|
113
|
-
</svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=r=>{r.preventDefault();const n=e.getBoundingClientRect(),s=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=n.left-s.left+"px",e.style.top=n.top-s.top+"px",e.style.right="auto",e.style.bottom="auto";const a=r.clientX-n.left,i=r.clientY-n.top,l=p=>{e.style.left=p.clientX-a-s.left+"px",e.style.top=p.clientY-i-s.top+"px"},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)}}dispose(){this.panel?.remove(),this.panel=null,this.listEl=null}}class Ri{engine;layerMap=new Map;panelUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.panelUI=new Zs(t,this))}_loadLayers(e=this.engine.dwgData?.layers??[]){this.layerMap.clear();for(const t of e)this.layerMap.set(t.name,{...t});this.panelUI?.refresh()}syncFromModel(e){e?.length>0&&(this._loadLayers(e),this.panelUI?.refresh())}getLayers(){return Array.from(this.layerMap.values())}getDisplayColor(e){return this.engine.modelToolModule2d?.getDisplayColor(e)??e}refresh(){this.panelUI?.refresh()}setLayerVisible(e,t){const r=this.layerMap.get(e);r&&(r.visible=t),this._applyVisibility(e,t),t||this.clearInteractiveStateForLayer(e)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const r=!t.visible;return this.setLayerVisible(e,r),r}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const r=this.layerMap.get(t);r.visible=e}this.applyLayerVisibility()}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}isLayerVisible(e){return e?this.layerMap.get(e)?.visible!==!1:!0}isModelVisibleByLayer(e){const t=this.engine.loaderModule2d?.model?.nodeMap?.get(String(e))??this.engine.loaderModule2d?.model?.nodeMap?.get(e);return!t||t.length===0?!0:t.some(r=>{const n=this.getNodeObject(r);return this.areNodeLayersVisible(r)&&n?.visible!==!1})}_applyVisibility(e,t){this.applyPrimaryLayerObjectVisibility(e,t),this.applyDependentLayerVisibility()}applyLayerVisibility(){for(const[e,t]of this.layerMap)this.applyPrimaryLayerObjectVisibility(e,t.visible!==!1);this.applyDependentLayerVisibility()}applyPrimaryLayerObjectVisibility(e,t){const r=this.engine?.modelGroup??this.engine?.scene;if(!r)return;const n=e+"||";r.traverse(s=>{s.name?.startsWith(n)&&(s.visible=t)})}applyDependentLayerVisibility(){const e=this.engine.loaderModule2d?.model?.nodeMap;e&&e.forEach(t=>{t?.forEach(r=>{const n=this.getNodeLayerDeps(r);n.length<=1||this.setNodeVisible(r,n.every(s=>this.isLayerVisible(s)))})})}setNodeVisible(e,t){const r=this.getNodeObject(e);if(!r||!e?.indexes)return;if(r.isLineSegments){const s=r.geometry?.attributes?.position?.array,a=r.clonePoints;if(!s||!a)return;for(let i=e.indexes[1];i<e.indexes[2];i+=1)s[i]=t?a[i]:NaN;r.geometry.attributes.position.needsUpdate=!0;return}this.engine.modelToolModule2d?.split_merge_model?.(r);const n=r.geometry?.groups?.[e.indexes[1]];n&&(n.materialIndex=t?0:-1)}areNodeLayersVisible(e){return this.getNodeLayerDeps(e).every(t=>this.isLayerVisible(t))}getNodeLayerDeps(e){const t=Array.isArray(e?.layerDeps)&&e.layerDeps.length>0?e.layerDeps:[e?.layer];return Array.from(new Set(t.map(r=>String(r??"")).filter(Boolean)))}getNodeObject(e){return e?.object??e?.group?.children?.[e.indexes?.[0]]??this.engine.modelGroup?.children?.[e.indexes?.[0]]}clearInteractiveStateForLayer(e){const t=[...this.engine.engineStatus2d?.highlightModels??[],...this.engine.engineStatus2d?.highlightHoverModels??[]];t.length===0||!t.some(n=>(this.engine.loaderModule2d?.model?.nodeMap?.get(String(n))??this.engine.loaderModule2d?.model?.nodeMap?.get(n))?.some(a=>this.getNodeLayerDeps(a).includes(e)))||(this.engine.modelToolModule2d?.unHighlightModelHover?.(),this.engine.modelToolModule2d?.unhighlightAllModels?.())}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}function xt(o){return Array.isArray(o)?new j.Vector3(o[0]??0,o[1]??0,o[2]??0):new j.Vector3(o?.x??0,o?.y??0,o?.z??0)}function Et(o){return o?(o.computeBoundingBox(),{min:o.boundingBox?.min.clone()??new j.Vector3,max:o.boundingBox?.max.clone()??new j.Vector3}):{min:new j.Vector3,max:new j.Vector3}}function mr(o,e,t){const r=new j.Vector3(o[0]??0,o[1]??0,o[2]??0),n=new j.Euler(0,0,t??0),s=new j.Vector3(e[0]??1,e[1]??1,e[2]??1),a=new j.Quaternion().setFromEuler(n);return new j.Matrix4().compose(r,a,s)}function Xs(o){return Array.isArray(o?.transformMatrix)&&o.transformMatrix.length===16?new j.Matrix4().fromArray(o.transformMatrix):mr(o.position??[0,0,0],o.scale??[1,1,1],o.rotation??0)}function Ni(o){if(o.length===0)return{min:new j.Vector3,max:new j.Vector3};const e=new j.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),t=new j.Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);return o.forEach(r=>{e.x=Math.min(e.x,r.x),e.y=Math.min(e.y,r.y),e.z=Math.min(e.z,r.z),t.x=Math.max(t.x,r.x),t.y=Math.max(t.y,r.y),t.z=Math.max(t.z,r.z)}),{min:e,max:t}}class Pi{constructor(e){this.geometryFactory=e}cache=new Map;blockIndex=new Map;setBlocks(e){this.cache.clear(),this.blockIndex.clear(),(e??[]).forEach(t=>{t?.name&&this.blockIndex.set(t.name,t),t?.id&&this.blockIndex.set(t.id,t)})}clearCache(){this.cache.clear()}flattenRootEntities(e){return Array.from(this.iterateRootEntities(e))}*iterateRootEntities(e){yield*this.iterateEntities(e??[],new j.Matrix4,0)}flattenBlock(e,t,r){const n=this.cache.get(t);if(n)return n;const s=e.origin??[0,0,0],a=new j.Matrix4().makeTranslation(-s[0],-s[1],-(s[2]??0)),i=this.flattenEntities(e.entities??[],a,r);return this.cache.set(t,i),e.name&&this.cache.set(e.name,i),e.id&&this.cache.set(e.id,i),i}flattenEntities(e,t,r){return Array.from(this.iterateEntities(e,t,r))}*iterateEntities(e,t,r){if(r>20){console.warn("[LoaderModule2d] Block nesting is too deep, skip nested INSERT.");return}for(const n of e)if(n?.visible!==!1){if(n.type==="INSERT"){const s=this.getBlockItems(n.blockId,r+1),a=t.clone().multiply(Xs(n)),i=this.getClipPolygon(n,t);for(const l of s){const c=this.cloneRenderItem(l,a,n),p=i?this.clipRenderItem(c,i):c;p&&(yield p)}i&&n.displayClipBoundary===!0&&(yield this.createClipBoundaryItem(n,i));continue}for(const s of this.geometryFactory.create(n,t))yield s}}getBlockItems(e,t){const r=this.cache.get(e);if(r)return r;const n=this.blockIndex.get(e);return n?this.flattenBlock(n,n.name??n.id??e,t):(console.warn(`[LoaderModule2d] Missing block: ${e}`),[])}cloneRenderItem(e,t,r){const n=e.layer==="0"&&r?.layer?r.layer:e.layer??r?.layer,s=e.color==null||e.color===0?r?.color??e.color??0:e.color,a=r?.linkId??r?.id??e.linkId,i=this.mergeLayerDeps(e.layerDeps??[e.layer],r?.layer,n);if(e.kind==="line")return{...e,layer:n,layerDeps:i,color:s,linkId:a,points:(e.points??[]).map(b=>b.clone().applyMatrix4(t))};const l=e.geometry?.clone();l?.applyMatrix4(t);const c=e.textAnchor?.clone().applyMatrix4(t),p=Et(l);return{...e,layer:n,layerDeps:i,color:s,linkId:a,geometry:l,min:p.min,max:p.max,textAnchor:c}}mergeLayerDeps(e,t,r){const n=new Set,s=e.some(a=>String(a??"")==="0")&&!!t;return e.forEach(a=>{const i=String(a??"");!i||s&&i==="0"||n.add(i)}),t&&n.add(String(t)),r&&n.add(String(r)),Array.from(n)}getClipPolygon(e,t){if(e?.clipping!==!0||!Array.isArray(e?.clipBoundary))return null;const r=e.clipBoundary.map(s=>new j.Vector3(s?.[0]??s?.x??0,s?.[1]??s?.y??0,s?.[2]??s?.z??0)).filter(s=>Number.isFinite(s.x)&&Number.isFinite(s.y));if(r.length<3)return null;const n=this.getClipBoundaryMatrix(e,t);return n?r.map(s=>s.clone().applyMatrix4(n)):r}getClipBoundaryMatrix(e,t){return!Array.isArray(e?.clipInsertTransform)||e.clipInsertTransform.length!==16?null:t.clone().multiply(new j.Matrix4().fromArray(e.clipInsertTransform))}clipRenderItem(e,t){if(e.kind==="line"){const s=this.clipLinePoints(e.points??[],t);if(s.length===0)return null;const a=this.getPointsBounds(s);return{...e,points:s,min:a.min,max:a.max}}const r=this.clipGeometry(e.geometry,t);if(!r)return null;const n=Et(r);return{...e,geometry:r,min:n.min,max:n.max}}clipLinePoints(e,t){const r=[];for(let n=0;n<e.length-1;n+=2)this.clipSegmentByPolygon(e[n],e[n+1],t).forEach(s=>{r.push(s[0],s[1])});return r}clipSegmentByPolygon(e,t,r){const n=t.clone().sub(e),s=[0,1];for(let l=0;l<r.length;l+=1){const c=this.getSegmentIntersectionParameter(e,t,r[l],r[(l+1)%r.length]);c!=null&&c>1e-9&&c<1-1e-9&&s.push(c)}const a=Array.from(new Set(s.map(l=>Number(l.toFixed(12))))).sort((l,c)=>l-c),i=[];for(let l=0;l<a.length-1;l+=1){const c=a[l],p=a[l+1];if(p-c<1e-10)continue;const b=(c+p)*.5,x=e.clone().add(n.clone().multiplyScalar(b));this.isPointInPolygon(x,r)&&i.push([e.clone().add(n.clone().multiplyScalar(c)),e.clone().add(n.clone().multiplyScalar(p))])}return i}getSegmentIntersectionParameter(e,t,r,n){const s=t.x-e.x,a=t.y-e.y,i=n.x-r.x,l=n.y-r.y,c=s*l-a*i;if(Math.abs(c)<1e-12)return null;const p=r.x-e.x,b=r.y-e.y,x=(p*l-b*i)/c,h=(p*a-b*s)/c;return x>=-1e-9&&x<=1+1e-9&&h>=-1e-9&&h<=1+1e-9?j.MathUtils.clamp(x,0,1):null}isPointInPolygon(e,t){let r=!1;for(let n=0,s=t.length-1;n<t.length;s=n,n+=1){const a=t[n],i=t[s];if(this.isPointOnSegment(e,a,i))return!0;a.y>e.y!=i.y>e.y&&e.x<(i.x-a.x)*(e.y-a.y)/(i.y-a.y)+a.x&&(r=!r)}return r}isPointOnSegment(e,t,r){const n=(r.x-t.x)*(e.y-t.y)-(r.y-t.y)*(e.x-t.x);if(Math.abs(n)>1e-8)return!1;const s=(e.x-t.x)*(r.x-t.x)+(e.y-t.y)*(r.y-t.y),a=(r.x-t.x)**2+(r.y-t.y)**2;return s>=-1e-8&&s<=a+1e-8}clipGeometry(e,t){if(!e?.attributes?.position)return null;const r=e.attributes.position,n=e.attributes.uv,s=e.index,a=[],i=[],l=!!n,c=this.triangulateClipPolygon(t),p=h=>({position:new j.Vector3(r.getX(h),r.getY(h),r.getZ(h)),uv:l?new j.Vector2(n.getX(h),n.getY(h)):void 0}),b=s?s.count:r.count;for(let h=0;h<b;h+=3){const m=s?s.getX(h):h,d=s?s.getX(h+1):h+1,y=s?s.getX(h+2):h+2,u=[p(m),p(d),p(y)];c.forEach(v=>{const E=this.clipTriangle(u,v);if(!(E.length<3))for(let T=1;T<E.length-1;T+=1)[E[0],E[T],E[T+1]].forEach(_=>{a.push(_.position.x,_.position.y,_.position.z),l&&_.uv&&i.push(_.uv.x,_.uv.y)})})}if(a.length===0)return null;const x=new j.BufferGeometry;return x.setAttribute("position",new j.Float32BufferAttribute(a,3)),l&&x.setAttribute("uv",new j.Float32BufferAttribute(i,2)),x.computeVertexNormals(),x}triangulateClipPolygon(e){const t=e.map(n=>new j.Vector2(n.x,n.y)),r=j.ShapeUtils.triangulateShape(t,[]);if(r.length===0){const n=[];for(let s=1;s<e.length-1;s+=1)n.push([e[0],e[s],e[s+1]]);return n}return r.map(n=>n.map(s=>e[s]))}clipTriangle(e,t){const r=this.getPolygonOrientation(t);let n=e;for(let s=0;s<t.length;s+=1){const a=t[s],i=t[(s+1)%t.length],l=n;if(n=[],l.length===0)break;let c=l[l.length-1],p=this.isInsideClipEdge(c.position,a,i,r);l.forEach(b=>{const x=this.isInsideClipEdge(b.position,a,i,r);x!==p&&n.push(this.intersectClipEdge(c,b,a,i,r)),x&&n.push(b),c=b,p=x})}return n}isInsideClipEdge(e,t,r,n){const s=r.x-t.x,a=r.y-t.y;return n*(s*(e.y-t.y)-a*(e.x-t.x))>=-1e-9}intersectClipEdge(e,t,r,n,s){const a=n.x-r.x,i=n.y-r.y,l=s*(a*(e.position.y-r.y)-i*(e.position.x-r.x)),c=s*(a*(t.position.y-r.y)-i*(t.position.x-r.x)),p=Math.abs(l-c)<1e-12?0:l/(l-c);return{position:e.position.clone().lerp(t.position,p),uv:e.uv&&t.uv?e.uv.clone().lerp(t.uv,p):void 0}}getPolygonOrientation(e){let t=0;for(let r=0;r<e.length;r+=1){const n=e[r],s=e[(r+1)%e.length];t+=n.x*s.y-s.x*n.y}return t>=0?1:-1}getPointsBounds(e){const t=new j.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),r=new j.Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);return e.forEach(n=>{t.min(n),r.max(n)}),{min:t,max:r}}createClipBoundaryItem(e,t){const r=[];for(let s=0;s<t.length;s+=1)r.push(t[s].clone(),t[(s+1)%t.length].clone());const n=this.getPointsBounds(r);return{kind:"line",layer:e.layer??"0",layerDeps:e.layer?[e.layer]:["0"],color:e.clipBoundaryColor??16711935,lineType:"Continuous",linkId:e.linkId??e.id,points:r,min:n.min,max:n.max,info:e}}}class Qs{zipObjectUrls=[];async load(e){if(this.clearZipObjectUrls(),this.isManifestUrl(e)){const t=await this.fetchJson(e);return this.loadSplitData(this.getBaseUrl(e),t)}if(e.endsWith("/")){const t=this.normalizeDirectoryUrl(e),r=await this.fetchJson(this.joinUrl(t,"manifest.json"));return this.loadSplitData(t,r)}try{return await this.loadZipData(e)}catch(t){if(this.is2dZipUrl(e))throw t;try{const r=this.normalizeDirectoryUrl(e),n=await this.fetchJson(this.joinUrl(r,"manifest.json"));return this.loadSplitData(r,n)}catch{throw t}}}async fetchJson(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}async loadSplitData(e,t,r=s=>this.fetchJson(s),n=(s,a)=>Promise.resolve(this.resolveImageUrl(s,a))){const s=await r(this.joinUrl(e,t.metadataUrl??"metadata.json")),[a,i,l,c]=await Promise.all([r(this.joinUrl(e,t.layersUrl??"layers.json")),this.loadBlocks(e,t.blocksUrl??"blocks/index.json",r),this.loadTiles(e,t.root,r),this.loadLayouts(e,s?.layoutsUrl,r)]);await this.resolveBlockAssets(i,e,n);const p=[];return l.forEach(b=>{b.inserts.forEach(x=>p.push(x))}),{version:t.version??"1.0",metadata:s,layers:a,blocks:i,entities:p,octree:t.root,tiles:l,layouts:c}}async loadLayouts(e,t,r){if(!t)return[];const n=await r(this.joinUrl(e,t)),s=Array.isArray(n?.layouts)?n.layouts:[];return(await Promise.all(s.map(async i=>{const l=i.paperUrl?await r(this.joinUrl(e,i.paperUrl)):void 0,c=i.viewportsUrl?await r(this.joinUrl(e,i.viewportsUrl)):void 0;return{id:String(i.id??l?.id??""),name:String(i.name??l?.name??i.id??""),tabOrder:Number.isFinite(Number(i.tabOrder))?Number(i.tabOrder):void 0,paperUrl:i.paperUrl,viewportsUrl:i.viewportsUrl,paper:l,paperTiles:await this.loadTiles(e,l?.root,r),viewports:Array.isArray(c?.viewports)?c.viewports:[]}}))).sort((i,l)=>(i.tabOrder??0)-(l.tabOrder??0))}async loadBlocks(e,t,r){const s=(await r(this.joinUrl(e,t))).parts??[],a=await Promise.all(s.map(l=>this.loadBlockPart(this.joinUrl(e,l),r))),i=[];return a.forEach(l=>{(Array.isArray(l?.blocks)?l.blocks:[]).forEach(p=>i.push(p))}),i}async loadBlockPart(e,t){try{return await t(e)}catch(r){const n=r instanceof Error?r.message:String(r);return console.warn(`[LoaderModule2d] Skip missing block json: ${e}`,n),{blocks:[]}}}async resolveBlockAssets(e,t,r){await Promise.all(e.map(async n=>{const s=Array.isArray(n?.entities)?n.entities:[];await Promise.all(s.map(async a=>{String(a?.type).toUpperCase()==="IMAGE"&&(a.imageUrl=await r(a,t))}))}))}resolveImageUrl(e,t){const r=e.localPath||e.sourcePath||e.path||e.url||"";if(/^(https?:)?\/\//i.test(r)||r.startsWith("/"))return r;const s=String(r).replace(/\\/g,"/").split("/").filter(Boolean).pop();return s?this.joinUrl(t,s):""}async loadTiles(e,t,r){const n=this.collectTileNodes(t);return await Promise.all(n.map(async a=>{const i=a.tileUrl??"",l=await r(this.joinUrl(e,i)),c=this.normalizeTileInserts(l.inserts??[]);return a.elements=c.map(p=>p.linkId??p.id).filter(p=>p!=null),{id:a.id??l.id??i,url:i,node:a,inserts:c}}))}normalizeTileInserts(e){return e.map(t=>({...t,linkId:t.linkId??t.id,type:"INSERT",color:t.color??0,visible:t.visible??!0}))}collectTileNodes(e){if(!e)return[];const t=[],r=[e];for(;r.length>0;){const n=r.pop();if(!n)continue;n.tileUrl&&t.push(n);const s=n.children??[];for(let a=s.length-1;a>=0;a-=1)r.push(s[a])}return t}async loadZipData(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const r=await Ai.loadAsync(await t.arrayBuffer()),n=this.findZipManifestPath(r),s=await this.fetchZipJson(r,n);if(!this.isSplitManifest(s))throw new Error("[LoaderModule2d] Expected split CAD manifest data in .2d package.");const a=this.getZipBasePath(n);return this.loadSplitData(a,s,i=>this.fetchZipJson(r,i),(i,l)=>this.resolveZipImageUrl(r,i,l))}findZipManifestPath(e){const t=Object.keys(e.files).filter(s=>!e.files[s].dir),n=t.find(s=>this.normalizeZipPath(s).toLowerCase()==="manifest.json")??t.find(s=>this.normalizeZipPath(s).toLowerCase().endsWith("/manifest.json"));if(!n)throw new Error("[LoaderModule2d] Missing manifest.json in .2d package.");return this.normalizeZipPath(n)}async fetchZipJson(e,t){if(/^(https?:)?\/\//i.test(t))return this.fetchJson(t);const r=this.getZipFile(e,t);if(!r)throw new Error(`[LoaderModule2d] Missing file in .2d package: ${t}`);return JSON.parse(await r.async("string"))}async resolveZipImageUrl(e,t,r){const n=t.localPath||t.sourcePath||t.path||t.url||"";if(/^(https?:)?\/\//i.test(n)||String(n).startsWith("blob:"))return n;const s=this.normalizeZipPath(String(n)),a=s.split("/").filter(Boolean).pop(),l=[this.joinUrl(r,s),a?this.joinUrl(r,a):"",s,a??""].filter(Boolean).map(p=>this.getZipFile(e,p)).find(p=>!!p);if(!l)return"";const c=URL.createObjectURL(new Blob([await l.async("arraybuffer")]));return this.zipObjectUrls.push(c),c}isSplitManifest(e){return!!e&&typeof e=="object"&&(e.splitType==="octree-2d"||!!e.blocksUrl)}is2dZipUrl(e){return/\.2d($|[?#])/i.test(e)}isManifestUrl(e){return/manifest\.json($|\?)/i.test(e)}getBaseUrl(e){const t=e.split("?")[0];return t.slice(0,t.lastIndexOf("/")+1)}getZipBasePath(e){const t=this.normalizeZipPath(e),r=t.lastIndexOf("/");return r>=0?t.slice(0,r+1):""}normalizeDirectoryUrl(e){return e.endsWith("/")?e:`${e}/`}joinUrl(e,t){return/^(https?:)?\/\//i.test(t)||t.startsWith("/")?t:`${e}${t}`.replace(/([^:]\/)\/+/g,"$1")}normalizeZipPath(e){return String(e).split("?")[0].split("#")[0].replace(/\\/g,"/").replace(/^\/+/,"")}getZipFile(e,t){const r=this.normalizeZipPath(t),n=e.file(r);if(n)return n;const s=r.toLowerCase(),a=Object.keys(e.files).find(i=>this.normalizeZipPath(i).toLowerCase()===s);return a?e.file(a):null}clearZipObjectUrls(){this.zipObjectUrls.forEach(e=>URL.revokeObjectURL(e)),this.zipObjectUrls=[]}}function Di(o,e,t){const r=t.length-o-1;if(e>=t[r])return r-1;if(e<=t[o])return o;let n=o,s=r,a=Math.floor((n+s)/2);for(;e<t[a]||e>=t[a+1];)e<t[a]?s=a:n=a,a=Math.floor((n+s)/2);return a}function Js(o,e,t,r){const n=[],s=[],a=[];n[0]=1;for(let i=1;i<=t;++i){s[i]=e-r[o+1-i],a[i]=r[o+i]-e;let l=0;for(let c=0;c<i;++c){const p=a[c+1],b=s[i-c],x=n[c]/(p+b);n[c]=l+p*x,l=b*x}n[i]=l}return n}function ea(o,e,t,r){const n=Di(o,r,e),s=Js(n,r,o,e),a=new Pe.Vector4(0,0,0,0);for(let i=0;i<=o;++i){const l=t[n-o+i],c=s[i],p=l.w*c;a.x+=l.x*p,a.y+=l.y*p,a.z+=l.z*p,a.w+=l.w*c}return a}function ta(o,e,t,r,n){const s=[];for(let b=0;b<=t;++b)s[b]=0;const a=[];for(let b=0;b<=r;++b)a[b]=s.slice(0);const i=[];for(let b=0;b<=t;++b)i[b]=s.slice(0);i[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let b=1;b<=t;++b){l[b]=e-n[o+1-b],c[b]=n[o+b]-e;let x=0;for(let h=0;h<b;++h){const m=c[h+1],d=l[b-h];i[b][h]=m+d;const y=i[h][b-1]/i[b][h];i[h][b]=x+m*y,x=d*y}i[b][b]=x}for(let b=0;b<=t;++b)a[0][b]=i[b][t];for(let b=0;b<=t;++b){let x=0,h=1;const m=[];for(let d=0;d<=t;++d)m[d]=s.slice(0);m[0][0]=1;for(let d=1;d<=r;++d){let y=0;const u=b-d,v=t-d;b>=d&&(m[h][0]=m[x][0]/i[v+1][u],y=m[h][0]*i[u][v]);const E=u>=-1?1:-u,T=b-1<=v?d-1:t-b;for(let w=E;w<=T;++w)m[h][w]=(m[x][w]-m[x][w-1])/i[v+1][u+w],y+=m[h][w]*i[u+w][v];b<=v&&(m[h][d]=-m[x][d-1]/i[v+1][b],y+=m[h][d]*i[b][v]),a[d][b]=y;const _=x;x=h,h=_}}let p=t;for(let b=1;b<=r;++b){for(let x=0;x<=t;++x)a[b][x]*=p;p*=t-b}return a}function ra(o,e,t,r,n){const s=n<o?n:o,a=[],i=Di(o,r,e),l=ta(i,r,o,s,e),c=[];for(let p=0;p<t.length;++p){const b=t[p].clone(),x=b.w;b.x*=x,b.y*=x,b.z*=x,c[p]=b}for(let p=0;p<=s;++p){const b=c[i-o].clone().multiplyScalar(l[p][0]);for(let x=1;x<=o;++x)b.add(c[i-o+x].clone().multiplyScalar(l[p][x]));a[p]=b}for(let p=s+1;p<=n+1;++p)a[p]=new Pe.Vector4(0,0,0);return a}function ia(o,e){let t=1;for(let n=2;n<=o;++n)t*=n;let r=1;for(let n=2;n<=e;++n)r*=n;for(let n=2;n<=o-e;++n)r*=n;return t/r}function na(o){const e=o.length,t=[],r=[];for(let s=0;s<e;++s){const a=o[s];t[s]=new Pe.Vector3(a.x,a.y,a.z),r[s]=a.w}const n=[];for(let s=0;s<e;++s){const a=t[s].clone();for(let i=1;i<=s;++i)a.sub(n[s-i].clone().multiplyScalar(ia(s,i)*r[i]));n[s]=a.divideScalar(r[0])}return n}function sa(o,e,t,r,n){const s=ra(o,e,t,r,n);return na(s)}class aa extends Pe.Curve{constructor(e,t,r,n,s){super();const a=t?t.length-1:0,i=r?r.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=n||0,this.endKnot=s||a;for(let l=0;l<i;++l){const c=r[l];this.controlPoints[l]=new Pe.Vector4(c.x,c.y,c.z,c.w)}}getPoint(e,t=new Pe.Vector3){const r=t,n=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=ea(this.degree,this.knots,this.controlPoints,n);return s.w!==1&&s.divideScalar(s.w),r.set(s.x,s.y,s.z)}getTangent(e,t=new Pe.Vector3){const r=t,n=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=sa(this.degree,this.knots,this.controlPoints,n,1);return r.copy(s[1]).normalize(),r}toJSON(){const e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(t=>t.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(t=>new Pe.Vector4(t[0],t[1],t[2],t[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}}function Bt(o,e=!1){const t=o[0].index!==null,r=new Set(Object.keys(o[0].attributes)),n=new Set(Object.keys(o[0].morphAttributes)),s={},a={},i=o[0].morphTargetsRelative,l=new Pe.BufferGeometry;let c=0;for(let p=0;p<o.length;++p){const b=o[p];let x=0;if(t!==(b.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+p+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const h in b.attributes){if(!r.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+p+'. All geometries must have compatible attributes; make sure "'+h+'" attribute exists among all geometries, or in none of them.'),null;s[h]===void 0&&(s[h]=[]),s[h].push(b.attributes[h]),x++}if(x!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+p+". Make sure all geometries have the same number of attributes."),null;if(i!==b.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+p+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const h in b.morphAttributes){if(!n.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+p+". .morphAttributes must be consistent throughout all geometries."),null;a[h]===void 0&&(a[h]=[]),a[h].push(b.morphAttributes[h])}if(e){let h;if(t)h=b.index.count;else if(b.attributes.position!==void 0)h=b.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+p+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,h,p),c+=h}}if(t){let p=0;const b=[];for(let x=0;x<o.length;++x){const h=o[x].index;for(let m=0;m<h.count;++m)b.push(h.getX(m)+p);p+=o[x].attributes.position.count}l.setIndex(b)}for(const p in s){const b=Ui(s[p]);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+p+" attribute."),null;l.setAttribute(p,b)}for(const p in a){const b=a[p][0].length;if(b===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[p]=[];for(let x=0;x<b;++x){const h=[];for(let d=0;d<a[p].length;++d)h.push(a[p][d][x]);const m=Ui(h);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+p+" morphAttribute."),null;l.morphAttributes[p].push(m)}}return l}function Ui(o){let e,t,r,n=-1,s=0;for(let c=0;c<o.length;++c){const p=o[c];if(e===void 0&&(e=p.array.constructor),e!==p.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=p.itemSize),t!==p.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=p.normalized),r!==p.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(n===-1&&(n=p.gpuType),n!==p.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=p.count*t}const a=new e(s),i=new Pe.BufferAttribute(a,t,r);let l=0;for(let c=0;c<o.length;++c){const p=o[c];if(p.isInterleavedBufferAttribute){const b=l/t;for(let x=0,h=p.count;x<h;x++)for(let m=0;m<t;m++){const d=p.getComponent(x,m);i.setComponent(x+b,m,d)}}else a.set(p.array,l);l+=p.count*t}return n!==void 0&&(i.gpuType=n),i}const Be=1e-8,Vi=.001,oa=8421504;class la{constructor(e){this.engine=e}create(e,t){const r=this.getLoopSet(e);if(r.outers.length===0)return[];if(this.isGradientFill(e))return this.createGradientItems(e,t,r);if(this.isSolidFill(e))return this.createSolidItems(e,t,r);const s=this.createPatternLineItem(e,t,r);return s?[s]:(this.warnUnknownPatternFallback(e),this.createSolidItems(e,t,r,oa))}isSolidFill(e){const t=String(e.pattern??e.patternName??"").toUpperCase();return e.solid===!0||t==="SOLID"}warnUnknownPatternFallback(e){const t=e.pattern??e.patternName??"UNKNOWN";this.engine.options?.debugHatch===!0&&console.warn(`[LoaderModule2d] HATCH pattern "${t}" cannot be rendered, use gray solid fallback.`)}isGradientFill(e){return e.gradient?.enabled===!0||String(e.patternType??"").toUpperCase()==="GRADIENTFILL"}getLoopSet(e){const t=(e.loops??[]).map(a=>this.normalizeLoop(a.points)).filter(a=>a.length>=3);if(t.length===0)return{outers:[],holes:[]};const r=(e.loops??[]).filter(a=>this.normalizeLoop(a.points).length>=3);if(!r.some(a=>a.type===!1))return this.classifyLoopsByContainment(t);const n=r.filter(a=>a.type!==!1).map(a=>this.normalizeLoop(a.points)),s=r.filter(a=>a.type===!1).map(a=>this.normalizeLoop(a.points));return n.length>0?{outers:n,holes:s}:{outers:[t[0]],holes:t.slice(1)}}classifyLoopsByContainment(e){const t=[...e].sort((s,a)=>Math.abs(this.signedArea(a))-Math.abs(this.signedArea(s))),r=[],n=[];return t.forEach((s,a)=>{const i=new j.Vector2(s[0][0],s[0][1]);t.slice(0,a).filter(c=>this.pointInPolygon(i,c)).length%2===0?r.push(s):n.push(s)}),{outers:r,holes:n}}signedArea(e){let t=0;for(let r=0;r<e.length;r+=1){const n=e[r],s=e[(r+1)%e.length];t+=n[0]*s[1]-s[0]*n[1]}return t/2}normalizeLoop(e){const t=[];(e??[]).forEach(s=>{if(!Array.isArray(s)||s.length<2)return;const a=[Number(s[0]),Number(s[1])];if(!Number.isFinite(a[0])||!Number.isFinite(a[1]))return;const i=t[t.length-1];(!i||Math.hypot(a[0]-i[0],a[1]-i[1])>Be)&&t.push(a)});const r=t[0],n=t[t.length-1];return r&&n&&Math.hypot(r[0]-n[0],r[1]-n[1])<=Be&&t.pop(),t}createSolidItems(e,t,r,n){const s=[];if(r.outers.forEach(l=>{const c=this.createShape(l);r.holes.filter(p=>this.pointInPolygon(new j.Vector2(p[0][0],p[0][1]),l)).forEach(p=>{c.holes.push(this.createPath(p))}),s.push(new j.ShapeGeometry(c))}),s.length===0)return[];const a=s.length===1?s[0]:Bt(s,!1);a.applyMatrix4(t);const i=Et(a);return[{kind:"hatch",layer:e.layer??"0",color:n??this.resolveEntityColor(e),linkId:e.linkId??e.id,geometry:a,min:i.min,max:i.max,info:e}]}createShape(e){const t=new j.Shape;t.moveTo(e[0][0],e[0][1]);for(let r=1;r<e.length;r+=1)t.lineTo(e[r][0],e[r][1]);return t.closePath(),t}createPath(e){const t=new j.Path;t.moveTo(e[0][0],e[0][1]);for(let r=1;r<e.length;r+=1)t.lineTo(e[r][0],e[r][1]);return t.closePath(),t}createGradientItems(e,t,r){const n=[];if(r.outers.forEach(i=>{const l=this.createShape(i);r.holes.filter(p=>this.pointInPolygon(new j.Vector2(p[0][0],p[0][1]),i)).forEach(p=>{l.holes.push(this.createPath(p))});const c=this.subdivideTriangles(new j.ShapeGeometry(l),this.engine.options?.hatchGradientSubdivisions??3);this.applyGradientVertexColors(c,i,e.gradient),n.push(c)}),n.length===0)return[];const s=n.length===1?n[0]:Bt(n,!1);s.applyMatrix4(t);const a=Et(s);return[{kind:"hatch",layer:e.layer??"0",color:this.resolveEntityColor(e),linkId:e.linkId??e.id,geometry:s,useVertexColors:!0,min:a.min,max:a.max,info:e}]}applyGradientVertexColors(e,t,r){const n=e.getAttribute("position"),s=[],a=this.resolveGradientStops(r),i=this.getBounds(t),l=new j.Vector2((i.minX+i.maxX)/2,(i.minY+i.maxY)/2),c=Math.max(i.maxX-i.minX,Be),p=Math.max(i.maxY-i.minY,Be),b=Math.max(Math.hypot(c/2,p/2),Be),x=Number(r?.angle??0),h=new j.Vector2(Math.cos(x),Math.sin(x)).normalize(),m=new j.Vector2(-h.y,h.x);for(let d=0;d<n.count;d+=1){const y=new j.Vector2(n.getX(d),n.getY(d)),u=this.resolveGradientFactor(y,l,h,m,c,p,b,r),v=this.sampleGradientColor(a,u);s.push(v.r,v.g,v.b)}e.setAttribute("color",new j.Float32BufferAttribute(s,3))}subdivideTriangles(e,t){let r=e.index?e.toNonIndexed():e.clone();const n=Math.max(0,Math.min(Math.floor(Number(t)||0),5));for(let s=0;s<n;s+=1){const a=r.getAttribute("position"),i=[];for(let l=0;l<a.count;l+=3){const c=new j.Vector3(a.getX(l),a.getY(l),a.getZ(l)),p=new j.Vector3(a.getX(l+1),a.getY(l+1),a.getZ(l+1)),b=new j.Vector3(a.getX(l+2),a.getY(l+2),a.getZ(l+2)),x=c.clone().lerp(p,.5),h=p.clone().lerp(b,.5),m=b.clone().lerp(c,.5);this.pushTriangle(i,c,x,m),this.pushTriangle(i,x,p,h),this.pushTriangle(i,m,h,b),this.pushTriangle(i,x,h,m)}r=new j.BufferGeometry().setAttribute("position",new j.Float32BufferAttribute(i,3))}return r}pushTriangle(e,t,r,n){e.push(t.x,t.y,t.z,r.x,r.y,r.z,n.x,n.y,n.z)}resolveGradientFactor(e,t,r,n,s,a,i,l){const c=e.clone().sub(t),p=String(l?.name??"LINEAR").toUpperCase(),b=Number(l?.shift??0),x=Math.max(Math.abs(r.x)*s+Math.abs(r.y)*a,Be),h=Math.max(Math.abs(n.x)*s+Math.abs(n.y)*a,Be);let m=.5+c.dot(r)/x+b;return p.includes("CYLINDER")?m=Math.abs(c.dot(n))/(h/2):p.includes("SPHERICAL")?(m=c.length()/i,p.includes("HEMI")&&(m=Math.sqrt(m))):p.includes("CURVED")&&(m=Math.pow(Math.abs(c.dot(r))/(x/2),.65)),p.startsWith("INV")&&(m=1-m),j.MathUtils.clamp(m,0,1)}resolveGradientStops(e){const t=(e?.colors??[]).map(r=>({value:j.MathUtils.clamp(Number(r.value??0),0,1),color:this.resolveGradientStopColor(r)})).sort((r,n)=>r.value-n.value);if(t.length>=2)return t;if(t.length===1){const r=j.MathUtils.clamp(Number(e?.colorTint??0),0,1);return[{value:0,color:t[0].color.clone().lerp(new j.Color(16777215),r)},{value:1,color:t[0].color}]}return[{value:0,color:new j.Color(16777215)},{value:1,color:new j.Color(0)}]}resolveGradientStopColor(e){if(Array.isArray(e.rgb)&&e.rgb.length>=3){const[t,r,n]=e.rgb.map(s=>j.MathUtils.clamp(Number(s??0),0,255)/255);return new j.Color(t,r,n)}return new j.Color(e.color??16777215)}resolveEntityColor(e){if(Array.isArray(e.rgb)&&e.rgb.length>=3){const[t,r,n]=e.rgb.map(s=>Math.round(j.MathUtils.clamp(Number(s??0),0,255)));return t<<16|r<<8|n}return e.color??16777215}sampleGradientColor(e,t){if(t<=e[0].value)return e[0].color.clone();for(let r=0;r<e.length-1;r+=1){const n=e[r],s=e[r+1];if(t<=s.value+Be){const a=Math.max(s.value-n.value,Be);return n.color.clone().lerp(s.color,(t-n.value)/a)}}return e[e.length-1].color.clone()}createPatternLineItem(e,t,r){const n=[],s=this.engine.options?.hatchPatternMaxSegments??2e4;let a=0;for(const l of r.outers){const c=this.getBounds(l),p=Math.hypot(c.maxX-c.minX,c.maxY-c.minY);if(!(p<Be))for(const b of e.patternLines??[]){if(a>=s)break;const x=this.createPatternFamilySegments(e,b,l,r.holes,c,p,s-a);x.forEach(([h,m])=>{n.push(new j.Vector3(h.x,h.y,Vi),new j.Vector3(m.x,m.y,Vi))}),a+=x.length}}if(n.length===0)return null;n.forEach(l=>l.applyMatrix4(t));const i=Ni(n);return{kind:"line",layer:e.layer??"0",color:this.resolveEntityColor(e),linkId:e.linkId??e.id,points:n,min:i.min,max:i.max,info:e}}createPatternFamilySegments(e,t,r,n,s,a,i){const l=this.resolvePatternLineTransform(e,t),c=l.dir,p=new j.Vector2(-c.y,c.x),b=l.base,x=l.offset;let h=x.dot(p);if(Math.abs(h)<Be&&(h=Number(t.lineOffset??0)),Math.abs(h)<Be)return[];const m=[new j.Vector2(s.minX,s.minY),new j.Vector2(s.maxX,s.minY),new j.Vector2(s.maxX,s.maxY),new j.Vector2(s.minX,s.maxY)],d=b.dot(p),y=m.map(g=>g.dot(p)-d),u=Math.min(...y)-a,v=Math.max(...y)+a,E=Math.floor(Math.min(u/h,v/h))-2,T=Math.ceil(Math.max(u/h,v/h))+2,_=[],w=new j.Vector2((s.minX+s.maxX)/2,(s.minY+s.maxY)/2);for(let g=E;g<=T&&_.length<i;g+=1){const f=b.clone().add(x.clone().multiplyScalar(g)),k=f.clone().add(c.clone().multiplyScalar(w.clone().sub(f).dot(c))),L=k.clone().add(c.clone().multiplyScalar(-a*2)),H=k.clone().add(c.clone().multiplyScalar(a*2));this.clipLineByPolygon(L,H,r).forEach(([V,A])=>{this.subtractHoles(V,A,n).forEach(([G,Y])=>{this.appendDashedSegment(_,G,Y,t.dashLengths,f,c)})})}return _.slice(0,i)}resolvePatternLineTransform(e,t){const r=Number(t.angle??e.patternAngle??0);return{dir:new j.Vector2(Math.cos(r),Math.sin(r)).normalize(),base:this.toVector2(t.basePoint),offset:this.toVector2(t.offset)}}toVector2(e){return new j.Vector2(e?.[0]??0,e?.[1]??0)}getBounds(e){return{minX:Math.min(...e.map(t=>t[0])),minY:Math.min(...e.map(t=>t[1])),maxX:Math.max(...e.map(t=>t[0])),maxY:Math.max(...e.map(t=>t[1]))}}clipLineByPolygon(e,t,r){const n=[0,1];for(let i=0;i<r.length;i+=1){const l=new j.Vector2(r[i][0],r[i][1]),c=new j.Vector2(r[(i+1)%r.length][0],r[(i+1)%r.length][1]),p=this.segmentIntersectionT(e,t,l,c);p!==null&&p>Be&&p<1-Be&&n.push(p)}const s=this.dedupeSorted(n.sort((i,l)=>i-l),1e-7),a=[];for(let i=0;i<s.length-1;i+=1){const l=s[i],c=s[i+1];if(c-l<1e-7)continue;const p=this.interpolate2(e,t,(l+c)/2);this.pointInPolygon(p,r)&&a.push([this.interpolate2(e,t,l),this.interpolate2(e,t,c)])}return a}subtractHoles(e,t,r){let n=[[e,t]];return r.forEach(s=>{const a=[];n.forEach(([i,l])=>{const c=this.clipLineByPolygon(i,l,s);a.push(...this.subtractSegments(i,l,c))}),n=a}),n}appendDashedSegment(e,t,r,n,s,a){const i=t.distanceTo(r);if(i<Be)return;if(!n?.length){e.push([t,r]);return}const l=this.normalizeDashPattern(n),c=l.reduce((E,T)=>E+T.length,0);if(c<Be){e.push([t,r]);return}const p=a?.clone().normalize()??r.clone().sub(t).normalize(),b=s??t,h=r.clone().sub(t).normalize().dot(p)>=0?1:-1,m=t.clone().sub(b).dot(p)*h,d=this.positiveModulo(m,c);let y=0,u=this.findDashIndex(l,d),v=d-l[u].start;for(;y<i-Be;){const E=l[u],T=Math.max(E.length-v,Be),_=Math.min(i,y+T);E.draw&&e.push([this.pointAtLength(t,r,y),this.pointAtLength(t,r,_)]),y=_,u=(u+1)%l.length,v=0}}normalizeDashPattern(e){let t=0;return e.map(r=>{const n=Number(r??0),s={length:Math.max(Math.abs(n),5e-4),draw:n>=0,start:t};return t+=s.length,s}).filter(r=>r.length>Be)}findDashIndex(e,t){for(let r=e.length-1;r>=0;r-=1)if(t>=e[r].start-Be)return r;return 0}positiveModulo(e,t){return(e%t+t)%t}subtractSegments(e,t,r){const n=r.map(([i,l])=>[this.projectT(e,t,i),this.projectT(e,t,l)]).map(([i,l])=>[Math.max(0,Math.min(i,l)),Math.min(1,Math.max(i,l))]).sort((i,l)=>i[0]-l[0]),s=[];let a=0;return n.forEach(([i,l])=>{i>a+Be&&s.push([this.interpolate2(e,t,a),this.interpolate2(e,t,i)]),a=Math.max(a,l)}),a<1-Be&&s.push([this.interpolate2(e,t,a),this.interpolate2(e,t,1)]),s}segmentIntersectionT(e,t,r,n){const s=t.clone().sub(e),a=n.clone().sub(r),i=this.cross2(s,a);if(Math.abs(i)<1e-10)return null;const l=r.clone().sub(e),c=this.cross2(l,a)/i,p=this.cross2(l,s)/i;return c>=-1e-8&&c<=1+1e-8&&p>=-1e-8&&p<=1+1e-8?c:null}pointInPolygon(e,t){let r=!1;for(let n=0,s=t.length-1;n<t.length;s=n,n+=1){const a=t[n][0],i=t[n][1],l=t[s][0],c=t[s][1];i>e.y!=c>e.y&&e.x<(l-a)*(e.y-i)/(c-i+1e-20)+a&&(r=!r)}return r}cross2(e,t){return e.x*t.y-e.y*t.x}interpolate2(e,t,r){return e.clone().lerp(t,r)}projectT(e,t,r){const n=t.clone().sub(e),s=n.lengthSq();return s<1e-12?0:r.clone().sub(e).dot(n)/s}pointAtLength(e,t,r){const n=e.distanceTo(t);return this.interpolate2(e,t,n<1e-12?0:r/n)}dedupeSorted(e,t){const r=[];return e.forEach(n=>{(!r.length||Math.abs(n-r[r.length-1])>t)&&r.push(n)}),r}}class Oi{constructor(e,t){this.engine=e,this.textFactory=t,this.hatchRenderer=new la(e)}hatchRenderer;create(e,t){switch(e.type){case"LINE_GROUP":case"LINE":case"CIRCLE":case"POLYLINE":case"SPLINE":return this.createLineItem(e,t);case"MTEXT":case"TEXT":return this.textFactory.create(e,t);case"HATCH":return this.createHatch(e,t);case"IMAGE":return this.createImage(e,t);default:return[]}}createLineItem(e,t){const r=this.getEntityPoints(e).map(n=>n.clone().applyMatrix4(t));return r.length===0?[]:[{kind:"line",layer:e.layer,color:e.color,lineType:e.lineType,lineTypeScale:e.lineTypeScale,lineTypePattern:Array.isArray(e.lineTypePattern)?e.lineTypePattern:void 0,linkId:e.linkId??e.id,points:r,info:e}]}getEntityPoints(e){switch(e.type){case"LINE_GROUP":return this.getLineGroupPoints(e);case"LINE":return[xt(e.startPoint),xt(e.endPoint)];case"CIRCLE":return this.getCirclePoints(e);case"POLYLINE":return this.getPolylinePoints(e);case"SPLINE":return this.getSplinePoints(e);default:return[]}}getLineGroupPoints(e){const t=[];return(e.segments??[]).forEach(r=>{t.push(new j.Vector3(r[0]??0,r[1]??0,r[2]??0)),t.push(new j.Vector3(r[3]??0,r[4]??0,r[5]??0))}),t}getCirclePoints(e){const t=new j.EllipseCurve(e.center?.[0]??0,e.center?.[1]??0,e.radius??0,e.radius??0,e.startAngle??0,(e.endAngle??Math.PI*2)-1e-5,!1,0);return this.pointsToSegments(t.getPoints(this.engine.options?.circleSegments??48).map(r=>new j.Vector3(r.x,r.y,e.center?.[2]??0)))}getPolylinePoints(e){const t=[],r=e.points??[];for(let n=0;n<r.length-1;n+=1)this.getPolylineSegmentPoints(r[n],r[n+1]).forEach(s=>{t.push(s)});return e.closed&&r.length>1&&this.getPolylineSegmentPoints(r[r.length-1],r[0]).forEach(n=>{t.push(n)}),t}getPolylineSegmentPoints(e,t){const r=xt(e),n=xt(t),s=Number(e?.bulge??0);if(!Number.isFinite(s)||Math.abs(s)<1e-10)return[r,n];const a=n.clone().sub(r),i=a.length();if(i<1e-12)return[r,n];const l=4*Math.atan(s),c=i*(1+s*s)/(4*Math.abs(s)),p=r.clone().add(n).multiplyScalar(.5),b=new j.Vector3(-a.y/i,a.x/i,0),x=p.clone().add(b.multiplyScalar(i*(1-s*s)/(4*s))),h=Math.atan2(r.y-x.y,r.x-x.x),m=Math.max(4,Math.ceil(Math.abs(l)/(this.engine.options?.polylineArcAngleStep??Math.PI/18))),d=[];for(let y=0;y<=m;y+=1){const u=y/m,v=h+l*u;d.push(new j.Vector3(x.x+Math.cos(v)*c,x.y+Math.sin(v)*c,r.z+(n.z-r.z)*u))}return this.pointsToSegments(d)}getSplinePoints(e){const t=(e.points??[]).map(n=>xt(n));if(t.length<2)return[];const r=t.length===2?t:this.sampleSplineCurve(t,e);return this.pointsToSegments(r)}sampleSplineCurve(e,t){const r=Math.min(Math.max(Number(t.degree??this.engine.options?.splineDegree??6),1),e.length-1),n=Array.isArray(t.knots)&&t.knots.length===e.length+r+1?t.knots:this.createClampedUniformKnots(e.length,r),s=e.map((l,c)=>{const p=Array.isArray(t.weights)?Number(t.weights[c]??1):1;return new j.Vector4(l.x,l.y,l.z,Number.isFinite(p)?p:1)});let a=(e.length-1)*2;const i=new aa(r,n,s).getPoints(a);return t.closed===!0&&i.length>1&&i.push(i[0].clone()),i}createClampedUniformKnots(e,t){const r=[];for(let n=0;n<e+t+1;n+=1)n<=t?r.push(0):n>=e?r.push(1):r.push((n-t)/(e-t));return r}pointsToSegments(e){const t=[];for(let r=0;r<e.length-1;r+=1)t.push(e[r].clone(),e[r+1].clone());return t}createHatch(e,t){return this.hatchRenderer.create(e,t)}createImage(e,t){const r=e.imageUrl||e.url;if(!r)return[];const n=xt(e.position),s=xt(e.uVector),a=xt(e.vVector),i=Number(e.pixelWidth??e.width??1),l=Number(e.pixelHeight??e.height??1);if(!Number.isFinite(i)||!Number.isFinite(l)||i===0||l===0)return[];const c=s.multiplyScalar(i),p=a.multiplyScalar(l),b=n.clone(),x=n.clone().add(c),h=n.clone().add(c).add(p),m=n.clone().add(p);[b,x,h,m].forEach(v=>v.applyMatrix4(t));const d=new j.BufferGeometry;d.setAttribute("position",new j.Float32BufferAttribute([b.x,b.y,b.z,x.x,x.y,x.z,h.x,h.y,h.z,b.x,b.y,b.z,h.x,h.y,h.z,m.x,m.y,m.z],3)),d.setAttribute("uv",new j.Float32BufferAttribute([0,0,1,0,1,1,0,0,1,1,0,1],2)),d.computeVertexNormals();const y=Et(d),u=Number(e.fade??0);return[{kind:"image",layer:e.layer??"0",color:e.color??16777215,linkId:e.linkId??e.id,geometry:d,imageUrl:r,opacity:Number.isFinite(u)?j.MathUtils.clamp(1-u/100,0,1):1,min:y.min,max:y.max,info:e}]}}class ca{constructor(e,t,r=e.modelGroup,n={}){this.model=t,this.targetGroup=r,this.options=n}modelMap=new Map;hatchMap=new Map;textMap=new Map;imageMap=new Map;textureLoader=new j.TextureLoader;addRenderItems(e){e.forEach(t=>this.addRenderItem(t))}buildSceneObjects(){this.buildImageObjects(),this.buildHatchObjects(),this.buildLineObjects(),this.buildTextObjects()}addRenderItem(e){const t=`${e.layer}||${e.color}`;if(e.kind==="line"){let a=this.modelMap.get(t);a||(a=new Map,this.modelMap.set(t,a));const i=this.resolveLinePoints(e),l=a.get(e.linkId);l?(i.forEach(c=>l.points.push(c)),l.layerDeps=this.mergeLayerDeps(l.layerDeps,e.layerDeps??[e.layer])):a.set(e.linkId,{points:[...i],layerDeps:this.mergeLayerDeps([],e.layerDeps??[e.layer])});return}const r=this.getItemMap(e),n=e.kind==="image"?`${t}||${e.imageUrl??""}`:t,s=r.get(n);s?s.push(e):r.set(n,[e])}getItemMap(e){return e.kind==="text"?this.textMap:e.kind==="image"?this.imageMap:this.hatchMap}resolveLinePoints(e){const t=e.points??[],r=this.resolveLineTypePattern(e);if(!r)return t;const n=[];for(let s=0;s<t.length-1;s+=2)this.applyDashPattern(t[s],t[s+1],r).forEach(a=>n.push(a));return n}resolveLineTypePattern(e){const t=this.model.layers.find(l=>l.name===e.layer),r=String(e.lineType??"").toLowerCase(),n=r==="bylayer"||r===""?String(t?.lineType??"").toLowerCase():r;if(!n||n==="continuous"||n==="byblock")return null;const s=Array.isArray(e.lineTypePattern)&&e.lineTypePattern.length>0?e.lineTypePattern:Array.isArray(t?.lineTypePattern)?t.lineTypePattern:this.getFallbackLineTypePattern(n);if(!s||s.length===0)return null;const a=this.resolveLineTypeScale(e,t),i=s.map(l=>Number(l)).filter(l=>Number.isFinite(l)).map(l=>l*a);return i.some(l=>Math.abs(l)>1e-12)?i:null}getFallbackLineTypePattern(e){return e.includes("dash")?[.25,-.1]:e.includes("dot")?[0,-.1]:null}resolveLineTypeScale(e,t){const r=Number(e.lineTypeScale??t?.lineTypeScale??1);return!Number.isFinite(r)||Math.abs(r)<1e-12?1:Math.abs(r)}applyDashPattern(e,t,r){const n=t.clone().sub(e),s=n.length();if(s<1e-12)return[];const a=n.multiplyScalar(1/s),i=r.reduce((x,h)=>x+Math.abs(h),0),l=Math.max(i*.05,s*.002,1e-6),c=[];let p=0,b=0;for(;p<s-1e-12;){const x=r[b%r.length],h=x>=0,m=Math.max(Math.abs(x),l),d=Math.min(p+m,s);if(h&&d>p&&c.push(e.clone().add(a.clone().multiplyScalar(p)),e.clone().add(a.clone().multiplyScalar(d))),p=d,b+=1,b>1e5)break}return c}buildLineObjects(){this.modelMap.forEach((e,t)=>{const[r]=t.split("||"),n=[];if(e.forEach(b=>{b.points.forEach(x=>n.push(x))}),n.length===0)return;const s=new j.BufferGeometry().setFromPoints(n),a=new j.LineBasicMaterial({color:this.resolveColor(t)}),i=new j.LineSegments(s,a);i.name=t;const l=s.getAttribute("position");i.clonePoints=l.array.slice(),i.materialClone=a.clone(),this.targetGroup.add(i);const c=this.targetGroup.children.length-1;let p=0;e.forEach((b,x)=>{const h=Ni(b.points);this.pushNodeMap(x,{indexes:[c,p,p+b.points.length*3],object:i,group:this.targetGroup,kind:"line",layer:r,layerDeps:b.layerDeps,min:h.min,max:h.max}),p+=b.points.length*3})})}buildTextObjects(){this.textMap.forEach((e,t)=>{const r=e.filter(i=>!!i.geometry),n=this.normalizeMeshGeometries(r,!1,!1);if(n.length===0)return;const s=this.mergeMeshGeometries(n),a=new j.MeshBasicMaterial({color:this.resolveColor(t),side:j.DoubleSide});t.includes("_hitbox")&&(a.visible=!1),this.addMeshObject(r,t,s,n,a)})}buildHatchObjects(){this.hatchMap.forEach((e,t)=>{const r=e.filter(l=>!!l.geometry),n=r.some(l=>l.useVertexColors===!0),s=this.normalizeMeshGeometries(r,!1,n);if(s.length===0)return;const a=this.mergeMeshGeometries(s),i=new j.MeshBasicMaterial({color:n?16777215:this.resolveColor(t),side:j.DoubleSide,transparent:!0,opacity:n?1:.5,vertexColors:n});this.addMeshObject(r,t,a,s,i)})}buildImageObjects(){this.imageMap.forEach((e,t)=>{const r=e.filter(p=>!!p.geometry),n=this.normalizeMeshGeometries(r,!0,!1);if(n.length===0)return;const s=r[0]?.imageUrl;if(!s)return;const a=this.mergeMeshGeometries(n),i=this.textureLoader.load(s);i.colorSpace=j.SRGBColorSpace,i.needsUpdate=!0;const l=r.reduce((p,b)=>Math.min(p,b.opacity??1),1),c=new j.MeshBasicMaterial({map:i,side:j.DoubleSide,transparent:!0,opacity:l,depthWrite:!1});this.addMeshObject(r,t,a,n,c)})}mergeMeshGeometries(e){const t=e.length===1?e[0]:Bt(e,!0);if(t.groups.length===0){const r=t.getAttribute("position");t.addGroup(0,r?.count??0,0)}return t.groups.forEach(r=>{r.materialIndex=0}),t}normalizeMeshGeometries(e,t,r){return e.map(n=>{const s=n.geometry,a=s.index?s.toNonIndexed():s.clone(),i=a.getAttribute("position"),l=a.getAttribute("uv"),c=a.getAttribute("color"),p=new j.BufferGeometry;return p.setAttribute("position",i.clone()),t&&p.setAttribute("uv",l?l.clone():this.createEmptyUv(i.count)),r&&p.setAttribute("color",c?c.clone():this.createSolidColorAttribute(i.count,n.color)),p})}createEmptyUv(e){return new j.Float32BufferAttribute(new Array(e*2).fill(0),2)}createSolidColorAttribute(e,t){const r=new j.Color(t??16777215),n=[];for(let s=0;s<e;s+=1)n.push(r.r,r.g,r.b);return new j.Float32BufferAttribute(n,3)}addMeshObject(e,t,r,n,s){const a=new j.Mesh(r,s);a.name=t,a.materialClone=s.clone(),a.isSplit=!1,a.geometrys=void 0,n.forEach(l=>{l!==r&&l.dispose()}),this.targetGroup.add(a);const i=this.targetGroup.children.length-1;e.forEach((l,c)=>{const p=l.linkId??l.info?.id;this.pushNodeMap(p,{indexes:[i,c],object:a,group:this.targetGroup,kind:l.kind,layer:l.layer,layerDeps:l.layerDeps??[l.layer],info:l.info,min:l.min??new j.Vector3,max:l.max??new j.Vector3}),this.pushTextSearchItem(l,t)})}pushTextSearchItem(e,t){if(this.options.interactive===!1||e.kind!=="text"||t.includes("_hitbox"))return;const r=e.info?.text,n=String(r??"").replace(/\r\n/g,`
|
|
114
|
-
`).replace(/\r/g,`
|
|
115
|
-
`).trim(),s=e.linkId??e.info?.id;!n||s==null||this.model.textItems.push({id:String(s),text:n,layer:e.layer,layerDeps:e.layerDeps??[e.layer],min:e.min,max:e.max,anchor:e.textAnchor,info:e.info})}resolveColor(e){const[t,r]=e.split("||");let n=Number.parseInt(r);return(n===0||Number.isNaN(n))&&(n=this.model.layers.find(a=>a.name===t)?.color??16777215),n}pushNodeMap(e,t){if(this.options.interactive===!1||e==null)return;const r=String(e),n=this.model.nodeMap.get(r);n?n.push(t):this.model.nodeMap.set(r,[t])}mergeLayerDeps(e,t){return Array.from(new Set([...e,...t].filter(r=>!!r)))}}class Fi{constructor(e,t){this.engine=e,this.font=t}create(e,t=new j.Matrix4){if(!e.text)return[];const r=this.normalizeText(e.text);if(!r.trim())return[];const n=this.engine.options?.textCurveSegments??1,s=this.createTextGeometry(r,e.height??100,n);if(!s)return[];const a=[...e.position??[0,0,0]];a[1]=a[1]-(e.height??0);const i=this.resolveWidthScale(e),l=new j.Vector3(a[0]??0,a[1]??0,a[2]??0).applyMatrix4(t),c=1.4*e.scale;s.applyMatrix4(t.clone().multiply(mr(a,[i*1.4,1*c,1*c],e.rotation??0)));const p=Et(s),b=[{kind:"text",layer:e.layer,color:e.color,linkId:e.linkId??e.id,geometry:s,min:p.min,max:p.max,textAnchor:l,info:e}],x=this.createHitbox(s);if(x){const h=Et(x);b.push({kind:"text",layer:e.layer,color:`${e.color}_hitbox`,linkId:e.linkId??e.id,geometry:x,min:h.min,max:h.max,textAnchor:l,info:e})}return b}resolveWidthScale(e){const t=Number(e.widthScale??e.widthFactor??1);return!Number.isFinite(t)||Math.abs(t)<1e-12?1:t}normalizeText(e){return String(e??"").replace(/\r\n/g,`
|
|
116
|
-
`).replace(/\r/g,`
|
|
117
|
-
`)}collectTextChars(e){return this.normalizeText(e).replace(/\n/g," ")}createTextGeometry(e,t,r){const n=e.split(`
|
|
118
|
-
`),s=t*(this.engine.options?.textLineHeight??1.35),a=[];return n.forEach((i,l)=>{if(!i)return;const c=this.getRenderableText(i);if(!c.trim())return;const p=this.font.generateShapes(c,t),b=new j.ShapeGeometry(p,r);b.applyMatrix4(new j.Matrix4().makeTranslation(0,-l*s,0)),a.push(b)}),a.length===0?null:a.length===1?a[0]:Bt(a,!1)}getRenderableText(e){const t=this.font?.data?.glyphs;return t?Array.from(e).map(r=>r===" "?" ":t[r]?r:" ").join(""):e}createHitbox(e){e.computeBoundingBox();const t=e.boundingBox;if(!t)return null;const r=t.max.x-t.min.x,n=t.max.y-t.min.y;if(r<=0||n<=0)return null;const s=new j.PlaneGeometry(r,n);return s.applyMatrix4(mr([(t.min.x+t.max.x)/2,(t.min.y+t.max.y)/2,0],[1,1,1],0)),s}}class ua{engine;data=null;enableValidation=!0;model=this.createEmptyModel();font=null;dataSource=new Qs;lastBuildOptions={};activeWorkspace={type:"model",name:"模型"};workspaceCache=new Map;workspaceViews=new Map;localModelResource=null;constructor(e){this.engine=e,this.engine.modelGroup=new j.Group,this.engine.modelGroup.name="model2d",this.engine.scene.add(this.engine.modelGroup),this.clearModelGroup()}async loadModel(e,t={}){this.enableValidation=t.enableValidation??this.enableValidation,this.engine.events?.trigger(et.ModelLoadStart,{url:e});try{this._emitProgress(10,"请求数据...");const r=await this.loadData(e),n=this.parseData(r);if(!n)throw new Error("Failed to parse DWG data");this.engine.dwgData=n,this.data=n,this._emitProgress(20,"解析数据..."),this.lastBuildOptions={chunkSize:t.chunkSize,enableChunkedLoading:t.enableChunkedLoading},this.clearModelGroup(),this.workspaceViews.clear(),this.workspaceCache.clear();const s=await this.buildScene(n,this.lastBuildOptions);this.activeWorkspace={type:"model",name:"模型"},this.activateWorkspace(s),this.afterModelLoaded()}catch(r){throw console.error("[LoaderModule2d] Model load failed:",r),this._emitProgress(0,"抱歉,图纸加载失败"),r}}async loadModelFile(e,t={}){if(e.length===0)return;this.revokeLocalModelResource();const r=e.length===1?Ds(e[0]):await Us(e,`${this.getLocalModelName(e)}.2d`);this.localModelResource=r;try{await this.loadModel(r.url,t)}catch(n){throw this.revokeLocalModelResource(),n}}async loadData(e){return this.dataSource.load(e)}getLayouts(){return[...this.data?.layouts??[]]}getActiveWorkspace(){return{...this.activeWorkspace}}getActiveWorkspaceExtents(){return this.workspaceCache.get(this.getActiveWorkspaceKey())?.extents}async loadLayout(e,t={}){if(!this.data)throw new Error("[LoaderModule2d] No DWG data loaded.");const r=this.resolveLayout(e);if(!r)throw new Error(`[LoaderModule2d] Layout not found: ${e}`);this.saveActiveWorkspaceView(),this.lastBuildOptions={...this.lastBuildOptions,...t};const n=this.getLayoutCacheKey(r.id);let s=this.workspaceCache.get(n);s||(this.engine.events?.trigger(et.ModelLoadStart,{layoutId:r.id}),this._emitProgress(20,"加载布局空间..."),s=await this.buildLayoutScene(this.data,r,this.lastBuildOptions)),this.activeWorkspace={type:"layout",layoutId:r.id,name:r.name},this.activateWorkspace(s);const a=this.restoreWorkspaceView(s.key);this.afterModelLoaded(s.extents,{fitView:!a})}async showModelSpace(e={}){if(!this.data)throw new Error("[LoaderModule2d] No DWG data loaded.");this.saveActiveWorkspaceView(),this.lastBuildOptions={...this.lastBuildOptions,...e};let t=this.workspaceCache.get("model");t||(this.engine.events?.trigger(et.ModelLoadStart,{workspace:"model"}),t=await this.buildScene(this.data,this.lastBuildOptions)),this.activeWorkspace={type:"model",name:"模型"},this.activateWorkspace(t);const r=this.restoreWorkspaceView(t.key);this.afterModelLoaded(void 0,{fitView:!r})}resolveLayout(e){const t=this.data?.layouts??[];return typeof e=="number"?t[e]??null:t.find(r=>r.id===e||r.name===e)??null}getLayoutCacheKey(e){return`layout:${e}`}getActiveWorkspaceKey(){return this.activeWorkspace.type==="layout"&&this.activeWorkspace.layoutId?this.getLayoutCacheKey(this.activeWorkspace.layoutId):"model"}saveActiveWorkspaceView(){const e=this.engine.cameraModule2d?.getViewState?.();e&&this.workspaceViews.set(this.getActiveWorkspaceKey(),e)}restoreWorkspaceView(e){const t=this.workspaceViews.get(e);return t?(this.engine.cameraModule2d?.applyViewState?.(t),!0):!1}activateWorkspace(e){this.engine.modelToolModule2d?.unHighlightModelHover?.(),this.engine.modelToolModule2d?.unhighlightAllModels?.(),this.engine.modelGroup.rotation.set(0,0,e.rotation??0),this.workspaceCache.forEach(t=>{if(t.isModelRoot){this.setModelSpaceVisible(e.isModelRoot===!0);return}t.group.visible=t.key===e.key}),this.model=e.model,this.engine.model=e.model,this.engine.modelGroup.updateMatrixWorld(!0),this.engine.measure?.setWorkspace?.(e.key),this.engine.markup?.setWorkspace?.(e.key)}setModelSpaceVisible(e){this.engine.modelGroup.children.forEach(t=>{String(t.name??"").startsWith("octree:")&&(t.visible=e)})}getMetadataViewRotation(e){const t=Number(e.metadata?.viewRotation??0);return Number.isFinite(t)?t:0}parseData(e){return e?this.enableValidation&&!this.validateDataStructure(e)?(console.error("[LoaderModule2d] Invalid data structure"),null):e:(console.error("[LoaderModule2d] Empty JSON data"),null)}validateDataStructure(e){return e.version||console.warn("[LoaderModule2d] Missing version"),e.metadata||console.warn("[LoaderModule2d] Missing metadata"),Array.isArray(e.layers)?Array.isArray(e.blocks)?Array.isArray(e.tiles)?!0:(console.error("[LoaderModule2d] Invalid or missing tiles array"),!1):(console.error("[LoaderModule2d] Invalid or missing blocks array"),!1):(console.error("[LoaderModule2d] Invalid or missing layers array"),!1)}async buildScene(e,t={}){const r=this.createEmptyModel();r.layers=e.layers,this.model=r,this._emitProgress(30,"加载字体..."),this.font=await this.loadFont(e),this._emitProgress(45,"生成图元...");const n=new Fi(this.engine,this.font),s=new Oi(this.engine,n),a=new Pi(s);a.setBlocks(e.blocks??[]);const i=e.tiles??[];await this.buildTilesIntoGroup(i,this.engine.modelGroup,a,t);const l={key:"model",group:this.engine.modelGroup,model:r,rotation:this.getMetadataViewRotation(e),isModelRoot:!0};return this.workspaceCache.set(l.key,l),this._emitProgress(100,"加载完成"),l}async buildLayoutScene(e,t,r={}){const n=new j.Group;n.name=`workspace:layout:${t.id}`,n.visible=!1,this.engine.modelGroup.add(n);const s=this.createEmptyModel();s.layers=e.layers,this.model=s,this.font||(this._emitProgress(30,"加载字体..."),this.font=await this.loadFont(e));const a=new Fi(this.engine,this.font),i=new Oi(this.engine,a),l=new Pi(i);l.setBlocks(e.blocks??[]);const c=new j.Group;c.name=`layout-viewports:${t.id}`,n.add(c),await this.buildViewportGroups(e,t,c,l,r);const p=new j.Group;p.name=`layout-paper:${t.id}`,n.add(p),await this.buildTilesIntoGroup(t.paperTiles??[],p,l,{...r,namePrefix:"paper"});const b={key:this.getLayoutCacheKey(t.id),group:n,model:s,extents:this.getLayoutExtents(t),rotation:this.getLayoutViewRotation(t)};return this.workspaceCache.set(b.key,b),this._emitProgress(100,"布局空间加载完成"),b}async buildViewportGroups(e,t,r,n,s){const a=(t.viewports??[]).filter(i=>this.isUsableViewport(i));for(let i=0;i<a.length;i+=1){const l=a[i],c=new j.Group;c.name=`viewport:${l.id}`,c.matrixAutoUpdate=!1,c.matrix.copy(this.buildViewportMatrix(l)),c.userData.viewport=l,r.add(c);const p=this.collectViewportTiles(e.tiles??[],l),b=new Set((l.frozenLayers??[]).map(m=>String(m))),x=this.getViewportModelClipPolygon(l);await this.buildTilesIntoGroup(p,c,n,{...s,namePrefix:`viewport:${l.id}`,interactive:!0,filterRenderItem:m=>this.isVisibleInViewport(m,b),transformRenderItem:m=>this.clipRenderItemToPolygon(m,x)});const h=45+Math.round((i+1)/Math.max(a.length,1)*35);this._emitProgress(h,`加载视口 ${i+1}/${a.length}...`)}}async buildTilesIntoGroup(e,t,r,n={}){const s=Math.max(e.length,1),a=Math.max(1,n.chunkSize??2e3),i=n.enableChunkedLoading??!0;for(let l=0;l<e.length;l+=1){const c=e[l],p=this.createTileGroup(c,n.namePrefix);t.add(p);const b=new ca(this.engine,this.model,p,{interactive:n.interactive??!0}),x=new Set;let h=0,m=0;for(const y of r.iterateRootEntities(c.inserts??[])){const u=n.transformRenderItem?n.transformRenderItem(y):y;u&&(n.filterRenderItem&&!n.filterRenderItem(u)||(u?.linkId!=null&&x.add(String(u.linkId)),h+=1,m+=1,b.addRenderItem(u),i&&m>=a&&(m=0,await this.yieldToBrowser())))}p.userData.linkIds=Array.from(x),p.userData.renderItemCount=h,b.buildSceneObjects(),r.clearCache();const d=45+Math.round((l+1)/s*45);this._emitProgress(d,`合并图元 ${l+1}/${s}...`),i&&await this.yieldToBrowser()}}async yieldToBrowser(){await new Promise(e=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>e());return}setTimeout(e,0)})}createTileGroup(e,t="octree"){const r=new j.Group;return r.name=`${t}:${e.id}`,r.userData={type:"octree-tile",tileId:e.id,tileUrl:e.url,min:e.node?.min,max:e.node?.max,entityCount:e.inserts?.length??e.node?.entityCount??0},r}buildViewportMatrix(e){const t=e.paperHeight/e.viewHeight,r=-(e.twistAngle||0),n=Math.cos(r),s=Math.sin(r),[a,i]=e.viewCenter,[l,c]=e.paperCenter,p=new j.Matrix4;return p.set(n*t,-s*t,0,l-(n*t*a-s*t*i),s*t,n*t,0,c-(s*t*a+n*t*i),0,0,1,-.005,0,0,0,1),p}collectViewportTiles(e,t){const r=this.getViewportModelBounds(t);return e.filter(n=>this.intersectsBounds(n.node?.min,n.node?.max,r.min,r.max))}getViewportModelBounds(e){const t=this.getViewportModelClipPolygon(e);return{min:[Math.min(...t.map(r=>r.x)),Math.min(...t.map(r=>r.y)),0],max:[Math.max(...t.map(r=>r.x)),Math.max(...t.map(r=>r.y)),0]}}getViewportModelClipPolygon(e){const[t,r]=e.viewCenter,n=e.viewWidth/2,s=e.viewHeight/2,a=e.twistAngle||0,i=Math.cos(a),l=Math.sin(a);return[[-n,-s],[n,-s],[n,s],[-n,s]].map(([p,b])=>new j.Vector3(t+p*i-b*l,r+p*l+b*i,0))}intersectsBounds(e,t,r,n){return!e||!t?!0:e[0]<=n[0]&&t[0]>=r[0]&&e[1]<=n[1]&&t[1]>=r[1]}isUsableViewport(e){return e.visible!==!1&&Array.isArray(e.paperCenter)&&Array.isArray(e.viewCenter)&&Number(e.paperHeight)>0&&Number(e.viewHeight)>0&&Number(e.viewWidth)>0}isVisibleInViewport(e,t){const r=this.getRenderItemLayerDeps(e);for(const n of r){const s=this.model.layers.find(a=>a.name===n);if(s&&(s.visible===!1||s.frozen===!0)||t.has(n))return!1}return!0}getRenderItemLayerDeps(e){const t=e.layerDeps&&e.layerDeps.length>0?e.layerDeps:[e.layer];return Array.from(new Set(t.map(r=>String(r??"")).filter(Boolean)))}clipRenderItemToPolygon(e,t){if(e.kind==="line"){const s=this.clipLinePoints(e.points??[],t);if(s.length===0)return null;const a=this.getPointsBounds(s);return{...e,points:s,min:a.min,max:a.max}}const r=this.clipGeometry(e.geometry,t);if(!r)return null;const n=this.getGeometryBounds(r);return{...e,geometry:r,min:n.min,max:n.max}}clipLinePoints(e,t){const r=[];for(let n=0;n<e.length-1;n+=2)this.clipSegmentByPolygon(e[n],e[n+1],t).forEach(s=>{r.push(s[0],s[1])});return r}clipSegmentByPolygon(e,t,r){const n=t.clone().sub(e),s=[0,1];for(let l=0;l<r.length;l+=1){const c=this.getSegmentIntersectionParameter(e,t,r[l],r[(l+1)%r.length]);c!=null&&c>1e-9&&c<1-1e-9&&s.push(c)}const a=Array.from(new Set(s.map(l=>Number(l.toFixed(12))))).sort((l,c)=>l-c),i=[];for(let l=0;l<a.length-1;l+=1){const c=a[l],p=a[l+1];if(p-c<1e-10)continue;const b=e.clone().add(n.clone().multiplyScalar((c+p)*.5));this.isPointInPolygon(b,r)&&i.push([e.clone().add(n.clone().multiplyScalar(c)),e.clone().add(n.clone().multiplyScalar(p))])}return i}getSegmentIntersectionParameter(e,t,r,n){const s=t.x-e.x,a=t.y-e.y,i=n.x-r.x,l=n.y-r.y,c=s*l-a*i;if(Math.abs(c)<1e-12)return null;const p=r.x-e.x,b=r.y-e.y,x=(p*l-b*i)/c,h=(p*a-b*s)/c;return x>=-1e-9&&x<=1+1e-9&&h>=-1e-9&&h<=1+1e-9?j.MathUtils.clamp(x,0,1):null}isPointInPolygon(e,t){let r=!1;for(let n=0,s=t.length-1;n<t.length;s=n,n+=1){const a=t[n],i=t[s];if(this.isPointOnSegment(e,a,i))return!0;a.y>e.y!=i.y>e.y&&e.x<(i.x-a.x)*(e.y-a.y)/(i.y-a.y)+a.x&&(r=!r)}return r}isPointOnSegment(e,t,r){const n=(r.x-t.x)*(e.y-t.y)-(r.y-t.y)*(e.x-t.x);if(Math.abs(n)>1e-8)return!1;const s=(e.x-t.x)*(r.x-t.x)+(e.y-t.y)*(r.y-t.y),a=(r.x-t.x)**2+(r.y-t.y)**2;return s>=-1e-8&&s<=a+1e-8}clipGeometry(e,t){if(!e?.attributes?.position)return null;const r=e.index?e.toNonIndexed():e,n=r.attributes.position,s=r.attributes.uv,a=!!s,i=[],l=[];for(let p=0;p<n.count;p+=3){const b=[0,1,2].map(h=>({position:new j.Vector3(n.getX(p+h),n.getY(p+h),n.getZ(p+h)),uv:a?new j.Vector2(s.getX(p+h),s.getY(p+h)):void 0})),x=this.clipPolygonVertices(b,t);if(!(x.length<3))for(let h=1;h<x.length-1;h+=1)[x[0],x[h],x[h+1]].forEach(m=>{i.push(m.position.x,m.position.y,m.position.z),a&&m.uv&&l.push(m.uv.x,m.uv.y)})}if(r!==e&&r.dispose(),i.length===0)return null;const c=new j.BufferGeometry;return c.setAttribute("position",new j.Float32BufferAttribute(i,3)),a&&c.setAttribute("uv",new j.Float32BufferAttribute(l,2)),c.computeVertexNormals(),c}clipPolygonVertices(e,t){const r=this.getPolygonOrientation(t);let n=e;for(let s=0;s<t.length;s+=1){const a=t[s],i=t[(s+1)%t.length],l=n;if(n=[],l.length===0)break;let c=l[l.length-1],p=this.isInsideClipEdge(c.position,a,i,r);l.forEach(b=>{const x=this.isInsideClipEdge(b.position,a,i,r);x!==p&&n.push(this.intersectClipEdge(c,b,a,i,r)),x&&n.push(b),c=b,p=x})}return n}isInsideClipEdge(e,t,r,n){const s=r.x-t.x,a=r.y-t.y;return n*(s*(e.y-t.y)-a*(e.x-t.x))>=-1e-9}intersectClipEdge(e,t,r,n,s){const a=n.x-r.x,i=n.y-r.y,l=s*(a*(e.position.y-r.y)-i*(e.position.x-r.x)),c=s*(a*(t.position.y-r.y)-i*(t.position.x-r.x)),p=Math.abs(l-c)<1e-12?0:l/(l-c);return{position:e.position.clone().lerp(t.position,p),uv:e.uv&&t.uv?e.uv.clone().lerp(t.uv,p):void 0}}getPolygonOrientation(e){let t=0;for(let r=0;r<e.length;r+=1){const n=e[r],s=e[(r+1)%e.length];t+=n.x*s.y-s.x*n.y}return t>=0?1:-1}getGeometryBounds(e){return e.computeBoundingBox(),{min:e.boundingBox?.min.clone()??new j.Vector3,max:e.boundingBox?.max.clone()??new j.Vector3}}getPointsBounds(e){const t=new j.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),r=new j.Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);return e.forEach(n=>{t.min(n),r.max(n)}),{min:t,max:r}}getLayoutExtents(e){const t=e.paper,r=t?.viewExtent??t?.viewExtents;if(r?.min&&r?.max)return{min:r.min,max:r.max};if(t?.min&&t?.max)return{min:t.min,max:t.max};if(t?.paperWidth&&t?.paperHeight)return{min:[0,0,0],max:[t.paperWidth,t.paperHeight,0]}}getLayoutViewRotation(e){const t=Number(e.paper?.viewRotation??0);return Number.isFinite(t)?t:0}async loadFont(e){const t=this.collectTextChars(e),r=this.engine.options?.fontFile,n=r?Re.fromArrayBuffer(await r.arrayBuffer(),{chars:t}):await Re.fromUrl(this.engine.options?.fontUrl??mt("/fonts/simfang.ttf",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ae&&Ae.tagName.toUpperCase()==="SCRIPT"&&Ae.src||new URL("dwg-preview.umd.js",document.baseURI).href),{chars:t});return Re.toThreeFont(n)}collectTextChars(e){const t=new Set([" "]),r=n=>{Array.isArray(n)&&n.forEach(s=>{if(typeof s?.text=="string")for(const a of this.normalizeText(s.text).replace(/\n/g," "))t.add(a)})};return r(e.entities),(e.blocks??[]).forEach(n=>r(n?.entities)),Array.from(t).join("")}normalizeText(e){return String(e??"").replace(/\r\n/g,`
|
|
119
|
-
`).replace(/\r/g,`
|
|
120
|
-
`)}afterModelLoaded(e,t={}){try{const s=t.fitView??!0;s&&e?this.engine.cameraModule2d?.fitToExtents(e):s&&this.engine.fitToView()}catch{}this.engine.layerManager||(this.engine.layerManager=new Ri(this.engine)),this.engine.layerManager._loadLayers();const r=this.engine.scene?.background,n=r instanceof j.Color?r.getHex():this.engine.options?.backgroundColor??1710618;this.engine.modelToolModule2d?.updateColorsForBackground(n),this.engine.layerManager.refresh(),this.engine.events?.trigger(et.ModelLoaded,{})}createEmptyModel(){return{layers:[],modelMap:new Map,hatchMap:new Map,textMap:new Map,imageMap:new Map,nodeMap:new Map,textItems:[]}}clearModelGroup(){for(this.engine.modelGroup.rotation.set(0,0,0),this.workspaceCache.clear();this.engine.modelGroup.children.length>0;){const e=this.engine.modelGroup.children[0];this.engine.modelGroup.remove(e),this.disposeObject3d(e)}}disposeObject3d(e){e.traverse(t=>{this.disposeGeometry(t.geometry),this.disposeGeometryList(t.geometrys),this.disposeMaterial(t.material),this.disposeMaterial(t.materialClone),t.geometrys=void 0,t.clonePoints=void 0,t.materialClone=void 0})}disposeGeometry(e){e?.dispose?.()}disposeGeometryList(e){e?.forEach(t=>this.disposeGeometry(t))}disposeMaterial(e){if(Array.isArray(e)){e.forEach(t=>this.disposeMaterial(t));return}e&&(Object.values(e).forEach(t=>{t?.isTexture&&t.dispose?.()}),e.dispose?.())}_emitProgress(e,t){this.engine.events?.trigger(et.ModelLoadProgress,{progress:e,text:t})}getData(){return this.data}getEntitiesByLayer(e){return this.data?this.data.entities.filter(t=>t.layer===e):[]}getLayers(){return this.data?this.data.layers:[]}clear(){this.data=null,this.engine.dwgData=null,this.model=this.createEmptyModel(),this.clearModelGroup(),this.activeWorkspace={type:"model",name:"模型"},this.workspaceViews.clear(),this.revokeLocalModelResource()}dispose(){this.clear()}revokeLocalModelResource(){this.localModelResource?.revoke(),this.localModelResource=null}getLocalModelName(e){return(e[0]?.webkitRelativePath||e[0]?.name||"model").replace(/\\/g,"/").split("/").filter(Boolean)[0]?.replace(/\.[^.]+$/,"")||"model"}}class zi{constructor(e,t,r){this.camera=e,this.renderer=t,this.scene=r,this.raycaster=new j.Raycaster}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new j.Vector2(t.x,t.y)}worldToScreen(e){const t=new j.Vector3;return t.copy(e).project(this.camera),t.x=t.x*this.renderer.domElement.clientWidth*.5,t.y=-t.y*this.renderer.domElement.clientHeight*.5,t.z=(t.z+1)*.5,t.x+=this.renderer.domElement.clientWidth*.5,t.y+=this.renderer.domElement.clientHeight*.5,new j.Vector2(t.x,t.y)}worldToScreenIfVisible(e){if(this.camera.updateMatrixWorld(!0),this.camera instanceof j.PerspectiveCamera&&e.clone().applyMatrix4(this.camera.matrixWorldInverse).z>=0)return null;const t=e.clone().project(this.camera);if(!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.z)||t.z<-1||t.z>1)return null;const r=this.renderer.domElement.clientWidth,n=this.renderer.domElement.clientHeight;return new j.Vector2(t.x*r*.5+r*.5,-t.y*n*.5+n*.5)}screenToNormalized(e,t){const r=this.renderer.domElement.clientWidth,n=this.renderer.domElement.clientHeight,s=e/r*2-1,a=-(t/n*2-1);return new j.Vector2(s,a)}screenToWorld(e,t,r){if(!this.scene&&!r)return console.warn("WorldToScreen: 需要提供 scene 或 objects 参数才能进行屏幕坐标转世界坐标"),null;const n=this.screenToNormalized(e,t);this.raycaster.setFromCamera(n,this.camera);const s=r||this.scene.children,a=this.raycaster.intersectObjects(s,!0);return a.length>0?a[0].point:null}screenToWorldWithDepth(e,t,r=0){const n=this.screenToNormalized(e,t);this.raycaster.setFromCamera(n,this.camera);const s=new j.Vector3;return this.raycaster.ray.at(r,s),s}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}class ha{engine;pickBoxElementIds=[];worldToScreen;invisibleMaterial=new j.MeshBasicMaterial({visible:!1});maxHoverLineCoordinateCount=3e4;maxHoverMeshVertexCount=3e4;constructor(e){this.engine=e,this.pickBoxElementIds=[],this.worldToScreen=new zi(e.camera,e.renderer,e.scene)}init(){this.pickBoxElementIds=[]}pick2d(e,t){const r=[],n=new j.Vector2(t.offsetX,t.offsetY);this.init(),this.collectPickCandidates(e);const s=[];this.pickBoxElementIds.forEach(i=>{(this.engine.loaderModule2d.model.nodeMap.get(String(i))??this.engine.loaderModule2d.model.nodeMap.get(i))?.forEach(c=>{if(c==null)return;const p=this.getNodeObject(c);if(p!=null&&this.isNodePickable(c,p)&&!(t?.isHover===!0&&this.isLargeHoverNode(c,p)))if(p instanceof j.LineSegments){p.updateWorldMatrix(!0,!1);const x=p.clonePoints.slice(c.indexes[1],c.indexes[2]),h=this.readLineWorldPoints(x,p.matrixWorld);if(h.length===0)return;const m=new j.Box3().setFromPoints(h),d=e.ray.intersectsBox(m);if(d==null||d===!1)return;const y=[];for(let u=0;u<h.length/2;u+=1){const v=this.worldToScreen.worldToScreen(h[u*2]),E=this.worldToScreen.worldToScreen(h[u*2+1]);v.distanceTo(E)>1&&y.push([v,E])}y.forEach(u=>{const v=this.pointToLineDistance(n,u[0],u[1]);v<10&&s.push({distance:v,linkId:i})})}else{const b=this.getNodeGeometry(p,c);if(!b)return;p.updateWorldMatrix(!0,!1),b.applyMatrix4(p.matrixWorld);const x=new j.Mesh(b,this.invisibleMaterial);x.linkId=i,r.push(x)}})});const a=e.intersectObjects(r,!0);return r.forEach(i=>{i.geometry?.dispose?.()}),a.length>0?a[0].object.linkId:s.length>0?(s.sort((i,l)=>i.distance-l.distance),s[0].linkId):null}getNodeObject(e){return e?.object??e?.group?.children?.[e.indexes?.[0]]??this.engine.modelGroup.children[e.indexes?.[0]]}readLineWorldPoints(e,t){const r=[];for(let n=0;n<e.length;n+=3)r.push(new j.Vector3(e[n],e[n+1],e[n+2]).applyMatrix4(t));return r}collectPickCandidates(e){if(this.engine.isModelSpaceActive?.()!==!1){this.RecurrentIteration(e,this.engine.dwgData?.octree);return}const t=this.engine.loaderModule2d?.model?.nodeMap;t&&(this.pickBoxElementIds=Array.from(t.keys()).filter(r=>this.isElementPickable(r)))}getNodeGeometry(e,t){if(Array.isArray(e.geometrys)&&e.geometrys[t.indexes[1]])return e.geometrys[t.indexes[1]].clone();const r=e.geometry,n=r?.groups?.[t.indexes[1]];if(!r||!n)return null;const s=new j.BufferGeometry;return Object.keys(r.attributes).forEach(a=>{const i=r.getAttribute(a),l=i.itemSize,c=i.array,p=n.start*l,b=(n.start+n.count)*l;s.setAttribute(a,new j.BufferAttribute(c.slice(p,b),l,i.normalized))}),s}RecurrentIteration(e,t){if(t==null)return;const r=[t];for(;r.length>0;){const n=r.pop();if(!n)continue;const s=this.getBox3(n);if(s&&!e.ray.intersectsBox(s))continue;(n.elements??[]).forEach(l=>{this.isElementPickable(l)&&this.pickBoxElementIds.push(l)});const i=n.children??[];for(let l=i.length-1;l>=0;l-=1)r.push(i[l])}}getBox3(e){const t=this.toVector3(e.min),r=this.toVector3(e.max);return!t||!r?null:new j.Box3(new j.Vector3(Math.min(t.x,r.x),Math.min(t.y,r.y),Math.min(t.z,r.z)),new j.Vector3(Math.max(r.x,t.x),Math.max(r.y,t.y),Math.max(r.z,t.z)))}toVector3(e){return Array.isArray(e)?new j.Vector3(e[0]??0,e[1]??0,e[2]??0):e&&typeof e=="object"?new j.Vector3(e.X??e.x??0,e.Y??e.y??0,e.Z??e.z??0):null}isElementPickable(e){let t=this.engine.engineStatus2d.hideModels;return!(t!=null&&t.includes(e)||(t=this.engine.engineStatus2d.highlightModels,t!=null&&t.includes(e))||this.engine.layerManager?.isModelVisibleByLayer?.(e)===!1)}isNodePickable(e,t){return t?.visible===!1?!1:this.getNodeLayerDeps(e).every(r=>this.engine.layerManager?.isLayerVisible?.(r)!==!1)}getNodeLayerDeps(e){const t=Array.isArray(e?.layerDeps)&&e.layerDeps.length>0?e.layerDeps:[e?.layer];return Array.from(new Set(t.map(r=>String(r??"")).filter(Boolean)))}isLargeHoverNode(e,t){return t instanceof j.LineSegments?Math.max(0,(e.indexes?.[2]??0)-(e.indexes?.[1]??0))>this.maxHoverLineCoordinateCount:(t?.geometry?.groups?.[e.indexes?.[1]]?.count??0)>this.maxHoverMeshVertexCount}pointToLineDistance(e,t,r){const n=new j.Vector2().subVectors(r,t),s=n.lengthSq();if(s<1e-10)return e.distanceTo(t);const a=new j.Vector2().subVectors(e,t),i=j.MathUtils.clamp(a.dot(n)/s,0,1),l=new j.Vector2().copy(n).multiplyScalar(i).add(t);return e.distanceTo(l)}}class da{engine;widgetContainer=null;widgetCanvas=null;widgetCtx=null;widgetSize=50;isDragging=!1;isRotating=!1;lastMouseX=0;lastMouseY=0;widgetX=this.widgetSize/2+5;widgetY=this.widgetSize/2+5;widgetRotation=0;rotationStartAngle=null;widgetRotationStart=0;worldToScreen;currentWordPosition=null;currentWordRotation=null;lastCameraWorldPosition=null;enabled=!1;constructor(e){this.engine=e,this.worldToScreen=new zi(e.camera,e.renderer,e.scene),this.initWidget();let t=this;this.engine.controlModule2d.panControls.addEventListener("change",()=>{t.updateViewPoint()})}toggle(){return this.enabled=!this.enabled,this.enabled?(this.active(),this.widgetContainer&&(this.widgetContainer.style.display="block")):(this.disActive(),this.widgetContainer&&(this.widgetContainer.style.display="none")),this.enabled}isEnabled(){return this.enabled}initWidget(){const e=window.devicePixelRatio||1;this.widgetContainer=document.createElement("div"),this.widgetContainer.className="MapController",this.widgetContainer.style.position="absolute",this.widgetContainer.style.width=`${this.widgetSize}px`,this.widgetContainer.style.height=`${this.widgetSize}px`,this.widgetContainer.style.border="2px solid rgba(255, 255, 255, 0.4)",this.widgetContainer.style.borderRadius="50%",this.widgetContainer.style.overflow="hidden",this.widgetContainer.style.backgroundColor="rgba(26, 26, 46, 0.85)",this.widgetContainer.style.cursor="crosshair",this.widgetContainer.style.userSelect="none",this.widgetContainer.style.pointerEvents="auto",this.syncWidgetPosition(),this.widgetCanvas=document.createElement("canvas"),this.widgetContainer.className="MapController",this.widgetCanvas.width=this.widgetSize*e,this.widgetCanvas.height=this.widgetSize*e,this.widgetCanvas.style.position="absolute",this.widgetCanvas.style.top="0",this.widgetCanvas.style.left="0",this.widgetCanvas.style.width=`${this.widgetSize}px`,this.widgetCanvas.style.height=`${this.widgetSize}px`,this.widgetCanvas.style.pointerEvents="auto",this.widgetContainer.style.zIndex="1000",this.widgetContainer.appendChild(this.widgetCanvas),this.widgetCtx=this.widgetCanvas.getContext("2d"),this.widgetCtx&&this.widgetCtx.scale(e,e),this.setupWidgetEvents(),this.engine.container&&this.engine.container.appendChild(this.widgetContainer),!this.enabled&&this.widgetContainer&&(this.widgetContainer.style.display="none"),this.drawWidget()}setupWidgetEvents(){this.widgetContainer&&(this.widgetContainer.addEventListener("mousedown",this.onWidgetCanvasMouseDown),this.widgetCanvas&&this.widgetCanvas.addEventListener("mousedown",this.onWidgetCanvasMouseDown),window.addEventListener("mousemove",this.onWidgetMouseMove),window.addEventListener("mouseup",this.onWidgetMouseUp),this.widgetContainer.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation()}),this.widgetCanvas&&this.widgetCanvas.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation()}))}onWidgetCanvasMouseDown=e=>{this.widgetContainer&&(e.button==0?(this.isDragging=!1,this.isRotating=!0):(this.isDragging=!0,this.isRotating=!1),this.captureRotationBaseline(e),this.lastMouseX=e.clientX,this.lastMouseY=e.clientY,this.widgetContainer&&(this.widgetContainer.style.cursor="alias"),e.preventDefault(),e.stopPropagation())};onWidgetMouseMove=e=>{if(!this.isDragging&&!this.isRotating)return;const t=e.clientX-this.lastMouseX,r=e.clientY-this.lastMouseY;if(this.isDragging)this.widgetX+=t,this.widgetY+=r,console.log(`[LinkView2d3d] 拖动位置更新: x=${this.widgetX.toFixed(0)}, y=${this.widgetY.toFixed(0)}`),this.syncWidgetPosition(),this.handleWidgetPositionControl();else if(this.isRotating){const n=this.calculatePointerAngle(e);if(n!==null){this.rotationStartAngle===null&&(this.rotationStartAngle=n,this.widgetRotationStart=this.widgetRotation);const s=n-this.rotationStartAngle;this.widgetRotation=this.widgetRotationStart+s,console.log(`[LinkView2d3d] 旋转角度更新: ${(this.widgetRotation*180/Math.PI).toFixed(1)}°`),this.drawWidget(),this.handleWidgetRotationControl()}}this.lastMouseX=e.clientX,this.lastMouseY=e.clientY};onWidgetMouseUp=()=>{this.isDragging&&console.log(`[LinkView2d3d] 拖动结束,最终位置: x=${this.widgetX.toFixed(0)}, y=${this.widgetY.toFixed(0)}`),this.isRotating&&console.log(`[LinkView2d3d] 旋转结束,最终角度: ${(this.widgetRotation*180/Math.PI).toFixed(1)}°`),this.isDragging=!1,this.isRotating=!1,this.rotationStartAngle=null,this.widgetContainer&&(this.widgetContainer.style.cursor="crosshair")};drawWidget(){const e=this.widgetCtx;if(!e)return;const t=this.widgetSize/2,r=this.widgetSize/2;e.clearRect(0,0,this.widgetSize,this.widgetSize),e.save(),e.translate(t,r),e.rotate(this.widgetRotation);const n=36,s=Math.PI/10,a=e.createRadialGradient(0,0,2,0,0,n);a.addColorStop(0,"rgba(0, 230, 130, 0.9)"),a.addColorStop(1,"rgba(0, 230, 130, 0)");const i=-Math.sin(s)*n,l=-Math.cos(s)*n,c=Math.sin(s)*n,p=-Math.cos(s)*n;e.beginPath(),e.moveTo(0,0),e.lineTo(i,l),e.lineTo(c,p),e.closePath(),e.fillStyle=a,e.fill(),e.fillStyle="rgba(255, 255, 255, 0.95)",e.strokeStyle="rgba(0, 200, 110, 0.9)",e.lineWidth=1.5,e.beginPath(),e.arc(0,0,4,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}active(){window.addEventListener("D3ViewUpdate",this.listenViewUpdate)}disActive(){window.removeEventListener("D3ViewUpdate",this.listenViewUpdate)}disposeWidget(){this.widgetContainer&&this.widgetContainer.removeEventListener("mousedown",this.onWidgetMouseDown),this.widgetCanvas&&this.widgetCanvas.removeEventListener("mousedown",this.onWidgetCanvasMouseDown),window.removeEventListener("mousemove",this.onWidgetMouseMove),window.removeEventListener("mouseup",this.onWidgetMouseUp),this.widgetContainer?.remove(),this.widgetContainer=null,this.widgetCanvas=null,this.widgetCtx=null}listenViewUpdate=e=>{console.log("[LinkView2d3d] 收到视图更新事件",e),e=e.detail,e&&e.position&&(this.lastCameraWorldPosition=new j.Vector3(e.position.x,e.position.y,e.position.z),this.currentWordPosition=new j.Vector3(e.position.x,-e.position.z,0)),e&&typeof e.rotation=="number"&&(this.currentWordRotation=e.rotation),this.updateViewPoint()};updateViewPoint(){if(this.currentWordPosition){let e=this.worldToScreen.worldToScreen(this.currentWordPosition);this.widgetX=e.x,this.widgetY=e.y,this.syncWidgetPosition()}this.currentWordRotation!==null&&(this.widgetRotation=this.currentWordRotation,this.drawWidget())}syncWidgetPosition(){if(!this.widgetContainer)return;const e=this.widgetSize/2;this.widgetContainer.style.left=`${this.widgetX-e}px`,this.widgetContainer.style.top=`${this.widgetY-e}px`}handleWidgetPositionControl(){const e=this.getWidgetWorldPosition();e&&(this.currentWordPosition=e,this.dispatchViewControl("move",{position2d:e}))}handleWidgetRotationControl(){this.currentWordRotation=this.widgetRotation,this.dispatchViewControl("rotate",{rotation:this.widgetRotation})}getWidgetWorldPosition(){if(!this.engine?.cameraModule2d?.screenToWorld)return null;const e=this.engine.cameraModule2d.screenToWorld(this.widgetX,this.widgetY);return e?new j.Vector3(e.x,e.y,0):null}dispatchViewControl(e,t){const r=!!t.position2d,n=typeof t.rotation=="number";if(!r&&!n)return;if(r&&!this.lastCameraWorldPosition){console.warn("[LinkView2d3d] 未获取到 3D 相机位置,暂不推送位置控制");return}const s={source:"LinkView2d3d",mode:e};if(t.position2d&&this.lastCameraWorldPosition){const a=this.lastCameraWorldPosition.y,i=-t.position2d.y;s.position={x:t.position2d.x,y:a,z:i},this.lastCameraWorldPosition=new j.Vector3(t.position2d.x,a,i)}n&&(s.rotation=t.rotation),window.dispatchEvent(new CustomEvent("D2ViewControl",{detail:s}))}captureRotationBaseline(e){const t=this.calculatePointerAngle(e);if(t===null){this.rotationStartAngle=null;return}this.rotationStartAngle=t,this.widgetRotationStart=this.widgetRotation}calculatePointerAngle(e){if(!this.widgetContainer)return null;const t=this.widgetContainer.getBoundingClientRect(),r=t.left+t.width/2,n=t.top+t.height/2;return Math.atan2(e.clientX-r,n-e.clientY)}}class fa{engine;enabled=!1;constructor(e){this.engine=e}toggle(){return this.enabled=!this.enabled,this.enabled?this.active():this.disActive(),this.enabled}isEnabled(){return this.enabled}active(){window.addEventListener("D3ElementClick",this.listenElementClick)}disActive(){window.removeEventListener("D3ElementClick",this.listenElementClick)}listenElementClick=e=>{const t=String(e?.detail?.id),r=this.engine.loaderModule2d?.model?.nodeMap?.get(t),n=this.getNodesWorldBounds(r);if(n){this.engine.modelToolModule2d.highlightModel([t]),this.engine.cameraModule2d.fitToExtents({min:[n.min.x,n.min.y],max:[n.max.x,n.max.y]},3);return}this.engine.modelToolModule2d.unhighlightAllModels()};getNodesWorldBounds(e){if(!Array.isArray(e)||e.length===0)return null;const t=new j.Box3;let r=!1;return e.forEach(n=>{const s=this.getNodeWorldBounds(n);s&&(t.union(s),r=!0)}),r?t:null}getNodeWorldBounds(e){if(!e?.min||!e?.max)return null;const t=this.getNodeObject(e);if(!t||t.visible===!1)return null;t.updateWorldMatrix?.(!0,!1);const r=new j.Box3(e.min.clone(),e.max.clone()).applyMatrix4(t.matrixWorld);return!Number.isFinite(r.min.x)||!Number.isFinite(r.min.y)||!Number.isFinite(r.max.x)||!Number.isFinite(r.max.y)?null:r}getNodeObject(e){return e?.object??e?.group?.children?.[e.indexes?.[0]]??this.engine.modelGroup?.children?.[e.indexes?.[0]]}}class pa{engine;highlightMaterial;hideMaterial;translucentMaterial;lightBackgroundWhiteColor=0;darkBackgroundWhiteColor=16777215;maxHoverLineCoordinateCount=3e4;maxHoverMeshVertexCount=3e4;constructor(e){this.engine=e,this.highlightMaterial=new j.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:j.DoubleSide}),this.hideMaterial=new j.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:j.DoubleSide}),this.translucentMaterial=new j.MeshBasicMaterial({color:this.getHoverHighlightColor(),depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:j.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof j.InstancedMesh)return;const t=e.materialClone.clone(),r=Array.isArray(e.geometrys)&&e.geometrys.length>0?Bt(e.geometrys,!0):e.geometry;r.groups.forEach(n=>{n.materialIndex=0}),e.geometry=r,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}getNodeObject(e){return e?.object??e?.group?.children?.[e.indexes?.[0]]??this.engine.modelGroup.children[e.indexes?.[0]]}forEachNode(e,t){(e??[]).forEach(r=>{const n=this.engine.loaderModule2d.model.nodeMap.get(String(r))??this.engine.loaderModule2d.model.nodeMap.get(r);n?.forEach(s=>{if(s==null||s.indexes==null)return;const a=this.getNodeObject(s);a!=null&&t(s,a,r)})})}getHoverHighlightColor(){const e=this.engine.scene?.background;return e instanceof j.Color?.299*e.r+.587*e.g+.114*e.b>.5?6735871:16777215:this.engine.themeManager?.getTheme?.()==="light"?6735871:16777215}updateColorsForBackground(e){const t=this.isLightBackground(e);this.engine.modelGroup?.traverse?.(r=>{this.updateObjectMaterialColor(r,t),this.updateVertexColors(r,t)})}getDisplayColor(e){return this.isCurrentBackgroundLight()&&this.isWhiteColor(e)?this.lightBackgroundWhiteColor:e}updateObjectMaterialColor(e,t){const r=this.resolveOriginalColor(e);if(r==null||!this.isWhiteColor(r))return;const n=t?this.lightBackgroundWhiteColor:this.darkBackgroundWhiteColor,s=a=>{a?.color&&a.color.setHex(n)};Array.isArray(e.material)?e.material.forEach(s):s(e.material),s(e.materialClone)}updateVertexColors(e,t){const r=e.geometry,n=r?.getAttribute("color");if(!r||!n)return;e.userData.originalColorAttribute||(e.userData.originalColorAttribute=n.clone());const s=e.userData.originalColorAttribute,a=n.array;for(let i=0;i<s.count;i+=1){const l=s.getX(i),c=s.getY(i),p=s.getZ(i),b=t&&this.isWhiteRgb(l,c,p);a[i*3]=b?0:l,a[i*3+1]=b?0:c,a[i*3+2]=b?0:p}n.needsUpdate=!0}resolveOriginalColor(e){if(typeof e.userData?.originalDisplayColor=="number")return e.userData.originalDisplayColor;const[t,r]=String(e.name??"").split("||");let n=Number.parseInt(r);return(n===0||Number.isNaN(n))&&(n=this.engine.loaderModule2d?.model?.layers?.find(a=>a.name===t)?.color),typeof n!="number"||Number.isNaN(n)?null:(e.userData.originalDisplayColor=n,n)}isCurrentBackgroundLight(){const e=this.engine.scene?.background;return e instanceof j.Color?.299*e.r+.587*e.g+.114*e.b>.5:this.engine.themeManager?.getTheme?.()==="light"}isLightBackground(e){const t=new j.Color(e);return .299*t.r+.587*t.g+.114*t.b>.5}isWhiteColor(e){return(e&16777215)===16777215}isWhiteRgb(e,t,r){return e>.99&&t>.99&&r>.99}highlightModelHover(e){e=this.filterVisibleLayerModels(e),e=this.filterHoverableModels(e),this.unHighlightModelHover(),e.length!==0&&(this.engine.engineStatus2d.highlightHoverModels=e,this.translucentMaterial.color.setHex(this.getHoverHighlightColor()),this.forEachNode(e,(t,r)=>{if(r instanceof j.LineSegments){const n=this.getLineNodePoints(t,r);this.highLightRenderLineHover(n)}else{this.split_merge_model(r);const n=r.geometry?.groups?.[t.indexes[1]];n&&(n.materialIndex=2)}}))}unHighlightModelHover(){const e=this.engine.engineStatus2d.highlightHoverModels??[],t=new Set((this.engine.engineStatus2d.highlightModels??[]).map(r=>String(r)));this.forEachNode(e,(r,n,s)=>{if(n instanceof j.LineSegments)return;const a=n.geometry?.groups?.[r.indexes[1]];a&&(a.materialIndex=t.has(String(s))?1:0)}),this.engine.engineStatus2d.highlightHoverModels=[],this.unhighLightRenderLineHover()}highlightModel(e){e=this.filterVisibleLayerModels(e),e.length!==0&&(this.unHighlightModelHover(),this.engine.engineStatus2d.highlightModels=e,this.forEachNode(e,(t,r)=>{if(r instanceof j.LineSegments){const n=this.getLineNodePoints(t,r);this.highLightRenderLine(n)}else this.split_merge_model(r),r.geometry.groups[t.indexes[1]].materialIndex=1}))}unhighlightModel(e){this.forEachNode(e,(t,r)=>{r instanceof j.LineSegments||(r.geometry.groups[t.indexes[1]].materialIndex=0)}),this.unhighLightRenderLine()}unhighlightAllModels(e=!0){this.engine.engineStatus2d.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus2d.highlightModels=[])}hideModel(e){this.unhighlightAllModels(),this.forEachNode(e,(t,r)=>{if(r instanceof j.LineSegments){const n=r.geometry.attributes.position.array;for(let s=t.indexes[1];s<t.indexes[2];s+=1)n[s]=NaN;r.geometry.attributes.position.needsUpdate=!0}else this.split_merge_model(r),r.geometry.groups[t.indexes[1]].materialIndex=-1}),this.engine.engineStatus2d.hideModels.push(...e)}showModel(e){this.forEachNode(e,(t,r)=>{if(r instanceof j.LineSegments){const n=r.geometry.attributes.position.array,s=r;for(let a=t.indexes[1];a<t.indexes[2];a+=1)n[a]=s.clonePoints[a];r.geometry.attributes.position.needsUpdate=!0}else this.split_merge_model(r),r.geometry.groups[t.indexes[1]].materialIndex=0}),this.engine.engineStatus2d.hideModels=[]}showAllModels(){this.engine.engineStatus2d.hideModels&&this.engine.engineStatus2d.hideModels.length>0&&this.showModel(this.engine.engineStatus2d.hideModels),this.engine.engineStatus2d.hideModels=[],this.unhighlightAllModels()}getLineNodePoints(e,t){const r=t.clonePoints.slice(e.indexes[1],e.indexes[2]);t.updateWorldMatrix(!0,!1),this.engine.modelGroup?.updateWorldMatrix?.(!0,!1);const n=new j.Matrix4,s=new j.Matrix4().copy(this.engine.modelGroup.matrixWorld).invert();n.multiplyMatrices(s,t.matrixWorld);const a=[];for(let i=0;i<r.length;i+=3){const l=new j.Vector3(r[i],r[i+1],r[i+2]).applyMatrix4(n);a.push(l.x,l.y,l.z)}return a}highLightRenderLine(e){const t=new j.BufferGeometry;t.setAttribute("position",new j.Float32BufferAttribute(e,3));const r=new j.LineBasicMaterial({color:43775,depthTest:!1,depthWrite:!1}),n=new j.LineSegments(t,r);n.name="HighLight",n.renderOrder=999,this.engine.modelGroup.add(n)}unhighLightRenderLine(){this.engine.modelGroup.children.filter(e=>e.name==="HighLight").forEach(e=>{this.engine.modelGroup.remove(e),this.disposeTemporaryObject(e)})}highLightRenderLineHover(e){const t=new j.BufferGeometry;t.setAttribute("position",new j.Float32BufferAttribute(e,3));const r=new j.LineBasicMaterial({color:this.getHoverHighlightColor(),depthTest:!1,depthWrite:!1}),n=new j.LineSegments(t,r);n.name="HighLightHover",n.renderOrder=999,this.engine.modelGroup.add(n)}unhighLightRenderLineHover(){this.engine.modelGroup.children.filter(e=>e.name==="HighLightHover").forEach(e=>{this.engine.modelGroup.remove(e),this.disposeTemporaryObject(e)})}disposeTemporaryObject(e){e.geometry?.dispose?.();const t=e.material,r=n=>{n===this.highlightMaterial||n===this.translucentMaterial||n===this.hideMaterial||n?.dispose?.()};Array.isArray(t)?t.forEach(r):r(t)}filterVisibleLayerModels(e){return(e??[]).filter(t=>this.engine.layerManager?.isModelVisibleByLayer?.(t)!==!1)}filterHoverableModels(e){return(e??[]).filter(t=>this.isHoverableModel(t))}isHoverableModel(e){const t=this.engine.loaderModule2d.model.nodeMap.get(String(e))??this.engine.loaderModule2d.model.nodeMap.get(e);if(!t||t.length===0)return!1;let r=0,n=0;for(const s of t){if(s==null||s.indexes==null)continue;const a=this.getNodeObject(s);if(a instanceof j.LineSegments){if(r+=Math.max(0,(s.indexes[2]??0)-(s.indexes[1]??0)),r>this.maxHoverLineCoordinateCount)return!1;continue}const i=a?.geometry?.groups?.[s.indexes[1]];if(n+=i?.count??0,n>this.maxHoverMeshVertexCount)return!1}return!0}}function ga(o){const e={mouseMoveFrame:null,latestMouseMoveEvent:null,self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(d,y){e.self!=null&&e.self.disActive!=null&&e.self.type!=d.type&&e.self.disActive(),e.self=d,y==null&&(y={showCatch:!1}),e.options=y},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){o.renderer.domElement.addEventListener("mousedown",i),o.renderer.domElement.addEventListener("mouseup",c),o.renderer.domElement.addEventListener("mousemove",l),o.renderer.domElement.addEventListener("touchstart",b,{passive:!1}),o.renderer.domElement.addEventListener("touchend",h,{passive:!1}),o.renderer.domElement.addEventListener("touchmove",x,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",r)},e.disActive=function(){o.renderer.domElement.removeEventListener("mousedown",i),o.renderer.domElement.removeEventListener("mouseup",c),o.renderer.domElement.removeEventListener("mousemove",l),o.renderer.domElement.removeEventListener("touchstart",b),o.renderer.domElement.removeEventListener("touchend",h),o.renderer.domElement.removeEventListener("touchmove",x),window.removeEventListener("keydown",t),window.removeEventListener("keyup",r),e.mouseMoveFrame!=null&&(cancelAnimationFrame(e.mouseMoveFrame),e.mouseMoveFrame=null,e.latestMouseMoveEvent=null)};function t(d){(d.keyCode===8||d.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),d.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),d.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),d.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),d.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),d.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),d.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),d.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function r(d){d.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),d.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),d.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),d.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),d.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),d.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),d.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function n(d){const y=new j.Vector2,u=o.renderer.domElement.clientWidth,v=o.renderer.domElement.clientHeight;return y.x=d.offsetX/u*2-1,y.y=-(d.offsetY/v)*2+1,y}function s(d){const y=new j.Raycaster,u=n(d);return y.setFromCamera(u,o.camera),y}function a(d,y=!1){const u=s(d);if(d.raycaster=u,y){const v=m(u,d);d.catch=v}}function i(d){d.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new j.Vector3(d.offsetX,d.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(o.engineStatus.isFree=!0,a(d,!0),d.catch!=null&&o.controlModule.orbitControls.origin.set(d.catch.point.x,d.catch.point.y,d.catch.point.z),e.self.handleMouseDown(d)))}function l(d){e.latestMouseMoveEvent=d,e.mouseMoveFrame==null&&(e.mouseMoveFrame=requestAnimationFrame(()=>{const y=e.latestMouseMoveEvent;e.latestMouseMoveEvent=null,e.mouseMoveFrame=null,y&&(y.isHover=!0,a(y,!0),e.self&&e.self.handleMouseMove!=null&&e.self.handleMouseMove(y))}))}function c(d){if(d.button!==0)return;const y=Date.now(),u=y-e.mouseDownTime,v=new j.Vector3(d.offsetX,d.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(a(d,!1),e.self.handleMouseUp(d));const E=v.distanceTo(e.mouseDownPosition);(u<100||E==0)&&e.self&&e.self.handleMouseClick!=null&&(a(d,!0),y-e.lastClickTime<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(d):e.self.handleMouseClick!=null&&e.self.handleMouseClick(d),e.lastClickTime=Date.now())}function p(d){const y=d.touches[0]||d.changedTouches[0];if(!y)return null;const v=o.renderer.domElement.getBoundingClientRect(),E=y.clientX-v.left,T=y.clientY-v.top;return{offsetX:E,offsetY:T,button:0,clientX:y.clientX,clientY:y.clientY,preventDefault:()=>d.preventDefault(),stopPropagation:()=>d.stopPropagation(),originalEvent:d}}function b(d){if(d.preventDefault(),d.touches.length!==1)return;const y=p(d);y&&i(y)}function x(d){if(d.preventDefault(),d.touches.length!==1)return;const y=p(d);y&&l(y)}function h(d){d.preventDefault();const y=p(d);y&&c(y)}function m(d,y){if(o.isModelSpaceActive?.()===!1&&o.isElementLink2d3dEnabled?.()!==!0)return null;var u=o.octreeBox2d.pick2d(d,y);return u==null?null:{point:null,id:u}}return e}class ma{el;xEl;yEl;constructor(e){this.el=document.createElement("div"),this.el.className="engine-2d-mouse-coord";const t=document.createElement("span");t.className="engine-2d-mouse-coord__label",t.textContent="",this.xEl=document.createElement("span"),this.xEl.className="engine-2d-mouse-coord__value",this.xEl.textContent="X: --",this.yEl=document.createElement("span"),this.yEl.className="engine-2d-mouse-coord__value",this.yEl.textContent="Y: --",this.el.appendChild(t),this.el.appendChild(this.xEl),this.el.appendChild(this.yEl),e.appendChild(this.el)}update(e,t){this.xEl.textContent=`X: ${e.toFixed(0)} mm`,this.yEl.textContent=`Y: ${t.toFixed(0)} mm`}reset(){this.xEl.textContent="X: --",this.yEl.textContent="Y: --"}dispose(){this.el.parentElement?.removeChild(this.el)}}var Ki=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelError="model-error",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.Click="click",o.MouseMove="mouse-move",o.CameraChanged="camera-changed",o.CameraIdle="camera-idle",o.EngineFree="engine-free",o.EngineBusy="engine-busy",o.MeasureChanged="measure-changed",o.MeasureClick="measure-click",o.SectionMove="section-move",o))(Ki||{});class ya{engine;behavior;mouseCoordUI=null;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved2d,this.behavior.init(this);const e=this.engine.container;e&&this.engine.options?.showMouseCoordinates!==!1&&(this.mouseCoordUI=new ma(e))}active(){this.behavior.active()}disActive(){this.behavior.disActive()}oldId=null;handleMouseMove(e){if(this.mouseCoordUI&&this.engine.cameraModule2d){const r=this.engine.cameraModule2d.screenToWorld(e.offsetX,e.offsetY);this.mouseCoordUI.update(r.x*1e3,r.y*1e3)}if(!this.canHandleElementInteraction()){this.engine.modelToolModule2d.unHighlightModelHover(),this.oldId=null;return}if(e.catch==null||e.catch.id==null){this.engine.modelToolModule2d.unHighlightModelHover(),this.oldId=null;return}let t=e.catch.id;if(!this.isModelInteractive(t)){this.engine.modelToolModule2d.unHighlightModelHover(),this.oldId=null;return}this.oldId!=t&&(this.engine.modelToolModule2d.highlightModelHover([t]),this.oldId=t)}handelKeyEscDown(e){this.engine.modelToolModule2d.unhighlightAllModels()}handleMouseDoubleClick(e){e.catch!=null&&e.catch.id!=null||(this.engine.modelToolModule2d.unHighlightModelHover(),this.engine.modelToolModule2d.unhighlightAllModels(),this.engine.fitToView())}handleMouseClick(e){if(this.canHandleElementInteraction())if(e.catch!=null&&this.isModelInteractive(e.catch.id)){this.engine.modelToolModule2d.highlightModel([e.catch.id]),this.engine.events.trigger(Ki.Click,e.catch.id);let t=new CustomEvent("D2ElementClick",{detail:{id:e.catch.id}});window.dispatchEvent(t)}else{this.engine.modelToolModule2d.unhighlightAllModels();let t=new CustomEvent("D2ElementClick",{detail:{id:-1}});window.dispatchEvent(t)}}isModelInteractive(e){return this.engine.layerManager?.isModelVisibleByLayer?.(e)!==!1}canHandleElementInteraction(){return this.engine.isElementLink2d3dEnabled?.()===!0}dispose(){this.mouseCoordUI?.dispose(),this.mouseCoordUI=null}}class va{overlay;hLine;vLine;box;canvas;container;style;constructor(e,t,r="full-crosshair"){this.container=e,this.canvas=t,this.style=r,t.style.cursor="none",this.overlay=document.createElement("div"),this.overlay.className=`engine-2d-cad-cursor engine-2d-cad-cursor--${r}`,this.hLine=document.createElement("div"),this.hLine.className="engine-2d-cad-cursor__h",this.vLine=document.createElement("div"),this.vLine.className="engine-2d-cad-cursor__v",this.box=document.createElement("div"),this.box.className="engine-2d-cad-cursor__box",this.overlay.appendChild(this.hLine),this.overlay.appendChild(this.vLine),this.overlay.appendChild(this.box),e.appendChild(this.overlay),this.hide(),this.bindEvents()}bindEvents(){this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseenter",this.onMouseEnter),this.canvas.addEventListener("mouseleave",this.onMouseLeave)}onMouseMove=e=>{this.updateFromMouseEvent(e)};updateFromMouseEvent(e){const t=this.canvas.getBoundingClientRect(),r=e.clientX-t.left,n=e.clientY-t.top;this.hLine.style.top=`${n}px`,this.vLine.style.left=`${r}px`,this.style==="short-crosshair"&&(this.hLine.style.left=`${r}px`,this.vLine.style.top=`${n}px`),this.box.style.left=`${r}px`,this.box.style.top=`${n}px`,this.show()}onMouseEnter=()=>{this.show()};onMouseLeave=()=>{this.hide()};show(){this.overlay.style.visibility="visible"}hide(){this.overlay.style.visibility="hidden"}setBackgroundColor(e){const t=e>>16&255,r=e>>8&255,n=e&255,a=(.299*t+.587*r+.114*n)/255<.5?"rgba(255,255,255,0.85)":"rgba(0,0,0,0.75)";this.container.style.setProperty("--e2d-cursor",a)}dispose(){this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseenter",this.onMouseEnter),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.style.cursor="",this.overlay.parentElement?.removeChild(this.overlay)}}const Hi=[{action:"search",label:"搜索"},{action:"hideElement",label:"隐藏元素",dividerBefore:!0},{action:"showAll",label:"显示全部"},{action:"hideLayer",label:"隐藏图层",dividerBefore:!0},{action:"showAllLayers",label:"显示所有图层"},{action:"layerManage",label:"图层管理",dividerBefore:!0},{action:"toggleBg",label:"切换背景"},{action:"linkElement2d3d",label:"模型联动",dividerBefore:!0},{action:"linkView2d3d",label:"视角关联"}];class xa{menu;container;canvas;onAction;menuItemStates=new Map;constructor(e,t,r,n){this.container=e,this.canvas=t,this.onAction=r,this.menu=this.createMenu(n),e.appendChild(this.menu),this.bindEvents()}createMenu(e){const t=document.createElement("div");return t.className="engine-2d-context-menu",this.resolveMenuItems(e).forEach(r=>{if(r.dividerBefore){const s=document.createElement("div");s.className="engine-2d-context-menu__divider",t.appendChild(s)}const n=document.createElement("div");n.className="engine-2d-context-menu__item",n.textContent=r.label,n.dataset.action=r.action,n.addEventListener("click",()=>{this.hide(),this.onAction(r.action)}),t.appendChild(n)}),t}resolveMenuItems(e){return!e||e.length===0?Hi:e.filter(t=>t.visible!==!1).map(t=>{const r=Hi.find(n=>n.action===t.action);return{action:t.action,label:t.label??r?.label??t.action,dividerBefore:t.dividerBefore??r?.dividerBefore}})}bindEvents(){this.canvas.addEventListener("contextmenu",this.onContextMenu),document.addEventListener("mousedown",this.onDocMouseDown),document.addEventListener("keydown",this.onEscape)}onContextMenu=e=>{e.preventDefault();const t=this.container.getBoundingClientRect();let r=e.clientX-t.left,n=e.clientY-t.top;this.menu.style.left=`${r}px`,this.menu.style.top=`${n}px`,this.menu.classList.add("engine-2d-context-menu--visible"),this.updateMenuItemStyles();const s=this.menu.offsetWidth,a=this.menu.offsetHeight,i=this.container.clientWidth,l=this.container.clientHeight;r+s>i&&(r=i-s-4),n+a>l&&(n=l-a-4),this.menu.style.left=`${r}px`,this.menu.style.top=`${n}px`};onDocMouseDown=e=>{this.menu.contains(e.target)||this.hide()};onEscape=e=>{e.key==="Escape"&&this.hide()};hide(){this.menu.classList.remove("engine-2d-context-menu--visible")}setMenuItemState(e,t){this.menuItemStates.set(e,t)}setMenuItemStates(e){Object.entries(e).forEach(([t,r])=>{this.menuItemStates.set(t,r)})}updateMenuItemStyles(){this.menu.querySelectorAll(".engine-2d-context-menu__item").forEach(t=>{const r=t.dataset.action;this.menuItemStates.get(r)?(t.style.color="#00e682",t.style.fontWeight="bold"):(t.style.color="",t.style.fontWeight="")})}dispose(){this.canvas.removeEventListener("contextmenu",this.onContextMenu),document.removeEventListener("mousedown",this.onDocMouseDown),document.removeEventListener("keydown",this.onEscape),this.menu.parentElement?.removeChild(this.menu)}}class Ca{overlay=null;textEl=null;barEl=null;pctEl=null;constructor(e,t=1){this._build(e,t)}show(e="正在加载...",t=0){this.overlay&&(this.overlay.style.display="flex",this._update(e,t))}update(e,t){this.overlay?.style.display!=="none"&&this._update(e,t)}hide(){this.overlay&&(this.overlay.style.display="none")}_update(e,t){const r=Math.min(100,Math.max(0,Math.round(t)));this.textEl&&(this.textEl.textContent=e),this.barEl&&(this.barEl.style.width=`${r}%`),this.pctEl&&(this.pctEl.textContent=`${r}%`)}_build(e,t){const r=document.createElement("div");r.style.cssText=this._getOverlayStyle(t),this.overlay=r;const n=t===2?this._buildBottomPanel():this._buildCardPanel();r.appendChild(n),e.appendChild(r)}_getOverlayStyle(e){return e===2?`
|
|
121
|
-
position:absolute; inset:0;
|
|
122
|
-
display:none; align-items:flex-end; justify-content:center;
|
|
123
|
-
z-index:200; pointer-events:none;
|
|
124
|
-
`:`
|
|
125
|
-
position:absolute; inset:0;
|
|
126
|
-
display:none; align-items:center; justify-content:center;
|
|
127
|
-
z-index:200;
|
|
128
|
-
`}_buildCardPanel(){const e=document.createElement("div");e.style.cssText=`
|
|
129
|
-
display:flex; flex-direction:column; align-items:center; gap:14px;
|
|
130
|
-
padding:28px 36px;
|
|
131
|
-
background:var(--e2d-bg,#1e1f22);
|
|
132
|
-
border:1px solid var(--e2d-border,rgba(255,255,255,0.12));
|
|
133
|
-
border-radius:8px;
|
|
134
|
-
box-shadow:0 8px 32px var(--e2d-shadow-lg,rgba(0,0,0,0.65));
|
|
135
|
-
min-width:200px;
|
|
136
|
-
font-family:system-ui,sans-serif;
|
|
137
|
-
`;const t=document.createElement("div");t.style.cssText="width:48px; height:48px;",t.innerHTML=`
|
|
138
|
-
<svg width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
|
139
|
-
<style>
|
|
140
|
-
@keyframes _e2d_spin { to { transform: rotate(360deg); } }
|
|
141
|
-
._e2d_ring { transform-origin: 24px 24px; animation: _e2d_spin 0.9s linear infinite; }
|
|
142
|
-
</style>
|
|
143
|
-
<circle cx="24" cy="24" r="19" fill="none"
|
|
144
|
-
stroke="var(--e2d-border2,#333)" stroke-width="3"/>
|
|
145
|
-
<g class="_e2d_ring">
|
|
146
|
-
<circle cx="24" cy="24" r="19" fill="none"
|
|
147
|
-
stroke="var(--e2d-accent,#4fc3f7)" stroke-width="3"
|
|
148
|
-
stroke-dasharray="30 90" stroke-linecap="round"/>
|
|
149
|
-
</g>
|
|
150
|
-
</svg>
|
|
151
|
-
`;const r=document.createElement("div");r.style.cssText=`
|
|
152
|
-
font-size:13px; color:var(--e2d-text2,#ccc);
|
|
153
|
-
text-align:center; white-space:nowrap;
|
|
154
|
-
`,r.textContent="正在加载...",this.textEl=r;const n=document.createElement("div");n.style.cssText=`
|
|
155
|
-
width:160px; height:3px; border-radius:2px;
|
|
156
|
-
background:var(--e2d-border2,#333); overflow:hidden;
|
|
157
|
-
`;const s=document.createElement("div");s.style.cssText=`
|
|
158
|
-
height:100%; width:0%; border-radius:2px;
|
|
159
|
-
background:var(--e2d-accent,#4fc3f7);
|
|
160
|
-
transition:width 0.25s ease;
|
|
161
|
-
`,n.appendChild(s),this.barEl=s;const a=document.createElement("div");return a.style.cssText=`
|
|
162
|
-
font-size:12px; color:var(--e2d-text3,rgba(255,255,255,0.35));
|
|
163
|
-
`,a.textContent="0%",this.pctEl=a,e.appendChild(t),e.appendChild(r),e.appendChild(n),e.appendChild(a),e}_buildBottomPanel(){const e=document.createElement("div");e.style.cssText=`
|
|
164
|
-
width:100%;
|
|
165
|
-
display:flex; flex-direction:column;
|
|
166
|
-
font-family:system-ui,sans-serif;
|
|
167
|
-
background:var(--e2d-float-bg,rgba(0,0,0,0.72));
|
|
168
|
-
border-top:1px solid var(--e2d-float-border,rgba(255,255,255,0.10));
|
|
169
|
-
box-shadow:0 -8px 24px var(--e2d-shadow,rgba(0,0,0,0.38));
|
|
170
|
-
`;const t=document.createElement("div");t.style.cssText=`
|
|
171
|
-
min-height:34px;
|
|
172
|
-
display:flex; align-items:center; justify-content:space-between; gap:16px;
|
|
173
|
-
padding:0 16px;
|
|
174
|
-
`;const r=document.createElement("div");r.style.cssText=`
|
|
175
|
-
min-width:0;
|
|
176
|
-
font-size:12px; line-height:1.4;
|
|
177
|
-
color:var(--e2d-text2,#ccc);
|
|
178
|
-
white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
|
|
179
|
-
`,r.textContent="正在加载...",this.textEl=r;const n=document.createElement("div");n.style.cssText=`
|
|
180
|
-
flex:0 0 auto;
|
|
181
|
-
font-size:12px; line-height:1;
|
|
182
|
-
color:var(--e2d-accent,#4fc3f7);
|
|
183
|
-
font-variant-numeric:tabular-nums;
|
|
184
|
-
`,n.textContent="0%",this.pctEl=n;const s=document.createElement("div");s.style.cssText=`
|
|
185
|
-
width:100%; height:4px;
|
|
186
|
-
background:var(--e2d-border2,#333);
|
|
187
|
-
overflow:hidden;
|
|
188
|
-
`;const a=document.createElement("div");return a.style.cssText=`
|
|
189
|
-
height:100%; width:0%;
|
|
190
|
-
background:linear-gradient(90deg,var(--e2d-accent,#4fc3f7),#8be9fd);
|
|
191
|
-
box-shadow:0 0 12px rgba(79,195,247,0.45);
|
|
192
|
-
transition:width 0.25s ease;
|
|
193
|
-
`,this.barEl=a,t.appendChild(r),t.appendChild(n),s.appendChild(a),e.appendChild(t),e.appendChild(s),e}dispose(){this.overlay?.remove(),this.overlay=null,this.textEl=null,this.barEl=null,this.pctEl=null}}const ba=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
194
|
-
<circle cx="6.5" cy="6.5" r="4.5" stroke="currentColor" stroke-width="1.5"/>
|
|
195
|
-
<line x1="10" y1="10" x2="14" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
196
|
-
</svg>`,Ea=`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
197
|
-
<line x1="1" y1="1" x2="11" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
198
|
-
<line x1="11" y1="1" x2="1" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
199
|
-
</svg>`;class wa{manager;wrapper;input;clearBtn;resultList;statusEl;activeIndex=-1;currentResults=[];debounceTimer=null;constructor(e,t){this.manager=t,this.wrapper=this.buildWrapper(),this.input=this.wrapper.querySelector(".engine-2d-search__input"),this.clearBtn=this.wrapper.querySelector(".engine-2d-search__clear"),this.resultList=this.wrapper.querySelector(".engine-2d-search__list"),this.statusEl=this.wrapper.querySelector(".engine-2d-search__status"),e.appendChild(this.wrapper),this.bindEvents()}buildWrapper(){const e=document.createElement("div");return e.className="engine-2d-search",e.innerHTML=`
|
|
200
|
-
<div class="engine-2d-search__box">
|
|
201
|
-
<div class="engine-2d-search__input-row">
|
|
202
|
-
<span class="engine-2d-search__icon">${ba}</span>
|
|
203
|
-
<input
|
|
204
|
-
class="engine-2d-search__input"
|
|
205
|
-
type="text"
|
|
206
|
-
placeholder="搜索文字内容"
|
|
207
|
-
autocomplete="off"
|
|
208
|
-
spellcheck="false"
|
|
209
|
-
/>
|
|
210
|
-
<button class="engine-2d-search__clear" title="清除">${Ea}</button>
|
|
211
|
-
</div>
|
|
212
|
-
<div class="engine-2d-search__divider"></div>
|
|
213
|
-
<div class="engine-2d-search__status"></div>
|
|
214
|
-
<ul class="engine-2d-search__list" role="listbox"></ul>
|
|
215
|
-
</div>
|
|
216
|
-
`,e}bindEvents(){this.input.addEventListener("input",this.onInput),this.input.addEventListener("keydown",this.onKeyDown),this.clearBtn.addEventListener("click",this.onClear),document.addEventListener("mousedown",this.onDocMouseDown),document.addEventListener("keydown",this.onEscape)}onInput=()=>{this.debounceTimer!==null&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>this.doSearch(),150);const e=this.input.value.length>0;this.clearBtn.style.opacity=e?"1":"0",this.clearBtn.style.pointerEvents=e?"auto":"none"};onKeyDown=e=>{if(e.key==="Enter"&&this.activeIndex>=0&&this.currentResults[this.activeIndex]){e.preventDefault(),this.selectResult(this.currentResults[this.activeIndex]);return}const t=this.resultList.querySelectorAll(".engine-2d-search__item");t.length&&(e.key==="ArrowDown"?(e.preventDefault(),this.activeIndex=Math.min(this.activeIndex+1,t.length-1),this.highlightItem(t)):e.key==="ArrowUp"&&(e.preventDefault(),this.activeIndex=Math.max(this.activeIndex-1,0),this.highlightItem(t)))};onClear=()=>{this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none",this.clearResults(),this.input.focus()};onDocMouseDown=e=>{this.wrapper.contains(e.target)||this.hide()};onEscape=e=>{e.key==="Escape"&&this.hide()};doSearch(){const e=this.input.value;if(!e.trim()){this.clearResults();return}this.currentResults=this.manager.search(e),this.activeIndex=this.currentResults.length>0?0:-1,this.renderResults(this.currentResults,e)}renderResults(e,t){this.resultList.innerHTML="";const r=this.wrapper.querySelector(".engine-2d-search__divider");if(e.length===0){this.statusEl.textContent=`未找到与 "${t}" 匹配的文字`,this.statusEl.style.display="block",r.style.display="none",this.resultList.style.display="none";return}this.statusEl.textContent=`找到 ${e.length} 条文字`,this.statusEl.style.display="block",r.style.display="block",this.resultList.style.display="block",e.forEach((n,s)=>{const a=document.createElement("li");a.className="engine-2d-search__item",a.classList.toggle("engine-2d-search__item--active",s===this.activeIndex),a.setAttribute("role","option"),a.dataset.index=String(s),a.innerHTML=`
|
|
217
|
-
<span class="engine-2d-search__item-badge">文字</span>
|
|
218
|
-
<span class="engine-2d-search__item-name">${this.highlight(n.name,t)}</span>
|
|
219
|
-
${n.layer?`<span class="engine-2d-search__item-layer">${this.escapeHtml(n.layer)}</span>`:""}
|
|
220
|
-
${n.description?`<span class="engine-2d-search__item-desc">${this.escapeHtml(n.description)}</span>`:""}
|
|
221
|
-
`,a.addEventListener("click",()=>this.selectResult(n)),a.addEventListener("mouseenter",()=>{this.activeIndex=s,this.highlightItem(this.resultList.querySelectorAll(".engine-2d-search__item"))}),this.resultList.appendChild(a)})}highlight(e,t){const r=this.escapeHtml(e),n=t.trim();if(!n)return r;const s=this.escapeRegExp(this.escapeHtml(n));return r.replace(new RegExp(`(${s})`,"gi"),'<mark class="engine-2d-search__mark">$1</mark>')}highlightItem(e){e.forEach((t,r)=>{t.classList.toggle("engine-2d-search__item--active",r===this.activeIndex)}),this.activeIndex>=0&&e[this.activeIndex]?.scrollIntoView({block:"nearest"})}selectResult(e){this.manager.onResultSelect(e),this.hide()}clearResults(){this.resultList.innerHTML="",this.resultList.style.display="none",this.statusEl.style.display="none";const e=this.wrapper.querySelector(".engine-2d-search__divider");e.style.display="none",this.currentResults=[],this.activeIndex=-1}escapeHtml(e){return String(e??"").replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]??t)}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}show(){this.wrapper.classList.add("engine-2d-search--visible"),requestAnimationFrame(()=>this.input.focus())}hide(){this.wrapper.classList.remove("engine-2d-search--visible"),this.clearResults(),this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none"}toggle(){this.wrapper.classList.contains("engine-2d-search--visible")?this.hide():this.show()}dispose(){this.input.removeEventListener("input",this.onInput),this.input.removeEventListener("keydown",this.onKeyDown),this.clearBtn.removeEventListener("click",this.onClear),document.removeEventListener("mousedown",this.onDocMouseDown),document.removeEventListener("keydown",this.onEscape),this.wrapper.parentElement?.removeChild(this.wrapper),this.debounceTimer!==null&&clearTimeout(this.debounceTimer)}}class Sa{engine;searchUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.searchUI=new wa(t,this))}search(e){const t=this.normalize(e);return t?(this.engine.loaderModule2d?.model?.textItems??[]).map(n=>{const s=this.getMatchScore(n.text,t);return s==null?null:{id:n.id,name:n.text,type:"文字",layer:n.layer,description:this.getPositionDescription(n),score:s,target:n}}).filter(n=>n!==null).sort((n,s)=>(s.score??0)-(n.score??0)||n.name.length-s.name.length).slice(0,100):[]}onResultSelect(e){const t=e.target;t&&(this.engine.modelToolModule2d?.unhighlightAllModels?.(),this.engine.modelToolModule2d?.highlightModel?.([e.id]),this.fitToText(t))}fitToText(e){const t=e.min?.clone(),r=e.max?.clone(),n=e.anchor?.clone();if((!t||!r||t.distanceTo(r)<1e-6)&&n){const i=Math.max(Number(e.info?.height??100),100);this.engine.cameraModule2d?.fitToExtents({min:[n.x-i,n.y-i,0],max:[n.x+i,n.y+i,0]},2,!0,500);return}if(!t||!r)return;const s=new j.Vector3().subVectors(r,t),a=Math.max(s.x,s.y)<1e-6?2:2.5;this.engine.cameraModule2d?.fitToExtents({min:[t.x,t.y,t.z],max:[r.x,r.y,r.z]},a,!0,500)}getPositionDescription(e){const t=e.anchor??e.min;return t?`X:${t.x.toFixed(0)} Y:${t.y.toFixed(0)}`:""}normalize(e){return String(e??"").trim().toLowerCase().replace(/\s+/g,"")}getMatchScore(e,t){const r=this.normalize(e);if(!r)return null;const n=r.indexOf(t);if(n>=0)return 1e3-n-Math.max(0,r.length-t.length)*.01;let s=0,a=0;for(const i of t){const l=r.indexOf(i,s);if(l<0)return null;a+=l-s,s=l+1}return 500-a-Math.max(0,r.length-t.length)*.01}show(){this.searchUI?.show()}hide(){this.searchUI?.hide()}toggle(){this.searchUI?.toggle()}dispose(){this.searchUI?.dispose(),this.searchUI=null}}const Gi={dark:{"--e2d-bg":"#1e1f22","--e2d-bg2":"#252526","--e2d-bg3":"#222222","--e2d-bg-hover":"rgba(79,195,247,0.08)","--e2d-bg-accent":"#094771","--e2d-icon-bg":"rgba(255,255,255,0.08)","--e2d-icon-bg-hover":"rgba(255,255,255,0.16)","--e2d-border":"rgba(255,255,255,0.12)","--e2d-border2":"#333333","--e2d-text":"#e0e0e0","--e2d-text2":"#cccccc","--e2d-text3":"rgba(255,255,255,0.35)","--e2d-text4":"#666666","--e2d-text-accent":"#ffffff","--e2d-accent":"#4fc3f7","--e2d-shadow":"rgba(0,0,0,0.50)","--e2d-shadow-lg":"rgba(0,0,0,0.65)","--e2d-cursor":"rgba(255,255,255,0.85)","--e2d-scrollbar":"rgba(255,255,255,0.15)","--e2d-float-bg":"rgba(0,0,0,0.65)","--e2d-float-border":"rgba(255,255,255,0.08)","--e2d-swatch-border":"#444444","--e2d-close":"#aaaaaa","--e2d-close-hover":"#ffffff","--e2d-icon":"rgba(255,255,255,0.4)","--e2d-coord-value":"#76c8ff","--e2d-coord-label":"rgba(255,255,255,0.45)"},light:{"--e2d-bg":"#ffffff","--e2d-bg2":"#ffffff","--e2d-bg3":"#eeeeee","--e2d-bg-hover":"rgba(25,118,210,0.06)","--e2d-bg-accent":"#e3f2fd","--e2d-icon-bg":"rgba(0,0,0,0.06)","--e2d-icon-bg-hover":"rgba(0,0,0,0.12)","--e2d-border":"rgba(0,0,0,0.12)","--e2d-border2":"#e0e0e0","--e2d-text":"#1a1a1a","--e2d-text2":"#444444","--e2d-text3":"rgba(0,0,0,0.40)","--e2d-text4":"#aaaaaa","--e2d-text-accent":"#1565c0","--e2d-accent":"#1976d2","--e2d-shadow":"rgba(0,0,0,0.15)","--e2d-shadow-lg":"rgba(0,0,0,0.22)","--e2d-cursor":"rgba(30,30,30,0.70)","--e2d-scrollbar":"rgba(0,0,0,0.18)","--e2d-float-bg":"#ffffff","--e2d-float-border":"rgba(0,0,0,0.10)","--e2d-swatch-border":"#cccccc","--e2d-close":"#777777","--e2d-close-hover":"#1a1a1a","--e2d-icon":"rgba(0,0,0,0.45)","--e2d-coord-value":"#1976d2","--e2d-coord-label":"rgba(0,0,0,0.50)"}};class Ta{container;current;constructor(e,t="dark"){this.container=e,this.current=t,this._apply(t)}_apply(e){const t=Gi[e];for(const[r,n]of Object.entries(t))this.container.style.setProperty(r,n);this.container.setAttribute("data-e2d-theme",e)}setTheme(e){this.current=e,this._apply(e)}getTheme(){return this.current}toggle(){this.setTheme(this.current==="dark"?"light":"dark")}dispose(){for(const e of Object.keys(Gi[this.current]))this.container.style.removeProperty(e);this.container.removeAttribute("data-e2d-theme")}}const Wi={precision:3,unit:"m",areaUnit:"m²",scale:1};class yr{manager;points=[];constructor(e){this.manager=e}active(){this.points=[],this.manager.setCurrentTool(this)}disActive(){this.points=[],this.manager.clearPreview()}clearAllPoints(){this.points=[],this.manager.clearPreview()}handleClick(e){this.points.push(e.clone())}handleMove(e){}handleDoubleClick(){}handleRightClick(){this.handleDoubleClick()}handleEnter(){this.handleDoubleClick()}handleEsc(){this.clearAllPoints()}}class Aa extends yr{handleClick(e){super.handleClick(e),this.points.length===2&&(this.manager.addMeasurement("distance",this.points),this.clearAllPoints())}handleMove(e){this.points.length===1&&this.manager.drawPreview("distance",[this.points[0],e])}}class _a extends yr{handleClick(e){super.handleClick(e),this.manager.drawPreview("area",this.points)}handleMove(e){this.points.length>0&&this.manager.drawPreview("area",[...this.points,e])}handleDoubleClick(){const e=this.manager.removeTrailingDuplicatePoint(this.points);e.length>=3&&this.manager.addMeasurement("area",e),this.clearAllPoints()}}class Ia extends yr{handleClick(e){super.handleClick(e),this.points.length===3&&(this.manager.addMeasurement("angle",this.points),this.clearAllPoints())}handleMove(e){this.points.length>=2&&this.manager.drawPreview("angle",[...this.points,e])}}class ka{distanceMeasure;areaMeasure;angleMeasure;annotationData={distanceAnnotation:[],areaAnnotation:[],angleAnnotation:[]};engine;container;annotationContainer;setting={...Wi};isActive=!1;currentTool=null;previewRecord=null;mouseDownPoint=null;hasDraggedAfterMouseDown=!1;currentWorkspaceKey="model";constructor(e){this.engine=e,this.container=e.container,this.distanceMeasure=new Aa(this),this.areaMeasure=new _a(this),this.angleMeasure=new Ia(this),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",this.annotationContainer.style.pointerEvents="none",this.annotationContainer.style.zIndex="20",this.container.appendChild(this.annotationContainer)}active(){if(this.isActive)return;this.isActive=!0,this.engine.interactionModule2d?.disActive?.();const e=this.engine.renderer.domElement;e.addEventListener("mousedown",this.handleMouseDown,!0),e.addEventListener("click",this.handleClick,!0),e.addEventListener("mousemove",this.handleMove,!0),e.addEventListener("dblclick",this.handleDoubleClick,!0),e.addEventListener("contextmenu",this.handleContextMenu,!0),window.addEventListener("keydown",this.handleKeyDown,!0)}disActive(){if(!this.isActive)return;this.quitDraw(),this.isActive=!1;const e=this.engine.renderer.domElement;e.removeEventListener("mousedown",this.handleMouseDown,!0),e.removeEventListener("click",this.handleClick,!0),e.removeEventListener("mousemove",this.handleMove,!0),e.removeEventListener("dblclick",this.handleDoubleClick,!0),e.removeEventListener("contextmenu",this.handleContextMenu,!0),window.removeEventListener("keydown",this.handleKeyDown,!0),this.engine.interactionModule2d?.active?.(),this.clearAll()}quitDraw(){this.currentTool?.disActive(),this.currentTool=null,this.clearPreview()}activate(e){this.active(),this.disActiveMeasureTools(),e==="distance"&&this.distanceMeasure.active(),e==="area"&&this.areaMeasure.active(),e==="angle"&&this.angleMeasure.active()}clearAllPoints(){this.distanceMeasure.clearAllPoints(),this.areaMeasure.clearAllPoints(),this.angleMeasure.clearAllPoints()}clearAll(){Object.values(this.annotationData).forEach(e=>this.removeRecords(e,t=>t.workspaceKey===this.currentWorkspaceKey)),this.clearPreview()}cancelCurrentSelectedAnnotation(){Object.values(this.annotationData).flat().forEach(e=>{e.highlight=!1,this.applyRecordHighlight(e,!1)})}saveSetting(e){this.setting={...this.setting,...e,precision:this.normalizePrecision(e.precision??this.setting.precision),scale:Number.isFinite(e.scale)&&e.scale>0?e.scale:this.setting.scale},this.refreshLabels()}setPrecision(e){this.saveSetting({precision:e})}getSetting(){return{...this.setting}}update(){this.updateRecords(Object.values(this.annotationData).flat().filter(e=>e.workspaceKey===this.currentWorkspaceKey)),this.previewRecord&&this.updateRecordSvg(this.previewRecord)}setWorkspace(e){!e||e===this.currentWorkspaceKey||(this.clearPreview(),this.cancelCurrentSelectedAnnotation(),this.currentWorkspaceKey=e,this.refreshWorkspaceVisibility())}dispose(){this.disActive(),this.clearAll(),this.annotationContainer.remove()}setCurrentTool(e){this.currentTool=e}drawPreview(e,t){this.clearPreview(),!(t.length<2)&&(this.previewRecord=this.createRecord(e,t,!0),this.annotationContainer.appendChild(this.previewRecord.container),this.updateRecordSvg(this.previewRecord))}clearPreview(){this.previewRecord?.container.remove(),this.previewRecord=null}addMeasurement(e,t){const r=this.createRecord(e,t,!1);return this.annotationContainer.appendChild(r.container),this.getRecords(e).push(r),this.updateRecordSvg(r),this.engine.events?.trigger?.("measure-changed",r),r}deleteSelected(){Object.values(this.annotationData).forEach(e=>{for(let t=e.length-1;t>=0;t--)e[t].workspaceKey===this.currentWorkspaceKey&&e[t].highlight&&(e[t].container.remove(),e.splice(t,1))})}removeTrailingDuplicatePoint(e){if(e.length<2)return e.map(s=>s.clone());const t=e.map(s=>s.clone()),r=t[t.length-1],n=t[t.length-2];return r.distanceTo(n)<1e-6&&t.pop(),t}disActiveMeasureTools(){this.distanceMeasure.disActive(),this.areaMeasure.disActive(),this.angleMeasure.disActive()}handleMouseDown=e=>{this.mouseDownPoint=new j.Vector2(e.clientX,e.clientY),this.hasDraggedAfterMouseDown=!1};handleClick=e=>{!this.currentTool||this.hasDraggedAfterMouseDown||(e.preventDefault(),e.stopImmediatePropagation(),this.currentTool.handleClick(this.eventToWorld(e)))};handleMove=e=>{this.currentTool&&(this.mouseDownPoint&&new j.Vector2(e.clientX,e.clientY).distanceTo(this.mouseDownPoint)>3&&(this.hasDraggedAfterMouseDown=!0),this.currentTool.handleMove(this.eventToWorld(e)))};handleDoubleClick=e=>{this.currentTool&&(e.preventDefault(),e.stopImmediatePropagation(),this.currentTool.handleDoubleClick())};handleContextMenu=e=>{this.currentTool&&(e.preventDefault(),e.stopImmediatePropagation(),this.currentTool.handleRightClick())};handleKeyDown=e=>{this.isActive&&(e.key==="Escape"&&(e.preventDefault(),e.stopImmediatePropagation(),this.currentTool?.handleEsc(),this.disActive(),this.engine.events?.trigger?.("quit_measure_draw",!0),window.dispatchEvent(new CustomEvent("D2MeasureQuit"))),(e.key==="Delete"||e.key==="Backspace")&&(e.preventDefault(),e.stopImmediatePropagation(),this.deleteSelected()),e.key==="Enter"&&this.currentTool&&(e.preventDefault(),this.currentTool.handleEnter()))};eventToWorld(e){const t=this.engine.renderer.domElement.getBoundingClientRect(),r=this.engine.cameraModule2d.screenToWorld(e.clientX-t.left,e.clientY-t.top);return r.z=0,r}createRecord(e,t,r){const n=document.createElement("div");n.className=`${e}-annotation`,n.style.position="absolute",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none";const s=this.createSvg(e);r&&(s.style.opacity="0.65"),n.appendChild(s);const a=this.computeValue(e,t),i={id:this.createId(),type:e,workspaceKey:this.currentWorkspaceKey,points:t.map(l=>l.clone()),container:n,svg:s,value:a,text:this.formatValue(e,a),isSelect:r};return r||this.bindRecordSelection(i),i}createSvg(e){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");if(t.classList.add("measureSvg"),t.style.left="0",t.style.top="0",t.style.pointerEvents="none",e==="area"){const i=this.svgElement("polygon");i.setAttribute("fill","rgba(0, 155, 234, 0.12)"),i.setAttribute("stroke","none"),t.appendChild(i)}const r=e==="angle"?2:1;for(let i=0;i<r;i++){const l=this.svgElement("polyline");l.classList.add("measureLine"),l.setAttribute("stroke-width","2"),l.setAttribute("style","fill: none; opacity: 1;"),t.appendChild(l)}const n=e==="angle"?3:e==="distance"?2:0;for(let i=0;i<n;i++){const l=this.svgElement("circle");l.classList.add("measurePointer"),l.setAttribute("r","5"),t.appendChild(l)}const s=this.svgElement("rect");s.classList.add("measureBack"),s.setAttribute("width","100"),s.setAttribute("height","25"),s.style.pointerEvents="auto",s.style.cursor="pointer",t.appendChild(s);const a=this.svgElement("text");return a.classList.add("measureLabel"),a.setAttribute("text-anchor","middle"),t.appendChild(a),t}bindRecordSelection(e){e.svg.getElementsByTagName("rect")[0].addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),this.cancelCurrentSelectedAnnotation(),e.highlight=!0,this.applyRecordHighlight(e,!0),this.engine.events?.trigger?.("measure-click",e)})}applyRecordHighlight(e,t){[e.svg,...Array.from(e.svg.getElementsByTagName("polyline")),...Array.from(e.svg.getElementsByTagName("circle")),...Array.from(e.svg.getElementsByTagName("polygon")),...Array.from(e.svg.getElementsByTagName("rect")),...Array.from(e.svg.getElementsByTagName("text"))].forEach(n=>{n.classList.toggle("Hight",t),n.classList.toggle("measure-2d-selected",t)})}svgElement(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}updateRecords(e){e.forEach(t=>this.updateRecordSvg(t))}updateRecordSvg(e){const t=this.container.clientWidth||1,r=this.container.clientHeight||1;e.svg.setAttribute("width",`${t}`),e.svg.setAttribute("height",`${r}`),e.svg.style.width=`${t}px`,e.svg.style.height=`${r}px`;const n=e.points.map(s=>this.worldToScreen(s));e.type==="distance"&&this.updateDistanceSvg(e,n),e.type==="area"&&this.updateAreaSvg(e,n),e.type==="angle"&&this.updateAngleSvg(e,n)}updateDistanceSvg(e,t){const[r,n]=t,s=e.svg.getElementsByTagName("polyline")[0],a=e.svg.getElementsByTagName("circle");s.setAttribute("points",`${r.x},${r.y} ${n.x},${n.y}`),a[0].setAttribute("cx",`${r.x}`),a[0].setAttribute("cy",`${r.y}`),a[1].setAttribute("cx",`${n.x}`),a[1].setAttribute("cy",`${n.y}`),this.updateLabel(e,(r.x+n.x)/2,(r.y+n.y)/2)}updateAreaSvg(e,t){const r=t.map(i=>`${i.x},${i.y}`).join(" "),s=(t.length>=3?[...t,t[0]]:t).map(i=>`${i.x},${i.y}`).join(" ");e.svg.getElementsByTagName("polygon")[0].setAttribute("points",t.length>=3?r:""),e.svg.getElementsByTagName("polyline")[0].setAttribute("points",s);const a=t.reduce((i,l)=>(i.x+=l.x,i.y+=l.y,i),{x:0,y:0});this.updateLabel(e,a.x/t.length,a.y/t.length)}updateAngleSvg(e,t){const[r,n,s]=t,a=e.svg.getElementsByTagName("polyline"),i=e.svg.getElementsByTagName("circle");a[0].setAttribute("points",`${r.x},${r.y} ${n.x},${n.y}`),a[1].setAttribute("points",`${n.x},${n.y} ${s.x},${s.y}`),[r,n,s].forEach((l,c)=>{i[c].setAttribute("cx",`${l.x}`),i[c].setAttribute("cy",`${l.y}`)}),this.updateLabel(e,n.x,n.y-30)}updateLabel(e,t,r){e.value=this.computeValue(e.type,e.points),e.text=this.formatValue(e.type,e.value);const n=e.svg.getElementsByTagName("rect")[0],s=e.svg.getElementsByTagName("text")[0],a=Math.max(100,e.text.length*9+22);n.setAttribute("x",`${t-a/2}`),n.setAttribute("y",`${r-12.5}`),n.setAttribute("width",`${a}`),s.setAttribute("x",`${t}`),s.setAttribute("y",`${r+4}`),s.textContent=e.text}worldToScreen(e){return this.engine.cameraModule2d.worldToScreen(e.x,e.y)}computeValue(e,t){return e==="distance"?t[0].distanceTo(t[1])*this.setting.scale:e==="angle"?this.computeAngle(t[0],t[1],t[2]):this.computeArea(t)*this.setting.scale*this.setting.scale}computeArea(e){if(e.length<3)return 0;let t=0;for(let r=0;r<e.length;r++){const n=e[r],s=e[(r+1)%e.length];t+=n.x*s.y-s.x*n.y}return Math.abs(t)/2}computeAngle(e,t,r){const n=e.clone().sub(t).normalize(),s=r.clone().sub(t).normalize(),a=j.MathUtils.clamp(n.dot(s),-1,1);return j.MathUtils.radToDeg(Math.acos(a))}formatValue(e,t){return e==="angle"?`${t.toFixed(this.setting.precision)}°`:e==="area"?`${t.toFixed(this.setting.precision)} ${this.setting.areaUnit??`${this.setting.unit}²`}`:`${t.toFixed(this.setting.precision)} ${this.setting.unit}`}refreshLabels(){Object.values(this.annotationData).flat().filter(e=>e.workspaceKey===this.currentWorkspaceKey).forEach(e=>{e.value=this.computeValue(e.type,e.points),e.text=this.formatValue(e.type,e.value),this.updateRecordSvg(e)})}refreshWorkspaceVisibility(){Object.values(this.annotationData).flat().forEach(e=>{e.container.style.display=e.workspaceKey===this.currentWorkspaceKey?"":"none"})}removeRecords(e,t){for(let r=e.length-1;r>=0;r-=1)t(e[r])&&(e[r].container.remove(),e.splice(r,1))}getRecords(e){return e==="distance"?this.annotationData.distanceAnnotation:e==="area"?this.annotationData.areaAnnotation:this.annotationData.angleAnnotation}normalizePrecision(e){return Number.isFinite(e)?Math.max(0,Math.min(8,Math.round(e))):Wi.precision}createId(){return`measure-2d-${Date.now()}-${Math.random().toString(16).slice(2)}`}}const vr={stroke:"#ff4d4f",fill:"rgba(255, 77, 79, 0.08)",strokeWidth:2,fontSize:16,cloudRadius:10},Ba={none:mt("/assets/icon/选择.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ae&&Ae.tagName.toUpperCase()==="SCRIPT"&&Ae.src||new URL("dwg-preview.umd.js",document.baseURI).href),line:mt("/assets/icon/线.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ae&&Ae.tagName.toUpperCase()==="SCRIPT"&&Ae.src||new URL("dwg-preview.umd.js",document.baseURI).href),arrow:mt("/assets/icon/箭头.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ae&&Ae.tagName.toUpperCase()==="SCRIPT"&&Ae.src||new URL("dwg-preview.umd.js",document.baseURI).href),rect:mt("/assets/icon/矩形.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ae&&Ae.tagName.toUpperCase()==="SCRIPT"&&Ae.src||new URL("dwg-preview.umd.js",document.baseURI).href),ellipse:mt("/assets/icon/圆形.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ae&&Ae.tagName.toUpperCase()==="SCRIPT"&&Ae.src||new URL("dwg-preview.umd.js",document.baseURI).href),polygon:mt("/assets/icon/面积.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ae&&Ae.tagName.toUpperCase()==="SCRIPT"&&Ae.src||new URL("dwg-preview.umd.js",document.baseURI).href),text:mt("/assets/icon/文字.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ae&&Ae.tagName.toUpperCase()==="SCRIPT"&&Ae.src||new URL("dwg-preview.umd.js",document.baseURI).href),cloudline:mt("/assets/icon/云线.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ae&&Ae.tagName.toUpperCase()==="SCRIPT"&&Ae.src||new URL("dwg-preview.umd.js",document.baseURI).href)},Ma="data:image/svg+xml;utf8,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#1f2937" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M8 6V4h8v2"/><path d="M6 6l1 16h10l1-16"/><path d="M10 11v6"/><path d="M14 11v6"/></svg>'),La="data:image/svg+xml;utf8,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#1f2937" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12"/><path d="M18 6L6 18"/></svg>');class Ra{engine;container;layer;svg;toolbar;records=[];isActive=!1;currentType=null;style={...vr};draft=null;draftStart=null;polygonPoints=[];currentWorkspaceKey="model";mouseDownPoint=null;hasDraggedAfterMouseDown=!1;buttons={};constructor(e){this.engine=e,this.container=e.container,getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),this.layer=document.createElement("div"),this.layer.className="markup-2d-layer",this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.classList.add("markup-2d-svg"),this.layer.appendChild(this.svg),this.toolbar=this.createToolbar(),this.layer.appendChild(this.toolbar),this.container.appendChild(this.layer)}active(e){if(this.engine.measure?.quitDraw?.(),!this.isActive){this.isActive=!0,this.engine.interactionModule2d?.disActive?.();const t=this.engine.renderer.domElement;t.addEventListener("mousedown",this.handleMouseDown,!0),t.addEventListener("mousemove",this.handleMouseMove,!0),t.addEventListener("mouseup",this.handleMouseUp,!0),t.addEventListener("click",this.handleClick,!0),t.addEventListener("dblclick",this.handleDoubleClick,!0),t.addEventListener("wheel",this.blockDrawingEvent,!0),t.addEventListener("touchstart",this.blockDrawingEvent,!0),t.addEventListener("touchmove",this.blockDrawingEvent,!0),window.addEventListener("keydown",this.handleKeyDown,!0)}this.showToolbar(),e&&this.setDrawType(e)}show(){this.active()}hide(){this.hideToolbar(),this.disActive()}disActive(){if(!this.isActive)return;this.isActive=!1,this.currentType=null,this.clearDraft(),this.polygonPoints=[],this.syncToolbar();const e=this.engine.renderer.domElement;e.removeEventListener("mousedown",this.handleMouseDown,!0),e.removeEventListener("mousemove",this.handleMouseMove,!0),e.removeEventListener("mouseup",this.handleMouseUp,!0),e.removeEventListener("click",this.handleClick,!0),e.removeEventListener("dblclick",this.handleDoubleClick,!0),e.removeEventListener("wheel",this.blockDrawingEvent,!0),e.removeEventListener("touchstart",this.blockDrawingEvent,!0),e.removeEventListener("touchmove",this.blockDrawingEvent,!0),window.removeEventListener("keydown",this.handleKeyDown,!0),this.engine.interactionModule2d?.active?.()}setDrawType(e){this.currentType=e==="none"?null:e,this.clearDraft(),this.polygonPoints=[],this.syncToolbar()}update(){const e=this.container.clientWidth||1,t=this.container.clientHeight||1;this.svg.setAttribute("width",`${e}`),this.svg.setAttribute("height",`${t}`),this.svg.style.width=`${e}px`,this.svg.style.height=`${t}px`,this.records.forEach(r=>{r.element.style.display=r.data.workspaceKey===this.currentWorkspaceKey?"":"none",this.updateElement(r)}),this.draft&&this.updateElement(this.draft)}setWorkspace(e){!e||e===this.currentWorkspaceKey||(this.currentWorkspaceKey=e,this.clearDraft(),this.polygonPoints=[],this.cancelSelected(),this.update())}getData(){return this.records.map(e=>this.cloneData(e.data))}restoreData(e=[]){this.clearAll(!0),e.forEach(t=>this.addMarkup(t)),this.update()}get(){return{cameraViewState:this.engine.cameraModule2d?.getViewState?.()??null,markupData:this.getData()}}restore(e){e&&(e.cameraViewState&&this.engine.cameraModule2d?.applyViewState?.(e.cameraViewState),this.restoreData(e.markupData??[]))}addMarkup(e){const t={id:e.id??this.createId(),type:e.type,workspaceKey:e.workspaceKey??this.currentWorkspaceKey,points:e.points.map(n=>({x:n.x,y:n.y,z:n.z??0})),text:e.text,style:{...this.style,...e.style??{}}},r=this.createRecord(t);return this.records.push(r),this.svg.appendChild(r.element),this.updateElement(r),this.engine.events?.trigger?.("markup-changed",this.cloneData(t)),this.cloneData(t)}clearAll(e=!1){for(let t=this.records.length-1;t>=0;t-=1){const r=this.records[t];!e&&r.data.workspaceKey!==this.currentWorkspaceKey||(r.element.remove(),this.records.splice(t,1))}this.clearDraft()}deleteSelected(){for(let e=this.records.length-1;e>=0;e-=1)this.records[e].selected&&(this.records[e].element.remove(),this.records.splice(e,1));this.engine.events?.trigger?.("markup-changed",this.getData())}dispose(){this.disActive(),this.records.forEach(e=>e.element.remove()),this.records=[],this.layer.remove()}blockDrawingEvent=e=>{this.currentType&&(e instanceof MouseEvent&&this.engine.cadCursorUI?.updateFromMouseEvent?.(e),e.preventDefault(),e.stopImmediatePropagation())};handleMouseDown=e=>{this.currentType&&(this.blockDrawingEvent(e),this.mouseDownPoint=new j.Vector2(e.clientX,e.clientY),this.hasDraggedAfterMouseDown=!1)};handleMouseMove=e=>{if(this.currentType){if(this.blockDrawingEvent(e),this.mouseDownPoint&&e.buttons!==0){const t=new j.Vector2(e.clientX,e.clientY);this.hasDraggedAfterMouseDown=t.distanceTo(this.mouseDownPoint)>3}if(this.isMultiPointType(this.currentType)&&this.polygonPoints.length>0){this.drawMultiPointDraft(this.eventToWorld(e));return}!this.draft||!this.draftStart||(this.draft.data.points=[this.pointToData(this.draftStart),this.pointToData(this.eventToWorld(e))],this.updateElement(this.draft))}};handleMouseUp=e=>{this.currentType&&(this.blockDrawingEvent(e),this.mouseDownPoint=null)};handleClick=e=>{if(this.currentType&&(this.blockDrawingEvent(e),!this.hasDraggedAfterMouseDown)){if(this.currentType==="text"){const t=window.prompt("请输入标记文字","文字")??"";t.trim()&&this.addMarkup({type:"text",points:[this.pointToData(this.eventToWorld(e))],text:t.trim()});return}if(this.isTwoPointType(this.currentType)){const t=this.eventToWorld(e);this.draftStart?this.finishTwoPointDraft(t):this.startTwoPointDraft(t);return}this.isMultiPointType(this.currentType)&&(this.polygonPoints.push(this.eventToWorld(e)),this.drawMultiPointDraft())}};handleDoubleClick=e=>{if(!this.currentType||!this.isMultiPointType(this.currentType))return;this.blockDrawingEvent(e);const t=this.currentType==="cloudline"?2:3,r=this.removeTrailingDuplicatePoints(this.polygonPoints);r.length>=t&&this.addMarkup({type:this.currentType,points:r.map(n=>this.pointToData(n))}),this.polygonPoints=[],this.clearDraft()};handleKeyDown=e=>{if(this.isActive&&(e.key==="Escape"&&(e.preventDefault(),this.clearDraft(),this.polygonPoints=[],this.setDrawType("none")),(e.key==="Delete"||e.key==="Backspace")&&(e.preventDefault(),this.deleteSelected()),e.key==="Enter"&&this.currentType&&this.isMultiPointType(this.currentType))){e.preventDefault();const t=this.currentType==="cloudline"?2:3,r=this.removeTrailingDuplicatePoints(this.polygonPoints);r.length>=t&&this.addMarkup({type:this.currentType,points:r.map(n=>this.pointToData(n))}),this.polygonPoints=[],this.clearDraft()}};createToolbar(){const e=document.createElement("div");e.className="markup-2d-toolbar",[{type:"none",title:"选择"},{type:"line",title:"直线"},{type:"arrow",title:"箭头"},{type:"rect",title:"矩形"},{type:"ellipse",title:"圆形/椭圆"},{type:"polygon",title:"多边形,双击或 Enter 结束"},{type:"cloudline",title:"云线,双击或 Enter 结束"},{type:"text",title:"文字"}].forEach(l=>{const c=this.createIconButton(l.title,Ba[l.type]);c.onclick=()=>{this.active(),this.setDrawType(l.type)},l.type!=="none"&&(this.buttons[l.type]=c),e.appendChild(c)}),e.appendChild(this.createDivider());const r=document.createElement("input");r.type="color",r.value=this.style.stroke,r.title="颜色",r.oninput=()=>{this.style.stroke=r.value,this.style.fill=this.hexToTransparent(r.value)},e.appendChild(r);const n=document.createElement("input");n.type="number",n.min="1",n.max="20",n.value=`${this.style.strokeWidth}`,n.title="线宽",n.onchange=()=>{this.style.strokeWidth=this.normalizeNumber(n.valueAsNumber,1,20,vr.strokeWidth)},e.appendChild(n);const s=document.createElement("input");s.type="number",s.min="10",s.max="72",s.value=`${this.style.fontSize}`,s.title="字号",s.onchange=()=>{this.style.fontSize=this.normalizeNumber(s.valueAsNumber,10,72,vr.fontSize)},e.appendChild(s),e.appendChild(this.createDivider());const a=this.createIconButton("清空",Ma);a.onclick=()=>this.clearAll(),e.appendChild(a);const i=this.createIconButton("关闭",La);return i.onclick=()=>{this.hideToolbar(),this.disActive()},e.appendChild(i),e}createDivider(){const e=document.createElement("div");return e.className="markup-2d-divider",e}createIconButton(e,t){const r=document.createElement("button");r.type="button",r.title=e,r.setAttribute("aria-label",e),r.classList.add("markup-2d-icon-button");const n=document.createElement("img");return n.src=t,n.alt=e,n.draggable=!1,r.appendChild(n),r}showToolbar(){this.toolbar.style.display="flex"}hideToolbar(){this.toolbar.style.display="none"}syncToolbar(){Object.entries(this.buttons).forEach(([e,t])=>{t?.classList.toggle("active",e===this.currentType)})}finishDraft(){if(!this.draft)return;const e=this.draft;this.draft=null,e.element.style.pointerEvents="auto",this.records.push(e),this.updateElement(e),this.engine.events?.trigger?.("markup-changed",this.cloneData(e.data))}clearDraft(){this.draft?.element.remove(),this.draft=null,this.draftStart=null}startTwoPointDraft(e){this.draftStart=e.clone(),this.draft=this.createRecord({id:this.createId(),type:this.currentType,workspaceKey:this.currentWorkspaceKey,points:[this.pointToData(e),this.pointToData(e)],style:{...this.style}}),this.draft.element.setAttribute("opacity","0.65"),this.draft.element.style.pointerEvents="none",this.svg.appendChild(this.draft.element),this.updateElement(this.draft)}finishTwoPointDraft(e){!this.draft||!this.draftStart||this.draftStart.distanceTo(e)<1e-6||(this.draft.data.points=[this.pointToData(this.draftStart),this.pointToData(e)],this.draft.element.removeAttribute("opacity"),this.finishDraft(),this.draftStart=null)}drawMultiPointDraft(e){if(this.clearDraft(),this.polygonPoints.length===0)return;const t=e?[...this.polygonPoints,e]:this.polygonPoints;this.draft=this.createRecord({id:this.createId(),type:this.currentType==="cloudline"?"cloudline":"polygon",workspaceKey:this.currentWorkspaceKey,points:t.map(r=>this.pointToData(r)),style:{...this.style}}),this.draft.element.setAttribute("opacity","0.65"),this.draft.element.style.pointerEvents="none",this.svg.appendChild(this.draft.element),this.updateElement(this.draft)}createRecord(e){const t=this.createElement(e.type);t.classList.add("markup-2d-shape");const r={data:this.cloneData(e),element:t};return this.applyStyle(r),this.bindSelection(r),r}createElement(e){return e==="rect"?this.svgElement("rect"):e==="ellipse"?this.svgElement("ellipse"):e==="text"?this.svgElement("text"):e==="polygon"||e==="cloudline"?this.svgElement("g"):this.svgElement("g")}bindSelection(e){e.element.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.cancelSelected(),e.selected=!0,e.element.classList.add("selected"),this.engine.events?.trigger?.("markup-click",this.cloneData(e.data))})}cancelSelected(){this.records.forEach(e=>{e.selected=!1,e.element.classList.remove("selected")})}updateElement(e){this.applyStyle(e);const t=e.data.points.map(r=>this.worldToScreen(r));e.data.type==="line"&&this.updateLine(e,t,!1),e.data.type==="arrow"&&this.updateLine(e,t,!0),e.data.type==="rect"&&this.updateRect(e,t),e.data.type==="ellipse"&&this.updateEllipse(e,t),e.data.type==="text"&&this.updateText(e,t[0]),e.data.type==="polygon"&&this.updatePolygon(e,t),e.data.type==="cloudline"&&this.updateCloudLine(e,t)}updateLine(e,t,r){const n=e.element;if(n.innerHTML="",t.length<2)return;const[s,a]=t,i=this.svgElement("line");if(i.setAttribute("x1",`${s.x}`),i.setAttribute("y1",`${s.y}`),i.setAttribute("x2",`${a.x}`),i.setAttribute("y2",`${a.y}`),this.applySvgPaint(i,e.data.style,!1),n.appendChild(i),e===this.draft&&this.drawVertexMarkers(n,t,e.data.style),!r)return;const l=this.createArrowHead(s,a,e.data.style.strokeWidth);this.applySvgPaint(l,e.data.style,!0),l.setAttribute("fill",e.data.style.stroke),n.appendChild(l)}updateRect(e,t){if(t.length<2)return;const[r,n]=t,s=e.element;s.setAttribute("x",`${Math.min(r.x,n.x)}`),s.setAttribute("y",`${Math.min(r.y,n.y)}`),s.setAttribute("width",`${Math.abs(n.x-r.x)}`),s.setAttribute("height",`${Math.abs(n.y-r.y)}`)}updateEllipse(e,t){if(t.length<2)return;const[r,n]=t,s=e.element;s.setAttribute("cx",`${(r.x+n.x)/2}`),s.setAttribute("cy",`${(r.y+n.y)/2}`),s.setAttribute("rx",`${Math.abs(n.x-r.x)/2}`),s.setAttribute("ry",`${Math.abs(n.y-r.y)/2}`)}updateText(e,t){const r=e.element;r.setAttribute("x",`${t.x}`),r.setAttribute("y",`${t.y}`),r.textContent=e.data.text??""}updatePolygon(e,t){const r=e.element;if(r.innerHTML="",t.length===0)return;const n=t.map(a=>`${a.x},${a.y}`).join(" "),s=t.length>=3?this.svgElement("polygon"):this.svgElement("polyline");s.setAttribute("points",n),this.applySvgPaint(s,e.data.style,t.length>=3),r.appendChild(s),e===this.draft&&this.drawVertexMarkers(r,t,e.data.style)}updateCloudLine(e,t){const r=e.element;if(r.innerHTML="",t.length===0)return;const n=this.svgElement("path");n.setAttribute("d",this.buildCloudPath(t,e.data.style.cloudRadius)),this.applySvgPaint(n,e.data.style,!1),r.appendChild(n),e===this.draft&&this.drawVertexMarkers(r,t,e.data.style)}drawVertexMarkers(e,t,r){t.forEach(n=>{const s=this.svgElement("circle");s.setAttribute("cx",`${n.x}`),s.setAttribute("cy",`${n.y}`),s.setAttribute("r",`${Math.max(3,r.strokeWidth+2)}`),s.setAttribute("fill",r.stroke),s.setAttribute("stroke","#ffffff"),s.setAttribute("stroke-width","1"),e.appendChild(s)})}applyStyle(e){e.data.type==="line"||e.data.type==="arrow"||e.data.type==="polygon"||e.data.type==="cloudline"||(this.applySvgPaint(e.element,e.data.style,e.data.type!=="text"&&e.data.type!=="cloudline"),e.data.type==="text"&&(e.element.setAttribute("font-size",`${e.data.style.fontSize}`),e.element.setAttribute("dominant-baseline","middle"),e.element.setAttribute("fill",e.data.style.stroke),e.element.setAttribute("stroke","none")))}applySvgPaint(e,t,r){e.setAttribute("stroke",t.stroke),e.setAttribute("stroke-width",`${t.strokeWidth}`),e.setAttribute("fill",r?t.fill:"none"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round")}createArrowHead(e,t,r){const n=Math.atan2(t.y-e.y,t.x-e.x),s=Math.max(10,r*5),a={x:t.x-s*Math.cos(n-Math.PI/6),y:t.y-s*Math.sin(n-Math.PI/6)},i={x:t.x-s*Math.cos(n+Math.PI/6),y:t.y-s*Math.sin(n+Math.PI/6)},l=this.svgElement("polygon");return l.setAttribute("points",`${t.x},${t.y} ${a.x},${a.y} ${i.x},${i.y}`),l}buildCloudPath(e,t){if(e.length===0)return"";if(e.length===1)return`M ${e[0].x} ${e[0].y}`;const r=Math.max(4,t),n=[`M ${e[0].x} ${e[0].y}`];for(let s=0;s<e.length-1;s+=1){const a=e[s],i=e[s+1],l=i.x-a.x,c=i.y-a.y,p=Math.hypot(l,c);if(p<1e-6)continue;const b=Math.max(1,Math.ceil(p/(r*1.6)));for(let x=0;x<b;x+=1){const h=x/b,m=(x+1)/b,d=(h+m)/2,y={x:a.x+l*d-c/p*r*.7,y:a.y+c*d+l/p*r*.7},u={x:a.x+l*m,y:a.y+c*m};n.push(`Q ${y.x} ${y.y} ${u.x} ${u.y}`)}}return n.join(" ")}isMultiPointType(e){return e==="polygon"||e==="cloudline"}isTwoPointType(e){return e==="line"||e==="arrow"||e==="rect"||e==="ellipse"}removeTrailingDuplicatePoints(e){const t=e.map(r=>r.clone());for(;t.length>=2&&t[t.length-1].distanceTo(t[t.length-2])<1e-6;)t.pop();return t}eventToWorld(e){const t=this.engine.renderer.domElement.getBoundingClientRect(),r=this.engine.cameraModule2d.screenToWorld(e.clientX-t.left,e.clientY-t.top);return r.z=0,r}worldToScreen(e){return this.engine.cameraModule2d.worldToScreen(e.x,e.y)}pointToData(e){return{x:e.x,y:e.y,z:e.z}}svgElement(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}cloneData(e){return{...e,points:e.points.map(t=>({...t})),style:{...e.style}}}hexToTransparent(e){const t=e.replace("#",""),r=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16);return`rgba(${r}, ${n}, ${s}, 0.08)`}normalizeNumber(e,t,r,n){return Number.isFinite(e)?Math.max(t,Math.min(r,Math.round(e))):n}createId(){return`markup-2d-${Date.now()}-${Math.random().toString(16).slice(2)}`}}class Na{container;labelContainer;projectCoordinate;pickCoordinate;emitEvent;labels=new Map;clickCallbacks=new Set;pickResolver=null;isPicking=!1;constructor(e){this.container=e.container,this.projectCoordinate=e.projectCoordinate,this.pickCoordinate=e.pickCoordinate,this.emitEvent=e.emitEvent,this.labelContainer=document.createElement("div"),this.labelContainer.className=e.className??"bim-engine-label-container",this.labelContainer.style.cssText=["position:absolute","left:0","top:0","width:100%","height:100%","pointer-events:none","overflow:hidden","z-index:1200"].join(";"),this.container.appendChild(this.labelContainer)}pickPoint(){return this.cancelPick(),this.isPicking=!0,this.container.style.cursor="crosshair",this.addPickBlockers(),this.container.addEventListener("click",this.handlePickClick,!0),new Promise(e=>{this.pickResolver=e})}startPickPoint(e){const t=this.pickPoint();return e&&t.then(e),t}createLabel(e){const t=e.id??this.createId();if(this.labels.has(t))throw new Error(`LabelManager: label "${t}" already exists`);const r=this.createElement(t),n={id:t,coordinate:{...e.coordinate},icon:e.icon,name:e.name,data:e.data,size:e.iconSize??e.size??28,visible:e.visible??!0,element:r};return this.labels.set(t,n),this.labelContainer.appendChild(r),this.renderLabel(n),this.updateLabelPosition(n),this.emitEvent?.("label-created",this.toPayload(n)),t}updateLabel(e,t){const r=this.labels.get(e);return r?(t.coordinate&&(r.coordinate={...t.coordinate}),t.icon!==void 0&&(r.icon=t.icon),t.name!==void 0&&(r.name=t.name),t.data!==void 0&&(r.data=t.data),t.iconSize!==void 0&&(r.size=t.iconSize),t.size!==void 0&&(r.size=t.size),t.visible!==void 0&&(r.visible=t.visible),this.renderLabel(r),this.updateLabelPosition(r),this.emitEvent?.("label-updated",this.toPayload(r)),!0):!1}deleteLabel(e){const t=this.labels.get(e);return t?(t.element.remove(),this.labels.delete(e),this.emitEvent?.("label-deleted",{id:e}),!0):!1}removeLabel(e){return this.deleteLabel(e)}clearLabels(){Array.from(this.labels.keys()).forEach(e=>this.deleteLabel(e))}getLabel(e){return this.labels.get(e)}getLabels(){return Array.from(this.labels.values())}onLabelClick(e){return this.clickCallbacks.add(e),()=>this.offLabelClick(e)}offLabelClick(e){this.clickCallbacks.delete(e)}update(){this.labels.forEach(e=>this.updateLabelPosition(e))}cancelPick(){this.isPicking&&(this.isPicking=!1,this.container.style.cursor="",this.removePickBlockers(),this.container.removeEventListener("click",this.handlePickClick,!0),this.pickResolver?.(null),this.pickResolver=null)}dispose(){this.cancelPick(),this.clearLabels(),this.clickCallbacks.clear(),this.labelContainer.remove()}createElement(e){const t=document.createElement("div");return t.dataset.labelId=e,t.style.cssText=["position:absolute","display:flex","flex-direction:column","align-items:center","gap:5px","transform:translate(-50%, -100%)","pointer-events:auto","cursor:pointer","user-select:none","white-space:nowrap","font:12px/1.2 -apple-system,BlinkMacSystemFont,Segoe UI,Arial,sans-serif"].join(";"),t.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation();const n=this.labels.get(e);if(!n)return;const s={id:e,label:n,coordinate:n.coordinate,originalEvent:r};this.clickCallbacks.forEach(a=>a(s)),this.emitEvent?.("label-click",s)}),t}renderLabel(e){e.element.innerHTML="";const t=document.createElement("img"),r=this.normalizeIconSize(e.size);t.src=e.icon,t.alt=e.name,t.style.cssText=[`width:${r.width}px`,`height:${r.height}px`,"object-fit:contain","display:block","filter:drop-shadow(0 3px 5px rgba(0,0,0,.32))"].join(";");const n=document.createElement("span");n.textContent=e.name,n.style.cssText=["max-width:160px","overflow:hidden","text-overflow:ellipsis","padding:5px 9px","border-radius:6px","background:rgba(15,23,42,.88)","color:#fff","border:1px solid rgba(255,255,255,.16)","box-shadow:0 3px 10px rgba(0,0,0,.24)"].join(";"),e.element.title=e.name,e.element.appendChild(n),e.element.appendChild(t)}updateLabelPosition(e){const t=this.projectCoordinate(e.coordinate);if(!(e.visible&&t!=null&&t.visible!==!1)||!t){e.element.style.display="none";return}e.element.style.display="flex",e.element.style.left=`${t.x}px`,e.element.style.top=`${t.y}px`}handlePickClick=e=>{e.preventDefault(),e.stopImmediatePropagation();const t=this.pickCoordinate(e);this.isPicking=!1,this.container.style.cursor="",this.removePickBlockers(),this.container.removeEventListener("click",this.handlePickClick,!0),this.pickResolver?.(t),this.pickResolver=null,t&&this.emitEvent?.("label-pick",t)};toPayload(e){return{id:e.id,coordinate:e.coordinate,icon:e.icon,name:e.name,data:e.data,size:e.size,visible:e.visible}}normalizeIconSize(e){return typeof e=="number"?{width:e,height:e}:{width:this.normalizeSizeValue(e.width,28),height:this.normalizeSizeValue(e.height,28)}}normalizeSizeValue(e,t){return Number.isFinite(e)&&e>0?e:t}createId(){return`label-${Date.now()}-${Math.random().toString(16).slice(2)}`}addPickBlockers(){this.container.addEventListener("mousedown",this.blockPickInteraction,!0),this.container.addEventListener("mouseup",this.blockPickInteraction,!0),this.container.addEventListener("touchstart",this.blockPickInteraction,!0),this.container.addEventListener("touchmove",this.blockPickInteraction,!0),this.container.addEventListener("touchend",this.blockPickInteraction,!0)}removePickBlockers(){this.container.removeEventListener("mousedown",this.blockPickInteraction,!0),this.container.removeEventListener("mouseup",this.blockPickInteraction,!0),this.container.removeEventListener("touchstart",this.blockPickInteraction,!0),this.container.removeEventListener("touchmove",this.blockPickInteraction,!0),this.container.removeEventListener("touchend",this.blockPickInteraction,!0)}blockPickInteraction=e=>{e.stopImmediatePropagation()}}class Pa{engine;manager;constructor(e){this.engine=e,this.manager=new Na({container:e.container,className:"bim-engine-label-container bim-engine-label-container-2d",projectCoordinate:t=>this.projectCoordinate(t),pickCoordinate:t=>this.pickCoordinate(t),emitEvent:(t,r)=>this.engine.events?.trigger?.(t,r)})}pickPoint(){return this.manager.pickPoint()}startPickPoint(e){return this.manager.startPickPoint(e)}createLabel(e){return this.manager.createLabel(e)}updateLabel(e,t){return this.manager.updateLabel(e,t)}deleteLabel(e){return this.manager.deleteLabel(e)}removeLabel(e){return this.manager.removeLabel(e)}clearLabels(){this.manager.clearLabels()}getLabel(e){return this.manager.getLabel(e)}getLabels(){return this.manager.getLabels()}onLabelClick(e){return this.manager.onLabelClick(e)}offLabelClick(e){this.manager.offLabelClick(e)}update(){this.manager.update()}dispose(){this.manager.dispose()}projectCoordinate(e){const t=this.engine.cameraModule2d.worldToScreen(e.x??0,e.y??0),r=this.engine.renderer.domElement.clientWidth,n=this.engine.renderer.domElement.clientHeight;return{x:t.x,y:t.y,visible:t.x>=0&&t.x<=r&&t.y>=0&&t.y<=n}}pickCoordinate(e){const t=this.engine.renderer.domElement.getBoundingClientRect(),r=this.engine.cameraModule2d.screenToWorld(e.clientX-t.left,e.clientY-t.top);return{x:r.x,y:r.y,z:0}}}class Da{engine;mainViewPort=null;constructor(e){this.engine=e}saveMainViewPort(){const e=this.engine.cameraModule2d;return e?(this.mainViewPort={activeCamera:"orthographic",orthographicCamera:e.getViewState()},this.mainViewPort):null}setMainViewPort(e){this.mainViewPort=this.normalizeMainViewPort(e),this.goToMainPort()}goToMainPort(){const e=this.mainViewPort;e&&this.engine.cameraModule2d?.applyViewState(e.orthographicCamera)}resetMainViewPort(){this.mainViewPort=null,this.engine.resetView?.(),this.engine.fitToView?.()}normalizeMainViewPort(e){if(!e)return null;const t=e;return t.orthographicCamera?t:{activeCamera:"orthographic",orthographicCamera:e}}}class Ua{constructor(e,t){this.container=e,this.engine=t,this.el=document.createElement("div"),this.el.className="engine-2d-workspace-tabs",this.container.appendChild(this.el),this.unsubscribe=this.engine.events?.on(et.ModelLoaded,()=>this.refresh())??(()=>{}),this.refresh()}el;unsubscribe;loading=!1;refresh(){const e=this.engine.getLayouts?.()??[],t=this.engine.loaderModule2d?.getActiveWorkspace?.()??{type:"model"};this.el.innerHTML="",this.el.appendChild(this.createTab("模型",t.type==="model",()=>this.switchToModelSpace())),e.forEach((r,n)=>{const s=r.name||`布局${n+1}`;this.el.appendChild(this.createTab(s,t.type==="layout"&&t.layoutId===r.id,()=>this.switchToLayout(r.id)))}),this.el.style.display=e.length>0?"flex":"none"}createTab(e,t,r){const n=document.createElement("button");return n.type="button",n.className="engine-2d-workspace-tabs__item",n.classList.toggle("engine-2d-workspace-tabs__item--active",t),n.textContent=e,n.title=e,n.disabled=this.loading||t,n.addEventListener("click",r),n}async switchToModelSpace(){this.loading||await this.runSwitch(()=>this.engine.showModelSpace?.())}async switchToLayout(e){this.loading||await this.runSwitch(()=>this.engine.loadLayout?.(e))}async runSwitch(e){this.loading=!0,this.refresh();try{await e()}finally{this.loading=!1,this.refresh()}}dispose(){this.unsubscribe(),this.el.remove()}}const Mt={version:"3.11.3"}.version;function xr(){const o=globalThis.crypto?.subtle;if(!o)throw new Error("[BimEngine] Web Crypto API is required for secure sdkAuth credentials mode");return o}function Lt(o){return new TextEncoder().encode(o)}function Rt(o){return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}function ji(o){let e="";return o.forEach(t=>{e+=String.fromCharCode(t)}),btoa(e)}function Va(o){const e=o.getUTCFullYear(),t=String(o.getUTCMonth()+1).padStart(2,"0"),r=String(o.getUTCDate()).padStart(2,"0");return`${e}${t}${r}`}async function Oa(o){const e=await xr().digest("SHA-256",Rt(Lt(o)));return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Fa(o,e){const t=xr(),r=await t.importKey("raw",Rt(o),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return t.sign("HMAC",r,Rt(Lt(e)))}function za(o){return Lt([o.appId,o.engineType,o.requestDate,String(o.timestamp),o.nonce].join("|"))}async function Ka(o){const e=xr(),t=new Date,r=t.getTime(),n=Va(t),s=globalThis.crypto.randomUUID(),a=globalThis.crypto.getRandomValues(new Uint8Array(12)),i=await Oa(o.appSecret),l=await Fa(Lt(i),n),c=await e.importKey("raw",l,"AES-GCM",!1,["encrypt"]),p=JSON.stringify({appKey:o.appKey,appSecret:o.appSecret}),b=await e.encrypt({name:"AES-GCM",iv:a,additionalData:Rt(za({appId:o.appId,engineType:o.engineType,requestDate:n,timestamp:r,nonce:s})),tagLength:128},c,Rt(Lt(p)));return{appId:o.appId,engineType:o.engineType,requestDate:n,timestamp:r,nonce:s,iv:ji(a),cipherText:ji(new Uint8Array(b)),sdkVersion:o.sdkVersion,origin:o.origin,product:o.product}}const Cr=new Map;function Yt(o){return o.replace(/\/+$/,"")}function $t(o){if(o)return o;if(typeof window<"u"&&typeof window.location?.origin=="string")return window.location.origin}function Ha(o,e){return JSON.stringify({endpoint:Yt(o.endpoint),token:o.token??"",appId:o.appId??"",appKey:o.appKey??"",appSecret:o.appSecret??"",origin:$t(o.origin)??"",product:o.product??"",engineType:e,sdkVersion:Mt})}async function br(o,e,t){const r=typeof AbortController<"u"?new AbortController:void 0,n=r?setTimeout(()=>r.abort(),t):void 0;try{const s=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:r?.signal}),a=await s.json().catch(()=>({}));if(!s.ok){const i=a?.error?.message??a?.message??`SDK authentication failed with status ${s.status}`;throw new Error(i)}return a}finally{n!=null&&clearTimeout(n)}}async function Ga(o,e){const t=await br(`${Yt(o.endpoint)}/oauth/sdk-verify`,{sdkToken:o.token,engineType:e,sdkVersion:Mt,origin:$t(o.origin),product:o.product},o.timeoutMs??8e3);return t.sdkToken=o.token,t}async function Wa(o,e){const t=await Ka({appId:o.appId,appKey:o.appKey,appSecret:o.appSecret,engineType:e,sdkVersion:Mt,origin:$t(o.origin),product:o.product}),r=await br(`${Yt(o.endpoint)}/oauth/sdk-token/secure`,t,o.timeoutMs??8e3),n=await br(`${Yt(o.endpoint)}/oauth/sdk-verify`,{sdkToken:r.sdkToken,engineType:e,sdkVersion:Mt,origin:$t(o.origin),product:o.product},o.timeoutMs??8e3);return n.sdkToken=r.sdkToken,n}async function ja(o,e){const t=o?.sdkAuth;if(!t)return null;if(!t.endpoint)throw new Error("[BimEngine] sdkAuth.endpoint is required");if(!t.token&&!(t.appId&&t.appKey&&t.appSecret))return null;const r=Ha(t,e),n=Cr.get(r);if(n){const a=await n;return o&&(o.__sdkAuthSession=a),a}const s=(t.token?Ga(t,e):Wa(t,e)).then(a=>{if(a.authorized!==!0)throw new Error("[BimEngine] SDK authorization rejected");return o&&(o.__sdkAuthSession=a),a}).catch(a=>{throw Cr.delete(r),a});return Cr.set(r,s),s}function qa(o){return o instanceof Uint8Array||ArrayBuffer.isView(o)&&o.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in o&&o.BYTES_PER_ELEMENT===1}function qi(o){if(typeof o!="number")throw new TypeError("number expected, got "+typeof o);if(!Number.isSafeInteger(o)||o<0)throw new RangeError("positive integer expected, got "+o)}function tt(o,e,t=""){const r=qa(o),n=o?.length,s=e!==void 0;if(!r||s&&n!==e){const a=t&&`"${t}" `,i=s?` of length ${e}`:"",l=r?`length=${n}`:`type=${typeof o}`,c=a+"expected Uint8Array"+i+", got "+l;throw r?new RangeError(c):new TypeError(c)}return o}function Yi(o,e=!0){if(o.destroyed)throw new Error("Hash instance has been destroyed");if(e&&o.finished)throw new Error("Hash#digest() has already been called")}function Ya(o,e,t=!1){tt(o,void 0,"output");const r=e.outputLen;if(o.length<r)throw new RangeError("digestInto() expects output buffer of length at least "+r);if(t&&!Nt(o))throw new Error("invalid output, must be aligned")}function $a(o){return new Uint8Array(o.buffer,o.byteOffset,o.byteLength)}function wt(o){return new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4))}function Ct(...o){for(let e=0;e<o.length;e++)o[e].fill(0)}function Zt(o){return new DataView(o.buffer,o.byteOffset,o.byteLength)}const Er=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,$i=o=>o<<24&4278190080|o<<8&16711680|o>>>8&65280|o>>>24&255,Ne=Er?o=>o:o=>$i(o)>>>0,wr=Er?o=>o:o=>{for(let e=0;e<o.length;e++)o[e]=$i(o[e]);return o};function Za(o,e){if(o.length!==e.length)return!1;let t=0;for(let r=0;r<o.length;r++)t|=o[r]^e[r];return t===0}function Xa(o,e,t){const r=e,n=t||(()=>[]),s=(i,l)=>r(l,...n(i)).update(i).digest(),a=r(new Uint8Array(o),...n(new Uint8Array(0)));return s.outputLen=a.outputLen,s.blockLen=a.blockLen,s.create=(i,...l)=>r(i,...l),s}const Qa=(o,e)=>{function t(r,...n){if(tt(r,void 0,"key"),o.nonceLength!==void 0){const p=n[0];tt(p,o.varSizeNonce?void 0:o.nonceLength,"nonce")}const s=o.tagLength;s&&n[1]!==void 0&&tt(n[1],void 0,"AAD");const a=e(r,...n),i=(p,b)=>{if(b!==void 0){if(p!==2)throw new Error("cipher output not supported");tt(b,void 0,"output")}};let l=!1;return{encrypt(p,b){if(l)throw new Error("cannot encrypt() twice with same key + nonce");return l=!0,tt(p),i(a.encrypt.length,b),a.encrypt(p,b)},decrypt(p,b){if(tt(p),s&&p.length<s)throw new Error('"ciphertext" expected length bigger than tagLength='+s);return i(a.decrypt.length,b),a.decrypt(p,b)}}}return Object.assign(t,o),t};function Ja(o,e,t=!0){if(e===void 0)return new Uint8Array(o);if(tt(e,void 0,"output"),e.length!==o)throw new Error('"output" expected Uint8Array of length '+o+", got: "+e.length);if(t&&!Nt(e))throw new Error("invalid output, must be aligned");return e}function eo(o,e,t){qi(o),qi(e);const r=new Uint8Array(16),n=Zt(r);return n.setBigUint64(0,BigInt(e),t),n.setBigUint64(8,BigInt(o),t),r}function Nt(o){return o.byteOffset%4===0}function Pt(o){return Uint8Array.from(tt(o))}const At=16,Zi=new Uint8Array(16),Dt=wt(Zi),to=225,ro=(o,e,t,r)=>{const n=r&1;return{s3:t<<31|r>>>1,s2:e<<31|t>>>1,s1:o<<31|e>>>1,s0:o>>>1^to<<24&-(n&1)}},Xt=o=>(o>>>0&255)<<24|(o>>>8&255)<<16|(o>>>16&255)<<8|o>>>24&255|0,io=o=>o>64*1024?8:o>1024?4:2;class no{blockLen=At;outputLen=At;s0=0;s1=0;s2=0;s3=0;finished=!1;destroyed=!1;t;W;windowSize;constructor(e,t){tt(e,16,"key"),e=Pt(e);const r=Zt(e);let n=r.getUint32(0,!1),s=r.getUint32(4,!1),a=r.getUint32(8,!1),i=r.getUint32(12,!1);const l=[];for(let m=0;m<128;m++)l.push({s0:Xt(n),s1:Xt(s),s2:Xt(a),s3:Xt(i)}),{s0:n,s1:s,s2:a,s3:i}=ro(n,s,a,i);const c=io(t||1024);if(![1,2,4,8].includes(c))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=c;const b=128/c,x=this.windowSize=2**c,h=[];for(let m=0;m<b;m++)for(let d=0;d<x;d++){let y=0,u=0,v=0,E=0;for(let T=0;T<c;T++){if(!(d>>>c-T-1&1))continue;const{s0:w,s1:g,s2:f,s3:k}=l[c*m+T];y^=w,u^=g,v^=f,E^=k}h.push({s0:y,s1:u,s2:v,s3:E})}this.t=h}_updateBlock(e,t,r,n){e^=this.s0,t^=this.s1,r^=this.s2,n^=this.s3;const{W:s,t:a,windowSize:i}=this;let l=0,c=0,p=0,b=0;const x=(1<<s)-1;let h=0;for(const m of[e,t,r,n])for(let d=0;d<4;d++){const y=m>>>8*d&255;for(let u=8/s-1;u>=0;u--){const v=y>>>s*u&x,{s0:E,s1:T,s2:_,s3:w}=a[h*i+v];l^=E,c^=T,p^=_,b^=w,h+=1}}this.s0=l,this.s1=c,this.s2=p,this.s3=b}update(e){Yi(this),tt(e),e=Pt(e);const t=wt(e),r=Math.floor(e.length/At),n=e.length%At;for(let s=0;s<r;s++)this._updateBlock(Ne(t[s*4+0]),Ne(t[s*4+1]),Ne(t[s*4+2]),Ne(t[s*4+3]));return n&&(Zi.set(e.subarray(r*At)),this._updateBlock(Ne(Dt[0]),Ne(Dt[1]),Ne(Dt[2]),Ne(Dt[3])),Ct(Dt)),this}destroy(){this.destroyed=!0;const{t:e}=this;for(const t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){Yi(this),Ya(e,this,!0),this.finished=!0;const{s0:t,s1:r,s2:n,s3:s}=this,a=wt(e);a[0]=t,a[1]=r,a[2]=n,a[3]=s,wr(a)}digest(){const e=new Uint8Array(At);return this.digestInto(e),this.destroy(),e}}const Xi=Xa(16,(o,e)=>new no(o,e),o=>[o.length]),Sr=16,so=4,Qt=new Uint8Array(Sr),ao=283;function oo(o){if(![16,24,32].includes(o.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+o.length)}function Tr(o){return o<<1^ao&-(o>>7)}function Qi(o,e){let t=0;for(;e>0;e>>=1)t^=o&-(e&1),o=Tr(o);return t}const lo=(()=>{const o=new Uint8Array(256);for(let t=0,r=1;t<256;t++,r^=Tr(r))o[t]=r;const e=new Uint8Array(256);e[0]=99;for(let t=0;t<255;t++){let r=o[255-t];r|=r<<8,e[o[t]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return Ct(o),e})(),co=o=>o<<24|o>>>8,Ar=o=>o<<8|o>>>24;function uo(o,e){if(o.length!==256)throw new Error("Wrong sbox length");const t=new Uint32Array(256).map((c,p)=>e(o[p])),r=t.map(Ar),n=r.map(Ar),s=n.map(Ar),a=new Uint32Array(256*256),i=new Uint32Array(256*256),l=new Uint16Array(256*256);for(let c=0;c<256;c++)for(let p=0;p<256;p++){const b=c*256+p;a[b]=t[c]^r[p],i[b]=n[c]^s[p],l[b]=o[c]<<8|o[p]}return{sbox:o,sbox2:l,T0:t,T1:r,T2:n,T3:s,T01:a,T23:i}}const Ji=uo(lo,o=>Qi(o,3)<<24|o<<16|o<<8|Qi(o,2)),ho=(()=>{const o=new Uint8Array(16);for(let e=0,t=1;e<16;e++,t=Tr(t))o[e]=t;return o})();function fo(o){tt(o);const e=o.length;oo(o);const{sbox2:t}=Ji,r=[];(!Er||!Nt(o))&&r.push(o=Pt(o));const n=wr(wt(o)),s=n.length,a=l=>Ut(t,l,l,l,l),i=new Uint32Array(e+28);i.set(n);for(let l=s;l<i.length;l++){let c=i[l-1];l%s===0?c=a(co(c))^ho[l/s-1]:s>6&&l%s===4&&(c=a(c)),i[l]=i[l-s]^c}return Ct(...r),i}function Jt(o,e,t,r,n,s){return o[t<<8&65280|r>>>8&255]^e[n>>>8&65280|s>>>24&255]}function Ut(o,e,t,r,n){return o[e&255|t&65280]|o[r>>>16&255|n>>>16&65280]<<16}function en(o,e,t,r,n){const{sbox2:s,T01:a,T23:i}=Ji;let l=0;e^=o[l++],t^=o[l++],r^=o[l++],n^=o[l++];const c=o.length/4-2;for(let m=0;m<c;m++){const d=o[l++]^Jt(a,i,e,t,r,n),y=o[l++]^Jt(a,i,t,r,n,e),u=o[l++]^Jt(a,i,r,n,e,t),v=o[l++]^Jt(a,i,n,e,t,r);e=d,t=y,r=u,n=v}const p=o[l++]^Ut(s,e,t,r,n),b=o[l++]^Ut(s,t,r,n,e),x=o[l++]^Ut(s,r,n,e,t),h=o[l++]^Ut(s,n,e,t,r);return{s0:p,s1:b,s2:x,s3:h}}function er(o,e,t,r,n){tt(t,Sr,"nonce"),tt(r),n=Ja(r.length,n);const s=t,a=wt(s),i=Zt(s),l=wt(r),c=wt(n),p=e?0:12,b=r.length;let x=i.getUint32(p,e),{s0:h,s1:m,s2:d,s3:y}=en(o,Ne(a[0]),Ne(a[1]),Ne(a[2]),Ne(a[3]));for(let v=0;v+4<=l.length;v+=4)c[v+0]=l[v+0]^Ne(h),c[v+1]=l[v+1]^Ne(m),c[v+2]=l[v+2]^Ne(d),c[v+3]=l[v+3]^Ne(y),x=x+1>>>0,i.setUint32(p,x,e),{s0:h,s1:m,s2:d,s3:y}=en(o,Ne(a[0]),Ne(a[1]),Ne(a[2]),Ne(a[3]));const u=Sr*Math.floor(l.length/so);if(u<b){const v=new Uint32Array([h,m,d,y]);wr(v);const E=$a(v);for(let T=u,_=0;T<b;T++,_++)n[T]=r[T]^E[_];Ct(v)}return n}function po(o,e,t,r,n){const s=n?n.length:0,a=o.create(t,r.length+s);n&&a.update(n);const i=eo(8*r.length,8*s,e);a.update(r),a.update(i);const l=a.digest();return Ct(i),l}const go=Qa({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(e,t,r){if(t.length<8)throw new Error("aes/gcm: invalid nonce length");const n=16;function s(i,l,c){const p=po(Xi,!1,i,c,r);for(let b=0;b<l.length;b++)p[b]^=l[b];return p}function a(){const i=fo(e),l=Qt.slice(),c=Qt.slice();if(er(i,!1,c,c,l),t.length===12)c.set(t);else{const b=Qt.slice();Zt(b).setBigUint64(8,BigInt(t.length*8),!1);const h=Xi.create(l).update(t).update(b);h.digestInto(c),h.destroy()}const p=er(i,!1,c,Qt);return{xk:i,authKey:l,counter:c,tagMask:p}}return{encrypt(i){const{xk:l,authKey:c,counter:p,tagMask:b}=a(),x=new Uint8Array(i.length+n),h=[l,c,p,b];Nt(i)||h.push(i=Pt(i)),er(l,!1,p,i,x.subarray(0,i.length));const m=s(c,b,x.subarray(0,x.length-n));return h.push(m),x.set(m,i.length),Ct(...h),x},decrypt(i){const{xk:l,authKey:c,counter:p,tagMask:b}=a(),x=[l,c,b,p];Nt(i)||x.push(i=Pt(i));const h=i.subarray(0,-n),m=i.subarray(-n),d=s(c,b,h);if(x.push(d),!Za(d,m))throw Ct(...x),new Error("aes/gcm: invalid ghash tag");const y=er(l,!1,p,h);return Ct(...x),y}}});var _r,tn;function xe(){return tn||(tn=1,_r={options:{usePureJavaScript:!1}}),_r}var Ir={exports:{}},kr,rn;function mo(){if(rn)return kr;rn=1;var o={};kr=o;var e={};o.encode=function(r,n,s){if(typeof n!="string")throw new TypeError('"alphabet" must be a string.');if(s!==void 0&&typeof s!="number")throw new TypeError('"maxline" must be a number.');var a="";if(!(r instanceof Uint8Array))a=t(r,n);else{var i=0,l=n.length,c=n.charAt(0),p=[0];for(i=0;i<r.length;++i){for(var b=0,x=r[i];b<p.length;++b)x+=p[b]<<8,p[b]=x%l,x=x/l|0;for(;x>0;)p.push(x%l),x=x/l|0}for(i=0;r[i]===0&&i<r.length-1;++i)a+=c;for(i=p.length-1;i>=0;--i)a+=n[p[i]]}if(s){var h=new RegExp(".{1,"+s+"}","g");a=a.match(h).join(`\r
|
|
222
|
-
`)}return a},o.decode=function(r,n){if(typeof r!="string")throw new TypeError('"input" must be a string.');if(typeof n!="string")throw new TypeError('"alphabet" must be a string.');var s=e[n];if(!s){s=e[n]=[];for(var a=0;a<n.length;++a)s[n.charCodeAt(a)]=a}r=r.replace(/\s/g,"");for(var i=n.length,l=n.charAt(0),c=[0],a=0;a<r.length;a++){var p=s[r.charCodeAt(a)];if(p===void 0)return;for(var b=0,x=p;b<c.length;++b)x+=c[b]*i,c[b]=x&255,x>>=8;for(;x>0;)c.push(x&255),x>>=8}for(var h=0;r[h]===l&&h<r.length-1;++h)c.push(0);return typeof Buffer<"u"?Buffer.from(c.reverse()):new Uint8Array(c.reverse())};function t(r,n){var s=0,a=n.length,i=n.charAt(0),l=[0];for(s=0;s<r.length();++s){for(var c=0,p=r.at(s);c<l.length;++c)p+=l[c]<<8,l[c]=p%a,p=p/a|0;for(;p>0;)l.push(p%a),p=p/a|0}var b="";for(s=0;r.at(s)===0&&s<r.length()-1;++s)b+=i;for(s=l.length-1;s>=0;--s)b+=n[l[s]];return b}return kr}var nn;function Ee(){if(nn)return Ir.exports;nn=1;var o=xe(),e=mo(),t=Ir.exports=o.util=o.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){t.nextTick=process.nextTick,typeof setImmediate=="function"?t.setImmediate=setImmediate:t.setImmediate=t.nextTick;return}if(typeof setImmediate=="function"){t.setImmediate=function(){return setImmediate.apply(void 0,arguments)},t.nextTick=function(g){return setImmediate(g)};return}if(t.setImmediate=function(g){setTimeout(g,0)},typeof window<"u"&&typeof window.postMessage=="function"){let g=function(f){if(f.source===window&&f.data===u){f.stopPropagation();var k=v.slice();v.length=0,k.forEach(function(L){L()})}};var u="forge.setImmediate",v=[];t.setImmediate=function(f){v.push(f),v.length===1&&window.postMessage(u,"*")},window.addEventListener("message",g,!0)}if(typeof MutationObserver<"u"){var E=Date.now(),T=!0,_=document.createElement("div"),v=[];new MutationObserver(function(){var f=v.slice();v.length=0,f.forEach(function(k){k()})}).observe(_,{attributes:!0});var w=t.setImmediate;t.setImmediate=function(f){Date.now()-E>15?(E=Date.now(),w(f)):(v.push(f),v.length===1&&_.setAttribute("a",T=!T))}}t.nextTick=t.setImmediate})(),t.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,t.globalScope=(function(){return t.isNodejs?kt:typeof self>"u"?window:self})(),t.isArray=Array.isArray||function(u){return Object.prototype.toString.call(u)==="[object Array]"},t.isArrayBuffer=function(u){return typeof ArrayBuffer<"u"&&u instanceof ArrayBuffer},t.isArrayBufferView=function(u){return u&&t.isArrayBuffer(u.buffer)&&u.byteLength!==void 0};function r(u){if(!(u===8||u===16||u===24||u===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+u)}t.ByteBuffer=n;function n(u){if(this.data="",this.read=0,typeof u=="string")this.data=u;else if(t.isArrayBuffer(u)||t.isArrayBufferView(u))if(typeof Buffer<"u"&&u instanceof Buffer)this.data=u.toString("binary");else{var v=new Uint8Array(u);try{this.data=String.fromCharCode.apply(null,v)}catch{for(var E=0;E<v.length;++E)this.putByte(v[E])}}else(u instanceof n||typeof u=="object"&&typeof u.data=="string"&&typeof u.read=="number")&&(this.data=u.data,this.read=u.read);this._constructedStringLength=0}t.ByteStringBuffer=n;var s=4096;t.ByteStringBuffer.prototype._optimizeConstructedString=function(u){this._constructedStringLength+=u,this._constructedStringLength>s&&(this.data.substr(0,1),this._constructedStringLength=0)},t.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},t.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},t.ByteStringBuffer.prototype.putByte=function(u){return this.putBytes(String.fromCharCode(u))},t.ByteStringBuffer.prototype.fillWithByte=function(u,v){u=String.fromCharCode(u);for(var E=this.data;v>0;)v&1&&(E+=u),v>>>=1,v>0&&(u+=u);return this.data=E,this._optimizeConstructedString(v),this},t.ByteStringBuffer.prototype.putBytes=function(u){return this.data+=u,this._optimizeConstructedString(u.length),this},t.ByteStringBuffer.prototype.putString=function(u){return this.putBytes(t.encodeUtf8(u))},t.ByteStringBuffer.prototype.putInt16=function(u){return this.putBytes(String.fromCharCode(u>>8&255)+String.fromCharCode(u&255))},t.ByteStringBuffer.prototype.putInt24=function(u){return this.putBytes(String.fromCharCode(u>>16&255)+String.fromCharCode(u>>8&255)+String.fromCharCode(u&255))},t.ByteStringBuffer.prototype.putInt32=function(u){return this.putBytes(String.fromCharCode(u>>24&255)+String.fromCharCode(u>>16&255)+String.fromCharCode(u>>8&255)+String.fromCharCode(u&255))},t.ByteStringBuffer.prototype.putInt16Le=function(u){return this.putBytes(String.fromCharCode(u&255)+String.fromCharCode(u>>8&255))},t.ByteStringBuffer.prototype.putInt24Le=function(u){return this.putBytes(String.fromCharCode(u&255)+String.fromCharCode(u>>8&255)+String.fromCharCode(u>>16&255))},t.ByteStringBuffer.prototype.putInt32Le=function(u){return this.putBytes(String.fromCharCode(u&255)+String.fromCharCode(u>>8&255)+String.fromCharCode(u>>16&255)+String.fromCharCode(u>>24&255))},t.ByteStringBuffer.prototype.putInt=function(u,v){r(v);var E="";do v-=8,E+=String.fromCharCode(u>>v&255);while(v>0);return this.putBytes(E)},t.ByteStringBuffer.prototype.putSignedInt=function(u,v){return u<0&&(u+=2<<v-1),this.putInt(u,v)},t.ByteStringBuffer.prototype.putBuffer=function(u){return this.putBytes(u.getBytes())},t.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},t.ByteStringBuffer.prototype.getInt16=function(){var u=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,u},t.ByteStringBuffer.prototype.getInt24=function(){var u=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,u},t.ByteStringBuffer.prototype.getInt32=function(){var u=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,u},t.ByteStringBuffer.prototype.getInt16Le=function(){var u=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,u},t.ByteStringBuffer.prototype.getInt24Le=function(){var u=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,u},t.ByteStringBuffer.prototype.getInt32Le=function(){var u=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,u},t.ByteStringBuffer.prototype.getInt=function(u){r(u);var v=0;do v=(v<<8)+this.data.charCodeAt(this.read++),u-=8;while(u>0);return v},t.ByteStringBuffer.prototype.getSignedInt=function(u){var v=this.getInt(u),E=2<<u-2;return v>=E&&(v-=E<<1),v},t.ByteStringBuffer.prototype.getBytes=function(u){var v;return u?(u=Math.min(this.length(),u),v=this.data.slice(this.read,this.read+u),this.read+=u):u===0?v="":(v=this.read===0?this.data:this.data.slice(this.read),this.clear()),v},t.ByteStringBuffer.prototype.bytes=function(u){return typeof u>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+u)},t.ByteStringBuffer.prototype.at=function(u){return this.data.charCodeAt(this.read+u)},t.ByteStringBuffer.prototype.setAt=function(u,v){return this.data=this.data.substr(0,this.read+u)+String.fromCharCode(v)+this.data.substr(this.read+u+1),this},t.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},t.ByteStringBuffer.prototype.copy=function(){var u=t.createBuffer(this.data);return u.read=this.read,u},t.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},t.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},t.ByteStringBuffer.prototype.truncate=function(u){var v=Math.max(0,this.length()-u);return this.data=this.data.substr(this.read,v),this.read=0,this},t.ByteStringBuffer.prototype.toHex=function(){for(var u="",v=this.read;v<this.data.length;++v){var E=this.data.charCodeAt(v);E<16&&(u+="0"),u+=E.toString(16)}return u},t.ByteStringBuffer.prototype.toString=function(){return t.decodeUtf8(this.bytes())};function a(u,v){v=v||{},this.read=v.readOffset||0,this.growSize=v.growSize||1024;var E=t.isArrayBuffer(u),T=t.isArrayBufferView(u);if(E||T){E?this.data=new DataView(u):this.data=new DataView(u.buffer,u.byteOffset,u.byteLength),this.write="writeOffset"in v?v.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,u!=null&&this.putBytes(u),"writeOffset"in v&&(this.write=v.writeOffset)}t.DataBuffer=a,t.DataBuffer.prototype.length=function(){return this.write-this.read},t.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},t.DataBuffer.prototype.accommodate=function(u,v){if(this.length()>=u)return this;v=Math.max(v||this.growSize,u);var E=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),T=new Uint8Array(this.length()+v);return T.set(E),this.data=new DataView(T.buffer),this},t.DataBuffer.prototype.putByte=function(u){return this.accommodate(1),this.data.setUint8(this.write++,u),this},t.DataBuffer.prototype.fillWithByte=function(u,v){this.accommodate(v);for(var E=0;E<v;++E)this.data.setUint8(u);return this},t.DataBuffer.prototype.putBytes=function(u,v){if(t.isArrayBufferView(u)){var E=new Uint8Array(u.buffer,u.byteOffset,u.byteLength),T=E.byteLength-E.byteOffset;this.accommodate(T);var _=new Uint8Array(this.data.buffer,this.write);return _.set(E),this.write+=T,this}if(t.isArrayBuffer(u)){var E=new Uint8Array(u);this.accommodate(E.byteLength);var _=new Uint8Array(this.data.buffer);return _.set(E,this.write),this.write+=E.byteLength,this}if(u instanceof t.DataBuffer||typeof u=="object"&&typeof u.read=="number"&&typeof u.write=="number"&&t.isArrayBufferView(u.data)){var E=new Uint8Array(u.data.byteLength,u.read,u.length());this.accommodate(E.byteLength);var _=new Uint8Array(u.data.byteLength,this.write);return _.set(E),this.write+=E.byteLength,this}if(u instanceof t.ByteStringBuffer&&(u=u.data,v="binary"),v=v||"binary",typeof u=="string"){var w;if(v==="hex")return this.accommodate(Math.ceil(u.length/2)),w=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.hex.decode(u,w,this.write),this;if(v==="base64")return this.accommodate(Math.ceil(u.length/4)*3),w=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.base64.decode(u,w,this.write),this;if(v==="utf8"&&(u=t.encodeUtf8(u),v="binary"),v==="binary"||v==="raw")return this.accommodate(u.length),w=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.raw.decode(w),this;if(v==="utf16")return this.accommodate(u.length*2),w=new Uint16Array(this.data.buffer,this.write),this.write+=t.text.utf16.encode(w),this;throw new Error("Invalid encoding: "+v)}throw Error("Invalid parameter: "+u)},t.DataBuffer.prototype.putBuffer=function(u){return this.putBytes(u),u.clear(),this},t.DataBuffer.prototype.putString=function(u){return this.putBytes(u,"utf16")},t.DataBuffer.prototype.putInt16=function(u){return this.accommodate(2),this.data.setInt16(this.write,u),this.write+=2,this},t.DataBuffer.prototype.putInt24=function(u){return this.accommodate(3),this.data.setInt16(this.write,u>>8&65535),this.data.setInt8(this.write,u>>16&255),this.write+=3,this},t.DataBuffer.prototype.putInt32=function(u){return this.accommodate(4),this.data.setInt32(this.write,u),this.write+=4,this},t.DataBuffer.prototype.putInt16Le=function(u){return this.accommodate(2),this.data.setInt16(this.write,u,!0),this.write+=2,this},t.DataBuffer.prototype.putInt24Le=function(u){return this.accommodate(3),this.data.setInt8(this.write,u>>16&255),this.data.setInt16(this.write,u>>8&65535,!0),this.write+=3,this},t.DataBuffer.prototype.putInt32Le=function(u){return this.accommodate(4),this.data.setInt32(this.write,u,!0),this.write+=4,this},t.DataBuffer.prototype.putInt=function(u,v){r(v),this.accommodate(v/8);do v-=8,this.data.setInt8(this.write++,u>>v&255);while(v>0);return this},t.DataBuffer.prototype.putSignedInt=function(u,v){return r(v),this.accommodate(v/8),u<0&&(u+=2<<v-1),this.putInt(u,v)},t.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},t.DataBuffer.prototype.getInt16=function(){var u=this.data.getInt16(this.read);return this.read+=2,u},t.DataBuffer.prototype.getInt24=function(){var u=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,u},t.DataBuffer.prototype.getInt32=function(){var u=this.data.getInt32(this.read);return this.read+=4,u},t.DataBuffer.prototype.getInt16Le=function(){var u=this.data.getInt16(this.read,!0);return this.read+=2,u},t.DataBuffer.prototype.getInt24Le=function(){var u=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,u},t.DataBuffer.prototype.getInt32Le=function(){var u=this.data.getInt32(this.read,!0);return this.read+=4,u},t.DataBuffer.prototype.getInt=function(u){r(u);var v=0;do v=(v<<8)+this.data.getInt8(this.read++),u-=8;while(u>0);return v},t.DataBuffer.prototype.getSignedInt=function(u){var v=this.getInt(u),E=2<<u-2;return v>=E&&(v-=E<<1),v},t.DataBuffer.prototype.getBytes=function(u){var v;return u?(u=Math.min(this.length(),u),v=this.data.slice(this.read,this.read+u),this.read+=u):u===0?v="":(v=this.read===0?this.data:this.data.slice(this.read),this.clear()),v},t.DataBuffer.prototype.bytes=function(u){return typeof u>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+u)},t.DataBuffer.prototype.at=function(u){return this.data.getUint8(this.read+u)},t.DataBuffer.prototype.setAt=function(u,v){return this.data.setUint8(u,v),this},t.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},t.DataBuffer.prototype.copy=function(){return new t.DataBuffer(this)},t.DataBuffer.prototype.compact=function(){if(this.read>0){var u=new Uint8Array(this.data.buffer,this.read),v=new Uint8Array(u.byteLength);v.set(u),this.data=new DataView(v),this.write-=this.read,this.read=0}return this},t.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},t.DataBuffer.prototype.truncate=function(u){return this.write=Math.max(0,this.length()-u),this.read=Math.min(this.read,this.write),this},t.DataBuffer.prototype.toHex=function(){for(var u="",v=this.read;v<this.data.byteLength;++v){var E=this.data.getUint8(v);E<16&&(u+="0"),u+=E.toString(16)}return u},t.DataBuffer.prototype.toString=function(u){var v=new Uint8Array(this.data,this.read,this.length());if(u=u||"utf8",u==="binary"||u==="raw")return t.binary.raw.encode(v);if(u==="hex")return t.binary.hex.encode(v);if(u==="base64")return t.binary.base64.encode(v);if(u==="utf8")return t.text.utf8.decode(v);if(u==="utf16")return t.text.utf16.decode(v);throw new Error("Invalid encoding: "+u)},t.createBuffer=function(u,v){return v=v||"raw",u!==void 0&&v==="utf8"&&(u=t.encodeUtf8(u)),new t.ByteBuffer(u)},t.fillString=function(u,v){for(var E="";v>0;)v&1&&(E+=u),v>>>=1,v>0&&(u+=u);return E},t.xorBytes=function(u,v,E){for(var T="",_="",w="",g=0,f=0;E>0;--E,++g)_=u.charCodeAt(g)^v.charCodeAt(g),f>=10&&(T+=w,w="",f=0),w+=String.fromCharCode(_),++f;return T+=w,T},t.hexToBytes=function(u){var v="",E=0;for(u.length&!0&&(E=1,v+=String.fromCharCode(parseInt(u[0],16)));E<u.length;E+=2)v+=String.fromCharCode(parseInt(u.substr(E,2),16));return v},t.bytesToHex=function(u){return t.createBuffer(u).toHex()},t.int32ToBytes=function(u){return String.fromCharCode(u>>24&255)+String.fromCharCode(u>>16&255)+String.fromCharCode(u>>8&255)+String.fromCharCode(u&255)};var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],c="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";t.encode64=function(u,v){for(var E="",T="",_,w,g,f=0;f<u.length;)_=u.charCodeAt(f++),w=u.charCodeAt(f++),g=u.charCodeAt(f++),E+=i.charAt(_>>2),E+=i.charAt((_&3)<<4|w>>4),isNaN(w)?E+="==":(E+=i.charAt((w&15)<<2|g>>6),E+=isNaN(g)?"=":i.charAt(g&63)),v&&E.length>v&&(T+=E.substr(0,v)+`\r
|
|
223
|
-
`,E=E.substr(v));return T+=E,T},t.decode64=function(u){u=u.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var v="",E,T,_,w,g=0;g<u.length;)E=l[u.charCodeAt(g++)-43],T=l[u.charCodeAt(g++)-43],_=l[u.charCodeAt(g++)-43],w=l[u.charCodeAt(g++)-43],v+=String.fromCharCode(E<<2|T>>4),_!==64&&(v+=String.fromCharCode((T&15)<<4|_>>2),w!==64&&(v+=String.fromCharCode((_&3)<<6|w)));return v},t.encodeUtf8=function(u){return unescape(encodeURIComponent(u))},t.decodeUtf8=function(u){return decodeURIComponent(escape(u))},t.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:e.encode,decode:e.decode}},t.binary.raw.encode=function(u){return String.fromCharCode.apply(null,u)},t.binary.raw.decode=function(u,v,E){var T=v;T||(T=new Uint8Array(u.length)),E=E||0;for(var _=E,w=0;w<u.length;++w)T[_++]=u.charCodeAt(w);return v?_-E:T},t.binary.hex.encode=t.bytesToHex,t.binary.hex.decode=function(u,v,E){var T=v;T||(T=new Uint8Array(Math.ceil(u.length/2))),E=E||0;var _=0,w=E;for(u.length&1&&(_=1,T[w++]=parseInt(u[0],16));_<u.length;_+=2)T[w++]=parseInt(u.substr(_,2),16);return v?w-E:T},t.binary.base64.encode=function(u,v){for(var E="",T="",_,w,g,f=0;f<u.byteLength;)_=u[f++],w=u[f++],g=u[f++],E+=i.charAt(_>>2),E+=i.charAt((_&3)<<4|w>>4),isNaN(w)?E+="==":(E+=i.charAt((w&15)<<2|g>>6),E+=isNaN(g)?"=":i.charAt(g&63)),v&&E.length>v&&(T+=E.substr(0,v)+`\r
|
|
224
|
-
`,E=E.substr(v));return T+=E,T},t.binary.base64.decode=function(u,v,E){var T=v;T||(T=new Uint8Array(Math.ceil(u.length/4)*3)),u=u.replace(/[^A-Za-z0-9\+\/\=]/g,""),E=E||0;for(var _,w,g,f,k=0,L=E;k<u.length;)_=l[u.charCodeAt(k++)-43],w=l[u.charCodeAt(k++)-43],g=l[u.charCodeAt(k++)-43],f=l[u.charCodeAt(k++)-43],T[L++]=_<<2|w>>4,g!==64&&(T[L++]=(w&15)<<4|g>>2,f!==64&&(T[L++]=(g&3)<<6|f));return v?L-E:T.subarray(0,L)},t.binary.base58.encode=function(u,v){return t.binary.baseN.encode(u,c,v)},t.binary.base58.decode=function(u,v){return t.binary.baseN.decode(u,c,v)},t.text={utf8:{},utf16:{}},t.text.utf8.encode=function(u,v,E){u=t.encodeUtf8(u);var T=v;T||(T=new Uint8Array(u.length)),E=E||0;for(var _=E,w=0;w<u.length;++w)T[_++]=u.charCodeAt(w);return v?_-E:T},t.text.utf8.decode=function(u){return t.decodeUtf8(String.fromCharCode.apply(null,u))},t.text.utf16.encode=function(u,v,E){var T=v;T||(T=new Uint8Array(u.length*2));var _=new Uint16Array(T.buffer);E=E||0;for(var w=E,g=E,f=0;f<u.length;++f)_[g++]=u.charCodeAt(f),w+=2;return v?w-E:T},t.text.utf16.decode=function(u){return String.fromCharCode.apply(null,new Uint16Array(u.buffer))},t.deflate=function(u,v,E){if(v=t.decode64(u.deflate(t.encode64(v)).rval),E){var T=2,_=v.charCodeAt(1);_&32&&(T=6),v=v.substring(T,v.length-4)}return v},t.inflate=function(u,v,E){var T=u.inflate(t.encode64(v)).rval;return T===null?null:t.decode64(T)};var p=function(u,v,E){if(!u)throw new Error("WebStorage not available.");var T;if(E===null?T=u.removeItem(v):(E=t.encode64(JSON.stringify(E)),T=u.setItem(v,E)),typeof T<"u"&&T.rval!==!0){var _=new Error(T.error.message);throw _.id=T.error.id,_.name=T.error.name,_}},b=function(u,v){if(!u)throw new Error("WebStorage not available.");var E=u.getItem(v);if(u.init)if(E.rval===null){if(E.error){var T=new Error(E.error.message);throw T.id=E.error.id,T.name=E.error.name,T}E=null}else E=E.rval;return E!==null&&(E=JSON.parse(t.decode64(E))),E},x=function(u,v,E,T){var _=b(u,v);_===null&&(_={}),_[E]=T,p(u,v,_)},h=function(u,v,E){var T=b(u,v);return T!==null&&(T=E in T?T[E]:null),T},m=function(u,v,E){var T=b(u,v);if(T!==null&&E in T){delete T[E];var _=!0;for(var w in T){_=!1;break}_&&(T=null),p(u,v,T)}},d=function(u,v){p(u,v,null)},y=function(u,v,E){var T=null;typeof E>"u"&&(E=["web","flash"]);var _,w=!1,g=null;for(var f in E){_=E[f];try{if(_==="flash"||_==="both"){if(v[0]===null)throw new Error("Flash local storage not available.");T=u.apply(this,v),w=_==="flash"}(_==="web"||_==="both")&&(v[0]=localStorage,T=u.apply(this,v),w=!0)}catch(k){g=k}if(w)break}if(!w)throw g;return T};return t.setItem=function(u,v,E,T,_){y(x,arguments,_)},t.getItem=function(u,v,E,T){return y(h,arguments,T)},t.removeItem=function(u,v,E,T){y(m,arguments,T)},t.clearItems=function(u,v,E){y(d,arguments,E)},t.isEmpty=function(u){for(var v in u)if(u.hasOwnProperty(v))return!1;return!0},t.format=function(u){for(var v=/%./g,E,T,_=0,w=[],g=0;E=v.exec(u);){T=u.substring(g,v.lastIndex-2),T.length>0&&w.push(T),g=v.lastIndex;var f=E[0][1];switch(f){case"s":case"o":_<arguments.length?w.push(arguments[_+++1]):w.push("<?>");break;case"%":w.push("%");break;default:w.push("<%"+f+"?>")}}return w.push(u.substring(g)),w.join("")},t.formatNumber=function(u,v,E,T){var _=u,w=isNaN(v=Math.abs(v))?2:v,g=E===void 0?",":E,f=T===void 0?".":T,k=_<0?"-":"",L=parseInt(_=Math.abs(+_||0).toFixed(w),10)+"",H=L.length>3?L.length%3:0;return k+(H?L.substr(0,H)+f:"")+L.substr(H).replace(/(\d{3})(?=\d)/g,"$1"+f)+(w?g+Math.abs(_-L).toFixed(w).slice(2):"")},t.formatSize=function(u){return u>=1073741824?u=t.formatNumber(u/1073741824,2,".","")+" GiB":u>=1048576?u=t.formatNumber(u/1048576,2,".","")+" MiB":u>=1024?u=t.formatNumber(u/1024,0)+" KiB":u=t.formatNumber(u,0)+" bytes",u},t.bytesFromIP=function(u){return u.indexOf(".")!==-1?t.bytesFromIPv4(u):u.indexOf(":")!==-1?t.bytesFromIPv6(u):null},t.bytesFromIPv4=function(u){if(u=u.split("."),u.length!==4)return null;for(var v=t.createBuffer(),E=0;E<u.length;++E){var T=parseInt(u[E],10);if(isNaN(T))return null;v.putByte(T)}return v.getBytes()},t.bytesFromIPv6=function(u){var v=0;u=u.split(":").filter(function(g){return g.length===0&&++v,!0});for(var E=(8-u.length+v)*2,T=t.createBuffer(),_=0;_<8;++_){if(!u[_]||u[_].length===0){T.fillWithByte(0,E),E=0;continue}var w=t.hexToBytes(u[_]);w.length<2&&T.putByte(0),T.putBytes(w)}return T.getBytes()},t.bytesToIP=function(u){return u.length===4?t.bytesToIPv4(u):u.length===16?t.bytesToIPv6(u):null},t.bytesToIPv4=function(u){if(u.length!==4)return null;for(var v=[],E=0;E<u.length;++E)v.push(u.charCodeAt(E));return v.join(".")},t.bytesToIPv6=function(u){if(u.length!==16)return null;for(var v=[],E=[],T=0,_=0;_<u.length;_+=2){for(var w=t.bytesToHex(u[_]+u[_+1]);w[0]==="0"&&w!=="0";)w=w.substr(1);if(w==="0"){var g=E[E.length-1],f=v.length;!g||f!==g.end+1?E.push({start:f,end:f}):(g.end=f,g.end-g.start>E[T].end-E[T].start&&(T=E.length-1))}v.push(w)}if(E.length>0){var k=E[T];k.end-k.start>0&&(v.splice(k.start,k.end-k.start+1,""),k.start===0&&v.unshift(""),k.end===7&&v.push(""))}return v.join(":")},t.estimateCores=function(u,v){if(typeof u=="function"&&(v=u,u={}),u=u||{},"cores"in t&&!u.update)return v(null,t.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return t.cores=navigator.hardwareConcurrency,v(null,t.cores);if(typeof Worker>"u")return t.cores=1,v(null,t.cores);if(typeof Blob>"u")return t.cores=2,v(null,t.cores);var E=URL.createObjectURL(new Blob(["(",(function(){self.addEventListener("message",function(g){var f=Date.now(),k=f+4;self.postMessage({st:f,et:k})})}).toString(),")()"],{type:"application/javascript"}));T([],5,16);function T(g,f,k){if(f===0){var L=Math.floor(g.reduce(function(H,I){return H+I},0)/g.length);return t.cores=Math.max(1,L),URL.revokeObjectURL(E),v(null,t.cores)}_(k,function(H,I){g.push(w(k,I)),T(g,f-1,k)})}function _(g,f){for(var k=[],L=[],H=0;H<g;++H){var I=new Worker(E);I.addEventListener("message",function(V){if(L.push(V.data),L.length===g){for(var A=0;A<g;++A)k[A].terminate();f(null,L)}}),k.push(I)}for(var H=0;H<g;++H)k[H].postMessage(H)}function w(g,f){for(var k=[],L=0;L<g;++L)for(var H=f[L],I=k[L]=[],V=0;V<g;++V)if(L!==V){var A=f[V];(H.st>A.st&&H.st<A.et||A.st>H.st&&A.st<H.et)&&I.push(V)}return k.reduce(function(G,Y){return Math.max(G,Y.length)},0)}},Ir.exports}var Br,sn;function Mr(){if(sn)return Br;sn=1;var o=xe();Ee(),Br=o.cipher=o.cipher||{},o.cipher.algorithms=o.cipher.algorithms||{},o.cipher.createCipher=function(t,r){var n=t;if(typeof n=="string"&&(n=o.cipher.getAlgorithm(n),n&&(n=n())),!n)throw new Error("Unsupported algorithm: "+t);return new o.cipher.BlockCipher({algorithm:n,key:r,decrypt:!1})},o.cipher.createDecipher=function(t,r){var n=t;if(typeof n=="string"&&(n=o.cipher.getAlgorithm(n),n&&(n=n())),!n)throw new Error("Unsupported algorithm: "+t);return new o.cipher.BlockCipher({algorithm:n,key:r,decrypt:!0})},o.cipher.registerAlgorithm=function(t,r){t=t.toUpperCase(),o.cipher.algorithms[t]=r},o.cipher.getAlgorithm=function(t){return t=t.toUpperCase(),t in o.cipher.algorithms?o.cipher.algorithms[t]:null};var e=o.cipher.BlockCipher=function(t){this.algorithm=t.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=t.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=t.decrypt,this.algorithm.initialize(t)};return e.prototype.start=function(t){t=t||{};var r={};for(var n in t)r[n]=t[n];r.decrypt=this._decrypt,this._finish=!1,this._input=o.util.createBuffer(),this.output=t.output||o.util.createBuffer(),this.mode.start(r)},e.prototype.update=function(t){for(t&&this._input.putBuffer(t);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},e.prototype.finish=function(t){t&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(n){return t(this.blockSize,n,!1)},this.mode.unpad=function(n){return t(this.blockSize,n,!0)});var r={};return r.decrypt=this._decrypt,r.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,r)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,r))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,r))},Br}var Lr={exports:{}},an;function on(){if(an)return Lr.exports;an=1;var o=xe();Ee(),o.cipher=o.cipher||{};var e=Lr.exports=o.cipher.modes=o.cipher.modes||{};e.ecb=function(s){s=s||{},this.name="ECB",this.cipher=s.cipher,this.blockSize=s.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},e.ecb.prototype.start=function(s){},e.ecb.prototype.encrypt=function(s,a,i){if(s.length()<this.blockSize&&!(i&&s.length()>0))return!0;for(var l=0;l<this._ints;++l)this._inBlock[l]=s.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var l=0;l<this._ints;++l)a.putInt32(this._outBlock[l])},e.ecb.prototype.decrypt=function(s,a,i){if(s.length()<this.blockSize&&!(i&&s.length()>0))return!0;for(var l=0;l<this._ints;++l)this._inBlock[l]=s.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var l=0;l<this._ints;++l)a.putInt32(this._outBlock[l])},e.ecb.prototype.pad=function(s,a){var i=s.length()===this.blockSize?this.blockSize:this.blockSize-s.length();return s.fillWithByte(i,i),!0},e.ecb.prototype.unpad=function(s,a){if(a.overflow>0)return!1;var i=s.length(),l=s.at(i-1);return l>this.blockSize<<2?!1:(s.truncate(l),!0)},e.cbc=function(s){s=s||{},this.name="CBC",this.cipher=s.cipher,this.blockSize=s.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},e.cbc.prototype.start=function(s){if(s.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in s)this._iv=t(s.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")},e.cbc.prototype.encrypt=function(s,a,i){if(s.length()<this.blockSize&&!(i&&s.length()>0))return!0;for(var l=0;l<this._ints;++l)this._inBlock[l]=this._prev[l]^s.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var l=0;l<this._ints;++l)a.putInt32(this._outBlock[l]);this._prev=this._outBlock},e.cbc.prototype.decrypt=function(s,a,i){if(s.length()<this.blockSize&&!(i&&s.length()>0))return!0;for(var l=0;l<this._ints;++l)this._inBlock[l]=s.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var l=0;l<this._ints;++l)a.putInt32(this._prev[l]^this._outBlock[l]);this._prev=this._inBlock.slice(0)},e.cbc.prototype.pad=function(s,a){var i=s.length()===this.blockSize?this.blockSize:this.blockSize-s.length();return s.fillWithByte(i,i),!0},e.cbc.prototype.unpad=function(s,a){if(a.overflow>0)return!1;var i=s.length(),l=s.at(i-1);return l>this.blockSize<<2?!1:(s.truncate(l),!0)},e.cfb=function(s){s=s||{},this.name="CFB",this.cipher=s.cipher,this.blockSize=s.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=o.util.createBuffer(),this._partialBytes=0},e.cfb.prototype.start=function(s){if(!("iv"in s))throw new Error("Invalid IV parameter.");this._iv=t(s.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.cfb.prototype.encrypt=function(s,a,i){var l=s.length();if(l===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&l>=this.blockSize){for(var c=0;c<this._ints;++c)this._inBlock[c]=s.getInt32()^this._outBlock[c],a.putInt32(this._inBlock[c]);return}var p=(this.blockSize-l)%this.blockSize;p>0&&(p=this.blockSize-p),this._partialOutput.clear();for(var c=0;c<this._ints;++c)this._partialBlock[c]=s.getInt32()^this._outBlock[c],this._partialOutput.putInt32(this._partialBlock[c]);if(p>0)s.read-=this.blockSize;else for(var c=0;c<this._ints;++c)this._inBlock[c]=this._partialBlock[c];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),p>0&&!i)return a.putBytes(this._partialOutput.getBytes(p-this._partialBytes)),this._partialBytes=p,!0;a.putBytes(this._partialOutput.getBytes(l-this._partialBytes)),this._partialBytes=0},e.cfb.prototype.decrypt=function(s,a,i){var l=s.length();if(l===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&l>=this.blockSize){for(var c=0;c<this._ints;++c)this._inBlock[c]=s.getInt32(),a.putInt32(this._inBlock[c]^this._outBlock[c]);return}var p=(this.blockSize-l)%this.blockSize;p>0&&(p=this.blockSize-p),this._partialOutput.clear();for(var c=0;c<this._ints;++c)this._partialBlock[c]=s.getInt32(),this._partialOutput.putInt32(this._partialBlock[c]^this._outBlock[c]);if(p>0)s.read-=this.blockSize;else for(var c=0;c<this._ints;++c)this._inBlock[c]=this._partialBlock[c];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),p>0&&!i)return a.putBytes(this._partialOutput.getBytes(p-this._partialBytes)),this._partialBytes=p,!0;a.putBytes(this._partialOutput.getBytes(l-this._partialBytes)),this._partialBytes=0},e.ofb=function(s){s=s||{},this.name="OFB",this.cipher=s.cipher,this.blockSize=s.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=o.util.createBuffer(),this._partialBytes=0},e.ofb.prototype.start=function(s){if(!("iv"in s))throw new Error("Invalid IV parameter.");this._iv=t(s.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ofb.prototype.encrypt=function(s,a,i){var l=s.length();if(s.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&l>=this.blockSize){for(var c=0;c<this._ints;++c)a.putInt32(s.getInt32()^this._outBlock[c]),this._inBlock[c]=this._outBlock[c];return}var p=(this.blockSize-l)%this.blockSize;p>0&&(p=this.blockSize-p),this._partialOutput.clear();for(var c=0;c<this._ints;++c)this._partialOutput.putInt32(s.getInt32()^this._outBlock[c]);if(p>0)s.read-=this.blockSize;else for(var c=0;c<this._ints;++c)this._inBlock[c]=this._outBlock[c];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),p>0&&!i)return a.putBytes(this._partialOutput.getBytes(p-this._partialBytes)),this._partialBytes=p,!0;a.putBytes(this._partialOutput.getBytes(l-this._partialBytes)),this._partialBytes=0},e.ofb.prototype.decrypt=e.ofb.prototype.encrypt,e.ctr=function(s){s=s||{},this.name="CTR",this.cipher=s.cipher,this.blockSize=s.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=o.util.createBuffer(),this._partialBytes=0},e.ctr.prototype.start=function(s){if(!("iv"in s))throw new Error("Invalid IV parameter.");this._iv=t(s.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ctr.prototype.encrypt=function(s,a,i){var l=s.length();if(l===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&l>=this.blockSize)for(var c=0;c<this._ints;++c)a.putInt32(s.getInt32()^this._outBlock[c]);else{var p=(this.blockSize-l)%this.blockSize;p>0&&(p=this.blockSize-p),this._partialOutput.clear();for(var c=0;c<this._ints;++c)this._partialOutput.putInt32(s.getInt32()^this._outBlock[c]);if(p>0&&(s.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),p>0&&!i)return a.putBytes(this._partialOutput.getBytes(p-this._partialBytes)),this._partialBytes=p,!0;a.putBytes(this._partialOutput.getBytes(l-this._partialBytes)),this._partialBytes=0}r(this._inBlock)},e.ctr.prototype.decrypt=e.ctr.prototype.encrypt,e.gcm=function(s){s=s||{},this.name="GCM",this.cipher=s.cipher,this.blockSize=s.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=o.util.createBuffer(),this._partialBytes=0,this._R=3774873600},e.gcm.prototype.start=function(s){if(!("iv"in s))throw new Error("Invalid IV parameter.");var a=o.util.createBuffer(s.iv);this._cipherLength=0;var i;if("additionalData"in s?i=o.util.createBuffer(s.additionalData):i=o.util.createBuffer(),"tagLength"in s?this._tagLength=s.tagLength:this._tagLength=128,this._tag=null,s.decrypt&&(this._tag=o.util.createBuffer(s.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var l=a.length();if(l===12)this._j0=[a.getInt32(),a.getInt32(),a.getInt32(),1];else{for(this._j0=[0,0,0,0];a.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(n(l*8)))}this._inBlock=this._j0.slice(0),r(this._inBlock),this._partialBytes=0,i=o.util.createBuffer(i),this._aDataLength=n(i.length()*8);var c=i.length()%this.blockSize;for(c&&i.fillWithByte(0,this.blockSize-c),this._s=[0,0,0,0];i.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[i.getInt32(),i.getInt32(),i.getInt32(),i.getInt32()])},e.gcm.prototype.encrypt=function(s,a,i){var l=s.length();if(l===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&l>=this.blockSize){for(var c=0;c<this._ints;++c)a.putInt32(this._outBlock[c]^=s.getInt32());this._cipherLength+=this.blockSize}else{var p=(this.blockSize-l)%this.blockSize;p>0&&(p=this.blockSize-p),this._partialOutput.clear();for(var c=0;c<this._ints;++c)this._partialOutput.putInt32(s.getInt32()^this._outBlock[c]);if(p<=0||i){if(i){var b=l%this.blockSize;this._cipherLength+=b,this._partialOutput.truncate(this.blockSize-b)}else this._cipherLength+=this.blockSize;for(var c=0;c<this._ints;++c)this._outBlock[c]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),p>0&&!i)return s.read-=this.blockSize,a.putBytes(this._partialOutput.getBytes(p-this._partialBytes)),this._partialBytes=p,!0;a.putBytes(this._partialOutput.getBytes(l-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),r(this._inBlock)},e.gcm.prototype.decrypt=function(s,a,i){var l=s.length();if(l<this.blockSize&&!(i&&l>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),r(this._inBlock),this._hashBlock[0]=s.getInt32(),this._hashBlock[1]=s.getInt32(),this._hashBlock[2]=s.getInt32(),this._hashBlock[3]=s.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var c=0;c<this._ints;++c)a.putInt32(this._outBlock[c]^this._hashBlock[c]);l<this.blockSize?this._cipherLength+=l%this.blockSize:this._cipherLength+=this.blockSize},e.gcm.prototype.afterFinish=function(s,a){var i=!0;a.decrypt&&a.overflow&&s.truncate(this.blockSize-a.overflow),this.tag=o.util.createBuffer();var l=this._aDataLength.concat(n(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,l);var c=[];this.cipher.encrypt(this._j0,c);for(var p=0;p<this._ints;++p)this.tag.putInt32(this._s[p]^c[p]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),a.decrypt&&this.tag.bytes()!==this._tag&&(i=!1),i},e.gcm.prototype.multiply=function(s,a){for(var i=[0,0,0,0],l=a.slice(0),c=0;c<128;++c){var p=s[c/32|0]&1<<31-c%32;p&&(i[0]^=l[0],i[1]^=l[1],i[2]^=l[2],i[3]^=l[3]),this.pow(l,l)}return i},e.gcm.prototype.pow=function(s,a){for(var i=s[3]&1,l=3;l>0;--l)a[l]=s[l]>>>1|(s[l-1]&1)<<31;a[0]=s[0]>>>1,i&&(a[0]^=this._R)},e.gcm.prototype.tableMultiply=function(s){for(var a=[0,0,0,0],i=0;i<32;++i){var l=i/8|0,c=s[l]>>>(7-i%8)*4&15,p=this._m[i][c];a[0]^=p[0],a[1]^=p[1],a[2]^=p[2],a[3]^=p[3]}return a},e.gcm.prototype.ghash=function(s,a,i){return a[0]^=i[0],a[1]^=i[1],a[2]^=i[2],a[3]^=i[3],this.tableMultiply(a)},e.gcm.prototype.generateHashTable=function(s,a){for(var i=8/a,l=4*i,c=16*i,p=new Array(c),b=0;b<c;++b){var x=[0,0,0,0],h=b/l|0,m=(l-1-b%l)*a;x[h]=1<<a-1<<m,p[b]=this.generateSubHashTable(this.multiply(x,s),a)}return p},e.gcm.prototype.generateSubHashTable=function(s,a){var i=1<<a,l=i>>>1,c=new Array(i);c[l]=s.slice(0);for(var p=l>>>1;p>0;)this.pow(c[2*p],c[p]=[]),p>>=1;for(p=2;p<l;){for(var b=1;b<p;++b){var x=c[p],h=c[b];c[p+b]=[x[0]^h[0],x[1]^h[1],x[2]^h[2],x[3]^h[3]]}p*=2}for(c[0]=[0,0,0,0],p=l+1;p<i;++p){var m=c[p^l];c[p]=[s[0]^m[0],s[1]^m[1],s[2]^m[2],s[3]^m[3]]}return c};function t(s,a){if(typeof s=="string"&&(s=o.util.createBuffer(s)),o.util.isArray(s)&&s.length>4){var i=s;s=o.util.createBuffer();for(var l=0;l<i.length;++l)s.putByte(i[l])}if(s.length()<a)throw new Error("Invalid IV length; got "+s.length()+" bytes and expected "+a+" bytes.");if(!o.util.isArray(s)){for(var c=[],p=a/4,l=0;l<p;++l)c.push(s.getInt32());s=c}return s}function r(s){s[s.length-1]=s[s.length-1]+1&4294967295}function n(s){return[s/4294967296|0,s&4294967295]}return Lr.exports}var Rr,ln;function St(){if(ln)return Rr;ln=1;var o=xe();Mr(),on(),Ee(),Rr=o.aes=o.aes||{},o.aes.startEncrypting=function(h,m,d,y){var u=x({key:h,output:d,decrypt:!1,mode:y});return u.start(m),u},o.aes.createEncryptionCipher=function(h,m){return x({key:h,output:null,decrypt:!1,mode:m})},o.aes.startDecrypting=function(h,m,d,y){var u=x({key:h,output:d,decrypt:!0,mode:y});return u.start(m),u},o.aes.createDecryptionCipher=function(h,m){return x({key:h,output:null,decrypt:!0,mode:m})},o.aes.Algorithm=function(h,m){t||c();var d=this;d.name=h,d.mode=new m({blockSize:16,cipher:{encrypt:function(y,u){return b(d._w,y,u,!1)},decrypt:function(y,u){return b(d._w,y,u,!0)}}}),d._init=!1},o.aes.Algorithm.prototype.initialize=function(h){if(!this._init){var m=h.key,d;if(typeof m=="string"&&(m.length===16||m.length===24||m.length===32))m=o.util.createBuffer(m);else if(o.util.isArray(m)&&(m.length===16||m.length===24||m.length===32)){d=m,m=o.util.createBuffer();for(var y=0;y<d.length;++y)m.putByte(d[y])}if(!o.util.isArray(m)){d=m,m=[];var u=d.length();if(u===16||u===24||u===32){u=u>>>2;for(var y=0;y<u;++y)m.push(d.getInt32())}}if(!o.util.isArray(m)||!(m.length===4||m.length===6||m.length===8))throw new Error("Invalid key parameter.");var v=this.mode.name,E=["CFB","OFB","CTR","GCM"].indexOf(v)!==-1;this._w=p(m,h.decrypt&&!E),this._init=!0}},o.aes._expandKey=function(h,m){return t||c(),p(h,m)},o.aes._updateBlock=b,e("AES-ECB",o.cipher.modes.ecb),e("AES-CBC",o.cipher.modes.cbc),e("AES-CFB",o.cipher.modes.cfb),e("AES-OFB",o.cipher.modes.ofb),e("AES-CTR",o.cipher.modes.ctr),e("AES-GCM",o.cipher.modes.gcm);function e(h,m){var d=function(){return new o.aes.Algorithm(h,m)};o.cipher.registerAlgorithm(h,d)}var t=!1,r=4,n,s,a,i,l;function c(){t=!0,a=[0,1,2,4,8,16,32,64,128,27,54];for(var h=new Array(256),m=0;m<128;++m)h[m]=m<<1,h[m+128]=m+128<<1^283;n=new Array(256),s=new Array(256),i=new Array(4),l=new Array(4);for(var m=0;m<4;++m)i[m]=new Array(256),l[m]=new Array(256);for(var d=0,y=0,u,v,E,T,_,w,g,m=0;m<256;++m){T=y^y<<1^y<<2^y<<3^y<<4,T=T>>8^T&255^99,n[d]=T,s[T]=d,_=h[T],u=h[d],v=h[u],E=h[v],w=_<<24^T<<16^T<<8^(T^_),g=(u^v^E)<<24^(d^E)<<16^(d^v^E)<<8^(d^u^E);for(var f=0;f<4;++f)i[f][d]=w,l[f][T]=g,w=w<<24|w>>>8,g=g<<24|g>>>8;d===0?d=y=1:(d=u^h[h[h[u^E]]],y^=h[h[y]])}}function p(h,m){for(var d=h.slice(0),y,u=1,v=d.length,E=v+6+1,T=r*E,_=v;_<T;++_)y=d[_-1],_%v===0?(y=n[y>>>16&255]<<24^n[y>>>8&255]<<16^n[y&255]<<8^n[y>>>24]^a[u]<<24,u++):v>6&&_%v===4&&(y=n[y>>>24]<<24^n[y>>>16&255]<<16^n[y>>>8&255]<<8^n[y&255]),d[_]=d[_-v]^y;if(m){var w,g=l[0],f=l[1],k=l[2],L=l[3],H=d.slice(0);T=d.length;for(var _=0,I=T-r;_<T;_+=r,I-=r)if(_===0||_===T-r)H[_]=d[I],H[_+1]=d[I+3],H[_+2]=d[I+2],H[_+3]=d[I+1];else for(var V=0;V<r;++V)w=d[I+V],H[_+(3&-V)]=g[n[w>>>24]]^f[n[w>>>16&255]]^k[n[w>>>8&255]]^L[n[w&255]];d=H}return d}function b(h,m,d,y){var u=h.length/4-1,v,E,T,_,w;y?(v=l[0],E=l[1],T=l[2],_=l[3],w=s):(v=i[0],E=i[1],T=i[2],_=i[3],w=n);var g,f,k,L,H,I,V;g=m[0]^h[0],f=m[y?3:1]^h[1],k=m[2]^h[2],L=m[y?1:3]^h[3];for(var A=3,G=1;G<u;++G)H=v[g>>>24]^E[f>>>16&255]^T[k>>>8&255]^_[L&255]^h[++A],I=v[f>>>24]^E[k>>>16&255]^T[L>>>8&255]^_[g&255]^h[++A],V=v[k>>>24]^E[L>>>16&255]^T[g>>>8&255]^_[f&255]^h[++A],L=v[L>>>24]^E[g>>>16&255]^T[f>>>8&255]^_[k&255]^h[++A],g=H,f=I,k=V;d[0]=w[g>>>24]<<24^w[f>>>16&255]<<16^w[k>>>8&255]<<8^w[L&255]^h[++A],d[y?3:1]=w[f>>>24]<<24^w[k>>>16&255]<<16^w[L>>>8&255]<<8^w[g&255]^h[++A],d[2]=w[k>>>24]<<24^w[L>>>16&255]<<16^w[g>>>8&255]<<8^w[f&255]^h[++A],d[y?1:3]=w[L>>>24]<<24^w[g>>>16&255]<<16^w[f>>>8&255]<<8^w[k&255]^h[++A]}function x(h){h=h||{};var m=(h.mode||"CBC").toUpperCase(),d="AES-"+m,y;h.decrypt?y=o.cipher.createDecipher(d,h.key):y=o.cipher.createCipher(d,h.key);var u=y.start;return y.start=function(v,E){var T=null;E instanceof o.util.ByteBuffer&&(T=E,E={}),E=E||{},E.output=T,E.iv=v,u.call(y,E)},y}return Rr}var Nr={exports:{}},Pr={exports:{}},Dr={exports:{}},cn;function Tt(){if(cn)return Dr.exports;cn=1;var o=xe();o.pki=o.pki||{};var e=Dr.exports=o.pki.oids=o.oids=o.oids||{};function t(n,s){e[n]=s,e[s]=n}function r(n,s){e[n]=s}return t("1.2.840.113549.1.1.1","rsaEncryption"),t("1.2.840.113549.1.1.4","md5WithRSAEncryption"),t("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),t("1.2.840.113549.1.1.7","RSAES-OAEP"),t("1.2.840.113549.1.1.8","mgf1"),t("1.2.840.113549.1.1.9","pSpecified"),t("1.2.840.113549.1.1.10","RSASSA-PSS"),t("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),t("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),t("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),t("1.3.101.112","EdDSA25519"),t("1.2.840.10040.4.3","dsa-with-sha1"),t("1.3.14.3.2.7","desCBC"),t("1.3.14.3.2.26","sha1"),t("1.3.14.3.2.29","sha1WithRSASignature"),t("2.16.840.1.101.3.4.2.1","sha256"),t("2.16.840.1.101.3.4.2.2","sha384"),t("2.16.840.1.101.3.4.2.3","sha512"),t("2.16.840.1.101.3.4.2.4","sha224"),t("2.16.840.1.101.3.4.2.5","sha512-224"),t("2.16.840.1.101.3.4.2.6","sha512-256"),t("1.2.840.113549.2.2","md2"),t("1.2.840.113549.2.5","md5"),t("1.2.840.113549.1.7.1","data"),t("1.2.840.113549.1.7.2","signedData"),t("1.2.840.113549.1.7.3","envelopedData"),t("1.2.840.113549.1.7.4","signedAndEnvelopedData"),t("1.2.840.113549.1.7.5","digestedData"),t("1.2.840.113549.1.7.6","encryptedData"),t("1.2.840.113549.1.9.1","emailAddress"),t("1.2.840.113549.1.9.2","unstructuredName"),t("1.2.840.113549.1.9.3","contentType"),t("1.2.840.113549.1.9.4","messageDigest"),t("1.2.840.113549.1.9.5","signingTime"),t("1.2.840.113549.1.9.6","counterSignature"),t("1.2.840.113549.1.9.7","challengePassword"),t("1.2.840.113549.1.9.8","unstructuredAddress"),t("1.2.840.113549.1.9.14","extensionRequest"),t("1.2.840.113549.1.9.20","friendlyName"),t("1.2.840.113549.1.9.21","localKeyId"),t("1.2.840.113549.1.9.22.1","x509Certificate"),t("1.2.840.113549.1.12.10.1.1","keyBag"),t("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),t("1.2.840.113549.1.12.10.1.3","certBag"),t("1.2.840.113549.1.12.10.1.4","crlBag"),t("1.2.840.113549.1.12.10.1.5","secretBag"),t("1.2.840.113549.1.12.10.1.6","safeContentsBag"),t("1.2.840.113549.1.5.13","pkcs5PBES2"),t("1.2.840.113549.1.5.12","pkcs5PBKDF2"),t("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),t("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),t("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),t("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),t("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),t("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),t("1.2.840.113549.2.7","hmacWithSHA1"),t("1.2.840.113549.2.8","hmacWithSHA224"),t("1.2.840.113549.2.9","hmacWithSHA256"),t("1.2.840.113549.2.10","hmacWithSHA384"),t("1.2.840.113549.2.11","hmacWithSHA512"),t("1.2.840.113549.3.7","des-EDE3-CBC"),t("2.16.840.1.101.3.4.1.2","aes128-CBC"),t("2.16.840.1.101.3.4.1.22","aes192-CBC"),t("2.16.840.1.101.3.4.1.42","aes256-CBC"),t("2.5.4.3","commonName"),t("2.5.4.4","surname"),t("2.5.4.5","serialNumber"),t("2.5.4.6","countryName"),t("2.5.4.7","localityName"),t("2.5.4.8","stateOrProvinceName"),t("2.5.4.9","streetAddress"),t("2.5.4.10","organizationName"),t("2.5.4.11","organizationalUnitName"),t("2.5.4.12","title"),t("2.5.4.13","description"),t("2.5.4.15","businessCategory"),t("2.5.4.17","postalCode"),t("2.5.4.42","givenName"),t("2.5.4.65","pseudonym"),t("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),t("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),t("2.16.840.1.113730.1.1","nsCertType"),t("2.16.840.1.113730.1.13","nsComment"),r("2.5.29.1","authorityKeyIdentifier"),r("2.5.29.2","keyAttributes"),r("2.5.29.3","certificatePolicies"),r("2.5.29.4","keyUsageRestriction"),r("2.5.29.5","policyMapping"),r("2.5.29.6","subtreesConstraint"),r("2.5.29.7","subjectAltName"),r("2.5.29.8","issuerAltName"),r("2.5.29.9","subjectDirectoryAttributes"),r("2.5.29.10","basicConstraints"),r("2.5.29.11","nameConstraints"),r("2.5.29.12","policyConstraints"),r("2.5.29.13","basicConstraints"),t("2.5.29.14","subjectKeyIdentifier"),t("2.5.29.15","keyUsage"),r("2.5.29.16","privateKeyUsagePeriod"),t("2.5.29.17","subjectAltName"),t("2.5.29.18","issuerAltName"),t("2.5.29.19","basicConstraints"),r("2.5.29.20","cRLNumber"),r("2.5.29.21","cRLReason"),r("2.5.29.22","expirationDate"),r("2.5.29.23","instructionCode"),r("2.5.29.24","invalidityDate"),r("2.5.29.25","cRLDistributionPoints"),r("2.5.29.26","issuingDistributionPoint"),r("2.5.29.27","deltaCRLIndicator"),r("2.5.29.28","issuingDistributionPoint"),r("2.5.29.29","certificateIssuer"),r("2.5.29.30","nameConstraints"),t("2.5.29.31","cRLDistributionPoints"),t("2.5.29.32","certificatePolicies"),r("2.5.29.33","policyMappings"),r("2.5.29.34","policyConstraints"),t("2.5.29.35","authorityKeyIdentifier"),r("2.5.29.36","policyConstraints"),t("2.5.29.37","extKeyUsage"),r("2.5.29.46","freshestCRL"),r("2.5.29.54","inhibitAnyPolicy"),t("1.3.6.1.4.1.11129.2.4.2","timestampList"),t("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),t("1.3.6.1.5.5.7.3.1","serverAuth"),t("1.3.6.1.5.5.7.3.2","clientAuth"),t("1.3.6.1.5.5.7.3.3","codeSigning"),t("1.3.6.1.5.5.7.3.4","emailProtection"),t("1.3.6.1.5.5.7.3.8","timeStamping"),Dr.exports}var un;function gt(){if(un)return Pr.exports;un=1;var o=xe();Ee(),Tt();var e=Pr.exports=o.asn1=o.asn1||{};e.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},e.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},e.maxDepth=256,e.create=function(a,i,l,c,p){if(o.util.isArray(c)){for(var b=[],x=0;x<c.length;++x)c[x]!==void 0&&b.push(c[x]);c=b}var h={tagClass:a,type:i,constructed:l,composed:l||o.util.isArray(c),value:c};return p&&"bitStringContents"in p&&(h.bitStringContents=p.bitStringContents,h.original=e.copy(h)),h},e.copy=function(a,i){var l;if(o.util.isArray(a)){l=[];for(var c=0;c<a.length;++c)l.push(e.copy(a[c],i));return l}return typeof a=="string"?a:(l={tagClass:a.tagClass,type:a.type,constructed:a.constructed,composed:a.composed,value:e.copy(a.value,i)},i&&!i.excludeBitStringContents&&(l.bitStringContents=a.bitStringContents),l)},e.equals=function(a,i,l){if(o.util.isArray(a)){if(!o.util.isArray(i)||a.length!==i.length)return!1;for(var c=0;c<a.length;++c)if(!e.equals(a[c],i[c]))return!1;return!0}if(typeof a!=typeof i)return!1;if(typeof a=="string")return a===i;var p=a.tagClass===i.tagClass&&a.type===i.type&&a.constructed===i.constructed&&a.composed===i.composed&&e.equals(a.value,i.value);return l&&l.includeBitStringContents&&(p=p&&a.bitStringContents===i.bitStringContents),p},e.getBerValueLength=function(a){var i=a.getByte();if(i!==128){var l,c=i&128;return c?l=a.getInt((i&127)<<3):l=i,l}};function t(a,i,l){if(l>i){var c=new Error("Too few bytes to parse DER.");throw c.available=a.length(),c.remaining=i,c.requested=l,c}}var r=function(a,i){var l=a.getByte();if(i--,l!==128){var c,p=l&128;if(!p)c=l;else{var b=l&127;t(a,i,b),c=a.getInt(b<<3)}if(c<0)throw new Error("Negative length: "+c);return c}};e.fromDer=function(a,i){i===void 0&&(i={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof i=="boolean"&&(i={strict:i,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in i||(i.strict=!0),"parseAllBytes"in i||(i.parseAllBytes=!0),"decodeBitStrings"in i||(i.decodeBitStrings=!0),"maxDepth"in i||(i.maxDepth=e.maxDepth),typeof a=="string"&&(a=o.util.createBuffer(a));var l=a.length(),c=n(a,a.length(),0,i);if(i.parseAllBytes&&a.length()!==0){var p=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw p.byteCount=l,p.remaining=a.length(),p}return c};function n(a,i,l,c){if(l>=c.maxDepth)throw new Error("ASN.1 parsing error: Max depth exceeded.");var p;t(a,i,2);var b=a.getByte();i--;var x=b&192,h=b&31;p=a.length();var m=r(a,i);if(i-=p-a.length(),m!==void 0&&m>i){if(c.strict){var d=new Error("Too few bytes to read ASN.1 value.");throw d.available=a.length(),d.remaining=i,d.requested=m,d}m=i}var y,u,v=(b&32)===32;if(v)if(y=[],m===void 0)for(;;){if(t(a,i,2),a.bytes(2)==="\0\0"){a.getBytes(2),i-=2;break}p=a.length(),y.push(n(a,i,l+1,c)),i-=p-a.length()}else for(;m>0;)p=a.length(),y.push(n(a,m,l+1,c)),i-=p-a.length(),m-=p-a.length();if(y===void 0&&x===e.Class.UNIVERSAL&&h===e.Type.BITSTRING&&(u=a.bytes(m)),y===void 0&&c.decodeBitStrings&&x===e.Class.UNIVERSAL&&h===e.Type.BITSTRING&&m>1){var E=a.read,T=i,_=0;if(h===e.Type.BITSTRING&&(t(a,i,1),_=a.getByte(),i--),_===0)try{p=a.length();var w={strict:!0,decodeBitStrings:!0},g=n(a,i,l+1,w),f=p-a.length();i-=f,h==e.Type.BITSTRING&&f++;var k=g.tagClass;f===m&&(k===e.Class.UNIVERSAL||k===e.Class.CONTEXT_SPECIFIC)&&(y=[g])}catch{}y===void 0&&(a.read=E,i=T)}if(y===void 0){if(m===void 0){if(c.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");m=i}if(h===e.Type.BMPSTRING)for(y="";m>0;m-=2)t(a,i,2),y+=String.fromCharCode(a.getInt16()),i-=2;else y=a.getBytes(m),i-=m}var L=u===void 0?null:{bitStringContents:u};return e.create(x,h,v,y,L)}e.toDer=function(a){var i=o.util.createBuffer(),l=a.tagClass|a.type,c=o.util.createBuffer(),p=!1;if("bitStringContents"in a&&(p=!0,a.original&&(p=e.equals(a,a.original))),p)c.putBytes(a.bitStringContents);else if(a.composed){a.constructed?l|=32:c.putByte(0);for(var b=0;b<a.value.length;++b)a.value[b]!==void 0&&c.putBuffer(e.toDer(a.value[b]))}else if(a.type===e.Type.BMPSTRING)for(var b=0;b<a.value.length;++b)c.putInt16(a.value.charCodeAt(b));else a.type===e.Type.INTEGER&&a.value.length>1&&(a.value.charCodeAt(0)===0&&(a.value.charCodeAt(1)&128)===0||a.value.charCodeAt(0)===255&&(a.value.charCodeAt(1)&128)===128)?c.putBytes(a.value.substr(1)):c.putBytes(a.value);if(i.putByte(l),c.length()<=127)i.putByte(c.length()&127);else{var x=c.length(),h="";do h+=String.fromCharCode(x&255),x=x>>>8;while(x>0);i.putByte(h.length|128);for(var b=h.length-1;b>=0;--b)i.putByte(h.charCodeAt(b))}return i.putBuffer(c),i},e.oidToDer=function(a){var i=a.split("."),l=o.util.createBuffer();l.putByte(40*parseInt(i[0],10)+parseInt(i[1],10));for(var c,p,b,x,h=2;h<i.length;++h){if(c=!0,p=[],b=parseInt(i[h],10),b>4294967295)throw new Error("OID value too large; max is 32-bits.");do x=b&127,b=b>>>7,c||(x|=128),p.push(x),c=!1;while(b>0);for(var m=p.length-1;m>=0;--m)l.putByte(p[m])}return l},e.derToOid=function(a){var i;typeof a=="string"&&(a=o.util.createBuffer(a));var l=a.getByte();i=Math.floor(l/40)+"."+l%40;for(var c=0;a.length()>0;){if(c>70368744177663)throw new Error("OID value too large; max is 53-bits.");l=a.getByte(),c=c*128,l&128?c+=l&127:(i+="."+(c+l),c=0)}return i},e.utcTimeToDate=function(a){var i=new Date,l=parseInt(a.substr(0,2),10);l=l>=50?1900+l:2e3+l;var c=parseInt(a.substr(2,2),10)-1,p=parseInt(a.substr(4,2),10),b=parseInt(a.substr(6,2),10),x=parseInt(a.substr(8,2),10),h=0;if(a.length>11){var m=a.charAt(10),d=10;m!=="+"&&m!=="-"&&(h=parseInt(a.substr(10,2),10),d+=2)}if(i.setUTCFullYear(l,c,p),i.setUTCHours(b,x,h,0),d&&(m=a.charAt(d),m==="+"||m==="-")){var y=parseInt(a.substr(d+1,2),10),u=parseInt(a.substr(d+4,2),10),v=y*60+u;v*=6e4,m==="+"?i.setTime(+i-v):i.setTime(+i+v)}return i},e.generalizedTimeToDate=function(a){var i=new Date,l=parseInt(a.substr(0,4),10),c=parseInt(a.substr(4,2),10)-1,p=parseInt(a.substr(6,2),10),b=parseInt(a.substr(8,2),10),x=parseInt(a.substr(10,2),10),h=parseInt(a.substr(12,2),10),m=0,d=0,y=!1;a.charAt(a.length-1)==="Z"&&(y=!0);var u=a.length-5,v=a.charAt(u);if(v==="+"||v==="-"){var E=parseInt(a.substr(u+1,2),10),T=parseInt(a.substr(u+4,2),10);d=E*60+T,d*=6e4,v==="+"&&(d*=-1),y=!0}return a.charAt(14)==="."&&(m=parseFloat(a.substr(14),10)*1e3),y?(i.setUTCFullYear(l,c,p),i.setUTCHours(b,x,h,m),i.setTime(+i+d)):(i.setFullYear(l,c,p),i.setHours(b,x,h,m)),i},e.dateToUtcTime=function(a){if(typeof a=="string")return a;var i="",l=[];l.push((""+a.getUTCFullYear()).substr(2)),l.push(""+(a.getUTCMonth()+1)),l.push(""+a.getUTCDate()),l.push(""+a.getUTCHours()),l.push(""+a.getUTCMinutes()),l.push(""+a.getUTCSeconds());for(var c=0;c<l.length;++c)l[c].length<2&&(i+="0"),i+=l[c];return i+="Z",i},e.dateToGeneralizedTime=function(a){if(typeof a=="string")return a;var i="",l=[];l.push(""+a.getUTCFullYear()),l.push(""+(a.getUTCMonth()+1)),l.push(""+a.getUTCDate()),l.push(""+a.getUTCHours()),l.push(""+a.getUTCMinutes()),l.push(""+a.getUTCSeconds());for(var c=0;c<l.length;++c)l[c].length<2&&(i+="0"),i+=l[c];return i+="Z",i},e.integerToDer=function(a){var i=o.util.createBuffer();if(a>=-128&&a<128)return i.putSignedInt(a,8);if(a>=-32768&&a<32768)return i.putSignedInt(a,16);if(a>=-8388608&&a<8388608)return i.putSignedInt(a,24);if(a>=-2147483648&&a<2147483648)return i.putSignedInt(a,32);var l=new Error("Integer too large; max is 32-bits.");throw l.integer=a,l},e.derToInteger=function(a){typeof a=="string"&&(a=o.util.createBuffer(a));var i=a.length()*8;if(i>32)throw new Error("Integer too large; max is 32-bits.");return a.getSignedInt(i)},e.validate=function(a,i,l,c){var p=!1;if((a.tagClass===i.tagClass||typeof i.tagClass>"u")&&(a.type===i.type||typeof i.type>"u"))if(a.constructed===i.constructed||typeof i.constructed>"u"){if(p=!0,i.value&&o.util.isArray(i.value))for(var b=0,x=0;p&&x<i.value.length;++x){var h=i.value[x];p=!!h.optional;var m=a.value[b];if(!m){h.optional||(p=!1,c&&c.push("["+i.name+'] Missing required element. Expected tag class "'+h.tagClass+'", type "'+h.type+'"'));continue}var d=typeof h.tagClass<"u"&&typeof h.type<"u";if(d&&(m.tagClass!==h.tagClass||m.type!==h.type))if(h.optional){p=!0;continue}else{p=!1,c&&c.push("["+i.name+"] Tag mismatch. Expected ("+h.tagClass+","+h.type+"), got ("+m.tagClass+","+m.type+")");break}var y=e.validate(m,h,l,c);if(y)++b,p=!0;else if(h.optional)p=!0;else{p=!1;break}}if(p&&l&&(i.capture&&(l[i.capture]=a.value),i.captureAsn1&&(l[i.captureAsn1]=a),i.captureBitStringContents&&"bitStringContents"in a&&(l[i.captureBitStringContents]=a.bitStringContents),i.captureBitStringValue&&"bitStringContents"in a))if(a.bitStringContents.length<2)l[i.captureBitStringValue]="";else{var u=a.bitStringContents.charCodeAt(0);if(u!==0)throw new Error("captureBitStringValue only supported for zero unused bits");l[i.captureBitStringValue]=a.bitStringContents.slice(1)}}else c&&c.push("["+i.name+'] Expected constructed "'+i.constructed+'", got "'+a.constructed+'"');else c&&(a.tagClass!==i.tagClass&&c.push("["+i.name+'] Expected tag class "'+i.tagClass+'", got "'+a.tagClass+'"'),a.type!==i.type&&c.push("["+i.name+'] Expected type "'+i.type+'", got "'+a.type+'"'));return p};var s=/[^\\u0000-\\u00ff]/;return e.prettyPrint=function(a,i,l){var c="";i=i||0,l=l||2,i>0&&(c+=`
|
|
225
|
-
`);for(var p="",b=0;b<i*l;++b)p+=" ";switch(c+=p+"Tag: ",a.tagClass){case e.Class.UNIVERSAL:c+="Universal:";break;case e.Class.APPLICATION:c+="Application:";break;case e.Class.CONTEXT_SPECIFIC:c+="Context-Specific:";break;case e.Class.PRIVATE:c+="Private:";break}if(a.tagClass===e.Class.UNIVERSAL)switch(c+=a.type,a.type){case e.Type.NONE:c+=" (None)";break;case e.Type.BOOLEAN:c+=" (Boolean)";break;case e.Type.INTEGER:c+=" (Integer)";break;case e.Type.BITSTRING:c+=" (Bit string)";break;case e.Type.OCTETSTRING:c+=" (Octet string)";break;case e.Type.NULL:c+=" (Null)";break;case e.Type.OID:c+=" (Object Identifier)";break;case e.Type.ODESC:c+=" (Object Descriptor)";break;case e.Type.EXTERNAL:c+=" (External or Instance of)";break;case e.Type.REAL:c+=" (Real)";break;case e.Type.ENUMERATED:c+=" (Enumerated)";break;case e.Type.EMBEDDED:c+=" (Embedded PDV)";break;case e.Type.UTF8:c+=" (UTF8)";break;case e.Type.ROID:c+=" (Relative Object Identifier)";break;case e.Type.SEQUENCE:c+=" (Sequence)";break;case e.Type.SET:c+=" (Set)";break;case e.Type.PRINTABLESTRING:c+=" (Printable String)";break;case e.Type.IA5String:c+=" (IA5String (ASCII))";break;case e.Type.UTCTIME:c+=" (UTC time)";break;case e.Type.GENERALIZEDTIME:c+=" (Generalized time)";break;case e.Type.BMPSTRING:c+=" (BMP String)";break}else c+=a.type;if(c+=`
|
|
226
|
-
`,c+=p+"Constructed: "+a.constructed+`
|
|
227
|
-
`,a.composed){for(var x=0,h="",b=0;b<a.value.length;++b)a.value[b]!==void 0&&(x+=1,h+=e.prettyPrint(a.value[b],i+1,l),b+1<a.value.length&&(h+=","));c+=p+"Sub values: "+x+h}else{if(c+=p+"Value: ",a.type===e.Type.OID){var m=e.derToOid(a.value);c+=m,o.pki&&o.pki.oids&&m in o.pki.oids&&(c+=" ("+o.pki.oids[m]+") ")}if(a.type===e.Type.INTEGER)try{c+=e.derToInteger(a.value)}catch{c+="0x"+o.util.bytesToHex(a.value)}else if(a.type===e.Type.BITSTRING){if(a.value.length>1?c+="0x"+o.util.bytesToHex(a.value.slice(1)):c+="(none)",a.value.length>0){var d=a.value.charCodeAt(0);d==1?c+=" (1 unused bit shown)":d>1&&(c+=" ("+d+" unused bits shown)")}}else if(a.type===e.Type.OCTETSTRING)s.test(a.value)||(c+="("+a.value+") "),c+="0x"+o.util.bytesToHex(a.value);else if(a.type===e.Type.UTF8)try{c+=o.util.decodeUtf8(a.value)}catch(y){if(y.message==="URI malformed")c+="0x"+o.util.bytesToHex(a.value)+" (malformed UTF8)";else throw y}else a.type===e.Type.PRINTABLESTRING||a.type===e.Type.IA5String?c+=a.value:s.test(a.value)?c+="0x"+o.util.bytesToHex(a.value):a.value.length===0?c+="[null]":c+=a.value}return c},Pr.exports}var Ur={exports:{}},Vr,hn;function yt(){if(hn)return Vr;hn=1;var o=xe();return Vr=o.md=o.md||{},o.md.algorithms=o.md.algorithms||{},Vr}var dn;function Vt(){if(dn)return Ur.exports;dn=1;var o=xe();yt(),Ee();var e=Ur.exports=o.hmac=o.hmac||{};return e.create=function(){var t=null,r=null,n=null,s=null,a={};return a.start=function(i,l){if(i!==null)if(typeof i=="string")if(i=i.toLowerCase(),i in o.md.algorithms)r=o.md.algorithms[i].create();else throw new Error('Unknown hash algorithm "'+i+'"');else r=i;if(l===null)l=t;else{if(typeof l=="string")l=o.util.createBuffer(l);else if(o.util.isArray(l)){var c=l;l=o.util.createBuffer();for(var p=0;p<c.length;++p)l.putByte(c[p])}var b=l.length();b>r.blockLength&&(r.start(),r.update(l.bytes()),l=r.digest()),n=o.util.createBuffer(),s=o.util.createBuffer(),b=l.length();for(var p=0;p<b;++p){var c=l.at(p);n.putByte(54^c),s.putByte(92^c)}if(b<r.blockLength)for(var c=r.blockLength-b,p=0;p<c;++p)n.putByte(54),s.putByte(92);t=l,n=n.bytes(),s=s.bytes()}r.start(),r.update(n)},a.update=function(i){r.update(i)},a.getMac=function(){var i=r.digest().bytes();return r.start(),r.update(s),r.update(i),r.digest()},a.digest=a.getMac,a},Ur.exports}var Or={exports:{}},fn;function Fr(){if(fn)return Or.exports;fn=1;var o=xe();yt(),Ee();var e=Or.exports=o.md5=o.md5||{};o.md.md5=o.md.algorithms.md5=e,e.create=function(){a||i();var c=null,p=o.util.createBuffer(),b=new Array(16),x={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return x.start=function(){x.messageLength=0,x.fullMessageLength=x.messageLength64=[];for(var h=x.messageLengthSize/4,m=0;m<h;++m)x.fullMessageLength.push(0);return p=o.util.createBuffer(),c={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},x},x.start(),x.update=function(h,m){m==="utf8"&&(h=o.util.encodeUtf8(h));var d=h.length;x.messageLength+=d,d=[d/4294967296>>>0,d>>>0];for(var y=x.fullMessageLength.length-1;y>=0;--y)x.fullMessageLength[y]+=d[1],d[1]=d[0]+(x.fullMessageLength[y]/4294967296>>>0),x.fullMessageLength[y]=x.fullMessageLength[y]>>>0,d[0]=d[1]/4294967296>>>0;return p.putBytes(h),l(c,b,p),(p.read>2048||p.length()===0)&&p.compact(),x},x.digest=function(){var h=o.util.createBuffer();h.putBytes(p.bytes());var m=x.fullMessageLength[x.fullMessageLength.length-1]+x.messageLengthSize,d=m&x.blockLength-1;h.putBytes(t.substr(0,x.blockLength-d));for(var y,u=0,v=x.fullMessageLength.length-1;v>=0;--v)y=x.fullMessageLength[v]*8+u,u=y/4294967296>>>0,h.putInt32Le(y>>>0);var E={h0:c.h0,h1:c.h1,h2:c.h2,h3:c.h3};l(E,b,h);var T=o.util.createBuffer();return T.putInt32Le(E.h0),T.putInt32Le(E.h1),T.putInt32Le(E.h2),T.putInt32Le(E.h3),T},x};var t=null,r=null,n=null,s=null,a=!1;function i(){t="",t+=o.util.fillString("\0",64),r=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],n=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],s=new Array(64);for(var c=0;c<64;++c)s[c]=Math.floor(Math.abs(Math.sin(c+1))*4294967296);a=!0}function l(c,p,b){for(var x,h,m,d,y,u,v,E,T=b.length();T>=64;){for(h=c.h0,m=c.h1,d=c.h2,y=c.h3,E=0;E<16;++E)p[E]=b.getInt32Le(),u=y^m&(d^y),x=h+u+s[E]+p[E],v=n[E],h=y,y=d,d=m,m+=x<<v|x>>>32-v;for(;E<32;++E)u=d^y&(m^d),x=h+u+s[E]+p[r[E]],v=n[E],h=y,y=d,d=m,m+=x<<v|x>>>32-v;for(;E<48;++E)u=m^d^y,x=h+u+s[E]+p[r[E]],v=n[E],h=y,y=d,d=m,m+=x<<v|x>>>32-v;for(;E<64;++E)u=d^(m|~y),x=h+u+s[E]+p[r[E]],v=n[E],h=y,y=d,d=m,m+=x<<v|x>>>32-v;c.h0=c.h0+h|0,c.h1=c.h1+m|0,c.h2=c.h2+d|0,c.h3=c.h3+y|0,T-=64}}return Or.exports}var zr={exports:{}},pn;function _t(){if(pn)return zr.exports;pn=1;var o=xe();Ee();var e=zr.exports=o.pem=o.pem||{};e.encode=function(n,s){s=s||{};var a="-----BEGIN "+n.type+`-----\r
|
|
228
|
-
`,i;if(n.procType&&(i={name:"Proc-Type",values:[String(n.procType.version),n.procType.type]},a+=t(i)),n.contentDomain&&(i={name:"Content-Domain",values:[n.contentDomain]},a+=t(i)),n.dekInfo&&(i={name:"DEK-Info",values:[n.dekInfo.algorithm]},n.dekInfo.parameters&&i.values.push(n.dekInfo.parameters),a+=t(i)),n.headers)for(var l=0;l<n.headers.length;++l)a+=t(n.headers[l]);return n.procType&&(a+=`\r
|
|
229
|
-
`),a+=o.util.encode64(n.body,s.maxline||64)+`\r
|
|
230
|
-
`,a+="-----END "+n.type+`-----\r
|
|
231
|
-
`,a},e.decode=function(n){for(var s=[],a=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,i=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,l=/\r?\n/,c;c=a.exec(n),!!c;){var p=c[1];p==="NEW CERTIFICATE REQUEST"&&(p="CERTIFICATE REQUEST");var b={type:p,procType:null,contentDomain:null,dekInfo:null,headers:[],body:o.util.decode64(c[3])};if(s.push(b),!!c[2]){for(var x=c[2].split(l),h=0;c&&h<x.length;){for(var m=x[h].replace(/\s+$/,""),d=h+1;d<x.length;++d){var y=x[d];if(!/\s/.test(y[0]))break;m+=y,h=d}if(c=m.match(i),c){for(var u={name:c[1],values:[]},v=c[2].split(","),E=0;E<v.length;++E)u.values.push(r(v[E]));if(b.procType)if(!b.contentDomain&&u.name==="Content-Domain")b.contentDomain=v[0]||"";else if(!b.dekInfo&&u.name==="DEK-Info"){if(u.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');b.dekInfo={algorithm:v[0],parameters:v[1]||null}}else b.headers.push(u);else{if(u.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(u.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');b.procType={version:v[0],type:v[1]}}}++h}if(b.procType==="ENCRYPTED"&&!b.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(s.length===0)throw new Error("Invalid PEM formatted message.");return s};function t(n){for(var s=n.name+": ",a=[],i=function(x,h){return" "+h},l=0;l<n.values.length;++l)a.push(n.values[l].replace(/^(\S+\r\n)/,i));s+=a.join(",")+`\r
|
|
232
|
-
`;for(var c=0,p=-1,l=0;l<s.length;++l,++c)if(c>65&&p!==-1){var b=s[p];b===","?(++p,s=s.substr(0,p)+`\r
|
|
233
|
-
`+s.substr(p)):s=s.substr(0,p)+`\r
|
|
234
|
-
`+b+s.substr(p+1),c=l-p-1,p=-1,++l}else(s[l]===" "||s[l]===" "||s[l]===",")&&(p=l);return s}function r(n){return n.replace(/^\s+/,"")}return zr.exports}var Kr={exports:{}},Hr,gn;function tr(){if(gn)return Hr;gn=1;var o=xe();Mr(),on(),Ee(),Hr=o.des=o.des||{},o.des.startEncrypting=function(h,m,d,y){var u=x({key:h,output:d,decrypt:!1,mode:y||(m===null?"ECB":"CBC")});return u.start(m),u},o.des.createEncryptionCipher=function(h,m){return x({key:h,output:null,decrypt:!1,mode:m})},o.des.startDecrypting=function(h,m,d,y){var u=x({key:h,output:d,decrypt:!0,mode:y||(m===null?"ECB":"CBC")});return u.start(m),u},o.des.createDecryptionCipher=function(h,m){return x({key:h,output:null,decrypt:!0,mode:m})},o.des.Algorithm=function(h,m){var d=this;d.name=h,d.mode=new m({blockSize:8,cipher:{encrypt:function(y,u){return b(d._keys,y,u,!1)},decrypt:function(y,u){return b(d._keys,y,u,!0)}}}),d._init=!1},o.des.Algorithm.prototype.initialize=function(h){if(!this._init){var m=o.util.createBuffer(h.key);if(this.name.indexOf("3DES")===0&&m.length()!==24)throw new Error("Invalid Triple-DES key size: "+m.length()*8);this._keys=p(m),this._init=!0}},e("DES-ECB",o.cipher.modes.ecb),e("DES-CBC",o.cipher.modes.cbc),e("DES-CFB",o.cipher.modes.cfb),e("DES-OFB",o.cipher.modes.ofb),e("DES-CTR",o.cipher.modes.ctr),e("3DES-ECB",o.cipher.modes.ecb),e("3DES-CBC",o.cipher.modes.cbc),e("3DES-CFB",o.cipher.modes.cfb),e("3DES-OFB",o.cipher.modes.ofb),e("3DES-CTR",o.cipher.modes.ctr);function e(h,m){var d=function(){return new o.des.Algorithm(h,m)};o.cipher.registerAlgorithm(h,d)}var t=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],r=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],n=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],s=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],a=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],i=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],l=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],c=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function p(h){for(var m=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],d=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],y=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],u=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],v=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],E=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],T=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],_=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],w=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],g=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],k=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],L=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],H=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],I=h.length()>8?3:1,V=[],A=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],G=0,Y,q=0;q<I;q++){var ie=h.getInt32(),ee=h.getInt32();Y=(ie>>>4^ee)&252645135,ee^=Y,ie^=Y<<4,Y=(ee>>>-16^ie)&65535,ie^=Y,ee^=Y<<-16,Y=(ie>>>2^ee)&858993459,ee^=Y,ie^=Y<<2,Y=(ee>>>-16^ie)&65535,ie^=Y,ee^=Y<<-16,Y=(ie>>>1^ee)&1431655765,ee^=Y,ie^=Y<<1,Y=(ee>>>8^ie)&16711935,ie^=Y,ee^=Y<<8,Y=(ie>>>1^ee)&1431655765,ee^=Y,ie^=Y<<1,Y=ie<<8|ee>>>20&240,ie=ee<<24|ee<<8&16711680|ee>>>8&65280|ee>>>24&240,ee=Y;for(var le=0;le<A.length;++le){A[le]?(ie=ie<<2|ie>>>26,ee=ee<<2|ee>>>26):(ie=ie<<1|ie>>>27,ee=ee<<1|ee>>>27),ie&=-15,ee&=-15;var $=m[ie>>>28]|d[ie>>>24&15]|y[ie>>>20&15]|u[ie>>>16&15]|v[ie>>>12&15]|E[ie>>>8&15]|T[ie>>>4&15],J=_[ee>>>28]|w[ee>>>24&15]|g[ee>>>20&15]|f[ee>>>16&15]|k[ee>>>12&15]|L[ee>>>8&15]|H[ee>>>4&15];Y=(J>>>16^$)&65535,V[G++]=$^Y,V[G++]=J^Y<<16}}return V}function b(h,m,d,y){var u=h.length===32?3:9,v;u===3?v=y?[30,-2,-2]:[0,32,2]:v=y?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var E,T=m[0],_=m[1];E=(T>>>4^_)&252645135,_^=E,T^=E<<4,E=(T>>>16^_)&65535,_^=E,T^=E<<16,E=(_>>>2^T)&858993459,T^=E,_^=E<<2,E=(_>>>8^T)&16711935,T^=E,_^=E<<8,E=(T>>>1^_)&1431655765,_^=E,T^=E<<1,T=T<<1|T>>>31,_=_<<1|_>>>31;for(var w=0;w<u;w+=3){for(var g=v[w+1],f=v[w+2],k=v[w];k!=g;k+=f){var L=_^h[k],H=(_>>>4|_<<28)^h[k+1];E=T,T=_,_=E^(r[L>>>24&63]|s[L>>>16&63]|i[L>>>8&63]|c[L&63]|t[H>>>24&63]|n[H>>>16&63]|a[H>>>8&63]|l[H&63])}E=T,T=_,_=E}T=T>>>1|T<<31,_=_>>>1|_<<31,E=(T>>>1^_)&1431655765,_^=E,T^=E<<1,E=(_>>>8^T)&16711935,T^=E,_^=E<<8,E=(_>>>2^T)&858993459,T^=E,_^=E<<2,E=(T>>>16^_)&65535,_^=E,T^=E<<16,E=(T>>>4^_)&252645135,_^=E,T^=E<<4,d[0]=T,d[1]=_}function x(h){h=h||{};var m=(h.mode||"CBC").toUpperCase(),d="DES-"+m,y;h.decrypt?y=o.cipher.createDecipher(d,h.key):y=o.cipher.createCipher(d,h.key);var u=y.start;return y.start=function(v,E){var T=null;E instanceof o.util.ByteBuffer&&(T=E,E={}),E=E||{},E.output=T,E.iv=v,u.call(y,E)},y}return Hr}const Gr=ls(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Wr,mn;function jr(){if(mn)return Wr;mn=1;var o=xe();Vt(),yt(),Ee();var e=o.pkcs5=o.pkcs5||{},t;return o.util.isNodejs&&!o.options.usePureJavaScript&&(t=Gr),Wr=o.pbkdf2=e.pbkdf2=function(r,n,s,a,i,l){if(typeof i=="function"&&(l=i,i=null),o.util.isNodejs&&!o.options.usePureJavaScript&&t.pbkdf2&&(i===null||typeof i!="object")&&(t.pbkdf2Sync.length>4||!i||i==="sha1"))return typeof i!="string"&&(i="sha1"),r=Buffer.from(r,"binary"),n=Buffer.from(n,"binary"),l?t.pbkdf2Sync.length===4?t.pbkdf2(r,n,s,a,function(w,g){if(w)return l(w);l(null,g.toString("binary"))}):t.pbkdf2(r,n,s,a,i,function(w,g){if(w)return l(w);l(null,g.toString("binary"))}):t.pbkdf2Sync.length===4?t.pbkdf2Sync(r,n,s,a).toString("binary"):t.pbkdf2Sync(r,n,s,a,i).toString("binary");if((typeof i>"u"||i===null)&&(i="sha1"),typeof i=="string"){if(!(i in o.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=o.md[i].create()}var c=i.digestLength;if(a>4294967295*c){var p=new Error("Derived key is too long.");if(l)return l(p);throw p}var b=Math.ceil(a/c),x=a-(b-1)*c,h=o.hmac.create();h.start(i,r);var m="",d,y,u;if(!l){for(var v=1;v<=b;++v){h.start(null,null),h.update(n),h.update(o.util.int32ToBytes(v)),d=u=h.digest().getBytes();for(var E=2;E<=s;++E)h.start(null,null),h.update(u),y=h.digest().getBytes(),d=o.util.xorBytes(d,y,c),u=y;m+=v<b?d:d.substr(0,x)}return m}var v=1,E;function T(){if(v>b)return l(null,m);h.start(null,null),h.update(n),h.update(o.util.int32ToBytes(v)),d=u=h.digest().getBytes(),E=2,_()}function _(){if(E<=s)return h.start(null,null),h.update(u),y=h.digest().getBytes(),d=o.util.xorBytes(d,y,c),u=y,++E,o.util.setImmediate(_);m+=v<b?d:d.substr(0,x),++v,T()}T()},Wr}var rr={exports:{}},qr={exports:{}},yn;function vn(){if(yn)return qr.exports;yn=1;var o=xe();yt(),Ee();var e=qr.exports=o.sha256=o.sha256||{};o.md.sha256=o.md.algorithms.sha256=e,e.create=function(){r||s();var i=null,l=o.util.createBuffer(),c=new Array(64),p={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return p.start=function(){p.messageLength=0,p.fullMessageLength=p.messageLength64=[];for(var b=p.messageLengthSize/4,x=0;x<b;++x)p.fullMessageLength.push(0);return l=o.util.createBuffer(),i={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},p},p.start(),p.update=function(b,x){x==="utf8"&&(b=o.util.encodeUtf8(b));var h=b.length;p.messageLength+=h,h=[h/4294967296>>>0,h>>>0];for(var m=p.fullMessageLength.length-1;m>=0;--m)p.fullMessageLength[m]+=h[1],h[1]=h[0]+(p.fullMessageLength[m]/4294967296>>>0),p.fullMessageLength[m]=p.fullMessageLength[m]>>>0,h[0]=h[1]/4294967296>>>0;return l.putBytes(b),a(i,c,l),(l.read>2048||l.length()===0)&&l.compact(),p},p.digest=function(){var b=o.util.createBuffer();b.putBytes(l.bytes());var x=p.fullMessageLength[p.fullMessageLength.length-1]+p.messageLengthSize,h=x&p.blockLength-1;b.putBytes(t.substr(0,p.blockLength-h));for(var m,d,y=p.fullMessageLength[0]*8,u=0;u<p.fullMessageLength.length-1;++u)m=p.fullMessageLength[u+1]*8,d=m/4294967296>>>0,y+=d,b.putInt32(y>>>0),y=m>>>0;b.putInt32(y);var v={h0:i.h0,h1:i.h1,h2:i.h2,h3:i.h3,h4:i.h4,h5:i.h5,h6:i.h6,h7:i.h7};a(v,c,b);var E=o.util.createBuffer();return E.putInt32(v.h0),E.putInt32(v.h1),E.putInt32(v.h2),E.putInt32(v.h3),E.putInt32(v.h4),E.putInt32(v.h5),E.putInt32(v.h6),E.putInt32(v.h7),E},p};var t=null,r=!1,n=null;function s(){t="",t+=o.util.fillString("\0",64),n=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],r=!0}function a(i,l,c){for(var p,b,x,h,m,d,y,u,v,E,T,_,w,g,f,k=c.length();k>=64;){for(y=0;y<16;++y)l[y]=c.getInt32();for(;y<64;++y)p=l[y-2],p=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,b=l[y-15],b=(b>>>7|b<<25)^(b>>>18|b<<14)^b>>>3,l[y]=p+l[y-7]+b+l[y-16]|0;for(u=i.h0,v=i.h1,E=i.h2,T=i.h3,_=i.h4,w=i.h5,g=i.h6,f=i.h7,y=0;y<64;++y)h=(_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7),m=g^_&(w^g),x=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),d=u&v|E&(u^v),p=f+h+m+n[y]+l[y],b=x+d,f=g,g=w,w=_,_=T+p>>>0,T=E,E=v,v=u,u=p+b>>>0;i.h0=i.h0+u|0,i.h1=i.h1+v|0,i.h2=i.h2+E|0,i.h3=i.h3+T|0,i.h4=i.h4+_|0,i.h5=i.h5+w|0,i.h6=i.h6+g|0,i.h7=i.h7+f|0,k-=64}}return qr.exports}var Yr={exports:{}},xn;function Cn(){if(xn)return Yr.exports;xn=1;var o=xe();Ee();var e=null;o.util.isNodejs&&!o.options.usePureJavaScript&&!process.versions["node-webkit"]&&(e=Gr);var t=Yr.exports=o.prng=o.prng||{};return t.create=function(r){for(var n={plugin:r,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},s=r.md,a=new Array(32),i=0;i<32;++i)a[i]=s.create();n.pools=a,n.pool=0,n.generate=function(x,h){if(!h)return n.generateSync(x);var m=n.plugin.cipher,d=n.plugin.increment,y=n.plugin.formatKey,u=n.plugin.formatSeed,v=o.util.createBuffer();n.key=null,E();function E(T){if(T)return h(T);if(v.length()>=x)return h(null,v.getBytes(x));if(n.generated>1048575&&(n.key=null),n.key===null)return o.util.nextTick(function(){l(E)});var _=m(n.key,n.seed);n.generated+=_.length,v.putBytes(_),n.key=y(m(n.key,d(n.seed))),n.seed=u(m(n.key,n.seed)),o.util.setImmediate(E)}},n.generateSync=function(x){var h=n.plugin.cipher,m=n.plugin.increment,d=n.plugin.formatKey,y=n.plugin.formatSeed;n.key=null;for(var u=o.util.createBuffer();u.length()<x;){n.generated>1048575&&(n.key=null),n.key===null&&c();var v=h(n.key,n.seed);n.generated+=v.length,u.putBytes(v),n.key=d(h(n.key,m(n.seed))),n.seed=y(h(n.key,n.seed))}return u.getBytes(x)};function l(x){if(n.pools[0].messageLength>=32)return p(),x();var h=32-n.pools[0].messageLength<<5;n.seedFile(h,function(m,d){if(m)return x(m);n.collect(d),p(),x()})}function c(){if(n.pools[0].messageLength>=32)return p();var x=32-n.pools[0].messageLength<<5;n.collect(n.seedFileSync(x)),p()}function p(){n.reseeds=n.reseeds===4294967295?0:n.reseeds+1;var x=n.plugin.md.create();x.update(n.keyBytes);for(var h=1,m=0;m<32;++m)n.reseeds%h===0&&(x.update(n.pools[m].digest().getBytes()),n.pools[m].start()),h=h<<1;n.keyBytes=x.digest().getBytes(),x.start(),x.update(n.keyBytes);var d=x.digest().getBytes();n.key=n.plugin.formatKey(n.keyBytes),n.seed=n.plugin.formatSeed(d),n.generated=0}function b(x){var h=null,m=o.util.globalScope,d=m.crypto||m.msCrypto;d&&d.getRandomValues&&(h=function(f){return d.getRandomValues(f)});var y=o.util.createBuffer();if(h)for(;y.length()<x;){var u=Math.max(1,Math.min(x-y.length(),65536)/4),v=new Uint32Array(Math.floor(u));try{h(v);for(var E=0;E<v.length;++E)y.putInt32(v[E])}catch(f){if(!(typeof QuotaExceededError<"u"&&f instanceof QuotaExceededError))throw f}}if(y.length()<x)for(var T,_,w,g=Math.floor(Math.random()*65536);y.length()<x;){_=16807*(g&65535),T=16807*(g>>16),_+=(T&32767)<<16,_+=T>>15,_=(_&2147483647)+(_>>31),g=_&4294967295;for(var E=0;E<3;++E)w=g>>>(E<<3),w^=Math.floor(Math.random()*256),y.putByte(w&255)}return y.getBytes(x)}return e?(n.seedFile=function(x,h){e.randomBytes(x,function(m,d){if(m)return h(m);h(null,d.toString())})},n.seedFileSync=function(x){return e.randomBytes(x).toString()}):(n.seedFile=function(x,h){try{h(null,b(x))}catch(m){h(m)}},n.seedFileSync=b),n.collect=function(x){for(var h=x.length,m=0;m<h;++m)n.pools[n.pool].update(x.substr(m,1)),n.pool=n.pool===31?0:n.pool+1},n.collectInt=function(x,h){for(var m="",d=0;d<h;d+=8)m+=String.fromCharCode(x>>d&255);n.collect(m)},n.registerWorker=function(x){if(x===self)n.seedFile=function(m,d){function y(u){var v=u.data;v.forge&&v.forge.prng&&(self.removeEventListener("message",y),d(v.forge.prng.err,v.forge.prng.bytes))}self.addEventListener("message",y),self.postMessage({forge:{prng:{needed:m}}})};else{var h=function(m){var d=m.data;d.forge&&d.forge.prng&&n.seedFile(d.forge.prng.needed,function(y,u){x.postMessage({forge:{prng:{err:y,bytes:u}}})})};x.addEventListener("message",h)}},n},Yr.exports}var bn;function ot(){if(bn)return rr.exports;bn=1;var o=xe();return St(),vn(),Cn(),Ee(),(function(){if(o.random&&o.random.getBytes){rr.exports=o.random;return}(function(e){var t={},r=new Array(4),n=o.util.createBuffer();t.formatKey=function(x){var h=o.util.createBuffer(x);return x=new Array(4),x[0]=h.getInt32(),x[1]=h.getInt32(),x[2]=h.getInt32(),x[3]=h.getInt32(),o.aes._expandKey(x,!1)},t.formatSeed=function(x){var h=o.util.createBuffer(x);return x=new Array(4),x[0]=h.getInt32(),x[1]=h.getInt32(),x[2]=h.getInt32(),x[3]=h.getInt32(),x},t.cipher=function(x,h){return o.aes._updateBlock(x,h,r,!1),n.putInt32(r[0]),n.putInt32(r[1]),n.putInt32(r[2]),n.putInt32(r[3]),n.getBytes()},t.increment=function(x){return++x[3],x},t.md=o.md.sha256;function s(){var x=o.prng.create(t);return x.getBytes=function(h,m){return x.generate(h,m)},x.getBytesSync=function(h){return x.generate(h)},x}var a=s(),i=null,l=o.util.globalScope,c=l.crypto||l.msCrypto;if(c&&c.getRandomValues&&(i=function(x){return c.getRandomValues(x)}),o.options.usePureJavaScript||!o.util.isNodejs&&!i){if(a.collectInt(+new Date,32),typeof navigator<"u"){var p="";for(var b in navigator)try{typeof navigator[b]=="string"&&(p+=navigator[b])}catch{}a.collect(p),p=null}e&&(e().mousemove(function(x){a.collectInt(x.clientX,16),a.collectInt(x.clientY,16)}),e().keypress(function(x){a.collectInt(x.charCode,8)}))}if(!o.random)o.random=a;else for(var b in a)o.random[b]=a[b];o.random.createInstance=s,rr.exports=o.random})(typeof jQuery<"u"?jQuery:null)})(),rr.exports}var $r,En;function wn(){if(En)return $r;En=1;var o=xe();Ee();var e=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],t=[1,2,3,5],r=function(a,i){return a<<i&65535|(a&65535)>>16-i},n=function(a,i){return(a&65535)>>i|a<<16-i&65535};$r=o.rc2=o.rc2||{},o.rc2.expandKey=function(a,i){typeof a=="string"&&(a=o.util.createBuffer(a)),i=i||128;var l=a,c=a.length(),p=i,b=Math.ceil(p/8),x=255>>(p&7),h;for(h=c;h<128;h++)l.putByte(e[l.at(h-1)+l.at(h-c)&255]);for(l.setAt(128-b,e[l.at(128-b)&x]),h=127-b;h>=0;h--)l.setAt(h,e[l.at(h+1)^l.at(h+b)]);return l};var s=function(a,i,l){var c=!1,p=null,b=null,x=null,h,m,d,y,u=[];for(a=o.rc2.expandKey(a,i),d=0;d<64;d++)u.push(a.getInt16Le());l?(h=function(T){for(d=0;d<4;d++)T[d]+=u[y]+(T[(d+3)%4]&T[(d+2)%4])+(~T[(d+3)%4]&T[(d+1)%4]),T[d]=r(T[d],t[d]),y++},m=function(T){for(d=0;d<4;d++)T[d]+=u[T[(d+3)%4]&63]}):(h=function(T){for(d=3;d>=0;d--)T[d]=n(T[d],t[d]),T[d]-=u[y]+(T[(d+3)%4]&T[(d+2)%4])+(~T[(d+3)%4]&T[(d+1)%4]),y--},m=function(T){for(d=3;d>=0;d--)T[d]-=u[T[(d+3)%4]&63]});var v=function(T){var _=[];for(d=0;d<4;d++){var w=p.getInt16Le();x!==null&&(l?w^=x.getInt16Le():x.putInt16Le(w)),_.push(w&65535)}y=l?0:63;for(var g=0;g<T.length;g++)for(var f=0;f<T[g][0];f++)T[g][1](_);for(d=0;d<4;d++)x!==null&&(l?x.putInt16Le(_[d]):_[d]^=x.getInt16Le()),b.putInt16Le(_[d])},E=null;return E={start:function(T,_){T&&typeof T=="string"&&(T=o.util.createBuffer(T)),c=!1,p=o.util.createBuffer(),b=_||new o.util.createBuffer,x=T,E.output=b},update:function(T){for(c||p.putBuffer(T);p.length()>=8;)v([[5,h],[1,m],[6,h],[1,m],[5,h]])},finish:function(T){var _=!0;if(l)if(T)_=T(8,p,!l);else{var w=p.length()===8?8:8-p.length();p.fillWithByte(w,w)}if(_&&(c=!0,E.update()),!l&&(_=p.length()===0,_))if(T)_=T(8,b,!l);else{var g=b.length(),f=b.at(g-1);f>g?_=!1:b.truncate(f)}return _}},E};return o.rc2.startEncrypting=function(a,i,l){var c=o.rc2.createEncryptionCipher(a,128);return c.start(i,l),c},o.rc2.createEncryptionCipher=function(a,i){return s(a,i,!0)},o.rc2.startDecrypting=function(a,i,l){var c=o.rc2.createDecryptionCipher(a,128);return c.start(i,l),c},o.rc2.createDecryptionCipher=function(a,i){return s(a,i,!1)},$r}var Zr,Sn;function ir(){if(Sn)return Zr;Sn=1;var o=xe();Zr=o.jsbn=o.jsbn||{};var e;function t(M,P,K){this.data=[],M!=null&&(typeof M=="number"?this.fromNumber(M,P,K):P==null&&typeof M!="string"?this.fromString(M,256):this.fromString(M,P))}o.jsbn.BigInteger=t;function r(){return new t(null)}function n(M,P,K,X,se,ue){for(;--ue>=0;){var ge=P*this.data[M++]+K.data[X]+se;se=Math.floor(ge/67108864),K.data[X++]=ge&67108863}return se}function s(M,P,K,X,se,ue){for(var ge=P&32767,fe=P>>15;--ue>=0;){var _e=this.data[M]&32767,Qe=this.data[M++]>>15,at=fe*_e+Qe*ge;_e=ge*_e+((at&32767)<<15)+K.data[X]+(se&1073741823),se=(_e>>>30)+(at>>>15)+fe*Qe+(se>>>30),K.data[X++]=_e&1073741823}return se}function a(M,P,K,X,se,ue){for(var ge=P&16383,fe=P>>14;--ue>=0;){var _e=this.data[M]&16383,Qe=this.data[M++]>>14,at=fe*_e+Qe*ge;_e=ge*_e+((at&16383)<<14)+K.data[X]+se,se=(_e>>28)+(at>>14)+fe*Qe,K.data[X++]=_e&268435455}return se}typeof navigator>"u"?(t.prototype.am=a,e=28):navigator.appName=="Microsoft Internet Explorer"?(t.prototype.am=s,e=30):navigator.appName!="Netscape"?(t.prototype.am=n,e=26):(t.prototype.am=a,e=28),t.prototype.DB=e,t.prototype.DM=(1<<e)-1,t.prototype.DV=1<<e;var i=52;t.prototype.FV=Math.pow(2,i),t.prototype.F1=i-e,t.prototype.F2=2*e-i;var l="0123456789abcdefghijklmnopqrstuvwxyz",c=new Array,p,b;for(p=48,b=0;b<=9;++b)c[p++]=b;for(p=97,b=10;b<36;++b)c[p++]=b;for(p=65,b=10;b<36;++b)c[p++]=b;function x(M){return l.charAt(M)}function h(M,P){var K=c[M.charCodeAt(P)];return K??-1}function m(M){for(var P=this.t-1;P>=0;--P)M.data[P]=this.data[P];M.t=this.t,M.s=this.s}function d(M){this.t=1,this.s=M<0?-1:0,M>0?this.data[0]=M:M<-1?this.data[0]=M+this.DV:this.t=0}function y(M){var P=r();return P.fromInt(M),P}function u(M,P){var K;if(P==16)K=4;else if(P==8)K=3;else if(P==256)K=8;else if(P==2)K=1;else if(P==32)K=5;else if(P==4)K=2;else{this.fromRadix(M,P);return}this.t=0,this.s=0;for(var X=M.length,se=!1,ue=0;--X>=0;){var ge=K==8?M[X]&255:h(M,X);if(ge<0){M.charAt(X)=="-"&&(se=!0);continue}se=!1,ue==0?this.data[this.t++]=ge:ue+K>this.DB?(this.data[this.t-1]|=(ge&(1<<this.DB-ue)-1)<<ue,this.data[this.t++]=ge>>this.DB-ue):this.data[this.t-1]|=ge<<ue,ue+=K,ue>=this.DB&&(ue-=this.DB)}K==8&&(M[0]&128)!=0&&(this.s=-1,ue>0&&(this.data[this.t-1]|=(1<<this.DB-ue)-1<<ue)),this.clamp(),se&&t.ZERO.subTo(this,this)}function v(){for(var M=this.s&this.DM;this.t>0&&this.data[this.t-1]==M;)--this.t}function E(M){if(this.s<0)return"-"+this.negate().toString(M);var P;if(M==16)P=4;else if(M==8)P=3;else if(M==2)P=1;else if(M==32)P=5;else if(M==4)P=2;else return this.toRadix(M);var K=(1<<P)-1,X,se=!1,ue="",ge=this.t,fe=this.DB-ge*this.DB%P;if(ge-- >0)for(fe<this.DB&&(X=this.data[ge]>>fe)>0&&(se=!0,ue=x(X));ge>=0;)fe<P?(X=(this.data[ge]&(1<<fe)-1)<<P-fe,X|=this.data[--ge]>>(fe+=this.DB-P)):(X=this.data[ge]>>(fe-=P)&K,fe<=0&&(fe+=this.DB,--ge)),X>0&&(se=!0),se&&(ue+=x(X));return se?ue:"0"}function T(){var M=r();return t.ZERO.subTo(this,M),M}function _(){return this.s<0?this.negate():this}function w(M){var P=this.s-M.s;if(P!=0)return P;var K=this.t;if(P=K-M.t,P!=0)return this.s<0?-P:P;for(;--K>=0;)if((P=this.data[K]-M.data[K])!=0)return P;return 0}function g(M){var P=1,K;return(K=M>>>16)!=0&&(M=K,P+=16),(K=M>>8)!=0&&(M=K,P+=8),(K=M>>4)!=0&&(M=K,P+=4),(K=M>>2)!=0&&(M=K,P+=2),(K=M>>1)!=0&&(M=K,P+=1),P}function f(){return this.t<=0?0:this.DB*(this.t-1)+g(this.data[this.t-1]^this.s&this.DM)}function k(M,P){var K;for(K=this.t-1;K>=0;--K)P.data[K+M]=this.data[K];for(K=M-1;K>=0;--K)P.data[K]=0;P.t=this.t+M,P.s=this.s}function L(M,P){for(var K=M;K<this.t;++K)P.data[K-M]=this.data[K];P.t=Math.max(this.t-M,0),P.s=this.s}function H(M,P){var K=M%this.DB,X=this.DB-K,se=(1<<X)-1,ue=Math.floor(M/this.DB),ge=this.s<<K&this.DM,fe;for(fe=this.t-1;fe>=0;--fe)P.data[fe+ue+1]=this.data[fe]>>X|ge,ge=(this.data[fe]&se)<<K;for(fe=ue-1;fe>=0;--fe)P.data[fe]=0;P.data[ue]=ge,P.t=this.t+ue+1,P.s=this.s,P.clamp()}function I(M,P){P.s=this.s;var K=Math.floor(M/this.DB);if(K>=this.t){P.t=0;return}var X=M%this.DB,se=this.DB-X,ue=(1<<X)-1;P.data[0]=this.data[K]>>X;for(var ge=K+1;ge<this.t;++ge)P.data[ge-K-1]|=(this.data[ge]&ue)<<se,P.data[ge-K]=this.data[ge]>>X;X>0&&(P.data[this.t-K-1]|=(this.s&ue)<<se),P.t=this.t-K,P.clamp()}function V(M,P){for(var K=0,X=0,se=Math.min(M.t,this.t);K<se;)X+=this.data[K]-M.data[K],P.data[K++]=X&this.DM,X>>=this.DB;if(M.t<this.t){for(X-=M.s;K<this.t;)X+=this.data[K],P.data[K++]=X&this.DM,X>>=this.DB;X+=this.s}else{for(X+=this.s;K<M.t;)X-=M.data[K],P.data[K++]=X&this.DM,X>>=this.DB;X-=M.s}P.s=X<0?-1:0,X<-1?P.data[K++]=this.DV+X:X>0&&(P.data[K++]=X),P.t=K,P.clamp()}function A(M,P){var K=this.abs(),X=M.abs(),se=K.t;for(P.t=se+X.t;--se>=0;)P.data[se]=0;for(se=0;se<X.t;++se)P.data[se+K.t]=K.am(0,X.data[se],P,se,0,K.t);P.s=0,P.clamp(),this.s!=M.s&&t.ZERO.subTo(P,P)}function G(M){for(var P=this.abs(),K=M.t=2*P.t;--K>=0;)M.data[K]=0;for(K=0;K<P.t-1;++K){var X=P.am(K,P.data[K],M,2*K,0,1);(M.data[K+P.t]+=P.am(K+1,2*P.data[K],M,2*K+1,X,P.t-K-1))>=P.DV&&(M.data[K+P.t]-=P.DV,M.data[K+P.t+1]=1)}M.t>0&&(M.data[M.t-1]+=P.am(K,P.data[K],M,2*K,0,1)),M.s=0,M.clamp()}function Y(M,P,K){var X=M.abs();if(!(X.t<=0)){var se=this.abs();if(se.t<X.t){P?.fromInt(0),K!=null&&this.copyTo(K);return}K==null&&(K=r());var ue=r(),ge=this.s,fe=M.s,_e=this.DB-g(X.data[X.t-1]);_e>0?(X.lShiftTo(_e,ue),se.lShiftTo(_e,K)):(X.copyTo(ue),se.copyTo(K));var Qe=ue.t,at=ue.data[Qe-1];if(at!=0){var nt=at*(1<<this.F1)+(Qe>1?ue.data[Qe-2]>>this.F2:0),vt=this.FV/nt,cr=(1<<this.F1)/nt,dt=1<<this.F2,ft=K.t,ur=ft-Qe,bt=P??r();for(ue.dlShiftTo(ur,bt),K.compareTo(bt)>=0&&(K.data[K.t++]=1,K.subTo(bt,K)),t.ONE.dlShiftTo(Qe,bt),bt.subTo(ue,ue);ue.t<Qe;)ue.data[ue.t++]=0;for(;--ur>=0;){var bi=K.data[--ft]==at?this.DM:Math.floor(K.data[ft]*vt+(K.data[ft-1]+dt)*cr);if((K.data[ft]+=ue.am(0,bi,K,ur,0,Qe))<bi)for(ue.dlShiftTo(ur,bt),K.subTo(bt,K);K.data[ft]<--bi;)K.subTo(bt,K)}P!=null&&(K.drShiftTo(Qe,P),ge!=fe&&t.ZERO.subTo(P,P)),K.t=Qe,K.clamp(),_e>0&&K.rShiftTo(_e,K),ge<0&&t.ZERO.subTo(K,K)}}}function q(M){var P=r();return this.abs().divRemTo(M,null,P),this.s<0&&P.compareTo(t.ZERO)>0&&M.subTo(P,P),P}function ie(M){this.m=M}function ee(M){return M.s<0||M.compareTo(this.m)>=0?M.mod(this.m):M}function le(M){return M}function $(M){M.divRemTo(this.m,null,M)}function J(M,P,K){M.multiplyTo(P,K),this.reduce(K)}function de(M,P){M.squareTo(P),this.reduce(P)}ie.prototype.convert=ee,ie.prototype.revert=le,ie.prototype.reduce=$,ie.prototype.mulTo=J,ie.prototype.sqrTo=de;function ae(){if(this.t<1)return 0;var M=this.data[0];if((M&1)==0)return 0;var P=M&3;return P=P*(2-(M&15)*P)&15,P=P*(2-(M&255)*P)&255,P=P*(2-((M&65535)*P&65535))&65535,P=P*(2-M*P%this.DV)%this.DV,P>0?this.DV-P:-P}function te(M){this.m=M,this.mp=M.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<M.DB-15)-1,this.mt2=2*M.t}function ce(M){var P=r();return M.abs().dlShiftTo(this.m.t,P),P.divRemTo(this.m,null,P),M.s<0&&P.compareTo(t.ZERO)>0&&this.m.subTo(P,P),P}function we(M){var P=r();return M.copyTo(P),this.reduce(P),P}function ye(M){for(;M.t<=this.mt2;)M.data[M.t++]=0;for(var P=0;P<this.m.t;++P){var K=M.data[P]&32767,X=K*this.mpl+((K*this.mph+(M.data[P]>>15)*this.mpl&this.um)<<15)&M.DM;for(K=P+this.m.t,M.data[K]+=this.m.am(0,X,M,P,0,this.m.t);M.data[K]>=M.DV;)M.data[K]-=M.DV,M.data[++K]++}M.clamp(),M.drShiftTo(this.m.t,M),M.compareTo(this.m)>=0&&M.subTo(this.m,M)}function B(M,P){M.squareTo(P),this.reduce(P)}function U(M,P,K){M.multiplyTo(P,K),this.reduce(K)}te.prototype.convert=ce,te.prototype.revert=we,te.prototype.reduce=ye,te.prototype.mulTo=U,te.prototype.sqrTo=B;function D(){return(this.t>0?this.data[0]&1:this.s)==0}function N(M,P){if(M>4294967295||M<1)return t.ONE;var K=r(),X=r(),se=P.convert(this),ue=g(M)-1;for(se.copyTo(K);--ue>=0;)if(P.sqrTo(K,X),(M&1<<ue)>0)P.mulTo(X,se,K);else{var ge=K;K=X,X=ge}return P.revert(K)}function S(M,P){var K;return M<256||P.isEven()?K=new ie(P):K=new te(P),this.exp(M,K)}t.prototype.copyTo=m,t.prototype.fromInt=d,t.prototype.fromString=u,t.prototype.clamp=v,t.prototype.dlShiftTo=k,t.prototype.drShiftTo=L,t.prototype.lShiftTo=H,t.prototype.rShiftTo=I,t.prototype.subTo=V,t.prototype.multiplyTo=A,t.prototype.squareTo=G,t.prototype.divRemTo=Y,t.prototype.invDigit=ae,t.prototype.isEven=D,t.prototype.exp=N,t.prototype.toString=E,t.prototype.negate=T,t.prototype.abs=_,t.prototype.compareTo=w,t.prototype.bitLength=f,t.prototype.mod=q,t.prototype.modPowInt=S,t.ZERO=y(0),t.ONE=y(1);function C(){var M=r();return this.copyTo(M),M}function R(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function W(){return this.t==0?this.s:this.data[0]<<24>>24}function F(){return this.t==0?this.s:this.data[0]<<16>>16}function O(M){return Math.floor(Math.LN2*this.DB/Math.log(M))}function z(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function Q(M){if(M==null&&(M=10),this.signum()==0||M<2||M>36)return"0";var P=this.chunkSize(M),K=Math.pow(M,P),X=y(K),se=r(),ue=r(),ge="";for(this.divRemTo(X,se,ue);se.signum()>0;)ge=(K+ue.intValue()).toString(M).substr(1)+ge,se.divRemTo(X,se,ue);return ue.intValue().toString(M)+ge}function re(M,P){this.fromInt(0),P==null&&(P=10);for(var K=this.chunkSize(P),X=Math.pow(P,K),se=!1,ue=0,ge=0,fe=0;fe<M.length;++fe){var _e=h(M,fe);if(_e<0){M.charAt(fe)=="-"&&this.signum()==0&&(se=!0);continue}ge=P*ge+_e,++ue>=K&&(this.dMultiply(X),this.dAddOffset(ge,0),ue=0,ge=0)}ue>0&&(this.dMultiply(Math.pow(P,ue)),this.dAddOffset(ge,0)),se&&t.ZERO.subTo(this,this)}function Z(M,P,K){if(typeof P=="number")if(M<2)this.fromInt(1);else for(this.fromNumber(M,K),this.testBit(M-1)||this.bitwiseTo(t.ONE.shiftLeft(M-1),Se,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(P);)this.dAddOffset(2,0),this.bitLength()>M&&this.subTo(t.ONE.shiftLeft(M-1),this);else{var X=new Array,se=M&7;X.length=(M>>3)+1,P.nextBytes(X),se>0?X[0]&=(1<<se)-1:X[0]=0,this.fromString(X,256)}}function ne(){var M=this.t,P=new Array;P[0]=this.s;var K=this.DB-M*this.DB%8,X,se=0;if(M-- >0)for(K<this.DB&&(X=this.data[M]>>K)!=(this.s&this.DM)>>K&&(P[se++]=X|this.s<<this.DB-K);M>=0;)K<8?(X=(this.data[M]&(1<<K)-1)<<8-K,X|=this.data[--M]>>(K+=this.DB-8)):(X=this.data[M]>>(K-=8)&255,K<=0&&(K+=this.DB,--M)),(X&128)!=0&&(X|=-256),se==0&&(this.s&128)!=(X&128)&&++se,(se>0||X!=this.s)&&(P[se++]=X);return P}function he(M){return this.compareTo(M)==0}function oe(M){return this.compareTo(M)<0?this:M}function pe(M){return this.compareTo(M)>0?this:M}function ve(M,P,K){var X,se,ue=Math.min(M.t,this.t);for(X=0;X<ue;++X)K.data[X]=P(this.data[X],M.data[X]);if(M.t<this.t){for(se=M.s&this.DM,X=ue;X<this.t;++X)K.data[X]=P(this.data[X],se);K.t=this.t}else{for(se=this.s&this.DM,X=ue;X<M.t;++X)K.data[X]=P(se,M.data[X]);K.t=M.t}K.s=P(this.s,M.s),K.clamp()}function me(M,P){return M&P}function be(M){var P=r();return this.bitwiseTo(M,me,P),P}function Se(M,P){return M|P}function Te(M){var P=r();return this.bitwiseTo(M,Se,P),P}function Ie(M,P){return M^P}function Ce(M){var P=r();return this.bitwiseTo(M,Ie,P),P}function Le(M,P){return M&~P}function Ue(M){var P=r();return this.bitwiseTo(M,Le,P),P}function ke(){for(var M=r(),P=0;P<this.t;++P)M.data[P]=this.DM&~this.data[P];return M.t=this.t,M.s=~this.s,M}function Je(M){var P=r();return M<0?this.rShiftTo(-M,P):this.lShiftTo(M,P),P}function rt(M){var P=r();return M<0?this.lShiftTo(-M,P):this.rShiftTo(M,P),P}function st(M){if(M==0)return-1;var P=0;return(M&65535)==0&&(M>>=16,P+=16),(M&255)==0&&(M>>=8,P+=8),(M&15)==0&&(M>>=4,P+=4),(M&3)==0&&(M>>=2,P+=2),(M&1)==0&&++P,P}function lt(){for(var M=0;M<this.t;++M)if(this.data[M]!=0)return M*this.DB+st(this.data[M]);return this.s<0?this.t*this.DB:-1}function ct(M){for(var P=0;M!=0;)M&=M-1,++P;return P}function it(){for(var M=0,P=this.s&this.DM,K=0;K<this.t;++K)M+=ct(this.data[K]^P);return M}function ut(M){var P=Math.floor(M/this.DB);return P>=this.t?this.s!=0:(this.data[P]&1<<M%this.DB)!=0}function Ft(M,P){var K=t.ONE.shiftLeft(M);return this.bitwiseTo(K,P,K),K}function lr(M){return this.changeBit(M,Se)}function Ve(M){return this.changeBit(M,Le)}function Oe(M){return this.changeBit(M,Ie)}function Fe(M,P){for(var K=0,X=0,se=Math.min(M.t,this.t);K<se;)X+=this.data[K]+M.data[K],P.data[K++]=X&this.DM,X>>=this.DB;if(M.t<this.t){for(X+=M.s;K<this.t;)X+=this.data[K],P.data[K++]=X&this.DM,X>>=this.DB;X+=this.s}else{for(X+=this.s;K<M.t;)X+=M.data[K],P.data[K++]=X&this.DM,X>>=this.DB;X+=M.s}P.s=X<0?-1:0,X>0?P.data[K++]=X:X<-1&&(P.data[K++]=this.DV+X),P.t=K,P.clamp()}function ze(M){var P=r();return this.addTo(M,P),P}function Ke(M){var P=r();return this.subTo(M,P),P}function He(M){var P=r();return this.multiplyTo(M,P),P}function Ge(){var M=r();return this.squareTo(M),M}function We(M){var P=r();return this.divRemTo(M,P,null),P}function je(M){var P=r();return this.divRemTo(M,null,P),P}function qe(M){var P=r(),K=r();return this.divRemTo(M,P,K),new Array(P,K)}function Ye(M){this.data[this.t]=this.am(0,M-1,this,0,0,this.t),++this.t,this.clamp()}function $e(M,P){if(M!=0){for(;this.t<=P;)this.data[this.t++]=0;for(this.data[P]+=M;this.data[P]>=this.DV;)this.data[P]-=this.DV,++P>=this.t&&(this.data[this.t++]=0),++this.data[P]}}function Me(){}function De(M){return M}function Ze(M,P,K){M.multiplyTo(P,K)}function Xe(M,P){M.squareTo(P)}Me.prototype.convert=De,Me.prototype.revert=De,Me.prototype.mulTo=Ze,Me.prototype.sqrTo=Xe;function zo(M){return this.exp(M,new Me)}function Ko(M,P,K){var X=Math.min(this.t+M.t,P);for(K.s=0,K.t=X;X>0;)K.data[--X]=0;var se;for(se=K.t-this.t;X<se;++X)K.data[X+this.t]=this.am(0,M.data[X],K,X,0,this.t);for(se=Math.min(M.t,P);X<se;++X)this.am(0,M.data[X],K,X,0,P-X);K.clamp()}function Ho(M,P,K){--P;var X=K.t=this.t+M.t-P;for(K.s=0;--X>=0;)K.data[X]=0;for(X=Math.max(P-this.t,0);X<M.t;++X)K.data[this.t+X-P]=this.am(P-X,M.data[X],K,0,0,this.t+X-P);K.clamp(),K.drShiftTo(1,K)}function It(M){this.r2=r(),this.q3=r(),t.ONE.dlShiftTo(2*M.t,this.r2),this.mu=this.r2.divide(M),this.m=M}function Go(M){if(M.s<0||M.t>2*this.m.t)return M.mod(this.m);if(M.compareTo(this.m)<0)return M;var P=r();return M.copyTo(P),this.reduce(P),P}function Wo(M){return M}function jo(M){for(M.drShiftTo(this.m.t-1,this.r2),M.t>this.m.t+1&&(M.t=this.m.t+1,M.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);M.compareTo(this.r2)<0;)M.dAddOffset(1,this.m.t+1);for(M.subTo(this.r2,M);M.compareTo(this.m)>=0;)M.subTo(this.m,M)}function qo(M,P){M.squareTo(P),this.reduce(P)}function Yo(M,P,K){M.multiplyTo(P,K),this.reduce(K)}It.prototype.convert=Go,It.prototype.revert=Wo,It.prototype.reduce=jo,It.prototype.mulTo=Yo,It.prototype.sqrTo=qo;function $o(M,P){var K=M.bitLength(),X,se=y(1),ue;if(K<=0)return se;K<18?X=1:K<48?X=3:K<144?X=4:K<768?X=5:X=6,K<8?ue=new ie(P):P.isEven()?ue=new It(P):ue=new te(P);var ge=new Array,fe=3,_e=X-1,Qe=(1<<X)-1;if(ge[1]=ue.convert(this),X>1){var at=r();for(ue.sqrTo(ge[1],at);fe<=Qe;)ge[fe]=r(),ue.mulTo(at,ge[fe-2],ge[fe]),fe+=2}var nt=M.t-1,vt,cr=!0,dt=r(),ft;for(K=g(M.data[nt])-1;nt>=0;){for(K>=_e?vt=M.data[nt]>>K-_e&Qe:(vt=(M.data[nt]&(1<<K+1)-1)<<_e-K,nt>0&&(vt|=M.data[nt-1]>>this.DB+K-_e)),fe=X;(vt&1)==0;)vt>>=1,--fe;if((K-=fe)<0&&(K+=this.DB,--nt),cr)ge[vt].copyTo(se),cr=!1;else{for(;fe>1;)ue.sqrTo(se,dt),ue.sqrTo(dt,se),fe-=2;fe>0?ue.sqrTo(se,dt):(ft=se,se=dt,dt=ft),ue.mulTo(dt,ge[vt],se)}for(;nt>=0&&(M.data[nt]&1<<K)==0;)ue.sqrTo(se,dt),ft=se,se=dt,dt=ft,--K<0&&(K=this.DB-1,--nt)}return ue.revert(se)}function Zo(M){var P=this.s<0?this.negate():this.clone(),K=M.s<0?M.negate():M.clone();if(P.compareTo(K)<0){var X=P;P=K,K=X}var se=P.getLowestSetBit(),ue=K.getLowestSetBit();if(ue<0)return P;for(se<ue&&(ue=se),ue>0&&(P.rShiftTo(ue,P),K.rShiftTo(ue,K));P.signum()>0;)(se=P.getLowestSetBit())>0&&P.rShiftTo(se,P),(se=K.getLowestSetBit())>0&&K.rShiftTo(se,K),P.compareTo(K)>=0?(P.subTo(K,P),P.rShiftTo(1,P)):(K.subTo(P,K),K.rShiftTo(1,K));return ue>0&&K.lShiftTo(ue,K),K}function Xo(M){if(M<=0)return 0;var P=this.DV%M,K=this.s<0?M-1:0;if(this.t>0)if(P==0)K=this.data[0]%M;else for(var X=this.t-1;X>=0;--X)K=(P*K+this.data[X])%M;return K}function Qo(M){if(this.signum()==0)return t.ZERO;var P=M.isEven();if(this.isEven()&&P||M.signum()==0)return t.ZERO;for(var K=M.clone(),X=this.clone(),se=y(1),ue=y(0),ge=y(0),fe=y(1);K.signum()!=0;){for(;K.isEven();)K.rShiftTo(1,K),P?((!se.isEven()||!ue.isEven())&&(se.addTo(this,se),ue.subTo(M,ue)),se.rShiftTo(1,se)):ue.isEven()||ue.subTo(M,ue),ue.rShiftTo(1,ue);for(;X.isEven();)X.rShiftTo(1,X),P?((!ge.isEven()||!fe.isEven())&&(ge.addTo(this,ge),fe.subTo(M,fe)),ge.rShiftTo(1,ge)):fe.isEven()||fe.subTo(M,fe),fe.rShiftTo(1,fe);K.compareTo(X)>=0?(K.subTo(X,K),P&&se.subTo(ge,se),ue.subTo(fe,ue)):(X.subTo(K,X),P&&ge.subTo(se,ge),fe.subTo(ue,fe))}if(X.compareTo(t.ONE)!=0)return t.ZERO;if(fe.compareTo(M)>=0)return fe.subtract(M);if(fe.signum()<0)fe.addTo(M,fe);else return fe;return fe.signum()<0?fe.add(M):fe}var ht=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Jo=(1<<26)/ht[ht.length-1];function el(M){var P,K=this.abs();if(K.t==1&&K.data[0]<=ht[ht.length-1]){for(P=0;P<ht.length;++P)if(K.data[0]==ht[P])return!0;return!1}if(K.isEven())return!1;for(P=1;P<ht.length;){for(var X=ht[P],se=P+1;se<ht.length&&X<Jo;)X*=ht[se++];for(X=K.modInt(X);P<se;)if(X%ht[P++]==0)return!1}return K.millerRabin(M)}function tl(M){var P=this.subtract(t.ONE),K=P.getLowestSetBit();if(K<=0)return!1;for(var X=P.shiftRight(K),se=rl(),ue,ge=0;ge<M;++ge){do ue=new t(this.bitLength(),se);while(ue.compareTo(t.ONE)<=0||ue.compareTo(P)>=0);var fe=ue.modPow(X,this);if(fe.compareTo(t.ONE)!=0&&fe.compareTo(P)!=0){for(var _e=1;_e++<K&&fe.compareTo(P)!=0;)if(fe=fe.modPowInt(2,this),fe.compareTo(t.ONE)==0)return!1;if(fe.compareTo(P)!=0)return!1}}return!0}function rl(){return{nextBytes:function(M){for(var P=0;P<M.length;++P)M[P]=Math.floor(Math.random()*256)}}}return t.prototype.chunkSize=O,t.prototype.toRadix=Q,t.prototype.fromRadix=re,t.prototype.fromNumber=Z,t.prototype.bitwiseTo=ve,t.prototype.changeBit=Ft,t.prototype.addTo=Fe,t.prototype.dMultiply=Ye,t.prototype.dAddOffset=$e,t.prototype.multiplyLowerTo=Ko,t.prototype.multiplyUpperTo=Ho,t.prototype.modInt=Xo,t.prototype.millerRabin=tl,t.prototype.clone=C,t.prototype.intValue=R,t.prototype.byteValue=W,t.prototype.shortValue=F,t.prototype.signum=z,t.prototype.toByteArray=ne,t.prototype.equals=he,t.prototype.min=oe,t.prototype.max=pe,t.prototype.and=be,t.prototype.or=Te,t.prototype.xor=Ce,t.prototype.andNot=Ue,t.prototype.not=ke,t.prototype.shiftLeft=Je,t.prototype.shiftRight=rt,t.prototype.getLowestSetBit=lt,t.prototype.bitCount=it,t.prototype.testBit=ut,t.prototype.setBit=lr,t.prototype.clearBit=Ve,t.prototype.flipBit=Oe,t.prototype.add=ze,t.prototype.subtract=Ke,t.prototype.multiply=He,t.prototype.divide=We,t.prototype.remainder=je,t.prototype.divideAndRemainder=qe,t.prototype.modPow=$o,t.prototype.modInverse=Qo,t.prototype.pow=zo,t.prototype.gcd=Zo,t.prototype.isProbablePrime=el,t.prototype.square=Ge,Zr}var Xr={exports:{}},Qr={exports:{}},Tn;function Ot(){if(Tn)return Qr.exports;Tn=1;var o=xe();yt(),Ee();var e=Qr.exports=o.sha1=o.sha1||{};o.md.sha1=o.md.algorithms.sha1=e,e.create=function(){r||n();var a=null,i=o.util.createBuffer(),l=new Array(80),c={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return c.start=function(){c.messageLength=0,c.fullMessageLength=c.messageLength64=[];for(var p=c.messageLengthSize/4,b=0;b<p;++b)c.fullMessageLength.push(0);return i=o.util.createBuffer(),a={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},c},c.start(),c.update=function(p,b){b==="utf8"&&(p=o.util.encodeUtf8(p));var x=p.length;c.messageLength+=x,x=[x/4294967296>>>0,x>>>0];for(var h=c.fullMessageLength.length-1;h>=0;--h)c.fullMessageLength[h]+=x[1],x[1]=x[0]+(c.fullMessageLength[h]/4294967296>>>0),c.fullMessageLength[h]=c.fullMessageLength[h]>>>0,x[0]=x[1]/4294967296>>>0;return i.putBytes(p),s(a,l,i),(i.read>2048||i.length()===0)&&i.compact(),c},c.digest=function(){var p=o.util.createBuffer();p.putBytes(i.bytes());var b=c.fullMessageLength[c.fullMessageLength.length-1]+c.messageLengthSize,x=b&c.blockLength-1;p.putBytes(t.substr(0,c.blockLength-x));for(var h,m,d=c.fullMessageLength[0]*8,y=0;y<c.fullMessageLength.length-1;++y)h=c.fullMessageLength[y+1]*8,m=h/4294967296>>>0,d+=m,p.putInt32(d>>>0),d=h>>>0;p.putInt32(d);var u={h0:a.h0,h1:a.h1,h2:a.h2,h3:a.h3,h4:a.h4};s(u,l,p);var v=o.util.createBuffer();return v.putInt32(u.h0),v.putInt32(u.h1),v.putInt32(u.h2),v.putInt32(u.h3),v.putInt32(u.h4),v},c};var t=null,r=!1;function n(){t="",t+=o.util.fillString("\0",64),r=!0}function s(a,i,l){for(var c,p,b,x,h,m,d,y,u=l.length();u>=64;){for(p=a.h0,b=a.h1,x=a.h2,h=a.h3,m=a.h4,y=0;y<16;++y)c=l.getInt32(),i[y]=c,d=h^b&(x^h),c=(p<<5|p>>>27)+d+m+1518500249+c,m=h,h=x,x=(b<<30|b>>>2)>>>0,b=p,p=c;for(;y<20;++y)c=i[y-3]^i[y-8]^i[y-14]^i[y-16],c=c<<1|c>>>31,i[y]=c,d=h^b&(x^h),c=(p<<5|p>>>27)+d+m+1518500249+c,m=h,h=x,x=(b<<30|b>>>2)>>>0,b=p,p=c;for(;y<32;++y)c=i[y-3]^i[y-8]^i[y-14]^i[y-16],c=c<<1|c>>>31,i[y]=c,d=b^x^h,c=(p<<5|p>>>27)+d+m+1859775393+c,m=h,h=x,x=(b<<30|b>>>2)>>>0,b=p,p=c;for(;y<40;++y)c=i[y-6]^i[y-16]^i[y-28]^i[y-32],c=c<<2|c>>>30,i[y]=c,d=b^x^h,c=(p<<5|p>>>27)+d+m+1859775393+c,m=h,h=x,x=(b<<30|b>>>2)>>>0,b=p,p=c;for(;y<60;++y)c=i[y-6]^i[y-16]^i[y-28]^i[y-32],c=c<<2|c>>>30,i[y]=c,d=b&x|h&(b^x),c=(p<<5|p>>>27)+d+m+2400959708+c,m=h,h=x,x=(b<<30|b>>>2)>>>0,b=p,p=c;for(;y<80;++y)c=i[y-6]^i[y-16]^i[y-28]^i[y-32],c=c<<2|c>>>30,i[y]=c,d=b^x^h,c=(p<<5|p>>>27)+d+m+3395469782+c,m=h,h=x,x=(b<<30|b>>>2)>>>0,b=p,p=c;a.h0=a.h0+p|0,a.h1=a.h1+b|0,a.h2=a.h2+x|0,a.h3=a.h3+h|0,a.h4=a.h4+m|0,u-=64}}return Qr.exports}var An;function _n(){if(An)return Xr.exports;An=1;var o=xe();Ee(),ot(),Ot();var e=Xr.exports=o.pkcs1=o.pkcs1||{};e.encode_rsa_oaep=function(r,n,s){var a,i,l,c;typeof s=="string"?(a=s,i=arguments[3]||void 0,l=arguments[4]||void 0):s&&(a=s.label||void 0,i=s.seed||void 0,l=s.md||void 0,s.mgf1&&s.mgf1.md&&(c=s.mgf1.md)),l?l.start():l=o.md.sha1.create(),c||(c=l);var p=Math.ceil(r.n.bitLength()/8),b=p-2*l.digestLength-2;if(n.length>b){var x=new Error("RSAES-OAEP input message length is too long.");throw x.length=n.length,x.maxLength=b,x}a||(a=""),l.update(a,"raw");for(var h=l.digest(),m="",d=b-n.length,y=0;y<d;y++)m+="\0";var u=h.getBytes()+m+""+n;if(!i)i=o.random.getBytes(l.digestLength);else if(i.length!==l.digestLength){var x=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw x.seedLength=i.length,x.digestLength=l.digestLength,x}var v=t(i,p-l.digestLength-1,c),E=o.util.xorBytes(u,v,u.length),T=t(E,l.digestLength,c),_=o.util.xorBytes(i,T,i.length);return"\0"+_+E},e.decode_rsa_oaep=function(r,n,s){var a,i,l;typeof s=="string"?(a=s,i=arguments[3]||void 0):s&&(a=s.label||void 0,i=s.md||void 0,s.mgf1&&s.mgf1.md&&(l=s.mgf1.md));var c=Math.ceil(r.n.bitLength()/8);if(n.length!==c){var E=new Error("RSAES-OAEP encoded message length is invalid.");throw E.length=n.length,E.expectedLength=c,E}if(i===void 0?i=o.md.sha1.create():i.start(),l||(l=i),c<2*i.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");a||(a=""),i.update(a,"raw");for(var p=i.digest().getBytes(),b=n.charAt(0),x=n.substring(1,i.digestLength+1),h=n.substring(1+i.digestLength),m=t(h,i.digestLength,l),d=o.util.xorBytes(x,m,x.length),y=t(d,c-i.digestLength-1,l),u=o.util.xorBytes(h,y,h.length),v=u.substring(0,i.digestLength),E=b!=="\0",T=0;T<i.digestLength;++T)E|=p.charAt(T)!==v.charAt(T);for(var _=1,w=i.digestLength,g=i.digestLength;g<u.length;g++){var f=u.charCodeAt(g),k=f&1^1,L=_?65534:0;E|=f&L,_=_&k,w+=_}if(E||u.charCodeAt(w)!==1)throw new Error("Invalid RSAES-OAEP padding.");return u.substring(w+1)};function t(r,n,s){s||(s=o.md.sha1.create());for(var a="",i=Math.ceil(n/s.digestLength),l=0;l<i;++l){var c=String.fromCharCode(l>>24&255,l>>16&255,l>>8&255,l&255);s.start(),s.update(r+c),a+=s.digest().getBytes()}return a.substring(0,n)}return Xr.exports}var nr={exports:{}},In;function kn(){if(In)return nr.exports;In=1;var o=xe();return Ee(),ir(),ot(),(function(){if(o.prime){nr.exports=o.prime;return}var e=nr.exports=o.prime=o.prime||{},t=o.jsbn.BigInteger,r=[6,4,2,4,2,4,6,2],n=new t(null);n.fromInt(30);var s=function(x,h){return x|h};e.generateProbablePrime=function(x,h,m){typeof h=="function"&&(m=h,h={}),h=h||{};var d=h.algorithm||"PRIMEINC";typeof d=="string"&&(d={name:d}),d.options=d.options||{};var y=h.prng||o.random,u={nextBytes:function(v){for(var E=y.getBytesSync(v.length),T=0;T<v.length;++T)v[T]=E.charCodeAt(T)}};if(d.name==="PRIMEINC")return a(x,u,d.options,m);throw new Error("Invalid prime generation algorithm: "+d.name)};function a(x,h,m,d){return"workers"in m?c(x,h,m,d):i(x,h,m,d)}function i(x,h,m,d){var y=p(x,h),u=0,v=b(y.bitLength());"millerRabinTests"in m&&(v=m.millerRabinTests);var E=10;"maxBlockTime"in m&&(E=m.maxBlockTime),l(y,x,h,u,v,E,d)}function l(x,h,m,d,y,u,v){var E=+new Date;do{if(x.bitLength()>h&&(x=p(h,m)),x.isProbablePrime(y))return v(null,x);x.dAddOffset(r[d++%8],0)}while(u<0||+new Date-E<u);o.util.setImmediate(function(){l(x,h,m,d,y,u,v)})}function c(x,h,m,d){if(typeof Worker>"u")return i(x,h,m,d);var y=p(x,h),u=m.workers,v=m.workLoad||100,E=v*30/8,T=m.workerScript||"forge/prime.worker.js";if(u===-1)return o.util.estimateCores(function(w,g){w&&(g=2),u=g-1,_()});_();function _(){u=Math.max(1,u);for(var w=[],g=0;g<u;++g)w[g]=new Worker(T);for(var g=0;g<u;++g)w[g].addEventListener("message",k);var f=!1;function k(L){if(!f){var H=L.data;if(H.found){for(var I=0;I<w.length;++I)w[I].terminate();return f=!0,d(null,new t(H.prime,16))}y.bitLength()>x&&(y=p(x,h));var V=y.toString(16);L.target.postMessage({hex:V,workLoad:v}),y.dAddOffset(E,0)}}}}function p(x,h){var m=new t(x,h),d=x-1;return m.testBit(d)||m.bitwiseTo(t.ONE.shiftLeft(d),s,m),m.dAddOffset(31-m.mod(n).byteValue(),0),m}function b(x){return x<=100?27:x<=150?18:x<=200?15:x<=250?12:x<=300?9:x<=350?8:x<=400?7:x<=500?6:x<=600?5:x<=800?4:x<=1250?3:2}})(),nr.exports}var Jr,Bn;function sr(){if(Bn)return Jr;Bn=1;var o=xe();if(gt(),ir(),Tt(),_n(),kn(),ot(),Ee(),typeof e>"u")var e=o.jsbn.BigInteger;var t=o.util.isNodejs?Gr:null,r=o.asn1,n=o.util;o.pki=o.pki||{},Jr=o.pki.rsa=o.rsa=o.rsa||{};var s=o.pki,a=[6,4,2,4,2,4,6,2],i={name:"PrivateKeyInfo",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},l={name:"RSAPrivateKey",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},c={name:"RSAPublicKey",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},p=o.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:r.Class.UNIVERSAL,type:r.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},b={name:"DigestInfo",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:r.Class.UNIVERSAL,type:r.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},x=function(g){var f;if(g.algorithm in s.oids)f=s.oids[g.algorithm];else{var k=new Error("Unknown message digest algorithm.");throw k.algorithm=g.algorithm,k}var L=r.oidToDer(f).getBytes(),H=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]),I=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]);I.value.push(r.create(r.Class.UNIVERSAL,r.Type.OID,!1,L)),I.value.push(r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,""));var V=r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,g.digest().getBytes());return H.value.push(I),H.value.push(V),r.toDer(H).getBytes()},h=function(g,f,k){if(k)return g.modPow(f.e,f.n);if(!f.p||!f.q)return g.modPow(f.d,f.n);f.dP||(f.dP=f.d.mod(f.p.subtract(e.ONE))),f.dQ||(f.dQ=f.d.mod(f.q.subtract(e.ONE))),f.qInv||(f.qInv=f.q.modInverse(f.p));var L;do L=new e(o.util.bytesToHex(o.random.getBytes(f.n.bitLength()/8)),16);while(L.compareTo(f.n)>=0||!L.gcd(f.n).equals(e.ONE));g=g.multiply(L.modPow(f.e,f.n)).mod(f.n);for(var H=g.mod(f.p).modPow(f.dP,f.p),I=g.mod(f.q).modPow(f.dQ,f.q);H.compareTo(I)<0;)H=H.add(f.p);var V=H.subtract(I).multiply(f.qInv).mod(f.p).multiply(f.q).add(I);return V=V.multiply(L.modInverse(f.n)).mod(f.n),V};s.rsa.encrypt=function(g,f,k){var L=k,H,I=Math.ceil(f.n.bitLength()/8);k!==!1&&k!==!0?(L=k===2,H=m(g,f,k)):(H=o.util.createBuffer(),H.putBytes(g));for(var V=new e(H.toHex(),16),A=h(V,f,L),G=A.toString(16),Y=o.util.createBuffer(),q=I-Math.ceil(G.length/2);q>0;)Y.putByte(0),--q;return Y.putBytes(o.util.hexToBytes(G)),Y.getBytes()},s.rsa.decrypt=function(g,f,k,L){var H=Math.ceil(f.n.bitLength()/8);if(g.length!==H){var I=new Error("Encrypted message length is invalid.");throw I.length=g.length,I.expected=H,I}var V=new e(o.util.createBuffer(g).toHex(),16);if(V.compareTo(f.n)>=0)throw new Error("Encrypted message is invalid.");for(var A=h(V,f,k),G=A.toString(16),Y=o.util.createBuffer(),q=H-Math.ceil(G.length/2);q>0;)Y.putByte(0),--q;return Y.putBytes(o.util.hexToBytes(G)),L!==!1?d(Y.getBytes(),f,k):Y.getBytes()},s.rsa.createKeyPairGenerationState=function(g,f,k){typeof g=="string"&&(g=parseInt(g,10)),g=g||2048,k=k||{};var L=k.prng||o.random,H={nextBytes:function(A){for(var G=L.getBytesSync(A.length),Y=0;Y<A.length;++Y)A[Y]=G.charCodeAt(Y)}},I=k.algorithm||"PRIMEINC",V;if(I==="PRIMEINC")V={algorithm:I,state:0,bits:g,rng:H,eInt:f||65537,e:new e(null),p:null,q:null,qBits:g>>1,pBits:g-(g>>1),pqState:0,num:null,keys:null},V.e.fromInt(V.eInt);else throw new Error("Invalid key generation algorithm: "+I);return V},s.rsa.stepKeyPairGenerationState=function(g,f){"algorithm"in g||(g.algorithm="PRIMEINC");var k=new e(null);k.fromInt(30);for(var L=0,H=function(ie,ee){return ie|ee},I=+new Date,V,A=0;g.keys===null&&(f<=0||A<f);){if(g.state===0){var G=g.p===null?g.pBits:g.qBits,Y=G-1;g.pqState===0?(g.num=new e(G,g.rng),g.num.testBit(Y)||g.num.bitwiseTo(e.ONE.shiftLeft(Y),H,g.num),g.num.dAddOffset(31-g.num.mod(k).byteValue(),0),L=0,++g.pqState):g.pqState===1?g.num.bitLength()>G?g.pqState=0:g.num.isProbablePrime(v(g.num.bitLength()))?++g.pqState:g.num.dAddOffset(a[L++%8],0):g.pqState===2?g.pqState=g.num.subtract(e.ONE).gcd(g.e).compareTo(e.ONE)===0?3:0:g.pqState===3&&(g.pqState=0,g.p===null?g.p=g.num:g.q=g.num,g.p!==null&&g.q!==null&&++g.state,g.num=null)}else if(g.state===1)g.p.compareTo(g.q)<0&&(g.num=g.p,g.p=g.q,g.q=g.num),++g.state;else if(g.state===2)g.p1=g.p.subtract(e.ONE),g.q1=g.q.subtract(e.ONE),g.phi=g.p1.multiply(g.q1),++g.state;else if(g.state===3)g.phi.gcd(g.e).compareTo(e.ONE)===0?++g.state:(g.p=null,g.q=null,g.state=0);else if(g.state===4)g.n=g.p.multiply(g.q),g.n.bitLength()===g.bits?++g.state:(g.q=null,g.state=0);else if(g.state===5){var q=g.e.modInverse(g.phi);g.keys={privateKey:s.rsa.setPrivateKey(g.n,g.e,q,g.p,g.q,q.mod(g.p1),q.mod(g.q1),g.q.modInverse(g.p)),publicKey:s.rsa.setPublicKey(g.n,g.e)}}V=+new Date,A+=V-I,I=V}return g.keys!==null},s.rsa.generateKeyPair=function(g,f,k,L){if(arguments.length===1?typeof g=="object"?(k=g,g=void 0):typeof g=="function"&&(L=g,g=void 0):arguments.length===2?typeof g=="number"?typeof f=="function"?(L=f,f=void 0):typeof f!="number"&&(k=f,f=void 0):(k=g,L=f,g=void 0,f=void 0):arguments.length===3&&(typeof f=="number"?typeof k=="function"&&(L=k,k=void 0):(L=k,k=f,f=void 0)),k=k||{},g===void 0&&(g=k.bits||2048),f===void 0&&(f=k.e||65537),!o.options.usePureJavaScript&&!k.prng&&g>=256&&g<=16384&&(f===65537||f===3)){if(L){if(E("generateKeyPair"))return t.generateKeyPair("rsa",{modulusLength:g,publicExponent:f,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(A,G,Y){if(A)return L(A);L(null,{privateKey:s.privateKeyFromPem(Y),publicKey:s.publicKeyFromPem(G)})});if(T("generateKey")&&T("exportKey"))return n.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:g,publicExponent:w(f),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(A){return n.globalScope.crypto.subtle.exportKey("pkcs8",A.privateKey)}).then(void 0,function(A){L(A)}).then(function(A){if(A){var G=s.privateKeyFromAsn1(r.fromDer(o.util.createBuffer(A)));L(null,{privateKey:G,publicKey:s.setRsaPublicKey(G.n,G.e)})}});if(_("generateKey")&&_("exportKey")){var H=n.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:g,publicExponent:w(f),hash:{name:"SHA-256"}},!0,["sign","verify"]);H.oncomplete=function(A){var G=A.target.result,Y=n.globalScope.msCrypto.subtle.exportKey("pkcs8",G.privateKey);Y.oncomplete=function(q){var ie=q.target.result,ee=s.privateKeyFromAsn1(r.fromDer(o.util.createBuffer(ie)));L(null,{privateKey:ee,publicKey:s.setRsaPublicKey(ee.n,ee.e)})},Y.onerror=function(q){L(q)}},H.onerror=function(A){L(A)};return}}else if(E("generateKeyPairSync")){var I=t.generateKeyPairSync("rsa",{modulusLength:g,publicExponent:f,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:s.privateKeyFromPem(I.privateKey),publicKey:s.publicKeyFromPem(I.publicKey)}}}var V=s.rsa.createKeyPairGenerationState(g,f,k);if(!L)return s.rsa.stepKeyPairGenerationState(V,0),V.keys;y(V,k,L)},s.setRsaPublicKey=s.rsa.setPublicKey=function(g,f){var k={n:g,e:f};return k.encrypt=function(L,H,I){if(typeof H=="string"?H=H.toUpperCase():H===void 0&&(H="RSAES-PKCS1-V1_5"),H==="RSAES-PKCS1-V1_5")H={encode:function(A,G,Y){return m(A,G,2).getBytes()}};else if(H==="RSA-OAEP"||H==="RSAES-OAEP")H={encode:function(A,G){return o.pkcs1.encode_rsa_oaep(G,A,I)}};else if(["RAW","NONE","NULL",null].indexOf(H)!==-1)H={encode:function(A){return A}};else if(typeof H=="string")throw new Error('Unsupported encryption scheme: "'+H+'".');var V=H.encode(L,k,!0);return s.rsa.encrypt(V,k,!0)},k.verify=function(L,H,I,V){typeof I=="string"?I=I.toUpperCase():I===void 0&&(I="RSASSA-PKCS1-V1_5"),V===void 0&&(V={_parseAllDigestBytes:!0,_skipPaddingChecks:!1}),"_parseAllDigestBytes"in V||(V._parseAllDigestBytes=!0),"_skipPaddingChecks"in V||(V._skipPaddingChecks=!1),I==="RSASSA-PKCS1-V1_5"?I={verify:function(G,Y){Y=d(Y,k,!0,void 0,V);var q=r.fromDer(Y,{parseAllBytes:V._parseAllDigestBytes}),ie={},ee=[];if(!r.validate(q,b,ie,ee)||q.value.length!==2){var le=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw le.errors=ee,le}var $=r.derToOid(ie.algorithmIdentifier);if(!($===o.oids.md2||$===o.oids.md5||$===o.oids.sha1||$===o.oids.sha224||$===o.oids.sha256||$===o.oids.sha384||$===o.oids.sha512||$===o.oids["sha512-224"]||$===o.oids["sha512-256"])){var le=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw le.oid=$,le}if(($===o.oids.md2||$===o.oids.md5)&&!("parameters"in ie))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters.");return G===ie.digest}}:(I==="NONE"||I==="NULL"||I===null)&&(I={verify:function(G,Y){return Y=d(Y,k,!0,void 0,V),G===Y}});var A=s.rsa.decrypt(H,k,!0,!1);return I.verify(L,A,k.n.bitLength())},k},s.setRsaPrivateKey=s.rsa.setPrivateKey=function(g,f,k,L,H,I,V,A){var G={n:g,e:f,d:k,p:L,q:H,dP:I,dQ:V,qInv:A};return G.decrypt=function(Y,q,ie){typeof q=="string"?q=q.toUpperCase():q===void 0&&(q="RSAES-PKCS1-V1_5");var ee=s.rsa.decrypt(Y,G,!1,!1);if(q==="RSAES-PKCS1-V1_5")q={decode:d};else if(q==="RSA-OAEP"||q==="RSAES-OAEP")q={decode:function(le,$){return o.pkcs1.decode_rsa_oaep($,le,ie)}};else if(["RAW","NONE","NULL",null].indexOf(q)!==-1)q={decode:function(le){return le}};else throw new Error('Unsupported encryption scheme: "'+q+'".');return q.decode(ee,G,!1)},G.sign=function(Y,q){var ie=!1;typeof q=="string"&&(q=q.toUpperCase()),q===void 0||q==="RSASSA-PKCS1-V1_5"?(q={encode:x},ie=1):(q==="NONE"||q==="NULL"||q===null)&&(q={encode:function(){return Y}},ie=1);var ee=q.encode(Y,G.n.bitLength());return s.rsa.encrypt(ee,G,ie)},G},s.wrapRsaPrivateKey=function(g){return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(0).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(s.oids.rsaEncryption).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,"")]),r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,r.toDer(g).getBytes())])},s.privateKeyFromAsn1=function(g){var f={},k=[];if(r.validate(g,i,f,k)&&(g=r.fromDer(o.util.createBuffer(f.privateKey))),f={},k=[],!r.validate(g,l,f,k)){var L=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw L.errors=k,L}var H,I,V,A,G,Y,q,ie;return H=o.util.createBuffer(f.privateKeyModulus).toHex(),I=o.util.createBuffer(f.privateKeyPublicExponent).toHex(),V=o.util.createBuffer(f.privateKeyPrivateExponent).toHex(),A=o.util.createBuffer(f.privateKeyPrime1).toHex(),G=o.util.createBuffer(f.privateKeyPrime2).toHex(),Y=o.util.createBuffer(f.privateKeyExponent1).toHex(),q=o.util.createBuffer(f.privateKeyExponent2).toHex(),ie=o.util.createBuffer(f.privateKeyCoefficient).toHex(),s.setRsaPrivateKey(new e(H,16),new e(I,16),new e(V,16),new e(A,16),new e(G,16),new e(Y,16),new e(q,16),new e(ie,16))},s.privateKeyToAsn1=s.privateKeyToRSAPrivateKey=function(g){return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(0).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,u(g.n)),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,u(g.e)),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,u(g.d)),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,u(g.p)),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,u(g.q)),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,u(g.dP)),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,u(g.dQ)),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,u(g.qInv))])},s.publicKeyFromAsn1=function(g){var f={},k=[];if(r.validate(g,p,f,k)){var L=r.derToOid(f.publicKeyOid);if(L!==s.oids.rsaEncryption){var H=new Error("Cannot read public key. Unknown OID.");throw H.oid=L,H}g=f.rsaPublicKey}if(k=[],!r.validate(g,c,f,k)){var H=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw H.errors=k,H}var I=o.util.createBuffer(f.publicKeyModulus).toHex(),V=o.util.createBuffer(f.publicKeyExponent).toHex();return s.setRsaPublicKey(new e(I,16),new e(V,16))},s.publicKeyToAsn1=s.publicKeyToSubjectPublicKeyInfo=function(g){return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(s.oids.rsaEncryption).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,"")]),r.create(r.Class.UNIVERSAL,r.Type.BITSTRING,!1,[s.publicKeyToRSAPublicKey(g)])])},s.publicKeyToRSAPublicKey=function(g){return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,u(g.n)),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,u(g.e))])};function m(g,f,k){var L=o.util.createBuffer(),H=Math.ceil(f.n.bitLength()/8);if(g.length>H-11){var I=new Error("Message is too long for PKCS#1 v1.5 padding.");throw I.length=g.length,I.max=H-11,I}L.putByte(0),L.putByte(k);var V=H-3-g.length,A;if(k===0||k===1){A=k===0?0:255;for(var G=0;G<V;++G)L.putByte(A)}else for(;V>0;){for(var Y=0,q=o.random.getBytes(V),G=0;G<V;++G)A=q.charCodeAt(G),A===0?++Y:L.putByte(A);V=Y}return L.putByte(0),L.putBytes(g),L}function d(g,f,k,L,H){var I=Math.ceil(f.n.bitLength()/8),V=o.util.createBuffer(g),A=V.getByte(),G=V.getByte();if(A!==0||k&&G!==0&&G!==1||!k&&G!==2||k&&G===0&&typeof L>"u")throw new Error("Encryption block is invalid.");var Y=0;if(G===0){Y=I-3-L;for(var q=0;q<Y;++q)if(V.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(G===1){for(Y=0;V.length()>1;){if(V.getByte()!==255){--V.read;break}++Y}if(Y<8&&!(H&&H._skipPaddingChecks))throw new Error("Encryption block is invalid.")}else if(G===2){for(Y=0;V.length()>1;){if(V.getByte()===0){--V.read;break}++Y}if(Y<8&&!(H&&H._skipPaddingChecks))throw new Error("Encryption block is invalid.")}var ie=V.getByte();if(ie!==0||Y!==I-3-V.length())throw new Error("Encryption block is invalid.");return V.getBytes()}function y(g,f,k){typeof f=="function"&&(k=f,f={}),f=f||{};var L={algorithm:{name:f.algorithm||"PRIMEINC",options:{workers:f.workers||2,workLoad:f.workLoad||100,workerScript:f.workerScript}}};"prng"in f&&(L.prng=f.prng),H();function H(){I(g.pBits,function(A,G){if(A)return k(A);if(g.p=G,g.q!==null)return V(A,g.q);I(g.qBits,V)})}function I(A,G){o.prime.generateProbablePrime(A,L,G)}function V(A,G){if(A)return k(A);if(g.q=G,g.p.compareTo(g.q)<0){var Y=g.p;g.p=g.q,g.q=Y}if(g.p.subtract(e.ONE).gcd(g.e).compareTo(e.ONE)!==0){g.p=null,H();return}if(g.q.subtract(e.ONE).gcd(g.e).compareTo(e.ONE)!==0){g.q=null,I(g.qBits,V);return}if(g.p1=g.p.subtract(e.ONE),g.q1=g.q.subtract(e.ONE),g.phi=g.p1.multiply(g.q1),g.phi.gcd(g.e).compareTo(e.ONE)!==0){g.p=g.q=null,H();return}if(g.n=g.p.multiply(g.q),g.n.bitLength()!==g.bits){g.q=null,I(g.qBits,V);return}var q=g.e.modInverse(g.phi);g.keys={privateKey:s.rsa.setPrivateKey(g.n,g.e,q,g.p,g.q,q.mod(g.p1),q.mod(g.q1),g.q.modInverse(g.p)),publicKey:s.rsa.setPublicKey(g.n,g.e)},k(null,g.keys)}}function u(g){var f=g.toString(16);f[0]>="8"&&(f="00"+f);var k=o.util.hexToBytes(f);return k.length>1&&(k.charCodeAt(0)===0&&(k.charCodeAt(1)&128)===0||k.charCodeAt(0)===255&&(k.charCodeAt(1)&128)===128)?k.substr(1):k}function v(g){return g<=100?27:g<=150?18:g<=200?15:g<=250?12:g<=300?9:g<=350?8:g<=400?7:g<=500?6:g<=600?5:g<=800?4:g<=1250?3:2}function E(g){return o.util.isNodejs&&typeof t[g]=="function"}function T(g){return typeof n.globalScope<"u"&&typeof n.globalScope.crypto=="object"&&typeof n.globalScope.crypto.subtle=="object"&&typeof n.globalScope.crypto.subtle[g]=="function"}function _(g){return typeof n.globalScope<"u"&&typeof n.globalScope.msCrypto=="object"&&typeof n.globalScope.msCrypto.subtle=="object"&&typeof n.globalScope.msCrypto.subtle[g]=="function"}function w(g){for(var f=o.util.hexToBytes(g.toString(16)),k=new Uint8Array(f.length),L=0;L<f.length;++L)k[L]=f.charCodeAt(L);return k}return Jr}var ei,Mn;function Ln(){if(Mn)return ei;Mn=1;var o=xe();if(St(),gt(),tr(),yt(),Tt(),jr(),_t(),ot(),wn(),sr(),Ee(),typeof e>"u")var e=o.jsbn.BigInteger;var t=o.asn1,r=o.pki=o.pki||{};ei=r.pbe=o.pbe=o.pbe||{};var n=r.oids,s={name:"EncryptedPrivateKeyInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},a={name:"PBES2Algorithms",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},i={name:"pkcs-12PbeParams",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"iterations"}]};r.encryptPrivateKeyInfo=function(x,h,m){m=m||{},m.saltSize=m.saltSize||8,m.count=m.count||2048,m.algorithm=m.algorithm||"aes128",m.prfAlgorithm=m.prfAlgorithm||"sha1";var d=o.random.getBytesSync(m.saltSize),y=m.count,u=t.integerToDer(y),v,E,T;if(m.algorithm.indexOf("aes")===0||m.algorithm==="des"){var _,w,g;switch(m.algorithm){case"aes128":v=16,_=16,w=n["aes128-CBC"],g=o.aes.createEncryptionCipher;break;case"aes192":v=24,_=16,w=n["aes192-CBC"],g=o.aes.createEncryptionCipher;break;case"aes256":v=32,_=16,w=n["aes256-CBC"],g=o.aes.createEncryptionCipher;break;case"des":v=8,_=8,w=n.desCBC,g=o.des.createEncryptionCipher;break;default:var f=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw f.algorithm=m.algorithm,f}var k="hmacWith"+m.prfAlgorithm.toUpperCase(),L=p(k),H=o.pkcs5.pbkdf2(h,d,y,v,L),I=o.random.getBytesSync(_),V=g(H);V.start(I),V.update(t.toDer(x)),V.finish(),T=V.output.getBytes();var A=b(d,u,v,k);E=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n.pkcs5PBES2).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n.pkcs5PBKDF2).getBytes()),A]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(w).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,I)])])])}else if(m.algorithm==="3des"){v=24;var G=new o.util.ByteBuffer(d),H=r.pbe.generatePkcs12Key(h,G,1,y,v),I=r.pbe.generatePkcs12Key(h,G,2,y,v),V=o.des.createEncryptionCipher(H);V.start(I),V.update(t.toDer(x)),V.finish(),T=V.output.getBytes(),E=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,d),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,u.getBytes())])])}else{var f=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw f.algorithm=m.algorithm,f}var Y=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[E,t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,T)]);return Y},r.decryptPrivateKeyInfo=function(x,h){var m=null,d={},y=[];if(!t.validate(x,s,d,y)){var u=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw u.errors=y,u}var v=t.derToOid(d.encryptionOid),E=r.pbe.getCipher(v,d.encryptionParams,h),T=o.util.createBuffer(d.encryptedData);return E.update(T),E.finish()&&(m=t.fromDer(E.output)),m},r.encryptedPrivateKeyToPem=function(x,h){var m={type:"ENCRYPTED PRIVATE KEY",body:t.toDer(x).getBytes()};return o.pem.encode(m,{maxline:h})},r.encryptedPrivateKeyFromPem=function(x){var h=o.pem.decode(x)[0];if(h.type!=="ENCRYPTED PRIVATE KEY"){var m=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw m.headerType=h.type,m}if(h.procType&&h.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return t.fromDer(h.body)},r.encryptRsaPrivateKey=function(x,h,m){if(m=m||{},!m.legacy){var d=r.wrapRsaPrivateKey(r.privateKeyToAsn1(x));return d=r.encryptPrivateKeyInfo(d,h,m),r.encryptedPrivateKeyToPem(d)}var y,u,v,E;switch(m.algorithm){case"aes128":y="AES-128-CBC",v=16,u=o.random.getBytesSync(16),E=o.aes.createEncryptionCipher;break;case"aes192":y="AES-192-CBC",v=24,u=o.random.getBytesSync(16),E=o.aes.createEncryptionCipher;break;case"aes256":y="AES-256-CBC",v=32,u=o.random.getBytesSync(16),E=o.aes.createEncryptionCipher;break;case"3des":y="DES-EDE3-CBC",v=24,u=o.random.getBytesSync(8),E=o.des.createEncryptionCipher;break;case"des":y="DES-CBC",v=8,u=o.random.getBytesSync(8),E=o.des.createEncryptionCipher;break;default:var T=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+m.algorithm+'".');throw T.algorithm=m.algorithm,T}var _=o.pbe.opensslDeriveBytes(h,u.substr(0,8),v),w=E(_);w.start(u),w.update(t.toDer(r.privateKeyToAsn1(x))),w.finish();var g={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:y,parameters:o.util.bytesToHex(u).toUpperCase()},body:w.output.getBytes()};return o.pem.encode(g)},r.decryptRsaPrivateKey=function(x,h){var m=null,d=o.pem.decode(x)[0];if(d.type!=="ENCRYPTED PRIVATE KEY"&&d.type!=="PRIVATE KEY"&&d.type!=="RSA PRIVATE KEY"){var y=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw y.headerType=y,y}if(d.procType&&d.procType.type==="ENCRYPTED"){var u,v;switch(d.dekInfo.algorithm){case"DES-CBC":u=8,v=o.des.createDecryptionCipher;break;case"DES-EDE3-CBC":u=24,v=o.des.createDecryptionCipher;break;case"AES-128-CBC":u=16,v=o.aes.createDecryptionCipher;break;case"AES-192-CBC":u=24,v=o.aes.createDecryptionCipher;break;case"AES-256-CBC":u=32,v=o.aes.createDecryptionCipher;break;case"RC2-40-CBC":u=5,v=function(g){return o.rc2.createDecryptionCipher(g,40)};break;case"RC2-64-CBC":u=8,v=function(g){return o.rc2.createDecryptionCipher(g,64)};break;case"RC2-128-CBC":u=16,v=function(g){return o.rc2.createDecryptionCipher(g,128)};break;default:var y=new Error('Could not decrypt private key; unsupported encryption algorithm "'+d.dekInfo.algorithm+'".');throw y.algorithm=d.dekInfo.algorithm,y}var E=o.util.hexToBytes(d.dekInfo.parameters),T=o.pbe.opensslDeriveBytes(h,E.substr(0,8),u),_=v(T);if(_.start(E),_.update(o.util.createBuffer(d.body)),_.finish())m=_.output.getBytes();else return m}else m=d.body;return d.type==="ENCRYPTED PRIVATE KEY"?m=r.decryptPrivateKeyInfo(t.fromDer(m),h):m=t.fromDer(m),m!==null&&(m=r.privateKeyFromAsn1(m)),m},r.pbe.generatePkcs12Key=function(x,h,m,d,y,u){var v,E;if(typeof u>"u"||u===null){if(!("sha1"in o.md))throw new Error('"sha1" hash algorithm unavailable.');u=o.md.sha1.create()}var T=u.digestLength,_=u.blockLength,w=new o.util.ByteBuffer,g=new o.util.ByteBuffer;if(x!=null){for(E=0;E<x.length;E++)g.putInt16(x.charCodeAt(E));g.putInt16(0)}var f=g.length(),k=h.length(),L=new o.util.ByteBuffer;L.fillWithByte(m,_);var H=_*Math.ceil(k/_),I=new o.util.ByteBuffer;for(E=0;E<H;E++)I.putByte(h.at(E%k));var V=_*Math.ceil(f/_),A=new o.util.ByteBuffer;for(E=0;E<V;E++)A.putByte(g.at(E%f));var G=I;G.putBuffer(A);for(var Y=Math.ceil(y/T),q=1;q<=Y;q++){var ie=new o.util.ByteBuffer;ie.putBytes(L.bytes()),ie.putBytes(G.bytes());for(var ee=0;ee<d;ee++)u.start(),u.update(ie.getBytes()),ie=u.digest();var le=new o.util.ByteBuffer;for(E=0;E<_;E++)le.putByte(ie.at(E%T));var $=Math.ceil(k/_)+Math.ceil(f/_),J=new o.util.ByteBuffer;for(v=0;v<$;v++){var de=new o.util.ByteBuffer(G.getBytes(_)),ae=511;for(E=le.length()-1;E>=0;E--)ae=ae>>8,ae+=le.at(E)+de.at(E),de.setAt(E,ae&255);J.putBuffer(de)}G=J,w.putBuffer(ie)}return w.truncate(w.length()-y),w},r.pbe.getCipher=function(x,h,m){switch(x){case r.oids.pkcs5PBES2:return r.pbe.getCipherForPBES2(x,h,m);case r.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case r.oids["pbewithSHAAnd40BitRC2-CBC"]:return r.pbe.getCipherForPKCS12PBE(x,h,m);default:var d=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw d.oid=x,d.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],d}},r.pbe.getCipherForPBES2=function(x,h,m){var d={},y=[];if(!t.validate(h,a,d,y)){var u=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw u.errors=y,u}if(x=t.derToOid(d.kdfOid),x!==r.oids.pkcs5PBKDF2){var u=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw u.oid=x,u.supportedOids=["pkcs5PBKDF2"],u}if(x=t.derToOid(d.encOid),x!==r.oids["aes128-CBC"]&&x!==r.oids["aes192-CBC"]&&x!==r.oids["aes256-CBC"]&&x!==r.oids["des-EDE3-CBC"]&&x!==r.oids.desCBC){var u=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw u.oid=x,u.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],u}var v=d.kdfSalt,E=o.util.createBuffer(d.kdfIterationCount);E=E.getInt(E.length()<<3);var T,_;switch(r.oids[x]){case"aes128-CBC":T=16,_=o.aes.createDecryptionCipher;break;case"aes192-CBC":T=24,_=o.aes.createDecryptionCipher;break;case"aes256-CBC":T=32,_=o.aes.createDecryptionCipher;break;case"des-EDE3-CBC":T=24,_=o.des.createDecryptionCipher;break;case"desCBC":T=8,_=o.des.createDecryptionCipher;break}var w=c(d.prfOid),g=o.pkcs5.pbkdf2(m,v,E,T,w),f=d.encIv,k=_(g);return k.start(f),k},r.pbe.getCipherForPKCS12PBE=function(x,h,m){var d={},y=[];if(!t.validate(h,i,d,y)){var u=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw u.errors=y,u}var v=o.util.createBuffer(d.salt),E=o.util.createBuffer(d.iterations);E=E.getInt(E.length()<<3);var T,_,w;switch(x){case r.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:T=24,_=8,w=o.des.startDecrypting;break;case r.oids["pbewithSHAAnd40BitRC2-CBC"]:T=5,_=8,w=function(H,I){var V=o.rc2.createDecryptionCipher(H,40);return V.start(I,null),V};break;default:var u=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw u.oid=x,u}var g=c(d.prfOid),f=r.pbe.generatePkcs12Key(m,v,1,E,T,g);g.start();var k=r.pbe.generatePkcs12Key(m,v,2,E,_,g);return w(f,k)},r.pbe.opensslDeriveBytes=function(x,h,m,d){if(typeof d>"u"||d===null){if(!("md5"in o.md))throw new Error('"md5" hash algorithm unavailable.');d=o.md.md5.create()}h===null&&(h="");for(var y=[l(d,x+h)],u=16,v=1;u<m;++v,u+=16)y.push(l(d,y[v-1]+x+h));return y.join("").substr(0,m)};function l(x,h){return x.start().update(h).digest().getBytes()}function c(x){var h;if(!x)h="hmacWithSHA1";else if(h=r.oids[t.derToOid(x)],!h){var m=new Error("Unsupported PRF OID.");throw m.oid=x,m.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],m}return p(h)}function p(x){var h=o.md;switch(x){case"hmacWithSHA224":h=o.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":x=x.substr(8).toLowerCase();break;default:var m=new Error("Unsupported PRF algorithm.");throw m.algorithm=x,m.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],m}if(!h||!(x in h))throw new Error("Unknown hash algorithm: "+x);return h[x].create()}function b(x,h,m,d){var y=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,x),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,h.getBytes())]);return d!=="hmacWithSHA1"&&y.value.push(t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,o.util.hexToBytes(m.toString(16))),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids[d]).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])),y}return ei}var ti={exports:{}},ri={exports:{}},Rn;function Nn(){if(Rn)return ri.exports;Rn=1;var o=xe();gt(),Ee();var e=o.asn1,t=ri.exports=o.pkcs7asn1=o.pkcs7asn1||{};o.pkcs7=o.pkcs7||{},o.pkcs7.asn1=t;var r={name:"ContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};t.contentInfoValidator=r;var n={name:"EncryptedContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};t.envelopedDataValidator={name:"EnvelopedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(n)},t.encryptedDataValidator={name:"EncryptedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"}].concat(n)};var s={name:"SignerInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};return t.signedDataValidator={name:"SignedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},r,{name:"SignedData.Certificates",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,capture:"signerInfos",optional:!0,value:[s]}]},t.recipientInfoValidator={name:"RecipientInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]},ri.exports}var ii={exports:{}},ni={exports:{}},Pn;function Dn(){if(Pn)return ni.exports;Pn=1;var o=xe();Ee(),o.mgf=o.mgf||{};var e=ni.exports=o.mgf.mgf1=o.mgf1=o.mgf1||{};return e.create=function(t){var r={generate:function(n,s){for(var a=new o.util.ByteBuffer,i=Math.ceil(s/t.digestLength),l=0;l<i;l++){var c=new o.util.ByteBuffer;c.putInt32(l),t.start(),t.update(n+c.getBytes()),a.putBuffer(t.digest())}return a.truncate(a.length()-s),a.getBytes()}};return r},ni.exports}var si,Un;function yo(){if(Un)return si;Un=1;var o=xe();return Dn(),si=o.mgf=o.mgf||{},o.mgf.mgf1=o.mgf1,si}var ai={exports:{}},Vn;function oi(){if(Vn)return ai.exports;Vn=1;var o=xe();ot(),Ee();var e=ai.exports=o.pss=o.pss||{};return e.create=function(t){arguments.length===3&&(t={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var r=t.md,n=t.mgf,s=r.digestLength,a=t.salt||null;typeof a=="string"&&(a=o.util.createBuffer(a));var i;if("saltLength"in t)i=t.saltLength;else if(a!==null)i=a.length();else throw new Error("Salt length not specified or specific salt not given.");if(a!==null&&a.length()!==i)throw new Error("Given salt length does not match length of given salt.");var l=t.prng||o.random,c={};return c.encode=function(p,b){var x,h=b-1,m=Math.ceil(h/8),d=p.digest().getBytes();if(m<s+i+2)throw new Error("Message is too long to encrypt.");var y;a===null?y=l.getBytesSync(i):y=a.bytes();var u=new o.util.ByteBuffer;u.fillWithByte(0,8),u.putBytes(d),u.putBytes(y),r.start(),r.update(u.getBytes());var v=r.digest().getBytes(),E=new o.util.ByteBuffer;E.fillWithByte(0,m-i-s-2),E.putByte(1),E.putBytes(y);var T=E.getBytes(),_=m-s-1,w=n.generate(v,_),g="";for(x=0;x<_;x++)g+=String.fromCharCode(T.charCodeAt(x)^w.charCodeAt(x));var f=65280>>8*m-h&255;return g=String.fromCharCode(g.charCodeAt(0)&~f)+g.substr(1),g+v+"¼"},c.verify=function(p,b,x){var h,m=x-1,d=Math.ceil(m/8);if(b=b.substr(-d),d<s+i+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(b.charCodeAt(d-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var y=d-s-1,u=b.substr(0,y),v=b.substr(y,s),E=65280>>8*d-m&255;if((u.charCodeAt(0)&E)!==0)throw new Error("Bits beyond keysize not zero as expected.");var T=n.generate(v,y),_="";for(h=0;h<y;h++)_+=String.fromCharCode(u.charCodeAt(h)^T.charCodeAt(h));_=String.fromCharCode(_.charCodeAt(0)&~E)+_.substr(1);var w=d-s-i-2;for(h=0;h<w;h++)if(_.charCodeAt(h)!==0)throw new Error("Leftmost octets not zero as expected");if(_.charCodeAt(w)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var g=_.substr(-i),f=new o.util.ByteBuffer;f.fillWithByte(0,8),f.putBytes(p),f.putBytes(g),r.start(),r.update(f.getBytes());var k=r.digest().getBytes();return v===k},c},ai.exports}var On;function li(){if(On)return ii.exports;On=1;var o=xe();St(),gt(),tr(),yt(),yo(),Tt(),_t(),oi(),sr(),Ee();var e=o.asn1,t=ii.exports=o.pki=o.pki||{},r=t.oids,n={};n.CN=r.commonName,n.commonName="CN",n.C=r.countryName,n.countryName="C",n.L=r.localityName,n.localityName="L",n.ST=r.stateOrProvinceName,n.stateOrProvinceName="ST",n.O=r.organizationName,n.organizationName="O",n.OU=r.organizationalUnitName,n.organizationalUnitName="OU",n.E=r.emailAddress,n.emailAddress="E";var s=o.pki.rsa.publicKeyValidator,a={name:"Certificate",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:e.Class.UNIVERSAL,type:e.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:e.Class.UNIVERSAL,type:e.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:e.Class.UNIVERSAL,type:e.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:e.Class.UNIVERSAL,type:e.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},s,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:e.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:e.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},i={name:"rsapss",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:e.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:e.Class.UNIVERSAL,type:e.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:e.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:e.Class.UNIVERSAL,type:e.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},l={name:"CertificationRequestInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},s,{name:"CertificationRequestInfo.attributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0}]}]}]},c={name:"CertificationRequest",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[l,{name:"CertificationRequest.signatureAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};t.RDNAttributesAsArray=function(w,g){for(var f=[],k,L,H,I=0;I<w.value.length;++I){k=w.value[I];for(var V=0;V<k.value.length;++V)H={},L=k.value[V],H.type=e.derToOid(L.value[0].value),H.value=L.value[1].value,H.valueTagClass=L.value[1].type,H.type in r&&(H.name=r[H.type],H.name in n&&(H.shortName=n[H.name])),g&&(g.update(H.type),g.update(H.value)),f.push(H)}return f},t.CRIAttributesAsArray=function(w){for(var g=[],f=0;f<w.length;++f)for(var k=w[f],L=e.derToOid(k.value[0].value),H=k.value[1].value,I=0;I<H.length;++I){var V={};if(V.type=L,V.value=H[I].value,V.valueTagClass=H[I].type,V.type in r&&(V.name=r[V.type],V.name in n&&(V.shortName=n[V.name])),V.type===r.extensionRequest){V.extensions=[];for(var A=0;A<V.value.length;++A)V.extensions.push(t.certificateExtensionFromAsn1(V.value[A]))}g.push(V)}return g};function p(w,g){typeof g=="string"&&(g={shortName:g});for(var f=null,k,L=0;f===null&&L<w.attributes.length;++L)k=w.attributes[L],(g.type&&g.type===k.type||g.name&&g.name===k.name||g.shortName&&g.shortName===k.shortName)&&(f=k);return f}var b=function(w,g,f){var k={};if(w!==r["RSASSA-PSS"])return k;f&&(k={hash:{algorithmOid:r.sha1},mgf:{algorithmOid:r.mgf1,hash:{algorithmOid:r.sha1}},saltLength:20});var L={},H=[];if(!e.validate(g,i,L,H)){var I=new Error("Cannot read RSASSA-PSS parameter block.");throw I.errors=H,I}return L.hashOid!==void 0&&(k.hash=k.hash||{},k.hash.algorithmOid=e.derToOid(L.hashOid)),L.maskGenOid!==void 0&&(k.mgf=k.mgf||{},k.mgf.algorithmOid=e.derToOid(L.maskGenOid),k.mgf.hash=k.mgf.hash||{},k.mgf.hash.algorithmOid=e.derToOid(L.maskGenHashOid)),L.saltLength!==void 0&&(k.saltLength=L.saltLength.charCodeAt(0)),k},x=function(w){switch(r[w.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return o.md.sha1.create();case"md5WithRSAEncryption":return o.md.md5.create();case"sha256WithRSAEncryption":return o.md.sha256.create();case"sha384WithRSAEncryption":return o.md.sha384.create();case"sha512WithRSAEncryption":return o.md.sha512.create();case"RSASSA-PSS":return o.md.sha256.create();default:var g=new Error("Could not compute "+w.type+" digest. Unknown signature OID.");throw g.signatureOid=w.signatureOid,g}},h=function(w){var g=w.certificate,f;switch(g.signatureOid){case r.sha1WithRSAEncryption:case r.sha1WithRSASignature:break;case r["RSASSA-PSS"]:var k,L;if(k=r[g.signatureParameters.mgf.hash.algorithmOid],k===void 0||o.md[k]===void 0){var H=new Error("Unsupported MGF hash function.");throw H.oid=g.signatureParameters.mgf.hash.algorithmOid,H.name=k,H}if(L=r[g.signatureParameters.mgf.algorithmOid],L===void 0||o.mgf[L]===void 0){var H=new Error("Unsupported MGF function.");throw H.oid=g.signatureParameters.mgf.algorithmOid,H.name=L,H}if(L=o.mgf[L].create(o.md[k].create()),k=r[g.signatureParameters.hash.algorithmOid],k===void 0||o.md[k]===void 0){var H=new Error("Unsupported RSASSA-PSS hash function.");throw H.oid=g.signatureParameters.hash.algorithmOid,H.name=k,H}f=o.pss.create(o.md[k].create(),L,g.signatureParameters.saltLength);break}return g.publicKey.verify(w.md.digest().getBytes(),w.signature,f)};t.certificateFromPem=function(w,g,f){var k=o.pem.decode(w)[0];if(k.type!=="CERTIFICATE"&&k.type!=="X509 CERTIFICATE"&&k.type!=="TRUSTED CERTIFICATE"){var L=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw L.headerType=k.type,L}if(k.procType&&k.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var H=e.fromDer(k.body,f);return t.certificateFromAsn1(H,g)},t.certificateToPem=function(w,g){var f={type:"CERTIFICATE",body:e.toDer(t.certificateToAsn1(w)).getBytes()};return o.pem.encode(f,{maxline:g})},t.publicKeyFromPem=function(w){var g=o.pem.decode(w)[0];if(g.type!=="PUBLIC KEY"&&g.type!=="RSA PUBLIC KEY"){var f=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw f.headerType=g.type,f}if(g.procType&&g.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var k=e.fromDer(g.body);return t.publicKeyFromAsn1(k)},t.publicKeyToPem=function(w,g){var f={type:"PUBLIC KEY",body:e.toDer(t.publicKeyToAsn1(w)).getBytes()};return o.pem.encode(f,{maxline:g})},t.publicKeyToRSAPublicKeyPem=function(w,g){var f={type:"RSA PUBLIC KEY",body:e.toDer(t.publicKeyToRSAPublicKey(w)).getBytes()};return o.pem.encode(f,{maxline:g})},t.getPublicKeyFingerprint=function(w,g){g=g||{};var f=g.md||o.md.sha1.create(),k=g.type||"RSAPublicKey",L;switch(k){case"RSAPublicKey":L=e.toDer(t.publicKeyToRSAPublicKey(w)).getBytes();break;case"SubjectPublicKeyInfo":L=e.toDer(t.publicKeyToAsn1(w)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+g.type+'".')}f.start(),f.update(L);var H=f.digest();if(g.encoding==="hex"){var I=H.toHex();return g.delimiter?I.match(/.{2}/g).join(g.delimiter):I}else{if(g.encoding==="binary")return H.getBytes();if(g.encoding)throw new Error('Unknown encoding "'+g.encoding+'".')}return H},t.certificationRequestFromPem=function(w,g,f){var k=o.pem.decode(w)[0];if(k.type!=="CERTIFICATE REQUEST"){var L=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw L.headerType=k.type,L}if(k.procType&&k.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var H=e.fromDer(k.body,f);return t.certificationRequestFromAsn1(H,g)},t.certificationRequestToPem=function(w,g){var f={type:"CERTIFICATE REQUEST",body:e.toDer(t.certificationRequestToAsn1(w)).getBytes()};return o.pem.encode(f,{maxline:g})},t.createCertificate=function(){var w={};return w.version=2,w.serialNumber="00",w.signatureOid=null,w.signature=null,w.siginfo={},w.siginfo.algorithmOid=null,w.validity={},w.validity.notBefore=new Date,w.validity.notAfter=new Date,w.issuer={},w.issuer.getField=function(g){return p(w.issuer,g)},w.issuer.addField=function(g){d([g]),w.issuer.attributes.push(g)},w.issuer.attributes=[],w.issuer.hash=null,w.subject={},w.subject.getField=function(g){return p(w.subject,g)},w.subject.addField=function(g){d([g]),w.subject.attributes.push(g)},w.subject.attributes=[],w.subject.hash=null,w.extensions=[],w.publicKey=null,w.md=null,w.setSubject=function(g,f){d(g),w.subject.attributes=g,delete w.subject.uniqueId,f&&(w.subject.uniqueId=f),w.subject.hash=null},w.setIssuer=function(g,f){d(g),w.issuer.attributes=g,delete w.issuer.uniqueId,f&&(w.issuer.uniqueId=f),w.issuer.hash=null},w.setExtensions=function(g){for(var f=0;f<g.length;++f)y(g[f],{cert:w});w.extensions=g},w.getExtension=function(g){typeof g=="string"&&(g={name:g});for(var f=null,k,L=0;f===null&&L<w.extensions.length;++L)k=w.extensions[L],(g.id&&k.id===g.id||g.name&&k.name===g.name)&&(f=k);return f},w.sign=function(g,f){w.md=f||o.md.sha1.create();var k=r[w.md.algorithm+"WithRSAEncryption"];if(!k){var L=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw L.algorithm=w.md.algorithm,L}w.signatureOid=w.siginfo.algorithmOid=k,w.tbsCertificate=t.getTBSCertificate(w);var H=e.toDer(w.tbsCertificate);w.md.update(H.getBytes()),w.signature=g.sign(w.md)},w.verify=function(g){var f=!1;if(!w.issued(g)){var k=g.issuer,L=w.subject,H=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw H.expectedIssuer=L.attributes,H.actualIssuer=k.attributes,H}var I=g.md;if(I===null){I=x({signatureOid:g.signatureOid,type:"certificate"});var V=g.tbsCertificate||t.getTBSCertificate(g),A=e.toDer(V);I.update(A.getBytes())}return I!==null&&(f=h({certificate:w,md:I,signature:g.signature})),f},w.isIssuer=function(g){var f=!1,k=w.issuer,L=g.subject;if(k.hash&&L.hash)f=k.hash===L.hash;else if(k.attributes.length===L.attributes.length){f=!0;for(var H,I,V=0;f&&V<k.attributes.length;++V)H=k.attributes[V],I=L.attributes[V],(H.type!==I.type||H.value!==I.value)&&(f=!1)}return f},w.issued=function(g){return g.isIssuer(w)},w.generateSubjectKeyIdentifier=function(){return t.getPublicKeyFingerprint(w.publicKey,{type:"RSAPublicKey"})},w.verifySubjectKeyIdentifier=function(){for(var g=r.subjectKeyIdentifier,f=0;f<w.extensions.length;++f){var k=w.extensions[f];if(k.id===g){var L=w.generateSubjectKeyIdentifier().getBytes();return o.util.hexToBytes(k.subjectKeyIdentifier)===L}}return!1},w},t.certificateFromAsn1=function(w,g){var f={},k=[];if(!e.validate(w,a,f,k)){var L=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw L.errors=k,L}var H=e.derToOid(f.publicKeyOid);if(H!==t.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var I=t.createCertificate();I.version=f.certVersion?f.certVersion.charCodeAt(0):0;var V=o.util.createBuffer(f.certSerialNumber);I.serialNumber=V.toHex(),I.signatureOid=o.asn1.derToOid(f.certSignatureOid),I.signatureParameters=b(I.signatureOid,f.certSignatureParams,!0),I.siginfo.algorithmOid=o.asn1.derToOid(f.certinfoSignatureOid),I.siginfo.parameters=b(I.siginfo.algorithmOid,f.certinfoSignatureParams,!1),I.signature=f.certSignature;var A=[];if(f.certValidity1UTCTime!==void 0&&A.push(e.utcTimeToDate(f.certValidity1UTCTime)),f.certValidity2GeneralizedTime!==void 0&&A.push(e.generalizedTimeToDate(f.certValidity2GeneralizedTime)),f.certValidity3UTCTime!==void 0&&A.push(e.utcTimeToDate(f.certValidity3UTCTime)),f.certValidity4GeneralizedTime!==void 0&&A.push(e.generalizedTimeToDate(f.certValidity4GeneralizedTime)),A.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(A.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(I.validity.notBefore=A[0],I.validity.notAfter=A[1],I.tbsCertificate=f.tbsCertificate,g){I.md=x({signatureOid:I.signatureOid,type:"certificate"});var G=e.toDer(I.tbsCertificate);I.md.update(G.getBytes())}var Y=o.md.sha1.create(),q=e.toDer(f.certIssuer);Y.update(q.getBytes()),I.issuer.getField=function(le){return p(I.issuer,le)},I.issuer.addField=function(le){d([le]),I.issuer.attributes.push(le)},I.issuer.attributes=t.RDNAttributesAsArray(f.certIssuer),f.certIssuerUniqueId&&(I.issuer.uniqueId=f.certIssuerUniqueId),I.issuer.hash=Y.digest().toHex();var ie=o.md.sha1.create(),ee=e.toDer(f.certSubject);return ie.update(ee.getBytes()),I.subject.getField=function(le){return p(I.subject,le)},I.subject.addField=function(le){d([le]),I.subject.attributes.push(le)},I.subject.attributes=t.RDNAttributesAsArray(f.certSubject),f.certSubjectUniqueId&&(I.subject.uniqueId=f.certSubjectUniqueId),I.subject.hash=ie.digest().toHex(),f.certExtensions?I.extensions=t.certificateExtensionsFromAsn1(f.certExtensions):I.extensions=[],I.publicKey=t.publicKeyFromAsn1(f.subjectPublicKeyInfo),I},t.certificateExtensionsFromAsn1=function(w){for(var g=[],f=0;f<w.value.length;++f)for(var k=w.value[f],L=0;L<k.value.length;++L)g.push(t.certificateExtensionFromAsn1(k.value[L]));return g},t.certificateExtensionFromAsn1=function(w){var g={};if(g.id=e.derToOid(w.value[0].value),g.critical=!1,w.value[1].type===e.Type.BOOLEAN?(g.critical=w.value[1].value.charCodeAt(0)!==0,g.value=w.value[2].value):g.value=w.value[1].value,g.id in r){if(g.name=r[g.id],g.name==="keyUsage"){var f=e.fromDer(g.value),k=0,L=0;f.value.length>1&&(k=f.value.charCodeAt(1),L=f.value.length>2?f.value.charCodeAt(2):0),g.digitalSignature=(k&128)===128,g.nonRepudiation=(k&64)===64,g.keyEncipherment=(k&32)===32,g.dataEncipherment=(k&16)===16,g.keyAgreement=(k&8)===8,g.keyCertSign=(k&4)===4,g.cRLSign=(k&2)===2,g.encipherOnly=(k&1)===1,g.decipherOnly=(L&128)===128}else if(g.name==="basicConstraints"){var f=e.fromDer(g.value);f.value.length>0&&f.value[0].type===e.Type.BOOLEAN?g.cA=f.value[0].value.charCodeAt(0)!==0:g.cA=!1;var H=null;f.value.length>0&&f.value[0].type===e.Type.INTEGER?H=f.value[0].value:f.value.length>1&&(H=f.value[1].value),H!==null&&(g.pathLenConstraint=e.derToInteger(H))}else if(g.name==="extKeyUsage")for(var f=e.fromDer(g.value),I=0;I<f.value.length;++I){var V=e.derToOid(f.value[I].value);V in r?g[r[V]]=!0:g[V]=!0}else if(g.name==="nsCertType"){var f=e.fromDer(g.value),k=0;f.value.length>1&&(k=f.value.charCodeAt(1)),g.client=(k&128)===128,g.server=(k&64)===64,g.email=(k&32)===32,g.objsign=(k&16)===16,g.reserved=(k&8)===8,g.sslCA=(k&4)===4,g.emailCA=(k&2)===2,g.objCA=(k&1)===1}else if(g.name==="subjectAltName"||g.name==="issuerAltName"){g.altNames=[];for(var A,f=e.fromDer(g.value),G=0;G<f.value.length;++G){A=f.value[G];var Y={type:A.type,value:A.value};switch(g.altNames.push(Y),A.type){case 1:case 2:case 6:break;case 7:Y.ip=o.util.bytesToIP(A.value);break;case 8:Y.oid=e.derToOid(A.value);break}}}else if(g.name==="subjectKeyIdentifier"){var f=e.fromDer(g.value);g.subjectKeyIdentifier=o.util.bytesToHex(f.value)}}return g},t.certificationRequestFromAsn1=function(w,g){var f={},k=[];if(!e.validate(w,c,f,k)){var L=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw L.errors=k,L}var H=e.derToOid(f.publicKeyOid);if(H!==t.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var I=t.createCertificationRequest();if(I.version=f.csrVersion?f.csrVersion.charCodeAt(0):0,I.signatureOid=o.asn1.derToOid(f.csrSignatureOid),I.signatureParameters=b(I.signatureOid,f.csrSignatureParams,!0),I.siginfo.algorithmOid=o.asn1.derToOid(f.csrSignatureOid),I.siginfo.parameters=b(I.siginfo.algorithmOid,f.csrSignatureParams,!1),I.signature=f.csrSignature,I.certificationRequestInfo=f.certificationRequestInfo,g){I.md=x({signatureOid:I.signatureOid,type:"certification request"});var V=e.toDer(I.certificationRequestInfo);I.md.update(V.getBytes())}var A=o.md.sha1.create();return I.subject.getField=function(G){return p(I.subject,G)},I.subject.addField=function(G){d([G]),I.subject.attributes.push(G)},I.subject.attributes=t.RDNAttributesAsArray(f.certificationRequestInfoSubject,A),I.subject.hash=A.digest().toHex(),I.publicKey=t.publicKeyFromAsn1(f.subjectPublicKeyInfo),I.getAttribute=function(G){return p(I,G)},I.addAttribute=function(G){d([G]),I.attributes.push(G)},I.attributes=t.CRIAttributesAsArray(f.certificationRequestInfoAttributes||[]),I},t.createCertificationRequest=function(){var w={};return w.version=0,w.signatureOid=null,w.signature=null,w.siginfo={},w.siginfo.algorithmOid=null,w.subject={},w.subject.getField=function(g){return p(w.subject,g)},w.subject.addField=function(g){d([g]),w.subject.attributes.push(g)},w.subject.attributes=[],w.subject.hash=null,w.publicKey=null,w.attributes=[],w.getAttribute=function(g){return p(w,g)},w.addAttribute=function(g){d([g]),w.attributes.push(g)},w.md=null,w.setSubject=function(g){d(g),w.subject.attributes=g,w.subject.hash=null},w.setAttributes=function(g){d(g),w.attributes=g},w.sign=function(g,f){w.md=f||o.md.sha1.create();var k=r[w.md.algorithm+"WithRSAEncryption"];if(!k){var L=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw L.algorithm=w.md.algorithm,L}w.signatureOid=w.siginfo.algorithmOid=k,w.certificationRequestInfo=t.getCertificationRequestInfo(w);var H=e.toDer(w.certificationRequestInfo);w.md.update(H.getBytes()),w.signature=g.sign(w.md)},w.verify=function(){var g=!1,f=w.md;if(f===null){f=x({signatureOid:w.signatureOid,type:"certification request"});var k=w.certificationRequestInfo||t.getCertificationRequestInfo(w),L=e.toDer(k);f.update(L.getBytes())}return f!==null&&(g=h({certificate:w,md:f,signature:w.signature})),g},w};function m(w){for(var g=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),f,k,L=w.attributes,H=0;H<L.length;++H){f=L[H];var I=f.value,V=e.Type.PRINTABLESTRING;"valueTagClass"in f&&(V=f.valueTagClass,V===e.Type.UTF8&&(I=o.util.encodeUtf8(I))),k=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(f.type).getBytes()),e.create(e.Class.UNIVERSAL,V,!1,I)])]),g.value.push(k)}return g}function d(w){for(var g,f=0;f<w.length;++f){if(g=w[f],typeof g.name>"u"&&(g.type&&g.type in t.oids?g.name=t.oids[g.type]:g.shortName&&g.shortName in n&&(g.name=t.oids[n[g.shortName]])),typeof g.type>"u")if(g.name&&g.name in t.oids)g.type=t.oids[g.name];else{var k=new Error("Attribute type not specified.");throw k.attribute=g,k}if(typeof g.shortName>"u"&&g.name&&g.name in n&&(g.shortName=n[g.name]),g.type===r.extensionRequest&&(g.valueConstructed=!0,g.valueTagClass=e.Type.SEQUENCE,!g.value&&g.extensions)){g.value=[];for(var L=0;L<g.extensions.length;++L)g.value.push(t.certificateExtensionToAsn1(y(g.extensions[L])))}if(typeof g.value>"u"){var k=new Error("Attribute value not specified.");throw k.attribute=g,k}}}function y(w,g){if(g=g||{},typeof w.name>"u"&&w.id&&w.id in t.oids&&(w.name=t.oids[w.id]),typeof w.id>"u")if(w.name&&w.name in t.oids)w.id=t.oids[w.name];else{var f=new Error("Extension ID not specified.");throw f.extension=w,f}if(typeof w.value<"u")return w;if(w.name==="keyUsage"){var k=0,L=0,H=0;w.digitalSignature&&(L|=128,k=7),w.nonRepudiation&&(L|=64,k=6),w.keyEncipherment&&(L|=32,k=5),w.dataEncipherment&&(L|=16,k=4),w.keyAgreement&&(L|=8,k=3),w.keyCertSign&&(L|=4,k=2),w.cRLSign&&(L|=2,k=1),w.encipherOnly&&(L|=1,k=0),w.decipherOnly&&(H|=128,k=7);var I=String.fromCharCode(k);H!==0?I+=String.fromCharCode(L)+String.fromCharCode(H):L!==0&&(I+=String.fromCharCode(L)),w.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,I)}else if(w.name==="basicConstraints")w.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),w.cA&&w.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,"ÿ")),"pathLenConstraint"in w&&w.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(w.pathLenConstraint).getBytes()));else if(w.name==="extKeyUsage"){w.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var V=w.value.value;for(var A in w)w[A]===!0&&(A in r?V.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r[A]).getBytes())):A.indexOf(".")!==-1&&V.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(A).getBytes())))}else if(w.name==="nsCertType"){var k=0,L=0;w.client&&(L|=128,k=7),w.server&&(L|=64,k=6),w.email&&(L|=32,k=5),w.objsign&&(L|=16,k=4),w.reserved&&(L|=8,k=3),w.sslCA&&(L|=4,k=2),w.emailCA&&(L|=2,k=1),w.objCA&&(L|=1,k=0);var I=String.fromCharCode(k);L!==0&&(I+=String.fromCharCode(L)),w.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,I)}else if(w.name==="subjectAltName"||w.name==="issuerAltName"){w.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);for(var G,Y=0;Y<w.altNames.length;++Y){G=w.altNames[Y];var I=G.value;if(G.type===7&&G.ip){if(I=o.util.bytesFromIP(G.ip),I===null){var f=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw f.extension=w,f}}else G.type===8&&(G.oid?I=e.oidToDer(e.oidToDer(G.oid)):I=e.oidToDer(I));w.value.value.push(e.create(e.Class.CONTEXT_SPECIFIC,G.type,!1,I))}}else if(w.name==="nsComment"&&g.cert){if(!/^[\x00-\x7F]*$/.test(w.comment)||w.comment.length<1||w.comment.length>128)throw new Error('Invalid "nsComment" content.');w.value=e.create(e.Class.UNIVERSAL,e.Type.IA5STRING,!1,w.comment)}else if(w.name==="subjectKeyIdentifier"&&g.cert){var q=g.cert.generateSubjectKeyIdentifier();w.subjectKeyIdentifier=q.toHex(),w.value=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,q.getBytes())}else if(w.name==="authorityKeyIdentifier"&&g.cert){w.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var V=w.value.value;if(w.keyIdentifier){var ie=w.keyIdentifier===!0?g.cert.generateSubjectKeyIdentifier().getBytes():w.keyIdentifier;V.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!1,ie))}if(w.authorityCertIssuer){var ee=[e.create(e.Class.CONTEXT_SPECIFIC,4,!0,[m(w.authorityCertIssuer===!0?g.cert.issuer:w.authorityCertIssuer)])];V.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,ee))}if(w.serialNumber){var le=o.util.hexToBytes(w.serialNumber===!0?g.cert.serialNumber:w.serialNumber);V.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!1,le))}}else if(w.name==="cRLDistributionPoints"){w.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);for(var V=w.value.value,$=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),J=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]),G,Y=0;Y<w.altNames.length;++Y){G=w.altNames[Y];var I=G.value;if(G.type===7&&G.ip){if(I=o.util.bytesFromIP(G.ip),I===null){var f=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw f.extension=w,f}}else G.type===8&&(G.oid?I=e.oidToDer(e.oidToDer(G.oid)):I=e.oidToDer(I));J.value.push(e.create(e.Class.CONTEXT_SPECIFIC,G.type,!1,I))}$.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[J])),V.push($)}if(typeof w.value>"u"){var f=new Error("Extension value not specified.");throw f.extension=w,f}return w}function u(w,g){switch(w){case r["RSASSA-PSS"]:var f=[];return g.hash.algorithmOid!==void 0&&f.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(g.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])])),g.mgf.algorithmOid!==void 0&&f.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(g.mgf.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(g.mgf.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])])])),g.saltLength!==void 0&&f.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(g.saltLength).getBytes())])),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,f);default:return e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")}}function v(w){var g=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);if(w.attributes.length===0)return g;for(var f=w.attributes,k=0;k<f.length;++k){var L=f[k],H=L.value,I=e.Type.UTF8;"valueTagClass"in L&&(I=L.valueTagClass),I===e.Type.UTF8&&(H=o.util.encodeUtf8(H));var V=!1;"valueConstructed"in L&&(V=L.valueConstructed);var A=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(L.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,I,V,H)])]);g.value.push(A)}return g}var E=new Date("1950-01-01T00:00:00Z"),T=new Date("2050-01-01T00:00:00Z");function _(w){return w>=E&&w<T?e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(w)):e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(w))}return t.getTBSCertificate=function(w){var g=_(w.validity.notBefore),f=_(w.validity.notAfter),k=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(w.version).getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,o.util.hexToBytes(w.serialNumber)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(w.siginfo.algorithmOid).getBytes()),u(w.siginfo.algorithmOid,w.siginfo.parameters)]),m(w.issuer),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[g,f]),m(w.subject),t.publicKeyToAsn1(w.publicKey)]);return w.issuer.uniqueId&&k.value.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+w.issuer.uniqueId)])),w.subject.uniqueId&&k.value.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+w.subject.uniqueId)])),w.extensions.length>0&&k.value.push(t.certificateExtensionsToAsn1(w.extensions)),k},t.getCertificationRequestInfo=function(w){var g=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(w.version).getBytes()),m(w.subject),t.publicKeyToAsn1(w.publicKey),v(w)]);return g},t.distinguishedNameToAsn1=function(w){return m(w)},t.certificateToAsn1=function(w){var g=w.tbsCertificate||t.getTBSCertificate(w);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[g,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(w.signatureOid).getBytes()),u(w.signatureOid,w.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+w.signature)])},t.certificateExtensionsToAsn1=function(w){var g=e.create(e.Class.CONTEXT_SPECIFIC,3,!0,[]),f=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);g.value.push(f);for(var k=0;k<w.length;++k)f.value.push(t.certificateExtensionToAsn1(w[k]));return g},t.certificateExtensionToAsn1=function(w){var g=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);g.value.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(w.id).getBytes())),w.critical&&g.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,"ÿ"));var f=w.value;return typeof w.value!="string"&&(f=e.toDer(f).getBytes()),g.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,f)),g},t.certificationRequestToAsn1=function(w){var g=w.certificationRequestInfo||t.getCertificationRequestInfo(w);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[g,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(w.signatureOid).getBytes()),u(w.signatureOid,w.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+w.signature)])},t.createCaStore=function(w){var g={certs:{}};g.getIssuer=function(I){var V=f(I.issuer);return V},g.addCertificate=function(I){if(typeof I=="string"&&(I=o.pki.certificateFromPem(I)),k(I.subject),!g.hasCertificate(I))if(I.subject.hash in g.certs){var V=g.certs[I.subject.hash];o.util.isArray(V)||(V=[V]),V.push(I),g.certs[I.subject.hash]=V}else g.certs[I.subject.hash]=I},g.hasCertificate=function(I){typeof I=="string"&&(I=o.pki.certificateFromPem(I));var V=f(I.subject);if(!V)return!1;o.util.isArray(V)||(V=[V]);for(var A=e.toDer(t.certificateToAsn1(I)).getBytes(),G=0;G<V.length;++G){var Y=e.toDer(t.certificateToAsn1(V[G])).getBytes();if(A===Y)return!0}return!1},g.listAllCertificates=function(){var I=[];for(var V in g.certs)if(g.certs.hasOwnProperty(V)){var A=g.certs[V];if(!o.util.isArray(A))I.push(A);else for(var G=0;G<A.length;++G)I.push(A[G])}return I},g.removeCertificate=function(I){var V;if(typeof I=="string"&&(I=o.pki.certificateFromPem(I)),k(I.subject),!g.hasCertificate(I))return null;var A=f(I.subject);if(!o.util.isArray(A))return V=g.certs[I.subject.hash],delete g.certs[I.subject.hash],V;for(var G=e.toDer(t.certificateToAsn1(I)).getBytes(),Y=0;Y<A.length;++Y){var q=e.toDer(t.certificateToAsn1(A[Y])).getBytes();G===q&&(V=A[Y],A.splice(Y,1))}return A.length===0&&delete g.certs[I.subject.hash],V};function f(I){return k(I),g.certs[I.hash]||null}function k(I){if(!I.hash){var V=o.md.sha1.create();I.attributes=t.RDNAttributesAsArray(m(I),V),I.hash=V.digest().toHex()}}if(w)for(var L=0;L<w.length;++L){var H=w[L];g.addCertificate(H)}return g},t.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},t.verifyCertificateChain=function(w,g,f){typeof f=="function"&&(f={verify:f}),f=f||{},g=g.slice(0);var k=g.slice(0),L=f.validityCheckDate;typeof L>"u"&&(L=new Date);var H=!0,I=null,V=0;do{var A=g.shift(),G=null,Y=!1;if(L&&(L<A.validity.notBefore||L>A.validity.notAfter)&&(I={message:"Certificate is not valid yet or has expired.",error:t.certificateError.certificate_expired,notBefore:A.validity.notBefore,notAfter:A.validity.notAfter,now:L}),I===null){if(G=g[0]||w.getIssuer(A),G===null&&A.isIssuer(A)&&(Y=!0,G=A),G){var q=G;o.util.isArray(q)||(q=[q]);for(var ie=!1;!ie&&q.length>0;){G=q.shift();try{ie=G.verify(A)}catch{}}ie||(I={message:"Certificate signature is invalid.",error:t.certificateError.bad_certificate})}I===null&&(!G||Y)&&!w.hasCertificate(A)&&(I={message:"Certificate is not trusted.",error:t.certificateError.unknown_ca})}if(I===null&&G&&!A.isIssuer(G)&&(I={message:"Certificate issuer is invalid.",error:t.certificateError.bad_certificate}),I===null)for(var ee={keyUsage:!0,basicConstraints:!0},le=0;I===null&&le<A.extensions.length;++le){var $=A.extensions[le];$.critical&&!($.name in ee)&&(I={message:"Certificate has an unsupported critical extension.",error:t.certificateError.unsupported_certificate})}if(I===null&&(!H||g.length===0&&(!G||Y))){var J=A.getExtension("basicConstraints"),de=A.getExtension("keyUsage");if(de!==null&&(!de.keyCertSign||J===null)&&(I={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:t.certificateError.bad_certificate}),I===null&&J===null&&(I={message:"Certificate is missing basicConstraints extension and cannot be used as a CA.",error:t.certificateError.bad_certificate}),I===null&&J!==null&&!J.cA&&(I={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:t.certificateError.bad_certificate}),I===null&&de!==null&&"pathLenConstraint"in J){var ae=V-1;ae>J.pathLenConstraint&&(I={message:"Certificate basicConstraints pathLenConstraint violated.",error:t.certificateError.bad_certificate})}}var te=I===null?!0:I.error,ce=f.verify?f.verify(te,V,k):te;if(ce===!0)I=null;else throw te===!0&&(I={message:"The application rejected the certificate.",error:t.certificateError.bad_certificate}),(ce||ce===0)&&(typeof ce=="object"&&!o.util.isArray(ce)?(ce.message&&(I.message=ce.message),ce.error&&(I.error=ce.error)):typeof ce=="string"&&(I.error=ce)),I;H=!1,++V}while(g.length>0);return!0},ii.exports}var Fn;function zn(){if(Fn)return ti.exports;Fn=1;var o=xe();gt(),Vt(),Tt(),Nn(),Ln(),ot(),sr(),Ot(),Ee(),li();var e=o.asn1,t=o.pki,r=ti.exports=o.pkcs12=o.pkcs12||{},n={name:"ContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},s={name:"PFX",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},n,{name:"PFX.macData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",optional:!0,tagClass:e.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},a={name:"SafeBag",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},i={name:"Attribute",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,capture:"values"}]},l={name:"CertBag",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:e.Class.UNIVERSAL,type:e.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function c(d,y,u,v){for(var E=[],T=0;T<d.length;T++)for(var _=0;_<d[T].safeBags.length;_++){var w=d[T].safeBags[_];if(!(v!==void 0&&w.type!==v)){if(y===null){E.push(w);continue}w.attributes[y]!==void 0&&w.attributes[y].indexOf(u)>=0&&E.push(w)}}return E}r.pkcs12FromAsn1=function(d,y,u){typeof y=="string"?(u=y,y=!0):y===void 0&&(y=!0);var v={},E=[];if(!e.validate(d,s,v,E)){var T=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw T.errors=T,T}var _={version:v.version.charCodeAt(0),safeContents:[],getBags:function(G){var Y={},q;return"localKeyId"in G?q=G.localKeyId:"localKeyIdHex"in G&&(q=o.util.hexToBytes(G.localKeyIdHex)),q===void 0&&!("friendlyName"in G)&&"bagType"in G&&(Y[G.bagType]=c(_.safeContents,null,null,G.bagType)),q!==void 0&&(Y.localKeyId=c(_.safeContents,"localKeyId",q,G.bagType)),"friendlyName"in G&&(Y.friendlyName=c(_.safeContents,"friendlyName",G.friendlyName,G.bagType)),Y},getBagsByFriendlyName:function(G,Y){return c(_.safeContents,"friendlyName",G,Y)},getBagsByLocalKeyId:function(G,Y){return c(_.safeContents,"localKeyId",G,Y)}};if(v.version.charCodeAt(0)!==3){var T=new Error("PKCS#12 PFX of version other than 3 not supported.");throw T.version=v.version.charCodeAt(0),T}if(e.derToOid(v.contentType)!==t.oids.data){var T=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw T.oid=e.derToOid(v.contentType),T}var w=v.content.value[0];if(w.tagClass!==e.Class.UNIVERSAL||w.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(w=p(w),v.mac){var g=null,f=0,k=e.derToOid(v.macAlgorithm);switch(k){case t.oids.sha1:g=o.md.sha1.create(),f=20;break;case t.oids.sha256:g=o.md.sha256.create(),f=32;break;case t.oids.sha384:g=o.md.sha384.create(),f=48;break;case t.oids.sha512:g=o.md.sha512.create(),f=64;break;case t.oids.md5:g=o.md.md5.create(),f=16;break}if(g===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+k);var L=new o.util.ByteBuffer(v.macSalt),H="macIterations"in v?parseInt(o.util.bytesToHex(v.macIterations),16):1,I=r.generateKey(u,L,3,H,f,g),V=o.hmac.create();V.start(g,I),V.update(w.value);var A=V.getMac();if(A.getBytes()!==v.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}else if(Array.isArray(d.value)&&d.value.length>2)throw new Error("Invalid PKCS#12. macData field present but MAC was not validated.");return b(_,w.value,y,u),_};function p(d){if(d.composed||d.constructed){for(var y=o.util.createBuffer(),u=0;u<d.value.length;++u)y.putBytes(d.value[u].value);d.composed=d.constructed=!1,d.value=y.getBytes()}return d}function b(d,y,u,v){if(y=e.fromDer(y,u),y.tagClass!==e.Class.UNIVERSAL||y.type!==e.Type.SEQUENCE||y.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var E=0;E<y.value.length;E++){var T=y.value[E],_={},w=[];if(!e.validate(T,n,_,w)){var g=new Error("Cannot read ContentInfo.");throw g.errors=w,g}var f={encrypted:!1},k=null,L=_.content.value[0];switch(e.derToOid(_.contentType)){case t.oids.data:if(L.tagClass!==e.Class.UNIVERSAL||L.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");k=p(L).value;break;case t.oids.encryptedData:k=x(L,v),f.encrypted=!0;break;default:var g=new Error("Unsupported PKCS#12 contentType.");throw g.contentType=e.derToOid(_.contentType),g}f.safeBags=h(k,u,v),d.safeContents.push(f)}}function x(d,y){var u={},v=[];if(!e.validate(d,o.pkcs7.asn1.encryptedDataValidator,u,v)){var E=new Error("Cannot read EncryptedContentInfo.");throw E.errors=v,E}var T=e.derToOid(u.contentType);if(T!==t.oids.data){var E=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw E.oid=T,E}T=e.derToOid(u.encAlgorithm);var _=t.pbe.getCipher(T,u.encParameter,y),w=p(u.encryptedContentAsn1),g=o.util.createBuffer(w.value);if(_.update(g),!_.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return _.output.getBytes()}function h(d,y,u){if(!y&&d.length===0)return[];if(d=e.fromDer(d,y),d.tagClass!==e.Class.UNIVERSAL||d.type!==e.Type.SEQUENCE||d.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var v=[],E=0;E<d.value.length;E++){var T=d.value[E],_={},w=[];if(!e.validate(T,a,_,w)){var g=new Error("Cannot read SafeBag.");throw g.errors=w,g}var f={type:e.derToOid(_.bagId),attributes:m(_.bagAttributes)};v.push(f);var k,L,H=_.bagValue.value[0];switch(f.type){case t.oids.pkcs8ShroudedKeyBag:if(H=t.decryptPrivateKeyInfo(H,u),H===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case t.oids.keyBag:try{f.key=t.privateKeyFromAsn1(H)}catch{f.key=null,f.asn1=H}continue;case t.oids.certBag:k=l,L=function(){if(e.derToOid(_.certId)!==t.oids.x509Certificate){var V=new Error("Unsupported certificate type, only X.509 supported.");throw V.oid=e.derToOid(_.certId),V}var A=e.fromDer(_.cert,y);try{f.cert=t.certificateFromAsn1(A,!0)}catch{f.cert=null,f.asn1=A}};break;default:var g=new Error("Unsupported PKCS#12 SafeBag type.");throw g.oid=f.type,g}if(k!==void 0&&!e.validate(H,k,_,w)){var g=new Error("Cannot read PKCS#12 "+k.name);throw g.errors=w,g}L()}return v}function m(d){var y={};if(d!==void 0)for(var u=0;u<d.length;++u){var v={},E=[];if(!e.validate(d[u],i,v,E)){var T=new Error("Cannot read PKCS#12 BagAttribute.");throw T.errors=E,T}var _=e.derToOid(v.oid);if(t.oids[_]!==void 0){y[t.oids[_]]=[];for(var w=0;w<v.values.length;++w)y[t.oids[_]].push(v.values[w].value)}}return y}return r.toPkcs12Asn1=function(d,y,u,v){v=v||{},v.saltSize=v.saltSize||8,v.count=v.count||2048,v.algorithm=v.algorithm||v.encAlgorithm||"aes128","useMac"in v||(v.useMac=!0),"localKeyId"in v||(v.localKeyId=null),"generateLocalKeyId"in v||(v.generateLocalKeyId=!0);var E=v.localKeyId,T;if(E!==null)E=o.util.hexToBytes(E);else if(v.generateLocalKeyId)if(y){var _=o.util.isArray(y)?y[0]:y;typeof _=="string"&&(_=t.certificateFromPem(_));var w=o.md.sha1.create();w.update(e.toDer(t.certificateToAsn1(_)).getBytes()),E=w.digest().getBytes()}else E=o.random.getBytes(20);var g=[];E!==null&&g.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.oids.localKeyId).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,E)])])),"friendlyName"in v&&g.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.oids.friendlyName).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.BMPSTRING,!1,v.friendlyName)])])),g.length>0&&(T=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,g));var f=[],k=[];y!==null&&(o.util.isArray(y)?k=y:k=[y]);for(var L=[],H=0;H<k.length;++H){y=k[H],typeof y=="string"&&(y=t.certificateFromPem(y));var I=H===0?T:void 0,V=t.certificateToAsn1(y),A=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.oids.certBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.oids.x509Certificate).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(V).getBytes())])])]),I]);L.push(A)}if(L.length>0){var G=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,L),Y=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(G).getBytes())])]);f.push(Y)}var q=null;if(d!==null){var ie=t.wrapRsaPrivateKey(t.privateKeyToAsn1(d));u===null?q=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.oids.keyBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[ie]),T]):q=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.oids.pkcs8ShroudedKeyBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[t.encryptPrivateKeyInfo(ie,u,v)]),T]);var ee=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[q]),le=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(ee).getBytes())])]);f.push(le)}var $=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,f),J;if(v.useMac){var w=o.md.sha1.create(),de=new o.util.ByteBuffer(o.random.getBytes(v.saltSize)),ae=v.count,d=r.generateKey(u,de,3,ae,20),te=o.hmac.create();te.start(w,d),te.update(e.toDer($).getBytes());var ce=te.getMac();J=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.oids.sha1).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,ce.getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,de.getBytes()),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(ae).getBytes())])}return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(3).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer($).getBytes())])]),J])},r.generateKey=o.pbe.generatePkcs12Key,ti.exports}var Kn;function Hn(){if(Kn)return Kr.exports;Kn=1;var o=xe();gt(),Tt(),Ln(),_t(),jr(),zn(),oi(),sr(),Ee(),li();var e=o.asn1,t=Kr.exports=o.pki=o.pki||{};return t.pemToDer=function(r){var n=o.pem.decode(r)[0];if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return o.util.createBuffer(n.body)},t.privateKeyFromPem=function(r){var n=o.pem.decode(r)[0];if(n.type!=="PRIVATE KEY"&&n.type!=="RSA PRIVATE KEY"){var s=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw s.headerType=n.type,s}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var a=e.fromDer(n.body);return t.privateKeyFromAsn1(a)},t.privateKeyToPem=function(r,n){var s={type:"RSA PRIVATE KEY",body:e.toDer(t.privateKeyToAsn1(r)).getBytes()};return o.pem.encode(s,{maxline:n})},t.privateKeyInfoToPem=function(r,n){var s={type:"PRIVATE KEY",body:e.toDer(r).getBytes()};return o.pem.encode(s,{maxline:n})},Kr.exports}var ci,Gn;function Wn(){if(Gn)return ci;Gn=1;var o=xe();gt(),Vt(),Fr(),_t(),Hn(),ot(),Ot(),Ee();var e=function(B,U,D,N){var S=o.util.createBuffer(),C=B.length>>1,R=C+(B.length&1),W=B.substr(0,R),F=B.substr(C,R),O=o.util.createBuffer(),z=o.hmac.create();D=U+D;var Q=Math.ceil(N/16),re=Math.ceil(N/20);z.start("MD5",W);var Z=o.util.createBuffer();O.putBytes(D);for(var ne=0;ne<Q;++ne)z.start(null,null),z.update(O.getBytes()),O.putBuffer(z.digest()),z.start(null,null),z.update(O.bytes()+D),Z.putBuffer(z.digest());z.start("SHA1",F);var he=o.util.createBuffer();O.clear(),O.putBytes(D);for(var ne=0;ne<re;++ne)z.start(null,null),z.update(O.getBytes()),O.putBuffer(z.digest()),z.start(null,null),z.update(O.bytes()+D),he.putBuffer(z.digest());return S.putBytes(o.util.xorBytes(Z.getBytes(),he.getBytes(),N)),S},t=function(B,U,D){var N=o.hmac.create();N.start("SHA1",B);var S=o.util.createBuffer();return S.putInt32(U[0]),S.putInt32(U[1]),S.putByte(D.type),S.putByte(D.version.major),S.putByte(D.version.minor),S.putInt16(D.length),S.putBytes(D.fragment.bytes()),N.update(S.getBytes()),N.digest().getBytes()},r=function(B,U,D){var N=!1;try{var S=B.deflate(U.fragment.getBytes());U.fragment=o.util.createBuffer(S),U.length=S.length,N=!0}catch{}return N},n=function(B,U,D){var N=!1;try{var S=B.inflate(U.fragment.getBytes());U.fragment=o.util.createBuffer(S),U.length=S.length,N=!0}catch{}return N},s=function(B,U){var D=0;switch(U){case 1:D=B.getByte();break;case 2:D=B.getInt16();break;case 3:D=B.getInt24();break;case 4:D=B.getInt32();break}return o.util.createBuffer(B.getBytes(D))},a=function(B,U,D){B.putInt(D.length(),U<<3),B.putBuffer(D)},i={};i.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}},i.SupportedVersions=[i.Versions.TLS_1_1,i.Versions.TLS_1_0],i.Version=i.SupportedVersions[0],i.MaxFragment=15360,i.ConnectionEnd={server:0,client:1},i.PRFAlgorithm={tls_prf_sha256:0},i.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},i.CipherType={stream:0,block:1,aead:2},i.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},i.CompressionMethod={none:0,deflate:1},i.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},i.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},i.Alert={},i.Alert.Level={warning:1,fatal:2},i.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},i.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},i.CipherSuites={},i.getCipherSuite=function(B){var U=null;for(var D in i.CipherSuites){var N=i.CipherSuites[D];if(N.id[0]===B.charCodeAt(0)&&N.id[1]===B.charCodeAt(1)){U=N;break}}return U},i.handleUnexpected=function(B,U){var D=!B.open&&B.entity===i.ConnectionEnd.client;D||B.error(B,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.unexpected_message}})},i.handleHelloRequest=function(B,U,D){!B.handshaking&&B.handshakes>0&&(i.queue(B,i.createAlert(B,{level:i.Alert.Level.warning,description:i.Alert.Description.no_renegotiation})),i.flush(B)),B.process()},i.parseHelloMessage=function(B,U,D){var N=null,S=B.entity===i.ConnectionEnd.client;if(D<38)B.error(B,{message:S?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}});else{var C=U.fragment,R=C.length();if(N={version:{major:C.getByte(),minor:C.getByte()},random:o.util.createBuffer(C.getBytes(32)),session_id:s(C,1),extensions:[]},S?(N.cipher_suite=C.getBytes(2),N.compression_method=C.getByte()):(N.cipher_suites=s(C,2),N.compression_methods=s(C,1)),R=D-(R-C.length()),R>0){for(var W=s(C,2);W.length()>0;)N.extensions.push({type:[W.getByte(),W.getByte()],data:s(W,2)});if(!S)for(var F=0;F<N.extensions.length;++F){var O=N.extensions[F];if(O.type[0]===0&&O.type[1]===0)for(var z=s(O.data,2);z.length()>0;){var Q=z.getByte();if(Q!==0)break;B.session.extensions.server_name.serverNameList.push(s(z,2).getBytes())}}}if(B.session.version&&(N.version.major!==B.session.version.major||N.version.minor!==B.session.version.minor))return B.error(B,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.protocol_version}});if(S)B.session.cipherSuite=i.getCipherSuite(N.cipher_suite);else for(var re=o.util.createBuffer(N.cipher_suites.bytes());re.length()>0&&(B.session.cipherSuite=i.getCipherSuite(re.getBytes(2)),B.session.cipherSuite===null););if(B.session.cipherSuite===null)return B.error(B,{message:"No cipher suites in common.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.handshake_failure},cipherSuite:o.util.bytesToHex(N.cipher_suite)});S?B.session.compressionMethod=N.compression_method:B.session.compressionMethod=i.CompressionMethod.none}return N},i.createSecurityParameters=function(B,U){var D=B.entity===i.ConnectionEnd.client,N=U.random.bytes(),S=D?B.session.sp.client_random:N,C=D?N:i.createRandom().getBytes();B.session.sp={entity:B.entity,prf_algorithm:i.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:B.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:S,server_random:C}},i.handleServerHello=function(B,U,D){var N=i.parseHelloMessage(B,U,D);if(!B.fail){if(N.version.minor<=B.version.minor)B.version.minor=N.version.minor;else return B.error(B,{message:"Incompatible TLS version.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.protocol_version}});B.session.version=B.version;var S=N.session_id.bytes();S.length>0&&S===B.session.id?(B.expect=h,B.session.resuming=!0,B.session.sp.server_random=N.random.bytes()):(B.expect=c,B.session.resuming=!1,i.createSecurityParameters(B,N)),B.session.id=S,B.process()}},i.handleClientHello=function(B,U,D){var N=i.parseHelloMessage(B,U,D);if(!B.fail){var S=N.session_id.bytes(),C=null;if(B.sessionCache&&(C=B.sessionCache.getSession(S),C===null?S="":(C.version.major!==N.version.major||C.version.minor>N.version.minor)&&(C=null,S="")),S.length===0&&(S=o.random.getBytes(32)),B.session.id=S,B.session.clientHelloVersion=N.version,B.session.sp={},C)B.version=B.session.version=C.version,B.session.sp=C.sp;else{for(var R,W=1;W<i.SupportedVersions.length&&(R=i.SupportedVersions[W],!(R.minor<=N.version.minor));++W);B.version={major:R.major,minor:R.minor},B.session.version=B.version}C!==null?(B.expect=_,B.session.resuming=!0,B.session.sp.client_random=N.random.bytes()):(B.expect=B.verifyClient!==!1?v:E,B.session.resuming=!1,i.createSecurityParameters(B,N)),B.open=!0,i.queue(B,i.createRecord(B,{type:i.ContentType.handshake,data:i.createServerHello(B)})),B.session.resuming?(i.queue(B,i.createRecord(B,{type:i.ContentType.change_cipher_spec,data:i.createChangeCipherSpec()})),B.state.pending=i.createConnectionState(B),B.state.current.write=B.state.pending.write,i.queue(B,i.createRecord(B,{type:i.ContentType.handshake,data:i.createFinished(B)}))):(i.queue(B,i.createRecord(B,{type:i.ContentType.handshake,data:i.createCertificate(B)})),B.fail||(i.queue(B,i.createRecord(B,{type:i.ContentType.handshake,data:i.createServerKeyExchange(B)})),B.verifyClient!==!1&&i.queue(B,i.createRecord(B,{type:i.ContentType.handshake,data:i.createCertificateRequest(B)})),i.queue(B,i.createRecord(B,{type:i.ContentType.handshake,data:i.createServerHelloDone(B)})))),i.flush(B),B.process()}},i.handleCertificate=function(B,U,D){if(D<3)return B.error(B,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}});var N=U.fragment,S={certificate_list:s(N,3)},C,R,W=[];try{for(;S.certificate_list.length()>0;)C=s(S.certificate_list,3),R=o.asn1.fromDer(C),C=o.pki.certificateFromAsn1(R,!0),W.push(C)}catch(O){return B.error(B,{message:"Could not parse certificate list.",cause:O,send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.bad_certificate}})}var F=B.entity===i.ConnectionEnd.client;(F||B.verifyClient===!0)&&W.length===0?B.error(B,{message:F?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}}):W.length===0?B.expect=F?p:E:(F?B.session.serverCertificate=W[0]:B.session.clientCertificate=W[0],i.verifyCertificateChain(B,W)&&(B.expect=F?p:E)),B.process()},i.handleServerKeyExchange=function(B,U,D){if(D>0)return B.error(B,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.unsupported_certificate}});B.expect=b,B.process()},i.handleClientKeyExchange=function(B,U,D){if(D<48)return B.error(B,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.unsupported_certificate}});var N=U.fragment,S={enc_pre_master_secret:s(N,2).getBytes()},C=null;if(B.getPrivateKey)try{C=B.getPrivateKey(B,B.session.serverCertificate),C=o.pki.privateKeyFromPem(C)}catch(F){B.error(B,{message:"Could not get private key.",cause:F,send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}})}if(C===null)return B.error(B,{message:"No private key set.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}});try{var R=B.session.sp;R.pre_master_secret=C.decrypt(S.enc_pre_master_secret);var W=B.session.clientHelloVersion;if(W.major!==R.pre_master_secret.charCodeAt(0)||W.minor!==R.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch{R.pre_master_secret=o.random.getBytes(48)}B.expect=_,B.session.clientCertificate!==null&&(B.expect=T),B.process()},i.handleCertificateRequest=function(B,U,D){if(D<3)return B.error(B,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}});var N=U.fragment,S={certificate_types:s(N,1),certificate_authorities:s(N,2)};B.session.certificateRequest=S,B.expect=x,B.process()},i.handleCertificateVerify=function(B,U,D){if(D<2)return B.error(B,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}});var N=U.fragment;N.read-=4;var S=N.bytes();N.read+=4;var C={signature:s(N,2).getBytes()},R=o.util.createBuffer();R.putBuffer(B.session.md5.digest()),R.putBuffer(B.session.sha1.digest()),R=R.getBytes();try{var W=B.session.clientCertificate;if(!W.publicKey.verify(R,C.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");B.session.md5.update(S),B.session.sha1.update(S)}catch{return B.error(B,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.handshake_failure}})}B.expect=_,B.process()},i.handleServerHelloDone=function(B,U,D){if(D>0)return B.error(B,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.record_overflow}});if(B.serverCertificate===null){var N={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.insufficient_security}},S=0,C=B.verify(B,N.alert.description,S,[]);if(C!==!0)return(C||C===0)&&(typeof C=="object"&&!o.util.isArray(C)?(C.message&&(N.message=C.message),C.alert&&(N.alert.description=C.alert)):typeof C=="number"&&(N.alert.description=C)),B.error(B,N)}B.session.certificateRequest!==null&&(U=i.createRecord(B,{type:i.ContentType.handshake,data:i.createCertificate(B)}),i.queue(B,U)),U=i.createRecord(B,{type:i.ContentType.handshake,data:i.createClientKeyExchange(B)}),i.queue(B,U),B.expect=y;var R=function(W,F){W.session.certificateRequest!==null&&W.session.clientCertificate!==null&&i.queue(W,i.createRecord(W,{type:i.ContentType.handshake,data:i.createCertificateVerify(W,F)})),i.queue(W,i.createRecord(W,{type:i.ContentType.change_cipher_spec,data:i.createChangeCipherSpec()})),W.state.pending=i.createConnectionState(W),W.state.current.write=W.state.pending.write,i.queue(W,i.createRecord(W,{type:i.ContentType.handshake,data:i.createFinished(W)})),W.expect=h,i.flush(W),W.process()};if(B.session.certificateRequest===null||B.session.clientCertificate===null)return R(B,null);i.getClientSignature(B,R)},i.handleChangeCipherSpec=function(B,U){if(U.fragment.getByte()!==1)return B.error(B,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}});var D=B.entity===i.ConnectionEnd.client;(B.session.resuming&&D||!B.session.resuming&&!D)&&(B.state.pending=i.createConnectionState(B)),B.state.current.read=B.state.pending.read,(!B.session.resuming&&D||B.session.resuming&&!D)&&(B.state.pending=null),B.expect=D?m:w,B.process()},i.handleFinished=function(B,U,D){var N=U.fragment;N.read-=4;var S=N.bytes();N.read+=4;var C=U.fragment.getBytes();N=o.util.createBuffer(),N.putBuffer(B.session.md5.digest()),N.putBuffer(B.session.sha1.digest());var R=B.entity===i.ConnectionEnd.client,W=R?"server finished":"client finished",F=B.session.sp,O=12,z=e;if(N=z(F.master_secret,W,N.getBytes(),O),N.getBytes()!==C)return B.error(B,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.decrypt_error}});B.session.md5.update(S),B.session.sha1.update(S),(B.session.resuming&&R||!B.session.resuming&&!R)&&(i.queue(B,i.createRecord(B,{type:i.ContentType.change_cipher_spec,data:i.createChangeCipherSpec()})),B.state.current.write=B.state.pending.write,B.state.pending=null,i.queue(B,i.createRecord(B,{type:i.ContentType.handshake,data:i.createFinished(B)}))),B.expect=R?d:g,B.handshaking=!1,++B.handshakes,B.peerCertificate=R?B.session.serverCertificate:B.session.clientCertificate,i.flush(B),B.isConnected=!0,B.connected(B),B.process()},i.handleAlert=function(B,U){var D=U.fragment,N={level:D.getByte(),description:D.getByte()},S;switch(N.description){case i.Alert.Description.close_notify:S="Connection closed.";break;case i.Alert.Description.unexpected_message:S="Unexpected message.";break;case i.Alert.Description.bad_record_mac:S="Bad record MAC.";break;case i.Alert.Description.decryption_failed:S="Decryption failed.";break;case i.Alert.Description.record_overflow:S="Record overflow.";break;case i.Alert.Description.decompression_failure:S="Decompression failed.";break;case i.Alert.Description.handshake_failure:S="Handshake failure.";break;case i.Alert.Description.bad_certificate:S="Bad certificate.";break;case i.Alert.Description.unsupported_certificate:S="Unsupported certificate.";break;case i.Alert.Description.certificate_revoked:S="Certificate revoked.";break;case i.Alert.Description.certificate_expired:S="Certificate expired.";break;case i.Alert.Description.certificate_unknown:S="Certificate unknown.";break;case i.Alert.Description.illegal_parameter:S="Illegal parameter.";break;case i.Alert.Description.unknown_ca:S="Unknown certificate authority.";break;case i.Alert.Description.access_denied:S="Access denied.";break;case i.Alert.Description.decode_error:S="Decode error.";break;case i.Alert.Description.decrypt_error:S="Decrypt error.";break;case i.Alert.Description.export_restriction:S="Export restriction.";break;case i.Alert.Description.protocol_version:S="Unsupported protocol version.";break;case i.Alert.Description.insufficient_security:S="Insufficient security.";break;case i.Alert.Description.internal_error:S="Internal error.";break;case i.Alert.Description.user_canceled:S="User canceled.";break;case i.Alert.Description.no_renegotiation:S="Renegotiation not supported.";break;default:S="Unknown error.";break}if(N.description===i.Alert.Description.close_notify)return B.close();B.error(B,{message:S,send:!1,origin:B.entity===i.ConnectionEnd.client?"server":"client",alert:N}),B.process()},i.handleHandshake=function(B,U){var D=U.fragment,N=D.getByte(),S=D.getInt24();if(S>D.length())return B.fragmented=U,U.fragment=o.util.createBuffer(),D.read-=4,B.process();B.fragmented=null,D.read-=4;var C=D.bytes(S+4);D.read+=4,N in J[B.entity][B.expect]?(B.entity===i.ConnectionEnd.server&&!B.open&&!B.fail&&(B.handshaking=!0,B.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:o.md.md5.create(),sha1:o.md.sha1.create()}),N!==i.HandshakeType.hello_request&&N!==i.HandshakeType.certificate_verify&&N!==i.HandshakeType.finished&&(B.session.md5.update(C),B.session.sha1.update(C)),J[B.entity][B.expect][N](B,U,S)):i.handleUnexpected(B,U)},i.handleApplicationData=function(B,U){B.data.putBuffer(U.fragment),B.dataReady(B),B.process()},i.handleHeartbeat=function(B,U){var D=U.fragment,N=D.getByte(),S=D.getInt16(),C=D.getBytes(S);if(N===i.HeartbeatMessageType.heartbeat_request){if(B.handshaking||S>C.length)return B.process();i.queue(B,i.createRecord(B,{type:i.ContentType.heartbeat,data:i.createHeartbeat(i.HeartbeatMessageType.heartbeat_response,C)})),i.flush(B)}else if(N===i.HeartbeatMessageType.heartbeat_response){if(C!==B.expectedHeartbeatPayload)return B.process();B.heartbeatReceived&&B.heartbeatReceived(B,o.util.createBuffer(C))}B.process()};var l=0,c=1,p=2,b=3,x=4,h=5,m=6,d=7,y=8,u=0,v=1,E=2,T=3,_=4,w=5,g=6,f=i.handleUnexpected,k=i.handleChangeCipherSpec,L=i.handleAlert,H=i.handleHandshake,I=i.handleApplicationData,V=i.handleHeartbeat,A=[];A[i.ConnectionEnd.client]=[[f,L,H,f,V],[f,L,H,f,V],[f,L,H,f,V],[f,L,H,f,V],[f,L,H,f,V],[k,L,f,f,V],[f,L,H,f,V],[f,L,H,I,V],[f,L,H,f,V]],A[i.ConnectionEnd.server]=[[f,L,H,f,V],[f,L,H,f,V],[f,L,H,f,V],[f,L,H,f,V],[k,L,f,f,V],[f,L,H,f,V],[f,L,H,I,V],[f,L,H,f,V]];var G=i.handleHelloRequest,Y=i.handleServerHello,q=i.handleCertificate,ie=i.handleServerKeyExchange,ee=i.handleCertificateRequest,le=i.handleServerHelloDone,$=i.handleFinished,J=[];J[i.ConnectionEnd.client]=[[f,f,Y,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f],[G,f,f,f,f,f,f,f,f,f,f,q,ie,ee,le,f,f,f,f,f,f],[G,f,f,f,f,f,f,f,f,f,f,f,ie,ee,le,f,f,f,f,f,f],[G,f,f,f,f,f,f,f,f,f,f,f,f,ee,le,f,f,f,f,f,f],[G,f,f,f,f,f,f,f,f,f,f,f,f,f,le,f,f,f,f,f,f],[G,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f],[G,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,$],[G,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f],[G,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f]];var de=i.handleClientHello,ae=i.handleClientKeyExchange,te=i.handleCertificateVerify;J[i.ConnectionEnd.server]=[[f,de,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f],[f,f,f,f,f,f,f,f,f,f,f,q,f,f,f,f,f,f,f,f,f],[f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,ae,f,f,f,f],[f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,te,f,f,f,f,f],[f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f],[f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,$],[f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f],[f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f]],i.generateKeys=function(B,U){var D=e,N=U.client_random+U.server_random;B.session.resuming||(U.master_secret=D(U.pre_master_secret,"master secret",N,48).bytes(),U.pre_master_secret=null),N=U.server_random+U.client_random;var S=2*U.mac_key_length+2*U.enc_key_length,C=B.version.major===i.Versions.TLS_1_0.major&&B.version.minor===i.Versions.TLS_1_0.minor;C&&(S+=2*U.fixed_iv_length);var R=D(U.master_secret,"key expansion",N,S),W={client_write_MAC_key:R.getBytes(U.mac_key_length),server_write_MAC_key:R.getBytes(U.mac_key_length),client_write_key:R.getBytes(U.enc_key_length),server_write_key:R.getBytes(U.enc_key_length)};return C&&(W.client_write_IV=R.getBytes(U.fixed_iv_length),W.server_write_IV=R.getBytes(U.fixed_iv_length)),W},i.createConnectionState=function(B){var U=B.entity===i.ConnectionEnd.client,D=function(){var C={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(R){return!0},compressionState:null,compressFunction:function(R){return!0},updateSequenceNumber:function(){C.sequenceNumber[1]===4294967295?(C.sequenceNumber[1]=0,++C.sequenceNumber[0]):++C.sequenceNumber[1]}};return C},N={read:D(),write:D()};if(N.read.update=function(C,R){return N.read.cipherFunction(R,N.read)?N.read.compressFunction(C,R,N.read)||C.error(C,{message:"Could not decompress record.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.decompression_failure}}):C.error(C,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.bad_record_mac}}),!C.fail},N.write.update=function(C,R){return N.write.compressFunction(C,R,N.write)?N.write.cipherFunction(R,N.write)||C.error(C,{message:"Could not encrypt record.",send:!1,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}}):C.error(C,{message:"Could not compress record.",send:!1,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}}),!C.fail},B.session){var S=B.session.sp;switch(B.session.cipherSuite.initSecurityParameters(S),S.keys=i.generateKeys(B,S),N.read.macKey=U?S.keys.server_write_MAC_key:S.keys.client_write_MAC_key,N.write.macKey=U?S.keys.client_write_MAC_key:S.keys.server_write_MAC_key,B.session.cipherSuite.initConnectionState(N,B,S),S.compression_algorithm){case i.CompressionMethod.none:break;case i.CompressionMethod.deflate:N.read.compressFunction=n,N.write.compressFunction=r;break;default:throw new Error("Unsupported compression algorithm.")}}return N},i.createRandom=function(){var B=new Date,U=+B+B.getTimezoneOffset()*6e4,D=o.util.createBuffer();return D.putInt32(U),D.putBytes(o.random.getBytes(28)),D},i.createRecord=function(B,U){if(!U.data)return null;var D={type:U.type,version:{major:B.version.major,minor:B.version.minor},length:U.data.length(),fragment:U.data};return D},i.createAlert=function(B,U){var D=o.util.createBuffer();return D.putByte(U.level),D.putByte(U.description),i.createRecord(B,{type:i.ContentType.alert,data:D})},i.createClientHello=function(B){B.session.clientHelloVersion={major:B.version.major,minor:B.version.minor};for(var U=o.util.createBuffer(),D=0;D<B.cipherSuites.length;++D){var N=B.cipherSuites[D];U.putByte(N.id[0]),U.putByte(N.id[1])}var S=U.length(),C=o.util.createBuffer();C.putByte(i.CompressionMethod.none);var R=C.length(),W=o.util.createBuffer();if(B.virtualHost){var F=o.util.createBuffer();F.putByte(0),F.putByte(0);var O=o.util.createBuffer();O.putByte(0),a(O,2,o.util.createBuffer(B.virtualHost));var z=o.util.createBuffer();a(z,2,O),a(F,2,z),W.putBuffer(F)}var Q=W.length();Q>0&&(Q+=2);var re=B.session.id,Z=re.length+1+2+4+28+2+S+1+R+Q,ne=o.util.createBuffer();return ne.putByte(i.HandshakeType.client_hello),ne.putInt24(Z),ne.putByte(B.version.major),ne.putByte(B.version.minor),ne.putBytes(B.session.sp.client_random),a(ne,1,o.util.createBuffer(re)),a(ne,2,U),a(ne,1,C),Q>0&&a(ne,2,W),ne},i.createServerHello=function(B){var U=B.session.id,D=U.length+1+2+4+28+2+1,N=o.util.createBuffer();return N.putByte(i.HandshakeType.server_hello),N.putInt24(D),N.putByte(B.version.major),N.putByte(B.version.minor),N.putBytes(B.session.sp.server_random),a(N,1,o.util.createBuffer(U)),N.putByte(B.session.cipherSuite.id[0]),N.putByte(B.session.cipherSuite.id[1]),N.putByte(B.session.compressionMethod),N},i.createCertificate=function(B){var U=B.entity===i.ConnectionEnd.client,D=null;if(B.getCertificate){var N;U?N=B.session.certificateRequest:N=B.session.extensions.server_name.serverNameList,D=B.getCertificate(B,N)}var S=o.util.createBuffer();if(D!==null)try{o.util.isArray(D)||(D=[D]);for(var C=null,R=0;R<D.length;++R){var W=o.pem.decode(D[R])[0];if(W.type!=="CERTIFICATE"&&W.type!=="X509 CERTIFICATE"&&W.type!=="TRUSTED CERTIFICATE"){var F=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw F.headerType=W.type,F}if(W.procType&&W.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var O=o.util.createBuffer(W.body);C===null&&(C=o.asn1.fromDer(O.bytes(),!1));var z=o.util.createBuffer();a(z,3,O),S.putBuffer(z)}D=o.pki.certificateFromAsn1(C),U?B.session.clientCertificate=D:B.session.serverCertificate=D}catch(Z){return B.error(B,{message:"Could not send certificate list.",cause:Z,send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.bad_certificate}})}var Q=3+S.length(),re=o.util.createBuffer();return re.putByte(i.HandshakeType.certificate),re.putInt24(Q),a(re,3,S),re},i.createClientKeyExchange=function(B){var U=o.util.createBuffer();U.putByte(B.session.clientHelloVersion.major),U.putByte(B.session.clientHelloVersion.minor),U.putBytes(o.random.getBytes(46));var D=B.session.sp;D.pre_master_secret=U.getBytes();var N=B.session.serverCertificate.publicKey;U=N.encrypt(D.pre_master_secret);var S=U.length+2,C=o.util.createBuffer();return C.putByte(i.HandshakeType.client_key_exchange),C.putInt24(S),C.putInt16(U.length),C.putBytes(U),C},i.createServerKeyExchange=function(B){var U=o.util.createBuffer();return U},i.getClientSignature=function(B,U){var D=o.util.createBuffer();D.putBuffer(B.session.md5.digest()),D.putBuffer(B.session.sha1.digest()),D=D.getBytes(),B.getSignature=B.getSignature||function(N,S,C){var R=null;if(N.getPrivateKey)try{R=N.getPrivateKey(N,N.session.clientCertificate),R=o.pki.privateKeyFromPem(R)}catch(W){N.error(N,{message:"Could not get private key.",cause:W,send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}})}R===null?N.error(N,{message:"No private key set.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}}):S=R.sign(S,null),C(N,S)},B.getSignature(B,D,U)},i.createCertificateVerify=function(B,U){var D=U.length+2,N=o.util.createBuffer();return N.putByte(i.HandshakeType.certificate_verify),N.putInt24(D),N.putInt16(U.length),N.putBytes(U),N},i.createCertificateRequest=function(B){var U=o.util.createBuffer();U.putByte(1);var D=o.util.createBuffer();for(var N in B.caStore.certs){var S=B.caStore.certs[N],C=o.pki.distinguishedNameToAsn1(S.subject),R=o.asn1.toDer(C);D.putInt16(R.length()),D.putBuffer(R)}var W=1+U.length()+2+D.length(),F=o.util.createBuffer();return F.putByte(i.HandshakeType.certificate_request),F.putInt24(W),a(F,1,U),a(F,2,D),F},i.createServerHelloDone=function(B){var U=o.util.createBuffer();return U.putByte(i.HandshakeType.server_hello_done),U.putInt24(0),U},i.createChangeCipherSpec=function(){var B=o.util.createBuffer();return B.putByte(1),B},i.createFinished=function(B){var U=o.util.createBuffer();U.putBuffer(B.session.md5.digest()),U.putBuffer(B.session.sha1.digest());var D=B.entity===i.ConnectionEnd.client,N=B.session.sp,S=12,C=e,R=D?"client finished":"server finished";U=C(N.master_secret,R,U.getBytes(),S);var W=o.util.createBuffer();return W.putByte(i.HandshakeType.finished),W.putInt24(U.length()),W.putBuffer(U),W},i.createHeartbeat=function(B,U,D){typeof D>"u"&&(D=U.length);var N=o.util.createBuffer();N.putByte(B),N.putInt16(D),N.putBytes(U);var S=N.length(),C=Math.max(16,S-D-3);return N.putBytes(o.random.getBytes(C)),N},i.queue=function(B,U){if(U&&!(U.fragment.length()===0&&(U.type===i.ContentType.handshake||U.type===i.ContentType.alert||U.type===i.ContentType.change_cipher_spec))){if(U.type===i.ContentType.handshake){var D=U.fragment.bytes();B.session.md5.update(D),B.session.sha1.update(D),D=null}var N;if(U.fragment.length()<=i.MaxFragment)N=[U];else{N=[];for(var S=U.fragment.bytes();S.length>i.MaxFragment;)N.push(i.createRecord(B,{type:U.type,data:o.util.createBuffer(S.slice(0,i.MaxFragment))})),S=S.slice(i.MaxFragment);S.length>0&&N.push(i.createRecord(B,{type:U.type,data:o.util.createBuffer(S)}))}for(var C=0;C<N.length&&!B.fail;++C){var R=N[C],W=B.state.current.write;W.update(B,R)&&B.records.push(R)}}},i.flush=function(B){for(var U=0;U<B.records.length;++U){var D=B.records[U];B.tlsData.putByte(D.type),B.tlsData.putByte(D.version.major),B.tlsData.putByte(D.version.minor),B.tlsData.putInt16(D.fragment.length()),B.tlsData.putBuffer(B.records[U].fragment)}return B.records=[],B.tlsDataReady(B)};var ce=function(B){switch(B){case!0:return!0;case o.pki.certificateError.bad_certificate:return i.Alert.Description.bad_certificate;case o.pki.certificateError.unsupported_certificate:return i.Alert.Description.unsupported_certificate;case o.pki.certificateError.certificate_revoked:return i.Alert.Description.certificate_revoked;case o.pki.certificateError.certificate_expired:return i.Alert.Description.certificate_expired;case o.pki.certificateError.certificate_unknown:return i.Alert.Description.certificate_unknown;case o.pki.certificateError.unknown_ca:return i.Alert.Description.unknown_ca;default:return i.Alert.Description.bad_certificate}},we=function(B){switch(B){case!0:return!0;case i.Alert.Description.bad_certificate:return o.pki.certificateError.bad_certificate;case i.Alert.Description.unsupported_certificate:return o.pki.certificateError.unsupported_certificate;case i.Alert.Description.certificate_revoked:return o.pki.certificateError.certificate_revoked;case i.Alert.Description.certificate_expired:return o.pki.certificateError.certificate_expired;case i.Alert.Description.certificate_unknown:return o.pki.certificateError.certificate_unknown;case i.Alert.Description.unknown_ca:return o.pki.certificateError.unknown_ca;default:return o.pki.certificateError.bad_certificate}};i.verifyCertificateChain=function(B,U){try{var D={};for(var N in B.verifyOptions)D[N]=B.verifyOptions[N];D.verify=function(C,R,W){var F=ce(C),O=B.verify(B,C,R,W);if(O!==!0){if(typeof O=="object"&&!o.util.isArray(O)){var z=new Error("The application rejected the certificate.");throw z.send=!0,z.alert={level:i.Alert.Level.fatal,description:i.Alert.Description.bad_certificate},O.message&&(z.message=O.message),O.alert&&(z.alert.description=O.alert),z}O!==C&&(O=we(O))}return O},o.pki.verifyCertificateChain(B.caStore,U,D)}catch(C){var S=C;(typeof S!="object"||o.util.isArray(S))&&(S={send:!0,alert:{level:i.Alert.Level.fatal,description:ce(C)}}),"send"in S||(S.send=!0),"alert"in S||(S.alert={level:i.Alert.Level.fatal,description:ce(S.error)}),B.error(B,S)}return!B.fail},i.createSessionCache=function(B,U){var D=null;if(B&&B.getSession&&B.setSession&&B.order)D=B;else{D={},D.cache=B||{},D.capacity=Math.max(U||100,1),D.order=[];for(var N in B)D.order.length<=U?D.order.push(N):delete B[N];D.getSession=function(S){var C=null,R=null;if(S?R=o.util.bytesToHex(S):D.order.length>0&&(R=D.order[0]),R!==null&&R in D.cache){C=D.cache[R],delete D.cache[R];for(var W in D.order)if(D.order[W]===R){D.order.splice(W,1);break}}return C},D.setSession=function(S,C){if(D.order.length===D.capacity){var R=D.order.shift();delete D.cache[R]}var R=o.util.bytesToHex(S);D.order.push(R),D.cache[R]=C}}return D},i.createConnection=function(B){var U=null;B.caStore?o.util.isArray(B.caStore)?U=o.pki.createCaStore(B.caStore):U=B.caStore:U=o.pki.createCaStore();var D=B.cipherSuites||null;if(D===null){D=[];for(var N in i.CipherSuites)D.push(i.CipherSuites[N])}var S=B.server?i.ConnectionEnd.server:i.ConnectionEnd.client,C=B.sessionCache?i.createSessionCache(B.sessionCache):null,R={version:{major:i.Version.major,minor:i.Version.minor},entity:S,sessionId:B.sessionId,caStore:U,sessionCache:C,cipherSuites:D,connected:B.connected,virtualHost:B.virtualHost||null,verifyClient:B.verifyClient||!1,verify:B.verify||function(z,Q,re,Z){return Q},verifyOptions:B.verifyOptions||{},getCertificate:B.getCertificate||null,getPrivateKey:B.getPrivateKey||null,getSignature:B.getSignature||null,input:o.util.createBuffer(),tlsData:o.util.createBuffer(),data:o.util.createBuffer(),tlsDataReady:B.tlsDataReady,dataReady:B.dataReady,heartbeatReceived:B.heartbeatReceived,closed:B.closed,error:function(z,Q){Q.origin=Q.origin||(z.entity===i.ConnectionEnd.client?"client":"server"),Q.send&&(i.queue(z,i.createAlert(z,Q.alert)),i.flush(z));var re=Q.fatal!==!1;re&&(z.fail=!0),B.error(z,Q),re&&z.close(!1)},deflate:B.deflate||null,inflate:B.inflate||null};R.reset=function(z){R.version={major:i.Version.major,minor:i.Version.minor},R.record=null,R.session=null,R.peerCertificate=null,R.state={pending:null,current:null},R.expect=R.entity===i.ConnectionEnd.client?l:u,R.fragmented=null,R.records=[],R.open=!1,R.handshakes=0,R.handshaking=!1,R.isConnected=!1,R.fail=!(z||typeof z>"u"),R.input.clear(),R.tlsData.clear(),R.data.clear(),R.state.current=i.createConnectionState(R)},R.reset();var W=function(z,Q){var re=Q.type-i.ContentType.change_cipher_spec,Z=A[z.entity][z.expect];re in Z?Z[re](z,Q):i.handleUnexpected(z,Q)},F=function(z){var Q=0,re=z.input,Z=re.length();if(Z<5)Q=5-Z;else{z.record={type:re.getByte(),version:{major:re.getByte(),minor:re.getByte()},length:re.getInt16(),fragment:o.util.createBuffer(),ready:!1};var ne=z.record.version.major===z.version.major;ne&&z.session&&z.session.version&&(ne=z.record.version.minor===z.version.minor),ne||z.error(z,{message:"Incompatible TLS version.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.protocol_version}})}return Q},O=function(z){var Q=0,re=z.input,Z=re.length();if(Z<z.record.length)Q=z.record.length-Z;else{z.record.fragment.putBytes(re.getBytes(z.record.length)),re.compact();var ne=z.state.current.read;ne.update(z,z.record)&&(z.fragmented!==null&&(z.fragmented.type===z.record.type?(z.fragmented.fragment.putBuffer(z.record.fragment),z.record=z.fragmented):z.error(z,{message:"Invalid fragmented record.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.unexpected_message}})),z.record.ready=!0)}return Q};return R.handshake=function(z){if(R.entity!==i.ConnectionEnd.client)R.error(R,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(R.handshaking)R.error(R,{message:"Handshake already in progress.",fatal:!1});else{R.fail&&!R.open&&R.handshakes===0&&(R.fail=!1),R.handshaking=!0,z=z||"";var Q=null;z.length>0&&(R.sessionCache&&(Q=R.sessionCache.getSession(z)),Q===null&&(z="")),z.length===0&&R.sessionCache&&(Q=R.sessionCache.getSession(),Q!==null&&(z=Q.id)),R.session={id:z,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:o.md.md5.create(),sha1:o.md.sha1.create()},Q&&(R.version=Q.version,R.session.sp=Q.sp),R.session.sp.client_random=i.createRandom().getBytes(),R.open=!0,i.queue(R,i.createRecord(R,{type:i.ContentType.handshake,data:i.createClientHello(R)})),i.flush(R)}},R.process=function(z){var Q=0;return z&&R.input.putBytes(z),R.fail||(R.record!==null&&R.record.ready&&R.record.fragment.isEmpty()&&(R.record=null),R.record===null&&(Q=F(R)),!R.fail&&R.record!==null&&!R.record.ready&&(Q=O(R)),!R.fail&&R.record!==null&&R.record.ready&&W(R,R.record)),Q},R.prepare=function(z){return i.queue(R,i.createRecord(R,{type:i.ContentType.application_data,data:o.util.createBuffer(z)})),i.flush(R)},R.prepareHeartbeatRequest=function(z,Q){return z instanceof o.util.ByteBuffer&&(z=z.bytes()),typeof Q>"u"&&(Q=z.length),R.expectedHeartbeatPayload=z,i.queue(R,i.createRecord(R,{type:i.ContentType.heartbeat,data:i.createHeartbeat(i.HeartbeatMessageType.heartbeat_request,z,Q)})),i.flush(R)},R.close=function(z){if(!R.fail&&R.sessionCache&&R.session){var Q={id:R.session.id,version:R.session.version,sp:R.session.sp};Q.sp.keys=null,R.sessionCache.setSession(Q.id,Q)}R.open&&(R.open=!1,R.input.clear(),(R.isConnected||R.handshaking)&&(R.isConnected=R.handshaking=!1,i.queue(R,i.createAlert(R,{level:i.Alert.Level.warning,description:i.Alert.Description.close_notify})),i.flush(R)),R.closed(R)),R.reset(z)},R},ci=o.tls=o.tls||{};for(var ye in i)typeof i[ye]!="function"&&(o.tls[ye]=i[ye]);return o.tls.prf_tls1=e,o.tls.hmac_sha1=t,o.tls.createSessionCache=i.createSessionCache,o.tls.createConnection=i.createConnection,ci}var jn;function vo(){if(jn)return Nr.exports;jn=1;var o=xe();St(),Wn();var e=Nr.exports=o.tls;e.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(l){l.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,l.cipher_type=e.CipherType.block,l.enc_key_length=16,l.block_length=16,l.fixed_iv_length=16,l.record_iv_length=16,l.mac_algorithm=e.MACAlgorithm.hmac_sha1,l.mac_length=20,l.mac_key_length=20},initConnectionState:t},e.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(l){l.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,l.cipher_type=e.CipherType.block,l.enc_key_length=32,l.block_length=16,l.fixed_iv_length=16,l.record_iv_length=16,l.mac_algorithm=e.MACAlgorithm.hmac_sha1,l.mac_length=20,l.mac_key_length=20},initConnectionState:t};function t(l,c,p){var b=c.entity===o.tls.ConnectionEnd.client;l.read.cipherState={init:!1,cipher:o.cipher.createDecipher("AES-CBC",b?p.keys.server_write_key:p.keys.client_write_key),iv:b?p.keys.server_write_IV:p.keys.client_write_IV},l.write.cipherState={init:!1,cipher:o.cipher.createCipher("AES-CBC",b?p.keys.client_write_key:p.keys.server_write_key),iv:b?p.keys.client_write_IV:p.keys.server_write_IV},l.read.cipherFunction=a,l.write.cipherFunction=r,l.read.macLength=l.write.macLength=p.mac_length,l.read.macFunction=l.write.macFunction=e.hmac_sha1}function r(l,c){var p=!1,b=c.macFunction(c.macKey,c.sequenceNumber,l);l.fragment.putBytes(b),c.updateSequenceNumber();var x;l.version.minor===e.Versions.TLS_1_0.minor?x=c.cipherState.init?null:c.cipherState.iv:x=o.random.getBytesSync(16),c.cipherState.init=!0;var h=c.cipherState.cipher;return h.start({iv:x}),l.version.minor>=e.Versions.TLS_1_1.minor&&h.output.putBytes(x),h.update(l.fragment),h.finish(n)&&(l.fragment=h.output,l.length=l.fragment.length(),p=!0),p}function n(l,c,p){if(!p){var b=l-c.length()%l;c.fillWithByte(b-1,b)}return!0}function s(l,c,p){var b=!0;if(p){for(var x=c.length(),h=c.last(),m=x-1-h;m<x-1;++m)b=b&&c.at(m)==h;b&&c.truncate(h+1)}return b}function a(l,c){var p=!1,b;l.version.minor===e.Versions.TLS_1_0.minor?b=c.cipherState.init?null:c.cipherState.iv:b=l.fragment.getBytes(16),c.cipherState.init=!0;var x=c.cipherState.cipher;x.start({iv:b}),x.update(l.fragment),p=x.finish(s);var h=c.macLength,m=o.random.getBytesSync(h),d=x.output.length();d>=h?(l.fragment=x.output.getBytes(d-h),m=x.output.getBytes(h)):l.fragment=x.output.getBytes(),l.fragment=o.util.createBuffer(l.fragment),l.length=l.fragment.length();var y=c.macFunction(c.macKey,c.sequenceNumber,l);return c.updateSequenceNumber(),p=i(c.macKey,m,y)&&p,p}function i(l,c,p){var b=o.hmac.create();return b.start("SHA1",l),b.update(c),c=b.digest().getBytes(),b.start(null,null),b.update(p),p=b.digest().getBytes(),c===p}return Nr.exports}var ui={exports:{}},qn;function Yn(){if(qn)return ui.exports;qn=1;var o=xe();yt(),Ee();var e=ui.exports=o.sha512=o.sha512||{};o.md.sha512=o.md.algorithms.sha512=e;var t=o.sha384=o.sha512.sha384=o.sha512.sha384||{};t.create=function(){return e.create("SHA-384")},o.md.sha384=o.md.algorithms.sha384=t,o.sha512.sha256=o.sha512.sha256||{create:function(){return e.create("SHA-512/256")}},o.md["sha512/256"]=o.md.algorithms["sha512/256"]=o.sha512.sha256,o.sha512.sha224=o.sha512.sha224||{create:function(){return e.create("SHA-512/224")}},o.md["sha512/224"]=o.md.algorithms["sha512/224"]=o.sha512.sha224,e.create=function(c){if(n||i(),typeof c>"u"&&(c="SHA-512"),!(c in a))throw new Error("Invalid SHA-512 algorithm: "+c);for(var p=a[c],b=null,x=o.util.createBuffer(),h=new Array(80),m=0;m<80;++m)h[m]=new Array(2);var d=64;switch(c){case"SHA-384":d=48;break;case"SHA-512/256":d=32;break;case"SHA-512/224":d=28;break}var y={algorithm:c.replace("-","").toLowerCase(),blockLength:128,digestLength:d,messageLength:0,fullMessageLength:null,messageLengthSize:16};return y.start=function(){y.messageLength=0,y.fullMessageLength=y.messageLength128=[];for(var u=y.messageLengthSize/4,v=0;v<u;++v)y.fullMessageLength.push(0);x=o.util.createBuffer(),b=new Array(p.length);for(var v=0;v<p.length;++v)b[v]=p[v].slice(0);return y},y.start(),y.update=function(u,v){v==="utf8"&&(u=o.util.encodeUtf8(u));var E=u.length;y.messageLength+=E,E=[E/4294967296>>>0,E>>>0];for(var T=y.fullMessageLength.length-1;T>=0;--T)y.fullMessageLength[T]+=E[1],E[1]=E[0]+(y.fullMessageLength[T]/4294967296>>>0),y.fullMessageLength[T]=y.fullMessageLength[T]>>>0,E[0]=E[1]/4294967296>>>0;return x.putBytes(u),l(b,h,x),(x.read>2048||x.length()===0)&&x.compact(),y},y.digest=function(){var u=o.util.createBuffer();u.putBytes(x.bytes());var v=y.fullMessageLength[y.fullMessageLength.length-1]+y.messageLengthSize,E=v&y.blockLength-1;u.putBytes(r.substr(0,y.blockLength-E));for(var T,_,w=y.fullMessageLength[0]*8,g=0;g<y.fullMessageLength.length-1;++g)T=y.fullMessageLength[g+1]*8,_=T/4294967296>>>0,w+=_,u.putInt32(w>>>0),w=T>>>0;u.putInt32(w);for(var f=new Array(b.length),g=0;g<b.length;++g)f[g]=b[g].slice(0);l(f,h,u);var k=o.util.createBuffer(),L;c==="SHA-512"?L=f.length:c==="SHA-384"?L=f.length-2:L=f.length-4;for(var g=0;g<L;++g)k.putInt32(f[g][0]),(g!==L-1||c!=="SHA-512/224")&&k.putInt32(f[g][1]);return k},y};var r=null,n=!1,s=null,a=null;function i(){r="",r+=o.util.fillString("\0",128),s=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],a={},a["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],a["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],a["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],a["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],n=!0}function l(c,p,b){for(var x,h,m,d,y,u,v,E,T,_,w,g,f,k,L,H,I,V,A,G,Y,q,ie,ee,le,$,J,de,ae,te,ce,we,ye,B,U,D=b.length();D>=128;){for(ae=0;ae<16;++ae)p[ae][0]=b.getInt32()>>>0,p[ae][1]=b.getInt32()>>>0;for(;ae<80;++ae)we=p[ae-2],te=we[0],ce=we[1],x=((te>>>19|ce<<13)^(ce>>>29|te<<3)^te>>>6)>>>0,h=((te<<13|ce>>>19)^(ce<<3|te>>>29)^(te<<26|ce>>>6))>>>0,B=p[ae-15],te=B[0],ce=B[1],m=((te>>>1|ce<<31)^(te>>>8|ce<<24)^te>>>7)>>>0,d=((te<<31|ce>>>1)^(te<<24|ce>>>8)^(te<<25|ce>>>7))>>>0,ye=p[ae-7],U=p[ae-16],ce=h+ye[1]+d+U[1],p[ae][0]=x+ye[0]+m+U[0]+(ce/4294967296>>>0)>>>0,p[ae][1]=ce>>>0;for(f=c[0][0],k=c[0][1],L=c[1][0],H=c[1][1],I=c[2][0],V=c[2][1],A=c[3][0],G=c[3][1],Y=c[4][0],q=c[4][1],ie=c[5][0],ee=c[5][1],le=c[6][0],$=c[6][1],J=c[7][0],de=c[7][1],ae=0;ae<80;++ae)v=((Y>>>14|q<<18)^(Y>>>18|q<<14)^(q>>>9|Y<<23))>>>0,E=((Y<<18|q>>>14)^(Y<<14|q>>>18)^(q<<23|Y>>>9))>>>0,T=(le^Y&(ie^le))>>>0,_=($^q&(ee^$))>>>0,y=((f>>>28|k<<4)^(k>>>2|f<<30)^(k>>>7|f<<25))>>>0,u=((f<<4|k>>>28)^(k<<30|f>>>2)^(k<<25|f>>>7))>>>0,w=(f&L|I&(f^L))>>>0,g=(k&H|V&(k^H))>>>0,ce=de+E+_+s[ae][1]+p[ae][1],x=J+v+T+s[ae][0]+p[ae][0]+(ce/4294967296>>>0)>>>0,h=ce>>>0,ce=u+g,m=y+w+(ce/4294967296>>>0)>>>0,d=ce>>>0,J=le,de=$,le=ie,$=ee,ie=Y,ee=q,ce=G+h,Y=A+x+(ce/4294967296>>>0)>>>0,q=ce>>>0,A=I,G=V,I=L,V=H,L=f,H=k,ce=h+d,f=x+m+(ce/4294967296>>>0)>>>0,k=ce>>>0;ce=c[0][1]+k,c[0][0]=c[0][0]+f+(ce/4294967296>>>0)>>>0,c[0][1]=ce>>>0,ce=c[1][1]+H,c[1][0]=c[1][0]+L+(ce/4294967296>>>0)>>>0,c[1][1]=ce>>>0,ce=c[2][1]+V,c[2][0]=c[2][0]+I+(ce/4294967296>>>0)>>>0,c[2][1]=ce>>>0,ce=c[3][1]+G,c[3][0]=c[3][0]+A+(ce/4294967296>>>0)>>>0,c[3][1]=ce>>>0,ce=c[4][1]+q,c[4][0]=c[4][0]+Y+(ce/4294967296>>>0)>>>0,c[4][1]=ce>>>0,ce=c[5][1]+ee,c[5][0]=c[5][0]+ie+(ce/4294967296>>>0)>>>0,c[5][1]=ce>>>0,ce=c[6][1]+$,c[6][0]=c[6][0]+le+(ce/4294967296>>>0)>>>0,c[6][1]=ce>>>0,ce=c[7][1]+de,c[7][0]=c[7][0]+J+(ce/4294967296>>>0)>>>0,c[7][1]=ce>>>0,D-=128}}return ui.exports}var ar={},$n;function xo(){if($n)return ar;$n=1;var o=xe();gt();var e=o.asn1;return ar.privateKeyValidator={name:"PrivateKeyInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},ar.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]},ar}var hi,Zn;function Co(){if(Zn)return hi;Zn=1;var o=xe();ir(),ot(),Yn(),Ee();var e=xo(),t=e.publicKeyValidator,r=e.privateKeyValidator;if(typeof n>"u")var n=o.jsbn.BigInteger;var s=o.util.ByteBuffer,a=typeof Buffer>"u"?Uint8Array:Buffer;o.pki=o.pki||{},hi=o.pki.ed25519=o.ed25519=o.ed25519||{};var i=o.ed25519;i.constants={},i.constants.PUBLIC_KEY_BYTE_LENGTH=32,i.constants.PRIVATE_KEY_BYTE_LENGTH=64,i.constants.SEED_BYTE_LENGTH=32,i.constants.SIGN_BYTE_LENGTH=64,i.constants.HASH_BYTE_LENGTH=64,i.generateKeyPair=function(U){U=U||{};var D=U.seed;if(D===void 0)D=o.random.getBytesSync(i.constants.SEED_BYTE_LENGTH);else if(typeof D=="string"){if(D.length!==i.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+i.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(D instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');D=l({message:D,encoding:"binary"});for(var N=new a(i.constants.PUBLIC_KEY_BYTE_LENGTH),S=new a(i.constants.PRIVATE_KEY_BYTE_LENGTH),C=0;C<32;++C)S[C]=D[C];return v(N,S),{publicKey:N,privateKey:S}},i.privateKeyFromAsn1=function(U){var D={},N=[],S=o.asn1.validate(U,r,D,N);if(!S){var C=new Error("Invalid Key.");throw C.errors=N,C}var R=o.asn1.derToOid(D.privateKeyOid),W=o.oids.EdDSA25519;if(R!==W)throw new Error('Invalid OID "'+R+'"; OID must be "'+W+'".');var F=D.privateKey,O=l({message:o.asn1.fromDer(F).value,encoding:"binary"});return{privateKeyBytes:O}},i.publicKeyFromAsn1=function(U){var D={},N=[],S=o.asn1.validate(U,t,D,N);if(!S){var C=new Error("Invalid Key.");throw C.errors=N,C}var R=o.asn1.derToOid(D.publicKeyOid),W=o.oids.EdDSA25519;if(R!==W)throw new Error('Invalid OID "'+R+'"; OID must be "'+W+'".');var F=D.ed25519PublicKey;if(F.length!==i.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return l({message:F,encoding:"binary"})},i.publicKeyFromPrivateKey=function(U){U=U||{};var D=l({message:U.privateKey,encoding:"binary"});if(D.length!==i.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+i.constants.PRIVATE_KEY_BYTE_LENGTH);for(var N=new a(i.constants.PUBLIC_KEY_BYTE_LENGTH),S=0;S<N.length;++S)N[S]=D[32+S];return N},i.sign=function(U){U=U||{};var D=l(U),N=l({message:U.privateKey,encoding:"binary"});if(N.length===i.constants.SEED_BYTE_LENGTH){var S=i.generateKeyPair({seed:N});N=S.privateKey}else if(N.length!==i.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+i.constants.SEED_BYTE_LENGTH+" or "+i.constants.PRIVATE_KEY_BYTE_LENGTH);var C=new a(i.constants.SIGN_BYTE_LENGTH+D.length);E(C,D,D.length,N);for(var R=new a(i.constants.SIGN_BYTE_LENGTH),W=0;W<R.length;++W)R[W]=C[W];return R},i.verify=function(U){U=U||{};var D=l(U);if(U.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var N=l({message:U.signature,encoding:"binary"});if(N.length!==i.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+i.constants.SIGN_BYTE_LENGTH);var S=l({message:U.publicKey,encoding:"binary"});if(S.length!==i.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+i.constants.PUBLIC_KEY_BYTE_LENGTH);var C=new a(i.constants.SIGN_BYTE_LENGTH+D.length),R=new a(i.constants.SIGN_BYTE_LENGTH+D.length),W;for(W=0;W<i.constants.SIGN_BYTE_LENGTH;++W)C[W]=N[W];for(W=0;W<D.length;++W)C[W+i.constants.SIGN_BYTE_LENGTH]=D[W];return T(R,C,C.length,S)>=0};function l(U){var D=U.message;if(D instanceof Uint8Array||D instanceof a)return D;var N=U.encoding;if(D===void 0)if(U.md)D=U.md.digest().getBytes(),N="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof D=="string"&&!N)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof D=="string"){if(typeof Buffer<"u")return Buffer.from(D,N);D=new s(D,N)}else if(!(D instanceof s))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var S=new a(D.length()),C=0;C<S.length;++C)S[C]=D.at(C);return S}var c=te(),p=te([1]),b=te([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),x=te([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),h=te([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=te([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),d=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),y=te([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function u(U,D){var N=o.md.sha512.create(),S=new s(U);N.update(S.getBytes(D),"binary");var C=N.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(C,"binary");for(var R=new a(i.constants.HASH_BYTE_LENGTH),W=0;W<64;++W)R[W]=C.charCodeAt(W);return R}function v(U,D){var N=[te(),te(),te(),te()],S,C=u(D,32);for(C[0]&=248,C[31]&=127,C[31]|=64,le(N,C),L(U,N),S=0;S<32;++S)D[S+32]=U[S];return 0}function E(U,D,N,S){var C,R,W=new Float64Array(64),F=[te(),te(),te(),te()],O=u(S,32);O[0]&=248,O[31]&=127,O[31]|=64;var z=N+64;for(C=0;C<N;++C)U[64+C]=D[C];for(C=0;C<32;++C)U[32+C]=O[32+C];var Q=u(U.subarray(32),N+32);for(g(Q),le(F,Q),L(U,F),C=32;C<64;++C)U[C]=S[C];var re=u(U,N+64);for(g(re),C=32;C<64;++C)W[C]=0;for(C=0;C<32;++C)W[C]=Q[C];for(C=0;C<32;++C)for(R=0;R<32;R++)W[C+R]+=re[C]*O[R];return w(U.subarray(32),W),z}function T(U,D,N,S){var C,R,W=new a(32),F=[te(),te(),te(),te()],O=[te(),te(),te(),te()];if(R=-1,N<64||I(O,S)||!_(D,32))return-1;for(C=0;C<N;++C)U[C]=D[C];for(C=0;C<32;++C)U[C+32]=S[C];var z=u(U,N);if(g(z),ee(F,O,z),le(O,D.subarray(32)),f(F,O),L(W,F),N-=64,Y(D,0,W,0)){for(C=0;C<N;++C)U[C]=0;return-1}for(C=0;C<N;++C)U[C]=D[C+64];return R=N,R}function _(U,D){var N;for(N=31;N>=0;--N){if(U[D+N]<d[N])return!0;if(U[D+N]>d[N])return!1}return!1}function w(U,D){var N,S,C,R;for(S=63;S>=32;--S){for(N=0,C=S-32,R=S-12;C<R;++C)D[C]+=N-16*D[S]*d[C-(S-32)],N=D[C]+128>>8,D[C]-=N*256;D[C]+=N,D[S]=0}for(N=0,C=0;C<32;++C)D[C]+=N-(D[31]>>4)*d[C],N=D[C]>>8,D[C]&=255;for(C=0;C<32;++C)D[C]-=N*d[C];for(S=0;S<32;++S)D[S+1]+=D[S]>>8,U[S]=D[S]&255}function g(U){for(var D=new Float64Array(64),N=0;N<64;++N)D[N]=U[N],U[N]=0;w(U,D)}function f(U,D){var N=te(),S=te(),C=te(),R=te(),W=te(),F=te(),O=te(),z=te(),Q=te();we(N,U[1],U[0]),we(Q,D[1],D[0]),B(N,N,Q),ce(S,U[0],U[1]),ce(Q,D[0],D[1]),B(S,S,Q),B(C,U[3],D[3]),B(C,C,x),B(R,U[2],D[2]),ce(R,R,R),we(W,S,N),we(F,R,C),ce(O,R,C),ce(z,S,N),B(U[0],W,F),B(U[1],z,O),B(U[2],O,F),B(U[3],W,z)}function k(U,D,N){for(var S=0;S<4;++S)ae(U[S],D[S],N)}function L(U,D){var N=te(),S=te(),C=te();J(C,D[2]),B(N,D[0],C),B(S,D[1],C),H(U,S),U[31]^=ie(N)<<7}function H(U,D){var N,S,C,R=te(),W=te();for(N=0;N<16;++N)W[N]=D[N];for(de(W),de(W),de(W),S=0;S<2;++S){for(R[0]=W[0]-65517,N=1;N<15;++N)R[N]=W[N]-65535-(R[N-1]>>16&1),R[N-1]&=65535;R[15]=W[15]-32767-(R[14]>>16&1),C=R[15]>>16&1,R[14]&=65535,ae(W,R,1-C)}for(N=0;N<16;N++)U[2*N]=W[N]&255,U[2*N+1]=W[N]>>8}function I(U,D){var N=te(),S=te(),C=te(),R=te(),W=te(),F=te(),O=te();return $(U[2],p),V(U[1],D),ye(C,U[1]),B(R,C,b),we(C,C,U[2]),ce(R,U[2],R),ye(W,R),ye(F,W),B(O,F,W),B(N,O,C),B(N,N,R),A(N,N),B(N,N,C),B(N,N,R),B(N,N,R),B(U[0],N,R),ye(S,U[0]),B(S,S,R),G(S,C)&&B(U[0],U[0],y),ye(S,U[0]),B(S,S,R),G(S,C)?-1:(ie(U[0])===D[31]>>7&&we(U[0],c,U[0]),B(U[3],U[0],U[1]),0)}function V(U,D){var N;for(N=0;N<16;++N)U[N]=D[2*N]+(D[2*N+1]<<8);U[15]&=32767}function A(U,D){var N=te(),S;for(S=0;S<16;++S)N[S]=D[S];for(S=250;S>=0;--S)ye(N,N),S!==1&&B(N,N,D);for(S=0;S<16;++S)U[S]=N[S]}function G(U,D){var N=new a(32),S=new a(32);return H(N,U),H(S,D),Y(N,0,S,0)}function Y(U,D,N,S){return q(U,D,N,S,32)}function q(U,D,N,S,C){var R,W=0;for(R=0;R<C;++R)W|=U[D+R]^N[S+R];return(1&W-1>>>8)-1}function ie(U){var D=new a(32);return H(D,U),D[0]&1}function ee(U,D,N){var S,C;for($(U[0],c),$(U[1],p),$(U[2],p),$(U[3],c),C=255;C>=0;--C)S=N[C/8|0]>>(C&7)&1,k(U,D,S),f(D,U),f(U,U),k(U,D,S)}function le(U,D){var N=[te(),te(),te(),te()];$(N[0],h),$(N[1],m),$(N[2],p),B(N[3],h,m),ee(U,N,D)}function $(U,D){var N;for(N=0;N<16;N++)U[N]=D[N]|0}function J(U,D){var N=te(),S;for(S=0;S<16;++S)N[S]=D[S];for(S=253;S>=0;--S)ye(N,N),S!==2&&S!==4&&B(N,N,D);for(S=0;S<16;++S)U[S]=N[S]}function de(U){var D,N,S=1;for(D=0;D<16;++D)N=U[D]+S+65535,S=Math.floor(N/65536),U[D]=N-S*65536;U[0]+=S-1+37*(S-1)}function ae(U,D,N){for(var S,C=~(N-1),R=0;R<16;++R)S=C&(U[R]^D[R]),U[R]^=S,D[R]^=S}function te(U){var D,N=new Float64Array(16);if(U)for(D=0;D<U.length;++D)N[D]=U[D];return N}function ce(U,D,N){for(var S=0;S<16;++S)U[S]=D[S]+N[S]}function we(U,D,N){for(var S=0;S<16;++S)U[S]=D[S]-N[S]}function ye(U,D){B(U,D,D)}function B(U,D,N){var S,C,R=0,W=0,F=0,O=0,z=0,Q=0,re=0,Z=0,ne=0,he=0,oe=0,pe=0,ve=0,me=0,be=0,Se=0,Te=0,Ie=0,Ce=0,Le=0,Ue=0,ke=0,Je=0,rt=0,st=0,lt=0,ct=0,it=0,ut=0,Ft=0,lr=0,Ve=N[0],Oe=N[1],Fe=N[2],ze=N[3],Ke=N[4],He=N[5],Ge=N[6],We=N[7],je=N[8],qe=N[9],Ye=N[10],$e=N[11],Me=N[12],De=N[13],Ze=N[14],Xe=N[15];S=D[0],R+=S*Ve,W+=S*Oe,F+=S*Fe,O+=S*ze,z+=S*Ke,Q+=S*He,re+=S*Ge,Z+=S*We,ne+=S*je,he+=S*qe,oe+=S*Ye,pe+=S*$e,ve+=S*Me,me+=S*De,be+=S*Ze,Se+=S*Xe,S=D[1],W+=S*Ve,F+=S*Oe,O+=S*Fe,z+=S*ze,Q+=S*Ke,re+=S*He,Z+=S*Ge,ne+=S*We,he+=S*je,oe+=S*qe,pe+=S*Ye,ve+=S*$e,me+=S*Me,be+=S*De,Se+=S*Ze,Te+=S*Xe,S=D[2],F+=S*Ve,O+=S*Oe,z+=S*Fe,Q+=S*ze,re+=S*Ke,Z+=S*He,ne+=S*Ge,he+=S*We,oe+=S*je,pe+=S*qe,ve+=S*Ye,me+=S*$e,be+=S*Me,Se+=S*De,Te+=S*Ze,Ie+=S*Xe,S=D[3],O+=S*Ve,z+=S*Oe,Q+=S*Fe,re+=S*ze,Z+=S*Ke,ne+=S*He,he+=S*Ge,oe+=S*We,pe+=S*je,ve+=S*qe,me+=S*Ye,be+=S*$e,Se+=S*Me,Te+=S*De,Ie+=S*Ze,Ce+=S*Xe,S=D[4],z+=S*Ve,Q+=S*Oe,re+=S*Fe,Z+=S*ze,ne+=S*Ke,he+=S*He,oe+=S*Ge,pe+=S*We,ve+=S*je,me+=S*qe,be+=S*Ye,Se+=S*$e,Te+=S*Me,Ie+=S*De,Ce+=S*Ze,Le+=S*Xe,S=D[5],Q+=S*Ve,re+=S*Oe,Z+=S*Fe,ne+=S*ze,he+=S*Ke,oe+=S*He,pe+=S*Ge,ve+=S*We,me+=S*je,be+=S*qe,Se+=S*Ye,Te+=S*$e,Ie+=S*Me,Ce+=S*De,Le+=S*Ze,Ue+=S*Xe,S=D[6],re+=S*Ve,Z+=S*Oe,ne+=S*Fe,he+=S*ze,oe+=S*Ke,pe+=S*He,ve+=S*Ge,me+=S*We,be+=S*je,Se+=S*qe,Te+=S*Ye,Ie+=S*$e,Ce+=S*Me,Le+=S*De,Ue+=S*Ze,ke+=S*Xe,S=D[7],Z+=S*Ve,ne+=S*Oe,he+=S*Fe,oe+=S*ze,pe+=S*Ke,ve+=S*He,me+=S*Ge,be+=S*We,Se+=S*je,Te+=S*qe,Ie+=S*Ye,Ce+=S*$e,Le+=S*Me,Ue+=S*De,ke+=S*Ze,Je+=S*Xe,S=D[8],ne+=S*Ve,he+=S*Oe,oe+=S*Fe,pe+=S*ze,ve+=S*Ke,me+=S*He,be+=S*Ge,Se+=S*We,Te+=S*je,Ie+=S*qe,Ce+=S*Ye,Le+=S*$e,Ue+=S*Me,ke+=S*De,Je+=S*Ze,rt+=S*Xe,S=D[9],he+=S*Ve,oe+=S*Oe,pe+=S*Fe,ve+=S*ze,me+=S*Ke,be+=S*He,Se+=S*Ge,Te+=S*We,Ie+=S*je,Ce+=S*qe,Le+=S*Ye,Ue+=S*$e,ke+=S*Me,Je+=S*De,rt+=S*Ze,st+=S*Xe,S=D[10],oe+=S*Ve,pe+=S*Oe,ve+=S*Fe,me+=S*ze,be+=S*Ke,Se+=S*He,Te+=S*Ge,Ie+=S*We,Ce+=S*je,Le+=S*qe,Ue+=S*Ye,ke+=S*$e,Je+=S*Me,rt+=S*De,st+=S*Ze,lt+=S*Xe,S=D[11],pe+=S*Ve,ve+=S*Oe,me+=S*Fe,be+=S*ze,Se+=S*Ke,Te+=S*He,Ie+=S*Ge,Ce+=S*We,Le+=S*je,Ue+=S*qe,ke+=S*Ye,Je+=S*$e,rt+=S*Me,st+=S*De,lt+=S*Ze,ct+=S*Xe,S=D[12],ve+=S*Ve,me+=S*Oe,be+=S*Fe,Se+=S*ze,Te+=S*Ke,Ie+=S*He,Ce+=S*Ge,Le+=S*We,Ue+=S*je,ke+=S*qe,Je+=S*Ye,rt+=S*$e,st+=S*Me,lt+=S*De,ct+=S*Ze,it+=S*Xe,S=D[13],me+=S*Ve,be+=S*Oe,Se+=S*Fe,Te+=S*ze,Ie+=S*Ke,Ce+=S*He,Le+=S*Ge,Ue+=S*We,ke+=S*je,Je+=S*qe,rt+=S*Ye,st+=S*$e,lt+=S*Me,ct+=S*De,it+=S*Ze,ut+=S*Xe,S=D[14],be+=S*Ve,Se+=S*Oe,Te+=S*Fe,Ie+=S*ze,Ce+=S*Ke,Le+=S*He,Ue+=S*Ge,ke+=S*We,Je+=S*je,rt+=S*qe,st+=S*Ye,lt+=S*$e,ct+=S*Me,it+=S*De,ut+=S*Ze,Ft+=S*Xe,S=D[15],Se+=S*Ve,Te+=S*Oe,Ie+=S*Fe,Ce+=S*ze,Le+=S*Ke,Ue+=S*He,ke+=S*Ge,Je+=S*We,rt+=S*je,st+=S*qe,lt+=S*Ye,ct+=S*$e,it+=S*Me,ut+=S*De,Ft+=S*Ze,lr+=S*Xe,R+=38*Te,W+=38*Ie,F+=38*Ce,O+=38*Le,z+=38*Ue,Q+=38*ke,re+=38*Je,Z+=38*rt,ne+=38*st,he+=38*lt,oe+=38*ct,pe+=38*it,ve+=38*ut,me+=38*Ft,be+=38*lr,C=1,S=R+C+65535,C=Math.floor(S/65536),R=S-C*65536,S=W+C+65535,C=Math.floor(S/65536),W=S-C*65536,S=F+C+65535,C=Math.floor(S/65536),F=S-C*65536,S=O+C+65535,C=Math.floor(S/65536),O=S-C*65536,S=z+C+65535,C=Math.floor(S/65536),z=S-C*65536,S=Q+C+65535,C=Math.floor(S/65536),Q=S-C*65536,S=re+C+65535,C=Math.floor(S/65536),re=S-C*65536,S=Z+C+65535,C=Math.floor(S/65536),Z=S-C*65536,S=ne+C+65535,C=Math.floor(S/65536),ne=S-C*65536,S=he+C+65535,C=Math.floor(S/65536),he=S-C*65536,S=oe+C+65535,C=Math.floor(S/65536),oe=S-C*65536,S=pe+C+65535,C=Math.floor(S/65536),pe=S-C*65536,S=ve+C+65535,C=Math.floor(S/65536),ve=S-C*65536,S=me+C+65535,C=Math.floor(S/65536),me=S-C*65536,S=be+C+65535,C=Math.floor(S/65536),be=S-C*65536,S=Se+C+65535,C=Math.floor(S/65536),Se=S-C*65536,R+=C-1+37*(C-1),C=1,S=R+C+65535,C=Math.floor(S/65536),R=S-C*65536,S=W+C+65535,C=Math.floor(S/65536),W=S-C*65536,S=F+C+65535,C=Math.floor(S/65536),F=S-C*65536,S=O+C+65535,C=Math.floor(S/65536),O=S-C*65536,S=z+C+65535,C=Math.floor(S/65536),z=S-C*65536,S=Q+C+65535,C=Math.floor(S/65536),Q=S-C*65536,S=re+C+65535,C=Math.floor(S/65536),re=S-C*65536,S=Z+C+65535,C=Math.floor(S/65536),Z=S-C*65536,S=ne+C+65535,C=Math.floor(S/65536),ne=S-C*65536,S=he+C+65535,C=Math.floor(S/65536),he=S-C*65536,S=oe+C+65535,C=Math.floor(S/65536),oe=S-C*65536,S=pe+C+65535,C=Math.floor(S/65536),pe=S-C*65536,S=ve+C+65535,C=Math.floor(S/65536),ve=S-C*65536,S=me+C+65535,C=Math.floor(S/65536),me=S-C*65536,S=be+C+65535,C=Math.floor(S/65536),be=S-C*65536,S=Se+C+65535,C=Math.floor(S/65536),Se=S-C*65536,R+=C-1+37*(C-1),U[0]=R,U[1]=W,U[2]=F,U[3]=O,U[4]=z,U[5]=Q,U[6]=re,U[7]=Z,U[8]=ne,U[9]=he,U[10]=oe,U[11]=pe,U[12]=ve,U[13]=me,U[14]=be,U[15]=Se}return hi}var di,Xn;function bo(){if(Xn)return di;Xn=1;var o=xe();Ee(),ot(),ir(),di=o.kem=o.kem||{};var e=o.jsbn.BigInteger;o.kem.rsa={},o.kem.rsa.create=function(r,n){n=n||{};var s=n.prng||o.random,a={};return a.encrypt=function(i,l){var c=Math.ceil(i.n.bitLength()/8),p;do p=new e(o.util.bytesToHex(s.getBytesSync(c)),16).mod(i.n);while(p.compareTo(e.ONE)<=0);p=o.util.hexToBytes(p.toString(16));var b=c-p.length;b>0&&(p=o.util.fillString("\0",b)+p);var x=i.encrypt(p,"NONE"),h=r.generate(p,l);return{encapsulation:x,key:h}},a.decrypt=function(i,l,c){var p=i.decrypt(l,"NONE");return r.generate(p,c)},a},o.kem.kdf1=function(r,n){t(this,r,0,n||r.digestLength)},o.kem.kdf2=function(r,n){t(this,r,1,n||r.digestLength)};function t(r,n,s,a){r.generate=function(i,l){for(var c=new o.util.ByteBuffer,p=Math.ceil(l/a)+s,b=new o.util.ByteBuffer,x=s;x<p;++x){b.putInt32(x),n.start(),n.update(i+b.getBytes());var h=n.digest();c.putBytes(h.getBytes(a))}return c.truncate(c.length()-l),c.getBytes()}}return di}var fi,Qn;function Eo(){if(Qn)return fi;Qn=1;var o=xe();Ee(),fi=o.log=o.log||{},o.log.levels=["none","error","warning","info","debug","verbose","max"];var e={},t=[],r=null;o.log.LEVEL_LOCKED=2,o.log.NO_LEVEL_CHECK=4,o.log.INTERPOLATE=8;for(var n=0;n<o.log.levels.length;++n){var s=o.log.levels[n];e[s]={index:n,name:s.toUpperCase()}}o.log.logMessage=function(x){for(var h=e[x.level].index,m=0;m<t.length;++m){var d=t[m];if(d.flags&o.log.NO_LEVEL_CHECK)d.f(x);else{var y=e[d.level].index;h<=y&&d.f(d,x)}}},o.log.prepareStandard=function(x){"standard"in x||(x.standard=e[x.level].name+" ["+x.category+"] "+x.message)},o.log.prepareFull=function(x){if(!("full"in x)){var h=[x.message];h=h.concat([]),x.full=o.util.format.apply(this,h)}},o.log.prepareStandardFull=function(x){"standardFull"in x||(o.log.prepareStandard(x),x.standardFull=x.standard)};for(var a=["error","warning","info","debug","verbose"],n=0;n<a.length;++n)(function(h){o.log[h]=function(m,d){var y=Array.prototype.slice.call(arguments).slice(2),u={timestamp:new Date,level:h,category:m,message:d,arguments:y};o.log.logMessage(u)}})(a[n]);if(o.log.makeLogger=function(x){var h={flags:0,f:x};return o.log.setLevel(h,"none"),h},o.log.setLevel=function(x,h){var m=!1;if(x&&!(x.flags&o.log.LEVEL_LOCKED))for(var d=0;d<o.log.levels.length;++d){var y=o.log.levels[d];if(h==y){x.level=h,m=!0;break}}return m},o.log.lock=function(x,h){typeof h>"u"||h?x.flags|=o.log.LEVEL_LOCKED:x.flags&=~o.log.LEVEL_LOCKED},o.log.addLogger=function(x){t.push(x)},typeof console<"u"&&"log"in console){var i;if(console.error&&console.warn&&console.info&&console.debug){var l={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},c=function(x,h){o.log.prepareStandard(h);var m=l[h.level],d=[h.standard];d=d.concat(h.arguments.slice()),m.apply(console,d)};i=o.log.makeLogger(c)}else{var c=function(h,m){o.log.prepareStandardFull(m),console.log(m.standardFull)};i=o.log.makeLogger(c)}o.log.setLevel(i,"debug"),o.log.addLogger(i),r=i}else console={log:function(){}};if(r!==null&&typeof window<"u"&&window.location){var p=new URL(window.location.href).searchParams;if(p.has("console.level")&&o.log.setLevel(r,p.get("console.level").slice(-1)[0]),p.has("console.lock")){var b=p.get("console.lock").slice(-1)[0];b=="true"&&o.log.lock(r)}}return o.log.consoleLogger=r,fi}var pi,Jn;function wo(){return Jn||(Jn=1,pi=yt(),Fr(),Ot(),vn(),Yn()),pi}var gi={exports:{}},es;function So(){if(es)return gi.exports;es=1;var o=xe();St(),gt(),tr(),Tt(),_t(),Nn(),ot(),Ee(),li();var e=o.asn1,t=gi.exports=o.pkcs7=o.pkcs7||{};t.messageFromPem=function(h){var m=o.pem.decode(h)[0];if(m.type!=="PKCS7"){var d=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw d.headerType=m.type,d}if(m.procType&&m.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var y=e.fromDer(m.body);return t.messageFromAsn1(y)},t.messageToPem=function(h,m){var d={type:"PKCS7",body:e.toDer(h.toAsn1()).getBytes()};return o.pem.encode(d,{maxline:m})},t.messageFromAsn1=function(h){var m={},d=[];if(!e.validate(h,t.asn1.contentInfoValidator,m,d)){var y=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw y.errors=d,y}var u=e.derToOid(m.contentType),v;switch(u){case o.pki.oids.envelopedData:v=t.createEnvelopedData();break;case o.pki.oids.encryptedData:v=t.createEncryptedData();break;case o.pki.oids.signedData:v=t.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+u+" is not (yet) supported.")}return v.fromAsn1(m.content.value[0]),v},t.createSignedData=function(){var h=null;return h={type:o.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(y){if(b(h,y,t.asn1.signedDataValidator),h.certificates=[],h.crls=[],h.digestAlgorithmIdentifiers=[],h.contentInfo=null,h.signerInfos=[],h.rawCapture.certificates)for(var u=h.rawCapture.certificates.value,v=0;v<u.length;++v)h.certificates.push(o.pki.certificateFromAsn1(u[v]))},toAsn1:function(){h.contentInfo||h.sign();for(var y=[],u=0;u<h.certificates.length;++u)y.push(o.pki.certificateToAsn1(h.certificates[u]));var v=[],E=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(h.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,h.digestAlgorithmIdentifiers),h.contentInfo])]);return y.length>0&&E.value[0].value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,y)),v.length>0&&E.value[0].value.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,v)),E.value[0].value.push(e.create(e.Class.UNIVERSAL,e.Type.SET,!0,h.signerInfos)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.type).getBytes()),E])},addSigner:function(y){var u=y.issuer,v=y.serialNumber;if(y.certificate){var E=y.certificate;typeof E=="string"&&(E=o.pki.certificateFromPem(E)),u=E.issuer.attributes,v=E.serialNumber}var T=y.key;if(!T)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof T=="string"&&(T=o.pki.privateKeyFromPem(T));var _=y.digestAlgorithm||o.pki.oids.sha1;switch(_){case o.pki.oids.sha1:case o.pki.oids.sha256:case o.pki.oids.sha384:case o.pki.oids.sha512:case o.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+_)}var w=y.authenticatedAttributes||[];if(w.length>0){for(var g=!1,f=!1,k=0;k<w.length;++k){var L=w[k];if(!g&&L.type===o.pki.oids.contentType){if(g=!0,f)break;continue}if(!f&&L.type===o.pki.oids.messageDigest){if(f=!0,g)break;continue}}if(!g||!f)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}h.signers.push({key:T,version:1,issuer:u,serialNumber:v,digestAlgorithm:_,signatureAlgorithm:o.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:w,unauthenticatedAttributes:[]})},sign:function(y){if(y=y||{},(typeof h.content!="object"||h.contentInfo===null)&&(h.contentInfo=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(o.pki.oids.data).getBytes())]),"content"in h)){var u;h.content instanceof o.util.ByteBuffer?u=h.content.bytes():typeof h.content=="string"&&(u=o.util.encodeUtf8(h.content)),y.detached?h.detachedContent=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,u):h.contentInfo.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,u)]))}if(h.signers.length!==0){var v=m();d(v)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(y){typeof y=="string"&&(y=o.pki.certificateFromPem(y)),h.certificates.push(y)},addCertificateRevokationList:function(y){throw new Error("PKCS#7 CRL support not yet implemented.")}},h;function m(){for(var y={},u=0;u<h.signers.length;++u){var v=h.signers[u],E=v.digestAlgorithm;E in y||(y[E]=o.md[o.pki.oids[E]].create()),v.authenticatedAttributes.length===0?v.md=y[E]:v.md=o.md[o.pki.oids[E]].create()}h.digestAlgorithmIdentifiers=[];for(var E in y)h.digestAlgorithmIdentifiers.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(E).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]));return y}function d(y){var u;if(h.detachedContent?u=h.detachedContent:(u=h.contentInfo.value[1],u=u.value[0]),!u)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var v=e.derToOid(h.contentInfo.value[0].value),E=e.toDer(u);E.getByte(),e.getBerValueLength(E),E=E.getBytes();for(var T in y)y[T].start().update(E);for(var _=new Date,w=0;w<h.signers.length;++w){var g=h.signers[w];if(g.authenticatedAttributes.length===0){if(v!==o.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{g.authenticatedAttributesAsn1=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var f=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[]),k=0;k<g.authenticatedAttributes.length;++k){var L=g.authenticatedAttributes[k];L.type===o.pki.oids.messageDigest?L.value=y[g.digestAlgorithm].digest():L.type===o.pki.oids.signingTime&&(L.value||(L.value=_)),f.value.push(c(L)),g.authenticatedAttributesAsn1.value.push(c(L))}E=e.toDer(f).getBytes(),g.md.start().update(E)}g.signature=g.key.sign(g.md,"RSASSA-PKCS1-V1_5")}h.signerInfos=l(h.signers)}},t.createEncryptedData=function(){var h=null;return h={type:o.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:o.pki.oids["aes256-CBC"]},fromAsn1:function(m){b(h,m,t.asn1.encryptedDataValidator)},decrypt:function(m){m!==void 0&&(h.encryptedContent.key=m),x(h)}},h},t.createEnvelopedData=function(){var h=null;return h={type:o.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:o.pki.oids["aes256-CBC"]},fromAsn1:function(m){var d=b(h,m,t.asn1.envelopedDataValidator);h.recipients=s(d.recipientInfos.value)},toAsn1:function(){return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.type).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(h.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,a(h.recipients)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,p(h.encryptedContent))])])])},findRecipient:function(m){for(var d=m.issuer.attributes,y=0;y<h.recipients.length;++y){var u=h.recipients[y],v=u.issuer;if(u.serialNumber===m.serialNumber&&v.length===d.length){for(var E=!0,T=0;T<d.length;++T)if(v[T].type!==d[T].type||v[T].value!==d[T].value){E=!1;break}if(E)return u}}return null},decrypt:function(m,d){if(h.encryptedContent.key===void 0&&m!==void 0&&d!==void 0)switch(m.encryptedContent.algorithm){case o.pki.oids.rsaEncryption:case o.pki.oids.desCBC:var y=d.decrypt(m.encryptedContent.content);h.encryptedContent.key=o.util.createBuffer(y);break;default:throw new Error("Unsupported asymmetric cipher, OID "+m.encryptedContent.algorithm)}x(h)},addRecipient:function(m){h.recipients.push({version:0,issuer:m.issuer.attributes,serialNumber:m.serialNumber,encryptedContent:{algorithm:o.pki.oids.rsaEncryption,key:m.publicKey}})},encrypt:function(m,d){if(h.encryptedContent.content===void 0){d=d||h.encryptedContent.algorithm,m=m||h.encryptedContent.key;var y,u,v;switch(d){case o.pki.oids["aes128-CBC"]:y=16,u=16,v=o.aes.createEncryptionCipher;break;case o.pki.oids["aes192-CBC"]:y=24,u=16,v=o.aes.createEncryptionCipher;break;case o.pki.oids["aes256-CBC"]:y=32,u=16,v=o.aes.createEncryptionCipher;break;case o.pki.oids["des-EDE3-CBC"]:y=24,u=8,v=o.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+d)}if(m===void 0)m=o.util.createBuffer(o.random.getBytes(y));else if(m.length()!=y)throw new Error("Symmetric key has wrong length; got "+m.length()+" bytes, expected "+y+".");h.encryptedContent.algorithm=d,h.encryptedContent.key=m,h.encryptedContent.parameter=o.util.createBuffer(o.random.getBytes(u));var E=v(m);if(E.start(h.encryptedContent.parameter.copy()),E.update(h.content),!E.finish())throw new Error("Symmetric encryption failed.");h.encryptedContent.content=E.output}for(var T=0;T<h.recipients.length;++T){var _=h.recipients[T];if(_.encryptedContent.content===void 0)switch(_.encryptedContent.algorithm){case o.pki.oids.rsaEncryption:_.encryptedContent.content=_.encryptedContent.key.encrypt(h.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+_.encryptedContent.algorithm)}}}},h};function r(h){var m={},d=[];if(!e.validate(h,t.asn1.recipientInfoValidator,m,d)){var y=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw y.errors=d,y}return{version:m.version.charCodeAt(0),issuer:o.pki.RDNAttributesAsArray(m.issuer),serialNumber:o.util.createBuffer(m.serial).toHex(),encryptedContent:{algorithm:e.derToOid(m.encAlgorithm),parameter:m.encParameter?m.encParameter.value:void 0,content:m.encKey}}}function n(h){return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(h.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[o.pki.distinguishedNameToAsn1({attributes:h.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,o.util.hexToBytes(h.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.encryptedContent.algorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,h.encryptedContent.content)])}function s(h){for(var m=[],d=0;d<h.length;++d)m.push(r(h[d]));return m}function a(h){for(var m=[],d=0;d<h.length;++d)m.push(n(h[d]));return m}function i(h){var m=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(h.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[o.pki.distinguishedNameToAsn1({attributes:h.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,o.util.hexToBytes(h.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.digestAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])]);if(h.authenticatedAttributesAsn1&&m.value.push(h.authenticatedAttributesAsn1),m.value.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.signatureAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])),m.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,h.signature)),h.unauthenticatedAttributes.length>0){for(var d=e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[]),y=0;y<h.unauthenticatedAttributes.length;++y){var u=h.unauthenticatedAttributes[y];d.values.push(c(u))}m.value.push(d)}return m}function l(h){for(var m=[],d=0;d<h.length;++d)m.push(i(h[d]));return m}function c(h){var m;if(h.type===o.pki.oids.contentType)m=e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.value).getBytes());else if(h.type===o.pki.oids.messageDigest)m=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,h.value.bytes());else if(h.type===o.pki.oids.signingTime){var d=new Date("1950-01-01T00:00:00Z"),y=new Date("2050-01-01T00:00:00Z"),u=h.value;if(typeof u=="string"){var v=Date.parse(u);isNaN(v)?u.length===13?u=e.utcTimeToDate(u):u=e.generalizedTimeToDate(u):u=new Date(v)}u>=d&&u<y?m=e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(u)):m=e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(u))}return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[m])])}function p(h){return[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(o.pki.oids.data).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.algorithm).getBytes()),h.parameter?e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,h.parameter.getBytes()):void 0]),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,h.content.getBytes())])]}function b(h,m,d){var y={},u=[];if(!e.validate(m,d,y,u)){var v=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw v.errors=v,v}var E=e.derToOid(y.contentType);if(E!==o.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(y.encryptedContent){var T="";if(o.util.isArray(y.encryptedContent))for(var _=0;_<y.encryptedContent.length;++_){if(y.encryptedContent[_].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");T+=y.encryptedContent[_].value}else T=y.encryptedContent;h.encryptedContent={algorithm:e.derToOid(y.encAlgorithm),parameter:o.util.createBuffer(y.encParameter.value),content:o.util.createBuffer(T)}}if(y.content){var T="";if(o.util.isArray(y.content))for(var _=0;_<y.content.length;++_){if(y.content[_].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");T+=y.content[_].value}else T=y.content;h.content=o.util.createBuffer(T)}return h.version=y.version.charCodeAt(0),h.rawCapture=y,y}function x(h){if(h.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(h.content===void 0){var m;switch(h.encryptedContent.algorithm){case o.pki.oids["aes128-CBC"]:case o.pki.oids["aes192-CBC"]:case o.pki.oids["aes256-CBC"]:m=o.aes.createDecryptionCipher(h.encryptedContent.key);break;case o.pki.oids.desCBC:case o.pki.oids["des-EDE3-CBC"]:m=o.des.createDecryptionCipher(h.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+h.encryptedContent.algorithm)}if(m.start(h.encryptedContent.parameter),m.update(h.encryptedContent.content),!m.finish())throw new Error("Symmetric decryption failed.");h.content=m.output}}return gi.exports}var mi={exports:{}},ts;function To(){if(ts)return mi.exports;ts=1;var o=xe();St(),Vt(),Fr(),Ot(),Ee();var e=mi.exports=o.ssh=o.ssh||{};e.privateKeyToPutty=function(s,a,i){i=i||"",a=a||"";var l="ssh-rsa",c=a===""?"none":"aes256-cbc",p="PuTTY-User-Key-File-2: "+l+`\r
|
|
235
|
-
`;p+="Encryption: "+c+`\r
|
|
236
|
-
`,p+="Comment: "+i+`\r
|
|
237
|
-
`;var b=o.util.createBuffer();r(b,l),t(b,s.e),t(b,s.n);var x=o.util.encode64(b.bytes(),64),h=Math.floor(x.length/66)+1;p+="Public-Lines: "+h+`\r
|
|
238
|
-
`,p+=x;var m=o.util.createBuffer();t(m,s.d),t(m,s.p),t(m,s.q),t(m,s.qInv);var d;if(!a)d=o.util.encode64(m.bytes(),64);else{var y=m.length()+16-1;y-=y%16;var u=n(m.bytes());u.truncate(u.length()-y+m.length()),m.putBuffer(u);var v=o.util.createBuffer();v.putBuffer(n("\0\0\0\0",a)),v.putBuffer(n("\0\0\0",a));var E=o.aes.createEncryptionCipher(v.truncate(8),"CBC");E.start(o.util.createBuffer().fillWithByte(0,16)),E.update(m.copy()),E.finish();var T=E.output;T.truncate(16),d=o.util.encode64(T.bytes(),64)}h=Math.floor(d.length/66)+1,p+=`\r
|
|
239
|
-
Private-Lines: `+h+`\r
|
|
240
|
-
`,p+=d;var _=n("putty-private-key-file-mac-key",a),w=o.util.createBuffer();r(w,l),r(w,c),r(w,i),w.putInt32(b.length()),w.putBuffer(b),w.putInt32(m.length()),w.putBuffer(m);var g=o.hmac.create();return g.start("sha1",_),g.update(w.bytes()),p+=`\r
|
|
241
|
-
Private-MAC: `+g.digest().toHex()+`\r
|
|
242
|
-
`,p},e.publicKeyToOpenSSH=function(s,a){var i="ssh-rsa";a=a||"";var l=o.util.createBuffer();return r(l,i),t(l,s.e),t(l,s.n),i+" "+o.util.encode64(l.bytes())+" "+a},e.privateKeyToOpenSSH=function(s,a){return a?o.pki.encryptRsaPrivateKey(s,a,{legacy:!0,algorithm:"aes128"}):o.pki.privateKeyToPem(s)},e.getPublicKeyFingerprint=function(s,a){a=a||{};var i=a.md||o.md.md5.create(),l="ssh-rsa",c=o.util.createBuffer();r(c,l),t(c,s.e),t(c,s.n),i.start(),i.update(c.getBytes());var p=i.digest();if(a.encoding==="hex"){var b=p.toHex();return a.delimiter?b.match(/.{2}/g).join(a.delimiter):b}else{if(a.encoding==="binary")return p.getBytes();if(a.encoding)throw new Error('Unknown encoding "'+a.encoding+'".')}return p};function t(s,a){var i=a.toString(16);i[0]>="8"&&(i="00"+i);var l=o.util.hexToBytes(i);s.putInt32(l.length),s.putBytes(l)}function r(s,a){s.putInt32(a.length),s.putString(a)}function n(){for(var s=o.md.sha1.create(),a=arguments.length,i=0;i<a;++i)s.update(arguments[i]);return s.digest()}return mi.exports}var yi,rs;function Ao(){return rs||(rs=1,yi=xe(),St(),vo(),gt(),Mr(),tr(),Co(),Vt(),bo(),Eo(),wo(),Dn(),jr(),_t(),_n(),zn(),So(),Hn(),kn(),Cn(),oi(),ot(),wn(),To(),Wn(),Ee()),yi}var vi=Ao();const _o="evtrsa1",xi=new Map;function is(o){return o.replace(/\/+$/,"")}function Io(o){return new TextEncoder().encode(o)}function or(o){let e="";return o.forEach(t=>{e+=String.fromCharCode(t)}),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}async function ko(o,e){const t=typeof AbortController<"u"?new AbortController:void 0,r=t?setTimeout(()=>t.abort(),e):void 0;try{const n=await fetch(o,{method:"GET",headers:{Accept:"application/json"},signal:t?.signal}),s=await n.json().catch(()=>({}));if(!n.ok){const a=s?.error?.message??s?.message??`ViewToken public key request failed with status ${n.status}`;throw new Error(a)}return s}finally{r!=null&&clearTimeout(r)}}function Ci(o){const e=globalThis.crypto;if(!e?.getRandomValues)throw new Error("[BimEngine] crypto.getRandomValues is required to encrypt viewToken");return e.getRandomValues(new Uint8Array(o))}function Bo(o){let e="";return o.forEach(t=>{e+=String.fromCharCode(t)}),e}function Mo(o){const e=new Uint8Array(o.length);for(let t=0;t<o.length;t+=1)e[t]=o.charCodeAt(t)&255;return e}async function Lo(o,e){const t=`${is(o)}/models/view-token/public-key`,r=await ko(t,e);if(r.algorithm!=="RSA-OAEP-256"||!r.publicKey)throw new Error("[BimEngine] OpenAPI returned an invalid viewToken public key");return vi.pki.publicKeyFromPem(r.publicKey)}function Ro(o,e){const t=is(o),r=xi.get(t);if(r)return r;const n=Lo(o,e).catch(s=>{throw xi.delete(t),s});return xi.set(t,n),n}async function No(o,e,t){const r=await Ro(o,t),n=Ci(32),s=Ci(12),a=Ci(16),i=JSON.stringify({viewToken:e,timestamp:Date.now(),nonce:or(a)}),l=r.encrypt(Bo(n),"RSA-OAEP",{md:vi.md.sha256.create(),mgf1:{md:vi.md.sha256.create()}}),c=go(n,s).encrypt(Io(i));return[_o,or(Mo(l)),or(s),or(c)].join(".")}function Po(o){return o.replace(/\/+$/,"")}async function Do(o,e,t){const r=typeof AbortController<"u"?new AbortController:void 0,n=r?setTimeout(()=>r.abort(),t):void 0;try{const s=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:r?.signal}),a=await s.json().catch(()=>({}));if(!s.ok){const i=a?.error?.message??a?.message??`ViewToken resolve failed with status ${s.status}`;throw new Error(i)}return a}finally{n!=null&&clearTimeout(n)}}function Uo(o){switch(o){case"2d":return"cad_model";case"720":return"panorama";case"gis":return"gis_scene";case"gaussian":return"gaussian_model";case"3d":default:return"model"}}function Vo(o){return{models:[{modelType:o.toLowerCase().endsWith(".json")?"3dtiles":"glb",url:o}]}}function Oo(o,e){return{applicationId:0,engineType:e,assetCategory:Uo(e),url:o,urls:[o],info:e==="gis"?Vo(o):void 0}}async function Fo(o,e,t){const r=o?.sdkAuth;if(!r?.endpoint)return Oo(e,t);let n;(r.token||r.appId&&r.appKey&&r.appSecret)&&(n=(await ja(o,t))?.sdkToken);const a={viewToken:await No(r.endpoint,e,r.timeoutMs??8e3),engineType:t};return n&&(a.sdkToken=n),Do(`${Po(r.endpoint)}/models/view-token/resolve`,a,r.timeoutMs??8e3)}class ns{options;container=null;animationId=null;isRendering=!1;fpsFrameCount=0;fpsLastCheck=0;currentFps=0;enablePerformanceMonitoring=!1;stats;modelToolModule2d;engineStatus2d;octreeBox2d;events;handelBehaved2d;interactionModule2d;sceneModule2d;cameraModule2d;renderModule2d;controlModule2d;loaderModule2d;layerManager;searchManager;themeManager;measure;markup;label;viewCube;cadCursorUI;contextMenuUI;loadingUI;workspaceTabsUI;versionEl=null;linkView2d3d;linkElement2d3d;scene=null;camera=null;renderer=null;dwgData=null;version=Mt;constructor(e){if(this.options=e,this.options.backgroundColor=this.options.backgroundColor??1710618,this.options.enablePerformanceMonitoring=this.options.enablePerformanceMonitoring??!1,this.options.showMouseCoordinates=this.options.showMouseCoordinates??!1,this.options.loadingStyle=this.options.loadingStyle??2,this.options.contextMenu=this.options.contextMenu??{items:[{action:"hideElement",label:"隐藏模型"},{action:"showAll",label:"显示全部"},{action:"hideLayer",label:"隐藏图层"},{action:"showAllLayers",label:"显示所有图层"},{action:"toggleBg",label:"切换背景"},{action:"layerManage",label:"图层管理"},{action:"linkElement2d3d",label:"模型联动",dividerBefore:!0}]},this.enablePerformanceMonitoring=e.enablePerformanceMonitoring??!1,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.initialize(),this.handelBehaved2d=ga(this),this.interactionModule2d=new ya(this),this.interactionModule2d.init(),this.interactionModule2d.active()}initialize(){this.events=new fs(!1),this.sceneModule2d=new ys(this,this.options),this.scene=this.sceneModule2d.scene,this.cameraModule2d=new xs(this,this.container),this.camera=this.cameraModule2d.orthographicCamera,this.renderModule2d=new As(this,this.container,this.options),this.renderer=this.renderModule2d.renderer,this.controlModule2d=new Is(this),this.loaderModule2d=new ua(this),this.themeManager=new Ta(this.container),this.layerManager=new Ri(this),this.searchManager=new Sa(this),this.measure=new ka(this),this.markup=new Ra(this),this.label=new Pa(this),this.viewCube=new Da(this),this.octreeBox2d=new ha(this),this.modelToolModule2d=new pa(this),this.engineStatus2d=new vs(this),this.linkView2d3d=new da(this),this.linkElement2d3d=new fa(this),this.sceneModule2d.initGrid(),this.cadCursorUI=new va(this.container,this.renderer.domElement,this.options.cursorStyle??"short-crosshair"),this.cadCursorUI.setBackgroundColor(this.options.backgroundColor??1710618),this.loadingUI=new Ca(this.container,this.options.loadingStyle),this.events.on(et.ModelLoadStart,()=>this.loadingUI.show("正在加载...",0)),this.events.on(et.ModelLoadProgress,e=>this.loadingUI.update(e.text,e.progress)),this.events.on(et.ModelLoaded,()=>this.loadingUI.hide()),this.events.on(et.ModelLoadError,()=>this.loadingUI.hide()),this.versionEl=document.createElement("div"),this.versionEl.className="engine-2d-version-text",this.updateVersionDisplay(),this.container.appendChild(this.versionEl),this.workspaceTabsUI=new Ua(this.container,this),this.contextMenuUI=new xa(this.container,this.renderer.domElement,e=>{if(e==="search"&&this.searchManager.show(),e==="layerManage"&&this.layerManager.toggle(),e==="hideElement"&&this.modelToolModule2d.hideModel(this.engineStatus2d.highlightModels),e==="showAll"&&this.modelToolModule2d.showAllModels(),e==="hideLayer"&&this.hideHighlightedLayers(),e==="showAllLayers"&&(this.layerManager.setAllLayersVisible(!0),this.layerManager.refresh()),e==="toggleBg"){const t=this.themeManager.getTheme()==="dark"?"light":"dark";this.setTheme(t)}if(e==="linkElement2d3d"){const t=this.linkElement2d3d.toggle();this.contextMenuUI.setMenuItemState("linkElement2d3d",t),!t&&!this.isModelSpaceActive()&&(this.modelToolModule2d.unHighlightModelHover(),this.modelToolModule2d.unhighlightAllModels()),console.log(`[EngineKernel2d] 二三维图元联动: ${t?"已开启":"已关闭"}`)}if(e==="linkView2d3d"){const t=this.linkView2d3d.toggle();this.contextMenuUI.setMenuItemState("linkView2d3d",t),console.log(`[EngineKernel2d] 图模关联: ${t?"已开启":"已关闭"}`)}},this.options.contextMenu?.items),this.contextMenuUI.setMenuItemStates({linkElement2d3d:this.linkElement2d3d.isEnabled(),linkView2d3d:this.linkView2d3d.isEnabled()}),this.initStatsMonitor(),this.startRendering(),console.log(`[EngineKernel2d] 2D Engine initialized (v${this.version})`)}startRendering(){this.isRendering||(this.isRendering=!0,this.fpsLastCheck=performance.now(),this.animate(),console.log("[EngineKernel2d] Rendering started"))}stopRendering(){this.isRendering=!1,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),console.log("[EngineKernel2d] Rendering stopped")}animate=()=>{this.isRendering&&(this.animationId=requestAnimationFrame(this.animate),this.stats?.begin(),this.controlModule2d.update(),this.camera?.updateMatrixWorld(!0),this.measure?.update(),this.markup?.update(),this.label?.update(),this.scene&&this.camera&&this.renderer&&(this.renderer.render(this.scene,this.camera),this.renderModule2d?.drawWatermark()),this.enablePerformanceMonitoring&&this.updatePerformanceStats(),this.stats?.end())};initStatsMonitor(){!(this.options.showStats??this.enablePerformanceMonitoring)||!this.container||(this.stats=new ds,this.stats.showPanel(0),this.stats.dom.className="engine-2d-stats-monitor",this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom))}updatePerformanceStats(){this.fpsFrameCount++;const e=performance.now();e-this.fpsLastCheck>=1e3&&(this.currentFps=this.fpsFrameCount,this.fpsFrameCount=0,this.fpsLastCheck=e,this.events.trigger(et.RenderEnd,{fps:this.currentFps}))}async loadModel(e,t){return await this.loaderModule2d.loadModel(e,t),{}}async loadModelFile(e,t){return await this.loaderModule2d.loadModelFile(e,t),{}}async loadModelByViewToken(e,t){const r=await Fo(this.options,e,"2d");if(r.assetCategory==="composite_model"&&r.urls.length>1)throw new Error("[BimEngine] 2D engine does not support composite_model viewToken loading");return this.loadModel(r.url,t)}getLayouts(){return this.loaderModule2d?.getLayouts()??[]}getActiveWorkspace(){return this.loaderModule2d?.getActiveWorkspace?.()??{type:"model",name:"模型"}}isModelSpaceActive(){return this.getActiveWorkspace().type==="model"}isElementLink2d3dEnabled(){return this.linkElement2d3d?.isEnabled?.()===!0}async loadLayout(e,t){await this.loaderModule2d.loadLayout(e,t)}async showModelSpace(e){await this.loaderModule2d.showModelSpace(e)}getLayers(){return this.loaderModule2d.getLayers()}getEntitiesByLayer(e){return this.loaderModule2d.getEntitiesByLayer(e)}setLayerVisible(e,t){this.layerManager?.setLayerVisible(e,t)}hideHighlightedLayers(){this.getLayersByModelIds(this.engineStatus2d?.highlightModels??[]).forEach(t=>this.layerManager?.setLayerVisible(t,!1)),this.layerManager?.refresh()}getLayersByModelIds(e){const t=new Set;return e.forEach(r=>{(this.loaderModule2d?.model?.nodeMap?.get(String(r))??this.loaderModule2d?.model?.nodeMap?.get(r))?.forEach(s=>{s?.layer&&t.add(s.layer)})}),Array.from(t)}setTheme(e){this.themeManager.setTheme(e);const t=e==="dark"?1710618:15790320;this.setBackgroundColor(t)}resetView(){this.cameraModule2d&&this.cameraModule2d.resetView()}fitToView(){const e=this.loaderModule2d?.getActiveWorkspaceExtents?.();if(this.getActiveWorkspace().type==="layout"&&e){this.cameraModule2d.fitToExtents(e);return}const t=this.dwgData?.metadata,r=t?.viewExtents??t?.extents;r&&this.cameraModule2d.fitToExtents(r)}setZoom(e){this.cameraModule2d&&this.cameraModule2d.setZoom(e)}getZoom(){return this.cameraModule2d?this.cameraModule2d.getZoom():1}updateVersionDisplay(){this.versionEl&&(this.versionEl.innerHTML=`v${this.version}`)}getPerformanceStats(){const e=this.sceneModule2d.getSceneStats();return{fps:this.currentFps,renderTime:0,entityCount:e.objectCount,visibleEntityCount:e.objectCount}}setBackgroundColor(e){this.options.backgroundColor=e,this.sceneModule2d&&this.sceneModule2d.setBackgroundColor(e),this.cadCursorUI?.setBackgroundColor(e),this.modelToolModule2d?.updateColorsForBackground(e),this.layerManager?.refresh()}clearScene(){this.sceneModule2d&&this.sceneModule2d.clearScene()}resize(){if(this.renderModule2d){const e=this.container?.clientWidth??0,t=this.container?.clientHeight??0;this.renderModule2d.setSize(e,t)}}captureImage(e){if(!this.renderer||!this.sceneModule2d)return console.error("[EngineKernel2d] Renderer or scene module not initialized"),null;const t=this.renderer.domElement,r=e?.format||"png",n=e?.quality||.92,s=`image/${r==="jpeg"?"jpeg":r}`,a=e?.transparent??!1,i=e?.hideGrid??!0,l=e?.hideAxes??!0,c=this.scene?.background??null;let p=!1,b=!1;this.sceneModule2d.adaptiveGrid&&(p=this.sceneModule2d.adaptiveGrid.gridGroup?.visible??!1,i&&this.sceneModule2d.adaptiveGrid.setVisible(!1)),this.sceneModule2d.axesHelper&&(b=this.sceneModule2d.axesHelper.visible??!1,l&&this.sceneModule2d.setAxesVisible(!1)),a&&this.scene&&(this.scene.background=null),this.scene&&this.camera&&(this.renderer.render(this.scene,this.camera),this.renderModule2d?.drawWatermark());const x=t.toDataURL(s,n);this.scene&&(this.scene.background=c),this.sceneModule2d.adaptiveGrid&&i&&this.sceneModule2d.adaptiveGrid.setVisible(p),this.sceneModule2d.axesHelper&&l&&this.sceneModule2d.setAxesVisible(b),this.scene&&this.camera&&(this.renderer.render(this.scene,this.camera),this.renderModule2d?.drawWatermark());const h={dataURL:x};if(e?.download){const m=e.filename||`capture-${Date.now()}.${r}`,d=document.createElement("a");d.href=x,d.download=m,d.style.display="none",document.body.appendChild(d),d.click(),d.remove(),console.log(`[EngineKernel2d] Image captured and downloaded: ${m}`)}else console.log("[EngineKernel2d] Image captured");return h}async captureImageAsync(e){if(!this.renderer||!this.sceneModule2d)return console.error("[EngineKernel2d] Renderer or scene module not initialized"),null;const t=this.renderer.domElement,r=e?.format||"png",n=e?.quality||.92,s=`image/${r==="jpeg"?"jpeg":r}`,a=e?.transparent??!1,i=e?.hideGrid??!0,l=e?.hideAxes??!0,c=this.scene?.background??null;let p=!1,b=!1;this.sceneModule2d.adaptiveGrid&&(p=this.sceneModule2d.adaptiveGrid.gridGroup?.visible??!1,i&&this.sceneModule2d.adaptiveGrid.setVisible(!1)),this.sceneModule2d.axesHelper&&(b=this.sceneModule2d.axesHelper.visible??!1,l&&this.sceneModule2d.setAxesVisible(!1)),a&&this.scene&&(this.scene.background=null),this.scene&&this.camera&&(this.renderer.render(this.scene,this.camera),this.renderModule2d?.drawWatermark());const x=t.toDataURL(s,n),h=await new Promise(d=>{t.toBlob(y=>{y&&d(y)},s,n)}),m=URL.createObjectURL(h);if(this.scene&&(this.scene.background=c),this.sceneModule2d.adaptiveGrid&&i&&this.sceneModule2d.adaptiveGrid.setVisible(p),this.sceneModule2d.axesHelper&&l&&this.sceneModule2d.setAxesVisible(b),this.scene&&this.camera&&(this.renderer.render(this.scene,this.camera),this.renderModule2d?.drawWatermark()),e?.download){const d=e.filename||`capture-${Date.now()}.${r}`,y=document.createElement("a");y.href=m,y.download=d,y.style.display="none",document.body.appendChild(y),y.click(),y.remove(),console.log(`[EngineKernel2d] Image captured and downloaded: ${d}`)}else console.log("[EngineKernel2d] Image captured with Blob URL:",m);return{dataURL:x,blobURL:m,blob:h}}dispose(){console.log("[EngineKernel2d] Disposing engine..."),this.stopRendering(),this.cadCursorUI?.dispose(),this.contextMenuUI?.dispose(),this.loadingUI?.dispose(),this.workspaceTabsUI?.dispose(),this.versionEl?.parentElement?.removeChild(this.versionEl),this.searchManager?.dispose(),this.measure?.dispose(),this.markup?.dispose(),this.label?.dispose(),this.themeManager?.dispose(),this.loaderModule2d?.dispose(),this.controlModule2d?.dispose(),this.renderModule2d?.dispose(),this.cameraModule2d?.dispose(),this.sceneModule2d?.dispose(),this.events?.dispose(),this.stats?.dom?.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.scene=null,this.camera=null,this.renderer=null,this.dwgData=null,this.stats=void 0,this.versionEl=null,console.log("[EngineKernel2d] Engine disposed")}}function ss(o){return new ns(o)}pt.EngineKernel2d=ns,pt.createEngine2d=ss,pt.default=ss,Object.defineProperties(pt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|