iflow-engine-base-3d 3.11.9 → 3.11.10
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 +8 -8
- package/dist/bim-engine-sdk.umd.js +1 -1
- package/dist/chunks/{engine-2d-Cdx92TJC.js → engine-2d-qvKNkmsX.js} +3 -3
- package/dist/chunks/{engine-3d-VekalXKk.js → engine-3d-BFrs6D9y.js} +4 -4
- package/dist/chunks/{engine-720-BflVxaCW.js → engine-720-BUjyPT_z.js} +1 -1
- package/dist/chunks/{engine-gaussian-BvBnOzs7.js → engine-gaussian-BtzqhQBu.js} +1 -1
- package/dist/chunks/{engine-gis-CAaUGGxe.js → engine-gis-CCukjsHp.js} +2 -2
- package/dist/chunks/{sdk-assets-DqNgQXE8.js → sdk-assets-CemZeVpH.js} +1 -1
- package/dist/chunks/{sdk-runtime-DolL9SrM.js → sdk-runtime-DE-ZoMSy.js} +2 -2
- package/dist/chunks/{sdk-vendor-CKU476P9.js → sdk-vendor-8NuRpL1E.js} +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as n, a as r, b as i } from "./chunks/sdk-assets-
|
|
2
|
-
import { g as u, r as y } from "./chunks/sdk-assets-
|
|
3
|
-
import { E as h } from "./chunks/engine-3d-
|
|
1
|
+
import { s as n, a as r, b as i } from "./chunks/sdk-assets-CemZeVpH.js";
|
|
2
|
+
import { g as u, r as y } from "./chunks/sdk-assets-CemZeVpH.js";
|
|
3
|
+
import { E as h } from "./chunks/engine-3d-BFrs6D9y.js";
|
|
4
4
|
const l = {
|
|
5
5
|
Initialized: "gis:initialized",
|
|
6
6
|
CameraChanged: "gis:camera-changed",
|
|
@@ -17,27 +17,27 @@ async function t(e) {
|
|
|
17
17
|
}
|
|
18
18
|
async function c(e) {
|
|
19
19
|
await t(e);
|
|
20
|
-
const { EngineKernelV2: a } = await import("./chunks/engine-3d-
|
|
20
|
+
const { EngineKernelV2: a } = await import("./chunks/engine-3d-BFrs6D9y.js").then((s) => s.a);
|
|
21
21
|
return new a(e);
|
|
22
22
|
}
|
|
23
23
|
async function g(e) {
|
|
24
24
|
await t(e);
|
|
25
|
-
const { EngineKernel2d: a } = await import("./chunks/engine-2d-
|
|
25
|
+
const { EngineKernel2d: a } = await import("./chunks/engine-2d-qvKNkmsX.js").then((s) => s.E);
|
|
26
26
|
return new a(e);
|
|
27
27
|
}
|
|
28
28
|
async function o(e) {
|
|
29
29
|
await t(e);
|
|
30
|
-
const { EngineKernel720: a } = await import("./chunks/engine-720-
|
|
30
|
+
const { EngineKernel720: a } = await import("./chunks/engine-720-BUjyPT_z.js");
|
|
31
31
|
return new a(e);
|
|
32
32
|
}
|
|
33
33
|
async function w(e) {
|
|
34
34
|
await t(e);
|
|
35
|
-
const { EngineKernelGaussian: a } = await import("./chunks/engine-gaussian-
|
|
35
|
+
const { EngineKernelGaussian: a } = await import("./chunks/engine-gaussian-BtzqhQBu.js");
|
|
36
36
|
return new a(e);
|
|
37
37
|
}
|
|
38
38
|
async function E(e) {
|
|
39
39
|
await t(e);
|
|
40
|
-
const { EngineKernelGIS: a } = await import("./chunks/engine-gis-
|
|
40
|
+
const { EngineKernelGIS: a } = await import("./chunks/engine-gis-CCukjsHp.js").then((s) => s.E);
|
|
41
41
|
return new a(e);
|
|
42
42
|
}
|
|
43
43
|
export {
|
|
@@ -6012,7 +6012,7 @@ void main() {
|
|
|
6012
6012
|
|
|
6013
6013
|
gl_FragColor = vec4(color, clamp(alpha, 0.0, 1.0));
|
|
6014
6014
|
}
|
|
6015
|
-
`});return h.clippingPlanes=this.engine.sectionPlane,n.alwaysOnTop&&(h.depthTest=!1),h}createPulseMaterial(e,n,i,r,s,o,a){return this.createSurfaceMaterial({color:`#${e.getHexString()}`,opacity:n,style:i,effect:{...r,pulse:r.pulse?.enabled?r.pulse:{enabled:!0,speed:1.4,minOpacity:.55,maxOpacity:1}},axisMode:s,axisMin:o,axisMax:a})}axisModeToNumber(e){return e==="x"?0:e==="y"?1:e==="z"?2:e==="uvx"?3:4}getGradientStops(e,n){if(!Array.isArray(n)||n.length===0)return[{offset:0,color:e,alpha:1},{offset:1,color:e,alpha:.08}];const i=[...n].sort((o,a)=>o.offset-a.offset),r=i[0],s=i[i.length-1];return[{offset:0,color:r.color,alpha:r.alpha??1},{offset:1,color:s.color,alpha:s.alpha??.08}]}}const UM={color:"#7ffcff",opacity:.92,fillColor:"#7ffcff",fillOpacity:.18,depthTest:!0,alwaysOnTop:!1,lineWidth:.18,point:{mode:"sprite",size:0,iconSize:32,billboard:!0,anchorY:0},line:{dashed:!1,closed:!1},polygon:{showEdge:!0,edgeColor:"#d9ffff",edgeWidth:1},volume:{height:10,showTop:!0,showSide:!0,showBottom:!1,edgeColor:"#d9ffff"}},IKe={background:"rgba(10, 18, 28, 0.92)",color:"#ffffff",border:"1px solid rgba(127, 252, 255, 0.72)",borderRadius:"10px",padding:"12px",boxShadow:"0 10px 30px rgba(0, 0, 0, 0.32)",minWidth:"120px",pointerEvents:"auto"},MKe="bim-engine-annotation3d-panels";class PKe{normalizeData(e){return{...e,id:e.id??`annotation3d-${Date.now()}-${Math.random().toString(16).slice(2)}`,points:_F(e.points??[]),visible:e.visible??!0,selectable:e.selectable??!0,style:this.mergeStyle(e.style),effect:this.mergeEffect(e.effect),panel:e.panel?this.normalizePanel(e.panel):void 0}}mergeData(e,n,i,r){const s=i.panel===void 0?e.panel?{...e.panel,actions:n}:void 0:i.panel==null?void 0:{...e.panel,...i.panel,style:{...e.panel?.style??{},...i.panel.style??{}},actions:i.panel.actions??n};return this.normalizeData({id:r,type:i.type??e.type,points:i.points?_F(i.points):_F(e.points),visible:i.visible??e.visible,selectable:i.selectable??e.selectable,style:{...e.style,...i.style??{},point:{...e.style.point??{},...i.style?.point??{}},line:{...e.style.line??{},...i.style?.line??{}},polygon:{...e.style.polygon??{},...i.style?.polygon??{}},volume:{...e.style.volume??{},...i.style?.volume??{}}},effect:{...e.effect,...i.effect??{}},panel:s,data:i.data??e.data})}mergeStyle(e){return{...UM,...e,point:{...UM.point,...e?.point??{}},line:{...UM.line,...e?.line??{}},polygon:{...UM.polygon,...e?.polygon??{}},volume:{...UM.volume,...e?.volume??{}}}}mergeEffect(e){return{...e,gradient:e?.gradient?{enabled:e.gradient.enabled,direction:e.gradient.direction??"vertical",stops:e.gradient.stops??[]}:void 0,glow:e?.glow?{...e.glow}:void 0,flow:e?.flow?{enabled:e.flow.enabled,speed:e.flow.speed??.6,width:e.flow.width??.18,direction:e.flow.direction??"forward"}:void 0,pulse:e?.pulse?{enabled:e.pulse.enabled,speed:e.pulse.speed??1.4,minOpacity:e.pulse.minOpacity??.55,maxOpacity:e.pulse.maxOpacity??1}:void 0,ripple:e?.ripple?{enabled:e.ripple.enabled,count:e.ripple.count??2,speed:e.ripple.speed??.9,maxRadius:e.ripple.maxRadius??12}:void 0,pillar:e?.pillar?{enabled:e.pillar.enabled,height:e.pillar.height??16,width:e.pillar.width??1.5}:void 0,baseRing:e?.baseRing?{enabled:e.baseRing.enabled,radius:e.baseRing.radius??3,rotateSpeed:e.baseRing.rotateSpeed??.8}:void 0,layers:e?.layers?{enabled:e.layers.enabled,count:e.layers.count??3,offsetY:e.layers.offsetY??3}:void 0,scan:e?.scan?{enabled:e.scan.enabled,speed:e.scan.speed??.8,width:e.scan.width??.18}:void 0}}normalizePanel(e){return{visible:e.visible??!0,trigger:e.trigger??"manual",mode:e.mode??(e.html?"html":"text"),text:e.text??"",html:e.html??"",anchor:e.anchor,offset:{...e.offset??{}},screenOffset:{...e.screenOffset??{}},className:e.className,style:{...IKe,...e.style??{}},interactive:e.interactive??!0,occlusion:e.occlusion??"show",actions:e.actions}}}function DKe(t,e,n){const i=t.camera;if(!i)return!1;const r=n.clone().sub(i.position),s=r.length();if(s<=1e-6)return!1;e.set(i.position,r.normalize());let o=t.octreeBox?.rayInterationModel?.(e,!0,!1)??[];o=t.clipping?.filterIntersectionsByClipping?.(o)??o;const a=o.sort((c,l)=>c.distance-l.distance)[0];return!!(a&&a.distance<s-.05)}class RKe{constructor(e,n){this.engine=e,this.isAnchorOccluded=n,this.container=document.createElement("div"),this.container.className=MKe,this.container.style.cssText=["position:absolute","left:0","top:0","width:100%","height:100%","pointer-events:none","overflow:hidden","z-index:1250"].join(";"),this.engine.container.appendChild(this.container),this.worldToScreen=new ua(this.engine.camera,this.engine.renderer,this.engine.scene)}container;worldToScreen;updateProjectionState(){this.worldToScreen.updateCamera(this.engine.camera),this.worldToScreen.updateRenderer(this.engine.renderer),this.worldToScreen.updateScene(this.engine.scene)}createPanelElement(e,n){const i=document.createElement("div");return i.className=`bim-annotation3d-panel ${n.className??""}`.trim(),i.dataset.annotationId=e.id,i.style.cssText=["position:absolute","left:0","top:0","transform:translate(-50%, -100%)","display:none",n.interactive===!1?"pointer-events:none":"pointer-events:auto"].join(";"),n.mode==="html"?i.innerHTML=n.html??"":i.textContent=n.text??"",Object.entries(n.style??{}).forEach(([r,s])=>{i.style.setProperty(CKe(r),s)}),i}updateRecord(e){if(!e.panelElement||!e.instance.panel)return;const n=e.instance.panel;if(!(n.visible!==!1&&this.shouldShowPanel(e))||!e.instance.visible){e.panelElement.style.display="none";return}const r=this.getPanelAnchorPoint(e),s=this.worldToScreen.worldToScreenIfVisible(r);if(!s){e.panelElement.style.display="none";return}if(n.occlusion==="hide"&&this.isAnchorOccluded(r)){e.panelElement.style.display="none";return}const o=n.screenOffset??{};e.panelElement.style.display="block",e.panelElement.style.left=`${s.x+(o.x??0)}px`,e.panelElement.style.top=`${s.y+(o.y??0)}px`}dispose(){this.container.remove()}shouldShowPanel(e){const n=e.instance.panel?.trigger??"manual";return n==="always"?!0:n==="hover"?e.instance.hovered:n==="click"||n==="manual"?e.instance.panelVisible:!1}getPanelAnchorPoint(e){const n=e.instance.panel?.anchor??EKe(e.instance.type),i=e.instance.panel?.offset??{};let r=new H;if(e.instance.type==="point")r.copy(Hh(e.instance.points[0])),n==="top"&&(r.y+=e.volumeHeight??e.instance.style.point?.anchorY??0);else if(e.instance.type==="polyline")n==="start"?r.copy(Hh(e.instance.points[0])):n==="end"?r.copy(Hh(e.instance.points[e.instance.points.length-1])):e.anchorCurve?r.copy(e.anchorCurve.getPoint(.5)):r.copy(AF(e.instance.points));else if(e.instance.type==="polygon")r.copy(AF(e.instance.points));else if(e.instance.type==="extrudePolygon")r.copy(AF(e.instance.points)),n==="top"&&e.anchorNormal&&r.add(e.anchorNormal.clone().multiplyScalar(e.volumeHeight??0));else if(e.instance.type==="box"&&(r.copy(AF(e.instance.points)),n==="top"&&e.instance.points.length>=2)){const s=Hh(e.instance.points[0]),o=Hh(e.instance.points[1]);r.y=Math.max(s.y,o.y)}return r.add(new H(i.x??0,i.y??0,i.z??0)),r}}class OKe{engine;rootGroup;records;panelContainer;onRecordVisualChange;onEmit;raycaster=new Da;hoveredId=null;constructor(e){this.engine=e.engine,this.rootGroup=e.rootGroup,this.records=e.records,this.panelContainer=e.panelContainer,this.onRecordVisualChange=e.onRecordVisualChange,this.onEmit=e.onEmit}bind(){this.engine.renderer?.domElement?.addEventListener?.("click",this.handleCanvasClick,!1),this.engine.renderer?.domElement?.addEventListener?.("mousemove",this.handleCanvasMove,!1),this.engine.renderer?.domElement?.addEventListener?.("mouseleave",this.handleCanvasLeave,!1),this.panelContainer.addEventListener("click",this.handlePanelClick,!1)}unbind(){this.engine.renderer?.domElement?.removeEventListener?.("click",this.handleCanvasClick,!1),this.engine.renderer?.domElement?.removeEventListener?.("mousemove",this.handleCanvasMove,!1),this.engine.renderer?.domElement?.removeEventListener?.("mouseleave",this.handleCanvasLeave,!1),this.panelContainer.removeEventListener("click",this.handlePanelClick,!1)}handleRecordRemoved(e){this.hoveredId===e&&(this.hoveredId=null)}pickAnnotation(e){const n=this.engine.renderer?.domElement,i=this.engine.camera;if(!n||!i)return null;const r=n.getBoundingClientRect(),s=e.clientX-r.left,o=e.clientY-r.top,a=new Ye(s/r.width*2-1,-(o/r.height)*2+1);this.raycaster.setFromCamera(a,i);const c=this.raycaster.intersectObjects(this.rootGroup.children,!0);for(const l of c){let u=l.object;for(;u;){const h=u.userData?.annotationId;if(h&&this.records.has(h)){const d=this.records.get(h);return d.instance.selectable!==!1&&d.instance.visible?d:null}u=u.parent}}return null}handleCanvasClick=e=>{const n=this.pickAnnotation(e);n&&(n.instance.panel?.trigger==="click"&&(n.instance.panelVisible=!n.instance.panelVisible,this.onRecordVisualChange(n),this.onEmit(n.instance.panelVisible?"annotation3d-panel-open":"annotation3d-panel-close",this.toEventPayload(n,e))),this.onEmit("annotation3d-click",this.toEventPayload(n,e)))};handleCanvasMove=e=>{const n=this.pickAnnotation(e),i=n?.instance.id??null;if(i!==this.hoveredId){if(this.hoveredId&&this.records.has(this.hoveredId)){const r=this.records.get(this.hoveredId);r.instance.hovered=!1,this.onRecordVisualChange(r),this.onEmit("annotation3d-leave",this.toEventPayload(r,e))}this.hoveredId=i,n&&(n.instance.hovered=!0,this.onRecordVisualChange(n),this.onEmit("annotation3d-hover",this.toEventPayload(n,e)))}};handleCanvasLeave=e=>{if(!this.hoveredId||!this.records.has(this.hoveredId)){this.hoveredId=null;return}const n=this.records.get(this.hoveredId);n.instance.hovered=!1,this.onRecordVisualChange(n),this.onEmit("annotation3d-leave",this.toEventPayload(n,e)),this.hoveredId=null};handlePanelClick=e=>{const n=e.target;if(!n)return;const i=n.closest("[data-annotation-id]");if(!i)return;const r=i.dataset.annotationId;if(!r||!this.records.has(r))return;const s=this.records.get(r);this.onEmit("annotation3d-panel-click",this.toEventPayload(s,e));const o=n.closest("[data-action]"),a=o?.dataset?.action;if(!a||!s.actions?.[a])return;const c={engine:this.engine,id:r,annotation:s.instance,action:a,element:o,originalEvent:e};s.actions[a]?.(c),this.onEmit("annotation3d-action",{...this.toEventPayload(s,e),action:a,target:o})};toEventPayload(e,n){return{id:e.instance.id,annotation:e.instance,originalEvent:n}}}function LKe(t){const{actions:e,...n}=t;return n}function BKe(t){return{id:t.instance.id,type:t.instance.type,points:_F(t.instance.points),visible:t.instance.visible,selectable:t.instance.selectable,style:yF(t.instance.style),effect:yF(t.instance.effect),panel:t.instance.panel?yF(t.instance.panel):void 0,data:yF(t.instance.data)}}function yF(t){return t===void 0?t:JSON.parse(JSON.stringify(t))}class NKe{engine;rootGroup;records=new Map;textureLoader=new Bd;occlusionRaycaster=new Da;normalizer=new PKe;materialFactory;geometryBuilder;effectsController;panelLayer;interaction;currentTime=0;constructor(e){this.engine=e,this.rootGroup=new $r,this.rootGroup.name="Annotation3dRoot",this.engine.scene.add(this.rootGroup),this.materialFactory=new SKe(this.engine),this.geometryBuilder=new wKe(this.engine,this.textureLoader,this.materialFactory),this.effectsController=new TKe(this.engine),this.panelLayer=new RKe(this.engine,n=>DKe(this.engine,this.occlusionRaycaster,n)),this.interaction=new OKe({engine:this.engine,rootGroup:this.rootGroup,records:this.records,panelContainer:this.panelLayer.container,onRecordVisualChange:n=>this.panelLayer.updateRecord(n),onEmit:(n,i)=>this.emit(n,i)}),this.interaction.bind()}add(e){const n=this.normalizer.normalizeData(e),i=this.buildRecord(n);return this.attachRecord(i),this.emit("annotation3d-created",this.toEventPayload(i)),n.id}addMany(e){return e.map(n=>this.add(n))}async pickPoint(){if(typeof this.engine.label?.pickPoint!="function")return null;const e=await this.engine.label.pickPoint();return e==null?null:{x:e.x,y:e.y,z:e.z}}update(e,n){const i=this.records.get(e);if(!i)return!1;const r=this.normalizer.mergeData(i.instance,i.actions,n,e);this.removeInternal(e,!1);const s=this.buildRecord(r);return this.attachRecord(s),this.emit("annotation3d-updated",this.toEventPayload(s)),!0}remove(e){return this.removeInternal(e,!0)}clear(){Array.from(this.records.keys()).forEach(e=>this.removeInternal(e,!1))}get(e){return this.records.get(e)?.instance}getAll(){return Array.from(this.records.values()).map(e=>e.instance)}show(e){return this.setVisible(e,!0)}hide(e){return this.setVisible(e,!1)}setVisible(e,n){const i=this.records.get(e);return i?(i.instance.visible=n,this.applyVisibility(i),!0):!1}showPanel(e){const n=this.records.get(e);return!n||!n.instance.panel?!1:(n.instance.panelVisible=!0,this.panelLayer.updateRecord(n),this.emit("annotation3d-panel-open",this.toEventPayload(n)),!0)}hidePanel(e){const n=this.records.get(e);return!n||!n.instance.panel?!1:(n.instance.panelVisible=!1,this.panelLayer.updateRecord(n),this.emit("annotation3d-panel-close",this.toEventPayload(n)),!0)}togglePanel(e){const n=this.records.get(e);return!n||!n.instance.panel?!1:n.instance.panelVisible?this.hidePanel(e):this.showPanel(e)}updatePanel(e,n){const i=this.records.get(e);if(!i||!i.instance.panel)return!1;const r={...i.instance.panel,...n,style:{...i.instance.panel.style??{},...n.style??{}},actions:n.actions??i.actions};return this.update(e,{panel:r})}getData(){return Array.from(this.records.values()).map(e=>BKe(e))}restoreData(e){this.clear(),e.forEach(n=>this.add(n))}updateFrame(e=1/60){this.currentTime+=e,this.panelLayer.updateProjectionState(),this.records.forEach(n=>{this.effectsController.updateRecord(n,this.currentTime),this.panelLayer.updateRecord(n)})}dispose(){this.interaction.unbind(),this.clear(),this.rootGroup.removeFromParent(),this.panelLayer.dispose()}buildRecord(e){const n=new $r;n.name=e.id;const i={id:e.id,type:e.type,points:e.points,visible:e.visible??!0,selectable:e.selectable??!0,style:e.style,effect:e.effect??{},panel:e.panel?LKe(e.panel):void 0,data:e.data,panelVisible:e.panel?.trigger==="always",hovered:!1,root:n},r={instance:i,actions:e.panel?.actions,panelElement:e.panel?this.panelLayer.createPanelElement(i,e.panel):null,timeSeed:Math.random()*Math.PI*2,pulseMaterials:[],rippleMeshes:[],baseRingMeshes:[],animatedMaterials:[]};return this.geometryBuilder.build(r),vKe(n,i.id),r}attachRecord(e){this.records.set(e.instance.id,e),this.rootGroup.add(e.instance.root),e.panelElement&&this.panelLayer.container.appendChild(e.panelElement),this.applyVisibility(e)}removeInternal(e,n){const i=this.records.get(e);return i?(this.interaction.handleRecordRemoved(e),xKe(i.instance.root),i.instance.root.removeFromParent(),i.panelElement?.remove(),this.records.delete(e),n&&this.emit("annotation3d-removed",{id:e}),!0):!1}applyVisibility(e){e.instance.root.visible=e.instance.visible,e.instance.style.alwaysOnTop&&e.instance.root.traverse(n=>{n.renderOrder=Math.max(n.renderOrder,1200)}),this.panelLayer.updateRecord(e)}toEventPayload(e,n){return{id:e.instance.id,annotation:e.instance,originalEvent:n}}emit(e,n){this.engine.events?.trigger?.(e,n)}}class ww{constructor(e){this.engine=e}static svgNamespace="http://www.w3.org/2000/svg";static sourceColor="#00bcd4";static targetColor="#ff9800";matrices=new Map;pointCalibrationUrl=null;pointCalibrationPoints=[];behavior;type="point-calibration";apply(e){if(!e?.url||e.matrix==null)return!1;const n=this.toThreeMatrix(e.matrix),i=FE(this.engine,e.url);return i.matrixAutoUpdate=!1,i.matrix.copy(n),i.matrixWorldNeedsUpdate=!0,i.updateMatrixWorld(!0),this.clearRuntimeWorldBoxCache(i),this.engine.octreeBox?.invalidateModelWorldCache?.(e.url),this.matrices.set(e.url,n.clone()),this.updateCachedModelBox(e.url,i),this.engine.modelEdge?.setModelEdgeTransform?.(e.url,n),this.engine.requestComposerRender?.(),!0}setCalibration(e){return this.apply(e)}alignBySegments(e){if(!e?.url||e.source==null||e.target==null)return!1;const n=this.toVector3(e.source.start),i=this.toVector3(e.source.end),r=this.toVector3(e.target.start),s=this.toVector3(e.target.end),o=i.clone().sub(n),a=s.clone().sub(r);if(o.lengthSq()<1e-10||a.lengthSq()<1e-10)throw new Error("[Calibration] source and target segments must have valid length");o.normalize(),a.normalize();const c=new xt().makeRotationFromQuaternion(new ni().setFromUnitVectors(o,a)),l=new xt().makeTranslation(r.x,r.y,r.z).multiply(c).multiply(new xt().makeTranslation(-n.x,-n.y,-n.z)),u=this.getMatrix(e.url);return this.apply({url:e.url,matrix:l.multiply(u)})}startPointCalibration(e){return!e?.url||(this.behavior=this.engine.handelBehaved,!this.behavior?.init||!this.behavior?.active||!this.behavior?.disActive)?!1:(this.pointCalibrationUrl=e.url,this.pointCalibrationPoints=[],this.engine.setIdleFrameRateExempt?.("point-calibration",!0),this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.behavior.isClickSimpleModel=!1,!0)}handleMouseClick(e){const n=e?.catch?.point;if(!(n instanceof H)||this.pointCalibrationUrl==null)return;if(this.pointCalibrationPoints.push(n.clone()),this.pointCalibrationPoints.length!==4){this.drawPointCalibrationOverlay(n);return}const[i,r,s,o]=this.pointCalibrationPoints;try{this.alignBySegments({url:this.pointCalibrationUrl,source:{start:i,end:r},target:{start:s,end:o}})}catch(a){console.warn("四点模型校准失败:",a)}this.finishPointCalibration()}handleMouseMove(e){const n=e?.catch?.point;this.drawPointCalibrationOverlay(n instanceof H?n:null)}handelKeyEscDown(){this.finishPointCalibration()}disActive(){this.engine.setIdleFrameRateExempt?.("point-calibration",!1),this.pointCalibrationPoints=[],this.pointCalibrationUrl=null,this.clearPointCalibrationOverlay(),this.behavior?.disActive()}finishPointCalibration(){this.disActive(),this.engine.interactionModule?.init?.(),this.engine.interactionModule?.active?.()}drawPointCalibrationOverlay(e){const n=this.engine.catchSvg;if(n==null)return;n.innerHTML="";const i=this.pointCalibrationPoints,r=i.slice(0,2),s=i.slice(2,4);this.drawCalibrationSegment(n,r,ww.sourceColor,i.length<2?e:null),this.drawCalibrationSegment(n,s,ww.targetColor,i.length>=2&&i.length<4?e:null)}drawCalibrationSegment(e,n,i,r){const s=n.map(a=>this.toSvgPoint(a)).filter(a=>a!=null),o=r==null?null:this.toSvgPoint(r);s.length===2&&this.appendSvgLine(e,s[0],s[1],i),s.length===1&&o!=null&&this.appendSvgLine(e,s[0],o,i,!0),s.forEach(a=>this.appendSvgPoint(e,a,i)),o!=null&&this.appendSvgPoint(e,o,i,!0)}toSvgPoint(e){const n=this.engine.worldToScreen?.worldToScreenIfVisible?.(e)??this.engine.worldToScreen?.worldToScreen?.(e);if(n==null||!Number.isFinite(n.x)||!Number.isFinite(n.y))return null;const i=this.engine.reactBoundingClientRect;return new Ye(n.x+(Number.isFinite(i?.left)?i.left:0),n.y+(Number.isFinite(i?.top)?i.top:0))}appendSvgLine(e,n,i,r,s=!1){const o=document.createElementNS(ww.svgNamespace,"line");o.setAttribute("x1",`${n.x}`),o.setAttribute("y1",`${n.y}`),o.setAttribute("x2",`${i.x}`),o.setAttribute("y2",`${i.y}`),o.setAttribute("stroke",r),o.setAttribute("stroke-width",s?"2":"3"),s&&o.setAttribute("stroke-dasharray","6 4"),e.appendChild(o)}appendSvgPoint(e,n,i,r=!1){const s=document.createElementNS(ww.svgNamespace,"circle");s.setAttribute("cx",`${n.x}`),s.setAttribute("cy",`${n.y}`),s.setAttribute("r",r?"6":"5"),s.setAttribute("fill",r?"transparent":i),s.setAttribute("fill-opacity",r?"0":"1"),s.setAttribute("stroke",i),s.setAttribute("stroke-width",r?"2":"1"),r&&s.setAttribute("stroke-dasharray","3 2"),e.appendChild(s)}clearPointCalibrationOverlay(){this.engine.catchSvg&&(this.engine.catchSvg.innerHTML="")}getMatrix(e){const n=this.matrices.get(e);if(n!=null)return n.clone();const i=$b(this.engine,e);return i==null?new xt:i.matrix.clone()}clear(e){const n=$b(this.engine,e);return n==null?!1:(n.matrixAutoUpdate=!1,n.matrix.identity(),n.matrixWorldNeedsUpdate=!0,n.updateMatrixWorld(!0),this.clearRuntimeWorldBoxCache(n),this.engine.octreeBox?.invalidateModelWorldCache?.(e),this.matrices.delete(e),this.updateCachedModelBox(e,n),this.engine.modelEdge?.setModelEdgeTransform?.(e,new xt),this.engine.requestComposerRender?.(),!0)}updateCachedModelBox(e,n){const i=this.engine.models?.find?.(s=>s.url===e);if(i?.boundingBox==null)return;i.localBoundingBox==null&&(i.localBoundingBox={min:i.boundingBox.min.clone(),max:i.boundingBox.max.clone()});const r=new Ln(i.localBoundingBox.min.clone(),i.localBoundingBox.max.clone());n.updateWorldMatrix(!0,!1),r.applyMatrix4(n.matrixWorld),i.boundingBox={min:r.min,max:r.max}}clearRuntimeWorldBoxCache(e){e.traverse(n=>{n?.box instanceof Ln&&delete n.box})}toThreeMatrix(e){if(e instanceof xt)return e.clone();if(Array.isArray(e)&&Array.isArray(e[0])){const i=e;if(i.length!==4||i.some(r=>!Array.isArray(r)||r.length!==4))throw new Error("[Calibration] matrix must be a 4x4 array");return new xt().set(i[0][0],i[0][1],i[0][2],i[0][3],i[1][0],i[1][1],i[1][2],i[1][3],i[2][0],i[2][1],i[2][2],i[2][3],i[3][0],i[3][1],i[3][2],i[3][3])}const n=Array.from(e);if(n.length!==16)throw new Error("[Calibration] matrix must contain 16 numbers");return new xt().fromArray(n)}toVector3(e){if(e instanceof H)return e.clone();if(Array.isArray(e)){if(e.length!==3)throw new Error("[Calibration] point array must contain 3 numbers");return new H(e[0],e[1],e[2])}return"x"in e?new H(e.x,e.y,e.z):new H(e.X,e.Y,e.Z)}}const FKe=.001,kKe=.65,UKe=1;class zKe{engine;loader=new Mj;modelList=new Map;modelTransforms=[];transformControl=null;transformHelper=null;selectedModelId=null;copiedModelData=null;editingEnabled=!1;isRestoring=!1;isUndoing=!1;isPasting=!1;pendingModelIds=new Set;bimHighlightDisabledBeforeEditing=null;selectionPointerDown=null;onPointerDown;onPointerUp;onKeyDown;constructor(e){this.engine=e,this.onPointerDown=this.handlePointerDown.bind(this),this.onPointerUp=this.handlePointerUp.bind(this),this.onKeyDown=this.handleKeyDown.bind(this),this.engine.renderer?.domElement?.addEventListener("pointerdown",this.onPointerDown),this.engine.renderer?.domElement?.addEventListener("pointerup",this.onPointerUp),window.addEventListener("keydown",this.onKeyDown),this.ensureTransformControl()}dispose(){this.engine.renderer?.domElement?.removeEventListener("pointerdown",this.onPointerDown),this.engine.renderer?.domElement?.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("keydown",this.onKeyDown),this.transformControl?.detach(),this.transformHelper?.parent?.remove(this.transformHelper),this.modelList.forEach(e=>this.removeObject(e.object)),this.modelList.clear(),this.modelTransforms.length=0,this.disableModelEditing()}update(){this.syncTransformControlCamera()}async placeModel(e){if(!e?.url)throw new Error("放置模型失败:url 不能为空。");const n=e.id??this.createId();if(this.modelList.has(n)||this.pendingModelIds.has(n))throw new Error(`放置模型失败:模型 id “${n}” 已存在。`);this.pendingModelIds.add(n);try{if(e.position){const i=this.normalizeData({...e,id:n,materials:[]});return this.saveHistory(),await this.loadRecord(i),this.editModel(n),this.cloneData(i)}return await this.placePreparedModel(this.normalizeData({...e,id:n,position:[0,0,0],materials:[]}))}finally{this.pendingModelIds.delete(n)}}async placePreparedModel(e){this.enableModelEditing(),this.clearSelection();const n=await this.createRecord(e);n.object.visible=!1,this.engine.scene?.add(n.object);try{const i=await this.pickPlacementPoint(r=>{n.object.visible=r!=null,r&&n.object.position.copy(r.position),this.requestRender()},()=>{n.object.rotateOnWorldAxis(new H(0,1,0),Math.PI/2),n.data.rotation=n.object.rotation.toArray(),this.requestRender()});n.data.position=i.position.toArray(),n.object.position.copy(i.position),n.object.visible=!0,this.saveHistory(),this.addRecord(n)}catch(i){throw this.removeObject(n.object),i}return this.editModel(e.id),this.cloneData(n.data)}editModel(e,n="translate"){const i=this.modelList.get(e);if(!i)throw new Error(`编辑模型失败:未找到模型 “${e}”。`);this.enableModelEditing(),this.selectedModelId=e,this.ensureTransformControl(),this.transformControl?.setMode(n),this.transformControl?.attach(i.object),this.transformHelper&&(this.transformHelper.visible=!0),this.engine.events?.trigger?.(eh.ModelPlaceSelected,{modelId:e,data:this.cloneData(i.data),object:i.object}),this.requestRender()}endEdit(){this.clearSelection(),this.disableModelEditing()}getSelectedModelId(){return this.selectedModelId}copySelectedModel(){this.syncSelectedTransform();const e=this.selectedModelId?this.modelList.get(this.selectedModelId):null;return e?(this.copiedModelData=this.cloneData(e.data),!0):!1}async pasteModel(){if(!this.copiedModelData||this.isPasting)return null;const e=this.createId();this.isPasting=!0,this.pendingModelIds.add(e);try{return await this.placePreparedModel(this.normalizeData({...this.cloneData(this.copiedModelData),id:e,position:[0,0,0]}))}finally{this.pendingModelIds.delete(e),this.isPasting=!1}}async replaceMaterial(e,n,i){const r=this.requireRecord(e);if(!i)throw new Error("替换材质失败:贴图 url 不能为空。");const s=this.getMaterials(r.object),o=this.getMaterialIndices(s,n);if(o.length===0){const a=typeof n=="number"?`槽位 ${n}`:`名称 “${n}”`;throw new Error(`替换材质失败:模型不存在材质${a}。`)}this.saveHistory(),await Promise.all(o.map(async a=>{const c=s[a],l=await new Bd().loadAsync(i);l.colorSpace=Xr,c.map=l,c.needsUpdate=!0;const u=r.data.materials.find(h=>h.materialIndex===a);u?(u.materialName=c.name||void 0,u.mapUrl=i):r.data.materials.push({materialIndex:a,materialName:c.name||void 0,mapUrl:i})})),this.requestRender()}getModelMaterials(e){return this.getMaterials(this.requireRecord(e).object).map((n,i)=>({materialIndex:i,materialName:n.name}))}deleteModel(e){const n=this.requireRecord(e);this.saveHistory(),this.removeObject(n.object),this.modelList.delete(e),this.selectedModelId===e&&this.clearSelection(),this.requestRender()}clearModels(){this.modelList.size!==0&&(this.saveHistory(),this.endEdit(),this.modelList.forEach(e=>this.removeObject(e.object)),this.modelList.clear(),this.requestRender())}hideModel(e){const n=this.requireRecord(e);this.saveHistory(),n.object.visible=!1,n.data.visible=!1,this.selectedModelId===e&&this.clearSelection(),this.requestRender()}showAllModels(){this.saveHistory(),this.modelList.forEach(e=>{e.object.visible=!0,e.data.visible=!0}),this.requestRender()}getSceneModels(){return this.syncSelectedTransform(),Array.from(this.modelList.values(),e=>this.cloneData(e.data))}async restoreSceneModels(e){if(!Array.isArray(e))throw new Error("还原场景失败:场景模型数据必须是数组。");this.isRestoring||this.saveHistory(),this.isRestoring=!0;try{this.endEdit(),this.modelList.forEach(n=>this.removeObject(n.object)),this.modelList.clear();for(const n of e)await this.loadRecord(this.normalizeData(n));return this.getSceneModels()}finally{this.isRestoring=!1,this.requestRender()}}async undo(){if(this.isUndoing)return!1;const e=this.modelTransforms.pop();if(!e)return!1;this.isUndoing=!0;try{return this.isRestoring=!0,await this.restoreSceneModels(e),!0}finally{this.isUndoing=!1}}async loadRecord(e){this.addRecord(await this.createRecord(e))}async createRecord(e){const i=(await this.loader.loadAsync(e.url)).scene;i.name=e.name,i.position.fromArray(e.position),i.rotation.fromArray(e.rotation),i.scale.fromArray(e.scale),i.visible=e.visible;const r={data:this.cloneData(e),object:i};for(const s of e.materials)s.mapUrl&&await this.applyTexture(r,s,s.mapUrl);return r}addRecord(e){e.object.userData.modelPlaceId=e.data.id,this.engine.scene?.add(e.object),this.modelList.set(e.data.id,e)}async applyTexture(e,n,i){const r=this.getMaterials(e.object),s=n.materialName?r.find(a=>a.name===n.materialName)??r[n.materialIndex]:r[n.materialIndex];if(!s)return;const o=await new Bd().loadAsync(i);o.colorSpace=Xr,s.map=o,s.needsUpdate=!0}ensureTransformControl(){if(this.transformControl){this.syncTransformControlCamera();return}!this.engine.camera||!this.engine.renderer||!this.engine.scene||(this.transformControl=new tN(this.engine.camera,this.engine.renderer.domElement),this.transformControl.addEventListener("dragging-changed",e=>{this.engine.controls&&(this.engine.controls.enabled=!e.value),e.value?this.saveHistory():this.syncSelectedTransform()}),this.transformControl.addEventListener("objectChange",()=>this.requestRender()),this.transformHelper=this.transformControl.getHelper(),this.transformHelper.visible=!1,this.engine.scene.add(this.transformHelper),this.syncTransformControlCamera())}syncTransformControlCamera(){!this.transformControl||!this.engine.camera||(this.transformControl.camera=this.engine.camera,this.transformControl.size=this.engine.camera.isPerspectiveCamera?kKe:UKe)}pickPlacementPoint(e,n){const i=this.engine.handelBehaved;return!i?.init||!i?.active||!i?.disActive?Promise.reject(new Error("放置模型失败:引擎捕捉交互尚未初始化。")):new Promise((r,s)=>{let o=!1;const a=l=>{o||(o=!0,i.disActive(),this.engine.catchSvg&&(this.engine.catchSvg.innerHTML=""),this.engine.interactionModule?.init?.(),this.engine.interactionModule?.active?.(),l())},c={type:"model-place",handleMouseMove:l=>e?.(this.getPlacementPoint(l?.catch)),handleMouseClick:l=>{const u=this.getPlacementPoint(l?.catch);u&&a(()=>r(u))},handelKeyEscDown:()=>{a(()=>s(new Error("已取消第三方模型放置。")))},handelKeySpaceDown:l=>{l.preventDefault(),n?.()},disActive:()=>{a(()=>s(new Error("第三方模型放置已被其他交互操作取消。")))}};i.init(c,{showCatch:!0}),i.active()})}getPlacementPoint(e){const n=e?.point;if(!(n instanceof H))return null;const i=n.clone(),r=e?.normal??e?.face?.normal;if(r==null)return{position:i,normal:null};const s=r.clone(),o=e?.matrix??e?.object?.matrixWorld;return o&&s.transformDirection(o),s.lengthSq()<1e-10?{position:i,normal:null}:(s.normalize(),i.addScaledVector(s,FKe),{position:i,normal:s})}handlePointerDown(e){if(!(!this.editingEnabled||!this.engine.camera||!this.engine.renderer)){if(this.transformControl?.axis!=null){this.selectionPointerDown=null;return}this.selectionPointerDown=new Ye(e.clientX,e.clientY)}}handlePointerUp(e){if(!this.editingEnabled||!this.engine.camera||!this.engine.renderer||!this.selectionPointerDown)return;const n=this.selectionPointerDown;if(this.selectionPointerDown=null,n.distanceTo(new Ye(e.clientX,e.clientY))>4)return;const i=this.engine.renderer.domElement.getBoundingClientRect(),r=new Ye((e.clientX-i.left)/i.width*2-1,-((e.clientY-i.top)/i.height)*2+1),s=new Da;s.setFromCamera(r,this.engine.camera);const o=s.intersectObjects(Array.from(this.modelList.values(),c=>c.object),!0)[0];if(!o){this.clearSelection();return}let a=o.object;for(;a&&!a.userData.modelPlaceId;)a=a.parent;a?.userData.modelPlaceId?this.editModel(a.userData.modelPlaceId):this.clearSelection()}handleKeyDown(e){if(this.isCopyShortcut(e)){e.preventDefault(),this.copySelectedModel();return}if(this.isPasteShortcut(e)){e.preventDefault(),this.pasteModel().catch(n=>console.error("第三方模型粘贴失败:",n));return}if(this.isDeleteShortcut(e)){e.preventDefault(),this.deleteModel(this.selectedModelId);return}if(this.isUndoShortcut(e)){e.preventDefault(),this.undo().catch(n=>console.error("第三方模型撤回失败:",n));return}if(this.isTransformModeShortcut(e)){e.preventDefault(),this.switchTransformMode(e.shiftKey?-1:1);return}(e.key==="Escape"||e.keyCode===27)&&this.editingEnabled&&this.selectedModelId&&this.clearSelection()}isUndoShortcut(e){return!e.ctrlKey&&!e.metaKey||e.shiftKey||e.altKey||e.key.toLowerCase()!=="z"||this.isTextInputTarget(e)?!1:this.modelTransforms.length>0&&!this.isUndoing}isCopyShortcut(e){return(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="c"&&!this.isTextInputTarget(e)&&this.selectedModelId!=null}isPasteShortcut(e){return(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="v"&&!this.isTextInputTarget(e)&&this.copiedModelData!=null&&!this.isPasting}isDeleteShortcut(e){return e.key==="Delete"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!this.isTextInputTarget(e)&&this.selectedModelId!=null}isTextInputTarget(e){const n=e.target;return!!(n?.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(n?.tagName??""))}isTransformModeShortcut(e){return e.key!=="Tab"||e.ctrlKey||e.metaKey||e.altKey||this.isTextInputTarget(e)?!1:this.editingEnabled&&this.selectedModelId!=null&&this.transformHelper?.visible===!0}switchTransformMode(e){const n=["translate","rotate","scale"],i=this.transformControl?.mode,s=(Math.max(0,n.indexOf(i??"translate"))+e+n.length)%n.length;this.transformControl?.setMode(n[s]),this.requestRender()}clearSelection(){this.selectedModelId=null,this.transformControl?.detach(),this.transformHelper&&(this.transformHelper.visible=!1),this.requestRender()}enableModelEditing(){this.editingEnabled=!0,this.bimHighlightDisabledBeforeEditing==null&&(this.bimHighlightDisabledBeforeEditing=!!this.engine.engineStatus?.disableModelInteractionHighlight),this.engine.engineStatus&&(this.engine.engineStatus.disableModelInteractionHighlight=!0),this.engine.modelToolModule?.unhighlightAllModels?.(),this.engine.hoverHighLight?.clearHighlight?.(),this.engine.hoverHighLight?.showModelNameTag?.(null,null)}disableModelEditing(){this.editingEnabled=!1,this.selectionPointerDown=null,this.bimHighlightDisabledBeforeEditing!=null&&this.engine.engineStatus&&(this.engine.engineStatus.disableModelInteractionHighlight=this.bimHighlightDisabledBeforeEditing),this.bimHighlightDisabledBeforeEditing=null}syncSelectedTransform(){if(!this.selectedModelId)return;const e=this.modelList.get(this.selectedModelId);e&&(e.data.position=e.object.position.toArray(),e.data.rotation=e.object.rotation.toArray(),e.data.scale=e.object.scale.toArray())}saveHistory(){this.isRestoring||this.modelTransforms.push(this.getSceneModels())}requireRecord(e){const n=this.modelList.get(e);if(!n)throw new Error(`未找到模型 “${e}”。`);return n}getMaterials(e){const n=[];return e.traverse(i=>{if(!i.isMesh)return;(Array.isArray(i.material)?i.material:[i.material]).forEach(s=>{s&&!n.includes(s)&&n.push(s)})}),n}getMaterialIndices(e,n){return typeof n=="number"?Number.isInteger(n)&&n>=0&&n<e.length?[n]:[]:e.reduce((i,r,s)=>(r.name===n&&i.push(s),i),[])}normalizeData(e){return{id:e.id??this.createId(),url:e.url,name:e.name??"第三方模型",position:e.position??[0,0,0],rotation:e.rotation??[0,0,0,"XYZ"],scale:e.scale??[1,1,1],visible:e.visible??!0,materials:e.materials??[]}}cloneData(e){return JSON.parse(JSON.stringify(e))}createId(){return`model-place-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}removeObject(e){e.parent?.remove(e),e.traverse(n=>{n.geometry?.dispose?.(),(Array.isArray(n.material)?n.material:[n.material]).forEach(i=>{i?.map?.dispose?.(),i?.dispose?.()})})}requestRender(){this.engine.requestComposerRender?.()}}const yg={version:"3.11.9"}.version;function XH(){const t=globalThis.crypto?.subtle;if(!t)throw new Error("[BimEngine] Web Crypto API is required for secure sdkAuth credentials mode");return t}function zM(t){return new TextEncoder().encode(t)}function VM(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function jue(t){let e="";return t.forEach(n=>{e+=String.fromCharCode(n)}),btoa(e)}function VKe(t){const e=t.getUTCFullYear(),n=String(t.getUTCMonth()+1).padStart(2,"0"),i=String(t.getUTCDate()).padStart(2,"0");return`${e}${n}${i}`}async function jKe(t){const e=await XH().digest("SHA-256",VM(zM(t)));return Array.from(new Uint8Array(e)).map(n=>n.toString(16).padStart(2,"0")).join("")}async function HKe(t,e){const n=XH(),i=await n.importKey("raw",VM(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return n.sign("HMAC",i,VM(zM(e)))}function GKe(t){return zM([t.appId,t.engineType,t.requestDate,String(t.timestamp),t.nonce].join("|"))}async function qKe(t){const e=XH(),n=new Date,i=n.getTime(),r=VKe(n),s=globalThis.crypto.randomUUID(),o=globalThis.crypto.getRandomValues(new Uint8Array(12)),a=await jKe(t.appSecret),c=await HKe(zM(a),r),l=await e.importKey("raw",c,"AES-GCM",!1,["encrypt"]),u=JSON.stringify({appKey:t.appKey,appSecret:t.appSecret}),h=await e.encrypt({name:"AES-GCM",iv:o,additionalData:VM(GKe({appId:t.appId,engineType:t.engineType,requestDate:r,timestamp:i,nonce:s})),tagLength:128},l,VM(zM(u)));return{appId:t.appId,engineType:t.engineType,requestDate:r,timestamp:i,nonce:s,iv:jue(o),cipherText:jue(new Uint8Array(h)),sdkVersion:t.sdkVersion,origin:t.origin,product:t.product}}const $H=new Map;function bF(t){return t.replace(/\/+$/,"")}function vF(t){if(t)return t;if(typeof window<"u"&&typeof window.location?.origin=="string")return window.location.origin}function WKe(t,e){return JSON.stringify({endpoint:bF(t.endpoint),token:t.token??"",appId:t.appId??"",appKey:t.appKey??"",appSecret:t.appSecret??"",origin:vF(t.origin)??"",product:t.product??"",engineType:e,sdkVersion:yg})}async function QH(t,e,n){const i=typeof AbortController<"u"?new AbortController:void 0,r=i?setTimeout(()=>i.abort(),n):void 0;try{const s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:i?.signal}),o=await s.json().catch(()=>({}));if(!s.ok){const a=o?.error?.message??o?.message??`SDK authentication failed with status ${s.status}`;throw new Error(a)}return o}finally{r!=null&&clearTimeout(r)}}async function YKe(t,e){const n=await QH(`${bF(t.endpoint)}/oauth/sdk-verify`,{sdkToken:t.token,engineType:e,sdkVersion:yg,origin:vF(t.origin),product:t.product},t.timeoutMs??8e3);return n.sdkToken=t.token,n}async function XKe(t,e){const n=await qKe({appId:t.appId,appKey:t.appKey,appSecret:t.appSecret,engineType:e,sdkVersion:yg,origin:vF(t.origin),product:t.product}),i=await QH(`${bF(t.endpoint)}/oauth/sdk-token/secure`,n,t.timeoutMs??8e3),r=await QH(`${bF(t.endpoint)}/oauth/sdk-verify`,{sdkToken:i.sdkToken,engineType:e,sdkVersion:yg,origin:vF(t.origin),product:t.product},t.timeoutMs??8e3);return r.sdkToken=i.sdkToken,r}async function $Ke(t,e){const n=t?.sdkAuth;if(!n)return null;if(!n.endpoint)throw new Error("[BimEngine] sdkAuth.endpoint is required");if(!n.token&&!(n.appId&&n.appKey&&n.appSecret))return null;const i=WKe(n,e),r=$H.get(i);if(r){const o=await r;return t&&(t.__sdkAuthSession=o),o}const s=(n.token?YKe(n,e):XKe(n,e)).then(o=>{if(o.authorized!==!0)throw new Error("[BimEngine] SDK authorization rejected");return t&&(t.__sdkAuthSession=o),o}).catch(o=>{throw $H.delete(i),o});return $H.set(i,s),s}var KH,Hue;function mr(){return Hue||(Hue=1,KH={options:{usePureJavaScript:!1}}),KH}var JH={exports:{}},ZH,Gue;function QKe(){if(Gue)return ZH;Gue=1;var t={};ZH=t;var e={};t.encode=function(i,r,s){if(typeof r!="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 o="";if(!(i instanceof Uint8Array))o=n(i,r);else{var a=0,c=r.length,l=r.charAt(0),u=[0];for(a=0;a<i.length;++a){for(var h=0,d=i[a];h<u.length;++h)d+=u[h]<<8,u[h]=d%c,d=d/c|0;for(;d>0;)u.push(d%c),d=d/c|0}for(a=0;i[a]===0&&a<i.length-1;++a)o+=l;for(a=u.length-1;a>=0;--a)o+=r[u[a]]}if(s){var p=new RegExp(".{1,"+s+"}","g");o=o.match(p).join(`\r
|
|
6015
|
+
`});return h.clippingPlanes=this.engine.sectionPlane,n.alwaysOnTop&&(h.depthTest=!1),h}createPulseMaterial(e,n,i,r,s,o,a){return this.createSurfaceMaterial({color:`#${e.getHexString()}`,opacity:n,style:i,effect:{...r,pulse:r.pulse?.enabled?r.pulse:{enabled:!0,speed:1.4,minOpacity:.55,maxOpacity:1}},axisMode:s,axisMin:o,axisMax:a})}axisModeToNumber(e){return e==="x"?0:e==="y"?1:e==="z"?2:e==="uvx"?3:4}getGradientStops(e,n){if(!Array.isArray(n)||n.length===0)return[{offset:0,color:e,alpha:1},{offset:1,color:e,alpha:.08}];const i=[...n].sort((o,a)=>o.offset-a.offset),r=i[0],s=i[i.length-1];return[{offset:0,color:r.color,alpha:r.alpha??1},{offset:1,color:s.color,alpha:s.alpha??.08}]}}const UM={color:"#7ffcff",opacity:.92,fillColor:"#7ffcff",fillOpacity:.18,depthTest:!0,alwaysOnTop:!1,lineWidth:.18,point:{mode:"sprite",size:0,iconSize:32,billboard:!0,anchorY:0},line:{dashed:!1,closed:!1},polygon:{showEdge:!0,edgeColor:"#d9ffff",edgeWidth:1},volume:{height:10,showTop:!0,showSide:!0,showBottom:!1,edgeColor:"#d9ffff"}},IKe={background:"rgba(10, 18, 28, 0.92)",color:"#ffffff",border:"1px solid rgba(127, 252, 255, 0.72)",borderRadius:"10px",padding:"12px",boxShadow:"0 10px 30px rgba(0, 0, 0, 0.32)",minWidth:"120px",pointerEvents:"auto"},MKe="bim-engine-annotation3d-panels";class PKe{normalizeData(e){return{...e,id:e.id??`annotation3d-${Date.now()}-${Math.random().toString(16).slice(2)}`,points:_F(e.points??[]),visible:e.visible??!0,selectable:e.selectable??!0,style:this.mergeStyle(e.style),effect:this.mergeEffect(e.effect),panel:e.panel?this.normalizePanel(e.panel):void 0}}mergeData(e,n,i,r){const s=i.panel===void 0?e.panel?{...e.panel,actions:n}:void 0:i.panel==null?void 0:{...e.panel,...i.panel,style:{...e.panel?.style??{},...i.panel.style??{}},actions:i.panel.actions??n};return this.normalizeData({id:r,type:i.type??e.type,points:i.points?_F(i.points):_F(e.points),visible:i.visible??e.visible,selectable:i.selectable??e.selectable,style:{...e.style,...i.style??{},point:{...e.style.point??{},...i.style?.point??{}},line:{...e.style.line??{},...i.style?.line??{}},polygon:{...e.style.polygon??{},...i.style?.polygon??{}},volume:{...e.style.volume??{},...i.style?.volume??{}}},effect:{...e.effect,...i.effect??{}},panel:s,data:i.data??e.data})}mergeStyle(e){return{...UM,...e,point:{...UM.point,...e?.point??{}},line:{...UM.line,...e?.line??{}},polygon:{...UM.polygon,...e?.polygon??{}},volume:{...UM.volume,...e?.volume??{}}}}mergeEffect(e){return{...e,gradient:e?.gradient?{enabled:e.gradient.enabled,direction:e.gradient.direction??"vertical",stops:e.gradient.stops??[]}:void 0,glow:e?.glow?{...e.glow}:void 0,flow:e?.flow?{enabled:e.flow.enabled,speed:e.flow.speed??.6,width:e.flow.width??.18,direction:e.flow.direction??"forward"}:void 0,pulse:e?.pulse?{enabled:e.pulse.enabled,speed:e.pulse.speed??1.4,minOpacity:e.pulse.minOpacity??.55,maxOpacity:e.pulse.maxOpacity??1}:void 0,ripple:e?.ripple?{enabled:e.ripple.enabled,count:e.ripple.count??2,speed:e.ripple.speed??.9,maxRadius:e.ripple.maxRadius??12}:void 0,pillar:e?.pillar?{enabled:e.pillar.enabled,height:e.pillar.height??16,width:e.pillar.width??1.5}:void 0,baseRing:e?.baseRing?{enabled:e.baseRing.enabled,radius:e.baseRing.radius??3,rotateSpeed:e.baseRing.rotateSpeed??.8}:void 0,layers:e?.layers?{enabled:e.layers.enabled,count:e.layers.count??3,offsetY:e.layers.offsetY??3}:void 0,scan:e?.scan?{enabled:e.scan.enabled,speed:e.scan.speed??.8,width:e.scan.width??.18}:void 0}}normalizePanel(e){return{visible:e.visible??!0,trigger:e.trigger??"manual",mode:e.mode??(e.html?"html":"text"),text:e.text??"",html:e.html??"",anchor:e.anchor,offset:{...e.offset??{}},screenOffset:{...e.screenOffset??{}},className:e.className,style:{...IKe,...e.style??{}},interactive:e.interactive??!0,occlusion:e.occlusion??"show",actions:e.actions}}}function DKe(t,e,n){const i=t.camera;if(!i)return!1;const r=n.clone().sub(i.position),s=r.length();if(s<=1e-6)return!1;e.set(i.position,r.normalize());let o=t.octreeBox?.rayInterationModel?.(e,!0,!1)??[];o=t.clipping?.filterIntersectionsByClipping?.(o)??o;const a=o.sort((c,l)=>c.distance-l.distance)[0];return!!(a&&a.distance<s-.05)}class RKe{constructor(e,n){this.engine=e,this.isAnchorOccluded=n,this.container=document.createElement("div"),this.container.className=MKe,this.container.style.cssText=["position:absolute","left:0","top:0","width:100%","height:100%","pointer-events:none","overflow:hidden","z-index:1250"].join(";"),this.engine.container.appendChild(this.container),this.worldToScreen=new ua(this.engine.camera,this.engine.renderer,this.engine.scene)}container;worldToScreen;updateProjectionState(){this.worldToScreen.updateCamera(this.engine.camera),this.worldToScreen.updateRenderer(this.engine.renderer),this.worldToScreen.updateScene(this.engine.scene)}createPanelElement(e,n){const i=document.createElement("div");return i.className=`bim-annotation3d-panel ${n.className??""}`.trim(),i.dataset.annotationId=e.id,i.style.cssText=["position:absolute","left:0","top:0","transform:translate(-50%, -100%)","display:none",n.interactive===!1?"pointer-events:none":"pointer-events:auto"].join(";"),n.mode==="html"?i.innerHTML=n.html??"":i.textContent=n.text??"",Object.entries(n.style??{}).forEach(([r,s])=>{i.style.setProperty(CKe(r),s)}),i}updateRecord(e){if(!e.panelElement||!e.instance.panel)return;const n=e.instance.panel;if(!(n.visible!==!1&&this.shouldShowPanel(e))||!e.instance.visible){e.panelElement.style.display="none";return}const r=this.getPanelAnchorPoint(e),s=this.worldToScreen.worldToScreenIfVisible(r);if(!s){e.panelElement.style.display="none";return}if(n.occlusion==="hide"&&this.isAnchorOccluded(r)){e.panelElement.style.display="none";return}const o=n.screenOffset??{};e.panelElement.style.display="block",e.panelElement.style.left=`${s.x+(o.x??0)}px`,e.panelElement.style.top=`${s.y+(o.y??0)}px`}dispose(){this.container.remove()}shouldShowPanel(e){const n=e.instance.panel?.trigger??"manual";return n==="always"?!0:n==="hover"?e.instance.hovered:n==="click"||n==="manual"?e.instance.panelVisible:!1}getPanelAnchorPoint(e){const n=e.instance.panel?.anchor??EKe(e.instance.type),i=e.instance.panel?.offset??{};let r=new H;if(e.instance.type==="point")r.copy(Hh(e.instance.points[0])),n==="top"&&(r.y+=e.volumeHeight??e.instance.style.point?.anchorY??0);else if(e.instance.type==="polyline")n==="start"?r.copy(Hh(e.instance.points[0])):n==="end"?r.copy(Hh(e.instance.points[e.instance.points.length-1])):e.anchorCurve?r.copy(e.anchorCurve.getPoint(.5)):r.copy(AF(e.instance.points));else if(e.instance.type==="polygon")r.copy(AF(e.instance.points));else if(e.instance.type==="extrudePolygon")r.copy(AF(e.instance.points)),n==="top"&&e.anchorNormal&&r.add(e.anchorNormal.clone().multiplyScalar(e.volumeHeight??0));else if(e.instance.type==="box"&&(r.copy(AF(e.instance.points)),n==="top"&&e.instance.points.length>=2)){const s=Hh(e.instance.points[0]),o=Hh(e.instance.points[1]);r.y=Math.max(s.y,o.y)}return r.add(new H(i.x??0,i.y??0,i.z??0)),r}}class OKe{engine;rootGroup;records;panelContainer;onRecordVisualChange;onEmit;raycaster=new Da;hoveredId=null;constructor(e){this.engine=e.engine,this.rootGroup=e.rootGroup,this.records=e.records,this.panelContainer=e.panelContainer,this.onRecordVisualChange=e.onRecordVisualChange,this.onEmit=e.onEmit}bind(){this.engine.renderer?.domElement?.addEventListener?.("click",this.handleCanvasClick,!1),this.engine.renderer?.domElement?.addEventListener?.("mousemove",this.handleCanvasMove,!1),this.engine.renderer?.domElement?.addEventListener?.("mouseleave",this.handleCanvasLeave,!1),this.panelContainer.addEventListener("click",this.handlePanelClick,!1)}unbind(){this.engine.renderer?.domElement?.removeEventListener?.("click",this.handleCanvasClick,!1),this.engine.renderer?.domElement?.removeEventListener?.("mousemove",this.handleCanvasMove,!1),this.engine.renderer?.domElement?.removeEventListener?.("mouseleave",this.handleCanvasLeave,!1),this.panelContainer.removeEventListener("click",this.handlePanelClick,!1)}handleRecordRemoved(e){this.hoveredId===e&&(this.hoveredId=null)}pickAnnotation(e){const n=this.engine.renderer?.domElement,i=this.engine.camera;if(!n||!i)return null;const r=n.getBoundingClientRect(),s=e.clientX-r.left,o=e.clientY-r.top,a=new Ye(s/r.width*2-1,-(o/r.height)*2+1);this.raycaster.setFromCamera(a,i);const c=this.raycaster.intersectObjects(this.rootGroup.children,!0);for(const l of c){let u=l.object;for(;u;){const h=u.userData?.annotationId;if(h&&this.records.has(h)){const d=this.records.get(h);return d.instance.selectable!==!1&&d.instance.visible?d:null}u=u.parent}}return null}handleCanvasClick=e=>{const n=this.pickAnnotation(e);n&&(n.instance.panel?.trigger==="click"&&(n.instance.panelVisible=!n.instance.panelVisible,this.onRecordVisualChange(n),this.onEmit(n.instance.panelVisible?"annotation3d-panel-open":"annotation3d-panel-close",this.toEventPayload(n,e))),this.onEmit("annotation3d-click",this.toEventPayload(n,e)))};handleCanvasMove=e=>{const n=this.pickAnnotation(e),i=n?.instance.id??null;if(i!==this.hoveredId){if(this.hoveredId&&this.records.has(this.hoveredId)){const r=this.records.get(this.hoveredId);r.instance.hovered=!1,this.onRecordVisualChange(r),this.onEmit("annotation3d-leave",this.toEventPayload(r,e))}this.hoveredId=i,n&&(n.instance.hovered=!0,this.onRecordVisualChange(n),this.onEmit("annotation3d-hover",this.toEventPayload(n,e)))}};handleCanvasLeave=e=>{if(!this.hoveredId||!this.records.has(this.hoveredId)){this.hoveredId=null;return}const n=this.records.get(this.hoveredId);n.instance.hovered=!1,this.onRecordVisualChange(n),this.onEmit("annotation3d-leave",this.toEventPayload(n,e)),this.hoveredId=null};handlePanelClick=e=>{const n=e.target;if(!n)return;const i=n.closest("[data-annotation-id]");if(!i)return;const r=i.dataset.annotationId;if(!r||!this.records.has(r))return;const s=this.records.get(r);this.onEmit("annotation3d-panel-click",this.toEventPayload(s,e));const o=n.closest("[data-action]"),a=o?.dataset?.action;if(!a||!s.actions?.[a])return;const c={engine:this.engine,id:r,annotation:s.instance,action:a,element:o,originalEvent:e};s.actions[a]?.(c),this.onEmit("annotation3d-action",{...this.toEventPayload(s,e),action:a,target:o})};toEventPayload(e,n){return{id:e.instance.id,annotation:e.instance,originalEvent:n}}}function LKe(t){const{actions:e,...n}=t;return n}function BKe(t){return{id:t.instance.id,type:t.instance.type,points:_F(t.instance.points),visible:t.instance.visible,selectable:t.instance.selectable,style:yF(t.instance.style),effect:yF(t.instance.effect),panel:t.instance.panel?yF(t.instance.panel):void 0,data:yF(t.instance.data)}}function yF(t){return t===void 0?t:JSON.parse(JSON.stringify(t))}class NKe{engine;rootGroup;records=new Map;textureLoader=new Bd;occlusionRaycaster=new Da;normalizer=new PKe;materialFactory;geometryBuilder;effectsController;panelLayer;interaction;currentTime=0;constructor(e){this.engine=e,this.rootGroup=new $r,this.rootGroup.name="Annotation3dRoot",this.engine.scene.add(this.rootGroup),this.materialFactory=new SKe(this.engine),this.geometryBuilder=new wKe(this.engine,this.textureLoader,this.materialFactory),this.effectsController=new TKe(this.engine),this.panelLayer=new RKe(this.engine,n=>DKe(this.engine,this.occlusionRaycaster,n)),this.interaction=new OKe({engine:this.engine,rootGroup:this.rootGroup,records:this.records,panelContainer:this.panelLayer.container,onRecordVisualChange:n=>this.panelLayer.updateRecord(n),onEmit:(n,i)=>this.emit(n,i)}),this.interaction.bind()}add(e){const n=this.normalizer.normalizeData(e),i=this.buildRecord(n);return this.attachRecord(i),this.emit("annotation3d-created",this.toEventPayload(i)),n.id}addMany(e){return e.map(n=>this.add(n))}async pickPoint(){if(typeof this.engine.label?.pickPoint!="function")return null;const e=await this.engine.label.pickPoint();return e==null?null:{x:e.x,y:e.y,z:e.z}}update(e,n){const i=this.records.get(e);if(!i)return!1;const r=this.normalizer.mergeData(i.instance,i.actions,n,e);this.removeInternal(e,!1);const s=this.buildRecord(r);return this.attachRecord(s),this.emit("annotation3d-updated",this.toEventPayload(s)),!0}remove(e){return this.removeInternal(e,!0)}clear(){Array.from(this.records.keys()).forEach(e=>this.removeInternal(e,!1))}get(e){return this.records.get(e)?.instance}getAll(){return Array.from(this.records.values()).map(e=>e.instance)}show(e){return this.setVisible(e,!0)}hide(e){return this.setVisible(e,!1)}setVisible(e,n){const i=this.records.get(e);return i?(i.instance.visible=n,this.applyVisibility(i),!0):!1}showPanel(e){const n=this.records.get(e);return!n||!n.instance.panel?!1:(n.instance.panelVisible=!0,this.panelLayer.updateRecord(n),this.emit("annotation3d-panel-open",this.toEventPayload(n)),!0)}hidePanel(e){const n=this.records.get(e);return!n||!n.instance.panel?!1:(n.instance.panelVisible=!1,this.panelLayer.updateRecord(n),this.emit("annotation3d-panel-close",this.toEventPayload(n)),!0)}togglePanel(e){const n=this.records.get(e);return!n||!n.instance.panel?!1:n.instance.panelVisible?this.hidePanel(e):this.showPanel(e)}updatePanel(e,n){const i=this.records.get(e);if(!i||!i.instance.panel)return!1;const r={...i.instance.panel,...n,style:{...i.instance.panel.style??{},...n.style??{}},actions:n.actions??i.actions};return this.update(e,{panel:r})}getData(){return Array.from(this.records.values()).map(e=>BKe(e))}restoreData(e){this.clear(),e.forEach(n=>this.add(n))}updateFrame(e=1/60){this.currentTime+=e,this.panelLayer.updateProjectionState(),this.records.forEach(n=>{this.effectsController.updateRecord(n,this.currentTime),this.panelLayer.updateRecord(n)})}dispose(){this.interaction.unbind(),this.clear(),this.rootGroup.removeFromParent(),this.panelLayer.dispose()}buildRecord(e){const n=new $r;n.name=e.id;const i={id:e.id,type:e.type,points:e.points,visible:e.visible??!0,selectable:e.selectable??!0,style:e.style,effect:e.effect??{},panel:e.panel?LKe(e.panel):void 0,data:e.data,panelVisible:e.panel?.trigger==="always",hovered:!1,root:n},r={instance:i,actions:e.panel?.actions,panelElement:e.panel?this.panelLayer.createPanelElement(i,e.panel):null,timeSeed:Math.random()*Math.PI*2,pulseMaterials:[],rippleMeshes:[],baseRingMeshes:[],animatedMaterials:[]};return this.geometryBuilder.build(r),vKe(n,i.id),r}attachRecord(e){this.records.set(e.instance.id,e),this.rootGroup.add(e.instance.root),e.panelElement&&this.panelLayer.container.appendChild(e.panelElement),this.applyVisibility(e)}removeInternal(e,n){const i=this.records.get(e);return i?(this.interaction.handleRecordRemoved(e),xKe(i.instance.root),i.instance.root.removeFromParent(),i.panelElement?.remove(),this.records.delete(e),n&&this.emit("annotation3d-removed",{id:e}),!0):!1}applyVisibility(e){e.instance.root.visible=e.instance.visible,e.instance.style.alwaysOnTop&&e.instance.root.traverse(n=>{n.renderOrder=Math.max(n.renderOrder,1200)}),this.panelLayer.updateRecord(e)}toEventPayload(e,n){return{id:e.instance.id,annotation:e.instance,originalEvent:n}}emit(e,n){this.engine.events?.trigger?.(e,n)}}class ww{constructor(e){this.engine=e}static svgNamespace="http://www.w3.org/2000/svg";static sourceColor="#00bcd4";static targetColor="#ff9800";matrices=new Map;pointCalibrationUrl=null;pointCalibrationPoints=[];behavior;type="point-calibration";apply(e){if(!e?.url||e.matrix==null)return!1;const n=this.toThreeMatrix(e.matrix),i=FE(this.engine,e.url);return i.matrixAutoUpdate=!1,i.matrix.copy(n),i.matrixWorldNeedsUpdate=!0,i.updateMatrixWorld(!0),this.clearRuntimeWorldBoxCache(i),this.engine.octreeBox?.invalidateModelWorldCache?.(e.url),this.matrices.set(e.url,n.clone()),this.updateCachedModelBox(e.url,i),this.engine.modelEdge?.setModelEdgeTransform?.(e.url,n),this.engine.requestComposerRender?.(),!0}setCalibration(e){return this.apply(e)}alignBySegments(e){if(!e?.url||e.source==null||e.target==null)return!1;const n=this.toVector3(e.source.start),i=this.toVector3(e.source.end),r=this.toVector3(e.target.start),s=this.toVector3(e.target.end),o=i.clone().sub(n),a=s.clone().sub(r);if(o.lengthSq()<1e-10||a.lengthSq()<1e-10)throw new Error("[Calibration] source and target segments must have valid length");o.normalize(),a.normalize();const c=new xt().makeRotationFromQuaternion(new ni().setFromUnitVectors(o,a)),l=new xt().makeTranslation(r.x,r.y,r.z).multiply(c).multiply(new xt().makeTranslation(-n.x,-n.y,-n.z)),u=this.getMatrix(e.url);return this.apply({url:e.url,matrix:l.multiply(u)})}startPointCalibration(e){return!e?.url||(this.behavior=this.engine.handelBehaved,!this.behavior?.init||!this.behavior?.active||!this.behavior?.disActive)?!1:(this.pointCalibrationUrl=e.url,this.pointCalibrationPoints=[],this.engine.setIdleFrameRateExempt?.("point-calibration",!0),this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.behavior.isClickSimpleModel=!1,!0)}handleMouseClick(e){const n=e?.catch?.point;if(!(n instanceof H)||this.pointCalibrationUrl==null)return;if(this.pointCalibrationPoints.push(n.clone()),this.pointCalibrationPoints.length!==4){this.drawPointCalibrationOverlay(n);return}const[i,r,s,o]=this.pointCalibrationPoints;try{this.alignBySegments({url:this.pointCalibrationUrl,source:{start:i,end:r},target:{start:s,end:o}})}catch(a){console.warn("四点模型校准失败:",a)}this.finishPointCalibration()}handleMouseMove(e){const n=e?.catch?.point;this.drawPointCalibrationOverlay(n instanceof H?n:null)}handelKeyEscDown(){this.finishPointCalibration()}disActive(){this.engine.setIdleFrameRateExempt?.("point-calibration",!1),this.pointCalibrationPoints=[],this.pointCalibrationUrl=null,this.clearPointCalibrationOverlay(),this.behavior?.disActive()}finishPointCalibration(){this.disActive(),this.engine.interactionModule?.init?.(),this.engine.interactionModule?.active?.()}drawPointCalibrationOverlay(e){const n=this.engine.catchSvg;if(n==null)return;n.innerHTML="";const i=this.pointCalibrationPoints,r=i.slice(0,2),s=i.slice(2,4);this.drawCalibrationSegment(n,r,ww.sourceColor,i.length<2?e:null),this.drawCalibrationSegment(n,s,ww.targetColor,i.length>=2&&i.length<4?e:null)}drawCalibrationSegment(e,n,i,r){const s=n.map(a=>this.toSvgPoint(a)).filter(a=>a!=null),o=r==null?null:this.toSvgPoint(r);s.length===2&&this.appendSvgLine(e,s[0],s[1],i),s.length===1&&o!=null&&this.appendSvgLine(e,s[0],o,i,!0),s.forEach(a=>this.appendSvgPoint(e,a,i)),o!=null&&this.appendSvgPoint(e,o,i,!0)}toSvgPoint(e){const n=this.engine.worldToScreen?.worldToScreenIfVisible?.(e)??this.engine.worldToScreen?.worldToScreen?.(e);if(n==null||!Number.isFinite(n.x)||!Number.isFinite(n.y))return null;const i=this.engine.reactBoundingClientRect;return new Ye(n.x+(Number.isFinite(i?.left)?i.left:0),n.y+(Number.isFinite(i?.top)?i.top:0))}appendSvgLine(e,n,i,r,s=!1){const o=document.createElementNS(ww.svgNamespace,"line");o.setAttribute("x1",`${n.x}`),o.setAttribute("y1",`${n.y}`),o.setAttribute("x2",`${i.x}`),o.setAttribute("y2",`${i.y}`),o.setAttribute("stroke",r),o.setAttribute("stroke-width",s?"2":"3"),s&&o.setAttribute("stroke-dasharray","6 4"),e.appendChild(o)}appendSvgPoint(e,n,i,r=!1){const s=document.createElementNS(ww.svgNamespace,"circle");s.setAttribute("cx",`${n.x}`),s.setAttribute("cy",`${n.y}`),s.setAttribute("r",r?"6":"5"),s.setAttribute("fill",r?"transparent":i),s.setAttribute("fill-opacity",r?"0":"1"),s.setAttribute("stroke",i),s.setAttribute("stroke-width",r?"2":"1"),r&&s.setAttribute("stroke-dasharray","3 2"),e.appendChild(s)}clearPointCalibrationOverlay(){this.engine.catchSvg&&(this.engine.catchSvg.innerHTML="")}getMatrix(e){const n=this.matrices.get(e);if(n!=null)return n.clone();const i=$b(this.engine,e);return i==null?new xt:i.matrix.clone()}clear(e){const n=$b(this.engine,e);return n==null?!1:(n.matrixAutoUpdate=!1,n.matrix.identity(),n.matrixWorldNeedsUpdate=!0,n.updateMatrixWorld(!0),this.clearRuntimeWorldBoxCache(n),this.engine.octreeBox?.invalidateModelWorldCache?.(e),this.matrices.delete(e),this.updateCachedModelBox(e,n),this.engine.modelEdge?.setModelEdgeTransform?.(e,new xt),this.engine.requestComposerRender?.(),!0)}updateCachedModelBox(e,n){const i=this.engine.models?.find?.(s=>s.url===e);if(i?.boundingBox==null)return;i.localBoundingBox==null&&(i.localBoundingBox={min:i.boundingBox.min.clone(),max:i.boundingBox.max.clone()});const r=new Ln(i.localBoundingBox.min.clone(),i.localBoundingBox.max.clone());n.updateWorldMatrix(!0,!1),r.applyMatrix4(n.matrixWorld),i.boundingBox={min:r.min,max:r.max}}clearRuntimeWorldBoxCache(e){e.traverse(n=>{n?.box instanceof Ln&&delete n.box})}toThreeMatrix(e){if(e instanceof xt)return e.clone();if(Array.isArray(e)&&Array.isArray(e[0])){const i=e;if(i.length!==4||i.some(r=>!Array.isArray(r)||r.length!==4))throw new Error("[Calibration] matrix must be a 4x4 array");return new xt().set(i[0][0],i[0][1],i[0][2],i[0][3],i[1][0],i[1][1],i[1][2],i[1][3],i[2][0],i[2][1],i[2][2],i[2][3],i[3][0],i[3][1],i[3][2],i[3][3])}const n=Array.from(e);if(n.length!==16)throw new Error("[Calibration] matrix must contain 16 numbers");return new xt().fromArray(n)}toVector3(e){if(e instanceof H)return e.clone();if(Array.isArray(e)){if(e.length!==3)throw new Error("[Calibration] point array must contain 3 numbers");return new H(e[0],e[1],e[2])}return"x"in e?new H(e.x,e.y,e.z):new H(e.X,e.Y,e.Z)}}const FKe=.001,kKe=.65,UKe=1;class zKe{engine;loader=new Mj;modelList=new Map;modelTransforms=[];transformControl=null;transformHelper=null;selectedModelId=null;copiedModelData=null;editingEnabled=!1;isRestoring=!1;isUndoing=!1;isPasting=!1;pendingModelIds=new Set;bimHighlightDisabledBeforeEditing=null;selectionPointerDown=null;onPointerDown;onPointerUp;onKeyDown;constructor(e){this.engine=e,this.onPointerDown=this.handlePointerDown.bind(this),this.onPointerUp=this.handlePointerUp.bind(this),this.onKeyDown=this.handleKeyDown.bind(this),this.engine.renderer?.domElement?.addEventListener("pointerdown",this.onPointerDown),this.engine.renderer?.domElement?.addEventListener("pointerup",this.onPointerUp),window.addEventListener("keydown",this.onKeyDown),this.ensureTransformControl()}dispose(){this.engine.renderer?.domElement?.removeEventListener("pointerdown",this.onPointerDown),this.engine.renderer?.domElement?.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("keydown",this.onKeyDown),this.transformControl?.detach(),this.transformHelper?.parent?.remove(this.transformHelper),this.modelList.forEach(e=>this.removeObject(e.object)),this.modelList.clear(),this.modelTransforms.length=0,this.disableModelEditing()}update(){this.syncTransformControlCamera()}async placeModel(e){if(!e?.url)throw new Error("放置模型失败:url 不能为空。");const n=e.id??this.createId();if(this.modelList.has(n)||this.pendingModelIds.has(n))throw new Error(`放置模型失败:模型 id “${n}” 已存在。`);this.pendingModelIds.add(n);try{if(e.position){const i=this.normalizeData({...e,id:n,materials:[]});return this.saveHistory(),await this.loadRecord(i),this.editModel(n),this.cloneData(i)}return await this.placePreparedModel(this.normalizeData({...e,id:n,position:[0,0,0],materials:[]}))}finally{this.pendingModelIds.delete(n)}}async placePreparedModel(e){this.enableModelEditing(),this.clearSelection();const n=await this.createRecord(e);n.object.visible=!1,this.engine.scene?.add(n.object);try{const i=await this.pickPlacementPoint(r=>{n.object.visible=r!=null,r&&n.object.position.copy(r.position),this.requestRender()},()=>{n.object.rotateOnWorldAxis(new H(0,1,0),Math.PI/2),n.data.rotation=n.object.rotation.toArray(),this.requestRender()});n.data.position=i.position.toArray(),n.object.position.copy(i.position),n.object.visible=!0,this.saveHistory(),this.addRecord(n)}catch(i){throw this.removeObject(n.object),i}return this.editModel(e.id),this.cloneData(n.data)}editModel(e,n="translate"){const i=this.modelList.get(e);if(!i)throw new Error(`编辑模型失败:未找到模型 “${e}”。`);this.enableModelEditing(),this.selectedModelId=e,this.ensureTransformControl(),this.transformControl?.setMode(n),this.transformControl?.attach(i.object),this.transformHelper&&(this.transformHelper.visible=!0),this.engine.events?.trigger?.(eh.ModelPlaceSelected,{modelId:e,data:this.cloneData(i.data),object:i.object}),this.requestRender()}endEdit(){this.clearSelection(),this.disableModelEditing()}getSelectedModelId(){return this.selectedModelId}copySelectedModel(){this.syncSelectedTransform();const e=this.selectedModelId?this.modelList.get(this.selectedModelId):null;return e?(this.copiedModelData=this.cloneData(e.data),!0):!1}async pasteModel(){if(!this.copiedModelData||this.isPasting)return null;const e=this.createId();this.isPasting=!0,this.pendingModelIds.add(e);try{return await this.placePreparedModel(this.normalizeData({...this.cloneData(this.copiedModelData),id:e,position:[0,0,0]}))}finally{this.pendingModelIds.delete(e),this.isPasting=!1}}async replaceMaterial(e,n,i){const r=this.requireRecord(e);if(!i)throw new Error("替换材质失败:贴图 url 不能为空。");const s=this.getMaterials(r.object),o=this.getMaterialIndices(s,n);if(o.length===0){const a=typeof n=="number"?`槽位 ${n}`:`名称 “${n}”`;throw new Error(`替换材质失败:模型不存在材质${a}。`)}this.saveHistory(),await Promise.all(o.map(async a=>{const c=s[a],l=await new Bd().loadAsync(i);l.colorSpace=Xr,c.map=l,c.needsUpdate=!0;const u=r.data.materials.find(h=>h.materialIndex===a);u?(u.materialName=c.name||void 0,u.mapUrl=i):r.data.materials.push({materialIndex:a,materialName:c.name||void 0,mapUrl:i})})),this.requestRender()}getModelMaterials(e){return this.getMaterials(this.requireRecord(e).object).map((n,i)=>({materialIndex:i,materialName:n.name}))}deleteModel(e){const n=this.requireRecord(e);this.saveHistory(),this.removeObject(n.object),this.modelList.delete(e),this.selectedModelId===e&&this.clearSelection(),this.requestRender()}clearModels(){this.modelList.size!==0&&(this.saveHistory(),this.endEdit(),this.modelList.forEach(e=>this.removeObject(e.object)),this.modelList.clear(),this.requestRender())}hideModel(e){const n=this.requireRecord(e);this.saveHistory(),n.object.visible=!1,n.data.visible=!1,this.selectedModelId===e&&this.clearSelection(),this.requestRender()}showAllModels(){this.saveHistory(),this.modelList.forEach(e=>{e.object.visible=!0,e.data.visible=!0}),this.requestRender()}getSceneModels(){return this.syncSelectedTransform(),Array.from(this.modelList.values(),e=>this.cloneData(e.data))}async restoreSceneModels(e){if(!Array.isArray(e))throw new Error("还原场景失败:场景模型数据必须是数组。");this.isRestoring||this.saveHistory(),this.isRestoring=!0;try{this.endEdit(),this.modelList.forEach(n=>this.removeObject(n.object)),this.modelList.clear();for(const n of e)await this.loadRecord(this.normalizeData(n));return this.getSceneModels()}finally{this.isRestoring=!1,this.requestRender()}}async undo(){if(this.isUndoing)return!1;const e=this.modelTransforms.pop();if(!e)return!1;this.isUndoing=!0;try{return this.isRestoring=!0,await this.restoreSceneModels(e),!0}finally{this.isUndoing=!1}}async loadRecord(e){this.addRecord(await this.createRecord(e))}async createRecord(e){const i=(await this.loader.loadAsync(e.url)).scene;i.name=e.name,i.position.fromArray(e.position),i.rotation.fromArray(e.rotation),i.scale.fromArray(e.scale),i.visible=e.visible;const r={data:this.cloneData(e),object:i};for(const s of e.materials)s.mapUrl&&await this.applyTexture(r,s,s.mapUrl);return r}addRecord(e){e.object.userData.modelPlaceId=e.data.id,this.engine.scene?.add(e.object),this.modelList.set(e.data.id,e)}async applyTexture(e,n,i){const r=this.getMaterials(e.object),s=n.materialName?r.find(a=>a.name===n.materialName)??r[n.materialIndex]:r[n.materialIndex];if(!s)return;const o=await new Bd().loadAsync(i);o.colorSpace=Xr,s.map=o,s.needsUpdate=!0}ensureTransformControl(){if(this.transformControl){this.syncTransformControlCamera();return}!this.engine.camera||!this.engine.renderer||!this.engine.scene||(this.transformControl=new tN(this.engine.camera,this.engine.renderer.domElement),this.transformControl.addEventListener("dragging-changed",e=>{this.engine.controls&&(this.engine.controls.enabled=!e.value),e.value?this.saveHistory():this.syncSelectedTransform()}),this.transformControl.addEventListener("objectChange",()=>this.requestRender()),this.transformHelper=this.transformControl.getHelper(),this.transformHelper.visible=!1,this.engine.scene.add(this.transformHelper),this.syncTransformControlCamera())}syncTransformControlCamera(){!this.transformControl||!this.engine.camera||(this.transformControl.camera=this.engine.camera,this.transformControl.size=this.engine.camera.isPerspectiveCamera?kKe:UKe)}pickPlacementPoint(e,n){const i=this.engine.handelBehaved;return!i?.init||!i?.active||!i?.disActive?Promise.reject(new Error("放置模型失败:引擎捕捉交互尚未初始化。")):new Promise((r,s)=>{let o=!1;const a=l=>{o||(o=!0,i.disActive(),this.engine.catchSvg&&(this.engine.catchSvg.innerHTML=""),this.engine.interactionModule?.init?.(),this.engine.interactionModule?.active?.(),l())},c={type:"model-place",handleMouseMove:l=>e?.(this.getPlacementPoint(l?.catch)),handleMouseClick:l=>{const u=this.getPlacementPoint(l?.catch);u&&a(()=>r(u))},handelKeyEscDown:()=>{a(()=>s(new Error("已取消第三方模型放置。")))},handelKeySpaceDown:l=>{l.preventDefault(),n?.()},disActive:()=>{a(()=>s(new Error("第三方模型放置已被其他交互操作取消。")))}};i.init(c,{showCatch:!0}),i.active()})}getPlacementPoint(e){const n=e?.point;if(!(n instanceof H))return null;const i=n.clone(),r=e?.normal??e?.face?.normal;if(r==null)return{position:i,normal:null};const s=r.clone(),o=e?.matrix??e?.object?.matrixWorld;return o&&s.transformDirection(o),s.lengthSq()<1e-10?{position:i,normal:null}:(s.normalize(),i.addScaledVector(s,FKe),{position:i,normal:s})}handlePointerDown(e){if(!(!this.editingEnabled||!this.engine.camera||!this.engine.renderer)){if(this.transformControl?.axis!=null){this.selectionPointerDown=null;return}this.selectionPointerDown=new Ye(e.clientX,e.clientY)}}handlePointerUp(e){if(!this.editingEnabled||!this.engine.camera||!this.engine.renderer||!this.selectionPointerDown)return;const n=this.selectionPointerDown;if(this.selectionPointerDown=null,n.distanceTo(new Ye(e.clientX,e.clientY))>4)return;const i=this.engine.renderer.domElement.getBoundingClientRect(),r=new Ye((e.clientX-i.left)/i.width*2-1,-((e.clientY-i.top)/i.height)*2+1),s=new Da;s.setFromCamera(r,this.engine.camera);const o=s.intersectObjects(Array.from(this.modelList.values(),c=>c.object),!0)[0];if(!o){this.clearSelection();return}let a=o.object;for(;a&&!a.userData.modelPlaceId;)a=a.parent;a?.userData.modelPlaceId?this.editModel(a.userData.modelPlaceId):this.clearSelection()}handleKeyDown(e){if(this.isCopyShortcut(e)){e.preventDefault(),this.copySelectedModel();return}if(this.isPasteShortcut(e)){e.preventDefault(),this.pasteModel().catch(n=>console.error("第三方模型粘贴失败:",n));return}if(this.isDeleteShortcut(e)){e.preventDefault(),this.deleteModel(this.selectedModelId);return}if(this.isUndoShortcut(e)){e.preventDefault(),this.undo().catch(n=>console.error("第三方模型撤回失败:",n));return}if(this.isTransformModeShortcut(e)){e.preventDefault(),this.switchTransformMode(e.shiftKey?-1:1);return}(e.key==="Escape"||e.keyCode===27)&&this.editingEnabled&&this.selectedModelId&&this.clearSelection()}isUndoShortcut(e){return!e.ctrlKey&&!e.metaKey||e.shiftKey||e.altKey||e.key.toLowerCase()!=="z"||this.isTextInputTarget(e)?!1:this.modelTransforms.length>0&&!this.isUndoing}isCopyShortcut(e){return(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="c"&&!this.isTextInputTarget(e)&&this.selectedModelId!=null}isPasteShortcut(e){return(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="v"&&!this.isTextInputTarget(e)&&this.copiedModelData!=null&&!this.isPasting}isDeleteShortcut(e){return e.key==="Delete"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!this.isTextInputTarget(e)&&this.selectedModelId!=null}isTextInputTarget(e){const n=e.target;return!!(n?.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(n?.tagName??""))}isTransformModeShortcut(e){return e.key!=="Tab"||e.ctrlKey||e.metaKey||e.altKey||this.isTextInputTarget(e)?!1:this.editingEnabled&&this.selectedModelId!=null&&this.transformHelper?.visible===!0}switchTransformMode(e){const n=["translate","rotate","scale"],i=this.transformControl?.mode,s=(Math.max(0,n.indexOf(i??"translate"))+e+n.length)%n.length;this.transformControl?.setMode(n[s]),this.requestRender()}clearSelection(){this.selectedModelId=null,this.transformControl?.detach(),this.transformHelper&&(this.transformHelper.visible=!1),this.requestRender()}enableModelEditing(){this.editingEnabled=!0,this.bimHighlightDisabledBeforeEditing==null&&(this.bimHighlightDisabledBeforeEditing=!!this.engine.engineStatus?.disableModelInteractionHighlight),this.engine.engineStatus&&(this.engine.engineStatus.disableModelInteractionHighlight=!0),this.engine.modelToolModule?.unhighlightAllModels?.(),this.engine.hoverHighLight?.clearHighlight?.(),this.engine.hoverHighLight?.showModelNameTag?.(null,null)}disableModelEditing(){this.editingEnabled=!1,this.selectionPointerDown=null,this.bimHighlightDisabledBeforeEditing!=null&&this.engine.engineStatus&&(this.engine.engineStatus.disableModelInteractionHighlight=this.bimHighlightDisabledBeforeEditing),this.bimHighlightDisabledBeforeEditing=null}syncSelectedTransform(){if(!this.selectedModelId)return;const e=this.modelList.get(this.selectedModelId);e&&(e.data.position=e.object.position.toArray(),e.data.rotation=e.object.rotation.toArray(),e.data.scale=e.object.scale.toArray())}saveHistory(){this.isRestoring||this.modelTransforms.push(this.getSceneModels())}requireRecord(e){const n=this.modelList.get(e);if(!n)throw new Error(`未找到模型 “${e}”。`);return n}getMaterials(e){const n=[];return e.traverse(i=>{if(!i.isMesh)return;(Array.isArray(i.material)?i.material:[i.material]).forEach(s=>{s&&!n.includes(s)&&n.push(s)})}),n}getMaterialIndices(e,n){return typeof n=="number"?Number.isInteger(n)&&n>=0&&n<e.length?[n]:[]:e.reduce((i,r,s)=>(r.name===n&&i.push(s),i),[])}normalizeData(e){return{id:e.id??this.createId(),url:e.url,name:e.name??"第三方模型",position:e.position??[0,0,0],rotation:e.rotation??[0,0,0,"XYZ"],scale:e.scale??[1,1,1],visible:e.visible??!0,materials:e.materials??[]}}cloneData(e){return JSON.parse(JSON.stringify(e))}createId(){return`model-place-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}removeObject(e){e.parent?.remove(e),e.traverse(n=>{n.geometry?.dispose?.(),(Array.isArray(n.material)?n.material:[n.material]).forEach(i=>{i?.map?.dispose?.(),i?.dispose?.()})})}requestRender(){this.engine.requestComposerRender?.()}}const yg={version:"3.11.10"}.version;function XH(){const t=globalThis.crypto?.subtle;if(!t)throw new Error("[BimEngine] Web Crypto API is required for secure sdkAuth credentials mode");return t}function zM(t){return new TextEncoder().encode(t)}function VM(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function jue(t){let e="";return t.forEach(n=>{e+=String.fromCharCode(n)}),btoa(e)}function VKe(t){const e=t.getUTCFullYear(),n=String(t.getUTCMonth()+1).padStart(2,"0"),i=String(t.getUTCDate()).padStart(2,"0");return`${e}${n}${i}`}async function jKe(t){const e=await XH().digest("SHA-256",VM(zM(t)));return Array.from(new Uint8Array(e)).map(n=>n.toString(16).padStart(2,"0")).join("")}async function HKe(t,e){const n=XH(),i=await n.importKey("raw",VM(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return n.sign("HMAC",i,VM(zM(e)))}function GKe(t){return zM([t.appId,t.engineType,t.requestDate,String(t.timestamp),t.nonce].join("|"))}async function qKe(t){const e=XH(),n=new Date,i=n.getTime(),r=VKe(n),s=globalThis.crypto.randomUUID(),o=globalThis.crypto.getRandomValues(new Uint8Array(12)),a=await jKe(t.appSecret),c=await HKe(zM(a),r),l=await e.importKey("raw",c,"AES-GCM",!1,["encrypt"]),u=JSON.stringify({appKey:t.appKey,appSecret:t.appSecret}),h=await e.encrypt({name:"AES-GCM",iv:o,additionalData:VM(GKe({appId:t.appId,engineType:t.engineType,requestDate:r,timestamp:i,nonce:s})),tagLength:128},l,VM(zM(u)));return{appId:t.appId,engineType:t.engineType,requestDate:r,timestamp:i,nonce:s,iv:jue(o),cipherText:jue(new Uint8Array(h)),sdkVersion:t.sdkVersion,origin:t.origin,product:t.product}}const $H=new Map;function bF(t){return t.replace(/\/+$/,"")}function vF(t){if(t)return t;if(typeof window<"u"&&typeof window.location?.origin=="string")return window.location.origin}function WKe(t,e){return JSON.stringify({endpoint:bF(t.endpoint),token:t.token??"",appId:t.appId??"",appKey:t.appKey??"",appSecret:t.appSecret??"",origin:vF(t.origin)??"",product:t.product??"",engineType:e,sdkVersion:yg})}async function QH(t,e,n){const i=typeof AbortController<"u"?new AbortController:void 0,r=i?setTimeout(()=>i.abort(),n):void 0;try{const s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:i?.signal}),o=await s.json().catch(()=>({}));if(!s.ok){const a=o?.error?.message??o?.message??`SDK authentication failed with status ${s.status}`;throw new Error(a)}return o}finally{r!=null&&clearTimeout(r)}}async function YKe(t,e){const n=await QH(`${bF(t.endpoint)}/oauth/sdk-verify`,{sdkToken:t.token,engineType:e,sdkVersion:yg,origin:vF(t.origin),product:t.product},t.timeoutMs??8e3);return n.sdkToken=t.token,n}async function XKe(t,e){const n=await qKe({appId:t.appId,appKey:t.appKey,appSecret:t.appSecret,engineType:e,sdkVersion:yg,origin:vF(t.origin),product:t.product}),i=await QH(`${bF(t.endpoint)}/oauth/sdk-token/secure`,n,t.timeoutMs??8e3),r=await QH(`${bF(t.endpoint)}/oauth/sdk-verify`,{sdkToken:i.sdkToken,engineType:e,sdkVersion:yg,origin:vF(t.origin),product:t.product},t.timeoutMs??8e3);return r.sdkToken=i.sdkToken,r}async function $Ke(t,e){const n=t?.sdkAuth;if(!n)return null;if(!n.endpoint)throw new Error("[BimEngine] sdkAuth.endpoint is required");if(!n.token&&!(n.appId&&n.appKey&&n.appSecret))return null;const i=WKe(n,e),r=$H.get(i);if(r){const o=await r;return t&&(t.__sdkAuthSession=o),o}const s=(n.token?YKe(n,e):XKe(n,e)).then(o=>{if(o.authorized!==!0)throw new Error("[BimEngine] SDK authorization rejected");return t&&(t.__sdkAuthSession=o),o}).catch(o=>{throw $H.delete(i),o});return $H.set(i,s),s}var KH,Hue;function mr(){return Hue||(Hue=1,KH={options:{usePureJavaScript:!1}}),KH}var JH={exports:{}},ZH,Gue;function QKe(){if(Gue)return ZH;Gue=1;var t={};ZH=t;var e={};t.encode=function(i,r,s){if(typeof r!="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 o="";if(!(i instanceof Uint8Array))o=n(i,r);else{var a=0,c=r.length,l=r.charAt(0),u=[0];for(a=0;a<i.length;++a){for(var h=0,d=i[a];h<u.length;++h)d+=u[h]<<8,u[h]=d%c,d=d/c|0;for(;d>0;)u.push(d%c),d=d/c|0}for(a=0;i[a]===0&&a<i.length-1;++a)o+=l;for(a=u.length-1;a>=0;--a)o+=r[u[a]]}if(s){var p=new RegExp(".{1,"+s+"}","g");o=o.match(p).join(`\r
|
|
6016
6016
|
`)}return o},t.decode=function(i,r){if(typeof i!="string")throw new TypeError('"input" must be a string.');if(typeof r!="string")throw new TypeError('"alphabet" must be a string.');var s=e[r];if(!s){s=e[r]=[];for(var o=0;o<r.length;++o)s[r.charCodeAt(o)]=o}i=i.replace(/\s/g,"");for(var a=r.length,c=r.charAt(0),l=[0],o=0;o<i.length;o++){var u=s[i.charCodeAt(o)];if(u===void 0)return;for(var h=0,d=u;h<l.length;++h)d+=l[h]*a,l[h]=d&255,d>>=8;for(;d>0;)l.push(d&255),d>>=8}for(var p=0;i[p]===c&&p<i.length-1;++p)l.push(0);return typeof Buffer<"u"?Buffer.from(l.reverse()):new Uint8Array(l.reverse())};function n(i,r){var s=0,o=r.length,a=r.charAt(0),c=[0];for(s=0;s<i.length();++s){for(var l=0,u=i.at(s);l<c.length;++l)u+=c[l]<<8,c[l]=u%o,u=u/o|0;for(;u>0;)c.push(u%o),u=u/o|0}var h="";for(s=0;i.at(s)===0&&s<i.length()-1;++s)h+=a;for(s=c.length-1;s>=0;--s)h+=r[c[s]];return h}return ZH}var que;function cs(){if(que)return JH.exports;que=1;var t=mr(),e=QKe(),n=JH.exports=t.util=t.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){n.nextTick=process.nextTick,typeof setImmediate=="function"?n.setImmediate=setImmediate:n.setImmediate=n.nextTick;return}if(typeof setImmediate=="function"){n.setImmediate=function(){return setImmediate.apply(void 0,arguments)},n.nextTick=function(w){return setImmediate(w)};return}if(n.setImmediate=function(w){setTimeout(w,0)},typeof window<"u"&&typeof window.postMessage=="function"){let w=function(E){if(E.source===window&&E.data===A){E.stopPropagation();var D=v.slice();v.length=0,D.forEach(function(O){O()})}};var A="forge.setImmediate",v=[];n.setImmediate=function(E){v.push(E),v.length===1&&window.postMessage(A,"*")},window.addEventListener("message",w,!0)}if(typeof MutationObserver<"u"){var x=Date.now(),C=!0,T=document.createElement("div"),v=[];new MutationObserver(function(){var E=v.slice();v.length=0,E.forEach(function(D){D()})}).observe(T,{attributes:!0});var S=n.setImmediate;n.setImmediate=function(E){Date.now()-x>15?(x=Date.now(),S(E)):(v.push(E),v.length===1&&T.setAttribute("a",C=!C))}}n.nextTick=n.setImmediate})(),n.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,n.globalScope=(function(){return n.isNodejs?Wb:typeof self>"u"?window:self})(),n.isArray=Array.isArray||function(A){return Object.prototype.toString.call(A)==="[object Array]"},n.isArrayBuffer=function(A){return typeof ArrayBuffer<"u"&&A instanceof ArrayBuffer},n.isArrayBufferView=function(A){return A&&n.isArrayBuffer(A.buffer)&&A.byteLength!==void 0};function i(A){if(!(A===8||A===16||A===24||A===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+A)}n.ByteBuffer=r;function r(A){if(this.data="",this.read=0,typeof A=="string")this.data=A;else if(n.isArrayBuffer(A)||n.isArrayBufferView(A))if(typeof Buffer<"u"&&A instanceof Buffer)this.data=A.toString("binary");else{var v=new Uint8Array(A);try{this.data=String.fromCharCode.apply(null,v)}catch{for(var x=0;x<v.length;++x)this.putByte(v[x])}}else(A instanceof r||typeof A=="object"&&typeof A.data=="string"&&typeof A.read=="number")&&(this.data=A.data,this.read=A.read);this._constructedStringLength=0}n.ByteStringBuffer=r;var s=4096;n.ByteStringBuffer.prototype._optimizeConstructedString=function(A){this._constructedStringLength+=A,this._constructedStringLength>s&&(this.data.substr(0,1),this._constructedStringLength=0)},n.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},n.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},n.ByteStringBuffer.prototype.putByte=function(A){return this.putBytes(String.fromCharCode(A))},n.ByteStringBuffer.prototype.fillWithByte=function(A,v){A=String.fromCharCode(A);for(var x=this.data;v>0;)v&1&&(x+=A),v>>>=1,v>0&&(A+=A);return this.data=x,this._optimizeConstructedString(v),this},n.ByteStringBuffer.prototype.putBytes=function(A){return this.data+=A,this._optimizeConstructedString(A.length),this},n.ByteStringBuffer.prototype.putString=function(A){return this.putBytes(n.encodeUtf8(A))},n.ByteStringBuffer.prototype.putInt16=function(A){return this.putBytes(String.fromCharCode(A>>8&255)+String.fromCharCode(A&255))},n.ByteStringBuffer.prototype.putInt24=function(A){return this.putBytes(String.fromCharCode(A>>16&255)+String.fromCharCode(A>>8&255)+String.fromCharCode(A&255))},n.ByteStringBuffer.prototype.putInt32=function(A){return this.putBytes(String.fromCharCode(A>>24&255)+String.fromCharCode(A>>16&255)+String.fromCharCode(A>>8&255)+String.fromCharCode(A&255))},n.ByteStringBuffer.prototype.putInt16Le=function(A){return this.putBytes(String.fromCharCode(A&255)+String.fromCharCode(A>>8&255))},n.ByteStringBuffer.prototype.putInt24Le=function(A){return this.putBytes(String.fromCharCode(A&255)+String.fromCharCode(A>>8&255)+String.fromCharCode(A>>16&255))},n.ByteStringBuffer.prototype.putInt32Le=function(A){return this.putBytes(String.fromCharCode(A&255)+String.fromCharCode(A>>8&255)+String.fromCharCode(A>>16&255)+String.fromCharCode(A>>24&255))},n.ByteStringBuffer.prototype.putInt=function(A,v){i(v);var x="";do v-=8,x+=String.fromCharCode(A>>v&255);while(v>0);return this.putBytes(x)},n.ByteStringBuffer.prototype.putSignedInt=function(A,v){return A<0&&(A+=2<<v-1),this.putInt(A,v)},n.ByteStringBuffer.prototype.putBuffer=function(A){return this.putBytes(A.getBytes())},n.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},n.ByteStringBuffer.prototype.getInt16=function(){var A=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,A},n.ByteStringBuffer.prototype.getInt24=function(){var A=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,A},n.ByteStringBuffer.prototype.getInt32=function(){var A=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,A},n.ByteStringBuffer.prototype.getInt16Le=function(){var A=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,A},n.ByteStringBuffer.prototype.getInt24Le=function(){var A=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,A},n.ByteStringBuffer.prototype.getInt32Le=function(){var A=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,A},n.ByteStringBuffer.prototype.getInt=function(A){i(A);var v=0;do v=(v<<8)+this.data.charCodeAt(this.read++),A-=8;while(A>0);return v},n.ByteStringBuffer.prototype.getSignedInt=function(A){var v=this.getInt(A),x=2<<A-2;return v>=x&&(v-=x<<1),v},n.ByteStringBuffer.prototype.getBytes=function(A){var v;return A?(A=Math.min(this.length(),A),v=this.data.slice(this.read,this.read+A),this.read+=A):A===0?v="":(v=this.read===0?this.data:this.data.slice(this.read),this.clear()),v},n.ByteStringBuffer.prototype.bytes=function(A){return typeof A>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+A)},n.ByteStringBuffer.prototype.at=function(A){return this.data.charCodeAt(this.read+A)},n.ByteStringBuffer.prototype.setAt=function(A,v){return this.data=this.data.substr(0,this.read+A)+String.fromCharCode(v)+this.data.substr(this.read+A+1),this},n.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},n.ByteStringBuffer.prototype.copy=function(){var A=n.createBuffer(this.data);return A.read=this.read,A},n.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},n.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},n.ByteStringBuffer.prototype.truncate=function(A){var v=Math.max(0,this.length()-A);return this.data=this.data.substr(this.read,v),this.read=0,this},n.ByteStringBuffer.prototype.toHex=function(){for(var A="",v=this.read;v<this.data.length;++v){var x=this.data.charCodeAt(v);x<16&&(A+="0"),A+=x.toString(16)}return A},n.ByteStringBuffer.prototype.toString=function(){return n.decodeUtf8(this.bytes())};function o(A,v){v=v||{},this.read=v.readOffset||0,this.growSize=v.growSize||1024;var x=n.isArrayBuffer(A),C=n.isArrayBufferView(A);if(x||C){x?this.data=new DataView(A):this.data=new DataView(A.buffer,A.byteOffset,A.byteLength),this.write="writeOffset"in v?v.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,A!=null&&this.putBytes(A),"writeOffset"in v&&(this.write=v.writeOffset)}n.DataBuffer=o,n.DataBuffer.prototype.length=function(){return this.write-this.read},n.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},n.DataBuffer.prototype.accommodate=function(A,v){if(this.length()>=A)return this;v=Math.max(v||this.growSize,A);var x=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),C=new Uint8Array(this.length()+v);return C.set(x),this.data=new DataView(C.buffer),this},n.DataBuffer.prototype.putByte=function(A){return this.accommodate(1),this.data.setUint8(this.write++,A),this},n.DataBuffer.prototype.fillWithByte=function(A,v){this.accommodate(v);for(var x=0;x<v;++x)this.data.setUint8(A);return this},n.DataBuffer.prototype.putBytes=function(A,v){if(n.isArrayBufferView(A)){var x=new Uint8Array(A.buffer,A.byteOffset,A.byteLength),C=x.byteLength-x.byteOffset;this.accommodate(C);var T=new Uint8Array(this.data.buffer,this.write);return T.set(x),this.write+=C,this}if(n.isArrayBuffer(A)){var x=new Uint8Array(A);this.accommodate(x.byteLength);var T=new Uint8Array(this.data.buffer);return T.set(x,this.write),this.write+=x.byteLength,this}if(A instanceof n.DataBuffer||typeof A=="object"&&typeof A.read=="number"&&typeof A.write=="number"&&n.isArrayBufferView(A.data)){var x=new Uint8Array(A.data.byteLength,A.read,A.length());this.accommodate(x.byteLength);var T=new Uint8Array(A.data.byteLength,this.write);return T.set(x),this.write+=x.byteLength,this}if(A instanceof n.ByteStringBuffer&&(A=A.data,v="binary"),v=v||"binary",typeof A=="string"){var S;if(v==="hex")return this.accommodate(Math.ceil(A.length/2)),S=new Uint8Array(this.data.buffer,this.write),this.write+=n.binary.hex.decode(A,S,this.write),this;if(v==="base64")return this.accommodate(Math.ceil(A.length/4)*3),S=new Uint8Array(this.data.buffer,this.write),this.write+=n.binary.base64.decode(A,S,this.write),this;if(v==="utf8"&&(A=n.encodeUtf8(A),v="binary"),v==="binary"||v==="raw")return this.accommodate(A.length),S=new Uint8Array(this.data.buffer,this.write),this.write+=n.binary.raw.decode(S),this;if(v==="utf16")return this.accommodate(A.length*2),S=new Uint16Array(this.data.buffer,this.write),this.write+=n.text.utf16.encode(S),this;throw new Error("Invalid encoding: "+v)}throw Error("Invalid parameter: "+A)},n.DataBuffer.prototype.putBuffer=function(A){return this.putBytes(A),A.clear(),this},n.DataBuffer.prototype.putString=function(A){return this.putBytes(A,"utf16")},n.DataBuffer.prototype.putInt16=function(A){return this.accommodate(2),this.data.setInt16(this.write,A),this.write+=2,this},n.DataBuffer.prototype.putInt24=function(A){return this.accommodate(3),this.data.setInt16(this.write,A>>8&65535),this.data.setInt8(this.write,A>>16&255),this.write+=3,this},n.DataBuffer.prototype.putInt32=function(A){return this.accommodate(4),this.data.setInt32(this.write,A),this.write+=4,this},n.DataBuffer.prototype.putInt16Le=function(A){return this.accommodate(2),this.data.setInt16(this.write,A,!0),this.write+=2,this},n.DataBuffer.prototype.putInt24Le=function(A){return this.accommodate(3),this.data.setInt8(this.write,A>>16&255),this.data.setInt16(this.write,A>>8&65535,!0),this.write+=3,this},n.DataBuffer.prototype.putInt32Le=function(A){return this.accommodate(4),this.data.setInt32(this.write,A,!0),this.write+=4,this},n.DataBuffer.prototype.putInt=function(A,v){i(v),this.accommodate(v/8);do v-=8,this.data.setInt8(this.write++,A>>v&255);while(v>0);return this},n.DataBuffer.prototype.putSignedInt=function(A,v){return i(v),this.accommodate(v/8),A<0&&(A+=2<<v-1),this.putInt(A,v)},n.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},n.DataBuffer.prototype.getInt16=function(){var A=this.data.getInt16(this.read);return this.read+=2,A},n.DataBuffer.prototype.getInt24=function(){var A=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,A},n.DataBuffer.prototype.getInt32=function(){var A=this.data.getInt32(this.read);return this.read+=4,A},n.DataBuffer.prototype.getInt16Le=function(){var A=this.data.getInt16(this.read,!0);return this.read+=2,A},n.DataBuffer.prototype.getInt24Le=function(){var A=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,A},n.DataBuffer.prototype.getInt32Le=function(){var A=this.data.getInt32(this.read,!0);return this.read+=4,A},n.DataBuffer.prototype.getInt=function(A){i(A);var v=0;do v=(v<<8)+this.data.getInt8(this.read++),A-=8;while(A>0);return v},n.DataBuffer.prototype.getSignedInt=function(A){var v=this.getInt(A),x=2<<A-2;return v>=x&&(v-=x<<1),v},n.DataBuffer.prototype.getBytes=function(A){var v;return A?(A=Math.min(this.length(),A),v=this.data.slice(this.read,this.read+A),this.read+=A):A===0?v="":(v=this.read===0?this.data:this.data.slice(this.read),this.clear()),v},n.DataBuffer.prototype.bytes=function(A){return typeof A>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+A)},n.DataBuffer.prototype.at=function(A){return this.data.getUint8(this.read+A)},n.DataBuffer.prototype.setAt=function(A,v){return this.data.setUint8(A,v),this},n.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},n.DataBuffer.prototype.copy=function(){return new n.DataBuffer(this)},n.DataBuffer.prototype.compact=function(){if(this.read>0){var A=new Uint8Array(this.data.buffer,this.read),v=new Uint8Array(A.byteLength);v.set(A),this.data=new DataView(v),this.write-=this.read,this.read=0}return this},n.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},n.DataBuffer.prototype.truncate=function(A){return this.write=Math.max(0,this.length()-A),this.read=Math.min(this.read,this.write),this},n.DataBuffer.prototype.toHex=function(){for(var A="",v=this.read;v<this.data.byteLength;++v){var x=this.data.getUint8(v);x<16&&(A+="0"),A+=x.toString(16)}return A},n.DataBuffer.prototype.toString=function(A){var v=new Uint8Array(this.data,this.read,this.length());if(A=A||"utf8",A==="binary"||A==="raw")return n.binary.raw.encode(v);if(A==="hex")return n.binary.hex.encode(v);if(A==="base64")return n.binary.base64.encode(v);if(A==="utf8")return n.text.utf8.decode(v);if(A==="utf16")return n.text.utf16.decode(v);throw new Error("Invalid encoding: "+A)},n.createBuffer=function(A,v){return v=v||"raw",A!==void 0&&v==="utf8"&&(A=n.encodeUtf8(A)),new n.ByteBuffer(A)},n.fillString=function(A,v){for(var x="";v>0;)v&1&&(x+=A),v>>>=1,v>0&&(A+=A);return x},n.xorBytes=function(A,v,x){for(var C="",T="",S="",w=0,E=0;x>0;--x,++w)T=A.charCodeAt(w)^v.charCodeAt(w),E>=10&&(C+=S,S="",E=0),S+=String.fromCharCode(T),++E;return C+=S,C},n.hexToBytes=function(A){var v="",x=0;for(A.length&!0&&(x=1,v+=String.fromCharCode(parseInt(A[0],16)));x<A.length;x+=2)v+=String.fromCharCode(parseInt(A.substr(x,2),16));return v},n.bytesToHex=function(A){return n.createBuffer(A).toHex()},n.int32ToBytes=function(A){return String.fromCharCode(A>>24&255)+String.fromCharCode(A>>16&255)+String.fromCharCode(A>>8&255)+String.fromCharCode(A&255)};var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",c=[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],l="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";n.encode64=function(A,v){for(var x="",C="",T,S,w,E=0;E<A.length;)T=A.charCodeAt(E++),S=A.charCodeAt(E++),w=A.charCodeAt(E++),x+=a.charAt(T>>2),x+=a.charAt((T&3)<<4|S>>4),isNaN(S)?x+="==":(x+=a.charAt((S&15)<<2|w>>6),x+=isNaN(w)?"=":a.charAt(w&63)),v&&x.length>v&&(C+=x.substr(0,v)+`\r
|
|
6017
6017
|
`,x=x.substr(v));return C+=x,C},n.decode64=function(A){A=A.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var v="",x,C,T,S,w=0;w<A.length;)x=c[A.charCodeAt(w++)-43],C=c[A.charCodeAt(w++)-43],T=c[A.charCodeAt(w++)-43],S=c[A.charCodeAt(w++)-43],v+=String.fromCharCode(x<<2|C>>4),T!==64&&(v+=String.fromCharCode((C&15)<<4|T>>2),S!==64&&(v+=String.fromCharCode((T&3)<<6|S)));return v},n.encodeUtf8=function(A){return unescape(encodeURIComponent(A))},n.decodeUtf8=function(A){return decodeURIComponent(escape(A))},n.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:e.encode,decode:e.decode}},n.binary.raw.encode=function(A){return String.fromCharCode.apply(null,A)},n.binary.raw.decode=function(A,v,x){var C=v;C||(C=new Uint8Array(A.length)),x=x||0;for(var T=x,S=0;S<A.length;++S)C[T++]=A.charCodeAt(S);return v?T-x:C},n.binary.hex.encode=n.bytesToHex,n.binary.hex.decode=function(A,v,x){var C=v;C||(C=new Uint8Array(Math.ceil(A.length/2))),x=x||0;var T=0,S=x;for(A.length&1&&(T=1,C[S++]=parseInt(A[0],16));T<A.length;T+=2)C[S++]=parseInt(A.substr(T,2),16);return v?S-x:C},n.binary.base64.encode=function(A,v){for(var x="",C="",T,S,w,E=0;E<A.byteLength;)T=A[E++],S=A[E++],w=A[E++],x+=a.charAt(T>>2),x+=a.charAt((T&3)<<4|S>>4),isNaN(S)?x+="==":(x+=a.charAt((S&15)<<2|w>>6),x+=isNaN(w)?"=":a.charAt(w&63)),v&&x.length>v&&(C+=x.substr(0,v)+`\r
|
|
6018
6018
|
`,x=x.substr(v));return C+=x,C},n.binary.base64.decode=function(A,v,x){var C=v;C||(C=new Uint8Array(Math.ceil(A.length/4)*3)),A=A.replace(/[^A-Za-z0-9\+\/\=]/g,""),x=x||0;for(var T,S,w,E,D=0,O=x;D<A.length;)T=c[A.charCodeAt(D++)-43],S=c[A.charCodeAt(D++)-43],w=c[A.charCodeAt(D++)-43],E=c[A.charCodeAt(D++)-43],C[O++]=T<<2|S>>4,w!==64&&(C[O++]=(S&15)<<4|w>>2,E!==64&&(C[O++]=(w&3)<<6|E));return v?O-x:C.subarray(0,O)},n.binary.base58.encode=function(A,v){return n.binary.baseN.encode(A,l,v)},n.binary.base58.decode=function(A,v){return n.binary.baseN.decode(A,l,v)},n.text={utf8:{},utf16:{}},n.text.utf8.encode=function(A,v,x){A=n.encodeUtf8(A);var C=v;C||(C=new Uint8Array(A.length)),x=x||0;for(var T=x,S=0;S<A.length;++S)C[T++]=A.charCodeAt(S);return v?T-x:C},n.text.utf8.decode=function(A){return n.decodeUtf8(String.fromCharCode.apply(null,A))},n.text.utf16.encode=function(A,v,x){var C=v;C||(C=new Uint8Array(A.length*2));var T=new Uint16Array(C.buffer);x=x||0;for(var S=x,w=x,E=0;E<A.length;++E)T[w++]=A.charCodeAt(E),S+=2;return v?S-x:C},n.text.utf16.decode=function(A){return String.fromCharCode.apply(null,new Uint16Array(A.buffer))},n.deflate=function(A,v,x){if(v=n.decode64(A.deflate(n.encode64(v)).rval),x){var C=2,T=v.charCodeAt(1);T&32&&(C=6),v=v.substring(C,v.length-4)}return v},n.inflate=function(A,v,x){var C=A.inflate(n.encode64(v)).rval;return C===null?null:n.decode64(C)};var u=function(A,v,x){if(!A)throw new Error("WebStorage not available.");var C;if(x===null?C=A.removeItem(v):(x=n.encode64(JSON.stringify(x)),C=A.setItem(v,x)),typeof C<"u"&&C.rval!==!0){var T=new Error(C.error.message);throw T.id=C.error.id,T.name=C.error.name,T}},h=function(A,v){if(!A)throw new Error("WebStorage not available.");var x=A.getItem(v);if(A.init)if(x.rval===null){if(x.error){var C=new Error(x.error.message);throw C.id=x.error.id,C.name=x.error.name,C}x=null}else x=x.rval;return x!==null&&(x=JSON.parse(n.decode64(x))),x},d=function(A,v,x,C){var T=h(A,v);T===null&&(T={}),T[x]=C,u(A,v,T)},p=function(A,v,x){var C=h(A,v);return C!==null&&(C=x in C?C[x]:null),C},m=function(A,v,x){var C=h(A,v);if(C!==null&&x in C){delete C[x];var T=!0;for(var S in C){T=!1;break}T&&(C=null),u(A,v,C)}},g=function(A,v){u(A,v,null)},y=function(A,v,x){var C=null;typeof x>"u"&&(x=["web","flash"]);var T,S=!1,w=null;for(var E in x){T=x[E];try{if(T==="flash"||T==="both"){if(v[0]===null)throw new Error("Flash local storage not available.");C=A.apply(this,v),S=T==="flash"}(T==="web"||T==="both")&&(v[0]=localStorage,C=A.apply(this,v),S=!0)}catch(D){w=D}if(S)break}if(!S)throw w;return C};return n.setItem=function(A,v,x,C,T){y(d,arguments,T)},n.getItem=function(A,v,x,C){return y(p,arguments,C)},n.removeItem=function(A,v,x,C){y(m,arguments,C)},n.clearItems=function(A,v,x){y(g,arguments,x)},n.isEmpty=function(A){for(var v in A)if(A.hasOwnProperty(v))return!1;return!0},n.format=function(A){for(var v=/%./g,x,C,T=0,S=[],w=0;x=v.exec(A);){C=A.substring(w,v.lastIndex-2),C.length>0&&S.push(C),w=v.lastIndex;var E=x[0][1];switch(E){case"s":case"o":T<arguments.length?S.push(arguments[T+++1]):S.push("<?>");break;case"%":S.push("%");break;default:S.push("<%"+E+"?>")}}return S.push(A.substring(w)),S.join("")},n.formatNumber=function(A,v,x,C){var T=A,S=isNaN(v=Math.abs(v))?2:v,w=x===void 0?",":x,E=C===void 0?".":C,D=T<0?"-":"",O=parseInt(T=Math.abs(+T||0).toFixed(S),10)+"",P=O.length>3?O.length%3:0;return D+(P?O.substr(0,P)+E:"")+O.substr(P).replace(/(\d{3})(?=\d)/g,"$1"+E)+(S?w+Math.abs(T-O).toFixed(S).slice(2):"")},n.formatSize=function(A){return A>=1073741824?A=n.formatNumber(A/1073741824,2,".","")+" GiB":A>=1048576?A=n.formatNumber(A/1048576,2,".","")+" MiB":A>=1024?A=n.formatNumber(A/1024,0)+" KiB":A=n.formatNumber(A,0)+" bytes",A},n.bytesFromIP=function(A){return A.indexOf(".")!==-1?n.bytesFromIPv4(A):A.indexOf(":")!==-1?n.bytesFromIPv6(A):null},n.bytesFromIPv4=function(A){if(A=A.split("."),A.length!==4)return null;for(var v=n.createBuffer(),x=0;x<A.length;++x){var C=parseInt(A[x],10);if(isNaN(C))return null;v.putByte(C)}return v.getBytes()},n.bytesFromIPv6=function(A){var v=0;A=A.split(":").filter(function(w){return w.length===0&&++v,!0});for(var x=(8-A.length+v)*2,C=n.createBuffer(),T=0;T<8;++T){if(!A[T]||A[T].length===0){C.fillWithByte(0,x),x=0;continue}var S=n.hexToBytes(A[T]);S.length<2&&C.putByte(0),C.putBytes(S)}return C.getBytes()},n.bytesToIP=function(A){return A.length===4?n.bytesToIPv4(A):A.length===16?n.bytesToIPv6(A):null},n.bytesToIPv4=function(A){if(A.length!==4)return null;for(var v=[],x=0;x<A.length;++x)v.push(A.charCodeAt(x));return v.join(".")},n.bytesToIPv6=function(A){if(A.length!==16)return null;for(var v=[],x=[],C=0,T=0;T<A.length;T+=2){for(var S=n.bytesToHex(A[T]+A[T+1]);S[0]==="0"&&S!=="0";)S=S.substr(1);if(S==="0"){var w=x[x.length-1],E=v.length;!w||E!==w.end+1?x.push({start:E,end:E}):(w.end=E,w.end-w.start>x[C].end-x[C].start&&(C=x.length-1))}v.push(S)}if(x.length>0){var D=x[C];D.end-D.start>0&&(v.splice(D.start,D.end-D.start+1,""),D.start===0&&v.unshift(""),D.end===7&&v.push(""))}return v.join(":")},n.estimateCores=function(A,v){if(typeof A=="function"&&(v=A,A={}),A=A||{},"cores"in n&&!A.update)return v(null,n.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return n.cores=navigator.hardwareConcurrency,v(null,n.cores);if(typeof Worker>"u")return n.cores=1,v(null,n.cores);if(typeof Blob>"u")return n.cores=2,v(null,n.cores);var x=URL.createObjectURL(new Blob(["(",(function(){self.addEventListener("message",function(w){var E=Date.now(),D=E+4;self.postMessage({st:E,et:D})})}).toString(),")()"],{type:"application/javascript"}));C([],5,16);function C(w,E,D){if(E===0){var O=Math.floor(w.reduce(function(P,I){return P+I},0)/w.length);return n.cores=Math.max(1,O),URL.revokeObjectURL(x),v(null,n.cores)}T(D,function(P,I){w.push(S(D,I)),C(w,E-1,D)})}function T(w,E){for(var D=[],O=[],P=0;P<w;++P){var I=new Worker(x);I.addEventListener("message",function(_){if(O.push(_.data),O.length===w){for(var M=0;M<w;++M)D[M].terminate();E(null,O)}}),D.push(I)}for(var P=0;P<w;++P)D[P].postMessage(P)}function S(w,E){for(var D=[],O=0;O<w;++O)for(var P=E[O],I=D[O]=[],_=0;_<w;++_)if(O!==_){var M=E[_];(P.st>M.st&&P.st<M.et||M.st>P.st&&M.st<P.et)&&I.push(_)}return D.reduce(function(L,N){return Math.max(L,N.length)},0)}},JH.exports}var eG,Wue;function tG(){if(Wue)return eG;Wue=1;var t=mr();cs(),eG=t.cipher=t.cipher||{},t.cipher.algorithms=t.cipher.algorithms||{},t.cipher.createCipher=function(n,i){var r=n;if(typeof r=="string"&&(r=t.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+n);return new t.cipher.BlockCipher({algorithm:r,key:i,decrypt:!1})},t.cipher.createDecipher=function(n,i){var r=n;if(typeof r=="string"&&(r=t.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+n);return new t.cipher.BlockCipher({algorithm:r,key:i,decrypt:!0})},t.cipher.registerAlgorithm=function(n,i){n=n.toUpperCase(),t.cipher.algorithms[n]=i},t.cipher.getAlgorithm=function(n){return n=n.toUpperCase(),n in t.cipher.algorithms?t.cipher.algorithms[n]:null};var e=t.cipher.BlockCipher=function(n){this.algorithm=n.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=n.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=n.decrypt,this.algorithm.initialize(n)};return e.prototype.start=function(n){n=n||{};var i={};for(var r in n)i[r]=n[r];i.decrypt=this._decrypt,this._finish=!1,this._input=t.util.createBuffer(),this.output=n.output||t.util.createBuffer(),this.mode.start(i)},e.prototype.update=function(n){for(n&&this._input.putBuffer(n);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},e.prototype.finish=function(n){n&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(r){return n(this.blockSize,r,!1)},this.mode.unpad=function(r){return n(this.blockSize,r,!0)});var i={};return i.decrypt=this._decrypt,i.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,i)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,i))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,i))},eG}var nG={exports:{}},Yue;function Xue(){if(Yue)return nG.exports;Yue=1;var t=mr();cs(),t.cipher=t.cipher||{};var e=nG.exports=t.cipher.modes=t.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,o,a){if(s.length()<this.blockSize&&!(a&&s.length()>0))return!0;for(var c=0;c<this._ints;++c)this._inBlock[c]=s.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var c=0;c<this._ints;++c)o.putInt32(this._outBlock[c])},e.ecb.prototype.decrypt=function(s,o,a){if(s.length()<this.blockSize&&!(a&&s.length()>0))return!0;for(var c=0;c<this._ints;++c)this._inBlock[c]=s.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var c=0;c<this._ints;++c)o.putInt32(this._outBlock[c])},e.ecb.prototype.pad=function(s,o){var a=s.length()===this.blockSize?this.blockSize:this.blockSize-s.length();return s.fillWithByte(a,a),!0},e.ecb.prototype.unpad=function(s,o){if(o.overflow>0)return!1;var a=s.length(),c=s.at(a-1);return c>this.blockSize<<2?!1:(s.truncate(c),!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=n(s.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")},e.cbc.prototype.encrypt=function(s,o,a){if(s.length()<this.blockSize&&!(a&&s.length()>0))return!0;for(var c=0;c<this._ints;++c)this._inBlock[c]=this._prev[c]^s.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var c=0;c<this._ints;++c)o.putInt32(this._outBlock[c]);this._prev=this._outBlock},e.cbc.prototype.decrypt=function(s,o,a){if(s.length()<this.blockSize&&!(a&&s.length()>0))return!0;for(var c=0;c<this._ints;++c)this._inBlock[c]=s.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var c=0;c<this._ints;++c)o.putInt32(this._prev[c]^this._outBlock[c]);this._prev=this._inBlock.slice(0)},e.cbc.prototype.pad=function(s,o){var a=s.length()===this.blockSize?this.blockSize:this.blockSize-s.length();return s.fillWithByte(a,a),!0},e.cbc.prototype.unpad=function(s,o){if(o.overflow>0)return!1;var a=s.length(),c=s.at(a-1);return c>this.blockSize<<2?!1:(s.truncate(c),!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=t.util.createBuffer(),this._partialBytes=0},e.cfb.prototype.start=function(s){if(!("iv"in s))throw new Error("Invalid IV parameter.");this._iv=n(s.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.cfb.prototype.encrypt=function(s,o,a){var c=s.length();if(c===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&c>=this.blockSize){for(var l=0;l<this._ints;++l)this._inBlock[l]=s.getInt32()^this._outBlock[l],o.putInt32(this._inBlock[l]);return}var u=(this.blockSize-c)%this.blockSize;u>0&&(u=this.blockSize-u),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialBlock[l]=s.getInt32()^this._outBlock[l],this._partialOutput.putInt32(this._partialBlock[l]);if(u>0)s.read-=this.blockSize;else for(var l=0;l<this._ints;++l)this._inBlock[l]=this._partialBlock[l];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),u>0&&!a)return o.putBytes(this._partialOutput.getBytes(u-this._partialBytes)),this._partialBytes=u,!0;o.putBytes(this._partialOutput.getBytes(c-this._partialBytes)),this._partialBytes=0},e.cfb.prototype.decrypt=function(s,o,a){var c=s.length();if(c===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&c>=this.blockSize){for(var l=0;l<this._ints;++l)this._inBlock[l]=s.getInt32(),o.putInt32(this._inBlock[l]^this._outBlock[l]);return}var u=(this.blockSize-c)%this.blockSize;u>0&&(u=this.blockSize-u),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialBlock[l]=s.getInt32(),this._partialOutput.putInt32(this._partialBlock[l]^this._outBlock[l]);if(u>0)s.read-=this.blockSize;else for(var l=0;l<this._ints;++l)this._inBlock[l]=this._partialBlock[l];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),u>0&&!a)return o.putBytes(this._partialOutput.getBytes(u-this._partialBytes)),this._partialBytes=u,!0;o.putBytes(this._partialOutput.getBytes(c-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=t.util.createBuffer(),this._partialBytes=0},e.ofb.prototype.start=function(s){if(!("iv"in s))throw new Error("Invalid IV parameter.");this._iv=n(s.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ofb.prototype.encrypt=function(s,o,a){var c=s.length();if(s.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&c>=this.blockSize){for(var l=0;l<this._ints;++l)o.putInt32(s.getInt32()^this._outBlock[l]),this._inBlock[l]=this._outBlock[l];return}var u=(this.blockSize-c)%this.blockSize;u>0&&(u=this.blockSize-u),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(s.getInt32()^this._outBlock[l]);if(u>0)s.read-=this.blockSize;else for(var l=0;l<this._ints;++l)this._inBlock[l]=this._outBlock[l];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),u>0&&!a)return o.putBytes(this._partialOutput.getBytes(u-this._partialBytes)),this._partialBytes=u,!0;o.putBytes(this._partialOutput.getBytes(c-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=t.util.createBuffer(),this._partialBytes=0},e.ctr.prototype.start=function(s){if(!("iv"in s))throw new Error("Invalid IV parameter.");this._iv=n(s.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ctr.prototype.encrypt=function(s,o,a){var c=s.length();if(c===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&c>=this.blockSize)for(var l=0;l<this._ints;++l)o.putInt32(s.getInt32()^this._outBlock[l]);else{var u=(this.blockSize-c)%this.blockSize;u>0&&(u=this.blockSize-u),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(s.getInt32()^this._outBlock[l]);if(u>0&&(s.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),u>0&&!a)return o.putBytes(this._partialOutput.getBytes(u-this._partialBytes)),this._partialBytes=u,!0;o.putBytes(this._partialOutput.getBytes(c-this._partialBytes)),this._partialBytes=0}i(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=t.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 o=t.util.createBuffer(s.iv);this._cipherLength=0;var a;if("additionalData"in s?a=t.util.createBuffer(s.additionalData):a=t.util.createBuffer(),"tagLength"in s?this._tagLength=s.tagLength:this._tagLength=128,this._tag=null,s.decrypt&&(this._tag=t.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 c=o.length();if(c===12)this._j0=[o.getInt32(),o.getInt32(),o.getInt32(),1];else{for(this._j0=[0,0,0,0];o.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[o.getInt32(),o.getInt32(),o.getInt32(),o.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(r(c*8)))}this._inBlock=this._j0.slice(0),i(this._inBlock),this._partialBytes=0,a=t.util.createBuffer(a),this._aDataLength=r(a.length()*8);var l=a.length()%this.blockSize;for(l&&a.fillWithByte(0,this.blockSize-l),this._s=[0,0,0,0];a.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()])},e.gcm.prototype.encrypt=function(s,o,a){var c=s.length();if(c===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&c>=this.blockSize){for(var l=0;l<this._ints;++l)o.putInt32(this._outBlock[l]^=s.getInt32());this._cipherLength+=this.blockSize}else{var u=(this.blockSize-c)%this.blockSize;u>0&&(u=this.blockSize-u),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(s.getInt32()^this._outBlock[l]);if(u<=0||a){if(a){var h=c%this.blockSize;this._cipherLength+=h,this._partialOutput.truncate(this.blockSize-h)}else this._cipherLength+=this.blockSize;for(var l=0;l<this._ints;++l)this._outBlock[l]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),u>0&&!a)return s.read-=this.blockSize,o.putBytes(this._partialOutput.getBytes(u-this._partialBytes)),this._partialBytes=u,!0;o.putBytes(this._partialOutput.getBytes(c-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),i(this._inBlock)},e.gcm.prototype.decrypt=function(s,o,a){var c=s.length();if(c<this.blockSize&&!(a&&c>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),i(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 l=0;l<this._ints;++l)o.putInt32(this._outBlock[l]^this._hashBlock[l]);c<this.blockSize?this._cipherLength+=c%this.blockSize:this._cipherLength+=this.blockSize},e.gcm.prototype.afterFinish=function(s,o){var a=!0;o.decrypt&&o.overflow&&s.truncate(this.blockSize-o.overflow),this.tag=t.util.createBuffer();var c=this._aDataLength.concat(r(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,c);var l=[];this.cipher.encrypt(this._j0,l);for(var u=0;u<this._ints;++u)this.tag.putInt32(this._s[u]^l[u]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),o.decrypt&&this.tag.bytes()!==this._tag&&(a=!1),a},e.gcm.prototype.multiply=function(s,o){for(var a=[0,0,0,0],c=o.slice(0),l=0;l<128;++l){var u=s[l/32|0]&1<<31-l%32;u&&(a[0]^=c[0],a[1]^=c[1],a[2]^=c[2],a[3]^=c[3]),this.pow(c,c)}return a},e.gcm.prototype.pow=function(s,o){for(var a=s[3]&1,c=3;c>0;--c)o[c]=s[c]>>>1|(s[c-1]&1)<<31;o[0]=s[0]>>>1,a&&(o[0]^=this._R)},e.gcm.prototype.tableMultiply=function(s){for(var o=[0,0,0,0],a=0;a<32;++a){var c=a/8|0,l=s[c]>>>(7-a%8)*4&15,u=this._m[a][l];o[0]^=u[0],o[1]^=u[1],o[2]^=u[2],o[3]^=u[3]}return o},e.gcm.prototype.ghash=function(s,o,a){return o[0]^=a[0],o[1]^=a[1],o[2]^=a[2],o[3]^=a[3],this.tableMultiply(o)},e.gcm.prototype.generateHashTable=function(s,o){for(var a=8/o,c=4*a,l=16*a,u=new Array(l),h=0;h<l;++h){var d=[0,0,0,0],p=h/c|0,m=(c-1-h%c)*o;d[p]=1<<o-1<<m,u[h]=this.generateSubHashTable(this.multiply(d,s),o)}return u},e.gcm.prototype.generateSubHashTable=function(s,o){var a=1<<o,c=a>>>1,l=new Array(a);l[c]=s.slice(0);for(var u=c>>>1;u>0;)this.pow(l[2*u],l[u]=[]),u>>=1;for(u=2;u<c;){for(var h=1;h<u;++h){var d=l[u],p=l[h];l[u+h]=[d[0]^p[0],d[1]^p[1],d[2]^p[2],d[3]^p[3]]}u*=2}for(l[0]=[0,0,0,0],u=c+1;u<a;++u){var m=l[u^c];l[u]=[s[0]^m[0],s[1]^m[1],s[2]^m[2],s[3]^m[3]]}return l};function n(s,o){if(typeof s=="string"&&(s=t.util.createBuffer(s)),t.util.isArray(s)&&s.length>4){var a=s;s=t.util.createBuffer();for(var c=0;c<a.length;++c)s.putByte(a[c])}if(s.length()<o)throw new Error("Invalid IV length; got "+s.length()+" bytes and expected "+o+" bytes.");if(!t.util.isArray(s)){for(var l=[],u=o/4,c=0;c<u;++c)l.push(s.getInt32());s=l}return s}function i(s){s[s.length-1]=s[s.length-1]+1&4294967295}function r(s){return[s/4294967296|0,s&4294967295]}return nG.exports}var iG,$ue;function Dv(){if($ue)return iG;$ue=1;var t=mr();tG(),Xue(),cs(),iG=t.aes=t.aes||{},t.aes.startEncrypting=function(p,m,g,y){var A=d({key:p,output:g,decrypt:!1,mode:y});return A.start(m),A},t.aes.createEncryptionCipher=function(p,m){return d({key:p,output:null,decrypt:!1,mode:m})},t.aes.startDecrypting=function(p,m,g,y){var A=d({key:p,output:g,decrypt:!0,mode:y});return A.start(m),A},t.aes.createDecryptionCipher=function(p,m){return d({key:p,output:null,decrypt:!0,mode:m})},t.aes.Algorithm=function(p,m){n||l();var g=this;g.name=p,g.mode=new m({blockSize:16,cipher:{encrypt:function(y,A){return h(g._w,y,A,!1)},decrypt:function(y,A){return h(g._w,y,A,!0)}}}),g._init=!1},t.aes.Algorithm.prototype.initialize=function(p){if(!this._init){var m=p.key,g;if(typeof m=="string"&&(m.length===16||m.length===24||m.length===32))m=t.util.createBuffer(m);else if(t.util.isArray(m)&&(m.length===16||m.length===24||m.length===32)){g=m,m=t.util.createBuffer();for(var y=0;y<g.length;++y)m.putByte(g[y])}if(!t.util.isArray(m)){g=m,m=[];var A=g.length();if(A===16||A===24||A===32){A=A>>>2;for(var y=0;y<A;++y)m.push(g.getInt32())}}if(!t.util.isArray(m)||!(m.length===4||m.length===6||m.length===8))throw new Error("Invalid key parameter.");var v=this.mode.name,x=["CFB","OFB","CTR","GCM"].indexOf(v)!==-1;this._w=u(m,p.decrypt&&!x),this._init=!0}},t.aes._expandKey=function(p,m){return n||l(),u(p,m)},t.aes._updateBlock=h,e("AES-ECB",t.cipher.modes.ecb),e("AES-CBC",t.cipher.modes.cbc),e("AES-CFB",t.cipher.modes.cfb),e("AES-OFB",t.cipher.modes.ofb),e("AES-CTR",t.cipher.modes.ctr),e("AES-GCM",t.cipher.modes.gcm);function e(p,m){var g=function(){return new t.aes.Algorithm(p,m)};t.cipher.registerAlgorithm(p,g)}var n=!1,i=4,r,s,o,a,c;function l(){n=!0,o=[0,1,2,4,8,16,32,64,128,27,54];for(var p=new Array(256),m=0;m<128;++m)p[m]=m<<1,p[m+128]=m+128<<1^283;r=new Array(256),s=new Array(256),a=new Array(4),c=new Array(4);for(var m=0;m<4;++m)a[m]=new Array(256),c[m]=new Array(256);for(var g=0,y=0,A,v,x,C,T,S,w,m=0;m<256;++m){C=y^y<<1^y<<2^y<<3^y<<4,C=C>>8^C&255^99,r[g]=C,s[C]=g,T=p[C],A=p[g],v=p[A],x=p[v],S=T<<24^C<<16^C<<8^(C^T),w=(A^v^x)<<24^(g^x)<<16^(g^v^x)<<8^(g^A^x);for(var E=0;E<4;++E)a[E][g]=S,c[E][C]=w,S=S<<24|S>>>8,w=w<<24|w>>>8;g===0?g=y=1:(g=A^p[p[p[A^x]]],y^=p[p[y]])}}function u(p,m){for(var g=p.slice(0),y,A=1,v=g.length,x=v+6+1,C=i*x,T=v;T<C;++T)y=g[T-1],T%v===0?(y=r[y>>>16&255]<<24^r[y>>>8&255]<<16^r[y&255]<<8^r[y>>>24]^o[A]<<24,A++):v>6&&T%v===4&&(y=r[y>>>24]<<24^r[y>>>16&255]<<16^r[y>>>8&255]<<8^r[y&255]),g[T]=g[T-v]^y;if(m){var S,w=c[0],E=c[1],D=c[2],O=c[3],P=g.slice(0);C=g.length;for(var T=0,I=C-i;T<C;T+=i,I-=i)if(T===0||T===C-i)P[T]=g[I],P[T+1]=g[I+3],P[T+2]=g[I+2],P[T+3]=g[I+1];else for(var _=0;_<i;++_)S=g[I+_],P[T+(3&-_)]=w[r[S>>>24]]^E[r[S>>>16&255]]^D[r[S>>>8&255]]^O[r[S&255]];g=P}return g}function h(p,m,g,y){var A=p.length/4-1,v,x,C,T,S;y?(v=c[0],x=c[1],C=c[2],T=c[3],S=s):(v=a[0],x=a[1],C=a[2],T=a[3],S=r);var w,E,D,O,P,I,_;w=m[0]^p[0],E=m[y?3:1]^p[1],D=m[2]^p[2],O=m[y?1:3]^p[3];for(var M=3,L=1;L<A;++L)P=v[w>>>24]^x[E>>>16&255]^C[D>>>8&255]^T[O&255]^p[++M],I=v[E>>>24]^x[D>>>16&255]^C[O>>>8&255]^T[w&255]^p[++M],_=v[D>>>24]^x[O>>>16&255]^C[w>>>8&255]^T[E&255]^p[++M],O=v[O>>>24]^x[w>>>16&255]^C[E>>>8&255]^T[D&255]^p[++M],w=P,E=I,D=_;g[0]=S[w>>>24]<<24^S[E>>>16&255]<<16^S[D>>>8&255]<<8^S[O&255]^p[++M],g[y?3:1]=S[E>>>24]<<24^S[D>>>16&255]<<16^S[O>>>8&255]<<8^S[w&255]^p[++M],g[2]=S[D>>>24]<<24^S[O>>>16&255]<<16^S[w>>>8&255]<<8^S[E&255]^p[++M],g[y?1:3]=S[O>>>24]<<24^S[w>>>16&255]<<16^S[E>>>8&255]<<8^S[D&255]^p[++M]}function d(p){p=p||{};var m=(p.mode||"CBC").toUpperCase(),g="AES-"+m,y;p.decrypt?y=t.cipher.createDecipher(g,p.key):y=t.cipher.createCipher(g,p.key);var A=y.start;return y.start=function(v,x){var C=null;x instanceof t.util.ByteBuffer&&(C=x,x={}),x=x||{},x.output=C,x.iv=v,A.call(y,x)},y}return iG}var rG={exports:{}},sG={exports:{}},oG={exports:{}},Que;function Rv(){if(Que)return oG.exports;Que=1;var t=mr();t.pki=t.pki||{};var e=oG.exports=t.pki.oids=t.oids=t.oids||{};function n(r,s){e[r]=s,e[s]=r}function i(r,s){e[r]=s}return n("1.2.840.113549.1.1.1","rsaEncryption"),n("1.2.840.113549.1.1.4","md5WithRSAEncryption"),n("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),n("1.2.840.113549.1.1.7","RSAES-OAEP"),n("1.2.840.113549.1.1.8","mgf1"),n("1.2.840.113549.1.1.9","pSpecified"),n("1.2.840.113549.1.1.10","RSASSA-PSS"),n("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),n("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),n("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),n("1.3.101.112","EdDSA25519"),n("1.2.840.10040.4.3","dsa-with-sha1"),n("1.3.14.3.2.7","desCBC"),n("1.3.14.3.2.26","sha1"),n("1.3.14.3.2.29","sha1WithRSASignature"),n("2.16.840.1.101.3.4.2.1","sha256"),n("2.16.840.1.101.3.4.2.2","sha384"),n("2.16.840.1.101.3.4.2.3","sha512"),n("2.16.840.1.101.3.4.2.4","sha224"),n("2.16.840.1.101.3.4.2.5","sha512-224"),n("2.16.840.1.101.3.4.2.6","sha512-256"),n("1.2.840.113549.2.2","md2"),n("1.2.840.113549.2.5","md5"),n("1.2.840.113549.1.7.1","data"),n("1.2.840.113549.1.7.2","signedData"),n("1.2.840.113549.1.7.3","envelopedData"),n("1.2.840.113549.1.7.4","signedAndEnvelopedData"),n("1.2.840.113549.1.7.5","digestedData"),n("1.2.840.113549.1.7.6","encryptedData"),n("1.2.840.113549.1.9.1","emailAddress"),n("1.2.840.113549.1.9.2","unstructuredName"),n("1.2.840.113549.1.9.3","contentType"),n("1.2.840.113549.1.9.4","messageDigest"),n("1.2.840.113549.1.9.5","signingTime"),n("1.2.840.113549.1.9.6","counterSignature"),n("1.2.840.113549.1.9.7","challengePassword"),n("1.2.840.113549.1.9.8","unstructuredAddress"),n("1.2.840.113549.1.9.14","extensionRequest"),n("1.2.840.113549.1.9.20","friendlyName"),n("1.2.840.113549.1.9.21","localKeyId"),n("1.2.840.113549.1.9.22.1","x509Certificate"),n("1.2.840.113549.1.12.10.1.1","keyBag"),n("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),n("1.2.840.113549.1.12.10.1.3","certBag"),n("1.2.840.113549.1.12.10.1.4","crlBag"),n("1.2.840.113549.1.12.10.1.5","secretBag"),n("1.2.840.113549.1.12.10.1.6","safeContentsBag"),n("1.2.840.113549.1.5.13","pkcs5PBES2"),n("1.2.840.113549.1.5.12","pkcs5PBKDF2"),n("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),n("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),n("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),n("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),n("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),n("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),n("1.2.840.113549.2.7","hmacWithSHA1"),n("1.2.840.113549.2.8","hmacWithSHA224"),n("1.2.840.113549.2.9","hmacWithSHA256"),n("1.2.840.113549.2.10","hmacWithSHA384"),n("1.2.840.113549.2.11","hmacWithSHA512"),n("1.2.840.113549.3.7","des-EDE3-CBC"),n("2.16.840.1.101.3.4.1.2","aes128-CBC"),n("2.16.840.1.101.3.4.1.22","aes192-CBC"),n("2.16.840.1.101.3.4.1.42","aes256-CBC"),n("2.5.4.3","commonName"),n("2.5.4.4","surname"),n("2.5.4.5","serialNumber"),n("2.5.4.6","countryName"),n("2.5.4.7","localityName"),n("2.5.4.8","stateOrProvinceName"),n("2.5.4.9","streetAddress"),n("2.5.4.10","organizationName"),n("2.5.4.11","organizationalUnitName"),n("2.5.4.12","title"),n("2.5.4.13","description"),n("2.5.4.15","businessCategory"),n("2.5.4.17","postalCode"),n("2.5.4.42","givenName"),n("2.5.4.65","pseudonym"),n("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),n("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),n("2.16.840.1.113730.1.1","nsCertType"),n("2.16.840.1.113730.1.13","nsComment"),i("2.5.29.1","authorityKeyIdentifier"),i("2.5.29.2","keyAttributes"),i("2.5.29.3","certificatePolicies"),i("2.5.29.4","keyUsageRestriction"),i("2.5.29.5","policyMapping"),i("2.5.29.6","subtreesConstraint"),i("2.5.29.7","subjectAltName"),i("2.5.29.8","issuerAltName"),i("2.5.29.9","subjectDirectoryAttributes"),i("2.5.29.10","basicConstraints"),i("2.5.29.11","nameConstraints"),i("2.5.29.12","policyConstraints"),i("2.5.29.13","basicConstraints"),n("2.5.29.14","subjectKeyIdentifier"),n("2.5.29.15","keyUsage"),i("2.5.29.16","privateKeyUsagePeriod"),n("2.5.29.17","subjectAltName"),n("2.5.29.18","issuerAltName"),n("2.5.29.19","basicConstraints"),i("2.5.29.20","cRLNumber"),i("2.5.29.21","cRLReason"),i("2.5.29.22","expirationDate"),i("2.5.29.23","instructionCode"),i("2.5.29.24","invalidityDate"),i("2.5.29.25","cRLDistributionPoints"),i("2.5.29.26","issuingDistributionPoint"),i("2.5.29.27","deltaCRLIndicator"),i("2.5.29.28","issuingDistributionPoint"),i("2.5.29.29","certificateIssuer"),i("2.5.29.30","nameConstraints"),n("2.5.29.31","cRLDistributionPoints"),n("2.5.29.32","certificatePolicies"),i("2.5.29.33","policyMappings"),i("2.5.29.34","policyConstraints"),n("2.5.29.35","authorityKeyIdentifier"),i("2.5.29.36","policyConstraints"),n("2.5.29.37","extKeyUsage"),i("2.5.29.46","freshestCRL"),i("2.5.29.54","inhibitAnyPolicy"),n("1.3.6.1.4.1.11129.2.4.2","timestampList"),n("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),n("1.3.6.1.5.5.7.3.1","serverAuth"),n("1.3.6.1.5.5.7.3.2","clientAuth"),n("1.3.6.1.5.5.7.3.3","codeSigning"),n("1.3.6.1.5.5.7.3.4","emailProtection"),n("1.3.6.1.5.5.7.3.8","timeStamping"),oG.exports}var Kue;function Um(){if(Kue)return sG.exports;Kue=1;var t=mr();cs(),Rv();var e=sG.exports=t.asn1=t.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(o,a,c,l,u){if(t.util.isArray(l)){for(var h=[],d=0;d<l.length;++d)l[d]!==void 0&&h.push(l[d]);l=h}var p={tagClass:o,type:a,constructed:c,composed:c||t.util.isArray(l),value:l};return u&&"bitStringContents"in u&&(p.bitStringContents=u.bitStringContents,p.original=e.copy(p)),p},e.copy=function(o,a){var c;if(t.util.isArray(o)){c=[];for(var l=0;l<o.length;++l)c.push(e.copy(o[l],a));return c}return typeof o=="string"?o:(c={tagClass:o.tagClass,type:o.type,constructed:o.constructed,composed:o.composed,value:e.copy(o.value,a)},a&&!a.excludeBitStringContents&&(c.bitStringContents=o.bitStringContents),c)},e.equals=function(o,a,c){if(t.util.isArray(o)){if(!t.util.isArray(a)||o.length!==a.length)return!1;for(var l=0;l<o.length;++l)if(!e.equals(o[l],a[l]))return!1;return!0}if(typeof o!=typeof a)return!1;if(typeof o=="string")return o===a;var u=o.tagClass===a.tagClass&&o.type===a.type&&o.constructed===a.constructed&&o.composed===a.composed&&e.equals(o.value,a.value);return c&&c.includeBitStringContents&&(u=u&&o.bitStringContents===a.bitStringContents),u},e.getBerValueLength=function(o){var a=o.getByte();if(a!==128){var c,l=a&128;return l?c=o.getInt((a&127)<<3):c=a,c}};function n(o,a,c){if(c>a){var l=new Error("Too few bytes to parse DER.");throw l.available=o.length(),l.remaining=a,l.requested=c,l}}var i=function(o,a){var c=o.getByte();if(a--,c!==128){var l,u=c&128;if(!u)l=c;else{var h=c&127;n(o,a,h),l=o.getInt(h<<3)}if(l<0)throw new Error("Negative length: "+l);return l}};e.fromDer=function(o,a){a===void 0&&(a={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof a=="boolean"&&(a={strict:a,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in a||(a.strict=!0),"parseAllBytes"in a||(a.parseAllBytes=!0),"decodeBitStrings"in a||(a.decodeBitStrings=!0),"maxDepth"in a||(a.maxDepth=e.maxDepth),typeof o=="string"&&(o=t.util.createBuffer(o));var c=o.length(),l=r(o,o.length(),0,a);if(a.parseAllBytes&&o.length()!==0){var u=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw u.byteCount=c,u.remaining=o.length(),u}return l};function r(o,a,c,l){if(c>=l.maxDepth)throw new Error("ASN.1 parsing error: Max depth exceeded.");var u;n(o,a,2);var h=o.getByte();a--;var d=h&192,p=h&31;u=o.length();var m=i(o,a);if(a-=u-o.length(),m!==void 0&&m>a){if(l.strict){var g=new Error("Too few bytes to read ASN.1 value.");throw g.available=o.length(),g.remaining=a,g.requested=m,g}m=a}var y,A,v=(h&32)===32;if(v)if(y=[],m===void 0)for(;;){if(n(o,a,2),o.bytes(2)==="\0\0"){o.getBytes(2),a-=2;break}u=o.length(),y.push(r(o,a,c+1,l)),a-=u-o.length()}else for(;m>0;)u=o.length(),y.push(r(o,m,c+1,l)),a-=u-o.length(),m-=u-o.length();if(y===void 0&&d===e.Class.UNIVERSAL&&p===e.Type.BITSTRING&&(A=o.bytes(m)),y===void 0&&l.decodeBitStrings&&d===e.Class.UNIVERSAL&&p===e.Type.BITSTRING&&m>1){var x=o.read,C=a,T=0;if(p===e.Type.BITSTRING&&(n(o,a,1),T=o.getByte(),a--),T===0)try{u=o.length();var S={strict:!0,decodeBitStrings:!0},w=r(o,a,c+1,S),E=u-o.length();a-=E,p==e.Type.BITSTRING&&E++;var D=w.tagClass;E===m&&(D===e.Class.UNIVERSAL||D===e.Class.CONTEXT_SPECIFIC)&&(y=[w])}catch{}y===void 0&&(o.read=x,a=C)}if(y===void 0){if(m===void 0){if(l.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");m=a}if(p===e.Type.BMPSTRING)for(y="";m>0;m-=2)n(o,a,2),y+=String.fromCharCode(o.getInt16()),a-=2;else y=o.getBytes(m),a-=m}var O=A===void 0?null:{bitStringContents:A};return e.create(d,p,v,y,O)}e.toDer=function(o){var a=t.util.createBuffer(),c=o.tagClass|o.type,l=t.util.createBuffer(),u=!1;if("bitStringContents"in o&&(u=!0,o.original&&(u=e.equals(o,o.original))),u)l.putBytes(o.bitStringContents);else if(o.composed){o.constructed?c|=32:l.putByte(0);for(var h=0;h<o.value.length;++h)o.value[h]!==void 0&&l.putBuffer(e.toDer(o.value[h]))}else if(o.type===e.Type.BMPSTRING)for(var h=0;h<o.value.length;++h)l.putInt16(o.value.charCodeAt(h));else o.type===e.Type.INTEGER&&o.value.length>1&&(o.value.charCodeAt(0)===0&&(o.value.charCodeAt(1)&128)===0||o.value.charCodeAt(0)===255&&(o.value.charCodeAt(1)&128)===128)?l.putBytes(o.value.substr(1)):l.putBytes(o.value);if(a.putByte(c),l.length()<=127)a.putByte(l.length()&127);else{var d=l.length(),p="";do p+=String.fromCharCode(d&255),d=d>>>8;while(d>0);a.putByte(p.length|128);for(var h=p.length-1;h>=0;--h)a.putByte(p.charCodeAt(h))}return a.putBuffer(l),a},e.oidToDer=function(o){var a=o.split("."),c=t.util.createBuffer();c.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var l,u,h,d,p=2;p<a.length;++p){if(l=!0,u=[],h=parseInt(a[p],10),h>4294967295)throw new Error("OID value too large; max is 32-bits.");do d=h&127,h=h>>>7,l||(d|=128),u.push(d),l=!1;while(h>0);for(var m=u.length-1;m>=0;--m)c.putByte(u[m])}return c},e.derToOid=function(o){var a;typeof o=="string"&&(o=t.util.createBuffer(o));var c=o.getByte();a=Math.floor(c/40)+"."+c%40;for(var l=0;o.length()>0;){if(l>70368744177663)throw new Error("OID value too large; max is 53-bits.");c=o.getByte(),l=l*128,c&128?l+=c&127:(a+="."+(l+c),l=0)}return a},e.utcTimeToDate=function(o){var a=new Date,c=parseInt(o.substr(0,2),10);c=c>=50?1900+c:2e3+c;var l=parseInt(o.substr(2,2),10)-1,u=parseInt(o.substr(4,2),10),h=parseInt(o.substr(6,2),10),d=parseInt(o.substr(8,2),10),p=0;if(o.length>11){var m=o.charAt(10),g=10;m!=="+"&&m!=="-"&&(p=parseInt(o.substr(10,2),10),g+=2)}if(a.setUTCFullYear(c,l,u),a.setUTCHours(h,d,p,0),g&&(m=o.charAt(g),m==="+"||m==="-")){var y=parseInt(o.substr(g+1,2),10),A=parseInt(o.substr(g+4,2),10),v=y*60+A;v*=6e4,m==="+"?a.setTime(+a-v):a.setTime(+a+v)}return a},e.generalizedTimeToDate=function(o){var a=new Date,c=parseInt(o.substr(0,4),10),l=parseInt(o.substr(4,2),10)-1,u=parseInt(o.substr(6,2),10),h=parseInt(o.substr(8,2),10),d=parseInt(o.substr(10,2),10),p=parseInt(o.substr(12,2),10),m=0,g=0,y=!1;o.charAt(o.length-1)==="Z"&&(y=!0);var A=o.length-5,v=o.charAt(A);if(v==="+"||v==="-"){var x=parseInt(o.substr(A+1,2),10),C=parseInt(o.substr(A+4,2),10);g=x*60+C,g*=6e4,v==="+"&&(g*=-1),y=!0}return o.charAt(14)==="."&&(m=parseFloat(o.substr(14),10)*1e3),y?(a.setUTCFullYear(c,l,u),a.setUTCHours(h,d,p,m),a.setTime(+a+g)):(a.setFullYear(c,l,u),a.setHours(h,d,p,m)),a},e.dateToUtcTime=function(o){if(typeof o=="string")return o;var a="",c=[];c.push((""+o.getUTCFullYear()).substr(2)),c.push(""+(o.getUTCMonth()+1)),c.push(""+o.getUTCDate()),c.push(""+o.getUTCHours()),c.push(""+o.getUTCMinutes()),c.push(""+o.getUTCSeconds());for(var l=0;l<c.length;++l)c[l].length<2&&(a+="0"),a+=c[l];return a+="Z",a},e.dateToGeneralizedTime=function(o){if(typeof o=="string")return o;var a="",c=[];c.push(""+o.getUTCFullYear()),c.push(""+(o.getUTCMonth()+1)),c.push(""+o.getUTCDate()),c.push(""+o.getUTCHours()),c.push(""+o.getUTCMinutes()),c.push(""+o.getUTCSeconds());for(var l=0;l<c.length;++l)c[l].length<2&&(a+="0"),a+=c[l];return a+="Z",a},e.integerToDer=function(o){var a=t.util.createBuffer();if(o>=-128&&o<128)return a.putSignedInt(o,8);if(o>=-32768&&o<32768)return a.putSignedInt(o,16);if(o>=-8388608&&o<8388608)return a.putSignedInt(o,24);if(o>=-2147483648&&o<2147483648)return a.putSignedInt(o,32);var c=new Error("Integer too large; max is 32-bits.");throw c.integer=o,c},e.derToInteger=function(o){typeof o=="string"&&(o=t.util.createBuffer(o));var a=o.length()*8;if(a>32)throw new Error("Integer too large; max is 32-bits.");return o.getSignedInt(a)},e.validate=function(o,a,c,l){var u=!1;if((o.tagClass===a.tagClass||typeof a.tagClass>"u")&&(o.type===a.type||typeof a.type>"u"))if(o.constructed===a.constructed||typeof a.constructed>"u"){if(u=!0,a.value&&t.util.isArray(a.value))for(var h=0,d=0;u&&d<a.value.length;++d){var p=a.value[d];u=!!p.optional;var m=o.value[h];if(!m){p.optional||(u=!1,l&&l.push("["+a.name+'] Missing required element. Expected tag class "'+p.tagClass+'", type "'+p.type+'"'));continue}var g=typeof p.tagClass<"u"&&typeof p.type<"u";if(g&&(m.tagClass!==p.tagClass||m.type!==p.type))if(p.optional){u=!0;continue}else{u=!1,l&&l.push("["+a.name+"] Tag mismatch. Expected ("+p.tagClass+","+p.type+"), got ("+m.tagClass+","+m.type+")");break}var y=e.validate(m,p,c,l);if(y)++h,u=!0;else if(p.optional)u=!0;else{u=!1;break}}if(u&&c&&(a.capture&&(c[a.capture]=o.value),a.captureAsn1&&(c[a.captureAsn1]=o),a.captureBitStringContents&&"bitStringContents"in o&&(c[a.captureBitStringContents]=o.bitStringContents),a.captureBitStringValue&&"bitStringContents"in o))if(o.bitStringContents.length<2)c[a.captureBitStringValue]="";else{var A=o.bitStringContents.charCodeAt(0);if(A!==0)throw new Error("captureBitStringValue only supported for zero unused bits");c[a.captureBitStringValue]=o.bitStringContents.slice(1)}}else l&&l.push("["+a.name+'] Expected constructed "'+a.constructed+'", got "'+o.constructed+'"');else l&&(o.tagClass!==a.tagClass&&l.push("["+a.name+'] Expected tag class "'+a.tagClass+'", got "'+o.tagClass+'"'),o.type!==a.type&&l.push("["+a.name+'] Expected type "'+a.type+'", got "'+o.type+'"'));return u};var s=/[^\\u0000-\\u00ff]/;return e.prettyPrint=function(o,a,c){var l="";a=a||0,c=c||2,a>0&&(l+=`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { J as pe, S as fe } from "./sdk-vendor-
|
|
1
|
+
import { J as pe, S as fe } from "./sdk-vendor-8NuRpL1E.js";
|
|
2
2
|
import { V as y, E as ye, Q as ve, M as I, a as P, b as x, B as D, F as T, S as we, c as F, m as j, d as xe, P as be, C as k, e as Me, f as Ce, N as Ee, T as ke, L as Y, g as S, h as V, D as W, i as Le, j as G, k as ne, G as R, l as Se, n as Te, A as Pe, o as Ie, O as Ae, p as De, W as Ne, q as Re, r as H, s as ze, I as Ve, R as We } from "./three-vendor-M4ZIGmaO.js";
|
|
3
|
-
import { c as Be, a as _e, F as O, C as je, W as oe, L as Ge, E as He, r as Ue } from "./sdk-runtime-
|
|
4
|
-
import { r as A } from "./sdk-assets-
|
|
3
|
+
import { c as Be, a as _e, F as O, C as je, W as oe, L as Ge, E as He, r as Ue } from "./sdk-runtime-DE-ZoMSy.js";
|
|
4
|
+
import { r as A } from "./sdk-assets-CemZeVpH.js";
|
|
5
5
|
class Oe {
|
|
6
6
|
panel = null;
|
|
7
7
|
listEl = null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as si, G as ue, t as ot, O as Me, a as R, V as h, p as sn, u as Kn, W as oi, v as Yn, i as Ye, w as ri, x as Xn, y as Ge, b as O, Q as De, q as on, R as le, E as ai, z as rn, r as q, H as li, J as $n, M as N, j as B, I as Y, f as zt, K as Rt, U as an, X as ln, Y as bt, Z as Zn, _ as Jn, $ as Qn, a0 as Mi, D as de, a1 as wi, a2 as es, a3 as ts, C as Ne, d as cn, a4 as hn, a5 as ci, a6 as is, a7 as dn, B as we, a8 as ns, m as rt, a9 as ss, aa as os, ab as rs, ac as as, ad as ke, ae as Ct, af as un, ag as J, h as fe, ah as ls, ai as Qe, T as He, aj as cs, ak as St, al as Et, L as ze, o as lt, am as hs, an as pn, k as jt, ao as Pt, ap as ds, aq as Ke, ar as us, as as ps, at as mn, au as gn, F as At, g as Kt, av as ms, aw as xi, ax as Yt, ay as _t, s as at, az as gs, aA as fs, aB as bi, aC as ys, aD as Ci, aE as vs, aF as Ms, aG as ws, aH as xs, c as bs, aI as Cs, aJ as Ss, l as Es, aK as Ps, aL as As, aM as _s, aN as Si } from "./three-vendor-M4ZIGmaO.js";
|
|
2
|
-
import { W as re, C as Ts, b as Tt, B as Ei, g as Ae, L as Ds, E as Is, r as Ls } from "./sdk-runtime-
|
|
3
|
-
import { r as W, g as ks } from "./sdk-assets-
|
|
4
|
-
import { a as fn, J as Xt, c as zs, b as Rs, P as Bt, q as Bs, k as Fs, n as Pi, E as Ai, S as Os } from "./sdk-vendor-
|
|
5
|
-
import { L as Ns } from "./engine-2d-
|
|
2
|
+
import { W as re, C as Ts, b as Tt, B as Ei, g as Ae, L as Ds, E as Is, r as Ls } from "./sdk-runtime-DE-ZoMSy.js";
|
|
3
|
+
import { r as W, g as ks } from "./sdk-assets-CemZeVpH.js";
|
|
4
|
+
import { a as fn, J as Xt, c as zs, b as Rs, P as Bt, q as Bs, k as Fs, n as Pi, E as Ai, S as Os } from "./sdk-vendor-8NuRpL1E.js";
|
|
5
|
+
import { L as Ns } from "./engine-2d-qvKNkmsX.js";
|
|
6
6
|
var ye = /* @__PURE__ */ ((a) => (a.ModelLoadStart = "model-load-start", a.ModelLoadProgress = "model-load-progress", a.ModelLoaded = "model-loaded", a.ModelError = "model-error", a.SelectionChanged = "selection-changed", a.HoverChanged = "hover-changed", a.Click = "click", a.MouseMove = "mouse-move", a.ModelPlaceSelected = "model-place-selected", a.CameraChanged = "camera-changed", a.CameraIdle = "camera-idle", a.ViewportResize = "viewport-resize", a.EngineFree = "engine-free", a.EngineBusy = "engine-busy", a.MeasureChanged = "measure-changed", a.SectionMove = "section-move", a.LoadingCompleted = "loading_completed", a))(ye || {});
|
|
7
7
|
class Hs {
|
|
8
8
|
engine;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as R, au as S, h as E, aO as b, j as x, t as A, E as k, Q as F, p as I, W as y, a as v, T as f, i as P, Y as m, V as p, b as D } from "./three-vendor-M4ZIGmaO.js";
|
|
2
|
-
import { C as L, W as w, E as T, c as z, r as _ } from "./sdk-runtime-
|
|
2
|
+
import { C as L, W as w, E as T, c as z, r as _ } from "./sdk-runtime-DE-ZoMSy.js";
|
|
3
3
|
class V {
|
|
4
4
|
scene;
|
|
5
5
|
panoramaSphere = null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as Js, C as st, t as Zs, V as v, b as N, O as $s, W as en, M as J, Q as ge, a as tn, f as qt, j as be, B as sn, h as ft, r as it, aP as ze, aQ as Pt, aR as at, X as Bt, aS as ms, aT as yn, aU as xn, aV as In, aW as Tn, U as wn, aX as En, aY as Bn, l as lt, aZ as As, a_ as gs, a$ as vn, k as Cs, b0 as Fn, ax as Je, au as Ss, D as Kt, ak as bn, aO as ys, q as Dn, y as We, b1 as qe, aC as xs, s as Mn, b2 as Rn, a9 as Pn, b3 as On, b4 as nn, aE as Is, b5 as kn, ag as Ln, b6 as Ne, b7 as mt, p as Hn } from "./three-vendor-M4ZIGmaO.js";
|
|
2
|
-
import { C as Un, c as zn, E as _n, r as Qn } from "./sdk-runtime-
|
|
2
|
+
import { C as Un, c as zn, E as _n, r as Qn } from "./sdk-runtime-DE-ZoMSy.js";
|
|
3
3
|
var De = /* @__PURE__ */ ((m) => (m.LoadStart = "gaussian-load-start", m.LoadProgress = "gaussian-load-progress", m.Loaded = "gaussian-loaded", m.LoadError = "gaussian-load-error", m.SceneRemoved = "gaussian-scene-removed", m.FpsUpdated = "gaussian-fps-updated", m.ViewChanged = "gaussian-view-changed", m))(De || {});
|
|
4
4
|
class Nn {
|
|
5
5
|
listeners = /* @__PURE__ */ new Map();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as xX, J as KN } from "./sdk-vendor-
|
|
1
|
+
import { g as xX, J as KN } from "./sdk-vendor-8NuRpL1E.js";
|
|
2
2
|
import { b8 as Ii, b9 as TX } from "./three-vendor-M4ZIGmaO.js";
|
|
3
|
-
import { l as vX, L as EX, E as CX, d as JN, e as wX, c as $C, a as SX, f as IX, r as DX, h as XC } from "./sdk-runtime-
|
|
3
|
+
import { l as vX, L as EX, E as CX, d as JN, e as wX, c as $C, a as SX, f as IX, r as DX, h as XC } from "./sdk-runtime-DE-ZoMSy.js";
|
|
4
4
|
var QN = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
5
5
|
function Fb(e) {
|
|
6
6
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
@@ -2,7 +2,7 @@ import { ba as w } from "./three-vendor-M4ZIGmaO.js";
|
|
|
2
2
|
const S = "__BIM_ENGINE_SDK_ASSET_BASE__", b = "__BIM_ENGINE_SDK_ASSET_FILE_MAP__", g = "__BIM_ENGINE_SDK_ASSET_FILE_URLS__", A = "__BIM_ENGINE_SDK_ASSET_FILE_SESSION__", j = "https://unpkg.com/iflow-engine-base@3.9.20/dist/", L = "https://__bim_engine_sdk_asset__/", M = ["assets/", "fonts/", "draco/", "basis/", "texture/", "prompt/"];
|
|
3
3
|
let _ = null;
|
|
4
4
|
async function R() {
|
|
5
|
-
return _ || (_ = import("./sdk-vendor-
|
|
5
|
+
return _ || (_ = import("./sdk-vendor-8NuRpL1E.js").then((t) => t.j).then((t) => t.default ?? t)), _;
|
|
6
6
|
}
|
|
7
7
|
function a() {
|
|
8
8
|
return typeof globalThis < "u" ? globalThis : null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { R as ve, b as B, V as ce, t as Te, bb as Ce } from "./three-vendor-M4ZIGmaO.js";
|
|
2
|
-
import { a as pe, J as ne, p as Ae, l as J } from "./sdk-vendor-
|
|
2
|
+
import { a as pe, J as ne, p as Ae, l as J } from "./sdk-vendor-8NuRpL1E.js";
|
|
3
3
|
class It {
|
|
4
4
|
/**
|
|
5
5
|
* 构造函数
|
|
@@ -1056,7 +1056,7 @@ class jt {
|
|
|
1056
1056
|
e.stopImmediatePropagation();
|
|
1057
1057
|
};
|
|
1058
1058
|
}
|
|
1059
|
-
const ot = "3.11.
|
|
1059
|
+
const ot = "3.11.10", st = {
|
|
1060
1060
|
version: ot
|
|
1061
1061
|
}, V = st.version;
|
|
1062
1062
|
function se() {
|